summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Makefile.am1
-rw-r--r--src/sandglass.c8
-rw-r--r--src/sandglass_impl.h2
-rw-r--r--src/timespec.c30
-rw-r--r--src/tsc.c4
5 files changed, 6 insertions, 39 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 519e0ea..d1a0109 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -24,7 +24,6 @@ nobase_include_HEADERS = sandglass.h
libsandglass_la_SOURCES = sandglass.h \
sandglass_impl.h \
sandglass.c \
- timespec.c \
tsc.c
if X86
diff --git a/src/sandglass.c b/src/sandglass.c
index c63e2a0..c3435d0 100644
--- a/src/sandglass.c
+++ b/src/sandglass.c
@@ -226,8 +226,8 @@ sandglass_real_gettime(sandglass_t *sandglass)
if (clock_gettime(CLOCK_REALTIME, &ts) != 0)
return -1;
}
- sandglass->grains = sandglass_timespec_grains(&ts);
- sandglass->adjustment = 2000000000L;
+ sandglass->grains = ts.tv_nsec;
+ sandglass->adjustment = 1000000000L;
break;
default:
@@ -250,8 +250,8 @@ sandglass_real_gettime(sandglass_t *sandglass)
return -1;
} else
return -1;
- sandglass->grains = sandglass_timespec_grains(&ts);
- sandglass->adjustment = 2000000000L;
+ sandglass->grains = ts.tv_nsec;
+ sandglass->adjustment = 1000000000L;
break;
case SANDGLASS_SYSTEM:
diff --git a/src/sandglass_impl.h b/src/sandglass_impl.h
index b618a93..cea95c3 100644
--- a/src/sandglass_impl.h
+++ b/src/sandglass_impl.h
@@ -37,6 +37,4 @@ double sandglass_tsc_resolution();
unsigned int sandglass_tsc_loops();
#endif
-long sandglass_timespec_grains(const struct timespec *ts);
-
#endif /* SANDGLASS_IMPL_H_INCLUDED */ \ No newline at end of file
diff --git a/src/timespec.c b/src/timespec.c
deleted file mode 100644
index 81a5815..0000000
--- a/src/timespec.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/*************************************************************************
- * Copyright (C) 2008 Tavian Barnes <tavianator@gmail.com> *
- * *
- * This file is part of The Sandglass Library. *
- * *
- * The Sandglass Library is free software; you can redistribute it *
- * and/or modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either version *
- * 3 of the License, or (at your option) any later version. *
- * *
- * The Sandglass Library is distributed in the hope that it will be *
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this program. If not, see *
- * <http://www.gnu.org/licenses/>. *
- *************************************************************************/
-
-#include "sandglass_impl.h"
-#include "sandglass.h"
-#include <time.h>
-
-/* Convert a timespec to grains */
-long
-sandglass_timespec_grains(const struct timespec *ts)
-{
- return (ts->tv_sec%2L)*1000000000L + ts->tv_nsec;
-} \ No newline at end of file
diff --git a/src/tsc.c b/src/tsc.c
index 8038c0e..28066a4 100644
--- a/src/tsc.c
+++ b/src/tsc.c
@@ -46,7 +46,7 @@ sandglass_tsc_resolution()
grains2 = grains1;
while (((grains2 >= grains1) ? grains2 - grains1
- : 2000000000L + (grains2 - grains1))
+ : 1000000000L + (grains2 - grains1))
< 10000000L)
{
if (monotonic) {
@@ -56,7 +56,7 @@ sandglass_tsc_resolution()
if (clock_gettime(CLOCK_REALTIME, &ts) != 0)
return 0.0/0.0;
}
- grains2 = sandglass_timespec_grains(&ts);
+ grains2 = ts.tv_nsec;
}
tsc = sandglass_get_tsc() - tsc;