2 ------------------------------------------------------------------------------
4 -- GNAT COMPILER COMPONENTS --
6 -- S Y S T E M . O S _ C O N S T A N T S --
10 -- Copyright (C) 2000-2021, Free Software Foundation, Inc. --
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. --
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. --
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/>. --
28 -- GNAT was originally developed by the GNAT team at New York University. --
29 -- Extensive contributions were provided by Ada Core Technologies Inc. --
31 ------------------------------------------------------------------------------
33 pragma Style_Checks ("M32766");
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
57 ** Two methods are supported to generate the list of constant values,
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
64 ** xgcc -DTARGET=\"$target\" -C -E s-oscons-tmplt.c > s-oscons-tmplt.i
65 ** xgcc -S s-oscons-tmplt.i
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
81 /* Feature macro definitions */
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.
89 #if defined (__linux__) || defined (__ANDROID__)
91 /* Define _XOPEN_SOURCE to get IOV_MAX */
92 # if !defined (_XOPEN_SOURCE)
93 # define _XOPEN_SOURCE 500
96 /* Define _BSD_SOURCE to get CRTSCTS */
99 #endif /* defined (__linux__) || defined (__ANDROID__) */
101 /* Include gsocket.h before any system header so it can redefine FD_SETSIZE */
111 #if ! (defined (__vxworks) || defined (__MINGW32__))
112 # define HAVE_TERMIOS
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__)
132 # if defined (TARGET)
133 # error TARGET may not be defined when generating the dummy version
135 # define TARGET "batch runtime compilation (dummy values)"
138 # if !(defined (HAVE_SOCKETS) && defined (HAVE_TERMIOS))
139 # error Features missing on platform
147 # error Please define TARGET
155 # include <termios.h>
162 #if defined (__linux__) || defined (__ANDROID__) || defined (__QNX__) \
163 || defined (__rtems__)
164 # include <pthread.h>
168 #if defined(__MINGW32__) || defined(__CYGWIN__)
170 # include <winbase.h>
178 # define _VAL(x) counter++
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__);
196 printf ("\n->SUB:$%d:" #sname ":" sname, __LINE__);
199 printf ("\n->TXT:$%d:" text, __LINE__);
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 \
218 /* General expression named number */
220 #define C(sname, type, value, comment) \
221 asm volatile("\n->C:%0:" sname ":" #type ":" value ":" comment \
226 asm volatile("\n->SUB:%0:" #sname ":" sname \
231 asm volatile("\n->TXT:%0:" text \
237 #define CST(name,comment) C(#name,String,name,comment)
238 /* String constant */
240 #define STR(x) STR1(x)
244 unsigned int _CRT_fmode
= _O_BINARY
;
251 -- This package provides target dependent definitions of constant for use
252 -- by the GNAT runtime library. This package should not be directly with'd
253 -- by an application program.
255 -- This file is generated automatically, do not modify it by hand! Instead,
256 -- make changes to s-oscons-tmplt.c and rebuild the GNAT runtime library.
260 ** Do not change the format of the line below without also updating the
263 TXT("-- This is the version for " TARGET
)
265 TXT("with Interfaces.C;")
266 #if defined (__MINGW32__) || defined (__CYGWIN__)
267 # define TARGET_OS "Windows"
268 # define Serial_Port_Descriptor "System.Win32.HANDLE"
269 TXT("with System.Win32;")
271 # define TARGET_OS "Other_OS"
272 # define Serial_Port_Descriptor "Interfaces.C.int"
276 package System.OS_Constants is
282 ** General constants (all platforms)
287 ---------------------------------
288 -- General platform parameters --
289 ---------------------------------
291 type OS_Type is (Windows, Other_OS);
293 C("Target_OS", OS_Type
, TARGET_OS
, "")
295 pragma Warnings (Off, Target_OS);
296 -- Suppress warnings on Target_OS since it is in general tested for
297 -- equality with a constant value to implement conditional compilation,
298 -- which normally generates a constant condition warning.
301 #define Target_Name TARGET
305 ** Note: the name of the following constant is recognized specially by
306 ** xoscons (case sensitive).
308 #define SIZEOF_unsigned_int sizeof (unsigned int)
309 CND(SIZEOF_unsigned_int
, "Size of unsigned int")
311 SUB(Serial_Port_Descriptor
)
322 # define IOV_MAX INT_MAX
324 CND(IOV_MAX
, "Maximum writev iovcnt")
326 /* NAME_MAX is used to compute the allocation size for a struct dirent
327 * passed to readdir() / readdir_r(). However on some systems it is not
328 * defined, as it is technically a filesystem dependent property that
329 * we should retrieve through pathconf(). In any case, we do not need a
330 * precise value but only an upper limit.
334 /* Solaris has no NAME_MAX but defines MAXNAMELEN */
335 # define NAME_MAX MAXNAMELEN
336 # elif defined(PATH_MAX)
337 /* PATH_MAX (maximum length of a full path name) is a safe fall back */
338 # define NAME_MAX PATH_MAX
339 # elif defined(FILENAME_MAX)
340 /* Similarly FILENAME_MAX can provide a safe fall back */
341 # define NAME_MAX FILENAME_MAX
343 /* Hardcode a reasonably large value as a last chance fallback */
344 # define NAME_MAX 1024
347 CND(NAME_MAX
, "Maximum file name length")
351 ---------------------
352 -- File open modes --
353 ---------------------
360 CND(O_RDWR
, "Read/write")
365 CND(O_NOCTTY
, "Don't change ctrl tty")
370 CND(O_NDELAY
, "Nonblocking")
374 ----------------------
375 -- Fcntl operations --
376 ----------------------
383 CND(F_GETFL
, "Get flags")
388 CND(F_SETFL
, "Set flags")
401 CND(FNDELAY
, "Nonblocking")
405 ----------------------
406 -- Ioctl operations --
407 ----------------------
411 /* ioctl(2) requests are "int" in UNIX, but "unsigned long" on FreeBSD */
413 #if defined (__FreeBSD__) || defined (__DragonFly__)
415 # define IOCTL_Req_T "Interfaces.C.unsigned"
418 # define IOCTL_Req_T "Interfaces.C.int"
426 CNI(FIONBIO
, "Set/clear non-blocking io")
431 CNI(FIONREAD
, "How many bytes to read")
439 -- The following constants are defined from <errno.h>
445 CND(EAGAIN
, "Try again")
450 CND(ENOENT
, "File not found")
455 CND(ENOMEM
, "Out of memory")
460 -- The following constants are defined from <winsock2.h> (WSA*)
465 ** For sockets-related errno values on Windows, gsocket.h redefines
474 CND(EACCES
, "Permission denied")
477 # define EADDRINUSE -1
479 CND(EADDRINUSE
, "Address already in use")
481 #ifndef EADDRNOTAVAIL
482 # define EADDRNOTAVAIL -1
484 CND(EADDRNOTAVAIL
, "Cannot assign address")
487 # define EAFNOSUPPORT -1
489 CND(EAFNOSUPPORT
, "Addr family not supported")
494 CND(EALREADY
, "Operation in progress")
499 CND(EBADF
, "Bad file descriptor")
502 # define ECONNABORTED -1
504 CND(ECONNABORTED
, "Connection aborted")
507 # define ECONNREFUSED -1
509 CND(ECONNREFUSED
, "Connection refused")
512 # define ECONNRESET -1
514 CND(ECONNRESET
, "Connection reset by peer")
517 # define EDESTADDRREQ -1
519 CND(EDESTADDRREQ
, "Destination addr required")
524 CND(EFAULT
, "Bad address")
527 # define EHOSTDOWN -1
529 CND(EHOSTDOWN
, "Host is down")
532 # define EHOSTUNREACH -1
534 CND(EHOSTUNREACH
, "No route to host")
537 # define EINPROGRESS -1
539 CND(EINPROGRESS
, "Operation now in progress")
544 CND(EINTR
, "Interrupted system call")
549 CND(EINVAL
, "Invalid argument")
554 CND(EIO
, "Input output error")
559 CND(EISCONN
, "Socket already connected")
564 CND(ELOOP
, "Too many symbolic links")
569 CND(EMFILE
, "Too many open files")
574 CND(EMSGSIZE
, "Message too long")
577 # define ENAMETOOLONG -1
579 CND(ENAMETOOLONG
, "Name too long")
584 CND(ENETDOWN
, "Network is down")
587 # define ENETRESET -1
589 CND(ENETRESET
, "Disconn. on network reset")
592 # define ENETUNREACH -1
594 CND(ENETUNREACH
, "Network is unreachable")
599 CND(ENOBUFS
, "No buffer space available")
602 # define ENOPROTOOPT -1
604 CND(ENOPROTOOPT
, "Protocol not available")
609 CND(ENOTCONN
, "Socket not connected")
614 CND(ENOTSOCK
, "Operation on non socket")
617 # define EOPNOTSUPP -1
619 CND(EOPNOTSUPP
, "Operation not supported")
624 CND(EPIPE
, "Broken pipe")
627 # define EPFNOSUPPORT -1
629 CND(EPFNOSUPPORT
, "Unknown protocol family")
631 #ifndef EPROTONOSUPPORT
632 # define EPROTONOSUPPORT -1
634 CND(EPROTONOSUPPORT
, "Unknown protocol")
637 # define EPROTOTYPE -1
639 CND(EPROTOTYPE
, "Unknown protocol type")
644 CND(ERANGE
, "Result too large")
647 # define ESHUTDOWN -1
649 CND(ESHUTDOWN
, "Cannot send once shutdown")
651 #ifndef ESOCKTNOSUPPORT
652 # define ESOCKTNOSUPPORT -1
654 CND(ESOCKTNOSUPPORT
, "Socket type not supported")
657 # define ETIMEDOUT -1
659 CND(ETIMEDOUT
, "Connection timed out")
662 # define ETOOMANYREFS -1
664 CND(ETOOMANYREFS
, "Too many references")
667 # define EWOULDBLOCK -1
669 CND(EWOULDBLOCK
, "Operation would block")
674 CND(E2BIG
, "Argument list too long")
679 CND(EILSEQ
, "Illegal byte sequence")
682 ** Terminal/serial I/O constants
685 #if defined(HAVE_TERMIOS) || defined(__MINGW32__)
688 ----------------------
689 -- Terminal control --
690 ----------------------
700 CND(TCSANOW
, "Immediate")
705 CND(TCIFLUSH
, "Flush input")
710 CNU(IXON
, "Output sw flow control")
720 CNU(CRTSCTS
, "Output hw flow control")
730 CNU(ICANON
, "canonical mode")
735 CNU(CBAUD
, "baud speed mask")
740 CNU(ECHO
, "echo input characters")
745 CNU(ECHOE
, "erase preceding characters")
750 CNU(ECHOK
, "kill character, erases current line")
755 CNU(ECHOCTL
, "echo special characters")
760 CNU(ECHONL
, "force echo NL character")
765 CNU(CS5
, "5 data bits")
770 CNU(CS6
, "6 data bits")
775 CNU(CS7
, "7 data bits")
780 CNU(CS8
, "8 data bits")
785 CNU(CSTOPB
, "2 stop bits")
790 CNU(PARENB
, "Parity enable")
795 CNU(PARODD
, "Parity odd")
845 CNU(B1200
, "1200 bps")
850 CNU(B1800
, "1800 bps")
855 CNU(B2400
, "2400 bps")
860 CNU(B4800
, "4800 bps")
865 CNU(B9600
, "9600 bps")
870 CNU(B19200
, "19200 bps")
875 CNU(B38400
, "38400 bps")
880 CNU(B57600
, "57600 bps")
885 CNU(B115200
, "115200 bps")
890 CNU(B230400
, "230400 bps")
895 CNU(B460800
, "460800 bps")
900 CNU(B500000
, "500000 bps")
905 CNU(B576000
, "576000 bps")
910 CNU(B921600
, "921600 bps")
915 CNU(B1000000
, "1000000 bps")
920 CNU(B1152000
, "1152000 bps")
925 CNU(B1500000
, "1500000 bps")
930 CNU(B2000000
, "2000000 bps")
935 CNU(B2500000
, "2500000 bps")
940 CNU(B3000000
, "3000000 bps")
945 CNU(B3500000
, "3500000 bps")
950 CNU(B4000000
, "4000000 bps")
954 ---------------------------------
955 -- Terminal control characters --
956 ---------------------------------
963 CND(VINTR
, "Interrupt")
988 CND(VTIME
, "Read timeout")
993 CND(VMIN
, "Read min chars")
1003 CND(VSTART
, "Flow control start")
1008 CND(VSTOP
, "Flow control stop")
1013 CND(VSUSP
, "Suspend")
1021 # define VREPRINT -1
1023 CND(VREPRINT
, "Reprint unread")
1026 # define VDISCARD -1
1028 CND(VDISCARD
, "Discard pending")
1033 CND(VWERASE
, "Word erase")
1038 CND(VLNEXT
, "Literal next")
1043 CND(VEOL2
, "Alternative EOL")
1045 #endif /* HAVE_TERMIOS */
1047 #if defined(__MINGW32__) || defined(__CYGWIN__)
1048 CNU(DTR_CONTROL_ENABLE
, "Enable DTR flow ctrl")
1049 CNU(RTS_CONTROL_ENABLE
, "Enable RTS flow ctrl")
1054 -----------------------------
1055 -- Pseudo terminal library --
1056 -----------------------------
1060 #if defined (__FreeBSD__) || defined (__linux__) || defined (__DragonFly__)
1061 # define PTY_Library "-lutil"
1063 # define PTY_Library ""
1065 CST(PTY_Library
, "for g-exptty")
1068 ** Sockets constants
1084 CND(AF_INET
, "IPv4 address family")
1087 # define AF_INET6 -1
1089 # define HAVE_AF_INET6 1
1091 CND(AF_INET6
, "IPv6 address family")
1096 CND(AF_UNIX
, "Local unix family")
1099 # define AF_UNSPEC -1
1101 # define HAVE_AF_UNSPEC 1
1103 CND(AF_UNSPEC
, "Unspecified address family")
1107 -----------------------------
1108 -- addrinfo fields offsets --
1109 -----------------------------
1114 const struct addrinfo ai
;
1116 #define AI_FLAGS_OFFSET ((void *)&ai.ai_flags - (void *)&ai)
1117 #define AI_FAMILY_OFFSET ((void *)&ai.ai_family - (void *)&ai)
1118 #define AI_SOCKTYPE_OFFSET ((void *)&ai.ai_socktype - (void *)&ai)
1119 #define AI_PROTOCOL_OFFSET ((void *)&ai.ai_protocol - (void *)&ai)
1120 #define AI_ADDRLEN_OFFSET ((void *)&ai.ai_addrlen - (void *)&ai)
1121 #define AI_ADDR_OFFSET ((void *)&ai.ai_addr - (void *)&ai)
1122 #define AI_CANONNAME_OFFSET ((void *)&ai.ai_canonname - (void *)&ai)
1123 #define AI_NEXT_OFFSET ((void *)&ai.ai_next - (void *)&ai)
1127 #define AI_FLAGS_OFFSET 0
1128 #define AI_FAMILY_OFFSET 4
1129 #define AI_SOCKTYPE_OFFSET 8
1130 #define AI_PROTOCOL_OFFSET 12
1131 #define AI_ADDRLEN_OFFSET 16
1132 #define AI_CANONNAME_OFFSET 24
1133 #define AI_ADDR_OFFSET 32
1134 #define AI_NEXT_OFFSET 40
1138 CND(AI_FLAGS_OFFSET
, "Offset of ai_flags in addrinfo");
1139 CND(AI_FAMILY_OFFSET
, "Offset of ai_family in addrinfo");
1140 CND(AI_SOCKTYPE_OFFSET
, "Offset of ai_socktype in addrinfo");
1141 CND(AI_PROTOCOL_OFFSET
, "Offset of ai_protocol in addrinfo");
1142 CND(AI_ADDRLEN_OFFSET
, "Offset of ai_addrlen in addrinfo");
1143 CND(AI_ADDR_OFFSET
, "Offset of ai_addr in addrinfo");
1144 CND(AI_CANONNAME_OFFSET
, "Offset of ai_canonname in addrinfo");
1145 CND(AI_NEXT_OFFSET
, "Offset of ai_next in addrinfo");
1149 ---------------------------------------
1150 -- getaddrinfo getnameinfo constants --
1151 ---------------------------------------
1156 # define AI_PASSIVE -1
1158 CND(AI_PASSIVE
, "NULL nodename for accepting")
1160 #ifndef AI_CANONNAME
1161 # define AI_CANONNAME -1
1163 CND(AI_CANONNAME
, "Get the host official name")
1165 #ifndef AI_NUMERICSERV
1166 # define AI_NUMERICSERV -1
1168 CND(AI_NUMERICSERV
, "Service is a numeric string")
1170 #ifndef AI_NUMERICHOST
1171 # define AI_NUMERICHOST -1
1173 CND(AI_NUMERICHOST
, "Node is a numeric IP address")
1175 #ifndef AI_ADDRCONFIG
1176 # define AI_ADDRCONFIG -1
1178 CND(AI_ADDRCONFIG
, "Returns addresses for only locally configured families")
1181 # define AI_V4MAPPED -1
1183 CND(AI_V4MAPPED
, "Returns IPv4 mapped to IPv6")
1188 CND(AI_ALL
, "Change AI_V4MAPPED behavior for unavailavle IPv6 addresses")
1191 # define NI_NAMEREQD -1
1193 CND(NI_NAMEREQD
, "Error if the hostname cannot be determined")
1196 # define NI_DGRAM -1
1198 CND(NI_DGRAM
, "Service is datagram")
1201 # define NI_NOFQDN -1
1203 CND(NI_NOFQDN
, "Return only the hostname part for local hosts")
1205 #ifndef NI_NUMERICSERV
1206 # define NI_NUMERICSERV -1
1208 CND(NI_NUMERICSERV
, "Numeric form of the service")
1210 #ifndef NI_NUMERICHOST
1211 # define NI_NUMERICHOST -1
1213 CND(NI_NUMERICHOST
, "Numeric form of the hostname")
1216 # define NI_MAXHOST -1
1218 CND(NI_MAXHOST
, "Maximum size of hostname")
1221 # define NI_MAXSERV -1
1223 CND(NI_MAXSERV
, "Maximum size of service name")
1226 # define EAI_SYSTEM -1
1228 CND(EAI_SYSTEM
, "Check errno for details")
1239 # define SOCK_STREAM -1
1241 CND(SOCK_STREAM
, "Stream socket")
1244 # define SOCK_DGRAM -1
1246 CND(SOCK_DGRAM
, "Datagram socket")
1249 # define SOCK_RAW -1
1251 CND(SOCK_RAW
, "Raw socket")
1261 #ifndef HOST_NOT_FOUND
1262 # define HOST_NOT_FOUND -1
1264 CND(HOST_NOT_FOUND
, "Unknown host")
1267 # define TRY_AGAIN -1
1269 CND(TRY_AGAIN
, "Host name lookup failure")
1274 CND(NO_DATA
, "No data record for name")
1277 # define NO_RECOVERY -1
1279 CND(NO_RECOVERY
, "Non recoverable errors")
1283 --------------------
1284 -- Shutdown modes --
1285 --------------------
1292 CND(SHUT_RD
, "No more recv")
1297 CND(SHUT_WR
, "No more send")
1300 # define SHUT_RDWR -1
1302 CND(SHUT_RDWR
, "No more recv/send")
1306 ---------------------
1307 -- Protocol levels --
1308 ---------------------
1313 # define SOL_SOCKET -1
1315 CND(SOL_SOCKET
, "Options for socket level")
1318 # define IPPROTO_IP -1
1320 CND(IPPROTO_IP
, "Dummy protocol for IP")
1322 #ifndef IPPROTO_IPV6
1323 # define IPPROTO_IPV6 -1
1325 CND(IPPROTO_IPV6
, "IPv6 socket option level")
1328 # define IPPROTO_UDP -1
1330 CND(IPPROTO_UDP
, "UDP")
1333 # define IPPROTO_TCP -1
1335 CND(IPPROTO_TCP
, "TCP")
1337 #ifndef IPPROTO_ICMP
1338 # define IPPROTO_ICMP -1
1340 CND(IPPROTO_ICMP
, "Internet Control Message Protocol")
1342 #ifndef IPPROTO_IGMP
1343 # define IPPROTO_IGMP -1
1345 CND(IPPROTO_IGMP
, "Internet Group Management Protocol")
1347 #ifndef IPPROTO_IPIP
1348 # define IPPROTO_IPIP -1
1350 CND(IPPROTO_IPIP
, "IPIP tunnels (older KA9Q tunnels use 94)")
1353 # define IPPROTO_EGP -1
1355 CND(IPPROTO_EGP
, "Exterior Gateway Protocol")
1358 # define IPPROTO_PUP -1
1360 CND(IPPROTO_PUP
, "PUP protocol")
1363 # define IPPROTO_IDP -1
1365 CND(IPPROTO_IDP
, "XNS IDP protocol")
1368 # define IPPROTO_TP -1
1370 CND(IPPROTO_TP
, "SO Transport Protocol Class 4")
1372 #ifndef IPPROTO_DCCP
1373 # define IPPROTO_DCCP -1
1375 CND(IPPROTO_DCCP
, "Datagram Congestion Control Protocol")
1377 #ifndef IPPROTO_RSVP
1378 # define IPPROTO_RSVP -1
1380 CND(IPPROTO_RSVP
, "Reservation Protocol")
1383 # define IPPROTO_GRE -1
1385 CND(IPPROTO_GRE
, "General Routing Encapsulation")
1388 # define IPPROTO_ESP -1
1390 CND(IPPROTO_ESP
, "encapsulating security payload")
1393 # define IPPROTO_AH -1
1395 CND(IPPROTO_AH
, "authentication header")
1398 # define IPPROTO_MTP -1
1400 CND(IPPROTO_MTP
, "Multicast Transport Protocol")
1402 #ifndef IPPROTO_BEETPH
1403 # define IPPROTO_BEETPH -1
1405 CND(IPPROTO_BEETPH
, "IP option pseudo header for BEET")
1407 #ifndef IPPROTO_ENCAP
1408 # define IPPROTO_ENCAP -1
1410 CND(IPPROTO_ENCAP
, "Encapsulation Header")
1413 # define IPPROTO_PIM -1
1415 CND(IPPROTO_PIM
, "Protocol Independent Multicast")
1417 #ifndef IPPROTO_COMP
1418 # define IPPROTO_COMP -1
1420 CND(IPPROTO_COMP
, "Compression Header Protocol")
1422 #ifndef IPPROTO_SCTP
1423 # define IPPROTO_SCTP -1
1425 CND(IPPROTO_SCTP
, "Stream Control Transmission Protocol")
1427 #ifndef IPPROTO_UDPLITE
1428 # define IPPROTO_UDPLITE -1
1430 CND(IPPROTO_UDPLITE
, "UDP-Lite protocol")
1432 #ifndef IPPROTO_MPLS
1433 # define IPPROTO_MPLS -1
1435 CND(IPPROTO_MPLS
, "MPLS in IP")
1438 # define IPPROTO_RAW -1
1440 CND(IPPROTO_RAW
, "Raw IP packets")
1453 CND(MSG_OOB
, "Process out-of-band data")
1456 # define MSG_PEEK -1
1458 CND(MSG_PEEK
, "Peek at incoming data")
1463 CND(MSG_EOR
, "Send end of record")
1466 # define MSG_WAITALL -1
1468 CND(MSG_WAITALL
, "Wait for full reception")
1470 #ifndef MSG_NOSIGNAL
1471 # define MSG_NOSIGNAL -1
1473 CND(MSG_NOSIGNAL
, "No SIGPIPE on send")
1475 #if defined (__linux__) || defined (__ANDROID__) || defined (__QNX__)
1476 # define MSG_Forced_Flags "MSG_NOSIGNAL"
1478 # define MSG_Forced_Flags "0"
1480 CNS(MSG_Forced_Flags
, "")
1482 -- Flags set on all send(2) calls
1487 --------------------
1488 -- Socket options --
1489 --------------------
1494 # define TCP_NODELAY -1
1496 CND(TCP_NODELAY
, "Do not coalesce packets")
1500 /* Windows headers can be too old to have all available constants.
1501 * We know this one. */
1502 # define TCP_KEEPCNT 16
1504 # define TCP_KEEPCNT -1
1507 CND(TCP_KEEPCNT
, "Maximum number of keepalive probes")
1509 #ifndef TCP_KEEPIDLE
1511 /* Windows headers can be too old to have all available constants.
1512 * We know this one. */
1513 # define TCP_KEEPIDLE 3
1515 # define TCP_KEEPIDLE -1
1518 CND(TCP_KEEPIDLE
, "Idle time before TCP starts sending keepalive probes")
1520 #ifndef TCP_KEEPINTVL
1522 /* Windows headers can be too old to have all available constants.
1523 * We know this one. */
1524 # define TCP_KEEPINTVL 17
1526 # define TCP_KEEPINTVL -1
1529 CND(TCP_KEEPINTVL
, "Time between individual keepalive probes")
1531 #ifndef SO_REUSEADDR
1532 # define SO_REUSEADDR -1
1534 CND(SO_REUSEADDR
, "Bind reuse local address")
1536 #ifndef SO_REUSEPORT
1537 # define SO_REUSEPORT -1
1539 CND(SO_REUSEPORT
, "Bind reuse port number")
1541 #ifndef SO_KEEPALIVE
1542 # define SO_KEEPALIVE -1
1544 CND(SO_KEEPALIVE
, "Enable keep-alive msgs")
1547 # define SO_LINGER -1
1549 CND(SO_LINGER
, "Defer close to flush data")
1551 #ifndef SO_BROADCAST
1552 # define SO_BROADCAST -1
1554 CND(SO_BROADCAST
, "Can send broadcast msgs")
1557 # define SO_SNDBUF -1
1559 CND(SO_SNDBUF
, "Set/get send buffer size")
1562 # define SO_RCVBUF -1
1564 CND(SO_RCVBUF
, "Set/get recv buffer size")
1567 # define SO_SNDTIMEO -1
1569 CND(SO_SNDTIMEO
, "Emission timeout")
1572 # define SO_RCVTIMEO -1
1574 CND(SO_RCVTIMEO
, "Reception timeout")
1577 # define SO_ERROR -1
1579 CND(SO_ERROR
, "Get/clear error status")
1581 #ifndef SO_BUSY_POLL
1582 # define SO_BUSY_POLL -1
1584 CND(SO_BUSY_POLL
, "Busy polling")
1586 #ifndef IP_MULTICAST_IF
1587 # define IP_MULTICAST_IF -1
1589 CND(IP_MULTICAST_IF
, "Set/get mcast interface")
1591 #ifndef IP_MULTICAST_TTL
1592 # define IP_MULTICAST_TTL -1
1594 CND(IP_MULTICAST_TTL
, "Set/get multicast TTL")
1596 #ifndef IP_MULTICAST_LOOP
1597 # define IP_MULTICAST_LOOP -1
1599 CND(IP_MULTICAST_LOOP
, "Set/get mcast loopback")
1601 #ifndef IP_ADD_MEMBERSHIP
1602 # define IP_ADD_MEMBERSHIP -1
1604 CND(IP_ADD_MEMBERSHIP
, "Join a multicast group")
1606 #ifndef IP_DROP_MEMBERSHIP
1607 # define IP_DROP_MEMBERSHIP -1
1609 CND(IP_DROP_MEMBERSHIP
, "Leave a multicast group")
1612 # define IP_PKTINFO -1
1614 CND(IP_PKTINFO
, "Get datagram info")
1617 # define IP_RECVERR -1
1619 CND(IP_RECVERR
, "Extended reliable error message passing")
1621 #ifndef IPV6_ADDRFORM
1622 # define IPV6_ADDRFORM -1
1624 CND(IPV6_ADDRFORM
, "Turn IPv6 socket into different address family")
1626 #ifndef IPV6_ADD_MEMBERSHIP
1627 # define IPV6_ADD_MEMBERSHIP -1
1629 CND(IPV6_ADD_MEMBERSHIP
, "Join IPv6 multicast group")
1631 #ifndef IPV6_DROP_MEMBERSHIP
1632 # define IPV6_DROP_MEMBERSHIP -1
1634 CND(IPV6_DROP_MEMBERSHIP
, "Leave IPv6 multicast group")
1637 # define IPV6_MTU -1
1639 CND(IPV6_MTU
, "Set/get MTU used for the socket")
1641 #ifndef IPV6_MTU_DISCOVER
1642 # define IPV6_MTU_DISCOVER -1
1644 CND(IPV6_MTU_DISCOVER
, "Control path-MTU discovery on the socket")
1646 #ifndef IPV6_MULTICAST_HOPS
1647 # define IPV6_MULTICAST_HOPS -1
1649 CND(IPV6_MULTICAST_HOPS
, "Set the multicast hop limit for the socket")
1651 #ifndef IPV6_MULTICAST_IF
1652 # define IPV6_MULTICAST_IF -1
1654 CND(IPV6_MULTICAST_IF
, "Set/get IPv6 mcast interface")
1656 #ifndef IPV6_MULTICAST_LOOP
1657 # define IPV6_MULTICAST_LOOP -1
1659 CND(IPV6_MULTICAST_LOOP
, "Set/get mcast loopback")
1661 #ifndef IPV6_RECVPKTINFO
1662 # define IPV6_RECVPKTINFO -1
1664 CND(IPV6_RECVPKTINFO
, "Set delivery of the IPV6_PKTINFO")
1666 #ifndef IPV6_PKTINFO
1667 # define IPV6_PKTINFO -1
1669 CND(IPV6_PKTINFO
, "Get IPv6datagram info")
1672 # define IPV6_RTHDR -1
1674 CND(IPV6_RTHDR
, "Set the routing header delivery")
1676 #ifndef IPV6_AUTHHDR
1677 # define IPV6_AUTHHDR -1
1679 CND(IPV6_AUTHHDR
, "Set the authentication header delivery")
1681 #ifndef IPV6_DSTOPTS
1682 # define IPV6_DSTOPTS -1
1684 CND(IPV6_DSTOPTS
, "Set the destination options delivery")
1686 #ifndef IPV6_HOPOPTS
1687 # define IPV6_HOPOPTS -1
1689 CND(IPV6_HOPOPTS
, "Set the hop options delivery")
1691 #ifndef IPV6_FLOWINFO
1693 /* The IPV6_FLOWINFO is defined in linux/in6.h, but we can't include it because
1694 * of conflicts with other headers. */
1695 # define IPV6_FLOWINFO 11
1697 # define IPV6_FLOWINFO -1
1700 CND(IPV6_FLOWINFO
, "Set the flow ID delivery")
1702 #ifndef IPV6_HOPLIMIT
1703 # define IPV6_HOPLIMIT -1
1705 CND(IPV6_HOPLIMIT
, "Set the hop count of the packet delivery")
1707 #ifndef IPV6_RECVERR
1708 # define IPV6_RECVERR -1
1710 CND(IPV6_RECVERR
, "Extended reliable error message passing")
1712 #ifndef IPV6_ROUTER_ALERT
1713 # define IPV6_ROUTER_ALERT -1
1715 CND(IPV6_ROUTER_ALERT
, "Pass forwarded router alert hop-by-hop option")
1717 #ifndef IPV6_UNICAST_HOPS
1718 # define IPV6_UNICAST_HOPS -1
1720 CND(IPV6_UNICAST_HOPS
, "Set the unicast hop limit")
1723 # define IPV6_V6ONLY -1
1725 CND(IPV6_V6ONLY
, "Restricted to IPv6 communications only")
1729 ----------------------
1730 -- Type definitions --
1731 ----------------------
1738 -- Sizes (in bytes) of the components of struct timeval
1740 #define SIZEOF_tv_sec (sizeof tv.tv_sec)
1741 CND(SIZEOF_tv_sec
, "tv_sec")
1742 #define SIZEOF_tv_usec (sizeof tv.tv_usec)
1743 CND(SIZEOF_tv_usec
, "tv_usec")
1746 -- Maximum allowed value for tv_sec
1750 ** On Solaris, field tv_sec in struct timeval has an undocumented
1751 ** hard-wired limit of 100 million.
1752 ** On IA64 HP-UX the limit is 2**31 - 1.
1754 #if defined (__sun__)
1755 # define MAX_tv_sec "100_000_000"
1757 #elif defined (__hpux__)
1758 # define MAX_tv_sec "16#7fffffff#"
1761 # define MAX_tv_sec "2 ** (SIZEOF_tv_sec * 8 - 1) - 1"
1767 -- Sizes of various data types
1770 #define SIZEOF_sockaddr_in (sizeof (struct sockaddr_in))
1771 CND(SIZEOF_sockaddr_in
, "struct sockaddr_in")
1772 #ifdef HAVE_AF_INET6
1773 # define SIZEOF_sockaddr_in6 (sizeof (struct sockaddr_in6))
1775 # define SIZEOF_sockaddr_in6 0
1777 CND(SIZEOF_sockaddr_in6
, "struct sockaddr_in6")
1780 ** The sockaddr_un structure is not defined in MINGW C headers
1781 ** but Windows supports it from build 17063.
1783 #if defined(__MINGW32__)
1784 struct sockaddr_un
{
1785 ADDRESS_FAMILY sun_family
; /* AF_UNIX */
1786 char sun_path
[108]; /* Pathname */
1789 #define SIZEOF_sockaddr_un (sizeof (struct sockaddr_un))
1790 CND(SIZEOF_sockaddr_un
, "struct sockaddr_un")
1792 #define SIZEOF_fd_set (sizeof (fd_set))
1793 CND(SIZEOF_fd_set
, "fd_set")
1794 CND(FD_SETSIZE
, "Max fd value")
1796 #define SIZEOF_struct_hostent (sizeof (struct hostent))
1797 CND(SIZEOF_struct_hostent
, "struct hostent")
1799 #define SIZEOF_struct_servent (sizeof (struct servent))
1800 CND(SIZEOF_struct_servent
, "struct servent")
1802 #if defined (__linux__) || defined (__ANDROID__) || defined (__QNX__)
1803 #define SIZEOF_sigset (sizeof (sigset_t))
1804 CND(SIZEOF_sigset
, "sigset")
1807 #if defined(_WIN32) || defined(__vxworks)
1808 #define SIZEOF_nfds_t sizeof (int) * 8
1809 #define SIZEOF_socklen_t sizeof (size_t)
1810 #elif defined(__Lynx__)
1811 #define SIZEOF_nfds_t sizeof (unsigned long int) * 8
1812 #define SIZEOF_socklen_t sizeof (socklen_t)
1814 #define SIZEOF_nfds_t sizeof (nfds_t) * 8
1815 #define SIZEOF_socklen_t sizeof (socklen_t)
1817 CND(SIZEOF_nfds_t
, "Size of nfds_t");
1818 CND(SIZEOF_socklen_t
, "Size of socklen_t");
1821 #if defined(__vxworks)
1822 #define SIZEOF_fd_type sizeof (int) * 8
1823 #define SIZEOF_pollfd_events sizeof (short) * 8
1825 const struct pollfd v_pollfd
;
1826 #define SIZEOF_fd_type sizeof (v_pollfd.fd) * 8
1827 #define SIZEOF_pollfd_events sizeof (v_pollfd.events) * 8
1829 CND(SIZEOF_fd_type
, "Size of socket fd");
1830 CND(SIZEOF_pollfd_events
, "Size of pollfd.events");
1834 #ifdef IF_MAX_STRING_SIZE
1835 #define IF_NAMESIZE IF_MAX_STRING_SIZE
1837 #define IF_NAMESIZE -1
1840 CND(IF_NAMESIZE
, "Max size of interface name with 0 terminator");
1848 #if defined(__vxworks)
1873 #elif defined(_WIN32)
1875 /* If the POLLPRI flag is set on a socket for the Microsoft Winsock provider,
1876 * the WSAPoll function will fail. */
1879 CND(POLLIN
, "There is data to read");
1880 CND(POLLPRI
, "Urgent data to read");
1881 CND(POLLOUT
, "Writing will not block");
1882 CND(POLLERR
, "Error (output only)");
1883 CND(POLLHUP
, "Hang up (output only)");
1884 CND(POLLNVAL
, "Invalid request");
1888 -- Fields of struct msghdr
1891 #if defined (__sun__) || defined (__hpux__)
1892 # define Msg_Iovlen_T "Interfaces.C.int"
1894 # define Msg_Iovlen_T "Interfaces.C.size_t"
1901 ----------------------------------------
1902 -- Properties of supported interfaces --
1903 ----------------------------------------
1907 CND(Need_Netdb_Buffer
, "Need buffer for Netdb ops")
1908 CND(Need_Netdb_Lock
, "Need lock for Netdb ops")
1909 CND(Has_Sockaddr_Len
, "Sockaddr has sa_len field")
1912 ** Do not change the format of the line below without also updating the
1915 C("Thread_Blocking_IO", Boolean
, "True", "")
1917 -- Set False for contexts where socket i/o are process blocking
1921 #ifdef HAVE_INET_PTON
1922 # define Inet_Pton_Linkname "inet_pton"
1924 # define Inet_Pton_Linkname "__gnat_inet_pton"
1926 CST(Inet_Pton_Linkname
, "")
1928 #ifdef HAVE_INET_NTOP
1929 # define Inet_Ntop_Linkname "inet_ntop"
1931 # define Inet_Ntop_Linkname "__gnat_inet_ntop"
1933 CST(Inet_Ntop_Linkname
, "")
1936 # define Poll_Linkname "WSAPoll"
1938 # define Poll_Linkname "poll"
1940 CST(Poll_Linkname
, "")
1942 #endif /* HAVE_SOCKETS */
1946 ---------------------
1947 -- Threads support --
1948 ---------------------
1950 -- Clock identifier definitions
1954 /* Note: On HP-UX, CLOCK_REALTIME is an enum, not a macro. */
1956 #if !(defined(CLOCK_REALTIME) || defined (__hpux__))
1957 # define CLOCK_REALTIME (-1)
1959 CND(CLOCK_REALTIME
, "System realtime clock")
1961 #ifdef CLOCK_MONOTONIC
1962 CND(CLOCK_MONOTONIC
, "System monotonic clock")
1965 #ifdef CLOCK_FASTEST
1966 CND(CLOCK_FASTEST
, "Fastest clock")
1969 #ifndef CLOCK_THREAD_CPUTIME_ID
1970 # define CLOCK_THREAD_CPUTIME_ID -1
1972 CND(CLOCK_THREAD_CPUTIME_ID
, "Thread CPU clock")
1974 #if defined(__linux__) || defined(__FreeBSD__) \
1975 || (defined(_AIX) && defined(_AIXVERSION_530)) \
1976 || defined(__DragonFly__) || defined(__QNX__)
1977 /** On these platforms use system provided monotonic clock instead of
1978 ** the default CLOCK_REALTIME. We then need to set up cond var attributes
1979 ** appropriately (see thread.c).
1981 ** Note that AIX 5.2 does not support CLOCK_MONOTONIC timestamps for
1982 ** pthread_cond_timedwait (and does not have pthread_condattr_setclock),
1983 ** hence the conditionalization on AIX version above). _AIXVERSION_530
1984 ** is defined in AIX 5.3 and more recent versions.
1986 # define CLOCK_RT_Ada "CLOCK_MONOTONIC"
1989 /* By default use CLOCK_REALTIME */
1990 # define CLOCK_RT_Ada "CLOCK_REALTIME"
1994 CNS(CLOCK_RT_Ada
, "")
1997 #if defined (__APPLE__) || defined (__linux__) || defined (__ANDROID__) \
1998 || defined (__QNX__) || defined (__rtems__) || defined (DUMMY)
2001 -- Sizes of pthread data types
2004 #if defined (__APPLE__) || defined (DUMMY)
2006 -- (on Darwin, these are just placeholders)
2008 #define PTHREAD_SIZE __PTHREAD_SIZE__
2009 #define PTHREAD_ATTR_SIZE __PTHREAD_ATTR_SIZE__
2010 #define PTHREAD_MUTEXATTR_SIZE __PTHREAD_MUTEXATTR_SIZE__
2011 #define PTHREAD_MUTEX_SIZE __PTHREAD_MUTEX_SIZE__
2012 #define PTHREAD_CONDATTR_SIZE __PTHREAD_CONDATTR_SIZE__
2013 #define PTHREAD_COND_SIZE __PTHREAD_COND_SIZE__
2014 #define PTHREAD_RWLOCKATTR_SIZE __PTHREAD_RWLOCKATTR_SIZE__
2015 #define PTHREAD_RWLOCK_SIZE __PTHREAD_RWLOCK_SIZE__
2016 #define PTHREAD_ONCE_SIZE __PTHREAD_ONCE_SIZE__
2018 #define PTHREAD_SIZE (sizeof (pthread_t))
2019 #define PTHREAD_ATTR_SIZE (sizeof (pthread_attr_t))
2020 #define PTHREAD_MUTEXATTR_SIZE (sizeof (pthread_mutexattr_t))
2021 #define PTHREAD_MUTEX_SIZE (sizeof (pthread_mutex_t))
2022 #define PTHREAD_CONDATTR_SIZE (sizeof (pthread_condattr_t))
2023 #define PTHREAD_COND_SIZE (sizeof (pthread_cond_t))
2024 #define PTHREAD_RWLOCKATTR_SIZE (sizeof (pthread_rwlockattr_t))
2025 #define PTHREAD_RWLOCK_SIZE (sizeof (pthread_rwlock_t))
2026 #define PTHREAD_ONCE_SIZE (sizeof (pthread_once_t))
2031 CND(PTHREAD_SIZE
, "pthread_t")
2032 CND(PTHREAD_ATTR_SIZE
, "pthread_attr_t")
2033 CND(PTHREAD_MUTEXATTR_SIZE
, "pthread_mutexattr_t")
2034 CND(PTHREAD_MUTEX_SIZE
, "pthread_mutex_t")
2035 CND(PTHREAD_CONDATTR_SIZE
, "pthread_condattr_t")
2036 CND(PTHREAD_COND_SIZE
, "pthread_cond_t")
2037 CND(PTHREAD_RWLOCKATTR_SIZE
, "pthread_rwlockattr_t")
2038 CND(PTHREAD_RWLOCK_SIZE
, "pthread_rwlock_t")
2039 CND(PTHREAD_ONCE_SIZE
, "pthread_once_t")
2041 #endif /* __APPLE__ || __linux__ || __ANDROID__ || __rtems__ */
2045 --------------------------------
2046 -- File and directory support --
2047 --------------------------------
2052 ** Note: this constant can be used in the GNAT runtime library. In compiler
2053 ** units on the other hand, System.OS_Constants is not available, so we
2054 ** declare an Ada constant (Osint.File_Attributes_Size) independently, which
2055 ** is at least as large as sizeof (struct file_attributes), and we have an
2056 ** assertion at initialization of Osint checking that the size is indeed at
2057 ** least sufficient.
2059 #define SIZEOF_struct_file_attributes (sizeof (struct file_attributes))
2060 CND(SIZEOF_struct_file_attributes
, "struct file_attributes")
2063 ** Maximal size of buffer for struct dirent. Note: Since POSIX.1 does not
2064 ** specify the size of the d_name field, and other nonstandard fields may
2065 ** precede that field within the dirent structure, we must make a conservative
2070 #define SIZEOF_struct_dirent_alloc \
2071 ((char*) &dent.d_name - (char*) &dent) + NAME_MAX + 1
2072 CND(SIZEOF_struct_dirent_alloc
, "struct dirent allocation")
2076 ** System-specific constants follow
2077 ** Each section should be activated if compiling for the corresponding
2078 ** platform *or* generating the dummy version for runtime test compilation.
2081 #if defined (__vxworks) || defined (DUMMY)
2085 --------------------------------
2086 -- VxWorks-specific constants --
2087 --------------------------------
2089 -- These constants may be used only within the VxWorks version of
2090 -- GNAT.Sockets.Thin.
2093 CND(OK
, "VxWorks generic success")
2094 CND(ERROR
, "VxWorks generic error")
2096 #endif /* __vxworks */
2098 #if defined (__MINGW32__) || defined (DUMMY)
2101 ------------------------------
2102 -- MinGW-specific constants --
2103 ------------------------------
2105 -- These constants may be used only within the MinGW version of
2106 -- GNAT.Sockets.Thin.
2109 CND(WSASYSNOTREADY
, "System not ready")
2110 CND(WSAVERNOTSUPPORTED
, "Version not supported")
2111 CND(WSANOTINITIALISED
, "Winsock not initialized")
2112 CND(WSAEDISCON
, "Disconnected")
2114 #endif /* __MINGW32__ */
2117 ** End of constants definitions
2126 end System.OS_Constants;