1 /****************************************************************************
3 * GNAT COMPILER COMPONENTS *
9 * Copyright (C) 2004-2010, 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
64 #if defined(__vxworks)
73 #define FD_SETSIZE 1024
80 #define EACCES WSAEACCES
82 #define EADDRINUSE WSAEADDRINUSE
84 #define EADDRNOTAVAIL WSAEADDRNOTAVAIL
86 #define EAFNOSUPPORT WSAEAFNOSUPPORT
88 #define EALREADY WSAEALREADY
90 #define EBADF WSAEBADF
92 #define ECONNABORTED WSAECONNABORTED
94 #define ECONNREFUSED WSAECONNREFUSED
96 #define ECONNRESET WSAECONNRESET
98 #define EDESTADDRREQ WSAEDESTADDRREQ
100 #define EFAULT WSAEFAULT
102 #define EHOSTDOWN WSAEHOSTDOWN
104 #define EHOSTUNREACH WSAEHOSTUNREACH
106 #define EINPROGRESS WSAEINPROGRESS
108 #define EINTR WSAEINTR
110 #define EINVAL WSAEINVAL
112 #define EIO WSAEDISCON
114 #define EISCONN WSAEISCONN
116 #define ELOOP WSAELOOP
118 #define EMFILE WSAEMFILE
120 #define EMSGSIZE WSAEMSGSIZE
122 #define ENAMETOOLONG WSAENAMETOOLONG
124 #define ENETDOWN WSAENETDOWN
126 #define ENETRESET WSAENETRESET
128 #define ENETUNREACH WSAENETUNREACH
130 #define ENOBUFS WSAENOBUFS
132 #define ENOPROTOOPT WSAENOPROTOOPT
134 #define ENOTCONN WSAENOTCONN
136 #define ENOTSOCK WSAENOTSOCK
138 #define EOPNOTSUPP WSAEOPNOTSUPP
140 #define EPFNOSUPPORT WSAEPFNOSUPPORT
141 #undef EPROTONOSUPPORT
142 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
144 #define EPROTOTYPE WSAEPROTOTYPE
146 #define ESHUTDOWN WSAESHUTDOWN
147 #undef ESOCKTNOSUPPORT
148 #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
150 #define ETIMEDOUT WSAETIMEDOUT
152 #define ETOOMANYREFS WSAETOOMANYREFS
154 #define EWOULDBLOCK WSAEWOULDBLOCK
156 #define SHUT_RD SD_RECEIVE
157 #define SHUT_WR SD_SEND
158 #define SHUT_RDWR SD_BOTH
165 #define FD_SETSIZE 4096
167 /* These DEC C headers are not available when building with GCC */
176 #if defined (__vxworks) && ! defined (__RTP__)
177 #include <sys/times.h>
179 #include <sys/time.h>
183 * RTEMS has these .h files but not until you have built and installed
184 * RTEMS. When building a C/C++ toolset, you also build the newlib C library.
185 * So the build procedure for an RTEMS GNAT toolset requires that
186 * you build a C/C++ toolset, then build and install RTEMS with
187 * --enable-multilib, and finally build the Ada part of the toolset.
189 #if !(defined (VMS) || defined (__MINGW32__))
190 #include <sys/socket.h>
191 #include <netinet/in.h>
192 #include <netinet/tcp.h>
193 #include <sys/ioctl.h>
197 #if defined (_AIX) || defined (__FreeBSD__) || defined (__hpux__) || \
198 defined (__osf__) || defined (_WIN32) || defined (__APPLE__)
199 # define HAVE_THREAD_SAFE_GETxxxBYyyy 1
201 #elif defined (sgi) || defined (linux) || defined (__GLIBC__) || \
202 (defined (sun) && defined (__SVR4) && !defined (__vxworks)) || \
204 # define HAVE_GETxxxBYyyy_R 1
208 * Properties of the unerlying NetDB library:
209 * Need_Netdb_Buffer __gnat_getXXXbyYYY expects a caller-supplied buffer
210 * Need_Netdb_Lock __gnat_getXXXbyYYY expects the caller to ensure
213 * See "Handling of gethostbyname, gethostbyaddr, getservbyname and
214 * getservbyport" in socket.c for details.
217 #if defined (HAVE_GETxxxBYyyy_R)
218 # define Need_Netdb_Buffer 1
219 # define Need_Netdb_Lock 0
222 # define Need_Netdb_Buffer 0
223 # if !defined (HAVE_THREAD_SAFE_GETxxxBYyyy)
224 # define Need_Netdb_Lock 1
226 # define Need_Netdb_Lock 0
230 #if defined (__FreeBSD__) || defined (__vxworks) || defined(__rtems__)
231 # define Has_Sockaddr_Len 1
233 # define Has_Sockaddr_Len 0
236 #if !(defined (__vxworks) || defined (_WIN32) || defined (__hpux__) || defined (VMS))
237 # define HAVE_INET_PTON
240 #endif /* defined(__nucleus__) */