mirror of
https://git.proxmox.com/git/wasi-libc
synced 2025-08-05 01:32:43 +00:00
![]() * Convert preopen initialization to be lazy. Insteead of eagerly initializing the preopens in a static constructor, perform preopen initialization the first time it's needed, or before a close or a renumber which might disrupt the file descriptor space. And, use a weak symbol with a stub function for use by `close` or `fd_renumber`, we that they can trigger preopen initialization only if it's actually needed. This way, if a program doesn't contain any calls to any function that needs preopens, it can avoid linking in the preopen initialization code. And if it contains calls but doesn't execute them at runtime, it can avoid executing the preopen intiailization code. A downside here is that this may cause problems for users that call `__wasi_fd_close` or `__wasi_fd_renumber` directly and close over overwrite some preopens before libc has a chance to scan them. To partially address this, this PR does add a declaration for `__wasilibc_populate_preopens` to <wasi/libc.h> so that users can call it manually if they need to. * Fix calling `internal_register_preopened_fd` with the lock held. Factor out the lock acquisition from the implementation of `internal_register_preopened_fd` so that we can call it from `__wasilibc_populate_preopens` with the lock held. |
||
---|---|---|
.. | ||
src | ||
LICENSE |