qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] aio / timers: use g_usleep() not sleep()
@ 2013-08-29 18:19 Alex Bligh
  2013-08-29 18:38 ` Stefan Weil
  0 siblings, 1 reply; 3+ messages in thread
From: Alex Bligh @ 2013-08-29 18:19 UTC (permalink / raw)
  To: qemu-devel, Charlie Shepherd
  Cc: Kevin Wolf, Anthony Liguori, Alex Bligh, Jan Kiszka, liu ping fan,
	Gerd Hoffmann, Stefan Hajnoczi, Anthony Perard, Paolo Bonzini,
	MORITA Kazutaka, rth

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

Signed-off-by: Alex Bligh <alex@alex.org.uk>
---
 tests/test-aio.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/test-aio.c b/tests/test-aio.c
index 4215701..110fa4a 100644
--- a/tests/test-aio.c
+++ b/tests/test-aio.c
@@ -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);
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] aio / timers: use g_usleep() not sleep()
  2013-08-29 18:19 [Qemu-devel] [PATCH] aio / timers: use g_usleep() not sleep() Alex Bligh
@ 2013-08-29 18:38 ` Stefan Weil
  2013-08-29 22:33   ` Alex Bligh
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Weil @ 2013-08-29 18:38 UTC (permalink / raw)
  To: Alex Bligh
  Cc: Kevin Wolf, Anthony Liguori, Jan Kiszka, qemu-devel, liu ping fan,
	Charlie Shepherd, Gerd Hoffmann, Stefan Hajnoczi, Anthony Perard,
	Paolo Bonzini, MORITA Kazutaka, rth

Am 29.08.2013 20:19, schrieb Alex Bligh:
> sleep() apparently doesn't exist under mingw. Use g_usleep for
> portability.
>
> Signed-off-by: Alex Bligh <alex@alex.org.uk>
> ---
>  tests/test-aio.c |    6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/tests/test-aio.c b/tests/test-aio.c
> index 4215701..110fa4a 100644
> --- a/tests/test-aio.c
> +++ b/tests/test-aio.c
> @@ -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);

Although checkpatch.pl does not complain, I'd prefer a blank before
and after operators like "*".

Here a simple g_usleep(G_USEC_PER_SEC) would be even better.

Otherwise this patch is fine.

Regards,
Stefan

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] aio / timers: use g_usleep() not sleep()
  2013-08-29 18:38 ` Stefan Weil
@ 2013-08-29 22:33   ` Alex Bligh
  0 siblings, 0 replies; 3+ messages in thread
From: Alex Bligh @ 2013-08-29 22:33 UTC (permalink / raw)
  To: Stefan Weil
  Cc: Kevin Wolf, Anthony Liguori, Stefan Hajnoczi, Jan Kiszka,
	qemu-devel, liu ping fan, Charlie Shepherd, Gerd Hoffmann,
	Alex Bligh, Anthony Perard, Paolo Bonzini, MORITA Kazutaka, rth


On 29 Aug 2013, at 19:38, Stefan Weil wrote:
>> 
>> -    sleep(1);
>> +    g_usleep(1*G_USEC_PER_SEC);
> 
> Although checkpatch.pl does not complain, I'd prefer a blank before
> and after operators like "*".
> 
> Here a simple g_usleep(G_USEC_PER_SEC) would be even better.


Prefer 1 as it's then obvious its a conversion and 1 second.

But I've fixed the blank and sent that as v2. I suspect checkpatch
is confused about * meaning a pointer dereference.

-- 
Alex Bligh

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-08-29 22:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-29 18:19 [Qemu-devel] [PATCH] aio / timers: use g_usleep() not sleep() Alex Bligh
2013-08-29 18:38 ` Stefan Weil
2013-08-29 22:33   ` Alex Bligh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).