]>
Commit | Line | Data |
---|---|---|
70f72767 TT |
1 | /* |
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 by Silicon Graphics. All rights reserved. | |
abdbd4a8 | 5 | * Copyright (c) 2000 by Hewlett-Packard Company. All rights reserved. |
70f72767 TT |
6 | * |
7 | * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED | |
8 | * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. | |
9 | * | |
10 | * Permission is hereby granted to use or copy this program | |
11 | * for any purpose, provided the above notices are retained on all copies. | |
12 | * Permission to modify the code and to distribute modified code is granted, | |
13 | * provided the above notices are retained, and a notice that the code was | |
14 | * modified is included with the above copyright notice. | |
15 | */ | |
16 | ||
56293c2b | 17 | #ifndef GCCONFIG_H |
70f72767 | 18 | |
56293c2b | 19 | # define GCCONFIG_H |
70f72767 TT |
20 | |
21 | /* Machine dependent parameters. Some tuning parameters can be found */ | |
22 | /* near the top of gc_private.h. */ | |
23 | ||
24 | /* Machine specific parts contributed by various people. See README file. */ | |
25 | ||
26 | /* First a unified test for Linux: */ | |
27 | # if defined(linux) || defined(__linux__) | |
28 | # define LINUX | |
29 | # endif | |
30 | ||
abdbd4a8 BM |
31 | /* And one for NetBSD: */ |
32 | # if defined(__NetBSD__) | |
33 | # define NETBSD | |
34 | # endif | |
35 | ||
4c7726b1 BM |
36 | /* And one for OpenBSD: */ |
37 | # if defined(__OpenBSD__) | |
38 | # define OPENBSD | |
39 | # endif | |
40 | ||
c0561434 LR |
41 | /* And one for FreeBSD: */ |
42 | # if defined(__FreeBSD__) | |
43 | # define FREEBSD | |
44 | # endif | |
45 | ||
70f72767 | 46 | /* Determine the machine type: */ |
b6459d9a AG |
47 | # if defined(__XSCALE__) |
48 | # define ARM32 | |
49 | # if !defined(LINUX) | |
50 | # define NOSYS | |
51 | # define mach_type_known | |
52 | # endif | |
53 | # endif | |
70f72767 TT |
54 | # if defined(sun) && defined(mc68000) |
55 | # define M68K | |
56 | # define SUNOS4 | |
57 | # define mach_type_known | |
58 | # endif | |
59 | # if defined(hp9000s300) | |
60 | # define M68K | |
61 | # define HP | |
62 | # define mach_type_known | |
63 | # endif | |
4c7726b1 | 64 | # if defined(OPENBSD) && defined(m68k) |
70f72767 | 65 | # define M68K |
70f72767 TT |
66 | # define mach_type_known |
67 | # endif | |
4c7726b1 | 68 | # if defined(OPENBSD) && defined(__sparc__) |
85f29b3b | 69 | # define SPARC |
85f29b3b TT |
70 | # define mach_type_known |
71 | # endif | |
4c7726b1 | 72 | # if defined(NETBSD) && defined(m68k) |
70f72767 | 73 | # define M68K |
70f72767 TT |
74 | # define mach_type_known |
75 | # endif | |
4c7726b1 | 76 | # if defined(NETBSD) && defined(__powerpc__) |
abdbd4a8 BM |
77 | # define POWERPC |
78 | # define mach_type_known | |
79 | # endif | |
4c7726b1 | 80 | # if defined(NETBSD) && defined(__arm32__) |
56293c2b | 81 | # define ARM32 |
56293c2b BM |
82 | # define mach_type_known |
83 | # endif | |
70f72767 TT |
84 | # if defined(vax) |
85 | # define VAX | |
86 | # ifdef ultrix | |
87 | # define ULTRIX | |
88 | # else | |
89 | # define BSD | |
90 | # endif | |
91 | # define mach_type_known | |
92 | # endif | |
79f777fd | 93 | # if defined(mips) || defined(__mips) || defined(_mips) |
70f72767 | 94 | # define MIPS |
79f777fd BM |
95 | # if defined(nec_ews) || defined(_nec_ews) |
96 | # define EWS4800 | |
97 | # endif | |
179a9caf JT |
98 | # if !defined(LINUX) && !defined(EWS4800) && !defined(NETBSD) |
99 | # if defined(ultrix) || defined(__ultrix) | |
56293c2b BM |
100 | # define ULTRIX |
101 | # else | |
102 | # if defined(_SYSTYPE_SVR4) || defined(SYSTYPE_SVR4) \ | |
103 | || defined(__SYSTYPE_SVR4__) | |
104 | # define IRIX5 /* or IRIX 6.X */ | |
105 | # else | |
106 | # define RISCOS /* or IRIX 4.X */ | |
107 | # endif | |
108 | # endif | |
109 | # endif /* !LINUX */ | |
70f72767 TT |
110 | # define mach_type_known |
111 | # endif | |
abdbd4a8 | 112 | # if defined(sequent) && (defined(i386) || defined(__i386__)) |
70f72767 TT |
113 | # define I386 |
114 | # define SEQUENT | |
115 | # define mach_type_known | |
116 | # endif | |
abdbd4a8 | 117 | # if defined(sun) && (defined(i386) || defined(__i386__)) |
70f72767 TT |
118 | # define I386 |
119 | # define SUNOS5 | |
120 | # define mach_type_known | |
121 | # endif | |
122 | # if (defined(__OS2__) || defined(__EMX__)) && defined(__32BIT__) | |
123 | # define I386 | |
124 | # define OS2 | |
125 | # define mach_type_known | |
126 | # endif | |
127 | # if defined(ibm032) | |
128 | # define RT | |
129 | # define mach_type_known | |
130 | # endif | |
131 | # if defined(sun) && (defined(sparc) || defined(__sparc)) | |
132 | # define SPARC | |
133 | /* Test for SunOS 5.x */ | |
134 | # include <errno.h> | |
135 | # ifdef ECHRNG | |
136 | # define SUNOS5 | |
137 | # else | |
138 | # define SUNOS4 | |
139 | # endif | |
140 | # define mach_type_known | |
141 | # endif | |
85f29b3b | 142 | # if defined(sparc) && defined(unix) && !defined(sun) && !defined(linux) \ |
abdbd4a8 | 143 | && !defined(__OpenBSD__) && !(__NetBSD__) |
70f72767 TT |
144 | # define SPARC |
145 | # define DRSNX | |
146 | # define mach_type_known | |
147 | # endif | |
148 | # if defined(_IBMR2) | |
149 | # define RS6000 | |
150 | # define mach_type_known | |
151 | # endif | |
abdbd4a8 BM |
152 | # if defined(__NetBSD__) && defined(__sparc__) |
153 | # define SPARC | |
154 | # define mach_type_known | |
155 | # endif | |
70f72767 TT |
156 | # if defined(_M_XENIX) && defined(_M_SYSV) && defined(_M_I386) |
157 | /* The above test may need refinement */ | |
158 | # define I386 | |
159 | # if defined(_SCO_ELF) | |
160 | # define SCO_ELF | |
161 | # else | |
162 | # define SCO | |
163 | # endif | |
164 | # define mach_type_known | |
165 | # endif | |
166 | # if defined(_AUX_SOURCE) | |
167 | # define M68K | |
168 | # define SYSV | |
169 | # define mach_type_known | |
170 | # endif | |
56293c2b | 171 | # if defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0) \ |
70f72767 TT |
172 | || defined(hppa) || defined(__hppa__) |
173 | # define HP_PA | |
56293c2b BM |
174 | # ifndef LINUX |
175 | # define HPUX | |
176 | # endif | |
70f72767 TT |
177 | # define mach_type_known |
178 | # endif | |
4c7726b1 BM |
179 | # if defined(__ia64) && defined(_HPUX_SOURCE) |
180 | # define IA64 | |
181 | # define HPUX | |
182 | # define mach_type_known | |
183 | # endif | |
abdbd4a8 BM |
184 | # if defined(__BEOS__) && defined(_X86_) |
185 | # define I386 | |
186 | # define BEOS | |
187 | # define mach_type_known | |
188 | # endif | |
85f29b3b | 189 | # if defined(LINUX) && (defined(i386) || defined(__i386__)) |
70f72767 TT |
190 | # define I386 |
191 | # define mach_type_known | |
192 | # endif | |
48528b67 BT |
193 | # if defined(LINUX) && defined(__x86_64__) |
194 | # define X86_64 | |
195 | # define mach_type_known | |
196 | # endif | |
56293c2b BM |
197 | # if defined(LINUX) && (defined(__ia64__) || defined(__ia64)) |
198 | # define IA64 | |
199 | # define mach_type_known | |
200 | # endif | |
5a2586cf | 201 | # if defined(LINUX) && (defined(powerpc) || defined(__powerpc__)) |
70f72767 TT |
202 | # define POWERPC |
203 | # define mach_type_known | |
204 | # endif | |
205 | # if defined(LINUX) && defined(__mc68000__) | |
206 | # define M68K | |
207 | # define mach_type_known | |
208 | # endif | |
56293c2b | 209 | # if defined(LINUX) && (defined(sparc) || defined(__sparc__)) |
70f72767 | 210 | # define SPARC |
70f72767 TT |
211 | # define mach_type_known |
212 | # endif | |
abdbd4a8 | 213 | # if defined(LINUX) && defined(__arm__) |
56293c2b BM |
214 | # define ARM32 |
215 | # define mach_type_known | |
216 | # endif | |
abdbd4a8 BM |
217 | # if defined(LINUX) && defined(__sh__) |
218 | # define SH | |
219 | # define mach_type_known | |
220 | # endif | |
70f72767 TT |
221 | # if defined(__alpha) || defined(__alpha__) |
222 | # define ALPHA | |
c0561434 | 223 | # if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD) && !defined(FREEBSD) |
70f72767 TT |
224 | # define OSF1 /* a.k.a Digital Unix */ |
225 | # endif | |
226 | # define mach_type_known | |
227 | # endif | |
85f29b3b | 228 | # if defined(_AMIGA) && !defined(AMIGA) |
70f72767 | 229 | # define AMIGA |
85f29b3b TT |
230 | # endif |
231 | # ifdef AMIGA | |
232 | # define M68K | |
70f72767 TT |
233 | # define mach_type_known |
234 | # endif | |
235 | # if defined(THINK_C) || defined(__MWERKS__) && !defined(__powerc) | |
236 | # define M68K | |
237 | # define MACOS | |
238 | # define mach_type_known | |
239 | # endif | |
240 | # if defined(__MWERKS__) && defined(__powerc) | |
241 | # define POWERPC | |
242 | # define MACOS | |
243 | # define mach_type_known | |
244 | # endif | |
abdbd4a8 BM |
245 | # if defined(macosx) || \ |
246 | defined(__APPLE__) && defined(__MACH__) && defined(__ppc__) | |
85f29b3b TT |
247 | # define MACOSX |
248 | # define POWERPC | |
249 | # define mach_type_known | |
250 | # endif | |
abdbd4a8 BM |
251 | # if defined(__APPLE__) && defined(__MACH__) && defined(__i386__) |
252 | # define MACOSX | |
253 | # define I386 | |
254 | --> Not really supported, but at least we recognize it. | |
255 | # endif | |
70f72767 TT |
256 | # if defined(NeXT) && defined(mc68000) |
257 | # define M68K | |
258 | # define NEXT | |
259 | # define mach_type_known | |
260 | # endif | |
abdbd4a8 | 261 | # if defined(NeXT) && (defined(i386) || defined(__i386__)) |
70f72767 TT |
262 | # define I386 |
263 | # define NEXT | |
264 | # define mach_type_known | |
265 | # endif | |
abdbd4a8 | 266 | # if defined(__OpenBSD__) && (defined(i386) || defined(__i386__)) |
70f72767 TT |
267 | # define I386 |
268 | # define OPENBSD | |
269 | # define mach_type_known | |
270 | # endif | |
c0561434 | 271 | # if defined(FREEBSD) && (defined(i386) || defined(__i386__)) |
70f72767 | 272 | # define I386 |
70f72767 TT |
273 | # define mach_type_known |
274 | # endif | |
abdbd4a8 | 275 | # if defined(__NetBSD__) && (defined(i386) || defined(__i386__)) |
70f72767 | 276 | # define I386 |
70f72767 TT |
277 | # define mach_type_known |
278 | # endif | |
abdbd4a8 | 279 | # if defined(bsdi) && (defined(i386) || defined(__i386__)) |
70f72767 TT |
280 | # define I386 |
281 | # define BSDI | |
282 | # define mach_type_known | |
283 | # endif | |
284 | # if !defined(mach_type_known) && defined(__386BSD__) | |
285 | # define I386 | |
286 | # define THREE86BSD | |
287 | # define mach_type_known | |
288 | # endif | |
289 | # if defined(_CX_UX) && defined(_M88K) | |
290 | # define M88K | |
291 | # define CX_UX | |
292 | # define mach_type_known | |
293 | # endif | |
294 | # if defined(DGUX) | |
295 | # define M88K | |
296 | /* DGUX defined */ | |
297 | # define mach_type_known | |
298 | # endif | |
abdbd4a8 BM |
299 | # if defined(_WIN32_WCE) |
300 | /* SH3, SH4, MIPS already defined for corresponding architectures */ | |
301 | # if defined(SH3) || defined(SH4) | |
302 | # define SH | |
303 | # endif | |
304 | # if defined(x86) | |
305 | # define I386 | |
306 | # endif | |
307 | # if defined(ARM) | |
308 | # define ARM32 | |
309 | # endif | |
310 | # define MSWINCE | |
70f72767 | 311 | # define mach_type_known |
abdbd4a8 BM |
312 | # else |
313 | # if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \ | |
314 | || defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__CYGWIN__) | |
315 | # define I386 | |
316 | # define MSWIN32 /* or Win32s */ | |
317 | # define mach_type_known | |
318 | # endif | |
70f72767 TT |
319 | # endif |
320 | # if defined(__DJGPP__) | |
321 | # define I386 | |
322 | # ifndef DJGPP | |
323 | # define DJGPP /* MSDOS running the DJGPP port of GCC */ | |
324 | # endif | |
325 | # define mach_type_known | |
326 | # endif | |
327 | # if defined(__CYGWIN32__) || defined(__CYGWIN__) | |
328 | # define I386 | |
329 | # define CYGWIN32 | |
330 | # define mach_type_known | |
331 | # endif | |
56293c2b BM |
332 | # if defined(__MINGW32__) |
333 | # define I386 | |
334 | # define MSWIN32 | |
335 | # define mach_type_known | |
336 | # endif | |
70f72767 TT |
337 | # if defined(__BORLANDC__) |
338 | # define I386 | |
339 | # define MSWIN32 | |
340 | # define mach_type_known | |
341 | # endif | |
342 | # if defined(_UTS) && !defined(mach_type_known) | |
343 | # define S370 | |
344 | # define UTS4 | |
345 | # define mach_type_known | |
346 | # endif | |
56293c2b BM |
347 | # if defined(__pj__) |
348 | # define PJ | |
349 | # define mach_type_known | |
350 | # endif | |
abdbd4a8 BM |
351 | # if defined(__embedded__) && defined(PPC) |
352 | # define POWERPC | |
353 | # define NOSYS | |
354 | # define mach_type_known | |
355 | # endif | |
70f72767 TT |
356 | /* Ivan Demakov */ |
357 | # if defined(__WATCOMC__) && defined(__386__) | |
358 | # define I386 | |
359 | # if !defined(OS2) && !defined(MSWIN32) && !defined(DOS4GW) | |
360 | # if defined(__OS2__) | |
361 | # define OS2 | |
362 | # else | |
363 | # if defined(__WINDOWS_386__) || defined(__NT__) | |
364 | # define MSWIN32 | |
365 | # else | |
366 | # define DOS4GW | |
367 | # endif | |
368 | # endif | |
369 | # endif | |
370 | # define mach_type_known | |
371 | # endif | |
abdbd4a8 | 372 | # if defined(__s390__) && defined(LINUX) |
10a197ee | 373 | # define S390 |
abdbd4a8 BM |
374 | # define mach_type_known |
375 | # endif | |
5a2586cf TT |
376 | # if defined(__GNU__) |
377 | # if defined(__i386__) | |
378 | /* The Debian Hurd running on generic PC */ | |
379 | # define HURD | |
380 | # define I386 | |
381 | # define mach_type_known | |
382 | # endif | |
383 | # endif | |
70f72767 TT |
384 | |
385 | /* Feel free to add more clauses here */ | |
386 | ||
387 | /* Or manually define the machine type here. A machine type is */ | |
388 | /* characterized by the architecture. Some */ | |
389 | /* machine types are further subdivided by OS. */ | |
390 | /* the macros ULTRIX, RISCOS, and BSD to distinguish. */ | |
391 | /* Note that SGI IRIX is treated identically to RISCOS. */ | |
392 | /* SYSV on an M68K actually means A/UX. */ | |
393 | /* The distinction in these cases is usually the stack starting address */ | |
394 | # ifndef mach_type_known | |
395 | --> unknown machine type | |
396 | # endif | |
397 | /* Mapping is: M68K ==> Motorola 680X0 */ | |
398 | /* (SUNOS4,HP,NEXT, and SYSV (A/UX), */ | |
399 | /* MACOS and AMIGA variants) */ | |
400 | /* I386 ==> Intel 386 */ | |
401 | /* (SEQUENT, OS2, SCO, LINUX, NETBSD, */ | |
402 | /* FREEBSD, THREE86BSD, MSWIN32, */ | |
403 | /* BSDI,SUNOS5, NEXT, other variants) */ | |
404 | /* NS32K ==> Encore Multimax */ | |
405 | /* MIPS ==> R2000 or R3000 */ | |
406 | /* (RISCOS, ULTRIX variants) */ | |
407 | /* VAX ==> DEC VAX */ | |
408 | /* (BSD, ULTRIX variants) */ | |
409 | /* RS6000 ==> IBM RS/6000 AIX3.X */ | |
410 | /* RT ==> IBM PC/RT */ | |
411 | /* HP_PA ==> HP9000/700 & /800 */ | |
4c7726b1 | 412 | /* HP/UX, LINUX */ |
abdbd4a8 BM |
413 | /* SPARC ==> SPARC v7/v8/v9 */ |
414 | /* (SUNOS4, SUNOS5, LINUX, */ | |
70f72767 TT |
415 | /* DRSNX variants) */ |
416 | /* ALPHA ==> DEC Alpha */ | |
417 | /* (OSF1 and LINUX variants) */ | |
418 | /* M88K ==> Motorola 88XX0 */ | |
419 | /* (CX_UX and DGUX) */ | |
420 | /* S370 ==> 370-like machine */ | |
421 | /* running Amdahl UTS4 */ | |
10a197ee UW |
422 | /* S390 ==> 390-like machine */ |
423 | /* running LINUX */ | |
56293c2b | 424 | /* ARM32 ==> Intel StrongARM */ |
4c7726b1 | 425 | /* IA64 ==> Intel IPF */ |
56293c2b | 426 | /* (e.g. Itanium) */ |
4c7726b1 BM |
427 | /* (LINUX and HPUX) */ |
428 | /* IA64_32 ==> IA64 w/32 bit ABI */ | |
429 | /* (HPUX) */ | |
abdbd4a8 BM |
430 | /* SH ==> Hitachi SuperH */ |
431 | /* (LINUX & MSWINCE) */ | |
48528b67 | 432 | /* X86_64 ==> AMD x86-64 */ |
70f72767 TT |
433 | |
434 | ||
435 | /* | |
436 | * For each architecture and OS, the following need to be defined: | |
437 | * | |
438 | * CPP_WORD_SZ is a simple integer constant representing the word size. | |
439 | * in bits. We assume byte addressibility, where a byte has 8 bits. | |
440 | * We also assume CPP_WORD_SZ is either 32 or 64. | |
441 | * (We care about the length of pointers, not hardware | |
442 | * bus widths. Thus a 64 bit processor with a C compiler that uses | |
443 | * 32 bit pointers should use CPP_WORD_SZ of 32, not 64. Default is 32.) | |
444 | * | |
445 | * MACH_TYPE is a string representation of the machine type. | |
446 | * OS_TYPE is analogous for the OS. | |
447 | * | |
448 | * ALIGNMENT is the largest N, such that | |
449 | * all pointer are guaranteed to be aligned on N byte boundaries. | |
450 | * defining it to be 1 will always work, but perform poorly. | |
451 | * | |
452 | * DATASTART is the beginning of the data segment. | |
453 | * On UNIX systems, the collector will scan the area between DATASTART | |
454 | * and DATAEND for root pointers. | |
455 | * | |
ed47971a LR |
456 | * DATAEND, if not `end' where `end' is defined as ``extern int end[];''. |
457 | * RTH suggests gaining access to linker script synth'd values with | |
458 | * this idiom instead of `&end' where `end' is defined as ``extern int end;'' . | |
b911c031 | 459 | * Otherwise, ``GCC will assume these are in .sdata/.sbss'' and it will, e.g., |
e285b259 | 460 | * cause failures on alpha*-*-* with ``-msmall-data or -fpic'' or mips-*-* |
b911c031 | 461 | * without any special options. |
70f72767 TT |
462 | * |
463 | * ALIGN_DOUBLE of GC_malloc should return blocks aligned to twice | |
464 | * the pointer size. | |
465 | * | |
466 | * STACKBOTTOM is the cool end of the stack, which is usually the | |
467 | * highest address in the stack. | |
468 | * Under PCR or OS/2, we have other ways of finding thread stacks. | |
469 | * For each machine, the following should: | |
470 | * 1) define STACK_GROWS_UP if the stack grows toward higher addresses, and | |
471 | * 2) define exactly one of | |
472 | * STACKBOTTOM (should be defined to be an expression) | |
473 | * HEURISTIC1 | |
474 | * HEURISTIC2 | |
475 | * If either of the last two macros are defined, then STACKBOTTOM is computed | |
476 | * during collector startup using one of the following two heuristics: | |
477 | * HEURISTIC1: Take an address inside GC_init's frame, and round it up to | |
478 | * the next multiple of STACK_GRAN. | |
479 | * HEURISTIC2: Take an address inside GC_init's frame, increment it repeatedly | |
480 | * in small steps (decrement if STACK_GROWS_UP), and read the value | |
481 | * at each location. Remember the value when the first | |
482 | * Segmentation violation or Bus error is signalled. Round that | |
483 | * to the nearest plausible page boundary, and use that instead | |
484 | * of STACKBOTTOM. | |
485 | * | |
179977c1 BM |
486 | * Gustavo Rodriguez-Rivera points out that on most (all?) Unix machines, |
487 | * the value of environ is a pointer that can serve as STACKBOTTOM. | |
488 | * I expect that HEURISTIC2 can be replaced by this approach, which | |
abdbd4a8 BM |
489 | * interferes far less with debugging. However it has the disadvantage |
490 | * that it's confused by a putenv call before the collector is initialized. | |
491 | * This could be dealt with by intercepting putenv ... | |
179977c1 | 492 | * |
70f72767 TT |
493 | * If no expression for STACKBOTTOM can be found, and neither of the above |
494 | * heuristics are usable, the collector can still be used with all of the above | |
495 | * undefined, provided one of the following is done: | |
496 | * 1) GC_mark_roots can be changed to somehow mark from the correct stack(s) | |
497 | * without reference to STACKBOTTOM. This is appropriate for use in | |
498 | * conjunction with thread packages, since there will be multiple stacks. | |
499 | * (Allocating thread stacks in the heap, and treating them as ordinary | |
500 | * heap data objects is also possible as a last resort. However, this is | |
501 | * likely to introduce significant amounts of excess storage retention | |
502 | * unless the dead parts of the thread stacks are periodically cleared.) | |
503 | * 2) Client code may set GC_stackbottom before calling any GC_ routines. | |
504 | * If the author of the client code controls the main program, this is | |
505 | * easily accomplished by introducing a new main program, setting | |
506 | * GC_stackbottom to the address of a local variable, and then calling | |
507 | * the original main program. The new main program would read something | |
508 | * like: | |
509 | * | |
510 | * # include "gc_private.h" | |
511 | * | |
512 | * main(argc, argv, envp) | |
513 | * int argc; | |
514 | * char **argv, **envp; | |
515 | * { | |
516 | * int dummy; | |
517 | * | |
518 | * GC_stackbottom = (ptr_t)(&dummy); | |
519 | * return(real_main(argc, argv, envp)); | |
520 | * } | |
521 | * | |
522 | * | |
523 | * Each architecture may also define the style of virtual dirty bit | |
524 | * implementation to be used: | |
525 | * MPROTECT_VDB: Write protect the heap and catch faults. | |
526 | * PROC_VDB: Use the SVR4 /proc primitives to read dirty bits. | |
527 | * | |
528 | * An architecture may define DYNAMIC_LOADING if dynamic_load.c | |
529 | * defined GC_register_dynamic_libraries() for the architecture. | |
56293c2b BM |
530 | * |
531 | * An architecture may define PREFETCH(x) to preload the cache with *x. | |
532 | * This defaults to a no-op. | |
533 | * | |
534 | * PREFETCH_FOR_WRITE(x) is used if *x is about to be written. | |
535 | * | |
536 | * An architecture may also define CLEAR_DOUBLE(x) to be a fast way to | |
537 | * clear the two words at GC_malloc-aligned address x. By default, | |
538 | * word stores of 0 are used instead. | |
70f72767 TT |
539 | */ |
540 | ||
5a2586cf TT |
541 | /* If we are using a recent version of gcc, we can use __builtin_unwind_init() |
542 | * to push the relevant registers onto the stack. This generally makes | |
543 | * USE_GENERIC_PUSH_REGS the preferred approach for marking from registers. | |
544 | */ | |
545 | # if defined(__GNUC__) && ((__GNUC__ >= 3) || \ | |
546 | (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)) | |
547 | # define HAVE_BUILTIN_UNWIND_INIT | |
548 | # endif | |
70f72767 TT |
549 | |
550 | # define STACK_GRAN 0x1000000 | |
551 | # ifdef M68K | |
552 | # define MACH_TYPE "M68K" | |
553 | # define ALIGNMENT 2 | |
554 | # ifdef OPENBSD | |
555 | # define OS_TYPE "OPENBSD" | |
556 | # define HEURISTIC2 | |
ed47971a LR |
557 | extern char etext[]; |
558 | # define DATASTART ((ptr_t)(etext)) | |
70f72767 TT |
559 | # endif |
560 | # ifdef NETBSD | |
561 | # define OS_TYPE "NETBSD" | |
562 | # define HEURISTIC2 | |
ed47971a LR |
563 | extern char etext[]; |
564 | # define DATASTART ((ptr_t)(etext)) | |
70f72767 TT |
565 | # endif |
566 | # ifdef LINUX | |
567 | # define OS_TYPE "LINUX" | |
568 | # define STACKBOTTOM ((ptr_t)0xf0000000) | |
4c7726b1 | 569 | /* # define MPROTECT_VDB - Reported to not work 9/17/01 */ |
70f72767 TT |
570 | # ifdef __ELF__ |
571 | # define DYNAMIC_LOADING | |
abdbd4a8 BM |
572 | # include <features.h> |
573 | # if defined(__GLIBC__)&& __GLIBC__>=2 | |
574 | # define LINUX_DATA_START | |
575 | # else /* !GLIBC2 */ | |
576 | extern char **__environ; | |
577 | # define DATASTART ((ptr_t)(&__environ)) | |
70f72767 TT |
578 | /* hideous kludge: __environ is the first */ |
579 | /* word in crt0.o, and delimits the start */ | |
580 | /* of the data segment, no matter which */ | |
581 | /* ld options were passed through. */ | |
582 | /* We could use _etext instead, but that */ | |
583 | /* would include .rodata, which may */ | |
584 | /* contain large read-only data tables */ | |
585 | /* that we'd rather not scan. */ | |
abdbd4a8 | 586 | # endif /* !GLIBC2 */ |
ed47971a LR |
587 | extern int _end[]; |
588 | # define DATAEND (_end) | |
70f72767 | 589 | # else |
ed47971a LR |
590 | extern int etext[]; |
591 | # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff)) | |
70f72767 TT |
592 | # endif |
593 | # endif | |
594 | # ifdef SUNOS4 | |
595 | # define OS_TYPE "SUNOS4" | |
ed47971a LR |
596 | extern char etext[]; |
597 | # define DATASTART ((ptr_t)((((word) (etext)) + 0x1ffff) & ~0x1ffff)) | |
70f72767 TT |
598 | # define HEURISTIC1 /* differs */ |
599 | # define DYNAMIC_LOADING | |
600 | # endif | |
601 | # ifdef HP | |
602 | # define OS_TYPE "HP" | |
ed47971a LR |
603 | extern char etext[]; |
604 | # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff)) | |
70f72767 TT |
605 | # define STACKBOTTOM ((ptr_t) 0xffeffffc) |
606 | /* empirically determined. seems to work. */ | |
607 | # include <unistd.h> | |
608 | # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE) | |
609 | # endif | |
610 | # ifdef SYSV | |
611 | # define OS_TYPE "SYSV" | |
ed47971a LR |
612 | extern etext[]; |
613 | # define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \ | |
70f72767 | 614 | & ~0x3fffff) \ |
ed47971a | 615 | +((word)etext & 0x1fff)) |
70f72767 TT |
616 | /* This only works for shared-text binaries with magic number 0413. |
617 | The other sorts of SysV binaries put the data at the end of the text, | |
ed47971a | 618 | in which case the default of etext would work. Unfortunately, |
70f72767 TT |
619 | handling both would require having the magic-number available. |
620 | -- Parag | |
621 | */ | |
622 | # define STACKBOTTOM ((ptr_t)0xFFFFFFFE) | |
623 | /* The stack starts at the top of memory, but */ | |
624 | /* 0x0 cannot be used as setjump_test complains */ | |
625 | /* that the stack direction is incorrect. Two */ | |
626 | /* bytes down from 0x0 should be safe enough. */ | |
627 | /* --Parag */ | |
628 | # include <sys/mmu.h> | |
629 | # define GETPAGESIZE() PAGESIZE /* Is this still right? */ | |
630 | # endif | |
631 | # ifdef AMIGA | |
632 | # define OS_TYPE "AMIGA" | |
633 | /* STACKBOTTOM and DATASTART handled specially */ | |
634 | /* in os_dep.c */ | |
635 | # define DATAEND /* not needed */ | |
636 | # define GETPAGESIZE() 4096 | |
637 | # endif | |
638 | # ifdef MACOS | |
639 | # ifndef __LOWMEM__ | |
640 | # include <LowMem.h> | |
641 | # endif | |
642 | # define OS_TYPE "MACOS" | |
643 | /* see os_dep.c for details of global data segments. */ | |
644 | # define STACKBOTTOM ((ptr_t) LMGetCurStackBase()) | |
645 | # define DATAEND /* not needed */ | |
646 | # define GETPAGESIZE() 4096 | |
647 | # endif | |
648 | # ifdef NEXT | |
649 | # define OS_TYPE "NEXT" | |
650 | # define DATASTART ((ptr_t) get_etext()) | |
651 | # define STACKBOTTOM ((ptr_t) 0x4000000) | |
652 | # define DATAEND /* not needed */ | |
653 | # endif | |
654 | # endif | |
655 | ||
656 | # ifdef POWERPC | |
657 | # define MACH_TYPE "POWERPC" | |
70f72767 | 658 | # ifdef MACOS |
85f29b3b | 659 | # define ALIGNMENT 2 /* Still necessary? Could it be 4? */ |
70f72767 TT |
660 | # ifndef __LOWMEM__ |
661 | # include <LowMem.h> | |
662 | # endif | |
663 | # define OS_TYPE "MACOS" | |
664 | /* see os_dep.c for details of global data segments. */ | |
665 | # define STACKBOTTOM ((ptr_t) LMGetCurStackBase()) | |
666 | # define DATAEND /* not needed */ | |
667 | # endif | |
668 | # ifdef LINUX | |
85f29b3b TT |
669 | # define ALIGNMENT 4 /* Guess. Can someone verify? */ |
670 | /* This was 2, but that didn't sound right. */ | |
70f72767 TT |
671 | # define OS_TYPE "LINUX" |
672 | # define HEURISTIC1 | |
179977c1 | 673 | # define DYNAMIC_LOADING |
70f72767 TT |
674 | # undef STACK_GRAN |
675 | # define STACK_GRAN 0x10000000 | |
85f29b3b | 676 | /* Stack usually starts at 0x80000000 */ |
56293c2b | 677 | # define LINUX_DATA_START |
ed47971a LR |
678 | extern int _end[]; |
679 | # define DATAEND (_end) | |
70f72767 | 680 | # endif |
85f29b3b | 681 | # ifdef MACOSX |
abdbd4a8 | 682 | /* There are reasons to suspect this may not be reliable. */ |
85f29b3b TT |
683 | # define ALIGNMENT 4 |
684 | # define OS_TYPE "MACOSX" | |
685 | # define DATASTART ((ptr_t) get_etext()) | |
686 | # define STACKBOTTOM ((ptr_t) 0xc0000000) | |
687 | # define DATAEND /* not needed */ | |
abdbd4a8 BM |
688 | # define MPROTECT_VDB |
689 | # include <unistd.h> | |
690 | # define GETPAGESIZE() getpagesize() | |
691 | # endif | |
692 | # ifdef NETBSD | |
693 | # define ALIGNMENT 4 | |
694 | # define OS_TYPE "NETBSD" | |
695 | # define HEURISTIC2 | |
ed47971a | 696 | extern char etext[]; |
abdbd4a8 BM |
697 | # define DATASTART GC_data_start |
698 | # define DYNAMIC_LOADING | |
699 | # endif | |
700 | # ifdef NOSYS | |
701 | # define ALIGNMENT 4 | |
702 | # define OS_TYPE "NOSYS" | |
ed47971a LR |
703 | extern void __end[], __dso_handle[]; |
704 | # define DATASTART (__dso_handle) /* OK, that's ugly. */ | |
705 | # define DATAEND (__end) | |
abdbd4a8 BM |
706 | /* Stack starts at 0xE0000000 for the simulator. */ |
707 | # undef STACK_GRAN | |
708 | # define STACK_GRAN 0x10000000 | |
709 | # define HEURISTIC1 | |
85f29b3b | 710 | # endif |
70f72767 TT |
711 | # endif |
712 | ||
713 | # ifdef VAX | |
714 | # define MACH_TYPE "VAX" | |
715 | # define ALIGNMENT 4 /* Pointers are longword aligned by 4.2 C compiler */ | |
ed47971a LR |
716 | extern char etext[]; |
717 | # define DATASTART ((ptr_t)(etext)) | |
70f72767 TT |
718 | # ifdef BSD |
719 | # define OS_TYPE "BSD" | |
720 | # define HEURISTIC1 | |
721 | /* HEURISTIC2 may be OK, but it's hard to test. */ | |
722 | # endif | |
723 | # ifdef ULTRIX | |
724 | # define OS_TYPE "ULTRIX" | |
725 | # define STACKBOTTOM ((ptr_t) 0x7fffc800) | |
726 | # endif | |
727 | # endif | |
728 | ||
729 | # ifdef RT | |
730 | # define MACH_TYPE "RT" | |
731 | # define ALIGNMENT 4 | |
732 | # define DATASTART ((ptr_t) 0x10000000) | |
733 | # define STACKBOTTOM ((ptr_t) 0x1fffd800) | |
734 | # endif | |
735 | ||
736 | # ifdef SPARC | |
737 | # define MACH_TYPE "SPARC" | |
abdbd4a8 BM |
738 | # if defined(__arch64__) || defined(__sparcv9) |
739 | # define ALIGNMENT 8 | |
a5b2a65b JS |
740 | # define CPP_WORDSZ 64 |
741 | # define ELF_CLASS ELFCLASS64 | |
abdbd4a8 BM |
742 | # else |
743 | # define ALIGNMENT 4 /* Required by hardware */ | |
79f777fd | 744 | # define CPP_WORDSZ 32 |
abdbd4a8 | 745 | # endif |
70f72767 | 746 | # define ALIGN_DOUBLE |
70f72767 TT |
747 | # ifdef SUNOS5 |
748 | # define OS_TYPE "SUNOS5" | |
ed47971a LR |
749 | extern int _etext[]; |
750 | extern int _end[]; | |
70f72767 | 751 | extern char * GC_SysVGetDataStart(); |
ed47971a LR |
752 | # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, _etext) |
753 | # define DATAEND (_end) | |
79f777fd | 754 | # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC) |
70f72767 | 755 | # define USE_MMAP |
79f777fd BM |
756 | /* Otherwise we now use calloc. Mmap may result in the */ |
757 | /* heap interleaved with thread stacks, which can result in */ | |
758 | /* excessive blacklisting. Sbrk is unusable since it */ | |
759 | /* doesn't interact correctly with the system malloc. */ | |
70f72767 TT |
760 | # endif |
761 | # ifdef USE_MMAP | |
762 | # define HEAP_START (ptr_t)0x40000000 | |
763 | # else | |
764 | # define HEAP_START DATAEND | |
765 | # endif | |
766 | # define PROC_VDB | |
abdbd4a8 BM |
767 | /* HEURISTIC1 reportedly no longer works under 2.7. */ |
768 | /* HEURISTIC2 probably works, but this appears to be preferable. */ | |
769 | /* Apparently USRSTACK is defined to be USERLIMIT, but in some */ | |
770 | /* installations that's undefined. We work around this with a */ | |
771 | /* gross hack: */ | |
772 | # include <sys/vmparam.h> | |
773 | # ifdef USERLIMIT | |
774 | /* This should work everywhere, but doesn't. */ | |
775 | # define STACKBOTTOM USRSTACK | |
776 | # else | |
777 | # define HEURISTIC2 | |
778 | # endif | |
70f72767 TT |
779 | # include <unistd.h> |
780 | # define GETPAGESIZE() sysconf(_SC_PAGESIZE) | |
781 | /* getpagesize() appeared to be missing from at least one */ | |
782 | /* Solaris 5.4 installation. Weird. */ | |
a61df6c7 | 783 | # define DYNAMIC_LOADING |
70f72767 TT |
784 | # endif |
785 | # ifdef SUNOS4 | |
786 | # define OS_TYPE "SUNOS4" | |
787 | /* [If you have a weak stomach, don't read this.] */ | |
788 | /* We would like to use: */ | |
ed47971a | 789 | /* # define DATASTART ((ptr_t)((((word) (etext)) + 0x1fff) & ~0x1fff)) */ |
70f72767 | 790 | /* This fails occasionally, due to an ancient, but very */ |
ed47971a | 791 | /* persistent ld bug. etext is set 32 bytes too high. */ |
70f72767 TT |
792 | /* We instead read the text segment size from the a.out */ |
793 | /* header, which happens to be mapped into our address space */ | |
794 | /* at the start of the text segment. The detective work here */ | |
795 | /* was done by Robert Ehrlich, Manuel Serrano, and Bernard */ | |
796 | /* Serpette of INRIA. */ | |
797 | /* This assumes ZMAGIC, i.e. demand-loadable executables. */ | |
798 | # define TEXTSTART 0x2000 | |
799 | # define DATASTART ((ptr_t)(*(int *)(TEXTSTART+0x4)+TEXTSTART)) | |
800 | # define MPROTECT_VDB | |
801 | # define HEURISTIC1 | |
802 | # define DYNAMIC_LOADING | |
803 | # endif | |
804 | # ifdef DRSNX | |
70f72767 TT |
805 | # define OS_TYPE "DRSNX" |
806 | extern char * GC_SysVGetDataStart(); | |
ed47971a LR |
807 | extern int etext[]; |
808 | # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, etext) | |
70f72767 TT |
809 | # define MPROTECT_VDB |
810 | # define STACKBOTTOM ((ptr_t) 0xdfff0000) | |
811 | # define DYNAMIC_LOADING | |
812 | # endif | |
813 | # ifdef LINUX | |
814 | # define OS_TYPE "LINUX" | |
815 | # ifdef __ELF__ | |
56293c2b | 816 | # define DYNAMIC_LOADING |
70f72767 | 817 | # else |
abdbd4a8 | 818 | Linux Sparc/a.out not supported |
70f72767 | 819 | # endif |
ed47971a LR |
820 | extern int _end[]; |
821 | extern int _etext[]; | |
822 | # define DATAEND (_end) | |
70f72767 | 823 | # define SVR4 |
abdbd4a8 | 824 | # ifdef __arch64__ |
a61df6c7 DM |
825 | /* libc_stack_end is not set reliably for sparc64 */ |
826 | # define STACKBOTTOM ((ptr_t) 0x80000000000) | |
ed47971a | 827 | # define DATASTART (ptr_t)GC_SysVGetDataStart(0x100000, _etext) |
abdbd4a8 | 828 | # else |
a61df6c7 | 829 | # define LINUX_STACKBOTTOM |
ed47971a | 830 | # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, _etext) |
abdbd4a8 | 831 | # endif |
70f72767 | 832 | # endif |
85f29b3b TT |
833 | # ifdef OPENBSD |
834 | # define OS_TYPE "OPENBSD" | |
835 | # define STACKBOTTOM ((ptr_t) 0xf8000000) | |
ed47971a LR |
836 | extern int etext[]; |
837 | # define DATASTART ((ptr_t)(etext)) | |
85f29b3b | 838 | # endif |
abdbd4a8 BM |
839 | # ifdef NETBSD |
840 | # define OS_TYPE "NETBSD" | |
841 | # define HEURISTIC2 | |
842 | # ifdef __ELF__ | |
843 | # define DATASTART GC_data_start | |
844 | # define DYNAMIC_LOADING | |
845 | # else | |
ed47971a LR |
846 | extern char etext[]; |
847 | # define DATASTART ((ptr_t)(etext)) | |
abdbd4a8 BM |
848 | # endif |
849 | # endif | |
70f72767 TT |
850 | # endif |
851 | ||
852 | # ifdef I386 | |
853 | # define MACH_TYPE "I386" | |
854 | # define ALIGNMENT 4 /* Appears to hold for all "32 bit" compilers */ | |
855 | /* except Borland. The -a4 option fixes */ | |
856 | /* Borland. */ | |
857 | /* Ivan Demakov: For Watcom the option is -zp4. */ | |
858 | # ifndef SMALL_CONFIG | |
859 | # define ALIGN_DOUBLE /* Not strictly necessary, but may give speed */ | |
860 | /* improvement on Pentiums. */ | |
861 | # endif | |
5a2586cf TT |
862 | # ifdef HAVE_BUILTIN_UNWIND_INIT |
863 | # define USE_GENERIC_PUSH_REGS | |
864 | # endif | |
70f72767 TT |
865 | # ifdef SEQUENT |
866 | # define OS_TYPE "SEQUENT" | |
ed47971a LR |
867 | extern int etext[]; |
868 | # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff)) | |
70f72767 TT |
869 | # define STACKBOTTOM ((ptr_t) 0x3ffff000) |
870 | # endif | |
abdbd4a8 BM |
871 | # ifdef BEOS |
872 | # define OS_TYPE "BEOS" | |
873 | # include <OS.h> | |
874 | # define GETPAGESIZE() B_PAGE_SIZE | |
ed47971a LR |
875 | extern int etext[]; |
876 | # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff)) | |
abdbd4a8 | 877 | # endif |
70f72767 TT |
878 | # ifdef SUNOS5 |
879 | # define OS_TYPE "SUNOS5" | |
ed47971a | 880 | extern int _etext[], _end[]; |
70f72767 | 881 | extern char * GC_SysVGetDataStart(); |
ed47971a LR |
882 | # define DATASTART GC_SysVGetDataStart(0x1000, _etext) |
883 | # define DATAEND (_end) | |
884 | /* # define STACKBOTTOM ((ptr_t)(_start)) worked through 2.7, */ | |
abdbd4a8 BM |
885 | /* but reportedly breaks under 2.8. It appears that the stack */ |
886 | /* base is a property of the executable, so this should not break */ | |
887 | /* old executables. */ | |
888 | /* HEURISTIC2 probably works, but this appears to be preferable. */ | |
79f777fd | 889 | # include <sys/vm.h> |
abdbd4a8 | 890 | # define STACKBOTTOM USRSTACK |
79f777fd BM |
891 | /* At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */ |
892 | /* It appears to be fixed in 2.8 and 2.9. */ | |
9c383523 RO |
893 | # ifdef SOLARIS25_PROC_VDB_BUG_FIXED |
894 | # define PROC_VDB | |
895 | # endif | |
70f72767 | 896 | # define DYNAMIC_LOADING |
79f777fd | 897 | # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC) |
70f72767 | 898 | # define USE_MMAP |
79f777fd BM |
899 | /* Otherwise we now use calloc. Mmap may result in the */ |
900 | /* heap interleaved with thread stacks, which can result in */ | |
901 | /* excessive blacklisting. Sbrk is unusable since it */ | |
902 | /* doesn't interact correctly with the system malloc. */ | |
70f72767 TT |
903 | # endif |
904 | # ifdef USE_MMAP | |
905 | # define HEAP_START (ptr_t)0x40000000 | |
906 | # else | |
907 | # define HEAP_START DATAEND | |
908 | # endif | |
909 | # endif | |
910 | # ifdef SCO | |
911 | # define OS_TYPE "SCO" | |
ed47971a LR |
912 | extern int etext[]; |
913 | # define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \ | |
70f72767 | 914 | & ~0x3fffff) \ |
ed47971a | 915 | +((word)etext & 0xfff)) |
70f72767 TT |
916 | # define STACKBOTTOM ((ptr_t) 0x7ffffffc) |
917 | # endif | |
918 | # ifdef SCO_ELF | |
919 | # define OS_TYPE "SCO_ELF" | |
ed47971a LR |
920 | extern int etext[]; |
921 | # define DATASTART ((ptr_t)(etext)) | |
70f72767 TT |
922 | # define STACKBOTTOM ((ptr_t) 0x08048000) |
923 | # define DYNAMIC_LOADING | |
924 | # define ELF_CLASS ELFCLASS32 | |
925 | # endif | |
926 | # ifdef LINUX | |
79f777fd BM |
927 | # ifndef __GNUC__ |
928 | /* The Intel compiler doesn't like inline assembly */ | |
929 | # define USE_GENERIC_PUSH_REGS | |
930 | # endif | |
70f72767 | 931 | # define OS_TYPE "LINUX" |
56293c2b BM |
932 | # define LINUX_STACKBOTTOM |
933 | # if 0 | |
934 | # define HEURISTIC1 | |
935 | # undef STACK_GRAN | |
936 | # define STACK_GRAN 0x10000000 | |
937 | /* STACKBOTTOM is usually 0xc0000000, but this changes with */ | |
938 | /* different kernel configurations. In particular, systems */ | |
939 | /* with 2GB physical memory will usually move the user */ | |
940 | /* address space limit, and hence initial SP to 0x80000000. */ | |
941 | # endif | |
4c7726b1 | 942 | # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC) |
70f72767 TT |
943 | # define MPROTECT_VDB |
944 | # else | |
945 | /* We seem to get random errors in incremental mode, */ | |
946 | /* possibly because Linux threads is itself a malloc client */ | |
947 | /* and can't deal with the signals. */ | |
948 | # endif | |
949 | # ifdef __ELF__ | |
950 | # define DYNAMIC_LOADING | |
951 | # ifdef UNDEFINED /* includes ro data */ | |
ed47971a LR |
952 | extern int _etext[]; |
953 | # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff)) | |
70f72767 TT |
954 | # endif |
955 | # include <features.h> | |
956 | # if defined(__GLIBC__) && __GLIBC__ >= 2 | |
56293c2b | 957 | # define LINUX_DATA_START |
70f72767 TT |
958 | # else |
959 | extern char **__environ; | |
960 | # define DATASTART ((ptr_t)(&__environ)) | |
961 | /* hideous kludge: __environ is the first */ | |
962 | /* word in crt0.o, and delimits the start */ | |
963 | /* of the data segment, no matter which */ | |
964 | /* ld options were passed through. */ | |
965 | /* We could use _etext instead, but that */ | |
966 | /* would include .rodata, which may */ | |
967 | /* contain large read-only data tables */ | |
968 | /* that we'd rather not scan. */ | |
969 | # endif | |
ed47971a LR |
970 | extern int _end[]; |
971 | # define DATAEND (_end) | |
70f72767 | 972 | # else |
ed47971a LR |
973 | extern int etext[]; |
974 | # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff)) | |
70f72767 | 975 | # endif |
56293c2b BM |
976 | # ifdef USE_I686_PREFETCH |
977 | # define PREFETCH(x) \ | |
978 | __asm__ __volatile__ (" prefetchnta %0": : "m"(*(char *)(x))) | |
979 | /* Empirically prefetcht0 is much more effective at reducing */ | |
980 | /* cache miss stalls for the targetted load instructions. But it */ | |
981 | /* seems to interfere enough with other cache traffic that the net */ | |
982 | /* result is worse than prefetchnta. */ | |
983 | # if 0 | |
984 | /* Using prefetches for write seems to have a slight negative */ | |
985 | /* impact on performance, at least for a PIII/500. */ | |
986 | # define PREFETCH_FOR_WRITE(x) \ | |
987 | __asm__ __volatile__ (" prefetcht0 %0": : "m"(*(char *)(x))) | |
988 | # endif | |
989 | # endif | |
990 | # ifdef USE_3DNOW_PREFETCH | |
991 | # define PREFETCH(x) \ | |
992 | __asm__ __volatile__ (" prefetch %0": : "m"(*(char *)(x))) | |
abdbd4a8 | 993 | # define PREFETCH_FOR_WRITE(x) \ |
56293c2b BM |
994 | __asm__ __volatile__ (" prefetchw %0": : "m"(*(char *)(x))) |
995 | # endif | |
70f72767 TT |
996 | # endif |
997 | # ifdef CYGWIN32 | |
998 | # define OS_TYPE "CYGWIN32" | |
ed47971a LR |
999 | extern int _data_start__[]; |
1000 | extern int _data_end__[]; | |
1001 | extern int _bss_start__[]; | |
1002 | extern int _bss_end__[]; | |
70f72767 TT |
1003 | /* For binutils 2.9.1, we have */ |
1004 | /* DATASTART = _data_start__ */ | |
1005 | /* DATAEND = _bss_end__ */ | |
1006 | /* whereas for some earlier versions it was */ | |
1007 | /* DATASTART = _bss_start__ */ | |
1008 | /* DATAEND = _data_end__ */ | |
1009 | /* To get it right for both, we take the */ | |
1010 | /* minumum/maximum of the two. */ | |
1011 | # define MAX(x,y) ((x) > (y) ? (x) : (y)) | |
1012 | # define MIN(x,y) ((x) < (y) ? (x) : (y)) | |
ed47971a LR |
1013 | # define DATASTART ((ptr_t) MIN(_data_start__, _bss_start__)) |
1014 | # define DATAEND ((ptr_t) MAX(_data_end__, _bss_end__)) | |
70f72767 TT |
1015 | # undef STACK_GRAN |
1016 | # define STACK_GRAN 0x10000 | |
1017 | # define HEURISTIC1 | |
1018 | # endif | |
1019 | # ifdef OS2 | |
1020 | # define OS_TYPE "OS2" | |
1021 | /* STACKBOTTOM and DATASTART are handled specially in */ | |
1022 | /* os_dep.c. OS2 actually has the right */ | |
1023 | /* system call! */ | |
1024 | # define DATAEND /* not needed */ | |
abdbd4a8 | 1025 | # define USE_GENERIC_PUSH_REGS |
70f72767 TT |
1026 | # endif |
1027 | # ifdef MSWIN32 | |
1028 | # define OS_TYPE "MSWIN32" | |
1029 | /* STACKBOTTOM and DATASTART are handled specially in */ | |
1030 | /* os_dep.c. */ | |
1031 | # ifndef __WATCOMC__ | |
1032 | # define MPROTECT_VDB | |
1033 | # endif | |
1034 | # define DATAEND /* not needed */ | |
1035 | # endif | |
abdbd4a8 BM |
1036 | # ifdef MSWINCE |
1037 | # define OS_TYPE "MSWINCE" | |
1038 | # define DATAEND /* not needed */ | |
1039 | # endif | |
70f72767 TT |
1040 | # ifdef DJGPP |
1041 | # define OS_TYPE "DJGPP" | |
1042 | # include "stubinfo.h" | |
ed47971a | 1043 | extern int etext[]; |
70f72767 TT |
1044 | extern int _stklen; |
1045 | extern int __djgpp_stack_limit; | |
ed47971a | 1046 | # define DATASTART ((ptr_t)((((word) (etext)) + 0x1ff) & ~0x1ff)) |
70f72767 TT |
1047 | /* # define STACKBOTTOM ((ptr_t)((word) _stubinfo + _stubinfo->size \ |
1048 | + _stklen)) */ | |
1049 | # define STACKBOTTOM ((ptr_t)((word) __djgpp_stack_limit + _stklen)) | |
1050 | /* This may not be right. */ | |
1051 | # endif | |
1052 | # ifdef OPENBSD | |
1053 | # define OS_TYPE "OPENBSD" | |
1054 | # endif | |
1055 | # ifdef FREEBSD | |
1056 | # define OS_TYPE "FREEBSD" | |
f6d882d9 LR |
1057 | # ifndef GC_FREEBSD_THREADS |
1058 | # define MPROTECT_VDB | |
1059 | # endif | |
1060 | # define SIG_SUSPEND SIGUSR1 | |
1061 | # define SIG_THR_RESTART SIGUSR2 | |
abdbd4a8 | 1062 | # define FREEBSD_STACKBOTTOM |
4c7726b1 BM |
1063 | # ifdef __ELF__ |
1064 | # define DYNAMIC_LOADING | |
1065 | # endif | |
3c55704e | 1066 | /* Handle unmapped hole i386*-*-freebsd[45]* may put between etext and edata. */ |
ed47971a | 1067 | extern char etext[]; |
3c55704e LR |
1068 | extern char edata[]; |
1069 | extern char end[]; | |
1070 | # define NEED_FIND_LIMIT | |
ed47971a | 1071 | # define DATASTART ((ptr_t)(etext)) |
3c55704e LR |
1072 | # define MIN(x,y) ((x) < (y) ? (x) : (y)) |
1073 | # define DATAEND (MIN (GC_find_limit (DATASTART, TRUE), DATASTART2)) | |
1074 | # define DATASTART2 ((ptr_t)(edata)) | |
1075 | # define DATAEND2 ((ptr_t)(end)) | |
70f72767 TT |
1076 | # endif |
1077 | # ifdef NETBSD | |
1078 | # define OS_TYPE "NETBSD" | |
c71f2c06 BM |
1079 | # ifdef __ELF__ |
1080 | # define DYNAMIC_LOADING | |
1081 | # endif | |
70f72767 TT |
1082 | # endif |
1083 | # ifdef THREE86BSD | |
1084 | # define OS_TYPE "THREE86BSD" | |
1085 | # endif | |
1086 | # ifdef BSDI | |
1087 | # define OS_TYPE "BSDI" | |
1088 | # endif | |
79f777fd | 1089 | # if defined(OPENBSD) || defined(NETBSD) \ |
70f72767 TT |
1090 | || defined(THREE86BSD) || defined(BSDI) |
1091 | # define HEURISTIC2 | |
ed47971a LR |
1092 | extern char etext[]; |
1093 | # define DATASTART ((ptr_t)(etext)) | |
70f72767 TT |
1094 | # endif |
1095 | # ifdef NEXT | |
1096 | # define OS_TYPE "NEXT" | |
1097 | # define DATASTART ((ptr_t) get_etext()) | |
1098 | # define STACKBOTTOM ((ptr_t)0xc0000000) | |
1099 | # define DATAEND /* not needed */ | |
1100 | # endif | |
1101 | # ifdef DOS4GW | |
1102 | # define OS_TYPE "DOS4GW" | |
1103 | extern long __nullarea; | |
1104 | extern char _end; | |
1105 | extern char *_STACKTOP; | |
1106 | /* Depending on calling conventions Watcom C either precedes | |
1107 | or does not precedes with undescore names of C-variables. | |
1108 | Make sure startup code variables always have the same names. */ | |
1109 | #pragma aux __nullarea "*"; | |
1110 | #pragma aux _end "*"; | |
1111 | # define STACKBOTTOM ((ptr_t) _STACKTOP) | |
1112 | /* confused? me too. */ | |
1113 | # define DATASTART ((ptr_t) &__nullarea) | |
1114 | # define DATAEND ((ptr_t) &_end) | |
1115 | # endif | |
5a2586cf TT |
1116 | # ifdef HURD |
1117 | # define OS_TYPE "HURD" | |
1118 | # define STACK_GROWS_DOWN | |
1119 | # define HEURISTIC2 | |
ed47971a LR |
1120 | extern int __data_start[]; |
1121 | # define DATASTART ( (ptr_t) (__data_start)) | |
1122 | extern int _end[]; | |
1123 | # define DATAEND ( (ptr_t) (_end)) | |
5a2586cf TT |
1124 | /* # define MPROTECT_VDB Not quite working yet? */ |
1125 | # define DYNAMIC_LOADING | |
1126 | # endif | |
70f72767 TT |
1127 | # endif |
1128 | ||
1129 | # ifdef NS32K | |
1130 | # define MACH_TYPE "NS32K" | |
1131 | # define ALIGNMENT 4 | |
1132 | extern char **environ; | |
1133 | # define DATASTART ((ptr_t)(&environ)) | |
1134 | /* hideous kludge: environ is the first */ | |
1135 | /* word in crt0.o, and delimits the start */ | |
1136 | /* of the data segment, no matter which */ | |
1137 | /* ld options were passed through. */ | |
1138 | # define STACKBOTTOM ((ptr_t) 0xfffff000) /* for Encore */ | |
1139 | # endif | |
1140 | ||
1141 | # ifdef MIPS | |
1142 | # define MACH_TYPE "MIPS" | |
56293c2b BM |
1143 | # ifdef LINUX |
1144 | /* This was developed for a linuxce style platform. Probably */ | |
1145 | /* needs to be tweaked for workstation class machines. */ | |
1146 | # define OS_TYPE "LINUX" | |
f3e83dc2 L |
1147 | # define DYNAMIC_LOADING |
1148 | extern int _end[]; | |
1149 | # define DATAEND (_end) | |
ed47971a LR |
1150 | extern int __data_start[]; |
1151 | # define DATASTART ((ptr_t)(__data_start)) | |
56293c2b | 1152 | # define ALIGNMENT 4 |
5a2586cf | 1153 | # define USE_GENERIC_PUSH_REGS |
f3e83dc2 | 1154 | # define LINUX_STACKBOTTOM |
56293c2b | 1155 | # endif /* Linux */ |
79f777fd BM |
1156 | # ifdef EWS4800 |
1157 | # define HEURISTIC2 | |
1158 | # if defined(_MIPS_SZPTR) && (_MIPS_SZPTR == 64) | |
1159 | extern int _fdata[], _end[]; | |
1160 | # define DATASTART ((ptr_t)_fdata) | |
1161 | # define DATAEND ((ptr_t)_end) | |
1162 | # define CPP_WORDSZ _MIPS_SZPTR | |
1163 | # define ALIGNMENT (_MIPS_SZPTR/8) | |
1164 | # else | |
ed47971a LR |
1165 | extern int etext[], edata[], end[]; |
1166 | extern int _DYNAMIC_LINKING[], _gp[]; | |
1167 | # define DATASTART ((ptr_t)((((word)etext + 0x3ffff) & ~0x3ffff) \ | |
1168 | + ((word)etext & 0xffff))) | |
1169 | # define DATAEND (edata) | |
1170 | # define DATASTART2 (_DYNAMIC_LINKING \ | |
1171 | ? (ptr_t)(((word)_gp + 0x8000 + 0x3ffff) & ~0x3ffff) \ | |
1172 | : (ptr_t)edata) | |
1173 | # define DATAEND2 (end) | |
79f777fd BM |
1174 | # define ALIGNMENT 4 |
1175 | # endif | |
1176 | # define OS_TYPE "EWS4800" | |
1177 | # define USE_GENERIC_PUSH_REGS 1 | |
1178 | # endif | |
70f72767 | 1179 | # ifdef ULTRIX |
56293c2b BM |
1180 | # define HEURISTIC2 |
1181 | # define DATASTART (ptr_t)0x10000000 | |
1182 | /* Could probably be slightly higher since */ | |
1183 | /* startup code allocates lots of stuff. */ | |
70f72767 TT |
1184 | # define OS_TYPE "ULTRIX" |
1185 | # define ALIGNMENT 4 | |
1186 | # endif | |
1187 | # ifdef RISCOS | |
56293c2b BM |
1188 | # define HEURISTIC2 |
1189 | # define DATASTART (ptr_t)0x10000000 | |
70f72767 TT |
1190 | # define OS_TYPE "RISCOS" |
1191 | # define ALIGNMENT 4 /* Required by hardware */ | |
1192 | # endif | |
1193 | # ifdef IRIX5 | |
56293c2b | 1194 | # define HEURISTIC2 |
ed47971a LR |
1195 | extern int _fdata[]; |
1196 | # define DATASTART ((ptr_t)(_fdata)) | |
56293c2b BM |
1197 | # ifdef USE_MMAP |
1198 | # define HEAP_START (ptr_t)0x30000000 | |
1199 | # else | |
1200 | # define HEAP_START DATASTART | |
1201 | # endif | |
1202 | /* Lowest plausible heap address. */ | |
1203 | /* In the MMAP case, we map there. */ | |
1204 | /* In either case it is used to identify */ | |
1205 | /* heap sections so they're not */ | |
1206 | /* considered as roots. */ | |
70f72767 TT |
1207 | # define OS_TYPE "IRIX5" |
1208 | # define MPROTECT_VDB | |
1209 | # ifdef _MIPS_SZPTR | |
1210 | # define CPP_WORDSZ _MIPS_SZPTR | |
1211 | # define ALIGNMENT (_MIPS_SZPTR/8) | |
1212 | # if CPP_WORDSZ != 64 | |
1213 | # define ALIGN_DOUBLE | |
1214 | # endif | |
1215 | # else | |
1216 | # define ALIGNMENT 4 | |
1217 | # define ALIGN_DOUBLE | |
1218 | # endif | |
1219 | # define DYNAMIC_LOADING | |
1220 | # endif | |
abdbd4a8 BM |
1221 | # ifdef MSWINCE |
1222 | # define OS_TYPE "MSWINCE" | |
1223 | # define ALIGNMENT 4 | |
1224 | # define DATAEND /* not needed */ | |
1225 | # endif | |
1226 | # if defined(NETBSD) | |
abdbd4a8 | 1227 | # define OS_TYPE "NETBSD" |
179a9caf | 1228 | # define ALIGNMENT 4 |
abdbd4a8 | 1229 | # define HEURISTIC2 |
5a2586cf | 1230 | # define USE_GENERIC_PUSH_REGS |
179a9caf JT |
1231 | extern int _fdata[]; |
1232 | # define DATASTART ((ptr_t)(_fdata)) | |
1233 | extern int _end[]; | |
1234 | # define DATAEND ((ptr_t)(_end)) | |
1235 | # define DYNAMIC_LOADING | |
abdbd4a8 | 1236 | # endif |
70f72767 TT |
1237 | # endif |
1238 | ||
1239 | # ifdef RS6000 | |
1240 | # define MACH_TYPE "RS6000" | |
6cb3421f DE |
1241 | # ifdef __64BIT__ |
1242 | # define ALIGNMENT 8 | |
1243 | # define CPP_WORDSZ 64 | |
1244 | # else | |
1245 | # define ALIGNMENT 4 | |
1246 | # define CPP_WORDSZ 32 | |
1247 | # endif | |
ed47971a LR |
1248 | extern int _data[], _end[]; |
1249 | # define DATASTART ((ptr_t)((ulong)_data)) | |
1250 | # define DATAEND ((ptr_t)((ulong)_end)) | |
70f72767 TT |
1251 | extern int errno; |
1252 | # define STACKBOTTOM ((ptr_t)((ulong)&errno)) | |
6cb3421f | 1253 | # define USE_GENERIC_PUSH_REGS |
70f72767 TT |
1254 | # define DYNAMIC_LOADING |
1255 | /* For really old versions of AIX, this may have to be removed. */ | |
1256 | # endif | |
1257 | ||
1258 | # ifdef HP_PA | |
1259 | # define MACH_TYPE "HP_PA" | |
56293c2b BM |
1260 | # ifdef __LP64__ |
1261 | # define CPP_WORDSZ 64 | |
1262 | # define ALIGNMENT 8 | |
1263 | # else | |
1264 | # define CPP_WORDSZ 32 | |
1265 | # define ALIGNMENT 4 | |
1266 | # define ALIGN_DOUBLE | |
1267 | # endif | |
4c7726b1 | 1268 | # if !defined(GC_HPUX_THREADS) && !defined(GC_LINUX_THREADS) |
abdbd4a8 BM |
1269 | # ifndef LINUX /* For now. */ |
1270 | # define MPROTECT_VDB | |
1271 | # endif | |
1272 | # else | |
1273 | # define GENERIC_COMPARE_AND_SWAP | |
1274 | /* No compare-and-swap instruction. Use pthread mutexes */ | |
1275 | /* when we absolutely have to. */ | |
1276 | # ifdef PARALLEL_MARK | |
1277 | # define USE_MARK_BYTES | |
1278 | /* Minimize compare-and-swap usage. */ | |
1279 | # endif | |
1280 | # endif | |
1281 | # define STACK_GROWS_UP | |
1282 | # ifdef HPUX | |
4c7726b1 | 1283 | # define OS_TYPE "HPUX" |
ed47971a LR |
1284 | extern int __data_start[]; |
1285 | # define DATASTART ((ptr_t)(__data_start)) | |
abdbd4a8 | 1286 | # if 0 |
70f72767 TT |
1287 | /* The following appears to work for 7xx systems running HP/UX */ |
1288 | /* 9.xx Furthermore, it might result in much faster */ | |
1289 | /* collections than HEURISTIC2, which may involve scanning */ | |
1290 | /* segments that directly precede the stack. It is not the */ | |
1291 | /* default, since it may not work on older machine/OS */ | |
1292 | /* combinations. (Thanks to Raymond X.T. Nijssen for uncovering */ | |
1293 | /* this.) */ | |
1294 | # define STACKBOTTOM ((ptr_t) 0x7b033000) /* from /etc/conf/h/param.h */ | |
abdbd4a8 | 1295 | # else |
179977c1 | 1296 | /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */ |
abdbd4a8 BM |
1297 | /* to this. Note that the GC must be initialized before the */ |
1298 | /* first putenv call. */ | |
179977c1 BM |
1299 | extern char ** environ; |
1300 | # define STACKBOTTOM ((ptr_t)environ) | |
abdbd4a8 BM |
1301 | # endif |
1302 | # define DYNAMIC_LOADING | |
1303 | # include <unistd.h> | |
1304 | # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE) | |
1305 | # ifndef __GNUC__ | |
1306 | # define PREFETCH(x) { \ | |
1307 | register long addr = (long)(x); \ | |
1308 | (void) _asm ("LDW", 0, 0, addr, 0); \ | |
1309 | } | |
1310 | # endif | |
1311 | # endif /* HPUX */ | |
1312 | # ifdef LINUX | |
1313 | # define OS_TYPE "LINUX" | |
1314 | # define LINUX_STACKBOTTOM | |
1315 | # define DYNAMIC_LOADING | |
1316 | # define LINUX_DATA_START | |
ed47971a LR |
1317 | extern int _end[]; |
1318 | # define DATAEND (_end) | |
abdbd4a8 BM |
1319 | # endif /* LINUX */ |
1320 | # endif /* HP_PA */ | |
70f72767 TT |
1321 | |
1322 | # ifdef ALPHA | |
1323 | # define MACH_TYPE "ALPHA" | |
1324 | # define ALIGNMENT 8 | |
abdbd4a8 BM |
1325 | # ifdef NETBSD |
1326 | # define OS_TYPE "NETBSD" | |
1327 | # define HEURISTIC2 | |
1328 | # define DATASTART GC_data_start | |
1329 | # define ELFCLASS32 32 | |
1330 | # define ELFCLASS64 64 | |
1331 | # define ELF_CLASS ELFCLASS64 | |
1332 | # define CPP_WORDSZ 64 | |
1333 | # define DYNAMIC_LOADING | |
1334 | # endif | |
4c7726b1 BM |
1335 | # ifdef OPENBSD |
1336 | # define OS_TYPE "OPENBSD" | |
1337 | # define HEURISTIC2 | |
1338 | # define CPP_WORDSZ 64 | |
1339 | # ifdef __ELF__ /* since OpenBSD/Alpha 2.9 */ | |
1340 | # define DATASTART GC_data_start | |
1341 | # define ELFCLASS32 32 | |
1342 | # define ELFCLASS64 64 | |
1343 | # define ELF_CLASS ELFCLASS64 | |
1344 | # else /* ECOFF, until OpenBSD/Alpha 2.7 */ | |
1345 | # define DATASTART ((ptr_t) 0x140000000) | |
1346 | # endif | |
1347 | # endif | |
c0561434 LR |
1348 | # ifdef FREEBSD |
1349 | # define OS_TYPE "FREEBSD" | |
1350 | /* MPROTECT_VDB is not yet supported at all on FreeBSD/alpha. */ | |
1351 | # define SIG_SUSPEND SIGUSR1 | |
1352 | # define SIG_THR_RESTART SIGUSR2 | |
1353 | # define FREEBSD_STACKBOTTOM | |
1354 | # ifdef __ELF__ | |
1355 | # define DYNAMIC_LOADING | |
1356 | # endif | |
1357 | /* Handle unmapped hole alpha*-*-freebsd[45]* puts between etext and edata. */ | |
ed47971a LR |
1358 | extern char etext[]; |
1359 | extern char edata[]; | |
1360 | extern char end[]; | |
c0561434 | 1361 | # define NEED_FIND_LIMIT |
ed47971a | 1362 | # define DATASTART ((ptr_t)(etext)) |
c0561434 | 1363 | # define DATAEND (GC_find_limit (DATASTART, TRUE)) |
ed47971a LR |
1364 | # define DATASTART2 ((ptr_t)(edata)) |
1365 | # define DATAEND2 ((ptr_t)(end)) | |
c0561434 LR |
1366 | # define CPP_WORDSZ 64 |
1367 | # endif | |
70f72767 TT |
1368 | # ifdef OSF1 |
1369 | # define OS_TYPE "OSF1" | |
1370 | # define DATASTART ((ptr_t) 0x140000000) | |
ed47971a LR |
1371 | extern int _end[]; |
1372 | # define DATAEND ((ptr_t) _end) | |
abdbd4a8 BM |
1373 | extern char ** environ; |
1374 | /* round up from the value of environ to the nearest page boundary */ | |
1375 | /* Probably breaks if putenv is called before collector */ | |
1376 | /* initialization. */ | |
1377 | # define STACKBOTTOM ((ptr_t)(((word)(environ) | (getpagesize()-1))+1)) | |
1378 | /* # define HEURISTIC2 */ | |
70f72767 TT |
1379 | /* Normally HEURISTIC2 is too conervative, since */ |
1380 | /* the text segment immediately follows the stack. */ | |
1381 | /* Hence we give an upper pound. */ | |
abdbd4a8 | 1382 | /* This is currently unused, since we disabled HEURISTIC2 */ |
ed47971a LR |
1383 | extern int __start[]; |
1384 | # define HEURISTIC2_LIMIT ((ptr_t)((word)(__start) & ~(getpagesize()-1))) | |
70f72767 TT |
1385 | # define CPP_WORDSZ 64 |
1386 | # define MPROTECT_VDB | |
1387 | # define DYNAMIC_LOADING | |
1388 | # endif | |
1389 | # ifdef LINUX | |
1390 | # define OS_TYPE "LINUX" | |
1391 | # define CPP_WORDSZ 64 | |
1392 | # define STACKBOTTOM ((ptr_t) 0x120000000) | |
1393 | # ifdef __ELF__ | |
abdbd4a8 BM |
1394 | # define SEARCH_FOR_DATA_START |
1395 | # define DATASTART GC_data_start | |
85f29b3b | 1396 | # define DYNAMIC_LOADING |
70f72767 TT |
1397 | # else |
1398 | # define DATASTART ((ptr_t) 0x140000000) | |
1399 | # endif | |
ed47971a LR |
1400 | extern int _end[]; |
1401 | # define DATAEND (_end) | |
70f72767 TT |
1402 | # define MPROTECT_VDB |
1403 | /* Has only been superficially tested. May not */ | |
1404 | /* work on all versions. */ | |
1405 | # endif | |
1406 | # endif | |
1407 | ||
56293c2b BM |
1408 | # ifdef IA64 |
1409 | # define MACH_TYPE "IA64" | |
56293c2b | 1410 | # define USE_GENERIC_PUSH_REGS |
abdbd4a8 BM |
1411 | /* We need to get preserved registers in addition to register */ |
1412 | /* windows. That's easiest to do with setjmp. */ | |
1413 | # ifdef PARALLEL_MARK | |
1414 | # define USE_MARK_BYTES | |
1415 | /* Compare-and-exchange is too expensive to use for */ | |
1416 | /* setting mark bits. */ | |
1417 | # endif | |
56293c2b | 1418 | # ifdef HPUX |
4c7726b1 BM |
1419 | # ifdef _ILP32 |
1420 | # define CPP_WORDSZ 32 | |
1421 | # define ALIGN_DOUBLE | |
1422 | /* Requires 8 byte alignment for malloc */ | |
1423 | # define ALIGNMENT 4 | |
1424 | # else | |
1425 | # ifndef _LP64 | |
1426 | ---> unknown ABI | |
1427 | # endif | |
1428 | # define CPP_WORDSZ 64 | |
1429 | # define ALIGN_DOUBLE | |
1430 | /* Requires 16 byte alignment for malloc */ | |
1431 | # define ALIGNMENT 8 | |
1432 | # endif | |
1433 | # define OS_TYPE "HPUX" | |
ed47971a LR |
1434 | extern int __data_start[]; |
1435 | # define DATASTART ((ptr_t)(__data_start)) | |
4c7726b1 BM |
1436 | /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */ |
1437 | /* to this. Note that the GC must be initialized before the */ | |
1438 | /* first putenv call. */ | |
1439 | extern char ** environ; | |
1440 | # define STACKBOTTOM ((ptr_t)environ) | |
1441 | # define DYNAMIC_LOADING | |
1442 | # include <unistd.h> | |
1443 | # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE) | |
1444 | /* The following was empirically determined, and is probably */ | |
1445 | /* not very robust. */ | |
1446 | /* Note that the backing store base seems to be at a nice */ | |
1447 | /* address minus one page. */ | |
1448 | # define BACKING_STORE_DISPLACEMENT 0x1000000 | |
1449 | # define BACKING_STORE_ALIGNMENT 0x1000 | |
1450 | # define BACKING_STORE_BASE \ | |
1451 | (ptr_t)(((word)GC_stackbottom - BACKING_STORE_DISPLACEMENT - 1) \ | |
1452 | & ~(BACKING_STORE_ALIGNMENT - 1)) | |
56293c2b BM |
1453 | # endif |
1454 | # ifdef LINUX | |
4c7726b1 BM |
1455 | # define CPP_WORDSZ 64 |
1456 | # define ALIGN_DOUBLE | |
1457 | /* Requires 16 byte alignment for malloc */ | |
1458 | # define ALIGNMENT 8 | |
56293c2b | 1459 | # define OS_TYPE "LINUX" |
abdbd4a8 BM |
1460 | /* The following works on NUE and older kernels: */ |
1461 | /* # define STACKBOTTOM ((ptr_t) 0xa000000000000000l) */ | |
1462 | /* This does not work on NUE: */ | |
1463 | # define LINUX_STACKBOTTOM | |
56293c2b | 1464 | /* We also need the base address of the register stack */ |
abdbd4a8 BM |
1465 | /* backing store. This is computed in */ |
1466 | /* GC_linux_register_stack_base based on the following */ | |
1467 | /* constants: */ | |
1468 | # define BACKING_STORE_ALIGNMENT 0x100000 | |
1469 | # define BACKING_STORE_DISPLACEMENT 0x80000000 | |
1470 | extern char * GC_register_stackbottom; | |
1471 | # define BACKING_STORE_BASE ((ptr_t)GC_register_stackbottom) | |
1472 | # define SEARCH_FOR_DATA_START | |
1473 | # define DATASTART GC_data_start | |
79f777fd BM |
1474 | # ifdef __GNUC__ |
1475 | # define DYNAMIC_LOADING | |
1476 | # else | |
1477 | /* In the Intel compiler environment, we seem to end up with */ | |
1478 | /* statically linked executables and an undefined reference */ | |
1479 | /* to _DYNAMIC */ | |
1480 | # endif | |
56293c2b BM |
1481 | # define MPROTECT_VDB |
1482 | /* Requires Linux 2.3.47 or later. */ | |
ed47971a LR |
1483 | extern int _end[]; |
1484 | # define DATAEND (_end) | |
abdbd4a8 BM |
1485 | # ifdef __GNUC__ |
1486 | # define PREFETCH(x) \ | |
1487 | __asm__ (" lfetch [%0]": : "r"((void *)(x))) | |
1488 | # define PREFETCH_FOR_WRITE(x) \ | |
1489 | __asm__ (" lfetch.excl [%0]": : "r"((void *)(x))) | |
1490 | # define CLEAR_DOUBLE(x) \ | |
1491 | __asm__ (" stf.spill [%0]=f0": : "r"((void *)(x))) | |
1492 | # endif | |
56293c2b BM |
1493 | # endif |
1494 | # endif | |
1495 | ||
70f72767 TT |
1496 | # ifdef M88K |
1497 | # define MACH_TYPE "M88K" | |
1498 | # define ALIGNMENT 4 | |
1499 | # define ALIGN_DOUBLE | |
ed47971a | 1500 | extern int etext[]; |
70f72767 TT |
1501 | # ifdef CX_UX |
1502 | # define OS_TYPE "CX_UX" | |
ed47971a | 1503 | # define DATASTART ((((word)etext + 0x3fffff) & ~0x3fffff) + 0x10000) |
70f72767 TT |
1504 | # endif |
1505 | # ifdef DGUX | |
1506 | # define OS_TYPE "DGUX" | |
1507 | extern char * GC_SysVGetDataStart(); | |
ed47971a | 1508 | # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, etext) |
70f72767 TT |
1509 | # endif |
1510 | # define STACKBOTTOM ((char*)0xf0000000) /* determined empirically */ | |
1511 | # endif | |
1512 | ||
1513 | # ifdef S370 | |
1514 | # define MACH_TYPE "S370" | |
70f72767 | 1515 | # define ALIGNMENT 4 /* Required by hardware */ |
abdbd4a8 BM |
1516 | # define USE_GENERIC_PUSH_REGS |
1517 | # ifdef UTS4 | |
1518 | # define OS_TYPE "UTS4" | |
ed47971a LR |
1519 | extern int etext[]; |
1520 | extern int _etext[]; | |
1521 | extern int _end[]; | |
70f72767 | 1522 | extern char * GC_SysVGetDataStart(); |
ed47971a LR |
1523 | # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, _etext) |
1524 | # define DATAEND (_end) | |
70f72767 | 1525 | # define HEURISTIC2 |
abdbd4a8 | 1526 | # endif |
10a197ee UW |
1527 | # endif |
1528 | ||
1529 | # ifdef S390 | |
1530 | # define MACH_TYPE "S390" | |
1531 | # define USE_GENERIC_PUSH_REGS | |
1532 | # ifndef __s390x__ | |
1533 | # define ALIGNMENT 4 | |
1534 | # define CPP_WORDSZ 32 | |
1535 | # else | |
1536 | # define ALIGNMENT 8 | |
1537 | # define CPP_WORDSZ 64 | |
1538 | # define HBLKSIZE 4096 | |
1539 | # endif | |
abdbd4a8 BM |
1540 | # ifdef LINUX |
1541 | # define OS_TYPE "LINUX" | |
10a197ee | 1542 | # define LINUX_STACKBOTTOM |
abdbd4a8 | 1543 | # define DYNAMIC_LOADING |
ed47971a LR |
1544 | extern int __data_start[]; |
1545 | # define DATASTART ((ptr_t)(__data_start)) | |
10a197ee UW |
1546 | extern int _end[]; |
1547 | # define DATAEND (_end) | |
1548 | # define CACHE_LINE_SIZE 256 | |
1549 | # define GETPAGESIZE() 4096 | |
abdbd4a8 | 1550 | # endif |
70f72767 TT |
1551 | # endif |
1552 | ||
56293c2b BM |
1553 | # if defined(PJ) |
1554 | # define ALIGNMENT 4 | |
ed47971a LR |
1555 | extern int _etext[]; |
1556 | # define DATASTART ((ptr_t)(_etext)) | |
56293c2b BM |
1557 | # define HEURISTIC1 |
1558 | # endif | |
1559 | ||
1560 | # ifdef ARM32 | |
1561 | # define CPP_WORDSZ 32 | |
1562 | # define MACH_TYPE "ARM32" | |
1563 | # define ALIGNMENT 4 | |
1564 | # ifdef NETBSD | |
1565 | # define OS_TYPE "NETBSD" | |
1566 | # define HEURISTIC2 | |
ed47971a LR |
1567 | extern char etext[]; |
1568 | # define DATASTART ((ptr_t)(etext)) | |
56293c2b BM |
1569 | # define USE_GENERIC_PUSH_REGS |
1570 | # endif | |
1571 | # ifdef LINUX | |
1572 | # define OS_TYPE "LINUX" | |
1573 | # define HEURISTIC1 | |
1574 | # undef STACK_GRAN | |
1575 | # define STACK_GRAN 0x10000000 | |
1576 | # define USE_GENERIC_PUSH_REGS | |
1577 | # ifdef __ELF__ | |
1578 | # define DYNAMIC_LOADING | |
1579 | # include <features.h> | |
1580 | # if defined(__GLIBC__) && __GLIBC__ >= 2 | |
1581 | # define LINUX_DATA_START | |
1582 | # else | |
1583 | extern char **__environ; | |
1584 | # define DATASTART ((ptr_t)(&__environ)) | |
1585 | /* hideous kludge: __environ is the first */ | |
1586 | /* word in crt0.o, and delimits the start */ | |
1587 | /* of the data segment, no matter which */ | |
1588 | /* ld options were passed through. */ | |
1589 | /* We could use _etext instead, but that */ | |
1590 | /* would include .rodata, which may */ | |
1591 | /* contain large read-only data tables */ | |
1592 | /* that we'd rather not scan. */ | |
1593 | # endif | |
ed47971a LR |
1594 | extern int _end[]; |
1595 | # define DATAEND (_end) | |
56293c2b | 1596 | # else |
ed47971a LR |
1597 | extern int etext[]; |
1598 | # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff)) | |
56293c2b BM |
1599 | # endif |
1600 | # endif | |
abdbd4a8 BM |
1601 | # ifdef MSWINCE |
1602 | # define OS_TYPE "MSWINCE" | |
1603 | # define DATAEND /* not needed */ | |
1604 | # endif | |
b6459d9a AG |
1605 | # ifdef NOSYS |
1606 | /* __data_start is usually defined in the target linker script. */ | |
ed47971a LR |
1607 | extern int __data_start[]; |
1608 | # define DATASTART (ptr_t)(__data_start) | |
b6459d9a AG |
1609 | # define USE_GENERIC_PUSH_REGS |
1610 | /* __stack_base__ is set in newlib/libc/sys/arm/crt0.S */ | |
1611 | extern void *__stack_base__; | |
1612 | # define STACKBOTTOM ((ptr_t) (__stack_base__)) | |
1613 | # endif | |
56293c2b BM |
1614 | #endif |
1615 | ||
abdbd4a8 BM |
1616 | # ifdef SH |
1617 | # define MACH_TYPE "SH" | |
1618 | # define ALIGNMENT 4 | |
1619 | # ifdef MSWINCE | |
1620 | # define OS_TYPE "MSWINCE" | |
1621 | # define DATAEND /* not needed */ | |
1622 | # endif | |
1623 | # ifdef LINUX | |
1624 | # define OS_TYPE "LINUX" | |
1625 | # define STACKBOTTOM ((ptr_t) 0x7c000000) | |
1626 | # define USE_GENERIC_PUSH_REGS | |
1627 | # define DYNAMIC_LOADING | |
1628 | # define LINUX_DATA_START | |
ed47971a LR |
1629 | extern int _end[]; |
1630 | # define DATAEND (_end) | |
abdbd4a8 BM |
1631 | # endif |
1632 | # endif | |
1633 | ||
1634 | # ifdef SH4 | |
1635 | # define MACH_TYPE "SH4" | |
1636 | # define OS_TYPE "MSWINCE" | |
1637 | # define ALIGNMENT 4 | |
1638 | # define DATAEND /* not needed */ | |
1639 | # endif | |
1640 | ||
48528b67 BT |
1641 | # ifdef X86_64 |
1642 | # define MACH_TYPE "X86_64" | |
1643 | # define ALIGNMENT 8 | |
1644 | # define CPP_WORDSZ 64 | |
1645 | # define CACHE_LINE_SIZE 64 | |
1646 | # define USE_GENERIC_PUSH_REGS | |
48528b67 BT |
1647 | # ifdef LINUX |
1648 | # define OS_TYPE "LINUX" | |
1649 | # define LINUX_STACKBOTTOM | |
1650 | # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC) | |
1651 | # define MPROTECT_VDB | |
1652 | # else | |
1653 | /* We seem to get random errors in incremental mode, */ | |
1654 | /* possibly because Linux threads is itself a malloc client */ | |
1655 | /* and can't deal with the signals. */ | |
1656 | # endif | |
1657 | # ifdef __ELF__ | |
1658 | # define DYNAMIC_LOADING | |
1659 | # ifdef UNDEFINED /* includes ro data */ | |
1660 | extern int _etext[]; | |
1661 | # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff)) | |
1662 | # endif | |
1663 | # include <features.h> | |
1664 | # define LINUX_DATA_START | |
1665 | extern int _end[]; | |
1666 | # define DATAEND (_end) | |
1667 | # else | |
1668 | extern int etext[]; | |
1669 | # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff)) | |
1670 | # endif | |
1671 | # define PREFETCH(x) \ | |
1672 | __asm__ __volatile__ (" prefetch %0": : "m"(*(char *)(x))) | |
1673 | # define PREFETCH_FOR_WRITE(x) \ | |
1674 | __asm__ __volatile__ (" prefetchw %0": : "m"(*(char *)(x))) | |
1675 | # endif | |
1676 | # endif | |
1677 | ||
56293c2b BM |
1678 | #ifdef LINUX_DATA_START |
1679 | /* Some Linux distributions arrange to define __data_start. Some */ | |
1680 | /* define data_start as a weak symbol. The latter is technically */ | |
1681 | /* broken, since the user program may define data_start, in which */ | |
1682 | /* case we lose. Nonetheless, we try both, prefering __data_start. */ | |
1683 | /* We assume gcc. */ | |
1684 | # pragma weak __data_start | |
ed47971a | 1685 | extern int __data_start[]; |
56293c2b | 1686 | # pragma weak data_start |
ed47971a LR |
1687 | extern int data_start[]; |
1688 | # define DATASTART ((ptr_t)(__data_start != 0? __data_start : data_start)) | |
56293c2b BM |
1689 | #endif |
1690 | ||
abdbd4a8 BM |
1691 | #if defined(LINUX) && defined(REDIRECT_MALLOC) |
1692 | /* Rld appears to allocate some memory with its own allocator, and */ | |
1693 | /* some through malloc, which might be redirected. To make this */ | |
1694 | /* work with collectable memory, we have to scan memory allocated */ | |
1695 | /* by rld's internal malloc. */ | |
1696 | # define USE_PROC_FOR_LIBRARIES | |
1697 | #endif | |
1698 | ||
70f72767 TT |
1699 | # ifndef STACK_GROWS_UP |
1700 | # define STACK_GROWS_DOWN | |
1701 | # endif | |
1702 | ||
1703 | # ifndef CPP_WORDSZ | |
1704 | # define CPP_WORDSZ 32 | |
1705 | # endif | |
1706 | ||
1707 | # ifndef OS_TYPE | |
1708 | # define OS_TYPE "" | |
1709 | # endif | |
1710 | ||
1711 | # ifndef DATAEND | |
ed47971a LR |
1712 | extern int end[]; |
1713 | # define DATAEND (end) | |
70f72767 TT |
1714 | # endif |
1715 | ||
1716 | # if defined(SVR4) && !defined(GETPAGESIZE) | |
1717 | # include <unistd.h> | |
1718 | # define GETPAGESIZE() sysconf(_SC_PAGESIZE) | |
1719 | # endif | |
1720 | ||
1721 | # ifndef GETPAGESIZE | |
1722 | # if defined(SUNOS5) || defined(IRIX5) | |
1723 | # include <unistd.h> | |
1724 | # endif | |
1725 | # define GETPAGESIZE() getpagesize() | |
1726 | # endif | |
1727 | ||
1728 | # if defined(SUNOS5) || defined(DRSNX) || defined(UTS4) | |
1729 | /* OS has SVR4 generic features. Probably others also qualify. */ | |
1730 | # define SVR4 | |
1731 | # endif | |
1732 | ||
1733 | # if defined(SUNOS5) || defined(DRSNX) | |
1734 | /* OS has SUNOS5 style semi-undocumented interface to dynamic */ | |
1735 | /* loader. */ | |
1736 | # define SUNOS5DL | |
1737 | /* OS has SUNOS5 style signal handlers. */ | |
1738 | # define SUNOS5SIGS | |
1739 | # endif | |
1740 | ||
56293c2b BM |
1741 | # if defined(HPUX) |
1742 | # define SUNOS5SIGS | |
1743 | # endif | |
1744 | ||
abdbd4a8 BM |
1745 | # if defined(SVR4) || defined(LINUX) || defined(IRIX) || defined(HPUX) \ |
1746 | || defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD) \ | |
6cb3421f | 1747 | || defined(BSD) || defined(_AIX) || defined(MACOSX) || defined(OSF1) |
abdbd4a8 BM |
1748 | # define UNIX_LIKE /* Basic Unix-like system calls work. */ |
1749 | # endif | |
1750 | ||
70f72767 TT |
1751 | # if CPP_WORDSZ != 32 && CPP_WORDSZ != 64 |
1752 | -> bad word size | |
1753 | # endif | |
1754 | ||
1755 | # ifdef PCR | |
1756 | # undef DYNAMIC_LOADING | |
1757 | # undef STACKBOTTOM | |
1758 | # undef HEURISTIC1 | |
1759 | # undef HEURISTIC2 | |
1760 | # undef PROC_VDB | |
1761 | # undef MPROTECT_VDB | |
1762 | # define PCR_VDB | |
1763 | # endif | |
1764 | ||
1765 | # ifdef SRC_M3 | |
1766 | /* Postponed for now. */ | |
1767 | # undef PROC_VDB | |
1768 | # undef MPROTECT_VDB | |
1769 | # endif | |
1770 | ||
1771 | # ifdef SMALL_CONFIG | |
1772 | /* Presumably not worth the space it takes. */ | |
1773 | # undef PROC_VDB | |
1774 | # undef MPROTECT_VDB | |
1775 | # endif | |
1776 | ||
85f29b3b TT |
1777 | # ifdef USE_MUNMAP |
1778 | # undef MPROTECT_VDB /* Can't deal with address space holes. */ | |
1779 | # endif | |
1780 | ||
abdbd4a8 BM |
1781 | # ifdef PARALLEL_MARK |
1782 | # undef MPROTECT_VDB /* For now. */ | |
1783 | # endif | |
1784 | ||
70f72767 TT |
1785 | # if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB) |
1786 | # define DEFAULT_VDB | |
1787 | # endif | |
1788 | ||
56293c2b BM |
1789 | # ifndef PREFETCH |
1790 | # define PREFETCH(x) | |
1791 | # define NO_PREFETCH | |
1792 | # endif | |
1793 | ||
1794 | # ifndef PREFETCH_FOR_WRITE | |
1795 | # define PREFETCH_FOR_WRITE(x) | |
1796 | # define NO_PREFETCH_FOR_WRITE | |
1797 | # endif | |
1798 | ||
1799 | # ifndef CACHE_LINE_SIZE | |
1800 | # define CACHE_LINE_SIZE 32 /* Wild guess */ | |
1801 | # endif | |
1802 | ||
1803 | # ifndef CLEAR_DOUBLE | |
1804 | # define CLEAR_DOUBLE(x) \ | |
1805 | ((word*)x)[0] = 0; \ | |
1806 | ((word*)x)[1] = 0; | |
1807 | # endif /* CLEAR_DOUBLE */ | |
1808 | ||
4c7726b1 BM |
1809 | /* Internally we use GC_SOLARIS_THREADS to test for either old or pthreads. */ |
1810 | # if defined(GC_SOLARIS_PTHREADS) && !defined(GC_SOLARIS_THREADS) | |
1811 | # define GC_SOLARIS_THREADS | |
70f72767 | 1812 | # endif |
4c7726b1 BM |
1813 | |
1814 | # if defined(GC_IRIX_THREADS) && !defined(IRIX5) | |
70f72767 TT |
1815 | --> inconsistent configuration |
1816 | # endif | |
4c7726b1 | 1817 | # if defined(GC_LINUX_THREADS) && !defined(LINUX) |
70f72767 TT |
1818 | --> inconsistent configuration |
1819 | # endif | |
4c7726b1 | 1820 | # if defined(GC_SOLARIS_THREADS) && !defined(SUNOS5) |
70f72767 TT |
1821 | --> inconsistent configuration |
1822 | # endif | |
4c7726b1 | 1823 | # if defined(GC_HPUX_THREADS) && !defined(HPUX) |
56293c2b BM |
1824 | --> inconsistent configuration |
1825 | # endif | |
4c7726b1 BM |
1826 | # if defined(GC_WIN32_THREADS) && !defined(MSWIN32) |
1827 | /* Ideally CYGWIN32 should work, in addition to MSWIN32. I suspect */ | |
1828 | /* the necessary code is mostly there, but nobody has actually made */ | |
1829 | /* sure the right combination of pieces is compiled in, etc. */ | |
5a2586cf TT |
1830 | --> inconsistent configuration |
1831 | # endif | |
4c7726b1 | 1832 | |
70f72767 | 1833 | # if defined(PCR) || defined(SRC_M3) || \ |
4c7726b1 BM |
1834 | defined(GC_SOLARIS_THREADS) || defined(GC_WIN32_THREADS) || \ |
1835 | defined(GC_PTHREADS) | |
70f72767 TT |
1836 | # define THREADS |
1837 | # endif | |
1838 | ||
abdbd4a8 BM |
1839 | # if defined(HP_PA) || defined(M88K) || defined(POWERPC) && !defined(MACOSX) \ |
1840 | || defined(LINT) || defined(MSWINCE) \ | |
1841 | || (defined(I386) && defined(__LCC__)) | |
1842 | /* Use setjmp based hack to mark from callee-save registers. */ | |
1843 | /* The define should move to the individual platform */ | |
1844 | /* descriptions. */ | |
70f72767 TT |
1845 | # define USE_GENERIC_PUSH_REGS |
1846 | # endif | |
79f777fd BM |
1847 | |
1848 | # if defined(SPARC) | |
1849 | # define ASM_CLEAR_CODE /* Stack clearing is crucial, and we */ | |
1850 | /* include assembly code to do it well. */ | |
1851 | # endif | |
1852 | ||
1853 | /* Can we save call chain in objects for debugging? */ | |
1854 | /* SET NFRAMES (# of saved frames) and NARGS (#of args for each frame) */ | |
1855 | /* to reasonable values for the platform. */ | |
1856 | /* Set SAVE_CALL_CHAIN if we can. SAVE_CALL_COUNT can be specified at */ | |
1857 | /* build time, though we feel free to adjust it slightly. */ | |
1858 | /* Define NEED_CALLINFO if we either save the call stack or */ | |
1859 | /* GC_ADD_CALLER is defined. */ | |
1860 | #ifdef LINUX | |
1861 | # include <features.h> | |
1862 | # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 || __GLIBC__ > 2 | |
1863 | # define HAVE_BUILTIN_BACKTRACE | |
1864 | # endif | |
1865 | #endif | |
1866 | ||
1867 | #if defined(SPARC) | |
1868 | # define CAN_SAVE_CALL_STACKS | |
1869 | # define CAN_SAVE_CALL_ARGS | |
1870 | #endif | |
48528b67 | 1871 | #if (defined(I386) || defined(X86_64)) && defined(LINUX) |
abdbd4a8 BM |
1872 | /* SAVE_CALL_CHAIN is supported if the code is compiled to save */ |
1873 | /* frame pointers by default, i.e. no -fomit-frame-pointer flag. */ | |
79f777fd BM |
1874 | # define CAN_SAVE_CALL_STACKS |
1875 | # define CAN_SAVE_CALL_ARGS | |
1876 | #endif | |
1877 | #if defined(HAVE_BUILTIN_BACKTRACE) && !defined(CAN_SAVE_CALL_STACKS) | |
1878 | # define CAN_SAVE_CALL_STACKS | |
1879 | #endif | |
1880 | ||
1881 | # if defined(SAVE_CALL_COUNT) && !defined(GC_ADD_CALLER) \ | |
1882 | && defined(CAN_SAVE_CALL_STACKS) | |
abdbd4a8 BM |
1883 | # define SAVE_CALL_CHAIN |
1884 | # endif | |
79f777fd BM |
1885 | # ifdef SAVE_CALL_CHAIN |
1886 | # if defined(SAVE_CALL_NARGS) && defined(CAN_SAVE_CALL_ARGS) | |
1887 | # define NARGS SAVE_CALL_NARGS | |
1888 | # else | |
1889 | # define NARGS 0 /* Number of arguments to save for each call. */ | |
1890 | # endif | |
abdbd4a8 | 1891 | # endif |
79f777fd BM |
1892 | # ifdef SAVE_CALL_CHAIN |
1893 | # ifndef SAVE_CALL_COUNT | |
1894 | # define NFRAMES 6 /* Number of frames to save. Even for */ | |
1895 | /* alignment reasons. */ | |
1896 | # else | |
1897 | # define NFRAMES ((SAVE_CALL_COUNT + 1) & ~1) | |
1898 | # endif | |
1899 | # define NEED_CALLINFO | |
1900 | # endif /* SAVE_CALL_CHAIN */ | |
1901 | # ifdef GC_ADD_CALLER | |
1902 | # define NFRAMES 1 | |
1903 | # define NARGS 0 | |
1904 | # define NEED_CALLINFO | |
1905 | # endif | |
1906 | ||
1907 | # if defined(MAKE_BACK_GRAPH) && !defined(DBG_HDRS_ALL) | |
1908 | # define DBG_HDRS_ALL | |
70f72767 TT |
1909 | # endif |
1910 | ||
56293c2b | 1911 | # endif /* GCCONFIG_H */ |