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