summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTanzinul Islam <tanzislam@users.noreply.github.com>2017-12-30 20:16:27 +0000
committerJeffrey Walton <noloader@gmail.com>2017-12-30 15:16:27 -0500
commitb4df31c7f9baaec194d939e7f7a4c9c45e64e166 (patch)
tree7e1ec39162c751c7a251c78fcd5596bc6dff76d6
parent16995625819d704ca21988a9142c664361684a5a (diff)
downloadcryptopp-git-b4df31c7f9baaec194d939e7f7a4c9c45e64e166.tar.gz
Change ::log() to log() to work with C++Builder (#552)
As reported in #520, C++Builder standard libraries don't have a `log()` function at global namespace. Change the invocations to unqualified name lookup, and apply a using-declaration to `std::log()` when compiling under C++Builder.
-rw-r--r--bench1.cpp4
-rw-r--r--nbtheory.cpp4
-rw-r--r--stdcpp.h6
3 files changed, 10 insertions, 4 deletions
diff --git a/bench1.cpp b/bench1.cpp
index e0fefc60..3159f54a 100644
--- a/bench1.cpp
+++ b/bench1.cpp
@@ -70,7 +70,7 @@ void OutputResultBytes(const char *name, double length, double timeTaken)
else
std::cout << "<TD>" << std::setprecision(1) << std::setiosflags(std::ios::fixed) << cpb;
}
- g_logTotal += ::log(mbs);
+ g_logTotal += log(mbs);
g_logCount++;
}
@@ -109,7 +109,7 @@ void OutputResultOperations(const char *name, const char *operation, bool pc, un
std::cout << "<TD>" << std::setprecision(2) << std::setiosflags(std::ios::fixed) << t;
}
- g_logTotal += ::log(iterations/timeTaken);
+ g_logTotal += log(iterations/timeTaken);
g_logCount++;
}
diff --git a/nbtheory.cpp b/nbtheory.cpp
index feb5802d..de812374 100644
--- a/nbtheory.cpp
+++ b/nbtheory.cpp
@@ -1021,14 +1021,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(::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(::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);
}
// ********************************************************
diff --git a/stdcpp.h b/stdcpp.h
index b58b976b..54037e29 100644
--- a/stdcpp.h
+++ b/stdcpp.h
@@ -62,4 +62,10 @@ namespace std {
# include <vector.cc>
#endif
+// C++Builder's standard library (Dinkumware) do not have C's global log() function
+// https://github.com/weidai11/cryptopp/issues/520
+#ifdef __BORLANDC__
+using std::log;
+#endif
+
#endif