Index: include/__os_support =================================================================== --- include/__os_support +++ include/__os_support @@ -186,7 +186,71 @@ pthread_setspecific(__key, __p); } -#else // !_LIBCPP_THREAD_API_PTHREAD +#elif defined(_LIBCPP_THREAD_API_EXTERNAL) + +// Mutex +#define __OS_MUTEX_INITIALIZER 0 +struct __libcpp_mutex_external; +typedef __libcpp_mutex_external* __libcpp_mutex; + +int __os_mutex_init(__libcpp_mutex* __m, bool is_recursive); + +int __os_mutex_lock(__libcpp_mutex* __m); + +int __os_mutex_trylock(__libcpp_mutex* __m); + +int __os_mutex_unlock(__libcpp_mutex* __m); + +int __os_mutex_destroy(__libcpp_mutex* __m); + +// Condition variable +#define __OS_COND_INITIALIZER 0 +struct __libcpp_condvar_external; +typedef __libcpp_condvar_external* __libcpp_condvar; + +int __os_condvar_signal(__libcpp_condvar* __cv); + +int __os_condvar_broadcast(__libcpp_condvar* __cv); + +int __os_condvar_wait(__libcpp_condvar* __cv, __libcpp_mutex* __m); + +int __os_condvar_timedwait(__libcpp_condvar* __cv, __libcpp_mutex* __m, timespec* __ts); + +int __os_condvar_destroy(__libcpp_condvar* __cv); + +// Thread id +typedef unsigned long __libcpp_thread_id; + +int __os_thread_id_compare(__libcpp_thread_id t1, __libcpp_thread_id t2); + +// Thread +struct __libcpp_thread_external; +typedef __libcpp_thread_external* __libcpp_thread; + +template +int __os_thread_create(__libcpp_thread* __t, _Func&& __f, _Arg&& __arg); + +__libcpp_thread_id __os_thread_get_current_id(); + +__libcpp_thread_id __os_thread_get_id(const __libcpp_thread* __t); + +int __os_thread_join(__libcpp_thread* __t); + +int __os_thread_detach(__libcpp_thread* __t); + +void __os_thread_yield(); + +// Thread local storage +typedef unsigned long __libcpp_tl_key; + +template +int __os_tl_create(__libcpp_tl_key* __key, _Func&& __at_exit); + +void* __os_tl_get(__libcpp_tl_key __key); + +void __os_tl_set(__libcpp_tl_key __key, void* __p); + +#else #error "No thread API selected." #endif