gcconfig.h 123 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656
  1. /*
  2. * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
  3. * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
  4. * Copyright (c) 1996 by Silicon Graphics. All rights reserved.
  5. * Copyright (c) 2000-2004 Hewlett-Packard Development Company, L.P.
  6. *
  7. * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
  8. * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
  9. *
  10. * Permission is hereby granted to use or copy this program
  11. * for any purpose, provided the above notices are retained on all copies.
  12. * Permission to modify the code and to distribute modified code is granted,
  13. * provided the above notices are retained, and a notice that the code was
  14. * modified is included with the above copyright notice.
  15. */
  16. /*
  17. * This header is private to the gc. It is almost always included from
  18. * gc_priv.h. However it is possible to include it by itself if just the
  19. * configuration macros are needed. In that
  20. * case, a few declarations relying on types declared in gc_priv.h will be
  21. * omitted.
  22. */
  23. #ifndef GCCONFIG_H
  24. #define GCCONFIG_H
  25. #define MANUAL_VDB
  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. # include <stddef.h> /* For size_t etc. */
  31. # endif
  32. /* Note: Only wrap our own declarations, and not the included headers. */
  33. /* In this case, wrap our entire file, but temporarily unwrap/rewrap */
  34. /* around #includes. Types and macros do not need such wrapping, only */
  35. /* the declared global data and functions. */
  36. #ifdef __cplusplus
  37. # define EXTERN_C_BEGIN extern "C" {
  38. # define EXTERN_C_END } /* extern "C" */
  39. #else
  40. # define EXTERN_C_BEGIN /* empty */
  41. # define EXTERN_C_END /* empty */
  42. #endif
  43. EXTERN_C_BEGIN
  44. /* Convenient internal macro to test version of Clang. */
  45. #if defined(__clang__) && defined(__clang_major__)
  46. # define GC_CLANG_PREREQ(major, minor) \
  47. ((__clang_major__ << 16) + __clang_minor__ >= ((major) << 16) + (minor))
  48. # define GC_CLANG_PREREQ_FULL(major, minor, patchlevel) \
  49. (GC_CLANG_PREREQ(major, (minor) + 1) \
  50. || (__clang_major__ == (major) && __clang_minor__ == (minor) \
  51. && __clang_patchlevel__ >= (patchlevel)))
  52. #else
  53. # define GC_CLANG_PREREQ(major, minor) 0 /* FALSE */
  54. # define GC_CLANG_PREREQ_FULL(major, minor, patchlevel) 0
  55. #endif
  56. #ifdef LINT2
  57. /* A macro (based on a tricky expression) to prevent false warnings */
  58. /* like "Array compared to 0", "Comparison of identical expressions", */
  59. /* "Untrusted loop bound" output by some static code analysis tools. */
  60. /* The argument should not be a literal value. The result is */
  61. /* converted to word type. (Actually, GC_word is used instead of */
  62. /* word type as the latter might be undefined at the place of use.) */
  63. # define COVERT_DATAFLOW(w) (~(GC_word)(w)^(~(GC_word)0))
  64. #else
  65. # define COVERT_DATAFLOW(w) ((GC_word)(w))
  66. #endif
  67. /* Machine dependent parameters. Some tuning parameters can be found */
  68. /* near the top of gc_private.h. */
  69. /* Machine specific parts contributed by various people. See README file. */
  70. #if defined(__ANDROID__) && !defined(HOST_ANDROID)
  71. /* __ANDROID__ macro is defined by Android NDK gcc. */
  72. # define HOST_ANDROID 1
  73. #endif
  74. #if defined(HOST_ANDROID)
  75. #define IGNORE_PROG_DATA_START
  76. #endif
  77. #if defined(TIZEN) && !defined(HOST_TIZEN)
  78. # define HOST_TIZEN 1
  79. #endif
  80. #if defined(__SYMBIAN32__) && !defined(SYMBIAN)
  81. # define SYMBIAN
  82. # ifdef __WINS__
  83. # pragma data_seg(".data2")
  84. # endif
  85. #endif
  86. /* First a unified test for Linux: */
  87. # if (defined(linux) || defined(__linux__) || defined(HOST_ANDROID)) \
  88. && !defined(LINUX) && !defined(__native_client__)
  89. # define LINUX
  90. # endif
  91. /* And one for NetBSD: */
  92. # if defined(__NetBSD__)
  93. # define NETBSD
  94. # endif
  95. /* And one for OpenBSD: */
  96. # if defined(__OpenBSD__)
  97. # define OPENBSD
  98. # endif
  99. /* And one for FreeBSD: */
  100. # if (defined(__FreeBSD__) || defined(__DragonFly__) \
  101. || defined(__FreeBSD_kernel__)) && !defined(FREEBSD) \
  102. && !defined(GC_NO_FREEBSD)
  103. # define FREEBSD
  104. # endif
  105. /* And one for Darwin: */
  106. # if defined(macosx) || (defined(__APPLE__) && defined(__MACH__))
  107. # define DARWIN
  108. EXTERN_C_END
  109. # include <TargetConditionals.h>
  110. EXTERN_C_BEGIN
  111. # endif
  112. /* Determine the machine type: */
  113. # if defined(__native_client__)
  114. # define NACL
  115. # if !defined(__portable_native_client__) && !defined(__arm__)
  116. # define I386
  117. # define mach_type_known
  118. # else
  119. /* Here we will rely upon arch-specific defines. */
  120. # endif
  121. # endif
  122. # if defined(__aarch64__)
  123. # define AARCH64
  124. # if !defined(LINUX) && !defined(DARWIN) && !defined(FREEBSD) \
  125. && !defined(NN_BUILD_TARGET_PLATFORM_NX) && !defined(__QNX__)
  126. # define NOSYS
  127. # define mach_type_known
  128. # endif
  129. # endif
  130. # if defined(__arm) || defined(__arm__) || defined(__thumb__)
  131. # define ARM32
  132. # if defined(NACL)
  133. # define mach_type_known
  134. # elif !defined(LINUX) && !defined(NETBSD) && !defined(FREEBSD) \
  135. && !defined(OPENBSD) && !defined(DARWIN) && !defined(_WIN32) \
  136. && !defined(__CEGCC__) && !defined(NN_PLATFORM_CTR) \
  137. && !defined(NN_BUILD_TARGET_PLATFORM_NX) \
  138. && !defined(GC_NO_NOSYS) && !defined(SN_TARGET_PSP2) \
  139. && !defined(SYMBIAN) && !defined(__QNX__)
  140. # define NOSYS
  141. # define mach_type_known
  142. # endif
  143. # endif
  144. # if defined(sun) && defined(mc68000) && !defined(CPPCHECK)
  145. # error SUNOS4 no longer supported
  146. # endif
  147. # if defined(hp9000s300) && !defined(CPPCHECK)
  148. # error M68K based HP machines no longer supported.
  149. # endif
  150. # if defined(OPENBSD) && defined(m68k)
  151. /* FIXME: Should we remove this case? */
  152. # define M68K
  153. # define mach_type_known
  154. # endif
  155. # if defined(OPENBSD) && defined(__sparc__)
  156. # define SPARC
  157. # define mach_type_known
  158. # endif
  159. # if defined(OPENBSD) && defined(__arm__)
  160. # define ARM32
  161. # define mach_type_known
  162. # endif
  163. # if defined(OPENBSD) && defined(__sh__)
  164. # define SH
  165. # define mach_type_known
  166. # endif
  167. # if defined(NETBSD) && (defined(m68k) || defined(__m68k__))
  168. # define M68K
  169. # define mach_type_known
  170. # endif
  171. # if defined(NETBSD) && defined(__powerpc__)
  172. # define POWERPC
  173. # define mach_type_known
  174. # endif
  175. # if defined(NETBSD) && (defined(__arm32__) || defined(__arm__))
  176. # define ARM32
  177. # define mach_type_known
  178. # endif
  179. # if defined(NETBSD) && defined(__sh__)
  180. # define SH
  181. # define mach_type_known
  182. # endif
  183. # if defined(vax) || defined(__vax__)
  184. # define VAX
  185. # ifdef ultrix
  186. # define ULTRIX
  187. # else
  188. # define BSD
  189. # endif
  190. # define mach_type_known
  191. # endif
  192. # if defined(__NetBSD__) && defined(__vax__)
  193. # define VAX
  194. # define mach_type_known
  195. # endif
  196. # if defined(mips) || defined(__mips) || defined(_mips)
  197. # define MIPS
  198. # if defined(nec_ews) || defined(_nec_ews)
  199. # define EWS4800
  200. # endif
  201. # if !defined(LINUX) && !defined(EWS4800) && !defined(NETBSD) \
  202. && !defined(OPENBSD)
  203. # if defined(ultrix) || defined(__ultrix)
  204. # define ULTRIX
  205. # else
  206. # define IRIX5 /* or IRIX 6.X */
  207. # endif
  208. # endif /* !LINUX */
  209. # if defined(__NetBSD__) && defined(__MIPSEL__)
  210. # undef ULTRIX
  211. # endif
  212. # define mach_type_known
  213. # endif
  214. # if defined(__NIOS2__) || defined(__NIOS2) || defined(__nios2__)
  215. # define NIOS2 /* Altera NIOS2 */
  216. # define mach_type_known
  217. # endif
  218. # if defined(__or1k__)
  219. # define OR1K /* OpenRISC/or1k */
  220. # define mach_type_known
  221. # endif
  222. # if defined(DGUX) && (defined(i386) || defined(__i386__))
  223. # define I386
  224. # ifndef _USING_DGUX
  225. # define _USING_DGUX
  226. # endif
  227. # define mach_type_known
  228. # endif
  229. # if defined(sequent) && (defined(i386) || defined(__i386__))
  230. # define I386
  231. # define SEQUENT
  232. # define mach_type_known
  233. # endif
  234. # if (defined(sun) || defined(__sun)) && (defined(i386) || defined(__i386__))
  235. # define I386
  236. # define SOLARIS
  237. # define mach_type_known
  238. # endif
  239. # if (defined(sun) || defined(__sun)) && defined(__amd64)
  240. # define X86_64
  241. # define SOLARIS
  242. # define mach_type_known
  243. # endif
  244. # if (defined(__OS2__) || defined(__EMX__)) && defined(__32BIT__)
  245. # define I386
  246. # define OS2
  247. # define mach_type_known
  248. # endif
  249. # if defined(ibm032) && !defined(CPPCHECK)
  250. # error IBM PC/RT no longer supported.
  251. # endif
  252. # if (defined(sun) || defined(__sun)) && (defined(sparc) || defined(__sparc))
  253. /* Test for SunOS 5.x */
  254. EXTERN_C_END
  255. # include <errno.h>
  256. EXTERN_C_BEGIN
  257. # define SPARC
  258. # define SOLARIS
  259. # define mach_type_known
  260. # elif defined(sparc) && defined(unix) && !defined(sun) && !defined(linux) \
  261. && !defined(__OpenBSD__) && !defined(__NetBSD__) \
  262. && !defined(__FreeBSD__) && !defined(__DragonFly__)
  263. # define SPARC
  264. # define DRSNX
  265. # define mach_type_known
  266. # endif
  267. # if defined(_IBMR2)
  268. # define POWERPC
  269. # define AIX
  270. # define mach_type_known
  271. # endif
  272. # if defined(__NetBSD__) && defined(__sparc__)
  273. # define SPARC
  274. # define mach_type_known
  275. # endif
  276. # if defined(_M_XENIX) && defined(_M_SYSV) && defined(_M_I386)
  277. /* The above test may need refinement */
  278. # define I386
  279. # if defined(_SCO_ELF)
  280. # define SCO_ELF
  281. # else
  282. # define SCO
  283. # endif
  284. # define mach_type_known
  285. # endif
  286. # if defined(_AUX_SOURCE) && !defined(CPPCHECK)
  287. # error A/UX no longer supported
  288. # endif
  289. # if defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0) \
  290. || defined(hppa) || defined(__hppa__)
  291. # define HP_PA
  292. # if !defined(LINUX) && !defined(HPUX) && !defined(OPENBSD)
  293. # define HPUX
  294. # endif
  295. # define mach_type_known
  296. # endif
  297. # if defined(__ia64) && (defined(_HPUX_SOURCE) || defined(__HP_aCC))
  298. # define IA64
  299. # ifndef HPUX
  300. # define HPUX
  301. # endif
  302. # define mach_type_known
  303. # endif
  304. # if (defined(__BEOS__) || defined(__HAIKU__)) && defined(_X86_)
  305. # define I386
  306. # define HAIKU
  307. # define mach_type_known
  308. # endif
  309. # if defined(__HAIKU__) && (defined(__amd64__) || defined(__x86_64__))
  310. # define X86_64
  311. # define HAIKU
  312. # define mach_type_known
  313. # endif
  314. # if defined(OPENBSD) && defined(__amd64__)
  315. # define X86_64
  316. # define mach_type_known
  317. # endif
  318. # if defined(LINUX) && (defined(i386) || defined(__i386__))
  319. # define I386
  320. # define mach_type_known
  321. # endif
  322. # if defined(LINUX) && defined(__x86_64__)
  323. # define X86_64
  324. # define mach_type_known
  325. # endif
  326. # if defined(LINUX) && (defined(__ia64__) || defined(__ia64))
  327. # define IA64
  328. # define mach_type_known
  329. # endif
  330. # if defined(LINUX) && defined(__aarch64__)
  331. # define AARCH64
  332. # define mach_type_known
  333. # endif
  334. # if defined(LINUX) && (defined(__arm) || defined(__arm__))
  335. # define ARM32
  336. # define mach_type_known
  337. # endif
  338. # if defined(LINUX) && defined(__cris__)
  339. # ifndef CRIS
  340. # define CRIS
  341. # endif
  342. # define mach_type_known
  343. # endif
  344. # if defined(LINUX) && (defined(powerpc) || defined(__powerpc__) \
  345. || defined(powerpc64) || defined(__powerpc64__))
  346. # define POWERPC
  347. # define mach_type_known
  348. # endif
  349. # if defined(LINUX) && defined(__mc68000__)
  350. # define M68K
  351. # define mach_type_known
  352. # endif
  353. # if defined(LINUX) && (defined(sparc) || defined(__sparc__))
  354. # define SPARC
  355. # define mach_type_known
  356. # endif
  357. # if defined(LINUX) && defined(__sh__)
  358. # define SH
  359. # define mach_type_known
  360. # endif
  361. # if defined(LINUX) && defined(__avr32__)
  362. # define AVR32
  363. # define mach_type_known
  364. # endif
  365. # if defined(LINUX) && defined(__m32r__)
  366. # define M32R
  367. # define mach_type_known
  368. # endif
  369. # if defined(__alpha) || defined(__alpha__)
  370. # define ALPHA
  371. # if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD) \
  372. && !defined(FREEBSD)
  373. # define OSF1 /* a.k.a Digital Unix */
  374. # endif
  375. # define mach_type_known
  376. # endif
  377. # if defined(_AMIGA) && !defined(AMIGA)
  378. # define AMIGA
  379. # endif
  380. # ifdef AMIGA
  381. # define M68K
  382. # define mach_type_known
  383. # endif
  384. # if defined(THINK_C) \
  385. || (defined(__MWERKS__) && !defined(__powerc) && !defined(SYMBIAN))
  386. # define M68K
  387. # define MACOS
  388. # define mach_type_known
  389. # endif
  390. # if defined(__MWERKS__) && defined(__powerc) && !defined(__MACH__) \
  391. && !defined(SYMBIAN)
  392. # define POWERPC
  393. # define MACOS
  394. # define mach_type_known
  395. # endif
  396. # if defined(__OpenBSD__) && defined(__powerpc__)
  397. # define POWERPC
  398. # define OPENBSD
  399. # define mach_type_known
  400. # endif
  401. # if defined(DARWIN)
  402. # if defined(__ppc__) || defined(__ppc64__)
  403. # define POWERPC
  404. # define mach_type_known
  405. # elif defined(__x86_64__) || defined(__x86_64)
  406. # define X86_64
  407. # define mach_type_known
  408. # elif defined(__i386__)
  409. # define I386
  410. # define mach_type_known
  411. # elif defined(__arm__)
  412. # define ARM32
  413. # define mach_type_known
  414. # elif defined(__aarch64__)
  415. # define AARCH64
  416. # define mach_type_known
  417. # endif
  418. # endif
  419. # if defined(__rtems__) && (defined(i386) || defined(__i386__))
  420. # define I386
  421. # define RTEMS
  422. # define mach_type_known
  423. # endif
  424. # if defined(NeXT) && defined(mc68000)
  425. # define M68K
  426. # define NEXT
  427. # define mach_type_known
  428. # endif
  429. # if defined(NeXT) && (defined(i386) || defined(__i386__))
  430. # define I386
  431. # define NEXT
  432. # define mach_type_known
  433. # endif
  434. # if defined(__OpenBSD__) && (defined(i386) || defined(__i386__))
  435. # define I386
  436. # define OPENBSD
  437. # define mach_type_known
  438. # endif
  439. # if defined(__NetBSD__) && (defined(i386) || defined(__i386__))
  440. # define I386
  441. # define mach_type_known
  442. # endif
  443. # if defined(__NetBSD__) && defined(__x86_64__)
  444. # define X86_64
  445. # define mach_type_known
  446. # endif
  447. # if defined(FREEBSD) && (defined(i386) || defined(__i386__))
  448. # define I386
  449. # define mach_type_known
  450. # endif
  451. # if (defined(FREEBSD)) \
  452. && (defined(__amd64__) || defined(__x86_64__))
  453. # define X86_64
  454. # define mach_type_known
  455. # endif
  456. # if defined(FREEBSD) && defined(__sparc__)
  457. # define SPARC
  458. # define mach_type_known
  459. # endif
  460. # if defined(FREEBSD) && (defined(powerpc) || defined(__powerpc__))
  461. # define POWERPC
  462. # define mach_type_known
  463. # endif
  464. # if defined(FREEBSD) && defined(__arm__)
  465. # define ARM32
  466. # define mach_type_known
  467. # endif
  468. # if defined(FREEBSD) && defined(__aarch64__)
  469. # define AARCH64
  470. # define mach_type_known
  471. # endif
  472. # if defined(FREEBSD) && (defined(mips) || defined(__mips) || defined(_mips))
  473. # define MIPS
  474. # define mach_type_known
  475. # endif
  476. # if defined(bsdi) && (defined(i386) || defined(__i386__))
  477. # define I386
  478. # define BSDI
  479. # define mach_type_known
  480. # endif
  481. # if !defined(mach_type_known) && defined(__386BSD__)
  482. # define I386
  483. # define THREE86BSD
  484. # define mach_type_known
  485. # endif
  486. # if defined(_CX_UX) && defined(_M88K)
  487. # define M88K
  488. # define CX_UX
  489. # define mach_type_known
  490. # endif
  491. # if defined(DGUX) && defined(m88k)
  492. # define M88K
  493. /* DGUX defined */
  494. # define mach_type_known
  495. # endif
  496. # if defined(_WIN32_WCE) || defined(__CEGCC__) || defined(__MINGW32CE__)
  497. /* SH3, SH4, MIPS already defined for corresponding architectures */
  498. # if defined(SH3) || defined(SH4)
  499. # define SH
  500. # endif
  501. # if defined(x86) || defined(__i386__)
  502. # define I386
  503. # endif
  504. # if defined(_M_ARM) || defined(ARM) || defined(_ARM_)
  505. # define ARM32
  506. # endif
  507. # define MSWINCE
  508. # define mach_type_known
  509. # else
  510. # if ((defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300)) \
  511. || (defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__CYGWIN__) \
  512. && !defined(SYMBIAN))
  513. # if defined(__LP64__) || defined(_M_X64)
  514. # define X86_64
  515. # elif defined(_M_ARM)
  516. # define ARM32
  517. # elif defined(_M_ARM64)
  518. # define AARCH64
  519. # else /* _M_IX86 */
  520. # define I386
  521. # endif
  522. # ifdef _XBOX_ONE
  523. # define MSWIN_XBOX1
  524. # else
  525. # define MSWIN32 /* or Win64 */
  526. # if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
  527. # define MSWINRT_FLAVOR
  528. # endif
  529. # endif
  530. # define mach_type_known
  531. # endif
  532. # if defined(_MSC_VER) && defined(_M_IA64)
  533. # define IA64
  534. # define MSWIN32 /* Really win64, but we don't treat 64-bit */
  535. /* variants as a different platform. */
  536. # endif
  537. # endif
  538. # if defined(__DJGPP__)
  539. # define I386
  540. # ifndef DJGPP
  541. # define DJGPP /* MSDOS running the DJGPP port of GCC */
  542. # endif
  543. # define mach_type_known
  544. # endif
  545. # if defined(__CYGWIN32__) || defined(__CYGWIN__)
  546. # if defined(__LP64__)
  547. # define X86_64
  548. # else
  549. # define I386
  550. # endif
  551. # define CYGWIN32
  552. # define mach_type_known
  553. # endif
  554. # if defined(__MINGW32__) && !defined(mach_type_known)
  555. # define I386
  556. # define MSWIN32
  557. # define mach_type_known
  558. # endif
  559. # if defined(__BORLANDC__)
  560. # define I386
  561. # define MSWIN32
  562. # define mach_type_known
  563. # endif
  564. # if defined(_UTS) && !defined(mach_type_known)
  565. # define S370
  566. # define UTS4
  567. # define mach_type_known
  568. # endif
  569. # if defined(__pj__) && !defined(CPPCHECK)
  570. # error PicoJava no longer supported
  571. /* The implementation had problems, and I haven't heard of users */
  572. /* in ages. If you want it resurrected, let me know. */
  573. # endif
  574. # if defined(__embedded__) && defined(PPC)
  575. # define POWERPC
  576. # define NOSYS
  577. # define mach_type_known
  578. # endif
  579. # if defined(__WATCOMC__) && defined(__386__)
  580. # define I386
  581. # if !defined(OS2) && !defined(MSWIN32) && !defined(DOS4GW)
  582. # if defined(__OS2__)
  583. # define OS2
  584. # else
  585. # if defined(__WINDOWS_386__) || defined(__NT__)
  586. # define MSWIN32
  587. # else
  588. # define DOS4GW
  589. # endif
  590. # endif
  591. # endif
  592. # define mach_type_known
  593. # endif
  594. # if defined(__s390__) && defined(LINUX)
  595. # define S390
  596. # define mach_type_known
  597. # endif
  598. # if defined(__GNU__)
  599. # if defined(__i386__)
  600. /* The Debian Hurd running on generic PC */
  601. # define HURD
  602. # define I386
  603. # define mach_type_known
  604. # endif
  605. # endif
  606. # if defined(__TANDEM)
  607. /* Nonstop S-series */
  608. /* FIXME: Should recognize Integrity series? */
  609. # define MIPS
  610. # define NONSTOP
  611. # define mach_type_known
  612. # endif
  613. # if defined(__hexagon__) && defined(LINUX)
  614. # define HEXAGON
  615. # define mach_type_known
  616. # endif
  617. # if defined(__tile__) && defined(LINUX)
  618. # ifdef __tilegx__
  619. # define TILEGX
  620. # else
  621. # define TILEPRO
  622. # endif
  623. # define mach_type_known
  624. # endif
  625. # if defined(__riscv) && defined(LINUX)
  626. # define RISCV
  627. # define mach_type_known
  628. # endif
  629. # if defined(SN_TARGET_PSP2)
  630. # define mach_type_known
  631. # endif
  632. # if defined(NN_PLATFORM_CTR)
  633. # define mach_type_known
  634. # endif
  635. # if defined(NN_BUILD_TARGET_PLATFORM_NX)
  636. # define NINTENDO_SWITCH
  637. # define mach_type_known
  638. # endif
  639. # if defined(SYMBIAN)
  640. # define mach_type_known
  641. # endif
  642. # if defined(__EMSCRIPTEN__)
  643. # define I386
  644. # define mach_type_known
  645. # endif
  646. # if defined(__QNX__)
  647. # define QNX
  648. # if defined(__aarch64__)
  649. # define AARCH64
  650. # elif defined(__arm__) || defined(__ARM__)
  651. # define ARM32
  652. # elif defined(__amd64) || defined(__X86_64__)
  653. # define X86_64
  654. # elif defined(__X86__)
  655. # define I386
  656. # else
  657. # error Unknown QNX target architecture detected.
  658. # endif
  659. # define mach_type_known
  660. # endif
  661. /* Feel free to add more clauses here */
  662. /* Or manually define the machine type here. A machine type is */
  663. /* characterized by the architecture. Some */
  664. /* machine types are further subdivided by OS. */
  665. /* Macros such as LINUX, FREEBSD, etc. distinguish them. */
  666. /* SYSV on an M68K actually means A/UX. */
  667. /* The distinction in these cases is usually the stack starting address */
  668. # if !defined(mach_type_known) && !defined(CPPCHECK)
  669. # error "The collector has not been ported to this machine/OS combination."
  670. # endif
  671. /* Mapping is: M68K ==> Motorola 680X0 */
  672. /* (NEXT, and SYSV (A/UX), */
  673. /* MACOS and AMIGA variants) */
  674. /* I386 ==> Intel 386 */
  675. /* (SEQUENT, OS2, SCO, LINUX, NETBSD, */
  676. /* FREEBSD, THREE86BSD, MSWIN32, */
  677. /* BSDI, SOLARIS, NEXT and others) */
  678. /* NS32K ==> Encore Multimax */
  679. /* MIPS ==> R2000 through R14K */
  680. /* (many variants) */
  681. /* VAX ==> DEC VAX */
  682. /* (BSD, ULTRIX variants) */
  683. /* HP_PA ==> HP9000/700 & /800 */
  684. /* HP/UX, LINUX */
  685. /* SPARC ==> SPARC v7/v8/v9 */
  686. /* (SOLARIS, LINUX, DRSNX variants) */
  687. /* ALPHA ==> DEC Alpha */
  688. /* (OSF1 and LINUX variants) */
  689. /* M88K ==> Motorola 88XX0 */
  690. /* (CX_UX and DGUX) */
  691. /* S370 ==> 370-like machine */
  692. /* running Amdahl UTS4 */
  693. /* S390 ==> 390-like machine */
  694. /* running LINUX */
  695. /* AARCH64 ==> ARM AArch64 */
  696. /* ARM32 ==> Intel StrongARM */
  697. /* IA64 ==> Intel IPF */
  698. /* (e.g. Itanium) */
  699. /* (LINUX and HPUX) */
  700. /* SH ==> Hitachi SuperH */
  701. /* (LINUX & MSWINCE) */
  702. /* X86_64 ==> AMD x86-64 */
  703. /* POWERPC ==> IBM/Apple PowerPC */
  704. /* (MACOS(<=9),DARWIN(incl.MACOSX),*/
  705. /* LINUX, NETBSD, AIX, NOSYS */
  706. /* variants) */
  707. /* Handles 32 and 64-bit variants. */
  708. /* CRIS ==> Axis Etrax */
  709. /* M32R ==> Renesas M32R */
  710. /* HEXAGON ==> Qualcomm Hexagon */
  711. /* TILEPRO ==> Tilera TILEPro */
  712. /* TILEGX ==> Tilera TILE-Gx */
  713. /*
  714. * For each architecture and OS, the following need to be defined:
  715. *
  716. * CPP_WORDSZ is a simple integer constant representing the word size.
  717. * in bits. We assume byte addressability, where a byte has 8 bits.
  718. * We also assume CPP_WORDSZ is either 32 or 64.
  719. * (We care about the length of pointers, not hardware
  720. * bus widths. Thus a 64 bit processor with a C compiler that uses
  721. * 32 bit pointers should use CPP_WORDSZ of 32, not 64. Default is 32.)
  722. *
  723. * MACH_TYPE is a string representation of the machine type.
  724. * OS_TYPE is analogous for the OS.
  725. *
  726. * ALIGNMENT is the largest N, such that
  727. * all pointer are guaranteed to be aligned on N byte boundaries.
  728. * defining it to be 1 will always work, but perform poorly.
  729. *
  730. * DATASTART is the beginning of the data segment.
  731. * On some platforms SEARCH_FOR_DATA_START is defined.
  732. * SEARCH_FOR_DATASTART will cause GC_data_start to
  733. * be set to an address determined by accessing data backwards from _end
  734. * until an unmapped page is found. DATASTART will be defined to be
  735. * GC_data_start.
  736. * On UNIX-like systems, the collector will scan the area between DATASTART
  737. * and DATAEND for root pointers.
  738. *
  739. * DATAEND, if not "end", where "end" is defined as "extern int end[]".
  740. * RTH suggests gaining access to linker script synth'd values with
  741. * this idiom instead of "&end", where "end" is defined as "extern int end".
  742. * Otherwise, "GCC will assume these are in .sdata/.sbss" and it will, e.g.,
  743. * cause failures on alpha*-*-* with -msmall-data or -fpic or mips-*-*
  744. * without any special options.
  745. *
  746. * STACKBOTTOM is the cool end of the stack, which is usually the
  747. * highest address in the stack.
  748. * Under PCR or OS/2, we have other ways of finding thread stacks.
  749. * For each machine, the following should:
  750. * 1) define STACK_GROWS_UP if the stack grows toward higher addresses, and
  751. * 2) define exactly one of
  752. * STACKBOTTOM (should be defined to be an expression)
  753. * LINUX_STACKBOTTOM
  754. * HEURISTIC1
  755. * HEURISTIC2
  756. * If STACKBOTTOM is defined, then its value will be used directly as the
  757. * stack base. If LINUX_STACKBOTTOM is defined, then it will be determined
  758. * with a method appropriate for most Linux systems. Currently we look
  759. * first for __libc_stack_end (currently only if USE_LIBC_PRIVATES is
  760. * defined), and if that fails read it from /proc. (If USE_LIBC_PRIVATES
  761. * is not defined and NO_PROC_STAT is defined, we revert to HEURISTIC2.)
  762. * If either of the last two macros are defined, then STACKBOTTOM is computed
  763. * during collector startup using one of the following two heuristics:
  764. * HEURISTIC1: Take an address inside GC_init's frame, and round it up to
  765. * the next multiple of STACK_GRAN.
  766. * HEURISTIC2: Take an address inside GC_init's frame, increment it repeatedly
  767. * in small steps (decrement if STACK_GROWS_UP), and read the value
  768. * at each location. Remember the value when the first
  769. * Segmentation violation or Bus error is signaled. Round that
  770. * to the nearest plausible page boundary, and use that instead
  771. * of STACKBOTTOM.
  772. *
  773. * Gustavo Rodriguez-Rivera points out that on most (all?) Unix machines,
  774. * the value of environ is a pointer that can serve as STACKBOTTOM.
  775. * I expect that HEURISTIC2 can be replaced by this approach, which
  776. * interferes far less with debugging. However it has the disadvantage
  777. * that it's confused by a putenv call before the collector is initialized.
  778. * This could be dealt with by intercepting putenv ...
  779. *
  780. * If no expression for STACKBOTTOM can be found, and neither of the above
  781. * heuristics are usable, the collector can still be used with all of the above
  782. * undefined, provided one of the following is done:
  783. * 1) GC_mark_roots can be changed to somehow mark from the correct stack(s)
  784. * without reference to STACKBOTTOM. This is appropriate for use in
  785. * conjunction with thread packages, since there will be multiple stacks.
  786. * (Allocating thread stacks in the heap, and treating them as ordinary
  787. * heap data objects is also possible as a last resort. However, this is
  788. * likely to introduce significant amounts of excess storage retention
  789. * unless the dead parts of the thread stacks are periodically cleared.)
  790. * 2) Client code may set GC_stackbottom before calling any GC_ routines.
  791. * If the author of the client code controls the main program, this is
  792. * easily accomplished by introducing a new main program, setting
  793. * GC_stackbottom to the address of a local variable, and then calling
  794. * the original main program. The new main program would read something
  795. * like (provided real_main() is not inlined by the compiler):
  796. *
  797. * #include "gc.h"
  798. *
  799. * main(argc, argv, envp)
  800. * int argc;
  801. * char **argv, **envp;
  802. * {
  803. * volatile int dummy;
  804. *
  805. * GC_stackbottom = (ptr_t)(&dummy);
  806. * return(real_main(argc, argv, envp));
  807. * }
  808. *
  809. *
  810. * Each architecture may also define the style of virtual dirty bit
  811. * implementation to be used:
  812. * MPROTECT_VDB: Write protect the heap and catch faults.
  813. * GWW_VDB: Use win32 GetWriteWatch primitive.
  814. * PROC_VDB: Use the SVR4 /proc primitives to read dirty bits.
  815. *
  816. * The first and second one may be combined, in which case a runtime
  817. * selection will be made, based on GetWriteWatch availability.
  818. *
  819. * An architecture may define DYNAMIC_LOADING if dyn_load.c
  820. * defined GC_register_dynamic_libraries() for the architecture.
  821. *
  822. * An architecture may define PREFETCH(x) to preload the cache with *x.
  823. * This defaults to GCC built-in operation (or a no-op for other compilers).
  824. *
  825. * GC_PREFETCH_FOR_WRITE(x) is used if *x is about to be written.
  826. *
  827. * An architecture may also define CLEAR_DOUBLE(x) to be a fast way to
  828. * clear the two words at GC_malloc-aligned address x. By default,
  829. * word stores of 0 are used instead.
  830. *
  831. * HEAP_START may be defined as the initial address hint for mmap-based
  832. * allocation.
  833. */
  834. /* If available, we can use __builtin_unwind_init() to push the */
  835. /* relevant registers onto the stack. */
  836. # if GC_GNUC_PREREQ(2, 8) \
  837. && !defined(__INTEL_COMPILER) && !defined(__PATHCC__) \
  838. && !defined(__FUJITSU) /* for FX10 system */ \
  839. && !(defined(POWERPC) && defined(DARWIN)) /* for MacOS X 10.3.9 */ \
  840. && !defined(RTEMS) \
  841. && !defined(__ARMCC_VERSION) /* does not exist in armcc gnu emu */ \
  842. && !defined(__clang__) /* since no-op in clang (3.0) */
  843. # define HAVE_BUILTIN_UNWIND_INIT
  844. # endif
  845. # ifdef SYMBIAN
  846. # define MACH_TYPE "SYMBIAN"
  847. # define OS_TYPE "SYMBIAN"
  848. # define CPP_WORDSZ 32
  849. # define ALIGNMENT 4
  850. # define DATASTART (ptr_t)ALIGNMENT /* cannot be null */
  851. # define DATAEND (ptr_t)ALIGNMENT
  852. # endif
  853. # ifdef __EMSCRIPTEN__
  854. # define OS_TYPE "EMSCRIPTEN"
  855. # define CPP_WORDSZ 32
  856. # define ALIGNMENT 4
  857. # define DATASTART (ptr_t)ALIGNMENT
  858. # define DATAEND (ptr_t)ALIGNMENT
  859. /* Since JavaScript/asm.js/WebAssembly is not able to access the */
  860. /* function call stack or the local data stack, it is not possible */
  861. /* for GC to perform its stack walking operation to find roots on */
  862. /* the stack. To work around that, the clients generally only do */
  863. /* BDWGC steps when the stack is empty so it is known that there */
  864. /* are no objects that would be found on the stack, and BDWGC is */
  865. /* compiled with stack walking disabled. */
  866. # define STACK_NOT_SCANNED
  867. # endif
  868. # ifdef QNX
  869. # define OS_TYPE "QNX"
  870. # define SA_RESTART 0
  871. extern char etext[];
  872. extern int _end[];
  873. # define DATASTART ((ptr_t)(etext))
  874. # define DATAEND ((ptr_t)(_end))
  875. EXTERN_C_BEGIN
  876. extern void *qnx_get_stack_bottom(void);
  877. EXTERN_C_END
  878. # define STACKBOTTOM ((ptr_t)qnx_get_stack_bottom())
  879. # endif
  880. # define STACK_GRAN 0x1000000
  881. # ifdef M68K
  882. # define MACH_TYPE "M68K"
  883. # define ALIGNMENT 2
  884. # ifdef OPENBSD
  885. /* FIXME: Should we remove this case? */
  886. # define OS_TYPE "OPENBSD"
  887. # define HEURISTIC2
  888. # ifdef __ELF__
  889. extern ptr_t GC_data_start;
  890. # define DATASTART GC_data_start
  891. # define DYNAMIC_LOADING
  892. # else
  893. extern char etext[];
  894. # define DATASTART ((ptr_t)(etext))
  895. # endif
  896. # endif
  897. # ifdef NETBSD
  898. # define OS_TYPE "NETBSD"
  899. # define HEURISTIC2
  900. # ifdef __ELF__
  901. extern ptr_t GC_data_start;
  902. # define DATASTART GC_data_start
  903. # define DYNAMIC_LOADING
  904. # else
  905. extern char etext[];
  906. # define DATASTART ((ptr_t)(etext))
  907. # endif
  908. # endif
  909. # ifdef LINUX
  910. # define OS_TYPE "LINUX"
  911. # define LINUX_STACKBOTTOM
  912. # define MPROTECT_VDB
  913. # ifdef __ELF__
  914. # define DYNAMIC_LOADING
  915. EXTERN_C_END
  916. # include <features.h>
  917. EXTERN_C_BEGIN
  918. # if defined(__GLIBC__) && __GLIBC__ >= 2
  919. # define SEARCH_FOR_DATA_START
  920. # else /* !GLIBC2 */
  921. extern char **__environ;
  922. # define DATASTART ((ptr_t)(&__environ))
  923. /* hideous kludge: __environ is the first */
  924. /* word in crt0.o, and delimits the start */
  925. /* of the data segment, no matter which */
  926. /* ld options were passed through. */
  927. /* We could use _etext instead, but that */
  928. /* would include .rodata, which may */
  929. /* contain large read-only data tables */
  930. /* that we'd rather not scan. */
  931. # endif /* !GLIBC2 */
  932. extern int _end[];
  933. # define DATAEND ((ptr_t)(_end))
  934. # else
  935. extern int etext[];
  936. # define DATASTART ((ptr_t)((((word)(etext)) + 0xfff) & ~0xfff))
  937. # endif
  938. # endif
  939. # ifdef AMIGA
  940. # define OS_TYPE "AMIGA"
  941. /* STACKBOTTOM and DATASTART handled specially */
  942. /* in os_dep.c */
  943. # define DATAEND /* not needed */
  944. # define GETPAGESIZE() 4096
  945. # endif
  946. # ifdef MACOS
  947. # ifndef __LOWMEM__
  948. EXTERN_C_END
  949. # include <LowMem.h>
  950. EXTERN_C_BEGIN
  951. # endif
  952. # define OS_TYPE "MACOS"
  953. /* see os_dep.c for details of global data segments. */
  954. # define STACKBOTTOM ((ptr_t)LMGetCurStackBase())
  955. # define DATAEND /* not needed */
  956. # define GETPAGESIZE() 4096
  957. # endif
  958. # ifdef NEXT
  959. # define OS_TYPE "NEXT"
  960. # define DATASTART ((ptr_t)get_etext())
  961. # define DATASTART_IS_FUNC
  962. # define STACKBOTTOM ((ptr_t)0x4000000)
  963. # define DATAEND /* not needed */
  964. # endif
  965. # endif
  966. # if defined(POWERPC)
  967. # define MACH_TYPE "POWERPC"
  968. # ifdef MACOS
  969. # define ALIGNMENT 2 /* Still necessary? Could it be 4? */
  970. # ifndef __LOWMEM__
  971. EXTERN_C_END
  972. # include <LowMem.h>
  973. EXTERN_C_BEGIN
  974. # endif
  975. # define OS_TYPE "MACOS"
  976. /* see os_dep.c for details of global data segments. */
  977. # define STACKBOTTOM ((ptr_t)LMGetCurStackBase())
  978. # define DATAEND /* not needed */
  979. # endif
  980. # ifdef LINUX
  981. # if defined(__powerpc64__)
  982. # define ALIGNMENT 8
  983. # define CPP_WORDSZ 64
  984. # ifndef HBLKSIZE
  985. # define HBLKSIZE 4096
  986. # endif
  987. # else
  988. # define ALIGNMENT 4
  989. # endif
  990. # define OS_TYPE "LINUX"
  991. /* HEURISTIC1 has been reliably reported to fail for a 32-bit */
  992. /* executable on a 64 bit kernel. */
  993. # if defined(__bg__)
  994. /* The Linux Compute Node Kernel (used on BlueGene systems) */
  995. /* does not support LINUX_STACKBOTTOM way. */
  996. # define HEURISTIC2
  997. # define NO_PTHREAD_GETATTR_NP
  998. # else
  999. # define LINUX_STACKBOTTOM
  1000. # endif
  1001. # define DYNAMIC_LOADING
  1002. # define SEARCH_FOR_DATA_START
  1003. extern int _end[];
  1004. # define DATAEND ((ptr_t)(_end))
  1005. # endif
  1006. # ifdef DARWIN
  1007. # define OS_TYPE "DARWIN"
  1008. # define DYNAMIC_LOADING
  1009. # if defined(__ppc64__)
  1010. # define ALIGNMENT 8
  1011. # define CPP_WORDSZ 64
  1012. # define STACKBOTTOM ((ptr_t)0x7fff5fc00000)
  1013. # define CACHE_LINE_SIZE 64
  1014. # ifndef HBLKSIZE
  1015. # define HBLKSIZE 4096
  1016. # endif
  1017. # else
  1018. # define ALIGNMENT 4
  1019. # define STACKBOTTOM ((ptr_t)0xc0000000)
  1020. # endif
  1021. /* XXX: see get_end(3), get_etext() and get_end() should not be used. */
  1022. /* These aren't used when dyld support is enabled (it is by default). */
  1023. # define DATASTART ((ptr_t)get_etext())
  1024. # define DATAEND ((ptr_t)get_end())
  1025. # define USE_MMAP_ANON
  1026. # define MPROTECT_VDB
  1027. EXTERN_C_END
  1028. # include <unistd.h>
  1029. EXTERN_C_BEGIN
  1030. # define GETPAGESIZE() (unsigned)getpagesize()
  1031. # if defined(USE_PPC_PREFETCH) && defined(__GNUC__)
  1032. /* The performance impact of prefetches is untested */
  1033. # define PREFETCH(x) \
  1034. __asm__ __volatile__ ("dcbt 0,%0" : : "r" ((const void *) (x)))
  1035. # define GC_PREFETCH_FOR_WRITE(x) \
  1036. __asm__ __volatile__ ("dcbtst 0,%0" : : "r" ((const void *) (x)))
  1037. # endif
  1038. /* There seems to be some issues with trylock hanging on darwin. */
  1039. /* This should be looked into some more. */
  1040. # define NO_PTHREAD_TRYLOCK
  1041. # endif
  1042. # ifdef OPENBSD
  1043. # define OS_TYPE "OPENBSD"
  1044. # define ALIGNMENT 4
  1045. # ifndef GC_OPENBSD_THREADS
  1046. EXTERN_C_END
  1047. # include <sys/param.h>
  1048. # include <uvm/uvm_extern.h>
  1049. EXTERN_C_BEGIN
  1050. /* USRSTACK is defined in <machine/vmparam.h> but that is */
  1051. /* protected by _KERNEL in <uvm/uvm_param.h> file. */
  1052. # ifdef USRSTACK
  1053. # define STACKBOTTOM ((ptr_t)USRSTACK)
  1054. # else
  1055. # define HEURISTIC2
  1056. # endif
  1057. # endif
  1058. extern int __data_start[];
  1059. # define DATASTART ((ptr_t)__data_start)
  1060. extern int _end[];
  1061. # define DATAEND ((ptr_t)(&_end))
  1062. # define DYNAMIC_LOADING
  1063. # endif
  1064. # ifdef FREEBSD
  1065. # if defined(__powerpc64__)
  1066. # define ALIGNMENT 8
  1067. # define CPP_WORDSZ 64
  1068. # ifndef HBLKSIZE
  1069. # define HBLKSIZE 4096
  1070. # endif
  1071. # else
  1072. # define ALIGNMENT 4
  1073. # endif
  1074. # define OS_TYPE "FREEBSD"
  1075. # ifndef GC_FREEBSD_THREADS
  1076. # define MPROTECT_VDB
  1077. # endif
  1078. # define SIG_SUSPEND SIGUSR1
  1079. # define SIG_THR_RESTART SIGUSR2
  1080. # define FREEBSD_STACKBOTTOM
  1081. # ifdef __ELF__
  1082. # define DYNAMIC_LOADING
  1083. # endif
  1084. extern char etext[];
  1085. # define DATASTART GC_FreeBSDGetDataStart(0x1000, (ptr_t)etext)
  1086. # define DATASTART_USES_BSDGETDATASTART
  1087. # endif
  1088. # ifdef NETBSD
  1089. # define ALIGNMENT 4
  1090. # define OS_TYPE "NETBSD"
  1091. # define HEURISTIC2
  1092. extern ptr_t GC_data_start;
  1093. # define DATASTART GC_data_start
  1094. # define DYNAMIC_LOADING
  1095. # endif
  1096. # ifdef SN_TARGET_PS3
  1097. # define NO_GETENV
  1098. # define CPP_WORDSZ 32
  1099. # define ALIGNMENT 4
  1100. extern int _end[];
  1101. extern int __bss_start;
  1102. # define DATASTART ((ptr_t)(__bss_start))
  1103. # define DATAEND ((ptr_t)(_end))
  1104. # define STACKBOTTOM ((ptr_t)ps3_get_stack_bottom())
  1105. # define NO_PTHREAD_TRYLOCK
  1106. /* Current GC LOCK() implementation for PS3 explicitly */
  1107. /* use pthread_mutex_lock for some reason. */
  1108. # endif
  1109. # ifdef AIX
  1110. # define OS_TYPE "AIX"
  1111. # undef ALIGNMENT /* in case it's defined */
  1112. # undef IA64
  1113. /* DOB: some AIX installs stupidly define IA64 in */
  1114. /* /usr/include/sys/systemcfg.h */
  1115. # ifdef __64BIT__
  1116. # define ALIGNMENT 8
  1117. # define CPP_WORDSZ 64
  1118. # define STACKBOTTOM ((ptr_t)0x1000000000000000)
  1119. # else
  1120. # define ALIGNMENT 4
  1121. # define CPP_WORDSZ 32
  1122. # define STACKBOTTOM ((ptr_t)((ulong)&errno))
  1123. # endif
  1124. # define USE_MMAP_ANON
  1125. /* From AIX linker man page:
  1126. _text Specifies the first location of the program.
  1127. _etext Specifies the first location after the program.
  1128. _data Specifies the first location of the data.
  1129. _edata Specifies the first location after the initialized data
  1130. _end or end Specifies the first location after all data.
  1131. */
  1132. extern int _data[], _end[];
  1133. # define DATASTART ((ptr_t)((ulong)_data))
  1134. # define DATAEND ((ptr_t)((ulong)_end))
  1135. extern int errno;
  1136. # define DYNAMIC_LOADING
  1137. /* For really old versions of AIX, this may have to be removed. */
  1138. # endif
  1139. # ifdef NOSYS
  1140. # define ALIGNMENT 4
  1141. # define OS_TYPE "NOSYS"
  1142. extern void __end[], __dso_handle[];
  1143. # define DATASTART ((ptr_t)__dso_handle) /* OK, that's ugly. */
  1144. # define DATAEND ((ptr_t)(__end))
  1145. /* Stack starts at 0xE0000000 for the simulator. */
  1146. # undef STACK_GRAN
  1147. # define STACK_GRAN 0x10000000
  1148. # define HEURISTIC1
  1149. # endif
  1150. # endif
  1151. # ifdef NACL
  1152. # define OS_TYPE "NACL"
  1153. # if defined(__GLIBC__)
  1154. # define DYNAMIC_LOADING
  1155. # endif
  1156. # define DATASTART ((ptr_t)0x10020000)
  1157. extern int _end[];
  1158. # define DATAEND ((ptr_t)_end)
  1159. # undef STACK_GRAN
  1160. # define STACK_GRAN 0x10000
  1161. # define HEURISTIC1
  1162. # define NO_PTHREAD_GETATTR_NP
  1163. # define USE_MUNMAP
  1164. # define USE_MMAP_ANON
  1165. # define GETPAGESIZE() 65536
  1166. # define MAX_NACL_GC_THREADS 1024
  1167. # endif
  1168. # ifdef VAX
  1169. # define MACH_TYPE "VAX"
  1170. # define ALIGNMENT 4 /* Pointers are longword aligned by 4.2 C compiler */
  1171. extern char etext[];
  1172. # define DATASTART ((ptr_t)(etext))
  1173. # ifdef BSD
  1174. # define OS_TYPE "BSD"
  1175. # define HEURISTIC1
  1176. /* HEURISTIC2 may be OK, but it's hard to test. */
  1177. # endif
  1178. # ifdef ULTRIX
  1179. # define OS_TYPE "ULTRIX"
  1180. # define STACKBOTTOM ((ptr_t)0x7fffc800)
  1181. # endif
  1182. # endif
  1183. # ifdef SPARC
  1184. # define MACH_TYPE "SPARC"
  1185. # if defined(__arch64__) || defined(__sparcv9)
  1186. # define ALIGNMENT 8
  1187. # define CPP_WORDSZ 64
  1188. # define ELF_CLASS ELFCLASS64
  1189. # else
  1190. # define ALIGNMENT 4 /* Required by hardware */
  1191. # define CPP_WORDSZ 32
  1192. # endif
  1193. /* Don't define USE_ASM_PUSH_REGS. We do use an asm helper, but */
  1194. /* not to push the registers on the mark stack. */
  1195. # ifdef SOLARIS
  1196. # define OS_TYPE "SOLARIS"
  1197. extern int _etext[];
  1198. extern int _end[];
  1199. ptr_t GC_SysVGetDataStart(size_t, ptr_t);
  1200. # define DATASTART GC_SysVGetDataStart(0x10000, (ptr_t)_etext)
  1201. # define DATASTART_IS_FUNC
  1202. # define DATAEND ((ptr_t)(_end))
  1203. # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
  1204. # define USE_MMAP
  1205. /* Otherwise we now use calloc. Mmap may result in the */
  1206. /* heap interleaved with thread stacks, which can result in */
  1207. /* excessive blacklisting. Sbrk is unusable since it */
  1208. /* doesn't interact correctly with the system malloc. */
  1209. # endif
  1210. # ifdef USE_MMAP
  1211. # define HEAP_START (ptr_t)0x40000000
  1212. # else
  1213. # define HEAP_START DATAEND
  1214. # endif
  1215. # define PROC_VDB
  1216. /* HEURISTIC1 reportedly no longer works under 2.7. */
  1217. /* HEURISTIC2 probably works, but this appears to be preferable.*/
  1218. /* Apparently USRSTACK is defined to be USERLIMIT, but in some */
  1219. /* installations that's undefined. We work around this with a */
  1220. /* gross hack: */
  1221. EXTERN_C_END
  1222. # include <sys/vmparam.h>
  1223. # include <unistd.h>
  1224. EXTERN_C_BEGIN
  1225. # ifdef USERLIMIT
  1226. /* This should work everywhere, but doesn't. */
  1227. # define STACKBOTTOM ((ptr_t)USRSTACK)
  1228. # else
  1229. # define HEURISTIC2
  1230. # endif
  1231. # define GETPAGESIZE() (unsigned)sysconf(_SC_PAGESIZE)
  1232. /* getpagesize() appeared to be missing from at least one */
  1233. /* Solaris 5.4 installation. Weird. */
  1234. # define DYNAMIC_LOADING
  1235. # endif
  1236. # ifdef DRSNX
  1237. # define OS_TYPE "DRSNX"
  1238. extern int etext[];
  1239. ptr_t GC_SysVGetDataStart(size_t, ptr_t);
  1240. # define DATASTART GC_SysVGetDataStart(0x10000, (ptr_t)etext)
  1241. # define DATASTART_IS_FUNC
  1242. # define MPROTECT_VDB
  1243. # define STACKBOTTOM ((ptr_t)0xdfff0000)
  1244. # define DYNAMIC_LOADING
  1245. # endif
  1246. # ifdef LINUX
  1247. # define OS_TYPE "LINUX"
  1248. # ifdef __ELF__
  1249. # define DYNAMIC_LOADING
  1250. # else
  1251. # error --> Linux SPARC a.out not supported
  1252. # endif
  1253. extern int _end[];
  1254. extern int _etext[];
  1255. # define DATAEND ((ptr_t)(_end))
  1256. # define SVR4
  1257. ptr_t GC_SysVGetDataStart(size_t, ptr_t);
  1258. # ifdef __arch64__
  1259. # define DATASTART GC_SysVGetDataStart(0x100000, (ptr_t)_etext)
  1260. # else
  1261. # define DATASTART GC_SysVGetDataStart(0x10000, (ptr_t)_etext)
  1262. # endif
  1263. # define DATASTART_IS_FUNC
  1264. # define LINUX_STACKBOTTOM
  1265. # endif
  1266. # ifdef OPENBSD
  1267. # define OS_TYPE "OPENBSD"
  1268. # ifndef GC_OPENBSD_THREADS
  1269. EXTERN_C_END
  1270. # include <sys/param.h>
  1271. # include <uvm/uvm_extern.h>
  1272. EXTERN_C_BEGIN
  1273. # ifdef USRSTACK
  1274. # define STACKBOTTOM ((ptr_t)USRSTACK)
  1275. # else
  1276. # define HEURISTIC2
  1277. # endif
  1278. # endif
  1279. extern int __data_start[];
  1280. # define DATASTART ((ptr_t)__data_start)
  1281. extern int _end[];
  1282. # define DATAEND ((ptr_t)(&_end))
  1283. # define DYNAMIC_LOADING
  1284. # endif
  1285. # ifdef NETBSD
  1286. # define OS_TYPE "NETBSD"
  1287. # define HEURISTIC2
  1288. # ifdef __ELF__
  1289. extern ptr_t GC_data_start;
  1290. # define DATASTART GC_data_start
  1291. # define DYNAMIC_LOADING
  1292. # else
  1293. extern char etext[];
  1294. # define DATASTART ((ptr_t)(etext))
  1295. # endif
  1296. # endif
  1297. # ifdef FREEBSD
  1298. # define OS_TYPE "FREEBSD"
  1299. # define SIG_SUSPEND SIGUSR1
  1300. # define SIG_THR_RESTART SIGUSR2
  1301. # define FREEBSD_STACKBOTTOM
  1302. # ifdef __ELF__
  1303. # define DYNAMIC_LOADING
  1304. # endif
  1305. extern char etext[];
  1306. extern char edata[];
  1307. extern char end[];
  1308. # define NEED_FIND_LIMIT
  1309. # define DATASTART ((ptr_t)(&etext))
  1310. ptr_t GC_find_limit(ptr_t, GC_bool);
  1311. # define DATAEND GC_find_limit(DATASTART, TRUE)
  1312. # define DATAEND_IS_FUNC
  1313. # define GC_HAVE_DATAREGION2
  1314. # define DATASTART2 ((ptr_t)(&edata))
  1315. # define DATAEND2 ((ptr_t)(&end))
  1316. # endif
  1317. # endif
  1318. # ifdef I386
  1319. # define MACH_TYPE "I386"
  1320. # if defined(__LP64__) || defined(_WIN64)
  1321. # error This should be handled as X86_64
  1322. # else
  1323. # define CPP_WORDSZ 32
  1324. # define ALIGNMENT 4
  1325. /* Appears to hold for all "32 bit" compilers */
  1326. /* except Borland. The -a4 option fixes */
  1327. /* Borland. For Watcom the option is -zp4. */
  1328. # endif
  1329. # ifdef SEQUENT
  1330. # define OS_TYPE "SEQUENT"
  1331. extern int etext[];
  1332. # define DATASTART ((ptr_t)((((word)(etext)) + 0xfff) & ~0xfff))
  1333. # define STACKBOTTOM ((ptr_t)0x3ffff000)
  1334. # endif
  1335. # ifdef HAIKU
  1336. # define OS_TYPE "HAIKU"
  1337. EXTERN_C_END
  1338. # include <OS.h>
  1339. EXTERN_C_BEGIN
  1340. # define GETPAGESIZE() (unsigned)B_PAGE_SIZE
  1341. extern int etext[];
  1342. # define DATASTART ((ptr_t)((((word)(etext)) + 0xfff) & ~0xfff))
  1343. # define DYNAMIC_LOADING
  1344. # define MPROTECT_VDB
  1345. # endif
  1346. # ifdef SOLARIS
  1347. # define OS_TYPE "SOLARIS"
  1348. extern int _etext[], _end[];
  1349. ptr_t GC_SysVGetDataStart(size_t, ptr_t);
  1350. # define DATASTART GC_SysVGetDataStart(0x1000, (ptr_t)_etext)
  1351. # define DATASTART_IS_FUNC
  1352. # define DATAEND ((ptr_t)(_end))
  1353. /* # define STACKBOTTOM ((ptr_t)(_start)) worked through 2.7, */
  1354. /* but reportedly breaks under 2.8. It appears that the stack */
  1355. /* base is a property of the executable, so this should not */
  1356. /* break old executables. */
  1357. /* HEURISTIC2 probably works, but this appears to be preferable.*/
  1358. /* Apparently USRSTACK is defined to be USERLIMIT, but in some */
  1359. /* installations that's undefined. We work around this with a */
  1360. /* gross hack: */
  1361. EXTERN_C_END
  1362. # include <sys/vmparam.h>
  1363. EXTERN_C_BEGIN
  1364. # ifdef USERLIMIT
  1365. /* This should work everywhere, but doesn't. */
  1366. # define STACKBOTTOM ((ptr_t)USRSTACK)
  1367. # else
  1368. # define HEURISTIC2
  1369. # endif
  1370. /* At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */
  1371. /* It appears to be fixed in 2.8 and 2.9. */
  1372. # ifdef SOLARIS25_PROC_VDB_BUG_FIXED
  1373. # define PROC_VDB
  1374. # endif
  1375. # ifndef GC_THREADS
  1376. # define MPROTECT_VDB
  1377. # endif
  1378. # define DYNAMIC_LOADING
  1379. # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
  1380. # define USE_MMAP
  1381. /* Otherwise we now use calloc. Mmap may result in the */
  1382. /* heap interleaved with thread stacks, which can result in */
  1383. /* excessive blacklisting. Sbrk is unusable since it */
  1384. /* doesn't interact correctly with the system malloc. */
  1385. # endif
  1386. # ifdef USE_MMAP
  1387. # define HEAP_START (ptr_t)0x40000000
  1388. # else
  1389. # define HEAP_START DATAEND
  1390. # endif
  1391. # endif
  1392. # ifdef SCO
  1393. # define OS_TYPE "SCO"
  1394. extern int etext[];
  1395. # define DATASTART ((ptr_t)((((word)(etext)) + 0x3fffff) & ~0x3fffff) \
  1396. + ((word)(etext) & 0xfff))
  1397. # define STACKBOTTOM ((ptr_t)0x7ffffffc)
  1398. # endif
  1399. # ifdef SCO_ELF
  1400. # define OS_TYPE "SCO_ELF"
  1401. extern int etext[];
  1402. # define DATASTART ((ptr_t)(etext))
  1403. # define STACKBOTTOM ((ptr_t)0x08048000)
  1404. # define DYNAMIC_LOADING
  1405. # define ELF_CLASS ELFCLASS32
  1406. # endif
  1407. # ifdef DGUX
  1408. # define OS_TYPE "DGUX"
  1409. extern int _etext, _end;
  1410. ptr_t GC_SysVGetDataStart(size_t, ptr_t);
  1411. # define DATASTART GC_SysVGetDataStart(0x1000, (ptr_t)(&_etext))
  1412. # define DATASTART_IS_FUNC
  1413. # define DATAEND ((ptr_t)(&_end))
  1414. # define STACK_GROWS_DOWN
  1415. # define HEURISTIC2
  1416. EXTERN_C_END
  1417. # include <unistd.h>
  1418. EXTERN_C_BEGIN
  1419. # define GETPAGESIZE() (unsigned)sysconf(_SC_PAGESIZE)
  1420. # define DYNAMIC_LOADING
  1421. # ifndef USE_MMAP
  1422. # define USE_MMAP
  1423. # endif
  1424. # define MAP_FAILED (void *) ((word)-1)
  1425. # define HEAP_START (ptr_t)0x40000000
  1426. # endif /* DGUX */
  1427. # ifdef LINUX
  1428. # define OS_TYPE "LINUX"
  1429. # define LINUX_STACKBOTTOM
  1430. # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
  1431. # define MPROTECT_VDB
  1432. # else
  1433. /* We seem to get random errors in incremental mode, */
  1434. /* possibly because Linux threads is itself a malloc client */
  1435. /* and can't deal with the signals. */
  1436. # endif
  1437. # define HEAP_START (ptr_t)0x1000
  1438. /* This encourages mmap to give us low addresses, */
  1439. /* thus allowing the heap to grow to ~3GB */
  1440. # ifdef __ELF__
  1441. # define DYNAMIC_LOADING
  1442. EXTERN_C_END
  1443. # include <features.h>
  1444. EXTERN_C_BEGIN
  1445. # if defined(__GLIBC__) && __GLIBC__ >= 2 \
  1446. || defined(HOST_ANDROID) || defined(HOST_TIZEN)
  1447. # define SEARCH_FOR_DATA_START
  1448. # else
  1449. extern char **__environ;
  1450. # define DATASTART ((ptr_t)(&__environ))
  1451. /* hideous kludge: __environ is the first */
  1452. /* word in crt0.o, and delimits the start */
  1453. /* of the data segment, no matter which */
  1454. /* ld options were passed through. */
  1455. /* We could use _etext instead, but that */
  1456. /* would include .rodata, which may */
  1457. /* contain large read-only data tables */
  1458. /* that we'd rather not scan. */
  1459. # endif
  1460. extern int _end[];
  1461. # define DATAEND ((ptr_t)(_end))
  1462. # if !defined(GC_NO_SIGSETJMP) && (defined(HOST_TIZEN) \
  1463. || (defined(HOST_ANDROID) \
  1464. && !(GC_GNUC_PREREQ(4, 8) || GC_CLANG_PREREQ(3, 2) \
  1465. || __ANDROID_API__ >= 18)))
  1466. /* Older Android NDK releases lack sigsetjmp in x86 libc */
  1467. /* (setjmp is used instead to find data_start). The bug */
  1468. /* is fixed in Android NDK r8e (so, ok to use sigsetjmp */
  1469. /* if gcc4.8+, clang3.2+ or Android API level 18+). */
  1470. # define GC_NO_SIGSETJMP
  1471. # endif
  1472. # else
  1473. extern int etext[];
  1474. # define DATASTART ((ptr_t)((((word)(etext)) + 0xfff) & ~0xfff))
  1475. # endif
  1476. # ifdef USE_I686_PREFETCH
  1477. # define PREFETCH(x) \
  1478. __asm__ __volatile__ ("prefetchnta %0" : : "m"(*(char *)(x)))
  1479. /* Empirically prefetcht0 is much more effective at reducing */
  1480. /* cache miss stalls for the targeted load instructions. But it */
  1481. /* seems to interfere enough with other cache traffic that the */
  1482. /* net result is worse than prefetchnta. */
  1483. # ifdef FORCE_WRITE_PREFETCH
  1484. /* Using prefetches for write seems to have a slight negative */
  1485. /* impact on performance, at least for a PIII/500. */
  1486. # define GC_PREFETCH_FOR_WRITE(x) \
  1487. __asm__ __volatile__ ("prefetcht0 %0" : : "m"(*(char *)(x)))
  1488. # else
  1489. # define GC_NO_PREFETCH_FOR_WRITE
  1490. # endif
  1491. # elif defined(USE_3DNOW_PREFETCH)
  1492. # define PREFETCH(x) \
  1493. __asm__ __volatile__ ("prefetch %0" : : "m"(*(char *)(x)))
  1494. # define GC_PREFETCH_FOR_WRITE(x) \
  1495. __asm__ __volatile__ ("prefetchw %0" : : "m"(*(char *)(x)))
  1496. # endif
  1497. # if defined(__GLIBC__) && !defined(__UCLIBC__)
  1498. /* Workaround lock elision implementation for some glibc. */
  1499. # define GLIBC_2_19_TSX_BUG
  1500. EXTERN_C_END
  1501. # include <gnu/libc-version.h> /* for gnu_get_libc_version() */
  1502. EXTERN_C_BEGIN
  1503. # endif
  1504. # endif
  1505. # ifdef CYGWIN32
  1506. # define OS_TYPE "CYGWIN32"
  1507. # define WOW64_THREAD_CONTEXT_WORKAROUND
  1508. # define RETRY_GET_THREAD_CONTEXT
  1509. # define DATASTART ((ptr_t)GC_DATASTART) /* From gc.h */
  1510. # define DATAEND ((ptr_t)GC_DATAEND)
  1511. # undef STACK_GRAN
  1512. # define STACK_GRAN 0x10000
  1513. # ifdef USE_MMAP
  1514. # define NEED_FIND_LIMIT
  1515. # define USE_MMAP_ANON
  1516. # endif
  1517. # endif
  1518. # ifdef OS2
  1519. # define OS_TYPE "OS2"
  1520. /* STACKBOTTOM and DATASTART are handled specially in */
  1521. /* os_dep.c. OS2 actually has the right */
  1522. /* system call! */
  1523. # define DATAEND /* not needed */
  1524. # endif
  1525. # ifdef MSWIN32
  1526. # define OS_TYPE "MSWIN32"
  1527. # define WOW64_THREAD_CONTEXT_WORKAROUND
  1528. # define RETRY_GET_THREAD_CONTEXT
  1529. /* STACKBOTTOM and DATASTART are handled specially in */
  1530. /* os_dep.c. */
  1531. # define MPROTECT_VDB
  1532. # define GWW_VDB
  1533. # define DATAEND /* not needed */
  1534. # endif
  1535. # ifdef MSWINCE
  1536. # define OS_TYPE "MSWINCE"
  1537. # define DATAEND /* not needed */
  1538. # endif
  1539. # ifdef DJGPP
  1540. # define OS_TYPE "DJGPP"
  1541. EXTERN_C_END
  1542. # include "stubinfo.h"
  1543. EXTERN_C_BEGIN
  1544. extern int etext[];
  1545. extern int _stklen;
  1546. extern int __djgpp_stack_limit;
  1547. # define DATASTART ((ptr_t)((((word)(etext)) + 0x1ff) & ~0x1ff))
  1548. /* #define STACKBOTTOM ((ptr_t)((word)_stubinfo+_stubinfo->size+_stklen)) */
  1549. # define STACKBOTTOM ((ptr_t)((word)__djgpp_stack_limit + _stklen))
  1550. /* This may not be right. */
  1551. # endif
  1552. # ifdef OPENBSD
  1553. # define OS_TYPE "OPENBSD"
  1554. # ifndef GC_OPENBSD_THREADS
  1555. EXTERN_C_END
  1556. # include <sys/param.h>
  1557. # include <uvm/uvm_extern.h>
  1558. EXTERN_C_BEGIN
  1559. # ifdef USRSTACK
  1560. # define STACKBOTTOM ((ptr_t)USRSTACK)
  1561. # else
  1562. # define HEURISTIC2
  1563. # endif
  1564. # endif
  1565. extern int __data_start[];
  1566. # define DATASTART ((ptr_t)__data_start)
  1567. extern int _end[];
  1568. # define DATAEND ((ptr_t)(&_end))
  1569. # define DYNAMIC_LOADING
  1570. # endif
  1571. # ifdef FREEBSD
  1572. # define OS_TYPE "FREEBSD"
  1573. # ifndef GC_FREEBSD_THREADS
  1574. # define MPROTECT_VDB
  1575. # endif
  1576. # ifdef __GLIBC__
  1577. # define SIG_SUSPEND (32+6)
  1578. # define SIG_THR_RESTART (32+5)
  1579. extern int _end[];
  1580. # define DATAEND ((ptr_t)(_end))
  1581. # else
  1582. # define SIG_SUSPEND SIGUSR1
  1583. # define SIG_THR_RESTART SIGUSR2
  1584. /* SIGTSTP and SIGCONT could be used alternatively. */
  1585. # endif
  1586. # define FREEBSD_STACKBOTTOM
  1587. # ifdef __ELF__
  1588. # define DYNAMIC_LOADING
  1589. # endif
  1590. extern char etext[];
  1591. # define DATASTART GC_FreeBSDGetDataStart(0x1000, (ptr_t)etext)
  1592. # define DATASTART_USES_BSDGETDATASTART
  1593. # endif
  1594. # ifdef NETBSD
  1595. # define OS_TYPE "NETBSD"
  1596. # ifdef __ELF__
  1597. # define DYNAMIC_LOADING
  1598. # endif
  1599. # endif
  1600. # ifdef THREE86BSD
  1601. # define OS_TYPE "THREE86BSD"
  1602. # endif
  1603. # ifdef BSDI
  1604. # define OS_TYPE "BSDI"
  1605. # endif
  1606. # if defined(NETBSD) || defined(THREE86BSD) || defined(BSDI)
  1607. # define HEURISTIC2
  1608. extern char etext[];
  1609. # define DATASTART ((ptr_t)(etext))
  1610. # endif
  1611. # ifdef NEXT
  1612. # define OS_TYPE "NEXT"
  1613. # define DATASTART ((ptr_t)get_etext())
  1614. # define DATASTART_IS_FUNC
  1615. # define STACKBOTTOM ((ptr_t)0xc0000000)
  1616. # define DATAEND /* not needed */
  1617. # endif
  1618. # ifdef RTEMS
  1619. # define OS_TYPE "RTEMS"
  1620. EXTERN_C_END
  1621. # include <sys/unistd.h>
  1622. EXTERN_C_BEGIN
  1623. extern int etext[];
  1624. extern int end[];
  1625. void *rtems_get_stack_bottom(void);
  1626. # define InitStackBottom rtems_get_stack_bottom()
  1627. # define DATASTART ((ptr_t)etext)
  1628. # define DATAEND ((ptr_t)end)
  1629. # define STACKBOTTOM ((ptr_t)InitStackBottom)
  1630. # define SIG_SUSPEND SIGUSR1
  1631. # define SIG_THR_RESTART SIGUSR2
  1632. # endif
  1633. # ifdef DOS4GW
  1634. # define OS_TYPE "DOS4GW"
  1635. extern long __nullarea;
  1636. extern char _end;
  1637. extern char *_STACKTOP;
  1638. /* Depending on calling conventions Watcom C either precedes */
  1639. /* or does not precedes with underscore names of C-variables. */
  1640. /* Make sure startup code variables always have the same names. */
  1641. #pragma aux __nullarea "*";
  1642. #pragma aux _end "*";
  1643. # define STACKBOTTOM ((ptr_t)_STACKTOP)
  1644. /* confused? me too. */
  1645. # define DATASTART ((ptr_t)(&__nullarea))
  1646. # define DATAEND ((ptr_t)(&_end))
  1647. # endif
  1648. # ifdef HURD
  1649. # define OS_TYPE "HURD"
  1650. # define STACK_GROWS_DOWN
  1651. # define HEURISTIC2
  1652. # define SIG_SUSPEND SIGUSR1
  1653. # define SIG_THR_RESTART SIGUSR2
  1654. # define SEARCH_FOR_DATA_START
  1655. extern int _end[];
  1656. # define DATAEND ((ptr_t)(_end))
  1657. /* # define MPROTECT_VDB Not quite working yet? */
  1658. # define DYNAMIC_LOADING
  1659. # define USE_MMAP_ANON
  1660. # endif
  1661. # ifdef DARWIN
  1662. # define OS_TYPE "DARWIN"
  1663. # define DARWIN_DONT_PARSE_STACK
  1664. # ifndef GC_DONT_REGISTER_MAIN_STATIC_DATA
  1665. # define DYNAMIC_LOADING
  1666. # endif
  1667. /* XXX: see get_end(3), get_etext() and get_end() should not be used. */
  1668. /* These aren't used when dyld support is enabled (it is by default). */
  1669. # define DATASTART ((ptr_t)get_etext())
  1670. # define DATAEND ((ptr_t)get_end())
  1671. # define STACKBOTTOM ((ptr_t)0xc0000000)
  1672. # define USE_MMAP_ANON
  1673. # define MPROTECT_VDB
  1674. EXTERN_C_END
  1675. # include <unistd.h>
  1676. EXTERN_C_BEGIN
  1677. # define GETPAGESIZE() (unsigned)getpagesize()
  1678. /* There seems to be some issues with trylock hanging on darwin. */
  1679. /* This should be looked into some more. */
  1680. # define NO_PTHREAD_TRYLOCK
  1681. # if (TARGET_OS_IPHONE || TARGET_OS_XR || TARGET_OS_VISION) && !defined(NO_DYLD_BIND_FULLY_IMAGE)
  1682. /* iPhone/iPad simulator */
  1683. # define NO_DYLD_BIND_FULLY_IMAGE
  1684. # endif
  1685. # endif /* DARWIN */
  1686. # endif
  1687. # ifdef NS32K
  1688. # define MACH_TYPE "NS32K"
  1689. # define ALIGNMENT 4
  1690. extern char **environ;
  1691. # define DATASTART ((ptr_t)(&environ))
  1692. /* hideous kludge: environ is the first */
  1693. /* word in crt0.o, and delimits the start */
  1694. /* of the data segment, no matter which */
  1695. /* ld options were passed through. */
  1696. # define STACKBOTTOM ((ptr_t)0xfffff000) /* for Encore */
  1697. # endif
  1698. # ifdef MIPS
  1699. # define MACH_TYPE "MIPS"
  1700. # ifdef LINUX
  1701. # define OS_TYPE "LINUX"
  1702. # define DYNAMIC_LOADING
  1703. extern int _end[];
  1704. # pragma weak __data_start
  1705. extern int __data_start[];
  1706. # define DATASTART ((ptr_t)(__data_start))
  1707. # define DATAEND ((ptr_t)(_end))
  1708. # ifdef _MIPS_SZPTR
  1709. # define CPP_WORDSZ _MIPS_SZPTR
  1710. # define ALIGNMENT (_MIPS_SZPTR/8)
  1711. # else
  1712. # define ALIGNMENT 4
  1713. # endif
  1714. # ifndef HBLKSIZE
  1715. # define HBLKSIZE 4096
  1716. # endif
  1717. # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 2 || __GLIBC__ > 2
  1718. # define LINUX_STACKBOTTOM
  1719. # else
  1720. # define STACKBOTTOM ((ptr_t)0x7fff8000)
  1721. # endif
  1722. # endif /* Linux */
  1723. # ifdef EWS4800
  1724. # define HEURISTIC2
  1725. # if defined(_MIPS_SZPTR) && (_MIPS_SZPTR == 64)
  1726. extern int _fdata[], _end[];
  1727. # define DATASTART ((ptr_t)_fdata)
  1728. # define DATAEND ((ptr_t)_end)
  1729. # define CPP_WORDSZ _MIPS_SZPTR
  1730. # define ALIGNMENT (_MIPS_SZPTR/8)
  1731. # else
  1732. extern int etext[], edata[], end[];
  1733. extern int _DYNAMIC_LINKING[], _gp[];
  1734. # define DATASTART ((ptr_t)((((word)(etext) + 0x3ffff) & ~0x3ffff) \
  1735. + ((word)(etext) & 0xffff)))
  1736. # define DATAEND ((ptr_t)(edata))
  1737. # define GC_HAVE_DATAREGION2
  1738. # define DATASTART2 (_DYNAMIC_LINKING \
  1739. ? (ptr_t)(((word)_gp + 0x8000 + 0x3ffff) & ~0x3ffff) \
  1740. : (ptr_t)edata)
  1741. # define DATAEND2 ((ptr_t)(end))
  1742. # define ALIGNMENT 4
  1743. # endif
  1744. # define OS_TYPE "EWS4800"
  1745. # endif
  1746. # ifdef ULTRIX
  1747. # define HEURISTIC2
  1748. # define DATASTART ((ptr_t)0x10000000)
  1749. /* Could probably be slightly higher since */
  1750. /* startup code allocates lots of stuff. */
  1751. # define OS_TYPE "ULTRIX"
  1752. # define ALIGNMENT 4
  1753. # endif
  1754. # ifdef IRIX5
  1755. # define HEURISTIC2
  1756. extern int _fdata[];
  1757. # define DATASTART ((ptr_t)(_fdata))
  1758. # ifdef USE_MMAP
  1759. # define HEAP_START (ptr_t)0x30000000
  1760. # else
  1761. # define HEAP_START DATASTART
  1762. # endif
  1763. /* Lowest plausible heap address. */
  1764. /* In the MMAP case, we map there. */
  1765. /* In either case it is used to identify */
  1766. /* heap sections so they're not */
  1767. /* considered as roots. */
  1768. # define OS_TYPE "IRIX5"
  1769. /*# define MPROTECT_VDB DOB: this should work, but there is evidence */
  1770. /* of recent breakage. */
  1771. # ifdef _MIPS_SZPTR
  1772. # define CPP_WORDSZ _MIPS_SZPTR
  1773. # define ALIGNMENT (_MIPS_SZPTR/8)
  1774. # else
  1775. # define ALIGNMENT 4
  1776. # endif
  1777. # define DYNAMIC_LOADING
  1778. # endif
  1779. # ifdef MSWINCE
  1780. # define OS_TYPE "MSWINCE"
  1781. # define ALIGNMENT 4
  1782. # define DATAEND /* not needed */
  1783. # endif
  1784. # if defined(NETBSD)
  1785. # define OS_TYPE "NETBSD"
  1786. # define ALIGNMENT 4
  1787. # define HEURISTIC2
  1788. # ifdef __ELF__
  1789. extern ptr_t GC_data_start;
  1790. # define DATASTART GC_data_start
  1791. # define NEED_FIND_LIMIT
  1792. # define DYNAMIC_LOADING
  1793. # else
  1794. # define DATASTART ((ptr_t)0x10000000)
  1795. # define STACKBOTTOM ((ptr_t)0x7ffff000)
  1796. # endif /* _ELF_ */
  1797. # endif
  1798. # ifdef OPENBSD
  1799. # define OS_TYPE "OPENBSD"
  1800. # define ALIGNMENT 4
  1801. # ifndef GC_OPENBSD_THREADS
  1802. EXTERN_C_END
  1803. # include <sys/param.h>
  1804. # include <uvm/uvm_extern.h>
  1805. EXTERN_C_BEGIN
  1806. # ifdef USRSTACK
  1807. # define STACKBOTTOM ((ptr_t)USRSTACK)
  1808. # else
  1809. # define HEURISTIC2
  1810. # endif
  1811. # endif
  1812. extern int _fdata[];
  1813. # define DATASTART ((ptr_t)_fdata)
  1814. extern int _end[];
  1815. # define DATAEND ((ptr_t)(&_end))
  1816. # define DYNAMIC_LOADING
  1817. # endif
  1818. # ifdef FREEBSD
  1819. # define OS_TYPE "FREEBSD"
  1820. # define ALIGNMENT 4
  1821. # ifndef GC_FREEBSD_THREADS
  1822. # define MPROTECT_VDB
  1823. # endif
  1824. # define SIG_SUSPEND SIGUSR1
  1825. # define SIG_THR_RESTART SIGUSR2
  1826. # define FREEBSD_STACKBOTTOM
  1827. # ifdef __ELF__
  1828. # define DYNAMIC_LOADING
  1829. # endif
  1830. extern char etext[];
  1831. # define DATASTART GC_FreeBSDGetDataStart(0x1000, (ptr_t)etext)
  1832. # define DATASTART_USES_BSDGETDATASTART
  1833. # endif /* FreeBSD */
  1834. # if defined(NONSTOP)
  1835. # define CPP_WORDSZ 32
  1836. # define OS_TYPE "NONSTOP"
  1837. # define ALIGNMENT 4
  1838. # define DATASTART ((ptr_t)0x08000000)
  1839. extern char **environ;
  1840. # define DATAEND ((ptr_t)(environ - 0x10))
  1841. # define STACKBOTTOM ((ptr_t)0x4fffffff)
  1842. # endif
  1843. # endif
  1844. # ifdef NIOS2
  1845. # define CPP_WORDSZ 32
  1846. # define MACH_TYPE "NIOS2"
  1847. # ifdef LINUX
  1848. # define OS_TYPE "LINUX"
  1849. # define DYNAMIC_LOADING
  1850. extern int _end[];
  1851. extern int __data_start[];
  1852. # define DATASTART ((ptr_t)(__data_start))
  1853. # define DATAEND ((ptr_t)(_end))
  1854. # define ALIGNMENT 4
  1855. # ifndef HBLKSIZE
  1856. # define HBLKSIZE 4096
  1857. # endif
  1858. # define LINUX_STACKBOTTOM
  1859. # endif /* Linux */
  1860. # endif
  1861. # ifdef OR1K
  1862. # define CPP_WORDSZ 32
  1863. # define MACH_TYPE "OR1K"
  1864. # ifdef LINUX
  1865. # define OS_TYPE "LINUX"
  1866. # define DYNAMIC_LOADING
  1867. extern int _end[];
  1868. extern int __data_start[];
  1869. # define DATASTART ((ptr_t)(__data_start))
  1870. # define DATAEND ((ptr_t)(_end))
  1871. # define ALIGNMENT 4
  1872. # ifndef HBLKSIZE
  1873. # define HBLKSIZE 4096
  1874. # endif
  1875. # define LINUX_STACKBOTTOM
  1876. # endif /* Linux */
  1877. # endif
  1878. # ifdef HP_PA
  1879. # define MACH_TYPE "HP_PA"
  1880. # ifdef __LP64__
  1881. # define CPP_WORDSZ 64
  1882. # define ALIGNMENT 8
  1883. # else
  1884. # define CPP_WORDSZ 32
  1885. # define ALIGNMENT 4
  1886. # endif
  1887. # if !defined(GC_HPUX_THREADS) && !defined(GC_LINUX_THREADS) \
  1888. && !defined(OPENBSD) && !defined(LINUX) /* For now. */
  1889. # define MPROTECT_VDB
  1890. # endif
  1891. # define STACK_GROWS_UP
  1892. # ifdef HPUX
  1893. # define OS_TYPE "HPUX"
  1894. extern int __data_start[];
  1895. # define DATASTART ((ptr_t)(__data_start))
  1896. # ifdef USE_HPUX_FIXED_STACKBOTTOM
  1897. /* The following appears to work for 7xx systems running HP/UX */
  1898. /* 9.xx. Furthermore, it might result in much faster */
  1899. /* collections than HEURISTIC2, which may involve scanning */
  1900. /* segments that directly precede the stack. It is not the */
  1901. /* default, since it may not work on older machine/OS */
  1902. /* combinations. (Thanks to Raymond X.T. Nijssen for uncovering */
  1903. /* this.) */
  1904. # define STACKBOTTOM ((ptr_t)0x7b033000) /* from /etc/conf/h/param.h */
  1905. # else
  1906. /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
  1907. /* to this. Note that the GC must be initialized before the */
  1908. /* first putenv call. */
  1909. extern char ** environ;
  1910. # define STACKBOTTOM ((ptr_t)environ)
  1911. # endif
  1912. # define DYNAMIC_LOADING
  1913. EXTERN_C_END
  1914. # include <unistd.h>
  1915. EXTERN_C_BEGIN
  1916. # define GETPAGESIZE() (unsigned)sysconf(_SC_PAGE_SIZE)
  1917. # ifndef __GNUC__
  1918. # define PREFETCH(x) do { \
  1919. register long addr = (long)(x); \
  1920. (void) _asm ("LDW", 0, 0, addr, 0); \
  1921. } while (0)
  1922. # endif
  1923. # endif /* HPUX */
  1924. # ifdef LINUX
  1925. # define OS_TYPE "LINUX"
  1926. # define LINUX_STACKBOTTOM
  1927. # define DYNAMIC_LOADING
  1928. # define SEARCH_FOR_DATA_START
  1929. extern int _end[];
  1930. # define DATAEND ((ptr_t)(&_end))
  1931. # endif /* LINUX */
  1932. # ifdef OPENBSD
  1933. # define OS_TYPE "OPENBSD"
  1934. # ifndef GC_OPENBSD_THREADS
  1935. EXTERN_C_END
  1936. # include <sys/param.h>
  1937. # include <uvm/uvm_extern.h>
  1938. EXTERN_C_BEGIN
  1939. # ifdef USRSTACK
  1940. # define STACKBOTTOM ((ptr_t)USRSTACK)
  1941. # else
  1942. # define HEURISTIC2
  1943. # endif
  1944. # endif
  1945. extern int __data_start[];
  1946. # define DATASTART ((ptr_t)__data_start)
  1947. extern int _end[];
  1948. # define DATAEND ((ptr_t)(&_end))
  1949. # define DYNAMIC_LOADING
  1950. # endif
  1951. # endif /* HP_PA */
  1952. # ifdef ALPHA
  1953. # define MACH_TYPE "ALPHA"
  1954. # define ALIGNMENT 8
  1955. # define CPP_WORDSZ 64
  1956. # ifdef NETBSD
  1957. # define OS_TYPE "NETBSD"
  1958. # define HEURISTIC2
  1959. extern ptr_t GC_data_start;
  1960. # define DATASTART GC_data_start
  1961. # define ELFCLASS32 32
  1962. # define ELFCLASS64 64
  1963. # define ELF_CLASS ELFCLASS64
  1964. # define DYNAMIC_LOADING
  1965. # endif
  1966. # ifdef OPENBSD
  1967. # define OS_TYPE "OPENBSD"
  1968. # define ELF_CLASS ELFCLASS64
  1969. # ifndef GC_OPENBSD_THREADS
  1970. EXTERN_C_END
  1971. # include <sys/param.h>
  1972. # include <uvm/uvm_extern.h>
  1973. EXTERN_C_BEGIN
  1974. # ifdef USRSTACK
  1975. # define STACKBOTTOM ((ptr_t)USRSTACK)
  1976. # else
  1977. # define HEURISTIC2
  1978. # endif
  1979. # endif
  1980. extern int __data_start[];
  1981. # define DATASTART ((ptr_t)__data_start)
  1982. extern int _end[];
  1983. # define DATAEND ((ptr_t)(&_end))
  1984. # define DYNAMIC_LOADING
  1985. # endif
  1986. # ifdef FREEBSD
  1987. # define OS_TYPE "FREEBSD"
  1988. /* MPROTECT_VDB is not yet supported at all on FreeBSD/alpha. */
  1989. # define SIG_SUSPEND SIGUSR1
  1990. # define SIG_THR_RESTART SIGUSR2
  1991. /* SIGTSTP and SIGCONT could be used alternatively. */
  1992. # define FREEBSD_STACKBOTTOM
  1993. # ifdef __ELF__
  1994. # define DYNAMIC_LOADING
  1995. # endif
  1996. /* Handle unmapped hole alpha*-*-freebsd[45]* puts between etext and edata. */
  1997. extern char etext[];
  1998. extern char edata[];
  1999. extern char end[];
  2000. # define NEED_FIND_LIMIT
  2001. # define DATASTART ((ptr_t)(&etext))
  2002. ptr_t GC_find_limit(ptr_t, GC_bool);
  2003. # define DATAEND GC_find_limit(DATASTART, TRUE)
  2004. # define DATAEND_IS_FUNC
  2005. # define GC_HAVE_DATAREGION2
  2006. # define DATASTART2 ((ptr_t)(&edata))
  2007. # define DATAEND2 ((ptr_t)(&end))
  2008. # endif
  2009. # ifdef OSF1
  2010. # define OS_TYPE "OSF1"
  2011. # define DATASTART ((ptr_t)0x140000000)
  2012. extern int _end[];
  2013. # define DATAEND ((ptr_t)(&_end))
  2014. extern char ** environ;
  2015. /* round up from the value of environ to the nearest page boundary */
  2016. /* Probably breaks if putenv is called before collector */
  2017. /* initialization. */
  2018. # define STACKBOTTOM ((ptr_t)(((word)(environ) | (getpagesize()-1))+1))
  2019. /* # define HEURISTIC2 */
  2020. /* Normally HEURISTIC2 is too conservative, since */
  2021. /* the text segment immediately follows the stack. */
  2022. /* Hence we give an upper pound. */
  2023. /* This is currently unused, since we disabled HEURISTIC2 */
  2024. extern int __start[];
  2025. # define HEURISTIC2_LIMIT ((ptr_t)((word)(__start) & ~(getpagesize()-1)))
  2026. # ifndef GC_OSF1_THREADS
  2027. /* Unresolved signal issues with threads. */
  2028. # define MPROTECT_VDB
  2029. # endif
  2030. # define DYNAMIC_LOADING
  2031. # endif
  2032. # ifdef LINUX
  2033. # define OS_TYPE "LINUX"
  2034. # define LINUX_STACKBOTTOM
  2035. # ifdef __ELF__
  2036. # define SEARCH_FOR_DATA_START
  2037. # define DYNAMIC_LOADING
  2038. # else
  2039. # define DATASTART ((ptr_t)0x140000000)
  2040. # endif
  2041. extern int _end[];
  2042. # define DATAEND ((ptr_t)(_end))
  2043. # define MPROTECT_VDB
  2044. /* Has only been superficially tested. May not */
  2045. /* work on all versions. */
  2046. # endif
  2047. # endif
  2048. # ifdef IA64
  2049. # define MACH_TYPE "IA64"
  2050. # ifdef HPUX
  2051. # ifdef _ILP32
  2052. # define CPP_WORDSZ 32
  2053. /* Requires 8 byte alignment for malloc */
  2054. # define ALIGNMENT 4
  2055. # else
  2056. # ifndef _LP64
  2057. # error --> unknown ABI
  2058. # endif
  2059. # define CPP_WORDSZ 64
  2060. /* Requires 16 byte alignment for malloc */
  2061. # define ALIGNMENT 8
  2062. # endif
  2063. # define OS_TYPE "HPUX"
  2064. extern int __data_start[];
  2065. # define DATASTART ((ptr_t)(__data_start))
  2066. /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
  2067. /* to this. Note that the GC must be initialized before the */
  2068. /* first putenv call. */
  2069. extern char ** environ;
  2070. # define STACKBOTTOM ((ptr_t)environ)
  2071. # define HPUX_STACKBOTTOM
  2072. # define DYNAMIC_LOADING
  2073. EXTERN_C_END
  2074. # include <unistd.h>
  2075. EXTERN_C_BEGIN
  2076. # define GETPAGESIZE() (unsigned)sysconf(_SC_PAGE_SIZE)
  2077. /* The following was empirically determined, and is probably */
  2078. /* not very robust. */
  2079. /* Note that the backing store base seems to be at a nice */
  2080. /* address minus one page. */
  2081. # define BACKING_STORE_DISPLACEMENT 0x1000000
  2082. # define BACKING_STORE_ALIGNMENT 0x1000
  2083. extern ptr_t GC_register_stackbottom;
  2084. # define BACKING_STORE_BASE GC_register_stackbottom
  2085. /* Known to be wrong for recent HP/UX versions!!! */
  2086. # endif
  2087. # ifdef LINUX
  2088. # define CPP_WORDSZ 64
  2089. # define ALIGNMENT 8
  2090. # define OS_TYPE "LINUX"
  2091. /* The following works on NUE and older kernels: */
  2092. /* # define STACKBOTTOM ((ptr_t) 0xa000000000000000l) */
  2093. /* This does not work on NUE: */
  2094. # define LINUX_STACKBOTTOM
  2095. /* We also need the base address of the register stack */
  2096. /* backing store. */
  2097. extern ptr_t GC_register_stackbottom;
  2098. # define BACKING_STORE_BASE GC_register_stackbottom
  2099. # define SEARCH_FOR_DATA_START
  2100. # ifdef __GNUC__
  2101. # define DYNAMIC_LOADING
  2102. # else
  2103. /* In the Intel compiler environment, we seem to end up with */
  2104. /* statically linked executables and an undefined reference */
  2105. /* to _DYNAMIC */
  2106. # endif
  2107. # define MPROTECT_VDB
  2108. /* Requires Linux 2.3.47 or later. */
  2109. extern int _end[];
  2110. # define DATAEND ((ptr_t)(_end))
  2111. # ifdef __GNUC__
  2112. # ifndef __INTEL_COMPILER
  2113. # define PREFETCH(x) \
  2114. __asm__ (" lfetch [%0]": : "r"(x))
  2115. # define GC_PREFETCH_FOR_WRITE(x) \
  2116. __asm__ (" lfetch.excl [%0]": : "r"(x))
  2117. # define CLEAR_DOUBLE(x) \
  2118. __asm__ (" stf.spill [%0]=f0": : "r"((void *)(x)))
  2119. # else
  2120. EXTERN_C_END
  2121. # include <ia64intrin.h>
  2122. EXTERN_C_BEGIN
  2123. # define PREFETCH(x) __lfetch(__lfhint_none, (x))
  2124. # define GC_PREFETCH_FOR_WRITE(x) __lfetch(__lfhint_nta, (x))
  2125. # define CLEAR_DOUBLE(x) __stf_spill((void *)(x), 0)
  2126. # endif /* __INTEL_COMPILER */
  2127. # endif
  2128. # endif
  2129. # ifdef CYGWIN32
  2130. # define OS_TYPE "CYGWIN32"
  2131. # define DATASTART ((ptr_t)GC_DATASTART) /* From gc.h */
  2132. # define DATAEND ((ptr_t)GC_DATAEND)
  2133. # undef STACK_GRAN
  2134. # define STACK_GRAN 0x10000
  2135. # ifdef USE_MMAP
  2136. # define NEED_FIND_LIMIT
  2137. # define USE_MMAP_ANON
  2138. # endif
  2139. # endif
  2140. # ifdef MSWIN32
  2141. /* FIXME: This is a very partial guess. There is no port, yet. */
  2142. # define OS_TYPE "MSWIN32"
  2143. /* STACKBOTTOM and DATASTART are handled specially in */
  2144. /* os_dep.c. */
  2145. # define DATAEND /* not needed */
  2146. # if defined(_WIN64)
  2147. # define CPP_WORDSZ 64
  2148. # else
  2149. # define CPP_WORDSZ 32 /* Is this possible? */
  2150. # endif
  2151. # define ALIGNMENT 8
  2152. # endif
  2153. # endif
  2154. # ifdef M88K
  2155. # define MACH_TYPE "M88K"
  2156. # define ALIGNMENT 4
  2157. extern int etext[];
  2158. # ifdef CX_UX
  2159. # define OS_TYPE "CX_UX"
  2160. # define DATASTART ((ptr_t)((((word)(etext) + 0x3fffff) & ~0x3fffff) \
  2161. + 0x10000))
  2162. # endif
  2163. # ifdef DGUX
  2164. # define OS_TYPE "DGUX"
  2165. ptr_t GC_SysVGetDataStart(size_t, ptr_t);
  2166. # define DATASTART GC_SysVGetDataStart(0x10000, (ptr_t)etext)
  2167. # define DATASTART_IS_FUNC
  2168. # endif
  2169. # define STACKBOTTOM ((char*)0xf0000000) /* determined empirically */
  2170. # endif
  2171. # ifdef S370
  2172. /* If this still works, and if anyone cares, this should probably */
  2173. /* be moved to the S390 category. */
  2174. # define MACH_TYPE "S370"
  2175. # define ALIGNMENT 4 /* Required by hardware */
  2176. # ifdef UTS4
  2177. # define OS_TYPE "UTS4"
  2178. extern int etext[];
  2179. extern int _etext[];
  2180. extern int _end[];
  2181. ptr_t GC_SysVGetDataStart(size_t, ptr_t);
  2182. # define DATASTART GC_SysVGetDataStart(0x10000, (ptr_t)_etext)
  2183. # define DATASTART_IS_FUNC
  2184. # define DATAEND ((ptr_t)(_end))
  2185. # define HEURISTIC2
  2186. # endif
  2187. # endif
  2188. # ifdef S390
  2189. # define MACH_TYPE "S390"
  2190. # ifndef __s390x__
  2191. # define ALIGNMENT 4
  2192. # define CPP_WORDSZ 32
  2193. # else
  2194. # define ALIGNMENT 8
  2195. # define CPP_WORDSZ 64
  2196. # ifndef HBLKSIZE
  2197. # define HBLKSIZE 4096
  2198. # endif
  2199. # endif
  2200. # ifdef LINUX
  2201. # define OS_TYPE "LINUX"
  2202. # define LINUX_STACKBOTTOM
  2203. # define DYNAMIC_LOADING
  2204. extern int __data_start[] __attribute__((__weak__));
  2205. # define DATASTART ((ptr_t)(__data_start))
  2206. extern int _end[] __attribute__((__weak__));
  2207. # define DATAEND ((ptr_t)(_end))
  2208. # define CACHE_LINE_SIZE 256
  2209. # define GETPAGESIZE() 4096
  2210. # endif
  2211. # endif
  2212. # ifdef AARCH64
  2213. # define MACH_TYPE "AARCH64"
  2214. # ifdef __ILP32__
  2215. # define CPP_WORDSZ 32
  2216. # define ALIGNMENT 4
  2217. # else
  2218. # define CPP_WORDSZ 64
  2219. # define ALIGNMENT 8
  2220. # endif
  2221. # ifndef HBLKSIZE
  2222. # define HBLKSIZE 4096
  2223. # endif
  2224. # ifdef LINUX
  2225. # define OS_TYPE "LINUX"
  2226. # define LINUX_STACKBOTTOM
  2227. # define DYNAMIC_LOADING
  2228. extern int __data_start[];
  2229. extern int _end[];
  2230. # define DATASTART ((ptr_t)__data_start)
  2231. # define DATAEND ((ptr_t)(&_end))
  2232. # endif
  2233. # ifdef DARWIN
  2234. /* iOS */
  2235. # define OS_TYPE "DARWIN"
  2236. # define DARWIN_DONT_PARSE_STACK
  2237. # ifndef GC_DONT_REGISTER_MAIN_STATIC_DATA
  2238. # define DYNAMIC_LOADING
  2239. # endif
  2240. # define DATASTART ((ptr_t)get_etext())
  2241. # define DATAEND ((ptr_t)get_end())
  2242. # define STACKBOTTOM ((ptr_t)0x16fdfffff)
  2243. # define USE_MMAP_ANON
  2244. # define MPROTECT_VDB
  2245. EXTERN_C_END
  2246. # include <unistd.h>
  2247. EXTERN_C_BEGIN
  2248. # define GETPAGESIZE() (unsigned)getpagesize()
  2249. /* FIXME: There seems to be some issues with trylock hanging on */
  2250. /* darwin. This should be looked into some more. */
  2251. # define NO_PTHREAD_TRYLOCK
  2252. # if (TARGET_OS_IPHONE || TARGET_OS_XR || TARGET_OS_VISION) && !defined(NO_DYLD_BIND_FULLY_IMAGE)
  2253. # define NO_DYLD_BIND_FULLY_IMAGE
  2254. # endif
  2255. # endif
  2256. # ifdef FREEBSD
  2257. # define OS_TYPE "FREEBSD"
  2258. # ifndef GC_FREEBSD_THREADS
  2259. # define MPROTECT_VDB
  2260. # endif
  2261. # define FREEBSD_STACKBOTTOM
  2262. # ifdef __ELF__
  2263. # define DYNAMIC_LOADING
  2264. # endif
  2265. extern char etext[];
  2266. # define DATASTART GC_FreeBSDGetDataStart(0x1000, (ptr_t)etext)
  2267. # define DATASTART_USES_BSDGETDATASTART
  2268. # endif
  2269. # ifdef NINTENDO_SWITCH
  2270. static int zero_fd = -1;
  2271. # define OPT_MAP_ANON 0
  2272. extern int __bss_end[];
  2273. # define NO_HANDLE_FORK
  2274. # define GETPAGESIZE() 4096
  2275. # define DATASTART (ptr_t)ALIGNMENT /* cannot be null */
  2276. # define DATAEND (ptr_t)(&__bss_end)
  2277. void *switch_get_stack_bottom(void);
  2278. # define STACKBOTTOM ((ptr_t)switch_get_stack_bottom())
  2279. # undef USE_MMAP
  2280. # undef USE_MUNMAP
  2281. # endif
  2282. # ifdef NOSYS
  2283. /* __data_start is usually defined in the target linker script. */
  2284. extern int __data_start[];
  2285. # define DATASTART ((ptr_t)__data_start)
  2286. extern void *__stack_base__;
  2287. # define STACKBOTTOM ((ptr_t)__stack_base__)
  2288. # endif
  2289. # endif
  2290. # ifdef ARM32
  2291. # if defined(NACL)
  2292. # define MACH_TYPE "NACL"
  2293. # else
  2294. # define MACH_TYPE "ARM32"
  2295. # endif
  2296. # define CPP_WORDSZ 32
  2297. # define ALIGNMENT 4
  2298. # ifdef NETBSD
  2299. # define OS_TYPE "NETBSD"
  2300. # define HEURISTIC2
  2301. # ifdef __ELF__
  2302. extern ptr_t GC_data_start;
  2303. # define DATASTART GC_data_start
  2304. # define DYNAMIC_LOADING
  2305. # else
  2306. extern char etext[];
  2307. # define DATASTART ((ptr_t)(etext))
  2308. # endif
  2309. # endif
  2310. # ifdef LINUX
  2311. # define OS_TYPE "LINUX"
  2312. # define LINUX_STACKBOTTOM
  2313. # undef STACK_GRAN
  2314. # define STACK_GRAN 0x10000000
  2315. # ifdef __ELF__
  2316. # define DYNAMIC_LOADING
  2317. EXTERN_C_END
  2318. # include <features.h>
  2319. EXTERN_C_BEGIN
  2320. # if defined(__GLIBC__) && __GLIBC__ >= 2 \
  2321. || defined(HOST_ANDROID) || defined(HOST_TIZEN)
  2322. # define SEARCH_FOR_DATA_START
  2323. # else
  2324. extern char **__environ;
  2325. # define DATASTART ((ptr_t)(&__environ))
  2326. /* hideous kludge: __environ is the first */
  2327. /* word in crt0.o, and delimits the start */
  2328. /* of the data segment, no matter which */
  2329. /* ld options were passed through. */
  2330. /* We could use _etext instead, but that */
  2331. /* would include .rodata, which may */
  2332. /* contain large read-only data tables */
  2333. /* that we'd rather not scan. */
  2334. # endif
  2335. extern int _end[];
  2336. # define DATAEND ((ptr_t)(_end))
  2337. # else
  2338. extern int etext[];
  2339. # define DATASTART ((ptr_t)((((word)(etext)) + 0xfff) & ~0xfff))
  2340. # endif
  2341. # endif
  2342. # ifdef MSWINCE
  2343. # define OS_TYPE "MSWINCE"
  2344. # define DATAEND /* not needed */
  2345. # endif
  2346. # ifdef FREEBSD
  2347. /* FreeBSD/arm */
  2348. # define OS_TYPE "FREEBSD"
  2349. # ifndef GC_FREEBSD_THREADS
  2350. # define MPROTECT_VDB
  2351. # endif
  2352. # define SIG_SUSPEND SIGUSR1
  2353. # define SIG_THR_RESTART SIGUSR2
  2354. # define FREEBSD_STACKBOTTOM
  2355. # ifdef __ELF__
  2356. # define DYNAMIC_LOADING
  2357. # endif
  2358. extern char etext[];
  2359. # define DATASTART GC_FreeBSDGetDataStart(0x1000, (ptr_t)etext)
  2360. # define DATASTART_USES_BSDGETDATASTART
  2361. # endif
  2362. # ifdef DARWIN
  2363. /* iOS */
  2364. # define OS_TYPE "DARWIN"
  2365. # define DARWIN_DONT_PARSE_STACK
  2366. # ifndef GC_DONT_REGISTER_MAIN_STATIC_DATA
  2367. # define DYNAMIC_LOADING
  2368. # endif
  2369. # define DATASTART ((ptr_t)get_etext())
  2370. # define DATAEND ((ptr_t)get_end())
  2371. # define STACKBOTTOM ((ptr_t)0x30000000)
  2372. # define USE_MMAP_ANON
  2373. # define MPROTECT_VDB
  2374. EXTERN_C_END
  2375. # include <unistd.h>
  2376. EXTERN_C_BEGIN
  2377. # define GETPAGESIZE() (unsigned)getpagesize()
  2378. /* FIXME: There seems to be some issues with trylock hanging on */
  2379. /* darwin. This should be looked into some more. */
  2380. # define NO_PTHREAD_TRYLOCK
  2381. # if (TARGET_OS_IPHONE || TARGET_OS_XR || TARGET_OS_VISION) && !defined(NO_DYLD_BIND_FULLY_IMAGE)
  2382. # define NO_DYLD_BIND_FULLY_IMAGE
  2383. # endif
  2384. # endif
  2385. # ifdef OPENBSD
  2386. # define OS_TYPE "OPENBSD"
  2387. # ifndef GC_OPENBSD_THREADS
  2388. EXTERN_C_END
  2389. # include <sys/param.h>
  2390. # include <uvm/uvm_extern.h>
  2391. EXTERN_C_BEGIN
  2392. # ifdef USRSTACK
  2393. # define STACKBOTTOM ((ptr_t)USRSTACK)
  2394. # else
  2395. # define HEURISTIC2
  2396. # endif
  2397. # endif
  2398. extern int __data_start[];
  2399. # define DATASTART ((ptr_t)__data_start)
  2400. extern int _end[];
  2401. # define DATAEND ((ptr_t)(&_end))
  2402. # define DYNAMIC_LOADING
  2403. # endif
  2404. # ifdef SN_TARGET_PSP2
  2405. # define NO_HANDLE_FORK
  2406. # define DATASTART (ptr_t)ALIGNMENT
  2407. # define DATAEND (ptr_t)ALIGNMENT
  2408. void *psp2_get_stack_bottom(void);
  2409. # define STACKBOTTOM ((ptr_t)psp2_get_stack_bottom())
  2410. # endif
  2411. # ifdef NN_PLATFORM_CTR
  2412. extern unsigned char Image$$ZI$$ZI$$Base[];
  2413. # define DATASTART (ptr_t)(Image$$ZI$$ZI$$Base)
  2414. extern unsigned char Image$$ZI$$ZI$$Limit[];
  2415. # define DATAEND (ptr_t)(Image$$ZI$$ZI$$Limit)
  2416. void *n3ds_get_stack_bottom(void);
  2417. # define STACKBOTTOM ((ptr_t)n3ds_get_stack_bottom())
  2418. # endif
  2419. # ifdef NOSYS
  2420. /* __data_start is usually defined in the target linker script. */
  2421. extern int __data_start[];
  2422. # define DATASTART ((ptr_t)(__data_start))
  2423. /* __stack_base__ is set in newlib/libc/sys/arm/crt0.S */
  2424. extern void *__stack_base__;
  2425. # define STACKBOTTOM ((ptr_t)(__stack_base__))
  2426. # endif
  2427. #endif
  2428. # ifdef CRIS
  2429. # define MACH_TYPE "CRIS"
  2430. # define CPP_WORDSZ 32
  2431. # define ALIGNMENT 1
  2432. # define OS_TYPE "LINUX"
  2433. # define DYNAMIC_LOADING
  2434. # define LINUX_STACKBOTTOM
  2435. # define SEARCH_FOR_DATA_START
  2436. extern int _end[];
  2437. # define DATAEND ((ptr_t)(_end))
  2438. # endif
  2439. # if defined(SH) && !defined(SH4)
  2440. # define MACH_TYPE "SH"
  2441. # define ALIGNMENT 4
  2442. # ifdef MSWINCE
  2443. # define OS_TYPE "MSWINCE"
  2444. # define DATAEND /* not needed */
  2445. # endif
  2446. # ifdef LINUX
  2447. # define OS_TYPE "LINUX"
  2448. # define LINUX_STACKBOTTOM
  2449. # define DYNAMIC_LOADING
  2450. # define SEARCH_FOR_DATA_START
  2451. extern int _end[];
  2452. # define DATAEND ((ptr_t)(_end))
  2453. # endif
  2454. # ifdef NETBSD
  2455. # define OS_TYPE "NETBSD"
  2456. # define HEURISTIC2
  2457. extern ptr_t GC_data_start;
  2458. # define DATASTART GC_data_start
  2459. # define DYNAMIC_LOADING
  2460. # endif
  2461. # ifdef OPENBSD
  2462. # define OS_TYPE "OPENBSD"
  2463. # ifndef GC_OPENBSD_THREADS
  2464. EXTERN_C_END
  2465. # include <sys/param.h>
  2466. # include <uvm/uvm_extern.h>
  2467. EXTERN_C_BEGIN
  2468. # ifdef USRSTACK
  2469. # define STACKBOTTOM ((ptr_t)USRSTACK)
  2470. # else
  2471. # define HEURISTIC2
  2472. # endif
  2473. # endif
  2474. extern int __data_start[];
  2475. # define DATASTART ((ptr_t)__data_start)
  2476. extern int _end[];
  2477. # define DATAEND ((ptr_t)(&_end))
  2478. # define DYNAMIC_LOADING
  2479. # endif
  2480. # endif
  2481. # ifdef SH4
  2482. # define MACH_TYPE "SH4"
  2483. # define OS_TYPE "MSWINCE"
  2484. # define ALIGNMENT 4
  2485. # define DATAEND /* not needed */
  2486. # endif
  2487. # ifdef AVR32
  2488. # define MACH_TYPE "AVR32"
  2489. # define CPP_WORDSZ 32
  2490. # define ALIGNMENT 4
  2491. # define OS_TYPE "LINUX"
  2492. # define DYNAMIC_LOADING
  2493. # define LINUX_STACKBOTTOM
  2494. # define SEARCH_FOR_DATA_START
  2495. extern int _end[];
  2496. # define DATAEND ((ptr_t)(_end))
  2497. # endif
  2498. # ifdef M32R
  2499. # define CPP_WORDSZ 32
  2500. # define MACH_TYPE "M32R"
  2501. # define ALIGNMENT 4
  2502. # ifdef LINUX
  2503. # define OS_TYPE "LINUX"
  2504. # define LINUX_STACKBOTTOM
  2505. # undef STACK_GRAN
  2506. # define STACK_GRAN 0x10000000
  2507. # define DYNAMIC_LOADING
  2508. # define SEARCH_FOR_DATA_START
  2509. extern int _end[];
  2510. # define DATAEND ((ptr_t)(_end))
  2511. # endif
  2512. # endif
  2513. # ifdef X86_64
  2514. # define MACH_TYPE "X86_64"
  2515. # ifdef __ILP32__
  2516. # define ALIGNMENT 4
  2517. # define CPP_WORDSZ 32
  2518. # else
  2519. # define ALIGNMENT 8
  2520. # define CPP_WORDSZ 64
  2521. # endif
  2522. # ifndef HBLKSIZE
  2523. # define HBLKSIZE 4096
  2524. # endif
  2525. # ifndef CACHE_LINE_SIZE
  2526. # define CACHE_LINE_SIZE 64
  2527. # endif
  2528. # ifdef PLATFORM_GETMEM
  2529. # define DATASTART (ptr_t)ALIGNMENT
  2530. # define DATAEND (ptr_t)ALIGNMENT
  2531. EXTERN_C_END
  2532. # include <pthread.h>
  2533. EXTERN_C_BEGIN
  2534. void *platform_get_stack_bottom(void);
  2535. # define STACKBOTTOM ((ptr_t)platform_get_stack_bottom())
  2536. # endif
  2537. # ifdef OPENBSD
  2538. # define OS_TYPE "OPENBSD"
  2539. # define ELF_CLASS ELFCLASS64
  2540. # ifndef GC_OPENBSD_THREADS
  2541. EXTERN_C_END
  2542. # include <sys/param.h>
  2543. # include <uvm/uvm_extern.h>
  2544. EXTERN_C_BEGIN
  2545. # ifdef USRSTACK
  2546. # define STACKBOTTOM ((ptr_t)USRSTACK)
  2547. # else
  2548. # define HEURISTIC2
  2549. # endif
  2550. # endif
  2551. extern int __data_start[];
  2552. extern int _end[];
  2553. # define DATASTART ((ptr_t)__data_start)
  2554. # define DATAEND ((ptr_t)(&_end))
  2555. # define DYNAMIC_LOADING
  2556. # endif
  2557. # ifdef LINUX
  2558. # define OS_TYPE "LINUX"
  2559. # define LINUX_STACKBOTTOM
  2560. # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
  2561. # define MPROTECT_VDB
  2562. # else
  2563. /* We seem to get random errors in incremental mode, */
  2564. /* possibly because Linux threads is itself a malloc client */
  2565. /* and can't deal with the signals. */
  2566. # endif
  2567. # ifdef __ELF__
  2568. # define DYNAMIC_LOADING
  2569. EXTERN_C_END
  2570. # include <features.h>
  2571. EXTERN_C_BEGIN
  2572. # define SEARCH_FOR_DATA_START
  2573. extern int _end[];
  2574. # define DATAEND ((ptr_t)(_end))
  2575. # else
  2576. extern int etext[];
  2577. # define DATASTART ((ptr_t)((((word)(etext)) + 0xfff) & ~0xfff))
  2578. # endif
  2579. # if defined(__GLIBC__) && !defined(__UCLIBC__)
  2580. /* At present, there's a bug in GLibc getcontext() on */
  2581. /* Linux/x64 (it clears FPU exception mask). We define this */
  2582. /* macro to workaround it. */
  2583. /* FIXME: This seems to be fixed in GLibc v2.14. */
  2584. # define GETCONTEXT_FPU_EXCMASK_BUG
  2585. # endif
  2586. # if defined(__GLIBC__) && !defined(__UCLIBC__)
  2587. /* Workaround lock elision implementation for some glibc. */
  2588. # define GLIBC_2_19_TSX_BUG
  2589. EXTERN_C_END
  2590. # include <gnu/libc-version.h> /* for gnu_get_libc_version() */
  2591. EXTERN_C_BEGIN
  2592. # endif
  2593. # endif
  2594. # ifdef DARWIN
  2595. # define OS_TYPE "DARWIN"
  2596. # define DARWIN_DONT_PARSE_STACK
  2597. # ifndef GC_DONT_REGISTER_MAIN_STATIC_DATA
  2598. # define DYNAMIC_LOADING
  2599. # endif
  2600. /* XXX: see get_end(3), get_etext() and get_end() should not be used. */
  2601. /* These aren't used when dyld support is enabled (it is by default) */
  2602. # define DATASTART ((ptr_t)get_etext())
  2603. # define DATAEND ((ptr_t)get_end())
  2604. # define STACKBOTTOM ((ptr_t)0x7fff5fc00000)
  2605. # define USE_MMAP_ANON
  2606. # define MPROTECT_VDB
  2607. EXTERN_C_END
  2608. # include <unistd.h>
  2609. EXTERN_C_BEGIN
  2610. # define GETPAGESIZE() (unsigned)getpagesize()
  2611. /* There seems to be some issues with trylock hanging on darwin. */
  2612. /* This should be looked into some more. */
  2613. # define NO_PTHREAD_TRYLOCK
  2614. # if (TARGET_OS_IPHONE || TARGET_OS_XR || TARGET_OS_VISION) && !defined(NO_DYLD_BIND_FULLY_IMAGE)
  2615. /* iPhone/iPad simulator */
  2616. # define NO_DYLD_BIND_FULLY_IMAGE
  2617. # endif
  2618. # endif
  2619. # ifdef FREEBSD
  2620. # define OS_TYPE "FREEBSD"
  2621. # ifndef GC_FREEBSD_THREADS
  2622. # define MPROTECT_VDB
  2623. # endif
  2624. # ifdef __GLIBC__
  2625. # define SIG_SUSPEND (32+6)
  2626. # define SIG_THR_RESTART (32+5)
  2627. extern int _end[];
  2628. # define DATAEND ((ptr_t)(_end))
  2629. # else
  2630. # define SIG_SUSPEND SIGUSR1
  2631. # define SIG_THR_RESTART SIGUSR2
  2632. /* SIGTSTP and SIGCONT could be used alternatively. */
  2633. # endif
  2634. # define FREEBSD_STACKBOTTOM
  2635. # ifdef __ELF__
  2636. # define DYNAMIC_LOADING
  2637. # endif
  2638. extern char etext[];
  2639. # define DATASTART GC_FreeBSDGetDataStart(0x1000, (ptr_t)etext)
  2640. # define DATASTART_USES_BSDGETDATASTART
  2641. # endif
  2642. # ifdef NETBSD
  2643. # define OS_TYPE "NETBSD"
  2644. # define HEURISTIC2
  2645. # ifdef __ELF__
  2646. extern ptr_t GC_data_start;
  2647. # define DATASTART GC_data_start
  2648. # define DYNAMIC_LOADING
  2649. # else
  2650. # define SEARCH_FOR_DATA_START
  2651. # endif
  2652. # endif
  2653. # ifdef HAIKU
  2654. # define OS_TYPE "HAIKU"
  2655. EXTERN_C_END
  2656. # include <OS.h>
  2657. EXTERN_C_BEGIN
  2658. # define GETPAGESIZE() (unsigned)B_PAGE_SIZE
  2659. # define HEURISTIC2
  2660. # define SEARCH_FOR_DATA_START
  2661. # define DYNAMIC_LOADING
  2662. # define MPROTECT_VDB
  2663. # endif
  2664. # ifdef SOLARIS
  2665. # define OS_TYPE "SOLARIS"
  2666. # define ELF_CLASS ELFCLASS64
  2667. extern int _etext[], _end[];
  2668. ptr_t GC_SysVGetDataStart(size_t, ptr_t);
  2669. # define DATASTART GC_SysVGetDataStart(0x1000, (ptr_t)_etext)
  2670. # define DATASTART_IS_FUNC
  2671. # define DATAEND ((ptr_t)(_end))
  2672. /* # define STACKBOTTOM ((ptr_t)(_start)) worked through 2.7, */
  2673. /* but reportedly breaks under 2.8. It appears that the stack */
  2674. /* base is a property of the executable, so this should not */
  2675. /* break old executables. */
  2676. /* HEURISTIC2 probably works, but this appears to be preferable.*/
  2677. /* Apparently USRSTACK is defined to be USERLIMIT, but in some */
  2678. /* installations that's undefined. We work around this with a */
  2679. /* gross hack: */
  2680. EXTERN_C_END
  2681. # include <sys/vmparam.h>
  2682. EXTERN_C_BEGIN
  2683. # ifdef USERLIMIT
  2684. /* This should work everywhere, but doesn't. */
  2685. # define STACKBOTTOM ((ptr_t)USRSTACK)
  2686. # else
  2687. # define HEURISTIC2
  2688. # endif
  2689. /* At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */
  2690. /* It appears to be fixed in 2.8 and 2.9. */
  2691. # ifdef SOLARIS25_PROC_VDB_BUG_FIXED
  2692. # define PROC_VDB
  2693. # endif
  2694. # ifndef GC_THREADS
  2695. # define MPROTECT_VDB
  2696. # endif
  2697. # define DYNAMIC_LOADING
  2698. # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
  2699. # define USE_MMAP
  2700. /* Otherwise we now use calloc. Mmap may result in the */
  2701. /* heap interleaved with thread stacks, which can result in */
  2702. /* excessive blacklisting. Sbrk is unusable since it */
  2703. /* doesn't interact correctly with the system malloc. */
  2704. # endif
  2705. # ifdef USE_MMAP
  2706. # define HEAP_START (ptr_t)0x40000000
  2707. # else
  2708. # define HEAP_START DATAEND
  2709. # endif
  2710. # endif
  2711. # ifdef CYGWIN32
  2712. # define OS_TYPE "CYGWIN32"
  2713. # define RETRY_GET_THREAD_CONTEXT
  2714. # ifdef USE_WINALLOC
  2715. # define GWW_VDB
  2716. # else
  2717. # if defined(THREAD_LOCAL_ALLOC)
  2718. /* TODO: For an unknown reason, thread-local allocations */
  2719. /* lead to spurious process exit after the fault handler is */
  2720. /* once invoked. */
  2721. # else
  2722. # define MPROTECT_VDB
  2723. # endif
  2724. # ifdef USE_MMAP
  2725. # define USE_MMAP_ANON
  2726. # endif
  2727. # endif
  2728. # endif
  2729. # ifdef MSWIN_XBOX1
  2730. # define NO_GETENV
  2731. # define DATASTART (ptr_t)ALIGNMENT
  2732. # define DATAEND (ptr_t)ALIGNMENT
  2733. LONG64 durango_get_stack_bottom(void);
  2734. # define STACKBOTTOM ((ptr_t)durango_get_stack_bottom())
  2735. # define GETPAGESIZE() 4096
  2736. # ifndef USE_MMAP
  2737. # define USE_MMAP
  2738. # endif
  2739. /* The following is from sys/mman.h: */
  2740. # define PROT_NONE 0
  2741. # define PROT_READ 1
  2742. # define PROT_WRITE 2
  2743. # define PROT_EXEC 4
  2744. # define MAP_PRIVATE 2
  2745. # define MAP_FIXED 0x10
  2746. # define MAP_FAILED ((void *)-1)
  2747. # endif
  2748. # ifdef MSWIN32
  2749. # define OS_TYPE "MSWIN32"
  2750. # define RETRY_GET_THREAD_CONTEXT
  2751. /* STACKBOTTOM and DATASTART are handled specially in */
  2752. /* os_dep.c. */
  2753. # if !defined(__GNUC__) || defined(__INTEL_COMPILER) \
  2754. || GC_GNUC_PREREQ(4, 7)
  2755. /* Older GCC has not supported SetUnhandledExceptionFilter */
  2756. /* properly on x64 (e.g. SEH unwinding information missed). */
  2757. # define MPROTECT_VDB
  2758. # endif
  2759. # define GWW_VDB
  2760. # ifndef DATAEND
  2761. # define DATAEND /* not needed */
  2762. # endif
  2763. # endif
  2764. # endif /* X86_64 */
  2765. # ifdef HEXAGON
  2766. # define CPP_WORDSZ 32
  2767. # define MACH_TYPE "HEXAGON"
  2768. # define ALIGNMENT 4
  2769. # ifdef LINUX
  2770. # define OS_TYPE "LINUX"
  2771. # define LINUX_STACKBOTTOM
  2772. # define MPROTECT_VDB
  2773. # ifdef __ELF__
  2774. # define DYNAMIC_LOADING
  2775. EXTERN_C_END
  2776. # include <features.h>
  2777. EXTERN_C_BEGIN
  2778. # if defined(__GLIBC__) && __GLIBC__ >= 2
  2779. # define SEARCH_FOR_DATA_START
  2780. # else
  2781. # error --> unknown Hexagon libc configuration
  2782. # endif
  2783. extern int _end[];
  2784. # define DATAEND ((ptr_t)(_end))
  2785. # elif !defined(CPPCHECK)
  2786. # error --> bad Hexagon Linux configuration
  2787. # endif
  2788. # else
  2789. # error --> unknown Hexagon OS configuration
  2790. # endif
  2791. # endif
  2792. # ifdef TILEPRO
  2793. # define CPP_WORDSZ 32
  2794. # define MACH_TYPE "TILEPro"
  2795. # define ALIGNMENT 4
  2796. # define PREFETCH(x) __insn_prefetch(x)
  2797. # define CACHE_LINE_SIZE 64
  2798. # ifdef LINUX
  2799. # define OS_TYPE "LINUX"
  2800. extern int __data_start[];
  2801. # define DATASTART ((ptr_t)__data_start)
  2802. # define LINUX_STACKBOTTOM
  2803. # define DYNAMIC_LOADING
  2804. # endif
  2805. # endif
  2806. # ifdef TILEGX
  2807. # define CPP_WORDSZ (__SIZEOF_POINTER__ * 8)
  2808. # define MACH_TYPE "TILE-Gx"
  2809. # define ALIGNMENT __SIZEOF_POINTER__
  2810. # if CPP_WORDSZ < 64
  2811. # define CLEAR_DOUBLE(x) (*(long long *)(x) = 0)
  2812. # endif
  2813. # define PREFETCH(x) __insn_prefetch_l1(x)
  2814. # define CACHE_LINE_SIZE 64
  2815. # ifdef LINUX
  2816. # define OS_TYPE "LINUX"
  2817. extern int __data_start[];
  2818. # define DATASTART ((ptr_t)__data_start)
  2819. # define LINUX_STACKBOTTOM
  2820. # define DYNAMIC_LOADING
  2821. # endif
  2822. # endif
  2823. # ifdef RISCV
  2824. # define MACH_TYPE "RISC-V"
  2825. # define CPP_WORDSZ __riscv_xlen /* 32 or 64 */
  2826. # define ALIGNMENT (CPP_WORDSZ/8)
  2827. # ifdef LINUX
  2828. # define OS_TYPE "LINUX"
  2829. extern int __data_start[];
  2830. # define DATASTART ((ptr_t)__data_start)
  2831. # define LINUX_STACKBOTTOM
  2832. # define DYNAMIC_LOADING
  2833. # endif
  2834. # endif /* RISCV */
  2835. #if defined(__GLIBC__) && !defined(DONT_USE_LIBC_PRIVATES)
  2836. /* Use glibc's stack-end marker. */
  2837. # define USE_LIBC_PRIVATES
  2838. #endif
  2839. #ifdef NO_RETRY_GET_THREAD_CONTEXT
  2840. # undef RETRY_GET_THREAD_CONTEXT
  2841. #endif
  2842. #if defined(LINUX_STACKBOTTOM) && defined(NO_PROC_STAT) \
  2843. && !defined(USE_LIBC_PRIVATES)
  2844. /* This combination will fail, since we have no way to get */
  2845. /* the stack base. Use HEURISTIC2 instead. */
  2846. # undef LINUX_STACKBOTTOM
  2847. # define HEURISTIC2
  2848. /* This may still fail on some architectures like IA64. */
  2849. /* We tried ... */
  2850. #endif
  2851. #if defined(USE_MMAP_ANON) && !defined(USE_MMAP)
  2852. # define USE_MMAP
  2853. #elif defined(LINUX) && defined(USE_MMAP)
  2854. /* The kernel may do a somewhat better job merging mappings etc. */
  2855. /* with anonymous mappings. */
  2856. # define USE_MMAP_ANON
  2857. #endif
  2858. #if defined(GC_LINUX_THREADS) && defined(REDIRECT_MALLOC) \
  2859. && !defined(USE_PROC_FOR_LIBRARIES)
  2860. /* Nptl allocates thread stacks with mmap, which is fine. But it */
  2861. /* keeps a cache of thread stacks. Thread stacks contain the */
  2862. /* thread control blocks. These in turn contain a pointer to */
  2863. /* (sizeof (void *) from the beginning of) the dtv for thread-local */
  2864. /* storage, which is calloc allocated. If we don't scan the cached */
  2865. /* thread stacks, we appear to lose the dtv. This tends to */
  2866. /* result in something that looks like a bogus dtv count, which */
  2867. /* tends to result in a memset call on a block that is way too */
  2868. /* large. Sometimes we're lucky and the process just dies ... */
  2869. /* There seems to be a similar issue with some other memory */
  2870. /* allocated by the dynamic loader. */
  2871. /* This should be avoidable by either: */
  2872. /* - Defining USE_PROC_FOR_LIBRARIES here. */
  2873. /* That performs very poorly, precisely because we end up */
  2874. /* scanning cached stacks. */
  2875. /* - Have calloc look at its callers. */
  2876. /* In spite of the fact that it is gross and disgusting. */
  2877. /* In fact neither seems to suffice, probably in part because */
  2878. /* even with USE_PROC_FOR_LIBRARIES, we don't scan parts of stack */
  2879. /* segments that appear to be out of bounds. Thus we actually */
  2880. /* do both, which seems to yield the best results. */
  2881. # define USE_PROC_FOR_LIBRARIES
  2882. #endif
  2883. #ifndef STACK_GROWS_UP
  2884. # define STACK_GROWS_DOWN
  2885. #endif
  2886. #ifndef CPP_WORDSZ
  2887. # define CPP_WORDSZ 32
  2888. #endif
  2889. #ifndef OS_TYPE
  2890. # define OS_TYPE ""
  2891. #endif
  2892. #ifndef DATAEND
  2893. extern int end[];
  2894. # define DATAEND ((ptr_t)(end))
  2895. #endif
  2896. /* Workaround for Android NDK clang 3.5+ (as of NDK r10e) which does */
  2897. /* not provide correct _end symbol. Unfortunately, alternate __end__ */
  2898. /* symbol is provided only by NDK "bfd" linker. */
  2899. #if defined(HOST_ANDROID) && defined(__clang__)
  2900. # undef DATAEND
  2901. # pragma weak __end__
  2902. extern int __end__[];
  2903. # define DATAEND (__end__ != 0 ? (ptr_t)__end__ : (ptr_t)_end)
  2904. #endif
  2905. #if (defined(SVR4) || defined(HOST_ANDROID) || defined(HOST_TIZEN)) \
  2906. && !defined(GETPAGESIZE)
  2907. EXTERN_C_END
  2908. # include <unistd.h>
  2909. EXTERN_C_BEGIN
  2910. # define GETPAGESIZE() (unsigned)sysconf(_SC_PAGESIZE)
  2911. #endif
  2912. #ifndef GETPAGESIZE
  2913. # if defined(SOLARIS) || defined(IRIX5) || defined(LINUX) \
  2914. || defined(NETBSD) || defined(FREEBSD) || defined(HPUX)
  2915. EXTERN_C_END
  2916. # include <unistd.h>
  2917. EXTERN_C_BEGIN
  2918. # endif
  2919. # define GETPAGESIZE() (unsigned)getpagesize()
  2920. #endif
  2921. #if defined(HOST_ANDROID) && !(__ANDROID_API__ >= 23) \
  2922. && ((defined(MIPS) && (CPP_WORDSZ == 32)) \
  2923. || defined(ARM32) || defined(I386) /* but not x32 */)
  2924. /* tkill() exists only on arm32/mips(32)/x86. */
  2925. /* NDK r11+ deprecates tkill() but keeps it for Mono clients. */
  2926. /* Unity: Android NDK r13 removed this for good. We should not need it. */
  2927. /*# define USE_TKILL_ON_ANDROID*/
  2928. #endif
  2929. #if defined(SOLARIS) || defined(DRSNX) || defined(UTS4)
  2930. /* OS has SVR4 generic features. */
  2931. /* Probably others also qualify. */
  2932. # define SVR4
  2933. #endif
  2934. #if defined(SOLARIS) || defined(DRSNX)
  2935. /* OS has SOLARIS style semi-undocumented interface */
  2936. /* to dynamic loader. */
  2937. # define SOLARISDL
  2938. /* OS has SOLARIS style signal handlers. */
  2939. # define SUNOS5SIGS
  2940. #endif
  2941. #if defined(HPUX)
  2942. # define SUNOS5SIGS
  2943. #endif
  2944. #if defined(FREEBSD) && (defined(__DragonFly__) || __FreeBSD__ >= 4 \
  2945. || (__FreeBSD_kernel__ >= 4))
  2946. # define SUNOS5SIGS
  2947. #endif
  2948. #if !defined(GC_EXPLICIT_SIGNALS_UNBLOCK) && defined(SUNOS5SIGS) \
  2949. && !defined(GC_NO_PTHREAD_SIGMASK)
  2950. # define GC_EXPLICIT_SIGNALS_UNBLOCK
  2951. #endif
  2952. #if !defined(NO_SIGNALS_UNBLOCK_IN_MAIN) && defined(GC_NO_PTHREAD_SIGMASK)
  2953. # define NO_SIGNALS_UNBLOCK_IN_MAIN
  2954. #endif
  2955. #if !defined(NO_MARKER_SPECIAL_SIGMASK) \
  2956. && (defined(NACL) || defined(GC_WIN32_PTHREADS))
  2957. /* Either there is no pthread_sigmask(), or GC marker thread cannot */
  2958. /* steal and drop user signal calls. */
  2959. # define NO_MARKER_SPECIAL_SIGMASK
  2960. #endif
  2961. #ifdef GC_NETBSD_THREADS
  2962. # define SIGRTMIN 33
  2963. # define SIGRTMAX 63
  2964. /* It seems to be necessary to wait until threads have restarted. */
  2965. /* But it is unclear why that is the case. */
  2966. # define GC_NETBSD_THREADS_WORKAROUND
  2967. #endif
  2968. #ifdef GC_OPENBSD_THREADS
  2969. EXTERN_C_END
  2970. # include <sys/param.h>
  2971. EXTERN_C_BEGIN
  2972. /* Prior to 5.2 release, OpenBSD had user threads and required */
  2973. /* special handling. */
  2974. # if OpenBSD < 201211
  2975. # define GC_OPENBSD_UTHREADS 1
  2976. # endif
  2977. #endif /* GC_OPENBSD_THREADS */
  2978. #if defined(SVR4) || defined(LINUX) || defined(IRIX5) || defined(HPUX) \
  2979. || defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD) \
  2980. || defined(DGUX) || defined(BSD) || defined(HAIKU) || defined(HURD) \
  2981. || defined(AIX) || defined(DARWIN) || defined(OSF1) || defined(QNX)
  2982. # define UNIX_LIKE /* Basic Unix-like system calls work. */
  2983. #endif
  2984. #if defined(CPPCHECK)
  2985. # undef CPP_WORDSZ
  2986. # define CPP_WORDSZ (__SIZEOF_POINTER__ * 8)
  2987. #endif
  2988. #if CPP_WORDSZ != 32 && CPP_WORDSZ != 64
  2989. # error --> bad word size
  2990. #endif
  2991. #if !defined(ALIGNMENT) && !defined(CPPCHECK)
  2992. # error --> undefined ALIGNMENT
  2993. #endif
  2994. #ifdef PCR
  2995. # undef DYNAMIC_LOADING
  2996. # undef STACKBOTTOM
  2997. # undef HEURISTIC1
  2998. # undef HEURISTIC2
  2999. # undef PROC_VDB
  3000. # undef MPROTECT_VDB
  3001. # define PCR_VDB
  3002. #endif
  3003. #if !defined(STACKBOTTOM) && (defined(ECOS) || defined(NOSYS)) \
  3004. && !defined(CPPCHECK)
  3005. # error --> undefined STACKBOTTOM
  3006. #endif
  3007. #ifdef IGNORE_DYNAMIC_LOADING
  3008. # undef DYNAMIC_LOADING
  3009. #endif
  3010. #if defined(SMALL_CONFIG) && !defined(GC_DISABLE_INCREMENTAL)
  3011. /* Presumably not worth the space it takes. */
  3012. # define GC_DISABLE_INCREMENTAL
  3013. #endif
  3014. #if (defined(MSWIN32) || defined(MSWINCE)) && !defined(USE_WINALLOC)
  3015. /* USE_WINALLOC is only an option for Cygwin. */
  3016. # define USE_WINALLOC
  3017. #endif
  3018. #ifdef USE_WINALLOC
  3019. # undef USE_MMAP
  3020. #endif
  3021. #if defined(LINUX) || defined(FREEBSD) || defined(SOLARIS) || defined(IRIX5) \
  3022. || ((defined(USE_MMAP) || defined(USE_MUNMAP)) && !defined(USE_WINALLOC))
  3023. # define MMAP_SUPPORTED
  3024. #endif
  3025. /* Xbox One (DURANGO) may not need to be this aggressive, but the */
  3026. /* default is likely too lax under heavy allocation pressure. */
  3027. /* The platform does not have a virtual paging system, so it does not */
  3028. /* have a large virtual address space that a standard x64 platform has. */
  3029. #if defined(USE_MUNMAP) && !defined(MUNMAP_THRESHOLD) \
  3030. && (defined(SN_TARGET_PS3) \
  3031. || defined(SN_TARGET_PSP2) || defined(MSWIN_XBOX1))
  3032. # define MUNMAP_THRESHOLD 2
  3033. #endif
  3034. #if defined(GC_DISABLE_INCREMENTAL) || defined(DEFAULT_VDB) \
  3035. || defined(MANUAL_VDB)
  3036. # undef GWW_VDB
  3037. # undef MPROTECT_VDB
  3038. # undef PCR_VDB
  3039. # undef PROC_VDB
  3040. #endif
  3041. #ifdef GC_DISABLE_INCREMENTAL
  3042. # undef CHECKSUMS
  3043. #endif
  3044. #ifdef USE_GLOBAL_ALLOC
  3045. /* Cannot pass MEM_WRITE_WATCH to GlobalAlloc(). */
  3046. # undef GWW_VDB
  3047. #endif
  3048. #if defined(USE_MUNMAP) && defined(GWW_VDB)
  3049. # undef MPROTECT_VDB /* TODO: Cannot deal with address space holes. */
  3050. /* Else if MPROTECT_VDB is available but not GWW_VDB then decide */
  3051. /* whether to disable memory unmapping or mprotect-based virtual */
  3052. /* dirty bits at runtime when GC_enable_incremental is called. */
  3053. #endif
  3054. /* PARALLEL_MARK does not cause undef MPROTECT_VDB any longer. */
  3055. #if defined(MPROTECT_VDB) && defined(GC_PREFER_MPROTECT_VDB)
  3056. /* Choose MPROTECT_VDB manually (if multiple strategies available). */
  3057. # undef PCR_VDB
  3058. # undef PROC_VDB
  3059. /* #undef GWW_VDB - handled in os_dep.c */
  3060. #endif
  3061. #ifdef PROC_VDB
  3062. /* Multi-VDB mode is not implemented. */
  3063. # undef MPROTECT_VDB
  3064. #endif
  3065. #if defined(SIGBUS) && !defined(HAVE_SIGBUS) && !defined(CPPCHECK)
  3066. # define HAVE_SIGBUS
  3067. #endif
  3068. #ifndef SA_SIGINFO
  3069. # define NO_SA_SIGACTION
  3070. #endif
  3071. #if defined(NO_SA_SIGACTION) && defined(MPROTECT_VDB) && !defined(DARWIN) \
  3072. && !defined(MSWIN32) && !defined(MSWINCE)
  3073. # undef MPROTECT_VDB
  3074. #endif
  3075. #if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB) \
  3076. && !defined(GWW_VDB) && !defined(DEFAULT_VDB) && !defined(MANUAL_VDB) \
  3077. && !defined(GC_DISABLE_INCREMENTAL)
  3078. # define DEFAULT_VDB
  3079. #endif
  3080. #if ((defined(UNIX_LIKE) && (defined(DARWIN) || defined(HAIKU) \
  3081. || defined(HURD) || defined(OPENBSD) \
  3082. || defined(ARM32) || defined(QNX) \
  3083. || defined(AVR32) || defined(MIPS) \
  3084. || defined(NIOS2) || defined(OR1K))) \
  3085. || (defined(LINUX) && !defined(__gnu_linux__)) \
  3086. || (defined(RTEMS) && defined(I386)) || defined(HOST_ANDROID)) \
  3087. && !defined(NO_GETCONTEXT)
  3088. # define NO_GETCONTEXT
  3089. #endif
  3090. #ifndef PREFETCH
  3091. # if GC_GNUC_PREREQ(3, 0) && !defined(NO_PREFETCH)
  3092. # define PREFETCH(x) __builtin_prefetch((x), 0, 0)
  3093. # else
  3094. # define PREFETCH(x) (void)0
  3095. # endif
  3096. #endif
  3097. #ifndef GC_PREFETCH_FOR_WRITE
  3098. # if GC_GNUC_PREREQ(3, 0) && !defined(GC_NO_PREFETCH_FOR_WRITE)
  3099. # define GC_PREFETCH_FOR_WRITE(x) __builtin_prefetch((x), 1)
  3100. # else
  3101. # define GC_PREFETCH_FOR_WRITE(x) (void)0
  3102. # endif
  3103. #endif
  3104. #ifndef CACHE_LINE_SIZE
  3105. # define CACHE_LINE_SIZE 32 /* Wild guess */
  3106. #endif
  3107. #ifndef STATIC
  3108. # ifndef NO_DEBUGGING
  3109. # define STATIC /* ignore to aid profiling and possibly debugging */
  3110. # else
  3111. # define STATIC static
  3112. # endif
  3113. #endif
  3114. #if defined(LINUX) && (defined(USE_PROC_FOR_LIBRARIES) || defined(IA64) \
  3115. || !defined(SMALL_CONFIG))
  3116. # define NEED_PROC_MAPS
  3117. #endif
  3118. #if defined(LINUX) || defined(HURD) || defined(__GLIBC__)
  3119. # define REGISTER_LIBRARIES_EARLY
  3120. /* We sometimes use dl_iterate_phdr, which may acquire an internal */
  3121. /* lock. This isn't safe after the world has stopped. So we must */
  3122. /* call GC_register_dynamic_libraries before stopping the world. */
  3123. /* For performance reasons, this may be beneficial on other */
  3124. /* platforms as well, though it should be avoided in win32. */
  3125. #endif /* LINUX */
  3126. #if defined(SEARCH_FOR_DATA_START)
  3127. extern ptr_t GC_data_start;
  3128. # define DATASTART GC_data_start
  3129. #endif
  3130. #ifndef HEAP_START
  3131. # define HEAP_START ((ptr_t)0)
  3132. #endif
  3133. #ifndef CLEAR_DOUBLE
  3134. # define CLEAR_DOUBLE(x) (((word*)(x))[0] = 0, ((word*)(x))[1] = 0)
  3135. #endif
  3136. #if defined(GC_LINUX_THREADS) && defined(REDIRECT_MALLOC) \
  3137. && !defined(INCLUDE_LINUX_THREAD_DESCR)
  3138. /* Will not work, since libc and the dynamic loader use thread */
  3139. /* locals, sometimes as the only reference. */
  3140. # define INCLUDE_LINUX_THREAD_DESCR
  3141. #endif
  3142. #if !defined(CPPCHECK)
  3143. #if defined(GC_IRIX_THREADS) && !defined(IRIX5)
  3144. # error --> inconsistent configuration
  3145. #endif
  3146. #if defined(GC_LINUX_THREADS) && !defined(LINUX) && !defined(NACL)
  3147. # error --> inconsistent configuration
  3148. #endif
  3149. #if defined(GC_NETBSD_THREADS) && !defined(NETBSD)
  3150. # error --> inconsistent configuration
  3151. #endif
  3152. #if defined(GC_FREEBSD_THREADS) && !defined(FREEBSD)
  3153. # error --> inconsistent configuration
  3154. #endif
  3155. #if defined(GC_SOLARIS_THREADS) && !defined(SOLARIS)
  3156. # error --> inconsistent configuration
  3157. #endif
  3158. #if defined(GC_HPUX_THREADS) && !defined(HPUX)
  3159. # error --> inconsistent configuration
  3160. #endif
  3161. #if defined(GC_AIX_THREADS) && !defined(_AIX)
  3162. # error --> inconsistent configuration
  3163. #endif
  3164. #if defined(GC_WIN32_THREADS) && !defined(CYGWIN32) && !defined(MSWIN32) \
  3165. && !defined(MSWINCE) && !defined(MSWIN_XBOX1)
  3166. # error --> inconsistent configuration
  3167. #endif
  3168. # if defined(GC_WIN32_PTHREADS) && defined(CYGWIN32)
  3169. # error --> inconsistent configuration
  3170. # endif
  3171. #endif /* !CPPCHECK */
  3172. #if defined(PCR) || defined(GC_WIN32_THREADS) || defined(GC_PTHREADS) \
  3173. || defined(NN_PLATFORM_CTR) || defined(NINTENDO_SWITCH) \
  3174. || defined(SN_TARGET_PS3) \
  3175. || defined(SN_TARGET_PSP2)
  3176. #if !defined(THREADS)
  3177. # define THREADS
  3178. #endif
  3179. #endif
  3180. #if defined(PARALLEL_MARK) && !defined(THREADS) && !defined(CPPCHECK)
  3181. # error "invalid config - PARALLEL_MARK requires GC_THREADS"
  3182. #endif
  3183. #if (((defined(MSWIN32) || defined(MSWINCE)) && !defined(__GNUC__)) \
  3184. || (defined(MSWIN32) && defined(I386)) /* for Win98 */ \
  3185. || (defined(USE_PROC_FOR_LIBRARIES) && defined(THREADS))) \
  3186. && !defined(NO_WRAP_MARK_SOME)
  3187. /* Under rare conditions, we may end up marking from nonexistent */
  3188. /* memory. Hence we need to be prepared to recover by running */
  3189. /* GC_mark_some with a suitable handler in place. */
  3190. /* TODO: Probably replace __GNUC__ above with ndef GC_PTHREADS. */
  3191. /* FIXME: Should we really need it for WinCE? If yes then */
  3192. /* WRAP_MARK_SOME should be also defined for CeGCC which requires */
  3193. /* CPU/OS-specific code in mark_ex_handler and GC_mark_some (for */
  3194. /* manual stack unwinding and exception handler installation). */
  3195. # define WRAP_MARK_SOME
  3196. #endif
  3197. #if defined(PARALLEL_MARK) && !defined(DEFAULT_STACK_MAYBE_SMALL) \
  3198. && (defined(HPUX) || defined(GC_DGUX386_THREADS) \
  3199. || defined(NO_GETCONTEXT) /* e.g. musl */)
  3200. /* TODO: Test default stack size in configure. */
  3201. # define DEFAULT_STACK_MAYBE_SMALL
  3202. #endif
  3203. #ifdef PARALLEL_MARK
  3204. /* The minimum stack size for a marker thread. */
  3205. # define MIN_STACK_SIZE (8 * HBLKSIZE * sizeof(word))
  3206. #endif
  3207. #if defined(HOST_ANDROID) && !defined(THREADS) \
  3208. && !defined(USE_GET_STACKBASE_FOR_MAIN)
  3209. /* Always use pthread_attr_getstack on Android ("-lpthread" option is */
  3210. /* not needed to be specified manually) since GC_linux_main_stack_base */
  3211. /* causes app crash if invoked inside Dalvik VM. */
  3212. # define USE_GET_STACKBASE_FOR_MAIN
  3213. #endif
  3214. /* Outline pthread primitives to use in GC_get_[main_]stack_base. */
  3215. #if ((defined(FREEBSD) && defined(__GLIBC__)) /* kFreeBSD */ \
  3216. || defined(LINUX) || defined(NETBSD) || defined(HOST_ANDROID)) \
  3217. && !defined(NO_PTHREAD_GETATTR_NP)
  3218. # define HAVE_PTHREAD_GETATTR_NP 1
  3219. #elif defined(FREEBSD) && !defined(__GLIBC__) \
  3220. && !defined(NO_PTHREAD_ATTR_GET_NP)
  3221. # define HAVE_PTHREAD_NP_H 1 /* requires include pthread_np.h */
  3222. # define HAVE_PTHREAD_ATTR_GET_NP 1
  3223. #endif
  3224. #if defined(UNIX_LIKE) && defined(THREADS) && !defined(NO_CANCEL_SAFE) \
  3225. && !defined(HOST_ANDROID)
  3226. /* Make the code cancellation-safe. This basically means that we */
  3227. /* ensure that cancellation requests are ignored while we are in */
  3228. /* the collector. This applies only to Posix deferred cancellation; */
  3229. /* we don't handle Posix asynchronous cancellation. */
  3230. /* Note that this only works if pthread_setcancelstate is */
  3231. /* async-signal-safe, at least in the absence of asynchronous */
  3232. /* cancellation. This appears to be true for the glibc version, */
  3233. /* though it is not documented. Without that assumption, there */
  3234. /* seems to be no way to safely wait in a signal handler, which */
  3235. /* we need to do for thread suspension. */
  3236. /* Also note that little other code appears to be cancellation-safe. */
  3237. /* Hence it may make sense to turn this off for performance. */
  3238. # define CANCEL_SAFE
  3239. #endif
  3240. #ifdef CANCEL_SAFE
  3241. # define IF_CANCEL(x) x
  3242. #else
  3243. # define IF_CANCEL(x) /* empty */
  3244. #endif
  3245. #if !defined(CAN_HANDLE_FORK) && !defined(NO_HANDLE_FORK) \
  3246. && !defined(HAVE_NO_FORK) \
  3247. && ((defined(GC_PTHREADS) && !defined(NACL) \
  3248. && !defined(GC_WIN32_PTHREADS) && !defined(USE_WINALLOC)) \
  3249. || (defined(DARWIN) && defined(MPROTECT_VDB)) || defined(HANDLE_FORK))
  3250. /* Attempts (where supported and requested) to make GC_malloc work in */
  3251. /* a child process fork'ed from a multi-threaded parent. */
  3252. # define CAN_HANDLE_FORK
  3253. #endif
  3254. #if defined(CAN_HANDLE_FORK) && !defined(CAN_CALL_ATFORK) \
  3255. && !defined(HURD) && !defined(GC_NO_CAN_CALL_ATFORK) && !defined(HOST_TIZEN) \
  3256. && (!defined(HOST_ANDROID) || __ANDROID_API__ >= 21)
  3257. /* Have working pthread_atfork(). */
  3258. # define CAN_CALL_ATFORK
  3259. #endif
  3260. #if !defined(CAN_HANDLE_FORK) && !defined(HAVE_NO_FORK) \
  3261. && (defined(MSWIN32) || defined(MSWINCE) || defined(DOS4GW) \
  3262. || defined(OS2) || defined(SYMBIAN) /* and probably others ... */)
  3263. # define HAVE_NO_FORK
  3264. #endif
  3265. #if !defined(USE_MARK_BITS) && !defined(USE_MARK_BYTES) \
  3266. && defined(PARALLEL_MARK)
  3267. /* Minimize compare-and-swap usage. */
  3268. # define USE_MARK_BYTES
  3269. #endif
  3270. #if (defined(MSWINCE) && !defined(__CEGCC__) || defined(MSWINRT_FLAVOR)) \
  3271. && !defined(NO_GETENV)
  3272. # define NO_GETENV
  3273. #endif
  3274. #if (defined(NO_GETENV) || defined(MSWINCE)) && !defined(NO_GETENV_WIN32)
  3275. # define NO_GETENV_WIN32
  3276. #endif
  3277. #ifndef STRTOULL
  3278. # if defined(_WIN64) && !defined(__GNUC__)
  3279. # define STRTOULL _strtoui64
  3280. # elif defined(_LLP64) || defined(__LLP64__) || defined(_WIN64)
  3281. # define STRTOULL strtoull
  3282. # else
  3283. /* strtoul() fits since sizeof(long) >= sizeof(word). */
  3284. # define STRTOULL strtoul
  3285. # endif
  3286. #endif /* !STRTOULL */
  3287. #ifndef GC_WORD_C
  3288. # if defined(_WIN64) && !defined(__GNUC__)
  3289. # define GC_WORD_C(val) val##ui64
  3290. # elif defined(_LLP64) || defined(__LLP64__) || defined(_WIN64)
  3291. # define GC_WORD_C(val) val##ULL
  3292. # else
  3293. # define GC_WORD_C(val) ((word)val##UL)
  3294. # endif
  3295. #endif /* !GC_WORD_C */
  3296. #if defined(__has_feature)
  3297. /* __has_feature() is supported. */
  3298. # if __has_feature(address_sanitizer) && !defined(ADDRESS_SANITIZER)
  3299. # define ADDRESS_SANITIZER
  3300. # endif
  3301. # if __has_feature(memory_sanitizer) && !defined(MEMORY_SANITIZER)
  3302. # define MEMORY_SANITIZER
  3303. # endif
  3304. # if __has_feature(thread_sanitizer) && !defined(THREAD_SANITIZER)
  3305. # define THREAD_SANITIZER
  3306. # endif
  3307. #else
  3308. # ifdef __SANITIZE_ADDRESS__
  3309. /* GCC v4.8+ */
  3310. # define ADDRESS_SANITIZER
  3311. # endif
  3312. #endif /* !__has_feature */
  3313. #if defined(SPARC)
  3314. # define ASM_CLEAR_CODE /* Stack clearing is crucial, and we */
  3315. /* include assembly code to do it well. */
  3316. #endif
  3317. /* Can we save call chain in objects for debugging? */
  3318. /* SET NFRAMES (# of saved frames) and NARGS (#of args for each */
  3319. /* frame) to reasonable values for the platform. */
  3320. /* Set SAVE_CALL_CHAIN if we can. SAVE_CALL_COUNT can be specified */
  3321. /* at build time, though we feel free to adjust it slightly. */
  3322. /* Define NEED_CALLINFO if we either save the call stack or */
  3323. /* GC_ADD_CALLER is defined. */
  3324. /* GC_CAN_SAVE_CALL_STACKS is set in gc.h. */
  3325. #if defined(SPARC)
  3326. # define CAN_SAVE_CALL_ARGS
  3327. #endif
  3328. #if (defined(I386) || defined(X86_64)) \
  3329. && (defined(LINUX) || defined(__GLIBC__))
  3330. /* SAVE_CALL_CHAIN is supported if the code is compiled to save */
  3331. /* frame pointers by default, i.e. no -fomit-frame-pointer flag. */
  3332. # define CAN_SAVE_CALL_ARGS
  3333. #endif
  3334. #if defined(SAVE_CALL_COUNT) && !defined(GC_ADD_CALLER) \
  3335. && defined(GC_CAN_SAVE_CALL_STACKS)
  3336. # define SAVE_CALL_CHAIN
  3337. #endif
  3338. #ifdef SAVE_CALL_CHAIN
  3339. # if defined(SAVE_CALL_NARGS) && defined(CAN_SAVE_CALL_ARGS)
  3340. # define NARGS SAVE_CALL_NARGS
  3341. # else
  3342. # define NARGS 0 /* Number of arguments to save for each call. */
  3343. # endif
  3344. #endif
  3345. #ifdef SAVE_CALL_CHAIN
  3346. # if !defined(SAVE_CALL_COUNT) || defined(CPPCHECK)
  3347. # define NFRAMES 6 /* Number of frames to save. Even for */
  3348. /* alignment reasons. */
  3349. # else
  3350. # define NFRAMES ((SAVE_CALL_COUNT + 1) & ~1)
  3351. # endif
  3352. # define NEED_CALLINFO
  3353. #endif /* SAVE_CALL_CHAIN */
  3354. #ifdef GC_ADD_CALLER
  3355. # define NFRAMES 1
  3356. # define NARGS 0
  3357. # define NEED_CALLINFO
  3358. #endif
  3359. #if (defined(FREEBSD) || (defined(DARWIN) && !defined(_POSIX_C_SOURCE)) \
  3360. || (defined(SOLARIS) && (!defined(_XOPEN_SOURCE) \
  3361. || defined(__EXTENSIONS__))) \
  3362. || defined(LINUX)) && !defined(HAVE_DLADDR)
  3363. # define HAVE_DLADDR
  3364. #endif
  3365. #if defined(MAKE_BACK_GRAPH) && !defined(DBG_HDRS_ALL)
  3366. # define DBG_HDRS_ALL
  3367. #endif
  3368. #if defined(POINTER_MASK) && !defined(POINTER_SHIFT)
  3369. # define POINTER_SHIFT 0
  3370. #endif
  3371. #if defined(POINTER_SHIFT) && !defined(POINTER_MASK)
  3372. # define POINTER_MASK ((word)(-1))
  3373. #endif
  3374. #if !defined(FIXUP_POINTER) && defined(POINTER_MASK)
  3375. # if defined(CPPCHECK)
  3376. # define FIXUP_POINTER(p) (p = (p) << 4) /* e.g. */
  3377. # else
  3378. # define FIXUP_POINTER(p) (p = ((p) & POINTER_MASK) << POINTER_SHIFT)
  3379. # endif
  3380. #endif
  3381. #if defined(FIXUP_POINTER)
  3382. # define NEED_FIXUP_POINTER
  3383. #else
  3384. # define FIXUP_POINTER(p)
  3385. #endif
  3386. #if !defined(MARK_BIT_PER_GRANULE) && !defined(MARK_BIT_PER_OBJ)
  3387. # define MARK_BIT_PER_GRANULE /* Usually faster */
  3388. #endif
  3389. /* Some static sanity tests. */
  3390. #if !defined(CPPCHECK)
  3391. #if defined(MARK_BIT_PER_GRANULE) && defined(MARK_BIT_PER_OBJ)
  3392. # error Define only one of MARK_BIT_PER_GRANULE and MARK_BIT_PER_OBJ.
  3393. #endif
  3394. #if defined(STACK_GROWS_UP) && defined(STACK_GROWS_DOWN)
  3395. # error "Only one of STACK_GROWS_UP and STACK_GROWS_DOWN should be defd."
  3396. #endif
  3397. #if !defined(STACK_GROWS_UP) && !defined(STACK_GROWS_DOWN)
  3398. # error "One of STACK_GROWS_UP and STACK_GROWS_DOWN should be defd."
  3399. #endif
  3400. #if defined(REDIRECT_MALLOC) && defined(THREADS) && !defined(LINUX) \
  3401. && !defined(REDIRECT_MALLOC_IN_HEADER)
  3402. # error "REDIRECT_MALLOC with THREADS works at most on Linux."
  3403. #endif
  3404. #endif /* !CPPCHECK */
  3405. #ifdef GC_PRIVATE_H
  3406. /* This relies on some type definitions from gc_priv.h, from */
  3407. /* where it's normally included. */
  3408. /* */
  3409. /* How to get heap memory from the OS: */
  3410. /* Note that sbrk()-like allocation is preferred, since it */
  3411. /* usually makes it possible to merge consecutively allocated */
  3412. /* chunks. It also avoids unintended recursion with */
  3413. /* REDIRECT_MALLOC macro defined. */
  3414. /* GET_MEM() argument should be of size_t type and have */
  3415. /* no side-effect. GET_MEM() returns HBLKSIZE-aligned chunk; */
  3416. /* 0 is taken to mean failure. */
  3417. /* In case of MMAP_SUPPORTED, the argument must also be */
  3418. /* a multiple of a physical page size. */
  3419. /* GET_MEM is currently not assumed to retrieve 0 filled space, */
  3420. /* though we should perhaps take advantage of the case in which */
  3421. /* does. */
  3422. struct hblk; /* See gc_priv.h. */
  3423. # if defined(PCR)
  3424. char * real_malloc(size_t bytes);
  3425. # define GET_MEM(bytes) HBLKPTR(real_malloc(SIZET_SAT_ADD(bytes, \
  3426. GC_page_size)) \
  3427. + GC_page_size-1)
  3428. # elif defined(OS2)
  3429. void * os2_alloc(size_t bytes);
  3430. # define GET_MEM(bytes) HBLKPTR((ptr_t)os2_alloc( \
  3431. SIZET_SAT_ADD(bytes, \
  3432. GC_page_size)) \
  3433. + GC_page_size-1)
  3434. # elif defined(NEXT) || defined(DOS4GW) || defined(NONSTOP) \
  3435. || (defined(AMIGA) && !defined(GC_AMIGA_FASTALLOC)) \
  3436. || (defined(SOLARIS) && !defined(USE_MMAP)) || defined(RTEMS) \
  3437. || defined(__CC_ARM)
  3438. # define GET_MEM(bytes) HBLKPTR((size_t)calloc(1, \
  3439. SIZET_SAT_ADD(bytes, \
  3440. GC_page_size)) \
  3441. + GC_page_size - 1)
  3442. # elif defined(MSWIN_XBOX1)
  3443. void *durango_get_mem(size_t bytes, size_t page_size);
  3444. # define GET_MEM(bytes) (struct hblk *)durango_get_mem(bytes, 0)
  3445. # elif defined(MSWIN32) || defined(CYGWIN32)
  3446. ptr_t GC_win32_get_mem(size_t bytes);
  3447. # define GET_MEM(bytes) (struct hblk *)GC_win32_get_mem(bytes)
  3448. # elif defined(MACOS)
  3449. # if defined(USE_TEMPORARY_MEMORY)
  3450. Ptr GC_MacTemporaryNewPtr(size_t size, Boolean clearMemory);
  3451. # define GET_MEM(bytes) HBLKPTR(GC_MacTemporaryNewPtr( \
  3452. SIZET_SAT_ADD(bytes, \
  3453. GC_page_size), true) \
  3454. + GC_page_size-1)
  3455. # else
  3456. # define GET_MEM(bytes) HBLKPTR(NewPtrClear(SIZET_SAT_ADD(bytes, \
  3457. GC_page_size)) \
  3458. + GC_page_size-1)
  3459. # endif
  3460. # elif defined(MSWINCE)
  3461. ptr_t GC_wince_get_mem(size_t bytes);
  3462. # define GET_MEM(bytes) (struct hblk *)GC_wince_get_mem(bytes)
  3463. # elif defined(AMIGA) && defined(GC_AMIGA_FASTALLOC)
  3464. void *GC_amiga_get_mem(size_t bytes);
  3465. # define GET_MEM(bytes) HBLKPTR((size_t)GC_amiga_get_mem( \
  3466. SIZET_SAT_ADD(bytes, \
  3467. GC_page_size)) \
  3468. + GC_page_size-1)
  3469. # elif defined(PLATFORM_GETMEM)
  3470. void *platform_get_mem(size_t bytes);
  3471. # define GET_MEM(bytes) (struct hblk*)platform_get_mem(bytes)
  3472. # elif defined(SN_TARGET_PS3)
  3473. void *ps3_get_mem(size_t bytes);
  3474. # define GET_MEM(bytes) (struct hblk*)ps3_get_mem(bytes)
  3475. # elif defined(SN_TARGET_PSP2)
  3476. void *psp2_get_mem(size_t bytes);
  3477. # define GET_MEM(bytes) (struct hblk*)psp2_get_mem(bytes)
  3478. # elif defined(NINTENDO_SWITCH)
  3479. void *switch_get_mem(size_t bytes);
  3480. # define GET_MEM(bytes) (struct hblk*)switch_get_mem(bytes)
  3481. # elif defined(HAIKU)
  3482. ptr_t GC_haiku_get_mem(size_t bytes);
  3483. # define GET_MEM(bytes) (struct hblk*)GC_haiku_get_mem(bytes)
  3484. # elif defined(EMSCRIPTEN_TINY)
  3485. void *emmalloc_memalign(size_t alignment, size_t size);
  3486. # define GET_MEM(bytes) (struct hblk*)emmalloc_memalign(GC_page_size, bytes)
  3487. # else
  3488. ptr_t GC_unix_get_mem(size_t bytes);
  3489. # define GET_MEM(bytes) (struct hblk *)GC_unix_get_mem(bytes)
  3490. # endif
  3491. #endif /* GC_PRIVATE_H */
  3492. EXTERN_C_END
  3493. #ifndef SMALL_CONFIG
  3494. /* We were running out of memory due to the fact that
  3495. * GC has a static sized array for heap segments, and without
  3496. * LARGE_CONFIG you go OOM at around 1.8 GB on 64-bit.
  3497. * Note, we define it everywhere on Mono. */
  3498. #define LARGE_CONFIG
  3499. #endif
  3500. #endif /* GCCONFIG_H */