mirror of
https://github.com/GOSTSec/ccminer
synced 2025-01-08 22:07:56 +00:00
bignum: some x64 warning fixes (vstudio)
This commit is contained in:
parent
a4404bc325
commit
0cc87b68a9
30
bignum.hpp
30
bignum.hpp
@ -117,17 +117,17 @@ public:
|
|||||||
|
|
||||||
unsigned long getulong() const
|
unsigned long getulong() const
|
||||||
{
|
{
|
||||||
return BN_get_word(this);
|
return (unsigned long) BN_get_word(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int getuint() const
|
unsigned int getuint() const
|
||||||
{
|
{
|
||||||
return BN_get_word(this);
|
return (unsigned int) BN_get_word(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
int getint() const
|
int getint() const
|
||||||
{
|
{
|
||||||
unsigned long n = BN_get_word(this);
|
unsigned long n = (unsigned long) BN_get_word(this);
|
||||||
if (!BN_is_negative(this))
|
if (!BN_is_negative(this))
|
||||||
return (n > (unsigned long)std::numeric_limits<int>::max() ? std::numeric_limits<int>::max() : n);
|
return (n > (unsigned long)std::numeric_limits<int>::max() ? std::numeric_limits<int>::max() : n);
|
||||||
else
|
else
|
||||||
@ -141,7 +141,7 @@ public:
|
|||||||
bool fNegative;
|
bool fNegative;
|
||||||
uint64 n;
|
uint64 n;
|
||||||
|
|
||||||
if (sn < (int64)0)
|
if (sn < 0LL)
|
||||||
{
|
{
|
||||||
// Since the minimum signed integer cannot be represented as positive so long as its type is signed,
|
// Since the minimum signed integer cannot be represented as positive so long as its type is signed,
|
||||||
// and it's not well-defined what happens if you make it unsigned before negating it,
|
// and it's not well-defined what happens if you make it unsigned before negating it,
|
||||||
@ -171,12 +171,12 @@ public:
|
|||||||
}
|
}
|
||||||
*p++ = c;
|
*p++ = c;
|
||||||
}
|
}
|
||||||
unsigned int nSize = p - (pch + 4);
|
unsigned int nSize = (unsigned int) (p - (pch + 4));
|
||||||
pch[0] = (nSize >> 24) & 0xff;
|
pch[0] = (nSize >> 24) & 0xff;
|
||||||
pch[1] = (nSize >> 16) & 0xff;
|
pch[1] = (nSize >> 16) & 0xff;
|
||||||
pch[2] = (nSize >> 8) & 0xff;
|
pch[2] = (nSize >> 8) & 0xff;
|
||||||
pch[3] = (nSize) & 0xff;
|
pch[3] = (nSize) & 0xff;
|
||||||
BN_mpi2bn(pch, p - pch, this);
|
BN_mpi2bn(pch, (int) (p - pch), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setuint64(uint64 n)
|
void setuint64(uint64 n)
|
||||||
@ -198,12 +198,12 @@ public:
|
|||||||
}
|
}
|
||||||
*p++ = c;
|
*p++ = c;
|
||||||
}
|
}
|
||||||
unsigned int nSize = p - (pch + 4);
|
unsigned int nSize = (unsigned int) (p - (pch + 4));
|
||||||
pch[0] = (nSize >> 24) & 0xff;
|
pch[0] = (nSize >> 24) & 0xff;
|
||||||
pch[1] = (nSize >> 16) & 0xff;
|
pch[1] = (nSize >> 16) & 0xff;
|
||||||
pch[2] = (nSize >> 8) & 0xff;
|
pch[2] = (nSize >> 8) & 0xff;
|
||||||
pch[3] = (nSize) & 0xff;
|
pch[3] = (nSize) & 0xff;
|
||||||
BN_mpi2bn(pch, p - pch, this);
|
BN_mpi2bn(pch, (int) (p - pch), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setuint256(uint256 n)
|
void setuint256(uint256 n)
|
||||||
@ -226,12 +226,12 @@ public:
|
|||||||
}
|
}
|
||||||
*p++ = c;
|
*p++ = c;
|
||||||
}
|
}
|
||||||
unsigned int nSize = p - (pch + 4);
|
unsigned int nSize = (unsigned int) (p - (pch + 4));
|
||||||
pch[0] = (nSize >> 24) & 0xff;
|
pch[0] = (nSize >> 24) & 0xff;
|
||||||
pch[1] = (nSize >> 16) & 0xff;
|
pch[1] = (nSize >> 16) & 0xff;
|
||||||
pch[2] = (nSize >> 8) & 0xff;
|
pch[2] = (nSize >> 8) & 0xff;
|
||||||
pch[3] = (nSize >> 0) & 0xff;
|
pch[3] = (nSize >> 0) & 0xff;
|
||||||
BN_mpi2bn(pch, p - pch, this);
|
BN_mpi2bn(pch, (int) (p - pch), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint256 getuint256() const
|
uint256 getuint256() const
|
||||||
@ -244,7 +244,7 @@ public:
|
|||||||
if (vch.size() > 4)
|
if (vch.size() > 4)
|
||||||
vch[4] &= 0x7f;
|
vch[4] &= 0x7f;
|
||||||
uint256 n = 0;
|
uint256 n = 0;
|
||||||
for (unsigned int i = 0, j = vch.size()-1; i < sizeof(n) && j >= 4; i++, j--)
|
for (unsigned int i = 0, j = (unsigned int) vch.size()-1; i < sizeof(n) && j >= 4; i++, j--)
|
||||||
((unsigned char*)&n)[i] = vch[j];
|
((unsigned char*)&n)[i] = vch[j];
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
@ -252,7 +252,7 @@ public:
|
|||||||
void setvch(const std::vector<unsigned char>& vch)
|
void setvch(const std::vector<unsigned char>& vch)
|
||||||
{
|
{
|
||||||
std::vector<unsigned char> vch2(vch.size() + 4);
|
std::vector<unsigned char> vch2(vch.size() + 4);
|
||||||
unsigned int nSize = vch.size();
|
unsigned int nSize = (unsigned int) vch.size();
|
||||||
// BIGNUM's byte stream format expects 4 bytes of
|
// BIGNUM's byte stream format expects 4 bytes of
|
||||||
// big endian size data info at the front
|
// big endian size data info at the front
|
||||||
vch2[0] = (nSize >> 24) & 0xff;
|
vch2[0] = (nSize >> 24) & 0xff;
|
||||||
@ -261,7 +261,7 @@ public:
|
|||||||
vch2[3] = (nSize >> 0) & 0xff;
|
vch2[3] = (nSize >> 0) & 0xff;
|
||||||
// swap data to big endian
|
// swap data to big endian
|
||||||
reverse_copy(vch.begin(), vch.end(), vch2.begin() + 4);
|
reverse_copy(vch.begin(), vch.end(), vch2.begin() + 4);
|
||||||
BN_mpi2bn(&vch2[0], vch2.size(), this);
|
BN_mpi2bn(&vch2[0], (int) vch2.size(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<unsigned char> getvch() const
|
std::vector<unsigned char> getvch() const
|
||||||
@ -322,12 +322,12 @@ public:
|
|||||||
unsigned int nSize = BN_num_bytes(this);
|
unsigned int nSize = BN_num_bytes(this);
|
||||||
unsigned int nCompact = 0;
|
unsigned int nCompact = 0;
|
||||||
if (nSize <= 3)
|
if (nSize <= 3)
|
||||||
nCompact = BN_get_word(this) << 8*(3-nSize);
|
nCompact = (unsigned int) BN_get_word(this) << 8*(3-nSize);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CBigNum bn;
|
CBigNum bn;
|
||||||
BN_rshift(&bn, this, 8*(nSize-3));
|
BN_rshift(&bn, this, 8*(nSize-3));
|
||||||
nCompact = BN_get_word(&bn);
|
nCompact = (unsigned int) BN_get_word(&bn);
|
||||||
}
|
}
|
||||||
// The 0x00800000 bit denotes the sign.
|
// The 0x00800000 bit denotes the sign.
|
||||||
// Thus, if it is already set, divide the mantissa by 256 and increase the exponent.
|
// Thus, if it is already set, divide the mantissa by 256 and increase the exponent.
|
||||||
|
@ -398,7 +398,7 @@ public:
|
|||||||
|
|
||||||
unsigned int GetSerializeSize(int, int=0) const
|
unsigned int GetSerializeSize(int, int=0) const
|
||||||
{
|
{
|
||||||
return pend - pbegin;
|
return (unsigned int) (pend - pbegin);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Stream>
|
template<typename Stream>
|
||||||
@ -593,7 +593,8 @@ void Unserialize(Stream& is, std::basic_string<C>& str, int, int)
|
|||||||
template<typename T, typename A>
|
template<typename T, typename A>
|
||||||
unsigned int GetSerializeSize_impl(const std::vector<T, A>& v, int nType, int nVersion, const unsigned char&)
|
unsigned int GetSerializeSize_impl(const std::vector<T, A>& v, int nType, int nVersion, const unsigned char&)
|
||||||
{
|
{
|
||||||
return (GetSizeOfCompactSize(v.size()) + v.size() * sizeof(T));
|
size_t sz = v.size() + v.size() * sizeof(T);
|
||||||
|
return (GetSizeOfCompactSize((uint64_t)sz));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename A, typename V>
|
template<typename T, typename A, typename V>
|
||||||
|
Loading…
Reference in New Issue
Block a user