1 /*
2 ------------------------------------------------------------------------------
3 -- --
4 -- GNAT COMPILER COMPONENTS --
5 -- --
6 -- S Y S T E M . O S _ C O N S T A N T S --
7 -- --
8 -- S p e c --
9 -- --
10 -- Copyright (C) 2000-2019, Free Software Foundation, Inc. --
11 -- --
12 -- GNAT is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 3, or (at your option) any later ver- --
15 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE. --
18 -- --
19 -- As a special exception under Section 7 of GPL version 3, you are granted --
20 -- additional permissions described in the GCC Runtime Library Exception, --
21 -- version 3.1, as published by the Free Software Foundation. --
22 -- --
23 -- You should have received a copy of the GNU General Public License and --
24 -- a copy of the GCC Runtime Library Exception along with this program; --
25 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
26 -- <http://www.gnu.org/licenses/>. --
27 -- --
28 -- GNAT was originally developed by the GNAT team at New York University. --
29 -- Extensive contributions were provided by Ada Core Technologies Inc. --
30 -- --
31 ------------------------------------------------------------------------------
32
33 pragma Style_Checks ("M32766");
34 -- Allow long lines
35
36 */
37
38 /**
39 ** This template file is used while building the GNAT runtime library to
40 ** generate package System.OS_Constants (s-oscons.ads).
41 **
42 ** The generation process is:
43 ** 1. the platform-independent extraction tool xoscons is built with the
44 ** base native compiler
45 ** 2. this template is processed by the cross C compiler to produce
46 ** a list of constant values
47 ** 3. the comments in this template and the list of values are processed
48 ** by xoscons to generate s-oscons.ads.
49 **
50 ** Any comment occurring in this file whose start and end markers are on
51 ** a line by themselves (see above) is copied verbatim to s-oscons.ads.
52 ** All other comments are ignored. Note that the build process first passes
53 ** this file through the C preprocessor, so comments that occur in a section
54 ** that is conditioned by a #if directive will be copied to the output only
55 ** when it applies.
56 **
57 ** Two methods are supported to generate the list of constant values,
58 ** s-oscons-tmpl.s.
59 **
60 ** The default one assumes that the template can be compiled by the newly-
61 ** built cross compiler. It uses markup produced in the (pseudo-)assembly
62 ** listing:
63 **
64 ** xgcc -DTARGET=\"$target\" -C -E s-oscons-tmplt.c > s-oscons-tmplt.i
65 ** xgcc -S s-oscons-tmplt.i
66 ** xoscons
67 **
68 ** Alternatively, if s-oscons-tmplt.c must be compiled with a proprietary
69 ** compiler (e.g. the native DEC CC on OpenVMS), the NATIVE macro should
70 ** be defined, and the resulting program executed:
71 **
72 ** $ CC/DEFINE=("TARGET=""OpenVMS""",NATIVE)
73 ** /PREPROCESS_ONLY /COMMENTS=AS_IS s-oscons-tmplt
74 ** $ CC/DEFINE=("TARGET=""OpenVMS""",NATIVE) s-oscons-tmplt
75 ** $ LINK s-oscons-tmplt
76 ** $ DEFINE/USER SYS$OUTPUT s-oscons-tmplt.s
77 ** $ RUN s-oscons-tmplt
78 ** $ RUN xoscons
79 **/
80
81 /* Feature macro definitions */
82
83 /**
84 ** Note: we deliberately do not define _POSIX_SOURCE / _POSIX_C_SOURCE
85 ** unconditionally, as on many platforms these macros actually disable
86 ** a number of non-POSIX but useful/required features.
87 **/
88
89 #if defined (__linux__) || defined (__ANDROID__)
90
91 /* Define _XOPEN_SOURCE to get IOV_MAX */
92 # if !defined (_XOPEN_SOURCE)
93 # define _XOPEN_SOURCE 500
94 # endif
95
96 /* Define _BSD_SOURCE to get CRTSCTS */
97 # define _BSD_SOURCE
98
99 #endif /* defined (__linux__) */
100
101 /* Include gsocket.h before any system header so it can redefine FD_SETSIZE */
102
103 #include "gsocket.h"
104
105 #include <stdlib.h>
106 #include <string.h>
107 #include <limits.h>
108 #include <fcntl.h>
109 #include <time.h>
110
111 #if ! (defined (__vxworks) || defined (__MINGW32__))
112 # define HAVE_TERMIOS
113 #endif
114
115 #if defined (__vxworks)
116
117 /**
118 ** For VxWorks, always include vxWorks.h (gsocket.h provides it only for
119 ** the case of runtime libraries that support sockets). Note: this must
120 ** be done before including adaint.h.
121 **/
122
123 # include <vxWorks.h>
124 #endif
125
126 #include "adaint.h"
127
128 #ifdef DUMMY
129
130 # if defined (TARGET)
131 # error TARGET may not be defined when generating the dummy version
132 # else
133 # define TARGET "batch runtime compilation (dummy values)"
134 # endif
135
136 # if !(defined (HAVE_SOCKETS) && defined (HAVE_TERMIOS))
137 # error Features missing on platform
138 # endif
139
140 # define NATIVE
141
142 #endif /* DUMMY */
143
144 #ifndef TARGET
145 # error Please define TARGET
146 #endif
147
148 #ifndef HAVE_SOCKETS
149 # include <errno.h>
150 #endif
151
152 #ifdef HAVE_TERMIOS
153 # include <termios.h>
154 #endif
155
156 #ifdef __APPLE__
157 # include <_types.h>
158 #endif
159
160 #if defined (__linux__) || defined (__ANDROID__) || defined (__QNX__) \
161 || defined (__rtems__)
162 # include <pthread.h>
163 # include <signal.h>
164 #endif
165
166 #if defined(__MINGW32__) || defined(__CYGWIN__)
167 # include <windef.h>
168 # include <winbase.h>
169 #endif
170
171 #ifdef NATIVE
172 #include <stdio.h>
173
174 #ifdef DUMMY
175 int counter = 0;
176 # define _VAL(x) counter++
177 #else
178 # define _VAL(x) x
179 #endif
180
181 #define CND(name,comment) \
182 printf ("\n->CND:$%d:" #name ":$%d:" comment, __LINE__, ((int) _VAL (name)));
183
184 #define CNU(name,comment) \
185 printf ("\n->CNU:$%d:" #name ":$%u:" comment, __LINE__, ((unsigned int) _VAL (name)));
186
187 #define CNS(name,comment) \
188 printf ("\n->CNS:$%d:" #name ":" name ":" comment, __LINE__);
189
190 #define C(sname,type,value,comment)\
191 printf ("\n->C:$%d:" sname ":" #type ":" value ":" comment, __LINE__);
192
193 #define SUB(sname)\
194 printf ("\n->SUB:$%d:" #sname ":" sname, __LINE__);
195
196 #define TXT(text) \
197 printf ("\n->TXT:$%d:" text, __LINE__);
198
199 #else
200
201 #define CND(name, comment) \
202 asm volatile("\n->CND:%0:" #name ":%1:" comment \
203 : : "i" (__LINE__), "i" ((int) name));
204 /* Decimal constant in the range of type "int" */
205
206 #define CNU(name, comment) \
207 asm volatile("\n->CNU:%0:" #name ":%1:" comment \
208 : : "i" (__LINE__), "i" ((int) name));
209 /* Decimal constant in the range of type "unsigned int" (note, assembler
210 * always wants a signed int, we convert back in xoscons).
211 */
212
213 #define CNS(name, comment) \
214 asm volatile("\n->CNS:%0:" #name ":" name ":" comment \
215 : : "i" (__LINE__));
216 /* General expression named number */
217
218 #define C(sname, type, value, comment) \
219 asm volatile("\n->C:%0:" sname ":" #type ":" value ":" comment \
220 : : "i" (__LINE__));
221 /* Typed constant */
222
223 #define SUB(sname) \
224 asm volatile("\n->SUB:%0:" #sname ":" sname \
225 : : "i" (__LINE__));
226 /* Subtype */
227
228 #define TXT(text) \
229 asm volatile("\n->TXT:%0:" text \
230 : : "i" (__LINE__));
231 /* Freeform text */
232
233 #endif /* NATIVE */
234
235 #define CST(name,comment) C(#name,String,name,comment)
236 /* String constant */
237
238 #define STR(x) STR1(x)
239 #define STR1(x) #x
240
241 #ifdef __MINGW32__
242 unsigned int _CRT_fmode = _O_BINARY;
243 #endif
244
245 int
main(void)246 main (void) {
247
248 /*
249 -- This package provides target dependent definitions of constant for use
250 -- by the GNAT runtime library. This package should not be directly with'd
251 -- by an application program.
252
253 -- This file is generated automatically, do not modify it by hand! Instead,
254 -- make changes to s-oscons-tmplt.c and rebuild the GNAT runtime library.
255 */
256
257 /**
258 ** Do not change the format of the line below without also updating the
259 ** MaRTE Makefile.
260 **/
261 TXT("-- This is the version for " TARGET)
262 TXT("")
263 TXT("with Interfaces.C;")
264
265 /*
266 package System.OS_Constants is
267
268 pragma Pure;
269 */
270
271 /**
272 ** General constants (all platforms)
273 **/
274
275 /*
276
277 ---------------------------------
278 -- General platform parameters --
279 ---------------------------------
280
281 type OS_Type is (Windows, Other_OS);
282 */
283 #if defined (__MINGW32__)
284 # define TARGET_OS "Windows"
285 #else
286 # define TARGET_OS "Other_OS"
287 #endif
288 C("Target_OS", OS_Type, TARGET_OS, "")
289 /*
290 pragma Warnings (Off, Target_OS);
291 -- Suppress warnings on Target_OS since it is in general tested for
292 -- equality with a constant value to implement conditional compilation,
293 -- which normally generates a constant condition warning.
294
295 */
296 #define Target_Name TARGET
297 CST(Target_Name, "")
298
299 /**
300 ** Note: the name of the following constant is recognized specially by
301 ** xoscons (case sensitive).
302 **/
303 #define SIZEOF_unsigned_int sizeof (unsigned int)
304 CND(SIZEOF_unsigned_int, "Size of unsigned int")
305
306 /*
307
308 -------------------
309 -- System limits --
310 -------------------
311
312 */
313
314 #ifndef IOV_MAX
315 # define IOV_MAX INT_MAX
316 #endif
317 CND(IOV_MAX, "Maximum writev iovcnt")
318
319 /* NAME_MAX is used to compute the allocation size for a struct dirent
320 * passed to readdir() / readdir_r(). However on some systems it is not
321 * defined, as it is technically a filesystem dependent property that
322 * we should retrieve through pathconf(). In any case, we do not need a
323 * precise value but only an upper limit.
324 */
325 #ifndef NAME_MAX
326 # ifdef MAXNAMELEN
327 /* Solaris has no NAME_MAX but defines MAXNAMELEN */
328 # define NAME_MAX MAXNAMELEN
329 # elif defined(PATH_MAX)
330 /* PATH_MAX (maximum length of a full path name) is a safe fall back */
331 # define NAME_MAX PATH_MAX
332 # elif defined(FILENAME_MAX)
333 /* Similarly FILENAME_MAX can provide a safe fall back */
334 # define NAME_MAX FILENAME_MAX
335 # else
336 /* Hardcode a reasonably large value as a last chance fallback */
337 # define NAME_MAX 1024
338 # endif
339 #endif
340 CND(NAME_MAX, "Maximum file name length")
341
342 /*
343
344 ---------------------
345 -- File open modes --
346 ---------------------
347
348 */
349
350 #ifndef O_RDWR
351 # define O_RDWR -1
352 #endif
353 CND(O_RDWR, "Read/write")
354
355 #ifndef O_NOCTTY
356 # define O_NOCTTY -1
357 #endif
358 CND(O_NOCTTY, "Don't change ctrl tty")
359
360 #ifndef O_NDELAY
361 # define O_NDELAY -1
362 #endif
363 CND(O_NDELAY, "Nonblocking")
364
365 /*
366
367 ----------------------
368 -- Fcntl operations --
369 ----------------------
370
371 */
372
373 #ifndef F_GETFL
374 # define F_GETFL -1
375 #endif
376 CND(F_GETFL, "Get flags")
377
378 #ifndef F_SETFL
379 # define F_SETFL -1
380 #endif
381 CND(F_SETFL, "Set flags")
382
383 /*
384
385 -----------------
386 -- Fcntl flags --
387 -----------------
388
389 */
390
391 #ifndef FNDELAY
392 # define FNDELAY -1
393 #endif
394 CND(FNDELAY, "Nonblocking")
395
396 /*
397
398 ----------------------
399 -- Ioctl operations --
400 ----------------------
401
402 */
403
404 /* ioctl(2) requests are "int" in UNIX, but "unsigned long" on FreeBSD */
405
406 #if defined (__FreeBSD__) || defined (__DragonFly__)
407 # define CNI CNU
408 # define IOCTL_Req_T "unsigned"
409 #else
410 # define CNI CND
411 # define IOCTL_Req_T "int"
412 #endif
413
414 SUB(IOCTL_Req_T)
415
416 #ifndef FIONBIO
417 # define FIONBIO -1
418 #endif
419 CNI(FIONBIO, "Set/clear non-blocking io")
420
421 #ifndef FIONREAD
422 # define FIONREAD -1
423 #endif
424 CNI(FIONREAD, "How many bytes to read")
425
426 /*
427
428 ------------------
429 -- Errno values --
430 ------------------
431
432 -- The following constants are defined from <errno.h>
433
434 */
435 #ifndef EAGAIN
436 # define EAGAIN -1
437 #endif
438 CND(EAGAIN, "Try again")
439
440 #ifndef ENOENT
441 # define ENOENT -1
442 #endif
443 CND(ENOENT, "File not found")
444
445 #ifndef ENOMEM
446 # define ENOMEM -1
447 #endif
448 CND(ENOMEM, "Out of memory")
449
450 #ifdef __MINGW32__
451 /*
452
453 -- The following constants are defined from <winsock2.h> (WSA*)
454
455 */
456
457 /**
458 ** For sockets-related errno values on Windows, gsocket.h redefines
459 ** Exxx as WSAExxx.
460 **/
461
462 #endif
463
464 #ifndef EACCES
465 # define EACCES -1
466 #endif
467 CND(EACCES, "Permission denied")
468
469 #ifndef EADDRINUSE
470 # define EADDRINUSE -1
471 #endif
472 CND(EADDRINUSE, "Address already in use")
473
474 #ifndef EADDRNOTAVAIL
475 # define EADDRNOTAVAIL -1
476 #endif
477 CND(EADDRNOTAVAIL, "Cannot assign address")
478
479 #ifndef EAFNOSUPPORT
480 # define EAFNOSUPPORT -1
481 #endif
482 CND(EAFNOSUPPORT, "Addr family not supported")
483
484 #ifndef EALREADY
485 # define EALREADY -1
486 #endif
487 CND(EALREADY, "Operation in progress")
488
489 #ifndef EBADF
490 # define EBADF -1
491 #endif
492 CND(EBADF, "Bad file descriptor")
493
494 #ifndef ECONNABORTED
495 # define ECONNABORTED -1
496 #endif
497 CND(ECONNABORTED, "Connection aborted")
498
499 #ifndef ECONNREFUSED
500 # define ECONNREFUSED -1
501 #endif
502 CND(ECONNREFUSED, "Connection refused")
503
504 #ifndef ECONNRESET
505 # define ECONNRESET -1
506 #endif
507 CND(ECONNRESET, "Connection reset by peer")
508
509 #ifndef EDESTADDRREQ
510 # define EDESTADDRREQ -1
511 #endif
512 CND(EDESTADDRREQ, "Destination addr required")
513
514 #ifndef EFAULT
515 # define EFAULT -1
516 #endif
517 CND(EFAULT, "Bad address")
518
519 #ifndef EHOSTDOWN
520 # define EHOSTDOWN -1
521 #endif
522 CND(EHOSTDOWN, "Host is down")
523
524 #ifndef EHOSTUNREACH
525 # define EHOSTUNREACH -1
526 #endif
527 CND(EHOSTUNREACH, "No route to host")
528
529 #ifndef EINPROGRESS
530 # define EINPROGRESS -1
531 #endif
532 CND(EINPROGRESS, "Operation now in progress")
533
534 #ifndef EINTR
535 # define EINTR -1
536 #endif
537 CND(EINTR, "Interrupted system call")
538
539 #ifndef EINVAL
540 # define EINVAL -1
541 #endif
542 CND(EINVAL, "Invalid argument")
543
544 #ifndef EIO
545 # define EIO -1
546 #endif
547 CND(EIO, "Input output error")
548
549 #ifndef EISCONN
550 # define EISCONN -1
551 #endif
552 CND(EISCONN, "Socket already connected")
553
554 #ifndef ELOOP
555 # define ELOOP -1
556 #endif
557 CND(ELOOP, "Too many symbolic links")
558
559 #ifndef EMFILE
560 # define EMFILE -1
561 #endif
562 CND(EMFILE, "Too many open files")
563
564 #ifndef EMSGSIZE
565 # define EMSGSIZE -1
566 #endif
567 CND(EMSGSIZE, "Message too long")
568
569 #ifndef ENAMETOOLONG
570 # define ENAMETOOLONG -1
571 #endif
572 CND(ENAMETOOLONG, "Name too long")
573
574 #ifndef ENETDOWN
575 # define ENETDOWN -1
576 #endif
577 CND(ENETDOWN, "Network is down")
578
579 #ifndef ENETRESET
580 # define ENETRESET -1
581 #endif
582 CND(ENETRESET, "Disconn. on network reset")
583
584 #ifndef ENETUNREACH
585 # define ENETUNREACH -1
586 #endif
587 CND(ENETUNREACH, "Network is unreachable")
588
589 #ifndef ENOBUFS
590 # define ENOBUFS -1
591 #endif
592 CND(ENOBUFS, "No buffer space available")
593
594 #ifndef ENOPROTOOPT
595 # define ENOPROTOOPT -1
596 #endif
597 CND(ENOPROTOOPT, "Protocol not available")
598
599 #ifndef ENOTCONN
600 # define ENOTCONN -1
601 #endif
602 CND(ENOTCONN, "Socket not connected")
603
604 #ifndef ENOTSOCK
605 # define ENOTSOCK -1
606 #endif
607 CND(ENOTSOCK, "Operation on non socket")
608
609 #ifndef EOPNOTSUPP
610 # define EOPNOTSUPP -1
611 #endif
612 CND(EOPNOTSUPP, "Operation not supported")
613
614 #ifndef EPIPE
615 # define EPIPE -1
616 #endif
617 CND(EPIPE, "Broken pipe")
618
619 #ifndef EPFNOSUPPORT
620 # define EPFNOSUPPORT -1
621 #endif
622 CND(EPFNOSUPPORT, "Unknown protocol family")
623
624 #ifndef EPROTONOSUPPORT
625 # define EPROTONOSUPPORT -1
626 #endif
627 CND(EPROTONOSUPPORT, "Unknown protocol")
628
629 #ifndef EPROTOTYPE
630 # define EPROTOTYPE -1
631 #endif
632 CND(EPROTOTYPE, "Unknown protocol type")
633
634 #ifndef ERANGE
635 # define ERANGE -1
636 #endif
637 CND(ERANGE, "Result too large")
638
639 #ifndef ESHUTDOWN
640 # define ESHUTDOWN -1
641 #endif
642 CND(ESHUTDOWN, "Cannot send once shutdown")
643
644 #ifndef ESOCKTNOSUPPORT
645 # define ESOCKTNOSUPPORT -1
646 #endif
647 CND(ESOCKTNOSUPPORT, "Socket type not supported")
648
649 #ifndef ETIMEDOUT
650 # define ETIMEDOUT -1
651 #endif
652 CND(ETIMEDOUT, "Connection timed out")
653
654 #ifndef ETOOMANYREFS
655 # define ETOOMANYREFS -1
656 #endif
657 CND(ETOOMANYREFS, "Too many references")
658
659 #ifndef EWOULDBLOCK
660 # define EWOULDBLOCK -1
661 #endif
662 CND(EWOULDBLOCK, "Operation would block")
663
664 #ifndef E2BIG
665 # define E2BIG -1
666 #endif
667 CND(E2BIG, "Argument list too long")
668
669 #ifndef EILSEQ
670 # define EILSEQ -1
671 #endif
672 CND(EILSEQ, "Illegal byte sequence")
673
674 /**
675 ** Terminal/serial I/O constants
676 **/
677
678 #if defined(HAVE_TERMIOS) || defined(__MINGW32__)
679 /*
680
681 ----------------------
682 -- Terminal control --
683 ----------------------
684
685 */
686 #endif
687
688 #ifdef HAVE_TERMIOS
689
690 #ifndef TCSANOW
691 # define TCSANOW -1
692 #endif
693 CND(TCSANOW, "Immediate")
694
695 #ifndef TCIFLUSH
696 # define TCIFLUSH -1
697 #endif
698 CND(TCIFLUSH, "Flush input")
699
700 #ifndef IXON
701 # define IXON -1
702 #endif
703 CNU(IXON, "Output sw flow control")
704
705 #ifndef CLOCAL
706 # define CLOCAL -1
707 #endif
708 CNU(CLOCAL, "Local")
709
710 #ifndef CRTSCTS
711 # define CRTSCTS -1
712 #endif
713 CNU(CRTSCTS, "Output hw flow control")
714
715 #ifndef CREAD
716 # define CREAD -1
717 #endif
718 CNU(CREAD, "Read")
719
720 #ifndef CS5
721 # define CS5 -1
722 #endif
723 CNU(CS5, "5 data bits")
724
725 #ifndef CS6
726 # define CS6 -1
727 #endif
728 CNU(CS6, "6 data bits")
729
730 #ifndef CS7
731 # define CS7 -1
732 #endif
733 CNU(CS7, "7 data bits")
734
735 #ifndef CS8
736 # define CS8 -1
737 #endif
738 CNU(CS8, "8 data bits")
739
740 #ifndef CSTOPB
741 # define CSTOPB -1
742 #endif
743 CNU(CSTOPB, "2 stop bits")
744
745 #ifndef PARENB
746 # define PARENB -1
747 #endif
748 CNU(PARENB, "Parity enable")
749
750 #ifndef PARODD
751 # define PARODD -1
752 #endif
753 CNU(PARODD, "Parity odd")
754
755 #ifndef B0
756 # define B0 -1
757 #endif
758 CNU(B0, "0 bps")
759
760 #ifndef B50
761 # define B50 -1
762 #endif
763 CNU(B50, "50 bps")
764
765 #ifndef B75
766 # define B75 -1
767 #endif
768 CNU(B75, "75 bps")
769
770 #ifndef B110
771 # define B110 -1
772 #endif
773 CNU(B110, "110 bps")
774
775 #ifndef B134
776 # define B134 -1
777 #endif
778 CNU(B134, "134 bps")
779
780 #ifndef B150
781 # define B150 -1
782 #endif
783 CNU(B150, "150 bps")
784
785 #ifndef B200
786 # define B200 -1
787 #endif
788 CNU(B200, "200 bps")
789
790 #ifndef B300
791 # define B300 -1
792 #endif
793 CNU(B300, "300 bps")
794
795 #ifndef B600
796 # define B600 -1
797 #endif
798 CNU(B600, "600 bps")
799
800 #ifndef B1200
801 # define B1200 -1
802 #endif
803 CNU(B1200, "1200 bps")
804
805 #ifndef B1800
806 # define B1800 -1
807 #endif
808 CNU(B1800, "1800 bps")
809
810 #ifndef B2400
811 # define B2400 -1
812 #endif
813 CNU(B2400, "2400 bps")
814
815 #ifndef B4800
816 # define B4800 -1
817 #endif
818 CNU(B4800, "4800 bps")
819
820 #ifndef B9600
821 # define B9600 -1
822 #endif
823 CNU(B9600, "9600 bps")
824
825 #ifndef B19200
826 # define B19200 -1
827 #endif
828 CNU(B19200, "19200 bps")
829
830 #ifndef B38400
831 # define B38400 -1
832 #endif
833 CNU(B38400, "38400 bps")
834
835 #ifndef B57600
836 # define B57600 -1
837 #endif
838 CNU(B57600, "57600 bps")
839
840 #ifndef B115200
841 # define B115200 -1
842 #endif
843 CNU(B115200, "115200 bps")
844
845 #ifndef B230400
846 # define B230400 -1
847 #endif
848 CNU(B230400, "230400 bps")
849
850 #ifndef B460800
851 # define B460800 -1
852 #endif
853 CNU(B460800, "460800 bps")
854
855 #ifndef B500000
856 # define B500000 -1
857 #endif
858 CNU(B500000, "500000 bps")
859
860 #ifndef B576000
861 # define B576000 -1
862 #endif
863 CNU(B576000, "576000 bps")
864
865 #ifndef B921600
866 # define B921600 -1
867 #endif
868 CNU(B921600, "921600 bps")
869
870 #ifndef B1000000
871 # define B1000000 -1
872 #endif
873 CNU(B1000000, "1000000 bps")
874
875 #ifndef B1152000
876 # define B1152000 -1
877 #endif
878 CNU(B1152000, "1152000 bps")
879
880 #ifndef B1500000
881 # define B1500000 -1
882 #endif
883 CNU(B1500000, "1500000 bps")
884
885 #ifndef B2000000
886 # define B2000000 -1
887 #endif
888 CNU(B2000000, "2000000 bps")
889
890 #ifndef B2500000
891 # define B2500000 -1
892 #endif
893 CNU(B2500000, "2500000 bps")
894
895 #ifndef B3000000
896 # define B3000000 -1
897 #endif
898 CNU(B3000000, "3000000 bps")
899
900 #ifndef B3500000
901 # define B3500000 -1
902 #endif
903 CNU(B3500000, "3500000 bps")
904
905 #ifndef B4000000
906 # define B4000000 -1
907 #endif
908 CNU(B4000000, "4000000 bps")
909
910 /*
911
912 ---------------------------------
913 -- Terminal control characters --
914 ---------------------------------
915
916 */
917
918 #ifndef VINTR
919 # define VINTR -1
920 #endif
921 CND(VINTR, "Interrupt")
922
923 #ifndef VQUIT
924 # define VQUIT -1
925 #endif
926 CND(VQUIT, "Quit")
927
928 #ifndef VERASE
929 # define VERASE -1
930 #endif
931 CND(VERASE, "Erase")
932
933 #ifndef VKILL
934 # define VKILL -1
935 #endif
936 CND(VKILL, "Kill")
937
938 #ifndef VEOF
939 # define VEOF -1
940 #endif
941 CND(VEOF, "EOF")
942
943 #ifndef VTIME
944 # define VTIME -1
945 #endif
946 CND(VTIME, "Read timeout")
947
948 #ifndef VMIN
949 # define VMIN -1
950 #endif
951 CND(VMIN, "Read min chars")
952
953 #ifndef VSWTC
954 # define VSWTC -1
955 #endif
956 CND(VSWTC, "Switch")
957
958 #ifndef VSTART
959 # define VSTART -1
960 #endif
961 CND(VSTART, "Flow control start")
962
963 #ifndef VSTOP
964 # define VSTOP -1
965 #endif
966 CND(VSTOP, "Flow control stop")
967
968 #ifndef VSUSP
969 # define VSUSP -1
970 #endif
971 CND(VSUSP, "Suspend")
972
973 #ifndef VEOL
974 # define VEOL -1
975 #endif
976 CND(VEOL, "EOL")
977
978 #ifndef VREPRINT
979 # define VREPRINT -1
980 #endif
981 CND(VREPRINT, "Reprint unread")
982
983 #ifndef VDISCARD
984 # define VDISCARD -1
985 #endif
986 CND(VDISCARD, "Discard pending")
987
988 #ifndef VWERASE
989 # define VWERASE -1
990 #endif
991 CND(VWERASE, "Word erase")
992
993 #ifndef VLNEXT
994 # define VLNEXT -1
995 #endif
996 CND(VLNEXT, "Literal next")
997
998 #ifndef VEOL2
999 # define VEOL2 -1
1000 #endif
1001 CND(VEOL2, "Alternative EOL")
1002
1003 #endif /* HAVE_TERMIOS */
1004
1005 #if defined(__MINGW32__) || defined(__CYGWIN__)
1006 CNU(DTR_CONTROL_ENABLE, "Enable DTR flow ctrl")
1007 CNU(RTS_CONTROL_ENABLE, "Enable RTS flow ctrl")
1008 #endif
1009
1010 /*
1011
1012 -----------------------------
1013 -- Pseudo terminal library --
1014 -----------------------------
1015
1016 */
1017
1018 #if defined (__FreeBSD__) || defined (__linux__) || defined (__DragonFly__)
1019 # define PTY_Library "-lutil"
1020 #else
1021 # define PTY_Library ""
1022 #endif
1023 CST(PTY_Library, "for g-exptty")
1024
1025 /**
1026 ** Sockets constants
1027 **/
1028
1029 #ifdef HAVE_SOCKETS
1030
1031 /*
1032
1033 --------------
1034 -- Families --
1035 --------------
1036
1037 */
1038
1039 #ifndef AF_INET
1040 # define AF_INET -1
1041 #endif
1042 CND(AF_INET, "IPv4 address family")
1043
1044 #ifndef AF_INET6
1045 # define AF_INET6 -1
1046 #else
1047 # define HAVE_AF_INET6 1
1048 #endif
1049 CND(AF_INET6, "IPv6 address family")
1050
1051 #ifndef AF_UNSPEC
1052 # define AF_UNSPEC -1
1053 #else
1054 # define HAVE_AF_UNSPEC 1
1055 #endif
1056 CND(AF_UNSPEC, "Unspecified address family")
1057
1058 /*
1059
1060 -----------------------------
1061 -- addrinfo fields offsets --
1062 -----------------------------
1063
1064 */
1065
1066 #ifdef AI_CANONNAME
1067 const struct addrinfo ai;
1068
1069 #define AI_FLAGS_OFFSET ((void *)&ai.ai_flags - (void *)&ai)
1070 #define AI_FAMILY_OFFSET ((void *)&ai.ai_family - (void *)&ai)
1071 #define AI_SOCKTYPE_OFFSET ((void *)&ai.ai_socktype - (void *)&ai)
1072 #define AI_PROTOCOL_OFFSET ((void *)&ai.ai_protocol - (void *)&ai)
1073 #define AI_ADDRLEN_OFFSET ((void *)&ai.ai_addrlen - (void *)&ai)
1074 #define AI_ADDR_OFFSET ((void *)&ai.ai_addr - (void *)&ai)
1075 #define AI_CANONNAME_OFFSET ((void *)&ai.ai_canonname - (void *)&ai)
1076 #define AI_NEXT_OFFSET ((void *)&ai.ai_next - (void *)&ai)
1077
1078 #else
1079
1080 #define AI_FLAGS_OFFSET 0
1081 #define AI_FAMILY_OFFSET 4
1082 #define AI_SOCKTYPE_OFFSET 8
1083 #define AI_PROTOCOL_OFFSET 12
1084 #define AI_ADDRLEN_OFFSET 16
1085 #define AI_CANONNAME_OFFSET 24
1086 #define AI_ADDR_OFFSET 32
1087 #define AI_NEXT_OFFSET 40
1088
1089 #endif
1090
1091 CND(AI_FLAGS_OFFSET, "Offset of ai_flags in addrinfo");
1092 CND(AI_FAMILY_OFFSET, "Offset of ai_family in addrinfo");
1093 CND(AI_SOCKTYPE_OFFSET, "Offset of ai_socktype in addrinfo");
1094 CND(AI_PROTOCOL_OFFSET, "Offset of ai_protocol in addrinfo");
1095 CND(AI_ADDRLEN_OFFSET, "Offset of ai_addrlen in addrinfo");
1096 CND(AI_ADDR_OFFSET, "Offset of ai_addr in addrinfo");
1097 CND(AI_CANONNAME_OFFSET, "Offset of ai_canonname in addrinfo");
1098 CND(AI_NEXT_OFFSET, "Offset of ai_next in addrinfo");
1099
1100 /*
1101
1102 ---------------------------------------
1103 -- getaddrinfo getnameinfo constants --
1104 ---------------------------------------
1105
1106 */
1107
1108 #ifndef AI_PASSIVE
1109 # define AI_PASSIVE -1
1110 #endif
1111 CND(AI_PASSIVE, "NULL nodename for accepting")
1112
1113 #ifndef AI_CANONNAME
1114 # define AI_CANONNAME -1
1115 #endif
1116 CND(AI_CANONNAME, "Get the host official name")
1117
1118 #ifndef AI_NUMERICSERV
1119 # define AI_NUMERICSERV -1
1120 #endif
1121 CND(AI_NUMERICSERV, "Service is a numeric string")
1122
1123 #ifndef AI_NUMERICHOST
1124 # define AI_NUMERICHOST -1
1125 #endif
1126 CND(AI_NUMERICHOST, "Node is a numeric IP address")
1127
1128 #ifndef AI_ADDRCONFIG
1129 # define AI_ADDRCONFIG -1
1130 #endif
1131 CND(AI_ADDRCONFIG, "Returns addresses for only locally configured families")
1132
1133 #ifndef AI_V4MAPPED
1134 # define AI_V4MAPPED -1
1135 #endif
1136 CND(AI_V4MAPPED, "Returns IPv4 mapped to IPv6")
1137
1138 #ifndef AI_ALL
1139 # define AI_ALL -1
1140 #endif
1141 CND(AI_ALL, "Change AI_V4MAPPED behavior for unavailavle IPv6 addresses")
1142
1143 #ifndef NI_NAMEREQD
1144 # define NI_NAMEREQD -1
1145 #endif
1146 CND(NI_NAMEREQD, "Error if the hostname cannot be determined")
1147
1148 #ifndef NI_DGRAM
1149 # define NI_DGRAM -1
1150 #endif
1151 CND(NI_DGRAM, "Service is datagram")
1152
1153 #ifndef NI_NOFQDN
1154 # define NI_NOFQDN -1
1155 #endif
1156 CND(NI_NOFQDN, "Return only the hostname part for local hosts")
1157
1158 #ifndef NI_NUMERICSERV
1159 # define NI_NUMERICSERV -1
1160 #endif
1161 CND(NI_NUMERICSERV, "Numeric form of the service")
1162
1163 #ifndef NI_NUMERICHOST
1164 # define NI_NUMERICHOST -1
1165 #endif
1166 CND(NI_NUMERICHOST, "Numeric form of the hostname")
1167
1168 #ifndef NI_MAXHOST
1169 # define NI_MAXHOST -1
1170 #endif
1171 CND(NI_MAXHOST, "Maximum size of hostname")
1172
1173 #ifndef NI_MAXSERV
1174 # define NI_MAXSERV -1
1175 #endif
1176 CND(NI_MAXSERV, "Maximum size of service name")
1177
1178 #ifndef EAI_SYSTEM
1179 # define EAI_SYSTEM -1
1180 #endif
1181 CND(EAI_SYSTEM, "Check errno for details")
1182
1183 /*
1184
1185 ------------------
1186 -- Socket modes --
1187 ------------------
1188
1189 */
1190
1191 #ifndef SOCK_STREAM
1192 # define SOCK_STREAM -1
1193 #endif
1194 CND(SOCK_STREAM, "Stream socket")
1195
1196 #ifndef SOCK_DGRAM
1197 # define SOCK_DGRAM -1
1198 #endif
1199 CND(SOCK_DGRAM, "Datagram socket")
1200
1201 #ifndef SOCK_RAW
1202 # define SOCK_RAW -1
1203 #endif
1204 CND(SOCK_RAW, "Raw socket")
1205
1206 /*
1207
1208 -----------------
1209 -- Host errors --
1210 -----------------
1211
1212 */
1213
1214 #ifndef HOST_NOT_FOUND
1215 # define HOST_NOT_FOUND -1
1216 #endif
1217 CND(HOST_NOT_FOUND, "Unknown host")
1218
1219 #ifndef TRY_AGAIN
1220 # define TRY_AGAIN -1
1221 #endif
1222 CND(TRY_AGAIN, "Host name lookup failure")
1223
1224 #ifndef NO_DATA
1225 # define NO_DATA -1
1226 #endif
1227 CND(NO_DATA, "No data record for name")
1228
1229 #ifndef NO_RECOVERY
1230 # define NO_RECOVERY -1
1231 #endif
1232 CND(NO_RECOVERY, "Non recoverable errors")
1233
1234 /*
1235
1236 --------------------
1237 -- Shutdown modes --
1238 --------------------
1239
1240 */
1241
1242 #ifndef SHUT_RD
1243 # define SHUT_RD -1
1244 #endif
1245 CND(SHUT_RD, "No more recv")
1246
1247 #ifndef SHUT_WR
1248 # define SHUT_WR -1
1249 #endif
1250 CND(SHUT_WR, "No more send")
1251
1252 #ifndef SHUT_RDWR
1253 # define SHUT_RDWR -1
1254 #endif
1255 CND(SHUT_RDWR, "No more recv/send")
1256
1257 /*
1258
1259 ---------------------
1260 -- Protocol levels --
1261 ---------------------
1262
1263 */
1264
1265 #ifndef SOL_SOCKET
1266 # define SOL_SOCKET -1
1267 #endif
1268 CND(SOL_SOCKET, "Options for socket level")
1269
1270 #ifndef IPPROTO_IP
1271 # define IPPROTO_IP -1
1272 #endif
1273 CND(IPPROTO_IP, "Dummy protocol for IP")
1274
1275 #ifndef IPPROTO_IPV6
1276 # define IPPROTO_IPV6 -1
1277 #endif
1278 CND(IPPROTO_IPV6, "IPv6 socket option level")
1279
1280 #ifndef IPPROTO_UDP
1281 # define IPPROTO_UDP -1
1282 #endif
1283 CND(IPPROTO_UDP, "UDP")
1284
1285 #ifndef IPPROTO_TCP
1286 # define IPPROTO_TCP -1
1287 #endif
1288 CND(IPPROTO_TCP, "TCP")
1289
1290 /*
1291
1292 -------------------
1293 -- Request flags --
1294 -------------------
1295
1296 */
1297
1298 #ifndef MSG_OOB
1299 # define MSG_OOB -1
1300 #endif
1301 CND(MSG_OOB, "Process out-of-band data")
1302
1303 #ifndef MSG_PEEK
1304 # define MSG_PEEK -1
1305 #endif
1306 CND(MSG_PEEK, "Peek at incoming data")
1307
1308 #ifndef MSG_EOR
1309 # define MSG_EOR -1
1310 #endif
1311 CND(MSG_EOR, "Send end of record")
1312
1313 #ifndef MSG_WAITALL
1314 #ifdef __MINWGW32__
1315 /* The value of MSG_WAITALL is 8. Nevertheless winsock.h doesn't
1316 define it, but it is still usable as we link to winsock2 API. */
1317 # define MSG_WAITALL (1 << 3)
1318 #else
1319 # define MSG_WAITALL -1
1320 #endif
1321 #endif
1322 CND(MSG_WAITALL, "Wait for full reception")
1323
1324 #ifndef MSG_NOSIGNAL
1325 # define MSG_NOSIGNAL -1
1326 #endif
1327 CND(MSG_NOSIGNAL, "No SIGPIPE on send")
1328
1329 #if defined (__linux__) || defined (__ANDROID__) || defined (__QNX__)
1330 # define MSG_Forced_Flags "MSG_NOSIGNAL"
1331 #else
1332 # define MSG_Forced_Flags "0"
1333 #endif
1334 CNS(MSG_Forced_Flags, "")
1335 /*
1336 -- Flags set on all send(2) calls
1337 */
1338
1339 /*
1340
1341 --------------------
1342 -- Socket options --
1343 --------------------
1344
1345 */
1346
1347 #ifndef TCP_NODELAY
1348 # define TCP_NODELAY -1
1349 #endif
1350 CND(TCP_NODELAY, "Do not coalesce packets")
1351
1352 #ifndef SO_REUSEADDR
1353 # define SO_REUSEADDR -1
1354 #endif
1355 CND(SO_REUSEADDR, "Bind reuse local address")
1356
1357 #ifndef SO_REUSEPORT
1358 # define SO_REUSEPORT -1
1359 #endif
1360 CND(SO_REUSEPORT, "Bind reuse port number")
1361
1362 #ifndef SO_KEEPALIVE
1363 # define SO_KEEPALIVE -1
1364 #endif
1365 CND(SO_KEEPALIVE, "Enable keep-alive msgs")
1366
1367 #ifndef SO_LINGER
1368 # define SO_LINGER -1
1369 #endif
1370 CND(SO_LINGER, "Defer close to flush data")
1371
1372 #ifndef SO_BROADCAST
1373 # define SO_BROADCAST -1
1374 #endif
1375 CND(SO_BROADCAST, "Can send broadcast msgs")
1376
1377 #ifndef SO_SNDBUF
1378 # define SO_SNDBUF -1
1379 #endif
1380 CND(SO_SNDBUF, "Set/get send buffer size")
1381
1382 #ifndef SO_RCVBUF
1383 # define SO_RCVBUF -1
1384 #endif
1385 CND(SO_RCVBUF, "Set/get recv buffer size")
1386
1387 #ifndef SO_SNDTIMEO
1388 # define SO_SNDTIMEO -1
1389 #endif
1390 CND(SO_SNDTIMEO, "Emission timeout")
1391
1392 #ifndef SO_RCVTIMEO
1393 # define SO_RCVTIMEO -1
1394 #endif
1395 CND(SO_RCVTIMEO, "Reception timeout")
1396
1397 #ifndef SO_ERROR
1398 # define SO_ERROR -1
1399 #endif
1400 CND(SO_ERROR, "Get/clear error status")
1401
1402 #ifndef SO_BUSY_POLL
1403 # define SO_BUSY_POLL -1
1404 #endif
1405 CND(SO_BUSY_POLL, "Busy polling")
1406
1407 #ifndef IP_MULTICAST_IF
1408 # define IP_MULTICAST_IF -1
1409 #endif
1410 CND(IP_MULTICAST_IF, "Set/get mcast interface")
1411
1412 #ifndef IP_MULTICAST_TTL
1413 # define IP_MULTICAST_TTL -1
1414 #endif
1415 CND(IP_MULTICAST_TTL, "Set/get multicast TTL")
1416
1417 #ifndef IP_MULTICAST_LOOP
1418 # define IP_MULTICAST_LOOP -1
1419 #endif
1420 CND(IP_MULTICAST_LOOP, "Set/get mcast loopback")
1421
1422 #ifndef IP_ADD_MEMBERSHIP
1423 # define IP_ADD_MEMBERSHIP -1
1424 #endif
1425 CND(IP_ADD_MEMBERSHIP, "Join a multicast group")
1426
1427 #ifndef IP_DROP_MEMBERSHIP
1428 # define IP_DROP_MEMBERSHIP -1
1429 #endif
1430 CND(IP_DROP_MEMBERSHIP, "Leave a multicast group")
1431
1432 #ifndef IP_PKTINFO
1433 # define IP_PKTINFO -1
1434 #endif
1435 CND(IP_PKTINFO, "Get datagram info")
1436
1437 #ifndef IP_RECVERR
1438 # define IP_RECVERR -1
1439 #endif
1440 CND(IP_RECVERR, "Extended reliable error message passing")
1441
1442 #ifndef IPV6_ADDRFORM
1443 # define IPV6_ADDRFORM -1
1444 #endif
1445 CND(IPV6_ADDRFORM, "Turn IPv6 socket into different address family")
1446
1447 #ifndef IPV6_ADD_MEMBERSHIP
1448 # define IPV6_ADD_MEMBERSHIP -1
1449 #endif
1450 CND(IPV6_ADD_MEMBERSHIP, "Join IPv6 multicast group")
1451
1452 #ifndef IPV6_DROP_MEMBERSHIP
1453 # define IPV6_DROP_MEMBERSHIP -1
1454 #endif
1455 CND(IPV6_DROP_MEMBERSHIP, "Leave IPv6 multicast group")
1456
1457 #ifndef IPV6_MTU
1458 # define IPV6_MTU -1
1459 #endif
1460 CND(IPV6_MTU, "Set/get MTU used for the socket")
1461
1462 #ifndef IPV6_MTU_DISCOVER
1463 # define IPV6_MTU_DISCOVER -1
1464 #endif
1465 CND(IPV6_MTU_DISCOVER, "Control path-MTU discovery on the socket")
1466
1467 #ifndef IPV6_MULTICAST_HOPS
1468 # define IPV6_MULTICAST_HOPS -1
1469 #endif
1470 CND(IPV6_MULTICAST_HOPS, "Set the multicast hop limit for the socket")
1471
1472 #ifndef IPV6_MULTICAST_IF
1473 # define IPV6_MULTICAST_IF -1
1474 #endif
1475 CND(IPV6_MULTICAST_IF, "Set/get IPv6 mcast interface")
1476
1477 #ifndef IPV6_MULTICAST_LOOP
1478 # define IPV6_MULTICAST_LOOP -1
1479 #endif
1480 CND(IPV6_MULTICAST_LOOP, "Set/get mcast loopback")
1481
1482 #ifndef IPV6_RECVPKTINFO
1483 # define IPV6_RECVPKTINFO -1
1484 #endif
1485 CND(IPV6_RECVPKTINFO, "Set delivery of the IPV6_PKTINFO")
1486
1487 #ifndef IPV6_PKTINFO
1488 # define IPV6_PKTINFO -1
1489 #endif
1490 CND(IPV6_PKTINFO, "Get IPv6datagram info")
1491
1492 #ifndef IPV6_RTHDR
1493 # define IPV6_RTHDR -1
1494 #endif
1495 CND(IPV6_RTHDR, "Set the routing header delivery")
1496
1497 #ifndef IPV6_AUTHHDR
1498 # define IPV6_AUTHHDR -1
1499 #endif
1500 CND(IPV6_AUTHHDR, "Set the authentication header delivery")
1501
1502 #ifndef IPV6_DSTOPTS
1503 # define IPV6_DSTOPTS -1
1504 #endif
1505 CND(IPV6_DSTOPTS, "Set the destination options delivery")
1506
1507 #ifndef IPV6_HOPOPTS
1508 # define IPV6_HOPOPTS -1
1509 #endif
1510 CND(IPV6_HOPOPTS, "Set the hop options delivery")
1511
1512 #ifndef IPV6_FLOWINFO
1513 # define IPV6_FLOWINFO -1
1514 #endif
1515 CND(IPV6_FLOWINFO, "Set the flow ID delivery")
1516
1517 #ifndef IPV6_HOPLIMIT
1518 # define IPV6_HOPLIMIT -1
1519 #endif
1520 CND(IPV6_HOPLIMIT, "Set the hop count of the packet delivery")
1521
1522 #ifndef IPV6_RECVERR
1523 # define IPV6_RECVERR -1
1524 #endif
1525 CND(IPV6_RECVERR, "Extended reliable error message passing")
1526
1527 #ifndef IPV6_ROUTER_ALERT
1528 # define IPV6_ROUTER_ALERT -1
1529 #endif
1530 CND(IPV6_ROUTER_ALERT, "Pass forwarded router alert hop-by-hop option")
1531
1532 #ifndef IPV6_UNICAST_HOPS
1533 # define IPV6_UNICAST_HOPS -1
1534 #endif
1535 CND(IPV6_UNICAST_HOPS, "Set the unicast hop limit")
1536
1537 #ifndef IPV6_V6ONLY
1538 # define IPV6_V6ONLY -1
1539 #endif
1540 CND(IPV6_V6ONLY, "Restricted to IPv6 communications only")
1541
1542 /*
1543
1544 ----------------------
1545 -- Type definitions --
1546 ----------------------
1547
1548 */
1549
1550 {
1551 struct timeval tv;
1552 /*
1553 -- Sizes (in bytes) of the components of struct timeval
1554 */
1555 #define SIZEOF_tv_sec (sizeof tv.tv_sec)
1556 CND(SIZEOF_tv_sec, "tv_sec")
1557 #define SIZEOF_tv_usec (sizeof tv.tv_usec)
1558 CND(SIZEOF_tv_usec, "tv_usec")
1559 /*
1560
1561 -- Maximum allowed value for tv_sec
1562 */
1563
1564 /**
1565 ** On Solaris, field tv_sec in struct timeval has an undocumented
1566 ** hard-wired limit of 100 million.
1567 ** On IA64 HP-UX the limit is 2**31 - 1.
1568 **/
1569 #if defined (__sun__)
1570 # define MAX_tv_sec "100_000_000"
1571
1572 #elif defined (__hpux__)
1573 # define MAX_tv_sec "16#7fffffff#"
1574
1575 #else
1576 # define MAX_tv_sec "2 ** (SIZEOF_tv_sec * 8 - 1) - 1"
1577 #endif
1578 CNS(MAX_tv_sec, "")
1579 }
1580 /*
1581
1582 -- Sizes of various data types
1583 */
1584
1585 #define SIZEOF_sockaddr_in (sizeof (struct sockaddr_in))
1586 CND(SIZEOF_sockaddr_in, "struct sockaddr_in")
1587 #ifdef HAVE_AF_INET6
1588 # define SIZEOF_sockaddr_in6 (sizeof (struct sockaddr_in6))
1589 #else
1590 # define SIZEOF_sockaddr_in6 0
1591 #endif
1592 CND(SIZEOF_sockaddr_in6, "struct sockaddr_in6")
1593
1594 #define SIZEOF_fd_set (sizeof (fd_set))
1595 CND(SIZEOF_fd_set, "fd_set")
1596 CND(FD_SETSIZE, "Max fd value")
1597
1598 #define SIZEOF_struct_hostent (sizeof (struct hostent))
1599 CND(SIZEOF_struct_hostent, "struct hostent")
1600
1601 #define SIZEOF_struct_servent (sizeof (struct servent))
1602 CND(SIZEOF_struct_servent, "struct servent")
1603
1604 #if defined (__linux__) || defined (__ANDROID__) || defined (__QNX__)
1605 #define SIZEOF_sigset (sizeof (sigset_t))
1606 CND(SIZEOF_sigset, "sigset")
1607 #endif
1608
1609 #if defined(_WIN32) || defined(__vxworks)
1610 #define SIZEOF_socklen_t sizeof (size_t)
1611 #else
1612 #define SIZEOF_socklen_t sizeof (socklen_t)
1613 #endif
1614 CND(SIZEOF_socklen_t, "Size of socklen_t");
1615
1616 #ifndef IF_NAMESIZE
1617 #ifdef IF_MAX_STRING_SIZE
1618 #define IF_NAMESIZE IF_MAX_STRING_SIZE
1619 #else
1620 #define IF_NAMESIZE -1
1621 #endif
1622 #endif
1623 CND(IF_NAMESIZE, "Max size of interface name with 0 terminator");
1624
1625 /*
1626
1627 -- Fields of struct msghdr
1628 */
1629
1630 #if defined (__sun__) || defined (__hpux__)
1631 # define Msg_Iovlen_T "int"
1632 #else
1633 # define Msg_Iovlen_T "size_t"
1634 #endif
1635
1636 SUB(Msg_Iovlen_T)
1637
1638 /*
1639
1640 ----------------------------------------
1641 -- Properties of supported interfaces --
1642 ----------------------------------------
1643
1644 */
1645
1646 CND(Need_Netdb_Buffer, "Need buffer for Netdb ops")
1647 CND(Need_Netdb_Lock, "Need lock for Netdb ops")
1648 CND(Has_Sockaddr_Len, "Sockaddr has sa_len field")
1649
1650 /**
1651 ** Do not change the format of the line below without also updating the
1652 ** MaRTE Makefile.
1653 **/
1654 C("Thread_Blocking_IO", Boolean, "True", "")
1655 /*
1656 -- Set False for contexts where socket i/o are process blocking
1657
1658 */
1659
1660 #ifdef HAVE_INET_PTON
1661 # define Inet_Pton_Linkname "inet_pton"
1662 #else
1663 # define Inet_Pton_Linkname "__gnat_inet_pton"
1664 #endif
1665 CST(Inet_Pton_Linkname, "")
1666
1667 #ifdef HAVE_INET_NTOP
1668 # define Inet_Ntop_Linkname "inet_ntop"
1669 #else
1670 # define Inet_Ntop_Linkname "__gnat_inet_ntop"
1671 #endif
1672 CST(Inet_Ntop_Linkname, "")
1673
1674 #endif /* HAVE_SOCKETS */
1675
1676 /*
1677
1678 ---------------------
1679 -- Threads support --
1680 ---------------------
1681
1682 -- Clock identifier definitions
1683
1684 */
1685
1686 /* Note: On HP-UX, CLOCK_REALTIME is an enum, not a macro. */
1687
1688 #if !(defined(CLOCK_REALTIME) || defined (__hpux__))
1689 # define CLOCK_REALTIME (-1)
1690 #endif
1691 CND(CLOCK_REALTIME, "System realtime clock")
1692
1693 #ifdef CLOCK_MONOTONIC
1694 CND(CLOCK_MONOTONIC, "System monotonic clock")
1695 #endif
1696
1697 #ifdef CLOCK_FASTEST
1698 CND(CLOCK_FASTEST, "Fastest clock")
1699 #endif
1700
1701 #ifndef CLOCK_THREAD_CPUTIME_ID
1702 # define CLOCK_THREAD_CPUTIME_ID -1
1703 #endif
1704 CND(CLOCK_THREAD_CPUTIME_ID, "Thread CPU clock")
1705
1706 #if defined(__linux__) || defined(__FreeBSD__) \
1707 || (defined(_AIX) && defined(_AIXVERSION_530)) \
1708 || defined(__DragonFly__) || defined(__QNX__)
1709 /** On these platforms use system provided monotonic clock instead of
1710 ** the default CLOCK_REALTIME. We then need to set up cond var attributes
1711 ** appropriately (see thread.c).
1712 **
1713 ** Note that AIX 5.2 does not support CLOCK_MONOTONIC timestamps for
1714 ** pthread_cond_timedwait (and does not have pthread_condattr_setclock),
1715 ** hence the conditionalization on AIX version above). _AIXVERSION_530
1716 ** is defined in AIX 5.3 and more recent versions.
1717 **/
1718 # define CLOCK_RT_Ada "CLOCK_MONOTONIC"
1719
1720 #else
1721 /* By default use CLOCK_REALTIME */
1722 # define CLOCK_RT_Ada "CLOCK_REALTIME"
1723 #endif
1724
1725 #ifdef CLOCK_RT_Ada
1726 CNS(CLOCK_RT_Ada, "")
1727 #endif
1728
1729 #if defined (__APPLE__) || defined (__linux__) || defined (__ANDROID__) \
1730 || defined (__QNX__) || defined (__rtems__) || defined (DUMMY)
1731 /*
1732
1733 -- Sizes of pthread data types
1734 */
1735
1736 #if defined (__APPLE__) || defined (DUMMY)
1737 /*
1738 -- (on Darwin, these are just placeholders)
1739 */
1740 #define PTHREAD_SIZE __PTHREAD_SIZE__
1741 #define PTHREAD_ATTR_SIZE __PTHREAD_ATTR_SIZE__
1742 #define PTHREAD_MUTEXATTR_SIZE __PTHREAD_MUTEXATTR_SIZE__
1743 #define PTHREAD_MUTEX_SIZE __PTHREAD_MUTEX_SIZE__
1744 #define PTHREAD_CONDATTR_SIZE __PTHREAD_CONDATTR_SIZE__
1745 #define PTHREAD_COND_SIZE __PTHREAD_COND_SIZE__
1746 #define PTHREAD_RWLOCKATTR_SIZE __PTHREAD_RWLOCKATTR_SIZE__
1747 #define PTHREAD_RWLOCK_SIZE __PTHREAD_RWLOCK_SIZE__
1748 #define PTHREAD_ONCE_SIZE __PTHREAD_ONCE_SIZE__
1749 #else
1750 #define PTHREAD_SIZE (sizeof (pthread_t))
1751 #define PTHREAD_ATTR_SIZE (sizeof (pthread_attr_t))
1752 #define PTHREAD_MUTEXATTR_SIZE (sizeof (pthread_mutexattr_t))
1753 #define PTHREAD_MUTEX_SIZE (sizeof (pthread_mutex_t))
1754 #define PTHREAD_CONDATTR_SIZE (sizeof (pthread_condattr_t))
1755 #define PTHREAD_COND_SIZE (sizeof (pthread_cond_t))
1756 #define PTHREAD_RWLOCKATTR_SIZE (sizeof (pthread_rwlockattr_t))
1757 #define PTHREAD_RWLOCK_SIZE (sizeof (pthread_rwlock_t))
1758 #define PTHREAD_ONCE_SIZE (sizeof (pthread_once_t))
1759 #endif
1760 /*
1761
1762 */
1763 CND(PTHREAD_SIZE, "pthread_t")
1764 CND(PTHREAD_ATTR_SIZE, "pthread_attr_t")
1765 CND(PTHREAD_MUTEXATTR_SIZE, "pthread_mutexattr_t")
1766 CND(PTHREAD_MUTEX_SIZE, "pthread_mutex_t")
1767 CND(PTHREAD_CONDATTR_SIZE, "pthread_condattr_t")
1768 CND(PTHREAD_COND_SIZE, "pthread_cond_t")
1769 CND(PTHREAD_RWLOCKATTR_SIZE, "pthread_rwlockattr_t")
1770 CND(PTHREAD_RWLOCK_SIZE, "pthread_rwlock_t")
1771 CND(PTHREAD_ONCE_SIZE, "pthread_once_t")
1772
1773 #endif /* __APPLE__ || __linux__ || __ANDROID__ || __rtems__ */
1774
1775 /*
1776
1777 --------------------------------
1778 -- File and directory support --
1779 --------------------------------
1780
1781 */
1782
1783 /**
1784 ** Note: this constant can be used in the GNAT runtime library. In compiler
1785 ** units on the other hand, System.OS_Constants is not available, so we
1786 ** declare an Ada constant (Osint.File_Attributes_Size) independently, which
1787 ** is at least as large as sizeof (struct file_attributes), and we have an
1788 ** assertion at initialization of Osint checking that the size is indeed at
1789 ** least sufficient.
1790 **/
1791 #define SIZEOF_struct_file_attributes (sizeof (struct file_attributes))
1792 CND(SIZEOF_struct_file_attributes, "struct file_attributes")
1793
1794 /**
1795 ** Maximal size of buffer for struct dirent. Note: Since POSIX.1 does not
1796 ** specify the size of the d_name field, and other nonstandard fields may
1797 ** precede that field within the dirent structure, we must make a conservative
1798 ** computation.
1799 **/
1800 {
1801 struct dirent dent;
1802 #define SIZEOF_struct_dirent_alloc \
1803 ((char*) &dent.d_name - (char*) &dent) + NAME_MAX + 1
1804 CND(SIZEOF_struct_dirent_alloc, "struct dirent allocation")
1805 }
1806
1807 /**
1808 ** System-specific constants follow
1809 ** Each section should be activated if compiling for the corresponding
1810 ** platform *or* generating the dummy version for runtime test compilation.
1811 **/
1812
1813 #if defined (__vxworks) || defined (DUMMY)
1814
1815 /*
1816
1817 --------------------------------
1818 -- VxWorks-specific constants --
1819 --------------------------------
1820
1821 -- These constants may be used only within the VxWorks version of
1822 -- GNAT.Sockets.Thin.
1823 */
1824
1825 CND(OK, "VxWorks generic success")
1826 CND(ERROR, "VxWorks generic error")
1827
1828 #endif /* __vxworks */
1829
1830 #if defined (__MINGW32__) || defined (DUMMY)
1831 /*
1832
1833 ------------------------------
1834 -- MinGW-specific constants --
1835 ------------------------------
1836
1837 -- These constants may be used only within the MinGW version of
1838 -- GNAT.Sockets.Thin.
1839 */
1840
1841 CND(WSASYSNOTREADY, "System not ready")
1842 CND(WSAVERNOTSUPPORTED, "Version not supported")
1843 CND(WSANOTINITIALISED, "Winsock not initialized")
1844 CND(WSAEDISCON, "Disconnected")
1845
1846 #endif /* __MINGW32__ */
1847
1848 /**
1849 ** End of constants definitions
1850 **/
1851
1852 #ifdef NATIVE
1853 putchar ('\n');
1854 #endif
1855
1856 /*
1857
1858 end System.OS_Constants;
1859 */
1860 }
1861