From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Richard Todd Newsgroups: gmane.lisp.guile.bugs Subject: Re: patch to build guile CVS on Mac OS X Date: Tue, 6 Jan 2004 17:16:45 -0600 Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Message-ID: <20040106231645.GA10000@Richard-Todds-Computer.local> References: <20040106101709.GA27012@Richard-Todds-Computer.local> <87vfno91qb.fsf@zip.com.au> Reply-To: Richard Todd NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0830467233==" X-Trace: sea.gmane.org 1073432967 24631 80.91.224.253 (6 Jan 2004 23:49:27 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 6 Jan 2004 23:49:27 +0000 (UTC) Cc: bug-guile@gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Wed Jan 07 00:49:22 2004 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1Ae0ws-00081J-00 for ; Wed, 07 Jan 2004 00:49:22 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1Ae1rq-0000nc-4C for guile-bugs@m.gmane.org; Tue, 06 Jan 2004 19:48:14 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1Ae1ji-0006k2-1v for bug-guile@gnu.org; Tue, 06 Jan 2004 19:39:50 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1Ae1VI-00033K-S1 for bug-guile@gnu.org; Tue, 06 Jan 2004 19:25:28 -0500 Original-Received: from [66.171.154.62] (helo=Richard-Todds-Computer.local) by monty-python.gnu.org with esmtp (Exim 4.24) id 1Ae1Ot-0001Lh-Pv for bug-guile@gnu.org; Tue, 06 Jan 2004 19:18:20 -0500 Original-Received: by Richard-Todds-Computer.local (Postfix, from userid 501) id 7E4DE8283C; Tue, 6 Jan 2004 17:16:45 -0600 (CST) Original-To: Kevin Ryde In-Reply-To: <87vfno91qb.fsf@zip.com.au> User-Agent: Mutt/1.4i X-BeenThere: bug-guile@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Bug reports for GUILE, GNU's Ubiquitous Extension Language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.bugs:1070 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.bugs:1070 --===============0830467233== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="zhXaljGHf11kAtnf" Content-Disposition: inline --zhXaljGHf11kAtnf Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jan 07, 2004 at 08:00:28AM +1000, Kevin Ryde wrote: > Richard Todd writes: > > > > +#if defined(__APPLE__) && defined(__DYNAMIC__) > > +#include > > +static char ** environ; > > +#else > > extern char ** environ; > > +#endif=20 > > =20 > > #ifdef HAVE_GRP_H > > #include > > @@ -1735,6 +1740,10 @@ > > void=20 > > scm_init_posix () > > { > > +#if defined(__APPLE__) && defined(__DYNAMIC__) > > + environ =3D *_NSGetEnviron(); > > +#endif > > + >=20 > 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=3D1= .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 > 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 -------------------- $ gcc -E test.c | grep -i env=20 char *getenv(const char *); int putenv(const char *); int setenv(const char *, const char *, int); void unsetenv(const char *); =2E.and I browsed the files by hand in case it was a #define. No luck. Richard Todd --zhXaljGHf11kAtnf Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (Darwin) iD8DBQE/+0Hda9lhNGIqsRIRAl9PAKC2OuBtCRFXXdd1fNRXGPYg/9leDQCeIp6K Rxm3e1RQ5jrnsEJMmSEdnVU= =M++C -----END PGP SIGNATURE----- --zhXaljGHf11kAtnf-- --===============0830467233== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Bug-guile mailing list Bug-guile@gnu.org http://mail.gnu.org/mailman/listinfo/bug-guile --===============0830467233==--