Add `emscripten_out` and `emscripten_err` along with `f` versions.
Replaced `emscripten_console_log`/`error` with those two functions respectively in `streams.cpp`.
The this is more accurate that !ENVIRONMENT_IS_WORKER, and holds
true, for example, under node where there is no main browser thread,
only a main runtime thread.
Relevant Issue: #15041
Tentative JS File Backend Structure
Introduced user-visible header file.
Users can create a new JS Backend and create JS Backed Files under both In-Memory and JS Backend directories.
This macro was clearly written to be used in this function but has no
current users. I could alternatively remove SMALLEST_ALLOCATION_SIZE
completely but that seems worse.
Restore the older versions of these files and used them in place of the
new ones when optimizing for size.
These regressions were intended and deemed acceptable in upsteeam
musl:
e4dd65305a2a3210cf4a236cd056e8Fixes: #15483
In all these places the code is really attempting to figure out if it is
the main runtime thread. i.e. the first place the program is loaded and
the place that runs the callback and async events send from secondary
threads.
The reason this mistake often goes unnoticed is that in almost all cases
the main runtime thread is also running on the main browser thread.
One easy way to see that `is_main_browser_thread` is the wrong question
to be asking in many of these cases is to remember that when emscripten
is started in a worker there is no main browser involved and so this
function will return false on *all* threads.
In the cast of `__timedwait.c` and `pthread_barrier_wait.c` the desire
is to avoid blocking the main runtime threads so that calls from other
threads can be processed by `emscripten_main_thread_process_queued_calls`.
`emscripten_main_thread_process_queued_calls` is expected to always run
on the main runtime thread, and not necessarily on the main browser
thread. Indeed its first line is:
`assert(emscripten_is_main_runtime_thread());`
Relevant Issue: #15041
Implement FS.readfile() which copies an in-memory file into JS.
Parameterize `test_sdl_audio_mix_channels` and `test_sdl_audio_mix` to work with `WASMFS`.
Relevant Issue: #15041
* fix mode on file and dir creation, update tests to verify
* file type is now derived from kind
* Add optional mode to open and refactor tests
The changes here mostly come from running the update_musl.py script
against the following commit:
https://github.com/emscripten-core/musl/tree/merge_v1.2.2
Notes:
- `weak` is defined in musl-internal headers so some of our usage of
`__attribute__((weak))` was switched to `__weak__` (which is a
synonym).
- Quite a few changes needed in library_pthread.js due to changes to
the internal representation of __pthread struct in C.
- removal of emscripten-specific threadStatus field. This can
can be fully replaced with the updated `detach_state` that
was added to musl (along with enum values for states!) along
with the existing `cancel` bit.
- `attr` is no longer stored on `__pthread`; it was only duplicating
other fields anyway. We now include `pthread_getattr_np.c` which
can pull those field out on demand into at attr structure.
We are now maintaining our llvm and musl patches in external
repositories so that it is easier to update from upstream
and rebase onto new releases.
I already created scripts for copying changes in one direction
(i.e. into emscripten). This change adds push_llvm_changes.py
and push_musl_changes.py which can be used to push changes
in the other direction.
Relevant Issue: #15041
Implement cwd and locking for the global wasmFS state object.
Add relative paths to general path parsing.
Add parent weak_ptr to all File nodes.
Add chdir and getcwd syscalls.
Add test for chdir and getcwd.
TSD == Thread Specific Data.
Basically, if there are any calls to to `pthread_key_create` we get a
full sized `__pthread_tsd_main` otherwise we get dummy one.
Split out from #13006.
The musl implemenation of dup2 works fine without this syscall as it can
be implemented in terms of dup3.
As part of this change I was forced to implement __wasi_fd_fdstat_get
for wasmfs since dup2 not depends on this wasi syscall.
Split out from #15411
Relevant issue: #15041
Enable loading of files when --preload-file is specified.
FS.createDataFile and FS.createPath are emulated in the new file system.
Edited browser.test_preload_file() to check preloading functionality.
Relevant Issue: #15041
- Refactored file structure to include a global wasmfs state object that one has to go through to gain access to the FileTable or getRootDirectory().
- Simplified streams.h header by moving function implementations into streams.cpp.
- Removed static member entries from FileTable due to new init_priority(100) on wasmFS.
This adds SjLj handling support using Wasm EH instructions:
https://github.com/WebAssembly/exception-handling/blob/master/proposals/exception-handling/Exceptions.md
This does not yet support mixing of EH and SjLj.
These are SjLj tests that I couldn't attach `@with_both_sjlj_handling`
and the reasons:
- `test_dlfcn_longjmp`: Uses NodeRAWFS
- `test_longjmp_throw`: Mixes EH and SjLj
- `test_exceptions_longjmp1`: Mixes EH and SjLj
- `test_exceptions_longjmp2`: Mixes EH and SjLj
- `test_exceptions_longjmp3`: Mixes EH and SjLj
- `test_longjmp`: This currently uses `@also_with_standalone_wasm`, and
it looks a test can't take two decorators when both of them take
arguments, which is the case for `@also_with_standalone_wasm` and
`@with_both_sjlj_handling`.
This change maintains a shared global list of DSOs loaded and adds a
`emscripten_thread_sync_code` helper function which can be used to bring
the current thread up to date by loading all the modules in the this
list.
The static table region allocated for a particular module is allocated
by the first loading thread. All other threads will use the same
pre-allocated region.
This change does not yet deal with sychronizing pointers loaded by
`dlsym`.
This NFC change was split out from #15317. These flags need to be
persisted and in shared memory so that each thread/worker can load with
the libraries with the same flags.