qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 4/5] Replace qemu_gettimeofday() with g_get_real_time()


From: Laurent Vivier
Subject: Re: [PATCH v2 4/5] Replace qemu_gettimeofday() with g_get_real_time()
Date: Mon, 7 Mar 2022 12:36:58 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0

Le 07/03/2022 à 11:35, Marc-André Lureau a écrit :
Hi

On Mon, Mar 7, 2022 at 2:13 PM Laurent Vivier <laurent@vivier.eu 
<mailto:laurent@vivier.eu>> wrote:

    Le 05/03/2022 à 20:17, Marc-André Lureau a écrit :
     > On Sat, Mar 5, 2022 at 1:18 AM <marcandre.lureau@redhat.com
    <mailto:marcandre.lureau@redhat.com>> wrote:
     >>
     >> From: Marc-André Lureau <marcandre.lureau@redhat.com 
<mailto:marcandre.lureau@redhat.com>>
     >>
     >> GLib g_get_real_time() is an alternative to gettimeofday() which allows
     >> to simplify our code.
     >>
     >> For semihosting, a few bits are lost on POSIX host, but this shouldn't
     >> be a big concern.
     >>
     >> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com
    <mailto:marcandre.lureau@redhat.com>>
     >> Reviewed-by: Laurent Vivier <laurent@vivier.eu 
<mailto:laurent@vivier.eu>>
     >> ---
     >>   blockdev.c                 |  8 ++++----
     >>   hw/rtc/m41t80.c            |  6 +++---
     >>   hw/virtio/virtio-balloon.c |  9 +--------
     >>   qapi/qmp-event.c           | 12 +++++-------
     >>   qemu-img.c                 |  8 ++++----
     >>   target/m68k/m68k-semi.c    | 22 ++++++++++------------
     >>   target/nios2/nios2-semi.c  | 23 ++++++++++-------------
     >>   7 files changed, 37 insertions(+), 51 deletions(-)
     >>
    ...
     >> index 19d3cd003833..025716b3ec37 100644
     >> --- a/qapi/qmp-event.c
     >> +++ b/qapi/qmp-event.c
     >> @@ -20,15 +20,13 @@
     >>
     >>   static void timestamp_put(QDict *qdict)
     >>   {
     >> -    int err;
     >>       QDict *ts;
     >> -    qemu_timeval tv;
     >> +    int64_t rt = g_get_real_time();
     >>
     >> -    err = qemu_gettimeofday(&tv);
     >> -    /* Put -1 to indicate failure of getting host time */
     >> -    ts = qdict_from_jsonf_nofail("{ 'seconds': %lld, 'microseconds': %lld 
}",
     >> -                                 err < 0 ? -1LL : (long long)tv.tv_sec,
     >> -                                 err < 0 ? -1LL : (long 
long)tv.tv_usec);
     >> +    ts = qdict_from_jsonf_nofail("{ 'seconds': %" G_GINT64_FORMAT
     >> +                                 ", 'microseconds': %" G_GINT64_FORMAT 
"}",
     >> +                                 rt / G_USEC_PER_SEC,
     >> +                                 rt % G_USEC_PER_SEC);
     >
     > NACK this, fixed in v3

    Why keeping the %lld is better than moving to %G_GINT64_FORMAT?


It's not supported by json-parser.c parse_interpolation(). We could address 
this in a different patch.

Yes, it would be a simple fix: it already supports "%i" and "%ld" but not "%li".

Thanks,
Laurent




reply via email to

[Prev in Thread] Current Thread [Next in Thread]