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