/* 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) \
/* 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: */
# 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
# 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 */
# 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. */
# 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. */
# 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 */
# 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
/* 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)
# 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
# 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))
/* 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)
# 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
/* 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
# 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
# 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;
# 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
# 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);
# 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. */
# 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
# 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 { \
# 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
# 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
# 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. */
# 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)
# 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. */
# 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 */
/* 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
# 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. */
# 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
# 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
# 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
# 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
# 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))
# 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
# 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. */
# 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
/* 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)
# 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
#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
#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
# endif
#endif /* GC_PRIVATE_H */
-#ifdef __cplusplus
- } /* extern "C" */
-#endif
+EXTERN_C_END
#endif /* GCCONFIG_H */