GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: node_constants.cc Lines: 344 344 100.0 %
Date: 2022-04-22 04:19:20 Branches: 9 18 50.0 %

Line Branch Exec Source
1
// Copyright Joyent, Inc. and other Node contributors.
2
//
3
// Permission is hereby granted, free of charge, to any person obtaining a
4
// copy of this software and associated documentation files (the
5
// "Software"), to deal in the Software without restriction, including
6
// without limitation the rights to use, copy, modify, merge, publish,
7
// distribute, sublicense, and/or sell copies of the Software, and to permit
8
// persons to whom the Software is furnished to do so, subject to the
9
// following conditions:
10
//
11
// The above copyright notice and this permission notice shall be included
12
// in all copies or substantial portions of the Software.
13
//
14
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20
// USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22
#include "env-inl.h"
23
#include "node_constants.h"
24
#include "node_internals.h"
25
#include "util-inl.h"
26
27
#include "zlib.h"
28
29
#if !defined(_MSC_VER)
30
#include <unistd.h>
31
#endif
32
33
#include <fcntl.h>
34
#include <sys/types.h>
35
#include <sys/stat.h>
36
37
38
#if HAVE_OPENSSL
39
#include <openssl/ec.h>
40
#include <openssl/ssl.h>
41
#ifndef OPENSSL_NO_ENGINE
42
#include <openssl/engine.h>
43
#endif  // !OPENSSL_NO_ENGINE
44
#endif  // HAVE_OPENSSL
45
46
#if defined(__POSIX__)
47
#include <dlfcn.h>
48
#endif
49
50
#if defined(_WIN32)
51
#include <io.h>  // _S_IREAD _S_IWRITE
52
#ifndef S_IRUSR
53
#define S_IRUSR _S_IREAD
54
#endif  // S_IRUSR
55
#ifndef S_IWUSR
56
#define S_IWUSR _S_IWRITE
57
#endif  // S_IWUSR
58
#endif
59
60
#include <cerrno>
61
#include <csignal>
62
#include <limits>
63
64
namespace node {
65
66
using v8::Local;
67
using v8::Object;
68
69
namespace {
70
71
632
void DefineErrnoConstants(Local<Object> target) {
72
#ifdef E2BIG
73
1896
  NODE_DEFINE_CONSTANT(target, E2BIG);
74
#endif
75
76
#ifdef EACCES
77
1896
  NODE_DEFINE_CONSTANT(target, EACCES);
78
#endif
79
80
#ifdef EADDRINUSE
81
1896
  NODE_DEFINE_CONSTANT(target, EADDRINUSE);
82
#endif
83
84
#ifdef EADDRNOTAVAIL
85
1896
  NODE_DEFINE_CONSTANT(target, EADDRNOTAVAIL);
86
#endif
87
88
#ifdef EAFNOSUPPORT
89
1896
  NODE_DEFINE_CONSTANT(target, EAFNOSUPPORT);
90
#endif
91
92
#ifdef EAGAIN
93
1896
  NODE_DEFINE_CONSTANT(target, EAGAIN);
94
#endif
95
96
#ifdef EALREADY
97
1896
  NODE_DEFINE_CONSTANT(target, EALREADY);
98
#endif
99
100
#ifdef EBADF
101
1896
  NODE_DEFINE_CONSTANT(target, EBADF);
102
#endif
103
104
#ifdef EBADMSG
105
1896
  NODE_DEFINE_CONSTANT(target, EBADMSG);
106
#endif
107
108
#ifdef EBUSY
109
1896
  NODE_DEFINE_CONSTANT(target, EBUSY);
110
#endif
111
112
#ifdef ECANCELED
113
1896
  NODE_DEFINE_CONSTANT(target, ECANCELED);
114
#endif
115
116
#ifdef ECHILD
117
1896
  NODE_DEFINE_CONSTANT(target, ECHILD);
118
#endif
119
120
#ifdef ECONNABORTED
121
1896
  NODE_DEFINE_CONSTANT(target, ECONNABORTED);
122
#endif
123
124
#ifdef ECONNREFUSED
125
1896
  NODE_DEFINE_CONSTANT(target, ECONNREFUSED);
126
#endif
127
128
#ifdef ECONNRESET
129
1896
  NODE_DEFINE_CONSTANT(target, ECONNRESET);
130
#endif
131
132
#ifdef EDEADLK
133
1896
  NODE_DEFINE_CONSTANT(target, EDEADLK);
134
#endif
135
136
#ifdef EDESTADDRREQ
137
1896
  NODE_DEFINE_CONSTANT(target, EDESTADDRREQ);
138
#endif
139
140
#ifdef EDOM
141
1896
  NODE_DEFINE_CONSTANT(target, EDOM);
142
#endif
143
144
#ifdef EDQUOT
145
1896
  NODE_DEFINE_CONSTANT(target, EDQUOT);
146
#endif
147
148
#ifdef EEXIST
149
1896
  NODE_DEFINE_CONSTANT(target, EEXIST);
150
#endif
151
152
#ifdef EFAULT
153
1896
  NODE_DEFINE_CONSTANT(target, EFAULT);
154
#endif
155
156
#ifdef EFBIG
157
1896
  NODE_DEFINE_CONSTANT(target, EFBIG);
158
#endif
159
160
#ifdef EHOSTUNREACH
161
1896
  NODE_DEFINE_CONSTANT(target, EHOSTUNREACH);
162
#endif
163
164
#ifdef EIDRM
165
1896
  NODE_DEFINE_CONSTANT(target, EIDRM);
166
#endif
167
168
#ifdef EILSEQ
169
1896
  NODE_DEFINE_CONSTANT(target, EILSEQ);
170
#endif
171
172
#ifdef EINPROGRESS
173
1896
  NODE_DEFINE_CONSTANT(target, EINPROGRESS);
174
#endif
175
176
#ifdef EINTR
177
1896
  NODE_DEFINE_CONSTANT(target, EINTR);
178
#endif
179
180
#ifdef EINVAL
181
1896
  NODE_DEFINE_CONSTANT(target, EINVAL);
182
#endif
183
184
#ifdef EIO
185
1896
  NODE_DEFINE_CONSTANT(target, EIO);
186
#endif
187
188
#ifdef EISCONN
189
1896
  NODE_DEFINE_CONSTANT(target, EISCONN);
190
#endif
191
192
#ifdef EISDIR
193
1896
  NODE_DEFINE_CONSTANT(target, EISDIR);
194
#endif
195
196
#ifdef ELOOP
197
1896
  NODE_DEFINE_CONSTANT(target, ELOOP);
198
#endif
199
200
#ifdef EMFILE
201
1896
  NODE_DEFINE_CONSTANT(target, EMFILE);
202
#endif
203
204
#ifdef EMLINK
205
1896
  NODE_DEFINE_CONSTANT(target, EMLINK);
206
#endif
207
208
#ifdef EMSGSIZE
209
1896
  NODE_DEFINE_CONSTANT(target, EMSGSIZE);
210
#endif
211
212
#ifdef EMULTIHOP
213
1896
  NODE_DEFINE_CONSTANT(target, EMULTIHOP);
214
#endif
215
216
#ifdef ENAMETOOLONG
217
1896
  NODE_DEFINE_CONSTANT(target, ENAMETOOLONG);
218
#endif
219
220
#ifdef ENETDOWN
221
1896
  NODE_DEFINE_CONSTANT(target, ENETDOWN);
222
#endif
223
224
#ifdef ENETRESET
225
1896
  NODE_DEFINE_CONSTANT(target, ENETRESET);
226
#endif
227
228
#ifdef ENETUNREACH
229
1896
  NODE_DEFINE_CONSTANT(target, ENETUNREACH);
230
#endif
231
232
#ifdef ENFILE
233
1896
  NODE_DEFINE_CONSTANT(target, ENFILE);
234
#endif
235
236
#ifdef ENOBUFS
237
1896
  NODE_DEFINE_CONSTANT(target, ENOBUFS);
238
#endif
239
240
#ifdef ENODATA
241
1896
  NODE_DEFINE_CONSTANT(target, ENODATA);
242
#endif
243
244
#ifdef ENODEV
245
1896
  NODE_DEFINE_CONSTANT(target, ENODEV);
246
#endif
247
248
#ifdef ENOENT
249
1896
  NODE_DEFINE_CONSTANT(target, ENOENT);
250
#endif
251
252
#ifdef ENOEXEC
253
1896
  NODE_DEFINE_CONSTANT(target, ENOEXEC);
254
#endif
255
256
#ifdef ENOLCK
257
1896
  NODE_DEFINE_CONSTANT(target, ENOLCK);
258
#endif
259
260
#ifdef ENOLINK
261
1896
  NODE_DEFINE_CONSTANT(target, ENOLINK);
262
#endif
263
264
#ifdef ENOMEM
265
1896
  NODE_DEFINE_CONSTANT(target, ENOMEM);
266
#endif
267
268
#ifdef ENOMSG
269
1896
  NODE_DEFINE_CONSTANT(target, ENOMSG);
270
#endif
271
272
#ifdef ENOPROTOOPT
273
1896
  NODE_DEFINE_CONSTANT(target, ENOPROTOOPT);
274
#endif
275
276
#ifdef ENOSPC
277
1896
  NODE_DEFINE_CONSTANT(target, ENOSPC);
278
#endif
279
280
#ifdef ENOSR
281
1896
  NODE_DEFINE_CONSTANT(target, ENOSR);
282
#endif
283
284
#ifdef ENOSTR
285
1896
  NODE_DEFINE_CONSTANT(target, ENOSTR);
286
#endif
287
288
#ifdef ENOSYS
289
1896
  NODE_DEFINE_CONSTANT(target, ENOSYS);
290
#endif
291
292
#ifdef ENOTCONN
293
1896
  NODE_DEFINE_CONSTANT(target, ENOTCONN);
294
#endif
295
296
#ifdef ENOTDIR
297
1896
  NODE_DEFINE_CONSTANT(target, ENOTDIR);
298
#endif
299
300
#ifdef ENOTEMPTY
301
1896
  NODE_DEFINE_CONSTANT(target, ENOTEMPTY);
302
#endif
303
304
#ifdef ENOTSOCK
305
1896
  NODE_DEFINE_CONSTANT(target, ENOTSOCK);
306
#endif
307
308
#ifdef ENOTSUP
309
1896
  NODE_DEFINE_CONSTANT(target, ENOTSUP);
310
#endif
311
312
#ifdef ENOTTY
313
1896
  NODE_DEFINE_CONSTANT(target, ENOTTY);
314
#endif
315
316
#ifdef ENXIO
317
1896
  NODE_DEFINE_CONSTANT(target, ENXIO);
318
#endif
319
320
#ifdef EOPNOTSUPP
321
1896
  NODE_DEFINE_CONSTANT(target, EOPNOTSUPP);
322
#endif
323
324
#ifdef EOVERFLOW
325
1896
  NODE_DEFINE_CONSTANT(target, EOVERFLOW);
326
#endif
327
328
#ifdef EPERM
329
1896
  NODE_DEFINE_CONSTANT(target, EPERM);
330
#endif
331
332
#ifdef EPIPE
333
1896
  NODE_DEFINE_CONSTANT(target, EPIPE);
334
#endif
335
336
#ifdef EPROTO
337
1896
  NODE_DEFINE_CONSTANT(target, EPROTO);
338
#endif
339
340
#ifdef EPROTONOSUPPORT
341
1896
  NODE_DEFINE_CONSTANT(target, EPROTONOSUPPORT);
342
#endif
343
344
#ifdef EPROTOTYPE
345
1896
  NODE_DEFINE_CONSTANT(target, EPROTOTYPE);
346
#endif
347
348
#ifdef ERANGE
349
1896
  NODE_DEFINE_CONSTANT(target, ERANGE);
350
#endif
351
352
#ifdef EROFS
353
1896
  NODE_DEFINE_CONSTANT(target, EROFS);
354
#endif
355
356
#ifdef ESPIPE
357
1896
  NODE_DEFINE_CONSTANT(target, ESPIPE);
358
#endif
359
360
#ifdef ESRCH
361
1896
  NODE_DEFINE_CONSTANT(target, ESRCH);
362
#endif
363
364
#ifdef ESTALE
365
1896
  NODE_DEFINE_CONSTANT(target, ESTALE);
366
#endif
367
368
#ifdef ETIME
369
1896
  NODE_DEFINE_CONSTANT(target, ETIME);
370
#endif
371
372
#ifdef ETIMEDOUT
373
1896
  NODE_DEFINE_CONSTANT(target, ETIMEDOUT);
374
#endif
375
376
#ifdef ETXTBSY
377
1896
  NODE_DEFINE_CONSTANT(target, ETXTBSY);
378
#endif
379
380
#ifdef EWOULDBLOCK
381
1896
  NODE_DEFINE_CONSTANT(target, EWOULDBLOCK);
382
#endif
383
384
#ifdef EXDEV
385
1264
  NODE_DEFINE_CONSTANT(target, EXDEV);
386
#endif
387
632
}
388
389
632
void DefineWindowsErrorConstants(Local<Object> target) {
390
#ifdef WSAEINTR
391
  NODE_DEFINE_CONSTANT(target, WSAEINTR);
392
#endif
393
394
#ifdef WSAEBADF
395
  NODE_DEFINE_CONSTANT(target, WSAEBADF);
396
#endif
397
398
#ifdef WSAEACCES
399
  NODE_DEFINE_CONSTANT(target, WSAEACCES);
400
#endif
401
402
#ifdef WSAEFAULT
403
  NODE_DEFINE_CONSTANT(target, WSAEFAULT);
404
#endif
405
406
#ifdef WSAEINVAL
407
  NODE_DEFINE_CONSTANT(target, WSAEINVAL);
408
#endif
409
410
#ifdef WSAEMFILE
411
  NODE_DEFINE_CONSTANT(target, WSAEMFILE);
412
#endif
413
414
#ifdef WSAEWOULDBLOCK
415
  NODE_DEFINE_CONSTANT(target, WSAEWOULDBLOCK);
416
#endif
417
418
#ifdef WSAEINPROGRESS
419
  NODE_DEFINE_CONSTANT(target, WSAEINPROGRESS);
420
#endif
421
422
#ifdef WSAEALREADY
423
  NODE_DEFINE_CONSTANT(target, WSAEALREADY);
424
#endif
425
426
#ifdef WSAENOTSOCK
427
  NODE_DEFINE_CONSTANT(target, WSAENOTSOCK);
428
#endif
429
430
#ifdef WSAEDESTADDRREQ
431
  NODE_DEFINE_CONSTANT(target, WSAEDESTADDRREQ);
432
#endif
433
434
#ifdef WSAEMSGSIZE
435
  NODE_DEFINE_CONSTANT(target, WSAEMSGSIZE);
436
#endif
437
438
#ifdef WSAEPROTOTYPE
439
  NODE_DEFINE_CONSTANT(target, WSAEPROTOTYPE);
440
#endif
441
442
#ifdef WSAENOPROTOOPT
443
  NODE_DEFINE_CONSTANT(target, WSAENOPROTOOPT);
444
#endif
445
446
#ifdef WSAEPROTONOSUPPORT
447
  NODE_DEFINE_CONSTANT(target, WSAEPROTONOSUPPORT);
448
#endif
449
450
#ifdef WSAESOCKTNOSUPPORT
451
  NODE_DEFINE_CONSTANT(target, WSAESOCKTNOSUPPORT);
452
#endif
453
454
#ifdef WSAEOPNOTSUPP
455
  NODE_DEFINE_CONSTANT(target, WSAEOPNOTSUPP);
456
#endif
457
458
#ifdef WSAEPFNOSUPPORT
459
  NODE_DEFINE_CONSTANT(target, WSAEPFNOSUPPORT);
460
#endif
461
462
#ifdef WSAEAFNOSUPPORT
463
  NODE_DEFINE_CONSTANT(target, WSAEAFNOSUPPORT);
464
#endif
465
466
#ifdef WSAEADDRINUSE
467
  NODE_DEFINE_CONSTANT(target, WSAEADDRINUSE);
468
#endif
469
470
#ifdef WSAEADDRNOTAVAIL
471
  NODE_DEFINE_CONSTANT(target, WSAEADDRNOTAVAIL);
472
#endif
473
474
#ifdef WSAENETDOWN
475
  NODE_DEFINE_CONSTANT(target, WSAENETDOWN);
476
#endif
477
478
#ifdef WSAENETUNREACH
479
  NODE_DEFINE_CONSTANT(target, WSAENETUNREACH);
480
#endif
481
482
#ifdef WSAENETRESET
483
  NODE_DEFINE_CONSTANT(target, WSAENETRESET);
484
#endif
485
486
#ifdef WSAECONNABORTED
487
  NODE_DEFINE_CONSTANT(target, WSAECONNABORTED);
488
#endif
489
490
#ifdef WSAECONNRESET
491
  NODE_DEFINE_CONSTANT(target, WSAECONNRESET);
492
#endif
493
494
#ifdef WSAENOBUFS
495
  NODE_DEFINE_CONSTANT(target, WSAENOBUFS);
496
#endif
497
498
#ifdef WSAEISCONN
499
  NODE_DEFINE_CONSTANT(target, WSAEISCONN);
500
#endif
501
502
#ifdef WSAENOTCONN
503
  NODE_DEFINE_CONSTANT(target, WSAENOTCONN);
504
#endif
505
506
#ifdef WSAESHUTDOWN
507
  NODE_DEFINE_CONSTANT(target, WSAESHUTDOWN);
508
#endif
509
510
#ifdef WSAETOOMANYREFS
511
  NODE_DEFINE_CONSTANT(target, WSAETOOMANYREFS);
512
#endif
513
514
#ifdef WSAETIMEDOUT
515
  NODE_DEFINE_CONSTANT(target, WSAETIMEDOUT);
516
#endif
517
518
#ifdef WSAECONNREFUSED
519
  NODE_DEFINE_CONSTANT(target, WSAECONNREFUSED);
520
#endif
521
522
#ifdef WSAELOOP
523
  NODE_DEFINE_CONSTANT(target, WSAELOOP);
524
#endif
525
526
#ifdef WSAENAMETOOLONG
527
  NODE_DEFINE_CONSTANT(target, WSAENAMETOOLONG);
528
#endif
529
530
#ifdef WSAEHOSTDOWN
531
  NODE_DEFINE_CONSTANT(target, WSAEHOSTDOWN);
532
#endif
533
534
#ifdef WSAEHOSTUNREACH
535
  NODE_DEFINE_CONSTANT(target, WSAEHOSTUNREACH);
536
#endif
537
538
#ifdef WSAENOTEMPTY
539
  NODE_DEFINE_CONSTANT(target, WSAENOTEMPTY);
540
#endif
541
542
#ifdef WSAEPROCLIM
543
  NODE_DEFINE_CONSTANT(target, WSAEPROCLIM);
544
#endif
545
546
#ifdef WSAEUSERS
547
  NODE_DEFINE_CONSTANT(target, WSAEUSERS);
548
#endif
549
550
#ifdef WSAEDQUOT
551
  NODE_DEFINE_CONSTANT(target, WSAEDQUOT);
552
#endif
553
554
#ifdef WSAESTALE
555
  NODE_DEFINE_CONSTANT(target, WSAESTALE);
556
#endif
557
558
#ifdef WSAEREMOTE
559
  NODE_DEFINE_CONSTANT(target, WSAEREMOTE);
560
#endif
561
562
#ifdef WSASYSNOTREADY
563
  NODE_DEFINE_CONSTANT(target, WSASYSNOTREADY);
564
#endif
565
566
#ifdef WSAVERNOTSUPPORTED
567
  NODE_DEFINE_CONSTANT(target, WSAVERNOTSUPPORTED);
568
#endif
569
570
#ifdef WSANOTINITIALISED
571
  NODE_DEFINE_CONSTANT(target, WSANOTINITIALISED);
572
#endif
573
574
#ifdef WSAEDISCON
575
  NODE_DEFINE_CONSTANT(target, WSAEDISCON);
576
#endif
577
578
#ifdef WSAENOMORE
579
  NODE_DEFINE_CONSTANT(target, WSAENOMORE);
580
#endif
581
582
#ifdef WSAECANCELLED
583
  NODE_DEFINE_CONSTANT(target, WSAECANCELLED);
584
#endif
585
586
#ifdef WSAEINVALIDPROCTABLE
587
  NODE_DEFINE_CONSTANT(target, WSAEINVALIDPROCTABLE);
588
#endif
589
590
#ifdef WSAEINVALIDPROVIDER
591
  NODE_DEFINE_CONSTANT(target, WSAEINVALIDPROVIDER);
592
#endif
593
594
#ifdef WSAEPROVIDERFAILEDINIT
595
  NODE_DEFINE_CONSTANT(target, WSAEPROVIDERFAILEDINIT);
596
#endif
597
598
#ifdef WSASYSCALLFAILURE
599
  NODE_DEFINE_CONSTANT(target, WSASYSCALLFAILURE);
600
#endif
601
602
#ifdef WSASERVICE_NOT_FOUND
603
  NODE_DEFINE_CONSTANT(target, WSASERVICE_NOT_FOUND);
604
#endif
605
606
#ifdef WSATYPE_NOT_FOUND
607
  NODE_DEFINE_CONSTANT(target, WSATYPE_NOT_FOUND);
608
#endif
609
610
#ifdef WSA_E_NO_MORE
611
  NODE_DEFINE_CONSTANT(target, WSA_E_NO_MORE);
612
#endif
613
614
#ifdef WSA_E_CANCELLED
615
  NODE_DEFINE_CONSTANT(target, WSA_E_CANCELLED);
616
#endif
617
618
#ifdef WSAEREFUSED
619
  NODE_DEFINE_CONSTANT(target, WSAEREFUSED);
620
#endif
621
632
}
622
623
632
void DefineSignalConstants(Local<Object> target) {
624
#ifdef SIGHUP
625
1896
  NODE_DEFINE_CONSTANT(target, SIGHUP);
626
#endif
627
628
#ifdef SIGINT
629
1896
  NODE_DEFINE_CONSTANT(target, SIGINT);
630
#endif
631
632
#ifdef SIGQUIT
633
1896
  NODE_DEFINE_CONSTANT(target, SIGQUIT);
634
#endif
635
636
#ifdef SIGILL
637
1896
  NODE_DEFINE_CONSTANT(target, SIGILL);
638
#endif
639
640
#ifdef SIGTRAP
641
1896
  NODE_DEFINE_CONSTANT(target, SIGTRAP);
642
#endif
643
644
#ifdef SIGABRT
645
1896
  NODE_DEFINE_CONSTANT(target, SIGABRT);
646
#endif
647
648
#ifdef SIGIOT
649
1896
  NODE_DEFINE_CONSTANT(target, SIGIOT);
650
#endif
651
652
#ifdef SIGBUS
653
1896
  NODE_DEFINE_CONSTANT(target, SIGBUS);
654
#endif
655
656
#ifdef SIGFPE
657
1896
  NODE_DEFINE_CONSTANT(target, SIGFPE);
658
#endif
659
660
#ifdef SIGKILL
661
1896
  NODE_DEFINE_CONSTANT(target, SIGKILL);
662
#endif
663
664
#ifdef SIGUSR1
665
1896
  NODE_DEFINE_CONSTANT(target, SIGUSR1);
666
#endif
667
668
#ifdef SIGSEGV
669
1896
  NODE_DEFINE_CONSTANT(target, SIGSEGV);
670
#endif
671
672
#ifdef SIGUSR2
673
1896
  NODE_DEFINE_CONSTANT(target, SIGUSR2);
674
#endif
675
676
#ifdef SIGPIPE
677
1896
  NODE_DEFINE_CONSTANT(target, SIGPIPE);
678
#endif
679
680
#ifdef SIGALRM
681
1896
  NODE_DEFINE_CONSTANT(target, SIGALRM);
682
#endif
683
684
1896
  NODE_DEFINE_CONSTANT(target, SIGTERM);
685
686
#ifdef SIGCHLD
687
1896
  NODE_DEFINE_CONSTANT(target, SIGCHLD);
688
#endif
689
690
#ifdef SIGSTKFLT
691
1896
  NODE_DEFINE_CONSTANT(target, SIGSTKFLT);
692
#endif
693
694
695
#ifdef SIGCONT
696
1896
  NODE_DEFINE_CONSTANT(target, SIGCONT);
697
#endif
698
699
#ifdef SIGSTOP
700
1896
  NODE_DEFINE_CONSTANT(target, SIGSTOP);
701
#endif
702
703
#ifdef SIGTSTP
704
1896
  NODE_DEFINE_CONSTANT(target, SIGTSTP);
705
#endif
706
707
#ifdef SIGBREAK
708
  NODE_DEFINE_CONSTANT(target, SIGBREAK);
709
#endif
710
711
#ifdef SIGTTIN
712
1896
  NODE_DEFINE_CONSTANT(target, SIGTTIN);
713
#endif
714
715
#ifdef SIGTTOU
716
1896
  NODE_DEFINE_CONSTANT(target, SIGTTOU);
717
#endif
718
719
#ifdef SIGURG
720
1896
  NODE_DEFINE_CONSTANT(target, SIGURG);
721
#endif
722
723
#ifdef SIGXCPU
724
1896
  NODE_DEFINE_CONSTANT(target, SIGXCPU);
725
#endif
726
727
#ifdef SIGXFSZ
728
1896
  NODE_DEFINE_CONSTANT(target, SIGXFSZ);
729
#endif
730
731
#ifdef SIGVTALRM
732
1896
  NODE_DEFINE_CONSTANT(target, SIGVTALRM);
733
#endif
734
735
#ifdef SIGPROF
736
1896
  NODE_DEFINE_CONSTANT(target, SIGPROF);
737
#endif
738
739
#ifdef SIGWINCH
740
1896
  NODE_DEFINE_CONSTANT(target, SIGWINCH);
741
#endif
742
743
#ifdef SIGIO
744
1896
  NODE_DEFINE_CONSTANT(target, SIGIO);
745
#endif
746
747
#ifdef SIGPOLL
748
1896
  NODE_DEFINE_CONSTANT(target, SIGPOLL);
749
#endif
750
751
#ifdef SIGLOST
752
  NODE_DEFINE_CONSTANT(target, SIGLOST);
753
#endif
754
755
#ifdef SIGPWR
756
1896
  NODE_DEFINE_CONSTANT(target, SIGPWR);
757
#endif
758
759
#ifdef SIGINFO
760
  NODE_DEFINE_CONSTANT(target, SIGINFO);
761
#endif
762
763
#ifdef SIGSYS
764
1896
  NODE_DEFINE_CONSTANT(target, SIGSYS);
765
#endif
766
767
#ifdef SIGUNUSED
768
1264
  NODE_DEFINE_CONSTANT(target, SIGUNUSED);
769
#endif
770
632
}
771
772
632
void DefinePriorityConstants(Local<Object> target) {
773
#ifdef UV_PRIORITY_LOW
774
# define PRIORITY_LOW UV_PRIORITY_LOW
775
1896
  NODE_DEFINE_CONSTANT(target, PRIORITY_LOW);
776
# undef PRIORITY_LOW
777
#endif
778
779
#ifdef UV_PRIORITY_BELOW_NORMAL
780
# define PRIORITY_BELOW_NORMAL UV_PRIORITY_BELOW_NORMAL
781
1896
  NODE_DEFINE_CONSTANT(target, PRIORITY_BELOW_NORMAL);
782
# undef PRIORITY_BELOW_NORMAL
783
#endif
784
785
#ifdef UV_PRIORITY_NORMAL
786
# define PRIORITY_NORMAL UV_PRIORITY_NORMAL
787
1896
  NODE_DEFINE_CONSTANT(target, PRIORITY_NORMAL);
788
# undef PRIORITY_NORMAL
789
#endif
790
791
#ifdef UV_PRIORITY_ABOVE_NORMAL
792
# define PRIORITY_ABOVE_NORMAL UV_PRIORITY_ABOVE_NORMAL
793
1896
  NODE_DEFINE_CONSTANT(target, PRIORITY_ABOVE_NORMAL);
794
# undef PRIORITY_ABOVE_NORMAL
795
#endif
796
797
#ifdef UV_PRIORITY_HIGH
798
# define PRIORITY_HIGH UV_PRIORITY_HIGH
799
1896
  NODE_DEFINE_CONSTANT(target, PRIORITY_HIGH);
800
# undef PRIORITY_HIGH
801
#endif
802
803
#ifdef UV_PRIORITY_HIGHEST
804
# define PRIORITY_HIGHEST UV_PRIORITY_HIGHEST
805
1264
  NODE_DEFINE_CONSTANT(target, PRIORITY_HIGHEST);
806
# undef PRIORITY_HIGHEST
807
#endif
808
632
}
809
810
632
void DefineCryptoConstants(Local<Object> target) {
811
#ifdef OPENSSL_VERSION_NUMBER
812
1896
    NODE_DEFINE_CONSTANT(target, OPENSSL_VERSION_NUMBER);
813
#endif
814
815
#ifdef SSL_OP_ALL
816
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_ALL);
817
#endif
818
819
#ifdef SSL_OP_ALLOW_NO_DHE_KEX
820
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_ALLOW_NO_DHE_KEX);
821
#endif
822
823
#ifdef SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION
824
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION);
825
#endif
826
827
#ifdef SSL_OP_CIPHER_SERVER_PREFERENCE
828
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_CIPHER_SERVER_PREFERENCE);
829
#endif
830
831
#ifdef SSL_OP_CISCO_ANYCONNECT
832
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_CISCO_ANYCONNECT);
833
#endif
834
835
#ifdef SSL_OP_COOKIE_EXCHANGE
836
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_COOKIE_EXCHANGE);
837
#endif
838
839
#ifdef SSL_OP_CRYPTOPRO_TLSEXT_BUG
840
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_CRYPTOPRO_TLSEXT_BUG);
841
#endif
842
843
#ifdef SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS
844
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS);
845
#endif
846
847
#ifdef SSL_OP_EPHEMERAL_RSA
848
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_EPHEMERAL_RSA);
849
#endif
850
851
#ifdef SSL_OP_LEGACY_SERVER_CONNECT
852
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_LEGACY_SERVER_CONNECT);
853
#endif
854
855
#ifdef SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER
856
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER);
857
#endif
858
859
#ifdef SSL_OP_MICROSOFT_SESS_ID_BUG
860
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_MICROSOFT_SESS_ID_BUG);
861
#endif
862
863
#ifdef SSL_OP_MSIE_SSLV2_RSA_PADDING
864
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_MSIE_SSLV2_RSA_PADDING);
865
#endif
866
867
#ifdef SSL_OP_NETSCAPE_CA_DN_BUG
868
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_NETSCAPE_CA_DN_BUG);
869
#endif
870
871
#ifdef SSL_OP_NETSCAPE_CHALLENGE_BUG
872
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_NETSCAPE_CHALLENGE_BUG);
873
#endif
874
875
#ifdef SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG
876
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG);
877
#endif
878
879
#ifdef SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG
880
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG);
881
#endif
882
883
#ifdef SSL_OP_NO_COMPRESSION
884
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_NO_COMPRESSION);
885
#endif
886
887
#ifdef SSL_OP_NO_ENCRYPT_THEN_MAC
888
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_NO_ENCRYPT_THEN_MAC);
889
#endif
890
891
#ifdef SSL_OP_NO_QUERY_MTU
892
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_NO_QUERY_MTU);
893
#endif
894
895
#ifdef SSL_OP_NO_RENEGOTIATION
896
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_NO_RENEGOTIATION);
897
#endif
898
899
#ifdef SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION
900
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION);
901
#endif
902
903
#ifdef SSL_OP_NO_SSLv2
904
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_NO_SSLv2);
905
#endif
906
907
#ifdef SSL_OP_NO_SSLv3
908
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_NO_SSLv3);
909
#endif
910
911
#ifdef SSL_OP_NO_TICKET
912
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_NO_TICKET);
913
#endif
914
915
#ifdef SSL_OP_NO_TLSv1
916
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_NO_TLSv1);
917
#endif
918
919
#ifdef SSL_OP_NO_TLSv1_1
920
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_NO_TLSv1_1);
921
#endif
922
923
#ifdef SSL_OP_NO_TLSv1_2
924
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_NO_TLSv1_2);
925
#endif
926
927
#ifdef SSL_OP_NO_TLSv1_3
928
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_NO_TLSv1_3);
929
#endif
930
931
#ifdef SSL_OP_PKCS1_CHECK_1
932
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_PKCS1_CHECK_1);
933
#endif
934
935
#ifdef SSL_OP_PKCS1_CHECK_2
936
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_PKCS1_CHECK_2);
937
#endif
938
939
#ifdef SSL_OP_PRIORITIZE_CHACHA
940
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_PRIORITIZE_CHACHA);
941
#endif
942
943
#ifdef SSL_OP_SINGLE_DH_USE
944
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_SINGLE_DH_USE);
945
#endif
946
947
#ifdef SSL_OP_SINGLE_ECDH_USE
948
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_SINGLE_ECDH_USE);
949
#endif
950
951
#ifdef SSL_OP_SSLEAY_080_CLIENT_DH_BUG
952
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_SSLEAY_080_CLIENT_DH_BUG);
953
#endif
954
955
#ifdef SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG
956
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG);
957
#endif
958
959
#ifdef SSL_OP_TLS_BLOCK_PADDING_BUG
960
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_TLS_BLOCK_PADDING_BUG);
961
#endif
962
963
#ifdef SSL_OP_TLS_D5_BUG
964
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_TLS_D5_BUG);
965
#endif
966
967
#ifdef SSL_OP_TLS_ROLLBACK_BUG
968
1896
    NODE_DEFINE_CONSTANT(target, SSL_OP_TLS_ROLLBACK_BUG);
