Mercurial > hg > octave-nkf > gnulib-hg
annotate m4/fcntl.m4 @ 17602:f98ee53d8e71
tests: simplify porting to Solaris 10 /bin/sh
Some test cases in 'grep' need a shell that groks '$(';
export re_shell_ for their benefit. Problem reported for 'grep'
by Dagobert Michelsen in <http://bugs.gnu.org/16380>.
* tests/init.sh (re_shell_): Export if it's used.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Tue, 07 Jan 2014 11:46:27 -0800 |
parents | 344018b6e5d7 |
children | 0d3cc0db9cb7 |
rev | line source |
---|---|
15472
284a8cc10af0
fcntl: Remove call-in from fchdir.m4.
Bruno Haible <bruno@clisp.org>
parents:
14232
diff
changeset
|
1 # fcntl.m4 serial 5 |
17587 | 2 dnl Copyright (C) 2009-2014 Free Software Foundation, Inc. |
12454
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
3 dnl This file is free software; the Free Software Foundation |
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
4 dnl gives unlimited permission to copy and/or distribute it, |
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
5 dnl with or without modifications, as long as this notice is preserved. |
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
6 |
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
7 # For now, this module ensures that fcntl() |
12455
dbc90a3fc4ed
fcntl: work around cygwin bug in F_DUPFD
Eric Blake <ebb9@byu.net>
parents:
12454
diff
changeset
|
8 # - supports F_DUPFD correctly |
12454
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
9 # - supports or emulates F_DUPFD_CLOEXEC |
12456
f3aceada3c52
fcntl: port portions of fcntl to mingw
Eric Blake <ebb9@byu.net>
parents:
12455
diff
changeset
|
10 # - supports F_GETFD |
12454
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
11 # Still to be ported to mingw: |
12456
f3aceada3c52
fcntl: port portions of fcntl to mingw
Eric Blake <ebb9@byu.net>
parents:
12455
diff
changeset
|
12 # - F_SETFD |
12454
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
13 # - F_GETFL, F_SETFL |
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
14 # - F_GETOWN, F_SETOWN |
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
15 # - F_GETLK, F_SETLK, F_SETLKW |
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
16 AC_DEFUN([gl_FUNC_FCNTL], |
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
17 [ |
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
18 dnl Persuade glibc to expose F_DUPFD_CLOEXEC. |
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
19 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) |
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
20 AC_REQUIRE([gl_FCNTL_H_DEFAULTS]) |
12455
dbc90a3fc4ed
fcntl: work around cygwin bug in F_DUPFD
Eric Blake <ebb9@byu.net>
parents:
12454
diff
changeset
|
21 AC_REQUIRE([AC_CANONICAL_HOST]) |
12454
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
22 AC_CHECK_FUNCS_ONCE([fcntl]) |
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
23 if test $ac_cv_func_fcntl = no; then |
12456
f3aceada3c52
fcntl: port portions of fcntl to mingw
Eric Blake <ebb9@byu.net>
parents:
12455
diff
changeset
|
24 gl_REPLACE_FCNTL |
12454
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
25 else |
12455
dbc90a3fc4ed
fcntl: work around cygwin bug in F_DUPFD
Eric Blake <ebb9@byu.net>
parents:
12454
diff
changeset
|
26 dnl cygwin 1.5.x F_DUPFD has wrong errno, and allows negative target |
14232
7b83eb00e47a
fcntl: work around Haiku F_DUPFD bugs
Eric Blake <eblake@redhat.com>
parents:
14079
diff
changeset
|
27 dnl haiku alpha 2 F_DUPFD has wrong errno |
12455
dbc90a3fc4ed
fcntl: work around cygwin bug in F_DUPFD
Eric Blake <ebb9@byu.net>
parents:
12454
diff
changeset
|
28 AC_CACHE_CHECK([whether fcntl handles F_DUPFD correctly], |
dbc90a3fc4ed
fcntl: work around cygwin bug in F_DUPFD
Eric Blake <ebb9@byu.net>
parents:
12454
diff
changeset
|
29 [gl_cv_func_fcntl_f_dupfd_works], |
dbc90a3fc4ed
fcntl: work around cygwin bug in F_DUPFD
Eric Blake <ebb9@byu.net>
parents:
12454
diff
changeset
|
30 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ |
dbc90a3fc4ed
fcntl: work around cygwin bug in F_DUPFD
Eric Blake <ebb9@byu.net>
parents:
12454
diff
changeset
|
31 #include <fcntl.h> |
14232
7b83eb00e47a
fcntl: work around Haiku F_DUPFD bugs
Eric Blake <eblake@redhat.com>
parents:
14079
diff
changeset
|
32 #include <errno.h> |
7b83eb00e47a
fcntl: work around Haiku F_DUPFD bugs
Eric Blake <eblake@redhat.com>
parents:
14079
diff
changeset
|
33 ]], [[int result = 0; |
7b83eb00e47a
fcntl: work around Haiku F_DUPFD bugs
Eric Blake <eblake@redhat.com>
parents:
14079
diff
changeset
|
34 if (fcntl (0, F_DUPFD, -1) != -1) result |= 1; |
7b83eb00e47a
fcntl: work around Haiku F_DUPFD bugs
Eric Blake <eblake@redhat.com>
parents:
14079
diff
changeset
|
35 if (errno != EINVAL) result |= 2; |
7b83eb00e47a
fcntl: work around Haiku F_DUPFD bugs
Eric Blake <eblake@redhat.com>
parents:
14079
diff
changeset
|
36 return result; |
12455
dbc90a3fc4ed
fcntl: work around cygwin bug in F_DUPFD
Eric Blake <ebb9@byu.net>
parents:
12454
diff
changeset
|
37 ]])], |
dbc90a3fc4ed
fcntl: work around cygwin bug in F_DUPFD
Eric Blake <ebb9@byu.net>
parents:
12454
diff
changeset
|
38 [gl_cv_func_fcntl_f_dupfd_works=yes], |
dbc90a3fc4ed
fcntl: work around cygwin bug in F_DUPFD
Eric Blake <ebb9@byu.net>
parents:
12454
diff
changeset
|
39 [gl_cv_func_fcntl_f_dupfd_works=no], |
dbc90a3fc4ed
fcntl: work around cygwin bug in F_DUPFD
Eric Blake <ebb9@byu.net>
parents:
12454
diff
changeset
|
40 [# Guess that it works on glibc systems |
dbc90a3fc4ed
fcntl: work around cygwin bug in F_DUPFD
Eric Blake <ebb9@byu.net>
parents:
12454
diff
changeset
|
41 case $host_os in #(( |
dbc90a3fc4ed
fcntl: work around cygwin bug in F_DUPFD
Eric Blake <ebb9@byu.net>
parents:
12454
diff
changeset
|
42 *-gnu*) gl_cv_func_fcntl_f_dupfd_works="guessing yes";; |
dbc90a3fc4ed
fcntl: work around cygwin bug in F_DUPFD
Eric Blake <ebb9@byu.net>
parents:
12454
diff
changeset
|
43 *) gl_cv_func_fcntl_f_dupfd_works="guessing no";; |
dbc90a3fc4ed
fcntl: work around cygwin bug in F_DUPFD
Eric Blake <ebb9@byu.net>
parents:
12454
diff
changeset
|
44 esac])]) |
dbc90a3fc4ed
fcntl: work around cygwin bug in F_DUPFD
Eric Blake <ebb9@byu.net>
parents:
12454
diff
changeset
|
45 case $gl_cv_func_fcntl_f_dupfd_works in |
dbc90a3fc4ed
fcntl: work around cygwin bug in F_DUPFD
Eric Blake <ebb9@byu.net>
parents:
12454
diff
changeset
|
46 *yes) ;; |
dbc90a3fc4ed
fcntl: work around cygwin bug in F_DUPFD
Eric Blake <ebb9@byu.net>
parents:
12454
diff
changeset
|
47 *) gl_REPLACE_FCNTL |
dbc90a3fc4ed
fcntl: work around cygwin bug in F_DUPFD
Eric Blake <ebb9@byu.net>
parents:
12454
diff
changeset
|
48 AC_DEFINE([FCNTL_DUPFD_BUGGY], [1], [Define this to 1 if F_DUPFD |
dbc90a3fc4ed
fcntl: work around cygwin bug in F_DUPFD
Eric Blake <ebb9@byu.net>
parents:
12454
diff
changeset
|
49 behavior does not match POSIX]) ;; |
dbc90a3fc4ed
fcntl: work around cygwin bug in F_DUPFD
Eric Blake <ebb9@byu.net>
parents:
12454
diff
changeset
|
50 esac |
dbc90a3fc4ed
fcntl: work around cygwin bug in F_DUPFD
Eric Blake <ebb9@byu.net>
parents:
12454
diff
changeset
|
51 |
dbc90a3fc4ed
fcntl: work around cygwin bug in F_DUPFD
Eric Blake <ebb9@byu.net>
parents:
12454
diff
changeset
|
52 dnl Many systems lack F_DUPFD_CLOEXEC |
12454
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
53 AC_CACHE_CHECK([whether fcntl understands F_DUPFD_CLOEXEC], |
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
54 [gl_cv_func_fcntl_f_dupfd_cloexec], |
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
55 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ |
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
56 #include <fcntl.h> |
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
57 #ifndef F_DUPFD_CLOEXEC |
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
58 choke me |
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
59 #endif |
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
60 ]])], |
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
61 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ |
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
62 #ifdef __linux__ |
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
63 /* The Linux kernel only added F_DUPFD_CLOEXEC in 2.6.24, so we always replace |
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
64 it to support the semantics on older kernels that failed with EINVAL. */ |
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
65 choke me |
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
66 #endif |
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
67 ]])], |
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
68 [gl_cv_func_fcntl_f_dupfd_cloexec=yes], |
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
69 [gl_cv_func_fcntl_f_dupfd_cloexec="needs runtime check"])], |
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
70 [gl_cv_func_fcntl_f_dupfd_cloexec=no])]) |
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
71 if test "$gl_cv_func_fcntl_f_dupfd_cloexec" != yes; then |
12455
dbc90a3fc4ed
fcntl: work around cygwin bug in F_DUPFD
Eric Blake <ebb9@byu.net>
parents:
12454
diff
changeset
|
72 gl_REPLACE_FCNTL |
dbc90a3fc4ed
fcntl: work around cygwin bug in F_DUPFD
Eric Blake <ebb9@byu.net>
parents:
12454
diff
changeset
|
73 dnl No witness macro needed for this bug. |
12454
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
74 fi |
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
75 fi |
15472
284a8cc10af0
fcntl: Remove call-in from fchdir.m4.
Bruno Haible <bruno@clisp.org>
parents:
14232
diff
changeset
|
76 dnl Replace fcntl() for supporting the gnulib-defined fchdir() function, |
284a8cc10af0
fcntl: Remove call-in from fchdir.m4.
Bruno Haible <bruno@clisp.org>
parents:
14232
diff
changeset
|
77 dnl to keep fchdir's bookkeeping up-to-date. |
284a8cc10af0
fcntl: Remove call-in from fchdir.m4.
Bruno Haible <bruno@clisp.org>
parents:
14232
diff
changeset
|
78 m4_ifdef([gl_FUNC_FCHDIR], [ |
284a8cc10af0
fcntl: Remove call-in from fchdir.m4.
Bruno Haible <bruno@clisp.org>
parents:
14232
diff
changeset
|
79 gl_TEST_FCHDIR |
284a8cc10af0
fcntl: Remove call-in from fchdir.m4.
Bruno Haible <bruno@clisp.org>
parents:
14232
diff
changeset
|
80 if test $HAVE_FCHDIR = 0; then |
284a8cc10af0
fcntl: Remove call-in from fchdir.m4.
Bruno Haible <bruno@clisp.org>
parents:
14232
diff
changeset
|
81 gl_REPLACE_FCNTL |
284a8cc10af0
fcntl: Remove call-in from fchdir.m4.
Bruno Haible <bruno@clisp.org>
parents:
14232
diff
changeset
|
82 fi |
284a8cc10af0
fcntl: Remove call-in from fchdir.m4.
Bruno Haible <bruno@clisp.org>
parents:
14232
diff
changeset
|
83 ]) |
12454
f7624052e60d
fcntl: support F_DUPFD_CLOEXEC on systems with fcntl
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
84 ]) |
12455
dbc90a3fc4ed
fcntl: work around cygwin bug in F_DUPFD
Eric Blake <ebb9@byu.net>
parents:
12454
diff
changeset
|
85 |
dbc90a3fc4ed
fcntl: work around cygwin bug in F_DUPFD
Eric Blake <ebb9@byu.net>
parents:
12454
diff
changeset
|
86 AC_DEFUN([gl_REPLACE_FCNTL], |
dbc90a3fc4ed
fcntl: work around cygwin bug in F_DUPFD
Eric Blake <ebb9@byu.net>
parents:
12454
diff
changeset
|
87 [ |
dbc90a3fc4ed
fcntl: work around cygwin bug in F_DUPFD
Eric Blake <ebb9@byu.net>
parents:
12454
diff
changeset
|
88 AC_REQUIRE([gl_FCNTL_H_DEFAULTS]) |
dbc90a3fc4ed
fcntl: work around cygwin bug in F_DUPFD
Eric Blake <ebb9@byu.net>
parents:
12454
diff
changeset
|
89 AC_CHECK_FUNCS_ONCE([fcntl]) |
12456
f3aceada3c52
fcntl: port portions of fcntl to mingw
Eric Blake <ebb9@byu.net>
parents:
12455
diff
changeset
|
90 if test $ac_cv_func_fcntl = no; then |
f3aceada3c52
fcntl: port portions of fcntl to mingw
Eric Blake <ebb9@byu.net>
parents:
12455
diff
changeset
|
91 HAVE_FCNTL=0 |
f3aceada3c52
fcntl: port portions of fcntl to mingw
Eric Blake <ebb9@byu.net>
parents:
12455
diff
changeset
|
92 else |
12455
dbc90a3fc4ed
fcntl: work around cygwin bug in F_DUPFD
Eric Blake <ebb9@byu.net>
parents:
12454
diff
changeset
|
93 REPLACE_FCNTL=1 |
dbc90a3fc4ed
fcntl: work around cygwin bug in F_DUPFD
Eric Blake <ebb9@byu.net>
parents:
12454
diff
changeset
|
94 fi |
dbc90a3fc4ed
fcntl: work around cygwin bug in F_DUPFD
Eric Blake <ebb9@byu.net>
parents:
12454
diff
changeset
|
95 ]) |