Add __pure2 to a few more functions, most notably gettid and pthread_self.
Change-Id: I7eee9f26f45130038af09d8285782b07f70a996f
diff --git a/benchmarks/pthread_benchmark.cpp b/benchmarks/pthread_benchmark.cpp
index 621fcb6..c010dd2 100644
--- a/benchmarks/pthread_benchmark.cpp
+++ b/benchmarks/pthread_benchmark.cpp
@@ -18,11 +18,14 @@
#include <pthread.h>
+// Stop GCC optimizing out our pure function.
+/* Must not be static! */ pthread_t (*pthread_self_fp)() = pthread_self;
+
static void BM_pthread_self(int iters) {
StartBenchmarkTiming();
for (int i = 0; i < iters; ++i) {
- pthread_self();
+ pthread_self_fp();
}
StopBenchmarkTiming();
diff --git a/benchmarks/unistd_benchmark.cpp b/benchmarks/unistd_benchmark.cpp
index f2c9d73..c35e7c3 100644
--- a/benchmarks/unistd_benchmark.cpp
+++ b/benchmarks/unistd_benchmark.cpp
@@ -30,11 +30,14 @@
}
BENCHMARK(BM_unistd_getpid);
+// Stop GCC optimizing out our pure function.
+/* Must not be static! */ pid_t (*gettid_fp)() = gettid;
+
static void BM_unistd_gettid(int iters) {
StartBenchmarkTiming();
for (int i = 0; i < iters; ++i) {
- gettid();
+ gettid_fp();
}
StopBenchmarkTiming();