version 1.4, 2002/07/24 07:46:31 |
version 1.5, 2002/07/24 08:00:17 |
|
|
|
|
# define _GC_H |
# define _GC_H |
|
|
#if defined(_SOLARIS_PTHREADS) && !defined(SOLARIS_THREADS) |
|
# define SOLARIS_THREADS |
|
#endif |
|
|
|
/* |
/* |
* Some tests for old macros. These violate our namespace rules and will |
* Some tests for old macros. These violate our namespace rules and will |
* disappear shortly. |
* disappear shortly. Use the GC_ names. |
*/ |
*/ |
#if defined(SOLARIS_THREADS) || defined(_SOLARIS_THREADS) |
#if defined(SOLARIS_THREADS) || defined(_SOLARIS_THREADS) |
# define GC_SOLARIS_THREADS |
# define GC_SOLARIS_THREADS |
|
|
#if defined(IRIX_THREADS) |
#if defined(IRIX_THREADS) |
# define GC_IRIX_THREADS |
# define GC_IRIX_THREADS |
#endif |
#endif |
|
#if defined(DGUX_THREADS) |
|
# if !defined(GC_DGUX386_THREADS) |
|
# define GC_DGUX386_THREADS |
|
# endif |
|
#endif |
#if defined(HPUX_THREADS) |
#if defined(HPUX_THREADS) |
# define GC_HPUX_THREADS |
# define GC_HPUX_THREADS |
#endif |
#endif |
|
|
/* depend on this were previously included. */ |
/* depend on this were previously included. */ |
#endif |
#endif |
|
|
|
#if defined(GC_DGUX386_THREADS) && !defined(_POSIX4A_DRAFT10_SOURCE) |
|
# define _POSIX4A_DRAFT10_SOURCE 1 |
|
#endif |
|
|
|
#if defined(GC_SOLARIS_PTHREADS) && !defined(GC_SOLARIS_THREADS) |
|
# define GC_SOLARIS_THREADS |
|
#endif |
|
|
|
# if defined(GC_SOLARIS_PTHREADS) || defined(GC_FREEBSD_THREADS) || \ |
|
defined(GC_IRIX_THREADS) || defined(GC_LINUX_THREADS) || \ |
|
defined(GC_HPUX_THREADS) || defined(GC_OSF1_THREADS) || \ |
|
defined(GC_DGUX386_THREADS) || \ |
|
(defined(GC_WIN32_THREADS) && defined(__CYGWIN32__)) |
|
# define GC_PTHREADS |
|
# endif |
|
|
# define __GC |
# define __GC |
# include <stddef.h> |
# include <stddef.h> |
# ifdef _WIN32_WCE |
# ifdef _WIN32_WCE |
|
|
typedef long ptrdiff_t; /* ptrdiff_t is not defined */ |
typedef long ptrdiff_t; /* ptrdiff_t is not defined */ |
# endif |
# endif |
|
|
#if defined(__CYGWIN32__) && defined(GC_USE_DLL) |
#if defined(__MINGW32__) && defined(_DLL) && !defined(GC_NOT_DLL) |
#include "libgc_globals.h" |
|
#endif |
|
|
|
#if defined(__MINGW32__) && defined(WIN32_THREADS) |
|
# ifdef GC_BUILD |
# ifdef GC_BUILD |
# define GC_API __declspec(dllexport) |
# define GC_API __declspec(dllexport) |
# else |
# else |
|
|
# endif |
# endif |
#endif |
#endif |
|
|
#if defined(_MSC_VER) && (defined(_DLL) && !defined(NOT_GC_DLL) \ |
#if (defined(__DMC__) || defined(_MSC_VER)) \ |
|| defined(GC_DLL)) |
&& (defined(_DLL) && !defined(GC_NOT_DLL) \ |
|
|| defined(GC_DLL)) |
# ifdef GC_BUILD |
# ifdef GC_BUILD |
# define GC_API extern __declspec(dllexport) |
# define GC_API extern __declspec(dllexport) |
# else |
# else |
Line 151 GC_API int GC_parallel; /* GC is parallelized for perf |
|
Line 165 GC_API int GC_parallel; /* GC is parallelized for perf |
|
/* Env variable GC_NPROC is set to > 1, or */ |
/* Env variable GC_NPROC is set to > 1, or */ |
/* GC_NPROC is not set and this is an MP. */ |
/* GC_NPROC is not set and this is an MP. */ |
/* If GC_parallel is set, incremental */ |
/* If GC_parallel is set, incremental */ |
/* collection is aonly partially functional, */ |
/* collection is only partially functional, */ |
/* and may not be desirable. */ |
/* and may not be desirable. */ |
|
|
|
|
Line 293 GC_API int GC_dont_precollect; /* Don't collect as pa |
|
Line 307 GC_API int GC_dont_precollect; /* Don't collect as pa |
|
/* Interferes with blacklisting. */ |
/* Interferes with blacklisting. */ |
/* Wizards only. */ |
/* Wizards only. */ |
|
|
|
GC_API unsigned long GC_time_limit; |
|
/* If incremental collection is enabled, */ |
|
/* We try to terminate collections */ |
|
/* after this many milliseconds. Not a */ |
|
/* hard time bound. Setting this to */ |
|
/* GC_TIME_UNLIMITED will essentially */ |
|
/* disable incremental collection while */ |
|
/* leaving generational collection */ |
|
/* enabled. */ |
|
# define GC_TIME_UNLIMITED 999999 |
|
/* Setting GC_time_limit to this value */ |
|
/* will disable the "pause time exceeded"*/ |
|
/* tests. */ |
|
|
/* Public procedures */ |
/* Public procedures */ |
|
|
|
/* Initialize the collector. This is only required when using thread-local |
|
* allocation, since unlike the regular allocation routines, GC_local_malloc |
|
* is not self-initializing. If you use GC_local_malloc you should arrange |
|
* to call this somehow (e.g. from a constructor) before doing any allocation. |
|
*/ |
|
GC_API void GC_init GC_PROTO((void)); |
|
|
/* |
/* |
* general purpose allocation routines, with roughly malloc calling conv. |
* general purpose allocation routines, with roughly malloc calling conv. |
* The atomic versions promise that no relevant pointers are contained |
* The atomic versions promise that no relevant pointers are contained |
Line 347 GC_API void GC_end_stubborn_change GC_PROTO((GC_PTR)); |
|
Line 383 GC_API void GC_end_stubborn_change GC_PROTO((GC_PTR)); |
|
|
|
/* Return a pointer to the base (lowest address) of an object given */ |
/* Return a pointer to the base (lowest address) of an object given */ |
/* a pointer to a location within the object. */ |
/* a pointer to a location within the object. */ |
|
/* I.e. map an interior pointer to the corresponding bas pointer. */ |
|
/* Note that with debugging allocation, this returns a pointer to the */ |
|
/* actual base of the object, i.e. the debug information, not to */ |
|
/* the base of the user object. */ |
/* Return 0 if displaced_pointer doesn't point to within a valid */ |
/* Return 0 if displaced_pointer doesn't point to within a valid */ |
/* object. */ |
/* object. */ |
GC_API GC_PTR GC_base GC_PROTO((GC_PTR displaced_pointer)); |
GC_API GC_PTR GC_base GC_PROTO((GC_PTR displaced_pointer)); |
Line 445 GC_API size_t GC_get_total_bytes GC_PROTO((void)); |
|
Line 485 GC_API size_t GC_get_total_bytes GC_PROTO((void)); |
|
/* Don't use in leak finding mode. */ |
/* Don't use in leak finding mode. */ |
/* Ignored if GC_dont_gc is true. */ |
/* Ignored if GC_dont_gc is true. */ |
/* Only the generational piece of this is */ |
/* Only the generational piece of this is */ |
/* functional if GC_parallel is TRUE. */ |
/* functional if GC_parallel is TRUE */ |
|
/* or if GC_time_limit is GC_TIME_UNLIMITED. */ |
|
/* Causes GC_local_gcj_malloc() to revert to */ |
|
/* locked allocation. Must be called */ |
|
/* before any GC_local_gcj_malloc() calls. */ |
GC_API void GC_enable_incremental GC_PROTO((void)); |
GC_API void GC_enable_incremental GC_PROTO((void)); |
|
|
|
/* Does incremental mode write-protect pages? Returns zero or */ |
|
/* more of the following, or'ed together: */ |
|
#define GC_PROTECTS_POINTER_HEAP 1 /* May protect non-atomic objs. */ |
|
#define GC_PROTECTS_PTRFREE_HEAP 2 |
|
#define GC_PROTECTS_STATIC_DATA 4 /* Curently never. */ |
|
#define GC_PROTECTS_STACK 8 /* Probably impractical. */ |
|
|
|
#define GC_PROTECTS_NONE 0 |
|
GC_API int GC_incremental_protection_needs GC_PROTO((void)); |
|
|
/* Perform some garbage collection work, if appropriate. */ |
/* Perform some garbage collection work, if appropriate. */ |
/* Return 0 if there is no more work to be done. */ |
/* Return 0 if there is no more work to be done. */ |
/* Typically performs an amount of work corresponding roughly */ |
/* Typically performs an amount of work corresponding roughly */ |
Line 701 GC_API GC_warn_proc GC_set_warn_proc GC_PROTO((GC_warn |
|
Line 755 GC_API GC_warn_proc GC_set_warn_proc GC_PROTO((GC_warn |
|
/* Returns old warning procedure. */ |
/* Returns old warning procedure. */ |
|
|
/* The following is intended to be used by a higher level */ |
/* The following is intended to be used by a higher level */ |
/* (e.g. cedar-like) finalization facility. It is expected */ |
/* (e.g. Java-like) finalization facility. It is expected */ |
/* that finalization code will arrange for hidden pointers to */ |
/* that finalization code will arrange for hidden pointers to */ |
/* disappear. Otherwise objects can be accessed after they */ |
/* disappear. Otherwise objects can be accessed after they */ |
/* have been collected. */ |
/* have been collected. */ |
Line 814 GC_API void (*GC_is_visible_print_proc) |
|
Line 868 GC_API void (*GC_is_visible_print_proc) |
|
/* thread library calls. We do that here by macro defining them. */ |
/* thread library calls. We do that here by macro defining them. */ |
|
|
#if !defined(GC_USE_LD_WRAP) && \ |
#if !defined(GC_USE_LD_WRAP) && \ |
(defined(GC_LINUX_THREADS) || defined(GC_HPUX_THREADS) || \ |
(defined(GC_PTHREADS) || defined(GC_SOLARIS_THREADS)) |
defined(GC_IRIX_THREADS) || defined(GC_SOLARIS_PTHREADS) || \ |
|
defined(GC_SOLARIS_THREADS) || defined(GC_OSF1_THREADS)) |
|
# include "gc_pthread_redirects.h" |
# include "gc_pthread_redirects.h" |
#endif |
#endif |
|
|
# if defined(PCR) || defined(GC_SOLARIS_THREADS) || \ |
# if defined(PCR) || defined(GC_SOLARIS_THREADS) || \ |
defined(GC_SOLARIS_PTHREADS) || defined(GC_WIN32_THREADS) || \ |
defined(GC_PTHREADS) || defined(GC_WIN32_THREADS) |
defined(GC_IRIX_THREADS) || defined(GC_LINUX_THREADS) || \ |
|
defined(GC_HPUX_THREADS) |
|
/* Any flavor of threads except SRC_M3. */ |
/* Any flavor of threads except SRC_M3. */ |
/* This returns a list of objects, linked through their first */ |
/* This returns a list of objects, linked through their first */ |
/* word. Its use can greatly reduce lock contention problems, since */ |
/* word. Its use can greatly reduce lock contention problems, since */ |
Line 838 extern void GC_thr_init(); /* Needed for Solaris/X86 * |
|
Line 888 extern void GC_thr_init(); /* Needed for Solaris/X86 * |
|
|
|
#endif /* THREADS && !SRC_M3 */ |
#endif /* THREADS && !SRC_M3 */ |
|
|
#if defined(WIN32_THREADS) && defined(_WIN32_WCE) |
#if defined(GC_WIN32_THREADS) |
# include <windows.h> |
# include <windows.h> |
|
# include <winbase.h> |
|
|
/* |
/* |
|
* All threads must be created using GC_CreateThread, so that they will be |
|
* recorded in the thread table. For backwards compatibility, this is not |
|
* technically true if the GC is built as a dynamic library, since it can |
|
* and does then use DllMain to keep track of thread creations. But new code |
|
* should be built to call GC_CreateThread. |
|
*/ |
|
HANDLE WINAPI GC_CreateThread( |
|
LPSECURITY_ATTRIBUTES lpThreadAttributes, |
|
DWORD dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, |
|
LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId ); |
|
|
|
# if defined(_WIN32_WCE) |
|
/* |
* win32_threads.c implements the real WinMain, which will start a new thread |
* win32_threads.c implements the real WinMain, which will start a new thread |
* to call GC_WinMain after initializing the garbage collector. |
* to call GC_WinMain after initializing the garbage collector. |
*/ |
*/ |
Line 851 extern void GC_thr_init(); /* Needed for Solaris/X86 * |
|
Line 915 extern void GC_thr_init(); /* Needed for Solaris/X86 * |
|
LPWSTR lpCmdLine, |
LPWSTR lpCmdLine, |
int nCmdShow ); |
int nCmdShow ); |
|
|
/* |
# ifndef GC_BUILD |
* All threads must be created using GC_CreateThread, so that they will be |
# define WinMain GC_WinMain |
* recorded in the thread table. |
# define CreateThread GC_CreateThread |
*/ |
# endif |
HANDLE WINAPI GC_CreateThread( |
# endif /* defined(_WIN32_WCE) */ |
LPSECURITY_ATTRIBUTES lpThreadAttributes, |
|
DWORD dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, |
|
LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId ); |
|
|
|
# ifndef GC_BUILD |
#endif /* defined(GC_WIN32_THREADS) */ |
# define WinMain GC_WinMain |
|
# define CreateThread GC_CreateThread |
|
# endif |
|
|
|
#endif |
|
|
|
/* |
/* |
* If you are planning on putting |
* If you are planning on putting |
* the collector in a SunOS 5 dynamic library, you need to call GC_INIT() |
* the collector in a SunOS 5 dynamic library, you need to call GC_INIT() |
Line 877 extern void GC_thr_init(); /* Needed for Solaris/X86 * |
|
Line 933 extern void GC_thr_init(); /* Needed for Solaris/X86 * |
|
# define GC_INIT() { extern end, etext; \ |
# define GC_INIT() { extern end, etext; \ |
GC_noop(&end, &etext); } |
GC_noop(&end, &etext); } |
#else |
#else |
# if defined(__CYGWIN32__) && defined(GC_USE_DLL) |
# if defined(__CYGWIN32__) && defined(GC_USE_DLL) || defined (_AIX) |
/* |
/* |
* Similarly gnu-win32 DLLs need explicit initialization |
* Similarly gnu-win32 DLLs need explicit initialization from |
|
* the main program, as does AIX. |
*/ |
*/ |
# define GC_INIT() { GC_add_roots(DATASTART, DATAEND); } |
# define GC_INIT() { GC_add_roots(DATASTART, DATAEND); } |
# else |
# else |