Use ::time() and ::log() instead of std::time() and std::log() (GH #512)
The 35c0fa82fd change broke GCC 4.8
pull/484/merge
parent
4b7549a990
commit
e4498a105e
|
|
@ -61,7 +61,7 @@ void OutputResultBytes(const char *name, double length, double timeTaken)
|
|||
std::cout << "<TD>" << std::setprecision(0) << std::setiosflags(std::ios::fixed) << mbs;
|
||||
if (g_hertz > 1.0f)
|
||||
std::cout << "<TD>" << std::setprecision(1) << std::setiosflags(std::ios::fixed) << timeTaken * g_hertz / length;
|
||||
g_logTotal += std::log(mbs);
|
||||
g_logTotal += ::log(mbs);
|
||||
g_logCount++;
|
||||
}
|
||||
|
||||
|
|
@ -97,7 +97,7 @@ void OutputResultOperations(const char *name, const char *operation, bool pc, un
|
|||
if (g_hertz > 1.0f)
|
||||
std::cout << "<TD>" << std::setprecision(2) << std::setiosflags(std::ios::fixed) << timeTaken * g_hertz / iterations / 1000000;
|
||||
|
||||
g_logTotal += std::log(iterations/timeTaken);
|
||||
g_logTotal += ::log(iterations/timeTaken);
|
||||
g_logCount++;
|
||||
}
|
||||
|
||||
|
|
@ -373,7 +373,7 @@ void Benchmark(Test::TestClass suites, double t, double hertz)
|
|||
|
||||
AddHtmlHeader();
|
||||
|
||||
g_testBegin = std::time(NULLPTR);
|
||||
g_testBegin = ::time(NULLPTR);
|
||||
|
||||
if (static_cast<int>(suites) == 0 || static_cast<int>(suites) > TestLast)
|
||||
suites = Test::All;
|
||||
|
|
@ -399,7 +399,7 @@ void Benchmark(Test::TestClass suites, double t, double hertz)
|
|||
Benchmark3(t, hertz);
|
||||
}
|
||||
|
||||
g_testEnd = std::time(NULLPTR);
|
||||
g_testEnd = ::time(NULLPTR);
|
||||
|
||||
{
|
||||
StreamState state(std::cout);
|
||||
|
|
|
|||
|
|
@ -1023,14 +1023,14 @@ unsigned int FactoringWorkFactor(unsigned int n)
|
|||
// extrapolated from the table in Odlyzko's "The Future of Integer Factorization"
|
||||
// updated to reflect the factoring of RSA-130
|
||||
if (n<5) return 0;
|
||||
else return (unsigned int)(2.4 * std::pow((double)n, 1.0/3.0) * std::pow(std::log(double(n)), 2.0/3.0) - 5);
|
||||
else return (unsigned int)(2.4 * std::pow((double)n, 1.0/3.0) * std::pow(::log(double(n)), 2.0/3.0) - 5);
|
||||
}
|
||||
|
||||
unsigned int DiscreteLogWorkFactor(unsigned int n)
|
||||
{
|
||||
// assuming discrete log takes about the same time as factoring
|
||||
if (n<5) return 0;
|
||||
else return (unsigned int)(2.4 * std::pow((double)n, 1.0/3.0) * std::pow(std::log(double(n)), 2.0/3.0) - 5);
|
||||
else return (unsigned int)(2.4 * std::pow((double)n, 1.0/3.0) * std::pow(::log(double(n)), 2.0/3.0) - 5);
|
||||
}
|
||||
|
||||
// ********************************************************
|
||||
|
|
|
|||
8
rng.cpp
8
rng.cpp
|
|
@ -76,7 +76,7 @@ X917RNG::X917RNG(BlockTransformation *c, const byte *seed, const byte *determini
|
|||
|
||||
if (!deterministicTimeVector)
|
||||
{
|
||||
time_t tstamp1 = std::time(NULLPTR);
|
||||
time_t tstamp1 = ::time(NULLPTR);
|
||||
xorbuf(m_datetime, (byte *)&tstamp1, UnsignedMin(sizeof(tstamp1), m_size));
|
||||
m_cipher->ProcessBlock(m_datetime);
|
||||
clock_t tstamp2 = clock();
|
||||
|
|
@ -102,7 +102,7 @@ void X917RNG::GenerateIntoBufferedTransformation(BufferedTransformation &target,
|
|||
{
|
||||
clock_t c = clock();
|
||||
xorbuf(m_datetime, (byte *)&c, UnsignedMin(sizeof(c), m_size));
|
||||
time_t t = std::time(NULLPTR);
|
||||
time_t t = ::time(NULLPTR);
|
||||
xorbuf(m_datetime+m_size-UnsignedMin(sizeof(t), m_size), (byte *)&t, UnsignedMin(sizeof(t), m_size));
|
||||
m_cipher->ProcessBlock(m_datetime);
|
||||
}
|
||||
|
|
@ -142,7 +142,7 @@ size_t MaurerRandomnessTest::Put2(const byte *inString, size_t length, int /*mes
|
|||
{
|
||||
byte inByte = *inString++;
|
||||
if (n >= Q)
|
||||
sum += std::log(double(n - tab[inByte]));
|
||||
sum += ::log(double(n - tab[inByte]));
|
||||
tab[inByte] = n;
|
||||
n++;
|
||||
}
|
||||
|
|
@ -154,7 +154,7 @@ double MaurerRandomnessTest::GetTestValue() const
|
|||
if (BytesNeeded() > 0)
|
||||
throw Exception(Exception::OTHER_ERROR, "MaurerRandomnessTest: " + IntToString(BytesNeeded()) + " more bytes of input needed");
|
||||
|
||||
double fTu = (sum/(n-Q))/std::log(2.0); // this is the test value defined by Maurer
|
||||
double fTu = (sum/(n-Q))/::log(2.0); // this is the test value defined by Maurer
|
||||
|
||||
double value = fTu * 0.1392; // arbitrarily normalize it to
|
||||
return value > 1.0 ? 1.0 : value; // a number between 0 and 1
|
||||
|
|
|
|||
6
test.cpp
6
test.cpp
|
|
@ -855,12 +855,12 @@ bool Validate(int alg, bool thorough, const char *seedInput)
|
|||
|
||||
// Some editors have problems with the '\0' character when redirecting output.
|
||||
// seedInput is argv[3] when issuing 'cryptest.exe v all <seed>'
|
||||
std::string seed = (seedInput ? seedInput : IntToString(std::time(NULLPTR)));
|
||||
std::string seed = (seedInput ? seedInput : IntToString(::time(NULLPTR)));
|
||||
seed.resize(16, ' ');
|
||||
OFB_Mode<AES>::Encryption& prng = dynamic_cast<OFB_Mode<AES>::Encryption&>(GlobalRNG());
|
||||
prng.SetKeyWithIV((byte *)seed.data(), 16, (byte *)seed.data());
|
||||
|
||||
g_testBegin = std::time(NULLPTR);
|
||||
g_testBegin = ::time(NULLPTR);
|
||||
PrintSeedAndThreads(seed);
|
||||
|
||||
switch (alg)
|
||||
|
|
@ -964,7 +964,7 @@ bool Validate(int alg, bool thorough, const char *seedInput)
|
|||
default: return false;
|
||||
}
|
||||
|
||||
g_testEnd = std::time(NULLPTR);
|
||||
g_testEnd = ::time(NULLPTR);
|
||||
|
||||
std::cout << "\nSeed used was " << seed << std::endl;
|
||||
std::cout << "Test started at " << TimeToString(g_testBegin) << std::endl;
|
||||
|
|
|
|||
Loading…
Reference in New Issue