OSDN Git Service

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