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-2020, 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")
1467 /* The value of MSG_WAITALL is 8. Nevertheless winsock.h doesn't
1468 define it, but it is still usable as we link to winsock2 API. */
1469 # define MSG_WAITALL (1 << 3)
1471 # define MSG_WAITALL -1
1474 CND(MSG_WAITALL
, "Wait for full reception")
1476 #ifndef MSG_NOSIGNAL
1477 # define MSG_NOSIGNAL -1
1479 CND(MSG_NOSIGNAL
, "No SIGPIPE on send")
1481 #if defined (__linux__) || defined (__ANDROID__) || defined (__QNX__)
1482 # define MSG_Forced_Flags "MSG_NOSIGNAL"
1484 # define MSG_Forced_Flags "0"
1486 CNS(MSG_Forced_Flags
, "")
1488 -- Flags set on all send(2) calls
1493 --------------------
1494 -- Socket options --
1495 --------------------
1500 # define TCP_NODELAY -1
1502 CND(TCP_NODELAY
, "Do not coalesce packets")
1504 #ifndef SO_REUSEADDR
1505 # define SO_REUSEADDR -1
1507 CND(SO_REUSEADDR
, "Bind reuse local address")
1509 #ifndef SO_REUSEPORT
1510 # define SO_REUSEPORT -1
1512 CND(SO_REUSEPORT
, "Bind reuse port number")
1514 #ifndef SO_KEEPALIVE
1515 # define SO_KEEPALIVE -1
1517 CND(SO_KEEPALIVE
, "Enable keep-alive msgs")
1520 # define SO_LINGER -1
1522 CND(SO_LINGER
, "Defer close to flush data")
1524 #ifndef SO_BROADCAST
1525 # define SO_BROADCAST -1
1527 CND(SO_BROADCAST
, "Can send broadcast msgs")
1530 # define SO_SNDBUF -1
1532 CND(SO_SNDBUF
, "Set/get send buffer size")
1535 # define SO_RCVBUF -1
1537 CND(SO_RCVBUF
, "Set/get recv buffer size")
1540 # define SO_SNDTIMEO -1
1542 CND(SO_SNDTIMEO
, "Emission timeout")
1545 # define SO_RCVTIMEO -1
1547 CND(SO_RCVTIMEO
, "Reception timeout")
1550 # define SO_ERROR -1
1552 CND(SO_ERROR
, "Get/clear error status")
1554 #ifndef SO_BUSY_POLL
1555 # define SO_BUSY_POLL -1
1557 CND(SO_BUSY_POLL
, "Busy polling")
1559 #ifndef IP_MULTICAST_IF
1560 # define IP_MULTICAST_IF -1
1562 CND(IP_MULTICAST_IF
, "Set/get mcast interface")
1564 #ifndef IP_MULTICAST_TTL
1565 # define IP_MULTICAST_TTL -1
1567 CND(IP_MULTICAST_TTL
, "Set/get multicast TTL")
1569 #ifndef IP_MULTICAST_LOOP
1570 # define IP_MULTICAST_LOOP -1
1572 CND(IP_MULTICAST_LOOP
, "Set/get mcast loopback")
1574 #ifndef IP_ADD_MEMBERSHIP
1575 # define IP_ADD_MEMBERSHIP -1
1577 CND(IP_ADD_MEMBERSHIP
, "Join a multicast group")
1579 #ifndef IP_DROP_MEMBERSHIP
1580 # define IP_DROP_MEMBERSHIP -1
1582 CND(IP_DROP_MEMBERSHIP
, "Leave a multicast group")
1585 # define IP_PKTINFO -1
1587 CND(IP_PKTINFO
, "Get datagram info")
1590 # define IP_RECVERR -1
1592 CND(IP_RECVERR
, "Extended reliable error message passing")
1594 #ifndef IPV6_ADDRFORM
1595 # define IPV6_ADDRFORM -1
1597 CND(IPV6_ADDRFORM
, "Turn IPv6 socket into different address family")
1599 #ifndef IPV6_ADD_MEMBERSHIP
1600 # define IPV6_ADD_MEMBERSHIP -1
1602 CND(IPV6_ADD_MEMBERSHIP
, "Join IPv6 multicast group")
1604 #ifndef IPV6_DROP_MEMBERSHIP
1605 # define IPV6_DROP_MEMBERSHIP -1
1607 CND(IPV6_DROP_MEMBERSHIP
, "Leave IPv6 multicast group")
1610 # define IPV6_MTU -1
1612 CND(IPV6_MTU
, "Set/get MTU used for the socket")
1614 #ifndef IPV6_MTU_DISCOVER
1615 # define IPV6_MTU_DISCOVER -1
1617 CND(IPV6_MTU_DISCOVER
, "Control path-MTU discovery on the socket")
1619 #ifndef IPV6_MULTICAST_HOPS
1620 # define IPV6_MULTICAST_HOPS -1
1622 CND(IPV6_MULTICAST_HOPS
, "Set the multicast hop limit for the socket")
1624 #ifndef IPV6_MULTICAST_IF
1625 # define IPV6_MULTICAST_IF -1
1627 CND(IPV6_MULTICAST_IF
, "Set/get IPv6 mcast interface")
1629 #ifndef IPV6_MULTICAST_LOOP
1630 # define IPV6_MULTICAST_LOOP -1
1632 CND(IPV6_MULTICAST_LOOP
, "Set/get mcast loopback")
1634 #ifndef IPV6_RECVPKTINFO
1635 # define IPV6_RECVPKTINFO -1
1637 CND(IPV6_RECVPKTINFO
, "Set delivery of the IPV6_PKTINFO")
1639 #ifndef IPV6_PKTINFO
1640 # define IPV6_PKTINFO -1
1642 CND(IPV6_PKTINFO
, "Get IPv6datagram info")
1645 # define IPV6_RTHDR -1
1647 CND(IPV6_RTHDR
, "Set the routing header delivery")
1649 #ifndef IPV6_AUTHHDR
1650 # define IPV6_AUTHHDR -1
1652 CND(IPV6_AUTHHDR
, "Set the authentication header delivery")
1654 #ifndef IPV6_DSTOPTS
1655 # define IPV6_DSTOPTS -1
1657 CND(IPV6_DSTOPTS
, "Set the destination options delivery")
1659 #ifndef IPV6_HOPOPTS
1660 # define IPV6_HOPOPTS -1
1662 CND(IPV6_HOPOPTS
, "Set the hop options delivery")
1664 #ifndef IPV6_FLOWINFO
1665 # define IPV6_FLOWINFO -1
1667 CND(IPV6_FLOWINFO
, "Set the flow ID delivery")
1669 #ifndef IPV6_HOPLIMIT
1670 # define IPV6_HOPLIMIT -1
1672 CND(IPV6_HOPLIMIT
, "Set the hop count of the packet delivery")
1674 #ifndef IPV6_RECVERR
1675 # define IPV6_RECVERR -1
1677 CND(IPV6_RECVERR
, "Extended reliable error message passing")
1679 #ifndef IPV6_ROUTER_ALERT
1680 # define IPV6_ROUTER_ALERT -1
1682 CND(IPV6_ROUTER_ALERT
, "Pass forwarded router alert hop-by-hop option")
1684 #ifndef IPV6_UNICAST_HOPS
1685 # define IPV6_UNICAST_HOPS -1
1687 CND(IPV6_UNICAST_HOPS
, "Set the unicast hop limit")
1690 # define IPV6_V6ONLY -1
1692 CND(IPV6_V6ONLY
, "Restricted to IPv6 communications only")
1696 ----------------------
1697 -- Type definitions --
1698 ----------------------
1705 -- Sizes (in bytes) of the components of struct timeval
1707 #define SIZEOF_tv_sec (sizeof tv.tv_sec)
1708 CND(SIZEOF_tv_sec
, "tv_sec")
1709 #define SIZEOF_tv_usec (sizeof tv.tv_usec)
1710 CND(SIZEOF_tv_usec
, "tv_usec")
1713 -- Maximum allowed value for tv_sec
1717 ** On Solaris, field tv_sec in struct timeval has an undocumented
1718 ** hard-wired limit of 100 million.
1719 ** On IA64 HP-UX the limit is 2**31 - 1.
1721 #if defined (__sun__)
1722 # define MAX_tv_sec "100_000_000"
1724 #elif defined (__hpux__)
1725 # define MAX_tv_sec "16#7fffffff#"
1728 # define MAX_tv_sec "2 ** (SIZEOF_tv_sec * 8 - 1) - 1"
1734 -- Sizes of various data types
1737 #define SIZEOF_sockaddr_in (sizeof (struct sockaddr_in))
1738 CND(SIZEOF_sockaddr_in
, "struct sockaddr_in")
1739 #ifdef HAVE_AF_INET6
1740 # define SIZEOF_sockaddr_in6 (sizeof (struct sockaddr_in6))
1742 # define SIZEOF_sockaddr_in6 0
1744 CND(SIZEOF_sockaddr_in6
, "struct sockaddr_in6")
1747 ** The sockaddr_un structure is not defined in MINGW C headers
1748 ** but Windows supports it from build 17063.
1750 #if defined(__MINGW32__)
1751 struct sockaddr_un
{
1752 ADDRESS_FAMILY sun_family
; /* AF_UNIX */
1753 char sun_path
[108]; /* Pathname */
1756 #define SIZEOF_sockaddr_un (sizeof (struct sockaddr_un))
1757 CND(SIZEOF_sockaddr_un
, "struct sockaddr_un")
1759 #define SIZEOF_fd_set (sizeof (fd_set))
1760 CND(SIZEOF_fd_set
, "fd_set")
1761 CND(FD_SETSIZE
, "Max fd value")
1763 #define SIZEOF_struct_hostent (sizeof (struct hostent))
1764 CND(SIZEOF_struct_hostent
, "struct hostent")
1766 #define SIZEOF_struct_servent (sizeof (struct servent))
1767 CND(SIZEOF_struct_servent
, "struct servent")
1769 #if defined (__linux__) || defined (__ANDROID__) || defined (__QNX__)
1770 #define SIZEOF_sigset (sizeof (sigset_t))
1771 CND(SIZEOF_sigset
, "sigset")
1774 #if defined(_WIN32) || defined(__vxworks)
1775 #define SIZEOF_nfds_t sizeof (int) * 8
1776 #define SIZEOF_socklen_t sizeof (size_t)
1777 #elif defined(__Lynx__)
1778 #define SIZEOF_nfds_t sizeof (unsigned long int) * 8
1779 #define SIZEOF_socklen_t sizeof (socklen_t)
1781 #define SIZEOF_nfds_t sizeof (nfds_t) * 8
1782 #define SIZEOF_socklen_t sizeof (socklen_t)
1784 CND(SIZEOF_nfds_t
, "Size of nfds_t");
1785 CND(SIZEOF_socklen_t
, "Size of socklen_t");
1788 #if defined(__vxworks)
1789 #define SIZEOF_fd_type sizeof (int) * 8
1790 #define SIZEOF_pollfd_events sizeof (short) * 8
1792 const struct pollfd v_pollfd
;
1793 #define SIZEOF_fd_type sizeof (v_pollfd.fd) * 8
1794 #define SIZEOF_pollfd_events sizeof (v_pollfd.events) * 8
1796 CND(SIZEOF_fd_type
, "Size of socket fd");
1797 CND(SIZEOF_pollfd_events
, "Size of pollfd.events");
1801 #ifdef IF_MAX_STRING_SIZE
1802 #define IF_NAMESIZE IF_MAX_STRING_SIZE
1804 #define IF_NAMESIZE -1
1807 CND(IF_NAMESIZE
, "Max size of interface name with 0 terminator");
1815 #if defined(__vxworks)
1840 #elif defined(_WIN32)
1842 /* If the POLLPRI flag is set on a socket for the Microsoft Winsock provider,
1843 * the WSAPoll function will fail. */
1846 CND(POLLIN
, "There is data to read");
1847 CND(POLLPRI
, "Urgent data to read");
1848 CND(POLLOUT
, "Writing will not block");
1849 CND(POLLERR
, "Error (output only)");
1850 CND(POLLHUP
, "Hang up (output only)");
1851 CND(POLLNVAL
, "Invalid request");
1855 -- Fields of struct msghdr
1858 #if defined (__sun__) || defined (__hpux__)
1859 # define Msg_Iovlen_T "Interfaces.C.int"
1861 # define Msg_Iovlen_T "Interfaces.C.size_t"
1868 ----------------------------------------
1869 -- Properties of supported interfaces --
1870 ----------------------------------------
1874 CND(Need_Netdb_Buffer
, "Need buffer for Netdb ops")
1875 CND(Need_Netdb_Lock
, "Need lock for Netdb ops")
1876 CND(Has_Sockaddr_Len
, "Sockaddr has sa_len field")
1879 ** Do not change the format of the line below without also updating the
1882 C("Thread_Blocking_IO", Boolean
, "True", "")
1884 -- Set False for contexts where socket i/o are process blocking
1888 #ifdef HAVE_INET_PTON
1889 # define Inet_Pton_Linkname "inet_pton"
1891 # define Inet_Pton_Linkname "__gnat_inet_pton"
1893 CST(Inet_Pton_Linkname
, "")
1895 #ifdef HAVE_INET_NTOP
1896 # define Inet_Ntop_Linkname "inet_ntop"
1898 # define Inet_Ntop_Linkname "__gnat_inet_ntop"
1900 CST(Inet_Ntop_Linkname
, "")
1903 # define Poll_Linkname "WSAPoll"
1905 # define Poll_Linkname "poll"
1907 CST(Poll_Linkname
, "")
1909 #endif /* HAVE_SOCKETS */
1913 ---------------------
1914 -- Threads support --
1915 ---------------------
1917 -- Clock identifier definitions
1921 /* Note: On HP-UX, CLOCK_REALTIME is an enum, not a macro. */
1923 #if !(defined(CLOCK_REALTIME) || defined (__hpux__))
1924 # define CLOCK_REALTIME (-1)
1926 CND(CLOCK_REALTIME
, "System realtime clock")
1928 #ifdef CLOCK_MONOTONIC
1929 CND(CLOCK_MONOTONIC
, "System monotonic clock")
1932 #ifdef CLOCK_FASTEST
1933 CND(CLOCK_FASTEST
, "Fastest clock")
1936 #ifndef CLOCK_THREAD_CPUTIME_ID
1937 # define CLOCK_THREAD_CPUTIME_ID -1
1939 CND(CLOCK_THREAD_CPUTIME_ID
, "Thread CPU clock")
1941 #if defined(__linux__) || defined(__FreeBSD__) \
1942 || (defined(_AIX) && defined(_AIXVERSION_530)) \
1943 || defined(__DragonFly__) || defined(__QNX__)
1944 /** On these platforms use system provided monotonic clock instead of
1945 ** the default CLOCK_REALTIME. We then need to set up cond var attributes
1946 ** appropriately (see thread.c).
1948 ** Note that AIX 5.2 does not support CLOCK_MONOTONIC timestamps for
1949 ** pthread_cond_timedwait (and does not have pthread_condattr_setclock),
1950 ** hence the conditionalization on AIX version above). _AIXVERSION_530
1951 ** is defined in AIX 5.3 and more recent versions.
1953 # define CLOCK_RT_Ada "CLOCK_MONOTONIC"
1956 /* By default use CLOCK_REALTIME */
1957 # define CLOCK_RT_Ada "CLOCK_REALTIME"
1961 CNS(CLOCK_RT_Ada
, "")
1964 #if defined (__APPLE__) || defined (__linux__) || defined (__ANDROID__) \
1965 || defined (__QNX__) || defined (__rtems__) || defined (DUMMY)
1968 -- Sizes of pthread data types
1971 #if defined (__APPLE__) || defined (DUMMY)
1973 -- (on Darwin, these are just placeholders)
1975 #define PTHREAD_SIZE __PTHREAD_SIZE__
1976 #define PTHREAD_ATTR_SIZE __PTHREAD_ATTR_SIZE__
1977 #define PTHREAD_MUTEXATTR_SIZE __PTHREAD_MUTEXATTR_SIZE__
1978 #define PTHREAD_MUTEX_SIZE __PTHREAD_MUTEX_SIZE__
1979 #define PTHREAD_CONDATTR_SIZE __PTHREAD_CONDATTR_SIZE__
1980 #define PTHREAD_COND_SIZE __PTHREAD_COND_SIZE__
1981 #define PTHREAD_RWLOCKATTR_SIZE __PTHREAD_RWLOCKATTR_SIZE__
1982 #define PTHREAD_RWLOCK_SIZE __PTHREAD_RWLOCK_SIZE__
1983 #define PTHREAD_ONCE_SIZE __PTHREAD_ONCE_SIZE__
1985 #define PTHREAD_SIZE (sizeof (pthread_t))
1986 #define PTHREAD_ATTR_SIZE (sizeof (pthread_attr_t))
1987 #define PTHREAD_MUTEXATTR_SIZE (sizeof (pthread_mutexattr_t))
1988 #define PTHREAD_MUTEX_SIZE (sizeof (pthread_mutex_t))
1989 #define PTHREAD_CONDATTR_SIZE (sizeof (pthread_condattr_t))
1990 #define PTHREAD_COND_SIZE (sizeof (pthread_cond_t))
1991 #define PTHREAD_RWLOCKATTR_SIZE (sizeof (pthread_rwlockattr_t))
1992 #define PTHREAD_RWLOCK_SIZE (sizeof (pthread_rwlock_t))
1993 #define PTHREAD_ONCE_SIZE (sizeof (pthread_once_t))
1998 CND(PTHREAD_SIZE
, "pthread_t")
1999 CND(PTHREAD_ATTR_SIZE
, "pthread_attr_t")
2000 CND(PTHREAD_MUTEXATTR_SIZE
, "pthread_mutexattr_t")
2001 CND(PTHREAD_MUTEX_SIZE
, "pthread_mutex_t")
2002 CND(PTHREAD_CONDATTR_SIZE
, "pthread_condattr_t")
2003 CND(PTHREAD_COND_SIZE
, "pthread_cond_t")
2004 CND(PTHREAD_RWLOCKATTR_SIZE
, "pthread_rwlockattr_t")
2005 CND(PTHREAD_RWLOCK_SIZE
, "pthread_rwlock_t")
2006 CND(PTHREAD_ONCE_SIZE
, "pthread_once_t")
2008 #endif /* __APPLE__ || __linux__ || __ANDROID__ || __rtems__ */
2012 --------------------------------
2013 -- File and directory support --
2014 --------------------------------
2019 ** Note: this constant can be used in the GNAT runtime library. In compiler
2020 ** units on the other hand, System.OS_Constants is not available, so we
2021 ** declare an Ada constant (Osint.File_Attributes_Size) independently, which
2022 ** is at least as large as sizeof (struct file_attributes), and we have an
2023 ** assertion at initialization of Osint checking that the size is indeed at
2024 ** least sufficient.
2026 #define SIZEOF_struct_file_attributes (sizeof (struct file_attributes))
2027 CND(SIZEOF_struct_file_attributes
, "struct file_attributes")
2030 ** Maximal size of buffer for struct dirent. Note: Since POSIX.1 does not
2031 ** specify the size of the d_name field, and other nonstandard fields may
2032 ** precede that field within the dirent structure, we must make a conservative
2037 #define SIZEOF_struct_dirent_alloc \
2038 ((char*) &dent.d_name - (char*) &dent) + NAME_MAX + 1
2039 CND(SIZEOF_struct_dirent_alloc
, "struct dirent allocation")
2043 ** System-specific constants follow
2044 ** Each section should be activated if compiling for the corresponding
2045 ** platform *or* generating the dummy version for runtime test compilation.
2048 #if defined (__vxworks) || defined (DUMMY)
2052 --------------------------------
2053 -- VxWorks-specific constants --
2054 --------------------------------
2056 -- These constants may be used only within the VxWorks version of
2057 -- GNAT.Sockets.Thin.
2060 CND(OK
, "VxWorks generic success")
2061 CND(ERROR
, "VxWorks generic error")
2063 #endif /* __vxworks */
2065 #if defined (__MINGW32__) || defined (DUMMY)
2068 ------------------------------
2069 -- MinGW-specific constants --
2070 ------------------------------
2072 -- These constants may be used only within the MinGW version of
2073 -- GNAT.Sockets.Thin.
2076 CND(WSASYSNOTREADY
, "System not ready")
2077 CND(WSAVERNOTSUPPORTED
, "Version not supported")
2078 CND(WSANOTINITIALISED
, "Winsock not initialized")
2079 CND(WSAEDISCON
, "Disconnected")
2081 #endif /* __MINGW32__ */
2084 ** End of constants definitions
2093 end System.OS_Constants;