-
Notifications
You must be signed in to change notification settings - Fork 0
/
duk_config.h
3779 lines (3486 loc) · 124 KB
/
duk_config.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* duk_config.h configuration header generated by genconfig.py.
*
* Git commit: 6001888049cb42656f8649db020e804bcdeca6a7
* Git describe: v2.5.0
* Git branch: master
*
* Supported platforms:
* - Mac OSX, iPhone, Darwin
* - Orbis
* - OpenBSD
* - Generic BSD
* - Atari ST TOS
* - AmigaOS
* - Durango (XboxOne)
* - Windows
* - Flashplayer (Crossbridge)
* - QNX
* - TI-Nspire
* - Emscripten
* - Android
* - Linux
* - Solaris
* - AIX
* - HPUX
* - Generic POSIX
* - Cygwin
* - Generic UNIX
* - Generic fallback
*
* Supported architectures:
* - x86
* - x64
* - x32
* - ARM 32-bit
* - ARM 64-bit
* - MIPS 32-bit
* - MIPS 64-bit
* - PowerPC 32-bit
* - PowerPC 64-bit
* - SPARC 32-bit
* - SPARC 64-bit
* - RISC-V 32-bit
* - RISC-V 64-bit
* - SuperH
* - Motorola 68k
* - Emscripten
* - Generic
*
* Supported compilers:
* - Clang
* - GCC
* - MSVC
* - Emscripten
* - TinyC
* - VBCC
* - Bruce's C compiler
* - Generic
*
*/
#if !defined(DUK_CONFIG_H_INCLUDED)
#define DUK_CONFIG_H_INCLUDED
/*
* Intermediate helper defines
*/
/* DLL build detection */
/* not configured for DLL build */
#undef DUK_F_DLL_BUILD
/* Apple OSX, iOS */
#if defined(__APPLE__)
#define DUK_F_APPLE
#endif
/* FreeBSD */
#if defined(__FreeBSD__) || defined(__FreeBSD)
#define DUK_F_FREEBSD
#endif
/* Orbis (PS4) variant */
#if defined(DUK_F_FREEBSD) && defined(__ORBIS__)
#define DUK_F_ORBIS
#endif
/* OpenBSD */
#if defined(__OpenBSD__) || defined(__OpenBSD)
#define DUK_F_OPENBSD
#endif
/* NetBSD */
#if defined(__NetBSD__) || defined(__NetBSD)
#define DUK_F_NETBSD
#endif
/* BSD variant */
#if defined(DUK_F_FREEBSD) || defined(DUK_F_NETBSD) || defined(DUK_F_OPENBSD) || \
defined(__bsdi__) || defined(__DragonFly__)
#define DUK_F_BSD
#endif
/* Atari ST TOS. __TOS__ defined by PureC. No platform define in VBCC
* apparently, so to use with VBCC user must define __TOS__ manually.
*/
#if defined(__TOS__)
#define DUK_F_TOS
#endif
/* Motorola 68K. Not defined by VBCC, so user must define one of these
* manually when using VBCC.
*/
#if defined(__m68k__) || defined(M68000) || defined(__MC68K__)
#define DUK_F_M68K
#endif
/* AmigaOS. Neither AMIGA nor __amigaos__ is defined on VBCC, so user must
* define 'AMIGA' manually when using VBCC.
*/
#if defined(AMIGA) || defined(__amigaos__)
#define DUK_F_AMIGAOS
#endif
/* PowerPC */
#if defined(__powerpc) || defined(__powerpc__) || defined(__PPC__)
#define DUK_F_PPC
#if defined(__PPC64__) || defined(__LP64__) || defined(_LP64)
#define DUK_F_PPC64
#else
#define DUK_F_PPC32
#endif
#endif
/* Durango (Xbox One) */
#if defined(_DURANGO) || defined(_XBOX_ONE)
#define DUK_F_DURANGO
#endif
/* Windows, both 32-bit and 64-bit */
#if defined(_WIN32) || defined(WIN32) || defined(_WIN64) || defined(WIN64) || \
defined(__WIN32__) || defined(__TOS_WIN__) || defined(__WINDOWS__)
#define DUK_F_WINDOWS
#if defined(_WIN64) || defined(WIN64)
#define DUK_F_WIN64
#else
#define DUK_F_WIN32
#endif
#endif
/* Flash player (e.g. Crossbridge) */
#if defined(__FLASHPLAYER__)
#define DUK_F_FLASHPLAYER
#endif
/* QNX */
#if defined(__QNX__)
#define DUK_F_QNX
#endif
/* TI-Nspire (using Ndless) */
#if defined(_TINSPIRE)
#define DUK_F_TINSPIRE
#endif
/* Emscripten (provided explicitly by user), improve if possible */
#if defined(EMSCRIPTEN)
#define DUK_F_EMSCRIPTEN
#endif
/* BCC (Bruce's C compiler): this is a "torture target" for compilation */
#if defined(__BCC__) || defined(__BCC_VERSION__)
#define DUK_F_BCC
#endif
#if defined(ANDROID) || defined(__ANDROID__)
#define DUK_F_ANDROID
#endif
/* Linux */
#if defined(__linux) || defined(__linux__) || defined(linux)
#define DUK_F_LINUX
#endif
/* illumos / Solaris */
#if defined(__sun) && defined(__SVR4)
#define DUK_F_SUN
#if defined(__SUNPRO_C) && (__SUNPRO_C < 0x550)
#define DUK_F_OLD_SOLARIS
/* Defines _ILP32 / _LP64 required by DUK_F_X86/DUK_F_X64. Platforms
* are processed before architectures, so this happens before the
* DUK_F_X86/DUK_F_X64 detection is emitted.
*/
#include <sys/isa_defs.h>
#endif
#endif
/* AIX */
#if defined(_AIX)
/* defined(__xlc__) || defined(__IBMC__): works but too wide */
#define DUK_F_AIX
#endif
/* HPUX */
#if defined(__hpux)
#define DUK_F_HPUX
#if defined(__ia64)
#define DUK_F_HPUX_ITANIUM
#endif
#endif
/* POSIX */
#if defined(__posix)
#define DUK_F_POSIX
#endif
/* Cygwin */
#if defined(__CYGWIN__)
#define DUK_F_CYGWIN
#endif
/* Generic Unix (includes Cygwin) */
#if defined(__unix) || defined(__unix__) || defined(unix) || \
defined(DUK_F_LINUX) || defined(DUK_F_BSD)
#define DUK_F_UNIX
#endif
/* Intel x86 (32-bit), x64 (64-bit) or x32 (64-bit but 32-bit pointers),
* define only one of DUK_F_X86, DUK_F_X64, DUK_F_X32.
* https://sites.google.com/site/x32abi/
*
* With DUK_F_OLD_SOLARIS the <sys/isa_defs.h> header must be included
* before this.
*/
#if defined(__amd64__) || defined(__amd64) || \
defined(__x86_64__) || defined(__x86_64) || \
defined(_M_X64) || defined(_M_AMD64)
#if defined(__ILP32__) || defined(_ILP32)
#define DUK_F_X32
#else
#define DUK_F_X64
#endif
#elif defined(i386) || defined(__i386) || defined(__i386__) || \
defined(__i486__) || defined(__i586__) || defined(__i686__) || \
defined(__IA32__) || defined(_M_IX86) || defined(__X86__) || \
defined(_X86_) || defined(__THW_INTEL__) || defined(__I86__)
#if defined(__LP64__) || defined(_LP64)
/* This should not really happen, but would indicate x64. */
#define DUK_F_X64
#else
#define DUK_F_X86
#endif
#endif
/* ARM */
#if defined(__arm__) || defined(__thumb__) || defined(_ARM) || defined(_M_ARM) || defined(_M_ARM64) || defined(__aarch64__)
#define DUK_F_ARM
#if defined(__LP64__) || defined(_LP64) || defined(__arm64) || defined(__arm64__) || defined(_M_ARM64) || defined(__aarch64__)
#define DUK_F_ARM64
#else
#define DUK_F_ARM32
#endif
#endif
/* MIPS. Related defines: __MIPSEB__, __MIPSEL__, __mips_isa_rev, __LP64__ */
#if defined(__mips__) || defined(mips) || defined(_MIPS_ISA) || \
defined(_R3000) || defined(_R4000) || defined(_R5900) || \
defined(_MIPS_ISA_MIPS1) || defined(_MIPS_ISA_MIPS2) || \
defined(_MIPS_ISA_MIPS3) || defined(_MIPS_ISA_MIPS4) || \
defined(__mips) || defined(__MIPS__)
#define DUK_F_MIPS
#if defined(__LP64__) || defined(_LP64) || defined(__mips64) || \
defined(__mips64__) || defined(__mips_n64)
#define DUK_F_MIPS64
#else
#define DUK_F_MIPS32
#endif
#endif
/* SPARC */
#if defined(sparc) || defined(__sparc) || defined(__sparc__)
#define DUK_F_SPARC
#if defined(__LP64__) || defined(_LP64)
#define DUK_F_SPARC64
#else
#define DUK_F_SPARC32
#endif
#endif
/* RISC-V, https://github.com/riscv/riscv-toolchain-conventions#cc-preprocessor-definitions */
#if defined(__riscv)
#define DUK_F_RISCV
#if defined(__riscv_xlen)
#if (__riscv_xlen == 32)
#define DUK_F_RISCV32
#elif (__riscv_xlen == 64)
#define DUK_F_RISCV64
#else
#error __riscv_xlen has unsupported value (not 32 or 64)
#endif
#else
#error __riscv defined without __riscv_xlen
#endif
#endif /* __riscv */
/* SuperH */
#if defined(__sh__) || \
defined(__sh1__) || defined(__SH1__) || \
defined(__sh2__) || defined(__SH2__) || \
defined(__sh3__) || defined(__SH3__) || \
defined(__sh4__) || defined(__SH4__) || \
defined(__sh5__) || defined(__SH5__)
#define DUK_F_SUPERH
#endif
/* Clang */
#if defined(__clang__)
#define DUK_F_CLANG
#endif
/* C++ */
#undef DUK_F_CPP
#if defined(__cplusplus)
#define DUK_F_CPP
#endif
/* C99 or above */
#undef DUK_F_C99
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
#define DUK_F_C99
#endif
/* C++11 or above */
#undef DUK_F_CPP11
#if defined(__cplusplus) && (__cplusplus >= 201103L)
#define DUK_F_CPP11
#endif
/* GCC. Clang also defines __GNUC__ so don't detect GCC if using Clang. */
#if defined(__GNUC__) && !defined(__clang__) && !defined(DUK_F_CLANG)
#define DUK_F_GCC
#if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
/* Convenience, e.g. gcc 4.5.1 == 40501; http://stackoverflow.com/questions/6031819/emulating-gccs-builtin-unreachable */
#define DUK_F_GCC_VERSION (__GNUC__ * 10000L + __GNUC_MINOR__ * 100L + __GNUC_PATCHLEVEL__)
#else
#error cannot figure out gcc version
#endif
#endif
/* MinGW. Also GCC flags (DUK_F_GCC) are enabled now. */
#if defined(__MINGW32__) || defined(__MINGW64__)
#define DUK_F_MINGW
#endif
/* MSVC */
#if defined(_MSC_VER)
/* MSVC preprocessor defines: http://msdn.microsoft.com/en-us/library/b0084kay.aspx
* _MSC_FULL_VER includes the build number, but it has at least two formats, see e.g.
* BOOST_MSVC_FULL_VER in http://www.boost.org/doc/libs/1_52_0/boost/config/compiler/visualc.hpp
*/
#define DUK_F_MSVC
#if defined(_MSC_FULL_VER)
#if (_MSC_FULL_VER > 100000000)
#define DUK_F_MSVC_FULL_VER _MSC_FULL_VER
#else
#define DUK_F_MSCV_FULL_VER (_MSC_FULL_VER * 10)
#endif
#endif
#endif /* _MSC_VER */
/* TinyC */
#if defined(__TINYC__)
/* http://bellard.org/tcc/tcc-doc.html#SEC9 */
#define DUK_F_TINYC
#endif
/* VBCC */
#if defined(__VBCC__)
#define DUK_F_VBCC
#endif
/* Atari Mint */
#if defined(__MINT__)
#define DUK_F_MINT
#endif
/*
* Platform autodetection
*/
/* Workaround for older C++ compilers before including <inttypes.h>,
* see e.g.: https://sourceware.org/bugzilla/show_bug.cgi?id=15366
*/
#if defined(__cplusplus) && !defined(__STDC_LIMIT_MACROS)
#define __STDC_LIMIT_MACROS
#endif
#if defined(__cplusplus) && !defined(__STDC_CONSTANT_MACROS)
#define __STDC_CONSTANT_MACROS
#endif
#if defined(DUK_F_APPLE)
/* --- Mac OSX, iPhone, Darwin --- */
#define DUK_USE_DATE_NOW_GETTIMEOFDAY
#define DUK_USE_DATE_TZO_GMTIME_R
#define DUK_USE_DATE_PRS_STRPTIME
#define DUK_USE_DATE_FMT_STRFTIME
#include <TargetConditionals.h>
#include <architecture/byte_order.h>
#include <sys/param.h>
#include <sys/time.h>
#include <time.h>
/* http://stackoverflow.com/questions/5919996/how-to-detect-reliably-mac-os-x-ios-linux-windows-in-c-preprocessor */
#if TARGET_IPHONE_SIMULATOR
#define DUK_USE_OS_STRING "iphone-sim"
#elif TARGET_OS_IPHONE
#define DUK_USE_OS_STRING "iphone"
#elif TARGET_OS_MAC
#define DUK_USE_OS_STRING "osx"
#else
#define DUK_USE_OS_STRING "osx-unknown"
#endif
/* Use _setjmp() on Apple by default, see GH-55. */
#define DUK_JMPBUF_TYPE jmp_buf
#define DUK_SETJMP(jb) _setjmp((jb))
#define DUK_LONGJMP(jb) _longjmp((jb), 1)
#elif defined(DUK_F_ORBIS)
/* --- Orbis --- */
/* Orbis = PS4 */
#define DUK_USE_DATE_NOW_GETTIMEOFDAY
#define DUK_USE_DATE_TZO_GMTIME_S
/* no parsing (not an error) */
#define DUK_USE_DATE_FMT_STRFTIME
#include <sys/types.h>
#include <machine/endian.h>
#include <sys/param.h>
#include <sys/time.h>
#include <time.h>
#define DUK_USE_OS_STRING "orbis"
#elif defined(DUK_F_OPENBSD)
/* --- OpenBSD --- */
/* http://www.monkey.org/openbsd/archive/ports/0401/msg00089.html */
#define DUK_USE_DATE_NOW_GETTIMEOFDAY
#define DUK_USE_DATE_TZO_GMTIME_R
#define DUK_USE_DATE_PRS_STRPTIME
#define DUK_USE_DATE_FMT_STRFTIME
#include <sys/types.h>
#include <sys/endian.h>
#include <sys/param.h>
#include <sys/time.h>
#include <time.h>
#define DUK_USE_OS_STRING "openbsd"
#elif defined(DUK_F_BSD)
/* --- Generic BSD --- */
#define DUK_USE_DATE_NOW_GETTIMEOFDAY
#define DUK_USE_DATE_TZO_GMTIME_R
#define DUK_USE_DATE_PRS_STRPTIME
#define DUK_USE_DATE_FMT_STRFTIME
#include <sys/types.h>
#include <sys/endian.h>
#include <sys/param.h>
#include <sys/time.h>
#include <time.h>
#define DUK_USE_OS_STRING "bsd"
#elif defined(DUK_F_TOS)
/* --- Atari ST TOS --- */
#define DUK_USE_DATE_NOW_TIME
#define DUK_USE_DATE_TZO_GMTIME
/* no parsing (not an error) */
#define DUK_USE_DATE_FMT_STRFTIME
#include <time.h>
#define DUK_USE_OS_STRING "tos"
/* TOS on M68K is always big endian. */
#if !defined(DUK_USE_BYTEORDER) && defined(DUK_F_M68K)
#define DUK_USE_BYTEORDER 3
#endif
#elif defined(DUK_F_AMIGAOS)
/* --- AmigaOS --- */
#if defined(DUK_F_M68K)
/* AmigaOS on M68k */
#define DUK_USE_DATE_NOW_TIME
#define DUK_USE_DATE_TZO_GMTIME
/* no parsing (not an error) */
#define DUK_USE_DATE_FMT_STRFTIME
#include <time.h>
#elif defined(DUK_F_PPC)
#define DUK_USE_DATE_NOW_GETTIMEOFDAY
#define DUK_USE_DATE_TZO_GMTIME_R
#define DUK_USE_DATE_PRS_STRPTIME
#define DUK_USE_DATE_FMT_STRFTIME
#include <time.h>
#if !defined(UINTPTR_MAX)
#define UINTPTR_MAX UINT_MAX
#endif
#else
#error AmigaOS but not M68K/PPC, not supported now
#endif
#define DUK_USE_OS_STRING "amigaos"
/* AmigaOS on M68K or PPC is always big endian. */
#if !defined(DUK_USE_BYTEORDER) && (defined(DUK_F_M68K) || defined(DUK_F_PPC))
#define DUK_USE_BYTEORDER 3
#endif
#elif defined(DUK_F_DURANGO)
/* --- Durango (XboxOne) --- */
/* Durango = XboxOne
* Configuration is nearly identical to Windows, except for
* DUK_USE_DATE_TZO_WINDOWS.
*/
/* Initial fix: disable secure CRT related warnings when compiling Duktape
* itself (must be defined before including Windows headers). Don't define
* for user code including duktape.h.
*/
#if defined(DUK_COMPILING_DUKTAPE) && !defined(_CRT_SECURE_NO_WARNINGS)
#define _CRT_SECURE_NO_WARNINGS
#endif
/* MSVC does not have sys/param.h */
#define DUK_USE_DATE_NOW_WINDOWS
#define DUK_USE_DATE_TZO_WINDOWS_NO_DST
/* Note: PRS and FMT are intentionally left undefined for now. This means
* there is no platform specific date parsing/formatting but there is still
* the ISO 8601 standard format.
*/
#if defined(DUK_COMPILING_DUKTAPE)
/* Only include when compiling Duktape to avoid polluting application build
* with a lot of unnecessary defines.
*/
#include <windows.h>
#endif
#define DUK_USE_OS_STRING "durango"
#if !defined(DUK_USE_BYTEORDER)
#define DUK_USE_BYTEORDER 1
#endif
#elif defined(DUK_F_WINDOWS)
/* --- Windows --- */
/* Windows version can't obviously be determined at compile time,
* but _WIN32_WINNT indicates the minimum version targeted:
* - https://msdn.microsoft.com/en-us/library/6sehtctf.aspx
*/
/* Initial fix: disable secure CRT related warnings when compiling Duktape
* itself (must be defined before including Windows headers). Don't define
* for user code including duktape.h.
*/
#if defined(DUK_COMPILING_DUKTAPE) && !defined(_CRT_SECURE_NO_WARNINGS)
#define _CRT_SECURE_NO_WARNINGS
#endif
/* Windows 32-bit and 64-bit are currently the same. */
/* MSVC does not have sys/param.h */
#if defined(DUK_COMPILING_DUKTAPE)
/* Only include when compiling Duktape to avoid polluting application build
* with a lot of unnecessary defines.
*/
#include <windows.h>
#endif
/* GetSystemTimePreciseAsFileTime() available from Windows 8:
* https://msdn.microsoft.com/en-us/library/windows/desktop/hh706895(v=vs.85).aspx
*/
#if defined(DUK_USE_DATE_NOW_WINDOWS_SUBMS) || defined(DUK_USE_DATE_NOW_WINDOWS)
/* User forced provider. */
#else
#if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0602)
#define DUK_USE_DATE_NOW_WINDOWS_SUBMS
#else
#define DUK_USE_DATE_NOW_WINDOWS
#endif
#endif
#define DUK_USE_DATE_TZO_WINDOWS
/* Note: PRS and FMT are intentionally left undefined for now. This means
* there is no platform specific date parsing/formatting but there is still
* the ISO 8601 standard format.
*/
/* QueryPerformanceCounter() may go backwards in Windows XP, so enable for
* Vista and later: https://msdn.microsoft.com/en-us/library/windows/desktop/dn553408(v=vs.85).aspx#qpc_support_in_windows_versions
*/
#if !defined(DUK_USE_GET_MONOTONIC_TIME_WINDOWS_QPC) && \
defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0600)
#define DUK_USE_GET_MONOTONIC_TIME_WINDOWS_QPC
#endif
#define DUK_USE_OS_STRING "windows"
/* On Windows, assume we're little endian. Even Itanium which has a
* configurable endianness runs little endian in Windows.
*/
#if !defined(DUK_USE_BYTEORDER)
#define DUK_USE_BYTEORDER 1
#endif
#elif defined(DUK_F_FLASHPLAYER)
/* --- Flashplayer (Crossbridge) --- */
#define DUK_USE_DATE_NOW_GETTIMEOFDAY
#define DUK_USE_DATE_TZO_GMTIME_R
#define DUK_USE_DATE_PRS_STRPTIME
#define DUK_USE_DATE_FMT_STRFTIME
#include <endian.h>
#include <sys/param.h>
#include <sys/time.h>
#include <time.h>
#define DUK_USE_OS_STRING "flashplayer"
#if !defined(DUK_USE_BYTEORDER) && defined(DUK_F_FLASHPLAYER)
#define DUK_USE_BYTEORDER 1
#endif
#elif defined(DUK_F_QNX)
/* --- QNX --- */
#if defined(DUK_F_QNX) && defined(DUK_COMPILING_DUKTAPE)
/* See: /opt/qnx650/target/qnx6/usr/include/sys/platform.h */
#define _XOPEN_SOURCE 600
#define _POSIX_C_SOURCE 200112L
#endif
#define DUK_USE_DATE_NOW_GETTIMEOFDAY
#define DUK_USE_DATE_TZO_GMTIME_R
#define DUK_USE_DATE_PRS_STRPTIME
#define DUK_USE_DATE_FMT_STRFTIME
#include <sys/types.h>
#include <sys/param.h>
#include <sys/time.h>
#include <time.h>
#define DUK_USE_OS_STRING "qnx"
#elif defined(DUK_F_TINSPIRE)
/* --- TI-Nspire --- */
#if defined(DUK_COMPILING_DUKTAPE) && !defined(_XOPEN_SOURCE)
#define _XOPEN_SOURCE /* e.g. strptime */
#endif
#define DUK_USE_DATE_NOW_GETTIMEOFDAY
#define DUK_USE_DATE_TZO_GMTIME_R
#define DUK_USE_DATE_PRS_STRPTIME
#define DUK_USE_DATE_FMT_STRFTIME
#include <sys/types.h>
#include <sys/param.h>
#include <sys/time.h>
#include <time.h>
#define DUK_USE_OS_STRING "tinspire"
#elif defined(DUK_F_EMSCRIPTEN)
/* --- Emscripten --- */
#if defined(DUK_COMPILING_DUKTAPE)
#if !defined(_POSIX_C_SOURCE)
#define _POSIX_C_SOURCE 200809L
#endif
#if !defined(_GNU_SOURCE)
#define _GNU_SOURCE /* e.g. getdate_r */
#endif
#if !defined(_XOPEN_SOURCE)
#define _XOPEN_SOURCE /* e.g. strptime */
#endif
#endif /* DUK_COMPILING_DUKTAPE */
#include <sys/types.h>
#if defined(DUK_F_BCC)
/* no endian.h */
#else
#include <endian.h>
#endif /* DUK_F_BCC */
#include <sys/param.h>
#include <sys/time.h>
#include <time.h>
#include <stdint.h>
#define DUK_USE_DATE_NOW_GETTIMEOFDAY
#define DUK_USE_DATE_TZO_GMTIME_R
#define DUK_USE_DATE_PRS_STRPTIME
#define DUK_USE_DATE_FMT_STRFTIME
#define DUK_USE_OS_STRING "emscripten"
#elif defined(DUK_F_ANDROID)
/* --- Android --- */
#if defined(DUK_COMPILING_DUKTAPE)
#if !defined(_POSIX_C_SOURCE)
#define _POSIX_C_SOURCE 200809L
#endif
#if !defined(_GNU_SOURCE)
#define _GNU_SOURCE /* e.g. getdate_r */
#endif
#if !defined(_XOPEN_SOURCE)
#define _XOPEN_SOURCE /* e.g. strptime */
#endif
#endif /* DUK_COMPILING_DUKTAPE */
#include <sys/types.h>
#if defined(DUK_F_BCC)
/* no endian.h or stdint.h */
#else
#include <endian.h>
#include <stdint.h>
#endif /* DUK_F_BCC */
#include <sys/param.h>
#include <sys/time.h>
#include <time.h>
#define DUK_USE_DATE_NOW_GETTIMEOFDAY
#define DUK_USE_DATE_TZO_GMTIME_R
#define DUK_USE_DATE_PRS_STRPTIME
#define DUK_USE_DATE_FMT_STRFTIME
#if 0 /* XXX: safe condition? */
#define DUK_USE_GET_MONOTONIC_TIME_CLOCK_GETTIME
#endif
#define DUK_USE_OS_STRING "android"
#elif defined(DUK_F_LINUX)
/* --- Linux --- */
#if defined(DUK_COMPILING_DUKTAPE)
#if !defined(_POSIX_C_SOURCE)
#define _POSIX_C_SOURCE 200809L
#endif
#if !defined(_GNU_SOURCE)
#define _GNU_SOURCE /* e.g. getdate_r */
#endif
#if !defined(_XOPEN_SOURCE)
#define _XOPEN_SOURCE /* e.g. strptime */
#endif
#endif /* DUK_COMPILING_DUKTAPE */
#include <sys/types.h>
#if defined(DUK_F_BCC)
/* no endian.h or stdint.h */
#else
#include <endian.h>
#include <stdint.h>
#endif /* DUK_F_BCC */
#include <sys/param.h>
#include <sys/time.h>
#include <time.h>
#define DUK_USE_DATE_NOW_GETTIMEOFDAY
#define DUK_USE_DATE_TZO_GMTIME_R
#define DUK_USE_DATE_PRS_STRPTIME
#define DUK_USE_DATE_FMT_STRFTIME
#if 0 /* XXX: safe condition? */
#define DUK_USE_GET_MONOTONIC_TIME_CLOCK_GETTIME
#endif
#define DUK_USE_OS_STRING "linux"
#elif defined(DUK_F_SUN)
/* --- Solaris --- */
#define DUK_USE_DATE_NOW_GETTIMEOFDAY
#define DUK_USE_DATE_TZO_GMTIME_R
#define DUK_USE_DATE_PRS_STRPTIME
#define DUK_USE_DATE_FMT_STRFTIME
#include <sys/types.h>
#if defined(DUK_F_OLD_SOLARIS)
/* Old Solaris with no endian.h, stdint.h */
#define DUK_F_NO_STDINT_H
#if !defined(DUK_USE_BYTEORDER)
#define DUK_USE_BYTEORDER 3
#endif
#else /* DUK_F_OLD_SOLARIS */
#include <sys/param.h>
#endif /* DUK_F_OLD_SOLARIS */
#include <sys/param.h>
#include <sys/time.h>
#include <time.h>
#define DUK_USE_OS_STRING "solaris"
#elif defined(DUK_F_AIX)
/* --- AIX --- */
#if !defined(DUK_USE_BYTEORDER)
#define DUK_USE_BYTEORDER 3
#endif
#define DUK_USE_DATE_NOW_GETTIMEOFDAY
#define DUK_USE_DATE_TZO_GMTIME_R
#define DUK_USE_DATE_PRS_STRPTIME
#define DUK_USE_DATE_FMT_STRFTIME
#include <sys/param.h>
#include <sys/time.h>
#include <time.h>
#define DUK_USE_OS_STRING "aix"
#elif defined(DUK_F_HPUX)
/* --- HPUX --- */
#define DUK_F_NO_STDINT_H
#if !defined(DUK_USE_BYTEORDER)
#define DUK_USE_BYTEORDER 3
#endif
#define DUK_USE_DATE_NOW_GETTIMEOFDAY
#define DUK_USE_DATE_TZO_GMTIME_R
#define DUK_USE_DATE_PRS_STRPTIME
#define DUK_USE_DATE_FMT_STRFTIME
#include <sys/param.h>
#include <sys/time.h>
#include <time.h>
#define DUK_USE_OS_STRING "hpux"
#elif defined(DUK_F_POSIX)
/* --- Generic POSIX --- */
#define DUK_USE_DATE_NOW_GETTIMEOFDAY
#define DUK_USE_DATE_TZO_GMTIME_R
#define DUK_USE_DATE_PRS_STRPTIME
#define DUK_USE_DATE_FMT_STRFTIME
#include <sys/types.h>
#include <endian.h>
#include <sys/param.h>
#include <sys/time.h>
#include <time.h>
#define DUK_USE_OS_STRING "posix"
#elif defined(DUK_F_CYGWIN)
/* --- Cygwin --- */
/* don't use strptime() for now */
#define DUK_USE_DATE_NOW_GETTIMEOFDAY
#define DUK_USE_DATE_TZO_GMTIME_R
#define DUK_USE_DATE_FMT_STRFTIME
#include <sys/types.h>
#include <endian.h>
#include <sys/param.h>
#include <sys/time.h>
#include <time.h>
#define DUK_JMPBUF_TYPE jmp_buf
#define DUK_SETJMP(jb) _setjmp((jb))
#define DUK_LONGJMP(jb) _longjmp((jb), 1)
#define DUK_USE_OS_STRING "windows"
#elif defined(DUK_F_UNIX)
/* --- Generic UNIX --- */
#define DUK_USE_DATE_NOW_GETTIMEOFDAY
#define DUK_USE_DATE_TZO_GMTIME_R
#define DUK_USE_DATE_PRS_STRPTIME
#define DUK_USE_DATE_FMT_STRFTIME
#include <time.h>
#include <sys/time.h>
#define DUK_USE_OS_STRING "unknown"
#else
/* --- Generic fallback --- */
/* The most portable current time provider is time(), but it only has a
* one second resolution.
*/
#define DUK_USE_DATE_NOW_TIME
/* The most portable way to figure out local time offset is gmtime(),
* but it's not thread safe so use with caution.
*/
#define DUK_USE_DATE_TZO_GMTIME
/* Avoid custom date parsing and formatting for portability. */
#undef DUK_USE_DATE_PRS_STRPTIME
#undef DUK_USE_DATE_FMT_STRFTIME
/* Rely on C89 headers only; time.h must be here. */
#include <time.h>
#define DUK_USE_OS_STRING "unknown"
#endif /* autodetect platform */
/* Shared includes: C89 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h> /* varargs */
#include <setjmp.h>
#include <stddef.h> /* e.g. ptrdiff_t */
#include <math.h>
#include <limits.h>
/* date.h is omitted, and included per platform */
/* Shared includes: stdint.h is C99 */
#if defined(DUK_F_NO_STDINT_H)
/* stdint.h not available */
#else
/* Technically C99 (C++11) but found in many systems. On some systems
* __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS must be defined before
* including stdint.h (see above).
*/
#include <stdint.h>
#endif
/* <exception> is only included if needed, based on DUK_USE_xxx flags. */
/*
* Architecture autodetection
*/
#if defined(DUK_F_X86)
/* --- x86 --- */
#define DUK_USE_ARCH_STRING "x86"
#if !defined(DUK_USE_BYTEORDER)
#define DUK_USE_BYTEORDER 1
#endif
#define DUK_USE_PACKED_TVAL
/* FreeBSD, -m32, and clang prior to 5.0 has union aliasing issues which
* break duk_tval copying. Disable packed duk_tval automatically.
*/
#if defined(DUK_F_FREEBSD) && defined(DUK_F_X86) && \
defined(__clang__) && defined(__clang_major__) && (__clang_major__ < 5)
#undef DUK_USE_PACKED_TVAL
#endif
#define DUK_F_PACKED_TVAL_PROVIDED
#elif defined(DUK_F_X64)
/* --- x64 --- */
#define DUK_USE_ARCH_STRING "x64"
#if !defined(DUK_USE_BYTEORDER)
#define DUK_USE_BYTEORDER 1
#endif
#undef DUK_USE_PACKED_TVAL
#define DUK_F_PACKED_TVAL_PROVIDED
#elif defined(DUK_F_X32)
/* --- x32 --- */
#define DUK_USE_ARCH_STRING "x32"
#if !defined(DUK_USE_BYTEORDER)
#define DUK_USE_BYTEORDER 1
#endif
#define DUK_USE_PACKED_TVAL
#define DUK_F_PACKED_TVAL_PROVIDED
#elif defined(DUK_F_ARM32)
/* --- ARM 32-bit --- */
#define DUK_USE_ARCH_STRING "arm32"
/* Byte order varies, so rely on autodetect. */
#define DUK_USE_PACKED_TVAL
#define DUK_F_PACKED_TVAL_PROVIDED
#elif defined(DUK_F_ARM64)
/* --- ARM 64-bit --- */
#define DUK_USE_ARCH_STRING "arm64"
/* Byte order varies, so rely on autodetect. */
#undef DUK_USE_PACKED_TVAL
#define DUK_F_PACKED_TVAL_PROVIDED
#elif defined(DUK_F_MIPS32)
/* --- MIPS 32-bit --- */
#define DUK_USE_ARCH_STRING "mips32"
/* MIPS byte order varies so rely on autodetection. */
#define DUK_USE_PACKED_TVAL
#define DUK_F_PACKED_TVAL_PROVIDED
#elif defined(DUK_F_MIPS64)
/* --- MIPS 64-bit --- */
#define DUK_USE_ARCH_STRING "mips64"
/* MIPS byte order varies so rely on autodetection. */
#undef DUK_USE_PACKED_TVAL
#define DUK_F_PACKED_TVAL_PROVIDED
#elif defined(DUK_F_PPC32)
/* --- PowerPC 32-bit --- */
#define DUK_USE_ARCH_STRING "ppc32"
#if !defined(DUK_USE_BYTEORDER)
#define DUK_USE_BYTEORDER 3
#endif
#define DUK_USE_PACKED_TVAL
#define DUK_F_PACKED_TVAL_PROVIDED
#elif defined(DUK_F_PPC64)
/* --- PowerPC 64-bit --- */
#define DUK_USE_ARCH_STRING "ppc64"
#if !defined(DUK_USE_BYTEORDER)
#define DUK_USE_BYTEORDER 3
#endif
#undef DUK_USE_PACKED_TVAL
#define DUK_F_PACKED_TVAL_PROVIDED
#elif defined(DUK_F_SPARC32)
/* --- SPARC 32-bit --- */
#define DUK_USE_ARCH_STRING "sparc32"
/* SPARC byte order varies so rely on autodetection. */
#define DUK_USE_PACKED_TVAL
#define DUK_F_PACKED_TVAL_PROVIDED
#elif defined(DUK_F_SPARC64)
/* --- SPARC 64-bit --- */
#define DUK_USE_ARCH_STRING "sparc64"
/* SPARC byte order varies so rely on autodetection. */
#undef DUK_USE_PACKED_TVAL
#define DUK_F_PACKED_TVAL_PROVIDED
#elif defined(DUK_F_RISCV32)
/* --- RISC-V 32-bit --- */
#define DUK_USE_ARCH_STRING "riscv32"
#define DUK_USE_BYTEORDER 1
#define DUK_USE_PACKED_TVAL
#define DUK_F_PACKED_TVAL_PROVIDED
#elif defined(DUK_F_RISCV64)
/* --- RISC-V 64-bit --- */
#define DUK_USE_ARCH_STRING "riscv64"
#define DUK_USE_BYTEORDER 1
#undef DUK_USE_PACKED_TVAL
#define DUK_F_PACKED_TVAL_PROVIDED
#elif defined(DUK_F_SUPERH)
/* --- SuperH --- */
#define DUK_USE_ARCH_STRING "sh"
/* Byte order varies, rely on autodetection. */
#define DUK_USE_PACKED_TVAL