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