* gcc.dg/compat/struct-layout-1_generate.c (dg_options): New. Moved
[official-gcc.git] / gcc / ada / gsocket.h
blob0dca1a9f50372e76931bff5350febe3de92cc762
1 /****************************************************************************
2 * *
3 * GNAT COMPILER COMPONENTS *
4 * *
5 * G S O C K E T *
6 * *
7 * C Header File *
8 * *
9 * Copyright (C) 2004-2008, Free Software Foundation, Inc. *
10 * *
11 * GNAT is free software; you can redistribute it and/or modify it under *
12 * terms of the GNU General Public License as published by the Free Soft- *
13 * ware Foundation; either version 2, or (at your option) any later ver- *
14 * sion. GNAT is distributed in the hope that it will be useful, but WITH- *
15 * OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
16 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
17 * for more details. You should have received a copy of the GNU General *
18 * Public License distributed with GNAT; see file COPYING. If not, write *
19 * to the Free Software Foundation, 51 Franklin Street, Fifth Floor, *
20 * Boston, MA 02110-1301, USA. *
21 * *
22 * As a special exception, if you link this file with other files to *
23 * produce an executable, this file does not by itself cause the resulting *
24 * executable to be covered by the GNU General Public License. This except- *
25 * ion does not however invalidate any other reasons why the executable *
26 * file might be covered by the GNU Public License. *
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 ****************************************************************************/
33 #if defined(__nucleus__)
35 #warning Sockets not supported on this platform
36 #undef HAVE_SOCKETS
38 #else
40 #define HAVE_SOCKETS
42 #ifndef _XOPEN_SOURCE_EXTENDED
43 #define _XOPEN_SOURCE_EXTENDED 1
44 /* For HP-UX */
45 #endif
47 #ifndef BSD_COMP
48 #define BSD_COMP 1
49 /* For Solaris */
50 #endif
52 #ifndef _ALL_SOURCE
53 #define _ALL_SOURCE 1
54 /* For AIX */
55 #endif
57 #ifndef _OSF_SOURCE
58 #define _OSF_SOURCE 1
59 /* For Tru64 */
60 #endif
62 #include <limits.h>
63 #include <errno.h>
65 #if defined(__vxworks)
66 #include <vxWorks.h>
67 #include <ioLib.h>
68 #include <hostLib.h>
69 #include <resolvLib.h>
70 #define SHUT_RD 0
71 #define SHUT_WR 1
72 #define SHUT_RDWR 2
74 #elif defined (WINNT)
75 #define FD_SETSIZE 1024
76 #include <windows.h>
78 #ifdef __MINGW32__
79 #include <winsock2.h>
80 #include <ws2tcpip.h>
82 #undef EACCES
83 #define EACCES WSAEACCES
84 #undef EADDRINUSE
85 #define EADDRINUSE WSAEADDRINUSE
86 #undef EADDRNOTAVAIL
87 #define EADDRNOTAVAIL WSAEADDRNOTAVAIL
88 #undef EAFNOSUPPORT
89 #define EAFNOSUPPORT WSAEAFNOSUPPORT
90 #undef EALREADY
91 #define EALREADY WSAEALREADY
92 #undef EBADF
93 #define EBADF WSAEBADF
94 #undef ECONNABORTED
95 #define ECONNABORTED WSAECONNABORTED
96 #undef ECONNREFUSED
97 #define ECONNREFUSED WSAECONNREFUSED
98 #undef ECONNRESET
99 #define ECONNRESET WSAECONNRESET
100 #undef EDESTADDRREQ
101 #define EDESTADDRREQ WSAEDESTADDRREQ
102 #undef EFAULT
103 #define EFAULT WSAEFAULT
104 #undef EHOSTDOWN
105 #define EHOSTDOWN WSAEHOSTDOWN
106 #undef EHOSTUNREACH
107 #define EHOSTUNREACH WSAEHOSTUNREACH
108 #undef EINPROGRESS
109 #define EINPROGRESS WSAEINPROGRESS
110 #undef EINTR
111 #define EINTR WSAEINTR
112 #undef EINVAL
113 #define EINVAL WSAEINVAL
114 #undef EIO
115 #define EIO WSAEDISCON
116 #undef EISCONN
117 #define EISCONN WSAEISCONN
118 #undef ELOOP
119 #define ELOOP WSAELOOP
120 #undef EMFILE
121 #define EMFILE WSAEMFILE
122 #undef EMSGSIZE
123 #define EMSGSIZE WSAEMSGSIZE
124 #undef ENAMETOOLONG
125 #define ENAMETOOLONG WSAENAMETOOLONG
126 #undef ENETDOWN
127 #define ENETDOWN WSAENETDOWN
128 #undef ENETRESET
129 #define ENETRESET WSAENETRESET
130 #undef ENETUNREACH
131 #define ENETUNREACH WSAENETUNREACH
132 #undef ENOBUFS
133 #define ENOBUFS WSAENOBUFS
134 #undef ENOPROTOOPT
135 #define ENOPROTOOPT WSAENOPROTOOPT
136 #undef ENOTCONN
137 #define ENOTCONN WSAENOTCONN
138 #undef ENOTSOCK
139 #define ENOTSOCK WSAENOTSOCK
140 #undef EOPNOTSUPP
141 #define EOPNOTSUPP WSAEOPNOTSUPP
142 #undef EPFNOSUPPORT
143 #define EPFNOSUPPORT WSAEPFNOSUPPORT
144 #undef EPROTONOSUPPORT
145 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
146 #undef EPROTOTYPE
147 #define EPROTOTYPE WSAEPROTOTYPE
148 #undef ESHUTDOWN
149 #define ESHUTDOWN WSAESHUTDOWN
150 #undef ESOCKTNOSUPPORT
151 #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
152 #undef ETIMEDOUT
153 #define ETIMEDOUT WSAETIMEDOUT
154 #undef ETOOMANYREFS
155 #define ETOOMANYREFS WSAETOOMANYREFS
156 #undef EWOULDBLOCK
157 #define EWOULDBLOCK WSAEWOULDBLOCK
159 #define SHUT_RD SD_RECEIVE
160 #define SHUT_WR SD_SEND
161 #define SHUT_RDWR SD_BOTH
163 #endif
165 #elif defined(VMS)
166 #define FD_SETSIZE 4096
167 #ifndef IN_RTS
168 /* These DEC C headers are not available when building with GCC */
169 #include <in.h>
170 #include <tcp.h>
171 #include <ioctl.h>
172 #include <netdb.h>
173 #endif
175 #endif
177 #ifdef __vxworks
178 #include <sys/times.h>
179 #else
180 #include <sys/time.h>
181 #endif
184 * RTEMS has these .h files but not until you have built RTEMS. When
185 * IN_RTS, you only have the .h files in the newlib C library.
186 * Because this file is also included from gen-soccon.c which is built
187 * to run on RTEMS (not IN_RTS), we must distinguish between IN_RTS
188 * and using this file to compile gen-soccon.
190 #if !(defined (VMS) || defined (__MINGW32__) || \
191 (defined(__rtems__) && defined(IN_RTS)))
192 #include <sys/socket.h>
193 #include <netinet/in.h>
194 #include <netinet/tcp.h>
195 #include <sys/ioctl.h>
196 #include <netdb.h>
197 #endif
200 * Handling of gethostbyname, gethostbyaddr, getservbyname and getservbyport
201 * =========================================================================
203 * The default implementation of GNAT.Sockets.Thin requires that these
204 * operations be either thread safe, or that a reentrant version getXXXbyYYY_r
205 * be provided. In both cases, socket.c provides a __gnat_safe_getXXXbyYYY
206 * function with the same signature as getXXXbyYYY_r. If the operating
207 * system version of getXXXbyYYY is thread safe, the provided auxiliary
208 * buffer argument is unused and ignored.
210 * Target specific versions of GNAT.Sockets.Thin for platforms that can't
211 * fulfill these requirements must provide their own protection mechanism
212 * in Safe_GetXXXbyYYY, and if they require GNAT.Sockets to provide a buffer
213 * to this effect, then we need to set Need_Netdb_Buffer here (case of
214 * VxWorks and VMS).
217 #if defined (_AIX) || defined (__FreeBSD__) || defined (__hpux__) || defined (__osf__) || defined (_WIN32) || defined (__APPLE__)
218 # define HAVE_THREAD_SAFE_GETxxxBYyyy 1
219 #elif defined (sgi) || defined (linux) || defined (__GLIBC__) || (defined (sun) && defined (__SVR4) && !defined (__vxworks)) || defined(__rtems__)
220 # define HAVE_GETxxxBYyyy_R 1
221 #endif
223 #if defined (HAVE_GETxxxBYyyy_R) || !defined (HAVE_THREAD_SAFE_GETxxxBYyyy)
224 # define Need_Netdb_Buffer 1
225 #else
226 # define Need_Netdb_Buffer 0
227 #endif
229 #if defined (__FreeBSD__) || defined (__vxworks) || defined(__rtems__)
230 # define Has_Sockaddr_Len 1
231 #else
232 # define Has_Sockaddr_Len 0
233 #endif
235 #endif /* defined(__nucleus__) */