Paul Eggert <eggert <at> CS.UCLA.EDU> writes: > > The main idea here is that we should try to avoid separate include > files like "gettimeofday.h" for declarations that POSIX says should be > in a standard file like <sys/time.h>. Instead, we should patch > <sys/time.h> by wrapping it; that way the user code can just code to > the POSIX standard.
Right now, this is broken - when cross-compiling to mingw, the following is happening: { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's/@''HAVE_SYS_TIME_H''@/1/g' \ -e 's|@''ABSOLUTE_SYS_TIME_H''@|"///usr/lib/gcc/i686-pc- mingw32/3.4.4/../../../../i686-pc-mingw32/include/sys/time.h"|g' \ -e 's/@''GETTIMEOFDAY_CLOBBERS_LOCALTIME''@/0/g' \ -e 's/@''HAVE_GETTIMEOFDAY_POSIX_SIGNATURE''@/1/g' \ -e 's/@''HAVE_STRUCT_TIMEVAL''@/1/g' \ < ../../lib/sys_time_.h; \ } > sys/time.h-t mv sys/time.h-t sys/time.h With the new headers, we no longer #define gettimeofday rpl_gettimeofday in <sys/time.h>. But in lib/gettimeofday.c, we are declaring gettimeofday, then trying to invoke the system version. As a result, there is infinite recursion, and any use of gettimeofday (including gnulib mkstemp) crash. I'm installing this patch. Index: lib/gettimeofday.c =================================================================== RCS file: /sources/gnulib/gnulib/lib/gettimeofday.c,v retrieving revision 1.12 diff -u -r1.12 gettimeofday.c --- lib/gettimeofday.c 18 Jan 2007 08:33:34 -0000 1.12 +++ lib/gettimeofday.c 18 Jan 2007 16:13:54 -0000 @@ -98,7 +98,7 @@ causes problems. */ int -gettimeofday (struct timeval *restrict tv, void *restrict tz) +rpl_gettimeofday (struct timeval *restrict tv, void *restrict tz) { #undef gettimeofday #if HAVE_GETTIMEOFDAY Index: m4/gettimeofday.m4 =================================================================== RCS file: /sources/gnulib/gnulib/m4/gettimeofday.m4,v retrieving revision 1.13 diff -u -r1.13 gettimeofday.m4 --- m4/gettimeofday.m4 18 Jan 2007 08:33:34 -0000 1.13 +++ m4/gettimeofday.m4 18 Jan 2007 16:13:55 -0000 @@ -90,6 +90,8 @@ [Define to rpl_gmtime if the replacement function should be used.]) AC_DEFINE([localtime], [rpl_localtime], [Define to rpl_localtime if the replacement function should be used.]) + AC_DEFINE([gettimeofday], [rpl_gettimeofday], + [Define to rpl_gettimeofday if the replacement function should be used.]) ]) # Prerequisites of lib/gettimeofday.c.