bug-guile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: patch to build guile CVS on Mac OS X


From: Richard Todd
Subject: Re: patch to build guile CVS on Mac OS X
Date: Tue, 6 Jan 2004 17:16:45 -0600
User-agent: Mutt/1.4i

On Wed, Jan 07, 2004 at 08:00:28AM +1000, Kevin Ryde wrote:
> Richard Todd <address@hidden> 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 (address@hidden)
*/

> 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: pgplCx_PuE5DC.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]