From 5904badec79656396879ec21b74ec1c91afc638f Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 29 Jul 2015 10:42:48 +0200 Subject: [PATCH] Use boost counterparts. Apparently std::random and boost::random are not reliably interoperable. --- libdevcore/CommonData.cpp | 6 +++--- libdevcore/FixedHash.h | 3 ++- libdevcore/vector_ref.h | 3 ++- libethash-cl/ethash_cl_miner.cpp | 3 ++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/libdevcore/CommonData.cpp b/libdevcore/CommonData.cpp index a2d4ce1e0..7a6e7ff55 100644 --- a/libdevcore/CommonData.cpp +++ b/libdevcore/CommonData.cpp @@ -20,7 +20,7 @@ */ #include "CommonData.h" - +#include #include "Exceptions.h" #include "Log.h" @@ -58,9 +58,9 @@ std::string dev::escaped(std::string const& _s, bool _all) std::string dev::randomWord() { static std::mt19937_64 s_eng(0); - std::string ret(std::uniform_int_distribution(1, 5)(s_eng), ' '); + std::string ret(boost::random::uniform_int_distribution(1, 5)(s_eng), ' '); char const n[] = "qwertyuiop";//asdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890"; - std::uniform_int_distribution d(0, sizeof(n) - 2); + boost::random::uniform_int_distribution d(0, sizeof(n) - 2); for (char& c: ret) c = n[d(s_eng)]; return ret; diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index 7c612970a..af67269a1 100644 --- a/libdevcore/FixedHash.h +++ b/libdevcore/FixedHash.h @@ -27,6 +27,7 @@ #include #include #include +#include #include "CommonData.h" namespace dev @@ -154,7 +155,7 @@ public: { FixedHash ret; for (auto& i: ret.m_data) - i = (uint8_t)std::uniform_int_distribution(0, 255)(_eng); + i = (uint8_t)boost::random::uniform_int_distribution(0, 255)(_eng); return ret; } diff --git a/libdevcore/vector_ref.h b/libdevcore/vector_ref.h index ca5ac3753..c7ba3a437 100644 --- a/libdevcore/vector_ref.h +++ b/libdevcore/vector_ref.h @@ -7,6 +7,7 @@ #include #include #include +#include namespace dev { @@ -76,7 +77,7 @@ public: { uint8_t* e = (uint8_t*)end(); for (uint8_t* i = (uint8_t*)begin(); i != e; ++i) - *i = (uint8_t)std::uniform_int_distribution(0, 255)(_eng); + *i = (uint8_t)boost::random::uniform_int_distribution(0, 255)(_eng); } /// @returns a random valued object. void randomize() { randomize(s_vectorRefEngine); } diff --git a/libethash-cl/ethash_cl_miner.cpp b/libethash-cl/ethash_cl_miner.cpp index 7e2573303..fa1dda8eb 100644 --- a/libethash-cl/ethash_cl_miner.cpp +++ b/libethash-cl/ethash_cl_miner.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -472,7 +473,7 @@ void ethash_cl_miner::search(uint8_t const* header, uint64_t target, search_hook unsigned buf = 0; boost::random_device engine; - uint64_t start_nonce = uniform_int_distribution()(engine); + uint64_t start_nonce = boost::random::uniform_int_distribution()(engine); for (;; start_nonce += m_globalWorkSize) { auto t = chrono::high_resolution_clock::now();