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-2018, 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 /* Feature macro definitions */
84 ** Note: we deliberately do not define _POSIX_SOURCE / _POSIX_C_SOURCE
85 ** unconditionally, as on many platforms these macros actually disable
86 ** a number of non-POSIX but useful/required features.
89 #if defined (__linux__) || defined (__ANDROID__)
91 /* Define _XOPEN_SOURCE to get IOV_MAX */
92 # if !defined (_XOPEN_SOURCE)
93 # define _XOPEN_SOURCE 500
96 /* Define _BSD_SOURCE to get CRTSCTS */
99 #endif /* defined (__linux__) */
101 /* Include gsocket.h before any system header so it can redefine FD_SETSIZE */
111 #if ! (defined (__vxworks) || defined (__MINGW32__))
112 # define HAVE_TERMIOS
115 #if defined (__vxworks)
118 ** For VxWorks, always include vxWorks.h (gsocket.h provides it only for
119 ** the case of runtime libraries that support sockets). Note: this must
120 ** be done before including adaint.h.
123 # include <vxWorks.h>
130 # if defined (TARGET)
131 # error TARGET may not be defined when generating the dummy version
133 # define TARGET "batch runtime compilation (dummy values)"
136 # if !(defined (HAVE_SOCKETS) && defined (HAVE_TERMIOS))
137 # error Features missing on platform
145 # error Please define TARGET
153 # include <termios.h>
160 #if defined (__linux__) || defined (__ANDROID__) || defined (__QNX__) \
161 || defined (__rtems__)
162 # include <pthread.h>
166 #if defined(__MINGW32__) || defined(__CYGWIN__)
168 # include <winbase.h>
176 # define _VAL(x) counter++
181 #define CND(name,comment) \
182 printf ("\n->CND:$%d:" #name ":$%d:" comment, __LINE__, ((int) _VAL (name)));
184 #define CNU(name,comment) \
185 printf ("\n->CNU:$%d:" #name ":$%u:" comment, __LINE__, ((unsigned int) _VAL (name)));
187 #define CNS(name,comment) \
188 printf ("\n->CNS:$%d:" #name ":" name ":" comment, __LINE__);
190 #define C(sname,type,value,comment)\
191 printf ("\n->C:$%d:" sname ":" #type ":" value ":" comment, __LINE__);
194 printf ("\n->SUB:$%d:" #sname ":" sname, __LINE__);
197 printf ("\n->TXT:$%d:" text, __LINE__);
201 #define CND(name, comment) \
202 asm volatile("\n->CND:%0:" #name ":%1:" comment \
203 : : "i" (__LINE__), "i" ((int) name));
204 /* Decimal constant in the range of type "int" */
206 #define CNU(name, comment) \
207 asm volatile("\n->CNU:%0:" #name ":%1:" comment \
208 : : "i" (__LINE__), "i" ((int) name));
209 /* Decimal constant in the range of type "unsigned int" (note, assembler
210 * always wants a signed int, we convert back in xoscons).
213 #define CNS(name, comment) \
214 asm volatile("\n->CNS:%0:" #name ":" name ":" comment \
216 /* General expression named number */
218 #define C(sname, type, value, comment) \
219 asm volatile("\n->C:%0:" sname ":" #type ":" value ":" comment \
224 asm volatile("\n->SUB:%0:" #sname ":" sname \
229 asm volatile("\n->TXT:%0:" text \
235 #define CST(name,comment) C(#name,String,name,comment)
236 /* String constant */
238 #define STR(x) STR1(x)
242 unsigned int _CRT_fmode
= _O_BINARY
;
249 -- This package provides target dependent definitions of constant for use
250 -- by the GNAT runtime library. This package should not be directly with'd
251 -- by an application program.
253 -- This file is generated automatically, do not modify it by hand! Instead,
254 -- make changes to s-oscons-tmplt.c and rebuild the GNAT runtime library.
258 ** Do not change the format of the line below without also updating the
261 TXT("-- This is the version for " TARGET
)
263 TXT("with Interfaces.C;")
266 package System.OS_Constants is
272 ** General constants (all platforms)
277 ---------------------------------
278 -- General platform parameters --
279 ---------------------------------
281 type OS_Type is (Windows, Other_OS);
283 #if defined (__MINGW32__)
284 # define TARGET_OS "Windows"
286 # define TARGET_OS "Other_OS"
288 C("Target_OS", OS_Type
, TARGET_OS
, "")
290 pragma Warnings (Off, Target_OS);
291 -- Suppress warnings on Target_OS since it is in general tested for
292 -- equality with a constant value to implement conditional compilation,
293 -- which normally generates a constant condition warning.
296 #define Target_Name TARGET
300 ** Note: the name of the following constant is recognized specially by
301 ** xoscons (case sensitive).
303 #define SIZEOF_unsigned_int sizeof (unsigned int)
304 CND(SIZEOF_unsigned_int
, "Size of unsigned int")
315 # define IOV_MAX INT_MAX
317 CND(IOV_MAX
, "Maximum writev iovcnt")
319 /* NAME_MAX is used to compute the allocation size for a struct dirent
320 * passed to readdir() / readdir_r(). However on some systems it is not
321 * defined, as it is technically a filesystem dependent property that
322 * we should retrieve through pathconf(). In any case, we do not need a
323 * precise value but only an upper limit.
327 /* Solaris has no NAME_MAX but defines MAXNAMELEN */
328 # define NAME_MAX MAXNAMELEN
329 # elif defined(PATH_MAX)
330 /* PATH_MAX (maximum length of a full path name) is a safe fall back */
331 # define NAME_MAX PATH_MAX
332 # elif defined(FILENAME_MAX)
333 /* Similarly FILENAME_MAX can provide a safe fall back */
334 # define NAME_MAX FILENAME_MAX
336 /* Hardcode a reasonably large value as a last chance fallback */
337 # define NAME_MAX 1024
340 CND(NAME_MAX
, "Maximum file name length")
344 ---------------------
345 -- File open modes --
346 ---------------------
353 CND(O_RDWR
, "Read/write")
358 CND(O_NOCTTY
, "Don't change ctrl tty")
363 CND(O_NDELAY
, "Nonblocking")
367 ----------------------
368 -- Fcntl operations --
369 ----------------------
376 CND(F_GETFL
, "Get flags")
381 CND(F_SETFL
, "Set flags")
394 CND(FNDELAY
, "Nonblocking")
398 ----------------------
399 -- Ioctl operations --
400 ----------------------
404 /* ioctl(2) requests are "int" in UNIX, but "unsigned long" on FreeBSD */
406 #if defined (__FreeBSD__) || defined (__DragonFly__)
408 # define IOCTL_Req_T "unsigned"
411 # define IOCTL_Req_T "int"
419 CNI(FIONBIO
, "Set/clear non-blocking io")
424 CNI(FIONREAD
, "How many bytes to read")
432 -- The following constants are defined from <errno.h>
438 CND(EAGAIN
, "Try again")
443 CND(ENOENT
, "File not found")
448 CND(ENOMEM
, "Out of memory")
453 -- The following constants are defined from <winsock2.h> (WSA*)
458 ** For sockets-related errno values on Windows, gsocket.h redefines
467 CND(EACCES
, "Permission denied")
470 # define EADDRINUSE -1
472 CND(EADDRINUSE
, "Address already in use")
474 #ifndef EADDRNOTAVAIL
475 # define EADDRNOTAVAIL -1
477 CND(EADDRNOTAVAIL
, "Cannot assign address")
480 # define EAFNOSUPPORT -1
482 CND(EAFNOSUPPORT
, "Addr family not supported")
487 CND(EALREADY
, "Operation in progress")
492 CND(EBADF
, "Bad file descriptor")
495 # define ECONNABORTED -1
497 CND(ECONNABORTED
, "Connection aborted")
500 # define ECONNREFUSED -1
502 CND(ECONNREFUSED
, "Connection refused")
505 # define ECONNRESET -1
507 CND(ECONNRESET
, "Connection reset by peer")
510 # define EDESTADDRREQ -1
512 CND(EDESTADDRREQ
, "Destination addr required")
517 CND(EFAULT
, "Bad address")
520 # define EHOSTDOWN -1
522 CND(EHOSTDOWN
, "Host is down")
525 # define EHOSTUNREACH -1
527 CND(EHOSTUNREACH
, "No route to host")
530 # define EINPROGRESS -1
532 CND(EINPROGRESS
, "Operation now in progress")
537 CND(EINTR
, "Interrupted system call")
542 CND(EINVAL
, "Invalid argument")
547 CND(EIO
, "Input output error")
552 CND(EISCONN
, "Socket already connected")
557 CND(ELOOP
, "Too many symbolic links")
562 CND(EMFILE
, "Too many open files")
567 CND(EMSGSIZE
, "Message too long")
570 # define ENAMETOOLONG -1
572 CND(ENAMETOOLONG
, "Name too long")
577 CND(ENETDOWN
, "Network is down")
580 # define ENETRESET -1
582 CND(ENETRESET
, "Disconn. on network reset")
585 # define ENETUNREACH -1
587 CND(ENETUNREACH
, "Network is unreachable")
592 CND(ENOBUFS
, "No buffer space available")
595 # define ENOPROTOOPT -1
597 CND(ENOPROTOOPT
, "Protocol not available")
602 CND(ENOTCONN
, "Socket not connected")
607 CND(ENOTSOCK
, "Operation on non socket")
610 # define EOPNOTSUPP -1
612 CND(EOPNOTSUPP
, "Operation not supported")
617 CND(EPIPE
, "Broken pipe")
620 # define EPFNOSUPPORT -1
622 CND(EPFNOSUPPORT
, "Unknown protocol family")
624 #ifndef EPROTONOSUPPORT
625 # define EPROTONOSUPPORT -1
627 CND(EPROTONOSUPPORT
, "Unknown protocol")
630 # define EPROTOTYPE -1
632 CND(EPROTOTYPE
, "Unknown protocol type")
637 CND(ERANGE
, "Result too large")
640 # define ESHUTDOWN -1
642 CND(ESHUTDOWN
, "Cannot send once shutdown")
644 #ifndef ESOCKTNOSUPPORT
645 # define ESOCKTNOSUPPORT -1
647 CND(ESOCKTNOSUPPORT
, "Socket type not supported")
650 # define ETIMEDOUT -1
652 CND(ETIMEDOUT
, "Connection timed out")
655 # define ETOOMANYREFS -1
657 CND(ETOOMANYREFS
, "Too many references")
660 # define EWOULDBLOCK -1
662 CND(EWOULDBLOCK
, "Operation would block")
667 CND(E2BIG
, "Argument list too long")
672 CND(EILSEQ
, "Illegal byte sequence")
675 ** Terminal/serial I/O constants
678 #if defined(HAVE_TERMIOS) || defined(__MINGW32__)
681 ----------------------
682 -- Terminal control --
683 ----------------------
693 CND(TCSANOW
, "Immediate")
698 CND(TCIFLUSH
, "Flush input")
703 CNU(IXON
, "Output sw flow control")
713 CNU(CRTSCTS
, "Output hw flow control")
723 CNU(CS5
, "5 data bits")
728 CNU(CS6
, "6 data bits")
733 CNU(CS7
, "7 data bits")
738 CNU(CS8
, "8 data bits")
743 CNU(CSTOPB
, "2 stop bits")
748 CNU(PARENB
, "Parity enable")
753 CNU(PARODD
, "Parity odd")
803 CNU(B1200
, "1200 bps")
808 CNU(B1800
, "1800 bps")
813 CNU(B2400
, "2400 bps")
818 CNU(B4800
, "4800 bps")
823 CNU(B9600
, "9600 bps")
828 CNU(B19200
, "19200 bps")
833 CNU(B38400
, "38400 bps")
838 CNU(B57600
, "57600 bps")
843 CNU(B115200
, "115200 bps")
848 CNU(B230400
, "230400 bps")
853 CNU(B460800
, "460800 bps")
858 CNU(B500000
, "500000 bps")
863 CNU(B576000
, "576000 bps")
868 CNU(B921600
, "921600 bps")
873 CNU(B1000000
, "1000000 bps")
878 CNU(B1152000
, "1152000 bps")
883 CNU(B1500000
, "1500000 bps")
888 CNU(B2000000
, "2000000 bps")
893 CNU(B2500000
, "2500000 bps")
898 CNU(B3000000
, "3000000 bps")
903 CNU(B3500000
, "3500000 bps")
908 CNU(B4000000
, "4000000 bps")
912 ---------------------------------
913 -- Terminal control characters --
914 ---------------------------------
921 CND(VINTR
, "Interrupt")
946 CND(VTIME
, "Read timeout")
951 CND(VMIN
, "Read min chars")
961 CND(VSTART
, "Flow control start")
966 CND(VSTOP
, "Flow control stop")
971 CND(VSUSP
, "Suspend")
981 CND(VREPRINT
, "Reprint unread")
986 CND(VDISCARD
, "Discard pending")
991 CND(VWERASE
, "Word erase")
996 CND(VLNEXT
, "Literal next")
1001 CND(VEOL2
, "Alternative EOL")
1003 #endif /* HAVE_TERMIOS */
1005 #if defined(__MINGW32__) || defined(__CYGWIN__)
1006 CNU(DTR_CONTROL_ENABLE
, "Enable DTR flow ctrl")
1007 CNU(RTS_CONTROL_ENABLE
, "Enable RTS flow ctrl")
1012 -----------------------------
1013 -- Pseudo terminal library --
1014 -----------------------------
1018 #if defined (__FreeBSD__) || defined (__linux__) || defined (__DragonFly__)
1019 # define PTY_Library "-lutil"
1021 # define PTY_Library ""
1023 CST(PTY_Library
, "for g-exptty")
1026 ** Sockets constants
1042 CND(AF_INET
, "IPv4 address family")
1045 ** RTEMS lies and defines AF_INET6 even though there is no IPV6 support.
1046 ** Its TCP/IP stack is in transition. It has newer .h files but no IPV6 yet.
1048 #if defined(__rtems__)
1053 # define AF_INET6 -1
1055 # define HAVE_AF_INET6 1
1057 CND(AF_INET6
, "IPv6 address family")
1068 # define SOCK_STREAM -1
1070 CND(SOCK_STREAM
, "Stream socket")
1073 # define SOCK_DGRAM -1
1075 CND(SOCK_DGRAM
, "Datagram socket")
1085 #ifndef HOST_NOT_FOUND
1086 # define HOST_NOT_FOUND -1
1088 CND(HOST_NOT_FOUND
, "Unknown host")
1091 # define TRY_AGAIN -1
1093 CND(TRY_AGAIN
, "Host name lookup failure")
1098 CND(NO_DATA
, "No data record for name")
1101 # define NO_RECOVERY -1
1103 CND(NO_RECOVERY
, "Non recoverable errors")
1107 --------------------
1108 -- Shutdown modes --
1109 --------------------
1116 CND(SHUT_RD
, "No more recv")
1121 CND(SHUT_WR
, "No more send")
1124 # define SHUT_RDWR -1
1126 CND(SHUT_RDWR
, "No more recv/send")
1130 ---------------------
1131 -- Protocol levels --
1132 ---------------------
1137 # define SOL_SOCKET -1
1139 CND(SOL_SOCKET
, "Options for socket level")
1142 # define IPPROTO_IP -1
1144 CND(IPPROTO_IP
, "Dummy protocol for IP")
1147 # define IPPROTO_UDP -1
1149 CND(IPPROTO_UDP
, "UDP")
1152 # define IPPROTO_TCP -1
1154 CND(IPPROTO_TCP
, "TCP")
1167 CND(MSG_OOB
, "Process out-of-band data")
1170 # define MSG_PEEK -1
1172 CND(MSG_PEEK
, "Peek at incoming data")
1177 CND(MSG_EOR
, "Send end of record")
1181 /* The value of MSG_WAITALL is 8. Nevertheless winsock.h doesn't
1182 define it, but it is still usable as we link to winsock2 API. */
1183 # define MSG_WAITALL (1 << 3)
1185 # define MSG_WAITALL -1
1188 CND(MSG_WAITALL
, "Wait for full reception")
1190 #ifndef MSG_NOSIGNAL
1191 # define MSG_NOSIGNAL -1
1193 CND(MSG_NOSIGNAL
, "No SIGPIPE on send")
1195 #if defined (__linux__) || defined (__ANDROID__) || defined (__QNX__)
1196 # define MSG_Forced_Flags "MSG_NOSIGNAL"
1198 # define MSG_Forced_Flags "0"
1200 CNS(MSG_Forced_Flags
, "")
1202 -- Flags set on all send(2) calls
1207 --------------------
1208 -- Socket options --
1209 --------------------
1214 # define TCP_NODELAY -1
1216 CND(TCP_NODELAY
, "Do not coalesce packets")
1218 #ifndef SO_REUSEADDR
1219 # define SO_REUSEADDR -1
1221 CND(SO_REUSEADDR
, "Bind reuse local address")
1223 #ifndef SO_REUSEPORT
1224 # define SO_REUSEPORT -1
1226 CND(SO_REUSEPORT
, "Bind reuse port number")
1228 #ifndef SO_KEEPALIVE
1229 # define SO_KEEPALIVE -1
1231 CND(SO_KEEPALIVE
, "Enable keep-alive msgs")
1234 # define SO_LINGER -1
1236 CND(SO_LINGER
, "Defer close to flush data")
1238 #ifndef SO_BROADCAST
1239 # define SO_BROADCAST -1
1241 CND(SO_BROADCAST
, "Can send broadcast msgs")
1244 # define SO_SNDBUF -1
1246 CND(SO_SNDBUF
, "Set/get send buffer size")
1249 # define SO_RCVBUF -1
1251 CND(SO_RCVBUF
, "Set/get recv buffer size")
1254 # define SO_SNDTIMEO -1
1256 CND(SO_SNDTIMEO
, "Emission timeout")
1259 # define SO_RCVTIMEO -1
1261 CND(SO_RCVTIMEO
, "Reception timeout")
1264 # define SO_ERROR -1
1266 CND(SO_ERROR
, "Get/clear error status")
1268 #ifndef SO_BUSY_POLL
1269 # define SO_BUSY_POLL -1
1271 CND(SO_BUSY_POLL
, "Busy polling")
1273 #ifndef IP_MULTICAST_IF
1274 # define IP_MULTICAST_IF -1
1276 CND(IP_MULTICAST_IF
, "Set/get mcast interface")
1278 #ifndef IP_MULTICAST_TTL
1279 # define IP_MULTICAST_TTL -1
1281 CND(IP_MULTICAST_TTL
, "Set/get multicast TTL")
1283 #ifndef IP_MULTICAST_LOOP
1284 # define IP_MULTICAST_LOOP -1
1286 CND(IP_MULTICAST_LOOP
, "Set/get mcast loopback")
1288 #ifndef IP_ADD_MEMBERSHIP
1289 # define IP_ADD_MEMBERSHIP -1
1291 CND(IP_ADD_MEMBERSHIP
, "Join a multicast group")
1293 #ifndef IP_DROP_MEMBERSHIP
1294 # define IP_DROP_MEMBERSHIP -1
1296 CND(IP_DROP_MEMBERSHIP
, "Leave a multicast group")
1299 # define IP_PKTINFO -1
1301 CND(IP_PKTINFO
, "Get datagram info")
1305 ----------------------
1306 -- Type definitions --
1307 ----------------------
1314 -- Sizes (in bytes) of the components of struct timeval
1316 #define SIZEOF_tv_sec (sizeof tv.tv_sec)
1317 CND(SIZEOF_tv_sec
, "tv_sec")
1318 #define SIZEOF_tv_usec (sizeof tv.tv_usec)
1319 CND(SIZEOF_tv_usec
, "tv_usec")
1322 -- Maximum allowed value for tv_sec
1326 ** On Solaris, field tv_sec in struct timeval has an undocumented
1327 ** hard-wired limit of 100 million.
1328 ** On IA64 HP-UX the limit is 2**31 - 1.
1330 #if defined (__sun__)
1331 # define MAX_tv_sec "100_000_000"
1333 #elif defined (__hpux__)
1334 # define MAX_tv_sec "16#7fffffff#"
1337 # define MAX_tv_sec "2 ** (SIZEOF_tv_sec * 8 - 1) - 1"
1343 -- Sizes of various data types
1346 #define SIZEOF_sockaddr_in (sizeof (struct sockaddr_in))
1347 CND(SIZEOF_sockaddr_in
, "struct sockaddr_in")
1348 #ifdef HAVE_AF_INET6
1349 # define SIZEOF_sockaddr_in6 (sizeof (struct sockaddr_in6))
1351 # define SIZEOF_sockaddr_in6 0
1353 CND(SIZEOF_sockaddr_in6
, "struct sockaddr_in6")
1355 #define SIZEOF_fd_set (sizeof (fd_set))
1356 CND(SIZEOF_fd_set
, "fd_set")
1357 CND(FD_SETSIZE
, "Max fd value")
1359 #define SIZEOF_struct_hostent (sizeof (struct hostent))
1360 CND(SIZEOF_struct_hostent
, "struct hostent")
1362 #define SIZEOF_struct_servent (sizeof (struct servent))
1363 CND(SIZEOF_struct_servent
, "struct servent")
1365 #if defined (__linux__) || defined (__ANDROID__) || defined (__QNX__)
1366 #define SIZEOF_sigset (sizeof (sigset_t))
1367 CND(SIZEOF_sigset
, "sigset")
1372 -- Fields of struct msghdr
1375 #if defined (__sun__) || defined (__hpux__)
1376 # define Msg_Iovlen_T "int"
1378 # define Msg_Iovlen_T "size_t"
1385 ----------------------------------------
1386 -- Properties of supported interfaces --
1387 ----------------------------------------
1391 CND(Need_Netdb_Buffer
, "Need buffer for Netdb ops")
1392 CND(Need_Netdb_Lock
, "Need lock for Netdb ops")
1393 CND(Has_Sockaddr_Len
, "Sockaddr has sa_len field")
1396 ** Do not change the format of the line below without also updating the
1399 C("Thread_Blocking_IO", Boolean
, "True", "")
1401 -- Set False for contexts where socket i/o are process blocking
1405 #ifdef HAVE_INET_PTON
1406 # define Inet_Pton_Linkname "inet_pton"
1408 # define Inet_Pton_Linkname "__gnat_inet_pton"
1410 CST(Inet_Pton_Linkname
, "")
1412 #endif /* HAVE_SOCKETS */
1416 ---------------------
1417 -- Threads support --
1418 ---------------------
1420 -- Clock identifier definitions
1424 /* Note: On HP-UX, CLOCK_REALTIME is an enum, not a macro. */
1426 #if !(defined(CLOCK_REALTIME) || defined (__hpux__))
1427 # define CLOCK_REALTIME (-1)
1429 CND(CLOCK_REALTIME
, "System realtime clock")
1431 #ifdef CLOCK_MONOTONIC
1432 CND(CLOCK_MONOTONIC
, "System monotonic clock")
1435 #ifdef CLOCK_FASTEST
1436 CND(CLOCK_FASTEST
, "Fastest clock")
1439 #ifndef CLOCK_THREAD_CPUTIME_ID
1440 # define CLOCK_THREAD_CPUTIME_ID -1
1442 CND(CLOCK_THREAD_CPUTIME_ID
, "Thread CPU clock")
1444 #if defined(__linux__) || defined(__FreeBSD__) \
1445 || (defined(_AIX) && defined(_AIXVERSION_530)) \
1446 || defined(__DragonFly__) || defined(__QNX__)
1447 /** On these platforms use system provided monotonic clock instead of
1448 ** the default CLOCK_REALTIME. We then need to set up cond var attributes
1449 ** appropriately (see thread.c).
1451 ** Note that AIX 5.2 does not support CLOCK_MONOTONIC timestamps for
1452 ** pthread_cond_timedwait (and does not have pthread_condattr_setclock),
1453 ** hence the conditionalization on AIX version above). _AIXVERSION_530
1454 ** is defined in AIX 5.3 and more recent versions.
1456 # define CLOCK_RT_Ada "CLOCK_MONOTONIC"
1459 /* By default use CLOCK_REALTIME */
1460 # define CLOCK_RT_Ada "CLOCK_REALTIME"
1464 CNS(CLOCK_RT_Ada
, "")
1467 #if defined (__APPLE__) || defined (__linux__) || defined (__ANDROID__) \
1468 || defined (__QNX__) || defined (__rtems__) || defined (DUMMY)
1471 -- Sizes of pthread data types
1474 #if defined (__APPLE__) || defined (DUMMY)
1476 -- (on Darwin, these are just placeholders)
1478 #define PTHREAD_SIZE __PTHREAD_SIZE__
1479 #define PTHREAD_ATTR_SIZE __PTHREAD_ATTR_SIZE__
1480 #define PTHREAD_MUTEXATTR_SIZE __PTHREAD_MUTEXATTR_SIZE__
1481 #define PTHREAD_MUTEX_SIZE __PTHREAD_MUTEX_SIZE__
1482 #define PTHREAD_CONDATTR_SIZE __PTHREAD_CONDATTR_SIZE__
1483 #define PTHREAD_COND_SIZE __PTHREAD_COND_SIZE__
1484 #define PTHREAD_RWLOCKATTR_SIZE __PTHREAD_RWLOCKATTR_SIZE__
1485 #define PTHREAD_RWLOCK_SIZE __PTHREAD_RWLOCK_SIZE__
1486 #define PTHREAD_ONCE_SIZE __PTHREAD_ONCE_SIZE__
1488 #define PTHREAD_SIZE (sizeof (pthread_t))
1489 #define PTHREAD_ATTR_SIZE (sizeof (pthread_attr_t))
1490 #define PTHREAD_MUTEXATTR_SIZE (sizeof (pthread_mutexattr_t))
1491 #define PTHREAD_MUTEX_SIZE (sizeof (pthread_mutex_t))
1492 #define PTHREAD_CONDATTR_SIZE (sizeof (pthread_condattr_t))
1493 #define PTHREAD_COND_SIZE (sizeof (pthread_cond_t))
1494 #define PTHREAD_RWLOCKATTR_SIZE (sizeof (pthread_rwlockattr_t))
1495 #define PTHREAD_RWLOCK_SIZE (sizeof (pthread_rwlock_t))
1496 #define PTHREAD_ONCE_SIZE (sizeof (pthread_once_t))
1501 CND(PTHREAD_SIZE
, "pthread_t")
1502 CND(PTHREAD_ATTR_SIZE
, "pthread_attr_t")
1503 CND(PTHREAD_MUTEXATTR_SIZE
, "pthread_mutexattr_t")
1504 CND(PTHREAD_MUTEX_SIZE
, "pthread_mutex_t")
1505 CND(PTHREAD_CONDATTR_SIZE
, "pthread_condattr_t")
1506 CND(PTHREAD_COND_SIZE
, "pthread_cond_t")
1507 CND(PTHREAD_RWLOCKATTR_SIZE
, "pthread_rwlockattr_t")
1508 CND(PTHREAD_RWLOCK_SIZE
, "pthread_rwlock_t")
1509 CND(PTHREAD_ONCE_SIZE
, "pthread_once_t")
1511 #endif /* __APPLE__ || __linux__ || __ANDROID__ || __rtems__ */
1515 --------------------------------
1516 -- File and directory support --
1517 --------------------------------
1522 ** Note: this constant can be used in the GNAT runtime library. In compiler
1523 ** units on the other hand, System.OS_Constants is not available, so we
1524 ** declare an Ada constant (Osint.File_Attributes_Size) independently, which
1525 ** is at least as large as sizeof (struct file_attributes), and we have an
1526 ** assertion at initialization of Osint checking that the size is indeed at
1527 ** least sufficient.
1529 #define SIZEOF_struct_file_attributes (sizeof (struct file_attributes))
1530 CND(SIZEOF_struct_file_attributes
, "struct file_attributes")
1533 ** Maximal size of buffer for struct dirent. Note: Since POSIX.1 does not
1534 ** specify the size of the d_name field, and other nonstandard fields may
1535 ** precede that field within the dirent structure, we must make a conservative
1540 #define SIZEOF_struct_dirent_alloc \
1541 ((char*) &dent.d_name - (char*) &dent) + NAME_MAX + 1
1542 CND(SIZEOF_struct_dirent_alloc
, "struct dirent allocation")
1546 ** System-specific constants follow
1547 ** Each section should be activated if compiling for the corresponding
1548 ** platform *or* generating the dummy version for runtime test compilation.
1551 #if defined (__vxworks) || defined (DUMMY)
1555 --------------------------------
1556 -- VxWorks-specific constants --
1557 --------------------------------
1559 -- These constants may be used only within the VxWorks version of
1560 -- GNAT.Sockets.Thin.
1563 CND(OK
, "VxWorks generic success")
1564 CND(ERROR
, "VxWorks generic error")
1566 #endif /* __vxworks */
1568 #if defined (__MINGW32__) || defined (DUMMY)
1571 ------------------------------
1572 -- MinGW-specific constants --
1573 ------------------------------
1575 -- These constants may be used only within the MinGW version of
1576 -- GNAT.Sockets.Thin.
1579 CND(WSASYSNOTREADY
, "System not ready")
1580 CND(WSAVERNOTSUPPORTED
, "Version not supported")
1581 CND(WSANOTINITIALISED
, "Winsock not initialized")
1582 CND(WSAEDISCON
, "Disconnected")
1584 #endif /* __MINGW32__ */
1587 ** End of constants definitions
1596 end System.OS_Constants;