[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] hvm: Correct RTC time offset update error due to tm->tm_year



On Tue, 2012-02-21 at 02:31 +0000, ANNIE LI wrote:
> 
> On 2012-2-21 7:54, Zhang, Yang Z wrote:
> >> -----Original Message-----
> >> From: young zhang [mailto:young.zhang.free@xxxxxxxxx]
> >> Sent: Monday, February 20, 2012 11:04 PM
> >> To: Zhang, Yang Z
> >> Cc: ANNIE LI; xen-devel@xxxxxxxxxxxxxxxxxxx; Kurt Hackel; Dan Magenheimer;
> >> Konrad Rzeszutek Wilk
> >> Subject: Re: [Xen-devel] [PATCH] hvm: Correct RTC time offset update error 
> >> due
> >> to tm->tm_year
> >>
> >> The mktime which used in xen is different from standard C. I think the 
> >> best way is
> >> change it same as normal mktime, or else, other people will make the same
> >> mistake too.
> > yes. The name will mislead the people who not look into the code, including 
> > me. :)
> 
> I compared the mktime of xen with mktime of linux. The code is almost 
> the same, I do not understand why xen requires the input year is 
> tm->tm_year, not tm->tm_year+1900. Am I missing somthing?

The Linux kernel's version of mktime and Xen's version both differ from
standard C/POSIX defined function (in fact I expect Xen's is derived
from Linux's). Not least because they take a bunch of values instead of
a struct tm as arguments (i.e. they take unsigned int year, not
tm->tm_year).

If you wanted to compare Xen vs. a POSIX compliant mktime you'd probably
want the libc version. The Xen and Linux mktime()s certainly differ
substantially from the eglibc one.

I don't think you can expect that the in-kernel mktime necessarily has
the same interface as POSIX documents, there is certainly no particular
reason why they should or must (a kernel is not a POSIX environment).
The comment preceding Xen's mktime makes no mention of offsetting
anything by 1900 (or anything else) and I believe its implementation is
consistent with its defined interface.

Ian.

> See following diff file which is created between mktime of linux and 
> mktime of xen, (I did some tab/space format changes for comparison)
> 
> diff linux-mktime.c xen-mktime.c
> 2,4c2,4
> < mktime(const unsigned int year0, const unsigned int mon0,
> <       const unsigned int day, const unsigned int hour,
> <       const unsigned int min, const unsigned int sec)
> ---
>  > mktime (unsigned int year, unsigned int mon,
>  >       unsigned int day, unsigned int hour,
>  >       unsigned int min, unsigned int sec)
> 6,8c6
> <       unsigned int mon = mon0, year = year0;
> <
> <       /* 1..12 -> 11,12,1..10 */
> ---
>  >       /* 1..12 -> 11,12,1..10: put Feb last since it has a leap day. */
> 10c8
> <               mon += 12;      /* Puts Feb last since it has leap day */
> ---
>  >               mon += 12;
> 21d18
> <
> 
> Thanks
> Annie
> >
> > best regards
> > yang
> >
> > _______________________________________________
> > Xen-devel mailing list
> > Xen-devel@xxxxxxxxxxxxx
> > http://lists.xensource.com/xen-devel
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxx
> http://lists.xensource.com/xen-devel



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.