forked from boostorg/beast
beast cleanup and tidying:
* Replace custom types with C++11 <cstdint> types * Fix sqlite integer intos and uses * Fix String implicit integer constructors * Escape the enclosing namespace in sqdb * Replace contract checks with assert * Make many header files compile independently * Remove the dependence on beast_core.h in many places * Remove unused or obsolete classes and functions * Remove unused or obsolete macros * Remove unused network functions and files * Remove unused or obsolete classes: - ChildProcess - HighResolutionTimer - InterProcessLock - Throw - TrackedMutex - UntrackedMutex - XmlDocument - XmlElement
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
|
||||
namespace beast {
|
||||
|
||||
Random::Random (const int64 seedValue) noexcept
|
||||
Random::Random (const std::int64_t seedValue) noexcept
|
||||
: seed (seedValue)
|
||||
{
|
||||
nextInt (); // fixes a bug where the first int is always 0
|
||||
@@ -41,23 +41,23 @@ Random::~Random() noexcept
|
||||
{
|
||||
}
|
||||
|
||||
void Random::setSeed (const int64 newSeed) noexcept
|
||||
void Random::setSeed (const std::int64_t newSeed) noexcept
|
||||
{
|
||||
seed = newSeed;
|
||||
|
||||
nextInt (); // fixes a bug where the first int is always 0
|
||||
}
|
||||
|
||||
void Random::combineSeed (const int64 seedValue) noexcept
|
||||
void Random::combineSeed (const std::int64_t seedValue) noexcept
|
||||
{
|
||||
seed ^= nextInt64() ^ seedValue;
|
||||
}
|
||||
|
||||
void Random::setSeedRandomly()
|
||||
{
|
||||
static int64 globalSeed = 0;
|
||||
static std::int64_t globalSeed = 0;
|
||||
|
||||
combineSeed (globalSeed ^ (int64) (pointer_sized_int) this);
|
||||
combineSeed (globalSeed ^ (std::int64_t) (std::intptr_t) this);
|
||||
combineSeed (Time::getMillisecondCounter());
|
||||
combineSeed (Time::getHighResolutionTicks());
|
||||
combineSeed (Time::getHighResolutionTicksPerSecond());
|
||||
@@ -76,7 +76,7 @@ Random& Random::getSystemRandom() noexcept
|
||||
//==============================================================================
|
||||
int Random::nextInt() noexcept
|
||||
{
|
||||
seed = (seed * literal64bit (0x5deece66d) + 11) & literal64bit (0xffffffffffff);
|
||||
seed = (seed * 0x5deece66dLL + 11) & 0xffffffffffffULL;
|
||||
|
||||
return (int) (seed >> 16);
|
||||
}
|
||||
@@ -84,12 +84,12 @@ int Random::nextInt() noexcept
|
||||
int Random::nextInt (const int maxValue) noexcept
|
||||
{
|
||||
bassert (maxValue > 0);
|
||||
return (int) ((((unsigned int) nextInt()) * (uint64) maxValue) >> 32);
|
||||
return (int) ((((unsigned int) nextInt()) * (std::uint64_t) maxValue) >> 32);
|
||||
}
|
||||
|
||||
int64 Random::nextInt64() noexcept
|
||||
std::int64_t Random::nextInt64() noexcept
|
||||
{
|
||||
return (((int64) nextInt()) << 32) | (int64) (uint64) (uint32) nextInt();
|
||||
return (((std::int64_t) nextInt()) << 32) | (std::int64_t) (std::uint64_t) (std::uint32_t) nextInt();
|
||||
}
|
||||
|
||||
bool Random::nextBool() noexcept
|
||||
@@ -99,12 +99,12 @@ bool Random::nextBool() noexcept
|
||||
|
||||
float Random::nextFloat() noexcept
|
||||
{
|
||||
return static_cast <uint32> (nextInt()) / (float) 0xffffffff;
|
||||
return static_cast <std::uint32_t> (nextInt()) / (float) 0xffffffff;
|
||||
}
|
||||
|
||||
double Random::nextDouble() noexcept
|
||||
{
|
||||
return static_cast <uint32> (nextInt()) / (double) 0xffffffff;
|
||||
return static_cast <std::uint32_t> (nextInt()) / (double) 0xffffffff;
|
||||
}
|
||||
|
||||
void Random::fillBitsRandomly (void* const buffer, size_t bytes)
|
||||
|
||||
Reference in New Issue
Block a user