Skip to content

Commit

Permalink
Use _NSGetEnviron on OSX. Fixes #3446.
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed Dec 29, 2015
1 parent f264f92 commit 6bb384d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion vm/ffi_util.cpp
Expand Up @@ -19,13 +19,23 @@
#include "windows_compat.h"
#include "ffi_util.hpp"

#ifdef __APPLE__
#include <crt_externs.h>
#endif

extern "C" {

extern char** environ;

int ffi_errno() { return errno; }

char** ffi_environ() { return environ; }
char** ffi_environ() {
#ifdef __APPLE__
return *_NSGetEnviron();
#else
return environ;
#endif
}

void ffi_set_errno(int n) {
errno = n;
Expand Down

0 comments on commit 6bb384d

Please sign in to comment.