2008-05-30 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / ada / gsocket.h
blob8b8c83808b6a6c95a595ea7d7891181441acfedd
1 /****************************************************************************
2 * *
3 * GNAT COMPILER COMPONENTS *
4 * *
5 * G S O C K E T *
6 * *
7 * C Header File *
8 * *
9 * Copyright (C) 2004-2008, Free Software Foundation, Inc. *
10 * *
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. *
21 * *
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. *
27 * *
28 * GNAT was originally developed by the GNAT team at New York University. *
29 * Extensive contributions were provided by Ada Core Technologies Inc. *
30 * *
31 ****************************************************************************/
33 #ifndef _XOPEN_SOURCE_EXTENDED
34 #define _XOPEN_SOURCE_EXTENDED 1
35 /* For HP-UX */
36 #endif
38 #ifndef BSD_COMP
39 #define BSD_COMP 1
40 /* For Solaris */
41 #endif
43 #ifndef _ALL_SOURCE
44 #define _ALL_SOURCE 1
45 /* For AIX */
46 #endif
48 #ifndef _OSF_SOURCE
49 #define _OSF_SOURCE 1
50 /* For Tru64 */
51 #endif
53 #include <limits.h>
55 #if defined(__vxworks)
56 #include <vxWorks.h>
57 #include <ioLib.h>
58 #include <hostLib.h>
59 #include <resolvLib.h>
60 #define SHUT_RD 0
61 #define SHUT_WR 1
62 #define SHUT_RDWR 2
64 #elif defined (WINNT)
65 #define FD_SETSIZE 1024
66 #include <windows.h>
68 #ifdef __MINGW32__
69 #include <winsock2.h>
70 #include <ws2tcpip.h>
72 #define EACCES WSAEACCES
73 #define EADDRINUSE WSAEADDRINUSE
74 #define EADDRNOTAVAIL WSAEADDRNOTAVAIL
75 #define EAFNOSUPPORT WSAEAFNOSUPPORT
76 #define EALREADY WSAEALREADY
77 #define EBADF WSAEBADF
78 #define ECONNABORTED WSAECONNABORTED
79 #define ECONNREFUSED WSAECONNREFUSED
80 #define ECONNRESET WSAECONNRESET
81 #define EDESTADDRREQ WSAEDESTADDRREQ
82 #define EFAULT WSAEFAULT
83 #define EHOSTDOWN WSAEHOSTDOWN
84 #define EHOSTUNREACH WSAEHOSTUNREACH
85 #define EINPROGRESS WSAEINPROGRESS
86 #define EINTR WSAEINTR
87 #define EINVAL WSAEINVAL
88 #define EIO WSAEDISCON
89 #define EISCONN WSAEISCONN
90 #define ELOOP WSAELOOP
91 #define EMFILE WSAEMFILE
92 #define EMSGSIZE WSAEMSGSIZE
93 #define ENAMETOOLONG WSAENAMETOOLONG
94 #define ENETDOWN WSAENETDOWN
95 #define ENETRESET WSAENETRESET
96 #define ENETUNREACH WSAENETUNREACH
97 #define ENOBUFS WSAENOBUFS
98 #define ENOPROTOOPT WSAENOPROTOOPT
99 #define ENOTCONN WSAENOTCONN
100 #define ENOTSOCK WSAENOTSOCK
101 #define EOPNOTSUPP WSAEOPNOTSUPP
102 #define EPFNOSUPPORT WSAEPFNOSUPPORT
103 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
104 #define ENOTSOCK WSAENOTSOCK
105 #define EOPNOTSUPP WSAEOPNOTSUPP
106 #define EPFNOSUPPORT WSAEPFNOSUPPORT
107 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
108 #define EPROTOTYPE WSAEPROTOTYPE
109 #define ESHUTDOWN WSAESHUTDOWN
110 #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
111 #define ETIMEDOUT WSAETIMEDOUT
112 #define ETOOMANYREFS WSAETOOMANYREFS
113 #define EWOULDBLOCK WSAEWOULDBLOCK
114 #define SHUT_RD SD_RECEIVE
115 #define SHUT_WR SD_SEND
116 #define SHUT_RDWR SD_BOTH
118 #endif
120 #elif defined(VMS)
121 #define FD_SETSIZE 4096
122 #ifndef IN_RTS
123 /* These DEC C headers are not available when building with GCC */
124 #include <in.h>
125 #include <tcp.h>
126 #include <ioctl.h>
127 #include <netdb.h>
128 #endif
130 #endif
132 #ifndef __MINGW32__
133 #include <errno.h>
134 #endif
136 #ifdef __vxworks
137 #include <sys/times.h>
138 #else
139 #include <sys/time.h>
140 #endif
143 * RTEMS has these .h files but not until you have built RTEMS. When
144 * IN_RTS, you only have the .h files in the newlib C library.
145 * Because this file is also included from gen-soccon.c which is built
146 * to run on RTEMS (not IN_RTS), we must distinguish between IN_RTS
147 * and using this file to compile gen-soccon.
149 #if !(defined (VMS) || defined (__MINGW32__) || \
150 (defined(__rtems__) && defined(IN_RTS)))
151 #include <sys/socket.h>
152 #include <netinet/in.h>
153 #include <netinet/tcp.h>
154 #include <sys/ioctl.h>
155 #include <netdb.h>
156 #endif
159 * Handling of gethostbyname, gethostbyaddr, getservbyname and getservbyport
160 * =========================================================================
162 * The default implementation of GNAT.Sockets.Thin requires that these
163 * operations be either thread safe, or that a reentrant version getXXXbyYYY_r
164 * be provided. In both cases, socket.c provides a __gnat_safe_getXXXbyYYY
165 * function with the same signature as getXXXbyYYY_r. If the operating
166 * system version of getXXXbyYYY is thread safe, the provided auxiliary
167 * buffer argument is unused and ignored.
169 * Target specific versions of GNAT.Sockets.Thin for platforms that can't
170 * fulfill these requirements must provide their own protection mechanism
171 * in Safe_GetXXXbyYYY, and if they require GNAT.Sockets to provide a buffer
172 * to this effect, then we need to set Need_Netdb_Buffer here (case of
173 * VxWorks and VMS).
176 #if defined (_AIX) || defined (__FreeBSD__) || defined (__hpux__) || defined (__osf__) || defined (_WIN32) || defined (__APPLE__)
177 # define HAVE_THREAD_SAFE_GETxxxBYyyy 1
178 #elif defined (sgi) || defined (linux) || defined (__GLIBC__) || (defined (sun) && defined (__SVR4) && !defined (__vxworks))
179 # define HAVE_GETxxxBYyyy_R 1
180 #endif
182 #if defined (HAVE_GETxxxBYyyy_R) || !defined (HAVE_THREAD_SAFE_GETxxxBYyyy)
183 # define Need_Netdb_Buffer 1
184 #else
185 # define Need_Netdb_Buffer 0
186 #endif
188 #if defined (__FreeBSD__) || defined (__vxworks)
189 # define Has_Sockaddr_Len 1
190 #else
191 # define Has_Sockaddr_Len 0
192 #endif