2014-12-12 Marc Glisse <marc.glisse@inria.fr>
[official-gcc.git] / gcc / ada / s-oscons-tmplt.c
blobde2b9b988bf2b8784cd350319e50ac73fac88dd1
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-2014, 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__)
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 (__VMS)
112 /** VMS is unable to do vector IO operations with default value of IOV_MAX,
113 ** so its value is redefined to a small one which is known to work properly.
115 #undef IOV_MAX
116 #define IOV_MAX 16
117 #endif
119 #if ! (defined (__vxworks) || defined (__VMS) || defined (__MINGW32__) || \
120 defined (__nucleus__))
121 # define HAVE_TERMIOS
122 #endif
124 #if defined (__vxworks)
127 ** For VxWorks, always include vxWorks.h (gsocket.h provides it only for
128 ** the case of runtime libraries that support sockets). Note: this must
129 ** be done before including adaint.h.
132 # include <vxWorks.h>
133 #endif
135 #include "adaint.h"
137 #ifdef DUMMY
139 # if defined (TARGET)
140 # error TARGET may not be defined when generating the dummy version
141 # else
142 # define TARGET "batch runtime compilation (dummy values)"
143 # endif
145 # if !(defined (HAVE_SOCKETS) && defined (HAVE_TERMIOS))
146 # error Features missing on platform
147 # endif
149 # define NATIVE
151 #endif /* DUMMY */
153 #ifndef TARGET
154 # error Please define TARGET
155 #endif
157 #ifndef HAVE_SOCKETS
158 # include <errno.h>
159 #endif
161 #ifdef HAVE_TERMIOS
162 # include <termios.h>
163 #endif
165 #ifdef __APPLE__
166 # include <_types.h>
167 #endif
169 #ifdef __linux__
170 # include <pthread.h>
171 # include <signal.h>
172 #endif
174 #if defined(__MINGW32__) || defined(__CYGWIN__)
175 # include <windef.h>
176 # include <winbase.h>
177 #endif
179 #ifdef NATIVE
180 #include <stdio.h>
182 #ifdef DUMMY
183 int counter = 0;
184 # define _VAL(x) counter++
185 #else
186 # define _VAL(x) x
187 #endif
189 #define CND(name,comment) \
190 printf ("\n->CND:$%d:" #name ":$%d:" comment, __LINE__, ((int) _VAL (name)));
192 #define CNU(name,comment) \
193 printf ("\n->CNU:$%d:" #name ":$%u:" comment, __LINE__, ((unsigned int) _VAL (name)));
195 #define CNS(name,comment) \
196 printf ("\n->CNS:$%d:" #name ":" name ":" comment, __LINE__);
198 #define C(sname,type,value,comment)\
199 printf ("\n->C:$%d:" sname ":" #type ":" value ":" comment, __LINE__);
201 #define SUB(sname)\
202 printf ("\n->SUB:$%d:" #sname ":" sname, __LINE__);
204 #define TXT(text) \
205 printf ("\n->TXT:$%d:" text, __LINE__);
207 #else
209 #define CND(name, comment) \
210 asm volatile("\n->CND:%0:" #name ":%1:" comment \
211 : : "i" (__LINE__), "i" ((int) name));
212 /* Decimal constant in the range of type "int" */
214 #define CNU(name, comment) \
215 asm volatile("\n->CNU:%0:" #name ":%1:" comment \
216 : : "i" (__LINE__), "i" ((int) name));
217 /* Decimal constant in the range of type "unsigned int" (note, assembler
218 * always wants a signed int, we convert back in xoscons).
221 #define CNS(name, comment) \
222 asm volatile("\n->CNS:%0:" #name ":" name ":" comment \
223 : : "i" (__LINE__));
224 /* General expression named number */
226 #define C(sname, type, value, comment) \
227 asm volatile("\n->C:%0:" sname ":" #type ":" value ":" comment \
228 : : "i" (__LINE__));
229 /* Typed constant */
231 #define SUB(sname) \
232 asm volatile("\n->SUB:%0:" #sname ":" sname \
233 : : "i" (__LINE__));
234 /* Subtype */
236 #define TXT(text) \
237 asm volatile("\n->TXT:%0:" text \
238 : : "i" (__LINE__));
239 /* Freeform text */
241 #endif /* NATIVE */
243 #define CST(name,comment) C(#name,String,name,comment)
244 /* String constant */
246 #define STR(x) STR1(x)
247 #define STR1(x) #x
249 #ifdef __MINGW32__
250 unsigned int _CRT_fmode = _O_BINARY;
251 #endif
254 main (void) {
257 -- This package provides target dependent definitions of constant for use
258 -- by the GNAT runtime library. This package should not be directly with'd
259 -- by an application program.
261 -- This file is generated automatically, do not modify it by hand! Instead,
262 -- make changes to s-oscons-tmplt.c and rebuild the GNAT runtime library.
266 ** Do not change the format of the line below without also updating the
267 ** MaRTE Makefile.
269 TXT("-- This is the version for " TARGET)
270 TXT("")
271 TXT("with Interfaces.C;")
274 package System.OS_Constants is
276 pragma Pure;
280 ** General constants (all platforms)
285 ---------------------------------
286 -- General platform parameters --
287 ---------------------------------
289 type OS_Type is (Windows, VMS, Other_OS);
291 #if defined (__MINGW32__)
292 # define TARGET_OS "Windows"
293 #elif defined (__VMS)
294 # define TARGET_OS "VMS"
295 #else
296 # define TARGET_OS "Other_OS"
297 #endif
298 C("Target_OS", OS_Type, TARGET_OS, "")
300 pragma Warnings (Off, Target_OS);
301 -- Suppress warnings on Target_OS since it is in general tested for
302 -- equality with a constant value to implement conditional compilation,
303 -- which normally generates a constant condition warning.
306 #define Target_Name TARGET
307 CST(Target_Name, "")
310 ** Note: the name of the following constant is recognized specially by
311 ** xoscons (case sensitive).
313 #define SIZEOF_unsigned_int sizeof (unsigned int)
314 CND(SIZEOF_unsigned_int, "Size of unsigned int")
318 -------------------
319 -- System limits --
320 -------------------
324 #ifndef IOV_MAX
325 # define IOV_MAX INT_MAX
326 #endif
327 CND(IOV_MAX, "Maximum writev iovcnt")
329 /* NAME_MAX is used to compute the allocation size for a struct dirent
330 * passed to readdir() / readdir_r(). However on some systems it is not
331 * defined, as it is technically a filesystem dependent property that
332 * we should retrieve through pathconf(). In any case, we do not need a
333 * precise value but only an upper limit.
335 #ifndef NAME_MAX
336 # ifdef MAXNAMELEN
337 /* Solaris has no NAME_MAX but defines MAXNAMELEN */
338 # define NAME_MAX MAXNAMELEN
339 # elif defined(PATH_MAX)
340 /* PATH_MAX (maximum length of a full path name) is a safe fall back */
341 # define NAME_MAX PATH_MAX
342 # elif defined(FILENAME_MAX)
343 /* Similarly FILENAME_MAX can provide a safe fall back */
344 # define NAME_MAX FILENAME_MAX
345 # else
346 /* Hardcode a reasonably large value as a last chance fallback */
347 # define NAME_MAX 1024
348 # endif
349 #endif
350 CND(NAME_MAX, "Maximum file name length")
354 ---------------------
355 -- File open modes --
356 ---------------------
360 #ifndef O_RDWR
361 # define O_RDWR -1
362 #endif
363 CND(O_RDWR, "Read/write")
365 #ifndef O_NOCTTY
366 # define O_NOCTTY -1
367 #endif
368 CND(O_NOCTTY, "Don't change ctrl tty")
370 #ifndef O_NDELAY
371 # define O_NDELAY -1
372 #endif
373 CND(O_NDELAY, "Nonblocking")
377 ----------------------
378 -- Fcntl operations --
379 ----------------------
383 #ifndef F_GETFL
384 # define F_GETFL -1
385 #endif
386 CND(F_GETFL, "Get flags")
388 #ifndef F_SETFL
389 # define F_SETFL -1
390 #endif
391 CND(F_SETFL, "Set flags")
395 -----------------
396 -- Fcntl flags --
397 -----------------
401 #ifndef FNDELAY
402 # define FNDELAY -1
403 #endif
404 CND(FNDELAY, "Nonblocking")
408 ----------------------
409 -- Ioctl operations --
410 ----------------------
414 /* ioctl(2) requests are "int" in UNIX, but "unsigned long" on FreeBSD */
416 #ifdef __FreeBSD__
417 # define CNI CNU
418 # define IOCTL_Req_T "unsigned"
419 #else
420 # define CNI CND
421 # define IOCTL_Req_T "int"
422 #endif
424 SUB(IOCTL_Req_T)
426 #ifndef FIONBIO
427 # define FIONBIO -1
428 #endif
429 CNI(FIONBIO, "Set/clear non-blocking io")
431 #ifndef FIONREAD
432 # define FIONREAD -1
433 #endif
434 CNI(FIONREAD, "How many bytes to read")
438 ------------------
439 -- Errno values --
440 ------------------
442 -- The following constants are defined from <errno.h>
445 #ifndef EAGAIN
446 # define EAGAIN -1
447 #endif
448 CND(EAGAIN, "Try again")
450 #ifndef ENOENT
451 # define ENOENT -1
452 #endif
453 CND(ENOENT, "File not found")
455 #ifndef ENOMEM
456 # define ENOMEM -1
457 #endif
458 CND(ENOMEM, "Out of memory")
460 #ifdef __MINGW32__
463 -- The following constants are defined from <winsock2.h> (WSA*)
468 ** For sockets-related errno values on Windows, gsocket.h redefines
469 ** Exxx as WSAExxx.
472 #endif
474 #ifndef EACCES
475 # define EACCES -1
476 #endif
477 CND(EACCES, "Permission denied")
479 #ifndef EADDRINUSE
480 # define EADDRINUSE -1
481 #endif
482 CND(EADDRINUSE, "Address already in use")
484 #ifndef EADDRNOTAVAIL
485 # define EADDRNOTAVAIL -1
486 #endif
487 CND(EADDRNOTAVAIL, "Cannot assign address")
489 #ifndef EAFNOSUPPORT
490 # define EAFNOSUPPORT -1
491 #endif
492 CND(EAFNOSUPPORT, "Addr family not supported")
494 #ifndef EALREADY
495 # define EALREADY -1
496 #endif
497 CND(EALREADY, "Operation in progress")
499 #ifndef EBADF
500 # define EBADF -1
501 #endif
502 CND(EBADF, "Bad file descriptor")
504 #ifndef ECONNABORTED
505 # define ECONNABORTED -1
506 #endif
507 CND(ECONNABORTED, "Connection aborted")
509 #ifndef ECONNREFUSED
510 # define ECONNREFUSED -1
511 #endif
512 CND(ECONNREFUSED, "Connection refused")
514 #ifndef ECONNRESET
515 # define ECONNRESET -1
516 #endif
517 CND(ECONNRESET, "Connection reset by peer")
519 #ifndef EDESTADDRREQ
520 # define EDESTADDRREQ -1
521 #endif
522 CND(EDESTADDRREQ, "Destination addr required")
524 #ifndef EFAULT
525 # define EFAULT -1
526 #endif
527 CND(EFAULT, "Bad address")
529 #ifndef EHOSTDOWN
530 # define EHOSTDOWN -1
531 #endif
532 CND(EHOSTDOWN, "Host is down")
534 #ifndef EHOSTUNREACH
535 # define EHOSTUNREACH -1
536 #endif
537 CND(EHOSTUNREACH, "No route to host")
539 #ifndef EINPROGRESS
540 # define EINPROGRESS -1
541 #endif
542 CND(EINPROGRESS, "Operation now in progress")
544 #ifndef EINTR
545 # define EINTR -1
546 #endif
547 CND(EINTR, "Interrupted system call")
549 #ifndef EINVAL
550 # define EINVAL -1
551 #endif
552 CND(EINVAL, "Invalid argument")
554 #ifndef EIO
555 # define EIO -1
556 #endif
557 CND(EIO, "Input output error")
559 #ifndef EISCONN
560 # define EISCONN -1
561 #endif
562 CND(EISCONN, "Socket already connected")
564 #ifndef ELOOP
565 # define ELOOP -1
566 #endif
567 CND(ELOOP, "Too many symbolic links")
569 #ifndef EMFILE
570 # define EMFILE -1
571 #endif
572 CND(EMFILE, "Too many open files")
574 #ifndef EMSGSIZE
575 # define EMSGSIZE -1
576 #endif
577 CND(EMSGSIZE, "Message too long")
579 #ifndef ENAMETOOLONG
580 # define ENAMETOOLONG -1
581 #endif
582 CND(ENAMETOOLONG, "Name too long")
584 #ifndef ENETDOWN
585 # define ENETDOWN -1
586 #endif
587 CND(ENETDOWN, "Network is down")
589 #ifndef ENETRESET
590 # define ENETRESET -1
591 #endif
592 CND(ENETRESET, "Disconn. on network reset")
594 #ifndef ENETUNREACH
595 # define ENETUNREACH -1
596 #endif
597 CND(ENETUNREACH, "Network is unreachable")
599 #ifndef ENOBUFS
600 # define ENOBUFS -1
601 #endif
602 CND(ENOBUFS, "No buffer space available")
604 #ifndef ENOPROTOOPT
605 # define ENOPROTOOPT -1
606 #endif
607 CND(ENOPROTOOPT, "Protocol not available")
609 #ifndef ENOTCONN
610 # define ENOTCONN -1
611 #endif
612 CND(ENOTCONN, "Socket not connected")
614 #ifndef ENOTSOCK
615 # define ENOTSOCK -1
616 #endif
617 CND(ENOTSOCK, "Operation on non socket")
619 #ifndef EOPNOTSUPP
620 # define EOPNOTSUPP -1
621 #endif
622 CND(EOPNOTSUPP, "Operation not supported")
624 #ifndef EPIPE
625 # define EPIPE -1
626 #endif
627 CND(EPIPE, "Broken pipe")
629 #ifndef EPFNOSUPPORT
630 # define EPFNOSUPPORT -1
631 #endif
632 CND(EPFNOSUPPORT, "Unknown protocol family")
634 #ifndef EPROTONOSUPPORT
635 # define EPROTONOSUPPORT -1
636 #endif
637 CND(EPROTONOSUPPORT, "Unknown protocol")
639 #ifndef EPROTOTYPE
640 # define EPROTOTYPE -1
641 #endif
642 CND(EPROTOTYPE, "Unknown protocol type")
644 #ifndef ERANGE
645 # define ERANGE -1
646 #endif
647 CND(ERANGE, "Result too large")
649 #ifndef ESHUTDOWN
650 # define ESHUTDOWN -1
651 #endif
652 CND(ESHUTDOWN, "Cannot send once shutdown")
654 #ifndef ESOCKTNOSUPPORT
655 # define ESOCKTNOSUPPORT -1
656 #endif
657 CND(ESOCKTNOSUPPORT, "Socket type not supported")
659 #ifndef ETIMEDOUT
660 # define ETIMEDOUT -1
661 #endif
662 CND(ETIMEDOUT, "Connection timed out")
664 #ifndef ETOOMANYREFS
665 # define ETOOMANYREFS -1
666 #endif
667 CND(ETOOMANYREFS, "Too many references")
669 #ifndef EWOULDBLOCK
670 # define EWOULDBLOCK -1
671 #endif
672 CND(EWOULDBLOCK, "Operation would block")
674 #ifndef E2BIG
675 # define E2BIG -1
676 #endif
677 CND(E2BIG, "Argument list too long")
679 #ifndef EILSEQ
680 # define EILSEQ -1
681 #endif
682 CND(EILSEQ, "Illegal byte sequence")
685 ** Terminal/serial I/O constants
688 #if defined(HAVE_TERMIOS) || defined(__MINGW32__)
691 ----------------------
692 -- Terminal control --
693 ----------------------
696 #endif
698 #ifdef HAVE_TERMIOS
700 #ifndef TCSANOW
701 # define TCSANOW -1
702 #endif
703 CND(TCSANOW, "Immediate")
705 #ifndef TCIFLUSH
706 # define TCIFLUSH -1
707 #endif
708 CND(TCIFLUSH, "Flush input")
710 #ifndef IXON
711 # define IXON -1
712 #endif
713 CNU(IXON, "Output sw flow control")
715 #ifndef CLOCAL
716 # define CLOCAL -1
717 #endif
718 CNU(CLOCAL, "Local")
720 #ifndef CRTSCTS
721 # define CRTSCTS -1
722 #endif
723 CNU(CRTSCTS, "Output hw flow control")
725 #ifndef CREAD
726 # define CREAD -1
727 #endif
728 CNU(CREAD, "Read")
730 #ifndef CS5
731 # define CS5 -1
732 #endif
733 CNU(CS5, "5 data bits")
735 #ifndef CS6
736 # define CS6 -1
737 #endif
738 CNU(CS6, "6 data bits")
740 #ifndef CS7
741 # define CS7 -1
742 #endif
743 CNU(CS7, "7 data bits")
745 #ifndef CS8
746 # define CS8 -1
747 #endif
748 CNU(CS8, "8 data bits")
750 #ifndef CSTOPB
751 # define CSTOPB -1
752 #endif
753 CNU(CSTOPB, "2 stop bits")
755 #ifndef PARENB
756 # define PARENB -1
757 #endif
758 CNU(PARENB, "Parity enable")
760 #ifndef PARODD
761 # define PARODD -1
762 #endif
763 CNU(PARODD, "Parity odd")
765 #ifndef B0
766 # define B0 -1
767 #endif
768 CNU(B0, "0 bps")
770 #ifndef B50
771 # define B50 -1
772 #endif
773 CNU(B50, "50 bps")
775 #ifndef B75
776 # define B75 -1
777 #endif
778 CNU(B75, "75 bps")
780 #ifndef B110
781 # define B110 -1
782 #endif
783 CNU(B110, "110 bps")
785 #ifndef B134
786 # define B134 -1
787 #endif
788 CNU(B134, "134 bps")
790 #ifndef B150
791 # define B150 -1
792 #endif
793 CNU(B150, "150 bps")
795 #ifndef B200
796 # define B200 -1
797 #endif
798 CNU(B200, "200 bps")
800 #ifndef B300
801 # define B300 -1
802 #endif
803 CNU(B300, "300 bps")
805 #ifndef B600
806 # define B600 -1
807 #endif
808 CNU(B600, "600 bps")
810 #ifndef B1200
811 # define B1200 -1
812 #endif
813 CNU(B1200, "1200 bps")
815 #ifndef B1800
816 # define B1800 -1
817 #endif
818 CNU(B1800, "1800 bps")
820 #ifndef B2400
821 # define B2400 -1
822 #endif
823 CNU(B2400, "2400 bps")
825 #ifndef B4800
826 # define B4800 -1
827 #endif
828 CNU(B4800, "4800 bps")
830 #ifndef B9600
831 # define B9600 -1
832 #endif
833 CNU(B9600, "9600 bps")
835 #ifndef B19200
836 # define B19200 -1
837 #endif
838 CNU(B19200, "19200 bps")
840 #ifndef B38400
841 # define B38400 -1
842 #endif
843 CNU(B38400, "38400 bps")
845 #ifndef B57600
846 # define B57600 -1
847 #endif
848 CNU(B57600, "57600 bps")
850 #ifndef B115200
851 # define B115200 -1
852 #endif
853 CNU(B115200, "115200 bps")
855 #ifndef B230400
856 # define B230400 -1
857 #endif
858 CNU(B230400, "230400 bps")
860 #ifndef B460800
861 # define B460800 -1
862 #endif
863 CNU(B460800, "460800 bps")
865 #ifndef B500000
866 # define B500000 -1
867 #endif
868 CNU(B500000, "500000 bps")
870 #ifndef B576000
871 # define B576000 -1
872 #endif
873 CNU(B576000, "576000 bps")
875 #ifndef B921600
876 # define B921600 -1
877 #endif
878 CNU(B921600, "921600 bps")
880 #ifndef B1000000
881 # define B1000000 -1
882 #endif
883 CNU(B1000000, "1000000 bps")
885 #ifndef B1152000
886 # define B1152000 -1
887 #endif
888 CNU(B1152000, "1152000 bps")
890 #ifndef B1500000
891 # define B1500000 -1
892 #endif
893 CNU(B1500000, "1500000 bps")
895 #ifndef B2000000
896 # define B2000000 -1
897 #endif
898 CNU(B2000000, "2000000 bps")
900 #ifndef B2500000
901 # define B2500000 -1
902 #endif
903 CNU(B2500000, "2500000 bps")
905 #ifndef B3000000
906 # define B3000000 -1
907 #endif
908 CNU(B3000000, "3000000 bps")
910 #ifndef B3500000
911 # define B3500000 -1
912 #endif
913 CNU(B3500000, "3500000 bps")
915 #ifndef B4000000
916 # define B4000000 -1
917 #endif
918 CNU(B4000000, "4000000 bps")
922 ---------------------------------
923 -- Terminal control characters --
924 ---------------------------------
928 #ifndef VINTR
929 # define VINTR -1
930 #endif
931 CND(VINTR, "Interrupt")
933 #ifndef VQUIT
934 # define VQUIT -1
935 #endif
936 CND(VQUIT, "Quit")
938 #ifndef VERASE
939 # define VERASE -1
940 #endif
941 CND(VERASE, "Erase")
943 #ifndef VKILL
944 # define VKILL -1
945 #endif
946 CND(VKILL, "Kill")
948 #ifndef VEOF
949 # define VEOF -1
950 #endif
951 CND(VEOF, "EOF")
953 #ifndef VTIME
954 # define VTIME -1
955 #endif
956 CND(VTIME, "Read timeout")
958 #ifndef VMIN
959 # define VMIN -1
960 #endif
961 CND(VMIN, "Read min chars")
963 #ifndef VSWTC
964 # define VSWTC -1
965 #endif
966 CND(VSWTC, "Switch")
968 #ifndef VSTART
969 # define VSTART -1
970 #endif
971 CND(VSTART, "Flow control start")
973 #ifndef VSTOP
974 # define VSTOP -1
975 #endif
976 CND(VSTOP, "Flow control stop")
978 #ifndef VSUSP
979 # define VSUSP -1
980 #endif
981 CND(VSUSP, "Suspend")
983 #ifndef VEOL
984 # define VEOL -1
985 #endif
986 CND(VEOL, "EOL")
988 #ifndef VREPRINT
989 # define VREPRINT -1
990 #endif
991 CND(VREPRINT, "Reprint unread")
993 #ifndef VDISCARD
994 # define VDISCARD -1
995 #endif
996 CND(VDISCARD, "Discard pending")
998 #ifndef VWERASE
999 # define VWERASE -1
1000 #endif
1001 CND(VWERASE, "Word erase")
1003 #ifndef VLNEXT
1004 # define VLNEXT -1
1005 #endif
1006 CND(VLNEXT, "Literal next")
1008 #ifndef VEOL2
1009 # define VEOL2 -1
1010 #endif
1011 CND(VEOL2, "Alternative EOL")
1013 #endif /* HAVE_TERMIOS */
1015 #if defined(__MINGW32__) || defined(__CYGWIN__)
1016 CNU(DTR_CONTROL_ENABLE, "Enable DTR flow ctrl")
1017 CNU(RTS_CONTROL_ENABLE, "Enable RTS flow ctrl")
1018 #endif
1022 -----------------------------
1023 -- Pseudo terminal library --
1024 -----------------------------
1028 #if defined (__FreeBSD__) || defined (linux)
1029 # define PTY_Library "-lutil"
1030 #else
1031 # define PTY_Library ""
1032 #endif
1033 CST(PTY_Library, "for g-exptty")
1036 ** Sockets constants
1039 #ifdef HAVE_SOCKETS
1043 --------------
1044 -- Families --
1045 --------------
1049 #ifndef AF_INET
1050 # define AF_INET -1
1051 #endif
1052 CND(AF_INET, "IPv4 address family")
1055 ** RTEMS lies and defines AF_INET6 even though there is no IPV6 support.
1056 ** Its TCP/IP stack is in transition. It has newer .h files but no IPV6 yet.
1058 #if defined(__rtems__)
1059 # undef AF_INET6
1060 #endif
1062 #ifndef AF_INET6
1063 # define AF_INET6 -1
1064 #else
1065 # define HAVE_AF_INET6 1
1066 #endif
1067 CND(AF_INET6, "IPv6 address family")
1071 ------------------
1072 -- Socket modes --
1073 ------------------
1077 #ifndef SOCK_STREAM
1078 # define SOCK_STREAM -1
1079 #endif
1080 CND(SOCK_STREAM, "Stream socket")
1082 #ifndef SOCK_DGRAM
1083 # define SOCK_DGRAM -1
1084 #endif
1085 CND(SOCK_DGRAM, "Datagram socket")
1089 -----------------
1090 -- Host errors --
1091 -----------------
1095 #ifndef HOST_NOT_FOUND
1096 # define HOST_NOT_FOUND -1
1097 #endif
1098 CND(HOST_NOT_FOUND, "Unknown host")
1100 #ifndef TRY_AGAIN
1101 # define TRY_AGAIN -1
1102 #endif
1103 CND(TRY_AGAIN, "Host name lookup failure")
1105 #ifndef NO_DATA
1106 # define NO_DATA -1
1107 #endif
1108 CND(NO_DATA, "No data record for name")
1110 #ifndef NO_RECOVERY
1111 # define NO_RECOVERY -1
1112 #endif
1113 CND(NO_RECOVERY, "Non recoverable errors")
1117 --------------------
1118 -- Shutdown modes --
1119 --------------------
1123 #ifndef SHUT_RD
1124 # define SHUT_RD -1
1125 #endif
1126 CND(SHUT_RD, "No more recv")
1128 #ifndef SHUT_WR
1129 # define SHUT_WR -1
1130 #endif
1131 CND(SHUT_WR, "No more send")
1133 #ifndef SHUT_RDWR
1134 # define SHUT_RDWR -1
1135 #endif
1136 CND(SHUT_RDWR, "No more recv/send")
1140 ---------------------
1141 -- Protocol levels --
1142 ---------------------
1146 #ifndef SOL_SOCKET
1147 # define SOL_SOCKET -1
1148 #endif
1149 CND(SOL_SOCKET, "Options for socket level")
1151 #ifndef IPPROTO_IP
1152 # define IPPROTO_IP -1
1153 #endif
1154 CND(IPPROTO_IP, "Dummy protocol for IP")
1156 #ifndef IPPROTO_UDP
1157 # define IPPROTO_UDP -1
1158 #endif
1159 CND(IPPROTO_UDP, "UDP")
1161 #ifndef IPPROTO_TCP
1162 # define IPPROTO_TCP -1
1163 #endif
1164 CND(IPPROTO_TCP, "TCP")
1168 -------------------
1169 -- Request flags --
1170 -------------------
1174 #ifndef MSG_OOB
1175 # define MSG_OOB -1
1176 #endif
1177 CND(MSG_OOB, "Process out-of-band data")
1179 #ifndef MSG_PEEK
1180 # define MSG_PEEK -1
1181 #endif
1182 CND(MSG_PEEK, "Peek at incoming data")
1184 #ifndef MSG_EOR
1185 # define MSG_EOR -1
1186 #endif
1187 CND(MSG_EOR, "Send end of record")
1189 #ifndef MSG_WAITALL
1190 #ifdef __MINWGW32__
1191 /* The value of MSG_WAITALL is 8. Nevertheless winsock.h doesn't
1192 define it, but it is still usable as we link to winsock2 API. */
1193 # define MSG_WAITALL (1 << 3)
1194 #else
1195 # define MSG_WAITALL -1
1196 #endif
1197 #endif
1198 CND(MSG_WAITALL, "Wait for full reception")
1200 #ifndef MSG_NOSIGNAL
1201 # define MSG_NOSIGNAL -1
1202 #endif
1203 CND(MSG_NOSIGNAL, "No SIGPIPE on send")
1205 #ifdef __linux__
1206 # define MSG_Forced_Flags "MSG_NOSIGNAL"
1207 #else
1208 # define MSG_Forced_Flags "0"
1209 #endif
1210 CNS(MSG_Forced_Flags, "")
1212 -- Flags set on all send(2) calls
1217 --------------------
1218 -- Socket options --
1219 --------------------
1223 #ifndef TCP_NODELAY
1224 # define TCP_NODELAY -1
1225 #endif
1226 CND(TCP_NODELAY, "Do not coalesce packets")
1228 #ifndef SO_REUSEADDR
1229 # define SO_REUSEADDR -1
1230 #endif
1231 CND(SO_REUSEADDR, "Bind reuse local address")
1233 #ifndef SO_REUSEPORT
1234 # define SO_REUSEPORT -1
1235 #endif
1236 CND(SO_REUSEPORT, "Bind reuse port number")
1238 #ifndef SO_KEEPALIVE
1239 # define SO_KEEPALIVE -1
1240 #endif
1241 CND(SO_KEEPALIVE, "Enable keep-alive msgs")
1243 #ifndef SO_LINGER
1244 # define SO_LINGER -1
1245 #endif
1246 CND(SO_LINGER, "Defer close to flush data")
1248 #ifndef SO_BROADCAST
1249 # define SO_BROADCAST -1
1250 #endif
1251 CND(SO_BROADCAST, "Can send broadcast msgs")
1253 #ifndef SO_SNDBUF
1254 # define SO_SNDBUF -1
1255 #endif
1256 CND(SO_SNDBUF, "Set/get send buffer size")
1258 #ifndef SO_RCVBUF
1259 # define SO_RCVBUF -1
1260 #endif
1261 CND(SO_RCVBUF, "Set/get recv buffer size")
1263 #ifndef SO_SNDTIMEO
1264 # define SO_SNDTIMEO -1
1265 #endif
1266 CND(SO_SNDTIMEO, "Emission timeout")
1268 #ifndef SO_RCVTIMEO
1269 # define SO_RCVTIMEO -1
1270 #endif
1271 CND(SO_RCVTIMEO, "Reception timeout")
1273 #ifndef SO_ERROR
1274 # define SO_ERROR -1
1275 #endif
1276 CND(SO_ERROR, "Get/clear error status")
1278 #ifndef IP_MULTICAST_IF
1279 # define IP_MULTICAST_IF -1
1280 #endif
1281 CND(IP_MULTICAST_IF, "Set/get mcast interface")
1283 #ifndef IP_MULTICAST_TTL
1284 # define IP_MULTICAST_TTL -1
1285 #endif
1286 CND(IP_MULTICAST_TTL, "Set/get multicast TTL")
1288 #ifndef IP_MULTICAST_LOOP
1289 # define IP_MULTICAST_LOOP -1
1290 #endif
1291 CND(IP_MULTICAST_LOOP, "Set/get mcast loopback")
1293 #ifndef IP_ADD_MEMBERSHIP
1294 # define IP_ADD_MEMBERSHIP -1
1295 #endif
1296 CND(IP_ADD_MEMBERSHIP, "Join a multicast group")
1298 #ifndef IP_DROP_MEMBERSHIP
1299 # define IP_DROP_MEMBERSHIP -1
1300 #endif
1301 CND(IP_DROP_MEMBERSHIP, "Leave a multicast group")
1303 #ifndef IP_PKTINFO
1304 # define IP_PKTINFO -1
1305 #endif
1306 CND(IP_PKTINFO, "Get datagram info")
1310 ----------------------
1311 -- Type definitions --
1312 ----------------------
1317 struct timeval tv;
1319 -- Sizes (in bytes) of the components of struct timeval
1321 #define SIZEOF_tv_sec (sizeof tv.tv_sec)
1322 CND(SIZEOF_tv_sec, "tv_sec")
1323 #define SIZEOF_tv_usec (sizeof tv.tv_usec)
1324 CND(SIZEOF_tv_usec, "tv_usec")
1327 -- Maximum allowed value for tv_sec
1331 ** On Solaris, field tv_sec in struct timeval has an undocumented
1332 ** hard-wired limit of 100 million.
1333 ** On IA64 HP-UX the limit is 2**31 - 1.
1335 #if defined (sun)
1336 # define MAX_tv_sec "100_000_000"
1338 #elif defined (__hpux__)
1339 # define MAX_tv_sec "16#7fffffff#"
1341 #else
1342 # define MAX_tv_sec "2 ** (SIZEOF_tv_sec * 8 - 1) - 1"
1343 #endif
1344 CNS(MAX_tv_sec, "")
1348 -- Sizes of various data types
1351 #define SIZEOF_sockaddr_in (sizeof (struct sockaddr_in))
1352 CND(SIZEOF_sockaddr_in, "struct sockaddr_in")
1353 #ifdef HAVE_AF_INET6
1354 # define SIZEOF_sockaddr_in6 (sizeof (struct sockaddr_in6))
1355 #else
1356 # define SIZEOF_sockaddr_in6 0
1357 #endif
1358 CND(SIZEOF_sockaddr_in6, "struct sockaddr_in6")
1360 #define SIZEOF_fd_set (sizeof (fd_set))
1361 CND(SIZEOF_fd_set, "fd_set")
1362 CND(FD_SETSIZE, "Max fd value")
1364 #define SIZEOF_struct_hostent (sizeof (struct hostent))
1365 CND(SIZEOF_struct_hostent, "struct hostent")
1367 #define SIZEOF_struct_servent (sizeof (struct servent))
1368 CND(SIZEOF_struct_servent, "struct servent")
1370 #if defined (__linux__)
1371 #define SIZEOF_sigset (sizeof (sigset_t))
1372 CND(SIZEOF_sigset, "sigset")
1373 #endif
1377 -- Fields of struct msghdr
1380 #if defined (__sun__) || defined (__hpux__)
1381 # define Msg_Iovlen_T "int"
1382 #else
1383 # define Msg_Iovlen_T "size_t"
1384 #endif
1386 SUB(Msg_Iovlen_T)
1390 ----------------------------------------
1391 -- Properties of supported interfaces --
1392 ----------------------------------------
1396 CND(Need_Netdb_Buffer, "Need buffer for Netdb ops")
1397 CND(Need_Netdb_Lock, "Need lock for Netdb ops")
1398 CND(Has_Sockaddr_Len, "Sockaddr has sa_len field")
1401 ** Do not change the format of the line below without also updating the
1402 ** MaRTE Makefile.
1404 C("Thread_Blocking_IO", Boolean, "True", "")
1406 -- Set False for contexts where socket i/o are process blocking
1410 #ifdef HAVE_INET_PTON
1411 # define Inet_Pton_Linkname "inet_pton"
1412 #else
1413 # define Inet_Pton_Linkname "__gnat_inet_pton"
1414 #endif
1415 CST(Inet_Pton_Linkname, "")
1417 #endif /* HAVE_SOCKETS */
1421 ---------------------
1422 -- Threads support --
1423 ---------------------
1425 -- Clock identifier definitions
1429 /* Note: On HP-UX, CLOCK_REALTIME is an enum, not a macro. */
1431 #if !(defined(CLOCK_REALTIME) || defined (__hpux__))
1432 # define CLOCK_REALTIME (-1)
1433 #endif
1434 CND(CLOCK_REALTIME, "System realtime clock")
1436 #ifdef CLOCK_MONOTONIC
1437 CND(CLOCK_MONOTONIC, "System monotonic clock")
1438 #endif
1440 #ifdef CLOCK_FASTEST
1441 CND(CLOCK_FASTEST, "Fastest clock")
1442 #endif
1444 #ifndef CLOCK_THREAD_CPUTIME_ID
1445 # define CLOCK_THREAD_CPUTIME_ID -1
1446 #endif
1447 CND(CLOCK_THREAD_CPUTIME_ID, "Thread CPU clock")
1449 #if defined(__FreeBSD__) || (defined(_AIX) && defined(_AIXVERSION_530))
1450 /** On these platforms use system provided monotonic clock instead of
1451 ** the default CLOCK_REALTIME. We then need to set up cond var attributes
1452 ** appropriately (see thread.c).
1454 ** Note that AIX 5.2 does not support CLOCK_MONOTONIC timestamps for
1455 ** pthread_cond_timedwait (and does not have pthread_condattr_setclock),
1456 ** hence the conditionalization on AIX version above). _AIXVERSION_530
1457 ** is defined in AIX 5.3 and more recent versions.
1459 # define CLOCK_RT_Ada "CLOCK_MONOTONIC"
1461 #else
1462 /* By default use CLOCK_REALTIME */
1463 # define CLOCK_RT_Ada "CLOCK_REALTIME"
1464 #endif
1466 #ifdef CLOCK_RT_Ada
1467 CNS(CLOCK_RT_Ada, "")
1468 #endif
1470 #if defined (__APPLE__) || defined (__linux__) || defined (DUMMY)
1473 -- Sizes of pthread data types
1476 #if defined (__APPLE__) || defined (DUMMY)
1478 -- (on Darwin, these are just placeholders)
1480 #define PTHREAD_SIZE __PTHREAD_SIZE__
1481 #define PTHREAD_ATTR_SIZE __PTHREAD_ATTR_SIZE__
1482 #define PTHREAD_MUTEXATTR_SIZE __PTHREAD_MUTEXATTR_SIZE__
1483 #define PTHREAD_MUTEX_SIZE __PTHREAD_MUTEX_SIZE__
1484 #define PTHREAD_CONDATTR_SIZE __PTHREAD_CONDATTR_SIZE__
1485 #define PTHREAD_COND_SIZE __PTHREAD_COND_SIZE__
1486 #define PTHREAD_RWLOCKATTR_SIZE __PTHREAD_RWLOCKATTR_SIZE__
1487 #define PTHREAD_RWLOCK_SIZE __PTHREAD_RWLOCK_SIZE__
1488 #define PTHREAD_ONCE_SIZE __PTHREAD_ONCE_SIZE__
1489 #else
1490 #define PTHREAD_SIZE (sizeof (pthread_t))
1491 #define PTHREAD_ATTR_SIZE (sizeof (pthread_attr_t))
1492 #define PTHREAD_MUTEXATTR_SIZE (sizeof (pthread_mutexattr_t))
1493 #define PTHREAD_MUTEX_SIZE (sizeof (pthread_mutex_t))
1494 #define PTHREAD_CONDATTR_SIZE (sizeof (pthread_condattr_t))
1495 #define PTHREAD_COND_SIZE (sizeof (pthread_cond_t))
1496 #define PTHREAD_RWLOCKATTR_SIZE (sizeof (pthread_rwlockattr_t))
1497 #define PTHREAD_RWLOCK_SIZE (sizeof (pthread_rwlock_t))
1498 #define PTHREAD_ONCE_SIZE (sizeof (pthread_once_t))
1499 #endif
1503 CND(PTHREAD_SIZE, "pthread_t")
1504 CND(PTHREAD_ATTR_SIZE, "pthread_attr_t")
1505 CND(PTHREAD_MUTEXATTR_SIZE, "pthread_mutexattr_t")
1506 CND(PTHREAD_MUTEX_SIZE, "pthread_mutex_t")
1507 CND(PTHREAD_CONDATTR_SIZE, "pthread_condattr_t")
1508 CND(PTHREAD_COND_SIZE, "pthread_cond_t")
1509 CND(PTHREAD_RWLOCKATTR_SIZE, "pthread_rwlockattr_t")
1510 CND(PTHREAD_RWLOCK_SIZE, "pthread_rwlock_t")
1511 CND(PTHREAD_ONCE_SIZE, "pthread_once_t")
1513 #endif /* __APPLE__ || __linux__ */
1517 --------------------------------
1518 -- File and directory support --
1519 --------------------------------
1524 ** Note: this constant can be used in the GNAT runtime library. In compiler
1525 ** units on the other hand, System.OS_Constants is not available, so we
1526 ** declare an Ada constant (Osint.File_Attributes_Size) independently, which
1527 ** is at least as large as sizeof (struct file_attributes), and we have an
1528 ** assertion at initialization of Osint checking that the size is indeed at
1529 ** least sufficient.
1531 #define SIZEOF_struct_file_attributes (sizeof (struct file_attributes))
1532 CND(SIZEOF_struct_file_attributes, "struct file_attributes")
1535 ** Maximal size of buffer for struct dirent. Note: Since POSIX.1 does not
1536 ** specify the size of the d_name field, and other nonstandard fields may
1537 ** precede that field within the dirent structure, we must make a conservative
1538 ** computation.
1541 struct dirent dent;
1542 #define SIZEOF_struct_dirent_alloc \
1543 ((char*) &dent.d_name - (char*) &dent) + NAME_MAX + 1
1544 CND(SIZEOF_struct_dirent_alloc, "struct dirent allocation")
1548 ** System-specific constants follow
1549 ** Each section should be activated if compiling for the corresponding
1550 ** platform *or* generating the dummy version for runtime test compilation.
1553 #if defined (__vxworks) || defined (DUMMY)
1557 --------------------------------
1558 -- VxWorks-specific constants --
1559 --------------------------------
1561 -- These constants may be used only within the VxWorks version of
1562 -- GNAT.Sockets.Thin.
1565 CND(OK, "VxWorks generic success")
1566 CND(ERROR, "VxWorks generic error")
1568 #endif /* __vxworks */
1570 #if defined (__MINGW32__) || defined (DUMMY)
1573 ------------------------------
1574 -- MinGW-specific constants --
1575 ------------------------------
1577 -- These constants may be used only within the MinGW version of
1578 -- GNAT.Sockets.Thin.
1581 CND(WSASYSNOTREADY, "System not ready")
1582 CND(WSAVERNOTSUPPORTED, "Version not supported")
1583 CND(WSANOTINITIALISED, "Winsock not initialized")
1584 CND(WSAEDISCON, "Disconnected")
1586 #endif /* __MINGW32__ */
1589 ** End of constants definitions
1592 #ifdef NATIVE
1593 putchar ('\n');
1594 #endif
1598 end System.OS_Constants;