3 dnl Copyright (C) 2006, 2007, 2009 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.
8 dnl Written by Paul Eggert.
10 AC_DEFUN([gl_FCNTL_H],
12 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
13 AC_REQUIRE([gl_FCNTL_O_FLAGS])
14 gl_CHECK_NEXT_HEADERS([fcntl.h])
17 # Test whether the flags O_NOATIME and O_NOFOLLOW actually work.
18 # Define HAVE_WORKING_O_NOATIME to 1 if O_NOATIME works, or to 0 otherwise.
19 # Define HAVE_WORKING_O_NOFOLLOW to 1 if O_NOFOLLOW works, or to 0 otherwise.
20 AC_DEFUN([gl_FCNTL_O_FLAGS],
22 dnl Persuade glibc <fcntl.h> to define O_NOATIME and O_NOFOLLOW.
23 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
24 AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h],
27 [[#include <sys/types.h>
37 static int const constants[] =
39 O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND,
40 O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY
44 int status = !constants;
46 static char const sym[] = "conftest.sym";
47 if (symlink (".", sym) != 0
48 || close (open (sym, O_RDONLY | O_NOFOLLOW)) == 0)
53 static char const file[] = "confdefs.h";
54 int fd = open (file, O_RDONLY | O_NOATIME);
58 || fstat (fd, &st0) != 0
60 || read (fd, &c, 1) != 1
62 || stat (file, &st1) != 0
63 || st0.st_atime != st1.st_atime)
67 [gl_cv_header_working_fcntl_h=yes],
69 32) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #(
70 64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #(
71 96) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #(
72 *) gl_cv_header_working_fcntl_h='no';;
74 [gl_cv_header_working_fcntl_h=cross-compiling])])
76 case $gl_cv_header_working_fcntl_h in #(
77 *O_NOATIME* | no | cross-compiling) ac_val=0;; #(
80 AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOATIME], [$ac_val],
81 [Define to 1 if O_NOATIME works.])
83 case $gl_cv_header_working_fcntl_h in #(
84 *O_NOFOLLOW* | no | cross-compiling) ac_val=0;; #(
87 AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOFOLLOW], [$ac_val],
88 [Define to 1 if O_NOFOLLOW works.])
91 AC_DEFUN([gl_FCNTL_MODULE_INDICATOR],
93 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
94 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
95 GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
98 AC_DEFUN([gl_FCNTL_H_DEFAULTS],
100 GNULIB_FCNTL=0; AC_SUBST([GNULIB_FCNTL])
101 GNULIB_OPEN=0; AC_SUBST([GNULIB_OPEN])
102 GNULIB_OPENAT=0; AC_SUBST([GNULIB_OPENAT])
103 dnl Assume proper GNU behavior unless another module says otherwise.
104 HAVE_OPENAT=1; AC_SUBST([HAVE_OPENAT])
105 REPLACE_FCNTL=0; AC_SUBST([REPLACE_FCNTL])
106 REPLACE_OPEN=0; AC_SUBST([REPLACE_OPEN])
107 REPLACE_OPENAT=0; AC_SUBST([REPLACE_OPENAT])