duk_config.h 120 KB

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