external/vixl/src \
external/zlib \
+# We optimize Thread::Current() with a direct TLS access. This requires access to a private
+# Bionic header.
+# Note: technically we only need this on device, but this avoids the duplication of the includes.
+ART_C_INCLUDES += bionic/libc/private
+
# Base set of cflags used by all things ART.
art_cflags := \
-fno-rtti \
#include "thread.h"
+#ifdef __ANDROID__
+#include <bionic_tls.h> // Access to our own TLS slot.
+#endif
+
#include <pthread.h>
#include "base/casts.h"
if (!is_started_) {
return nullptr;
} else {
+#ifdef __ANDROID__
+ void* thread = __get_tls()[TLS_SLOT_ART_THREAD_SELF];
+#else
void* thread = pthread_getspecific(Thread::pthread_key_self_);
+#endif
return reinterpret_cast<Thread*>(thread);
}
}
InitCardTable();
InitTid();
+#ifdef __ANDROID__
+ __get_tls()[TLS_SLOT_ART_THREAD_SELF] = this;
+#else
CHECK_PTHREAD_CALL(pthread_setspecific, (Thread::pthread_key_self_, this), "attach self");
+#endif
DCHECK_EQ(Thread::Current(), this);
tls32_.thin_lock_thread_id = thread_list->AllocThreadId(this);
LOG(WARNING) << "Native thread exiting without having called DetachCurrentThread (maybe it's "
"going to use a pthread_key_create destructor?): " << *self;
CHECK(is_started_);
+#ifdef __ANDROID__
+ __get_tls()[TLS_SLOT_ART_THREAD_SELF] = self;
+#else
CHECK_PTHREAD_CALL(pthread_setspecific, (Thread::pthread_key_self_, self), "reattach self");
+#endif
self->tls32_.thread_exit_check_count = 1;
} else {
LOG(FATAL) << "Native thread exited without calling DetachCurrentThread: " << *self;
// Clear the TLS data, so that the underlying native thread is recognizably detached.
// (It may wish to reattach later.)
+#ifdef __ANDROID__
+ __get_tls()[TLS_SLOT_ART_THREAD_SELF] = nullptr;
+#else
CHECK_PTHREAD_CALL(pthread_setspecific, (Thread::pthread_key_self_, nullptr), "detach self");
+#endif
// Signal that a thread just detached.
MutexLock mu(nullptr, *Locks::thread_list_lock_);