From 94ef3eaf4b301b6e610b272524dd5f4ebe4ac2cc Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Wed, 1 Dec 2010 05:47:18 +0000 Subject: [PATCH] windows build fixes --- Jamfile | 7 ++++++- include/libtorrent/file_storage.hpp | 2 +- include/libtorrent/http_stream.hpp | 1 + include/libtorrent/instantiate_connection.hpp | 2 +- include/libtorrent/packet_buffer.hpp | 3 ++- include/libtorrent/socks5_stream.hpp | 1 + include/libtorrent/thread.hpp | 6 ++++-- include/libtorrent/utp_stream.hpp | 2 +- src/enum_net.cpp | 4 ++++ src/file_pool.cpp | 1 + src/instantiate_connection.cpp | 2 +- src/kademlia/rpc_manager.cpp | 2 -- src/session_impl.cpp | 6 ++++++ 13 files changed, 29 insertions(+), 10 deletions(-) diff --git a/Jamfile b/Jamfile index 78f792cd2..f0199d16f 100755 --- a/Jamfile +++ b/Jamfile @@ -83,7 +83,6 @@ rule linking ( properties * ) wsock32 iphlpapi WIN32_LEAN_AND_MEAN - _WIN32_WINNT=0x0600 __USE_W32_SOCKETS WIN32 _WIN32 @@ -242,6 +241,12 @@ feature asserts : on off production : composite propagated ; feature.compose production : TORRENT_PRODUCTION_ASSERTS=1 ; feature.compose off : TORRENT_NO_ASSERTS=1 ; +feature windows-version : 2k xp vista win7 : composite propagated link-incompatible ; +feature.compose 2k : _WIN32_WINNT=0x0500 ; +feature.compose xp : _WIN32_WINNT=0x0501 ; +feature.compose vista : _WIN32_WINNT=0x0600 ; +feature.compose win7 : _WIN32_WINNT=0x0601 ; + feature asio-debugging : off on : composite propagated link-incompatible ; feature.compose on : TORRENT_ASIO_DEBUGGING ; diff --git a/include/libtorrent/file_storage.hpp b/include/libtorrent/file_storage.hpp index da50fa07a..23ffdc6b9 100644 --- a/include/libtorrent/file_storage.hpp +++ b/include/libtorrent/file_storage.hpp @@ -74,7 +74,7 @@ namespace libtorrent // it's smaller and optimized for smaller memory // footprint, as opposed to file_entry, which is // optimized for convenience - struct internal_file_entry + struct TORRENT_EXPORT internal_file_entry { friend class file_storage; internal_file_entry() diff --git a/include/libtorrent/http_stream.hpp b/include/libtorrent/http_stream.hpp index 8f97d8aa6..afc3d25db 100644 --- a/include/libtorrent/http_stream.hpp +++ b/include/libtorrent/http_stream.hpp @@ -36,6 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include "libtorrent/proxy_base.hpp" #include +#include namespace libtorrent { diff --git a/include/libtorrent/instantiate_connection.hpp b/include/libtorrent/instantiate_connection.hpp index a0e95d859..c74ecd454 100644 --- a/include/libtorrent/instantiate_connection.hpp +++ b/include/libtorrent/instantiate_connection.hpp @@ -41,7 +41,7 @@ namespace libtorrent struct proxy_settings; struct utp_socket_manager; - bool instantiate_connection(io_service& ios + TORRENT_EXPORT bool instantiate_connection(io_service& ios , proxy_settings const& ps, socket_type& s , void* ssl_context = 0 , utp_socket_manager* sm = 0); diff --git a/include/libtorrent/packet_buffer.hpp b/include/libtorrent/packet_buffer.hpp index 1092760dd..f6adfac37 100644 --- a/include/libtorrent/packet_buffer.hpp +++ b/include/libtorrent/packet_buffer.hpp @@ -33,6 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_PACKET_BUFFER_HPP_INCLUDED #define TORRENT_PACKET_BUFFER_HPP_INCLUDED +#include "libtorrent/config.hpp" #include "boost/cstdint.hpp" #include @@ -64,7 +65,7 @@ namespace libtorrent // whenever the element at the cursor is removed, the // cursor is bumped to the next occupied element - class packet_buffer + class TORRENT_EXPORT packet_buffer { public: typedef boost::uint32_t index_type; diff --git a/include/libtorrent/socks5_stream.hpp b/include/libtorrent/socks5_stream.hpp index 0922199b5..1d35561ba 100644 --- a/include/libtorrent/socks5_stream.hpp +++ b/include/libtorrent/socks5_stream.hpp @@ -35,6 +35,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include +#include #include "libtorrent/proxy_base.hpp" namespace libtorrent { diff --git a/include/libtorrent/thread.hpp b/include/libtorrent/thread.hpp index cdd7dc15c..c91f1532a 100644 --- a/include/libtorrent/thread.hpp +++ b/include/libtorrent/thread.hpp @@ -40,6 +40,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #endif +#include // for auto_ptr required by asio + #include #include #include @@ -50,9 +52,9 @@ namespace libtorrent typedef boost::asio::detail::mutex mutex; typedef boost::asio::detail::event event; - void sleep(int milliseconds); + TORRENT_EXPORT void sleep(int milliseconds); - struct condition + struct TORRENT_EXPORT condition { condition(); ~condition(); diff --git a/include/libtorrent/utp_stream.hpp b/include/libtorrent/utp_stream.hpp index e2d3157a0..daf00ba42 100644 --- a/include/libtorrent/utp_stream.hpp +++ b/include/libtorrent/utp_stream.hpp @@ -162,7 +162,7 @@ int socket_impl_size(); // will keep the utp_stream object around for. // for more details, see utp_socket_impl, which is analogous // to the kernel state for a socket. It's defined in utp_stream.cpp -class utp_stream +class TORRENT_EXPORT utp_stream { public: diff --git a/src/enum_net.cpp b/src/enum_net.cpp index d786af0b0..997bcea79 100644 --- a/src/enum_net.cpp +++ b/src/enum_net.cpp @@ -454,6 +454,7 @@ namespace libtorrent #elif defined TORRENT_WINDOWS || defined TORRENT_MINGW +#if _WIN32_WINNT >= 0x0501 // Load Iphlpapi library HMODULE iphlp = LoadLibraryA("Iphlpapi.dll"); if (iphlp) @@ -512,6 +513,7 @@ namespace libtorrent } FreeLibrary(iphlp); } +#endif SOCKET s = socket(AF_INET, SOCK_DGRAM, 0); if (s == SOCKET_ERROR) @@ -803,6 +805,7 @@ namespace libtorrent return std::vector(); } +#if _WIN32_WINNT >= 0x0600 typedef DWORD (WINAPI *GetIpForwardTable2_t)( ADDRESS_FAMILY, PMIB_IPFORWARD_TABLE2*); typedef void (WINAPI *FreeMibTable_t)(PVOID Memory); @@ -839,6 +842,7 @@ namespace libtorrent FreeLibrary(iphlp); return ret; } +#endif // Get GetIpForwardTable() pointer typedef DWORD (WINAPI *GetIpForwardTable_t)(PMIB_IPFORWARDTABLE pIpForwardTable,PULONG pdwSize,BOOL bOrder); diff --git a/src/file_pool.cpp b/src/file_pool.cpp index f540c3a89..51252b977 100644 --- a/src/file_pool.cpp +++ b/src/file_pool.cpp @@ -88,6 +88,7 @@ namespace libtorrent #if _WIN32_WINNT >= 0x0600 if (m_low_prio_io) { + // TODO: load this function dynamically from Kernel32.dll FILE_IO_PRIORITY_HINT_INFO priorityHint; priorityHint.PriorityHint = IoPriorityHintLow; SetFileInformationByHandle(e.file_ptr->native_handle(), diff --git a/src/instantiate_connection.cpp b/src/instantiate_connection.cpp index 8842fdbba..d8e33a01b 100644 --- a/src/instantiate_connection.cpp +++ b/src/instantiate_connection.cpp @@ -42,7 +42,7 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { - bool instantiate_connection(io_service& ios + TORRENT_EXPORT bool instantiate_connection(io_service& ios , proxy_settings const& ps, socket_type& s , void* ssl_context , utp_socket_manager* sm) diff --git a/src/kademlia/rpc_manager.cpp b/src/kademlia/rpc_manager.cpp index 4fac42f70..0349324ae 100644 --- a/src/kademlia/rpc_manager.cpp +++ b/src/kademlia/rpc_manager.cpp @@ -52,8 +52,6 @@ POSSIBILITY OF SUCH DAMAGE. #include #endif -using boost::shared_ptr; - namespace libtorrent { namespace dht { diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 50fdc6a25..8c967b42b 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -714,7 +714,9 @@ namespace aux { PRINT_OFFSETOF(udp_socket, m_socks5_sock) PRINT_OFFSETOF(udp_socket, m_connection_ticket) PRINT_OFFSETOF(udp_socket, m_proxy_settings) +#ifndef _MSC_VER PRINT_OFFSETOF(udp_socket, m_cc) +#endif PRINT_OFFSETOF(udp_socket, m_resolver) PRINT_OFFSETOF(udp_socket, m_tmp_buf) PRINT_OFFSETOF(udp_socket, m_queue_packets) @@ -732,13 +734,17 @@ namespace aux { PRINT_SIZEOF(http_tracker_connection) PRINT_SIZEOF(udp_tracker_connection) +#ifndef _MSC_VER PRINT_OFFSETOF(udp_tracker_connection, m_man) +#endif PRINT_OFFSETOF(udp_tracker_connection, m_abort) PRINT_OFFSETOF(udp_tracker_connection, m_hostname) PRINT_OFFSETOF(udp_tracker_connection, m_target) PRINT_OFFSETOF(udp_tracker_connection, m_endpoints) PRINT_OFFSETOF(udp_tracker_connection, m_transaction_id) +#ifndef _MSC_VER PRINT_OFFSETOF(udp_tracker_connection, m_ses) +#endif PRINT_OFFSETOF(udp_tracker_connection, m_attempts) PRINT_OFFSETOF(udp_tracker_connection, m_state) PRINT_OFFSETOF(udp_tracker_connection, m_proxy)