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-2023, 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 */
241 unsigned int _CRT_fmode
= _O_BINARY
;
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
260 TXT("-- This is the version for " TARGET
)
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;")
268 # define TARGET_OS "Other_OS"
269 # define Serial_Port_Descriptor "Interfaces.C.int"
273 package System.OS_Constants is
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
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
)
319 # define IOV_MAX INT_MAX
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.
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
340 /* Hardcode a reasonably large value as a last chance fallback */
341 # define NAME_MAX 1024
344 CND(NAME_MAX
, "Maximum file name length")
348 ---------------------
349 -- File open modes --
350 ---------------------
357 CND(O_RDWR
, "Read/write")
362 CND(O_NOCTTY
, "Don't change ctrl tty")
367 CND(O_NDELAY
, "Nonblocking")
371 ----------------------
372 -- Fcntl operations --
373 ----------------------
380 CND(F_GETFL
, "Get flags")
385 CND(F_SETFL
, "Set flags")
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__)
412 # define IOCTL_Req_T "Interfaces.C.unsigned"
415 # define IOCTL_Req_T "Interfaces.C.int"
423 CNI(FIONBIO
, "Set/clear non-blocking io")
428 CNI(FIONREAD
, "How many bytes to read")
436 -- The following constants are defined from <errno.h>
442 CND(EAGAIN
, "Try again")
447 CND(ENOENT
, "File not found")
452 CND(ENOMEM
, "Out of memory")
457 -- The following constants are defined from <winsock2.h> (WSA*)
462 ** For sockets-related errno values on Windows, gsocket.h redefines
471 CND(EACCES
, "Permission denied")
474 # define EADDRINUSE -1
476 CND(EADDRINUSE
, "Address already in use")
478 #ifndef EADDRNOTAVAIL
479 # define EADDRNOTAVAIL -1
481 CND(EADDRNOTAVAIL
, "Cannot assign address")
484 # define EAFNOSUPPORT -1
486 CND(EAFNOSUPPORT
, "Addr family not supported")
491 CND(EALREADY
, "Operation in progress")
496 CND(EBADF
, "Bad file descriptor")
499 # define ECONNABORTED -1
501 CND(ECONNABORTED
, "Connection aborted")
504 # define ECONNREFUSED -1
506 CND(ECONNREFUSED
, "Connection refused")
509 # define ECONNRESET -1
511 CND(ECONNRESET
, "Connection reset by peer")
514 # define EDESTADDRREQ -1
516 CND(EDESTADDRREQ
, "Destination addr required")
521 CND(EFAULT
, "Bad address")
524 # define EHOSTDOWN -1
526 CND(EHOSTDOWN
, "Host is down")
529 # define EHOSTUNREACH -1
531 CND(EHOSTUNREACH
, "No route to host")
534 # define EINPROGRESS -1
536 CND(EINPROGRESS
, "Operation now in progress")
541 CND(EINTR
, "Interrupted system call")
546 CND(EINVAL
, "Invalid argument")
551 CND(EIO
, "Input output error")
556 CND(EISCONN
, "Socket already connected")
561 CND(ELOOP
, "Too many symbolic links")
566 CND(EMFILE
, "Too many open files")
571 CND(EMSGSIZE
, "Message too long")
574 # define ENAMETOOLONG -1
576 CND(ENAMETOOLONG
, "Name too long")
581 CND(ENETDOWN
, "Network is down")
584 # define ENETRESET -1
586 CND(ENETRESET
, "Disconn. on network reset")
589 # define ENETUNREACH -1
591 CND(ENETUNREACH
, "Network is unreachable")
596 CND(ENOBUFS
, "No buffer space available")
599 # define ENOPROTOOPT -1
601 CND(ENOPROTOOPT
, "Protocol not available")
606 CND(ENOTCONN
, "Socket not connected")
611 CND(ENOTSOCK
, "Operation on non socket")
614 # define EOPNOTSUPP -1
616 CND(EOPNOTSUPP
, "Operation not supported")
621 CND(EPIPE
, "Broken pipe")
624 # define EPFNOSUPPORT -1
626 CND(EPFNOSUPPORT
, "Unknown protocol family")
628 #ifndef EPROTONOSUPPORT
629 # define EPROTONOSUPPORT -1
631 CND(EPROTONOSUPPORT
, "Unknown protocol")
634 # define EPROTOTYPE -1
636 CND(EPROTOTYPE
, "Unknown protocol type")
641 CND(ERANGE
, "Result too large")
644 # define ESHUTDOWN -1
646 CND(ESHUTDOWN
, "Cannot send once shutdown")
648 #ifndef ESOCKTNOSUPPORT
649 # define ESOCKTNOSUPPORT -1
651 CND(ESOCKTNOSUPPORT
, "Socket type not supported")
654 # define ETIMEDOUT -1
656 CND(ETIMEDOUT
, "Connection timed out")
659 # define ETOOMANYREFS -1
661 CND(ETOOMANYREFS
, "Too many references")
664 # define EWOULDBLOCK -1
666 CND(EWOULDBLOCK
, "Operation would block")
671 CND(E2BIG
, "Argument list too long")
676 CND(EILSEQ
, "Illegal byte sequence")
679 ** Terminal/serial I/O constants
682 #if defined(HAVE_TERMIOS) || defined(__MINGW32__)
685 ----------------------
686 -- Terminal control --
687 ----------------------
697 CND(TCSANOW
, "Immediate")
702 CND(TCIFLUSH
, "Flush input")
707 CNU(IXON
, "Output sw flow control")
717 CNU(CRTSCTS
, "Output hw flow control")
727 CNU(ICANON
, "canonical mode")
732 CNU(CBAUD
, "baud speed mask")
737 CNU(ECHO
, "echo input characters")
742 CNU(ECHOE
, "erase preceding characters")
747 CNU(ECHOK
, "kill character, erases current line")
752 CNU(ECHOCTL
, "echo special characters")
757 CNU(ECHONL
, "force echo NL character")
762 CNU(CS5
, "5 data bits")
767 CNU(CS6
, "6 data bits")
772 CNU(CS7
, "7 data bits")
777 CNU(CS8
, "8 data bits")
782 CNU(CSTOPB
, "2 stop bits")
787 CNU(PARENB
, "Parity enable")
792 CNU(PARODD
, "Parity odd")
842 CNU(B1200
, "1200 bps")
847 CNU(B1800
, "1800 bps")
852 CNU(B2400
, "2400 bps")
857 CNU(B4800
, "4800 bps")
862 CNU(B9600
, "9600 bps")
867 CNU(B19200
, "19200 bps")
872 CNU(B38400
, "38400 bps")
877 CNU(B57600
, "57600 bps")
882 CNU(B115200
, "115200 bps")
887 CNU(B230400
, "230400 bps")
892 CNU(B460800
, "460800 bps")
897 CNU(B500000
, "500000 bps")
902 CNU(B576000
, "576000 bps")
907 CNU(B921600
, "921600 bps")
912 CNU(B1000000
, "1000000 bps")
917 CNU(B1152000
, "1152000 bps")
922 CNU(B1500000
, "1500000 bps")
927 CNU(B2000000
, "2000000 bps")
932 CNU(B2500000
, "2500000 bps")
937 CNU(B3000000
, "3000000 bps")
942 CNU(B3500000
, "3500000 bps")
947 CNU(B4000000
, "4000000 bps")
951 ---------------------------------
952 -- Terminal control characters --
953 ---------------------------------
960 CND(VINTR
, "Interrupt")
985 CND(VTIME
, "Read timeout")
990 CND(VMIN
, "Read min chars")
1000 CND(VSTART
, "Flow control start")
1005 CND(VSTOP
, "Flow control stop")
1010 CND(VSUSP
, "Suspend")
1018 # define VREPRINT -1
1020 CND(VREPRINT
, "Reprint unread")
1023 # define VDISCARD -1
1025 CND(VDISCARD
, "Discard pending")
1030 CND(VWERASE
, "Word erase")
1035 CND(VLNEXT
, "Literal next")
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")
1051 -----------------------------
1052 -- Pseudo terminal library --
1053 -----------------------------
1057 #if defined (__FreeBSD__) || defined (__linux__) || defined (__DragonFly__)
1058 # define PTY_Library "-lutil"
1060 # define PTY_Library ""
1062 CST(PTY_Library
, "for g-exptty")
1065 ** Sockets constants
1081 CND(AF_INET
, "IPv4 address family")
1084 # define AF_INET6 -1
1086 # define HAVE_AF_INET6 1
1088 CND(AF_INET6
, "IPv6 address family")
1093 CND(AF_UNIX
, "Local unix family")
1096 # define AF_UNSPEC -1
1098 # define HAVE_AF_UNSPEC 1
1100 CND(AF_UNSPEC
, "Unspecified address family")
1104 -----------------------------
1105 -- addrinfo fields offsets --
1106 -----------------------------
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)
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
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 ---------------------------------------
1153 # define AI_PASSIVE -1
1155 CND(AI_PASSIVE
, "NULL nodename for accepting")
1157 #ifndef AI_CANONNAME
1158 # define AI_CANONNAME -1
1160 CND(AI_CANONNAME
, "Get the host official name")
1162 #ifndef AI_NUMERICSERV
1163 # define AI_NUMERICSERV -1
1165 CND(AI_NUMERICSERV
, "Service is a numeric string")
1167 #ifndef AI_NUMERICHOST
1168 # define AI_NUMERICHOST -1
1170 CND(AI_NUMERICHOST
, "Node is a numeric IP address")
1172 #ifndef AI_ADDRCONFIG
1173 # define AI_ADDRCONFIG -1
1175 CND(AI_ADDRCONFIG
, "Returns addresses for only locally configured families")
1178 # define AI_V4MAPPED -1
1180 CND(AI_V4MAPPED
, "Returns IPv4 mapped to IPv6")
1185 CND(AI_ALL
, "Change AI_V4MAPPED behavior for unavailavle IPv6 addresses")
1188 # define NI_NAMEREQD -1
1190 CND(NI_NAMEREQD
, "Error if the hostname cannot be determined")
1193 # define NI_DGRAM -1
1195 CND(NI_DGRAM
, "Service is datagram")
1198 # define NI_NOFQDN -1
1200 CND(NI_NOFQDN
, "Return only the hostname part for local hosts")
1202 #ifndef NI_NUMERICSERV
1203 # define NI_NUMERICSERV -1
1205 CND(NI_NUMERICSERV
, "Numeric form of the service")
1207 #ifndef NI_NUMERICHOST
1208 # define NI_NUMERICHOST -1
1210 CND(NI_NUMERICHOST
, "Numeric form of the hostname")
1213 # define NI_MAXHOST -1
1215 CND(NI_MAXHOST
, "Maximum size of hostname")
1218 # define NI_MAXSERV -1
1220 CND(NI_MAXSERV
, "Maximum size of service name")
1223 # define EAI_SYSTEM -1
1225 CND(EAI_SYSTEM
, "Check errno for details")
1236 # define SOCK_STREAM -1
1238 CND(SOCK_STREAM
, "Stream socket")
1241 # define SOCK_DGRAM -1
1243 CND(SOCK_DGRAM
, "Datagram socket")
1246 # define SOCK_RAW -1
1248 CND(SOCK_RAW
, "Raw socket")
1258 #ifndef HOST_NOT_FOUND
1259 # define HOST_NOT_FOUND -1
1261 CND(HOST_NOT_FOUND
, "Unknown host")
1264 # define TRY_AGAIN -1
1266 CND(TRY_AGAIN
, "Host name lookup failure")
1271 CND(NO_DATA
, "No data record for name")
1274 # define NO_RECOVERY -1
1276 CND(NO_RECOVERY
, "Non recoverable errors")
1280 --------------------
1281 -- Shutdown modes --
1282 --------------------
1289 CND(SHUT_RD
, "No more recv")
1294 CND(SHUT_WR
, "No more send")
1297 # define SHUT_RDWR -1
1299 CND(SHUT_RDWR
, "No more recv/send")
1303 ---------------------
1304 -- Protocol levels --
1305 ---------------------
1310 # define SOL_SOCKET -1
1312 CND(SOL_SOCKET
, "Options for socket level")
1315 # define IPPROTO_IP -1
1317 CND(IPPROTO_IP
, "Dummy protocol for IP")
1319 #ifndef IPPROTO_IPV6
1320 # define IPPROTO_IPV6 -1
1322 CND(IPPROTO_IPV6
, "IPv6 socket option level")
1325 # define IPPROTO_UDP -1
1327 CND(IPPROTO_UDP
, "UDP")
1330 # define IPPROTO_TCP -1
1332 CND(IPPROTO_TCP
, "TCP")
1334 #ifndef IPPROTO_ICMP
1335 # define IPPROTO_ICMP -1
1337 CND(IPPROTO_ICMP
, "Internet Control Message Protocol")
1339 #ifndef IPPROTO_IGMP
1340 # define IPPROTO_IGMP -1
1342 CND(IPPROTO_IGMP
, "Internet Group Management Protocol")
1344 #ifndef IPPROTO_IPIP
1345 # define IPPROTO_IPIP -1
1347 CND(IPPROTO_IPIP
, "IPIP tunnels (older KA9Q tunnels use 94)")
1350 # define IPPROTO_EGP -1
1352 CND(IPPROTO_EGP
, "Exterior Gateway Protocol")
1355 # define IPPROTO_PUP -1
1357 CND(IPPROTO_PUP
, "PUP protocol")
1360 # define IPPROTO_IDP -1
1362 CND(IPPROTO_IDP
, "XNS IDP protocol")
1365 # define IPPROTO_TP -1
1367 CND(IPPROTO_TP
, "SO Transport Protocol Class 4")
1369 #ifndef IPPROTO_DCCP
1370 # define IPPROTO_DCCP -1
1372 CND(IPPROTO_DCCP
, "Datagram Congestion Control Protocol")
1374 #ifndef IPPROTO_RSVP
1375 # define IPPROTO_RSVP -1
1377 CND(IPPROTO_RSVP
, "Reservation Protocol")
1380 # define IPPROTO_GRE -1
1382 CND(IPPROTO_GRE
, "General Routing Encapsulation")
1385 # define IPPROTO_ESP -1
1387 CND(IPPROTO_ESP
, "encapsulating security payload")
1390 # define IPPROTO_AH -1
1392 CND(IPPROTO_AH
, "authentication header")
1395 # define IPPROTO_MTP -1
1397 CND(IPPROTO_MTP
, "Multicast Transport Protocol")
1399 #ifndef IPPROTO_BEETPH
1400 # define IPPROTO_BEETPH -1
1402 CND(IPPROTO_BEETPH
, "IP option pseudo header for BEET")
1404 #ifndef IPPROTO_ENCAP
1405 # define IPPROTO_ENCAP -1
1407 CND(IPPROTO_ENCAP
, "Encapsulation Header")
1410 # define IPPROTO_PIM -1
1412 CND(IPPROTO_PIM
, "Protocol Independent Multicast")
1414 #ifndef IPPROTO_COMP
1415 # define IPPROTO_COMP -1
1417 CND(IPPROTO_COMP
, "Compression Header Protocol")
1419 #ifndef IPPROTO_SCTP
1420 # define IPPROTO_SCTP -1
1422 CND(IPPROTO_SCTP
, "Stream Control Transmission Protocol")
1424 #ifndef IPPROTO_UDPLITE
1425 # define IPPROTO_UDPLITE -1
1427 CND(IPPROTO_UDPLITE
, "UDP-Lite protocol")
1429 #ifndef IPPROTO_MPLS
1430 # define IPPROTO_MPLS -1
1432 CND(IPPROTO_MPLS
, "MPLS in IP")
1435 # define IPPROTO_RAW -1
1437 CND(IPPROTO_RAW
, "Raw IP packets")
1450 CND(MSG_OOB
, "Process out-of-band data")
1453 # define MSG_PEEK -1
1455 CND(MSG_PEEK
, "Peek at incoming data")
1460 CND(MSG_EOR
, "Send end of record")
1463 # define MSG_WAITALL -1
1465 CND(MSG_WAITALL
, "Wait for full reception")
1467 #ifndef MSG_NOSIGNAL
1468 # define MSG_NOSIGNAL -1
1470 CND(MSG_NOSIGNAL
, "No SIGPIPE on send")
1472 #if defined (__linux__) || defined (__ANDROID__) || defined (__QNX__)
1473 # define MSG_Forced_Flags "MSG_NOSIGNAL"
1475 # define MSG_Forced_Flags "0"
1477 CNS(MSG_Forced_Flags
, "")
1479 -- Flags set on all send(2) calls
1484 --------------------
1485 -- Socket options --
1486 --------------------
1491 # define TCP_NODELAY -1
1493 CND(TCP_NODELAY
, "Do not coalesce packets")
1497 /* Windows headers can be too old to have all available constants.
1498 * We know this one. */
1499 # define TCP_KEEPCNT 16
1501 # define TCP_KEEPCNT -1
1504 CND(TCP_KEEPCNT
, "Maximum number of keepalive probes")
1506 #ifndef TCP_KEEPIDLE
1508 /* Windows headers can be too old to have all available constants.
1509 * We know this one. */
1510 # define TCP_KEEPIDLE 3
1512 # define TCP_KEEPIDLE -1
1515 CND(TCP_KEEPIDLE
, "Idle time before TCP starts sending keepalive probes")
1517 #ifndef TCP_KEEPINTVL
1519 /* Windows headers can be too old to have all available constants.
1520 * We know this one. */
1521 # define TCP_KEEPINTVL 17
1523 # define TCP_KEEPINTVL -1
1526 CND(TCP_KEEPINTVL
, "Time between individual keepalive probes")
1528 #ifndef SO_REUSEADDR
1529 # define SO_REUSEADDR -1
1531 CND(SO_REUSEADDR
, "Bind reuse local address")
1533 #ifndef SO_REUSEPORT
1534 # define SO_REUSEPORT -1
1536 CND(SO_REUSEPORT
, "Bind reuse port number")
1538 #ifndef SO_KEEPALIVE
1539 # define SO_KEEPALIVE -1
1541 CND(SO_KEEPALIVE
, "Enable keep-alive msgs")
1544 # define SO_LINGER -1
1546 CND(SO_LINGER
, "Defer close to flush data")
1548 #ifndef SO_BROADCAST
1549 # define SO_BROADCAST -1
1551 CND(SO_BROADCAST
, "Can send broadcast msgs")
1554 # define SO_SNDBUF -1
1556 CND(SO_SNDBUF
, "Set/get send buffer size")
1559 # define SO_RCVBUF -1
1561 CND(SO_RCVBUF
, "Set/get recv buffer size")
1564 # define SO_SNDTIMEO -1
1566 CND(SO_SNDTIMEO
, "Emission timeout")
1569 # define SO_RCVTIMEO -1
1571 CND(SO_RCVTIMEO
, "Reception timeout")
1574 # define SO_ERROR -1
1576 CND(SO_ERROR
, "Get/clear error status")
1578 #ifndef SO_BUSY_POLL
1579 # define SO_BUSY_POLL -1
1581 CND(SO_BUSY_POLL
, "Busy polling")
1583 #ifndef IP_MULTICAST_IF
1584 # define IP_MULTICAST_IF -1
1586 CND(IP_MULTICAST_IF
, "Set/get mcast interface")
1588 #ifndef IP_MULTICAST_TTL
1589 # define IP_MULTICAST_TTL -1
1591 CND(IP_MULTICAST_TTL
, "Set/get multicast TTL")
1593 #ifndef IP_MULTICAST_LOOP
1594 # define IP_MULTICAST_LOOP -1
1596 CND(IP_MULTICAST_LOOP
, "Set/get mcast loopback")
1598 #ifndef IP_ADD_MEMBERSHIP
1599 # define IP_ADD_MEMBERSHIP -1
1601 CND(IP_ADD_MEMBERSHIP
, "Join a multicast group")
1603 #ifndef IP_DROP_MEMBERSHIP
1604 # define IP_DROP_MEMBERSHIP -1
1606 CND(IP_DROP_MEMBERSHIP
, "Leave a multicast group")
1609 # define IP_PKTINFO -1
1611 CND(IP_PKTINFO
, "Get datagram info")
1614 # define IP_RECVERR -1
1616 CND(IP_RECVERR
, "Extended reliable error message passing")
1618 #ifndef IPV6_ADDRFORM
1619 # define IPV6_ADDRFORM -1
1621 CND(IPV6_ADDRFORM
, "Turn IPv6 socket into different address family")
1623 #ifndef IPV6_ADD_MEMBERSHIP
1624 # define IPV6_ADD_MEMBERSHIP -1
1626 CND(IPV6_ADD_MEMBERSHIP
, "Join IPv6 multicast group")
1628 #ifndef IPV6_DROP_MEMBERSHIP
1629 # define IPV6_DROP_MEMBERSHIP -1
1631 CND(IPV6_DROP_MEMBERSHIP
, "Leave IPv6 multicast group")
1634 # define IPV6_MTU -1
1636 CND(IPV6_MTU
, "Set/get MTU used for the socket")
1638 #ifndef IPV6_MTU_DISCOVER
1639 # define IPV6_MTU_DISCOVER -1
1641 CND(IPV6_MTU_DISCOVER
, "Control path-MTU discovery on the socket")
1643 #ifndef IPV6_MULTICAST_HOPS
1644 # define IPV6_MULTICAST_HOPS -1
1646 CND(IPV6_MULTICAST_HOPS
, "Set the multicast hop limit for the socket")
1648 #ifndef IPV6_MULTICAST_IF
1649 # define IPV6_MULTICAST_IF -1
1651 CND(IPV6_MULTICAST_IF
, "Set/get IPv6 mcast interface")
1653 #ifndef IPV6_MULTICAST_LOOP
1654 # define IPV6_MULTICAST_LOOP -1
1656 CND(IPV6_MULTICAST_LOOP
, "Set/get mcast loopback")
1658 #ifndef IPV6_RECVPKTINFO
1659 # define IPV6_RECVPKTINFO -1
1661 CND(IPV6_RECVPKTINFO
, "Set delivery of the IPV6_PKTINFO")
1663 #ifndef IPV6_PKTINFO
1664 # define IPV6_PKTINFO -1
1666 CND(IPV6_PKTINFO
, "Get IPv6datagram info")
1669 # define IPV6_RTHDR -1
1671 CND(IPV6_RTHDR
, "Set the routing header delivery")
1673 #ifndef IPV6_AUTHHDR
1674 # define IPV6_AUTHHDR -1
1676 CND(IPV6_AUTHHDR
, "Set the authentication header delivery")
1678 #ifndef IPV6_DSTOPTS
1679 # define IPV6_DSTOPTS -1
1681 CND(IPV6_DSTOPTS
, "Set the destination options delivery")
1683 #ifndef IPV6_HOPOPTS
1684 # define IPV6_HOPOPTS -1
1686 CND(IPV6_HOPOPTS
, "Set the hop options delivery")
1688 #ifndef IPV6_FLOWINFO
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
1694 # define IPV6_FLOWINFO -1
1697 CND(IPV6_FLOWINFO
, "Set the flow ID delivery")
1699 #ifndef IPV6_HOPLIMIT
1700 # define IPV6_HOPLIMIT -1
1702 CND(IPV6_HOPLIMIT
, "Set the hop count of the packet delivery")
1704 #ifndef IPV6_RECVERR
1705 # define IPV6_RECVERR -1
1707 CND(IPV6_RECVERR
, "Extended reliable error message passing")
1709 #ifndef IPV6_ROUTER_ALERT
1710 # define IPV6_ROUTER_ALERT -1
1712 CND(IPV6_ROUTER_ALERT
, "Pass forwarded router alert hop-by-hop option")
1714 #ifndef IPV6_UNICAST_HOPS
1715 # define IPV6_UNICAST_HOPS -1
1717 CND(IPV6_UNICAST_HOPS
, "Set the unicast hop limit")
1720 # define IPV6_V6ONLY -1
1722 CND(IPV6_V6ONLY
, "Restricted to IPv6 communications only")
1726 ----------------------
1727 -- Type definitions --
1728 ----------------------
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#"
1758 # define MAX_tv_sec "2 ** (SIZEOF_tv_sec * 8 - 1) - 1"
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))
1772 # define SIZEOF_sockaddr_in6 0
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 */
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")
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)
1811 #define SIZEOF_nfds_t sizeof (nfds_t) * 8
1812 #define SIZEOF_socklen_t sizeof (socklen_t)
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
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
1826 CND(SIZEOF_fd_type
, "Size of socket fd");
1827 CND(SIZEOF_pollfd_events
, "Size of pollfd.events");
1831 #ifdef IF_MAX_STRING_SIZE
1832 #define IF_NAMESIZE IF_MAX_STRING_SIZE
1834 #define IF_NAMESIZE -1
1837 CND(IF_NAMESIZE
, "Max size of interface name with 0 terminator");
1845 #if defined(__vxworks)
1870 #elif defined(_WIN32)
1872 /* If the POLLPRI flag is set on a socket for the Microsoft Winsock provider,
1873 * the WSAPoll function will fail. */
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"
1891 # define Msg_Iovlen_T "Interfaces.C.size_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
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"
1921 # define Inet_Pton_Linkname "__gnat_inet_pton"
1923 CST(Inet_Pton_Linkname
, "")
1925 #ifdef HAVE_INET_NTOP
1926 # define Inet_Ntop_Linkname "inet_ntop"
1928 # define Inet_Ntop_Linkname "__gnat_inet_ntop"
1930 CST(Inet_Ntop_Linkname
, "")
1933 # define Poll_Linkname "WSAPoll"
1935 # define Poll_Linkname "poll"
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)
1956 CND(CLOCK_REALTIME
, "System realtime clock")
1958 #ifdef CLOCK_MONOTONIC
1959 CND(CLOCK_MONOTONIC
, "System monotonic clock")
1962 #ifdef CLOCK_FASTEST
1963 CND(CLOCK_FASTEST
, "Fastest clock")
1966 #ifndef CLOCK_THREAD_CPUTIME_ID
1967 # define CLOCK_THREAD_CPUTIME_ID -1
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"
1986 /* By default use CLOCK_REALTIME */
1987 # define CLOCK_RT_Ada "CLOCK_REALTIME"
1991 CNS(CLOCK_RT_Ada
, "")
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__
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))
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
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
2123 end System.OS_Constants;