OSDN Git Service

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