]> git.proxmox.com Git - wasi-libc.git/commitdiff
Update to musl 1.2.3.
authorDan Gohman <dev@sunfishcode.online>
Wed, 25 May 2022 02:31:23 +0000 (19:31 -0700)
committerGitHub <noreply@github.com>
Wed, 25 May 2022 02:31:23 +0000 (19:31 -0700)
* Update to musl 1.2.3.

See the WHATSNEW file for details.

104 files changed:
expected/wasm32-wasi/defined-symbols.txt
expected/wasm32-wasi/predefined-macros.txt
libc-top-half/musl/VERSION
libc-top-half/musl/WHATSNEW
libc-top-half/musl/arch/aarch64/bits/hwcap.h
libc-top-half/musl/arch/aarch64/bits/mman.h [new file with mode: 0644]
libc-top-half/musl/arch/aarch64/bits/syscall.h.in
libc-top-half/musl/arch/arm/bits/syscall.h.in
libc-top-half/musl/arch/i386/bits/syscall.h.in
libc-top-half/musl/arch/m68k/bits/syscall.h.in
libc-top-half/musl/arch/microblaze/bits/syscall.h.in
libc-top-half/musl/arch/mips/bits/syscall.h.in
libc-top-half/musl/arch/mips/pthread_arch.h
libc-top-half/musl/arch/mips64/bits/syscall.h.in
libc-top-half/musl/arch/mipsn32/bits/syscall.h.in
libc-top-half/musl/arch/or1k/bits/syscall.h.in
libc-top-half/musl/arch/powerpc/bits/fenv.h
libc-top-half/musl/arch/powerpc/bits/shm.h
libc-top-half/musl/arch/powerpc/bits/syscall.h.in
libc-top-half/musl/arch/powerpc/reloc.h
libc-top-half/musl/arch/powerpc64/bits/syscall.h.in
libc-top-half/musl/arch/riscv64/bits/syscall.h.in
libc-top-half/musl/arch/riscv64/bits/user.h
libc-top-half/musl/arch/s390x/bits/ptrace.h
libc-top-half/musl/arch/s390x/bits/syscall.h.in
libc-top-half/musl/arch/sh/bits/syscall.h.in
libc-top-half/musl/arch/x32/bits/syscall.h.in
libc-top-half/musl/arch/x32/bits/user.h
libc-top-half/musl/arch/x86_64/bits/syscall.h.in
libc-top-half/musl/configure
libc-top-half/musl/include/ctype.h
libc-top-half/musl/include/elf.h
libc-top-half/musl/include/locale.h
libc-top-half/musl/include/netinet/if_ether.h
libc-top-half/musl/include/netinet/in.h
libc-top-half/musl/include/netinet/tcp.h
libc-top-half/musl/include/pthread.h
libc-top-half/musl/include/setjmp.h
libc-top-half/musl/include/signal.h
libc-top-half/musl/include/stdc-predef.h
libc-top-half/musl/include/stddef.h
libc-top-half/musl/include/stdio.h
libc-top-half/musl/include/stdlib.h
libc-top-half/musl/include/string.h
libc-top-half/musl/include/sys/membarrier.h
libc-top-half/musl/include/sys/mman.h
libc-top-half/musl/include/sys/mount.h
libc-top-half/musl/include/sys/prctl.h
libc-top-half/musl/include/sys/ptrace.h
libc-top-half/musl/include/sys/socket.h
libc-top-half/musl/include/time.h
libc-top-half/musl/include/unistd.h
libc-top-half/musl/include/wchar.h
libc-top-half/musl/ldso/dynlink.c
libc-top-half/musl/src/complex/cacosf.c
libc-top-half/musl/src/complex/catanf.c
libc-top-half/musl/src/complex/cproj.c
libc-top-half/musl/src/complex/cprojf.c
libc-top-half/musl/src/complex/cprojl.c
libc-top-half/musl/src/ctype/nonspacing.h
libc-top-half/musl/src/env/__libc_start_main.c
libc-top-half/musl/src/env/__stack_chk_fail.c
libc-top-half/musl/src/errno/__strerror.h
libc-top-half/musl/src/fenv/powerpc/fenv-sf.c
libc-top-half/musl/src/fenv/powerpc/fenv.S
libc-top-half/musl/src/include/stdlib.h
libc-top-half/musl/src/ldso/dl_iterate_phdr.c
libc-top-half/musl/src/legacy/cuserid.c
libc-top-half/musl/src/linux/epoll.c
libc-top-half/musl/src/locale/dcngettext.c
libc-top-half/musl/src/locale/duplocale.c
libc-top-half/musl/src/locale/strtod_l.c [new file with mode: 0644]
libc-top-half/musl/src/malloc/free.c
libc-top-half/musl/src/malloc/mallocng/aligned_alloc.c
libc-top-half/musl/src/malloc/mallocng/free.c
libc-top-half/musl/src/malloc/oldmalloc/malloc.c
libc-top-half/musl/src/math/acoshf.c
libc-top-half/musl/src/math/expm1f.c
libc-top-half/musl/src/math/fmaf.c
libc-top-half/musl/src/math/powerpc/fabs.c
libc-top-half/musl/src/math/powerpc/fabsf.c
libc-top-half/musl/src/math/powerpc/fma.c
libc-top-half/musl/src/math/powerpc/fmaf.c
libc-top-half/musl/src/misc/ioctl.c
libc-top-half/musl/src/passwd/nscd_query.c
libc-top-half/musl/src/process/fdop.h
libc-top-half/musl/src/process/posix_spawn_file_actions_addclose.c
libc-top-half/musl/src/process/posix_spawn_file_actions_adddup2.c
libc-top-half/musl/src/process/posix_spawn_file_actions_addfchdir.c
libc-top-half/musl/src/process/posix_spawn_file_actions_addopen.c
libc-top-half/musl/src/setjmp/powerpc/longjmp.S
libc-top-half/musl/src/setjmp/powerpc/setjmp.S
libc-top-half/musl/src/signal/block.c
libc-top-half/musl/src/stdio/fgetws.c
libc-top-half/musl/src/stdio/fseek.c
libc-top-half/musl/src/stdio/getdelim.c
libc-top-half/musl/src/stdio/popen.c
libc-top-half/musl/src/stdlib/qsort.c
libc-top-half/musl/src/stdlib/qsort_nr.c [new file with mode: 0644]
libc-top-half/musl/src/stdlib/strtod.c
libc-top-half/musl/src/thread/pthread_getname_np.c [new file with mode: 0644]
libc-top-half/musl/src/thread/pthread_setname_np.c
libc-top-half/musl/src/time/__tz.c
libc-top-half/musl/src/unistd/nice.c

index a0d70666e30a58fe8e4b881945c7d78546456182..ba995bae282dd189e45557dbc6b0a41bfb900054 100644 (file)
@@ -183,6 +183,7 @@ __powf_log2_data
 __progname
 __progname_full
 __putenv
+__qsort_r
 __rand48_step
 __reallocarray
 __rem_pio2
@@ -228,8 +229,11 @@ __strerror_l
 __strftime_fmt_1
 __strftime_l
 __strncasecmp_l
+__strtod_l
+__strtof_l
 __strtoimax_internal
 __strtol_internal
+__strtold_l
 __strtoll_internal
 __strtoul_internal
 __strtoull_internal
@@ -931,6 +935,7 @@ putwchar_unlocked
 pwrite
 pwritev
 qsort
+qsort_r
 quick_exit
 raise
 rand
index f1389b5d1a2c5601ec0e2ceeb6388976cc7d7101..0cfff9b8cd943426411617e50c483d0a939674cd 100644 (file)
 #define INADDR_ALLSNOOPERS_GROUP ((in_addr_t) 0xe000006a)
 #define INADDR_ANY ((in_addr_t) 0x00000000)
 #define INADDR_BROADCAST ((in_addr_t) 0xffffffff)
+#define INADDR_DUMMY ((in_addr_t) 0xc0000008)
 #define INADDR_LOOPBACK ((in_addr_t) 0x7f000001)
 #define INADDR_MAX_LOCAL_GROUP ((in_addr_t) 0xe00000ff)
 #define INADDR_NONE ((in_addr_t) 0xffffffff)
 #define TCP_NOTSENT_LOWAT 25
 #define TCP_QUEUE_SEQ 21
 #define TCP_QUICKACK 12
+#define TCP_RECEIVE_ZEROCOPY_FLAG_TLB_CLEAN_HINT 0x1
 #define TCP_REPAIR 19
 #define TCP_REPAIR_OFF 0
 #define TCP_REPAIR_OFF_NO_WP -1
index 23aa8390630cc1ae7f102ddd472e4ba48b689844..0495c4a88caed0f036ffab0948c17d4b5fdc96c1 100644 (file)
@@ -1 +1 @@
-1.2.2
+1.2.3
index e1d01982a2ac66a25b64cb550e00e30df71a9822..f9bb248256005ad09399bcfd65ec3bd5a19d733e 100644 (file)
@@ -2287,3 +2287,43 @@ arch-specific bugs fixed:
 - i386 __set_thread_area fallback for pre-2.6 kernels didn't work
 - missing O_LARGEFILE macro value on x86_64, x32, mips64
 - unpredictable s390x breakage from failure to preserve call-saved registers
+
+
+
+1.2.3 release notes
+
+new features:
+- qsort_r function (POSIX-future)
+- pthread_getname_np extension function
+- hard float on SPE FPU for powerpc-sf
+- SEEK_DATA and SEEK_HOLE exposed in unistd.h (Linux extensions)
+
+compatibility:
+- free now preserves errno (POSIX-future requirement)
+- setjmp is declared explicitly with returns_twice for non-GCC compilers
+- macro version of isascii is no longer defined for C++
+- dynamic linker now tolerates zero-length LOAD segments
+- epoll_[p]wait is now a cancellation point
+- pwd/grp functions no longer fail on systems without AF_UNIX support
+- POSIX TZ parsing is stricter to allow more names to fallback to files
+- NULL is now defined as nullptr when used in C++11 or later
+- gettext now accepts null pointer as argument
+
+bugs fixed:
+- old regression in wcwidth of Hangul combining (vowel/final) letters
+- duplocale used wrong malloc when malloc was replaced (1.2.2 regression)
+- fmaf rounded wrong on archs without FE_TOWARDZERO (all softfloat archs)
+- popen didn't honor requirement not to leak other popen pipe fds to child
+- aligned_alloc and variants crashed on allocation failure
+- dl_iterate_phdr reported incorrect module TLS pointers
+- mishandling of some inputs in acoshf and expm1f and functions using them
+- potentially wrong-sign zero in cproj functions at infinity
+- multiple bugs in legacy function cuserid
+- minor posix_spawn file actions API conformance issues
+- pthread_setname_np fd leak
+- out-of-bound read in zoneinfo handling with distant-past times
+- out-of-tree builds lacked generated debug cfi for x86 asm
+
+arch-specific bugs fixed:
+- powerpc (32-bit) struct shmid_ds layout was wrong for some fields
+- time64 struct layout was wrong in sound ioctl fallback (32-bit archs)
index 7ab73f99b68a06e9e372946eb5abe12174bf0607..424cc4d4fcda8cd0c8376bc916cac2cf6c130b72 100644 (file)
@@ -48,3 +48,5 @@
 #define HWCAP2_BF16            (1 << 14)
 #define HWCAP2_DGH             (1 << 15)
 #define HWCAP2_RNG             (1 << 16)
