diff --git a/glib/gtimer.c b/glib/gtimer.c index de0ef1b93..e95ac0ead 100644 --- a/glib/gtimer.c +++ b/glib/gtimer.c @@ -251,7 +251,8 @@ void g_usleep (gulong microseconds) { #ifdef G_OS_WIN32 - Sleep (microseconds / 1000); + /* Round up to the next millisecond */ + Sleep (microseconds ? (1 + (microseconds - 1) / 1000) : 0); #else struct timespec request, remaining; request.tv_sec = microseconds / G_USEC_PER_SEC; diff --git a/gobject/tests/threadtests.c b/gobject/tests/threadtests.c index b623e8ba4..bb57bd4a8 100644 --- a/gobject/tests/threadtests.c +++ b/gobject/tests/threadtests.c @@ -247,6 +247,12 @@ test_threaded_weak_ref (void) else n = NUM_COUNTER_INCREMENTS / 20; +#ifdef G_OS_WIN32 + /* On Windows usleep has millisecond resolution and gets rounded up + * leading to the test running for a long time. */ + n /= 10; +#endif + for (i = 0; i < n; i++) { UnrefInThreadData data;