This is the mail archive of the cygwin-cvs@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[newlib-cygwin] Cygwin: timers: clock_setres: make no-op


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=6df301076af0f8b6dd0b12eb7c3ea15a4f835267

commit 6df301076af0f8b6dd0b12eb7c3ea15a4f835267
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Tue Nov 27 13:59:37 2018 +0100

    Cygwin: timers: clock_setres: make no-op
    
    clock_setres is a questionable function only existing on QNX.
    Disable the function, just return success for CLOCK_REALTIME
    to maintain backward compatibility.
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/times.cc | 38 ++------------------------------------
 1 file changed, 2 insertions(+), 36 deletions(-)

diff --git a/winsup/cygwin/times.cc b/winsup/cygwin/times.cc
index 4e405b2..c557e82 100644
--- a/winsup/cygwin/times.cc
+++ b/winsup/cygwin/times.cc
@@ -688,47 +688,13 @@ clock_getres (clockid_t clk_id, struct timespec *tp)
 extern "C" int
 clock_setres (clockid_t clk_id, struct timespec *tp)
 {
-  static NO_COPY bool period_set;
-  int status;
-
+  /* Don't use this function.  It only exists in QNX.  Just return
+     success on CLOCK_REALTIME for backward compat. */
   if (clk_id != CLOCK_REALTIME)
     {
       set_errno (EINVAL);
       return -1;
     }
-
-  /* Convert to 100ns to match OS resolution.  The OS uses ULONG values
-     to express resolution in 100ns units, so the coarsest timer resolution
-     is < 430 secs.  Actually the coarsest timer resolution is only slightly
-     beyond 15ms, but this might change in future OS versions, so we play nice
-     here. */
-  ULONGLONG period = tp->tv_sec * NS100PERSEC
-		     + (tp->tv_nsec + (NSPERSEC/NS100PERSEC) - 1)
-		       / (NSPERSEC/NS100PERSEC);
-
-  /* clock_setres is non-POSIX/non-Linux.  On QNX, the function always
-     rounds the incoming value to the nearest supported value. */
-  ULONG coarsest, finest, actual;
-  if (NT_SUCCESS (NtQueryTimerResolution (&coarsest, &finest, &actual)))
-    {
-      if (period > coarsest)
-	period = coarsest;
-      else if (finest > period)
-	period = finest;
-    }
-
-  if (period_set
-      && NT_SUCCESS (NtSetTimerResolution (minperiod, FALSE, &actual)))
-    period_set = false;
-
-  status = NtSetTimerResolution (period, TRUE, &actual);
-  if (!NT_SUCCESS (status))
-    {
-      __seterrno_from_nt_status (status);
-      return -1;
-    }
-  minperiod = period;
-  period_set = true;
   return 0;
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]