/vendor/gc/include/private/gcconfig.h

http://github.com/feyeleanor/RubyGoLightly · C++ Header · 2364 lines · 1793 code · 86 blank · 485 comment · 380 complexity · 24cbc177235511924cd170c144594d23 MD5 · raw file

Large files are truncated click here to view the full file

  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.
  5. * Copyright (c) 2000-2004 Hewlett-Packard Development Company, L.P.
  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. /*
  17. * This header is private to the gc. It is almost always included from
  18. * gc_priv.h. However it is possible to include it by itself if just the
  19. * configuration macros are needed. In that
  20. * case, a few declarations relying on types declared in gc_priv.h will be
  21. * omitted.
  22. */
  23. #ifndef GCCONFIG_H
  24. # define GCCONFIG_H
  25. # ifndef GC_PRIVATE_H
  26. /* Fake ptr_t declaration, just to avoid compilation errors. */
  27. /* This avoids many instances if "ifndef GC_PRIVATE_H" below. */
  28. typedef struct GC_undefined_struct * ptr_t;
  29. # include <stddef.h> /* For size_t etc. */
  30. # endif
  31. /* Machine dependent parameters. Some tuning parameters can be found */
  32. /* near the top of gc_private.h. */
  33. /* Machine specific parts contributed by various people. See README file. */
  34. /* First a unified test for Linux: */
  35. # if defined(linux) || defined(__linux__)
  36. # ifndef LINUX
  37. # define LINUX
  38. # endif
  39. # endif
  40. /* And one for NetBSD: */
  41. # if defined(__NetBSD__)
  42. # define NETBSD
  43. # endif
  44. /* And one for OpenBSD: */
  45. # if defined(__OpenBSD__)
  46. # define OPENBSD
  47. # endif
  48. /* And one for FreeBSD: */
  49. # if (defined(__FreeBSD__) || defined(__DragonFly__) || \
  50. defined(__FreeBSD_kernel__)) && !defined(FREEBSD)
  51. # define FREEBSD
  52. # endif
  53. /* Determine the machine type: */
  54. # if defined(__arm__) || defined(__thumb__)
  55. # define ARM32
  56. # if !defined(LINUX) && !defined(NETBSD)
  57. # define NOSYS
  58. # define mach_type_known
  59. # endif
  60. # endif
  61. # if defined(sun) && defined(mc68000)
  62. # error SUNOS4 no longer supported
  63. # endif
  64. # if defined(hp9000s300)
  65. # error M68K based HP machines no longer supported.
  66. # endif
  67. # if defined(OPENBSD) && defined(m68k)
  68. # define M68K
  69. # define mach_type_known
  70. # endif
  71. # if defined(OPENBSD) && defined(__sparc__)
  72. # define SPARC
  73. # define mach_type_known
  74. # endif
  75. # if defined(NETBSD) && (defined(m68k) || defined(__m68k__))
  76. # define M68K
  77. # define mach_type_known
  78. # endif
  79. # if defined(NETBSD) && defined(__powerpc__)
  80. # define POWERPC
  81. # define mach_type_known
  82. # endif
  83. # if defined(NETBSD) && (defined(__arm32__) || defined(__arm__))
  84. # define ARM32
  85. # define mach_type_known
  86. # endif
  87. # if defined(NETBSD) && defined(__sh__)
  88. # define SH
  89. # define mach_type_known
  90. # endif
  91. # if defined(vax)
  92. # define VAX
  93. # ifdef ultrix
  94. # define ULTRIX
  95. # else
  96. # define BSD
  97. # endif
  98. # define mach_type_known
  99. # endif
  100. # if defined(__NetBSD__) && defined(__vax__)
  101. # define VAX
  102. # define mach_type_known
  103. # endif
  104. # if defined(mips) || defined(__mips) || defined(_mips)
  105. # define MIPS
  106. # if defined(nec_ews) || defined(_nec_ews)
  107. # define EWS4800
  108. # endif
  109. # if !defined(LINUX) && !defined(EWS4800) && !defined(NETBSD)
  110. # if defined(ultrix) || defined(__ultrix)
  111. # define ULTRIX
  112. # else
  113. # define IRIX5 /* or IRIX 6.X */
  114. # endif
  115. # endif /* !LINUX */
  116. # if defined(__NetBSD__) && defined(__MIPSEL__)
  117. # undef ULTRIX
  118. # endif
  119. # define mach_type_known
  120. # endif
  121. # if defined(DGUX) && (defined(i386) || defined(__i386__))
  122. # define I386
  123. # ifndef _USING_DGUX
  124. # define _USING_DGUX
  125. # endif
  126. # define mach_type_known
  127. # endif
  128. # if defined(sequent) && (defined(i386) || defined(__i386__))
  129. # define I386
  130. # define SEQUENT
  131. # define mach_type_known
  132. # endif
  133. # if defined(sun) && (defined(i386) || defined(__i386__))
  134. # define I386
  135. # define SOLARIS
  136. # define mach_type_known
  137. # endif
  138. # if defined(sun) && defined(__amd64)
  139. # define X86_64
  140. # define SOLARIS
  141. # define mach_type_known
  142. # endif
  143. # if (defined(__OS2__) || defined(__EMX__)) && defined(__32BIT__)
  144. # define I386
  145. # define OS2
  146. # define mach_type_known
  147. # endif
  148. # if defined(ibm032)
  149. # error IBM PC/RT no longer supported.
  150. # endif
  151. # if defined(sun) && (defined(sparc) || defined(__sparc))
  152. # define SPARC
  153. /* Test for SunOS 5.x */
  154. # include <errno.h>
  155. # define SOLARIS
  156. # define mach_type_known
  157. # endif
  158. # if defined(sparc) && defined(unix) && !defined(sun) && !defined(linux) \
  159. && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__FreeBSD__) \
  160. && !defined(__DragonFly__)
  161. # define SPARC
  162. # define DRSNX
  163. # define mach_type_known
  164. # endif
  165. # if defined(_IBMR2)
  166. # define POWERPC
  167. # define AIX
  168. # define mach_type_known
  169. # endif
  170. # if defined(__NetBSD__) && defined(__sparc__)
  171. # define SPARC
  172. # define mach_type_known
  173. # endif
  174. # if defined(_M_XENIX) && defined(_M_SYSV) && defined(_M_I386)
  175. /* The above test may need refinement */
  176. # define I386
  177. # if defined(_SCO_ELF)
  178. # define SCO_ELF
  179. # else
  180. # define SCO
  181. # endif
  182. # define mach_type_known
  183. # endif
  184. # if defined(_AUX_SOURCE)
  185. # error A/UX no longer supported
  186. # endif
  187. # if defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0) \
  188. || defined(hppa) || defined(__hppa__)
  189. # define HP_PA
  190. # if !defined(LINUX) && !defined(HPUX)
  191. # define HPUX
  192. # endif
  193. # define mach_type_known
  194. # endif
  195. # if defined(__ia64) && (defined(_HPUX_SOURCE) || defined(__HP_aCC))
  196. # define IA64
  197. # ifndef HPUX
  198. # define HPUX
  199. # endif
  200. # define mach_type_known
  201. # endif
  202. # if defined(__BEOS__) && defined(_X86_)
  203. # define I386
  204. # define BEOS
  205. # define mach_type_known
  206. # endif
  207. # if defined(LINUX) && (defined(i386) || defined(__i386__))
  208. # define I386
  209. # define mach_type_known
  210. # endif
  211. # if defined(LINUX) && defined(__x86_64__)
  212. # define X86_64
  213. # define mach_type_known
  214. # endif
  215. # if defined(LINUX) && (defined(__ia64__) || defined(__ia64))
  216. # define IA64
  217. # define mach_type_known
  218. # endif
  219. # if defined(LINUX) && defined(__arm__)
  220. # define ARM32
  221. # define mach_type_known
  222. # endif
  223. # if defined(LINUX) && defined(__cris__)
  224. # ifndef CRIS
  225. # define CRIS
  226. # endif
  227. # define mach_type_known
  228. # endif
  229. # if defined(LINUX) && (defined(powerpc) || defined(__powerpc__) || \
  230. defined(powerpc64) || defined(__powerpc64__))
  231. # define POWERPC
  232. # define mach_type_known
  233. # endif
  234. # if defined(FREEBSD) && (defined(powerpc) || defined(__powerpc__))
  235. # define POWERPC
  236. # define mach_type_known
  237. # endif
  238. # if defined(LINUX) && defined(__mc68000__)
  239. # define M68K
  240. # define mach_type_known
  241. # endif
  242. # if defined(LINUX) && (defined(sparc) || defined(__sparc__))
  243. # define SPARC
  244. # define mach_type_known
  245. # endif
  246. # if defined(LINUX) && defined(__arm__)
  247. # define ARM32
  248. # define mach_type_known
  249. # endif
  250. # if defined(LINUX) && defined(__sh__)
  251. # define SH
  252. # define mach_type_known
  253. # endif
  254. # if defined(LINUX) && defined(__m32r__)
  255. # define M32R
  256. # define mach_type_known
  257. # endif
  258. # if defined(__alpha) || defined(__alpha__)
  259. # define ALPHA
  260. # if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD) && !defined(FREEBSD)
  261. # define OSF1 /* a.k.a Digital Unix */
  262. # endif
  263. # define mach_type_known
  264. # endif
  265. # if defined(_AMIGA) && !defined(AMIGA)
  266. # define AMIGA
  267. # endif
  268. # ifdef AMIGA
  269. # define M68K
  270. # define mach_type_known
  271. # endif
  272. # if defined(THINK_C) || defined(__MWERKS__) && !defined(__powerc)
  273. # define M68K
  274. # define MACOS
  275. # define mach_type_known
  276. # endif
  277. # if defined(__MWERKS__) && defined(__powerc) && !defined(__MACH__)
  278. # define POWERPC
  279. # define MACOS
  280. # define mach_type_known
  281. # endif
  282. # if defined(macosx) || (defined(__APPLE__) && defined(__MACH__))
  283. # define DARWIN
  284. # if defined(__ppc__) || defined(__ppc64__)
  285. # define POWERPC
  286. # define mach_type_known
  287. # elif defined(__x86_64__)
  288. # define X86_64
  289. # define mach_type_known
  290. # elif defined(__i386__)
  291. # define I386
  292. # define mach_type_known
  293. # endif
  294. # endif
  295. # if defined(NeXT) && defined(mc68000)
  296. # define M68K
  297. # define NEXT
  298. # define mach_type_known
  299. # endif
  300. # if defined(NeXT) && (defined(i386) || defined(__i386__))
  301. # define I386
  302. # define NEXT
  303. # define mach_type_known
  304. # endif
  305. # if defined(__OpenBSD__) && (defined(i386) || defined(__i386__))
  306. # define I386
  307. # define OPENBSD
  308. # define mach_type_known
  309. # endif
  310. # if defined(FREEBSD) && (defined(i386) || defined(__i386__))
  311. # define I386
  312. # define mach_type_known
  313. # endif
  314. # if defined(FREEBSD) && defined(__x86_64__)
  315. # define X86_64
  316. # define mach_type_known
  317. # endif
  318. # if defined(__NetBSD__) && (defined(i386) || defined(__i386__))
  319. # define I386
  320. # define mach_type_known
  321. # endif
  322. # if defined(__NetBSD__) && defined(__x86_64__)
  323. # define X86_64
  324. # define mach_type_known
  325. # endif
  326. # if defined(FREEBSD) && defined(__sparc__)
  327. # define SPARC
  328. # define mach_type_known
  329. # endif
  330. # if defined(bsdi) && (defined(i386) || defined(__i386__))
  331. # define I386
  332. # define BSDI
  333. # define mach_type_known
  334. # endif
  335. # if !defined(mach_type_known) && defined(__386BSD__)
  336. # define I386
  337. # define THREE86BSD
  338. # define mach_type_known
  339. # endif
  340. # if defined(_CX_UX) && defined(_M88K)
  341. # define M88K
  342. # define CX_UX
  343. # define mach_type_known
  344. # endif
  345. # if defined(DGUX) && defined(m88k)
  346. # define M88K
  347. /* DGUX defined */
  348. # define mach_type_known
  349. # endif
  350. # if defined(_WIN32_WCE)
  351. /* SH3, SH4, MIPS already defined for corresponding architectures */
  352. # if defined(SH3) || defined(SH4)
  353. # define SH
  354. # endif
  355. # if defined(x86)
  356. # define I386
  357. # endif
  358. # if defined(ARM)
  359. # define ARM32
  360. # endif
  361. # define MSWINCE
  362. # define mach_type_known
  363. # else
  364. # if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \
  365. || defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__CYGWIN__)
  366. # if defined(__LP64__) || defined(_WIN64)
  367. # define X86_64
  368. # else
  369. # define I386
  370. # endif
  371. # define MSWIN32 /* or Win64 */
  372. # define mach_type_known
  373. # endif
  374. # if defined(_MSC_VER) && defined(_M_IA64)
  375. # define IA64
  376. # define MSWIN32 /* Really win64, but we don't treat 64-bit */
  377. /* variants as a differnt platform. */
  378. # endif
  379. # endif
  380. # if defined(__DJGPP__)
  381. # define I386
  382. # ifndef DJGPP
  383. # define DJGPP /* MSDOS running the DJGPP port of GCC */
  384. # endif
  385. # define mach_type_known
  386. # endif
  387. # if defined(__CYGWIN32__) || defined(__CYGWIN__)
  388. # define I386
  389. # define CYGWIN32
  390. # define mach_type_known
  391. # endif
  392. # if defined(__MINGW32__)
  393. # define I386
  394. # define MSWIN32
  395. # define mach_type_known
  396. # endif
  397. # if defined(__BORLANDC__)
  398. # define I386
  399. # define MSWIN32
  400. # define mach_type_known
  401. # endif
  402. # if defined(_UTS) && !defined(mach_type_known)
  403. # define S370
  404. # define UTS4
  405. # define mach_type_known
  406. # endif
  407. # if defined(__pj__)
  408. # error PicoJava no longer supported
  409. /* The implementation had problems, and I haven't heard of users */
  410. /* in ages. If you want it resurrected, let me know. */
  411. # endif
  412. # if defined(__embedded__) && defined(PPC)
  413. # define POWERPC
  414. # define NOSYS
  415. # define mach_type_known
  416. # endif
  417. /* Ivan Demakov */
  418. # if defined(__WATCOMC__) && defined(__386__)
  419. # define I386
  420. # if !defined(OS2) && !defined(MSWIN32) && !defined(DOS4GW)
  421. # if defined(__OS2__)
  422. # define OS2
  423. # else
  424. # if defined(__WINDOWS_386__) || defined(__NT__)
  425. # define MSWIN32
  426. # else
  427. # define DOS4GW
  428. # endif
  429. # endif
  430. # endif
  431. # define mach_type_known
  432. # endif
  433. # if defined(__s390__) && defined(LINUX)
  434. # define S390
  435. # define mach_type_known
  436. # endif
  437. # if defined(__GNU__)
  438. # if defined(__i386__)
  439. /* The Debian Hurd running on generic PC */
  440. # define HURD
  441. # define I386
  442. # define mach_type_known
  443. # endif
  444. # endif
  445. # if defined(__TANDEM)
  446. /* Nonstop S-series */
  447. /* FIXME: Should recognize Integrity series? */
  448. # define MIPS
  449. # define NONSTOP
  450. # define mach_type_known
  451. # endif
  452. /* Feel free to add more clauses here */
  453. /* Or manually define the machine type here. A machine type is */
  454. /* characterized by the architecture. Some */
  455. /* machine types are further subdivided by OS. */
  456. /* Macros such as LINUX, FREEBSD, etc. distinguish them. */
  457. /* SYSV on an M68K actually means A/UX. */
  458. /* The distinction in these cases is usually the stack starting address */
  459. # ifndef mach_type_known
  460. # error "The collector has not been ported to this machine/OS combination."
  461. # endif
  462. /* Mapping is: M68K ==> Motorola 680X0 */
  463. /* (NEXT, and SYSV (A/UX), */
  464. /* MACOS and AMIGA variants) */
  465. /* I386 ==> Intel 386 */
  466. /* (SEQUENT, OS2, SCO, LINUX, NETBSD, */
  467. /* FREEBSD, THREE86BSD, MSWIN32, */
  468. /* BSDI,SOLARIS, NEXT, other variants) */
  469. /* NS32K ==> Encore Multimax */
  470. /* MIPS ==> R2000 through R14K */
  471. /* (many variants) */
  472. /* VAX ==> DEC VAX */
  473. /* (BSD, ULTRIX variants) */
  474. /* HP_PA ==> HP9000/700 & /800 */
  475. /* HP/UX, LINUX */
  476. /* SPARC ==> SPARC v7/v8/v9 */
  477. /* (SOLARIS, LINUX, DRSNX variants) */
  478. /* ALPHA ==> DEC Alpha */
  479. /* (OSF1 and LINUX variants) */
  480. /* M88K ==> Motorola 88XX0 */
  481. /* (CX_UX and DGUX) */
  482. /* S370 ==> 370-like machine */
  483. /* running Amdahl UTS4 */
  484. /* S390 ==> 390-like machine */
  485. /* running LINUX */
  486. /* ARM32 ==> Intel StrongARM */
  487. /* IA64 ==> Intel IPF */
  488. /* (e.g. Itanium) */
  489. /* (LINUX and HPUX) */
  490. /* SH ==> Hitachi SuperH */
  491. /* (LINUX & MSWINCE) */
  492. /* X86_64 ==> AMD x86-64 */
  493. /* POWERPC ==> IBM/Apple PowerPC */
  494. /* (MACOS(<=9),DARWIN(incl.MACOSX),*/
  495. /* LINUX, NETBSD, AIX, NOSYS */
  496. /* variants) */
  497. /* Handles 32 and 64-bit variants. */
  498. /* CRIS ==> Axis Etrax */
  499. /* M32R ==> Renesas M32R */
  500. /*
  501. * For each architecture and OS, the following need to be defined:
  502. *
  503. * CPP_WORDSZ is a simple integer constant representing the word size.
  504. * in bits. We assume byte addressibility, where a byte has 8 bits.
  505. * We also assume CPP_WORDSZ is either 32 or 64.
  506. * (We care about the length of pointers, not hardware
  507. * bus widths. Thus a 64 bit processor with a C compiler that uses
  508. * 32 bit pointers should use CPP_WORDSZ of 32, not 64. Default is 32.)
  509. *
  510. * MACH_TYPE is a string representation of the machine type.
  511. * OS_TYPE is analogous for the OS.
  512. *
  513. * ALIGNMENT is the largest N, such that
  514. * all pointer are guaranteed to be aligned on N byte boundaries.
  515. * defining it to be 1 will always work, but perform poorly.
  516. *
  517. * DATASTART is the beginning of the data segment.
  518. * On some platforms SEARCH_FOR_DATA_START is defined.
  519. * SEARCH_FOR_DATASTART will cause GC_data_start to
  520. * be set to an address determined by accessing data backwards from _end
  521. * until an unmapped page is found. DATASTART will be defined to be
  522. * GC_data_start.
  523. * On UNIX-like systems, the collector will scan the area between DATASTART
  524. * and DATAEND for root pointers.
  525. *
  526. * DATAEND, if not `end' where `end' is defined as ``extern int end[];''.
  527. * RTH suggests gaining access to linker script synth'd values with
  528. * this idiom instead of `&end' where `end' is defined as ``extern int end;'' .
  529. * Otherwise, ``GCC will assume these are in .sdata/.sbss'' and it will, e.g.,
  530. * cause failures on alpha*-*-* with ``-msmall-data or -fpic'' or mips-*-*
  531. * without any special options.
  532. *
  533. * STACKBOTTOM is the cool end of the stack, which is usually the
  534. * highest address in the stack.
  535. * Under PCR or OS/2, we have other ways of finding thread stacks.
  536. * For each machine, the following should:
  537. * 1) define STACK_GROWS_UP if the stack grows toward higher addresses, and
  538. * 2) define exactly one of
  539. * STACKBOTTOM (should be defined to be an expression)
  540. * LINUX_STACKBOTTOM
  541. * HEURISTIC1
  542. * HEURISTIC2
  543. * If STACKBOTTOM is defined, then it's value will be used directly as the
  544. * stack base. If LINUX_STACKBOTTOM is defined, then it will be determined
  545. * with a method appropriate for most Linux systems. Currently we look
  546. * first for __libc_stack_end (currently only id USE_LIBC_PRIVATES is
  547. * defined), and if that fails read it from /proc. (If USE_LIBC_PRIVATES
  548. * is not defined and NO_PROC_STAT is defined, we revert to HEURISTIC2.)
  549. * If either of the last two macros are defined, then STACKBOTTOM is computed
  550. * during collector startup using one of the following two heuristics:
  551. * HEURISTIC1: Take an address inside GC_init's frame, and round it up to
  552. * the next multiple of STACK_GRAN.
  553. * HEURISTIC2: Take an address inside GC_init's frame, increment it repeatedly
  554. * in small steps (decrement if STACK_GROWS_UP), and read the value
  555. * at each location. Remember the value when the first
  556. * Segmentation violation or Bus error is signalled. Round that
  557. * to the nearest plausible page boundary, and use that instead
  558. * of STACKBOTTOM.
  559. *
  560. * Gustavo Rodriguez-Rivera points out that on most (all?) Unix machines,
  561. * the value of environ is a pointer that can serve as STACKBOTTOM.
  562. * I expect that HEURISTIC2 can be replaced by this approach, which
  563. * interferes far less with debugging. However it has the disadvantage
  564. * that it's confused by a putenv call before the collector is initialized.
  565. * This could be dealt with by intercepting putenv ...
  566. *
  567. * If no expression for STACKBOTTOM can be found, and neither of the above
  568. * heuristics are usable, the collector can still be used with all of the above
  569. * undefined, provided one of the following is done:
  570. * 1) GC_mark_roots can be changed to somehow mark from the correct stack(s)
  571. * without reference to STACKBOTTOM. This is appropriate for use in
  572. * conjunction with thread packages, since there will be multiple stacks.
  573. * (Allocating thread stacks in the heap, and treating them as ordinary
  574. * heap data objects is also possible as a last resort. However, this is
  575. * likely to introduce significant amounts of excess storage retention
  576. * unless the dead parts of the thread stacks are periodically cleared.)
  577. * 2) Client code may set GC_stackbottom before calling any GC_ routines.
  578. * If the author of the client code controls the main program, this is
  579. * easily accomplished by introducing a new main program, setting
  580. * GC_stackbottom to the address of a local variable, and then calling
  581. * the original main program. The new main program would read something
  582. * like:
  583. *
  584. * # include "gc_private.h"
  585. *
  586. * main(argc, argv, envp)
  587. * int argc;
  588. * char **argv, **envp;
  589. * {
  590. * int dummy;
  591. *
  592. * GC_stackbottom = (ptr_t)(&dummy);
  593. * return(real_main(argc, argv, envp));
  594. * }
  595. *
  596. *
  597. * Each architecture may also define the style of virtual dirty bit
  598. * implementation to be used:
  599. * MPROTECT_VDB: Write protect the heap and catch faults.
  600. * GWW_VDB: Use win32 GetWriteWatch primitive.
  601. * PROC_VDB: Use the SVR4 /proc primitives to read dirty bits.
  602. *
  603. * The first and second one may be combined, in which case a runtime
  604. * selection will be made, based on GetWriteWatch availability.
  605. *
  606. * An architecture may define DYNAMIC_LOADING if dynamic_load.c
  607. * defined GC_register_dynamic_libraries() for the architecture.
  608. *
  609. * An architecture may define PREFETCH(x) to preload the cache with *x.
  610. * This defaults to a no-op.
  611. *
  612. * PREFETCH_FOR_WRITE(x) is used if *x is about to be written.
  613. *
  614. * An architecture may also define CLEAR_DOUBLE(x) to be a fast way to
  615. * clear the two words at GC_malloc-aligned address x. By default,
  616. * word stores of 0 are used instead.
  617. *
  618. * HEAP_START may be defined as the initial address hint for mmap-based
  619. * allocation.
  620. */
  621. /* If we are using a recent version of gcc, we can use __builtin_unwind_init()
  622. * to push the relevant registers onto the stack.
  623. */
  624. # if defined(__GNUC__) && ((__GNUC__ >= 3) || \
  625. (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)) \
  626. && !defined(__INTEL_COMPILER) && !defined(__PATHCC__)
  627. # define HAVE_BUILTIN_UNWIND_INIT
  628. # endif
  629. # define STACK_GRAN 0x1000000
  630. # ifdef M68K
  631. # define MACH_TYPE "M68K"
  632. # define ALIGNMENT 2
  633. # ifdef OPENBSD
  634. # define OS_TYPE "OPENBSD"
  635. # define HEURISTIC2
  636. # ifdef __ELF__
  637. # define DATASTART GC_data_start
  638. # define DYNAMIC_LOADING
  639. # else
  640. extern char etext[];
  641. # define DATASTART ((ptr_t)(etext))
  642. # endif
  643. # endif
  644. # ifdef NETBSD
  645. # define OS_TYPE "NETBSD"
  646. # define HEURISTIC2
  647. # ifdef __ELF__
  648. # define DATASTART GC_data_start
  649. # define DYNAMIC_LOADING
  650. # else
  651. extern char etext[];
  652. # define DATASTART ((ptr_t)(etext))
  653. # endif
  654. # endif
  655. # ifdef LINUX
  656. # define OS_TYPE "LINUX"
  657. # define LINUX_STACKBOTTOM
  658. # define MPROTECT_VDB
  659. # ifdef __ELF__
  660. # define DYNAMIC_LOADING
  661. # include <features.h>
  662. # if defined(__GLIBC__)&& __GLIBC__>=2
  663. # define SEARCH_FOR_DATA_START
  664. # else /* !GLIBC2 */
  665. extern char **__environ;
  666. # define DATASTART ((ptr_t)(&__environ))
  667. /* hideous kludge: __environ is the first */
  668. /* word in crt0.o, and delimits the start */
  669. /* of the data segment, no matter which */
  670. /* ld options were passed through. */
  671. /* We could use _etext instead, but that */
  672. /* would include .rodata, which may */
  673. /* contain large read-only data tables */
  674. /* that we'd rather not scan. */
  675. # endif /* !GLIBC2 */
  676. extern int _end[];
  677. # define DATAEND (_end)
  678. # else
  679. extern int etext[];
  680. # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
  681. # endif
  682. # endif
  683. # ifdef AMIGA
  684. # define OS_TYPE "AMIGA"
  685. /* STACKBOTTOM and DATASTART handled specially */
  686. /* in os_dep.c */
  687. # define DATAEND /* not needed */
  688. # define GETPAGESIZE() 4096
  689. # endif
  690. # ifdef MACOS
  691. # ifndef __LOWMEM__
  692. # include <LowMem.h>
  693. # endif
  694. # define OS_TYPE "MACOS"
  695. /* see os_dep.c for details of global data segments. */
  696. # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
  697. # define DATAEND /* not needed */
  698. # define GETPAGESIZE() 4096
  699. # endif
  700. # ifdef NEXT
  701. # define OS_TYPE "NEXT"
  702. # define DATASTART ((ptr_t) get_etext())
  703. # define STACKBOTTOM ((ptr_t) 0x4000000)
  704. # define DATAEND /* not needed */
  705. # endif
  706. # endif
  707. # if defined(POWERPC)
  708. # define MACH_TYPE "POWERPC"
  709. # ifdef MACOS
  710. # define ALIGNMENT 2 /* Still necessary? Could it be 4? */
  711. # ifndef __LOWMEM__
  712. # include <LowMem.h>
  713. # endif
  714. # define OS_TYPE "MACOS"
  715. /* see os_dep.c for details of global data segments. */
  716. # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
  717. # define DATAEND /* not needed */
  718. # endif
  719. # ifdef LINUX
  720. # if defined(__powerpc64__)
  721. # define ALIGNMENT 8
  722. # define CPP_WORDSZ 64
  723. # ifndef HBLKSIZE
  724. # define HBLKSIZE 4096
  725. # endif
  726. # else
  727. # define ALIGNMENT 4
  728. # endif
  729. # define OS_TYPE "LINUX"
  730. /* HEURISTIC1 has been reliably reported to fail for a 32-bit */
  731. /* executable on a 64 bit kernel. */
  732. # define LINUX_STACKBOTTOM
  733. # define DYNAMIC_LOADING
  734. # define SEARCH_FOR_DATA_START
  735. extern int _end[];
  736. # define DATAEND (_end)
  737. # endif
  738. # ifdef DARWIN
  739. # define OS_TYPE "DARWIN"
  740. # define DYNAMIC_LOADING
  741. # if defined(__ppc64__)
  742. # define ALIGNMENT 8
  743. # define CPP_WORDSZ 64
  744. # define STACKBOTTOM ((ptr_t) 0x7fff5fc00000)
  745. # define CACHE_LINE_SIZE 64
  746. # ifndef HBLKSIZE
  747. # define HBLKSIZE 4096
  748. # endif
  749. # else
  750. # define ALIGNMENT 4
  751. # define STACKBOTTOM ((ptr_t) 0xc0000000)
  752. # endif
  753. /* XXX: see get_end(3), get_etext() and get_end() should not be used.
  754. These aren't used when dyld support is enabled (it is by default) */
  755. # define DATASTART ((ptr_t) get_etext())
  756. # define DATAEND ((ptr_t) get_end())
  757. # define USE_MMAP
  758. # define USE_MMAP_ANON
  759. # ifdef GC_DARWIN_THREADS
  760. # define MPROTECT_VDB
  761. # endif
  762. # include <unistd.h>
  763. # define GETPAGESIZE() getpagesize()
  764. # if defined(USE_PPC_PREFETCH) && defined(__GNUC__)
  765. /* The performance impact of prefetches is untested */
  766. # define PREFETCH(x) \
  767. __asm__ __volatile__ ("dcbt 0,%0" : : "r" ((const void *) (x)))
  768. # define PREFETCH_FOR_WRITE(x) \
  769. __asm__ __volatile__ ("dcbtst 0,%0" : : "r" ((const void *) (x)))
  770. # endif
  771. /* There seems to be some issues with trylock hanging on darwin. This
  772. should be looked into some more */
  773. # define NO_PTHREAD_TRYLOCK
  774. # endif
  775. # ifdef FREEBSD
  776. # define ALIGNMENT 4
  777. # define OS_TYPE "FREEBSD"
  778. # ifndef GC_FREEBSD_THREADS
  779. # define MPROTECT_VDB
  780. # endif
  781. # define SIG_SUSPEND SIGUSR1
  782. # define SIG_THR_RESTART SIGUSR2
  783. # define FREEBSD_STACKBOTTOM
  784. # ifdef __ELF__
  785. # define DYNAMIC_LOADING
  786. # endif
  787. extern char etext[];
  788. extern char * GC_FreeBSDGetDataStart();
  789. # define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
  790. # endif
  791. # ifdef NETBSD
  792. # define ALIGNMENT 4
  793. # define OS_TYPE "NETBSD"
  794. # define HEURISTIC2
  795. extern char etext[];
  796. # define DATASTART GC_data_start
  797. # define DYNAMIC_LOADING
  798. # endif
  799. # ifdef AIX
  800. # define OS_TYPE "AIX"
  801. # undef ALIGNMENT /* in case it's defined */
  802. # ifdef IA64
  803. # undef IA64
  804. /* DOB: some AIX installs stupidly define IA64 in */
  805. /* /usr/include/sys/systemcfg.h */
  806. # endif
  807. # ifdef __64BIT__
  808. # define ALIGNMENT 8
  809. # define CPP_WORDSZ 64
  810. # define STACKBOTTOM ((ptr_t)0x1000000000000000)
  811. # else
  812. # define ALIGNMENT 4
  813. # define CPP_WORDSZ 32
  814. # define STACKBOTTOM ((ptr_t)((ulong)&errno))
  815. # endif
  816. # define USE_MMAP
  817. # define USE_MMAP_ANON
  818. /* From AIX linker man page:
  819. _text Specifies the first location of the program.
  820. _etext Specifies the first location after the program.
  821. _data Specifies the first location of the data.
  822. _edata Specifies the first location after the initialized data
  823. _end or end Specifies the first location after all data.
  824. */
  825. extern int _data[], _end[];
  826. # define DATASTART ((ptr_t)((ulong)_data))
  827. # define DATAEND ((ptr_t)((ulong)_end))
  828. extern int errno;
  829. # define DYNAMIC_LOADING
  830. /* For really old versions of AIX, this may have to be removed. */
  831. # endif
  832. # ifdef NOSYS
  833. # define ALIGNMENT 4
  834. # define OS_TYPE "NOSYS"
  835. extern void __end[], __dso_handle[];
  836. # define DATASTART (__dso_handle) /* OK, that's ugly. */
  837. # define DATAEND (__end)
  838. /* Stack starts at 0xE0000000 for the simulator. */
  839. # undef STACK_GRAN
  840. # define STACK_GRAN 0x10000000
  841. # define HEURISTIC1
  842. # endif
  843. # endif
  844. # ifdef VAX
  845. # define MACH_TYPE "VAX"
  846. # define ALIGNMENT 4 /* Pointers are longword aligned by 4.2 C compiler */
  847. extern char etext[];
  848. # define DATASTART ((ptr_t)(etext))
  849. # ifdef BSD
  850. # define OS_TYPE "BSD"
  851. # define HEURISTIC1
  852. /* HEURISTIC2 may be OK, but it's hard to test. */
  853. # endif
  854. # ifdef ULTRIX
  855. # define OS_TYPE "ULTRIX"
  856. # define STACKBOTTOM ((ptr_t) 0x7fffc800)
  857. # endif
  858. # endif
  859. # ifdef SPARC
  860. # define MACH_TYPE "SPARC"
  861. # if defined(__arch64__) || defined(__sparcv9)
  862. # define ALIGNMENT 8
  863. # define CPP_WORDSZ 64
  864. # define ELF_CLASS ELFCLASS64
  865. # else
  866. # define ALIGNMENT 4 /* Required by hardware */
  867. # define CPP_WORDSZ 32
  868. # endif
  869. /* Don't define USE_ASM_PUSH_REGS. We do use an asm helper, but */
  870. /* not to push the registers on the mark stack. */
  871. # ifdef SOLARIS
  872. # define OS_TYPE "SOLARIS"
  873. extern int _etext[];
  874. extern int _end[];
  875. extern ptr_t GC_SysVGetDataStart(size_t, ptr_t);
  876. # define DATASTART GC_SysVGetDataStart(0x10000, (ptr_t)_etext)
  877. # define DATAEND (_end)
  878. # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
  879. # define USE_MMAP
  880. /* Otherwise we now use calloc. Mmap may result in the */
  881. /* heap interleaved with thread stacks, which can result in */
  882. /* excessive blacklisting. Sbrk is unusable since it */
  883. /* doesn't interact correctly with the system malloc. */
  884. # endif
  885. # ifdef USE_MMAP
  886. # define HEAP_START (ptr_t)0x40000000
  887. # else
  888. # define HEAP_START DATAEND
  889. # endif
  890. # define PROC_VDB
  891. /* HEURISTIC1 reportedly no longer works under 2.7. */
  892. /* HEURISTIC2 probably works, but this appears to be preferable. */
  893. /* Apparently USRSTACK is defined to be USERLIMIT, but in some */
  894. /* installations that's undefined. We work around this with a */
  895. /* gross hack: */
  896. # include <sys/vmparam.h>
  897. # ifdef USERLIMIT
  898. /* This should work everywhere, but doesn't. */
  899. # define STACKBOTTOM USRSTACK
  900. # else
  901. # define HEURISTIC2
  902. # endif
  903. # include <unistd.h>
  904. # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
  905. /* getpagesize() appeared to be missing from at least one */
  906. /* Solaris 5.4 installation. Weird. */
  907. # define DYNAMIC_LOADING
  908. # endif
  909. # ifdef DRSNX
  910. # define OS_TYPE "DRSNX"
  911. extern ptr_t GC_SysVGetDataStart(size_t, ptr_t);
  912. extern int etext[];
  913. # define DATASTART GC_SysVGetDataStart(0x10000, (ptr_t)etext)
  914. # define MPROTECT_VDB
  915. # define STACKBOTTOM ((ptr_t) 0xdfff0000)
  916. # define DYNAMIC_LOADING
  917. # endif
  918. # ifdef LINUX
  919. # define OS_TYPE "LINUX"
  920. # ifdef __ELF__
  921. # define DYNAMIC_LOADING
  922. # else
  923. Linux Sparc/a.out not supported
  924. # endif
  925. extern int _end[];
  926. extern int _etext[];
  927. # define DATAEND (_end)
  928. # define SVR4
  929. extern ptr_t GC_SysVGetDataStart(size_t, ptr_t);
  930. # ifdef __arch64__
  931. # define DATASTART GC_SysVGetDataStart(0x100000, (ptr_t)_etext)
  932. # else
  933. # define DATASTART GC_SysVGetDataStart(0x10000, (ptr_t)_etext)
  934. # endif
  935. # define LINUX_STACKBOTTOM
  936. # endif
  937. # ifdef OPENBSD
  938. # define OS_TYPE "OPENBSD"
  939. # define STACKBOTTOM ((ptr_t) 0xf8000000)
  940. extern int etext[];
  941. # define DATASTART ((ptr_t)(etext))
  942. # endif
  943. # ifdef NETBSD
  944. # define OS_TYPE "NETBSD"
  945. # define HEURISTIC2
  946. # ifdef __ELF__
  947. # define DATASTART GC_data_start
  948. # define DYNAMIC_LOADING
  949. # else
  950. extern char etext[];
  951. # define DATASTART ((ptr_t)(etext))
  952. # endif
  953. # endif
  954. # ifdef FREEBSD
  955. # define OS_TYPE "FREEBSD"
  956. # define SIG_SUSPEND SIGUSR1
  957. # define SIG_THR_RESTART SIGUSR2
  958. # define FREEBSD_STACKBOTTOM
  959. # ifdef __ELF__
  960. # define DYNAMIC_LOADING
  961. # endif
  962. extern char etext[];
  963. extern char edata[];
  964. extern char end[];
  965. # define NEED_FIND_LIMIT
  966. # define DATASTART ((ptr_t)(&etext))
  967. # define DATAEND (GC_find_limit (DATASTART, TRUE))
  968. # define DATASTART2 ((ptr_t)(&edata))
  969. # define DATAEND2 ((ptr_t)(&end))
  970. # endif
  971. # endif
  972. # ifdef I386
  973. # define MACH_TYPE "I386"
  974. # if defined(__LP64__) || defined(_WIN64)
  975. # error This should be handled as X86_64
  976. # else
  977. # define CPP_WORDSZ 32
  978. # define ALIGNMENT 4
  979. /* Appears to hold for all "32 bit" compilers */
  980. /* except Borland. The -a4 option fixes */
  981. /* Borland. */
  982. /* Ivan Demakov: For Watcom the option is -zp4. */
  983. # endif
  984. # ifdef SEQUENT
  985. # define OS_TYPE "SEQUENT"
  986. extern int etext[];
  987. # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
  988. # define STACKBOTTOM ((ptr_t) 0x3ffff000)
  989. # endif
  990. # ifdef BEOS
  991. # define OS_TYPE "BEOS"
  992. # include <OS.h>
  993. # define GETPAGESIZE() B_PAGE_SIZE
  994. extern int etext[];
  995. # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
  996. # endif
  997. # ifdef SOLARIS
  998. # define OS_TYPE "SOLARIS"
  999. extern int _etext[], _end[];
  1000. extern ptr_t GC_SysVGetDataStart(size_t, ptr_t);
  1001. # define DATASTART GC_SysVGetDataStart(0x1000, (ptr_t)_etext)
  1002. # define DATAEND (_end)
  1003. /* # define STACKBOTTOM ((ptr_t)(_start)) worked through 2.7, */
  1004. /* but reportedly breaks under 2.8. It appears that the stack */
  1005. /* base is a property of the executable, so this should not break */
  1006. /* old executables. */
  1007. /* HEURISTIC2 probably works, but this appears to be preferable. */
  1008. # include <sys/vm.h>
  1009. # define STACKBOTTOM USRSTACK
  1010. /* At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */
  1011. /* It appears to be fixed in 2.8 and 2.9. */
  1012. # ifdef SOLARIS25_PROC_VDB_BUG_FIXED
  1013. # define PROC_VDB
  1014. # endif
  1015. # define DYNAMIC_LOADING
  1016. # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
  1017. # define USE_MMAP
  1018. /* Otherwise we now use calloc. Mmap may result in the */
  1019. /* heap interleaved with thread stacks, which can result in */
  1020. /* excessive blacklisting. Sbrk is unusable since it */
  1021. /* doesn't interact correctly with the system malloc. */
  1022. # endif
  1023. # ifdef USE_MMAP
  1024. # define HEAP_START (ptr_t)0x40000000
  1025. # else
  1026. # define HEAP_START DATAEND
  1027. # endif
  1028. # endif
  1029. # ifdef SCO
  1030. # define OS_TYPE "SCO"
  1031. extern int etext[];
  1032. # define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
  1033. & ~0x3fffff) \
  1034. +((word)etext & 0xfff))
  1035. # define STACKBOTTOM ((ptr_t) 0x7ffffffc)
  1036. # endif
  1037. # ifdef SCO_ELF
  1038. # define OS_TYPE "SCO_ELF"
  1039. extern int etext[];
  1040. # define DATASTART ((ptr_t)(etext))
  1041. # define STACKBOTTOM ((ptr_t) 0x08048000)
  1042. # define DYNAMIC_LOADING
  1043. # define ELF_CLASS ELFCLASS32
  1044. # endif
  1045. # ifdef DGUX
  1046. # define OS_TYPE "DGUX"
  1047. extern int _etext, _end;
  1048. extern ptr_t GC_SysVGetDataStart(size_t, ptr_t);
  1049. # define DATASTART GC_SysVGetDataStart(0x1000, (ptr_t)(&_etext))
  1050. # define DATAEND (&_end)
  1051. # define STACK_GROWS_DOWN
  1052. # define HEURISTIC2
  1053. # include <unistd.h>
  1054. # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
  1055. # define DYNAMIC_LOADING
  1056. # ifndef USE_MMAP
  1057. # define USE_MMAP
  1058. # endif /* USE_MMAP */
  1059. # define MAP_FAILED (void *) -1
  1060. # ifdef USE_MMAP
  1061. # define HEAP_START (ptr_t)0x40000000
  1062. # else /* USE_MMAP */
  1063. # define HEAP_START DATAEND
  1064. # endif /* USE_MMAP */
  1065. # endif /* DGUX */
  1066. # ifdef LINUX
  1067. # define OS_TYPE "LINUX"
  1068. # define LINUX_STACKBOTTOM
  1069. # if 0
  1070. # define HEURISTIC1
  1071. # undef STACK_GRAN
  1072. # define STACK_GRAN 0x10000000
  1073. /* STACKBOTTOM is usually 0xc0000000, but this changes with */
  1074. /* different kernel configurations. In particular, systems */
  1075. /* with 2GB physical memory will usually move the user */
  1076. /* address space limit, and hence initial SP to 0x80000000. */
  1077. # endif
  1078. # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
  1079. # define MPROTECT_VDB
  1080. # else
  1081. /* We seem to get random errors in incremental mode, */
  1082. /* possibly because Linux threads is itself a malloc client */
  1083. /* and can't deal with the signals. */
  1084. # endif
  1085. # define HEAP_START (ptr_t)0x1000
  1086. /* This encourages mmap to give us low addresses, */
  1087. /* thus allowing the heap to grow to ~3GB */
  1088. # ifdef __ELF__
  1089. # define DYNAMIC_LOADING
  1090. # ifdef UNDEFINED /* includes ro data */
  1091. extern int _etext[];
  1092. # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
  1093. # endif
  1094. # include <features.h>
  1095. # if defined(__GLIBC__) && __GLIBC__ >= 2
  1096. # define SEARCH_FOR_DATA_START
  1097. # else
  1098. extern char **__environ;
  1099. # define DATASTART ((ptr_t)(&__environ))
  1100. /* hideous kludge: __environ is the first */
  1101. /* word in crt0.o, and delimits the start */
  1102. /* of the data segment, no matter which */
  1103. /* ld options were passed through. */
  1104. /* We could use _etext instead, but that */
  1105. /* would include .rodata, which may */
  1106. /* contain large read-only data tables */
  1107. /* that we'd rather not scan. */
  1108. # endif
  1109. extern int _end[];
  1110. # define DATAEND (_end)
  1111. # else
  1112. extern int etext[];
  1113. # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
  1114. # endif
  1115. # ifdef USE_I686_PREFETCH
  1116. /* FIXME: Thus should use __builtin_prefetch, but we'll leave that */
  1117. /* for the next rtelease. */
  1118. # define PREFETCH(x) \
  1119. __asm__ __volatile__ (" prefetchnta %0": : "m"(*(char *)(x)))
  1120. /* Empirically prefetcht0 is much more effective at reducing */
  1121. /* cache miss stalls for the targetted load instructions. But it */
  1122. /* seems to interfere enough with other cache traffic that the net */
  1123. /* result is worse than prefetchnta. */
  1124. # if 0
  1125. /* Using prefetches for write seems to have a slight negative */
  1126. /* impact on performance, at least for a PIII/500. */
  1127. # define PREFETCH_FOR_WRITE(x) \
  1128. __asm__ __volatile__ (" prefetcht0 %0": : "m"(*(char *)(x)))
  1129. # endif
  1130. # endif
  1131. # ifdef USE_3DNOW_PREFETCH
  1132. # define PREFETCH(x) \
  1133. __asm__ __volatile__ (" prefetch %0": : "m"(*(char *)(x)))
  1134. # define PREFETCH_FOR_WRITE(x) \
  1135. __asm__ __volatile__ (" prefetchw %0": : "m"(*(char *)(x)))
  1136. # endif
  1137. # endif
  1138. # ifdef CYGWIN32
  1139. # define OS_TYPE "CYGWIN32"
  1140. # define DATASTART ((ptr_t)GC_DATASTART) /* From gc.h */
  1141. # define DATAEND ((ptr_t)GC_DATAEND)
  1142. # undef STACK_GRAN
  1143. # define STACK_GRAN 0x10000
  1144. # define HEURISTIC1
  1145. # endif
  1146. # ifdef OS2
  1147. # define OS_TYPE "OS2"
  1148. /* STACKBOTTOM and DATASTART are handled specially in */
  1149. /* os_dep.c. OS2 actually has the right */
  1150. /* system call! */
  1151. # define DATAEND /* not needed */
  1152. # endif
  1153. # ifdef MSWIN32
  1154. # define OS_TYPE "MSWIN32"
  1155. /* STACKBOTTOM and DATASTART are handled specially in */
  1156. /* os_dep.c. */
  1157. # if !defined(__WATCOMC__)
  1158. # define MPROTECT_VDB
  1159. /* We also avoided doing this in the past with GC_WIN32_THREADS */
  1160. /* Hopefully that's fixed. */
  1161. # endif
  1162. # if _MSC_VER >= 1300 /* .NET, i.e. > VisualStudio 6 */
  1163. # define GWW_VDB
  1164. # endif
  1165. # define DATAEND /* not needed */
  1166. # endif
  1167. # ifdef MSWINCE
  1168. # define OS_TYPE "MSWINCE"
  1169. # define DATAEND /* not needed */
  1170. # endif
  1171. # ifdef DJGPP
  1172. # define OS_TYPE "DJGPP"
  1173. # include "stubinfo.h"
  1174. extern int etext[];
  1175. extern int _stklen;
  1176. extern int __djgpp_stack_limit;
  1177. # define DATASTART ((ptr_t)((((word) (etext)) + 0x1ff) & ~0x1ff))
  1178. /* # define STACKBOTTOM ((ptr_t)((word) _stubinfo + _stubinfo->size \
  1179. + _stklen)) */
  1180. # define STACKBOTTOM ((ptr_t)((word) __djgpp_stack_limit + _stklen))
  1181. /* This may not be right. */
  1182. # endif
  1183. # ifdef OPENBSD
  1184. # define OS_TYPE "OPENBSD"
  1185. # endif
  1186. # ifdef FREEBSD
  1187. # define OS_TYPE "FREEBSD"
  1188. # ifndef GC_FREEBSD_THREADS
  1189. # define MPROTECT_VDB
  1190. # endif
  1191. # ifdef __GLIBC__
  1192. # define SIG_SUSPEND (32+6)
  1193. # define SIG_THR_RESTART (32+5)
  1194. extern int _end[];
  1195. # define DATAEND (_end)
  1196. # else
  1197. # define SIG_SUSPEND SIGUSR1
  1198. # define SIG_THR_RESTART SIGUSR2
  1199. # endif
  1200. # define FREEBSD_STACKBOTTOM
  1201. # ifdef __ELF__
  1202. # define DYNAMIC_LOADING
  1203. # endif
  1204. extern char etext[];
  1205. extern char * GC_FreeBSDGetDataStart(size_t, ptr_t);
  1206. # define DATASTART GC_FreeBSDGetDataStart(0x1000, (ptr_t)etext)
  1207. # endif
  1208. # ifdef NETBSD
  1209. # define OS_TYPE "NETBSD"
  1210. # ifdef __ELF__
  1211. # define DYNAMIC_LOADING
  1212. # endif
  1213. # endif
  1214. # ifdef THREE86BSD
  1215. # define OS_TYPE "THREE86BSD"
  1216. # endif
  1217. # ifdef BSDI
  1218. # define OS_TYPE "BSDI"
  1219. # endif
  1220. # if defined(OPENBSD) || defined(NETBSD) \
  1221. || defined(THREE86BSD) || defined(BSDI)
  1222. # define HEURISTIC2
  1223. extern char etext[];
  1224. # define DATASTART ((ptr_t)(etext))
  1225. # endif
  1226. # ifdef NEXT
  1227. # define OS_TYPE "NEXT"
  1228. # define DATASTART ((ptr_t) get_etext())
  1229. # define STACKBOTTOM ((ptr_t)0xc0000000)
  1230. # define DATAEND /* not needed */
  1231. # endif
  1232. # ifdef DOS4GW
  1233. # define OS_TYPE "DOS4GW"
  1234. extern long __nullarea;
  1235. extern char _end;
  1236. extern char *_STACKTOP;
  1237. /* Depending on calling conventions Watcom C either precedes
  1238. or does not precedes with undescore names of C-variables.
  1239. Make sure startup code variables always have the same names. */
  1240. #pragma aux __nullarea "*";
  1241. #pragma aux _end "*";
  1242. # define STACKBOTTOM ((ptr_t) _STACKTOP)
  1243. /* confused? me too. */
  1244. # define DATASTART ((ptr_t) &__nullarea)
  1245. # define DATAEND ((ptr_t) &_end)
  1246. # endif
  1247. # ifdef HURD
  1248. # define OS_TYPE "HURD"
  1249. # define STACK_GROWS_DOWN
  1250. # define HEURISTIC2
  1251. # define SIG_SUSPEND SIGUSR1
  1252. # define SIG_THR_RESTART SIGUSR2
  1253. # define SEARCH_FOR_DATA_START
  1254. extern int _end[];
  1255. # define DATAEND ((ptr_t) (_end))
  1256. /* # define MPROTECT_VDB Not quite working yet? */
  1257. # define DYNAMIC_LOADING
  1258. # endif
  1259. # ifdef DARWIN
  1260. # define OS_TYPE "DARWIN"
  1261. # define DARWIN_DONT_PARSE_STACK
  1262. # define DYNAMIC_LOADING
  1263. /* XXX: see get_end(3), get_etext() and get_end() should not be used.
  1264. These aren't used when dyld support is enabled (it is by default) */
  1265. # define DATASTART ((ptr_t) get_etext())
  1266. # define DATAEND ((ptr_t) get_end())
  1267. # define STACKBOTTOM ((ptr_t) 0xc0000000)
  1268. # define USE_MMAP
  1269. # define USE_MMAP_ANON
  1270. # ifdef GC_DARWIN_THREADS
  1271. # define MPROTECT_VDB
  1272. # endif
  1273. # include <unistd.h>
  1274. # define GETPAGESIZE() getpagesize()
  1275. /* There seems to be some issues with trylock hanging on darwin. This
  1276. should be looked into some more */
  1277. # define NO_PTHREAD_TRYLOCK
  1278. # endif /* DARWIN */
  1279. # endif
  1280. # ifdef NS32K
  1281. # define MACH_TYPE "NS32K"
  1282. # define ALIGNMENT 4
  1283. extern char **environ;
  1284. # define DATASTART ((ptr_t)(&environ))
  1285. /* hideous kludge: environ is the first */
  1286. /* word in crt0.o, and delimits the start */
  1287. /* of the data segment, no matter which */
  1288. /* ld options were passed through. */
  1289. # define STACKBOTTOM ((ptr_t) 0xfffff000) /* for Encore */
  1290. # endif
  1291. # ifdef MIPS
  1292. # define MACH_TYPE "MIPS"
  1293. # ifdef LINUX
  1294. /* This was developed for a linuxce style platform. Probably */
  1295. /* needs to be tweaked for workstation class machines. */
  1296. # define OS_TYPE "LINUX"
  1297. # define DYNAMIC_LOADING
  1298. extern int _end[];
  1299. # define DATAEND (_end)
  1300. extern int __data_start[];
  1301. # define DATASTART ((ptr_t)(__data_start))
  1302. # ifdef _MIPS_SZPTR
  1303. # define CPP_WORDSZ _MIPS_SZPTR
  1304. # define ALIGNMENT (_MIPS_SZPTR/8)
  1305. # else
  1306. # define ALIGNMENT 4
  1307. # endif
  1308. # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 2 || __GLIBC__ > 2
  1309. # define LINUX_STACKBOTTOM
  1310. # else
  1311. # define STACKBOTTOM 0x80000000
  1312. # endif
  1313. # endif /* Linux */
  1314. # ifdef EWS4800
  1315. # define HEURISTIC2
  1316. # if defined(_MIPS_SZPTR) && (_MIPS_SZPTR == 64)
  1317. extern int _fdata[], _end[];
  1318. # define DATASTART ((ptr_t)_fdata)
  1319. # define DATAEND ((ptr_t)_end)
  1320. # define CPP_WORDSZ _MIPS_SZPTR
  1321. # define ALIGNMENT (_MIPS_SZPTR/8)
  1322. # else
  1323. extern int etext[], edata[], end[];
  1324. extern int _DYNAMIC_LINKING[], _gp[];
  1325. # define DATASTART ((ptr_t)((((word)etext + 0x3ffff) & ~0x3ffff) \
  1326. + ((word)etext & 0xffff)))
  1327. # define DATAEND (edata)
  1328. # define DATASTART2 (_DYNAMIC_LINKING \
  1329. ? (ptr_t)(((word)_gp + 0x8000 + 0x3ffff) & ~0x3ffff) \
  1330. : (ptr_t)edata)
  1331. # define DATAEND2 (end)
  1332. # define ALIGNMENT 4
  1333. # endif
  1334. # define OS_TYPE "EWS4800"
  1335. # endif
  1336. # ifdef ULTRIX
  1337. # define HEURISTIC2
  1338. # define DATASTART (ptr_t)0x10000000
  1339. /* Could probably be slightly higher since */
  1340. /* startup code allocates lots of stuff. */
  1341. # define OS_TYPE "ULTRIX"
  1342. # define ALIGNMENT 4
  1343. # endif
  1344. # ifdef IRIX5
  1345. # define HEURISTIC2
  1346. extern int _fdata[];
  1347. # define DATASTART ((ptr_t)(_fdata))
  1348. # ifdef USE_MMAP
  1349. # define HEAP_START (ptr_t)0x30000000
  1350. # else
  1351. # define HEAP_START DATASTART
  1352. # endif
  1353. /* Lowest plausible heap address. */
  1354. /* In the MMAP case, we map there. */
  1355. /* In either case it is used to identify */
  1356. /* heap sections so they're not */
  1357. /* considered as roots. */
  1358. # define OS_TYPE "IRIX5"
  1359. /*# define MPROTECT_VDB DOB: this should work, but there is evidence */
  1360. /* of recent breakage. */
  1361. # ifdef _MIPS_SZPTR
  1362. # define CPP_WORDSZ _MIPS_SZPTR
  1363. # define ALIGNMENT (_MIPS_SZPTR/8)
  1364. # else
  1365. # define ALIGNMENT 4
  1366. # endif
  1367. # define DYNAMIC_LOADING
  1368. # endif
  1369. # ifdef MSWINCE
  1370. # define OS_TYPE "MSWINCE"
  1371. # define ALIGNMENT 4
  1372. # define DATAEND /* not needed */
  1373. # endif
  1374. # if defined(NETBSD)
  1375. # define OS_TYPE "NETBSD"
  1376. # define ALIGNMENT 4
  1377. # define HEURISTIC2
  1378. # ifdef __ELF__
  1379. extern int etext[];
  1380. # define DATASTART GC_data_start
  1381. # define NEED_FIND_LIMIT
  1382. # define DYNAMIC_LOADING
  1383. # else
  1384. # define DATASTART ((ptr_t) 0x10000000)
  1385. # define STACKBOTTOM ((ptr_t) 0x7ffff000)
  1386. # endif /* _ELF_ */
  1387. # endif
  1388. # if defined(NONSTOP)
  1389. # define CPP_WORDSZ 32
  1390. # define OS_TYPE "NONSTOP"
  1391. # define ALIGNMENT 4
  1392. # define DATASTART ((ptr_t) 0x08000000)
  1393. extern char **environ;
  1394. # define DATAEND ((ptr_t)(environ - 0x10))
  1395. # define STACKBOTTOM ((ptr_t) 0x4fffffff)
  1396. # endif
  1397. # endif
  1398. # ifdef HP_PA
  1399. # define MACH_TYPE "HP_PA"
  1400. # ifdef __LP64__
  1401. # define CPP_WORDSZ 64
  1402. # define ALIGNMENT 8
  1403. # else
  1404. # define CPP_WORDSZ 32
  1405. # define ALIGNMENT 4
  1406. # endif
  1407. # if !defined(GC_HPUX_THREADS) && !defined(GC_LINUX_THREADS)
  1408. # ifndef LINUX /* For now. */
  1409. # define MPROTECT_VDB
  1410. # endif
  1411. # else
  1412. # ifdef PARALLEL_MARK
  1413. # define USE_MARK_BYTES
  1414. /* Minimize compare-and-swap usage. */
  1415. # endif
  1416. # endif
  1417. # define STACK_GROWS_UP
  1418. # ifdef HPUX
  1419. # define OS_TYPE "HPUX"
  1420. extern int __data_start[];
  1421. # define DATASTART ((ptr_t)(__data_start))
  1422. # if 0
  1423. /* The following appears to work for 7xx systems running HP/UX */
  1424. /* 9.xx Furthermore, it might result in much faster */
  1425. /* collections than HEURISTIC2, which may involve scanning */
  1426. /* segments that directly precede the stack. It is not the */
  1427. /* default, since it may not work on older machine/OS */
  1428. /* combinations. (Thanks to Raymond X.T. Nijssen for uncovering */
  1429. /* this.) */
  1430. # define STACKBOTTOM ((ptr_t) 0x7b033000) /* from /etc/conf/h/param.h */
  1431. # else
  1432. /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
  1433. /* to this. Note that the GC must be initialized before the */
  1434. /* first putenv call. */
  1435. extern char ** environ;
  1436. # define STACKBOTTOM ((ptr_t)environ)
  1437. # endif
  1438. # define DYNAMIC_LOADING
  1439. # include <unistd.h>
  1440. # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
  1441. # ifndef __GNUC__
  1442. # define PREFETCH(x) { \
  1443. register long addr = (long)(x); \
  1444. (void) _asm ("LDW", 0, 0, addr, 0); \
  1445. }
  1446. # endif
  1447. # endif /* HPUX */
  1448. # ifdef LINUX
  1449. # define OS_TYPE "LINUX"
  1450. # define LINUX_STACKBOTTOM
  1451. # define DYNAMIC_LOADING
  1452. # define SEARCH_FOR_DATA_START
  1453. extern int _end[];
  1454. # define DATAEND (&_end)
  1455. # endif /* LINUX */
  1456. # endif /* HP_PA */
  1457. # ifdef ALPHA
  1458. # define MACH_TYPE "ALPHA"
  1459. # define ALIGNMENT 8
  1460. # define CPP_WORDSZ 64
  1461. # ifdef NETBSD
  1462. # define OS_TYPE "NETBSD"
  1463. # define HEURISTIC2
  1464. # define DATASTART GC_data_start
  1465. # define ELFCLASS32 32
  1466. # define ELFCLASS64 64
  1467. # define ELF_CLASS ELFCLASS64
  1468. # define DYNAMIC_LOADING
  1469. # endif
  1470. # ifdef OPENBSD
  1471. # define OS_TYPE "OPENBSD"
  1472. # define HEURISTIC2
  1473. # ifdef __ELF__ /* since OpenBSD/Alpha 2.9 */
  1474. # define DATASTART GC_data_start
  1475. # define ELFCLASS32 32
  1476. # define ELFCLASS64 64
  1477. # define ELF_CLASS ELFCLASS64
  1478. # else /* ECOFF, until OpenBSD/Alpha 2.7 */
  1479. # define DATASTART ((ptr_t) 0x140000000)
  1480. # endif
  1481. # endif
  1482. # ifdef FREEBSD
  1483. # define OS_TYPE "FREEBSD"
  1484. /* MPROTECT_VDB is not yet supported at all on FreeBSD/alpha. */
  1485. # define SIG_SUSPEND SIGUSR1
  1486. # define SIG_THR_RESTART SIGUSR2
  1487. # define FREEBSD_STACKBOTTOM
  1488. # ifdef __ELF__
  1489. # define DYNAMIC_LOADING
  1490. # endif
  1491. /* Handle unmapped hole alpha*-*-freebsd[45]* puts between etext and edata. */
  1492. extern char etext[];
  1493. extern char edata[];
  1494. extern char end[];
  1495. # define NEED_FIND_LIMIT
  1496. # define DATASTART ((ptr_t)(&etext))
  1497. # define DATAEND (GC_find_limit (DATASTART, TRUE))
  1498. # define DATASTART2 ((ptr_t)(&edata))
  1499. # define DATAEND2 ((ptr_t)(&end))
  1500. # endif
  1501. # ifdef OSF1
  1502. # define OS_TYPE "OSF1"
  1503. # define DATASTART ((ptr_t) 0x140000000)
  1504. extern int _end[];
  1505. # define DATAEND ((ptr_t) &_end)
  1506. extern char ** environ;
  1507. /* round up from the value of environ to the nearest page boundary */
  1508. /* Probably breaks if putenv is called before collector */
  1509. /* initialization. */
  1510. # define STACKBOTTOM ((ptr_t)(((word)(environ) | (getpagesize()-1))+1))
  1511. /* # define HEURISTIC2 */
  1512. /* Normally HEURISTIC2 is too conervative, since */
  1513. /* the text segment immediately follows the stack. */
  1514. /* Hence we give an upper pound. */
  1515. /* This is currently unused, since we disabled HEURISTIC2 */
  1516. extern int __start[];
  1517. # define HEURISTIC2_LIMIT ((ptr_t)((word)(__start) & ~(getpagesize()-1)))
  1518. # ifndef GC_OSF1_THREADS
  1519. /* Unresolved signal issues with threads. */
  1520. # define MPROTECT_VDB
  1521. # endif
  1522. # define DYNAMIC_LOADING
  1523. # endif
  1524. # ifdef LINUX
  1525. # define OS_TYPE "LINUX"
  1526. # define LINUX_STACKBOTTOM
  1527. # ifdef __ELF__
  1528. # define SEARCH_FOR_DATA_START
  1529. # define DYNAMIC_LOADING
  1530. # else
  1531. # define DATASTART ((ptr_t) 0x140000000)
  1532. # endif
  1533. extern int _end[];
  1534. # define DATAEND (_end)
  1535. # define MPROTECT_VD