969
#endif
970
971
# ifndef OPENSSL_NO_ENGINE
972
973
# ifdef ENGINE_METHOD_RSA
974
1896
    NODE_DEFINE_CONSTANT(target, ENGINE_METHOD_RSA);
975
# endif
976
977
# ifdef ENGINE_METHOD_DSA
978
1896
    NODE_DEFINE_CONSTANT(target, ENGINE_METHOD_DSA);
979
# endif
980
981
# ifdef ENGINE_METHOD_DH
982
1896
    NODE_DEFINE_CONSTANT(target, ENGINE_METHOD_DH);
983
# endif
984
985
# ifdef ENGINE_METHOD_RAND
986
1896
    NODE_DEFINE_CONSTANT(target, ENGINE_METHOD_RAND);
987
# endif
988
989
# ifdef ENGINE_METHOD_EC
990
1896
    NODE_DEFINE_CONSTANT(target, ENGINE_METHOD_EC);
991
# endif
992
993
# ifdef ENGINE_METHOD_CIPHERS
994
1896
    NODE_DEFINE_CONSTANT(target, ENGINE_METHOD_CIPHERS);
995
# endif
996
997
# ifdef ENGINE_METHOD_DIGESTS
998
1896
    NODE_DEFINE_CONSTANT(target, ENGINE_METHOD_DIGESTS);
