OSDN Git Service

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