1818#else
1919#include < unistd.h>
2020#endif
21+ #ifndef __STDC_NO_THREADS__
2122#include < threads.h>
23+ #endif
2224#include < volk/volk_prefs.h>
2325
2426void volk_get_config_path (char * path, bool read)
@@ -78,10 +80,12 @@ static struct volk_preferences {
7880 volk_arch_pref_t * volk_arch_prefs;
7981 size_t n_arch_prefs;
8082 int initialized;
83+ #ifndef __STDC_NO_THREADS__
8184 mtx_t mutex;
82-
85+ # endif
8386} volk_preferences;
8487
88+ #ifndef __STDC_NO_THREADS__
8589void init_struct_mutex (void )
8690{
8791 if (mtx_init (&volk_preferences.mutex , mtx_plain) != thrd_success) {
@@ -91,30 +95,39 @@ void init_struct_mutex(void)
9195
9296static once_flag mutex_init_once_flag = ONCE_FLAG_INIT;
9397void initialize_mutex () { call_once (&mutex_init_once_flag, init_struct_mutex); }
98+ #endif
9499
95100void volk_initialize_preferences ()
96101{
102+ #ifndef __STDC_NO_THREADS__
97103 initialize_mutex ();
98104 mtx_lock (&volk_preferences.mutex );
105+ #endif
99106 if (!volk_preferences.initialized ) {
100107 volk_preferences.n_arch_prefs =
101108 volk_load_preferences (&volk_preferences.volk_arch_prefs );
102109 volk_preferences.initialized = 1 ;
103110 }
111+ #ifndef __STDC_NO_THREADS__
104112 mtx_unlock (&volk_preferences.mutex );
113+ #endif
105114}
106115
107116
108117void volk_free_preferences ()
109118{
119+ #ifndef __STDC_NO_THREADS__
110120 initialize_mutex ();
111121 mtx_lock (&volk_preferences.mutex );
122+ #endif
112123 if (volk_preferences.initialized ) {
113124 free (volk_preferences.volk_arch_prefs );
114125 volk_preferences.n_arch_prefs = 0 ;
115126 volk_preferences.initialized = 0 ;
116127 }
128+ #ifndef __STDC_NO_THREADS__
117129 mtx_unlock (&volk_preferences.mutex );
130+ #endif
118131}
119132
120133
0 commit comments