Update Gnulib to the latest git version
[deliverable/binutils-gdb.git] / gnulib / import / m4 / fdopendir.m4
CommitLineData
c0c3707f 1# serial 12
6ec2e0f5
SDJ
2# See if we need to provide fdopendir.
3
c0c3707f 4dnl Copyright (C) 2009-2019 Free Software Foundation, Inc.
6ec2e0f5
SDJ
5dnl This file is free software; the Free Software Foundation
6dnl gives unlimited permission to copy and/or distribute it,
7dnl with or without modifications, as long as this notice is preserved.
8
9# Written by Eric Blake.
10
11AC_DEFUN([gl_FUNC_FDOPENDIR],
12[
13 AC_REQUIRE([gl_DIRENT_H_DEFAULTS])
14 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
15
16 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
17
18 dnl FreeBSD 7.3 has the function, but failed to declare it.
19 AC_CHECK_DECLS([fdopendir], [], [HAVE_DECL_FDOPENDIR=0], [[
20#include <dirent.h>
21 ]])
22 AC_CHECK_FUNCS_ONCE([fdopendir])
23 if test $ac_cv_func_fdopendir = no; then
24 HAVE_FDOPENDIR=0
25 else
26 AC_CACHE_CHECK([whether fdopendir works],
27 [gl_cv_func_fdopendir_works],
28 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
29#include <dirent.h>
30#include <fcntl.h>
31#include <unistd.h>
32#if !HAVE_DECL_FDOPENDIR
33extern
34# ifdef __cplusplus
35"C"
36# endif
37DIR *fdopendir (int);
38#endif
39]], [int result = 0;
40 int fd = open ("conftest.c", O_RDONLY);
41 if (fd < 0) result |= 1;
42 if (fdopendir (fd)) result |= 2;
43 if (close (fd)) result |= 4;
44 return result;])],
45 [gl_cv_func_fdopendir_works=yes],
46 [gl_cv_func_fdopendir_works=no],
47 [case "$host_os" in
c0c3707f
CB
48 # Guess yes on glibc systems.
49 *-gnu*) gl_cv_func_fdopendir_works="guessing yes" ;;
50 # Guess yes on musl systems.
51 *-musl*) gl_cv_func_fdopendir_works="guessing yes" ;;
52 # If we don't know, obey --enable-cross-guesses.
53 *) gl_cv_func_fdopendir_works="$gl_cross_guess_normal" ;;
6ec2e0f5
SDJ
54 esac
55 ])])
56 case "$gl_cv_func_fdopendir_works" in
57 *yes) ;;
58 *)
59 REPLACE_FDOPENDIR=1
60 ;;
61 esac
62 fi
63])
This page took 0.203385 seconds and 4 git commands to generate.