Merge branch 'win32-usleep-ceil' into 'master'

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

See merge request GNOME/glib!24
This commit is contained in:
Philip Withnall 2018-05-28 10:18:28 +00:00
commit a431f4fe3e
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;

View File

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