Skip to content

Commit 3bbefb6

Browse files
committed
Add #ifdefs around #defines
In order to avoid redefinition warnings, check before we define.
1 parent 5fd03ec commit 3bbefb6

File tree

1 file changed

+50
-3
lines changed
  • contrib/win32/win32compat/includes/sys

1 file changed

+50
-3
lines changed

contrib/win32/win32compat/includes/sys/socket.h

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ int WSHELPshutdown(int sfd, int how);
4040
int WSHELPaccept(int sfd, struct sockaddr* addr, int* addrlen);
4141
int WSHELPselect (int sfds, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, const struct timeval *timeout);
4242

43+
4344
/* Other helpers */
4445
void WSHELPinitialize();
4546
int map_standard_descriptor(int *fd);
4647
void allocate_standard_descriptor(int fd);
4748

49+
4850
/* Redirect callers of socket functions to use our indirection functions */
4951
#if NEED_FUNC_MACROS
5052
#define isatty(sfd) WSHELPisatty(sfd)
@@ -127,30 +129,75 @@ int WSHELPclose(int sfd);
127129

128130

129131
/* Errno helpers */
132+
#ifndef ENETDOWN
130133
#define ENETDOWN WSAENETDOWN
134+
#endif
135+
#ifndef EAFNOSUPPORT
131136
#define EAFNOSUPPORT WSAEAFNOSUPPORT
137+
#endif
138+
#ifndef EINPROGRESS
132139
#define EINPROGRESS WSAEINPROGRESS
140+
#endif
141+
#ifndef EXX
133142
#define EXX WSAEMFILE
143+
#endif
144+
#ifndef EXX1
134145
#define EXX1 WSAENOBUFS
146+
#endif
147+
#ifndef EPROTONOSUPPORT
135148
#define EPROTONOSUPPORT WSAEPROTONOSUPPORT
149+
#endif
150+
#ifndef EPROTOTYPE
136151
#define EPROTOTYPE WSAEPROTOTYPE
152+
#endif
153+
#ifndef ESOCKTNOSUPPORT
137154
#define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
155+
#endif
156+
#ifndef EADDRINUSE
138157
#define EADDRINUSE WSAEADDRINUSE
139-
// in errno.h #define EINVAL WSAEINVAL
158+
#endif
159+
#ifndef EISCONN
140160
#define EISCONN WSAEISCONN
161+
#endif
162+
#ifndef ENOTSOCK
141163
#define ENOTSOCK WSAENOTSOCK
164+
#endif
165+
#ifndef EOPNOTSUPP
142166
#define EOPNOTSUPP WSAENOTSUPP
143-
// in errno.h #define EINTR WSAEINTR
167+
#endif
168+
#ifndef EALREADY
144169
#define EALREADY WSAEALREADY
170+
#endif
171+
#ifndef ECONNREFUSED
145172
#define ECONNREFUSED WSAECONNREFUSED
146-
// in errno.h #define EFAULT WSAEFAULT
173+
#endif
174+
#ifndef ENOTUNREACH
147175
#define ENOTUNREACH WSAENOTUNREACH
176+
#endif
177+
#ifndef EHOSTUNREACH
148178
#define EHOSTUNREACH WSAEHOSTUNREACH
179+
#endif
180+
#ifndef ETIMEDOUT
149181
#define ETIMEDOUT WSAETIMEDOUT
182+
#endif
183+
#ifndef EWOULDBLOCK
150184
#define EWOULDBLOCK WSAEWOULDBLOCK
185+
#endif
186+
#ifndef EACCES
151187
#define EACCES WSAEACCESS
188+
#endif
189+
#ifndef ECONNRESET
152190
#define ECONNRESET WSAECONNRESET
191+
#endif
192+
#ifndef ENOPROTOOPT
153193
#define ENOPROTOOPT WSAENOPROTOOPT
194+
#endif
195+
#ifndef EPFNOSUPPORT
154196
#define EPFNOSUPPORT WSAEPFNOSUPPORT
197+
#endif
198+
#ifndef ENOTCONN
155199
#define ENOTCONN WSAENOTCONN
156200
#endif
201+
202+
203+
#endif

0 commit comments

Comments
 (0)