Fix bionic benchmarks and header tests for musl
Fix references to symbols that don't exist in musl in the bionic
benchmarks, and disable the header tests for musl.
Bug: 190084016
Test: m USE_HOST_MUSL=true host-native
Change-Id: I6b1964afa4a7b6e6a4812e9f2605fcfc2fae9691
diff --git a/benchmarks/pthread_benchmark.cpp b/benchmarks/pthread_benchmark.cpp
index 856f150..6790c77 100644
--- a/benchmarks/pthread_benchmark.cpp
+++ b/benchmarks/pthread_benchmark.cpp
@@ -75,6 +75,7 @@
}
BIONIC_BENCHMARK(BM_pthread_mutex_lock);
+#if !defined(ANDROID_HOST_MUSL)
static void BM_pthread_mutex_lock_ERRORCHECK(benchmark::State& state) {
pthread_mutex_t mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
@@ -84,7 +85,9 @@
}
}
BIONIC_BENCHMARK(BM_pthread_mutex_lock_ERRORCHECK);
+#endif
+#if !defined(ANDROID_HOST_MUSL)
static void BM_pthread_mutex_lock_RECURSIVE(benchmark::State& state) {
pthread_mutex_t mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
@@ -94,6 +97,7 @@
}
}
BIONIC_BENCHMARK(BM_pthread_mutex_lock_RECURSIVE);
+#endif
namespace {
struct PIMutex {
diff --git a/benchmarks/time_benchmark.cpp b/benchmarks/time_benchmark.cpp
index a765e3e..70cc662 100644
--- a/benchmarks/time_benchmark.cpp
+++ b/benchmarks/time_benchmark.cpp
@@ -22,6 +22,21 @@
#include <benchmark/benchmark.h>
#include "util.h"
+// Musl doesn't define __NR_gettimeofday, __NR_clock_gettime32, __NR_gettimeofday_time32 or
+// __NR_clock_getres on 32-bit architectures.
+#if !defined(__NR_gettimeofday)
+#define __NR_gettimeofday __NR_gettimeofday_time32
+#endif
+#if !defined(__NR_clock_gettime)
+#define __NR_clock_gettime __NR_clock_gettime32
+#endif
+#if !defined(__NR_gettimeofday)
+#define __NR_gettimeofday __NR_gettimeofday_time32
+#endif
+#if !defined(__NR_clock_getres)
+#define __NR_clock_getres __NR_clock_getres_time32
+#endif
+
static void BM_time_clock_gettime(benchmark::State& state) {
// CLOCK_MONOTONIC is required supported in vdso
timespec t;