1 /****************************************************************************
3 * GNAT COMPILER COMPONENTS *
9 * Copyright (C) 2004-2008, 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 2, 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. See the GNU General Public License *
17 * for more details. You should have received a copy of the GNU General *
18 * Public License distributed with GNAT; see file COPYING. If not, write *
19 * to the Free Software Foundation, 51 Franklin Street, Fifth Floor, *
20 * Boston, MA 02110-1301, USA. *
22 * As a special exception, if you link this file with other files to *
23 * produce an executable, this file does not by itself cause the resulting *
24 * executable to be covered by the GNU General Public License. This except- *
25 * ion does not however invalidate any other reasons why the executable *
26 * file might be covered by the GNU Public License. *
28 * GNAT was originally developed by the GNAT team at New York University. *
29 * Extensive contributions were provided by Ada Core Technologies Inc. *
31 ****************************************************************************/
33 #if defined(__nucleus__)
35 #warning Sockets not supported on this platform
42 #ifndef _XOPEN_SOURCE_EXTENDED
43 #define _XOPEN_SOURCE_EXTENDED 1
65 #if defined(__vxworks)
69 #include <resolvLib.h>
75 #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
166 #define FD_SETSIZE 4096
168 /* These DEC C headers are not available when building with GCC */
178 #include <sys/times.h>
180 #include <sys/time.h>
184 * RTEMS has these .h files but not until you have built RTEMS. When
185 * IN_RTS, you only have the .h files in the newlib C library.
186 * Because this file is also included from gen-soccon.c which is built
187 * to run on RTEMS (not IN_RTS), we must distinguish between IN_RTS
188 * and using this file to compile gen-soccon.
190 #if !(defined (VMS) || defined (__MINGW32__) || \
191 (defined(__rtems__) && defined(IN_RTS)))
192 #include <sys/socket.h>
193 #include <netinet/in.h>
194 #include <netinet/tcp.h>
195 #include <sys/ioctl.h>
200 * Handling of gethostbyname, gethostbyaddr, getservbyname and getservbyport
201 * =========================================================================
203 * The default implementation of GNAT.Sockets.Thin requires that these
204 * operations be either thread safe, or that a reentrant version getXXXbyYYY_r
205 * be provided. In both cases, socket.c provides a __gnat_safe_getXXXbyYYY
206 * function with the same signature as getXXXbyYYY_r. If the operating
207 * system version of getXXXbyYYY is thread safe, the provided auxiliary
208 * buffer argument is unused and ignored.
210 * Target specific versions of GNAT.Sockets.Thin for platforms that can't
211 * fulfill these requirements must provide their own protection mechanism
212 * in Safe_GetXXXbyYYY, and if they require GNAT.Sockets to provide a buffer
213 * to this effect, then we need to set Need_Netdb_Buffer here (case of
217 #if defined (_AIX) || defined (__FreeBSD__) || defined (__hpux__) || defined (__osf__) || defined (_WIN32) || defined (__APPLE__)
218 # define HAVE_THREAD_SAFE_GETxxxBYyyy 1
219 #elif defined (sgi) || defined (linux) || defined (__GLIBC__) || (defined (sun) && defined (__SVR4) && !defined (__vxworks)) || defined(__rtems__)
220 # define HAVE_GETxxxBYyyy_R 1
223 #if defined (HAVE_GETxxxBYyyy_R) || !defined (HAVE_THREAD_SAFE_GETxxxBYyyy)
224 # define Need_Netdb_Buffer 1
226 # define Need_Netdb_Buffer 0
229 #if defined (__FreeBSD__) || defined (__vxworks) || defined(__rtems__)
230 # define Has_Sockaddr_Len 1
232 # define Has_Sockaddr_Len 0
235 #endif /* defined(__nucleus__) */