From cd3467bb01cb5bd98b2978fb50bdaa2f3227c980 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Thu, 14 Aug 2003 17:13:52 +0000 Subject: Attempt to make sockets code work right on windows. svn:r398 --- src/common/util.h | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'src/common/util.h') diff --git a/src/common/util.h b/src/common/util.h index 3569632e9..0590f8ed7 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -13,6 +13,12 @@ #ifdef HAVE_TIME_H #include #endif +#if _MSC_VER > 1300 +#include +#include +#elif defined(_MSC_VER) +#include +#endif #ifndef HAVE_GETTIMEOFDAY #ifdef HAVE_FTIME #define USING_FAKE_TIMEVAL @@ -23,7 +29,7 @@ #endif #endif -#ifdef _MSC_VER +#ifdef MS_WINDOWS /* Windows names string functions funnily. */ #define strncasecmp strnicmp #define strcasecmp stricmp @@ -55,4 +61,24 @@ void spawn_exit(); int tor_socketpair(int family, int type, int protocol, int fd[2]); +/* For stupid historical reasons, windows sockets have an independent set of + * errnos which they use as the fancy strikes them. + */ +#ifdef MS_WINDOWS +#define ERRNO_EAGAIN(e) ((e) == EAGAIN || \ + (e) == WSAEWOULDBLOCK || \ + (e) == EWOULDBLOCK) +#define ERRNO_EINPROGRESS(e) ((e) == EINPROGRESS || \ + (e) == WSAEINPROGRESS) +#define ERRNO_CONN_EINPROGRESS(e) ((e) == EINPROGRESS || \ + (e) == WSAEINPROGRESS || (e) == WSAEINVAL) +int correct_socket_errno(int s); +#else +#define ERRNO_EAGAIN(e) ((e) == EAGAIN) +#define ERRNO_EINPROGRESS(e) ((e) == EINPROGRESS) +#define ERRNO_CONN_EINPROGRESS(e) ((e) == EINPROGRESS) +#define correct_socket_errno(s) (errno) +#endif + + #endif -- cgit v1.2.3