summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread/qthread.h
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2024-02-22 16:53:51 -0600
committerThiago Macieira <thiago.macieira@intel.com>2024-02-25 18:29:38 -0600
commit08349ef0fe3902504987d12ebe0ed9674ed1e486 (patch)
treed882c08aa69e0fab7fbd892865fcff1af6b73aed /src/corelib/thread/qthread.h
parent90a6415bedfc4ce1a934c3a36271b20c1a6a606a (diff)
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.5 6.6 6.7 Change-Id: I01ec3c774d9943adb903fffd17b6513d146e89ce Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/corelib/thread/qthread.h')
-rw-r--r--src/corelib/thread/qthread.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h
index 32a0bb703e..a4b7183b5a 100644
--- a/src/corelib/thread/qthread.h
+++ b/src/corelib/thread/qthread.h
@@ -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