diff --git a/src/library.js b/src/library.js index 344ec8d669692..41214d848142f 100644 --- a/src/library.js +++ b/src/library.js @@ -7554,6 +7554,16 @@ LibraryManager.library = { getpwent: function() { throw 'getpwent: TODO' }, endpwent: function() { throw 'endpwent: TODO' }, + // crt_externs.h + + _NSGetEnviron__deps: ['$ENV', 'environ'], + _NSGetEnviron: function() { + // extern char ***_NSGetEnviron(void); + // https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man7/environ.7.html + var envPtr = {{{ makeGetValue(makeGlobalUse('_environ'), '0', 'i8**') }}}; + return allocate([envPtr], 'i8**', ALLOC_NORMAL); + }, + // ========================================================================== // emscripten.h // ========================================================================== diff --git a/system/include/libc/crt_externs.h b/system/include/libc/crt_externs.h new file mode 100644 index 0000000000000..dd82d6a6f0da4 --- /dev/null +++ b/system/include/libc/crt_externs.h @@ -0,0 +1 @@ +extern char ***_NSGetEnviron(void); \ No newline at end of file