OSDN Git Service

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