1 /* -----------------------------------------------------------------------------
3 * (c) The GHC Team 2011
5 * Access to the process environment variables
7 * ---------------------------------------------------------------------------*/
12 #if defined(darwin_HOST_OS)
14 /* While the "extern char** environ" var does exist on OSX, it is not
15 * available to shared libs. See ghc ticket #2458 and
16 * http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man7/environ.7.html
18 #include <crt_externs.h>
20 static char** get_environ(void) { return *(_NSGetEnviron()); }
24 /* On proper unix systems the environ is just a global var.
26 extern char** environ;
27 static char** get_environ(void) { return environ; }
32 void getProgEnvv(int *out_envc, char **out_envv[]) {
34 char **environ = get_environ();
36 for (envc = 0; environ[envc] != NULL; envc++) {};
42 void freeProgEnvv(int envc STG_UNUSED, char *envv[] STG_UNUSED) {