diff options
author | aurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-12-04 21:34:52 +0000 |
---|---|---|
committer | aurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-12-04 21:34:52 +0000 |
commit | 0cd2df75a2d7223b567c0eaa2547ce6c7d6a83f7 (patch) | |
tree | ec1ea752936674862f150022b0c23eba9cc451f0 /hw | |
parent | bb6834cfae238e342da966557d7d24423efe18ab (diff) |
Fix RTC initial date computation
qemu_get_clock() returns a structure containing the time the user wants
to be set (either UTC time, a local time, or a given date). Use mktimegm()
instead of mktime() to convert it into POSIX time without taking the host
timezone into account.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5878 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'hw')
-rw-r--r-- | hw/omap1.c | 12 | ||||
-rw-r--r-- | hw/pl031.c | 2 | ||||
-rw-r--r-- | hw/pxa2xx.c | 2 |
3 files changed, 8 insertions, 8 deletions
diff --git a/hw/omap1.c b/hw/omap1.c index 85a253ea68..9aa28cab9e 100644 --- a/hw/omap1.c +++ b/hw/omap1.c @@ -3349,7 +3349,7 @@ static void omap_rtc_interrupts_update(struct omap_rtc_s *s) static void omap_rtc_alarm_update(struct omap_rtc_s *s) { - s->alarm_ti = mktime(&s->alarm_tm); + s->alarm_ti = mktimegm(&s->alarm_tm); if (s->alarm_ti == -1) printf("%s: conversion failed\n", __FUNCTION__); } @@ -3492,8 +3492,8 @@ static void omap_rtc_write(void *opaque, target_phys_addr_t addr, #endif memcpy(&new_tm, &s->current_tm, sizeof(new_tm)); new_tm.tm_mon = omap_rtc_bin(value); - ti[0] = mktime(&s->current_tm); - ti[1] = mktime(&new_tm); + ti[0] = mktimegm(&s->current_tm); + ti[1] = mktimegm(&new_tm); if (ti[0] != -1 && ti[1] != -1) { s->ti -= ti[0]; @@ -3511,8 +3511,8 @@ static void omap_rtc_write(void *opaque, target_phys_addr_t addr, #endif memcpy(&new_tm, &s->current_tm, sizeof(new_tm)); new_tm.tm_year += omap_rtc_bin(value) - (new_tm.tm_year % 100); - ti[0] = mktime(&s->current_tm); - ti[1] = mktime(&new_tm); + ti[0] = mktimegm(&s->current_tm); + ti[1] = mktimegm(&new_tm); if (ti[0] != -1 && ti[1] != -1) { s->ti -= ti[0]; @@ -3719,7 +3719,7 @@ static void omap_rtc_reset(struct omap_rtc_s *s) s->alarm_tm.tm_mday = 0x01; s->status = 1 << 7; qemu_get_timedate(&tm, 0); - s->ti = mktime(&tm); + s->ti = mktimegm(&tm); omap_rtc_alarm_update(s); omap_rtc_tick(s); diff --git a/hw/pl031.c b/hw/pl031.c index cd8759faa8..fb5f323cb7 100644 --- a/hw/pl031.c +++ b/hw/pl031.c @@ -206,7 +206,7 @@ void pl031_init(uint32_t base, qemu_irq irq) s->irq = irq; /* ??? We assume vm_clock is zero at this point. */ qemu_get_timedate(&tm, 0); - s->tick_offset = mktime(&tm); + s->tick_offset = mktimegm(&tm); s->timer = qemu_new_timer(vm_clock, pl031_interrupt, s); } diff --git a/hw/pxa2xx.c b/hw/pxa2xx.c index f4295b0523..a281c241b9 100644 --- a/hw/pxa2xx.c +++ b/hw/pxa2xx.c @@ -1181,7 +1181,7 @@ static void pxa2xx_rtc_init(struct pxa2xx_state_s *s) qemu_get_timedate(&tm, 0); wom = ((tm.tm_mday - 1) / 7) + 1; - s->last_rcnr = (uint32_t) mktime(&tm); + s->last_rcnr = (uint32_t) mktimegm(&tm); s->last_rdcr = (wom << 20) | ((tm.tm_wday + 1) << 17) | (tm.tm_hour << 12) | (tm.tm_min << 6) | tm.tm_sec; s->last_rycr = ((tm.tm_year + 1900) << 9) | |