qemu-block
[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: Marc-André Lureau
Subject: Re: [PATCH v2 4/5] Replace qemu_gettimeofday() with g_get_real_time()
Date: Mon, 7 Mar 2022 14:35:01 +0400

Hi

On Mon, Mar 7, 2022 at 2:13 PM Laurent Vivier <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> wrote:
>>
>> From: Marc-André Lureau <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>
>> Reviewed-by: Laurent Vivier <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.

--
Marc-André Lureau

reply via email to

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