aboutsummaryrefslogtreecommitdiff
path: root/m4/fcntl-o.m4
diff options
context:
space:
mode:
Diffstat (limited to 'm4/fcntl-o.m4')
-rw-r--r--m4/fcntl-o.m481
1 files changed, 81 insertions, 0 deletions
diff --git a/m4/fcntl-o.m4 b/m4/fcntl-o.m4
new file mode 100644
index 00000000..d416a61c
--- /dev/null
+++ b/m4/fcntl-o.m4
@@ -0,0 +1,81 @@
1# fcntl-o.m4 serial 1
2dnl Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl Written by Paul Eggert.
8
9# Test whether the flags O_NOATIME and O_NOFOLLOW actually work.
10# Define HAVE_WORKING_O_NOATIME to 1 if O_NOATIME works, or to 0 otherwise.
11# Define HAVE_WORKING_O_NOFOLLOW to 1 if O_NOFOLLOW works, or to 0 otherwise.
12AC_DEFUN([gl_FCNTL_O_FLAGS],
13[
14 dnl Persuade glibc <fcntl.h> to define O_NOATIME and O_NOFOLLOW.
15 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
16 AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h],
17 [AC_RUN_IFELSE(
18 [AC_LANG_PROGRAM(
19 [[#include <sys/types.h>
20 #include <sys/stat.h>
21 #include <unistd.h>
22 #include <fcntl.h>
23 #ifndef O_NOATIME
24 #define O_NOATIME 0
25 #endif
26 #ifndef O_NOFOLLOW
27 #define O_NOFOLLOW 0
28 #endif
29 static int const constants[] =
30 {
31 O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND,
32 O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY
33 };
34 ]],
35 [[
36 int status = !constants;
37 {
38 static char const sym[] = "conftest.sym";
39 if (symlink (".", sym) != 0
40 || close (open (sym, O_RDONLY | O_NOFOLLOW)) == 0)
41 status |= 32;
42 unlink (sym);
43 }
44 {
45 static char const file[] = "confdefs.h";
46 int fd = open (file, O_RDONLY | O_NOATIME);
47 char c;
48 struct stat st0, st1;
49 if (fd < 0
50 || fstat (fd, &st0) != 0
51 || sleep (1) != 0
52 || read (fd, &c, 1) != 1
53 || close (fd) != 0
54 || stat (file, &st1) != 0
55 || st0.st_atime != st1.st_atime)
56 status |= 64;
57 }
58 return status;]])],
59 [gl_cv_header_working_fcntl_h=yes],
60 [case $? in #(
61 32) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #(
62 64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #(
63 96) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #(
64 *) gl_cv_header_working_fcntl_h='no';;
65 esac],
66 [gl_cv_header_working_fcntl_h=cross-compiling])])
67
68 case $gl_cv_header_working_fcntl_h in #(
69 *O_NOATIME* | no | cross-compiling) ac_val=0;; #(
70 *) ac_val=1;;
71 esac
72 AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOATIME], [$ac_val],
73 [Define to 1 if O_NOATIME works.])
74
75 case $gl_cv_header_working_fcntl_h in #(
76 *O_NOFOLLOW* | no | cross-compiling) ac_val=0;; #(
77 *) ac_val=1;;
78 esac
79 AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOFOLLOW], [$ac_val],
80 [Define to 1 if O_NOFOLLOW works.])
81])