1 /****************************************************************************
3 * GNAT COMPILER COMPONENTS *
9 * Copyright (C) 2004-2009, 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__)
34 #warning Sockets not supported on this platform
41 #ifndef _XOPEN_SOURCE_EXTENDED
42 #define _XOPEN_SOURCE_EXTENDED 1
64 #if defined(__vxworks)
73 #define FD_SETSIZE 1024
81 #define EACCES WSAEACCES
83 #define EADDRINUSE WSAEADDRINUSE
85 #define EADDRNOTAVAIL WSAEADDRNOTAVAIL
87 #define EAFNOSUPPORT WSAEAFNOSUPPORT
89 #define EALREADY WSAEALREADY
91 #define EBADF WSAEBADF
93 #define ECONNABORTED WSAECONNABORTED
95 #define ECONNREFUSED WSAECONNREFUSED
97 #define ECONNRESET WSAECONNRESET
99 #define EDESTADDRREQ WSAEDESTADDRREQ
101 #define EFAULT WSAEFAULT
103 #define EHOSTDOWN WSAEHOSTDOWN
105 #define EHOSTUNREACH WSAEHOSTUNREACH
107 #define EINPROGRESS WSAEINPROGRESS
109 #define EINTR WSAEINTR
111 #define EINVAL WSAEINVAL
113 #define EIO WSAEDISCON
115 #define EISCONN WSAEISCONN
117 #define ELOOP WSAELOOP
119 #define EMFILE WSAEMFILE
121 #define EMSGSIZE WSAEMSGSIZE
123 #define ENAMETOOLONG WSAENAMETOOLONG
125 #define ENETDOWN WSAENETDOWN
127 #define ENETRESET WSAENETRESET
129 #define ENETUNREACH WSAENETUNREACH
131 #define ENOBUFS WSAENOBUFS
133 #define ENOPROTOOPT WSAENOPROTOOPT
135 #define ENOTCONN WSAENOTCONN
137 #define ENOTSOCK WSAENOTSOCK
139 #define EOPNOTSUPP WSAEOPNOTSUPP
141 #define EPFNOSUPPORT WSAEPFNOSUPPORT
142 #undef EPROTONOSUPPORT
143 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
145 #define EPROTOTYPE WSAEPROTOTYPE
147 #define ESHUTDOWN WSAESHUTDOWN
148 #undef ESOCKTNOSUPPORT
149 #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
151 #define ETIMEDOUT WSAETIMEDOUT
153 #define ETOOMANYREFS WSAETOOMANYREFS
155 #define EWOULDBLOCK WSAEWOULDBLOCK
157 #define SHUT_RD SD_RECEIVE
158 #define SHUT_WR SD_SEND
159 #define SHUT_RDWR SD_BOTH
164 #define FD_SETSIZE 4096
166 /* These DEC C headers are not available when building with GCC */
175 #if defined (__vxworks) && ! defined (__RTP__)
176 #include <sys/times.h>
178 #include <sys/time.h>
182 * RTEMS has these .h files but not until you have built RTEMS. When
183 * IN_RTS, you only have the .h files in the newlib C library.
184 * Because this file is also included from gen-soccon.c which is built
185 * to run on RTEMS (not IN_RTS), we must distinguish between IN_RTS
186 * and using this file to compile gen-soccon.
188 #if !(defined (VMS) || defined (__MINGW32__) || \
189 (defined(__rtems__) && defined(IN_RTS)))
190 #include <sys/socket.h>
191 #include <netinet/in.h>
192 #include <netinet/tcp.h>
193 #include <sys/ioctl.h>
198 * Handling of gethostbyname, gethostbyaddr, getservbyname and getservbyport
199 * =========================================================================
201 * The default implementation of GNAT.Sockets.Thin requires that these
202 * operations be either thread safe, or that a reentrant version getXXXbyYYY_r
203 * be provided. In both cases, socket.c provides a __gnat_safe_getXXXbyYYY
204 * function with the same signature as getXXXbyYYY_r. If the operating
205 * system version of getXXXbyYYY is thread safe, the provided auxiliary
206 * buffer argument is unused and ignored.
208 * Target specific versions of GNAT.Sockets.Thin for platforms that can't
209 * fulfill these requirements must provide their own protection mechanism
210 * in Safe_GetXXXbyYYY, and if they require GNAT.Sockets to provide a buffer
211 * to this effect, then we need to set Need_Netdb_Buffer here (case of
215 #if defined (_AIX) || defined (__FreeBSD__) || defined (__hpux__) || defined (__osf__) || defined (_WIN32) || defined (__APPLE__)
216 # define HAVE_THREAD_SAFE_GETxxxBYyyy 1
217 #elif defined (sgi) || defined (linux) || defined (__GLIBC__) || (defined (sun) && defined (__SVR4) && !defined (__vxworks)) || defined(__rtems__)
218 # define HAVE_GETxxxBYyyy_R 1
221 #if defined (HAVE_GETxxxBYyyy_R) || !defined (HAVE_THREAD_SAFE_GETxxxBYyyy)
222 # define Need_Netdb_Buffer 1
224 # define Need_Netdb_Buffer 0
227 #if defined (__FreeBSD__) || defined (__vxworks) || defined(__rtems__)
228 # define Has_Sockaddr_Len 1
230 # define Has_Sockaddr_Len 0
233 #if !(defined (__vxworks) || defined (_WIN32) || defined (__hpux__) || defined (VMS))
234 # define HAVE_INET_PTON
237 #endif /* defined(__nucleus__) */