999
# endif
1000
1001
# ifdef ENGINE_METHOD_PKEY_METHS
1002
1896
    NODE_DEFINE_CONSTANT(target, ENGINE_METHOD_PKEY_METHS);
1003
# endif
1004
1005
# ifdef ENGINE_METHOD_PKEY_ASN1_METHS
1006
1896
    NODE_DEFINE_CONSTANT(target, ENGINE_METHOD_PKEY_ASN1_METHS);
1007
# endif
1008
1009
# ifdef ENGINE_METHOD_ALL
1010
1896
    NODE_DEFINE_CONSTANT(target, ENGINE_METHOD_ALL);
1011
# endif
1012
1013
# ifdef ENGINE_METHOD_NONE
1014
1896
    NODE_DEFINE_CONSTANT(target, ENGINE_METHOD_NONE);
1015
# endif
1016
1017
# endif  // !OPENSSL_NO_ENGINE
1018
1019
#ifdef DH_CHECK_P_NOT_SAFE_PRIME
1020
1896
    NODE_DEFINE_CONSTANT(target, DH_CHECK_P_NOT_SAFE_PRIME);
1021
#endif
1022
1023
#ifdef DH_CHECK_P_NOT_PRIME
1024
1896
    NODE_DEFINE_CONSTANT(target, DH_CHECK_P_NOT_PRIME);
