PageRenderTime 58ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/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
Possible License(s): BSD-3-Clause, GPL-2.0
  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_VDB
  1536. /* Has only been superficially tested. May not */
  1537. /* work on all versions. */
  1538. # endif
  1539. # endif
  1540. # ifdef IA64
  1541. # define MACH_TYPE "IA64"
  1542. # ifdef HPUX
  1543. # ifdef _ILP32
  1544. # define CPP_WORDSZ 32
  1545. /* Requires 8 byte alignment for malloc */
  1546. # define ALIGNMENT 4
  1547. # else
  1548. # ifndef _LP64
  1549. ---> unknown ABI
  1550. # endif
  1551. # define CPP_WORDSZ 64
  1552. /* Requires 16 byte alignment for malloc */
  1553. # define ALIGNMENT 8
  1554. # endif
  1555. # define OS_TYPE "HPUX"
  1556. extern int __data_start[];
  1557. # define DATASTART ((ptr_t)(__data_start))
  1558. /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
  1559. /* to this. Note that the GC must be initialized before the */
  1560. /* first putenv call. */
  1561. extern char ** environ;
  1562. # define STACKBOTTOM ((ptr_t)environ)
  1563. # define HPUX_STACKBOTTOM
  1564. # define DYNAMIC_LOADING
  1565. # include <unistd.h>
  1566. # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
  1567. /* The following was empirically determined, and is probably */
  1568. /* not very robust. */
  1569. /* Note that the backing store base seems to be at a nice */
  1570. /* address minus one page. */
  1571. # define BACKING_STORE_DISPLACEMENT 0x1000000
  1572. # define BACKING_STORE_ALIGNMENT 0x1000
  1573. extern ptr_t GC_register_stackbottom;
  1574. # define BACKING_STORE_BASE GC_register_stackbottom
  1575. /* Known to be wrong for recent HP/UX versions!!! */
  1576. # endif
  1577. # ifdef LINUX
  1578. # define CPP_WORDSZ 64
  1579. # define ALIGNMENT 8
  1580. # define OS_TYPE "LINUX"
  1581. /* The following works on NUE and older kernels: */
  1582. /* # define STACKBOTTOM ((ptr_t) 0xa000000000000000l) */
  1583. /* This does not work on NUE: */
  1584. # define LINUX_STACKBOTTOM
  1585. /* We also need the base address of the register stack */
  1586. /* backing store. This is computed in */
  1587. /* GC_linux_register_stack_base based on the following */
  1588. /* constants: */
  1589. # define BACKING_STORE_ALIGNMENT 0x100000
  1590. # define BACKING_STORE_DISPLACEMENT 0x80000000
  1591. extern ptr_t GC_register_stackbottom;
  1592. # define BACKING_STORE_BASE GC_register_stackbottom
  1593. # define SEARCH_FOR_DATA_START
  1594. # ifdef __GNUC__
  1595. # define DYNAMIC_LOADING
  1596. # else
  1597. /* In the Intel compiler environment, we seem to end up with */
  1598. /* statically linked executables and an undefined reference */
  1599. /* to _DYNAMIC */
  1600. # endif
  1601. # define MPROTECT_VDB
  1602. /* Requires Linux 2.3.47 or later. */
  1603. extern int _end[];
  1604. # define DATAEND (_end)
  1605. # ifdef __GNUC__
  1606. # ifndef __INTEL_COMPILER
  1607. # define PREFETCH(x) \
  1608. __asm__ (" lfetch [%0]": : "r"(x))
  1609. # define PREFETCH_FOR_WRITE(x) \
  1610. __asm__ (" lfetch.excl [%0]": : "r"(x))
  1611. # define CLEAR_DOUBLE(x) \
  1612. __asm__ (" stf.spill [%0]=f0": : "r"((void *)(x)))
  1613. # else
  1614. # include <ia64intrin.h>
  1615. # define PREFETCH(x) \
  1616. __lfetch(__lfhint_none, (x))
  1617. # define PREFETCH_FOR_WRITE(x) \
  1618. __lfetch(__lfhint_nta, (x))
  1619. # define CLEAR_DOUBLE(x) \
  1620. __stf_spill((void *)(x), 0)
  1621. # endif // __INTEL_COMPILER
  1622. # endif
  1623. # endif
  1624. # ifdef MSWIN32
  1625. /* FIXME: This is a very partial guess. There is no port, yet. */
  1626. # define OS_TYPE "MSWIN32"
  1627. /* STACKBOTTOM and DATASTART are handled specially in */
  1628. /* os_dep.c. */
  1629. # define DATAEND /* not needed */
  1630. # if defined(_WIN64)
  1631. # define CPP_WORDSZ 64
  1632. # else
  1633. # define CPP_WORDSZ 32 /* Is this possible? */
  1634. # endif
  1635. # define ALIGNMENT 8
  1636. # define STRTOULL _strtoui64
  1637. # endif
  1638. # endif
  1639. # ifdef M88K
  1640. # define MACH_TYPE "M88K"
  1641. # define ALIGNMENT 4
  1642. extern int etext[];
  1643. # ifdef CX_UX
  1644. # define OS_TYPE "CX_UX"
  1645. # define DATASTART ((((word)etext + 0x3fffff) & ~0x3fffff) + 0x10000)
  1646. # endif
  1647. # ifdef DGUX
  1648. # define OS_TYPE "DGUX"
  1649. extern ptr_t GC_SysVGetDataStart(size_t, ptr_t);
  1650. # define DATASTART GC_SysVGetDataStart(0x10000, (ptr_t)etext)
  1651. # endif
  1652. # define STACKBOTTOM ((char*)0xf0000000) /* determined empirically */
  1653. # endif
  1654. # ifdef S370
  1655. /* If this still works, and if anyone cares, this should probably */
  1656. /* be moved to the S390 category. */
  1657. # define MACH_TYPE "S370"
  1658. # define ALIGNMENT 4 /* Required by hardware */
  1659. # ifdef UTS4
  1660. # define OS_TYPE "UTS4"
  1661. extern int etext[];
  1662. extern int _etext[];
  1663. extern int _end[];
  1664. extern ptr_t GC_SysVGetDataStart(size_t, ptr_t);
  1665. # define DATASTART GC_SysVGetDataStart(0x10000, (ptr_t)_etext)
  1666. # define DATAEND (_end)
  1667. # define HEURISTIC2
  1668. # endif
  1669. # endif
  1670. # ifdef S390
  1671. # define MACH_TYPE "S390"
  1672. # ifndef __s390x__
  1673. # define ALIGNMENT 4
  1674. # define CPP_WORDSZ 32
  1675. # else
  1676. # define ALIGNMENT 8
  1677. # define CPP_WORDSZ 64
  1678. # ifndef HBLKSIZE
  1679. # define HBLKSIZE 4096
  1680. # endif
  1681. # endif
  1682. # ifdef LINUX
  1683. # define OS_TYPE "LINUX"
  1684. # define LINUX_STACKBOTTOM
  1685. # define DYNAMIC_LOADING
  1686. extern int __data_start[];
  1687. # define DATASTART ((ptr_t)(__data_start))
  1688. extern int _end[];
  1689. # define DATAEND (_end)
  1690. # define CACHE_LINE_SIZE 256
  1691. # define GETPAGESIZE() 4096
  1692. # endif
  1693. # endif
  1694. # ifdef ARM32
  1695. # define CPP_WORDSZ 32
  1696. # define MACH_TYPE "ARM32"
  1697. # define ALIGNMENT 4
  1698. # ifdef NETBSD
  1699. # define OS_TYPE "NETBSD"
  1700. # define HEURISTIC2
  1701. # ifdef __ELF__
  1702. # define DATASTART GC_data_start
  1703. # define DYNAMIC_LOADING
  1704. # else
  1705. extern char etext[];
  1706. # define DATASTART ((ptr_t)(etext))
  1707. # endif
  1708. # endif
  1709. # ifdef LINUX
  1710. # define OS_TYPE "LINUX"
  1711. # define LINUX_STACKBOTTOM
  1712. # undef STACK_GRAN
  1713. # define STACK_GRAN 0x10000000
  1714. # ifdef __ELF__
  1715. # define DYNAMIC_LOADING
  1716. # include <features.h>
  1717. # if defined(__GLIBC__) && __GLIBC__ >= 2
  1718. # define SEARCH_FOR_DATA_START
  1719. # else
  1720. extern char **__environ;
  1721. # define DATASTART ((ptr_t)(&__environ))
  1722. /* hideous kludge: __environ is the first */
  1723. /* word in crt0.o, and delimits the start */
  1724. /* of the data segment, no matter which */
  1725. /* ld options were passed through. */
  1726. /* We could use _etext instead, but that */
  1727. /* would include .rodata, which may */
  1728. /* contain large read-only data tables */
  1729. /* that we'd rather not scan. */
  1730. # endif
  1731. extern int _end[];
  1732. # define DATAEND (_end)
  1733. # else
  1734. extern int etext[];
  1735. # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
  1736. # endif
  1737. # endif
  1738. # ifdef MSWINCE
  1739. # define OS_TYPE "MSWINCE"
  1740. # define DATAEND /* not needed */
  1741. # endif
  1742. # ifdef NOSYS
  1743. /* __data_start is usually defined in the target linker script. */
  1744. extern int __data_start[];
  1745. # define DATASTART (ptr_t)(__data_start)
  1746. /* __stack_base__ is set in newlib/libc/sys/arm/crt0.S */
  1747. extern void *__stack_base__;
  1748. # define STACKBOTTOM ((ptr_t) (__stack_base__))
  1749. # endif
  1750. #endif
  1751. # ifdef CRIS
  1752. # define MACH_TYPE "CRIS"
  1753. # define CPP_WORDSZ 32
  1754. # define ALIGNMENT 1
  1755. # define OS_TYPE "LINUX"
  1756. # define DYNAMIC_LOADING
  1757. # define LINUX_STACKBOTTOM
  1758. # define SEARCH_FOR_DATA_START
  1759. extern int _end[];
  1760. # define DATAEND (_end)
  1761. # endif
  1762. # ifdef SH
  1763. # define MACH_TYPE "SH"
  1764. # define ALIGNMENT 4
  1765. # ifdef MSWINCE
  1766. # define OS_TYPE "MSWINCE"
  1767. # define DATAEND /* not needed */
  1768. # endif
  1769. # ifdef LINUX
  1770. # define OS_TYPE "LINUX"
  1771. # define LINUX_STACKBOTTOM
  1772. # define DYNAMIC_LOADING
  1773. # define SEARCH_FOR_DATA_START
  1774. extern int _end[];
  1775. # define DATAEND (_end)
  1776. # endif
  1777. # ifdef NETBSD
  1778. # define OS_TYPE "NETBSD"
  1779. # define HEURISTIC2
  1780. # define DATASTART GC_data_start
  1781. # define DYNAMIC_LOADING
  1782. # endif
  1783. # endif
  1784. # ifdef SH4
  1785. # define MACH_TYPE "SH4"
  1786. # define OS_TYPE "MSWINCE"
  1787. # define ALIGNMENT 4
  1788. # define DATAEND /* not needed */
  1789. # endif
  1790. # ifdef M32R
  1791. # define CPP_WORDSZ 32
  1792. # define MACH_TYPE "M32R"
  1793. # define ALIGNMENT 4
  1794. # ifdef LINUX
  1795. # define OS_TYPE "LINUX"
  1796. # define LINUX_STACKBOTTOM
  1797. # undef STACK_GRAN
  1798. # define STACK_GRAN 0x10000000
  1799. # define DYNAMIC_LOADING
  1800. # define SEARCH_FOR_DATA_START
  1801. extern int _end[];
  1802. # define DATAEND (_end)
  1803. # endif
  1804. # endif
  1805. # ifdef X86_64
  1806. # define MACH_TYPE "X86_64"
  1807. # define ALIGNMENT 8
  1808. # define CPP_WORDSZ 64
  1809. # ifndef HBLKSIZE
  1810. # define HBLKSIZE 4096
  1811. # endif
  1812. # define CACHE_LINE_SIZE 64
  1813. # ifdef LINUX
  1814. # define OS_TYPE "LINUX"
  1815. # define LINUX_STACKBOTTOM
  1816. # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
  1817. # define MPROTECT_VDB
  1818. # else
  1819. /* We seem to get random errors in incremental mode, */
  1820. /* possibly because Linux threads is itself a malloc client */
  1821. /* and can't deal with the signals. */
  1822. # endif
  1823. # ifdef __ELF__
  1824. # define DYNAMIC_LOADING
  1825. # ifdef UNDEFINED /* includes ro data */
  1826. extern int _etext[];
  1827. # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
  1828. # endif
  1829. # include <features.h>
  1830. # define SEARCH_FOR_DATA_START
  1831. extern int _end[];
  1832. # define DATAEND (_end)
  1833. # else
  1834. extern int etext[];
  1835. # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
  1836. # endif
  1837. # if defined(__GNUC__) && __GNUC__ >= 3
  1838. # define PREFETCH(x) __builtin_prefetch((x), 0, 0)
  1839. # define PREFETCH_FOR_WRITE(x) __builtin_prefetch((x), 1)
  1840. # endif
  1841. # endif
  1842. # ifdef DARWIN
  1843. # define OS_TYPE "DARWIN"
  1844. # define DARWIN_DONT_PARSE_STACK
  1845. # define DYNAMIC_LOADING
  1846. /* XXX: see get_end(3), get_etext() and get_end() should not be used.
  1847. These aren't used when dyld support is enabled (it is by default) */
  1848. # define DATASTART ((ptr_t) get_etext())
  1849. # define DATAEND ((ptr_t) get_end())
  1850. # define STACKBOTTOM ((ptr_t) 0x7fff5fc00000)
  1851. # define USE_MMAP
  1852. # define USE_MMAP_ANON
  1853. # ifdef GC_DARWIN_THREADS
  1854. # define MPROTECT_VDB
  1855. # endif
  1856. # include <unistd.h>
  1857. # define GETPAGESIZE() getpagesize()
  1858. /* There seems to be some issues with trylock hanging on darwin. This
  1859. should be looked into some more */
  1860. # define NO_PTHREAD_TRYLOCK
  1861. # endif
  1862. # ifdef FREEBSD
  1863. # define OS_TYPE "FREEBSD"
  1864. # ifndef GC_FREEBSD_THREADS
  1865. # define MPROTECT_VDB
  1866. # endif
  1867. # ifdef __GLIBC__
  1868. # define SIG_SUSPEND (32+6)
  1869. # define SIG_THR_RESTART (32+5)
  1870. extern int _end[];
  1871. # define DATAEND (_end)
  1872. # else
  1873. # define SIG_SUSPEND SIGUSR1
  1874. # define SIG_THR_RESTART SIGUSR2
  1875. # endif
  1876. # define FREEBSD_STACKBOTTOM
  1877. # ifdef __ELF__
  1878. # define DYNAMIC_LOADING
  1879. # endif
  1880. extern char etext[];
  1881. extern char * GC_FreeBSDGetDataStart();
  1882. # define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
  1883. # endif
  1884. # ifdef NETBSD
  1885. # define OS_TYPE "NETBSD"
  1886. # ifdef __ELF__
  1887. # define DYNAMIC_LOADING
  1888. # endif
  1889. # define HEURISTIC2
  1890. extern char etext[];
  1891. # define SEARCH_FOR_DATA_START
  1892. # endif
  1893. # ifdef SOLARIS
  1894. # define OS_TYPE "SOLARIS"
  1895. # define ELF_CLASS ELFCLASS64
  1896. extern int _etext[], _end[];
  1897. extern ptr_t GC_SysVGetDataStart(size_t, ptr_t);
  1898. # define DATASTART GC_SysVGetDataStart(0x1000, (ptr_t)_etext)
  1899. # define DATAEND (_end)
  1900. /* # define STACKBOTTOM ((ptr_t)(_start)) worked through 2.7, */
  1901. /* but reportedly breaks under 2.8. It appears that the stack */
  1902. /* base is a property of the executable, so this should not break */
  1903. /* old executables. */
  1904. /* HEURISTIC2 probably works, but this appears to be preferable. */
  1905. /* Apparently USRSTACK is defined to be USERLIMIT, but in some */
  1906. /* installations that's undefined. We work around this with a */
  1907. /* gross hack: */
  1908. # include <sys/vmparam.h>
  1909. # ifdef USERLIMIT
  1910. /* This should work everywhere, but doesn't. */
  1911. # define STACKBOTTOM USRSTACK
  1912. # else
  1913. # define HEURISTIC2
  1914. # endif
  1915. /* At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */
  1916. /* It appears to be fixed in 2.8 and 2.9. */
  1917. # ifdef SOLARIS25_PROC_VDB_BUG_FIXED
  1918. # define PROC_VDB
  1919. # endif
  1920. # define DYNAMIC_LOADING
  1921. # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
  1922. # define USE_MMAP
  1923. /* Otherwise we now use calloc. Mmap may result in the */
  1924. /* heap interleaved with thread stacks, which can result in */
  1925. /* excessive blacklisting. Sbrk is unusable since it */
  1926. /* doesn't interact correctly with the system malloc. */
  1927. # endif
  1928. # ifdef USE_MMAP
  1929. # define HEAP_START (ptr_t)0x40000000
  1930. # else
  1931. # define HEAP_START DATAEND
  1932. # endif
  1933. # endif
  1934. # ifdef MSWIN32
  1935. # define OS_TYPE "MSWIN32"
  1936. /* STACKBOTTOM and DATASTART are handled specially in */
  1937. /* os_dep.c. */
  1938. # if !defined(__WATCOMC__)
  1939. # define MPROTECT_VDB
  1940. /* We also avoided doing this in the past with GC_WIN32_THREADS */
  1941. /* Hopefully that's fixed. */
  1942. # endif
  1943. # if _MSC_VER >= 1300 /* .NET, i.e. > VisualStudio 6 */
  1944. # define GWW_VDB
  1945. # endif
  1946. # define DATAEND /* not needed */
  1947. # endif
  1948. # endif
  1949. #if defined(LINUX_STACKBOTTOM) && defined(NO_PROC_STAT) \
  1950. && !defined(USE_LIBC_PRIVATES)
  1951. /* This combination will fail, since we have no way to get */
  1952. /* the stack base. Use HEURISTIC2 instead. */
  1953. # undef LINUX_STACKBOTTOM
  1954. # define HEURISTIC2
  1955. /* This may still fail on some architectures like IA64. */
  1956. /* We tried ... */
  1957. #endif
  1958. #if defined(LINUX) && defined(USE_MMAP)
  1959. /* The kernel may do a somewhat better job merging mappings etc. */
  1960. /* with anonymous mappings. */
  1961. # define USE_MMAP_ANON
  1962. #endif
  1963. #if defined(GC_LINUX_THREADS) && defined(REDIRECT_MALLOC)
  1964. /* Nptl allocates thread stacks with mmap, which is fine. But it */
  1965. /* keeps a cache of thread stacks. Thread stacks contain the */
  1966. /* thread control blocks. These in turn contain a pointer to */
  1967. /* (sizeof (void *) from the beginning of) the dtv for thread-local */
  1968. /* storage, which is calloc allocated. If we don't scan the cached */
  1969. /* thread stacks, we appear to lose the dtv. This tends to */
  1970. /* result in something that looks like a bogus dtv count, which */
  1971. /* tends to result in a memset call on a block that is way too */
  1972. /* large. Sometimes we're lucky and the process just dies ... */
  1973. /* There seems to be a similar issue with some other memory */
  1974. /* allocated by the dynamic loader. */
  1975. /* This should be avoidable by either: */
  1976. /* - Defining USE_PROC_FOR_LIBRARIES here. */
  1977. /* That performs very poorly, precisely because we end up */
  1978. /* scanning cached stacks. */
  1979. /* - Have calloc look at its callers. */
  1980. /* In spite of the fact that it is gross and disgusting. */
  1981. /* In fact neither seems to suffice, probably in part because */
  1982. /* even with USE_PROC_FOR_LIBRARIES, we don't scan parts of stack */
  1983. /* segments that appear to be out of bounds. Thus we actually */
  1984. /* do both, which seems to yield the best results. */
  1985. # define USE_PROC_FOR_LIBRARIES
  1986. #endif
  1987. # ifndef STACK_GROWS_UP
  1988. # define STACK_GROWS_DOWN
  1989. # endif
  1990. # ifndef CPP_WORDSZ
  1991. # define CPP_WORDSZ 32
  1992. # endif
  1993. # ifndef OS_TYPE
  1994. # define OS_TYPE ""
  1995. # endif
  1996. # ifndef DATAEND
  1997. extern int end[];
  1998. # define DATAEND (end)
  1999. # endif
  2000. # if defined(SVR4) && !defined(GETPAGESIZE)
  2001. # include <unistd.h>
  2002. # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
  2003. # endif
  2004. # ifndef GETPAGESIZE
  2005. # if defined(SOLARIS) || defined(IRIX5) || defined(LINUX) \
  2006. || defined(NETBSD) || defined(FREEBSD) || defined(HPUX)
  2007. # include <unistd.h>
  2008. # endif
  2009. # define GETPAGESIZE() getpagesize()
  2010. # endif
  2011. # if defined(SOLARIS) || defined(DRSNX) || defined(UTS4)
  2012. /* OS has SVR4 generic features. */
  2013. /* Probably others also qualify. */
  2014. # define SVR4
  2015. # endif
  2016. # if defined(SOLARIS) || defined(DRSNX)
  2017. /* OS has SOLARIS style semi-undocumented interface */
  2018. /* to dynamic loader. */
  2019. # define SOLARISDL
  2020. /* OS has SOLARIS style signal handlers. */
  2021. # define SUNOS5SIGS
  2022. # endif
  2023. # if defined(HPUX)
  2024. # define SUNOS5SIGS
  2025. # endif
  2026. # if defined(FREEBSD) && \
  2027. (defined(__DragonFly__) || __FreeBSD__ >= 4 || (__FreeBSD_kernel__ >= 4))
  2028. # define SUNOS5SIGS
  2029. # endif
  2030. # ifdef GC_NETBSD_THREADS
  2031. # define SIGRTMIN 33
  2032. # define SIGRTMAX 63
  2033. # endif
  2034. # if defined(SVR4) || defined(LINUX) || defined(IRIX5) || defined(HPUX) \
  2035. || defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD) \
  2036. || defined(DGUX) || defined(BSD) \
  2037. || defined(AIX) || defined(DARWIN) || defined(OSF1) \
  2038. || defined(HURD)
  2039. # define UNIX_LIKE /* Basic Unix-like system calls work. */
  2040. # endif
  2041. # if CPP_WORDSZ != 32 && CPP_WORDSZ != 64
  2042. -> bad word size
  2043. # endif
  2044. # ifdef PCR
  2045. # undef DYNAMIC_LOADING
  2046. # undef STACKBOTTOM
  2047. # undef HEURISTIC1
  2048. # undef HEURISTIC2
  2049. # undef PROC_VDB
  2050. # undef MPROTECT_VDB
  2051. # define PCR_VDB
  2052. # endif
  2053. # ifdef SMALL_CONFIG
  2054. /* Presumably not worth the space it takes. */
  2055. # undef PROC_VDB
  2056. # undef MPROTECT_VDB
  2057. # endif
  2058. # ifdef USE_MUNMAP
  2059. # undef MPROTECT_VDB /* Can't deal with address space holes. */
  2060. # endif
  2061. # ifdef PARALLEL_MARK
  2062. # undef MPROTECT_VDB /* For now. */
  2063. # endif
  2064. # if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB) \
  2065. && !defined(GWW_VDB)
  2066. # define DEFAULT_VDB
  2067. # endif
  2068. # ifndef PREFETCH
  2069. # define PREFETCH(x)
  2070. # define NO_PREFETCH
  2071. # endif
  2072. # ifndef PREFETCH_FOR_WRITE
  2073. # define PREFETCH_FOR_WRITE(x)
  2074. # define NO_PREFETCH_FOR_WRITE
  2075. # endif
  2076. # ifndef CACHE_LINE_SIZE
  2077. # define CACHE_LINE_SIZE 32 /* Wild guess */
  2078. # endif
  2079. # if defined(LINUX) || defined(HURD) || defined(__GLIBC__)
  2080. # define REGISTER_LIBRARIES_EARLY
  2081. /* We sometimes use dl_iterate_phdr, which may acquire an internal */
  2082. /* lock. This isn't safe after the world has stopped. So we must */
  2083. /* call GC_register_dynamic_libraries before stopping the world. */
  2084. /* For performance reasons, this may be beneficial on other */
  2085. /* platforms as well, though it should be avoided in win32. */
  2086. # endif /* LINUX */
  2087. # if defined(SEARCH_FOR_DATA_START)
  2088. extern ptr_t GC_data_start;
  2089. # define DATASTART GC_data_start
  2090. # endif
  2091. # ifndef CLEAR_DOUBLE
  2092. # define CLEAR_DOUBLE(x) \
  2093. ((word*)x)[0] = 0; \
  2094. ((word*)x)[1] = 0;
  2095. # endif /* CLEAR_DOUBLE */
  2096. # if defined(GC_LINUX_THREADS) && defined(REDIRECT_MALLOC) \
  2097. && !defined(INCLUDE_LINUX_THREAD_DESCR)
  2098. /* Will not work, since libc and the dynamic loader use thread */
  2099. /* locals, sometimes as the only reference. */
  2100. # define INCLUDE_LINUX_THREAD_DESCR
  2101. # endif
  2102. # if defined(GC_IRIX_THREADS) && !defined(IRIX5)
  2103. --> inconsistent configuration
  2104. # endif
  2105. # if defined(GC_LINUX_THREADS) && !defined(LINUX)
  2106. --> inconsistent configuration
  2107. # endif
  2108. # if defined(GC_NETBSD_THREADS) && !defined(NETBSD)
  2109. --> inconsistent configuration
  2110. # endif
  2111. # if defined(GC_FREEBSD_THREADS) && !defined(FREEBSD)
  2112. --> inconsistent configuration
  2113. # endif
  2114. # if defined(GC_SOLARIS_THREADS) && !defined(SOLARIS)
  2115. --> inconsistent configuration
  2116. # endif
  2117. # if defined(GC_HPUX_THREADS) && !defined(HPUX)
  2118. --> inconsistent configuration
  2119. # endif
  2120. # if defined(GC_AIX_THREADS) && !defined(_AIX)
  2121. --> inconsistent configuration
  2122. # endif
  2123. # if defined(GC_GNU_THREADS) && !defined(HURD)
  2124. --> inconsistent configuration
  2125. # endif
  2126. # if defined(GC_WIN32_THREADS) && !defined(MSWIN32) && !defined(CYGWIN32)
  2127. --> inconsistent configuration
  2128. # endif
  2129. # if defined(PCR) || defined(GC_WIN32_THREADS) || defined(GC_PTHREADS)
  2130. # define THREADS
  2131. # endif
  2132. # if !defined(USE_MARK_BITS) && !defined(USE_MARK_BYTES)
  2133. # if defined(THREADS) && defined(PARALLEL_MARK)
  2134. # define USE_MARK_BYTES
  2135. # else
  2136. # define USE_MARK_BITS
  2137. # endif
  2138. # endif
  2139. # if defined(MSWINCE)
  2140. # define NO_GETENV
  2141. # endif
  2142. # if defined(SPARC)
  2143. # define ASM_CLEAR_CODE /* Stack clearing is crucial, and we */
  2144. /* include assembly code to do it well. */
  2145. # endif
  2146. /* Can we save call chain in objects for debugging? */
  2147. /* SET NFRAMES (# of saved frames) and NARGS (#of args for each */
  2148. /* frame) to reasonable values for the platform. */
  2149. /* Set SAVE_CALL_CHAIN if we can. SAVE_CALL_COUNT can be specified */
  2150. /* at build time, though we feel free to adjust it slightly. */
  2151. /* Define NEED_CALLINFO if we either save the call stack or */
  2152. /* GC_ADD_CALLER is defined. */
  2153. /* GC_CAN_SAVE_CALL_STACKS is set in gc.h. */
  2154. #if defined(SPARC)
  2155. # define CAN_SAVE_CALL_ARGS
  2156. #endif
  2157. #if (defined(I386) || defined(X86_64)) && (defined(LINUX) || defined(__GLIBC__))
  2158. /* SAVE_CALL_CHAIN is supported if the code is compiled to save */
  2159. /* frame pointers by default, i.e. no -fomit-frame-pointer flag. */
  2160. # define CAN_SAVE_CALL_ARGS
  2161. #endif
  2162. # if defined(SAVE_CALL_COUNT) && !defined(GC_ADD_CALLER) \
  2163. && defined(GC_CAN_SAVE_CALL_STACKS)
  2164. # define SAVE_CALL_CHAIN
  2165. # endif
  2166. # ifdef SAVE_CALL_CHAIN
  2167. # if defined(SAVE_CALL_NARGS) && defined(CAN_SAVE_CALL_ARGS)
  2168. # define NARGS SAVE_CALL_NARGS
  2169. # else
  2170. # define NARGS 0 /* Number of arguments to save for each call. */
  2171. # endif
  2172. # endif
  2173. # ifdef SAVE_CALL_CHAIN
  2174. # ifndef SAVE_CALL_COUNT
  2175. # define NFRAMES 6 /* Number of frames to save. Even for */
  2176. /* alignment reasons. */
  2177. # else
  2178. # define NFRAMES ((SAVE_CALL_COUNT + 1) & ~1)
  2179. # endif
  2180. # define NEED_CALLINFO
  2181. # endif /* SAVE_CALL_CHAIN */
  2182. # ifdef GC_ADD_CALLER
  2183. # define NFRAMES 1
  2184. # define NARGS 0
  2185. # define NEED_CALLINFO
  2186. # endif
  2187. # if defined(MAKE_BACK_GRAPH) && !defined(DBG_HDRS_ALL)
  2188. # define DBG_HDRS_ALL
  2189. # endif
  2190. # if defined(POINTER_MASK) && !defined(POINTER_SHIFT)
  2191. # define POINTER_SHIFT 0
  2192. # endif
  2193. # if defined(POINTER_SHIFT) && !defined(POINTER_MASK)
  2194. # define POINTER_MASK ((GC_word)(-1))
  2195. # endif
  2196. # if !defined(FIXUP_POINTER) && defined(POINTER_MASK)
  2197. # define FIXUP_POINTER(p) (p) = ((p) & (POINTER_MASK) << POINTER_SHIFT)
  2198. # endif
  2199. # if defined(FIXUP_POINTER)
  2200. # define NEED_FIXUP_POINTER 1
  2201. # else
  2202. # define NEED_FIXUP_POINTER 0
  2203. # define FIXUP_POINTER(p)
  2204. # endif
  2205. # if !defined(MARK_BIT_PER_GRANULE) && !defined(MARK_BIT_PER_OBJ)
  2206. # define MARK_BIT_PER_GRANULE /* Usually faster */
  2207. # endif
  2208. /* Some static sanity tests. */
  2209. # if defined(MARK_BIT_PER_GRANULE) && defined(MARK_BIT_PER_OBJ)
  2210. # error Define only one of MARK_BIT_PER_GRANULE and MARK_BIT_PER_OBJ.
  2211. # endif
  2212. # if defined(STACK_GROWS_UP) && defined(STACK_GROWS_DOWN)
  2213. # error "Only one of STACK_GROWS_UP and STACK_GROWS_DOWN should be defd."
  2214. # endif
  2215. # if !defined(STACK_GROWS_UP) && !defined(STACK_GROWS_DOWN)
  2216. # error "One of STACK_GROWS_UP and STACK_GROWS_DOWN should be defd."
  2217. # endif
  2218. # if defined(REDIRECT_MALLOC) && defined(THREADS) && !defined(LINUX)
  2219. # error "REDIRECT_MALLOC with THREADS works at most on Linux."
  2220. # endif
  2221. #ifdef GC_PRIVATE_H
  2222. /* This relies on some type definitions from gc_priv.h, from */
  2223. /* where it's normally included. */
  2224. /* */
  2225. /* How to get heap memory from the OS: */
  2226. /* Note that sbrk()-like allocation is preferred, since it */
  2227. /* usually makes it possible to merge consecutively allocated */
  2228. /* chunks. It also avoids unintented recursion with */
  2229. /* -DREDIRECT_MALLOC. */
  2230. /* GET_MEM() returns a HLKSIZE aligned chunk. */
  2231. /* 0 is taken to mean failure. */
  2232. /* In the case os USE_MMAP, the argument must also be a */
  2233. /* physical page size. */
  2234. /* GET_MEM is currently not assumed to retrieve 0 filled space, */
  2235. /* though we should perhaps take advantage of the case in which */
  2236. /* does. */
  2237. struct hblk; /* See gc_priv.h. */
  2238. # if defined(PCR)
  2239. char * real_malloc();
  2240. # define GET_MEM(bytes) HBLKPTR(real_malloc((size_t)bytes + GC_page_size) \
  2241. + GC_page_size-1)
  2242. # elif defined(OS2)
  2243. void * os2_alloc(size_t bytes);
  2244. # define GET_MEM(bytes) HBLKPTR((ptr_t)os2_alloc((size_t)bytes \
  2245. + GC_page_size) \
  2246. + GC_page_size-1)
  2247. # elif defined(NEXT) || defined(DOS4GW) || defined(NONSTOP) || \
  2248. (defined(AMIGA) && !defined(GC_AMIGA_FASTALLOC)) || \
  2249. (defined(SOLARIS) && !defined(USE_MMAP))
  2250. # define GET_MEM(bytes) HBLKPTR((size_t) calloc(1, (size_t)bytes + GC_page_size) \
  2251. + GC_page_size-1)
  2252. # elif defined(MSWIN32)
  2253. extern ptr_t GC_win32_get_mem();
  2254. # define GET_MEM(bytes) (struct hblk *)GC_win32_get_mem(bytes)
  2255. # elif defined(MACOS)
  2256. # if defined(USE_TEMPORARY_MEMORY)
  2257. extern Ptr GC_MacTemporaryNewPtr(size_t size, Boolean clearMemory);
  2258. # define GET_MEM(bytes) HBLKPTR( \
  2259. GC_MacTemporaryNewPtr(bytes + GC_page_size, true) \
  2260. + GC_page_size-1)
  2261. # else
  2262. # define GET_MEM(bytes) HBLKPTR( \
  2263. NewPtrClear(bytes + GC_page_size) + GC_page_size-1)
  2264. # endif
  2265. # elif defined(MSWINCE)
  2266. extern ptr_t GC_wince_get_mem();
  2267. # define GET_MEM(bytes) (struct hblk *)GC_wince_get_mem(bytes)
  2268. # elif defined(AMIGA) && defined(GC_AMIGA_FASTALLOC)
  2269. extern void *GC_amiga_get_mem(size_t size);
  2270. # define GET_MEM(bytes) HBLKPTR((size_t) \
  2271. GC_amiga_get_mem((size_t)bytes + GC_page_size) \
  2272. + GC_page_size-1)
  2273. # else
  2274. extern ptr_t GC_unix_get_mem();
  2275. # define GET_MEM(bytes) (struct hblk *)GC_unix_get_mem(bytes)
  2276. # endif
  2277. #endif /* GC_PRIVATE_H */
  2278. # endif /* GCCONFIG_H */