summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2018-02-09 00:42:25 +0300
committerIvan Maidanski <ivmai@mail.ru>2018-02-09 00:52:40 +0300
commited206ef27a104f9d29af8afd5209d05766afaa85 (patch)
treecbd850a2f7de206b3770db9c00c4436cda2de33a /src
parent3e37c2083e4e841e86f014ad5ae0467c7e1c1d51 (diff)
downloadlibatomic_ops-ed206ef27a104f9d29af8afd5209d05766afaa85.tar.gz
Fix public headers inclusion from clients C++ code
Put declarations of exported variables and non-inline functions into extern "C" blocks. * src/atomic_ops/sysdeps/emul_cas.h [__cplusplus] (AO_fetch_compare_and_swap_emulation, AO_compare_double_and_swap_double_emulation, AO_store_full_emulation): Wrap the prototypes (but not included headers). * src/atomic_ops/sysdeps/gcc/x86.h [AO_WEAK_DOUBLE_CAS_EMULATION && __cplusplus] (AO_compare_double_and_swap_double_emulation): Likewise. * src/atomic_ops/sysdeps/generic_pthread.h [__cplusplus] (AO_pt_lock): Likewise. * src/atomic_ops/sysdeps/sunc/sparc.h [__cplusplus] (AO_test_and_set_full): Likewise. * src/atomic_ops_malloc.h [__cplusplus] (AO_free, AO_malloc, AO_malloc_enable_mmap): Likewise. * src/atomic_ops_stack.h [__cplusplus] (AO_stack_push_explicit_aux_release, AO_stack_pop_explicit_aux_acquire, AO_stack_init, AO_stack_push_release, AO_stack_pop_acquire): Likewise. * tests/test_atomic.c [AO_TEST_EMULATION && __cplusplus] (AO_store_full_emulation, AO_fetch_compare_and_swap_emulation, AO_compare_double_and_swap_double_emulation): Likewise. * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER<1400 && __cplusplus]: Adjust comment for the end of extern "C" block.
Diffstat (limited to 'src')
-rw-r--r--src/atomic_ops/sysdeps/emul_cas.h8
-rw-r--r--src/atomic_ops/sysdeps/gcc/x86.h8
-rw-r--r--src/atomic_ops/sysdeps/generic_pthread.h8
-rw-r--r--src/atomic_ops/sysdeps/msftc/common32_defs.h2
-rw-r--r--src/atomic_ops/sysdeps/sunc/sparc.h8
-rw-r--r--src/atomic_ops_malloc.h8
-rw-r--r--src/atomic_ops_stack.h14
7 files changed, 55 insertions, 1 deletions
diff --git a/src/atomic_ops/sysdeps/emul_cas.h b/src/atomic_ops/sysdeps/emul_cas.h
index 2a592bc..e52f75a 100644
--- a/src/atomic_ops/sysdeps/emul_cas.h
+++ b/src/atomic_ops/sysdeps/emul_cas.h
@@ -43,6 +43,10 @@
# include "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);
@@ -76,3 +80,7 @@ void AO_store_full_emulation(volatile AO_t *addr, AO_t val);
#undef AO_HAVE_store_full
#define AO_store_full(addr, val) AO_store_full_emulation(addr, val)
#define AO_HAVE_store_full
+
+#ifdef __cplusplus
+ } /* extern "C" */
+#endif
diff --git a/src/atomic_ops/sysdeps/gcc/x86.h b/src/atomic_ops/sysdeps/gcc/x86.h
index e4863ad..d7c06c5 100644
--- a/src/atomic_ops/sysdeps/gcc/x86.h
+++ b/src/atomic_ops/sysdeps/gcc/x86.h
@@ -557,6 +557,10 @@ AO_fetch_compare_and_swap_full(volatile AO_t *addr, AO_t old_val,
#elif defined(AO_WEAK_DOUBLE_CAS_EMULATION)
# include "../standard_ao_double_t.h"
+# ifdef __cplusplus
+ extern "C" {
+# endif
+
/* This one provides spinlock based emulation of CAS implemented in */
/* atomic_ops.c. We probably do not want to do this here, since it */
/* is not atomic with respect to other kinds of updates of *addr. */
@@ -566,6 +570,10 @@ AO_fetch_compare_and_swap_full(volatile AO_t *addr, AO_t old_val,
AO_t old_val1, AO_t old_val2,
AO_t new_val1, AO_t new_val2);
+# ifdef __cplusplus
+ } /* extern "C" */
+# endif
+
AO_INLINE int
AO_compare_double_and_swap_double_full(volatile AO_double_t *addr,
AO_t old_val1, AO_t old_val2,
diff --git a/src/atomic_ops/sysdeps/generic_pthread.h b/src/atomic_ops/sysdeps/generic_pthread.h
index 3c65624..854cb77 100644
--- a/src/atomic_ops/sysdeps/generic_pthread.h
+++ b/src/atomic_ops/sysdeps/generic_pthread.h
@@ -33,10 +33,18 @@
/* This is not necessarily compatible with the native */
/* implementation. But those can't be safely mixed anyway. */
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
/* We define only the full barrier variants, and count on the */
/* generalization section below to fill in the rest. */
extern pthread_mutex_t AO_pt_lock;
+#ifdef __cplusplus
+ } /* extern "C" */
+#endif
+
AO_INLINE void
AO_nop_full(void)
{
diff --git a/src/atomic_ops/sysdeps/msftc/common32_defs.h b/src/atomic_ops/sysdeps/msftc/common32_defs.h
index 92f8092..a5c6904 100644
--- a/src/atomic_ops/sysdeps/msftc/common32_defs.h
+++ b/src/atomic_ops/sysdeps/msftc/common32_defs.h
@@ -62,7 +62,7 @@
LONG __cdecl _InterlockedCompareExchange(LONG volatile *,
LONG /* Exchange */, LONG /* Comp */);
# ifdef __cplusplus
- }
+ } /* extern "C" */
# endif
# endif /* _MSC_VER < 1400 */
diff --git a/src/atomic_ops/sysdeps/sunc/sparc.h b/src/atomic_ops/sysdeps/sunc/sparc.h
index 298881f..5530fd0 100644
--- a/src/atomic_ops/sysdeps/sunc/sparc.h
+++ b/src/atomic_ops/sysdeps/sunc/sparc.h
@@ -28,9 +28,17 @@
/* Test_and_set location is just a byte. */
#include "../test_and_set_t_is_char.h"
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
extern AO_TS_VAL_t
AO_test_and_set_full(volatile AO_TS_t *addr);
/* Implemented in separate .S file, for now. */
#define AO_HAVE_test_and_set_full
/* TODO: Like the gcc version, extend this for V8 and V9. */
+
+#ifdef __cplusplus
+ } /* extern "C" */
+#endif
diff --git a/src/atomic_ops_malloc.h b/src/atomic_ops_malloc.h
index 3ffe173..f9ed900 100644
--- a/src/atomic_ops_malloc.h
+++ b/src/atomic_ops_malloc.h
@@ -30,6 +30,10 @@
#include <stddef.h> /* for size_t */
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
#ifdef AO_STACK_IS_LOCK_FREE
# define AO_MALLOC_IS_LOCK_FREE
#endif
@@ -70,4 +74,8 @@ void * AO_malloc(size_t);
/* Allow use of mmap to grow the heap. No-op on some platforms. */
void AO_malloc_enable_mmap(void);
+#ifdef __cplusplus
+ } /* extern "C" */
+#endif
+
#endif /* !AO_MALLOC_H */
diff --git a/src/atomic_ops_stack.h b/src/atomic_ops_stack.h
index 5c21268..345ae21 100644
--- a/src/atomic_ops_stack.h
+++ b/src/atomic_ops_stack.h
@@ -31,6 +31,10 @@
#include "atomic_ops.h"
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
#ifdef AO_USE_ALMOST_LOCK_FREE
/* Use the almost-non-blocking implementation regardless of the */
/* double-word CAS availability. */
@@ -154,7 +158,13 @@ AO_INLINE void AO_stack_init(AO_stack_t *list)
#ifndef AO_HAVE_double_t
/* Can happen if we're using CAS emulation, since we don't want to */
/* force that here, in case other atomic_ops clients don't want it. */
+# ifdef __cplusplus
+ } /* extern "C" */
+# endif
# include "atomic_ops/sysdeps/standard_ao_double_t.h"
+# ifdef __cplusplus
+ extern "C" {
+# endif
#endif
typedef volatile AO_double_t AO_stack_t;
@@ -191,4 +201,8 @@ AO_t * AO_stack_pop_acquire(AO_stack_t *list);
# define AO_HAVE_stack_pop
#endif
+#ifdef __cplusplus
+ } /* extern "C" */
+#endif
+
#endif /* !AO_STACK_H */