aboutsummaryrefslogtreecommitdiff
path: root/cpu-exec.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2015-01-28 10:09:55 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2015-02-02 16:55:11 +0100
commita498d0ef37cf23e1776240af61f558d113afdf4f (patch)
tree695645c1e3b82d6a47fd7ac99a412ec5828a27a0 /cpu-exec.c
parent2b647668c9092dbc26e36a2ece9647cc2f00e05b (diff)
cpu-exec: simplify align_clocks
sc->diff_clk is already equal to sleep_delay (split in a second and a nanosecond part). If you subtract sleep_delay - rem_delay, the result is exactly rem_delay. Cc: Sebastian Tanase <sebastian.tanase@openwide.fr> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'cpu-exec.c')
-rw-r--r--cpu-exec.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/cpu-exec.c b/cpu-exec.c
index a4f0effaf4..9dd1ca5bb8 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -61,8 +61,7 @@ static void align_clocks(SyncClocks *sc, const CPUState *cpu)
sleep_delay.tv_sec = sc->diff_clk / 1000000000LL;
sleep_delay.tv_nsec = sc->diff_clk % 1000000000LL;
if (nanosleep(&sleep_delay, &rem_delay) < 0) {
- sc->diff_clk -= (sleep_delay.tv_sec - rem_delay.tv_sec) * 1000000000LL;
- sc->diff_clk -= sleep_delay.tv_nsec - rem_delay.tv_nsec;
+ sc->diff_clk = rem_delay.tv_sec * 1000000000LL + rem_delay.tv_nsec;
} else {
sc->diff_clk = 0;
}