OSDN Git Service

5f6782054262af43e64d31cfffbb9c9733edecb9
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-oscons-tmplt.c
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-2011, 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 ------------------------------------------------------------------------------
32
33 pragma Style_Checks ("M32766");
34 --  Allow long lines
35
36 */
37
38 /**
39  **  This template file is used while building the GNAT runtime library to
40  **  generate package System.OS_Constants (s-oscons.ads).
41  **
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.
49  **
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.
56  **
57  **  Two methods are supported to generate the list of constant values,
58  **  s-oscons-tmpl.s.
59  **
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:
63  **
64  **     xgcc -DTARGET=\"$target\" -C -E s-oscons-tmplt.c > s-oscons-tmplt.i
65  **     xgcc -S s-oscons-tmplt.i
66  **     xoscons
67  **
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:
71  **
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  **/
80
81 /* Feature macro definitions */
82
83 #if defined (__linux__) && !defined (_XOPEN_SOURCE)
84 /** For Linux _XOPEN_SOURCE must be defined, otherwise IOV_MAX is not defined
85  **/
86 #define _XOPEN_SOURCE 500
87
88 #elif defined (__mips) && defined (__sgi)
89 /** For IRIX 6, _XOPEN5 must be defined and _XOPEN_IOV_MAX must be used as
90  ** IOV_MAX, otherwise IOV_MAX is not defined.  IRIX 5 has neither.
91  **/
92 #ifdef _XOPEN_IOV_MAX
93 #define _XOPEN5
94 #define IOV_MAX _XOPEN_IOV_MAX
95 #endif
96 #endif
97
98 /* Include gsocket.h before any system header so it can redefine FD_SETSIZE */
99
100 #include "gsocket.h"
101
102 #include <stdlib.h>
103 #include <string.h>
104 #include <limits.h>
105 #include <fcntl.h>
106 #include <time.h>
107
108 #if defined (__alpha__) && defined (__osf__)
109 /** Tru64 is unable to do vector IO operations with default value of IOV_MAX,
110  ** so its value is redefined to a small one which is known to work properly.
111  **/
112 #undef IOV_MAX
113 #define IOV_MAX 16
114 #endif
115
116 #if defined (__VMS)
117 /** VMS is unable to do vector IO operations with default value of IOV_MAX,
118  ** so its value is redefined to a small one which is known to work properly.
119  **/
120 #undef IOV_MAX
121 #define IOV_MAX 16
122 #endif
123
124 #if ! (defined (__vxworks) || defined (__VMS) || defined (__MINGW32__) || \
125        defined (__nucleus__))
126 # define HAVE_TERMIOS
127 #endif
128
129 #if defined (__vxworks)
130
131 /**
132  ** For VxWorks, always include vxWorks.h (gsocket.h provides it only for
133  ** the case of runtime libraries that support sockets).
134  **/
135
136 # include <vxWorks.h>
137 #endif
138
139 #ifdef DUMMY
140
141 # if defined (TARGET)
142 #   error TARGET may not be defined when generating the dummy version
143 # else
144 #   define TARGET "batch runtime compilation (dummy values)"
145 # endif
146
147 # if !(defined (HAVE_SOCKETS) && defined (HAVE_TERMIOS))
148 #   error Features missing on platform
149 # endif
150
151 # define NATIVE
152
153 #endif /* DUMMY */
154
155 #ifndef TARGET
156 # error Please define TARGET
157 #endif
158
159 #ifndef HAVE_SOCKETS
160 # include <errno.h>
161 #endif
162
163 #ifdef HAVE_TERMIOS
164 # include <termios.h>
165 #endif
166
167 #ifdef __APPLE__
168 # include <_types.h>
169 #endif
170
171 #ifdef __linux__
172 # include <pthread.h>
173 # include <signal.h>
174 #endif
175
176 #ifdef NATIVE
177 #include <stdio.h>
178
179 #ifdef DUMMY
180 int counter = 0;
181 # define _VAL(x) counter++
182 #else
183 # define _VAL(x) x
184 #endif
185
186 #define CND(name,comment) \
187   printf ("\n->CND:$%d:" #name ":$%d:" comment, __LINE__, ((int) _VAL (name)));
188
189 #define CNS(name,comment) \
190   printf ("\n->CNS:$%d:" #name ":" name ":" comment, __LINE__);
191
192 #define C(sname,type,value,comment)\
193   printf ("\n->C:$%d:" sname ":" #type ":" value ":" comment, __LINE__);
194
195 #define TXT(text) \
196   printf ("\n->TXT:$%d:" text, __LINE__);
197
198 #else
199
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" */
204
205 #define CNS(name, comment) \
206   asm volatile("\n->CNS:%0:" #name ":" name ":" comment \
207   : : "i" (__LINE__));
208 /* General expression named number */
209
210 #define C(sname, type, value, comment) \
211   asm volatile("\n->C:%0:" sname ":" #type ":" value ":" comment \
212   : : "i" (__LINE__));
213 /* Typed constant */
214
215 #define TXT(text) \
216   asm volatile("\n->TXT:%0:" text \
217   : : "i" (__LINE__));
218 /* Freeform text */
219
220 #endif /* NATIVE */
221
222 #define CST(name,comment) C(#name,String,name,comment)
223
224 #define STR(x) STR1(x)
225 #define STR1(x) #x
226
227 #ifdef __MINGW32__
228 unsigned int _CRT_fmode = _O_BINARY;
229 #endif
230
231 int
232 main (void) {
233
234 /*
235 --  This package provides target dependent definitions of constant for use
236 --  by the GNAT runtime library. This package should not be directly with'd
237 --  by an application program.
238
239 --  This file is generated automatically, do not modify it by hand! Instead,
240 --  make changes to s-oscons-tmplt.c and rebuild the GNAT runtime library.
241 */
242
243 /**
244  ** Do not change the format of the line below without also updating the
245  ** MaRTE Makefile.
246  **/
247 TXT("--  This is the version for " TARGET)
248 TXT("")
249
250 #ifdef HAVE_SOCKETS
251 /**
252  **  The type definitions for struct hostent components uses Interfaces.C
253  **/
254
255 TXT("with Interfaces.C;")
256 #endif
257
258 /*
259 package System.OS_Constants is
260
261    pragma Pure;
262 */
263
264 /**
265  **  General constants (all platforms)
266  **/
267
268 /*
269
270    -----------------------------
271    -- Platform identification --
272    -----------------------------
273
274    type OS_Type is (Windows, VMS, Other_OS);
275 */
276 #if defined (__MINGW32__)
277 # define TARGET_OS "Windows"
278 #elif defined (__VMS)
279 # define TARGET_OS "VMS"
280 #else
281 # define TARGET_OS "Other_OS"
282 #endif
283 C("Target_OS", OS_Type, TARGET_OS, "")
284 #define Target_Name TARGET
285 CST(Target_Name, "")
286 /*
287
288    -------------------
289    -- System limits --
290    -------------------
291
292 */
293
294 #ifndef IOV_MAX
295 # define IOV_MAX INT_MAX
296 #endif
297 CND(IOV_MAX, "Maximum writev iovcnt")
298
299 /*
300
301    ---------------------
302    -- File open modes --
303    ---------------------
304
305 */
306
307 #ifndef O_RDWR
308 # define O_RDWR -1
309 #endif
310 CND(O_RDWR, "Read/write")
311
312 #ifndef O_NOCTTY
313 # define O_NOCTTY -1
314 #endif
315 CND(O_NOCTTY, "Don't change ctrl tty")
316
317 #ifndef O_NDELAY
318 # define O_NDELAY -1
319 #endif
320 CND(O_NDELAY, "Nonblocking")
321
322 /*
323
324    ----------------------
325    -- Fcntl operations --
326    ----------------------
327
328 */
329
330 #ifndef F_GETFL
331 # define F_GETFL -1
332 #endif
333 CND(F_GETFL, "Get flags")
334
335 #ifndef F_SETFL
336 # define F_SETFL -1
337 #endif
338 CND(F_SETFL, "Set flags")
339
340 /*
341
342    -----------------
343    -- Fcntl flags --
344    -----------------
345
346 */
347
348 #ifndef FNDELAY
349 # define FNDELAY -1
350 #endif
351 CND(FNDELAY, "Nonblocking")
352
353 /*
354
355    ----------------------
356    -- Ioctl operations --
357    ----------------------
358
359 */
360
361 #ifndef FIONBIO
362 # define FIONBIO -1
363 #endif
364 CND(FIONBIO, "Set/clear non-blocking io")
365
366 #ifndef FIONREAD
367 # define FIONREAD -1
368 #endif
369 CND(FIONREAD, "How many bytes to read")
370
371 /*
372
373    ------------------
374    -- Errno values --
375    ------------------
376
377    --  The following constants are defined from <errno.h>
378
379 */
380 #ifndef EAGAIN
381 # define EAGAIN -1
382 #endif
383 CND(EAGAIN, "Try again")
384
385 #ifndef ENOENT
386 # define ENOENT -1
387 #endif
388 CND(ENOENT, "File not found")
389
390 #ifndef ENOMEM
391 # define ENOMEM -1
392 #endif
393 CND(ENOMEM, "Out of memory")
394
395 #ifdef __MINGW32__
396 /*
397
398    --  The following constants are defined from <winsock2.h> (WSA*)
399
400 */
401
402 /**
403  **  For sockets-related errno values on Windows, gsocket.h redefines
404  **  Exxx as WSAExxx.
405  **/
406
407 #endif
408
409 #ifndef EACCES
410 # define EACCES -1
411 #endif
412 CND(EACCES, "Permission denied")
413
414 #ifndef EADDRINUSE
415 # define EADDRINUSE -1
416 #endif
417 CND(EADDRINUSE, "Address already in use")
418
419 #ifndef EADDRNOTAVAIL
420 # define EADDRNOTAVAIL -1
421 #endif
422 CND(EADDRNOTAVAIL, "Cannot assign address")
423
424 #ifndef EAFNOSUPPORT
425 # define EAFNOSUPPORT -1
426 #endif
427 CND(EAFNOSUPPORT, "Addr family not supported")
428
429 #ifndef EALREADY
430 # define EALREADY -1
431 #endif
432 CND(EALREADY, "Operation in progress")
433
434 #ifndef EBADF
435 # define EBADF -1
436 #endif
437 CND(EBADF, "Bad file descriptor")
438
439 #ifndef ECONNABORTED
440 # define ECONNABORTED -1
441 #endif
442 CND(ECONNABORTED, "Connection aborted")
443
444 #ifndef ECONNREFUSED
445 # define ECONNREFUSED -1
446 #endif
447 CND(ECONNREFUSED, "Connection refused")
448
449 #ifndef ECONNRESET
450 # define ECONNRESET -1
451 #endif
452 CND(ECONNRESET, "Connection reset by peer")
453
454 #ifndef EDESTADDRREQ
455 # define EDESTADDRREQ -1
456 #endif
457 CND(EDESTADDRREQ, "Destination addr required")
458
459 #ifndef EFAULT
460 # define EFAULT -1
461 #endif
462 CND(EFAULT, "Bad address")
463
464 #ifndef EHOSTDOWN
465 # define EHOSTDOWN -1
466 #endif
467 CND(EHOSTDOWN, "Host is down")
468
469 #ifndef EHOSTUNREACH
470 # define EHOSTUNREACH -1
471 #endif
472 CND(EHOSTUNREACH, "No route to host")
473
474 #ifndef EINPROGRESS
475 # define EINPROGRESS -1
476 #endif
477 CND(EINPROGRESS, "Operation now in progress")
478
479 #ifndef EINTR
480 # define EINTR -1
481 #endif
482 CND(EINTR, "Interrupted system call")
483
484 #ifndef EINVAL
485 # define EINVAL -1
486 #endif
487 CND(EINVAL, "Invalid argument")
488
489 #ifndef EIO
490 # define EIO -1
491 #endif
492 CND(EIO, "Input output error")
493
494 #ifndef EISCONN
495 # define EISCONN -1
496 #endif
497 CND(EISCONN, "Socket already connected")
498
499 #ifndef ELOOP
500 # define ELOOP -1
501 #endif
502 CND(ELOOP, "Too many symbolic links")
503
504 #ifndef EMFILE
505 # define EMFILE -1
506 #endif
507 CND(EMFILE, "Too many open files")
508
509 #ifndef EMSGSIZE
510 # define EMSGSIZE -1
511 #endif
512 CND(EMSGSIZE, "Message too long")
513
514 #ifndef ENAMETOOLONG
515 # define ENAMETOOLONG -1
516 #endif
517 CND(ENAMETOOLONG, "Name too long")
518
519 #ifndef ENETDOWN
520 # define ENETDOWN -1
521 #endif
522 CND(ENETDOWN, "Network is down")
523
524 #ifndef ENETRESET
525 # define ENETRESET -1
526 #endif
527 CND(ENETRESET, "Disconn. on network reset")
528
529 #ifndef ENETUNREACH
530 # define ENETUNREACH -1
531 #endif
532 CND(ENETUNREACH, "Network is unreachable")
533
534 #ifndef ENOBUFS
535 # define ENOBUFS -1
536 #endif
537 CND(ENOBUFS, "No buffer space available")
538
539 #ifndef ENOPROTOOPT
540 # define ENOPROTOOPT -1
541 #endif
542 CND(ENOPROTOOPT, "Protocol not available")
543
544 #ifndef ENOTCONN
545 # define ENOTCONN -1
546 #endif
547 CND(ENOTCONN, "Socket not connected")
548
549 #ifndef ENOTSOCK
550 # define ENOTSOCK -1
551 #endif
552 CND(ENOTSOCK, "Operation on non socket")
553
554 #ifndef EOPNOTSUPP
555 # define EOPNOTSUPP -1
556 #endif
557 CND(EOPNOTSUPP, "Operation not supported")
558
559 #ifndef EPIPE
560 # define EPIPE -1
561 #endif
562 CND(EPIPE, "Broken pipe")
563
564 #ifndef EPFNOSUPPORT
565 # define EPFNOSUPPORT -1
566 #endif
567 CND(EPFNOSUPPORT, "Unknown protocol family")
568
569 #ifndef EPROTONOSUPPORT
570 # define EPROTONOSUPPORT -1
571 #endif
572 CND(EPROTONOSUPPORT, "Unknown protocol")
573
574 #ifndef EPROTOTYPE
575 # define EPROTOTYPE -1
576 #endif
577 CND(EPROTOTYPE, "Unknown protocol type")
578
579 #ifndef ERANGE
580 # define ERANGE -1
581 #endif
582 CND(ERANGE, "Result too large")
583
584 #ifndef ESHUTDOWN
585 # define ESHUTDOWN -1
586 #endif
587 CND(ESHUTDOWN, "Cannot send once shutdown")
588
589 #ifndef ESOCKTNOSUPPORT
590 # define ESOCKTNOSUPPORT -1
591 #endif
592 CND(ESOCKTNOSUPPORT, "Socket type not supported")
593
594 #ifndef ETIMEDOUT
595 # define ETIMEDOUT -1
596 #endif
597 CND(ETIMEDOUT, "Connection timed out")
598
599 #ifndef ETOOMANYREFS
600 # define ETOOMANYREFS -1
601 #endif
602 CND(ETOOMANYREFS, "Too many references")
603
604 #ifndef EWOULDBLOCK
605 # define EWOULDBLOCK -1
606 #endif
607 CND(EWOULDBLOCK, "Operation would block")
608
609 /**
610  **  Terminal I/O constants
611  **/
612
613 #ifdef HAVE_TERMIOS
614
615 /*
616
617    ----------------------
618    -- Terminal control --
619    ----------------------
620
621 */
622
623 #ifndef TCSANOW
624 # define TCSANOW -1
625 #endif
626 CND(TCSANOW, "Immediate")
627
628 #ifndef TCIFLUSH
629 # define TCIFLUSH -1
630 #endif
631 CND(TCIFLUSH, "Flush input")
632
633 #ifndef CLOCAL
634 # define CLOCAL -1
635 #endif
636 CND(CLOCAL, "Local")
637
638 #ifndef CRTSCTS
639 # define CRTSCTS -1
640 #endif
641 CND(CRTSCTS, "Hardware flow control")
642
643 #ifndef CREAD
644 # define CREAD -1
645 #endif
646 CND(CREAD, "Read")
647
648 #ifndef CS5
649 # define CS5 -1
650 #endif
651 CND(CS5, "5 data bits")
652
653 #ifndef CS6
654 # define CS6 -1
655 #endif
656 CND(CS6, "6 data bits")
657
658 #ifndef CS7
659 # define CS7 -1
660 #endif
661 CND(CS7, "7 data bits")
662
663 #ifndef CS8
664 # define CS8 -1
665 #endif
666 CND(CS8, "8 data bits")
667
668 #ifndef CSTOPB
669 # define CSTOPB -1
670 #endif
671 CND(CSTOPB, "2 stop bits")
672
673 #ifndef PARENB
674 # define PARENB -1
675 #endif
676 CND(PARENB, "Parity enable")
677
678 #ifndef PARODD
679 # define PARODD -1
680 #endif
681 CND(PARODD, "Parity odd")
682
683 #ifndef B0
684 # define B0 -1
685 #endif
686 CND(B0, "0 bps")
687
688 #ifndef B50
689 # define B50 -1
690 #endif
691 CND(B50, "50 bps")
692
693 #ifndef B75
694 # define B75 -1
695 #endif
696 CND(B75, "75 bps")
697
698 #ifndef B110
699 # define B110 -1
700 #endif
701 CND(B110, "110 bps")
702
703 #ifndef B134
704 # define B134 -1
705 #endif
706 CND(B134, "134 bps")
707
708 #ifndef B150
709 # define B150 -1
710 #endif
711 CND(B150, "150 bps")
712
713 #ifndef B200
714 # define B200 -1
715 #endif
716 CND(B200, "200 bps")
717
718 #ifndef B300
719 # define B300 -1
720 #endif
721 CND(B300, "300 bps")
722
723 #ifndef B600
724 # define B600 -1
725 #endif
726 CND(B600, "600 bps")
727
728 #ifndef B1200
729 # define B1200 -1
730 #endif
731 CND(B1200, "1200 bps")
732
733 #ifndef B1800
734 # define B1800 -1
735 #endif
736 CND(B1800, "1800 bps")
737
738 #ifndef B2400
739 # define B2400 -1
740 #endif
741 CND(B2400, "2400 bps")
742
743 #ifndef B4800
744 # define B4800 -1
745 #endif
746 CND(B4800, "4800 bps")
747
748 #ifndef B9600
749 # define B9600 -1
750 #endif
751 CND(B9600, "9600 bps")
752
753 #ifndef B19200
754 # define B19200 -1
755 #endif
756 CND(B19200, "19200 bps")
757
758 #ifndef B38400
759 # define B38400 -1
760 #endif
761 CND(B38400, "38400 bps")
762
763 #ifndef B57600
764 # define B57600 -1
765 #endif
766 CND(B57600, "57600 bps")
767
768 #ifndef B115200
769 # define B115200 -1
770 #endif
771 CND(B115200, "115200 bps")
772
773 #ifndef B230400
774 # define B230400 -1
775 #endif
776 CND(B230400, "230400 bps")
777
778 #ifndef B460800
779 # define B460800 -1
780 #endif
781 CND(B460800, "460800 bps")
782
783 #ifndef B500000
784 # define B500000 -1
785 #endif
786 CND(B500000, "500000 bps")
787
788 #ifndef B576000
789 # define B576000 -1
790 #endif
791 CND(B576000, "576000 bps")
792
793 #ifndef B921600
794 # define B921600 -1
795 #endif
796 CND(B921600, "921600 bps")
797
798 #ifndef B1000000
799 # define B1000000 -1
800 #endif
801 CND(B1000000, "1000000 bps")
802
803 #ifndef B1152000
804 # define B1152000 -1
805 #endif
806 CND(B1152000, "1152000 bps")
807
808 #ifndef B1500000
809 # define B1500000 -1
810 #endif
811 CND(B1500000, "1500000 bps")
812
813 #ifndef B2000000
814 # define B2000000 -1
815 #endif
816 CND(B2000000, "2000000 bps")
817
818 #ifndef B2500000
819 # define B2500000 -1
820 #endif
821 CND(B2500000, "2500000 bps")
822
823 #ifndef B3000000
824 # define B3000000 -1
825 #endif
826 CND(B3000000, "3000000 bps")
827
828 #ifndef B3500000
829 # define B3500000 -1
830 #endif
831 CND(B3500000, "3500000 bps")
832
833 #ifndef B4000000
834 # define B4000000 -1
835 #endif
836 CND(B4000000, "4000000 bps")
837
838 /*
839
840    ---------------------------------
841    -- Terminal control characters --
842    ---------------------------------
843
844 */
845
846 #ifndef VINTR
847 # define VINTR -1
848 #endif
849 CND(VINTR, "Interrupt")
850
851 #ifndef VQUIT
852 # define VQUIT -1
853 #endif
854 CND(VQUIT, "Quit")
855
856 #ifndef VERASE
857 # define VERASE -1
858 #endif
859 CND(VERASE, "Erase")
860
861 #ifndef VKILL
862 # define VKILL -1
863 #endif
864 CND(VKILL, "Kill")
865
866 #ifndef VEOF
867 # define VEOF -1
868 #endif
869 CND(VEOF, "EOF")
870
871 #ifndef VTIME
872 # define VTIME -1
873 #endif
874 CND(VTIME, "Read timeout")
875
876 #ifndef VMIN
877 # define VMIN -1
878 #endif
879 CND(VMIN, "Read min chars")
880
881 #ifndef VSWTC
882 # define VSWTC -1
883 #endif
884 CND(VSWTC, "Switch")
885
886 #ifndef VSTART
887 # define VSTART -1
888 #endif
889 CND(VSTART, "Flow control start")
890
891 #ifndef VSTOP
892 # define VSTOP -1
893 #endif
894 CND(VSTOP, "Flow control stop")
895
896 #ifndef VSUSP
897 # define VSUSP -1
898 #endif
899 CND(VSUSP, "Suspend")
900
901 #ifndef VEOL
902 # define VEOL -1
903 #endif
904 CND(VEOL, "EOL")
905
906 #ifndef VREPRINT
907 # define VREPRINT -1
908 #endif
909 CND(VREPRINT, "Reprint unread")
910
911 #ifndef VDISCARD
912 # define VDISCARD -1
913 #endif
914 CND(VDISCARD, "Discard pending")
915
916 #ifndef VWERASE
917 # define VWERASE -1
918 #endif
919 CND(VWERASE, "Word erase")
920
921 #ifndef VLNEXT
922 # define VLNEXT -1
923 #endif
924 CND(VLNEXT, "Literal next")
925
926 #ifndef VEOL2
927 # define VEOL2 -1
928 #endif
929 CND(VEOL2, "Alternative EOL")
930
931 #endif /* HAVE_TERMIOS */
932
933 /*
934
935    -----------------------------
936    -- Pseudo terminal library --
937    -----------------------------
938
939 */
940
941 #if defined (__FreeBSD__) || defined (linux)
942 # define PTY_Library "-lutil"
943 #else
944 # define PTY_Library ""
945 #endif
946 CST(PTY_Library, "for g-exptty")
947
948 /**
949  **  Sockets constants
950  **/
951
952 #ifdef HAVE_SOCKETS
953
954 /*
955
956    --------------
957    -- Families --
958    --------------
959
960 */
961
962 #ifndef AF_INET
963 # define AF_INET -1
964 #endif
965 CND(AF_INET, "IPv4 address family")
966
967 /**
968  ** RTEMS lies and defines AF_INET6 even though there is no IPV6 support.
969  ** Its TCP/IP stack is in transition.  It has newer .h files but no IPV6 yet.
970  **/
971 #if defined(__rtems__)
972 # undef AF_INET6
973 #endif
974
975 /**
976  ** Tru64 UNIX V4.0F defines AF_INET6 without IPv6 support, specifically
977  ** without struct sockaddr_in6.  We use _SS_MAXSIZE (used for the definition
978  ** of struct sockaddr_storage on Tru64 UNIX V5.1) to detect this.
979  **/
980 #if defined(__osf__) && !defined(_SS_MAXSIZE)
981 # undef AF_INET6
982 #endif
983
984 #ifndef AF_INET6
985 # define AF_INET6 -1
986 #else
987 # define HAVE_AF_INET6 1
988 #endif
989 CND(AF_INET6, "IPv6 address family")
990
991 /*
992
993    ------------------
994    -- Socket modes --
995    ------------------
996
997 */
998
999 #ifndef SOCK_STREAM
1000 # define SOCK_STREAM -1
1001 #endif
1002 CND(SOCK_STREAM, "Stream socket")
1003
1004 #ifndef SOCK_DGRAM
1005 # define SOCK_DGRAM -1
1006 #endif
1007 CND(SOCK_DGRAM, "Datagram socket")
1008
1009 /*
1010
1011    -----------------
1012    -- Host errors --
1013    -----------------
1014
1015 */
1016
1017 #ifndef HOST_NOT_FOUND
1018 # define HOST_NOT_FOUND -1
1019 #endif
1020 CND(HOST_NOT_FOUND, "Unknown host")
1021
1022 #ifndef TRY_AGAIN
1023 # define TRY_AGAIN -1
1024 #endif
1025 CND(TRY_AGAIN, "Host name lookup failure")
1026
1027 #ifndef NO_DATA
1028 # define NO_DATA -1
1029 #endif
1030 CND(NO_DATA, "No data record for name")
1031
1032 #ifndef NO_RECOVERY
1033 # define NO_RECOVERY -1
1034 #endif
1035 CND(NO_RECOVERY, "Non recoverable errors")
1036
1037 /*
1038
1039    --------------------
1040    -- Shutdown modes --
1041    --------------------
1042
1043 */
1044
1045 #ifndef SHUT_RD
1046 # define SHUT_RD -1
1047 #endif
1048 CND(SHUT_RD, "No more recv")
1049
1050 #ifndef SHUT_WR
1051 # define SHUT_WR -1
1052 #endif
1053 CND(SHUT_WR, "No more send")
1054
1055 #ifndef SHUT_RDWR
1056 # define SHUT_RDWR -1
1057 #endif
1058 CND(SHUT_RDWR, "No more recv/send")
1059
1060 /*
1061
1062    ---------------------
1063    -- Protocol levels --
1064    ---------------------
1065
1066 */
1067
1068 #ifndef SOL_SOCKET
1069 # define SOL_SOCKET -1
1070 #endif
1071 CND(SOL_SOCKET, "Options for socket level")
1072
1073 #ifndef IPPROTO_IP
1074 # define IPPROTO_IP -1
1075 #endif
1076 CND(IPPROTO_IP, "Dummy protocol for IP")
1077
1078 #ifndef IPPROTO_UDP
1079 # define IPPROTO_UDP -1
1080 #endif
1081 CND(IPPROTO_UDP, "UDP")
1082
1083 #ifndef IPPROTO_TCP
1084 # define IPPROTO_TCP -1
1085 #endif
1086 CND(IPPROTO_TCP, "TCP")
1087
1088 /*
1089
1090    -------------------
1091    -- Request flags --
1092    -------------------
1093
1094 */
1095
1096 #ifndef MSG_OOB
1097 # define MSG_OOB -1
1098 #endif
1099 CND(MSG_OOB, "Process out-of-band data")
1100
1101 #ifndef MSG_PEEK
1102 # define MSG_PEEK -1
1103 #endif
1104 CND(MSG_PEEK, "Peek at incoming data")
1105
1106 #ifndef MSG_EOR
1107 # define MSG_EOR -1
1108 #endif
1109 CND(MSG_EOR, "Send end of record")
1110
1111 #ifndef MSG_WAITALL
1112 #ifdef __MINWGW32__
1113 /* The value of MSG_WAITALL is 8.  Nevertheless winsock.h doesn't
1114    define it, but it is still usable as we link to winsock2 API.  */
1115 # define MSG_WAITALL (1 << 3)
1116 #else
1117 # define MSG_WAITALL -1
1118 #endif
1119 #endif
1120 CND(MSG_WAITALL, "Wait for full reception")
1121
1122 #ifndef MSG_NOSIGNAL
1123 # define MSG_NOSIGNAL -1
1124 #endif
1125 CND(MSG_NOSIGNAL, "No SIGPIPE on send")
1126
1127 #ifdef __linux__
1128 # define MSG_Forced_Flags "MSG_NOSIGNAL"
1129 #else
1130 # define MSG_Forced_Flags "0"
1131 #endif
1132 CNS(MSG_Forced_Flags, "")
1133 /*
1134    --  Flags set on all send(2) calls
1135 */
1136
1137 /*
1138
1139    --------------------
1140    -- Socket options --
1141    --------------------
1142
1143 */
1144
1145 #ifndef TCP_NODELAY
1146 # define TCP_NODELAY -1
1147 #endif
1148 CND(TCP_NODELAY, "Do not coalesce packets")
1149
1150 #ifndef SO_REUSEADDR
1151 # define SO_REUSEADDR -1
1152 #endif
1153 CND(SO_REUSEADDR, "Bind reuse local address")
1154
1155 #ifndef SO_REUSEPORT
1156 # define SO_REUSEPORT -1
1157 #endif
1158 CND(SO_REUSEPORT, "Bind reuse port number")
1159
1160 #ifndef SO_KEEPALIVE
1161 # define SO_KEEPALIVE -1
1162 #endif
1163 CND(SO_KEEPALIVE, "Enable keep-alive msgs")
1164
1165 #ifndef SO_LINGER
1166 # define SO_LINGER -1
1167 #endif
1168 CND(SO_LINGER, "Defer close to flush data")
1169
1170 #ifndef SO_BROADCAST
1171 # define SO_BROADCAST -1
1172 #endif
1173 CND(SO_BROADCAST, "Can send broadcast msgs")
1174
1175 #ifndef SO_SNDBUF
1176 # define SO_SNDBUF -1
1177 #endif
1178 CND(SO_SNDBUF, "Set/get send buffer size")
1179
1180 #ifndef SO_RCVBUF
1181 # define SO_RCVBUF -1
1182 #endif
1183 CND(SO_RCVBUF, "Set/get recv buffer size")
1184
1185 #ifndef SO_SNDTIMEO
1186 # define SO_SNDTIMEO -1
1187 #endif
1188 CND(SO_SNDTIMEO, "Emission timeout")
1189
1190 #ifndef SO_RCVTIMEO
1191 # define SO_RCVTIMEO -1
1192 #endif
1193 CND(SO_RCVTIMEO, "Reception timeout")
1194
1195 #ifndef SO_ERROR
1196 # define SO_ERROR -1
1197 #endif
1198 CND(SO_ERROR, "Get/clear error status")
1199
1200 #ifndef IP_MULTICAST_IF
1201 # define IP_MULTICAST_IF -1
1202 #endif
1203 CND(IP_MULTICAST_IF, "Set/get mcast interface")
1204
1205 #ifndef IP_MULTICAST_TTL
1206 # define IP_MULTICAST_TTL -1
1207 #endif
1208 CND(IP_MULTICAST_TTL, "Set/get multicast TTL")
1209
1210 #ifndef IP_MULTICAST_LOOP
1211 # define IP_MULTICAST_LOOP -1
1212 #endif
1213 CND(IP_MULTICAST_LOOP, "Set/get mcast loopback")
1214
1215 #ifndef IP_ADD_MEMBERSHIP
1216 # define IP_ADD_MEMBERSHIP -1
1217 #endif
1218 CND(IP_ADD_MEMBERSHIP, "Join a multicast group")
1219
1220 #ifndef IP_DROP_MEMBERSHIP
1221 # define IP_DROP_MEMBERSHIP -1
1222 #endif
1223 CND(IP_DROP_MEMBERSHIP, "Leave a multicast group")
1224
1225 #ifndef IP_PKTINFO
1226 # define IP_PKTINFO -1
1227 #endif
1228 CND(IP_PKTINFO, "Get datagram info")
1229
1230 /*
1231
1232    ----------------------
1233    -- Type definitions --
1234    ----------------------
1235
1236 */
1237
1238 {
1239   struct timeval tv;
1240 /*
1241    --  Sizes (in bytes) of the components of struct timeval
1242 */
1243 #define SIZEOF_tv_sec (sizeof tv.tv_sec)
1244 CND(SIZEOF_tv_sec, "tv_sec")
1245 #define SIZEOF_tv_usec (sizeof tv.tv_usec)
1246 CND(SIZEOF_tv_usec, "tv_usec")
1247 /*
1248
1249    --  Maximum allowed value for tv_sec
1250 */
1251
1252 /**
1253  ** On Solaris and IRIX, field tv_sec in struct timeval has an undocumented
1254  ** hard-wired limit of 100 million.
1255  ** On IA64 HP-UX the limit is 2**31 - 1.
1256  **/
1257 #if defined (sun) || (defined (__mips) && defined (__sgi))
1258 # define MAX_tv_sec "100_000_000"
1259
1260 #elif defined (__hpux__)
1261 # define MAX_tv_sec "16#7fffffff#"
1262
1263 #else
1264 # define MAX_tv_sec "2 ** (SIZEOF_tv_sec * 8 - 1) - 1"
1265 #endif
1266 CNS(MAX_tv_sec, "")
1267 }
1268 /*
1269
1270    --  Sizes of various data types
1271 */
1272
1273 #define SIZEOF_sockaddr_in (sizeof (struct sockaddr_in))
1274 CND(SIZEOF_sockaddr_in, "struct sockaddr_in")
1275 #ifdef HAVE_AF_INET6
1276 # define SIZEOF_sockaddr_in6 (sizeof (struct sockaddr_in6))
1277 #else
1278 # define SIZEOF_sockaddr_in6 0
1279 #endif
1280 CND(SIZEOF_sockaddr_in6, "struct sockaddr_in6")
1281
1282 #define SIZEOF_fd_set (sizeof (fd_set))
1283 CND(SIZEOF_fd_set, "fd_set");
1284 CND(FD_SETSIZE, "Max fd value");
1285
1286 #define SIZEOF_struct_hostent (sizeof (struct hostent))
1287 CND(SIZEOF_struct_hostent, "struct hostent");
1288
1289 #define SIZEOF_struct_servent (sizeof (struct servent))
1290 CND(SIZEOF_struct_servent, "struct servent");
1291
1292 #if defined (__linux__)
1293 #define SIZEOF_sigset (sizeof (sigset_t))
1294 CND(SIZEOF_sigset, "sigset");
1295 #endif
1296 /*
1297
1298    --  Fields of struct msghdr
1299 */
1300
1301 #if defined (__sun__) || defined (__hpux__)
1302 # define msg_iovlen_t "int"
1303 #else
1304 # define msg_iovlen_t "size_t"
1305 #endif
1306
1307 TXT("   subtype Msg_Iovlen_T is Interfaces.C." msg_iovlen_t ";")
1308
1309 /*
1310
1311    ----------------------------------------
1312    -- Properties of supported interfaces --
1313    ----------------------------------------
1314
1315 */
1316
1317 CND(Need_Netdb_Buffer, "Need buffer for Netdb ops")
1318 CND(Need_Netdb_Lock,   "Need lock for Netdb ops")
1319 CND(Has_Sockaddr_Len,  "Sockaddr has sa_len field")
1320
1321 /**
1322  ** Do not change the format of the line below without also updating the
1323  ** MaRTE Makefile.
1324  **/
1325 C("Thread_Blocking_IO", Boolean, "True", "")
1326 /*
1327    --  Set False for contexts where socket i/o are process blocking
1328
1329 */
1330
1331 #ifdef HAVE_INET_PTON
1332 # define Inet_Pton_Linkname "inet_pton"
1333 #else
1334 # define Inet_Pton_Linkname "__gnat_inet_pton"
1335 #endif
1336 CST(Inet_Pton_Linkname, "")
1337
1338 #endif /* HAVE_SOCKETS */
1339
1340 /*
1341
1342    ---------------------
1343    -- Threads support --
1344    ---------------------
1345
1346    --  Clock identifier definitions
1347
1348 */
1349
1350 /* Note: On HP-UX, CLOCK_REALTIME is an enum, not a macro. */
1351
1352 #if defined(CLOCK_REALTIME) || defined (__hpux__)
1353 # define HAVE_CLOCK_REALTIME
1354 #endif
1355
1356 #ifdef HAVE_CLOCK_REALTIME
1357 CND(CLOCK_REALTIME, "System realtime clock")
1358 #endif
1359
1360 #ifdef CLOCK_MONOTONIC
1361 CND(CLOCK_MONOTONIC, "System monotonic clock")
1362 #endif
1363
1364 #ifdef CLOCK_FASTEST
1365 CND(CLOCK_FASTEST, "Fastest clock")
1366 #endif
1367
1368 #if defined (__sgi)
1369 CND(CLOCK_SGI_FAST,  "SGI fast clock")
1370 CND(CLOCK_SGI_CYCLE, "SGI CPU clock")
1371 #endif
1372
1373 #ifndef CLOCK_THREAD_CPUTIME_ID
1374 # define CLOCK_THREAD_CPUTIME_ID -1
1375 #endif
1376 CND(CLOCK_THREAD_CPUTIME_ID, "Thread CPU clock")
1377
1378 #if defined(__APPLE__)
1379 /* There's no clock_gettime or clock_id's on Darwin, generate a dummy value */
1380 # define CLOCK_RT_Ada "-1"
1381
1382 #elif defined(FreeBSD) || defined(_AIX)
1383 /** On these platforms use system provided monotonic clock instead of
1384  ** the default CLOCK_REALTIME. We then need to set up cond var attributes
1385  ** appropriately (see thread.c).
1386  **/
1387 # define CLOCK_RT_Ada "CLOCK_MONOTONIC"
1388 # define NEED_PTHREAD_CONDATTR_SETCLOCK
1389
1390 #elif defined(HAVE_CLOCK_REALTIME)
1391 /* By default use CLOCK_REALTIME */
1392 # define CLOCK_RT_Ada "CLOCK_REALTIME"
1393 #endif
1394
1395 #ifdef CLOCK_RT_Ada
1396 CNS(CLOCK_RT_Ada, "")
1397 #endif
1398
1399 #if defined (__APPLE__) || defined (__linux__) || defined (DUMMY)
1400 /*
1401
1402    --  Sizes of pthread data types
1403
1404 */
1405
1406 #if defined (__APPLE__) || defined (DUMMY)
1407 /*
1408    --  (on Darwin, these are just placeholders)
1409
1410 */
1411 #define PTHREAD_SIZE            __PTHREAD_SIZE__
1412 #define PTHREAD_ATTR_SIZE       __PTHREAD_ATTR_SIZE__
1413 #define PTHREAD_MUTEXATTR_SIZE  __PTHREAD_MUTEXATTR_SIZE__
1414 #define PTHREAD_MUTEX_SIZE      __PTHREAD_MUTEX_SIZE__
1415 #define PTHREAD_CONDATTR_SIZE   __PTHREAD_CONDATTR_SIZE__
1416 #define PTHREAD_COND_SIZE       __PTHREAD_COND_SIZE__
1417 #define PTHREAD_RWLOCKATTR_SIZE __PTHREAD_RWLOCKATTR_SIZE__
1418 #define PTHREAD_RWLOCK_SIZE     __PTHREAD_RWLOCK_SIZE__
1419 #define PTHREAD_ONCE_SIZE       __PTHREAD_ONCE_SIZE__
1420 #else
1421 #define PTHREAD_SIZE            (sizeof (pthread_t))
1422 #define PTHREAD_ATTR_SIZE       (sizeof (pthread_attr_t))
1423 #define PTHREAD_MUTEXATTR_SIZE  (sizeof (pthread_mutexattr_t))
1424 #define PTHREAD_MUTEX_SIZE      (sizeof (pthread_mutex_t))
1425 #define PTHREAD_CONDATTR_SIZE   (sizeof (pthread_condattr_t))
1426 #define PTHREAD_COND_SIZE       (sizeof (pthread_cond_t))
1427 #define PTHREAD_RWLOCKATTR_SIZE (sizeof (pthread_rwlockattr_t))
1428 #define PTHREAD_RWLOCK_SIZE     (sizeof (pthread_rwlock_t))
1429 #define PTHREAD_ONCE_SIZE       (sizeof (pthread_once_t))
1430 #endif
1431
1432 CND(PTHREAD_SIZE,            "pthread_t")
1433 CND(PTHREAD_ATTR_SIZE,       "pthread_attr_t")
1434 CND(PTHREAD_MUTEXATTR_SIZE,  "pthread_mutexattr_t")
1435 CND(PTHREAD_MUTEX_SIZE,      "pthread_mutex_t")
1436 CND(PTHREAD_CONDATTR_SIZE,   "pthread_condattr_t")
1437 CND(PTHREAD_COND_SIZE,       "pthread_cond_t")
1438 CND(PTHREAD_RWLOCKATTR_SIZE, "pthread_rwlockattr_t")
1439 CND(PTHREAD_RWLOCK_SIZE,     "pthread_rwlock_t")
1440 CND(PTHREAD_ONCE_SIZE,       "pthread_once_t")
1441
1442 #endif /* __APPLE__ || __linux__ */
1443
1444 /**
1445  **  System-specific constants follow
1446  **  Each section should be activated if compiling for the corresponding
1447  **  platform *or* generating the dummy version for runtime test compilation.
1448  **/
1449
1450 #if defined (__vxworks) || defined (DUMMY)
1451
1452 /*
1453
1454    --------------------------------
1455    -- VxWorks-specific constants --
1456    --------------------------------
1457
1458    --  These constants may be used only within the VxWorks version of
1459    --  GNAT.Sockets.Thin.
1460 */
1461
1462 CND(OK,    "VxWorks generic success")
1463 CND(ERROR, "VxWorks generic error")
1464
1465 #endif /* __vxworks */
1466
1467 #if defined (__MINGW32__) || defined (DUMMY)
1468 /*
1469
1470    ------------------------------
1471    -- MinGW-specific constants --
1472    ------------------------------
1473
1474    --  These constants may be used only within the MinGW version of
1475    --  GNAT.Sockets.Thin.
1476 */
1477
1478 CND(WSASYSNOTREADY,     "System not ready")
1479 CND(WSAVERNOTSUPPORTED, "Version not supported")
1480 CND(WSANOTINITIALISED,  "Winsock not initialized")
1481 CND(WSAEDISCON,         "Disconnected")
1482
1483 #endif /* __MINGW32__ */
1484
1485 /**
1486  ** End of constants definitions
1487  **/
1488
1489 #ifdef NATIVE
1490    putchar ('\n');
1491 #endif
1492
1493 /*
1494
1495 end System.OS_Constants;
1496 */
1497 }