QThread::currentThreadId: fix build on x32 (ILP32) ABI
On this ABI, pointers are 32-bit, so Qt::HANDLE (void *) is a 32-bit variable and the "movq" instruction is inappropriate. There's a GCC extended inline assembler modifier for the instruction size suffix (%z0) but Clang seems not to understand it. Instead, I just removed the suffix: we can do that because this is a memory load instruction, which implies the destination is a general purpose register (also required by the "=r" constraint) and therefore the assembler can determine the size of the memory load from the name of the selected register. Note: I did not verify this compiles on x32 at all, much less that it loads the right thing from memory. Fixes: QTBUG-122674 Pick-to: 6.6 6.5 Change-Id: I01ec3c774d9943adb903fffd17b6513d146e89ce Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit 08349ef0fe3902504987d12ebe0ed9674ed1e486) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
5fea2d374b
commit
f5738ab463
@ -151,13 +151,13 @@ inline Qt::HANDLE QThread::currentThreadId() noexcept
|
||||
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(__GLIBC__)) || defined(Q_OS_FREEBSD)) // x86 32-bit always uses GS
|
||||
__asm__("movl %%gs:%c1, %0" : "=r" (tid) : "i" (2 * sizeof(void*)) : );
|
||||
__asm__("mov %%gs:%c1, %0" : "=r" (tid) : "i" (2 * sizeof(void*)) : );
|
||||
#elif defined(Q_PROCESSOR_X86_64) && defined(Q_OS_DARWIN)
|
||||
// 64bit macOS uses GS, see https://github.com/apple/darwin-xnu/blob/master/libsyscall/os/tsd.h
|
||||
__asm__("movq %%gs:0, %0" : "=r" (tid) : : );
|
||||
__asm__("mov %%gs:0, %0" : "=r" (tid) : : );
|
||||
#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*)) : );
|
||||
__asm__("mov %%fs:%c1, %0" : "=r" (tid) : "i" (2 * sizeof(void*)) : );
|
||||
#elif defined(Q_PROCESSOR_X86_64) && defined(Q_OS_WIN)
|
||||
// See https://en.wikipedia.org/wiki/Win32_Thread_Information_Block
|
||||
// First get the pointer to the TIB
|
||||
|
Loading…
x
Reference in New Issue
Block a user