changeset 17465:a2d511609297

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.
author Paul Eggert <eggert@cs.ucla.edu>
date Sat, 10 Aug 2013 22:02:58 -0700
parents 290d581e2e24
children 6a24e1749b9f
files ChangeLog lib/sys_time.in.h tests/test-sys_select.c tests/test-sys_time.c
diffstat 4 files changed, 19 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2013-08-10  Paul Eggert  <eggert@cs.ucla.edu>
+
+	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 <P@draigBrady.com>
 
 	bootstrap: support checksum utils having -c but not --status
--- 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
 
--- a/tests/test-sys_select.c
+++ b/tests/test-sys_select.c
@@ -40,8 +40,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];
 
 /* Check that sigset_t is defined.  */
 sigset_t t2;
--- 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)