Erich E. Hoover : user32: Reduce the minimum Set[System] Timer from 15 ms to 10 ms.

Alexandre Julliard julliard at winehq.org
Thu May 1 14:40:01 CDT 2014


Module: wine
Branch: master
Commit: b5bd529769696f2b4e4f7d6389f2dc21da5acd4a
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b5bd529769696f2b4e4f7d6389f2dc21da5acd4a

Author: Erich E. Hoover <erich.e.hoover at gmail.com>
Date:   Thu May  1 07:41:57 2014 -0600

user32: Reduce the minimum Set[System]Timer from 15 ms to 10 ms.

---

 dlls/user32/message.c   |    8 ++------
 dlls/user32/tests/msg.c |   26 ++++++++++++++++----------
 2 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/dlls/user32/message.c b/dlls/user32/message.c
index 1e93c8d..be5d995 100644
--- a/dlls/user32/message.c
+++ b/dlls/user32/message.c
@@ -4439,9 +4439,7 @@ UINT_PTR WINAPI SetTimer( HWND hwnd, UINT_PTR id, UINT timeout, TIMERPROC proc )
 
     if (proc) winproc = WINPROC_AllocProc( (WNDPROC)proc, FALSE );
 
-    /* MSDN states that the minimum timeout should be USER_TIMER_MINIMUM (10.0 ms), but testing
-     * indicates that the true minimum is closer to 15.6 ms. */
-    timeout = min( max( 15, timeout ), USER_TIMER_MAXIMUM );
+    timeout = min( max( USER_TIMER_MINIMUM, timeout ), USER_TIMER_MAXIMUM );
 
     SERVER_START_REQ( set_win_timer )
     {
@@ -4474,9 +4472,7 @@ UINT_PTR WINAPI SetSystemTimer( HWND hwnd, UINT_PTR id, UINT timeout, TIMERPROC
 
     if (proc) winproc = WINPROC_AllocProc( (WNDPROC)proc, FALSE );
 
-    /* MSDN states that the minimum timeout should be USER_TIMER_MINIMUM (10.0 ms), but testing
-     * indicates that the true minimum is closer to 15.6 ms. */
-    timeout = min( max( 15, timeout ), USER_TIMER_MAXIMUM );
+    timeout = min( max( USER_TIMER_MINIMUM, timeout ), USER_TIMER_MAXIMUM );
 
     SERVER_START_REQ( set_win_timer )
     {
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c
index 6406190..66b9c7e 100644
--- a/dlls/user32/tests/msg.c
+++ b/dlls/user32/tests/msg.c
@@ -8390,8 +8390,8 @@ static VOID CALLBACK tfunc(HWND hwnd, UINT uMsg, UINT_PTR id, DWORD dwTime)
 }
 
 #define TIMER_ID               0x19
-#define TIMER_COUNT_EXPECTED   64
-#define TIMER_COUNT_TOLERANCE  9
+#define TIMER_COUNT_EXPECTED   100
+#define TIMER_COUNT_TOLERANCE  10
 
 static int count = 0;
 static void CALLBACK callback_count(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
@@ -8442,8 +8442,9 @@ static void test_timers(void)
     ok( KillTimer(info.hWnd, TIMER_ID), "KillTimer failed\n");
 
     /* Check the minimum allowed timeout for a timer.  MSDN indicates that it should be 10.0 ms,
-     * but testing indicates that the minimum timeout is actually about 15.6 ms.  Since there is
-     * some measurement error between test runs we're allowing for ±8 counts (~2 ms).
+     * which occurs sometimes, but most testing on the VMs indicates a minimum timeout closer to
+     * 15.6 ms.  Since there is some measurement error between test runs we are allowing for
+     * ±9 counts (~4 ms) around the expected value.
      */
     count = 0;
     id = SetTimer(info.hWnd, TIMER_ID, 0, callback_count);
@@ -8452,8 +8453,9 @@ static void test_timers(void)
     start = GetTickCount();
     while (GetTickCount()-start < 1001 && GetMessageA(&msg, info.hWnd, 0, 0))
         DispatchMessageA(&msg);
-    ok(abs(count-TIMER_COUNT_EXPECTED) < TIMER_COUNT_TOLERANCE
-       || broken(abs(count-43) < TIMER_COUNT_TOLERANCE) /* w2k3 */,
+    ok(abs(count-TIMER_COUNT_EXPECTED) < TIMER_COUNT_TOLERANCE /* xp */
+       || broken(abs(count-64) < TIMER_COUNT_TOLERANCE) /* most common */
+       || broken(abs(count-43) < TIMER_COUNT_TOLERANCE) /* w2k3, win8 */,
        "did not get expected count for minimum timeout (%d != ~%d).\n",
        count, TIMER_COUNT_EXPECTED);
     ok(KillTimer(info.hWnd, id), "KillTimer failed\n");
@@ -8473,7 +8475,9 @@ static void test_timers(void)
                 syscount++;
             DispatchMessageA(&msg);
         }
-        ok(abs(syscount-TIMER_COUNT_EXPECTED) < TIMER_COUNT_TOLERANCE,
+        ok(abs(syscount-TIMER_COUNT_EXPECTED) < TIMER_COUNT_TOLERANCE
+           || broken(abs(syscount-64) < TIMER_COUNT_TOLERANCE) /* most common */
+           || broken(syscount > 4000 && syscount < 12000) /* win2k3sp0 */,
            "did not get expected count for minimum timeout (%d != ~%d).\n",
            syscount, TIMER_COUNT_EXPECTED);
         todo_wine ok(count == 0, "did not get expected count for callback timeout (%d != 0).\n",
@@ -8507,8 +8511,9 @@ static void test_timers_no_wnd(void)
     ok(count == 1, "killing replaced timer did not work (%i).\n", count);
 
     /* Check the minimum allowed timeout for a timer.  MSDN indicates that it should be 10.0 ms,
-     * but testing indicates that the minimum timeout is actually about 15.6 ms.  Since there is
-     * some measurement error between test runs we're allowing for ±8 counts (~2 ms).
+     * which occurs sometimes, but most testing on the VMs indicates a minimum timeout closer to
+     * 15.6 ms.  Since there is some measurement error between test runs we are allowing for
+     * ±9 counts (~4 ms) around the expected value.
      */
     count = 0;
     id = SetTimer(NULL, 0, 0, callback_count);
@@ -8516,7 +8521,8 @@ static void test_timers_no_wnd(void)
     start = GetTickCount();
     while (GetTickCount()-start < 1001 && GetMessageA(&msg, NULL, 0, 0))
         DispatchMessageA(&msg);
-    ok(abs(count-TIMER_COUNT_EXPECTED) < TIMER_COUNT_TOLERANCE,
+    ok(abs(count-TIMER_COUNT_EXPECTED) < TIMER_COUNT_TOLERANCE /* xp */
+       || broken(abs(count-64) < TIMER_COUNT_TOLERANCE) /* most common */,
        "did not get expected count for minimum timeout (%d != ~%d).\n",
        count, TIMER_COUNT_EXPECTED);
     KillTimer(NULL, id);




More information about the wine-cvs mailing list