# HG changeset patch # User Eric Blake # Date 1266854406 25200 # Node ID 88955fc5764d59a3ba10a49c06aa0e03b5517fca # Parent 1015aee00ece083216e96a707db020bff286aee0 gettimeofday: restore support for platforms that lack function Fixes a regression from 2010-02-04, commit de4d0a3. * m4/gettimeofday.m4 (gl_FUNC_GETTIMEOFDAY): Also compile replacement if function is missing. * m4/sys_time_h.m4 (gl_HEADER_SYS_TIME_H_DEFAULTS): New witness. * modules/sys_time (Makefile.am): Substitute it. * lib/sys_time.in.h (gettimeofday): Check it. Reported by Michael Goffioul. Signed-off-by: Eric Blake diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2010-02-22 Eric Blake + + gettimeofday: restore support for platforms that lack function + * m4/gettimeofday.m4 (gl_FUNC_GETTIMEOFDAY): Also compile + replacement if function is missing. + * m4/sys_time_h.m4 (gl_HEADER_SYS_TIME_H_DEFAULTS): New witness. + * modules/sys_time (Makefile.am): Substitute it. + * lib/sys_time.in.h (gettimeofday): Check it. + Reported by Michael Goffioul. + 2010-02-21 Bruno Haible * lib/stdio.in.h (obstack_printf): Fix typo. diff --git a/lib/sys_time.in.h b/lib/sys_time.in.h --- a/lib/sys_time.in.h +++ b/lib/sys_time.in.h @@ -59,6 +59,8 @@ # if @REPLACE_GETTIMEOFDAY@ # undef gettimeofday # define gettimeofday rpl_gettimeofday +# endif +# if @REPLACE_GETTIMEOFDAY@ || !@HAVE_GETTIMEOFDAY@ extern int gettimeofday (struct timeval *restrict, void *restrict) _GL_ARG_NONNULL ((1)); # endif diff --git a/m4/gettimeofday.m4 b/m4/gettimeofday.m4 --- a/m4/gettimeofday.m4 +++ b/m4/gettimeofday.m4 @@ -1,4 +1,4 @@ -# serial 14 +# serial 15 # Copyright (C) 2001-2003, 2005, 2007, 2009-2010 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation @@ -15,7 +15,11 @@ AC_CHECK_FUNCS_ONCE([gettimeofday]) gl_gettimeofday_timezone=void - if test $ac_cv_func_gettimeofday = yes; then + if test $ac_cv_func_gettimeofday != yes; then + HAVE_GETTIMEOFDAY=0 + AC_LIBOBJ([gettimeofday]) + gl_PREREQ_GETTIMEOFDAY + else gl_FUNC_GETTIMEOFDAY_CLOBBER AC_CACHE_CHECK([for gettimeofday with POSIX signature], [gl_cv_func_gettimeofday_posix_signature], diff --git a/m4/sys_time_h.m4 b/m4/sys_time_h.m4 --- a/m4/sys_time_h.m4 +++ b/m4/sys_time_h.m4 @@ -1,5 +1,5 @@ # Configure a replacement for . -# serial 3 +# serial 4 # Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation @@ -63,6 +63,7 @@ [ GNULIB_GETTIMEOFDAY=0; AC_SUBST([GNULIB_GETTIMEOFDAY]) dnl Assume POSIX behavior unless another module says otherwise. + HAVE_GETTIMEOFDAY=1; AC_SUBST([HAVE_GETTIMEOFDAY]) HAVE_STRUCT_TIMEVAL=1; AC_SUBST([HAVE_STRUCT_TIMEVAL]) HAVE_SYS_TIME_H=1; AC_SUBST([HAVE_SYS_TIME_H]) REPLACE_GETTIMEOFDAY=0; AC_SUBST([REPLACE_GETTIMEOFDAY]) diff --git a/modules/sys_time b/modules/sys_time --- a/modules/sys_time +++ b/modules/sys_time @@ -28,6 +28,7 @@ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''NEXT_SYS_TIME_H''@|$(NEXT_SYS_TIME_H)|g' \ -e 's/@''GNULIB_GETTIMEOFDAY''@/$(GNULIB_GETTIMEOFDAY)/g' \ + -e 's/@''HAVE_GETTIMEOFDAY''@/$(HAVE_GETTIMEOFDAY)/g' \ -e 's/@''HAVE_STRUCT_TIMEVAL''@/$(HAVE_STRUCT_TIMEVAL)/g' \ -e 's/@''REPLACE_GETTIMEOFDAY''@/$(REPLACE_GETTIMEOFDAY)/g' \ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \