aboutsummaryrefslogtreecommitdiff
path: root/lib/setup_once.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/setup_once.h')
-rw-r--r--lib/setup_once.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/setup_once.h b/lib/setup_once.h
index e5a1117ac..38d86db6f 100644
--- a/lib/setup_once.h
+++ b/lib/setup_once.h
@@ -165,5 +165,33 @@ typedef int sig_atomic_t;
#endif
+/*
+ * Macro SOCKERRNO / SET_SOCKERRNO() returns / sets the *socket-related* errno
+ * (or equivalent) on this platform to hide platform details to code using it.
+ */
+
+#ifdef USE_WINSOCK
+#define SOCKERRNO ((int)WSAGetLastError())
+#define SET_SOCKERRNO(x) (WSASetLastError((int)(x)))
+#else
+#define SOCKERRNO (errno)
+#define SET_SOCKERRNO(x) (errno = (x))
+#endif
+
+
+/*
+ * Macro ERRNO / SET_ERRNO() returns / sets the NOT *socket-related* errno
+ * (or equivalent) on this platform to hide platform details to code using it.
+ */
+
+#ifdef WIN32
+#define ERRNO ((int)GetLastError())
+#define SET_ERRNO(x) (SetLastError((DWORD)(x)))
+#else
+#define ERRNO (errno)
+#define SET_ERRNO(x) (errno = (x))
+#endif
+
+
#endif /* __SETUP_ONCE_H */