Change args to int64_t
The new benchmark framework uses int64_t for args.
Related benchmark change:
https://github.com/google/benchmark/commit/9913418d323e64a0111ca0da81388260c2bbe1e9#diff-b9f55422dc0bd52759c6aaa25c305bb0R757
Upgrade benchmark framework:
https://android-review.googlesource.com/c/platform/external/google-benchmark/+/714118
Test: compile and run bionic benchmark
Change-Id: I1b81c853c28abbead1816bf0be7a20a35e036619
diff --git a/benchmarks/bionic_benchmarks.cpp b/benchmarks/bionic_benchmarks.cpp
index a5d7267..e4c32fa 100644
--- a/benchmarks/bionic_benchmarks.cpp
+++ b/benchmarks/bionic_benchmarks.cpp
@@ -16,6 +16,7 @@
#include <err.h>
#include <getopt.h>
+#include <inttypes.h>
#include <math.h>
#include <sys/resource.h>
@@ -85,7 +86,7 @@
{0, 0, 0, 0},
};
-typedef std::vector<std::vector<int>> args_vector_t;
+typedef std::vector<std::vector<int64_t>> args_vector_t;
void Usage() {
printf("Usage:\n");
@@ -212,15 +213,16 @@
static constexpr char kOnebufManualStr[] = "AT_ONEBUF_MANUAL_ALIGN_";
static constexpr char kTwobufManualStr[] = "AT_TWOBUF_MANUAL_ALIGN1_";
-static bool ParseOnebufManualStr(std::string& arg, std::vector<int>* values) {
+static bool ParseOnebufManualStr(std::string& arg, std::vector<int64_t>* values) {
// The format of this is:
// AT_ONEBUF_MANUAL_ALIGN_XX_SIZE_YY
// Where:
// XX is the alignment
// YY is the size
- int align;
- int size;
- if (sscanf(arg.c_str(), "AT_ONEBUF_MANUAL_ALIGN_%d_SIZE_%d" , &align, &size) != 2) {
+ int64_t align;
+ int64_t size;
+ if (sscanf(arg.c_str(), "AT_ONEBUF_MANUAL_ALIGN_%" SCNd64 "_SIZE_%" SCNd64,
+ &align, &size) != 2) {
return false;
}
@@ -228,22 +230,22 @@
return false;
}
- values->push_back(static_cast<int>(size));
- values->push_back(static_cast<int>(align));
+ values->push_back(static_cast<int64_t>(size));
+ values->push_back(static_cast<int64_t>(align));
return true;
}
-static bool ParseTwobufManualStr(std::string& arg, std::vector<int>* values) {
+static bool ParseTwobufManualStr(std::string& arg, std::vector<int64_t>* values) {
// The format of this is:
// AT_TWOBUF_MANUAL_ALIGN1_XX_ALIGN2_YY_SIZE_ZZ
// Where:
// XX is the alignment of the first argument
// YY is the alignment of the second argument
// ZZ is the size
- int align1;
- int align2;
- int size;
- if (sscanf(arg.c_str(), "AT_TWOBUF_MANUAL_ALIGN1_%d_ALIGN2_%d_SIZE_%d" ,
+ int64_t align1;
+ int64_t align2;
+ int64_t size;
+ if (sscanf(arg.c_str(), "AT_TWOBUF_MANUAL_ALIGN1_%" SCNd64 "_ALIGN2_%" SCNd64 "_SIZE_%" SCNd64,
&align1, &align2, &size) != 3) {
return false;
}
@@ -254,9 +256,9 @@
return false;
}
- values->push_back(static_cast<int>(size));
- values->push_back(static_cast<int>(align1));
- values->push_back(static_cast<int>(align2));
+ values->push_back(static_cast<int64_t>(size));
+ values->push_back(static_cast<int64_t>(align1));
+ values->push_back(static_cast<int64_t>(align2));
return true;
}
@@ -270,7 +272,7 @@
}
// Check for free form macro.
if (android::base::StartsWith(args, kOnebufManualStr)) {
- std::vector<int> values;
+ std::vector<int64_t> values;
if (!ParseOnebufManualStr(args, &values)) {
errx(1, "ERROR: Bad format of macro %s, should be AT_ONEBUF_MANUAL_ALIGN_XX_SIZE_YY",
args.c_str());
@@ -278,7 +280,7 @@
to_populate->push_back(std::move(values));
return to_populate;
} else if (android::base::StartsWith(args, kTwobufManualStr)) {
- std::vector<int> values;
+ std::vector<int64_t> values;
if (!ParseTwobufManualStr(args, &values)) {
errx(1,
"ERROR: Bad format of macro %s, should be AT_TWOBUF_MANUAL_ALIGN1_XX_ALIGNE2_YY_SIZE_ZZ",
@@ -288,7 +290,7 @@
return to_populate;
}
- to_populate->push_back(std::vector<int>());
+ to_populate->push_back(std::vector<int64_t>());
std::stringstream sstream(args);
std::string argstr;
while (sstream >> argstr) {
@@ -318,7 +320,7 @@
}
benchmark_func_t benchmark_function = g_str_to_func.at(fn_name).first;
- for (const std::vector<int>& args : (*run_args)) {
+ for (const std::vector<int64_t>& args : (*run_args)) {
auto registration = benchmark::RegisterBenchmark(fn_name.c_str(), LockAndRun,
benchmark_function,
cpu_to_use)->Args(args);