authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-06-15 12:33:17+02:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2022-06-15 12:33:17+02:00
logd3caacfab70736b43719b92391c9d343b54a03fd
tree48c83d2764be807835c1e1d53a45f1d16ae63fac
parent27610b0a0f0b2fc0695b0687d1e93ce910c155db
parent8c630376952546ddd09e76fcc72d3d2a8d12e0b6
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #11864 from jedisct1/wasi-libc-update

Update the WASI libc to 30094b6ed05f19cee102115215863d185f2db4f0

81 files changed, 581 insertions(+), 225 deletions(-)

lib/libc/wasi/libc-bottom-half/cloudlibc/src/libc/sys/stat/stat_impl.h+6
...@@ -75,14 +75,18 @@ static inline bool utimens_get_timestamps(const struct timespec *times,...@@ -75,14 +75,18 @@ static inline bool utimens_get_timestamps(const struct timespec *times,
75 if (times == NULL) {75 if (times == NULL) {
76 // Update both timestamps.76 // Update both timestamps.
77 *flags = __WASI_FSTFLAGS_ATIM_NOW | __WASI_FSTFLAGS_MTIM_NOW;77 *flags = __WASI_FSTFLAGS_ATIM_NOW | __WASI_FSTFLAGS_MTIM_NOW;
78 *st_atim = (__wasi_timestamp_t) { 0 };
79 *st_mtim = (__wasi_timestamp_t) { 0 };
78 } else {80 } else {
79 // Set individual timestamps.81 // Set individual timestamps.
80 *flags = 0;82 *flags = 0;
81 switch (times[0].tv_nsec) {83 switch (times[0].tv_nsec) {
82 case UTIME_NOW:84 case UTIME_NOW:
83 *flags |= __WASI_FSTFLAGS_ATIM_NOW;85 *flags |= __WASI_FSTFLAGS_ATIM_NOW;
86 *st_atim = (__wasi_timestamp_t) { 0 };
84 break;87 break;
85 case UTIME_OMIT:88 case UTIME_OMIT:
89 *st_atim = (__wasi_timestamp_t) { 0 };
86 break;90 break;
87 default:91 default:
88 *flags |= __WASI_FSTFLAGS_ATIM;92 *flags |= __WASI_FSTFLAGS_ATIM;
...@@ -94,8 +98,10 @@ static inline bool utimens_get_timestamps(const struct timespec *times,...@@ -94,8 +98,10 @@ static inline bool utimens_get_timestamps(const struct timespec *times,
94 switch (times[1].tv_nsec) {98 switch (times[1].tv_nsec) {
95 case UTIME_NOW:99 case UTIME_NOW:
96 *flags |= __WASI_FSTFLAGS_MTIM_NOW;100 *flags |= __WASI_FSTFLAGS_MTIM_NOW;
101 *st_mtim = (__wasi_timestamp_t) { 0 };
97 break;102 break;
98 case UTIME_OMIT:103 case UTIME_OMIT:
104 *st_mtim = (__wasi_timestamp_t) { 0 };
99 break;105 break;
100 default:106 default:
101 *flags |= __WASI_FSTFLAGS_MTIM;107 *flags |= __WASI_FSTFLAGS_MTIM;
lib/libc/wasi/libc-bottom-half/cloudlibc/src/libc/sys/time/gettimeofday.c+5-3
...@@ -9,8 +9,10 @@...@@ -9,8 +9,10 @@
9#include <wasi/api.h>9#include <wasi/api.h>
1010
11int gettimeofday(struct timeval *restrict tp, void *tz) {11int gettimeofday(struct timeval *restrict tp, void *tz) {
12 __wasi_timestamp_t ts = 0;12 if (tp != NULL) {
13 (void)__wasi_clock_time_get(__WASI_CLOCKID_REALTIME, 1000, &ts);13 __wasi_timestamp_t ts = 0;
14 *tp = timestamp_to_timeval(ts);14 (void)__wasi_clock_time_get(__WASI_CLOCKID_REALTIME, 1000, &ts);
15 *tp = timestamp_to_timeval(ts);
16 }
15 return 0;17 return 0;
16}18}
lib/libc/wasi/libc-bottom-half/sources/__wasilibc_real.c-12
...@@ -574,18 +574,6 @@ _Noreturn void __wasi_proc_exit(...@@ -574,18 +574,6 @@ _Noreturn void __wasi_proc_exit(
574 __imported_wasi_snapshot_preview1_proc_exit((int32_t) rval);574 __imported_wasi_snapshot_preview1_proc_exit((int32_t) rval);
575}575}
576576
577int32_t __imported_wasi_snapshot_preview1_proc_raise(int32_t arg0) __attribute__((
578 __import_module__("wasi_snapshot_preview1"),
579 __import_name__("proc_raise")
580));
581
582__wasi_errno_t __wasi_proc_raise(
583 __wasi_signal_t sig
584){
585 int32_t ret = __imported_wasi_snapshot_preview1_proc_raise((int32_t) sig);
586 return (uint16_t) ret;
587}
588
589int32_t __imported_wasi_snapshot_preview1_sched_yield() __attribute__((577int32_t __imported_wasi_snapshot_preview1_sched_yield() __attribute__((
590 __import_module__("wasi_snapshot_preview1"),578 __import_module__("wasi_snapshot_preview1"),
591 __import_name__("sched_yield")579 __import_name__("sched_yield")
lib/libc/wasi/libc-bottom-half/sources/accept.c created+51
...@@ -0,0 +1,51 @@
1// SPDX-License-Identifier: BSD-2-Clause
2
3#include <sys/socket.h>
4
5#include <assert.h>
6#include <wasi/api.h>
7#include <errno.h>
8#include <string.h>
9
10int accept(int socket, struct sockaddr *restrict addr, socklen_t *restrict addrlen) {
11 int ret = -1;
12
13 __wasi_errno_t error = __wasi_sock_accept(socket, 0, &ret);
14
15 if (error != 0) {
16 errno = error;
17 return -1;
18 }
19
20 // Clear sockaddr to indicate undefined address
21 memset(addr, 0, *addrlen);
22 // might be AF_UNIX or AF_INET
23 addr->sa_family = AF_UNSPEC;
24 *addrlen = sizeof(struct sockaddr);
25
26 return ret;
27}
28
29int accept4(int socket, struct sockaddr *restrict addr, socklen_t *restrict addrlen, int flags) {
30 int ret = -1;
31
32 if (flags & ~(SOCK_NONBLOCK | SOCK_CLOEXEC)) {
33 errno = EINVAL;
34 return -1;
35 }
36
37 __wasi_errno_t error = __wasi_sock_accept(socket, (flags & SOCK_NONBLOCK) ? __WASI_FDFLAGS_NONBLOCK : 0, &ret);
38
39 if (error != 0) {
40 errno = error;
41 return -1;
42 }
43
44 // Clear sockaddr to indicate undefined address
45 memset(addr, 0, *addrlen);
46 // might be AF_UNIX or AF_INET
47 addr->sa_family = AF_UNSPEC;
48 *addrlen = sizeof(struct sockaddr);
49
50 return ret;
51}
lib/libc/wasi/libc-bottom-half/sources/chdir.c+5-4
...@@ -46,7 +46,7 @@ int chdir(const char *path)...@@ -46,7 +46,7 @@ int chdir(const char *path)
46 size_t len = strlen(abs) + 1;46 size_t len = strlen(abs) + 1;
47 int copy_relative = strcmp(relative_buf, ".") != 0;47 int copy_relative = strcmp(relative_buf, ".") != 0;
48 int mid = copy_relative && abs[0] != 0;48 int mid = copy_relative && abs[0] != 0;
49 char *new_cwd = malloc(len + (copy_relative ? strlen(relative_buf) + mid: 0));49 char *new_cwd = malloc(len + (copy_relative ? strlen(relative_buf) + mid: 0)+1);
50 if (new_cwd == NULL) {50 if (new_cwd == NULL) {
51 errno = ENOMEM;51 errno = ENOMEM;
52 return -1;52 return -1;
...@@ -54,7 +54,7 @@ int chdir(const char *path)...@@ -54,7 +54,7 @@ int chdir(const char *path)
54 new_cwd[0] = '/';54 new_cwd[0] = '/';
55 strcpy(new_cwd + 1, abs);55 strcpy(new_cwd + 1, abs);
56 if (mid)56 if (mid)
57 new_cwd[strlen(abs) + 1] = '/';57 new_cwd[len] = '/';
58 if (copy_relative)58 if (copy_relative)
59 strcpy(new_cwd + 1 + mid + strlen(abs), relative_buf);59 strcpy(new_cwd + 1 + mid + strlen(abs), relative_buf);
6060
...@@ -95,9 +95,10 @@ static const char *make_absolute(const char *path) {...@@ -95,9 +95,10 @@ static const char *make_absolute(const char *path) {
95 int need_slash = __wasilibc_cwd[cwd_len - 1] == '/' ? 0 : 1;95 int need_slash = __wasilibc_cwd[cwd_len - 1] == '/' ? 0 : 1;
96 size_t alloc_len = cwd_len + path_len + 1 + need_slash;96 size_t alloc_len = cwd_len + path_len + 1 + need_slash;
97 if (alloc_len > make_absolute_len) {97 if (alloc_len > make_absolute_len) {
98 make_absolute_buf = realloc(make_absolute_buf, alloc_len);98 char *tmp = realloc(make_absolute_buf, alloc_len);
99 if (make_absolute_buf == NULL)99 if (tmp == NULL)
100 return NULL;100 return NULL;
101 make_absolute_buf = tmp;
101 make_absolute_len = alloc_len;102 make_absolute_len = alloc_len;
102 }103 }
103 strcpy(make_absolute_buf, __wasilibc_cwd);104 strcpy(make_absolute_buf, __wasilibc_cwd);
lib/libc/wasi/libc-bottom-half/sources/posix.c+28-2
...@@ -31,16 +31,20 @@ static int find_relpath2(...@@ -31,16 +31,20 @@ static int find_relpath2(
31static int find_relpath(const char *path, char **relative) {31static int find_relpath(const char *path, char **relative) {
32 static __thread char *relative_buf = NULL;32 static __thread char *relative_buf = NULL;
33 static __thread size_t relative_buf_len = 0;33 static __thread size_t relative_buf_len = 0;
34 int fd = find_relpath2(path, &relative_buf, &relative_buf_len);
35 // find_relpath2 can update relative_buf, so assign it after the call
34 *relative = relative_buf;36 *relative = relative_buf;
35 return find_relpath2(path, relative, &relative_buf_len);37 return fd;
36}38}
3739
38// same as `find_relpath`, but uses another set of static variables to cache40// same as `find_relpath`, but uses another set of static variables to cache
39static int find_relpath_alt(const char *path, char **relative) {41static int find_relpath_alt(const char *path, char **relative) {
40 static __thread char *relative_buf = NULL;42 static __thread char *relative_buf = NULL;
41 static __thread size_t relative_buf_len = 0;43 static __thread size_t relative_buf_len = 0;
44 int fd = find_relpath2(path, &relative_buf, &relative_buf_len);
45 // find_relpath2 can update relative_buf, so assign it after the call
42 *relative = relative_buf;46 *relative = relative_buf;
43 return find_relpath2(path, relative, &relative_buf_len);47 return fd;
44}48}
4549
46int open(const char *path, int oflag, ...) {50int open(const char *path, int oflag, ...) {
...@@ -139,6 +143,28 @@ int utime(const char *path, const struct utimbuf *times) {...@@ -139,6 +143,28 @@ int utime(const char *path, const struct utimbuf *times) {
139 0);143 0);
140}144}
141145
146int utimes(const char *path, const struct timeval times[2]) {
147 char *relative_path;
148 int dirfd = find_relpath(path, &relative_path);
149
150 // If we can't find a preopen for it, indicate that we lack capabilities.
151 if (dirfd == -1) {
152 errno = ENOTCAPABLE;
153 return -1;
154 }
155
156 return __wasilibc_nocwd_utimensat(
157 dirfd, relative_path,
158 times ? ((struct timespec [2]) {
159 { .tv_sec = times[0].tv_sec,
160 .tv_nsec = times[0].tv_usec * 1000 },
161 { .tv_sec = times[1].tv_sec,
162 .tv_nsec = times[1].tv_usec * 1000 },
163 })
164 : NULL,
165 0);
166}
167
142int unlink(const char *path) {168int unlink(const char *path) {
143 char *relative_path;169 char *relative_path;
144 int dirfd = find_relpath(path, &relative_path);170 int dirfd = find_relpath(path, &relative_path);
lib/libc/wasi/libc-top-half/musl/include/ctype.h+2
...@@ -64,7 +64,9 @@ int isascii(int);...@@ -64,7 +64,9 @@ int isascii(int);
64int toascii(int);64int toascii(int);
65#define _tolower(a) ((a)|0x20)65#define _tolower(a) ((a)|0x20)
66#define _toupper(a) ((a)&0x5f)66#define _toupper(a) ((a)&0x5f)
67#ifndef __cplusplus
67#define isascii(a) (0 ? isascii(a) : (unsigned)(a) < 128)68#define isascii(a) (0 ? isascii(a) : (unsigned)(a) < 128)
69#endif
6870
69#endif71#endif
7072
lib/libc/wasi/libc-top-half/musl/include/elf.h+2
...@@ -686,6 +686,8 @@ typedef struct {...@@ -686,6 +686,8 @@ typedef struct {
686#define NT_ARM_PAC_MASK 0x406686#define NT_ARM_PAC_MASK 0x406
687#define NT_ARM_PACA_KEYS 0x407687#define NT_ARM_PACA_KEYS 0x407
688#define NT_ARM_PACG_KEYS 0x408688#define NT_ARM_PACG_KEYS 0x408
689#define NT_ARM_TAGGED_ADDR_CTRL 0x409
690#define NT_ARM_PAC_ENABLED_KEYS 0x40a
689#define NT_METAG_CBUF 0x500691#define NT_METAG_CBUF 0x500
690#define NT_METAG_RPIPE 0x501692#define NT_METAG_RPIPE 0x501
691#define NT_METAG_TLS 0x502693#define NT_METAG_TLS 0x502
lib/libc/wasi/libc-top-half/musl/include/locale.h+3-1
...@@ -8,7 +8,9 @@ extern "C" {...@@ -8,7 +8,9 @@ extern "C" {
8#include <features.h>8#include <features.h>
99
10#ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */10#ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */
11#ifdef __cplusplus11#if __cplusplus >= 201103L
12#define NULL nullptr
13#elif defined(__cplusplus)
12#define NULL 0L14#define NULL 0L
13#else15#else
14#define NULL ((void*)0)16#define NULL ((void*)0)
lib/libc/wasi/libc-top-half/musl/include/netinet/if_ether.h+1
...@@ -66,6 +66,7 @@...@@ -66,6 +66,7 @@
66#define ETH_P_1588 0x88F766#define ETH_P_1588 0x88F7
67#define ETH_P_NCSI 0x88F867#define ETH_P_NCSI 0x88F8
68#define ETH_P_PRP 0x88FB68#define ETH_P_PRP 0x88FB
69#define ETH_P_CFM 0x8902
69#define ETH_P_FCOE 0x890670#define ETH_P_FCOE 0x8906
70#define ETH_P_TDLS 0x890D71#define ETH_P_TDLS 0x890D
71#define ETH_P_FIP 0x891472#define ETH_P_FIP 0x8914
lib/libc/wasi/libc-top-half/musl/include/netinet/in.h+1
...@@ -60,6 +60,7 @@ struct ipv6_mreq {...@@ -60,6 +60,7 @@ struct ipv6_mreq {
60#define INADDR_BROADCAST ((in_addr_t) 0xffffffff)60#define INADDR_BROADCAST ((in_addr_t) 0xffffffff)
61#define INADDR_NONE ((in_addr_t) 0xffffffff)61#define INADDR_NONE ((in_addr_t) 0xffffffff)
62#define INADDR_LOOPBACK ((in_addr_t) 0x7f000001)62#define INADDR_LOOPBACK ((in_addr_t) 0x7f000001)
63#define INADDR_DUMMY ((in_addr_t) 0xc0000008)
6364
64#define INADDR_UNSPEC_GROUP ((in_addr_t) 0xe0000000)65#define INADDR_UNSPEC_GROUP ((in_addr_t) 0xe0000000)
65#define INADDR_ALLHOSTS_GROUP ((in_addr_t) 0xe0000001)66#define INADDR_ALLHOSTS_GROUP ((in_addr_t) 0xe0000001)
lib/libc/wasi/libc-top-half/musl/include/netinet/tcp.h+11
...@@ -80,6 +80,8 @@ enum {...@@ -80,6 +80,8 @@ enum {
80 TCP_NLA_SRTT,80 TCP_NLA_SRTT,
81 TCP_NLA_TIMEOUT_REHASH,81 TCP_NLA_TIMEOUT_REHASH,
82 TCP_NLA_BYTES_NOTSENT,82 TCP_NLA_BYTES_NOTSENT,
83 TCP_NLA_EDT,
84 TCP_NLA_TTL,
83};85};
8486
85#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)87#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
...@@ -281,12 +283,21 @@ struct tcp_repair_window {...@@ -281,12 +283,21 @@ struct tcp_repair_window {
281 uint32_t rcv_wup;283 uint32_t rcv_wup;
282};284};
283285
286#define TCP_RECEIVE_ZEROCOPY_FLAG_TLB_CLEAN_HINT 0x1
287
284struct tcp_zerocopy_receive {288struct tcp_zerocopy_receive {
285 uint64_t address;289 uint64_t address;
286 uint32_t length;290 uint32_t length;
287 uint32_t recv_skip_hint;291 uint32_t recv_skip_hint;
288 uint32_t inq;292 uint32_t inq;
289 int32_t err;293 int32_t err;
294 uint64_t copybuf_address;
295 int32_t copybuf_len;
296 uint32_t flags;
297 uint64_t msg_control;
298 uint64_t msg_controllen;
299 uint32_t msg_flags;
300 uint32_t reserved;
290};301};
291302
292#endif303#endif
lib/libc/wasi/libc-top-half/musl/include/pthread.h+1
...@@ -227,6 +227,7 @@ int pthread_getaffinity_np(pthread_t, size_t, struct cpu_set_t *);...@@ -227,6 +227,7 @@ int pthread_getaffinity_np(pthread_t, size_t, struct cpu_set_t *);
227int pthread_setaffinity_np(pthread_t, size_t, const struct cpu_set_t *);227int pthread_setaffinity_np(pthread_t, size_t, const struct cpu_set_t *);
228int pthread_getattr_np(pthread_t, pthread_attr_t *);228int pthread_getattr_np(pthread_t, pthread_attr_t *);
229int pthread_setname_np(pthread_t, const char *);229int pthread_setname_np(pthread_t, const char *);
230int pthread_getname_np(pthread_t, char *, size_t);
230int pthread_getattr_default_np(pthread_attr_t *);231int pthread_getattr_default_np(pthread_attr_t *);
231int pthread_setattr_default_np(const pthread_attr_t *);232int pthread_setattr_default_np(const pthread_attr_t *);
232int pthread_tryjoin_np(pthread_t, void **);233int pthread_tryjoin_np(pthread_t, void **);
lib/libc/wasi/libc-top-half/musl/include/setjmp.h+11-3
...@@ -16,21 +16,27 @@ typedef struct __jmp_buf_tag {...@@ -16,21 +16,27 @@ typedef struct __jmp_buf_tag {
16 unsigned long __ss[128/sizeof(long)];16 unsigned long __ss[128/sizeof(long)];
17} jmp_buf[1];17} jmp_buf[1];
1818
19#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)
20#define __setjmp_attr __attribute__((__returns_twice__))
21#else
22#define __setjmp_attr
23#endif
24
19#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \25#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
20 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \26 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
21 || defined(_BSD_SOURCE)27 || defined(_BSD_SOURCE)
22typedef jmp_buf sigjmp_buf;28typedef jmp_buf sigjmp_buf;
23int sigsetjmp (sigjmp_buf, int);29int sigsetjmp (sigjmp_buf, int) __setjmp_attr;
24_Noreturn void siglongjmp (sigjmp_buf, int);30_Noreturn void siglongjmp (sigjmp_buf, int);
25#endif31#endif
2632
27#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \33#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
28 || defined(_BSD_SOURCE)34 || defined(_BSD_SOURCE)
29int _setjmp (jmp_buf);35int _setjmp (jmp_buf) __setjmp_attr;
30_Noreturn void _longjmp (jmp_buf, int);36_Noreturn void _longjmp (jmp_buf, int);
31#endif37#endif
3238
33int setjmp (jmp_buf);39int setjmp (jmp_buf) __setjmp_attr;
34_Noreturn void longjmp (jmp_buf, int);40_Noreturn void longjmp (jmp_buf, int);
3541
36#define setjmp setjmp42#define setjmp setjmp
...@@ -38,6 +44,8 @@ _Noreturn void longjmp (jmp_buf, int);...@@ -38,6 +44,8 @@ _Noreturn void longjmp (jmp_buf, int);
38#warning setjmp is not yet implemented for WASI44#warning setjmp is not yet implemented for WASI
39#endif45#endif
4046
47#undef __setjmp_attr
48
41#ifdef __cplusplus49#ifdef __cplusplus
42}50}
43#endif51#endif
lib/libc/wasi/libc-top-half/musl/include/signal.h+8
...@@ -82,6 +82,8 @@ typedef struct sigaltstack stack_t;...@@ -82,6 +82,8 @@ typedef struct sigaltstack stack_t;
82#define SEGV_ACCERR 282#define SEGV_ACCERR 2
83#define SEGV_BNDERR 383#define SEGV_BNDERR 3
84#define SEGV_PKUERR 484#define SEGV_PKUERR 4
85#define SEGV_MTEAERR 8
86#define SEGV_MTESERR 9
8587
86#define BUS_ADRALN 188#define BUS_ADRALN 1
87#define BUS_ADRERR 289#define BUS_ADRERR 2
...@@ -183,6 +185,9 @@ struct sigaction {...@@ -183,6 +185,9 @@ struct sigaction {
183#define sa_handler __sa_handler.sa_handler185#define sa_handler __sa_handler.sa_handler
184#define sa_sigaction __sa_handler.sa_sigaction186#define sa_sigaction __sa_handler.sa_sigaction
185187
188#define SA_UNSUPPORTED 0x00000400
189#define SA_EXPOSE_TAGBITS 0x00000800
190
186struct sigevent {191struct sigevent {
187 union sigval sigev_value;192 union sigval sigev_value;
188 int sigev_signo;193 int sigev_signo;
...@@ -277,6 +282,9 @@ void (*sigset(int, void (*)(int)))(int);...@@ -277,6 +282,9 @@ void (*sigset(int, void (*)(int)))(int);
277#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)282#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
278#define NSIG _NSIG283#define NSIG _NSIG
279typedef void (*sig_t)(int);284typedef void (*sig_t)(int);
285
286#define SYS_SECCOMP 1
287#define SYS_USER_DISPATCH 2
280#endif288#endif
281289
282#ifdef _GNU_SOURCE290#ifdef _GNU_SOURCE
lib/libc/wasi/libc-top-half/musl/include/stdc-predef.h+3
...@@ -7,4 +7,7 @@...@@ -7,4 +7,7 @@
7#define __STDC_IEC_559__ 17#define __STDC_IEC_559__ 1
8#endif8#endif
99
10#define __STDC_UTF_16__ 1
11#define __STDC_UTF_32__ 1
12
10#endif13#endif
lib/libc/wasi/libc-top-half/musl/include/stddef.h+3-1
...@@ -1,7 +1,9 @@...@@ -1,7 +1,9 @@
1#ifndef _STDDEF_H1#ifndef _STDDEF_H
2#define _STDDEF_H2#define _STDDEF_H
33
4#ifdef __cplusplus4#if __cplusplus >= 201103L
5#define NULL nullptr
6#elif defined(__cplusplus)
5#define NULL 0L7#define NULL 0L
6#else8#else
7#define NULL ((void*)0)9#define NULL ((void*)0)
lib/libc/wasi/libc-top-half/musl/include/stdio.h+3-1
...@@ -28,7 +28,9 @@ extern "C" {...@@ -28,7 +28,9 @@ extern "C" {
28#include <bits/alltypes.h>28#include <bits/alltypes.h>
2929
30#ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */30#ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */
31#ifdef __cplusplus31#if __cplusplus >= 201103L
32#define NULL nullptr
33#elif defined(__cplusplus)
32#define NULL 0L34#define NULL 0L
33#else35#else
34#define NULL ((void*)0)36#define NULL ((void*)0)
lib/libc/wasi/libc-top-half/musl/include/stdlib.h+4-1
...@@ -13,7 +13,9 @@ extern "C" {...@@ -13,7 +13,9 @@ extern "C" {
13#include <features.h>13#include <features.h>
1414
15#ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */15#ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */
16#ifdef __cplusplus16#if __cplusplus >= 201103L
17#define NULL nullptr
18#elif defined(__cplusplus)
17#define NULL 0L19#define NULL 0L
18#else20#else
19#define NULL ((void*)0)21#define NULL ((void*)0)
...@@ -171,6 +173,7 @@ int clearenv(void);...@@ -171,6 +173,7 @@ int clearenv(void);
171#define WCOREDUMP(s) ((s) & 0x80)173#define WCOREDUMP(s) ((s) & 0x80)
172#define WIFCONTINUED(s) ((s) == 0xffff)174#define WIFCONTINUED(s) ((s) == 0xffff)
173void *reallocarray (void *, size_t, size_t);175void *reallocarray (void *, size_t, size_t);
176void qsort_r (void *, size_t, size_t, int (*)(const void *, const void *, void *), void *);
174#endif177#endif
175#endif178#endif
176179
lib/libc/wasi/libc-top-half/musl/include/string.h+3-1
...@@ -12,7 +12,9 @@ extern "C" {...@@ -12,7 +12,9 @@ extern "C" {
12#include <features.h>12#include <features.h>
1313
14#ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */14#ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */
15#ifdef __cplusplus15#if __cplusplus >= 201103L
16#define NULL nullptr
17#elif defined(__cplusplus)
16#define NULL 0L18#define NULL 0L
17#else19#else
18#define NULL ((void*)0)20#define NULL ((void*)0)
lib/libc/wasi/libc-top-half/musl/include/sys/membarrier.h+4
...@@ -9,9 +9,13 @@...@@ -9,9 +9,13 @@
9#define MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED 169#define MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED 16
10#define MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE 3210#define MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE 32
11#define MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE 6411#define MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE 64
12#define MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ 128
13#define MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ 256
1214
13#define MEMBARRIER_CMD_SHARED MEMBARRIER_CMD_GLOBAL15#define MEMBARRIER_CMD_SHARED MEMBARRIER_CMD_GLOBAL
1416
17#define MEMBARRIER_CMD_FLAG_CPU 1
18
15int membarrier(int, int);19int membarrier(int, int);
1620
17#endif21#endif
lib/libc/wasi/libc-top-half/musl/include/sys/mman.h+1
...@@ -44,6 +44,7 @@ extern "C" {...@@ -44,6 +44,7 @@ extern "C" {
4444
45#define MAP_HUGE_SHIFT 2645#define MAP_HUGE_SHIFT 26
46#define MAP_HUGE_MASK 0x3f46#define MAP_HUGE_MASK 0x3f
47#define MAP_HUGE_16KB (14 << 26)
47#define MAP_HUGE_64KB (16 << 26)48#define MAP_HUGE_64KB (16 << 26)
48#define MAP_HUGE_512KB (19 << 26)49#define MAP_HUGE_512KB (19 << 26)
49#define MAP_HUGE_1MB (20 << 26)50#define MAP_HUGE_1MB (20 << 26)
lib/libc/wasi/libc-top-half/musl/include/sys/mount.h+1
...@@ -31,6 +31,7 @@ extern "C" {...@@ -31,6 +31,7 @@ extern "C" {
31#define MS_REMOUNT 3231#define MS_REMOUNT 32
32#define MS_MANDLOCK 6432#define MS_MANDLOCK 64
33#define MS_DIRSYNC 12833#define MS_DIRSYNC 128
34#define MS_NOSYMFOLLOW 256
34#define MS_NOATIME 102435#define MS_NOATIME 1024
35#define MS_NODIRATIME 204836#define MS_NODIRATIME 2048
36#define MS_BIND 409637#define MS_BIND 4096
lib/libc/wasi/libc-top-half/musl/include/sys/prctl.h+16
...@@ -157,10 +157,26 @@ struct prctl_mm_map {...@@ -157,10 +157,26 @@ struct prctl_mm_map {
157#define PR_SET_TAGGED_ADDR_CTRL 55157#define PR_SET_TAGGED_ADDR_CTRL 55
158#define PR_GET_TAGGED_ADDR_CTRL 56158#define PR_GET_TAGGED_ADDR_CTRL 56
159#define PR_TAGGED_ADDR_ENABLE (1UL << 0)159#define PR_TAGGED_ADDR_ENABLE (1UL << 0)
160#define PR_MTE_TCF_SHIFT 1
161#define PR_MTE_TCF_NONE (0UL << 1)
162#define PR_MTE_TCF_SYNC (1UL << 1)
163#define PR_MTE_TCF_ASYNC (2UL << 1)
164#define PR_MTE_TCF_MASK (3UL << 1)
165#define PR_MTE_TAG_SHIFT 3
166#define PR_MTE_TAG_MASK (0xffffUL << 3)
160167
161#define PR_SET_IO_FLUSHER 57168#define PR_SET_IO_FLUSHER 57
162#define PR_GET_IO_FLUSHER 58169#define PR_GET_IO_FLUSHER 58
163170
171#define PR_SET_SYSCALL_USER_DISPATCH 59
172#define PR_SYS_DISPATCH_OFF 0
173#define PR_SYS_DISPATCH_ON 1
174#define SYSCALL_DISPATCH_FILTER_ALLOW 0
175#define SYSCALL_DISPATCH_FILTER_BLOCK 1
176
177#define PR_PAC_SET_ENABLED_KEYS 60
178#define PR_PAC_GET_ENABLED_KEYS 61
179
164int prctl (int, ...);180int prctl (int, ...);
165181
166#ifdef __cplusplus182#ifdef __cplusplus
lib/libc/wasi/libc-top-half/musl/include/sys/ptrace.h+9
...@@ -42,6 +42,7 @@ extern "C" {...@@ -42,6 +42,7 @@ extern "C" {
42#define PTRACE_SECCOMP_GET_FILTER 0x420c42#define PTRACE_SECCOMP_GET_FILTER 0x420c
43#define PTRACE_SECCOMP_GET_METADATA 0x420d43#define PTRACE_SECCOMP_GET_METADATA 0x420d
44#define PTRACE_GET_SYSCALL_INFO 0x420e44#define PTRACE_GET_SYSCALL_INFO 0x420e
45#define PTRACE_GET_RSEQ_CONFIGURATION 0x420f
4546
46#define PT_READ_I PTRACE_PEEKTEXT47#define PT_READ_I PTRACE_PEEKTEXT
47#define PT_READ_D PTRACE_PEEKDATA48#define PT_READ_D PTRACE_PEEKDATA
...@@ -130,6 +131,14 @@ struct __ptrace_syscall_info {...@@ -130,6 +131,14 @@ struct __ptrace_syscall_info {
130 };131 };
131};132};
132133
134struct __ptrace_rseq_configuration {
135 uint64_t rseq_abi_pointer;
136 uint32_t rseq_abi_size;
137 uint32_t signature;
138 uint32_t flags;
139 uint32_t pad;
140};
141
133long ptrace(int, ...);142long ptrace(int, ...);
134143
135#ifdef __cplusplus144#ifdef __cplusplus
lib/libc/wasi/libc-top-half/musl/include/sys/socket.h+4-1
...@@ -298,6 +298,8 @@ struct linger {...@@ -298,6 +298,8 @@ struct linger {
298#define SCM_TXTIME SO_TXTIME298#define SCM_TXTIME SO_TXTIME
299#define SO_BINDTOIFINDEX 62299#define SO_BINDTOIFINDEX 62
300#define SO_DETACH_REUSEPORT_BPF 68300#define SO_DETACH_REUSEPORT_BPF 68
301#define SO_PREFER_BUSY_POLL 69
302#define SO_BUSY_POLL_BUDGET 70
301303
302#ifndef SOL_SOCKET304#ifndef SOL_SOCKET
303#define SOL_SOCKET 1305#define SOL_SOCKET 1
...@@ -404,9 +406,10 @@ int shutdown (int, int);...@@ -404,9 +406,10 @@ int shutdown (int, int);
404int bind (int, const struct sockaddr *, socklen_t);406int bind (int, const struct sockaddr *, socklen_t);
405int connect (int, const struct sockaddr *, socklen_t);407int connect (int, const struct sockaddr *, socklen_t);
406int listen (int, int);408int listen (int, int);
409#endif
410
407int accept (int, struct sockaddr *__restrict, socklen_t *__restrict);411int accept (int, struct sockaddr *__restrict, socklen_t *__restrict);
408int accept4(int, struct sockaddr *__restrict, socklen_t *__restrict, int);412int accept4(int, struct sockaddr *__restrict, socklen_t *__restrict, int);
409#endif
410413
411#ifdef __wasilibc_unmodified_upstream /* WASI has no getsockname/getpeername */414#ifdef __wasilibc_unmodified_upstream /* WASI has no getsockname/getpeername */
412int getsockname (int, struct sockaddr *__restrict, socklen_t *__restrict);415int getsockname (int, struct sockaddr *__restrict, socklen_t *__restrict);
lib/libc/wasi/libc-top-half/musl/include/sys/time.h+2-2
...@@ -23,9 +23,7 @@ struct itimerval {...@@ -23,9 +23,7 @@ struct itimerval {
23int getitimer (int, struct itimerval *);23int getitimer (int, struct itimerval *);
24int setitimer (int, const struct itimerval *__restrict, struct itimerval *__restrict);24int setitimer (int, const struct itimerval *__restrict, struct itimerval *__restrict);
25#endif25#endif
26#ifdef __wasilibc_unmodified_upstream /* WASI libc doesn't build the legacy functions */
27int utimes (const char *, const struct timeval [2]);26int utimes (const char *, const struct timeval [2]);
28#endif
2927
30#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)28#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
31struct timezone {29struct timezone {
...@@ -34,7 +32,9 @@ struct timezone {...@@ -34,7 +32,9 @@ struct timezone {
34};32};
35#ifdef __wasilibc_unmodified_upstream /* WASI libc doesn't build the legacy functions */33#ifdef __wasilibc_unmodified_upstream /* WASI libc doesn't build the legacy functions */
36int futimes(int, const struct timeval [2]);34int futimes(int, const struct timeval [2]);
35#endif
37int futimesat(int, const char *, const struct timeval [2]);36int futimesat(int, const char *, const struct timeval [2]);
37#ifdef __wasilibc_unmodified_upstream /* WASI libc doesn't build the legacy functions */
38int lutimes(const char *, const struct timeval [2]);38int lutimes(const char *, const struct timeval [2]);
39#endif39#endif
40#ifdef __wasilibc_unmodified_upstream /* WASI has no way to set the time */40#ifdef __wasilibc_unmodified_upstream /* WASI has no way to set the time */
lib/libc/wasi/libc-top-half/musl/include/time.h+3-1
...@@ -8,7 +8,9 @@ extern "C" {...@@ -8,7 +8,9 @@ extern "C" {
8#include <features.h>8#include <features.h>
99
10#ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */10#ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */
11#ifdef __cplusplus11#if __cplusplus >= 201103L
12#define NULL nullptr
13#elif defined(__cplusplus)
12#define NULL 0L14#define NULL 0L
13#else15#else
14#define NULL ((void*)0)16#define NULL ((void*)0)
lib/libc/wasi/libc-top-half/musl/include/unistd.h+5-1
...@@ -15,12 +15,16 @@ extern "C" {...@@ -15,12 +15,16 @@ extern "C" {
15#define SEEK_SET 015#define SEEK_SET 0
16#define SEEK_CUR 116#define SEEK_CUR 1
17#define SEEK_END 217#define SEEK_END 2
18#define SEEK_DATA 3
19#define SEEK_HOLE 4
18#else20#else
19#include <__header_unistd.h>21#include <__header_unistd.h>
20#endif22#endif
2123
22#ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */24#ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */
23#ifdef __cplusplus25#if __cplusplus >= 201103L
26#define NULL nullptr
27#elif defined(__cplusplus)
24#define NULL 0L28#define NULL 0L
25#else29#else
26#define NULL ((void*)0)30#define NULL ((void*)0)
lib/libc/wasi/libc-top-half/musl/include/wchar.h+3-1
...@@ -41,7 +41,9 @@ extern "C" {...@@ -41,7 +41,9 @@ extern "C" {
41#endif41#endif
4242
43#ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */43#ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */
44#ifdef __cplusplus44#if __cplusplus >= 201103L
45#define NULL nullptr
46#elif defined(__cplusplus)
45#define NULL 0L47#define NULL 0L
46#else48#else
47#define NULL ((void*)0)49#define NULL ((void*)0)
lib/libc/wasi/libc-top-half/musl/src/complex/cacosf.c+3-1
...@@ -2,8 +2,10 @@...@@ -2,8 +2,10 @@
22
3// FIXME3// FIXME
44
5static const float float_pi_2 = M_PI_2;
6
5float complex cacosf(float complex z)7float complex cacosf(float complex z)
6{8{
7 z = casinf(z);9 z = casinf(z);
8 return CMPLXF((float)M_PI_2 - crealf(z), -cimagf(z));10 return CMPLXF(float_pi_2 - crealf(z), -cimagf(z));
9}11}
lib/libc/wasi/libc-top-half/musl/src/complex/catanf.c+3-1
...@@ -61,13 +61,15 @@ static const double DP1 = 3.140625;...@@ -61,13 +61,15 @@ static const double DP1 = 3.140625;
61static const double DP2 = 9.67502593994140625E-4;61static const double DP2 = 9.67502593994140625E-4;
62static const double DP3 = 1.509957990978376432E-7;62static const double DP3 = 1.509957990978376432E-7;
6363
64static const float float_pi = M_PI;
65
64static float _redupif(float xx)66static float _redupif(float xx)
65{67{
66 float x, t;68 float x, t;
67 long i;69 long i;
6870
69 x = xx;71 x = xx;
70 t = x/(float)M_PI;72 t = x/float_pi;
71 if (t >= 0.0f)73 if (t >= 0.0f)
72 t += 0.5f;74 t += 0.5f;
73 else75 else
lib/libc/wasi/libc-top-half/musl/src/complex/cproj.c+1-1
...@@ -3,6 +3,6 @@...@@ -3,6 +3,6 @@
3double complex cproj(double complex z)3double complex cproj(double complex z)
4{4{
5 if (isinf(creal(z)) || isinf(cimag(z)))5 if (isinf(creal(z)) || isinf(cimag(z)))
6 return CMPLX(INFINITY, copysign(0.0, creal(z)));6 return CMPLX(INFINITY, copysign(0.0, cimag(z)));
7 return z;7 return z;
8}8}
lib/libc/wasi/libc-top-half/musl/src/complex/cprojf.c+1-1
...@@ -3,6 +3,6 @@...@@ -3,6 +3,6 @@
3float complex cprojf(float complex z)3float complex cprojf(float complex z)
4{4{
5 if (isinf(crealf(z)) || isinf(cimagf(z)))5 if (isinf(crealf(z)) || isinf(cimagf(z)))
6 return CMPLXF(INFINITY, copysignf(0.0, crealf(z)));6 return CMPLXF(INFINITY, copysignf(0.0, cimagf(z)));
7 return z;7 return z;
8}8}
lib/libc/wasi/libc-top-half/musl/src/complex/cprojl.c+1-1
...@@ -9,7 +9,7 @@ long double complex cprojl(long double complex z)...@@ -9,7 +9,7 @@ long double complex cprojl(long double complex z)
9long double complex cprojl(long double complex z)9long double complex cprojl(long double complex z)
10{10{
11 if (isinf(creall(z)) || isinf(cimagl(z)))11 if (isinf(creall(z)) || isinf(cimagl(z)))
12 return CMPLXL(INFINITY, copysignl(0.0, creall(z)));12 return CMPLXL(INFINITY, copysignl(0.0, cimagl(z)));
13 return z;13 return z;
14}14}
15#endif15#endif
lib/libc/wasi/libc-top-half/musl/src/ctype/nonspacing.h+60-58
...@@ -1,23 +1,23 @@...@@ -1,23 +1,23 @@
116,16,16,18,19,20,21,22,23,24,25,26,27,28,29,30,31,16,16,32,16,16,16,33,34,35,116,16,16,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,16,33,16,16,16,34,35,36,
236,37,38,39,16,16,40,16,16,16,16,16,16,16,16,16,16,16,41,42,16,16,43,16,16,16,237,38,39,40,16,16,41,16,16,16,16,16,16,16,16,16,16,16,42,43,16,16,44,16,16,16,
316,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,316,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
416,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,416,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
516,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,516,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
616,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,616,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
716,16,16,16,16,16,16,16,16,16,44,16,45,46,47,48,16,16,16,16,16,16,16,16,16,16,716,16,16,16,16,16,16,16,16,16,45,16,46,47,48,49,16,16,16,16,16,16,16,16,16,16,
816,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,816,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
916,16,16,16,16,16,16,50,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
1016,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,51,16,16,52,
1153,16,54,55,56,16,16,16,16,16,16,57,16,16,58,16,59,60,61,62,63,64,65,66,67,68,
1269,70,16,71,72,73,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
1316,74,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
916,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,1416,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
1016,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,49,16,16,50,1516,16,16,75,76,16,16,16,77,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
1151,16,52,53,54,16,16,16,16,16,16,55,16,16,56,16,57,58,59,60,61,62,63,64,65,66,
1267,68,16,69,70,71,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
1316,72,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
1416,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,1616,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
1516,16,16,73,74,16,16,16,75,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
1616,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,1716,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
1716,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,1816,16,16,16,16,16,16,78,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
1816,16,16,16,16,16,16,76,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,1916,16,79,80,16,16,16,16,16,16,16,81,16,16,16,16,16,82,83,84,16,16,16,16,16,85,
1916,16,77,78,16,16,16,16,16,16,16,79,16,16,16,16,16,80,81,82,16,16,16,16,16,83,2086,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
2084,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
2116,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,2116,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,
22255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,22255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
23255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,23255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
...@@ -35,55 +35,57 @@...@@ -35,55 +35,57 @@
35242,7,128,127,0,0,0,0,0,0,0,0,0,0,0,0,242,31,0,63,0,0,0,0,0,0,0,0,0,3,0,0,160,35242,7,128,127,0,0,0,0,0,0,0,0,0,0,0,0,242,31,0,63,0,0,0,0,0,0,0,0,0,3,0,0,160,
362,0,0,0,0,0,0,254,127,223,224,255,254,255,255,255,31,64,0,0,0,0,0,0,0,0,0,0,0,362,0,0,0,0,0,0,254,127,223,224,255,254,255,255,255,31,64,0,0,0,0,0,0,0,0,0,0,0,
370,224,253,102,0,0,0,195,1,0,30,0,100,32,0,32,0,0,0,0,0,0,0,0,0,0,0,370,224,253,102,0,0,0,195,1,0,30,0,100,32,0,32,0,0,0,0,0,0,0,0,0,0,0,
380,0,0,0,0,0,0,0,0,0,0,0,224,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,28,0,380,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,
390,0,28,0,0,0,12,0,0,0,12,0,0,0,0,0,0,0,176,63,64,254,15,32,0,0,0,0,0,120,0,0,39255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,224,0,0,0,0,0,0,0,0,0,0,0,0,
400,0,0,0,0,0,0,0,0,0,0,0,96,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,135,1,4,14,0,400,0,0,0,0,0,0,0,0,0,28,0,0,0,28,0,0,0,12,0,0,0,12,0,0,0,0,0,0,0,176,63,64,254,
410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,9,0,0,0,0,0,0,64,127,4115,32,0,0,0,0,0,120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,0,0,0,0,2,0,0,0,0,0,0,0,0,
42229,31,248,159,0,0,0,0,0,0,255,127,0,0,0,0,0,0,0,0,15,0,0,0,0,0,208,23,4,0,0,420,0,0,0,0,0,135,1,4,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
430,0,248,15,0,3,0,0,0,60,59,0,0,0,0,0,0,64,163,3,0,0,0,0,0,0,240,207,0,0,0,0,0,43128,9,0,0,0,0,0,0,64,127,229,31,248,159,0,0,0,0,0,0,255,127,0,0,0,0,0,0,0,0,
440,0,0,0,0,0,0,0,0,0,0,0,0,0,247,255,253,33,16,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4415,0,0,0,0,0,208,23,4,0,0,0,0,248,15,0,3,0,0,0,60,59,0,0,0,0,0,0,64,163,3,0,0,
450,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,450,0,0,0,240,207,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,247,255,253,33,16,
463,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,
46251,0,248,0,0,0,124,0,0,0,0,0,0,223,255,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,47251,0,248,0,0,0,124,0,0,0,0,0,0,223,255,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,
47255,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,3,0,0,0,48255,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,3,0,0,0,
480,0,0,0,0,0,0,0,0,0,0,0,0,128,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,0,0,0,0,490,0,0,0,0,0,0,0,0,0,0,0,0,128,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,0,0,0,0,
490,60,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,500,60,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
500,0,0,128,247,63,0,0,0,192,0,0,0,0,0,0,0,0,0,0,3,0,68,8,0,0,96,0,0,0,0,0,0,0,510,0,0,128,247,63,0,0,0,192,0,0,0,0,0,0,0,0,0,0,3,0,68,8,0,0,96,0,0,0,0,0,0,0,
510,0,0,0,0,0,0,0,0,0,0,0,48,0,0,0,255,255,3,128,0,0,0,0,192,63,0,0,128,255,3,0,520,0,0,0,0,0,0,0,0,0,0,0,48,0,0,0,255,255,3,128,0,0,0,0,192,63,0,0,128,255,3,0,
520,0,0,0,7,0,0,0,0,0,200,51,0,0,0,0,32,0,0,0,0,0,0,0,0,126,102,0,8,16,0,0,0,0,530,0,0,0,7,0,0,0,0,0,200,51,0,0,0,0,32,0,0,
530,16,0,0,0,0,0,0,157,193,2,0,0,0,0,48,64,540,0,0,0,0,0,126,102,0,8,16,0,0,0,0,0,16,0,0,0,0,0,0,157,193,2,0,0,0,0,48,64,0,
540,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,33,0,0,0,0,0,64,550,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,33,0,0,0,0,0,0,0,0,
550,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,0,0,255,255,0,560,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,0,0,0,
560,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,0,0,0,0,0,0,0,0,0,0,0,0,0,5764,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,0,0,255,
570,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,58255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,0,0,0,0,0,0,0,0,0,0,
580,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,590,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
590,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,600,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
600,110,240,0,0,0,0,0,135,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,0,0,610,0,0,0,0,0,1,0,0,
610,0,0,0,0,240,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,620,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,110,240,0,
620,0,0,192,255,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,255,630,0,0,0,135,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,0,0,0,0,0,0,0,240,0,0,
63127,0,0,0,0,0,0,128,3,0,0,0,0,0,120,38,0,32,0,0,0,0,0,0,7,0,0,0,128,239,31,0,640,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,255,1,0,
640,0,0,0,0,0,8,0,3,0,0,0,0,0,192,127,0,30,0,0,0,0,0,0,0,0,0,0,0,128,211,64,0,0,650,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,255,127,0,0,0,0,0,0,128,
650,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,248,7,0,0,3,0,0,0,0,0,0,24,1,0,0,0,192,663,0,0,0,0,0,120,38,0,32,0,0,0,0,0,0,7,0,0,0,128,239,31,0,0,0,0,0,0,0,8,0,3,0,
6631,31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,92,0,0,64,0,0,0,0,0,670,0,0,0,192,127,0,30,0,0,0,0,0,0,0,0,0,0,0,128,211,64,0,0,0,0,0,0,0,0,0,0,0,0,
670,0,0,0,0,248,133,13,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,680,0,0,0,0,0,0,128,248,7,0,0,3,0,0,0,0,0,0,24,1,0,0,0,192,31,31,0,0,0,0,0,0,0,
680,60,176,1,0,0,48,0,0,0,690,0,0,0,0,0,0,0,0,
690,0,0,0,0,0,0,248,167,1,0,0,0,0,0,0,0,0,0,0,0,0,40,191,0,0,0,0,0,0,0,0,0,0,0,700,0,0,0,0,0,0,0,255,92,0,0,64,0,0,0,0,0,0,0,0,0,0,248,133,13,0,0,0,0,0,0,0,0,
700,224,188,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,710,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,176,1,0,0,48,0,0,0,0,0,0,0,0,0,0,
71128,255,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,72248,167,1,0,0,0,0,0,0,0,0,0,0,0,0,40,191,0,0,0,0,0,0,0,0,0,0,0,0,224,188,15,0,
720,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,240,12,1,0,0,0,254,7,0,0,0,0,248,121,128,0,730,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,255,6,0,0,0,0,
73126,14,0,0,0,0,0,252,127,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,127,191,0,0,0,740,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
740,0,0,0,0,0,0,252,255,255,252,109,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,126,180,191,0,750,0,0,0,0,0,0,240,12,1,0,0,0,254,7,0,0,0,0,248,121,128,0,126,14,0,0,0,0,0,252,
750,0,0,0,0,0,0,0,163,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,76127,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,127,191,0,0,0,0,0,0,0,0,0,0,252,255,
760,0,0,0,0,0,0,0,0,0,0,0,0,0,24,77255,252,109,0,0,0,0,0,0,0,0,
770,0,0,0,0,0,0,255,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,780,0,0,0,0,0,0,126,180,191,0,0,0,0,0,0,0,0,0,163,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
780,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31,0,0,0,0,0,0,0,127,0,0,0,790,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,255,
790,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,0,0,0,0,0,0,801,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
800,128,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,15,810,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31,0,0,0,0,0,0,0,127,0,0,0,0,0,0,0,0,0,0,0,0,
810,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,3,248,255,231,15,0,0,0,60,0,820,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,0,0,0,0,0,0,0,128,7,0,0,0,0,0,
820,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,28,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,830,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,15,0,0,0,0,0,0,0,0,0,
830,0,0,255,255,255,255,255,255,127,248,255,255,255,255,255,31,32,0,16,0,0,248,840,0,0,0,0,0,0,0,0,0,0,0,0,0,128,3,248,255,231,15,0,0,0,60,0,0,0,0,0,0,0,0,0,
84254,255,0,0,0,0,0,0,0,0,0,850,0,0,0,0,0,0,0,0,28,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,
850,127,255,255,249,219,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,86255,255,255,255,127,248,255,255,255,255,255,31,32,0,16,0,0,248,254,255,0,0,0,
860,0,0,0,0,127,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,870,0,0,0,0,0,0,127,255,255,249,219,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
870,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,240,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,880,0,0,0,0,0,0,0,0,0,0,127,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
880,0,0,0,0,0,0,0,0,0,0,0,0,127,0,0,0,0,0,0,0,0,0,0,0,0,0,240,7,0,0,0,0,0,0,0,0,890,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,240,0,0,0,0,0,0,0,0,0,
890,0,0,0,0,0,0,0,0,0,0,0,0,0,900,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,127,0,0,0,0,0,0,0,0,0,0,0,0,0,240,7,0,0,
910,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
lib/libc/wasi/libc-top-half/musl/src/env/__libc_start_main.c+2-1
...@@ -69,7 +69,8 @@ weak_alias(libc_start_init, __libc_start_init);...@@ -69,7 +69,8 @@ weak_alias(libc_start_init, __libc_start_init);
69typedef int lsm2_fn(int (*)(int,char **,char **), int, char **);69typedef int lsm2_fn(int (*)(int,char **,char **), int, char **);
70static lsm2_fn libc_start_main_stage2;70static lsm2_fn libc_start_main_stage2;
7171
72int __libc_start_main(int (*main)(int,char **,char **), int argc, char **argv)72int __libc_start_main(int (*main)(int,char **,char **), int argc, char **argv,
73 void (*init_dummy)(), void(*fini_dummy)(), void(*ldso_dummy)())
73{74{
74 char **envp = argv+argc+1;75 char **envp = argv+argc+1;
7576
lib/libc/wasi/libc-top-half/musl/src/env/__stack_chk_fail.c+9
...@@ -9,6 +9,15 @@ void __init_ssp(void *entropy)...@@ -9,6 +9,15 @@ void __init_ssp(void *entropy)
9 if (entropy) memcpy(&__stack_chk_guard, entropy, sizeof(uintptr_t));9 if (entropy) memcpy(&__stack_chk_guard, entropy, sizeof(uintptr_t));
10 else __stack_chk_guard = (uintptr_t)&__stack_chk_guard * 1103515245;10 else __stack_chk_guard = (uintptr_t)&__stack_chk_guard * 1103515245;
1111
12#if UINTPTR_MAX >= 0xffffffffffffffff
13 /* Sacrifice 8 bits of entropy on 64bit to prevent leaking/
14 * overwriting the canary via string-manipulation functions.
15 * The NULL byte is on the second byte so that off-by-ones can
16 * still be detected. Endianness is taken care of
17 * automatically. */
18 ((char *)&__stack_chk_guard)[1] = 0;
19#endif
20
12 __pthread_self()->canary = __stack_chk_guard;21 __pthread_self()->canary = __stack_chk_guard;
13}22}
1423
lib/libc/wasi/libc-top-half/musl/src/errno/__strerror.h+6
...@@ -124,6 +124,12 @@ E(ENOMEDIUM, "No medium found")...@@ -124,6 +124,12 @@ E(ENOMEDIUM, "No medium found")
124E(EMEDIUMTYPE, "Wrong medium type")124E(EMEDIUMTYPE, "Wrong medium type")
125#endif125#endif
126E(EMULTIHOP, "Multihop attempted")126E(EMULTIHOP, "Multihop attempted")
127#ifdef __wasilibc_unmodified_upstream // errno value not in WASI
128E(ENOKEY, "Required key not available")
129E(EKEYEXPIRED, "Key has expired")
130E(EKEYREVOKED, "Key has been revoked")
131E(EKEYREJECTED, "Key was rejected by service")
132#endif
127#ifdef __wasilibc_unmodified_upstream // errno value in WASI and not musl133#ifdef __wasilibc_unmodified_upstream // errno value in WASI and not musl
128#else134#else
129// WASI adds this errno code.135// WASI adds this errno code.
lib/libc/wasi/libc-top-half/musl/src/fenv/powerpc/fenv-sf.c+1-1
...@@ -1,3 +1,3 @@...@@ -1,3 +1,3 @@
1#ifdef _SOFT_FLOAT1#if defined(_SOFT_FLOAT) || defined(__NO_FPRS__)
2#include "../fenv.c"2#include "../fenv.c"
3#endif3#endif
lib/libc/wasi/libc-top-half/musl/src/fenv/powerpc/fenv.S+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1#ifndef _SOFT_FLOAT1#if !defined(_SOFT_FLOAT) && !defined(__NO_FPRS__)
2.global feclearexcept2.global feclearexcept
3.type feclearexcept,@function3.type feclearexcept,@function
4feclearexcept:4feclearexcept:
lib/libc/wasi/libc-top-half/musl/src/include/stdlib.h+1
...@@ -8,6 +8,7 @@ hidden void __env_rm_add(char *, char *);...@@ -8,6 +8,7 @@ hidden void __env_rm_add(char *, char *);
8hidden int __mkostemps(char *, int, int);8hidden int __mkostemps(char *, int, int);
9hidden int __ptsname_r(int, char *, size_t);9hidden int __ptsname_r(int, char *, size_t);
10hidden char *__randname(char *);10hidden char *__randname(char *);
11hidden void __qsort_r (void *, size_t, size_t, int (*)(const void *, const void *, void *), void *);
1112
12hidden void *__libc_malloc(size_t);13hidden void *__libc_malloc(size_t);
13hidden void *__libc_malloc_impl(size_t);14hidden void *__libc_malloc_impl(size_t);
lib/libc/wasi/libc-top-half/musl/src/ldso/dl_iterate_phdr.c+2-1
...@@ -1,5 +1,6 @@...@@ -1,5 +1,6 @@
1#include <elf.h>1#include <elf.h>
2#include <link.h>2#include <link.h>
3#include "pthread_impl.h"
3#include "libc.h"4#include "libc.h"
45
5#define AUX_CNT 386#define AUX_CNT 38
...@@ -35,7 +36,7 @@ static int static_dl_iterate_phdr(int(*callback)(struct dl_phdr_info *info, size...@@ -35,7 +36,7 @@ static int static_dl_iterate_phdr(int(*callback)(struct dl_phdr_info *info, size
35 info.dlpi_subs = 0;36 info.dlpi_subs = 0;
36 if (tls_phdr) {37 if (tls_phdr) {
37 info.dlpi_tls_modid = 1;38 info.dlpi_tls_modid = 1;
38 info.dlpi_tls_data = (void *)(base + tls_phdr->p_vaddr);39 info.dlpi_tls_data = __tls_get_addr((tls_mod_off_t[]){1,0});
39 } else {40 } else {
40 info.dlpi_tls_modid = 0;41 info.dlpi_tls_modid = 0;
41 info.dlpi_tls_data = 0;42 info.dlpi_tls_data = 0;
lib/libc/wasi/libc-top-half/musl/src/legacy/cuserid.c+11-3
...@@ -2,13 +2,21 @@...@@ -2,13 +2,21 @@
2#include <pwd.h>2#include <pwd.h>
3#include <stdio.h>3#include <stdio.h>
4#include <unistd.h>4#include <unistd.h>
5#include <string.h>
56
6char *cuserid(char *buf)7char *cuserid(char *buf)
7{8{
9 static char usridbuf[L_cuserid];
8 struct passwd pw, *ppw;10 struct passwd pw, *ppw;
9 long pwb[256];11 long pwb[256];
10 if (getpwuid_r(geteuid(), &pw, (void *)pwb, sizeof pwb, &ppw))12 if (buf) *buf = 0;
11 return 0;13 getpwuid_r(geteuid(), &pw, (void *)pwb, sizeof pwb, &ppw);
12 snprintf(buf, L_cuserid, "%s", pw.pw_name);14 if (!ppw)
15 return buf;
16 size_t len = strnlen(pw.pw_name, L_cuserid);
17 if (len == L_cuserid)
18 return buf;
19 if (!buf) buf = usridbuf;
20 memcpy(buf, pw.pw_name, len+1);
13 return buf;21 return buf;
14}22}
lib/libc/wasi/libc-top-half/musl/src/linux/epoll.c+2-2
...@@ -24,9 +24,9 @@ int epoll_ctl(int fd, int op, int fd2, struct epoll_event *ev)...@@ -24,9 +24,9 @@ int epoll_ctl(int fd, int op, int fd2, struct epoll_event *ev)
2424
25int epoll_pwait(int fd, struct epoll_event *ev, int cnt, int to, const sigset_t *sigs)25int epoll_pwait(int fd, struct epoll_event *ev, int cnt, int to, const sigset_t *sigs)
26{26{
27 int r = __syscall(SYS_epoll_pwait, fd, ev, cnt, to, sigs, _NSIG/8);27 int r = __syscall_cp(SYS_epoll_pwait, fd, ev, cnt, to, sigs, _NSIG/8);
28#ifdef SYS_epoll_wait28#ifdef SYS_epoll_wait
29 if (r==-ENOSYS && !sigs) r = __syscall(SYS_epoll_wait, fd, ev, cnt, to);29 if (r==-ENOSYS && !sigs) r = __syscall_cp(SYS_epoll_wait, fd, ev, cnt, to);
30#endif30#endif
31 return __syscall_ret(r);31 return __syscall_ret(r);
32}32}
lib/libc/wasi/libc-top-half/musl/src/locale/dcngettext.c+3
...@@ -132,6 +132,9 @@ char *dcngettext(const char *domainname, const char *msgid1, const char *msgid2,...@@ -132,6 +132,9 @@ char *dcngettext(const char *domainname, const char *msgid1, const char *msgid2,
132 struct binding *q;132 struct binding *q;
133 int old_errno = errno;133 int old_errno = errno;
134134
135 /* match gnu gettext behaviour */
136 if (!msgid1) goto notrans;
137
135 if ((unsigned)category >= LC_ALL) goto notrans;138 if ((unsigned)category >= LC_ALL) goto notrans;
136139
137 if (!domainname) domainname = __gettextdomain();140 if (!domainname) domainname = __gettextdomain();
lib/libc/wasi/libc-top-half/musl/src/locale/duplocale.c+5
...@@ -3,6 +3,11 @@...@@ -3,6 +3,11 @@
3#include "locale_impl.h"3#include "locale_impl.h"
4#include "libc.h"4#include "libc.h"
55
6#define malloc __libc_malloc
7#define calloc undef
8#define realloc undef
9#define free undef
10
6locale_t __duplocale(locale_t old)11locale_t __duplocale(locale_t old)
7{12{
8 locale_t new = malloc(sizeof *new);13 locale_t new = malloc(sizeof *new);
lib/libc/wasi/libc-top-half/musl/src/locale/strtod_l.c created+22
...@@ -0,0 +1,22 @@
1#define _GNU_SOURCE
2#include <stdlib.h>
3#include <locale.h>
4
5float strtof_l(const char *restrict s, char **restrict p, locale_t l)
6{
7 return strtof(s, p);
8}
9
10double strtod_l(const char *restrict s, char **restrict p, locale_t l)
11{
12 return strtod(s, p);
13}
14
15long double strtold_l(const char *restrict s, char **restrict p, locale_t l)
16{
17 return strtold(s, p);
18}
19
20weak_alias(strtof_l, __strtof_l);
21weak_alias(strtod_l, __strtod_l);
22weak_alias(strtold_l, __strtold_l);
lib/libc/wasi/libc-top-half/musl/src/malloc/free.c+1-1
...@@ -2,5 +2,5 @@...@@ -2,5 +2,5 @@
22
3void free(void *p)3void free(void *p)
4{4{
5 return __libc_free(p);5 __libc_free(p);
6}6}
lib/libc/wasi/libc-top-half/musl/src/malloc/mallocng/aligned_alloc.c+3
...@@ -22,6 +22,9 @@ void *aligned_alloc(size_t align, size_t len)...@@ -22,6 +22,9 @@ void *aligned_alloc(size_t align, size_t len)
22 if (align <= UNIT) align = UNIT;22 if (align <= UNIT) align = UNIT;
2323
24 unsigned char *p = malloc(len + align - UNIT);24 unsigned char *p = malloc(len + align - UNIT);
25 if (!p)
26 return 0;
27
25 struct meta *g = get_meta(p);28 struct meta *g = get_meta(p);
26 int idx = get_slot_index(p);29 int idx = get_slot_index(p);
27 size_t stride = get_stride(g);30 size_t stride = get_stride(g);
lib/libc/wasi/libc-top-half/musl/src/malloc/mallocng/free.c+10-2
...@@ -119,7 +119,11 @@ void free(void *p)...@@ -119,7 +119,11 @@ void free(void *p)
119 if (((uintptr_t)(start-1) ^ (uintptr_t)end) >= 2*PGSZ && g->last_idx) {119 if (((uintptr_t)(start-1) ^ (uintptr_t)end) >= 2*PGSZ && g->last_idx) {
120 unsigned char *base = start + (-(uintptr_t)start & (PGSZ-1));120 unsigned char *base = start + (-(uintptr_t)start & (PGSZ-1));
121 size_t len = (end-base) & -PGSZ;121 size_t len = (end-base) & -PGSZ;
122 if (len) madvise(base, len, MADV_FREE);122 if (len) {
123 int e = errno;
124 madvise(base, len, MADV_FREE);
125 errno = e;
126 }
123 }127 }
124128
125 // atomic free without locking if this is neither first or last slot129 // atomic free without locking if this is neither first or last slot
...@@ -139,5 +143,9 @@ void free(void *p)...@@ -139,5 +143,9 @@ void free(void *p)
139 wrlock();143 wrlock();
140 struct mapinfo mi = nontrivial_free(g, idx);144 struct mapinfo mi = nontrivial_free(g, idx);
141 unlock();145 unlock();
142 if (mi.len) munmap(mi.base, mi.len);146 if (mi.len) {
147 int e = errno;
148 munmap(mi.base, mi.len);
149 errno = e;
150 }
143}151}
lib/libc/wasi/libc-top-half/musl/src/malloc/oldmalloc/malloc.c+5-1
...@@ -11,7 +11,7 @@...@@ -11,7 +11,7 @@
11#include "malloc_impl.h"11#include "malloc_impl.h"
12#include "fork_impl.h"12#include "fork_impl.h"
1313
14#define malloc __libc_malloc14#define malloc __libc_malloc_impl
15#define realloc __libc_realloc15#define realloc __libc_realloc
16#define free __libc_free16#define free __libc_free
1717
...@@ -481,12 +481,14 @@ void __bin_chunk(struct chunk *self)...@@ -481,12 +481,14 @@ void __bin_chunk(struct chunk *self)
481 if (size > RECLAIM && (size^(size-osize)) > size-osize) {481 if (size > RECLAIM && (size^(size-osize)) > size-osize) {
482 uintptr_t a = (uintptr_t)self + SIZE_ALIGN+PAGE_SIZE-1 & -PAGE_SIZE;482 uintptr_t a = (uintptr_t)self + SIZE_ALIGN+PAGE_SIZE-1 & -PAGE_SIZE;
483 uintptr_t b = (uintptr_t)next - SIZE_ALIGN & -PAGE_SIZE;483 uintptr_t b = (uintptr_t)next - SIZE_ALIGN & -PAGE_SIZE;
484 int e = errno;
484#if 1485#if 1
485 __madvise((void *)a, b-a, MADV_DONTNEED);486 __madvise((void *)a, b-a, MADV_DONTNEED);
486#else487#else
487 __mmap((void *)a, b-a, PROT_READ|PROT_WRITE,488 __mmap((void *)a, b-a, PROT_READ|PROT_WRITE,
488 MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED, -1, 0);489 MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED, -1, 0);
489#endif490#endif
491 errno = e;
490 }492 }
491493
492 unlock_bin(i);494 unlock_bin(i);
...@@ -499,7 +501,9 @@ static void unmap_chunk(struct chunk *self)...@@ -499,7 +501,9 @@ static void unmap_chunk(struct chunk *self)
499 size_t len = CHUNK_SIZE(self) + extra;501 size_t len = CHUNK_SIZE(self) + extra;
500 /* Crash on double free */502 /* Crash on double free */
501 if (extra & 1) a_crash();503 if (extra & 1) a_crash();
504 int e = errno;
502 __munmap(base, len);505 __munmap(base, len);
506 errno = e;
503}507}
504508
505void free(void *p)509void free(void *p)
lib/libc/wasi/libc-top-half/musl/src/math/acoshf.c+4-4
...@@ -15,12 +15,12 @@ float acoshf(float x)...@@ -15,12 +15,12 @@ float acoshf(float x)
15 uint32_t a = u.i & 0x7fffffff;15 uint32_t a = u.i & 0x7fffffff;
1616
17 if (a < 0x3f800000+(1<<23))17 if (a < 0x3f800000+(1<<23))
18 /* |x| < 2, invalid if x < 1 or nan */18 /* |x| < 2, invalid if x < 1 */
19 /* up to 2ulp error in [1,1.125] */19 /* up to 2ulp error in [1,1.125] */
20 return log1pf(x-1 + sqrtf((x-1)*(x-1)+2*(x-1)));20 return log1pf(x-1 + sqrtf((x-1)*(x-1)+2*(x-1)));
21 if (a < 0x3f800000+(12<<23))21 if (u.i < 0x3f800000+(12<<23))
22 /* |x| < 0x1p12 */22 /* 2 <= x < 0x1p12 */
23 return logf(2*x - 1/(x+sqrtf(x*x-1)));23 return logf(2*x - 1/(x+sqrtf(x*x-1)));
24 /* x >= 0x1p12 */24 /* x >= 0x1p12 or x <= -2 or nan */
25 return logf(x) + 0.693147180559945309417232121458176568f;25 return logf(x) + 0.693147180559945309417232121458176568f;
26}26}
lib/libc/wasi/libc-top-half/musl/src/math/expm1f.c+1-2
...@@ -16,7 +16,6 @@...@@ -16,7 +16,6 @@
16#include "libm.h"16#include "libm.h"
1717
18static const float18static const float
19o_threshold = 8.8721679688e+01, /* 0x42b17180 */
20ln2_hi = 6.9313812256e-01, /* 0x3f317180 */19ln2_hi = 6.9313812256e-01, /* 0x3f317180 */
21ln2_lo = 9.0580006145e-06, /* 0x3717f7d1 */20ln2_lo = 9.0580006145e-06, /* 0x3717f7d1 */
22invln2 = 1.4426950216e+00, /* 0x3fb8aa3b */21invln2 = 1.4426950216e+00, /* 0x3fb8aa3b */
...@@ -41,7 +40,7 @@ float expm1f(float x)...@@ -41,7 +40,7 @@ float expm1f(float x)
41 return x;40 return x;
42 if (sign)41 if (sign)
43 return -1;42 return -1;
44 if (x > o_threshold) {43 if (hx > 0x42b17217) { /* x > log(FLT_MAX) */
45 x *= 0x1p127f;44 x *= 0x1p127f;
46 return x;45 return x;
47 }46 }
lib/libc/wasi/libc-top-half/musl/src/math/fmaf.c+10-15
...@@ -77,21 +77,16 @@ float fmaf(float x, float y, float z)...@@ -77,21 +77,16 @@ float fmaf(float x, float y, float z)
77 * If result is inexact, and exactly halfway between two float values,77 * If result is inexact, and exactly halfway between two float values,
78 * we need to adjust the low-order bit in the direction of the error.78 * we need to adjust the low-order bit in the direction of the error.
79 */79 */
80#ifdef FE_TOWARDZERO80 double err;
81 fesetround(FE_TOWARDZERO);81 int neg = u.i >> 63;
82#endif82 if (neg == (z > xy))
83#ifdef __wasilibc_unmodified_upstream // WASI doesn't need old GCC workarounds83 err = xy - result + z;
84 volatile double vxy = xy; /* XXX work around gcc CSE bug */84 else
85#else85 err = z - result + xy;
86 double vxy = xy;86 if (neg == (err < 0))
87#endif
88 double adjusted_result = vxy + z;
89 fesetround(FE_TONEAREST);
90 if (result == adjusted_result) {
91 u.f = adjusted_result;
92 u.i++;87 u.i++;
93 adjusted_result = u.f;88 else
94 }89 u.i--;
95 z = adjusted_result;90 z = u.f;
96 return z;91 return z;
97}92}
lib/libc/wasi/libc-top-half/musl/src/math/powerpc/fabs.c+1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1#include <math.h>1#include <math.h>
22
3#if defined(_SOFT_FLOAT) || defined(BROKEN_PPC_D_ASM)3#if defined(_SOFT_FLOAT) || defined(__NO_FPRS__) || defined(BROKEN_PPC_D_ASM)
44
5#include "../fabs.c"5#include "../fabs.c"
66
lib/libc/wasi/libc-top-half/musl/src/math/powerpc/fabsf.c+1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1#include <math.h>1#include <math.h>
22
3#ifdef _SOFT_FLOAT3#if defined(_SOFT_FLOAT) || defined(__NO_FPRS__)
44
5#include "../fabsf.c"5#include "../fabsf.c"
66
lib/libc/wasi/libc-top-half/musl/src/math/powerpc/fma.c+1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1#include <math.h>1#include <math.h>
22
3#if defined(_SOFT_FLOAT) || defined(BROKEN_PPC_D_ASM)3#if defined(_SOFT_FLOAT) || defined(__NO_FPRS__) || defined(BROKEN_PPC_D_ASM)
44
5#include "../fma.c"5#include "../fma.c"
66
lib/libc/wasi/libc-top-half/musl/src/math/powerpc/fmaf.c+1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1#include <math.h>1#include <math.h>
22
3#ifdef _SOFT_FLOAT3#if defined(_SOFT_FLOAT) || defined(__NO_FPRS__)
44
5#include "../fmaf.c"5#include "../fmaf.c"
66
lib/libc/wasi/libc-top-half/musl/src/misc/ioctl.c+7-2
...@@ -6,6 +6,7 @@...@@ -6,6 +6,7 @@
6#include <stddef.h>6#include <stddef.h>
7#include <stdint.h>7#include <stdint.h>
8#include <string.h>8#include <string.h>
9#include <endian.h>
9#include "syscall.h"10#include "syscall.h"
1011
11#define alignof(t) offsetof(struct { char c; t x; }, x)12#define alignof(t) offsetof(struct { char c; t x; }, x)
...@@ -53,7 +54,7 @@ static const struct ioctl_compat_map compat_map[] = {...@@ -53,7 +54,7 @@ static const struct ioctl_compat_map compat_map[] = {
53 { _IOWR('A', 0x23, char[136]), _IOWR('A', 0x23, char[132]), 0, WR, 1, 0 },54 { _IOWR('A', 0x23, char[136]), _IOWR('A', 0x23, char[132]), 0, WR, 1, 0 },
54 { 0, 0, 4, WR, 1, 0 }, /* snd_pcm_sync_ptr (flags only) */55 { 0, 0, 4, WR, 1, 0 }, /* snd_pcm_sync_ptr (flags only) */
55 { 0, 0, 32, WR, 1, OFFS(8,12,16,24,28) }, /* snd_pcm_mmap_status */56 { 0, 0, 32, WR, 1, OFFS(8,12,16,24,28) }, /* snd_pcm_mmap_status */
56 { 0, 0, 8, WR, 1, OFFS(0,4) }, /* snd_pcm_mmap_control */57 { 0, 0, 4, WR, 1, 0 }, /* snd_pcm_mmap_control (each member) */
5758
58 /* VIDIOC_QUERYBUF, VIDIOC_QBUF, VIDIOC_DQBUF, VIDIOC_PREPARE_BUF */59 /* VIDIOC_QUERYBUF, VIDIOC_QBUF, VIDIOC_DQBUF, VIDIOC_PREPARE_BUF */
59 { _IOWR('V', 9, new_misaligned(68)), _IOWR('V', 9, char[68]), 68, WR, 1, OFFS(20, 24) },60 { _IOWR('V', 9, new_misaligned(68)), _IOWR('V', 9, char[68]), 68, WR, 1, OFFS(20, 24) },
...@@ -90,7 +91,11 @@ static void convert_ioctl_struct(const struct ioctl_compat_map *map, char *old,...@@ -90,7 +91,11 @@ static void convert_ioctl_struct(const struct ioctl_compat_map *map, char *old,
90 * if another exception appears this needs changing. */91 * if another exception appears this needs changing. */
91 convert_ioctl_struct(map+1, old, new, dir);92 convert_ioctl_struct(map+1, old, new, dir);
92 convert_ioctl_struct(map+2, old+4, new+8, dir);93 convert_ioctl_struct(map+2, old+4, new+8, dir);
93 convert_ioctl_struct(map+3, old+68, new+72, dir);94 /* snd_pcm_mmap_control, special-cased due to kernel
95 * type definition having been botched. */
96 int adj = BYTE_ORDER==BIG_ENDIAN ? 4 : 0;
97 convert_ioctl_struct(map+3, old+68, new+72+adj, dir);
98 convert_ioctl_struct(map+3, old+72, new+76+3*adj, dir);
94 return;99 return;
95 }100 }
96 for (int i=0; i < map->noffs; i++) {101 for (int i=0; i < map->noffs; i++) {
lib/libc/wasi/libc-top-half/musl/src/passwd/nscd_query.c+9-1
...@@ -40,7 +40,15 @@ retry:...@@ -40,7 +40,15 @@ retry:
40 buf[0] = NSCDVERSION;40 buf[0] = NSCDVERSION;
4141
42 fd = socket(PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);42 fd = socket(PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
43 if (fd < 0) return NULL;43 if (fd < 0) {
44 if (errno == EAFNOSUPPORT) {
45 f = fopen("/dev/null", "re");
46 if (f)
47 errno = errno_save;
48 return f;
49 }
50 return 0;
51 }
4452
45 if(!(f = fdopen(fd, "r"))) {53 if(!(f = fdopen(fd, "r"))) {
46 close(fd);54 close(fd);
lib/libc/wasi/libc-top-half/musl/src/process/fdop.h+5
...@@ -10,3 +10,8 @@ struct fdop {...@@ -10,3 +10,8 @@ struct fdop {
10 mode_t mode;10 mode_t mode;
11 char path[];11 char path[];
12};12};
13
14#define malloc __libc_malloc
15#define calloc __libc_calloc
16#define realloc undef
17#define free __libc_free
lib/libc/wasi/libc-top-half/musl/src/process/posix_spawn_file_actions_addclose.c+1
...@@ -5,6 +5,7 @@...@@ -5,6 +5,7 @@
55
6int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *fa, int fd)6int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *fa, int fd)
7{7{
8 if (fd < 0) return EBADF;
8 struct fdop *op = malloc(sizeof *op);9 struct fdop *op = malloc(sizeof *op);
9 if (!op) return ENOMEM;10 if (!op) return ENOMEM;
10 op->cmd = FDOP_CLOSE;11 op->cmd = FDOP_CLOSE;
lib/libc/wasi/libc-top-half/musl/src/process/posix_spawn_file_actions_adddup2.c+1
...@@ -5,6 +5,7 @@...@@ -5,6 +5,7 @@
55
6int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *fa, int srcfd, int fd)6int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *fa, int srcfd, int fd)
7{7{
8 if (srcfd < 0 || fd < 0) return EBADF;
8 struct fdop *op = malloc(sizeof *op);9 struct fdop *op = malloc(sizeof *op);
9 if (!op) return ENOMEM;10 if (!op) return ENOMEM;
10 op->cmd = FDOP_DUP2;11 op->cmd = FDOP_DUP2;
lib/libc/wasi/libc-top-half/musl/src/process/posix_spawn_file_actions_addfchdir.c+1
...@@ -6,6 +6,7 @@...@@ -6,6 +6,7 @@
66
7int posix_spawn_file_actions_addfchdir_np(posix_spawn_file_actions_t *fa, int fd)7int posix_spawn_file_actions_addfchdir_np(posix_spawn_file_actions_t *fa, int fd)
8{8{
9 if (fd < 0) return EBADF;
9 struct fdop *op = malloc(sizeof *op);10 struct fdop *op = malloc(sizeof *op);
10 if (!op) return ENOMEM;11 if (!op) return ENOMEM;
11 op->cmd = FDOP_FCHDIR;12 op->cmd = FDOP_FCHDIR;
lib/libc/wasi/libc-top-half/musl/src/process/posix_spawn_file_actions_addopen.c+1
...@@ -6,6 +6,7 @@...@@ -6,6 +6,7 @@
66
7int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *restrict fa, int fd, const char *restrict path, int flags, mode_t mode)7int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *restrict fa, int fd, const char *restrict path, int flags, mode_t mode)
8{8{
9 if (fd < 0) return EBADF;
9 struct fdop *op = malloc(sizeof *op + strlen(path) + 1);10 struct fdop *op = malloc(sizeof *op + strlen(path) + 1);
10 if (!op) return ENOMEM;11 if (!op) return ENOMEM;
11 op->cmd = FDOP_OPEN;12 op->cmd = FDOP_OPEN;
lib/libc/wasi/libc-top-half/musl/src/setjmp/powerpc/longjmp.S+31-1
...@@ -37,7 +37,37 @@ longjmp:...@@ -37,7 +37,37 @@ longjmp:
37 lwz 29, 72(3)37 lwz 29, 72(3)
38 lwz 30, 76(3)38 lwz 30, 76(3)
39 lwz 31, 80(3)39 lwz 31, 80(3)
40#ifndef _SOFT_FLOAT40#if defined(_SOFT_FLOAT) || defined(__NO_FPRS__)
41 mflr 0
42 bl 1f
43 .hidden __hwcap
44 .long __hwcap-.
451: mflr 4
46 lwz 5, 0(4)
47 lwzx 4, 4, 5
48 andis. 4, 4, 0x80
49 beq 1f
50 .long 0x11c35b01 /* evldd 14,88(3) */
51 .long 0x11e36301 /* ... */
52 .long 0x12036b01
53 .long 0x12237301
54 .long 0x12437b01
55 .long 0x12638301
56 .long 0x12838b01
57 .long 0x12a39301
58 .long 0x12c39b01
59 .long 0x12e3a301
60 .long 0x1303ab01
61 .long 0x1323b301
62 .long 0x1343bb01
63 .long 0x1363c301
64 .long 0x1383cb01
65 .long 0x13a3d301
66 .long 0x13c3db01
67 .long 0x13e3e301 /* evldd 31,224(3) */
68 .long 0x11a3eb01 /* evldd 13,232(3) */
691: mtlr 0
70#else
41 lfd 14,88(3)71 lfd 14,88(3)
42 lfd 15,96(3)72 lfd 15,96(3)
43 lfd 16,104(3)73 lfd 16,104(3)
lib/libc/wasi/libc-top-half/musl/src/setjmp/powerpc/setjmp.S+31-1
...@@ -37,7 +37,37 @@ setjmp:...@@ -37,7 +37,37 @@ setjmp:
37 stw 29, 72(3)37 stw 29, 72(3)
38 stw 30, 76(3)38 stw 30, 76(3)
39 stw 31, 80(3)39 stw 31, 80(3)
40#ifndef _SOFT_FLOAT40#if defined(_SOFT_FLOAT) || defined(__NO_FPRS__)
41 mflr 0
42 bl 1f
43 .hidden __hwcap
44 .long __hwcap-.
451: mflr 4
46 lwz 5, 0(4)
47 lwzx 4, 4, 5
48 andis. 4, 4, 0x80
49 beq 1f
50 .long 0x11c35b21 /* evstdd 14,88(3) */
51 .long 0x11e36321 /* ... */
52 .long 0x12036b21
53 .long 0x12237321
54 .long 0x12437b21
55 .long 0x12638321
56 .long 0x12838b21
57 .long 0x12a39321
58 .long 0x12c39b21
59 .long 0x12e3a321
60 .long 0x1303ab21
61 .long 0x1323b321
62 .long 0x1343bb21
63 .long 0x1363c321
64 .long 0x1383cb21
65 .long 0x13a3d321
66 .long 0x13c3db21
67 .long 0x13e3e321 /* evstdd 31,224(3) */
68 .long 0x11a3eb21 /* evstdd 13,232(3) */
691: mtlr 0
70#else
41 stfd 14,88(3)71 stfd 14,88(3)
42 stfd 15,96(3)72 stfd 15,96(3)
43 stfd 16,104(3)73 stfd 16,104(3)
lib/libc/wasi/libc-top-half/musl/src/signal/block.c+2-2
...@@ -3,9 +3,9 @@...@@ -3,9 +3,9 @@
3#include <signal.h>3#include <signal.h>
44
5static const unsigned long all_mask[] = {5static const unsigned long all_mask[] = {
6#if ULONG_MAX == 0xffffffff && _NSIG == 1296#if ULONG_MAX == 0xffffffff && _NSIG > 65
7 -1UL, -1UL, -1UL, -1UL7 -1UL, -1UL, -1UL, -1UL
8#elif ULONG_MAX == 0xffffffff8#elif ULONG_MAX == 0xffffffff || _NSIG > 65
9 -1UL, -1UL9 -1UL, -1UL
10#else10#else
11 -1UL11 -1UL
lib/libc/wasi/libc-top-half/musl/src/stat/futimesat.c+9
...@@ -2,7 +2,9 @@...@@ -2,7 +2,9 @@
2#include <sys/time.h>2#include <sys/time.h>
3#include <sys/stat.h>3#include <sys/stat.h>
4#include <errno.h>4#include <errno.h>
5#ifdef __wasilibc_unmodified_upstream // WASI has no syscall
5#include "syscall.h"6#include "syscall.h"
7#endif
68
7int __futimesat(int dirfd, const char *pathname, const struct timeval times[2])9int __futimesat(int dirfd, const char *pathname, const struct timeval times[2])
8{10{
...@@ -10,8 +12,15 @@ int __futimesat(int dirfd, const char *pathname, const struct timeval times[2])...@@ -10,8 +12,15 @@ int __futimesat(int dirfd, const char *pathname, const struct timeval times[2])
10 if (times) {12 if (times) {
11 int i;13 int i;
12 for (i=0; i<2; i++) {14 for (i=0; i<2; i++) {
15#ifdef __wasilibc_unmodified_upstream // WASI has no syscall
13 if (times[i].tv_usec >= 1000000ULL)16 if (times[i].tv_usec >= 1000000ULL)
14 return __syscall_ret(-EINVAL);17 return __syscall_ret(-EINVAL);
18#else
19 if (times[i].tv_usec >= 1000000ULL) {
20 errno = EINVAL;
21 return -1;
22 }
23#endif
15 ts[i].tv_sec = times[i].tv_sec;24 ts[i].tv_sec = times[i].tv_sec;
16 ts[i].tv_nsec = times[i].tv_usec * 1000;25 ts[i].tv_nsec = times[i].tv_usec * 1000;
17 }26 }
lib/libc/wasi/libc-top-half/musl/src/stdio/fgetws.c+1-6
...@@ -1,6 +1,5 @@...@@ -1,6 +1,5 @@
1#include "stdio_impl.h"1#include "stdio_impl.h"
2#include <wchar.h>2#include <wchar.h>
3#include <errno.h>
43
5wint_t __fgetwc_unlocked(FILE *);4wint_t __fgetwc_unlocked(FILE *);
65
...@@ -12,10 +11,6 @@ wchar_t *fgetws(wchar_t *restrict s, int n, FILE *restrict f)...@@ -12,10 +11,6 @@ wchar_t *fgetws(wchar_t *restrict s, int n, FILE *restrict f)
1211
13 FLOCK(f);12 FLOCK(f);
1413
15 /* Setup a dummy errno so we can detect EILSEQ. This is
16 * the only way to catch encoding errors in the form of a
17 * partial character just before EOF. */
18 errno = EAGAIN;
19 for (; n; n--) {14 for (; n; n--) {
20 wint_t c = __fgetwc_unlocked(f);15 wint_t c = __fgetwc_unlocked(f);
21 if (c == WEOF) break;16 if (c == WEOF) break;
...@@ -23,7 +18,7 @@ wchar_t *fgetws(wchar_t *restrict s, int n, FILE *restrict f)...@@ -23,7 +18,7 @@ wchar_t *fgetws(wchar_t *restrict s, int n, FILE *restrict f)
23 if (c == '\n') break;18 if (c == '\n') break;
24 }19 }
25 *p = 0;20 *p = 0;
26 if (ferror(f) || errno==EILSEQ) p = s;21 if (ferror(f)) p = s;
2722
28 FUNLOCK(f);23 FUNLOCK(f);
2924
lib/libc/wasi/libc-top-half/musl/src/stdio/fseek.c+7
...@@ -1,7 +1,14 @@...@@ -1,7 +1,14 @@
1#include "stdio_impl.h"1#include "stdio_impl.h"
2#include <errno.h>
23
3int __fseeko_unlocked(FILE *f, off_t off, int whence)4int __fseeko_unlocked(FILE *f, off_t off, int whence)
4{5{
6 /* Fail immediately for invalid whence argument. */
7 if (whence != SEEK_CUR && whence != SEEK_SET && whence != SEEK_END) {
8 errno = EINVAL;
9 return -1;
10 }
11
5 /* Adjust relative offset for unread data in buffer, if any. */12 /* Adjust relative offset for unread data in buffer, if any. */
6 if (whence == SEEK_CUR && f->rend) off -= f->rend - f->rpos;13 if (whence == SEEK_CUR && f->rend) off -= f->rend - f->rpos;
714
lib/libc/wasi/libc-top-half/musl/src/stdio/getdelim.c+5-3
...@@ -55,9 +55,11 @@ ssize_t getdelim(char **restrict s, size_t *restrict n, int delim, FILE *restric...@@ -55,9 +55,11 @@ ssize_t getdelim(char **restrict s, size_t *restrict n, int delim, FILE *restric
55 *s = tmp;55 *s = tmp;
56 *n = m;56 *n = m;
57 }57 }
58 memcpy(*s+i, f->rpos, k);58 if (k) {
59 f->rpos += k;59 memcpy(*s+i, f->rpos, k);
60 i += k;60 f->rpos += k;
61 i += k;
62 }
61 if (z) break;63 if (z) break;
62 if ((c = getc_unlocked(f)) == EOF) {64 if ((c = getc_unlocked(f)) == EOF) {
63 if (!i || !feof(f)) {65 if (!i || !feof(f)) {
lib/libc/wasi/libc-top-half/musl/src/stdio/popen.c+6-18
...@@ -31,25 +31,12 @@ FILE *popen(const char *cmd, const char *mode)...@@ -31,25 +31,12 @@ FILE *popen(const char *cmd, const char *mode)
31 __syscall(SYS_close, p[1]);31 __syscall(SYS_close, p[1]);
32 return NULL;32 return NULL;
33 }33 }
34 FLOCK(f);
35
36 /* If the child's end of the pipe happens to already be on the final
37 * fd number to which it will be assigned (either 0 or 1), it must
38 * be moved to a different fd. Otherwise, there is no safe way to
39 * remove the close-on-exec flag in the child without also creating
40 * a file descriptor leak race condition in the parent. */
41 if (p[1-op] == 1-op) {
42 int tmp = fcntl(1-op, F_DUPFD_CLOEXEC, 0);
43 if (tmp < 0) {
44 e = errno;
45 goto fail;
46 }
47 __syscall(SYS_close, p[1-op]);
48 p[1-op] = tmp;
49 }
5034
51 e = ENOMEM;35 e = ENOMEM;
52 if (!posix_spawn_file_actions_init(&fa)) {36 if (!posix_spawn_file_actions_init(&fa)) {
37 for (FILE *l = *__ofl_lock(); l; l=l->next)
38 if (l->pipe_pid && posix_spawn_file_actions_addclose(&fa, l->fd))
39 goto fail;
53 if (!posix_spawn_file_actions_adddup2(&fa, p[1-op], 1-op)) {40 if (!posix_spawn_file_actions_adddup2(&fa, p[1-op], 1-op)) {
54 if (!(e = posix_spawn(&pid, "/bin/sh", &fa, 0,41 if (!(e = posix_spawn(&pid, "/bin/sh", &fa, 0,
55 (char *[]){ "sh", "-c", (char *)cmd, 0 }, __environ))) {42 (char *[]){ "sh", "-c", (char *)cmd, 0 }, __environ))) {
...@@ -58,13 +45,14 @@ FILE *popen(const char *cmd, const char *mode)...@@ -58,13 +45,14 @@ FILE *popen(const char *cmd, const char *mode)
58 if (!strchr(mode, 'e'))45 if (!strchr(mode, 'e'))
59 fcntl(p[op], F_SETFD, 0);46 fcntl(p[op], F_SETFD, 0);
60 __syscall(SYS_close, p[1-op]);47 __syscall(SYS_close, p[1-op]);
61 FUNLOCK(f);48 __ofl_unlock();
62 return f;49 return f;
63 }50 }
64 }51 }
52fail:
53 __ofl_unlock();
65 posix_spawn_file_actions_destroy(&fa);54 posix_spawn_file_actions_destroy(&fa);
66 }55 }
67fail:
68 fclose(f);56 fclose(f);
69 __syscall(SYS_close, p[1-op]);57 __syscall(SYS_close, p[1-op]);
7058
lib/libc/wasi/libc-top-half/musl/src/stdlib/qsort.c+20-17
...@@ -24,6 +24,7 @@...@@ -24,6 +24,7 @@
24/* Smoothsort, an adaptive variant of Heapsort. Memory usage: O(1).24/* Smoothsort, an adaptive variant of Heapsort. Memory usage: O(1).
25 Run time: Worst case O(n log n), close to O(n) in the mostly-sorted case. */25 Run time: Worst case O(n log n), close to O(n) in the mostly-sorted case. */
2626
27#define _BSD_SOURCE
27#include <stdint.h>28#include <stdint.h>
28#include <stdlib.h>29#include <stdlib.h>
29#include <string.h>30#include <string.h>
...@@ -31,7 +32,7 @@...@@ -31,7 +32,7 @@
31#include "atomic.h"32#include "atomic.h"
32#define ntz(x) a_ctz_l((x))33#define ntz(x) a_ctz_l((x))
3334
34typedef int (*cmpfun)(const void *, const void *);35typedef int (*cmpfun)(const void *, const void *, void *);
3536
36static inline int pntz(size_t p[2]) {37static inline int pntz(size_t p[2]) {
37 int r = ntz(p[0] - 1);38 int r = ntz(p[0] - 1);
...@@ -88,7 +89,7 @@ static inline void shr(size_t p[2], int n)...@@ -88,7 +89,7 @@ static inline void shr(size_t p[2], int n)
88 p[1] >>= n;89 p[1] >>= n;
89}90}
9091
91static void sift(unsigned char *head, size_t width, cmpfun cmp, int pshift, size_t lp[])92static void sift(unsigned char *head, size_t width, cmpfun cmp, void *arg, int pshift, size_t lp[])
92{93{
93 unsigned char *rt, *lf;94 unsigned char *rt, *lf;
94 unsigned char *ar[14 * sizeof(size_t) + 1];95 unsigned char *ar[14 * sizeof(size_t) + 1];
...@@ -99,10 +100,10 @@ static void sift(unsigned char *head, size_t width, cmpfun cmp, int pshift, size...@@ -99,10 +100,10 @@ static void sift(unsigned char *head, size_t width, cmpfun cmp, int pshift, size
99 rt = head - width;100 rt = head - width;
100 lf = head - width - lp[pshift - 2];101 lf = head - width - lp[pshift - 2];
101102
102 if((*cmp)(ar[0], lf) >= 0 && (*cmp)(ar[0], rt) >= 0) {103 if(cmp(ar[0], lf, arg) >= 0 && cmp(ar[0], rt, arg) >= 0) {
103 break;104 break;
104 }105 }
105 if((*cmp)(lf, rt) >= 0) {106 if(cmp(lf, rt, arg) >= 0) {
106 ar[i++] = lf;107 ar[i++] = lf;
107 head = lf;108 head = lf;
108 pshift -= 1;109 pshift -= 1;
...@@ -115,7 +116,7 @@ static void sift(unsigned char *head, size_t width, cmpfun cmp, int pshift, size...@@ -115,7 +116,7 @@ static void sift(unsigned char *head, size_t width, cmpfun cmp, int pshift, size
115 cycle(width, ar, i);116 cycle(width, ar, i);
116}117}
117118
118static void trinkle(unsigned char *head, size_t width, cmpfun cmp, size_t pp[2], int pshift, int trusty, size_t lp[])119static void trinkle(unsigned char *head, size_t width, cmpfun cmp, void *arg, size_t pp[2], int pshift, int trusty, size_t lp[])
119{120{
120 unsigned char *stepson,121 unsigned char *stepson,
121 *rt, *lf;122 *rt, *lf;
...@@ -130,13 +131,13 @@ static void trinkle(unsigned char *head, size_t width, cmpfun cmp, size_t pp[2],...@@ -130,13 +131,13 @@ static void trinkle(unsigned char *head, size_t width, cmpfun cmp, size_t pp[2],
130 ar[0] = head;131 ar[0] = head;
131 while(p[0] != 1 || p[1] != 0) {132 while(p[0] != 1 || p[1] != 0) {
132 stepson = head - lp[pshift];133 stepson = head - lp[pshift];
133 if((*cmp)(stepson, ar[0]) <= 0) {134 if(cmp(stepson, ar[0], arg) <= 0) {
134 break;135 break;
135 }136 }
136 if(!trusty && pshift > 1) {137 if(!trusty && pshift > 1) {
137 rt = head - width;138 rt = head - width;
138 lf = head - width - lp[pshift - 2];139 lf = head - width - lp[pshift - 2];
139 if((*cmp)(rt, stepson) >= 0 || (*cmp)(lf, stepson) >= 0) {140 if(cmp(rt, stepson, arg) >= 0 || cmp(lf, stepson, arg) >= 0) {
140 break;141 break;
141 }142 }
142 }143 }
...@@ -150,11 +151,11 @@ static void trinkle(unsigned char *head, size_t width, cmpfun cmp, size_t pp[2],...@@ -150,11 +151,11 @@ static void trinkle(unsigned char *head, size_t width, cmpfun cmp, size_t pp[2],
150 }151 }
151 if(!trusty) {152 if(!trusty) {
152 cycle(width, ar, i);153 cycle(width, ar, i);
153 sift(head, width, cmp, pshift, lp);154 sift(head, width, cmp, arg, pshift, lp);
154 }155 }
155}156}
156157
157void qsort(void *base, size_t nel, size_t width, cmpfun cmp)158void __qsort_r(void *base, size_t nel, size_t width, cmpfun cmp, void *arg)
158{159{
159 size_t lp[12*sizeof(size_t)];160 size_t lp[12*sizeof(size_t)];
160 size_t i, size = width * nel;161 size_t i, size = width * nel;
...@@ -173,16 +174,16 @@ void qsort(void *base, size_t nel, size_t width, cmpfun cmp)...@@ -173,16 +174,16 @@ void qsort(void *base, size_t nel, size_t width, cmpfun cmp)
173174
174 while(head < high) {175 while(head < high) {
175 if((p[0] & 3) == 3) {176 if((p[0] & 3) == 3) {
176 sift(head, width, cmp, pshift, lp);177 sift(head, width, cmp, arg, pshift, lp);
177 shr(p, 2);178 shr(p, 2);
178 pshift += 2;179 pshift += 2;
179 } else {180 } else {
180 if(lp[pshift - 1] >= high - head) {181 if(lp[pshift - 1] >= high - head) {
181 trinkle(head, width, cmp, p, pshift, 0, lp);182 trinkle(head, width, cmp, arg, p, pshift, 0, lp);
182 } else {183 } else {
183 sift(head, width, cmp, pshift, lp);184 sift(head, width, cmp, arg, pshift, lp);
184 }185 }
185 186
186 if(pshift == 1) {187 if(pshift == 1) {
187 shl(p, 1);188 shl(p, 1);
188 pshift = 0;189 pshift = 0;
...@@ -191,12 +192,12 @@ void qsort(void *base, size_t nel, size_t width, cmpfun cmp)...@@ -191,12 +192,12 @@ void qsort(void *base, size_t nel, size_t width, cmpfun cmp)
191 pshift = 1;192 pshift = 1;
192 }193 }
193 }194 }
194 195
195 p[0] |= 1;196 p[0] |= 1;
196 head += width;197 head += width;
197 }198 }
198199
199 trinkle(head, width, cmp, p, pshift, 0, lp);200 trinkle(head, width, cmp, arg, p, pshift, 0, lp);
200201
201 while(pshift != 1 || p[0] != 1 || p[1] != 0) {202 while(pshift != 1 || p[0] != 1 || p[1] != 0) {
202 if(pshift <= 1) {203 if(pshift <= 1) {
...@@ -208,11 +209,13 @@ void qsort(void *base, size_t nel, size_t width, cmpfun cmp)...@@ -208,11 +209,13 @@ void qsort(void *base, size_t nel, size_t width, cmpfun cmp)
208 pshift -= 2;209 pshift -= 2;
209 p[0] ^= 7;210 p[0] ^= 7;
210 shr(p, 1);211 shr(p, 1);
211 trinkle(head - lp[pshift] - width, width, cmp, p, pshift + 1, 1, lp);212 trinkle(head - lp[pshift] - width, width, cmp, arg, p, pshift + 1, 1, lp);
212 shl(p, 1);213 shl(p, 1);
213 p[0] |= 1;214 p[0] |= 1;
214 trinkle(head - width, width, cmp, p, pshift, 1, lp);215 trinkle(head - width, width, cmp, arg, p, pshift, 1, lp);
215 }216 }
216 head -= width;217 head -= width;
217 }218 }
218}219}
220
221weak_alias(__qsort_r, qsort_r);
lib/libc/wasi/libc-top-half/musl/src/stdlib/qsort_nr.c created+14
...@@ -0,0 +1,14 @@
1#define _BSD_SOURCE
2#include <stdlib.h>
3
4typedef int (*cmpfun)(const void *, const void *);
5
6static int wrapper_cmp(const void *v1, const void *v2, void *cmp)
7{
8 return ((cmpfun)cmp)(v1, v2);
9}
10
11void qsort(void *base, size_t nel, size_t width, cmpfun cmp)
12{
13 __qsort_r(base, nel, width, wrapper_cmp, cmp);
14}
lib/libc/wasi/libc-top-half/musl/src/stdlib/strtod.c-21
...@@ -46,24 +46,3 @@ long double strtold(const char *restrict s, char **restrict p)...@@ -46,24 +46,3 @@ long double strtold(const char *restrict s, char **restrict p)
46 return strtox(s, p, 2);46 return strtox(s, p, 2);
47#endif47#endif
48}48}
49
50#ifdef __wasilibc_unmodified_upstream // WASI doesn't support signature-changing aliases
51weak_alias(strtof, strtof_l);
52weak_alias(strtod, strtod_l);
53weak_alias(strtold, strtold_l);
54weak_alias(strtof, __strtof_l);
55weak_alias(strtod, __strtod_l);
56weak_alias(strtold, __strtold_l);
57#else
58// WebAssembly doesn't permit signature-changing aliases, so use wrapper
59// functions instead.
60weak float strtof_l(const char *restrict s, char **restrict p, locale_t loc) {
61 return strtof(s, p);
62}
63weak double strtod_l(const char *restrict s, char **restrict p, locale_t loc) {
64 return strtod(s, p);
65}
66weak long double strtold_l(const char *restrict s, char **restrict p, locale_t loc) {
67 return strtold(s, p);
68}
69#endif
lib/libc/wasi/libc-top-half/musl/src/thread/pthread_getname_np.c created+25
...@@ -0,0 +1,25 @@
1#define _GNU_SOURCE
2#include <fcntl.h>
3#include <unistd.h>
4#include <sys/prctl.h>
5
6#include "pthread_impl.h"
7
8int pthread_getname_np(pthread_t thread, char *name, size_t len)
9{
10 int fd, cs, status = 0;
11 char f[sizeof "/proc/self/task//comm" + 3*sizeof(int)];
12
13 if (len < 16) return ERANGE;
14
15 if (thread == pthread_self())
16 return prctl(PR_GET_NAME, (unsigned long)name, 0UL, 0UL, 0UL) ? errno : 0;
17
18 snprintf(f, sizeof f, "/proc/self/task/%d/comm", thread->tid);
19 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
20 if ((fd = open(f, O_RDONLY|O_CLOEXEC)) < 0 || (len = read(fd, name, len)) == -1) status = errno;
21 else name[len-1] = 0; /* remove trailing new line only if successful */
22 if (fd >= 0) close(fd);
23 pthread_setcancelstate(cs, 0);
24 return status;
25}
lib/libc/wasi/libc-top-half/musl/src/thread/pthread_setname_np.c+1-1
...@@ -19,7 +19,7 @@ int pthread_setname_np(pthread_t thread, const char *name)...@@ -19,7 +19,7 @@ int pthread_setname_np(pthread_t thread, const char *name)
1919
20 snprintf(f, sizeof f, "/proc/self/task/%d/comm", thread->tid);20 snprintf(f, sizeof f, "/proc/self/task/%d/comm", thread->tid);
21 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);21 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
22 if ((fd = open(f, O_WRONLY)) < 0 || write(fd, name, len) < 0) status = errno;22 if ((fd = open(f, O_WRONLY|O_CLOEXEC)) < 0 || write(fd, name, len) < 0) status = errno;
23 if (fd >= 0) close(fd);23 if (fd >= 0) close(fd);
24 pthread_setcancelstate(cs, 0);24 pthread_setcancelstate(cs, 0);
25 return status;25 return status;
lib/libc/wasi/libc-top-half/musl/src/time/__tz.c+25-15
...@@ -5,6 +5,7 @@...@@ -5,6 +5,7 @@
5#include <string.h>5#include <string.h>
6#ifdef __wasilibc_unmodified_upstream // timezone data6#ifdef __wasilibc_unmodified_upstream // timezone data
7#include <sys/mman.h>7#include <sys/mman.h>
8#include <ctype.h>
8#endif9#endif
9#include "libc.h"10#include "libc.h"
10#include "lock.h"11#include "lock.h"
...@@ -159,10 +160,21 @@ static void do_tzset()...@@ -159,10 +160,21 @@ static void do_tzset()
159 }160 }
160 if (old_tz) memcpy(old_tz, s, i+1);161 if (old_tz) memcpy(old_tz, s, i+1);
161162
163 int posix_form = 0;
164 if (*s != ':') {
165 p = s;
166 char dummy_name[TZNAME_MAX+1];
167 getname(dummy_name, &p);
168 if (p!=s && (*p == '+' || *p == '-' || isdigit(*p)
169 || !strcmp(dummy_name, "UTC")
170 || !strcmp(dummy_name, "GMT")))
171 posix_form = 1;
172 }
173
162 /* Non-suid can use an absolute tzfile pathname or a relative174 /* Non-suid can use an absolute tzfile pathname or a relative
163 * pathame beginning with "."; in secure mode, only the175 * pathame beginning with "."; in secure mode, only the
164 * standard path will be searched. */176 * standard path will be searched. */
165 if (*s == ':' || ((p=strchr(s, '/')) && !memchr(s, ',', p-s))) {177 if (!posix_form) {
166 if (*s == ':') s++;178 if (*s == ':') s++;
167 if (*s == '/' || *s == '.') {179 if (*s == '/' || *s == '.') {
168 if (!libc.secure || !strcmp(s, "/etc/localtime"))180 if (!libc.secure || !strcmp(s, "/etc/localtime"))
...@@ -286,22 +298,20 @@ static size_t scan_trans(long long t, int local, size_t *alt)...@@ -286,22 +298,20 @@ static size_t scan_trans(long long t, int local, size_t *alt)
286 n = (index-trans)>>scale;298 n = (index-trans)>>scale;
287 if (a == n-1) return -1;299 if (a == n-1) return -1;
288 if (a == 0) {300 if (a == 0) {
289 x = zi_read32(trans + (a<<scale));301 x = zi_read32(trans);
290 if (scale == 3) x = x<<32 | zi_read32(trans + (a<<scale) + 4);302 if (scale == 3) x = x<<32 | zi_read32(trans + 4);
291 else x = (int32_t)x;303 else x = (int32_t)x;
292 if (local) off = (int32_t)zi_read32(types + 6 * index[a-1]);304 /* Find the lowest non-DST type, or 0 if none. */
305 size_t j = 0;
306 for (size_t i=abbrevs-types; i; i-=6) {
307 if (!types[i-6+4]) j = i-6;
308 }
309 if (local) off = (int32_t)zi_read32(types + j);
310 /* If t is before first transition, use the above-found type
311 * and the index-zero (after transition) type as the alt. */
293 if (t - off < (int64_t)x) {312 if (t - off < (int64_t)x) {
294 for (a=0; a<(abbrevs-types)/6; a++) {313 if (alt) *alt = index[0];
295 if (types[6*a+4] != types[4]) break;314 return j/6;
296 }
297 if (a == (abbrevs-types)/6) a = 0;
298 if (types[6*a+4]) {
299 *alt = a;
300 return 0;
301 } else {
302 *alt = 0;
303 return a;
304 }
305 }315 }
306 }316 }
307317
lib/libc/wasi/libc-top-half/musl/src/unistd/nice.c+8-1
...@@ -1,4 +1,5 @@...@@ -1,4 +1,5 @@
1#include <unistd.h>1#include <unistd.h>
2#include <errno.h>
2#include <sys/resource.h>3#include <sys/resource.h>
3#include <limits.h>4#include <limits.h>
4#include "syscall.h"5#include "syscall.h"
...@@ -12,5 +13,11 @@ int nice(int inc)...@@ -12,5 +13,11 @@ int nice(int inc)
12 prio += getpriority(PRIO_PROCESS, 0);13 prio += getpriority(PRIO_PROCESS, 0);
13 if (prio > NZERO-1) prio = NZERO-1;14 if (prio > NZERO-1) prio = NZERO-1;
14 if (prio < -NZERO) prio = -NZERO;15 if (prio < -NZERO) prio = -NZERO;
15 return setpriority(PRIO_PROCESS, 0, prio) ? -1 : prio;16 if (setpriority(PRIO_PROCESS, 0, prio)) {
17 if (errno == EACCES)
18 errno = EPERM;
19 return -1;
20 } else {
21 return prio;
22 }
16}23}