Fix typo in t-dimode
[official-gcc.git] / gcc / ada / gsocket.h
bloba987594782b70cdba996f4dc757c8ed73c6c8b52
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-2021, 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 3, 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. *
17 * *
18 * As a special exception under Section 7 of GPL version 3, you are granted *
19 * additional permissions described in the GCC Runtime Library Exception, *
20 * version 3.1, as published by the Free Software Foundation. *
21 * *
22 * You should have received a copy of the GNU General Public License and *
23 * a copy of the GCC Runtime Library Exception along with this program; *
24 * see the files COPYING3 and COPYING.RUNTIME respectively. If not, see *
25 * <http://www.gnu.org/licenses/>. *
26 * *
27 * GNAT was originally developed by the GNAT team at New York University. *
28 * Extensive contributions were provided by Ada Core Technologies Inc. *
29 * *
30 ****************************************************************************/
32 #if defined(VTHREADS) || defined(__PikeOS__) || defined(__DJGPP__)
34 /* Sockets not supported on these platforms. */
35 #undef HAVE_SOCKETS
37 #else
39 #define HAVE_SOCKETS
41 #ifndef _XOPEN_SOURCE_EXTENDED
42 #define _XOPEN_SOURCE_EXTENDED 1
43 /* For HP-UX */
44 #endif
46 #ifndef BSD_COMP
47 #define BSD_COMP 1
48 /* For Solaris */
49 #endif
51 #ifndef _ALL_SOURCE
52 #define _ALL_SOURCE 1
53 /* For AIX */
54 #endif
56 /** No system header may be included prior to this point since on some targets
57 ** we need to redefine FD_SETSIZE.
58 **/
60 /* Target-specific includes and definitions */
62 #if defined(__vxworks)
63 #include <vxWorks.h>
64 #include <ioLib.h>
65 #include <hostLib.h>
67 #define SHUT_RD 0
68 #define SHUT_WR 1
69 #define SHUT_RDWR 2
71 #ifndef IPV6_ADD_MEMBERSHIP
72 #define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
73 #endif
75 #ifndef IPV6_DROP_MEMBERSHIP
76 #define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP
77 #endif
79 #elif defined (WINNT)
80 #define FD_SETSIZE 1024
82 #ifdef __MINGW32__
83 /* winsock2.h allows WSAPoll related definitions only when
84 * _WIN32_WINNT >= 0x0600 */
85 #if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600
86 #define _WIN32_WINNT 0x0600
87 #endif
89 #include <winsock2.h>
90 #include <ws2tcpip.h>
91 #include <versionhelpers.h>
93 #undef EACCES
94 #define EACCES WSAEACCES
95 #undef EADDRINUSE
96 #define EADDRINUSE WSAEADDRINUSE
97 #undef EADDRNOTAVAIL
98 #define EADDRNOTAVAIL WSAEADDRNOTAVAIL
99 #undef EAFNOSUPPORT
100 #define EAFNOSUPPORT WSAEAFNOSUPPORT
101 #undef EALREADY
102 #define EALREADY WSAEALREADY
103 #undef EBADF
104 #define EBADF WSAEBADF
105 #undef ECONNABORTED
106 #define ECONNABORTED WSAECONNABORTED
107 #undef ECONNREFUSED
108 #define ECONNREFUSED WSAECONNREFUSED
109 #undef ECONNRESET
110 #define ECONNRESET WSAECONNRESET
111 #undef EDESTADDRREQ
112 #define EDESTADDRREQ WSAEDESTADDRREQ
113 #undef EFAULT
114 #define EFAULT WSAEFAULT
115 #undef EHOSTDOWN
116 #define EHOSTDOWN WSAEHOSTDOWN
117 #undef EHOSTUNREACH
118 #define EHOSTUNREACH WSAEHOSTUNREACH
119 #undef EINPROGRESS
120 #define EINPROGRESS WSAEINPROGRESS
121 #undef EINTR
122 #define EINTR WSAEINTR
123 #undef EINVAL
124 #define EINVAL WSAEINVAL
125 #undef EIO
126 #define EIO WSAEDISCON
127 #undef EISCONN
128 #define EISCONN WSAEISCONN
129 #undef ELOOP
130 #define ELOOP WSAELOOP
131 #undef EMFILE
132 #define EMFILE WSAEMFILE
133 #undef EMSGSIZE
134 #define EMSGSIZE WSAEMSGSIZE
135 #undef ENAMETOOLONG
136 #define ENAMETOOLONG WSAENAMETOOLONG
137 #undef ENETDOWN
138 #define ENETDOWN WSAENETDOWN
139 #undef ENETRESET
140 #define ENETRESET WSAENETRESET
141 #undef ENETUNREACH
142 #define ENETUNREACH WSAENETUNREACH
143 #undef ENOBUFS
144 #define ENOBUFS WSAENOBUFS
145 #undef ENOPROTOOPT
146 #define ENOPROTOOPT WSAENOPROTOOPT
147 #undef ENOTCONN
148 #define ENOTCONN WSAENOTCONN
149 #undef ENOTSOCK
150 #define ENOTSOCK WSAENOTSOCK
151 #undef EOPNOTSUPP
152 #define EOPNOTSUPP WSAEOPNOTSUPP
153 #undef EPFNOSUPPORT
154 #define EPFNOSUPPORT WSAEPFNOSUPPORT
155 #undef EPROTONOSUPPORT
156 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
157 #undef EPROTOTYPE
158 #define EPROTOTYPE WSAEPROTOTYPE
159 #undef ESHUTDOWN
160 #define ESHUTDOWN WSAESHUTDOWN
161 #undef ESOCKTNOSUPPORT
162 #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
163 #undef ETIMEDOUT
164 #define ETIMEDOUT WSAETIMEDOUT
165 #undef ETOOMANYREFS
166 #define ETOOMANYREFS WSAETOOMANYREFS
167 #undef EWOULDBLOCK
168 #define EWOULDBLOCK WSAEWOULDBLOCK
170 #define SHUT_RD SD_RECEIVE
171 #define SHUT_WR SD_SEND
172 #define SHUT_RDWR SD_BOTH
174 #endif
176 #include <windows.h>
178 #elif defined(VMS)
179 /* Allow a large number of fds for select. */
180 #define FD_SETSIZE 4096
181 #ifndef IN_RTS
182 /* These DEC C headers are not available when building with GCC. Order is
183 important. */
184 #include <time.h>
185 #include <tcp.h>
186 #include <in.h>
187 #include <ioctl.h>
188 #include <netdb.h>
189 #endif
191 #endif
193 #include <limits.h>
194 #include <errno.h>
195 #include <stddef.h>
197 #if defined (__vxworks) && ! defined (__RTP__)
198 #include <sys/times.h>
199 #else
200 #include <sys/time.h>
201 #endif
203 #if defined(__rtems__)
204 #include <unistd.h>
205 /* Required, for read(), write(), and close() */
206 #endif
209 * RTEMS has these .h files but not until you have built and installed RTEMS.
210 * When building a C/C++ toolset, you also build the newlib C library, so the
211 * build procedure for an RTEMS GNAT toolset requires that you build a C/C++
212 * toolset, then build and install RTEMS with --enable-multilib, and finally
213 * build the Ada part of the toolset.
215 #if !(defined (VMS) || defined (__MINGW32__))
216 #include <sys/socket.h>
217 #include <sys/un.h>
218 #include <net/if.h>
219 #include <netinet/in.h>
220 #include <netinet/tcp.h>
221 #include <sys/ioctl.h>
222 #include <netdb.h>
223 #include <unistd.h>
224 #endif
226 #ifdef __ANDROID__
227 #include <unistd.h>
228 #include <sys/select.h>
229 #endif
231 #if defined (_AIX) || defined (__FreeBSD__) || defined (__hpux__) || \
232 defined (_WIN32) || defined (__APPLE__) || defined (__ANDROID__) || \
233 defined (__DragonFly__) || defined (__NetBSD__) || defined (__OpenBSD__)
234 # define HAVE_THREAD_SAFE_GETxxxBYyyy 1
236 #elif defined (__linux__) || defined (__GLIBC__) || \
237 (defined (__sun__) && !defined (__vxworks)) || \
238 defined (__rtems__)
239 # define HAVE_GETxxxBYyyy_R 1
240 #endif
243 * Properties of the unerlying NetDB library:
244 * Need_Netdb_Buffer __gnat_getXXXbyYYY expects a caller-supplied buffer
245 * Need_Netdb_Lock __gnat_getXXXbyYYY expects the caller to ensure
246 * mutual exclusion
248 * See "Handling of gethostbyname, gethostbyaddr, getservbyname and
249 * getservbyport" in socket.c for details.
252 #if defined (HAVE_GETxxxBYyyy_R)
253 # define Need_Netdb_Buffer 1
254 # define Need_Netdb_Lock 0
256 #else
257 # define Need_Netdb_Buffer 0
258 # if !defined (HAVE_THREAD_SAFE_GETxxxBYyyy)
259 # define Need_Netdb_Lock 1
260 # else
261 # define Need_Netdb_Lock 0
262 # endif
263 #endif
265 # define Has_Sockaddr_Len (offsetof(struct sockaddr_in, sin_family) != 0)
267 #if !(defined (_WIN32) || defined (__hpux__) || defined (VMS))
268 # define HAVE_INET_PTON
269 # define HAVE_INET_NTOP
270 #endif
272 #endif /* defined(VTHREADS) */