From bde280b9a4da2652716c8ffdeed9ebfa4461cc70 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Wed, 21 Dec 2011 22:33:19 +0100 Subject: Revert "Use standard C99 (and Qt) types for 64-bit integers" This reverts commit 21d9f36781604e4ca9fc35dc65265593423b73e9. --- src/serialize.h | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'src/serialize.h') diff --git a/src/serialize.h b/src/serialize.h index 4bfff0a1a2..54555907d8 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -5,8 +5,6 @@ #ifndef BITCOIN_SERIALIZE_H #define BITCOIN_SERIALIZE_H -#include - #include #include #include @@ -21,6 +19,9 @@ #include #include +typedef long long int64; +typedef unsigned long long uint64; + #ifdef WIN32 #include // This is used to attempt to keep keying material out of swap @@ -136,8 +137,8 @@ inline unsigned int GetSerializeSize(signed int a, int, int=0) { return size inline unsigned int GetSerializeSize(unsigned int a, int, int=0) { return sizeof(a); } inline unsigned int GetSerializeSize(signed long a, int, int=0) { return sizeof(a); } inline unsigned int GetSerializeSize(unsigned long a, int, int=0) { return sizeof(a); } -inline unsigned int GetSerializeSize(int64_t a, int, int=0) { return sizeof(a); } -inline unsigned int GetSerializeSize(uint64_t a, int, int=0) { return sizeof(a); } +inline unsigned int GetSerializeSize(int64 a, int, int=0) { return sizeof(a); } +inline unsigned int GetSerializeSize(uint64 a, int, int=0) { return sizeof(a); } inline unsigned int GetSerializeSize(float a, int, int=0) { return sizeof(a); } inline unsigned int GetSerializeSize(double a, int, int=0) { return sizeof(a); } @@ -150,8 +151,8 @@ template inline void Serialize(Stream& s, signed int a, int template inline void Serialize(Stream& s, unsigned int a, int, int=0) { WRITEDATA(s, a); } template inline void Serialize(Stream& s, signed long a, int, int=0) { WRITEDATA(s, a); } template inline void Serialize(Stream& s, unsigned long a, int, int=0) { WRITEDATA(s, a); } -template inline void Serialize(Stream& s, int64_t a, int, int=0) { WRITEDATA(s, a); } -template inline void Serialize(Stream& s, uint64_t a, int, int=0) { WRITEDATA(s, a); } +template inline void Serialize(Stream& s, int64 a, int, int=0) { WRITEDATA(s, a); } +template inline void Serialize(Stream& s, uint64 a, int, int=0) { WRITEDATA(s, a); } template inline void Serialize(Stream& s, float a, int, int=0) { WRITEDATA(s, a); } template inline void Serialize(Stream& s, double a, int, int=0) { WRITEDATA(s, a); } @@ -164,8 +165,8 @@ template inline void Unserialize(Stream& s, signed int& a, template inline void Unserialize(Stream& s, unsigned int& a, int, int=0) { READDATA(s, a); } template inline void Unserialize(Stream& s, signed long& a, int, int=0) { READDATA(s, a); } template inline void Unserialize(Stream& s, unsigned long& a, int, int=0) { READDATA(s, a); } -template inline void Unserialize(Stream& s, int64_t& a, int, int=0) { READDATA(s, a); } -template inline void Unserialize(Stream& s, uint64_t& a, int, int=0) { READDATA(s, a); } +template inline void Unserialize(Stream& s, int64& a, int, int=0) { READDATA(s, a); } +template inline void Unserialize(Stream& s, uint64& a, int, int=0) { READDATA(s, a); } template inline void Unserialize(Stream& s, float& a, int, int=0) { READDATA(s, a); } template inline void Unserialize(Stream& s, double& a, int, int=0) { READDATA(s, a); } @@ -185,16 +186,16 @@ template inline void Unserialize(Stream& s, bool& a, int, int=0 // size <= UINT_MAX -- 5 bytes (254 + 4 bytes) // size > UINT_MAX -- 9 bytes (255 + 8 bytes) // -inline unsigned int GetSizeOfCompactSize(uint64_t nSize) +inline unsigned int GetSizeOfCompactSize(uint64 nSize) { if (nSize < 253) return sizeof(unsigned char); else if (nSize <= std::numeric_limits::max()) return sizeof(unsigned char) + sizeof(unsigned short); else if (nSize <= std::numeric_limits::max()) return sizeof(unsigned char) + sizeof(unsigned int); - else return sizeof(unsigned char) + sizeof(uint64_t); + else return sizeof(unsigned char) + sizeof(uint64); } template -void WriteCompactSize(Stream& os, uint64_t nSize) +void WriteCompactSize(Stream& os, uint64 nSize) { if (nSize < 253) { @@ -218,7 +219,7 @@ void WriteCompactSize(Stream& os, uint64_t nSize) else { unsigned char chSize = 255; - uint64_t xSize = nSize; + uint64 xSize = nSize; WRITEDATA(os, chSize); WRITEDATA(os, xSize); } @@ -226,11 +227,11 @@ void WriteCompactSize(Stream& os, uint64_t nSize) } template -uint64_t ReadCompactSize(Stream& is) +uint64 ReadCompactSize(Stream& is) { unsigned char chSize; READDATA(is, chSize); - uint64_t nSizeRet = 0; + uint64 nSizeRet = 0; if (chSize < 253) { nSizeRet = chSize; @@ -249,11 +250,11 @@ uint64_t ReadCompactSize(Stream& is) } else { - uint64_t xSize; + uint64 xSize; READDATA(is, xSize); nSizeRet = xSize; } - if (nSizeRet > (uint64_t)MAX_SIZE) + if (nSizeRet > (uint64)MAX_SIZE) throw std::ios_base::failure("ReadCompactSize() : size too large"); return nSizeRet; } -- cgit v1.2.3