From c9bdd50270d2eb60488ef38c56f990b781bbb3d2 Mon Sep 17 00:00:00 2001 From: henrique Date: Wed, 25 Jun 2014 13:13:23 +0200 Subject: [PATCH] THRIFT-2579 C++ lib Windows CE support --- lib/cpp/src/thrift/transport/PlatformSocket.h | 6 +++++- lib/cpp/src/thrift/windows/WinFcntl.cpp | 6 ++++++ lib/cpp/src/thrift/windows/WinFcntl.h | 8 ++++++++ lib/cpp/src/thrift/windows/config.h | 5 ++++- 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/lib/cpp/src/thrift/transport/PlatformSocket.h b/lib/cpp/src/thrift/transport/PlatformSocket.h index 019f4cb4..d28978ef 100644 --- a/lib/cpp/src/thrift/transport/PlatformSocket.h +++ b/lib/cpp/src/thrift/transport/PlatformSocket.h @@ -50,7 +50,11 @@ # define THRIFT_READ _read # define THRIFT_FSTAT _fstat # define THRIFT_STAT _stat -# define THRIFT_GAI_STRERROR gai_strerrorA +# ifdef _WIN32_WCE +# define THRIFT_GAI_STRERROR(...) thrift_wstr2str(gai_strerrorW(__VA_ARGS__)) +# else +# define THRIFT_GAI_STRERROR gai_strerrorA +# endif # define THRIFT_SSIZET ptrdiff_t # define THRIFT_SNPRINTF _snprintf # define THRIFT_SLEEP_SEC thrift_sleep diff --git a/lib/cpp/src/thrift/windows/WinFcntl.cpp b/lib/cpp/src/thrift/windows/WinFcntl.cpp index f7b43377..3dd4e3da 100644 --- a/lib/cpp/src/thrift/windows/WinFcntl.cpp +++ b/lib/cpp/src/thrift/windows/WinFcntl.cpp @@ -102,3 +102,9 @@ int thrift_poll(THRIFT_POLLFD *fdArray, ULONG nfds, INT timeout) } #endif // WINVER +#ifdef _WIN32_WCE +std::string thrift_wstr2str(std::wstring ws) { + std::string s(ws.begin(), ws.end()); + return s; +} +#endif diff --git a/lib/cpp/src/thrift/windows/WinFcntl.h b/lib/cpp/src/thrift/windows/WinFcntl.h index f30c0de4..118c9a4d 100644 --- a/lib/cpp/src/thrift/windows/WinFcntl.h +++ b/lib/cpp/src/thrift/windows/WinFcntl.h @@ -28,6 +28,10 @@ #error This is a MSVC header only. #endif +#ifdef _WIN32_WCE +#include +#endif + // Win32 #include #include @@ -45,4 +49,8 @@ int thrift_fcntl(THRIFT_SOCKET fd, int cmd, int flags); int thrift_poll(THRIFT_POLLFD *fdArray, ULONG nfds, INT timeout); } +#ifdef _WIN32_WCE +std::string thrift_wstr2str(std::wstring ws); +#endif + #endif // _THRIFT_WINDOWS_FCNTL_H_ diff --git a/lib/cpp/src/thrift/windows/config.h b/lib/cpp/src/thrift/windows/config.h index 0555e079..dca55c9e 100644 --- a/lib/cpp/src/thrift/windows/config.h +++ b/lib/cpp/src/thrift/windows/config.h @@ -84,7 +84,10 @@ typedef boost::uint8_t uint8_t; // windows #include #include +#ifdef _WIN32_WCE +#pragma comment(lib, "Ws2.lib") +#else #pragma comment(lib, "Ws2_32.lib") #pragma comment(lib, "advapi32.lib") //For security APIs in TPipeServer - +#endif #endif // _THRIFT_WINDOWS_CONFIG_H_ -- 2.17.1