+#define HWCAP2_BTI             (1 << 17)
+#define HWCAP2_MTE             (1 << 18)
diff --git a/libc-top-half/musl/arch/aarch64/bits/mman.h b/libc-top-half/musl/arch/aarch64/bits/mman.h
new file mode 100644 (file)
index 0000000..8fad5ce
--- /dev/null
@@ -0,0 +1,2 @@
+#define PROT_BTI 0x10
+#define PROT_MTE 0x20
index f9457c184a6318e78abf05d87f17c9b17574d1f8..5f420e61769070050e69429214c68ff758abb344 100644 (file)
 #define __NR_openat2           437
 #define __NR_pidfd_getfd       438
 #define __NR_faccessat2                439
+#define __NR_process_madvise   440
+#define __NR_epoll_pwait2      441
+#define __NR_mount_setattr     442
+#define __NR_landlock_create_ruleset   444
+#define __NR_landlock_add_rule 445
+#define __NR_landlock_restrict_self    446
 
index 7e2fc26697adf6f6697b988f830e110b426cd581..048fdea79707a6b590e4ecb563943d5cdd38db82 100644 (file)
 #define __NR_openat2           437
 #define __NR_pidfd_getfd       438
 #define __NR_faccessat2                439
+#define __NR_process_madvise   440
+#define __NR_epoll_pwait2      441
+#define __NR_mount_setattr     442
+#define __NR_landlock_create_ruleset   444
+#define __NR_landlock_add_rule 445
+#define __NR_landlock_restrict_self    446
 
 #define __ARM_NR_breakpoint    0x0f0001
 #define __ARM_NR_cacheflush    0x0f0002
index abdb210d39703b913b828e086591eef7cd60ec75..46ffe1d99a926df30f1795c02a15477b565bfc1a 100644 (file)
 #define __NR_openat2           437
 #define __NR_pidfd_getfd       438
 #define __NR_faccessat2                439
+#define __NR_process_madvise   440
+#define __NR_epoll_pwait2      441
+#define __NR_mount_setattr     442
+#define __NR_landlock_create_ruleset   444
+#define __NR_landlock_add_rule 445
+#define __NR_landlock_restrict_self    446
 
index e10969a2641d4b942fe473ea0a4c33ac45fe73ae..a0c6332330ca6d597381837eba577f1ab1671cb9 100644 (file)
 #define __NR_openat2           437
 #define __NR_pidfd_getfd       438
 #define __NR_faccessat2                439
+#define __NR_process_madvise   440
+#define __NR_epoll_pwait2      441
+#define __NR_mount_setattr     442
+#define __NR_landlock_create_ruleset   444
+#define __NR_landlock_add_rule 445
+#define __NR_landlock_restrict_self    446
index 9d46904738df5e8afc2ef118e8656f161ee3e376..931d79193171f5633191c4bf880ea47a2b579aca 100644 (file)
 #define __NR_openat2           437
 #define __NR_pidfd_getfd       438
 #define __NR_faccessat2                439
+#define __NR_process_madvise   440
+#define __NR_epoll_pwait2      441
+#define __NR_mount_setattr     442
+#define __NR_landlock_create_ruleset   444
+#define __NR_landlock_add_rule 445
+#define __NR_landlock_restrict_self    446
 
index 2bb03f067ab431354e4459b3230ba04cd3d45f9c..63e3503a6b0495e8caaf95eca97879686ef88c1e 100644 (file)
 #define __NR_openat2           4437
 #define __NR_pidfd_getfd       4438
 #define __NR_faccessat2                4439
+#define __NR_process_madvise   4440
+#define __NR_epoll_pwait2      4441
+#define __NR_mount_setattr     4442
+#define __NR_landlock_create_ruleset   4444
+#define __NR_landlock_add_rule 4445
+#define __NR_landlock_restrict_self    4446
 
