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 (__vxworks) || defined (__VMS) || defined (__MINGW32__) || \
102 defined (__nucleus__))
103 # define HAVE_TERMIOS
106 #if defined (__vxworks)
109 ** For VxWorks, always include vxWorks.h (gsocket.h provides it only for
110 ** the case of runtime libraries that support sockets).
113 # include <vxWorks.h>
120 # if defined (TARGET)
121 # error TARGET may not be defined when generating the dummy version
123 # define TARGET "batch runtime compilation (dummy values)"
126 # if !(defined (HAVE_SOCKETS) && defined (HAVE_TERMIOS))
127 # error Features missing on platform
135 # error Please define TARGET
143 # include <termios.h>
155 # define _VAL(x) counter++
160 #define CND(name,comment) \
161 printf ("\n->CND:$%d:" #name ":$%d:" comment, __LINE__, ((int) _VAL (name)));
163 #define CNS(name,comment) \
164 printf ("\n->CNS:$%d:" #name ":" name ":" comment, __LINE__);
166 #define C(sname,type,value,comment)\
167 printf ("\n->C:$%d:" sname ":" #type ":" value ":" comment, __LINE__);
170 printf ("\n->TXT:$%d:" text, __LINE__);
174 #define CND(name, comment) \
175 asm volatile("\n->CND:%0:" #name ":%1:" comment \
176 : : "i" (__LINE__), "i" ((int) name));
177 /* Decimal constant in the range of type "int" */
179 #define CNS(name, comment) \
180 asm volatile("\n->CNS:%0:" #name ":" name ":" comment \
182 /* General expression named number */
184 #define C(sname, type, value, comment) \
185 asm volatile("\n->C:%0:" sname ":" #type ":" value ":" comment \
190 asm volatile("\n->TXT:%0:" text \
196 #define CST(name,comment) C(#name,String,name,comment)
198 #define STR(x) STR1(x)
202 unsigned int _CRT_fmode
= _O_BINARY
;
209 -- This package provides target dependent definitions of constant for use
210 -- by the GNAT runtime library. This package should not be directly with'd
211 -- by an application program.
213 -- This file is generated automatically, do not modify it by hand! Instead,
214 -- make changes to s-oscons-tmplt.c and rebuild the GNAT runtime library.
218 ** Do not change the format of the line below without also updating the
221 TXT("-- This is the version for " TARGET
)
226 ** The type definitions for struct hostent components uses Interfaces.C
229 TXT("with Interfaces.C;")
233 package System.OS_Constants is
239 ** General constants (all platforms)
244 -----------------------------
245 -- Platform identification --
246 -----------------------------
248 type OS_Type is (Windows, VMS, Other_OS);
250 #if defined (__MINGW32__)
251 # define TARGET_OS "Windows"
252 #elif defined (__VMS)
253 # define TARGET_OS "VMS"
255 # define TARGET_OS "Other_OS"
257 C("Target_OS", OS_Type
, TARGET_OS
, "")
258 #define Target_Name TARGET
269 # define IOV_MAX INT_MAX
271 CND(IOV_MAX
, "Maximum writev iovcnt")
275 ---------------------
276 -- File open modes --
277 ---------------------
284 CND(O_RDWR
, "Read/write")
289 CND(O_NOCTTY
, "Don't change ctrl tty")
294 CND(O_NDELAY
, "Nonblocking")
298 ----------------------
299 -- Fcntl operations --
300 ----------------------
307 CND(F_GETFL
, "Get flags")
312 CND(F_SETFL
, "Set flags")
325 CND(FNDELAY
, "Nonblocking")
329 ----------------------
330 -- Ioctl operations --
331 ----------------------
338 CND(FIONBIO
, "Set/clear non-blocking io")
343 CND(FIONREAD
, "How many bytes to read")
351 -- The following constants are defined from <errno.h>
357 CND(EAGAIN
, "Try again")
362 CND(ENOENT
, "File not found")
367 CND(ENOMEM
, "Out of memory")
372 -- The following constants are defined from <winsock2.h> (WSA*)
377 ** For sockets-related errno values on Windows, gsocket.h redefines
386 CND(EACCES
, "Permission denied")
389 # define EADDRINUSE -1
391 CND(EADDRINUSE
, "Address already in use")
393 #ifndef EADDRNOTAVAIL
394 # define EADDRNOTAVAIL -1
396 CND(EADDRNOTAVAIL
, "Cannot assign address")
399 # define EAFNOSUPPORT -1
401 CND(EAFNOSUPPORT
, "Addr family not supported")
406 CND(EALREADY
, "Operation in progress")
411 CND(EBADF
, "Bad file descriptor")
414 # define ECONNABORTED -1
416 CND(ECONNABORTED
, "Connection aborted")
419 # define ECONNREFUSED -1
421 CND(ECONNREFUSED
, "Connection refused")
424 # define ECONNRESET -1
426 CND(ECONNRESET
, "Connection reset by peer")
429 # define EDESTADDRREQ -1
431 CND(EDESTADDRREQ
, "Destination addr required")
436 CND(EFAULT
, "Bad address")
439 # define EHOSTDOWN -1
441 CND(EHOSTDOWN
, "Host is down")
444 # define EHOSTUNREACH -1
446 CND(EHOSTUNREACH
, "No route to host")
449 # define EINPROGRESS -1
451 CND(EINPROGRESS
, "Operation now in progress")
456 CND(EINTR
, "Interrupted system call")
461 CND(EINVAL
, "Invalid argument")
466 CND(EIO
, "Input output error")
471 CND(EISCONN
, "Socket already connected")
476 CND(ELOOP
, "Too many symbolic links")
481 CND(EMFILE
, "Too many open files")
486 CND(EMSGSIZE
, "Message too long")
489 # define ENAMETOOLONG -1
491 CND(ENAMETOOLONG
, "Name too long")
496 CND(ENETDOWN
, "Network is down")
499 # define ENETRESET -1
501 CND(ENETRESET
, "Disconn. on network reset")
504 # define ENETUNREACH -1
506 CND(ENETUNREACH
, "Network is unreachable")
511 CND(ENOBUFS
, "No buffer space available")
514 # define ENOPROTOOPT -1
516 CND(ENOPROTOOPT
, "Protocol not available")
521 CND(ENOTCONN
, "Socket not connected")
526 CND(ENOTSOCK
, "Operation on non socket")
529 # define EOPNOTSUPP -1
531 CND(EOPNOTSUPP
, "Operation not supported")
536 CND(EPIPE
, "Broken pipe")
539 # define EPFNOSUPPORT -1
541 CND(EPFNOSUPPORT
, "Unknown protocol family")
543 #ifndef EPROTONOSUPPORT
544 # define EPROTONOSUPPORT -1
546 CND(EPROTONOSUPPORT
, "Unknown protocol")
549 # define EPROTOTYPE -1
551 CND(EPROTOTYPE
, "Unknown protocol type")
556 CND(ERANGE
, "Result too large")
559 # define ESHUTDOWN -1
561 CND(ESHUTDOWN
, "Cannot send once shutdown")
563 #ifndef ESOCKTNOSUPPORT
564 # define ESOCKTNOSUPPORT -1
566 CND(ESOCKTNOSUPPORT
, "Socket type not supported")
569 # define ETIMEDOUT -1
571 CND(ETIMEDOUT
, "Connection timed out")
574 # define ETOOMANYREFS -1
576 CND(ETOOMANYREFS
, "Too many references")
579 # define EWOULDBLOCK -1
581 CND(EWOULDBLOCK
, "Operation would block")
584 ** Terminal I/O constants
591 ----------------------
592 -- Terminal control --
593 ----------------------
600 CND(TCSANOW
, "Immediate")
605 CND(TCIFLUSH
, "Flush input")
615 CND(CRTSCTS
, "Hardware flow control")
625 CND(CS5
, "5 data bits")
630 CND(CS6
, "6 data bits")
635 CND(CS7
, "7 data bits")
640 CND(CS8
, "8 data bits")
645 CND(CSTOPB
, "2 stop bits")
650 CND(PARENB
, "Parity enable")
655 CND(PARODD
, "Parity odd")
705 CND(B1200
, "1200 bps")
710 CND(B1800
, "1800 bps")
715 CND(B2400
, "2400 bps")
720 CND(B4800
, "4800 bps")
725 CND(B9600
, "9600 bps")
730 CND(B19200
, "19200 bps")
735 CND(B38400
, "38400 bps")
740 CND(B57600
, "57600 bps")
745 CND(B115200
, "115200 bps")
750 CND(B230400
, "230400 bps")
755 CND(B460800
, "460800 bps")
760 CND(B500000
, "500000 bps")
765 CND(B576000
, "576000 bps")
770 CND(B921600
, "921600 bps")
775 CND(B1000000
, "1000000 bps")
780 CND(B1152000
, "1152000 bps")
785 CND(B1500000
, "1500000 bps")
790 CND(B2000000
, "2000000 bps")
795 CND(B2500000
, "2500000 bps")
800 CND(B3000000
, "3000000 bps")
805 CND(B3500000
, "3500000 bps")
810 CND(B4000000
, "4000000 bps")
814 ---------------------------------
815 -- Terminal control characters --
816 ---------------------------------
823 CND(VINTR
, "Interrupt")
848 CND(VTIME
, "Read timeout")
853 CND(VMIN
, "Read min chars")
863 CND(VSTART
, "Flow control start")
868 CND(VSTOP
, "Flow control stop")
873 CND(VSUSP
, "Suspend")
883 CND(VREPRINT
, "Reprint unread")
888 CND(VDISCARD
, "Discard pending")
893 CND(VWERASE
, "Word erase")
898 CND(VLNEXT
, "Literal next")
903 CND(VEOL2
, "Alternative EOL")
905 #endif /* HAVE_TERMIOS */
924 CND(AF_INET
, "IPv4 address family")
927 ** RTEMS lies and defines AF_INET6 even though there is no IPV6 support.
928 ** Its TCP/IP stack is in transition. It has newer .h files but no IPV6 yet.
930 #if defined(__rtems__)
935 ** Tru64 UNIX V4.0F defines AF_INET6 without IPv6 support, specificially
936 ** without struct sockaddr_in6. We use _SS_MAXSIZE (used for the definition
937 ** of struct sockaddr_storage on Tru64 UNIX V5.1) to detect this.
939 #if defined(__osf__) && !defined(_SS_MAXSIZE)
946 # define HAVE_AF_INET6 1
948 CND(AF_INET6
, "IPv6 address family")
959 # define SOCK_STREAM -1
961 CND(SOCK_STREAM
, "Stream socket")
964 # define SOCK_DGRAM -1
966 CND(SOCK_DGRAM
, "Datagram socket")
976 #ifndef HOST_NOT_FOUND
977 # define HOST_NOT_FOUND -1
979 CND(HOST_NOT_FOUND
, "Unknown host")
982 # define TRY_AGAIN -1
984 CND(TRY_AGAIN
, "Host name lookup failure")
989 CND(NO_DATA
, "No data record for name")
992 # define NO_RECOVERY -1
994 CND(NO_RECOVERY
, "Non recoverable errors")
1000 --------------------
1007 CND(SHUT_RD
, "No more recv")
1012 CND(SHUT_WR
, "No more send")
1015 # define SHUT_RDWR -1
1017 CND(SHUT_RDWR
, "No more recv/send")
1021 ---------------------
1022 -- Protocol levels --
1023 ---------------------
1028 # define SOL_SOCKET -1
1030 CND(SOL_SOCKET
, "Options for socket level")
1033 # define IPPROTO_IP -1
1035 CND(IPPROTO_IP
, "Dummy protocol for IP")
1038 # define IPPROTO_UDP -1
1040 CND(IPPROTO_UDP
, "UDP")
1043 # define IPPROTO_TCP -1
1045 CND(IPPROTO_TCP
, "TCP")
1058 CND(MSG_OOB
, "Process out-of-band data")
1061 # define MSG_PEEK -1
1063 CND(MSG_PEEK
, "Peek at incoming data")
1068 CND(MSG_EOR
, "Send end of record")
1071 # define MSG_WAITALL -1
1073 CND(MSG_WAITALL
, "Wait for full reception")
1075 #ifndef MSG_NOSIGNAL
1076 # define MSG_NOSIGNAL -1
1078 CND(MSG_NOSIGNAL
, "No SIGPIPE on send")
1081 # define MSG_Forced_Flags "MSG_NOSIGNAL"
1083 # define MSG_Forced_Flags "0"
1085 CNS(MSG_Forced_Flags
, "")
1087 -- Flags set on all send(2) calls
1092 --------------------
1093 -- Socket options --
1094 --------------------
1099 # define TCP_NODELAY -1
1101 CND(TCP_NODELAY
, "Do not coalesce packets")
1103 #ifndef SO_REUSEADDR
1104 # define SO_REUSEADDR -1
1106 CND(SO_REUSEADDR
, "Bind reuse local address")
1108 #ifndef SO_REUSEPORT
1109 # define SO_REUSEPORT -1
1111 CND(SO_REUSEPORT
, "Bind reuse port number")
1113 #ifndef SO_KEEPALIVE
1114 # define SO_KEEPALIVE -1
1116 CND(SO_KEEPALIVE
, "Enable keep-alive msgs")
1119 # define SO_LINGER -1
1121 CND(SO_LINGER
, "Defer close to flush data")
1123 #ifndef SO_BROADCAST
1124 # define SO_BROADCAST -1
1126 CND(SO_BROADCAST
, "Can send broadcast msgs")
1129 # define SO_SNDBUF -1
1131 CND(SO_SNDBUF
, "Set/get send buffer size")
1134 # define SO_RCVBUF -1
1136 CND(SO_RCVBUF
, "Set/get recv buffer size")
1139 # define SO_SNDTIMEO -1
1141 CND(SO_SNDTIMEO
, "Emission timeout")
1144 # define SO_RCVTIMEO -1
1146 CND(SO_RCVTIMEO
, "Reception timeout")
1149 # define SO_ERROR -1
1151 CND(SO_ERROR
, "Get/clear error status")
1153 #ifndef IP_MULTICAST_IF
1154 # define IP_MULTICAST_IF -1
1156 CND(IP_MULTICAST_IF
, "Set/get mcast interface")
1158 #ifndef IP_MULTICAST_TTL
1159 # define IP_MULTICAST_TTL -1
1161 CND(IP_MULTICAST_TTL
, "Set/get multicast TTL")
1163 #ifndef IP_MULTICAST_LOOP
1164 # define IP_MULTICAST_LOOP -1
1166 CND(IP_MULTICAST_LOOP
, "Set/get mcast loopback")
1168 #ifndef IP_ADD_MEMBERSHIP
1169 # define IP_ADD_MEMBERSHIP -1
1171 CND(IP_ADD_MEMBERSHIP
, "Join a multicast group")
1173 #ifndef IP_DROP_MEMBERSHIP
1174 # define IP_DROP_MEMBERSHIP -1
1176 CND(IP_DROP_MEMBERSHIP
, "Leave a multicast group")
1179 # define IP_PKTINFO -1
1181 CND(IP_PKTINFO
, "Get datagram info")
1185 ----------------------
1186 -- Type definitions --
1187 ----------------------
1194 -- Sizes (in bytes) of the components of struct timeval
1196 #define SIZEOF_tv_sec (sizeof tv.tv_sec)
1197 CND(SIZEOF_tv_sec
, "tv_sec")
1198 #define SIZEOF_tv_usec (sizeof tv.tv_usec)
1199 CND(SIZEOF_tv_usec
, "tv_usec")
1203 -- Sizes of various data types
1206 #define SIZEOF_sockaddr_in (sizeof (struct sockaddr_in))
1207 CND(SIZEOF_sockaddr_in
, "struct sockaddr_in")
1208 #ifdef HAVE_AF_INET6
1209 # define SIZEOF_sockaddr_in6 (sizeof (struct sockaddr_in6))
1211 # define SIZEOF_sockaddr_in6 0
1213 CND(SIZEOF_sockaddr_in6
, "struct sockaddr_in6")
1215 #define SIZEOF_fd_set (sizeof (fd_set))
1216 CND(SIZEOF_fd_set
, "fd_set");
1218 #define SIZEOF_struct_servent (sizeof (struct servent))
1219 CND(SIZEOF_struct_servent
, "struct servent");
1222 -- Fields of struct hostent
1226 # define h_addrtype_t "short"
1227 # define h_length_t "short"
1229 # define h_addrtype_t "int"
1230 # define h_length_t "int"
1233 TXT(" subtype H_Addrtype_T is Interfaces.C." h_addrtype_t
";")
1234 TXT(" subtype H_Length_T is Interfaces.C." h_length_t
";")
1238 -- Fields of struct msghdr
1241 #if defined (__sun__) || defined (__hpux__)
1242 # define msg_iovlen_t "int"
1244 # define msg_iovlen_t "size_t"
1247 TXT(" subtype Msg_Iovlen_T is Interfaces.C." msg_iovlen_t
";")
1251 ----------------------------------------
1252 -- Properties of supported interfaces --
1253 ----------------------------------------
1257 CND(Need_Netdb_Buffer
, "Need buffer for Netdb ops")
1258 CND(Has_Sockaddr_Len
, "Sockaddr has sa_len field")
1261 ** Do not change the format of the line below without also updating the
1264 C("Thread_Blocking_IO", Boolean
, "True", "")
1266 -- Set False for contexts where socket i/o are process blocking
1270 #ifdef HAVE_INET_PTON
1271 # define Inet_Pton_Linkname "inet_pton"
1273 # define Inet_Pton_Linkname "__gnat_inet_pton"
1275 CST(Inet_Pton_Linkname
, "")
1277 #endif /* HAVE_SOCKETS */
1280 ** System-specific constants follow
1281 ** Each section should be activated if compiling for the corresponding
1282 ** platform *or* generating the dummy version for runtime test compilation.
1285 #if defined (__vxworks) || defined (DUMMY)
1289 --------------------------------
1290 -- VxWorks-specific constants --
1291 --------------------------------
1293 -- These constants may be used only within the VxWorks version of
1294 -- GNAT.Sockets.Thin.
1297 CND(OK
, "VxWorks generic success")
1298 CND(ERROR
, "VxWorks generic error")
1302 #if defined (__MINGW32__) || defined (DUMMY)
1305 ------------------------------
1306 -- MinGW-specific constants --
1307 ------------------------------
1309 -- These constants may be used only within the MinGW version of
1310 -- GNAT.Sockets.Thin.
1313 CND(WSASYSNOTREADY
, "System not ready")
1314 CND(WSAVERNOTSUPPORTED
, "Version not supported")
1315 CND(WSANOTINITIALISED
, "Winsock not initialized")
1316 CND(WSAEDISCON
, "Disconnected")
1324 #if defined (__APPLE__) || defined (DUMMY)
1327 -------------------------------
1328 -- Darwin-specific constants --
1329 -------------------------------
1331 -- These constants may be used only within the Darwin version of the GNAT
1335 #define PTHREAD_SIZE __PTHREAD_SIZE__
1336 CND(PTHREAD_SIZE
, "Pad in pthread_t")
1338 #define PTHREAD_ATTR_SIZE __PTHREAD_ATTR_SIZE__
1339 CND(PTHREAD_ATTR_SIZE
, "Pad in pthread_attr_t")
1341 #define PTHREAD_MUTEXATTR_SIZE __PTHREAD_MUTEXATTR_SIZE__
1342 CND(PTHREAD_MUTEXATTR_SIZE
, "Pad in pthread_mutexattr_t")
1344 #define PTHREAD_MUTEX_SIZE __PTHREAD_MUTEX_SIZE__
1345 CND(PTHREAD_MUTEX_SIZE
, "Pad in pthread_mutex_t")
1347 #define PTHREAD_CONDATTR_SIZE __PTHREAD_CONDATTR_SIZE__
1348 CND(PTHREAD_CONDATTR_SIZE
, "Pad in pthread_condattr_t")
1350 #define PTHREAD_COND_SIZE __PTHREAD_COND_SIZE__
1351 CND(PTHREAD_COND_SIZE
, "Pad in pthread_cond_t")
1353 #define PTHREAD_RWLOCKATTR_SIZE __PTHREAD_RWLOCKATTR_SIZE__
1354 CND(PTHREAD_RWLOCKATTR_SIZE
, "Pad in pthread_rwlockattr_t")
1356 #define PTHREAD_RWLOCK_SIZE __PTHREAD_RWLOCK_SIZE__
1357 CND(PTHREAD_RWLOCK_SIZE
, "Pad in pthread_rwlock_t")
1359 #define PTHREAD_ONCE_SIZE __PTHREAD_ONCE_SIZE__
1360 CND(PTHREAD_ONCE_SIZE
, "Pad in pthread_once_t")
1366 end System.OS_Constants;