Commit Graph

48 Commits

Author SHA1 Message Date
Dan Gohman
cf366c06d1 Optimize lseek in the tell case.
`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.
2019-04-30 16:19:05 -07:00
Dan Gohman
9f103c2883 Say "wasm32-wasi" rather than "wasm32-unknown-wasi". 2019-04-30 16:14:32 -07:00
Dan Gohman
401012952d Declare getentropy in <sys/random.h>
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.
2019-04-30 16:07:49 -07:00
Dan Gohman
9bb4cc5c41 Disable unused fields in FILE and __libc.
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.
2019-04-29 07:33:59 -07:00
Dan Gohman
2201343c17 Add vfwprintf.c to the printscan list.
This causes the build to produce no-long-double and no-floating-point
versions of this file, following what is done for vfprintf.c.
2019-04-23 21:00:32 -07:00
Dan Gohman
1cbedc6d7e Implement FD_SET, FD_CLR, etc.
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.
2019-04-23 15:01:23 -07:00
Dan Gohman
538937e2c8 Remove capsicum.h; WASI libc doesn't support that API, even internally. 2019-04-23 15:01:05 -07:00
Dan Gohman
0df6243d52 Make calloc set ENOMEM when failing due to overflow.
This fixes a bug in upstream dlmalloc, where it doesn't set errno to
ENOMEM in overflow or footprint overrun cases.
2019-04-23 15:00:40 -07:00
Dan Gohman
972067b74b Make the strerror message for ESUCCESS (0) be "Success".
Previously it was "No error information", which was indistinguishable
from an unrecognized errno value.
2019-04-23 15:00:23 -07:00
Dan Gohman
ad03c82d65 Implement reallocarray.
reallocarray is non-standard but present in GLIBC and BSDs.
2019-04-23 15:00:07 -07:00
Dimitrii Nemkov
488c478b59 Update README.md 2019-04-23 12:54:55 -07:00
Jakub Konka
5ce487a789 Add missing asctime symbol 2019-04-23 09:22:00 -07:00
vms
4194578ae8 Fix floatscan no long double usage (#21)
* fix long double using in floatscan

* define separate macroses for copysignl, fmodl, and scalbnl instead of #ifndef
2019-04-22 14:37:03 -07:00
Dan Gohman
29d45024c7 Remove the Linux-specific <sys/signalfd.h> header. 2019-04-22 11:41:55 -07:00
Dan Gohman
49f1a57cb8 Declare getrusage.
It's defined publicly in libc, so publicly declare it too.
2019-04-22 11:41:40 -07:00
Dan Gohman
ec9f1c3956 Format changes to musl code to fit musl's style.
The whitespace diffs are converting from spaces to tabs.
2019-04-22 11:41:22 -07:00
Jakub Konka
03a1adbf2b Fixes #20
Adds missing localtime.c source file to Makefile and to expected
defined symbols list.
2019-04-22 08:24:42 -07:00
Pat Hickey
fa84763026 gitignore build 2019-04-19 11:16:25 -07:00
Pat Hickey
fad009dc1d build: use LC_ALL=C for sorting
LC_COLLATE doesn't seem to work with all `sort`s
2019-04-18 17:24:33 -07:00
Dan Gohman
1cc98f27f5 Update to cloudlibc 8835639f27fc42d32096d59d294a0bbb857dc368.
There's no functional change here; the only change is the patch I
submitted upstream, so we can remove some local changes.
2019-04-15 09:49:02 -07:00
Dan Gohman
f41256b602 Update to musl 1.1.22.
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.
2019-04-15 09:48:03 -07:00
Dan Gohman
65107e782f Rename README to README.md. 2019-04-15 09:47:16 -07:00
Dan Gohman
e18d69c801 Remove socket.c, which was a stub that always failed with ENOSYS. 2019-04-15 09:47:16 -07:00
Dan Gohman
ab594e4d51 Use the same indentation style as surrounding code. 2019-04-15 09:47:16 -07:00
Dan Gohman
7ba6adfc61 Fix miscellaneous lint warnings. 2019-04-15 09:47:16 -07:00
Dan Gohman
4646d29abc Make basics include guard names more consistent. 2019-04-15 09:47:16 -07:00
Dan Gohman
ad22a59013 Add a basics implementation of <inttypes.h>.
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.
2019-04-15 09:44:33 -07:00
Dan Gohman
9f0d8e85e3 Define _ALL_SOURCE when generating predefined-macros.txt.
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.
2019-04-15 04:05:20 -07:00
Dan Gohman
079d7bda78 Don't install <ucontext.h> or <sys/ucontext.h> for WASI.
WASI doesn't support `getcontext`, `setcontext`, or related functions.
2019-04-11 10:46:23 -07:00
Dan Gohman
24792713d7 Fix uselocale to support non-default locales.
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.
2019-04-05 08:33:57 -07:00
Dan Gohman
f74124a6f4 Filter out __FLT16_* macros from predefined-macros.txt.
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.
2019-04-05 08:30:47 -07:00
Dan Gohman
e5f14be383 Add comments explaining changes to upstream source files.
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.
2019-04-05 06:39:09 -07:00
Dan Gohman
685d014446
Provide a public interface to preopened directory lookups. (#10)
* 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.
2019-04-05 06:30:30 -07:00
Dan Gohman
320054e84f WASI libc prototype implementation.
This incoporates pieces from musl-libc, cloudlibc, cloudabi, libpreopen,
and dlmalloc, as well as a significant amount of new code.
2019-03-27 07:59:55 -07:00
eliasbenali
0e98504240 Fix ssize_t redefinition mismatch. (#10)
* 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
2019-03-20 19:24:58 -07:00
Dan Gohman
78b6c3d875
Merge pull request #9 from WebAssembly/dlmalloc
Add a malloc implementation using dlmalloc.
2019-01-15 12:41:50 -08:00
Dan Gohman
dbfccac2e4 Add a malloc implementation using dlmalloc. 2019-01-10 15:42:34 -08:00
Dan Gohman
55fef5877b
Merge pull request #8 from WebAssembly/suseconds_t_and_nlink_t
Add more typedefs and struct stat
2019-01-08 19:41:55 -08:00
Dan Gohman
51d4922df8 Add a definition of struct stat and supporting types.
This `struct stat` matches the x32 and x86-64 definitions.
2019-01-02 20:37:21 -08:00
Dan Gohman
26722dc857 Add typedefs for suseconds_t and nlink_t. 2019-01-02 16:01:05 -08:00
Dan Gohman
d68aebf353
Merge pull request #5 from penzn/master
Enable overriding 'ar'
2018-11-26 23:24:19 -08:00
Petr Penzin
7ef30385ab Enable overriding 'ar'
Make has a stanard variable for 'ar', it is better to use it to enable
overriding the standard name in non-standard builds (i.e. MinGW).
2018-11-07 09:39:33 -08:00
Dan Gohman
b91c4ea256
Merge pull request #1 from WebAssembly/add-initial-files
Add initial files.
2018-10-08 13:38:12 -07:00
Dan Gohman
ae5ae4de91 Explain why this doesn't have a full libc. 2018-10-02 22:06:07 -07:00
Dan Gohman
c9850bfdbc Fix typos. 2018-10-02 22:04:41 -07:00
Dan Gohman
f2049d9bd0 Fix missing quote. 2018-10-02 19:16:19 -07:00
Dan Gohman
dcf13b6fc4 Add initial files.
This populates the repo with a very minimal set of files. This is just
enough to set out a basic outline. Hopefully as we move forward we'll
be replacing many of these parts, but this is just something basic to
get things started.

This tree isn't really usable yet, as it doesn't yet have an easy way
to obtain a compiler-rt/libgcc build.
2018-10-02 17:48:36 -07:00
Dan Gohman
d9982c379b Start with nothing, so that we can add the initial files with a PR. 2018-10-02 17:27:27 -07:00