OSDN Git Service

* gcc-interface/misc.c (gnat_expand_expr): Remove.
[pf3gnuchains/gcc-fork.git] / gcc / ada / gsocket.h
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-2009, 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 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.                                     *
17  *                                                                          *
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.               *
21  *                                                                          *
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/>.                                          *
26  *                                                                          *
27  * GNAT was originally developed  by the GNAT team at  New York University. *
28  * Extensive contributions were provided by Ada Core Technologies Inc.      *
29  *                                                                          *
30  ****************************************************************************/
31
32 #if defined(__nucleus__)
33
34 #warning Sockets not supported on this platform
35 #undef HAVE_SOCKETS
36
37 #else
38
39 #define HAVE_SOCKETS
40
41 #ifndef _XOPEN_SOURCE_EXTENDED
42 #define _XOPEN_SOURCE_EXTENDED 1
43 /* For HP-UX */
44 #endif
45
46 #ifndef BSD_COMP
47 #define BSD_COMP 1
48 /* For Solaris */
49 #endif
50
51 #ifndef _ALL_SOURCE
52 #define _ALL_SOURCE 1
53 /* For AIX */
54 #endif
55
56 #ifndef _OSF_SOURCE
57 #define _OSF_SOURCE 1
58 /* For Tru64 */
59 #endif
60
61 #include <limits.h>
62 #include <errno.h>
63
64 #if defined(__vxworks)
65 #include <vxWorks.h>
66 #include <ioLib.h>
67 #include <hostLib.h>
68 #if (_WRS_VXWORKS_MAJOR != 6) && ! defined (__RTP__)
69 #include <resolvLib.h>
70 #endif
71 #define SHUT_RD         0
72 #define SHUT_WR         1
73 #define SHUT_RDWR       2
74
75 #elif defined (WINNT)
76 #define FD_SETSIZE 1024
77 #include <windows.h>
78
79 #ifdef __MINGW32__
80 #include <winsock2.h>
81 #include <ws2tcpip.h>
82
83 #undef  EACCES
84 #define EACCES          WSAEACCES
85 #undef  EADDRINUSE
86 #define EADDRINUSE      WSAEADDRINUSE
87 #undef  EADDRNOTAVAIL
88 #define EADDRNOTAVAIL   WSAEADDRNOTAVAIL
89 #undef  EAFNOSUPPORT
90 #define EAFNOSUPPORT    WSAEAFNOSUPPORT
91 #undef  EALREADY
92 #define EALREADY        WSAEALREADY
93 #undef  EBADF
94 #define EBADF           WSAEBADF
95 #undef  ECONNABORTED
96 #define ECONNABORTED    WSAECONNABORTED
97 #undef  ECONNREFUSED
98 #define ECONNREFUSED    WSAECONNREFUSED
99 #undef  ECONNRESET
100 #define ECONNRESET      WSAECONNRESET
101 #undef  EDESTADDRREQ
102 #define EDESTADDRREQ    WSAEDESTADDRREQ
103 #undef  EFAULT
104 #define EFAULT          WSAEFAULT
105 #undef  EHOSTDOWN
106 #define EHOSTDOWN       WSAEHOSTDOWN
107 #undef  EHOSTUNREACH
108 #define EHOSTUNREACH    WSAEHOSTUNREACH
109 #undef  EINPROGRESS
110 #define EINPROGRESS     WSAEINPROGRESS
111 #undef  EINTR
112 #define EINTR           WSAEINTR
113 #undef  EINVAL
114 #define EINVAL          WSAEINVAL
115 #undef  EIO
116 #define EIO             WSAEDISCON
117 #undef  EISCONN
118 #define EISCONN         WSAEISCONN
119 #undef  ELOOP
120 #define ELOOP           WSAELOOP
121 #undef  EMFILE
122 #define EMFILE          WSAEMFILE
123 #undef  EMSGSIZE
124 #define EMSGSIZE        WSAEMSGSIZE
125 #undef  ENAMETOOLONG
126 #define ENAMETOOLONG    WSAENAMETOOLONG
127 #undef  ENETDOWN
128 #define ENETDOWN        WSAENETDOWN
129 #undef  ENETRESET
130 #define ENETRESET       WSAENETRESET
131 #undef  ENETUNREACH
132 #define ENETUNREACH     WSAENETUNREACH
133 #undef  ENOBUFS
134 #define ENOBUFS         WSAENOBUFS
135 #undef  ENOPROTOOPT
136 #define ENOPROTOOPT     WSAENOPROTOOPT
137 #undef  ENOTCONN
138 #define ENOTCONN        WSAENOTCONN
139 #undef  ENOTSOCK
140 #define ENOTSOCK        WSAENOTSOCK
141 #undef  EOPNOTSUPP
142 #define EOPNOTSUPP      WSAEOPNOTSUPP
143 #undef  EPFNOSUPPORT
144 #define EPFNOSUPPORT    WSAEPFNOSUPPORT
145 #undef  EPROTONOSUPPORT
146 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
147 #undef  EPROTOTYPE
148 #define EPROTOTYPE      WSAEPROTOTYPE
149 #undef  ESHUTDOWN
150 #define ESHUTDOWN       WSAESHUTDOWN
151 #undef  ESOCKTNOSUPPORT
152 #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
153 #undef  ETIMEDOUT
154 #define ETIMEDOUT       WSAETIMEDOUT
155 #undef  ETOOMANYREFS
156 #define ETOOMANYREFS    WSAETOOMANYREFS
157 #undef  EWOULDBLOCK
158 #define EWOULDBLOCK     WSAEWOULDBLOCK
159
160 #define SHUT_RD         SD_RECEIVE
161 #define SHUT_WR         SD_SEND
162 #define SHUT_RDWR       SD_BOTH
163
164 #endif
165
166 #elif defined(VMS)
167 #define FD_SETSIZE 4096
168 #ifndef IN_RTS
169 /* These DEC C headers are not available when building with GCC */
170 #include <in.h>
171 #include <tcp.h>
172 #include <ioctl.h>
173 #include <netdb.h>
174 #endif
175
176 #endif
177
178 #if defined (__vxworks) && ! defined (__RTP__)
179 #include <sys/times.h>
180 #else
181 #include <sys/time.h>
182 #endif
183
184 /*
185  * RTEMS has these .h files but not until you have built RTEMS.  When
186  * IN_RTS, you only have the .h files in the newlib C library.
187  * Because this file is also included from gen-soccon.c which is built
188  * to run on RTEMS (not IN_RTS), we must distinguish between IN_RTS
189  * and using this file to compile gen-soccon.
190  */
191 #if !(defined (VMS) || defined (__MINGW32__) || \
192       (defined(__rtems__) && defined(IN_RTS)))
193 #include <sys/socket.h>
194 #include <netinet/in.h>
195 #include <netinet/tcp.h>
196 #include <sys/ioctl.h>
197 #include <netdb.h>
198 #endif
199
200 /*
201  * Handling of gethostbyname, gethostbyaddr, getservbyname and getservbyport
202  * =========================================================================
203  *
204  * The default implementation of GNAT.Sockets.Thin requires that these
205  * operations be either thread safe, or that a reentrant version getXXXbyYYY_r
206  * be provided. In both cases, socket.c provides a __gnat_safe_getXXXbyYYY
207  * function with the same signature as getXXXbyYYY_r. If the operating
208  * system version of getXXXbyYYY is thread safe, the provided auxiliary
209  * buffer argument is unused and ignored.
210  *
211  * Target specific versions of GNAT.Sockets.Thin for platforms that can't
212  * fulfill these requirements must provide their own protection mechanism
213  * in Safe_GetXXXbyYYY, and if they require GNAT.Sockets to provide a buffer
214  * to this effect, then we need to set Need_Netdb_Buffer here (case of
215  * VxWorks and VMS).
216  */
217
218 #if defined (_AIX) || defined (__FreeBSD__) || defined (__hpux__) || defined (__osf__) || defined (_WIN32) || defined (__APPLE__)
219 # define HAVE_THREAD_SAFE_GETxxxBYyyy 1
220 #elif defined (sgi) || defined (linux) || defined (__GLIBC__) || (defined (sun) && defined (__SVR4) && !defined (__vxworks)) || defined(__rtems__)
221 # define HAVE_GETxxxBYyyy_R 1
222 #endif
223
224 #if defined (HAVE_GETxxxBYyyy_R) || !defined (HAVE_THREAD_SAFE_GETxxxBYyyy)
225 # define Need_Netdb_Buffer 1
226 #else
227 # define Need_Netdb_Buffer 0
228 #endif
229
230 #if defined (__FreeBSD__) || defined (__vxworks) || defined(__rtems__)
231 # define Has_Sockaddr_Len 1
232 #else
233 # define Has_Sockaddr_Len 0
234 #endif
235
236 #endif /* defined(__nucleus__) */