Remove build rules for $(SYSROOT) and $(SYSROOT_INC). The latter
becomes `include_dirs`. The former is not needed, instead just add
startup_files to the finish rule.
`lseek(x, 0, SEEK_CUR)` has no effect other than to return the current
file offset. The patch here uses a macro with `__builtin_constant_p` to
recognize this case and rewrite it to a library call that uses `fd_tell`
rather than `fd_seek`, so that programs that don't need actual seeking
don't end up importing `fd_seek`.
This is also the first usage of `__wasi_fd_tell` in WASI libc, so this
adds it to undefined-symbols.txt.
Some systems, such as Darwin, only declare getentropy in <sys/random.h>,
so declare it there on WASI too for compatibility.
Also, give getentropy the underscore-prefix/weak-symbol treatment, as
it's not a standard-reserved identifier.
Some of these fields are only needed for threads, some are not needed at
all. Removing them helps prevent code from accidentally using them, such
as when we merge in new musl versions.
Previously, FD_SET and friends were missing their actual definitions.
This provides definitions, entirely within the system headers in a
way that doesn't need instantiated out-of-line definitions.
Most of the changes are in threads, TLS, dynamic linking, and other
features wasi doesn't yet use, but there are some bug fixes in code
wasi does use.
atanl.c - local changes no longer needed as they've now landed upstream.
include/alltypes.h.in - Upstream now makes FILE a complete type in
pre-C11 mode. For WASI, this level of pre-C11 strictness isn't as
important, and having multiple incompatible definitions of _IO_FILE
that are kept separate only by clever use of translation unit
boundaries can confuse some tools, so stick with the incomplete type.
Musl's generic definitions for PRIxPTR and several others in
<inttypes.h> are incorrect for wasm, so introduce a new <inttypes.h>
and <__header_inttypes.h> in the basics module using compiler-provided
definitions.
Fixes#13.
And clean up various stale declarations and macros that this turned up.
In particular:
- Don't install pthread.h or aio.h in THREAD_MODEL=single mode.
- Don't define mkstemp and friends, since WASI currently has no support for
temporary directories.
Musl's locales implementation depends on pthreads. Since WASI libc
doesn't yet have pthreads, it currently has alternate code for
supporting locales. Previously, this code just assumed that it only had
to support the default locale, however libc++ uses uselocale with
non-default locals, so add support for that.
With this, the C++ <iostream>-style hello world now works, with
-fno-exceptions.
Whether these are defined or not depends on the version of clang in use,
and they're not that important at this time, so for now just ignore them
for the purposes of this testing output.
Add at least a one-line comment on every
`#ifdef __wasilibc_unmodified_upstream` briefly indicating what its
purpose is.
While here, reenable some of the code that was previously disabled when
getenv wasn't supported, as getenv is now supported.
* Provide a public interface to preopened directory lookups.
For users of especially non-C compilers, provide an API for looking up
preopened directories. This is used internally in WASI libc to translate
from eg. `open` to `openat`, but it can now also be used by user code.
* Fix ssize_t redefinition mismatch.
Align definition with comment and previous define in __typedef_ssize_t.h
* Fix __typedef_ssize_t.h, redundancy in sys/types.h