1025
#endif
1026
1027
#ifdef DH_UNABLE_TO_CHECK_GENERATOR
1028
1896
    NODE_DEFINE_CONSTANT(target, DH_UNABLE_TO_CHECK_GENERATOR);
1029
#endif
1030
1031
#ifdef DH_NOT_SUITABLE_GENERATOR
1032
1896
    NODE_DEFINE_CONSTANT(target, DH_NOT_SUITABLE_GENERATOR);
1033
#endif
1034
1035
#ifdef TLSEXT_TYPE_application_layer_protocol_negotiation
1036
#define ALPN_ENABLED 1
1037
1896
    NODE_DEFINE_CONSTANT(target, ALPN_ENABLED);
1038
#endif
1039
1040
#ifdef RSA_PKCS1_PADDING
1041
1896
    NODE_DEFINE_CONSTANT(target, RSA_PKCS1_PADDING);
1042
#endif
1043
1044
#ifdef RSA_SSLV23_PADDING
1045
    NODE_DEFINE_CONSTANT(target, RSA_SSLV23_PADDING);
1046
#endif
1047
1048
#ifdef RSA_NO_PADDING
1049
1896
    NODE_DEFINE_CONSTANT(target, RSA_NO_PADDING);
1050
#endif
1051
1052
#ifdef RSA_PKCS1_OAEP_PADDING
1053
1896
    NODE_DEFINE_CONSTANT(target, RSA_PKCS1_OAEP_PADDING);
