ticks_per_sec is a constant. There's no need to store it as a variable as it
never changes since our time is based on units.
Convert get_ticks_per_sec() to a static inline and move the constant into
qemu-timer.h. Remove all references to QEMU_TIMER_BASE so that we consistently
use this interface.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
int qemu_timer_pending(QEMUTimer *ts);
int qemu_timer_expired(QEMUTimer *timer_head, int64_t current_time);
int qemu_timer_pending(QEMUTimer *ts);
int qemu_timer_expired(QEMUTimer *timer_head, int64_t current_time);
-int64_t get_ticks_per_sec(void);
+static inline int64_t get_ticks_per_sec(void)
+{
+ return 1000000000LL;
+}
void qemu_get_timer(QEMUFile *f, QEMUTimer *ts);
void qemu_put_timer(QEMUFile *f, QEMUTimer *ts);
void qemu_get_timer(QEMUFile *f, QEMUTimer *ts);
void qemu_put_timer(QEMUFile *f, QEMUTimer *ts);
/***********************************************************/
/* real time host monotonic timer */
/***********************************************************/
/* real time host monotonic timer */
-#define QEMU_TIMER_BASE 1000000000LL
-
#ifdef WIN32
static int64_t clock_freq;
#ifdef WIN32
static int64_t clock_freq;
{
LARGE_INTEGER ti;
QueryPerformanceCounter(&ti);
{
LARGE_INTEGER ti;
QueryPerformanceCounter(&ti);
- return muldiv64(ti.QuadPart, QEMU_TIMER_BASE, clock_freq);
+ return muldiv64(ti.QuadPart, get_ticks_per_sec(), clock_freq);
int64_t cpu_ticks_offset;
int64_t cpu_clock_offset;
int32_t cpu_ticks_enabled;
int64_t cpu_ticks_offset;
int64_t cpu_clock_offset;
int32_t cpu_ticks_enabled;
} TimersState;
TimersState timers_state;
} TimersState;
TimersState timers_state;
fairly approximate, so ignore small variation.
When the guest is idle real and virtual time will be aligned in
the IO wait loop. */
fairly approximate, so ignore small variation.
When the guest is idle real and virtual time will be aligned in
the IO wait loop. */
-#define ICOUNT_WOBBLE (QEMU_TIMER_BASE / 10)
+#define ICOUNT_WOBBLE (get_ticks_per_sec() / 10)
static void icount_adjust(void)
{
static void icount_adjust(void)
{
static void icount_adjust_vm(void * opaque)
{
qemu_mod_timer(icount_vm_timer,
static void icount_adjust_vm(void * opaque)
{
qemu_mod_timer(icount_vm_timer,
- qemu_get_clock(vm_clock) + QEMU_TIMER_BASE / 10);
+ qemu_get_clock(vm_clock) + get_ticks_per_sec() / 10);
qemu_get_clock(rt_clock) + 1000);
icount_vm_timer = qemu_new_timer(vm_clock, icount_adjust_vm, NULL);
qemu_mod_timer(icount_vm_timer,
qemu_get_clock(rt_clock) + 1000);
icount_vm_timer = qemu_new_timer(vm_clock, icount_adjust_vm, NULL);
qemu_mod_timer(icount_vm_timer,
- qemu_get_clock(vm_clock) + QEMU_TIMER_BASE / 10);
+ qemu_get_clock(vm_clock) + get_ticks_per_sec() / 10);
}
static struct qemu_alarm_timer alarm_timers[] = {
}
static struct qemu_alarm_timer alarm_timers[] = {
-int64_t get_ticks_per_sec(void)
-{
- return timers_state.ticks_per_sec;
-}
-
static void init_timers(void)
{
init_get_clock();
static void init_timers(void)
{
init_get_clock();
- timers_state.ticks_per_sec = QEMU_TIMER_BASE;
rt_clock = qemu_new_clock(QEMU_TIMER_REALTIME);
vm_clock = qemu_new_clock(QEMU_TIMER_VIRTUAL);
}
rt_clock = qemu_new_clock(QEMU_TIMER_REALTIME);
vm_clock = qemu_new_clock(QEMU_TIMER_VIRTUAL);
}
.minimum_version_id_old = 1,
.fields = (VMStateField []) {
VMSTATE_INT64(cpu_ticks_offset, TimersState),
.minimum_version_id_old = 1,
.fields = (VMStateField []) {
VMSTATE_INT64(cpu_ticks_offset, TimersState),
- VMSTATE_INT64(ticks_per_sec, TimersState),
+ VMSTATE_INT64(dummy, TimersState),
VMSTATE_INT64_V(cpu_clock_offset, TimersState, 2),
VMSTATE_END_OF_LIST()
}
VMSTATE_INT64_V(cpu_clock_offset, TimersState, 2),
VMSTATE_END_OF_LIST()
}