From 3814af1ef1a10f25e7a76929edfd3abdb0ab791d Mon Sep 17 00:00:00 2001 From: 0xDEADFACE Date: Sat, 18 Apr 2015 13:03:13 -0700 Subject: [PATCH] Fix MinGW compilation issues. --- src/main.cpp | 2 +- src/net.cpp | 2 +- src/net.h | 7 ++++--- src/protocol.cpp | 2 +- src/protocol.h | 1 + src/stun.cpp | 15 +++++++-------- src/util.cpp | 2 +- 7 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 21eef1e..e3e4fd8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2387,7 +2387,7 @@ bool CBlock::AcceptBlock() // Write block to history file if (!CheckDiskSpace(::GetSerializeSize(*this, SER_DISK, CLIENT_VERSION))) return error("AcceptBlock() : out of disk space"); - unsigned int nFile = UINT_MAX; + unsigned int nFile = std::numeric_limits::max(); unsigned int nBlockPos = 0; if (!WriteToDisk(nFile, nBlockPos)) return error("AcceptBlock() : WriteToDisk failed"); diff --git a/src/net.cpp b/src/net.cpp index e1ac9a2..fa2bf44 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -307,7 +307,7 @@ extern int GetExternalIPbySTUN(uint64_t rnd, struct sockaddr_in *mapped, const c bool GetMyExternalIP(CNetAddr& ipRet) { struct sockaddr_in mapped; - uint64_t rnd = UINT64_MAX; + uint64_t rnd = std::numeric_limits::max(); const char *srv; int rc = GetExternalIPbySTUN(rnd, &mapped, &srv); if(rc >= 0) { diff --git a/src/net.h b/src/net.h index 7306d13..d1696fc 100644 --- a/src/net.h +++ b/src/net.h @@ -5,6 +5,7 @@ #ifndef BITCOIN_NET_H #define BITCOIN_NET_H +#include #include #ifndef Q_MOC_RUN #include @@ -233,7 +234,7 @@ public: nLastSendEmpty = GetTime(); nTimeConnected = GetTime(); nHeaderStart = -1; - nMessageStart = UINT_MAX; + nMessageStart = std::numeric_limits::max(); addr = addrIn; addrName = addrNameIn == "" ? addr.ToStringIPPort() : addrNameIn; nVersion = 0; @@ -375,7 +376,7 @@ public: return; vSend.resize(nHeaderStart); nHeaderStart = -1; - nMessageStart = UINT_MAX; + nMessageStart = std::numeric_limits::max(); LEAVE_CRITICAL_SECTION(cs_vSend); if (fDebug) @@ -410,7 +411,7 @@ public: } nHeaderStart = -1; - nMessageStart = UINT_MAX; + nMessageStart = std::numeric_limits::max(); LEAVE_CRITICAL_SECTION(cs_vSend); } diff --git a/src/protocol.cpp b/src/protocol.cpp index fc112a5..5a7dd4a 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -23,7 +23,7 @@ CMessageHeader::CMessageHeader() memcpy(pchMessageStart, ::pchMessageStart, sizeof(pchMessageStart)); memset(pchCommand, 0, sizeof(pchCommand)); pchCommand[1] = 1; - nMessageSize = UINT_MAX; + nMessageSize = std::numeric_limits::max(); nChecksum = 0; } diff --git a/src/protocol.h b/src/protocol.h index ed8beab..75c24d8 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -13,6 +13,7 @@ #include "serialize.h" #include "netbase.h" #include +#include #include "uint256.h" extern bool fTestNet; diff --git a/src/stun.cpp b/src/stun.cpp index c1c7d6e..1ab410e 100644 --- a/src/stun.cpp +++ b/src/stun.cpp @@ -28,10 +28,9 @@ * Of course all fields are in network format. */ -#define __STDC_LIMIT_MACROS - #include -#include +#include +#include #include #include #include @@ -339,14 +338,14 @@ static int stun_send(int s, struct sockaddr_in *dst, struct stun_header *resp) } /* helper function to generate a random request id */ -static uint64_t randfiller = GetRand(UINT64_MAX); +static uint64_t randfiller = GetRand(std::numeric_limits::max()); static void stun_req_id(struct stun_header *req) { const uint64_t *S_block = (const uint64_t *)StunSrvList; - req->id.id[0] = GetRandInt(INT32_MAX); - req->id.id[1] = GetRandInt(INT32_MAX); - req->id.id[2] = GetRandInt(INT32_MAX); - req->id.id[3] = GetRandInt(INT32_MAX); + req->id.id[0] = GetRandInt(std::numeric_limits::max()); + req->id.id[1] = GetRandInt(std::numeric_limits::max()); + req->id.id[2] = GetRandInt(std::numeric_limits::max()); + req->id.id[3] = GetRandInt(std::numeric_limits::max()); req->id.id[0] |= 0x55555555; req->id.id[1] &= 0x55555555; diff --git a/src/util.cpp b/src/util.cpp index 03f86e7..8cc62eb 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1271,7 +1271,7 @@ void ShrinkDebugFile() { // Restart the file with some of the end char pch[200000]; - fseek(file, -sizeof(pch), SEEK_END); + fseek(file, (long long)-sizeof(pch), SEEK_END); int nBytes = fread(pch, 1, sizeof(pch), file); fclose(file); -- 1.7.1