1 /****************************************************************************
3 * GNAT SYSTEM UTILITIES *
5 * G E N - S O C C O N *
7 * Copyright (C) 2004-2008, Free Software Foundation, Inc. *
9 * GNAT is free software; you can redistribute it and/or modify it under *
10 * terms of the GNU General Public License as published by the Free Soft- *
11 * ware Foundation; either version 2, or (at your option) any later ver- *
12 * sion. GNAT is distributed in the hope that it will be useful, but WITH- *
13 * OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
15 * for more details. You should have received a copy of the GNU General *
16 * Public License distributed with GNAT; see file COPYING. If not, write *
17 * to the Free Software Foundation, 51 Franklin Street, Fifth Floor, *
18 * Boston, MA 02110-1301, USA. *
20 * GNAT was originally developed by the GNAT team at New York University. *
21 * Extensive contributions were provided by Ada Core Technologies Inc. *
23 ****************************************************************************/
25 /* This program generates g-soccon.ads */
28 * To build using DEC C:
30 * CC/DEFINE="TARGET=""OpenVMS""" gen-soccon
34 * Note: OpenVMS versions older than 8.3 provide an incorrect value in
35 * the DEC C header files for MSG_WAITALL. To generate the VMS version
36 * of g-soccon.ads, gen-soccon should be run on an 8.3 or later machine.
40 # error Please define TARGET
54 typedef enum { NUM
, TXT
} kind_t
;
64 struct line
*first
= NULL
, *last
= NULL
;
66 #define TXT(_text) add_line(_text, NULL, NULL, TXT);
72 #define itoad(n) f_itoa ("%d", (n))
73 #define itoax(n) f_itoa ("16#%08x#", (n))
75 #define CND(name,comment) add_line(#name, itoad (name), comment, NUM);
76 /* Constant (decimal) */
78 #define CNX(name,comment) add_line(#name, itoax (name), comment, NUM);
79 /* Constant (hexadecimal) */
81 #define CN_(name,comment) add_line(#name, name, comment, TXT);
82 /* Constant (generic) */
84 #define STR(p) STR1(p)
88 /* Generate output spec */
90 char *f_itoa (char *, int);
93 void add_line (char *, char*, char*, kind_t
);
96 unsigned int _CRT_fmode
= _O_BINARY
;
102 TXT("------------------------------------------------------------------------------")
104 TXT("-- GNAT COMPILER COMPONENTS --")
106 TXT("-- G N A T . S O C K E T S . C O N S T A N T S --")
110 TXT("-- Copyright (C) 2000-2008, Free Software Foundation, Inc. --")
112 TXT("-- GNAT is free software; you can redistribute it and/or modify it under --")
113 TXT("-- terms of the GNU General Public License as published by the Free Soft- --")
114 TXT("-- ware Foundation; either version 2, or (at your option) any later ver- --")
115 TXT("-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --")
116 TXT("-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --")
117 TXT("-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --")
118 TXT("-- for more details. You should have received a copy of the GNU General --")
119 TXT("-- Public License distributed with GNAT; see file COPYING. If not, write --")
120 TXT("-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --")
121 TXT("-- Boston, MA 02110-1301, USA. --")
123 TXT("-- As a special exception, if other files instantiate generics from this --")
124 TXT("-- unit, or you link this unit with other files to produce an executable, --")
125 TXT("-- this unit does not by itself cause the resulting executable to be --")
126 TXT("-- covered by the GNU General Public License. This exception does not --")
127 TXT("-- however invalidate any other reasons why the executable file might be --")
128 TXT("-- covered by the GNU Public License. --")
130 TXT("-- GNAT was originally developed by the GNAT team at New York University. --")
131 TXT("-- Extensive contributions were provided by Ada Core Technologies Inc. --")
133 TXT("------------------------------------------------------------------------------")
135 TXT("-- This package provides target dependent definitions of constant for use")
136 TXT("-- by the GNAT.Sockets package (g-socket.ads). This package should not be")
137 TXT("-- directly with'ed by an applications program.")
139 TXT("-- This is the version for " TARGET
)
140 TXT("-- This file is generated automatically, do not modify it by hand! Instead,")
141 TXT("-- make changes to gen-soccon.c and re-run it on each target.")
143 TXT("with Interfaces.C;")
144 TXT("package GNAT.Sockets.Constants is")
146 TXT(" --------------")
147 TXT(" -- Families --")
148 TXT(" --------------")
154 CND(AF_INET
, "IPv4 address family")
159 # define HAVE_AF_INET6 1
161 CND(AF_INET6
, "IPv6 address family")
169 #define SOCK_STREAM -1
171 CND(SOCK_STREAM
, "Stream socket")
174 #define SOCK_DGRAM -1
176 CND(SOCK_DGRAM
, "Datagram socket")
178 TXT(" -------------------")
179 TXT(" -- Socket errors --")
180 TXT(" -------------------")
186 CND(EACCES
, "Permission denied")
189 #define EADDRINUSE -1
191 CND(EADDRINUSE
, "Address already in use")
193 #ifndef EADDRNOTAVAIL
194 #define EADDRNOTAVAIL -1
196 CND(EADDRNOTAVAIL
, "Cannot assign address")
199 #define EAFNOSUPPORT -1
201 CND(EAFNOSUPPORT
, "Addr family not supported")
206 CND(EALREADY
, "Operation in progress")
211 CND(EBADF
, "Bad file descriptor")
214 #define ECONNABORTED -1
216 CND(ECONNABORTED
, "Connection aborted")
219 #define ECONNREFUSED -1
221 CND(ECONNREFUSED
, "Connection refused")
224 #define ECONNRESET -1
226 CND(ECONNRESET
, "Connection reset by peer")
229 #define EDESTADDRREQ -1
231 CND(EDESTADDRREQ
, "Destination addr required")
236 CND(EFAULT
, "Bad address")
241 CND(EHOSTDOWN
, "Host is down")
244 #define EHOSTUNREACH -1
246 CND(EHOSTUNREACH
, "No route to host")
249 #define EINPROGRESS -1
251 CND(EINPROGRESS
, "Operation now in progress")
256 CND(EINTR
, "Interrupted system call")
261 CND(EINVAL
, "Invalid argument")
266 CND(EIO
, "Input output error")
271 CND(EISCONN
, "Socket already connected")
276 CND(ELOOP
, "Too many symbolic links")
281 CND(EMFILE
, "Too many open files")
286 CND(EMSGSIZE
, "Message too long")
289 #define ENAMETOOLONG -1
291 CND(ENAMETOOLONG
, "Name too long")
296 CND(ENETDOWN
, "Network is down")
301 CND(ENETRESET
, "Disconn. on network reset")
304 #define ENETUNREACH -1
306 CND(ENETUNREACH
, "Network is unreachable")
311 CND(ENOBUFS
, "No buffer space available")
314 #define ENOPROTOOPT -1
316 CND(ENOPROTOOPT
, "Protocol not available")
321 CND(ENOTCONN
, "Socket not connected")
326 CND(ENOTSOCK
, "Operation on non socket")
329 #define EOPNOTSUPP -1
331 CND(EOPNOTSUPP
, "Operation not supported")
334 #define EPFNOSUPPORT -1
336 CND(EPFNOSUPPORT
, "Unknown protocol family")
338 #ifndef EPROTONOSUPPORT
339 #define EPROTONOSUPPORT -1
341 CND(EPROTONOSUPPORT
, "Unknown protocol")
344 #define EPROTOTYPE -1
346 CND(EPROTOTYPE
, "Unknown protocol type")
351 CND(ESHUTDOWN
, "Cannot send once shutdown")
353 #ifndef ESOCKTNOSUPPORT
354 #define ESOCKTNOSUPPORT -1
356 CND(ESOCKTNOSUPPORT
, "Socket type not supported")
361 CND(ETIMEDOUT
, "Connection timed out")
364 #define ETOOMANYREFS -1
366 CND(ETOOMANYREFS
, "Too many references")
369 #define EWOULDBLOCK -1
371 CND(EWOULDBLOCK
, "Operation would block")
373 TXT(" -----------------")
374 TXT(" -- Host errors --")
375 TXT(" -----------------")
378 #ifndef HOST_NOT_FOUND
379 #define HOST_NOT_FOUND -1
381 CND(HOST_NOT_FOUND
, "Unknown host")
386 CND(TRY_AGAIN
, "Host name lookup failure")
391 CND(NO_DATA
, "No data record for name")
394 #define NO_RECOVERY -1
396 CND(NO_RECOVERY
, "Non recoverable errors")
398 TXT(" -------------------")
399 TXT(" -- Control flags --")
400 TXT(" -------------------")
406 CND(FIONBIO
, "Set/clear non-blocking io")
411 CND(FIONREAD
, "How many bytes to read")
413 TXT(" --------------------")
414 TXT(" -- Shutdown modes --")
415 TXT(" --------------------")
421 CND(SHUT_RD
, "No more recv")
426 CND(SHUT_WR
, "No more send")
431 CND(SHUT_RDWR
, "No more recv/send")
433 TXT(" ---------------------")
434 TXT(" -- Protocol levels --")
435 TXT(" ---------------------")
439 #define SOL_SOCKET -1
441 CND(SOL_SOCKET
, "Options for socket level")
444 #define IPPROTO_IP -1
446 CND(IPPROTO_IP
, "Dummy protocol for IP")
449 #define IPPROTO_UDP -1
451 CND(IPPROTO_UDP
, "UDP")
454 #define IPPROTO_TCP -1
456 CND(IPPROTO_TCP
, "TCP")
458 TXT(" -------------------")
459 TXT(" -- Request flags --")
460 TXT(" -------------------")
466 CND(MSG_OOB
, "Process out-of-band data")
471 CND(MSG_PEEK
, "Peek at incoming data")
476 CND(MSG_EOR
, "Send end of record")
479 #define MSG_WAITALL -1
481 CND(MSG_WAITALL
, "Wait for full reception")
484 #define MSG_NOSIGNAL -1
486 CND(MSG_NOSIGNAL
, "No SIGPIPE on send")
489 # define MSG_Forced_Flags "MSG_NOSIGNAL"
491 # define MSG_Forced_Flags "0"
493 CN_(MSG_Forced_Flags
, "")
494 TXT(" -- Flags set on all send(2) calls")
497 TXT(" --------------------")
498 TXT(" -- Socket options --")
499 TXT(" --------------------")
503 #define TCP_NODELAY -1
505 CND(TCP_NODELAY
, "Do not coalesce packets")
508 #define SO_REUSEADDR -1
510 CND(SO_REUSEADDR
, "Bind reuse local address")
513 #define SO_REUSEPORT -1
515 CND(SO_REUSEPORT
, "Bind reuse port number")
518 #define SO_KEEPALIVE -1
520 CND(SO_KEEPALIVE
, "Enable keep-alive msgs")
525 CND(SO_LINGER
, "Defer close to flush data")
528 #define SO_BROADCAST -1
530 CND(SO_BROADCAST
, "Can send broadcast msgs")
535 CND(SO_SNDBUF
, "Set/get send buffer size")
540 CND(SO_RCVBUF
, "Set/get recv buffer size")
543 #define SO_SNDTIMEO -1
545 CND(SO_SNDTIMEO
, "Emission timeout")
548 #define SO_RCVTIMEO -1
550 CND(SO_RCVTIMEO
, "Reception timeout")
555 CND(SO_ERROR
, "Get/clear error status")
557 #ifndef IP_MULTICAST_IF
558 #define IP_MULTICAST_IF -1
560 CND(IP_MULTICAST_IF
, "Set/get mcast interface")
562 #ifndef IP_MULTICAST_TTL
563 #define IP_MULTICAST_TTL -1
565 CND(IP_MULTICAST_TTL
, "Set/get multicast TTL")
567 #ifndef IP_MULTICAST_LOOP
568 #define IP_MULTICAST_LOOP -1
570 CND(IP_MULTICAST_LOOP
, "Set/get mcast loopback")
572 #ifndef IP_ADD_MEMBERSHIP
573 #define IP_ADD_MEMBERSHIP -1
575 CND(IP_ADD_MEMBERSHIP
, "Join a multicast group")
577 #ifndef IP_DROP_MEMBERSHIP
578 #define IP_DROP_MEMBERSHIP -1
580 CND(IP_DROP_MEMBERSHIP
, "Leave a multicast group")
583 #define IP_PKTINFO -1
585 CND(IP_PKTINFO
, "Get datagram info")
588 TXT(" -------------------")
589 TXT(" -- System limits --")
590 TXT(" -------------------")
594 #define IOV_MAX INT_MAX
596 CND(IOV_MAX
, "Maximum writev iovcnt")
599 TXT(" ----------------------")
600 TXT(" -- Type definitions --")
601 TXT(" ----------------------")
606 TXT(" -- Sizes (in bytes) of the components of struct timeval")
608 #define SIZEOF_tv_sec (sizeof tv.tv_sec)
609 CND(SIZEOF_tv_sec
, "tv_sec")
610 #define SIZEOF_tv_usec (sizeof tv.tv_usec)
611 CND(SIZEOF_tv_usec
, "tv_usec")
614 TXT(" -- Sizes of protocol specific address types (for sockaddr.sa_len)")
616 #define SIZEOF_sockaddr_in (sizeof (struct sockaddr_in))
617 CND(SIZEOF_sockaddr_in
, "struct sockaddr_in")
619 # define SIZEOF_sockaddr_in6 (sizeof (struct sockaddr_in6))
621 # define SIZEOF_sockaddr_in6 0
623 CND(SIZEOF_sockaddr_in6
, "struct sockaddr_in6")
625 TXT(" -- Size of file descriptor sets")
627 #define SIZEOF_fd_set (sizeof (fd_set))
628 CND(SIZEOF_fd_set
, "fd_set");
630 TXT(" -- Fields of struct hostent")
633 # define h_addrtype_t "short"
634 # define h_length_t "short"
636 # define h_addrtype_t "int"
637 # define h_length_t "int"
639 TXT(" subtype H_Addrtype_T is Interfaces.C." h_addrtype_t
";")
640 TXT(" subtype H_Length_T is Interfaces.C." h_length_t
";")
642 TXT(" ----------------------------------------")
643 TXT(" -- Properties of supported interfaces --")
644 TXT(" ----------------------------------------")
647 CND(Need_Netdb_Buffer
, "Need buffer for Netdb ops")
648 CND(Has_Sockaddr_Len
, "Sockaddr has sa_len field")
650 TXT(" Thread_Blocking_IO : constant Boolean := True;")
651 TXT(" -- Set False for contexts where socket i/o are process blocking")
655 TXT(" --------------------------------")
656 TXT(" -- VxWorks-specific constants --")
657 TXT(" --------------------------------")
659 TXT(" -- These constants may be used only within the VxWorks version of")
660 TXT(" -- GNAT.Sockets.Thin.")
663 CND(OK
, "VxWorks generic success")
664 CND(ERROR
, "VxWorks generic error")
669 TXT(" ------------------------------")
670 TXT(" -- MinGW-specific constants --")
671 TXT(" ------------------------------")
673 TXT(" -- These constants may be used only within the MinGW version of")
674 TXT(" -- GNAT.Sockets.Thin.")
677 CND(WSASYSNOTREADY
, "System not ready")
678 CND(WSAVERNOTSUPPORTED
, "Version not supported")
679 CND(WSANOTINITIALISED
, "Winsock not initialized")
680 CND(WSAEDISCON
, "Disconnected")
684 TXT("end GNAT.Sockets.Constants;")
692 int text_max
= 0, value_max
= 0, l
;
695 #define UPD_MAX(x) do { \
697 if (l > x ## _max) x ## _max = l; \
700 for (p
= first
; p
!= NULL
; p
= p
->next
) {
701 if (p
->value
!= NULL
) {
707 sprintf (fmt
, " %%-%ds : constant := %%%ds;%%s%%s\n",
708 text_max
, value_max
);
710 for (p
= first
; p
!= NULL
; p
= p
->next
) {
711 if (p
->value
== NULL
) {
712 printf ("%s\n", p
->text
);
714 char *comment_sep
= (strlen (p
->comment
) > 0)
716 printf (fmt
, p
->text
, p
->value
, comment_sep
, p
->comment
);
722 f_itoa (char *fmt
, int n
) {
724 sprintf (buf
, fmt
, n
);
725 ret
= malloc (strlen (buf
) + 1);
732 add_line (char *_text
, char *_value
, char *_comment
, kind_t _kind
) {
733 struct line
*l
= (struct line
*) malloc (sizeof (struct line
));
737 l
->comment
= _comment
;