annotate m4/fcntl_h.m4 @ 11482:5ff04014c57f

Tweak last commit.
author Bruno Haible <bruno@clisp.org>
date Tue, 14 Apr 2009 21:31:30 +0200
parents 2e168b9fc9aa
children d1047ae4b8d5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7225
3307ae6ea2e5 * lib/fcntl_.h: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
1 # Configure fcntl.h.
11007
f6cba5a556ce many *.m4 files: improve m4 quoting
Jim Meyering <meyering@redhat.com>
parents: 9299
diff changeset
2 dnl Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc.
7225
3307ae6ea2e5 * lib/fcntl_.h: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
3 dnl This file is free software; the Free Software Foundation
3307ae6ea2e5 * lib/fcntl_.h: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
4 dnl gives unlimited permission to copy and/or distribute it,
3307ae6ea2e5 * lib/fcntl_.h: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
5 dnl with or without modifications, as long as this notice is preserved.
3307ae6ea2e5 * lib/fcntl_.h: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
6
3307ae6ea2e5 * lib/fcntl_.h: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
7 dnl Written by Paul Eggert.
3307ae6ea2e5 * lib/fcntl_.h: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
8
3307ae6ea2e5 * lib/fcntl_.h: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
9 AC_DEFUN([gl_FCNTL_H],
3307ae6ea2e5 * lib/fcntl_.h: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
10 [
11482
5ff04014c57f Tweak last commit.
Bruno Haible <bruno@clisp.org>
parents: 11479
diff changeset
11 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
5ff04014c57f Tweak last commit.
Bruno Haible <bruno@clisp.org>
parents: 11479
diff changeset
12 dnl Persuade glibc <fcntl.h> to define O_NOATIME and O_NOFOLLOW.
11479
2e168b9fc9aa Make fcntl module detect O_NOATIME, O_NOFOLLOW on GNU/Linux.
Ben Pfaff <blp@cs.stanford.edu>
parents: 11007
diff changeset
13 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
11007
f6cba5a556ce many *.m4 files: improve m4 quoting
Jim Meyering <meyering@redhat.com>
parents: 9299
diff changeset
14 AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h],
7225
3307ae6ea2e5 * lib/fcntl_.h: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
15 [AC_RUN_IFELSE(
3307ae6ea2e5 * lib/fcntl_.h: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
16 [AC_LANG_PROGRAM(
3307ae6ea2e5 * lib/fcntl_.h: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
17 [[#include <sys/types.h>
3307ae6ea2e5 * lib/fcntl_.h: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
18 #include <sys/stat.h>
3307ae6ea2e5 * lib/fcntl_.h: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
19 #include <unistd.h>
3307ae6ea2e5 * lib/fcntl_.h: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
20 #include <fcntl.h>
7408
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
21 #ifndef O_NOATIME
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
22 #define O_NOATIME 0
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
23 #endif
7225
3307ae6ea2e5 * lib/fcntl_.h: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
24 #ifndef O_NOFOLLOW
3307ae6ea2e5 * lib/fcntl_.h: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
25 #define O_NOFOLLOW 0
3307ae6ea2e5 * lib/fcntl_.h: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
26 #endif
3307ae6ea2e5 * lib/fcntl_.h: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
27 static int const constants[] =
3307ae6ea2e5 * lib/fcntl_.h: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
28 {
3307ae6ea2e5 * lib/fcntl_.h: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
29 O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND,
3307ae6ea2e5 * lib/fcntl_.h: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
30 O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY
3307ae6ea2e5 * lib/fcntl_.h: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
31 };
3307ae6ea2e5 * lib/fcntl_.h: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
32 ]],
7408
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
33 [[
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
34 int status = !constants;
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
35 {
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
36 static char const sym[] = "conftest.sym";
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
37 if (symlink (".", sym) != 0
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
38 || close (open (sym, O_RDONLY | O_NOFOLLOW)) == 0)
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
39 status |= 32;
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
40 }
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
41 {
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
42 static char const file[] = "confdefs.h";
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
43 int fd = open (file, O_RDONLY | O_NOATIME);
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
44 char c;
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
45 struct stat st0, st1;
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
46 if (fd < 0
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
47 || fstat (fd, &st0) != 0
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
48 || sleep (1) != 0
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
49 || read (fd, &c, 1) != 1
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
50 || close (fd) != 0
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
51 || stat (file, &st1) != 0
7687
7fcc949f763a * m4/fcntl_h.m4 (gl_FCNTL_H): Test the atime, not the mtime.
Paul Eggert <eggert@cs.ucla.edu>
parents: 7408
diff changeset
52 || st0.st_atime != st1.st_atime)
7408
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
53 status |= 64;
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
54 }
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
55 return status;]])],
7225
3307ae6ea2e5 * lib/fcntl_.h: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
56 [gl_cv_header_working_fcntl_h=yes],
7408
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
57 [case $? in #(
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
58 32) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #(
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
59 64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #(
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
60 96) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #(
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
61 *) gl_cv_header_working_fcntl_h='no';;
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
62 esac],
7225
3307ae6ea2e5 * lib/fcntl_.h: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
63 [gl_cv_header_working_fcntl_h=cross-compiling])])
3307ae6ea2e5 * lib/fcntl_.h: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
64
7408
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
65 case $gl_cv_header_working_fcntl_h in #(
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
66 *O_NOATIME* | no | cross-compiling) ac_val=0;; #(
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
67 *) ac_val=1;;
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
68 esac
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
69 AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOATIME], [$ac_val],
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
70 [Define to 1 if O_NOATIME works.])
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
71
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
72 case $gl_cv_header_working_fcntl_h in #(
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
73 *O_NOFOLLOW* | no | cross-compiling) ac_val=0;; #(
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
74 *) ac_val=1;;
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
75 esac
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
76 AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOFOLLOW], [$ac_val],
e23b1333a117 [lib/ChangeLog]
Paul Eggert <eggert@cs.ucla.edu>
parents: 7362
diff changeset
77 [Define to 1 if O_NOFOLLOW works.])
7225
3307ae6ea2e5 * lib/fcntl_.h: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
78
8995
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 7687
diff changeset
79 gl_CHECK_NEXT_HEADERS([fcntl.h])
7225
3307ae6ea2e5 * lib/fcntl_.h: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
80 FCNTL_H='fcntl.h'
3307ae6ea2e5 * lib/fcntl_.h: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
81 AC_SUBST([FCNTL_H])
3307ae6ea2e5 * lib/fcntl_.h: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
82 ])
9299
ada4d73c37a6 New module 'open'.
Bruno Haible <bruno@clisp.org>
parents: 8995
diff changeset
83
ada4d73c37a6 New module 'open'.
Bruno Haible <bruno@clisp.org>
parents: 8995
diff changeset
84 AC_DEFUN([gl_FCNTL_MODULE_INDICATOR],
ada4d73c37a6 New module 'open'.
Bruno Haible <bruno@clisp.org>
parents: 8995
diff changeset
85 [
ada4d73c37a6 New module 'open'.
Bruno Haible <bruno@clisp.org>
parents: 8995
diff changeset
86 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
ada4d73c37a6 New module 'open'.
Bruno Haible <bruno@clisp.org>
parents: 8995
diff changeset
87 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
ada4d73c37a6 New module 'open'.
Bruno Haible <bruno@clisp.org>
parents: 8995
diff changeset
88 GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
ada4d73c37a6 New module 'open'.
Bruno Haible <bruno@clisp.org>
parents: 8995
diff changeset
89 ])
ada4d73c37a6 New module 'open'.
Bruno Haible <bruno@clisp.org>
parents: 8995
diff changeset
90
ada4d73c37a6 New module 'open'.
Bruno Haible <bruno@clisp.org>
parents: 8995
diff changeset
91 AC_DEFUN([gl_FCNTL_H_DEFAULTS],
ada4d73c37a6 New module 'open'.
Bruno Haible <bruno@clisp.org>
parents: 8995
diff changeset
92 [
ada4d73c37a6 New module 'open'.
Bruno Haible <bruno@clisp.org>
parents: 8995
diff changeset
93 GNULIB_OPEN=0; AC_SUBST([GNULIB_OPEN])
ada4d73c37a6 New module 'open'.
Bruno Haible <bruno@clisp.org>
parents: 8995
diff changeset
94 dnl Assume proper GNU behavior unless another module says otherwise.
ada4d73c37a6 New module 'open'.
Bruno Haible <bruno@clisp.org>
parents: 8995
diff changeset
95 REPLACE_OPEN=0; AC_SUBST([REPLACE_OPEN])
ada4d73c37a6 New module 'open'.
Bruno Haible <bruno@clisp.org>
parents: 8995
diff changeset
96 ])