From 3c12c3d58c5e27a5792eb85de994539c17ef2c38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 7 Jun 2023 00:47:27 +0200 Subject: [PATCH] Deprecate some older Apple platform defines Clang's macro deprecation pragma was introduced in Clang 14, shipped with Xcode 14.0. We can't version check Q_CC_CLANG here, as qcompilerdetection.h hasn't been included at this point. Nor would it have helped much, as we would have had to do so for each individual define we wanted to deprecate, since mentioning an undefined define in the deprecation pragma is an error. And we can't wrap the pragma in another macro that conditionally expands to _Pragma either, as the input argument is a define that needs to be passed on as is, without expanding it. So the simplest way to support < Xcode 14 is just to silence the unknown pragma warning. Pick-to: 6.6 Change-Id: Icf95042e6186deb212cd1793eb12ba32206ce34b Reviewed-by: Thiago Macieira --- src/corelib/global/qsystemdetection.h | 37 +++++++++++++++------------ src/corelib/thread/qthread.h | 2 +- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/corelib/global/qsystemdetection.h b/src/corelib/global/qsystemdetection.h index 09011c2131..ca94d552ec 100644 --- a/src/corelib/global/qsystemdetection.h +++ b/src/corelib/global/qsystemdetection.h @@ -54,11 +54,6 @@ # if defined(TARGET_OS_MAC) && TARGET_OS_MAC # define Q_OS_DARWIN # define Q_OS_BSD4 -# ifdef __LP64__ -# define Q_OS_DARWIN64 -# else -# define Q_OS_DARWIN32 -# endif # if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE # define QT_PLATFORM_UIKIT # if defined(TARGET_OS_WATCH) && TARGET_OS_WATCH @@ -154,17 +149,27 @@ // Compatibility synonyms #ifdef Q_OS_DARWIN -#define Q_OS_MAC -#endif -#ifdef Q_OS_DARWIN32 -#define Q_OS_MAC32 -#endif -#ifdef Q_OS_DARWIN64 -#define Q_OS_MAC64 -#endif -#ifdef Q_OS_MACOS -#define Q_OS_MACX -#define Q_OS_OSX +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wunknown-pragmas" +# define Q_OS_MAC // FIXME: Deprecate +# ifdef __LP64__ +# define Q_OS_DARWIN64 +# pragma clang deprecated(Q_OS_DARWIN64, "use Q_OS_DARWIN and QT_POINTER_SIZE/Q_PROCESSOR_* instead") +# define Q_OS_MAC64 +# pragma clang deprecated(Q_OS_MAC64, "use Q_OS_DARWIN and QT_POINTER_SIZE/Q_PROCESSOR_* instead") +# else +# define Q_OS_DARWIN32 +# pragma clang deprecated(Q_OS_DARWIN32, "use Q_OS_DARWIN and QT_POINTER_SIZE/Q_PROCESSOR_* instead") +# define Q_OS_MAC32 +# pragma clang deprecated(Q_OS_MAC32, "use Q_OS_DARWIN and QT_POINTER_SIZE/Q_PROCESSOR_* instead") +# endif +# ifdef Q_OS_MACOS +# define Q_OS_MACX +# pragma clang deprecated(Q_OS_MACX, "use Q_OS_MACOS instead") +# define Q_OS_OSX +# pragma clang deprecated(Q_OS_OSX, "use Q_OS_MACOS instead") +# endif +# pragma clang diagnostic pop #endif #ifdef Q_OS_DARWIN diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h index 6929961150..cea5aeb73c 100644 --- a/src/corelib/thread/qthread.h +++ b/src/corelib/thread/qthread.h @@ -158,7 +158,7 @@ inline Qt::HANDLE QThread::currentThreadId() noexcept // 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*)) : ); -#elif defined(Q_PROCESSOR_X86_64) && defined(Q_OS_DARWIN64) +#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) : : ); #elif defined(Q_PROCESSOR_X86_64) && ((defined(Q_OS_LINUX) && defined(__GLIBC__)) || defined(Q_OS_FREEBSD))