Index: include/__threading_support =================================================================== --- include/__threading_support +++ include/__threading_support @@ -192,7 +192,77 @@ pthread_setspecific(__key, __p); } -#else // !_LIBCPP_THREAD_API_PTHREAD +#elif defined(_LIBCPP_THREAD_API_EXTERNAL) + +// Mutex +#if !defined(_LIBCPP_MUTEX_INITIALIZER) + #error "_LIBCPP_MUTEX_INITIALIZER must be defined." +#endif +struct __libcpp_mutex_external; +typedef __libcpp_mutex_external* __libcpp_mutex_t; + +int __libcpp_recursive_mutex_init(__libcpp_mutex_t* __m); + +int __libcpp_mutex_lock(__libcpp_mutex_t* __m); + +int __libcpp_mutex_trylock(__libcpp_mutex_t* __m); + +int __libcpp_mutex_unlock(__libcpp_mutex_t* __m); + +int __libcpp_mutex_destroy(__libcpp_mutex_t* __m); + +// Condition variable +#if !defined(_LIBCPP_COND_INITIALIZER) + #error "_LIBCPP_COND_INITIALIZER must be defined." +#endif +struct __libcpp_condvar_external; +typedef __libcpp_condvar_external* __libcpp_condvar_t; + +int __libcpp_condvar_signal(__libcpp_condvar_t* __cv); + +int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv); + +int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m); + +int __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m, timespec* __ts); + +int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv); + +// Thread id +typedef unsigned long __libcpp_thread_id; + +// Returns non-zero if the thread ids are equal, otherwise 0 +int __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2); + +// Returns non-zero if t1 < t2, otherwise 0 +int __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2); + +// Thread +struct __libcpp_thread_external; +typedef __libcpp_thread_external* __libcpp_thread_t; + +int __libcpp_thread_create(__libcpp_thread_t* __t, void* (*__f)(void*), void* __arg); + +__libcpp_thread_id __libcpp_thread_get_current_id(); + +__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t); + +int __libcpp_thread_join(__libcpp_thread_t* __t); + +int __libcpp_thread_detach(__libcpp_thread_t* __t); + +void __libcpp_thread_yield(); + +// Thread local storage +typedef unsigned long __libcpp_tl_key; + +int __libcpp_tl_create(__libcpp_tl_key* __key, void (*__at_exit) (void*)); + +void* __libcpp_tl_get(__libcpp_tl_key __key); + +void __libcpp_tl_set(__libcpp_tl_key __key, void* __p); + +#else #error "No thread API selected." #endif