diff options
author | Yaakov Selkowitz <yselkowi@redhat.com> | 2011-08-03 16:40:48 +0000 |
---|---|---|
committer | Yaakov Selkowitz <yselkowi@redhat.com> | 2011-08-03 16:40:48 +0000 |
commit | f0968c1e7eda1e949a938be187c631ff5ae868db (patch) | |
tree | c13d8c0da29e5db75a29e6a6b86de6e0e9fb6ed7 /winsup/cygwin/times.cc | |
parent | 529aa781b65f8020f93551fc4989147f489395ba (diff) | |
download | cygnal-f0968c1e7eda1e949a938be187c631ff5ae868db.tar.gz cygnal-f0968c1e7eda1e949a938be187c631ff5ae868db.tar.bz2 cygnal-f0968c1e7eda1e949a938be187c631ff5ae868db.zip |
* cygtls.h (struct _local_storage): Add cw_timer member.
* cygtls.cc (_cygtls::init_thread): Initialize locals.cw_timer.
(_cygtls::fixup_after_fork): Ditto.
* tlsoffsets.h: Regenerate.
* ntdll.h (enum _TIMER_INFORMATION_CLASS): Define.
(struct _TIMER_BASIC_INFORMATION): Define.
(NtQueryTimer): Declare function.
* thread.h (cancelable_wait): Change timeout argument to
PLARGE_INTEGER and provide NULL default.
(fast_mutex::lock): Adjust accordingly.
(pthread_cond::wait): Change timeout argument to PLARGE_INTEGER
and default to NULL.
* thread.cc (cancelable_wait): Change timeout argument to
PLARGE_INTEGER. Initialize _cygtls.locals.cw_timer if needed.
Use NT waitable timers for handling timeout. Return remaining time
to timeout argument if timeout was relative.
(pthread_cond::wait): Change timeout argument to PLARGE_INTEGER.
Adjust to change in cancelable_wait.
(pthread_mutex::lock): Adjust to change in cancelable_wait.
(pthread_spinlock::lock): Ditto.
(pthread::join): Ditto.
(__pthread_cond_dowait): Change waitlength argument to PLARGE_INTEGER.
Adjust to changes in cancelable_wait and pthread_cond::wait.
(pthread_cond_timedwait): Adjust to change in __pthread_cond_dowait.
(pthread_cond_wait): Ditto.
(semaphore::_timedwait): Adjust to change in cancelable_wait.
(semaphore::_wait): Ditto.
* exceptions.cc (handle_sigsuspend): Ditto.
* signal.cc (nanosleep): Ditto.
* wait.cc (wait4): Ditto. Fix copyright dates.
* times.cc (FACTOR, NSPERSEC): Move from here...
* hires.h (FACTOR, NSPERSEC): ...to here.
Diffstat (limited to 'winsup/cygwin/times.cc')
-rw-r--r-- | winsup/cygwin/times.cc | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/winsup/cygwin/times.cc b/winsup/cygwin/times.cc index 362439365..34ec1d30d 100644 --- a/winsup/cygwin/times.cc +++ b/winsup/cygwin/times.cc @@ -27,10 +27,6 @@ details. */ #include "cygtls.h" #include "ntdll.h" -/* 100ns difference between WIndows and UNIX timebase. */ -#define FACTOR (0x19db1ded53e8000LL) -/* # of 100ns intervals per second. */ -#define NSPERSEC 10000000LL /* Max allowed diversion in 100ns of internal timer from system time. If this difference is exceeded, the internal timer gets re-primed. */ #define JITTER (40 * 10000LL) @@ -737,7 +733,7 @@ hires_ms::resolution () status = NtQueryTimerResolution (&coarsest, &finest, &actual); if (NT_SUCCESS (status)) - minperiod = (DWORD) actual / 10000L; + minperiod = (DWORD) actual; else { /* Try to empirically determine current timer resolution */ @@ -757,13 +753,9 @@ hires_ms::resolution () period += now - then; } SetThreadPriority (GetCurrentThread (), priority); - period /= 40000L; + period /= 4L; minperiod = (DWORD) period; } - /* The resolution can be as low as 5000 100ns intervals on recent OSes. - We have to make sure that the resolution in ms is never 0. */ - if (!minperiod) - minperiod = 1L; } return minperiod; } @@ -786,8 +778,8 @@ clock_getres (clockid_t clk_id, struct timespec *tp) case CLOCK_REALTIME: { DWORD period = gtod.resolution (); - tp->tv_sec = period / 1000; - tp->tv_nsec = (period % 1000) * 1000000; + tp->tv_sec = period / NSPERSEC; + tp->tv_nsec = (period % NSPERSEC) * 100; break; } @@ -838,7 +830,7 @@ clock_setres (clockid_t clk_id, struct timespec *tp) } if (period_set - && NT_SUCCESS (NtSetTimerResolution (minperiod * 10000L, FALSE, &actual))) + && NT_SUCCESS (NtSetTimerResolution (minperiod, FALSE, &actual))) period_set = false; status = NtSetTimerResolution (period, TRUE, &actual); @@ -847,11 +839,7 @@ clock_setres (clockid_t clk_id, struct timespec *tp) __seterrno_from_nt_status (status); return -1; } - minperiod = actual / 10000L; - /* The resolution can be as low as 5000 100ns intervals on recent OSes. - We have to make sure that the resolution in ms is never 0. */ - if (!minperiod) - minperiod = 1L; + minperiod = actual; period_set = true; return 0; } |