1 /****************************************************************************
3 * GNAT COMPILER COMPONENTS *
9 * Copyright (C) 2004-2014, Free Software Foundation, Inc. *
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. *
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. *
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/>. *
27 * GNAT was originally developed by the GNAT team at New York University. *
28 * Extensive contributions were provided by Ada Core Technologies Inc. *
30 ****************************************************************************/
32 #if defined(__nucleus__) || defined(VTHREADS) || defined(__ANDROID__) \
33 || defined(__PikeOS__)
35 /* Sockets not supported on these platforms. */
42 #ifndef _XOPEN_SOURCE_EXTENDED
43 #define _XOPEN_SOURCE_EXTENDED 1
57 /** No system header may be included prior to this point since on some targets
58 ** we need to redefine FD_SETSIZE.
61 /* Target-specific includes and definitions */
63 #if defined(__vxworks)
72 #define FD_SETSIZE 1024
79 #define EACCES WSAEACCES
81 #define EADDRINUSE WSAEADDRINUSE
83 #define EADDRNOTAVAIL WSAEADDRNOTAVAIL
85 #define EAFNOSUPPORT WSAEAFNOSUPPORT
87 #define EALREADY WSAEALREADY
89 #define EBADF WSAEBADF
91 #define ECONNABORTED WSAECONNABORTED
93 #define ECONNREFUSED WSAECONNREFUSED
95 #define ECONNRESET WSAECONNRESET
97 #define EDESTADDRREQ WSAEDESTADDRREQ
99 #define EFAULT WSAEFAULT
101 #define EHOSTDOWN WSAEHOSTDOWN
103 #define EHOSTUNREACH WSAEHOSTUNREACH
105 #define EINPROGRESS WSAEINPROGRESS
107 #define EINTR WSAEINTR
109 #define EINVAL WSAEINVAL
111 #define EIO WSAEDISCON
113 #define EISCONN WSAEISCONN
115 #define ELOOP WSAELOOP
117 #define EMFILE WSAEMFILE
119 #define EMSGSIZE WSAEMSGSIZE
121 #define ENAMETOOLONG WSAENAMETOOLONG
123 #define ENETDOWN WSAENETDOWN
125 #define ENETRESET WSAENETRESET
127 #define ENETUNREACH WSAENETUNREACH
129 #define ENOBUFS WSAENOBUFS
131 #define ENOPROTOOPT WSAENOPROTOOPT
133 #define ENOTCONN WSAENOTCONN
135 #define ENOTSOCK WSAENOTSOCK
137 #define EOPNOTSUPP WSAEOPNOTSUPP
139 #define EPFNOSUPPORT WSAEPFNOSUPPORT
140 #undef EPROTONOSUPPORT
141 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
143 #define EPROTOTYPE WSAEPROTOTYPE
145 #define ESHUTDOWN WSAESHUTDOWN
146 #undef ESOCKTNOSUPPORT
147 #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
149 #define ETIMEDOUT WSAETIMEDOUT
151 #define ETOOMANYREFS WSAETOOMANYREFS
153 #define EWOULDBLOCK WSAEWOULDBLOCK
155 #define SHUT_RD SD_RECEIVE
156 #define SHUT_WR SD_SEND
157 #define SHUT_RDWR SD_BOTH
164 /* Allow a large number of fds for select. */
165 #define FD_SETSIZE 4096
167 /* These DEC C headers are not available when building with GCC. Order is
181 #if defined (__vxworks) && ! defined (__RTP__)
182 #include <sys/times.h>
184 #include <sys/time.h>
188 * RTEMS has these .h files but not until you have built and installed RTEMS.
189 * When building a C/C++ toolset, you also build the newlib C library, so the
190 * build procedure for an RTEMS GNAT toolset requires that you build a C/C++
191 * toolset, then build and install RTEMS with --enable-multilib, and finally
192 * build the Ada part of the toolset.
194 #if !(defined (VMS) || defined (__MINGW32__))
195 #include <sys/socket.h>
196 #include <netinet/in.h>
197 #include <netinet/tcp.h>
198 #include <sys/ioctl.h>
202 #if defined (_AIX) || defined (__FreeBSD__) || defined (__hpux__) || \
203 defined (_WIN32) || defined (__APPLE__)
204 # define HAVE_THREAD_SAFE_GETxxxBYyyy 1
206 #elif defined (linux) || defined (__GLIBC__) || \
207 (defined (sun) && defined (__SVR4) && !defined (__vxworks)) || \
209 # define HAVE_GETxxxBYyyy_R 1
213 * Properties of the unerlying NetDB library:
214 * Need_Netdb_Buffer __gnat_getXXXbyYYY expects a caller-supplied buffer
215 * Need_Netdb_Lock __gnat_getXXXbyYYY expects the caller to ensure
218 * See "Handling of gethostbyname, gethostbyaddr, getservbyname and
219 * getservbyport" in socket.c for details.
222 #if defined (HAVE_GETxxxBYyyy_R)
223 # define Need_Netdb_Buffer 1
224 # define Need_Netdb_Lock 0
227 # define Need_Netdb_Buffer 0
228 # if !defined (HAVE_THREAD_SAFE_GETxxxBYyyy)
229 # define Need_Netdb_Lock 1
231 # define Need_Netdb_Lock 0
235 #if defined (__FreeBSD__) || defined (__vxworks) || defined(__rtems__)
236 # define Has_Sockaddr_Len 1
238 # define Has_Sockaddr_Len 0
241 #if !(defined (__vxworks) || defined (_WIN32) || defined (__hpux__) || defined (VMS))
242 # define HAVE_INET_PTON
245 #endif /* defined(__nucleus__) */