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 2, 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. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNAT; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
21 -- Boston, MA 02110-1301, USA. --
23 -- As a special exception, if other files instantiate generics from this --
24 -- unit, or you link this unit with other files to produce an executable, --
25 -- this unit does not by itself cause the resulting executable to be --
26 -- covered by the GNU General Public License. This exception does not --
27 -- however invalidate any other reasons why the executable file might be --
28 -- covered by the GNU Public License. --
30 -- GNAT was originally developed by the GNAT team at New York University. --
31 -- Extensive contributions were provided by Ada Core Technologies Inc. --
33 ------------------------------------------------------------------------------
38 ** This template file is used while building the GNAT runtime library to
39 ** generate package System.OS_Constants (s-oscons.ads).
41 ** The generation process is:
42 ** 1. the platform-independent extraction tool xoscons is built with the
43 ** base native compiler
44 ** 2. this template is processed by the cross C compiler to produce
45 ** a list of constant values
46 ** 3. the comments in this template and the list of values are processed
47 ** by xoscons to generate s-oscons.ads.
49 ** Any comment occurring in this file whose start and end markers are on
50 ** a line by themselves (see above) is copied verbatim to s-oscons.ads.
51 ** All other comments are ignored. Note that the build process first passes
52 ** this file through the C preprocessor, so comments that occur in a section
53 ** that is conditioned by a #if directive will be copied to the output only
56 ** Two methods are supported to generate the list of constant values,
59 ** The default one assumes that the template can be compiled by the newly-
60 ** build cross compiler. It uses markup produced in the (pseudo-)assembly
63 ** xgcc -DTARGET=\"$target\" -C -E s-oscons-tmplt.c > s-oscons-tmplt.i
64 ** xgcc -S s-oscons-tmplt.i
67 ** Alternatively, if s-oscons-tmplt.c must be compiled with a proprietary
68 ** compiler (e.g. the native DEC CC on OpenVMS), the NATIVE macro should
69 ** be defined, and the resulting program executed:
71 ** $ CC/DEFINE=("TARGET=""OpenVMS""",NATIVE)
72 ** /PREPROCESS_ONLY /COMMENTS=AS_IS s-oscons-tmplt
73 ** $ CC/DEFINE=("TARGET=""OpenVMS""",NATIVE) s-oscons-tmplt
74 ** $ LINK s-oscons-tmplt
75 ** $ DEFINE/USER SYS$OUTPUT s-oscons-tmplt.s
76 ** $ RUN s-oscons-tmplt
82 # error Please define TARGET
90 #if ! (defined (__vxworks) || defined (__VMS) || defined (__MINGW32__) || \
91 defined (__nucleus__))
102 # include <termios.h>
107 #define CND(name,comment) \
108 printf ("\n->CND:$%d:" #name ":$%d:" comment, __LINE__, ((int) name));
110 #define CNS(name,comment) \
111 printf ("\n->CNS:$%d:" #name ":" name ":" comment, __LINE__);
114 printf ("\n->TXT:$%d:" text, __LINE__);
118 #define CND(name, comment) \
119 asm volatile("\n->CND:%0:" #name ":%1:" comment \
120 : : "i" (__LINE__), "i" ((int) name));
121 /* Decimal constant in the range of type "int" */
123 #define CNS(name, comment) \
124 asm volatile("\n->CNS:%0:" #name ":" name ":" comment \
126 /* General expression constant */
129 asm volatile("\n->TXT:%0:" text \
136 unsigned int _CRT_fmode
= _O_BINARY
;
143 -- This package provides target dependent definitions of constant for use
144 -- by the GNAT runtime library. This package should not be directly with'd
145 -- by an application program.
147 -- This file is generated automatically, do not modify it by hand! Instead,
148 -- make changes to s-oscons-tmplt.c and rebuild the GNAT runtime library.
152 ** Do not change the format of the line below without also updating the
155 TXT("-- This is the version for " TARGET
)
160 ** The type definitions for struct hostent components uses Interfaces.C
163 TXT("with Interfaces.C;")
167 package System.OS_Constants is
173 ** General constants (all platforms)
185 # define IOV_MAX INT_MAX
187 CND(IOV_MAX
, "Maximum writev iovcnt")
191 ---------------------
192 -- File open modes --
193 ---------------------
200 CND(O_RDWR
, "Read/write")
205 CND(O_NOCTTY
, "Don't change ctrl tty")
210 CND(O_NDELAY
, "Nonblocking")
214 ----------------------
215 -- Fcntl operations --
216 ----------------------
223 CND(F_GETFL
, "Get flags")
228 CND(F_SETFL
, "Set flags")
241 CND(FNDELAY
, "Nonblocking")
245 ----------------------
246 -- Ioctl operations --
247 ----------------------
254 CND(FIONBIO
, "Set/clear non-blocking io")
259 CND(FIONREAD
, "How many bytes to read")
267 -- The following constants are defined from <errno.h>
273 CND(EAGAIN
, "Try again")
278 CND(ENOENT
, "File not found")
283 CND(ENOMEM
, "Out of memory")
288 -- The following constants are defined from <winsock2.h> (WSA*)
293 ** For sockets-related errno values on Windows, gsocket.h redefines
302 CND(EACCES
, "Permission denied")
305 # define EADDRINUSE -1
307 CND(EADDRINUSE
, "Address already in use")
309 #ifndef EADDRNOTAVAIL
310 # define EADDRNOTAVAIL -1
312 CND(EADDRNOTAVAIL
, "Cannot assign address")
315 # define EAFNOSUPPORT -1
317 CND(EAFNOSUPPORT
, "Addr family not supported")
322 CND(EALREADY
, "Operation in progress")
327 CND(EBADF
, "Bad file descriptor")
330 # define ECONNABORTED -1
332 CND(ECONNABORTED
, "Connection aborted")
335 # define ECONNREFUSED -1
337 CND(ECONNREFUSED
, "Connection refused")
340 # define ECONNRESET -1
342 CND(ECONNRESET
, "Connection reset by peer")
345 # define EDESTADDRREQ -1
347 CND(EDESTADDRREQ
, "Destination addr required")
352 CND(EFAULT
, "Bad address")
355 # define EHOSTDOWN -1
357 CND(EHOSTDOWN
, "Host is down")
360 # define EHOSTUNREACH -1
362 CND(EHOSTUNREACH
, "No route to host")
365 # define EINPROGRESS -1
367 CND(EINPROGRESS
, "Operation now in progress")
372 CND(EINTR
, "Interrupted system call")
377 CND(EINVAL
, "Invalid argument")
382 CND(EIO
, "Input output error")
387 CND(EISCONN
, "Socket already connected")
392 CND(ELOOP
, "Too many symbolic links")
397 CND(EMFILE
, "Too many open files")
402 CND(EMSGSIZE
, "Message too long")
405 # define ENAMETOOLONG -1
407 CND(ENAMETOOLONG
, "Name too long")
412 CND(ENETDOWN
, "Network is down")
415 # define ENETRESET -1
417 CND(ENETRESET
, "Disconn. on network reset")
420 # define ENETUNREACH -1
422 CND(ENETUNREACH
, "Network is unreachable")
427 CND(ENOBUFS
, "No buffer space available")
430 # define ENOPROTOOPT -1
432 CND(ENOPROTOOPT
, "Protocol not available")
437 CND(ENOTCONN
, "Socket not connected")
442 CND(ENOTSOCK
, "Operation on non socket")
445 # define EOPNOTSUPP -1
447 CND(EOPNOTSUPP
, "Operation not supported")
450 # define EPFNOSUPPORT -1
452 CND(EPFNOSUPPORT
, "Unknown protocol family")
454 #ifndef EPROTONOSUPPORT
455 # define EPROTONOSUPPORT -1
457 CND(EPROTONOSUPPORT
, "Unknown protocol")
460 # define EPROTOTYPE -1
462 CND(EPROTOTYPE
, "Unknown protocol type")
465 # define ESHUTDOWN -1
467 CND(ESHUTDOWN
, "Cannot send once shutdown")
469 #ifndef ESOCKTNOSUPPORT
470 # define ESOCKTNOSUPPORT -1
472 CND(ESOCKTNOSUPPORT
, "Socket type not supported")
475 # define ETIMEDOUT -1
477 CND(ETIMEDOUT
, "Connection timed out")
480 # define ETOOMANYREFS -1
482 CND(ETOOMANYREFS
, "Too many references")
485 # define EWOULDBLOCK -1
487 CND(EWOULDBLOCK
, "Operation would block")
490 ** Terminal I/O constants
497 ----------------------
498 -- Terminal control --
499 ----------------------
506 CND(TCSANOW
, "Immediate")
511 CND(TCIFLUSH
, "Flush input")
521 CND(CRTSCTS
, "Hardware flow control")
531 CND(CS5
, "5 data bits")
536 CND(CS6
, "6 data bits")
541 CND(CS7
, "7 data bits")
546 CND(CS8
, "8 data bits")
551 CND(CSTOPB
, "2 stop bits")
556 CND(PARENB
, "Parity enable")
561 CND(PARODD
, "Parity odd")
611 CND(B1200
, "1200 bps")
616 CND(B1800
, "1800 bps")
621 CND(B2400
, "2400 bps")
626 CND(B4800
, "4800 bps")
631 CND(B9600
, "9600 bps")
636 CND(B19200
, "19200 bps")
641 CND(B38400
, "38400 bps")
646 CND(B57600
, "57600 bps")
651 CND(B115200
, "115200 bps")
656 CND(B230400
, "230400 bps")
661 CND(B460800
, "460800 bps")
666 CND(B500000
, "500000 bps")
671 CND(B576000
, "576000 bps")
676 CND(B921600
, "921600 bps")
681 CND(B1000000
, "1000000 bps")
686 CND(B1152000
, "1152000 bps")
691 CND(B1500000
, "1500000 bps")
696 CND(B2000000
, "2000000 bps")
701 CND(B2500000
, "2500000 bps")
706 CND(B3000000
, "3000000 bps")
711 CND(B3500000
, "3500000 bps")
716 CND(B4000000
, "4000000 bps")
720 ---------------------------------
721 -- Terminal control characters --
722 ---------------------------------
729 CND(VINTR
, "Interrupt")
754 CND(VTIME
, "Read timeout")
759 CND(VMIN
, "Read min chars")
769 CND(VSTART
, "Flow control start")
774 CND(VSTOP
, "Flow control stop")
779 CND(VSUSP
, "Suspend")
789 CND(VREPRINT
, "Reprint unread")
794 CND(VDISCARD
, "Discard pending")
799 CND(VWERASE
, "Word erase")
804 CND(VLNEXT
, "Literal next")
809 CND(VEOL2
, "Alternative EOL")
811 #endif /* HAVE_TERMIOS */
830 CND(AF_INET
, "IPv4 address family")
833 ** RTEMS lies and defines AF_INET6 even though there is no IPV6 support.
834 ** Its TCP/IP stack is in transition. It has newer .h files but no IPV6 yet.
836 #if defined(__rtems__)
841 ** Tru64 UNIX V4.0F defines AF_INET6 without IPv6 support, specificially
842 ** without struct sockaddr_in6. We use _SS_MAXSIZE (used for the definition
843 ** of struct sockaddr_storage on Tru64 UNIX V5.1) to detect this.
845 #if defined(__osf__) && !defined(_SS_MAXSIZE)
852 # define HAVE_AF_INET6 1
854 CND(AF_INET6
, "IPv6 address family")
865 # define SOCK_STREAM -1
867 CND(SOCK_STREAM
, "Stream socket")
870 # define SOCK_DGRAM -1
872 CND(SOCK_DGRAM
, "Datagram socket")
882 #ifndef HOST_NOT_FOUND
883 # define HOST_NOT_FOUND -1
885 CND(HOST_NOT_FOUND
, "Unknown host")
888 # define TRY_AGAIN -1
890 CND(TRY_AGAIN
, "Host name lookup failure")
895 CND(NO_DATA
, "No data record for name")
898 # define NO_RECOVERY -1
900 CND(NO_RECOVERY
, "Non recoverable errors")
913 CND(SHUT_RD
, "No more recv")
918 CND(SHUT_WR
, "No more send")
921 # define SHUT_RDWR -1
923 CND(SHUT_RDWR
, "No more recv/send")
927 ---------------------
928 -- Protocol levels --
929 ---------------------
934 # define SOL_SOCKET -1
936 CND(SOL_SOCKET
, "Options for socket level")
939 # define IPPROTO_IP -1
941 CND(IPPROTO_IP
, "Dummy protocol for IP")
944 # define IPPROTO_UDP -1
946 CND(IPPROTO_UDP
, "UDP")
949 # define IPPROTO_TCP -1
951 CND(IPPROTO_TCP
, "TCP")
964 CND(MSG_OOB
, "Process out-of-band data")
969 CND(MSG_PEEK
, "Peek at incoming data")
974 CND(MSG_EOR
, "Send end of record")
977 # define MSG_WAITALL -1
979 CND(MSG_WAITALL
, "Wait for full reception")
982 # define MSG_NOSIGNAL -1
984 CND(MSG_NOSIGNAL
, "No SIGPIPE on send")
987 # define MSG_Forced_Flags "MSG_NOSIGNAL"
989 # define MSG_Forced_Flags "0"
991 CNS(MSG_Forced_Flags
, "")
993 -- Flags set on all send(2) calls
1000 --------------------
1005 # define TCP_NODELAY -1
1007 CND(TCP_NODELAY
, "Do not coalesce packets")
1009 #ifndef SO_REUSEADDR
1010 # define SO_REUSEADDR -1
1012 CND(SO_REUSEADDR
, "Bind reuse local address")
1014 #ifndef SO_REUSEPORT
1015 # define SO_REUSEPORT -1
1017 CND(SO_REUSEPORT
, "Bind reuse port number")
1019 #ifndef SO_KEEPALIVE
1020 # define SO_KEEPALIVE -1
1022 CND(SO_KEEPALIVE
, "Enable keep-alive msgs")
1025 # define SO_LINGER -1
1027 CND(SO_LINGER
, "Defer close to flush data")
1029 #ifndef SO_BROADCAST
1030 # define SO_BROADCAST -1
1032 CND(SO_BROADCAST
, "Can send broadcast msgs")
1035 # define SO_SNDBUF -1
1037 CND(SO_SNDBUF
, "Set/get send buffer size")
1040 # define SO_RCVBUF -1
1042 CND(SO_RCVBUF
, "Set/get recv buffer size")
1045 # define SO_SNDTIMEO -1
1047 CND(SO_SNDTIMEO
, "Emission timeout")
1050 # define SO_RCVTIMEO -1
1052 CND(SO_RCVTIMEO
, "Reception timeout")
1055 # define SO_ERROR -1
1057 CND(SO_ERROR
, "Get/clear error status")
1059 #ifndef IP_MULTICAST_IF
1060 # define IP_MULTICAST_IF -1
1062 CND(IP_MULTICAST_IF
, "Set/get mcast interface")
1064 #ifndef IP_MULTICAST_TTL
1065 # define IP_MULTICAST_TTL -1
1067 CND(IP_MULTICAST_TTL
, "Set/get multicast TTL")
1069 #ifndef IP_MULTICAST_LOOP
1070 # define IP_MULTICAST_LOOP -1
1072 CND(IP_MULTICAST_LOOP
, "Set/get mcast loopback")
1074 #ifndef IP_ADD_MEMBERSHIP
1075 # define IP_ADD_MEMBERSHIP -1
1077 CND(IP_ADD_MEMBERSHIP
, "Join a multicast group")
1079 #ifndef IP_DROP_MEMBERSHIP
1080 # define IP_DROP_MEMBERSHIP -1
1082 CND(IP_DROP_MEMBERSHIP
, "Leave a multicast group")
1085 # define IP_PKTINFO -1
1087 CND(IP_PKTINFO
, "Get datagram info")
1091 ----------------------
1092 -- Type definitions --
1093 ----------------------
1100 -- Sizes (in bytes) of the components of struct timeval
1102 #define SIZEOF_tv_sec (sizeof tv.tv_sec)
1103 CND(SIZEOF_tv_sec
, "tv_sec")
1104 #define SIZEOF_tv_usec (sizeof tv.tv_usec)
1105 CND(SIZEOF_tv_usec
, "tv_usec")
1109 -- Sizes of protocol specific address types (for sockaddr.sa_len)
1112 #define SIZEOF_sockaddr_in (sizeof (struct sockaddr_in))
1113 CND(SIZEOF_sockaddr_in
, "struct sockaddr_in")
1114 #ifdef HAVE_AF_INET6
1115 # define SIZEOF_sockaddr_in6 (sizeof (struct sockaddr_in6))
1117 # define SIZEOF_sockaddr_in6 0
1119 CND(SIZEOF_sockaddr_in6
, "struct sockaddr_in6")
1123 -- Size of file descriptor sets
1125 #define SIZEOF_fd_set (sizeof (fd_set))
1126 CND(SIZEOF_fd_set
, "fd_set");
1129 -- Fields of struct hostent
1133 # define h_addrtype_t "short"
1134 # define h_length_t "short"
1136 # define h_addrtype_t "int"
1137 # define h_length_t "int"
1140 TXT(" subtype H_Addrtype_T is Interfaces.C." h_addrtype_t
";")
1141 TXT(" subtype H_Length_T is Interfaces.C." h_length_t
";")
1145 ----------------------------------------
1146 -- Properties of supported interfaces --
1147 ----------------------------------------
1151 CND(Need_Netdb_Buffer
, "Need buffer for Netdb ops")
1152 CND(Has_Sockaddr_Len
, "Sockaddr has sa_len field")
1155 ** Do not change the format of the line below without also updating the
1158 TXT(" Thread_Blocking_IO : constant Boolean := True;")
1160 -- Set False for contexts where socket i/o are process blocking
1163 #endif /* HAVE_SOCKETS */
1166 ** System-specific constants follow
1173 --------------------------------
1174 -- VxWorks-specific constants --
1175 --------------------------------
1177 -- These constants may be used only within the VxWorks version of
1178 -- GNAT.Sockets.Thin.
1181 CND(OK
, "VxWorks generic success")
1182 CND(ERROR
, "VxWorks generic error")
1189 ------------------------------
1190 -- MinGW-specific constants --
1191 ------------------------------
1193 -- These constants may be used only within the MinGW version of
1194 -- GNAT.Sockets.Thin.
1197 CND(WSASYSNOTREADY
, "System not ready")
1198 CND(WSAVERNOTSUPPORTED
, "Version not supported")
1199 CND(WSANOTINITIALISED
, "Winsock not initialized")
1200 CND(WSAEDISCON
, "Disconnected")
1210 end System.OS_Constants;