32 |
|
|
33 |
# include "gc_config_macros.h" |
# include "gc_config_macros.h" |
34 |
|
|
35 |
# if defined(__STDC__) || defined(__cplusplus) |
# if defined(__STDC__) || defined(__cplusplus) || defined(_AIX) |
36 |
# define GC_PROTO(args) args |
# define GC_PROTO(args) args |
37 |
typedef void * GC_PTR; |
typedef void * GC_PTR; |
38 |
# define GC_CONST const |
# define GC_CONST const |
191 |
/* least N/GC_free_space_divisor bytes between */ |
/* least N/GC_free_space_divisor bytes between */ |
192 |
/* collections, where N is the heap size plus */ |
/* collections, where N is the heap size plus */ |
193 |
/* a rough estimate of the root set size. */ |
/* a rough estimate of the root set size. */ |
194 |
/* Initially, GC_free_space_divisor = 4. */ |
/* Initially, GC_free_space_divisor = 3. */ |
195 |
/* Increasing its value will use less space */ |
/* Increasing its value will use less space */ |
196 |
/* but more collection time. Decreasing it */ |
/* but more collection time. Decreasing it */ |
197 |
/* will appreciably decrease collection time */ |
/* will appreciably decrease collection time */ |
308 |
/* the base of the user object. */ |
/* the base of the user object. */ |
309 |
/* Return 0 if displaced_pointer doesn't point to within a valid */ |
/* Return 0 if displaced_pointer doesn't point to within a valid */ |
310 |
/* object. */ |
/* object. */ |
311 |
|
/* Note that a deallocated object in the garbage collected heap */ |
312 |
|
/* may be considered valid, even if it has been deallocated with */ |
313 |
|
/* GC_free. */ |
314 |
GC_API GC_PTR GC_base GC_PROTO((GC_PTR displaced_pointer)); |
GC_API GC_PTR GC_base GC_PROTO((GC_PTR displaced_pointer)); |
315 |
|
|
316 |
/* Given a pointer to the base of an object, return its size in bytes. */ |
/* Given a pointer to the base of an object, return its size in bytes. */ |
479 |
# if defined(__i386__) || defined(__x86_64__) |
# if defined(__i386__) || defined(__x86_64__) |
480 |
# define GC_CAN_SAVE_CALL_STACKS |
# define GC_CAN_SAVE_CALL_STACKS |
481 |
# endif |
# endif |
|
# if defined(__UCLIBC__) |
|
|
# undef GC_HAVE_BUILTIN_BACKTRACE |
|
|
# endif |
|
482 |
#endif |
#endif |
483 |
|
|
484 |
#if defined(GC_HAVE_BUILTIN_BACKTRACE) && !defined(GC_CAN_SAVE_CALL_STACKS) |
#if defined(GC_HAVE_BUILTIN_BACKTRACE) && !defined(GC_CAN_SAVE_CALL_STACKS) |
848 |
|
|
849 |
/* Safer assignment of a pointer to a nonstack location. */ |
/* Safer assignment of a pointer to a nonstack location. */ |
850 |
#ifdef GC_DEBUG |
#ifdef GC_DEBUG |
851 |
# ifdef __STDC__ |
# if defined(__STDC__) || defined(_AIX) |
852 |
# define GC_PTR_STORE(p, q) \ |
# define GC_PTR_STORE(p, q) \ |
853 |
(*(void **)GC_is_visible(p) = GC_is_valid_displacement(q)) |
(*(void **)GC_is_visible(p) = GC_is_valid_displacement(q)) |
854 |
# else |
# else |
896 |
#if defined(GC_WIN32_THREADS) && !defined(__CYGWIN32__) && !defined(__CYGWIN__) |
#if defined(GC_WIN32_THREADS) && !defined(__CYGWIN32__) && !defined(__CYGWIN__) |
897 |
# include <windows.h> |
# include <windows.h> |
898 |
|
|
|
#if defined(__CYGWIN32__) || defined(__CYGWIN__) |
|
|
GC_API HANDLE GC_CreateThread( |
|
|
LPSECURITY_ATTRIBUTES lpThreadAttributes, |
|
|
DWORD dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, |
|
|
LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId ); |
|
|
#else |
|
899 |
/* |
/* |
900 |
* All threads must be created using GC_CreateThread, so that they will be |
* All threads must be created using GC_CreateThread, so that they will be |
901 |
* recorded in the thread table. For backwards compatibility, this is not |
* recorded in the thread table. For backwards compatibility, this is not |
907 |
LPSECURITY_ATTRIBUTES lpThreadAttributes, |
LPSECURITY_ATTRIBUTES lpThreadAttributes, |
908 |
DWORD dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, |
DWORD dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, |
909 |
LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId ); |
LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId ); |
|
#endif |
|
910 |
|
|
911 |
# if defined(_WIN32_WCE) |
# if defined(_WIN32_WCE) |
912 |
/* |
/* |
933 |
* no-op and the collector self-initializes. But a number of platforms |
* no-op and the collector self-initializes. But a number of platforms |
934 |
* make that too hard. |
* make that too hard. |
935 |
*/ |
*/ |
936 |
#if defined(sparc) || defined(__sparc) |
#if (defined(sparc) || defined(__sparc)) && defined(sun) |
937 |
/* |
/* |
938 |
* If you are planning on putting |
* If you are planning on putting |
939 |
* 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() |
943 |
# define GC_INIT() { extern end, etext; \ |
# define GC_INIT() { extern end, etext; \ |
944 |
GC_noop(&end, &etext); } |
GC_noop(&end, &etext); } |
945 |
#else |
#else |
946 |
# if defined(__CYGWIN32__) && defined(GC_DLL) || defined (_AIX) |
# if defined(__CYGWIN32__) || defined (_AIX) |
947 |
/* |
/* |
948 |
* Similarly gnu-win32 DLLs need explicit initialization from |
* Similarly gnu-win32 DLLs need explicit initialization from |
949 |
* the main program, as does AIX. |
* the main program, as does AIX. |
950 |
*/ |
*/ |
951 |
# define GC_INIT() { GC_add_roots(DATASTART, DATAEND); } |
# ifdef __CYGWIN32__ |
952 |
|
extern int _data_start__[]; |
953 |
|
extern int _data_end__[]; |
954 |
|
extern int _bss_start__[]; |
955 |
|
extern int _bss_end__[]; |
956 |
|
# define GC_MAX(x,y) ((x) > (y) ? (x) : (y)) |
957 |
|
# define GC_MIN(x,y) ((x) < (y) ? (x) : (y)) |
958 |
|
# define GC_DATASTART ((GC_PTR) GC_MIN(_data_start__, _bss_start__)) |
959 |
|
# define GC_DATAEND ((GC_PTR) GC_MAX(_data_end__, _bss_end__)) |
960 |
|
# ifdef GC_DLL |
961 |
|
# define GC_INIT() { GC_add_roots(GC_DATASTART, GC_DATAEND); } |
962 |
|
# else |
963 |
|
# define GC_INIT() |
964 |
|
# endif |
965 |
|
# endif |
966 |
|
# if defined(_AIX) |
967 |
|
extern int _data[], _end[]; |
968 |
|
# define GC_DATASTART ((GC_PTR)((ulong)_data)) |
969 |
|
# define GC_DATAEND ((GC_PTR)((ulong)_end)) |
970 |
|
# define GC_INIT() { GC_add_roots(GC_DATASTART, GC_DATAEND); } |
971 |
|
# endif |
972 |
# else |
# else |
973 |
# if defined(__APPLE__) && defined(__MACH__) || defined(GC_WIN32_THREADS) |
# if defined(__APPLE__) && defined(__MACH__) || defined(GC_WIN32_THREADS) |
974 |
# define GC_INIT() { GC_init(); } |
# define GC_INIT() { GC_init(); } |