2 # See if we need to provide fdopendir.
4 dnl Copyright (C) 2009-2019 Free Software Foundation, Inc.
5 dnl This file is free software; the Free Software Foundation
6 dnl gives unlimited permission to copy and/or distribute it,
7 dnl with or without modifications, as long as this notice is preserved.
9 # Written by Eric Blake.
11 AC_DEFUN([gl_FUNC_FDOPENDIR],
13 AC_REQUIRE([gl_DIRENT_H_DEFAULTS])
14 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
16 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
18 dnl FreeBSD 7.3 has the function, but failed to declare it.
19 AC_CHECK_DECLS([fdopendir], [], [HAVE_DECL_FDOPENDIR=0], [[
22 AC_CHECK_FUNCS_ONCE([fdopendir])
23 if test $ac_cv_func_fdopendir = no; then
26 AC_CACHE_CHECK([whether fdopendir works],
27 [gl_cv_func_fdopendir_works],
28 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
32 #if !HAVE_DECL_FDOPENDIR
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;
45 [gl_cv_func_fdopendir_works=yes],
46 [gl_cv_func_fdopendir_works=no],
48 # Guess yes on glibc systems.
49 *-gnu*) gl_cv_func_fdopendir_works="guessing yes" ;;
50 # If we don't know, assume the worst.
51 *) gl_cv_func_fdopendir_works="guessing no" ;;
54 case "$gl_cv_func_fdopendir_works" in