diff options
Diffstat (limited to '3rdParty/Boost/src/boost/uuid/seed_rng.hpp')
-rw-r--r-- | 3rdParty/Boost/src/boost/uuid/seed_rng.hpp | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/3rdParty/Boost/src/boost/uuid/seed_rng.hpp b/3rdParty/Boost/src/boost/uuid/seed_rng.hpp index 3090197..97b505f 100644 --- a/3rdParty/Boost/src/boost/uuid/seed_rng.hpp +++ b/3rdParty/Boost/src/boost/uuid/seed_rng.hpp @@ -24,12 +24,11 @@ #include <boost/config.hpp> #include <cstring> // for memcpy #include <limits> -#include <memory.h> #include <ctime> // for time_t, time, clock_t, clock #include <cstdlib> // for rand #include <cstdio> // for FILE, fopen, fread, fclose #include <boost/uuid/sha1.hpp> -//#include <boost/nondet_random.hpp> //forward declare boost::random_device +//#include <boost/nondet_random.hpp> //forward declare boost::random::random_device // can't use boost::generator_iterator since boost::random number seed(Iter&, Iter) // functions need a last iterator @@ -57,9 +56,9 @@ namespace std { #endif // forward declare random number generators -namespace boost { +namespace boost { namespace random { class random_device; -} //namespace boost +}} //namespace boost::random namespace boost { namespace uuids { @@ -80,7 +79,7 @@ public: : rd_index_(5) , random_(std::fopen( "/dev/urandom", "rb" )) {} - + ~seed_rng() { if (random_) { @@ -110,9 +109,10 @@ public: } private: + inline void ignore_size(size_t) {} + static unsigned int * sha1_random_digest_state_() { - // intentionally left uninitialized static unsigned int state[ 5 ]; return state; } @@ -140,7 +140,11 @@ private: } { - unsigned int rn[] = { std::rand(), std::rand(), std::rand() }; + unsigned int rn[] = + { static_cast<unsigned int>(std::rand()) + , static_cast<unsigned int>(std::rand()) + , static_cast<unsigned int>(std::rand()) + }; sha.process_bytes( (unsigned char const*)rn, sizeof( rn ) ); } @@ -150,7 +154,7 @@ private: if(random_) { - std::fread( buffer, 1, 20, random_ ); + ignore_size(std::fread( buffer, 1, 20, random_ )); } // using an uninitialized buffer[] if fopen fails @@ -185,7 +189,7 @@ private: unsigned int rd_[5]; int rd_index_; std::FILE * random_; - + private: // make seed_rng noncopyable seed_rng(seed_rng const&); seed_rng& operator=(seed_rng const&); @@ -208,9 +212,9 @@ class generator_iterator , single_pass_traversal_tag , typename Generator::result_type const& > super_t; - + public: - generator_iterator() : m_g(NULL) {} + generator_iterator() : m_g(NULL), m_value(0) {} generator_iterator(Generator* g) : m_g(g), m_value((*m_g)()) {} void increment() @@ -247,7 +251,7 @@ inline void seed(UniformRandomNumberGenerator& rng) // random_device does not / can not be seeded template <> -inline void seed<boost::random_device>(boost::random_device&) {} +inline void seed<boost::random::random_device>(boost::random::random_device&) {} // random_device does not / can not be seeded template <> |