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 ------------------------------------------------------------------------------
35 pragma Style_Checks ("M32766");
41 ** This template file is used while building the GNAT runtime library to
42 ** generate package System.OS_Constants (s-oscons.ads).
44 ** The generation process is:
45 ** 1. the platform-independent extraction tool xoscons is built with the
46 ** base native compiler
47 ** 2. this template is processed by the cross C compiler to produce
48 ** a list of constant values
49 ** 3. the comments in this template and the list of values are processed
50 ** by xoscons to generate s-oscons.ads.
52 ** Any comment occurring in this file whose start and end markers are on
53 ** a line by themselves (see above) is copied verbatim to s-oscons.ads.
54 ** All other comments are ignored. Note that the build process first passes
55 ** this file through the C preprocessor, so comments that occur in a section
56 ** that is conditioned by a #if directive will be copied to the output only
59 ** Two methods are supported to generate the list of constant values,
62 ** The default one assumes that the template can be compiled by the newly-
63 ** build cross compiler. It uses markup produced in the (pseudo-)assembly
66 ** xgcc -DTARGET=\"$target\" -C -E s-oscons-tmplt.c > s-oscons-tmplt.i
67 ** xgcc -S s-oscons-tmplt.i
70 ** Alternatively, if s-oscons-tmplt.c must be compiled with a proprietary
71 ** compiler (e.g. the native DEC CC on OpenVMS), the NATIVE macro should
72 ** be defined, and the resulting program executed:
74 ** $ CC/DEFINE=("TARGET=""OpenVMS""",NATIVE)
75 ** /PREPROCESS_ONLY /COMMENTS=AS_IS s-oscons-tmplt
76 ** $ CC/DEFINE=("TARGET=""OpenVMS""",NATIVE) s-oscons-tmplt
77 ** $ LINK s-oscons-tmplt
78 ** $ DEFINE/USER SYS$OUTPUT s-oscons-tmplt.s
79 ** $ RUN s-oscons-tmplt
85 # error Please define TARGET
93 #if ! (defined (__vxworks) || defined (__VMS) || defined (__MINGW32__) || \
94 defined (__nucleus__))
105 # include <termios.h>
114 #define CND(name,comment) \
115 printf ("\n->CND:$%d:" #name ":$%d:" comment, __LINE__, ((int) name));
117 #define CNS(name,comment) \
118 printf ("\n->CNS:$%d:" #name ":" name ":" comment, __LINE__);
121 printf ("\n->TXT:$%d:" text, __LINE__);
125 #define CND(name, comment) \
126 asm volatile("\n->CND:%0:" #name ":%1:" comment \
127 : : "i" (__LINE__), "i" ((int) name));
128 /* Decimal constant in the range of type "int" */
130 #define CNS(name, comment) \
131 asm volatile("\n->CNS:%0:" #name ":" name ":" comment \
133 /* General expression constant */
136 asm volatile("\n->TXT:%0:" text \
143 unsigned int _CRT_fmode = _O_BINARY;
150 -- This package provides target dependent definitions of constant for use
151 -- by the GNAT runtime library. This package should not be directly with'd
152 -- by an application program.
154 -- This file is generated automatically, do not modify it by hand! Instead,
155 -- make changes to s-oscons-tmplt.c and rebuild the GNAT runtime library.
159 ** Do not change the format of the line below without also updating the
162 TXT("-- This is the version for " TARGET)
167 ** The type definitions for struct hostent components uses Interfaces.C
170 TXT("with Interfaces.C;")
174 package System.OS_Constants is
180 ** General constants (all platforms)
192 # define IOV_MAX INT_MAX
194 CND(IOV_MAX, "Maximum writev iovcnt")
198 ---------------------
199 -- File open modes --
200 ---------------------
207 CND(O_RDWR, "Read/write")
212 CND(O_NOCTTY, "Don't change ctrl tty")
217 CND(O_NDELAY, "Nonblocking")
221 ----------------------
222 -- Fcntl operations --
223 ----------------------
230 CND(F_GETFL, "Get flags")
235 CND(F_SETFL, "Set flags")
248 CND(FNDELAY, "Nonblocking")
252 ----------------------
253 -- Ioctl operations --
254 ----------------------
261 CND(FIONBIO, "Set/clear non-blocking io")
266 CND(FIONREAD, "How many bytes to read")
274 -- The following constants are defined from <errno.h>
280 CND(EAGAIN, "Try again")
285 CND(ENOENT, "File not found")
290 CND(ENOMEM, "Out of memory")
295 -- The following constants are defined from <winsock2.h> (WSA*)
300 ** For sockets-related errno values on Windows, gsocket.h redefines
309 CND(EACCES, "Permission denied")
312 # define EADDRINUSE -1
314 CND(EADDRINUSE, "Address already in use")
316 #ifndef EADDRNOTAVAIL
317 # define EADDRNOTAVAIL -1
319 CND(EADDRNOTAVAIL, "Cannot assign address")
322 # define EAFNOSUPPORT -1
324 CND(EAFNOSUPPORT, "Addr family not supported")
329 CND(EALREADY, "Operation in progress")
334 CND(EBADF, "Bad file descriptor")
337 # define ECONNABORTED -1
339 CND(ECONNABORTED, "Connection aborted")
342 # define ECONNREFUSED -1
344 CND(ECONNREFUSED, "Connection refused")
347 # define ECONNRESET -1
349 CND(ECONNRESET, "Connection reset by peer")
352 # define EDESTADDRREQ -1
354 CND(EDESTADDRREQ, "Destination addr required")
359 CND(EFAULT, "Bad address")
362 # define EHOSTDOWN -1
364 CND(EHOSTDOWN, "Host is down")
367 # define EHOSTUNREACH -1
369 CND(EHOSTUNREACH, "No route to host")
372 # define EINPROGRESS -1
374 CND(EINPROGRESS, "Operation now in progress")
379 CND(EINTR, "Interrupted system call")
384 CND(EINVAL, "Invalid argument")
389 CND(EIO, "Input output error")
394 CND(EISCONN, "Socket already connected")
399 CND(ELOOP, "Too many symbolic links")
404 CND(EMFILE, "Too many open files")
409 CND(EMSGSIZE, "Message too long")
412 # define ENAMETOOLONG -1
414 CND(ENAMETOOLONG, "Name too long")
419 CND(ENETDOWN, "Network is down")
422 # define ENETRESET -1
424 CND(ENETRESET, "Disconn. on network reset")
427 # define ENETUNREACH -1
429 CND(ENETUNREACH, "Network is unreachable")
434 CND(ENOBUFS, "No buffer space available")
437 # define ENOPROTOOPT -1
439 CND(ENOPROTOOPT, "Protocol not available")
444 CND(ENOTCONN, "Socket not connected")
449 CND(ENOTSOCK, "Operation on non socket")
452 # define EOPNOTSUPP -1
454 CND(EOPNOTSUPP, "Operation not supported")
457 # define EPFNOSUPPORT -1
459 CND(EPFNOSUPPORT, "Unknown protocol family")
461 #ifndef EPROTONOSUPPORT
462 # define EPROTONOSUPPORT -1
464 CND(EPROTONOSUPPORT, "Unknown protocol")
467 # define EPROTOTYPE -1
469 CND(EPROTOTYPE, "Unknown protocol type")
472 # define ESHUTDOWN -1
474 CND(ESHUTDOWN, "Cannot send once shutdown")
476 #ifndef ESOCKTNOSUPPORT
477 # define ESOCKTNOSUPPORT -1
479 CND(ESOCKTNOSUPPORT, "Socket type not supported")
482 # define ETIMEDOUT -1
484 CND(ETIMEDOUT, "Connection timed out")
487 # define ETOOMANYREFS -1
489 CND(ETOOMANYREFS, "Too many references")
492 # define EWOULDBLOCK -1
494 CND(EWOULDBLOCK, "Operation would block")
497 ** Terminal I/O constants
504 ----------------------
505 -- Terminal control --
506 ----------------------
513 CND(TCSANOW, "Immediate")
518 CND(TCIFLUSH, "Flush input")
528 CND(CRTSCTS, "Hardware flow control")
538 CND(CS5, "5 data bits")
543 CND(CS6, "6 data bits")
548 CND(CS7, "7 data bits")
553 CND(CS8, "8 data bits")
558 CND(CSTOPB, "2 stop bits")
563 CND(PARENB, "Parity enable")
568 CND(PARODD, "Parity odd")
618 CND(B1200, "1200 bps")
623 CND(B1800, "1800 bps")
628 CND(B2400, "2400 bps")
633 CND(B4800, "4800 bps")
638 CND(B9600, "9600 bps")
643 CND(B19200, "19200 bps")
648 CND(B38400, "38400 bps")
653 CND(B57600, "57600 bps")
658 CND(B115200, "115200 bps")
663 CND(B230400, "230400 bps")
668 CND(B460800, "460800 bps")
673 CND(B500000, "500000 bps")
678 CND(B576000, "576000 bps")
683 CND(B921600, "921600 bps")
688 CND(B1000000, "1000000 bps")
693 CND(B1152000, "1152000 bps")
698 CND(B1500000, "1500000 bps")
703 CND(B2000000, "2000000 bps")
708 CND(B2500000, "2500000 bps")
713 CND(B3000000, "3000000 bps")
718 CND(B3500000, "3500000 bps")
723 CND(B4000000, "4000000 bps")
727 ---------------------------------
728 -- Terminal control characters --
729 ---------------------------------
736 CND(VINTR, "Interrupt")
761 CND(VTIME, "Read timeout")
766 CND(VMIN, "Read min chars")
776 CND(VSTART, "Flow control start")
781 CND(VSTOP, "Flow control stop")
786 CND(VSUSP, "Suspend")
796 CND(VREPRINT, "Reprint unread")
801 CND(VDISCARD, "Discard pending")
806 CND(VWERASE, "Word erase")
811 CND(VLNEXT, "Literal next")
816 CND(VEOL2, "Alternative EOL")
818 #endif /* HAVE_TERMIOS */
837 CND(AF_INET, "IPv4 address family")
840 ** RTEMS lies and defines AF_INET6 even though there is no IPV6 support.
841 ** Its TCP/IP stack is in transition. It has newer .h files but no IPV6 yet.
843 #if defined(__rtems__)
848 ** Tru64 UNIX V4.0F defines AF_INET6 without IPv6 support, specificially
849 ** without struct sockaddr_in6. We use _SS_MAXSIZE (used for the definition
850 ** of struct sockaddr_storage on Tru64 UNIX V5.1) to detect this.
852 #if defined(__osf__) && !defined(_SS_MAXSIZE)
859 # define HAVE_AF_INET6 1
861 CND(AF_INET6, "IPv6 address family")
872 # define SOCK_STREAM -1
874 CND(SOCK_STREAM, "Stream socket")
877 # define SOCK_DGRAM -1
879 CND(SOCK_DGRAM, "Datagram socket")
889 #ifndef HOST_NOT_FOUND
890 # define HOST_NOT_FOUND -1
892 CND(HOST_NOT_FOUND, "Unknown host")
895 # define TRY_AGAIN -1
897 CND(TRY_AGAIN, "Host name lookup failure")
902 CND(NO_DATA, "No data record for name")
905 # define NO_RECOVERY -1
907 CND(NO_RECOVERY, "Non recoverable errors")
920 CND(SHUT_RD, "No more recv")
925 CND(SHUT_WR, "No more send")
928 # define SHUT_RDWR -1
930 CND(SHUT_RDWR, "No more recv/send")
934 ---------------------
935 -- Protocol levels --
936 ---------------------
941 # define SOL_SOCKET -1
943 CND(SOL_SOCKET, "Options for socket level")
946 # define IPPROTO_IP -1
948 CND(IPPROTO_IP, "Dummy protocol for IP")
951 # define IPPROTO_UDP -1
953 CND(IPPROTO_UDP, "UDP")
956 # define IPPROTO_TCP -1
958 CND(IPPROTO_TCP, "TCP")
971 CND(MSG_OOB, "Process out-of-band data")
976 CND(MSG_PEEK, "Peek at incoming data")
981 CND(MSG_EOR, "Send end of record")
984 # define MSG_WAITALL -1
986 CND(MSG_WAITALL, "Wait for full reception")
989 # define MSG_NOSIGNAL -1
991 CND(MSG_NOSIGNAL, "No SIGPIPE on send")
994 # define MSG_Forced_Flags "MSG_NOSIGNAL"
996 # define MSG_Forced_Flags "0"
998 CNS(MSG_Forced_Flags, "")
1000 -- Flags set on all send(2) calls
1005 --------------------
1006 -- Socket options --
1007 --------------------
1012 # define TCP_NODELAY -1
1014 CND(TCP_NODELAY, "Do not coalesce packets")
1016 #ifndef SO_REUSEADDR
1017 # define SO_REUSEADDR -1
1019 CND(SO_REUSEADDR, "Bind reuse local address")
1021 #ifndef SO_REUSEPORT
1022 # define SO_REUSEPORT -1
1024 CND(SO_REUSEPORT, "Bind reuse port number")
1026 #ifndef SO_KEEPALIVE
1027 # define SO_KEEPALIVE -1
1029 CND(SO_KEEPALIVE, "Enable keep-alive msgs")
1032 # define SO_LINGER -1
1034 CND(SO_LINGER, "Defer close to flush data")
1036 #ifndef SO_BROADCAST
1037 # define SO_BROADCAST -1
1039 CND(SO_BROADCAST, "Can send broadcast msgs")
1042 # define SO_SNDBUF -1
1044 CND(SO_SNDBUF, "Set/get send buffer size")
1047 # define SO_RCVBUF -1
1049 CND(SO_RCVBUF, "Set/get recv buffer size")
1052 # define SO_SNDTIMEO -1
1054 CND(SO_SNDTIMEO, "Emission timeout")
1057 # define SO_RCVTIMEO -1
1059 CND(SO_RCVTIMEO, "Reception timeout")
1062 # define SO_ERROR -1
1064 CND(SO_ERROR, "Get/clear error status")
1066 #ifndef IP_MULTICAST_IF
1067 # define IP_MULTICAST_IF -1
1069 CND(IP_MULTICAST_IF, "Set/get mcast interface")
1071 #ifndef IP_MULTICAST_TTL
1072 # define IP_MULTICAST_TTL -1
1074 CND(IP_MULTICAST_TTL, "Set/get multicast TTL")
1076 #ifndef IP_MULTICAST_LOOP
1077 # define IP_MULTICAST_LOOP -1
1079 CND(IP_MULTICAST_LOOP, "Set/get mcast loopback")
1081 #ifndef IP_ADD_MEMBERSHIP
1082 # define IP_ADD_MEMBERSHIP -1
1084 CND(IP_ADD_MEMBERSHIP, "Join a multicast group")
1086 #ifndef IP_DROP_MEMBERSHIP
1087 # define IP_DROP_MEMBERSHIP -1
1089 CND(IP_DROP_MEMBERSHIP, "Leave a multicast group")
1092 # define IP_PKTINFO -1
1094 CND(IP_PKTINFO, "Get datagram info")
1098 ----------------------
1099 -- Type definitions --
1100 ----------------------
1107 -- Sizes (in bytes) of the components of struct timeval
1109 #define SIZEOF_tv_sec (sizeof tv.tv_sec)
1110 CND(SIZEOF_tv_sec, "tv_sec")
1111 #define SIZEOF_tv_usec (sizeof tv.tv_usec)
1112 CND(SIZEOF_tv_usec, "tv_usec")
1116 -- Sizes of protocol specific address types (for sockaddr.sa_len)
1119 #define SIZEOF_sockaddr_in (sizeof (struct sockaddr_in))
1120 CND(SIZEOF_sockaddr_in, "struct sockaddr_in")
1121 #ifdef HAVE_AF_INET6
1122 # define SIZEOF_sockaddr_in6 (sizeof (struct sockaddr_in6))
1124 # define SIZEOF_sockaddr_in6 0
1126 CND(SIZEOF_sockaddr_in6, "struct sockaddr_in6")
1130 -- Size of file descriptor sets
1132 #define SIZEOF_fd_set (sizeof (fd_set))
1133 CND(SIZEOF_fd_set, "fd_set");
1136 -- Fields of struct hostent
1140 # define h_addrtype_t "short"
1141 # define h_length_t "short"
1143 # define h_addrtype_t "int"
1144 # define h_length_t "int"
1147 TXT(" subtype H_Addrtype_T is Interfaces.C." h_addrtype_t ";")
1148 TXT(" subtype H_Length_T is Interfaces.C." h_length_t ";")
1152 ----------------------------------------
1153 -- Properties of supported interfaces --
1154 ----------------------------------------
1158 CND(Need_Netdb_Buffer, "Need buffer for Netdb ops")
1159 CND(Has_Sockaddr_Len, "Sockaddr has sa_len field")
1162 ** Do not change the format of the line below without also updating the
1165 TXT(" Thread_Blocking_IO : constant Boolean := True;")
1167 -- Set False for contexts where socket i/o are process blocking
1170 #endif /* HAVE_SOCKETS */
1173 ** System-specific constants follow
1180 --------------------------------
1181 -- VxWorks-specific constants --
1182 --------------------------------
1184 -- These constants may be used only within the VxWorks version of
1185 -- GNAT.Sockets.Thin.
1188 CND(OK, "VxWorks generic success")
1189 CND(ERROR, "VxWorks generic error")
1196 ------------------------------
1197 -- MinGW-specific constants --
1198 ------------------------------
1200 -- These constants may be used only within the MinGW version of
1201 -- GNAT.Sockets.Thin.
1204 CND(WSASYSNOTREADY, "System not ready")
1205 CND(WSAVERNOTSUPPORTED, "Version not supported")
1206 CND(WSANOTINITIALISED, "Winsock not initialized")
1207 CND(WSAEDISCON, "Disconnected")
1218 -------------------------------
1219 -- Darwin-specific constants --
1220 -------------------------------
1222 -- These constants may be used only within the Darwin version of the GNAT
1226 #define PTHREAD_SIZE __PTHREAD_SIZE__
1227 CND(PTHREAD_SIZE, "Pad in pthread_t")
1229 #define PTHREAD_ATTR_SIZE __PTHREAD_ATTR_SIZE__
1230 CND(PTHREAD_ATTR_SIZE, "Pad in pthread_attr_t")
1232 #define PTHREAD_MUTEXATTR_SIZE __PTHREAD_MUTEXATTR_SIZE__
1233 CND(PTHREAD_MUTEXATTR_SIZE, "Pad in pthread_mutexattr_t")
1235 #define PTHREAD_MUTEX_SIZE __PTHREAD_MUTEX_SIZE__
1236 CND(PTHREAD_MUTEX_SIZE, "Pad in pthread_mutex_t")
1238 #define PTHREAD_CONDATTR_SIZE __PTHREAD_CONDATTR_SIZE__
1239 CND(PTHREAD_CONDATTR_SIZE, "Pad in pthread_condattr_t")
1241 #define PTHREAD_COND_SIZE __PTHREAD_COND_SIZE__
1242 CND(PTHREAD_COND_SIZE, "Pad in pthread_cond_t")
1244 #define PTHREAD_RWLOCKATTR_SIZE __PTHREAD_RWLOCKATTR_SIZE__
1245 CND(PTHREAD_RWLOCKATTR_SIZE, "Pad in pthread_rwlockattr_t")
1247 #define PTHREAD_RWLOCK_SIZE __PTHREAD_RWLOCK_SIZE__
1248 CND(PTHREAD_RWLOCK_SIZE, "Pad in pthread_rwlock_t")
1250 #define PTHREAD_ONCE_SIZE __PTHREAD_ONCE_SIZE__
1251 CND(PTHREAD_ONCE_SIZE, "Pad in pthread_once_t")
1257 end System.OS_Constants;