[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gettimeofday module on cygwin
From: |
Bruno Haible |
Subject: |
Re: gettimeofday module on cygwin |
Date: |
Fri, 6 Jul 2007 01:27:00 +0200 |
User-agent: |
KMail/1.5.4 |
Eric Blake wrote:
> cygwin's <sys/time.h> declares struct
> timeval, then includes <sys/select.h>, which in turn includes <sys/time.h>
> to guarantee struct timeval is declared no matter which header was
> included first. But once gnulib has decided that cygwin needs the
> replacement, it turns into the following:
>
> include ./sys/time.h
> first time, so...
> include_next /usr/include/sys/time.h
> declare struct timeval
> include /usr/include/sys/select.h
> include ./sys/time.h
> second time, so...
> define gettimeofday rpl_gettimeofday
> declare gettimeofday (struct timeval*, void*);
> declare gettimeofday (struct timeval*, struct timezone*)
I don't understand this sequence. Did you mean to indent it like this?
include ./sys/time.h
first time, so...
include_next /usr/include/sys/time.h
declare struct timeval
include /usr/include/sys/select.h
include ./sys/time.h
second time, so...
define gettimeofday rpl_gettimeofday
declare gettimeofday (struct timeval*, void*);
declare gettimeofday (struct timeval*, struct timezone*)
Paul patched lib/time_.h so that it allows recursive includes on 2007-06-23;
appended is a proposed patch to do the same with lib/sys_time_.h.
> At any rate, is it necessary that gettimeofday.m4 insist that gettimeofday
> have void* as the type of the second parameter?
The gettimeofday redeclaration is fine. There is no need to blame it.
> Without -Werror,
> gnulib does not create ./sys/time.h, so this problem does not surface.
Maybe gnulib will create a sys/time.h for other reasons in the future.
Therefore it's not worthless to fix the problem now, even through -Werror
is unsupported by gnulib.
Bruno
2007-07-05 Bruno Haible <address@hidden>
* lib/sys_time_.h: Use a recursion-safe inclusion guard rather than
a split double-inclusion guard. Needed for cygwin, where <sys/time.h>
includes <cygwin/sys_time.h> which includes <sys/select.h> which
include <sys/time.h>.
Reported by Eric Blake.
--- lib/sys_time_.h 21 Jun 2007 04:39:11 -0000 1.7
+++ lib/sys_time_.h 5 Jul 2007 23:17:50 -0000
@@ -18,31 +18,35 @@
/* Written by Paul Eggert. */
-#ifndef _GL_SYS_TIME_H
+#if defined _GL_SYS_TIME_H
+
+/* Simply delegate to the system's header, without adding anything. */
+# if @HAVE_SYS_TIME_H@
+# @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
+# endif
-/* The include_next requires a split double-inclusion guard. */
-#if @HAVE_SYS_TIME_H@
-# @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
#else
-# include <time.h>
-#endif
-#ifndef _GL_SYS_TIME_H
-#define _GL_SYS_TIME_H
+# define _GL_SYS_TIME_H
+
+# if @HAVE_SYS_TIME_H@
+# @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
+# else
+# include <time.h>
+# endif
-#if ! @HAVE_STRUCT_TIMEVAL@
+# if ! @HAVE_STRUCT_TIMEVAL@
struct timeval
{
time_t tv_sec;
long int tv_usec;
};
-#endif
+# endif
-#if @REPLACE_GETTIMEOFDAY@
-# undef gettimeofday
-# define gettimeofday rpl_gettimeofday
+# if @REPLACE_GETTIMEOFDAY@
+# undef gettimeofday
+# define gettimeofday rpl_gettimeofday
int gettimeofday (struct timeval *restrict, void *restrict);
-#endif
+# endif
#endif /* _GL_SYS_TIME_H */
-#endif /* _GL_SYS_TIME_H */