summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread/qthread.h
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-08-25 11:36:50 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-08-26 01:11:48 +0200
commitf3eb9aa257340913b88d890dc437da4d412d755a (patch)
tree1108fefa90107458b800b21de44f9a286616b42a /src/corelib/thread/qthread.h
parent75cd9c13c2c6130d51ccacd7f1247bdc2628e4b3 (diff)
Android: Fix currentThreadId to work on Android emulator
Apparently the Linux asm assumptions are not correct for the x86 Android emulator and this caused Android apps not to work properly: signal connections being queued instead of being direct, crashes in QPropertyAnimation, etc. Using currentThreadIdImpl on the Android emulator works fine though. Optimizing the code for the Android emulator case can be done in another change. Amends 5e9b2ade678f37e43bfc2e3484f54cbbb5844d2e Fixes: QTBUG-85640 Change-Id: I3b3ba76ea143aed949a6e50678c850b6ba231476 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/corelib/thread/qthread.h')
-rw-r--r--src/corelib/thread/qthread.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h
index caa91b100f..49224c81e6 100644
--- a/src/corelib/thread/qthread.h
+++ b/src/corelib/thread/qthread.h
@@ -182,12 +182,12 @@ inline Qt::HANDLE QThread::currentThreadId() noexcept
Qt::HANDLE tid; // typedef to void*
static_assert(sizeof(tid) == sizeof(void*));
// See https://akkadia.org/drepper/tls.pdf for x86 ABI
-#if defined(Q_PROCESSOR_X86_32) && defined(Q_OS_LINUX) // x86 32-bit always uses GS
+#if defined(Q_PROCESSOR_X86_32) && defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID) // x86 32-bit always uses GS
__asm__("movl %%gs:0, %0" : "=r" (tid) : : );
#elif defined(Q_PROCESSOR_X86_64) && defined(Q_OS_DARWIN64)
// 64bit macOS uses GS, see https://github.com/apple/darwin-xnu/blob/master/libsyscall/os/tsd.h
__asm__("movq %%gs:0, %0" : "=r" (tid) : : );
-#elif defined(Q_PROCESSOR_X86_64) && (defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD))
+#elif defined(Q_PROCESSOR_X86_64) && (defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)) && !defined(Q_OS_ANDROID)
// x86_64 Linux, BSD uses FS
__asm__("movq %%fs:0, %0" : "=r" (tid) : : );
#else