* CVS-060720 compilation failure on Mac OS X 10.4, patch (dirfd)
@ 2006-07-20 14:09 Claes Wallin
2006-07-20 23:58 ` Kevin Ryde
2006-07-25 0:52 ` Kevin Ryde
0 siblings, 2 replies; 5+ messages in thread
From: Claes Wallin @ 2006-07-20 14:09 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 526 bytes --]
When trying to compile CVS-060720 on Mac OS X 10.4, compilation fails
with conflicting defines, because configure doesn't recognize the dirfd
macro, it merely looks for a function in the library.
Using gnulib dirfd, the problem disappears.
This patch is tested on Mac OS X 10.4 and Solaris 10. The Solaris 10
patch I submitted earlier today is also needed, since Mac OS X has the
same problems with Linux-specific pthread_*_np functions.
Both platforms now compile (with -O2) and pass all tests except
regexp.tests.
/c
[-- Attachment #2: guile-core-dirfd.ChangeLog --]
[-- Type: text/plain, Size: 829 bytes --]
2006-07-20 Claes Wallin <clacke+guile@lysator.liu.se>
On Mac OS X 10.4 dirfd is a macro, not a function. This confuces AC_CHECK_FUNCS.
Use gl_Func_DIRFD from gnulib instead, which does a more thorough check.
* configure.in:
Replace AC_CHECK_FUNCS([dirfd]) with gl_FUNC_DIRFD.
* guile-config/dirfd.m4:
* libguile/dirfd.c:
* libguile/dirfd.h:
Imports from gnulib providing gl_FUNC_DIRFD and associated code.
* libguile/filesys.c:
Replace '#define dirfd ...' with '#include "dirfd.h"'
* test-suite/tests/dirfd.test:
Since dirfd is used by readdir on platforms that have it, this test
does an opendir and two consecutive readdirs, expecting "." and "..".
Not sure if this works on non-posix platforms.
[-- Attachment #3: guile-core-dirfd.diff --]
[-- Type: text/plain, Size: 7123 bytes --]
=== 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 <sys/types.h>
+ #include <dirent.h>])
+
+ AC_CACHE_CHECK([whether dirfd is a macro],
+ gl_cv_func_dirfd_macro,
+ [AC_EGREP_CPP([dirent_header_defines_dirfd], [
+#include <sys/types.h>
+#include <dirent.h>
+#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 <sys/types.h>
+ #include <dirent.h>],
+ [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 <config.h>
+#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 <sys/types.h>
+
+#include <dirent.h>
+
+#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 <clacke+guile@lysator.liu.se>
+;;;;
+;;;; 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"
\f
[-- Attachment #4: Type: text/plain, Size: 137 bytes --]
_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-guile
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: CVS-060720 compilation failure on Mac OS X 10.4, patch (dirfd)
2006-07-20 14:09 CVS-060720 compilation failure on Mac OS X 10.4, patch (dirfd) Claes Wallin
@ 2006-07-20 23:58 ` Kevin Ryde
2006-07-21 6:36 ` Claes Wallin
2006-07-21 7:36 ` Claes Wallin
2006-07-25 0:52 ` Kevin Ryde
1 sibling, 2 replies; 5+ messages in thread
From: Kevin Ryde @ 2006-07-20 23:58 UTC (permalink / raw)
Cc: bug-guile
Claes Wallin <clawa570+gmane@student.liu.se> writes:
>
> On Mac OS X 10.4 dirfd is a macro, not a function.
Thanks. Is that true on solaris too? I'm guessing it is.
> Replace AC_CHECK_FUNCS([dirfd]) with gl_FUNC_DIRFD.
I think I'll make the test "#ifndef dirfd" instead.
Is gl_FUNC_DIRFD an actual documented function?
_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-guile
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: CVS-060720 compilation failure on Mac OS X 10.4, patch (dirfd)
2006-07-20 23:58 ` Kevin Ryde
@ 2006-07-21 6:36 ` Claes Wallin
2006-07-21 7:36 ` Claes Wallin
1 sibling, 0 replies; 5+ messages in thread
From: Claes Wallin @ 2006-07-21 6:36 UTC (permalink / raw)
[-- Attachment #1.1: Type: text/plain, Size: 605 bytes --]
Kevin Ryde wrote:
> Claes Wallin <clawa570+gmane@student.liu.se> writes:
>> On Mac OS X 10.4 dirfd is a macro, not a function.
>
> Thanks. Is that true on solaris too? I'm guessing it is.
No, it's undefined. That's why the kludge in filesys.c exists.
>> Replace AC_CHECK_FUNCS([dirfd]) with gl_FUNC_DIRFD.
>
> I think I'll make the test "#ifndef dirfd" instead.
> Is gl_FUNC_DIRFD an actual documented function?
It's a part of gnulib, defined in dirfd.m4, which I included. A more
generic kludge than ours, because it works on both Mac OS X and Solaris.
/c
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 249 bytes --]
[-- Attachment #2: Type: text/plain, Size: 137 bytes --]
_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-guile
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: CVS-060720 compilation failure on Mac OS X 10.4, patch (dirfd)
2006-07-20 23:58 ` Kevin Ryde
2006-07-21 6:36 ` Claes Wallin
@ 2006-07-21 7:36 ` Claes Wallin
1 sibling, 0 replies; 5+ messages in thread
From: Claes Wallin @ 2006-07-21 7:36 UTC (permalink / raw)
[-- Attachment #1.1: Type: text/plain, Size: 225 bytes --]
Kevin Ryde wrote:
>> Replace AC_CHECK_FUNCS([dirfd]) with gl_FUNC_DIRFD.
>
> I think I'll make the test "#ifndef dirfd" instead.
You are, of course, right. An #ifndef in there will do a good job.
/c
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 249 bytes --]
[-- Attachment #2: Type: text/plain, Size: 137 bytes --]
_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-guile
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: CVS-060720 compilation failure on Mac OS X 10.4, patch (dirfd)
2006-07-20 14:09 CVS-060720 compilation failure on Mac OS X 10.4, patch (dirfd) Claes Wallin
2006-07-20 23:58 ` Kevin Ryde
@ 2006-07-25 0:52 ` Kevin Ryde
1 sibling, 0 replies; 5+ messages in thread
From: Kevin Ryde @ 2006-07-25 0:52 UTC (permalink / raw)
Cc: bug-guile
Claes Wallin <clawa570+gmane@student.liu.se> writes:
>
> * test-suite/tests/dirfd.test:
> Since dirfd is used by readdir on platforms that have it, this test
> does an opendir and two consecutive readdirs, expecting "." and "..".
> Not sure if this works on non-posix platforms.
Yep, not sure about "." and "..", though I remember most unixy stuff
on DOS systems synthesising them in the bad old days. There's an
existing test in filesys.test when expects the root directory "/" to
be non-empty; it at least exercises the opendir/readdir/closedir
sequence.
Perhaps a test that created a long-named temporary file (in the
builddir) would be an idea. But might have to communicate the
NAME_MAX (or equivalent) size to the scheme level to do that
effectively.
_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-guile
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-07-25 0:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-20 14:09 CVS-060720 compilation failure on Mac OS X 10.4, patch (dirfd) Claes Wallin
2006-07-20 23:58 ` Kevin Ryde
2006-07-21 6:36 ` Claes Wallin
2006-07-21 7:36 ` Claes Wallin
2006-07-25 0:52 ` Kevin Ryde
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).