[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: OpenBSD: gettimeofday and sys/time.h errors
From: |
Paul Eggert |
Subject: |
Re: OpenBSD: gettimeofday and sys/time.h errors |
Date: |
Sat, 10 Aug 2013 22:05:39 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130803 Thunderbird/17.0.8 |
On 08/10/2013 09:44 PM, Mike Miller wrote:
> So is this as close as we can get with gnulib until OpenBSD addresses
> this?
No, I think Gnulib is being too picky here. I installed the
following patch, which I hope fixes the problems you mentioned.
>From 8a087194f758bfd49bc31a247865d66cdcd6b2dd Mon Sep 17 00:00:00 2001
From: Paul Eggert <address@hidden>
Date: Sat, 10 Aug 2013 22:02:58 -0700
Subject: [PATCH] sys_time: port to OpenBSD
* lib/sys_time.in.h: Simply delegate to the system's header
in the BSDish cases as well. Problem reported by Mike Miller in
<http://lists.gnu.org/archive/html/bug-gnulib/2013-08/msg00016.html>.
* tests/test-sys_select.c, tests/test-sys_time.c (verify_tv_sec_type):
Allow platforms like 64-bit OpenBSD where timeval's tv_sec is
wider than time_t.
---
ChangeLog | 10 ++++++++++
lib/sys_time.in.h | 5 +++--
tests/test-sys_select.c | 5 +++--
tests/test-sys_time.c | 5 +++--
4 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3363d6f..b850fb6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2013-08-10 Paul Eggert <address@hidden>
+
+ sys_time: port to OpenBSD
+ * lib/sys_time.in.h: Simply delegate to the system's header
+ in the BSDish cases as well. Problem reported by Mike Miller in
+ <http://lists.gnu.org/archive/html/bug-gnulib/2013-08/msg00016.html>.
+ * tests/test-sys_select.c, tests/test-sys_time.c (verify_tv_sec_type):
+ Allow platforms like 64-bit OpenBSD where timeval's tv_sec is
+ wider than time_t.
+
2013-08-09 Pádraig Brady <address@hidden>
bootstrap: support checksum utils having -c but not --status
diff --git a/lib/sys_time.in.h b/lib/sys_time.in.h
index 09c9601..90dd02b 100644
--- a/lib/sys_time.in.h
+++ b/lib/sys_time.in.h
@@ -24,11 +24,12 @@
#endif
@PRAGMA_COLUMNS@
-/* On Cygwin, <sys/time.h> includes itself recursively via <sys/select.h>.
+/* On Cygwin and on many BSDish systems, <sys/time.h> includes itself
+ recursively via <sys/select.h>.
Simply delegate to the system's header in this case; it is a no-op.
Without this extra ifdef, the C++ gettimeofday declaration below
would be a forward declaration in gnulib's nested <sys/time.h>. */
-#ifdef _CYGWIN_SYS_TIME_H
+#if defined _CYGWIN_SYS_TIME_H || defined _SYS_TIME_H || defined _SYS_TIME_H_
# @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
#else
diff --git a/tests/test-sys_select.c b/tests/test-sys_select.c
index cd84c01..1604699 100644
--- a/tests/test-sys_select.c
+++ b/tests/test-sys_select.c
@@ -40,8 +40,9 @@ SIGNATURE_CHECK (FD_ZERO, void, (fd_set *));
/* Check that the 'struct timeval' type is defined. */
struct timeval a;
-/* Check that &a.tv_sec is a 'time_t *', ignoring signedness issues. */
-typedef int verify_tv_sec_type[sizeof (a.tv_sec) == sizeof (time_t) ? 1 : -1];
+/* Check that a.tv_sec is wide enough to hold a time_t, ignoring
+ signedness issues. */
+typedef int verify_tv_sec_type[sizeof (time_t) <= sizeof (a.tv_sec) ? 1 : -1];
/* Check that sigset_t is defined. */
sigset_t t2;
diff --git a/tests/test-sys_time.c b/tests/test-sys_time.c
index 1389b52..8062842 100644
--- a/tests/test-sys_time.c
+++ b/tests/test-sys_time.c
@@ -23,8 +23,9 @@
/* Check that the 'struct timeval' type is defined. */
struct timeval a;
-/* Check that &a.tv_sec is a 'time_t *', ignoring signedness issues. */
-typedef int verify_tv_sec_type[sizeof (a.tv_sec) == sizeof (time_t) ? 1 : -1];
+/* Check that a.tv_sec is wide enough to hold a time_t, ignoring
+ signedness issues. */
+typedef int verify_tv_sec_type[sizeof (time_t) <= sizeof (a.tv_sec) ? 1 : -1];
int
main (void)
--
1.7.11.7