diff options
author | joerg <joerg@pkgsrc.org> | 2007-09-21 19:51:58 +0000 |
---|---|---|
committer | joerg <joerg@pkgsrc.org> | 2007-09-21 19:51:58 +0000 |
commit | e1263c0baa18a0d81ff3a002d6db7d8b70a0b29b (patch) | |
tree | 23d736f62a625b9de3261bb79a79104fbf9d0ce2 /pkgtools | |
parent | a585706a2fb358033be66dc18e06e3bc903bac49 (diff) | |
download | pkgsrc-e1263c0baa18a0d81ff3a002d6db7d8b70a0b29b.tar.gz |
If dirfd is either a function or a macro, use it. If it doesn't exist,
but DIR contains dd_fd, define it as macro. Otherwise use -1 when
calling fts_safe_changedir in fts(3). Based on patch from Sean Boudreau.
Diffstat (limited to 'pkgtools')
-rw-r--r-- | pkgtools/libnbcompat/files/__fts13.c | 11 | ||||
-rwxr-xr-x | pkgtools/libnbcompat/files/configure | 206 | ||||
-rw-r--r-- | pkgtools/libnbcompat/files/configure.ac | 30 | ||||
-rw-r--r-- | pkgtools/libnbcompat/files/nbcompat/config.h.in | 6 | ||||
-rw-r--r-- | pkgtools/libnbcompat/files/nbcompat/dirent.h | 4 |
5 files changed, 250 insertions, 7 deletions
diff --git a/pkgtools/libnbcompat/files/__fts13.c b/pkgtools/libnbcompat/files/__fts13.c index f6f8150364c..211d60aa91a 100644 --- a/pkgtools/libnbcompat/files/__fts13.c +++ b/pkgtools/libnbcompat/files/__fts13.c @@ -1,4 +1,4 @@ -/* $NetBSD: __fts13.c,v 1.8 2007/07/31 13:17:33 joerg Exp $ */ +/* $NetBSD: __fts13.c,v 1.9 2007/09/21 19:51:58 joerg Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94"; #else -__RCSID("$NetBSD: __fts13.c,v 1.8 2007/07/31 13:17:33 joerg Exp $"); +__RCSID("$NetBSD: __fts13.c,v 1.9 2007/09/21 19:51:58 joerg Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -714,7 +714,12 @@ fts_build(sp, type) */ cderrno = 0; if (nlinks || type == BREAD) { - if (fts_safe_changedir(sp, cur, dirfd(dirp), NULL)) { +#if defined(HAVE_DIRFD) + if (fts_safe_changedir(sp, cur, dirfd(dirp), NULL)) +#else + if (fts_safe_changedir(sp, cur, -1, cur->fts_accpath)) +#endif + { if (nlinks && type == BREAD) cur->fts_errno = errno; cur->fts_flags |= FTS_DONTCHDIR; diff --git a/pkgtools/libnbcompat/files/configure b/pkgtools/libnbcompat/files/configure index 3953f5c581d..a42297ed24b 100755 --- a/pkgtools/libnbcompat/files/configure +++ b/pkgtools/libnbcompat/files/configure @@ -10998,7 +10998,213 @@ _ACEOF else : fi +{ echo "$as_me:$LINENO: checking for DIR.dd_fd" >&5 +echo $ECHO_N "checking for DIR.dd_fd... $ECHO_C" >&6; } +if test "${ac_cv_member_DIR_dd_fd+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + #include <sys/types.h> + #if HAVE_DIRENT_H + # include <dirent.h> + #else + # define dirent direct + # if HAVE_SYS_NDIR_H + # include <sys/ndir.h> + # endif + # if HAVE_SYS_DIR_H + # include <sys/dir.h> + # endif + # if HAVE_NDIR_H + # include <ndir.h> + # endif + #endif +int +main () +{ +static DIR ac_aggr; +if (ac_aggr.dd_fd) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_member_DIR_dd_fd=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + #include <sys/types.h> + #if HAVE_DIRENT_H + # include <dirent.h> + #else + # define dirent direct + # if HAVE_SYS_NDIR_H + # include <sys/ndir.h> + # endif + # if HAVE_SYS_DIR_H + # include <sys/dir.h> + # endif + # if HAVE_NDIR_H + # include <ndir.h> + # endif + #endif + +int +main () +{ +static DIR ac_aggr; +if (sizeof ac_aggr.dd_fd) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_member_DIR_dd_fd=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_member_DIR_dd_fd=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_member_DIR_dd_fd" >&5 +echo "${ECHO_T}$ac_cv_member_DIR_dd_fd" >&6; } +if test $ac_cv_member_DIR_dd_fd = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DIR_DD_FD 1 +_ACEOF + +: +else + : +fi + + +{ echo "$as_me:$LINENO: checking for dirfd" >&5 +echo $ECHO_N "checking for dirfd... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + #include <sys/types.h> + #if HAVE_DIRENT_H + # include <dirent.h> + #else + # define dirent direct + # if HAVE_SYS_NDIR_H + # include <sys/ndir.h> + # endif + # if HAVE_SYS_DIR_H + # include <sys/dir.h> + # endif + # if HAVE_NDIR_H + # include <ndir.h> + # endif + #endif + int dummy_var; + +int +main () +{ + dummy_var = dirfd((DIR *)0) + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + +cat >>confdefs.h <<\_ACEOF +#define HAVE_DIRFD 1 +_ACEOF + + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext if test $ac_cv_type_long_long = yes; then diff --git a/pkgtools/libnbcompat/files/configure.ac b/pkgtools/libnbcompat/files/configure.ac index 5e2d29bb5d4..1bfd981491e 100644 --- a/pkgtools/libnbcompat/files/configure.ac +++ b/pkgtools/libnbcompat/files/configure.ac @@ -1,4 +1,4 @@ -dnl $NetBSD: configure.ac,v 1.57 2007/07/21 13:57:33 tnn Exp $ +dnl $NetBSD: configure.ac,v 1.58 2007/09/21 19:51:58 joerg Exp $ dnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.52) @@ -308,7 +308,7 @@ AC_CHECK_MEMBERS([struct statfs.f_fsize], [:], [:], [ #include <sys/statfs.h> ]) AC_CHECK_MEMBERS([struct statfs.f_iosize], [:], [:], [ #include <sys/statfs.h> ]) -AC_CHECK_MEMBERS([struct dirent.d_namlen], [:], [:], +AC_CHECK_MEMBERS([struct dirent.d_namlen, DIR.dd_fd], [:], [:], [ #include <sys/types.h> #if HAVE_DIRENT_H # include <dirent.h> @@ -325,6 +325,32 @@ AC_CHECK_MEMBERS([struct dirent.d_namlen], [:], [:], # endif #endif ]) +AC_MSG_CHECKING([for dirfd]) +AC_TRY_LINK( + [ #include <sys/types.h> + #if HAVE_DIRENT_H + # include <dirent.h> + #else + # define dirent direct + # if HAVE_SYS_NDIR_H + # include <sys/ndir.h> + # endif + # if HAVE_SYS_DIR_H + # include <sys/dir.h> + # endif + # if HAVE_NDIR_H + # include <ndir.h> + # endif + #endif + int dummy_var; + ], [ dummy_var = dirfd((DIR *)0) ], + [ + AC_MSG_RESULT(yes) + AC_DEFINE([HAVE_DIRFD], [1], [Define if dirfd is either a function or a macro.]) + ], [ AC_MSG_RESULT(no) ] + +) + if test $ac_cv_type_long_long = yes; then dnl We assume that if sprintf() supports %lld or %qd, diff --git a/pkgtools/libnbcompat/files/nbcompat/config.h.in b/pkgtools/libnbcompat/files/nbcompat/config.h.in index 961e98f0c1a..39c51902c3e 100644 --- a/pkgtools/libnbcompat/files/nbcompat/config.h.in +++ b/pkgtools/libnbcompat/files/nbcompat/config.h.in @@ -39,6 +39,12 @@ /* Define to 1 if you have the <dirent.h> header file. */ #undef HAVE_DIRENT_H +/* Define if dirfd is either a function or a macro. */ +#undef HAVE_DIRFD + +/* Define to 1 if `dd_fd' is member of `DIR'. */ +#undef HAVE_DIR_DD_FD + /* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ #undef HAVE_DOPRNT diff --git a/pkgtools/libnbcompat/files/nbcompat/dirent.h b/pkgtools/libnbcompat/files/nbcompat/dirent.h index b23adfc60ec..c287fa56fea 100644 --- a/pkgtools/libnbcompat/files/nbcompat/dirent.h +++ b/pkgtools/libnbcompat/files/nbcompat/dirent.h @@ -1,4 +1,4 @@ -/* $NetBSD: dirent.h,v 1.1 2004/08/23 03:32:13 jlam Exp $ */ +/* $NetBSD: dirent.h,v 1.2 2007/09/21 19:51:58 joerg Exp $ */ /*- * Copyright (c) 2004 The NetBSD Foundation, Inc. @@ -58,7 +58,7 @@ * Declare functions and macros that may be missing in <dirent.h>. */ -#ifndef dirfd +#if !defined(HAVE_DIRFD) && defined(HAVE_DIR_DD_FD) #define dirfd(dirp) ((dirp)->dd_fd) #endif |