Skip to contentSkip to conversation

aio / timers: use g_usleep() not sleep()

PATCH Applied Alex Bligh 4 participants 4 messages Aug 29, 2013 – Sep 3, 2013

lore
Share & tools
lore

Alex Bligh

author
#0 lore raw

PATCH v2 1/1 aio / timers: use g_usleep() not sleep()

sleep() apparently doesn't exist under mingw. Use g_usleep for portability.

---
 tests/test-aio.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tests/test-aio.c +3 -3
index 4215701..c4fe0fc 100644
@@ -400,7 +400,7 @@ static void test_timer_schedule(void)
     g_assert(!aio_poll(ctx, false));
     g_assert_cmpint(data.n, ==, 0);
 
-    sleep(1);
+    g_usleep(1 * G_USEC_PER_SEC);
     g_assert_cmpint(data.n, ==, 0);
 
     g_assert(aio_poll(ctx, false));
@@ -736,7 +736,7 @@ static void test_source_timer_schedule(void)
 
     g_assert_cmpint(data.n, ==, 0);
 
-    sleep(1);
+    g_usleep(1 * G_USEC_PER_SEC);
     g_assert_cmpint(data.n, ==, 0);
 
     g_assert(g_main_context_iteration(NULL, false));
@@ -746,7 +746,7 @@ static void test_source_timer_schedule(void)
     do {
         g_assert(g_main_context_iteration(NULL, true));
     } while (qemu_clock_get_ns(data.clock_type) <= expiry);
-    sleep(1);
+    g_usleep(1 * G_USEC_PER_SEC);
     g_main_context_iteration(NULL, false);
 
     g_assert_cmpint(data.n, ==, 2);
Signature · 1 line
1.7.9.5
Reviewed-by on v2 1/1
#1 lore raw

Am 30.08.2013 00:32, schrieb Alex Bligh:

Quoted 31 lines

sleep() apparently doesn't exist under mingw. Use g_usleep for portability.

---
 tests/test-aio.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tests/test-aio.c +2 -2
index 4215701..c4fe0fc 100644
@@ -400,7 +400,7 @@ static void test_timer_schedule(void)
     g_assert(!aio_poll(ctx, false));
     g_assert_cmpint(data.n, ==, 0);
 
-    sleep(1);
+    g_usleep(1 * G_USEC_PER_SEC);
     g_assert_cmpint(data.n, ==, 0);
 
     g_assert(aio_poll(ctx, false));
@@ -736,7 +736,7 @@ static void test_source_timer_schedule(void)
 
     g_assert_cmpint(data.n, ==, 0);
 
-    sleep(1);
+    g_usleep(1 * G_USEC_PER_SEC);
     g_assert_cmpint(data.n, ==, 0);
 
     g_assert(g_main_context_iteration(NULL, false));

tests/test-aio.c static void test_source_timer_schedule(void) · line 752

Quoted 8 lines
tests/test-aio.c +1 -1
@@ -746,7 +746,7 @@ static void test_source_timer_schedule(void)
     do {
         g_assert(g_main_context_iteration(NULL, true));
     } while (qemu_clock_get_ns(data.clock_type) <= expiry);
-    sleep(1);
+    g_usleep(1 * G_USEC_PER_SEC);
     g_main_context_iteration(NULL, false);
 
     g_assert_cmpint(data.n, ==, 2);

I cc'ed the mail to qemu-trivial, so it can be applied there.

Stefan

#2 lore raw
Quoted 3 lines · Stefan Weil

Am 30.08.2013 00:32, schrieb Alex Bligh:

Quoted 2 lines

sleep() apparently doesn't exist under mingw. Use g_usleep for portability.

Thanks, applied to the trivial-patches queue.

/mjt