wasi-libc/libc-bottom-half/sources
Dan Gohman 9efc2f4283
Lazy-initialize the environment variables. (#184)
* Lazy-initialize the environment variables.

This is the first in a series of PRs to make it easier to use WASI libc
in Wasm modules that don't have a `main` function. By initializing the
environment on demand, we avoid depending on having `__wasm_call_ctors`
run.

This uses weak symbols strategically to ensure that if `environ` is
used, it is initialized eagerly, but if only `getenv` and friends
are used, the environment is initialized lazily.

Eventually, I expect we'll have a convention for wasm modules without
main functions which will allow the `__wasm_call_ctors` function to be
called automatically, but this helps in simple cases for now.

Fixes #180.

* Add comments explaining the libc-environ-compat.h header usage.
2020-03-19 09:32:41 -07:00
..
__main_argc_argv.c Add support for __main_argc_argv. 2020-02-27 13:09:38 -08:00
__main_void.c Add support for __main_argc_argv. 2020-02-27 13:09:38 -08:00
__original_main.c Add support for __main_argc_argv. 2020-02-27 13:09:38 -08:00
__wasilibc_fd_renumber.c Wasi snapshot preview1 (#140) 2019-11-21 20:06:00 -08:00
__wasilibc_initialize_environ.c Lazy-initialize the environment variables. (#184) 2020-03-19 09:32:41 -07:00
__wasilibc_rmdirat.c Wasi snapshot preview1 (#140) 2019-11-21 20:06:00 -08:00
__wasilibc_tell.c Wasi snapshot preview1 (#140) 2019-11-21 20:06:00 -08:00
__wasilibc_unlinkat.c Wasi snapshot preview1 (#140) 2019-11-21 20:06:00 -08:00
environ.c Lazy-initialize the environment variables. (#184) 2020-03-19 09:32:41 -07:00
errno.c Use consistent style for wasi-libc C source files. (#131) 2019-11-08 11:59:57 -08:00
getentropy.c Wasi snapshot preview1 (#140) 2019-11-21 20:06:00 -08:00
isatty.c Wasi snapshot preview1 (#140) 2019-11-21 20:06:00 -08:00
pause.c Wasi snapshot preview1 (#140) 2019-11-21 20:06:00 -08:00
sbrk.c Use consistent style for wasi-libc C source files. (#131) 2019-11-08 11:59:57 -08:00
string.c Use the same indentation style as surrounding code. 2019-04-15 09:47:16 -07:00
truncate.c Avoid varargs conventions when calling open (#126) 2019-11-04 16:37:45 -08:00