1054
#endif
1055
1056
#ifdef RSA_X931_PADDING
1057
1896
    NODE_DEFINE_CONSTANT(target, RSA_X931_PADDING);
1058
#endif
1059
1060
#ifdef RSA_PKCS1_PSS_PADDING
1061
1896
    NODE_DEFINE_CONSTANT(target, RSA_PKCS1_PSS_PADDING);
1062
#endif
1063
1064
#ifdef RSA_PSS_SALTLEN_DIGEST
1065
1896
    NODE_DEFINE_CONSTANT(target, RSA_PSS_SALTLEN_DIGEST);
1066
#endif
1067
1068
#ifdef RSA_PSS_SALTLEN_MAX_SIGN
1069
1896
    NODE_DEFINE_CONSTANT(target, RSA_PSS_SALTLEN_MAX_SIGN);
1070
#endif
1071
1072
#ifdef RSA_PSS_SALTLEN_AUTO
1073
1896
    NODE_DEFINE_CONSTANT(target, RSA_PSS_SALTLEN_AUTO);
1074
#endif
1075
1076
#ifdef DEFAULT_CIPHER_LIST_CORE
1077
2528
  NODE_DEFINE_STRING_CONSTANT(target,
1078
                              "defaultCoreCipherList",
1079
                              DEFAULT_CIPHER_LIST_CORE);