index c45347ab92f6b85825e644201982bc4de42b5e5f..376b77415a6f89e2009f6b2429db449874e0cd31 100644 (file)
@@ -1,10 +1,9 @@
 static inline uintptr_t __get_tp()
 {
-#if __mips_isa_rev < 2
        register uintptr_t tp __asm__("$3");
+#if __mips_isa_rev < 2
        __asm__ (".word 0x7c03e83b" : "=r" (tp) );
 #else
-       uintptr_t tp;
        __asm__ ("rdhwr %0, $29" : "=r" (tp) );
 #endif
        return tp;
index 045e8238ad0337f8ba36f7fd309a4a8873f0a538..b89965d11a10e8a65c1fc4093610a23bca711ff3 100644 (file)
 #define __NR_openat2           5437
 #define __NR_pidfd_getfd       5438
 #define __NR_faccessat2                5439
+#define __NR_process_madvise   5440
+#define __NR_epoll_pwait2      5441
+#define __NR_mount_setattr     5442
+#define __NR_landlock_create_ruleset   5444
+#define __NR_landlock_add_rule 5445
+#define __NR_landlock_restrict_self    5446
 
index 5b3225585e7ec743af32c426153f104fd0adc98a..bb2d04a87527b3ca6d40331703b35141238b30c8 100644 (file)
 #define __NR_openat2           6437
 #define __NR_pidfd_getfd       6438
 #define __NR_faccessat2                6439
+#define __NR_process_madvise   6440
+#define __NR_epoll_pwait2      6441
+#define __NR_mount_setattr     6442
+#define __NR_landlock_create_ruleset   6444
+#define __NR_landlock_add_rule 6445
+#define __NR_landlock_restrict_self    6446
 
index b36038915d42d50b045d7a3c795ea056cefecf0a..2b5f2052264eb3eb30c31ee318a31e98d3d31d6a 100644 (file)
 #define __NR_openat2           437
 #define __NR_pidfd_getfd       438
 #define __NR_faccessat2                439
+#define __NR_process_madvise   440
+#define __NR_epoll_pwait2      441
+#define __NR_mount_setattr     442
+#define __NR_landlock_create_ruleset   444
+#define __NR_landlock_add_rule 445
+#define __NR_landlock_restrict_self    446
 
index c5a3e5c5c70fe850964879b60eedf7616e6ac7e3..5b15c69a3a509ccddbbc4cb4d10e13c90b440e9c 100644 (file)
@@ -1,4 +1,4 @@
-#ifdef _SOFT_FLOAT
+#if defined(_SOFT_FLOAT) || defined(__NO_FPRS__)
 #define FE_ALL_EXCEPT 0
 #define FE_TONEAREST  0
 #else
index fb1d4020f683cc22885195ac63a384ecd9880dba..7f1ca17ebffa976b7ca46651d9113169dfc54b5d 100644 (file)
@@ -8,11 +8,11 @@ struct shmid_ds {
        unsigned long __shm_dtime_lo;
        unsigned long __shm_ctime_hi;
        unsigned long __shm_ctime_lo;
+       unsigned long __pad1;
        size_t shm_segsz;
        pid_t shm_cpid;
        pid_t shm_lpid;
        unsigned long shm_nattch;
-       unsigned long __pad1;
        unsigned long __pad2;
        time_t shm_atime;
        time_t shm_dtime;
index 5c6fae3e5887ca7f3419b969943d76609455caee..b1605a58f1018de38da912304a217c3974d1affa 100644 (file)
 #define __NR_openat2           437
 #define __NR_pidfd_getfd       438
 #define __NR_faccessat2                439
+#define __NR_process_madvise   440
+#define __NR_epoll_pwait2      441
+#define __NR_mount_setattr     442
+#define __NR_landlock_create_ruleset   444
+#define __NR_landlock_add_rule 445
+#define __NR_landlock_restrict_self    446
 
index 527b6b7cdc5f4409e6419b3a177d5cb7320a0ea3..fdfbf827e8e081237be4daef11119fbbddf64782 100644 (file)
@@ -1,4 +1,4 @@
-#ifdef _SOFT_FLOAT
+#if defined(_SOFT_FLOAT) || defined(__NO_FPRS__)
 #define FP_SUFFIX "-sf"
 #else
 #define FP_SUFFIX ""
index edf73d3d6b1ddab8494630af3b25cf933fd552ff..b3a8fba092d2cdb2f1bec5c6c89d0b0853779f69 100644 (file)
 #define __NR_openat2           437
 #define __NR_pidfd_getfd       438
 #define __NR_faccessat2                439
+#define __NR_process_madvise   440
+#define __NR_epoll_pwait2      441
+#define __NR_mount_setattr     442
+#define __NR_landlock_create_ruleset   444
+#define __NR_landlock_add_rule 445
+#define __NR_landlock_restrict_self    446
 
index 5def016b129d675f4c5219b5dd439c1eb3e5fa73..b534afe81ca22b78d66e36667830ac67167d9c6a 100644 (file)
@@ -76,7 +76,7 @@
 #define __NR_splice 76
 #define __NR_tee 77
 #define __NR_readlinkat 78
-#define __NR_fstatat 79
+#define __NR_newfstatat 79
 #define __NR_fstat 80
 #define __NR_sync 81
 #define __NR_fsync 82
 #define __NR_openat2           437
 #define __NR_pidfd_getfd       438
 #define __NR_faccessat2                439
+#define __NR_process_madvise   440
+#define __NR_epoll_pwait2      441
+#define __NR_mount_setattr     442
+#define __NR_landlock_create_ruleset   444
+#define __NR_landlock_add_rule 445
+#define __NR_landlock_restrict_self    446
 
 #define __NR_sysriscv __NR_arch_specific_syscall
 #define __NR_riscv_flush_icache (__NR_sysriscv + 15)
index 2da743eaf8fe9b437f3f6183968124c532083553..0d37de0b045bd2bc5f52805aa9acc71eacc01a33 100644 (file)
@@ -1,5 +1,6 @@
 #include <signal.h>
 
 #define ELF_NGREG 32
+#define ELF_NFPREG 33
 typedef unsigned long elf_greg_t, elf_gregset_t[ELF_NGREG];
 typedef union __riscv_mc_fp_state elf_fpregset_t;
index d50e3262110806e8d8efc5ffb8e2f92a78237a5e..a06cb0778fe380c46424c4dc948853a06aa711c6 100644 (file)
@@ -1,4 +1,7 @@
 #define PTRACE_SINGLEBLOCK             12
+#define PTRACE_OLDSETOPTIONS           21
+#define PTRACE_SYSEMU                  31
+#define PTRACE_SYSEMU_SINGLESTEP       32
 #define PTRACE_PEEKUSR_AREA            0x5000
 #define PTRACE_POKEUSR_AREA            0x5001
 #define PTRACE_GET_LAST_BREAK          0x5006
index fb2e60e30b03f76c1b82a25e67dd3f0329e136cd..dfc384792a4d3795ae682c5fb9d84d3732ae8ec5 100644 (file)
 #define __NR_openat2           437
 #define __NR_pidfd_getfd       438
 #define __NR_faccessat2                439
+#define __NR_process_madvise   440
+#define __NR_epoll_pwait2      441
+#define __NR_mount_setattr     442
+#define __NR_landlock_create_ruleset   444
+#define __NR_landlock_add_rule 445
+#define __NR_landlock_restrict_self    446
 
index 158afc091047e94dc52bce5ac8d9cd5927501f38..ff14f54d2439e2fa2bf40e99e916572faae2f644 100644 (file)
 #define __NR_openat2           437
 #define __NR_pidfd_getfd       438
 #define __NR_faccessat2                439
+#define __NR_process_madvise   440
+#define __NR_epoll_pwait2      441
+#define __NR_mount_setattr     442
+#define __NR_landlock_create_ruleset   444
+#define __NR_landlock_add_rule 445
+#define __NR_landlock_restrict_self    446
 
index cfd9856f13d735750e9ef3aaae978dded9c9e746..5d22fa1751dd55e775440e32b833c2d709b9cc82 100644 (file)
 #define __NR_openat2           (0x40000000 + 437)
 #define __NR_pidfd_getfd       (0x40000000 + 438)
 #define __NR_faccessat2                (0x40000000 + 439)
+#define __NR_process_madvise   (0x40000000 + 440)
+#define __NR_epoll_pwait2      (0x40000000 + 441)
+#define __NR_mount_setattr     (0x40000000 + 442)
+#define __NR_landlock_create_ruleset   (0x40000000 + 444)
+#define __NR_landlock_add_rule (0x40000000 + 445)
+#define __NR_landlock_restrict_self    (0x40000000 + 446)
 
 
 #define __NR_rt_sigaction (0x40000000 + 512)
index 4073cc06ffbb638993021e129e48ef9aa4799729..eac82a14bced4910e8da0030db7eae53f5086dd4 100644 (file)
@@ -1,5 +1,5 @@
 #undef __WORDSIZE
-#define __WORDSIZE 64
+#define __WORDSIZE 32
 
 typedef struct user_fpregs_struct {
        uint16_t cwd, swd, ftw, fop;
index a6117951047676835f1e26752986212c8216ebbb..c3882de7e7021b901e96a38b6b9130c25a3a30bb 100644 (file)
 #define __NR_openat2           437
 #define __NR_pidfd_getfd       438
 #define __NR_faccessat2                439
+#define __NR_process_madvise   440
+#define __NR_epoll_pwait2      441
+#define __NR_mount_setattr     442
+#define __NR_landlock_create_ruleset   444
+#define __NR_landlock_add_rule 445
+#define __NR_landlock_restrict_self    446
 
index 3a4ed7a12f93052b6f7ac6f9dd834041dfff63e0..931d55664e5d236ffa259a528035b6fa9ceda4a7 100755 (executable)
@@ -411,7 +411,7 @@ test "$debug" = yes && CFLAGS_AUTO=-g
 #
 printf "checking whether we should preprocess assembly to add debugging information... "
 if fnmatch '-g*|*\ -g*' "$CFLAGS_AUTO $CFLAGS" &&
-   test -f "tools/add-cfi.$ARCH.awk" &&
+   test -f "$srcdir/tools/add-cfi.$ARCH.awk" &&
    printf ".file 1 \"srcfile.s\"\n.line 1\n.cfi_startproc\n.cfi_endproc" | $CC -g -x assembler -c -o /dev/null 2>/dev/null -
 then
   ADD_CFI=yes
@@ -673,9 +673,7 @@ trycppif __mips_soft_float "$t" && SUBARCH=${SUBARCH}-sf
 fi
 
 if test "$ARCH" = "powerpc" ; then
-trycppif "__NO_FPRS__ && !_SOFT_FLOAT" "$t" && fail \
-  "$0: error: compiler's floating point configuration is unsupported"
-trycppif _SOFT_FLOAT "$t" && SUBARCH=${SUBARCH}-sf
+trycppif "_SOFT_FLOAT || __NO_FPRS__" "$t" && SUBARCH=${SUBARCH}-sf
 printf "checking whether compiler can use 'd' constraint in asm... "
 echo 'double f(double x) { __asm__ ("fabs %0, %1" : "=d"(x) : "d"(x)); return x; }' > "$tmpc"
 if $CC $CFLAGS_C99FSE $CPPFLAGS $CFLAGS -c -o /dev/null "$tmpc" >/dev/null 2>&1 ; then
index 7936536f577c7d5ee5fd9257b8baad2fc491f4ec..32bcef4dabcce1b37d3ed009937abf5b48a074f9 100644 (file)
@@ -64,7 +64,9 @@ int   isascii(int);
 int   toascii(int);
 #define _tolower(a) ((a)|0x20)
 #define _toupper(a) ((a)&0x5f)
+#ifndef __cplusplus
 #define isascii(a) (0 ? isascii(a) : (unsigned)(a) < 128)
+#endif
 
 #endif
 
index b5e7befb02980d7228d0d0ba4d58228ccfbcf435..86e2f0bb7d04a2bcf7f9ec1c7f615287c65666d0 100644 (file)
@@ -686,6 +686,8 @@ typedef struct {
 #define NT_ARM_PAC_MASK        0x406
 #define NT_ARM_PACA_KEYS       0x407
 #define NT_ARM_PACG_KEYS       0x408
+#define NT_ARM_TAGGED_ADDR_CTRL        0x409
+#define NT_ARM_PAC_ENABLED_KEYS        0x40a
 #define NT_METAG_CBUF  0x500
 #define NT_METAG_RPIPE 0x501
 #define NT_METAG_TLS   0x502
index 228e5026c88d5e4b99b11f079e84c4f7a5bf9a67..6a62d1f5a7ff1843d59200a0380ea2868117c0b0 100644 (file)
@@ -8,7 +8,9 @@ extern "C" {
 #include <features.h>
 
 #ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */
-#ifdef __cplusplus
+#if __cplusplus >= 201103L
+#define NULL nullptr
+#elif defined(__cplusplus)
 #define NULL 0L
 #else
 #define NULL ((void*)0)
index 55a2ff1b1753176a2c5da66f8f2f0d821a9033ee..3479f511bf21565b53459aadab47da88340725f8 100644 (file)
@@ -66,6 +66,7 @@
 #define ETH_P_1588     0x88F7
 #define ETH_P_NCSI     0x88F8
 #define ETH_P_PRP      0x88FB
+#define ETH_P_CFM      0x8902
 #define ETH_P_FCOE     0x8906
 #define ETH_P_TDLS     0x890D
 #define ETH_P_FIP      0x8914
index b09efab018f2deeb2dae6750195d83f460a1fad5..d9422af2ea09c8da87b558c5d7629dc60681c268 100644 (file)
@@ -60,6 +60,7 @@ struct ipv6_mreq {
 #define INADDR_BROADCAST  ((in_addr_t) 0xffffffff)
 #define INADDR_NONE       ((in_addr_t) 0xffffffff)
 #define INADDR_LOOPBACK   ((in_addr_t) 0x7f000001)
+#define INADDR_DUMMY      ((in_addr_t) 0xc0000008)
 
 #define INADDR_UNSPEC_GROUP     ((in_addr_t) 0xe0000000)
 #define INADDR_ALLHOSTS_GROUP   ((in_addr_t) 0xe0000001)
index b7b997f5fde543203822036ebba6ff6c94bc7336..fad1d844943f714b98a6c56e338e0b78c55e9eb0 100644 (file)
@@ -80,6 +80,8 @@ enum {
        TCP_NLA_SRTT,
        TCP_NLA_TIMEOUT_REHASH,
        TCP_NLA_BYTES_NOTSENT,
+       TCP_NLA_EDT,
+       TCP_NLA_TTL,
 };
 
 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
@@ -281,12 +283,21 @@ struct tcp_repair_window {
        uint32_t rcv_wup;
 };
 
+#define TCP_RECEIVE_ZEROCOPY_FLAG_TLB_CLEAN_HINT 0x1
+
 struct tcp_zerocopy_receive {
        uint64_t address;
        uint32_t length;
        uint32_t recv_skip_hint;
        uint32_t inq;
        int32_t err;
+       uint64_t copybuf_address;
+       int32_t copybuf_len;
+       uint32_t flags;
+       uint64_t msg_control;
+       uint64_t msg_controllen;
+       uint32_t msg_flags;
+       uint32_t reserved;
 };
 
 #endif
index b11a567d5cab98cef0cd7864a3bed785781be31e..b0801d406017132c7e4a3d4c5a12bf344322e8da 100644 (file)
@@ -227,6 +227,7 @@ int pthread_getaffinity_np(pthread_t, size_t, struct cpu_set_t *);
 int pthread_setaffinity_np(pthread_t, size_t, const struct cpu_set_t *);
 int pthread_getattr_np(pthread_t, pthread_attr_t *);
 int pthread_setname_np(pthread_t, const char *);
+int pthread_getname_np(pthread_t, char *, size_t);
 int pthread_getattr_default_np(pthread_attr_t *);
 int pthread_setattr_default_np(const pthread_attr_t *);
 int pthread_tryjoin_np(pthread_t, void **);
index 6a653efa3d50246fba608fe1eb5aa93377dc90f9..f505f8e4fa3be6e45bf14b48c28d43791834124f 100644 (file)
@@ -16,21 +16,27 @@ typedef struct __jmp_buf_tag {
        unsigned long __ss[128/sizeof(long)];
 } jmp_buf[1];
 
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)
+#define __setjmp_attr __attribute__((__returns_twice__))
+#else
+#define __setjmp_attr
+#endif
+
 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
  || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
  || defined(_BSD_SOURCE)
 typedef jmp_buf sigjmp_buf;
-int sigsetjmp (sigjmp_buf, int);
+int sigsetjmp (sigjmp_buf, int) __setjmp_attr;
 _Noreturn void siglongjmp (sigjmp_buf, int);
 #endif
 
 #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
  || defined(_BSD_SOURCE)
-int _setjmp (jmp_buf);
+int _setjmp (jmp_buf) __setjmp_attr;
 _Noreturn void _longjmp (jmp_buf, int);
 #endif
 
-int setjmp (jmp_buf);
+int setjmp (jmp_buf) __setjmp_attr;
 _Noreturn void longjmp (jmp_buf, int);
 
 #define setjmp setjmp
@@ -38,6 +44,8 @@ _Noreturn void longjmp (jmp_buf, int);
 #warning setjmp is not yet implemented for WASI
 #endif
 
+#undef __setjmp_attr
+
 #ifdef __cplusplus
 }
 #endif
index ae74966b96bd9adcca641bdbba5706786d475a9e..75b5e55284f56a4b1ee4d2a32faee77830858265 100644 (file)
@@ -82,6 +82,8 @@ typedef struct sigaltstack stack_t;
 #define SEGV_ACCERR 2
 #define SEGV_BNDERR 3
 #define SEGV_PKUERR 4
+#define SEGV_MTEAERR 8
+#define SEGV_MTESERR 9
 
 #define BUS_ADRALN 1
 #define BUS_ADRERR 2
@@ -183,6 +185,9 @@ struct sigaction {
 #define sa_handler   __sa_handler.sa_handler
 #define sa_sigaction __sa_handler.sa_sigaction
 
+#define SA_UNSUPPORTED 0x00000400
+#define SA_EXPOSE_TAGBITS 0x00000800
+
 struct sigevent {
        union sigval sigev_value;
        int sigev_signo;
@@ -277,6 +282,9 @@ void (*sigset(int, void (*)(int)))(int);
 #if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
 #define NSIG _NSIG
 typedef void (*sig_t)(int);
+
+#define SYS_SECCOMP 1
+#define SYS_USER_DISPATCH 2
 #endif
 
 #ifdef _GNU_SOURCE
index f8cd4b8911366530ab3231f25dbd93826f769add..af1a27998f9036009cbfcc48c5b72ee640918ebb 100644 (file)
@@ -7,4 +7,7 @@
 #define __STDC_IEC_559__ 1
 #endif
 
+#define __STDC_UTF_16__ 1
+#define __STDC_UTF_32__ 1
+
 #endif
index bd753853503d94ca3759b2e451fffb68675e869b..f25b86396e80a015490a6aec521cb38ab36ab118 100644 (file)
@@ -1,7 +1,9 @@
 #ifndef _STDDEF_H
 #define _STDDEF_H
 
-#ifdef __cplusplus
+#if __cplusplus >= 201103L
+#define NULL nullptr
+#elif defined(__cplusplus)
 #define NULL 0L
 #else
 #define NULL ((void*)0)
index 0c3aff9c2cad2a81924098a4cad8de562a5c091e..d63d739f0ff0ae3333bf3aac972bf80faad9a104 100644 (file)
@@ -28,7 +28,9 @@ extern "C" {
 #include <bits/alltypes.h>
 
 #ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */
-#ifdef __cplusplus
+#if __cplusplus >= 201103L
+#define NULL nullptr
+#elif defined(__cplusplus)
 #define NULL 0L
 #else
 #define NULL ((void*)0)
index e635275d681d0a9b99f89f19a156b12b5d3421b6..1bcb9ab0aa244e35bcab084f1cf82bca27d79ca6 100644 (file)
@@ -13,7 +13,9 @@ extern "C" {
 #include <features.h>
 
 #ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */
-#ifdef __cplusplus
+#if __cplusplus >= 201103L
+#define NULL nullptr
+#elif defined(__cplusplus)
 #define NULL 0L
 #else
 #define NULL ((void*)0)
@@ -171,6 +173,7 @@ int clearenv(void);
 #define WCOREDUMP(s) ((s) & 0x80)
 #define WIFCONTINUED(s) ((s) == 0xffff)
 void *reallocarray (void *, size_t, size_t);
+void qsort_r (void *, size_t, size_t, int (*)(const void *, const void *, void *), void *);
 #endif
 #endif
 
index c2d464c8897cc7e797ee947240e1a8dc489ec548..dc47b7aee0280c0963bd310bac46e5eefb45fe44 100644 (file)
@@ -12,7 +12,9 @@ extern "C" {
 #include <features.h>
 
 #ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */
-#ifdef __cplusplus
+#if __cplusplus >= 201103L
+#define NULL nullptr
+#elif defined(__cplusplus)
 #define NULL 0L
 #else
 #define NULL ((void*)0)
index 10cb31083c0b2902668e0423f75401269c591980..11193eda15a64dca6f8e7b499baad69b220a56e9 100644 (file)
@@ -9,9 +9,13 @@
 #define MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED 16
 #define MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE 32
 #define MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE 64
+#define MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ 128
+#define MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ 256
 
 #define MEMBARRIER_CMD_SHARED MEMBARRIER_CMD_GLOBAL
 
+#define MEMBARRIER_CMD_FLAG_CPU 1
+
 int membarrier(int, int);
 
 #endif
index 80615c5d57bf937a0990292a584187aa0b58de8d..335ba2d714be677a29df7bb53bddd5acd4c37131 100644 (file)
@@ -44,6 +44,7 @@ extern "C" {
 
 #define MAP_HUGE_SHIFT 26
 #define MAP_HUGE_MASK  0x3f
+#define MAP_HUGE_16KB  (14 << 26)
 #define MAP_HUGE_64KB  (16 << 26)
 #define MAP_HUGE_512KB (19 << 26)
 #define MAP_HUGE_1MB   (20 << 26)
index 57a89c09ecb1ff8dc6448b6fd6a1405851768028..09bd6e9dfeffa8867432ed1080996f456e1e3981 100644 (file)
@@ -31,6 +31,7 @@ extern "C" {
 #define MS_REMOUNT     32
 #define MS_MANDLOCK    64
 #define MS_DIRSYNC     128
+#define MS_NOSYMFOLLOW 256
 #define MS_NOATIME     1024
 #define MS_NODIRATIME  2048
 #define MS_BIND        4096
index 4b9fcc050802c2e80a7565545886009442389eb7..087a75c9da0c216b0f5b9b991786e62d1303a9c4 100644 (file)
@@ -157,10 +157,26 @@ struct prctl_mm_map {
 #define PR_SET_TAGGED_ADDR_CTRL 55
 #define PR_GET_TAGGED_ADDR_CTRL 56
 #define PR_TAGGED_ADDR_ENABLE (1UL << 0)
+#define PR_MTE_TCF_SHIFT 1
+#define PR_MTE_TCF_NONE  (0UL << 1)
+#define PR_MTE_TCF_SYNC  (1UL << 1)
+#define PR_MTE_TCF_ASYNC (2UL << 1)
+#define PR_MTE_TCF_MASK  (3UL << 1)
+#define PR_MTE_TAG_SHIFT 3
+#define PR_MTE_TAG_MASK  (0xffffUL << 3)
 
 #define PR_SET_IO_FLUSHER 57
 #define PR_GET_IO_FLUSHER 58
 
+#define PR_SET_SYSCALL_USER_DISPATCH 59
+#define PR_SYS_DISPATCH_OFF 0
+#define PR_SYS_DISPATCH_ON 1
+#define SYSCALL_DISPATCH_FILTER_ALLOW 0
+#define SYSCALL_DISPATCH_FILTER_BLOCK 1
+
+#define PR_PAC_SET_ENABLED_KEYS 60
+#define PR_PAC_GET_ENABLED_KEYS 61
+
 int prctl (int, ...);
 
 #ifdef __cplusplus
index 5d62a9859aac6016e89e0134bce25ec270673da3..c72e3c061c3bb9ea7154efdcc9ab7ec83d940c51 100644 (file)
@@ -42,6 +42,7 @@ extern "C" {
 #define PTRACE_SECCOMP_GET_FILTER 0x420c
 #define PTRACE_SECCOMP_GET_METADATA 0x420d
 #define PTRACE_GET_SYSCALL_INFO 0x420e
+#define PTRACE_GET_RSEQ_CONFIGURATION  0x420f
 
 #define PT_READ_I PTRACE_PEEKTEXT
 #define PT_READ_D PTRACE_PEEKDATA
@@ -130,6 +131,14 @@ struct __ptrace_syscall_info {
        };
 };
 
+struct __ptrace_rseq_configuration {
+       uint64_t rseq_abi_pointer;
+       uint32_t rseq_abi_size;
+       uint32_t signature;
+       uint32_t flags;
+       uint32_t pad;
+};
+
 long ptrace(int, ...);
 
 #ifdef __cplusplus
index a98f16bc97745270fdcfc89a9df191fa03eb6679..4d574c6627e07b7c073d2b55208a04c0b7b0d3d1 100644 (file)
@@ -298,6 +298,8 @@ struct linger {
 #define SCM_TXTIME              SO_TXTIME
 #define SO_BINDTOIFINDEX        62
 #define SO_DETACH_REUSEPORT_BPF 68
+#define SO_PREFER_BUSY_POLL     69
+#define SO_BUSY_POLL_BUDGET     70
 
 #ifndef SOL_SOCKET
 #define SOL_SOCKET      1
index 1fb87689d18e6e0c0909061ee1f92511ac36d3a1..f53414878aa0daff7d6f9e9f042443a9b2e2f9e6 100644 (file)
@@ -8,7 +8,9 @@ extern "C" {
 #include <features.h>
 
 #ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */
-#ifdef __cplusplus
+#if __cplusplus >= 201103L
+#define NULL nullptr
+#elif defined(__cplusplus)
 #define NULL 0L
 #else
 #define NULL ((void*)0)
index 7ca99aeca063da92c581ab4ce90429bfcc4cbb19..9231d605c4cf6a0e6950c672a7182f9a725ceac8 100644 (file)
@@ -15,12 +15,16 @@ extern "C" {
 #define SEEK_SET 0
 #define SEEK_CUR 1
 #define SEEK_END 2
+#define SEEK_DATA 3
+#define SEEK_HOLE 4
 #else
 #include <__header_unistd.h>
 #endif
 
 #ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */
-#ifdef __cplusplus
+#if __cplusplus >= 201103L
+#define NULL nullptr
+#elif defined(__cplusplus)
 #define NULL 0L
 #else
 #define NULL ((void*)0)
index 4f45539f16acf706f34e84e93b110563313b8538..06b088aa9bde488d10892eae44f4f4635b5155ce 100644 (file)
@@ -41,7 +41,9 @@ extern "C" {
 #endif
 
 #ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */
-#ifdef __cplusplus
+#if __cplusplus >= 201103L
+#define NULL nullptr
+#elif defined(__cplusplus)
 #define NULL 0L
 #else
 #define NULL ((void*)0)
index 6b868c841476a34b0bb3eea98be9611052b7b3ef..5b9c8be42160c1730424226c1d29e05a6964a86e 100644 (file)
@@ -579,6 +579,7 @@ static void *mmap_fixed(void *p, size_t n, int prot, int flags, int fd, off_t of
 {
        static int no_map_fixed;
        char *q;
+       if (!n) return p;
        if (!no_map_fixed) {
                q = mmap(p, n, prot, flags|MAP_FIXED, fd, off);
                if (!DL_NOMMU_SUPPORT || q != MAP_FAILED || errno != EINVAL)
@@ -1830,7 +1831,7 @@ void __dls3(size_t *sp, size_t *auxv)
                        dprintf(2, "%s: cannot load %s: %s\n", ldname, argv[0], strerror(errno));
                        _exit(1);
                }
-               Ehdr *ehdr = (void *)map_library(fd, &app);
+               Ehdr *ehdr = map_library(fd, &app);
                if (!ehdr) {
                        dprintf(2, "%s: %s: Not a valid dynamic program\n", ldname, argv[0]);
                        _exit(1);
@@ -2330,7 +2331,8 @@ int dl_iterate_phdr(int(*callback)(struct dl_phdr_info *info, size_t size, void
                info.dlpi_adds      = gencnt;
                info.dlpi_subs      = 0;
                info.dlpi_tls_modid = current->tls_id;
-               info.dlpi_tls_data  = current->tls.image;
+               info.dlpi_tls_data = !current->tls_id ? 0 :
+                       __tls_get_addr((tls_mod_off_t[]){current->tls_id,0});
 
                ret = (callback)(&info, sizeof (info), data);
 
index 2e048540fac8c261cb7a625f0f2d66bb23aee5c9..ed8acf0f5a0161675da8692ba90112afc760c186 100644 (file)
@@ -2,8 +2,10 @@
 
 // FIXME
 
+static const float float_pi_2 = M_PI_2;
+
 float complex cacosf(float complex z)
 {
        z = casinf(z);
-       return CMPLXF((float)M_PI_2 - crealf(z), -cimagf(z));
+       return CMPLXF(float_pi_2 - crealf(z), -cimagf(z));
 }
index ef3907a5069e245d52b11078f072ab113828ce19..1d569f2dacf99b075d8b205e874383c2c41c9212 100644 (file)
@@ -61,13 +61,15 @@ static const double DP1 = 3.140625;
 static const double DP2 = 9.67502593994140625E-4;
 static const double DP3 = 1.509957990978376432E-7;
 
+static const float float_pi = M_PI;
+
 static float _redupif(float xx)
 {
        float x, t;
        long i;
 
        x = xx;
-       t = x/(float)M_PI;
+       t = x/float_pi;
        if (t >= 0.0f)
                t += 0.5f;
        else
index 9ae1e17c0d8e26c91e0608794427f790bd94b65c..d2b8f5a972ada4f392d67b9967415092264a661f 100644 (file)
@@ -3,6 +3,6 @@
 double complex cproj(double complex z)
 {
        if (isinf(creal(z)) || isinf(cimag(z)))
-               return CMPLX(INFINITY, copysign(0.0, creal(z)));
+               return CMPLX(INFINITY, copysign(0.0, cimag(z)));
        return z;
 }
index 03fab339d9215dc589142444f9440195549339e3..15a874bb2f8bbf7ddf337e4233eb97fd3217dccc 100644 (file)
@@ -3,6 +3,6 @@
 float complex cprojf(float complex z)
 {
        if (isinf(crealf(z)) || isinf(cimagf(z)))
-               return CMPLXF(INFINITY, copysignf(0.0, crealf(z)));
+               return CMPLXF(INFINITY, copysignf(0.0, cimagf(z)));
        return z;
 }
index 38a494c5c4b9c14bee615c8b337f17f6adcdc0e7..531ffa1c5e85d2fb93c6845a6a240e5091c98650 100644 (file)
@@ -9,7 +9,7 @@ long double complex cprojl(long double complex z)
 long double complex cprojl(long double complex z)
 {
        if (isinf(creall(z)) || isinf(cimagl(z)))
-               return CMPLXL(INFINITY, copysignl(0.0, creall(z)));
+               return CMPLXL(INFINITY, copysignl(0.0, cimagl(z)));
        return z;
 }
 #endif
index 5d05a3d1a064737b3a8357f2d0084f34b4d5c7ba..7746f3b6031025c46f593e54fe6627e45299dbf8 100644 (file)
@@ -1,23 +1,23 @@
-16,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,
-36,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,
+16,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,
+37,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,
 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,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,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,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,16,16,16,16,
-16,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,
+16,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,
 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,16,
+16,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,
+16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,51,16,16,52,
+53,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,
+69,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,
+16,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,
 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,16,
-16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,49,16,16,50,
-51,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,
-67,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,
-16,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,
+16,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,
 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,16,
-16,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,
 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,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,16,16,
-16,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,
-16,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,
-84,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,16,16,16,78,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
+16,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,
+86,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
 16,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,
 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
 242,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,
 2,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,
 0,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,
-0,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,
-0,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,
-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,0,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,128,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,15,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,0,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,3,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,
+0,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,
+255,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,
+0,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,
+15,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,
+0,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,
+128,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,
+15,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,
+0,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,
+3,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,
 251,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,
 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,0,128,3,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,255,255,255,255,0,0,0,0,
 0,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,
 0,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,
 0,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,
-0,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,
-0,16,0,0,0,0,0,0,157,193,2,0,0,0,0,48,64,
-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,32,33,0,0,0,0,0,64,
-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,255,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,0,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,0,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,0,0,0,
-0,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,
-0,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,
-0,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,
-0,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,
-127,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,
-0,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,
-0,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,
-31,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,
-0,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,
-0,60,176,1,0,0,48,0,0,0,
-0,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,
-0,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,
-128,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,
-0,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,
-126,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,
-0,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,
-0,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,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,
-0,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,
-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,31,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,0,0,0,0,0,0,0,0,128,0,0,0,0,0,0,
-0,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,
-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,248,255,231,15,0,0,0,60,0,
-0,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,
-0,0,0,255,255,255,255,255,255,127,248,255,255,255,255,255,31,32,0,16,0,0,248,
-254,255,0,0,0,0,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,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,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,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,127,0,0,0,0,0,0,0,0,0,0,0,0,0,240,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,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,0,16,0,0,0,0,0,0,157,193,2,0,0,0,0,48,64,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,32,33,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,255,255,255,0,0,0,
+64,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,
+255,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,
+0,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,
+0,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,
+0,0,0,0,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,0,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,0,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,0,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,127,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,0,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,0,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,31,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,0,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,0,60,176,1,0,0,48,0,0,0,0,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,0,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,128,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,0,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,126,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,0,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,0,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,0,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,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,31,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,0,0,0,0,0,0,0,0,128,0,0,0,0,0,0,0,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,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,248,255,231,15,0,0,0,60,0,0,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,0,0,0,255,255,
+255,255,255,255,127,248,255,255,255,255,255,31,32,0,16,0,0,248,254,255,0,0,0,
+0,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,
+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,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,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,127,0,0,0,0,0,0,0,0,0,0,0,0,0,240,7,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
index 8fbe526271d812cc467664e9a1c96fb813c528b7..c5b277bdcf2e6b927dd93090137ea66dcb1c76a4 100644 (file)
@@ -69,7 +69,8 @@ weak_alias(libc_start_init, __libc_start_init);
 typedef int lsm2_fn(int (*)(int,char **,char **), int, char **);
 static lsm2_fn libc_start_main_stage2;
 
-int __libc_start_main(int (*main)(int,char **,char **), int argc, char **argv)
+int __libc_start_main(int (*main)(int,char **,char **), int argc, char **argv,
+       void (*init_dummy)(), void(*fini_dummy)(), void(*ldso_dummy)())
 {
        char **envp = argv+argc+1;
 
index bf5a280ad95b66187dabb3e61ce4ebecb5d2ac08..e53526020f751d34542f07c6b30d94c5dc08bf72 100644 (file)
@@ -9,6 +9,15 @@ void __init_ssp(void *entropy)
        if (entropy) memcpy(&__stack_chk_guard, entropy, sizeof(uintptr_t));
        else __stack_chk_guard = (uintptr_t)&__stack_chk_guard * 1103515245;
 
+#if UINTPTR_MAX >= 0xffffffffffffffff
+       /* Sacrifice 8 bits of entropy on 64bit to prevent leaking/
+        * overwriting the canary via string-manipulation functions.
+        * The NULL byte is on the second byte so that off-by-ones can
+        * still be detected. Endianness is taken care of
+        * automatically. */
+       ((char *)&__stack_chk_guard)[1] = 0;
+#endif
+
        __pthread_self()->canary = __stack_chk_guard;
 }
 
index db0660d2ee7bba915320fdfc170a9c034bb9491d..bd6dccbe2d3fdf63134ddb5d291ae423978cd8e6 100644 (file)
@@ -124,6 +124,12 @@ E(ENOMEDIUM,    "No medium found")
 E(EMEDIUMTYPE,  "Wrong medium type")
 #endif
 E(EMULTIHOP,    "Multihop attempted")
+#ifdef __wasilibc_unmodified_upstream // errno value not in WASI
+E(ENOKEY,       "Required key not available")
+E(EKEYEXPIRED,  "Key has expired")
+E(EKEYREVOKED,  "Key has been revoked")
+E(EKEYREJECTED, "Key was rejected by service")
+#endif
 #ifdef __wasilibc_unmodified_upstream // errno value in WASI and not musl
 #else
 // WASI adds this errno code.
index 85bef40f10a65e961ed3090df09890bde4c3db1d..d4248f26f7183a8287cdc900b1faf655b6b71d46 100644 (file)
@@ -1,3 +1,3 @@
-#ifdef _SOFT_FLOAT
+#if defined(_SOFT_FLOAT) || defined(__NO_FPRS__)
 #include "../fenv.c"
 #endif
index 22cea216a0e87460cffa9f50ab29acefe565084f..55055d0b3a87dc46e4afe0598a461f402a22b393 100644 (file)
@@ -1,4 +1,4 @@
-#ifndef _SOFT_FLOAT
+#if !defined(_SOFT_FLOAT) && !defined(__NO_FPRS__)
 .global feclearexcept
 .type feclearexcept,@function
 feclearexcept:
index e9da20158c157582eb45c72f63f552a0c87383e5..812b04de2fd6b6efb1576a72eea4fa16007fc2ad 100644 (file)
@@ -8,6 +8,7 @@ hidden void __env_rm_add(char *, char *);
 hidden int __mkostemps(char *, int, int);
 hidden int __ptsname_r(int, char *, size_t);
 hidden char *__randname(char *);
+hidden void __qsort_r (void *, size_t, size_t, int (*)(const void *, const void *, void *), void *);
 
 hidden void *__libc_malloc(size_t);
 hidden void *__libc_malloc_impl(size_t);
index 86c87ef8358c86c78755409909baf63533cb0d4b..9546dd360961ada14fa5ae301416888caab57b9f 100644 (file)
@@ -1,5 +1,6 @@
 #include <elf.h>
 #include <link.h>
+#include "pthread_impl.h"
 #include "libc.h"
 
 #define AUX_CNT 38
@@ -35,7 +36,7 @@ static int static_dl_iterate_phdr(int(*callback)(struct dl_phdr_info *info, size
        info.dlpi_subs  = 0;
        if (tls_phdr) {
                info.dlpi_tls_modid = 1;
-               info.dlpi_tls_data = (void *)(base + tls_phdr->p_vaddr);
+               info.dlpi_tls_data = __tls_get_addr((tls_mod_off_t[]){1,0});
        } else {
                info.dlpi_tls_modid = 0;
                info.dlpi_tls_data = 0;
index 4e78798ded26b09992bb69c4383447a805ae2ab9..dcaf73d4e64882e857fa3f1ef5192af0e4bf6b16 100644 (file)
@@ -2,13 +2,21 @@
 #include <pwd.h>
 #include <stdio.h>
 #include <unistd.h>
+#include <string.h>
 
 char *cuserid(char *buf)
 {
+       static char usridbuf[L_cuserid];
        struct passwd pw, *ppw;
        long pwb[256];
-       if (getpwuid_r(geteuid(), &pw, (void *)pwb, sizeof pwb, &ppw))
-               return 0;
-       snprintf(buf, L_cuserid, "%s", pw.pw_name);
+       if (buf) *buf = 0;
+       getpwuid_r(geteuid(), &pw, (void *)pwb, sizeof pwb, &ppw);
+       if (!ppw)
+               return buf;
+       size_t len = strnlen(pw.pw_name, L_cuserid);
+       if (len == L_cuserid)
+               return buf;
+       if (!buf) buf = usridbuf;
+       memcpy(buf, pw.pw_name, len+1);
        return buf;
 }
index deff5b101aade0dde5efff1cad5272b3e782ef83..93baa8147e422e1d319f973159ec19d785205ba5 100644 (file)
@@ -24,9 +24,9 @@ int epoll_ctl(int fd, int op, int fd2, struct epoll_event *ev)
 
 int epoll_pwait(int fd, struct epoll_event *ev, int cnt, int to, const sigset_t *sigs)
 {
-       int r = __syscall(SYS_epoll_pwait, fd, ev, cnt, to, sigs, _NSIG/8);
+       int r = __syscall_cp(SYS_epoll_pwait, fd, ev, cnt, to, sigs, _NSIG/8);
 #ifdef SYS_epoll_wait
-       if (r==-ENOSYS && !sigs) r = __syscall(SYS_epoll_wait, fd, ev, cnt, to);
+       if (r==-ENOSYS && !sigs) r = __syscall_cp(SYS_epoll_wait, fd, ev, cnt, to);
 #endif
        return __syscall_ret(r);
 }
index d1e6c6d13af33d6f095a58ed583502214fa2bcad..0b53286db753648d68ddef5b2905091bf39c4b9f 100644 (file)
@@ -132,6 +132,9 @@ char *dcngettext(const char *domainname, const char *msgid1, const char *msgid2,
        struct binding *q;
        int old_errno = errno;
 
+       /* match gnu gettext behaviour */
+       if (!msgid1) goto notrans;
+
        if ((unsigned)category >= LC_ALL) goto notrans;
 
        if (!domainname) domainname = __gettextdomain();
index 030b64cb0e706cdf29c7104526e86b6ee08d7adb..5ce33ae6ded0acc40a93706bf39db10c3775f2b3 100644 (file)
@@ -3,6 +3,11 @@
 #include "locale_impl.h"
 #include "libc.h"
 
+#define malloc __libc_malloc
+#define calloc undef
+#define realloc undef
+#define free undef
+
 locale_t __duplocale(locale_t old)
 {
        locale_t new = malloc(sizeof *new);
diff --git a/libc-top-half/musl/src/locale/strtod_l.c b/libc-top-half/musl/src/locale/strtod_l.c
new file mode 100644 (file)
index 0000000..574ba14
--- /dev/null
@@ -0,0 +1,22 @@
+#define _GNU_SOURCE
+#include <stdlib.h>
+#include <locale.h>
+
+float strtof_l(const char *restrict s, char **restrict p, locale_t l)
+{
+       return strtof(s, p);
+}
+
+double strtod_l(const char *restrict s, char **restrict p, locale_t l)
+{
+       return strtod(s, p);
+}
+
+long double strtold_l(const char *restrict s, char **restrict p, locale_t l)
+{
+       return strtold(s, p);
+}
+
+weak_alias(strtof_l, __strtof_l);
+weak_alias(strtod_l, __strtod_l);
+weak_alias(strtold_l, __strtold_l);
index f17a952cb46fb6679a5146bcb1b2b00b33f3f1df..3944f7b28f3c3265cb092cf984c69e89f62f435a 100644 (file)
@@ -2,5 +2,5 @@
 
 void free(void *p)
 {
-       return __libc_free(p);
+       __libc_free(p);
 }
index 3411689600e88e4de7c5e861483482e445e09e6c..e0862a83ae00444734417d97dea6b4a679e557df 100644 (file)
@@ -22,6 +22,9 @@ void *aligned_alloc(size_t align, size_t len)
        if (align <= UNIT) align = UNIT;
 
        unsigned char *p = malloc(len + align - UNIT);
+       if (!p)
+               return 0;
+
        struct meta *g = get_meta(p);
        int idx = get_slot_index(p);
        size_t stride = get_stride(g);
index 40745f97daf695a27c48b8c392a543c66be1cc4c..418a085c18aaebf3192589a7e716856de9af548a 100644 (file)
@@ -119,7 +119,11 @@ void free(void *p)
        if (((uintptr_t)(start-1) ^ (uintptr_t)end) >= 2*PGSZ && g->last_idx) {
                unsigned char *base = start + (-(uintptr_t)start & (PGSZ-1));
                size_t len = (end-base) & -PGSZ;
-               if (len) madvise(base, len, MADV_FREE);
+               if (len) {
+                       int e = errno;
+                       madvise(base, len, MADV_FREE);
+                       errno = e;
+               }
        }
 
        // atomic free without locking if this is neither first or last slot
@@ -139,5 +143,9 @@ void free(void *p)
        wrlock();
        struct mapinfo mi = nontrivial_free(g, idx);
        unlock();
-       if (mi.len) munmap(mi.base, mi.len);
+       if (mi.len) {
+               int e = errno;
+               munmap(mi.base, mi.len);
+               errno = e;
+       }
 }
index 53f5f959ec24c31dc57a4a22af1c445ccc35804f..25d00d44dea770a7f78ac61a15aeda9308057b2a 100644 (file)
@@ -11,7 +11,7 @@
 #include "malloc_impl.h"
 #include "fork_impl.h"
 
-#define malloc __libc_malloc
+#define malloc __libc_malloc_impl
 #define realloc __libc_realloc
 #define free __libc_free
 
@@ -481,12 +481,14 @@ void __bin_chunk(struct chunk *self)
        if (size > RECLAIM && (size^(size-osize)) > size-osize) {
                uintptr_t a = (uintptr_t)self + SIZE_ALIGN+PAGE_SIZE-1 & -PAGE_SIZE;
                uintptr_t b = (uintptr_t)next - SIZE_ALIGN & -PAGE_SIZE;
+               int e = errno;
 #if 1
                __madvise((void *)a, b-a, MADV_DONTNEED);
 #else
                __mmap((void *)a, b-a, PROT_READ|PROT_WRITE,
                        MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED, -1, 0);
 #endif
+               errno = e;
        }
 
        unlock_bin(i);
@@ -499,7 +501,9 @@ static void unmap_chunk(struct chunk *self)
        size_t len = CHUNK_SIZE(self) + extra;
        /* Crash on double free */
        if (extra & 1) a_crash();
+       int e = errno;
        __munmap(base, len);
+       errno = e;
 }
 
 void free(void *p)
index 8a4ec4d57ead3cbcd473d2ddfdd43d910956f1b9..b773d48e2b84627e0d405a30d9ca8c2994aafe1c 100644 (file)
@@ -15,12 +15,12 @@ float acoshf(float x)
        uint32_t a = u.i & 0x7fffffff;
 
        if (a < 0x3f800000+(1<<23))
-               /* |x| < 2, invalid if x < 1 or nan */
+               /* |x| < 2, invalid if x < 1 */
                /* up to 2ulp error in [1,1.125] */
                return log1pf(x-1 + sqrtf((x-1)*(x-1)+2*(x-1)));
-       if (a < 0x3f800000+(12<<23))
-               /* |x| < 0x1p12 */
+       if (u.i < 0x3f800000+(12<<23))
+               /* 2 <= x < 0x1p12 */
                return logf(2*x - 1/(x+sqrtf(x*x-1)));
-       /* x >= 0x1p12 */
+       /* x >= 0x1p12 or x <= -2 or nan */
        return logf(x) + 0.693147180559945309417232121458176568f;
 }
index 297e0b44a2ebcc99d406bc7641d1fbf8aa76b097..09a41afe7d2c00117672fe9c3c709e27d55001fa 100644 (file)
@@ -16,7 +16,6 @@
 #include "libm.h"
 
 static const float
-o_threshold = 8.8721679688e+01, /* 0x42b17180 */
 ln2_hi      = 6.9313812256e-01, /* 0x3f317180 */
 ln2_lo      = 9.0580006145e-06, /* 0x3717f7d1 */
 invln2      = 1.4426950216e+00, /* 0x3fb8aa3b */
@@ -41,7 +40,7 @@ float expm1f(float x)
                        return x;
                if (sign)
                        return -1;
-               if (x > o_threshold) {
+               if (hx > 0x42b17217) { /* x > log(FLT_MAX) */
                        x *= 0x1p127f;
                        return x;
                }
index 111c0aec986ee249cdd06e5af98c738657e5549c..7c65acf1fc5e07eabcad635b31af3ee747319106 100644 (file)
@@ -77,21 +77,16 @@ float fmaf(float x, float y, float z)
         * If result is inexact, and exactly halfway between two float values,
         * we need to adjust the low-order bit in the direction of the error.
         */
-#ifdef FE_TOWARDZERO
-       fesetround(FE_TOWARDZERO);
-#endif
-#ifdef __wasilibc_unmodified_upstream // WASI doesn't need old GCC workarounds
-       volatile double vxy = xy;  /* XXX work around gcc CSE bug */
-#else
-       double vxy = xy;
-#endif
-       double adjusted_result = vxy + z;
-       fesetround(FE_TONEAREST);
-       if (result == adjusted_result) {
-               u.f = adjusted_result;
+       double err;
+       int neg = u.i >> 63;
+       if (neg == (z > xy))
+               err = xy - result + z;
+       else
+               err = z - result + xy;
+       if (neg == (err < 0))
                u.i++;
-               adjusted_result = u.f;
-       }
-       z = adjusted_result;
+       else
+               u.i--;
+       z = u.f;
        return z;
 }
index 0efc21ef831d71cd73ca33ced836e3cc7bdb3a90..9453a3aa981ffcc70343a355a41a758fe3070b1d 100644 (file)
@@ -1,6 +1,6 @@
 #include <math.h>
 
-#if defined(_SOFT_FLOAT) || defined(BROKEN_PPC_D_ASM)
+#if defined(_SOFT_FLOAT) || defined(__NO_FPRS__) || defined(BROKEN_PPC_D_ASM)
 
 #include "../fabs.c"
 
index d88b5911c0dd9829b849e4088d9ff58e32827e87..2e9da588dd65bed4f08e8a70cef491feb41b6d3a 100644 (file)
@@ -1,6 +1,6 @@
 #include <math.h>
 
-#ifdef _SOFT_FLOAT
+#if defined(_SOFT_FLOAT) || defined(__NO_FPRS__)
 
 #include "../fabsf.c"
 
index 135c990357d2d2deda4bbd4158a312d48e1f1c8d..0eb2ba1ef58ae2d5e867bd036368afb7ba61d4f5 100644 (file)
@@ -1,6 +1,6 @@
 #include <math.h>
 
-#if defined(_SOFT_FLOAT) || defined(BROKEN_PPC_D_ASM)
+#if defined(_SOFT_FLOAT) || defined(__NO_FPRS__) || defined(BROKEN_PPC_D_ASM)
 
 #include "../fma.c"
 
index a99a2a3ba165ea5496e321bc5a59ae99f74cedbd..dc1a749d984c2e29db51e58bd72a79e0f456bc8a 100644 (file)
@@ -1,6 +1,6 @@
 #include <math.h>
 
-#ifdef _SOFT_FLOAT
+#if defined(_SOFT_FLOAT) || defined(__NO_FPRS__)
 
 #include "../fmaf.c"
 
index 492828119aeaa8583ed7dd72ab67f89507e8aa9c..35804f026ef687c1a7e4150ed384c0bafb42a03c 100644 (file)
@@ -6,6 +6,7 @@
 #include <stddef.h>
 #include <stdint.h>
 #include <string.h>
+#include <endian.h>
 #include "syscall.h"
 
 #define alignof(t) offsetof(struct { char c; t x; }, x)
@@ -53,7 +54,7 @@ static const struct ioctl_compat_map compat_map[] = {
        { _IOWR('A', 0x23, char[136]), _IOWR('A', 0x23, char[132]), 0, WR, 1, 0 },
        { 0, 0, 4, WR, 1, 0 }, /* snd_pcm_sync_ptr (flags only) */
        { 0, 0, 32, WR, 1, OFFS(8,12,16,24,28) }, /* snd_pcm_mmap_status */
-       { 0, 0, 8, WR, 1, OFFS(0,4) }, /* snd_pcm_mmap_control */
+       { 0, 0, 4, WR, 1, 0 }, /* snd_pcm_mmap_control (each member) */
 
        /* VIDIOC_QUERYBUF, VIDIOC_QBUF, VIDIOC_DQBUF, VIDIOC_PREPARE_BUF */
        { _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,
                 * if another exception appears this needs changing. */
                convert_ioctl_struct(map+1, old, new, dir);
                convert_ioctl_struct(map+2, old+4, new+8, dir);
-               convert_ioctl_struct(map+3, old+68, new+72, dir);
+               /* snd_pcm_mmap_control, special-cased due to kernel
+                * type definition having been botched. */
+               int adj = BYTE_ORDER==BIG_ENDIAN ? 4 : 0;
+               convert_ioctl_struct(map+3, old+68, new+72+adj, dir);
+               convert_ioctl_struct(map+3, old+72, new+76+3*adj, dir);
                return;
        }
        for (int i=0; i < map->noffs; i++) {
index d38e371bcda395855a4e9a125d4a75a115c76416..dc3406b851f6849704bf46d648a53a73855e46f4 100644 (file)
@@ -40,7 +40,15 @@ retry:
        buf[0] = NSCDVERSION;
 
        fd = socket(PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
-       if (fd < 0) return NULL;
+       if (fd < 0) {
+               if (errno == EAFNOSUPPORT) {
+                       f = fopen("/dev/null", "re");
+                       if (f)
+                               errno = errno_save;
+                       return f;
+               }
+               return 0;
+       }
 
        if(!(f = fdopen(fd, "r"))) {
                close(fd);
index 5adf1443874854c6a7a33c4b641ff18c152a0f38..7cf733b21dc14ce2708fac19fa46dea87fcdfa9b 100644 (file)
@@ -10,3 +10,8 @@ struct fdop {
        mode_t mode;
        char path[];
 };
+
+#define malloc __libc_malloc
+#define calloc __libc_calloc
+#define realloc undef
+#define free __libc_free
index cdda5979916dd1437cc1e0249617847291fcd3e9..0c2ef8fa37985aefbb8f0fe9756c895401950374 100644 (file)
@@ -5,6 +5,7 @@
 
 int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *fa, int fd)
 {
+       if (fd < 0) return EBADF;
        struct fdop *op = malloc(sizeof *op);
        if (!op) return ENOMEM;
        op->cmd = FDOP_CLOSE;
index 0367498fd4f36ca9fe5d0ae12ec65fc15936bc5b..addca4d4f0a545159f71569806906c3fda46380a 100644 (file)
@@ -5,6 +5,7 @@
 
 int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *fa, int srcfd, int fd)
 {
+       if (srcfd < 0 || fd < 0) return EBADF;
        struct fdop *op = malloc(sizeof *op);
        if (!op) return ENOMEM;
        op->cmd = FDOP_DUP2;
index 436c683d25d4ecf95371fdb488affa24377cd303..e89ede8c3c47acae29c9f1e177d608037668f4b1 100644 (file)
@@ -6,6 +6,7 @@
 
 int posix_spawn_file_actions_addfchdir_np(posix_spawn_file_actions_t *fa, int fd)
 {
+       if (fd < 0) return EBADF;
        struct fdop *op = malloc(sizeof *op);
        if (!op) return ENOMEM;
        op->cmd = FDOP_FCHDIR;
index 368922c76b5259944059bad15d1c1d9d8e79fce5..82bbcec9eb42cd5f112d2a6b66d0769b8349f11f 100644 (file)
@@ -6,6 +6,7 @@
 
 int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *restrict fa, int fd, const char *restrict path, int flags, mode_t mode)
 {
+       if (fd < 0) return EBADF;
        struct fdop *op = malloc(sizeof *op + strlen(path) + 1);
        if (!op) return ENOMEM;
        op->cmd = FDOP_OPEN;
index e598bd056e6ca240c5ac1a13263f35acce584dcd..611389fed9f399a1b324c9ee5ad9add114b231c5 100644 (file)
@@ -37,7 +37,37 @@ longjmp:
        lwz 29, 72(3)
        lwz 30, 76(3)
        lwz 31, 80(3)
-#ifndef _SOFT_FLOAT
+#if defined(_SOFT_FLOAT) || defined(__NO_FPRS__)
+       mflr 0
+       bl 1f
+       .hidden __hwcap
+       .long __hwcap-.
+1:     mflr 4
+       lwz 5, 0(4)
+       lwzx 4, 4, 5
+       andis. 4, 4, 0x80
+       beq 1f
+       .long 0x11c35b01 /* evldd 14,88(3) */
+       .long 0x11e36301 /* ... */
+       .long 0x12036b01
+       .long 0x12237301
+       .long 0x12437b01
+       .long 0x12638301
+       .long 0x12838b01
+       .long 0x12a39301
+       .long 0x12c39b01
+       .long 0x12e3a301
+       .long 0x1303ab01
+       .long 0x1323b301
+       .long 0x1343bb01
+       .long 0x1363c301
+       .long 0x1383cb01
+       .long 0x13a3d301
+       .long 0x13c3db01
+       .long 0x13e3e301 /* evldd 31,224(3) */
+       .long 0x11a3eb01 /* evldd 13,232(3) */
+1:     mtlr 0
+#else
        lfd 14,88(3)
        lfd 15,96(3)
        lfd 16,104(3)
index cd91a207f5c7fd82aa2da53b19558a5634189e60..f1fcce339e59af502406b5a856bad1ed2e0a6b18 100644 (file)
@@ -37,7 +37,37 @@ setjmp:
        stw 29, 72(3)
        stw 30, 76(3)
        stw 31, 80(3)
-#ifndef _SOFT_FLOAT
+#if defined(_SOFT_FLOAT) || defined(__NO_FPRS__)
+       mflr 0
+       bl 1f
+       .hidden __hwcap
+       .long __hwcap-.
+1:     mflr 4
+       lwz 5, 0(4)
+       lwzx 4, 4, 5
+       andis. 4, 4, 0x80
+       beq 1f
+       .long 0x11c35b21 /* evstdd 14,88(3) */
+       .long 0x11e36321 /* ... */
+       .long 0x12036b21
+       .long 0x12237321
+       .long 0x12437b21
+       .long 0x12638321
+       .long 0x12838b21
+       .long 0x12a39321
+       .long 0x12c39b21
+       .long 0x12e3a321
+       .long 0x1303ab21
+       .long 0x1323b321
+       .long 0x1343bb21
+       .long 0x1363c321
+       .long 0x1383cb21
+       .long 0x13a3d321
+       .long 0x13c3db21
+       .long 0x13e3e321 /* evstdd 31,224(3) */
+       .long 0x11a3eb21 /* evstdd 13,232(3) */
+1:     mtlr 0
+#else
        stfd 14,88(3)
        stfd 15,96(3)
        stfd 16,104(3)
index d7f6100134572aeaa42131dc001ff287ffc9fbbd..cc8698f0bb7fbcf5508ceaf43edd4c8954e81075 100644 (file)
@@ -3,9 +3,9 @@
 #include <signal.h>
 
 static const unsigned long all_mask[] = {
-#if ULONG_MAX == 0xffffffff && _NSIG == 129
+#if ULONG_MAX == 0xffffffff && _NSIG > 65
        -1UL, -1UL, -1UL, -1UL
-#elif ULONG_MAX == 0xffffffff
+#elif ULONG_MAX == 0xffffffff || _NSIG > 65
        -1UL, -1UL
 #else
        -1UL
index b08b30491af14982248461caafd62d3a3aa64909..195cb4355a14b10b05b0b50cf293456b5b7b4f75 100644 (file)
@@ -1,6 +1,5 @@
 #include "stdio_impl.h"
 #include <wchar.h>
-#include <errno.h>
 
 wint_t __fgetwc_unlocked(FILE *);
 
@@ -12,10 +11,6 @@ wchar_t *fgetws(wchar_t *restrict s, int n, FILE *restrict f)
 
        FLOCK(f);
 
-       /* Setup a dummy errno so we can detect EILSEQ. This is
-        * the only way to catch encoding errors in the form of a
-        * partial character just before EOF. */
-       errno = EAGAIN;
        for (; n; n--) {
                wint_t c = __fgetwc_unlocked(f);
                if (c == WEOF) break;
@@ -23,7 +18,7 @@ wchar_t *fgetws(wchar_t *restrict s, int n, FILE *restrict f)
                if (c == '\n') break;
        }
        *p = 0;
-       if (ferror(f) || errno==EILSEQ) p = s;
+       if (ferror(f)) p = s;
 
        FUNLOCK(f);
 
index 439308f7574ba7efbd03ea9626c9041f3b7a322c..c07f7e952642ba3bef35f4eb8a7865e6a8d1b5dc 100644 (file)
@@ -1,7 +1,14 @@
 #include "stdio_impl.h"
+#include <errno.h>
 
 int __fseeko_unlocked(FILE *f, off_t off, int whence)
 {
+       /* Fail immediately for invalid whence argument. */
+       if (whence != SEEK_CUR && whence != SEEK_SET && whence != SEEK_END) {
+               errno = EINVAL;
+               return -1;
+       }
+
        /* Adjust relative offset for unread data in buffer, if any. */
        if (whence == SEEK_CUR && f->rend) off -= f->rend - f->rpos;
 
index d2f5b15ab1d7da3d693bcf5d9d4652ec89d4e858..df114441c72562a8bfd39e6e1fb3f4687d6715e9 100644 (file)
@@ -55,9 +55,11 @@ ssize_t getdelim(char **restrict s, size_t *restrict n, int delim, FILE *restric
                        *s = tmp;
                        *n = m;
                }
-               memcpy(*s+i, f->rpos, k);
-               f->rpos += k;
-               i += k;
+               if (k) {
+                       memcpy(*s+i, f->rpos, k);
+                       f->rpos += k;
+                       i += k;
+               }
                if (z) break;
                if ((c = getc_unlocked(f)) == EOF) {
                        if (!i || !feof(f)) {
index 92cb57ee937b7ea3908de2c0de86ced5eefb3d8d..3ec833941c821435ccf8128e16cfd95192799f36 100644 (file)
@@ -31,25 +31,12 @@ FILE *popen(const char *cmd, const char *mode)
                __syscall(SYS_close, p[1]);
                return NULL;
        }
-       FLOCK(f);
-
-       /* If the child's end of the pipe happens to already be on the final
-        * fd number to which it will be assigned (either 0 or 1), it must
-        * be moved to a different fd. Otherwise, there is no safe way to
-        * remove the close-on-exec flag in the child without also creating
-        * a file descriptor leak race condition in the parent. */
-       if (p[1-op] == 1-op) {
-               int tmp = fcntl(1-op, F_DUPFD_CLOEXEC, 0);
-               if (tmp < 0) {
-                       e = errno;
-                       goto fail;
-               }
-               __syscall(SYS_close, p[1-op]);
-               p[1-op] = tmp;
-       }
 
        e = ENOMEM;
        if (!posix_spawn_file_actions_init(&fa)) {
+               for (FILE *l = *__ofl_lock(); l; l=l->next)
+                       if (l->pipe_pid && posix_spawn_file_actions_addclose(&fa, l->fd))
+                               goto fail;
                if (!posix_spawn_file_actions_adddup2(&fa, p[1-op], 1-op)) {
                        if (!(e = posix_spawn(&pid, "/bin/sh", &fa, 0,
                            (char *[]){ "sh", "-c", (char *)cmd, 0 }, __environ))) {
@@ -58,13 +45,14 @@ FILE *popen(const char *cmd, const char *mode)
                                if (!strchr(mode, 'e'))
                                        fcntl(p[op], F_SETFD, 0);
                                __syscall(SYS_close, p[1-op]);
-                               FUNLOCK(f);
+                               __ofl_unlock();
                                return f;
                        }
                }
+fail:
+               __ofl_unlock();
                posix_spawn_file_actions_destroy(&fa);
        }
-fail:
        fclose(f);
        __syscall(SYS_close, p[1-op]);
 
index da58fd3177814634d7e1b9b06ea2135ee633295f..314ddc29da1db7d236044683c264b1a9367b69c1 100644 (file)
@@ -24,6 +24,7 @@
 /* Smoothsort, an adaptive variant of Heapsort.  Memory usage: O(1).
    Run time: Worst case O(n log n), close to O(n) in the mostly-sorted case. */
 
+#define _BSD_SOURCE
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
@@ -31,7 +32,7 @@
 #include "atomic.h"
 #define ntz(x) a_ctz_l((x))
 
-typedef int (*cmpfun)(const void *, const void *);
+typedef int (*cmpfun)(const void *, const void *, void *);
 
 static inline int pntz(size_t p[2]) {
        int r = ntz(p[0] - 1);
@@ -88,7 +89,7 @@ static inline void shr(size_t p[2], int n)
        p[1] >>= n;
 }
 
-static void sift(unsigned char *head, size_t width, cmpfun cmp, int pshift, size_t lp[])
+static void sift(unsigned char *head, size_t width, cmpfun cmp, void *arg, int pshift, size_t lp[])
 {
        unsigned char *rt, *lf;
        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
                rt = head - width;
                lf = head - width - lp[pshift - 2];
 
-               if((*cmp)(ar[0], lf) >= 0 && (*cmp)(ar[0], rt) >= 0) {
+               if(cmp(ar[0], lf, arg) >= 0 && cmp(ar[0], rt, arg) >= 0) {
                        break;
                }
-               if((*cmp)(lf, rt) >= 0) {
+               if(cmp(lf, rt, arg) >= 0) {
                        ar[i++] = lf;
                        head = lf;
                        pshift -= 1;
@@ -115,7 +116,7 @@ static void sift(unsigned char *head, size_t width, cmpfun cmp, int pshift, size
        cycle(width, ar, i);
 }
 
-static void trinkle(unsigned char *head, size_t width, cmpfun cmp, size_t pp[2], int pshift, int trusty, size_t lp[])
+static void trinkle(unsigned char *head, size_t width, cmpfun cmp, void *arg, size_t pp[2], int pshift, int trusty, size_t lp[])
 {
        unsigned char *stepson,
                      *rt, *lf;
@@ -130,13 +131,13 @@ static void trinkle(unsigned char *head, size_t width, cmpfun cmp, size_t pp[2],
        ar[0] = head;
        while(p[0] != 1 || p[1] != 0) {
                stepson = head - lp[pshift];
-               if((*cmp)(stepson, ar[0]) <= 0) {
+               if(cmp(stepson, ar[0], arg) <= 0) {
                        break;
                }
                if(!trusty && pshift > 1) {
                        rt = head - width;
                        lf = head - width - lp[pshift - 2];
-                       if((*cmp)(rt, stepson) >= 0 || (*cmp)(lf, stepson) >= 0) {
+                       if(cmp(rt, stepson, arg) >= 0 || cmp(lf, stepson, arg) >= 0) {
                                break;
                        }
                }
@@ -150,11 +151,11 @@ static void trinkle(unsigned char *head, size_t width, cmpfun cmp, size_t pp[2],
        }
        if(!trusty) {
                cycle(width, ar, i);
-               sift(head, width, cmp, pshift, lp);
+               sift(head, width, cmp, arg, pshift, lp);
        }
 }
 
-void qsort(void *base, size_t nel, size_t width, cmpfun cmp)
+void __qsort_r(void *base, size_t nel, size_t width, cmpfun cmp, void *arg)
 {
        size_t lp[12*sizeof(size_t)];
        size_t i, size = width * nel;
@@ -173,16 +174,16 @@ void qsort(void *base, size_t nel, size_t width, cmpfun cmp)
 
        while(head < high) {
                if((p[0] & 3) == 3) {
-                       sift(head, width, cmp, pshift, lp);
+                       sift(head, width, cmp, arg, pshift, lp);
                        shr(p, 2);
                        pshift += 2;
                } else {
                        if(lp[pshift - 1] >= high - head) {
-                               trinkle(head, width, cmp, p, pshift, 0, lp);
+                               trinkle(head, width, cmp, arg, p, pshift, 0, lp);
                        } else {
-                               sift(head, width, cmp, pshift, lp);
+                               sift(head, width, cmp, arg, pshift, lp);
                        }
-                       
+
                        if(pshift == 1) {
                                shl(p, 1);
                                pshift = 0;
@@ -191,12 +192,12 @@ void qsort(void *base, size_t nel, size_t width, cmpfun cmp)
                                pshift = 1;
                        }
                }
-               
+
                p[0] |= 1;
                head += width;
        }
 
-       trinkle(head, width, cmp, p, pshift, 0, lp);
+       trinkle(head, width, cmp, arg, p, pshift, 0, lp);
 
        while(pshift != 1 || p[0] != 1 || p[1] != 0) {
                if(pshift <= 1) {
@@ -208,11 +209,13 @@ void qsort(void *base, size_t nel, size_t width, cmpfun cmp)
                        pshift -= 2;
                        p[0] ^= 7;
                        shr(p, 1);
-                       trinkle(head - lp[pshift] - width, width, cmp, p, pshift + 1, 1, lp);
+                       trinkle(head - lp[pshift] - width, width, cmp, arg, p, pshift + 1, 1, lp);
                        shl(p, 1);
                        p[0] |= 1;
-                       trinkle(head - width, width, cmp, p, pshift, 1, lp);
+                       trinkle(head - width, width, cmp, arg, p, pshift, 1, lp);
                }
                head -= width;
        }
 }
+
+weak_alias(__qsort_r, qsort_r);
diff --git a/libc-top-half/musl/src/stdlib/qsort_nr.c b/libc-top-half/musl/src/stdlib/qsort_nr.c
new file mode 100644 (file)
index 0000000..efe7cce
--- /dev/null
@@ -0,0 +1,14 @@
+#define _BSD_SOURCE
+#include <stdlib.h>
+
+typedef int (*cmpfun)(const void *, const void *);
+
+static int wrapper_cmp(const void *v1, const void *v2, void *cmp)
+{
+       return ((cmpfun)cmp)(v1, v2);
+}
+
+void qsort(void *base, size_t nel, size_t width, cmpfun cmp)
+{
+       __qsort_r(base, nel, width, wrapper_cmp, cmp);
+}
index 60158291df629e1709d2e14a9d928df1e391c7e1..184bca4629e7f9df4d477858d22e7d21c1ef3383 100644 (file)
@@ -46,24 +46,3 @@ long double strtold(const char *restrict s, char **restrict p)
        return strtox(s, p, 2);
 #endif
 }
-
-#ifdef __wasilibc_unmodified_upstream // WASI doesn't support signature-changing aliases
-weak_alias(strtof, strtof_l);
-weak_alias(strtod, strtod_l);
-weak_alias(strtold, strtold_l);
-weak_alias(strtof, __strtof_l);
-weak_alias(strtod, __strtod_l);
-weak_alias(strtold, __strtold_l);
-#else
-// WebAssembly doesn't permit signature-changing aliases, so use wrapper
-// functions instead.
-weak float strtof_l(const char *restrict s, char **restrict p, locale_t loc) {
-       return strtof(s, p);
-}
-weak double strtod_l(const char *restrict s, char **restrict p, locale_t loc) {
-       return strtod(s, p);
-}
-weak long double strtold_l(const char *restrict s, char **restrict p, locale_t loc) {
-       return strtold(s, p);
-}
-#endif
diff --git a/libc-top-half/musl/src/thread/pthread_getname_np.c b/libc-top-half/musl/src/thread/pthread_getname_np.c
new file mode 100644 (file)
index 0000000..85504e4
--- /dev/null
@@ -0,0 +1,25 @@
+#define _GNU_SOURCE
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/prctl.h>
+
+#include "pthread_impl.h"
+
+int pthread_getname_np(pthread_t thread, char *name, size_t len)
+{
+       int fd, cs, status = 0;
+       char f[sizeof "/proc/self/task//comm" + 3*sizeof(int)];
+
+       if (len < 16) return ERANGE;
+
+       if (thread == pthread_self())
+               return prctl(PR_GET_NAME, (unsigned long)name, 0UL, 0UL, 0UL) ? errno : 0;
+
+       snprintf(f, sizeof f, "/proc/self/task/%d/comm", thread->tid);
+       pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
+       if ((fd = open(f, O_RDONLY|O_CLOEXEC)) < 0 || (len = read(fd, name, len)) == -1) status = errno;
+       else name[len-1] = 0; /* remove trailing new line only if successful */
+       if (fd >= 0) close(fd);
+       pthread_setcancelstate(cs, 0);
+       return status;
+}
index 82d35e17eda7b33f386484cbe06de1a3d6cf079e..fc2d2306181141913320d24b5e5f2a84d3912088 100644 (file)
@@ -19,7 +19,7 @@ int pthread_setname_np(pthread_t thread, const char *name)
 
        snprintf(f, sizeof f, "/proc/self/task/%d/comm", thread->tid);
        pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
-       if ((fd = open(f, O_WRONLY)) < 0 || write(fd, name, len) < 0) status = errno;
+       if ((fd = open(f, O_WRONLY|O_CLOEXEC)) < 0 || write(fd, name, len) < 0) status = errno;
        if (fd >= 0) close(fd);
        pthread_setcancelstate(cs, 0);
        return status;
index 092d343df3300bb605222ff194ed72dbd4b1287d..9551503448805e39391ca303eea7ca57da04b411 100644 (file)
@@ -5,6 +5,7 @@
 #include <string.h>
 #ifdef __wasilibc_unmodified_upstream // timezone data
 #include <sys/mman.h>
+#include <ctype.h>
 #endif
 #include "libc.h"
 #include "lock.h"
@@ -159,10 +160,21 @@ static void do_tzset()
        }
        if (old_tz) memcpy(old_tz, s, i+1);
 
+       int posix_form = 0;
+       if (*s != ':') {
+               p = s;
+               char dummy_name[TZNAME_MAX+1];
+               getname(dummy_name, &p);
+               if (p!=s && (*p == '+' || *p == '-' || isdigit(*p)
+                            || !strcmp(dummy_name, "UTC")
+                            || !strcmp(dummy_name, "GMT")))
+                       posix_form = 1;
+       }       
+
        /* Non-suid can use an absolute tzfile pathname or a relative
         * pathame beginning with "."; in secure mode, only the
         * standard path will be searched. */
-       if (*s == ':' || ((p=strchr(s, '/')) && !memchr(s, ',', p-s))) {
+       if (!posix_form) {
                if (*s == ':') s++;
                if (*s == '/' || *s == '.') {
                        if (!libc.secure || !strcmp(s, "/etc/localtime"))
@@ -286,22 +298,20 @@ static size_t scan_trans(long long t, int local, size_t *alt)
        n = (index-trans)>>scale;
        if (a == n-1) return -1;
        if (a == 0) {
-               x = zi_read32(trans + (a<<scale));
-               if (scale == 3) x = x<<32 | zi_read32(trans + (a<<scale) + 4);
+               x = zi_read32(trans);
+               if (scale == 3) x = x<<32 | zi_read32(trans + 4);
                else x = (int32_t)x;
-               if (local) off = (int32_t)zi_read32(types + 6 * index[a-1]);
+               /* Find the lowest non-DST type, or 0 if none. */
+               size_t j = 0;
+               for (size_t i=abbrevs-types; i; i-=6) {
+                       if (!types[i-6+4]) j = i-6;
+               }
+               if (local) off = (int32_t)zi_read32(types + j);
+               /* If t is before first transition, use the above-found type
+                * and the index-zero (after transition) type as the alt. */
                if (t - off < (int64_t)x) {
-                       for (a=0; a<(abbrevs-types)/6; a++) {
-                               if (types[6*a+4] != types[4]) break;
-                       }
-                       if (a == (abbrevs-types)/6) a = 0;
-                       if (types[6*a+4]) {
-                               *alt = a;
-                               return 0;
-                       } else {
-                               *alt = 0;
-                               return a;
-                       }
+                       if (alt) *alt = index[0];
+                       return j/6;
                }
        }
 
index 6c25c8c326a72f26ad6d8a5359f85dc669d59d1f..1c2295ffc6591e7642cf17c352dfce7e168dad73 100644 (file)
@@ -1,4 +1,5 @@
 #include <unistd.h>
+#include <errno.h>
 #include <sys/resource.h>
 #include <limits.h>
 #include "syscall.h"
@@ -12,5 +13,11 @@ int nice(int inc)
                prio += getpriority(PRIO_PROCESS, 0);
        if (prio > NZERO-1) prio = NZERO-1;
        if (prio < -NZERO) prio = -NZERO;
-       return setpriority(PRIO_PROCESS, 0, prio) ? -1 : prio;
+       if (setpriority(PRIO_PROCESS, 0, prio)) {
+               if (errno == EACCES)
+                       errno = EPERM;
+               return -1;
+       } else {
+               return prio;
+       }
 }