duk_config.h 120 KB

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