QThread: re-fix currentThreadId() on Linux
Commit 1808df9ce5 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>
bb10
parent
58d4645661
commit
f7152a4bb7
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue