summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2018-02-28 21:39:04 +0300
committerIvan Maidanski <ivmai@mail.ru>2018-02-28 21:39:04 +0300
commitdafe71bca00384b4647700635f8321885b3cf100 (patch)
tree598338f3e248e5fe11ea4e694da2359b790504e7
parentc6ea1f66fe335c303f9ce73319d24247bc504304 (diff)
downloadbdwgc-dafe71bca00384b4647700635f8321885b3cf100.tar.gz
Replace conditional extern 'C' blocks begin/end with EXTERN_C_BEGIN/END
(code refactoring) Issue #206 (bdwgc). Note: EXTERN_C_BEGIN and EXTERN_C_END are not available in the GC public headers. * include/private/darwin_stop_world.h: Replace the conditional extern "C" block begin/end with EXTERN_C_BEGIN and EXTERN_C_END, respectively. * include/private/dbg_mlc.h: Likewise. * include/private/gc_hdrs.h: Likewise. * include/private/gc_locks.h: Likewise. * include/private/gc_pmark.h: Likewise. * include/private/gc_priv.h: Likewise. * include/private/gcconfig.h: Likewise. * include/private/pthread_stop_world.h: Likewise. * include/private/pthread_support.h: Likewise. * include/private/specific.h: Likewise. * include/private/thread_local_alloc.h: Likewise. * os_dep.c [MPROTECT_VDB && DARWIN]: Likewise. * tests/test.c [GC_AMIGA_FASTALLOC && AMIGA]: Likewise. * include/private/gcconfig.h (EXTERN_C_BEGIN, EXTERN_C_END): Define macro.
-rw-r--r--include/private/darwin_stop_world.h8
-rw-r--r--include/private/dbg_mlc.h8
-rw-r--r--include/private/gc_hdrs.h14
-rw-r--r--include/private/gc_locks.h40
-rw-r--r--include/private/gc_pmark.h8
-rw-r--r--include/private/gc_priv.h49
-rw-r--r--include/private/gcconfig.h360
-rw-r--r--include/private/pthread_stop_world.h9
-rw-r--r--include/private/pthread_support.h9
-rw-r--r--include/private/specific.h9
-rw-r--r--include/private/thread_local_alloc.h25
-rw-r--r--os_dep.c8
-rw-r--r--tests/test.c9
13 files changed, 151 insertions, 405 deletions
diff --git a/include/private/darwin_stop_world.h b/include/private/darwin_stop_world.h
index ca8ef9ed..ee97cbf6 100644
--- a/include/private/darwin_stop_world.h
+++ b/include/private/darwin_stop_world.h
@@ -25,9 +25,7 @@
#include <mach/mach.h>
#include <mach/thread_act.h>
-#ifdef __cplusplus
- extern "C" {
-#endif
+EXTERN_C_BEGIN
struct thread_stop_info {
mach_port_t mach_thread;
@@ -50,8 +48,6 @@ struct thread_stop_info {
GC_INNER GC_bool GC_is_mach_marker(thread_act_t);
#endif
-#ifdef __cplusplus
- } /* extern "C" */
-#endif
+EXTERN_C_END
#endif
diff --git a/include/private/dbg_mlc.h b/include/private/dbg_mlc.h
index 2ba8f9cb..4283bdac 100644
--- a/include/private/dbg_mlc.h
+++ b/include/private/dbg_mlc.h
@@ -30,9 +30,7 @@
# include "gc_backptr.h"
#endif
-#ifdef __cplusplus
- extern "C" {
-#endif
+EXTERN_C_BEGIN
#if CPP_WORDSZ == 32
# define START_FLAG (word)0xfedcedcb
@@ -171,8 +169,6 @@ typedef struct {
# define GC_HAS_DEBUG_INFO(p) (GC_has_other_debug_info(p) > 0)
#endif
-#ifdef __cplusplus
- } /* extern "C" */
-#endif
+EXTERN_C_END
#endif /* _DBG_MLC_H */
diff --git a/include/private/gc_hdrs.h b/include/private/gc_hdrs.h
index d44b5998..03889feb 100644
--- a/include/private/gc_hdrs.h
+++ b/include/private/gc_hdrs.h
@@ -15,16 +15,14 @@
#ifndef GC_HEADERS_H
#define GC_HEADERS_H
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-typedef struct hblkhdr hdr;
-
#if CPP_WORDSZ != 32 && CPP_WORDSZ < 36
# error Get a real machine
#endif
+EXTERN_C_BEGIN
+
+typedef struct hblkhdr hdr;
+
/*
* The 2 level tree data structure that is used to find block headers.
* If there are more than 32 bits in a pointer, the top level is a hash
@@ -211,8 +209,6 @@ typedef struct bi {
/* h. Assumes hhdr == HDR(h) and IS_FORWARDING_ADDR(hhdr). */
#define FORWARDED_ADDR(h, hhdr) ((struct hblk *)(h) - (size_t)(hhdr))
-#ifdef __cplusplus
- } /* extern "C" */
-#endif
+EXTERN_C_END
#endif /* GC_HEADERS_H */
diff --git a/include/private/gc_locks.h b/include/private/gc_locks.h
index fad4ad2d..15da91bb 100644
--- a/include/private/gc_locks.h
+++ b/include/private/gc_locks.h
@@ -33,9 +33,7 @@
# include <th/PCR_Th.h>
# endif
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# ifdef PCR
GC_EXTERN PCR_Th_ML GC_allocate_ml;
@@ -57,17 +55,13 @@
# endif
# if defined(GC_WIN32_THREADS) && !defined(USE_PTHREAD_LOCKS)
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN 1
# endif
# define NOSERVICE
+ EXTERN_C_END
# include <windows.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# define NO_THREAD (DWORD)(-1)
GC_EXTERN CRITICAL_SECTION GC_allocate_ml;
# ifdef GC_ASSERTIONS
@@ -94,13 +88,9 @@
# define UNCOND_UNLOCK() LeaveCriticalSection(&GC_allocate_ml)
# endif /* !GC_ASSERTIONS */
# elif defined(GC_PTHREADS)
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <pthread.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
/* Posix allows pthread_t to be a struct, though it rarely is. */
/* Unfortunately, we need to use a pthread_t to index a data */
/* structure. It also helps if comparisons don't involve a */
@@ -136,13 +126,9 @@
/* != NUMERIC_THREAD_ID(pthread_self()) for any thread */
# ifdef SN_TARGET_PSP2
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include "psp2-support.h"
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
GC_EXTERN WapiMutex GC_allocate_ml_PSP2;
# define UNCOND_LOCK() { int res; GC_ASSERT(I_DONT_HOLD_LOCK()); \
res = PSP2_MutexLock(&GC_allocate_ml_PSP2); \
@@ -186,13 +172,9 @@
# endif
# endif /* THREAD_LOCAL_ALLOC || USE_PTHREAD_LOCKS */
# ifdef USE_PTHREAD_LOCKS
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <pthread.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
GC_EXTERN pthread_mutex_t GC_allocate_ml;
# ifdef GC_ASSERTIONS
# define UNCOND_LOCK() { GC_ASSERT(I_DONT_HOLD_LOCK()); \
@@ -258,9 +240,7 @@
# endif
# endif
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# else /* !THREADS */
# define LOCK() (void)0
diff --git a/include/private/gc_pmark.h b/include/private/gc_pmark.h
index aad245c8..1a8841df 100644
--- a/include/private/gc_pmark.h
+++ b/include/private/gc_pmark.h
@@ -48,9 +48,7 @@
# include "gc_priv.h"
#endif
-#ifdef __cplusplus
- extern "C" {
-#endif
+EXTERN_C_BEGIN
/* The real declarations of the following is in gc_priv.h, so that */
/* we can avoid scanning the following table. */
@@ -482,8 +480,6 @@ typedef int mark_state_t; /* Current state of marking, as follows:*/
GC_EXTERN mark_state_t GC_mark_state;
-#ifdef __cplusplus
- } /* extern "C" */
-#endif
+EXTERN_C_END
#endif /* GC_PMARK_H */
diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h
index 393aec52..002945c1 100644
--- a/include/private/gc_priv.h
+++ b/include/private/gc_priv.h
@@ -326,10 +326,7 @@ typedef char * ptr_t; /* A generic pointer to which we can add */
/* This is now really controlled at startup, */
/* through GC_all_interior_pointers. */
-/* Note: never put extern "C" around an #include. */
-#ifdef __cplusplus
- extern "C" {
-#endif
+EXTERN_C_BEGIN
#ifndef GC_NO_FINALIZATION
# define GC_INVOKE_FINALIZERS() GC_notify_or_invoke_finalizers()
@@ -420,9 +417,7 @@ typedef char * ptr_t; /* A generic pointer to which we can add */
GC_INNER void GC_print_callers(struct callinfo info[NFRAMES]);
#endif
-#ifdef __cplusplus
- } /* extern "C" */
-#endif
+EXTERN_C_END
/*********************************/
/* */
@@ -460,14 +455,10 @@ typedef char * ptr_t; /* A generic pointer to which we can add */
# define MS_TIME_DIFF(a,b) ((long)((a)-(b)))
#elif defined(NN_PLATFORM_CTR)
# define CLOCK_TYPE long long
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
CLOCK_TYPE n3ds_get_system_tick(void);
CLOCK_TYPE n3ds_convert_tick_to_ms(CLOCK_TYPE tick);
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# define GET_TIME(x) (void)(x = n3ds_get_system_tick())
# define MS_TIME_DIFF(a,b) ((long)n3ds_convert_tick_to_ms((a)-(b)))
#else /* !BSD_TIME && !NN_PLATFORM_CTR && !MSWIN32 && !MSWINCE */
@@ -525,9 +516,7 @@ typedef char * ptr_t; /* A generic pointer to which we can add */
# include "th/PCR_ThCtl.h"
#endif
-#ifdef __cplusplus
- extern "C" {
-#endif
+EXTERN_C_BEGIN
/*
* Stop and restart mutator threads.
@@ -673,9 +662,7 @@ GC_EXTERN GC_warn_proc GC_current_warn_proc;
# define GETENV(name) getenv(name)
#endif
-#ifdef __cplusplus
- } /* extern "C" */
-#endif
+EXTERN_C_END
#if defined(DARWIN)
# include <mach/thread_status.h>
@@ -762,9 +749,7 @@ GC_EXTERN GC_warn_proc GC_current_warn_proc;
#include <setjmp.h>
-#ifdef __cplusplus
- extern "C" {
-#endif
+EXTERN_C_BEGIN
/*********************************/
/* */
@@ -2627,13 +2612,9 @@ GC_INNER ptr_t GC_store_debug_info(ptr_t p, word sz, const char *str,
#if (defined(UNIX_LIKE) || (defined(NEED_FIND_LIMIT) && defined(CYGWIN32))) \
&& !defined(GC_NO_SIGSETJMP)
# if defined(SUNOS5SIGS) && !defined(FREEBSD) && !defined(LINUX)
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <sys/siginfo.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# endif
/* Define SETJMP and friends to be the version that restores */
/* the signal mask. */
@@ -2660,13 +2641,9 @@ GC_INNER ptr_t GC_store_debug_info(ptr_t p, word sz, const char *str,
#endif
#if defined(DATASTART_USES_BSDGETDATASTART)
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <machine/trap.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# if !defined(PCR)
# define NEED_FIND_LIMIT
# endif
@@ -2725,8 +2702,6 @@ GC_INNER ptr_t GC_store_debug_info(ptr_t p, word sz, const char *str,
# define ASSERT_CANCEL_DISABLED() (void)0
#endif /* !CANCEL_SAFE */
-#ifdef __cplusplus
- } /* extern "C" */
-#endif
+EXTERN_C_END
#endif /* GC_PRIVATE_H */
diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h
index bd4867f7..408318c3 100644
--- a/include/private/gcconfig.h
+++ b/include/private/gcconfig.h
@@ -37,9 +37,15 @@
/* around #includes. Types and macros do not need such wrapping, only */
/* the declared global data and functions. */
#ifdef __cplusplus
- extern "C" {
+# define EXTERN_C_BEGIN extern "C" {
+# define EXTERN_C_END } /* extern "C" */
+#else
+# define EXTERN_C_BEGIN /* empty */
+# define EXTERN_C_END /* empty */
#endif
+EXTERN_C_BEGIN
+
/* Convenient internal macro to test version of Clang. */
#if defined(__clang__) && defined(__clang_major__)
# define GC_CLANG_PREREQ(major, minor) \
@@ -125,13 +131,9 @@
/* And one for Darwin: */
# if defined(macosx) || (defined(__APPLE__) && defined(__MACH__))
# define DARWIN
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <TargetConditionals.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# endif
/* Determine the machine type: */
@@ -276,13 +278,9 @@
# endif
# if (defined(sun) || defined(__sun)) && (defined(sparc) || defined(__sparc))
/* Test for SunOS 5.x */
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <errno.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# define SPARC
# define SOLARIS
# define mach_type_known
@@ -926,13 +924,9 @@
# define MPROTECT_VDB
# ifdef __ELF__
# define DYNAMIC_LOADING
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <features.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# if defined(__GLIBC__) && __GLIBC__ >= 2
# define SEARCH_FOR_DATA_START
# else /* !GLIBC2 */
@@ -963,13 +957,9 @@
# endif
# ifdef MACOS
# ifndef __LOWMEM__
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <LowMem.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# endif
# define OS_TYPE "MACOS"
/* see os_dep.c for details of global data segments. */
@@ -991,13 +981,9 @@
# ifdef MACOS
# define ALIGNMENT 2 /* Still necessary? Could it be 4? */
# ifndef __LOWMEM__
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <LowMem.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# endif
# define OS_TYPE "MACOS"
/* see os_dep.c for details of global data segments. */
@@ -1051,13 +1037,9 @@
# define DATAEND ((ptr_t)get_end())
# define USE_MMAP_ANON
# define MPROTECT_VDB
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <unistd.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# define GETPAGESIZE() (unsigned)getpagesize()
# if defined(USE_PPC_PREFETCH) && defined(__GNUC__)
/* The performance impact of prefetches is untested */
@@ -1074,14 +1056,10 @@
# define OS_TYPE "OPENBSD"
# define ALIGNMENT 4
# ifndef GC_OPENBSD_THREADS
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <sys/param.h>
# include <uvm/uvm_extern.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
/* USRSTACK is defined in <machine/vmparam.h> but that is */
/* protected by _KERNEL in <uvm/uvm_param.h> file. */
# ifdef USRSTACK
@@ -1257,14 +1235,10 @@
/* Apparently USRSTACK is defined to be USERLIMIT, but in some */
/* installations that's undefined. We work around this with a */
/* gross hack: */
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <sys/vmparam.h>
# include <unistd.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# ifdef USERLIMIT
/* This should work everywhere, but doesn't. */
# define STACKBOTTOM ((ptr_t)USRSTACK)
@@ -1309,14 +1283,10 @@
# ifdef OPENBSD
# define OS_TYPE "OPENBSD"
# ifndef GC_OPENBSD_THREADS
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <sys/param.h>
# include <uvm/uvm_extern.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# ifdef USRSTACK
# define STACKBOTTOM ((ptr_t)USRSTACK)
# else
@@ -1382,13 +1352,9 @@
# endif
# ifdef HAIKU
# define OS_TYPE "HAIKU"
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <OS.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# define GETPAGESIZE() (unsigned)B_PAGE_SIZE
extern int etext[];
# define DATASTART ((ptr_t)((((word)(etext)) + 0xfff) & ~0xfff))
@@ -1410,13 +1376,9 @@
/* Apparently USRSTACK is defined to be USERLIMIT, but in some */
/* installations that's undefined. We work around this with a */
/* gross hack: */
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <sys/vmparam.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# ifdef USERLIMIT
/* This should work everywhere, but doesn't. */
# define STACKBOTTOM ((ptr_t)USRSTACK)
@@ -1469,13 +1431,9 @@
# define DATAEND ((ptr_t)(&_end))
# define STACK_GROWS_DOWN
# define HEURISTIC2
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <unistd.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# define GETPAGESIZE() (unsigned)sysconf(_SC_PAGESIZE)
# define DYNAMIC_LOADING
# ifndef USE_MMAP
@@ -1499,13 +1457,9 @@
/* thus allowing the heap to grow to ~3GB */
# ifdef __ELF__
# define DYNAMIC_LOADING
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <features.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# if defined(__GLIBC__) && __GLIBC__ >= 2 \
|| defined(HOST_ANDROID) || defined(HOST_TIZEN)
# define SEARCH_FOR_DATA_START
@@ -1561,13 +1515,9 @@
# if defined(__GLIBC__) && !defined(__UCLIBC__)
/* Workaround lock elision implementation for some glibc. */
# define GLIBC_2_19_TSX_BUG
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <gnu/libc-version.h> /* for gnu_get_libc_version() */
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# endif
# endif
# ifdef CYGWIN32
@@ -1602,13 +1552,9 @@
# endif
# ifdef DJGPP
# define OS_TYPE "DJGPP"
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include "stubinfo.h"
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
extern int etext[];
extern int _stklen;
extern int __djgpp_stack_limit;
@@ -1620,14 +1566,10 @@
# ifdef OPENBSD
# define OS_TYPE "OPENBSD"
# ifndef GC_OPENBSD_THREADS
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <sys/param.h>
# include <uvm/uvm_extern.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# ifdef USRSTACK
# define STACKBOTTOM ((ptr_t)USRSTACK)
# else
@@ -1689,13 +1631,9 @@
# endif
# ifdef RTEMS
# define OS_TYPE "RTEMS"
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <sys/unistd.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
extern int etext[];
extern int end[];
void *rtems_get_stack_bottom(void);
@@ -1747,13 +1685,9 @@
# define STACKBOTTOM ((ptr_t)0xc0000000)
# define USE_MMAP_ANON
# define MPROTECT_VDB
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <unistd.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# define GETPAGESIZE() (unsigned)getpagesize()
/* There seems to be some issues with trylock hanging on darwin. */
/* This should be looked into some more. */
@@ -1881,14 +1815,10 @@
# define OS_TYPE "OPENBSD"
# define ALIGNMENT 4
# ifndef GC_OPENBSD_THREADS
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <sys/param.h>
# include <uvm/uvm_extern.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# ifdef USRSTACK
# define STACKBOTTOM ((ptr_t)USRSTACK)
# else
@@ -1999,13 +1929,9 @@
# define STACKBOTTOM ((ptr_t)environ)
# endif
# define DYNAMIC_LOADING
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <unistd.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# define GETPAGESIZE() (unsigned)sysconf(_SC_PAGE_SIZE)
# ifndef __GNUC__
# define PREFETCH(x) do { \
@@ -2025,14 +1951,10 @@
# ifdef OPENBSD
# define OS_TYPE "OPENBSD"
# ifndef GC_OPENBSD_THREADS
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <sys/param.h>
# include <uvm/uvm_extern.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# ifdef USRSTACK
# define STACKBOTTOM ((ptr_t)USRSTACK)
# else
@@ -2065,14 +1987,10 @@
# define OS_TYPE "OPENBSD"
# define ELF_CLASS ELFCLASS64
# ifndef GC_OPENBSD_THREADS
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <sys/param.h>
# include <uvm/uvm_extern.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# ifdef USRSTACK
# define STACKBOTTOM ((ptr_t)USRSTACK)
# else
@@ -2173,13 +2091,9 @@
# define STACKBOTTOM ((ptr_t)environ)
# define HPUX_STACKBOTTOM
# define DYNAMIC_LOADING
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <unistd.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# define GETPAGESIZE() (unsigned)sysconf(_SC_PAGE_SIZE)
/* The following was empirically determined, and is probably */
/* not very robust. */
@@ -2224,13 +2138,9 @@
# define CLEAR_DOUBLE(x) \
__asm__ (" stf.spill [%0]=f0": : "r"((void *)(x)))
# else
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <ia64intrin.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# define PREFETCH(x) __lfetch(__lfhint_none, (x))
# define GC_PREFETCH_FOR_WRITE(x) __lfetch(__lfhint_nta, (x))
# define CLEAR_DOUBLE(x) __stf_spill((void *)(x), 0)
@@ -2357,13 +2267,9 @@
# define STACKBOTTOM ((ptr_t)0x16fdfffff)
# define USE_MMAP_ANON
# define MPROTECT_VDB
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <unistd.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# define GETPAGESIZE() (unsigned)getpagesize()
/* FIXME: There seems to be some issues with trylock hanging on */
/* darwin. This should be looked into some more. */
@@ -2421,17 +2327,13 @@
# define STACK_GRAN 0x10000000
# ifdef __ELF__
# define DYNAMIC_LOADING
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <features.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
-# if defined(__GLIBC__) && __GLIBC__ >= 2 \
+ EXTERN_C_BEGIN
+# if defined(__GLIBC__) && __GLIBC__ >= 2 \
|| defined(HOST_ANDROID) || defined(HOST_TIZEN)
# define SEARCH_FOR_DATA_START
-# else
+# else
extern char **__environ;
# define DATASTART ((ptr_t)(&__environ))
/* hideous kludge: __environ is the first */
@@ -2442,12 +2344,12 @@
/* would include .rodata, which may */
/* contain large read-only data tables */
/* that we'd rather not scan. */
-# endif
- extern int _end[];
-# define DATAEND ((ptr_t)(_end))
+# endif
+ extern int _end[];
+# define DATAEND ((ptr_t)(_end))
# else
- extern int etext[];
-# define DATASTART ((ptr_t)((((word)(etext)) + 0xfff) & ~0xfff))
+ extern int etext[];
+# define DATASTART ((ptr_t)((((word)(etext)) + 0xfff) & ~0xfff))
# endif
# endif
# ifdef MSWINCE
@@ -2482,13 +2384,9 @@
# define STACKBOTTOM ((ptr_t)0x30000000)
# define USE_MMAP_ANON
# define MPROTECT_VDB
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <unistd.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# define GETPAGESIZE() (unsigned)getpagesize()
/* FIXME: There seems to be some issues with trylock hanging on */
/* darwin. This should be looked into some more. */
@@ -2500,14 +2398,10 @@
# ifdef OPENBSD
# define OS_TYPE "OPENBSD"
# ifndef GC_OPENBSD_THREADS
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <sys/param.h>
# include <uvm/uvm_extern.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# ifdef USRSTACK
# define STACKBOTTOM ((ptr_t)USRSTACK)
# else
@@ -2590,14 +2484,10 @@
# ifdef OPENBSD
# define OS_TYPE "OPENBSD"
# ifndef GC_OPENBSD_THREADS
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <sys/param.h>
# include <uvm/uvm_extern.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# ifdef USRSTACK
# define STACKBOTTOM ((ptr_t)USRSTACK)
# else
@@ -2665,13 +2555,9 @@
# ifdef SN_TARGET_ORBIS
# define DATASTART (ptr_t)ALIGNMENT
# define DATAEND (ptr_t)ALIGNMENT
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <pthread.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
void *ps4_get_stack_bottom(void);
# define STACKBOTTOM ((ptr_t)ps4_get_stack_bottom())
# endif
@@ -2679,14 +2565,10 @@
# define OS_TYPE "OPENBSD"
# define ELF_CLASS ELFCLASS64
# ifndef GC_OPENBSD_THREADS
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <sys/param.h>
# include <uvm/uvm_extern.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# ifdef USRSTACK
# define STACKBOTTOM ((ptr_t)USRSTACK)
# else
@@ -2711,13 +2593,9 @@
# endif
# ifdef __ELF__
# define DYNAMIC_LOADING
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <features.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# define SEARCH_FOR_DATA_START
extern int _end[];
# define DATAEND ((ptr_t)(_end))
@@ -2735,13 +2613,9 @@
# if defined(__GLIBC__) && !defined(__UCLIBC__)
/* Workaround lock elision implementation for some glibc. */
# define GLIBC_2_19_TSX_BUG
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <gnu/libc-version.h> /* for gnu_get_libc_version() */
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# endif
# endif
# ifdef DARWIN
@@ -2757,13 +2631,9 @@
# define STACKBOTTOM ((ptr_t)0x7fff5fc00000)
# define USE_MMAP_ANON
# define MPROTECT_VDB
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <unistd.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# define GETPAGESIZE() (unsigned)getpagesize()
/* There seems to be some issues with trylock hanging on darwin. */
/* This should be looked into some more. */
@@ -2809,13 +2679,9 @@
# endif
# ifdef HAIKU
# define OS_TYPE "HAIKU"
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <OS.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# define GETPAGESIZE() (unsigned)B_PAGE_SIZE
# define HEURISTIC2
# define SEARCH_FOR_DATA_START
@@ -2838,13 +2704,9 @@
/* Apparently USRSTACK is defined to be USERLIMIT, but in some */
/* installations that's undefined. We work around this with a */
/* gross hack: */
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <sys/vmparam.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# ifdef USERLIMIT
/* This should work everywhere, but doesn't. */
# define STACKBOTTOM ((ptr_t)USRSTACK)
@@ -2919,22 +2781,18 @@
# define MPROTECT_VDB
# ifdef __ELF__
# define DYNAMIC_LOADING
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <features.h>
-# ifdef __cplusplus
- extern "C" {
+ EXTERN_C_BEGIN
+# if defined(__GLIBC__) && __GLIBC__ >= 2
+# define SEARCH_FOR_DATA_START
+# else
+# error --> unknown Hexagon libc configuration
# endif
-# if defined(__GLIBC__) && __GLIBC__ >= 2
-# define SEARCH_FOR_DATA_START
-# else
-# error --> unknown Hexagon libc configuration
-# endif
- extern int _end[];
-# define DATAEND ((ptr_t)(_end))
+ extern int _end[];
+# define DATAEND ((ptr_t)(_end))
# elif !defined(CPPCHECK)
-# error --> bad Hexagon Linux configuration
+# error --> bad Hexagon Linux configuration
# endif
# else
# error --> unknown Hexagon OS configuration
@@ -3065,26 +2923,18 @@
#if (defined(SVR4) || defined(HOST_ANDROID) || defined(HOST_TIZEN)) \
&& !defined(GETPAGESIZE)
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <unistd.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# define GETPAGESIZE() (unsigned)sysconf(_SC_PAGESIZE)
#endif
#ifndef GETPAGESIZE
# if defined(SOLARIS) || defined(IRIX5) || defined(LINUX) \
|| defined(NETBSD) || defined(FREEBSD) || defined(HPUX)
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <unistd.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# endif
# define GETPAGESIZE() (unsigned)getpagesize()
#endif
@@ -3141,13 +2991,9 @@
#endif
#ifdef GC_OPENBSD_THREADS
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include <sys/param.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
/* Prior to 5.2 release, OpenBSD had user threads and required */
/* special handling. */
# if OpenBSD < 201211
@@ -3730,8 +3576,6 @@
# endif
#endif /* GC_PRIVATE_H */
-#ifdef __cplusplus
- } /* extern "C" */
-#endif
+EXTERN_C_END
#endif /* GCCONFIG_H */
diff --git a/include/private/pthread_stop_world.h b/include/private/pthread_stop_world.h
index 2293aada..080b682c 100644
--- a/include/private/pthread_stop_world.h
+++ b/include/private/pthread_stop_world.h
@@ -18,10 +18,7 @@
#ifndef GC_PTHREAD_STOP_WORLD_H
#define GC_PTHREAD_STOP_WORLD_H
-/* Note: never put extern "C" around an #include. */
-#ifdef __cplusplus
- extern "C" {
-#endif
+EXTERN_C_BEGIN
struct thread_stop_info {
# if !defined(GC_OPENBSD_UTHREADS) && !defined(NACL)
@@ -51,8 +48,6 @@ struct thread_stop_info {
GC_INNER void GC_stop_init(void);
-#ifdef __cplusplus
- } /* extern "C" */
-#endif
+EXTERN_C_END
#endif
diff --git a/include/private/pthread_support.h b/include/private/pthread_support.h
index 57a6cd90..8df6bc21 100644
--- a/include/private/pthread_support.h
+++ b/include/private/pthread_support.h
@@ -36,10 +36,7 @@
# include "dbg_mlc.h" /* for oh type */
#endif
-/* Note: never put extern "C" around an #include. */
-#ifdef __cplusplus
- extern "C" {
-#endif
+EXTERN_C_BEGIN
/* We use the allocation lock to protect thread-related data structures. */
@@ -184,9 +181,7 @@ GC_INNER_PTHRSTART GC_thread GC_start_rtn_prepare_thread(
struct GC_stack_base *sb, void *arg);
GC_INNER_PTHRSTART void GC_thread_exit_proc(void *);
-#ifdef __cplusplus
- } /* extern "C" */
-#endif
+EXTERN_C_END
#endif /* GC_PTHREADS && !GC_WIN32_THREADS */
diff --git a/include/private/specific.h b/include/private/specific.h
index 1367a252..1cc1f6b0 100644
--- a/include/private/specific.h
+++ b/include/private/specific.h
@@ -14,10 +14,7 @@
#include <errno.h>
-/* Note: never put extern "C" around an #include. */
-#ifdef __cplusplus
- extern "C" {
-#endif
+EXTERN_C_BEGIN
/* Called during key creation or setspecific. */
/* For the GC we already hold lock. */
@@ -103,6 +100,4 @@ GC_INLINE void * GC_getspecific(tsd * key)
return GC_slow_getspecific(key, qtid, entry_ptr);
}
-#ifdef __cplusplus
- } /* extern "C" */
-#endif
+EXTERN_C_END
diff --git a/include/private/thread_local_alloc.h b/include/private/thread_local_alloc.h
index 268e3ec2..e01133de 100644
--- a/include/private/thread_local_alloc.h
+++ b/include/private/thread_local_alloc.h
@@ -34,10 +34,7 @@
#include <stdlib.h>
-/* Note: never put extern "C" around an #include. */
-#ifdef __cplusplus
- extern "C" {
-#endif
+EXTERN_C_BEGIN
#if !defined(USE_PTHREAD_SPECIFIC) && !defined(USE_WIN32_SPECIFIC) \
&& !defined(USE_WIN32_COMPILER_TLS) && !defined(USE_COMPILER_TLS) \
@@ -134,17 +131,13 @@ typedef struct thread_local_freelists {
# define GC_remove_specific_after_fork(key, t) (void)0
typedef void * GC_key_t;
#elif defined(USE_WIN32_SPECIFIC)
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN 1
# endif
# define NOSERVICE
+ EXTERN_C_END
# include <windows.h>
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
# define GC_getspecific TlsGetValue
# define GC_setspecific(key, v) !TlsSetValue(key, v)
/* We assume 0 == success, msft does the opposite. */
@@ -159,13 +152,9 @@ typedef struct thread_local_freelists {
# define GC_remove_specific_after_fork(key, t) (void)0
typedef DWORD GC_key_t;
#elif defined(USE_CUSTOM_SPECIFIC)
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
# include "private/specific.h"
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
#else
# error implement me
#endif
@@ -208,9 +197,7 @@ extern
/* for cleanup on thread exit. But the thread support layer makes sure */
/* that GC_thread_key is traced, if necessary. */
-#ifdef __cplusplus
- } /* extern "C" */
-#endif
+EXTERN_C_END
#endif /* THREAD_LOCAL_ALLOC */
diff --git a/os_dep.c b/os_dep.c
index f7369ac2..1cd4e890 100644
--- a/os_dep.c
+++ b/os_dep.c
@@ -3914,9 +3914,7 @@ GC_INNER void GC_remove_protection(struct hblk *h, word nblocks,
#include <mach/task.h>
#include <pthread.h>
-#ifdef __cplusplus
- extern "C" {
-#endif
+EXTERN_C_BEGIN
/* Some of the following prototypes are missing in any header, although */
/* they are documented. Some are in mach/exc.h file. */
@@ -3961,9 +3959,7 @@ catch_exception_raise_state_identity(mach_port_name_t exception_port,
int flavor, thread_state_t old_state, int old_stateCnt,
thread_state_t new_state, int new_stateCnt);
-#ifdef __cplusplus
- } /* extern "C" */
-#endif
+EXTERN_C_END
/* These should never be called, but just in case... */
GC_API_OSCALL kern_return_t
diff --git a/tests/test.c b/tests/test.c
index 452ad720..a05358fe 100644
--- a/tests/test.c
+++ b/tests/test.c
@@ -213,14 +213,9 @@ volatile AO_t extra_count = 0; /* Amount of space wasted in cons node; */
/* chktree (for other purposes). */
#if defined(GC_AMIGA_FASTALLOC) && defined(AMIGA)
-
-# ifdef __cplusplus
- extern "C" {
-# endif
+ EXTERN_C_BEGIN
void GC_amiga_free_all_mem(void);
-# ifdef __cplusplus
- } /* extern "C" */
-# endif
+ EXTERN_C_END
void Amiga_Fail(void){GC_amiga_free_all_mem();abort();}
# define FAIL Amiga_Fail()