From: "Radim Krčmář" <rkrcmar@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Laurent Vivier <lvivier@redhat.com>,
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, 03 Mar 2016 17:09:13 +0000 [thread overview]
Message-ID: <20160303170912.GD2354@potion.brq.redhat.com> (raw)
In-Reply-To: <56D8666A.40508@redhat.com>
2016-03-03 17:29+0100, Paolo Bonzini:
> 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.
I agree that there is no need to move stuff into lib/.
I just wouldn't expose DAYS in this shape even to mktime, because DAYS
makes little sense without the "month -= 2" fixup.
>>> > + /* Put February at end of the year to avoid leap day this year */
Leap day is not the only reason.
'367UL * (m) / 12' equation needs to have shifted months to report the
correct numbers of days throughout any year.
>>> > + /* compute epoch: substract DAYS(since_March(1-1-1970)) */
>>> > + epoch = DAYS(year, month, day) - DAYS(1969, 11, 1);
And this comment points out that the API is bad. :)
(Btw. am I going overboard?)
WARNING: multiple messages have this Message-ID (diff)
From: "Radim Krčmář" <rkrcmar@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Laurent Vivier <lvivier@redhat.com>,
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 18:09:13 +0100 [thread overview]
Message-ID: <20160303170912.GD2354@potion.brq.redhat.com> (raw)
In-Reply-To: <56D8666A.40508@redhat.com>
2016-03-03 17:29+0100, Paolo Bonzini:
> 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.
I agree that there is no need to move stuff into lib/.
I just wouldn't expose DAYS in this shape even to mktime, because DAYS
makes little sense without the "month -= 2" fixup.
>>> > + /* Put February at end of the year to avoid leap day this year */
Leap day is not the only reason.
'367UL * (m) / 12' equation needs to have shifted months to report the
correct numbers of days throughout any year.
>>> > + /* compute epoch: substract DAYS(since_March(1-1-1970)) */
>>> > + epoch = DAYS(year, month, day) - DAYS(1969, 11, 1);
And this comment points out that the API is bad. :)
(Btw. am I going overboard?)
next prev parent reply other threads:[~2016-03-03 17:09 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-25 21:19 [kvm-unit-tests PATCH] powerpc: Add tests for sPAPR h-calls Thomas Huth
2016-02-25 21:19 ` Thomas Huth
2016-02-29 0:38 ` David Gibson
2016-02-29 0:38 ` David Gibson
2016-03-03 12:28 ` [kvm-unit-tests PATCH] powerpc: Add tests for RTAS Laurent Vivier
2016-03-03 12:28 ` Laurent Vivier
2016-03-03 12:45 ` Paolo Bonzini
2016-03-03 12:45 ` Paolo Bonzini
2016-03-03 13:02 ` Laurent Vivier
2016-03-03 13:02 ` Laurent Vivier
2016-03-03 16:03 ` Radim Krčmář
2016-03-03 16:03 ` Radim Krčmář
2016-03-03 16:29 ` Paolo Bonzini
2016-03-03 16:29 ` Paolo Bonzini
2016-03-03 17:09 ` Radim Krčmář [this message]
2016-03-03 17:09 ` Radim Krčmář
2016-03-03 17:12 ` Paolo Bonzini
2016-03-03 17:12 ` Paolo Bonzini
2016-03-03 17:17 ` Radim Krčmář
2016-03-03 17:17 ` Radim Krčmář
2016-03-03 16:54 ` Thomas Huth
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=20160303170912.GD2354@potion.brq.redhat.com \
--to=rkrcmar@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=pbonzini@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.