Remove thread_store_set()/thread_store_get().
C++ thread_local is less code to write, and performs better. All known
users have been moved over already.
Test: treehugger
Change-Id: Idaa2a58bf23342dae08dd6b9003d8f532839b351
diff --git a/libcutils/include/cutils/threads.h b/libcutils/include/cutils/threads.h
index bbbba6d..0f7f8a8 100644
--- a/libcutils/include/cutils/threads.h
+++ b/libcutils/include/cutils/threads.h
@@ -18,44 +18,21 @@
#include <sys/types.h>
-#if !defined(_WIN32)
-#include <pthread.h>
-#else
+#if defined(_WIN32)
#include <windows.h>
+#else
+#include <pthread.h>
#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 eac63b5..8cfee1e 100644
--- a/libcutils/threads.cpp
+++ b/libcutils/threads.cpp
@@ -16,23 +16,18 @@
#include <cutils/threads.h>
-// For gettid.
#if defined(__APPLE__)
-#include "AvailabilityMacros.h" // For MAC_OS_X_VERSION_MAX_ALLOWED
#include <stdint.h>
-#include <stdlib.h>
-#include <sys/syscall.h>
-#include <sys/time.h>
-#include <unistd.h>
-#elif defined(__linux__) && !defined(__ANDROID__)
+#elif defined(__linux__)
#include <syscall.h>
#include <unistd.h>
#elif defined(_WIN32)
#include <windows.h>
#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 @@
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