1 /****************************************************************************
3 * GNAT COMPILER COMPONENTS *
9 * Copyright (C) 2004-2011, 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)
34 #warning Sockets not supported on these platforms
41 #ifndef _XOPEN_SOURCE_EXTENDED
42 #define _XOPEN_SOURCE_EXTENDED 1
61 /** No system header may be included prior to this point since on some targets
62 ** we need to redefine FD_SETSIZE.
65 /* Target-specific includes and definitions */
67 #if defined(__vxworks)
76 #define FD_SETSIZE 1024
83 #define EACCES WSAEACCES
85 #define EADDRINUSE WSAEADDRINUSE
87 #define EADDRNOTAVAIL WSAEADDRNOTAVAIL
89 #define EAFNOSUPPORT WSAEAFNOSUPPORT
91 #define EALREADY WSAEALREADY
93 #define EBADF WSAEBADF
95 #define ECONNABORTED WSAECONNABORTED
97 #define ECONNREFUSED WSAECONNREFUSED
99 #define ECONNRESET WSAECONNRESET
101 #define EDESTADDRREQ WSAEDESTADDRREQ
103 #define EFAULT WSAEFAULT
105 #define EHOSTDOWN WSAEHOSTDOWN
107 #define EHOSTUNREACH WSAEHOSTUNREACH
109 #define EINPROGRESS WSAEINPROGRESS
111 #define EINTR WSAEINTR
113 #define EINVAL WSAEINVAL
115 #define EIO WSAEDISCON
117 #define EISCONN WSAEISCONN
119 #define ELOOP WSAELOOP
121 #define EMFILE WSAEMFILE
123 #define EMSGSIZE WSAEMSGSIZE
125 #define ENAMETOOLONG WSAENAMETOOLONG
127 #define ENETDOWN WSAENETDOWN
129 #define ENETRESET WSAENETRESET
131 #define ENETUNREACH WSAENETUNREACH
133 #define ENOBUFS WSAENOBUFS
135 #define ENOPROTOOPT WSAENOPROTOOPT
137 #define ENOTCONN WSAENOTCONN
139 #define ENOTSOCK WSAENOTSOCK
141 #define EOPNOTSUPP WSAEOPNOTSUPP
143 #define EPFNOSUPPORT WSAEPFNOSUPPORT
144 #undef EPROTONOSUPPORT
145 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
147 #define EPROTOTYPE WSAEPROTOTYPE
149 #define ESHUTDOWN WSAESHUTDOWN
150 #undef ESOCKTNOSUPPORT
151 #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
153 #define ETIMEDOUT WSAETIMEDOUT
155 #define ETOOMANYREFS WSAETOOMANYREFS
157 #define EWOULDBLOCK WSAEWOULDBLOCK
159 #define SHUT_RD SD_RECEIVE
160 #define SHUT_WR SD_SEND
161 #define SHUT_RDWR SD_BOTH
168 /* Allow a large number of fds for select. */
169 #define FD_SETSIZE 4096
171 /* These DEC C headers are not available when building with GCC. Order is
185 #if defined (__vxworks) && ! defined (__RTP__)
186 #include <sys/times.h>
188 #include <sys/time.h>
192 * RTEMS has these .h files but not until you have built and installed RTEMS.
193 * When building a C/C++ toolset, you also build the newlib C library, so the
194 * build procedure for an RTEMS GNAT toolset requires that you build a C/C++
195 * toolset, then build and install RTEMS with --enable-multilib, and finally
196 * build the Ada part of the toolset.
198 #if !(defined (VMS) || defined (__MINGW32__))
199 #include <sys/socket.h>
200 #include <netinet/in.h>
201 #include <netinet/tcp.h>
202 #include <sys/ioctl.h>
206 #if defined (_AIX) || defined (__FreeBSD__) || defined (__hpux__) || \
207 defined (__osf__) || defined (_WIN32) || defined (__APPLE__)
208 # define HAVE_THREAD_SAFE_GETxxxBYyyy 1
210 #elif defined (sgi) || defined (linux) || defined (__GLIBC__) || \
211 (defined (sun) && defined (__SVR4) && !defined (__vxworks)) || \
213 # define HAVE_GETxxxBYyyy_R 1
217 * Properties of the unerlying NetDB library:
218 * Need_Netdb_Buffer __gnat_getXXXbyYYY expects a caller-supplied buffer
219 * Need_Netdb_Lock __gnat_getXXXbyYYY expects the caller to ensure
222 * See "Handling of gethostbyname, gethostbyaddr, getservbyname and
223 * getservbyport" in socket.c for details.
226 #if defined (HAVE_GETxxxBYyyy_R)
227 # define Need_Netdb_Buffer 1
228 # define Need_Netdb_Lock 0
231 # define Need_Netdb_Buffer 0
232 # if !defined (HAVE_THREAD_SAFE_GETxxxBYyyy)
233 # define Need_Netdb_Lock 1
235 # define Need_Netdb_Lock 0
239 #if defined (__FreeBSD__) || defined (__vxworks) || defined(__rtems__)
240 # define Has_Sockaddr_Len 1
242 # define Has_Sockaddr_Len 0
245 #if !(defined (__vxworks) || defined (_WIN32) || defined (__hpux__) || defined (VMS))
246 # define HAVE_INET_PTON
249 #endif /* defined(__nucleus__) */