Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2018-11-26 19:38:15 +0300
committerCorinna Vinschen <corinna@vinschen.de>2018-11-26 19:59:11 +0300
commit161d0fd27bdedcf5ff9ea2a56596a3b1ce368d74 (patch)
treecbcf2cdd95632c6ea55241a0c83c930671715e08 /winsup/cygwin/times.cc
parent65091f0f35b29d5a043630fd877f0314a0779fb6 (diff)
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>
Diffstat (limited to 'winsup/cygwin/times.cc')
-rw-r--r--winsup/cygwin/times.cc37
1 files changed, 7 insertions, 30 deletions
diff --git a/winsup/cygwin/times.cc b/winsup/cygwin/times.cc
index e89051407..1ead18efc 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;
}