[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 3/9] Remove support for CLOCK_MONOTONIC not being defined
From: |
Paolo Bonzini |
Subject: |
[PULL 3/9] Remove support for CLOCK_MONOTONIC not being defined |
Date: |
Wed, 12 Feb 2020 17:41:23 +0100 |
From: Peter Maydell <address@hidden>
Some older parts of QEMU's codebase assume that CLOCK_MONOTONIC
might not be defined by the host OS, and have workarounds to
deal with this. However, more recently (notably in commit
50290c002c045280f8d for qemu-img in mid-2019, but also much
earlier in 2011 in commit 22795174a37e0 for ui/spice-display.c)
we've written code that assumes CLOCK_MONOTONIC is always
defined. The only host OS anybody's ever noticed this on
is OSX 10.11 and earlier, which we don't support.
So we can assume that all our host OSes have the #define,
and we can remove some now-unnecessary ifdefs.
Signed-off-by: Peter Maydell <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
include/qemu/timer.h | 5 +----
util/qemu-timer-common.c | 11 ++++-------
2 files changed, 5 insertions(+), 11 deletions(-)
diff --git a/include/qemu/timer.h b/include/qemu/timer.h
index 85bc6eb00b..6a8b48b5a9 100644
--- a/include/qemu/timer.h
+++ b/include/qemu/timer.h
@@ -838,14 +838,11 @@ extern int use_rt_clock;
static inline int64_t get_clock(void)
{
-#ifdef CLOCK_MONOTONIC
if (use_rt_clock) {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return ts.tv_sec * 1000000000LL + ts.tv_nsec;
- } else
-#endif
- {
+ } else {
/* XXX: using gettimeofday leads to problems if the date
changes, so it should be avoided. */
return get_clock_realtime();
diff --git a/util/qemu-timer-common.c b/util/qemu-timer-common.c
index 06d084d364..baf3317f74 100644
--- a/util/qemu-timer-common.c
+++ b/util/qemu-timer-common.c
@@ -49,14 +49,11 @@ int use_rt_clock;
static void __attribute__((constructor)) init_get_clock(void)
{
+ struct timespec ts;
+
use_rt_clock = 0;
-#ifdef CLOCK_MONOTONIC
- {
- struct timespec ts;
- if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) {
- use_rt_clock = 1;
- }
+ if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) {
+ use_rt_clock = 1;
}
-#endif
}
#endif
--
2.21.0
- [PULL 0/9] Mini misc patches queue for 2020-02-12, Paolo Bonzini, 2020/02/12
- [PULL 1/9] vl: Don't mismatch g_strsplit()/g_free(), Paolo Bonzini, 2020/02/12
- [PULL 2/9] seqlock: fix seqlock_write_unlock_impl function, Paolo Bonzini, 2020/02/12
- [PULL 3/9] Remove support for CLOCK_MONOTONIC not being defined,
Paolo Bonzini <=
- [PULL 4/9] minikconf: accept alnum identifiers, Paolo Bonzini, 2020/02/12
- [PULL 5/9] exec: do not define use_icount for user-mode emulation, Paolo Bonzini, 2020/02/12
- [PULL 6/9] build: move TARGET_GPROF to config-host.mak, Paolo Bonzini, 2020/02/12
- [PULL 7/9] target/i386: fix TCG UCODE_REV access, Paolo Bonzini, 2020/02/12
- [PULL 8/9] target/i386: check for availability of MSR_IA32_UCODE_REV as an emulated MSR, Paolo Bonzini, 2020/02/12
- [PULL 9/9] target/i386: enable monitor and ucode revision with -cpu max, Paolo Bonzini, 2020/02/12
- Re: [PULL 0/9] Mini misc patches queue for 2020-02-12, Peter Maydell, 2020/02/13