diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2021-11-06 12:18:11 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2021-11-06 12:18:11 +0300 |
commit | a821036cc7208fbd83cf8c05d080506581ca2471 (patch) | |
tree | b159dcd4b22b1fd748a984e47b4ee9c4ae29737e | |
parent | eac8caa3de6d6466a37d2471f9fb0eecbfa9474c (diff) | |
download | libatomic_ops-a821036cc7208fbd83cf8c05d080506581ca2471.tar.gz |
Ensure atomic_ops.c global symbols are always declared as extern 'C'
* src/atomic_ops.c (AO_pause): Declare as extern "C" if __cplusplus.
* src/atomic_ops.c [!_MSC_VER && !__MINGW32__ && !__BORLANDC__
|| AO_USE_NO_SIGNALS] (AO_fetch_compare_and_swap_emulation,
AO_compare_double_and_swap_double_emulation, AO_store_full_emulation):
Likewise.
* src/atomic_ops.c [(!_MSC_VER && !__MINGW32__ && !__BORLANDC__
|| AO_USE_NO_SIGNALS) && !AO_NO_PTHREADS] (AO_pt_lock): Likewise.
* src/atomic_ops_stack.c [AO_USE_ALMOST_LOCK_FREE] (AO_pause):
Likewise.
* src/atomic_ops.c (AO_pause): Move declaration up to have it
unconditionally.
-rw-r--r-- | src/atomic_ops.c | 29 | ||||
-rw-r--r-- | src/atomic_ops_stack.c | 8 |
2 files changed, 35 insertions, 2 deletions
diff --git a/src/atomic_ops.c b/src/atomic_ops.c index 5f33a90..3c62fb5 100644 --- a/src/atomic_ops.c +++ b/src/atomic_ops.c @@ -53,6 +53,16 @@ #undef AO_REQUIRE_CAS #include "atomic_ops.h" /* Without cas emulation! */ +#ifdef __cplusplus + extern "C" { +#endif + +void AO_pause(int); /* defined below */ + +#ifdef __cplusplus + } /* extern "C" */ +#endif + #if !defined(_MSC_VER) && !defined(__MINGW32__) && !defined(__BORLANDC__) \ || defined(AO_USE_NO_SIGNALS) @@ -80,11 +90,28 @@ # include "atomic_ops/sysdeps/standard_ao_double_t.h" #endif +#ifdef __cplusplus + extern "C" { +#endif + +AO_t AO_fetch_compare_and_swap_emulation(volatile AO_t *addr, AO_t old_val, + AO_t new_val); + +int AO_compare_double_and_swap_double_emulation(volatile AO_double_t *addr, + AO_t old_val1, AO_t old_val2, + AO_t new_val1, AO_t new_val2); + +void AO_store_full_emulation(volatile AO_t *addr, AO_t val); + /* Lock for pthreads-based implementation. */ #ifndef AO_NO_PTHREADS pthread_mutex_t AO_pt_lock = PTHREAD_MUTEX_INITIALIZER; #endif +#ifdef __cplusplus + } /* extern "C" */ +#endif + /* * Out of line compare-and-swap emulation based on test and set. * @@ -108,8 +135,6 @@ static AO_TS_t AO_locks[AO_HASH_SIZE] = { AO_TS_INITIALIZER, AO_TS_INITIALIZER, AO_TS_INITIALIZER, AO_TS_INITIALIZER, }; -void AO_pause(int); /* defined below */ - static void lock_ool(volatile AO_TS_t *l) { int i = 0; diff --git a/src/atomic_ops_stack.c b/src/atomic_ops_stack.c index 5d7995f..bb9c3ad 100644 --- a/src/atomic_ops_stack.c +++ b/src/atomic_ops_stack.c @@ -36,8 +36,16 @@ #ifdef AO_USE_ALMOST_LOCK_FREE +# ifdef __cplusplus + extern "C" { +# endif + void AO_pause(int); /* defined in atomic_ops.c */ +# ifdef __cplusplus + } /* extern "C" */ +# endif + /* LIFO linked lists based on compare-and-swap. We need to avoid */ /* the case of a node deletion and reinsertion while I'm deleting */ /* it, since that may cause my CAS to succeed eventhough the next */ |