Mercurial > hg > octave-nkf > gnulib-hg
annotate m4/dup2.m4 @ 12421:e8d2c6fc33ad
Use spaces for indentation, not tabs.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Thu, 10 Dec 2009 20:28:30 +0100 |
parents | 4e193de62444 |
children | c2cbabec01dd |
rev | line source |
---|---|
12401 | 1 #serial 10 |
11726
c694fa3f9d7d
dup2: work around mingw and cygwin 1.5 bug
Eric Blake <ebb9@byu.net>
parents:
8199
diff
changeset
|
2 dnl Copyright (C) 2002, 2005, 2007, 2009 Free Software Foundation, Inc. |
5611
87c42e194f4a
Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4107
diff
changeset
|
3 dnl This file is free software; the Free Software Foundation |
87c42e194f4a
Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4107
diff
changeset
|
4 dnl gives unlimited permission to copy and/or distribute it, |
87c42e194f4a
Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4107
diff
changeset
|
5 dnl with or without modifications, as long as this notice is preserved. |
4107
7c1a6b73f48e
An autoconf macro for its associated module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
6 |
7c1a6b73f48e
An autoconf macro for its associated module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
7 AC_DEFUN([gl_FUNC_DUP2], |
7c1a6b73f48e
An autoconf macro for its associated module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
8 [ |
8199
51d32a83a7df
Move more declarations into <unistd.h>.
Bruno Haible <bruno@clisp.org>
parents:
6275
diff
changeset
|
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) |
11726
c694fa3f9d7d
dup2: work around mingw and cygwin 1.5 bug
Eric Blake <ebb9@byu.net>
parents:
8199
diff
changeset
|
10 AC_REQUIRE([AC_CANONICAL_HOST]) |
8199
51d32a83a7df
Move more declarations into <unistd.h>.
Bruno Haible <bruno@clisp.org>
parents:
6275
diff
changeset
|
11 AC_CHECK_FUNCS_ONCE([dup2]) |
51d32a83a7df
Move more declarations into <unistd.h>.
Bruno Haible <bruno@clisp.org>
parents:
6275
diff
changeset
|
12 if test $ac_cv_func_dup2 = no; then |
51d32a83a7df
Move more declarations into <unistd.h>.
Bruno Haible <bruno@clisp.org>
parents:
6275
diff
changeset
|
13 HAVE_DUP2=0 |
51d32a83a7df
Move more declarations into <unistd.h>.
Bruno Haible <bruno@clisp.org>
parents:
6275
diff
changeset
|
14 AC_LIBOBJ([dup2]) |
11726
c694fa3f9d7d
dup2: work around mingw and cygwin 1.5 bug
Eric Blake <ebb9@byu.net>
parents:
8199
diff
changeset
|
15 else |
c694fa3f9d7d
dup2: work around mingw and cygwin 1.5 bug
Eric Blake <ebb9@byu.net>
parents:
8199
diff
changeset
|
16 AC_CACHE_CHECK([whether dup2 works], [gl_cv_func_dup2_works], |
11902
0aca807a4d5f
dup2: work around a Linux bug.
Bruno Haible <bruno@clisp.org>
parents:
11726
diff
changeset
|
17 [AC_RUN_IFELSE([ |
12148
3c9981d0d9c3
dup2: work around FreeBSD 6.1 bug
Eric Blake <ebb9@byu.net>
parents:
11932
diff
changeset
|
18 AC_LANG_PROGRAM([[#include <unistd.h> |
3c9981d0d9c3
dup2: work around FreeBSD 6.1 bug
Eric Blake <ebb9@byu.net>
parents:
11932
diff
changeset
|
19 #include <errno.h>]], |
11902
0aca807a4d5f
dup2: work around a Linux bug.
Bruno Haible <bruno@clisp.org>
parents:
11726
diff
changeset
|
20 [if (dup2 (1, 1) == 0) |
0aca807a4d5f
dup2: work around a Linux bug.
Bruno Haible <bruno@clisp.org>
parents:
11726
diff
changeset
|
21 return 1; |
0aca807a4d5f
dup2: work around a Linux bug.
Bruno Haible <bruno@clisp.org>
parents:
11726
diff
changeset
|
22 close (0); |
0aca807a4d5f
dup2: work around a Linux bug.
Bruno Haible <bruno@clisp.org>
parents:
11726
diff
changeset
|
23 if (dup2 (0, 0) != -1) |
12148
3c9981d0d9c3
dup2: work around FreeBSD 6.1 bug
Eric Blake <ebb9@byu.net>
parents:
11932
diff
changeset
|
24 return 2; |
3c9981d0d9c3
dup2: work around FreeBSD 6.1 bug
Eric Blake <ebb9@byu.net>
parents:
11932
diff
changeset
|
25 /* Many gnulib modules require POSIX conformance of EBADF. */ |
3c9981d0d9c3
dup2: work around FreeBSD 6.1 bug
Eric Blake <ebb9@byu.net>
parents:
11932
diff
changeset
|
26 if (dup2 (1, 1000000) == -1 && errno != EBADF) |
3c9981d0d9c3
dup2: work around FreeBSD 6.1 bug
Eric Blake <ebb9@byu.net>
parents:
11932
diff
changeset
|
27 return 3; |
11902
0aca807a4d5f
dup2: work around a Linux bug.
Bruno Haible <bruno@clisp.org>
parents:
11726
diff
changeset
|
28 return 0; |
0aca807a4d5f
dup2: work around a Linux bug.
Bruno Haible <bruno@clisp.org>
parents:
11726
diff
changeset
|
29 ]) |
0aca807a4d5f
dup2: work around a Linux bug.
Bruno Haible <bruno@clisp.org>
parents:
11726
diff
changeset
|
30 ], |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12401
diff
changeset
|
31 [gl_cv_func_dup2_works=yes], [gl_cv_func_dup2_works=no], |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12401
diff
changeset
|
32 [case "$host_os" in |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12401
diff
changeset
|
33 mingw*) # on this platform, dup2 always returns 0 for success |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12401
diff
changeset
|
34 gl_cv_func_dup2_works=no;; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12401
diff
changeset
|
35 cygwin*) # on cygwin 1.5.x, dup2(1,1) returns 0 |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12401
diff
changeset
|
36 gl_cv_func_dup2_works=no;; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12401
diff
changeset
|
37 linux*) # On linux between 2008-07-27 and 2009-05-11, dup2 of a |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12401
diff
changeset
|
38 # closed fd may yield -EBADF instead of -1 / errno=EBADF. |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12401
diff
changeset
|
39 gl_cv_func_dup2_works=no;; |
12148
3c9981d0d9c3
dup2: work around FreeBSD 6.1 bug
Eric Blake <ebb9@byu.net>
parents:
11932
diff
changeset
|
40 freebsd*) # on FreeBSD 6.1, dup2(1,1000000) gives EMFILE, not EBADF. |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12401
diff
changeset
|
41 gl_cv_func_dup2_works=no;; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12401
diff
changeset
|
42 *) gl_cv_func_dup2_works=yes;; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12401
diff
changeset
|
43 esac]) |
11902
0aca807a4d5f
dup2: work around a Linux bug.
Bruno Haible <bruno@clisp.org>
parents:
11726
diff
changeset
|
44 ]) |
11726
c694fa3f9d7d
dup2: work around mingw and cygwin 1.5 bug
Eric Blake <ebb9@byu.net>
parents:
8199
diff
changeset
|
45 if test "$gl_cv_func_dup2_works" = no; then |
11932
4073da4a848c
fchdir: simplify error handling, and support dup3
Eric Blake <ebb9@byu.net>
parents:
11902
diff
changeset
|
46 gl_REPLACE_DUP2 |
11726
c694fa3f9d7d
dup2: work around mingw and cygwin 1.5 bug
Eric Blake <ebb9@byu.net>
parents:
8199
diff
changeset
|
47 fi |
8199
51d32a83a7df
Move more declarations into <unistd.h>.
Bruno Haible <bruno@clisp.org>
parents:
6275
diff
changeset
|
48 fi |
4107
7c1a6b73f48e
An autoconf macro for its associated module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
49 ]) |
11932
4073da4a848c
fchdir: simplify error handling, and support dup3
Eric Blake <ebb9@byu.net>
parents:
11902
diff
changeset
|
50 |
4073da4a848c
fchdir: simplify error handling, and support dup3
Eric Blake <ebb9@byu.net>
parents:
11902
diff
changeset
|
51 AC_DEFUN([gl_REPLACE_DUP2], |
4073da4a848c
fchdir: simplify error handling, and support dup3
Eric Blake <ebb9@byu.net>
parents:
11902
diff
changeset
|
52 [ |
4073da4a848c
fchdir: simplify error handling, and support dup3
Eric Blake <ebb9@byu.net>
parents:
11902
diff
changeset
|
53 AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) |
12401 | 54 if test $ac_cv_func_dup2 = yes; then |
55 REPLACE_DUP2=1 | |
56 fi | |
11932
4073da4a848c
fchdir: simplify error handling, and support dup3
Eric Blake <ebb9@byu.net>
parents:
11902
diff
changeset
|
57 AC_LIBOBJ([dup2]) |
4073da4a848c
fchdir: simplify error handling, and support dup3
Eric Blake <ebb9@byu.net>
parents:
11902
diff
changeset
|
58 ]) |