From: Rudolf Polzer <divverent@alientrap.org>
Date: Sun, 25 Apr 2010 16:09:47 +0000 (+0200)
Subject: don't use clock_gettime, OS X sucks
X-Git-Tag: xonotic-v0.1.0preview~41
X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=eb36b7dd0169367b0c98988e5f02bc7baf852323;p=xonotic%2Fd0_blind_id.git

don't use clock_gettime, OS X sucks
---

diff --git a/configure.ac b/configure.ac
index ca9fa9f..6fe8993 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,7 +4,6 @@ AM_INIT_AUTOMAKE([-Wall foreign])
 AC_PROG_CC
 AC_PROG_LIBTOOL
 
-AC_SEARCH_LIBS(clock_gettime, rt, , [AC_MSG_ERROR([GNU MP not found, see http://gmplib.org/])])
 AC_SEARCH_LIBS(__gmpz_init, gmp, , [AC_MSG_ERROR([GNU MP not found, see http://gmplib.org/])])
 
 dnl AC_CONFIG_HEADERS([config.h])
diff --git a/main.c b/main.c
index 3c233e8..1a649a2 100644
--- a/main.c
+++ b/main.c
@@ -25,12 +25,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 void bench(double *b)
 {
-	static struct timespec thistime, lasttime;
+	static struct timeval thistime, lasttime;
 	static double x = 0;
 	static double *lastclock = &x;
 	lasttime = thistime;
-	clock_gettime(CLOCK_MONOTONIC, &thistime);
-	*lastclock += (thistime.tv_sec - lasttime.tv_sec) + 0.000000001 * (thistime.tv_nsec - lasttime.tv_nsec);
+	gettimeofday(&thistime, NULL);
+	*lastclock += (thistime.tv_sec - lasttime.tv_sec) + 0.000001 * (thistime.tv_usec - lasttime.tv_usec);
 	lastclock = b;
 }