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