Skip to content
Permalink
Browse files

Fix build without C++17 static_assert()

  • Loading branch information...
bmhjyu committed Aug 9, 2019
1 parent 90d6f2a commit 9c8bbd84b429b0fa9d59c46489440fb93d60b042
Showing with 9 additions and 7 deletions.
  1. +4 −2 3rdparty/beam/crypto/equihashR.h
  2. +5 −5 3rdparty/beam/crypto/equihashR_impl.cpp
@@ -18,6 +18,8 @@

#include "libblake2/blake2.h"

#include <boost/static_assert.hpp>

#include <cstring>
#include <exception>
#include <stdexcept>
@@ -232,8 +234,8 @@ template<unsigned int N, unsigned int K, unsigned int R>
class EquihashR : public PoWScheme
{
private:
static_assert(K < N);
static_assert((N/(K+1)) + 1 < 8*sizeof(eh_index));
BOOST_STATIC_ASSERT(K < N);
BOOST_STATIC_ASSERT((N/(K+1)) + 1 < 8*sizeof(eh_index));

public:
enum : size_t { IndicesPerHashOutput=512/N };
@@ -62,7 +62,7 @@ int EquihashR<N,K,R>::InitialiseState(eh_HashState& base_state)

const uint8_t outlen = (512 / N) * GetSizeInBytes(N);

static_assert(!((!outlen) || (outlen > BLAKE2B_OUTBYTES)));
BOOST_STATIC_ASSERT(!((!outlen) || (outlen > BLAKE2B_OUTBYTES)));

blake2b_param param = {0};
param.digest_length = outlen;
@@ -192,7 +192,7 @@ void CompressArray(const unsigned char* in, size_t in_len,
// comparison
void EhIndexToArray(const eh_index i, unsigned char* array)
{
static_assert(sizeof(eh_index) == 4);
BOOST_STATIC_ASSERT(sizeof(eh_index) == 4);
eh_index bei = htobe32(i);
memcpy(array, &bei, sizeof(eh_index));
}
@@ -201,7 +201,7 @@ void EhIndexToArray(const eh_index i, unsigned char* array)
// comparison
eh_index ArrayToEhIndex(const unsigned char* array)
{
static_assert(sizeof(eh_index) == 4);
BOOST_STATIC_ASSERT(sizeof(eh_index) == 4);
eh_index bei;
memcpy(&bei, array, sizeof(eh_index));
return be32toh(bei);
@@ -210,7 +210,7 @@ eh_index ArrayToEhIndex(const unsigned char* array)
eh_trunc TruncateIndex(const eh_index i, const unsigned int ilen)
{
// Truncate to 8 bits
static_assert(sizeof(eh_trunc) == 1);
BOOST_STATIC_ASSERT(sizeof(eh_trunc) == 1);
return (i >> (ilen - 8)) & 0xff;
}

@@ -264,7 +264,7 @@ StepRow<WIDTH>::StepRow(const unsigned char* hashIn, size_t hInLen,
template<size_t WIDTH> template<size_t W>
StepRow<WIDTH>::StepRow(const StepRow<W>& a)
{
static_assert(W <= WIDTH);
BOOST_STATIC_ASSERT(W <= WIDTH);
std::copy(a.hash, a.hash+W, hash);
}

0 comments on commit 9c8bbd8

Please sign in to comment.
You can’t perform that action at this time.