2 # See if we need to provide utimensat replacement.
4 dnl Copyright (C) 2009-2020 Free Software Foundation, Inc.
5 dnl This file is free software; the Free Software Foundation
6 dnl gives unlimited permission to copy and/or distribute it,
7 dnl with or without modifications, as long as this notice is preserved.
9 # Written by Eric Blake.
11 AC_DEFUN([gl_FUNC_UTIMENSAT],
13 AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
14 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
15 AC_CHECK_FUNCS_ONCE([utimensat])
16 if test $ac_cv_func_utimensat = no; then
19 AC_CACHE_CHECK([whether utimensat works],
20 [gl_cv_func_utimensat_works],
28 const char *f = "conftest.file";
29 if (close (creat (f, 0600)))
31 /* Test whether the AT_SYMLINK_NOFOLLOW flag is supported. */
33 if (utimensat (AT_FDCWD, f, NULL, AT_SYMLINK_NOFOLLOW))
36 /* Test whether UTIME_NOW and UTIME_OMIT work. */
38 struct timespec ts[2];
40 ts[0].tv_nsec = UTIME_OMIT;
42 ts[1].tv_nsec = UTIME_NOW;
43 if (utimensat (AT_FDCWD, f, ts, 0))
49 struct timespec ts[2];
51 ts[0].tv_nsec = UTIME_NOW;
53 ts[1].tv_nsec = UTIME_OMIT;
54 if (utimensat (AT_FDCWD, f, ts, 0))
58 else if (st.st_ctime < st.st_atime)
63 [gl_cv_func_utimensat_works=yes],
64 [gl_cv_func_utimensat_works=no],
65 [gl_cv_func_utimensat_works="guessing yes"])])
66 if test "$gl_cv_func_utimensat_works" = no; then