From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L8Lqa-0002GL-2j for qemu-devel@nongnu.org; Thu, 04 Dec 2008 16:34:56 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L8LqZ-0002Ff-4u for qemu-devel@nongnu.org; Thu, 04 Dec 2008 16:34:55 -0500 Received: from [199.232.76.173] (port=50696 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L8LqY-0002FM-KV for qemu-devel@nongnu.org; Thu, 04 Dec 2008 16:34:54 -0500 Received: from savannah.gnu.org ([199.232.41.3]:49287 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1L8LqX-0006Yx-Ua for qemu-devel@nongnu.org; Thu, 04 Dec 2008 16:34:54 -0500 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1L8LqX-00034a-7q for qemu-devel@nongnu.org; Thu, 04 Dec 2008 21:34:53 +0000 Received: from aurel32 by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1L8LqW-00034V-VG for qemu-devel@nongnu.org; Thu, 04 Dec 2008 21:34:53 +0000 MIME-Version: 1.0 Errors-To: aurel32 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Aurelien Jarno Message-Id: Date: Thu, 04 Dec 2008 21:34:52 +0000 Subject: [Qemu-devel] [5878] Fix RTC initial date computation Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 5878 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5878 Author: aurel32 Date: 2008-12-04 21:34:52 +0000 (Thu, 04 Dec 2008) Log Message: ----------- 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 Modified Paths: -------------- trunk/hw/omap1.c trunk/hw/pl031.c trunk/hw/pxa2xx.c Modified: trunk/hw/omap1.c =================================================================== --- trunk/hw/omap1.c 2008-12-04 21:28:28 UTC (rev 5877) +++ trunk/hw/omap1.c 2008-12-04 21:34:52 UTC (rev 5878) @@ -3349,7 +3349,7 @@ 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 @@ #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 @@ #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 @@ 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); Modified: trunk/hw/pl031.c =================================================================== --- trunk/hw/pl031.c 2008-12-04 21:28:28 UTC (rev 5877) +++ trunk/hw/pl031.c 2008-12-04 21:34:52 UTC (rev 5878) @@ -206,7 +206,7 @@ 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); } Modified: trunk/hw/pxa2xx.c =================================================================== --- trunk/hw/pxa2xx.c 2008-12-04 21:28:28 UTC (rev 5877) +++ trunk/hw/pxa2xx.c 2008-12-04 21:34:52 UTC (rev 5878) @@ -1181,7 +1181,7 @@ 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) |