Support FreeBSD (#5233)

* Fix build on FreeBSD

* Use __linux__ macro
This commit is contained in:
Philip Hyunsu Cho 2020-01-27 22:19:16 -08:00 committed by GitHub
parent ef19480eda
commit b513dcd352
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View File

@ -630,13 +630,13 @@ Json JsonReader::ParseNumber() {
// multiply zero by inf which gives nan.
if (f != 0.0) {
// Only use exp10 from libc on gcc+linux
#if !defined(__GNUC__) || defined(_WIN32) || defined(__APPLE__)
#if !defined(__GNUC__) || defined(_WIN32) || defined(__APPLE__) || !defined(__linux__)
#define exp10(val) std::pow(10, (val))
#endif // !defined(__GNUC__) || defined(_WIN32) || defined(__APPLE__)
#endif // !defined(__GNUC__) || defined(_WIN32) || defined(__APPLE__) || !defined(__linux__)
f *= exp10(exponent);
#if !defined(__GNUC__) || defined(_WIN32) || defined(__APPLE__)
#if !defined(__GNUC__) || defined(_WIN32) || defined(__APPLE__) || !defined(__linux__)
#undef exp10
#endif // !defined(__GNUC__) || defined(_WIN32) || defined(__APPLE__)
#endif // !defined(__GNUC__) || defined(_WIN32) || defined(__APPLE__) || !defined(__linux__)
}
}

View File

@ -44,8 +44,9 @@ std::vector<Monitor::StatMap> Monitor::CollectFromOtherRanks() const {
statistic[kv.first] = Object();
auto& j_pair = statistic[kv.first];
j_pair["count"] = Integer(kv.second.count);
j_pair["elapsed"] = Integer(std::chrono::duration_cast<std::chrono::microseconds>(
kv.second.timer.elapsed).count());
j_pair["elapsed"] = Integer(static_cast<int64_t>(
std::chrono::duration_cast<std::chrono::microseconds>(
kv.second.timer.elapsed).count()));
}
std::stringstream ss;