annotate m4/open.m4 @ 40196:e63f5d3edab5

relocatable-prog: Update documentation. * doc/relocatable-maint.texi (Supporting Relocation): Update to match the recent changes.
author Bruno Haible <bruno@clisp.org>
date Sun, 24 Feb 2019 01:49:15 +0100
parents b06060465f09
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19052
637f3a63efbd open: support O_CLOEXEC
Paul Eggert <eggert@cs.ucla.edu>
parents: 18626
diff changeset
1 # open.m4 serial 15
40057
b06060465f09 maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents: 19484
diff changeset
2 dnl Copyright (C) 2007-2019 Free Software Foundation, Inc.
9299
ada4d73c37a6 New module 'open'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3 dnl This file is free software; the Free Software Foundation
ada4d73c37a6 New module 'open'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 dnl gives unlimited permission to copy and/or distribute it,
ada4d73c37a6 New module 'open'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 dnl with or without modifications, as long as this notice is preserved.
ada4d73c37a6 New module 'open'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6
ada4d73c37a6 New module 'open'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 AC_DEFUN([gl_FUNC_OPEN],
ada4d73c37a6 New module 'open'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8 [
ada4d73c37a6 New module 'open'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 AC_REQUIRE([AC_CANONICAL_HOST])
19052
637f3a63efbd open: support O_CLOEXEC
Paul Eggert <eggert@cs.ucla.edu>
parents: 18626
diff changeset
10 AC_REQUIRE([gl_PREPROC_O_CLOEXEC])
9299
ada4d73c37a6 New module 'open'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 case "$host_os" in
ada4d73c37a6 New module 'open'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 mingw* | pw*)
15464
c7958f06a571 open: Move AC_LIBOBJ invocation to module description.
Bruno Haible <bruno@clisp.org>
parents: 15463
diff changeset
13 REPLACE_OPEN=1
9299
ada4d73c37a6 New module 'open'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14 ;;
10201
270b7afb8fb7 Work around open() bug on HP-UX 11 and Solaris 9.
Bruno Haible <bruno@clisp.org>
parents: 9299
diff changeset
15 *)
270b7afb8fb7 Work around open() bug on HP-UX 11 and Solaris 9.
Bruno Haible <bruno@clisp.org>
parents: 9299
diff changeset
16 dnl open("foo/") should not create a file when the file name has a
12259
80f02cc1739e open: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 11802
diff changeset
17 dnl trailing slash. FreeBSD only has the problem on symlinks.
80f02cc1739e open: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 11802
diff changeset
18 AC_CHECK_FUNCS_ONCE([lstat])
19052
637f3a63efbd open: support O_CLOEXEC
Paul Eggert <eggert@cs.ucla.edu>
parents: 18626
diff changeset
19 if test "$gl_cv_macro_O_CLOEXEC" != yes; then
637f3a63efbd open: support O_CLOEXEC
Paul Eggert <eggert@cs.ucla.edu>
parents: 18626
diff changeset
20 REPLACE_OPEN=1
637f3a63efbd open: support O_CLOEXEC
Paul Eggert <eggert@cs.ucla.edu>
parents: 18626
diff changeset
21 fi
10201
270b7afb8fb7 Work around open() bug on HP-UX 11 and Solaris 9.
Bruno Haible <bruno@clisp.org>
parents: 9299
diff changeset
22 AC_CACHE_CHECK([whether open recognizes a trailing slash],
270b7afb8fb7 Work around open() bug on HP-UX 11 and Solaris 9.
Bruno Haible <bruno@clisp.org>
parents: 9299
diff changeset
23 [gl_cv_func_open_slash],
12259
80f02cc1739e open: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 11802
diff changeset
24 [# Assume that if we have lstat, we can also check symlinks.
80f02cc1739e open: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 11802
diff changeset
25 if test $ac_cv_func_lstat = yes; then
80f02cc1739e open: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 11802
diff changeset
26 touch conftest.tmp
80f02cc1739e open: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 11802
diff changeset
27 ln -s conftest.tmp conftest.lnk
80f02cc1739e open: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 11802
diff changeset
28 fi
13579
da9779900713 Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents: 13490
diff changeset
29 AC_RUN_IFELSE(
da9779900713 Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents: 13490
diff changeset
30 [AC_LANG_SOURCE([[
10201
270b7afb8fb7 Work around open() bug on HP-UX 11 and Solaris 9.
Bruno Haible <bruno@clisp.org>
parents: 9299
diff changeset
31 #include <fcntl.h>
270b7afb8fb7 Work around open() bug on HP-UX 11 and Solaris 9.
Bruno Haible <bruno@clisp.org>
parents: 9299
diff changeset
32 #if HAVE_UNISTD_H
270b7afb8fb7 Work around open() bug on HP-UX 11 and Solaris 9.
Bruno Haible <bruno@clisp.org>
parents: 9299
diff changeset
33 # include <unistd.h>
270b7afb8fb7 Work around open() bug on HP-UX 11 and Solaris 9.
Bruno Haible <bruno@clisp.org>
parents: 9299
diff changeset
34 #endif
270b7afb8fb7 Work around open() bug on HP-UX 11 and Solaris 9.
Bruno Haible <bruno@clisp.org>
parents: 9299
diff changeset
35 int main ()
270b7afb8fb7 Work around open() bug on HP-UX 11 and Solaris 9.
Bruno Haible <bruno@clisp.org>
parents: 9299
diff changeset
36 {
13918
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13579
diff changeset
37 int result = 0;
12259
80f02cc1739e open: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 11802
diff changeset
38 #if HAVE_LSTAT
13918
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13579
diff changeset
39 if (open ("conftest.lnk/", O_RDONLY) != -1)
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13579
diff changeset
40 result |= 1;
12259
80f02cc1739e open: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 11802
diff changeset
41 #endif
13918
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13579
diff changeset
42 if (open ("conftest.sl/", O_CREAT, 0600) >= 0)
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13579
diff changeset
43 result |= 2;
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13579
diff changeset
44 return result;
13579
da9779900713 Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents: 13490
diff changeset
45 }]])],
da9779900713 Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents: 13490
diff changeset
46 [gl_cv_func_open_slash=yes],
da9779900713 Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents: 13490
diff changeset
47 [gl_cv_func_open_slash=no],
10201
270b7afb8fb7 Work around open() bug on HP-UX 11 and Solaris 9.
Bruno Haible <bruno@clisp.org>
parents: 9299
diff changeset
48 [
270b7afb8fb7 Work around open() bug on HP-UX 11 and Solaris 9.
Bruno Haible <bruno@clisp.org>
parents: 9299
diff changeset
49 changequote(,)dnl
270b7afb8fb7 Work around open() bug on HP-UX 11 and Solaris 9.
Bruno Haible <bruno@clisp.org>
parents: 9299
diff changeset
50 case "$host_os" in
13972
258e995bb973 Fix cross-compilation guesses on Solaris.
Bruno Haible <bruno@clisp.org>
parents: 13918
diff changeset
51 freebsd* | aix* | hpux* | solaris2.[0-9] | solaris2.[0-9].*)
13490
e04f4ee19c1b open, fopen: Update regarding AIX.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
52 gl_cv_func_open_slash="guessing no" ;;
e04f4ee19c1b open, fopen: Update regarding AIX.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
53 *)
e04f4ee19c1b open, fopen: Update regarding AIX.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
54 gl_cv_func_open_slash="guessing yes" ;;
10201
270b7afb8fb7 Work around open() bug on HP-UX 11 and Solaris 9.
Bruno Haible <bruno@clisp.org>
parents: 9299
diff changeset
55 esac
270b7afb8fb7 Work around open() bug on HP-UX 11 and Solaris 9.
Bruno Haible <bruno@clisp.org>
parents: 9299
diff changeset
56 changequote([,])dnl
270b7afb8fb7 Work around open() bug on HP-UX 11 and Solaris 9.
Bruno Haible <bruno@clisp.org>
parents: 9299
diff changeset
57 ])
12259
80f02cc1739e open: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 11802
diff changeset
58 rm -f conftest.sl conftest.tmp conftest.lnk
10201
270b7afb8fb7 Work around open() bug on HP-UX 11 and Solaris 9.
Bruno Haible <bruno@clisp.org>
parents: 9299
diff changeset
59 ])
270b7afb8fb7 Work around open() bug on HP-UX 11 and Solaris 9.
Bruno Haible <bruno@clisp.org>
parents: 9299
diff changeset
60 case "$gl_cv_func_open_slash" in
270b7afb8fb7 Work around open() bug on HP-UX 11 and Solaris 9.
Bruno Haible <bruno@clisp.org>
parents: 9299
diff changeset
61 *no)
11007
f6cba5a556ce many *.m4 files: improve m4 quoting
Jim Meyering <meyering@redhat.com>
parents: 10605
diff changeset
62 AC_DEFINE([OPEN_TRAILING_SLASH_BUG], [1],
10201
270b7afb8fb7 Work around open() bug on HP-UX 11 and Solaris 9.
Bruno Haible <bruno@clisp.org>
parents: 9299
diff changeset
63 [Define to 1 if open() fails to recognize a trailing slash.])
15464
c7958f06a571 open: Move AC_LIBOBJ invocation to module description.
Bruno Haible <bruno@clisp.org>
parents: 15463
diff changeset
64 REPLACE_OPEN=1
10201
270b7afb8fb7 Work around open() bug on HP-UX 11 and Solaris 9.
Bruno Haible <bruno@clisp.org>
parents: 9299
diff changeset
65 ;;
270b7afb8fb7 Work around open() bug on HP-UX 11 and Solaris 9.
Bruno Haible <bruno@clisp.org>
parents: 9299
diff changeset
66 esac
270b7afb8fb7 Work around open() bug on HP-UX 11 and Solaris 9.
Bruno Haible <bruno@clisp.org>
parents: 9299
diff changeset
67 ;;
9299
ada4d73c37a6 New module 'open'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
68 esac
15463
d4d986a874bd open: Remove call-in from fchdir.m4.
Bruno Haible <bruno@clisp.org>
parents: 14594
diff changeset
69 dnl Replace open() for supporting the gnulib-defined fchdir() function,
d4d986a874bd open: Remove call-in from fchdir.m4.
Bruno Haible <bruno@clisp.org>
parents: 14594
diff changeset
70 dnl to keep fchdir's bookkeeping up-to-date.
d4d986a874bd open: Remove call-in from fchdir.m4.
Bruno Haible <bruno@clisp.org>
parents: 14594
diff changeset
71 m4_ifdef([gl_FUNC_FCHDIR], [
d4d986a874bd open: Remove call-in from fchdir.m4.
Bruno Haible <bruno@clisp.org>
parents: 14594
diff changeset
72 if test $REPLACE_OPEN = 0; then
d4d986a874bd open: Remove call-in from fchdir.m4.
Bruno Haible <bruno@clisp.org>
parents: 14594
diff changeset
73 gl_TEST_FCHDIR
d4d986a874bd open: Remove call-in from fchdir.m4.
Bruno Haible <bruno@clisp.org>
parents: 14594
diff changeset
74 if test $HAVE_FCHDIR = 0; then
15464
c7958f06a571 open: Move AC_LIBOBJ invocation to module description.
Bruno Haible <bruno@clisp.org>
parents: 15463
diff changeset
75 REPLACE_OPEN=1
15463
d4d986a874bd open: Remove call-in from fchdir.m4.
Bruno Haible <bruno@clisp.org>
parents: 14594
diff changeset
76 fi
d4d986a874bd open: Remove call-in from fchdir.m4.
Bruno Haible <bruno@clisp.org>
parents: 14594
diff changeset
77 fi
d4d986a874bd open: Remove call-in from fchdir.m4.
Bruno Haible <bruno@clisp.org>
parents: 14594
diff changeset
78 ])
14594
e270695eecd5 Move the support of O_NONBLOCK in open() to the 'open' module.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
79 dnl Replace open() for supporting the gnulib-defined O_NONBLOCK flag.
e270695eecd5 Move the support of O_NONBLOCK in open() to the 'open' module.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
80 m4_ifdef([gl_NONBLOCKING_IO], [
e270695eecd5 Move the support of O_NONBLOCK in open() to the 'open' module.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
81 if test $REPLACE_OPEN = 0; then
e270695eecd5 Move the support of O_NONBLOCK in open() to the 'open' module.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
82 gl_NONBLOCKING_IO
e270695eecd5 Move the support of O_NONBLOCK in open() to the 'open' module.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
83 if test $gl_cv_have_open_O_NONBLOCK != yes; then
15464
c7958f06a571 open: Move AC_LIBOBJ invocation to module description.
Bruno Haible <bruno@clisp.org>
parents: 15463
diff changeset
84 REPLACE_OPEN=1
14594
e270695eecd5 Move the support of O_NONBLOCK in open() to the 'open' module.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
85 fi
e270695eecd5 Move the support of O_NONBLOCK in open() to the 'open' module.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
86 fi
e270695eecd5 Move the support of O_NONBLOCK in open() to the 'open' module.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
87 ])
9299
ada4d73c37a6 New module 'open'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
88 ])
10533
d4b37870fdc9 Override open more carefully.
Bruno Haible <bruno@clisp.org>
parents: 10201
diff changeset
89
d4b37870fdc9 Override open more carefully.
Bruno Haible <bruno@clisp.org>
parents: 10201
diff changeset
90 # Prerequisites of lib/open.c.
d4b37870fdc9 Override open more carefully.
Bruno Haible <bruno@clisp.org>
parents: 10201
diff changeset
91 AC_DEFUN([gl_PREREQ_OPEN],
d4b37870fdc9 Override open more carefully.
Bruno Haible <bruno@clisp.org>
parents: 10201
diff changeset
92 [
11586
35f0931dc243 Simplify use of mode_t varargs.
Bruno Haible <bruno@clisp.org>
parents: 11007
diff changeset
93 AC_REQUIRE([gl_PROMOTED_TYPE_MODE_T])
10605
e47d71e06ebd Fix organization of 'open' replacement.
Paolo Bonzini <bonzini@gnu.org>
parents: 10533
diff changeset
94 :
10533
d4b37870fdc9 Override open more carefully.
Bruno Haible <bruno@clisp.org>
parents: 10201
diff changeset
95 ])