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: drop error handling for Windows perf timer functions


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

commit 161d0fd27bdedcf5ff9ea2a56596a3b1ce368d74
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Mon Nov 26 17:38:15 2018 +0100

    Cygwin: timers: drop error handling for Windows perf timer functions
    
    Per MSDN, the perf timer functions always succeed on Windows XP or
    later.
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/times.cc | 37 +++++++------------------------------
 1 file changed, 7 insertions(+), 30 deletions(-)

diff --git a/winsup/cygwin/times.cc b/winsup/cygwin/times.cc
index e890514..1ead18e 100644
--- a/winsup/cygwin/times.cc
+++ b/winsup/cygwin/times.cc
@@ -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;
 }


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