~~This patch series first starts with a number of commits stubbing out
functions in the existing `THREAD_model=posix` code. According to "The
Open Group Base Specifications Issue 7, 2018 edition", there are a
number of mandatory functions which have not been provided. There are
also some optional functions that have been partially provided in a
not-useful way (e.g. get but no set function). For these, I have chosen
to clean them up and remove the get functions for consistency.~~ EDIT:
These have been split off into separate PRs and merged.
The remainder of the patches then build up a stub implementation of
pthreads for `THREAD_MODEL=single`. I have done my best to try to make
sure that all functions are as conforming as possible (under the
assumption that another thread cannot ever be launched). This means that
objects such as mutexes and rwlocks actually do update their state and
will correctly fail when locks cannot be acquired.
When an inevitable deadlock occurs, I have chosen to return EDEADLK when
it has been explicitly listed as a permissible return value, and to
invoke `__builtin_trap` otherwise.
I have tested this by rebuilding libc++ with threads enabled and then
smoke-testing Clang/LLVM-on-WASI to make sure that it can compile a
simple program. I have not run any more-extensive conformance testing.
Fixes#501
The WASI libc "top half" is conceptually the upper half of a traditional libc
implementation, consisting of C standard library and other relatively
higher-level functionality.
Code in the musl directory is based on musl revision
040c1d16b468c50c04fc94edff521f1637708328, which is v1.2.0, from
git://git.musl-libc.org/musl.
Whole files which are unused are omitted. Changes to upstream code are wrapped
in preprocessor directives controlled by the macro __wasilibc_unmodified_upstream.
Some major known missing areas include:
threads
aio
setjmp
signals
ipc
termios
nss
timezones
non-builtin locales
TIOCGWINSZ (because cloudabi lacks it; affects isatty, line buffering for stdout)