1080
#endif
1081
1082
#ifdef TLS1_VERSION
1083
1896
  NODE_DEFINE_CONSTANT(target, TLS1_VERSION);
1084
#endif
1085
1086
#ifdef TLS1_1_VERSION
1087
1896
  NODE_DEFINE_CONSTANT(target, TLS1_1_VERSION);
1088
#endif
1089
1090
#ifdef TLS1_2_VERSION
1091
1896
  NODE_DEFINE_CONSTANT(target, TLS1_2_VERSION);
1092
#endif
1093
1094
#ifdef TLS1_3_VERSION
1095
1896
  NODE_DEFINE_CONSTANT(target, TLS1_3_VERSION);
1096
#endif
1097
1098
#if HAVE_OPENSSL
1099
  // NOTE: These are not defines
1100
1896
  NODE_DEFINE_CONSTANT(target, POINT_CONVERSION_COMPRESSED);
1101
1102
1896
  NODE_DEFINE_CONSTANT(target, POINT_CONVERSION_UNCOMPRESSED);
1103
1104
1264
  NODE_DEFINE_CONSTANT(target, POINT_CONVERSION_HYBRID);
1105
#endif
1106
632
}
1107
1108
632
void DefineSystemConstants(Local<Object> target) {
1109
1896
  NODE_DEFINE_CONSTANT(target, UV_FS_SYMLINK_DIR);
1110
1896
  NODE_DEFINE_CONSTANT(target, UV_FS_SYMLINK_JUNCTION);
1111
  // file access modes
1112
1896
  NODE_DEFINE_CONSTANT(target, O_RDONLY);
1113
1896
  NODE_DEFINE_CONSTANT(target, O_WRONLY);
1114
1896
  NODE_DEFINE_CONSTANT(target, O_RDWR);
1115
1116
  // file types from readdir
1117
1896
  NODE_DEFINE_CONSTANT(target, UV_DIRENT_UNKNOWN);
1118
1896
  NODE_DEFINE_CONSTANT(target, UV_DIRENT_FILE);
1119
1896
  NODE_DEFINE_CONSTANT(target, UV_DIRENT_DIR);
1120
1896
  NODE_DEFINE_CONSTANT(target, UV_DIRENT_LINK);
1121
1896
  NODE_DEFINE_CONSTANT(target, UV_DIRENT_FIFO);
1122
1896
  NODE_DEFINE_CONSTANT(target, UV_DIRENT_SOCKET);
1123
1896
  NODE_DEFINE_CONSTANT(target, UV_DIRENT_CHAR);
1124
1896
  NODE_DEFINE_CONSTANT(target, UV_DIRENT_BLOCK);
1125
1126
1896
  NODE_DEFINE_CONSTANT(target, S_IFMT);
1127
1896
  NODE_DEFINE_CONSTANT(target, S_IFREG);
1128
1896
  NODE_DEFINE_CONSTANT(target, S_IFDIR);
1129
1896
  NODE_DEFINE_CONSTANT(target, S_IFCHR);
1130
#ifdef S_IFBLK
1131
1896
  NODE_DEFINE_CONSTANT(target, S_IFBLK);
1132
#endif
1133
1134
#ifdef S_IFIFO
1135
1896
  NODE_DEFINE_CONSTANT(target, S_IFIFO);
1136
#endif
1137
1138
#ifdef S_IFLNK
1139
1896
  NODE_DEFINE_CONSTANT(target, S_IFLNK);
1140
#endif
1141
1142
#ifdef S_IFSOCK
1143
1896
  NODE_DEFINE_CONSTANT(target, S_IFSOCK);
1144
#endif
1145
1146
#ifdef O_CREAT
1147
1896
  NODE_DEFINE_CONSTANT(target, O_CREAT);
1148
#endif
1149
1150
#ifdef O_EXCL
1151
1896
  NODE_DEFINE_CONSTANT(target, O_EXCL);
1152
#endif
1153
1154
1896
NODE_DEFINE_CONSTANT(target, UV_FS_O_FILEMAP);
1155
1156
#ifdef O_NOCTTY
1157
1896
  NODE_DEFINE_CONSTANT(target, O_NOCTTY);
1158
#endif
1159
1160
#ifdef O_TRUNC
1161
1896
  NODE_DEFINE_CONSTANT(target, O_TRUNC);
1162
#endif
1163
1164
#ifdef O_APPEND
1165
1896
  NODE_DEFINE_CONSTANT(target, O_APPEND);
1166
#endif
1167
1168
#ifdef O_DIRECTORY
1169
1896
  NODE_DEFINE_CONSTANT(target, O_DIRECTORY);
1170
#endif
1171
1172
#ifdef O_EXCL
1173
1896
  NODE_DEFINE_CONSTANT(target, O_EXCL);
1174
#endif
1175
1176
#ifdef O_NOATIME
1177
1896
  NODE_DEFINE_CONSTANT(target, O_NOATIME);
1178
#endif
1179
1180
#ifdef O_NOFOLLOW
1181
1896
  NODE_DEFINE_CONSTANT(target, O_NOFOLLOW);
1182
#endif
1183
1184
#ifdef O_SYNC
1185
1896
  NODE_DEFINE_CONSTANT(target, O_SYNC);
1186
#endif
1187
1188
#ifdef O_DSYNC
1189
1896
  NODE_DEFINE_CONSTANT(target, O_DSYNC);
1190
#endif
1191
1192
1193
#ifdef O_SYMLINK
1194
  NODE_DEFINE_CONSTANT(target, O_SYMLINK);
1195
#endif
1196
1197
#ifdef O_DIRECT
1198
1896
  NODE_DEFINE_CONSTANT(target, O_DIRECT);
1199
#endif
1200
1201
#ifdef O_NONBLOCK
1202
1896
  NODE_DEFINE_CONSTANT(target, O_NONBLOCK);
1203
#endif
1204
1205
#ifdef S_IRWXU
1206
1896
  NODE_DEFINE_CONSTANT(target, S_IRWXU);
1207
#endif
1208
1209
#ifdef S_IRUSR
1210
1896
  NODE_DEFINE_CONSTANT(target, S_IRUSR);
1211
#endif
1212
1213
#ifdef S_IWUSR
1214
1896
  NODE_DEFINE_CONSTANT(target, S_IWUSR);
1215
#endif
1216
1217
#ifdef S_IXUSR
1218
1896
  NODE_DEFINE_CONSTANT(target, S_IXUSR);
1219
#endif
1220
1221
#ifdef S_IRWXG
1222
1896
  NODE_DEFINE_CONSTANT(target, S_IRWXG);
1223
#endif
1224
1225
#ifdef S_IRGRP
1226
1896
  NODE_DEFINE_CONSTANT(target, S_IRGRP);
1227
#endif
1228
1229
#ifdef S_IWGRP
1230
1896
  NODE_DEFINE_CONSTANT(target, S_IWGRP);
1231
#endif
1232
1233
#ifdef S_IXGRP
1234
1896
  NODE_DEFINE_CONSTANT(target, S_IXGRP);
1235
#endif
1236
1237
#ifdef S_IRWXO
1238
1896
  NODE_DEFINE_CONSTANT(target, S_IRWXO);
1239
#endif
1240
1241
#ifdef S_IROTH
1242
1896
  NODE_DEFINE_CONSTANT(target, S_IROTH);
1243
#endif
1244
1245
#ifdef S_IWOTH
1246
1896
  NODE_DEFINE_CONSTANT(target, S_IWOTH);
1247
#endif
1248
1249
#ifdef S_IXOTH
1250
1896
  NODE_DEFINE_CONSTANT(target, S_IXOTH);
1251
#endif
1252
1253
#ifdef F_OK
1254
1896
  NODE_DEFINE_CONSTANT(target, F_OK);
1255
#endif
1256
1257
#ifdef R_OK
1258
1896
  NODE_DEFINE_CONSTANT(target, R_OK);
1259
#endif
1260
1261
#ifdef W_OK
1262
1896
  NODE_DEFINE_CONSTANT(target, W_OK);
1263
#endif
1264
1265
#ifdef X_OK
1266
1896
  NODE_DEFINE_CONSTANT(target, X_OK);
1267
#endif
1268
1269
#ifdef UV_FS_COPYFILE_EXCL
1270
# define COPYFILE_EXCL UV_FS_COPYFILE_EXCL
1271
1896
  NODE_DEFINE_CONSTANT(target, UV_FS_COPYFILE_EXCL);
1272
1896
  NODE_DEFINE_CONSTANT(target, COPYFILE_EXCL);
1273
# undef COPYFILE_EXCL
1274
#endif
1275
1276
#ifdef UV_FS_COPYFILE_FICLONE
1277
# define COPYFILE_FICLONE UV_FS_COPYFILE_FICLONE
1278
1896
  NODE_DEFINE_CONSTANT(target, UV_FS_COPYFILE_FICLONE);
1279
1896
  NODE_DEFINE_CONSTANT(target, COPYFILE_FICLONE);
1280
# undef COPYFILE_FICLONE
1281
#endif
1282
1283
#ifdef UV_FS_COPYFILE_FICLONE_FORCE
1284
# define COPYFILE_FICLONE_FORCE UV_FS_COPYFILE_FICLONE_FORCE
1285
1896
  NODE_DEFINE_CONSTANT(target, UV_FS_COPYFILE_FICLONE_FORCE);
1286
1264
  NODE_DEFINE_CONSTANT(target, COPYFILE_FICLONE_FORCE);
1287
# undef COPYFILE_FICLONE_FORCE
1288
#endif
1289
632
}
1290
1291
632
void DefineDLOpenConstants(Local<Object> target) {
1292
#ifdef RTLD_LAZY
1293
1896
  NODE_DEFINE_CONSTANT(target, RTLD_LAZY);
1294
#endif
1295
1296
#ifdef RTLD_NOW
1297
1896
  NODE_DEFINE_CONSTANT(target, RTLD_NOW);
1298
#endif
1299
1300
#ifdef RTLD_GLOBAL
1301
1896
  NODE_DEFINE_CONSTANT(target, RTLD_GLOBAL);
1302
#endif
1303
1304
#ifdef RTLD_LOCAL
1305
1896
  NODE_DEFINE_CONSTANT(target, RTLD_LOCAL);
1306
#endif
1307
1308
#ifdef RTLD_DEEPBIND
1309
1264
  NODE_DEFINE_CONSTANT(target, RTLD_DEEPBIND);
1310
#endif
1311
632
}
1312
1313
632
void DefineTraceConstants(Local<Object> target) {
1314
1896
  NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_BEGIN);
