From: Corinna Vinschen Date: Mon, 21 Jan 2019 09:05:13 +0000 (+0100) Subject: Cygwin: timerfd: settime: fix computing DueTime on non-realtime clocks X-Git-Tag: cygwin-3_0_0-release~93 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=6ed50a68a133e7e0c0d10e328bce94f98944dbe5;p=newlib-cygwin.git Cygwin: timerfd: settime: fix computing DueTime on non-realtime clocks Non-CLOCK_REALTIME counters always use a relative DueTime in NtSetTimer. However, relative DueTime has to be negative, but the code Signed-off-by: Corinna Vinschen --- diff --git a/winsup/cygwin/timerfd.cc b/winsup/cygwin/timerfd.cc index e5c17fb4e..64836b021 100644 --- a/winsup/cygwin/timerfd.cc +++ b/winsup/cygwin/timerfd.cc @@ -532,7 +532,7 @@ timerfd_shared::arm_timer (int flags, const struct itimerspec *new_value) DueTime.QuadPart = ts + FACTOR; else /* non-REALTIME clocks require relative DueTime. */ { - DueTime.QuadPart = ts - get_clock_now (); + DueTime.QuadPart = get_clock_now () - ts; /* If the timestamp was earlier than now, compute number of overruns and offset DueTime to expire immediately. */ if (DueTime.QuadPart >= 0)