summaryrefslogtreecommitdiffstats
path: root/gl/m4/fcntl_h.m4
diff options
context:
space:
mode:
authorThomas Guyot-Sionnest <dermoth@aei.ca>2009-01-15 04:22:57 -0500
committerThomas Guyot-Sionnest <dermoth@aei.ca>2009-01-15 05:19:08 -0500
commit71cdb52799220f8d9052643baf1d3e9836a9c755 (patch)
tree27aee97a35d9ab51f0d8f64a46690bd41a5f8c1b /gl/m4/fcntl_h.m4
parentf7afa46586645e50498d8b2d0c67884f014dc3a4 (diff)
downloadmonitoring-plugins-71cdb52799220f8d9052643baf1d3e9836a9c755.tar.gz
Sync with gnulib
Diffstat (limited to 'gl/m4/fcntl_h.m4')
-rw-r--r--gl/m4/fcntl_h.m494
1 files changed, 94 insertions, 0 deletions
diff --git a/gl/m4/fcntl_h.m4 b/gl/m4/fcntl_h.m4
new file mode 100644
index 00000000..4a7fc42b
--- /dev/null
+++ b/gl/m4/fcntl_h.m4
@@ -0,0 +1,94 @@
1# Configure fcntl.h.
2dnl Copyright (C) 2006, 2007, 2009 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
9AC_DEFUN([gl_FCNTL_H],
10[
11 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
12 AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h],
13 [AC_RUN_IFELSE(
14 [AC_LANG_PROGRAM(
15 [[#include <sys/types.h>
16 #include <sys/stat.h>
17 #include <unistd.h>
18 #include <fcntl.h>
19 #ifndef O_NOATIME
20 #define O_NOATIME 0
21 #endif
22 #ifndef O_NOFOLLOW
23 #define O_NOFOLLOW 0
24 #endif
25 static int const constants[] =
26 {
27 O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND,
28 O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY
29 };
30 ]],
31 [[
32 int status = !constants;
33 {
34 static char const sym[] = "conftest.sym";
35 if (symlink (".", sym) != 0
36 || close (open (sym, O_RDONLY | O_NOFOLLOW)) == 0)
37 status |= 32;
38 }
39 {
40 static char const file[] = "confdefs.h";
41 int fd = open (file, O_RDONLY | O_NOATIME);
42 char c;
43 struct stat st0, st1;
44 if (fd < 0
45 || fstat (fd, &st0) != 0
46 || sleep (1) != 0
47 || read (fd, &c, 1) != 1
48 || close (fd) != 0
49 || stat (file, &st1) != 0
50 || st0.st_atime != st1.st_atime)
51 status |= 64;
52 }
53 return status;]])],
54 [gl_cv_header_working_fcntl_h=yes],
55 [case $? in #(
56 32) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #(
57 64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #(
58 96) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #(
59 *) gl_cv_header_working_fcntl_h='no';;
60 esac],
61 [gl_cv_header_working_fcntl_h=cross-compiling])])
62
63 case $gl_cv_header_working_fcntl_h in #(
64 *O_NOATIME* | no | cross-compiling) ac_val=0;; #(
65 *) ac_val=1;;
66 esac
67 AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOATIME], [$ac_val],
68 [Define to 1 if O_NOATIME works.])
69
70 case $gl_cv_header_working_fcntl_h in #(
71 *O_NOFOLLOW* | no | cross-compiling) ac_val=0;; #(
72 *) ac_val=1;;
73 esac
74 AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOFOLLOW], [$ac_val],
75 [Define to 1 if O_NOFOLLOW works.])
76
77 gl_CHECK_NEXT_HEADERS([fcntl.h])
78 FCNTL_H='fcntl.h'
79 AC_SUBST([FCNTL_H])
80])
81
82AC_DEFUN([gl_FCNTL_MODULE_INDICATOR],
83[
84 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
85 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
86 GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
87])
88
89AC_DEFUN([gl_FCNTL_H_DEFAULTS],
90[
91 GNULIB_OPEN=0; AC_SUBST([GNULIB_OPEN])
92 dnl Assume proper GNU behavior unless another module says otherwise.
93 REPLACE_OPEN=0; AC_SUBST([REPLACE_OPEN])
94])