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