summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Lutomirski <luto@amacapital.net>2014-02-26 15:59:29 -0800
committerAndy Lutomirski <luto@amacapital.net>2014-02-26 15:59:29 -0800
commit83ec12a21ef39e4d0a00ed584fb6845a28a027ce (patch)
treea40fdb8ece0c4eec745d8c55612bae2029f6089b
parentd661e356ce69580601053411b00de81c212ecbc2 (diff)
downloadmisc-tests-83ec12a21ef39e4d0a00ed584fb6845a28a027ce.tar.gz
Improve 32-bit support
-rw-r--r--Makefile19
-rw-r--r--evil-clock-test.cc4
-rw-r--r--test_vsyscall.cc18
-rw-r--r--timing_test.cc2
4 files changed, 26 insertions, 17 deletions
diff --git a/Makefile b/Makefile
index 155f9cd..bf3334e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,23 +1,26 @@
-.PHONY: all
+.PHONY: all clean
all: timing_test evil-clock-test test_vsyscall dump-vdso dump-vvar dump-vsyscall context_switch_latency
+clean:
+ rm -f timing_test evil-clock-test test_vsyscall dump-vdso dump-vvar dump-vsyscall context_switch_latency
+
timing_test: timing_test.cc
- g++ -o $@ -O2 -Wall -g $^ -lrt -ldl
+ g++ -o $@ -O2 -Wall $(EXTRA_CFLAGS) -g $^ -lrt -ldl
evil-clock-test: evil-clock-test.cc
- g++ -o $@ -pthread -O2 -Wall -g $^ -lrt
+ g++ -o $@ -pthread -O2 -Wall $(EXTRA_CFLAGS) -g $^ -lrt
test_vsyscall: test_vsyscall.cc
- g++ -o $@ -std=gnu++0x -O2 -Wall -g $^ -lrt -ldl
+ g++ -o $@ -std=gnu++0x -O2 -Wall $(EXTRA_CFLAGS) -g $^ -lrt -ldl
dump-vdso: dump-vdso.c
- gcc -o $@ -O2 $^ -ldl
+ gcc -o $@ -O2 $(EXTRA_CFLAGS) $^ -ldl
dump-vvar: dump-vvar.c
- gcc -o $@ -O2 $^
+ gcc -o $@ -O2 $(EXTRA_CFLAGS) $^
dump-vsyscall: dump-vsyscall.c
- gcc -o $@ -O2 $^ -ldl
+ gcc -o $@ -O2 $(EXTRA_CFLAGS) $^ -ldl
context_switch_latency: context_switch_latency.c
- g++ -o $@ -pthread -O2 -Wall -g $^ -lrt
+ g++ -o $@ -pthread -O2 -Wall -g $(EXTRA_CFLAGS) $^ -lrt
diff --git a/evil-clock-test.cc b/evil-clock-test.cc
index 00d8264..68f7503 100644
--- a/evil-clock-test.cc
+++ b/evil-clock-test.cc
@@ -509,7 +509,7 @@ public:
private:
enum { results_len = 1048576 };
- unsigned long results_1[results_len], results_2[results_len];
+ Time results_1[results_len], results_2[results_len];
void WriterThread(int threadidx)
{
@@ -619,7 +619,7 @@ private:
};
enum { results_len = 1048576 };
- unsigned long results_1[results_len], results_2[results_len];
+ uint64_t results_1[results_len], results_2[results_len];
void WriterThread(int threadidx)
{
diff --git a/test_vsyscall.cc b/test_vsyscall.cc
index abfc378..b6a6a12 100644
--- a/test_vsyscall.cc
+++ b/test_vsyscall.cc
@@ -46,19 +46,19 @@ void init_vdso()
return;
}
- vdso_gtod = (gtod_t)dlsym(vdso, "gettimeofday");
+ vdso_gtod = (gtod_t)dlsym(vdso, "__vdso_gettimeofday");
if (!vdso_gtod)
printf("Warning: failed to find gettimeofday in vDSO\n");
- vdso_gettime = (vgettime_t)dlsym(vdso, "clock_gettime");
- if (!vdso_gtod)
+ vdso_gettime = (vgettime_t)dlsym(vdso, "__vdso_clock_gettime");
+ if (!vdso_gettime)
printf("Warning: failed to find clock_gettime in vDSO\n");
- vdso_time = (time_func_t)dlsym(vdso, "time");
+ vdso_time = (time_func_t)dlsym(vdso, "__vdso_time");
if (!vdso_time)
printf("Warning: failed to find time in vDSO\n");
- vdso_getcpu = (getcpu_t)dlsym(vdso, "getcpu");
+ vdso_getcpu = (getcpu_t)dlsym(vdso, "__vdso_getcpu");
if (!vdso_getcpu)
printf("Warning: failed to find getcpu in vDSO\n");
}
@@ -94,7 +94,9 @@ static void segv(int sig, siginfo_t *info, void *ctx_void)
psiginfo(info, "Caught SIGSEGV");
ucontext_t *ctx = (ucontext_t*)ctx_void;
- printf("RIP = %lx\n", ctx->uc_mcontext.gregs[REG_RIP]);
+#ifdef REG_RIP
+ printf("RIP = %lx\n", (unsigned long)ctx->uc_mcontext.gregs[REG_RIP]);
+#endif
exit(1);
}
@@ -359,6 +361,7 @@ int intcc32(int argc, char **argv)
return 1;
}
+#if __x86_64__
// Install a 32-bit code descriptor
struct user_desc desc;
memset(&desc, 0, sizeof(desc));
@@ -410,6 +413,9 @@ int intcc32(int argc, char **argv)
: "rsi", "cc");
printf("Holy cow! We survived!\n");
+#else
+ printf("Not supported on 32-bit builds\n");
+#endif
return 0;
}
diff --git a/timing_test.cc b/timing_test.cc
index 136a731..3a8de3c 100644
--- a/timing_test.cc
+++ b/timing_test.cc
@@ -108,7 +108,7 @@ int main(int argc, char **argv)
clock_gettime(CLOCK_MONOTONIC, &end);
unsigned long long duration = (end.tv_nsec - start.tv_nsec) + 1000000000ULL * (end.tv_sec - start.tv_sec);
printf("%ld loops in %.5fs = %.2f nsec / loop\n",
- loops, float(duration) * 1e-9,
+ (long)loops, float(duration) * 1e-9,
float(duration) / loops);
return 0;
}