Prefer it to futimes since it doesn't have the futimes bug.
* m4/utimens.m4 (gl_UTIMENS): Check for futimesat.
#include "utimens.h"
#include <errno.h>
#include "utimens.h"
#include <errno.h>
#if HAVE_UTIME_H
# include <utime.h>
#if HAVE_UTIME_H
# include <utime.h>
/* There's currently no interface to set file timestamps with
nanosecond resolution, so do the best we can, discarding any
fractional part of the timestamp. */
/* There's currently no interface to set file timestamps with
nanosecond resolution, so do the best we can, discarding any
fractional part of the timestamp. */
+#if HAVE_FUTIMESAT || HAVE_WORKING_UTIMES
struct timeval timeval[2];
struct timeval const *t;
if (timespec)
struct timeval timeval[2];
struct timeval const *t;
if (timespec)
+
+# if HAVE_FUTIMESAT
+ return fd < 0 ? futimesat (AT_FDCWD, file, t) : futimesat (fd, NULL, t);
+# else
+# if HAVE_FUTIMES
if (0 <= fd)
{
if (futimes (fd, t) == 0)
if (0 <= fd)
{
if (futimes (fd, t) == 0)
AC_REQUIRE([gl_FUNC_UTIMES])
AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC])
AC_REQUIRE([gl_CHECK_TYPE_STRUCT_UTIMBUF])
AC_REQUIRE([gl_FUNC_UTIMES])
AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC])
AC_REQUIRE([gl_CHECK_TYPE_STRUCT_UTIMBUF])
- AC_CHECK_FUNCS_ONCE(futimes)
+ AC_CHECK_FUNCS_ONCE([futimes futimesat])