34
35
# include <tchar.h>
40
# include <sys/types.h>
41
# include <sys/stat.h>
43
int GC_log; /* Forward decl, so we can set it. */
38
47
# include <floss.h>
43
# include "il/PCR_IL.h"
44
PCR_Th_ML GC_allocate_ml;
47
/* Critical section counter is defined in the M3 runtime */
48
/* That's all we use. */
50
# ifdef GC_SOLARIS_THREADS
51
mutex_t GC_allocate_ml; /* Implicitly initialized. */
53
# if defined(GC_WIN32_THREADS)
54
# if defined(GC_PTHREADS)
55
pthread_mutex_t GC_allocate_ml = PTHREAD_MUTEX_INITIALIZER;
56
# elif defined(GC_DLL)
57
__declspec(dllexport) CRITICAL_SECTION GC_allocate_ml;
59
CRITICAL_SECTION GC_allocate_ml;
62
# if defined(GC_PTHREADS) && !defined(GC_SOLARIS_THREADS)
63
# if defined(USE_SPIN_LOCK)
64
pthread_t GC_lock_holder = NO_THREAD;
66
pthread_mutex_t GC_allocate_ml = PTHREAD_MUTEX_INITIALIZER;
67
pthread_t GC_lock_holder = NO_THREAD;
68
/* Used only for assertions, and to prevent */
69
/* recursive reentry in the system call wrapper. */
72
--> declare allocator lock here
50
#if defined(THREADS) && defined(PCR)
51
# include "il/PCR_IL.h"
52
PCR_Th_ML GC_allocate_ml;
54
/* For other platforms with threads, the lock and possibly */
55
/* GC_lock_holder variables are defined in the thread support code. */
80
57
#if defined(NOSYS) || defined(ECOS)
144
123
/* Number of warnings suppressed so far. */
147
GC_PTR GC_default_oom_fn GC_PROTO((size_t bytes_requested))
126
void * GC_default_oom_fn(size_t bytes_requested)
152
GC_PTR (*GC_oom_fn) GC_PROTO((size_t bytes_requested)) = GC_default_oom_fn;
154
extern signed_word GC_mem_found;
156
void * GC_project2(arg1, arg2)
131
void * (*GC_oom_fn) (size_t bytes_requested) = GC_default_oom_fn;
133
void * GC_project2(void *arg1, void *arg2)
164
/* Set things up so that GC_size_map[i] >= words(i), */
165
/* but not too much bigger */
166
/* and so that size_map contains relatively few distinct entries */
167
/* This is stolen from Russ Atkinson's Cedar quantization */
168
/* alogrithm (but we precompute it). */
171
void GC_init_size_map()
175
/* Map size 0 to something bigger. */
176
/* This avoids problems at lower levels. */
177
/* One word objects don't have to be 2 word aligned, */
178
/* unless we're using mark bytes. */
179
for (i = 0; i < sizeof(word); i++) {
180
GC_size_map[i] = MIN_WORDS;
183
GC_size_map[sizeof(word)] = MIN_WORDS;
185
GC_size_map[sizeof(word)] = ROUNDED_UP_WORDS(sizeof(word));
187
for (i = sizeof(word) + 1; i <= 8 * sizeof(word); i++) {
188
GC_size_map[i] = ALIGNED_WORDS(i);
190
for (i = 8*sizeof(word) + 1; i <= 16 * sizeof(word); i++) {
191
GC_size_map[i] = (ROUNDED_UP_WORDS(i) + 1) & (~1);
193
# ifdef GC_GCJ_SUPPORT
194
/* Make all sizes up to 32 words predictable, so that a */
195
/* compiler can statically perform the same computation, */
196
/* or at least a computation that results in similar size */
198
for (i = 16*sizeof(word) + 1; i <= 32 * sizeof(word); i++) {
199
GC_size_map[i] = (ROUNDED_UP_WORDS(i) + 3) & (~3);
202
/* We leave the rest of the array to be filled in on demand. */
138
/* Set things up so that GC_size_map[i] >= granules(i), */
139
/* but not too much bigger */
140
/* and so that size_map contains relatively few distinct entries */
141
/* This was originally stolen from Russ Atkinson's Cedar */
142
/* quantization alogrithm (but we precompute it). */
143
void GC_init_size_map(void)
147
/* Map size 0 to something bigger. */
148
/* This avoids problems at lower levels. */
150
for (i = 1; i <= GRANULES_TO_BYTES(TINY_FREELISTS-1) - EXTRA_BYTES; i++) {
151
GC_size_map[i] = ROUNDED_UP_GRANULES(i);
152
GC_ASSERT(GC_size_map[i] < TINY_FREELISTS);
154
/* We leave the rest of the array to be filled in on demand. */
157
/* Fill in additional entries in GC_size_map, including the ith one */
158
/* We assume the ith entry is currently 0. */
159
/* Note that a filled in section of the array ending at n always */
160
/* has length at least n/4. */
161
void GC_extend_size_map(size_t i)
163
size_t orig_granule_sz = ROUNDED_UP_GRANULES(i);
164
size_t granule_sz = orig_granule_sz;
165
size_t byte_sz = GRANULES_TO_BYTES(granule_sz);
166
/* The size we try to preserve. */
167
/* Close to i, unless this would */
168
/* introduce too many distinct sizes. */
169
size_t smaller_than_i = byte_sz - (byte_sz >> 3);
170
size_t much_smaller_than_i = byte_sz - (byte_sz >> 2);
171
size_t low_limit; /* The lowest indexed entry we */
205
/* Fill in additional entries in GC_size_map, including the ith one */
206
/* We assume the ith entry is currently 0. */
207
/* Note that a filled in section of the array ending at n always */
208
/* has length at least n/4. */
209
void GC_extend_size_map(i)
175
if (GC_size_map[smaller_than_i] == 0) {
176
low_limit = much_smaller_than_i;
177
while (GC_size_map[low_limit] != 0) low_limit++;
179
low_limit = smaller_than_i + 1;
180
while (GC_size_map[low_limit] != 0) low_limit++;
181
granule_sz = ROUNDED_UP_GRANULES(low_limit);
182
granule_sz += granule_sz >> 3;
183
if (granule_sz < orig_granule_sz) granule_sz = orig_granule_sz;
185
/* For these larger sizes, we use an even number of granules. */
186
/* This makes it easier to, for example, construct a 16byte-aligned */
187
/* allocator even if GRANULE_BYTES is 8. */
190
if (granule_sz > MAXOBJGRANULES) {
191
granule_sz = MAXOBJGRANULES;
193
/* If we can fit the same number of larger objects in a block, */
212
word orig_word_sz = ROUNDED_UP_WORDS(i);
213
word word_sz = orig_word_sz;
214
register word byte_sz = WORDS_TO_BYTES(word_sz);
215
/* The size we try to preserve. */
216
/* Close to to i, unless this would */
217
/* introduce too many distinct sizes. */
218
word smaller_than_i = byte_sz - (byte_sz >> 3);
219
word much_smaller_than_i = byte_sz - (byte_sz >> 2);
220
register word low_limit; /* The lowest indexed entry we */
224
if (GC_size_map[smaller_than_i] == 0) {
225
low_limit = much_smaller_than_i;
226
while (GC_size_map[low_limit] != 0) low_limit++;
228
low_limit = smaller_than_i + 1;
229
while (GC_size_map[low_limit] != 0) low_limit++;
230
word_sz = ROUNDED_UP_WORDS(low_limit);
231
word_sz += word_sz >> 3;
232
if (word_sz < orig_word_sz) word_sz = orig_word_sz;
238
if (word_sz > MAXOBJSZ) {
241
/* If we can fit the same number of larger objects in a block, */
244
size_t number_of_objs = BODY_SZ/word_sz;
245
word_sz = BODY_SZ/number_of_objs;
250
byte_sz = WORDS_TO_BYTES(word_sz);
251
if (GC_all_interior_pointers) {
252
/* We need one extra byte; don't fill in GC_size_map[byte_sz] */
253
byte_sz -= EXTRA_BYTES;
256
for (j = low_limit; j <= byte_sz; j++) GC_size_map[j] = word_sz;
196
size_t number_of_objs = HBLK_GRANULES/granule_sz;
197
granule_sz = HBLK_GRANULES/number_of_objs;
200
byte_sz = GRANULES_TO_BYTES(granule_sz);
201
/* We may need one extra byte; */
202
/* don't always fill in GC_size_map[byte_sz] */
203
byte_sz -= EXTRA_BYTES;
205
for (j = low_limit; j <= byte_sz; j++) GC_size_map[j] = granule_sz;
274
222
# define CLEAR_SIZE 213 /* Granularity for GC_clear_stack_inner */
275
223
# define DEGRADE_RATE 50
277
word GC_min_sp; /* Coolest stack pointer value from which we've */
225
ptr_t GC_min_sp; /* Coolest stack pointer value from which we've */
278
226
/* already cleared the stack. */
281
229
/* "hottest" stack pointer value we have seen */
282
230
/* recently. Degrades over time. */
284
word GC_words_allocd_at_reset;
232
word GC_bytes_allocd_at_reset;
286
234
#if defined(ASM_CLEAR_CODE)
287
extern ptr_t GC_clear_stack_inner();
235
extern void *GC_clear_stack_inner(void *, ptr_t);
289
237
/* Clear the stack up to about limit. Return arg. */
291
ptr_t GC_clear_stack_inner(arg, limit)
239
void * GC_clear_stack_inner(void *arg, ptr_t limit)
295
241
word dummy[CLEAR_SIZE];
297
243
BZERO(dummy, CLEAR_SIZE*sizeof(word));
298
if ((word)(dummy) COOLER_THAN limit) {
244
if ((ptr_t)(dummy) COOLER_THAN limit) {
299
245
(void) GC_clear_stack_inner(arg, limit);
301
247
/* Make sure the recursive call is not a tail call, and the bzero */
406
347
/* to the beginning. */
407
348
while (IS_FORWARDING_ADDR_OR_NIL(candidate_hdr)) {
408
349
h = FORWARDED_ADDR(h,candidate_hdr);
410
351
candidate_hdr = HDR(h);
412
if (candidate_hdr -> hb_map == GC_invalid_map) return(0);
353
if (HBLK_IS_FREE(candidate_hdr)) return(0);
413
354
/* Make sure r points to the beginning of the object */
414
r &= ~(WORDS_TO_BYTES(1) - 1);
355
r = (ptr_t)((word)r & ~(WORDS_TO_BYTES(1) - 1));
416
register int offset = HBLKDISPL(r);
417
register signed_word sz = candidate_hdr -> hb_sz;
418
register signed_word map_entry;
420
map_entry = MAP_ENTRY((candidate_hdr -> hb_map), offset);
421
if (map_entry > CPP_MAX_OFFSET) {
422
map_entry = (signed_word)(BYTES_TO_WORDS(offset)) % sz;
424
r -= WORDS_TO_BYTES(map_entry);
425
limit = r + WORDS_TO_BYTES(sz);
426
if (limit > (word)(h + 1)
427
&& sz <= BYTES_TO_WORDS(HBLKSIZE)) {
357
size_t offset = HBLKDISPL(r);
358
signed_word sz = candidate_hdr -> hb_sz;
359
size_t obj_displ = offset % sz;
363
if (limit > (ptr_t)(h + 1) && sz <= HBLKSIZE) {
430
if ((word)p >= limit) return(0);
366
if ((ptr_t)p >= limit) return(0);
436
372
/* Return the size of an object, given a pointer to its base. */
437
373
/* (For small obects this also happens to work from interior pointers, */
438
374
/* but that shouldn't be relied upon.) */
440
size_t GC_size(GC_PTR p)
375
size_t GC_size(void * p)
447
register hdr * hhdr = HDR(p);
449
sz = WORDS_TO_BYTES(hhdr -> hb_sz);
453
size_t GC_get_heap_size GC_PROTO(())
455
return ((size_t) GC_heapsize);
458
size_t GC_get_free_bytes GC_PROTO(())
460
return ((size_t) GC_large_free_bytes);
463
size_t GC_get_bytes_since_gc GC_PROTO(())
465
return ((size_t) WORDS_TO_BYTES(GC_words_allocd));
468
size_t GC_get_total_bytes GC_PROTO(())
470
return ((size_t) WORDS_TO_BYTES(GC_words_allocd+GC_words_allocd_before_gc));
379
return hhdr -> hb_sz;
382
size_t GC_get_heap_size(void)
387
size_t GC_get_free_bytes(void)
389
return GC_large_free_bytes;
392
size_t GC_get_bytes_since_gc(void)
394
return GC_bytes_allocd;
397
size_t GC_get_total_bytes(void)
399
return GC_bytes_allocd+GC_bytes_allocd_before_gc;
473
402
GC_bool GC_is_initialized = FALSE;
404
# if defined(PARALLEL_MARK) || defined(THREAD_LOCAL_ALLOC)
405
extern void GC_init_parallel(void);
406
# endif /* PARALLEL_MARK || THREAD_LOCAL_ALLOC */
408
/* FIXME: The GC_init/GC_init_inner distinction should go away. */
481
#if defined(GC_WIN32_THREADS) && !defined(GC_PTHREADS)
482
if (!GC_is_initialized) {
483
BOOL (WINAPI *pfn) (LPCRITICAL_SECTION, DWORD) = NULL;
484
HMODULE hK32 = GetModuleHandleA("kernel32.dll");
486
pfn = (BOOL (WINAPI *) (LPCRITICAL_SECTION, DWORD))
487
GetProcAddress (hK32,
488
"InitializeCriticalSectionAndSpinCount");
490
pfn(&GC_allocate_ml, 4000);
492
InitializeCriticalSection (&GC_allocate_ml);
411
/* LOCK(); -- no longer does anything this early. */
501
# if defined(PARALLEL_MARK) || defined(THREAD_LOCAL_ALLOC)
502
/* Make sure marker threads and started and thread local */
503
/* allocation is initialized, in case we didn't get */
504
/* called from GC_init_parallel(); */
506
extern void GC_init_parallel(void);
509
# endif /* PARALLEL_MARK || THREAD_LOCAL_ALLOC */
511
# if defined(DYNAMIC_LOADING) && defined(DARWIN)
513
/* This must be called WITHOUT the allocation lock held
514
and before any threads are created */
515
extern void GC_init_dyld();
521
416
#if defined(MSWIN32) || defined(MSWINCE)
581
479
word initial_heap_sz = (word)MINHINCR;
583
481
if (GC_is_initialized) return;
483
/* Note that although we are nominally called with the */
484
/* allocation lock held, the allocation lock is now */
485
/* only really acquired once a second thread is forked.*/
486
/* And the initialization code needs to run before */
487
/* then. Thus we really don't hold any locks, and can */
488
/* in fact safely initialize them here. */
490
GC_ASSERT(!GC_need_to_lock);
492
# if defined(GC_WIN32_THREADS) && !defined(GC_PTHREADS)
493
if (!GC_is_initialized) {
494
BOOL (WINAPI *pfn) (LPCRITICAL_SECTION, DWORD) = NULL;
495
HMODULE hK32 = GetModuleHandleA("kernel32.dll");
497
pfn = (BOOL (WINAPI *) (LPCRITICAL_SECTION, DWORD))
498
GetProcAddress (hK32,
499
"InitializeCriticalSectionAndSpinCount");
501
pfn(&GC_allocate_ml, 4000);
503
InitializeCriticalSection (&GC_allocate_ml);
587
506
# if defined(MSWIN32) || defined(MSWINCE)
588
507
InitializeCriticalSection(&GC_write_cs);
590
if (0 != GETENV("GC_PRINT_STATS")) {
509
# if (!defined(SMALL_CONFIG))
510
if (0 != GETENV("GC_PRINT_STATS")) {
513
if (0 != GETENV("GC_PRINT_VERBOSE_STATS")) {
514
GC_print_stats = VERBOSE;
516
# if defined(UNIX_LIKE)
518
char * file_name = GETENV("GC_LOG_FILE");
519
if (0 != file_name) {
520
int log_d = open(file_name, O_CREAT|O_WRONLY|O_APPEND, 0666);
522
GC_log_printf("Failed to open %s as log file\n", file_name);
593
530
# ifndef NO_DEBUGGING
594
531
if (0 != GETENV("GC_DUMP_REGULARLY")) {
595
532
GC_dump_regularly = 1;
616
# if defined(USE_PROC_FOR_LIBRARIES) && defined(GC_LINUX_THREADS)
617
WARN("USE_PROC_FOR_LIBRARIES + GC_LINUX_THREADS performs poorly.\n", 0);
618
/* If thread stacks are cached, they tend to be scanned in */
619
/* entirety as part of the root set. This wil grow them to */
620
/* maximum size, and is generally not desirable. */
664
622
# if defined(SEARCH_FOR_DATA_START)
665
623
GC_init_linux_data_start();
667
625
# if (defined(NETBSD) || defined(OPENBSD)) && defined(__ELF__)
668
626
GC_init_netbsd_elf();
670
# if defined(GC_PTHREADS) || defined(GC_SOLARIS_THREADS) \
671
|| defined(GC_WIN32_THREADS)
674
# ifdef GC_SOLARIS_THREADS
675
/* We need dirty bits in order to find live stack sections. */
678
628
# if !defined(THREADS) || defined(GC_PTHREADS) || defined(GC_WIN32_THREADS) \
679
629
|| defined(GC_SOLARIS_THREADS)
680
630
if (GC_stackbottom == 0) {
681
GC_stackbottom = GC_get_stack_base();
631
GC_stackbottom = GC_get_main_stack_base();
682
632
# if (defined(LINUX) || defined(HPUX)) && defined(IA64)
683
633
GC_register_stackbottom = GC_get_register_stack_base();
686
636
# if (defined(LINUX) || defined(HPUX)) && defined(IA64)
687
637
if (GC_register_stackbottom == 0) {
688
WARN("GC_register_stackbottom should be set with GC_stackbottom", 0);
638
WARN("GC_register_stackbottom should be set with GC_stackbottom\n", 0);
689
639
/* The following may fail, since we may rely on */
690
640
/* alignment properties that may not hold with a user set */
691
641
/* GC_stackbottom. */
866
int GC_write(buf, len)
839
# define GC_need_to_lock 0 /* Not defined without threads */
841
int GC_write(const char *buf, size_t len)
874
EnterCriticalSection(&GC_write_cs);
847
if (GC_need_to_lock) EnterCriticalSection(&GC_write_cs);
875
848
if (GC_stdout == INVALID_HANDLE_VALUE) {
849
if (GC_need_to_lock) LeaveCriticalSection(&GC_write_cs);
877
851
} else if (GC_stdout == 0) {
878
GC_stdout = CreateFile(LOG_FILE, GENERIC_WRITE,
879
FILE_SHARE_READ | FILE_SHARE_WRITE,
880
NULL, CREATE_ALWAYS, FILE_FLAG_WRITE_THROUGH,
882
if (GC_stdout == INVALID_HANDLE_VALUE) ABORT("Open of log file failed");
852
char * file_name = GETENV("GC_LOG_FILE");
853
char logPath[_MAX_PATH + 5];
855
if (0 == file_name) {
856
# ifdef OLD_WIN32_LOG_FILE
857
strcpy(logPath, LOG_FILE);
859
GetModuleFileName(NULL, logPath, _MAX_PATH);
860
strcat(logPath, ".log");
864
GC_stdout = CreateFile(logPath, GENERIC_WRITE,
866
NULL, CREATE_ALWAYS, FILE_FLAG_WRITE_THROUGH,
868
if (GC_stdout == INVALID_HANDLE_VALUE)
869
ABORT("Open of log file failed");
884
tmp = WriteFile(GC_stdout, buf, len, &written, NULL);
871
tmp = WriteFile(GC_stdout, buf, (DWORD)len, &written, NULL);
887
LeaveCriticalSection(&GC_write_cs);
874
# if defined(_MSC_VER) && defined(_DEBUG)
875
_CrtDbgReport(_CRT_WARN, NULL, 0, NULL, "%.*s", len, buf);
877
if (GC_need_to_lock) LeaveCriticalSection(&GC_write_cs);
888
878
return tmp ? (int)written : -1;
880
# undef GC_need_to_lock
893
884
#if defined(OS2) || defined(MACOS)
894
885
FILE * GC_stdout = NULL;
895
886
FILE * GC_stderr = NULL;
887
FILE * GC_log = NULL;
896
888
int GC_tmp; /* Should really be local ... */
898
890
void GC_set_files()
969
# define vsnprintf _vsnprintf
970
971
/* A version of printf that is unlikely to call malloc, and is thus safer */
971
972
/* to call from the collector in case malloc has been bound to GC_malloc. */
972
/* Assumes that no more than 1023 characters are written at once. */
973
/* Assumes that all arguments have been converted to something of the */
974
/* same size as long, and that the format conversions expect something */
976
void GC_printf(format, a, b, c, d, e, f)
977
GC_CONST char * format;
978
long a, b, c, d, e, f;
973
/* Floating point arguments ans formats should be avoided, since fp */
974
/* conversion is more likely to allocate. */
975
/* Assumes that no more than BUFSZ-1 characters are written at once. */
976
void GC_printf(const char *format, ...)
981
va_start(args, format);
982
982
if (GC_quiet) return;
984
(void) sprintf(buf, format, a, b, c, d, e, f);
985
if (buf[1024] != 0x15) ABORT("GC_printf clobbered stack");
984
(void) vsnprintf(buf, BUFSZ, format, args);
986
if (buf[BUFSZ] != 0x15) ABORT("GC_printf clobbered stack");
986
987
if (WRITE(GC_stdout, buf, strlen(buf)) < 0) ABORT("write to stdout failed");
989
void GC_err_printf(format, a, b, c, d, e, f)
990
GC_CONST char * format;
991
long a, b, c, d, e, f;
990
void GC_err_printf(const char *format, ...)
996
(void) sprintf(buf, format, a, b, c, d, e, f);
997
if (buf[1024] != 0x15) ABORT("GC_err_printf clobbered stack");
995
va_start(args, format);
997
(void) vsnprintf(buf, BUFSZ, format, args);
999
if (buf[BUFSZ] != 0x15) ABORT("GC_printf clobbered stack");
998
1000
if (WRITE(GC_stderr, buf, strlen(buf)) < 0) ABORT("write to stderr failed");
1003
void GC_log_printf(const char *format, ...)
1008
va_start(args, format);
1010
(void) vsnprintf(buf, BUFSZ, format, args);
1012
if (buf[BUFSZ] != 0x15) ABORT("GC_printf clobbered stack");
1013
if (WRITE(GC_log, buf, strlen(buf)) < 0) ABORT("write to log failed");
1016
void GC_err_puts(const char *s)
1004
1018
if (WRITE(GC_stderr, s, strlen(s)) < 0) ABORT("write to stderr failed");
1007
1021
#if defined(LINUX) && !defined(SMALL_CONFIG)
1008
1022
void GC_err_write(buf, len)
1012
1026
if (WRITE(GC_stderr, buf, len) < 0) ABORT("write to stderr failed");
1016
# if defined(__STDC__) || defined(__cplusplus)
1017
void GC_default_warn_proc(char *msg, GC_word arg)
1019
void GC_default_warn_proc(msg, arg)
1030
void GC_default_warn_proc(char *msg, GC_word arg)
1024
GC_err_printf1(msg, (unsigned long)arg);
1032
GC_err_printf(msg, arg);
1027
1035
GC_warn_proc GC_current_warn_proc = GC_default_warn_proc;
1029
# if defined(__STDC__) || defined(__cplusplus)
1030
GC_warn_proc GC_set_warn_proc(GC_warn_proc p)
1032
GC_warn_proc GC_set_warn_proc(p)
1037
GC_warn_proc GC_set_warn_proc(GC_warn_proc p)
1036
1039
GC_warn_proc result;
1098
1095
/* Helper procedures for new kind creation. */
1099
1096
void ** GC_new_free_list_inner()
1101
void *result = GC_INTERNAL_MALLOC((MAXOBJSZ+1)*sizeof(ptr_t), PTRFREE);
1098
void *result = GC_INTERNAL_MALLOC((MAXOBJGRANULES+1)*sizeof(ptr_t),
1102
1100
if (result == 0) ABORT("Failed to allocate freelist for new kind");
1103
BZERO(result, (MAXOBJSZ+1)*sizeof(ptr_t));
1101
BZERO(result, (MAXOBJGRANULES+1)*sizeof(ptr_t));
1107
1105
void ** GC_new_free_list()
1110
LOCK(); DISABLE_SIGNALS();
1111
1109
result = GC_new_free_list_inner();
1112
UNLOCK(); ENABLE_SIGNALS();
1116
int GC_new_kind_inner(fl, descr, adjust, clear)
1114
unsigned GC_new_kind_inner(void **fl, GC_word descr, int adjust, int clear)
1122
int result = GC_n_kinds++;
1116
unsigned result = GC_n_kinds++;
1124
1118
if (GC_n_kinds > MAXOBJKINDS) ABORT("Too many kinds");
1125
GC_obj_kinds[result].ok_freelist = (ptr_t *)fl;
1119
GC_obj_kinds[result].ok_freelist = fl;
1126
1120
GC_obj_kinds[result].ok_reclaim_list = 0;
1127
1121
GC_obj_kinds[result].ok_descriptor = descr;
1128
1122
GC_obj_kinds[result].ok_relocate_descr = adjust;
1133
int GC_new_kind(fl, descr, adjust, clear)
1127
unsigned GC_new_kind(void **fl, GC_word descr, int adjust, int clear)
1140
LOCK(); DISABLE_SIGNALS();
1141
1131
result = GC_new_kind_inner(fl, descr, adjust, clear);
1142
UNLOCK(); ENABLE_SIGNALS();
1146
int GC_new_proc_inner(proc)
1136
unsigned GC_new_proc_inner(GC_mark_proc proc)
1149
int result = GC_n_mark_procs++;
1138
unsigned result = GC_n_mark_procs++;
1151
1140
if (GC_n_mark_procs > MAX_MARK_PROCS) ABORT("Too many mark procedures");
1152
1141
GC_mark_procs[result] = proc;
1156
int GC_new_proc(proc)
1145
unsigned GC_new_proc(GC_mark_proc proc)
1160
LOCK(); DISABLE_SIGNALS();
1161
1149
result = GC_new_proc_inner(proc);
1162
UNLOCK(); ENABLE_SIGNALS();
1154
GC_API void * GC_call_with_stack_base(GC_stack_base_func fn, void *arg)
1157
struct GC_stack_base base;
1159
base.mem_base = (void *)&dummy;
1161
base.reg_base = (void *)GC_save_regs_in_stack();
1162
/* Unnecessarily flushes register stack, */
1163
/* but that probably doesn't hurt. */
1165
return fn(&base, arg);
1167
1168
#if !defined(NO_DEBUGGING)
1171
GC_printf0("***Static roots:\n");
1172
GC_printf("***Static roots:\n");
1172
1173
GC_print_static_roots();
1173
GC_printf0("\n***Heap sections:\n");
1174
GC_printf("\n***Heap sections:\n");
1174
1175
GC_print_heap_sects();
1175
GC_printf0("\n***Free blocks:\n");
1176
GC_printf("\n***Free blocks:\n");
1176
1177
GC_print_hblkfreelist();
1177
GC_printf0("\n***Blocks in use:\n");
1178
GC_printf("\n***Blocks in use:\n");
1178
1179
GC_print_block_list();
1179
GC_printf0("\n***Finalization statistics:\n");
1180
GC_printf("\n***Finalization statistics:\n");
1180
1181
GC_print_finalization_stats();