1315
1896
  NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_END);
1316
1896
  NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_COMPLETE);
1317
1896
  NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_INSTANT);
1318
1896
  NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_ASYNC_BEGIN);
1319
1896
  NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_ASYNC_STEP_INTO);
1320
1896
  NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_ASYNC_STEP_PAST);
1321
1896
  NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_ASYNC_END);
1322
1896
  NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN);
1323
1896
  NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_NESTABLE_ASYNC_END);
1324
1896
  NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_NESTABLE_ASYNC_INSTANT);
1325
1896
  NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_FLOW_BEGIN);
1326
1896
  NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_FLOW_STEP);
1327
1896
  NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_FLOW_END);
1328
1896
  NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_METADATA);
1329
1896
  NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_COUNTER);
1330
1896
  NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_SAMPLE);
1331
1896
  NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_CREATE_OBJECT);
1332
1896
  NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_SNAPSHOT_OBJECT);
1333
1896
  NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_DELETE_OBJECT);
1334
1896
  NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_MEMORY_DUMP);
1335
1896
  NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_MARK);
1336
1896
  NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_CLOCK_SYNC);
1337
1896
  NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_ENTER_CONTEXT);
1338
1896
  NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_LEAVE_CONTEXT);
1339
1264
  NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_LINK_IDS);
