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 ** build 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
87 #if ! (defined (__vxworks) || defined (__VMS) || defined (__MINGW32__) || \
88 defined (__nucleus__))
92 #if defined (__vxworks)
100 # if defined (TARGET)
101 # error TARGET may not be defined when generating the dummy version
103 # define TARGET "batch runtime compilation (dummy values)"
106 # if !(defined (HAVE_SOCKETS) && defined (HAVE_TERMIOS))
107 # error Features missing on platform
115 # error Please define TARGET
123 # include <termios.h>
135 # define _VAL(x) counter++
140 #define CND(name,comment) \
141 printf ("\n->CND:$%d:" #name ":$%d:" comment, __LINE__, ((int) _VAL (name)));
143 #define CNS(name,comment) \
144 printf ("\n->CNS:$%d:" #name ":" name ":" comment, __LINE__);
147 printf ("\n->TXT:$%d:" text, __LINE__);
151 #define CND(name, comment) \
152 asm volatile("\n->CND:%0:" #name ":%1:" comment \
153 : : "i" (__LINE__), "i" ((int) name));
154 /* Decimal constant in the range of type "int" */
156 #define CNS(name, comment) \
157 asm volatile("\n->CNS:%0:" #name ":" name ":" comment \
159 /* General expression constant */
162 asm volatile("\n->TXT:%0:" text \
169 unsigned int _CRT_fmode = _O_BINARY;
176 -- This package provides target dependent definitions of constant for use
177 -- by the GNAT runtime library. This package should not be directly with'd
178 -- by an application program.
180 -- This file is generated automatically, do not modify it by hand! Instead,
181 -- make changes to s-oscons-tmplt.c and rebuild the GNAT runtime library.
185 ** Do not change the format of the line below without also updating the
188 TXT("-- This is the version for " TARGET)
193 ** The type definitions for struct hostent components uses Interfaces.C
196 TXT("with Interfaces.C;")
200 package System.OS_Constants is
206 ** General constants (all platforms)
218 # define IOV_MAX INT_MAX
220 CND(IOV_MAX, "Maximum writev iovcnt")
224 ---------------------
225 -- File open modes --
226 ---------------------
233 CND(O_RDWR, "Read/write")
238 CND(O_NOCTTY, "Don't change ctrl tty")
243 CND(O_NDELAY, "Nonblocking")
247 ----------------------
248 -- Fcntl operations --
249 ----------------------
256 CND(F_GETFL, "Get flags")
261 CND(F_SETFL, "Set flags")
274 CND(FNDELAY, "Nonblocking")
278 ----------------------
279 -- Ioctl operations --
280 ----------------------
287 CND(FIONBIO, "Set/clear non-blocking io")
292 CND(FIONREAD, "How many bytes to read")
300 -- The following constants are defined from <errno.h>
306 CND(EAGAIN, "Try again")
311 CND(ENOENT, "File not found")
316 CND(ENOMEM, "Out of memory")
321 -- The following constants are defined from <winsock2.h> (WSA*)
326 ** For sockets-related errno values on Windows, gsocket.h redefines
335 CND(EACCES, "Permission denied")
338 # define EADDRINUSE -1
340 CND(EADDRINUSE, "Address already in use")
342 #ifndef EADDRNOTAVAIL
343 # define EADDRNOTAVAIL -1
345 CND(EADDRNOTAVAIL, "Cannot assign address")
348 # define EAFNOSUPPORT -1
350 CND(EAFNOSUPPORT, "Addr family not supported")
355 CND(EALREADY, "Operation in progress")
360 CND(EBADF, "Bad file descriptor")
363 # define ECONNABORTED -1
365 CND(ECONNABORTED, "Connection aborted")
368 # define ECONNREFUSED -1
370 CND(ECONNREFUSED, "Connection refused")
373 # define ECONNRESET -1
375 CND(ECONNRESET, "Connection reset by peer")
378 # define EDESTADDRREQ -1
380 CND(EDESTADDRREQ, "Destination addr required")
385 CND(EFAULT, "Bad address")
388 # define EHOSTDOWN -1
390 CND(EHOSTDOWN, "Host is down")
393 # define EHOSTUNREACH -1
395 CND(EHOSTUNREACH, "No route to host")
398 # define EINPROGRESS -1
400 CND(EINPROGRESS, "Operation now in progress")
405 CND(EINTR, "Interrupted system call")
410 CND(EINVAL, "Invalid argument")
415 CND(EIO, "Input output error")
420 CND(EISCONN, "Socket already connected")
425 CND(ELOOP, "Too many symbolic links")
430 CND(EMFILE, "Too many open files")
435 CND(EMSGSIZE, "Message too long")
438 # define ENAMETOOLONG -1
440 CND(ENAMETOOLONG, "Name too long")
445 CND(ENETDOWN, "Network is down")
448 # define ENETRESET -1
450 CND(ENETRESET, "Disconn. on network reset")
453 # define ENETUNREACH -1
455 CND(ENETUNREACH, "Network is unreachable")
460 CND(ENOBUFS, "No buffer space available")
463 # define ENOPROTOOPT -1
465 CND(ENOPROTOOPT, "Protocol not available")
470 CND(ENOTCONN, "Socket not connected")
475 CND(ENOTSOCK, "Operation on non socket")
478 # define EOPNOTSUPP -1
480 CND(EOPNOTSUPP, "Operation not supported")
485 CND(EPIPE, "Broken pipe")
488 # define EPFNOSUPPORT -1
490 CND(EPFNOSUPPORT, "Unknown protocol family")
492 #ifndef EPROTONOSUPPORT
493 # define EPROTONOSUPPORT -1
495 CND(EPROTONOSUPPORT, "Unknown protocol")
498 # define EPROTOTYPE -1
500 CND(EPROTOTYPE, "Unknown protocol type")
505 CND(ERANGE, "Result too large")
508 # define ESHUTDOWN -1
510 CND(ESHUTDOWN, "Cannot send once shutdown")
512 #ifndef ESOCKTNOSUPPORT
513 # define ESOCKTNOSUPPORT -1
515 CND(ESOCKTNOSUPPORT, "Socket type not supported")
518 # define ETIMEDOUT -1
520 CND(ETIMEDOUT, "Connection timed out")
523 # define ETOOMANYREFS -1
525 CND(ETOOMANYREFS, "Too many references")
528 # define EWOULDBLOCK -1
530 CND(EWOULDBLOCK, "Operation would block")
533 ** Terminal I/O constants
540 ----------------------
541 -- Terminal control --
542 ----------------------
549 CND(TCSANOW, "Immediate")
554 CND(TCIFLUSH, "Flush input")
564 CND(CRTSCTS, "Hardware flow control")
574 CND(CS5, "5 data bits")
579 CND(CS6, "6 data bits")
584 CND(CS7, "7 data bits")
589 CND(CS8, "8 data bits")
594 CND(CSTOPB, "2 stop bits")
599 CND(PARENB, "Parity enable")
604 CND(PARODD, "Parity odd")
654 CND(B1200, "1200 bps")
659 CND(B1800, "1800 bps")
664 CND(B2400, "2400 bps")
669 CND(B4800, "4800 bps")
674 CND(B9600, "9600 bps")
679 CND(B19200, "19200 bps")
684 CND(B38400, "38400 bps")
689 CND(B57600, "57600 bps")
694 CND(B115200, "115200 bps")
699 CND(B230400, "230400 bps")
704 CND(B460800, "460800 bps")
709 CND(B500000, "500000 bps")
714 CND(B576000, "576000 bps")
719 CND(B921600, "921600 bps")
724 CND(B1000000, "1000000 bps")
729 CND(B1152000, "1152000 bps")
734 CND(B1500000, "1500000 bps")
739 CND(B2000000, "2000000 bps")
744 CND(B2500000, "2500000 bps")
749 CND(B3000000, "3000000 bps")
754 CND(B3500000, "3500000 bps")
759 CND(B4000000, "4000000 bps")
763 ---------------------------------
764 -- Terminal control characters --
765 ---------------------------------
772 CND(VINTR, "Interrupt")
797 CND(VTIME, "Read timeout")
802 CND(VMIN, "Read min chars")
812 CND(VSTART, "Flow control start")
817 CND(VSTOP, "Flow control stop")
822 CND(VSUSP, "Suspend")
832 CND(VREPRINT, "Reprint unread")
837 CND(VDISCARD, "Discard pending")
842 CND(VWERASE, "Word erase")
847 CND(VLNEXT, "Literal next")
852 CND(VEOL2, "Alternative EOL")
854 #endif /* HAVE_TERMIOS */
873 CND(AF_INET, "IPv4 address family")
876 ** RTEMS lies and defines AF_INET6 even though there is no IPV6 support.
877 ** Its TCP/IP stack is in transition. It has newer .h files but no IPV6 yet.
879 #if defined(__rtems__)
884 ** Tru64 UNIX V4.0F defines AF_INET6 without IPv6 support, specificially
885 ** without struct sockaddr_in6. We use _SS_MAXSIZE (used for the definition
886 ** of struct sockaddr_storage on Tru64 UNIX V5.1) to detect this.
888 #if defined(__osf__) && !defined(_SS_MAXSIZE)
895 # define HAVE_AF_INET6 1
897 CND(AF_INET6, "IPv6 address family")
908 # define SOCK_STREAM -1
910 CND(SOCK_STREAM, "Stream socket")
913 # define SOCK_DGRAM -1
915 CND(SOCK_DGRAM, "Datagram socket")
925 #ifndef HOST_NOT_FOUND
926 # define HOST_NOT_FOUND -1
928 CND(HOST_NOT_FOUND, "Unknown host")
931 # define TRY_AGAIN -1
933 CND(TRY_AGAIN, "Host name lookup failure")
938 CND(NO_DATA, "No data record for name")
941 # define NO_RECOVERY -1
943 CND(NO_RECOVERY, "Non recoverable errors")
956 CND(SHUT_RD, "No more recv")
961 CND(SHUT_WR, "No more send")
964 # define SHUT_RDWR -1
966 CND(SHUT_RDWR, "No more recv/send")
970 ---------------------
971 -- Protocol levels --
972 ---------------------
977 # define SOL_SOCKET -1
979 CND(SOL_SOCKET, "Options for socket level")
982 # define IPPROTO_IP -1
984 CND(IPPROTO_IP, "Dummy protocol for IP")
987 # define IPPROTO_UDP -1
989 CND(IPPROTO_UDP, "UDP")
992 # define IPPROTO_TCP -1
994 CND(IPPROTO_TCP, "TCP")
1007 CND(MSG_OOB, "Process out-of-band data")
1010 # define MSG_PEEK -1
1012 CND(MSG_PEEK, "Peek at incoming data")
1017 CND(MSG_EOR, "Send end of record")
1020 # define MSG_WAITALL -1
1022 CND(MSG_WAITALL, "Wait for full reception")
1024 #ifndef MSG_NOSIGNAL
1025 # define MSG_NOSIGNAL -1
1027 CND(MSG_NOSIGNAL, "No SIGPIPE on send")
1030 # define MSG_Forced_Flags "MSG_NOSIGNAL"
1032 # define MSG_Forced_Flags "0"
1034 CNS(MSG_Forced_Flags, "")
1036 -- Flags set on all send(2) calls
1041 --------------------
1042 -- Socket options --
1043 --------------------
1048 # define TCP_NODELAY -1
1050 CND(TCP_NODELAY, "Do not coalesce packets")
1052 #ifndef SO_REUSEADDR
1053 # define SO_REUSEADDR -1
1055 CND(SO_REUSEADDR, "Bind reuse local address")
1057 #ifndef SO_REUSEPORT
1058 # define SO_REUSEPORT -1
1060 CND(SO_REUSEPORT, "Bind reuse port number")
1062 #ifndef SO_KEEPALIVE
1063 # define SO_KEEPALIVE -1
1065 CND(SO_KEEPALIVE, "Enable keep-alive msgs")
1068 # define SO_LINGER -1
1070 CND(SO_LINGER, "Defer close to flush data")
1072 #ifndef SO_BROADCAST
1073 # define SO_BROADCAST -1
1075 CND(SO_BROADCAST, "Can send broadcast msgs")
1078 # define SO_SNDBUF -1
1080 CND(SO_SNDBUF, "Set/get send buffer size")
1083 # define SO_RCVBUF -1
1085 CND(SO_RCVBUF, "Set/get recv buffer size")
1088 # define SO_SNDTIMEO -1
1090 CND(SO_SNDTIMEO, "Emission timeout")
1093 # define SO_RCVTIMEO -1
1095 CND(SO_RCVTIMEO, "Reception timeout")
1098 # define SO_ERROR -1
1100 CND(SO_ERROR, "Get/clear error status")
1102 #ifndef IP_MULTICAST_IF
1103 # define IP_MULTICAST_IF -1
1105 CND(IP_MULTICAST_IF, "Set/get mcast interface")
1107 #ifndef IP_MULTICAST_TTL
1108 # define IP_MULTICAST_TTL -1
1110 CND(IP_MULTICAST_TTL, "Set/get multicast TTL")
1112 #ifndef IP_MULTICAST_LOOP
1113 # define IP_MULTICAST_LOOP -1
1115 CND(IP_MULTICAST_LOOP, "Set/get mcast loopback")
1117 #ifndef IP_ADD_MEMBERSHIP
1118 # define IP_ADD_MEMBERSHIP -1
1120 CND(IP_ADD_MEMBERSHIP, "Join a multicast group")
1122 #ifndef IP_DROP_MEMBERSHIP
1123 # define IP_DROP_MEMBERSHIP -1
1125 CND(IP_DROP_MEMBERSHIP, "Leave a multicast group")
1128 # define IP_PKTINFO -1
1130 CND(IP_PKTINFO, "Get datagram info")
1134 ----------------------
1135 -- Type definitions --
1136 ----------------------
1143 -- Sizes (in bytes) of the components of struct timeval
1145 #define SIZEOF_tv_sec (sizeof tv.tv_sec)
1146 CND(SIZEOF_tv_sec, "tv_sec")
1147 #define SIZEOF_tv_usec (sizeof tv.tv_usec)
1148 CND(SIZEOF_tv_usec, "tv_usec")
1152 -- Sizes of protocol specific address types (for sockaddr.sa_len)
1155 #define SIZEOF_sockaddr_in (sizeof (struct sockaddr_in))
1156 CND(SIZEOF_sockaddr_in, "struct sockaddr_in")
1157 #ifdef HAVE_AF_INET6
1158 # define SIZEOF_sockaddr_in6 (sizeof (struct sockaddr_in6))
1160 # define SIZEOF_sockaddr_in6 0
1162 CND(SIZEOF_sockaddr_in6, "struct sockaddr_in6")
1166 -- Size of file descriptor sets
1168 #define SIZEOF_fd_set (sizeof (fd_set))
1169 CND(SIZEOF_fd_set, "fd_set");
1172 -- Fields of struct hostent
1176 # define h_addrtype_t "short"
1177 # define h_length_t "short"
1179 # define h_addrtype_t "int"
1180 # define h_length_t "int"
1183 TXT(" subtype H_Addrtype_T is Interfaces.C." h_addrtype_t ";")
1184 TXT(" subtype H_Length_T is Interfaces.C." h_length_t ";")
1188 -- Fields of struct msghdr
1191 #if defined (__sun__) || defined (__hpux__)
1192 # define msg_iovlen_t "int"
1194 # define msg_iovlen_t "size_t"
1197 TXT(" subtype Msg_Iovlen_T is Interfaces.C." msg_iovlen_t ";")
1201 ----------------------------------------
1202 -- Properties of supported interfaces --
1203 ----------------------------------------
1207 CND(Need_Netdb_Buffer, "Need buffer for Netdb ops")
1208 CND(Has_Sockaddr_Len, "Sockaddr has sa_len field")
1211 ** Do not change the format of the line below without also updating the
1214 TXT(" Thread_Blocking_IO : constant Boolean := True;")
1216 -- Set False for contexts where socket i/o are process blocking
1220 #ifdef HAVE_INET_PTON
1221 # define Inet_Pton_Linkname "inet_pton"
1223 # define Inet_Pton_Linkname "__gnat_inet_pton"
1225 TXT(" Inet_Pton_Linkname : constant String := \"" Inet_Pton_Linkname "\";")
1227 #endif /* HAVE_SOCKETS */
1230 ** System-specific constants follow
1231 ** Each section should be activated if compiling for the corresponding
1232 ** platform *or* generating the dummy version for runtime test compilation.
1235 #if defined (__vxworks) || defined (DUMMY)
1239 --------------------------------
1240 -- VxWorks-specific constants --
1241 --------------------------------
1243 -- These constants may be used only within the VxWorks version of
1244 -- GNAT.Sockets.Thin.
1247 CND(OK, "VxWorks generic success")
1248 CND(ERROR, "VxWorks generic error")
1252 #if defined (__MINGW32__) || defined (DUMMY)
1255 ------------------------------
1256 -- MinGW-specific constants --
1257 ------------------------------
1259 -- These constants may be used only within the MinGW version of
1260 -- GNAT.Sockets.Thin.
1263 CND(WSASYSNOTREADY, "System not ready")
1264 CND(WSAVERNOTSUPPORTED, "Version not supported")
1265 CND(WSANOTINITIALISED, "Winsock not initialized")
1266 CND(WSAEDISCON, "Disconnected")
1274 #if defined (__APPLE__) || defined (DUMMY)
1277 -------------------------------
1278 -- Darwin-specific constants --
1279 -------------------------------
1281 -- These constants may be used only within the Darwin version of the GNAT
1285 #define PTHREAD_SIZE __PTHREAD_SIZE__
1286 CND(PTHREAD_SIZE, "Pad in pthread_t")
1288 #define PTHREAD_ATTR_SIZE __PTHREAD_ATTR_SIZE__
1289 CND(PTHREAD_ATTR_SIZE, "Pad in pthread_attr_t")
1291 #define PTHREAD_MUTEXATTR_SIZE __PTHREAD_MUTEXATTR_SIZE__
1292 CND(PTHREAD_MUTEXATTR_SIZE, "Pad in pthread_mutexattr_t")
1294 #define PTHREAD_MUTEX_SIZE __PTHREAD_MUTEX_SIZE__
1295 CND(PTHREAD_MUTEX_SIZE, "Pad in pthread_mutex_t")
1297 #define PTHREAD_CONDATTR_SIZE __PTHREAD_CONDATTR_SIZE__
1298 CND(PTHREAD_CONDATTR_SIZE, "Pad in pthread_condattr_t")
1300 #define PTHREAD_COND_SIZE __PTHREAD_COND_SIZE__
1301 CND(PTHREAD_COND_SIZE, "Pad in pthread_cond_t")
1303 #define PTHREAD_RWLOCKATTR_SIZE __PTHREAD_RWLOCKATTR_SIZE__
1304 CND(PTHREAD_RWLOCKATTR_SIZE, "Pad in pthread_rwlockattr_t")
1306 #define PTHREAD_RWLOCK_SIZE __PTHREAD_RWLOCK_SIZE__
1307 CND(PTHREAD_RWLOCK_SIZE, "Pad in pthread_rwlock_t")
1309 #define PTHREAD_ONCE_SIZE __PTHREAD_ONCE_SIZE__
1310 CND(PTHREAD_ONCE_SIZE, "Pad in pthread_once_t")
1316 end System.OS_Constants;