Commit 0cd2df75a2d7223b567c0eaa2547ce6c7d6a83f7

Authored by aurel32
1 parent bb6834cf

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
hw/omap1.c
... ... @@ -3349,7 +3349,7 @@ static void omap_rtc_interrupts_update(struct omap_rtc_s *s)
3349 3349  
3350 3350 static void omap_rtc_alarm_update(struct omap_rtc_s *s)
3351 3351 {
3352   - s->alarm_ti = mktime(&s->alarm_tm);
  3352 + s->alarm_ti = mktimegm(&s->alarm_tm);
3353 3353 if (s->alarm_ti == -1)
3354 3354 printf("%s: conversion failed\n", __FUNCTION__);
3355 3355 }
... ... @@ -3492,8 +3492,8 @@ static void omap_rtc_write(void *opaque, target_phys_addr_t addr,
3492 3492 #endif
3493 3493 memcpy(&new_tm, &s->current_tm, sizeof(new_tm));
3494 3494 new_tm.tm_mon = omap_rtc_bin(value);
3495   - ti[0] = mktime(&s->current_tm);
3496   - ti[1] = mktime(&new_tm);
  3495 + ti[0] = mktimegm(&s->current_tm);
  3496 + ti[1] = mktimegm(&new_tm);
3497 3497  
3498 3498 if (ti[0] != -1 && ti[1] != -1) {
3499 3499 s->ti -= ti[0];
... ... @@ -3511,8 +3511,8 @@ static void omap_rtc_write(void *opaque, target_phys_addr_t addr,
3511 3511 #endif
3512 3512 memcpy(&new_tm, &s->current_tm, sizeof(new_tm));
3513 3513 new_tm.tm_year += omap_rtc_bin(value) - (new_tm.tm_year % 100);
3514   - ti[0] = mktime(&s->current_tm);
3515   - ti[1] = mktime(&new_tm);
  3514 + ti[0] = mktimegm(&s->current_tm);
  3515 + ti[1] = mktimegm(&new_tm);
3516 3516  
3517 3517 if (ti[0] != -1 && ti[1] != -1) {
3518 3518 s->ti -= ti[0];
... ... @@ -3719,7 +3719,7 @@ static void omap_rtc_reset(struct omap_rtc_s *s)
3719 3719 s->alarm_tm.tm_mday = 0x01;
3720 3720 s->status = 1 << 7;
3721 3721 qemu_get_timedate(&tm, 0);
3722   - s->ti = mktime(&tm);
  3722 + s->ti = mktimegm(&tm);
3723 3723  
3724 3724 omap_rtc_alarm_update(s);
3725 3725 omap_rtc_tick(s);
... ...
hw/pl031.c
... ... @@ -206,7 +206,7 @@ void pl031_init(uint32_t base, qemu_irq irq)
206 206 s->irq = irq;
207 207 /* ??? We assume vm_clock is zero at this point. */
208 208 qemu_get_timedate(&tm, 0);
209   - s->tick_offset = mktime(&tm);
  209 + s->tick_offset = mktimegm(&tm);
210 210  
211 211 s->timer = qemu_new_timer(vm_clock, pl031_interrupt, s);
212 212 }
... ...
hw/pxa2xx.c
... ... @@ -1181,7 +1181,7 @@ static void pxa2xx_rtc_init(struct pxa2xx_state_s *s)
1181 1181 qemu_get_timedate(&tm, 0);
1182 1182 wom = ((tm.tm_mday - 1) / 7) + 1;
1183 1183  
1184   - s->last_rcnr = (uint32_t) mktime(&tm);
  1184 + s->last_rcnr = (uint32_t) mktimegm(&tm);
1185 1185 s->last_rdcr = (wom << 20) | ((tm.tm_wday + 1) << 17) |
1186 1186 (tm.tm_hour << 12) | (tm.tm_min << 6) | tm.tm_sec;
1187 1187 s->last_rycr = ((tm.tm_year + 1900) << 9) |
... ...