diff options
author | Yang Tse <yangsita@gmail.com> | 2007-02-15 16:23:24 +0000 |
---|---|---|
committer | Yang Tse <yangsita@gmail.com> | 2007-02-15 16:23:24 +0000 |
commit | d21e4eb8ae10d704a01cfd0278f4efd636842457 (patch) | |
tree | 6e4377a7bcdb55bb9e88f23c3c1ff65e5fefa39d | |
parent | d381dd68cfe4db83a27bbd5d149339f0ed1e4047 (diff) |
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.
-rw-r--r-- | ares/setup_once.h | 28 | ||||
-rw-r--r-- | lib/setup_once.h | 28 |
2 files changed, 56 insertions, 0 deletions
diff --git a/ares/setup_once.h b/ares/setup_once.h index 202b0cadc..25eacf51e 100644 --- a/ares/setup_once.h +++ b/ares/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 */ 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 */ |