summaryrefslogtreecommitdiff
path: root/setup_once.h
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2007-02-15 16:23:24 (GMT)
committerYang Tse <yangsita@gmail.com>2007-02-15 16:23:24 (GMT)
commitc2f42a9bf4290e45ef4f9cced856ca03268089ef (patch)
tree3a729cceb92a8cafdf369bc4f9b4ba927be33086 /setup_once.h
parent3c769f98e8fe55bf160ed7f62e7526f3d42f0276 (diff)
downloadc-ares-c2f42a9bf4290e45ef4f9cced856ca03268089ef.zip
c-ares-c2f42a9bf4290e45ef4f9cced856ca03268089ef.tar.gz
c-ares-c2f42a9bf4290e45ef4f9cced856ca03268089ef.tar.bz2
introduce uppercase macros SOCKERRNO, SET_SOCKERRNO(), ERRNO and SET_ERRNO()
making them available to any source code file which includes "setup.h". Macro SOCKERRNO / SET_SOCKERRNO() returns / sets the *socket-related* errno (or equivalent) on this platform to hide platform details to code using it. Macro ERRNO / SET_ERRNO() returns / sets the NOT *socket-related* errno (or equivalent) on this platform to hide platform details to code using it.
Diffstat (limited to 'setup_once.h')
-rw-r--r--setup_once.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/setup_once.h b/setup_once.h
index 202b0ca..25eacf5 100644
--- a/setup_once.h
+++ b/setup_once.h
@@ -158,5 +158,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 */