From e2084b4a98d550bd5011a8b7de5014dd6c00412d Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Tue, 30 Aug 2022 00:20:13 -0700 Subject: [PATCH] macOS: Fix very old Xcode build --- CMakeLists.txt | 7 +++++++ include/mgba-util/common.h | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e4e99f964..f6a8ab221 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -240,6 +240,13 @@ if(APPLE) if(NOT CMAKE_SYSTEM_VERSION VERSION_LESS "10.0") # Darwin 10.x is Mac OS X 10.6 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mmacosx-version-min=10.6") endif() + # Not supported until Xcode 9 + if(CMAKE_C_COMPILER_ID STREQUAL "AppleClang" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "9") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__STDC_NO_THREADS__=1") + endif() + if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_NO_THREADS__=1") + endif() endif() if(NOT HAIKU AND NOT MSVC AND NOT PSP2) diff --git a/include/mgba-util/common.h b/include/mgba-util/common.h index 8f14706d3..4583ac0ed 100644 --- a/include/mgba-util/common.h +++ b/include/mgba-util/common.h @@ -84,6 +84,10 @@ typedef intptr_t ssize_t; #define M_PI 3.141592654f #endif +#if !defined(__cplusplus) && !defined(static_assert) +#define static_assert(X, C) _Static_assert((X), C) +#endif + #if !defined(_MSC_VER) && (defined(__llvm__) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) #define ATOMIC_STORE(DST, SRC) __atomic_store_n(&DST, SRC, __ATOMIC_RELEASE) #define ATOMIC_LOAD(DST, SRC) DST = __atomic_load_n(&SRC, __ATOMIC_ACQUIRE)