PR rtl-optimization/57003
[official-gcc.git] / gcc / ada / gsocket.h
blob2034137b2b6496af0ccbc6b9b8fa55029f3deabf
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-2014, 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(__nucleus__) || defined(VTHREADS) || defined(__ANDROID__) \
33 || defined(__PikeOS__)
35 /* Sockets not supported on these platforms. */
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 /** No system header may be included prior to this point since on some targets
58 ** we need to redefine FD_SETSIZE.
59 **/
61 /* Target-specific includes and definitions */
63 #if defined(__vxworks)
64 #include <vxWorks.h>
65 #include <ioLib.h>
66 #include <hostLib.h>
67 #define SHUT_RD 0
68 #define SHUT_WR 1
69 #define SHUT_RDWR 2
71 #elif defined (WINNT)
72 #define FD_SETSIZE 1024
74 #ifdef __MINGW32__
75 #include <winsock2.h>
76 #include <ws2tcpip.h>
78 #undef EACCES
79 #define EACCES WSAEACCES
80 #undef EADDRINUSE
81 #define EADDRINUSE WSAEADDRINUSE
82 #undef EADDRNOTAVAIL
83 #define EADDRNOTAVAIL WSAEADDRNOTAVAIL
84 #undef EAFNOSUPPORT
85 #define EAFNOSUPPORT WSAEAFNOSUPPORT
86 #undef EALREADY
87 #define EALREADY WSAEALREADY
88 #undef EBADF
89 #define EBADF WSAEBADF
90 #undef ECONNABORTED
91 #define ECONNABORTED WSAECONNABORTED
92 #undef ECONNREFUSED
93 #define ECONNREFUSED WSAECONNREFUSED
94 #undef ECONNRESET
95 #define ECONNRESET WSAECONNRESET
96 #undef EDESTADDRREQ
97 #define EDESTADDRREQ WSAEDESTADDRREQ
98 #undef EFAULT
99 #define EFAULT WSAEFAULT
100 #undef EHOSTDOWN
101 #define EHOSTDOWN WSAEHOSTDOWN
102 #undef EHOSTUNREACH
103 #define EHOSTUNREACH WSAEHOSTUNREACH
104 #undef EINPROGRESS
105 #define EINPROGRESS WSAEINPROGRESS
106 #undef EINTR
107 #define EINTR WSAEINTR
108 #undef EINVAL
109 #define EINVAL WSAEINVAL
110 #undef EIO
111 #define EIO WSAEDISCON
112 #undef EISCONN
113 #define EISCONN WSAEISCONN
114 #undef ELOOP
115 #define ELOOP WSAELOOP
116 #undef EMFILE
117 #define EMFILE WSAEMFILE
118 #undef EMSGSIZE
119 #define EMSGSIZE WSAEMSGSIZE
120 #undef ENAMETOOLONG
121 #define ENAMETOOLONG WSAENAMETOOLONG
122 #undef ENETDOWN
123 #define ENETDOWN WSAENETDOWN
124 #undef ENETRESET
125 #define ENETRESET WSAENETRESET
126 #undef ENETUNREACH
127 #define ENETUNREACH WSAENETUNREACH
128 #undef ENOBUFS
129 #define ENOBUFS WSAENOBUFS
130 #undef ENOPROTOOPT
131 #define ENOPROTOOPT WSAENOPROTOOPT
132 #undef ENOTCONN
133 #define ENOTCONN WSAENOTCONN
134 #undef ENOTSOCK
135 #define ENOTSOCK WSAENOTSOCK
136 #undef EOPNOTSUPP
137 #define EOPNOTSUPP WSAEOPNOTSUPP
138 #undef EPFNOSUPPORT
139 #define EPFNOSUPPORT WSAEPFNOSUPPORT
140 #undef EPROTONOSUPPORT
141 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
142 #undef EPROTOTYPE
143 #define EPROTOTYPE WSAEPROTOTYPE
144 #undef ESHUTDOWN
145 #define ESHUTDOWN WSAESHUTDOWN
146 #undef ESOCKTNOSUPPORT
147 #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
148 #undef ETIMEDOUT
149 #define ETIMEDOUT WSAETIMEDOUT
150 #undef ETOOMANYREFS
151 #define ETOOMANYREFS WSAETOOMANYREFS
152 #undef EWOULDBLOCK
153 #define EWOULDBLOCK WSAEWOULDBLOCK
155 #define SHUT_RD SD_RECEIVE
156 #define SHUT_WR SD_SEND
157 #define SHUT_RDWR SD_BOTH
159 #endif
161 #include <windows.h>
163 #elif defined(VMS)
164 /* Allow a large number of fds for select. */
165 #define FD_SETSIZE 4096
166 #ifndef IN_RTS
167 /* These DEC C headers are not available when building with GCC. Order is
168 important. */
169 #include <time.h>
170 #include <tcp.h>
171 #include <in.h>
172 #include <ioctl.h>
173 #include <netdb.h>
174 #endif
176 #endif
178 #include <limits.h>
179 #include <errno.h>
181 #if defined (__vxworks) && ! defined (__RTP__)
182 #include <sys/times.h>
183 #else
184 #include <sys/time.h>
185 #endif
187 #if defined(__rtems__)
188 #include <unistd.h>
189 /* Required, for read(), write(), and close() */
190 #endif
193 * RTEMS has these .h files but not until you have built and installed RTEMS.
194 * When building a C/C++ toolset, you also build the newlib C library, so the
195 * build procedure for an RTEMS GNAT toolset requires that you build a C/C++
196 * toolset, then build and install RTEMS with --enable-multilib, and finally
197 * build the Ada part of the toolset.
199 #if !(defined (VMS) || defined (__MINGW32__))
200 #include <sys/socket.h>
201 #include <netinet/in.h>
202 #include <netinet/tcp.h>
203 #include <sys/ioctl.h>
204 #include <netdb.h>
205 #endif
207 #if defined (_AIX) || defined (__FreeBSD__) || defined (__hpux__) || \
208 defined (_WIN32) || defined (__APPLE__)
209 # define HAVE_THREAD_SAFE_GETxxxBYyyy 1
211 #elif defined (linux) || defined (__GLIBC__) || \
212 (defined (sun) && defined (__SVR4) && !defined (__vxworks)) || \
213 defined(__rtems__)
214 # define HAVE_GETxxxBYyyy_R 1
215 #endif
218 * Properties of the unerlying NetDB library:
219 * Need_Netdb_Buffer __gnat_getXXXbyYYY expects a caller-supplied buffer
220 * Need_Netdb_Lock __gnat_getXXXbyYYY expects the caller to ensure
221 * mutual exclusion
223 * See "Handling of gethostbyname, gethostbyaddr, getservbyname and
224 * getservbyport" in socket.c for details.
227 #if defined (HAVE_GETxxxBYyyy_R)
228 # define Need_Netdb_Buffer 1
229 # define Need_Netdb_Lock 0
231 #else
232 # define Need_Netdb_Buffer 0
233 # if !defined (HAVE_THREAD_SAFE_GETxxxBYyyy)
234 # define Need_Netdb_Lock 1
235 # else
236 # define Need_Netdb_Lock 0
237 # endif
238 #endif
240 #if defined (__FreeBSD__) || defined (__vxworks) || defined(__rtems__)
241 # define Has_Sockaddr_Len 1
242 #else
243 # define Has_Sockaddr_Len 0
244 #endif
246 #if !(defined (__vxworks) || defined (_WIN32) || defined (__hpux__) || defined (VMS))
247 # define HAVE_INET_PTON
248 #endif
250 #endif /* defined(__nucleus__) */