]> granicus.if.org Git - curl/commitdiff
introduce uppercase macros SOCKERRNO, SET_SOCKERRNO(), ERRNO and SET_ERRNO()
authorYang Tse <yangsita@gmail.com>
Thu, 15 Feb 2007 16:23:24 +0000 (16:23 +0000)
committerYang Tse <yangsita@gmail.com>
Thu, 15 Feb 2007 16:23:24 +0000 (16:23 +0000)
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.

ares/setup_once.h
lib/setup_once.h

index 202b0cadc2d919760b32bc436a5103ec238c26f3..25eacf51ed6eee53178966d2de5428218102ab6f 100644 (file)
@@ -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 */
 
index e5a1117acb345735ee52db5138169a4d3bff027a..38d86db6f439eada9a0f78831b78a83fe638175e 100644 (file)
@@ -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 */