From: "Daniel P. Berrange" <berrange@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Brad Smith <brad@comstyle.com>, QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] osdep: Deal with TIME_MAX and OpenBSD 64-bit time_t
Date: Mon, 6 Nov 2017 11:26:38 +0000 [thread overview]
Message-ID: <20171106112638.GF23361@redhat.com> (raw)
In-Reply-To: <CAFEAcA_2i0p9C3amtoB0o9Y4K83aCP7Gkw1cDqmLjrkLwJTZxg@mail.gmail.com>
On Mon, Nov 06, 2017 at 10:51:16AM +0000, Peter Maydell wrote:
> On 6 November 2017 at 00:56, Brad Smith <brad@comstyle.com> wrote:
> > Define TIME_MAX to LLONG_MAX for OpenBSD since OpenBSD uses 64-bit time_t.
> >
> > Signed-off-by: Brad Smith <brad@comstyle.com>
> >
> >
> > diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
> > index 6855b94bbf..824714049b 100644
> > --- a/include/qemu/osdep.h
> > +++ b/include/qemu/osdep.h
> > @@ -132,8 +132,12 @@ extern int daemon(int, int);
> > #define ESHUTDOWN 4099
> > #endif
> > #ifndef TIME_MAX
> > +#ifdef __OpenBSD__
> > +#define TIME_MAX LLONG_MAX
> > +#else
> > #define TIME_MAX LONG_MAX
> > #endif
> > +#endif
>
> I'm not really a fan of adding new OS-specific #ifdefs --
> what if one of the other BSDs uses or switches to 64-bit
> time_t for 32-bit platforms? Is there some way we can detect
> this generically at compile time (possibly in configure) ?
You could use a pair of compile time asserts to figure it out.
Would need one compile test to check 32 vs 64 bit:
#include <time.h>
char time_t_64bit[sizeof(time_t) == 8 ? 1 : -1];
and a second to check signed vs unsigned:
#include <time.h>
char time_t_signed[(time_t) -1 < 0 ? 1 : -1];
Save each of these programs to the file $TMPC, and then run 'compile_object'
from configure. You then have a decision matrix for 4 different TIME_MAX
values to write into config-host.h.
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
next prev parent reply other threads:[~2017-11-06 11:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-06 0:56 [Qemu-devel] [PATCH] osdep: Deal with TIME_MAX and OpenBSD 64-bit time_t Brad Smith
2017-11-06 10:51 ` Peter Maydell
2017-11-06 11:26 ` Daniel P. Berrange [this message]
2017-11-06 17:41 ` Paolo Bonzini
2017-11-23 15:31 ` Peter Maydell
2017-11-06 17:21 ` Kamil Rytarowski
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=20171106112638.GF23361@redhat.com \
--to=berrange@redhat.com \
--cc=brad@comstyle.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/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.