* patch to build guile CVS on Mac OS X
@ 2004-01-06 10:17 Richard Todd
2004-01-06 21:53 ` Kevin Ryde
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Richard Todd @ 2004-01-06 10:17 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 1268 bytes --]
Hi all,
These changes made guile CVS build for me on Mac OS X. Non-scientific
testing (ran some of my programs) seems to show that it's working.
I'd appreciate it if this, or something like it, could get applied.
BTW, on 12/30 I submitted a patch to bug-guile for a problem with
ice-9/q.scm and haven't gotten an ACK from anyone about it. Should I
re-submit after a while, or ...?
Summary of changes:
1) Mac OS X has a funny quirk about getting to the
environment from shared libs. Patches exactly like what I'm
submitting were applied to many other programs (like python and tcl)
for this exact issue. posix.c and stime.c were hit.
2) The SCM_MUTEX_MAX_SIZE was too small. I also added to the error
message in threads-plugin.c, so that it tells you what the size should
be. This was faster than getting to that point in a debugger! It may
be that you'd want to just raise the size for all platforms, but I
took the conservative approach and just raised it for __APPLE__.
3) numbers.c defined s_bignum but did not use it, and guile compiles
such that this was an error. Maybe it'd be right to just get rid of
it...but to get this to work I just #ifdef'ed it out for __APPLE__
Richard Todd
richardt at vzavenue dot net
[-- Attachment #2: mac_osx.patch --]
[-- Type: text/plain, Size: 3827 bytes --]
Index: libguile/numbers.c
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/libguile/numbers.c,v
retrieving revision 1.220
diff -u -r1.220 numbers.c
--- libguile/numbers.c 3 Jan 2004 21:38:38 -0000 1.220
+++ libguile/numbers.c 6 Jan 2004 09:49:32 -0000
@@ -153,7 +153,9 @@
\f
+#ifndef __APPLE__
static const char s_bignum[] = "bignum";
+#endif
SCM_C_INLINE_KEYWORD SCM
scm_i_mkbig ()
Index: libguile/posix.c
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/libguile/posix.c,v
retrieving revision 1.120
diff -u -r1.120 posix.c
--- libguile/posix.c 15 Sep 2003 12:36:57 -0000 1.120
+++ libguile/posix.c 6 Jan 2004 09:49:34 -0000
@@ -97,7 +97,12 @@
#include <signal.h>
+#if defined(__APPLE__) && defined(__DYNAMIC__)
+#include<crt_externs.h>
+static char ** environ;
+#else
extern char ** environ;
+#endif
#ifdef HAVE_GRP_H
#include <grp.h>
@@ -1735,6 +1740,10 @@
void
scm_init_posix ()
{
+#if defined(__APPLE__) && defined(__DYNAMIC__)
+ environ = *_NSGetEnviron();
+#endif
+
scm_add_feature ("posix");
#ifdef HAVE_GETEUID
scm_add_feature ("EIDs");
Index: libguile/stime.c
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/libguile/stime.c,v
retrieving revision 1.82
diff -u -r1.82 stime.c
--- libguile/stime.c 3 Jan 2004 22:25:24 -0000 1.82
+++ libguile/stime.c 6 Jan 2004 09:49:34 -0000
@@ -260,7 +260,12 @@
}
static char tzvar[3] = "TZ";
+#if defined(__APPLE__) && defined(__DYNAMIC__)
+#include<crt_externs.h>
+static char ** environ;
+#else
extern char ** environ;
+#endif
/* if zone is set, create a temporary environment with only a TZ
string. other threads or interrupt handlers shouldn't be allowed
@@ -671,6 +676,10 @@
void
scm_init_stime()
{
+#if defined(__APPLE__) && defined(__DYNAMIC__)
+ environ = *_NSGetEnviron();
+#endif
+
scm_c_define ("internal-time-units-per-second",
scm_long2num((long) SCM_TIME_UNITS_PER_SECOND));
Index: libguile/threads-plugin.c
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/libguile/threads-plugin.c,v
retrieving revision 1.4
diff -u -r1.4 threads-plugin.c
--- libguile/threads-plugin.c 5 Apr 2003 19:10:22 -0000 1.4
+++ libguile/threads-plugin.c 6 Jan 2004 09:49:35 -0000
@@ -181,6 +181,16 @@
|| scm_i_plugin_rec_mutex_size > SCM_REC_MUTEX_MAXSIZE)
{
fprintf (stderr, "Internal error: Need to upgrade mutex size\n");
+ fprintf (stderr,
+ "Mutex Size: %d\tCurrent Max: %ld\n",
+ scm_i_plugin_mutex_size,
+ SCM_MUTEX_MAXSIZE);
+ fprintf (stderr,
+ "Recursive Mutex Size: %d\tCurrent Max: %ld\n",
+ scm_i_plugin_rec_mutex_size,
+ SCM_REC_MUTEX_MAXSIZE);
+
+
abort ();
}
}
Index: libguile/threads-plugin.h
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/libguile/threads-plugin.h,v
retrieving revision 1.3
diff -u -r1.3 threads-plugin.h
--- libguile/threads-plugin.h 5 Apr 2003 19:10:22 -0000 1.3
+++ libguile/threads-plugin.h 6 Jan 2004 09:49:35 -0000
@@ -24,7 +24,11 @@
#include <pthread.h> /* This file should *not* need to include pthread.h */
/* Size is checked in scm_init_threads_plugin */
+#ifdef __APPLE__
+#define SCM_MUTEX_MAXSIZE (12 * sizeof (long))
+#else
#define SCM_MUTEX_MAXSIZE (9 * sizeof (long))
+#endif
typedef struct { char _[SCM_MUTEX_MAXSIZE]; } scm_t_mutex;
/*fixme* Should be defined similarly to scm_t_mutex. */
[-- Attachment #3: Type: text/plain, Size: 136 bytes --]
_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-guile
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: patch to build guile CVS on Mac OS X
2004-01-06 10:17 patch to build guile CVS on Mac OS X Richard Todd
@ 2004-01-06 21:53 ` Kevin Ryde
2004-01-06 22:00 ` Kevin Ryde
2004-01-06 23:02 ` Kevin Ryde
2 siblings, 0 replies; 10+ messages in thread
From: Kevin Ryde @ 2004-01-06 21:53 UTC (permalink / raw)
Cc: bug-guile
Richard Todd <richardt@vzavenue.net> writes:
>
> 3) numbers.c defined s_bignum but did not use it,
Thanks, I removed it. (Not used now bignums are done with gmp.)
> and guile compiles
> such that this was an error. Maybe it'd be right to just get rid of
> it...but to get this to work I just #ifdef'ed it out for __APPLE__
I'm pretty sure it can just be removed.
--
All followups to bug-guile@gnu.org please.
_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-guile
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: patch to build guile CVS on Mac OS X
2004-01-06 10:17 patch to build guile CVS on Mac OS X Richard Todd
2004-01-06 21:53 ` Kevin Ryde
@ 2004-01-06 22:00 ` Kevin Ryde
2004-01-06 23:16 ` Richard Todd
2004-01-06 23:02 ` Kevin Ryde
2 siblings, 1 reply; 10+ messages in thread
From: Kevin Ryde @ 2004-01-06 22:00 UTC (permalink / raw)
Cc: bug-guile
Richard Todd <richardt@vzavenue.net> writes:
>
> +#if defined(__APPLE__) && defined(__DYNAMIC__)
> +#include<crt_externs.h>
> +static char ** environ;
> +#else
> extern char ** environ;
> +#endif
>
> #ifdef HAVE_GRP_H
> #include <grp.h>
> @@ -1735,6 +1740,10 @@
> void
> scm_init_posix ()
> {
> +#if defined(__APPLE__) && defined(__DYNAMIC__)
> + environ = *_NSGetEnviron();
> +#endif
> +
That's really weird. I'd rather not do that if it can be avoided.
Surely they can't expect every library that accesses environ to get a
system-specific change?
Does it work to take the declaration of environ from <stdlib.h>
instead of giving an explicit "extern"? The autoconf way is normally
to let the headers do the job where possible.
_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-guile
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: patch to build guile CVS on Mac OS X
2004-01-06 22:00 ` Kevin Ryde
@ 2004-01-06 23:16 ` Richard Todd
2004-01-06 23:30 ` Kevin Ryde
0 siblings, 1 reply; 10+ messages in thread
From: Richard Todd @ 2004-01-06 23:16 UTC (permalink / raw)
Cc: bug-guile
[-- Attachment #1.1: Type: text/plain, Size: 2852 bytes --]
On Wed, Jan 07, 2004 at 08:00:28AM +1000, Kevin Ryde wrote:
> Richard Todd <richardt@vzavenue.net> writes:
> >
> > +#if defined(__APPLE__) && defined(__DYNAMIC__)
> > +#include<crt_externs.h>
> > +static char ** environ;
> > +#else
> > extern char ** environ;
> > +#endif
> >
> > #ifdef HAVE_GRP_H
> > #include <grp.h>
> > @@ -1735,6 +1740,10 @@
> > void
> > scm_init_posix ()
> > {
> > +#if defined(__APPLE__) && defined(__DYNAMIC__)
> > + environ = *_NSGetEnviron();
> > +#endif
> > +
>
> That's really weird. I'd rather not do that if it can be avoided.
Yeah, that's why I pointed out in my mail that I've seen (via google)
that lots of patches along these lines have been made. I didn't want
anyone to assume I was nuts!
As far as I can tell, it's part of their OS (with heritage going back
to NeXT), that the environment is not directly accessible to loaded
libraries (they're stored off in the crt0 bootstrap code and
inaccessible). The crt_externs.h header is there for the express
purpose of closing this hole.
The comment in the apple header is:
/*
** Prototypes for the functions to get environment information in
** the world of dynamic libraries. Lifted from .c file of same name.
** Fri Jun 23 12:56:47 PDT 1995
** AOF (afreier@next.com)
*/
> Surely they can't expect every library that accesses environ to get a
> system-specific change?
I found posts for python and tcl with similar patches. The (somewhat
buggy) FINK project guile patches also have a call to _NSGetEnviron()
in them.
Change to ruby:
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/537
Here's a KDE project that tried to be cleaner by defining:
#define environ (*_NSGetEnviron())
http://cvs.sourceforge.net/viewcvs.py/kcvdphoto/kimg2mpg/aclocal.m4?rev=1.4
(still have to #ifdef out the extern declaration, though...)
And another example of that approach here:
http://www.pycs.net/bob/weblog/2004/01/02.html
You may prefer the #define approach...I avoided it because I thought
the init_xxx() stuff in guile was a clean enough place for it, and
though I'm sure it's not an issue it would technically be more
efficient not to do the function call on each access.
> Does it work to take the declaration of environ from <stdlib.h>
> instead of giving an explicit "extern"? The autoconf way is normally
> to let the headers do the job where possible.
On this machine, there is no declaration of environ that is pulled in from
stdlib.h:
test.c:
--------------------
#include<stdlib.h>
--------------------
$ gcc -E test.c | grep -i env
char *getenv(const char *);
int putenv(const char *);
int setenv(const char *, const char *, int);
void unsetenv(const char *);
..and I browsed the files by hand in case it was a #define. No luck.
Richard Todd
[-- Attachment #1.2: Type: application/pgp-signature, Size: 186 bytes --]
[-- Attachment #2: Type: text/plain, Size: 136 bytes --]
_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-guile
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: patch to build guile CVS on Mac OS X
2004-01-06 23:16 ` Richard Todd
@ 2004-01-06 23:30 ` Kevin Ryde
2004-01-07 0:06 ` Richard Todd
0 siblings, 1 reply; 10+ messages in thread
From: Kevin Ryde @ 2004-01-06 23:30 UTC (permalink / raw)
Cc: bug-guile
Richard Todd <richardt@vzavenue.net> writes:
>
> Here's a KDE project that tried to be cleaner by defining:
> #define environ (*_NSGetEnviron())
> http://cvs.sourceforge.net/viewcvs.py/kcvdphoto/kimg2mpg/aclocal.m4?rev=1.4
> (still have to #ifdef out the extern declaration, though...)
That sounds cleanest.
Does apple hide some advice on this somewhere in the man pages? (To
put a reference to.)
> You may prefer the #define approach...I avoided it because I thought
> the init_xxx() stuff in guile was a clean enough place for it, and
> though I'm sure it's not an issue it would technically be more
> efficient not to do the function call on each access.
Yep. But I'm guessing you need to hold the return from _NSGetEnviron,
ie. the address of the environ variable, not its contents a given
time.
_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-guile
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: patch to build guile CVS on Mac OS X
2004-01-06 23:30 ` Kevin Ryde
@ 2004-01-07 0:06 ` Richard Todd
2004-01-07 0:37 ` Kevin Ryde
0 siblings, 1 reply; 10+ messages in thread
From: Richard Todd @ 2004-01-07 0:06 UTC (permalink / raw)
Cc: bug-guile
[-- Attachment #1.1: Type: text/plain, Size: 673 bytes --]
On Wed, Jan 07, 2004 at 09:30:41AM +1000, Kevin Ryde wrote:
> Richard Todd <richardt@vzavenue.net> writes:
> >
> > Here's a KDE project that tried to be cleaner by defining:
> > #define environ (*_NSGetEnviron())
> > http://cvs.sourceforge.net/viewcvs.py/kcvdphoto/kimg2mpg/aclocal.m4?rev=1.4
> > (still have to #ifdef out the extern declaration, though...)
>
> That sounds cleanest.
>
> Does apple hide some advice on this somewhere in the man pages? (To
> put a reference to.)
Not that I can find.
Would you like another patch for the environ stuff, or would you
rather commit something with the information you have and let me test it?
Richard
[-- Attachment #1.2: Type: application/pgp-signature, Size: 186 bytes --]
[-- Attachment #2: Type: text/plain, Size: 136 bytes --]
_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-guile
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: patch to build guile CVS on Mac OS X
2004-01-07 0:06 ` Richard Todd
@ 2004-01-07 0:37 ` Kevin Ryde
0 siblings, 0 replies; 10+ messages in thread
From: Kevin Ryde @ 2004-01-07 0:37 UTC (permalink / raw)
Cc: bug-guile
Richard Todd <richardt@vzavenue.net> writes:
>
> Would you like another patch for the environ stuff, or would you
> rather commit something with the information you have and let me test it?
If you have copyright papers on file we can accept a patch, otherwise
I'll look into it at some stage.
I'm thinking of just the #define, for simplicity. Though establishing
some sort of scm_i_environ_location in init.c, and using it only under
#ifdef PIC, would be optimal.
_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-guile
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: patch to build guile CVS on Mac OS X
2004-01-06 10:17 patch to build guile CVS on Mac OS X Richard Todd
2004-01-06 21:53 ` Kevin Ryde
2004-01-06 22:00 ` Kevin Ryde
@ 2004-01-06 23:02 ` Kevin Ryde
2004-01-06 23:30 ` Richard Todd
2 siblings, 1 reply; 10+ messages in thread
From: Kevin Ryde @ 2004-01-06 23:02 UTC (permalink / raw)
Cc: bug-guile
Richard Todd <richardt@vzavenue.net> writes:
>
> +#ifdef __APPLE__
> +#define SCM_MUTEX_MAXSIZE (12 * sizeof (long))
Hmm, I guess if that's what it takes.
For reference, how many bytes is the underlying actual mutex?
> +#else
> #define SCM_MUTEX_MAXSIZE (9 * sizeof (long))
> +#endif
No, I think it should be increased for all systems. I think it'll be
too hard to keep the conditionals right going forward otherwise. (The
same size needs to be maintained for binary compatibility.)
PS. Matters like this relating only to the development code can be
raised on the guile-devel list.
_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-guile
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: patch to build guile CVS on Mac OS X
2004-01-06 23:02 ` Kevin Ryde
@ 2004-01-06 23:30 ` Richard Todd
2004-01-06 23:44 ` Kevin Ryde
0 siblings, 1 reply; 10+ messages in thread
From: Richard Todd @ 2004-01-06 23:30 UTC (permalink / raw)
Cc: bug-guile
[-- Attachment #1.1: Type: text/plain, Size: 1026 bytes --]
On Wed, Jan 07, 2004 at 09:02:19AM +1000, Kevin Ryde wrote:
> Richard Todd <richardt@vzavenue.net> writes:
> >
> > +#ifdef __APPLE__
> > +#define SCM_MUTEX_MAXSIZE (12 * sizeof (long))
>
> Hmm, I guess if that's what it takes.
>
> For reference, how many bytes is the underlying actual mutex?
Both normal and recursive mutexes are showing up as 44 bytes. Either
it was the late night, or caution, but I upped it to 48 bytes. I guess
I could have gotten by on 11*sizeof(long).
> No, I think it should be increased for all systems. I think it'll be
> too hard to keep the conditionals right going forward otherwise. (The
> same size needs to be maintained for binary compatibility.)
I thought you might prefer that, but I was trying to make the smallest changes
to other architectures as possible, and let you make that call.
Thanks for looking these over.
> PS. Matters like this relating only to the development code can be
> raised on the guile-devel list.
Got it, thanks.
Richard
[-- Attachment #1.2: Type: application/pgp-signature, Size: 186 bytes --]
[-- Attachment #2: Type: text/plain, Size: 136 bytes --]
_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-guile
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: patch to build guile CVS on Mac OS X
2004-01-06 23:30 ` Richard Todd
@ 2004-01-06 23:44 ` Kevin Ryde
0 siblings, 0 replies; 10+ messages in thread
From: Kevin Ryde @ 2004-01-06 23:44 UTC (permalink / raw)
Cc: bug-guile
Richard Todd <richardt@vzavenue.net> writes:
>
> Both normal and recursive mutexes are showing up as 44 bytes.
Thanks, I increased it.
> I thought you might prefer that, but I was trying to make the smallest changes
> to other architectures as possible, and let you make that call.
Yes, ... and no :-).
Conditionals like __APPLE__ are usually bad, since people end up
unable to remember exactly why it was like that, and apple might make
a new system, or make their existing system normal, or whatever.
_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-guile
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2004-01-07 0:37 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-06 10:17 patch to build guile CVS on Mac OS X Richard Todd
2004-01-06 21:53 ` Kevin Ryde
2004-01-06 22:00 ` Kevin Ryde
2004-01-06 23:16 ` Richard Todd
2004-01-06 23:30 ` Kevin Ryde
2004-01-07 0:06 ` Richard Todd
2004-01-07 0:37 ` Kevin Ryde
2004-01-06 23:02 ` Kevin Ryde
2004-01-06 23:30 ` Richard Todd
2004-01-06 23:44 ` 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).