2 * Copyright (c) 1994 by Xerox Corporation. All rights reserved.
3 * Copyright (c) 1996 by Silicon Graphics. All rights reserved.
4 * Copyright (c) 1998 by Fergus Henderson. All rights reserved.
5 * Copyright (c) 2000-2009 by Hewlett-Packard Development Company.
8 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
9 * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
11 * Permission is hereby granted to use or copy this program
12 * for any purpose, provided the above notices are retained on all copies.
13 * Permission to modify the code and to distribute modified code is granted,
14 * provided the above notices are retained, and a notice that the code was
15 * modified is included with the above copyright notice.
19 * This should never be included directly. It is included only from gc.h.
20 * We separate it only to make gc.h more suitable as documentation.
22 * Some tests for old macros. These violate our namespace rules and will
23 * disappear shortly. Use the GC_ names.
25 #if defined(SOLARIS_THREADS) || defined(_SOLARIS_THREADS) \
26 || defined(_SOLARIS_PTHREADS) || defined(GC_SOLARIS_PTHREADS)
27 /* We no longer support old style Solaris threads. */
28 /* GC_SOLARIS_THREADS now means pthreads. */
29 # ifndef GC_SOLARIS_THREADS
30 # define GC_SOLARIS_THREADS
33 #if defined(IRIX_THREADS)
34 # define GC_IRIX_THREADS
36 #if defined(DGUX_THREADS) && !defined(GC_DGUX386_THREADS)
37 # define GC_DGUX386_THREADS
39 #if defined(AIX_THREADS)
40 # define GC_AIX_THREADS
42 #if defined(HPUX_THREADS)
43 # define GC_HPUX_THREADS
45 #if defined(OSF1_THREADS)
46 # define GC_OSF1_THREADS
48 #if defined(LINUX_THREADS)
49 # define GC_LINUX_THREADS
51 #if defined(WIN32_THREADS)
52 # define GC_WIN32_THREADS
54 #if defined(USE_LD_WRAP)
55 # define GC_USE_LD_WRAP
58 #if defined(GC_WIN32_PTHREADS) && !defined(GC_WIN32_THREADS)
59 /* Using pthreads-w32 library. */
60 # define GC_WIN32_THREADS
63 #if defined(GC_AIX_THREADS) || defined(GC_DARWIN_THREADS) \
64 || defined(GC_DGUX386_THREADS) || defined(GC_FREEBSD_THREADS) \
65 || defined(GC_GNU_THREADS) || defined(GC_HPUX_THREADS) \
66 || defined(GC_IRIX_THREADS) || defined(GC_LINUX_THREADS) \
67 || defined(GC_NETBSD_THREADS) || defined(GC_OPENBSD_THREADS) \
68 || defined(GC_OSF1_THREADS) || defined(GC_SOLARIS_THREADS) \
69 || defined(GC_WIN32_THREADS)
73 #elif defined(GC_THREADS)
74 # if defined(__linux__)
75 # define GC_LINUX_THREADS
77 # if !defined(__linux__) && (defined(_PA_RISC1_1) || defined(_PA_RISC2_0) \
78 || defined(hppa) || defined(__HPPA)) \
79 || (defined(__ia64) && defined(_HPUX_SOURCE))
80 # define GC_HPUX_THREADS
82 # if !defined(__linux__) && (defined(__alpha) || defined(__alpha__))
83 # define GC_OSF1_THREADS
85 # if defined(__mips) && !defined(__linux__)
86 # define GC_IRIX_THREADS
88 # if defined(__sparc) && !defined(__linux__) \
89 || defined(sun) && (defined(i386) || defined(__i386__) \
90 || defined(__amd64__))
91 # define GC_SOLARIS_THREADS
92 # elif defined(__APPLE__) && defined(__MACH__)
93 # define GC_DARWIN_THREADS
94 # elif defined(__OpenBSD__)
95 # define GC_OPENBSD_THREADS
96 # elif !defined(GC_LINUX_THREADS) && !defined(GC_HPUX_THREADS) \
97 && !defined(GC_OSF1_THREADS) && !defined(GC_IRIX_THREADS)
98 /* FIXME: Should we really need for FreeBSD and NetBSD to check */
99 /* that no other GC_xxx_THREADS macro is set? */
100 # if defined(__FreeBSD__) || defined(__DragonFly__)
101 # define GC_FREEBSD_THREADS
102 # elif defined(__NetBSD__)
103 # define GC_NETBSD_THREADS
106 # if defined(DGUX) && (defined(i386) || defined(__i386__))
107 # define GC_DGUX386_THREADS
110 # define GC_AIX_THREADS
112 # if (defined(_WIN32) || defined(_MSC_VER) || defined(__BORLANDC__) \
113 || defined(__CYGWIN32__) || defined(__CYGWIN__) || defined(__CEGCC__) \
114 || defined(_WIN32_WCE) || defined(__MINGW32__)) \
115 && !defined(GC_WIN32_THREADS)
116 /* Either posix or native Win32 threads. */
117 # define GC_WIN32_THREADS
119 #endif /* GC_THREADS */
122 #if (!defined(GC_WIN32_THREADS) || defined(GC_WIN32_PTHREADS) \
123 || defined(__CYGWIN32__) || defined(__CYGWIN__)) && defined(GC_THREADS)
128 #if !defined(_PTHREADS) && defined(GC_NETBSD_THREADS)
132 #if defined(GC_DGUX386_THREADS) && !defined(_POSIX4A_DRAFT10_SOURCE)
133 # define _POSIX4A_DRAFT10_SOURCE 1
136 #if !defined(_REENTRANT) && defined(GC_PTHREADS) && !defined(GC_WIN32_THREADS)
137 /* Better late than never. This fails if system headers that depend */
138 /* on this were previously included. */
143 #if !defined(_WIN32_WCE) || defined(__GNUC__)
145 # if defined(__MINGW32__) && !defined(_WIN32_WCE)
147 /* We mention uintptr_t. */
148 /* Perhaps this should be included in pure msft environments */
151 #else /* ! _WIN32_WCE */
152 /* Yet more kludges for WinCE */
153 # include <stdlib.h> /* size_t is defined here */
154 # ifndef _PTRDIFF_T_DEFINED
155 /* ptrdiff_t is not defined */
156 # define _PTRDIFF_T_DEFINED
157 typedef long ptrdiff_t;
161 #if defined(_DLL) && !defined(GC_NOT_DLL) && !defined(GC_DLL) \
162 && !defined(__GNUC__)
166 #if defined(GC_DLL) && !defined(GC_API)
168 # if defined(__MINGW32__) || defined(__CEGCC__)
170 # define GC_API __declspec(dllexport)
172 # define GC_API __declspec(dllimport)
175 # elif defined(_MSC_VER) || defined(__DMC__) || defined(__BORLANDC__) \
176 || defined(__CYGWIN__)
178 # define GC_API extern __declspec(dllexport)
180 # define GC_API __declspec(dllimport)
183 # elif defined(__WATCOMC__)
185 # define GC_API extern __declspec(dllexport)
187 # define GC_API extern __declspec(dllimport)
190 # elif defined(__GNUC__)
191 /* Only matters if used in conjunction with -fvisibility=hidden option. */
192 # if __GNUC__ >= 4 && defined(GC_BUILD)
193 # define GC_API extern __attribute__((__visibility__("default")))
200 # define GC_API extern
208 # define GC_CALLBACK GC_CALL
211 #ifndef GC_ATTR_MALLOC
212 /* 'malloc' attribute should be used for all malloc-like functions */
213 /* (to tell the compiler that a function may be treated as if any */
214 /* non-NULL pointer it returns cannot alias any other pointer valid */
215 /* when the function returns). If the client code violates this rule */
216 /* by using custom GC_oom_func then define GC_OOM_FUNC_RETURNS_ALIAS. */
217 # if !defined(GC_OOM_FUNC_RETURNS_ALIAS) && defined(__GNUC__) \
218 && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
219 # define GC_ATTR_MALLOC __attribute__((__malloc__))
221 # define GC_ATTR_MALLOC
225 #ifndef GC_ATTR_ALLOC_SIZE
226 /* 'alloc_size' attribute improves __builtin_object_size correctness. */
227 /* Only single-argument form of 'alloc_size' attribute is used. */
228 # if defined(__GNUC__) && (__GNUC__ > 4 \
229 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3 && !defined(__ICC)))
230 # define GC_ATTR_ALLOC_SIZE(argnum) __attribute__((__alloc_size__(argnum)))
232 # define GC_ATTR_ALLOC_SIZE(argnum)