|
Packit |
709fb3 |
# serial 10
|
|
Packit |
709fb3 |
# See if we need to provide fdopendir.
|
|
Packit |
709fb3 |
|
|
Packit |
709fb3 |
dnl Copyright (C) 2009-2017 Free Software Foundation, Inc.
|
|
Packit |
709fb3 |
dnl This file is free software; the Free Software Foundation
|
|
Packit |
709fb3 |
dnl gives unlimited permission to copy and/or distribute it,
|
|
Packit |
709fb3 |
dnl with or without modifications, as long as this notice is preserved.
|
|
Packit |
709fb3 |
|
|
Packit |
709fb3 |
# Written by Eric Blake.
|
|
Packit |
709fb3 |
|
|
Packit |
709fb3 |
AC_DEFUN([gl_FUNC_FDOPENDIR],
|
|
Packit |
709fb3 |
[
|
|
Packit |
709fb3 |
AC_REQUIRE([gl_DIRENT_H_DEFAULTS])
|
|
Packit |
709fb3 |
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
|
|
Packit |
709fb3 |
|
|
Packit |
709fb3 |
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
|
|
Packit |
709fb3 |
|
|
Packit |
709fb3 |
dnl FreeBSD 7.3 has the function, but failed to declare it.
|
|
Packit |
709fb3 |
AC_CHECK_DECLS([fdopendir], [], [HAVE_DECL_FDOPENDIR=0], [[
|
|
Packit |
709fb3 |
#include <dirent.h>
|
|
Packit |
709fb3 |
]])
|
|
Packit |
709fb3 |
AC_CHECK_FUNCS_ONCE([fdopendir])
|
|
Packit |
709fb3 |
if test $ac_cv_func_fdopendir = no; then
|
|
Packit |
709fb3 |
HAVE_FDOPENDIR=0
|
|
Packit |
709fb3 |
else
|
|
Packit |
709fb3 |
AC_CACHE_CHECK([whether fdopendir works],
|
|
Packit |
709fb3 |
[gl_cv_func_fdopendir_works],
|
|
Packit |
709fb3 |
[AC_RUN_IFELSE([AC_LANG_PROGRAM([[
|
|
Packit |
709fb3 |
#include <dirent.h>
|
|
Packit |
709fb3 |
#include <fcntl.h>
|
|
Packit |
709fb3 |
#include <unistd.h>
|
|
Packit |
709fb3 |
#if !HAVE_DECL_FDOPENDIR
|
|
Packit |
709fb3 |
extern
|
|
Packit |
709fb3 |
# ifdef __cplusplus
|
|
Packit |
709fb3 |
"C"
|
|
Packit |
709fb3 |
# endif
|
|
Packit |
709fb3 |
DIR *fdopendir (int);
|
|
Packit |
709fb3 |
#endif
|
|
Packit |
709fb3 |
]], [int result = 0;
|
|
Packit |
709fb3 |
int fd = open ("conftest.c", O_RDONLY);
|
|
Packit |
709fb3 |
if (fd < 0) result |= 1;
|
|
Packit |
709fb3 |
if (fdopendir (fd)) result |= 2;
|
|
Packit |
709fb3 |
if (close (fd)) result |= 4;
|
|
Packit |
709fb3 |
return result;])],
|
|
Packit |
709fb3 |
[gl_cv_func_fdopendir_works=yes],
|
|
Packit |
709fb3 |
[gl_cv_func_fdopendir_works=no],
|
|
Packit |
709fb3 |
[case "$host_os" in
|
|
Packit |
709fb3 |
# Guess yes on glibc systems.
|
|
Packit |
709fb3 |
*-gnu*) gl_cv_func_fdopendir_works="guessing yes" ;;
|
|
Packit |
709fb3 |
# If we don't know, assume the worst.
|
|
Packit |
709fb3 |
*) gl_cv_func_fdopendir_works="guessing no" ;;
|
|
Packit |
709fb3 |
esac
|
|
Packit |
709fb3 |
])])
|
|
Packit |
709fb3 |
case "$gl_cv_func_fdopendir_works" in
|
|
Packit |
709fb3 |
*yes) ;;
|
|
Packit |
709fb3 |
*)
|
|
Packit |
709fb3 |
REPLACE_FDOPENDIR=1
|
|
Packit |
709fb3 |
;;
|
|
Packit |
709fb3 |
esac
|
|
Packit |
709fb3 |
fi
|
|
Packit |
709fb3 |
])
|