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 dnl Persuade glibc <fcntl.h> to define O_NOATIME and O_NOFOLLOW.
14 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
15 AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h],
18 [[#include <sys/types.h>
28 static int const constants[] =
30 O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND,
31 O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY
35 int status = !constants;
37 static char const sym[] = "conftest.sym";
38 if (symlink (".", sym) != 0
39 || close (open (sym, O_RDONLY | O_NOFOLLOW)) == 0)
44 static char const file[] = "confdefs.h";
45 int fd = open (file, O_RDONLY | O_NOATIME);
49 || fstat (fd, &st0) != 0
51 || read (fd, &c, 1) != 1
53 || stat (file, &st1) != 0
54 || st0.st_atime != st1.st_atime)
58 [gl_cv_header_working_fcntl_h=yes],
60 32) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #(
61 64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #(
62 96) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #(
63 *) gl_cv_header_working_fcntl_h='no';;
65 [gl_cv_header_working_fcntl_h=cross-compiling])])
67 case $gl_cv_header_working_fcntl_h in #(
68 *O_NOATIME* | no | cross-compiling) ac_val=0;; #(
71 AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOATIME], [$ac_val],
72 [Define to 1 if O_NOATIME works.])
74 case $gl_cv_header_working_fcntl_h in #(
75 *O_NOFOLLOW* | no | cross-compiling) ac_val=0;; #(
78 AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOFOLLOW], [$ac_val],
79 [Define to 1 if O_NOFOLLOW works.])
81 gl_CHECK_NEXT_HEADERS([fcntl.h])
86 AC_DEFUN([gl_FCNTL_MODULE_INDICATOR],
88 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
89 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
90 GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
93 AC_DEFUN([gl_FCNTL_H_DEFAULTS],
95 GNULIB_OPEN=0; AC_SUBST([GNULIB_OPEN])
96 GNULIB_OPENAT=0; AC_SUBST([GNULIB_OPENAT])
97 dnl Assume proper GNU behavior unless another module says otherwise.
98 HAVE_OPENAT=1; AC_SUBST([HAVE_OPENAT])
99 REPLACE_OPEN=0; AC_SUBST([REPLACE_OPEN])
100 REPLACE_OPENAT=0; AC_SUBST([REPLACE_OPENAT])