g_usleep: round up the next millisecond on Windows. See #1371

The timer tests expect that a small value for sleep does not result in
no sleep at all. Round up to the next millisecond to bring it more in line
with other platforms.

This fixes the glib/timer tests.

This makes the 'threadtests' time out since that uses small usleeps a lot and
until now didn't wait at all, but now always waits a msec. Reduce the amount
of tests done on Windows to get the runtime down to something reasonable again.

https://bugzilla.gnome.org/show_bug.cgi?id=795569
This commit is contained in:
Christoph Reiter
2018-05-10 20:30:49 +02:00
parent ab116c3111
commit 01c02ac08b
2 changed files with 8 additions and 1 deletions

View File

@@ -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;