diff --git a/lib/cpp/README_WINDOWS b/lib/cpp/README_WINDOWS index 27520bcfc..ad4cac407 100644 --- a/lib/cpp/README_WINDOWS +++ b/lib/cpp/README_WINDOWS @@ -33,7 +33,7 @@ Thrift is divided into two libraries. libthrift The core Thrift library contains all the core Thrift code. It requires - boost shared pointers and pthreads_win32. + boost shared pointers and boost thread. libthriftnb This library contains the Thrift nonblocking server, which uses libevent. @@ -46,7 +46,7 @@ Linking Against Thrift ====================== You need to link your project that uses thrift against all the thrift -dependancies; in the case of libthrift, pthreads_win32, boost and for +dependancies; in the case of libthrift, boost and for libthriftnb, libevent. In the project properties you must also set HAVE_CONFIG_H as force include @@ -58,29 +58,35 @@ Dependencies boost shared pointers http://www.boost.org/libs/smart_ptr/smart_ptr.htm +boost thread +http://www.boost.org/doc/libs/release/doc/html/thread.html + libevent (for libthriftnb only) http://monkey.org/~provos/libevent/ -pthreads win32 -http://sources.redhat.com/pthreads-win32/ +Notes on boost thread (static vs shared): +========================================= + +By default lib/cpp/windows/force_inc.h defines: + +#define BOOST_ALL_NO_LIB 1 +#define BOOST_THREAD_NO_LIB 1 + +This has for effect to have the host application linking against Thrift +to have to link with boost thread as a static library. + +If you wanted instead to link with boost thread as a shared library, +you'll need to uncomment those two lines, and recompile. Known issues ============ -- Endianess has not been fully tested, may not work with doubles. -- Currently does not support the non-blocking connect path. -- Only supports the creation of clients, server sockets are not yet ported. - Does not support named pipes. (Supported in unix through unix domain sockets). TODO ==== - Port remaining classes in libthrift: - - TFDTransport - - TFileTransport - - THttpClient - - THttpServer - - TSimpleFileTransport - TSSLSocket - Port test cases. (Not even started this. Run test cases in release mode?) diff --git a/lib/cpp/libthrift.vcxproj b/lib/cpp/libthrift.vcxproj index 5896726cd..19747fcd6 100644 --- a/lib/cpp/libthrift.vcxproj +++ b/lib/cpp/libthrift.vcxproj @@ -5,138 +5,162 @@ Debug Win32 + + Debug + x64 + Release Win32 + + Release + x64 + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - - config.h - config.h - _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - - - - _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - + + + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) %(PreprocessorDefinitions) + %(PreprocessorDefinitions) %(PreprocessorDefinitions) + %(PreprocessorDefinitions) _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - - true - true - + - true - true - - - true - true - - - true true + true + + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - force_inc.h - force_inc.h - - - true - true + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - force_inc.h - force_inc.h + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true + true true + true _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - NotUsing + NotUsing NotUsing + NotUsing + + - - + @@ -165,7 +189,6 @@ - @@ -173,6 +196,7 @@ + @@ -190,28 +214,51 @@ true MultiByte + + StaticLibrary + true + MultiByte + StaticLibrary false true MultiByte + + StaticLibrary + false + true + MultiByte + + + + + + + $(ProjectDir)\src\;$(ProjectDir)\src\windows\;$(ProjectDir)\src\transport\;$(THIRD_PARTY)\boost\boost_1_47_0\;$(THIRD_PARTY)\pthreads\;$(THIRD_PARTY)\openssl\OpenSSL-Win32\include\;$(IncludePath) + + $(ProjectDir)\src\;$(ProjectDir)\src\windows\;$(ProjectDir)\src\transport\;$(THIRD_PARTY)\boost\boost_1_47_0\;$(THIRD_PARTY)\pthreads\;$(THIRD_PARTY)\openssl\OpenSSL-Win32\include\;$(IncludePath) + $(ProjectDir)\src\;$(ProjectDir)\src\windows\;$(ProjectDir)\src\transport\;$(THIRD_PARTY)\boost\boost_1_47_0\;$(THIRD_PARTY)\pthreads\;$(THIRD_PARTY)\openssl\OpenSSL-Win32\include\;$(IncludePath) + + $(ProjectDir)\src\;$(ProjectDir)\src\windows\;$(ProjectDir)\src\transport\;$(THIRD_PARTY)\boost\boost_1_47_0\;$(THIRD_PARTY)\pthreads\;$(THIRD_PARTY)\openssl\OpenSSL-Win32\include\;$(IncludePath) + NotUsing @@ -225,6 +272,19 @@ true + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + force_inc.h;%(ForcedIncludeFiles) + + + Windows + true + + Level3 @@ -242,6 +302,23 @@ true + + + Level3 + NotUsing + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + force_inc.h;%(ForcedIncludeFiles) + + + Windows + true + true + true + + diff --git a/lib/cpp/libthrift.vcxproj.filters b/lib/cpp/libthrift.vcxproj.filters index 8d3ce66ac..0b0003c9e 100644 --- a/lib/cpp/libthrift.vcxproj.filters +++ b/lib/cpp/libthrift.vcxproj.filters @@ -9,21 +9,12 @@ windows - - concurrency - - - concurrency - transport windows - - concurrency - concurrency @@ -87,15 +78,24 @@ transport - - windows - windows windows + + concurrency + + + concurrency + + + concurrency + + + windows + @@ -116,12 +116,6 @@ windows - - concurrency - - - concurrency - concurrency @@ -200,9 +194,6 @@ windows - - windows - windows @@ -212,6 +203,15 @@ windows + + concurrency + + + concurrency + + + windows + diff --git a/lib/cpp/libthriftnb.vcxproj b/lib/cpp/libthriftnb.vcxproj index f672790ce..40aa9db99 100644 --- a/lib/cpp/libthriftnb.vcxproj +++ b/lib/cpp/libthriftnb.vcxproj @@ -5,29 +5,43 @@ Debug Win32 + + Debug + x64 + Release Win32 + + Release + x64 + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - config.h - config.h _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -37,6 +51,7 @@ + @@ -51,28 +66,51 @@ true MultiByte + + StaticLibrary + true + MultiByte + StaticLibrary false true MultiByte + + StaticLibrary + false + true + MultiByte + + + + + + + $(ProjectDir)\src\;$(ProjectDir)\src\windows\;$(THIRD_PARTY)\boost\boost_1_47_0\;$(THIRD_PARTY)\pthreads\;$(THIRD_PARTY)\libevent\libevent-2.0.13-stable\WIN32-Code\;$(THIRD_PARTY)\libevent\libevent-2.0.13-stable\include;$(THIRD_PARTY)\libevent\libevent-2.0.13-stable\;$(IncludePath) + + $(ProjectDir)\src\;$(ProjectDir)\src\windows\;$(THIRD_PARTY)\boost\boost_1_47_0\;$(THIRD_PARTY)\pthreads\;$(THIRD_PARTY)\libevent\libevent-2.0.13-stable\WIN32-Code\;$(THIRD_PARTY)\libevent\libevent-2.0.13-stable\include;$(THIRD_PARTY)\libevent\libevent-2.0.13-stable\;$(IncludePath) + $(ProjectDir)\src\;$(ProjectDir)\src\windows\;$(THIRD_PARTY)\boost\boost_1_47_0\;$(THIRD_PARTY)\pthreads\;$(THIRD_PARTY)\libevent\libevent-2.0.13-stable\WIN32-Code\;$(THIRD_PARTY)\libevent\libevent-2.0.13-stable\include;$(THIRD_PARTY)\libevent\libevent-2.0.13-stable\;$(IncludePath) + + $(ProjectDir)\src\;$(ProjectDir)\src\windows\;$(THIRD_PARTY)\boost\boost_1_47_0\;$(THIRD_PARTY)\pthreads\;$(THIRD_PARTY)\libevent\libevent-2.0.13-stable\WIN32-Code\;$(THIRD_PARTY)\libevent\libevent-2.0.13-stable\include;$(THIRD_PARTY)\libevent\libevent-2.0.13-stable\;$(IncludePath) + @@ -80,6 +118,21 @@ Level3 Disabled WIN32;HAVE_CONFIG_H;_DEBUG;_LIB;%(PreprocessorDefinitions) + force_inc.h;%(ForcedIncludeFiles) + + + Windows + true + + + + + + + Level3 + Disabled + WIN32;HAVE_CONFIG_H;_DEBUG;_LIB;%(PreprocessorDefinitions) + force_inc.h;%(ForcedIncludeFiles) Windows @@ -95,6 +148,25 @@ true true WIN32;HAVE_CONFIG_H;NDEBUG;_LIB;%(PreprocessorDefinitions) + force_inc.h;%(ForcedIncludeFiles) + + + Windows + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;HAVE_CONFIG_H;NDEBUG;_LIB;%(PreprocessorDefinitions) + force_inc.h;%(ForcedIncludeFiles) Windows diff --git a/lib/cpp/libthriftnb.vcxproj.filters b/lib/cpp/libthriftnb.vcxproj.filters index 943cce07b..d481d8f0b 100644 --- a/lib/cpp/libthriftnb.vcxproj.filters +++ b/lib/cpp/libthriftnb.vcxproj.filters @@ -50,5 +50,8 @@ windows + + windows + \ No newline at end of file diff --git a/lib/cpp/src/transport/TFDTransport.cpp b/lib/cpp/src/transport/TFDTransport.cpp index 8a448fa2d..a47e2a45b 100644 --- a/lib/cpp/src/transport/TFDTransport.cpp +++ b/lib/cpp/src/transport/TFDTransport.cpp @@ -26,6 +26,10 @@ #include #endif +#ifdef _WIN32 +#include +#endif + using namespace std; namespace apache { namespace thrift { namespace transport { diff --git a/lib/cpp/src/transport/TSimpleFileTransport.cpp b/lib/cpp/src/transport/TSimpleFileTransport.cpp index b9a74aacf..b52e4d5bd 100644 --- a/lib/cpp/src/transport/TSimpleFileTransport.cpp +++ b/lib/cpp/src/transport/TSimpleFileTransport.cpp @@ -28,6 +28,10 @@ #endif #include +#ifdef _WIN32 +#include +#endif + namespace apache { namespace thrift { namespace transport { TSimpleFileTransport:: @@ -46,9 +50,14 @@ TSimpleFileTransport(const std::string& path, bool read, bool write) if (write) { flags |= O_CREAT | O_APPEND; } +#ifndef _WIN32 + mode_t mode = S_IRUSR | S_IWUSR| S_IRGRP | S_IROTH; +#else + int mode = _S_IREAD | _S_IWRITE; +#endif int fd = ::open(path.c_str(), flags, - S_IRUSR | S_IWUSR| S_IRGRP | S_IROTH); + mode); if (fd < 0) { throw TTransportException("failed to open file for writing: " + path); } diff --git a/lib/cpp/src/windows/Fcntl.cpp b/lib/cpp/src/windows/WinFcntl.cpp similarity index 100% rename from lib/cpp/src/windows/Fcntl.cpp rename to lib/cpp/src/windows/WinFcntl.cpp diff --git a/lib/cpp/src/windows/Fcntl.h b/lib/cpp/src/windows/WinFcntl.h similarity index 100% rename from lib/cpp/src/windows/Fcntl.h rename to lib/cpp/src/windows/WinFcntl.h diff --git a/lib/cpp/src/windows/config.h b/lib/cpp/src/windows/config.h index 2db25967d..6116caaf9 100644 --- a/lib/cpp/src/windows/config.h +++ b/lib/cpp/src/windows/config.h @@ -31,6 +31,7 @@ #pragma warning(disable: 4996) // Depreciated posix name. #pragma warning(disable: 4250) // Inherits via dominance. +#define VERSION "0.8.0-dev" #define HAVE_GETTIMEOFDAY 1 #define HAVE_SYS_STAT_H 1 @@ -38,7 +39,7 @@ #include "GetTimeOfDay.h" #include "Operators.h" #include "TWinsockSingleton.h" -#include "Fcntl.h" +#include "WinFcntl.h" #include "SocketPair.h" // boost @@ -58,8 +59,8 @@ typedef boost::uint8_t uint8_t; # include #else struct timespec { - long tv_sec; - long tv_nsec; + int64_t tv_sec; + int64_t tv_nsec; }; # define USE_BOOST_THREAD 1 # define ctime_r( _clock, _buf ) \ @@ -94,8 +95,9 @@ inline int poll_win32(LPWSAPOLLFD fdArray, ULONG fds, INT timeout) return select(1, &read_fds, &write_fds, &except_fds, &time_out); } #else -# define poll(fds, nfds, timeout) \ - WSAPoll(fds, nfds, timeout) + inline int poll(struct pollfd* fdArray, ULONG fds, INT timeout) { + return WSAPoll(fdArray, fds, timeout); + } #endif // WINVER inline void close(SOCKET socket) diff --git a/lib/cpp/src/windows/force_inc.h b/lib/cpp/src/windows/force_inc.h index a85b8801d..2ee020770 100644 --- a/lib/cpp/src/windows/force_inc.h +++ b/lib/cpp/src/windows/force_inc.h @@ -29,6 +29,8 @@ #endif #define NOMINMAX +#define BOOST_ALL_NO_LIB 1 +#define BOOST_THREAD_NO_LIB 1 #include "windows/config.h" diff --git a/lib/cpp/thrift.sln b/lib/cpp/thrift.sln index 244499df9..7cfd969e5 100644 --- a/lib/cpp/thrift.sln +++ b/lib/cpp/thrift.sln @@ -13,17 +13,27 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {D8696CCE-7D46-4659-B432-91754A41DEB0}.Debug|Win32.ActiveCfg = Debug|Win32 {D8696CCE-7D46-4659-B432-91754A41DEB0}.Debug|Win32.Build.0 = Debug|Win32 + {D8696CCE-7D46-4659-B432-91754A41DEB0}.Debug|x64.ActiveCfg = Debug|x64 + {D8696CCE-7D46-4659-B432-91754A41DEB0}.Debug|x64.Build.0 = Debug|x64 {D8696CCE-7D46-4659-B432-91754A41DEB0}.Release|Win32.ActiveCfg = Release|Win32 {D8696CCE-7D46-4659-B432-91754A41DEB0}.Release|Win32.Build.0 = Release|Win32 + {D8696CCE-7D46-4659-B432-91754A41DEB0}.Release|x64.ActiveCfg = Release|x64 + {D8696CCE-7D46-4659-B432-91754A41DEB0}.Release|x64.Build.0 = Release|x64 {DD26F57E-60F2-4F37-A616-D219A9BF338F}.Debug|Win32.ActiveCfg = Debug|Win32 {DD26F57E-60F2-4F37-A616-D219A9BF338F}.Debug|Win32.Build.0 = Debug|Win32 + {DD26F57E-60F2-4F37-A616-D219A9BF338F}.Debug|x64.ActiveCfg = Debug|x64 + {DD26F57E-60F2-4F37-A616-D219A9BF338F}.Debug|x64.Build.0 = Debug|x64 {DD26F57E-60F2-4F37-A616-D219A9BF338F}.Release|Win32.ActiveCfg = Release|Win32 {DD26F57E-60F2-4F37-A616-D219A9BF338F}.Release|Win32.Build.0 = Release|Win32 + {DD26F57E-60F2-4F37-A616-D219A9BF338F}.Release|x64.ActiveCfg = Release|x64 + {DD26F57E-60F2-4F37-A616-D219A9BF338F}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE