diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2013-04-11 19:49:58 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2013-04-11 19:49:58 +0000 |
commit | 8f81761b6997db261137b8f02c8a838b6e5bb15b (patch) | |
tree | 287e4d53167de9c1ddbb6a26e6ab0ac093bf867c | |
parent | 99e6ee04d657800680cced150e200e8b075957ba (diff) | |
download | newlib-8f81761b6997db261137b8f02c8a838b6e5bb15b.zip newlib-8f81761b6997db261137b8f02c8a838b6e5bb15b.tar.gz newlib-8f81761b6997db261137b8f02c8a838b6e5bb15b.tar.bz2 |
* hires.h (hires_ns::nsecs): Declare with bool parameter.
* times.cc (hires_ns::nsecs): Take bool parameter. If set to true,
don't use prime value (== return system wide absolute value).
-rw-r--r-- | winsup/cygwin/ChangeLog | 6 | ||||
-rw-r--r-- | winsup/cygwin/hires.h | 2 | ||||
-rw-r--r-- | winsup/cygwin/times.cc | 7 |
3 files changed, 11 insertions, 4 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 5024aab..b6b81eb 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2013-04-11 Corinna Vinschen <corinna@vinschen.de> + + * hires.h (hires_ns::nsecs): Declare with bool parameter. + * times.cc (hires_ns::nsecs): Take bool parameter. If set to true, + don't use prime value (== return system wide absolute value). + 2013-04-08 Christopher Faylor <me.cygwin2013@cgf.cx> * cygtls.h (_cygtls::reset_signal_arrived): Actually reset the diff --git a/winsup/cygwin/hires.h b/winsup/cygwin/hires.h index c9a4def..0135a80 100644 --- a/winsup/cygwin/hires.h +++ b/winsup/cygwin/hires.h @@ -48,7 +48,7 @@ class hires_ns : public hires_base double freq; void prime (); public: - LONGLONG nsecs (); + LONGLONG nsecs (bool monotonic = false); LONGLONG usecs () {return nsecs () / 1000LL;} LONGLONG resolution(); }; diff --git a/winsup/cygwin/times.cc b/winsup/cygwin/times.cc index 764a490..407f7c4 100644 --- a/winsup/cygwin/times.cc +++ b/winsup/cygwin/times.cc @@ -477,7 +477,7 @@ hires_ns::prime () } LONGLONG -hires_ns::nsecs () +hires_ns::nsecs (bool monotonic) { if (!inited) prime (); @@ -495,7 +495,8 @@ hires_ns::nsecs () } // FIXME: Use round() here? - now.QuadPart = (LONGLONG) (freq * (double) (now.QuadPart - primed_pc.QuadPart)); + now.QuadPart = (LONGLONG) (freq * (double) + (now.QuadPart - (monotonic ? 0LL : primed_pc.QuadPart))); return now.QuadPart; } @@ -642,7 +643,7 @@ clock_gettime (clockid_t clk_id, struct timespec *tp) case CLOCK_MONOTONIC: { - LONGLONG now = ntod.nsecs (); + LONGLONG now = ntod.nsecs (true); if (now == (LONGLONG) -1) return -1; |