mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 00:33:55 -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
|
@ -378,19 +378,17 @@ void do_m68k_semihosting(CPUM68KState *env, int nr)
|
|||
arg0, arg1);
|
||||
return;
|
||||
} else {
|
||||
qemu_timeval tv;
|
||||
struct gdb_timeval *p;
|
||||
result = qemu_gettimeofday(&tv);
|
||||
if (result == 0) {
|
||||
if (!(p = lock_user(VERIFY_WRITE,
|
||||
arg0, sizeof(struct gdb_timeval), 0))) {
|
||||
/* FIXME - check error code? */
|
||||
result = -1;
|
||||
} else {
|
||||
p->tv_sec = cpu_to_be32(tv.tv_sec);
|
||||
p->tv_usec = cpu_to_be64(tv.tv_usec);
|
||||
unlock_user(p, arg0, sizeof(struct gdb_timeval));
|
||||
}
|
||||
int64_t rt = g_get_real_time();
|
||||
p = lock_user(VERIFY_WRITE, arg0, sizeof(struct gdb_timeval), 0);
|
||||
if (!p) {
|
||||
/* FIXME - check error code? */
|
||||
result = -1;
|
||||
} else {
|
||||
result = 0;
|
||||
p->tv_sec = cpu_to_be32(rt / G_USEC_PER_SEC);
|
||||
p->tv_usec = cpu_to_be64(rt % G_USEC_PER_SEC);
|
||||
unlock_user(p, arg0, sizeof(struct gdb_timeval));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue