diff --git a/libcutils/include/cutils/threads.h b/libcutils/include/cutils/threads.h index bbbba6d57..0f7f8a8c1 100644 --- a/libcutils/include/cutils/threads.h +++ b/libcutils/include/cutils/threads.h @@ -18,44 +18,21 @@ #include -#if !defined(_WIN32) -#include -#else +#if defined(_WIN32) #include +#else +#include #endif #ifdef __cplusplus extern "C" { #endif -#if !defined(_WIN32) - -typedef struct { - pthread_mutex_t lock; - int has_tls; - pthread_key_t tls; -} thread_store_t; - -#define THREAD_STORE_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, 0, 0 } - -#endif - // // Deprecated: use android::base::GetThreadId instead, which doesn't truncate on Mac/Windows. // extern pid_t gettid(); -// -// Deprecated: use `_Thread_local` in C or `thread_local` in C++. -// -#if !defined(_WIN32) -typedef void (*thread_store_destruct_t)(void* x); -extern void* thread_store_get(thread_store_t* x) - __attribute__((__deprecated__("use thread_local instead"))); -extern void thread_store_set(thread_store_t* x, void* y, thread_store_destruct_t z) - __attribute__((__deprecated__("use thread_local instead"))); -#endif - #ifdef __cplusplus } #endif diff --git a/libcutils/threads.cpp b/libcutils/threads.cpp index eac63b5b2..8cfee1e53 100644 --- a/libcutils/threads.cpp +++ b/libcutils/threads.cpp @@ -16,23 +16,18 @@ #include -// For gettid. #if defined(__APPLE__) -#include "AvailabilityMacros.h" // For MAC_OS_X_VERSION_MAX_ALLOWED #include -#include -#include -#include -#include -#elif defined(__linux__) && !defined(__ANDROID__) +#elif defined(__linux__) #include #include #elif defined(_WIN32) #include #endif +#if defined(__BIONIC__) // No definition needed for Android because we'll just pick up bionic's copy. -#ifndef __ANDROID__ +#else pid_t gettid() { #if defined(__APPLE__) uint64_t tid; @@ -44,31 +39,4 @@ pid_t gettid() { return GetCurrentThreadId(); #endif } -#endif // __ANDROID__ - -#if !defined(_WIN32) -void* thread_store_get( thread_store_t* store ) -{ - if (!store->has_tls) - return NULL; - - return pthread_getspecific( store->tls ); -} - -extern void thread_store_set( thread_store_t* store, - void* value, - thread_store_destruct_t destroy) -{ - pthread_mutex_lock( &store->lock ); - if (!store->has_tls) { - if (pthread_key_create( &store->tls, destroy) != 0) { - pthread_mutex_unlock(&store->lock); - return; - } - store->has_tls = 1; - } - pthread_mutex_unlock( &store->lock ); - - pthread_setspecific( store->tls, value ); -} #endif