gcconfig.h 122 KB

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