aboutsummaryrefslogtreecommitdiff
path: root/src/compat
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2022-06-28 17:37:32 +0100
committerfanquake <fanquake@gmail.com>2022-07-20 13:10:12 +0100
commit3be7ee750fd0d31d6e995140025e0d18e6aa788e (patch)
treeee3521b6c7ce56160096cb3d81713b2817a9994e /src/compat
parent3f1d2fb035bf6413c33847326ac5938802cd5860 (diff)
downloadbitcoin-3be7ee750fd0d31d6e995140025e0d18e6aa788e.tar.xz
compat: document error-code mapping
See: https://docs.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2
Diffstat (limited to 'src/compat')
-rw-r--r--src/compat/compat.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/compat/compat.h b/src/compat/compat.h
index 633aa6f3b5..670da9a631 100644
--- a/src/compat/compat.h
+++ b/src/compat/compat.h
@@ -37,9 +37,12 @@
#include <unistd.h>
#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
typedef unsigned int SOCKET;
-#include <errno.h>
+#include <cerrno>
#define WSAGetLastError() errno
#define WSAEINVAL EINVAL
#define WSAEWOULDBLOCK EWOULDBLOCK
@@ -51,14 +54,13 @@ typedef unsigned int SOCKET;
#define INVALID_SOCKET (SOCKET)(~0)
#define SOCKET_ERROR -1
#else
-#ifndef WSAEAGAIN
+// WSAEAGAIN doesn't exist on Windows
#ifdef EAGAIN
#define WSAEAGAIN EAGAIN
#else
#define WSAEAGAIN WSAEWOULDBLOCK
#endif
#endif
-#endif
// Windows doesn't define S_IRUSR or S_IWUSR. We define both
// here, with the same values as glibc (see stat.h).