2 * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
3 * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
4 * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved.
5 * Copyright (c) 1999-2001 by Hewlett-Packard Company. All rights reserved.
8 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
9 * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
11 * Permission is hereby granted to use or copy this program
12 * for any purpose, provided the above notices are retained on all copies.
13 * Permission to modify the code and to distribute modified code is granted,
14 * provided the above notices are retained, and a notice that the code was
15 * modified is included with the above copyright notice.
22 #if defined(mips) && defined(SYSTYPE_BSD) && defined(sony_news)
23 /* sony RISC NEWS, NEWSOS 4 */
25 /* typedef long ptrdiff_t; -- necessary on some really old systems */
28 #if defined(mips) && defined(SYSTYPE_BSD43)
34 # include <sys/types.h>
35 # include <sys/time.h>
36 # include <sys/resource.h>
44 # include "../gc_mark.h"
48 # include "gcconfig.h"
52 typedef GC_signed_word signed_word;
58 typedef char * ptr_t; /* A generic pointer to which we can add */
59 /* byte displacements. */
60 /* Preferably identical to caddr_t, if it */
69 # if !(defined( sony_news ) )
72 # define VOLATILE volatile
80 #if 0 /* defined(__GNUC__) doesn't work yet */
81 # define EXPECT(expr, outcome) __builtin_expect(expr,outcome)
82 /* Equivalent to (expr), but predict that usually (expr)==outcome. */
84 # define EXPECT(expr, outcome) (expr)
88 # include "gc_locks.h"
91 # ifdef STACK_GROWS_DOWN
92 # define COOLER_THAN >
93 # define HOTTER_THAN <
94 # define MAKE_COOLER(x,y) if ((word)(x)+(y) > (word)(x)) {(x) += (y);} \
95 else {(x) = (word)ONES;}
96 # define MAKE_HOTTER(x,y) (x) -= (y)
98 # define COOLER_THAN <
99 # define HOTTER_THAN >
100 # define MAKE_COOLER(x,y) if ((word)(x)-(y) < (word)(x)) {(x) -= (y);} else {(x) = 0;}
101 # define MAKE_HOTTER(x,y) (x) += (y)
104 #if defined(AMIGA) && defined(__SASC)
105 # define GC_FAR __far
111 /*********************************/
113 /* Definitions for conservative */
116 /*********************************/
118 /*********************************/
120 /* Easily changeable parameters */
122 /*********************************/
124 /* #define STUBBORN_ALLOC */
125 /* Enable stubborm allocation, and thus a limited */
126 /* form of incremental collection w/o dirty bits. */
128 /* #define ALL_INTERIOR_POINTERS */
129 /* Forces all pointers into the interior of an */
130 /* object to be considered valid. Also causes the */
131 /* sizes of all objects to be inflated by at least */
132 /* one byte. This should suffice to guarantee */
133 /* that in the presence of a compiler that does */
134 /* not perform garbage-collector-unsafe */
135 /* optimizations, all portable, strictly ANSI */
136 /* conforming C programs should be safely usable */
137 /* with malloc replaced by GC_malloc and free */
138 /* calls removed. There are several disadvantages: */
139 /* 1. There are probably no interesting, portable, */
140 /* strictly ANSI conforming C programs. */
141 /* 2. This option makes it hard for the collector */
142 /* to allocate space that is not ``pointed to'' */
143 /* by integers, etc. Under SunOS 4.X with a */
144 /* statically linked libc, we empiricaly */
145 /* observed that it would be difficult to */
146 /* allocate individual objects larger than 100K. */
147 /* Even if only smaller objects are allocated, */
148 /* more swap space is likely to be needed. */
149 /* Fortunately, much of this will never be */
151 /* If you can easily avoid using this option, do. */
152 /* If not, try to keep individual objects small. */
153 /* This is now really controlled at startup, */
154 /* through GC_all_interior_pointers. */
156 #define PRINTSTATS /* Print garbage collection statistics */
157 /* For less verbose output, undefine in reclaim.c */
159 #define PRINTTIMES /* Print the amount of time consumed by each garbage */
162 #define PRINTBLOCKS /* Print object sizes associated with heap blocks, */
163 /* whether the objects are atomic or composite, and */
164 /* whether or not the block was found to be empty */
165 /* during the reclaim phase. Typically generates */
166 /* about one screenful per garbage collection. */
181 #if defined(PRINTSTATS) && !defined(GATHERSTATS)
185 #if defined(PRINTSTATS) || !defined(SMALL_CONFIG)
186 # define CONDPRINT /* Print some things if GC_print_stats is set */
189 #define GC_INVOKE_FINALIZERS() GC_notify_or_invoke_finalizers()
191 #define MERGE_SIZES /* Round up some object sizes, so that fewer distinct */
192 /* free lists are actually maintained. This applies */
193 /* only to the top level routines in misc.c, not to */
194 /* user generated code that calls GC_allocobj and */
195 /* GC_allocaobj directly. */
196 /* Slows down average programs slightly. May however */
197 /* substantially reduce fragmentation if allocation */
198 /* request sizes are widely scattered. */
199 /* May save significant amounts of space for obj_map */
202 #if defined(USE_MARK_BYTES) && !defined(ALIGN_DOUBLE)
203 # define ALIGN_DOUBLE
204 /* We use one byte for every 2 words, which doesn't allow for */
205 /* odd numbered words to have mark bits. */
208 #if defined(GC_GCJ_SUPPORT) && ALIGNMENT < 8 && !defined(ALIGN_DOUBLE)
209 /* GCJ's Hashtable synchronization code requires 64-bit alignment. */
210 # define ALIGN_DOUBLE
214 /* ALIGN_DOUBLE requires MERGE_SIZES at present. */
215 # if defined(ALIGN_DOUBLE) && !defined(MERGE_SIZES)
219 #if !defined(DONT_ADD_BYTE_AT_END)
220 # define EXTRA_BYTES GC_all_interior_pointers
222 # define EXTRA_BYTES 0
226 # ifndef LARGE_CONFIG
227 # define MINHINCR 16 /* Minimum heap increment, in blocks of HBLKSIZE */
228 /* Must be multiple of largest page size. */
229 # define MAXHINCR 2048 /* Maximum heap increment, in blocks */
232 # define MAXHINCR 4096
235 # define TIME_LIMIT 50 /* We try to keep pause times from exceeding */
236 /* this by much. In milliseconds. */
238 # define BL_LIMIT GC_black_list_spacing
239 /* If we need a block of N bytes, and we have */
240 /* a block of N + BL_LIMIT bytes available, */
241 /* and N > BL_LIMIT, */
242 /* but all possible positions in it are */
243 /* blacklisted, we just use it anyway (and */
244 /* print a warning, if warnings are enabled). */
245 /* This risks subsequently leaking the block */
246 /* due to a false reference. But not using */
247 /* the block risks unreasonable immediate */
250 /*********************************/
252 /* Stack saving for debugging */
254 /*********************************/
256 #ifdef SAVE_CALL_CHAIN
258 /* Fill in the pc and argument information for up to NFRAMES of my */
259 /* callers. Ignore my frame and my callers frame. */
261 void GC_save_callers GC_PROTO((struct callinfo info[NFRAMES]));
263 void GC_print_callers GC_PROTO((struct callinfo info[NFRAMES]));
269 word ci_pc; /* Caller, not callee, pc */
271 word ci_arg[NARGS]; /* bit-wise complement to avoid retention */
273 # if defined(ALIGN_DOUBLE) && (NFRAMES * (NARGS + 1)) % 2 == 1
274 /* Likely alignment problem. */
281 /*********************************/
283 /* OS interface routines */
285 /*********************************/
291 # define CLOCK_TYPE struct timeval
292 # define GET_TIME(x) { struct rusage rusage; \
293 getrusage (RUSAGE_SELF, &rusage); \
294 x = rusage.ru_utime; }
295 # define MS_TIME_DIFF(a,b) ((double) (a.tv_sec - b.tv_sec) * 1000.0 \
296 + (double) (a.tv_usec - b.tv_usec) / 1000.0)
297 #else /* !BSD_TIME */
298 # if defined(MSWIN32) || defined(MSWINCE)
299 # include <windows.h>
300 # include <winbase.h>
301 # define CLOCK_TYPE DWORD
302 # define GET_TIME(x) x = GetTickCount()
303 # define MS_TIME_DIFF(a,b) ((long)((a)-(b)))
304 # else /* !MSWIN32, !MSWINCE, !BSD_TIME */
306 # if !defined(__STDC__) && defined(SPARC) && defined(SUNOS4)
307 clock_t clock(); /* Not in time.h, where it belongs */
309 # if defined(FREEBSD) && !defined(CLOCKS_PER_SEC)
310 # include <machine/limits.h>
311 # define CLOCKS_PER_SEC CLK_TCK
313 # if !defined(CLOCKS_PER_SEC)
314 # define CLOCKS_PER_SEC 1000000
316 * This is technically a bug in the implementation. ANSI requires that
317 * CLOCKS_PER_SEC be defined. But at least under SunOS4.1.1, it isn't.
318 * Also note that the combination of ANSI C and POSIX is incredibly gross
319 * here. The type clock_t is used by both clock() and times(). But on
320 * some machines these use different notions of a clock tick, CLOCKS_PER_SEC
321 * seems to apply only to clock. Hence we use it here. On many machines,
322 * including SunOS, clock actually uses units of microseconds (which are
323 * not really clock ticks).
326 # define CLOCK_TYPE clock_t
327 # define GET_TIME(x) x = clock()
328 # define MS_TIME_DIFF(a,b) ((unsigned long) \
329 (1000.0*(double)((a)-(b))/(double)CLOCKS_PER_SEC))
330 # endif /* !MSWIN32 */
331 #endif /* !BSD_TIME */
333 /* We use bzero and bcopy internally. They may not be available. */
334 # if defined(SPARC) && defined(SUNOS4)
335 # define BCOPY_EXISTS
337 # if defined(M68K) && defined(AMIGA)
338 # define BCOPY_EXISTS
340 # if defined(M68K) && defined(NEXT)
341 # define BCOPY_EXISTS
344 # define BCOPY_EXISTS
348 # define BCOPY_EXISTS
351 # define BCOPY_EXISTS
354 # ifndef BCOPY_EXISTS
356 # define BCOPY(x,y,n) memcpy(y, x, (size_t)(n))
357 # define BZERO(x,n) memset(x, 0, (size_t)(n))
359 # define BCOPY(x,y,n) bcopy((char *)(x),(char *)(y),(int)(n))
360 # define BZERO(x,n) bzero((char *)(x),(int)(n))
363 /* HBLKSIZE aligned allocation. 0 is taken to mean failure */
364 /* space is assumed to be cleared. */
365 /* In the case os USE_MMAP, the argument must also be a */
366 /* physical page size. */
367 /* GET_MEM is currently not assumed to retrieve 0 filled space, */
368 /* though we should perhaps take advantage of the case in which */
370 struct hblk; /* See below. */
372 char * real_malloc();
373 # define GET_MEM(bytes) HBLKPTR(real_malloc((size_t)bytes + GC_page_size) \
377 void * os2_alloc(size_t bytes);
378 # define GET_MEM(bytes) HBLKPTR((ptr_t)os2_alloc((size_t)bytes \
382 # if defined(NEXT) || defined(MACOSX) || defined(DOS4GW) || \
383 (defined(AMIGA) && !defined(GC_AMIGA_FASTALLOC)) || \
384 (defined(SUNOS5) && !defined(USE_MMAP))
385 # define GET_MEM(bytes) HBLKPTR((size_t) \
386 calloc(1, (size_t)bytes + GC_page_size) \
390 extern ptr_t GC_win32_get_mem();
391 # define GET_MEM(bytes) (struct hblk *)GC_win32_get_mem(bytes)
394 # if defined(USE_TEMPORARY_MEMORY)
395 extern Ptr GC_MacTemporaryNewPtr(size_t size,
396 Boolean clearMemory);
397 # define GET_MEM(bytes) HBLKPTR( \
398 GC_MacTemporaryNewPtr(bytes + GC_page_size, true) \
401 # define GET_MEM(bytes) HBLKPTR( \
402 NewPtrClear(bytes + GC_page_size) + GC_page_size-1)
406 extern ptr_t GC_wince_get_mem();
407 # define GET_MEM(bytes) (struct hblk *)GC_wince_get_mem(bytes)
409 # if defined(AMIGA) && defined(GC_AMIGA_FASTALLOC)
410 extern void *GC_amiga_get_mem(size_t size);
411 define GET_MEM(bytes) HBLKPTR((size_t) \
412 GC_amiga_get_mem((size_t)bytes + GC_page_size) \
415 extern ptr_t GC_unix_get_mem();
416 # define GET_MEM(bytes) (struct hblk *)GC_unix_get_mem(bytes)
425 /* Delay any interrupts or signals that may abort this thread. Data */
426 /* structures are in a consistent state outside this pair of calls. */
427 /* ANSI C allows both to be empty (though the standard isn't very */
428 /* clear on that point). Standard malloc implementations are usually */
429 /* neither interruptable nor thread-safe, and thus correspond to */
430 /* empty definitions. */
431 /* It probably doesn't make any sense to declare these to be nonempty */
432 /* if the code is being optimized, since signal safety relies on some */
433 /* ordering constraints that are typically not obeyed by optimizing */
436 # define DISABLE_SIGNALS() \
437 PCR_Th_SetSigMask(PCR_allSigsBlocked,&GC_old_sig_mask)
438 # define ENABLE_SIGNALS() \
439 PCR_Th_SetSigMask(&GC_old_sig_mask, NIL)
441 # if defined(THREADS) || defined(AMIGA) \
442 || defined(MSWIN32) || defined(MSWINCE) || defined(MACOS) \
443 || defined(DJGPP) || defined(NO_SIGNALS)
444 /* Also useful for debugging. */
445 /* Should probably use thr_sigsetmask for GC_SOLARIS_THREADS. */
446 # define DISABLE_SIGNALS()
447 # define ENABLE_SIGNALS()
449 # define DISABLE_SIGNALS() GC_disable_signals()
450 void GC_disable_signals();
451 # define ENABLE_SIGNALS() GC_enable_signals()
452 void GC_enable_signals();
457 * Stop and restart mutator threads.
460 # include "th/PCR_ThCtl.h"
461 # define STOP_WORLD() \
462 PCR_ThCtl_SetExclusiveMode(PCR_ThCtl_ExclusiveMode_stopNormal, \
463 PCR_allSigsBlocked, \
465 # define START_WORLD() \
466 PCR_ThCtl_SetExclusiveMode(PCR_ThCtl_ExclusiveMode_null, \
467 PCR_allSigsBlocked, \
470 # if defined(GC_SOLARIS_THREADS) || defined(GC_WIN32_THREADS) \
471 || defined(GC_PTHREADS)
472 void GC_stop_world();
473 void GC_start_world();
474 # define STOP_WORLD() GC_stop_world()
475 # define START_WORLD() GC_start_world()
477 # define STOP_WORLD()
478 # define START_WORLD()
484 # define ABORT(s) PCR_Base_Panic(s)
487 # define ABORT(msg) abort();
489 GC_API void GC_abort();
490 # define ABORT(msg) GC_abort(msg);
494 /* Exit abnormally, but without making a mess (e.g. out of memory) */
496 # define EXIT() PCR_Base_Exit(1,PCR_waitForever)
498 # define EXIT() (void)exit(1)
501 /* Print warning message, e.g. almost out of memory. */
502 # define WARN(msg,arg) (*GC_current_warn_proc)("GC Warning: " msg, (GC_word)(arg))
503 extern GC_warn_proc GC_current_warn_proc;
505 /* Get environment entry */
506 #if !defined(NO_GETENV)
507 # define GETENV(name) getenv(name)
509 # define GETENV(name) 0
512 /*********************************/
514 /* Word-size-dependent defines */
516 /*********************************/
519 # define WORDS_TO_BYTES(x) ((x)<<2)
520 # define BYTES_TO_WORDS(x) ((x)>>2)
521 # define LOGWL ((word)5) /* log[2] of CPP_WORDSZ */
522 # define modWORDSZ(n) ((n) & 0x1f) /* n mod size of word */
529 # define WORDS_TO_BYTES(x) ((x)<<3)
530 # define BYTES_TO_WORDS(x) ((x)>>3)
531 # define LOGWL ((word)6) /* log[2] of CPP_WORDSZ */
532 # define modWORDSZ(n) ((n) & 0x3f) /* n mod size of word */
538 #define WORDSZ ((word)CPP_WORDSZ)
539 #define SIGNB ((word)1 << (WORDSZ-1))
540 #define BYTES_PER_WORD ((word)(sizeof (word)))
541 #define ONES ((word)(signed_word)(-1))
542 #define divWORDSZ(n) ((n) >> LOGWL) /* divide n by size of word */
544 /*********************/
546 /* Size Parameters */
548 /*********************/
550 /* heap block size, bytes. Should be power of 2 */
554 # define CPP_LOG_HBLKSIZE 10
556 # if (CPP_WORDSZ == 32) || (defined(HPUX) && defined(HP_PA))
557 /* HPUX/PA seems to use 4K pages with the 64 bit ABI */
558 # define CPP_LOG_HBLKSIZE 12
560 # define CPP_LOG_HBLKSIZE 13
565 # define CPP_LOG_HBLKSIZE 9
567 # if HBLKSIZE == 1024
568 # define CPP_LOG_HBLKSIZE 10
570 # if HBLKSIZE == 2048
571 # define CPP_LOG_HBLKSIZE 11
573 # if HBLKSIZE == 4096
574 # define CPP_LOG_HBLKSIZE 12
576 # if HBLKSIZE == 8192
577 # define CPP_LOG_HBLKSIZE 13
579 # if HBLKSIZE == 16384
580 # define CPP_LOG_HBLKSIZE 14
582 # ifndef CPP_LOG_HBLKSIZE
587 # define CPP_HBLKSIZE (1 << CPP_LOG_HBLKSIZE)
588 # define LOG_HBLKSIZE ((word)CPP_LOG_HBLKSIZE)
589 # define HBLKSIZE ((word)CPP_HBLKSIZE)
592 /* max size objects supported by freelist (larger objects may be */
593 /* allocated, but less efficiently) */
595 #define CPP_MAXOBJBYTES (CPP_HBLKSIZE/2)
596 #define MAXOBJBYTES ((word)CPP_MAXOBJBYTES)
597 #define CPP_MAXOBJSZ BYTES_TO_WORDS(CPP_HBLKSIZE/2)
598 #define MAXOBJSZ ((word)CPP_MAXOBJSZ)
600 # define divHBLKSZ(n) ((n) >> LOG_HBLKSIZE)
602 # define HBLK_PTR_DIFF(p,q) divHBLKSZ((ptr_t)p - (ptr_t)q)
603 /* Equivalent to subtracting 2 hblk pointers. */
604 /* We do it this way because a compiler should */
605 /* find it hard to use an integer division */
606 /* instead of a shift. The bundled SunOS 4.1 */
607 /* o.w. sometimes pessimizes the subtraction to */
608 /* involve a call to .div. */
610 # define modHBLKSZ(n) ((n) & (HBLKSIZE-1))
612 # define HBLKPTR(objptr) ((struct hblk *)(((word) (objptr)) & ~(HBLKSIZE-1)))
614 # define HBLKDISPL(objptr) (((word) (objptr)) & (HBLKSIZE-1))
616 /* Round up byte allocation requests to integral number of words, etc. */
617 # define ROUNDED_UP_WORDS(n) \
618 BYTES_TO_WORDS((n) + (WORDS_TO_BYTES(1) - 1 + EXTRA_BYTES))
620 # define ALIGNED_WORDS(n) \
621 (BYTES_TO_WORDS((n) + WORDS_TO_BYTES(2) - 1 + EXTRA_BYTES) & ~1)
623 # define ALIGNED_WORDS(n) ROUNDED_UP_WORDS(n)
625 # define SMALL_OBJ(bytes) ((bytes) < (MAXOBJBYTES - EXTRA_BYTES))
626 # define ADD_SLOP(bytes) ((bytes) + EXTRA_BYTES)
628 /* MIN_WORDS is the size of the smallest allocated object. */
629 /* 1 and 2 are the only valid values. */
630 /* 2 must be used if: */
631 /* - GC_gcj_malloc can be used for objects of requested */
632 /* size smaller than 2 words, or */
633 /* - USE_MARK_BYTES is defined. */
634 # if defined(USE_MARK_BYTES) || defined(GC_GCJ_SUPPORT)
635 # define MIN_WORDS 2 /* Smallest allocated object. */
643 * Hash table representation of sets of pages. This assumes it is
644 * OK to add spurious entries to sets.
645 * Used by black-listing code, and perhaps by dirty bit maintenance code.
649 # define LOG_PHT_ENTRIES 19 /* Collisions likely at 512K blocks, */
650 /* which is >= 2GB. Each table takes */
654 # define LOG_PHT_ENTRIES 14 /* Collisions are likely if heap grows */
655 /* to more than 16K hblks = 64MB. */
656 /* Each hash table occupies 2K bytes. */
657 # else /* default "medium" configuration */
658 # define LOG_PHT_ENTRIES 16 /* Collisions are likely if heap grows */
659 /* to more than 16K hblks >= 256MB. */
660 /* Each hash table occupies 8K bytes. */
663 # define PHT_ENTRIES ((word)1 << LOG_PHT_ENTRIES)
664 # define PHT_SIZE (PHT_ENTRIES >> LOGWL)
665 typedef word page_hash_table[PHT_SIZE];
667 # define PHT_HASH(addr) ((((word)(addr)) >> LOG_HBLKSIZE) & (PHT_ENTRIES - 1))
669 # define get_pht_entry_from_index(bl, index) \
670 (((bl)[divWORDSZ(index)] >> modWORDSZ(index)) & 1)
671 # define set_pht_entry_from_index(bl, index) \
672 (bl)[divWORDSZ(index)] |= (word)1 << modWORDSZ(index)
673 # define clear_pht_entry_from_index(bl, index) \
674 (bl)[divWORDSZ(index)] &= ~((word)1 << modWORDSZ(index))
675 /* And a dumb but thread-safe version of set_pht_entry_from_index. */
676 /* This sets (many) extra bits. */
677 # define set_pht_entry_from_index_safe(bl, index) \
678 (bl)[divWORDSZ(index)] = ONES
682 /********************************************/
684 /* H e a p B l o c k s */
686 /********************************************/
688 /* heap block header */
689 #define HBLKMASK (HBLKSIZE-1)
691 #define BITS_PER_HBLK (CPP_HBLKSIZE * 8)
693 #define MARK_BITS_PER_HBLK (BITS_PER_HBLK/CPP_WORDSZ)
695 /* We allocate 1 bit/word, unless USE_MARK_BYTES */
696 /* is defined. Only the first word */
697 /* in each object is actually marked. */
699 # ifdef USE_MARK_BYTES
700 # define MARK_BITS_SZ (MARK_BITS_PER_HBLK/2)
701 /* Unlike the other case, this is in units of bytes. */
702 /* We actually allocate only every second mark bit, since we */
703 /* force all objects to be doubleword aligned. */
704 /* However, each mark bit is allocated as a byte. */
706 # define MARK_BITS_SZ (MARK_BITS_PER_HBLK/CPP_WORDSZ)
709 /* We maintain layout maps for heap blocks containing objects of a given */
710 /* size. Each entry in this map describes a byte offset and has the */
711 /* following type. */
712 typedef unsigned char map_entry_type;
715 word hb_sz; /* If in use, size in words, of objects in the block. */
716 /* if free, the size in bytes of the whole block */
717 struct hblk * hb_next; /* Link field for hblk free list */
718 /* and for lists of chunks waiting to be */
720 struct hblk * hb_prev; /* Backwards link for free list. */
721 word hb_descr; /* object descriptor for marking. See */
723 map_entry_type * hb_map;
724 /* A pointer to a pointer validity map of the block. */
725 /* See GC_obj_map. */
726 /* Valid for all blocks with headers. */
727 /* Free blocks point to GC_invalid_map. */
728 unsigned char hb_obj_kind;
729 /* Kind of objects in the block. Each kind */
730 /* identifies a mark procedure and a set of */
731 /* list headers. Sometimes called regions. */
732 unsigned char hb_flags;
733 # define IGNORE_OFF_PAGE 1 /* Ignore pointers that do not */
734 /* point to the first page of */
736 # define WAS_UNMAPPED 2 /* This is a free block, which has */
737 /* been unmapped from the address */
739 /* GC_remap must be invoked on it */
740 /* before it can be reallocated. */
741 /* Only set with USE_MUNMAP. */
742 unsigned short hb_last_reclaimed;
743 /* Value of GC_gc_no when block was */
744 /* last allocated or swept. May wrap. */
745 /* For a free block, this is maintained */
746 /* only for USE_MUNMAP, and indicates */
747 /* when the header was allocated, or */
748 /* when the size of the block last */
750 # ifdef USE_MARK_BYTES
752 char _hb_marks[MARK_BITS_SZ];
753 /* The i'th byte is 1 if the object */
754 /* starting at word 2i is marked, 0 o.w. */
755 word dummy; /* Force word alignment of mark bytes. */
757 # define hb_marks _mark_byte_union._hb_marks
759 word hb_marks[MARK_BITS_SZ];
760 /* Bit i in the array refers to the */
761 /* object starting at the ith word (header */
762 /* INCLUDED) in the heap block. */
763 /* The lsb of word 0 is numbered 0. */
764 /* Unused bits are invalid, and are */
765 /* occasionally set, e.g for uncollectable */
767 # endif /* !USE_MARK_BYTES */
770 /* heap block body */
772 # define BODY_SZ (HBLKSIZE/sizeof(word))
775 word hb_body[BODY_SZ];
778 # define HBLK_IS_FREE(hdr) ((hdr) -> hb_map == GC_invalid_map)
780 # define OBJ_SZ_TO_BLOCKS(sz) \
781 divHBLKSZ(WORDS_TO_BYTES(sz) + HBLKSIZE-1)
782 /* Size of block (in units of HBLKSIZE) needed to hold objects of */
783 /* given sz (in words). */
785 /* Object free list link */
786 # define obj_link(p) (*(ptr_t *)(p))
788 # define LOG_MAX_MARK_PROCS 6
789 # define MAX_MARK_PROCS (1 << LOG_MAX_MARK_PROCS)
791 /* Root sets. Logically private to mark_rts.c. But we don't want the */
792 /* tables scanned, so we put them here. */
793 /* MAX_ROOT_SETS is the maximum number of ranges that can be */
794 /* registered as static roots. */
796 # define MAX_ROOT_SETS 4096
799 # define MAX_ROOT_SETS 1024
801 # if defined(MSWIN32) || defined(MSWINCE)
802 # define MAX_ROOT_SETS 1024
803 /* Under NT, we add only written pages, which can result */
804 /* in many small root sets. */
806 # define MAX_ROOT_SETS 256
811 # define MAX_EXCLUSIONS (MAX_ROOT_SETS/4)
812 /* Maximum number of segments that can be excluded from root sets. */
815 * Data structure for excluded static roots.
822 /* Data structure for list of root sets. */
823 /* We keep a hash table, so that we can filter out duplicate additions. */
824 /* Under Win32, we need to do a better job of filtering overlaps, so */
825 /* we resort to sequential search, and pay the price. */
829 # if !defined(MSWIN32) && !defined(MSWINCE)
830 struct roots * r_next;
833 /* Delete before registering new dynamic libraries */
836 #if !defined(MSWIN32) && !defined(MSWINCE)
837 /* Size of hash table index to roots. */
838 # define LOG_RT_SIZE 6
839 # define RT_SIZE (1 << LOG_RT_SIZE) /* Power of 2, may be != MAX_ROOT_SETS */
842 /* Lists of all heap blocks and free lists */
843 /* as well as other random data structures */
844 /* that should not be scanned by the */
846 /* These are grouped together in a struct */
847 /* so that they can be easily skipped by the */
848 /* GC_mark routine. */
849 /* The ordering is weird to make GC_malloc */
850 /* faster by keeping the important fields */
851 /* sufficiently close together that a */
852 /* single load of a base register will do. */
853 /* Scalars that could easily appear to */
854 /* be pointers are also put here. */
855 /* The main fields should precede any */
856 /* conditionally included fields, so that */
857 /* gc_inl.h will work even if a different set */
858 /* of macros is defined when the client is */
864 word _requested_heapsize; /* Heap size due to explicit expansion */
865 ptr_t _last_heap_addr;
866 ptr_t _prev_heap_addr;
867 word _large_free_bytes;
868 /* Total bytes contained in blocks on large object free */
870 word _large_allocd_bytes;
871 /* Total number of bytes in allocated large objects blocks. */
872 /* For the purposes of this counter and the next one only, a */
873 /* large object is one that occupies a block of at least */
875 word _max_large_allocd_bytes;
876 /* Maximum number of bytes that were ever allocated in */
877 /* large object blocks. This is used to help decide when it */
878 /* is safe to split up a large block. */
879 word _words_allocd_before_gc;
880 /* Number of words allocated before this */
881 /* collection cycle. */
882 # ifndef SEPARATE_GLOBALS
884 /* Number of words allocated during this collection cycle */
887 /* Number of words wasted due to internal fragmentation */
888 /* in large objects, or due to dropping blacklisted */
889 /* blocks, since last gc. Approximate. */
890 word _words_finalized;
891 /* Approximate number of words in objects (and headers) */
892 /* That became ready for finalization in the last */
894 word _non_gc_bytes_at_gc;
895 /* Number of explicitly managed bytes of storage */
896 /* at last collection. */
898 /* Number of explicitly deallocated words of memory */
899 /* since last collection. */
900 ptr_t _scratch_end_ptr;
901 ptr_t _scratch_last_end_ptr;
902 /* Used by headers.c, and can easily appear to point to */
904 GC_mark_proc _mark_procs[MAX_MARK_PROCS];
905 /* Table of user-defined mark procedures. There is */
906 /* a small number of these, which can be referenced */
907 /* by DS_PROC mark descriptors. See gc_mark.h. */
909 # ifndef SEPARATE_GLOBALS
910 ptr_t _objfreelist[MAXOBJSZ+1];
911 /* free list for objects */
912 ptr_t _aobjfreelist[MAXOBJSZ+1];
913 /* free list for atomic objs */
916 ptr_t _uobjfreelist[MAXOBJSZ+1];
917 /* uncollectable but traced objs */
918 /* objects on this and auobjfreelist */
919 /* are always marked, except during */
920 /* garbage collections. */
921 # ifdef ATOMIC_UNCOLLECTABLE
922 ptr_t _auobjfreelist[MAXOBJSZ+1];
924 /* uncollectable but traced objs */
927 word _composite_in_use;
928 /* Number of words in accessible composite */
931 /* Number of words in accessible atomic */
935 word _unmapped_bytes;
938 unsigned _size_map[WORDS_TO_BYTES(MAXOBJSZ+1)];
939 /* Number of words to allocate for a given allocation request in */
943 # ifdef STUBBORN_ALLOC
944 ptr_t _sobjfreelist[MAXOBJSZ+1];
946 /* free list for immutable objects */
947 map_entry_type * _obj_map[MAXOBJSZ+1];
948 /* If not NIL, then a pointer to a map of valid */
949 /* object addresses. _obj_map[sz][i] is j if the */
950 /* address block_start+i is a valid pointer */
951 /* to an object at block_start + */
952 /* WORDS_TO_BYTES(BYTES_TO_WORDS(i) - j) */
953 /* I.e. j is a word displacement from the */
954 /* object beginning. */
955 /* The entry is OBJ_INVALID if the corresponding */
956 /* address is not a valid pointer. It is */
957 /* OFFSET_TOO_BIG if the value j would be too */
958 /* large to fit in the entry. (Note that the */
959 /* size of these entries matters, both for */
960 /* space consumption and for cache utilization. */
961 # define OFFSET_TOO_BIG 0xfe
962 # define OBJ_INVALID 0xff
963 # define MAP_ENTRY(map, bytes) (map)[bytes]
964 # define MAP_ENTRIES HBLKSIZE
965 # define MAP_SIZE MAP_ENTRIES
966 # define CPP_MAX_OFFSET (OFFSET_TOO_BIG - 1)
967 # define MAX_OFFSET ((word)CPP_MAX_OFFSET)
968 /* The following are used only if GC_all_interior_ptrs != 0 */
969 # define VALID_OFFSET_SZ \
970 (CPP_MAX_OFFSET > WORDS_TO_BYTES(CPP_MAXOBJSZ)? \
972 : WORDS_TO_BYTES(CPP_MAXOBJSZ)+1)
973 char _valid_offsets[VALID_OFFSET_SZ];
974 /* GC_valid_offsets[i] == TRUE ==> i */
975 /* is registered as a displacement. */
976 # define OFFSET_VALID(displ) \
977 (GC_all_interior_pointers || GC_valid_offsets[displ])
978 char _modws_valid_offsets[sizeof(word)];
979 /* GC_valid_offsets[i] ==> */
980 /* GC_modws_valid_offsets[i%sizeof(word)] */
981 # ifdef STUBBORN_ALLOC
982 page_hash_table _changed_pages;
983 /* Stubborn object pages that were changes since last call to */
984 /* GC_read_changed. */
985 page_hash_table _prev_changed_pages;
986 /* Stubborn object pages that were changes before last call to */
987 /* GC_read_changed. */
989 # if defined(PROC_VDB) || defined(MPROTECT_VDB)
990 page_hash_table _grungy_pages; /* Pages that were dirty at last */
994 VOLATILE page_hash_table _dirty_pages;
995 /* Pages dirtied since last GC_read_dirty. */
998 page_hash_table _written_pages; /* Pages ever dirtied */
1000 # ifdef LARGE_CONFIG
1001 # if CPP_WORDSZ > 32
1002 # define MAX_HEAP_SECTS 4096 /* overflows at roughly 64 GB */
1004 # define MAX_HEAP_SECTS 768 /* Separately added heap sections. */
1007 # ifdef SMALL_CONFIG
1008 # define MAX_HEAP_SECTS 128 /* Roughly 1GB */
1010 # define MAX_HEAP_SECTS 384 /* Roughly 3GB */
1014 ptr_t hs_start; word hs_bytes;
1015 } _heap_sects[MAX_HEAP_SECTS];
1016 # if defined(MSWIN32) || defined(MSWINCE)
1017 ptr_t _heap_bases[MAX_HEAP_SECTS];
1018 /* Start address of memory regions obtained from kernel. */
1021 word _heap_lengths[MAX_HEAP_SECTS];
1022 /* Commited lengths of memory regions obtained from kernel. */
1024 struct roots _static_roots[MAX_ROOT_SETS];
1025 # if !defined(MSWIN32) && !defined(MSWINCE)
1026 struct roots * _root_index[RT_SIZE];
1028 struct exclusion _excl_table[MAX_EXCLUSIONS];
1029 /* Block header index; see gc_headers.h */
1030 bottom_index * _all_nils;
1031 bottom_index * _top_index [TOP_SZ];
1032 #ifdef SAVE_CALL_CHAIN
1033 struct callinfo _last_stack[NFRAMES]; /* Stack at last garbage collection.*/
1034 /* Useful for debugging mysterious */
1035 /* object disappearances. */
1036 /* In the multithreaded case, we */
1037 /* currently only save the calling */
1042 GC_API GC_FAR struct _GC_arrays GC_arrays;
1044 # ifndef SEPARATE_GLOBALS
1045 # define GC_objfreelist GC_arrays._objfreelist
1046 # define GC_aobjfreelist GC_arrays._aobjfreelist
1047 # define GC_words_allocd GC_arrays._words_allocd
1049 # define GC_uobjfreelist GC_arrays._uobjfreelist
1050 # ifdef ATOMIC_UNCOLLECTABLE
1051 # define GC_auobjfreelist GC_arrays._auobjfreelist
1053 # define GC_sobjfreelist GC_arrays._sobjfreelist
1054 # define GC_valid_offsets GC_arrays._valid_offsets
1055 # define GC_modws_valid_offsets GC_arrays._modws_valid_offsets
1056 # ifdef STUBBORN_ALLOC
1057 # define GC_changed_pages GC_arrays._changed_pages
1058 # define GC_prev_changed_pages GC_arrays._prev_changed_pages
1060 # define GC_obj_map GC_arrays._obj_map
1061 # define GC_last_heap_addr GC_arrays._last_heap_addr
1062 # define GC_prev_heap_addr GC_arrays._prev_heap_addr
1063 # define GC_words_wasted GC_arrays._words_wasted
1064 # define GC_large_free_bytes GC_arrays._large_free_bytes
1065 # define GC_large_allocd_bytes GC_arrays._large_allocd_bytes
1066 # define GC_max_large_allocd_bytes GC_arrays._max_large_allocd_bytes
1067 # define GC_words_finalized GC_arrays._words_finalized
1068 # define GC_non_gc_bytes_at_gc GC_arrays._non_gc_bytes_at_gc
1069 # define GC_mem_freed GC_arrays._mem_freed
1070 # define GC_scratch_end_ptr GC_arrays._scratch_end_ptr
1071 # define GC_scratch_last_end_ptr GC_arrays._scratch_last_end_ptr
1072 # define GC_mark_procs GC_arrays._mark_procs
1073 # define GC_heapsize GC_arrays._heapsize
1074 # define GC_max_heapsize GC_arrays._max_heapsize
1075 # define GC_requested_heapsize GC_arrays._requested_heapsize
1076 # define GC_words_allocd_before_gc GC_arrays._words_allocd_before_gc
1077 # define GC_heap_sects GC_arrays._heap_sects
1078 # define GC_last_stack GC_arrays._last_stack
1080 # define GC_unmapped_bytes GC_arrays._unmapped_bytes
1082 # if defined(MSWIN32) || defined(MSWINCE)
1083 # define GC_heap_bases GC_arrays._heap_bases
1086 # define GC_heap_lengths GC_arrays._heap_lengths
1088 # define GC_static_roots GC_arrays._static_roots
1089 # define GC_root_index GC_arrays._root_index
1090 # define GC_excl_table GC_arrays._excl_table
1091 # define GC_all_nils GC_arrays._all_nils
1092 # define GC_top_index GC_arrays._top_index
1093 # if defined(PROC_VDB) || defined(MPROTECT_VDB)
1094 # define GC_grungy_pages GC_arrays._grungy_pages
1096 # ifdef MPROTECT_VDB
1097 # define GC_dirty_pages GC_arrays._dirty_pages
1100 # define GC_written_pages GC_arrays._written_pages
1103 # define GC_composite_in_use GC_arrays._composite_in_use
1104 # define GC_atomic_in_use GC_arrays._atomic_in_use
1107 # define GC_size_map GC_arrays._size_map
1110 # define beginGC_arrays ((ptr_t)(&GC_arrays))
1111 # define endGC_arrays (((ptr_t)(&GC_arrays)) + (sizeof GC_arrays))
1113 #define USED_HEAP_SIZE (GC_heapsize - GC_large_free_bytes)
1116 # define MAXOBJKINDS 16
1118 extern struct obj_kind {
1119 ptr_t *ok_freelist; /* Array of free listheaders for this kind of object */
1120 /* Point either to GC_arrays or to storage allocated */
1121 /* with GC_scratch_alloc. */
1122 struct hblk **ok_reclaim_list;
1123 /* List headers for lists of blocks waiting to be */
1125 word ok_descriptor; /* Descriptor template for objects in this */
1127 GC_bool ok_relocate_descr;
1128 /* Add object size in bytes to descriptor */
1129 /* template to obtain descriptor. Otherwise */
1130 /* template is used as is. */
1131 GC_bool ok_init; /* Clear objects before putting them on the free list. */
1132 } GC_obj_kinds[MAXOBJKINDS];
1134 # define beginGC_obj_kinds ((ptr_t)(&GC_obj_kinds))
1135 # define endGC_obj_kinds (beginGC_obj_kinds + (sizeof GC_obj_kinds))
1137 /* Variables that used to be in GC_arrays, but need to be accessed by */
1138 /* inline allocation code. If they were in GC_arrays, the inlined */
1139 /* allocation code would include GC_arrays offsets (as it did), which */
1140 /* introduce maintenance problems. */
1142 #ifdef SEPARATE_GLOBALS
1143 word GC_words_allocd;
1144 /* Number of words allocated during this collection cycle */
1145 ptr_t GC_objfreelist[MAXOBJSZ+1];
1146 /* free list for NORMAL objects */
1147 # define beginGC_objfreelist ((ptr_t)(&GC_objfreelist))
1148 # define endGC_objfreelist (beginGC_objfreelist + sizeof(GC_objfreelist))
1150 ptr_t GC_aobjfreelist[MAXOBJSZ+1];
1151 /* free list for atomic (PTRFREE) objs */
1152 # define beginGC_aobjfreelist ((ptr_t)(&GC_aobjfreelist))
1153 # define endGC_aobjfreelist (beginGC_aobjfreelist + sizeof(GC_aobjfreelist))
1156 /* Predefined kinds: */
1159 # define UNCOLLECTABLE 2
1160 # ifdef ATOMIC_UNCOLLECTABLE
1161 # define AUNCOLLECTABLE 3
1163 # define IS_UNCOLLECTABLE(k) (((k) & ~1) == UNCOLLECTABLE)
1166 # define IS_UNCOLLECTABLE(k) ((k) == UNCOLLECTABLE)
1169 extern int GC_n_kinds;
1171 GC_API word GC_fo_entries;
1173 extern word GC_n_heap_sects; /* Number of separately added heap */
1176 extern word GC_page_size;
1178 # if defined(MSWIN32) || defined(MSWINCE)
1179 struct _SYSTEM_INFO;
1180 extern struct _SYSTEM_INFO GC_sysinfo;
1181 extern word GC_n_heap_bases; /* See GC_heap_bases. */
1184 extern word GC_total_stack_black_listed;
1185 /* Number of bytes on stack blacklist. */
1187 extern word GC_black_list_spacing;
1188 /* Average number of bytes between blacklisted */
1189 /* blocks. Approximate. */
1190 /* Counts only blocks that are */
1191 /* "stack-blacklisted", i.e. that are */
1192 /* problematic in the interior of an object. */
1194 extern map_entry_type * GC_invalid_map;
1195 /* Pointer to the nowhere valid hblk map */
1196 /* Blocks pointing to this map are free. */
1198 extern struct hblk * GC_hblkfreelist[];
1199 /* List of completely empty heap blocks */
1200 /* Linked through hb_next field of */
1201 /* header structure associated with */
1204 extern GC_bool GC_is_initialized; /* GC_init() has been run. */
1206 extern GC_bool GC_objects_are_marked; /* There are marked objects in */
1209 #ifndef SMALL_CONFIG
1210 extern GC_bool GC_incremental;
1211 /* Using incremental/generational collection. */
1213 # define GC_incremental FALSE
1214 /* Hopefully allow optimizer to remove some code. */
1217 extern GC_bool GC_dirty_maintained;
1218 /* Dirty bits are being maintained, */
1219 /* either for incremental collection, */
1220 /* or to limit the root set. */
1222 extern word GC_root_size; /* Total size of registered root sections */
1224 extern GC_bool GC_debugging_started; /* GC_debug_malloc has been called. */
1226 extern long GC_large_alloc_warn_interval;
1227 /* Interval between unsuppressed warnings. */
1229 extern long GC_large_alloc_warn_suppressed;
1230 /* Number of warnings suppressed so far. */
1234 # define abs(x) ((x) < 0? (-(x)) : (x))
1238 /* Marks are in a reserved area in */
1239 /* each heap block. Each word has one mark bit associated */
1240 /* with it. Only those corresponding to the beginning of an */
1241 /* object are used. */
1243 /* Set mark bit correctly, even if mark bits may be concurrently */
1245 #ifdef PARALLEL_MARK
1246 # define OR_WORD(addr, bits) \
1249 old = *((volatile word *)addr); \
1250 } while (!GC_compare_and_exchange((addr), old, old | (bits))); \
1252 # define OR_WORD_EXIT_IF_SET(addr, bits, exit_label) \
1254 word my_bits = (bits); \
1256 old = *((volatile word *)addr); \
1257 if (old & my_bits) goto exit_label; \
1258 } while (!GC_compare_and_exchange((addr), old, old | my_bits)); \
1261 # define OR_WORD(addr, bits) *(addr) |= (bits)
1262 # define OR_WORD_EXIT_IF_SET(addr, bits, exit_label) \
1264 word old = *(addr); \
1265 word my_bits = (bits); \
1266 if (old & my_bits) goto exit_label; \
1267 *(addr) = (old | my_bits); \
1271 /* Mark bit operations */
1274 * Retrieve, set, clear the mark bit corresponding
1275 * to the nth word in a given heap block.
1277 * (Recall that bit n corresponds to object beginning at word n
1278 * relative to the beginning of the block, including unused words)
1281 #ifdef USE_MARK_BYTES
1282 # define mark_bit_from_hdr(hhdr,n) ((hhdr)->hb_marks[(n) >> 1])
1283 # define set_mark_bit_from_hdr(hhdr,n) ((hhdr)->hb_marks[(n)>>1]) = 1
1284 # define clear_mark_bit_from_hdr(hhdr,n) ((hhdr)->hb_marks[(n)>>1]) = 0
1285 #else /* !USE_MARK_BYTES */
1286 # define mark_bit_from_hdr(hhdr,n) (((hhdr)->hb_marks[divWORDSZ(n)] \
1287 >> (modWORDSZ(n))) & (word)1)
1288 # define set_mark_bit_from_hdr(hhdr,n) \
1289 OR_WORD((hhdr)->hb_marks+divWORDSZ(n), \
1290 (word)1 << modWORDSZ(n))
1291 # define clear_mark_bit_from_hdr(hhdr,n) (hhdr)->hb_marks[divWORDSZ(n)] \
1292 &= ~((word)1 << modWORDSZ(n))
1293 #endif /* !USE_MARK_BYTES */
1295 /* Important internal collector routines */
1297 ptr_t GC_approx_sp GC_PROTO((void));
1299 GC_bool GC_should_collect GC_PROTO((void));
1301 void GC_apply_to_all_blocks GC_PROTO(( \
1302 void (*fn) GC_PROTO((struct hblk *h, word client_data)), \
1304 /* Invoke fn(hbp, client_data) for each */
1305 /* allocated heap block. */
1306 struct hblk * GC_next_used_block GC_PROTO((struct hblk * h));
1307 /* Return first in-use block >= h */
1308 struct hblk * GC_prev_block GC_PROTO((struct hblk * h));
1309 /* Return last block <= h. Returned block */
1310 /* is managed by GC, but may or may not be in */
1312 void GC_mark_init GC_PROTO((void));
1313 void GC_clear_marks GC_PROTO((void)); /* Clear mark bits for all heap objects. */
1314 void GC_invalidate_mark_state GC_PROTO((void));
1315 /* Tell the marker that marked */
1316 /* objects may point to unmarked */
1317 /* ones, and roots may point to */
1318 /* unmarked objects. */
1319 /* Reset mark stack. */
1320 GC_bool GC_mark_stack_empty GC_PROTO((void));
1321 GC_bool GC_mark_some GC_PROTO((ptr_t cold_gc_frame));
1322 /* Perform about one pages worth of marking */
1323 /* work of whatever kind is needed. Returns */
1324 /* quickly if no collection is in progress. */
1325 /* Return TRUE if mark phase finished. */
1326 void GC_initiate_gc GC_PROTO((void));
1327 /* initiate collection. */
1328 /* If the mark state is invalid, this */
1329 /* becomes full colleection. Otherwise */
1331 void GC_push_all GC_PROTO((ptr_t bottom, ptr_t top));
1332 /* Push everything in a range */
1333 /* onto mark stack. */
1334 void GC_push_selected GC_PROTO(( \
1337 int (*dirty_fn) GC_PROTO((struct hblk *h)), \
1338 void (*push_fn) GC_PROTO((ptr_t bottom, ptr_t top)) ));
1339 /* Push all pages h in [b,t) s.t. */
1340 /* select_fn(h) != 0 onto mark stack. */
1341 #ifndef SMALL_CONFIG
1342 void GC_push_conditional GC_PROTO((ptr_t b, ptr_t t, GC_bool all));
1344 # define GC_push_conditional(b, t, all) GC_push_all(b, t)
1346 /* Do either of the above, depending */
1347 /* on the third arg. */
1348 void GC_push_all_stack GC_PROTO((ptr_t b, ptr_t t));
1349 /* As above, but consider */
1350 /* interior pointers as valid */
1351 void GC_push_all_eager GC_PROTO((ptr_t b, ptr_t t));
1352 /* Same as GC_push_all_stack, but */
1353 /* ensures that stack is scanned */
1354 /* immediately, not just scheduled */
1357 void GC_push_all_stack_partially_eager GC_PROTO(( \
1358 ptr_t bottom, ptr_t top, ptr_t cold_gc_frame ));
1359 /* Similar to GC_push_all_eager, but only the */
1360 /* part hotter than cold_gc_frame is scanned */
1361 /* immediately. Needed to ensure that callee- */
1362 /* save registers are not missed. */
1364 /* In the threads case, we push part of the current thread stack */
1365 /* with GC_push_all_eager when we push the registers. This gets the */
1366 /* callee-save registers that may disappear. The remainder of the */
1367 /* stacks are scheduled for scanning in *GC_push_other_roots, which */
1368 /* is thread-package-specific. */
1370 void GC_push_current_stack GC_PROTO((ptr_t cold_gc_frame));
1371 /* Push enough of the current stack eagerly to */
1372 /* ensure that callee-save registers saved in */
1373 /* GC frames are scanned. */
1374 /* In the non-threads case, schedule entire */
1375 /* stack for scanning. */
1376 void GC_push_roots GC_PROTO((GC_bool all, ptr_t cold_gc_frame));
1377 /* Push all or dirty roots. */
1378 extern void (*GC_push_other_roots) GC_PROTO((void));
1379 /* Push system or application specific roots */
1380 /* onto the mark stack. In some environments */
1381 /* (e.g. threads environments) this is */
1382 /* predfined to be non-zero. A client supplied */
1383 /* replacement should also call the original */
1385 extern void GC_push_gc_structures GC_PROTO((void));
1386 /* Push GC internal roots. These are normally */
1387 /* included in the static data segment, and */
1388 /* Thus implicitly pushed. But we must do this */
1389 /* explicitly if normal root processing is */
1390 /* disabled. Calls the following: */
1391 extern void GC_push_finalizer_structures GC_PROTO((void));
1392 extern void GC_push_stubborn_structures GC_PROTO((void));
1394 extern void GC_push_thread_structures GC_PROTO((void));
1396 extern void (*GC_start_call_back) GC_PROTO((void));
1397 /* Called at start of full collections. */
1398 /* Not called if 0. Called with allocation */
1401 # if defined(USE_GENERIC_PUSH_REGS)
1402 void GC_generic_push_regs GC_PROTO((ptr_t cold_gc_frame));
1404 void GC_push_regs GC_PROTO((void));
1406 /* Push register contents onto mark stack. */
1407 /* If NURSERY is defined, the default push */
1408 /* action can be overridden with GC_push_proc */
1411 extern void (*GC_push_proc)(ptr_t);
1413 # if defined(MSWIN32) || defined(MSWINCE)
1414 void __cdecl GC_push_one GC_PROTO((word p));
1416 void GC_push_one GC_PROTO((word p));
1417 /* If p points to an object, mark it */
1418 /* and push contents on the mark stack */
1419 /* Pointer recognition test always */
1420 /* accepts interior pointers, i.e. this */
1421 /* is appropriate for pointers found on */
1424 # if defined(PRINT_BLACK_LIST) || defined(KEEP_BACK_PTRS)
1425 void GC_mark_and_push_stack GC_PROTO((word p, ptr_t source));
1426 /* Ditto, omits plausibility test */
1428 void GC_mark_and_push_stack GC_PROTO((word p));
1430 void GC_push_marked GC_PROTO((struct hblk * h, hdr * hhdr));
1431 /* Push contents of all marked objects in h onto */
1434 # define GC_push_next_marked_dirty(h) GC_push_next_marked(h)
1436 struct hblk * GC_push_next_marked_dirty GC_PROTO((struct hblk * h));
1437 /* Invoke GC_push_marked on next dirty block above h. */
1438 /* Return a pointer just past the end of this block. */
1439 #endif /* !SMALL_CONFIG */
1440 struct hblk * GC_push_next_marked GC_PROTO((struct hblk * h));
1441 /* Ditto, but also mark from clean pages. */
1442 struct hblk * GC_push_next_marked_uncollectable GC_PROTO((struct hblk * h));
1443 /* Ditto, but mark only from uncollectable pages. */
1444 GC_bool GC_stopped_mark GC_PROTO((GC_stop_func stop_func));
1445 /* Stop world and mark from all roots */
1447 void GC_clear_hdr_marks GC_PROTO((hdr * hhdr));
1448 /* Clear the mark bits in a header */
1449 void GC_set_hdr_marks GC_PROTO((hdr * hhdr));
1450 /* Set the mark bits in a header */
1451 void GC_set_fl_marks GC_PROTO((ptr_t p));
1452 /* Set all mark bits associated with */
1454 void GC_add_roots_inner GC_PROTO((char * b, char * e, GC_bool tmp));
1455 GC_bool GC_is_static_root GC_PROTO((ptr_t p));
1456 /* Is the address p in one of the registered static */
1457 /* root sections? */
1458 # if defined(MSWIN32) || defined(_WIN32_WCE_EMULATION)
1459 GC_bool GC_is_tmp_root GC_PROTO((ptr_t p));
1460 /* Is the address p in one of the temporary static */
1461 /* root sections? */
1463 void GC_register_dynamic_libraries GC_PROTO((void));
1464 /* Add dynamic library data sections to the root set. */
1466 GC_bool GC_register_main_static_data GC_PROTO((void));
1467 /* We need to register the main data segment. Returns */
1468 /* TRUE unless this is done implicitly as part of */
1469 /* dynamic library registration. */
1471 /* Machine dependent startup routines */
1472 ptr_t GC_get_stack_base GC_PROTO((void)); /* Cold end of stack */
1474 ptr_t GC_get_register_stack_base GC_PROTO((void));
1475 /* Cold end of register stack. */
1477 void GC_register_data_segments GC_PROTO((void));
1479 /* Black listing: */
1480 void GC_bl_init GC_PROTO((void));
1481 # ifdef PRINT_BLACK_LIST
1482 void GC_add_to_black_list_normal GC_PROTO((word p, ptr_t source));
1483 /* Register bits as a possible future false */
1484 /* reference from the heap or static data */
1485 # define GC_ADD_TO_BLACK_LIST_NORMAL(bits, source) \
1486 if (GC_all_interior_pointers) { \
1487 GC_add_to_black_list_stack(bits, (ptr_t)(source)); \
1489 GC_add_to_black_list_normal(bits, (ptr_t)(source)); \
1492 void GC_add_to_black_list_normal GC_PROTO((word p));
1493 # define GC_ADD_TO_BLACK_LIST_NORMAL(bits, source) \
1494 if (GC_all_interior_pointers) { \
1495 GC_add_to_black_list_stack(bits); \
1497 GC_add_to_black_list_normal(bits); \
1501 # ifdef PRINT_BLACK_LIST
1502 void GC_add_to_black_list_stack GC_PROTO((word p, ptr_t source));
1504 void GC_add_to_black_list_stack GC_PROTO((word p));
1506 struct hblk * GC_is_black_listed GC_PROTO((struct hblk * h, word len));
1507 /* If there are likely to be false references */
1508 /* to a block starting at h of the indicated */
1509 /* length, then return the next plausible */
1510 /* starting location for h that might avoid */
1511 /* these false references. */
1512 void GC_promote_black_lists GC_PROTO((void));
1513 /* Declare an end to a black listing phase. */
1514 void GC_unpromote_black_lists GC_PROTO((void));
1515 /* Approximately undo the effect of the above. */
1516 /* This actually loses some information, but */
1517 /* only in a reasonably safe way. */
1518 word GC_number_stack_black_listed GC_PROTO(( \
1519 struct hblk *start, struct hblk *endp1));
1520 /* Return the number of (stack) blacklisted */
1521 /* blocks in the range for statistical */
1524 ptr_t GC_scratch_alloc GC_PROTO((word bytes));
1525 /* GC internal memory allocation for */
1526 /* small objects. Deallocation is not */
1529 /* Heap block layout maps: */
1530 void GC_invalidate_map GC_PROTO((hdr * hhdr));
1531 /* Remove the object map associated */
1532 /* with the block. This identifies */
1533 /* the block as invalid to the mark */
1535 GC_bool GC_add_map_entry GC_PROTO((word sz));
1536 /* Add a heap block map for objects of */
1537 /* size sz to obj_map. */
1538 /* Return FALSE on failure. */
1539 void GC_register_displacement_inner GC_PROTO((word offset));
1540 /* Version of GC_register_displacement */
1541 /* that assumes lock is already held */
1542 /* and signals are already disabled. */
1544 /* hblk allocation: */
1545 void GC_new_hblk GC_PROTO((word size_in_words, int kind));
1546 /* Allocate a new heap block, and build */
1547 /* a free list in it. */
1549 ptr_t GC_build_fl GC_PROTO((struct hblk *h, word sz,
1550 GC_bool clear, ptr_t list));
1551 /* Build a free list for objects of */
1552 /* size sz in block h. Append list to */
1553 /* end of the free lists. Possibly */
1554 /* clear objects on the list. Normally */
1555 /* called by GC_new_hblk, but also */
1556 /* called explicitly without GC lock. */
1558 struct hblk * GC_allochblk GC_PROTO(( \
1559 word size_in_words, int kind, unsigned flags));
1560 /* Allocate a heap block, inform */
1561 /* the marker that block is valid */
1562 /* for objects of indicated size. */
1564 ptr_t GC_alloc_large GC_PROTO((word lw, int k, unsigned flags));
1565 /* Allocate a large block of size lw words. */
1566 /* The block is not cleared. */
1567 /* Flags is 0 or IGNORE_OFF_PAGE. */
1568 /* Calls GC_allchblk to do the actual */
1569 /* allocation, but also triggers GC and/or */
1570 /* heap expansion as appropriate. */
1571 /* Does not update GC_words_allocd, but does */
1572 /* other accounting. */
1574 ptr_t GC_alloc_large_and_clear GC_PROTO((word lw, int k, unsigned flags));
1575 /* As above, but clear block if appropriate */
1578 void GC_freehblk GC_PROTO((struct hblk * p));
1579 /* Deallocate a heap block and mark it */
1583 void GC_init_inner GC_PROTO((void));
1584 GC_bool GC_expand_hp_inner GC_PROTO((word n));
1585 void GC_start_reclaim GC_PROTO((int abort_if_found));
1586 /* Restore unmarked objects to free */
1587 /* lists, or (if abort_if_found is */
1588 /* TRUE) report them. */
1589 /* Sweeping of small object pages is */
1590 /* largely deferred. */
1591 void GC_continue_reclaim GC_PROTO((word sz, int kind));
1592 /* Sweep pages of the given size and */
1593 /* kind, as long as possible, and */
1594 /* as long as the corr. free list is */
1596 void GC_reclaim_or_delete_all GC_PROTO((void));
1597 /* Arrange for all reclaim lists to be */
1598 /* empty. Judiciously choose between */
1599 /* sweeping and discarding each page. */
1600 GC_bool GC_reclaim_all GC_PROTO((GC_stop_func stop_func, GC_bool ignore_old));
1601 /* Reclaim all blocks. Abort (in a */
1602 /* consistent state) if f returns TRUE. */
1603 GC_bool GC_block_empty GC_PROTO((hdr * hhdr));
1604 /* Block completely unmarked? */
1605 GC_bool GC_never_stop_func GC_PROTO((void));
1606 /* Returns FALSE. */
1607 GC_bool GC_try_to_collect_inner GC_PROTO((GC_stop_func f));
1609 /* Collect; caller must have acquired */
1610 /* lock and disabled signals. */
1611 /* Collection is aborted if f returns */
1612 /* TRUE. Returns TRUE if it completes */
1614 # define GC_gcollect_inner() \
1615 (void) GC_try_to_collect_inner(GC_never_stop_func)
1616 void GC_finish_collection GC_PROTO((void));
1617 /* Finish collection. Mark bits are */
1618 /* consistent and lock is still held. */
1619 GC_bool GC_collect_or_expand GC_PROTO(( \
1620 word needed_blocks, GC_bool ignore_off_page));
1621 /* Collect or expand heap in an attempt */
1622 /* make the indicated number of free */
1623 /* blocks available. Should be called */
1624 /* until the blocks are available or */
1625 /* until it fails by returning FALSE. */
1627 #if defined(MSWIN32) || defined(MSWINCE)
1628 void GC_deinit GC_PROTO((void));
1629 /* Free any resources allocated by */
1633 void GC_collect_a_little_inner GC_PROTO((int n));
1634 /* Do n units worth of garbage */
1635 /* collection work, if appropriate. */
1636 /* A unit is an amount appropriate for */
1637 /* HBLKSIZE bytes of allocation. */
1638 ptr_t GC_generic_malloc GC_PROTO((word lb, int k));
1639 /* Allocate an object of the given */
1640 /* kind. By default, there are only */
1641 /* a few kinds: composite(pointerfree), */
1642 /* atomic, uncollectable, etc. */
1643 /* We claim it's possible for clever */
1644 /* client code that understands GC */
1645 /* internals to add more, e.g. to */
1646 /* communicate object layout info */
1647 /* to the collector. */
1648 ptr_t GC_generic_malloc_ignore_off_page GC_PROTO((size_t b, int k));
1649 /* As above, but pointers past the */
1650 /* first page of the resulting object */
1652 ptr_t GC_generic_malloc_inner GC_PROTO((word lb, int k));
1653 /* Ditto, but I already hold lock, etc. */
1654 ptr_t GC_generic_malloc_words_small GC_PROTO((size_t lw, int k));
1655 /* As above, but size in units of words */
1656 /* Bypasses MERGE_SIZES. Assumes */
1657 /* words <= MAXOBJSZ. */
1658 ptr_t GC_generic_malloc_inner_ignore_off_page GC_PROTO((size_t lb, int k));
1659 /* Allocate an object, where */
1660 /* the client guarantees that there */
1661 /* will always be a pointer to the */
1662 /* beginning of the object while the */
1663 /* object is live. */
1664 ptr_t GC_allocobj GC_PROTO((word sz, int kind));
1665 /* Make the indicated */
1666 /* free list nonempty, and return its */
1669 void GC_init_headers GC_PROTO((void));
1670 struct hblkhdr * GC_install_header GC_PROTO((struct hblk *h));
1671 /* Install a header for block h. */
1672 /* Return 0 on failure, or the header */
1674 GC_bool GC_install_counts GC_PROTO((struct hblk * h, word sz));
1675 /* Set up forwarding counts for block */
1677 /* Return FALSE on failure. */
1678 void GC_remove_header GC_PROTO((struct hblk * h));
1679 /* Remove the header for block h. */
1680 void GC_remove_counts GC_PROTO((struct hblk * h, word sz));
1681 /* Remove forwarding counts for h. */
1682 hdr * GC_find_header GC_PROTO((ptr_t h)); /* Debugging only. */
1684 void GC_finalize GC_PROTO((void));
1685 /* Perform all indicated finalization actions */
1686 /* on unmarked objects. */
1687 /* Unreachable finalizable objects are enqueued */
1688 /* for processing by GC_invoke_finalizers. */
1689 /* Invoked with lock. */
1691 void GC_notify_or_invoke_finalizers GC_PROTO((void));
1692 /* If GC_finalize_on_demand is not set, invoke */
1693 /* eligible finalizers. Otherwise: */
1694 /* Call *GC_finalizer_notifier if there are */
1695 /* finalizers to be run, and we haven't called */
1696 /* this procedure yet this GC cycle. */
1698 void GC_add_to_heap GC_PROTO((struct hblk *p, word bytes));
1699 /* Add a HBLKSIZE aligned chunk to the heap. */
1701 void GC_print_obj GC_PROTO((ptr_t p));
1702 /* P points to somewhere inside an object with */
1703 /* debugging info. Print a human readable */
1704 /* description of the object to stderr. */
1705 extern void (*GC_check_heap) GC_PROTO((void));
1706 /* Check that all objects in the heap with */
1707 /* debugging info are intact. Print */
1708 /* descriptions of any that are not. */
1709 extern void (*GC_print_heap_obj) GC_PROTO((ptr_t p));
1710 /* If possible print s followed by a more */
1711 /* detailed description of the object */
1712 /* referred to by p. */
1714 extern GC_bool GC_print_stats; /* Produce at least some logging output */
1715 /* Set from environment variable. */
1717 /* Macros used for collector internal allocation. */
1718 /* These assume the collector lock is held. */
1720 extern GC_PTR GC_debug_generic_malloc_inner(size_t lb, int k);
1721 extern GC_PTR GC_debug_generic_malloc_inner_ignore_off_page(size_t lb,
1723 # define GC_INTERNAL_MALLOC GC_debug_generic_malloc_inner
1724 # define GC_INTERNAL_MALLOC_IGNORE_OFF_PAGE \
1725 GC_debug_generic_malloc_inner_ignore_off_page
1727 # define GC_INTERNAL_FREE GC_debug_free_inner
1729 # define GC_INTERNAL_FREE GC_debug_free
1732 # define GC_INTERNAL_MALLOC GC_generic_malloc_inner
1733 # define GC_INTERNAL_MALLOC_IGNORE_OFF_PAGE \
1734 GC_generic_malloc_inner_ignore_off_page
1736 # define GC_INTERNAL_FREE GC_free_inner
1738 # define GC_INTERNAL_FREE GC_free
1742 /* Memory unmapping: */
1744 void GC_unmap_old(void);
1745 void GC_merge_unmapped(void);
1746 void GC_unmap(ptr_t start, word bytes);
1747 void GC_remap(ptr_t start, word bytes);
1748 void GC_unmap_gap(ptr_t start1, word bytes1, ptr_t start2, word bytes2);
1751 /* Virtual dirty bit implementation: */
1752 /* Each implementation exports the following: */
1753 void GC_read_dirty GC_PROTO((void));
1754 /* Retrieve dirty bits. */
1755 GC_bool GC_page_was_dirty GC_PROTO((struct hblk *h));
1756 /* Read retrieved dirty bits. */
1757 GC_bool GC_page_was_ever_dirty GC_PROTO((struct hblk *h));
1758 /* Could the page contain valid heap pointers? */
1759 void GC_is_fresh GC_PROTO((struct hblk *h, word n));
1760 /* Assert the region currently contains no */
1761 /* valid pointers. */
1762 void GC_remove_protection GC_PROTO((struct hblk *h, word nblocks,
1763 GC_bool pointerfree));
1764 /* h is about to be writteni or allocated. Ensure */
1765 /* that it's not write protected by the virtual */
1766 /* dirty bit implementation. */
1768 void GC_dirty_init GC_PROTO((void));
1770 /* Slow/general mark bit manipulation: */
1771 GC_API GC_bool GC_is_marked GC_PROTO((ptr_t p));
1772 void GC_clear_mark_bit GC_PROTO((ptr_t p));
1773 void GC_set_mark_bit GC_PROTO((ptr_t p));
1775 /* Stubborn objects: */
1776 void GC_read_changed GC_PROTO((void)); /* Analogous to GC_read_dirty */
1777 GC_bool GC_page_was_changed GC_PROTO((struct hblk * h));
1778 /* Analogous to GC_page_was_dirty */
1779 void GC_clean_changing_list GC_PROTO((void));
1780 /* Collect obsolete changing list entries */
1781 void GC_stubborn_init GC_PROTO((void));
1783 /* Debugging print routines: */
1784 void GC_print_block_list GC_PROTO((void));
1785 void GC_print_hblkfreelist GC_PROTO((void));
1786 void GC_print_heap_sects GC_PROTO((void));
1787 void GC_print_static_roots GC_PROTO((void));
1788 void GC_dump GC_PROTO((void));
1790 #ifdef KEEP_BACK_PTRS
1791 void GC_store_back_pointer(ptr_t source, ptr_t dest);
1792 void GC_marked_for_finalization(ptr_t dest);
1793 # define GC_STORE_BACK_PTR(source, dest) GC_store_back_pointer(source, dest)
1794 # define GC_MARKED_FOR_FINALIZATION(dest) GC_marked_for_finalization(dest)
1796 # define GC_STORE_BACK_PTR(source, dest)
1797 # define GC_MARKED_FOR_FINALIZATION(dest)
1800 /* Make arguments appear live to compiler */
1802 void GC_noop(void*, ...);
1805 GC_API void GC_noop(...);
1807 GC_API void GC_noop();
1811 void GC_noop1 GC_PROTO((word));
1813 /* Logging and diagnostic output: */
1814 GC_API void GC_printf GC_PROTO((GC_CONST char * format, long, long, long, long, long, long));
1815 /* A version of printf that doesn't allocate, */
1816 /* is restricted to long arguments, and */
1817 /* (unfortunately) doesn't use varargs for */
1818 /* portability. Restricted to 6 args and */
1819 /* 1K total output length. */
1820 /* (We use sprintf. Hopefully that doesn't */
1821 /* allocate for long arguments.) */
1822 # define GC_printf0(f) GC_printf(f, 0l, 0l, 0l, 0l, 0l, 0l)
1823 # define GC_printf1(f,a) GC_printf(f, (long)a, 0l, 0l, 0l, 0l, 0l)
1824 # define GC_printf2(f,a,b) GC_printf(f, (long)a, (long)b, 0l, 0l, 0l, 0l)
1825 # define GC_printf3(f,a,b,c) GC_printf(f, (long)a, (long)b, (long)c, 0l, 0l, 0l)
1826 # define GC_printf4(f,a,b,c,d) GC_printf(f, (long)a, (long)b, (long)c, \
1828 # define GC_printf5(f,a,b,c,d,e) GC_printf(f, (long)a, (long)b, (long)c, \
1829 (long)d, (long)e, 0l)
1830 # define GC_printf6(f,a,b,c,d,e,g) GC_printf(f, (long)a, (long)b, (long)c, \
1831 (long)d, (long)e, (long)g)
1833 GC_API void GC_err_printf GC_PROTO((GC_CONST char * format, long, long, long, long, long, long));
1834 # define GC_err_printf0(f) GC_err_puts(f)
1835 # define GC_err_printf1(f,a) GC_err_printf(f, (long)a, 0l, 0l, 0l, 0l, 0l)
1836 # define GC_err_printf2(f,a,b) GC_err_printf(f, (long)a, (long)b, 0l, 0l, 0l, 0l)
1837 # define GC_err_printf3(f,a,b,c) GC_err_printf(f, (long)a, (long)b, (long)c, \
1839 # define GC_err_printf4(f,a,b,c,d) GC_err_printf(f, (long)a, (long)b, \
1840 (long)c, (long)d, 0l, 0l)
1841 # define GC_err_printf5(f,a,b,c,d,e) GC_err_printf(f, (long)a, (long)b, \
1844 # define GC_err_printf6(f,a,b,c,d,e,g) GC_err_printf(f, (long)a, (long)b, \
1847 /* Ditto, writes to stderr. */
1849 void GC_err_puts GC_PROTO((GC_CONST char *s));
1850 /* Write s to stderr, don't buffer, don't add */
1851 /* newlines, don't ... */
1853 #if defined(LINUX) && !defined(SMALL_CONFIG)
1854 void GC_err_write GC_PROTO((GC_CONST char *buf, size_t len));
1855 /* Write buf to stderr, don't buffer, don't add */
1856 /* newlines, don't ... */
1860 # ifdef GC_ASSERTIONS
1861 # define GC_ASSERT(expr) if(!(expr)) {\
1862 GC_err_printf2("Assertion failure: %s:%ld\n", \
1863 __FILE__, (unsigned long)__LINE__); \
1864 ABORT("assertion failure"); }
1866 # define GC_ASSERT(expr)
1869 # if defined(PARALLEL_MARK) || defined(THREAD_LOCAL_ALLOC)
1870 /* We need additional synchronization facilities from the thread */
1871 /* support. We believe these are less performance critical */
1872 /* than the main garbage collector lock; standard pthreads-based */
1873 /* implementations should be sufficient. */
1875 /* The mark lock and condition variable. If the GC lock is also */
1876 /* acquired, the GC lock must be acquired first. The mark lock is */
1877 /* used to both protect some variables used by the parallel */
1878 /* marker, and to protect GC_fl_builder_count, below. */
1879 /* GC_notify_all_marker() is called when */
1880 /* the state of the parallel marker changes */
1881 /* in some significant way (see gc_mark.h for details). The */
1882 /* latter set of events includes incrementing GC_mark_no. */
1883 /* GC_notify_all_builder() is called when GC_fl_builder_count */
1886 extern void GC_acquire_mark_lock();
1887 extern void GC_release_mark_lock();
1888 extern void GC_notify_all_builder();
1889 /* extern void GC_wait_builder(); */
1890 extern void GC_wait_for_reclaim();
1892 extern word GC_fl_builder_count; /* Protected by mark lock. */
1893 # endif /* PARALLEL_MARK || THREAD_LOCAL_ALLOC */
1894 # ifdef PARALLEL_MARK
1895 extern void GC_notify_all_marker();
1896 extern void GC_wait_marker();
1897 extern word GC_mark_no; /* Protected by mark lock. */
1899 extern void GC_help_marker(word my_mark_no);
1900 /* Try to help out parallel marker for mark cycle */
1901 /* my_mark_no. Returns if the mark cycle finishes or */
1902 /* was already done, or there was nothing to do for */
1903 /* some other reason. */
1904 # endif /* PARALLEL_MARK */
1906 # if defined(GC_PTHREADS) && !defined(GC_SOLARIS_THREADS)
1907 /* We define the thread suspension signal here, so that we can refer */
1908 /* to it in the dirty bit implementation, if necessary. Ideally we */
1909 /* would allocate a (real-time ?) signal using the standard mechanism.*/
1910 /* unfortunately, there is no standard mechanism. (There is one */
1911 /* in Linux glibc, but it's not exported.) Thus we continue to use */
1912 /* the same hard-coded signals we've always used. */
1913 # if !defined(SIG_SUSPEND)
1914 # if defined(GC_LINUX_THREADS)
1915 # if defined(SPARC) && !defined(SIGPWR)
1916 /* SPARC/Linux doesn't properly define SIGPWR in <signal.h>.
1917 * It is aliased to SIGLOST in asm/signal.h, though. */
1918 # define SIG_SUSPEND SIGLOST
1920 /* Linuxthreads itself uses SIGUSR1 and SIGUSR2. */
1921 # define SIG_SUSPEND SIGPWR
1923 # else /* !GC_LINUX_THREADS */
1924 # if defined(_SIGRTMIN)
1925 # define SIG_SUSPEND _SIGRTMIN + 6
1927 # define SIG_SUSPEND SIGRTMIN + 6
1930 # endif /* !SIG_SUSPEND */
1934 # endif /* GC_PRIVATE_H */