Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions bases/cmake-native/macos-arm/clang/lib/predefined_macros.txt
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ clang no __GCC_ATOMIC_POINTER_LOCK_FREE 2
clang no __GCC_ATOMIC_SHORT_LOCK_FREE 2
clang no __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1
clang no __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2
clang no __GCC_CONSTRUCTIVE_SIZE 64
clang no __GCC_DESTRUCTIVE_SIZE 256
clang no __GCC_HAVE_DWARF2_CFI_ASM 1
clang no __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
clang no __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ clang no __GCC_ATOMIC_POINTER_LOCK_FREE 2
clang no __GCC_ATOMIC_SHORT_LOCK_FREE 2
clang no __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1
clang no __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2
clang no __GCC_CONSTRUCTIVE_SIZE 64
clang no __GCC_DESTRUCTIVE_SIZE 256
clang no __GCC_HAVE_DWARF2_CFI_ASM 1
clang no __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
clang no __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ clang no __GCC_ATOMIC_POINTER_LOCK_FREE 2
clang no __GCC_ATOMIC_SHORT_LOCK_FREE 2
clang no __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1
clang no __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2
clang no __GCC_CONSTRUCTIVE_SIZE 64
clang no __GCC_DESTRUCTIVE_SIZE 64
clang no __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 1
clang no __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
clang no __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ clang no __GCC_ATOMIC_POINTER_LOCK_FREE 2
clang no __GCC_ATOMIC_SHORT_LOCK_FREE 2
clang no __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1
clang no __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2
clang no __GCC_CONSTRUCTIVE_SIZE 64
clang no __GCC_DESTRUCTIVE_SIZE 64
clang no __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 1
clang no __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
clang no __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
Expand Down
1 change: 1 addition & 0 deletions tests/tests/changes/.GH319.rto/default.1.1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fe_only -DTEST_NUMBER=1 --clang --c++17 Test_name.c
49 changes: 49 additions & 0 deletions tests/tests/changes/GH319.sft.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//type:fp
//options_all:--clang --c++17
//remark:[GH #319] The macOS clang bases define __GCC_CONSTRUCTIVE_SIZE and __GCC_DESTRUCTIVE_SIZE
// 10/15/26 [GH #319]
//
// Clang 19 and later predefine __GCC_CONSTRUCTIVE_SIZE and
// __GCC_DESTRUCTIVE_SIZE, and libc++ (<__new/interference_size.h>, reached by
// <new>, <string>, <vector>, <algorithm>, ...) uses them unconditionally from
// C++17 on to define std::hardware_constructive_interference_size and
// std::hardware_destructive_interference_size.
//
// The values depend on the target (Apple clang 21 gives 64 and 256 for arm64,
// 64 and 64 for x86_64), so the test checks that the macros are defined and
// usable the way libc++ uses them, not their values.

#if defined(__APPLE__) && defined(__clang__)

#ifndef __GCC_DESTRUCTIVE_SIZE
#error "__GCC_DESTRUCTIVE_SIZE is not defined"
#endif
#ifndef __GCC_CONSTRUCTIVE_SIZE
#error "__GCC_CONSTRUCTIVE_SIZE is not defined"
#endif

typedef decltype(sizeof(0)) size_t;

// As in libc++'s <__new/interference_size.h>.
inline constexpr size_t hardware_destructive_interference_size =
__GCC_DESTRUCTIVE_SIZE;
inline constexpr size_t hardware_constructive_interference_size =
__GCC_CONSTRUCTIVE_SIZE;

// Both are positive powers of two, and the destructive size (the one that
// avoids false sharing) is not smaller than the constructive one.
static_assert(hardware_constructive_interference_size > 0 &&
(hardware_constructive_interference_size &
(hardware_constructive_interference_size - 1)) == 0,
"constructive size is a power of two");
static_assert(hardware_destructive_interference_size > 0 &&
(hardware_destructive_interference_size &
(hardware_destructive_interference_size - 1)) == 0,
"destructive size is a power of two");
static_assert(hardware_destructive_interference_size >=
hardware_constructive_interference_size,
"destructive size is not smaller than constructive size");

#endif

int main() { return 0; }
Loading