mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-29 08:31:13 +00:00
builtins: Implement the functions from stdatomic.h
Talking to John and Doug, we concluded that these functions from stdatomic really do belong here in compiler-rt rather than in libc, since the compiler owns stdatomic.h and these need to refer to clang-specific builtins. Nonetheless, I've only added these on darwin for now - other platforms should probably do the same unless their libc does implement these functions. llvm-svn: 236805
This commit is contained in:
parent
1cf6c28a9c
commit
fa7525935b
19
compiler-rt/lib/builtins/atomic_flag_clear.c
Normal file
19
compiler-rt/lib/builtins/atomic_flag_clear.c
Normal file
@ -0,0 +1,19 @@
|
||||
/*===-- atomic_flag_clear.c -------------------------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is dual licensed under the MIT and the University of Illinois Open
|
||||
* Source Licenses. See LICENSE.TXT for details.
|
||||
*
|
||||
*===------------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements atomic_flag_clear from C11's stdatomic.h.
|
||||
*
|
||||
*===------------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include <stdatomic.h>
|
||||
#undef atomic_flag_clear
|
||||
void atomic_flag_clear(volatile atomic_flag *object) {
|
||||
return __c11_atomic_store(&(object)->_Value, 0, __ATOMIC_SEQ_CST);
|
||||
}
|
20
compiler-rt/lib/builtins/atomic_flag_clear_explicit.c
Normal file
20
compiler-rt/lib/builtins/atomic_flag_clear_explicit.c
Normal file
@ -0,0 +1,20 @@
|
||||
/*===-- atomic_flag_clear_explicit.c ----------------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is dual licensed under the MIT and the University of Illinois Open
|
||||
* Source Licenses. See LICENSE.TXT for details.
|
||||
*
|
||||
*===------------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements atomic_flag_clear_explicit from C11's stdatomic.h.
|
||||
*
|
||||
*===------------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include <stdatomic.h>
|
||||
#undef atomic_flag_clear_explicit
|
||||
void atomic_flag_clear_explicit(volatile atomic_flag *object,
|
||||
memory_order order) {
|
||||
return __c11_atomic_store(&(object)->_Value, 0, order);
|
||||
}
|
19
compiler-rt/lib/builtins/atomic_flag_test_and_set.c
Normal file
19
compiler-rt/lib/builtins/atomic_flag_test_and_set.c
Normal file
@ -0,0 +1,19 @@
|
||||
/*===-- atomic_flag_test_and_set.c ------------------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is dual licensed under the MIT and the University of Illinois Open
|
||||
* Source Licenses. See LICENSE.TXT for details.
|
||||
*
|
||||
*===------------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements atomic_flag_test_and_set from C11's stdatomic.h.
|
||||
*
|
||||
*===------------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include <stdatomic.h>
|
||||
#undef atomic_flag_test_and_set
|
||||
_Bool atomic_flag_test_and_set(volatile atomic_flag *object) {
|
||||
return __c11_atomic_exchange(&(object)->_Value, 1, __ATOMIC_SEQ_CST);
|
||||
}
|
20
compiler-rt/lib/builtins/atomic_flag_test_and_set_explicit.c
Normal file
20
compiler-rt/lib/builtins/atomic_flag_test_and_set_explicit.c
Normal file
@ -0,0 +1,20 @@
|
||||
/*===-- atomic_flag_test_and_set_explicit.c ---------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is dual licensed under the MIT and the University of Illinois Open
|
||||
* Source Licenses. See LICENSE.TXT for details.
|
||||
*
|
||||
*===------------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements atomic_flag_test_and_set_explicit from C11's stdatomic.h
|
||||
*
|
||||
*===------------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include <stdatomic.h>
|
||||
#undef atomic_flag_test_and_set_explicit
|
||||
_Bool atomic_flag_test_and_set_explicit(volatile atomic_flag *object,
|
||||
memory_order order) {
|
||||
return __c11_atomic_exchange(&(object)->_Value, 1, order);
|
||||
}
|
19
compiler-rt/lib/builtins/atomic_signal_fence.c
Normal file
19
compiler-rt/lib/builtins/atomic_signal_fence.c
Normal file
@ -0,0 +1,19 @@
|
||||
/*===-- atomic_signal_fence.c -----------------------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is dual licensed under the MIT and the University of Illinois Open
|
||||
* Source Licenses. See LICENSE.TXT for details.
|
||||
*
|
||||
*===------------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements atomic_signal_fence from C11's stdatomic.h.
|
||||
*
|
||||
*===------------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include <stdatomic.h>
|
||||
#undef atomic_signal_fence
|
||||
void atomic_signal_fence(memory_order order) {
|
||||
__c11_atomic_signal_fence(order);
|
||||
}
|
19
compiler-rt/lib/builtins/atomic_thread_fence.c
Normal file
19
compiler-rt/lib/builtins/atomic_thread_fence.c
Normal file
@ -0,0 +1,19 @@
|
||||
/*===-- atomic_thread_fence.c -----------------------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is dual licensed under the MIT and the University of Illinois Open
|
||||
* Source Licenses. See LICENSE.TXT for details.
|
||||
*
|
||||
*===------------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements atomic_thread_fence from C11's stdatomic.h.
|
||||
*
|
||||
*===------------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include <stdatomic.h>
|
||||
#undef atomic_thread_fence
|
||||
void atomic_thread_fence(memory_order order) {
|
||||
__c11_atomic_thread_fence(order);
|
||||
}
|
@ -255,17 +255,26 @@ CFLAGS.ubsan_osx_dynamic += -isysroot $(OSX_SDK)
|
||||
LDFLAGS.ubsan_osx_dynamic += -isysroot $(OSX_SDK)
|
||||
endif
|
||||
|
||||
ATOMIC_FUNCTIONS := \
|
||||
atomic_flag_clear \
|
||||
atomic_flag_clear_explicit \
|
||||
atomic_flag_test_and_set \
|
||||
atomic_flag_test_and_set_explicit \
|
||||
atomic_signal_fence \
|
||||
atomic_thread_fence
|
||||
|
||||
FUNCTIONS.eprintf := eprintf
|
||||
FUNCTIONS.10.4 := eprintf floatundidf floatundisf floatundixf
|
||||
|
||||
FUNCTIONS.ios := divmodsi4 udivmodsi4 mulosi4 mulodi4 muloti4
|
||||
FUNCTIONS.ios := divmodsi4 udivmodsi4 mulosi4 mulodi4 muloti4 \
|
||||
$(ATOMIC_FUNCTIONS)
|
||||
# On x86, the divmod functions reference divsi.
|
||||
FUNCTIONS.ios.i386 := $(FUNCTIONS.ios) \
|
||||
divsi3 udivsi3
|
||||
FUNCTIONS.ios.x86_64 := $(FUNCTIONS.ios.i386)
|
||||
FUNCTIONS.ios.arm64 := mulsc3 muldc3 divsc3 divdc3
|
||||
FUNCTIONS.ios.arm64 := mulsc3 muldc3 divsc3 divdc3 $(ATOMIC_FUNCTIONS)
|
||||
|
||||
FUNCTIONS.osx := mulosi4 mulodi4 muloti4
|
||||
FUNCTIONS.osx := mulosi4 mulodi4 muloti4 $(ATOMIC_FUNCTIONS)
|
||||
|
||||
FUNCTIONS.profile_osx := GCDAProfiling InstrProfiling InstrProfilingBuffer \
|
||||
InstrProfilingFile InstrProfilingPlatformDarwin \
|
||||
|
@ -176,7 +176,13 @@ COMMON_FUNCTIONS := \
|
||||
udivsi3 \
|
||||
umodsi3 \
|
||||
unorddf2 \
|
||||
unordsf2
|
||||
unordsf2 \
|
||||
atomic_flag_clear \
|
||||
atomic_flag_clear_explicit \
|
||||
atomic_flag_test_and_set \
|
||||
atomic_flag_test_and_set_explicit \
|
||||
atomic_signal_fence \
|
||||
atomic_thread_fence
|
||||
|
||||
ARM_FUNCTIONS := \
|
||||
aeabi_cdcmpeq \
|
||||
|
@ -47,7 +47,10 @@ FUNCTIONS := absvdi2 absvsi2 addvdi3 addvsi3 ashldi3 ashrdi3 \
|
||||
mulodi4 muloti4 mulsc3 mulvdi3 mulvsi3 negdi2 negvdi2 negvsi2 \
|
||||
paritydi2 paritysi2 popcountdi2 popcountsi2 powidf2 \
|
||||
powisf2 subvdi3 subvsi3 ucmpdi2 udivdi3 \
|
||||
udivmoddi4 umoddi3 apple_versioning eprintf atomic
|
||||
udivmoddi4 umoddi3 apple_versioning eprintf atomic \
|
||||
atomic_flag_clear atomic_flag_clear_explicit \
|
||||
atomic_flag_test_and_set atomic_flag_test_and_set_explicit \
|
||||
atomic_signal_fence atomic_thread_fence
|
||||
|
||||
FUNCTIONS.i386 := $(FUNCTIONS) \
|
||||
divxc3 fixunsxfdi fixunsxfsi fixxfdi floatdixf \
|
||||
@ -124,5 +127,8 @@ FUNCTIONS.arm64 := divti3 modti3 \
|
||||
fixdfti fixsfti \
|
||||
fixunsdfti fixunssfti fixunssfti \
|
||||
floattidf floattisf floatuntidf floatuntisf \
|
||||
gcc_personality_v0 atomic
|
||||
|
||||
gcc_personality_v0 atomic \
|
||||
atomic_flag_clear atomic_flag_clear_explicit \
|
||||
atomic_flag_test_and_set \
|
||||
atomic_flag_test_and_set_explicit \
|
||||
atomic_signal_fence atomic_thread_fence
|
||||
|
Loading…
Reference in New Issue
Block a user