mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
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>
This commit is contained in:
parent
287698e50f
commit
f793dde091
7 changed files with 35 additions and 50 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue