From 11167e1f08b15381d5e7834baf7f0a6811af1985 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Peter=20=C3=85strand=20=28astrand=29?= Date: Thu, 5 Feb 2015 11:10:32 +0100 Subject: [PATCH] Use a common header file for Windows errno names. In earlier Visual Studio and MinGW editions, BSD socket errno:s were left undefined. This is no longer the case. This may cause build or runtime errors. To avoid this, we are using a common header file which corrects all definitions. This header will also be used with other projects such as sercd, unfs3, PulseAudio etc. --- common/os/winerrno.h | 101 +++++++++++++++++++++++++++++++++++++ common/rdr/FdInStream.cxx | 3 +- common/rdr/FdOutStream.cxx | 4 +- vncviewer/vncviewer.cxx | 1 + 4 files changed, 104 insertions(+), 5 deletions(-) create mode 100644 common/os/winerrno.h diff --git a/common/os/winerrno.h b/common/os/winerrno.h new file mode 100644 index 00000000..aebbdbe7 --- /dev/null +++ b/common/os/winerrno.h @@ -0,0 +1,101 @@ + +/* Generated with: +cat /usr/i686-pc-mingw32/sys-root/mingw/include/winerror.h \ + | awk '/#define WSAE.*WSABASE/{gsub("WSA", ""); print "#undef " $2 "\n#define " $2 " WSA" $2}' \ + | egrep -v '_QOS|PROVIDER|PROCTABLE' +*/ + +#undef EINTR +#define EINTR WSAEINTR +#undef EBADF +#define EBADF WSAEBADF +#undef EACCES +#define EACCES WSAEACCES +#undef EFAULT +#define EFAULT WSAEFAULT +#undef EINVAL +#define EINVAL WSAEINVAL +#undef EMFILE +#define EMFILE WSAEMFILE +#undef EWOULDBLOCK +#define EWOULDBLOCK WSAEWOULDBLOCK +#undef EINPROGRESS +#define EINPROGRESS WSAEINPROGRESS +#undef EALREADY +#define EALREADY WSAEALREADY +#undef ENOTSOCK +#define ENOTSOCK WSAENOTSOCK +#undef EDESTADDRREQ +#define EDESTADDRREQ WSAEDESTADDRREQ +#undef EMSGSIZE +#define EMSGSIZE WSAEMSGSIZE +#undef EPROTOTYPE +#define EPROTOTYPE WSAEPROTOTYPE +#undef ENOPROTOOPT +#define ENOPROTOOPT WSAENOPROTOOPT +#undef EPROTONOSUPPORT +#define EPROTONOSUPPORT WSAEPROTONOSUPPORT +#undef ESOCKTNOSUPPORT +#define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT +#undef EOPNOTSUPP +#define EOPNOTSUPP WSAEOPNOTSUPP +#undef EPFNOSUPPORT +#define EPFNOSUPPORT WSAEPFNOSUPPORT +#undef EAFNOSUPPORT +#define EAFNOSUPPORT WSAEAFNOSUPPORT +#undef EADDRINUSE +#define EADDRINUSE WSAEADDRINUSE +#undef EADDRNOTAVAIL +#define EADDRNOTAVAIL WSAEADDRNOTAVAIL +#undef ENETDOWN +#define ENETDOWN WSAENETDOWN +#undef ENETUNREACH +#define ENETUNREACH WSAENETUNREACH +#undef ENETRESET +#define ENETRESET WSAENETRESET +#undef ECONNABORTED +#define ECONNABORTED WSAECONNABORTED +#undef ECONNRESET +#define ECONNRESET WSAECONNRESET +#undef ENOBUFS +#define ENOBUFS WSAENOBUFS +#undef EISCONN +#define EISCONN WSAEISCONN +#undef ENOTCONN +#define ENOTCONN WSAENOTCONN +#undef ESHUTDOWN +#define ESHUTDOWN WSAESHUTDOWN +#undef ETOOMANYREFS +#define ETOOMANYREFS WSAETOOMANYREFS +#undef ETIMEDOUT +#define ETIMEDOUT WSAETIMEDOUT +#undef ECONNREFUSED +#define ECONNREFUSED WSAECONNREFUSED +#undef ELOOP +#define ELOOP WSAELOOP +#undef ENAMETOOLONG +#define ENAMETOOLONG WSAENAMETOOLONG +#undef EHOSTDOWN +#define EHOSTDOWN WSAEHOSTDOWN +#undef EHOSTUNREACH +#define EHOSTUNREACH WSAEHOSTUNREACH +#undef ENOTEMPTY +#define ENOTEMPTY WSAENOTEMPTY +#undef EPROCLIM +#define EPROCLIM WSAEPROCLIM +#undef EUSERS +#define EUSERS WSAEUSERS +#undef EDQUOT +#define EDQUOT WSAEDQUOT +#undef ESTALE +#define ESTALE WSAESTALE +#undef EREMOTE +#define EREMOTE WSAEREMOTE +#undef EDISCON +#define EDISCON WSAEDISCON +#undef ENOMORE +#define ENOMORE WSAENOMORE +#undef ECANCELLED +#define ECANCELLED WSAECANCELLED +#undef EREFUSED +#define EREFUSED WSAEREFUSED diff --git a/common/rdr/FdInStream.cxx b/common/rdr/FdInStream.cxx index adb14c50..22433a1b 100644 --- a/common/rdr/FdInStream.cxx +++ b/common/rdr/FdInStream.cxx @@ -31,8 +31,7 @@ #define close closesocket #undef errno #define errno WSAGetLastError() -#undef EINTR -#define EINTR WSAEINTR +#include #else #include #include diff --git a/common/rdr/FdOutStream.cxx b/common/rdr/FdOutStream.cxx index 533faa3f..83360d64 100644 --- a/common/rdr/FdOutStream.cxx +++ b/common/rdr/FdOutStream.cxx @@ -26,11 +26,9 @@ #ifdef _WIN32 #include #define write(s,b,l) send(s,(const char*)b,l,0) -#define EWOULDBLOCK WSAEWOULDBLOCK #undef errno #define errno WSAGetLastError() -#undef EINTR -#define EINTR WSAEINTR +#include #else #include #include diff --git a/vncviewer/vncviewer.cxx b/vncviewer/vncviewer.cxx index 7fb712ab..d980ed2c 100644 --- a/vncviewer/vncviewer.cxx +++ b/vncviewer/vncviewer.cxx @@ -32,6 +32,7 @@ #include #ifdef WIN32 +#include #include #define mkdir(path, mode) _mkdir(path) #endif -- 2.39.5