make it compile with g++-3.3
[prop.git] / include / AD / gc / gcconfig.h
bloba93680db2bfcc55be7c68ae5024acf50fd2999c2
1 //////////////////////////////////////////////////////////////////////////////
2 // NOTICE:
3 //
4 // ADLib, Prop and their related set of tools and documentation are in the
5 // public domain. The author(s) of this software reserve no copyrights on
6 // the source code and any code generated using the tools. You are encouraged
7 // to use ADLib and Prop to develop software, in both academic and commercial
8 // settings, and are welcomed to incorporate any part of ADLib and Prop into
9 // your programs.
11 // Although you are under no obligation to do so, we strongly recommend that
12 // you give away all software developed using our tools.
14 // We also ask that credit be given to us when ADLib and/or Prop are used in
15 // your programs, and that this notice be preserved intact in all the source
16 // code.
18 // This software is still under development and we welcome(read crave for)
19 // any suggestions and help from the users.
21 // Allen Leung (leunga@cs.nyu.edu)
22 // 1994-1995
23 //////////////////////////////////////////////////////////////////////////////
25 #ifndef gc_configuration_h
26 #define gc_configuration_h
28 #include <AD/config/config.h>
30 //////////////////////////////////////////////////////////////////////////////
31 // This file is used to customize the garbage collectors. Please
32 // read this through carefully and customize it to suit your platform's
33 // needs.
34 //////////////////////////////////////////////////////////////////////////////
36 //////////////////////////////////////////////////////////////////////////////
37 // Maximum number of garbage collectors instance.
38 // Notice that more than one type of heaps are allowed.
39 //////////////////////////////////////////////////////////////////////////////
40 #define GC_MAX_NUMBER_OF_COLLECTORS 256
42 //////////////////////////////////////////////////////////////////////////////
43 // Size of a *logical* page in bytes. Memory managed by the managers
44 // are partitioned into logical pages. Increasing the page size will
45 // decrease the sizes bookkeeping data structures, but may increase retention.
46 // Page size *MUST* be a power of two but it doesn't have to match the
47 // underlying page size of the VM.
49 // I think 256 bytes is probably too small while something like 4K
50 // is probably too large.
51 //////////////////////////////////////////////////////////////////////////////
52 #define GC_PAGE_SIZE 512
54 //////////////////////////////////////////////////////////////////////////////
55 // Should we use blacklisting to decrease the likehood of
56 // false root identification?
58 // The default is yes.
59 // We'll allow up to ten percentage of all memory to be blacklisted,
60 // or 64K of memory at one time, or 512K total, whichever is lower.
62 //////////////////////////////////////////////////////////////////////////////
63 #define GC_USE_BLACKLISTING
64 #define GC_MIN_BLACKLISTED_PAGES 4
65 #define GC_MAX_BLACKLISTED_PERCENTAGE 10
66 #define GC_MAX_BLACKLISTED_PAGES (65536/GC_PAGE_SIZE)
67 #define GC_MAX_TOTAL_BLACKLISTED_PAGES (512*1024/GC_PAGE_SIZE)
69 //////////////////////////////////////////////////////////////////////////////
70 // Should cross heap pointers be allowed?
71 // The default is yes. If you want to allocate connecting structures
72 // in multiple collectable heaps then this is a must. If you'll only use
73 // one collector at a time then you can safely comment this option
74 // out. The code will be a bit faster.
75 //////////////////////////////////////////////////////////////////////////////
76 #define GC_HAS_CROSS_HEAP_POINTERS
78 //////////////////////////////////////////////////////////////////////////////
79 // Should we try to keep track of garbage collection time?
80 // The default is yes. This is generally a good idea since you may want
81 // to profile the programs during fine-tuning. The timer code should
82 // work on both BSD and System V systems.
83 //////////////////////////////////////////////////////////////////////////////
84 #if defined(PROP_HAS_GETRUSAGE) || defined(PROP_HAS_TIMES)
85 #define GC_USE_TIMER
86 #endif
88 //////////////////////////////////////////////////////////////////////////////
89 // Debugging flag. Off for production use.
90 //////////////////////////////////////////////////////////////////////////////
91 // #define DEBUG_GC
93 //////////////////////////////////////////////////////////////////////////////
94 // Architecture dependent information follows:
96 // GC_ALIGNMENT -- a suitable data alignment in bytes. This is
97 // 8 on most platforms. All data allocated
98 // are guaranteed to satisfy this constraint.
99 // Notice that while decrease this alignment may
100 // decrease the sizes of objects allocated, it
101 // will also increase the sizes of the internal
102 // bitmaps and the times for roots identification,
103 // as more addresses will become candidates.
104 // GC_DATA_START -- a macro to find the start of static data
105 // GC_DATA_END -- a macro to find the end of the static data
107 // GC_GET_HEAP_BOTTOM -- a macro to locate the bottom of the heap
108 // GC_GET_HEAP_TOP -- a macro to locate the top of the heap
110 // Some assumptions that I've made:
112 // 8 bits in a bytes.
113 // 32 bit processor.
114 // 4 byte alignment for pointers.
115 // linear address space.
116 // the static area is contiguous and not expandable during execution.
117 // the heap area is contiguous.
118 // the stack area is contiguous(no spaghetti stack please).
119 // _setjmp() will properly flush the registers onto the stack.
120 //////////////////////////////////////////////////////////////////////////////
122 //////////////////////////////////////////////////////////////////////////////
123 // Configuration for Linux on x86 architectures.
124 // Configuration for Sparc on SUN/OS
125 //////////////////////////////////////////////////////////////////////////////
126 #if defined(linux) || (defined(sparc) && ! defined(__SVR4))
127 # define GC_ALIGNMENT 8 // use 8-byte alignment for our heap
128 extern int etext;
129 extern int end;
130 # define GC_DATA_START (void*)(((unsigned long)(&etext) + 0xfff) & ~0xfff)
131 # define GC_DATA_END (void*)(&end)
132 #include <stdlib.h>
133 #include <unistd.h>
134 //extern "C" void * sbrk(int);
135 # define GC_GET_HEAP_BOTTOM sbrk(0)
136 # define GC_GET_HEAP_TOP sbrk(0)
137 # define GC_CONFIGURED
138 #endif
140 //////////////////////////////////////////////////////////////////////////////
141 // Configuration for Sparc on Solaris 5.*
142 // Paul F. Dietz, 2/26/97
143 //////////////////////////////////////////////////////////////////////////////
144 #if defined(sparc) && defined(__SVR4)
145 # define GC_ALIGNMENT 8 // use 8-byte alignment for our heap
146 extern int etext;
147 extern int end;
150 // The data segment in Solaris Sparc binaries does not start
151 // on the next page after the text segment. The first symbol
152 // in the data segment is apparently _GLOBAL_OFFSET_TABLE.
153 // So, make the first page be the page containing this symbol.
154 // PFD 2/26/97
156 extern int _GLOBAL_OFFSET_TABLE_;
157 # define GC_DATA_START (void*)((unsigned long)(&_GLOBAL_OFFSET_TABLE_)\
158 & ~0xfff)
159 # define GC_DATA_END (void*)(&end)
160 #include <stdlib.h>
161 #include <unistd.h>
162 extern "C" void * sbrk(int);
163 # define GC_GET_HEAP_BOTTOM sbrk(0)
164 # define GC_GET_HEAP_TOP sbrk(0)
165 # define GC_CONFIGURED
166 #endif
168 //////////////////////////////////////////////////////////////////////////////
169 // Default configuration: assume vanilla Unixes.
170 // Caution: I don't know if it'll work!!!!
172 // Please add your own and email any new configurations to
174 // leunga@cs.nyu.edu
176 // It'll be much appreciated.
177 //////////////////////////////////////////////////////////////////////////////
178 #ifndef GC_CONFIGURED
179 struct GC_ALIGNMENT_TYPE { int a; void * b; double c; };
180 #define GC_ALIGNMENT sizeof(GC_ALIGNMENT_TYPE)
181 extern int etext;
182 extern int end;
183 # define GC_DATA_START (void*)(((unsigned long)(&etext) + 0xfff) & ~0xfff)
184 # define GC_DATA_END (void*)(&end)
185 #include <stdlib.h>
186 #include <unistd.h>
187 extern "C" void * sbrk(int);
188 # define GC_GET_HEAP_BOTTOM sbrk(0)
189 # define GC_GET_HEAP_TOP sbrk(0)
190 #endif
192 #endif