From ce02b05888fd421c3329c4cc74ab1547b08467dc Mon Sep 17 00:00:00 2001 From: sam Date: Wed, 24 Sep 2003 15:14:16 +0000 Subject: [PATCH] * Fixed the check for "environ" on OS X and Solaris. git-svn-id: svn://svn.zoy.org/elk/trunk@184 55e467fa-43c5-0310-a8a2-de718669efc6 --- configure.ac | 7 ++++++- lib/unix/process.c | 16 +++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index 864406f..1c3e637 100644 --- a/configure.ac +++ b/configure.ac @@ -385,7 +385,12 @@ AC_DEFINE(ANSI_CPP, 1, [FIXME HARD]) # library functions, and include files are supported by the system. AC_CHECK_HEADERS(utime.h sys/utime.h sys/wait.h sys/times.h dirent.h netdb.h) AC_CHECK_FUNCS(waitpid wait3 wait4 vfork uname gethostname gettimeofday ftime) -AC_CHECK_FUNCS(mktemp tmpnam tempnam getcwd getwd rename regcomp) +AC_CHECK_FUNCS(mktemp tmpnam tempnam getcwd getwd rename regcomp environ) +AC_MSG_CHECKING(for environ in unistd.h) +AC_EGREP_HEADER(environ, unistd.h, + [AC_MSG_RESULT(yes) + AC_DEFINE(ENVIRON_IN_UNISTD_H, 1, Define if defines environ)], + [AC_MSG_RESULT(no)]) # Element type of the gidset argument of getgroups(); typically int # or gid_t. Only needed by the UNIX extension. diff --git a/lib/unix/process.c b/lib/unix/process.c index 69be56f..8e9d85c 100644 --- a/lib/unix/process.c +++ b/lib/unix/process.c @@ -32,17 +32,20 @@ #include #include + #ifdef HAVE_SYS_TIMES_H # include #endif #ifndef WIN32 -/* "extern" in front of the next declaration causes the Ultrix 4.2 linker - * to fail when dynamically loading unix.o (but omitting it does no longer - * work with modern C compilers): - */ -extern char **environ; +#ifdef ENVIRON_IN_UNISTD_H +/* "extern" in front of the next declaration causes the Ultrix 4.2 linker + * to fail, but omitting it no longer works with modern C compilers: */ +extern char **environ; +#endif + +#ifdef HAVE_ENVIRON static Object P_Environ() { Object ret, cell, str; char *p, **ep; @@ -67,6 +70,7 @@ static Object P_Environ() { GC_Unlink; return P_Reverse(ret); } +#endif static Object General_Exec(int argc, Object *argv, int path) { Object fn, args, p, e; @@ -357,7 +361,9 @@ err: } void elk_init_unix_process() { +#ifdef HAVE_UNISTD_H Def_Prim(P_Environ, "unix-environ", 0, 0, EVAL); +#endif Def_Prim(P_Exec, "unix-exec", 2, 3, VARARGS); Def_Prim(P_Exec_Path, "unix-exec-path", 2, 3, VARARGS); Def_Prim(P_Fork, "unix-fork", 0, 0, EVAL);