=== added file 'guile-config/dirfd.m4' --- guile-config/dirfd.m4 1970-01-01 00:00:00 +0000 +++ guile-config/dirfd.m4 2006-07-20 04:16:34 +0000 @@ -0,0 +1,76 @@ +#serial 13 -*- Autoconf -*- + +dnl Find out how to get the file descriptor associated with an open DIR*. + +# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software +# Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +dnl From Jim Meyering + +AC_DEFUN([gl_FUNC_DIRFD], +[ + AC_LIBSOURCES([dirfd.c, dirfd.h]) + + dnl Work around a bug of AC_EGREP_CPP in autoconf-2.57. + AC_REQUIRE([AC_PROG_CPP]) + AC_REQUIRE([AC_PROG_EGREP]) + AC_CHECK_FUNCS(dirfd) + AC_CHECK_DECLS([dirfd], , , + [#include + #include ]) + + AC_CACHE_CHECK([whether dirfd is a macro], + gl_cv_func_dirfd_macro, + [AC_EGREP_CPP([dirent_header_defines_dirfd], [ +#include +#include +#ifdef dirfd + dirent_header_defines_dirfd +#endif], + gl_cv_func_dirfd_macro=yes, + gl_cv_func_dirfd_macro=no)]) + + # Use the replacement only if we have no function, macro, + # or declaration with that name. + if test $ac_cv_func_dirfd,$ac_cv_have_decl_dirfd,$gl_cv_func_dirfd_macro \ + = no,no,no; then + AC_REPLACE_FUNCS([dirfd]) + AC_CACHE_CHECK( + [how to get the file descriptor associated with an open DIR*], + gl_cv_sys_dir_fd_member_name, + [ + dirfd_save_CFLAGS=$CFLAGS + for ac_expr in d_fd dd_fd; do + + CFLAGS="$CFLAGS -DDIR_FD_MEMBER_NAME=$ac_expr" + AC_TRY_COMPILE( + [#include + #include ], + [DIR *dir_p = opendir("."); (void) dir_p->DIR_FD_MEMBER_NAME;], + dir_fd_found=yes + ) + CFLAGS=$dirfd_save_CFLAGS + test "$dir_fd_found" = yes && break + done + test "$dir_fd_found" = yes || ac_expr=no_such_member + + gl_cv_sys_dir_fd_member_name=$ac_expr + ] + ) + if test $gl_cv_sys_dir_fd_member_name != no_such_member; then + AC_DEFINE_UNQUOTED(DIR_FD_MEMBER_NAME, + $gl_cv_sys_dir_fd_member_name, + [the name of the file descriptor member of DIR]) + fi + AH_VERBATIM(DIR_TO_FD, + [#ifdef DIR_FD_MEMBER_NAME +# define DIR_TO_FD(Dir_p) ((Dir_p)->DIR_FD_MEMBER_NAME) +#else +# define DIR_TO_FD(Dir_p) -1 +#endif +]) + fi +]) === added file 'libguile/dirfd.c' --- libguile/dirfd.c 1970-01-01 00:00:00 +0000 +++ libguile/dirfd.c 2006-07-20 04:19:05 +0000 @@ -0,0 +1,30 @@ +/* dirfd.c -- return the file descriptor associated with an open DIR* + Copyright (C) 2001 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* Written by Jim Meyering. */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "dirfd.h" + +int +dirfd (DIR const *dir_p) +{ + return DIR_TO_FD (dir_p); +} === added file 'libguile/dirfd.h' --- libguile/dirfd.h 1970-01-01 00:00:00 +0000 +++ libguile/dirfd.h 2006-07-20 04:16:34 +0000 @@ -0,0 +1,29 @@ +/* Declare dirfd, if necessary. + Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + Written by Jim Meyering. */ + +#include + +#include + +#ifndef HAVE_DECL_DIRFD +"this configure-time declaration test was not run" +#endif +#if !HAVE_DECL_DIRFD && !defined dirfd +int dirfd (DIR const *); +#endif === added file 'test-suite/tests/dirfd.test' --- test-suite/tests/dirfd.test 1970-01-01 00:00:00 +0000 +++ test-suite/tests/dirfd.test 2006-07-20 05:22:11 +0000 @@ -0,0 +1,29 @@ +;;;; dirfd.test --- test suite for Guile's dir functions -*- scheme -*- +;;;; Claes Wallin +;;;; +;;;; Copyright (C) 2000, 2006 Free Software Foundation, Inc. +;;;; +;;;; This program is free software; you can redistribute it and/or modify +;;;; it under the terms of the GNU General Public License as published by +;;;; the Free Software Foundation; either version 2, or (at your option) +;;;; any later version. +;;;; +;;;; This program is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;;; GNU General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU General Public License +;;;; along with this software; see the file COPYING. If not, write to +;;;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;;;; Boston, MA 02110-1301 USA + +(use-modules (test-suite lib)) + +(with-test-prefix "basic dir handling" + + (with-test-prefix "readdir" + + (let ((d (opendir "."))) + (pass-if (equal? "." (readdir d))) + (pass-if (equal? ".." (readdir d)))))) === modified file 'configure.in' --- configure.in 2006-07-20 01:41:06 +0000 +++ configure.in 2006-07-20 04:16:34 +0000 @@ -879,7 +879,8 @@ # dirfd - mainly BSD derived, not in older systems # sincos - GLIBC extension # -AC_CHECK_FUNCS(asinh acosh atanh copysign dirfd finite sincos trunc) +AC_CHECK_FUNCS(asinh acosh atanh copysign finite sincos trunc) +gl_FUNC_DIRFD # C99 specifies isinf and isnan as macros. # HP-UX provides only macros, no functions. === modified file 'libguile/filesys.c' --- libguile/filesys.c 2006-07-20 03:01:09 +0000 +++ libguile/filesys.c 2006-07-20 04:16:34 +0000 @@ -204,11 +204,8 @@ # define fchmod(fd, mode) (-1) #endif /* __MINGW32__ */ -/* This definition is for Solaris 10, it's probably not right elsewhere, but - that's ok, it shouldn't be used elsewhere. */ -#if ! HAVE_DIRFD -#define dirfd(dirstream) (dirstream->dd_fd) -#endif +/* When all else fails, get dirfd from gnulib */ +#include "dirfd.h"