summaryrefslogtreecommitdiffstats
path: root/libcutils/threads.c
diff options
context:
space:
mode:
authorDan Albert <danalbert@google.com>2015-04-29 17:13:32 -0700
committerDan Albert <danalbert@google.com>2015-04-29 17:13:32 -0700
commitb3a36ca5ee79411c18984b85b224d9285b4468af (patch)
tree2ecb7737cd5c2a9577725a8f9777382d6857b5fc /libcutils/threads.c
parent0c4b3a319d2bc3dbc917e869af34e24788e6fc48 (diff)
downloadcore-b3a36ca5ee79411c18984b85b224d9285b4468af.tar.gz
core-b3a36ca5ee79411c18984b85b224d9285b4468af.tar.bz2
core-b3a36ca5ee79411c18984b85b224d9285b4468af.zip
Fix gettid() on Windows.
Accidentally had this all hidden by an #ifndef _WIN32 when I wrote it. Change-Id: I3a6afefe23b799ea7aa0f9a380f5a743673096d0
Diffstat (limited to 'libcutils/threads.c')
-rw-r--r--libcutils/threads.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/libcutils/threads.c b/libcutils/threads.c
index 5f5577b42..3d8dd4848 100644
--- a/libcutils/threads.c
+++ b/libcutils/threads.c
@@ -16,8 +16,6 @@
#include "cutils/threads.h"
-#if !defined(_WIN32)
-
// For gettid.
#if defined(__APPLE__)
#include "AvailabilityMacros.h" // For MAC_OS_X_VERSION_MAX_ALLOWED
@@ -30,9 +28,29 @@
#include <syscall.h>
#include <unistd.h>
#elif defined(_WIN32)
-#include <Windows.h>
+#include <windows.h>
#endif
+// No definition needed for Android because we'll just pick up bionic's copy.
+#ifndef __ANDROID__
+pid_t gettid() {
+#if defined(__APPLE__)
+ uint64_t owner;
+ int rc = pthread_threadid_np(NULL, &owner);
+ if (rc != 0) {
+ abort();
+ }
+ return owner;
+#elif defined(__linux__)
+ return syscall(__NR_gettid);
+#elif defined(_WIN32)
+ return GetCurrentThreadId();
+#endif
+}
+#endif // __ANDROID__
+
+#if !defined(_WIN32)
+
void* thread_store_get( thread_store_t* store )
{
if (!store->has_tls)
@@ -58,24 +76,6 @@ extern void thread_store_set( thread_store_t* store,
pthread_setspecific( store->tls, value );
}
-// No definition needed for Android because we'll just pick up bionic's copy.
-#ifndef __ANDROID__
-pid_t gettid() {
-#if defined(__APPLE__)
- uint64_t owner;
- int rc = pthread_threadid_np(NULL, &owner);
- if (rc != 0) {
- abort();
- }
- return owner;
-#elif defined(__linux__)
- return syscall(__NR_gettid);
-#elif defined(_WIN32)
- return (pid_t)GetCurrentThreadId();
-#endif
-}
-#endif // __ANDROID__
-
#else /* !defined(_WIN32) */
void* thread_store_get( thread_store_t* store )
{