duk_config.h 121 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680
  1. /*
  2. * duk_config.h configuration header generated by genconfig.py.
  3. *
  4. * Git commit: a459cf3c9bd1779fc01b435d69302b742675a08f
  5. * Git describe: v2.2.0
  6. * Git branch: master
  7. *
  8. * Supported platforms:
  9. * - Mac OSX, iPhone, Darwin
  10. * - Orbis
  11. * - OpenBSD
  12. * - Generic BSD
  13. * - Atari ST TOS
  14. * - AmigaOS
  15. * - Durango (XboxOne)
  16. * - Windows
  17. * - Flashplayer (Crossbridge)
  18. * - QNX
  19. * - TI-Nspire
  20. * - Emscripten
  21. * - Linux
  22. * - Solaris
  23. * - AIX
  24. * - HPUX
  25. * - Generic POSIX
  26. * - Cygwin
  27. * - Generic UNIX
  28. * - Generic fallback
  29. *
  30. * Supported architectures:
  31. * - x86
  32. * - x64
  33. * - x32
  34. * - ARM 32-bit
  35. * - ARM 64-bit
  36. * - MIPS 32-bit
  37. * - MIPS 64-bit
  38. * - PowerPC 32-bit
  39. * - PowerPC 64-bit
  40. * - SPARC 32-bit
  41. * - SPARC 64-bit
  42. * - SuperH
  43. * - Motorola 68k
  44. * - Emscripten
  45. * - Generic
  46. *
  47. * Supported compilers:
  48. * - Clang
  49. * - GCC
  50. * - MSVC
  51. * - Emscripten
  52. * - TinyC
  53. * - VBCC
  54. * - Bruce's C compiler
  55. * - Generic
  56. *
  57. */
  58. #if !defined(DUK_CONFIG_H_INCLUDED)
  59. #define DUK_CONFIG_H_INCLUDED
  60. /*
  61. * Intermediate helper defines
  62. */
  63. /* DLL build detection */
  64. /* not configured for DLL build */
  65. #undef DUK_F_DLL_BUILD
  66. /* Apple OSX, iOS */
  67. #if defined(__APPLE__)
  68. #define DUK_F_APPLE
  69. #endif
  70. /* FreeBSD */
  71. #if defined(__FreeBSD__) || defined(__FreeBSD)
  72. #define DUK_F_FREEBSD
  73. #endif
  74. /* Orbis (PS4) variant */
  75. #if defined(DUK_F_FREEBSD) && defined(__ORBIS__)
  76. #define DUK_F_ORBIS
  77. #endif
  78. /* OpenBSD */
  79. #if defined(__OpenBSD__) || defined(__OpenBSD)
  80. #define DUK_F_OPENBSD
  81. #endif
  82. /* NetBSD */
  83. #if defined(__NetBSD__) || defined(__NetBSD)
  84. #define DUK_F_NETBSD
  85. #endif
  86. /* BSD variant */
  87. #if defined(DUK_F_FREEBSD) || defined(DUK_F_NETBSD) || defined(DUK_F_OPENBSD) || \
  88. defined(__bsdi__) || defined(__DragonFly__)
  89. #define DUK_F_BSD
  90. #endif
  91. /* Atari ST TOS. __TOS__ defined by PureC. No platform define in VBCC
  92. * apparently, so to use with VBCC user must define __TOS__ manually.
  93. */
  94. #if defined(__TOS__)
  95. #define DUK_F_TOS
  96. #endif
  97. /* Motorola 68K. Not defined by VBCC, so user must define one of these
  98. * manually when using VBCC.
  99. */
  100. #if defined(__m68k__) || defined(M68000) || defined(__MC68K__)
  101. #define DUK_F_M68K
  102. #endif
  103. /* AmigaOS. Neither AMIGA nor __amigaos__ is defined on VBCC, so user must
  104. * define 'AMIGA' manually when using VBCC.
  105. */
  106. #if defined(AMIGA) || defined(__amigaos__)
  107. #define DUK_F_AMIGAOS
  108. #endif
  109. /* PowerPC */
  110. #if defined(__powerpc) || defined(__powerpc__) || defined(__PPC__)
  111. #define DUK_F_PPC
  112. #if defined(__PPC64__) || defined(__LP64__) || defined(_LP64)
  113. #define DUK_F_PPC64
  114. #else
  115. #define DUK_F_PPC32
  116. #endif
  117. #endif
  118. /* Durango (Xbox One) */
  119. #if defined(_DURANGO) || defined(_XBOX_ONE)
  120. #define DUK_F_DURANGO
  121. #endif
  122. /* Windows, both 32-bit and 64-bit */
  123. #if defined(_WIN32) || defined(WIN32) || defined(_WIN64) || defined(WIN64) || \
  124. defined(__WIN32__) || defined(__TOS_WIN__) || defined(__WINDOWS__)
  125. #define DUK_F_WINDOWS
  126. #if defined(_WIN64) || defined(WIN64)
  127. #define DUK_F_WIN64
  128. #else
  129. #define DUK_F_WIN32
  130. #endif
  131. #endif
  132. /* Flash player (e.g. Crossbridge) */
  133. #if defined(__FLASHPLAYER__)
  134. #define DUK_F_FLASHPLAYER
  135. #endif
  136. /* QNX */
  137. #if defined(__QNX__)
  138. #define DUK_F_QNX
  139. #endif
  140. /* TI-Nspire (using Ndless) */
  141. #if defined(_TINSPIRE)
  142. #define DUK_F_TINSPIRE
  143. #endif
  144. /* Emscripten (provided explicitly by user), improve if possible */
  145. #if defined(EMSCRIPTEN)
  146. #define DUK_F_EMSCRIPTEN
  147. #endif
  148. /* BCC (Bruce's C compiler): this is a "torture target" for compilation */
  149. #if defined(__BCC__) || defined(__BCC_VERSION__)
  150. #define DUK_F_BCC
  151. #endif
  152. /* Linux */
  153. #if defined(__linux) || defined(__linux__) || defined(linux)
  154. #define DUK_F_LINUX
  155. #endif
  156. /* illumos / Solaris */
  157. #if defined(__sun) && defined(__SVR4)
  158. #define DUK_F_SUN
  159. #if defined(__SUNPRO_C) && (__SUNPRO_C < 0x550)
  160. #define DUK_F_OLD_SOLARIS
  161. /* Defines _ILP32 / _LP64 required by DUK_F_X86/DUK_F_X64. Platforms
  162. * are processed before architectures, so this happens before the
  163. * DUK_F_X86/DUK_F_X64 detection is emitted.
  164. */
  165. #include <sys/isa_defs.h>
  166. #endif
  167. #endif
  168. /* AIX */
  169. #if defined(_AIX)
  170. /* defined(__xlc__) || defined(__IBMC__): works but too wide */
  171. #define DUK_F_AIX
  172. #endif
  173. /* HPUX */
  174. #if defined(__hpux)
  175. #define DUK_F_HPUX
  176. #if defined(__ia64)
  177. #define DUK_F_HPUX_ITANIUM
  178. #endif
  179. #endif
  180. /* POSIX */
  181. #if defined(__posix)
  182. #define DUK_F_POSIX
  183. #endif
  184. /* Cygwin */
  185. #if defined(__CYGWIN__)
  186. #define DUK_F_CYGWIN
  187. #endif
  188. /* Generic Unix (includes Cygwin) */
  189. #if defined(__unix) || defined(__unix__) || defined(unix) || \
  190. defined(DUK_F_LINUX) || defined(DUK_F_BSD)
  191. #define DUK_F_UNIX
  192. #endif
  193. /* C++ */
  194. #undef DUK_F_CPP
  195. #if defined(__cplusplus)
  196. #define DUK_F_CPP
  197. #endif
  198. /* Intel x86 (32-bit), x64 (64-bit) or x32 (64-bit but 32-bit pointers),
  199. * define only one of DUK_F_X86, DUK_F_X64, DUK_F_X32.
  200. * https://sites.google.com/site/x32abi/
  201. *
  202. * With DUK_F_OLD_SOLARIS the <sys/isa_defs.h> header must be included
  203. * before this.
  204. */
  205. #if defined(__amd64__) || defined(__amd64) || \
  206. defined(__x86_64__) || defined(__x86_64) || \
  207. defined(_M_X64) || defined(_M_AMD64)
  208. #if defined(__ILP32__) || defined(_ILP32)
  209. #define DUK_F_X32
  210. #else
  211. #define DUK_F_X64
  212. #endif
  213. #elif defined(i386) || defined(__i386) || defined(__i386__) || \
  214. defined(__i486__) || defined(__i586__) || defined(__i686__) || \
  215. defined(__IA32__) || defined(_M_IX86) || defined(__X86__) || \
  216. defined(_X86_) || defined(__THW_INTEL__) || defined(__I86__)
  217. #if defined(__LP64__) || defined(_LP64)
  218. /* This should not really happen, but would indicate x64. */
  219. #define DUK_F_X64
  220. #else
  221. #define DUK_F_X86
  222. #endif
  223. #endif
  224. /* ARM */
  225. #if defined(__arm__) || defined(__thumb__) || defined(_ARM) || defined(_M_ARM) || defined(__aarch64__)
  226. #define DUK_F_ARM
  227. #if defined(__LP64__) || defined(_LP64) || defined(__arm64) || defined(__arm64__) || defined(__aarch64__)
  228. #define DUK_F_ARM64
  229. #else
  230. #define DUK_F_ARM32
  231. #endif
  232. #endif
  233. /* MIPS. Related defines: __MIPSEB__, __MIPSEL__, __mips_isa_rev, __LP64__ */
  234. #if defined(__mips__) || defined(mips) || defined(_MIPS_ISA) || \
  235. defined(_R3000) || defined(_R4000) || defined(_R5900) || \
  236. defined(_MIPS_ISA_MIPS1) || defined(_MIPS_ISA_MIPS2) || \
  237. defined(_MIPS_ISA_MIPS3) || defined(_MIPS_ISA_MIPS4) || \
  238. defined(__mips) || defined(__MIPS__)
  239. #define DUK_F_MIPS
  240. #if defined(__LP64__) || defined(_LP64) || defined(__mips64) || \
  241. defined(__mips64__) || defined(__mips_n64)
  242. #define DUK_F_MIPS64
  243. #else
  244. #define DUK_F_MIPS32
  245. #endif
  246. #endif
  247. /* SPARC */
  248. #if defined(sparc) || defined(__sparc) || defined(__sparc__)
  249. #define DUK_F_SPARC
  250. #if defined(__LP64__) || defined(_LP64)
  251. #define DUK_F_SPARC64
  252. #else
  253. #define DUK_F_SPARC32
  254. #endif
  255. #endif
  256. /* SuperH */
  257. #if defined(__sh__) || \
  258. defined(__sh1__) || defined(__SH1__) || \
  259. defined(__sh2__) || defined(__SH2__) || \
  260. defined(__sh3__) || defined(__SH3__) || \
  261. defined(__sh4__) || defined(__SH4__) || \
  262. defined(__sh5__) || defined(__SH5__)
  263. #define DUK_F_SUPERH
  264. #endif
  265. /* Clang */
  266. #if defined(__clang__)
  267. #define DUK_F_CLANG
  268. #endif
  269. /* C99 or above */
  270. #undef DUK_F_C99
  271. #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
  272. #define DUK_F_C99
  273. #endif
  274. /* C++11 or above */
  275. #undef DUK_F_CPP11
  276. #if defined(__cplusplus) && (__cplusplus >= 201103L)
  277. #define DUK_F_CPP11
  278. #endif
  279. /* GCC. Clang also defines __GNUC__ so don't detect GCC if using Clang. */
  280. #if defined(__GNUC__) && !defined(__clang__) && !defined(DUK_F_CLANG)
  281. #define DUK_F_GCC
  282. #if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
  283. /* Convenience, e.g. gcc 4.5.1 == 40501; http://stackoverflow.com/questions/6031819/emulating-gccs-builtin-unreachable */
  284. #define DUK_F_GCC_VERSION (__GNUC__ * 10000L + __GNUC_MINOR__ * 100L + __GNUC_PATCHLEVEL__)
  285. #else
  286. #error cannot figure out gcc version
  287. #endif
  288. #endif
  289. /* MinGW. Also GCC flags (DUK_F_GCC) are enabled now. */
  290. #if defined(__MINGW32__) || defined(__MINGW64__)
  291. #define DUK_F_MINGW
  292. #endif
  293. /* MSVC */
  294. #if defined(_MSC_VER)
  295. /* MSVC preprocessor defines: http://msdn.microsoft.com/en-us/library/b0084kay.aspx
  296. * _MSC_FULL_VER includes the build number, but it has at least two formats, see e.g.
  297. * BOOST_MSVC_FULL_VER in http://www.boost.org/doc/libs/1_52_0/boost/config/compiler/visualc.hpp
  298. */
  299. #define DUK_F_MSVC
  300. #if defined(_MSC_FULL_VER)
  301. #if (_MSC_FULL_VER > 100000000)
  302. #define DUK_F_MSVC_FULL_VER _MSC_FULL_VER
  303. #else
  304. #define DUK_F_MSCV_FULL_VER (_MSC_FULL_VER * 10)
  305. #endif
  306. #endif
  307. #endif /* _MSC_VER */
  308. /* TinyC */
  309. #if defined(__TINYC__)
  310. /* http://bellard.org/tcc/tcc-doc.html#SEC9 */
  311. #define DUK_F_TINYC
  312. #endif
  313. /* VBCC */
  314. #if defined(__VBCC__)
  315. #define DUK_F_VBCC
  316. #endif
  317. #if defined(ANDROID) || defined(__ANDROID__)
  318. #define DUK_F_ANDROID
  319. #endif
  320. /* Atari Mint */
  321. #if defined(__MINT__)
  322. #define DUK_F_MINT
  323. #endif
  324. /*
  325. * Platform autodetection
  326. */
  327. /* Workaround for older C++ compilers before including <inttypes.h>,
  328. * see e.g.: https://sourceware.org/bugzilla/show_bug.cgi?id=15366
  329. */
  330. #if defined(__cplusplus) && !defined(__STDC_LIMIT_MACROS)
  331. #define __STDC_LIMIT_MACROS
  332. #endif
  333. #if defined(__cplusplus) && !defined(__STDC_CONSTANT_MACROS)
  334. #define __STDC_CONSTANT_MACROS
  335. #endif
  336. #if defined(DUK_F_APPLE)
  337. /* --- Mac OSX, iPhone, Darwin --- */
  338. #define DUK_USE_DATE_NOW_GETTIMEOFDAY
  339. #define DUK_USE_DATE_TZO_GMTIME_R
  340. #define DUK_USE_DATE_PRS_STRPTIME
  341. #define DUK_USE_DATE_FMT_STRFTIME
  342. #include <TargetConditionals.h>
  343. #include <architecture/byte_order.h>
  344. #include <sys/param.h>
  345. #include <sys/time.h>
  346. #include <time.h>
  347. /* http://stackoverflow.com/questions/5919996/how-to-detect-reliably-mac-os-x-ios-linux-windows-in-c-preprocessor */
  348. #if TARGET_IPHONE_SIMULATOR
  349. #define DUK_USE_OS_STRING "iphone-sim"
  350. #elif TARGET_OS_IPHONE
  351. #define DUK_USE_OS_STRING "iphone"
  352. #elif TARGET_OS_MAC
  353. #define DUK_USE_OS_STRING "osx"
  354. #else
  355. #define DUK_USE_OS_STRING "osx-unknown"
  356. #endif
  357. /* Use _setjmp() on Apple by default, see GH-55. */
  358. #define DUK_JMPBUF_TYPE jmp_buf
  359. #define DUK_SETJMP(jb) _setjmp((jb))
  360. #define DUK_LONGJMP(jb) _longjmp((jb), 1)
  361. #elif defined(DUK_F_ORBIS)
  362. /* --- Orbis --- */
  363. /* Orbis = PS4 */
  364. #define DUK_USE_DATE_NOW_GETTIMEOFDAY
  365. #define DUK_USE_DATE_TZO_GMTIME_S
  366. /* no parsing (not an error) */
  367. #define DUK_USE_DATE_FMT_STRFTIME
  368. #include <sys/types.h>
  369. #include <machine/endian.h>
  370. #include <sys/param.h>
  371. #include <sys/time.h>
  372. #include <time.h>
  373. #define DUK_USE_OS_STRING "orbis"
  374. #elif defined(DUK_F_OPENBSD)
  375. /* --- OpenBSD --- */
  376. /* http://www.monkey.org/openbsd/archive/ports/0401/msg00089.html */
  377. #define DUK_USE_DATE_NOW_GETTIMEOFDAY
  378. #define DUK_USE_DATE_TZO_GMTIME_R
  379. #define DUK_USE_DATE_PRS_STRPTIME
  380. #define DUK_USE_DATE_FMT_STRFTIME
  381. #include <sys/types.h>
  382. #include <sys/endian.h>
  383. #include <sys/param.h>
  384. #include <sys/time.h>
  385. #include <time.h>
  386. #define DUK_USE_OS_STRING "openbsd"
  387. #elif defined(DUK_F_BSD)
  388. /* --- Generic BSD --- */
  389. #define DUK_USE_DATE_NOW_GETTIMEOFDAY
  390. #define DUK_USE_DATE_TZO_GMTIME_R
  391. #define DUK_USE_DATE_PRS_STRPTIME
  392. #define DUK_USE_DATE_FMT_STRFTIME
  393. #include <sys/types.h>
  394. #include <sys/endian.h>
  395. #include <sys/param.h>
  396. #include <sys/time.h>
  397. #include <time.h>
  398. #define DUK_USE_OS_STRING "bsd"
  399. #elif defined(DUK_F_TOS)
  400. /* --- Atari ST TOS --- */
  401. #define DUK_USE_DATE_NOW_TIME
  402. #define DUK_USE_DATE_TZO_GMTIME
  403. /* no parsing (not an error) */
  404. #define DUK_USE_DATE_FMT_STRFTIME
  405. #include <time.h>
  406. #define DUK_USE_OS_STRING "tos"
  407. /* TOS on M68K is always big endian. */
  408. #if !defined(DUK_USE_BYTEORDER) && defined(DUK_F_M68K)
  409. #define DUK_USE_BYTEORDER 3
  410. #endif
  411. #elif defined(DUK_F_AMIGAOS)
  412. /* --- AmigaOS --- */
  413. #if defined(DUK_F_M68K)
  414. /* AmigaOS on M68k */
  415. #define DUK_USE_DATE_NOW_TIME
  416. #define DUK_USE_DATE_TZO_GMTIME
  417. /* no parsing (not an error) */
  418. #define DUK_USE_DATE_FMT_STRFTIME
  419. #include <time.h>
  420. #elif defined(DUK_F_PPC)
  421. #define DUK_USE_DATE_NOW_GETTIMEOFDAY
  422. #define DUK_USE_DATE_TZO_GMTIME_R
  423. #define DUK_USE_DATE_PRS_STRPTIME
  424. #define DUK_USE_DATE_FMT_STRFTIME
  425. #include <time.h>
  426. #if !defined(UINTPTR_MAX)
  427. #define UINTPTR_MAX UINT_MAX
  428. #endif
  429. #else
  430. #error AmigaOS but not M68K/PPC, not supported now
  431. #endif
  432. #define DUK_USE_OS_STRING "amigaos"
  433. /* AmigaOS on M68K or PPC is always big endian. */
  434. #if !defined(DUK_USE_BYTEORDER) && (defined(DUK_F_M68K) || defined(DUK_F_PPC))
  435. #define DUK_USE_BYTEORDER 3
  436. #endif
  437. #elif defined(DUK_F_DURANGO)
  438. /* --- Durango (XboxOne) --- */
  439. /* Durango = XboxOne
  440. * Configuration is nearly identical to Windows, except for
  441. * DUK_USE_DATE_TZO_WINDOWS.
  442. */
  443. /* Initial fix: disable secure CRT related warnings when compiling Duktape
  444. * itself (must be defined before including Windows headers). Don't define
  445. * for user code including duktape.h.
  446. */
  447. #if defined(DUK_COMPILING_DUKTAPE) && !defined(_CRT_SECURE_NO_WARNINGS)
  448. #define _CRT_SECURE_NO_WARNINGS
  449. #endif
  450. /* MSVC does not have sys/param.h */
  451. #define DUK_USE_DATE_NOW_WINDOWS
  452. #define DUK_USE_DATE_TZO_WINDOWS_NO_DST
  453. /* Note: PRS and FMT are intentionally left undefined for now. This means
  454. * there is no platform specific date parsing/formatting but there is still
  455. * the ISO 8601 standard format.
  456. */
  457. #if defined(DUK_COMPILING_DUKTAPE)
  458. /* Only include when compiling Duktape to avoid polluting application build
  459. * with a lot of unnecessary defines.
  460. */
  461. #include <windows.h>
  462. #endif
  463. #define DUK_USE_OS_STRING "durango"
  464. #if !defined(DUK_USE_BYTEORDER)
  465. #define DUK_USE_BYTEORDER 1
  466. #endif
  467. #elif defined(DUK_F_WINDOWS)
  468. /* --- Windows --- */
  469. /* Windows version can't obviously be determined at compile time,
  470. * but _WIN32_WINNT indicates the minimum version targeted:
  471. * - https://msdn.microsoft.com/en-us/library/6sehtctf.aspx
  472. */
  473. /* Initial fix: disable secure CRT related warnings when compiling Duktape
  474. * itself (must be defined before including Windows headers). Don't define
  475. * for user code including duktape.h.
  476. */
  477. #if defined(DUK_COMPILING_DUKTAPE) && !defined(_CRT_SECURE_NO_WARNINGS)
  478. #define _CRT_SECURE_NO_WARNINGS
  479. #endif
  480. /* Windows 32-bit and 64-bit are currently the same. */
  481. /* MSVC does not have sys/param.h */
  482. #if defined(DUK_COMPILING_DUKTAPE)
  483. /* Only include when compiling Duktape to avoid polluting application build
  484. * with a lot of unnecessary defines.
  485. */
  486. #include <windows.h>
  487. #endif
  488. /* GetSystemTimePreciseAsFileTime() available from Windows 8:
  489. * https://msdn.microsoft.com/en-us/library/windows/desktop/hh706895(v=vs.85).aspx
  490. */
  491. #if defined(DUK_USE_DATE_NOW_WINDOWS_SUBMS) || defined(DUK_USE_DATE_NOW_WINDOWS)
  492. /* User forced provider. */
  493. #else
  494. #if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0602)
  495. #define DUK_USE_DATE_NOW_WINDOWS_SUBMS
  496. #else
  497. #define DUK_USE_DATE_NOW_WINDOWS
  498. #endif
  499. #endif
  500. #define DUK_USE_DATE_TZO_WINDOWS
  501. /* Note: PRS and FMT are intentionally left undefined for now. This means
  502. * there is no platform specific date parsing/formatting but there is still
  503. * the ISO 8601 standard format.
  504. */
  505. /* QueryPerformanceCounter() may go backwards in Windows XP, so enable for
  506. * Vista and later: https://msdn.microsoft.com/en-us/library/windows/desktop/dn553408(v=vs.85).aspx#qpc_support_in_windows_versions
  507. */
  508. #if !defined(DUK_USE_GET_MONOTONIC_TIME_WINDOWS_QPC) && \
  509. defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0600)
  510. #define DUK_USE_GET_MONOTONIC_TIME_WINDOWS_QPC
  511. #endif
  512. #define DUK_USE_OS_STRING "windows"
  513. /* On Windows, assume we're little endian. Even Itanium which has a
  514. * configurable endianness runs little endian in Windows.
  515. */
  516. #if !defined(DUK_USE_BYTEORDER)
  517. #define DUK_USE_BYTEORDER 1
  518. #endif
  519. #elif defined(DUK_F_FLASHPLAYER)
  520. /* --- Flashplayer (Crossbridge) --- */
  521. #define DUK_USE_DATE_NOW_GETTIMEOFDAY
  522. #define DUK_USE_DATE_TZO_GMTIME_R
  523. #define DUK_USE_DATE_PRS_STRPTIME
  524. #define DUK_USE_DATE_FMT_STRFTIME
  525. #include <endian.h>
  526. #include <sys/param.h>
  527. #include <sys/time.h>
  528. #include <time.h>
  529. #define DUK_USE_OS_STRING "flashplayer"
  530. #if !defined(DUK_USE_BYTEORDER) && defined(DUK_F_FLASHPLAYER)
  531. #define DUK_USE_BYTEORDER 1
  532. #endif
  533. #elif defined(DUK_F_QNX)
  534. /* --- QNX --- */
  535. #if defined(DUK_F_QNX) && defined(DUK_COMPILING_DUKTAPE)
  536. /* See: /opt/qnx650/target/qnx6/usr/include/sys/platform.h */
  537. #define _XOPEN_SOURCE 600
  538. #define _POSIX_C_SOURCE 200112L
  539. #endif
  540. #define DUK_USE_DATE_NOW_GETTIMEOFDAY
  541. #define DUK_USE_DATE_TZO_GMTIME_R
  542. #define DUK_USE_DATE_PRS_STRPTIME
  543. #define DUK_USE_DATE_FMT_STRFTIME
  544. #include <sys/types.h>
  545. #include <sys/param.h>
  546. #include <sys/time.h>
  547. #include <time.h>
  548. #define DUK_USE_OS_STRING "qnx"
  549. #elif defined(DUK_F_TINSPIRE)
  550. /* --- TI-Nspire --- */
  551. #if defined(DUK_COMPILING_DUKTAPE) && !defined(_XOPEN_SOURCE)
  552. #define _XOPEN_SOURCE /* e.g. strptime */
  553. #endif
  554. #define DUK_USE_DATE_NOW_GETTIMEOFDAY
  555. #define DUK_USE_DATE_TZO_GMTIME_R
  556. #define DUK_USE_DATE_PRS_STRPTIME
  557. #define DUK_USE_DATE_FMT_STRFTIME
  558. #include <sys/types.h>
  559. #include <sys/param.h>
  560. #include <sys/time.h>
  561. #include <time.h>
  562. #define DUK_USE_OS_STRING "tinspire"
  563. #elif defined(DUK_F_EMSCRIPTEN)
  564. /* --- Emscripten --- */
  565. #if defined(DUK_COMPILING_DUKTAPE)
  566. #if !defined(_POSIX_C_SOURCE)
  567. #define _POSIX_C_SOURCE 200809L
  568. #endif
  569. #if !defined(_GNU_SOURCE)
  570. #define _GNU_SOURCE /* e.g. getdate_r */
  571. #endif
  572. #if !defined(_XOPEN_SOURCE)
  573. #define _XOPEN_SOURCE /* e.g. strptime */
  574. #endif
  575. #endif /* DUK_COMPILING_DUKTAPE */
  576. #include <sys/types.h>
  577. #if defined(DUK_F_BCC)
  578. /* no endian.h */
  579. #else
  580. #include <endian.h>
  581. #endif /* DUK_F_BCC */
  582. #include <sys/param.h>
  583. #include <sys/time.h>
  584. #include <time.h>
  585. #include <stdint.h>
  586. #define DUK_USE_DATE_NOW_GETTIMEOFDAY
  587. #define DUK_USE_DATE_TZO_GMTIME_R
  588. #define DUK_USE_DATE_PRS_STRPTIME
  589. #define DUK_USE_DATE_FMT_STRFTIME
  590. #define DUK_USE_OS_STRING "emscripten"
  591. #elif defined(DUK_F_LINUX)
  592. /* --- Linux --- */
  593. #if defined(DUK_COMPILING_DUKTAPE)
  594. #if !defined(_POSIX_C_SOURCE)
  595. #define _POSIX_C_SOURCE 200809L
  596. #endif
  597. #if !defined(_GNU_SOURCE)
  598. #define _GNU_SOURCE /* e.g. getdate_r */
  599. #endif
  600. #if !defined(_XOPEN_SOURCE)
  601. #define _XOPEN_SOURCE /* e.g. strptime */
  602. #endif
  603. #endif /* DUK_COMPILING_DUKTAPE */
  604. #include <sys/types.h>
  605. #if defined(DUK_F_BCC)
  606. /* no endian.h or stdint.h */
  607. #else
  608. #include <endian.h>
  609. #include <stdint.h>
  610. #endif /* DUK_F_BCC */
  611. #include <sys/param.h>
  612. #include <sys/time.h>
  613. #include <time.h>
  614. #define DUK_USE_DATE_NOW_GETTIMEOFDAY
  615. #define DUK_USE_DATE_TZO_GMTIME_R
  616. #define DUK_USE_DATE_PRS_STRPTIME
  617. #define DUK_USE_DATE_FMT_STRFTIME
  618. #if 0 /* XXX: safe condition? */
  619. #define DUK_USE_GET_MONOTONIC_TIME_CLOCK_GETTIME
  620. #endif
  621. #define DUK_USE_OS_STRING "linux"
  622. #elif defined(DUK_F_SUN)
  623. /* --- Solaris --- */
  624. #define DUK_USE_DATE_NOW_GETTIMEOFDAY
  625. #define DUK_USE_DATE_TZO_GMTIME_R
  626. #define DUK_USE_DATE_PRS_STRPTIME
  627. #define DUK_USE_DATE_FMT_STRFTIME
  628. #include <sys/types.h>
  629. #if defined(DUK_F_OLD_SOLARIS)
  630. /* Old Solaris with no endian.h, stdint.h */
  631. #define DUK_F_NO_STDINT_H
  632. #if !defined(DUK_USE_BYTEORDER)
  633. #define DUK_USE_BYTEORDER 3
  634. #endif
  635. #else /* DUK_F_OLD_SOLARIS */
  636. #include <ast/endian.h>
  637. #endif /* DUK_F_OLD_SOLARIS */
  638. #include <sys/param.h>
  639. #include <sys/time.h>
  640. #include <time.h>
  641. #define DUK_USE_OS_STRING "solaris"
  642. #elif defined(DUK_F_AIX)
  643. /* --- AIX --- */
  644. #if !defined(DUK_USE_BYTEORDER)
  645. #define DUK_USE_BYTEORDER 3
  646. #endif
  647. #define DUK_USE_DATE_NOW_GETTIMEOFDAY
  648. #define DUK_USE_DATE_TZO_GMTIME_R
  649. #define DUK_USE_DATE_PRS_STRPTIME
  650. #define DUK_USE_DATE_FMT_STRFTIME
  651. #include <sys/param.h>
  652. #include <sys/time.h>
  653. #include <time.h>
  654. #define DUK_USE_OS_STRING "aix"
  655. #elif defined(DUK_F_HPUX)
  656. /* --- HPUX --- */
  657. #define DUK_F_NO_STDINT_H
  658. #if !defined(DUK_USE_BYTEORDER)
  659. #define DUK_USE_BYTEORDER 3
  660. #endif
  661. #define DUK_USE_DATE_NOW_GETTIMEOFDAY
  662. #define DUK_USE_DATE_TZO_GMTIME_R
  663. #define DUK_USE_DATE_PRS_STRPTIME
  664. #define DUK_USE_DATE_FMT_STRFTIME
  665. #include <sys/param.h>
  666. #include <sys/time.h>
  667. #include <time.h>
  668. #define DUK_USE_OS_STRING "hpux"
  669. #elif defined(DUK_F_POSIX)
  670. /* --- Generic POSIX --- */
  671. #define DUK_USE_DATE_NOW_GETTIMEOFDAY
  672. #define DUK_USE_DATE_TZO_GMTIME_R
  673. #define DUK_USE_DATE_PRS_STRPTIME
  674. #define DUK_USE_DATE_FMT_STRFTIME
  675. #include <sys/types.h>
  676. #include <endian.h>
  677. #include <sys/param.h>
  678. #include <sys/time.h>
  679. #include <time.h>
  680. #define DUK_USE_OS_STRING "posix"
  681. #elif defined(DUK_F_CYGWIN)
  682. /* --- Cygwin --- */
  683. /* don't use strptime() for now */
  684. #define DUK_USE_DATE_NOW_GETTIMEOFDAY
  685. #define DUK_USE_DATE_TZO_GMTIME_R
  686. #define DUK_USE_DATE_FMT_STRFTIME
  687. #include <sys/types.h>
  688. #include <endian.h>
  689. #include <sys/param.h>
  690. #include <sys/time.h>
  691. #include <time.h>
  692. #define DUK_JMPBUF_TYPE jmp_buf
  693. #define DUK_SETJMP(jb) _setjmp((jb))
  694. #define DUK_LONGJMP(jb) _longjmp((jb), 1)
  695. #define DUK_USE_OS_STRING "windows"
  696. #elif defined(DUK_F_UNIX)
  697. /* --- Generic UNIX --- */
  698. #define DUK_USE_DATE_NOW_GETTIMEOFDAY
  699. #define DUK_USE_DATE_TZO_GMTIME_R
  700. #define DUK_USE_DATE_PRS_STRPTIME
  701. #define DUK_USE_DATE_FMT_STRFTIME
  702. #include <time.h>
  703. #include <sys/time.h>
  704. #define DUK_USE_OS_STRING "unknown"
  705. #else
  706. /* --- Generic fallback --- */
  707. /* The most portable current time provider is time(), but it only has a
  708. * one second resolution.
  709. */
  710. #define DUK_USE_DATE_NOW_TIME
  711. /* The most portable way to figure out local time offset is gmtime(),
  712. * but it's not thread safe so use with caution.
  713. */
  714. #define DUK_USE_DATE_TZO_GMTIME
  715. /* Avoid custom date parsing and formatting for portability. */
  716. #undef DUK_USE_DATE_PRS_STRPTIME
  717. #undef DUK_USE_DATE_FMT_STRFTIME
  718. /* Rely on C89 headers only; time.h must be here. */
  719. #include <time.h>
  720. #define DUK_USE_OS_STRING "unknown"
  721. #endif /* autodetect platform */
  722. /* Shared includes: C89 */
  723. #include <stdio.h>
  724. #include <stdlib.h>
  725. #include <string.h>
  726. #include <stdarg.h> /* varargs */
  727. #include <setjmp.h>
  728. #include <stddef.h> /* e.g. ptrdiff_t */
  729. #include <math.h>
  730. #include <limits.h>
  731. /* date.h is omitted, and included per platform */
  732. /* Shared includes: stdint.h is C99 */
  733. #if defined(DUK_F_NO_STDINT_H)
  734. /* stdint.h not available */
  735. #else
  736. /* Technically C99 (C++11) but found in many systems. On some systems
  737. * __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS must be defined before
  738. * including stdint.h (see above).
  739. */
  740. #include <stdint.h>
  741. #endif
  742. #if defined(DUK_F_CPP)
  743. #include <exception> /* std::exception */
  744. #endif
  745. /*
  746. * Architecture autodetection
  747. */
  748. #if defined(DUK_F_X86)
  749. /* --- x86 --- */
  750. #define DUK_USE_ARCH_STRING "x86"
  751. #if !defined(DUK_USE_BYTEORDER)
  752. #define DUK_USE_BYTEORDER 1
  753. #endif
  754. /* XXX: This is technically not guaranteed because it's possible to configure
  755. * an x86 to require aligned accesses with Alignment Check (AC) flag.
  756. */
  757. #if !defined(DUK_USE_ALIGN_BY)
  758. #define DUK_USE_ALIGN_BY 1
  759. #endif
  760. #define DUK_USE_PACKED_TVAL
  761. #define DUK_F_PACKED_TVAL_PROVIDED
  762. #elif defined(DUK_F_X64)
  763. /* --- x64 --- */
  764. #define DUK_USE_ARCH_STRING "x64"
  765. #if !defined(DUK_USE_BYTEORDER)
  766. #define DUK_USE_BYTEORDER 1
  767. #endif
  768. /* XXX: This is technically not guaranteed because it's possible to configure
  769. * an x86 to require aligned accesses with Alignment Check (AC) flag.
  770. */
  771. #if !defined(DUK_USE_ALIGN_BY)
  772. #define DUK_USE_ALIGN_BY 1
  773. #endif
  774. #undef DUK_USE_PACKED_TVAL
  775. #define DUK_F_PACKED_TVAL_PROVIDED
  776. #elif defined(DUK_F_X32)
  777. /* --- x32 --- */
  778. #define DUK_USE_ARCH_STRING "x32"
  779. #if !defined(DUK_USE_BYTEORDER)
  780. #define DUK_USE_BYTEORDER 1
  781. #endif
  782. /* XXX: This is technically not guaranteed because it's possible to configure
  783. * an x86 to require aligned accesses with Alignment Check (AC) flag.
  784. */
  785. #if !defined(DUK_USE_ALIGN_BY)
  786. #define DUK_USE_ALIGN_BY 1
  787. #endif
  788. #define DUK_USE_PACKED_TVAL
  789. #define DUK_F_PACKED_TVAL_PROVIDED
  790. #elif defined(DUK_F_ARM32)
  791. /* --- ARM 32-bit --- */
  792. #define DUK_USE_ARCH_STRING "arm32"
  793. /* Byte order varies, so rely on autodetect. */
  794. #if !defined(DUK_USE_ALIGN_BY)
  795. #define DUK_USE_ALIGN_BY 4
  796. #endif
  797. #define DUK_USE_PACKED_TVAL
  798. #define DUK_F_PACKED_TVAL_PROVIDED
  799. #elif defined(DUK_F_ARM64)
  800. /* --- ARM 64-bit --- */
  801. #define DUK_USE_ARCH_STRING "arm64"
  802. /* Byte order varies, so rely on autodetect. */
  803. #if !defined(DUK_USE_ALIGN_BY)
  804. #define DUK_USE_ALIGN_BY 8
  805. #endif
  806. #undef DUK_USE_PACKED_TVAL
  807. #define DUK_F_PACKED_TVAL_PROVIDED
  808. #elif defined(DUK_F_MIPS32)
  809. /* --- MIPS 32-bit --- */
  810. #define DUK_USE_ARCH_STRING "mips32"
  811. /* MIPS byte order varies so rely on autodetection. */
  812. #if !defined(DUK_USE_ALIGN_BY)
  813. #define DUK_USE_ALIGN_BY 8
  814. #endif
  815. #define DUK_USE_PACKED_TVAL
  816. #define DUK_F_PACKED_TVAL_PROVIDED
  817. #elif defined(DUK_F_MIPS64)
  818. /* --- MIPS 64-bit --- */
  819. #define DUK_USE_ARCH_STRING "mips64"
  820. /* MIPS byte order varies so rely on autodetection. */
  821. #if !defined(DUK_USE_ALIGN_BY)
  822. #define DUK_USE_ALIGN_BY 8
  823. #endif
  824. #undef DUK_USE_PACKED_TVAL
  825. #define DUK_F_PACKED_TVAL_PROVIDED
  826. #elif defined(DUK_F_PPC32)
  827. /* --- PowerPC 32-bit --- */
  828. #define DUK_USE_ARCH_STRING "ppc32"
  829. #if !defined(DUK_USE_BYTEORDER)
  830. #define DUK_USE_BYTEORDER 3
  831. #endif
  832. #if !defined(DUK_USE_ALIGN_BY)
  833. #define DUK_USE_ALIGN_BY 8
  834. #endif
  835. #define DUK_USE_PACKED_TVAL
  836. #define DUK_F_PACKED_TVAL_PROVIDED
  837. #elif defined(DUK_F_PPC64)
  838. /* --- PowerPC 64-bit --- */
  839. #define DUK_USE_ARCH_STRING "ppc64"
  840. #if !defined(DUK_USE_BYTEORDER)
  841. #define DUK_USE_BYTEORDER 3
  842. #endif
  843. #if !defined(DUK_USE_ALIGN_BY)
  844. #define DUK_USE_ALIGN_BY 8
  845. #endif
  846. #undef DUK_USE_PACKED_TVAL
  847. #define DUK_F_PACKED_TVAL_PROVIDED
  848. #elif defined(DUK_F_SPARC32)
  849. /* --- SPARC 32-bit --- */
  850. #define DUK_USE_ARCH_STRING "sparc32"
  851. /* SPARC byte order varies so rely on autodetection. */
  852. #if !defined(DUK_USE_ALIGN_BY)
  853. #define DUK_USE_ALIGN_BY 8
  854. #endif
  855. #define DUK_USE_PACKED_TVAL
  856. #define DUK_F_PACKED_TVAL_PROVIDED
  857. #elif defined(DUK_F_SPARC64)
  858. /* --- SPARC 64-bit --- */
  859. #define DUK_USE_ARCH_STRING "sparc64"
  860. /* SPARC byte order varies so rely on autodetection. */
  861. #if !defined(DUK_USE_ALIGN_BY)
  862. #define DUK_USE_ALIGN_BY 8
  863. #endif
  864. #undef DUK_USE_PACKED_TVAL
  865. #define DUK_F_PACKED_TVAL_PROVIDED
  866. #elif defined(DUK_F_SUPERH)
  867. /* --- SuperH --- */
  868. #define DUK_USE_ARCH_STRING "sh"
  869. /* Byte order varies, rely on autodetection. */
  870. /* Based on 'make checkalign' there are no alignment requirements on
  871. * Linux SH4, but align by 4 is probably a good basic default.
  872. */
  873. #if !defined(DUK_USE_ALIGN_BY)
  874. #define DUK_USE_ALIGN_BY 4
  875. #endif
  876. #define DUK_USE_PACKED_TVAL
  877. #define DUK_F_PACKED_TVAL_PROVIDED
  878. #elif defined(DUK_F_M68K)
  879. /* --- Motorola 68k --- */
  880. #define DUK_USE_ARCH_STRING "m68k"
  881. #if !defined(DUK_USE_BYTEORDER)
  882. #define DUK_USE_BYTEORDER 3
  883. #endif
  884. #if !defined(DUK_USE_ALIGN_BY)
  885. #define DUK_USE_ALIGN_BY 8
  886. #endif
  887. #define DUK_USE_PACKED_TVAL
  888. #define DUK_F_PACKED_TVAL_PROVIDED
  889. #elif defined(DUK_F_EMSCRIPTEN)
  890. /* --- Emscripten --- */
  891. #define DUK_USE_ARCH_STRING "emscripten"
  892. #if !defined(DUK_USE_BYTEORDER)
  893. #define DUK_USE_BYTEORDER 1
  894. #endif
  895. #if !defined(DUK_USE_ALIGN_BY)
  896. #define DUK_USE_ALIGN_BY 8
  897. #endif
  898. #undef DUK_USE_PACKED_TVAL
  899. #define DUK_F_PACKED_TVAL_PROVIDED
  900. #else
  901. /* --- Generic --- */
  902. /* These are necessary wild guesses. */
  903. #define DUK_USE_ARCH_STRING "generic"
  904. /* Rely on autodetection for byte order, alignment, and packed tval. */
  905. #endif /* autodetect architecture */
  906. /*
  907. * Compiler autodetection
  908. */
  909. #if defined(DUK_F_CLANG)
  910. /* --- Clang --- */
  911. #if defined(DUK_F_C99) || defined(DUK_F_CPP11)
  912. /* C99 / C++11 and above: rely on va_copy() which is required. */
  913. #define DUK_VA_COPY(dest,src) va_copy(dest,src)
  914. #else
  915. /* Clang: assume we have __va_copy() in non-C99 mode. */
  916. #define DUK_VA_COPY(dest,src) __va_copy(dest,src)
  917. #endif
  918. #define DUK_NORETURN(decl) decl __attribute__((noreturn))
  919. #if defined(__clang__) && defined(__has_builtin)
  920. #if __has_builtin(__builtin_unreachable)
  921. #define DUK_UNREACHABLE() do { __builtin_unreachable(); } while (0)
  922. #endif
  923. #endif
  924. #define DUK_USE_BRANCH_HINTS
  925. #define DUK_LIKELY(x) __builtin_expect((x), 1)
  926. #define DUK_UNLIKELY(x) __builtin_expect((x), 0)
  927. #if defined(__clang__) && defined(__has_builtin)
  928. #if __has_builtin(__builtin_unpredictable)
  929. #define DUK_UNPREDICTABLE(x) __builtin_unpredictable((x))
  930. #endif
  931. #endif
  932. #if defined(DUK_F_C99) || defined(DUK_F_CPP11)
  933. #define DUK_NOINLINE __attribute__((noinline))
  934. #define DUK_INLINE inline
  935. #define DUK_ALWAYS_INLINE inline __attribute__((always_inline))
  936. #endif
  937. /* DUK_HOT */
  938. /* DUK_COLD */
  939. #if defined(DUK_F_DLL_BUILD) && defined(DUK_F_WINDOWS)
  940. /* MSVC dllexport/dllimport: appropriate __declspec depends on whether we're
  941. * compiling Duktape or the application.
  942. */
  943. #if defined(DUK_COMPILING_DUKTAPE)
  944. #define DUK_EXTERNAL_DECL extern __declspec(dllexport)
  945. #define DUK_EXTERNAL __declspec(dllexport)
  946. #else
  947. #define DUK_EXTERNAL_DECL extern __declspec(dllimport)
  948. #define DUK_EXTERNAL should_not_happen
  949. #endif
  950. #if defined(DUK_SINGLE_FILE)
  951. #define DUK_INTERNAL_DECL static
  952. #define DUK_INTERNAL static
  953. #else
  954. #define DUK_INTERNAL_DECL extern
  955. #define DUK_INTERNAL /*empty*/
  956. #endif
  957. #define DUK_LOCAL_DECL static
  958. #define DUK_LOCAL static
  959. #else
  960. #define DUK_EXTERNAL_DECL __attribute__ ((visibility("default"))) extern
  961. #define DUK_EXTERNAL __attribute__ ((visibility("default")))
  962. #if defined(DUK_SINGLE_FILE)
  963. #if (defined(DUK_F_GCC_VERSION) && DUK_F_GCC_VERSION >= 30101) || defined(DUK_F_CLANG)
  964. /* Minimize warnings for unused internal functions with GCC >= 3.1.1 and
  965. * Clang. Based on documentation it should suffice to have the attribute
  966. * in the declaration only, but in practice some warnings are generated unless
  967. * the attribute is also applied to the definition.
  968. */
  969. #define DUK_INTERNAL_DECL static __attribute__ ((unused))
  970. #define DUK_INTERNAL static __attribute__ ((unused))
  971. #else
  972. #define DUK_INTERNAL_DECL static
  973. #define DUK_INTERNAL static
  974. #endif
  975. #else
  976. #if (defined(DUK_F_GCC_VERSION) && DUK_F_GCC_VERSION >= 30101) || defined(DUK_F_CLANG)
  977. #define DUK_INTERNAL_DECL __attribute__ ((visibility("hidden"))) __attribute__ ((unused)) extern
  978. #define DUK_INTERNAL __attribute__ ((visibility("hidden"))) __attribute__ ((unused))
  979. #else
  980. #define DUK_INTERNAL_DECL __attribute__ ((visibility("hidden"))) extern
  981. #define DUK_INTERNAL __attribute__ ((visibility("hidden")))
  982. #endif
  983. #endif
  984. #define DUK_LOCAL_DECL static
  985. #define DUK_LOCAL static
  986. #endif
  987. #if defined(DUK_F_CPP)
  988. #define DUK_USE_COMPILER_STRING "clang"
  989. #else
  990. #define DUK_USE_COMPILER_STRING "clang"
  991. #endif
  992. #undef DUK_USE_VARIADIC_MACROS
  993. #if defined(DUK_F_C99) || defined(DUK_F_CPP11)
  994. #define DUK_USE_VARIADIC_MACROS
  995. #endif
  996. #define DUK_USE_UNION_INITIALIZERS
  997. #undef DUK_USE_FLEX_C99
  998. #undef DUK_USE_FLEX_ZEROSIZE
  999. #undef DUK_USE_FLEX_ONESIZE
  1000. #if defined(DUK_F_C99)
  1001. #define DUK_USE_FLEX_C99
  1002. #else
  1003. #define DUK_USE_FLEX_ZEROSIZE
  1004. #endif
  1005. #undef DUK_USE_GCC_PRAGMAS
  1006. #define DUK_USE_PACK_CLANG_ATTR
  1007. #elif defined(DUK_F_GCC)
  1008. /* --- GCC --- */
  1009. #if defined(DUK_F_C99) || defined(DUK_F_CPP11)
  1010. /* C99 / C++11 and above: rely on va_copy() which is required. */
  1011. #define DUK_VA_COPY(dest,src) va_copy(dest,src)
  1012. #else
  1013. /* GCC: assume we have __va_copy() in non-C99 mode. */
  1014. #define DUK_VA_COPY(dest,src) __va_copy(dest,src)
  1015. #endif
  1016. #if defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 20500L)
  1017. /* since gcc-2.5 */
  1018. #define DUK_NORETURN(decl) decl __attribute__((noreturn))
  1019. #endif
  1020. #if defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 40500L)
  1021. /* since gcc-4.5 */
  1022. #define DUK_UNREACHABLE() do { __builtin_unreachable(); } while (0)
  1023. #endif
  1024. #define DUK_USE_BRANCH_HINTS
  1025. #if defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 40500L)
  1026. /* GCC: test not very accurate; enable only in relatively recent builds
  1027. * because of bugs in gcc-4.4 (http://lists.debian.org/debian-gcc/2010/04/msg00000.html)
  1028. */
  1029. #define DUK_LIKELY(x) __builtin_expect((x), 1)
  1030. #define DUK_UNLIKELY(x) __builtin_expect((x), 0)
  1031. #endif
  1032. /* XXX: equivalent of clang __builtin_unpredictable? */
  1033. #if (defined(DUK_F_C99) || defined(DUK_F_CPP11)) && \
  1034. defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 30101)
  1035. #define DUK_NOINLINE __attribute__((noinline))
  1036. #define DUK_INLINE inline
  1037. #define DUK_ALWAYS_INLINE inline __attribute__((always_inline))
  1038. #endif
  1039. #if (defined(DUK_F_C99) || defined(DUK_F_CPP11)) && \
  1040. defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 40300)
  1041. #define DUK_HOT __attribute__((hot))
  1042. #define DUK_COLD __attribute__((cold))
  1043. #endif
  1044. #if defined(DUK_F_DLL_BUILD) && defined(DUK_F_WINDOWS)
  1045. /* MSVC dllexport/dllimport: appropriate __declspec depends on whether we're
  1046. * compiling Duktape or the application.
  1047. */
  1048. #if defined(DUK_COMPILING_DUKTAPE)
  1049. #define DUK_EXTERNAL_DECL extern __declspec(dllexport)
  1050. #define DUK_EXTERNAL __declspec(dllexport)
  1051. #else
  1052. #define DUK_EXTERNAL_DECL extern __declspec(dllimport)
  1053. #define DUK_EXTERNAL should_not_happen
  1054. #endif
  1055. #if defined(DUK_SINGLE_FILE)
  1056. #define DUK_INTERNAL_DECL static
  1057. #define DUK_INTERNAL static
  1058. #else
  1059. #define DUK_INTERNAL_DECL extern
  1060. #define DUK_INTERNAL /*empty*/
  1061. #endif
  1062. #define DUK_LOCAL_DECL static
  1063. #define DUK_LOCAL static
  1064. #elif defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 40000)
  1065. #define DUK_EXTERNAL_DECL __attribute__ ((visibility("default"))) extern
  1066. #define DUK_EXTERNAL __attribute__ ((visibility("default")))
  1067. #if defined(DUK_SINGLE_FILE)
  1068. #if (defined(DUK_F_GCC_VERSION) && DUK_F_GCC_VERSION >= 30101) || defined(DUK_F_CLANG)
  1069. /* Minimize warnings for unused internal functions with GCC >= 3.1.1 and
  1070. * Clang. Based on documentation it should suffice to have the attribute
  1071. * in the declaration only, but in practice some warnings are generated unless
  1072. * the attribute is also applied to the definition.
  1073. */
  1074. #define DUK_INTERNAL_DECL static __attribute__ ((unused))
  1075. #define DUK_INTERNAL static __attribute__ ((unused))
  1076. #else
  1077. #define DUK_INTERNAL_DECL static
  1078. #define DUK_INTERNAL static
  1079. #endif
  1080. #else
  1081. #if (defined(DUK_F_GCC_VERSION) && DUK_F_GCC_VERSION >= 30101) || defined(DUK_F_CLANG)
  1082. #define DUK_INTERNAL_DECL __attribute__ ((visibility("hidden"))) __attribute__ ((unused)) extern
  1083. #define DUK_INTERNAL __attribute__ ((visibility("hidden"))) __attribute__ ((unused))
  1084. #else
  1085. #define DUK_INTERNAL_DECL __attribute__ ((visibility("hidden"))) extern
  1086. #define DUK_INTERNAL __attribute__ ((visibility("hidden")))
  1087. #endif
  1088. #endif
  1089. #define DUK_LOCAL_DECL static
  1090. #define DUK_LOCAL static
  1091. #endif
  1092. #if defined(DUK_F_MINGW)
  1093. #if defined(DUK_F_CPP)
  1094. #define DUK_USE_COMPILER_STRING "mingw++"
  1095. #else
  1096. #define DUK_USE_COMPILER_STRING "mingw"
  1097. #endif
  1098. #else
  1099. #if defined(DUK_F_CPP)
  1100. #define DUK_USE_COMPILER_STRING "g++"
  1101. #else
  1102. #define DUK_USE_COMPILER_STRING "gcc"
  1103. #endif
  1104. #endif
  1105. #undef DUK_USE_VARIADIC_MACROS
  1106. #if defined(DUK_F_C99) || (defined(DUK_F_CPP11) && defined(__GNUC__))
  1107. #define DUK_USE_VARIADIC_MACROS
  1108. #endif
  1109. #define DUK_USE_UNION_INITIALIZERS
  1110. #undef DUK_USE_FLEX_C99
  1111. #undef DUK_USE_FLEX_ZEROSIZE
  1112. #undef DUK_USE_FLEX_ONESIZE
  1113. #if defined(DUK_F_C99)
  1114. #define DUK_USE_FLEX_C99
  1115. #else
  1116. #define DUK_USE_FLEX_ZEROSIZE
  1117. #endif
  1118. #if defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 40600)
  1119. #define DUK_USE_GCC_PRAGMAS
  1120. #else
  1121. #undef DUK_USE_GCC_PRAGMAS
  1122. #endif
  1123. #define DUK_USE_PACK_GCC_ATTR
  1124. #elif defined(DUK_F_MSVC)
  1125. /* --- MSVC --- */
  1126. /* http://msdn.microsoft.com/en-us/library/aa235362(VS.60).aspx */
  1127. #define DUK_NORETURN(decl) __declspec(noreturn) decl
  1128. /* XXX: DUK_UNREACHABLE for msvc? */
  1129. #undef DUK_USE_BRANCH_HINTS
  1130. /* XXX: DUK_LIKELY, DUK_UNLIKELY for msvc? */
  1131. /* XXX: DUK_NOINLINE, DUK_INLINE, DUK_ALWAYS_INLINE for msvc? */
  1132. #if defined(DUK_F_DLL_BUILD) && defined(DUK_F_WINDOWS)
  1133. /* MSVC dllexport/dllimport: appropriate __declspec depends on whether we're
  1134. * compiling Duktape or the application.
  1135. */
  1136. #if defined(DUK_COMPILING_DUKTAPE)
  1137. #define DUK_EXTERNAL_DECL extern __declspec(dllexport)
  1138. #define DUK_EXTERNAL __declspec(dllexport)
  1139. #else
  1140. #define DUK_EXTERNAL_DECL extern __declspec(dllimport)
  1141. #define DUK_EXTERNAL should_not_happen
  1142. #endif
  1143. #if defined(DUK_SINGLE_FILE)
  1144. #define DUK_INTERNAL_DECL static
  1145. #define DUK_INTERNAL static
  1146. #else
  1147. #define DUK_INTERNAL_DECL extern
  1148. #define DUK_INTERNAL /*empty*/
  1149. #endif
  1150. #define DUK_LOCAL_DECL static
  1151. #define DUK_LOCAL static
  1152. #endif
  1153. #if defined(DUK_F_CPP)
  1154. #define DUK_USE_COMPILER_STRING "msvc++"
  1155. #else
  1156. #define DUK_USE_COMPILER_STRING "msvc"
  1157. #endif
  1158. #undef DUK_USE_VARIADIC_MACROS
  1159. #if defined(DUK_F_C99)
  1160. #define DUK_USE_VARIADIC_MACROS
  1161. #elif defined(_MSC_VER) && (_MSC_VER >= 1400)
  1162. /* VS2005+ should have variadic macros even when they're not C99. */
  1163. #define DUK_USE_VARIADIC_MACROS
  1164. #endif
  1165. #undef DUK_USE_UNION_INITIALIZERS
  1166. #if defined(_MSC_VER) && (_MSC_VER >= 1800)
  1167. /* VS2013+ supports union initializers but there's a bug involving union-inside-struct:
  1168. * https://connect.microsoft.com/VisualStudio/feedback/details/805981
  1169. * The bug was fixed (at least) in VS2015 so check for VS2015 for now:
  1170. * https://blogs.msdn.microsoft.com/vcblog/2015/07/01/c-compiler-front-end-fixes-in-vs2015/
  1171. * Manually tested using VS2013, CL reports 18.00.31101, so enable for VS2013 too.
  1172. */
  1173. #define DUK_USE_UNION_INITIALIZERS
  1174. #endif
  1175. #undef DUK_USE_FLEX_C99
  1176. #undef DUK_USE_FLEX_ZEROSIZE
  1177. #undef DUK_USE_FLEX_ONESIZE
  1178. #if defined(DUK_F_C99)
  1179. #define DUK_USE_FLEX_C99
  1180. #else
  1181. #define DUK_USE_FLEX_ZEROSIZE
  1182. #endif
  1183. #undef DUK_USE_GCC_PRAGMAS
  1184. #define DUK_USE_PACK_MSVC_PRAGMA
  1185. /* These have been tested from VS2008 onwards; may work in older VS versions
  1186. * too but not enabled by default.
  1187. */
  1188. #if defined(_MSC_VER) && (_MSC_VER >= 1500)
  1189. #define DUK_NOINLINE __declspec(noinline)
  1190. #define DUK_INLINE __inline
  1191. #define DUK_ALWAYS_INLINE __forceinline
  1192. #endif
  1193. #if defined(_MSC_VER) && (_MSC_VER >= 1900)
  1194. #define DUK_SNPRINTF snprintf
  1195. #define DUK_VSNPRINTF vsnprintf
  1196. #else
  1197. /* (v)snprintf() is missing before MSVC 2015. Note that _(v)snprintf() does
  1198. * NOT NUL terminate on truncation, but Duktape code never assumes that.
  1199. * http://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010
  1200. */
  1201. #define DUK_SNPRINTF _snprintf
  1202. #define DUK_VSNPRINTF _vsnprintf
  1203. #endif
  1204. /* Avoid warning when doing DUK_UNREF(some_function). */
  1205. #if defined(_MSC_VER) && (_MSC_VER < 1500)
  1206. #pragma warning(disable: 4100 4101 4550 4551)
  1207. #define DUK_UNREF(x)
  1208. #else
  1209. #define DUK_UNREF(x) do { __pragma(warning(suppress:4100 4101 4550 4551)) (x); } while (0)
  1210. #endif
  1211. /* Older versions of MSVC don't support the LL/ULL suffix. */
  1212. #define DUK_U64_CONSTANT(x) x##ui64
  1213. #define DUK_I64_CONSTANT(x) x##i64
  1214. #elif defined(DUK_F_EMSCRIPTEN)
  1215. /* --- Emscripten --- */
  1216. #define DUK_NORETURN(decl) decl __attribute__((noreturn))
  1217. #if defined(__clang__) && defined(__has_builtin)
  1218. #if __has_builtin(__builtin_unreachable)
  1219. #define DUK_UNREACHABLE() do { __builtin_unreachable(); } while (0)
  1220. #endif
  1221. #endif
  1222. #define DUK_USE_BRANCH_HINTS
  1223. #define DUK_LIKELY(x) __builtin_expect((x), 1)
  1224. #define DUK_UNLIKELY(x) __builtin_expect((x), 0)
  1225. #if defined(__clang__) && defined(__has_builtin)
  1226. #if __has_builtin(__builtin_unpredictable)
  1227. #define DUK_UNPREDICTABLE(x) __builtin_unpredictable((x))
  1228. #endif
  1229. #endif
  1230. #if defined(DUK_F_C99) || defined(DUK_F_CPP11)
  1231. #define DUK_NOINLINE __attribute__((noinline))
  1232. #define DUK_INLINE inline
  1233. #define DUK_ALWAYS_INLINE inline __attribute__((always_inline))
  1234. #endif
  1235. #define DUK_EXTERNAL_DECL __attribute__ ((visibility("default"))) extern
  1236. #define DUK_EXTERNAL __attribute__ ((visibility("default")))
  1237. #if defined(DUK_SINGLE_FILE)
  1238. #if (defined(DUK_F_GCC_VERSION) && DUK_F_GCC_VERSION >= 30101) || defined(DUK_F_CLANG)
  1239. /* Minimize warnings for unused internal functions with GCC >= 3.1.1 and
  1240. * Clang. Based on documentation it should suffice to have the attribute
  1241. * in the declaration only, but in practice some warnings are generated unless
  1242. * the attribute is also applied to the definition.
  1243. */
  1244. #define DUK_INTERNAL_DECL static __attribute__ ((unused))
  1245. #define DUK_INTERNAL static __attribute__ ((unused))
  1246. #else
  1247. #define DUK_INTERNAL_DECL static
  1248. #define DUK_INTERNAL static
  1249. #endif
  1250. #else
  1251. #if (defined(DUK_F_GCC_VERSION) && DUK_F_GCC_VERSION >= 30101) || defined(DUK_F_CLANG)
  1252. #define DUK_INTERNAL_DECL __attribute__ ((visibility("hidden"))) __attribute__ ((unused)) extern
  1253. #define DUK_INTERNAL __attribute__ ((visibility("hidden"))) __attribute__ ((unused))
  1254. #else
  1255. #define DUK_INTERNAL_DECL __attribute__ ((visibility("hidden"))) extern
  1256. #define DUK_INTERNAL __attribute__ ((visibility("hidden")))
  1257. #endif
  1258. #endif
  1259. #define DUK_LOCAL_DECL static
  1260. #define DUK_LOCAL static
  1261. #define DUK_USE_COMPILER_STRING "emscripten"
  1262. #undef DUK_USE_VARIADIC_MACROS
  1263. #if defined(DUK_F_C99) || defined(DUK_F_CPP11)
  1264. #define DUK_USE_VARIADIC_MACROS
  1265. #endif
  1266. #define DUK_USE_UNION_INITIALIZERS
  1267. #undef DUK_USE_FLEX_C99
  1268. #undef DUK_USE_FLEX_ZEROSIZE
  1269. #undef DUK_USE_FLEX_ONESIZE
  1270. #if defined(DUK_F_C99)
  1271. #define DUK_USE_FLEX_C99
  1272. #else
  1273. #define DUK_USE_FLEX_ZEROSIZE
  1274. #endif
  1275. #undef DUK_USE_GCC_PRAGMAS
  1276. #define DUK_USE_PACK_CLANG_ATTR
  1277. #elif defined(DUK_F_TINYC)
  1278. /* --- TinyC --- */
  1279. #undef DUK_USE_BRANCH_HINTS
  1280. #if defined(DUK_F_CPP)
  1281. #define DUK_USE_COMPILER_STRING "tinyc++"
  1282. #else
  1283. #define DUK_USE_COMPILER_STRING "tinyc"
  1284. #endif
  1285. /* http://bellard.org/tcc/tcc-doc.html#SEC7 */
  1286. #define DUK_USE_VARIADIC_MACROS
  1287. #define DUK_USE_UNION_INITIALIZERS
  1288. /* Most portable, wastes space */
  1289. #define DUK_USE_FLEX_ONESIZE
  1290. /* Most portable, potentially wastes space */
  1291. #define DUK_USE_PACK_DUMMY_MEMBER
  1292. #elif defined(DUK_F_VBCC)
  1293. /* --- VBCC --- */
  1294. #undef DUK_USE_BRANCH_HINTS
  1295. #if defined(DUK_F_CPP)
  1296. #define DUK_USE_COMPILER_STRING "vbcc-c++"
  1297. #else
  1298. #define DUK_USE_COMPILER_STRING "vbcc"
  1299. #endif
  1300. #undef DUK_USE_VARIADIC_MACROS
  1301. #if defined(DUK_F_C99) || defined(DUK_F_CPP11)
  1302. #define DUK_USE_VARIADIC_MACROS
  1303. #endif
  1304. /* VBCC supports C99 so check only for C99 for union initializer support.
  1305. * Designated union initializers would possibly work even without a C99 check.
  1306. */
  1307. #undef DUK_USE_UNION_INITIALIZERS
  1308. #if defined(DUK_F_C99)
  1309. #define DUK_USE_UNION_INITIALIZERS
  1310. #endif
  1311. #define DUK_USE_FLEX_ZEROSIZE
  1312. #define DUK_USE_PACK_DUMMY_MEMBER
  1313. #elif defined(DUK_F_BCC)
  1314. /* --- Bruce's C compiler --- */
  1315. #undef DUK_USE_BRANCH_HINTS
  1316. #if defined(DUK_F_CPP)
  1317. #define DUK_USE_COMPILER_STRING "bcc++"
  1318. #else
  1319. #define DUK_USE_COMPILER_STRING "bcc"
  1320. #endif
  1321. /* Most portable */
  1322. #undef DUK_USE_VARIADIC_MACROS
  1323. /* Most portable, wastes space */
  1324. #undef DUK_USE_UNION_INITIALIZERS
  1325. /* Most portable, wastes space */
  1326. #define DUK_USE_FLEX_ONESIZE
  1327. /* Most portable, potentially wastes space */
  1328. #define DUK_USE_PACK_DUMMY_MEMBER
  1329. /* BCC, assume we're on x86. */
  1330. #if !defined(DUK_USE_BYTEORDER)
  1331. #define DUK_USE_BYTEORDER 1
  1332. #endif
  1333. #else
  1334. /* --- Generic --- */
  1335. #undef DUK_USE_BRANCH_HINTS
  1336. #if defined(DUK_F_CPP)
  1337. #define DUK_USE_COMPILER_STRING "generic-c++"
  1338. #else
  1339. #define DUK_USE_COMPILER_STRING "generic"
  1340. #endif
  1341. #undef DUK_USE_VARIADIC_MACROS
  1342. #if defined(DUK_F_C99) || defined(DUK_F_CPP11)
  1343. #define DUK_USE_VARIADIC_MACROS
  1344. #endif
  1345. /* C++ doesn't have standard designated union initializers ({ .foo = 1 }). */
  1346. #undef DUK_USE_UNION_INITIALIZERS
  1347. #if defined(DUK_F_C99)
  1348. #define DUK_USE_UNION_INITIALIZERS
  1349. #endif
  1350. /* Most portable, wastes space */
  1351. #define DUK_USE_FLEX_ONESIZE
  1352. /* Most portable, potentially wastes space */
  1353. #define DUK_USE_PACK_DUMMY_MEMBER
  1354. #endif /* autodetect compiler */
  1355. /* uclibc */
  1356. #if defined(__UCLIBC__)
  1357. #define DUK_F_UCLIBC
  1358. #endif
  1359. /*
  1360. * Wrapper typedefs and constants for integer types, also sanity check types.
  1361. *
  1362. * C99 typedefs are quite good but not always available, and we want to avoid
  1363. * forcibly redefining the C99 typedefs. So, there are Duktape wrappers for
  1364. * all C99 typedefs and Duktape code should only use these typedefs. Type
  1365. * detection when C99 is not supported is best effort and may end up detecting
  1366. * some types incorrectly.
  1367. *
  1368. * Pointer sizes are a portability problem: pointers to different types may
  1369. * have a different size and function pointers are very difficult to manage
  1370. * portably.
  1371. *
  1372. * http://en.wikipedia.org/wiki/C_data_types#Fixed-width_integer_types
  1373. *
  1374. * Note: there's an interesting corner case when trying to define minimum
  1375. * signed integer value constants which leads to the current workaround of
  1376. * defining e.g. -0x80000000 as (-0x7fffffffL - 1L). See doc/code-issues.txt
  1377. * for a longer discussion.
  1378. *
  1379. * Note: avoid typecasts and computations in macro integer constants as they
  1380. * can then no longer be used in macro relational expressions (such as
  1381. * #if DUK_SIZE_MAX < 0xffffffffUL). There is internal code which relies on
  1382. * being able to compare DUK_SIZE_MAX against a limit.
  1383. */
  1384. /* XXX: add feature options to force basic types from outside? */
  1385. #if !defined(INT_MAX)
  1386. #error INT_MAX not defined
  1387. #endif
  1388. /* Check that architecture is two's complement, standard C allows e.g.
  1389. * INT_MIN to be -2**31+1 (instead of -2**31).
  1390. */
  1391. #if defined(INT_MAX) && defined(INT_MIN)
  1392. #if INT_MAX != -(INT_MIN + 1)
  1393. #error platform does not seem complement of two
  1394. #endif
  1395. #else
  1396. #error cannot check complement of two
  1397. #endif
  1398. /* Pointer size determination based on __WORDSIZE or architecture when
  1399. * that's not available.
  1400. */
  1401. #if defined(DUK_F_X86) || defined(DUK_F_X32) || \
  1402. defined(DUK_F_M68K) || defined(DUK_F_PPC32) || \
  1403. defined(DUK_F_BCC) || \
  1404. (defined(__WORDSIZE) && (__WORDSIZE == 32)) || \
  1405. ((defined(DUK_F_OLD_SOLARIS) || defined(DUK_F_AIX) || \
  1406. defined(DUK_F_HPUX)) && defined(_ILP32)) || \
  1407. defined(DUK_F_ARM32)
  1408. #define DUK_F_32BIT_PTRS
  1409. #elif defined(DUK_F_X64) || \
  1410. (defined(__WORDSIZE) && (__WORDSIZE == 64)) || \
  1411. ((defined(DUK_F_OLD_SOLARIS) || defined(DUK_F_AIX) || \
  1412. defined(DUK_F_HPUX)) && defined(_LP64)) || \
  1413. defined(DUK_F_ARM64)
  1414. #define DUK_F_64BIT_PTRS
  1415. #else
  1416. /* not sure, not needed with C99 anyway */
  1417. #endif
  1418. /* Intermediate define for 'have inttypes.h' */
  1419. #undef DUK_F_HAVE_INTTYPES
  1420. #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
  1421. !(defined(DUK_F_AMIGAOS) && defined(DUK_F_VBCC))
  1422. /* vbcc + AmigaOS has C99 but no inttypes.h */
  1423. #define DUK_F_HAVE_INTTYPES
  1424. #elif defined(__cplusplus) && (__cplusplus >= 201103L)
  1425. /* C++11 apparently ratified stdint.h */
  1426. #define DUK_F_HAVE_INTTYPES
  1427. #endif
  1428. /* Basic integer typedefs and limits, preferably from inttypes.h, otherwise
  1429. * through automatic detection.
  1430. */
  1431. #if defined(DUK_F_HAVE_INTTYPES)
  1432. /* C99 or compatible */
  1433. #define DUK_F_HAVE_64BIT
  1434. #include <inttypes.h>
  1435. typedef uint8_t duk_uint8_t;
  1436. typedef int8_t duk_int8_t;
  1437. typedef uint16_t duk_uint16_t;
  1438. typedef int16_t duk_int16_t;
  1439. typedef uint32_t duk_uint32_t;
  1440. typedef int32_t duk_int32_t;
  1441. typedef uint64_t duk_uint64_t;
  1442. typedef int64_t duk_int64_t;
  1443. typedef uint_least8_t duk_uint_least8_t;
  1444. typedef int_least8_t duk_int_least8_t;
  1445. typedef uint_least16_t duk_uint_least16_t;
  1446. typedef int_least16_t duk_int_least16_t;
  1447. typedef uint_least32_t duk_uint_least32_t;
  1448. typedef int_least32_t duk_int_least32_t;
  1449. typedef uint_least64_t duk_uint_least64_t;
  1450. typedef int_least64_t duk_int_least64_t;
  1451. typedef uint_fast8_t duk_uint_fast8_t;
  1452. typedef int_fast8_t duk_int_fast8_t;
  1453. typedef uint_fast16_t duk_uint_fast16_t;
  1454. typedef int_fast16_t duk_int_fast16_t;
  1455. typedef uint_fast32_t duk_uint_fast32_t;
  1456. typedef int_fast32_t duk_int_fast32_t;
  1457. typedef uint_fast64_t duk_uint_fast64_t;
  1458. typedef int_fast64_t duk_int_fast64_t;
  1459. typedef uintptr_t duk_uintptr_t;
  1460. typedef intptr_t duk_intptr_t;
  1461. typedef uintmax_t duk_uintmax_t;
  1462. typedef intmax_t duk_intmax_t;
  1463. #define DUK_UINT8_MIN 0
  1464. #define DUK_UINT8_MAX UINT8_MAX
  1465. #define DUK_INT8_MIN INT8_MIN
  1466. #define DUK_INT8_MAX INT8_MAX
  1467. #define DUK_UINT_LEAST8_MIN 0
  1468. #define DUK_UINT_LEAST8_MAX UINT_LEAST8_MAX
  1469. #define DUK_INT_LEAST8_MIN INT_LEAST8_MIN
  1470. #define DUK_INT_LEAST8_MAX INT_LEAST8_MAX
  1471. #define DUK_UINT_FAST8_MIN 0
  1472. #define DUK_UINT_FAST8_MAX UINT_FAST8_MAX
  1473. #define DUK_INT_FAST8_MIN INT_FAST8_MIN
  1474. #define DUK_INT_FAST8_MAX INT_FAST8_MAX
  1475. #define DUK_UINT16_MIN 0
  1476. #define DUK_UINT16_MAX UINT16_MAX
  1477. #define DUK_INT16_MIN INT16_MIN
  1478. #define DUK_INT16_MAX INT16_MAX
  1479. #define DUK_UINT_LEAST16_MIN 0
  1480. #define DUK_UINT_LEAST16_MAX UINT_LEAST16_MAX
  1481. #define DUK_INT_LEAST16_MIN INT_LEAST16_MIN
  1482. #define DUK_INT_LEAST16_MAX INT_LEAST16_MAX
  1483. #define DUK_UINT_FAST16_MIN 0
  1484. #define DUK_UINT_FAST16_MAX UINT_FAST16_MAX
  1485. #define DUK_INT_FAST16_MIN INT_FAST16_MIN
  1486. #define DUK_INT_FAST16_MAX INT_FAST16_MAX
  1487. #define DUK_UINT32_MIN 0
  1488. #define DUK_UINT32_MAX UINT32_MAX
  1489. #define DUK_INT32_MIN INT32_MIN
  1490. #define DUK_INT32_MAX INT32_MAX
  1491. #define DUK_UINT_LEAST32_MIN 0
  1492. #define DUK_UINT_LEAST32_MAX UINT_LEAST32_MAX
  1493. #define DUK_INT_LEAST32_MIN INT_LEAST32_MIN
  1494. #define DUK_INT_LEAST32_MAX INT_LEAST32_MAX
  1495. #define DUK_UINT_FAST32_MIN 0
  1496. #define DUK_UINT_FAST32_MAX UINT_FAST32_MAX
  1497. #define DUK_INT_FAST32_MIN INT_FAST32_MIN
  1498. #define DUK_INT_FAST32_MAX INT_FAST32_MAX
  1499. #define DUK_UINT64_MIN 0
  1500. #define DUK_UINT64_MAX UINT64_MAX
  1501. #define DUK_INT64_MIN INT64_MIN
  1502. #define DUK_INT64_MAX INT64_MAX
  1503. #define DUK_UINT_LEAST64_MIN 0
  1504. #define DUK_UINT_LEAST64_MAX UINT_LEAST64_MAX
  1505. #define DUK_INT_LEAST64_MIN INT_LEAST64_MIN
  1506. #define DUK_INT_LEAST64_MAX INT_LEAST64_MAX
  1507. #define DUK_UINT_FAST64_MIN 0
  1508. #define DUK_UINT_FAST64_MAX UINT_FAST64_MAX
  1509. #define DUK_INT_FAST64_MIN INT_FAST64_MIN
  1510. #define DUK_INT_FAST64_MAX INT_FAST64_MAX
  1511. #define DUK_UINTPTR_MIN 0
  1512. #define DUK_UINTPTR_MAX UINTPTR_MAX
  1513. #define DUK_INTPTR_MIN INTPTR_MIN
  1514. #define DUK_INTPTR_MAX INTPTR_MAX
  1515. #define DUK_UINTMAX_MIN 0
  1516. #define DUK_UINTMAX_MAX UINTMAX_MAX
  1517. #define DUK_INTMAX_MIN INTMAX_MIN
  1518. #define DUK_INTMAX_MAX INTMAX_MAX
  1519. #define DUK_SIZE_MIN 0
  1520. #define DUK_SIZE_MAX SIZE_MAX
  1521. #undef DUK_SIZE_MAX_COMPUTED
  1522. #else /* C99 types */
  1523. /* When C99 types are not available, we use heuristic detection to get
  1524. * the basic 8, 16, 32, and (possibly) 64 bit types. The fast/least
  1525. * types are then assumed to be exactly the same for now: these could
  1526. * be improved per platform but C99 types are very often now available.
  1527. * 64-bit types are not available on all platforms; this is OK at least
  1528. * on 32-bit platforms.
  1529. *
  1530. * This detection code is necessarily a bit hacky and can provide typedefs
  1531. * and defines that won't work correctly on some exotic platform.
  1532. */
  1533. #if (defined(CHAR_BIT) && (CHAR_BIT == 8)) || \
  1534. (defined(UCHAR_MAX) && (UCHAR_MAX == 255))
  1535. typedef unsigned char duk_uint8_t;
  1536. typedef signed char duk_int8_t;
  1537. #else
  1538. #error cannot detect 8-bit type
  1539. #endif
  1540. #if defined(USHRT_MAX) && (USHRT_MAX == 65535UL)
  1541. typedef unsigned short duk_uint16_t;
  1542. typedef signed short duk_int16_t;
  1543. #elif defined(UINT_MAX) && (UINT_MAX == 65535UL)
  1544. /* On some platforms int is 16-bit but long is 32-bit (e.g. PureC) */
  1545. typedef unsigned int duk_uint16_t;
  1546. typedef signed int duk_int16_t;
  1547. #else
  1548. #error cannot detect 16-bit type
  1549. #endif
  1550. #if defined(UINT_MAX) && (UINT_MAX == 4294967295UL)
  1551. typedef unsigned int duk_uint32_t;
  1552. typedef signed int duk_int32_t;
  1553. #elif defined(ULONG_MAX) && (ULONG_MAX == 4294967295UL)
  1554. /* On some platforms int is 16-bit but long is 32-bit (e.g. PureC) */
  1555. typedef unsigned long duk_uint32_t;
  1556. typedef signed long duk_int32_t;
  1557. #else
  1558. #error cannot detect 32-bit type
  1559. #endif
  1560. /* 64-bit type detection is a bit tricky.
  1561. *
  1562. * ULLONG_MAX is a standard define. __LONG_LONG_MAX__ and __ULONG_LONG_MAX__
  1563. * are used by at least GCC (even if system headers don't provide ULLONG_MAX).
  1564. * Some GCC variants may provide __LONG_LONG_MAX__ but not __ULONG_LONG_MAX__.
  1565. *
  1566. * ULL / LL constants are rejected / warned about by some compilers, even if
  1567. * the compiler has a 64-bit type and the compiler/system headers provide an
  1568. * unsupported constant (ULL/LL)! Try to avoid using ULL / LL constants.
  1569. * As a side effect we can only check that e.g. ULONG_MAX is larger than 32
  1570. * bits but can't be sure it is exactly 64 bits. Self tests will catch such
  1571. * cases.
  1572. */
  1573. #undef DUK_F_HAVE_64BIT
  1574. #if !defined(DUK_F_HAVE_64BIT) && defined(ULONG_MAX)
  1575. #if (ULONG_MAX > 4294967295UL)
  1576. #define DUK_F_HAVE_64BIT
  1577. typedef unsigned long duk_uint64_t;
  1578. typedef signed long duk_int64_t;
  1579. #endif
  1580. #endif
  1581. #if !defined(DUK_F_HAVE_64BIT) && defined(ULLONG_MAX)
  1582. #if (ULLONG_MAX > 4294967295UL)
  1583. #define DUK_F_HAVE_64BIT
  1584. typedef unsigned long long duk_uint64_t;
  1585. typedef signed long long duk_int64_t;
  1586. #endif
  1587. #endif
  1588. #if !defined(DUK_F_HAVE_64BIT) && defined(__ULONG_LONG_MAX__)
  1589. #if (__ULONG_LONG_MAX__ > 4294967295UL)
  1590. #define DUK_F_HAVE_64BIT
  1591. typedef unsigned long long duk_uint64_t;
  1592. typedef signed long long duk_int64_t;
  1593. #endif
  1594. #endif
  1595. #if !defined(DUK_F_HAVE_64BIT) && defined(__LONG_LONG_MAX__)
  1596. #if (__LONG_LONG_MAX__ > 2147483647L)
  1597. #define DUK_F_HAVE_64BIT
  1598. typedef unsigned long long duk_uint64_t;
  1599. typedef signed long long duk_int64_t;
  1600. #endif
  1601. #endif
  1602. #if !defined(DUK_F_HAVE_64BIT) && defined(DUK_F_MINGW)
  1603. #define DUK_F_HAVE_64BIT
  1604. typedef unsigned long duk_uint64_t;
  1605. typedef signed long duk_int64_t;
  1606. #endif
  1607. #if !defined(DUK_F_HAVE_64BIT) && defined(DUK_F_MSVC)
  1608. #define DUK_F_HAVE_64BIT
  1609. typedef unsigned __int64 duk_uint64_t;
  1610. typedef signed __int64 duk_int64_t;
  1611. #endif
  1612. #if !defined(DUK_F_HAVE_64BIT)
  1613. /* cannot detect 64-bit type, not always needed so don't error */
  1614. #endif
  1615. typedef duk_uint8_t duk_uint_least8_t;
  1616. typedef duk_int8_t duk_int_least8_t;
  1617. typedef duk_uint16_t duk_uint_least16_t;
  1618. typedef duk_int16_t duk_int_least16_t;
  1619. typedef duk_uint32_t duk_uint_least32_t;
  1620. typedef duk_int32_t duk_int_least32_t;
  1621. typedef duk_uint8_t duk_uint_fast8_t;
  1622. typedef duk_int8_t duk_int_fast8_t;
  1623. typedef duk_uint16_t duk_uint_fast16_t;
  1624. typedef duk_int16_t duk_int_fast16_t;
  1625. typedef duk_uint32_t duk_uint_fast32_t;
  1626. typedef duk_int32_t duk_int_fast32_t;
  1627. #if defined(DUK_F_HAVE_64BIT)
  1628. typedef duk_uint64_t duk_uint_least64_t;
  1629. typedef duk_int64_t duk_int_least64_t;
  1630. typedef duk_uint64_t duk_uint_fast64_t;
  1631. typedef duk_int64_t duk_int_fast64_t;
  1632. #endif
  1633. #if defined(DUK_F_HAVE_64BIT)
  1634. typedef duk_uint64_t duk_uintmax_t;
  1635. typedef duk_int64_t duk_intmax_t;
  1636. #else
  1637. typedef duk_uint32_t duk_uintmax_t;
  1638. typedef duk_int32_t duk_intmax_t;
  1639. #endif
  1640. /* Note: the funny looking computations for signed minimum 16-bit, 32-bit, and
  1641. * 64-bit values are intentional as the obvious forms (e.g. -0x80000000L) are
  1642. * -not- portable. See code-issues.txt for a detailed discussion.
  1643. */
  1644. #define DUK_UINT8_MIN 0UL
  1645. #define DUK_UINT8_MAX 0xffUL
  1646. #define DUK_INT8_MIN (-0x80L)
  1647. #define DUK_INT8_MAX 0x7fL
  1648. #define DUK_UINT_LEAST8_MIN 0UL
  1649. #define DUK_UINT_LEAST8_MAX 0xffUL
  1650. #define DUK_INT_LEAST8_MIN (-0x80L)
  1651. #define DUK_INT_LEAST8_MAX 0x7fL
  1652. #define DUK_UINT_FAST8_MIN 0UL
  1653. #define DUK_UINT_FAST8_MAX 0xffUL
  1654. #define DUK_INT_FAST8_MIN (-0x80L)
  1655. #define DUK_INT_FAST8_MAX 0x7fL
  1656. #define DUK_UINT16_MIN 0UL
  1657. #define DUK_UINT16_MAX 0xffffUL
  1658. #define DUK_INT16_MIN (-0x7fffL - 1L)
  1659. #define DUK_INT16_MAX 0x7fffL
  1660. #define DUK_UINT_LEAST16_MIN 0UL
  1661. #define DUK_UINT_LEAST16_MAX 0xffffUL
  1662. #define DUK_INT_LEAST16_MIN (-0x7fffL - 1L)
  1663. #define DUK_INT_LEAST16_MAX 0x7fffL
  1664. #define DUK_UINT_FAST16_MIN 0UL
  1665. #define DUK_UINT_FAST16_MAX 0xffffUL
  1666. #define DUK_INT_FAST16_MIN (-0x7fffL - 1L)
  1667. #define DUK_INT_FAST16_MAX 0x7fffL
  1668. #define DUK_UINT32_MIN 0UL
  1669. #define DUK_UINT32_MAX 0xffffffffUL
  1670. #define DUK_INT32_MIN (-0x7fffffffL - 1L)
  1671. #define DUK_INT32_MAX 0x7fffffffL
  1672. #define DUK_UINT_LEAST32_MIN 0UL
  1673. #define DUK_UINT_LEAST32_MAX 0xffffffffUL
  1674. #define DUK_INT_LEAST32_MIN (-0x7fffffffL - 1L)
  1675. #define DUK_INT_LEAST32_MAX 0x7fffffffL
  1676. #define DUK_UINT_FAST32_MIN 0UL
  1677. #define DUK_UINT_FAST32_MAX 0xffffffffUL
  1678. #define DUK_INT_FAST32_MIN (-0x7fffffffL - 1L)
  1679. #define DUK_INT_FAST32_MAX 0x7fffffffL
  1680. /* 64-bit constants. Since LL / ULL constants are not always available,
  1681. * use computed values. These values can't be used in preprocessor
  1682. * comparisons; flag them as such.
  1683. */
  1684. #if defined(DUK_F_HAVE_64BIT)
  1685. #define DUK_UINT64_MIN ((duk_uint64_t) 0)
  1686. #define DUK_UINT64_MAX ((duk_uint64_t) -1)
  1687. #define DUK_INT64_MIN ((duk_int64_t) (~(DUK_UINT64_MAX >> 1)))
  1688. #define DUK_INT64_MAX ((duk_int64_t) (DUK_UINT64_MAX >> 1))
  1689. #define DUK_UINT_LEAST64_MIN DUK_UINT64_MIN
  1690. #define DUK_UINT_LEAST64_MAX DUK_UINT64_MAX
  1691. #define DUK_INT_LEAST64_MIN DUK_INT64_MIN
  1692. #define DUK_INT_LEAST64_MAX DUK_INT64_MAX
  1693. #define DUK_UINT_FAST64_MIN DUK_UINT64_MIN
  1694. #define DUK_UINT_FAST64_MAX DUK_UINT64_MAX
  1695. #define DUK_INT_FAST64_MIN DUK_INT64_MIN
  1696. #define DUK_INT_FAST64_MAX DUK_INT64_MAX
  1697. #define DUK_UINT64_MIN_COMPUTED
  1698. #define DUK_UINT64_MAX_COMPUTED
  1699. #define DUK_INT64_MIN_COMPUTED
  1700. #define DUK_INT64_MAX_COMPUTED
  1701. #define DUK_UINT_LEAST64_MIN_COMPUTED
  1702. #define DUK_UINT_LEAST64_MAX_COMPUTED
  1703. #define DUK_INT_LEAST64_MIN_COMPUTED
  1704. #define DUK_INT_LEAST64_MAX_COMPUTED
  1705. #define DUK_UINT_FAST64_MIN_COMPUTED
  1706. #define DUK_UINT_FAST64_MAX_COMPUTED
  1707. #define DUK_INT_FAST64_MIN_COMPUTED
  1708. #define DUK_INT_FAST64_MAX_COMPUTED
  1709. #endif
  1710. #if defined(DUK_F_HAVE_64BIT)
  1711. #define DUK_UINTMAX_MIN DUK_UINT64_MIN
  1712. #define DUK_UINTMAX_MAX DUK_UINT64_MAX
  1713. #define DUK_INTMAX_MIN DUK_INT64_MIN
  1714. #define DUK_INTMAX_MAX DUK_INT64_MAX
  1715. #define DUK_UINTMAX_MIN_COMPUTED
  1716. #define DUK_UINTMAX_MAX_COMPUTED
  1717. #define DUK_INTMAX_MIN_COMPUTED
  1718. #define DUK_INTMAX_MAX_COMPUTED
  1719. #else
  1720. #define DUK_UINTMAX_MIN 0UL
  1721. #define DUK_UINTMAX_MAX 0xffffffffUL
  1722. #define DUK_INTMAX_MIN (-0x7fffffffL - 1L)
  1723. #define DUK_INTMAX_MAX 0x7fffffffL
  1724. #endif
  1725. /* This detection is not very reliable. */
  1726. #if defined(DUK_F_32BIT_PTRS)
  1727. typedef duk_int32_t duk_intptr_t;
  1728. typedef duk_uint32_t duk_uintptr_t;
  1729. #define DUK_UINTPTR_MIN DUK_UINT32_MIN
  1730. #define DUK_UINTPTR_MAX DUK_UINT32_MAX
  1731. #define DUK_INTPTR_MIN DUK_INT32_MIN
  1732. #define DUK_INTPTR_MAX DUK_INT32_MAX
  1733. #elif defined(DUK_F_64BIT_PTRS) && defined(DUK_F_HAVE_64BIT)
  1734. typedef duk_int64_t duk_intptr_t;
  1735. typedef duk_uint64_t duk_uintptr_t;
  1736. #define DUK_UINTPTR_MIN DUK_UINT64_MIN
  1737. #define DUK_UINTPTR_MAX DUK_UINT64_MAX
  1738. #define DUK_INTPTR_MIN DUK_INT64_MIN
  1739. #define DUK_INTPTR_MAX DUK_INT64_MAX
  1740. #define DUK_UINTPTR_MIN_COMPUTED
  1741. #define DUK_UINTPTR_MAX_COMPUTED
  1742. #define DUK_INTPTR_MIN_COMPUTED
  1743. #define DUK_INTPTR_MAX_COMPUTED
  1744. #else
  1745. #error cannot determine intptr type
  1746. #endif
  1747. /* SIZE_MAX may be missing so use an approximate value for it. */
  1748. #undef DUK_SIZE_MAX_COMPUTED
  1749. #if !defined(SIZE_MAX)
  1750. #define DUK_SIZE_MAX_COMPUTED
  1751. #define SIZE_MAX ((size_t) (-1))
  1752. #endif
  1753. #define DUK_SIZE_MIN 0
  1754. #define DUK_SIZE_MAX SIZE_MAX
  1755. #endif /* C99 types */
  1756. /* A few types are assumed to always exist. */
  1757. typedef size_t duk_size_t;
  1758. typedef ptrdiff_t duk_ptrdiff_t;
  1759. /* The best type for an "all around int" in Duktape internals is "at least
  1760. * 32 bit signed integer" which is most convenient. Same for unsigned type.
  1761. * Prefer 'int' when large enough, as it is almost always a convenient type.
  1762. */
  1763. #if defined(UINT_MAX) && (UINT_MAX >= 0xffffffffUL)
  1764. typedef int duk_int_t;
  1765. typedef unsigned int duk_uint_t;
  1766. #define DUK_INT_MIN INT_MIN
  1767. #define DUK_INT_MAX INT_MAX
  1768. #define DUK_UINT_MIN 0
  1769. #define DUK_UINT_MAX UINT_MAX
  1770. #else
  1771. typedef duk_int_fast32_t duk_int_t;
  1772. typedef duk_uint_fast32_t duk_uint_t;
  1773. #define DUK_INT_MIN DUK_INT_FAST32_MIN
  1774. #define DUK_INT_MAX DUK_INT_FAST32_MAX
  1775. #define DUK_UINT_MIN DUK_UINT_FAST32_MIN
  1776. #define DUK_UINT_MAX DUK_UINT_FAST32_MAX
  1777. #endif
  1778. /* Same as 'duk_int_t' but guaranteed to be a 'fast' variant if this
  1779. * distinction matters for the CPU. These types are used mainly in the
  1780. * executor where it might really matter.
  1781. */
  1782. typedef duk_int_fast32_t duk_int_fast_t;
  1783. typedef duk_uint_fast32_t duk_uint_fast_t;
  1784. #define DUK_INT_FAST_MIN DUK_INT_FAST32_MIN
  1785. #define DUK_INT_FAST_MAX DUK_INT_FAST32_MAX
  1786. #define DUK_UINT_FAST_MIN DUK_UINT_FAST32_MIN
  1787. #define DUK_UINT_FAST_MAX DUK_UINT_FAST32_MAX
  1788. /* Small integers (16 bits or more) can fall back to the 'int' type, but
  1789. * have a typedef so they are marked "small" explicitly.
  1790. */
  1791. typedef int duk_small_int_t;
  1792. typedef unsigned int duk_small_uint_t;
  1793. #define DUK_SMALL_INT_MIN INT_MIN
  1794. #define DUK_SMALL_INT_MAX INT_MAX
  1795. #define DUK_SMALL_UINT_MIN 0
  1796. #define DUK_SMALL_UINT_MAX UINT_MAX
  1797. /* Fast variants of small integers, again for really fast paths like the
  1798. * executor.
  1799. */
  1800. typedef duk_int_fast16_t duk_small_int_fast_t;
  1801. typedef duk_uint_fast16_t duk_small_uint_fast_t;
  1802. #define DUK_SMALL_INT_FAST_MIN DUK_INT_FAST16_MIN
  1803. #define DUK_SMALL_INT_FAST_MAX DUK_INT_FAST16_MAX
  1804. #define DUK_SMALL_UINT_FAST_MIN DUK_UINT_FAST16_MIN
  1805. #define DUK_SMALL_UINT_FAST_MAX DUK_UINT_FAST16_MAX
  1806. /* Boolean values are represented with the platform 'unsigned int'. */
  1807. typedef duk_small_uint_t duk_bool_t;
  1808. #define DUK_BOOL_MIN DUK_SMALL_INT_MIN
  1809. #define DUK_BOOL_MAX DUK_SMALL_INT_MAX
  1810. /* Index values must have at least 32-bit signed range. */
  1811. typedef duk_int_t duk_idx_t;
  1812. #define DUK_IDX_MIN DUK_INT_MIN
  1813. #define DUK_IDX_MAX DUK_INT_MAX
  1814. /* Unsigned index variant. */
  1815. typedef duk_uint_t duk_uidx_t;
  1816. #define DUK_UIDX_MIN DUK_UINT_MIN
  1817. #define DUK_UIDX_MAX DUK_UINT_MAX
  1818. /* Array index values, could be exact 32 bits.
  1819. * Currently no need for signed duk_arridx_t.
  1820. */
  1821. typedef duk_uint_t duk_uarridx_t;
  1822. #define DUK_UARRIDX_MIN DUK_UINT_MIN
  1823. #define DUK_UARRIDX_MAX DUK_UINT_MAX
  1824. /* Duktape/C function return value, platform int is enough for now to
  1825. * represent 0, 1, or negative error code. Must be compatible with
  1826. * assigning truth values (e.g. duk_ret_t rc = (foo == bar);).
  1827. */
  1828. typedef duk_small_int_t duk_ret_t;
  1829. #define DUK_RET_MIN DUK_SMALL_INT_MIN
  1830. #define DUK_RET_MAX DUK_SMALL_INT_MAX
  1831. /* Error codes are represented with platform int. High bits are used
  1832. * for flags and such, so 32 bits are needed.
  1833. */
  1834. typedef duk_int_t duk_errcode_t;
  1835. #define DUK_ERRCODE_MIN DUK_INT_MIN
  1836. #define DUK_ERRCODE_MAX DUK_INT_MAX
  1837. /* Codepoint type. Must be 32 bits or more because it is used also for
  1838. * internal codepoints. The type is signed because negative codepoints
  1839. * are used as internal markers (e.g. to mark EOF or missing argument).
  1840. * (X)UTF-8/CESU-8 encode/decode take and return an unsigned variant to
  1841. * ensure duk_uint32_t casts back and forth nicely. Almost everything
  1842. * else uses the signed one.
  1843. */
  1844. typedef duk_int_t duk_codepoint_t;
  1845. typedef duk_uint_t duk_ucodepoint_t;
  1846. #define DUK_CODEPOINT_MIN DUK_INT_MIN
  1847. #define DUK_CODEPOINT_MAX DUK_INT_MAX
  1848. #define DUK_UCODEPOINT_MIN DUK_UINT_MIN
  1849. #define DUK_UCODEPOINT_MAX DUK_UINT_MAX
  1850. /* IEEE float/double typedef. */
  1851. typedef float duk_float_t;
  1852. typedef double duk_double_t;
  1853. /* We're generally assuming that we're working on a platform with a 32-bit
  1854. * address space. If DUK_SIZE_MAX is a typecast value (which is necessary
  1855. * if SIZE_MAX is missing), the check must be avoided because the
  1856. * preprocessor can't do a comparison.
  1857. */
  1858. #if !defined(DUK_SIZE_MAX)
  1859. #error DUK_SIZE_MAX is undefined, probably missing SIZE_MAX
  1860. #elif !defined(DUK_SIZE_MAX_COMPUTED)
  1861. #if DUK_SIZE_MAX < 0xffffffffUL
  1862. /* On some systems SIZE_MAX can be smaller than max unsigned 32-bit value
  1863. * which seems incorrect if size_t is (at least) an unsigned 32-bit type.
  1864. * However, it doesn't seem useful to error out compilation if this is the
  1865. * case.
  1866. */
  1867. #endif
  1868. #endif
  1869. /* Type used in public API declarations and user code. Typedef maps to
  1870. * 'struct duk_hthread' like the 'duk_hthread' typedef which is used
  1871. * exclusively in internals.
  1872. */
  1873. typedef struct duk_hthread duk_context;
  1874. /* Check whether we should use 64-bit integers or not.
  1875. *
  1876. * Quite incomplete now. Use 64-bit types if detected (C99 or other detection)
  1877. * unless they are known to be unreliable. For instance, 64-bit types are
  1878. * available on VBCC but seem to misbehave.
  1879. */
  1880. #if defined(DUK_F_HAVE_64BIT) && !defined(DUK_F_VBCC)
  1881. #define DUK_USE_64BIT_OPS
  1882. #else
  1883. #undef DUK_USE_64BIT_OPS
  1884. #endif
  1885. /*
  1886. * Fill-ins for platform, architecture, and compiler
  1887. */
  1888. /* An abort()-like primitive is needed by the default fatal error handler. */
  1889. #if !defined(DUK_ABORT)
  1890. #define DUK_ABORT abort
  1891. #endif
  1892. #if !defined(DUK_SETJMP)
  1893. #define DUK_JMPBUF_TYPE jmp_buf
  1894. #define DUK_SETJMP(jb) setjmp((jb))
  1895. #define DUK_LONGJMP(jb) longjmp((jb), 1)
  1896. #endif
  1897. #if 0
  1898. /* sigsetjmp() alternative */
  1899. #define DUK_JMPBUF_TYPE sigjmp_buf
  1900. #define DUK_SETJMP(jb) sigsetjmp((jb))
  1901. #define DUK_LONGJMP(jb) siglongjmp((jb), 1)
  1902. #endif
  1903. /* Special naming to avoid conflict with e.g. DUK_FREE() in duk_heap.h
  1904. * (which is unfortunately named). May sometimes need replacement, e.g.
  1905. * some compilers don't handle zero length or NULL correctly in realloc().
  1906. */
  1907. #if !defined(DUK_ANSI_MALLOC)
  1908. #define DUK_ANSI_MALLOC malloc
  1909. #endif
  1910. #if !defined(DUK_ANSI_REALLOC)
  1911. #define DUK_ANSI_REALLOC realloc
  1912. #endif
  1913. #if !defined(DUK_ANSI_CALLOC)
  1914. #define DUK_ANSI_CALLOC calloc
  1915. #endif
  1916. #if !defined(DUK_ANSI_FREE)
  1917. #define DUK_ANSI_FREE free
  1918. #endif
  1919. /* ANSI C (various versions) and some implementations require that the
  1920. * pointer arguments to memset(), memcpy(), and memmove() be valid values
  1921. * even when byte size is 0 (even a NULL pointer is considered invalid in
  1922. * this context). Zero-size operations as such are allowed, as long as their
  1923. * pointer arguments point to a valid memory area. The DUK_MEMSET(),
  1924. * DUK_MEMCPY(), and DUK_MEMMOVE() macros require this same behavior, i.e.:
  1925. * (1) pointers must be valid and non-NULL, (2) zero size must otherwise be
  1926. * allowed. If these are not fulfilled, a macro wrapper is needed.
  1927. *
  1928. * http://stackoverflow.com/questions/5243012/is-it-guaranteed-to-be-safe-to-perform-memcpy0-0-0
  1929. * http://lists.cs.uiuc.edu/pipermail/llvmdev/2007-October/011065.html
  1930. *
  1931. * Not sure what's the required behavior when a pointer points just past the
  1932. * end of a buffer, which often happens in practice (e.g. zero size memmoves).
  1933. * For example, if allocation size is 3, the following pointer would not
  1934. * technically point to a valid memory byte:
  1935. *
  1936. * <-- alloc -->
  1937. * | 0 | 1 | 2 | .....
  1938. * ^-- p=3, points after last valid byte (2)
  1939. */
  1940. #if !defined(DUK_MEMCPY)
  1941. #if defined(DUK_F_UCLIBC)
  1942. /* Old uclibcs have a broken memcpy so use memmove instead (this is overly wide
  1943. * now on purpose): http://lists.uclibc.org/pipermail/uclibc-cvs/2008-October/025511.html
  1944. */
  1945. #define DUK_MEMCPY memmove
  1946. #else
  1947. #define DUK_MEMCPY memcpy
  1948. #endif
  1949. #endif
  1950. #if !defined(DUK_MEMMOVE)
  1951. #define DUK_MEMMOVE memmove
  1952. #endif
  1953. #if !defined(DUK_MEMCMP)
  1954. #define DUK_MEMCMP memcmp
  1955. #endif
  1956. #if !defined(DUK_MEMSET)
  1957. #define DUK_MEMSET memset
  1958. #endif
  1959. #if !defined(DUK_STRLEN)
  1960. #define DUK_STRLEN strlen
  1961. #endif
  1962. #if !defined(DUK_STRCMP)
  1963. #define DUK_STRCMP strcmp
  1964. #endif
  1965. #if !defined(DUK_STRNCMP)
  1966. #define DUK_STRNCMP strncmp
  1967. #endif
  1968. #if !defined(DUK_SPRINTF)
  1969. #define DUK_SPRINTF sprintf
  1970. #endif
  1971. #if !defined(DUK_SNPRINTF)
  1972. /* snprintf() is technically not part of C89 but usually available. */
  1973. #define DUK_SNPRINTF snprintf
  1974. #endif
  1975. #if !defined(DUK_VSPRINTF)
  1976. #define DUK_VSPRINTF vsprintf
  1977. #endif
  1978. #if !defined(DUK_VSNPRINTF)
  1979. /* vsnprintf() is technically not part of C89 but usually available. */
  1980. #define DUK_VSNPRINTF vsnprintf
  1981. #endif
  1982. #if !defined(DUK_SSCANF)
  1983. #define DUK_SSCANF sscanf
  1984. #endif
  1985. #if !defined(DUK_VSSCANF)
  1986. #define DUK_VSSCANF vsscanf
  1987. #endif
  1988. #if !defined(DUK_MEMZERO)
  1989. #define DUK_MEMZERO(p,n) DUK_MEMSET((p), 0, (n))
  1990. #endif
  1991. #if !defined(DUK_DOUBLE_INFINITY)
  1992. #undef DUK_USE_COMPUTED_INFINITY
  1993. #if defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION < 40600)
  1994. /* GCC older than 4.6: avoid overflow warnings related to using INFINITY */
  1995. #define DUK_DOUBLE_INFINITY (__builtin_inf())
  1996. #elif defined(INFINITY)
  1997. #define DUK_DOUBLE_INFINITY ((double) INFINITY)
  1998. #elif !defined(DUK_F_VBCC) && !defined(DUK_F_MSVC) && !defined(DUK_F_BCC) && \
  1999. !defined(DUK_F_OLD_SOLARIS) && !defined(DUK_F_AIX)
  2000. #define DUK_DOUBLE_INFINITY (1.0 / 0.0)
  2001. #else
  2002. /* In VBCC (1.0 / 0.0) results in a warning and 0.0 instead of infinity.
  2003. * Use a computed infinity (initialized when a heap is created at the
  2004. * latest).
  2005. */
  2006. #define DUK_USE_COMPUTED_INFINITY
  2007. #define DUK_DOUBLE_INFINITY duk_computed_infinity
  2008. #endif
  2009. #endif
  2010. #if !defined(DUK_DOUBLE_NAN)
  2011. #undef DUK_USE_COMPUTED_NAN
  2012. #if defined(NAN)
  2013. #define DUK_DOUBLE_NAN NAN
  2014. #elif !defined(DUK_F_VBCC) && !defined(DUK_F_MSVC) && !defined(DUK_F_BCC) && \
  2015. !defined(DUK_F_OLD_SOLARIS) && !defined(DUK_F_AIX)
  2016. #define DUK_DOUBLE_NAN (0.0 / 0.0)
  2017. #else
  2018. /* In VBCC (0.0 / 0.0) results in a warning and 0.0 instead of NaN.
  2019. * In MSVC (VS2010 Express) (0.0 / 0.0) results in a compile error.
  2020. * Use a computed NaN (initialized when a heap is created at the
  2021. * latest).
  2022. */
  2023. #define DUK_USE_COMPUTED_NAN
  2024. #define DUK_DOUBLE_NAN duk_computed_nan
  2025. #endif
  2026. #endif
  2027. /* Many platforms are missing fpclassify() and friends, so use replacements
  2028. * if necessary. The replacement constants (FP_NAN etc) can be anything but
  2029. * match Linux constants now.
  2030. */
  2031. #undef DUK_USE_REPL_FPCLASSIFY
  2032. #undef DUK_USE_REPL_SIGNBIT
  2033. #undef DUK_USE_REPL_ISFINITE
  2034. #undef DUK_USE_REPL_ISNAN
  2035. #undef DUK_USE_REPL_ISINF
  2036. /* Complex condition broken into separate parts. */
  2037. #undef DUK_F_USE_REPL_ALL
  2038. #if !(defined(FP_NAN) && defined(FP_INFINITE) && defined(FP_ZERO) && \
  2039. defined(FP_SUBNORMAL) && defined(FP_NORMAL))
  2040. /* Missing some obvious constants. */
  2041. #define DUK_F_USE_REPL_ALL
  2042. #elif defined(DUK_F_AMIGAOS) && defined(DUK_F_VBCC)
  2043. /* VBCC is missing the built-ins even in C99 mode (perhaps a header issue). */
  2044. #define DUK_F_USE_REPL_ALL
  2045. #elif defined(DUK_F_AMIGAOS) && defined(DUK_F_M68K)
  2046. /* AmigaOS + M68K seems to have math issues even when using GCC cross
  2047. * compilation. Use replacements for all AmigaOS versions on M68K
  2048. * regardless of compiler.
  2049. */
  2050. #define DUK_F_USE_REPL_ALL
  2051. #elif defined(DUK_F_FREEBSD) && defined(DUK_F_CLANG)
  2052. /* Placeholder fix for (detection is wider than necessary):
  2053. * http://llvm.org/bugs/show_bug.cgi?id=17788
  2054. */
  2055. #define DUK_F_USE_REPL_ALL
  2056. #elif defined(DUK_F_UCLIBC)
  2057. /* At least some uclibc versions have broken floating point math. For
  2058. * example, fpclassify() can incorrectly classify certain NaN formats.
  2059. * To be safe, use replacements.
  2060. */
  2061. #define DUK_F_USE_REPL_ALL
  2062. #elif defined(DUK_F_AIX)
  2063. /* Older versions may be missing isnan(), etc. */
  2064. #define DUK_F_USE_REPL_ALL
  2065. #endif
  2066. #if defined(DUK_F_USE_REPL_ALL)
  2067. #define DUK_USE_REPL_FPCLASSIFY
  2068. #define DUK_USE_REPL_SIGNBIT
  2069. #define DUK_USE_REPL_ISFINITE
  2070. #define DUK_USE_REPL_ISNAN
  2071. #define DUK_USE_REPL_ISINF
  2072. #define DUK_FPCLASSIFY duk_repl_fpclassify
  2073. #define DUK_SIGNBIT duk_repl_signbit
  2074. #define DUK_ISFINITE duk_repl_isfinite
  2075. #define DUK_ISNAN duk_repl_isnan
  2076. #define DUK_ISINF duk_repl_isinf
  2077. #define DUK_FP_NAN 0
  2078. #define DUK_FP_INFINITE 1
  2079. #define DUK_FP_ZERO 2
  2080. #define DUK_FP_SUBNORMAL 3
  2081. #define DUK_FP_NORMAL 4
  2082. #else
  2083. #define DUK_FPCLASSIFY fpclassify
  2084. #define DUK_SIGNBIT signbit
  2085. #define DUK_ISFINITE isfinite
  2086. #define DUK_ISNAN isnan
  2087. #define DUK_ISINF isinf
  2088. #define DUK_FP_NAN FP_NAN
  2089. #define DUK_FP_INFINITE FP_INFINITE
  2090. #define DUK_FP_ZERO FP_ZERO
  2091. #define DUK_FP_SUBNORMAL FP_SUBNORMAL
  2092. #define DUK_FP_NORMAL FP_NORMAL
  2093. #endif
  2094. #if defined(DUK_F_USE_REPL_ALL)
  2095. #undef DUK_F_USE_REPL_ALL
  2096. #endif
  2097. /* These functions don't currently need replacement but are wrapped for
  2098. * completeness. Because these are used as function pointers, they need
  2099. * to be defined as concrete C functions (not macros).
  2100. */
  2101. #if !defined(DUK_FABS)
  2102. #define DUK_FABS fabs
  2103. #endif
  2104. #if !defined(DUK_FLOOR)
  2105. #define DUK_FLOOR floor
  2106. #endif
  2107. #if !defined(DUK_CEIL)
  2108. #define DUK_CEIL ceil
  2109. #endif
  2110. #if !defined(DUK_FMOD)
  2111. #define DUK_FMOD fmod
  2112. #endif
  2113. #if !defined(DUK_POW)
  2114. #define DUK_POW pow
  2115. #endif
  2116. #if !defined(DUK_ACOS)
  2117. #define DUK_ACOS acos
  2118. #endif
  2119. #if !defined(DUK_ASIN)
  2120. #define DUK_ASIN asin
  2121. #endif
  2122. #if !defined(DUK_ATAN)
  2123. #define DUK_ATAN atan
  2124. #endif
  2125. #if !defined(DUK_ATAN2)
  2126. #define DUK_ATAN2 atan2
  2127. #endif
  2128. #if !defined(DUK_SIN)
  2129. #define DUK_SIN sin
  2130. #endif
  2131. #if !defined(DUK_COS)
  2132. #define DUK_COS cos
  2133. #endif
  2134. #if !defined(DUK_TAN)
  2135. #define DUK_TAN tan
  2136. #endif
  2137. #if !defined(DUK_EXP)
  2138. #define DUK_EXP exp
  2139. #endif
  2140. #if !defined(DUK_LOG)
  2141. #define DUK_LOG log
  2142. #endif
  2143. #if !defined(DUK_SQRT)
  2144. #define DUK_SQRT sqrt
  2145. #endif
  2146. /* The functions below exist only in C99/C++11 or later and need a workaround
  2147. * for platforms that don't include them. MSVC isn't detected as C99, but
  2148. * these functions also exist in MSVC 2013 and later so include a clause for
  2149. * that too. Android doesn't have log2; disable all of these for Android.
  2150. */
  2151. #if (defined(DUK_F_C99) || defined(DUK_F_CPP11) || (defined(_MSC_VER) && (_MSC_VER >= 1800))) && \
  2152. !defined(DUK_F_ANDROID) && !defined(DUK_F_MINT)
  2153. #if !defined(DUK_CBRT)
  2154. #define DUK_CBRT cbrt
  2155. #endif
  2156. #if !defined(DUK_LOG2)
  2157. #define DUK_LOG2 log2
  2158. #endif
  2159. #if !defined(DUK_LOG10)
  2160. #define DUK_LOG10 log10
  2161. #endif
  2162. #if !defined(DUK_TRUNC)
  2163. #define DUK_TRUNC trunc
  2164. #endif
  2165. #endif /* DUK_F_C99 etc */
  2166. /* NetBSD 6.0 x86 (at least) has a few problems with pow() semantics,
  2167. * see test-bug-netbsd-math-pow.js. MinGW has similar (but different)
  2168. * issues, see test-bug-mingw-math-issues.js. Enable pow() workarounds
  2169. * for these targets.
  2170. */
  2171. #undef DUK_USE_POW_WORKAROUNDS
  2172. #if defined(DUK_F_NETBSD) || defined(DUK_F_MINGW)
  2173. #define DUK_USE_POW_WORKAROUNDS
  2174. #endif
  2175. /* Similar workarounds for atan2() semantics issues. MinGW issues are
  2176. * documented in test-bug-mingw-math-issues.js.
  2177. */
  2178. #undef DUK_USE_ATAN2_WORKAROUNDS
  2179. #if defined(DUK_F_MINGW)
  2180. #define DUK_USE_ATAN2_WORKAROUNDS
  2181. #endif
  2182. /* Rely as little as possible on compiler behavior for NaN comparison,
  2183. * signed zero handling, etc. Currently never activated but may be needed
  2184. * for broken compilers.
  2185. */
  2186. #undef DUK_USE_PARANOID_MATH
  2187. /* There was a curious bug where test-bi-date-canceling.js would fail e.g.
  2188. * on 64-bit Ubuntu, gcc-4.8.1, -m32, and no -std=c99. Some date computations
  2189. * using doubles would be optimized which then broke some corner case tests.
  2190. * The problem goes away by adding 'volatile' to the datetime computations.
  2191. * Not sure what the actual triggering conditions are, but using this on
  2192. * non-C99 systems solves the known issues and has relatively little cost
  2193. * on other platforms.
  2194. */
  2195. #undef DUK_USE_PARANOID_DATE_COMPUTATION
  2196. #if !defined(DUK_F_C99)
  2197. #define DUK_USE_PARANOID_DATE_COMPUTATION
  2198. #endif
  2199. /*
  2200. * Byte order and double memory layout detection
  2201. *
  2202. * Endianness detection is a major portability hassle because the macros
  2203. * and headers are not standardized. There's even variance across UNIX
  2204. * platforms. Even with "standard" headers, details like underscore count
  2205. * varies between platforms, e.g. both __BYTE_ORDER and _BYTE_ORDER are used
  2206. * (Crossbridge has a single underscore, for instance).
  2207. *
  2208. * The checks below are structured with this in mind: several approaches are
  2209. * used, and at the end we check if any of them worked. This allows generic
  2210. * approaches to be tried first, and platform/compiler specific hacks tried
  2211. * last. As a last resort, the user can force a specific endianness, as it's
  2212. * not likely that automatic detection will work on the most exotic platforms.
  2213. *
  2214. * Duktape supports little and big endian machines. There's also support
  2215. * for a hybrid used by some ARM machines where integers are little endian
  2216. * but IEEE double values use a mixed order (12345678 -> 43218765). This
  2217. * byte order for doubles is referred to as "mixed endian".
  2218. */
  2219. /* GCC and Clang provide endianness defines as built-in predefines, with
  2220. * leading and trailing double underscores (e.g. __BYTE_ORDER__). See
  2221. * output of "make gccpredefs" and "make clangpredefs". Clang doesn't
  2222. * seem to provide __FLOAT_WORD_ORDER__; assume not mixed endian for clang.
  2223. * http://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
  2224. */
  2225. #if !defined(DUK_USE_BYTEORDER) && defined(__BYTE_ORDER__)
  2226. #if defined(__ORDER_LITTLE_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
  2227. #if defined(__FLOAT_WORD_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && (__FLOAT_WORD_ORDER__ == __ORDER_LITTLE_ENDIAN__)
  2228. #define DUK_USE_BYTEORDER 1
  2229. #elif defined(__FLOAT_WORD_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__)
  2230. #define DUK_USE_BYTEORDER 2
  2231. #elif !defined(__FLOAT_WORD_ORDER__)
  2232. /* Float word order not known, assume not a hybrid. */
  2233. #define DUK_USE_BYTEORDER 1
  2234. #else
  2235. /* Byte order is little endian but cannot determine IEEE double word order. */
  2236. #endif /* float word order */
  2237. #elif defined(__ORDER_BIG_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
  2238. #if defined(__FLOAT_WORD_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__)
  2239. #define DUK_USE_BYTEORDER 3
  2240. #elif !defined(__FLOAT_WORD_ORDER__)
  2241. /* Float word order not known, assume not a hybrid. */
  2242. #define DUK_USE_BYTEORDER 3
  2243. #else
  2244. /* Byte order is big endian but cannot determine IEEE double word order. */
  2245. #endif /* float word order */
  2246. #else
  2247. /* Cannot determine byte order; __ORDER_PDP_ENDIAN__ is related to 32-bit
  2248. * integer ordering and is not relevant.
  2249. */
  2250. #endif /* integer byte order */
  2251. #endif /* !defined(DUK_USE_BYTEORDER) && defined(__BYTE_ORDER__) */
  2252. /* More or less standard endianness predefines provided by header files.
  2253. * The ARM hybrid case is detected by assuming that __FLOAT_WORD_ORDER
  2254. * will be big endian, see: http://lists.mysql.com/internals/443.
  2255. * On some platforms some defines may be present with an empty value which
  2256. * causes comparisons to fail: https://github.com/svaarala/duktape/issues/453.
  2257. */
  2258. #if !defined(DUK_USE_BYTEORDER)
  2259. #if defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && (__BYTE_ORDER == __LITTLE_ENDIAN) || \
  2260. defined(_BYTE_ORDER) && defined(_LITTLE_ENDIAN) && (_BYTE_ORDER == _LITTLE_ENDIAN) || \
  2261. defined(__LITTLE_ENDIAN__)
  2262. #if defined(__FLOAT_WORD_ORDER) && defined(__LITTLE_ENDIAN) && (__FLOAT_WORD_ORDER == __LITTLE_ENDIAN) || \
  2263. defined(_FLOAT_WORD_ORDER) && defined(_LITTLE_ENDIAN) && (_FLOAT_WORD_ORDER == _LITTLE_ENDIAN)
  2264. #define DUK_USE_BYTEORDER 1
  2265. #elif defined(__FLOAT_WORD_ORDER) && defined(__BIG_ENDIAN) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN) || \
  2266. defined(_FLOAT_WORD_ORDER) && defined(_BIG_ENDIAN) && (_FLOAT_WORD_ORDER == _BIG_ENDIAN)
  2267. #define DUK_USE_BYTEORDER 2
  2268. #elif !defined(__FLOAT_WORD_ORDER) && !defined(_FLOAT_WORD_ORDER)
  2269. /* Float word order not known, assume not a hybrid. */
  2270. #define DUK_USE_BYTEORDER 1
  2271. #else
  2272. /* Byte order is little endian but cannot determine IEEE double word order. */
  2273. #endif /* float word order */
  2274. #elif defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && (__BYTE_ORDER == __BIG_ENDIAN) || \
  2275. defined(_BYTE_ORDER) && defined(_BIG_ENDIAN) && (_BYTE_ORDER == _BIG_ENDIAN) || \
  2276. defined(__BIG_ENDIAN__)
  2277. #if defined(__FLOAT_WORD_ORDER) && defined(__BIG_ENDIAN) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN) || \
  2278. defined(_FLOAT_WORD_ORDER) && defined(_BIG_ENDIAN) && (_FLOAT_WORD_ORDER == _BIG_ENDIAN)
  2279. #define DUK_USE_BYTEORDER 3
  2280. #elif !defined(__FLOAT_WORD_ORDER) && !defined(_FLOAT_WORD_ORDER)
  2281. /* Float word order not known, assume not a hybrid. */
  2282. #define DUK_USE_BYTEORDER 3
  2283. #else
  2284. /* Byte order is big endian but cannot determine IEEE double word order. */
  2285. #endif /* float word order */
  2286. #else
  2287. /* Cannot determine byte order. */
  2288. #endif /* integer byte order */
  2289. #endif /* !defined(DUK_USE_BYTEORDER) */
  2290. /* QNX gcc cross compiler seems to define e.g. __LITTLEENDIAN__ or __BIGENDIAN__:
  2291. * $ /opt/qnx650/host/linux/x86/usr/bin/i486-pc-nto-qnx6.5.0-gcc -dM -E - </dev/null | grep -ni endian
  2292. * 67:#define __LITTLEENDIAN__ 1
  2293. * $ /opt/qnx650/host/linux/x86/usr/bin/mips-unknown-nto-qnx6.5.0-gcc -dM -E - </dev/null | grep -ni endian
  2294. * 81:#define __BIGENDIAN__ 1
  2295. * $ /opt/qnx650/host/linux/x86/usr/bin/arm-unknown-nto-qnx6.5.0-gcc -dM -E - </dev/null | grep -ni endian
  2296. * 70:#define __LITTLEENDIAN__ 1
  2297. */
  2298. #if !defined(DUK_USE_BYTEORDER)
  2299. #if defined(__LITTLEENDIAN__)
  2300. #define DUK_USE_BYTEORDER 1
  2301. #elif defined(__BIGENDIAN__)
  2302. #define DUK_USE_BYTEORDER 3
  2303. #endif
  2304. #endif
  2305. /*
  2306. * Alignment requirement and support for unaligned accesses
  2307. *
  2308. * Assume unaligned accesses are not supported unless specifically allowed
  2309. * in the target platform. Some platforms may support unaligned accesses
  2310. * but alignment to 4 or 8 may still be desirable.
  2311. */
  2312. /* If not provided, use safe default for alignment. */
  2313. #if !defined(DUK_USE_ALIGN_BY)
  2314. #define DUK_USE_ALIGN_BY 8
  2315. #endif
  2316. /* Compiler specific hackery needed to force struct size to match aligment,
  2317. * see e.g. duk_hbuffer.h.
  2318. *
  2319. * http://stackoverflow.com/questions/11130109/c-struct-size-alignment
  2320. * http://stackoverflow.com/questions/10951039/specifying-64-bit-alignment
  2321. */
  2322. #if !(defined(DUK_USE_PACK_MSVC_PRAGMA) || defined(DUK_USE_PACK_GCC_ATTR) || \
  2323. defined(DUK_USE_PACK_CLANG_ATTR) || defined(DUK_USE_PACK_DUMMY_MEMBER))
  2324. #define DUK_USE_PACK_DUMMY_MEMBER
  2325. #endif
  2326. #if !defined(DUK_VA_COPY)
  2327. /* We need va_copy() which is defined in C99 / C++11, so an awkward
  2328. * replacement is needed for pre-C99 / pre-C++11 environments. This
  2329. * will quite likely need portability hacks for some non-C99
  2330. * environments.
  2331. */
  2332. #if defined(DUK_F_C99) || defined(DUK_F_CPP11)
  2333. /* C99 / C++11 and above: rely on va_copy() which is required.
  2334. * Omit parenthesis on macro right side on purpose to minimize differences
  2335. * to direct use.
  2336. */
  2337. #define DUK_VA_COPY(dest,src) va_copy(dest,src)
  2338. #else
  2339. /* Pre-C99: va_list type is implementation dependent. This replacement
  2340. * assumes it is a plain value so that a simple assignment will work.
  2341. * This is not the case on all platforms (it may be a single-array element,
  2342. * for instance).
  2343. */
  2344. #define DUK_VA_COPY(dest,src) do { (dest) = (src); } while (0)
  2345. #endif
  2346. #endif
  2347. #if !defined(DUK_MACRO_STRINGIFY)
  2348. /* Macro hackery to convert e.g. __LINE__ to a string without formatting,
  2349. * see: http://stackoverflow.com/questions/240353/convert-a-preprocessor-token-to-a-string
  2350. */
  2351. #define DUK_MACRO_STRINGIFY_HELPER(x) #x
  2352. #define DUK_MACRO_STRINGIFY(x) DUK_MACRO_STRINGIFY_HELPER(x)
  2353. #endif
  2354. #if !defined(DUK_CAUSE_SEGFAULT)
  2355. /* This can be used for testing; valgrind will then indicate the C call stack
  2356. * leading to the call site.
  2357. */
  2358. #define DUK_CAUSE_SEGFAULT() do { *((volatile duk_uint32_t *) NULL) = (duk_uint32_t) 0xdeadbeefUL; } while (0)
  2359. #endif
  2360. #if !defined(DUK_UNREF)
  2361. /* Macro for suppressing warnings for potentially unreferenced variables.
  2362. * The variables can be actually unreferenced or unreferenced in some
  2363. * specific cases only; for instance, if a variable is only debug printed,
  2364. * it is unreferenced when debug printing is disabled. May cause warnings
  2365. * for volatile arguments.
  2366. */
  2367. #define DUK_UNREF(x) do { (void) (x); } while (0)
  2368. #endif
  2369. #if !defined(DUK_NORETURN)
  2370. #define DUK_NORETURN(decl) decl
  2371. #endif
  2372. #if !defined(DUK_UNREACHABLE)
  2373. /* Don't know how to declare unreachable point, so don't do it; this
  2374. * may cause some spurious compilation warnings (e.g. "variable used
  2375. * uninitialized").
  2376. */
  2377. #define DUK_UNREACHABLE() do { } while (0)
  2378. #endif
  2379. #if !defined(DUK_LOSE_CONST)
  2380. /* Convert any input pointer into a "void *", losing a const qualifier.
  2381. * This is not fully portable because casting through duk_uintptr_t may
  2382. * not work on all architectures (e.g. those with long, segmented pointers).
  2383. */
  2384. #define DUK_LOSE_CONST(src) ((void *) (duk_uintptr_t) (src))
  2385. #endif
  2386. #if !defined(DUK_LIKELY)
  2387. #define DUK_LIKELY(x) (x)
  2388. #endif
  2389. #if !defined(DUK_UNLIKELY)
  2390. #define DUK_UNLIKELY(x) (x)
  2391. #endif
  2392. #if !defined(DUK_UNPREDICTABLE)
  2393. #define DUK_UNPREDICTABLE(x) (x)
  2394. #endif
  2395. #if !defined(DUK_NOINLINE)
  2396. #define DUK_NOINLINE /*nop*/
  2397. #endif
  2398. #if !defined(DUK_INLINE)
  2399. #define DUK_INLINE /*nop*/
  2400. #endif
  2401. #if !defined(DUK_ALWAYS_INLINE)
  2402. #define DUK_ALWAYS_INLINE /*nop*/
  2403. #endif
  2404. #if !defined(DUK_HOT)
  2405. #define DUK_HOT /*nop*/
  2406. #endif
  2407. #if !defined(DUK_COLD)
  2408. #define DUK_COLD /*nop*/
  2409. #endif
  2410. #if !defined(DUK_EXTERNAL_DECL)
  2411. #define DUK_EXTERNAL_DECL extern
  2412. #endif
  2413. #if !defined(DUK_EXTERNAL)
  2414. #define DUK_EXTERNAL /*empty*/
  2415. #endif
  2416. #if !defined(DUK_INTERNAL_DECL)
  2417. #if defined(DUK_SINGLE_FILE)
  2418. #define DUK_INTERNAL_DECL static
  2419. #else
  2420. #define DUK_INTERNAL_DECL extern
  2421. #endif
  2422. #endif
  2423. #if !defined(DUK_INTERNAL)
  2424. #if defined(DUK_SINGLE_FILE)
  2425. #define DUK_INTERNAL static
  2426. #else
  2427. #define DUK_INTERNAL /*empty*/
  2428. #endif
  2429. #endif
  2430. #if !defined(DUK_LOCAL_DECL)
  2431. #define DUK_LOCAL_DECL static
  2432. #endif
  2433. #if !defined(DUK_LOCAL)
  2434. #define DUK_LOCAL static
  2435. #endif
  2436. #if !defined(DUK_FILE_MACRO)
  2437. #define DUK_FILE_MACRO __FILE__
  2438. #endif
  2439. #if !defined(DUK_LINE_MACRO)
  2440. #define DUK_LINE_MACRO __LINE__
  2441. #endif
  2442. #if !defined(DUK_FUNC_MACRO)
  2443. #if defined(DUK_F_C99) || defined(DUK_F_CPP11)
  2444. #define DUK_FUNC_MACRO __func__
  2445. #elif defined(__FUNCTION__)
  2446. #define DUK_FUNC_MACRO __FUNCTION__
  2447. #else
  2448. #define DUK_FUNC_MACRO "unknown"
  2449. #endif
  2450. #endif
  2451. #if !defined(DUK_BSWAP32)
  2452. #define DUK_BSWAP32(x) \
  2453. ((((duk_uint32_t) (x)) >> 24) | \
  2454. ((((duk_uint32_t) (x)) >> 8) & 0xff00UL) | \
  2455. ((((duk_uint32_t) (x)) << 8) & 0xff0000UL) | \
  2456. (((duk_uint32_t) (x)) << 24))
  2457. #endif
  2458. #if !defined(DUK_BSWAP16)
  2459. #define DUK_BSWAP16(x) \
  2460. ((duk_uint16_t) (x) >> 8) | \
  2461. ((duk_uint16_t) (x) << 8)
  2462. #endif
  2463. /* DUK_USE_VARIADIC_MACROS: required from compilers, so no fill-in. */
  2464. /* DUK_USE_UNION_INITIALIZERS: required from compilers, so no fill-in. */
  2465. #if !(defined(DUK_USE_FLEX_C99) || defined(DUK_USE_FLEX_ZEROSIZE) || defined(DUK_USE_FLEX_ONESIZE))
  2466. #if defined(DUK_F_C99)
  2467. #define DUK_USE_FLEX_C99
  2468. #else
  2469. #define DUK_USE_FLEX_ZEROSIZE /* Not standard but common enough */
  2470. #endif
  2471. #endif
  2472. #if !(defined(DUK_USE_PACK_GCC_ATTR) || defined(DUK_USE_PACK_CLANG_ATTR) || \
  2473. defined(DUK_USE_PACK_MSVC_PRAGMA) || defined(DUK_USE_PACK_DUMMY_MEMBER))
  2474. #define DUK_USE_PACK_DUMMY_MEMBER
  2475. #endif
  2476. #if 0 /* not defined by default */
  2477. #undef DUK_USE_GCC_PRAGMAS
  2478. #endif
  2479. #if !defined(DUK_U64_CONSTANT)
  2480. #define DUK_U64_CONSTANT(x) x##ULL
  2481. #endif
  2482. #if !defined(DUK_I64_CONSTANT)
  2483. #define DUK_I64_CONSTANT(x) x##LL
  2484. #endif
  2485. /* Workaround for GH-323: avoid inlining control when compiling from
  2486. * multiple sources, as it causes compiler portability trouble.
  2487. */
  2488. #if !defined(DUK_SINGLE_FILE)
  2489. #undef DUK_NOINLINE
  2490. #undef DUK_INLINE
  2491. #undef DUK_ALWAYS_INLINE
  2492. #define DUK_NOINLINE /*nop*/
  2493. #define DUK_INLINE /*nop*/
  2494. #define DUK_ALWAYS_INLINE /*nop*/
  2495. #endif
  2496. /*
  2497. * Check whether or not a packed duk_tval representation is possible.
  2498. * What's basically required is that pointers are 32-bit values
  2499. * (sizeof(void *) == 4). Best effort check, not always accurate.
  2500. * If guess goes wrong, crashes may result; self tests also verify
  2501. * the guess.
  2502. */
  2503. /* Explicit marker needed; may be 'defined', 'undefined, 'or 'not provided'. */
  2504. #if !defined(DUK_F_PACKED_TVAL_PROVIDED)
  2505. #undef DUK_F_PACKED_TVAL_POSSIBLE
  2506. /* Strict C99 case: DUK_UINTPTR_MAX (= UINTPTR_MAX) should be very reliable */
  2507. #if !defined(DUK_F_PACKED_TVAL_POSSIBLE) && defined(DUK_UINTPTR_MAX)
  2508. #if (DUK_UINTPTR_MAX <= 0xffffffffUL)
  2509. #define DUK_F_PACKED_TVAL_POSSIBLE
  2510. #endif
  2511. #endif
  2512. /* Non-C99 case, still relying on DUK_UINTPTR_MAX, as long as it is not a computed value */
  2513. #if !defined(DUK_F_PACKED_TVAL_POSSIBLE) && defined(DUK_UINTPTR_MAX) && !defined(DUK_UINTPTR_MAX_COMPUTED)
  2514. #if (DUK_UINTPTR_MAX <= 0xffffffffUL)
  2515. #define DUK_F_PACKED_TVAL_POSSIBLE
  2516. #endif
  2517. #endif
  2518. /* DUK_SIZE_MAX (= SIZE_MAX) is often reliable */
  2519. #if !defined(DUK_F_PACKED_TVAL_POSSIBLE) && defined(DUK_SIZE_MAX) && !defined(DUK_SIZE_MAX_COMPUTED)
  2520. #if (DUK_SIZE_MAX <= 0xffffffffUL)
  2521. #define DUK_F_PACKED_TVAL_POSSIBLE
  2522. #endif
  2523. #endif
  2524. #undef DUK_USE_PACKED_TVAL
  2525. #if defined(DUK_F_PACKED_TVAL_POSSIBLE)
  2526. #define DUK_USE_PACKED_TVAL
  2527. #endif
  2528. #undef DUK_F_PACKED_TVAL_POSSIBLE
  2529. #endif /* DUK_F_PACKED_TVAL_PROVIDED */
  2530. /* Object property allocation layout has implications for memory and code
  2531. * footprint and generated code size/speed. The best layout also depends
  2532. * on whether the platform has alignment requirements or benefits from
  2533. * having mostly aligned accesses.
  2534. */
  2535. #undef DUK_USE_HOBJECT_LAYOUT_1
  2536. #undef DUK_USE_HOBJECT_LAYOUT_2
  2537. #undef DUK_USE_HOBJECT_LAYOUT_3
  2538. #if (DUK_USE_ALIGN_BY == 1)
  2539. /* On platforms without any alignment issues, layout 1 is preferable
  2540. * because it compiles to slightly less code and provides direct access
  2541. * to property keys.
  2542. */
  2543. #define DUK_USE_HOBJECT_LAYOUT_1
  2544. #else
  2545. /* On other platforms use layout 2, which requires some padding but
  2546. * is a bit more natural than layout 3 in ordering the entries. Layout
  2547. * 3 is currently not used.
  2548. */
  2549. #define DUK_USE_HOBJECT_LAYOUT_2
  2550. #endif
  2551. /* GCC/clang inaccurate math would break compliance and probably duk_tval,
  2552. * so refuse to compile. Relax this if -ffast-math is tested to work.
  2553. */
  2554. #if defined(__FAST_MATH__)
  2555. #error __FAST_MATH__ defined, refusing to compile
  2556. #endif
  2557. #define DUK_USE_FATAL_HANDLER(udata,msg) do { \
  2558. const char *fatal_msg = (msg); /* avoid double evaluation */ \
  2559. (void) udata; \
  2560. fprintf(stderr, "*** FATAL ERROR: %s\n", fatal_msg ? fatal_msg : "no message"); \
  2561. fflush(stderr); \
  2562. abort(); \
  2563. } while (0)
  2564. /*
  2565. * Autogenerated defaults
  2566. */
  2567. #define DUK_USE_ARRAY_BUILTIN
  2568. #define DUK_USE_ARRAY_FASTPATH
  2569. #define DUK_USE_ARRAY_PROP_FASTPATH
  2570. #undef DUK_USE_ASSERTIONS
  2571. #define DUK_USE_AUGMENT_ERROR_CREATE
  2572. #define DUK_USE_AUGMENT_ERROR_THROW
  2573. #define DUK_USE_AVOID_PLATFORM_FUNCPTRS
  2574. #define DUK_USE_BASE64_FASTPATH
  2575. #define DUK_USE_BOOLEAN_BUILTIN
  2576. #define DUK_USE_BUFFEROBJECT_SUPPORT
  2577. #undef DUK_USE_BUFLEN16
  2578. #define DUK_USE_BYTECODE_DUMP_SUPPORT
  2579. #define DUK_USE_CACHE_ACTIVATION
  2580. #define DUK_USE_CACHE_CATCHER
  2581. #define DUK_USE_CALLSTACK_LIMIT 10000
  2582. #define DUK_USE_COMMONJS_MODULES
  2583. #define DUK_USE_COMPILER_RECLIMIT 2500
  2584. #define DUK_USE_COROUTINE_SUPPORT
  2585. #undef DUK_USE_CPP_EXCEPTIONS
  2586. #undef DUK_USE_DATAPTR16
  2587. #undef DUK_USE_DATAPTR_DEC16
  2588. #undef DUK_USE_DATAPTR_ENC16
  2589. #define DUK_USE_DATE_BUILTIN
  2590. #undef DUK_USE_DATE_FORMAT_STRING
  2591. #undef DUK_USE_DATE_GET_LOCAL_TZOFFSET
  2592. #undef DUK_USE_DATE_GET_NOW
  2593. #undef DUK_USE_DATE_PARSE_STRING
  2594. #undef DUK_USE_DATE_PRS_GETDATE
  2595. #undef DUK_USE_DEBUG
  2596. #undef DUK_USE_DEBUGGER_DUMPHEAP
  2597. #undef DUK_USE_DEBUGGER_INSPECT
  2598. #undef DUK_USE_DEBUGGER_PAUSE_UNCAUGHT
  2599. #undef DUK_USE_DEBUGGER_SUPPORT
  2600. #define DUK_USE_DEBUGGER_THROW_NOTIFY
  2601. #undef DUK_USE_DEBUGGER_TRANSPORT_TORTURE
  2602. #define DUK_USE_DEBUG_BUFSIZE 65536L
  2603. #define DUK_USE_DEBUG_LEVEL 0
  2604. #undef DUK_USE_DEBUG_WRITE
  2605. #define DUK_USE_DOUBLE_LINKED_HEAP
  2606. #define DUK_USE_DUKTAPE_BUILTIN
  2607. #define DUK_USE_ENCODING_BUILTINS
  2608. #define DUK_USE_ERRCREATE
  2609. #define DUK_USE_ERRTHROW
  2610. #define DUK_USE_ES6
  2611. #define DUK_USE_ES6_OBJECT_PROTO_PROPERTY
  2612. #define DUK_USE_ES6_OBJECT_SETPROTOTYPEOF
  2613. #define DUK_USE_ES6_PROXY
  2614. #define DUK_USE_ES6_REGEXP_SYNTAX
  2615. #define DUK_USE_ES6_UNICODE_ESCAPE
  2616. #define DUK_USE_ES7
  2617. #define DUK_USE_ES7_EXP_OPERATOR
  2618. #define DUK_USE_ES8
  2619. #define DUK_USE_ES9
  2620. #define DUK_USE_ESBC_LIMITS
  2621. #define DUK_USE_ESBC_MAX_BYTES 2147418112L
  2622. #define DUK_USE_ESBC_MAX_LINENUMBER 2147418112L
  2623. #undef DUK_USE_EXEC_FUN_LOCAL
  2624. #undef DUK_USE_EXEC_INDIRECT_BOUND_CHECK
  2625. #undef DUK_USE_EXEC_PREFER_SIZE
  2626. #define DUK_USE_EXEC_REGCONST_OPTIMIZE
  2627. #undef DUK_USE_EXEC_TIMEOUT_CHECK
  2628. #undef DUK_USE_EXPLICIT_NULL_INIT
  2629. #undef DUK_USE_EXTSTR_FREE
  2630. #undef DUK_USE_EXTSTR_INTERN_CHECK
  2631. #undef DUK_USE_FASTINT
  2632. #define DUK_USE_FAST_REFCOUNT_DEFAULT
  2633. #define DUK_USE_FATAL_MAXLEN 128
  2634. #define DUK_USE_FINALIZER_SUPPORT
  2635. #undef DUK_USE_FINALIZER_TORTURE
  2636. #undef DUK_USE_FUNCPTR16
  2637. #undef DUK_USE_FUNCPTR_DEC16
  2638. #undef DUK_USE_FUNCPTR_ENC16
  2639. #define DUK_USE_FUNCTION_BUILTIN
  2640. #define DUK_USE_FUNC_FILENAME_PROPERTY
  2641. #define DUK_USE_FUNC_NAME_PROPERTY
  2642. #undef DUK_USE_GC_TORTURE
  2643. #undef DUK_USE_GET_MONOTONIC_TIME
  2644. #undef DUK_USE_GET_RANDOM_DOUBLE
  2645. #undef DUK_USE_GLOBAL_BINDING
  2646. #define DUK_USE_GLOBAL_BUILTIN
  2647. #undef DUK_USE_HEAPPTR16
  2648. #undef DUK_USE_HEAPPTR_DEC16
  2649. #undef DUK_USE_HEAPPTR_ENC16
  2650. #define DUK_USE_HEX_FASTPATH
  2651. #define DUK_USE_HOBJECT_ARRAY_ABANDON_LIMIT 2
  2652. #define DUK_USE_HOBJECT_ARRAY_FAST_RESIZE_LIMIT 9
  2653. #define DUK_USE_HOBJECT_ARRAY_MINGROW_ADD 16
  2654. #define DUK_USE_HOBJECT_ARRAY_MINGROW_DIVISOR 8
  2655. #define DUK_USE_HOBJECT_ENTRY_MINGROW_ADD 16
  2656. #define DUK_USE_HOBJECT_ENTRY_MINGROW_DIVISOR 8
  2657. #define DUK_USE_HOBJECT_HASH_PART
  2658. #define DUK_USE_HOBJECT_HASH_PROP_LIMIT 8
  2659. #define DUK_USE_HSTRING_ARRIDX
  2660. #define DUK_USE_HSTRING_CLEN
  2661. #undef DUK_USE_HSTRING_EXTDATA
  2662. #define DUK_USE_HSTRING_LAZY_CLEN
  2663. #define DUK_USE_HTML_COMMENTS
  2664. #define DUK_USE_IDCHAR_FASTPATH
  2665. #undef DUK_USE_INJECT_HEAP_ALLOC_ERROR
  2666. #undef DUK_USE_INTERRUPT_COUNTER
  2667. #undef DUK_USE_INTERRUPT_DEBUG_FIXUP
  2668. #define DUK_USE_JC
  2669. #define DUK_USE_JSON_BUILTIN
  2670. #define DUK_USE_JSON_DECNUMBER_FASTPATH
  2671. #define DUK_USE_JSON_DECSTRING_FASTPATH
  2672. #define DUK_USE_JSON_DEC_RECLIMIT 1000
  2673. #define DUK_USE_JSON_EATWHITE_FASTPATH
  2674. #define DUK_USE_JSON_ENC_RECLIMIT 1000
  2675. #define DUK_USE_JSON_QUOTESTRING_FASTPATH
  2676. #undef DUK_USE_JSON_STRINGIFY_FASTPATH
  2677. #define DUK_USE_JSON_SUPPORT
  2678. #define DUK_USE_JX
  2679. #define DUK_USE_LEXER_SLIDING_WINDOW
  2680. #undef DUK_USE_LIGHTFUNC_BUILTINS
  2681. #define DUK_USE_MARK_AND_SWEEP_RECLIMIT 256
  2682. #define DUK_USE_MATH_BUILTIN
  2683. #define DUK_USE_NATIVE_CALL_RECLIMIT 1000
  2684. #define DUK_USE_NONSTD_ARRAY_CONCAT_TRAILER
  2685. #define DUK_USE_NONSTD_ARRAY_MAP_TRAILER
  2686. #define DUK_USE_NONSTD_ARRAY_SPLICE_DELCOUNT
  2687. #undef DUK_USE_NONSTD_FUNC_CALLER_PROPERTY
  2688. #undef DUK_USE_NONSTD_FUNC_SOURCE_PROPERTY
  2689. #define DUK_USE_NONSTD_FUNC_STMT
  2690. #define DUK_USE_NONSTD_GETTER_KEY_ARGUMENT
  2691. #define DUK_USE_NONSTD_JSON_ESC_U2028_U2029
  2692. #define DUK_USE_NONSTD_SETTER_KEY_ARGUMENT
  2693. #define DUK_USE_NONSTD_STRING_FROMCHARCODE_32BIT
  2694. #define DUK_USE_NUMBER_BUILTIN
  2695. #define DUK_USE_OBJECT_BUILTIN
  2696. #undef DUK_USE_OBJSIZES16
  2697. #undef DUK_USE_PARANOID_ERRORS
  2698. #define DUK_USE_PC2LINE
  2699. #define DUK_USE_PERFORMANCE_BUILTIN
  2700. #undef DUK_USE_PREFER_SIZE
  2701. #undef DUK_USE_PROMISE_BUILTIN
  2702. #define DUK_USE_PROVIDE_DEFAULT_ALLOC_FUNCTIONS
  2703. #undef DUK_USE_REFCOUNT16
  2704. #define DUK_USE_REFCOUNT32
  2705. #define DUK_USE_REFERENCE_COUNTING
  2706. #define DUK_USE_REFLECT_BUILTIN
  2707. #define DUK_USE_REGEXP_CANON_BITMAP
  2708. #undef DUK_USE_REGEXP_CANON_WORKAROUND
  2709. #define DUK_USE_REGEXP_COMPILER_RECLIMIT 10000
  2710. #define DUK_USE_REGEXP_EXECUTOR_RECLIMIT 10000
  2711. #define DUK_USE_REGEXP_SUPPORT
  2712. #undef DUK_USE_ROM_GLOBAL_CLONE
  2713. #undef DUK_USE_ROM_GLOBAL_INHERIT
  2714. #undef DUK_USE_ROM_OBJECTS
  2715. #define DUK_USE_ROM_PTRCOMP_FIRST 63488L
  2716. #undef DUK_USE_ROM_STRINGS
  2717. #define DUK_USE_SECTION_B
  2718. #undef DUK_USE_SELF_TESTS
  2719. #define DUK_USE_SHEBANG_COMMENTS
  2720. #undef DUK_USE_SHUFFLE_TORTURE
  2721. #define DUK_USE_SOURCE_NONBMP
  2722. #undef DUK_USE_STRHASH16
  2723. #undef DUK_USE_STRHASH_DENSE
  2724. #define DUK_USE_STRHASH_SKIP_SHIFT 5
  2725. #define DUK_USE_STRICT_DECL
  2726. #undef DUK_USE_STRICT_UTF8_SOURCE
  2727. #define DUK_USE_STRING_BUILTIN
  2728. #undef DUK_USE_STRLEN16
  2729. #define DUK_USE_STRTAB_GROW_LIMIT 17
  2730. #define DUK_USE_STRTAB_MAXSIZE 268435456L
  2731. #define DUK_USE_STRTAB_MINSIZE 1024
  2732. #undef DUK_USE_STRTAB_PTRCOMP
  2733. #define DUK_USE_STRTAB_RESIZE_CHECK_MASK 255
  2734. #define DUK_USE_STRTAB_SHRINK_LIMIT 6
  2735. #undef DUK_USE_STRTAB_TORTURE
  2736. #undef DUK_USE_SYMBOL_BUILTIN
  2737. #define DUK_USE_TAILCALL
  2738. #define DUK_USE_TARGET_INFO "unknown"
  2739. #define DUK_USE_TRACEBACKS
  2740. #define DUK_USE_TRACEBACK_DEPTH 10
  2741. #define DUK_USE_USER_DECLARE() /* no user declarations */
  2742. #define DUK_USE_VALSTACK_GROW_SHIFT 2
  2743. #define DUK_USE_VALSTACK_LIMIT 1000000L
  2744. #define DUK_USE_VALSTACK_SHRINK_CHECK_SHIFT 2
  2745. #define DUK_USE_VALSTACK_SHRINK_SLACK_SHIFT 4
  2746. #undef DUK_USE_VALSTACK_UNSAFE
  2747. #define DUK_USE_VERBOSE_ERRORS
  2748. #define DUK_USE_VERBOSE_EXECUTOR_ERRORS
  2749. #define DUK_USE_VOLUNTARY_GC
  2750. #define DUK_USE_ZERO_BUFFER_DATA
  2751. /*
  2752. * You may add overriding #define/#undef directives below for
  2753. * customization. You of course cannot un-#include or un-typedef
  2754. * anything; these require direct changes above.
  2755. */
  2756. /* __OVERRIDE_DEFINES__ */
  2757. /*
  2758. * Date provider selection
  2759. *
  2760. * User may define DUK_USE_DATE_GET_NOW() etc directly, in which case we'll
  2761. * rely on an external provider. If this is not done, revert to previous
  2762. * behavior and use Unix/Windows built-in provider.
  2763. */
  2764. #if defined(DUK_COMPILING_DUKTAPE)
  2765. #if defined(DUK_USE_DATE_GET_NOW)
  2766. /* External provider already defined. */
  2767. #elif defined(DUK_USE_DATE_NOW_GETTIMEOFDAY)
  2768. #define DUK_USE_DATE_GET_NOW(ctx) duk_bi_date_get_now_gettimeofday()
  2769. #elif defined(DUK_USE_DATE_NOW_TIME)
  2770. #define DUK_USE_DATE_GET_NOW(ctx) duk_bi_date_get_now_time()
  2771. #elif defined(DUK_USE_DATE_NOW_WINDOWS)
  2772. #define DUK_USE_DATE_GET_NOW(ctx) duk_bi_date_get_now_windows()
  2773. #elif defined(DUK_USE_DATE_NOW_WINDOWS_SUBMS)
  2774. #define DUK_USE_DATE_GET_NOW(ctx) duk_bi_date_get_now_windows_subms()
  2775. #else
  2776. #error no provider for DUK_USE_DATE_GET_NOW()
  2777. #endif
  2778. #if defined(DUK_USE_DATE_GET_LOCAL_TZOFFSET)
  2779. /* External provider already defined. */
  2780. #elif defined(DUK_USE_DATE_TZO_GMTIME_R) || defined(DUK_USE_DATE_TZO_GMTIME_S) || defined(DUK_USE_DATE_TZO_GMTIME)
  2781. #define DUK_USE_DATE_GET_LOCAL_TZOFFSET(d) duk_bi_date_get_local_tzoffset_gmtime((d))
  2782. #elif defined(DUK_USE_DATE_TZO_WINDOWS)
  2783. #define DUK_USE_DATE_GET_LOCAL_TZOFFSET(d) duk_bi_date_get_local_tzoffset_windows((d))
  2784. #elif defined(DUK_USE_DATE_TZO_WINDOWS_NO_DST)
  2785. #define DUK_USE_DATE_GET_LOCAL_TZOFFSET(d) duk_bi_date_get_local_tzoffset_windows_no_dst((d))
  2786. #else
  2787. #error no provider for DUK_USE_DATE_GET_LOCAL_TZOFFSET()
  2788. #endif
  2789. #if defined(DUK_USE_DATE_PARSE_STRING)
  2790. /* External provider already defined. */
  2791. #elif defined(DUK_USE_DATE_PRS_STRPTIME)
  2792. #define DUK_USE_DATE_PARSE_STRING(ctx,str) duk_bi_date_parse_string_strptime((ctx), (str))
  2793. #elif defined(DUK_USE_DATE_PRS_GETDATE)
  2794. #define DUK_USE_DATE_PARSE_STRING(ctx,str) duk_bi_date_parse_string_getdate((ctx), (str))
  2795. #else
  2796. /* No provider for DUK_USE_DATE_PARSE_STRING(), fall back to ISO 8601 only. */
  2797. #endif
  2798. #if defined(DUK_USE_DATE_FORMAT_STRING)
  2799. /* External provider already defined. */
  2800. #elif defined(DUK_USE_DATE_FMT_STRFTIME)
  2801. #define DUK_USE_DATE_FORMAT_STRING(ctx,parts,tzoffset,flags) \
  2802. duk_bi_date_format_parts_strftime((ctx), (parts), (tzoffset), (flags))
  2803. #else
  2804. /* No provider for DUK_USE_DATE_FORMAT_STRING(), fall back to ISO 8601 only. */
  2805. #endif
  2806. #if defined(DUK_USE_GET_MONOTONIC_TIME)
  2807. /* External provider already defined. */
  2808. #elif defined(DUK_USE_GET_MONOTONIC_TIME_CLOCK_GETTIME)
  2809. #define DUK_USE_GET_MONOTONIC_TIME(ctx) duk_bi_date_get_monotonic_time_clock_gettime()
  2810. #elif defined(DUK_USE_GET_MONOTONIC_TIME_WINDOWS_QPC)
  2811. #define DUK_USE_GET_MONOTONIC_TIME(ctx) duk_bi_date_get_monotonic_time_windows_qpc()
  2812. #else
  2813. /* No provider for DUK_USE_GET_MONOTONIC_TIME(), fall back to DUK_USE_DATE_GET_NOW(). */
  2814. #endif
  2815. #endif /* DUK_COMPILING_DUKTAPE */
  2816. /*
  2817. * Checks for legacy feature options (DUK_OPT_xxx)
  2818. */
  2819. #if defined(DUK_OPT_ASSERTIONS)
  2820. #error unsupported legacy feature option DUK_OPT_ASSERTIONS used
  2821. #endif
  2822. #if defined(DUK_OPT_BUFFEROBJECT_SUPPORT)
  2823. #error unsupported legacy feature option DUK_OPT_BUFFEROBJECT_SUPPORT used
  2824. #endif
  2825. #if defined(DUK_OPT_BUFLEN16)
  2826. #error unsupported legacy feature option DUK_OPT_BUFLEN16 used
  2827. #endif
  2828. #if defined(DUK_OPT_DATAPTR16)
  2829. #error unsupported legacy feature option DUK_OPT_DATAPTR16 used
  2830. #endif
  2831. #if defined(DUK_OPT_DATAPTR_DEC16)
  2832. #error unsupported legacy feature option DUK_OPT_DATAPTR_DEC16 used
  2833. #endif
  2834. #if defined(DUK_OPT_DATAPTR_ENC16)
  2835. #error unsupported legacy feature option DUK_OPT_DATAPTR_ENC16 used
  2836. #endif
  2837. #if defined(DUK_OPT_DDDPRINT)
  2838. #error unsupported legacy feature option DUK_OPT_DDDPRINT used
  2839. #endif
  2840. #if defined(DUK_OPT_DDPRINT)
  2841. #error unsupported legacy feature option DUK_OPT_DDPRINT used
  2842. #endif
  2843. #if defined(DUK_OPT_DEBUG)
  2844. #error unsupported legacy feature option DUK_OPT_DEBUG used
  2845. #endif
  2846. #if defined(DUK_OPT_DEBUGGER_DUMPHEAP)
  2847. #error unsupported legacy feature option DUK_OPT_DEBUGGER_DUMPHEAP used
  2848. #endif
  2849. #if defined(DUK_OPT_DEBUGGER_FWD_LOGGING)
  2850. #error unsupported legacy feature option DUK_OPT_DEBUGGER_FWD_LOGGING used
  2851. #endif
  2852. #if defined(DUK_OPT_DEBUGGER_FWD_PRINTALERT)
  2853. #error unsupported legacy feature option DUK_OPT_DEBUGGER_FWD_PRINTALERT used
  2854. #endif
  2855. #if defined(DUK_OPT_DEBUGGER_SUPPORT)
  2856. #error unsupported legacy feature option DUK_OPT_DEBUGGER_SUPPORT used
  2857. #endif
  2858. #if defined(DUK_OPT_DEBUGGER_TRANSPORT_TORTURE)
  2859. #error unsupported legacy feature option DUK_OPT_DEBUGGER_TRANSPORT_TORTURE used
  2860. #endif
  2861. #if defined(DUK_OPT_DEBUG_BUFSIZE)
  2862. #error unsupported legacy feature option DUK_OPT_DEBUG_BUFSIZE used
  2863. #endif
  2864. #if defined(DUK_OPT_DECLARE)
  2865. #error unsupported legacy feature option DUK_OPT_DECLARE used
  2866. #endif
  2867. #if defined(DUK_OPT_DEEP_C_STACK)
  2868. #error unsupported legacy feature option DUK_OPT_DEEP_C_STACK used
  2869. #endif
  2870. #if defined(DUK_OPT_DLL_BUILD)
  2871. #error unsupported legacy feature option DUK_OPT_DLL_BUILD used
  2872. #endif
  2873. #if defined(DUK_OPT_DPRINT)
  2874. #error unsupported legacy feature option DUK_OPT_DPRINT used
  2875. #endif
  2876. #if defined(DUK_OPT_DPRINT_COLORS)
  2877. #error unsupported legacy feature option DUK_OPT_DPRINT_COLORS used
  2878. #endif
  2879. #if defined(DUK_OPT_DPRINT_RDTSC)
  2880. #error unsupported legacy feature option DUK_OPT_DPRINT_RDTSC used
  2881. #endif
  2882. #if defined(DUK_OPT_EXEC_TIMEOUT_CHECK)
  2883. #error unsupported legacy feature option DUK_OPT_EXEC_TIMEOUT_CHECK used
  2884. #endif
  2885. #if defined(DUK_OPT_EXTERNAL_STRINGS)
  2886. #error unsupported legacy feature option DUK_OPT_EXTERNAL_STRINGS used
  2887. #endif
  2888. #if defined(DUK_OPT_EXTSTR_FREE)
  2889. #error unsupported legacy feature option DUK_OPT_EXTSTR_FREE used
  2890. #endif
  2891. #if defined(DUK_OPT_EXTSTR_INTERN_CHECK)
  2892. #error unsupported legacy feature option DUK_OPT_EXTSTR_INTERN_CHECK used
  2893. #endif
  2894. #if defined(DUK_OPT_FASTINT)
  2895. #error unsupported legacy feature option DUK_OPT_FASTINT used
  2896. #endif
  2897. #if defined(DUK_OPT_FORCE_ALIGN)
  2898. #error unsupported legacy feature option DUK_OPT_FORCE_ALIGN used
  2899. #endif
  2900. #if defined(DUK_OPT_FORCE_BYTEORDER)
  2901. #error unsupported legacy feature option DUK_OPT_FORCE_BYTEORDER used
  2902. #endif
  2903. #if defined(DUK_OPT_FUNCPTR16)
  2904. #error unsupported legacy feature option DUK_OPT_FUNCPTR16 used
  2905. #endif
  2906. #if defined(DUK_OPT_FUNCPTR_DEC16)
  2907. #error unsupported legacy feature option DUK_OPT_FUNCPTR_DEC16 used
  2908. #endif
  2909. #if defined(DUK_OPT_FUNCPTR_ENC16)
  2910. #error unsupported legacy feature option DUK_OPT_FUNCPTR_ENC16 used
  2911. #endif
  2912. #if defined(DUK_OPT_FUNC_NONSTD_CALLER_PROPERTY)
  2913. #error unsupported legacy feature option DUK_OPT_FUNC_NONSTD_CALLER_PROPERTY used
  2914. #endif
  2915. #if defined(DUK_OPT_FUNC_NONSTD_SOURCE_PROPERTY)
  2916. #error unsupported legacy feature option DUK_OPT_FUNC_NONSTD_SOURCE_PROPERTY used
  2917. #endif
  2918. #if defined(DUK_OPT_GC_TORTURE)
  2919. #error unsupported legacy feature option DUK_OPT_GC_TORTURE used
  2920. #endif
  2921. #if defined(DUK_OPT_HAVE_CUSTOM_H)
  2922. #error unsupported legacy feature option DUK_OPT_HAVE_CUSTOM_H used
  2923. #endif
  2924. #if defined(DUK_OPT_HEAPPTR16)
  2925. #error unsupported legacy feature option DUK_OPT_HEAPPTR16 used
  2926. #endif
  2927. #if defined(DUK_OPT_HEAPPTR_DEC16)
  2928. #error unsupported legacy feature option DUK_OPT_HEAPPTR_DEC16 used
  2929. #endif
  2930. #if defined(DUK_OPT_HEAPPTR_ENC16)
  2931. #error unsupported legacy feature option DUK_OPT_HEAPPTR_ENC16 used
  2932. #endif
  2933. #if defined(DUK_OPT_INTERRUPT_COUNTER)
  2934. #error unsupported legacy feature option DUK_OPT_INTERRUPT_COUNTER used
  2935. #endif
  2936. #if defined(DUK_OPT_JSON_STRINGIFY_FASTPATH)
  2937. #error unsupported legacy feature option DUK_OPT_JSON_STRINGIFY_FASTPATH used
  2938. #endif
  2939. #if defined(DUK_OPT_LIGHTFUNC_BUILTINS)
  2940. #error unsupported legacy feature option DUK_OPT_LIGHTFUNC_BUILTINS used
  2941. #endif
  2942. #if defined(DUK_OPT_NONSTD_FUNC_CALLER_PROPERTY)
  2943. #error unsupported legacy feature option DUK_OPT_NONSTD_FUNC_CALLER_PROPERTY used
  2944. #endif
  2945. #if defined(DUK_OPT_NONSTD_FUNC_SOURCE_PROPERTY)
  2946. #error unsupported legacy feature option DUK_OPT_NONSTD_FUNC_SOURCE_PROPERTY used
  2947. #endif
  2948. #if defined(DUK_OPT_NO_ARRAY_SPLICE_NONSTD_DELCOUNT)
  2949. #error unsupported legacy feature option DUK_OPT_NO_ARRAY_SPLICE_NONSTD_DELCOUNT used
  2950. #endif
  2951. #if defined(DUK_OPT_NO_AUGMENT_ERRORS)
  2952. #error unsupported legacy feature option DUK_OPT_NO_AUGMENT_ERRORS used
  2953. #endif
  2954. #if defined(DUK_OPT_NO_BROWSER_LIKE)
  2955. #error unsupported legacy feature option DUK_OPT_NO_BROWSER_LIKE used
  2956. #endif
  2957. #if defined(DUK_OPT_NO_BUFFEROBJECT_SUPPORT)
  2958. #error unsupported legacy feature option DUK_OPT_NO_BUFFEROBJECT_SUPPORT used
  2959. #endif
  2960. #if defined(DUK_OPT_NO_BYTECODE_DUMP_SUPPORT)
  2961. #error unsupported legacy feature option DUK_OPT_NO_BYTECODE_DUMP_SUPPORT used
  2962. #endif
  2963. #if defined(DUK_OPT_NO_COMMONJS_MODULES)
  2964. #error unsupported legacy feature option DUK_OPT_NO_COMMONJS_MODULES used
  2965. #endif
  2966. #if defined(DUK_OPT_NO_ES6_OBJECT_PROTO_PROPERTY)
  2967. #error unsupported legacy feature option DUK_OPT_NO_ES6_OBJECT_PROTO_PROPERTY used
  2968. #endif
  2969. #if defined(DUK_OPT_NO_ES6_OBJECT_SETPROTOTYPEOF)
  2970. #error unsupported legacy feature option DUK_OPT_NO_ES6_OBJECT_SETPROTOTYPEOF used
  2971. #endif
  2972. #if defined(DUK_OPT_NO_ES6_PROXY)
  2973. #error unsupported legacy feature option DUK_OPT_NO_ES6_PROXY used
  2974. #endif
  2975. #if defined(DUK_OPT_NO_FILE_IO)
  2976. #error unsupported legacy feature option DUK_OPT_NO_FILE_IO used
  2977. #endif
  2978. #if defined(DUK_OPT_NO_FUNC_STMT)
  2979. #error unsupported legacy feature option DUK_OPT_NO_FUNC_STMT used
  2980. #endif
  2981. #if defined(DUK_OPT_NO_JC)
  2982. #error unsupported legacy feature option DUK_OPT_NO_JC used
  2983. #endif
  2984. #if defined(DUK_OPT_NO_JSONC)
  2985. #error unsupported legacy feature option DUK_OPT_NO_JSONC used
  2986. #endif
  2987. #if defined(DUK_OPT_NO_JSONX)
  2988. #error unsupported legacy feature option DUK_OPT_NO_JSONX used
  2989. #endif
  2990. #if defined(DUK_OPT_NO_JX)
  2991. #error unsupported legacy feature option DUK_OPT_NO_JX used
  2992. #endif
  2993. #if defined(DUK_OPT_NO_MARK_AND_SWEEP)
  2994. #error unsupported legacy feature option DUK_OPT_NO_MARK_AND_SWEEP used
  2995. #endif
  2996. #if defined(DUK_OPT_NO_MS_STRINGTABLE_RESIZE)
  2997. #error unsupported legacy feature option DUK_OPT_NO_MS_STRINGTABLE_RESIZE used
  2998. #endif
  2999. #if defined(DUK_OPT_NO_NONSTD_ACCESSOR_KEY_ARGUMENT)
  3000. #error unsupported legacy feature option DUK_OPT_NO_NONSTD_ACCESSOR_KEY_ARGUMENT used
  3001. #endif
  3002. #if defined(DUK_OPT_NO_NONSTD_ARRAY_CONCAT_TRAILER)
  3003. #error unsupported legacy feature option DUK_OPT_NO_NONSTD_ARRAY_CONCAT_TRAILER used
  3004. #endif
  3005. #if defined(DUK_OPT_NO_NONSTD_ARRAY_MAP_TRAILER)
  3006. #error unsupported legacy feature option DUK_OPT_NO_NONSTD_ARRAY_MAP_TRAILER used
  3007. #endif
  3008. #if defined(DUK_OPT_NO_NONSTD_ARRAY_SPLICE_DELCOUNT)
  3009. #error unsupported legacy feature option DUK_OPT_NO_NONSTD_ARRAY_SPLICE_DELCOUNT used
  3010. #endif
  3011. #if defined(DUK_OPT_NO_NONSTD_FUNC_STMT)
  3012. #error unsupported legacy feature option DUK_OPT_NO_NONSTD_FUNC_STMT used
  3013. #endif
  3014. #if defined(DUK_OPT_NO_NONSTD_JSON_ESC_U2028_U2029)
  3015. #error unsupported legacy feature option DUK_OPT_NO_NONSTD_JSON_ESC_U2028_U2029 used
  3016. #endif
  3017. #if defined(DUK_OPT_NO_NONSTD_STRING_FROMCHARCODE_32BIT)
  3018. #error unsupported legacy feature option DUK_OPT_NO_NONSTD_STRING_FROMCHARCODE_32BIT used
  3019. #endif
  3020. #if defined(DUK_OPT_NO_OBJECT_ES6_PROTO_PROPERTY)
  3021. #error unsupported legacy feature option DUK_OPT_NO_OBJECT_ES6_PROTO_PROPERTY used
  3022. #endif
  3023. #if defined(DUK_OPT_NO_OBJECT_ES6_SETPROTOTYPEOF)
  3024. #error unsupported legacy feature option DUK_OPT_NO_OBJECT_ES6_SETPROTOTYPEOF used
  3025. #endif
  3026. #if defined(DUK_OPT_NO_OCTAL_SUPPORT)
  3027. #error unsupported legacy feature option DUK_OPT_NO_OCTAL_SUPPORT used
  3028. #endif
  3029. #if defined(DUK_OPT_NO_PACKED_TVAL)
  3030. #error unsupported legacy feature option DUK_OPT_NO_PACKED_TVAL used
  3031. #endif
  3032. #if defined(DUK_OPT_NO_PC2LINE)
  3033. #error unsupported legacy feature option DUK_OPT_NO_PC2LINE used
  3034. #endif
  3035. #if defined(DUK_OPT_NO_REFERENCE_COUNTING)
  3036. #error unsupported legacy feature option DUK_OPT_NO_REFERENCE_COUNTING used
  3037. #endif
  3038. #if defined(DUK_OPT_NO_REGEXP_SUPPORT)
  3039. #error unsupported legacy feature option DUK_OPT_NO_REGEXP_SUPPORT used
  3040. #endif
  3041. #if defined(DUK_OPT_NO_SECTION_B)
  3042. #error unsupported legacy feature option DUK_OPT_NO_SECTION_B used
  3043. #endif
  3044. #if defined(DUK_OPT_NO_SOURCE_NONBMP)
  3045. #error unsupported legacy feature option DUK_OPT_NO_SOURCE_NONBMP used
  3046. #endif
  3047. #if defined(DUK_OPT_NO_STRICT_DECL)
  3048. #error unsupported legacy feature option DUK_OPT_NO_STRICT_DECL used
  3049. #endif
  3050. #if defined(DUK_OPT_NO_TRACEBACKS)
  3051. #error unsupported legacy feature option DUK_OPT_NO_TRACEBACKS used
  3052. #endif
  3053. #if defined(DUK_OPT_NO_VERBOSE_ERRORS)
  3054. #error unsupported legacy feature option DUK_OPT_NO_VERBOSE_ERRORS used
  3055. #endif
  3056. #if defined(DUK_OPT_NO_VOLUNTARY_GC)
  3057. #error unsupported legacy feature option DUK_OPT_NO_VOLUNTARY_GC used
  3058. #endif
  3059. #if defined(DUK_OPT_NO_ZERO_BUFFER_DATA)
  3060. #error unsupported legacy feature option DUK_OPT_NO_ZERO_BUFFER_DATA used
  3061. #endif
  3062. #if defined(DUK_OPT_OBJSIZES16)
  3063. #error unsupported legacy feature option DUK_OPT_OBJSIZES16 used
  3064. #endif
  3065. #if defined(DUK_OPT_PANIC_HANDLER)
  3066. #error unsupported legacy feature option DUK_OPT_PANIC_HANDLER used
  3067. #endif
  3068. #if defined(DUK_OPT_REFCOUNT16)
  3069. #error unsupported legacy feature option DUK_OPT_REFCOUNT16 used
  3070. #endif
  3071. #if defined(DUK_OPT_SEGFAULT_ON_PANIC)
  3072. #error unsupported legacy feature option DUK_OPT_SEGFAULT_ON_PANIC used
  3073. #endif
  3074. #if defined(DUK_OPT_SELF_TESTS)
  3075. #error unsupported legacy feature option DUK_OPT_SELF_TESTS used
  3076. #endif
  3077. #if defined(DUK_OPT_SETJMP)
  3078. #error unsupported legacy feature option DUK_OPT_SETJMP used
  3079. #endif
  3080. #if defined(DUK_OPT_SHUFFLE_TORTURE)
  3081. #error unsupported legacy feature option DUK_OPT_SHUFFLE_TORTURE used
  3082. #endif
  3083. #if defined(DUK_OPT_SIGSETJMP)
  3084. #error unsupported legacy feature option DUK_OPT_SIGSETJMP used
  3085. #endif
  3086. #if defined(DUK_OPT_STRHASH16)
  3087. #error unsupported legacy feature option DUK_OPT_STRHASH16 used
  3088. #endif
  3089. #if defined(DUK_OPT_STRICT_UTF8_SOURCE)
  3090. #error unsupported legacy feature option DUK_OPT_STRICT_UTF8_SOURCE used
  3091. #endif
  3092. #if defined(DUK_OPT_STRLEN16)
  3093. #error unsupported legacy feature option DUK_OPT_STRLEN16 used
  3094. #endif
  3095. #if defined(DUK_OPT_STRTAB_CHAIN)
  3096. #error unsupported legacy feature option DUK_OPT_STRTAB_CHAIN used
  3097. #endif
  3098. #if defined(DUK_OPT_STRTAB_CHAIN_SIZE)
  3099. #error unsupported legacy feature option DUK_OPT_STRTAB_CHAIN_SIZE used
  3100. #endif
  3101. #if defined(DUK_OPT_TARGET_INFO)
  3102. #error unsupported legacy feature option DUK_OPT_TARGET_INFO used
  3103. #endif
  3104. #if defined(DUK_OPT_TRACEBACK_DEPTH)
  3105. #error unsupported legacy feature option DUK_OPT_TRACEBACK_DEPTH used
  3106. #endif
  3107. #if defined(DUK_OPT_UNDERSCORE_SETJMP)
  3108. #error unsupported legacy feature option DUK_OPT_UNDERSCORE_SETJMP used
  3109. #endif
  3110. #if defined(DUK_OPT_USER_INITJS)
  3111. #error unsupported legacy feature option DUK_OPT_USER_INITJS used
  3112. #endif
  3113. /*
  3114. * Checks for config option consistency (DUK_USE_xxx)
  3115. */
  3116. #if defined(DUK_USE_32BIT_PTRS)
  3117. #error unsupported config option used (option has been removed): DUK_USE_32BIT_PTRS
  3118. #endif
  3119. #if defined(DUK_USE_ALIGN_4)
  3120. #error unsupported config option used (option has been removed): DUK_USE_ALIGN_4
  3121. #endif
  3122. #if defined(DUK_USE_ALIGN_8)
  3123. #error unsupported config option used (option has been removed): DUK_USE_ALIGN_8
  3124. #endif
  3125. #if defined(DUK_USE_BROWSER_LIKE)
  3126. #error unsupported config option used (option has been removed): DUK_USE_BROWSER_LIKE
  3127. #endif
  3128. #if defined(DUK_USE_BUILTIN_INITJS)
  3129. #error unsupported config option used (option has been removed): DUK_USE_BUILTIN_INITJS
  3130. #endif
  3131. #if defined(DUK_USE_BYTEORDER_FORCED)
  3132. #error unsupported config option used (option has been removed): DUK_USE_BYTEORDER_FORCED
  3133. #endif
  3134. #if defined(DUK_USE_DATAPTR_DEC16) && !defined(DUK_USE_DATAPTR16)
  3135. #error config option DUK_USE_DATAPTR_DEC16 requires option DUK_USE_DATAPTR16 (which is missing)
  3136. #endif
  3137. #if defined(DUK_USE_DATAPTR_ENC16) && !defined(DUK_USE_DATAPTR16)
  3138. #error config option DUK_USE_DATAPTR_ENC16 requires option DUK_USE_DATAPTR16 (which is missing)
  3139. #endif
  3140. #if defined(DUK_USE_DDDPRINT)
  3141. #error unsupported config option used (option has been removed): DUK_USE_DDDPRINT
  3142. #endif
  3143. #if defined(DUK_USE_DDPRINT)
  3144. #error unsupported config option used (option has been removed): DUK_USE_DDPRINT
  3145. #endif
  3146. #if defined(DUK_USE_DEBUGGER_FWD_LOGGING)
  3147. #error unsupported config option used (option has been removed): DUK_USE_DEBUGGER_FWD_LOGGING
  3148. #endif
  3149. #if defined(DUK_USE_DEBUGGER_FWD_PRINTALERT)
  3150. #error unsupported config option used (option has been removed): DUK_USE_DEBUGGER_FWD_PRINTALERT
  3151. #endif
  3152. #if defined(DUK_USE_DEBUGGER_SUPPORT) && !defined(DUK_USE_INTERRUPT_COUNTER)
  3153. #error config option DUK_USE_DEBUGGER_SUPPORT requires option DUK_USE_INTERRUPT_COUNTER (which is missing)
  3154. #endif
  3155. #if defined(DUK_USE_DEEP_C_STACK)
  3156. #error unsupported config option used (option has been removed): DUK_USE_DEEP_C_STACK
  3157. #endif
  3158. #if defined(DUK_USE_DOUBLE_BE)
  3159. #error unsupported config option used (option has been removed): DUK_USE_DOUBLE_BE
  3160. #endif
  3161. #if defined(DUK_USE_DOUBLE_BE) && defined(DUK_USE_DOUBLE_LE)
  3162. #error config option DUK_USE_DOUBLE_BE conflicts with option DUK_USE_DOUBLE_LE (which is also defined)
  3163. #endif
  3164. #if defined(DUK_USE_DOUBLE_BE) && defined(DUK_USE_DOUBLE_ME)
  3165. #error config option DUK_USE_DOUBLE_BE conflicts with option DUK_USE_DOUBLE_ME (which is also defined)
  3166. #endif
  3167. #if defined(DUK_USE_DOUBLE_LE)
  3168. #error unsupported config option used (option has been removed): DUK_USE_DOUBLE_LE
  3169. #endif
  3170. #if defined(DUK_USE_DOUBLE_LE) && defined(DUK_USE_DOUBLE_BE)
  3171. #error config option DUK_USE_DOUBLE_LE conflicts with option DUK_USE_DOUBLE_BE (which is also defined)
  3172. #endif
  3173. #if defined(DUK_USE_DOUBLE_LE) && defined(DUK_USE_DOUBLE_ME)
  3174. #error config option DUK_USE_DOUBLE_LE conflicts with option DUK_USE_DOUBLE_ME (which is also defined)
  3175. #endif
  3176. #if defined(DUK_USE_DOUBLE_ME)
  3177. #error unsupported config option used (option has been removed): DUK_USE_DOUBLE_ME
  3178. #endif
  3179. #if defined(DUK_USE_DOUBLE_ME) && defined(DUK_USE_DOUBLE_LE)
  3180. #error config option DUK_USE_DOUBLE_ME conflicts with option DUK_USE_DOUBLE_LE (which is also defined)
  3181. #endif
  3182. #if defined(DUK_USE_DOUBLE_ME) && defined(DUK_USE_DOUBLE_BE)
  3183. #error config option DUK_USE_DOUBLE_ME conflicts with option DUK_USE_DOUBLE_BE (which is also defined)
  3184. #endif
  3185. #if defined(DUK_USE_DPRINT)
  3186. #error unsupported config option used (option has been removed): DUK_USE_DPRINT
  3187. #endif
  3188. #if defined(DUK_USE_DPRINT) && !defined(DUK_USE_DEBUG)
  3189. #error config option DUK_USE_DPRINT requires option DUK_USE_DEBUG (which is missing)
  3190. #endif
  3191. #if defined(DUK_USE_DPRINT_COLORS)
  3192. #error unsupported config option used (option has been removed): DUK_USE_DPRINT_COLORS
  3193. #endif
  3194. #if defined(DUK_USE_DPRINT_RDTSC)
  3195. #error unsupported config option used (option has been removed): DUK_USE_DPRINT_RDTSC
  3196. #endif
  3197. #if defined(DUK_USE_ES6_REGEXP_BRACES)
  3198. #error unsupported config option used (option has been removed): DUK_USE_ES6_REGEXP_BRACES
  3199. #endif
  3200. #if defined(DUK_USE_ESBC_MAX_BYTES) && !defined(DUK_USE_ESBC_LIMITS)
  3201. #error config option DUK_USE_ESBC_MAX_BYTES requires option DUK_USE_ESBC_LIMITS (which is missing)
  3202. #endif
  3203. #if defined(DUK_USE_ESBC_MAX_LINENUMBER) && !defined(DUK_USE_ESBC_LIMITS)
  3204. #error config option DUK_USE_ESBC_MAX_LINENUMBER requires option DUK_USE_ESBC_LIMITS (which is missing)
  3205. #endif
  3206. #if defined(DUK_USE_EXEC_TIMEOUT_CHECK) && !defined(DUK_USE_INTERRUPT_COUNTER)
  3207. #error config option DUK_USE_EXEC_TIMEOUT_CHECK requires option DUK_USE_INTERRUPT_COUNTER (which is missing)
  3208. #endif
  3209. #if defined(DUK_USE_EXTSTR_FREE) && !defined(DUK_USE_HSTRING_EXTDATA)
  3210. #error config option DUK_USE_EXTSTR_FREE requires option DUK_USE_HSTRING_EXTDATA (which is missing)
  3211. #endif
  3212. #if defined(DUK_USE_EXTSTR_INTERN_CHECK) && !defined(DUK_USE_HSTRING_EXTDATA)
  3213. #error config option DUK_USE_EXTSTR_INTERN_CHECK requires option DUK_USE_HSTRING_EXTDATA (which is missing)
  3214. #endif
  3215. #if defined(DUK_USE_FASTINT) && !defined(DUK_USE_64BIT_OPS)
  3216. #error config option DUK_USE_FASTINT requires option DUK_USE_64BIT_OPS (which is missing)
  3217. #endif
  3218. #if defined(DUK_USE_FILE_IO)
  3219. #error unsupported config option used (option has been removed): DUK_USE_FILE_IO
  3220. #endif
  3221. #if defined(DUK_USE_FULL_TVAL)
  3222. #error unsupported config option used (option has been removed): DUK_USE_FULL_TVAL
  3223. #endif
  3224. #if defined(DUK_USE_FUNCPTR_DEC16) && !defined(DUK_USE_FUNCPTR16)
  3225. #error config option DUK_USE_FUNCPTR_DEC16 requires option DUK_USE_FUNCPTR16 (which is missing)
  3226. #endif
  3227. #if defined(DUK_USE_FUNCPTR_ENC16) && !defined(DUK_USE_FUNCPTR16)
  3228. #error config option DUK_USE_FUNCPTR_ENC16 requires option DUK_USE_FUNCPTR16 (which is missing)
  3229. #endif
  3230. #if defined(DUK_USE_HASHBYTES_UNALIGNED_U32_ACCESS)
  3231. #error unsupported config option used (option has been removed): DUK_USE_HASHBYTES_UNALIGNED_U32_ACCESS
  3232. #endif
  3233. #if defined(DUK_USE_HEAPPTR16) && defined(DUK_USE_DEBUG)
  3234. #error config option DUK_USE_HEAPPTR16 conflicts with option DUK_USE_DEBUG (which is also defined)
  3235. #endif
  3236. #if defined(DUK_USE_HEAPPTR_DEC16) && !defined(DUK_USE_HEAPPTR16)
  3237. #error config option DUK_USE_HEAPPTR_DEC16 requires option DUK_USE_HEAPPTR16 (which is missing)
  3238. #endif
  3239. #if defined(DUK_USE_HEAPPTR_ENC16) && !defined(DUK_USE_HEAPPTR16)
  3240. #error config option DUK_USE_HEAPPTR_ENC16 requires option DUK_USE_HEAPPTR16 (which is missing)
  3241. #endif
  3242. #if defined(DUK_USE_INTEGER_BE)
  3243. #error unsupported config option used (option has been removed): DUK_USE_INTEGER_BE
  3244. #endif
  3245. #if defined(DUK_USE_INTEGER_BE) && defined(DUK_USE_INTEGER_LE)
  3246. #error config option DUK_USE_INTEGER_BE conflicts with option DUK_USE_INTEGER_LE (which is also defined)
  3247. #endif
  3248. #if defined(DUK_USE_INTEGER_BE) && defined(DUK_USE_INTEGER_ME)
  3249. #error config option DUK_USE_INTEGER_BE conflicts with option DUK_USE_INTEGER_ME (which is also defined)
  3250. #endif
  3251. #if defined(DUK_USE_INTEGER_LE)
  3252. #error unsupported config option used (option has been removed): DUK_USE_INTEGER_LE
  3253. #endif
  3254. #if defined(DUK_USE_INTEGER_LE) && defined(DUK_USE_INTEGER_BE)
  3255. #error config option DUK_USE_INTEGER_LE conflicts with option DUK_USE_INTEGER_BE (which is also defined)
  3256. #endif
  3257. #if defined(DUK_USE_INTEGER_LE) && defined(DUK_USE_INTEGER_ME)
  3258. #error config option DUK_USE_INTEGER_LE conflicts with option DUK_USE_INTEGER_ME (which is also defined)
  3259. #endif
  3260. #if defined(DUK_USE_INTEGER_ME)
  3261. #error unsupported config option used (option has been removed): DUK_USE_INTEGER_ME
  3262. #endif
  3263. #if defined(DUK_USE_INTEGER_ME) && defined(DUK_USE_INTEGER_LE)
  3264. #error config option DUK_USE_INTEGER_ME conflicts with option DUK_USE_INTEGER_LE (which is also defined)
  3265. #endif
  3266. #if defined(DUK_USE_INTEGER_ME) && defined(DUK_USE_INTEGER_BE)
  3267. #error config option DUK_USE_INTEGER_ME conflicts with option DUK_USE_INTEGER_BE (which is also defined)
  3268. #endif
  3269. #if defined(DUK_USE_MARKANDSWEEP_FINALIZER_TORTURE)
  3270. #error unsupported config option used (option has been removed): DUK_USE_MARKANDSWEEP_FINALIZER_TORTURE
  3271. #endif
  3272. #if defined(DUK_USE_MARK_AND_SWEEP)
  3273. #error unsupported config option used (option has been removed): DUK_USE_MARK_AND_SWEEP
  3274. #endif
  3275. #if defined(DUK_USE_MATH_FMAX)
  3276. #error unsupported config option used (option has been removed): DUK_USE_MATH_FMAX
  3277. #endif
  3278. #if defined(DUK_USE_MATH_FMIN)
  3279. #error unsupported config option used (option has been removed): DUK_USE_MATH_FMIN
  3280. #endif
  3281. #if defined(DUK_USE_MATH_ROUND)
  3282. #error unsupported config option used (option has been removed): DUK_USE_MATH_ROUND
  3283. #endif
  3284. #if defined(DUK_USE_MS_STRINGTABLE_RESIZE)
  3285. #error unsupported config option used (option has been removed): DUK_USE_MS_STRINGTABLE_RESIZE
  3286. #endif
  3287. #if defined(DUK_USE_NONSTD_REGEXP_DOLLAR_ESCAPE)
  3288. #error unsupported config option used (option has been removed): DUK_USE_NONSTD_REGEXP_DOLLAR_ESCAPE
  3289. #endif
  3290. #if defined(DUK_USE_NO_DOUBLE_ALIASING_SELFTEST)
  3291. #error unsupported config option used (option has been removed): DUK_USE_NO_DOUBLE_ALIASING_SELFTEST
  3292. #endif
  3293. #if defined(DUK_USE_OCTAL_SUPPORT)
  3294. #error unsupported config option used (option has been removed): DUK_USE_OCTAL_SUPPORT
  3295. #endif
  3296. #if defined(DUK_USE_PACKED_TVAL_POSSIBLE)
  3297. #error unsupported config option used (option has been removed): DUK_USE_PACKED_TVAL_POSSIBLE
  3298. #endif
  3299. #if defined(DUK_USE_PANIC_ABORT)
  3300. #error unsupported config option used (option has been removed): DUK_USE_PANIC_ABORT
  3301. #endif
  3302. #if defined(DUK_USE_PANIC_EXIT)
  3303. #error unsupported config option used (option has been removed): DUK_USE_PANIC_EXIT
  3304. #endif
  3305. #if defined(DUK_USE_PANIC_HANDLER)
  3306. #error unsupported config option used (option has been removed): DUK_USE_PANIC_HANDLER
  3307. #endif
  3308. #if defined(DUK_USE_PANIC_SEGFAULT)
  3309. #error unsupported config option used (option has been removed): DUK_USE_PANIC_SEGFAULT
  3310. #endif
  3311. #if defined(DUK_USE_POW_NETBSD_WORKAROUND)
  3312. #error unsupported config option used (option has been removed): DUK_USE_POW_NETBSD_WORKAROUND
  3313. #endif
  3314. #if defined(DUK_USE_RDTSC)
  3315. #error unsupported config option used (option has been removed): DUK_USE_RDTSC
  3316. #endif
  3317. #if defined(DUK_USE_REFZERO_FINALIZER_TORTURE)
  3318. #error unsupported config option used (option has been removed): DUK_USE_REFZERO_FINALIZER_TORTURE
  3319. #endif
  3320. #if defined(DUK_USE_ROM_GLOBAL_CLONE) && !defined(DUK_USE_ROM_STRINGS)
  3321. #error config option DUK_USE_ROM_GLOBAL_CLONE requires option DUK_USE_ROM_STRINGS (which is missing)
  3322. #endif
  3323. #if defined(DUK_USE_ROM_GLOBAL_CLONE) && !defined(DUK_USE_ROM_OBJECTS)
  3324. #error config option DUK_USE_ROM_GLOBAL_CLONE requires option DUK_USE_ROM_OBJECTS (which is missing)
  3325. #endif
  3326. #if defined(DUK_USE_ROM_GLOBAL_CLONE) && defined(DUK_USE_ROM_GLOBAL_INHERIT)
  3327. #error config option DUK_USE_ROM_GLOBAL_CLONE conflicts with option DUK_USE_ROM_GLOBAL_INHERIT (which is also defined)
  3328. #endif
  3329. #if defined(DUK_USE_ROM_GLOBAL_INHERIT) && !defined(DUK_USE_ROM_STRINGS)
  3330. #error config option DUK_USE_ROM_GLOBAL_INHERIT requires option DUK_USE_ROM_STRINGS (which is missing)
  3331. #endif
  3332. #if defined(DUK_USE_ROM_GLOBAL_INHERIT) && !defined(DUK_USE_ROM_OBJECTS)
  3333. #error config option DUK_USE_ROM_GLOBAL_INHERIT requires option DUK_USE_ROM_OBJECTS (which is missing)
  3334. #endif
  3335. #if defined(DUK_USE_ROM_GLOBAL_INHERIT) && defined(DUK_USE_ROM_GLOBAL_CLONE)
  3336. #error config option DUK_USE_ROM_GLOBAL_INHERIT conflicts with option DUK_USE_ROM_GLOBAL_CLONE (which is also defined)
  3337. #endif
  3338. #if defined(DUK_USE_ROM_OBJECTS) && !defined(DUK_USE_ROM_STRINGS)
  3339. #error config option DUK_USE_ROM_OBJECTS requires option DUK_USE_ROM_STRINGS (which is missing)
  3340. #endif
  3341. #if defined(DUK_USE_ROM_STRINGS) && !defined(DUK_USE_ROM_OBJECTS)
  3342. #error config option DUK_USE_ROM_STRINGS requires option DUK_USE_ROM_OBJECTS (which is missing)
  3343. #endif
  3344. #if defined(DUK_USE_SETJMP)
  3345. #error unsupported config option used (option has been removed): DUK_USE_SETJMP
  3346. #endif
  3347. #if defined(DUK_USE_SIGSETJMP)
  3348. #error unsupported config option used (option has been removed): DUK_USE_SIGSETJMP
  3349. #endif
  3350. #if defined(DUK_USE_STRTAB_CHAIN)
  3351. #error unsupported config option used (option has been removed): DUK_USE_STRTAB_CHAIN
  3352. #endif
  3353. #if defined(DUK_USE_STRTAB_CHAIN_SIZE)
  3354. #error unsupported config option used (option has been removed): DUK_USE_STRTAB_CHAIN_SIZE
  3355. #endif
  3356. #if defined(DUK_USE_STRTAB_CHAIN_SIZE) && !defined(DUK_USE_STRTAB_CHAIN)
  3357. #error config option DUK_USE_STRTAB_CHAIN_SIZE requires option DUK_USE_STRTAB_CHAIN (which is missing)
  3358. #endif
  3359. #if defined(DUK_USE_STRTAB_PROBE)
  3360. #error unsupported config option used (option has been removed): DUK_USE_STRTAB_PROBE
  3361. #endif
  3362. #if defined(DUK_USE_STRTAB_PTRCOMP) && !defined(DUK_USE_HEAPPTR16)
  3363. #error config option DUK_USE_STRTAB_PTRCOMP requires option DUK_USE_HEAPPTR16 (which is missing)
  3364. #endif
  3365. #if defined(DUK_USE_TAILCALL) && defined(DUK_USE_NONSTD_FUNC_CALLER_PROPERTY)
  3366. #error config option DUK_USE_TAILCALL conflicts with option DUK_USE_NONSTD_FUNC_CALLER_PROPERTY (which is also defined)
  3367. #endif
  3368. #if defined(DUK_USE_UNALIGNED_ACCESSES_POSSIBLE)
  3369. #error unsupported config option used (option has been removed): DUK_USE_UNALIGNED_ACCESSES_POSSIBLE
  3370. #endif
  3371. #if defined(DUK_USE_UNDERSCORE_SETJMP)
  3372. #error unsupported config option used (option has been removed): DUK_USE_UNDERSCORE_SETJMP
  3373. #endif
  3374. #if defined(DUK_USE_USER_INITJS)
  3375. #error unsupported config option used (option has been removed): DUK_USE_USER_INITJS
  3376. #endif
  3377. #if defined(DUK_USE_CPP_EXCEPTIONS) && !defined(__cplusplus)
  3378. #error DUK_USE_CPP_EXCEPTIONS enabled but not compiling with a C++ compiler
  3379. #endif
  3380. /*
  3381. * Convert DUK_USE_BYTEORDER, from whatever source, into currently used
  3382. * internal defines. If detection failed, #error out.
  3383. */
  3384. #if defined(DUK_USE_BYTEORDER)
  3385. #if (DUK_USE_BYTEORDER == 1)
  3386. #define DUK_USE_INTEGER_LE
  3387. #define DUK_USE_DOUBLE_LE
  3388. #elif (DUK_USE_BYTEORDER == 2)
  3389. #define DUK_USE_INTEGER_LE /* integer endianness is little on purpose */
  3390. #define DUK_USE_DOUBLE_ME
  3391. #elif (DUK_USE_BYTEORDER == 3)
  3392. #define DUK_USE_INTEGER_BE
  3393. #define DUK_USE_DOUBLE_BE
  3394. #else
  3395. #error unsupported: byte order invalid
  3396. #endif /* byte order */
  3397. #else
  3398. #error unsupported: byte order detection failed
  3399. #endif /* defined(DUK_USE_BYTEORDER) */
  3400. #endif /* DUK_CONFIG_H_INCLUDED */