compat: document error-code mapping
See: https://docs.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2
This commit is contained in:
1 file changed
+5
-3
+5
-3
@@ -37,9 +37,12 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// We map Linux / BSD error functions and codes, to the equivalent
|
||||||
|
// Windows definitions, and use the WSA* names throughout our code.
|
||||||
|
// Note that glibc defines EWOULDBLOCK as EAGAIN (see errno.h).
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
typedef unsigned int SOCKET;
|
typedef unsigned int SOCKET;
|
||||||
#include <errno.h>
|
#include <cerrno>
|
||||||
#define WSAGetLastError() errno
|
#define WSAGetLastError() errno
|
||||||
#define WSAEINVAL EINVAL
|
#define WSAEINVAL EINVAL
|
||||||
#define WSAEWOULDBLOCK EWOULDBLOCK
|
#define WSAEWOULDBLOCK EWOULDBLOCK
|
||||||
@@ -51,14 +54,13 @@ typedef unsigned int SOCKET;
|
|||||||
#define INVALID_SOCKET (SOCKET)(~0)
|
#define INVALID_SOCKET (SOCKET)(~0)
|
||||||
#define SOCKET_ERROR -1
|
#define SOCKET_ERROR -1
|
||||||
#else
|
#else
|
||||||
#ifndef WSAEAGAIN
|
// WSAEAGAIN doesn't exist on Windows
|
||||||
#ifdef EAGAIN
|
#ifdef EAGAIN
|
||||||
#define WSAEAGAIN EAGAIN
|
#define WSAEAGAIN EAGAIN
|
||||||
#else
|
#else
|
||||||
#define WSAEAGAIN WSAEWOULDBLOCK
|
#define WSAEAGAIN WSAEWOULDBLOCK
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
// Windows doesn't define S_IRUSR or S_IWUSR. We define both
|
// Windows doesn't define S_IRUSR or S_IWUSR. We define both
|
||||||
// here, with the same values as glibc (see stat.h).
|
// here, with the same values as glibc (see stat.h).
|
||||||
|
|||||||
Reference in new issue
Block a user