diff --git a/compiler-rt/lib/builtins/atomic.c b/compiler-rt/lib/builtins/atomic.c --- a/compiler-rt/lib/builtins/atomic.c +++ b/compiler-rt/lib/builtins/atomic.c @@ -164,6 +164,7 @@ /// An atomic load operation. This is atomic with respect to the source /// pointer only. +void __atomic_load_c(int size, void *src, void *dest, int model); void __atomic_load_c(int size, void *src, void *dest, int model) { #define LOCK_FREE_ACTION(type) \ *((type *)dest) = __c11_atomic_load((_Atomic(type) *)src, model); \ @@ -178,6 +179,7 @@ /// An atomic store operation. This is atomic with respect to the destination /// pointer only. +void __atomic_store_c(int size, void *dest, void *src, int model); void __atomic_store_c(int size, void *dest, void *src, int model) { #define LOCK_FREE_ACTION(type) \ __c11_atomic_store((_Atomic(type) *)dest, *(type *)src, model); \ @@ -195,6 +197,8 @@ /// they are not, then this stores the current value from *ptr in *expected. /// /// This function returns 1 if the exchange takes place or 0 if it fails. +int __atomic_compare_exchange_c(int size, void *ptr, void *expected, + void *desired, int success, int failure); int __atomic_compare_exchange_c(int size, void *ptr, void *expected, void *desired, int success, int failure) { #define LOCK_FREE_ACTION(type) \ @@ -217,6 +221,7 @@ /// Performs an atomic exchange operation between two pointers. This is atomic /// with respect to the target address. +void __atomic_exchange_c(int size, void *ptr, void *val, void *old, int model); void __atomic_exchange_c(int size, void *ptr, void *val, void *old, int model) { #define LOCK_FREE_ACTION(type) \ *(type *)old = \ @@ -251,6 +256,7 @@ #endif #define OPTIMISED_CASE(n, lockfree, type) \ + type __atomic_load_##n(type *src, int model); \ type __atomic_load_##n(type *src, int model) { \ if (lockfree) \ return __c11_atomic_load((_Atomic(type) *)src, model); \ @@ -264,6 +270,7 @@ #undef OPTIMISED_CASE #define OPTIMISED_CASE(n, lockfree, type) \ + void __atomic_store_##n(type *dest, type val, int model); \ void __atomic_store_##n(type *dest, type val, int model) { \ if (lockfree) { \ __c11_atomic_store((_Atomic(type) *)dest, val, model); \ @@ -279,6 +286,7 @@ #undef OPTIMISED_CASE #define OPTIMISED_CASE(n, lockfree, type) \ + type __atomic_exchange_##n(type *dest, type val, int model); \ type __atomic_exchange_##n(type *dest, type val, int model) { \ if (lockfree) \ return __c11_atomic_exchange((_Atomic(type) *)dest, val, model); \ @@ -293,6 +301,8 @@ #undef OPTIMISED_CASE #define OPTIMISED_CASE(n, lockfree, type) \ + int __atomic_compare_exchange_##n(type *ptr, type *expected, type desired, \ + int success, int failure); \ int __atomic_compare_exchange_##n(type *ptr, type *expected, type desired, \ int success, int failure) { \ if (lockfree) \ @@ -316,6 +326,7 @@ // Atomic read-modify-write operations for integers of various sizes. //////////////////////////////////////////////////////////////////////////////// #define ATOMIC_RMW(n, lockfree, type, opname, op) \ + type __atomic_fetch_##opname##_##n(type *ptr, type val, int model); \ type __atomic_fetch_##opname##_##n(type *ptr, type val, int model) { \ if (lockfree) \ return __c11_atomic_fetch_##opname((_Atomic(type) *)ptr, val, model); \