]> git.cworth.org Git - tar/blob - m4/utimens.m4
upstream: Fix extraction of device nodes.
[tar] / m4 / utimens.m4
1 dnl Copyright (C) 2003-2010 Free Software Foundation, Inc.
2 dnl This file is free software; the Free Software Foundation
3 dnl gives unlimited permission to copy and/or distribute it,
4 dnl with or without modifications, as long as this notice is preserved.
5
6 dnl serial 4
7
8 AC_DEFUN([gl_UTIMENS],
9 [
10   AC_LIBOBJ([utimens])
11
12   dnl Prerequisites of lib/utimens.c.
13   AC_REQUIRE([gl_FUNC_UTIMES])
14   AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC])
15   AC_REQUIRE([gl_CHECK_TYPE_STRUCT_UTIMBUF])
16   AC_CHECK_FUNCS_ONCE([futimes futimesat futimens utimensat lutimes])
17
18   if test $ac_cv_func_futimens = no && test $ac_cv_func_futimesat = yes; then
19     dnl FreeBSD 8.0-rc2 mishandles futimesat(fd,NULL,time).  It is not
20     dnl standardized, but Solaris implemented it first and uses it as
21     dnl its only means to set fd time.
22     AC_CACHE_CHECK([whether futimesat handles NULL file],
23       [gl_cv_func_futimesat_works],
24       [touch conftest.file
25        AC_RUN_IFELSE([AC_LANG_PROGRAM([[
26 #include <stddef.h>
27 #include <sys/times.h>
28 ]], [[    int fd = open ("conftest.file", O_RDWR);
29           if (fd < 0) return 1;
30           if (futimesat (fd, NULL, NULL)) return 2;
31         ]])],
32         [gl_cv_func_futimesat_works=yes],
33         [gl_cv_func_futimesat_works=no],
34         [gl_cv_func_futimesat_works="guessing no"])
35       rm -f conftest.file])
36     if test "$gl_cv_func_futimesat_works" != yes; then
37       AC_DEFINE([FUTIMESAT_NULL_BUG], [1],
38         [Define to 1 if futimesat mishandles a NULL file name.])
39     fi
40   fi
41 ])