1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-10 14:00:21 +02:00

(environ): Use _NSGetEnviron in Darwin

shared library, since environ is not directly available there.
This commit is contained in:
Kevin Ryde 2004-02-18 00:20:08 +00:00
parent 424d0540f2
commit eb7e1603ad
3 changed files with 47 additions and 3 deletions

View file

@ -122,6 +122,10 @@ extern char ** environ;
# include <sys/file.h>
#endif
#if HAVE_CRT_EXTERNS_H
#include <crt_externs.h> /* for Darwin _NSGetEnviron */
#endif
/* Some Unix systems don't define these. CPP hair is dangerous, but
this seems safe enough... */
#ifndef R_OK
@ -157,7 +161,23 @@ extern char ** environ;
/* Please don't add any more #includes or #defines here. The hack
above means that _POSIX_SOURCE may be #defined, which will
encourage header files to do strange things. */
encourage header files to do strange things.
FIXME: Maybe should undef _POSIX_SOURCE after it's done its job.
FIXME: Probably should do all the includes first, then all the fallback
declarations and defines, in case things are not in the header we
imagine. */
/* On Apple Darwin in a shared library there's no "environ" to access
directly, instead the address of that variable must be obtained with
_NSGetEnviron(). */
#if HAVE__NSGETENVIRON && defined (PIC)
#define environ (*_NSGetEnviron())
#endif
SCM_SYMBOL (sym_read_pipe, "read pipe");

View file

@ -1,4 +1,4 @@
/* Copyright (C) 1991, 2000, 2001 Free Software Foundation, Inc.
/* Copyright (C) 1991, 2000, 2001, 2004 Free Software Foundation, Inc.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -51,12 +51,23 @@ char *malloc ();
#include <unistd.h>
#endif
#if HAVE_CRT_EXTERNS_H
#include <crt_externs.h> /* for Darwin _NSGetEnviron */
#endif
#ifndef NULL
#define NULL 0
#endif
extern char **environ;
/* On Apple Darwin in a shared library there's no "environ" to access
directly, instead the address of that variable must be obtained with
_NSGetEnviron(). */
#if HAVE__NSGETENVIRON && defined (PIC)
#define environ (*_NSGetEnviron())
#endif
/* Put STRING, which is of the form "NAME=VALUE", in the environment. */
int
putenv (const char *string)

View file

@ -54,6 +54,10 @@
# include <sys/timeb.h>
#endif
#if HAVE_CRT_EXTERNS_H
#include <crt_externs.h> /* for Darwin _NSGetEnviron */
#endif
#ifndef tzname /* For SGI. */
extern char *tzname[]; /* RS6000 and others reject char **tzname. */
#endif
@ -71,6 +75,16 @@ extern char *strptime ();
# define timet long
#endif
extern char ** environ;
/* On Apple Darwin in a shared library there's no "environ" to access
directly, instead the address of that variable must be obtained with
_NSGetEnviron(). */
#if HAVE__NSGETENVIRON && defined (PIC)
#define environ (*_NSGetEnviron())
#endif
#ifdef HAVE_TIMES
static
timet mytime()
@ -260,7 +274,6 @@ filltime (struct tm *bd_time, int zoff, char *zname)
}
static char tzvar[3] = "TZ";
extern char ** environ;
/* if zone is set, create a temporary environment with only a TZ
string. other threads or interrupt handlers shouldn't be allowed