Mercurial > hg > octave-kai > gnulib-hg
annotate m4/fcntl_h.m4 @ 11966:715fd167345f
Remove dependency from unistd_h.m4, sys_stat_h.m4, fcntl_h.m4 to openat.m4.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Mon, 07 Sep 2009 01:33:12 +0200 |
parents | d1047ae4b8d5 |
children | 21ec8b9a3f27 |
rev | line source |
---|---|
11966
715fd167345f
Remove dependency from unistd_h.m4, sys_stat_h.m4, fcntl_h.m4 to openat.m4.
Bruno Haible <bruno@clisp.org>
parents:
11942
diff
changeset
|
1 # serial 3 |
7225 | 2 # Configure fcntl.h. |
11007
f6cba5a556ce
many *.m4 files: improve m4 quoting
Jim Meyering <meyering@redhat.com>
parents:
9299
diff
changeset
|
3 dnl Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc. |
7225 | 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. | |
7 | |
8 dnl Written by Paul Eggert. | |
9 | |
10 AC_DEFUN([gl_FCNTL_H], | |
11 [ | |
11482 | 12 AC_REQUIRE([gl_FCNTL_H_DEFAULTS]) |
13 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
|
14 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) |
11007
f6cba5a556ce
many *.m4 files: improve m4 quoting
Jim Meyering <meyering@redhat.com>
parents:
9299
diff
changeset
|
15 AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h], |
7225 | 16 [AC_RUN_IFELSE( |
17 [AC_LANG_PROGRAM( | |
18 [[#include <sys/types.h> | |
19 #include <sys/stat.h> | |
20 #include <unistd.h> | |
21 #include <fcntl.h> | |
7408 | 22 #ifndef O_NOATIME |
23 #define O_NOATIME 0 | |
24 #endif | |
7225 | 25 #ifndef O_NOFOLLOW |
26 #define O_NOFOLLOW 0 | |
27 #endif | |
28 static int const constants[] = | |
29 { | |
30 O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND, | |
31 O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY | |
32 }; | |
33 ]], | |
7408 | 34 [[ |
35 int status = !constants; | |
36 { | |
37 static char const sym[] = "conftest.sym"; | |
38 if (symlink (".", sym) != 0 | |
39 || close (open (sym, O_RDONLY | O_NOFOLLOW)) == 0) | |
40 status |= 32; | |
41 } | |
42 { | |
43 static char const file[] = "confdefs.h"; | |
44 int fd = open (file, O_RDONLY | O_NOATIME); | |
45 char c; | |
46 struct stat st0, st1; | |
47 if (fd < 0 | |
48 || fstat (fd, &st0) != 0 | |
49 || sleep (1) != 0 | |
50 || read (fd, &c, 1) != 1 | |
51 || close (fd) != 0 | |
52 || 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
|
53 || st0.st_atime != st1.st_atime) |
7408 | 54 status |= 64; |
55 } | |
56 return status;]])], | |
7225 | 57 [gl_cv_header_working_fcntl_h=yes], |
7408 | 58 [case $? in #( |
59 32) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #( | |
60 64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #( | |
61 96) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #( | |
62 *) gl_cv_header_working_fcntl_h='no';; | |
63 esac], | |
7225 | 64 [gl_cv_header_working_fcntl_h=cross-compiling])]) |
65 | |
7408 | 66 case $gl_cv_header_working_fcntl_h in #( |
67 *O_NOATIME* | no | cross-compiling) ac_val=0;; #( | |
68 *) ac_val=1;; | |
69 esac | |
70 AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOATIME], [$ac_val], | |
71 [Define to 1 if O_NOATIME works.]) | |
72 | |
73 case $gl_cv_header_working_fcntl_h in #( | |
74 *O_NOFOLLOW* | no | cross-compiling) ac_val=0;; #( | |
75 *) ac_val=1;; | |
76 esac | |
77 AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOFOLLOW], [$ac_val], | |
78 [Define to 1 if O_NOFOLLOW works.]) | |
7225 | 79 |
8995
1025663f7658
* m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents:
7687
diff
changeset
|
80 gl_CHECK_NEXT_HEADERS([fcntl.h]) |
7225 | 81 FCNTL_H='fcntl.h' |
82 AC_SUBST([FCNTL_H]) | |
83 ]) | |
9299 | 84 |
85 AC_DEFUN([gl_FCNTL_MODULE_INDICATOR], | |
86 [ | |
87 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. | |
88 AC_REQUIRE([gl_FCNTL_H_DEFAULTS]) | |
89 GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1 | |
90 ]) | |
91 | |
92 AC_DEFUN([gl_FCNTL_H_DEFAULTS], | |
93 [ | |
11966
715fd167345f
Remove dependency from unistd_h.m4, sys_stat_h.m4, fcntl_h.m4 to openat.m4.
Bruno Haible <bruno@clisp.org>
parents:
11942
diff
changeset
|
94 GNULIB_OPEN=0; AC_SUBST([GNULIB_OPEN]) |
715fd167345f
Remove dependency from unistd_h.m4, sys_stat_h.m4, fcntl_h.m4 to openat.m4.
Bruno Haible <bruno@clisp.org>
parents:
11942
diff
changeset
|
95 GNULIB_OPENAT=0; AC_SUBST([GNULIB_OPENAT]) |
9299 | 96 dnl Assume proper GNU behavior unless another module says otherwise. |
11966
715fd167345f
Remove dependency from unistd_h.m4, sys_stat_h.m4, fcntl_h.m4 to openat.m4.
Bruno Haible <bruno@clisp.org>
parents:
11942
diff
changeset
|
97 HAVE_OPENAT=1; AC_SUBST([HAVE_OPENAT]) |
9299 | 98 REPLACE_OPEN=0; AC_SUBST([REPLACE_OPEN]) |
99 ]) |