diff --git a/ChangeLog b/ChangeLog index 41f897a24..8ded4d976 100644 --- a/ChangeLog +++ b/ChangeLog @@ -115,6 +115,7 @@ release 0.14.9 * fixed optimistic unchoke timer * fixed bug where torrents with incorrectly formatted web seed URLs would be connected multiple times + * fixed MinGW support release 0.14.8 diff --git a/include/libtorrent/bencode.hpp b/include/libtorrent/bencode.hpp index 42772d2cc..303019966 100644 --- a/include/libtorrent/bencode.hpp +++ b/include/libtorrent/bencode.hpp @@ -246,7 +246,7 @@ namespace libtorrent ++in; // 'e' ret = entry(entry::int_t); char* end_pointer; -#ifdef TORRENT_WINDOWS +#if defined TORRENT_WINDOWS && !defined TORRENT_MINGW ret.integer() = _strtoi64(val.c_str(), &end_pointer, 10); #else ret.integer() = strtoll(val.c_str(), &end_pointer, 10); diff --git a/include/libtorrent/config.hpp b/include/libtorrent/config.hpp index 44aebeb01..5998f40d1 100644 --- a/include/libtorrent/config.hpp +++ b/include/libtorrent/config.hpp @@ -129,8 +129,13 @@ POSSIBILITY OF SUCH DAMAGE. // ==== LINUX === #elif defined __linux__ #define TORRENT_LINUX + +// ==== MINGW === #elif defined __MINGW32__ #define TORRENT_MINGW +#define TORRENT_WINDOWS +#define TORRENT_USE_ICONV 0 +#define TORRENT_USE_RLIMIT 0 // ==== WINDOWS === #elif defined WIN32 @@ -139,6 +144,7 @@ POSSIBILITY OF SUCH DAMAGE. // apple uses utf-8 as its locale, so no conversion // is necessary #define TORRENT_USE_ICONV 0 +#define TORRENT_USE_RLIMIT 0 // ==== SOLARIS === #elif defined sun || defined __sun @@ -192,7 +198,7 @@ POSSIBILITY OF SUCH DAMAGE. #endif -#ifdef TORRENT_WINDOWS +#if defined TORRENT_WINDOWS && !defined TORRENT_MINGW // class X needs to have dll-interface to be used by clients of class Y #pragma warning(disable:4251) @@ -248,6 +254,10 @@ inline int snprintf(char* buf, int len, char const* fmt, ...) #define TORRENT_DEPRECATED #endif +#ifndef TORRENT_USE_RLIMIT +#define TORRENT_USE_RLIMIT 1 +#endif + #ifndef TORRENT_USE_IPV6 #define TORRENT_USE_IPV6 1 #endif @@ -303,7 +313,7 @@ inline int snprintf(char* buf, int len, char const* fmt, ...) #if defined(__MACH__) #define TORRENT_USE_ABSOLUTE_TIME 1 -#elif defined(_WIN32) +#elif defined(_WIN32) || defined TORRENT_MINGW #define TORRENT_USE_QUERY_PERFORMANCE_TIMER 1 #elif defined(_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0 #define TORRENT_USE_CLOCK_GETTIME 1 diff --git a/include/libtorrent/utf8.hpp b/include/libtorrent/utf8.hpp index a75af94c1..ae8f2a59d 100644 --- a/include/libtorrent/utf8.hpp +++ b/include/libtorrent/utf8.hpp @@ -35,7 +35,9 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" -#if TORRENT_USE_WSTRING +// on windows we need these functions for +// convert_to_native and convert_from_native +#if TORRENT_USE_WSTRING || defined TORRENT_WINDOWS #include #include diff --git a/src/escape_string.cpp b/src/escape_string.cpp index e234132e7..fbb5af5fe 100644 --- a/src/escape_string.cpp +++ b/src/escape_string.cpp @@ -547,7 +547,7 @@ namespace libtorrent return true; } -#if defined TORRENT_WINDOWS && defined UNICODE +#if defined TORRENT_WINDOWS && TORRENT_USE_WSTRING && defined UNICODE std::wstring convert_to_wstring(std::string const& s) { std::wstring ret; diff --git a/src/file.cpp b/src/file.cpp index f62b312b2..a649dff6d 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1504,6 +1504,11 @@ namespace libtorrent #ifdef TORRENT_WINDOWS // according to MSDN, clearing the sparse flag of a file only // works on windows vista and later +#ifdef TORRENT_MINGW +typedef struct _FILE_SET_SPARSE_BUFFER { + BOOLEAN SetSparse; +} FILE_SET_SPARSE_BUFFER, *PFILE_SET_SPARSE_BUFFER; +#endif DWORD temp; FILE_SET_SPARSE_BUFFER b; b.SetSparse = FALSE; @@ -1536,6 +1541,13 @@ namespace libtorrent size_type file::sparse_end(size_type start) const { #ifdef TORRENT_WINDOWS +#ifdef TORRENT_MINGW +typedef struct _FILE_ALLOCATED_RANGE_BUFFER { + LARGE_INTEGER FileOffset; + LARGE_INTEGER Length; +} FILE_ALLOCATED_RANGE_BUFFER, *PFILE_ALLOCATED_RANGE_BUFFER; +#define FSCTL_QUERY_ALLOCATED_RANGES ((0x9 << 16) | (1 << 14) | (51 << 2) | 3) +#endif FILE_ALLOCATED_RANGE_BUFFER buffer; DWORD bytes_returned = 0; FILE_ALLOCATED_RANGE_BUFFER in; diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 01e7a0b80..cbe41100c 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -1185,6 +1185,10 @@ namespace aux { { s.sock->set_option(v6only(v6_only), ec); #ifdef TORRENT_WINDOWS + +#ifndef PROTECTION_LEVEL_UNRESTRICTED +#define PROTECTION_LEVEL_UNRESTRICTED 10 +#endif // enable Teredo on windows s.sock->set_option(v6_protection_level(PROTECTION_LEVEL_UNRESTRICTED), ec); #endif @@ -3446,7 +3450,7 @@ namespace aux { if (limit <= 0) { limit = (std::numeric_limits::max)(); -#ifndef TORRENT_WINDOWS +#if TORRENT_USE_RLIMIT rlimit l; if (getrlimit(RLIMIT_NOFILE, &l) == 0 && l.rlim_cur != RLIM_INFINITY)