gcconfig.h
上传用户:fbh598
上传日期:2007-07-05
资源大小:5960k
文件大小:66k
源码类别:

Java编程

开发平台:

Unix_Linux

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