re-mark 1.29b-2 as not yet uploaded (merge madness!)
[debian/tar] / m4 / utimensat.m4
index 1110e07c63fcb5bd46b59a9cc1a2991755ffbac3..9a80fa06bd4356832b09cf0d8428714cc875748c 100644 (file)
@@ -1,7 +1,7 @@
-# serial 3
+# serial 5
 # See if we need to provide utimensat replacement.
 
-dnl Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+dnl Copyright (C) 2009-2015 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -15,26 +15,42 @@ AC_DEFUN([gl_FUNC_UTIMENSAT],
   AC_CHECK_FUNCS_ONCE([utimensat])
   if test $ac_cv_func_utimensat = no; then
     HAVE_UTIMENSAT=0
-    AC_LIBOBJ([utimensat])
   else
     AC_CACHE_CHECK([whether utimensat works],
       [gl_cv_func_utimensat_works],
-      [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+      [AC_RUN_IFELSE(
+         [AC_LANG_PROGRAM([[
 #include <fcntl.h>
 #include <sys/stat.h>
 #include <unistd.h>
-]], [[struct timespec ts[2] = { { 1, UTIME_OMIT }, { 1, UTIME_NOW } };
-      struct stat st;
-      const char *f = "conftest.file";
-      if (close (creat (f, 0600))) return 1;
-      if (utimensat (AT_FDCWD, f, NULL, AT_SYMLINK_NOFOLLOW)) return 2;
-      if (utimensat (AT_FDCWD, f, ts, 0)) return 3;
-      sleep (1);
-      ts[0].tv_nsec = UTIME_NOW;
-      ts[1].tv_nsec = UTIME_OMIT;
-      if (utimensat (AT_FDCWD, f, ts, 0)) return 4;
-      if (stat (f, &st)) return 5;
-      if (st.st_ctime < st.st_atime) return 6;]])],
+]],         [[int result = 0;
+              const char *f = "conftest.file";
+              if (close (creat (f, 0600)))
+                return 1;
+              /* Test whether the AT_SYMLINK_NOFOLLOW flag is supported.  */
+              {
+                if (utimensat (AT_FDCWD, f, NULL, AT_SYMLINK_NOFOLLOW))
+                  result |= 2;
+              }
+              /* Test whether UTIME_NOW and UTIME_OMIT work.  */
+              {
+                struct timespec ts[2] = { { 1, UTIME_OMIT }, { 1, UTIME_NOW } };
+                if (utimensat (AT_FDCWD, f, ts, 0))
+                  result |= 4;
+              }
+              sleep (1);
+              {
+                struct timespec ts[2] = { { 1, UTIME_NOW }, { 1, UTIME_OMIT } };
+                struct stat st;
+                if (utimensat (AT_FDCWD, f, ts, 0))
+                  result |= 8;
+                if (stat (f, &st))
+                  result |= 16;
+                else if (st.st_ctime < st.st_atime)
+                  result |= 32;
+              }
+              return result;
+            ]])],
 dnl FIXME: simplify this in 2012, when file system bugs are no longer common
          [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 #ifdef __linux__
@@ -50,7 +66,6 @@ choke me
          [gl_cv_func_utimensat_works="guessing no"])])
     if test "$gl_cv_func_utimensat_works" != yes; then
       REPLACE_UTIMENSAT=1
-      AC_LIBOBJ([utimensat])
     fi
   fi
 ])