Debian Codegraph @

external/bdwgc/include/gc_config_macros.h

raw
1 /*
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.
6 * All rights reserved.
7 *
8 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
9 * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
10 *
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.
16 */
17
18 /* This should never be included directly; it is included only from gc.h. */
19 /* We separate it only to make gc.h more suitable as documentation. */
20 #if defined(GC_H)
21
22 /* Convenient internal macro to test version of GCC. */
23 #if defined(__GNUC__) && defined(__GNUC_MINOR__)
24 # define GC_GNUC_PREREQ(major, minor) \
25 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((major) << 16) + (minor))
26 #else
27 # define GC_GNUC_PREREQ(major, minor) 0 /* FALSE */
28 #endif
29
30 /* Some tests for old macros. These violate our namespace rules and */
31 /* will disappear shortly. Use the GC_ names. */
32 #if defined(SOLARIS_THREADS) || defined(_SOLARIS_THREADS) \
33 || defined(_SOLARIS_PTHREADS) || defined(GC_SOLARIS_PTHREADS)
34 /* We no longer support old style Solaris threads. */
35 /* GC_SOLARIS_THREADS now means pthreads. */
36 # ifndef GC_SOLARIS_THREADS
37 # define GC_SOLARIS_THREADS
38 # endif
39 #endif
40 #if defined(IRIX_THREADS)
41 # define GC_IRIX_THREADS
42 #endif
43 #if defined(DGUX_THREADS) && !defined(GC_DGUX386_THREADS)
44 # define GC_DGUX386_THREADS
45 #endif
46 #if defined(AIX_THREADS)
47 # define GC_AIX_THREADS
48 #endif
49 #if defined(HPUX_THREADS)
50 # define GC_HPUX_THREADS
51 #endif
52 #if defined(OSF1_THREADS)
53 # define GC_OSF1_THREADS
54 #endif
55 #if defined(LINUX_THREADS)
56 # define GC_LINUX_THREADS
57 #endif
58 #if defined(WIN32_THREADS)
59 # define GC_WIN32_THREADS
60 #endif
61 #if defined(RTEMS_THREADS)
62 # define GC_RTEMS_PTHREADS
63 #endif
64 #if defined(USE_LD_WRAP)
65 # define GC_USE_LD_WRAP
66 #endif
67
68 #if defined(GC_WIN32_PTHREADS) && !defined(GC_WIN32_THREADS)
69 /* Using pthreads-win32 library (or other Win32 implementation). */
70 # define GC_WIN32_THREADS
71 #endif
72
73
74 #if defined(GC_AIX_THREADS) || defined(GC_DARWIN_THREADS) \
75 || defined(GC_DGUX386_THREADS) || defined(GC_FREEBSD_THREADS) \
76 || defined(GC_HPUX_THREADS) \
77 || defined(GC_IRIX_THREADS) || defined(GC_LINUX_THREADS) \
78 || defined(GC_NETBSD_THREADS) || defined(GC_OPENBSD_THREADS) \
79 || defined(GC_OSF1_THREADS) || defined(GC_SOLARIS_THREADS) \
80 || defined(GC_WIN32_THREADS) || defined(GC_RTEMS_PTHREADS) \
81 || defined(SN_TARGET_PSP2)
82 # ifndef GC_THREADS
83 # define GC_THREADS
84 # endif
85 #elif defined(GC_THREADS)
86 # if defined(__linux__)
87 # define GC_LINUX_THREADS
88 # elif defined(_PA_RISC1_1) || defined(_PA_RISC2_0) || defined(hppa) \
89 || defined(__HPPA) || (defined(__ia64) && defined(_HPUX_SOURCE))
90 # define GC_HPUX_THREADS
91 # elif defined(__HAIKU__)
92 # define GC_HAIKU_THREADS
93 # elif defined(__OpenBSD__)
94 # define GC_OPENBSD_THREADS
95 # elif ( defined(__DragonFly__) || defined(__FreeBSD_kernel__) \
96 || defined(__FreeBSD__) ) && !defined(GC_NO_FREEBSD)
97 # define GC_FREEBSD_THREADS
98 # elif defined(__NetBSD__)
99 # define GC_NETBSD_THREADS
100 # elif defined(__alpha) || defined(__alpha__) /* && !Linux && !xBSD */
101 # define GC_OSF1_THREADS
102 # elif (defined(mips) || defined(__mips) || defined(_mips)) \
103 && !(defined(nec_ews) || defined(_nec_ews) \
104 || defined(ultrix) || defined(__ultrix))
105 # define GC_IRIX_THREADS
106 # elif defined(__sparc) /* && !Linux */ \
107 || ((defined(sun) || defined(__sun)) \
108 && (defined(i386) || defined(__i386__) \
109 || defined(__amd64) || defined(__amd64__)))
110 # define GC_SOLARIS_THREADS
111 # elif defined(__APPLE__) && defined(__MACH__)
112 # define GC_DARWIN_THREADS
113 # endif
114 # if defined(DGUX) && (defined(i386) || defined(__i386__))
115 # define GC_DGUX386_THREADS
116 # endif
117 # if defined(_AIX)
118 # define GC_AIX_THREADS
119 # endif
120 # if (defined(_WIN32) || defined(_MSC_VER) || defined(__BORLANDC__) \
121 || defined(__CYGWIN32__) || defined(__CYGWIN__) || defined(__CEGCC__) \
122 || defined(_WIN32_WCE) || defined(__MINGW32__)) \
123 && !defined(GC_WIN32_THREADS)
124 /* Either posix or native Win32 threads. */
125 # define GC_WIN32_THREADS
126 # endif
127 # if defined(__rtems__) && (defined(i386) || defined(__i386__))
128 # define GC_RTEMS_PTHREADS
129 # endif
130 #endif /* GC_THREADS */
131
132 #undef GC_PTHREADS
133 #if (!defined(GC_WIN32_THREADS) || defined(GC_WIN32_PTHREADS) \
134 || defined(__CYGWIN32__) || defined(__CYGWIN__)) && defined(GC_THREADS) \
135 && !defined(NN_PLATFORM_CTR) && !defined(NN_BUILD_TARGET_PLATFORM_NX)
136 /* Posix threads. */
137 # define GC_PTHREADS
138 #endif
139
140 #if !defined(_PTHREADS) && defined(GC_NETBSD_THREADS)
141 # define _PTHREADS
142 #endif
143
144 #if defined(GC_DGUX386_THREADS) && !defined(_POSIX4A_DRAFT10_SOURCE)
145 # define _POSIX4A_DRAFT10_SOURCE 1
146 #endif
147
148 #if !defined(_REENTRANT) && defined(GC_PTHREADS) && !defined(GC_WIN32_THREADS)
149 /* Better late than never. This fails if system headers that depend */
150 /* on this were previously included. */
151 # define _REENTRANT
152 #endif
153
154 #define __GC
155 #if !defined(_WIN32_WCE) || defined(__GNUC__)
156 # include <stddef.h>
157 # if defined(__MINGW32__) && !defined(_WIN32_WCE)
158 # include <stdint.h>
159 /* We mention uintptr_t. */
160 /* Perhaps this should be included in pure msft environments */
161 /* as well? */
162 # endif
163 #else /* _WIN32_WCE */
164 /* Yet more kludges for WinCE. */
165 # include <stdlib.h> /* size_t is defined here */
166 # ifndef _PTRDIFF_T_DEFINED
167 /* ptrdiff_t is not defined */
168 # define _PTRDIFF_T_DEFINED
169 typedef long ptrdiff_t;
170 # endif
171 #endif /* _WIN32_WCE */
172
173 #if !defined(GC_NOT_DLL) && !defined(GC_DLL) \
174 && ((defined(_DLL) && !defined(__GNUC__)) \
175 || (defined(DLL_EXPORT) && defined(GC_BUILD)))
176 # define GC_DLL
177 #endif
178
179 #if defined(GC_DLL) && !defined(GC_API)
180
181 # if defined(__MINGW32__) || defined(__CEGCC__)
182 # if defined(GC_BUILD) || defined(__MINGW32_DELAY_LOAD__)
183 # define GC_API __declspec(dllexport)
184 # else
185 # define GC_API __declspec(dllimport)
186 # endif
187
188 # elif defined(_MSC_VER) || defined(__DMC__) || defined(__BORLANDC__) \
189 || defined(__CYGWIN__)
190 # ifdef GC_BUILD
191 # define GC_API extern __declspec(dllexport)
192 # else
193 # define GC_API __declspec(dllimport)
194 # endif
195
196 # elif defined(__WATCOMC__)
197 # ifdef GC_BUILD
198 # define GC_API extern __declspec(dllexport)
199 # else
200 # define GC_API extern __declspec(dllimport)
201 # endif
202
203 # elif defined(__SYMBIAN32__)
204 # ifdef GC_BUILD
205 # define GC_API extern EXPORT_C
206 # else
207 # define GC_API extern IMPORT_C
208 # endif
209
210 # elif defined(__GNUC__)
211 /* Only matters if used in conjunction with -fvisibility=hidden option. */
212 # if defined(GC_BUILD) && !defined(GC_NO_VISIBILITY) \
213 && (GC_GNUC_PREREQ(4, 0) || defined(GC_VISIBILITY_HIDDEN_SET))
214 # define GC_API extern __attribute__((__visibility__("default")))
215 # endif
216 # endif
217 #endif /* GC_DLL */
218
219 #ifndef GC_API
220 # define GC_API extern
221 #endif
222
223 #ifndef GC_CALL
224 # define GC_CALL
225 #endif
226
227 #ifndef GC_CALLBACK
228 # define GC_CALLBACK GC_CALL
229 #endif
230
231 #ifndef GC_ATTR_MALLOC
232 /* 'malloc' attribute should be used for all malloc-like functions */
233 /* (to tell the compiler that a function may be treated as if any */
234 /* non-NULL pointer it returns cannot alias any other pointer valid */
235 /* when the function returns). If the client code violates this rule */
236 /* by using custom GC_oom_func then define GC_OOM_FUNC_RETURNS_ALIAS. */
237 # ifdef GC_OOM_FUNC_RETURNS_ALIAS
238 # define GC_ATTR_MALLOC /* empty */
239 # elif GC_GNUC_PREREQ(3, 1)
240 # define GC_ATTR_MALLOC __attribute__((__malloc__))
241 # elif defined(_MSC_VER) && (_MSC_VER >= 1900) && !defined(__EDG__)
242 # define GC_ATTR_MALLOC \
243 __declspec(allocator) __declspec(noalias) __declspec(restrict)
244 # elif defined(_MSC_VER) && _MSC_VER >= 1400
245 # define GC_ATTR_MALLOC __declspec(noalias) __declspec(restrict)
246 # else
247 # define GC_ATTR_MALLOC
248 # endif
249 #endif
250
251 #ifndef GC_ATTR_ALLOC_SIZE
252 /* 'alloc_size' attribute improves __builtin_object_size correctness. */
253 # undef GC_ATTR_CALLOC_SIZE
254 # ifdef __clang__
255 # if __has_attribute(__alloc_size__)
256 # define GC_ATTR_ALLOC_SIZE(argnum) __attribute__((__alloc_size__(argnum)))
257 # define GC_ATTR_CALLOC_SIZE(n, s) __attribute__((__alloc_size__(n, s)))
258 # else
259 # define GC_ATTR_ALLOC_SIZE(argnum) /* empty */
260 # endif
261 # elif GC_GNUC_PREREQ(4, 3) && !defined(__ICC)
262 # define GC_ATTR_ALLOC_SIZE(argnum) __attribute__((__alloc_size__(argnum)))
263 # define GC_ATTR_CALLOC_SIZE(n, s) __attribute__((__alloc_size__(n, s)))
264 # else
265 # define GC_ATTR_ALLOC_SIZE(argnum) /* empty */
266 # endif
267 #endif
268
269 #ifndef GC_ATTR_CALLOC_SIZE
270 # define GC_ATTR_CALLOC_SIZE(n, s) /* empty */
271 #endif
272
273 #ifndef GC_ATTR_NONNULL
274 # if GC_GNUC_PREREQ(4, 0)
275 # define GC_ATTR_NONNULL(argnum) __attribute__((__nonnull__(argnum)))
276 # else
277 # define GC_ATTR_NONNULL(argnum) /* empty */
278 # endif
279 #endif
280
281 #ifndef GC_ATTR_DEPRECATED
282 # ifdef GC_BUILD
283 # undef GC_ATTR_DEPRECATED
284 # define GC_ATTR_DEPRECATED /* empty */
285 # elif GC_GNUC_PREREQ(4, 0)
286 # define GC_ATTR_DEPRECATED __attribute__((__deprecated__))
287 # elif defined(_MSC_VER) && _MSC_VER >= 1200
288 # define GC_ATTR_DEPRECATED __declspec(deprecated)
289 # else
290 # define GC_ATTR_DEPRECATED /* empty */
291 # endif
292 #endif
293
294 #if defined(__sgi) && !defined(__GNUC__) && _COMPILER_VERSION >= 720
295 # define GC_ADD_CALLER
296 # define GC_RETURN_ADDR (GC_word)__return_address
297 #endif
298
299 #if defined(__linux__) || defined(__GLIBC__)
300 # if !defined(__native_client__)
301 # include <features.h>
302 # endif
303 # if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 || __GLIBC__ > 2) \
304 && !defined(__ia64__) \
305 && !defined(GC_MISSING_EXECINFO_H) \
306 && !defined(GC_HAVE_BUILTIN_BACKTRACE)
307 # define GC_HAVE_BUILTIN_BACKTRACE
308 # endif
309 # if defined(__i386__) || defined(__amd64__) || defined(__x86_64__)
310 # define GC_CAN_SAVE_CALL_STACKS
311 # endif
312 #endif /* GLIBC */
313
314 #if defined(_MSC_VER) && _MSC_VER >= 1200 /* version 12.0+ (MSVC 6.0+) */ \
315 && !defined(_AMD64_) && !defined(_M_X64) && !defined(_WIN32_WCE) \
316 && !defined(GC_HAVE_NO_BUILTIN_BACKTRACE) \
317 && !defined(GC_HAVE_BUILTIN_BACKTRACE)
318 # define GC_HAVE_BUILTIN_BACKTRACE
319 #endif
320
321 #if defined(GC_HAVE_BUILTIN_BACKTRACE) && !defined(GC_CAN_SAVE_CALL_STACKS)
322 # define GC_CAN_SAVE_CALL_STACKS
323 #endif
324
325 #if defined(__sparc__)
326 # define GC_CAN_SAVE_CALL_STACKS
327 #endif
328
329 /* If we're on a platform on which we can't save call stacks, but */
330 /* gcc is normally used, we go ahead and define GC_ADD_CALLER. */
331 /* We make this decision independent of whether gcc is actually being */
332 /* used, in order to keep the interface consistent, and allow mixing */
333 /* of compilers. */
334 /* This may also be desirable if it is possible but expensive to */
335 /* retrieve the call chain. */
336 #if (defined(__linux__) || defined(__DragonFly__) || defined(__FreeBSD__) \
337 || defined(__FreeBSD_kernel__) || defined(__HAIKU__) \
338 || defined(__NetBSD__) || defined(__OpenBSD__) \
339 || defined(HOST_ANDROID) || defined(__ANDROID__)) \
340 && !defined(GC_CAN_SAVE_CALL_STACKS)
341 # define GC_ADD_CALLER
342 # if GC_GNUC_PREREQ(2, 95)
343 /* gcc knows how to retrieve return address, but we don't know */
344 /* how to generate call stacks. */
345 # define GC_RETURN_ADDR (GC_word)__builtin_return_address(0)
346 # if GC_GNUC_PREREQ(4, 0) && (defined(__i386__) || defined(__amd64__) \
347 || defined(__x86_64__) /* and probably others... */)
348 # define GC_HAVE_RETURN_ADDR_PARENT
349 # define GC_RETURN_ADDR_PARENT \
350 (GC_word)__builtin_extract_return_addr(__builtin_return_address(1))
351 # endif
352 # else
353 /* Just pass 0 for gcc compatibility. */
354 # define GC_RETURN_ADDR 0
355 # endif
356 #endif /* !GC_CAN_SAVE_CALL_STACKS */
357
358 #ifdef GC_PTHREADS
359
360 # if (defined(GC_DARWIN_THREADS) || defined(GC_WIN32_PTHREADS) \
361 || defined(__native_client__) || defined(GC_RTEMS_PTHREADS)) \
362 && !defined(GC_NO_DLOPEN)
363 /* Either there is no dlopen() or we do not need to intercept it. */
364 # define GC_NO_DLOPEN
365 # endif
366
367 # if (defined(GC_DARWIN_THREADS) || defined(GC_WIN32_PTHREADS) \
368 || defined(GC_OPENBSD_THREADS) || defined(__native_client__)) \
369 && !defined(GC_NO_PTHREAD_SIGMASK)
370 /* Either there is no pthread_sigmask() or no need to intercept it. */
371 # define GC_NO_PTHREAD_SIGMASK
372 # endif
373
374 # if defined(__native_client__)
375 /* At present, NaCl pthread_create() prototype does not have */
376 /* "const" for its "attr" argument; also, NaCl pthread_exit() one */
377 /* does not have "noreturn" attribute. */
378 # ifndef GC_PTHREAD_CREATE_CONST
379 # define GC_PTHREAD_CREATE_CONST /* empty */
380 # endif
381 # ifndef GC_HAVE_PTHREAD_EXIT
382 # define GC_HAVE_PTHREAD_EXIT
383 # define GC_PTHREAD_EXIT_ATTRIBUTE /* empty */
384 # endif
385 # endif
386
387 # if !defined(GC_HAVE_PTHREAD_EXIT) \
388 && !defined(HOST_ANDROID) && !defined(__ANDROID__) \
389 && (defined(GC_LINUX_THREADS) || defined(GC_SOLARIS_THREADS))
390 # define GC_HAVE_PTHREAD_EXIT
391 /* Intercept pthread_exit on Linux and Solaris. */
392 # if GC_GNUC_PREREQ(2, 7)
393 # define GC_PTHREAD_EXIT_ATTRIBUTE __attribute__((__noreturn__))
394 # elif defined(__NORETURN) /* used in Solaris */
395 # define GC_PTHREAD_EXIT_ATTRIBUTE __NORETURN
396 # else
397 # define GC_PTHREAD_EXIT_ATTRIBUTE /* empty */
398 # endif
399 # endif
400
401 # if (!defined(GC_HAVE_PTHREAD_EXIT) || defined(__native_client__)) \
402 && !defined(GC_NO_PTHREAD_CANCEL)
403 /* Either there is no pthread_cancel() or no need to intercept it. */
404 # define GC_NO_PTHREAD_CANCEL
405 # endif
406
407 #endif /* GC_PTHREADS */
408
409 #endif