2009-03-26 Jonathan Chambers <joncham@gmail.com>
[mono-project.git] / libgc / include / gc.h
blobef3a06c11f5b47a2cfc9de6e8594d0d972583ceb
1 /*
2 * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
3 * Copyright (c) 1991-1995 by Xerox Corporation. All rights reserved.
4 * Copyright 1996-1999 by Silicon Graphics. All rights reserved.
5 * Copyright 1999 by Hewlett-Packard Company. All rights reserved.
7 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
8 * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
10 * Permission is hereby granted to use or copy this program
11 * for any purpose, provided the above notices are retained on all copies.
12 * Permission to modify the code and to distribute modified code is granted,
13 * provided the above notices are retained, and a notice that the code was
14 * modified is included with the above copyright notice.
18 * Note that this defines a large number of tuning hooks, which can
19 * safely be ignored in nearly all cases. For normal use it suffices
20 * to call only GC_MALLOC and perhaps GC_REALLOC.
21 * For better performance, also look at GC_MALLOC_ATOMIC, and
22 * GC_enable_incremental. If you need an action to be performed
23 * immediately before an object is collected, look at GC_register_finalizer.
24 * If you are using Solaris threads, look at the end of this file.
25 * Everything else is best ignored unless you encounter performance
26 * problems.
29 #ifndef _GC_H
31 # define _GC_H
33 # include "gc_config_macros.h"
35 # if defined(__STDC__) || defined(__cplusplus) || defined(_AIX)
36 # define GC_PROTO(args) args
37 typedef void * GC_PTR;
38 # define GC_CONST const
39 # else
40 # define GC_PROTO(args) ()
41 typedef char * GC_PTR;
42 # define GC_CONST
43 # endif
45 # ifdef __cplusplus
46 extern "C" {
47 # endif
50 /* Define word and signed_word to be unsigned and signed types of the */
51 /* size as char * or void *. There seems to be no way to do this */
52 /* even semi-portably. The following is probably no better/worse */
53 /* than almost anything else. */
54 /* The ANSI standard suggests that size_t and ptr_diff_t might be */
55 /* better choices. But those had incorrect definitions on some older */
56 /* systems. Notably "typedef int size_t" is WRONG. */
57 #ifndef _WIN64
58 typedef unsigned long GC_word;
59 typedef long GC_signed_word;
60 #else
61 /* Win64 isn't really supported yet, but this is the first step. And */
62 /* it might cause error messages to show up in more plausible places. */
63 /* This needs basetsd.h, which is included by windows.h. */
64 typedef unsigned __int64 GC_word;
65 typedef __int64 GC_signed_word;
66 #endif
68 /* Public read-only variables */
70 GC_API GC_word GC_gc_no;/* Counter incremented per collection. */
71 /* Includes empty GCs at startup. */
73 GC_API int GC_parallel; /* GC is parallelized for performance on */
74 /* multiprocessors. Currently set only */
75 /* implicitly if collector is built with */
76 /* -DPARALLEL_MARK and if either: */
77 /* Env variable GC_NPROC is set to > 1, or */
78 /* GC_NPROC is not set and this is an MP. */
79 /* If GC_parallel is set, incremental */
80 /* collection is only partially functional, */
81 /* and may not be desirable. */
84 /* Public R/W variables */
86 GC_API GC_PTR (*GC_oom_fn) GC_PROTO((size_t bytes_requested));
87 /* When there is insufficient memory to satisfy */
88 /* an allocation request, we return */
89 /* (*GC_oom_fn)(). By default this just */
90 /* returns 0. */
91 /* If it returns, it must return 0 or a valid */
92 /* pointer to a previously allocated heap */
93 /* object. */
95 typedef enum {
96 GC_EVENT_START,
97 GC_EVENT_MARK_START,
98 GC_EVENT_MARK_END,
99 GC_EVENT_RECLAIM_START,
100 GC_EVENT_RECLAIM_END,
101 GC_EVENT_END,
102 GC_EVENT_PRE_STOP_WORLD,
103 GC_EVENT_POST_STOP_WORLD,
104 GC_EVENT_PRE_START_WORLD,
105 GC_EVENT_POST_START_WORLD
106 } GCEventType;
108 GC_API void (*GC_notify_event) GC_PROTO((GCEventType event_type));
109 /* Invoked at specific points during every collection.
112 GC_API void (*GC_on_heap_resize) GC_PROTO((size_t new_size));
113 /* Invoked when the heap grows or shrinks */
115 GC_API int GC_find_leak;
116 /* Do not actually garbage collect, but simply */
117 /* report inaccessible memory that was not */
118 /* deallocated with GC_free. Initial value */
119 /* is determined by FIND_LEAK macro. */
121 GC_API int GC_all_interior_pointers;
122 /* Arrange for pointers to object interiors to */
123 /* be recognized as valid. May not be changed */
124 /* after GC initialization. */
125 /* Initial value is determined by */
126 /* -DALL_INTERIOR_POINTERS. */
127 /* Unless DONT_ADD_BYTE_AT_END is defined, this */
128 /* also affects whether sizes are increased by */
129 /* at least a byte to allow "off the end" */
130 /* pointer recognition. */
131 /* MUST BE 0 or 1. */
133 GC_API int GC_quiet; /* Disable statistics output. Only matters if */
134 /* collector has been compiled with statistics */
135 /* enabled. This involves a performance cost, */
136 /* and is thus not the default. */
138 GC_API int GC_finalize_on_demand;
139 /* If nonzero, finalizers will only be run in */
140 /* response to an explicit GC_invoke_finalizers */
141 /* call. The default is determined by whether */
142 /* the FINALIZE_ON_DEMAND macro is defined */
143 /* when the collector is built. */
145 GC_API int GC_java_finalization;
146 /* Mark objects reachable from finalizable */
147 /* objects in a separate postpass. This makes */
148 /* it a bit safer to use non-topologically- */
149 /* ordered finalization. Default value is */
150 /* determined by JAVA_FINALIZATION macro. */
152 GC_API void (* GC_finalizer_notifier)(void);
153 /* Invoked by the collector when there are */
154 /* objects to be finalized. Invoked at most */
155 /* once per GC cycle. Never invoked unless */
156 /* GC_finalize_on_demand is set. */
157 /* Typically this will notify a finalization */
158 /* thread, which will call GC_invoke_finalizers */
159 /* in response. */
161 GC_API int GC_dont_gc; /* != 0 ==> Dont collect. In versions 6.2a1+, */
162 /* this overrides explicit GC_gcollect() calls. */
163 /* Used as a counter, so that nested enabling */
164 /* and disabling work correctly. Should */
165 /* normally be updated with GC_enable() and */
166 /* GC_disable() calls. */
167 /* Direct assignment to GC_dont_gc is */
168 /* deprecated. */
170 GC_API int GC_dont_expand;
171 /* Dont expand heap unless explicitly requested */
172 /* or forced to. */
174 GC_API int GC_use_entire_heap;
175 /* Causes the nonincremental collector to use the */
176 /* entire heap before collecting. This was the only */
177 /* option for GC versions < 5.0. This sometimes */
178 /* results in more large block fragmentation, since */
179 /* very larg blocks will tend to get broken up */
180 /* during each GC cycle. It is likely to result in a */
181 /* larger working set, but lower collection */
182 /* frequencies, and hence fewer instructions executed */
183 /* in the collector. */
185 GC_API int GC_full_freq; /* Number of partial collections between */
186 /* full collections. Matters only if */
187 /* GC_incremental is set. */
188 /* Full collections are also triggered if */
189 /* the collector detects a substantial */
190 /* increase in the number of in-use heap */
191 /* blocks. Values in the tens are now */
192 /* perfectly reasonable, unlike for */
193 /* earlier GC versions. */
195 GC_API GC_word GC_non_gc_bytes;
196 /* Bytes not considered candidates for collection. */
197 /* Used only to control scheduling of collections. */
198 /* Updated by GC_malloc_uncollectable and GC_free. */
199 /* Wizards only. */
201 GC_API int GC_no_dls;
202 /* Don't register dynamic library data segments. */
203 /* Wizards only. Should be used only if the */
204 /* application explicitly registers all roots. */
205 /* In Microsoft Windows environments, this will */
206 /* usually also prevent registration of the */
207 /* main data segment as part of the root set. */
209 GC_API GC_word GC_free_space_divisor;
210 /* We try to make sure that we allocate at */
211 /* least N/GC_free_space_divisor bytes between */
212 /* collections, where N is the heap size plus */
213 /* a rough estimate of the root set size. */
214 /* Initially, GC_free_space_divisor = 3. */
215 /* Increasing its value will use less space */
216 /* but more collection time. Decreasing it */
217 /* will appreciably decrease collection time */
218 /* at the expense of space. */
219 /* GC_free_space_divisor = 1 will effectively */
220 /* disable collections. */
222 GC_API GC_word GC_max_retries;
223 /* The maximum number of GCs attempted before */
224 /* reporting out of memory after heap */
225 /* expansion fails. Initially 0. */
228 GC_API char *GC_stackbottom; /* Cool end of user stack. */
229 /* May be set in the client prior to */
230 /* calling any GC_ routines. This */
231 /* avoids some overhead, and */
232 /* potentially some signals that can */
233 /* confuse debuggers. Otherwise the */
234 /* collector attempts to set it */
235 /* automatically. */
236 /* For multithreaded code, this is the */
237 /* cold end of the stack for the */
238 /* primordial thread. */
240 GC_API int GC_dont_precollect; /* Don't collect as part of */
241 /* initialization. Should be set only */
242 /* if the client wants a chance to */
243 /* manually initialize the root set */
244 /* before the first collection. */
245 /* Interferes with blacklisting. */
246 /* Wizards only. */
248 GC_API unsigned long GC_time_limit;
249 /* If incremental collection is enabled, */
250 /* We try to terminate collections */
251 /* after this many milliseconds. Not a */
252 /* hard time bound. Setting this to */
253 /* GC_TIME_UNLIMITED will essentially */
254 /* disable incremental collection while */
255 /* leaving generational collection */
256 /* enabled. */
257 # define GC_TIME_UNLIMITED 999999
258 /* Setting GC_time_limit to this value */
259 /* will disable the "pause time exceeded"*/
260 /* tests. */
262 /* Public procedures */
264 /* Initialize the collector. This is only required when using thread-local
265 * allocation, since unlike the regular allocation routines, GC_local_malloc
266 * is not self-initializing. If you use GC_local_malloc you should arrange
267 * to call this somehow (e.g. from a constructor) before doing any allocation.
268 * For win32 threads, it needs to be called explicitly.
270 GC_API void GC_init GC_PROTO((void));
273 * general purpose allocation routines, with roughly malloc calling conv.
274 * The atomic versions promise that no relevant pointers are contained
275 * in the object. The nonatomic versions guarantee that the new object
276 * is cleared. GC_malloc_stubborn promises that no changes to the object
277 * will occur after GC_end_stubborn_change has been called on the
278 * result of GC_malloc_stubborn. GC_malloc_uncollectable allocates an object
279 * that is scanned for pointers to collectable objects, but is not itself
280 * collectable. The object is scanned even if it does not appear to
281 * be reachable. GC_malloc_uncollectable and GC_free called on the resulting
282 * object implicitly update GC_non_gc_bytes appropriately.
284 * Note that the GC_malloc_stubborn support is stubbed out by default
285 * starting in 6.0. GC_malloc_stubborn is an alias for GC_malloc unless
286 * the collector is built with STUBBORN_ALLOC defined.
288 GC_API GC_PTR GC_malloc GC_PROTO((size_t size_in_bytes));
289 GC_API GC_PTR GC_malloc_atomic GC_PROTO((size_t size_in_bytes));
290 GC_API GC_PTR GC_malloc_uncollectable GC_PROTO((size_t size_in_bytes));
291 GC_API GC_PTR GC_malloc_stubborn GC_PROTO((size_t size_in_bytes));
293 /* The following is only defined if the library has been suitably */
294 /* compiled: */
295 GC_API GC_PTR GC_malloc_atomic_uncollectable GC_PROTO((size_t size_in_bytes));
297 /* Explicitly deallocate an object. Dangerous if used incorrectly. */
298 /* Requires a pointer to the base of an object. */
299 /* If the argument is stubborn, it should not be changeable when freed. */
300 /* An object should not be enable for finalization when it is */
301 /* explicitly deallocated. */
302 /* GC_free(0) is a no-op, as required by ANSI C for free. */
303 GC_API void GC_free GC_PROTO((GC_PTR object_addr));
306 * Stubborn objects may be changed only if the collector is explicitly informed.
307 * The collector is implicitly informed of coming change when such
308 * an object is first allocated. The following routines inform the
309 * collector that an object will no longer be changed, or that it will
310 * once again be changed. Only nonNIL pointer stores into the object
311 * are considered to be changes. The argument to GC_end_stubborn_change
312 * must be exacly the value returned by GC_malloc_stubborn or passed to
313 * GC_change_stubborn. (In the second case it may be an interior pointer
314 * within 512 bytes of the beginning of the objects.)
315 * There is a performance penalty for allowing more than
316 * one stubborn object to be changed at once, but it is acceptable to
317 * do so. The same applies to dropping stubborn objects that are still
318 * changeable.
320 GC_API void GC_change_stubborn GC_PROTO((GC_PTR));
321 GC_API void GC_end_stubborn_change GC_PROTO((GC_PTR));
323 /* Return a pointer to the base (lowest address) of an object given */
324 /* a pointer to a location within the object. */
325 /* I.e. map an interior pointer to the corresponding bas pointer. */
326 /* Note that with debugging allocation, this returns a pointer to the */
327 /* actual base of the object, i.e. the debug information, not to */
328 /* the base of the user object. */
329 /* Return 0 if displaced_pointer doesn't point to within a valid */
330 /* object. */
331 /* Note that a deallocated object in the garbage collected heap */
332 /* may be considered valid, even if it has been deallocated with */
333 /* GC_free. */
334 GC_API GC_PTR GC_base GC_PROTO((GC_PTR displaced_pointer));
336 /* Given a pointer to the base of an object, return its size in bytes. */
337 /* The returned size may be slightly larger than what was originally */
338 /* requested. */
339 GC_API size_t GC_size GC_PROTO((GC_PTR object_addr));
341 /* For compatibility with C library. This is occasionally faster than */
342 /* a malloc followed by a bcopy. But if you rely on that, either here */
343 /* or with the standard C library, your code is broken. In my */
344 /* opinion, it shouldn't have been invented, but now we're stuck. -HB */
345 /* The resulting object has the same kind as the original. */
346 /* If the argument is stubborn, the result will have changes enabled. */
347 /* It is an error to have changes enabled for the original object. */
348 /* Follows ANSI comventions for NULL old_object. */
349 GC_API GC_PTR GC_realloc
350 GC_PROTO((GC_PTR old_object, size_t new_size_in_bytes));
352 /* Explicitly increase the heap size. */
353 /* Returns 0 on failure, 1 on success. */
354 GC_API int GC_expand_hp GC_PROTO((size_t number_of_bytes));
356 /* Limit the heap size to n bytes. Useful when you're debugging, */
357 /* especially on systems that don't handle running out of memory well. */
358 /* n == 0 ==> unbounded. This is the default. */
359 GC_API void GC_set_max_heap_size GC_PROTO((GC_word n));
361 /* Inform the collector that a certain section of statically allocated */
362 /* memory contains no pointers to garbage collected memory. Thus it */
363 /* need not be scanned. This is sometimes important if the application */
364 /* maps large read/write files into the address space, which could be */
365 /* mistaken for dynamic library data segments on some systems. */
366 GC_API void GC_exclude_static_roots GC_PROTO((GC_PTR start, GC_PTR finish));
368 /* Clear the set of root segments. Wizards only. */
369 GC_API void GC_clear_roots GC_PROTO((void));
371 /* Add a root segment. Wizards only. */
372 GC_API void GC_add_roots GC_PROTO((char * low_address,
373 char * high_address_plus_1));
375 /* Remove a root segment. Wizards only. */
376 GC_API void GC_remove_roots GC_PROTO((char * low_address,
377 char * high_address_plus_1));
379 /* Add a displacement to the set of those considered valid by the */
380 /* collector. GC_register_displacement(n) means that if p was returned */
381 /* by GC_malloc, then (char *)p + n will be considered to be a valid */
382 /* pointer to p. N must be small and less than the size of p. */
383 /* (All pointers to the interior of objects from the stack are */
384 /* considered valid in any case. This applies to heap objects and */
385 /* static data.) */
386 /* Preferably, this should be called before any other GC procedures. */
387 /* Calling it later adds to the probability of excess memory */
388 /* retention. */
389 /* This is a no-op if the collector has recognition of */
390 /* arbitrary interior pointers enabled, which is now the default. */
391 GC_API void GC_register_displacement GC_PROTO((GC_word n));
393 /* The following version should be used if any debugging allocation is */
394 /* being done. */
395 GC_API void GC_debug_register_displacement GC_PROTO((GC_word n));
397 /* Explicitly trigger a full, world-stop collection. */
398 GC_API void GC_gcollect GC_PROTO((void));
400 /* Trigger a full world-stopped collection. Abort the collection if */
401 /* and when stop_func returns a nonzero value. Stop_func will be */
402 /* called frequently, and should be reasonably fast. This works even */
403 /* if virtual dirty bits, and hence incremental collection is not */
404 /* available for this architecture. Collections can be aborted faster */
405 /* than normal pause times for incremental collection. However, */
406 /* aborted collections do no useful work; the next collection needs */
407 /* to start from the beginning. */
408 /* Return 0 if the collection was aborted, 1 if it succeeded. */
409 typedef int (* GC_stop_func) GC_PROTO((void));
410 GC_API int GC_try_to_collect GC_PROTO((GC_stop_func stop_func));
412 /* Return the number of bytes in the heap. Excludes collector private */
413 /* data structures. Includes empty blocks and fragmentation loss. */
414 /* Includes some pages that were allocated but never written. */
415 GC_API size_t GC_get_heap_size GC_PROTO((void));
417 /* Return a lower bound on the number of free bytes in the heap. */
418 GC_API size_t GC_get_free_bytes GC_PROTO((void));
420 /* Return the number of bytes allocated since the last collection. */
421 GC_API size_t GC_get_bytes_since_gc GC_PROTO((void));
423 /* Return the total number of bytes allocated in this process. */
424 /* Never decreases, except due to wrapping. */
425 GC_API size_t GC_get_total_bytes GC_PROTO((void));
427 /* Disable garbage collection. Even GC_gcollect calls will be */
428 /* ineffective. */
429 GC_API void GC_disable GC_PROTO((void));
431 /* Reenable garbage collection. GC_disable() and GC_enable() calls */
432 /* nest. Garbage collection is enabled if the number of calls to both */
433 /* both functions is equal. */
434 GC_API void GC_enable GC_PROTO((void));
436 /* Enable incremental/generational collection. */
437 /* Not advisable unless dirty bits are */
438 /* available or most heap objects are */
439 /* pointerfree(atomic) or immutable. */
440 /* Don't use in leak finding mode. */
441 /* Ignored if GC_dont_gc is true. */
442 /* Only the generational piece of this is */
443 /* functional if GC_parallel is TRUE */
444 /* or if GC_time_limit is GC_TIME_UNLIMITED. */
445 /* Causes GC_local_gcj_malloc() to revert to */
446 /* locked allocation. Must be called */
447 /* before any GC_local_gcj_malloc() calls. */
448 GC_API void GC_enable_incremental GC_PROTO((void));
450 /* Does incremental mode write-protect pages? Returns zero or */
451 /* more of the following, or'ed together: */
452 #define GC_PROTECTS_POINTER_HEAP 1 /* May protect non-atomic objs. */
453 #define GC_PROTECTS_PTRFREE_HEAP 2
454 #define GC_PROTECTS_STATIC_DATA 4 /* Curently never. */
455 #define GC_PROTECTS_STACK 8 /* Probably impractical. */
457 #define GC_PROTECTS_NONE 0
458 GC_API int GC_incremental_protection_needs GC_PROTO((void));
460 /* Perform some garbage collection work, if appropriate. */
461 /* Return 0 if there is no more work to be done. */
462 /* Typically performs an amount of work corresponding roughly */
463 /* to marking from one page. May do more work if further */
464 /* progress requires it, e.g. if incremental collection is */
465 /* disabled. It is reasonable to call this in a wait loop */
466 /* until it returns 0. */
467 GC_API int GC_collect_a_little GC_PROTO((void));
469 /* Allocate an object of size lb bytes. The client guarantees that */
470 /* as long as the object is live, it will be referenced by a pointer */
471 /* that points to somewhere within the first 256 bytes of the object. */
472 /* (This should normally be declared volatile to prevent the compiler */
473 /* from invalidating this assertion.) This routine is only useful */
474 /* if a large array is being allocated. It reduces the chance of */
475 /* accidentally retaining such an array as a result of scanning an */
476 /* integer that happens to be an address inside the array. (Actually, */
477 /* it reduces the chance of the allocator not finding space for such */
478 /* an array, since it will try hard to avoid introducing such a false */
479 /* reference.) On a SunOS 4.X or MS Windows system this is recommended */
480 /* for arrays likely to be larger than 100K or so. For other systems, */
481 /* or if the collector is not configured to recognize all interior */
482 /* pointers, the threshold is normally much higher. */
483 GC_API GC_PTR GC_malloc_ignore_off_page GC_PROTO((size_t lb));
484 GC_API GC_PTR GC_malloc_atomic_ignore_off_page GC_PROTO((size_t lb));
486 #if defined(__sgi) && !defined(__GNUC__) && _COMPILER_VERSION >= 720
487 # define GC_ADD_CALLER
488 # define GC_RETURN_ADDR (GC_word)__return_address
489 #endif
491 #ifdef __linux__
492 # include <features.h>
493 # if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 || __GLIBC__ > 2) \
494 && !defined(__ia64__)
495 # ifndef GC_HAVE_BUILTIN_BACKTRACE
496 # define GC_HAVE_BUILTIN_BACKTRACE
497 # endif
498 # endif
499 # if defined(__i386__) || defined(__x86_64__)
500 # define GC_CAN_SAVE_CALL_STACKS
501 # endif
502 #endif
504 #if defined(GC_HAVE_BUILTIN_BACKTRACE) && !defined(GC_CAN_SAVE_CALL_STACKS)
505 # define GC_CAN_SAVE_CALL_STACKS
506 #endif
508 #if defined(__sparc__)
509 # define GC_CAN_SAVE_CALL_STACKS
510 #endif
512 /* If we're on an a platform on which we can't save call stacks, but */
513 /* gcc is normally used, we go ahead and define GC_ADD_CALLER. */
514 /* We make this decision independent of whether gcc is actually being */
515 /* used, in order to keep the interface consistent, and allow mixing */
516 /* of compilers. */
517 /* This may also be desirable if it is possible but expensive to */
518 /* retrieve the call chain. */
519 #if (defined(__linux__) || defined(__NetBSD__) || defined(__OpenBSD__) \
520 || defined(__FreeBSD__)) & !defined(GC_CAN_SAVE_CALL_STACKS)
521 # define GC_ADD_CALLER
522 # if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
523 /* gcc knows how to retrieve return address, but we don't know */
524 /* how to generate call stacks. */
525 # define GC_RETURN_ADDR (GC_word)__builtin_return_address(0)
526 # else
527 /* Just pass 0 for gcc compatibility. */
528 # define GC_RETURN_ADDR 0
529 # endif
530 #endif
532 #ifdef GC_ADD_CALLER
533 # define GC_EXTRAS GC_RETURN_ADDR, __FILE__, __LINE__
534 # define GC_EXTRA_PARAMS GC_word ra, GC_CONST char * s, int i
535 #else
536 # define GC_EXTRAS __FILE__, __LINE__
537 # define GC_EXTRA_PARAMS GC_CONST char * s, int i
538 #endif
540 /* Debugging (annotated) allocation. GC_gcollect will check */
541 /* objects allocated in this way for overwrites, etc. */
542 GC_API GC_PTR GC_debug_malloc
543 GC_PROTO((size_t size_in_bytes, GC_EXTRA_PARAMS));
544 GC_API GC_PTR GC_debug_malloc_atomic
545 GC_PROTO((size_t size_in_bytes, GC_EXTRA_PARAMS));
546 GC_API GC_PTR GC_debug_malloc_uncollectable
547 GC_PROTO((size_t size_in_bytes, GC_EXTRA_PARAMS));
548 GC_API GC_PTR GC_debug_malloc_stubborn
549 GC_PROTO((size_t size_in_bytes, GC_EXTRA_PARAMS));
550 GC_API GC_PTR GC_debug_malloc_ignore_off_page
551 GC_PROTO((size_t size_in_bytes, GC_EXTRA_PARAMS));
552 GC_API GC_PTR GC_debug_malloc_atomic_ignore_off_page
553 GC_PROTO((size_t size_in_bytes, GC_EXTRA_PARAMS));
554 GC_API void GC_debug_free GC_PROTO((GC_PTR object_addr));
555 GC_API GC_PTR GC_debug_realloc
556 GC_PROTO((GC_PTR old_object, size_t new_size_in_bytes,
557 GC_EXTRA_PARAMS));
558 GC_API void GC_debug_change_stubborn GC_PROTO((GC_PTR));
559 GC_API void GC_debug_end_stubborn_change GC_PROTO((GC_PTR));
561 /* Routines that allocate objects with debug information (like the */
562 /* above), but just fill in dummy file and line number information. */
563 /* Thus they can serve as drop-in malloc/realloc replacements. This */
564 /* can be useful for two reasons: */
565 /* 1) It allows the collector to be built with DBG_HDRS_ALL defined */
566 /* even if some allocation calls come from 3rd party libraries */
567 /* that can't be recompiled. */
568 /* 2) On some platforms, the file and line information is redundant, */
569 /* since it can be reconstructed from a stack trace. On such */
570 /* platforms it may be more convenient not to recompile, e.g. for */
571 /* leak detection. This can be accomplished by instructing the */
572 /* linker to replace malloc/realloc with these. */
573 GC_API GC_PTR GC_debug_malloc_replacement GC_PROTO((size_t size_in_bytes));
574 GC_API GC_PTR GC_debug_realloc_replacement
575 GC_PROTO((GC_PTR object_addr, size_t size_in_bytes));
577 # ifdef GC_DEBUG
578 # define GC_MALLOC(sz) GC_debug_malloc(sz, GC_EXTRAS)
579 # define GC_MALLOC_ATOMIC(sz) GC_debug_malloc_atomic(sz, GC_EXTRAS)
580 # define GC_MALLOC_UNCOLLECTABLE(sz) \
581 GC_debug_malloc_uncollectable(sz, GC_EXTRAS)
582 # define GC_MALLOC_IGNORE_OFF_PAGE(sz) \
583 GC_debug_malloc_ignore_off_page(sz, GC_EXTRAS)
584 # define GC_MALLOC_ATOMIC_IGNORE_OFF_PAGE(sz) \
585 GC_debug_malloc_atomic_ignore_off_page(sz, GC_EXTRAS)
586 # define GC_REALLOC(old, sz) GC_debug_realloc(old, sz, GC_EXTRAS)
587 # define GC_FREE(p) GC_debug_free(p)
588 # define GC_REGISTER_FINALIZER(p, f, d, of, od) \
589 GC_debug_register_finalizer(p, f, d, of, od)
590 # define GC_REGISTER_FINALIZER_IGNORE_SELF(p, f, d, of, od) \
591 GC_debug_register_finalizer_ignore_self(p, f, d, of, od)
592 # define GC_REGISTER_FINALIZER_NO_ORDER(p, f, d, of, od) \
593 GC_debug_register_finalizer_no_order(p, f, d, of, od)
594 # define GC_MALLOC_STUBBORN(sz) GC_debug_malloc_stubborn(sz, GC_EXTRAS);
595 # define GC_CHANGE_STUBBORN(p) GC_debug_change_stubborn(p)
596 # define GC_END_STUBBORN_CHANGE(p) GC_debug_end_stubborn_change(p)
597 # define GC_GENERAL_REGISTER_DISAPPEARING_LINK(link, obj) \
598 GC_general_register_disappearing_link(link, GC_base(obj))
599 # define GC_REGISTER_DISPLACEMENT(n) GC_debug_register_displacement(n)
600 # else
601 # define GC_MALLOC(sz) GC_malloc(sz)
602 # define GC_MALLOC_ATOMIC(sz) GC_malloc_atomic(sz)
603 # define GC_MALLOC_UNCOLLECTABLE(sz) GC_malloc_uncollectable(sz)
604 # define GC_MALLOC_IGNORE_OFF_PAGE(sz) \
605 GC_malloc_ignore_off_page(sz)
606 # define GC_MALLOC_ATOMIC_IGNORE_OFF_PAGE(sz) \
607 GC_malloc_atomic_ignore_off_page(sz)
608 # define GC_REALLOC(old, sz) GC_realloc(old, sz)
609 # define GC_FREE(p) GC_free(p)
610 # define GC_REGISTER_FINALIZER(p, f, d, of, od) \
611 GC_register_finalizer(p, f, d, of, od)
612 # define GC_REGISTER_FINALIZER_IGNORE_SELF(p, f, d, of, od) \
613 GC_register_finalizer_ignore_self(p, f, d, of, od)
614 # define GC_REGISTER_FINALIZER_NO_ORDER(p, f, d, of, od) \
615 GC_register_finalizer_no_order(p, f, d, of, od)
616 # define GC_MALLOC_STUBBORN(sz) GC_malloc_stubborn(sz)
617 # define GC_CHANGE_STUBBORN(p) GC_change_stubborn(p)
618 # define GC_END_STUBBORN_CHANGE(p) GC_end_stubborn_change(p)
619 # define GC_GENERAL_REGISTER_DISAPPEARING_LINK(link, obj) \
620 GC_general_register_disappearing_link(link, obj)
621 # define GC_REGISTER_DISPLACEMENT(n) GC_register_displacement(n)
622 # endif
623 /* The following are included because they are often convenient, and */
624 /* reduce the chance for a misspecifed size argument. But calls may */
625 /* expand to something syntactically incorrect if t is a complicated */
626 /* type expression. */
627 # define GC_NEW(t) (t *)GC_MALLOC(sizeof (t))
628 # define GC_NEW_ATOMIC(t) (t *)GC_MALLOC_ATOMIC(sizeof (t))
629 # define GC_NEW_STUBBORN(t) (t *)GC_MALLOC_STUBBORN(sizeof (t))
630 # define GC_NEW_UNCOLLECTABLE(t) (t *)GC_MALLOC_UNCOLLECTABLE(sizeof (t))
632 /* Finalization. Some of these primitives are grossly unsafe. */
633 /* The idea is to make them both cheap, and sufficient to build */
634 /* a safer layer, closer to Modula-3, Java, or PCedar finalization. */
635 /* The interface represents my conclusions from a long discussion */
636 /* with Alan Demers, Dan Greene, Carl Hauser, Barry Hayes, */
637 /* Christian Jacobi, and Russ Atkinson. It's not perfect, and */
638 /* probably nobody else agrees with it. Hans-J. Boehm 3/13/92 */
639 typedef void (*GC_finalization_proc)
640 GC_PROTO((GC_PTR obj, GC_PTR client_data));
642 GC_API void GC_register_finalizer
643 GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd,
644 GC_finalization_proc *ofn, GC_PTR *ocd));
645 GC_API void GC_debug_register_finalizer
646 GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd,
647 GC_finalization_proc *ofn, GC_PTR *ocd));
648 /* When obj is no longer accessible, invoke */
649 /* (*fn)(obj, cd). If a and b are inaccessible, and */
650 /* a points to b (after disappearing links have been */
651 /* made to disappear), then only a will be */
652 /* finalized. (If this does not create any new */
653 /* pointers to b, then b will be finalized after the */
654 /* next collection.) Any finalizable object that */
655 /* is reachable from itself by following one or more */
656 /* pointers will not be finalized (or collected). */
657 /* Thus cycles involving finalizable objects should */
658 /* be avoided, or broken by disappearing links. */
659 /* All but the last finalizer registered for an object */
660 /* is ignored. */
661 /* Finalization may be removed by passing 0 as fn. */
662 /* Finalizers are implicitly unregistered just before */
663 /* they are invoked. */
664 /* The old finalizer and client data are stored in */
665 /* *ofn and *ocd. */
666 /* Fn is never invoked on an accessible object, */
667 /* provided hidden pointers are converted to real */
668 /* pointers only if the allocation lock is held, and */
669 /* such conversions are not performed by finalization */
670 /* routines. */
671 /* If GC_register_finalizer is aborted as a result of */
672 /* a signal, the object may be left with no */
673 /* finalization, even if neither the old nor new */
674 /* finalizer were NULL. */
675 /* Obj should be the nonNULL starting address of an */
676 /* object allocated by GC_malloc or friends. */
677 /* Note that any garbage collectable object referenced */
678 /* by cd will be considered accessible until the */
679 /* finalizer is invoked. */
681 /* Another versions of the above follow. It ignores */
682 /* self-cycles, i.e. pointers from a finalizable object to */
683 /* itself. There is a stylistic argument that this is wrong, */
684 /* but it's unavoidable for C++, since the compiler may */
685 /* silently introduce these. It's also benign in that specific */
686 /* case. And it helps if finalizable objects are split to */
687 /* avoid cycles. */
688 /* Note that cd will still be viewed as accessible, even if it */
689 /* refers to the object itself. */
690 GC_API void GC_register_finalizer_ignore_self
691 GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd,
692 GC_finalization_proc *ofn, GC_PTR *ocd));
693 GC_API void GC_debug_register_finalizer_ignore_self
694 GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd,
695 GC_finalization_proc *ofn, GC_PTR *ocd));
697 /* Another version of the above. It ignores all cycles. */
698 /* It should probably only be used by Java implementations. */
699 /* Note that cd will still be viewed as accessible, even if it */
700 /* refers to the object itself. */
701 GC_API void GC_register_finalizer_no_order
702 GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd,
703 GC_finalization_proc *ofn, GC_PTR *ocd));
704 GC_API void GC_debug_register_finalizer_no_order
705 GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd,
706 GC_finalization_proc *ofn, GC_PTR *ocd));
709 /* The following routine may be used to break cycles between */
710 /* finalizable objects, thus causing cyclic finalizable */
711 /* objects to be finalized in the correct order. Standard */
712 /* use involves calling GC_register_disappearing_link(&p), */
713 /* where p is a pointer that is not followed by finalization */
714 /* code, and should not be considered in determining */
715 /* finalization order. */
716 GC_API int GC_register_disappearing_link GC_PROTO((GC_PTR * /* link */));
717 /* Link should point to a field of a heap allocated */
718 /* object obj. *link will be cleared when obj is */
719 /* found to be inaccessible. This happens BEFORE any */
720 /* finalization code is invoked, and BEFORE any */
721 /* decisions about finalization order are made. */
722 /* This is useful in telling the finalizer that */
723 /* some pointers are not essential for proper */
724 /* finalization. This may avoid finalization cycles. */
725 /* Note that obj may be resurrected by another */
726 /* finalizer, and thus the clearing of *link may */
727 /* be visible to non-finalization code. */
728 /* There's an argument that an arbitrary action should */
729 /* be allowed here, instead of just clearing a pointer. */
730 /* But this causes problems if that action alters, or */
731 /* examines connectivity. */
732 /* Returns 1 if link was already registered, 0 */
733 /* otherwise. */
734 /* Only exists for backward compatibility. See below: */
736 GC_API int GC_general_register_disappearing_link
737 GC_PROTO((GC_PTR * /* link */, GC_PTR obj));
738 /* A slight generalization of the above. *link is */
739 /* cleared when obj first becomes inaccessible. This */
740 /* can be used to implement weak pointers easily and */
741 /* safely. Typically link will point to a location */
742 /* holding a disguised pointer to obj. (A pointer */
743 /* inside an "atomic" object is effectively */
744 /* disguised.) In this way soft */
745 /* pointers are broken before any object */
746 /* reachable from them are finalized. Each link */
747 /* May be registered only once, i.e. with one obj */
748 /* value. This was added after a long email discussion */
749 /* with John Ellis. */
750 /* Obj must be a pointer to the first word of an object */
751 /* we allocated. It is unsafe to explicitly deallocate */
752 /* the object containing link. Explicitly deallocating */
753 /* obj may or may not cause link to eventually be */
754 /* cleared. */
755 GC_API int GC_unregister_disappearing_link GC_PROTO((GC_PTR * /* link */));
756 /* Returns 0 if link was not actually registered. */
757 /* Undoes a registration by either of the above two */
758 /* routines. */
760 /* Returns !=0 if GC_invoke_finalizers has something to do. */
761 GC_API int GC_should_invoke_finalizers GC_PROTO((void));
763 GC_API int GC_invoke_finalizers GC_PROTO((void));
764 /* Run finalizers for all objects that are ready to */
765 /* be finalized. Return the number of finalizers */
766 /* that were run. Normally this is also called */
767 /* implicitly during some allocations. If */
768 /* GC-finalize_on_demand is nonzero, it must be called */
769 /* explicitly. */
771 /* GC_set_warn_proc can be used to redirect or filter warning messages. */
772 /* p may not be a NULL pointer. */
773 typedef void (*GC_warn_proc) GC_PROTO((char *msg, GC_word arg));
774 GC_API GC_warn_proc GC_set_warn_proc GC_PROTO((GC_warn_proc p));
775 /* Returns old warning procedure. */
777 GC_API GC_word GC_set_free_space_divisor GC_PROTO((GC_word value));
778 /* Set free_space_divisor. See above for definition. */
779 /* Returns old value. */
781 /* The following is intended to be used by a higher level */
782 /* (e.g. Java-like) finalization facility. It is expected */
783 /* that finalization code will arrange for hidden pointers to */
784 /* disappear. Otherwise objects can be accessed after they */
785 /* have been collected. */
786 /* Note that putting pointers in atomic objects or in */
787 /* nonpointer slots of "typed" objects is equivalent to */
788 /* disguising them in this way, and may have other advantages. */
789 # if defined(I_HIDE_POINTERS) || defined(GC_I_HIDE_POINTERS)
790 typedef GC_word GC_hidden_pointer;
791 # define HIDE_POINTER(p) (~(GC_hidden_pointer)(p))
792 # define REVEAL_POINTER(p) ((GC_PTR)(HIDE_POINTER(p)))
793 /* Converting a hidden pointer to a real pointer requires verifying */
794 /* that the object still exists. This involves acquiring the */
795 /* allocator lock to avoid a race with the collector. */
796 # endif /* I_HIDE_POINTERS */
798 typedef GC_PTR (*GC_fn_type) GC_PROTO((GC_PTR client_data));
799 GC_API GC_PTR GC_call_with_alloc_lock
800 GC_PROTO((GC_fn_type fn, GC_PTR client_data));
802 /* The following routines are primarily intended for use with a */
803 /* preprocessor which inserts calls to check C pointer arithmetic. */
804 /* They indicate failure by invoking the corresponding _print_proc. */
806 /* Check that p and q point to the same object. */
807 /* Fail conspicuously if they don't. */
808 /* Returns the first argument. */
809 /* Succeeds if neither p nor q points to the heap. */
810 /* May succeed if both p and q point to between heap objects. */
811 GC_API GC_PTR GC_same_obj GC_PROTO((GC_PTR p, GC_PTR q));
813 /* Checked pointer pre- and post- increment operations. Note that */
814 /* the second argument is in units of bytes, not multiples of the */
815 /* object size. This should either be invoked from a macro, or the */
816 /* call should be automatically generated. */
817 GC_API GC_PTR GC_pre_incr GC_PROTO((GC_PTR *p, size_t how_much));
818 GC_API GC_PTR GC_post_incr GC_PROTO((GC_PTR *p, size_t how_much));
820 /* Check that p is visible */
821 /* to the collector as a possibly pointer containing location. */
822 /* If it isn't fail conspicuously. */
823 /* Returns the argument in all cases. May erroneously succeed */
824 /* in hard cases. (This is intended for debugging use with */
825 /* untyped allocations. The idea is that it should be possible, though */
826 /* slow, to add such a call to all indirect pointer stores.) */
827 /* Currently useless for multithreaded worlds. */
828 GC_API GC_PTR GC_is_visible GC_PROTO((GC_PTR p));
830 /* Check that if p is a pointer to a heap page, then it points to */
831 /* a valid displacement within a heap object. */
832 /* Fail conspicuously if this property does not hold. */
833 /* Uninteresting with GC_all_interior_pointers. */
834 /* Always returns its argument. */
835 GC_API GC_PTR GC_is_valid_displacement GC_PROTO((GC_PTR p));
837 /* Returns 1 if the calling thread is registered with the GC, 0 otherwise */
838 GC_API int GC_thread_is_registered GC_PROTO((void));
840 /* Safer, but slow, pointer addition. Probably useful mainly with */
841 /* a preprocessor. Useful only for heap pointers. */
842 #ifdef GC_DEBUG
843 # define GC_PTR_ADD3(x, n, type_of_result) \
844 ((type_of_result)GC_same_obj((x)+(n), (x)))
845 # define GC_PRE_INCR3(x, n, type_of_result) \
846 ((type_of_result)GC_pre_incr(&(x), (n)*sizeof(*x))
847 # define GC_POST_INCR2(x, type_of_result) \
848 ((type_of_result)GC_post_incr(&(x), sizeof(*x))
849 # ifdef __GNUC__
850 # define GC_PTR_ADD(x, n) \
851 GC_PTR_ADD3(x, n, typeof(x))
852 # define GC_PRE_INCR(x, n) \
853 GC_PRE_INCR3(x, n, typeof(x))
854 # define GC_POST_INCR(x, n) \
855 GC_POST_INCR3(x, typeof(x))
856 # else
857 /* We can't do this right without typeof, which ANSI */
858 /* decided was not sufficiently useful. Repeatedly */
859 /* mentioning the arguments seems too dangerous to be */
860 /* useful. So does not casting the result. */
861 # define GC_PTR_ADD(x, n) ((x)+(n))
862 # endif
863 #else /* !GC_DEBUG */
864 # define GC_PTR_ADD3(x, n, type_of_result) ((x)+(n))
865 # define GC_PTR_ADD(x, n) ((x)+(n))
866 # define GC_PRE_INCR3(x, n, type_of_result) ((x) += (n))
867 # define GC_PRE_INCR(x, n) ((x) += (n))
868 # define GC_POST_INCR2(x, n, type_of_result) ((x)++)
869 # define GC_POST_INCR(x, n) ((x)++)
870 #endif
872 /* Safer assignment of a pointer to a nonstack location. */
873 #ifdef GC_DEBUG
874 # if defined(__STDC__) || defined(_AIX)
875 # define GC_PTR_STORE(p, q) \
876 (*(void **)GC_is_visible(p) = GC_is_valid_displacement(q))
877 # else
878 # define GC_PTR_STORE(p, q) \
879 (*(char **)GC_is_visible(p) = GC_is_valid_displacement(q))
880 # endif
881 #else /* !GC_DEBUG */
882 # define GC_PTR_STORE(p, q) *((p) = (q))
883 #endif
885 /* Functions called to report pointer checking errors */
886 GC_API void (*GC_same_obj_print_proc) GC_PROTO((GC_PTR p, GC_PTR q));
888 GC_API void (*GC_is_valid_displacement_print_proc)
889 GC_PROTO((GC_PTR p));
891 GC_API void (*GC_is_visible_print_proc)
892 GC_PROTO((GC_PTR p));
894 /* For pthread support, we generally need to intercept a number of */
895 /* thread library calls. We do that here by macro defining them. */
897 #if !defined(GC_USE_LD_WRAP) && \
898 (defined(GC_PTHREADS) || defined(GC_SOLARIS_THREADS) || defined(GC_DARWIN_THREADS) || defined(GC_MACOSX_THREADS))
899 #if defined(_IN_LIBGC) || defined(USE_INCLUDED_LIBGC)
900 # include "gc_pthread_redirects.h"
901 #else
902 # include <gc/gc_pthread_redirects.h>
903 #endif
904 #endif
906 # if defined(PCR) || defined(GC_SOLARIS_THREADS) || \
907 defined(GC_PTHREADS) || defined(GC_WIN32_THREADS)
908 /* Any flavor of threads except SRC_M3. */
909 /* This returns a list of objects, linked through their first */
910 /* word. Its use can greatly reduce lock contention problems, since */
911 /* the allocation lock can be acquired and released many fewer times. */
912 /* lb must be large enough to hold the pointer field. */
913 /* It is used internally by gc_local_alloc.h, which provides a simpler */
914 /* programming interface on Linux. */
915 GC_PTR GC_malloc_many(size_t lb);
916 #define GC_NEXT(p) (*(GC_PTR *)(p)) /* Retrieve the next element */
917 /* in returned list. */
918 extern void GC_thr_init(void); /* Needed for Solaris/X86 */
920 #endif /* THREADS && !SRC_M3 */
922 #if defined(GC_WIN32_THREADS) && !defined(__CYGWIN32__) && !defined(__CYGWIN__)
923 # include <windows.h>
925 BOOL WINAPI GC_DllMain(HINSTANCE inst, ULONG reason, LPVOID reserved);
928 * All threads must be created using GC_CreateThread, so that they will be
929 * recorded in the thread table. For backwards compatibility, this is not
930 * technically true if the GC is built as a dynamic library, since it can
931 * and does then use DllMain to keep track of thread creations. But new code
932 * should be built to call GC_CreateThread.
934 GC_API HANDLE WINAPI GC_CreateThread(
935 LPSECURITY_ATTRIBUTES lpThreadAttributes,
936 DWORD dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress,
937 LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId );
939 # if defined(_WIN32_WCE)
941 * win32_threads.c implements the real WinMain, which will start a new thread
942 * to call GC_WinMain after initializing the garbage collector.
944 int WINAPI GC_WinMain(
945 HINSTANCE hInstance,
946 HINSTANCE hPrevInstance,
947 LPWSTR lpCmdLine,
948 int nCmdShow );
950 # ifndef GC_BUILD
951 # define WinMain GC_WinMain
952 # define CreateThread GC_CreateThread
953 # endif
954 # endif /* defined(_WIN32_WCE) */
956 #endif /* defined(GC_WIN32_THREADS) && !cygwin */
959 * Fully portable code should call GC_INIT() from the main program
960 * before making any other GC_ calls. On most platforms this is a
961 * no-op and the collector self-initializes. But a number of platforms
962 * make that too hard.
964 #if (defined(sparc) || defined(__sparc)) && defined(sun)
966 * If you are planning on putting
967 * the collector in a SunOS 5 dynamic library, you need to call GC_INIT()
968 * from the statically loaded program section.
969 * This circumvents a Solaris 2.X (X<=4) linker bug.
971 # define GC_INIT() { extern end, etext; \
972 GC_noop(&end, &etext); }
973 #else
974 # if defined(__CYGWIN32__) || defined (_AIX)
976 * Similarly gnu-win32 DLLs need explicit initialization from
977 * the main program, as does AIX.
979 # ifdef __CYGWIN32__
980 extern int _data_start__[];
981 extern int _data_end__[];
982 extern int _bss_start__[];
983 extern int _bss_end__[];
984 # define GC_MAX(x,y) ((x) > (y) ? (x) : (y))
985 # define GC_MIN(x,y) ((x) < (y) ? (x) : (y))
986 # define GC_DATASTART ((GC_PTR) GC_MIN(_data_start__, _bss_start__))
987 # define GC_DATAEND ((GC_PTR) GC_MAX(_data_end__, _bss_end__))
988 # ifdef GC_DLL
989 # define GC_INIT() { GC_add_roots(GC_DATASTART, GC_DATAEND); }
990 # else
991 # define GC_INIT()
992 # endif
993 # endif
994 # if defined(_AIX)
995 extern int _data[], _end[];
996 # define GC_DATASTART ((GC_PTR)((ulong)_data))
997 # define GC_DATAEND ((GC_PTR)((ulong)_end))
998 # define GC_INIT() { GC_add_roots(GC_DATASTART, GC_DATAEND); }
999 # endif
1000 # else
1001 # if defined(__APPLE__) && defined(__MACH__) || defined(GC_WIN32_THREADS)
1002 # define GC_INIT() { GC_init(); }
1003 # else
1004 # define GC_INIT()
1005 # endif /* !__MACH && !GC_WIN32_THREADS */
1006 # endif /* !AIX && !cygwin */
1007 #endif /* !sparc */
1009 #if !defined(_WIN32_WCE) \
1010 && ((defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \
1011 || defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__CYGWIN__))
1012 /* win32S may not free all resources on process exit. */
1013 /* This explicitly deallocates the heap. */
1014 GC_API void GC_win32_free_heap ();
1015 #endif
1017 #if ( defined(_AMIGA) && !defined(GC_AMIGA_MAKINGLIB) )
1018 /* Allocation really goes through GC_amiga_allocwrapper_do */
1019 # include "gc_amiga_redirects.h"
1020 #endif
1022 #if defined(GC_REDIRECT_TO_LOCAL) && !defined(GC_LOCAL_ALLOC_H)
1023 # include "gc_local_alloc.h"
1024 #endif
1026 #ifdef __cplusplus
1027 } /* end of extern "C" */
1028 #endif
1030 #endif /* _GC_H */