Add assember CFI directives to millicode division and remainder routines.
[official-gcc.git] / gcc / ada / s-oscons-tmplt.c
blob5480e55a5bbdd44249d581fcba7bd93e5234c254
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-2023, 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 ------------------------------------------------------------------------------
33 pragma Style_Checks ("M32766");
34 -- Allow long lines
38 /**
39 ** This template file is used while building the GNAT runtime library to
40 ** generate package System.OS_Constants (s-oscons.ads).
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.
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.
57 ** Two methods are supported to generate the list of constant values,
58 ** s-oscons-tmpl.s.
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:
64 ** xgcc -DTARGET=\"$target\" -C -E s-oscons-tmplt.c > s-oscons-tmplt.i
65 ** xgcc -S s-oscons-tmplt.i
66 ** xoscons
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:
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 **/
81 /* Feature macro definitions */
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 **/
89 #if defined (__linux__) || defined (__ANDROID__)
91 /* Define _XOPEN_SOURCE to get IOV_MAX */
92 # if !defined (_XOPEN_SOURCE)
93 # define _XOPEN_SOURCE 500
94 # endif
96 /* Define _BSD_SOURCE to get CRTSCTS */
97 # define _BSD_SOURCE
99 #endif /* defined (__linux__) || defined (__ANDROID__) */
101 /* Include gsocket.h before any system header so it can redefine FD_SETSIZE */
103 #include "gsocket.h"
105 #include <stdlib.h>
106 #include <string.h>
107 #include <limits.h>
108 #include <fcntl.h>
109 #include <time.h>
111 #if ! (defined (__vxworks) || defined (__MINGW32__))
112 # define HAVE_TERMIOS
113 #endif
115 #if defined (__vxworks)
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.
123 # include <vxWorks.h>
124 #elif !defined(__MINGW32__)
125 #include <poll.h>
126 #endif
128 #include "adaint.h"
130 #ifdef DUMMY
132 # if defined (TARGET)
133 # error TARGET may not be defined when generating the dummy version
134 # else
135 # define TARGET "batch runtime compilation (dummy values)"
136 # endif
138 # if !(defined (HAVE_SOCKETS) && defined (HAVE_TERMIOS))
139 # error Features missing on platform
140 # endif
142 # define NATIVE
144 #endif /* DUMMY */
146 #ifndef TARGET
147 # error Please define TARGET
148 #endif
150 #ifndef HAVE_SOCKETS
151 # include <errno.h>
152 #endif
154 #ifdef HAVE_TERMIOS
155 # include <termios.h>
156 #endif
158 #ifdef __APPLE__
159 # include <_types.h>
160 #endif
162 #if defined (__linux__) || defined (__ANDROID__) || defined (__QNX__) \
163 || defined (__rtems__)
164 # include <pthread.h>
165 # include <signal.h>
166 #endif
168 #if defined(__MINGW32__) || defined(__CYGWIN__)
169 # include <windef.h>
170 # include <winbase.h>
171 #endif
173 #ifdef NATIVE
174 #include <stdio.h>
176 #ifdef DUMMY
177 int counter = 0;
178 # define _VAL(x) counter++
179 #else
180 # define _VAL(x) x
181 #endif
183 #define CND(name,comment) \
184 printf ("\n->CND:$%d:" #name ":$%d:" comment, __LINE__, ((int) _VAL (name)));
186 #define CNU(name,comment) \
187 printf ("\n->CNU:$%d:" #name ":$%u:" comment, __LINE__, ((unsigned int) _VAL (name)));
189 #define CNS(name,comment) \
190 printf ("\n->CNS:$%d:" #name ":" name ":" comment, __LINE__);
192 #define C(sname,type,value,comment)\
193 printf ("\n->C:$%d:" sname ":" #type ":" value ":" comment, __LINE__);
195 #define SUB(sname)\
196 printf ("\n->SUB:$%d:" #sname ":" sname, __LINE__);
198 #define TXT(text) \
199 printf ("\n->TXT:$%d:" text, __LINE__);
201 #else
203 #define CND(name, comment) \
204 asm volatile("\n->CND:%0:" #name ":%1:" comment \
205 : : "i" (__LINE__), "i" ((int) name));
206 /* Decimal constant in the range of type "int" */
208 #define CNU(name, comment) \
209 asm volatile("\n->CNU:%0:" #name ":%1:" comment \
210 : : "i" (__LINE__), "i" ((int) name));
211 /* Decimal constant in the range of type "unsigned int" (note, assembler
212 * always wants a signed int, we convert back in xoscons).
215 #define CNS(name, comment) \
216 asm volatile("\n->CNS:%0:" #name ":" name ":" comment \
217 : : "i" (__LINE__));
218 /* General expression named number */
220 #define C(sname, type, value, comment) \
221 asm volatile("\n->C:%0:" sname ":" #type ":" value ":" comment \
222 : : "i" (__LINE__));
223 /* Typed constant */
225 #define SUB(sname) \
226 asm volatile("\n->SUB:%0:" #sname ":" sname \
227 : : "i" (__LINE__));
228 /* Subtype */
230 #define TXT(text) \
231 asm volatile("\n->TXT:%0:" text \
232 : : "i" (__LINE__));
233 /* Freeform text */
235 #endif /* NATIVE */
237 #define CST(name,comment) C(#name,String,name,comment)
238 /* String constant */
240 #ifdef __MINGW32__
241 unsigned int _CRT_fmode = _O_BINARY;
242 #endif
245 main (void) {
248 -- This package provides target dependent definitions of constant for use
249 -- by the GNAT runtime library. This package should not be directly with'd
250 -- by an application program.
252 -- This file is generated automatically, do not modify it by hand! Instead,
253 -- make changes to s-oscons-tmplt.c and rebuild the GNAT runtime library.
257 ** Do not change the format of the line below without also updating the
258 ** MaRTE Makefile.
260 TXT("-- This is the version for " TARGET)
261 TXT("")
262 TXT("with Interfaces.C;")
263 #if defined (__MINGW32__) || defined (__CYGWIN__)
264 # define TARGET_OS "Windows"
265 # define Serial_Port_Descriptor "System.Win32.HANDLE"
266 TXT("with System.Win32;")
267 #else
268 # define TARGET_OS "Other_OS"
269 # define Serial_Port_Descriptor "Interfaces.C.int"
270 #endif
273 package System.OS_Constants is
275 pragma Pure;
279 ** General constants (all platforms)
284 ---------------------------------
285 -- General platform parameters --
286 ---------------------------------
288 type OS_Type is (Windows, Other_OS);
290 C("Target_OS", OS_Type, TARGET_OS, "")
292 pragma Warnings (Off, Target_OS);
293 -- Suppress warnings on Target_OS since it is in general tested for
294 -- equality with a constant value to implement conditional compilation,
295 -- which normally generates a constant condition warning.
298 #define Target_Name TARGET
299 CST(Target_Name, "")
302 ** Note: the name of the following constant is recognized specially by
303 ** xoscons (case sensitive).
305 #define SIZEOF_unsigned_int sizeof (unsigned int)
306 CND(SIZEOF_unsigned_int, "Size of unsigned int")
308 SUB(Serial_Port_Descriptor)
312 -------------------
313 -- System limits --
314 -------------------
318 #ifndef IOV_MAX
319 # define IOV_MAX INT_MAX
320 #endif
321 CND(IOV_MAX, "Maximum writev iovcnt")
323 /* NAME_MAX is used to compute the allocation size for a struct dirent
324 * passed to readdir() / readdir_r(). However on some systems it is not
325 * defined, as it is technically a filesystem dependent property that
326 * we should retrieve through pathconf(). In any case, we do not need a
327 * precise value but only an upper limit.
329 #ifndef NAME_MAX
330 # ifdef MAXNAMELEN
331 /* Solaris has no NAME_MAX but defines MAXNAMELEN */
332 # define NAME_MAX MAXNAMELEN
333 # elif defined(PATH_MAX)
334 /* PATH_MAX (maximum length of a full path name) is a safe fall back */
335 # define NAME_MAX PATH_MAX
336 # elif defined(FILENAME_MAX)
337 /* Similarly FILENAME_MAX can provide a safe fall back */
338 # define NAME_MAX FILENAME_MAX
339 # else
340 /* Hardcode a reasonably large value as a last chance fallback */
341 # define NAME_MAX 1024
342 # endif
343 #endif
344 CND(NAME_MAX, "Maximum file name length")
348 ---------------------
349 -- File open modes --
350 ---------------------
354 #ifndef O_RDWR
355 # define O_RDWR -1
356 #endif
357 CND(O_RDWR, "Read/write")
359 #ifndef O_NOCTTY
360 # define O_NOCTTY -1
361 #endif
362 CND(O_NOCTTY, "Don't change ctrl tty")
364 #ifndef O_NDELAY
365 # define O_NDELAY -1
366 #endif
367 CND(O_NDELAY, "Nonblocking")
371 ----------------------
372 -- Fcntl operations --
373 ----------------------
377 #ifndef F_GETFL
378 # define F_GETFL -1
379 #endif
380 CND(F_GETFL, "Get flags")
382 #ifndef F_SETFL
383 # define F_SETFL -1
384 #endif
385 CND(F_SETFL, "Set flags")
389 -----------------
390 -- Fcntl flags --
391 -----------------
395 #ifndef FNDELAY
396 # define FNDELAY -1
397 #endif
398 CND(FNDELAY, "Nonblocking")
402 ----------------------
403 -- Ioctl operations --
404 ----------------------
408 /* ioctl(2) requests are "int" in UNIX, but "unsigned long" on FreeBSD */
410 #if defined (__FreeBSD__) || defined (__DragonFly__)
411 # define CNI CNU
412 # define IOCTL_Req_T "Interfaces.C.unsigned"
413 #else
414 # define CNI CND
415 # define IOCTL_Req_T "Interfaces.C.int"
416 #endif
418 SUB(IOCTL_Req_T)
420 #ifndef FIONBIO
421 # define FIONBIO -1
422 #endif
423 CNI(FIONBIO, "Set/clear non-blocking io")
425 #ifndef FIONREAD
426 # define FIONREAD -1
427 #endif
428 CNI(FIONREAD, "How many bytes to read")
432 ------------------
433 -- Errno values --
434 ------------------
436 -- The following constants are defined from <errno.h>
439 #ifndef EAGAIN
440 # define EAGAIN -1
441 #endif
442 CND(EAGAIN, "Try again")
444 #ifndef ENOENT
445 # define ENOENT -1
446 #endif
447 CND(ENOENT, "File not found")
449 #ifndef ENOMEM
450 # define ENOMEM -1
451 #endif
452 CND(ENOMEM, "Out of memory")
454 #ifdef __MINGW32__
457 -- The following constants are defined from <winsock2.h> (WSA*)
462 ** For sockets-related errno values on Windows, gsocket.h redefines
463 ** Exxx as WSAExxx.
466 #endif
468 #ifndef EACCES
469 # define EACCES -1
470 #endif
471 CND(EACCES, "Permission denied")
473 #ifndef EADDRINUSE
474 # define EADDRINUSE -1
475 #endif
476 CND(EADDRINUSE, "Address already in use")
478 #ifndef EADDRNOTAVAIL
479 # define EADDRNOTAVAIL -1
480 #endif
481 CND(EADDRNOTAVAIL, "Cannot assign address")
483 #ifndef EAFNOSUPPORT
484 # define EAFNOSUPPORT -1
485 #endif
486 CND(EAFNOSUPPORT, "Addr family not supported")
488 #ifndef EALREADY
489 # define EALREADY -1
490 #endif
491 CND(EALREADY, "Operation in progress")
493 #ifndef EBADF
494 # define EBADF -1
495 #endif
496 CND(EBADF, "Bad file descriptor")
498 #ifndef ECONNABORTED
499 # define ECONNABORTED -1
500 #endif
501 CND(ECONNABORTED, "Connection aborted")
503 #ifndef ECONNREFUSED
504 # define ECONNREFUSED -1
505 #endif
506 CND(ECONNREFUSED, "Connection refused")
508 #ifndef ECONNRESET
509 # define ECONNRESET -1
510 #endif
511 CND(ECONNRESET, "Connection reset by peer")
513 #ifndef EDESTADDRREQ
514 # define EDESTADDRREQ -1
515 #endif
516 CND(EDESTADDRREQ, "Destination addr required")
518 #ifndef EFAULT
519 # define EFAULT -1
520 #endif
521 CND(EFAULT, "Bad address")
523 #ifndef EHOSTDOWN
524 # define EHOSTDOWN -1
525 #endif
526 CND(EHOSTDOWN, "Host is down")
528 #ifndef EHOSTUNREACH
529 # define EHOSTUNREACH -1
530 #endif
531 CND(EHOSTUNREACH, "No route to host")
533 #ifndef EINPROGRESS
534 # define EINPROGRESS -1
535 #endif
536 CND(EINPROGRESS, "Operation now in progress")
538 #ifndef EINTR
539 # define EINTR -1
540 #endif
541 CND(EINTR, "Interrupted system call")
543 #ifndef EINVAL
544 # define EINVAL -1
545 #endif
546 CND(EINVAL, "Invalid argument")
548 #ifndef EIO
549 # define EIO -1
550 #endif
551 CND(EIO, "Input output error")
553 #ifndef EISCONN
554 # define EISCONN -1
555 #endif
556 CND(EISCONN, "Socket already connected")
558 #ifndef ELOOP
559 # define ELOOP -1
560 #endif
561 CND(ELOOP, "Too many symbolic links")
563 #ifndef EMFILE
564 # define EMFILE -1
565 #endif
566 CND(EMFILE, "Too many open files")
568 #ifndef EMSGSIZE
569 # define EMSGSIZE -1
570 #endif
571 CND(EMSGSIZE, "Message too long")
573 #ifndef ENAMETOOLONG
574 # define ENAMETOOLONG -1
575 #endif
576 CND(ENAMETOOLONG, "Name too long")
578 #ifndef ENETDOWN
579 # define ENETDOWN -1
580 #endif
581 CND(ENETDOWN, "Network is down")
583 #ifndef ENETRESET
584 # define ENETRESET -1
585 #endif
586 CND(ENETRESET, "Disconn. on network reset")
588 #ifndef ENETUNREACH
589 # define ENETUNREACH -1
590 #endif
591 CND(ENETUNREACH, "Network is unreachable")
593 #ifndef ENOBUFS
594 # define ENOBUFS -1
595 #endif
596 CND(ENOBUFS, "No buffer space available")
598 #ifndef ENOPROTOOPT
599 # define ENOPROTOOPT -1
600 #endif
601 CND(ENOPROTOOPT, "Protocol not available")
603 #ifndef ENOTCONN
604 # define ENOTCONN -1
605 #endif
606 CND(ENOTCONN, "Socket not connected")
608 #ifndef ENOTSOCK
609 # define ENOTSOCK -1
610 #endif
611 CND(ENOTSOCK, "Operation on non socket")
613 #ifndef EOPNOTSUPP
614 # define EOPNOTSUPP -1
615 #endif
616 CND(EOPNOTSUPP, "Operation not supported")
618 #ifndef EPIPE
619 # define EPIPE -1
620 #endif
621 CND(EPIPE, "Broken pipe")
623 #ifndef EPFNOSUPPORT
624 # define EPFNOSUPPORT -1
625 #endif
626 CND(EPFNOSUPPORT, "Unknown protocol family")
628 #ifndef EPROTONOSUPPORT
629 # define EPROTONOSUPPORT -1
630 #endif
631 CND(EPROTONOSUPPORT, "Unknown protocol")
633 #ifndef EPROTOTYPE
634 # define EPROTOTYPE -1
635 #endif
636 CND(EPROTOTYPE, "Unknown protocol type")
638 #ifndef ERANGE
639 # define ERANGE -1
640 #endif
641 CND(ERANGE, "Result too large")
643 #ifndef ESHUTDOWN
644 # define ESHUTDOWN -1
645 #endif
646 CND(ESHUTDOWN, "Cannot send once shutdown")
648 #ifndef ESOCKTNOSUPPORT
649 # define ESOCKTNOSUPPORT -1
650 #endif
651 CND(ESOCKTNOSUPPORT, "Socket type not supported")
653 #ifndef ETIMEDOUT
654 # define ETIMEDOUT -1
655 #endif
656 CND(ETIMEDOUT, "Connection timed out")
658 #ifndef ETOOMANYREFS
659 # define ETOOMANYREFS -1
660 #endif
661 CND(ETOOMANYREFS, "Too many references")
663 #ifndef EWOULDBLOCK
664 # define EWOULDBLOCK -1
665 #endif
666 CND(EWOULDBLOCK, "Operation would block")
668 #ifndef E2BIG
669 # define E2BIG -1
670 #endif
671 CND(E2BIG, "Argument list too long")
673 #ifndef EILSEQ
674 # define EILSEQ -1
675 #endif
676 CND(EILSEQ, "Illegal byte sequence")
679 ** Terminal/serial I/O constants
682 #if defined(HAVE_TERMIOS) || defined(__MINGW32__)
685 ----------------------
686 -- Terminal control --
687 ----------------------
690 #endif
692 #ifdef HAVE_TERMIOS
694 #ifndef TCSANOW
695 # define TCSANOW -1
696 #endif
697 CND(TCSANOW, "Immediate")
699 #ifndef TCIFLUSH
700 # define TCIFLUSH -1
701 #endif
702 CND(TCIFLUSH, "Flush input")
704 #ifndef IXON
705 # define IXON -1
706 #endif
707 CNU(IXON, "Output sw flow control")
709 #ifndef CLOCAL
710 # define CLOCAL -1
711 #endif
712 CNU(CLOCAL, "Local")
714 #ifndef CRTSCTS
715 # define CRTSCTS -1
716 #endif
717 CNU(CRTSCTS, "Output hw flow control")
719 #ifndef CREAD
720 # define CREAD -1
721 #endif
722 CNU(CREAD, "Read")
724 #ifndef ICANON
725 # define ICANON -1
726 #endif
727 CNU(ICANON, "canonical mode")
729 #ifndef CBAUD
730 # define CBAUD -1
731 #endif
732 CNU(CBAUD, "baud speed mask")
734 #ifndef ECHO
735 # define ECHO -1
736 #endif
737 CNU(ECHO, "echo input characters")
739 #ifndef ECHOE
740 # define ECHOE -1
741 #endif
742 CNU(ECHOE, "erase preceding characters")
744 #ifndef ECHOK
745 # define ECHOK -1
746 #endif
747 CNU(ECHOK, "kill character, erases current line")
749 #ifndef ECHOCTL
750 # define ECHOCTL -1
751 #endif
752 CNU(ECHOCTL, "echo special characters")
754 #ifndef ECHONL
755 # define ECHONL -1
756 #endif
757 CNU(ECHONL, "force echo NL character")
759 #ifndef CS5
760 # define CS5 -1
761 #endif
762 CNU(CS5, "5 data bits")
764 #ifndef CS6
765 # define CS6 -1
766 #endif
767 CNU(CS6, "6 data bits")
769 #ifndef CS7
770 # define CS7 -1
771 #endif
772 CNU(CS7, "7 data bits")
774 #ifndef CS8
775 # define CS8 -1
776 #endif
777 CNU(CS8, "8 data bits")
779 #ifndef CSTOPB
780 # define CSTOPB -1
781 #endif
782 CNU(CSTOPB, "2 stop bits")
784 #ifndef PARENB
785 # define PARENB -1
786 #endif
787 CNU(PARENB, "Parity enable")
789 #ifndef PARODD
790 # define PARODD -1
791 #endif
792 CNU(PARODD, "Parity odd")
794 #ifndef B0
795 # define B0 -1
796 #endif
797 CNU(B0, "0 bps")
799 #ifndef B50
800 # define B50 -1
801 #endif
802 CNU(B50, "50 bps")
804 #ifndef B75
805 # define B75 -1
806 #endif
807 CNU(B75, "75 bps")
809 #ifndef B110
810 # define B110 -1
811 #endif
812 CNU(B110, "110 bps")
814 #ifndef B134
815 # define B134 -1
816 #endif
817 CNU(B134, "134 bps")
819 #ifndef B150
820 # define B150 -1
821 #endif
822 CNU(B150, "150 bps")
824 #ifndef B200
825 # define B200 -1
826 #endif
827 CNU(B200, "200 bps")
829 #ifndef B300
830 # define B300 -1
831 #endif
832 CNU(B300, "300 bps")
834 #ifndef B600
835 # define B600 -1
836 #endif
837 CNU(B600, "600 bps")
839 #ifndef B1200
840 # define B1200 -1
841 #endif
842 CNU(B1200, "1200 bps")
844 #ifndef B1800
845 # define B1800 -1
846 #endif
847 CNU(B1800, "1800 bps")
849 #ifndef B2400
850 # define B2400 -1
851 #endif
852 CNU(B2400, "2400 bps")
854 #ifndef B4800
855 # define B4800 -1
856 #endif
857 CNU(B4800, "4800 bps")
859 #ifndef B9600
860 # define B9600 -1
861 #endif
862 CNU(B9600, "9600 bps")
864 #ifndef B19200
865 # define B19200 -1
866 #endif
867 CNU(B19200, "19200 bps")
869 #ifndef B38400
870 # define B38400 -1
871 #endif
872 CNU(B38400, "38400 bps")
874 #ifndef B57600
875 # define B57600 -1
876 #endif
877 CNU(B57600, "57600 bps")
879 #ifndef B115200
880 # define B115200 -1
881 #endif
882 CNU(B115200, "115200 bps")
884 #ifndef B230400
885 # define B230400 -1
886 #endif
887 CNU(B230400, "230400 bps")
889 #ifndef B460800
890 # define B460800 -1
891 #endif
892 CNU(B460800, "460800 bps")
894 #ifndef B500000
895 # define B500000 -1
896 #endif
897 CNU(B500000, "500000 bps")
899 #ifndef B576000
900 # define B576000 -1
901 #endif
902 CNU(B576000, "576000 bps")
904 #ifndef B921600
905 # define B921600 -1
906 #endif
907 CNU(B921600, "921600 bps")
909 #ifndef B1000000
910 # define B1000000 -1
911 #endif
912 CNU(B1000000, "1000000 bps")
914 #ifndef B1152000
915 # define B1152000 -1
916 #endif
917 CNU(B1152000, "1152000 bps")
919 #ifndef B1500000
920 # define B1500000 -1
921 #endif
922 CNU(B1500000, "1500000 bps")
924 #ifndef B2000000
925 # define B2000000 -1
926 #endif
927 CNU(B2000000, "2000000 bps")
929 #ifndef B2500000
930 # define B2500000 -1
931 #endif
932 CNU(B2500000, "2500000 bps")
934 #ifndef B3000000
935 # define B3000000 -1
936 #endif
937 CNU(B3000000, "3000000 bps")
939 #ifndef B3500000
940 # define B3500000 -1
941 #endif
942 CNU(B3500000, "3500000 bps")
944 #ifndef B4000000
945 # define B4000000 -1
946 #endif
947 CNU(B4000000, "4000000 bps")
951 ---------------------------------
952 -- Terminal control characters --
953 ---------------------------------
957 #ifndef VINTR
958 # define VINTR -1
959 #endif
960 CND(VINTR, "Interrupt")
962 #ifndef VQUIT
963 # define VQUIT -1
964 #endif
965 CND(VQUIT, "Quit")
967 #ifndef VERASE
968 # define VERASE -1
969 #endif
970 CND(VERASE, "Erase")
972 #ifndef VKILL
973 # define VKILL -1
974 #endif
975 CND(VKILL, "Kill")
977 #ifndef VEOF
978 # define VEOF -1
979 #endif
980 CND(VEOF, "EOF")
982 #ifndef VTIME
983 # define VTIME -1
984 #endif
985 CND(VTIME, "Read timeout")
987 #ifndef VMIN
988 # define VMIN -1
989 #endif
990 CND(VMIN, "Read min chars")
992 #ifndef VSWTC
993 # define VSWTC -1
994 #endif
995 CND(VSWTC, "Switch")
997 #ifndef VSTART
998 # define VSTART -1
999 #endif
1000 CND(VSTART, "Flow control start")
1002 #ifndef VSTOP
1003 # define VSTOP -1
1004 #endif
1005 CND(VSTOP, "Flow control stop")
1007 #ifndef VSUSP
1008 # define VSUSP -1
1009 #endif
1010 CND(VSUSP, "Suspend")
1012 #ifndef VEOL
1013 # define VEOL -1
1014 #endif
1015 CND(VEOL, "EOL")
1017 #ifndef VREPRINT
1018 # define VREPRINT -1
1019 #endif
1020 CND(VREPRINT, "Reprint unread")
1022 #ifndef VDISCARD
1023 # define VDISCARD -1
1024 #endif
1025 CND(VDISCARD, "Discard pending")
1027 #ifndef VWERASE
1028 # define VWERASE -1
1029 #endif
1030 CND(VWERASE, "Word erase")
1032 #ifndef VLNEXT
1033 # define VLNEXT -1
1034 #endif
1035 CND(VLNEXT, "Literal next")
1037 #ifndef VEOL2
1038 # define VEOL2 -1
1039 #endif
1040 CND(VEOL2, "Alternative EOL")
1042 #endif /* HAVE_TERMIOS */
1044 #if defined(__MINGW32__) || defined(__CYGWIN__)
1045 CNU(DTR_CONTROL_ENABLE, "Enable DTR flow ctrl")
1046 CNU(RTS_CONTROL_ENABLE, "Enable RTS flow ctrl")
1047 #endif
1051 -----------------------------
1052 -- Pseudo terminal library --
1053 -----------------------------
1057 #if defined (__FreeBSD__) || defined (__linux__) || defined (__DragonFly__)
1058 # define PTY_Library "-lutil"
1059 #else
1060 # define PTY_Library ""
1061 #endif
1062 CST(PTY_Library, "for g-exptty")
1065 ** Sockets constants
1068 #ifdef HAVE_SOCKETS
1072 --------------
1073 -- Families --
1074 --------------
1078 #ifndef AF_INET
1079 # define AF_INET -1
1080 #endif
1081 CND(AF_INET, "IPv4 address family")
1083 #ifndef AF_INET6
1084 # define AF_INET6 -1
1085 #else
1086 # define HAVE_AF_INET6 1
1087 #endif
1088 CND(AF_INET6, "IPv6 address family")
1090 #ifndef AF_UNIX
1091 # define AF_UNIX -1
1092 #endif
1093 CND(AF_UNIX, "Local unix family")
1095 #ifndef AF_UNSPEC
1096 # define AF_UNSPEC -1
1097 #else
1098 # define HAVE_AF_UNSPEC 1
1099 #endif
1100 CND(AF_UNSPEC, "Unspecified address family")
1104 -----------------------------
1105 -- addrinfo fields offsets --
1106 -----------------------------
1110 #ifdef AI_CANONNAME
1111 const struct addrinfo ai;
1113 #define AI_FLAGS_OFFSET ((void *)&ai.ai_flags - (void *)&ai)
1114 #define AI_FAMILY_OFFSET ((void *)&ai.ai_family - (void *)&ai)
1115 #define AI_SOCKTYPE_OFFSET ((void *)&ai.ai_socktype - (void *)&ai)
1116 #define AI_PROTOCOL_OFFSET ((void *)&ai.ai_protocol - (void *)&ai)
1117 #define AI_ADDRLEN_OFFSET ((void *)&ai.ai_addrlen - (void *)&ai)
1118 #define AI_ADDR_OFFSET ((void *)&ai.ai_addr - (void *)&ai)
1119 #define AI_CANONNAME_OFFSET ((void *)&ai.ai_canonname - (void *)&ai)
1120 #define AI_NEXT_OFFSET ((void *)&ai.ai_next - (void *)&ai)
1122 #else
1124 #define AI_FLAGS_OFFSET 0
1125 #define AI_FAMILY_OFFSET 4
1126 #define AI_SOCKTYPE_OFFSET 8
1127 #define AI_PROTOCOL_OFFSET 12
1128 #define AI_ADDRLEN_OFFSET 16
1129 #define AI_CANONNAME_OFFSET 24
1130 #define AI_ADDR_OFFSET 32
1131 #define AI_NEXT_OFFSET 40
1133 #endif
1135 CND(AI_FLAGS_OFFSET, "Offset of ai_flags in addrinfo");
1136 CND(AI_FAMILY_OFFSET, "Offset of ai_family in addrinfo");
1137 CND(AI_SOCKTYPE_OFFSET, "Offset of ai_socktype in addrinfo");
1138 CND(AI_PROTOCOL_OFFSET, "Offset of ai_protocol in addrinfo");
1139 CND(AI_ADDRLEN_OFFSET, "Offset of ai_addrlen in addrinfo");
1140 CND(AI_ADDR_OFFSET, "Offset of ai_addr in addrinfo");
1141 CND(AI_CANONNAME_OFFSET, "Offset of ai_canonname in addrinfo");
1142 CND(AI_NEXT_OFFSET, "Offset of ai_next in addrinfo");
1146 ---------------------------------------
1147 -- getaddrinfo getnameinfo constants --
1148 ---------------------------------------
1152 #ifndef AI_PASSIVE
1153 # define AI_PASSIVE -1
1154 #endif
1155 CND(AI_PASSIVE, "NULL nodename for accepting")
1157 #ifndef AI_CANONNAME
1158 # define AI_CANONNAME -1
1159 #endif
1160 CND(AI_CANONNAME, "Get the host official name")
1162 #ifndef AI_NUMERICSERV
1163 # define AI_NUMERICSERV -1
1164 #endif
1165 CND(AI_NUMERICSERV, "Service is a numeric string")
1167 #ifndef AI_NUMERICHOST
1168 # define AI_NUMERICHOST -1
1169 #endif
1170 CND(AI_NUMERICHOST, "Node is a numeric IP address")
1172 #ifndef AI_ADDRCONFIG
1173 # define AI_ADDRCONFIG -1
1174 #endif
1175 CND(AI_ADDRCONFIG, "Returns addresses for only locally configured families")
1177 #ifndef AI_V4MAPPED
1178 # define AI_V4MAPPED -1
1179 #endif
1180 CND(AI_V4MAPPED, "Returns IPv4 mapped to IPv6")
1182 #ifndef AI_ALL
1183 # define AI_ALL -1
1184 #endif
1185 CND(AI_ALL, "Change AI_V4MAPPED behavior for unavailavle IPv6 addresses")
1187 #ifndef NI_NAMEREQD
1188 # define NI_NAMEREQD -1
1189 #endif
1190 CND(NI_NAMEREQD, "Error if the hostname cannot be determined")
1192 #ifndef NI_DGRAM
1193 # define NI_DGRAM -1
1194 #endif
1195 CND(NI_DGRAM, "Service is datagram")
1197 #ifndef NI_NOFQDN
1198 # define NI_NOFQDN -1
1199 #endif
1200 CND(NI_NOFQDN, "Return only the hostname part for local hosts")
1202 #ifndef NI_NUMERICSERV
1203 # define NI_NUMERICSERV -1
1204 #endif
1205 CND(NI_NUMERICSERV, "Numeric form of the service")
1207 #ifndef NI_NUMERICHOST
1208 # define NI_NUMERICHOST -1
1209 #endif
1210 CND(NI_NUMERICHOST, "Numeric form of the hostname")
1212 #ifndef NI_MAXHOST
1213 # define NI_MAXHOST -1
1214 #endif
1215 CND(NI_MAXHOST, "Maximum size of hostname")
1217 #ifndef NI_MAXSERV
1218 # define NI_MAXSERV -1
1219 #endif
1220 CND(NI_MAXSERV, "Maximum size of service name")
1222 #ifndef EAI_SYSTEM
1223 # define EAI_SYSTEM -1
1224 #endif
1225 CND(EAI_SYSTEM, "Check errno for details")
1229 ------------------
1230 -- Socket modes --
1231 ------------------
1235 #ifndef SOCK_STREAM
1236 # define SOCK_STREAM -1
1237 #endif
1238 CND(SOCK_STREAM, "Stream socket")
1240 #ifndef SOCK_DGRAM
1241 # define SOCK_DGRAM -1
1242 #endif
1243 CND(SOCK_DGRAM, "Datagram socket")
1245 #ifndef SOCK_RAW
1246 # define SOCK_RAW -1
1247 #endif
1248 CND(SOCK_RAW, "Raw socket")
1252 -----------------
1253 -- Host errors --
1254 -----------------
1258 #ifndef HOST_NOT_FOUND
1259 # define HOST_NOT_FOUND -1
1260 #endif
1261 CND(HOST_NOT_FOUND, "Unknown host")
1263 #ifndef TRY_AGAIN
1264 # define TRY_AGAIN -1
1265 #endif
1266 CND(TRY_AGAIN, "Host name lookup failure")
1268 #ifndef NO_DATA
1269 # define NO_DATA -1
1270 #endif
1271 CND(NO_DATA, "No data record for name")
1273 #ifndef NO_RECOVERY
1274 # define NO_RECOVERY -1
1275 #endif
1276 CND(NO_RECOVERY, "Non recoverable errors")
1280 --------------------
1281 -- Shutdown modes --
1282 --------------------
1286 #ifndef SHUT_RD
1287 # define SHUT_RD -1
1288 #endif
1289 CND(SHUT_RD, "No more recv")
1291 #ifndef SHUT_WR
1292 # define SHUT_WR -1
1293 #endif
1294 CND(SHUT_WR, "No more send")
1296 #ifndef SHUT_RDWR
1297 # define SHUT_RDWR -1
1298 #endif
1299 CND(SHUT_RDWR, "No more recv/send")
1303 ---------------------
1304 -- Protocol levels --
1305 ---------------------
1309 #ifndef SOL_SOCKET
1310 # define SOL_SOCKET -1
1311 #endif
1312 CND(SOL_SOCKET, "Options for socket level")
1314 #ifndef IPPROTO_IP
1315 # define IPPROTO_IP -1
1316 #endif
1317 CND(IPPROTO_IP, "Dummy protocol for IP")
1319 #ifndef IPPROTO_IPV6
1320 # define IPPROTO_IPV6 -1
1321 #endif
1322 CND(IPPROTO_IPV6, "IPv6 socket option level")
1324 #ifndef IPPROTO_UDP
1325 # define IPPROTO_UDP -1
1326 #endif
1327 CND(IPPROTO_UDP, "UDP")
1329 #ifndef IPPROTO_TCP
1330 # define IPPROTO_TCP -1
1331 #endif
1332 CND(IPPROTO_TCP, "TCP")
1334 #ifndef IPPROTO_ICMP
1335 # define IPPROTO_ICMP -1
1336 #endif
1337 CND(IPPROTO_ICMP, "Internet Control Message Protocol")
1339 #ifndef IPPROTO_IGMP
1340 # define IPPROTO_IGMP -1
1341 #endif
1342 CND(IPPROTO_IGMP, "Internet Group Management Protocol")
1344 #ifndef IPPROTO_IPIP
1345 # define IPPROTO_IPIP -1
1346 #endif
1347 CND(IPPROTO_IPIP, "IPIP tunnels (older KA9Q tunnels use 94)")
1349 #ifndef IPPROTO_EGP
1350 # define IPPROTO_EGP -1
1351 #endif
1352 CND(IPPROTO_EGP, "Exterior Gateway Protocol")
1354 #ifndef IPPROTO_PUP
1355 # define IPPROTO_PUP -1
1356 #endif
1357 CND(IPPROTO_PUP, "PUP protocol")
1359 #ifndef IPPROTO_IDP
1360 # define IPPROTO_IDP -1
1361 #endif
1362 CND(IPPROTO_IDP, "XNS IDP protocol")
1364 #ifndef IPPROTO_TP
1365 # define IPPROTO_TP -1
1366 #endif
1367 CND(IPPROTO_TP, "SO Transport Protocol Class 4")
1369 #ifndef IPPROTO_DCCP
1370 # define IPPROTO_DCCP -1
1371 #endif
1372 CND(IPPROTO_DCCP, "Datagram Congestion Control Protocol")
1374 #ifndef IPPROTO_RSVP
1375 # define IPPROTO_RSVP -1
1376 #endif
1377 CND(IPPROTO_RSVP, "Reservation Protocol")
1379 #ifndef IPPROTO_GRE
1380 # define IPPROTO_GRE -1
1381 #endif
1382 CND(IPPROTO_GRE, "General Routing Encapsulation")
1384 #ifndef IPPROTO_ESP
1385 # define IPPROTO_ESP -1
1386 #endif
1387 CND(IPPROTO_ESP, "encapsulating security payload")
1389 #ifndef IPPROTO_AH
1390 # define IPPROTO_AH -1
1391 #endif
1392 CND(IPPROTO_AH, "authentication header")
1394 #ifndef IPPROTO_MTP
1395 # define IPPROTO_MTP -1
1396 #endif
1397 CND(IPPROTO_MTP, "Multicast Transport Protocol")
1399 #ifndef IPPROTO_BEETPH
1400 # define IPPROTO_BEETPH -1
1401 #endif
1402 CND(IPPROTO_BEETPH, "IP option pseudo header for BEET")
1404 #ifndef IPPROTO_ENCAP
1405 # define IPPROTO_ENCAP -1
1406 #endif
1407 CND(IPPROTO_ENCAP, "Encapsulation Header")
1409 #ifndef IPPROTO_PIM
1410 # define IPPROTO_PIM -1
1411 #endif
1412 CND(IPPROTO_PIM, "Protocol Independent Multicast")
1414 #ifndef IPPROTO_COMP
1415 # define IPPROTO_COMP -1
1416 #endif
1417 CND(IPPROTO_COMP, "Compression Header Protocol")
1419 #ifndef IPPROTO_SCTP
1420 # define IPPROTO_SCTP -1
1421 #endif
1422 CND(IPPROTO_SCTP, "Stream Control Transmission Protocol")
1424 #ifndef IPPROTO_UDPLITE
1425 # define IPPROTO_UDPLITE -1
1426 #endif
1427 CND(IPPROTO_UDPLITE, "UDP-Lite protocol")
1429 #ifndef IPPROTO_MPLS
1430 # define IPPROTO_MPLS -1
1431 #endif
1432 CND(IPPROTO_MPLS, "MPLS in IP")
1434 #ifndef IPPROTO_RAW
1435 # define IPPROTO_RAW -1
1436 #endif
1437 CND(IPPROTO_RAW, "Raw IP packets")
1441 -------------------
1442 -- Request flags --
1443 -------------------
1447 #ifndef MSG_OOB
1448 # define MSG_OOB -1
1449 #endif
1450 CND(MSG_OOB, "Process out-of-band data")
1452 #ifndef MSG_PEEK
1453 # define MSG_PEEK -1
1454 #endif
1455 CND(MSG_PEEK, "Peek at incoming data")
1457 #ifndef MSG_EOR
1458 # define MSG_EOR -1
1459 #endif
1460 CND(MSG_EOR, "Send end of record")
1462 #ifndef MSG_WAITALL
1463 # define MSG_WAITALL -1
1464 #endif
1465 CND(MSG_WAITALL, "Wait for full reception")
1467 #ifndef MSG_NOSIGNAL
1468 # define MSG_NOSIGNAL -1
1469 #endif
1470 CND(MSG_NOSIGNAL, "No SIGPIPE on send")
1472 #if defined (__linux__) || defined (__ANDROID__) || defined (__QNX__)
1473 # define MSG_Forced_Flags "MSG_NOSIGNAL"
1474 #else
1475 # define MSG_Forced_Flags "0"
1476 #endif
1477 CNS(MSG_Forced_Flags, "")
1479 -- Flags set on all send(2) calls
1484 --------------------
1485 -- Socket options --
1486 --------------------
1490 #ifndef TCP_NODELAY
1491 # define TCP_NODELAY -1
1492 #endif
1493 CND(TCP_NODELAY, "Do not coalesce packets")
1495 #ifndef TCP_KEEPCNT
1496 #ifdef __MINGW32__
1497 /* Windows headers can be too old to have all available constants.
1498 * We know this one. */
1499 # define TCP_KEEPCNT 16
1500 #else
1501 # define TCP_KEEPCNT -1
1502 #endif
1503 #endif
1504 CND(TCP_KEEPCNT, "Maximum number of keepalive probes")
1506 #ifndef TCP_KEEPIDLE
1507 #ifdef __MINGW32__
1508 /* Windows headers can be too old to have all available constants.
1509 * We know this one. */
1510 # define TCP_KEEPIDLE 3
1511 #else
1512 # define TCP_KEEPIDLE -1
1513 #endif
1514 #endif
1515 CND(TCP_KEEPIDLE, "Idle time before TCP starts sending keepalive probes")
1517 #ifndef TCP_KEEPINTVL
1518 #ifdef __MINGW32__
1519 /* Windows headers can be too old to have all available constants.
1520 * We know this one. */
1521 # define TCP_KEEPINTVL 17
1522 #else
1523 # define TCP_KEEPINTVL -1
1524 #endif
1525 #endif
1526 CND(TCP_KEEPINTVL, "Time between individual keepalive probes")
1528 #ifndef SO_REUSEADDR
1529 # define SO_REUSEADDR -1
1530 #endif
1531 CND(SO_REUSEADDR, "Bind reuse local address")
1533 #ifndef SO_REUSEPORT
1534 # define SO_REUSEPORT -1
1535 #endif
1536 CND(SO_REUSEPORT, "Bind reuse port number")
1538 #ifndef SO_KEEPALIVE
1539 # define SO_KEEPALIVE -1
1540 #endif
1541 CND(SO_KEEPALIVE, "Enable keep-alive msgs")
1543 #ifndef SO_LINGER
1544 # define SO_LINGER -1
1545 #endif
1546 CND(SO_LINGER, "Defer close to flush data")
1548 #ifndef SO_BROADCAST
1549 # define SO_BROADCAST -1
1550 #endif
1551 CND(SO_BROADCAST, "Can send broadcast msgs")
1553 #ifndef SO_SNDBUF
1554 # define SO_SNDBUF -1
1555 #endif
1556 CND(SO_SNDBUF, "Set/get send buffer size")
1558 #ifndef SO_RCVBUF
1559 # define SO_RCVBUF -1
1560 #endif
1561 CND(SO_RCVBUF, "Set/get recv buffer size")
1563 #ifndef SO_SNDTIMEO
1564 # define SO_SNDTIMEO -1
1565 #endif
1566 CND(SO_SNDTIMEO, "Emission timeout")
1568 #ifndef SO_RCVTIMEO
1569 # define SO_RCVTIMEO -1
1570 #endif
1571 CND(SO_RCVTIMEO, "Reception timeout")
1573 #ifndef SO_ERROR
1574 # define SO_ERROR -1
1575 #endif
1576 CND(SO_ERROR, "Get/clear error status")
1578 #ifndef SO_BUSY_POLL
1579 # define SO_BUSY_POLL -1
1580 #endif
1581 CND(SO_BUSY_POLL, "Busy polling")
1583 #ifndef IP_MULTICAST_IF
1584 # define IP_MULTICAST_IF -1
1585 #endif
1586 CND(IP_MULTICAST_IF, "Set/get mcast interface")
1588 #ifndef IP_MULTICAST_TTL
1589 # define IP_MULTICAST_TTL -1
1590 #endif
1591 CND(IP_MULTICAST_TTL, "Set/get multicast TTL")
1593 #ifndef IP_MULTICAST_LOOP
1594 # define IP_MULTICAST_LOOP -1
1595 #endif
1596 CND(IP_MULTICAST_LOOP, "Set/get mcast loopback")
1598 #ifndef IP_ADD_MEMBERSHIP
1599 # define IP_ADD_MEMBERSHIP -1
1600 #endif
1601 CND(IP_ADD_MEMBERSHIP, "Join a multicast group")
1603 #ifndef IP_DROP_MEMBERSHIP
1604 # define IP_DROP_MEMBERSHIP -1
1605 #endif
1606 CND(IP_DROP_MEMBERSHIP, "Leave a multicast group")
1608 #ifndef IP_PKTINFO
1609 # define IP_PKTINFO -1
1610 #endif
1611 CND(IP_PKTINFO, "Get datagram info")
1613 #ifndef IP_RECVERR
1614 # define IP_RECVERR -1
1615 #endif
1616 CND(IP_RECVERR, "Extended reliable error message passing")
1618 #ifndef IPV6_ADDRFORM
1619 # define IPV6_ADDRFORM -1
1620 #endif
1621 CND(IPV6_ADDRFORM, "Turn IPv6 socket into different address family")
1623 #ifndef IPV6_ADD_MEMBERSHIP
1624 # define IPV6_ADD_MEMBERSHIP -1
1625 #endif
1626 CND(IPV6_ADD_MEMBERSHIP, "Join IPv6 multicast group")
1628 #ifndef IPV6_DROP_MEMBERSHIP
1629 # define IPV6_DROP_MEMBERSHIP -1
1630 #endif
1631 CND(IPV6_DROP_MEMBERSHIP, "Leave IPv6 multicast group")
1633 #ifndef IPV6_MTU
1634 # define IPV6_MTU -1
1635 #endif
1636 CND(IPV6_MTU, "Set/get MTU used for the socket")
1638 #ifndef IPV6_MTU_DISCOVER
1639 # define IPV6_MTU_DISCOVER -1
1640 #endif
1641 CND(IPV6_MTU_DISCOVER, "Control path-MTU discovery on the socket")
1643 #ifndef IPV6_MULTICAST_HOPS
1644 # define IPV6_MULTICAST_HOPS -1
1645 #endif
1646 CND(IPV6_MULTICAST_HOPS, "Set the multicast hop limit for the socket")
1648 #ifndef IPV6_MULTICAST_IF
1649 # define IPV6_MULTICAST_IF -1
1650 #endif
1651 CND(IPV6_MULTICAST_IF, "Set/get IPv6 mcast interface")
1653 #ifndef IPV6_MULTICAST_LOOP
1654 # define IPV6_MULTICAST_LOOP -1
1655 #endif
1656 CND(IPV6_MULTICAST_LOOP, "Set/get mcast loopback")
1658 #ifndef IPV6_RECVPKTINFO
1659 # define IPV6_RECVPKTINFO -1
1660 #endif
1661 CND(IPV6_RECVPKTINFO, "Set delivery of the IPV6_PKTINFO")
1663 #ifndef IPV6_PKTINFO
1664 # define IPV6_PKTINFO -1
1665 #endif
1666 CND(IPV6_PKTINFO, "Get IPv6datagram info")
1668 #ifndef IPV6_RTHDR
1669 # define IPV6_RTHDR -1
1670 #endif
1671 CND(IPV6_RTHDR, "Set the routing header delivery")
1673 #ifndef IPV6_AUTHHDR
1674 # define IPV6_AUTHHDR -1
1675 #endif
1676 CND(IPV6_AUTHHDR, "Set the authentication header delivery")
1678 #ifndef IPV6_DSTOPTS
1679 # define IPV6_DSTOPTS -1
1680 #endif
1681 CND(IPV6_DSTOPTS, "Set the destination options delivery")
1683 #ifndef IPV6_HOPOPTS
1684 # define IPV6_HOPOPTS -1
1685 #endif
1686 CND(IPV6_HOPOPTS, "Set the hop options delivery")
1688 #ifndef IPV6_FLOWINFO
1689 #ifdef __linux__
1690 /* The IPV6_FLOWINFO is defined in linux/in6.h, but we can't include it because
1691 * of conflicts with other headers. */
1692 # define IPV6_FLOWINFO 11
1693 #else
1694 # define IPV6_FLOWINFO -1
1695 #endif
1696 #endif
1697 CND(IPV6_FLOWINFO, "Set the flow ID delivery")
1699 #ifndef IPV6_HOPLIMIT
1700 # define IPV6_HOPLIMIT -1
1701 #endif
1702 CND(IPV6_HOPLIMIT, "Set the hop count of the packet delivery")
1704 #ifndef IPV6_RECVERR
1705 # define IPV6_RECVERR -1
1706 #endif
1707 CND(IPV6_RECVERR, "Extended reliable error message passing")
1709 #ifndef IPV6_ROUTER_ALERT
1710 # define IPV6_ROUTER_ALERT -1
1711 #endif
1712 CND(IPV6_ROUTER_ALERT, "Pass forwarded router alert hop-by-hop option")
1714 #ifndef IPV6_UNICAST_HOPS
1715 # define IPV6_UNICAST_HOPS -1
1716 #endif
1717 CND(IPV6_UNICAST_HOPS, "Set the unicast hop limit")
1719 #ifndef IPV6_V6ONLY
1720 # define IPV6_V6ONLY -1
1721 #endif
1722 CND(IPV6_V6ONLY, "Restricted to IPv6 communications only")
1726 ----------------------
1727 -- Type definitions --
1728 ----------------------
1733 struct timeval tv;
1735 -- Sizes (in bytes) of the components of struct timeval
1737 #define SIZEOF_tv_sec (sizeof tv.tv_sec)
1738 CND(SIZEOF_tv_sec, "tv_sec")
1739 #define SIZEOF_tv_usec (sizeof tv.tv_usec)
1740 CND(SIZEOF_tv_usec, "tv_usec")
1743 -- Maximum allowed value for tv_sec
1747 ** On Solaris, field tv_sec in struct timeval has an undocumented
1748 ** hard-wired limit of 100 million.
1749 ** On IA64 HP-UX the limit is 2**31 - 1.
1751 #if defined (__sun__)
1752 # define MAX_tv_sec "100_000_000"
1754 #elif defined (__hpux__)
1755 # define MAX_tv_sec "16#7fffffff#"
1757 #else
1758 # define MAX_tv_sec "2 ** (SIZEOF_tv_sec * 8 - 1) - 1"
1759 #endif
1760 CNS(MAX_tv_sec, "")
1764 -- Sizes of various data types
1767 #define SIZEOF_sockaddr_in (sizeof (struct sockaddr_in))
1768 CND(SIZEOF_sockaddr_in, "struct sockaddr_in")
1769 #ifdef HAVE_AF_INET6
1770 # define SIZEOF_sockaddr_in6 (sizeof (struct sockaddr_in6))
1771 #else
1772 # define SIZEOF_sockaddr_in6 0
1773 #endif
1774 CND(SIZEOF_sockaddr_in6, "struct sockaddr_in6")
1777 ** The sockaddr_un structure is not defined in MINGW C headers
1778 ** but Windows supports it from build 17063.
1780 #if defined(__MINGW32__)
1781 struct sockaddr_un {
1782 ADDRESS_FAMILY sun_family; /* AF_UNIX */
1783 char sun_path[108]; /* Pathname */
1785 #endif
1786 #define SIZEOF_sockaddr_un (sizeof (struct sockaddr_un))
1787 CND(SIZEOF_sockaddr_un, "struct sockaddr_un")
1789 #define SIZEOF_fd_set (sizeof (fd_set))
1790 CND(SIZEOF_fd_set, "fd_set")
1791 CND(FD_SETSIZE, "Max fd value")
1793 #define SIZEOF_struct_hostent (sizeof (struct hostent))
1794 CND(SIZEOF_struct_hostent, "struct hostent")
1796 #define SIZEOF_struct_servent (sizeof (struct servent))
1797 CND(SIZEOF_struct_servent, "struct servent")
1799 #if defined (__linux__) || defined (__ANDROID__) || defined (__QNX__)
1800 #define SIZEOF_sigset (sizeof (sigset_t))
1801 CND(SIZEOF_sigset, "sigset")
1802 #endif
1804 #if defined(_WIN32) || defined(__vxworks)
1805 #define SIZEOF_nfds_t sizeof (int) * 8
1806 #define SIZEOF_socklen_t sizeof (size_t)
1807 #elif defined(__Lynx__)
1808 #define SIZEOF_nfds_t sizeof (unsigned long int) * 8
1809 #define SIZEOF_socklen_t sizeof (socklen_t)
1810 #else
1811 #define SIZEOF_nfds_t sizeof (nfds_t) * 8
1812 #define SIZEOF_socklen_t sizeof (socklen_t)
1813 #endif
1814 CND(SIZEOF_nfds_t, "Size of nfds_t");
1815 CND(SIZEOF_socklen_t, "Size of socklen_t");
1818 #if defined(__vxworks)
1819 #define SIZEOF_fd_type sizeof (int) * 8
1820 #define SIZEOF_pollfd_events sizeof (short) * 8
1821 #else
1822 const struct pollfd v_pollfd;
1823 #define SIZEOF_fd_type sizeof (v_pollfd.fd) * 8
1824 #define SIZEOF_pollfd_events sizeof (v_pollfd.events) * 8
1825 #endif
1826 CND(SIZEOF_fd_type, "Size of socket fd");
1827 CND(SIZEOF_pollfd_events, "Size of pollfd.events");
1830 #ifndef IF_NAMESIZE
1831 #ifdef IF_MAX_STRING_SIZE
1832 #define IF_NAMESIZE IF_MAX_STRING_SIZE
1833 #else
1834 #define IF_NAMESIZE -1
1835 #endif
1836 #endif
1837 CND(IF_NAMESIZE, "Max size of interface name with 0 terminator");
1841 -- Poll values
1845 #if defined(__vxworks)
1846 #ifndef POLLIN
1847 #define POLLIN 1
1848 #endif
1850 #ifndef POLLPRI
1851 #define POLLPRI 2
1852 #endif
1854 #ifndef POLLOUT
1855 #define POLLOUT 4
1856 #endif
1858 #ifndef POLLERR
1859 #define POLLERR 8
1860 #endif
1862 #ifndef POLLHUP
1863 #define POLLHUP 16
1864 #endif
1866 #ifndef POLLNVAL
1867 #define POLLNVAL 32
1868 #endif
1870 #elif defined(_WIN32)
1871 #define POLLPRI 0
1872 /* If the POLLPRI flag is set on a socket for the Microsoft Winsock provider,
1873 * the WSAPoll function will fail. */
1874 #endif
1876 CND(POLLIN, "There is data to read");
1877 CND(POLLPRI, "Urgent data to read");
1878 CND(POLLOUT, "Writing will not block");
1879 CND(POLLERR, "Error (output only)");
1880 CND(POLLHUP, "Hang up (output only)");
1881 CND(POLLNVAL, "Invalid request");
1885 -- Fields of struct msghdr
1888 #if defined (__sun__) || defined (__hpux__)
1889 # define Msg_Iovlen_T "Interfaces.C.int"
1890 #else
1891 # define Msg_Iovlen_T "Interfaces.C.size_t"
1892 #endif
1894 SUB(Msg_Iovlen_T)
1898 ----------------------------------------
1899 -- Properties of supported interfaces --
1900 ----------------------------------------
1904 CND(Need_Netdb_Buffer, "Need buffer for Netdb ops")
1905 CND(Need_Netdb_Lock, "Need lock for Netdb ops")
1906 CND(Has_Sockaddr_Len, "Sockaddr has sa_len field")
1909 ** Do not change the format of the line below without also updating the
1910 ** MaRTE Makefile.
1912 C("Thread_Blocking_IO", Boolean, "True", "")
1914 -- Set False for contexts where socket i/o are process blocking
1918 #ifdef HAVE_INET_PTON
1919 # define Inet_Pton_Linkname "inet_pton"
1920 #else
1921 # define Inet_Pton_Linkname "__gnat_inet_pton"
1922 #endif
1923 CST(Inet_Pton_Linkname, "")
1925 #ifdef HAVE_INET_NTOP
1926 # define Inet_Ntop_Linkname "inet_ntop"
1927 #else
1928 # define Inet_Ntop_Linkname "__gnat_inet_ntop"
1929 #endif
1930 CST(Inet_Ntop_Linkname, "")
1932 #if defined(_WIN32)
1933 # define Poll_Linkname "WSAPoll"
1934 #else
1935 # define Poll_Linkname "poll"
1936 #endif
1937 CST(Poll_Linkname, "")
1939 #endif /* HAVE_SOCKETS */
1943 ---------------------
1944 -- Threads support --
1945 ---------------------
1947 -- Clock identifier definitions
1951 /* Note: On HP-UX, CLOCK_REALTIME is an enum, not a macro. */
1953 #if !(defined(CLOCK_REALTIME) || defined (__hpux__))
1954 # define CLOCK_REALTIME (-1)
1955 #endif
1956 CND(CLOCK_REALTIME, "System realtime clock")
1958 #ifdef CLOCK_MONOTONIC
1959 CND(CLOCK_MONOTONIC, "System monotonic clock")
1960 #endif
1962 #ifdef CLOCK_FASTEST
1963 CND(CLOCK_FASTEST, "Fastest clock")
1964 #endif
1966 #ifndef CLOCK_THREAD_CPUTIME_ID
1967 # define CLOCK_THREAD_CPUTIME_ID -1
1968 #endif
1969 CND(CLOCK_THREAD_CPUTIME_ID, "Thread CPU clock")
1971 #if defined(__linux__) || defined(__FreeBSD__) \
1972 || (defined(_AIX) && defined(_AIXVERSION_530)) \
1973 || defined(__DragonFly__) || defined(__QNX__)
1974 /** On these platforms use system provided monotonic clock instead of
1975 ** the default CLOCK_REALTIME. We then need to set up cond var attributes
1976 ** appropriately (see thread.c).
1978 ** Note that AIX 5.2 does not support CLOCK_MONOTONIC timestamps for
1979 ** pthread_cond_timedwait (and does not have pthread_condattr_setclock),
1980 ** hence the conditionalization on AIX version above). _AIXVERSION_530
1981 ** is defined in AIX 5.3 and more recent versions.
1983 # define CLOCK_RT_Ada "CLOCK_MONOTONIC"
1985 #else
1986 /* By default use CLOCK_REALTIME */
1987 # define CLOCK_RT_Ada "CLOCK_REALTIME"
1988 #endif
1990 #ifdef CLOCK_RT_Ada
1991 CNS(CLOCK_RT_Ada, "")
1992 #endif
1994 #if defined (__APPLE__) || defined (__linux__) || defined (__ANDROID__) \
1995 || defined (__QNX__) || defined (__rtems__) || defined (DUMMY)
1998 -- Sizes of pthread data types
2001 #if defined (__APPLE__) || defined (DUMMY)
2003 -- (on Darwin, these are just placeholders)
2005 #define PTHREAD_SIZE __PTHREAD_SIZE__
2006 #define PTHREAD_ATTR_SIZE __PTHREAD_ATTR_SIZE__
2007 #define PTHREAD_MUTEXATTR_SIZE __PTHREAD_MUTEXATTR_SIZE__
2008 #define PTHREAD_MUTEX_SIZE __PTHREAD_MUTEX_SIZE__
2009 #define PTHREAD_CONDATTR_SIZE __PTHREAD_CONDATTR_SIZE__
2010 #define PTHREAD_COND_SIZE __PTHREAD_COND_SIZE__
2011 #define PTHREAD_RWLOCKATTR_SIZE __PTHREAD_RWLOCKATTR_SIZE__
2012 #define PTHREAD_RWLOCK_SIZE __PTHREAD_RWLOCK_SIZE__
2013 #define PTHREAD_ONCE_SIZE __PTHREAD_ONCE_SIZE__
2014 #else
2015 #define PTHREAD_SIZE (sizeof (pthread_t))
2016 #define PTHREAD_ATTR_SIZE (sizeof (pthread_attr_t))
2017 #define PTHREAD_MUTEXATTR_SIZE (sizeof (pthread_mutexattr_t))
2018 #define PTHREAD_MUTEX_SIZE (sizeof (pthread_mutex_t))
2019 #define PTHREAD_CONDATTR_SIZE (sizeof (pthread_condattr_t))
2020 #define PTHREAD_COND_SIZE (sizeof (pthread_cond_t))
2021 #define PTHREAD_RWLOCKATTR_SIZE (sizeof (pthread_rwlockattr_t))
2022 #define PTHREAD_RWLOCK_SIZE (sizeof (pthread_rwlock_t))
2023 #define PTHREAD_ONCE_SIZE (sizeof (pthread_once_t))
2024 #endif
2028 CND(PTHREAD_SIZE, "pthread_t")
2029 CND(PTHREAD_ATTR_SIZE, "pthread_attr_t")
2030 CND(PTHREAD_MUTEXATTR_SIZE, "pthread_mutexattr_t")
2031 CND(PTHREAD_MUTEX_SIZE, "pthread_mutex_t")
2032 CND(PTHREAD_CONDATTR_SIZE, "pthread_condattr_t")
2033 CND(PTHREAD_COND_SIZE, "pthread_cond_t")
2034 CND(PTHREAD_RWLOCKATTR_SIZE, "pthread_rwlockattr_t")
2035 CND(PTHREAD_RWLOCK_SIZE, "pthread_rwlock_t")
2036 CND(PTHREAD_ONCE_SIZE, "pthread_once_t")
2038 #endif /* __APPLE__ || __linux__ || __ANDROID__ || __rtems__ */
2042 --------------------------------
2043 -- File and directory support --
2044 --------------------------------
2049 ** Note: this constant can be used in the GNAT runtime library. In compiler
2050 ** units on the other hand, System.OS_Constants is not available, so we
2051 ** declare an Ada constant (Osint.File_Attributes_Size) independently, which
2052 ** is at least as large as sizeof (struct file_attributes), and we have an
2053 ** assertion at initialization of Osint checking that the size is indeed at
2054 ** least sufficient.
2056 #define SIZEOF_struct_file_attributes (sizeof (struct file_attributes))
2057 CND(SIZEOF_struct_file_attributes, "struct file_attributes")
2060 ** Maximal size of buffer for struct dirent. Note: Since POSIX.1 does not
2061 ** specify the size of the d_name field, and other nonstandard fields may
2062 ** precede that field within the dirent structure, we must make a conservative
2063 ** computation.
2066 struct dirent dent;
2067 #define SIZEOF_struct_dirent_alloc \
2068 ((char*) &dent.d_name - (char*) &dent) + NAME_MAX + 1
2069 CND(SIZEOF_struct_dirent_alloc, "struct dirent allocation")
2073 ** System-specific constants follow
2074 ** Each section should be activated if compiling for the corresponding
2075 ** platform *or* generating the dummy version for runtime test compilation.
2078 #if defined (__vxworks) || defined (DUMMY)
2082 --------------------------------
2083 -- VxWorks-specific constants --
2084 --------------------------------
2086 -- These constants may be used only within the VxWorks version of
2087 -- GNAT.Sockets.Thin.
2090 CND(OK, "VxWorks generic success")
2091 CND(ERROR, "VxWorks generic error")
2093 #endif /* __vxworks */
2095 #if defined (__MINGW32__) || defined (DUMMY)
2098 ------------------------------
2099 -- MinGW-specific constants --
2100 ------------------------------
2102 -- These constants may be used only within the MinGW version of
2103 -- GNAT.Sockets.Thin.
2106 CND(WSASYSNOTREADY, "System not ready")
2107 CND(WSAVERNOTSUPPORTED, "Version not supported")
2108 CND(WSANOTINITIALISED, "Winsock not initialized")
2109 CND(WSAEDISCON, "Disconnected")
2111 #endif /* __MINGW32__ */
2114 ** End of constants definitions
2117 #ifdef NATIVE
2118 putchar ('\n');
2119 #endif
2123 end System.OS_Constants;