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