THRIFT-2579 C++ lib Windows CE support
authorhenrique <henrique@apache.org>
Wed, 25 Jun 2014 11:13:23 +0000 (13:13 +0200)
committerhenrique <henrique@apache.org>
Wed, 25 Jun 2014 11:13:23 +0000 (13:13 +0200)
lib/cpp/src/thrift/transport/PlatformSocket.h
lib/cpp/src/thrift/windows/WinFcntl.cpp
lib/cpp/src/thrift/windows/WinFcntl.h
lib/cpp/src/thrift/windows/config.h

index 019f4cb..d28978e 100644 (file)
 #  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
index f7b4337..3dd4e3d 100644 (file)
@@ -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
index f30c0de..118c9a4 100644 (file)
 #error This is a MSVC header only.
 #endif
 
+#ifdef _WIN32_WCE
+#include <string>
+#endif
+
 // Win32
 #include <Winsock2.h>
 #include <thrift/transport/PlatformSocket.h>
@@ -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_
index 0555e07..dca55c9 100644 (file)
@@ -84,7 +84,10 @@ typedef boost::uint8_t    uint8_t;
 // windows
 #include <Winsock2.h>
 #include <ws2tcpip.h>
+#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_