]> sourceware.org Git - newlib-cygwin.git/commitdiff
Cygwin: timers: drop error handling for Windows perf timer functions
authorCorinna Vinschen <corinna@vinschen.de>
Mon, 26 Nov 2018 16:38:15 +0000 (17:38 +0100)
committerCorinna Vinschen <corinna@vinschen.de>
Mon, 26 Nov 2018 16:59:11 +0000 (17:59 +0100)
Per MSDN, the perf timer functions always succeed on Windows XP or
later.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
winsup/cygwin/times.cc

index e890514073f3f9be4effc015def7f758328a39ca..1ead18efce8ae2e62674c0ac762e819356ff443a 100644 (file)
@@ -466,21 +466,14 @@ void
 hires_ns::prime ()
 {
   LARGE_INTEGER ifreq;
-  if (!QueryPerformanceFrequency (&ifreq))
-    {
-      inited = -1;
-      return;
-    }
+
+  /* On XP or later the perf counter functions will always succeed. */
+  QueryPerformanceFrequency (&ifreq);
 
   int priority = GetThreadPriority (GetCurrentThread ());
 
   SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_TIME_CRITICAL);
-  if (!QueryPerformanceCounter (&primed_pc))
-    {
-      SetThreadPriority (GetCurrentThread (), priority);
-      inited = -1;
-      return;
-    }
+  QueryPerformanceCounter (&primed_pc);
 
   freq = (double) ((double) NSPERSEC / (double) ifreq.QuadPart);
   inited = true;
@@ -490,21 +483,11 @@ hires_ns::prime ()
 LONGLONG
 hires_ns::nsecs (bool monotonic)
 {
-  if (!inited)
-    prime ();
-  if (inited < 0)
-    {
-      set_errno (ENOSYS);
-      return (LONGLONG) -1;
-    }
-
   LARGE_INTEGER now;
-  if (!QueryPerformanceCounter (&now))
-    {
-      set_errno (ENOSYS);
-      return -1;
-    }
 
+  if (!inited)
+    prime ();
+  QueryPerformanceCounter (&now);
   // FIXME: Use round() here?
   now.QuadPart = (LONGLONG) (freq * (double)
                 (now.QuadPart - (monotonic ? 0LL : primed_pc.QuadPart)));
@@ -646,12 +629,6 @@ hires_ns::resolution ()
 {
   if (!inited)
     prime ();
-  if (inited < 0)
-    {
-      set_errno (ENOSYS);
-      return (LONGLONG) -1;
-    }
-
   return (freq <= 1.0) ? 1LL : (LONGLONG) freq;
 }
 
This page took 0.033728 seconds and 5 git commands to generate.