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 #if defined (__MINGW32__) || defined (__CYGWIN__)
265 # define TARGET_OS "Windows"
266 # define Serial_Port_Descriptor "System.Win32.HANDLE"
267 TXT("with System.Win32;")
268 #else
269 # define TARGET_OS "Other_OS"
270 # define Serial_Port_Descriptor "Interfaces.C.int"
271 #endif
272 
273 /*
274 package System.OS_Constants is
275 
276    pragma Pure;
277 */
278 
279 /**
280  **  General constants (all platforms)
281  **/
282 
283 /*
284 
285    ---------------------------------
286    -- General platform parameters --
287    ---------------------------------
288 
289    type OS_Type is (Windows, Other_OS);
290 */
291 C("Target_OS", OS_Type, TARGET_OS, "")
292 /*
293    pragma Warnings (Off, Target_OS);
294    --  Suppress warnings on Target_OS since it is in general tested for
295    --  equality with a constant value to implement conditional compilation,
296    --  which normally generates a constant condition warning.
297 
298 */
299 #define Target_Name TARGET
300 CST(Target_Name, "")
301 
302 /**
303  ** Note: the name of the following constant is recognized specially by
304  **  xoscons (case sensitive).
305  **/
306 #define SIZEOF_unsigned_int sizeof (unsigned int)
307 CND(SIZEOF_unsigned_int, "Size of unsigned int")
308 
309 SUB(Serial_Port_Descriptor)
310 
311 /*
312 
313    -------------------
314    -- System limits --
315    -------------------
316 
317 */
318 
319 #ifndef IOV_MAX
320 # define IOV_MAX INT_MAX
321 #endif
322 CND(IOV_MAX, "Maximum writev iovcnt")
323 
324 /* NAME_MAX is used to compute the allocation size for a struct dirent
325  * passed to readdir() / readdir_r(). However on some systems it is not
326  * defined, as it is technically a filesystem dependent property that
327  * we should retrieve through pathconf(). In any case, we do not need a
328  * precise value but only an upper limit.
329  */
330 #ifndef NAME_MAX
331 # ifdef MAXNAMELEN
332    /* Solaris has no NAME_MAX but defines MAXNAMELEN */
333 #  define NAME_MAX MAXNAMELEN
334 # elif defined(PATH_MAX)
335    /* PATH_MAX (maximum length of a full path name) is a safe fall back */
336 #  define NAME_MAX PATH_MAX
337 # elif defined(FILENAME_MAX)
338    /* Similarly FILENAME_MAX can provide a safe fall back */
339 #  define NAME_MAX FILENAME_MAX
340 # else
341    /* Hardcode a reasonably large value as a last chance fallback */
342 #  define NAME_MAX 1024
343 # endif
344 #endif
345 CND(NAME_MAX, "Maximum file name length")
346 
347 /*
348 
349    ---------------------
350    -- File open modes --
351    ---------------------
352 
353 */
354 
355 #ifndef O_RDWR
356 # define O_RDWR -1
357 #endif
358 CND(O_RDWR, "Read/write")
359 
360 #ifndef O_NOCTTY
361 # define O_NOCTTY -1
362 #endif
363 CND(O_NOCTTY, "Don't change ctrl tty")
364 
365 #ifndef O_NDELAY
366 # define O_NDELAY -1
367 #endif
368 CND(O_NDELAY, "Nonblocking")
369 
370 /*
371 
372    ----------------------
373    -- Fcntl operations --
374    ----------------------
375 
376 */
377 
378 #ifndef F_GETFL
379 # define F_GETFL -1
380 #endif
381 CND(F_GETFL, "Get flags")
382 
383 #ifndef F_SETFL
384 # define F_SETFL -1
385 #endif
386 CND(F_SETFL, "Set flags")
387 
388 /*
389 
390    -----------------
391    -- Fcntl flags --
392    -----------------
393 
394 */
395 
396 #ifndef FNDELAY
397 # define FNDELAY -1
398 #endif
399 CND(FNDELAY, "Nonblocking")
400 
401 /*
402 
403    ----------------------
404    -- Ioctl operations --
405    ----------------------
406 
407 */
408 
409 /* ioctl(2) requests are "int" in UNIX, but "unsigned long" on FreeBSD */
410 
411 #if defined (__FreeBSD__) || defined (__DragonFly__)
412 # define CNI CNU
413 # define IOCTL_Req_T "Interfaces.C.unsigned"
414 #else
415 # define CNI CND
416 # define IOCTL_Req_T "Interfaces.C.int"
417 #endif
418 
419 SUB(IOCTL_Req_T)
420 
421 #ifndef FIONBIO
422 # define FIONBIO -1
423 #endif
424 CNI(FIONBIO, "Set/clear non-blocking io")
425 
426 #ifndef FIONREAD
427 # define FIONREAD -1
428 #endif
429 CNI(FIONREAD, "How many bytes to read")
430 
431 /*
432 
433    ------------------
434    -- Errno values --
435    ------------------
436 
437    --  The following constants are defined from <errno.h>
438 
439 */
440 #ifndef EAGAIN
441 # define EAGAIN -1
442 #endif
443 CND(EAGAIN, "Try again")
444 
445 #ifndef ENOENT
446 # define ENOENT -1
447 #endif
448 CND(ENOENT, "File not found")
449 
450 #ifndef ENOMEM
451 # define ENOMEM -1
452 #endif
453 CND(ENOMEM, "Out of memory")
454 
455 #ifdef __MINGW32__
456 /*
457 
458    --  The following constants are defined from <winsock2.h> (WSA*)
459 
460 */
461 
462 /**
463  **  For sockets-related errno values on Windows, gsocket.h redefines
464  **  Exxx as WSAExxx.
465  **/
466 
467 #endif
468 
469 #ifndef EACCES
470 # define EACCES -1
471 #endif
472 CND(EACCES, "Permission denied")
473 
474 #ifndef EADDRINUSE
475 # define EADDRINUSE -1
476 #endif
477 CND(EADDRINUSE, "Address already in use")
478 
479 #ifndef EADDRNOTAVAIL
480 # define EADDRNOTAVAIL -1
481 #endif
482 CND(EADDRNOTAVAIL, "Cannot assign address")
483 
484 #ifndef EAFNOSUPPORT
485 # define EAFNOSUPPORT -1
486 #endif
487 CND(EAFNOSUPPORT, "Addr family not supported")
488 
489 #ifndef EALREADY
490 # define EALREADY -1
491 #endif
492 CND(EALREADY, "Operation in progress")
493 
494 #ifndef EBADF
495 # define EBADF -1
496 #endif
497 CND(EBADF, "Bad file descriptor")
498 
499 #ifndef ECONNABORTED
500 # define ECONNABORTED -1
501 #endif
502 CND(ECONNABORTED, "Connection aborted")
503 
504 #ifndef ECONNREFUSED
505 # define ECONNREFUSED -1
506 #endif
507 CND(ECONNREFUSED, "Connection refused")
508 
509 #ifndef ECONNRESET
510 # define ECONNRESET -1
511 #endif
512 CND(ECONNRESET, "Connection reset by peer")
513 
514 #ifndef EDESTADDRREQ
515 # define EDESTADDRREQ -1
516 #endif
517 CND(EDESTADDRREQ, "Destination addr required")
518 
519 #ifndef EFAULT
520 # define EFAULT -1
521 #endif
522 CND(EFAULT, "Bad address")
523 
524 #ifndef EHOSTDOWN
525 # define EHOSTDOWN -1
526 #endif
527 CND(EHOSTDOWN, "Host is down")
528 
529 #ifndef EHOSTUNREACH
530 # define EHOSTUNREACH -1
531 #endif
532 CND(EHOSTUNREACH, "No route to host")
533 
534 #ifndef EINPROGRESS
535 # define EINPROGRESS -1
536 #endif
537 CND(EINPROGRESS, "Operation now in progress")
538 
539 #ifndef EINTR
540 # define EINTR -1
541 #endif
542 CND(EINTR, "Interrupted system call")
543 
544 #ifndef EINVAL
545 # define EINVAL -1
546 #endif
547 CND(EINVAL, "Invalid argument")
548 
549 #ifndef EIO
550 # define EIO -1
551 #endif
552 CND(EIO, "Input output error")
553 
554 #ifndef EISCONN
555 # define EISCONN -1
556 #endif
557 CND(EISCONN, "Socket already connected")
558 
559 #ifndef ELOOP
560 # define ELOOP -1
561 #endif
562 CND(ELOOP, "Too many symbolic links")
563 
564 #ifndef EMFILE
565 # define EMFILE -1
566 #endif
567 CND(EMFILE, "Too many open files")
568 
569 #ifndef EMSGSIZE
570 # define EMSGSIZE -1
571 #endif
572 CND(EMSGSIZE, "Message too long")
573 
574 #ifndef ENAMETOOLONG
575 # define ENAMETOOLONG -1
576 #endif
577 CND(ENAMETOOLONG, "Name too long")
578 
579 #ifndef ENETDOWN
580 # define ENETDOWN -1
581 #endif
582 CND(ENETDOWN, "Network is down")
583 
584 #ifndef ENETRESET
585 # define ENETRESET -1
586 #endif
587 CND(ENETRESET, "Disconn. on network reset")
588 
589 #ifndef ENETUNREACH
590 # define ENETUNREACH -1
591 #endif
592 CND(ENETUNREACH, "Network is unreachable")
593 
594 #ifndef ENOBUFS
595 # define ENOBUFS -1
596 #endif
597 CND(ENOBUFS, "No buffer space available")
598 
599 #ifndef ENOPROTOOPT
600 # define ENOPROTOOPT -1
601 #endif
602 CND(ENOPROTOOPT, "Protocol not available")
603 
604 #ifndef ENOTCONN
605 # define ENOTCONN -1
606 #endif
607 CND(ENOTCONN, "Socket not connected")
608 
609 #ifndef ENOTSOCK
610 # define ENOTSOCK -1
611 #endif
612 CND(ENOTSOCK, "Operation on non socket")
613 
614 #ifndef EOPNOTSUPP
615 # define EOPNOTSUPP -1
616 #endif
617 CND(EOPNOTSUPP, "Operation not supported")
618 
619 #ifndef EPIPE
620 # define EPIPE -1
621 #endif
622 CND(EPIPE, "Broken pipe")
623 
624 #ifndef EPFNOSUPPORT
625 # define EPFNOSUPPORT -1
626 #endif
627 CND(EPFNOSUPPORT, "Unknown protocol family")
628 
629 #ifndef EPROTONOSUPPORT
630 # define EPROTONOSUPPORT -1
631 #endif
632 CND(EPROTONOSUPPORT, "Unknown protocol")
633 
634 #ifndef EPROTOTYPE
635 # define EPROTOTYPE -1
636 #endif
637 CND(EPROTOTYPE, "Unknown protocol type")
638 
639 #ifndef ERANGE
640 # define ERANGE -1
641 #endif
642 CND(ERANGE, "Result too large")
643 
644 #ifndef ESHUTDOWN
645 # define ESHUTDOWN -1
646 #endif
647 CND(ESHUTDOWN, "Cannot send once shutdown")
648 
649 #ifndef ESOCKTNOSUPPORT
650 # define ESOCKTNOSUPPORT -1
651 #endif
652 CND(ESOCKTNOSUPPORT, "Socket type not supported")
653 
654 #ifndef ETIMEDOUT
655 # define ETIMEDOUT -1
656 #endif
657 CND(ETIMEDOUT, "Connection timed out")
658 
659 #ifndef ETOOMANYREFS
660 # define ETOOMANYREFS -1
661 #endif
662 CND(ETOOMANYREFS, "Too many references")
663 
664 #ifndef EWOULDBLOCK
665 # define EWOULDBLOCK -1
666 #endif
667 CND(EWOULDBLOCK, "Operation would block")
668 
669 #ifndef E2BIG
670 # define E2BIG -1
671 #endif
672 CND(E2BIG, "Argument list too long")
673 
674 #ifndef EILSEQ
675 # define EILSEQ -1
676 #endif
677 CND(EILSEQ, "Illegal byte sequence")
678 
679 /**
680  **  Terminal/serial I/O constants
681  **/
682 
683 #if defined(HAVE_TERMIOS) || defined(__MINGW32__)
684 /*
685 
686    ----------------------
687    -- Terminal control --
688    ----------------------
689 
690 */
691 #endif
692 
693 #ifdef HAVE_TERMIOS
694 
695 #ifndef TCSANOW
696 # define TCSANOW -1
697 #endif
698 CND(TCSANOW, "Immediate")
699 
700 #ifndef TCIFLUSH
701 # define TCIFLUSH -1
702 #endif
703 CND(TCIFLUSH, "Flush input")
704 
705 #ifndef IXON
706 # define IXON -1
707 #endif
708 CNU(IXON, "Output sw flow control")
709 
710 #ifndef CLOCAL
711 # define CLOCAL -1
712 #endif
713 CNU(CLOCAL, "Local")
714 
715 #ifndef CRTSCTS
716 # define CRTSCTS -1
717 #endif
718 CNU(CRTSCTS, "Output hw flow control")
719 
720 #ifndef CREAD
721 # define CREAD -1
722 #endif
723 CNU(CREAD, "Read")
724 
725 #ifndef CS5
726 # define CS5 -1
727 #endif
728 CNU(CS5, "5 data bits")
729 
730 #ifndef CS6
731 # define CS6 -1
732 #endif
733 CNU(CS6, "6 data bits")
734 
735 #ifndef CS7
736 # define CS7 -1
737 #endif
738 CNU(CS7, "7 data bits")
739 
740 #ifndef CS8
741 # define CS8 -1
742 #endif
743 CNU(CS8, "8 data bits")
744 
745 #ifndef CSTOPB
746 # define CSTOPB -1
747 #endif
748 CNU(CSTOPB, "2 stop bits")
749 
750 #ifndef PARENB
751 # define PARENB -1
752 #endif
753 CNU(PARENB, "Parity enable")
754 
755 #ifndef PARODD
756 # define PARODD -1
757 #endif
758 CNU(PARODD, "Parity odd")
759 
760 #ifndef B0
761 # define B0 -1
762 #endif
763 CNU(B0, "0 bps")
764 
765 #ifndef B50
766 # define B50 -1
767 #endif
768 CNU(B50, "50 bps")
769 
770 #ifndef B75
771 # define B75 -1
772 #endif
773 CNU(B75, "75 bps")
774 
775 #ifndef B110
776 # define B110 -1
777 #endif
778 CNU(B110, "110 bps")
779 
780 #ifndef B134
781 # define B134 -1
782 #endif
783 CNU(B134, "134 bps")
784 
785 #ifndef B150
786 # define B150 -1
787 #endif
788 CNU(B150, "150 bps")
789 
790 #ifndef B200
791 # define B200 -1
792 #endif
793 CNU(B200, "200 bps")
794 
795 #ifndef B300
796 # define B300 -1
797 #endif
798 CNU(B300, "300 bps")
799 
800 #ifndef B600
801 # define B600 -1
802 #endif
803 CNU(B600, "600 bps")
804 
805 #ifndef B1200
806 # define B1200 -1
807 #endif
808 CNU(B1200, "1200 bps")
809 
810 #ifndef B1800
811 # define B1800 -1
812 #endif
813 CNU(B1800, "1800 bps")
814 
815 #ifndef B2400
816 # define B2400 -1
817 #endif
818 CNU(B2400, "2400 bps")
819 
820 #ifndef B4800
821 # define B4800 -1
822 #endif
823 CNU(B4800, "4800 bps")
824 
825 #ifndef B9600
826 # define B9600 -1
827 #endif
828 CNU(B9600, "9600 bps")
829 
830 #ifndef B19200
831 # define B19200 -1
832 #endif
833 CNU(B19200, "19200 bps")
834 
835 #ifndef B38400
836 # define B38400 -1
837 #endif
838 CNU(B38400, "38400 bps")
839 
840 #ifndef B57600
841 # define B57600 -1
842 #endif
843 CNU(B57600, "57600 bps")
844 
845 #ifndef B115200
846 # define B115200 -1
847 #endif
848 CNU(B115200, "115200 bps")
849 
850 #ifndef B230400
851 # define B230400 -1
852 #endif
853 CNU(B230400, "230400 bps")
854 
855 #ifndef B460800
856 # define B460800 -1
857 #endif
858 CNU(B460800, "460800 bps")
859 
860 #ifndef B500000
861 # define B500000 -1
862 #endif
863 CNU(B500000, "500000 bps")
864 
865 #ifndef B576000
866 # define B576000 -1
867 #endif
868 CNU(B576000, "576000 bps")
869 
870 #ifndef B921600
871 # define B921600 -1
872 #endif
873 CNU(B921600, "921600 bps")
874 
875 #ifndef B1000000
876 # define B1000000 -1
877 #endif
878 CNU(B1000000, "1000000 bps")
879 
880 #ifndef B1152000
881 # define B1152000 -1
882 #endif
883 CNU(B1152000, "1152000 bps")
884 
885 #ifndef B1500000
886 # define B1500000 -1
887 #endif
888 CNU(B1500000, "1500000 bps")
889 
890 #ifndef B2000000
891 # define B2000000 -1
892 #endif
893 CNU(B2000000, "2000000 bps")
894 
895 #ifndef B2500000
896 # define B2500000 -1
897 #endif
898 CNU(B2500000, "2500000 bps")
899 
900 #ifndef B3000000
901 # define B3000000 -1
902 #endif
903 CNU(B3000000, "3000000 bps")
904 
905 #ifndef B3500000
906 # define B3500000 -1
907 #endif
908 CNU(B3500000, "3500000 bps")
909 
910 #ifndef B4000000
911 # define B4000000 -1
912 #endif
913 CNU(B4000000, "4000000 bps")
914 
915 /*
916 
917    ---------------------------------
918    -- Terminal control characters --
919    ---------------------------------
920 
921 */
922 
923 #ifndef VINTR
924 # define VINTR -1
925 #endif
926 CND(VINTR, "Interrupt")
927 
928 #ifndef VQUIT
929 # define VQUIT -1
930 #endif
931 CND(VQUIT, "Quit")
932 
933 #ifndef VERASE
934 # define VERASE -1
935 #endif
936 CND(VERASE, "Erase")
937 
938 #ifndef VKILL
939 # define VKILL -1
940 #endif
941 CND(VKILL, "Kill")
942 
943 #ifndef VEOF
944 # define VEOF -1
945 #endif
946 CND(VEOF, "EOF")
947 
948 #ifndef VTIME
949 # define VTIME -1
950 #endif
951 CND(VTIME, "Read timeout")
952 
953 #ifndef VMIN
954 # define VMIN -1
955 #endif
956 CND(VMIN, "Read min chars")
957 
958 #ifndef VSWTC
959 # define VSWTC -1
960 #endif
961 CND(VSWTC, "Switch")
962 
963 #ifndef VSTART
964 # define VSTART -1
965 #endif
966 CND(VSTART, "Flow control start")
967 
968 #ifndef VSTOP
969 # define VSTOP -1
970 #endif
971 CND(VSTOP, "Flow control stop")
972 
973 #ifndef VSUSP
974 # define VSUSP -1
975 #endif
976 CND(VSUSP, "Suspend")
977 
978 #ifndef VEOL
979 # define VEOL -1
980 #endif
981 CND(VEOL, "EOL")
982 
983 #ifndef VREPRINT
984 # define VREPRINT -1
985 #endif
986 CND(VREPRINT, "Reprint unread")
987 
988 #ifndef VDISCARD
989 # define VDISCARD -1
990 #endif
991 CND(VDISCARD, "Discard pending")
992 
993 #ifndef VWERASE
994 # define VWERASE -1
995 #endif
996 CND(VWERASE, "Word erase")
997 
998 #ifndef VLNEXT
999 # define VLNEXT -1
1000 #endif
1001 CND(VLNEXT, "Literal next")
1002 
1003 #ifndef VEOL2
1004 # define VEOL2 -1
1005 #endif
1006 CND(VEOL2, "Alternative EOL")
1007 
1008 #endif /* HAVE_TERMIOS */
1009 
1010 #if defined(__MINGW32__) || defined(__CYGWIN__)
1011 CNU(DTR_CONTROL_ENABLE, "Enable DTR flow ctrl")
1012 CNU(RTS_CONTROL_ENABLE, "Enable RTS flow ctrl")
1013 #endif
1014 
1015 /*
1016 
1017    -----------------------------
1018    -- Pseudo terminal library --
1019    -----------------------------
1020 
1021 */
1022 
1023 #if defined (__FreeBSD__) || defined (__linux__) || defined (__DragonFly__)
1024 # define PTY_Library "-lutil"
1025 #else
1026 # define PTY_Library ""
1027 #endif
1028 CST(PTY_Library, "for g-exptty")
1029 
1030 /**
1031  **  Sockets constants
1032  **/
1033 
1034 #ifdef HAVE_SOCKETS
1035 
1036 /*
1037 
1038    --------------
1039    -- Families --
1040    --------------
1041 
1042 */
1043 
1044 #ifndef AF_INET
1045 # define AF_INET -1
1046 #endif
1047 CND(AF_INET, "IPv4 address family")
1048 
1049 #ifndef AF_INET6
1050 # define AF_INET6 -1
1051 #else
1052 # define HAVE_AF_INET6 1
1053 #endif
1054 CND(AF_INET6, "IPv6 address family")
1055 
1056 #ifndef AF_UNIX
1057 # define AF_UNIX -1
1058 #endif
1059 CND(AF_UNIX, "Local unix family")
1060 
1061 #ifndef AF_UNSPEC
1062 # define AF_UNSPEC -1
1063 #else
1064 # define HAVE_AF_UNSPEC 1
1065 #endif
1066 CND(AF_UNSPEC, "Unspecified address family")
1067 
1068 /*
1069 
1070    -----------------------------
1071    -- addrinfo fields offsets --
1072    -----------------------------
1073 
1074 */
1075 
1076 #ifdef AI_CANONNAME
1077   const struct addrinfo ai;
1078 
1079 #define AI_FLAGS_OFFSET ((void *)&ai.ai_flags - (void *)&ai)
1080 #define AI_FAMILY_OFFSET ((void *)&ai.ai_family - (void *)&ai)
1081 #define AI_SOCKTYPE_OFFSET ((void *)&ai.ai_socktype - (void *)&ai)
1082 #define AI_PROTOCOL_OFFSET ((void *)&ai.ai_protocol - (void *)&ai)
1083 #define AI_ADDRLEN_OFFSET ((void *)&ai.ai_addrlen - (void *)&ai)
1084 #define AI_ADDR_OFFSET ((void *)&ai.ai_addr - (void *)&ai)
1085 #define AI_CANONNAME_OFFSET ((void *)&ai.ai_canonname - (void *)&ai)
1086 #define AI_NEXT_OFFSET ((void *)&ai.ai_next - (void *)&ai)
1087 
1088 #else
1089 
1090 #define AI_FLAGS_OFFSET 0
1091 #define AI_FAMILY_OFFSET 4
1092 #define AI_SOCKTYPE_OFFSET 8
1093 #define AI_PROTOCOL_OFFSET 12
1094 #define AI_ADDRLEN_OFFSET 16
1095 #define AI_CANONNAME_OFFSET 24
1096 #define AI_ADDR_OFFSET 32
1097 #define AI_NEXT_OFFSET 40
1098 
1099 #endif
1100 
1101 CND(AI_FLAGS_OFFSET,     "Offset of ai_flags in addrinfo");
1102 CND(AI_FAMILY_OFFSET,    "Offset of ai_family in addrinfo");
1103 CND(AI_SOCKTYPE_OFFSET,  "Offset of ai_socktype in addrinfo");
1104 CND(AI_PROTOCOL_OFFSET,  "Offset of ai_protocol in addrinfo");
1105 CND(AI_ADDRLEN_OFFSET,   "Offset of ai_addrlen in addrinfo");
1106 CND(AI_ADDR_OFFSET,      "Offset of ai_addr in addrinfo");
1107 CND(AI_CANONNAME_OFFSET, "Offset of ai_canonname in addrinfo");
1108 CND(AI_NEXT_OFFSET,      "Offset of ai_next in addrinfo");
1109 
1110 /*
1111 
1112    ---------------------------------------
1113    -- getaddrinfo getnameinfo constants --
1114    ---------------------------------------
1115 
1116 */
1117 
1118 #ifndef AI_PASSIVE
1119 # define AI_PASSIVE -1
1120 #endif
1121 CND(AI_PASSIVE, "NULL nodename for accepting")
1122 
1123 #ifndef AI_CANONNAME
1124 # define AI_CANONNAME -1
1125 #endif
1126 CND(AI_CANONNAME, "Get the host official name")
1127 
1128 #ifndef AI_NUMERICSERV
1129 # define AI_NUMERICSERV -1
1130 #endif
1131 CND(AI_NUMERICSERV, "Service is a numeric string")
1132 
1133 #ifndef AI_NUMERICHOST
1134 # define AI_NUMERICHOST -1
1135 #endif
1136 CND(AI_NUMERICHOST, "Node is a numeric IP address")
1137 
1138 #ifndef AI_ADDRCONFIG
1139 # define AI_ADDRCONFIG -1
1140 #endif
1141 CND(AI_ADDRCONFIG, "Returns addresses for only locally configured families")
1142 
1143 #ifndef AI_V4MAPPED
1144 # define AI_V4MAPPED -1
1145 #endif
1146 CND(AI_V4MAPPED, "Returns IPv4 mapped to IPv6")
1147 
1148 #ifndef AI_ALL
1149 # define AI_ALL -1
1150 #endif
1151 CND(AI_ALL, "Change AI_V4MAPPED behavior for unavailavle IPv6 addresses")
1152 
1153 #ifndef NI_NAMEREQD
1154 # define NI_NAMEREQD -1
1155 #endif
1156 CND(NI_NAMEREQD, "Error if the hostname cannot be determined")
1157 
1158 #ifndef NI_DGRAM
1159 # define NI_DGRAM -1
1160 #endif
1161 CND(NI_DGRAM, "Service is datagram")
1162 
1163 #ifndef NI_NOFQDN
1164 # define NI_NOFQDN -1
1165 #endif
1166 CND(NI_NOFQDN, "Return only the hostname part for local hosts")
1167 
1168 #ifndef NI_NUMERICSERV
1169 # define NI_NUMERICSERV -1
1170 #endif
1171 CND(NI_NUMERICSERV, "Numeric form of the service")
1172 
1173 #ifndef NI_NUMERICHOST
1174 # define NI_NUMERICHOST -1
1175 #endif
1176 CND(NI_NUMERICHOST, "Numeric form of the hostname")
1177 
1178 #ifndef NI_MAXHOST
1179 # define NI_MAXHOST -1
1180 #endif
1181 CND(NI_MAXHOST, "Maximum size of hostname")
1182 
1183 #ifndef NI_MAXSERV
1184 # define NI_MAXSERV -1
1185 #endif
1186 CND(NI_MAXSERV, "Maximum size of service name")
1187 
1188 #ifndef EAI_SYSTEM
1189 # define EAI_SYSTEM -1
1190 #endif
1191 CND(EAI_SYSTEM, "Check errno for details")
1192 
1193 /*
1194 
1195    ------------------
1196    -- Socket modes --
1197    ------------------
1198 
1199 */
1200 
1201 #ifndef SOCK_STREAM
1202 # define SOCK_STREAM -1
1203 #endif
1204 CND(SOCK_STREAM, "Stream socket")
1205 
1206 #ifndef SOCK_DGRAM
1207 # define SOCK_DGRAM -1
1208 #endif
1209 CND(SOCK_DGRAM, "Datagram socket")
1210 
1211 #ifndef SOCK_RAW
1212 # define SOCK_RAW -1
1213 #endif
1214 CND(SOCK_RAW, "Raw socket")
1215 
1216 /*
1217 
1218    -----------------
1219    -- Host errors --
1220    -----------------
1221 
1222 */
1223 
1224 #ifndef HOST_NOT_FOUND
1225 # define HOST_NOT_FOUND -1
1226 #endif
1227 CND(HOST_NOT_FOUND, "Unknown host")
1228 
1229 #ifndef TRY_AGAIN
1230 # define TRY_AGAIN -1
1231 #endif
1232 CND(TRY_AGAIN, "Host name lookup failure")
1233 
1234 #ifndef NO_DATA
1235 # define NO_DATA -1
1236 #endif
1237 CND(NO_DATA, "No data record for name")
1238 
1239 #ifndef NO_RECOVERY
1240 # define NO_RECOVERY -1
1241 #endif
1242 CND(NO_RECOVERY, "Non recoverable errors")
1243 
1244 /*
1245 
1246    --------------------
1247    -- Shutdown modes --
1248    --------------------
1249 
1250 */
1251 
1252 #ifndef SHUT_RD
1253 # define SHUT_RD -1
1254 #endif
1255 CND(SHUT_RD, "No more recv")
1256 
1257 #ifndef SHUT_WR
1258 # define SHUT_WR -1
1259 #endif
1260 CND(SHUT_WR, "No more send")
1261 
1262 #ifndef SHUT_RDWR
1263 # define SHUT_RDWR -1
1264 #endif
1265 CND(SHUT_RDWR, "No more recv/send")
1266 
1267 /*
1268 
1269    ---------------------
1270    -- Protocol levels --
1271    ---------------------
1272 
1273 */
1274 
1275 #ifndef SOL_SOCKET
1276 # define SOL_SOCKET -1
1277 #endif
1278 CND(SOL_SOCKET, "Options for socket level")
1279 
1280 #ifndef IPPROTO_IP
1281 # define IPPROTO_IP -1
1282 #endif
1283 CND(IPPROTO_IP, "Dummy protocol for IP")
1284 
1285 #ifndef IPPROTO_IPV6
1286 # define IPPROTO_IPV6 -1
1287 #endif
1288 CND(IPPROTO_IPV6, "IPv6 socket option level")
1289 
1290 #ifndef IPPROTO_UDP
1291 # define IPPROTO_UDP -1
1292 #endif
1293 CND(IPPROTO_UDP, "UDP")
1294 
1295 #ifndef IPPROTO_TCP
1296 # define IPPROTO_TCP -1
1297 #endif
1298 CND(IPPROTO_TCP, "TCP")
1299 
1300 #ifndef IPPROTO_ICMP
1301 # define IPPROTO_ICMP -1
1302 #endif
1303 CND(IPPROTO_ICMP, "Internet Control Message Protocol")
1304 
1305 #ifndef IPPROTO_IGMP
1306 # define IPPROTO_IGMP -1
1307 #endif
1308 CND(IPPROTO_IGMP, "Internet Group Management Protocol")
1309 
1310 #ifndef IPPROTO_IPIP
1311 # define IPPROTO_IPIP -1
1312 #endif
1313 CND(IPPROTO_IPIP, "IPIP tunnels (older KA9Q tunnels use 94)")
1314 
1315 #ifndef IPPROTO_EGP
1316 # define IPPROTO_EGP -1
1317 #endif
1318 CND(IPPROTO_EGP, "Exterior Gateway Protocol")
1319 
1320 #ifndef IPPROTO_PUP
1321 # define IPPROTO_PUP -1
1322 #endif
1323 CND(IPPROTO_PUP, "PUP protocol")
1324 
1325 #ifndef IPPROTO_IDP
1326 # define IPPROTO_IDP -1
1327 #endif
1328 CND(IPPROTO_IDP, "XNS IDP protocol")
1329 
1330 #ifndef IPPROTO_TP
1331 # define IPPROTO_TP -1
1332 #endif
1333 CND(IPPROTO_TP, "SO Transport Protocol Class 4")
1334 
1335 #ifndef IPPROTO_DCCP
1336 # define IPPROTO_DCCP -1
1337 #endif
1338 CND(IPPROTO_DCCP, "Datagram Congestion Control Protocol")
1339 
1340 #ifndef IPPROTO_RSVP
1341 # define IPPROTO_RSVP -1
1342 #endif
1343 CND(IPPROTO_RSVP, "Reservation Protocol")
1344 
1345 #ifndef IPPROTO_GRE
1346 # define IPPROTO_GRE -1
1347 #endif
1348 CND(IPPROTO_GRE, "General Routing Encapsulation")
1349 
1350 #ifndef IPPROTO_ESP
1351 # define IPPROTO_ESP -1
1352 #endif
1353 CND(IPPROTO_ESP, "encapsulating security payload")
1354 
1355 #ifndef IPPROTO_AH
1356 # define IPPROTO_AH -1
1357 #endif
1358 CND(IPPROTO_AH, "authentication header")
1359 
1360 #ifndef IPPROTO_MTP
1361 # define IPPROTO_MTP -1
1362 #endif
1363 CND(IPPROTO_MTP, "Multicast Transport Protocol")
1364 
1365 #ifndef IPPROTO_BEETPH
1366 # define IPPROTO_BEETPH -1
1367 #endif
1368 CND(IPPROTO_BEETPH, "IP option pseudo header for BEET")
1369 
1370 #ifndef IPPROTO_ENCAP
1371 # define IPPROTO_ENCAP -1
1372 #endif
1373 CND(IPPROTO_ENCAP, "Encapsulation Header")
1374 
1375 #ifndef IPPROTO_PIM
1376 # define IPPROTO_PIM -1
1377 #endif
1378 CND(IPPROTO_PIM, "Protocol Independent Multicast")
1379 
1380 #ifndef IPPROTO_COMP
1381 # define IPPROTO_COMP -1
1382 #endif
1383 CND(IPPROTO_COMP, "Compression Header Protocol")
1384 
1385 #ifndef IPPROTO_SCTP
1386 # define IPPROTO_SCTP -1
1387 #endif
1388 CND(IPPROTO_SCTP, "Stream Control Transmission Protocol")
1389 
1390 #ifndef IPPROTO_UDPLITE
1391 # define IPPROTO_UDPLITE -1
1392 #endif
1393 CND(IPPROTO_UDPLITE, "UDP-Lite protocol")
1394 
1395 #ifndef IPPROTO_MPLS
1396 # define IPPROTO_MPLS -1
1397 #endif
1398 CND(IPPROTO_MPLS, "MPLS in IP")
1399 
1400 #ifndef IPPROTO_RAW
1401 # define IPPROTO_RAW -1
1402 #endif
1403 CND(IPPROTO_RAW, "Raw IP packets")
1404 
1405 /*
1406 
1407    -------------------
1408    -- Request flags --
1409    -------------------
1410 
1411 */
1412 
1413 #ifndef MSG_OOB
1414 # define MSG_OOB -1
1415 #endif
1416 CND(MSG_OOB, "Process out-of-band data")
1417 
1418 #ifndef MSG_PEEK
1419 # define MSG_PEEK -1
1420 #endif
1421 CND(MSG_PEEK, "Peek at incoming data")
1422 
1423 #ifndef MSG_EOR
1424 # define MSG_EOR -1
1425 #endif
1426 CND(MSG_EOR, "Send end of record")
1427 
1428 #ifndef MSG_WAITALL
1429 #ifdef __MINWGW32__
1430 /* The value of MSG_WAITALL is 8.  Nevertheless winsock.h doesn't
1431    define it, but it is still usable as we link to winsock2 API.  */
1432 # define MSG_WAITALL (1 << 3)
1433 #else
1434 # define MSG_WAITALL -1
1435 #endif
1436 #endif
1437 CND(MSG_WAITALL, "Wait for full reception")
1438 
1439 #ifndef MSG_NOSIGNAL
1440 # define MSG_NOSIGNAL -1
1441 #endif
1442 CND(MSG_NOSIGNAL, "No SIGPIPE on send")
1443 
1444 #if defined (__linux__) || defined (__ANDROID__) || defined (__QNX__)
1445 # define MSG_Forced_Flags "MSG_NOSIGNAL"
1446 #else
1447 # define MSG_Forced_Flags "0"
1448 #endif
1449 CNS(MSG_Forced_Flags, "")
1450 /*
1451    --  Flags set on all send(2) calls
1452 */
1453 
1454 /*
1455 
1456    --------------------
1457    -- Socket options --
1458    --------------------
1459 
1460 */
1461 
1462 #ifndef TCP_NODELAY
1463 # define TCP_NODELAY -1
1464 #endif
1465 CND(TCP_NODELAY, "Do not coalesce packets")
1466 
1467 #ifndef SO_REUSEADDR
1468 # define SO_REUSEADDR -1
1469 #endif
1470 CND(SO_REUSEADDR, "Bind reuse local address")
1471 
1472 #ifndef SO_REUSEPORT
1473 # define SO_REUSEPORT -1
1474 #endif
1475 CND(SO_REUSEPORT, "Bind reuse port number")
1476 
1477 #ifndef SO_KEEPALIVE
1478 # define SO_KEEPALIVE -1
1479 #endif
1480 CND(SO_KEEPALIVE, "Enable keep-alive msgs")
1481 
1482 #ifndef SO_LINGER
1483 # define SO_LINGER -1
1484 #endif
1485 CND(SO_LINGER, "Defer close to flush data")
1486 
1487 #ifndef SO_BROADCAST
1488 # define SO_BROADCAST -1
1489 #endif
1490 CND(SO_BROADCAST, "Can send broadcast msgs")
1491 
1492 #ifndef SO_SNDBUF
1493 # define SO_SNDBUF -1
1494 #endif
1495 CND(SO_SNDBUF, "Set/get send buffer size")
1496 
1497 #ifndef SO_RCVBUF
1498 # define SO_RCVBUF -1
1499 #endif
1500 CND(SO_RCVBUF, "Set/get recv buffer size")
1501 
1502 #ifndef SO_SNDTIMEO
1503 # define SO_SNDTIMEO -1
1504 #endif
1505 CND(SO_SNDTIMEO, "Emission timeout")
1506 
1507 #ifndef SO_RCVTIMEO
1508 # define SO_RCVTIMEO -1
1509 #endif
1510 CND(SO_RCVTIMEO, "Reception timeout")
1511 
1512 #ifndef SO_ERROR
1513 # define SO_ERROR -1
1514 #endif
1515 CND(SO_ERROR, "Get/clear error status")
1516 
1517 #ifndef SO_BUSY_POLL
1518 # define SO_BUSY_POLL -1
1519 #endif
1520 CND(SO_BUSY_POLL, "Busy polling")
1521 
1522 #ifndef IP_MULTICAST_IF
1523 # define IP_MULTICAST_IF -1
1524 #endif
1525 CND(IP_MULTICAST_IF, "Set/get mcast interface")
1526 
1527 #ifndef IP_MULTICAST_TTL
1528 # define IP_MULTICAST_TTL -1
1529 #endif
1530 CND(IP_MULTICAST_TTL, "Set/get multicast TTL")
1531 
1532 #ifndef IP_MULTICAST_LOOP
1533 # define IP_MULTICAST_LOOP -1
1534 #endif
1535 CND(IP_MULTICAST_LOOP, "Set/get mcast loopback")
1536 
1537 #ifndef IP_ADD_MEMBERSHIP
1538 # define IP_ADD_MEMBERSHIP -1
1539 #endif
1540 CND(IP_ADD_MEMBERSHIP, "Join a multicast group")
1541 
1542 #ifndef IP_DROP_MEMBERSHIP
1543 # define IP_DROP_MEMBERSHIP -1
1544 #endif
1545 CND(IP_DROP_MEMBERSHIP, "Leave a multicast group")
1546 
1547 #ifndef IP_PKTINFO
1548 # define IP_PKTINFO -1
1549 #endif
1550 CND(IP_PKTINFO, "Get datagram info")
1551 
1552 #ifndef IP_RECVERR
1553 # define IP_RECVERR -1
1554 #endif
1555 CND(IP_RECVERR, "Extended reliable error message passing")
1556 
1557 #ifndef IPV6_ADDRFORM
1558 # define IPV6_ADDRFORM -1
1559 #endif
1560 CND(IPV6_ADDRFORM, "Turn IPv6 socket into different address family")
1561 
1562 #ifndef IPV6_ADD_MEMBERSHIP
1563 # define IPV6_ADD_MEMBERSHIP -1
1564 #endif
1565 CND(IPV6_ADD_MEMBERSHIP, "Join IPv6 multicast group")
1566 
1567 #ifndef IPV6_DROP_MEMBERSHIP
1568 # define IPV6_DROP_MEMBERSHIP -1
1569 #endif
1570 CND(IPV6_DROP_MEMBERSHIP, "Leave IPv6 multicast group")
1571 
1572 #ifndef IPV6_MTU
1573 # define IPV6_MTU -1
1574 #endif
1575 CND(IPV6_MTU, "Set/get MTU used for the socket")
1576 
1577 #ifndef IPV6_MTU_DISCOVER
1578 # define IPV6_MTU_DISCOVER -1
1579 #endif
1580 CND(IPV6_MTU_DISCOVER, "Control path-MTU discovery on the socket")
1581 
1582 #ifndef IPV6_MULTICAST_HOPS
1583 # define IPV6_MULTICAST_HOPS -1
1584 #endif
1585 CND(IPV6_MULTICAST_HOPS, "Set the multicast hop limit for the socket")
1586 
1587 #ifndef IPV6_MULTICAST_IF
1588 # define IPV6_MULTICAST_IF -1
1589 #endif
1590 CND(IPV6_MULTICAST_IF, "Set/get IPv6 mcast interface")
1591 
1592 #ifndef IPV6_MULTICAST_LOOP
1593 # define IPV6_MULTICAST_LOOP -1
1594 #endif
1595 CND(IPV6_MULTICAST_LOOP, "Set/get mcast loopback")
1596 
1597 #ifndef IPV6_RECVPKTINFO
1598 # define IPV6_RECVPKTINFO -1
1599 #endif
1600 CND(IPV6_RECVPKTINFO, "Set delivery of the IPV6_PKTINFO")
1601 
1602 #ifndef IPV6_PKTINFO
1603 # define IPV6_PKTINFO -1
1604 #endif
1605 CND(IPV6_PKTINFO, "Get IPv6datagram info")
1606 
1607 #ifndef IPV6_RTHDR
1608 # define IPV6_RTHDR -1
1609 #endif
1610 CND(IPV6_RTHDR, "Set the routing header delivery")
1611 
1612 #ifndef IPV6_AUTHHDR
1613 # define IPV6_AUTHHDR -1
1614 #endif
1615 CND(IPV6_AUTHHDR, "Set the authentication header delivery")
1616 
1617 #ifndef IPV6_DSTOPTS
1618 # define IPV6_DSTOPTS -1
1619 #endif
1620 CND(IPV6_DSTOPTS, "Set the destination options delivery")
1621 
1622 #ifndef IPV6_HOPOPTS
1623 # define IPV6_HOPOPTS -1
1624 #endif
1625 CND(IPV6_HOPOPTS, "Set the hop options delivery")
1626 
1627 #ifndef IPV6_FLOWINFO
1628 # define IPV6_FLOWINFO -1
1629 #endif
1630 CND(IPV6_FLOWINFO, "Set the flow ID delivery")
1631 
1632 #ifndef IPV6_HOPLIMIT
1633 # define IPV6_HOPLIMIT -1
1634 #endif
1635 CND(IPV6_HOPLIMIT, "Set the hop count of the packet delivery")
1636 
1637 #ifndef IPV6_RECVERR
1638 # define IPV6_RECVERR -1
1639 #endif
1640 CND(IPV6_RECVERR, "Extended reliable error message passing")
1641 
1642 #ifndef IPV6_ROUTER_ALERT
1643 # define IPV6_ROUTER_ALERT -1
1644 #endif
1645 CND(IPV6_ROUTER_ALERT, "Pass forwarded router alert hop-by-hop option")
1646 
1647 #ifndef IPV6_UNICAST_HOPS
1648 # define IPV6_UNICAST_HOPS -1
1649 #endif
1650 CND(IPV6_UNICAST_HOPS, "Set the unicast hop limit")
1651 
1652 #ifndef IPV6_V6ONLY
1653 # define IPV6_V6ONLY -1
1654 #endif
1655 CND(IPV6_V6ONLY, "Restricted to IPv6 communications only")
1656 
1657 /*
1658 
1659    ----------------------
1660    -- Type definitions --
1661    ----------------------
1662 
1663 */
1664 
1665 {
1666   struct timeval tv;
1667 /*
1668    --  Sizes (in bytes) of the components of struct timeval
1669 */
1670 #define SIZEOF_tv_sec (sizeof tv.tv_sec)
1671 CND(SIZEOF_tv_sec, "tv_sec")
1672 #define SIZEOF_tv_usec (sizeof tv.tv_usec)
1673 CND(SIZEOF_tv_usec, "tv_usec")
1674 /*
1675 
1676    --  Maximum allowed value for tv_sec
1677 */
1678 
1679 /**
1680  ** On Solaris, field tv_sec in struct timeval has an undocumented
1681  ** hard-wired limit of 100 million.
1682  ** On IA64 HP-UX the limit is 2**31 - 1.
1683  **/
1684 #if defined (__sun__)
1685 # define MAX_tv_sec "100_000_000"
1686 
1687 #elif defined (__hpux__)
1688 # define MAX_tv_sec "16#7fffffff#"
1689 
1690 #else
1691 # define MAX_tv_sec "2 ** (SIZEOF_tv_sec * 8 - 1) - 1"
1692 #endif
1693 CNS(MAX_tv_sec, "")
1694 }
1695 /*
1696 
1697    --  Sizes of various data types
1698 */
1699 
1700 #define SIZEOF_sockaddr_in (sizeof (struct sockaddr_in))
1701 CND(SIZEOF_sockaddr_in, "struct sockaddr_in")
1702 #ifdef HAVE_AF_INET6
1703 # define SIZEOF_sockaddr_in6 (sizeof (struct sockaddr_in6))
1704 #else
1705 # define SIZEOF_sockaddr_in6 0
1706 #endif
1707 CND(SIZEOF_sockaddr_in6, "struct sockaddr_in6")
1708 
1709 /**
1710  ** The sockaddr_un structure is not defined in MINGW C headers
1711  ** but Windows supports it from build 17063.
1712  **/
1713 #if defined(__MINGW32__)
1714 struct sockaddr_un {
1715   ADDRESS_FAMILY sun_family;    /* AF_UNIX */
1716   char           sun_path[108]; /* Pathname */
1717 };
1718 #endif
1719 #define SIZEOF_sockaddr_un (sizeof (struct sockaddr_un))
1720 CND(SIZEOF_sockaddr_un, "struct sockaddr_un")
1721 
1722 #define SIZEOF_fd_set (sizeof (fd_set))
1723 CND(SIZEOF_fd_set, "fd_set")
1724 CND(FD_SETSIZE, "Max fd value")
1725 
1726 #define SIZEOF_struct_hostent (sizeof (struct hostent))
1727 CND(SIZEOF_struct_hostent, "struct hostent")
1728 
1729 #define SIZEOF_struct_servent (sizeof (struct servent))
1730 CND(SIZEOF_struct_servent, "struct servent")
1731 
1732 #if defined (__linux__) || defined (__ANDROID__) || defined (__QNX__)
1733 #define SIZEOF_sigset (sizeof (sigset_t))
1734 CND(SIZEOF_sigset, "sigset")
1735 #endif
1736 
1737 #if defined(_WIN32) || defined(__vxworks)
1738 #define SIZEOF_socklen_t sizeof (size_t)
1739 #else
1740 #define SIZEOF_socklen_t sizeof (socklen_t)
1741 #endif
1742 CND(SIZEOF_socklen_t, "Size of socklen_t");
1743 
1744 #ifndef IF_NAMESIZE
1745 #ifdef IF_MAX_STRING_SIZE
1746 #define IF_NAMESIZE IF_MAX_STRING_SIZE
1747 #else
1748 #define IF_NAMESIZE -1
1749 #endif
1750 #endif
1751 CND(IF_NAMESIZE, "Max size of interface name with 0 terminator");
1752 
1753 /*
1754 
1755    --  Fields of struct msghdr
1756 */
1757 
1758 #if defined (__sun__) || defined (__hpux__)
1759 # define Msg_Iovlen_T "Interfaces.C.int"
1760 #else
1761 # define Msg_Iovlen_T "Interfaces.C.size_t"
1762 #endif
1763 
1764 SUB(Msg_Iovlen_T)
1765 
1766 /*
1767 
1768    ----------------------------------------
1769    -- Properties of supported interfaces --
1770    ----------------------------------------
1771 
1772 */
1773 
1774 CND(Need_Netdb_Buffer, "Need buffer for Netdb ops")
1775 CND(Need_Netdb_Lock,   "Need lock for Netdb ops")
1776 CND(Has_Sockaddr_Len,  "Sockaddr has sa_len field")
1777 
1778 /**
1779  ** Do not change the format of the line below without also updating the
1780  ** MaRTE Makefile.
1781  **/
1782 C("Thread_Blocking_IO", Boolean, "True", "")
1783 /*
1784    --  Set False for contexts where socket i/o are process blocking
1785 
1786 */
1787 
1788 #ifdef HAVE_INET_PTON
1789 # define Inet_Pton_Linkname "inet_pton"
1790 #else
1791 # define Inet_Pton_Linkname "__gnat_inet_pton"
1792 #endif
1793 CST(Inet_Pton_Linkname, "")
1794 
1795 #ifdef HAVE_INET_NTOP
1796 # define Inet_Ntop_Linkname "inet_ntop"
1797 #else
1798 # define Inet_Ntop_Linkname "__gnat_inet_ntop"
1799 #endif
1800 CST(Inet_Ntop_Linkname, "")
1801 
1802 #endif /* HAVE_SOCKETS */
1803 
1804 /*
1805 
1806    ---------------------
1807    -- Threads support --
1808    ---------------------
1809 
1810    --  Clock identifier definitions
1811 
1812 */
1813 
1814 /* Note: On HP-UX, CLOCK_REALTIME is an enum, not a macro. */
1815 
1816 #if !(defined(CLOCK_REALTIME) || defined (__hpux__))
1817 # define CLOCK_REALTIME (-1)
1818 #endif
1819 CND(CLOCK_REALTIME, "System realtime clock")
1820 
1821 #ifdef CLOCK_MONOTONIC
1822 CND(CLOCK_MONOTONIC, "System monotonic clock")
1823 #endif
1824 
1825 #ifdef CLOCK_FASTEST
1826 CND(CLOCK_FASTEST, "Fastest clock")
1827 #endif
1828 
1829 #ifndef CLOCK_THREAD_CPUTIME_ID
1830 # define CLOCK_THREAD_CPUTIME_ID -1
1831 #endif
1832 CND(CLOCK_THREAD_CPUTIME_ID, "Thread CPU clock")
1833 
1834 #if defined(__linux__) || defined(__FreeBSD__) \
1835  || (defined(_AIX) && defined(_AIXVERSION_530)) \
1836  || defined(__DragonFly__) || defined(__QNX__)
1837 /** On these platforms use system provided monotonic clock instead of
1838  ** the default CLOCK_REALTIME. We then need to set up cond var attributes
1839  ** appropriately (see thread.c).
1840  **
1841  ** Note that AIX 5.2 does not support CLOCK_MONOTONIC timestamps for
1842  ** pthread_cond_timedwait (and does not have pthread_condattr_setclock),
1843  ** hence the conditionalization on AIX version above). _AIXVERSION_530
1844  ** is defined in AIX 5.3 and more recent versions.
1845  **/
1846 # define CLOCK_RT_Ada "CLOCK_MONOTONIC"
1847 
1848 #else
1849 /* By default use CLOCK_REALTIME */
1850 # define CLOCK_RT_Ada "CLOCK_REALTIME"
1851 #endif
1852 
1853 #ifdef CLOCK_RT_Ada
1854 CNS(CLOCK_RT_Ada, "")
1855 #endif
1856 
1857 #if defined (__APPLE__) || defined (__linux__) || defined (__ANDROID__) \
1858   || defined (__QNX__) || defined (__rtems__) || defined (DUMMY)
1859 /*
1860 
1861    --  Sizes of pthread data types
1862 */
1863 
1864 #if defined (__APPLE__) || defined (DUMMY)
1865 /*
1866    --  (on Darwin, these are just placeholders)
1867 */
1868 #define PTHREAD_SIZE            __PTHREAD_SIZE__
1869 #define PTHREAD_ATTR_SIZE       __PTHREAD_ATTR_SIZE__
1870 #define PTHREAD_MUTEXATTR_SIZE  __PTHREAD_MUTEXATTR_SIZE__
1871 #define PTHREAD_MUTEX_SIZE      __PTHREAD_MUTEX_SIZE__
1872 #define PTHREAD_CONDATTR_SIZE   __PTHREAD_CONDATTR_SIZE__
1873 #define PTHREAD_COND_SIZE       __PTHREAD_COND_SIZE__
1874 #define PTHREAD_RWLOCKATTR_SIZE __PTHREAD_RWLOCKATTR_SIZE__
1875 #define PTHREAD_RWLOCK_SIZE     __PTHREAD_RWLOCK_SIZE__
1876 #define PTHREAD_ONCE_SIZE       __PTHREAD_ONCE_SIZE__
1877 #else
1878 #define PTHREAD_SIZE            (sizeof (pthread_t))
1879 #define PTHREAD_ATTR_SIZE       (sizeof (pthread_attr_t))
1880 #define PTHREAD_MUTEXATTR_SIZE  (sizeof (pthread_mutexattr_t))
1881 #define PTHREAD_MUTEX_SIZE      (sizeof (pthread_mutex_t))
1882 #define PTHREAD_CONDATTR_SIZE   (sizeof (pthread_condattr_t))
1883 #define PTHREAD_COND_SIZE       (sizeof (pthread_cond_t))
1884 #define PTHREAD_RWLOCKATTR_SIZE (sizeof (pthread_rwlockattr_t))
1885 #define PTHREAD_RWLOCK_SIZE     (sizeof (pthread_rwlock_t))
1886 #define PTHREAD_ONCE_SIZE       (sizeof (pthread_once_t))
1887 #endif
1888 /*
1889 
1890 */
1891 CND(PTHREAD_SIZE,            "pthread_t")
1892 CND(PTHREAD_ATTR_SIZE,       "pthread_attr_t")
1893 CND(PTHREAD_MUTEXATTR_SIZE,  "pthread_mutexattr_t")
1894 CND(PTHREAD_MUTEX_SIZE,      "pthread_mutex_t")
1895 CND(PTHREAD_CONDATTR_SIZE,   "pthread_condattr_t")
1896 CND(PTHREAD_COND_SIZE,       "pthread_cond_t")
1897 CND(PTHREAD_RWLOCKATTR_SIZE, "pthread_rwlockattr_t")
1898 CND(PTHREAD_RWLOCK_SIZE,     "pthread_rwlock_t")
1899 CND(PTHREAD_ONCE_SIZE,       "pthread_once_t")
1900 
1901 #endif /* __APPLE__ || __linux__ || __ANDROID__ || __rtems__ */
1902 
1903 /*
1904 
1905    --------------------------------
1906    -- File and directory support --
1907    --------------------------------
1908 
1909 */
1910 
1911 /**
1912  ** Note: this constant can be used in the GNAT runtime library. In compiler
1913  ** units on the other hand, System.OS_Constants is not available, so we
1914  ** declare an Ada constant (Osint.File_Attributes_Size) independently, which
1915  ** is at least as large as sizeof (struct file_attributes), and we have an
1916  ** assertion at initialization of Osint checking that the size is indeed at
1917  ** least sufficient.
1918  **/
1919 #define SIZEOF_struct_file_attributes (sizeof (struct file_attributes))
1920 CND(SIZEOF_struct_file_attributes, "struct file_attributes")
1921 
1922 /**
1923  ** Maximal size of buffer for struct dirent. Note: Since POSIX.1 does not
1924  ** specify the size of the d_name field, and other nonstandard fields may
1925  ** precede that field within the dirent structure, we must make a conservative
1926  ** computation.
1927  **/
1928 {
1929   struct dirent dent;
1930 #define SIZEOF_struct_dirent_alloc \
1931   ((char*) &dent.d_name - (char*) &dent) + NAME_MAX + 1
1932 CND(SIZEOF_struct_dirent_alloc, "struct dirent allocation")
1933 }
1934 
1935 /**
1936  **  System-specific constants follow
1937  **  Each section should be activated if compiling for the corresponding
1938  **  platform *or* generating the dummy version for runtime test compilation.
1939  **/
1940 
1941 #if defined (__vxworks) || defined (DUMMY)
1942 
1943 /*
1944 
1945    --------------------------------
1946    -- VxWorks-specific constants --
1947    --------------------------------
1948 
1949    --  These constants may be used only within the VxWorks version of
1950    --  GNAT.Sockets.Thin.
1951 */
1952 
1953 CND(OK,    "VxWorks generic success")
1954 CND(ERROR, "VxWorks generic error")
1955 
1956 #endif /* __vxworks */
1957 
1958 #if defined (__MINGW32__) || defined (DUMMY)
1959 /*
1960 
1961    ------------------------------
1962    -- MinGW-specific constants --
1963    ------------------------------
1964 
1965    --  These constants may be used only within the MinGW version of
1966    --  GNAT.Sockets.Thin.
1967 */
1968 
1969 CND(WSASYSNOTREADY,     "System not ready")
1970 CND(WSAVERNOTSUPPORTED, "Version not supported")
1971 CND(WSANOTINITIALISED,  "Winsock not initialized")
1972 CND(WSAEDISCON,         "Disconnected")
1973 
1974 #endif /* __MINGW32__ */
1975 
1976 /**
1977  ** End of constants definitions
1978  **/
1979 
1980 #ifdef NATIVE
1981    putchar ('\n');
1982 #endif
1983 
1984 /*
1985 
1986 end System.OS_Constants;
1987 */
1988 }
1989