forked from premiere/premiere-libtorrent
merged mingw build fixes from RC_0_16
This commit is contained in:
parent
5586df1a03
commit
adc4280f50
|
@ -24,6 +24,7 @@
|
||||||
* fix uTP edge case where udp socket buffer fills up
|
* fix uTP edge case where udp socket buffer fills up
|
||||||
* fix nagle implementation in uTP
|
* fix nagle implementation in uTP
|
||||||
|
|
||||||
|
* fix mingw build issues
|
||||||
* increase max allowed outstanding piece requests from peers
|
* increase max allowed outstanding piece requests from peers
|
||||||
* uTP performance improvement. only fast retransmit one packet at a time
|
* uTP performance improvement. only fast retransmit one packet at a time
|
||||||
* improve error message for 'file too short'
|
* improve error message for 'file too short'
|
||||||
|
|
|
@ -34,18 +34,27 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/config.hpp"
|
#include "libtorrent/config.hpp"
|
||||||
#include "libtorrent/assert.hpp"
|
#include "libtorrent/assert.hpp"
|
||||||
|
|
||||||
#ifdef TORRENT_WINDOWS
|
#if defined TORRENT_BEOS
|
||||||
#include <windows.h>
|
|
||||||
#elif defined TORRENT_BEOS
|
|
||||||
#include <kernel/OS.h>
|
#include <kernel/OS.h>
|
||||||
#include <stdlib.h> // malloc/free
|
#include <stdlib.h> // malloc/free
|
||||||
#else
|
#elif !defined TORRENT_WINDOWS
|
||||||
#include <stdlib.h> // valloc/free
|
#include <stdlib.h> // valloc/free
|
||||||
#include <unistd.h> // _SC_PAGESIZE
|
#include <unistd.h> // _SC_PAGESIZE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if TORRENT_USE_MEMALIGN || TORRENT_USE_POSIX_MEMALIGN || defined TORRENT_WINDOWS
|
#if TORRENT_USE_MEMALIGN || TORRENT_USE_POSIX_MEMALIGN || defined TORRENT_WINDOWS
|
||||||
#include <malloc.h> // memalign and _aligned_malloc
|
#include <malloc.h> // memalign and _aligned_malloc
|
||||||
|
#include <stdlib.h> // _aligned_malloc on mingw
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef TORRENT_WINDOWS
|
||||||
|
// windows.h must be included after stdlib.h under mingw
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef TORRENT_MINGW
|
||||||
|
#define _aligned_malloc __mingw_aligned_malloc
|
||||||
|
#define _aligned_free __mingw_aligned_free
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TORRENT_DEBUG_BUFFERS
|
#ifdef TORRENT_DEBUG_BUFFERS
|
||||||
|
|
22
src/file.cpp
22
src/file.cpp
|
@ -1978,22 +1978,30 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
|
||||||
|
|
||||||
if ((m_open_mode & sparse) == 0)
|
if ((m_open_mode & sparse) == 0)
|
||||||
{
|
{
|
||||||
typedef DWORD (WINAPI *GetCompressedFileSizeW_t)(LPCWSTR lpFileName, LPDWORD lpFileSizeHigh);
|
#if TORRENT_USE_WSTRING
|
||||||
|
typedef DWORD (WINAPI *GetCompressedFileSize_t)(LPCWSTR lpFileName, LPDWORD lpFileSizeHigh);
|
||||||
|
#else
|
||||||
|
typedef DWORD (WINAPI *GetCompressedFileSize_t)(LPCSTR lpFileName, LPDWORD lpFileSizeHigh);
|
||||||
|
#endif
|
||||||
typedef BOOL (WINAPI *SetFileValidData_t)(HANDLE hFile, LONGLONG ValidDataLength);
|
typedef BOOL (WINAPI *SetFileValidData_t)(HANDLE hFile, LONGLONG ValidDataLength);
|
||||||
|
|
||||||
static GetCompressedFileSizeW_t GetCompressedFileSizeW = NULL;
|
static GetCompressedFileSize_t GetCompressedFileSize_ = NULL;
|
||||||
static SetFileValidData_t SetFileValidData = NULL;
|
static SetFileValidData_t SetFileValidData = NULL;
|
||||||
|
|
||||||
static bool failed_kernel32 = false;
|
static bool failed_kernel32 = false;
|
||||||
|
|
||||||
if ((GetCompressedFileSizeW == NULL) && !failed_kernel32)
|
if ((GetCompressedFileSize_ == NULL) && !failed_kernel32)
|
||||||
{
|
{
|
||||||
HMODULE kernel32 = LoadLibraryA("kernel32.dll");
|
HMODULE kernel32 = LoadLibraryA("kernel32.dll");
|
||||||
if (kernel32)
|
if (kernel32)
|
||||||
{
|
{
|
||||||
GetCompressedFileSizeW = (GetCompressedFileSizeW_t)GetProcAddress(kernel32, "GetCompressedFileSizeW");
|
#if TORRENT_USE_WSTRING
|
||||||
|
GetCompressedFileSize_ = (GetCompressedFileSize_t)GetProcAddress(kernel32, "GetCompressedFileSizeW");
|
||||||
|
#else
|
||||||
|
GetCompressedFileSize_ = (GetCompressedFileSize_t)GetProcAddress(kernel32, "GetCompressedFileSizeA");
|
||||||
|
#endif
|
||||||
SetFileValidData = (SetFileValidData_t)GetProcAddress(kernel32, "SetFileValidData");
|
SetFileValidData = (SetFileValidData_t)GetProcAddress(kernel32, "SetFileValidData");
|
||||||
if ((GetCompressedFileSizeW == NULL) || (SetFileValidData == NULL))
|
if ((GetCompressedFileSize_ == NULL) || (SetFileValidData == NULL))
|
||||||
{
|
{
|
||||||
failed_kernel32 = true;
|
failed_kernel32 = true;
|
||||||
}
|
}
|
||||||
|
@ -2004,12 +2012,12 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!failed_kernel32 && GetCompressedFileSizeW && SetFileValidData)
|
if (!failed_kernel32 && GetCompressedFileSize_ && SetFileValidData)
|
||||||
{
|
{
|
||||||
// only allocate the space if the file
|
// only allocate the space if the file
|
||||||
// is not fully allocated
|
// is not fully allocated
|
||||||
DWORD high_dword = 0;
|
DWORD high_dword = 0;
|
||||||
offs.LowPart = GetCompressedFileSize(m_path.c_str(), &high_dword);
|
offs.LowPart = GetCompressedFileSize_(m_path.c_str(), &high_dword);
|
||||||
offs.HighPart = high_dword;
|
offs.HighPart = high_dword;
|
||||||
ec.assign(GetLastError(), get_system_category());
|
ec.assign(GetLastError(), get_system_category());
|
||||||
if (ec) return false;
|
if (ec) return false;
|
||||||
|
|
Loading…
Reference in New Issue