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-2017, 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 (__rtems__)
161 # include <pthread.h>
165 #if defined(__MINGW32__) || defined(__CYGWIN__)
167 # include <winbase.h>
175 # define _VAL(x) counter++
180 #define CND(name,comment) \
181 printf ("\n->CND:$%d:" #name ":$%d:" comment, __LINE__, ((int) _VAL (name)));
183 #define CNU(name,comment) \
184 printf ("\n->CNU:$%d:" #name ":$%u:" comment, __LINE__, ((unsigned int) _VAL (name)));
186 #define CNS(name,comment) \
187 printf ("\n->CNS:$%d:" #name ":" name ":" comment, __LINE__);
189 #define C(sname,type,value,comment)\
190 printf ("\n->C:$%d:" sname ":" #type ":" value ":" comment, __LINE__);
193 printf ("\n->SUB:$%d:" #sname ":" sname, __LINE__);
196 printf ("\n->TXT:$%d:" text, __LINE__);
200 #define CND(name, comment) \
201 asm volatile("\n->CND:%0:" #name ":%1:" comment \
202 : : "i" (__LINE__), "i" ((int) name));
203 /* Decimal constant in the range of type "int" */
205 #define CNU(name, comment) \
206 asm volatile("\n->CNU:%0:" #name ":%1:" comment \
207 : : "i" (__LINE__), "i" ((int) name));
208 /* Decimal constant in the range of type "unsigned int" (note, assembler
209 * always wants a signed int, we convert back in xoscons).
212 #define CNS(name, comment) \
213 asm volatile("\n->CNS:%0:" #name ":" name ":" comment \
215 /* General expression named number */
217 #define C(sname, type, value, comment) \
218 asm volatile("\n->C:%0:" sname ":" #type ":" value ":" comment \
223 asm volatile("\n->SUB:%0:" #sname ":" sname \
228 asm volatile("\n->TXT:%0:" text \
234 #define CST(name,comment) C(#name,String,name,comment)
235 /* String constant */
237 #define STR(x) STR1(x)
241 unsigned int _CRT_fmode
= _O_BINARY
;
248 -- This package provides target dependent definitions of constant for use
249 -- by the GNAT runtime library. This package should not be directly with'd
250 -- by an application program.
252 -- This file is generated automatically, do not modify it by hand! Instead,
253 -- make changes to s-oscons-tmplt.c and rebuild the GNAT runtime library.
257 ** Do not change the format of the line below without also updating the
260 TXT("-- This is the version for " TARGET
)
262 TXT("with Interfaces.C;")
265 package System.OS_Constants is
271 ** General constants (all platforms)
276 ---------------------------------
277 -- General platform parameters --
278 ---------------------------------
280 type OS_Type is (Windows, Other_OS);
282 #if defined (__MINGW32__)
283 # define TARGET_OS "Windows"
285 # define TARGET_OS "Other_OS"
287 C("Target_OS", OS_Type
, TARGET_OS
, "")
289 pragma Warnings (Off, Target_OS);
290 -- Suppress warnings on Target_OS since it is in general tested for
291 -- equality with a constant value to implement conditional compilation,
292 -- which normally generates a constant condition warning.
295 #define Target_Name TARGET
299 ** Note: the name of the following constant is recognized specially by
300 ** xoscons (case sensitive).
302 #define SIZEOF_unsigned_int sizeof (unsigned int)
303 CND(SIZEOF_unsigned_int
, "Size of unsigned int")
314 # define IOV_MAX INT_MAX
316 CND(IOV_MAX
, "Maximum writev iovcnt")
318 /* NAME_MAX is used to compute the allocation size for a struct dirent
319 * passed to readdir() / readdir_r(). However on some systems it is not
320 * defined, as it is technically a filesystem dependent property that
321 * we should retrieve through pathconf(). In any case, we do not need a
322 * precise value but only an upper limit.
326 /* Solaris has no NAME_MAX but defines MAXNAMELEN */
327 # define NAME_MAX MAXNAMELEN
328 # elif defined(PATH_MAX)
329 /* PATH_MAX (maximum length of a full path name) is a safe fall back */
330 # define NAME_MAX PATH_MAX
331 # elif defined(FILENAME_MAX)
332 /* Similarly FILENAME_MAX can provide a safe fall back */
333 # define NAME_MAX FILENAME_MAX
335 /* Hardcode a reasonably large value as a last chance fallback */
336 # define NAME_MAX 1024
339 CND(NAME_MAX
, "Maximum file name length")
343 ---------------------
344 -- File open modes --
345 ---------------------
352 CND(O_RDWR
, "Read/write")
357 CND(O_NOCTTY
, "Don't change ctrl tty")
362 CND(O_NDELAY
, "Nonblocking")
366 ----------------------
367 -- Fcntl operations --
368 ----------------------
375 CND(F_GETFL
, "Get flags")
380 CND(F_SETFL
, "Set flags")
393 CND(FNDELAY
, "Nonblocking")
397 ----------------------
398 -- Ioctl operations --
399 ----------------------
403 /* ioctl(2) requests are "int" in UNIX, but "unsigned long" on FreeBSD */
405 #if defined (__FreeBSD__) || defined (__DragonFly__)
407 # define IOCTL_Req_T "unsigned"
410 # define IOCTL_Req_T "int"
418 CNI(FIONBIO
, "Set/clear non-blocking io")
423 CNI(FIONREAD
, "How many bytes to read")
431 -- The following constants are defined from <errno.h>
437 CND(EAGAIN
, "Try again")
442 CND(ENOENT
, "File not found")
447 CND(ENOMEM
, "Out of memory")
452 -- The following constants are defined from <winsock2.h> (WSA*)
457 ** For sockets-related errno values on Windows, gsocket.h redefines
466 CND(EACCES
, "Permission denied")
469 # define EADDRINUSE -1
471 CND(EADDRINUSE
, "Address already in use")
473 #ifndef EADDRNOTAVAIL
474 # define EADDRNOTAVAIL -1
476 CND(EADDRNOTAVAIL
, "Cannot assign address")
479 # define EAFNOSUPPORT -1
481 CND(EAFNOSUPPORT
, "Addr family not supported")
486 CND(EALREADY
, "Operation in progress")
491 CND(EBADF
, "Bad file descriptor")
494 # define ECONNABORTED -1
496 CND(ECONNABORTED
, "Connection aborted")
499 # define ECONNREFUSED -1
501 CND(ECONNREFUSED
, "Connection refused")
504 # define ECONNRESET -1
506 CND(ECONNRESET
, "Connection reset by peer")
509 # define EDESTADDRREQ -1
511 CND(EDESTADDRREQ
, "Destination addr required")
516 CND(EFAULT
, "Bad address")
519 # define EHOSTDOWN -1
521 CND(EHOSTDOWN
, "Host is down")
524 # define EHOSTUNREACH -1
526 CND(EHOSTUNREACH
, "No route to host")
529 # define EINPROGRESS -1
531 CND(EINPROGRESS
, "Operation now in progress")
536 CND(EINTR
, "Interrupted system call")
541 CND(EINVAL
, "Invalid argument")
546 CND(EIO
, "Input output error")
551 CND(EISCONN
, "Socket already connected")
556 CND(ELOOP
, "Too many symbolic links")
561 CND(EMFILE
, "Too many open files")
566 CND(EMSGSIZE
, "Message too long")
569 # define ENAMETOOLONG -1
571 CND(ENAMETOOLONG
, "Name too long")
576 CND(ENETDOWN
, "Network is down")
579 # define ENETRESET -1
581 CND(ENETRESET
, "Disconn. on network reset")
584 # define ENETUNREACH -1
586 CND(ENETUNREACH
, "Network is unreachable")
591 CND(ENOBUFS
, "No buffer space available")
594 # define ENOPROTOOPT -1
596 CND(ENOPROTOOPT
, "Protocol not available")
601 CND(ENOTCONN
, "Socket not connected")
606 CND(ENOTSOCK
, "Operation on non socket")
609 # define EOPNOTSUPP -1
611 CND(EOPNOTSUPP
, "Operation not supported")
616 CND(EPIPE
, "Broken pipe")
619 # define EPFNOSUPPORT -1
621 CND(EPFNOSUPPORT
, "Unknown protocol family")
623 #ifndef EPROTONOSUPPORT
624 # define EPROTONOSUPPORT -1
626 CND(EPROTONOSUPPORT
, "Unknown protocol")
629 # define EPROTOTYPE -1
631 CND(EPROTOTYPE
, "Unknown protocol type")
636 CND(ERANGE
, "Result too large")
639 # define ESHUTDOWN -1
641 CND(ESHUTDOWN
, "Cannot send once shutdown")
643 #ifndef ESOCKTNOSUPPORT
644 # define ESOCKTNOSUPPORT -1
646 CND(ESOCKTNOSUPPORT
, "Socket type not supported")
649 # define ETIMEDOUT -1
651 CND(ETIMEDOUT
, "Connection timed out")
654 # define ETOOMANYREFS -1
656 CND(ETOOMANYREFS
, "Too many references")
659 # define EWOULDBLOCK -1
661 CND(EWOULDBLOCK
, "Operation would block")
666 CND(E2BIG
, "Argument list too long")
671 CND(EILSEQ
, "Illegal byte sequence")
674 ** Terminal/serial I/O constants
677 #if defined(HAVE_TERMIOS) || defined(__MINGW32__)
680 ----------------------
681 -- Terminal control --
682 ----------------------
692 CND(TCSANOW
, "Immediate")
697 CND(TCIFLUSH
, "Flush input")
702 CNU(IXON
, "Output sw flow control")
712 CNU(CRTSCTS
, "Output hw flow control")
722 CNU(CS5
, "5 data bits")
727 CNU(CS6
, "6 data bits")
732 CNU(CS7
, "7 data bits")
737 CNU(CS8
, "8 data bits")
742 CNU(CSTOPB
, "2 stop bits")
747 CNU(PARENB
, "Parity enable")
752 CNU(PARODD
, "Parity odd")
802 CNU(B1200
, "1200 bps")
807 CNU(B1800
, "1800 bps")
812 CNU(B2400
, "2400 bps")
817 CNU(B4800
, "4800 bps")
822 CNU(B9600
, "9600 bps")
827 CNU(B19200
, "19200 bps")
832 CNU(B38400
, "38400 bps")
837 CNU(B57600
, "57600 bps")
842 CNU(B115200
, "115200 bps")
847 CNU(B230400
, "230400 bps")
852 CNU(B460800
, "460800 bps")
857 CNU(B500000
, "500000 bps")
862 CNU(B576000
, "576000 bps")
867 CNU(B921600
, "921600 bps")
872 CNU(B1000000
, "1000000 bps")
877 CNU(B1152000
, "1152000 bps")
882 CNU(B1500000
, "1500000 bps")
887 CNU(B2000000
, "2000000 bps")
892 CNU(B2500000
, "2500000 bps")
897 CNU(B3000000
, "3000000 bps")
902 CNU(B3500000
, "3500000 bps")
907 CNU(B4000000
, "4000000 bps")
911 ---------------------------------
912 -- Terminal control characters --
913 ---------------------------------
920 CND(VINTR
, "Interrupt")
945 CND(VTIME
, "Read timeout")
950 CND(VMIN
, "Read min chars")
960 CND(VSTART
, "Flow control start")
965 CND(VSTOP
, "Flow control stop")
970 CND(VSUSP
, "Suspend")
980 CND(VREPRINT
, "Reprint unread")
985 CND(VDISCARD
, "Discard pending")
990 CND(VWERASE
, "Word erase")
995 CND(VLNEXT
, "Literal next")
1000 CND(VEOL2
, "Alternative EOL")
1002 #endif /* HAVE_TERMIOS */
1004 #if defined(__MINGW32__) || defined(__CYGWIN__)
1005 CNU(DTR_CONTROL_ENABLE
, "Enable DTR flow ctrl")
1006 CNU(RTS_CONTROL_ENABLE
, "Enable RTS flow ctrl")
1011 -----------------------------
1012 -- Pseudo terminal library --
1013 -----------------------------
1017 #if defined (__FreeBSD__) || defined (__linux__) || defined (__DragonFly__)
1018 # define PTY_Library "-lutil"
1020 # define PTY_Library ""
1022 CST(PTY_Library
, "for g-exptty")
1025 ** Sockets constants
1041 CND(AF_INET
, "IPv4 address family")
1044 ** RTEMS lies and defines AF_INET6 even though there is no IPV6 support.
1045 ** Its TCP/IP stack is in transition. It has newer .h files but no IPV6 yet.
1047 #if defined(__rtems__)
1052 # define AF_INET6 -1
1054 # define HAVE_AF_INET6 1
1056 CND(AF_INET6
, "IPv6 address family")
1067 # define SOCK_STREAM -1
1069 CND(SOCK_STREAM
, "Stream socket")
1072 # define SOCK_DGRAM -1
1074 CND(SOCK_DGRAM
, "Datagram socket")
1084 #ifndef HOST_NOT_FOUND
1085 # define HOST_NOT_FOUND -1
1087 CND(HOST_NOT_FOUND
, "Unknown host")
1090 # define TRY_AGAIN -1
1092 CND(TRY_AGAIN
, "Host name lookup failure")
1097 CND(NO_DATA
, "No data record for name")
1100 # define NO_RECOVERY -1
1102 CND(NO_RECOVERY
, "Non recoverable errors")
1106 --------------------
1107 -- Shutdown modes --
1108 --------------------
1115 CND(SHUT_RD
, "No more recv")
1120 CND(SHUT_WR
, "No more send")
1123 # define SHUT_RDWR -1
1125 CND(SHUT_RDWR
, "No more recv/send")
1129 ---------------------
1130 -- Protocol levels --
1131 ---------------------
1136 # define SOL_SOCKET -1
1138 CND(SOL_SOCKET
, "Options for socket level")
1141 # define IPPROTO_IP -1
1143 CND(IPPROTO_IP
, "Dummy protocol for IP")
1146 # define IPPROTO_UDP -1
1148 CND(IPPROTO_UDP
, "UDP")
1151 # define IPPROTO_TCP -1
1153 CND(IPPROTO_TCP
, "TCP")
1166 CND(MSG_OOB
, "Process out-of-band data")
1169 # define MSG_PEEK -1
1171 CND(MSG_PEEK
, "Peek at incoming data")
1176 CND(MSG_EOR
, "Send end of record")
1180 /* The value of MSG_WAITALL is 8. Nevertheless winsock.h doesn't
1181 define it, but it is still usable as we link to winsock2 API. */
1182 # define MSG_WAITALL (1 << 3)
1184 # define MSG_WAITALL -1
1187 CND(MSG_WAITALL
, "Wait for full reception")
1189 #ifndef MSG_NOSIGNAL
1190 # define MSG_NOSIGNAL -1
1192 CND(MSG_NOSIGNAL
, "No SIGPIPE on send")
1194 #if defined (__linux__) || defined (__ANDROID__)
1195 # define MSG_Forced_Flags "MSG_NOSIGNAL"
1197 # define MSG_Forced_Flags "0"
1199 CNS(MSG_Forced_Flags
, "")
1201 -- Flags set on all send(2) calls
1206 --------------------
1207 -- Socket options --
1208 --------------------
1213 # define TCP_NODELAY -1
1215 CND(TCP_NODELAY
, "Do not coalesce packets")
1217 #ifndef SO_REUSEADDR
1218 # define SO_REUSEADDR -1
1220 CND(SO_REUSEADDR
, "Bind reuse local address")
1222 #ifndef SO_REUSEPORT
1223 # define SO_REUSEPORT -1
1225 CND(SO_REUSEPORT
, "Bind reuse port number")
1227 #ifndef SO_KEEPALIVE
1228 # define SO_KEEPALIVE -1
1230 CND(SO_KEEPALIVE
, "Enable keep-alive msgs")
1233 # define SO_LINGER -1
1235 CND(SO_LINGER
, "Defer close to flush data")
1237 #ifndef SO_BROADCAST
1238 # define SO_BROADCAST -1
1240 CND(SO_BROADCAST
, "Can send broadcast msgs")
1243 # define SO_SNDBUF -1
1245 CND(SO_SNDBUF
, "Set/get send buffer size")
1248 # define SO_RCVBUF -1
1250 CND(SO_RCVBUF
, "Set/get recv buffer size")
1253 # define SO_SNDTIMEO -1
1255 CND(SO_SNDTIMEO
, "Emission timeout")
1258 # define SO_RCVTIMEO -1
1260 CND(SO_RCVTIMEO
, "Reception timeout")
1263 # define SO_ERROR -1
1265 CND(SO_ERROR
, "Get/clear error status")
1267 #ifndef SO_BUSY_POLL
1268 # define SO_BUSY_POLL -1
1270 CND(SO_BUSY_POLL
, "Busy polling")
1272 #ifndef IP_MULTICAST_IF
1273 # define IP_MULTICAST_IF -1
1275 CND(IP_MULTICAST_IF
, "Set/get mcast interface")
1277 #ifndef IP_MULTICAST_TTL
1278 # define IP_MULTICAST_TTL -1
1280 CND(IP_MULTICAST_TTL
, "Set/get multicast TTL")
1282 #ifndef IP_MULTICAST_LOOP
1283 # define IP_MULTICAST_LOOP -1
1285 CND(IP_MULTICAST_LOOP
, "Set/get mcast loopback")
1287 #ifndef IP_ADD_MEMBERSHIP
1288 # define IP_ADD_MEMBERSHIP -1
1290 CND(IP_ADD_MEMBERSHIP
, "Join a multicast group")
1292 #ifndef IP_DROP_MEMBERSHIP
1293 # define IP_DROP_MEMBERSHIP -1
1295 CND(IP_DROP_MEMBERSHIP
, "Leave a multicast group")
1298 # define IP_PKTINFO -1
1300 CND(IP_PKTINFO
, "Get datagram info")
1304 ----------------------
1305 -- Type definitions --
1306 ----------------------
1313 -- Sizes (in bytes) of the components of struct timeval
1315 #define SIZEOF_tv_sec (sizeof tv.tv_sec)
1316 CND(SIZEOF_tv_sec
, "tv_sec")
1317 #define SIZEOF_tv_usec (sizeof tv.tv_usec)
1318 CND(SIZEOF_tv_usec
, "tv_usec")
1321 -- Maximum allowed value for tv_sec
1325 ** On Solaris, field tv_sec in struct timeval has an undocumented
1326 ** hard-wired limit of 100 million.
1327 ** On IA64 HP-UX the limit is 2**31 - 1.
1329 #if defined (__sun__)
1330 # define MAX_tv_sec "100_000_000"
1332 #elif defined (__hpux__)
1333 # define MAX_tv_sec "16#7fffffff#"
1336 # define MAX_tv_sec "2 ** (SIZEOF_tv_sec * 8 - 1) - 1"
1342 -- Sizes of various data types
1345 #define SIZEOF_sockaddr_in (sizeof (struct sockaddr_in))
1346 CND(SIZEOF_sockaddr_in
, "struct sockaddr_in")
1347 #ifdef HAVE_AF_INET6
1348 # define SIZEOF_sockaddr_in6 (sizeof (struct sockaddr_in6))
1350 # define SIZEOF_sockaddr_in6 0
1352 CND(SIZEOF_sockaddr_in6
, "struct sockaddr_in6")
1354 #define SIZEOF_fd_set (sizeof (fd_set))
1355 CND(SIZEOF_fd_set
, "fd_set")
1356 CND(FD_SETSIZE
, "Max fd value")
1358 #define SIZEOF_struct_hostent (sizeof (struct hostent))
1359 CND(SIZEOF_struct_hostent
, "struct hostent")
1361 #define SIZEOF_struct_servent (sizeof (struct servent))
1362 CND(SIZEOF_struct_servent
, "struct servent")
1364 #if defined (__linux__) || defined (__ANDROID__)
1365 #define SIZEOF_sigset (sizeof (sigset_t))
1366 CND(SIZEOF_sigset
, "sigset")
1371 -- Fields of struct msghdr
1374 #if defined (__sun__) || defined (__hpux__)
1375 # define Msg_Iovlen_T "int"
1377 # define Msg_Iovlen_T "size_t"
1384 ----------------------------------------
1385 -- Properties of supported interfaces --
1386 ----------------------------------------
1390 CND(Need_Netdb_Buffer
, "Need buffer for Netdb ops")
1391 CND(Need_Netdb_Lock
, "Need lock for Netdb ops")
1392 CND(Has_Sockaddr_Len
, "Sockaddr has sa_len field")
1395 ** Do not change the format of the line below without also updating the
1398 C("Thread_Blocking_IO", Boolean
, "True", "")
1400 -- Set False for contexts where socket i/o are process blocking
1404 #ifdef HAVE_INET_PTON
1405 # define Inet_Pton_Linkname "inet_pton"
1407 # define Inet_Pton_Linkname "__gnat_inet_pton"
1409 CST(Inet_Pton_Linkname
, "")
1411 #endif /* HAVE_SOCKETS */
1415 ---------------------
1416 -- Threads support --
1417 ---------------------
1419 -- Clock identifier definitions
1423 /* Note: On HP-UX, CLOCK_REALTIME is an enum, not a macro. */
1425 #if !(defined(CLOCK_REALTIME) || defined (__hpux__))
1426 # define CLOCK_REALTIME (-1)
1428 CND(CLOCK_REALTIME
, "System realtime clock")
1430 #ifdef CLOCK_MONOTONIC
1431 CND(CLOCK_MONOTONIC
, "System monotonic clock")
1434 #ifdef CLOCK_FASTEST
1435 CND(CLOCK_FASTEST
, "Fastest clock")
1438 #ifndef CLOCK_THREAD_CPUTIME_ID
1439 # define CLOCK_THREAD_CPUTIME_ID -1
1441 CND(CLOCK_THREAD_CPUTIME_ID
, "Thread CPU clock")
1443 #if defined(__FreeBSD__) || (defined(_AIX) && defined(_AIXVERSION_530)) \
1444 || defined(__DragonFly__)
1445 /** On these platforms use system provided monotonic clock instead of
1446 ** the default CLOCK_REALTIME. We then need to set up cond var attributes
1447 ** appropriately (see thread.c).
1449 ** Note that AIX 5.2 does not support CLOCK_MONOTONIC timestamps for
1450 ** pthread_cond_timedwait (and does not have pthread_condattr_setclock),
1451 ** hence the conditionalization on AIX version above). _AIXVERSION_530
1452 ** is defined in AIX 5.3 and more recent versions.
1454 # define CLOCK_RT_Ada "CLOCK_MONOTONIC"
1457 /* By default use CLOCK_REALTIME */
1458 # define CLOCK_RT_Ada "CLOCK_REALTIME"
1462 CNS(CLOCK_RT_Ada
, "")
1465 #if defined (__APPLE__) || defined (__linux__) || defined (__ANDROID__) \
1466 || defined (__rtems__) || defined (DUMMY)
1469 -- Sizes of pthread data types
1472 #if defined (__APPLE__) || defined (DUMMY)
1474 -- (on Darwin, these are just placeholders)
1476 #define PTHREAD_SIZE __PTHREAD_SIZE__
1477 #define PTHREAD_ATTR_SIZE __PTHREAD_ATTR_SIZE__
1478 #define PTHREAD_MUTEXATTR_SIZE __PTHREAD_MUTEXATTR_SIZE__
1479 #define PTHREAD_MUTEX_SIZE __PTHREAD_MUTEX_SIZE__
1480 #define PTHREAD_CONDATTR_SIZE __PTHREAD_CONDATTR_SIZE__
1481 #define PTHREAD_COND_SIZE __PTHREAD_COND_SIZE__
1482 #define PTHREAD_RWLOCKATTR_SIZE __PTHREAD_RWLOCKATTR_SIZE__
1483 #define PTHREAD_RWLOCK_SIZE __PTHREAD_RWLOCK_SIZE__
1484 #define PTHREAD_ONCE_SIZE __PTHREAD_ONCE_SIZE__
1486 #define PTHREAD_SIZE (sizeof (pthread_t))
1487 #define PTHREAD_ATTR_SIZE (sizeof (pthread_attr_t))
1488 #define PTHREAD_MUTEXATTR_SIZE (sizeof (pthread_mutexattr_t))
1489 #define PTHREAD_MUTEX_SIZE (sizeof (pthread_mutex_t))
1490 #define PTHREAD_CONDATTR_SIZE (sizeof (pthread_condattr_t))
1491 #define PTHREAD_COND_SIZE (sizeof (pthread_cond_t))
1492 #define PTHREAD_RWLOCKATTR_SIZE (sizeof (pthread_rwlockattr_t))
1493 #define PTHREAD_RWLOCK_SIZE (sizeof (pthread_rwlock_t))
1494 #define PTHREAD_ONCE_SIZE (sizeof (pthread_once_t))
1499 CND(PTHREAD_SIZE
, "pthread_t")
1500 CND(PTHREAD_ATTR_SIZE
, "pthread_attr_t")
1501 CND(PTHREAD_MUTEXATTR_SIZE
, "pthread_mutexattr_t")
1502 CND(PTHREAD_MUTEX_SIZE
, "pthread_mutex_t")
1503 CND(PTHREAD_CONDATTR_SIZE
, "pthread_condattr_t")
1504 CND(PTHREAD_COND_SIZE
, "pthread_cond_t")
1505 CND(PTHREAD_RWLOCKATTR_SIZE
, "pthread_rwlockattr_t")
1506 CND(PTHREAD_RWLOCK_SIZE
, "pthread_rwlock_t")
1507 CND(PTHREAD_ONCE_SIZE
, "pthread_once_t")
1509 #endif /* __APPLE__ || __linux__ || __ANDROID__ || __rtems__ */
1513 --------------------------------
1514 -- File and directory support --
1515 --------------------------------
1520 ** Note: this constant can be used in the GNAT runtime library. In compiler
1521 ** units on the other hand, System.OS_Constants is not available, so we
1522 ** declare an Ada constant (Osint.File_Attributes_Size) independently, which
1523 ** is at least as large as sizeof (struct file_attributes), and we have an
1524 ** assertion at initialization of Osint checking that the size is indeed at
1525 ** least sufficient.
1527 #define SIZEOF_struct_file_attributes (sizeof (struct file_attributes))
1528 CND(SIZEOF_struct_file_attributes
, "struct file_attributes")
1531 ** Maximal size of buffer for struct dirent. Note: Since POSIX.1 does not
1532 ** specify the size of the d_name field, and other nonstandard fields may
1533 ** precede that field within the dirent structure, we must make a conservative
1538 #define SIZEOF_struct_dirent_alloc \
1539 ((char*) &dent.d_name - (char*) &dent) + NAME_MAX + 1
1540 CND(SIZEOF_struct_dirent_alloc
, "struct dirent allocation")
1544 ** System-specific constants follow
1545 ** Each section should be activated if compiling for the corresponding
1546 ** platform *or* generating the dummy version for runtime test compilation.
1549 #if defined (__vxworks) || defined (DUMMY)
1553 --------------------------------
1554 -- VxWorks-specific constants --
1555 --------------------------------
1557 -- These constants may be used only within the VxWorks version of
1558 -- GNAT.Sockets.Thin.
1561 CND(OK
, "VxWorks generic success")
1562 CND(ERROR
, "VxWorks generic error")
1564 #endif /* __vxworks */
1566 #if defined (__MINGW32__) || defined (DUMMY)
1569 ------------------------------
1570 -- MinGW-specific constants --
1571 ------------------------------
1573 -- These constants may be used only within the MinGW version of
1574 -- GNAT.Sockets.Thin.
1577 CND(WSASYSNOTREADY
, "System not ready")
1578 CND(WSAVERNOTSUPPORTED
, "Version not supported")
1579 CND(WSANOTINITIALISED
, "Winsock not initialized")
1580 CND(WSAEDISCON
, "Disconnected")
1582 #endif /* __MINGW32__ */
1585 ** End of constants definitions
1594 end System.OS_Constants;