Skip to content

Commit 8bb6933

Browse files
committed
Solve MacOs compile errors and threading atomic detection.
1 parent a731c17 commit 8bb6933

File tree

7 files changed

+23
-21
lines changed

7 files changed

+23
-21
lines changed

cmake/CompileOptions.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ include(Portability)
3737
# Test for GNU 4.9+, Clang 3.6+ or ((Visual Studio C++ or Clang with MSVC backend) and Visual Studio 2022 or superior)
3838
if(("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND ${CMAKE_C_COMPILER_VERSION} VERSION_GREATER 4.9) OR
3939
((("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") OR
40-
("${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang")) AND AND ${CMAKE_C_COMPILER_VERSION} VERSION_GREATER 3.6) OR
40+
("${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang")) AND ${CMAKE_C_COMPILER_VERSION} VERSION_GREATER 3.6) OR
4141
(
4242
(("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") OR
4343
(("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") AND ("${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "MSVC"))) AND

source/benchmarks/metacall_py_c_api_bench/source/metacall_py_c_api_bench.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,4 @@ BENCHMARK_REGISTER_F(metacall_py_c_api_bench, call_object)
150150
->Iterations(1)
151151
->Repetitions(5);
152152

153-
BENCHMARK_MAIN();
153+
BENCHMARK_MAIN();

source/tests/sanitizer/tsan.supp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
# NodeJS
1717
#
1818
race:v8::platform::tracing::TracingController::GetCategoryGroupEnabled
19-
# TODO: Review this race condition, it started to happen after NodeJS v12
2019
race:v8::platform::DefaultJobWorker::~DefaultJobWorker()
20+
race:v8::platform::DefaultJobState::~DefaultJobState
2121
#
2222
# Ruby
2323
#

source/threading/include/threading/threading_atomic_ref_count.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ typedef struct threading_atomic_ref_count_type *threading_atomic_ref_count;
6262

6363
/* -- Methods -- */
6464

65-
inline void threading_atomic_ref_count_store(threading_atomic_ref_count ref, uintmax_t v)
65+
static inline void threading_atomic_ref_count_store(threading_atomic_ref_count ref, uintmax_t v)
6666
{
6767
#if defined(__THREAD_SANITIZER__)
6868
threading_mutex_store(&ref->m, &ref->count, &v, sizeof(uintmax_t));
@@ -71,7 +71,7 @@ inline void threading_atomic_ref_count_store(threading_atomic_ref_count ref, uin
7171
#endif
7272
}
7373

74-
inline void threading_atomic_ref_count_initialize(threading_atomic_ref_count ref)
74+
static inline void threading_atomic_ref_count_initialize(threading_atomic_ref_count ref)
7575
{
7676
#if defined(__THREAD_SANITIZER__)
7777
uintmax_t init = THREADING_ATOMIC_REF_COUNT_MIN;
@@ -84,7 +84,7 @@ inline void threading_atomic_ref_count_initialize(threading_atomic_ref_count ref
8484
#endif
8585
}
8686

87-
inline uintmax_t threading_atomic_ref_count_load(threading_atomic_ref_count ref)
87+
static inline uintmax_t threading_atomic_ref_count_load(threading_atomic_ref_count ref)
8888
{
8989
#if defined(__THREAD_SANITIZER__)
9090
uintmax_t result = 0;
@@ -97,7 +97,7 @@ inline uintmax_t threading_atomic_ref_count_load(threading_atomic_ref_count ref)
9797
#endif
9898
}
9999

100-
inline int threading_atomic_ref_count_increment(threading_atomic_ref_count ref)
100+
static inline int threading_atomic_ref_count_increment(threading_atomic_ref_count ref)
101101
{
102102
#if defined(__THREAD_SANITIZER__)
103103
threading_mutex_lock(&ref->m);
@@ -117,7 +117,7 @@ inline int threading_atomic_ref_count_increment(threading_atomic_ref_count ref)
117117
return 0;
118118
}
119119

120-
inline int threading_atomic_ref_count_decrement(threading_atomic_ref_count ref)
120+
static inline int threading_atomic_ref_count_decrement(threading_atomic_ref_count ref)
121121
{
122122
#if defined(__THREAD_SANITIZER__)
123123
threading_mutex_lock(&ref->m);
@@ -142,7 +142,7 @@ inline int threading_atomic_ref_count_decrement(threading_atomic_ref_count ref)
142142
return 0;
143143
}
144144

145-
inline void threading_atomic_ref_count_destroy(threading_atomic_ref_count ref)
145+
static inline void threading_atomic_ref_count_destroy(threading_atomic_ref_count ref)
146146
{
147147
#if defined(__THREAD_SANITIZER__)
148148
threading_mutex_destroy(&ref->m);

source/threading/include/threading/threading_atomic_win32.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ typedef LONG volatile atomic_flag;
122122

123123
#undef __atomic_is_lock_free_power_of_2
124124

125-
inline void atomic_store_explicit8(CHAR volatile *obj, CHAR desired, memory_order order)
125+
static inline void atomic_store_explicit8(CHAR volatile *obj, CHAR desired, memory_order order)
126126
{
127127
if (order == memory_order_seq_cst)
128128
{
@@ -134,7 +134,7 @@ inline void atomic_store_explicit8(CHAR volatile *obj, CHAR desired, memory_orde
134134
}
135135
}
136136

137-
inline void atomic_store_explicit16(SHORT volatile *obj, SHORT desired, memory_order order)
137+
static inline void atomic_store_explicit16(SHORT volatile *obj, SHORT desired, memory_order order)
138138
{
139139
if (order == memory_order_seq_cst)
140140
{
@@ -146,7 +146,7 @@ inline void atomic_store_explicit16(SHORT volatile *obj, SHORT desired, memory_o
146146
}
147147
}
148148

149-
inline void atomic_store_explicit32(LONG volatile *obj, LONG desired, memory_order order)
149+
static inline void atomic_store_explicit32(LONG volatile *obj, LONG desired, memory_order order)
150150
{
151151
if (order == memory_order_seq_cst)
152152
{
@@ -158,7 +158,7 @@ inline void atomic_store_explicit32(LONG volatile *obj, LONG desired, memory_ord
158158
}
159159
}
160160

161-
inline void atomic_store_explicit64(LONG64 volatile *obj, LONG64 desired, memory_order order)
161+
static inline void atomic_store_explicit64(LONG64 volatile *obj, LONG64 desired, memory_order order)
162162
{
163163
if (order == memory_order_seq_cst)
164164
#ifdef _M_IX86
@@ -224,7 +224,7 @@ inline void atomic_store_explicit64(LONG64 volatile *obj, LONG64 desired, memory
224224
(sizeof *(obj) == 8) ? _InterlockedExchange64((LONG64 volatile *)obj, (LONG64)desired) : \
225225
(abort(), 0))
226226

227-
inline bool atomic_compare_exchange8(CHAR volatile *obj, CHAR *expected, CHAR desired)
227+
static inline bool atomic_compare_exchange8(CHAR volatile *obj, CHAR *expected, CHAR desired)
228228
{
229229
CHAR previous = _InterlockedCompareExchange8(obj, desired, *expected);
230230
bool result = (previous == *expected);
@@ -237,7 +237,7 @@ inline bool atomic_compare_exchange8(CHAR volatile *obj, CHAR *expected, CHAR de
237237
return result;
238238
}
239239

240-
inline bool atomic_compare_exchange16(SHORT volatile *obj, SHORT *expected, SHORT desired)
240+
static inline bool atomic_compare_exchange16(SHORT volatile *obj, SHORT *expected, SHORT desired)
241241
{
242242
SHORT previous = _InterlockedCompareExchange16(obj, desired, *expected);
243243
bool result = (previous == *expected);
@@ -250,7 +250,7 @@ inline bool atomic_compare_exchange16(SHORT volatile *obj, SHORT *expected, SHOR
250250
return result;
251251
}
252252

253-
inline bool atomic_compare_exchange32(LONG volatile *obj, LONG *expected, LONG desired)
253+
static inline bool atomic_compare_exchange32(LONG volatile *obj, LONG *expected, LONG desired)
254254
{
255255
LONG previous = _InterlockedCompareExchange(obj, desired, *expected);
256256
bool result = (previous == *expected);
@@ -263,7 +263,7 @@ inline bool atomic_compare_exchange32(LONG volatile *obj, LONG *expected, LONG d
263263
return result;
264264
}
265265

266-
inline bool atomic_compare_exchange64(LONG64 volatile *obj, LONG64 *expected, LONG64 desired)
266+
static inline bool atomic_compare_exchange64(LONG64 volatile *obj, LONG64 *expected, LONG64 desired)
267267
{
268268
LONG64 previous = _InterlockedCompareExchange64(obj, desired, *expected);
269269
bool result = (previous == *expected);
@@ -346,7 +346,7 @@ inline bool atomic_compare_exchange64(LONG64 volatile *obj, LONG64 *expected, LO
346346
} \
347347
} while (0)
348348

349-
inline void atomic_thread_fence(memory_order order)
349+
static inline void atomic_thread_fence(memory_order order)
350350
{
351351
__atomic_compiler_barrier(order);
352352

@@ -357,7 +357,7 @@ inline void atomic_thread_fence(memory_order order)
357357
}
358358
}
359359

360-
inline void atomic_signal_fence(memory_order order)
360+
static inline void atomic_signal_fence(memory_order order)
361361
{
362362
__atomic_compiler_barrier(order);
363363
}

source/threading/include/threading/threading_mutex.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ int threading_mutex_unlock(threading_mutex m);
7575

7676
int threading_mutex_destroy(threading_mutex m);
7777

78-
inline int threading_mutex_store(threading_mutex m, void *dest, void *src, size_t size)
78+
static inline int threading_mutex_store(threading_mutex m, void *dest, void *src, size_t size)
7979
{
8080
if (threading_mutex_lock(m) != 0)
8181
{

source/threading/source/threading_mutex_macos.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@
2222

2323
#include <threading/threading_mutex.h>
2424

25+
#include <string.h>
26+
2527
int threading_mutex_initialize(threading_mutex m)
2628
{
27-
m->impl = 0;
29+
memset(&m->impl, 0, sizeof(os_unfair_lock));
2830

2931
return 0;
3032
}

0 commit comments

Comments
 (0)