qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/3]use int64 when compare two time
@ 2012-01-06  7:37 Zhang, Yang Z
  2012-01-06 13:20 ` Peter Maydell
  2012-01-06 17:44 ` Andreas Färber
  0 siblings, 2 replies; 5+ messages in thread
From: Zhang, Yang Z @ 2012-01-06  7:37 UTC (permalink / raw)
  To: qemu-devel@nongnu.org
  Cc: aliguori@us.ibm.com, Shan, Haitao, avi@redhat.com,
	kvm@vger.kernel.org

use int64 when compare two time

int32 only represent only 136 years when comparing two times based on second. It would be better to use int64.

Signed-off-by: Yang Zhang <yang.z.zhang@intel.com>

diff --git a/qemu-common.h b/qemu-common.h
index b2de015..c14f506 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -116,8 +116,8 @@ extern int use_icount;
 int qemu_main(int argc, char **argv, char **envp);
 #endif

-void qemu_get_timedate(struct tm *tm, int offset);
-int qemu_timedate_diff(struct tm *tm);
+void qemu_get_timedate(struct tm *tm, int64_t offset);
+int64_t qemu_timedate_diff(struct tm *tm);

 /* cutils.c */
 void pstrcpy(char *buf, int buf_size, const char *str);
diff --git a/vl.c b/vl.c
index 640e3ca..01c5a9d 100644
--- a/vl.c
+++ b/vl.c
@@ -189,7 +189,7 @@ int nb_nics;
 NICInfo nd_table[MAX_NICS];
 int autostart;
 static int rtc_utc = 1;
-static int rtc_date_offset = -1; /* -1 means no change */
+static int64_t rtc_date_offset = -1; /* -1 means no change */
 QEMUClock *rtc_clock;
 int vga_interface_type = VGA_NONE;
 static int full_screen = 0;
@@ -434,7 +434,7 @@ StatusInfo *qmp_query_status(Error **errp)

 /***********************************************************/
 /* host time/date access */
-void qemu_get_timedate(struct tm *tm, int offset)
+void qemu_get_timedate(struct tm *tm, int64_t offset)
 {
     time_t ti;
     struct tm *ret;
@@ -454,7 +454,7 @@ void qemu_get_timedate(struct tm *tm, int offset)
     memcpy(tm, ret, sizeof(struct tm));
 }

-int qemu_timedate_diff(struct tm *tm)
+int64_t qemu_timedate_diff(struct tm *tm)
 {
     time_t seconds;

@@ -476,7 +476,7 @@ void rtc_change_mon_event(struct tm *tm)
 {
     QObject *data;

-    data = qobject_from_jsonf("{ 'offset': %d }", qemu_timedate_diff(tm));
+    data = qobject_from_jsonf("{ 'offset': %ld }", qemu_timedate_diff(tm));
     monitor_protocol_event(QEVENT_RTC_CHANGE, data);
     qobject_decref(data);
 }

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-01-10 17:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-06  7:37 [Qemu-devel] [PATCH 1/3]use int64 when compare two time Zhang, Yang Z
2012-01-06 13:20 ` Peter Maydell
2012-01-10 16:51   ` Marcelo Tosatti
2012-01-06 17:44 ` Andreas Färber
2012-01-10  5:18   ` Zhang, Yang Z

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).