18
18
#else
19
19
#include < unistd.h>
20
20
#endif
21
+ #ifndef __STDC_NO_THREADS__
21
22
#include < threads.h>
23
+ #endif
22
24
#include < volk/volk_prefs.h>
23
25
24
26
void volk_get_config_path (char * path, bool read)
@@ -78,10 +80,12 @@ static struct volk_preferences {
78
80
volk_arch_pref_t * volk_arch_prefs;
79
81
size_t n_arch_prefs;
80
82
int initialized;
83
+ #ifndef __STDC_NO_THREADS__
81
84
mtx_t mutex;
82
-
85
+ # endif
83
86
} volk_preferences;
84
87
88
+ #ifndef __STDC_NO_THREADS__
85
89
void init_struct_mutex (void )
86
90
{
87
91
if (mtx_init (&volk_preferences.mutex , mtx_plain) != thrd_success) {
@@ -91,30 +95,39 @@ void init_struct_mutex(void)
91
95
92
96
static once_flag mutex_init_once_flag = ONCE_FLAG_INIT;
93
97
void initialize_mutex () { call_once (&mutex_init_once_flag, init_struct_mutex); }
98
+ #endif
94
99
95
100
void volk_initialize_preferences ()
96
101
{
102
+ #ifndef __STDC_NO_THREADS__
97
103
initialize_mutex ();
98
104
mtx_lock (&volk_preferences.mutex );
105
+ #endif
99
106
if (!volk_preferences.initialized ) {
100
107
volk_preferences.n_arch_prefs =
101
108
volk_load_preferences (&volk_preferences.volk_arch_prefs );
102
109
volk_preferences.initialized = 1 ;
103
110
}
111
+ #ifndef __STDC_NO_THREADS__
104
112
mtx_unlock (&volk_preferences.mutex );
113
+ #endif
105
114
}
106
115
107
116
108
117
void volk_free_preferences ()
109
118
{
119
+ #ifndef __STDC_NO_THREADS__
110
120
initialize_mutex ();
111
121
mtx_lock (&volk_preferences.mutex );
122
+ #endif
112
123
if (volk_preferences.initialized ) {
113
124
free (volk_preferences.volk_arch_prefs );
114
125
volk_preferences.n_arch_prefs = 0 ;
115
126
volk_preferences.initialized = 0 ;
116
127
}
128
+ #ifndef __STDC_NO_THREADS__
117
129
mtx_unlock (&volk_preferences.mutex );
130
+ #endif
118
131
}
119
132
120
133
0 commit comments