summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-03-06 13:22:59 -0500
committerTavian Barnes <tavianator@gmail.com>2010-03-06 13:22:59 -0500
commitb31647ec5bc1979a0accfd8e89936d0d943734f1 (patch)
treef41905a5b3079764e23fd1d8a5203bdc148eb024
parent6952438ad1ef40132f8c00aa850fa558fe2202c1 (diff)
downloadlibsandglass-b31647ec5bc1979a0accfd8e89936d0d943734f1.tar.xz
Make build work on non-x86/x86_64 platforms.
-rw-r--r--configure.ac6
-rw-r--r--src/sandglass.c4
-rw-r--r--src/sandglass_impl.h2
-rw-r--r--tests/monotonic-realticks.c6
4 files changed, 11 insertions, 7 deletions
diff --git a/configure.ac b/configure.ac
index d81b8e6..c0b1000 100644
--- a/configure.ac
+++ b/configure.ac
@@ -39,6 +39,8 @@ AC_TYPE_SIZE_T
dnl Find out which assembly files to compile
AC_CANONICAL_HOST
+tsc=0
+
if echo $host_cpu | grep '86$' 2>&1 >/dev/null
then
arch_x86=1
@@ -54,8 +56,8 @@ fi
AM_CONDITIONAL([X86], [test "$arch_x86"])
AM_CONDITIONAL([X86_64], [test "$arch_x86_64"])
-AC_DEFINE([SANDGLASS_TSC], ["$tsc"])
-AM_CONDITIONAL([TSC], [test "$tsc"])
+AC_DEFINE_UNQUOTED([SANDGLASS_TSC], [$tsc])
+AM_CONDITIONAL([TSC], [test "$tsc" -ne 0])
dnl Generate Makefiles
AC_CONFIG_MACRO_DIR([m4])
diff --git a/src/sandglass.c b/src/sandglass.c
index 7ffe511..0710788 100644
--- a/src/sandglass.c
+++ b/src/sandglass.c
@@ -58,7 +58,7 @@ sandglass_init_monotonic(sandglass_t *sandglass, sandglass_resolution_t res)
{
switch (res) {
case SANDGLASS_CPUTIME:
-#ifdef SANDGLASS_TSC
+#if SANDGLASS_TSC
sandglass->freq = sandglass_tsc_freq();
sandglass->loops = sandglass_tsc_loops();
break;
@@ -120,7 +120,7 @@ sandglass_real_gettime(sandglass_t *sandglass)
case SANDGLASS_MONOTONIC:
switch (sandglass->resolution) {
case SANDGLASS_CPUTIME:
-#ifdef SANDGLASS_TSC
+#if SANDGLASS_TSC
sandglass->grains = sandglass_get_tsc();
break;
#else
diff --git a/src/sandglass_impl.h b/src/sandglass_impl.h
index accb332..e10562f 100644
--- a/src/sandglass_impl.h
+++ b/src/sandglass_impl.h
@@ -28,7 +28,7 @@
#include "sandglass.h"
#include <time.h>
-#ifdef SANDGLASS_TSC
+#if SANDGLASS_TSC
/* Read the time stamp counter */
long sandglass_get_tsc();
/* Get the frequency of the TSC */
diff --git a/tests/monotonic-realticks.c b/tests/monotonic-realticks.c
index e3e973a..1e48ca5 100644
--- a/tests/monotonic-realticks.c
+++ b/tests/monotonic-realticks.c
@@ -36,9 +36,11 @@ main()
return EXIT_FAILURE;
}
+#if SANDGLASS_TSC
sandglass_bench_fine(&sandglass, sandglass_get_tsc());
-
printf("%ld\n", sandglass.grains);
-
return EXIT_SUCCESS;
+#else
+ return EXIT_FAILURE;
+#endif
}