source: ada-examples/gen-soconn/gsocket.h

ada-examples-4-10-branch ada-examples-4-10-2
Last change on this file was 57716a5, checked in by Joel Sherrill <joel.sherrill@…>, on 09/17/09 at 18:13:35

2009-09-17 Joel Sherrill <joel.sherrill@…>

  • Makefile, gen-soccon.c, gsocket.h, init.c: Make follow standard RTEMS test output format. Add output screens where appropriate.
  • Property mode set to 100644
File size: 6.7 KB
Line 
1/*
2 *  $Id$
3 */
4
5/****************************************************************************
6 *                                                                          *
7 *                         GNAT COMPILER COMPONENTS                         *
8 *                                                                          *
9 *                              G S O C K E T                               *
10 *                                                                          *
11 *                              C Header File                               *
12 *                                                                          *
13 *         Copyright (C) 2004-2008, Free Software Foundation, Inc.          *
14 *                                                                          *
15 * GNAT is free software;  you can  redistribute it  and/or modify it under *
16 * terms of the  GNU General Public License as published  by the Free Soft- *
17 * ware  Foundation;  either version 2,  or (at your option) any later ver- *
18 * sion.  GNAT is distributed in the hope that it will be useful, but WITH- *
19 * OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY *
20 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License *
21 * for  more details.  You should have  received  a copy of the GNU General *
22 * Public License  distributed with GNAT;  see file COPYING.  If not, write *
23 * to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, *
24 * Boston, MA 02110-1301, USA.                                              *
25 *                                                                          *
26 * As a  special  exception,  if you  link  this file  with other  files to *
27 * produce an executable,  this file does not by itself cause the resulting *
28 * executable to be covered by the GNU General Public License. This except- *
29 * ion does not  however invalidate  any other reasons  why the  executable *
30 * file might be covered by the  GNU Public License.                        *
31 *                                                                          *
32 * GNAT was originally developed  by the GNAT team at  New York University. *
33 * Extensive contributions were provided by Ada Core Technologies Inc.      *
34 *                                                                          *
35 ****************************************************************************/
36
37#ifndef _XOPEN_SOURCE_EXTENDED
38#define _XOPEN_SOURCE_EXTENDED 1
39/* For HP-UX */
40#endif
41
42#ifndef BSD_COMP
43#define BSD_COMP 1
44/* For Solaris */
45#endif
46
47#ifndef _ALL_SOURCE
48#define _ALL_SOURCE 1
49/* For AIX */
50#endif
51
52#ifndef _OSF_SOURCE
53#define _OSF_SOURCE 1
54/* For Tru64 */
55#endif
56
57#include <limits.h>
58
59#if defined(__vxworks)
60#include <vxWorks.h>
61#include <ioLib.h>
62#include <hostLib.h>
63#include <resolvLib.h>
64#define SHUT_RD         0
65#define SHUT_WR         1
66#define SHUT_RDWR       2
67
68#elif defined (WINNT)
69#define FD_SETSIZE 1024
70#include <windows.h>
71
72#ifdef __MINGW32__
73#include <winsock2.h>
74#include <ws2tcpip.h>
75
76#define EACCES          WSAEACCES
77#define EADDRINUSE      WSAEADDRINUSE
78#define EADDRNOTAVAIL   WSAEADDRNOTAVAIL
79#define EAFNOSUPPORT    WSAEAFNOSUPPORT
80#define EALREADY        WSAEALREADY
81#define EBADF           WSAEBADF
82#define ECONNABORTED    WSAECONNABORTED
83#define ECONNREFUSED    WSAECONNREFUSED
84#define ECONNRESET      WSAECONNRESET
85#define EDESTADDRREQ    WSAEDESTADDRREQ
86#define EFAULT          WSAEFAULT
87#define EHOSTDOWN       WSAEHOSTDOWN
88#define EHOSTUNREACH    WSAEHOSTUNREACH
89#define EINPROGRESS     WSAEINPROGRESS
90#define EINTR           WSAEINTR
91#define EINVAL          WSAEINVAL
92#define EIO             WSAEDISCON
93#define EISCONN         WSAEISCONN
94#define ELOOP           WSAELOOP
95#define EMFILE          WSAEMFILE
96#define EMSGSIZE        WSAEMSGSIZE
97#define ENAMETOOLONG    WSAENAMETOOLONG
98#define ENETDOWN        WSAENETDOWN
99#define ENETRESET       WSAENETRESET
100#define ENETUNREACH     WSAENETUNREACH
101#define ENOBUFS         WSAENOBUFS
102#define ENOPROTOOPT     WSAENOPROTOOPT
103#define ENOTCONN        WSAENOTCONN
104#define ENOTSOCK        WSAENOTSOCK
105#define EOPNOTSUPP      WSAEOPNOTSUPP
106#define EPFNOSUPPORT    WSAEPFNOSUPPORT
107#define EPROTONOSUPPORT WSAEPROTONOSUPPORT
108#define ENOTSOCK        WSAENOTSOCK
109#define EOPNOTSUPP      WSAEOPNOTSUPP
110#define EPFNOSUPPORT    WSAEPFNOSUPPORT
111#define EPROTONOSUPPORT WSAEPROTONOSUPPORT
112#define EPROTOTYPE      WSAEPROTOTYPE
113#define ESHUTDOWN       WSAESHUTDOWN
114#define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
115#define ETIMEDOUT       WSAETIMEDOUT
116#define ETOOMANYREFS    WSAETOOMANYREFS
117#define EWOULDBLOCK     WSAEWOULDBLOCK
118#define SHUT_RD         SD_RECEIVE
119#define SHUT_WR         SD_SEND
120#define SHUT_RDWR       SD_BOTH
121
122#endif
123
124#elif defined(VMS)
125#define FD_SETSIZE 4096
126#ifndef IN_RTS
127/* These DEC C headers are not available when building with GCC */
128#include <in.h>
129#include <tcp.h>
130#include <ioctl.h>
131#include <netdb.h>
132#endif
133
134#endif
135
136#ifndef __MINGW32__
137#include <errno.h>
138#endif
139
140#ifdef __vxworks
141#include <sys/times.h>
142#else
143#include <sys/time.h>
144#endif
145
146/*
147 * RTEMS has these .h files but not until you have built RTEMS.  When
148 * IN_RTS, you only have the .h files in the newlib C library.
149 * Because this file is also included from gen-soccon.c which is built
150 * to run on RTEMS (not IN_RTS), we must distinguish between IN_RTS
151 * and using this file to compile gen-soccon.
152 */
153#if !(defined (VMS) || defined (__MINGW32__) || \
154      (defined(__rtems__) && defined(IN_RTS)))
155#include <sys/socket.h>
156#include <netinet/in.h>
157#include <netinet/tcp.h>
158#include <sys/ioctl.h>
159#include <netdb.h>
160#endif
161
162/*
163 * Handling of gethostbyname, gethostbyaddr, getservbyname and getservbyport
164 * =========================================================================
165 *
166 * The default implementation of GNAT.Sockets.Thin requires that these
167 * operations be either thread safe, or that a reentrant version getXXXbyYYY_r
168 * be provided. In both cases, socket.c provides a __gnat_safe_getXXXbyYYY
169 * function with the same signature as getXXXbyYYY_r. If the operating
170 * system version of getXXXbyYYY is thread safe, the provided auxiliary
171 * buffer argument is unused and ignored.
172 *
173 * Target specific versions of GNAT.Sockets.Thin for platforms that can't
174 * fulfill these requirements must provide their own protection mechanism
175 * in Safe_GetXXXbyYYY, and if they require GNAT.Sockets to provide a buffer
176 * to this effect, then we need to set Need_Netdb_Buffer here (case of
177 * VxWorks and VMS).
178 */
179
180#if defined (_AIX) || defined (__FreeBSD__) || defined (__hpux__) || defined (__osf__) || defined (_WIN32) || defined (__APPLE__)
181# define HAVE_THREAD_SAFE_GETxxxBYyyy 1
182#elif defined (sgi) || defined (linux) || defined (__GLIBC__) || (defined (sun) && defined (__SVR4) && !defined (__vxworks))
183# define HAVE_GETxxxBYyyy_R 1
184#endif
185
186#if defined (HAVE_GETxxxBYyyy_R) || !defined (HAVE_THREAD_SAFE_GETxxxBYyyy)
187# define Need_Netdb_Buffer 1
188#else
189# define Need_Netdb_Buffer 0
190#endif
191
192#if defined (__FreeBSD__) || defined (__vxworks) || defined (__rtems__)
193# define Has_Sockaddr_Len 1
194#else
195# define Has_Sockaddr_Len 0
196#endif
Note: See TracBrowser for help on using the repository browser.