From: Paolo Bonzini <pbonzini@redhat.com>
To: "Radim Krčmář" <rkrcmar@redhat.com>,
"Laurent Vivier" <lvivier@redhat.com>
Cc: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, drjones@redhat.com,
thuth@redhat.com, dgibson@redhat.com
Subject: Re: [kvm-unit-tests PATCH] powerpc: Add tests for RTAS
Date: Thu, 3 Mar 2016 17:29:30 +0100 [thread overview]
Message-ID: <56D8666A.40508@redhat.com> (raw)
In-Reply-To: <20160303160309.GC2354@potion.brq.redhat.com>
On 03/03/2016 17:03, Radim Krčmář wrote:
>> > diff --git a/powerpc/rtas.c b/powerpc/rtas.c
>> > +#define DAYS(y,m,d) (365UL * (y) + ((y) / 4) - ((y) / 100) + ((y) / 400) + \
>> > + 367UL * (m) / 12 + \
>> > + (d))
> This function is hard to (re)use.
> What about putting the "month -= 2" block together with DAYS to give a
> better estimate of the amount of days in the gregorian calendar?
Even the Gregorian calendar only starts in 1583 though. :)
This is just a utility function for mktime. I think it's okay. We
should aim at making libcflat a minimal libc, and in that case we would
move mktime to lib/. Putting stuff directly in tests is good enough
(worse is better), but let's remember that duplicated code is not.
Paolo
> static inline unsigned long days(int year, int month, int day) {
> month -= 2;
> if (month <= 0) {
> month += 12;
> year -= 1;
> }
> return DAYS(year, month, day);
> }
>
> (Or replacing it with an obvious, but slower/bigger implementation? :])
>
>> > + /* Put February at end of the year to avoid leap day this year */
>> > +
>> > + month -= 2;
>> > + if (month <= 0) {
>> > + month += 12;
>> > + year -= 1;
>> > + }
>> > +
>> > + /* compute epoch: substract DAYS(since_March(1-1-1970)) */
>> > +
>> > + epoch = DAYS(year, month, day) - DAYS(1969, 11, 1);
next prev parent reply other threads:[~2016-03-03 16:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-03 12:28 [kvm-unit-tests PATCH] powerpc: Add tests for RTAS Laurent Vivier
2016-03-03 12:45 ` Paolo Bonzini
2016-03-03 13:02 ` Laurent Vivier
2016-03-03 16:03 ` Radim Krčmář
2016-03-03 16:29 ` Paolo Bonzini [this message]
2016-03-03 17:09 ` Radim Krčmář
2016-03-03 17:12 ` Paolo Bonzini
2016-03-03 17:17 ` Radim Krčmář
2016-03-03 16:54 ` Thomas Huth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56D8666A.40508@redhat.com \
--to=pbonzini@redhat.com \
--cc=dgibson@redhat.com \
--cc=drjones@redhat.com \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=lvivier@redhat.com \
--cc=rkrcmar@redhat.com \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox