unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
blob ad40fc9a231e0f2da579117052edb6a8774b9746 7746 bytes (raw)
name: nt/inc/sys/socket.h 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
 
/* Copyright (C) 1995, 2001-2016 Free Software Foundation, Inc.

This file is part of GNU Emacs.

GNU Emacs is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at
your option) any later version.

GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */


/* Workable version of <sys/socket.h> based on winsock.h */

#ifndef _SOCKET_H_
#define _SOCKET_H_

/* defeat the multiple include protection */
#ifdef _WINSOCKAPI_
#undef _WINSOCKAPI_
#endif
#ifdef _WINSOCK_H
#undef _WINSOCK_H
#endif

/* avoid confusion with our version of select */
#ifdef select
#undef select
#define MUST_REDEF_SELECT
#endif

/* avoid clashing with our version of FD_SET if already defined */
#ifdef FD_SET
#undef FD_SET
#undef FD_CLR
#undef FD_ISSET
#undef FD_ZERO
#endif

/* Avoid duplicate definition of timeval.  MinGW uses _TIMEVAL_DEFINED
   in sys/time.h to avoid that.  */
#if defined (HAVE_TIMEVAL) && defined (_MSC_VER)
#define timeval ws_timeval
#endif

#include <winsock2.h>
#include <ws2tcpip.h>
/* process.c uses uint16_t (from C99) for IPv6, but
   apparently it is not defined in some versions of mingw and msvc.  */
#ifndef UINT16_C
typedef unsigned short uint16_t;
#endif

/* redefine select to reference our version */
#ifdef MUST_REDEF_SELECT
#define select sys_select
#undef MUST_REDEF_SELECT
#endif

/* Revert to our version of FD_SET, but not when included from test
   programs run by configure.  */
#ifdef EMACS_CONFIG_H
#undef FD_SET
#undef FD_CLR
#undef FD_ISSET
#undef FD_ZERO

/* allow us to provide our own version of fd_set */
#define fd_set ws_fd_set
#include "w32.h"
#endif	/* EMACS_CONFIG_H */

#if defined (HAVE_TIMEVAL) && defined (_MSC_VER)
#undef timeval
#endif

/* shadow functions where we provide our own wrapper */
#define socket         sys_socket
#define bind           sys_bind
#define connect        sys_connect
#define htons          sys_htons
#define ntohs          sys_ntohs
#define inet_addr      sys_inet_addr
#define gethostname    sys_gethostname
#define gethostbyname  sys_gethostbyname
#define getpeername    sys_getpeername
#define getservbyname  sys_getservbyname
#define shutdown       sys_shutdown
#define setsockopt     sys_setsockopt
#define listen         sys_listen
#define getsockname    sys_getsockname
#define accept         sys_accept
#define recvfrom       sys_recvfrom
#define sendto         sys_sendto

int sys_socket(int af, int type, int protocol);
int sys_bind (int s, const struct sockaddr *addr, int namelen);
int sys_connect (int s, const struct sockaddr *addr, int namelen);
u_short sys_htons (u_short hostshort);
u_short sys_ntohs (u_short netshort);
unsigned long sys_inet_addr (const char * cp);
int sys_gethostname (char * name, int namelen);
struct hostent * sys_gethostbyname (const char * name);
struct servent * sys_getservbyname (const char * name, const char * proto);
int sys_getpeername (int s, struct sockaddr *addr, int * namelen);
int sys_shutdown (int socket, int how);
int sys_setsockopt (int s, int level, int oname, const void * oval, int olen);
int sys_listen (int s, int backlog);
int sys_getsockname (int s, struct sockaddr * name, int * namelen);
int sys_accept (int s, struct sockaddr *addr, int *addrlen);
int sys_recvfrom (int s, char *buf, int len, int flags,
		  struct sockaddr *from, int * fromlen);
int sys_sendto (int s, const char * buf, int len, int flags,
		const struct sockaddr *to, int tolen);

/* In addition to wrappers for the winsock functions, we also provide
   an fcntl function, for setting sockets to non-blocking mode.  */
int fcntl (int s, int cmd, int options);
#define F_SETFL   4
#define F_SETFD   2
#define O_NONBLOCK  04000
#define O_CLOEXEC O_NOINHERIT
#define F_DUPFD_CLOEXEC 0x40000000
#define FD_CLOEXEC 1

/* we are providing a real h_errno variable */
#undef h_errno
extern int h_errno;

