mirror of https://github.com/google/benchmark.git
fix android compilation (#372)
* fix android compilation * checking __GLIBCXX__ and __GLIBCPP__ macro in addition to __ANDROID__ * using vsnprintf instead of std::vsnprintf to compile on Android * removed __GLIBCPP__ check on Android * StringPrintF instead of std::to_string for Android
This commit is contained in:
parent
46afd8e693
commit
09b93ccc6a
|
@ -31,6 +31,7 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <sstream>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
#include "check.h"
|
#include "check.h"
|
||||||
|
@ -163,8 +164,8 @@ bool BenchmarkFamilies::FindBenchmarks(
|
||||||
StringPrintF("%s:", family->arg_names_[arg_i].c_str());
|
StringPrintF("%s:", family->arg_names_[arg_i].c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
instance.name += std::to_string(arg);
|
instance.name += StringPrintF("%d", arg);
|
||||||
++arg_i;
|
++arg_i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ std::string FormatString(const char* msg, va_list args) {
|
||||||
|
|
||||||
std::size_t size = 256;
|
std::size_t size = 256;
|
||||||
char local_buff[256];
|
char local_buff[256];
|
||||||
auto ret = std::vsnprintf(local_buff, size, msg, args_cp);
|
auto ret = vsnprintf(local_buff, size, msg, args_cp);
|
||||||
|
|
||||||
va_end(args_cp);
|
va_end(args_cp);
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ std::string FormatString(const char* msg, va_list args) {
|
||||||
// we did not provide a long enough buffer on our first attempt.
|
// we did not provide a long enough buffer on our first attempt.
|
||||||
size = (size_t)ret + 1; // + 1 for the null byte
|
size = (size_t)ret + 1; // + 1 for the null byte
|
||||||
std::unique_ptr<char[]> buff(new char[size]);
|
std::unique_ptr<char[]> buff(new char[size]);
|
||||||
ret = std::vsnprintf(buff.get(), size, msg, args);
|
ret = vsnprintf(buff.get(), size, msg, args);
|
||||||
CHECK(ret > 0 && ((size_t)ret) < size);
|
CHECK(ret > 0 && ((size_t)ret) < size);
|
||||||
return buff.get();
|
return buff.get();
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,14 +114,14 @@ void TestRegistrationAtRuntime() {
|
||||||
#endif
|
#endif
|
||||||
#ifndef BENCHMARK_HAS_NO_VARIADIC_REGISTER_BENCHMARK
|
#ifndef BENCHMARK_HAS_NO_VARIADIC_REGISTER_BENCHMARK
|
||||||
{
|
{
|
||||||
int x = 42;
|
const char* x = "42";
|
||||||
auto capturing_lam = [=](benchmark::State& st) {
|
auto capturing_lam = [=](benchmark::State& st) {
|
||||||
while (st.KeepRunning()) {
|
while (st.KeepRunning()) {
|
||||||
}
|
}
|
||||||
st.SetLabel(std::to_string(x));
|
st.SetLabel(x);
|
||||||
};
|
};
|
||||||
benchmark::RegisterBenchmark("lambda_benchmark", capturing_lam);
|
benchmark::RegisterBenchmark("lambda_benchmark", capturing_lam);
|
||||||
AddCases({{"lambda_benchmark", "42"}});
|
AddCases({{"lambda_benchmark", x}});
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue