Fix MinGW compilation issues.
author0xDEADFACE <masmfan@gmail.com>
Sat, 18 Apr 2015 20:03:13 +0000 (13:03 -0700)
committer0xDEADFACE <masmfan@gmail.com>
Sat, 18 Apr 2015 20:03:13 +0000 (13:03 -0700)
src/main.cpp
src/net.cpp
src/net.h
src/protocol.cpp
src/protocol.h
src/stun.cpp
src/util.cpp

index 21eef1e..e3e4fd8 100644 (file)
@@ -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<unsigned int>::max();
     unsigned int nBlockPos = 0;
     if (!WriteToDisk(nFile, nBlockPos))
         return error("AcceptBlock() : WriteToDisk failed");
index e1ac9a2..fa2bf44 100644 (file)
@@ -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<uint64_t>::max();
     const char *srv;
     int rc = GetExternalIPbySTUN(rnd, &mapped, &srv);
     if(rc >= 0) {
index 7306d13..d1696fc 100644 (file)
--- a/src/net.h
+++ b/src/net.h
@@ -5,6 +5,7 @@
 #ifndef BITCOIN_NET_H
 #define BITCOIN_NET_H
 
+#include <limits>
 #include <deque>
 #ifndef Q_MOC_RUN
 #include <boost/array.hpp>
@@ -233,7 +234,7 @@ public:
         nLastSendEmpty = GetTime();
         nTimeConnected = GetTime();
         nHeaderStart = -1;
-        nMessageStart = UINT_MAX;
+        nMessageStart = std::numeric_limits<uint32_t>::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<uint32_t>::max();
         LEAVE_CRITICAL_SECTION(cs_vSend);
 
         if (fDebug)
@@ -410,7 +411,7 @@ public:
         }
 
         nHeaderStart = -1;
-        nMessageStart = UINT_MAX;
+        nMessageStart = std::numeric_limits<uint32_t>::max();
         LEAVE_CRITICAL_SECTION(cs_vSend);
     }
 
index fc112a5..5a7dd4a 100644 (file)
@@ -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<uint32_t>::max();
     nChecksum = 0;
 }
 
index ed8beab..75c24d8 100644 (file)
@@ -13,6 +13,7 @@
 #include "serialize.h"
 #include "netbase.h"
 #include <string>
+#include <limits>
 #include "uint256.h"
 
 extern bool fTestNet;
index c1c7d6e..1ab410e 100644 (file)
  * Of course all fields are in network format.
  */
 
-#define __STDC_LIMIT_MACROS
-
 #include <stdio.h>
-#include <stdint.h>
+#include <inttypes.h>
+#include <limits>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>
@@ -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<uint64_t>::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<int32_t>::max());
+    req->id.id[1] = GetRandInt(std::numeric_limits<int32_t>::max());
+    req->id.id[2] = GetRandInt(std::numeric_limits<int32_t>::max());
+    req->id.id[3] = GetRandInt(std::numeric_limits<int32_t>::max());
 
     req->id.id[0] |= 0x55555555;
     req->id.id[1] &= 0x55555555;
index 03f86e7..8cc62eb 100644 (file)
@@ -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);