From b1c57d13eecc208408b7ed05f888d7625fb6e251 Mon Sep 17 00:00:00 2001 From: "Tobias C. Berner" Date: Sat, 20 Aug 2022 11:36:28 +0200 Subject: [PATCH] qthread.h: fix logic for Q_OS_FREEBSD and add support for 32bit FreeBSD Fails to compile on i386 on FreeBSD with: In file included from /wrkdirs/usr/ports/devel/qt6-base/work/qtbase-everywhere-src-6.3.1/src/corelib/thread/qmutex.cpp:49: /wrkdirs/usr/ports/devel/qt6-base/work/qtbase-everywhere-src-6.3.1/src/corelib/thread/qthread.h:201:13: error: invalid operand for instruction __asm__("movq %%fs:%c1, %0" : "=r" (tid) : "i" (2 * sizeof(void*)) : ); ^ :1:14: note: instantiated into assembly here movq %fs:8, %edi ^~~~ 1 error generated. Pick-to: 6.2 6.3 6.4 Change-Id: I0a71e4631d7b6d452083d3ca8e35759e5dc563d4 Reviewed-by: Thiago Macieira --- src/corelib/thread/qthread.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h index 4cea76cf77..d856d8daa8 100644 --- a/src/corelib/thread/qthread.h +++ b/src/corelib/thread/qthread.h @@ -155,12 +155,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(__GLIBC__) // x86 32-bit always uses GS +#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*)) : ); #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(__GLIBC__)) || defined(Q_OS_FREEBSD) +#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)