/* map winsock error codes to standard names */
#if defined(EWOULDBLOCK)
#undef EWOULDBLOCK
#endif
#define EWOULDBLOCK             WSAEWOULDBLOCK
#if defined(EINPROGRESS)
#undef EINPROGRESS
#endif
#define EINPROGRESS             WSAEINPROGRESS
#if defined(EALREADY)
#undef EALREADY
#endif
#define EALREADY                WSAEALREADY
#if defined(ENOTSOCK)
#undef ENOTSOCK
#endif
#define ENOTSOCK                WSAENOTSOCK
#if defined(EDESTADDRREQ)
#undef EDESTADDRREQ
#endif
#define EDESTADDRREQ            WSAEDESTADDRREQ
#if defined(EMSGSIZE)
#undef EMSGSIZE
#endif
#define EMSGSIZE                WSAEMSGSIZE
#if defined(EPROTOTYPE)
#undef EPROTOTYPE
#endif
#define EPROTOTYPE              WSAEPROTOTYPE
#if defined(ENOPROTOOPT)
#undef ENOPROTOOPT
#endif
#define ENOPROTOOPT             WSAENOPROTOOPT
#if defined(EPROTONOSUPPORT)
#undef EPROTONOSUPPORT
#endif
#define EPROTONOSUPPORT         WSAEPROTONOSUPPORT
#if defined(ESOCKTNOSUPPORT)
#undef ESOCKTNOSUPPORT
#endif
#define ESOCKTNOSUPPORT         WSAESOCKTNOSUPPORT
#if defined(EOPNOTSUPP)
#undef EOPNOTSUPP
#endif
#define EOPNOTSUPP              WSAEOPNOTSUPP
#if defined(EPFNOSUPPORT)
#undef EPFNOSUPPORT
#endif
#define EPFNOSUPPORT            WSAEPFNOSUPPORT
#if defined(EAFNOSUPPORT)
#undef EAFNOSUPPORT
#endif
#define EAFNOSUPPORT            WSAEAFNOSUPPORT
#if defined(EADDRINUSE)
#undef EADDRINUSE
#endif
#define EADDRINUSE              WSAEADDRINUSE
#if defined(EADDRNOTAVAIL)
#undef EADDRNOTAVAIL
#endif
#define EADDRNOTAVAIL           WSAEADDRNOTAVAIL
#if defined(ENETDOWN)
#undef ENETDOWN
#endif
#define ENETDOWN                WSAENETDOWN
#if defined(ENETUNREACH)
#undef ENETUNREACH
#endif
#define ENETUNREACH             WSAENETUNREACH
#if defined(ENETRESET)
#undef ENETRESET
#endif
#define ENETRESET               WSAENETRESET
#if defined(ECONNABORTED)
#undef ECONNABORTED
#endif
#define ECONNABORTED            WSAECONNABORTED
#if defined(ECONNRESET)
#undef ECONNRESET
#endif
#define ECONNRESET              WSAECONNRESET
#if defined(ENOBUFS)
#undef ENOBUFS
#endif
#define ENOBUFS                 WSAENOBUFS
#if defined(EISCONN)
#undef EISCONN
#endif
#define EISCONN                 WSAEISCONN
#if defined(ENOTCONN)
#undef ENOTCONN
#endif
#define ENOTCONN                WSAENOTCONN
#if defined(ESHUTDOWN)
#undef ESHUTDOWN
#endif
#define ESHUTDOWN               WSAESHUTDOWN
#if defined(ETOOMANYREFS)
#undef ETOOMANYREFS
#endif
#define ETOOMANYREFS            WSAETOOMANYREFS
#if defined(ETIMEDOUT)
#undef ETIMEDOUT
#endif
#define ETIMEDOUT               WSAETIMEDOUT
#if defined(ECONNREFUSED)
#undef ECONNREFUSED
#endif
#define ECONNREFUSED            WSAECONNREFUSED
#if defined(ELOOP)
#undef ELOOP
#endif
#define ELOOP                   WSAELOOP
/* #define ENAMETOOLONG            WSAENAMETOOLONG */
#if defined(EHOSTDOWN)
#undef EHOSTDOWN
#endif
#define EHOSTDOWN               WSAEHOSTDOWN
#if defined(EHOSTUNREACH)
#undef EHOSTUNREACH
#endif
#define EHOSTUNREACH            WSAEHOSTUNREACH
/* #define ENOTEMPTY               WSAENOTEMPTY */
#if defined(EPROCLIM)
#undef EPROCLIM
#endif
#define EPROCLIM                WSAEPROCLIM
#if defined(EUSERS)
#undef EUSERS
#endif
#define EUSERS                  WSAEUSERS
#if defined(EDQUOT)
#undef EDQUOT
#endif
#define EDQUOT                  WSAEDQUOT
#if defined(ESTALE)
#undef ESTALE
#endif
#define ESTALE                  WSAESTALE
#if defined(EREMOTE)
#undef EREMOTE
#endif
#define EREMOTE                 WSAEREMOTE

#endif /* _SOCKET_H_ */

/* end of socket.h */

debug log:

solving ad40fc9 ...
found ad40fc9 in https://git.savannah.gnu.org/cgit/emacs.git

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).