| 1 |
# utimens.m4 |
| 2 |
# serial 17 |
| 3 |
dnl Copyright (C) 2003-2024 Free Software Foundation, Inc. |
| 4 |
dnl This file is free software; the Free Software Foundation |
| 5 |
dnl gives unlimited permission to copy and/or distribute it, |
| 6 |
dnl with or without modifications, as long as this notice is preserved. |
| 7 |
dnl This file is offered as-is, without any warranty. |
| 8 |
|
| 9 |
AC_DEFUN([gl_UTIMENS], |
| 10 |
[ |
| 11 |
dnl Prerequisites of lib/utimens.c. |
| 12 |
AC_REQUIRE([gl_FUNC_UTIMES]) |
| 13 |
AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC]) |
| 14 |
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
| 15 |
gl_CHECK_FUNCS_ANDROID([futimes], [[#include <sys/time.h>]]) |
| 16 |
gl_CHECK_FUNCS_ANDROID([futimesat], [[#include <sys/time.h>]]) |
| 17 |
gl_CHECK_FUNCS_ANDROID([lutimes], [[#include <sys/time.h>]]) |
| 18 |
gl_CHECK_FUNCS_ANDROID([futimens], [[#include <sys/stat.h>]]) |
| 19 |
gl_CHECK_FUNCS_ANDROID([utimensat], [[#include <sys/stat.h>]]) |
| 20 |
AC_CHECK_FUNCS_ONCE([utimens lutimens]) |
| 21 |
|
| 22 |
if test $ac_cv_func_futimens = no && test $ac_cv_func_futimesat = yes; then |
| 23 |
dnl FreeBSD 8.0-rc2 mishandles futimesat(fd,NULL,time). It is not |
| 24 |
dnl standardized, but Solaris implemented it first and uses it as |
| 25 |
dnl its only means to set fd time. |
| 26 |
AC_CACHE_CHECK([whether futimesat handles NULL file], |
| 27 |
[gl_cv_func_futimesat_works], |
| 28 |
[touch conftest.file |
| 29 |
AC_RUN_IFELSE([AC_LANG_PROGRAM([[ |
| 30 |
#include <stddef.h> |
| 31 |
#include <sys/times.h> |
| 32 |
#include <fcntl.h> |
| 33 |
]GL_MDA_DEFINES], |
| 34 |
[[int fd = open ("conftest.file", O_RDWR); |
| 35 |
if (fd < 0) return 1; |
| 36 |
if (futimesat (fd, NULL, NULL)) return 2; |
| 37 |
]])], |
| 38 |
[gl_cv_func_futimesat_works=yes], |
| 39 |
[gl_cv_func_futimesat_works=no], |
| 40 |
[case "$host_os" in |
| 41 |
# Guess yes on Linux systems |
| 42 |
# and on systems that emulate the Linux system calls. |
| 43 |
linux* | midipix*) gl_cv_func_futimesat_works="guessing yes" ;; |
| 44 |
# Guess yes on glibc systems. |
| 45 |
*-gnu*) gl_cv_func_futimesat_works="guessing yes" ;; |
| 46 |
# If we don't know, obey --enable-cross-guesses. |
| 47 |
*) gl_cv_func_futimesat_works="$gl_cross_guess_normal" ;; |
| 48 |
esac |
| 49 |
]) |
| 50 |
rm -f conftest.file]) |
| 51 |
case "$gl_cv_func_futimesat_works" in |
| 52 |
*yes) ;; |
| 53 |
*) |
| 54 |
AC_DEFINE([FUTIMESAT_NULL_BUG], [1], |
| 55 |
[Define to 1 if futimesat mishandles a NULL file name.]) |
| 56 |
;; |
| 57 |
esac |
| 58 |
fi |
| 59 |
]) |