Commit Graph

167 Commits

Author SHA1 Message Date
Dan Gohman
46ce01276f Don't declare dup in unistd.h.
Dup isn't defined in libc.a, so don't declare it.
2019-05-09 09:07:57 -07:00
Dan Gohman
e91e6dd766 Re-enable '%s' in strftime.
This was commented out earlier when timezone handling was more in flux,
but it's ok to minimally support this now.

This fixes src/functional/strftime.c in libc-test.
2019-05-09 09:07:38 -07:00
Dan Gohman
382b944a2e Rename __wasilibc_rmfileat to __wasilibc_unlinkat.
The POSIX terminology is that directories are "removed" while files
are "unlinked".
2019-05-07 15:04:17 -07:00
Dan Gohman
124f6a4d0a Add __restrict qualifiers to the fstatat declaration.
This makes it consistent with its definition.
2019-05-07 15:03:26 -07:00
Dan Gohman
07858345bc Ensure that environ is always initialized.
Initialize `environ` even if there are no environment variables, so that
it alwasy points to a NULL-terminated array even if that array just
contains the NULL. This fixes src/functional/env.c.
2019-05-07 11:35:48 -07:00
Dan Gohman
b40521edc3 Fix the return value of the first call to uselocale.
The first call to uselocale should return LC_GLOBAL_LOCALE. This fixes
src/regression/uselocale-0.c in libc-test.
2019-05-07 11:35:14 -07:00
Dan Gohman
c87e877f88 Move abort.c out of libc-bottom-half and into basics. 2019-05-07 11:34:41 -07:00
Frank Denis
b1e234b683 Document that WASM_NM and WASM_AR may also be required
Also make it explicit that we currently need clang 8+

Fixes #44
2019-05-06 13:32:45 -07:00
vms
d987aad467 use ENOMEM instead of EINVAL, set EINVAL if length == 0 2019-05-06 09:46:36 -07:00
vms
30e5a1fd1f move to __builtin_add_overflow 2019-05-06 09:46:36 -07:00
vms
ccfe4bda30 code deduplication 2019-05-06 09:46:36 -07:00
vms
4a8d1c7cf5 fix comment to correspond existing coding style 2019-05-06 09:46:36 -07:00
vms
20c48b57c7 fix mmap overflow and some other stuff 2019-05-06 09:46:36 -07:00
Sam Clegg
8e8cc34aad Makefile: Don't mix phony targets with directory names
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.
2019-05-02 12:47:45 -07:00
vms
5ae626e99d delete a space in predefined-macros.txt 2019-05-02 08:06:39 -07:00
vms
a64f654488 replace some macros with its builtins analogs 2019-05-02 08:06:39 -07:00
vms
2be6428b21 rename printf_no_Lf to __small_printf 2019-05-01 15:43:55 -07:00
Dan Gohman
51969495ee Define TIME_UTC to be 1.
TIME_UTC is the only time base defined by the relevant standards. This
change doesn't preclude adding other time bases in the future.
2019-05-01 12:52:28 -07:00
Dan Gohman
1bdb356bef Define CLOCKS_PER_SEC to have type clock_t.
The C standard requires CLOCKS_PER_SEC to have type clock_t.
2019-05-01 12:52:28 -07:00
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