Index: include/__threading_support =================================================================== --- include/__threading_support +++ include/__threading_support @@ -183,7 +183,75 @@ 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_mutex_init(__libcpp_mutex_t* __m, bool is_recursive); + +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; + +int __libcpp_thread_id_compare(__libcpp_thread_id t1, __libcpp_thread_id t2); + +// Thread +struct __libcpp_thread_external; +typedef __libcpp_thread_external* __libcpp_thread_t; + +template +int __libcpp_thread_create(__libcpp_thread_t* __t, _Func&& __f, _Arg&& __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; + +template +int __libcpp_tl_create(__libcpp_tl_key* __key, _Func&& __at_exit); + +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