forked from OSchip/llvm-project
[libc++] Revert the addition of _LIBCPP_HIDE_FROM_ABI and inline in __threading_support
This reverts commit 2722ac65
. As explained in D115906, this was actually
unnecessary and it broke the external threading configuration.
Differential Revision: https://reviews.llvm.org/D119484
This commit is contained in:
parent
7338227882
commit
c74b192404
|
@ -254,7 +254,6 @@ int __libcpp_tls_set(__libcpp_tls_key __key, void *__p);
|
|||
|
||||
#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m)
|
||||
{
|
||||
pthread_mutexattr_t attr;
|
||||
|
@ -279,88 +278,74 @@ int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m)
|
|||
return 0;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m)
|
||||
{
|
||||
return pthread_mutex_lock(__m);
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m)
|
||||
{
|
||||
return pthread_mutex_trylock(__m) == 0;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m)
|
||||
{
|
||||
return pthread_mutex_unlock(__m);
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m)
|
||||
{
|
||||
return pthread_mutex_destroy(__m);
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
int __libcpp_mutex_lock(__libcpp_mutex_t *__m)
|
||||
{
|
||||
return pthread_mutex_lock(__m);
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
bool __libcpp_mutex_trylock(__libcpp_mutex_t *__m)
|
||||
{
|
||||
return pthread_mutex_trylock(__m) == 0;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
int __libcpp_mutex_unlock(__libcpp_mutex_t *__m)
|
||||
{
|
||||
return pthread_mutex_unlock(__m);
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
int __libcpp_mutex_destroy(__libcpp_mutex_t *__m)
|
||||
{
|
||||
return pthread_mutex_destroy(__m);
|
||||
}
|
||||
|
||||
// Condition Variable
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
int __libcpp_condvar_signal(__libcpp_condvar_t *__cv)
|
||||
{
|
||||
return pthread_cond_signal(__cv);
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
int __libcpp_condvar_broadcast(__libcpp_condvar_t *__cv)
|
||||
{
|
||||
return pthread_cond_broadcast(__cv);
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
int __libcpp_condvar_wait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m)
|
||||
{
|
||||
return pthread_cond_wait(__cv, __m);
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
|
||||
__libcpp_timespec_t *__ts)
|
||||
{
|
||||
return pthread_cond_timedwait(__cv, __m, __ts);
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
int __libcpp_condvar_destroy(__libcpp_condvar_t *__cv)
|
||||
{
|
||||
return pthread_cond_destroy(__cv);
|
||||
}
|
||||
|
||||
// Execute once
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
int __libcpp_execute_once(__libcpp_exec_once_flag *flag,
|
||||
void (*init_routine)()) {
|
||||
return pthread_once(flag, init_routine);
|
||||
|
@ -368,40 +353,34 @@ int __libcpp_execute_once(__libcpp_exec_once_flag *flag,
|
|||
|
||||
// Thread id
|
||||
// Returns non-zero if the thread ids are equal, otherwise 0
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2)
|
||||
{
|
||||
return t1 == t2;
|
||||
}
|
||||
|
||||
// Returns non-zero if t1 < t2, otherwise 0
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2)
|
||||
{
|
||||
return t1 < t2;
|
||||
}
|
||||
|
||||
// Thread
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) {
|
||||
return __libcpp_thread_get_id(__t) == 0;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
|
||||
void *__arg)
|
||||
{
|
||||
return pthread_create(__t, nullptr, __func, __arg);
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
__libcpp_thread_id __libcpp_thread_get_current_id()
|
||||
{
|
||||
const __libcpp_thread_t thread = pthread_self();
|
||||
return __libcpp_thread_get_id(&thread);
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t)
|
||||
{
|
||||
#if defined(__MVS__)
|
||||
|
@ -411,25 +390,21 @@ __libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t)
|
|||
#endif
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
int __libcpp_thread_join(__libcpp_thread_t *__t)
|
||||
{
|
||||
return pthread_join(*__t, nullptr);
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
int __libcpp_thread_detach(__libcpp_thread_t *__t)
|
||||
{
|
||||
return pthread_detach(*__t);
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
void __libcpp_thread_yield()
|
||||
{
|
||||
sched_yield();
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns)
|
||||
{
|
||||
__libcpp_timespec_t __ts = _VSTD::__convert_to_timespec<__libcpp_timespec_t>(__ns);
|
||||
|
@ -437,19 +412,16 @@ void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns)
|
|||
}
|
||||
|
||||
// Thread local storage
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
int __libcpp_tls_create(__libcpp_tls_key *__key, void (*__at_exit)(void *))
|
||||
{
|
||||
return pthread_key_create(__key, __at_exit);
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
void *__libcpp_tls_get(__libcpp_tls_key __key)
|
||||
{
|
||||
return pthread_getspecific(__key);
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
int __libcpp_tls_set(__libcpp_tls_key __key, void *__p)
|
||||
{
|
||||
return pthread_setspecific(__key, __p);
|
||||
|
@ -457,56 +429,47 @@ int __libcpp_tls_set(__libcpp_tls_key __key, void *__p)
|
|||
|
||||
#elif defined(_LIBCPP_HAS_THREAD_API_C11)
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m)
|
||||
{
|
||||
return mtx_init(__m, mtx_plain | mtx_recursive) == thrd_success ? 0 : EINVAL;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m)
|
||||
{
|
||||
return mtx_lock(__m) == thrd_success ? 0 : EINVAL;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m)
|
||||
{
|
||||
return mtx_trylock(__m) == thrd_success;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m)
|
||||
{
|
||||
return mtx_unlock(__m) == thrd_success ? 0 : EINVAL;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m)
|
||||
{
|
||||
mtx_destroy(__m);
|
||||
return 0;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
int __libcpp_mutex_lock(__libcpp_mutex_t *__m)
|
||||
{
|
||||
return mtx_lock(__m) == thrd_success ? 0 : EINVAL;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
bool __libcpp_mutex_trylock(__libcpp_mutex_t *__m)
|
||||
{
|
||||
return mtx_trylock(__m) == thrd_success;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
int __libcpp_mutex_unlock(__libcpp_mutex_t *__m)
|
||||
{
|
||||
return mtx_unlock(__m) == thrd_success ? 0 : EINVAL;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
int __libcpp_mutex_destroy(__libcpp_mutex_t *__m)
|
||||
{
|
||||
mtx_destroy(__m);
|
||||
|
@ -514,25 +477,21 @@ int __libcpp_mutex_destroy(__libcpp_mutex_t *__m)
|
|||
}
|
||||
|
||||
// Condition Variable
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
int __libcpp_condvar_signal(__libcpp_condvar_t *__cv)
|
||||
{
|
||||
return cnd_signal(__cv) == thrd_success ? 0 : EINVAL;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
int __libcpp_condvar_broadcast(__libcpp_condvar_t *__cv)
|
||||
{
|
||||
return cnd_broadcast(__cv) == thrd_success ? 0 : EINVAL;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
int __libcpp_condvar_wait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m)
|
||||
{
|
||||
return cnd_wait(__cv, __m) == thrd_success ? 0 : EINVAL;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
|
||||
timespec *__ts)
|
||||
{
|
||||
|
@ -540,7 +499,6 @@ int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
|
|||
return __ec == thrd_timedout ? ETIMEDOUT : __ec;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
int __libcpp_condvar_destroy(__libcpp_condvar_t *__cv)
|
||||
{
|
||||
cnd_destroy(__cv);
|
||||
|
@ -548,7 +506,6 @@ int __libcpp_condvar_destroy(__libcpp_condvar_t *__cv)
|
|||
}
|
||||
|
||||
// Execute once
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
int __libcpp_execute_once(__libcpp_exec_once_flag *flag,
|
||||
void (*init_routine)(void)) {
|
||||
::call_once(flag, init_routine);
|
||||
|
@ -557,26 +514,22 @@ int __libcpp_execute_once(__libcpp_exec_once_flag *flag,
|
|||
|
||||
// Thread id
|
||||
// Returns non-zero if the thread ids are equal, otherwise 0
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2)
|
||||
{
|
||||
return thrd_equal(t1, t2) != 0;
|
||||
}
|
||||
|
||||
// Returns non-zero if t1 < t2, otherwise 0
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2)
|
||||
{
|
||||
return t1 < t2;
|
||||
}
|
||||
|
||||
// Thread
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) {
|
||||
return __libcpp_thread_get_id(__t) == 0;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
|
||||
void *__arg)
|
||||
{
|
||||
|
@ -584,37 +537,31 @@ int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
|
|||
return __ec == thrd_nomem ? ENOMEM : __ec;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
__libcpp_thread_id __libcpp_thread_get_current_id()
|
||||
{
|
||||
return thrd_current();
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t)
|
||||
{
|
||||
return *__t;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
int __libcpp_thread_join(__libcpp_thread_t *__t)
|
||||
{
|
||||
return thrd_join(*__t, nullptr) == thrd_success ? 0 : EINVAL;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
int __libcpp_thread_detach(__libcpp_thread_t *__t)
|
||||
{
|
||||
return thrd_detach(*__t) == thrd_success ? 0 : EINVAL;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
void __libcpp_thread_yield()
|
||||
{
|
||||
thrd_yield();
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns)
|
||||
{
|
||||
__libcpp_timespec_t __ts = _VSTD::__convert_to_timespec<__libcpp_timespec_t>(__ns);
|
||||
|
@ -622,19 +569,16 @@ void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns)
|
|||
}
|
||||
|
||||
// Thread local storage
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
int __libcpp_tls_create(__libcpp_tls_key *__key, void (*__at_exit)(void *))
|
||||
{
|
||||
return tss_create(__key, __at_exit) == thrd_success ? 0 : EINVAL;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
void *__libcpp_tls_get(__libcpp_tls_key __key)
|
||||
{
|
||||
return tss_get(__key);
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
int __libcpp_tls_set(__libcpp_tls_key __key, void *__p)
|
||||
{
|
||||
return tss_set(__key, __p) == thrd_success ? 0 : EINVAL;
|
||||
|
|
Loading…
Reference in New Issue