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-2009, 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 #if defined (__linux__) && !defined (_XOPEN_SOURCE)
82 /** For Linux _XOPEN_SOURCE must be defined, otherwise IOV_MAX is not defined
84 #define _XOPEN_SOURCE 500
86 #elif defined (__mips) && defined (__sgi)
87 /** For IRIX _XOPEN5 must be defined and _XOPEN_IOV_MAX must be used as IOV_MAX,
88 ** otherwise IOV_MAX is not defined.
91 #define IOV_MAX _XOPEN_IOV_MAX
99 #if ! (defined (__vxworks) || defined (__VMS) || defined (__MINGW32__) || \
100 defined (__nucleus__))
101 # define HAVE_TERMIOS
104 #if defined (__vxworks)
107 ** For VxWorks, always include vxWorks.h (gsocket.h provides it only for
108 ** the case of runtime libraries that support sockets).
111 # include <vxWorks.h>
118 # if defined (TARGET)
119 # error TARGET may not be defined when generating the dummy version
121 # define TARGET "batch runtime compilation (dummy values)"
124 # if !(defined (HAVE_SOCKETS) && defined (HAVE_TERMIOS))
125 # error Features missing on platform
133 # error Please define TARGET
141 # include <termios.h>
153 # define _VAL(x) counter++
158 #define CND(name,comment) \
159 printf ("\n->CND:$%d:" #name ":$%d:" comment, __LINE__, ((int) _VAL (name)));
161 #define CNS(name,comment) \
162 printf ("\n->CNS:$%d:" #name ":" name ":" comment, __LINE__);
165 printf ("\n->TXT:$%d:" text, __LINE__);
169 #define CND(name, comment) \
170 asm volatile("\n->CND:%0:" #name ":%1:" comment \
171 : : "i" (__LINE__), "i" ((int) name));
172 /* Decimal constant in the range of type "int" */
174 #define CNS(name, comment) \
175 asm volatile("\n->CNS:%0:" #name ":" name ":" comment \
177 /* General expression constant */
180 asm volatile("\n->TXT:%0:" text \
186 #define STR(x) STR1(x)
190 unsigned int _CRT_fmode = _O_BINARY;
197 -- This package provides target dependent definitions of constant for use
198 -- by the GNAT runtime library. This package should not be directly with'd
199 -- by an application program.
201 -- This file is generated automatically, do not modify it by hand! Instead,
202 -- make changes to s-oscons-tmplt.c and rebuild the GNAT runtime library.
206 ** Do not change the format of the line below without also updating the
209 TXT("-- This is the version for " TARGET)
214 ** The type definitions for struct hostent components uses Interfaces.C
217 TXT("with Interfaces.C;")
221 package System.OS_Constants is
227 ** General constants (all platforms)
232 -----------------------------
233 -- Platform identification --
234 -----------------------------
237 TXT(" Target_Name : constant String := " STR(TARGET) ";")
239 type Target_OS_Type is (Windows, VMS, Other_OS);
241 #if defined (__MINGW32__)
242 # define TARGET_OS "Windows"
243 #elif defined (__VMS)
244 # define TARGET_OS "VMS"
246 # define TARGET_OS "Other_OS"
248 TXT(" Target_OS : constant Target_OS_Type := " TARGET_OS ";")
258 # define IOV_MAX INT_MAX
260 CND(IOV_MAX, "Maximum writev iovcnt")
264 ---------------------
265 -- File open modes --
266 ---------------------
273 CND(O_RDWR, "Read/write")
278 CND(O_NOCTTY, "Don't change ctrl tty")
283 CND(O_NDELAY, "Nonblocking")
287 ----------------------
288 -- Fcntl operations --
289 ----------------------
296 CND(F_GETFL, "Get flags")
301 CND(F_SETFL, "Set flags")
314 CND(FNDELAY, "Nonblocking")
318 ----------------------
319 -- Ioctl operations --
320 ----------------------
327 CND(FIONBIO, "Set/clear non-blocking io")
332 CND(FIONREAD, "How many bytes to read")
340 -- The following constants are defined from <errno.h>
346 CND(EAGAIN, "Try again")
351 CND(ENOENT, "File not found")
356 CND(ENOMEM, "Out of memory")
361 -- The following constants are defined from <winsock2.h> (WSA*)
366 ** For sockets-related errno values on Windows, gsocket.h redefines
375 CND(EACCES, "Permission denied")
378 # define EADDRINUSE -1
380 CND(EADDRINUSE, "Address already in use")
382 #ifndef EADDRNOTAVAIL
383 # define EADDRNOTAVAIL -1
385 CND(EADDRNOTAVAIL, "Cannot assign address")
388 # define EAFNOSUPPORT -1
390 CND(EAFNOSUPPORT, "Addr family not supported")
395 CND(EALREADY, "Operation in progress")
400 CND(EBADF, "Bad file descriptor")
403 # define ECONNABORTED -1
405 CND(ECONNABORTED, "Connection aborted")
408 # define ECONNREFUSED -1
410 CND(ECONNREFUSED, "Connection refused")
413 # define ECONNRESET -1
415 CND(ECONNRESET, "Connection reset by peer")
418 # define EDESTADDRREQ -1
420 CND(EDESTADDRREQ, "Destination addr required")
425 CND(EFAULT, "Bad address")
428 # define EHOSTDOWN -1
430 CND(EHOSTDOWN, "Host is down")
433 # define EHOSTUNREACH -1
435 CND(EHOSTUNREACH, "No route to host")
438 # define EINPROGRESS -1
440 CND(EINPROGRESS, "Operation now in progress")
445 CND(EINTR, "Interrupted system call")
450 CND(EINVAL, "Invalid argument")
455 CND(EIO, "Input output error")
460 CND(EISCONN, "Socket already connected")
465 CND(ELOOP, "Too many symbolic links")
470 CND(EMFILE, "Too many open files")
475 CND(EMSGSIZE, "Message too long")
478 # define ENAMETOOLONG -1
480 CND(ENAMETOOLONG, "Name too long")
485 CND(ENETDOWN, "Network is down")
488 # define ENETRESET -1
490 CND(ENETRESET, "Disconn. on network reset")
493 # define ENETUNREACH -1
495 CND(ENETUNREACH, "Network is unreachable")
500 CND(ENOBUFS, "No buffer space available")
503 # define ENOPROTOOPT -1
505 CND(ENOPROTOOPT, "Protocol not available")
510 CND(ENOTCONN, "Socket not connected")
515 CND(ENOTSOCK, "Operation on non socket")
518 # define EOPNOTSUPP -1
520 CND(EOPNOTSUPP, "Operation not supported")
525 CND(EPIPE, "Broken pipe")
528 # define EPFNOSUPPORT -1
530 CND(EPFNOSUPPORT, "Unknown protocol family")
532 #ifndef EPROTONOSUPPORT
533 # define EPROTONOSUPPORT -1
535 CND(EPROTONOSUPPORT, "Unknown protocol")
538 # define EPROTOTYPE -1
540 CND(EPROTOTYPE, "Unknown protocol type")
545 CND(ERANGE, "Result too large")
548 # define ESHUTDOWN -1
550 CND(ESHUTDOWN, "Cannot send once shutdown")
552 #ifndef ESOCKTNOSUPPORT
553 # define ESOCKTNOSUPPORT -1
555 CND(ESOCKTNOSUPPORT, "Socket type not supported")
558 # define ETIMEDOUT -1
560 CND(ETIMEDOUT, "Connection timed out")
563 # define ETOOMANYREFS -1
565 CND(ETOOMANYREFS, "Too many references")
568 # define EWOULDBLOCK -1
570 CND(EWOULDBLOCK, "Operation would block")
573 ** Terminal I/O constants
580 ----------------------
581 -- Terminal control --
582 ----------------------
589 CND(TCSANOW, "Immediate")
594 CND(TCIFLUSH, "Flush input")
604 CND(CRTSCTS, "Hardware flow control")
614 CND(CS5, "5 data bits")
619 CND(CS6, "6 data bits")
624 CND(CS7, "7 data bits")
629 CND(CS8, "8 data bits")
634 CND(CSTOPB, "2 stop bits")
639 CND(PARENB, "Parity enable")
644 CND(PARODD, "Parity odd")
694 CND(B1200, "1200 bps")
699 CND(B1800, "1800 bps")
704 CND(B2400, "2400 bps")
709 CND(B4800, "4800 bps")
714 CND(B9600, "9600 bps")
719 CND(B19200, "19200 bps")
724 CND(B38400, "38400 bps")
729 CND(B57600, "57600 bps")
734 CND(B115200, "115200 bps")
739 CND(B230400, "230400 bps")
744 CND(B460800, "460800 bps")
749 CND(B500000, "500000 bps")
754 CND(B576000, "576000 bps")
759 CND(B921600, "921600 bps")
764 CND(B1000000, "1000000 bps")
769 CND(B1152000, "1152000 bps")
774 CND(B1500000, "1500000 bps")
779 CND(B2000000, "2000000 bps")
784 CND(B2500000, "2500000 bps")
789 CND(B3000000, "3000000 bps")
794 CND(B3500000, "3500000 bps")
799 CND(B4000000, "4000000 bps")
803 ---------------------------------
804 -- Terminal control characters --
805 ---------------------------------
812 CND(VINTR, "Interrupt")
837 CND(VTIME, "Read timeout")
842 CND(VMIN, "Read min chars")
852 CND(VSTART, "Flow control start")
857 CND(VSTOP, "Flow control stop")
862 CND(VSUSP, "Suspend")
872 CND(VREPRINT, "Reprint unread")
877 CND(VDISCARD, "Discard pending")
882 CND(VWERASE, "Word erase")
887 CND(VLNEXT, "Literal next")
892 CND(VEOL2, "Alternative EOL")
894 #endif /* HAVE_TERMIOS */
913 CND(AF_INET, "IPv4 address family")
916 ** RTEMS lies and defines AF_INET6 even though there is no IPV6 support.
917 ** Its TCP/IP stack is in transition. It has newer .h files but no IPV6 yet.
919 #if defined(__rtems__)
924 ** Tru64 UNIX V4.0F defines AF_INET6 without IPv6 support, specificially
925 ** without struct sockaddr_in6. We use _SS_MAXSIZE (used for the definition
926 ** of struct sockaddr_storage on Tru64 UNIX V5.1) to detect this.
928 #if defined(__osf__) && !defined(_SS_MAXSIZE)
935 # define HAVE_AF_INET6 1
937 CND(AF_INET6, "IPv6 address family")
948 # define SOCK_STREAM -1
950 CND(SOCK_STREAM, "Stream socket")
953 # define SOCK_DGRAM -1
955 CND(SOCK_DGRAM, "Datagram socket")
965 #ifndef HOST_NOT_FOUND
966 # define HOST_NOT_FOUND -1
968 CND(HOST_NOT_FOUND, "Unknown host")
971 # define TRY_AGAIN -1
973 CND(TRY_AGAIN, "Host name lookup failure")
978 CND(NO_DATA, "No data record for name")
981 # define NO_RECOVERY -1
983 CND(NO_RECOVERY, "Non recoverable errors")
996 CND(SHUT_RD, "No more recv")
1001 CND(SHUT_WR, "No more send")
1004 # define SHUT_RDWR -1
1006 CND(SHUT_RDWR, "No more recv/send")
1010 ---------------------
1011 -- Protocol levels --
1012 ---------------------
1017 # define SOL_SOCKET -1
1019 CND(SOL_SOCKET, "Options for socket level")
1022 # define IPPROTO_IP -1
1024 CND(IPPROTO_IP, "Dummy protocol for IP")
1027 # define IPPROTO_UDP -1
1029 CND(IPPROTO_UDP, "UDP")
1032 # define IPPROTO_TCP -1
1034 CND(IPPROTO_TCP, "TCP")
1047 CND(MSG_OOB, "Process out-of-band data")
1050 # define MSG_PEEK -1
1052 CND(MSG_PEEK, "Peek at incoming data")
1057 CND(MSG_EOR, "Send end of record")
1060 # define MSG_WAITALL -1
1062 CND(MSG_WAITALL, "Wait for full reception")
1064 #ifndef MSG_NOSIGNAL
1065 # define MSG_NOSIGNAL -1
1067 CND(MSG_NOSIGNAL, "No SIGPIPE on send")
1070 # define MSG_Forced_Flags "MSG_NOSIGNAL"
1072 # define MSG_Forced_Flags "0"
1074 CNS(MSG_Forced_Flags, "")
1076 -- Flags set on all send(2) calls
1081 --------------------
1082 -- Socket options --
1083 --------------------
1088 # define TCP_NODELAY -1
1090 CND(TCP_NODELAY, "Do not coalesce packets")
1092 #ifndef SO_REUSEADDR
1093 # define SO_REUSEADDR -1
1095 CND(SO_REUSEADDR, "Bind reuse local address")
1097 #ifndef SO_REUSEPORT
1098 # define SO_REUSEPORT -1
1100 CND(SO_REUSEPORT, "Bind reuse port number")
1102 #ifndef SO_KEEPALIVE
1103 # define SO_KEEPALIVE -1
1105 CND(SO_KEEPALIVE, "Enable keep-alive msgs")
1108 # define SO_LINGER -1
1110 CND(SO_LINGER, "Defer close to flush data")
1112 #ifndef SO_BROADCAST
1113 # define SO_BROADCAST -1
1115 CND(SO_BROADCAST, "Can send broadcast msgs")
1118 # define SO_SNDBUF -1
1120 CND(SO_SNDBUF, "Set/get send buffer size")
1123 # define SO_RCVBUF -1
1125 CND(SO_RCVBUF, "Set/get recv buffer size")
1128 # define SO_SNDTIMEO -1
1130 CND(SO_SNDTIMEO, "Emission timeout")
1133 # define SO_RCVTIMEO -1
1135 CND(SO_RCVTIMEO, "Reception timeout")
1138 # define SO_ERROR -1
1140 CND(SO_ERROR, "Get/clear error status")
1142 #ifndef IP_MULTICAST_IF
1143 # define IP_MULTICAST_IF -1
1145 CND(IP_MULTICAST_IF, "Set/get mcast interface")
1147 #ifndef IP_MULTICAST_TTL
1148 # define IP_MULTICAST_TTL -1
1150 CND(IP_MULTICAST_TTL, "Set/get multicast TTL")
1152 #ifndef IP_MULTICAST_LOOP
1153 # define IP_MULTICAST_LOOP -1
1155 CND(IP_MULTICAST_LOOP, "Set/get mcast loopback")
1157 #ifndef IP_ADD_MEMBERSHIP
1158 # define IP_ADD_MEMBERSHIP -1
1160 CND(IP_ADD_MEMBERSHIP, "Join a multicast group")
1162 #ifndef IP_DROP_MEMBERSHIP
1163 # define IP_DROP_MEMBERSHIP -1
1165 CND(IP_DROP_MEMBERSHIP, "Leave a multicast group")
1168 # define IP_PKTINFO -1
1170 CND(IP_PKTINFO, "Get datagram info")
1174 ----------------------
1175 -- Type definitions --
1176 ----------------------
1183 -- Sizes (in bytes) of the components of struct timeval
1185 #define SIZEOF_tv_sec (sizeof tv.tv_sec)
1186 CND(SIZEOF_tv_sec, "tv_sec")
1187 #define SIZEOF_tv_usec (sizeof tv.tv_usec)
1188 CND(SIZEOF_tv_usec, "tv_usec")
1192 -- Sizes of protocol specific address types (for sockaddr.sa_len)
1195 #define SIZEOF_sockaddr_in (sizeof (struct sockaddr_in))
1196 CND(SIZEOF_sockaddr_in, "struct sockaddr_in")
1197 #ifdef HAVE_AF_INET6
1198 # define SIZEOF_sockaddr_in6 (sizeof (struct sockaddr_in6))
1200 # define SIZEOF_sockaddr_in6 0
1202 CND(SIZEOF_sockaddr_in6, "struct sockaddr_in6")
1206 -- Size of file descriptor sets
1208 #define SIZEOF_fd_set (sizeof (fd_set))
1209 CND(SIZEOF_fd_set, "fd_set");
1212 -- Fields of struct hostent
1216 # define h_addrtype_t "short"
1217 # define h_length_t "short"
1219 # define h_addrtype_t "int"
1220 # define h_length_t "int"
1223 TXT(" subtype H_Addrtype_T is Interfaces.C." h_addrtype_t ";")
1224 TXT(" subtype H_Length_T is Interfaces.C." h_length_t ";")
1228 -- Fields of struct msghdr
1231 #if defined (__sun__) || defined (__hpux__)
1232 # define msg_iovlen_t "int"
1234 # define msg_iovlen_t "size_t"
1237 TXT(" subtype Msg_Iovlen_T is Interfaces.C." msg_iovlen_t ";")
1241 ----------------------------------------
1242 -- Properties of supported interfaces --
1243 ----------------------------------------
1247 CND(Need_Netdb_Buffer, "Need buffer for Netdb ops")
1248 CND(Has_Sockaddr_Len, "Sockaddr has sa_len field")
1251 ** Do not change the format of the line below without also updating the
1254 TXT(" Thread_Blocking_IO : constant Boolean := True;")
1256 -- Set False for contexts where socket i/o are process blocking
1260 #ifdef HAVE_INET_PTON
1261 # define Inet_Pton_Linkname "inet_pton"
1263 # define Inet_Pton_Linkname "__gnat_inet_pton"
1265 TXT(" Inet_Pton_Linkname : constant String := \"" Inet_Pton_Linkname "\";")
1267 #endif /* HAVE_SOCKETS */
1270 ** System-specific constants follow
1271 ** Each section should be activated if compiling for the corresponding
1272 ** platform *or* generating the dummy version for runtime test compilation.
1275 #if defined (__vxworks) || defined (DUMMY)
1279 --------------------------------
1280 -- VxWorks-specific constants --
1281 --------------------------------
1283 -- These constants may be used only within the VxWorks version of
1284 -- GNAT.Sockets.Thin.
1287 CND(OK, "VxWorks generic success")
1288 CND(ERROR, "VxWorks generic error")
1292 #if defined (__MINGW32__) || defined (DUMMY)
1295 ------------------------------
1296 -- MinGW-specific constants --
1297 ------------------------------
1299 -- These constants may be used only within the MinGW version of
1300 -- GNAT.Sockets.Thin.
1303 CND(WSASYSNOTREADY, "System not ready")
1304 CND(WSAVERNOTSUPPORTED, "Version not supported")
1305 CND(WSANOTINITIALISED, "Winsock not initialized")
1306 CND(WSAEDISCON, "Disconnected")
1314 #if defined (__APPLE__) || defined (DUMMY)
1317 -------------------------------
1318 -- Darwin-specific constants --
1319 -------------------------------
1321 -- These constants may be used only within the Darwin version of the GNAT
1325 #define PTHREAD_SIZE __PTHREAD_SIZE__
1326 CND(PTHREAD_SIZE, "Pad in pthread_t")
1328 #define PTHREAD_ATTR_SIZE __PTHREAD_ATTR_SIZE__
1329 CND(PTHREAD_ATTR_SIZE, "Pad in pthread_attr_t")
1331 #define PTHREAD_MUTEXATTR_SIZE __PTHREAD_MUTEXATTR_SIZE__
1332 CND(PTHREAD_MUTEXATTR_SIZE, "Pad in pthread_mutexattr_t")
1334 #define PTHREAD_MUTEX_SIZE __PTHREAD_MUTEX_SIZE__
1335 CND(PTHREAD_MUTEX_SIZE, "Pad in pthread_mutex_t")
1337 #define PTHREAD_CONDATTR_SIZE __PTHREAD_CONDATTR_SIZE__
1338 CND(PTHREAD_CONDATTR_SIZE, "Pad in pthread_condattr_t")
1340 #define PTHREAD_COND_SIZE __PTHREAD_COND_SIZE__
1341 CND(PTHREAD_COND_SIZE, "Pad in pthread_cond_t")
1343 #define PTHREAD_RWLOCKATTR_SIZE __PTHREAD_RWLOCKATTR_SIZE__
1344 CND(PTHREAD_RWLOCKATTR_SIZE, "Pad in pthread_rwlockattr_t")
1346 #define PTHREAD_RWLOCK_SIZE __PTHREAD_RWLOCK_SIZE__
1347 CND(PTHREAD_RWLOCK_SIZE, "Pad in pthread_rwlock_t")
1349 #define PTHREAD_ONCE_SIZE __PTHREAD_ONCE_SIZE__
1350 CND(PTHREAD_ONCE_SIZE, "Pad in pthread_once_t")
1356 end System.OS_Constants;