X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=m4%2Futimes.m4;h=dae46f00eb5c072de2cfa151ee2a7dd693267d8c;hb=be1c8adeedf52b5ceee7091a43c1937ea2caaa7d;hp=ce9f86bf7bf13932c8e6a5f08e0eeb87e21443ac;hpb=d945878e2567f96a561d3f2d569749fc0b413a1c;p=gnulib.git diff --git a/m4/utimes.m4 b/m4/utimes.m4 index ce9f86bf7..dae46f00e 100644 --- a/m4/utimes.m4 +++ b/m4/utimes.m4 @@ -1,39 +1,46 @@ -#serial 2 +# See if we need to work around bugs in glibc's implementation of +# utimes from 2003-07-12 to 2003-09-17. +# First, there was a bug that would make utimes set mtime +# and atime to zero (1970-01-01) unconditionally. +# Then, there was code to round rather than truncate. +# +# From Jim Meyering, with suggestions from Paul Eggert. -dnl Shamelessly cloned from acspecific.m4's AC_FUNC_UTIME_NULL. - -AC_DEFUN(jm_FUNC_UTIMES_NULL, -[AC_CACHE_CHECK(whether utimes accepts a null argument, ac_cv_func_utimes_null, -[rm -f conftestdata; > conftestdata -AC_TRY_RUN([ -/* In case stat has been defined to rpl_stat, undef it here. */ -#undef stat +AC_DEFUN([gl_FUNC_UTIMES], +[ + AC_CACHE_CHECK([determine whether the utimes function works], + gl_cv_func_working_utimes, + [ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include -main() { -struct stat s, t; -exit(!(stat ("conftestdata", &s) == 0 && utimes("conftestdata", (long *)0) == 0 -&& stat("conftestdata", &t) == 0 && t.st_mtime >= s.st_mtime -&& t.st_mtime - s.st_mtime < 120)); -}], - ac_cv_func_utimes_null=yes, - ac_cv_func_utimes_null=no, - ac_cv_func_utimes_null=no) -rm -f core core.* *.core]) +#include +#include +#include +#include +#include + +int +main () +{ + static struct timeval timeval[2] = {{9, 10}, {999999, 999999}}; + struct stat sbuf; + char const *file = "conftest.utimes"; + FILE *f; + + exit ( ! ((f = fopen (file, "w")) + && fclose (f) == 0 + && utimes (file, timeval) == 0 + && lstat (file, &sbuf) == 0 + && sbuf.st_atime == timeval[0].tv_sec + && sbuf.st_mtime == timeval[1].tv_sec) ); +} + ]])], + [gl_cv_func_working_utimes=yes], + [gl_cv_func_working_utimes=no], + [gl_cv_func_working_utimes=no])]) - if test $ac_cv_func_utimes_null = yes; then - if test x = y; then - # This code is deliberately never run via ./configure. - # FIXME: this is a hack to make autoheader put the corresponding - # HAVE_* undef for this symbol in config.h.in. This saves me the - # trouble of having to maintain the #undef in acconfig.h manually. - AC_CHECK_FUNCS(UTIMES_NULL) - fi - # Defining it this way (rather than via AC_DEFINE) short-circuits the - # autoheader check -- autoheader doesn't know it's already been taken - # care of by the hack above. - ac_kludge=HAVE_UTIMES_NULL - AC_DEFINE_UNQUOTED($ac_kludge) - fi - ] -) + if test $gl_cv_func_working_utimes = yes; then + AC_DEFINE([HAVE_WORKING_UTIMES], 1, [Define if utimes works properly. ]) + fi +])