From df300d5062aa928260e50832e0788ca6da10c0be Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith" Date: Sat, 21 Jan 2012 18:20:15 -0800 Subject: [PATCH] Improve the test for dirfd(), some systems #define it rather than have an actual function. --- configure | 104 +++++++++++++++++++++++++++----------------------- configure.in | 8 +++- pyconfig.h.in | 2 +- 3 files changed, 65 insertions(+), 49 deletions(-) diff --git a/configure b/configure index b95e0a3f0f1..5f00c1ecfaf 100755 --- a/configure +++ b/configure @@ -2248,6 +2248,52 @@ $as_echo "$ac_res" >&6; } } # 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 # ---------------------------------------------------- # 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 } # 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 This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. @@ -9410,7 +9410,7 @@ $as_echo "MACHDEP_OBJS" >&6; } # checks for library functions 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 \ getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \ initgroups kill killpg lchmod lchown lstat mbrtowc mkfifo mknod mktime \ @@ -9435,6 +9435,16 @@ fi done +ac_fn_c_check_decl "$LINENO" "dirfd" "ac_cv_have_decl_dirfd" "#include + #include +" +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 # we want to take their address. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for chroot" >&5 diff --git a/configure.in b/configure.in index 71e0a8f2de3..138d562011a 100644 --- a/configure.in +++ b/configure.in @@ -2587,7 +2587,7 @@ AC_MSG_RESULT(MACHDEP_OBJS) # checks for library functions 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 \ getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \ 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 \ wcscoll wcsftime wcsxfrm _getpty) +AC_CHECK_DECL(dirfd, + AC_DEFINE(HAVE_DIRFD, 1, + Define if you have the 'dirfd' function or macro.), , + [#include + #include ]) + # For some functions, having a definition is not sufficient, since # we want to take their address. AC_MSG_CHECKING(for chroot) diff --git a/pyconfig.h.in b/pyconfig.h.in index 936098140e7..8e8f3191e75 100644 --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -178,7 +178,7 @@ */ #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 /* Define to 1 if you have the header file. */