summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread/qthread.h
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2022-05-03 10:10:07 -0700
committerThiago Macieira <thiago.macieira@intel.com>2022-05-04 20:15:36 -0700
commitf7152a4bb78676cb211ac3c3e1e59aa53a307491 (patch)
tree6e947b41d3f99980a8b2d57a264bb72e91fafb8d /src/corelib/thread/qthread.h
parent58d464566160383b8e53d17a53629b9c06684c7a (diff)
QThread: re-fix currentThreadId() on Linux
Commit 1808df9ce59a8c1d426f0361e25120a7852a6442 changed the Linux code to read the third field in the TCB header instead of the first, because that matches what FreeBSD does and what the documentation for the ABI appears to say. But it broke MUSL builds because they apparently don't obey the ABI. So don't use the inline code with libcs other than glibc. Pick-to: 6.2 6.3 Task-number: QTBUG-103000 Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16eba7748de50ddd Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Mike Achtelik <mike.achtelik@gmail.com>
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 45c5ab9487..934db4f7c3 100644
--- a/src/corelib/thread/qthread.h
+++ b/src/corelib/thread/qthread.h
@@ -191,12 +191,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) && !defined(Q_OS_ANDROID) // x86 32-bit always uses GS
+#if defined(Q_PROCESSOR_X86_32) && defined(Q_OS_LINUX) && defined(__GLIBC__) // x86 32-bit always uses GS
__asm__("movl %%gs:%c1, %0" : "=r" (tid) : "i" (2 * sizeof(void*)) : );
#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)) && !defined(Q_OS_ANDROID)
+#elif defined(Q_PROCESSOR_X86_64) && (defined(Q_OS_LINUX) && defined(__GLIBC__)) || defined(Q_OS_FREEBSD)
// x86_64 Linux, BSD uses FS
__asm__("movq %%fs:%c1, %0" : "=r" (tid) : "i" (2 * sizeof(void*)) : );
#elif defined(Q_PROCESSOR_X86_64) && defined(Q_OS_WIN)