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