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 6, _XOPEN5 must be defined and _XOPEN_IOV_MAX must be used as
88 ** IOV_MAX, otherwise IOV_MAX is not defined. IRIX 5 has neither.
92 #define IOV_MAX _XOPEN_IOV_MAX
101 #if defined (__alpha__) && defined (__osf__)
102 /** Tru64 is unable to do vector IO operations with default value of IOV_MAX,
103 ** so its value is redefined to a small one which is known to work properly.
110 /** VMS is unable to do vector IO operations with default value of IOV_MAX,
111 ** so its value is redefined to a small one which is known to work properly.
117 #if ! (defined (__vxworks) || defined (__VMS) || defined (__MINGW32__) || \
118 defined (__nucleus__))
119 # define HAVE_TERMIOS
122 #if defined (__vxworks)
125 ** For VxWorks, always include vxWorks.h (gsocket.h provides it only for
126 ** the case of runtime libraries that support sockets).
129 # include <vxWorks.h>
136 # if defined (TARGET)
137 # error TARGET may not be defined when generating the dummy version
139 # define TARGET "batch runtime compilation (dummy values)"
142 # if !(defined (HAVE_SOCKETS) && defined (HAVE_TERMIOS))
143 # error Features missing on platform
151 # error Please define TARGET
159 # include <termios.h>
171 # define _VAL(x) counter++
176 #define CND(name,comment) \
177 printf ("\n->CND:$%d:" #name ":$%d:" comment, __LINE__, ((int) _VAL (name)));
179 #define CNS(name,comment) \
180 printf ("\n->CNS:$%d:" #name ":" name ":" comment, __LINE__);
182 #define C(sname,type,value,comment)\
183 printf ("\n->C:$%d:" sname ":" #type ":" value ":" comment, __LINE__);
186 printf ("\n->TXT:$%d:" text, __LINE__);
190 #define CND(name, comment) \
191 asm volatile("\n->CND:%0:" #name ":%1:" comment \
192 : : "i" (__LINE__), "i" ((int) name));
193 /* Decimal constant in the range of type "int" */
195 #define CNS(name, comment) \
196 asm volatile("\n->CNS:%0:" #name ":" name ":" comment \
198 /* General expression named number */
200 #define C(sname, type, value, comment) \
201 asm volatile("\n->C:%0:" sname ":" #type ":" value ":" comment \
206 asm volatile("\n->TXT:%0:" text \
212 #define CST(name,comment) C(#name,String,name,comment)
214 #define STR(x) STR1(x)
218 unsigned int _CRT_fmode
= _O_BINARY
;
225 -- This package provides target dependent definitions of constant for use
226 -- by the GNAT runtime library. This package should not be directly with'd
227 -- by an application program.
229 -- This file is generated automatically, do not modify it by hand! Instead,
230 -- make changes to s-oscons-tmplt.c and rebuild the GNAT runtime library.
234 ** Do not change the format of the line below without also updating the
237 TXT("-- This is the version for " TARGET
)
242 ** The type definitions for struct hostent components uses Interfaces.C
245 TXT("with Interfaces.C;")
249 package System.OS_Constants is
255 ** General constants (all platforms)
260 -----------------------------
261 -- Platform identification --
262 -----------------------------
264 type OS_Type is (Windows, VMS, Other_OS);
266 #if defined (__MINGW32__)
267 # define TARGET_OS "Windows"
268 #elif defined (__VMS)
269 # define TARGET_OS "VMS"
271 # define TARGET_OS "Other_OS"
273 C("Target_OS", OS_Type
, TARGET_OS
, "")
274 #define Target_Name TARGET
285 # define IOV_MAX INT_MAX
287 CND(IOV_MAX
, "Maximum writev iovcnt")
291 ---------------------
292 -- File open modes --
293 ---------------------
300 CND(O_RDWR
, "Read/write")
305 CND(O_NOCTTY
, "Don't change ctrl tty")
310 CND(O_NDELAY
, "Nonblocking")
314 ----------------------
315 -- Fcntl operations --
316 ----------------------
323 CND(F_GETFL
, "Get flags")
328 CND(F_SETFL
, "Set flags")
341 CND(FNDELAY
, "Nonblocking")
345 ----------------------
346 -- Ioctl operations --
347 ----------------------
354 CND(FIONBIO
, "Set/clear non-blocking io")
359 CND(FIONREAD
, "How many bytes to read")
367 -- The following constants are defined from <errno.h>
373 CND(EAGAIN
, "Try again")
378 CND(ENOENT
, "File not found")
383 CND(ENOMEM
, "Out of memory")
388 -- The following constants are defined from <winsock2.h> (WSA*)
393 ** For sockets-related errno values on Windows, gsocket.h redefines
402 CND(EACCES
, "Permission denied")
405 # define EADDRINUSE -1
407 CND(EADDRINUSE
, "Address already in use")
409 #ifndef EADDRNOTAVAIL
410 # define EADDRNOTAVAIL -1
412 CND(EADDRNOTAVAIL
, "Cannot assign address")
415 # define EAFNOSUPPORT -1
417 CND(EAFNOSUPPORT
, "Addr family not supported")
422 CND(EALREADY
, "Operation in progress")
427 CND(EBADF
, "Bad file descriptor")
430 # define ECONNABORTED -1
432 CND(ECONNABORTED
, "Connection aborted")
435 # define ECONNREFUSED -1
437 CND(ECONNREFUSED
, "Connection refused")
440 # define ECONNRESET -1
442 CND(ECONNRESET
, "Connection reset by peer")
445 # define EDESTADDRREQ -1
447 CND(EDESTADDRREQ
, "Destination addr required")
452 CND(EFAULT
, "Bad address")
455 # define EHOSTDOWN -1
457 CND(EHOSTDOWN
, "Host is down")
460 # define EHOSTUNREACH -1
462 CND(EHOSTUNREACH
, "No route to host")
465 # define EINPROGRESS -1
467 CND(EINPROGRESS
, "Operation now in progress")
472 CND(EINTR
, "Interrupted system call")
477 CND(EINVAL
, "Invalid argument")
482 CND(EIO
, "Input output error")
487 CND(EISCONN
, "Socket already connected")
492 CND(ELOOP
, "Too many symbolic links")
497 CND(EMFILE
, "Too many open files")
502 CND(EMSGSIZE
, "Message too long")
505 # define ENAMETOOLONG -1
507 CND(ENAMETOOLONG
, "Name too long")
512 CND(ENETDOWN
, "Network is down")
515 # define ENETRESET -1
517 CND(ENETRESET
, "Disconn. on network reset")
520 # define ENETUNREACH -1
522 CND(ENETUNREACH
, "Network is unreachable")
527 CND(ENOBUFS
, "No buffer space available")
530 # define ENOPROTOOPT -1
532 CND(ENOPROTOOPT
, "Protocol not available")
537 CND(ENOTCONN
, "Socket not connected")
542 CND(ENOTSOCK
, "Operation on non socket")
545 # define EOPNOTSUPP -1
547 CND(EOPNOTSUPP
, "Operation not supported")
552 CND(EPIPE
, "Broken pipe")
555 # define EPFNOSUPPORT -1
557 CND(EPFNOSUPPORT
, "Unknown protocol family")
559 #ifndef EPROTONOSUPPORT
560 # define EPROTONOSUPPORT -1
562 CND(EPROTONOSUPPORT
, "Unknown protocol")
565 # define EPROTOTYPE -1
567 CND(EPROTOTYPE
, "Unknown protocol type")
572 CND(ERANGE
, "Result too large")
575 # define ESHUTDOWN -1
577 CND(ESHUTDOWN
, "Cannot send once shutdown")
579 #ifndef ESOCKTNOSUPPORT
580 # define ESOCKTNOSUPPORT -1
582 CND(ESOCKTNOSUPPORT
, "Socket type not supported")
585 # define ETIMEDOUT -1
587 CND(ETIMEDOUT
, "Connection timed out")
590 # define ETOOMANYREFS -1
592 CND(ETOOMANYREFS
, "Too many references")
595 # define EWOULDBLOCK -1
597 CND(EWOULDBLOCK
, "Operation would block")
600 ** Terminal I/O constants
607 ----------------------
608 -- Terminal control --
609 ----------------------
616 CND(TCSANOW
, "Immediate")
621 CND(TCIFLUSH
, "Flush input")
631 CND(CRTSCTS
, "Hardware flow control")
641 CND(CS5
, "5 data bits")
646 CND(CS6
, "6 data bits")
651 CND(CS7
, "7 data bits")
656 CND(CS8
, "8 data bits")
661 CND(CSTOPB
, "2 stop bits")
666 CND(PARENB
, "Parity enable")
671 CND(PARODD
, "Parity odd")
721 CND(B1200
, "1200 bps")
726 CND(B1800
, "1800 bps")
731 CND(B2400
, "2400 bps")
736 CND(B4800
, "4800 bps")
741 CND(B9600
, "9600 bps")
746 CND(B19200
, "19200 bps")
751 CND(B38400
, "38400 bps")
756 CND(B57600
, "57600 bps")
761 CND(B115200
, "115200 bps")
766 CND(B230400
, "230400 bps")
771 CND(B460800
, "460800 bps")
776 CND(B500000
, "500000 bps")
781 CND(B576000
, "576000 bps")
786 CND(B921600
, "921600 bps")
791 CND(B1000000
, "1000000 bps")
796 CND(B1152000
, "1152000 bps")
801 CND(B1500000
, "1500000 bps")
806 CND(B2000000
, "2000000 bps")
811 CND(B2500000
, "2500000 bps")
816 CND(B3000000
, "3000000 bps")
821 CND(B3500000
, "3500000 bps")
826 CND(B4000000
, "4000000 bps")
830 ---------------------------------
831 -- Terminal control characters --
832 ---------------------------------
839 CND(VINTR
, "Interrupt")
864 CND(VTIME
, "Read timeout")
869 CND(VMIN
, "Read min chars")
879 CND(VSTART
, "Flow control start")
884 CND(VSTOP
, "Flow control stop")
889 CND(VSUSP
, "Suspend")
899 CND(VREPRINT
, "Reprint unread")
904 CND(VDISCARD
, "Discard pending")
909 CND(VWERASE
, "Word erase")
914 CND(VLNEXT
, "Literal next")
919 CND(VEOL2
, "Alternative EOL")
921 #endif /* HAVE_TERMIOS */
940 CND(AF_INET
, "IPv4 address family")
943 ** RTEMS lies and defines AF_INET6 even though there is no IPV6 support.
944 ** Its TCP/IP stack is in transition. It has newer .h files but no IPV6 yet.
946 #if defined(__rtems__)
951 ** Tru64 UNIX V4.0F defines AF_INET6 without IPv6 support, specifically
952 ** without struct sockaddr_in6. We use _SS_MAXSIZE (used for the definition
953 ** of struct sockaddr_storage on Tru64 UNIX V5.1) to detect this.
955 #if defined(__osf__) && !defined(_SS_MAXSIZE)
962 # define HAVE_AF_INET6 1
964 CND(AF_INET6
, "IPv6 address family")
975 # define SOCK_STREAM -1
977 CND(SOCK_STREAM
, "Stream socket")
980 # define SOCK_DGRAM -1
982 CND(SOCK_DGRAM
, "Datagram socket")
992 #ifndef HOST_NOT_FOUND
993 # define HOST_NOT_FOUND -1
995 CND(HOST_NOT_FOUND
, "Unknown host")
998 # define TRY_AGAIN -1
1000 CND(TRY_AGAIN
, "Host name lookup failure")
1005 CND(NO_DATA
, "No data record for name")
1008 # define NO_RECOVERY -1
1010 CND(NO_RECOVERY
, "Non recoverable errors")
1014 --------------------
1015 -- Shutdown modes --
1016 --------------------
1023 CND(SHUT_RD
, "No more recv")
1028 CND(SHUT_WR
, "No more send")
1031 # define SHUT_RDWR -1
1033 CND(SHUT_RDWR
, "No more recv/send")
1037 ---------------------
1038 -- Protocol levels --
1039 ---------------------
1044 # define SOL_SOCKET -1
1046 CND(SOL_SOCKET
, "Options for socket level")
1049 # define IPPROTO_IP -1
1051 CND(IPPROTO_IP
, "Dummy protocol for IP")
1054 # define IPPROTO_UDP -1
1056 CND(IPPROTO_UDP
, "UDP")
1059 # define IPPROTO_TCP -1
1061 CND(IPPROTO_TCP
, "TCP")
1074 CND(MSG_OOB
, "Process out-of-band data")
1077 # define MSG_PEEK -1
1079 CND(MSG_PEEK
, "Peek at incoming data")
1084 CND(MSG_EOR
, "Send end of record")
1087 # define MSG_WAITALL -1
1089 CND(MSG_WAITALL
, "Wait for full reception")
1091 #ifndef MSG_NOSIGNAL
1092 # define MSG_NOSIGNAL -1
1094 CND(MSG_NOSIGNAL
, "No SIGPIPE on send")
1097 # define MSG_Forced_Flags "MSG_NOSIGNAL"
1099 # define MSG_Forced_Flags "0"
1101 CNS(MSG_Forced_Flags
, "")
1103 -- Flags set on all send(2) calls
1108 --------------------
1109 -- Socket options --
1110 --------------------
1115 # define TCP_NODELAY -1
1117 CND(TCP_NODELAY
, "Do not coalesce packets")
1119 #ifndef SO_REUSEADDR
1120 # define SO_REUSEADDR -1
1122 CND(SO_REUSEADDR
, "Bind reuse local address")
1124 #ifndef SO_REUSEPORT
1125 # define SO_REUSEPORT -1
1127 CND(SO_REUSEPORT
, "Bind reuse port number")
1129 #ifndef SO_KEEPALIVE
1130 # define SO_KEEPALIVE -1
1132 CND(SO_KEEPALIVE
, "Enable keep-alive msgs")
1135 # define SO_LINGER -1
1137 CND(SO_LINGER
, "Defer close to flush data")
1139 #ifndef SO_BROADCAST
1140 # define SO_BROADCAST -1
1142 CND(SO_BROADCAST
, "Can send broadcast msgs")
1145 # define SO_SNDBUF -1
1147 CND(SO_SNDBUF
, "Set/get send buffer size")
1150 # define SO_RCVBUF -1
1152 CND(SO_RCVBUF
, "Set/get recv buffer size")
1155 # define SO_SNDTIMEO -1
1157 CND(SO_SNDTIMEO
, "Emission timeout")
1160 # define SO_RCVTIMEO -1
1162 CND(SO_RCVTIMEO
, "Reception timeout")
1165 # define SO_ERROR -1
1167 CND(SO_ERROR
, "Get/clear error status")
1169 #ifndef IP_MULTICAST_IF
1170 # define IP_MULTICAST_IF -1
1172 CND(IP_MULTICAST_IF
, "Set/get mcast interface")
1174 #ifndef IP_MULTICAST_TTL
1175 # define IP_MULTICAST_TTL -1
1177 CND(IP_MULTICAST_TTL
, "Set/get multicast TTL")
1179 #ifndef IP_MULTICAST_LOOP
1180 # define IP_MULTICAST_LOOP -1
1182 CND(IP_MULTICAST_LOOP
, "Set/get mcast loopback")
1184 #ifndef IP_ADD_MEMBERSHIP
1185 # define IP_ADD_MEMBERSHIP -1
1187 CND(IP_ADD_MEMBERSHIP
, "Join a multicast group")
1189 #ifndef IP_DROP_MEMBERSHIP
1190 # define IP_DROP_MEMBERSHIP -1
1192 CND(IP_DROP_MEMBERSHIP
, "Leave a multicast group")
1195 # define IP_PKTINFO -1
1197 CND(IP_PKTINFO
, "Get datagram info")
1201 ----------------------
1202 -- Type definitions --
1203 ----------------------
1210 -- Sizes (in bytes) of the components of struct timeval
1212 #define SIZEOF_tv_sec (sizeof tv.tv_sec)
1213 CND(SIZEOF_tv_sec
, "tv_sec")
1214 #define SIZEOF_tv_usec (sizeof tv.tv_usec)
1215 CND(SIZEOF_tv_usec
, "tv_usec")
1219 -- Sizes of various data types
1222 #define SIZEOF_sockaddr_in (sizeof (struct sockaddr_in))
1223 CND(SIZEOF_sockaddr_in
, "struct sockaddr_in")
1224 #ifdef HAVE_AF_INET6
1225 # define SIZEOF_sockaddr_in6 (sizeof (struct sockaddr_in6))
1227 # define SIZEOF_sockaddr_in6 0
1229 CND(SIZEOF_sockaddr_in6
, "struct sockaddr_in6")
1231 #define SIZEOF_fd_set (sizeof (fd_set))
1232 CND(SIZEOF_fd_set
, "fd_set");
1234 #define SIZEOF_struct_hostent (sizeof (struct hostent))
1235 CND(SIZEOF_struct_hostent
, "struct hostent");
1237 #define SIZEOF_struct_servent (sizeof (struct servent))
1238 CND(SIZEOF_struct_servent
, "struct servent");
1241 -- Fields of struct msghdr
1244 #if defined (__sun__) || defined (__hpux__)
1245 # define msg_iovlen_t "int"
1247 # define msg_iovlen_t "size_t"
1250 TXT(" subtype Msg_Iovlen_T is Interfaces.C." msg_iovlen_t
";")
1254 ----------------------------------------
1255 -- Properties of supported interfaces --
1256 ----------------------------------------
1260 CND(Need_Netdb_Buffer
, "Need buffer for Netdb ops")
1261 CND(Need_Netdb_Lock
, "Need lock for Netdb ops")
1262 CND(Has_Sockaddr_Len
, "Sockaddr has sa_len field")
1265 ** Do not change the format of the line below without also updating the
1268 C("Thread_Blocking_IO", Boolean
, "True", "")
1270 -- Set False for contexts where socket i/o are process blocking
1274 #ifdef HAVE_INET_PTON
1275 # define Inet_Pton_Linkname "inet_pton"
1277 # define Inet_Pton_Linkname "__gnat_inet_pton"
1279 CST(Inet_Pton_Linkname
, "")
1281 #endif /* HAVE_SOCKETS */
1284 ** System-specific constants follow
1285 ** Each section should be activated if compiling for the corresponding
1286 ** platform *or* generating the dummy version for runtime test compilation.
1289 #if defined (__vxworks) || defined (DUMMY)
1293 --------------------------------
1294 -- VxWorks-specific constants --
1295 --------------------------------
1297 -- These constants may be used only within the VxWorks version of
1298 -- GNAT.Sockets.Thin.
1301 CND(OK
, "VxWorks generic success")
1302 CND(ERROR
, "VxWorks generic error")
1306 #if defined (__MINGW32__) || defined (DUMMY)
1309 ------------------------------
1310 -- MinGW-specific constants --
1311 ------------------------------
1313 -- These constants may be used only within the MinGW version of
1314 -- GNAT.Sockets.Thin.
1317 CND(WSASYSNOTREADY
, "System not ready")
1318 CND(WSAVERNOTSUPPORTED
, "Version not supported")
1319 CND(WSANOTINITIALISED
, "Winsock not initialized")
1320 CND(WSAEDISCON
, "Disconnected")
1328 #if defined (__APPLE__) || defined (DUMMY)
1331 -------------------------------
1332 -- Darwin-specific constants --
1333 -------------------------------
1335 -- These constants may be used only within the Darwin version of the GNAT
1339 #define PTHREAD_SIZE __PTHREAD_SIZE__
1340 CND(PTHREAD_SIZE
, "Pad in pthread_t")
1342 #define PTHREAD_ATTR_SIZE __PTHREAD_ATTR_SIZE__
1343 CND(PTHREAD_ATTR_SIZE
, "Pad in pthread_attr_t")
1345 #define PTHREAD_MUTEXATTR_SIZE __PTHREAD_MUTEXATTR_SIZE__
1346 CND(PTHREAD_MUTEXATTR_SIZE
, "Pad in pthread_mutexattr_t")
1348 #define PTHREAD_MUTEX_SIZE __PTHREAD_MUTEX_SIZE__
1349 CND(PTHREAD_MUTEX_SIZE
, "Pad in pthread_mutex_t")
1351 #define PTHREAD_CONDATTR_SIZE __PTHREAD_CONDATTR_SIZE__
1352 CND(PTHREAD_CONDATTR_SIZE
, "Pad in pthread_condattr_t")
1354 #define PTHREAD_COND_SIZE __PTHREAD_COND_SIZE__
1355 CND(PTHREAD_COND_SIZE
, "Pad in pthread_cond_t")
1357 #define PTHREAD_RWLOCKATTR_SIZE __PTHREAD_RWLOCKATTR_SIZE__
1358 CND(PTHREAD_RWLOCKATTR_SIZE
, "Pad in pthread_rwlockattr_t")
1360 #define PTHREAD_RWLOCK_SIZE __PTHREAD_RWLOCK_SIZE__
1361 CND(PTHREAD_RWLOCK_SIZE
, "Pad in pthread_rwlock_t")
1363 #define PTHREAD_ONCE_SIZE __PTHREAD_ONCE_SIZE__
1364 CND(PTHREAD_ONCE_SIZE
, "Pad in pthread_once_t")
1370 end System.OS_Constants;