Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1577cf7

Browse files
committed
Improve the test for dirfd(). Some systems #define it rather than
have it as a library function.
2 parents d45382d + df300d5 commit 1577cf7

3 files changed

Lines changed: 65 additions & 49 deletions

File tree

configure

Lines changed: 57 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2242,6 +2242,52 @@ $as_echo "$ac_res" >&6; }
22422242

22432243
} # ac_fn_c_check_func
22442244

2245+
# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
2246+
# ---------------------------------------------
2247+
# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
2248+
# accordingly.
2249+
ac_fn_c_check_decl ()
2250+
{
2251+
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
2252+
as_decl_name=`echo $2|sed 's/ *(.*//'`
2253+
as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
2254+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
2255+
$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
2256+
if eval \${$3+:} false; then :
2257+
$as_echo_n "(cached) " >&6
2258+
else
2259+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
2260+
/* end confdefs.h. */
2261+
$4
2262+
int
2263+
main ()
2264+
{
2265+
#ifndef $as_decl_name
2266+
#ifdef __cplusplus
2267+
(void) $as_decl_use;
2268+
#else
2269+
(void) $as_decl_name;
2270+
#endif
2271+
#endif
2272+
2273+
;
2274+
return 0;
2275+
}
2276+
_ACEOF
2277+
if ac_fn_c_try_compile "$LINENO"; then :
2278+
eval "$3=yes"
2279+
else
2280+
eval "$3=no"
2281+
fi
2282+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
2283+
fi
2284+
eval ac_res=\$$3
2285+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
2286+
$as_echo "$ac_res" >&6; }
2287+
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
2288+
2289+
} # ac_fn_c_check_decl
2290+
22452291
# ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES
22462292
# ----------------------------------------------------
22472293
# Tries to find if the field MEMBER exists in type AGGR, after including
@@ -2298,52 +2344,6 @@ $as_echo "$ac_res" >&6; }
22982344
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
22992345

23002346
} # ac_fn_c_check_member
2301-
2302-
# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
2303-
# ---------------------------------------------
2304-
# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
2305-
# accordingly.
2306-
ac_fn_c_check_decl ()
2307-
{
2308-
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
2309-
as_decl_name=`echo $2|sed 's/ *(.*//'`
2310-
as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
2311-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
2312-
$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
2313-
if eval \${$3+:} false; then :
2314-
$as_echo_n "(cached) " >&6
2315-
else
2316-
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
2317-
/* end confdefs.h. */
2318-
$4
2319-
int
2320-
main ()
2321-
{
2322-
#ifndef $as_decl_name
2323-
#ifdef __cplusplus
2324-
(void) $as_decl_use;
2325-
#else
2326-
(void) $as_decl_name;
2327-
#endif
2328-
#endif
2329-
2330-
;
2331-
return 0;
2332-
}
2333-
_ACEOF
2334-
if ac_fn_c_try_compile "$LINENO"; then :
2335-
eval "$3=yes"
2336-
else
2337-
eval "$3=no"
2338-
fi
2339-
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
2340-
fi
2341-
eval ac_res=\$$3
2342-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
2343-
$as_echo "$ac_res" >&6; }
2344-
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
2345-
2346-
} # ac_fn_c_check_decl
23472347
cat >config.log <<_ACEOF
23482348
This file contains any messages produced by compilers while
23492349
running configure, to aid debugging if configure makes a mistake.
@@ -9396,7 +9396,7 @@ $as_echo "MACHDEP_OBJS" >&6; }
93969396

93979397
# checks for library functions
93989398
for ac_func in alarm accept4 setitimer getitimer bind_textdomain_codeset chown \
9399-
clock confstr ctermid dirfd execv faccessat fchmod fchmodat fchown fchownat \
9399+
clock confstr ctermid execv faccessat fchmod fchmodat fchown fchownat \
94009400
fexecve fdopendir fork fpathconf fstatat ftime ftruncate futimesat \
94019401
futimens futimes gai_strerror \
94029402
getgrouplist getgroups getlogin getloadavg getpeername getpgid getpid \
@@ -9429,6 +9429,16 @@ fi
94299429
done
94309430

94319431

9432+
ac_fn_c_check_decl "$LINENO" "dirfd" "ac_cv_have_decl_dirfd" "#include <sys/types.h>
9433+
#include <dirent.h>
9434+
"
9435+
if test "x$ac_cv_have_decl_dirfd" = xyes; then :
9436+
9437+
$as_echo "#define HAVE_DIRFD 1" >>confdefs.h
9438+
9439+
fi
9440+
9441+
94329442
# For some functions, having a definition is not sufficient, since
94339443
# we want to take their address.
94349444
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for chroot" >&5

configure.in

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2562,7 +2562,7 @@ AC_MSG_RESULT(MACHDEP_OBJS)
25622562

25632563
# checks for library functions
25642564
AC_CHECK_FUNCS(alarm accept4 setitimer getitimer bind_textdomain_codeset chown \
2565-
clock confstr ctermid dirfd execv faccessat fchmod fchmodat fchown fchownat \
2565+
clock confstr ctermid execv faccessat fchmod fchmodat fchown fchownat \
25662566
fexecve fdopendir fork fpathconf fstatat ftime ftruncate futimesat \
25672567
futimens futimes gai_strerror \
25682568
getgrouplist getgroups getlogin getloadavg getpeername getpgid getpid \
@@ -2584,6 +2584,12 @@ AC_CHECK_FUNCS(alarm accept4 setitimer getitimer bind_textdomain_codeset chown \
25842584
truncate uname unlinkat unsetenv utimensat utimes waitid waitpid wait3 wait4 \
25852585
wcscoll wcsftime wcsxfrm writev _getpty)
25862586

2587+
AC_CHECK_DECL(dirfd,
2588+
AC_DEFINE(HAVE_DIRFD, 1,
2589+
Define if you have the 'dirfd' function or macro.), ,
2590+
[#include <sys/types.h>
2591+
#include <dirent.h>])
2592+
25872593
# For some functions, having a definition is not sufficient, since
25882594
# we want to take their address.
25892595
AC_MSG_CHECKING(for chroot)

pyconfig.h.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@
181181
*/
182182
#undef HAVE_DIRENT_H
183183

184-
/* Define to 1 if you have the `dirfd' function. */
184+
/* Define if you have the 'dirfd' function or macro. */
185185
#undef HAVE_DIRFD
186186

187187
/* Define to 1 if you have the <dlfcn.h> header file. */

0 commit comments

Comments
 (0)