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:
Marc-André Lureau 2022-03-07 11:04:00 +04:00 committed by Paolo Bonzini
parent 287698e50f
commit f793dde091
7 changed files with 35 additions and 50 deletions

View file

@ -47,7 +47,7 @@ static uint8_t m41t80_recv(I2CSlave *i2c)
{
M41t80State *s = M41T80(i2c);
struct tm now;
qemu_timeval tv;
int64_t rt;
if (s->addr < 0) {
s->addr = 0;
@ -57,8 +57,8 @@ static uint8_t m41t80_recv(I2CSlave *i2c)
}
switch (s->addr++) {
case 0:
qemu_gettimeofday(&tv);
return to_bcd(tv.tv_usec / 10000);
rt = g_get_real_time();
return to_bcd((rt % G_USEC_PER_SEC) / 10000);
case 1:
return to_bcd(now.tm_sec);
case 2: