mirror of
https://git.proxmox.com/git/wasi-libc
synced 2025-08-03 19:28:57 +00:00
Also add a way to read environ
without triggering eager init.
Add a `__wasilibc_get_environ` function which returns the value of `environ` but without performing eager init.
This commit is contained in:
parent
82fc2c4f44
commit
3c4a3f94d1
@ -313,6 +313,7 @@ __wasilibc_fd_renumber
|
||||
__wasilibc_find_abspath
|
||||
__wasilibc_find_relpath
|
||||
__wasilibc_find_relpath_alloc
|
||||
__wasilibc_get_environ
|
||||
__wasilibc_initialize_environ
|
||||
__wasilibc_link
|
||||
__wasilibc_link_newat
|
||||
|
@ -24,6 +24,11 @@ void __wasilibc_deinitialize_environ(void);
|
||||
/// referenced in the program.
|
||||
void __wasilibc_maybe_reinitialize_environ_eagerly(void);
|
||||
|
||||
/// Return the value of the `environ` variable. Using `environ` directly
|
||||
/// requires eager initialization of the environment variables. Using this
|
||||
/// function instead of `environ` allows initialization to happen lazily.
|
||||
char **__wasilibc_get_environ(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
14
libc-bottom-half/sources/__wasilibc_environ.c
Normal file
14
libc-bottom-half/sources/__wasilibc_environ.c
Normal file
@ -0,0 +1,14 @@
|
||||
#include <wasi/libc-environ.h>
|
||||
|
||||
extern char **__wasilibc_environ;
|
||||
|
||||
// See the comments in libc-environ.h.
|
||||
char **__wasilibc_get_environ(void) {
|
||||
// Perform lazy initialization if needed.
|
||||
__wasilibc_ensure_environ();
|
||||
|
||||
// Return `environ`. Use the `__wasilibc_`-prefixed name so that we don't
|
||||
// pull in the `environ` symbol directly, which would lead to eager
|
||||
// initialization being done instead.
|
||||
return __wasilibc_environ;
|
||||
}
|
Loading…
Reference in New Issue
Block a user