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-2008, 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__)
843 # define HAVE_AF_INET6 1
845 CND(AF_INET6, "IPv6 address family")
856 # define SOCK_STREAM -1
858 CND(SOCK_STREAM, "Stream socket")
861 # define SOCK_DGRAM -1
863 CND(SOCK_DGRAM, "Datagram socket")
873 #ifndef HOST_NOT_FOUND
874 # define HOST_NOT_FOUND -1
876 CND(HOST_NOT_FOUND, "Unknown host")
879 # define TRY_AGAIN -1
881 CND(TRY_AGAIN, "Host name lookup failure")
886 CND(NO_DATA, "No data record for name")
889 # define NO_RECOVERY -1
891 CND(NO_RECOVERY, "Non recoverable errors")
904 CND(SHUT_RD, "No more recv")
909 CND(SHUT_WR, "No more send")
912 # define SHUT_RDWR -1
914 CND(SHUT_RDWR, "No more recv/send")
918 ---------------------
919 -- Protocol levels --
920 ---------------------
925 # define SOL_SOCKET -1
927 CND(SOL_SOCKET, "Options for socket level")
930 # define IPPROTO_IP -1
932 CND(IPPROTO_IP, "Dummy protocol for IP")
935 # define IPPROTO_UDP -1
937 CND(IPPROTO_UDP, "UDP")
940 # define IPPROTO_TCP -1
942 CND(IPPROTO_TCP, "TCP")
955 CND(MSG_OOB, "Process out-of-band data")
960 CND(MSG_PEEK, "Peek at incoming data")
965 CND(MSG_EOR, "Send end of record")
968 # define MSG_WAITALL -1
970 CND(MSG_WAITALL, "Wait for full reception")
973 # define MSG_NOSIGNAL -1
975 CND(MSG_NOSIGNAL, "No SIGPIPE on send")
978 # define MSG_Forced_Flags "MSG_NOSIGNAL"
980 # define MSG_Forced_Flags "0"
982 CNS(MSG_Forced_Flags, "")
984 -- Flags set on all send(2) calls
996 # define TCP_NODELAY -1
998 CND(TCP_NODELAY, "Do not coalesce packets")
1000 #ifndef SO_REUSEADDR
1001 # define SO_REUSEADDR -1
1003 CND(SO_REUSEADDR, "Bind reuse local address")
1005 #ifndef SO_REUSEPORT
1006 # define SO_REUSEPORT -1
1008 CND(SO_REUSEPORT, "Bind reuse port number")
1010 #ifndef SO_KEEPALIVE
1011 # define SO_KEEPALIVE -1
1013 CND(SO_KEEPALIVE, "Enable keep-alive msgs")
1016 # define SO_LINGER -1
1018 CND(SO_LINGER, "Defer close to flush data")
1020 #ifndef SO_BROADCAST
1021 # define SO_BROADCAST -1
1023 CND(SO_BROADCAST, "Can send broadcast msgs")
1026 # define SO_SNDBUF -1
1028 CND(SO_SNDBUF, "Set/get send buffer size")
1031 # define SO_RCVBUF -1
1033 CND(SO_RCVBUF, "Set/get recv buffer size")
1036 # define SO_SNDTIMEO -1
1038 CND(SO_SNDTIMEO, "Emission timeout")
1041 # define SO_RCVTIMEO -1
1043 CND(SO_RCVTIMEO, "Reception timeout")
1046 # define SO_ERROR -1
1048 CND(SO_ERROR, "Get/clear error status")
1050 #ifndef IP_MULTICAST_IF
1051 # define IP_MULTICAST_IF -1
1053 CND(IP_MULTICAST_IF, "Set/get mcast interface")
1055 #ifndef IP_MULTICAST_TTL
1056 # define IP_MULTICAST_TTL -1
1058 CND(IP_MULTICAST_TTL, "Set/get multicast TTL")
1060 #ifndef IP_MULTICAST_LOOP
1061 # define IP_MULTICAST_LOOP -1
1063 CND(IP_MULTICAST_LOOP, "Set/get mcast loopback")
1065 #ifndef IP_ADD_MEMBERSHIP
1066 # define IP_ADD_MEMBERSHIP -1
1068 CND(IP_ADD_MEMBERSHIP, "Join a multicast group")
1070 #ifndef IP_DROP_MEMBERSHIP
1071 # define IP_DROP_MEMBERSHIP -1
1073 CND(IP_DROP_MEMBERSHIP, "Leave a multicast group")
1076 # define IP_PKTINFO -1
1078 CND(IP_PKTINFO, "Get datagram info")
1082 ----------------------
1083 -- Type definitions --
1084 ----------------------
1091 -- Sizes (in bytes) of the components of struct timeval
1093 #define SIZEOF_tv_sec (sizeof tv.tv_sec)
1094 CND(SIZEOF_tv_sec, "tv_sec")
1095 #define SIZEOF_tv_usec (sizeof tv.tv_usec)
1096 CND(SIZEOF_tv_usec, "tv_usec")
1100 -- Sizes of protocol specific address types (for sockaddr.sa_len)
1103 #define SIZEOF_sockaddr_in (sizeof (struct sockaddr_in))
1104 CND(SIZEOF_sockaddr_in, "struct sockaddr_in")
1105 #ifdef HAVE_AF_INET6
1106 # define SIZEOF_sockaddr_in6 (sizeof (struct sockaddr_in6))
1108 # define SIZEOF_sockaddr_in6 0
1110 CND(SIZEOF_sockaddr_in6, "struct sockaddr_in6")
1114 -- Size of file descriptor sets
1116 #define SIZEOF_fd_set (sizeof (fd_set))
1117 CND(SIZEOF_fd_set, "fd_set");
1120 -- Fields of struct hostent
1124 # define h_addrtype_t "short"
1125 # define h_length_t "short"
1127 # define h_addrtype_t "int"
1128 # define h_length_t "int"
1131 TXT(" subtype H_Addrtype_T is Interfaces.C." h_addrtype_t ";")
1132 TXT(" subtype H_Length_T is Interfaces.C." h_length_t ";")
1136 ----------------------------------------
1137 -- Properties of supported interfaces --
1138 ----------------------------------------
1142 CND(Need_Netdb_Buffer, "Need buffer for Netdb ops")
1143 CND(Has_Sockaddr_Len, "Sockaddr has sa_len field")
1146 ** Do not change the format of the line below without also updating the
1149 TXT(" Thread_Blocking_IO : constant Boolean := True;")
1151 -- Set False for contexts where socket i/o are process blocking
1154 #endif /* HAVE_SOCKETS */
1157 ** System-specific constants follow
1164 --------------------------------
1165 -- VxWorks-specific constants --
1166 --------------------------------
1168 -- These constants may be used only within the VxWorks version of
1169 -- GNAT.Sockets.Thin.
1172 CND(OK, "VxWorks generic success")
1173 CND(ERROR, "VxWorks generic error")
1180 ------------------------------
1181 -- MinGW-specific constants --
1182 ------------------------------
1184 -- These constants may be used only within the MinGW version of
1185 -- GNAT.Sockets.Thin.
1188 CND(WSASYSNOTREADY, "System not ready")
1189 CND(WSAVERNOTSUPPORTED, "Version not supported")
1190 CND(WSANOTINITIALISED, "Winsock not initialized")
1191 CND(WSAEDISCON, "Disconnected")
1201 end System.OS_Constants;