1340
632
}
1341
1342
}  // anonymous namespace
1343
1344
632
void DefineConstants(v8::Isolate* isolate, Local<Object> target) {
1345
632
  Environment* env = Environment::GetCurrent(isolate);
1346
1347
632
  Local<Object> os_constants = Object::New(isolate);
1348
1896
  CHECK(os_constants->SetPrototype(env->context(),
1349
                                   Null(env->isolate())).FromJust());
1350
1351
632
  Local<Object> err_constants = Object::New(isolate);
1352
1896
  CHECK(err_constants->SetPrototype(env->context(),
1353
                                    Null(env->isolate())).FromJust());
1354
1355
632
  Local<Object> sig_constants = Object::New(isolate);
1356
1896
  CHECK(sig_constants->SetPrototype(env->context(),
1357
                                    Null(env->isolate())).FromJust());
1358
1359
632
  Local<Object> priority_constants = Object::New(isolate);
1360
1896
  CHECK(priority_constants->SetPrototype(env->context(),
1361
                                         Null(env->isolate())).FromJust());
1362
1363
632
  Local<Object> fs_constants = Object::New(isolate);
1364
1896
  CHECK(fs_constants->SetPrototype(env->context(),
1365
                                   Null(env->isolate())).FromJust());
1366
1367
632
  Local<Object> crypto_constants = Object::New(isolate);
1368
1896
  CHECK(crypto_constants->SetPrototype(env->context(),
1369
                                       Null(env->isolate())).FromJust());
1370
1371
632
  Local<Object> zlib_constants = Object::New(isolate);
1372
1896
  CHECK(zlib_constants->SetPrototype(env->context(),
1373
                                     Null(env->isolate())).FromJust());
1374
1375
632
  Local<Object> dlopen_constants = Object::New(isolate);
1376
1896
  CHECK(dlopen_constants->SetPrototype(env->context(),
1377
                                       Null(env->isolate())).FromJust());
1378
1379
632
  Local<Object> trace_constants = Object::New(isolate);
1380
1896
  CHECK(trace_constants->SetPrototype(env->context(),
1381
                                      Null(env->isolate())).FromJust());
1382
1383
632
  DefineErrnoConstants(err_constants);
1384
632
  DefineWindowsErrorConstants(err_constants);
1385
632
  DefineSignalConstants(sig_constants);
1386
632
  DefinePriorityConstants(priority_constants);
1387
632
  DefineSystemConstants(fs_constants);
1388
632
  DefineCryptoConstants(crypto_constants);
1389
632
  DefineZlibConstants(zlib_constants);
1390
632
  DefineDLOpenConstants(dlopen_constants);
1391
632
  DefineTraceConstants(trace_constants);
1392
1393
  // Define libuv constants.
1394
1896
  NODE_DEFINE_CONSTANT(os_constants, UV_UDP_REUSEADDR);
1395
1396
632
  os_constants->Set(env->context(),
1397
                    OneByteString(isolate, "dlopen"),
1398
1896
                    dlopen_constants).Check();
1399
632
  os_constants->Set(env->context(),
1400
                    OneByteString(isolate, "errno"),
1401
1896
                    err_constants).Check();
1402
632
  os_constants->Set(env->context(),
1403
                    OneByteString(isolate, "signals"),
1404
1896
                    sig_constants).Check();
1405
632
  os_constants->Set(env->context(),
1406
                    OneByteString(isolate, "priority"),
1407
1896
                    priority_constants).Check();
1408
632
  target->Set(env->context(),
1409
              OneByteString(isolate, "os"),
1410
1896
              os_constants).Check();
1411
632
  target->Set(env->context(),
1412
              OneByteString(isolate, "fs"),
1413
1896
              fs_constants).Check();
1414
632
  target->Set(env->context(),
1415
              OneByteString(isolate, "crypto"),
1416
1896
              crypto_constants).Check();
1417
632
  target->Set(env->context(),
1418
              OneByteString(isolate, "zlib"),
1419
1896
              zlib_constants).Check();
1420
632
  target->Set(env->context(),
1421
              OneByteString(isolate, "trace"),
1422
1264
              trace_constants).Check();
1423
632
}
1424
1425
}  // namespace node