Implement interface for bionic benchmarks.
Test: Unit tests.
Change-Id: Ic61932f61ddd572e2f045b601f9da6e090cdc45d
diff --git a/benchmarks/util.cpp b/benchmarks/util.cpp
index d9641cf..9afca6f 100644
--- a/benchmarks/util.cpp
+++ b/benchmarks/util.cpp
@@ -19,11 +19,11 @@
#include <sched.h>
#include <stdio.h>
#include <string.h>
+
#include <cstdlib>
-#include <vector>
// This function returns a pointer less than 2 * alignment + or_mask bytes into the array.
-char *GetAlignedMemory(char *orig_ptr, size_t alignment, size_t or_mask) {
+char* GetAlignedMemory(char* orig_ptr, size_t alignment, size_t or_mask) {
if ((alignment & (alignment - 1)) != 0) {
fprintf(stderr, "warning: alignment passed into GetAlignedMemory is not a power of two.\n");
std::abort();
@@ -44,12 +44,12 @@
return reinterpret_cast<char*>(ptr);
}
-char *GetAlignedPtr(std::vector<char>* buf, size_t alignment, size_t nbytes) {
+char* GetAlignedPtr(std::vector<char>* buf, size_t alignment, size_t nbytes) {
buf->resize(nbytes + 3 * alignment);
return GetAlignedMemory(buf->data(), alignment, 0);
}
-char *GetAlignedPtrFilled(std::vector<char>* buf, size_t alignment, size_t nbytes, char fill_byte) {
+char* GetAlignedPtrFilled(std::vector<char>* buf, size_t alignment, size_t nbytes, char fill_byte) {
char* buf_aligned = GetAlignedPtr(buf, alignment, nbytes);
memset(buf_aligned, fill_byte, nbytes);
return buf_aligned;
@@ -64,7 +64,7 @@
#else
-bool LockToCPU(int cpu_to_lock) {
+bool LockToCPU(long cpu_to_lock) {
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
@@ -81,7 +81,7 @@
}
}
} else if (!CPU_ISSET(cpu_to_lock, &cpuset)) {
- printf("Cpu %d does not exist.\n", cpu_to_lock);
+ printf("Cpu %ld does not exist.\n", cpu_to_lock);
return false;
}