diff options
author | Marc-André Lureau | 2022-03-07 08:04:00 +0100 |
---|---|---|
committer | Paolo Bonzini | 2022-04-06 10:50:37 +0200 |
commit | f793dde0914ae7f2605ee22c5bbc81dc79e23eee (patch) | |
tree | af62c611c5d4f73d9a87bc8ec84d2ae5265e9d8d /qapi | |
parent | qga: replace qemu_gettimeofday() with g_get_real_time() (diff) | |
download | qemu-f793dde0914ae7f2605ee22c5bbc81dc79e23eee.tar.gz qemu-f793dde0914ae7f2605ee22c5bbc81dc79e23eee.tar.xz qemu-f793dde0914ae7f2605ee22c5bbc81dc79e23eee.zip |
Replace qemu_gettimeofday() with g_get_real_time()
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>
Message-Id: <20220307070401.171986-5-marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'qapi')
-rw-r--r-- | qapi/qmp-event.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/qapi/qmp-event.c b/qapi/qmp-event.c index 19d3cd0038..0fe0d0a5a6 100644 --- a/qapi/qmp-event.c +++ b/qapi/qmp-event.c @@ -20,15 +20,12 @@ 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); + (long long)rt / G_USEC_PER_SEC, + (long long)rt % G_USEC_PER_SEC); qdict_put(qdict, "timestamp", ts); } |