Skip to content

Commit 3be7ee7

Browse files
committed
1 parent 3f1d2fb commit 3be7ee7

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/compat/compat.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,12 @@
3737
#include <unistd.h>
3838
#endif
3939

40+
// We map Linux / BSD error functions and codes, to the equivalent
41+
// Windows definitions, and use the WSA* names throughout our code.
42+
// Note that glibc defines EWOULDBLOCK as EAGAIN (see errno.h).
4043
#ifndef WIN32
4144
typedef unsigned int SOCKET;
42-
#include <errno.h>
45+
#include <cerrno>
4346
#define WSAGetLastError() errno
4447
#define WSAEINVAL EINVAL
4548
#define WSAEWOULDBLOCK EWOULDBLOCK
@@ -51,14 +54,13 @@ typedef unsigned int SOCKET;
5154
#define INVALID_SOCKET (SOCKET)(~0)
5255
#define SOCKET_ERROR -1
5356
#else
54-
#ifndef WSAEAGAIN
57+
// WSAEAGAIN doesn't exist on Windows
5558
#ifdef EAGAIN
5659
#define WSAEAGAIN EAGAIN
5760
#else
5861
#define WSAEAGAIN WSAEWOULDBLOCK
5962
#endif
6063
#endif
61-
#endif
6264

6365
// Windows doesn't define S_IRUSR or S_IWUSR. We define both
6466
// here, with the same values as glibc (see stat.h).

0 commit comments

Comments
 (0)