comparison m4/dup.m4 @ 15760:45b9be95a543

New module 'dup'. * lib/unistd.in.h (dup): Declare only if the 'dup' module is in use. Allow replacement. * lib/dup.c: New file. * lib/fchdir.c (rpl_dup): Remove function. * m4/dup.m4: New file. * m4/fchdir.m4 (gl_FUNC_FCHDIR): Don't set REPLACE_DUP here. * m4/unistd_h.m4 (gl_UNISTD_H): Test whether 'dup' is declared. (gl_UNISTD_H_DEFAULTS): Initialize GNULIB_DUP. * modules/unistd (Makefile.am): Substitute GNULIB_DUP. * modules/dup: New file. * tests/test-unistd-c++.cc: Check the signature of 'dup' only if the 'dup' module is in use. * modules/fdopendir (Depends-on): Add dup. * modules/fdutimensat-tests (Depends-on): Likewise. * modules/fts (Depends-on): Likewise. * modules/futimens-tests (Depends-on): Likewise. * modules/posix_spawnp-tests (Depends-on): Likewise. * modules/unistd-safer-tests (Depends-on): Likewise. * modules/utimens-tests (Depends-on): Likewise. * doc/posix-functions/dup.texi: Mention the new module and the problem on MSVC.
author Bruno Haible <bruno@clisp.org>
date Sat, 24 Sep 2011 02:08:13 +0200
parents
children b5685d79081c
comparison
equal deleted inserted replaced
15759:4583838a5587 15760:45b9be95a543
1 # dup.m4 serial 1
2 dnl Copyright (C) 2011 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 AC_DEFUN([gl_FUNC_DUP],
8 [
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10 AC_REQUIRE([AC_CANONICAL_HOST])
11 AC_CHECK_HEADERS_ONCE([unistd.h])
12 AC_CACHE_CHECK([whether dup supports bad arguments], [gl_cv_func_dup_works],
13 [AC_RUN_IFELSE(
14 [AC_LANG_PROGRAM([[
15 #if HAVE_UNISTD_H
16 # include <unistd.h>
17 #else
18 # include <io.h>
19 #endif
20 #include <errno.h>
21 ]],
22 [[if (dup (-1) != -1)
23 return 1;
24 if (errno != EBADF)
25 return 2;
26 return 0;
27 ]])],
28 [gl_cv_func_dup_works=yes],
29 [gl_cv_func_dup_works=no],
30 [case "$host_os" in
31 mingw*) gl_cv_func_dup_works="guessing no" ;;
32 *) gl_cv_func_dup_works="guessing yes" ;;
33 esac
34 ])
35 ])
36 case "$gl_cv_func_dup_works" in
37 *no) REPLACE_DUP=1 ;;
38 esac
39 dnl Replace dup() for supporting the gnulib-defined fchdir() function,
40 dnl to keep fchdir's bookkeeping up-to-date.
41 m4_ifdef([gl_FUNC_FCHDIR], [
42 gl_TEST_FCHDIR
43 if test $HAVE_FCHDIR = 0; then
44 REPLACE_DUP=1
45 fi
46 ])
47 ])
48
49 # Prerequisites of lib/dup.c.
50 AC_DEFUN([gl_PREREQ_DUP], [
51 AC_REQUIRE([AC_C_INLINE])
52 ])