1 | # Configure fcntl.h.
|
---|
2 | dnl Copyright (C) 2006 Free Software Foundation, Inc.
|
---|
3 | dnl This file is free software; the Free Software Foundation
|
---|
4 | dnl gives unlimited permission to copy and/or distribute it,
|
---|
5 | dnl with or without modifications, as long as this notice is preserved.
|
---|
6 |
|
---|
7 | dnl Written by Paul Eggert.
|
---|
8 |
|
---|
9 | AC_DEFUN([gl_FCNTL_H],
|
---|
10 | [
|
---|
11 | AC_CACHE_CHECK([for working fcntl.h], gl_cv_header_working_fcntl_h,
|
---|
12 | [AC_RUN_IFELSE(
|
---|
13 | [AC_LANG_PROGRAM(
|
---|
14 | [[#include <sys/types.h>
|
---|
15 | #include <sys/stat.h>
|
---|
16 | #include <unistd.h>
|
---|
17 | #include <fcntl.h>
|
---|
18 | #ifndef O_NOATIME
|
---|
19 | #define O_NOATIME 0
|
---|
20 | #endif
|
---|
21 | #ifndef O_NOFOLLOW
|
---|
22 | #define O_NOFOLLOW 0
|
---|
23 | #endif
|
---|
24 | static int const constants[] =
|
---|
25 | {
|
---|
26 | O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND,
|
---|
27 | O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY
|
---|
28 | };
|
---|
29 | ]],
|
---|
30 | [[
|
---|
31 | int status = !constants;
|
---|
32 | {
|
---|
33 | static char const sym[] = "conftest.sym";
|
---|
34 | if (symlink (".", sym) != 0
|
---|
35 | || close (open (sym, O_RDONLY | O_NOFOLLOW)) == 0)
|
---|
36 | status |= 32;
|
---|
37 | }
|
---|
38 | {
|
---|
39 | static char const file[] = "confdefs.h";
|
---|
40 | int fd = open (file, O_RDONLY | O_NOATIME);
|
---|
41 | char c;
|
---|
42 | struct stat st0, st1;
|
---|
43 | if (fd < 0
|
---|
44 | || fstat (fd, &st0) != 0
|
---|
45 | || sleep (1) != 0
|
---|
46 | || read (fd, &c, 1) != 1
|
---|
47 | || close (fd) != 0
|
---|
48 | || stat (file, &st1) != 0
|
---|
49 | || st0.st_atime != st1.st_atime)
|
---|
50 | status |= 64;
|
---|
51 | }
|
---|
52 | return status;]])],
|
---|
53 | [gl_cv_header_working_fcntl_h=yes],
|
---|
54 | [case $? in #(
|
---|
55 | 32) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #(
|
---|
56 | 64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #(
|
---|
57 | 96) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #(
|
---|
58 | *) gl_cv_header_working_fcntl_h='no';;
|
---|
59 | esac],
|
---|
60 | [gl_cv_header_working_fcntl_h=cross-compiling])])
|
---|
61 |
|
---|
62 | case $gl_cv_header_working_fcntl_h in #(
|
---|
63 | *O_NOATIME* | no | cross-compiling) ac_val=0;; #(
|
---|
64 | *) ac_val=1;;
|
---|
65 | esac
|
---|
66 | AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOATIME], [$ac_val],
|
---|
67 | [Define to 1 if O_NOATIME works.])
|
---|
68 |
|
---|
69 | case $gl_cv_header_working_fcntl_h in #(
|
---|
70 | *O_NOFOLLOW* | no | cross-compiling) ac_val=0;; #(
|
---|
71 | *) ac_val=1;;
|
---|
72 | esac
|
---|
73 | AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOFOLLOW], [$ac_val],
|
---|
74 | [Define to 1 if O_NOFOLLOW works.])
|
---|
75 |
|
---|
76 | gl_ABSOLUTE_HEADER([fcntl.h])
|
---|
77 | ABSOLUTE_FCNTL_H=\"$gl_cv_absolute_fcntl_h\"
|
---|
78 | AC_SUBST([ABSOLUTE_FCNTL_H])
|
---|
79 | FCNTL_H='fcntl.h'
|
---|
80 | AC_SUBST([FCNTL_H])
|
---|
81 | ])
|
---|