[PATCH] xfstests: add test for ctimes updates in futimens

Eric Blake ebb9 at byu.net
Tue Feb 2 08:02:42 CST 2010


According to Eric Sandeen on 1/28/2010 1:59 PM:
> Late on review, but this won't build on older glibc's  :(
> 
> need some auto-fu somewhere? was going to put:
> 
> +# 
> +# Check if we have a working futimens libc call
> +# 
> +AC_DEFUN([AC_HAVE_FUTIMENS],
> +  [ AC_MSG_CHECKING([for futimens ])
> +    AC_TRY_COMPILE([
> +#define _GNU_SOURCE
> +#include <sys/stat.h>
> +    ], [
> +       struct timespec t[2] = { { 1000000000, 0 }, { 0, UTIME_OMIT } };
> +       futimens(0, t);
> +    ], have_futimens=yes
> +       AC_MSG_RESULT(yes),
> +       AC_MSG_RESULT(no))
> +    AC_SUBST(have_futimens)
> +  ])

You are missing some m4 quoting, and are using deprecated macros; also,
caching the value speeds up subsequent configure runs.  Furthermore, you
are impinging on the autoconf macro namespace, which is discouraged (what
if autoconf later introduces AC_HAVE_FUTIMENS with different semantics
than your macro?).  Then, since you are only checking for compilation, you
can avoid messing with struct timespec.  AC_SUBST is useful for makefiles,
but AC_DEFINE is useful for preprocessor macros; I'm assuming you wanted
the latter?

So, assuming that you are using xfs_ as your package-specific namespace, I
would write this as:

AC_DEFUN([XFS_HAVE_FUTIMENS], [
  AC_CACHE_CHECK([for futimens], [xfs_cv_have_futimens], [
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#define _GNU_SOURCE
#include <sys/stat.h>
      ]], [[futimens (0, 0);
      ]])], [xfs_cv_have_futimens=yes], [xfs_cv_have_futimens=no])
    ])
  if test "x$xfs_cv_have_futimens" = xyes; then
    AC_DEFINE([HAVE_FUTIMENS], [1], [Define to 1 if futimens compiles])
  fi
])

-- 
Don't work too hard, make some time for fun as well!

Eric Blake             ebb9 at byu.net




More information about the xfs mailing list