99#else
1010#include <unistd.h>
1111#endif
12+ #ifndef __STDC_NO_THREADS__
1213#include <threads.h>
14+ #endif
1315#include <volk/volk_prefs.h>
1416
1517void volk_get_config_path (char * path , bool read )
@@ -69,10 +71,12 @@ static struct volk_preferences {
6971 volk_arch_pref_t * volk_arch_prefs ;
7072 size_t n_arch_prefs ;
7173 int initialized ;
74+ #ifndef __STDC_NO_THREADS__
7275 mtx_t mutex ;
73-
76+ #endif
7477} volk_preferences ;
7578
79+ #ifndef __STDC_NO_THREADS__
7680void init_struct_mutex (void )
7781{
7882 if (mtx_init (& volk_preferences .mutex , mtx_plain ) != thrd_success ) {
@@ -82,30 +86,39 @@ void init_struct_mutex(void)
8286
8387static once_flag mutex_init_once_flag = ONCE_FLAG_INIT ;
8488void initialize_mutex () { call_once (& mutex_init_once_flag , init_struct_mutex ); }
89+ #endif
8590
8691void volk_initialize_preferences ()
8792{
93+ #ifndef __STDC_NO_THREADS__
8894 initialize_mutex ();
8995 mtx_lock (& volk_preferences .mutex );
96+ #endif
9097 if (!volk_preferences .initialized ) {
9198 volk_preferences .n_arch_prefs =
9299 volk_load_preferences (& volk_preferences .volk_arch_prefs );
93100 volk_preferences .initialized = 1 ;
94101 }
102+ #ifndef __STDC_NO_THREADS__
95103 mtx_unlock (& volk_preferences .mutex );
104+ #endif
96105}
97106
98107
99108void volk_free_preferences ()
100109{
110+ #ifndef __STDC_NO_THREADS__
101111 initialize_mutex ();
102112 mtx_lock (& volk_preferences .mutex );
113+ #endif
103114 if (volk_preferences .initialized ) {
104115 free (volk_preferences .volk_arch_prefs );
105116 volk_preferences .n_arch_prefs = 0 ;
106117 volk_preferences .initialized = 0 ;
107118 }
119+ #ifndef __STDC_NO_THREADS__
108120 mtx_unlock (& volk_preferences .mutex );
121+ #endif
109122}
110123
111124
0 commit comments