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