OSDN Git Service

7df7ea089cb5b7d9018e7fd258ddec802356bd39
[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-2006, 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  ****************************************************************************/
32
33 #ifndef _XOPEN_SOURCE_EXTENDED
34 #define _XOPEN_SOURCE_EXTENDED 1
35 /* For HP-UX */
36 #endif
37
38 #ifndef BSD_COMP
39 #define BSD_COMP 1
40 /* For Solaris */
41 #endif
42
43 #ifndef _ALL_SOURCE
44 #define _ALL_SOURCE 1
45 /* For AIX */
46 #endif
47
48 #ifndef _OSF_SOURCE
49 #define _OSF_SOURCE 1
50 /* For Tru64 */
51 #endif
52
53 #include <limits.h>
54
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
63
64 #elif defined (WINNT)
65 #define FD_SETSIZE 1024
66 #include <windows.h>
67
68 #ifdef __MINGW32__
69 #include <winsock2.h>
70 #include <ws2tcpip.h>
71
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
117
118 #endif
119
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
129
130 #endif
131
132 #ifndef __MINGW32__
133 #include <errno.h>
134 #endif
135
136 #ifdef __vxworks
137 #include <sys/times.h>
138 #else
139 #include <sys/time.h>
140 #endif
141
142 #if !(defined (VMS) || defined (__MINGW32__) || defined(__rtems__))
143 #include <sys/socket.h>
144 #include <netinet/in.h>
145 #include <netinet/tcp.h>
146 #include <sys/ioctl.h>
147 #include <netdb.h>
148 #endif
149
150 /*
151  * Handling of gethostbyname, gethostbyaddr, getservbyname and getservbyport
152  * =========================================================================
153  *
154  * The default implementation of GNAT.Sockets.Thin requires that these
155  * operations be either thread safe, or that a reentrant version getXXXbyYYY_r
156  * be provided. In both cases, socket.c provides a __gnat_safe_getXXXbyYYY
157  * function with the same signature as getXXXbyYYY_r. If the operating
158  * system version of getXXXbyYYY is thread safe, the provided auxiliary
159  * buffer argument is unused and ignored.
160  *
161  * Target specific versions of GNAT.Sockets.Thin for platforms that can't
162  * fulfill these requirements must provide their own protection mechanism
163  * in Safe_GetXXXbyYYY, and if they require GNAT.Sockets to provide a buffer
164  * to this effect, then we need to set Need_Netdb_Buffer here (case of
165  * VxWorks and VMS).
166  */
167
168 #if defined (_AIX) || defined (__FreeBSD__) || defined (__hpux__) || defined (__osf__) || defined (_WIN32) || defined (__APPLE__)
169 # define HAVE_THREAD_SAFE_GETxxxBYyyy 1
170 #elif defined (sgi) || defined (linux) || (defined (sun) && defined (__SVR4) && !defined (__vxworks))
171 # define HAVE_GETxxxBYyyy_R 1
172 #endif
173
174 #if defined (HAVE_GETxxxBYyyy_R) || !defined (HAVE_THREAD_SAFE_GETxxxBYyyy)
175 # define Need_Netdb_Buffer 1
176 #else
177 # define Need_Netdb_Buffer 0
178 #endif