aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/FbTime.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk/FbTime.cc')
-rw-r--r--src/FbTk/FbTime.cc24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/FbTk/FbTime.cc b/src/FbTk/FbTime.cc
index d0ef731..c86edb1 100644
--- a/src/FbTk/FbTime.cc
+++ b/src/FbTk/FbTime.cc
@@ -21,6 +21,8 @@
21 21
22#include "FbTime.hh" 22#include "FbTime.hh"
23 23
24#include <cstdlib>
25#include <sys/time.h>
24 26
25 27
26#ifdef HAVE_CLOCK_GETTIME // linux|*bsd|solaris 28#ifdef HAVE_CLOCK_GETTIME // linux|*bsd|solaris
@@ -28,16 +30,16 @@
28 30
29namespace { 31namespace {
30 32
31uint64_t _now() { 33uint64_t _mono() {
32 34
33 uint64_t n = 0L; 35 uint64_t t = 0L;
34 timespec ts; 36 timespec ts;
35 37
36 if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) { 38 if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) {
37 n = (ts.tv_sec * FbTk::FbTime::IN_SECONDS) + (ts.tv_nsec / 1000L); 39 t = (ts.tv_sec * FbTk::FbTime::IN_SECONDS) + (ts.tv_nsec / 1000L);
38 } 40 }
39 41
40 return n; 42 return t;
41} 43}
42 44
43} 45}
@@ -59,7 +61,7 @@ uint64_t _now() {
59 61
60namespace { 62namespace {
61 63
62uint64_t _now() { 64uint64_t _mono() {
63 65
64 // mach_absolute_time() * info.numer / info.denom yields 66 // mach_absolute_time() * info.numer / info.denom yields
65 // nanoseconds. 67 // nanoseconds.
@@ -85,13 +87,15 @@ uint64_t _now() {
85 87
86 88
87 89
88 90uint64_t FbTk::FbTime::mono() {
89uint64_t FbTk::FbTime::now() { 91 return ::_mono();
90 return ::_now();
91} 92}
92 93
93 94
94uint64_t FbTk::FbTime::remainingNext(uint64_t unit) { 95uint64_t FbTk::FbTime::system() {
95 return (unit - (::_now() % unit) - 1); 96 static timeval v;
97 gettimeofday(&v, NULL);
98 return (v.tv_sec * FbTk::FbTime::IN_SECONDS) + v.tv_usec;
96} 99}
97 100
101