[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] time: enforce recent POSIX ruling that time_t is integral
From: |
Eric Blake |
Subject: |
[PATCH] time: enforce recent POSIX ruling that time_t is integral |
Date: |
Fri, 8 Oct 2010 17:20:49 -0600 |
* lib/time.in.h (__time_t_must_be_integral): Detect any
problematic systems, allowing the rest of gnulib to assume POSIX.
Signed-off-by: Eric Blake <address@hidden>
---
> > oppose a patch that adds a compile-time verification in gnulib's
> > <time.h> that time_t is integral on all platforms that we support,
> > given that POSIX now requires this even though C99 doesn't?
> I can't imagine anyone objecting. Thanks!
Then I'm pushing this. Since our replacement <time.h> is intended to
be installable in a libposix setting, I couldn't directly use
"verify.h", but had to inline the important parts of it; on the other
hand, since I'm not reusing verify() I don't need quite as much
wrapper logic to protect against reuse of an identifier.
Hmm, given Bruno's recent point that C89 didn't require ?: support
in constant expressions, should we re-visit verify.h to use
(2 * cond - 1) instead of (cond ? 1 : -1)?
ChangeLog | 6 ++++++
lib/time.in.h | 9 +++++++++
2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 9130e57..3d68f20 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2010-10-08 Eric Blake <address@hidden>
+
+ time: enforce recent POSIX ruling that time_t is integral
+ * lib/time.in.h (__time_t_must_be_integral): Detect any
+ problematic systems, allowing the rest of gnulib to assume POSIX.
+
2010-10-08 Jim Meyering <address@hidden>
fdopendir: fix a bug on systems lacking openat and /proc support
diff --git a/lib/time.in.h b/lib/time.in.h
index 28e3f5f..f6bdad6 100644
--- a/lib/time.in.h
+++ b/lib/time.in.h
@@ -84,6 +84,15 @@ struct timespec
# endif
# endif
+/* Per http://austingroupbugs.net/view.php?id=327, POSIX requires
+ time_t to be an integer type, even though C99 permits floating
+ point. We don't know of any implementation that uses floating
+ point, and it is much easier to write code that doesn't have to
+ worry about that corner case, so we force the issue. */
+struct __time_t_must_be_integral {
+ unsigned int __floating_time_t_unsupported : 2 * ((time_t) 1 / 2 == 0) - 1;
+};
+
/* Sleep for at least RQTP seconds unless interrupted, If interrupted,
return -1 and store the remaining time into RMTP. See
<http://www.opengroup.org/susv3xsh/nanosleep.html>. */
--
1.7.2.3
- Re: [coreutils] [PATCH 2/2] stat: print timestamps to full resolution, Eric Blake, 2010/10/08
- Re: [coreutils] [PATCH 2/2] stat: print timestamps to full resolution, Jim Meyering, 2010/10/08
- [PATCH] time: enforce recent POSIX ruling that time_t is integral,
Eric Blake <=
- Re: [PATCH] time: enforce recent POSIX ruling that time_t is integral, Bruno Haible, 2010/10/09
- Re: [PATCH] time: enforce recent POSIX ruling that time_t is integral, Paul Eggert, 2010/10/09
- Re: [PATCH] time: enforce recent POSIX ruling that time_t is integral, Bruno Haible, 2010/10/10
- Re: [PATCH] time: enforce recent POSIX ruling that time_t is integral, Paul Eggert, 2010/10/10
- Re: [PATCH] time: enforce recent POSIX ruling that time_t is integral, Paul Eggert, 2010/10/10
- Re: [PATCH] time: enforce recent POSIX ruling that time_t is integral, Bruno Haible, 2010/10/10
- Re: [PATCH] time: enforce recent POSIX ruling that time_t is integral, Paul Eggert, 2010/10/10
- Re: [PATCH] time: enforce recent POSIX ruling that time_t is integral, Bruno Haible, 2010/10/10
- Re: [PATCH] time: enforce recent POSIX ruling that time_t is integral, Paul Eggert, 2010/10/10
- [PATCH] Fix mismatched parens in previous commit, Gary V. Vaughan, 2010/10/11