Paste number 86913: environ patch for OD system library

Paste number 86913: environ patch for OD system library
Pasted by: housel
When:6 months, 1 week ago
Share:Tweet this! | http://paste.lisp.org/+1V29
Channel:#dylan
Paste contents:
Raw Source | XML | Display As
Index: unix-operating-system.dylan
===================================================================
--- unix-operating-system.dylan	(revision 12502)
+++ unix-operating-system.dylan	(working copy)
@@ -453,9 +453,9 @@
   // environment variable name
   let old-envp :: <machine-word>
     = primitive-wrap-machine-word
-        (primitive-c-pointer-at(%c-variable-pointer("environ", #t),
-                                integer-as-raw(0),
-                                integer-as-raw(0)));
+        (%call-c-function ("system_environ") () => (environ :: <raw-c-pointer>)
+           ()
+         end);
   block (envp-done)
     for (i :: <integer> from 0)
       let raw-item

Index: unix-portability.c
===================================================================
--- unix-portability.c	(revision 12502)
+++ unix-portability.c	(working copy)
@@ -2,6 +2,18 @@
 #include <signal.h>
 #include <errno.h>
 
+#ifdef __APPLE__
+#include <crt_externs.h>
+#define environ (*_NSGetEnviron())
+#else
+extern char **environ;
+#endif
+
+char **system_environ(void)
+{
+  return environ;
+}
+
 /* Adapted from the SBCL run-time system, which in turn is derived
  * from the CMU CL system, which was written at Carnegie Mellon
  * University and released into the public domain.

This paste has no annotations.

Colorize as:
Show Line Numbers

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.