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