Commit 09b93ccc by Dmitry Trifonov Committed by Eric

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
parent 46afd8e6
...@@ -31,6 +31,7 @@ ...@@ -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"
...@@ -164,7 +165,7 @@ bool BenchmarkFamilies::FindBenchmarks( ...@@ -164,7 +165,7 @@ bool BenchmarkFamilies::FindBenchmarks(
} }
} }
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) { ...@@ -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) { ...@@ -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() { ...@@ -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
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment