From 915816326e34b1a5b1821e76e1537a086601618e Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Wed, 3 Oct 2012 18:02:03 +0400 Subject: [PATCH] Fix AO_pause sleep delay for particular argument values (Win32) * src/atomic_ops.c (AO_pause): Fix millis value (passed to Win32 Sleep) for the case of 'n' argument in range between 12 and 21, inclusive if AO_USE_WIN32_PTHREADS (sleep for 1 ms in this case). * src/atomic_ops_stack.c (AO_pause): Evaluate 'msecs' value using the same algorithm as in atomic_ops.c (Win32 only). --- src/atomic_ops.c | 2 +- src/atomic_ops_stack.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/atomic_ops.c b/src/atomic_ops.c index e0f7ae2..6842ac0 100644 --- a/src/atomic_ops.c +++ b/src/atomic_ops.c @@ -127,7 +127,7 @@ void AO_pause(int n) ts.tv_nsec = (n > 28 ? 100000 * 1000 : 1 << (n - 2)); nanosleep(&ts, 0); # elif defined(AO_USE_WIN32_PTHREADS) - Sleep(n > 28 ? 100 : 1 << (n - 22)); /* in millis */ + Sleep(n > 28 ? 100 : n < 22 ? 1 : 1 << (n - 22)); /* in millis */ # else struct timeval tv; /* Short async-signal-safe sleep. */ diff --git a/src/atomic_ops_stack.c b/src/atomic_ops_stack.c index 2f6a640..c19409e 100644 --- a/src/atomic_ops_stack.c +++ b/src/atomic_ops_stack.c @@ -50,7 +50,7 @@ void AO_pause(int n) DWORD msecs; /* Short async-signal-safe sleep. */ - msecs = (n > 18? 100 : (1 << (n - 12))); + msecs = n > 28 ? 100 : n < 22 ? 1 : 1 << (n - 22); /* in millis */ Sleep(msecs); } } -- 2.40.0