Improve the test for dirfd(), some systems #define it rather than have

an actual function.
This commit is contained in:
Gregory P. Smith 2012-01-21 18:20:15 -08:00
parent e9b7cab1da
commit df300d5062
3 changed files with 65 additions and 49 deletions

104
configure vendored
View File

@ -2248,6 +2248,52 @@ $as_echo "$ac_res" >&6; }
} # ac_fn_c_check_func } # ac_fn_c_check_func
# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
# ---------------------------------------------
# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
# accordingly.
ac_fn_c_check_decl ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
as_decl_name=`echo $2|sed 's/ *(.*//'`
as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
if eval \${$3+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
int
main ()
{
#ifndef $as_decl_name
#ifdef __cplusplus
(void) $as_decl_use;
#else
(void) $as_decl_name;
#endif
#endif
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
eval "$3=yes"
else
eval "$3=no"
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_decl
# ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES # ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES
# ---------------------------------------------------- # ----------------------------------------------------
# Tries to find if the field MEMBER exists in type AGGR, after including # Tries to find if the field MEMBER exists in type AGGR, after including
@ -2304,52 +2350,6 @@ $as_echo "$ac_res" >&6; }
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_member } # ac_fn_c_check_member
# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
# ---------------------------------------------
# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
# accordingly.
ac_fn_c_check_decl ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
as_decl_name=`echo $2|sed 's/ *(.*//'`
as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
if eval \${$3+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
int
main ()
{
#ifndef $as_decl_name
#ifdef __cplusplus
(void) $as_decl_use;
#else
(void) $as_decl_name;
#endif
#endif
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
eval "$3=yes"
else
eval "$3=no"
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_decl
cat >config.log <<_ACEOF cat >config.log <<_ACEOF
This file contains any messages produced by compilers while This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake. running configure, to aid debugging if configure makes a mistake.
@ -9410,7 +9410,7 @@ $as_echo "MACHDEP_OBJS" >&6; }
# checks for library functions # checks for library functions
for ac_func in alarm accept4 setitimer getitimer bind_textdomain_codeset chown \ for ac_func in alarm accept4 setitimer getitimer bind_textdomain_codeset chown \
clock confstr ctermid dirfd execv fchmod fchown fork fpathconf ftime ftruncate \ clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \ gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \ getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \
initgroups kill killpg lchmod lchown lstat mbrtowc mkfifo mknod mktime \ initgroups kill killpg lchmod lchown lstat mbrtowc mkfifo mknod mktime \
@ -9435,6 +9435,16 @@ fi
done done
ac_fn_c_check_decl "$LINENO" "dirfd" "ac_cv_have_decl_dirfd" "#include <sys/types.h>
#include <dirent.h>
"
if test "x$ac_cv_have_decl_dirfd" = xyes; then :
$as_echo "#define HAVE_DIRFD 1" >>confdefs.h
fi
# For some functions, having a definition is not sufficient, since # For some functions, having a definition is not sufficient, since
# we want to take their address. # we want to take their address.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for chroot" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for chroot" >&5

View File

@ -2587,7 +2587,7 @@ AC_MSG_RESULT(MACHDEP_OBJS)
# checks for library functions # checks for library functions
AC_CHECK_FUNCS(alarm accept4 setitimer getitimer bind_textdomain_codeset chown \ AC_CHECK_FUNCS(alarm accept4 setitimer getitimer bind_textdomain_codeset chown \
clock confstr ctermid dirfd execv fchmod fchown fork fpathconf ftime ftruncate \ clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \ gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \ getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \
initgroups kill killpg lchmod lchown lstat mbrtowc mkfifo mknod mktime \ initgroups kill killpg lchmod lchown lstat mbrtowc mkfifo mknod mktime \
@ -2601,6 +2601,12 @@ AC_CHECK_FUNCS(alarm accept4 setitimer getitimer bind_textdomain_codeset chown \
truncate uname unsetenv utimes waitpid wait3 wait4 \ truncate uname unsetenv utimes waitpid wait3 wait4 \
wcscoll wcsftime wcsxfrm _getpty) wcscoll wcsftime wcsxfrm _getpty)
AC_CHECK_DECL(dirfd,
AC_DEFINE(HAVE_DIRFD, 1,
Define if you have the 'dirfd' function or macro.), ,
[#include <sys/types.h>
#include <dirent.h>])
# For some functions, having a definition is not sufficient, since # For some functions, having a definition is not sufficient, since
# we want to take their address. # we want to take their address.
AC_MSG_CHECKING(for chroot) AC_MSG_CHECKING(for chroot)

View File

@ -178,7 +178,7 @@
*/ */
#undef HAVE_DIRENT_H #undef HAVE_DIRENT_H
/* Define to 1 if you have the `dirfd' function. */ /* Define if you have the 'dirfd' function or macro. */
#undef HAVE_DIRFD #undef HAVE_DIRFD
/* Define to 1 if you have the <dlfcn.h> header file. */ /* Define to 1 if you have the <dlfcn.h> header file. */