[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 1/3]use int64 when compare two time
From: |
Zhang, Yang Z |
Subject: |
[Qemu-devel] [PATCH 1/3]use int64 when compare two time |
Date: |
Fri, 6 Jan 2012 07:37:24 +0000 |
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 <address@hidden>
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);
}
- [Qemu-devel] [PATCH 1/3]use int64 when compare two time,
Zhang, Yang Z <=