Skip to content

Commit e505554

Browse files
committed
Use clang's c11_atomic builtins instead of the older gcc extensions
to implement the handful of atomic operations used in test cases.
1 parent bdee09e commit e505554

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tests/linux_port.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
static inline int32_t
55
OSAtomicIncrement32(volatile int32_t *var)
66
{
7-
return __sync_add_and_fetch(var,1);
7+
return __c11_atomic_fetch_add((_Atomic(int)*)var, 1, __ATOMIC_RELAXED)+1;
88
}
99

1010
static inline int32_t
1111
OSAtomicIncrement32Barrier(volatile int32_t *var)
1212
{
13-
return __sync_add_and_fetch(var,1);
13+
return __c11_atomic_fetch_add((_Atomic(int)*)var, 1, __ATOMIC_SEQ_CST)+1;
1414
}
1515

1616
static inline int32_t
1717
OSAtomicAdd32(volatile int32_t *var, int32_t val)
1818
{
19-
return __sync_add_and_fetch(var,val);
19+
return __c11_atomic_fetch_add((_Atomic(int)*)var, val, __ATOMIC_RELAXED)+val;
2020
}
2121

2222
// Simulation of mach_absolute_time related infrastructure

0 commit comments

Comments
 (0)