PR rtl-optimization/82913
[official-gcc.git] / gcc / ada / s-oscons-tmplt.c
blob95eadfc8854e55f8f11989eba4402bab0e99f9c5
1 /*
2 ------------------------------------------------------------------------------
3 -- --
4 -- GNAT COMPILER COMPONENTS --
5 -- --
6 -- S Y S T E M . O S _ C O N S T A N T S --
7 -- --
8 -- S p e c --
9 -- --
10 -- Copyright (C) 2000-2017, Free Software Foundation, Inc. --
11 -- --
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. --
18 -- --
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. --
22 -- --
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/>. --
27 -- --
28 -- GNAT was originally developed by the GNAT team at New York University. --
29 -- Extensive contributions were provided by Ada Core Technologies Inc. --
30 -- --
31 ------------------------------------------------------------------------------
33 pragma Style_Checks ("M32766");
34 -- Allow long lines
38 /**
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
55 ** when it applies.
57 ** Two methods are supported to generate the list of constant values,
58 ** s-oscons-tmpl.s.
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
62 ** listing:
64 ** xgcc -DTARGET=\"$target\" -C -E s-oscons-tmplt.c > s-oscons-tmplt.i
65 ** xgcc -S s-oscons-tmplt.i
66 ** xoscons
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
78 ** $ RUN xoscons
79 **/
81 /* Feature macro definitions */
83 /**
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.
87 **/
89 #if defined (__linux__) || defined (__ANDROID__)
91 /* Define _XOPEN_SOURCE to get IOV_MAX */
92 # if !defined (_XOPEN_SOURCE)
93 # define _XOPEN_SOURCE 500
94 # endif
96 /* Define _BSD_SOURCE to get CRTSCTS */
97 # define _BSD_SOURCE
99 #endif /* defined (__linux__) */
101 /* Include gsocket.h before any system header so it can redefine FD_SETSIZE */
103 #include "gsocket.h"
105 #include <stdlib.h>
106 #include <string.h>
107 #include <limits.h>
108 #include <fcntl.h>
109 #include <time.h>
111 #if ! (defined (__vxworks) || defined (__MINGW32__))
112 # define HAVE_TERMIOS
113 #endif
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>
124 #endif
126 #include "adaint.h"
128 #ifdef DUMMY
130 # if defined (TARGET)
131 # error TARGET may not be defined when generating the dummy version
132 # else
133 # define TARGET "batch runtime compilation (dummy values)"
134 # endif
136 # if !(defined (HAVE_SOCKETS) && defined (HAVE_TERMIOS))
137 # error Features missing on platform
138 # endif
140 # define NATIVE
142 #endif /* DUMMY */
144 #ifndef TARGET
145 # error Please define TARGET
146 #endif
148 #ifndef HAVE_SOCKETS
149 # include <errno.h>
150 #endif
152 #ifdef HAVE_TERMIOS
153 # include <termios.h>
154 #endif
156 #ifdef __APPLE__
157 # include <_types.h>
158 #endif
160 #if defined (__linux__) || defined (__ANDROID__) || defined (__QNX__) \
161 || defined (__rtems__)
162 # include <pthread.h>
163 # include <signal.h>
164 #endif
166 #if defined(__MINGW32__) || defined(__CYGWIN__)
167 # include <windef.h>
168 # include <winbase.h>
169 #endif
171 #ifdef NATIVE
172 #include <stdio.h>
174 #ifdef DUMMY
175 int counter = 0;
176 # define _VAL(x) counter++
177 #else
178 # define _VAL(x) x
179 #endif
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__);
193 #define SUB(sname)\
194 printf ("\n->SUB:$%d:" #sname ":" sname, __LINE__);
196 #define TXT(text) \
197 printf ("\n->TXT:$%d:" text, __LINE__);
199 #else
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 \
215 : : "i" (__LINE__));
216 /* General expression named number */
218 #define C(sname, type, value, comment) \
219 asm volatile("\n->C:%0:" sname ":" #type ":" value ":" comment \
220 : : "i" (__LINE__));
221 /* Typed constant */
223 #define SUB(sname) \
224 asm volatile("\n->SUB:%0:" #sname ":" sname \
225 : : "i" (__LINE__));
226 /* Subtype */
228 #define TXT(text) \
229 asm volatile("\n->TXT:%0:" text \
230 : : "i" (__LINE__));
231 /* Freeform text */
233 #endif /* NATIVE */
235 #define CST(name,comment) C(#name,String,name,comment)
236 /* String constant */
238 #define STR(x) STR1(x)
239 #define STR1(x) #x
241 #ifdef __MINGW32__
242 unsigned int _CRT_fmode = _O_BINARY;
243 #endif
246 main (void) {
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
259 ** MaRTE Makefile.
261 TXT("-- This is the version for " TARGET)
262 TXT("")
263 TXT("with Interfaces.C;")
266 package System.OS_Constants is
268 pragma Pure;
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"
285 #else
286 # define TARGET_OS "Other_OS"
287 #endif
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
297 CST(Target_Name, "")
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")
308 -------------------
309 -- System limits --
310 -------------------
314 #ifndef IOV_MAX
315 # define IOV_MAX INT_MAX
316 #endif
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.
325 #ifndef NAME_MAX
326 # ifdef MAXNAMELEN
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
335 # else
336 /* Hardcode a reasonably large value as a last chance fallback */
337 # define NAME_MAX 1024
338 # endif
339 #endif
340 CND(NAME_MAX, "Maximum file name length")
344 ---------------------
345 -- File open modes --
346 ---------------------
350 #ifndef O_RDWR
351 # define O_RDWR -1
352 #endif
353 CND(O_RDWR, "Read/write")
355 #ifndef O_NOCTTY
356 # define O_NOCTTY -1
357 #endif
358 CND(O_NOCTTY, "Don't change ctrl tty")
360 #ifndef O_NDELAY
361 # define O_NDELAY -1
362 #endif
363 CND(O_NDELAY, "Nonblocking")
367 ----------------------
368 -- Fcntl operations --
369 ----------------------
373 #ifndef F_GETFL
374 # define F_GETFL -1
375 #endif
376 CND(F_GETFL, "Get flags")
378 #ifndef F_SETFL
379 # define F_SETFL -1
380 #endif
381 CND(F_SETFL, "Set flags")
385 -----------------
386 -- Fcntl flags --
387 -----------------
391 #ifndef FNDELAY
392 # define FNDELAY -1
393 #endif
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__)
407 # define CNI CNU
408 # define IOCTL_Req_T "unsigned"
409 #else
410 # define CNI CND
411 # define IOCTL_Req_T "int"
412 #endif
414 SUB(IOCTL_Req_T)
416 #ifndef FIONBIO
417 # define FIONBIO -1
418 #endif
419 CNI(FIONBIO, "Set/clear non-blocking io")
421 #ifndef FIONREAD
422 # define FIONREAD -1
423 #endif
424 CNI(FIONREAD, "How many bytes to read")
428 ------------------
429 -- Errno values --
430 ------------------
432 -- The following constants are defined from <errno.h>
435 #ifndef EAGAIN
436 # define EAGAIN -1
437 #endif
438 CND(EAGAIN, "Try again")
440 #ifndef ENOENT
441 # define ENOENT -1
442 #endif
443 CND(ENOENT, "File not found")
445 #ifndef ENOMEM
446 # define ENOMEM -1
447 #endif
448 CND(ENOMEM, "Out of memory")
450 #ifdef __MINGW32__
453 -- The following constants are defined from <winsock2.h> (WSA*)
458 ** For sockets-related errno values on Windows, gsocket.h redefines
459 ** Exxx as WSAExxx.
462 #endif
464 #ifndef EACCES
465 # define EACCES -1
466 #endif
467 CND(EACCES, "Permission denied")
469 #ifndef EADDRINUSE
470 # define EADDRINUSE -1
471 #endif
472 CND(EADDRINUSE, "Address already in use")
474 #ifndef EADDRNOTAVAIL
475 # define EADDRNOTAVAIL -1
476 #endif
477 CND(EADDRNOTAVAIL, "Cannot assign address")
479 #ifndef EAFNOSUPPORT
480 # define EAFNOSUPPORT -1
481 #endif
482 CND(EAFNOSUPPORT, "Addr family not supported")
484 #ifndef EALREADY
485 # define EALREADY -1
486 #endif
487 CND(EALREADY, "Operation in progress")
489 #ifndef EBADF
490 # define EBADF -1
491 #endif
492 CND(EBADF, "Bad file descriptor")
494 #ifndef ECONNABORTED
495 # define ECONNABORTED -1
496 #endif
497 CND(ECONNABORTED, "Connection aborted")
499 #ifndef ECONNREFUSED
500 # define ECONNREFUSED -1
501 #endif
502 CND(ECONNREFUSED, "Connection refused")
504 #ifndef ECONNRESET
505 # define ECONNRESET -1
506 #endif
507 CND(ECONNRESET, "Connection reset by peer")
509 #ifndef EDESTADDRREQ
510 # define EDESTADDRREQ -1
511 #endif
512 CND(EDESTADDRREQ, "Destination addr required")
514 #ifndef EFAULT
515 # define EFAULT -1
516 #endif
517 CND(EFAULT, "Bad address")
519 #ifndef EHOSTDOWN
520 # define EHOSTDOWN -1
521 #endif
522 CND(EHOSTDOWN, "Host is down")
524 #ifndef EHOSTUNREACH
525 # define EHOSTUNREACH -1
526 #endif
527 CND(EHOSTUNREACH, "No route to host")
529 #ifndef EINPROGRESS
530 # define EINPROGRESS -1
531 #endif
532 CND(EINPROGRESS, "Operation now in progress")
534 #ifndef EINTR
535 # define EINTR -1
536 #endif
537 CND(EINTR, "Interrupted system call")
539 #ifndef EINVAL
540 # define EINVAL -1
541 #endif
542 CND(EINVAL, "Invalid argument")
544 #ifndef EIO
545 # define EIO -1
546 #endif
547 CND(EIO, "Input output error")
549 #ifndef EISCONN
550 # define EISCONN -1
551 #endif
552 CND(EISCONN, "Socket already connected")
554 #ifndef ELOOP
555 # define ELOOP -1
556 #endif
557 CND(ELOOP, "Too many symbolic links")
559 #ifndef EMFILE
560 # define EMFILE -1
561 #endif
562 CND(EMFILE, "Too many open files")
564 #ifndef EMSGSIZE
565 # define EMSGSIZE -1
566 #endif
567 CND(EMSGSIZE, "Message too long")
569 #ifndef ENAMETOOLONG
570 # define ENAMETOOLONG -1
571 #endif
572 CND(ENAMETOOLONG, "Name too long")
574 #ifndef ENETDOWN
575 # define ENETDOWN -1
576 #endif
577 CND(ENETDOWN, "Network is down")
579 #ifndef ENETRESET
580 # define ENETRESET -1
581 #endif
582 CND(ENETRESET, "Disconn. on network reset")
584 #ifndef ENETUNREACH
585 # define ENETUNREACH -1
586 #endif
587 CND(ENETUNREACH, "Network is unreachable")
589 #ifndef ENOBUFS
590 # define ENOBUFS -1
591 #endif
592 CND(ENOBUFS, "No buffer space available")
594 #ifndef ENOPROTOOPT
595 # define ENOPROTOOPT -1
596 #endif
597 CND(ENOPROTOOPT, "Protocol not available")
599 #ifndef ENOTCONN
600 # define ENOTCONN -1
601 #endif
602 CND(ENOTCONN, "Socket not connected")
604 #ifndef ENOTSOCK
605 # define ENOTSOCK -1
606 #endif
607 CND(ENOTSOCK, "Operation on non socket")
609 #ifndef EOPNOTSUPP
610 # define EOPNOTSUPP -1
611 #endif
612 CND(EOPNOTSUPP, "Operation not supported")
614 #ifndef EPIPE
615 # define EPIPE -1
616 #endif
617 CND(EPIPE, "Broken pipe")
619 #ifndef EPFNOSUPPORT
620 # define EPFNOSUPPORT -1
621 #endif
622 CND(EPFNOSUPPORT, "Unknown protocol family")
624 #ifndef EPROTONOSUPPORT
625 # define EPROTONOSUPPORT -1
626 #endif
627 CND(EPROTONOSUPPORT, "Unknown protocol")
629 #ifndef EPROTOTYPE
630 # define EPROTOTYPE -1
631 #endif
632 CND(EPROTOTYPE, "Unknown protocol type")
634 #ifndef ERANGE
635 # define ERANGE -1
636 #endif
637 CND(ERANGE, "Result too large")
639 #ifndef ESHUTDOWN
640 # define ESHUTDOWN -1
641 #endif
642 CND(ESHUTDOWN, "Cannot send once shutdown")
644 #ifndef ESOCKTNOSUPPORT
645 # define ESOCKTNOSUPPORT -1
646 #endif
647 CND(ESOCKTNOSUPPORT, "Socket type not supported")
649 #ifndef ETIMEDOUT
650 # define ETIMEDOUT -1
651 #endif
652 CND(ETIMEDOUT, "Connection timed out")
654 #ifndef ETOOMANYREFS
655 # define ETOOMANYREFS -1
656 #endif
657 CND(ETOOMANYREFS, "Too many references")
659 #ifndef EWOULDBLOCK
660 # define EWOULDBLOCK -1
661 #endif
662 CND(EWOULDBLOCK, "Operation would block")
664 #ifndef E2BIG
665 # define E2BIG -1
666 #endif
667 CND(E2BIG, "Argument list too long")
669 #ifndef EILSEQ
670 # define EILSEQ -1
671 #endif
672 CND(EILSEQ, "Illegal byte sequence")
675 ** Terminal/serial I/O constants
678 #if defined(HAVE_TERMIOS) || defined(__MINGW32__)
681 ----------------------
682 -- Terminal control --
683 ----------------------
686 #endif
688 #ifdef HAVE_TERMIOS
690 #ifndef TCSANOW
691 # define TCSANOW -1
692 #endif
693 CND(TCSANOW, "Immediate")
695 #ifndef TCIFLUSH
696 # define TCIFLUSH -1
697 #endif
698 CND(TCIFLUSH, "Flush input")
700 #ifndef IXON
701 # define IXON -1
702 #endif
703 CNU(IXON, "Output sw flow control")
705 #ifndef CLOCAL
706 # define CLOCAL -1
707 #endif
708 CNU(CLOCAL, "Local")
710 #ifndef CRTSCTS
711 # define CRTSCTS -1
712 #endif
713 CNU(CRTSCTS, "Output hw flow control")
715 #ifndef CREAD
716 # define CREAD -1
717 #endif
718 CNU(CREAD, "Read")
720 #ifndef CS5
721 # define CS5 -1
722 #endif
723 CNU(CS5, "5 data bits")
725 #ifndef CS6
726 # define CS6 -1
727 #endif
728 CNU(CS6, "6 data bits")
730 #ifndef CS7
731 # define CS7 -1
732 #endif
733 CNU(CS7, "7 data bits")
735 #ifndef CS8
736 # define CS8 -1
737 #endif
738 CNU(CS8, "8 data bits")
740 #ifndef CSTOPB
741 # define CSTOPB -1
742 #endif
743 CNU(CSTOPB, "2 stop bits")
745 #ifndef PARENB
746 # define PARENB -1
747 #endif
748 CNU(PARENB, "Parity enable")
750 #ifndef PARODD
751 # define PARODD -1
752 #endif
753 CNU(PARODD, "Parity odd")
755 #ifndef B0
756 # define B0 -1
757 #endif
758 CNU(B0, "0 bps")
760 #ifndef B50
761 # define B50 -1
762 #endif
763 CNU(B50, "50 bps")
765 #ifndef B75
766 # define B75 -1
767 #endif
768 CNU(B75, "75 bps")
770 #ifndef B110
771 # define B110 -1
772 #endif
773 CNU(B110, "110 bps")
775 #ifndef B134
776 # define B134 -1
777 #endif
778 CNU(B134, "134 bps")
780 #ifndef B150
781 # define B150 -1
782 #endif
783 CNU(B150, "150 bps")
785 #ifndef B200
786 # define B200 -1
787 #endif
788 CNU(B200, "200 bps")
790 #ifndef B300
791 # define B300 -1
792 #endif
793 CNU(B300, "300 bps")
795 #ifndef B600
796 # define B600 -1
797 #endif
798 CNU(B600, "600 bps")
800 #ifndef B1200
801 # define B1200 -1
802 #endif
803 CNU(B1200, "1200 bps")
805 #ifndef B1800
806 # define B1800 -1
807 #endif
808 CNU(B1800, "1800 bps")
810 #ifndef B2400
811 # define B2400 -1
812 #endif
813 CNU(B2400, "2400 bps")
815 #ifndef B4800
816 # define B4800 -1
817 #endif
818 CNU(B4800, "4800 bps")
820 #ifndef B9600
821 # define B9600 -1
822 #endif
823 CNU(B9600, "9600 bps")
825 #ifndef B19200
826 # define B19200 -1
827 #endif
828 CNU(B19200, "19200 bps")
830 #ifndef B38400
831 # define B38400 -1
832 #endif
833 CNU(B38400, "38400 bps")
835 #ifndef B57600
836 # define B57600 -1
837 #endif
838 CNU(B57600, "57600 bps")
840 #ifndef B115200
841 # define B115200 -1
842 #endif
843 CNU(B115200, "115200 bps")
845 #ifndef B230400
846 # define B230400 -1
847 #endif
848 CNU(B230400, "230400 bps")
850 #ifndef B460800
851 # define B460800 -1
852 #endif
853 CNU(B460800, "460800 bps")
855 #ifndef B500000
856 # define B500000 -1
857 #endif
858 CNU(B500000, "500000 bps")
860 #ifndef B576000
861 # define B576000 -1
862 #endif
863 CNU(B576000, "576000 bps")
865 #ifndef B921600
866 # define B921600 -1
867 #endif
868 CNU(B921600, "921600 bps")
870 #ifndef B1000000
871 # define B1000000 -1
872 #endif
873 CNU(B1000000, "1000000 bps")
875 #ifndef B1152000
876 # define B1152000 -1
877 #endif
878 CNU(B1152000, "1152000 bps")
880 #ifndef B1500000
881 # define B1500000 -1
882 #endif
883 CNU(B1500000, "1500000 bps")
885 #ifndef B2000000
886 # define B2000000 -1
887 #endif
888 CNU(B2000000, "2000000 bps")
890 #ifndef B2500000
891 # define B2500000 -1
892 #endif
893 CNU(B2500000, "2500000 bps")
895 #ifndef B3000000
896 # define B3000000 -1
897 #endif
898 CNU(B3000000, "3000000 bps")
900 #ifndef B3500000
901 # define B3500000 -1
902 #endif
903 CNU(B3500000, "3500000 bps")
905 #ifndef B4000000
906 # define B4000000 -1
907 #endif
908 CNU(B4000000, "4000000 bps")
912 ---------------------------------
913 -- Terminal control characters --
914 ---------------------------------
918 #ifndef VINTR
919 # define VINTR -1
920 #endif
921 CND(VINTR, "Interrupt")
923 #ifndef VQUIT
924 # define VQUIT -1
925 #endif
926 CND(VQUIT, "Quit")
928 #ifndef VERASE
929 # define VERASE -1
930 #endif
931 CND(VERASE, "Erase")
933 #ifndef VKILL
934 # define VKILL -1
935 #endif
936 CND(VKILL, "Kill")
938 #ifndef VEOF
939 # define VEOF -1
940 #endif
941 CND(VEOF, "EOF")
943 #ifndef VTIME
944 # define VTIME -1
945 #endif
946 CND(VTIME, "Read timeout")
948 #ifndef VMIN
949 # define VMIN -1
950 #endif
951 CND(VMIN, "Read min chars")
953 #ifndef VSWTC
954 # define VSWTC -1
955 #endif
956 CND(VSWTC, "Switch")
958 #ifndef VSTART
959 # define VSTART -1
960 #endif
961 CND(VSTART, "Flow control start")
963 #ifndef VSTOP
964 # define VSTOP -1
965 #endif
966 CND(VSTOP, "Flow control stop")
968 #ifndef VSUSP
969 # define VSUSP -1
970 #endif
971 CND(VSUSP, "Suspend")
973 #ifndef VEOL
974 # define VEOL -1
975 #endif
976 CND(VEOL, "EOL")
978 #ifndef VREPRINT
979 # define VREPRINT -1
980 #endif
981 CND(VREPRINT, "Reprint unread")
983 #ifndef VDISCARD
984 # define VDISCARD -1
985 #endif
986 CND(VDISCARD, "Discard pending")
988 #ifndef VWERASE
989 # define VWERASE -1
990 #endif
991 CND(VWERASE, "Word erase")
993 #ifndef VLNEXT
994 # define VLNEXT -1
995 #endif
996 CND(VLNEXT, "Literal next")
998 #ifndef VEOL2
999 # define VEOL2 -1
1000 #endif
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")
1008 #endif
1012 -----------------------------
1013 -- Pseudo terminal library --
1014 -----------------------------
1018 #if defined (__FreeBSD__) || defined (__linux__) || defined (__DragonFly__)
1019 # define PTY_Library "-lutil"
1020 #else
1021 # define PTY_Library ""
1022 #endif
1023 CST(PTY_Library, "for g-exptty")
1026 ** Sockets constants
1029 #ifdef HAVE_SOCKETS
1033 --------------
1034 -- Families --
1035 --------------
1039 #ifndef AF_INET
1040 # define AF_INET -1
1041 #endif
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__)
1049 # undef AF_INET6
1050 #endif
1052 #ifndef AF_INET6
1053 # define AF_INET6 -1
1054 #else
1055 # define HAVE_AF_INET6 1
1056 #endif
1057 CND(AF_INET6, "IPv6 address family")
1061 ------------------
1062 -- Socket modes --
1063 ------------------
1067 #ifndef SOCK_STREAM
1068 # define SOCK_STREAM -1
1069 #endif
1070 CND(SOCK_STREAM, "Stream socket")
1072 #ifndef SOCK_DGRAM
1073 # define SOCK_DGRAM -1
1074 #endif
1075 CND(SOCK_DGRAM, "Datagram socket")
1079 -----------------
1080 -- Host errors --
1081 -----------------
1085 #ifndef HOST_NOT_FOUND
1086 # define HOST_NOT_FOUND -1
1087 #endif
1088 CND(HOST_NOT_FOUND, "Unknown host")
1090 #ifndef TRY_AGAIN
1091 # define TRY_AGAIN -1
1092 #endif
1093 CND(TRY_AGAIN, "Host name lookup failure")
1095 #ifndef NO_DATA
1096 # define NO_DATA -1
1097 #endif
1098 CND(NO_DATA, "No data record for name")
1100 #ifndef NO_RECOVERY
1101 # define NO_RECOVERY -1
1102 #endif
1103 CND(NO_RECOVERY, "Non recoverable errors")
1107 --------------------
1108 -- Shutdown modes --
1109 --------------------
1113 #ifndef SHUT_RD
1114 # define SHUT_RD -1
1115 #endif
1116 CND(SHUT_RD, "No more recv")
1118 #ifndef SHUT_WR
1119 # define SHUT_WR -1
1120 #endif
1121 CND(SHUT_WR, "No more send")
1123 #ifndef SHUT_RDWR
1124 # define SHUT_RDWR -1
1125 #endif
1126 CND(SHUT_RDWR, "No more recv/send")
1130 ---------------------
1131 -- Protocol levels --
1132 ---------------------
1136 #ifndef SOL_SOCKET
1137 # define SOL_SOCKET -1
1138 #endif
1139 CND(SOL_SOCKET, "Options for socket level")
1141 #ifndef IPPROTO_IP
1142 # define IPPROTO_IP -1
1143 #endif
1144 CND(IPPROTO_IP, "Dummy protocol for IP")
1146 #ifndef IPPROTO_UDP
1147 # define IPPROTO_UDP -1
1148 #endif
1149 CND(IPPROTO_UDP, "UDP")
1151 #ifndef IPPROTO_TCP
1152 # define IPPROTO_TCP -1
1153 #endif
1154 CND(IPPROTO_TCP, "TCP")
1158 -------------------
1159 -- Request flags --
1160 -------------------
1164 #ifndef MSG_OOB
1165 # define MSG_OOB -1
1166 #endif
1167 CND(MSG_OOB, "Process out-of-band data")
1169 #ifndef MSG_PEEK
1170 # define MSG_PEEK -1
1171 #endif
1172 CND(MSG_PEEK, "Peek at incoming data")
1174 #ifndef MSG_EOR
1175 # define MSG_EOR -1
1176 #endif
1177 CND(MSG_EOR, "Send end of record")
1179 #ifndef MSG_WAITALL
1180 #ifdef __MINWGW32__
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)
1184 #else
1185 # define MSG_WAITALL -1
1186 #endif
1187 #endif
1188 CND(MSG_WAITALL, "Wait for full reception")
1190 #ifndef MSG_NOSIGNAL
1191 # define MSG_NOSIGNAL -1
1192 #endif
1193 CND(MSG_NOSIGNAL, "No SIGPIPE on send")
1195 #if defined (__linux__) || defined (__ANDROID__) || defined (__QNX__)
1196 # define MSG_Forced_Flags "MSG_NOSIGNAL"
1197 #else
1198 # define MSG_Forced_Flags "0"
1199 #endif
1200 CNS(MSG_Forced_Flags, "")
1202 -- Flags set on all send(2) calls
1207 --------------------
1208 -- Socket options --
1209 --------------------
1213 #ifndef TCP_NODELAY
1214 # define TCP_NODELAY -1
1215 #endif
1216 CND(TCP_NODELAY, "Do not coalesce packets")
1218 #ifndef SO_REUSEADDR
1219 # define SO_REUSEADDR -1
1220 #endif
1221 CND(SO_REUSEADDR, "Bind reuse local address")
1223 #ifndef SO_REUSEPORT
1224 # define SO_REUSEPORT -1
1225 #endif
1226 CND(SO_REUSEPORT, "Bind reuse port number")
1228 #ifndef SO_KEEPALIVE
1229 # define SO_KEEPALIVE -1
1230 #endif
1231 CND(SO_KEEPALIVE, "Enable keep-alive msgs")
1233 #ifndef SO_LINGER
1234 # define SO_LINGER -1
1235 #endif
1236 CND(SO_LINGER, "Defer close to flush data")
1238 #ifndef SO_BROADCAST
1239 # define SO_BROADCAST -1
1240 #endif
1241 CND(SO_BROADCAST, "Can send broadcast msgs")
1243 #ifndef SO_SNDBUF
1244 # define SO_SNDBUF -1
1245 #endif
1246 CND(SO_SNDBUF, "Set/get send buffer size")
1248 #ifndef SO_RCVBUF
1249 # define SO_RCVBUF -1
1250 #endif
1251 CND(SO_RCVBUF, "Set/get recv buffer size")
1253 #ifndef SO_SNDTIMEO
1254 # define SO_SNDTIMEO -1
1255 #endif
1256 CND(SO_SNDTIMEO, "Emission timeout")
1258 #ifndef SO_RCVTIMEO
1259 # define SO_RCVTIMEO -1
1260 #endif
1261 CND(SO_RCVTIMEO, "Reception timeout")
1263 #ifndef SO_ERROR
1264 # define SO_ERROR -1
1265 #endif
1266 CND(SO_ERROR, "Get/clear error status")
1268 #ifndef SO_BUSY_POLL
1269 # define SO_BUSY_POLL -1
1270 #endif
1271 CND(SO_BUSY_POLL, "Busy polling")
1273 #ifndef IP_MULTICAST_IF
1274 # define IP_MULTICAST_IF -1
1275 #endif
1276 CND(IP_MULTICAST_IF, "Set/get mcast interface")
1278 #ifndef IP_MULTICAST_TTL
1279 # define IP_MULTICAST_TTL -1
1280 #endif
1281 CND(IP_MULTICAST_TTL, "Set/get multicast TTL")
1283 #ifndef IP_MULTICAST_LOOP
1284 # define IP_MULTICAST_LOOP -1
1285 #endif
1286 CND(IP_MULTICAST_LOOP, "Set/get mcast loopback")
1288 #ifndef IP_ADD_MEMBERSHIP
1289 # define IP_ADD_MEMBERSHIP -1
1290 #endif
1291 CND(IP_ADD_MEMBERSHIP, "Join a multicast group")
1293 #ifndef IP_DROP_MEMBERSHIP
1294 # define IP_DROP_MEMBERSHIP -1
1295 #endif
1296 CND(IP_DROP_MEMBERSHIP, "Leave a multicast group")
1298 #ifndef IP_PKTINFO
1299 # define IP_PKTINFO -1
1300 #endif
1301 CND(IP_PKTINFO, "Get datagram info")
1305 ----------------------
1306 -- Type definitions --
1307 ----------------------
1312 struct timeval tv;
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#"
1336 #else
1337 # define MAX_tv_sec "2 ** (SIZEOF_tv_sec * 8 - 1) - 1"
1338 #endif
1339 CNS(MAX_tv_sec, "")
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))
1350 #else
1351 # define SIZEOF_sockaddr_in6 0
1352 #endif
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")
1368 #endif
1372 -- Fields of struct msghdr
1375 #if defined (__sun__) || defined (__hpux__)
1376 # define Msg_Iovlen_T "int"
1377 #else
1378 # define Msg_Iovlen_T "size_t"
1379 #endif
1381 SUB(Msg_Iovlen_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
1397 ** MaRTE Makefile.
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"
1407 #else
1408 # define Inet_Pton_Linkname "__gnat_inet_pton"
1409 #endif
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)
1428 #endif
1429 CND(CLOCK_REALTIME, "System realtime clock")
1431 #ifdef CLOCK_MONOTONIC
1432 CND(CLOCK_MONOTONIC, "System monotonic clock")
1433 #endif
1435 #ifdef CLOCK_FASTEST
1436 CND(CLOCK_FASTEST, "Fastest clock")
1437 #endif
1439 #ifndef CLOCK_THREAD_CPUTIME_ID
1440 # define CLOCK_THREAD_CPUTIME_ID -1
1441 #endif
1442 CND(CLOCK_THREAD_CPUTIME_ID, "Thread CPU clock")
1444 #if defined(__linux__) || defined(__FreeBSD__) \
1445 || (defined(_AIX) && defined(_AIXVERSION_530)) \
1446 || defined(__DragonFly__)
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"
1458 #else
1459 /* By default use CLOCK_REALTIME */
1460 # define CLOCK_RT_Ada "CLOCK_REALTIME"
1461 #endif
1463 #ifdef CLOCK_RT_Ada
1464 CNS(CLOCK_RT_Ada, "")
1465 #endif
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__
1487 #else
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))
1497 #endif
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
1536 ** computation.
1539 struct dirent dent;
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
1590 #ifdef NATIVE
1591 putchar ('\n');
1592 #endif
1596 end System.OS_Constants;