]> git.proxmox.com Git - wasi-libc.git/commitdiff
Update to musl 1.1.24.
authorDan Gohman <sunfish@mozilla.com>
Mon, 14 Oct 2019 16:00:02 +0000 (09:00 -0700)
committerDan Gohman <sunfish@mozilla.com>
Wed, 26 Feb 2020 18:23:05 +0000 (10:23 -0800)
See the WHATSNEW file for details; this doesn't have any major changes
for wasi-libc; in particular, the new catgets and GLOB_TILDE features
are disabled.

239 files changed:
expected/wasm32-wasi/defined-symbols.txt
expected/wasm32-wasi/predefined-macros.txt
libc-bottom-half/cloudlibc/src/libc/unistd/lseek.c
libc-bottom-half/headers/public/__header_netinet_in.h
libc-bottom-half/headers/public/__struct_in6_addr.h
libc-top-half/musl/COPYRIGHT
libc-top-half/musl/INSTALL
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/ipc.h [deleted file]
libc-top-half/musl/arch/aarch64/bits/msg.h [deleted file]
libc-top-half/musl/arch/aarch64/bits/sem.h [deleted file]
libc-top-half/musl/arch/aarch64/bits/shm.h [deleted file]
libc-top-half/musl/arch/aarch64/bits/syscall.h.in
libc-top-half/musl/arch/aarch64/kstat.h [new file with mode: 0644]
libc-top-half/musl/arch/aarch64/syscall_arch.h
libc-top-half/musl/arch/arm/bits/ipcstat.h [new file with mode: 0644]
libc-top-half/musl/arch/arm/bits/msg.h [new file with mode: 0644]
libc-top-half/musl/arch/arm/bits/sem.h [new file with mode: 0644]
libc-top-half/musl/arch/arm/bits/shm.h [new file with mode: 0644]
libc-top-half/musl/arch/arm/bits/syscall.h.in
libc-top-half/musl/arch/arm/kstat.h [new file with mode: 0644]
libc-top-half/musl/arch/generic/bits/ipc.h
libc-top-half/musl/arch/generic/bits/ipcstat.h [new file with mode: 0644]
libc-top-half/musl/arch/generic/bits/msg.h
libc-top-half/musl/arch/generic/bits/sem.h
libc-top-half/musl/arch/generic/bits/shm.h
libc-top-half/musl/arch/i386/bits/ipcstat.h [new file with mode: 0644]
libc-top-half/musl/arch/i386/bits/msg.h [new file with mode: 0644]
libc-top-half/musl/arch/i386/bits/sem.h [new file with mode: 0644]
libc-top-half/musl/arch/i386/bits/shm.h [new file with mode: 0644]
libc-top-half/musl/arch/i386/bits/syscall.h.in
libc-top-half/musl/arch/i386/kstat.h [new file with mode: 0644]
libc-top-half/musl/arch/m68k/bits/alltypes.h.in
libc-top-half/musl/arch/m68k/bits/ipcstat.h [new file with mode: 0644]
libc-top-half/musl/arch/m68k/bits/msg.h [new file with mode: 0644]
libc-top-half/musl/arch/m68k/bits/sem.h [new file with mode: 0644]
libc-top-half/musl/arch/m68k/bits/shm.h [new file with mode: 0644]
libc-top-half/musl/arch/m68k/bits/syscall.h.in
libc-top-half/musl/arch/m68k/kstat.h [new file with mode: 0644]
libc-top-half/musl/arch/microblaze/bits/ipcstat.h [new file with mode: 0644]
libc-top-half/musl/arch/microblaze/bits/msg.h [new file with mode: 0644]
libc-top-half/musl/arch/microblaze/bits/sem.h [new file with mode: 0644]
libc-top-half/musl/arch/microblaze/bits/shm.h [new file with mode: 0644]
libc-top-half/musl/arch/microblaze/bits/syscall.h.in
libc-top-half/musl/arch/microblaze/kstat.h [new file with mode: 0644]
libc-top-half/musl/arch/mips/bits/ipcstat.h [new file with mode: 0644]
libc-top-half/musl/arch/mips/bits/sem.h
libc-top-half/musl/arch/mips/bits/shm.h
libc-top-half/musl/arch/mips/bits/syscall.h.in
libc-top-half/musl/arch/mips/kstat.h [new file with mode: 0644]
libc-top-half/musl/arch/mips/syscall_arch.h
libc-top-half/musl/arch/mips64/bits/ipc.h
libc-top-half/musl/arch/mips64/bits/msg.h [deleted file]
libc-top-half/musl/arch/mips64/bits/sem.h [deleted file]
libc-top-half/musl/arch/mips64/bits/shm.h [deleted file]
libc-top-half/musl/arch/mips64/bits/stat.h
libc-top-half/musl/arch/mips64/bits/syscall.h.in
libc-top-half/musl/arch/mips64/kstat.h [new file with mode: 0644]
libc-top-half/musl/arch/mips64/syscall_arch.h
libc-top-half/musl/arch/mipsn32/bits/ipcstat.h [new file with mode: 0644]
libc-top-half/musl/arch/mipsn32/bits/sem.h
libc-top-half/musl/arch/mipsn32/bits/stat.h
libc-top-half/musl/arch/mipsn32/bits/syscall.h.in
libc-top-half/musl/arch/mipsn32/kstat.h [new file with mode: 0644]
libc-top-half/musl/arch/mipsn32/syscall_arch.h
libc-top-half/musl/arch/or1k/bits/ipc.h [deleted file]
libc-top-half/musl/arch/or1k/bits/ipcstat.h [new file with mode: 0644]
libc-top-half/musl/arch/or1k/bits/sem.h [new file with mode: 0644]
libc-top-half/musl/arch/or1k/bits/shm.h [new file with mode: 0644]
libc-top-half/musl/arch/or1k/bits/syscall.h.in
libc-top-half/musl/arch/or1k/kstat.h [new file with mode: 0644]
libc-top-half/musl/arch/or1k/syscall_arch.h
libc-top-half/musl/arch/powerpc/bits/alltypes.h.in
libc-top-half/musl/arch/powerpc/bits/ipc.h
libc-top-half/musl/arch/powerpc/bits/ipcstat.h [new file with mode: 0644]
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/bits/user.h
libc-top-half/musl/arch/powerpc/kstat.h [new file with mode: 0644]
libc-top-half/musl/arch/powerpc/reloc.h
libc-top-half/musl/arch/powerpc/syscall_arch.h
libc-top-half/musl/arch/powerpc64/bits/ipc.h
libc-top-half/musl/arch/powerpc64/bits/msg.h [deleted file]
libc-top-half/musl/arch/powerpc64/bits/sem.h [deleted file]
libc-top-half/musl/arch/powerpc64/bits/shm.h
libc-top-half/musl/arch/powerpc64/bits/syscall.h.in
libc-top-half/musl/arch/powerpc64/bits/user.h
libc-top-half/musl/arch/powerpc64/kstat.h [new file with mode: 0644]
libc-top-half/musl/arch/powerpc64/reloc.h
libc-top-half/musl/arch/powerpc64/syscall_arch.h
libc-top-half/musl/arch/riscv64/atomic_arch.h
libc-top-half/musl/arch/riscv64/bits/ipc.h [deleted file]
libc-top-half/musl/arch/riscv64/bits/msg.h [deleted file]
libc-top-half/musl/arch/riscv64/bits/sem.h [deleted file]
libc-top-half/musl/arch/riscv64/bits/shm.h [deleted file]
libc-top-half/musl/arch/riscv64/bits/signal.h
libc-top-half/musl/arch/riscv64/bits/syscall.h.in
libc-top-half/musl/arch/riscv64/bits/user.h
libc-top-half/musl/arch/riscv64/kstat.h [new file with mode: 0644]
libc-top-half/musl/arch/riscv64/pthread_arch.h
libc-top-half/musl/arch/riscv64/syscall_arch.h
libc-top-half/musl/arch/s390x/bits/ipc.h [deleted file]
libc-top-half/musl/arch/s390x/bits/msg.h [deleted file]
libc-top-half/musl/arch/s390x/bits/sem.h [deleted file]
libc-top-half/musl/arch/s390x/bits/shm.h [deleted file]
libc-top-half/musl/arch/s390x/bits/syscall.h.in
libc-top-half/musl/arch/s390x/kstat.h [new file with mode: 0644]
libc-top-half/musl/arch/sh/bits/alltypes.h.in
libc-top-half/musl/arch/sh/bits/ipcstat.h [new file with mode: 0644]
libc-top-half/musl/arch/sh/bits/msg.h [new file with mode: 0644]
libc-top-half/musl/arch/sh/bits/sem.h [new file with mode: 0644]
libc-top-half/musl/arch/sh/bits/syscall.h.in
libc-top-half/musl/arch/sh/bits/user.h
libc-top-half/musl/arch/sh/kstat.h [new file with mode: 0644]
libc-top-half/musl/arch/sh/syscall_arch.h
libc-top-half/musl/arch/x32/bits/alltypes.h.in
libc-top-half/musl/arch/x32/bits/ipc.h
libc-top-half/musl/arch/x32/bits/sem.h [new file with mode: 0644]
libc-top-half/musl/arch/x32/bits/syscall.h.in
libc-top-half/musl/arch/x32/kstat.h [new file with mode: 0644]
libc-top-half/musl/arch/x32/syscall_arch.h
libc-top-half/musl/arch/x86_64/bits/ipc.h [deleted file]
libc-top-half/musl/arch/x86_64/bits/msg.h [deleted file]
libc-top-half/musl/arch/x86_64/bits/sem.h [new file with mode: 0644]
libc-top-half/musl/arch/x86_64/bits/shm.h [deleted file]
libc-top-half/musl/arch/x86_64/bits/syscall.h.in
libc-top-half/musl/arch/x86_64/kstat.h [new file with mode: 0644]
libc-top-half/musl/arch/x86_64/syscall_arch.h
libc-top-half/musl/include/fcntl.h
libc-top-half/musl/include/glob.h
libc-top-half/musl/include/netinet/if_ether.h
libc-top-half/musl/include/netinet/in.h
libc-top-half/musl/include/sched.h
libc-top-half/musl/include/spawn.h
libc-top-half/musl/include/stdlib.h
libc-top-half/musl/include/sys/ipc.h
libc-top-half/musl/include/sys/msg.h
libc-top-half/musl/include/sys/sem.h
libc-top-half/musl/include/sys/shm.h
libc-top-half/musl/include/unistd.h
libc-top-half/musl/ldso/dynlink.c
libc-top-half/musl/src/conf/fpathconf.c
libc-top-half/musl/src/env/secure_getenv.c [new file with mode: 0644]
libc-top-half/musl/src/include/time.h
libc-top-half/musl/src/include/unistd.h
libc-top-half/musl/src/internal/dynlink.h
libc-top-half/musl/src/internal/floatscan.c
libc-top-half/musl/src/internal/pthread_impl.h
libc-top-half/musl/src/internal/syscall.h
libc-top-half/musl/src/ipc/ipc.h
libc-top-half/musl/src/ipc/msgctl.c
libc-top-half/musl/src/ipc/semctl.c
libc-top-half/musl/src/ipc/semtimedop.c
libc-top-half/musl/src/ipc/shmctl.c
libc-top-half/musl/src/ldso/aarch64/tlsdesc.s
libc-top-half/musl/src/ldso/arm/tlsdesc.S
libc-top-half/musl/src/ldso/i386/tlsdesc.s
libc-top-half/musl/src/ldso/x86_64/tlsdesc.s
libc-top-half/musl/src/linux/adjtime.c
libc-top-half/musl/src/linux/adjtimex.c
libc-top-half/musl/src/linux/clock_adjtime.c
libc-top-half/musl/src/linux/copy_file_range.c [new file with mode: 0644]
libc-top-half/musl/src/linux/ppoll.c
libc-top-half/musl/src/linux/settimeofday.c
libc-top-half/musl/src/linux/timerfd.c
libc-top-half/musl/src/locale/catclose.c
libc-top-half/musl/src/locale/catgets.c
libc-top-half/musl/src/locale/catopen.c
libc-top-half/musl/src/math/i386/asin.s
libc-top-half/musl/src/math/i386/atan.s
libc-top-half/musl/src/math/i386/atan2.s
libc-top-half/musl/src/math/i386/atan2f.s
libc-top-half/musl/src/math/i386/atanf.s
libc-top-half/musl/src/math/i386/exp.s
libc-top-half/musl/src/math/i386/log1p.s
libc-top-half/musl/src/math/i386/log1pf.s
libc-top-half/musl/src/math/lrint.c
libc-top-half/musl/src/math/sqrt.c
libc-top-half/musl/src/math/sqrtf.c
libc-top-half/musl/src/misc/getopt.c
libc-top-half/musl/src/misc/ioctl.c
libc-top-half/musl/src/mq/mq_timedreceive.c
libc-top-half/musl/src/mq/mq_timedsend.c
libc-top-half/musl/src/multibyte/mbsrtowcs.c
libc-top-half/musl/src/network/getsockopt.c
libc-top-half/musl/src/network/recvmmsg.c
libc-top-half/musl/src/network/setsockopt.c
libc-top-half/musl/src/process/fdop.h
libc-top-half/musl/src/process/posix_spawn.c
libc-top-half/musl/src/process/posix_spawn_file_actions_addchdir.c [new file with mode: 0644]
libc-top-half/musl/src/process/posix_spawn_file_actions_addfchdir.c [new file with mode: 0644]
libc-top-half/musl/src/regex/glob.c
libc-top-half/musl/src/sched/sched_rr_get_interval.c
libc-top-half/musl/src/select/pselect.c
libc-top-half/musl/src/select/select.c
libc-top-half/musl/src/setjmp/arm/longjmp.S [new file with mode: 0644]
libc-top-half/musl/src/setjmp/arm/longjmp.s [deleted file]
libc-top-half/musl/src/setjmp/arm/setjmp.S [new file with mode: 0644]
libc-top-half/musl/src/setjmp/arm/setjmp.s [deleted file]
libc-top-half/musl/src/setjmp/mips/longjmp.S
libc-top-half/musl/src/setjmp/mips/setjmp.S
libc-top-half/musl/src/signal/getitimer.c
libc-top-half/musl/src/signal/setitimer.c
libc-top-half/musl/src/signal/sigaction.c
libc-top-half/musl/src/signal/sigtimedwait.c
libc-top-half/musl/src/signal/x32/getitimer.c [new file with mode: 0644]
libc-top-half/musl/src/signal/x32/setitimer.c [new file with mode: 0644]
libc-top-half/musl/src/stat/fstat.c
libc-top-half/musl/src/stat/fstatat.c
libc-top-half/musl/src/stat/lstat.c
libc-top-half/musl/src/stat/stat.c
libc-top-half/musl/src/stat/utimensat.c
libc-top-half/musl/src/stdio/__stdio_seek.c
libc-top-half/musl/src/stdio/vfwprintf.c
libc-top-half/musl/src/thread/__timedwait.c
libc-top-half/musl/src/thread/arm/atomics.s
libc-top-half/musl/src/thread/arm/clone.s
libc-top-half/musl/src/thread/arm/syscall_cp.s
libc-top-half/musl/src/thread/pthread_create.c
libc-top-half/musl/src/thread/pthread_join.c
libc-top-half/musl/src/thread/pthread_mutex_timedlock.c
libc-top-half/musl/src/thread/thrd_sleep.c
libc-top-half/musl/src/thread/x32/syscall_cp.s
libc-top-half/musl/src/thread/x32/syscall_cp_fixup.c [deleted file]
libc-top-half/musl/src/time/clock_getres.c
libc-top-half/musl/src/time/clock_gettime.c
libc-top-half/musl/src/time/clock_nanosleep.c
libc-top-half/musl/src/time/clock_settime.c
libc-top-half/musl/src/time/nanosleep.c
libc-top-half/musl/src/time/strftime.c
libc-top-half/musl/src/time/timer_create.c
libc-top-half/musl/src/time/timer_gettime.c
libc-top-half/musl/src/time/timer_settime.c
libc-top-half/musl/src/unistd/alarm.c
libc-top-half/musl/src/unistd/lseek.c
libc-top-half/musl/src/unistd/mipsn32/lseek.c [new file with mode: 0644]
libc-top-half/musl/src/unistd/x32/lseek.c [new file with mode: 0644]

index b3a46b869d597cf941ed06d10577d399c8b57f5a..a5105081bba8f64e8cbf3ae6e4a0c965c0ec99fc 100644 (file)
@@ -139,6 +139,7 @@ __log2_data
 __log2f_data
 __log_data
 __logf_data
+__lseek
 __math_divzero
 __math_divzerof
 __math_invalid
index b95d56306f81dceff5d24af63ff8746775152b02..f7fa6e4dbb741d4713032d74ae16c704d035c0f6 100644 (file)
 #define ILL_PRVOPC 5
 #define ILL_PRVREG 6
 #define IN6ADDRSZ NS_IN6ADDRSZ
-#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
-#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
+#define IN6ADDR_ANY_INIT { { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }
+#define IN6ADDR_LOOPBACK_INIT { { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 } }
 #define IN6_ARE_ADDR_EQUAL(a,b) __ARE_4_EQUAL((const uint32_t *)(a), (const uint32_t *)(b))
 #define IN6_IS_ADDR_LINKLOCAL(a) ((((uint8_t *) (a))[0]) == 0xfe && (((uint8_t *) (a))[1] & 0xc0) == 0x80)
 #define IN6_IS_ADDR_LOOPBACK(a) (((uint32_t *) (a))[0] == 0 && ((uint32_t *) (a))[1] == 0 && ((uint32_t *) (a))[2] == 0 && ((uint8_t *) (a))[12] == 0 && ((uint8_t *) (a))[13] == 0 && ((uint8_t *) (a))[14] == 0 && ((uint8_t *) (a))[15] == 1 )
index f21e328884d75804bc18730dd4bff7ee50fb95fc..cb5d995b3ce3394901c3c9e995dbc67553019b48 100644 (file)
@@ -11,10 +11,10 @@ static_assert(SEEK_CUR == __WASI_WHENCE_CUR, "Value mismatch");
 static_assert(SEEK_END == __WASI_WHENCE_END, "Value mismatch");
 static_assert(SEEK_SET == __WASI_WHENCE_SET, "Value mismatch");
 
-#ifdef __wasilibc_unmodified_upstream /* Optimize the readonly case of lseek */
+#ifdef __wasilibc_unmodified_upstream // Provide an __lseek entry point
 off_t lseek(int fildes, off_t offset, int whence) {
 #else
-off_t (lseek)(int fildes, off_t offset, int whence) {
+off_t __lseek(int fildes, off_t offset, int whence) {
 #endif
   __wasi_filesize_t new_offset;
   __wasi_errno_t error =
@@ -25,3 +25,8 @@ off_t (lseek)(int fildes, off_t offset, int whence) {
   }
   return new_offset;
 }
+
+#ifdef __wasilibc_unmodified_upstream // Provide an __lseek entry point
+#else
+extern __typeof(__lseek) lseek __attribute__((weak, alias("__lseek")));
+#endif
index a20a394e82b531322c3d3f8a3a7c31e93693b050..30359c88ff1c243c742ad6b4d5ab9d0b3ed6d34e 100644 (file)
 #define IPPROTO_IPV6 41
 #define IPPROTO_RAW 255
 
+#define IN6ADDR_ANY_INIT { { \
+    0x00, 0x00, 0x00, 0x00, \
+    0x00, 0x00, 0x00, 0x00, \
+    0x00, 0x00, 0x00, 0x00, \
+    0x00, 0x00, 0x00, 0x00  \
+} }
+
+#define IN6ADDR_LOOPBACK_INIT { { \
+    0x00, 0x00, 0x00, 0x00, \
+    0x00, 0x00, 0x00, 0x00, \
+    0x00, 0x00, 0x00, 0x00, \
+    0x00, 0x00, 0x00, 0x01  \
+} }
+
 #endif
index 8d61ada1adc3b5e4d0a5f53b3fcb41049f86d280..cf2fafeb40bf0928dfdaecd5c71c2b24797d52c9 100644 (file)
@@ -2,7 +2,7 @@
 #define __wasilibc___struct_in6_addr_h
 
 struct in6_addr {
-    _Alignas(long) unsigned char s6_addr[16];
+    _Alignas(int32_t) unsigned char s6_addr[16];
 };
 
 #endif
index 2525ffb540e49c6c85356ef480bf895ba03cb032..67802d11907fdd3ff5dc04cf3e3b4bc435e8a223 100644 (file)
@@ -122,7 +122,8 @@ Copyright Â© 1993,2004 Sun Microsystems or
 Copyright Â© 2003-2011 David Schultz or
 Copyright Â© 2003-2009 Steven G. Kargl or
 Copyright Â© 2003-2009 Bruce D. Evans or
-Copyright Â© 2008 Stephen L. Moshier
+Copyright Â© 2008 Stephen L. Moshier or
+Copyright Â© 2017-2018 Arm Limited
 and labelled as such in comments in the individual source files. All
 have been licensed under extremely permissive terms.
 
index 322ee9766251dd9cfdd02735cf592ee5db1a8084..22477b6ba0f99f2fef07011535da873c5907a862 100644 (file)
@@ -55,12 +55,13 @@ and ABI combinations:
     * Little-endian default; big-endian variants also supported
 
 * MIPS
-    * ABI is o32
+    * ABI is o32, fp32/fpxx (except on r6 which is fp64)
     * Big-endian default; little-endian variants also supported
     * Default ABI variant uses FPU registers; alternate soft-float ABI
       that does not use FPU registers or instructions is available
     * MIPS2 or later, or kernel emulation of ll/sc (standard in Linux)
       is required
+    * MIPS32r6, an incompatible ISA, is supported as a variant "mipsr6"
 
 * MIPS64
     * ABI is n64 (LP64) or n32 (ILP32)
index 32ffe1201e74072c00a43c47ad97d9adf9538c58..3fe3e58a8facc415b80eff0c639660eb8ebd2021 100644 (file)
@@ -1 +1 @@
-1.1.23
+1.1.24
index b46e9ae15841a633f53f50fe66d9738654b4f338..f9879bd5f5626472150804e9cfcdff00014c6ea0 100644 (file)
@@ -2115,3 +2115,52 @@ arch-specfic bugs fixed:
 - passing of 64-bit syscall arguments was broken on microblaze
 - posix_fadvise was broken on mips due to missing 7-arg syscall support
 - vrregset_t layout and member naming was wrong on powerpc64
+
+
+
+1.1.24 release notes
+
+new features:
+- GLOB_TILDE extension to glob
+- non-stub catgets localization API, using netbsd binary catalog format
+- posix_spawn file actions for [f]chdir (extension, pending future standard)
+- secure_getenv function (extension)
+- copy_file_range syscall wrapper (Linux extension)
+- header-level support for new linux features in 5.2
+
+performance:
+- new fast path for lrint (generic C version) on 32-bit archs
+
+major internal changes:
+- functions involving time are overhauled to be time64-ready in 32-bit archs
+- x32 uses the new time64 code paths to replace nasty hacks in syscall glue
+
+compatibility & conformance:
+- support for powerpc[64] unaligned relocation types
+- powerpc[64] and sh sys/user.h no longer clash with kernel asm/ptrace.h
+- select no longer modifies timeout on failure (or at all)
+- mips64 stat results are no longer limited to 32-bit time range
+- optreset (BSD extension) now has a public declaration
+- support for clang inconsistencies in wchar_t type vs some 32-bit archs
+- mips r6 syscall asm no longer has invalid lo/hi register clobbers
+- vestigial asm declarations of __tls_get_new are removed (broke some tooling)
+- riscv64 mcontext_t mismatch glibc's member naming is corrected
+
+bugs fixed:
+- glob failed to match broken symlinks consistently
+- invalid use of interposed calloc to allocate initial TLS
+- various dlsym symbol resolution logic errors
+- semctl with SEM_STAT_ANY didn't work
+- pthread_create with explicit scheduling was subject to priority inversion
+- pthread_create failure path had data race for thread count
+- timer_create with SIGEV_THREAD notification had data race getting timer id
+- wide printf family failed to support l modifier for float formats
+
+arch-specific bugs fixed:
+- x87 floating point stack imbalance in math asm (i386-only CVE-2019-14697)
+- x32 clock_adjtime, getrusage, wait3, wait4 produced junk (struct mismatches)
+- lseek broken on x32 and mipsn32 with large file offsets
+- riscv64 atomics weren't compiler barriers
+- riscv64 atomics had broken asm constraints (missing earlyclobber flag)
+- arm clone() was broken when compiled as thumb if start function returned
+- mipsr6 setjmp/longjmp did not preserve fpu register state correctly
index ad670914c82b329804b5a0b09fe408a2bad73005..a7484028e0a33f73d0538f93af205ffc591d9bd4 100644 (file)
 #define HWCAP_SB               (1 << 29)
 #define HWCAP_PACA             (1 << 30)
 #define HWCAP_PACG             (1UL << 31)
+
+#define HWCAP2_DCPODP          (1 << 0)
+#define HWCAP2_SVE2            (1 << 1)
+#define HWCAP2_SVEAES          (1 << 2)
+#define HWCAP2_SVEPMULL                (1 << 3)
+#define HWCAP2_SVEBITPERM      (1 << 4)
+#define HWCAP2_SVESHA3         (1 << 5)
+#define HWCAP2_SVESM4          (1 << 6)
diff --git a/libc-top-half/musl/arch/aarch64/bits/ipc.h b/libc-top-half/musl/arch/aarch64/bits/ipc.h
deleted file mode 100644 (file)
index 6f3328a..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-struct ipc_perm {
-       key_t __ipc_perm_key;
-       uid_t uid;
-       gid_t gid;
-       uid_t cuid;
-       gid_t cgid;
-       mode_t mode;
-       unsigned short __ipc_perm_seq;
-
-       unsigned long __pad1;
-       unsigned long __pad2;
-};
-
-#define IPC_64 0
diff --git a/libc-top-half/musl/arch/aarch64/bits/msg.h b/libc-top-half/musl/arch/aarch64/bits/msg.h
deleted file mode 100644 (file)
index 641e170..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-struct msqid_ds {
-       struct ipc_perm msg_perm;
-       time_t msg_stime;
-       time_t msg_rtime;
-       time_t msg_ctime;
-       unsigned long msg_cbytes;
-       msgqnum_t msg_qnum;
-       msglen_t msg_qbytes;
-       pid_t msg_lspid;
-       pid_t msg_lrpid;
-       unsigned long __pad1;
-       unsigned long __pad2;
-};
diff --git a/libc-top-half/musl/arch/aarch64/bits/sem.h b/libc-top-half/musl/arch/aarch64/bits/sem.h
deleted file mode 100644 (file)
index e46ced9..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-struct semid_ds {
-       struct ipc_perm sem_perm;
-       time_t sem_otime;
-       time_t sem_ctime;
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-       unsigned short sem_nsems;
-       char __sem_nsems_pad[sizeof(time_t)-sizeof(short)];
-#else
-       char __sem_nsems_pad[sizeof(time_t)-sizeof(short)];
-       unsigned short sem_nsems;
-#endif
-       time_t __unused3;
-       time_t __unused4;
-};
diff --git a/libc-top-half/musl/arch/aarch64/bits/shm.h b/libc-top-half/musl/arch/aarch64/bits/shm.h
deleted file mode 100644 (file)
index 8d19378..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-#define SHMLBA 4096
-
-struct shmid_ds {
-       struct ipc_perm shm_perm;
-       size_t shm_segsz;
-       time_t shm_atime;
-       time_t shm_dtime;
-       time_t shm_ctime;
-       pid_t shm_cpid;
-       pid_t shm_lpid;
-       unsigned long shm_nattch;
-       unsigned long __pad1;
-       unsigned long __pad2;
-};
-
-struct shminfo {
-       unsigned long shmmax, shmmin, shmmni, shmseg, shmall, __unused[4];
-};
-
-struct shm_info {
-       int __used_ids;
-       unsigned long shm_tot, shm_rss, shm_swp;
-       unsigned long __swap_attempts, __swap_successes;
-};
index eed5a612c08f794e45c2a6d1b9159eb2e48e664b..955e2cabada6ae1384f98c61a4957116b4abce1c 100644 (file)
 #define __NR_io_uring_setup 425
 #define __NR_io_uring_enter 426
 #define __NR_io_uring_register 427
+#define __NR_open_tree         428
+#define __NR_move_mount                429
+#define __NR_fsopen            430
+#define __NR_fsconfig          431
+#define __NR_fsmount           432
+#define __NR_fspick            433
 
diff --git a/libc-top-half/musl/arch/aarch64/kstat.h b/libc-top-half/musl/arch/aarch64/kstat.h
new file mode 100644 (file)
index 0000000..92625f3
--- /dev/null
@@ -0,0 +1,21 @@
+struct kstat {
+       dev_t st_dev;
+       ino_t st_ino;
+       mode_t st_mode;
+       nlink_t st_nlink;
+       uid_t st_uid;
+       gid_t st_gid;
+       dev_t st_rdev;
+       unsigned long __pad;
+       off_t st_size;
+       blksize_t st_blksize;
+       int __pad2;
+       blkcnt_t st_blocks;
+       long st_atime_sec;
+       long st_atime_nsec;
+       long st_mtime_sec;
+       long st_mtime_nsec;
+       long st_ctime_sec;
+       long st_ctime_nsec;
+       unsigned __unused[2];
+};
index 25f5ce670ff84a7410d5120141b488cdab0c7b6e..504983aa276a641a4be60ea12733c752b9b49ea1 100644 (file)
@@ -74,3 +74,5 @@ static inline long __syscall6(long n, long a, long b, long c, long d, long e, lo
 #define VDSO_USEFUL
 #define VDSO_CGT_SYM "__kernel_clock_gettime"
 #define VDSO_CGT_VER "LINUX_2.6.39"
+
+#define IPC_64 0
diff --git a/libc-top-half/musl/arch/arm/bits/ipcstat.h b/libc-top-half/musl/arch/arm/bits/ipcstat.h
new file mode 100644 (file)
index 0000000..0018ad1
--- /dev/null
@@ -0,0 +1 @@
+#define IPC_STAT 2
diff --git a/libc-top-half/musl/arch/arm/bits/msg.h b/libc-top-half/musl/arch/arm/bits/msg.h
new file mode 100644 (file)
index 0000000..bc8436c
--- /dev/null
@@ -0,0 +1,15 @@
+struct msqid_ds {
+       struct ipc_perm msg_perm;
+       time_t msg_stime;
+       int __unused1;
+       time_t msg_rtime;
+       int __unused2;
+       time_t msg_ctime;
+       int __unused3;
+       unsigned long msg_cbytes;
+       msgqnum_t msg_qnum;
+       msglen_t msg_qbytes;
+       pid_t msg_lspid;
+       pid_t msg_lrpid;
+       unsigned long __unused[2];
+};
diff --git a/libc-top-half/musl/arch/arm/bits/sem.h b/libc-top-half/musl/arch/arm/bits/sem.h
new file mode 100644 (file)
index 0000000..d383d4e
--- /dev/null
@@ -0,0 +1,16 @@
+struct semid_ds {
+       struct ipc_perm sem_perm;
+       time_t sem_otime;
+       long __unused1;
+       time_t sem_ctime;
+       long __unused2;
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+       unsigned short sem_nsems;
+       char __sem_nsems_pad[sizeof(long)-sizeof(short)];
+#else
+       char __sem_nsems_pad[sizeof(long)-sizeof(short)];
+       unsigned short sem_nsems;
+#endif
+       long __unused3;
+       long __unused4;
+};
diff --git a/libc-top-half/musl/arch/arm/bits/shm.h b/libc-top-half/musl/arch/arm/bits/shm.h
new file mode 100644 (file)
index 0000000..81b2a29
--- /dev/null
@@ -0,0 +1,27 @@
+#define SHMLBA 4096
+
+struct shmid_ds {
+       struct ipc_perm shm_perm;
+       size_t shm_segsz;
+       time_t shm_atime;
+       int __unused1;
+       time_t shm_dtime;
+       int __unused2;
+       time_t shm_ctime;
+       int __unused3;
+       pid_t shm_cpid;
+       pid_t shm_lpid;
+       unsigned long shm_nattch;
+       unsigned long __pad1;
+       unsigned long __pad2;
+};
+
+struct shminfo {
+       unsigned long shmmax, shmmin, shmmni, shmseg, shmall, __unused[4];
+};
+
+struct shm_info {
+       int __used_ids;
+       unsigned long shm_tot, shm_rss, shm_swp;
+       unsigned long __swap_attempts, __swap_successes;
+};
index 8ce1d70a4ae9c6b5bcd29e5a0af9235c9cf855d1..a565a4ee1f0bf64111b7020925190d0965a92536 100644 (file)
 #define __NR_io_uring_setup    425
 #define __NR_io_uring_enter    426
 #define __NR_io_uring_register 427
+#define __NR_open_tree         428
+#define __NR_move_mount                429
+#define __NR_fsopen            430
+#define __NR_fsconfig          431
+#define __NR_fsmount           432
+#define __NR_fspick            433
 
 #define __ARM_NR_breakpoint    0x0f0001
 #define __ARM_NR_cacheflush    0x0f0002
diff --git a/libc-top-half/musl/arch/arm/kstat.h b/libc-top-half/musl/arch/arm/kstat.h
new file mode 100644 (file)
index 0000000..af449c9
--- /dev/null
@@ -0,0 +1,21 @@
+struct kstat {
+       dev_t st_dev;
+       int __st_dev_padding;
+       long __st_ino_truncated;
+       mode_t st_mode;
+       nlink_t st_nlink;
+       uid_t st_uid;
+       gid_t st_gid;
+       dev_t st_rdev;
+       int __st_rdev_padding;
+       off_t st_size;
+       blksize_t st_blksize;
+       blkcnt_t st_blocks;
+       long st_atime_sec;
+       long st_atime_nsec;
+       long st_mtime_sec;
+       long st_mtime_nsec;
+       long st_ctime_sec;
+       long st_ctime_nsec;
+       ino_t st_ino;
+};
index 779c42fd7bf5249d1e936f657974e8689ca1b531..40d6f3a2587cf475469eb65b19af5a85e1a11d7f 100644 (file)
@@ -9,5 +9,3 @@ struct ipc_perm {
        long __pad1;
        long __pad2;
 };
-
-#define IPC_64 0x100
diff --git a/libc-top-half/musl/arch/generic/bits/ipcstat.h b/libc-top-half/musl/arch/generic/bits/ipcstat.h
new file mode 100644 (file)
index 0000000..0018ad1
--- /dev/null
@@ -0,0 +1 @@
+#define IPC_STAT 2
index bc8436c4ad26797d69e762b701aa906b9bed1271..2e23ca27f580705efe87a0ab6e9742daaf047577 100644 (file)
@@ -1,11 +1,8 @@
 struct msqid_ds {
        struct ipc_perm msg_perm;
        time_t msg_stime;
-       int __unused1;
        time_t msg_rtime;
-       int __unused2;
        time_t msg_ctime;
-       int __unused3;
        unsigned long msg_cbytes;
        msgqnum_t msg_qnum;
        msglen_t msg_qbytes;
index c629b81ebb2a097b823aae6caac56cf34f2b2dc8..5184eb5977ece3775fe5f7a6659a83d6da24ca44 100644 (file)
@@ -1,16 +1,14 @@
 struct semid_ds {
        struct ipc_perm sem_perm;
        time_t sem_otime;
-       time_t __unused1;
        time_t sem_ctime;
-       time_t __unused2;
 #if __BYTE_ORDER == __LITTLE_ENDIAN
        unsigned short sem_nsems;
-       char __sem_nsems_pad[sizeof(time_t)-sizeof(short)];
+       char __sem_nsems_pad[sizeof(long)-sizeof(short)];
 #else
-       char __sem_nsems_pad[sizeof(time_t)-sizeof(short)];
+       char __sem_nsems_pad[sizeof(long)-sizeof(short)];
        unsigned short sem_nsems;
 #endif
-       time_t __unused3;
-       time_t __unused4;
+       long __unused3;
+       long __unused4;
 };
index 45d1d157832388d8ef93ba4f9ae3a8bd5ec91d76..8d19378191bacd8a43080a7f96027befcfd30e4c 100644 (file)
@@ -4,11 +4,8 @@ struct shmid_ds {
        struct ipc_perm shm_perm;
        size_t shm_segsz;
        time_t shm_atime;
-       int __unused1;
        time_t shm_dtime;
-       int __unused2;
        time_t shm_ctime;
-       int __unused3;
        pid_t shm_cpid;
        pid_t shm_lpid;
        unsigned long shm_nattch;
@@ -25,4 +22,3 @@ struct shm_info {
        unsigned long shm_tot, shm_rss, shm_swp;
        unsigned long __swap_attempts, __swap_successes;
 };
-
diff --git a/libc-top-half/musl/arch/i386/bits/ipcstat.h b/libc-top-half/musl/arch/i386/bits/ipcstat.h
new file mode 100644 (file)
index 0000000..0018ad1
--- /dev/null
@@ -0,0 +1 @@
+#define IPC_STAT 2
diff --git a/libc-top-half/musl/arch/i386/bits/msg.h b/libc-top-half/musl/arch/i386/bits/msg.h
new file mode 100644 (file)
index 0000000..bc8436c
--- /dev/null
@@ -0,0 +1,15 @@
+struct msqid_ds {
+       struct ipc_perm msg_perm;
+       time_t msg_stime;
+       int __unused1;
+       time_t msg_rtime;
+       int __unused2;
+       time_t msg_ctime;
+       int __unused3;
+       unsigned long msg_cbytes;
+       msgqnum_t msg_qnum;
+       msglen_t msg_qbytes;
+       pid_t msg_lspid;
+       pid_t msg_lrpid;
+       unsigned long __unused[2];
+};
diff --git a/libc-top-half/musl/arch/i386/bits/sem.h b/libc-top-half/musl/arch/i386/bits/sem.h
new file mode 100644 (file)
index 0000000..e61571c
--- /dev/null
@@ -0,0 +1,11 @@
+struct semid_ds {
+       struct ipc_perm sem_perm;
+       time_t sem_otime;
+       long __unused1;
+       time_t sem_ctime;
+       long __unused2;
+       unsigned short sem_nsems;
+       char __sem_nsems_pad[sizeof(long)-sizeof(short)];
+       long __unused3;
+       long __unused4;
+};
diff --git a/libc-top-half/musl/arch/i386/bits/shm.h b/libc-top-half/musl/arch/i386/bits/shm.h
new file mode 100644 (file)
index 0000000..81b2a29
--- /dev/null
@@ -0,0 +1,27 @@
+#define SHMLBA 4096
+
+struct shmid_ds {
+       struct ipc_perm shm_perm;
+       size_t shm_segsz;
+       time_t shm_atime;
+       int __unused1;
+       time_t shm_dtime;
+       int __unused2;
+       time_t shm_ctime;
+       int __unused3;
+       pid_t shm_cpid;
+       pid_t shm_lpid;
+       unsigned long shm_nattch;
+       unsigned long __pad1;
+       unsigned long __pad2;
+};
+
+struct shminfo {
+       unsigned long shmmax, shmmin, shmmni, shmseg, shmall, __unused[4];
+};
+
+struct shm_info {
+       int __used_ids;
+       unsigned long shm_tot, shm_rss, shm_swp;
+       unsigned long __swap_attempts, __swap_successes;
+};
index fdfdc7108bc4f30dffa4d5f4a8a7b2fb1fa8dcad..c95e108e55d577b16eb1c4396b07d272aad778cc 100644 (file)
 #define __NR_io_uring_setup    425
 #define __NR_io_uring_enter    426
 #define __NR_io_uring_register 427
+#define __NR_open_tree         428
+#define __NR_move_mount                429
+#define __NR_fsopen            430
+#define __NR_fsconfig          431
+#define __NR_fsmount           432
+#define __NR_fspick            433
 
diff --git a/libc-top-half/musl/arch/i386/kstat.h b/libc-top-half/musl/arch/i386/kstat.h
new file mode 100644 (file)
index 0000000..af449c9
--- /dev/null
@@ -0,0 +1,21 @@
+struct kstat {
+       dev_t st_dev;
+       int __st_dev_padding;
+       long __st_ino_truncated;
+       mode_t st_mode;
+       nlink_t st_nlink;
+       uid_t st_uid;
+       gid_t st_gid;
+       dev_t st_rdev;
+       int __st_rdev_padding;
+       off_t st_size;
+       blksize_t st_blksize;
+       blkcnt_t st_blocks;
+       long st_atime_sec;
+       long st_atime_nsec;
+       long st_mtime_sec;
+       long st_mtime_nsec;
+       long st_ctime_sec;
+       long st_ctime_nsec;
+       ino_t st_ino;
+};
index a4a8141fe2ae5ca523c18bdf96a2af2ff84c713a..bd37a6318da7e405f8bef956942c9d6a265fe481 100644 (file)
@@ -6,8 +6,12 @@ TYPEDEF __builtin_va_list va_list;
 TYPEDEF __builtin_va_list __isoc_va_list;
 
 #ifndef __cplusplus
+#ifdef __WCHAR_TYPE__
+TYPEDEF __WCHAR_TYPE__ wchar_t;
+#else
 TYPEDEF long wchar_t;
 #endif
+#endif
 
 #if __mcffpu__
 TYPEDEF float float_t;
diff --git a/libc-top-half/musl/arch/m68k/bits/ipcstat.h b/libc-top-half/musl/arch/m68k/bits/ipcstat.h
new file mode 100644 (file)
index 0000000..0018ad1
--- /dev/null
@@ -0,0 +1 @@
+#define IPC_STAT 2
diff --git a/libc-top-half/musl/arch/m68k/bits/msg.h b/libc-top-half/musl/arch/m68k/bits/msg.h
new file mode 100644 (file)
index 0000000..bc8436c
--- /dev/null
@@ -0,0 +1,15 @@
+struct msqid_ds {
+       struct ipc_perm msg_perm;
+       time_t msg_stime;
+       int __unused1;
+       time_t msg_rtime;
+       int __unused2;
+       time_t msg_ctime;
+       int __unused3;
+       unsigned long msg_cbytes;
+       msgqnum_t msg_qnum;
+       msglen_t msg_qbytes;
+       pid_t msg_lspid;
+       pid_t msg_lrpid;
+       unsigned long __unused[2];
+};
diff --git a/libc-top-half/musl/arch/m68k/bits/sem.h b/libc-top-half/musl/arch/m68k/bits/sem.h
new file mode 100644 (file)
index 0000000..08faafe
--- /dev/null
@@ -0,0 +1,11 @@
+struct semid_ds {
+       struct ipc_perm sem_perm;
+       time_t sem_otime;
+       long __unused1;
+       time_t sem_ctime;
+       long __unused2;
+       char __sem_nsems_pad[sizeof(long)-sizeof(short)];
+       unsigned short sem_nsems;
+       long __unused3;
+       long __unused4;
+};
diff --git a/libc-top-half/musl/arch/m68k/bits/shm.h b/libc-top-half/musl/arch/m68k/bits/shm.h
new file mode 100644 (file)
index 0000000..81b2a29
--- /dev/null
@@ -0,0 +1,27 @@
+#define SHMLBA 4096
+
+struct shmid_ds {
+       struct ipc_perm shm_perm;
+       size_t shm_segsz;
+       time_t shm_atime;
+       int __unused1;
+       time_t shm_dtime;
+       int __unused2;
+       time_t shm_ctime;
+       int __unused3;
+       pid_t shm_cpid;
+       pid_t shm_lpid;
+       unsigned long shm_nattch;
+       unsigned long __pad1;
+       unsigned long __pad2;
+};
+
+struct shminfo {
+       unsigned long shmmax, shmmin, shmmni, shmseg, shmall, __unused[4];
+};
+
+struct shm_info {
+       int __used_ids;
+       unsigned long shm_tot, shm_rss, shm_swp;
+       unsigned long __swap_attempts, __swap_successes;
+};
index c7859b99526d4b550c6731c2e71329f370535ae0..fb522b485e922d492209f99df40bb60c59f0e513 100644 (file)
 #define __NR_io_uring_setup    425
 #define __NR_io_uring_enter    426
 #define __NR_io_uring_register 427
+#define __NR_open_tree         428
+#define __NR_move_mount                429
+#define __NR_fsopen            430
+#define __NR_fsconfig          431
+#define __NR_fsmount           432
+#define __NR_fspick            433
diff --git a/libc-top-half/musl/arch/m68k/kstat.h b/libc-top-half/musl/arch/m68k/kstat.h
new file mode 100644 (file)
index 0000000..ac13e27
--- /dev/null
@@ -0,0 +1,21 @@
+struct kstat {
+       dev_t st_dev;
+       short __st_dev_padding;
+       long __st_ino_truncated;
+       mode_t st_mode;
+       nlink_t st_nlink;
+       uid_t st_uid;
+       gid_t st_gid;
+       dev_t st_rdev;
+       short __st_rdev_padding;
+       off_t st_size;
+       blksize_t st_blksize;
+       blkcnt_t st_blocks;
+       long st_atime_sec;
+       long st_atime_nsec;
+       long st_mtime_sec;
+       long st_mtime_nsec;
+       long st_ctime_sec;
+       long st_ctime_nsec;
+       ino_t st_ino;
+};
diff --git a/libc-top-half/musl/arch/microblaze/bits/ipcstat.h b/libc-top-half/musl/arch/microblaze/bits/ipcstat.h
new file mode 100644 (file)
index 0000000..0018ad1
--- /dev/null
@@ -0,0 +1 @@
+#define IPC_STAT 2
diff --git a/libc-top-half/musl/arch/microblaze/bits/msg.h b/libc-top-half/musl/arch/microblaze/bits/msg.h
new file mode 100644 (file)
index 0000000..bc8436c
--- /dev/null
@@ -0,0 +1,15 @@
+struct msqid_ds {
+       struct ipc_perm msg_perm;
+       time_t msg_stime;
+       int __unused1;
+       time_t msg_rtime;
+       int __unused2;
+       time_t msg_ctime;
+       int __unused3;
+       unsigned long msg_cbytes;
+       msgqnum_t msg_qnum;
+       msglen_t msg_qbytes;
+       pid_t msg_lspid;
+       pid_t msg_lrpid;
+       unsigned long __unused[2];
+};
diff --git a/libc-top-half/musl/arch/microblaze/bits/sem.h b/libc-top-half/musl/arch/microblaze/bits/sem.h
new file mode 100644 (file)
index 0000000..d383d4e
--- /dev/null
@@ -0,0 +1,16 @@
+struct semid_ds {
+       struct ipc_perm sem_perm;
+       time_t sem_otime;
+       long __unused1;
+       time_t sem_ctime;
+       long __unused2;
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+       unsigned short sem_nsems;
+       char __sem_nsems_pad[sizeof(long)-sizeof(short)];
+#else
+       char __sem_nsems_pad[sizeof(long)-sizeof(short)];
+       unsigned short sem_nsems;
+#endif
+       long __unused3;
+       long __unused4;
+};
diff --git a/libc-top-half/musl/arch/microblaze/bits/shm.h b/libc-top-half/musl/arch/microblaze/bits/shm.h
new file mode 100644 (file)
index 0000000..81b2a29
--- /dev/null
@@ -0,0 +1,27 @@
+#define SHMLBA 4096
+
+struct shmid_ds {
+       struct ipc_perm shm_perm;
+       size_t shm_segsz;
+       time_t shm_atime;
+       int __unused1;
+       time_t shm_dtime;
+       int __unused2;
+       time_t shm_ctime;
+       int __unused3;
+       pid_t shm_cpid;
+       pid_t shm_lpid;
+       unsigned long shm_nattch;
+       unsigned long __pad1;
+       unsigned long __pad2;
+};
+
+struct shminfo {
+       unsigned long shmmax, shmmin, shmmni, shmseg, shmall, __unused[4];
+};
+
+struct shm_info {
+       int __used_ids;
+       unsigned long shm_tot, shm_rss, shm_swp;
+       unsigned long __swap_attempts, __swap_successes;
+};
index 91bc244e7172af2dd4f48851d8815ccaaf7bae58..59f86236595d6d6cf0ea430d474f8cf226e069e3 100644 (file)
 #define __NR_io_uring_setup 425
 #define __NR_io_uring_enter 426
 #define __NR_io_uring_register 427
+#define __NR_open_tree         428
+#define __NR_move_mount                429
+#define __NR_fsopen            430
+#define __NR_fsconfig          431
+#define __NR_fsmount           432
+#define __NR_fspick            433
 
diff --git a/libc-top-half/musl/arch/microblaze/kstat.h b/libc-top-half/musl/arch/microblaze/kstat.h
new file mode 100644 (file)
index 0000000..c144957
--- /dev/null
@@ -0,0 +1,21 @@
+struct kstat {
+       dev_t st_dev;
+       ino_t st_ino;
+       mode_t st_mode;
+       nlink_t st_nlink;
+       uid_t st_uid;
+       gid_t st_gid;
+       dev_t st_rdev;
+       long long __st_rdev_padding;
+       off_t st_size;
+       blksize_t st_blksize;
+       int __st_blksize_padding;
+       blkcnt_t st_blocks;
+       long st_atime_sec;
+       long st_atime_nsec;
+       long st_mtime_sec;
+       long st_mtime_nsec;
+       long st_ctime_sec;
+       long st_ctime_nsec;
+       unsigned __unused[2];
+};
diff --git a/libc-top-half/musl/arch/mips/bits/ipcstat.h b/libc-top-half/musl/arch/mips/bits/ipcstat.h
new file mode 100644 (file)
index 0000000..0018ad1
--- /dev/null
@@ -0,0 +1 @@
+#define IPC_STAT 2
index e46ced95d2be4c4ef568b4717d1012d1cfdb2d30..5184eb5977ece3775fe5f7a6659a83d6da24ca44 100644 (file)
@@ -4,11 +4,11 @@ struct semid_ds {
        time_t sem_ctime;
 #if __BYTE_ORDER == __LITTLE_ENDIAN
        unsigned short sem_nsems;
-       char __sem_nsems_pad[sizeof(time_t)-sizeof(short)];
+       char __sem_nsems_pad[sizeof(long)-sizeof(short)];
 #else
-       char __sem_nsems_pad[sizeof(time_t)-sizeof(short)];
+       char __sem_nsems_pad[sizeof(long)-sizeof(short)];
        unsigned short sem_nsems;
 #endif
-       time_t __unused3;
-       time_t __unused4;
+       long __unused3;
+       long __unused4;
 };
index 6652d6592316b78a3e508f2fd8ae94302efa1c2f..8d19378191bacd8a43080a7f96027befcfd30e4c 100644 (file)
@@ -22,4 +22,3 @@ struct shm_info {
        unsigned long shm_tot, shm_rss, shm_swp;
        unsigned long __swap_attempts, __swap_successes;
 };
-
index 6175a7c228b96c44a38c59decf9ce1d19238cd4f..582fa3b51c7d9dcb23e61b7d1e67bb49c885e29e 100644 (file)
 #define __NR_io_uring_setup          4425
 #define __NR_io_uring_enter          4426
 #define __NR_io_uring_register       4427
+#define __NR_open_tree         4428
+#define __NR_move_mount                4429
+#define __NR_fsopen            4430
+#define __NR_fsconfig          4431
+#define __NR_fsmount           4432
+#define __NR_fspick            4433
 
diff --git a/libc-top-half/musl/arch/mips/kstat.h b/libc-top-half/musl/arch/mips/kstat.h
new file mode 100644 (file)
index 0000000..5e637ea
--- /dev/null
@@ -0,0 +1,22 @@
+struct kstat {
+       unsigned st_dev;
+       long __st_padding1[3];
+       ino_t st_ino;
+       mode_t st_mode;
+       nlink_t st_nlink;
+       uid_t st_uid;
+       gid_t st_gid;
+       unsigned st_rdev;
+       long __st_padding2[3];
+       off_t st_size;
+       long st_atime_sec;
+       long st_atime_nsec;
+       long st_mtime_sec;
+       long st_mtime_nsec;
+       long st_ctime_sec;
+       long st_ctime_nsec;
+       blksize_t st_blksize;
+       long __st_padding3;
+       blkcnt_t st_blocks;
+        long __st_padding4[14];
+};
index 43bcdee7af65da1b9f46bf255d7f173ce974ace4..6ea73437b52baf7e53b7dc218a36d6c3c7bbf85c 100644 (file)
@@ -5,27 +5,25 @@
 
 #define SYSCALL_RLIM_INFINITY (-1UL/2)
 
-#if _MIPSEL || __MIPSEL || __MIPSEL__
-#define __stat_fix(st) ((st),(void)0)
+#if __mips_isa_rev >= 6
+#define SYSCALL_CLOBBERLIST \
+       "$1", "$3", "$11", "$12", "$13", \
+       "$14", "$15", "$24", "$25", "memory"
 #else
-#include <sys/stat.h>
-static inline void __stat_fix(long p)
-{
-       struct stat *st = (struct stat *)p;
-       st->st_dev >>= 32;
-       st->st_rdev >>= 32;
-}
+#define SYSCALL_CLOBBERLIST \
+       "$1", "$3", "$11", "$12", "$13", \
+       "$14", "$15", "$24", "$25", "hi", "lo", "memory"
 #endif
 
 static inline long __syscall0(long n)
 {
        register long r7 __asm__("$7");
-       register long r2 __asm__("$2");
+       register long r2 __asm__("$2") = n;
        __asm__ __volatile__ (
-               "addu $2,$0,%2 ; syscall"
-               : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7)
-               : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13",
-                 "$14", "$15", "$24", "$25", "hi", "lo", "memory");
+               "syscall"
+               : "+r"(r2), "=r"(r7)
+               :
+               : SYSCALL_CLOBBERLIST, "$8", "$9", "$10");
        return r7 ? -r2 : r2;
 }
 
@@ -33,13 +31,12 @@ static inline long __syscall1(long n, long a)
 {
        register long r4 __asm__("$4") = a;
        register long r7 __asm__("$7");
-       register long r2 __asm__("$2");
+       register long r2 __asm__("$2") = n;
        __asm__ __volatile__ (
-               "addu $2,$0,%2 ; syscall"
-               : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7),
-                 "r"(r4)
-               : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13",
-                 "$14", "$15", "$24", "$25", "hi", "lo", "memory");
+               "syscall"
+               : "+r"(r2), "=r"(r7)
+               : "r"(r4)
+               : SYSCALL_CLOBBERLIST, "$8", "$9", "$10");
        return r7 ? -r2 : r2;
 }
 
@@ -48,17 +45,13 @@ static inline long __syscall2(long n, long a, long b)
        register long r4 __asm__("$4") = a;
        register long r5 __asm__("$5") = b;
        register long r7 __asm__("$7");
-       register long r2 __asm__("$2");
+       register long r2 __asm__("$2") = n;
        __asm__ __volatile__ (
-               "addu $2,$0,%2 ; syscall"
-               : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7),
-                 "r"(r4), "r"(r5)
-               : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13",
-                 "$14", "$15", "$24", "$25", "hi", "lo", "memory");
-       if (r7) return -r2;
-       long ret = r2;
-       if (n == SYS_stat64 || n == SYS_fstat64 || n == SYS_lstat64) __stat_fix(b);
-       return ret;
+               "syscall"
+               : "+r"(r2), "=r"(r7)
+               : "r"(r4), "r"(r5)
+               : SYSCALL_CLOBBERLIST, "$8", "$9", "$10");
+       return r7 ? -r2 : r2;
 }
 
 static inline long __syscall3(long n, long a, long b, long c)
@@ -67,17 +60,13 @@ static inline long __syscall3(long n, long a, long b, long c)
        register long r5 __asm__("$5") = b;
        register long r6 __asm__("$6") = c;
        register long r7 __asm__("$7");
-       register long r2 __asm__("$2");
+       register long r2 __asm__("$2") = n;
        __asm__ __volatile__ (
-               "addu $2,$0,%2 ; syscall"
-               : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7),
-                 "r"(r4), "r"(r5), "r"(r6)
-               : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13",
-                 "$14", "$15", "$24", "$25", "hi", "lo", "memory");
-       if (r7) return -r2;
-       long ret = r2;
-       if (n == SYS_stat64 || n == SYS_fstat64 || n == SYS_lstat64) __stat_fix(b);
-       return ret;
+               "syscall"
+               : "+r"(r2), "=r"(r7)
+               : "r"(r4), "r"(r5), "r"(r6)
+               : SYSCALL_CLOBBERLIST, "$8", "$9", "$10");
+       return r7 ? -r2 : r2;
 }
 
 static inline long __syscall4(long n, long a, long b, long c, long d)
@@ -86,18 +75,13 @@ static inline long __syscall4(long n, long a, long b, long c, long d)
        register long r5 __asm__("$5") = b;
        register long r6 __asm__("$6") = c;
        register long r7 __asm__("$7") = d;
-       register long r2 __asm__("$2");
+       register long r2 __asm__("$2") = n;
        __asm__ __volatile__ (
-               "addu $2,$0,%2 ; syscall"
-               : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7),
-                 "r"(r4), "r"(r5), "r"(r6)
-               : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13",
-                 "$14", "$15", "$24", "$25", "hi", "lo", "memory");
-       if (r7) return -r2;
-       long ret = r2;
-       if (n == SYS_stat64 || n == SYS_fstat64 || n == SYS_lstat64) __stat_fix(b);
-       if (n == SYS_fstatat64) __stat_fix(c);
-       return ret;
+               "syscall"
+               : "+r"(r2), "+r"(r7)
+               : "r"(r4), "r"(r5), "r"(r6)
+               : SYSCALL_CLOBBERLIST, "$8", "$9", "$10");
+       return r7 ? -r2 : r2;
 }
 
 static inline long __syscall5(long n, long a, long b, long c, long d, long e)
@@ -107,20 +91,15 @@ static inline long __syscall5(long n, long a, long b, long c, long d, long e)
        register long r6 __asm__("$6") = c;
        register long r7 __asm__("$7") = d;
        register long r8 __asm__("$8") = e;
-       register long r2 __asm__("$2");
+       register long r2 __asm__("$2") = n;
        __asm__ __volatile__ (
                "subu $sp,$sp,32 ; sw $8,16($sp) ; "
-               "addu $2,$0,%3 ; syscall ;"
+               "syscall ;"
                "addu $sp,$sp,32"
-               : "=&r"(r2), "=r"(r7), "+r"(r8)
-               : "ir"(n), "0"(r2), "1"(r7), "r"(r4), "r"(r5), "r"(r6)
-               : "$1", "$3", "$9", "$10", "$11", "$12", "$13",
-                 "$14", "$15", "$24", "$25", "hi", "lo", "memory");
-       if (r7) return -r2;
-       long ret = r2;
-       if (n == SYS_stat64 || n == SYS_fstat64 || n == SYS_lstat64) __stat_fix(b);
-       if (n == SYS_fstatat64) __stat_fix(c);
-       return r2;
+               : "+r"(r2), "+r"(r7), "+r"(r8)
+               : "r"(r4), "r"(r5), "r"(r6)
+               : SYSCALL_CLOBBERLIST, "$9", "$10");
+       return r7 ? -r2 : r2;
 }
 
 static inline long __syscall6(long n, long a, long b, long c, long d, long e, long f)
@@ -131,20 +110,15 @@ static inline long __syscall6(long n, long a, long b, long c, long d, long e, lo
        register long r7 __asm__("$7") = d;
        register long r8 __asm__("$8") = e;
        register long r9 __asm__("$9") = f;
-       register long r2 __asm__("$2");
+       register long r2 __asm__("$2") = n;
        __asm__ __volatile__ (
                "subu $sp,$sp,32 ; sw $8,16($sp) ; sw $9,20($sp) ; "
-               "addu $2,$0,%4 ; syscall ;"
+               "syscall ;"
                "addu $sp,$sp,32"
-               : "=&r"(r2), "=r"(r7), "+r"(r8), "+r"(r9)
-               : "ir"(n), "0"(r2), "1"(r7), "r"(r4), "r"(r5), "r"(r6)
-               : "$1", "$3", "$10", "$11", "$12", "$13",
-                 "$14", "$15", "$24", "$25", "hi", "lo", "memory");
-       if (r7) return -r2;
-       long ret = r2;
-       if (n == SYS_stat64 || n == SYS_fstat64 || n == SYS_lstat64) __stat_fix(b);
-       if (n == SYS_fstatat64) __stat_fix(c);
-       return r2;
+               : "+r"(r2), "+r"(r7), "+r"(r8), "+r"(r9)
+               : "r"(r4), "r"(r5), "r"(r6)
+               : SYSCALL_CLOBBERLIST, "$10");
+       return r7 ? -r2 : r2;
 }
 
 static inline long __syscall7(long n, long a, long b, long c, long d, long e, long f, long g)
@@ -156,22 +130,20 @@ static inline long __syscall7(long n, long a, long b, long c, long d, long e, lo
        register long r8 __asm__("$8") = e;
        register long r9 __asm__("$9") = f;
        register long r10 __asm__("$10") = g;
-       register long r2 __asm__("$2");
+       register long r2 __asm__("$2") = n;
        __asm__ __volatile__ (
                "subu $sp,$sp,32 ; sw $8,16($sp) ; sw $9,20($sp) ; sw $10,24($sp) ; "
-               "addu $2,$0,%5 ; syscall ;"
+               "syscall ;"
                "addu $sp,$sp,32"
-               : "=&r"(r2), "=r"(r7), "+r"(r8), "+r"(r9), "+r"(r10)
-               : "ir"(n), "0"(r2), "1"(r7), "r"(r4), "r"(r5), "r"(r6)
-               : "$1", "$3", "$11", "$12", "$13",
-                 "$14", "$15", "$24", "$25", "hi", "lo", "memory");
-       if (r7) return -r2;
-       long ret = r2;
-       if (n == SYS_stat64 || n == SYS_fstat64 || n == SYS_lstat64) __stat_fix(b);
-       if (n == SYS_fstatat64) __stat_fix(c);
-       return r2;
+               : "+r"(r2), "+r"(r7), "+r"(r8), "+r"(r9), "+r"(r10)
+               : "r"(r4), "r"(r5), "r"(r6)
+               : SYSCALL_CLOBBERLIST);
+       return r7 ? -r2 : r2;
 }
 
 #define VDSO_USEFUL
 #define VDSO_CGT_SYM "__vdso_clock_gettime"
 #define VDSO_CGT_VER "LINUX_2.6"
+
+#define SO_SNDTIMEO_OLD 0x1005
+#define SO_RCVTIMEO_OLD 0x1006
index 43a8314e22141145529132788aa84781a3efa41d..df2271686a1c1e1ff1a75a37d2755cd56d1eb3e4 100644 (file)
@@ -10,5 +10,3 @@ struct ipc_perm {
        unsigned long __unused1;
        unsigned long __unused2;
 };
-
-#define IPC_64 0x100
diff --git a/libc-top-half/musl/arch/mips64/bits/msg.h b/libc-top-half/musl/arch/mips64/bits/msg.h
deleted file mode 100644 (file)
index 641e170..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-struct msqid_ds {
-       struct ipc_perm msg_perm;
-       time_t msg_stime;
-       time_t msg_rtime;
-       time_t msg_ctime;
-       unsigned long msg_cbytes;
-       msgqnum_t msg_qnum;
-       msglen_t msg_qbytes;
-       pid_t msg_lspid;
-       pid_t msg_lrpid;
-       unsigned long __pad1;
-       unsigned long __pad2;
-};
diff --git a/libc-top-half/musl/arch/mips64/bits/sem.h b/libc-top-half/musl/arch/mips64/bits/sem.h
deleted file mode 100644 (file)
index e46ced9..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-struct semid_ds {
-       struct ipc_perm sem_perm;
-       time_t sem_otime;
-       time_t sem_ctime;
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-       unsigned short sem_nsems;
-       char __sem_nsems_pad[sizeof(time_t)-sizeof(short)];
-#else
-       char __sem_nsems_pad[sizeof(time_t)-sizeof(short)];
-       unsigned short sem_nsems;
-#endif
-       time_t __unused3;
-       time_t __unused4;
-};
diff --git a/libc-top-half/musl/arch/mips64/bits/shm.h b/libc-top-half/musl/arch/mips64/bits/shm.h
deleted file mode 100644 (file)
index 8d19378..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-#define SHMLBA 4096
-
-struct shmid_ds {
-       struct ipc_perm shm_perm;
-       size_t shm_segsz;
-       time_t shm_atime;
-       time_t shm_dtime;
-       time_t shm_ctime;
-       pid_t shm_cpid;
-       pid_t shm_lpid;
-       unsigned long shm_nattch;
-       unsigned long __pad1;
-       unsigned long __pad2;
-};
-
-struct shminfo {
-       unsigned long shmmax, shmmin, shmmni, shmseg, shmall, __unused[4];
-};
-
-struct shm_info {
-       int __used_ids;
-       unsigned long shm_tot, shm_rss, shm_swp;
-       unsigned long __swap_attempts, __swap_successes;
-};
index b46617f144558c3567f3fce75aa0f5da55f5e9b0..b620e142da0a3d29a504018a1ecc9a223f41b36d 100644 (file)
@@ -1,6 +1,3 @@
-#include <string.h>
-#include <bits/alltypes.h>
-
 struct stat {
        dev_t st_dev;
        int __pad1[3];
index ca99e453f763526d0c854d35d05b1250dd61c148..34b9752e6a695b98c6da52d6c4b25d3b0c6d604e 100644 (file)
 #define __NR_io_uring_setup            5425
 #define __NR_io_uring_enter            5426
 #define __NR_io_uring_register         5427
+#define __NR_open_tree         5428
+#define __NR_move_mount                5429
+#define __NR_fsopen            5430
+#define __NR_fsconfig          5431
+#define __NR_fsmount           5432
+#define __NR_fspick            5433
 
diff --git a/libc-top-half/musl/arch/mips64/kstat.h b/libc-top-half/musl/arch/mips64/kstat.h
new file mode 100644 (file)
index 0000000..9a4468b
--- /dev/null
@@ -0,0 +1,21 @@
+struct kstat {
+       unsigned st_dev;
+       int __pad1[3];
+       ino_t st_ino;
+       mode_t st_mode;
+       unsigned st_nlink;
+       uid_t st_uid;
+       gid_t st_gid;
+       unsigned st_rdev;
+       int __pad2[3];
+       off_t st_size;
+       int st_atime_sec;
+       int st_atime_nsec;
+       int st_mtime_sec;
+       int st_mtime_nsec;
+       int st_ctime_sec;
+       int st_ctime_nsec;
+       unsigned st_blksize;
+       unsigned __pad3;
+       blkcnt_t st_blocks;
+};
index 99eebc3261253e5dcb6b2901a8bad9c9dbade3bf..69c429b8653aef6eff4c2a3189710c31bc36a60d 100644 (file)
@@ -3,58 +3,25 @@
 
 #define SYSCALL_RLIM_INFINITY (-1UL/2)
 
-#include <sys/stat.h>
-struct kernel_stat {
-       unsigned int st_dev;
-       unsigned int __pad1[3];
-       unsigned long long st_ino;
-       unsigned int st_mode;
-       unsigned int st_nlink;
-       int st_uid;
-       int st_gid;
-       unsigned int st_rdev;
-       unsigned int __pad2[3];
-       long long st_size;
-       unsigned int st_atime_sec;
-       unsigned int st_atime_nsec;
-       unsigned int st_mtime_sec;
-       unsigned int st_mtime_nsec;
-       unsigned int st_ctime_sec;
-       unsigned int st_ctime_nsec;
-       unsigned int st_blksize;
-       unsigned int __pad3;
-       unsigned long long st_blocks;
-};
-
-static void __stat_fix(struct kernel_stat *kst, struct stat *st)
-{
-       st->st_dev = kst->st_dev;
-       st->st_ino = kst->st_ino;
-       st->st_mode = kst->st_mode;
-       st->st_nlink = kst->st_nlink;
-       st->st_uid = kst->st_uid;
-       st->st_gid = kst->st_gid;
-       st->st_rdev = kst->st_rdev;
-       st->st_size = kst->st_size;
-       st->st_atim.tv_sec = kst->st_atime_sec;
-       st->st_atim.tv_nsec = kst->st_atime_nsec;
-       st->st_mtim.tv_sec = kst->st_mtime_sec;
-       st->st_mtim.tv_nsec = kst->st_mtime_nsec;
-       st->st_ctim.tv_sec = kst->st_ctime_sec;
-       st->st_ctim.tv_nsec = kst->st_ctime_nsec;
-       st->st_blksize = kst->st_blksize;
-       st->st_blocks = kst->st_blocks;
-}
+#if __mips_isa_rev >= 6
+#define SYSCALL_CLOBBERLIST \
+       "$1", "$3", "$10", "$11", "$12", "$13", \
+       "$14", "$15", "$24", "$25", "memory"
+#else
+#define SYSCALL_CLOBBERLIST \
+       "$1", "$3", "$10", "$11", "$12", "$13", \
+       "$14", "$15", "$24", "$25", "hi", "lo", "memory"
+#endif
 
 static inline long __syscall0(long n)
 {
        register long r7 __asm__("$7");
-       register long r2 __asm__("$2");
+       register long r2 __asm__("$2") = n;
        __asm__ __volatile__ (
-               "daddu $2,$0,%2 ; syscall"
-               : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7)
-               : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13",
-                 "$14", "$15", "$24", "$25", "hi", "lo", "memory");
+               "syscall"
+               : "+&r"(r2), "=r"(r7)
+               :
+               : SYSCALL_CLOBBERLIST);
        return r7 ? -r2 : r2;
 }
 
@@ -62,175 +29,100 @@ static inline long __syscall1(long n, long a)
 {
        register long r4 __asm__("$4") = a;
        register long r7 __asm__("$7");
-       register long r2 __asm__("$2");
+       register long r2 __asm__("$2") = n;
        __asm__ __volatile__ (
-               "daddu $2,$0,%2 ; syscall"
-               : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7),
-                 "r"(r4)
-               : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13",
-                 "$14", "$15", "$24", "$25", "hi", "lo", "memory");
+               "syscall"
+               : "+&r"(r2), "=r"(r7)
+               : "r"(r4)
+               : SYSCALL_CLOBBERLIST);
        return r7 ? -r2 : r2;
 }
 
 static inline long __syscall2(long n, long a, long b)
 {
-       struct kernel_stat kst;
-       long ret;
        register long r4 __asm__("$4") = a;
        register long r5 __asm__("$5") = b;
        register long r7 __asm__("$7");
-       register long r2 __asm__("$2");
-
-       if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat)
-               r5 = (long) &kst;
+       register long r2 __asm__("$2") = n;
 
        __asm__ __volatile__ (
-               "daddu $2,$0,%2 ; syscall"
-               : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7),
-                 "r"(r4), "r"(r5)
-               : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13",
-                 "$14", "$15", "$24", "$25", "hi", "lo", "memory");
-
-       if (r7) return -r2;
-       ret = r2;
-
-       if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat)
-               __stat_fix(&kst, (struct stat *)b);
-
-       return ret;
+               "syscall"
+               : "+&r"(r2), "=r"(r7)
+               : "r"(r4), "r"(r5)
+               : SYSCALL_CLOBBERLIST);
+       return r7 ? -r2 : r2;
 }
 
 static inline long __syscall3(long n, long a, long b, long c)
 {
-       struct kernel_stat kst;
-       long ret;
        register long r4 __asm__("$4") = a;
        register long r5 __asm__("$5") = b;
        register long r6 __asm__("$6") = c;
        register long r7 __asm__("$7");
-       register long r2 __asm__("$2");
-
-       if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat)
-               r5 = (long) &kst;
+       register long r2 __asm__("$2") = n;
 
        __asm__ __volatile__ (
-               "daddu $2,$0,%2 ; syscall"
-               : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7),
-                 "r"(r4), "r"(r5), "r"(r6)
-               : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13",
-                 "$14", "$15", "$24", "$25", "hi", "lo", "memory");
-
-       if (r7) return -r2;
-       ret = r2;
-
-       if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat)
-               __stat_fix(&kst, (struct stat *)b);
-
-       return ret;
+               "syscall"
+               : "+&r"(r2), "=r"(r7)
+               : "r"(r4), "r"(r5), "r"(r6)
+               : SYSCALL_CLOBBERLIST);
+       return r7 ? -r2 : r2;
 }
 
 static inline long __syscall4(long n, long a, long b, long c, long d)
 {
-       struct kernel_stat kst;
-       long ret;
        register long r4 __asm__("$4") = a;
        register long r5 __asm__("$5") = b;
        register long r6 __asm__("$6") = c;
        register long r7 __asm__("$7") = d;
-       register long r2 __asm__("$2");
-
-       if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat)
-               r5 = (long) &kst;
-       if (n == SYS_newfstatat)
-               r6 = (long) &kst;
+       register long r2 __asm__("$2") = n;
 
        __asm__ __volatile__ (
-               "daddu $2,$0,%2 ; syscall"
-               : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7),
-                 "r"(r4), "r"(r5), "r"(r6)
-               : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13",
-                 "$14", "$15", "$24", "$25", "hi", "lo", "memory");
-
-       if (r7) return -r2;
-       ret = r2;
-
-       if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat)
-               __stat_fix(&kst, (struct stat *)b);
-       if (n == SYS_newfstatat)
-               __stat_fix(&kst, (struct stat *)c);
-
-       return ret;
+               "syscall"
+               : "+&r"(r2), "+r"(r7)
+               : "r"(r4), "r"(r5), "r"(r6)
+               : SYSCALL_CLOBBERLIST);
+       return r7 ? -r2 : r2;
 }
 
 static inline long __syscall5(long n, long a, long b, long c, long d, long e)
 {
-       struct kernel_stat kst;
-       long ret;
        register long r4 __asm__("$4") = a;
        register long r5 __asm__("$5") = b;
        register long r6 __asm__("$6") = c;
        register long r7 __asm__("$7") = d;
        register long r8 __asm__("$8") = e;
-       register long r2 __asm__("$2");
-
-       if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat)
-               r5 = (long) &kst;
-       if (n == SYS_newfstatat)
-               r6 = (long) &kst;
+       register long r2 __asm__("$2") = n;
 
        __asm__ __volatile__ (
-               "daddu $2,$0,%2 ; syscall"
-               : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7),
-                 "r"(r4), "r"(r5), "r"(r6), "r"(r8)
-               : "$1", "$3", "$9", "$10", "$11", "$12", "$13",
-                 "$14", "$15", "$24", "$25", "hi", "lo", "memory");
-
-       if (r7) return -r2;
-       ret = r2;
-
-       if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat)
-               __stat_fix(&kst, (struct stat *)b);
-       if (n == SYS_newfstatat)
-               __stat_fix(&kst, (struct stat *)c);
-
-       return ret;
+               "syscall"
+               : "+&r"(r2), "+r"(r7)
+               : "r"(r4), "r"(r5), "r"(r6), "r"(r8)
+               : SYSCALL_CLOBBERLIST);
+       return r7 ? -r2 : r2;
 }
 
 static inline long __syscall6(long n, long a, long b, long c, long d, long e, long f)
 {
-       struct kernel_stat kst;
-       long ret;
        register long r4 __asm__("$4") = a;
        register long r5 __asm__("$5") = b;
        register long r6 __asm__("$6") = c;
        register long r7 __asm__("$7") = d;
        register long r8 __asm__("$8") = e;
        register long r9 __asm__("$9") = f;
-       register long r2 __asm__("$2");
-
-       if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat)
-               r5 = (long) &kst;
-       if (n == SYS_newfstatat)
-               r6 = (long) &kst;
+       register long r2 __asm__("$2") = n;
 
        __asm__ __volatile__ (
-               "daddu $2,$0,%2 ; syscall"
-               : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7),
-                 "r"(r4), "r"(r5), "r"(r6), "r"(r8), "r"(r9)
-               : "$1", "$3", "$10", "$11", "$12", "$13",
-                 "$14", "$15", "$24", "$25", "hi", "lo", "memory");
-
-       if (r7) return -r2;
-       ret = r2;
-
-       if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat)
-               __stat_fix(&kst, (struct stat *)b);
-       if (n == SYS_newfstatat)
-               __stat_fix(&kst, (struct stat *)c);
-
-       return ret;
+               "syscall"
+               : "+&r"(r2), "+r"(r7)
+               : "r"(r4), "r"(r5), "r"(r6), "r"(r8), "r"(r9)
+               : SYSCALL_CLOBBERLIST);
+       return r7 ? -r2 : r2;
 }
 
 #define VDSO_USEFUL
 #define VDSO_CGT_SYM "__vdso_clock_gettime"
 #define VDSO_CGT_VER "LINUX_2.6"
+
+#define SO_SNDTIMEO_OLD 0x1005
+#define SO_RCVTIMEO_OLD 0x1006
diff --git a/libc-top-half/musl/arch/mipsn32/bits/ipcstat.h b/libc-top-half/musl/arch/mipsn32/bits/ipcstat.h
new file mode 100644 (file)
index 0000000..0018ad1
--- /dev/null
@@ -0,0 +1 @@
+#define IPC_STAT 2
index e46ced95d2be4c4ef568b4717d1012d1cfdb2d30..5184eb5977ece3775fe5f7a6659a83d6da24ca44 100644 (file)
@@ -4,11 +4,11 @@ struct semid_ds {
        time_t sem_ctime;
 #if __BYTE_ORDER == __LITTLE_ENDIAN
        unsigned short sem_nsems;
-       char __sem_nsems_pad[sizeof(time_t)-sizeof(short)];
+       char __sem_nsems_pad[sizeof(long)-sizeof(short)];
 #else
-       char __sem_nsems_pad[sizeof(time_t)-sizeof(short)];
+       char __sem_nsems_pad[sizeof(long)-sizeof(short)];
        unsigned short sem_nsems;
 #endif
-       time_t __unused3;
-       time_t __unused4;
+       long __unused3;
+       long __unused4;
 };
index f4d1df83e60cda5913df8cc59cc8f45338f0a8c7..27d36b5125ef6791cfcaa0873f0fd55c64e34600 100644 (file)
@@ -1,6 +1,3 @@
-#include <string.h>
-#include <bits/alltypes.h>
-
 struct stat {
        dev_t st_dev;
        long __pad1[2];
index f31ee4463f88bbed5983cc01de965259847398d0..d80cafa81dee8b4f198c48abdfe1aa0de03f7a5b 100644 (file)
 #define __NR_io_uring_setup            6425
 #define __NR_io_uring_enter            6426
 #define __NR_io_uring_register         6427
+#define __NR_open_tree         6428
+#define __NR_move_mount                6429
+#define __NR_fsopen            6430
+#define __NR_fsconfig          6431
+#define __NR_fsmount           6432
+#define __NR_fspick            6433
 
diff --git a/libc-top-half/musl/arch/mipsn32/kstat.h b/libc-top-half/musl/arch/mipsn32/kstat.h
new file mode 100644 (file)
index 0000000..3841559
--- /dev/null
@@ -0,0 +1,22 @@
+struct kstat {
+       unsigned st_dev;
+       long __pad1[3];
+       ino_t st_ino;
+       mode_t st_mode;
+       nlink_t st_nlink;
+       uid_t st_uid;
+       gid_t st_gid;
+       unsigned st_rdev;
+       long __pad2[3];
+       off_t st_size;
+       long st_atime_sec;
+       long st_atime_nsec;
+       long st_mtime_sec;
+       long st_mtime_nsec;
+       long st_ctime_sec;
+       long st_ctime_nsec;
+       blksize_t st_blksize;
+       long __pad3;
+       blkcnt_t st_blocks;
+       long __pad4[14];
+};
index 7b11740f07b78b7e715ca741d82d726488213a3a..5ff43bba1f7ccdb8dc75b9ec2e0c7d98044532f2 100644 (file)
@@ -3,27 +3,25 @@
 
 #define SYSCALL_RLIM_INFINITY (-1UL/2)
 
-#if _MIPSEL || __MIPSEL || __MIPSEL__
-#define __stat_fix(st) ((st),(void)0)
+#if __mips_isa_rev >= 6
+#define SYSCALL_CLOBBERLIST \
+       "$1", "$3", "$10", "$11", "$12", "$13", \
+       "$14", "$15", "$24", "$25", "memory"
 #else
-#include <sys/stat.h>
-static inline void __stat_fix(long p)
-{
-       struct stat *st = (struct stat *)p;
-       st->st_dev >>= 32;
-       st->st_rdev >>= 32;
-}
+#define SYSCALL_CLOBBERLIST \
+       "$1", "$3", "$10", "$11", "$12", "$13", \
+       "$14", "$15", "$24", "$25", "hi", "lo", "memory"
 #endif
 
 static inline long __syscall0(long n)
 {
        register long r7 __asm__("$7");
-       register long r2 __asm__("$2");
+       register long r2 __asm__("$2") = n;
        __asm__ __volatile__ (
-               "addu $2,$0,%2 ; syscall"
-               : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7)
-               : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13",
-                 "$14", "$15", "$24", "$25", "hi", "lo", "memory");
+               "syscall"
+               : "+&r"(r2), "=r"(r7)
+               :
+               : SYSCALL_CLOBBERLIST);
        return r7 ? -r2 : r2;
 }
 
@@ -31,13 +29,12 @@ static inline long __syscall1(long n, long a)
 {
        register long r4 __asm__("$4") = a;
        register long r7 __asm__("$7");
-       register long r2 __asm__("$2");
+       register long r2 __asm__("$2") = n;
        __asm__ __volatile__ (
-               "addu $2,$0,%2 ; syscall"
-               : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7),
-                 "r"(r4)
-               : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13",
-                 "$14", "$15", "$24", "$25", "hi", "lo", "memory");
+               "syscall"
+               : "+&r"(r2), "=r"(r7)
+               : "r"(r4)
+               : SYSCALL_CLOBBERLIST);
        return r7 ? -r2 : r2;
 }
 
@@ -46,17 +43,13 @@ static inline long __syscall2(long n, long a, long b)
        register long r4 __asm__("$4") = a;
        register long r5 __asm__("$5") = b;
        register long r7 __asm__("$7");
-       register long r2 __asm__("$2");
+       register long r2 __asm__("$2") = n;
        __asm__ __volatile__ (
-               "addu $2,$0,%2 ; syscall"
-               : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7),
-                 "r"(r4), "r"(r5)
-               : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13",
-                 "$14", "$15", "$24", "$25", "hi", "lo", "memory");
-       if (r7) return -r2;
-       long ret = r2;
-       if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat) __stat_fix(b);
-       return ret;
+               "syscall"
+               : "+&r"(r2), "=r"(r7)
+               : "r"(r4), "r"(r5)
+               : SYSCALL_CLOBBERLIST);
+       return r7 ? -r2 : r2;
 }
 
 static inline long __syscall3(long n, long a, long b, long c)
@@ -65,17 +58,13 @@ static inline long __syscall3(long n, long a, long b, long c)
        register long r5 __asm__("$5") = b;
        register long r6 __asm__("$6") = c;
        register long r7 __asm__("$7");
-       register long r2 __asm__("$2");
+       register long r2 __asm__("$2") = n;
        __asm__ __volatile__ (
-               "addu $2,$0,%2 ; syscall"
-               : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7),
-                 "r"(r4), "r"(r5), "r"(r6)
-               : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13",
-                 "$14", "$15", "$24", "$25", "hi", "lo", "memory");
-       if (r7) return -r2;
-       long ret = r2;
-       if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat) __stat_fix(b);
-       return ret;
+               "syscall"
+               : "+&r"(r2), "=r"(r7)
+               : "r"(r4), "r"(r5), "r"(r6)
+               : SYSCALL_CLOBBERLIST);
+       return r7 ? -r2 : r2;
 }
 
 static inline long __syscall4(long n, long a, long b, long c, long d)
@@ -84,18 +73,13 @@ static inline long __syscall4(long n, long a, long b, long c, long d)
        register long r5 __asm__("$5") = b;
        register long r6 __asm__("$6") = c;
        register long r7 __asm__("$7") = d;
-       register long r2 __asm__("$2");
+       register long r2 __asm__("$2") = n;
        __asm__ __volatile__ (
-               "addu $2,$0,%2 ; syscall"
-               : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7),
-                 "r"(r4), "r"(r5), "r"(r6)
-               : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13",
-                 "$14", "$15", "$24", "$25", "hi", "lo", "memory");
-       if (r7) return -r2;
-       long ret = r2;
-       if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat) __stat_fix(b);
-       if (n == SYS_newfstatat) __stat_fix(c);
-       return ret;
+               "syscall"
+               : "+&r"(r2), "+r"(r7)
+               : "r"(r4), "r"(r5), "r"(r6)
+               : SYSCALL_CLOBBERLIST);
+       return r7 ? -r2 : r2;
 }
 
 static inline long __syscall5(long n, long a, long b, long c, long d, long e)
@@ -105,16 +89,13 @@ static inline long __syscall5(long n, long a, long b, long c, long d, long e)
        register long r6 __asm__("$6") = c;
        register long r7 __asm__("$7") = d;
        register long r8 __asm__("$8") = e;
-       register long r2 __asm__("$2");
+       register long r2 __asm__("$2") = n;
        __asm__ __volatile__ (
-               "addu $2,$0,%2 ; syscall"
-               : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7),
-                 "r"(r4), "r"(r5), "r"(r6), "r"(r8)
-               : "$1", "$3", "$9", "$10", "$11", "$12", "$13",
-                 "$14", "$15", "$24", "$25", "hi", "lo", "memory");
-       if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat) __stat_fix(b);
-       if (n == SYS_newfstatat) __stat_fix(c);
-       return r2;
+               "syscall"
+               : "+&r"(r2), "+r"(r7)
+               : "r"(r4), "r"(r5), "r"(r6), "r"(r8)
+               : SYSCALL_CLOBBERLIST);
+       return r7 ? -r2 : r2;
 }
 
 static inline long __syscall6(long n, long a, long b, long c, long d, long e, long f)
@@ -125,18 +106,18 @@ static inline long __syscall6(long n, long a, long b, long c, long d, long e, lo
        register long r7 __asm__("$7") = d;
        register long r8 __asm__("$8") = e;
        register long r9 __asm__("$9") = f;
-       register long r2 __asm__("$2");
+       register long r2 __asm__("$2") = n;
        __asm__ __volatile__ (
-               "addu $2,$0,%2 ; syscall"
-               : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7),
-                 "r"(r4), "r"(r5), "r"(r6), "r"(r8), "r"(r9)
-               : "$1", "$3", "$10", "$11", "$12", "$13",
-                 "$14", "$15", "$24", "$25", "hi", "lo", "memory");
-       if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat) __stat_fix(b);
-       if (n == SYS_newfstatat) __stat_fix(c);
-       return r2;
+               "syscall"
+               : "+&r"(r2), "+r"(r7)
+               : "r"(r4), "r"(r5), "r"(r6), "r"(r8), "r"(r9)
+               : SYSCALL_CLOBBERLIST);
+       return r7 ? -r2 : r2;
 }
 
 #define VDSO_USEFUL
 #define VDSO_CGT_SYM "__vdso_clock_gettime"
 #define VDSO_CGT_VER "LINUX_2.6"
+
+#define SO_SNDTIMEO_OLD 0x1005
+#define SO_RCVTIMEO_OLD 0x1006
diff --git a/libc-top-half/musl/arch/or1k/bits/ipc.h b/libc-top-half/musl/arch/or1k/bits/ipc.h
deleted file mode 100644 (file)
index 3d894e3..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-struct ipc_perm {
-       key_t __ipc_perm_key;
-       uid_t uid;
-       gid_t gid;
-       uid_t cuid;
-       gid_t cgid;
-       mode_t mode;
-       int __ipc_perm_seq;
-       long __pad1;
-       long __pad2;
-};
-
-#define IPC_64 0
diff --git a/libc-top-half/musl/arch/or1k/bits/ipcstat.h b/libc-top-half/musl/arch/or1k/bits/ipcstat.h
new file mode 100644 (file)
index 0000000..0018ad1
--- /dev/null
@@ -0,0 +1 @@
+#define IPC_STAT 2
diff --git a/libc-top-half/musl/arch/or1k/bits/sem.h b/libc-top-half/musl/arch/or1k/bits/sem.h
new file mode 100644 (file)
index 0000000..08faafe
--- /dev/null
@@ -0,0 +1,11 @@
+struct semid_ds {
+       struct ipc_perm sem_perm;
+       time_t sem_otime;
+       long __unused1;
+       time_t sem_ctime;
+       long __unused2;
+       char __sem_nsems_pad[sizeof(long)-sizeof(short)];
+       unsigned short sem_nsems;
+       long __unused3;
+       long __unused4;
+};
diff --git a/libc-top-half/musl/arch/or1k/bits/shm.h b/libc-top-half/musl/arch/or1k/bits/shm.h
new file mode 100644 (file)
index 0000000..81b2a29
--- /dev/null
@@ -0,0 +1,27 @@
+#define SHMLBA 4096
+
+struct shmid_ds {
+       struct ipc_perm shm_perm;
+       size_t shm_segsz;
+       time_t shm_atime;
+       int __unused1;
+       time_t shm_dtime;
+       int __unused2;
+       time_t shm_ctime;
+       int __unused3;
+       pid_t shm_cpid;
+       pid_t shm_lpid;
+       unsigned long shm_nattch;
+       unsigned long __pad1;
+       unsigned long __pad2;
+};
+
+struct shminfo {
+       unsigned long shmmax, shmmin, shmmni, shmseg, shmall, __unused[4];
+};
+
+struct shm_info {
+       int __used_ids;
+       unsigned long shm_tot, shm_rss, shm_swp;
+       unsigned long __swap_attempts, __swap_successes;
+};
index 33a868619f1746d9cea766bc9f6b56c9b449dce5..8ffcfae87a6a5629b2e172da7867b72e9e6f1519 100644 (file)
 #define __NR_io_uring_setup 425
 #define __NR_io_uring_enter 426
 #define __NR_io_uring_register 427
+#define __NR_open_tree         428
+#define __NR_move_mount                429
+#define __NR_fsopen            430
+#define __NR_fsconfig          431
+#define __NR_fsmount           432
+#define __NR_fspick            433
 
diff --git a/libc-top-half/musl/arch/or1k/kstat.h b/libc-top-half/musl/arch/or1k/kstat.h
new file mode 100644 (file)
index 0000000..c144957
--- /dev/null
@@ -0,0 +1,21 @@
+struct kstat {
+       dev_t st_dev;
+       ino_t st_ino;
+       mode_t st_mode;
+       nlink_t st_nlink;
+       uid_t st_uid;
+       gid_t st_gid;
+       dev_t st_rdev;
+       long long __st_rdev_padding;
+       off_t st_size;
+       blksize_t st_blksize;
+       int __st_blksize_padding;
+       blkcnt_t st_blocks;
+       long st_atime_sec;
+       long st_atime_nsec;
+       long st_mtime_sec;
+       long st_mtime_nsec;
+       long st_ctime_sec;
+       long st_ctime_nsec;
+       unsigned __unused[2];
+};
index 5a9b074a02b409a958751f4f22e2d1e375261723..21738ce07e2f44d104162f681ee4be8a1c94ed80 100644 (file)
@@ -111,3 +111,5 @@ static inline long __syscall6(long n, long a, long b, long c, long d, long e, lo
                                "r23", "r25", "r27", "r29", "r31");
        return r11;
 }
+
+#define IPC_64 0
index 37f27d6f4d58479f60a3dc814421b86869ea42a9..8e687ef16dd3d24d64f4e7fd7ba91cee2b4677c7 100644 (file)
@@ -6,8 +6,12 @@ TYPEDEF __builtin_va_list va_list;
 TYPEDEF __builtin_va_list __isoc_va_list;
 
 #ifndef __cplusplus
+#ifdef __WCHAR_TYPE__
+TYPEDEF __WCHAR_TYPE__ wchar_t;
+#else
 TYPEDEF long wchar_t;
 #endif
+#endif
 
 TYPEDEF float float_t;
 TYPEDEF double double_t;
index 3f2ede07b6d4d4435897b8068be5d34051e5938f..a388d56b5b3e36b7b8f5d2c7b3ac2e34bb6815ad 100644 (file)
@@ -10,6 +10,3 @@ struct ipc_perm {
        long long __pad2;
        long long __pad3;
 };
-
-#define IPC_64 0x100
-
diff --git a/libc-top-half/musl/arch/powerpc/bits/ipcstat.h b/libc-top-half/musl/arch/powerpc/bits/ipcstat.h
new file mode 100644 (file)
index 0000000..0018ad1
--- /dev/null
@@ -0,0 +1 @@
+#define IPC_STAT 2
index 40e5e8bec848e66d95ebd18d38d920d785c298bc..b19801d51a067d8211b1b211dd395ebfaff7ce1f 100644 (file)
@@ -26,4 +26,3 @@ struct shm_info {
        unsigned long shm_tot, shm_rss, shm_swp;
        unsigned long __swap_attempts, __swap_successes;
 };
-
index 0a6c9addff1d18a63a3a1b87650032fb5492850e..adcf63dbbc8d3038654e22a4b4028d1f2a095756 100644 (file)
 #define __NR_io_uring_setup        425
 #define __NR_io_uring_enter        426
 #define __NR_io_uring_register     427
+#define __NR_open_tree         428
+#define __NR_move_mount                429
+#define __NR_fsopen            430
+#define __NR_fsconfig          431
+#define __NR_fsmount           432
+#define __NR_fspick            433
 
index 6cc8aaf7228864446a9d2fb54cc3f933276586e0..7f528746323b1aac2c08d24a94c89b9c42482c61 100644 (file)
@@ -1,10 +1,8 @@
-struct pt_regs {
-       unsigned long gpr[32], nip, msr, orig_gpr3, ctr, link, xer, ccr, mq;
-       unsigned long trap, dar, dsisr, result;
-};
-
 struct user {
-       struct pt_regs regs;
+       struct {
+               unsigned long gpr[32], nip, msr, orig_gpr3, ctr, link, xer, ccr, mq;
+               unsigned long trap, dar, dsisr, result;
+       } regs;
        unsigned long u_tsize, u_dsize, u_ssize;
        unsigned long start_code, start_data, start_stack;
        long signal;
diff --git a/libc-top-half/musl/arch/powerpc/kstat.h b/libc-top-half/musl/arch/powerpc/kstat.h
new file mode 100644 (file)
index 0000000..5a611e7
--- /dev/null
@@ -0,0 +1,20 @@
+struct kstat {
+       dev_t st_dev;
+       ino_t st_ino;
+       mode_t st_mode;
+       nlink_t st_nlink;
+       uid_t st_uid;
+       gid_t st_gid;
+       dev_t st_rdev;
+       short __st_rdev_padding;
+       off_t st_size;
+       blksize_t st_blksize;
+       blkcnt_t st_blocks;
+       long st_atime_sec;
+       long st_atime_nsec;
+       long st_mtime_sec;
+       long st_mtime_nsec;
+       long st_ctime_sec;
+       long st_ctime_nsec;
+       unsigned __unused[2];
+};
index 1b4cab36a60878c81bb20e06ea1fdc6e22d346df..527b6b7cdc5f4409e6419b3a177d5cb7320a0ea3 100644 (file)
@@ -9,6 +9,7 @@
 #define TPOFF_K (-0x7000)
 
 #define REL_SYMBOLIC    R_PPC_ADDR32
+#define REL_USYMBOLIC   R_PPC_UADDR32
 #define REL_GOT         R_PPC_GLOB_DAT
 #define REL_PLT         R_PPC_JMP_SLOT
 #define REL_RELATIVE    R_PPC_RELATIVE
index e26a3c34c26a821dda8765cd6eb4ab63d068df50..ede97c1c085fa54b0439d3742a946574bae42bb2 100644 (file)
@@ -89,3 +89,6 @@ static inline long __syscall6(long n, long a, long b, long c, long d, long e, lo
 }
 
 #define SYSCALL_FADVISE_6_ARG
+
+#define SO_RCVTIMEO_OLD  18
+#define SO_SNDTIMEO_OLD  19
index 3f2ede07b6d4d4435897b8068be5d34051e5938f..a388d56b5b3e36b7b8f5d2c7b3ac2e34bb6815ad 100644 (file)
@@ -10,6 +10,3 @@ struct ipc_perm {
        long long __pad2;
        long long __pad3;
 };
-
-#define IPC_64 0x100
-
diff --git a/libc-top-half/musl/arch/powerpc64/bits/msg.h b/libc-top-half/musl/arch/powerpc64/bits/msg.h
deleted file mode 100644 (file)
index 2e23ca2..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-struct msqid_ds {
-       struct ipc_perm msg_perm;
-       time_t msg_stime;
-       time_t msg_rtime;
-       time_t msg_ctime;
-       unsigned long msg_cbytes;
-       msgqnum_t msg_qnum;
-       msglen_t msg_qbytes;
-       pid_t msg_lspid;
-       pid_t msg_lrpid;
-       unsigned long __unused[2];
-};
diff --git a/libc-top-half/musl/arch/powerpc64/bits/sem.h b/libc-top-half/musl/arch/powerpc64/bits/sem.h
deleted file mode 100644 (file)
index 558184d..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <endian.h>
-
-struct semid_ds {
-       struct ipc_perm sem_perm;
-       time_t sem_otime;
-       time_t sem_ctime;
-#if __BYTE_ORDER == __BIG_ENDIAN
-       unsigned short __pad[3], sem_nsems;
-#else
-       unsigned short sem_nsems, __pad[3];
-#endif
-       unsigned long __unused[2];
-};
index 8108c3a8116a02035fd8b83dcb24ae1173f1c2bb..b7f73a8deb92adcbe4baa231ea7bdc5d502870ee 100644 (file)
@@ -21,4 +21,3 @@ struct shm_info {
        unsigned long shm_tot, shm_rss, shm_swp;
        unsigned long __swap_attempts, __swap_successes;
 };
-
index 0c894a2325cbe663e222505bc42adaf97b945a74..32545b3940f14152d4960acf1c2f22a223ab62ef 100644 (file)
 #define __NR_io_uring_setup         425
 #define __NR_io_uring_enter         426
 #define __NR_io_uring_register      427
+#define __NR_open_tree         428
+#define __NR_move_mount                429
+#define __NR_fsopen            430
+#define __NR_fsconfig          431
+#define __NR_fsmount           432
+#define __NR_fspick            433
 
index 7ca459b327b7a2537a88e05b1a80cd11829a7cfc..7e75d20156b4e78ce6e188cf12b94d187f1881ea 100644 (file)
@@ -1,10 +1,8 @@
-struct pt_regs {
-       unsigned long gpr[32], nip, msr, orig_gpr3, ctr, link, xer, ccr, softe;
-       unsigned long trap, dar, dsisr, result;
-};
-
 struct user {
-       struct pt_regs regs;
+       struct {
+               unsigned long gpr[32], nip, msr, orig_gpr3, ctr, link, xer, ccr, softe;
+               unsigned long trap, dar, dsisr, result;
+       } regs;
        unsigned long u_tsize, u_dsize, u_ssize;
        unsigned long start_code, start_data, start_stack;
        long signal;
diff --git a/libc-top-half/musl/arch/powerpc64/kstat.h b/libc-top-half/musl/arch/powerpc64/kstat.h
new file mode 100644 (file)
index 0000000..887b3e2
--- /dev/null
@@ -0,0 +1,19 @@
+struct kstat {
+       dev_t st_dev;
+       ino_t st_ino;
+       nlink_t st_nlink;
+       mode_t st_mode;
+       uid_t st_uid;
+       gid_t st_gid;
+       dev_t st_rdev;
+       off_t st_size;
+       blksize_t st_blksize;
+       blkcnt_t st_blocks;
+       long st_atime_sec;
+       long st_atime_nsec;
+       long st_mtime_sec;
+       long st_mtime_nsec;
+       long st_ctime_sec;
+       long st_ctime_nsec;
+       unsigned long __unused[3];
+};
index faf70acd752c6f950ba6126cd09b75624fc0abf9..5bdaeede5437bbc99b5f47bd1271e5ef87c55d3d 100644 (file)
@@ -11,6 +11,7 @@
 #define TPOFF_K (-0x7000)
 
 #define REL_SYMBOLIC    R_PPC64_ADDR64
+#define REL_USYMBOLIC   R_PPC64_UADDR64
 #define REL_GOT         R_PPC64_GLOB_DAT
 #define REL_PLT         R_PPC64_JMP_SLOT
 #define REL_RELATIVE    R_PPC64_RELATIVE
index 1e730625350551108c7f6fcde4814f39c6859be2..76b4e335cff958d189a737ae75cbe07ef0891503 100644 (file)
@@ -85,3 +85,6 @@ static inline long __syscall6(long n, long a, long b, long c, long d, long e, lo
        :: "memory", "cr0", "r9", "r10", "r11", "r12");
        return r3;
 }
+
+#define SO_RCVTIMEO_OLD  18
+#define SO_SNDTIMEO_OLD  19
index 98f12fc7cb965ebe377ce1add7847136c2f0de69..41ad4d04907cb2627c484da9eb756a9f635134a5 100644 (file)
@@ -8,13 +8,15 @@ static inline void a_barrier()
 static inline int a_cas(volatile int *p, int t, int s)
 {
        int old, tmp;
-       __asm__("\n1:   lr.w.aqrl %0, %2\n"
+       __asm__ __volatile__ (
+               "\n1:   lr.w.aqrl %0, (%2)\n"
                "       bne %0, %3, 1f\n"
-               "       sc.w.aqrl %1, %4, %2\n"
+               "       sc.w.aqrl %1, %4, (%2)\n"
                "       bnez %1, 1b\n"
                "1:"
-               : "=&r"(old), "+r"(tmp), "+A"(*p)
-               : "r"(t), "r"(s));
+               : "=&r"(old), "=&r"(tmp)
+               : "r"(p), "r"(t), "r"(s)
+               : "memory");
        return old;
 }
 
@@ -23,12 +25,14 @@ static inline void *a_cas_p(volatile void *p, void *t, void *s)
 {
        void *old;
        int tmp;
-       __asm__("\n1:   lr.d.aqrl %0, %2\n"
+       __asm__ __volatile__ (
+               "\n1:   lr.d.aqrl %0, (%2)\n"
                "       bne %0, %3, 1f\n"
-               "       sc.d.aqrl %1, %4, %2\n"
+               "       sc.d.aqrl %1, %4, (%2)\n"
                "       bnez %1, 1b\n"
                "1:"
-               : "=&r"(old), "+r"(tmp), "+A"(*(long *)p)
-               : "r"(t), "r"(s));
+               : "=&r"(old), "=&r"(tmp)
+               : "r"(p), "r"(t), "r"(s)
+               : "memory");
        return old;
 }
diff --git a/libc-top-half/musl/arch/riscv64/bits/ipc.h b/libc-top-half/musl/arch/riscv64/bits/ipc.h
deleted file mode 100644 (file)
index 6f3328a..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-struct ipc_perm {
-       key_t __ipc_perm_key;
-       uid_t uid;
-       gid_t gid;
-       uid_t cuid;
-       gid_t cgid;
-       mode_t mode;
-       unsigned short __ipc_perm_seq;
-
-       unsigned long __pad1;
-       unsigned long __pad2;
-};
-
-#define IPC_64 0
diff --git a/libc-top-half/musl/arch/riscv64/bits/msg.h b/libc-top-half/musl/arch/riscv64/bits/msg.h
deleted file mode 100644 (file)
index 641e170..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-struct msqid_ds {
-       struct ipc_perm msg_perm;
-       time_t msg_stime;
-       time_t msg_rtime;
-       time_t msg_ctime;
-       unsigned long msg_cbytes;
-       msgqnum_t msg_qnum;
-       msglen_t msg_qbytes;
-       pid_t msg_lspid;
-       pid_t msg_lrpid;
-       unsigned long __pad1;
-       unsigned long __pad2;
-};
diff --git a/libc-top-half/musl/arch/riscv64/bits/sem.h b/libc-top-half/musl/arch/riscv64/bits/sem.h
deleted file mode 100644 (file)
index 5f93c12..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-struct semid_ds {
-       struct ipc_perm sem_perm;
-       time_t sem_otime;
-       time_t sem_ctime;
-       unsigned short sem_nsems;
-       char __sem_nsems_pad[sizeof(time_t)-sizeof(short)];
-       time_t __unused3;
-       time_t __unused4;
-};
diff --git a/libc-top-half/musl/arch/riscv64/bits/shm.h b/libc-top-half/musl/arch/riscv64/bits/shm.h
deleted file mode 100644 (file)
index 4c3c9fb..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-#define SHMLBA 4096
-
-struct shmid_ds
-{
-       struct ipc_perm shm_perm;
-       size_t shm_segsz;
-       time_t shm_atime;
-       time_t shm_dtime;
-       time_t shm_ctime;
-       pid_t shm_cpid;
-       pid_t shm_lpid;
-       unsigned long shm_nattch;
-       unsigned long __pad1;
-       unsigned long __pad2;
-};
-
-struct shminfo {
-       unsigned long shmmax, shmmin, shmmni, shmseg, shmall, __unused[4];
-};
-
-struct shm_info {
-       int __used_ids;
-       unsigned long shm_tot, shm_rss, shm_swp;
-       unsigned long __swap_attempts, __swap_successes;
-};
index 4c94a8f02edc189fcd90924eb83700a13eab11c5..2ff4be302c62130d69c0733ed51067faec2675be 100644 (file)
@@ -6,46 +6,43 @@
 # define SIGSTKSZ 8192
 #endif
 
-/* gregs[0] holds the program counter. */
+typedef unsigned long __riscv_mc_gp_state[32];
 
-#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
-typedef unsigned long greg_t;
-typedef unsigned long gregset_t[32];
-
-struct __riscv_f_ext_state {
-       unsigned int f[32];
-       unsigned int fcsr;
+struct __riscv_mc_f_ext_state {
+       unsigned int __f[32];
+       unsigned int __fcsr;
 };
 
-struct __riscv_d_ext_state {
-       unsigned long long f[32];
-       unsigned int fcsr;
+struct __riscv_mc_d_ext_state {
+       unsigned long long __f[32];
+       unsigned int __fcsr;
 };
 
-struct __riscv_q_ext_state {
-       unsigned long long f[64] __attribute__((aligned(16)));
-       unsigned int fcsr;
-       unsigned int reserved[3];
+struct __riscv_mc_q_ext_state {
+       unsigned long long __f[64] __attribute__((aligned(16)));
+       unsigned int __fcsr;
+       unsigned int __reserved[3];
 };
 
-union __riscv_fp_state {
-       struct __riscv_f_ext_state f;
-       struct __riscv_d_ext_state d;
-       struct __riscv_q_ext_state q;
+union __riscv_mc_fp_state {
+       struct __riscv_mc_f_ext_state __f;
+       struct __riscv_mc_d_ext_state __d;
+       struct __riscv_mc_q_ext_state __q;
 };
 
-typedef union __riscv_fp_state fpregset_t;
+typedef struct mcontext_t {
+       __riscv_mc_gp_state __gregs;
+       union __riscv_mc_fp_state __fpregs;
+} mcontext_t;
 
-typedef struct sigcontext {
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+typedef unsigned long greg_t;
+typedef unsigned long gregset_t[32];
+typedef union __riscv_mc_fp_state fpregset_t;
+struct sigcontext {
        gregset_t gregs;
        fpregset_t fpregs;
-} mcontext_t;
-
-#else
-typedef struct {
-       unsigned long gregs[32];
-       unsigned long long fpregs[66];
-} mcontext_t;
+};
 #endif
 
 struct sigaltstack {
@@ -54,10 +51,10 @@ struct sigaltstack {
        size_t ss_size;
 };
 
-typedef struct __ucontext
+typedef struct ucontext_t
 {
        unsigned long uc_flags;
-       struct __ucontext *uc_link;
+       struct ucontext_t *uc_link;
        stack_t uc_stack;
        sigset_t uc_sigmask;
        mcontext_t uc_mcontext;
index 03d7f86dacd2271588c04142b421977dc125695f..1db70cfbf562a02d67f310ae631104753f7694b5 100644 (file)
 #define __NR_pkey_mprotect 288
 #define __NR_pkey_alloc 289
 #define __NR_pkey_free 290
+#define __NR_statx 291
+#define __NR_io_pgetevents 292
+#define __NR_rseq 293
+#define __NR_kexec_file_load 294
+#define __NR_pidfd_send_signal 424
+#define __NR_io_uring_setup 425
+#define __NR_io_uring_enter 426
+#define __NR_io_uring_register 427
+#define __NR_open_tree         428
+#define __NR_move_mount                429
+#define __NR_fsopen            430
+#define __NR_fsconfig          431
+#define __NR_fsmount           432
+#define __NR_fspick            433
+
 #define __NR_sysriscv __NR_arch_specific_syscall
 #define __NR_riscv_flush_icache (__NR_sysriscv + 15)
index bd0f0fc7027f058468992eed35437ed4275bfa6c..2da743eaf8fe9b437f3f6183968124c532083553 100644 (file)
@@ -1,43 +1,5 @@
-struct user_regs_struct {
-       unsigned long pc;
-       unsigned long ra;
-       unsigned long sp;
-       unsigned long gp;
-       unsigned long tp;
-       unsigned long t0;
-       unsigned long t1;
-       unsigned long t2;
-       unsigned long s0;
-       unsigned long s1;
-       unsigned long a0;
-       unsigned long a1;
-       unsigned long a2;
-       unsigned long a3;
-       unsigned long a4;
-       unsigned long a5;
-       unsigned long a6;
-       unsigned long a7;
-       unsigned long s2;
-       unsigned long s3;
-       unsigned long s4;
-       unsigned long s5;
-       unsigned long s6;
-       unsigned long s7;
-       unsigned long s8;
-       unsigned long s9;
-       unsigned long s10;
-       unsigned long s11;
-       unsigned long t3;
-       unsigned long t4;
-       unsigned long t5;
-       unsigned long t6;
-};
-
-struct user_fpregs_struct {
-       double f[32];
-       unsigned int fcsr;
-};
+#include <signal.h>
 
 #define ELF_NGREG 32
 typedef unsigned long elf_greg_t, elf_gregset_t[ELF_NGREG];
-typedef struct user_fpregs_struct elf_fpregset_t;
+typedef union __riscv_mc_fp_state elf_fpregset_t;
diff --git a/libc-top-half/musl/arch/riscv64/kstat.h b/libc-top-half/musl/arch/riscv64/kstat.h
new file mode 100644 (file)
index 0000000..92625f3
--- /dev/null
@@ -0,0 +1,21 @@
+struct kstat {
+       dev_t st_dev;
+       ino_t st_ino;
+       mode_t st_mode;
+       nlink_t st_nlink;
+       uid_t st_uid;
+       gid_t st_gid;
+       dev_t st_rdev;
+       unsigned long __pad;
+       off_t st_size;
+       blksize_t st_blksize;
+       int __pad2;
+       blkcnt_t st_blocks;
+       long st_atime_sec;
+       long st_atime_nsec;
+       long st_mtime_sec;
+       long st_mtime_nsec;
+       long st_ctime_sec;
+       long st_ctime_nsec;
+       unsigned __unused[2];
+};
index 1268b72dc99df756d82529f61fb5753661253da6..db414b170281af8f29d9fbbd1d65d1145ad7bd7f 100644 (file)
@@ -11,4 +11,4 @@ static inline struct pthread *__pthread_self()
 
 #define DTP_OFFSET 0x800
 
-#define MC_PC gregs[0]
+#define MC_PC __gregs[0]
index 1aaeb63138d59598d6c280b564bfdbe36d34693a..7fd042cd4ad37695f84d87372ff830cf5aa3b22b 100644 (file)
@@ -3,7 +3,7 @@
 
 #define __asm_syscall(...) \
        __asm__ __volatile__ ("ecall\n\t" \
-       : "+r"(a0) : __VA_ARGS__ : "memory"); \
+       : "=r"(a0) : __VA_ARGS__ : "memory"); \
        return a0; \
 
 static inline long __syscall0(long n)
@@ -74,3 +74,5 @@ static inline long __syscall6(long n, long a, long b, long c, long d, long e, lo
 /* We don't have a clock_gettime function.
 #define VDSO_CGT_SYM "__vdso_clock_gettime"
 #define VDSO_CGT_VER "LINUX_2.6" */
+
+#define IPC_64 0
diff --git a/libc-top-half/musl/arch/s390x/bits/ipc.h b/libc-top-half/musl/arch/s390x/bits/ipc.h
deleted file mode 100644 (file)
index 4710c12..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-struct ipc_perm {
-       key_t __ipc_perm_key;
-       uid_t uid;
-       gid_t gid;
-       uid_t cuid;
-       gid_t cgid;
-       mode_t mode;
-       unsigned short __pad1;
-       unsigned short __ipc_perm_seq;
-       unsigned long __pad2;
-       unsigned long __pad3;
-};
-
-#define IPC_64 0x100
diff --git a/libc-top-half/musl/arch/s390x/bits/msg.h b/libc-top-half/musl/arch/s390x/bits/msg.h
deleted file mode 100644 (file)
index 2e23ca2..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-struct msqid_ds {
-       struct ipc_perm msg_perm;
-       time_t msg_stime;
-       time_t msg_rtime;
-       time_t msg_ctime;
-       unsigned long msg_cbytes;
-       msgqnum_t msg_qnum;
-       msglen_t msg_qbytes;
-       pid_t msg_lspid;
-       pid_t msg_lrpid;
-       unsigned long __unused[2];
-};
diff --git a/libc-top-half/musl/arch/s390x/bits/sem.h b/libc-top-half/musl/arch/s390x/bits/sem.h
deleted file mode 100644 (file)
index 644f68a..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-struct semid_ds {
-       struct ipc_perm sem_perm;
-       time_t sem_otime;
-       time_t sem_ctime;
-       unsigned short __pad[3], sem_nsems;
-       unsigned long __unused[2];
-};
diff --git a/libc-top-half/musl/arch/s390x/bits/shm.h b/libc-top-half/musl/arch/s390x/bits/shm.h
deleted file mode 100644 (file)
index 6652d65..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-#define SHMLBA 4096
-
-struct shmid_ds {
-       struct ipc_perm shm_perm;
-       size_t shm_segsz;
-       time_t shm_atime;
-       time_t shm_dtime;
-       time_t shm_ctime;
-       pid_t shm_cpid;
-       pid_t shm_lpid;
-       unsigned long shm_nattch;
-       unsigned long __pad1;
-       unsigned long __pad2;
-};
-
-struct shminfo {
-       unsigned long shmmax, shmmin, shmmni, shmseg, shmall, __unused[4];
-};
-
-struct shm_info {
-       int __used_ids;
-       unsigned long shm_tot, shm_rss, shm_swp;
-       unsigned long __swap_attempts, __swap_successes;
-};
-
index 72fd2cce1f3f47bec3155dadd1efac47e773870b..c4c70474efe273c64b8ac5ff491534dd07d0b778 100644 (file)
 #define __NR_io_uring_setup             425
 #define __NR_io_uring_enter             426
 #define __NR_io_uring_register          427
+#define __NR_open_tree         428
+#define __NR_move_mount                429
+#define __NR_fsopen            430
+#define __NR_fsconfig          431
+#define __NR_fsmount           432
+#define __NR_fspick            433
 
diff --git a/libc-top-half/musl/arch/s390x/kstat.h b/libc-top-half/musl/arch/s390x/kstat.h
new file mode 100644 (file)
index 0000000..001c10b
--- /dev/null
@@ -0,0 +1,19 @@
+struct kstat {
+       dev_t st_dev;
+       ino_t st_ino;
+       nlink_t st_nlink;
+       mode_t st_mode;
+       uid_t st_uid;
+       gid_t st_gid;
+       dev_t st_rdev;
+       off_t st_size;
+       long st_atime_sec;
+       long st_atime_nsec;
+       long st_mtime_sec;
+       long st_mtime_nsec;
+       long st_ctime_sec;
+       long st_ctime_nsec;
+       blksize_t st_blksize;
+       blkcnt_t st_blocks;
+       unsigned long __unused[3];
+};
index 37f27d6f4d58479f60a3dc814421b86869ea42a9..8e687ef16dd3d24d64f4e7fd7ba91cee2b4677c7 100644 (file)
@@ -6,8 +6,12 @@ TYPEDEF __builtin_va_list va_list;
 TYPEDEF __builtin_va_list __isoc_va_list;
 
 #ifndef __cplusplus
+#ifdef __WCHAR_TYPE__
+TYPEDEF __WCHAR_TYPE__ wchar_t;
+#else
 TYPEDEF long wchar_t;
 #endif
+#endif
 
 TYPEDEF float float_t;
 TYPEDEF double double_t;
diff --git a/libc-top-half/musl/arch/sh/bits/ipcstat.h b/libc-top-half/musl/arch/sh/bits/ipcstat.h
new file mode 100644 (file)
index 0000000..0018ad1
--- /dev/null
@@ -0,0 +1 @@
+#define IPC_STAT 2
diff --git a/libc-top-half/musl/arch/sh/bits/msg.h b/libc-top-half/musl/arch/sh/bits/msg.h
new file mode 100644 (file)
index 0000000..bc8436c
--- /dev/null
@@ -0,0 +1,15 @@
+struct msqid_ds {
+       struct ipc_perm msg_perm;
+       time_t msg_stime;
+       int __unused1;
+       time_t msg_rtime;
+       int __unused2;
+       time_t msg_ctime;
+       int __unused3;
+       unsigned long msg_cbytes;
+       msgqnum_t msg_qnum;
+       msglen_t msg_qbytes;
+       pid_t msg_lspid;
+       pid_t msg_lrpid;
+       unsigned long __unused[2];
+};
diff --git a/libc-top-half/musl/arch/sh/bits/sem.h b/libc-top-half/musl/arch/sh/bits/sem.h
new file mode 100644 (file)
index 0000000..d383d4e
--- /dev/null
@@ -0,0 +1,16 @@
+struct semid_ds {
+       struct ipc_perm sem_perm;
+       time_t sem_otime;
+       long __unused1;
+       time_t sem_ctime;
+       long __unused2;
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+       unsigned short sem_nsems;
+       char __sem_nsems_pad[sizeof(long)-sizeof(short)];
+#else
+       char __sem_nsems_pad[sizeof(long)-sizeof(short)];
+       unsigned short sem_nsems;
+#endif
+       long __unused3;
+       long __unused4;
+};
index ad35fc64ee6dfc98de3478227aa1b598595bb5ad..4705ef93e457a0557ea1f5f81687797d76641825 100644 (file)
 #define __NR_io_uring_setup         425
 #define __NR_io_uring_enter         426
 #define __NR_io_uring_register      427
+#define __NR_open_tree         428
+#define __NR_move_mount                429
+#define __NR_fsopen            430
+#define __NR_fsconfig          431
+#define __NR_fsmount           432
+#define __NR_fspick            433
 
index d7363f74a99af663530532128e299d1c8f30841a..07fe843b6e6077ca08e9a8f5118ca531e31da497 100644 (file)
 #define REG_FPSCR      55
 #define REG_FPUL       56
 
-struct pt_regs {
-       unsigned long regs[16];
-       unsigned long pc;
-       unsigned long pr;
-       unsigned long sr;
-       unsigned long gbr;
-       unsigned long mach;
-       unsigned long macl;
-       long tra;
-};
-
-struct pt_dspregs {
-       unsigned long a1;
-       unsigned long a0g;
-       unsigned long a1g;
-       unsigned long m0;
-       unsigned long m1;
-       unsigned long a0;
-       unsigned long x0;
-       unsigned long x1;
-       unsigned long y0;
-       unsigned long y1;
-       unsigned long dsr;
-       unsigned long rs;
-       unsigned long re;
-       unsigned long mod;
-};
-
 struct user_fpu_struct {
        unsigned long fp_regs[16];
        unsigned long xfp_regs[16];
@@ -58,7 +30,11 @@ typedef elf_greg_t elf_gregset_t[ELF_NGREG];
 typedef struct user_fpu_struct elf_fpregset_t;
 
 struct user {
-       struct pt_regs regs;
+       struct {
+               unsigned long regs[16];
+               unsigned long pc, pr, sr, gbr, mach, macl;
+               long tra;
+       } regs;
        struct user_fpu_struct fpu;
        int u_fpvalid;
        unsigned long u_tsize;
diff --git a/libc-top-half/musl/arch/sh/kstat.h b/libc-top-half/musl/arch/sh/kstat.h
new file mode 100644 (file)
index 0000000..af449c9
--- /dev/null
@@ -0,0 +1,21 @@
+struct kstat {
+       dev_t st_dev;
+       int __st_dev_padding;
+       long __st_ino_truncated;
+       mode_t st_mode;
+       nlink_t st_nlink;
+       uid_t st_uid;
+       gid_t st_gid;
+       dev_t st_rdev;
+       int __st_rdev_padding;
+       off_t st_size;
+       blksize_t st_blksize;
+       blkcnt_t st_blocks;
+       long st_atime_sec;
+       long st_atime_nsec;
+       long st_mtime_sec;
+       long st_mtime_nsec;
+       long st_ctime_sec;
+       long st_ctime_nsec;
+       ino_t st_ino;
+};
index 48f61d94a2f5d34d92f52e1cfc815fc098b6b6f9..628d8d3741226183b20cd2b3f5f0569a36969751 100644 (file)
@@ -88,3 +88,6 @@ static inline long __syscall6(long n, long a, long b, long c, long d, long e, lo
 }
 
 #define SYSCALL_IPC_BROKEN_MODE
+
+#define SIOCGSTAMP_OLD   (2U<<30 | 's'<<8 | 100 | 8<<16)
+#define SIOCGSTAMPNS_OLD (2U<<30 | 's'<<8 | 101 | 8<<16)
index 16391295bcbf5c56cc6ef0898ad1a19dfa44f290..c612eec098263b63e27386f6ff9e6ea9fd4a8f2c 100644 (file)
@@ -6,8 +6,12 @@ TYPEDEF __builtin_va_list va_list;
 TYPEDEF __builtin_va_list __isoc_va_list;
 
 #ifndef __cplusplus
+#ifdef __WCHAR_TYPE__
+TYPEDEF __WCHAR_TYPE__ wchar_t;
+#else
 TYPEDEF long wchar_t;
 #endif
+#endif
 
 #if defined(__FLT_EVAL_METHOD__) && __FLT_EVAL_METHOD__ == 2
 TYPEDEF long double float_t;
index 55d2e41a4da4d85716812638d16fc1fb8ba5d0b5..a12380f638dc672080978eb48149b30bddc7ce3e 100644 (file)
@@ -9,5 +9,3 @@ struct ipc_perm {
        long long __pad1;
        long long __pad2;
 };
-
-#define IPC_64 0
diff --git a/libc-top-half/musl/arch/x32/bits/sem.h b/libc-top-half/musl/arch/x32/bits/sem.h
new file mode 100644 (file)
index 0000000..18745f4
--- /dev/null
@@ -0,0 +1,11 @@
+struct semid_ds {
+       struct ipc_perm sem_perm;
+       time_t sem_otime;
+       long long __unused1;
+       time_t sem_ctime;
+       long long __unused2;
+       unsigned short sem_nsems;
+       char __sem_nsems_pad[sizeof(long long)-sizeof(short)];
+       long long __unused3;
+       long long __unused4;
+};
index 77ec432fe5884b48264a054d1db126fc99df6a5d..4d72852e327254ac10e707580179f781fb104276 100644 (file)
 #define __NR_io_uring_setup (0x40000000 + 425)
 #define __NR_io_uring_enter (0x40000000 + 426)
 #define __NR_io_uring_register (0x40000000 + 427)
+#define __NR_open_tree         (0x40000000 + 428)
+#define __NR_move_mount                (0x40000000 + 429)
+#define __NR_fsopen            (0x40000000 + 430)
+#define __NR_fsconfig          (0x40000000 + 431)
+#define __NR_fsmount           (0x40000000 + 432)
+#define __NR_fspick            (0x40000000 + 433)
 
 #define __NR_rt_sigaction (0x40000000 + 512)
 #define __NR_rt_sigreturn (0x40000000 + 513)
diff --git a/libc-top-half/musl/arch/x32/kstat.h b/libc-top-half/musl/arch/x32/kstat.h
new file mode 100644 (file)
index 0000000..ce25fce
--- /dev/null
@@ -0,0 +1,22 @@
+struct kstat {
+       dev_t st_dev;
+       ino_t st_ino;
+       nlink_t st_nlink;
+
+       mode_t st_mode;
+       uid_t st_uid;
+       gid_t st_gid;
+       unsigned int    __pad0;
+       dev_t st_rdev;
+       off_t st_size;
+       blksize_t st_blksize;
+       blkcnt_t st_blocks;
+
+       long long st_atime_sec;
+       long st_atime_nsec;
+       long long st_mtime_sec;
+       long st_mtime_nsec;
+       long long st_ctime_sec;
+       long st_ctime_nsec;
+       long long __unused[3];
+};
index 344da03c9a49947f4db0fa2ce2665e8aa597070a..e0a2216067d27cae5c1f8c4c45a6406e8f3c9f08 100644 (file)
@@ -3,35 +3,6 @@
 
 #define __scc(X) sizeof(1?(X):0ULL) < 8 ? (unsigned long) (X) : (long long) (X)
 typedef long long syscall_arg_t;
-struct __timespec { long long tv_sec; long tv_nsec; };
-struct __timespec_kernel { long long tv_sec; long long tv_nsec; };
-#define __tsc(X) ((struct __timespec*)(unsigned long)(X))
-#define __fixup(X) do { if(X) { \
-       ts->tv_sec = __tsc(X)->tv_sec; \
-       ts->tv_nsec = __tsc(X)->tv_nsec; \
-       (X) = (unsigned long)ts; } } while(0)
-#define __fixup_case_2 \
-       case SYS_nanosleep: \
-               __fixup(a1); break; \
-       case SYS_clock_settime: \
-               __fixup(a2); break;
-#define __fixup_case_3 \
-       case SYS_clock_nanosleep: case SYS_rt_sigtimedwait: case SYS_ppoll: \
-               __fixup(a3); break; \
-       case SYS_utimensat: \
-               if(a3) { \
-                       ts[0].tv_sec = __tsc(a3)[0].tv_sec; \
-                       ts[0].tv_nsec = __tsc(a3)[0].tv_nsec; \
-                       ts[1].tv_sec = __tsc(a3)[1].tv_sec; \
-                       ts[1].tv_nsec = __tsc(a3)[1].tv_nsec; \
-                       a3 = (unsigned long)ts; \
-               } break;
-#define __fixup_case_4 \
-       case SYS_futex: \
-               if((a2 & (~128 /* FUTEX_PRIVATE_FLAG */)) == 0 /* FUTEX_WAIT */) __fixup(a4); break;
-#define __fixup_case_5 \
-       case SYS_mq_timedsend: case SYS_mq_timedreceive: case SYS_pselect6: \
-               __fixup(a5); break;
 
 static __inline long __syscall0(long long n)
 {
@@ -50,10 +21,6 @@ static __inline long __syscall1(long long n, long long a1)
 static __inline long __syscall2(long long n, long long a1, long long a2)
 {
        unsigned long ret;
-       struct __timespec_kernel ts[1];
-       switch (n) {
-               __fixup_case_2;
-       }
        __asm__ __volatile__ ("syscall" : "=a"(ret) : "a"(n), "D"(a1), "S"(a2)
                                        : "rcx", "r11", "memory");
        return ret;
@@ -62,11 +29,6 @@ static __inline long __syscall2(long long n, long long a1, long long a2)
 static __inline long __syscall3(long long n, long long a1, long long a2, long long a3)
 {
        unsigned long ret;
-       struct __timespec_kernel ts[2];
-       switch (n) {
-               __fixup_case_2;
-               __fixup_case_3;
-       }
        __asm__ __volatile__ ("syscall" : "=a"(ret) : "a"(n), "D"(a1), "S"(a2),
                                                  "d"(a3) : "rcx", "r11", "memory");
        return ret;
@@ -77,12 +39,6 @@ static __inline long __syscall4(long long n, long long a1, long long a2, long lo
 {
        unsigned long ret;
        register long long a4 __asm__("r10") = a4_;
-       struct __timespec_kernel ts[2];
-       switch (n) {
-               __fixup_case_2;
-               __fixup_case_3;
-               __fixup_case_4;
-       }
        __asm__ __volatile__ ("syscall" : "=a"(ret) : "a"(n), "D"(a1), "S"(a2),
                                          "d"(a3), "r"(a4): "rcx", "r11", "memory");
        return ret;
@@ -94,13 +50,6 @@ static __inline long __syscall5(long long n, long long a1, long long a2, long lo
        unsigned long ret;
        register long long a4 __asm__("r10") = a4_;
        register long long a5 __asm__("r8") = a5_;
-       struct __timespec_kernel ts[2];
-       switch (n) {
-               __fixup_case_2;
-               __fixup_case_3;
-               __fixup_case_4;
-               __fixup_case_5;
-       }
        __asm__ __volatile__ ("syscall" : "=a"(ret) : "a"(n), "D"(a1), "S"(a2),
                                          "d"(a3), "r"(a4), "r"(a5) : "rcx", "r11", "memory");
        return ret;
@@ -113,14 +62,30 @@ static __inline long __syscall6(long long n, long long a1, long long a2, long lo
        register long long a4 __asm__("r10") = a4_;
        register long long a5 __asm__("r8") = a5_;
        register long long a6 __asm__("r9") = a6_;
-       struct __timespec_kernel ts[2];
-       switch (n) {
-               __fixup_case_2;
-               __fixup_case_3;
-               __fixup_case_4;
-               __fixup_case_5;
-       }
        __asm__ __volatile__ ("syscall" : "=a"(ret) : "a"(n), "D"(a1), "S"(a2),
                                          "d"(a3), "r"(a4), "r"(a5), "r"(a6) : "rcx", "r11", "memory");
        return ret;
 }
+
+#undef SYS_futimesat
+
+#define SYS_clock_gettime64 SYS_clock_gettime
+#define SYS_clock_settime64 SYS_clock_settime
+#define SYS_clock_adjtime64 SYS_clock_adjtime
+#define SYS_clock_nanosleep_time64 SYS_clock_nanosleep
+#define SYS_timer_gettime64 SYS_timer_gettime
+#define SYS_timer_settime64 SYS_timer_settime
+#define SYS_timerfd_gettime64 SYS_timerfd_gettime
+#define SYS_timerfd_settime64 SYS_timerfd_settime
+#define SYS_utimensat_time64 SYS_utimensat
+#define SYS_pselect6_time64 SYS_pselect6
+#define SYS_ppoll_time64 SYS_ppoll
+#define SYS_recvmmsg_time64 SYS_recvmmsg
+#define SYS_mq_timedsend_time64 SYS_mq_timedsend
+#define SYS_mq_timedreceive_time64 SYS_mq_timedreceive
+#define SYS_semtimedop_time64 SYS_semtimedop
+#define SYS_rt_sigtimedwait_time64 SYS_rt_sigtimedwait
+#define SYS_futex_time64 SYS_futex
+#define SYS_sched_rr_get_interval_time64 SYS_sched_rr_get_interval
+
+#define IPC_64 0
diff --git a/libc-top-half/musl/arch/x86_64/bits/ipc.h b/libc-top-half/musl/arch/x86_64/bits/ipc.h
deleted file mode 100644 (file)
index 3d894e3..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-struct ipc_perm {
-       key_t __ipc_perm_key;
-       uid_t uid;
-       gid_t gid;
-       uid_t cuid;
-       gid_t cgid;
-       mode_t mode;
-       int __ipc_perm_seq;
-       long __pad1;
-       long __pad2;
-};
-
-#define IPC_64 0
diff --git a/libc-top-half/musl/arch/x86_64/bits/msg.h b/libc-top-half/musl/arch/x86_64/bits/msg.h
deleted file mode 100644 (file)
index 2e23ca2..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-struct msqid_ds {
-       struct ipc_perm msg_perm;
-       time_t msg_stime;
-       time_t msg_rtime;
-       time_t msg_ctime;
-       unsigned long msg_cbytes;
-       msgqnum_t msg_qnum;
-       msglen_t msg_qbytes;
-       pid_t msg_lspid;
-       pid_t msg_lrpid;
-       unsigned long __unused[2];
-};
diff --git a/libc-top-half/musl/arch/x86_64/bits/sem.h b/libc-top-half/musl/arch/x86_64/bits/sem.h
new file mode 100644 (file)
index 0000000..e61571c
--- /dev/null
@@ -0,0 +1,11 @@
+struct semid_ds {
+       struct ipc_perm sem_perm;
+       time_t sem_otime;
+       long __unused1;
+       time_t sem_ctime;
+       long __unused2;
+       unsigned short sem_nsems;
+       char __sem_nsems_pad[sizeof(long)-sizeof(short)];
+       long __unused3;
+       long __unused4;
+};
diff --git a/libc-top-half/musl/arch/x86_64/bits/shm.h b/libc-top-half/musl/arch/x86_64/bits/shm.h
deleted file mode 100644 (file)
index 6652d65..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-#define SHMLBA 4096
-
-struct shmid_ds {
-       struct ipc_perm shm_perm;
-       size_t shm_segsz;
-       time_t shm_atime;
-       time_t shm_dtime;
-       time_t shm_ctime;
-       pid_t shm_cpid;
-       pid_t shm_lpid;
-       unsigned long shm_nattch;
-       unsigned long __pad1;
-       unsigned long __pad2;
-};
-
-struct shminfo {
-       unsigned long shmmax, shmmin, shmmni, shmseg, shmall, __unused[4];
-};
-
-struct shm_info {
-       int __used_ids;
-       unsigned long shm_tot, shm_rss, shm_swp;
-       unsigned long __swap_attempts, __swap_successes;
-};
-
index 49572ef2defd83500963ee05419d85e33986ebc9..2d4634f68359d5514e0e762ad834cf65fe7926cd 100644 (file)
 #define __NR_io_uring_setup                    425
 #define __NR_io_uring_enter                    426
 #define __NR_io_uring_register                 427
+#define __NR_open_tree         428
+#define __NR_move_mount                429
+#define __NR_fsopen            430
+#define __NR_fsconfig          431
+#define __NR_fsmount           432
+#define __NR_fspick            433
 
diff --git a/libc-top-half/musl/arch/x86_64/kstat.h b/libc-top-half/musl/arch/x86_64/kstat.h
new file mode 100644 (file)
index 0000000..5976c04
--- /dev/null
@@ -0,0 +1,22 @@
+struct kstat {
+       dev_t st_dev;
+       ino_t st_ino;
+       nlink_t st_nlink;
+
+       mode_t st_mode;
+       uid_t st_uid;
+       gid_t st_gid;
+       unsigned int    __pad0;
+       dev_t st_rdev;
+       off_t st_size;
+       blksize_t st_blksize;
+       blkcnt_t st_blocks;
+
+       long st_atime_sec;
+       long st_atime_nsec;
+       long st_mtime_sec;
+       long st_mtime_nsec;
+       long st_ctime_sec;
+       long st_ctime_nsec;
+       long __unused[3];
+};
index 54e05ff653527bd52c5e109eb9a74a3cab6e0634..92d5c179217b25418e257b2fd1b563abeeff6f65 100644 (file)
@@ -66,3 +66,5 @@ static __inline long __syscall6(long n, long a1, long a2, long a3, long a4, long
 #define VDSO_CGT_VER "LINUX_2.6"
 #define VDSO_GETCPU_SYM "__vdso_getcpu"
 #define VDSO_GETCPU_VER "LINUX_2.6"
+
+#define IPC_64 0
index 969b6f7b2dec686c7ad13e69c5a37c68412937ce..15bef28854b38f1301b4e433897208861ebe5c60 100644 (file)
@@ -105,6 +105,11 @@ int posix_fallocate(int, off_t, off_t);
 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
 #define AT_NO_AUTOMOUNT 0x800
 #define AT_EMPTY_PATH 0x1000
+#define AT_STATX_SYNC_TYPE 0x6000
+#define AT_STATX_SYNC_AS_STAT 0x0000
+#define AT_STATX_FORCE_SYNC 0x2000
+#define AT_STATX_DONT_SYNC 0x4000
+#define AT_RECURSIVE 0x8000
 
 #define FAPPEND O_APPEND
 #define FFSYNC O_SYNC
index 76f6c1c68a235688789bbf740b2ba7e5f34983a5..8c4bf15891d78c8fec9ff164be9c58762ecc2c71 100644 (file)
@@ -31,6 +31,11 @@ void globfree(glob_t *);
 #define GLOB_NOESCAPE 0x40
 #define        GLOB_PERIOD   0x80
 
+#ifdef __wasilibc_unmodified_upstream // WASI has no usernames
+#define GLOB_TILDE       0x1000
+#define GLOB_TILDE_CHECK 0x4000
+#endif
+
 #define GLOB_NOSPACE 1
 #define GLOB_ABORTED 2
 #define GLOB_NOMATCH 3
index ecd6c73cbda7f47da6f3ec64f95b577463d7d805..8af47dbef55cafb100c830b978165a2d7c028b7c 100644 (file)
@@ -76,6 +76,7 @@
 #define ETH_P_QINQ2    0x9200
 #define ETH_P_QINQ3    0x9300
 #define ETH_P_EDSA     0xDADA
+#define ETH_P_DSA_8021Q        0xDADB
 #define ETH_P_IFE      0xED3E
 #define ETH_P_AF_IUCV  0xFBFB
 
index b39685a3e43cad5de07019a6e4dd8d6b2cfcd2b3..887b926e2c644dc6737815adc7df6b728a59aed1 100644 (file)
@@ -67,8 +67,10 @@ struct ipv6_mreq {
 #define INADDR_ALLSNOOPERS_GROUP ((in_addr_t) 0xe000006a)
 #define INADDR_MAX_LOCAL_GROUP  ((in_addr_t) 0xe00000ff)
 
+#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
 #define IN6ADDR_ANY_INIT      { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
 #define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
+#endif
 
 extern const struct in6_addr in6addr_any, in6addr_loopback;
 
index 6c20036d700dabe863a995a1b6275fd397fcb702..290e174aac5a6ac6360183b366bf79c57e780ff3 100644 (file)
@@ -19,10 +19,12 @@ extern "C" {
 #ifdef __wasilibc_unmodified_upstream /* WASI has no CPU scheduling support. */
 struct sched_param {
        int sched_priority;
-       int sched_ss_low_priority;
-       struct timespec sched_ss_repl_period;
-       struct timespec sched_ss_init_budget;
-       int sched_ss_max_repl;
+       int __reserved1;
+       struct {
+               time_t __reserved1;
+               long __reserved2;
+       } __reserved2[2];
+       int __reserved3;
 };
 
 int    sched_get_priority_max(int);
@@ -50,6 +52,7 @@ int     sched_yield(void);
 #define CLONE_FS       0x00000200
 #define CLONE_FILES    0x00000400
 #define CLONE_SIGHAND  0x00000800
+#define CLONE_PIDFD    0x00001000
 #define CLONE_PTRACE   0x00002000
 #define CLONE_VFORK    0x00004000
 #define CLONE_PARENT   0x00008000
index c9bd1939e05b108ea6c42ac5100f84a6b9dbb2bc..8eb73e003a65e3cb40abdc3c47371084522b9864 100644 (file)
@@ -71,6 +71,11 @@ int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *__restrict, int
 int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *, int);
 int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *, int, int);
 
+#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
+int posix_spawn_file_actions_addchdir_np(posix_spawn_file_actions_t *__restrict, const char *__restrict);
+int posix_spawn_file_actions_addfchdir_np(posix_spawn_file_actions_t *, int);
+#endif
+
 #ifdef __cplusplus
 }
 #endif
index 42f628eac7fb4e9bc4274fc475f957eff996b970..3d4b1f3fc6e1c0ac8f85b9330845daa09b5bdaa7 100644 (file)
@@ -180,6 +180,7 @@ int ptsname_r(int, char *, size_t);
 char *ecvt(double, int, int *, int *);
 char *fcvt(double, int, int *, int *);
 char *gcvt(double, int, char *);
+char *secure_getenv(const char *);
 struct __locale_struct;
 float strtof_l(const char *__restrict, char **__restrict, struct __locale_struct *);
 double strtod_l(const char *__restrict, char **__restrict, struct __locale_struct *);
index c5a39819c5e700b8c08e448cb0e4fa22389378d3..9e366b7bed0499abed8cacb13a4e64faedad79d1 100644 (file)
@@ -22,6 +22,7 @@ extern "C" {
 #endif
 
 #include <bits/ipc.h>
+#include <bits/ipcstat.h>
 
 #define IPC_CREAT  01000
 #define IPC_EXCL   02000
@@ -29,7 +30,6 @@ extern "C" {
 
 #define IPC_RMID 0
 #define IPC_SET  1
-#define IPC_STAT 2
 #define IPC_INFO 3
 
 #define IPC_PRIVATE ((key_t) 0)
index be6afc34fb7ff66f2a5a4af623605ddccca9d84b..db5c62a42f5934170e8ee6a1c188473a6f5ec2ba 100644 (file)
@@ -25,9 +25,9 @@ typedef unsigned long msglen_t;
 #define MSG_NOERROR 010000
 #define MSG_EXCEPT  020000
 
-#define MSG_STAT 11
+#define MSG_STAT (11 | (IPC_STAT & 0x100))
 #define MSG_INFO 12
-#define MSG_STAT_ANY 13
+#define MSG_STAT_ANY (13 | (IPC_STAT & 0x100))
 
 struct msginfo {
        int msgpool, msgmap, msgmax, msgmnb, msgmni, msgssz, msgtql;
index 61cdb83d3fb3ec33c089a67d82d3908ccf3957f5..410c877446b929b6b1c4f0eaaccfe71a7c0a036e 100644 (file)
@@ -31,9 +31,9 @@ extern "C" {
 
 #define _SEM_SEMUN_UNDEFINED 1
 
-#define SEM_STAT 18
+#define SEM_STAT (18 | (IPC_STAT & 0x100))
 #define SEM_INFO 19
-#define SEM_STAT_ANY 20
+#define SEM_STAT_ANY (20 | (IPC_STAT & 0x100))
 
 struct  seminfo {
        int semmap;
index 8ef4e8f2f958f24329c2693888f14a6568e90eb2..fd708cab1eb8c2e22eaf6bf300d8234e5002d770 100644 (file)
@@ -33,9 +33,9 @@ extern "C" {
 
 #define SHM_LOCK 11
 #define SHM_UNLOCK 12
-#define SHM_STAT 13
+#define SHM_STAT (13 | (IPC_STAT & 0x100))
 #define SHM_INFO 14
-#define SHM_STAT_ANY 15
+#define SHM_STAT_ANY (15 | (IPC_STAT & 0x100))
 #define SHM_DEST 01000
 #define SHM_LOCKED 02000
 #define SHM_HUGETLB 04000
index 302e536a2fb9b672602fd320a6e591b8299a8a21..c6fe070bbbf3a02a6b22f80c2c3912950e8a3123 100644 (file)
@@ -245,6 +245,7 @@ int execvpe(const char *, char *const [], char *const []);
 int issetugid(void);
 #endif
 int getentropy(void *, size_t);
+extern int optreset;
 #endif
 
 #ifdef _GNU_SOURCE
@@ -264,6 +265,7 @@ int syncfs(int);
 #ifdef __wasilibc_unmodified_upstream /* WASI has no eaccess */
 int euidaccess(const char *, int);
 int eaccess(const char *, int);
+ssize_t copy_file_range(int, off_t *, int, off_t *, size_t, unsigned);
 #endif
 #endif
 
index d1edb131f7a8e57e1239d325a9149fb148d45e98..7ac0bf7552bc2aac596ec6ffb24f23217714202a 100644 (file)
@@ -283,12 +283,16 @@ static Sym *gnu_lookup_filtered(uint32_t h1, uint32_t *hashtab, struct dso *dso,
 #define ARCH_SYM_REJECT_UND(s) 0
 #endif
 
-static struct symdef find_sym(struct dso *dso, const char *s, int need_def)
+#if defined(__GNUC__)
+__attribute__((always_inline))
+#endif
+static inline struct symdef find_sym2(struct dso *dso, const char *s, int need_def, int use_deps)
 {
        uint32_t h = 0, gh = gnu_hash(s), gho = gh / (8*sizeof(size_t)), *ght;
        size_t ghm = 1ul << gh % (8*sizeof(size_t));
        struct symdef def = {0};
-       for (; dso; dso=dso->syms_next) {
+       struct dso **deps = use_deps ? dso->deps : 0;
+       for (; dso; dso=use_deps ? *deps++ : dso->syms_next) {
                Sym *sym;
                if ((ght = dso->ghashtab)) {
                        sym = gnu_lookup_filtered(gh, ght, dso, s, gho, ghm);
@@ -313,6 +317,11 @@ static struct symdef find_sym(struct dso *dso, const char *s, int need_def)
        return def;
 }
 
+static struct symdef find_sym(struct dso *dso, const char *s, int need_def)
+{
+       return find_sym2(dso, s, need_def, 0);
+}
+
 static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stride)
 {
        unsigned char *base = dso->base;
@@ -363,7 +372,7 @@ static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stri
                        sym = syms + sym_index;
                        name = strings + sym->st_name;
                        ctx = type==REL_COPY ? head->syms_next : head;
-                       def = (sym->st_info&0xf) == STT_SECTION
+                       def = (sym->st_info>>4) == STB_LOCAL
                                ? (struct symdef){ .dso = dso, .sym = sym }
                                : find_sym(ctx, name, type==REL_PLT);
                        if (!def.sym && (sym->st_shndx != SHN_UNDEF
@@ -390,7 +399,7 @@ static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stri
                tls_val = def.sym ? def.sym->st_value : 0;
 
                if ((type == REL_TPOFF || type == REL_TPOFF_NEG)
-                   && runtime && def.dso->tls_id > static_tls_cnt) {
+                   && def.dso->tls_id > static_tls_cnt) {
                        error("Error relocating %s: %s: initial-exec TLS "
                                "resolves to dynamic definition in %s",
                                dso->name, name, def.dso->name);
@@ -407,6 +416,9 @@ static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stri
                case REL_PLT:
                        *reloc_addr = sym_val + addend;
                        break;
+               case REL_USYMBOLIC:
+                       memcpy(reloc_addr, &(size_t){sym_val + addend}, sizeof(size_t));
+                       break;
                case REL_RELATIVE:
                        *reloc_addr = (size_t)base + addend;
                        break;
@@ -450,7 +462,7 @@ static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stri
 #endif
                case REL_TLSDESC:
                        if (stride<3) addend = reloc_addr[1];
-                       if (runtime && def.dso->tls_id > static_tls_cnt) {
+                       if (def.dso->tls_id > static_tls_cnt) {
                                struct td_index *new = malloc(sizeof *new);
                                if (!new) {
                                        error(
@@ -1874,19 +1886,28 @@ void __dls3(size_t *sp)
         * code can see to perform. */
        main_ctor_queue = queue_ctors(&app);
 
-       /* The main program must be relocated LAST since it may contin
-        * copy relocations which depend on libraries' relocations. */
-       reloc_all(app.next);
-       reloc_all(&app);
-
+       /* Initial TLS must also be allocated before final relocations
+        * might result in calloc being a call to application code. */
        update_tls_size();
+       void *initial_tls = builtin_tls;
        if (libc.tls_size > sizeof builtin_tls || tls_align > MIN_TLS_ALIGN) {
-               void *initial_tls = calloc(libc.tls_size, 1);
+               initial_tls = calloc(libc.tls_size, 1);
                if (!initial_tls) {
                        dprintf(2, "%s: Error getting %zu bytes thread-local storage: %m\n",
                                argv[0], libc.tls_size);
                        _exit(127);
                }
+       }
+       static_tls_cnt = tls_cnt;
+
+       /* The main program must be relocated LAST since it may contain
+        * copy relocations which depend on libraries' relocations. */
+       reloc_all(app.next);
+       reloc_all(&app);
+
+       /* Actual copying to new TLS needs to happen after relocations,
+        * since the TLS images might have contained relocated addresses. */
+       if (initial_tls != builtin_tls) {
                if (__init_tp(__copy_tls(initial_tls)) < 0) {
                        a_crash();
                }
@@ -1900,7 +1921,6 @@ void __dls3(size_t *sp)
                if (__copy_tls((void*)builtin_tls) != self) a_crash();
                libc.tls_size = tmp_tls_size;
        }
-       static_tls_cnt = tls_cnt;
 
        if (ldso_fail) _exit(127);
        if (ldd_mode) _exit(0);
@@ -2118,58 +2138,27 @@ static void *addr2dso(size_t a)
 
 static void *do_dlsym(struct dso *p, const char *s, void *ra)
 {
-       size_t i;
-       uint32_t h = 0, gh = 0, *ght;
-       Sym *sym;
-       if (p == head || p == RTLD_DEFAULT || p == RTLD_NEXT) {
-               if (p == RTLD_DEFAULT) {
-                       p = head;
-               } else if (p == RTLD_NEXT) {
-                       p = addr2dso((size_t)ra);
-                       if (!p) p=head;
-                       p = p->next;
-               }
-               struct symdef def = find_sym(p, s, 0);
-               if (!def.sym) goto failed;
-               if ((def.sym->st_info&0xf) == STT_TLS)
-                       return __tls_get_addr((tls_mod_off_t []){def.dso->tls_id, def.sym->st_value-DTP_OFFSET});
-               if (DL_FDPIC && (def.sym->st_info&0xf) == STT_FUNC)
-                       return def.dso->funcdescs + (def.sym - def.dso->syms);
-               return laddr(def.dso, def.sym->st_value);
-       }
-       if (__dl_invalid_handle(p))
+       int use_deps = 0;
+       if (p == head || p == RTLD_DEFAULT) {
+               p = head;
+       } else if (p == RTLD_NEXT) {
+               p = addr2dso((size_t)ra);
+               if (!p) p=head;
+               p = p->next;
+       } else if (__dl_invalid_handle(p)) {
                return 0;
-       if ((ght = p->ghashtab)) {
-               gh = gnu_hash(s);
-               sym = gnu_lookup(gh, ght, p, s);
-       } else {
-               h = sysv_hash(s);
-               sym = sysv_lookup(s, h, p);
-       }
-       if (sym && (sym->st_info&0xf) == STT_TLS)
-               return __tls_get_addr((tls_mod_off_t []){p->tls_id, sym->st_value-DTP_OFFSET});
-       if (DL_FDPIC && sym && sym->st_shndx && (sym->st_info&0xf) == STT_FUNC)
-               return p->funcdescs + (sym - p->syms);
-       if (sym && sym->st_value && (1<<(sym->st_info&0xf) & OK_TYPES))
-               return laddr(p, sym->st_value);
-       for (i=0; p->deps[i]; i++) {
-               if ((ght = p->deps[i]->ghashtab)) {
-                       if (!gh) gh = gnu_hash(s);
-                       sym = gnu_lookup(gh, ght, p->deps[i], s);
-               } else {
-                       if (!h) h = sysv_hash(s);
-                       sym = sysv_lookup(s, h, p->deps[i]);
-               }
-               if (sym && (sym->st_info&0xf) == STT_TLS)
-                       return __tls_get_addr((tls_mod_off_t []){p->deps[i]->tls_id, sym->st_value-DTP_OFFSET});
-               if (DL_FDPIC && sym && sym->st_shndx && (sym->st_info&0xf) == STT_FUNC)
-                       return p->deps[i]->funcdescs + (sym - p->deps[i]->syms);
-               if (sym && sym->st_value && (1<<(sym->st_info&0xf) & OK_TYPES))
-                       return laddr(p->deps[i], sym->st_value);
-       }
-failed:
-       error("Symbol not found: %s", s);
-       return 0;
+       } else
+               use_deps = 1;
+       struct symdef def = find_sym2(p, s, 0, use_deps);
+       if (!def.sym) {
+               error("Symbol not found: %s", s);
+               return 0;
+       }
+       if ((def.sym->st_info&0xf) == STT_TLS)
+               return __tls_get_addr((tls_mod_off_t []){def.dso->tls_id, def.sym->st_value-DTP_OFFSET});
+       if (DL_FDPIC && (def.sym->st_info&0xf) == STT_FUNC)
+               return def.dso->funcdescs + (def.sym - def.dso->syms);
+       return laddr(def.dso, def.sym->st_value);
 }
 
 int dladdr(const void *addr_arg, Dl_info *info)
index b960ba1066a655a055a60f00ed1bccd11a5fcd21..058b62aee953418116c863df60b41181817146f7 100644 (file)
@@ -10,7 +10,7 @@ long fpathconf(int fd, int name)
                [_PC_MAX_INPUT] = _POSIX_MAX_INPUT,
                [_PC_NAME_MAX] = NAME_MAX,
                [_PC_PATH_MAX] = PATH_MAX,
-#ifdef __wasilibc_unmodified_upstream /* WASI has no pipes */
+#ifdef __wasilibc_unmodified_upstream // WASI has no pipes
                [_PC_PIPE_BUF] = PIPE_BUF,
 #else
                [_PC_PIPE_BUF] = -1,
diff --git a/libc-top-half/musl/src/env/secure_getenv.c b/libc-top-half/musl/src/env/secure_getenv.c
new file mode 100644 (file)
index 0000000..72322f8
--- /dev/null
@@ -0,0 +1,8 @@
+#define _GNU_SOURCE
+#include <stdlib.h>
+#include "libc.h"
+
+char *secure_getenv(const char *name)
+{
+       return libc.secure ? NULL : getenv(name);
+}
index 24c87973a38a3c990f70903ffaa03d50ef22ff7c..cbabde476790e755cb85210b0194c320256ed027 100644 (file)
@@ -4,6 +4,7 @@
 #include "../../include/time.h"
 
 hidden int __clock_gettime(clockid_t, struct timespec *);
+hidden int __clock_nanosleep(clockid_t, int, const struct timespec *, struct timespec *);
 
 hidden char *__asctime_r(const struct tm *, char *);
 hidden struct tm *__gmtime_r(const time_t *restrict, struct tm *restrict);
index 6deb1bcc16caae974ee5229abbd6ea3b940c55a7..1b4605c7c6a6d3461e293985797dfd95aa13a49a 100644 (file)
@@ -9,5 +9,6 @@ hidden int __dup3(int, int, int);
 hidden int __mkostemps(char *, int, int);
 hidden int __execvpe(const char *, char *const *, char *const *);
 hidden int __aio_close(int);
+hidden off_t __lseek(int, off_t, int);
 
 #endif
index 165bbedbb8d0d5c8245f56d7b42fa426c7a512d1..ffd06b0471b9855691cc70c40486313c09d7da7c 100644 (file)
@@ -28,6 +28,7 @@ typedef Elf64_Sym Sym;
 enum {
        REL_NONE = 0,
        REL_SYMBOLIC = -100,
+       REL_USYMBOLIC,
        REL_GOT,
        REL_PLT,
        REL_RELATIVE,
index 7fd0060b20c4d56fb21498161d63b97a5047333c..0fbea302dd05113115a8284915e16b28bafe6829 100644 (file)
@@ -332,7 +332,7 @@ static long double decfloat(FILE *f, int c, int bits, int emin, int sign, int po
        y -= bias;
 
        if ((e2+LDBL_MANT_DIG & INT_MAX) > emax-5) {
-               if (fabs(y) >= CONCAT(0x1p, LDBL_MANT_DIG)) {
+               if (fabsl(y) >= CONCAT(0x1p, LDBL_MANT_DIG)) {
                        if (denormal && bits==LDBL_MANT_DIG+e2-emin)
                                denormal = 0;
                        y *= 0.5;
index 9b001421200f59a0e276972ad7d40302583469b6..5742dfc55cb979a225dc6e12aaf784807da7eb12 100644 (file)
@@ -125,7 +125,6 @@ struct __timer {
         0x80000000 })
 
 void *__tls_get_addr(tls_mod_off_t *);
-hidden void *__tls_get_new(tls_mod_off_t *);
 hidden int __init_tp(void *);
 hidden void *__copy_tls(unsigned char *);
 hidden void __reset_tls();
index 69f019cd8d04407cfb9d831f065f0188117245fa..9f2784dbafea868dd3f4eb8a69b2ad81d32cc0c8 100644 (file)
@@ -43,8 +43,8 @@ hidden long __syscall_ret(unsigned long),
 #define __syscall(...) __SYSCALL_DISP(__syscall,__VA_ARGS__)
 #define syscall(...) __syscall_ret(__syscall(__VA_ARGS__))
 
-#define socketcall __socketcall
-#define socketcall_cp __socketcall_cp
+#define socketcall(nm,a,b,c,d,e,f) __syscall_ret(__socketcall(nm,a,b,c,d,e,f))
+#define socketcall_cp(nm,a,b,c,d,e,f) __syscall_ret(__socketcall_cp(nm,a,b,c,d,e,f))
 
 #define __syscall_cp0(n) (__syscall_cp)(n,0,0,0,0,0,0)
 #define __syscall_cp1(n,a) (__syscall_cp)(n,__scc(a),0,0,0,0,0)
@@ -58,12 +58,12 @@ hidden long __syscall_ret(unsigned long),
 #define syscall_cp(...) __syscall_ret(__syscall_cp(__VA_ARGS__))
 
 #ifndef SYSCALL_USE_SOCKETCALL
-#define __socketcall(nm,a,b,c,d,e,f) syscall(SYS_##nm, a, b, c, d, e, f)
-#define __socketcall_cp(nm,a,b,c,d,e,f) syscall_cp(SYS_##nm, a, b, c, d, e, f)
+#define __socketcall(nm,a,b,c,d,e,f) __syscall(SYS_##nm, a, b, c, d, e, f)
+#define __socketcall_cp(nm,a,b,c,d,e,f) __syscall_cp(SYS_##nm, a, b, c, d, e, f)
 #else
-#define __socketcall(nm,a,b,c,d,e,f) syscall(SYS_socketcall, __SC_##nm, \
+#define __socketcall(nm,a,b,c,d,e,f) __syscall(SYS_socketcall, __SC_##nm, \
     ((long [6]){ (long)a, (long)b, (long)c, (long)d, (long)e, (long)f }))
-#define __socketcall_cp(nm,a,b,c,d,e,f) syscall_cp(SYS_socketcall, __SC_##nm, \
+#define __socketcall_cp(nm,a,b,c,d,e,f) __syscall_cp(SYS_socketcall, __SC_##nm, \
     ((long [6]){ (long)a, (long)b, (long)c, (long)d, (long)e, (long)f }))
 #endif
 
@@ -193,6 +193,89 @@ hidden long __syscall_ret(unsigned long),
 #define SYS_sendfile SYS_sendfile64
 #endif
 
+
+/* Ensure that the plain syscall names are defined even for "time64-only"
+ * archs. These facilitate callers passing null time arguments, and make
+ * tests for establishing which to use/fallback-to more consistent when
+ * they do need to be called with time arguments. */
+
+#ifndef SYS_clock_gettime
+#define SYS_clock_gettime SYS_clock_gettime64
+#endif
+
+#ifndef SYS_clock_settime
+#define SYS_clock_settime SYS_clock_settime64
+#endif
+
+#ifndef SYS_clock_adjtime
+#define SYS_clock_adjtime SYS_clock_adjtime64
+#endif
+
+#ifndef SYS_clock_getres
+#define SYS_clock_getres SYS_clock_getres_time64
+#endif
+
+#ifndef SYS_clock_nanosleep
+#define SYS_clock_nanosleep SYS_clock_nanosleep_time64
+#endif
+
+#ifndef SYS_timer_gettime
+#define SYS_timer_gettime SYS_timer_gettime64
+#endif
+
+#ifndef SYS_timer_settime
+#define SYS_timer_settime SYS_timer_settime64
+#endif
+
+#ifndef SYS_timerfd_gettime
+#define SYS_timerfd_gettime SYS_timerfd_gettime64
+#endif
+
+#ifndef SYS_timerfd_settime
+#define SYS_timerfd_settime SYS_timerfd_settime64
+#endif
+
+#ifndef SYS_utimensat
+#define SYS_utimensat SYS_utimensat_time64
+#endif
+
+#ifndef SYS_pselect6
+#define SYS_pselect6 SYS_pselect6_time64
+#endif
+
+#ifndef SYS_ppoll
+#define SYS_ppoll SYS_ppoll_time64
+#endif
+
+#ifndef SYS_recvmmsg
+#define SYS_recvmmsg SYS_recvmmsg_time64
+#endif
+
+#ifndef SYS_mq_timedsend
+#define SYS_mq_timedsend SYS_mq_timedsend_time64
+#endif
+
+#ifndef SYS_mq_timedreceive
+#define SYS_mq_timedreceive SYS_mq_timedreceive_time64
+#endif
+
+/* SYS_semtimedop omitted because SYS_ipc may provide it */
+
+#ifndef SYS_rt_sigtimedwait
+#define SYS_rt_sigtimedwait SYS_rt_sigtimedwait_time64
+#endif
+
+#ifndef SYS_futex
+#define SYS_futex SYS_futex_time64
+#endif
+
+#ifndef SYS_sched_rr_get_interval
+#define SYS_sched_rr_get_interval SYS_sched_rr_get_interval_time64
+#endif
+
+
+
+
 /* socketcall calls */
 
 #define __SC_socket      1
@@ -216,6 +299,20 @@ hidden long __syscall_ret(unsigned long),
 #define __SC_recvmmsg    19
 #define __SC_sendmmsg    20
 
+#ifndef SO_RCVTIMEO_OLD
+#define SO_RCVTIMEO_OLD  20
+#endif
+#ifndef SO_SNDTIMEO_OLD
+#define SO_SNDTIMEO_OLD  21
+#endif
+
+#ifndef SIOCGSTAMP_OLD
+#define SIOCGSTAMP_OLD 0x8906
+#endif
+#ifndef SIOCGSTAMPNS_OLD
+#define SIOCGSTAMPNS_OLD 0x8907
+#endif
+
 #ifdef SYS_open
 #define __sys_open2(x,pn,fl) __syscall2(SYS_open, pn, (fl)|O_LARGEFILE)
 #define __sys_open3(x,pn,fl,mo) __syscall3(SYS_open, pn, (fl)|O_LARGEFILE, mo)
index 30ab939ad6b9a2c4e4c9ebca7ec8cf3c6fc3cc38..746a905c986a02a4bca7f9dbd0db2c87e9f9c952 100644 (file)
@@ -1,3 +1,5 @@
+#include "syscall.h"
+
 #define IPCOP_semop      1
 #define IPCOP_semget     2
 #define IPCOP_semctl     3
 #define IPCOP_shmdt     22
 #define IPCOP_shmget    23
 #define IPCOP_shmctl    24
+
+#ifndef IPC_64
+#define IPC_64 0x100
+#endif
+
+#define IPC_TIME64 (IPC_STAT & 0x100)
+
+#define IPC_CMD(cmd) (((cmd) & ~IPC_TIME64) | IPC_64)
+
+#define IPC_HILO(b,t) ((b)->t = (b)->__##t##_lo | 0LL+(b)->__##t##_hi<<32)
index 868197f61738ed9ead09929be86197926ae492ad..b043041a565a1c21bab03b616afb79c4e2a84e0d 100644 (file)
@@ -18,17 +18,24 @@ int msgctl(int q, int cmd, struct msqid_ds *buf)
        }
 #endif
 #ifndef SYS_ipc
-       int r = __syscall(SYS_msgctl, q, cmd | IPC_64, buf);
+       int r = __syscall(SYS_msgctl, q, IPC_CMD(cmd), buf);
 #else
-       int r = __syscall(SYS_ipc, IPCOP_msgctl, q, cmd | IPC_64, 0, buf, 0);
+       int r = __syscall(SYS_ipc, IPCOP_msgctl, q, IPC_CMD(cmd), 0, buf, 0);
 #endif
 #ifdef SYSCALL_IPC_BROKEN_MODE
-       if (r >= 0) switch (cmd) {
+       if (r >= 0) switch (cmd | IPC_TIME64) {
        case IPC_STAT:
        case MSG_STAT:
        case MSG_STAT_ANY:
                buf->msg_perm.mode >>= 16;
        }
+#endif
+#if IPC_TIME64
+       if (r >= 0 && (cmd&IPC_TIME64)) {
+               IPC_HILO(buf, msg_stime);
+               IPC_HILO(buf, msg_rtime);
+               IPC_HILO(buf, msg_ctime);
+       }
 #endif
        return __syscall_ret(r);
 }
index ce1fb164fa8114bee5511c554b12ab0edd557aa3..ed9827477aee81c032a0c7d29c9c8595ca64eed8 100644 (file)
@@ -18,9 +18,12 @@ int semctl(int id, int num, int cmd, ...)
 {
        union semun arg = {0};
        va_list ap;
-       switch (cmd) {
-       case SETVAL: case GETALL: case SETALL: case IPC_STAT: case IPC_SET:
-       case IPC_INFO: case SEM_INFO: case SEM_STAT:
+       switch (cmd & ~IPC_TIME64) {
+       case SETVAL: case GETALL: case SETALL: case IPC_SET:
+       case IPC_INFO: case SEM_INFO:
+       case IPC_STAT & ~IPC_TIME64:
+       case SEM_STAT & ~IPC_TIME64:
+       case SEM_STAT_ANY & ~IPC_TIME64:
                va_start(ap, cmd);
                arg = va_arg(ap, union semun);
                va_end(ap);
@@ -34,17 +37,23 @@ int semctl(int id, int num, int cmd, ...)
        }
 #endif
 #ifndef SYS_ipc
-       int r = __syscall(SYS_semctl, id, num, cmd | IPC_64, arg.buf);
+       int r = __syscall(SYS_semctl, id, num, IPC_CMD(cmd), arg.buf);
 #else
-       int r = __syscall(SYS_ipc, IPCOP_semctl, id, num, cmd | IPC_64, &arg.buf);
+       int r = __syscall(SYS_ipc, IPCOP_semctl, id, num, IPC_CMD(cmd), &arg.buf);
 #endif
 #ifdef SYSCALL_IPC_BROKEN_MODE
-       if (r >= 0) switch (cmd) {
+       if (r >= 0) switch (cmd | IPC_TIME64) {
        case IPC_STAT:
        case SEM_STAT:
        case SEM_STAT_ANY:
                arg.buf->sem_perm.mode >>= 16;
        }
+#endif
+#if IPC_TIME64
+       if (r >= 0 && (cmd&IPC_TIME64)) {
+               IPC_HILO(arg.buf, sem_otime);
+               IPC_HILO(arg.buf, sem_ctime);
+       }
 #endif
        return __syscall_ret(r);
 }
index 51e70805314f196238ce29e979f0061df2287d04..1632e7b03f38ad6a2bb43c1ec890bc195f4367d2 100644 (file)
@@ -1,13 +1,35 @@
 #define _GNU_SOURCE
 #include <sys/sem.h>
+#include <errno.h>
 #include "syscall.h"
 #include "ipc.h"
 
+#define IS32BIT(x) !((x)+0x80000000ULL>>32)
+#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63))
+
+#if !defined(SYS_semtimedop) && !defined(SYS_ipc)
+#define NO_TIME32 1
+#else
+#define NO_TIME32 0
+#endif
+
 int semtimedop(int id, struct sembuf *buf, size_t n, const struct timespec *ts)
 {
-#ifndef SYS_ipc
+#ifdef SYS_semtimedop_time64
+       time_t s = ts ? ts->tv_sec : 0;
+       long ns = ts ? ts->tv_nsec : 0;
+       int r = -ENOSYS;
+       if (NO_TIME32 || !IS32BIT(s))
+               r = __syscall(SYS_semtimedop_time64, id, buf, n,
+                       ts ? ((long long[]){s, ns}) : 0);
+       if (NO_TIME32 || r!=-ENOSYS) return __syscall_ret(r);
+       ts = ts ? (void *)(long[]){CLAMP(s), ns} : 0;
+#endif
+#if defined(SYS_ipc)
+       return syscall(SYS_ipc, IPCOP_semtimedop, id, n, 0, buf, ts);
+#elif defined(SYS_semtimedop)
        return syscall(SYS_semtimedop, id, buf, n, ts);
 #else
-       return syscall(SYS_ipc, IPCOP_semtimedop, id, n, 0, buf, ts);
+       return __syscall_ret(-ENOSYS);
 #endif
 }
index c2b2bb0d4c44fe68e9b2b4f5797e06573f0f2cd3..de3ce9d4d7d9f2cb1b15a5e9c29a33ce7c3716e8 100644 (file)
@@ -18,17 +18,24 @@ int shmctl(int id, int cmd, struct shmid_ds *buf)
        }
 #endif
 #ifndef SYS_ipc
-       int r = __syscall(SYS_shmctl, id, cmd | IPC_64, buf);
+       int r = __syscall(SYS_shmctl, id, IPC_CMD(cmd), buf);
 #else
-       int r = __syscall(SYS_ipc, IPCOP_shmctl, id, cmd | IPC_64, 0, buf, 0);
+       int r = __syscall(SYS_ipc, IPCOP_shmctl, id, IPC_CMD(cmd), 0, buf, 0);
 #endif
 #ifdef SYSCALL_IPC_BROKEN_MODE
-       if (r >= 0) switch (cmd) {
+       if (r >= 0) switch (cmd | IPC_TIME64) {
        case IPC_STAT:
        case SHM_STAT:
        case SHM_STAT_ANY:
                buf->shm_perm.mode >>= 16;
        }
+#endif
+#if IPC_TIME64
+       if (r >= 0 && (cmd&IPC_TIME64)) {
+               IPC_HILO(buf, shm_atime);
+               IPC_HILO(buf, shm_dtime);
+               IPC_HILO(buf, shm_ctime);
+       }
 #endif
        return __syscall_ret(r);
 }
index 04d97e730431a957dab6c2bbc7dfa0242265c20e..c6c685b3d7f03eedf0b1cdb25beb148a64ce455f 100644 (file)
@@ -9,15 +9,11 @@ __tlsdesc_static:
        ldr x0,[x0,#8]
        ret
 
-.hidden __tls_get_new
-
 // size_t __tlsdesc_dynamic(size_t *a)
 // {
 //     struct {size_t modidx,off;} *p = (void*)a[1];
 //     size_t *dtv = *(size_t**)(tp - 8);
-//     if (p->modidx <= dtv[0])
-//             return dtv[p->modidx] + p->off - tp;
-//     return __tls_get_new(p) - tp;
+//     return dtv[p->modidx] + p->off - tp;
 // }
 .global __tlsdesc_dynamic
 .hidden __tlsdesc_dynamic
index 455eac1d58cfcd10716c0ba4a9c78db0d39d9256..3ae133c96b82f233b8a19e8f26349cb3805e3a16 100644 (file)
@@ -8,8 +8,6 @@ __tlsdesc_static:
        ldr r0,[r0]
        bx lr
 
-.hidden __tls_get_new
-
 .global __tlsdesc_dynamic
 .hidden __tlsdesc_dynamic
 .type __tlsdesc_dynamic,%function
@@ -29,8 +27,12 @@ __tlsdesc_dynamic:
 2:
 #if __ARM_ARCH >= 5
        blx r0          // r0 = tp
+#else
+#if __thumb__
+       add lr,pc,#1
 #else
        mov lr,pc
+#endif
        bx r0
 #endif
 #endif
index a5c0100c3f896e956205eaaeaf433503f15ad4e4..32c81766915b8b10c0fe6fa50729ce06a6caa02b 100644 (file)
@@ -6,8 +6,6 @@ __tlsdesc_static:
        mov 4(%eax),%eax
        ret
 
-.hidden __tls_get_new
-
 .global __tlsdesc_dynamic
 .hidden __tlsdesc_dynamic
 .type __tlsdesc_dynamic,@function
index 0151d15c928a8792db44091d23f55d7367a97eea..e08f1d7df589ef1f28beeca61a57c841b86df44a 100644 (file)
@@ -6,8 +6,6 @@ __tlsdesc_static:
        mov 8(%rax),%rax
        ret
 
-.hidden __tls_get_new
-
 .global __tlsdesc_dynamic
 .hidden __tlsdesc_dynamic
 .type __tlsdesc_dynamic,@function
index fa8af9f021773f575989fb34b872699434cfe4cf..5a707f2f217e829127247301896883667f487b5a 100644 (file)
@@ -15,7 +15,7 @@ int adjtime(const struct timeval *in, struct timeval *out)
                tx.offset = in->tv_sec*1000000 + in->tv_usec;
                tx.modes = ADJ_OFFSET_SINGLESHOT;
        }
-       if (syscall(SYS_adjtimex, &tx) < 0) return -1;
+       if (adjtimex(&tx) < 0) return -1;
        if (out) {
                out->tv_sec = tx.offset / 1000000;
                if ((out->tv_usec = tx.offset % 1000000) < 0) {
index 91de6824c32b8dabd48151352a24d254d6ec499c..e9d727cf3af40caf6859a21694ff451148a9b576 100644 (file)
@@ -1,7 +1,7 @@
 #include <sys/timex.h>
-#include "syscall.h"
+#include <time.h>
 
 int adjtimex(struct timex *tx)
 {
-       return syscall(SYS_adjtimex, tx);
+       return clock_adjtime(CLOCK_REALTIME, tx);
 }
index 056ad6d34104cfa35064ea293763a94fffbd0372..2f531397c3309618d28186fdfff3ba368559700b 100644 (file)
@@ -1,7 +1,119 @@
 #include <sys/timex.h>
+#include <time.h>
+#include <errno.h>
 #include "syscall.h"
 
+#define IS32BIT(x) !((x)+0x80000000ULL>>32)
+
+struct ktimex64 {
+       unsigned modes;
+       int :32;
+       long long offset, freq, maxerror, esterror;
+       int status;
+       int :32;
+       long long constant, precision, tolerance;
+       long long time_sec, time_usec;
+       long long tick, ppsfreq, jitter;
+       int shift;
+       int :32;
+       long long stabil, jitcnt, calcnt, errcnt, stbcnt;
+       int tai;
+       int __padding[11];
+};
+
+struct ktimex {
+       unsigned modes;
+       long offset, freq, maxerror, esterror;
+       int status;
+       long constant, precision, tolerance;
+       long time_sec, time_usec;
+       long tick, ppsfreq, jitter;
+       int shift;
+       long stabil, jitcnt, calcnt, errcnt, stbcnt;
+       int tai;
+       int __padding[11];
+};
+
 int clock_adjtime (clockid_t clock_id, struct timex *utx)
 {
+       int r = -ENOSYS;
+#ifdef SYS_clock_adjtime64
+       if (SYS_clock_adjtime == SYS_clock_adjtime64 ||
+           (utx->modes & ADJ_SETOFFSET) && !IS32BIT(utx->time.tv_sec)) {
+               struct ktimex64 ktx = {
+                       .modes = utx->modes,
+                       .offset = utx->offset,
+                       .freq = utx->freq,
+                       .maxerror = utx->maxerror,
+                       .esterror = utx->esterror,
+                       .status = utx->status,
+                       .constant = utx->constant,
+                       .precision = utx->precision,
+                       .tolerance = utx->tolerance,
+                       .time_sec = utx->time.tv_sec,
+                       .time_usec = utx->time.tv_usec,
+                       .tick = utx->tick,
+                       .ppsfreq = utx->ppsfreq,
+                       .jitter = utx->jitter,
+                       .shift = utx->shift,
+                       .stabil = utx->stabil,
+                       .jitcnt = utx->jitcnt,
+                       .calcnt = utx->calcnt,
+                       .errcnt = utx->errcnt,
+                       .stbcnt = utx->stbcnt,
+                       .tai = utx->tai,
+               };
+               r = __syscall(SYS_clock_adjtime, clock_id, &ktx);
+               if (r>=0) {
+                       utx->modes = ktx.modes;
+                       utx->offset = ktx.offset;
+                       utx->freq = ktx.freq;
+                       utx->maxerror = ktx.maxerror;
+                       utx->esterror = ktx.esterror;
+                       utx->status = ktx.status;
+                       utx->constant = ktx.constant;
+                       utx->precision = ktx.precision;
+                       utx->tolerance = ktx.tolerance;
+                       utx->time.tv_sec = ktx.time_sec;
+                       utx->time.tv_usec = ktx.time_usec;
+                       utx->tick = ktx.tick;
+                       utx->ppsfreq = ktx.ppsfreq;
+                       utx->jitter = ktx.jitter;
+                       utx->shift = ktx.shift;
+                       utx->stabil = ktx.stabil;
+                       utx->jitcnt = ktx.jitcnt;
+                       utx->calcnt = ktx.calcnt;
+                       utx->errcnt = ktx.errcnt;
+                       utx->stbcnt = ktx.stbcnt;
+                       utx->tai = ktx.tai;
+               }
+       }
+       if (SYS_clock_adjtime == SYS_clock_adjtime64 || r!=-ENOSYS)
+               return __syscall_ret(r);
+       if ((utx->modes & ADJ_SETOFFSET) && !IS32BIT(utx->time.tv_sec))
+               return __syscall_ret(-ENOTSUP);
+#endif
+       if (sizeof(time_t) > sizeof(long)) {
+               union {
+                       struct timex utx;
+                       struct ktimex ktx;
+               } u = { *utx };
+               u.ktx.time_sec = utx->time.tv_sec;
+               u.ktx.time_usec = utx->time.tv_usec;
+#ifdef SYS_adjtimex
+               if (clock_id==CLOCK_REALTIME) r = __syscall(SYS_adjtimex, &u);
+               else
+#endif
+               r = __syscall(SYS_clock_adjtime, clock_id, &u);
+               if (r>=0) {
+                       *utx = u.utx;
+                       utx->time.tv_sec = u.ktx.time_sec;
+                       utx->time.tv_usec = u.ktx.time_usec;
+               }
+               return __syscall_ret(r);
+       }
+#ifdef SYS_adjtimex
+       if (clock_id==CLOCK_REALTIME) return syscall(SYS_adjtimex, utx);
+#endif
        return syscall(SYS_clock_adjtime, clock_id, utx);
 }
diff --git a/libc-top-half/musl/src/linux/copy_file_range.c b/libc-top-half/musl/src/linux/copy_file_range.c
new file mode 100644 (file)
index 0000000..dd4b133
--- /dev/null
@@ -0,0 +1,8 @@
+#define _GNU_SOURCE
+#include <unistd.h>
+#include "syscall.h"
+
+ssize_t copy_file_range(int fd_in, off_t *off_in, int fd_out, off_t *off_out, size_t len, unsigned flags)
+{
+       return syscall(SYS_copy_file_range, fd_in, off_in, fd_out, off_out, len, flags);
+}
index 9e262477ba93de416a3498f71f6eb2e75a059eec..e614600ab8b721e6b41dc96d589d3365337fbb9a 100644 (file)
@@ -1,10 +1,26 @@
 #define _GNU_SOURCE
 #include <poll.h>
 #include <signal.h>
+#include <errno.h>
 #include "syscall.h"
 
+#define IS32BIT(x) !((x)+0x80000000ULL>>32)
+#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63))
+
 int ppoll(struct pollfd *fds, nfds_t n, const struct timespec *to, const sigset_t *mask)
 {
+       time_t s = to ? to->tv_sec : 0;
+       long ns = to ? to->tv_nsec : 0;
+#ifdef SYS_ppoll_time64
+       int r = -ENOSYS;
+       if (SYS_ppoll == SYS_ppoll_time64 || !IS32BIT(s))
+               r = __syscall_cp(SYS_ppoll_time64, fds, n,
+                       to ? ((long long[]){s, ns}) : 0,
+                       mask, _NSIG/8);
+       if (SYS_ppoll == SYS_ppoll_time64 || r != -ENOSYS)
+               return __syscall_ret(r);
+       s = CLAMP(s);
+#endif
        return syscall_cp(SYS_ppoll, fds, n,
-               to ? (struct timespec []){*to} : 0, mask, _NSIG/8);
+               to ? ((long[]){s, ns}) : 0, mask, _NSIG/8);
 }
index 15c18c637972f4a62a86666f6ad865d626487edf..860fb5de97b006c2d0c2c1e12a1cd6fd3f3a9a1b 100644 (file)
@@ -1,8 +1,13 @@
 #define _BSD_SOURCE
 #include <sys/time.h>
+#include <time.h>
+#include <errno.h>
 #include "syscall.h"
 
 int settimeofday(const struct timeval *tv, const struct timezone *tz)
 {
-       return syscall(SYS_settimeofday, tv, 0);
+       if (!tv) return 0;
+       if (tv->tv_usec >= 1000000ULL) return __syscall_ret(-EINVAL);
+       return clock_settime(CLOCK_REALTIME, &((struct timespec){
+               .tv_sec = tv->tv_sec, .tv_nsec = tv->tv_usec * 1000}));
 }
index 62cc277365fbe09f43fb0ac03a16ee7ef5c62376..5bdfaf16569195231cf0d70e61c9312fe123b7fa 100644 (file)
@@ -1,6 +1,9 @@
 #include <sys/timerfd.h>
+#include <errno.h>
 #include "syscall.h"
 
+#define IS32BIT(x) !((x)+0x80000000ULL>>32)
+
 int timerfd_create(int clockid, int flags)
 {
        return syscall(SYS_timerfd_create, clockid, flags);
@@ -8,10 +11,49 @@ int timerfd_create(int clockid, int flags)
 
 int timerfd_settime(int fd, int flags, const struct itimerspec *new, struct itimerspec *old)
 {
+#ifdef SYS_timerfd_settime64
+       time_t is = new->it_interval.tv_sec, vs = new->it_value.tv_sec;
+       long ins = new->it_interval.tv_nsec, vns = new->it_value.tv_nsec;
+       int r = -ENOSYS;
+       if (SYS_timerfd_settime == SYS_timerfd_settime64
+           || !IS32BIT(is) || !IS32BIT(vs) || (sizeof(time_t)>4 && old))
+               r = __syscall(SYS_timerfd_settime64, fd, flags,
+                       ((long long[]){is, ins, vs, vns}), old);
+       if (SYS_timerfd_settime == SYS_timerfd_settime64 || r!=-ENOSYS)
+               return __syscall_ret(r);
+       if (!IS32BIT(is) || !IS32BIT(vs))
+               return __syscall_ret(-ENOTSUP);
+       long old32[4];
+       r = __syscall(SYS_timerfd_settime, fd, flags,
+               ((long[]){is, ins, vs, vns}), old32);
+       if (!r && old) {
+               old->it_interval.tv_sec = old32[0];
+               old->it_interval.tv_nsec = old32[1];
+               old->it_value.tv_sec = old32[2];
+               old->it_value.tv_nsec = old32[3];
+       }
+       return __syscall_ret(r);
+#endif
        return syscall(SYS_timerfd_settime, fd, flags, new, old);
 }
 
 int timerfd_gettime(int fd, struct itimerspec *cur)
 {
+#ifdef SYS_timerfd_gettime64
+       int r = -ENOSYS;
+       if (sizeof(time_t) > 4)
+               r = __syscall(SYS_timerfd_gettime64, fd, cur);
+       if (SYS_timerfd_gettime == SYS_timerfd_gettime64 || r!=-ENOSYS)
+               return __syscall_ret(r);
+       long cur32[4];
+       r = __syscall(SYS_timerfd_gettime, fd, cur32);
+       if (!r) {
+               cur->it_interval.tv_sec = cur32[0];
+               cur->it_interval.tv_nsec = cur32[1];
+               cur->it_value.tv_sec = cur32[2];
+               cur->it_value.tv_nsec = cur32[3];
+       }
+       return __syscall_ret(r);
+#endif
        return syscall(SYS_timerfd_gettime, fd, cur);
 }
index 02cd3e5c9c7a76a553e950c475e67b2c1e125259..a110246cb78db2a3437673986396da149dc3b556 100644 (file)
@@ -1,6 +1,18 @@
+#define _BSD_SOURCE
 #include <nl_types.h>
+#include <stdint.h>
+#include <endian.h>
+#ifdef __wasilibc_unmodified_upstream // wasi-libc doesn't support catgets yet
+#include <sys/mman.h>
+#endif
+
+#define V(p) be32toh(*(uint32_t *)(p))
 
 int catclose (nl_catd catd)
 {
+#ifdef __wasilibc_unmodified_upstream // wasi-libc doesn't support catgets yet
+       char *map = (char *)catd;
+       munmap(map, V(map+8)+20);
+#endif
        return 0;
 }
index bbee8986fc581ebce93494b2dad7539c37083628..ad0457fdf3e69101fd73ae372959ecdf9558a1ae 100644 (file)
@@ -1,6 +1,44 @@
+#define _BSD_SOURCE
 #include <nl_types.h>
+#include <endian.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <errno.h>
+
+#define V(p) be32toh(*(uint32_t *)(p))
+
+#ifdef __wasilibc_unmodified_upstream // wasi-libc doesn't support catgets yet
+static int cmp(const void *a, const void *b)
+{
+       uint32_t x = V(a), y = V(b);
+       return x<y ? -1 : x>y ? 1 : 0;
+}
+#endif
 
 char *catgets (nl_catd catd, int set_id, int msg_id, const char *s)
 {
+#ifdef __wasilibc_unmodified_upstream // wasi-libc doesn't support catgets yet
+       const char *map = (const char *)catd;
+       uint32_t nsets = V(map+4);
+       const char *sets = map+20;
+       const char *msgs = map+20+V(map+12);
+       const char *strings = map+20+V(map+16);
+       uint32_t set_id_be = htobe32(set_id);
+       uint32_t msg_id_be = htobe32(msg_id);
+       const char *set = bsearch(&set_id_be, sets, nsets, 12, cmp);
+       if (!set) {
+               errno = ENOMSG;
+               return (char *)s;
+       }
+       uint32_t nmsgs = V(set+4);
+       msgs += 12*V(set+8);
+       const char *msg = bsearch(&msg_id_be, msgs, nmsgs, 12, cmp);
+       if (!msg) {
+               errno = ENOMSG;
+               return (char *)s;
+       }
+       return (char *)(strings + V(msg+8));
+#else
        return (char *)s;
+#endif
 }
index 3fbc77178fb24e7c9661f383dccdd9b762387957..c6116b1606c30701b911dec28bc8efd5d262b629 100644 (file)
@@ -1,8 +1,87 @@
+#define _BSD_SOURCE
 #include <nl_types.h>
+#include <string.h>
+#include <stdint.h>
+#include <endian.h>
 #include <errno.h>
+#include <langinfo.h>
+#include <locale.h>
+#ifdef __wasilibc_unmodified_upstream // wasi-libc doesn't support catgets yet
+#include <sys/mman.h>
+#endif
+#include "libc.h"
 
-nl_catd catopen (const char *name, int oflag)
+#define V(p) be32toh(*(uint32_t *)(p))
+
+#ifdef __wasilibc_unmodified_upstream // wasi-libc doesn't support catgets yet
+static nl_catd do_catopen(const char *name)
+{
+       size_t size;
+       const unsigned char *map = __map_file(name, &size);
+       /* Size recorded in the file must match file size; otherwise
+        * the information needed to unmap the file will be lost. */
+       if (!map || V(map) != 0xff88ff89 || 20+V(map+8) != size) {
+               if(map) munmap((void *)map, size);
+               errno = ENOENT;
+               return (nl_catd)-1;
+       }
+       return (nl_catd)map;
+}
+#endif
+
+nl_catd catopen(const char *name, int oflag)
 {
+#ifdef __wasilibc_unmodified_upstream // wasi-libc doesn't support catgets yet
+       nl_catd catd;
+
+       if (strchr(name, '/')) return do_catopen(name);
+
+       char buf[PATH_MAX];
+       size_t i;
+       const char *path, *lang, *p, *z;
+       if (libc.secure || !(path = getenv("NLSPATH"))) {
+               errno = ENOENT;
+               return (nl_catd)-1;
+       }
+       lang = oflag ? nl_langinfo(_NL_LOCALE_NAME(LC_MESSAGES)) : getenv("LANG");
+       if (!lang) lang = "";
+       for (p=path; *p; p=z) {
+               i = 0;
+               z = __strchrnul(p, ':');
+               for (; p<z; p++) {
+                       const char *v;
+                       size_t l;
+                       if (*p!='%') v=p, l=1;
+                       else switch (*++p) {
+                       case 'N': v=name; l=strlen(v); break;
+                       case 'L': v=lang; l=strlen(v); break;
+                       case 'l': v=lang; l=strcspn(v,"_.@"); break;
+                       case 't':
+                               v=__strchrnul(lang,'_');
+                               if (*v) v++;
+                               l=strcspn(v,".@");
+                               break;
+                       case 'c': v="UTF-8"; l=5; break;
+                       case '%': v="%"; l=1; break;
+                       default: v=0;
+                       }
+                       if (!v || l >= sizeof buf - i) {
+                               break;
+                       }
+                       memcpy(buf+i, v, l);
+                       i += l;
+               }
+               if (!*z && (p<z || !i)) break;
+               if (p<z) continue;
+               if (*z) z++;
+               buf[i] = 0;
+               /* Leading : or :: in NLSPATH is same as %N */
+               catd = do_catopen(i ? buf : name);
+               if (catd != (nl_catd)-1) return catd;
+       }
+       errno = ENOENT;
+#else
        errno = EOPNOTSUPP;
+#endif
        return (nl_catd)-1;
 }
index a9f691bff3b16c21e0ab10a75b2243707117b92a..920d967acfd257e0a6ac1a1d17a867cca7e6d4f7 100644 (file)
@@ -7,13 +7,10 @@ asinf:
        cmp $0x01000000,%eax
        jae 1f
                # subnormal x, return x with underflow
-       fnstsw %ax
-       and $16,%ax
-       jnz 2f
        fld %st(0)
        fmul %st(1)
        fstps 4(%esp)
-2:     ret
+       ret
 
 .global asinl
 .type asinl,@function
@@ -30,11 +27,8 @@ asin:
        cmp $0x00200000,%eax
        jae 1f
                # subnormal x, return x with underflow
-       fnstsw %ax
-       and $16,%ax
-       jnz 2f
        fsts 4(%esp)
-2:     ret
+       ret
 1:     fld %st(0)
        fld1
        fsub %st(0),%st(1)
index d73137b28eb545c543338383b0a5bbc8947345a7..a26feae1ff53583f97ccfbbf56a3382fd7dbad03 100644 (file)
@@ -10,8 +10,5 @@ atan:
        fpatan
        ret
                # subnormal x, return x with underflow
-1:     fnstsw %ax
-       and $16,%ax
-       jnz 2f
-       fsts 4(%esp)
-2:     ret
+1:     fsts 4(%esp)
+       ret
index a7d2979b050cbdeec7989b208ad0e55e6ccc7f91..76b95f3176d49904a918e36aad30517ea720cb68 100644 (file)
@@ -10,8 +10,5 @@ atan2:
        cmp $0x00200000,%eax
        jae 1f
                # subnormal x, return x with underflow
-       fnstsw %ax
-       and $16,%ax
-       jnz 1f
        fsts 4(%esp)
 1:     ret
index 14b88ce54a032765360b57512e6a4ec245857008..c9408a9088d076e8a12618b3eeb2d32612d315ff 100644 (file)
@@ -10,9 +10,6 @@ atan2f:
        cmp $0x01000000,%eax
        jae 1f
                # subnormal x, return x with underflow
-       fnstsw %ax
-       and $16,%ax
-       jnz 1f
        fld %st(0)
        fmul %st(1)
        fstps 4(%esp)
index 8caddefa26efc0256e756b4b164def3b317dd148..893beac5066c9d679747fbc486db3599888216fc 100644 (file)
@@ -10,10 +10,7 @@ atanf:
        fpatan
        ret
                # subnormal x, return x with underflow
-1:     fnstsw %ax
-       and $16,%ax
-       jnz 2f
-       fld %st(0)
+1:     fld %st(0)
        fmul %st(1)
        fstps 4(%esp)
-2:     ret
+       ret
index c7aa5b6eaa37a8385ff3998cf5b690884295618d..df87c49728b2f0496921b09db8b6caeaf55441d0 100644 (file)
@@ -7,13 +7,10 @@ expm1f:
        cmp $0x01000000,%eax
        jae 1f
                # subnormal x, return x with underflow
-       fnstsw %ax
-       and $16,%ax
-       jnz 2f
        fld %st(0)
        fmul %st(1)
        fstps 4(%esp)
-2:     ret
+       ret
 
 .global expm1l
 .type expm1l,@function
@@ -30,11 +27,8 @@ expm1:
        cmp $0x00200000,%eax
        jae 1f
                # subnormal x, return x with underflow
-       fnstsw %ax
-       and $16,%ax
-       jnz 2f
        fsts 4(%esp)
-2:     ret
+       ret
 1:     fldl2e
        fmulp
        mov $0xc2820000,%eax
index 6b6929c72800ab35c07bc331995fe1ed2de1ba61..354f391a7e3707dad653269030da52082e5c4f0a 100644 (file)
@@ -16,9 +16,6 @@ log1p:
        fyl2x
        ret
                # subnormal x, return x with underflow
-2:     fnstsw %ax
-       and $16,%ax
-       jnz 1f
-       fsts 4(%esp)
+2:     fsts 4(%esp)
        fstp %st(1)
-1:     ret
+       ret
index c0bcd30f0e6efd46b0b1223d5439097f7bc7febd..4d3484cd3747ad300c8732632e181d8cac716018 100644 (file)
@@ -16,10 +16,7 @@ log1pf:
        fyl2x
        ret
                # subnormal x, return x with underflow
-2:     fnstsw %ax
-       and $16,%ax
-       jnz 1f
-       fxch
+2:     fxch
        fmul %st(1)
        fstps 4(%esp)
-1:     ret
+       ret
index bdca8b7cb82ec8b90ca9619e989dceb253b7ebc9..ddee7a0d9a689c5e062ad6ef2a59ae6c5cad2683 100644 (file)
@@ -1,5 +1,6 @@
 #include <limits.h>
 #include <fenv.h>
+#include <math.h>
 #include "libm.h"
 
 /*
@@ -26,7 +27,18 @@ as a double.
 */
 
 #if LONG_MAX < 1U<<53 && defined(FE_INEXACT)
-long lrint(double x)
+#include <float.h>
+#include <stdint.h>
+#if FLT_EVAL_METHOD==0 || FLT_EVAL_METHOD==1
+#define EPS DBL_EPSILON
+#elif FLT_EVAL_METHOD==2
+#define EPS LDBL_EPSILON
+#endif
+#ifdef __GNUC__
+/* avoid stack frame in lrint */
+__attribute__((noinline))
+#endif
+static long lrint_slow(double x)
 {
        #pragma STDC FENV_ACCESS ON
        int e;
@@ -38,6 +50,20 @@ long lrint(double x)
        /* conversion */
        return x;
 }
+
+long lrint(double x)
+{
+       uint32_t abstop = asuint64(x)>>32 & 0x7fffffff;
+       uint64_t sign = asuint64(x) & (1ULL << 63);
+
+       if (abstop < 0x41dfffff) {
+               /* |x| < 0x7ffffc00, no overflow */
+               double_t toint = asdouble(asuint64(1/EPS) | sign);
+               double_t y = x + toint - toint;
+               return (long)y;
+       }
+       return lrint_slow(x);
+}
 #else
 long lrint(double x)
 {
index b27756738595dc29a8a7f35e7bffa8da64214826..f1f6d76c780cee4b342e9facd441fa1e8d80384f 100644 (file)
@@ -179,7 +179,6 @@ double sqrt(double x)
        ix1 = q1>>1;
        if (q&1)
                ix1 |= sign;
-       ix0 += m << 20;
-       INSERT_WORDS(z, ix0, ix1);
+       INSERT_WORDS(z, ix0 + ((uint32_t)m << 20), ix1);
        return z;
 }
index 28cb4ad3713e6447843631a8d4e686f0f1dfdbb9..d6ace38aa6b49491926c394651826d8f696ebcda 100644 (file)
@@ -78,7 +78,6 @@ float sqrtf(float x)
                }
        }
        ix = (q>>1) + 0x3f000000;
-       ix += m << 23;
-       SET_FLOAT_WORD(z, ix);
+       SET_FLOAT_WORD(z, ix + ((uint32_t)m << 23));
        return z;
 }
index 864d52cdc44d46809f2adf10460b9b4f5f889c7e..c3f6699559b5c97ba8babdcd84cbb5f839d4bfba 100644 (file)
@@ -1,3 +1,4 @@
+#define _BSD_SOURCE
 #include <unistd.h>
 #include <wchar.h>
 #include <string.h>
index 5a41f0e846456e5647500c0da4c23f5b39065dc6..6f31d4bc91cf26a68b9bc799eb2eb0e636b8bce7 100644 (file)
@@ -1,5 +1,8 @@
 #include <sys/ioctl.h>
 #include <stdarg.h>
+#include <errno.h>
+#include <time.h>
+#include <sys/time.h>
 #include "syscall.h"
 
 int ioctl(int fd, int req, ...)
@@ -9,5 +12,25 @@ int ioctl(int fd, int req, ...)
        va_start(ap, req);
        arg = va_arg(ap, void *);
        va_end(ap);
-       return syscall(SYS_ioctl, fd, req, arg);
+       int r = __syscall(SYS_ioctl, fd, req, arg);
+       if (r==-ENOTTY) switch (req) {
+       case SIOCGSTAMP:
+       case SIOCGSTAMPNS:
+               if (SIOCGSTAMP==SIOCGSTAMP_OLD) break;
+               if (req==SIOCGSTAMP) req=SIOCGSTAMP_OLD;
+               if (req==SIOCGSTAMPNS) req=SIOCGSTAMPNS_OLD;
+               long t32[2];
+               r = __syscall(SYS_ioctl, fd, req, t32);
+               if (r<0) break;
+               if (req==SIOCGSTAMP_OLD) {
+                       struct timeval *tv = arg;
+                       tv->tv_sec = t32[0];
+                       tv->tv_usec = t32[1];
+               } else {
+                       struct timespec *ts = arg;
+                       ts->tv_sec = t32[0];
+                       ts->tv_nsec = t32[1];
+               }
+       }
+       return __syscall_ret(r);
 }
index 2cef6a86bff8c99498fe62acbd3411be6e5a45e5..f41b6642f822e4d95edc701a4578ddbefce3ab93 100644 (file)
@@ -1,7 +1,24 @@
 #include <mqueue.h>
+#include <errno.h>
 #include "syscall.h"
 
+#define IS32BIT(x) !((x)+0x80000000ULL>>32)
+#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63))
+
 ssize_t mq_timedreceive(mqd_t mqd, char *restrict msg, size_t len, unsigned *restrict prio, const struct timespec *restrict at)
 {
+#ifdef SYS_mq_timedreceive_time64
+       time_t s = at ? at->tv_sec : 0;
+       long ns = at ? at->tv_nsec : 0;
+       long r = -ENOSYS;
+       if (SYS_mq_timedreceive == SYS_mq_timedreceive_time64 || !IS32BIT(s))
+               r = __syscall_cp(SYS_mq_timedreceive_time64, mqd, msg, len, prio,
+                       at ? ((long long []){at->tv_sec, at->tv_nsec}) : 0);
+       if (SYS_mq_timedreceive == SYS_mq_timedreceive_time64 || r != -ENOSYS)
+               return __syscall_ret(r);
+       return syscall_cp(SYS_mq_timedreceive, mqd, msg, len, prio,
+               at ? ((long[]){CLAMP(s), ns}) : 0);
+#else
        return syscall_cp(SYS_mq_timedreceive, mqd, msg, len, prio, at);
+#endif
 }
index 1c00aa0b28660e0dadc32c4575bfccc00f5fa5c6..56cfcbb833edb9bc8912b08dc23e82108117f47a 100644 (file)
@@ -1,7 +1,24 @@
 #include <mqueue.h>
+#include <errno.h>
 #include "syscall.h"
 
+#define IS32BIT(x) !((x)+0x80000000ULL>>32)
+#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63))
+
 int mq_timedsend(mqd_t mqd, const char *msg, size_t len, unsigned prio, const struct timespec *at)
 {
+#ifdef SYS_mq_timedsend_time64
+       time_t s = at ? at->tv_sec : 0;
+       long ns = at ? at->tv_nsec : 0;
+       long r = -ENOSYS;
+       if (SYS_mq_timedsend == SYS_mq_timedsend_time64 || !IS32BIT(s))
+               r = __syscall_cp(SYS_mq_timedsend_time64, mqd, msg, len, prio,
+                       at ? ((long long []){at->tv_sec, at->tv_nsec}) : 0);
+       if (SYS_mq_timedsend == SYS_mq_timedsend_time64 || r != -ENOSYS)
+               return __syscall_ret(r);
+       return syscall_cp(SYS_mq_timedsend, mqd, msg, len, prio,
+               at ? ((long[]){CLAMP(s), ns}) : 0);
+#else
        return syscall_cp(SYS_mq_timedsend, mqd, msg, len, prio, at);
+#endif
 }
index 0ee8b69cbfda8d90354b5b298f8ba7ce567d2957..9b2f2dfbb023b6db8924bc7081c5c128594c8e1d 100644 (file)
@@ -38,12 +38,15 @@ size_t mbsrtowcs(wchar_t *restrict ws, const char **restrict src, size_t wn, mbs
        }
 
        if (!ws) for (;;) {
+#ifdef __GNUC__
+               typedef uint32_t __attribute__((__may_alias__)) w32;
                if (*s-1u < 0x7f && (uintptr_t)s%4 == 0) {
-                       while (!(( *(uint32_t*)s | *(uint32_t*)s-0x01010101) & 0x80808080)) {
+                       while (!(( *(w32*)s | *(w32*)s-0x01010101) & 0x80808080)) {
                                s += 4;
                                wn -= 4;
                        }
                }
+#endif
                if (*s-1u < 0x7f) {
                        s++;
                        wn--;
@@ -69,8 +72,10 @@ resume0:
                        *src = (const void *)s;
                        return wn0;
                }
+#ifdef __GNUC__
+               typedef uint32_t __attribute__((__may_alias__)) w32;
                if (*s-1u < 0x7f && (uintptr_t)s%4 == 0) {
-                       while (wn>=5 && !(( *(uint32_t*)s | *(uint32_t*)s-0x01010101) & 0x80808080)) {
+                       while (wn>=5 && !(( *(w32*)s | *(w32*)s-0x01010101) & 0x80808080)) {
                                *ws++ = *s++;
                                *ws++ = *s++;
                                *ws++ = *s++;
@@ -78,6 +83,7 @@ resume0:
                                wn -= 4;
                        }
                }
+#endif
                if (*s-1u < 0x7f) {
                        *ws++ = *s++;
                        wn--;
index 28079d8c0cb60a4e4d810a49ca7b0992bc6d4d9f..e871d624b7dc5f836847e0285887138b2704386c 100644 (file)
@@ -1,7 +1,32 @@
 #include <sys/socket.h>
+#include <sys/time.h>
+#include <errno.h>
 #include "syscall.h"
 
 int getsockopt(int fd, int level, int optname, void *restrict optval, socklen_t *restrict optlen)
 {
-       return socketcall(getsockopt, fd, level, optname, optval, optlen, 0);
+       long tv32[2];
+       struct timeval *tv;
+
+       int r = __socketcall(getsockopt, fd, level, optname, optval, optlen, 0);
+
+       if (r==-ENOPROTOOPT) switch (level) {
+       case SOL_SOCKET:
+               switch (optname) {
+               case SO_RCVTIMEO:
+               case SO_SNDTIMEO:
+                       if (SO_RCVTIMEO == SO_RCVTIMEO_OLD) break;
+                       if (*optlen < sizeof *tv) return __syscall_ret(-EINVAL);
+                       if (optname==SO_RCVTIMEO) optname=SO_RCVTIMEO_OLD;
+                       if (optname==SO_SNDTIMEO) optname=SO_SNDTIMEO_OLD;
+                       r = __socketcall(getsockopt, fd, level, optname,
+                               tv32, (socklen_t[]){sizeof tv32}, 0);
+                       if (r<0) break;
+                       tv = optval;
+                       tv->tv_sec = tv32[0];
+                       tv->tv_usec = tv32[1];
+                       *optlen = sizeof *tv;
+               }
+       }
+       return __syscall_ret(r);
 }
index 58b1b2f635bdeba487f361acc9f0cc3a75e018aa..d5dc6b51cb8be7b93a99179734ede4d2ad7362cb 100644 (file)
@@ -1,8 +1,13 @@
 #define _GNU_SOURCE
 #include <sys/socket.h>
 #include <limits.h>
+#include <errno.h>
+#include <time.h>
 #include "syscall.h"
 
+#define IS32BIT(x) !((x)+0x80000000ULL>>32)
+#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63))
+
 int recvmmsg(int fd, struct mmsghdr *msgvec, unsigned int vlen, unsigned int flags, struct timespec *timeout)
 {
 #if LONG_MAX > INT_MAX
@@ -11,5 +16,18 @@ int recvmmsg(int fd, struct mmsghdr *msgvec, unsigned int vlen, unsigned int fla
        for (i = vlen; i; i--, mh++)
                mh->msg_hdr.__pad1 = mh->msg_hdr.__pad2 = 0;
 #endif
+#ifdef SYS_recvmmsg_time64
+       time_t s = timeout ? timeout->tv_sec : 0;
+       long ns = timeout ? timeout->tv_nsec : 0;
+       int r = -ENOSYS;
+       if (SYS_recvmmsg == SYS_recvmmsg_time64 || !IS32BIT(s))
+               r = __syscall_cp(SYS_recvmmsg_time64, fd, msgvec, vlen, flags,
+                       timeout ? ((long long[]){s, ns}) : 0);
+       if (SYS_recvmmsg == SYS_recvmmsg_time64 || r!=-ENOSYS)
+               return __syscall_ret(r);
+       return syscall_cp(SYS_recvmmsg, fd, msgvec, vlen, flags,
+               timeout ? ((long[]){CLAMP(s), ns}) : 0);
+#else
        return syscall_cp(SYS_recvmmsg, fd, msgvec, vlen, flags, timeout);
+#endif
 }
index c960c9ca7de97595042e382ed724e1aa6f0d3e2a..2c188a96e36427122868b76c5b90479f454913b8 100644 (file)
@@ -1,7 +1,37 @@
 #include <sys/socket.h>
+#include <sys/time.h>
+#include <errno.h>
 #include "syscall.h"
 
+#define IS32BIT(x) !((x)+0x80000000ULL>>32)
+#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63))
+
 int setsockopt(int fd, int level, int optname, const void *optval, socklen_t optlen)
 {
-       return socketcall(setsockopt, fd, level, optname, optval, optlen, 0);
+       const struct timeval *tv;
+       time_t s;
+       suseconds_t us;
+
+       int r = __socketcall(setsockopt, fd, level, optname, optval, optlen, 0);
+
+       if (r==-ENOPROTOOPT) switch (level) {
+       case SOL_SOCKET:
+               switch (optname) {
+               case SO_RCVTIMEO:
+               case SO_SNDTIMEO:
+                       if (SO_RCVTIMEO == SO_RCVTIMEO_OLD) break;
+                       if (optlen < sizeof *tv) return __syscall_ret(-EINVAL);
+                       tv = optval;
+                       s = tv->tv_sec;
+                       us = tv->tv_usec;
+                       if (!IS32BIT(s)) return __syscall_ret(-ENOTSUP);
+
+                       if (optname==SO_RCVTIMEO) optname=SO_RCVTIMEO_OLD;
+                       if (optname==SO_SNDTIMEO) optname=SO_SNDTIMEO_OLD;
+
+                       r = __socketcall(setsockopt, fd, level, optname,
+                               ((long[]){s, CLAMP(us)}), 2*sizeof(long), 0);
+               }
+       }
+       return __syscall_ret(r);
 }
index 00b875143afa674eade2f27fc98df08cce8a7133..5adf1443874854c6a7a33c4b641ff18c152a0f38 100644 (file)
@@ -1,6 +1,8 @@
 #define FDOP_CLOSE 1
 #define FDOP_DUP2 2
 #define FDOP_OPEN 3
+#define FDOP_CHDIR 4
+#define FDOP_FCHDIR 5
 
 struct fdop {
        struct fdop *next, *prev;
index 306faa055af0512d06327a4e794bc2697777e5e9..29652197c58cbff007a3251b89a699e69dbbb2f7 100644 (file)
@@ -125,6 +125,14 @@ static int child(void *args_vp)
                                        __syscall(SYS_close, fd);
                                }
                                break;
+                       case FDOP_CHDIR:
+                               ret = __syscall(SYS_chdir, op->path);
+                               if (ret<0) goto fail;
+                               break;
+                       case FDOP_FCHDIR:
+                               ret = __syscall(SYS_fchdir, op->fd);
+                               if (ret<0) goto fail;
+                               break;
                        }
                }
        }
diff --git a/libc-top-half/musl/src/process/posix_spawn_file_actions_addchdir.c b/libc-top-half/musl/src/process/posix_spawn_file_actions_addchdir.c
new file mode 100644 (file)
index 0000000..7f2590a
--- /dev/null
@@ -0,0 +1,18 @@
+#include <spawn.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include "fdop.h"
+
+int posix_spawn_file_actions_addchdir_np(posix_spawn_file_actions_t *restrict fa, const char *restrict path)
+{
+       struct fdop *op = malloc(sizeof *op + strlen(path) + 1);
+       if (!op) return ENOMEM;
+       op->cmd = FDOP_CHDIR;
+       op->fd = -1;
+       strcpy(op->path, path);
+       if ((op->next = fa->__actions)) op->next->prev = op;
+       op->prev = 0;
+       fa->__actions = op;
+       return 0;
+}
diff --git a/libc-top-half/musl/src/process/posix_spawn_file_actions_addfchdir.c b/libc-top-half/musl/src/process/posix_spawn_file_actions_addfchdir.c
new file mode 100644 (file)
index 0000000..436c683
--- /dev/null
@@ -0,0 +1,17 @@
+#include <spawn.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include "fdop.h"
+
+int posix_spawn_file_actions_addfchdir_np(posix_spawn_file_actions_t *fa, int fd)
+{
+       struct fdop *op = malloc(sizeof *op);
+       if (!op) return ENOMEM;
+       op->cmd = FDOP_FCHDIR;
+       op->fd = fd;
+       if ((op->next = fa->__actions)) op->next->prev = op;
+       op->prev = 0;
+       fa->__actions = op;
+       return 0;
+}
index aa1c6a4482ee4424ace4b8a97ba3bb7ec23f9a1f..78063a469a706484e2d0d814c6b6082805d22326 100644 (file)
@@ -8,6 +8,10 @@
 #include <stdlib.h>
 #include <errno.h>
 #include <stddef.h>
+#include <unistd.h>
+#ifdef __wasilibc_unmodified_upstream // WASI has no usernames
+#include <pwd.h>
+#endif
 
 struct match
 {
@@ -90,16 +94,23 @@ static int do_glob(char *buf, size_t pos, int type, char *pat, int flags, int (*
        if (!*pat) {
                /* If we consumed any components above, or if GLOB_MARK is
                 * requested and we don't yet know if the match is a dir,
-                * we must call stat to confirm the file exists and/or
-                * determine its type. */
+                * we must confirm the file exists and/or determine its type.
+                *
+                * If marking dirs, symlink type is inconclusive; we need the
+                * type for the symlink target, and therefore must try stat
+                * first unless type is known not to be a symlink. Otherwise,
+                * or if that fails, use lstat for determining existence to
+                * avoid false negatives in the case of broken symlinks. */
                struct stat st;
-               if ((flags & GLOB_MARK) && type==DT_LNK) type = 0;
-               if (!type && stat(buf, &st)) {
+               if ((flags & GLOB_MARK) && (!type||type==DT_LNK) && !stat(buf, &st)) {
+                       if (S_ISDIR(st.st_mode)) type = DT_DIR;
+                       else type = DT_REG;
+               }
+               if (!type && lstat(buf, &st)) {
                        if (errno!=ENOENT && (errfunc(buf, errno) || (flags & GLOB_ERR)))
                                return GLOB_ABORTED;
                        return 0;
                }
-               if (!type && S_ISDIR(st.st_mode)) type = DT_DIR;
                if (append(tail, buf, pos, (flags & GLOB_MARK) && type==DT_DIR))
                        return GLOB_NOSPACE;
                return 0;
@@ -182,6 +193,41 @@ static int sort(const void *a, const void *b)
        return strcmp(*(const char **)a, *(const char **)b);
 }
 
+#ifdef __wasilibc_unmodified_upstream // WASI has no usernames
+static int expand_tilde(char **pat, char *buf, size_t *pos)
+{
+       char *p = *pat + 1;
+       size_t i = 0;
+
+       char delim, *name_end = __strchrnul(p, '/');
+       if ((delim = *name_end)) *name_end++ = 0;
+       *pat = name_end;
+
+       char *home = *p ? NULL : getenv("HOME");
+       if (!home) {
+               struct passwd pw, *res;
+               switch (*p ? getpwnam_r(p, &pw, buf, PATH_MAX, &res)
+                          : getpwuid_r(getuid(), &pw, buf, PATH_MAX, &res)) {
+               case ENOMEM:
+                       return GLOB_NOSPACE;
+               case 0:
+                       if (!res)
+               default:
+                               return GLOB_NOMATCH;
+               }
+               home = pw.pw_dir;
+       }
+       while (i < PATH_MAX - 2 && *home)
+               buf[i++] = *home++;
+       if (*home)
+               return GLOB_NOMATCH;
+       if ((buf[i] = delim))
+               buf[++i] = 0;
+       *pos = i;
+       return 0;
+}
+#endif
+
 int glob(const char *restrict pat, int flags, int (*errfunc)(const char *path, int err), glob_t *restrict g)
 {
        struct match head = { .next = NULL }, *tail = &head;
@@ -202,7 +248,14 @@ int glob(const char *restrict pat, int flags, int (*errfunc)(const char *path, i
                char *p = strdup(pat);
                if (!p) return GLOB_NOSPACE;
                buf[0] = 0;
-               error = do_glob(buf, 0, 0, p, flags, errfunc, &tail);
+               size_t pos = 0;
+               char *s = p;
+#ifdef __wasilibc_unmodified_upstream // WASI has no usernames
+               if ((flags & (GLOB_TILDE | GLOB_TILDE_CHECK)) && *p == '~')
+                       error = expand_tilde(&s, buf, &pos);
+#endif
+               if (!error)
+                       error = do_glob(buf, pos, 0, s, flags, errfunc, &tail);
                free(p);
        }
 
index 4b01028f5ddaf102fcc37d39e7a4a915069b72bf..33a3d1aeed43bf2860ffa89540b7848c0854fdd4 100644 (file)
@@ -3,5 +3,19 @@
 
 int sched_rr_get_interval(pid_t pid, struct timespec *ts)
 {
+#ifdef SYS_sched_rr_get_interval_time64
+       /* On a 32-bit arch, use the old syscall if it exists. */
+       if (SYS_sched_rr_get_interval != SYS_sched_rr_get_interval_time64) {
+               long ts32[2];
+               int r = __syscall(SYS_sched_rr_get_interval, pid, ts32);
+               if (!r) {
+                       ts->tv_sec = ts32[0];
+                       ts->tv_nsec = ts32[1];
+               }
+               return __syscall_ret(r);
+       }
+#endif
+       /* If reaching this point, it's a 64-bit arch or time64-only
+        * 32-bit arch and we can get result directly into timespec. */
        return syscall(SYS_sched_rr_get_interval, pid, ts);
 }
index 762af37f109343d5400d2c0d1be2c89715a7d879..54cfb291bba2cbf7c73dfb9bea3a77f0f8870d2e 100644 (file)
@@ -1,12 +1,26 @@
 #include <sys/select.h>
 #include <signal.h>
 #include <stdint.h>
+#include <errno.h>
 #include "syscall.h"
 
+#define IS32BIT(x) !((x)+0x80000000ULL>>32)
+#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63))
+
 int pselect(int n, fd_set *restrict rfds, fd_set *restrict wfds, fd_set *restrict efds, const struct timespec *restrict ts, const sigset_t *restrict mask)
 {
        syscall_arg_t data[2] = { (uintptr_t)mask, _NSIG/8 };
-       struct timespec ts_tmp;
-       if (ts) ts_tmp = *ts;
-       return syscall_cp(SYS_pselect6, n, rfds, wfds, efds, ts ? &ts_tmp : 0, data);
+       time_t s = ts ? ts->tv_sec : 0;
+       long ns = ts ? ts->tv_nsec : 0;
+#ifdef SYS_pselect6_time64
+       int r = -ENOSYS;
+       if (SYS_pselect6 == SYS_pselect6_time64 || !IS32BIT(s))
+               r = __syscall_cp(SYS_pselect6_time64, n, rfds, wfds, efds,
+                       ts ? ((long long[]){s, ns}) : 0, data);
+       if (SYS_pselect6 == SYS_pselect6_time64 || r!=-ENOSYS)
+               return __syscall_ret(r);
+       s = CLAMP(s);
+#endif
+       return syscall_cp(SYS_pselect6, n, rfds, wfds, efds,
+               ts ? ((long[]){s, ns}) : 0, data);
 }
index 02fd75c3828aca664bf6d695d82e30003c34619a..8a78688403047d0a1ce8ff3566530ea3722615f9 100644 (file)
@@ -4,22 +4,41 @@
 #include <errno.h>
 #include "syscall.h"
 
+#define IS32BIT(x) !((x)+0x80000000ULL>>32)
+#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63))
+
 int select(int n, fd_set *restrict rfds, fd_set *restrict wfds, fd_set *restrict efds, struct timeval *restrict tv)
 {
+       time_t s = tv ? tv->tv_sec : 0;
+       suseconds_t us = tv ? tv->tv_usec : 0;
+       long ns;
+       const time_t max_time = (1ULL<<8*sizeof(time_t)-1)-1;
+
+       if (s<0 || us<0) return __syscall_ret(-EINVAL);
+       if (us/1000000 > max_time - s) {
+               s = max_time;
+               us = 999999;
+               ns = 999999999;
+       } else {
+               s += us/1000000;
+               us %= 1000000;
+               ns = us*1000;
+       }
+
+#ifdef SYS_pselect6_time64
+       int r = -ENOSYS;
+       if (SYS_pselect6 == SYS_pselect6_time64 || !IS32BIT(s))
+               r = __syscall_cp(SYS_pselect6_time64, n, rfds, wfds, efds,
+                       tv ? ((long long[]){s, ns}) : 0,
+                       ((syscall_arg_t[]){ 0, _NSIG/8 }));
+       if (SYS_pselect6 == SYS_pselect6_time64 || r!=-ENOSYS)
+               return __syscall_ret(r);
+#endif
 #ifdef SYS_select
-       return syscall_cp(SYS_select, n, rfds, wfds, efds, tv);
+       return syscall_cp(SYS_select, n, rfds, wfds, efds,
+               tv ? ((long[]){s, us}) : 0);
 #else
-       syscall_arg_t data[2] = { 0, _NSIG/8 };
-       struct timespec ts;
-       if (tv) {
-               if (tv->tv_sec < 0 || tv->tv_usec < 0)
-                       return __syscall_ret(-EINVAL);
-               time_t extra_secs = tv->tv_usec / 1000000;
-               ts.tv_nsec = tv->tv_usec % 1000000 * 1000;
-               const time_t max_time = (1ULL<<8*sizeof(time_t)-1)-1;
-               ts.tv_sec = extra_secs > max_time - tv->tv_sec ?
-                       max_time : tv->tv_sec + extra_secs;
-       }
-       return syscall_cp(SYS_pselect6, n, rfds, wfds, efds, tv ? &ts : 0, data);
+       return syscall_cp(SYS_pselect6, n, rfds, wfds, efds,
+               tv ? ((long[]){s, ns}) : 0, ((syscall_arg_t[]){ 0, _NSIG/8 }));
 #endif
 }
diff --git a/libc-top-half/musl/src/setjmp/arm/longjmp.S b/libc-top-half/musl/src/setjmp/arm/longjmp.S
new file mode 100644 (file)
index 0000000..8df0b81
--- /dev/null
@@ -0,0 +1,50 @@
+.syntax unified
+.global _longjmp
+.global longjmp
+.type _longjmp,%function
+.type longjmp,%function
+_longjmp:
+longjmp:
+       mov ip,r0
+       movs r0,r1
+       moveq r0,#1
+       ldmia ip!, {v1,v2,v3,v4,v5,v6,sl,fp}
+       ldmia ip!, {r2,lr}
+       mov sp,r2
+
+       adr r1,1f
+       ldr r2,1f
+       ldr r1,[r1,r2]
+
+#if __ARM_ARCH < 8
+       tst r1,#0x260
+       beq 3f
+       // HWCAP_ARM_FPA
+       tst r1,#0x20
+       beq 2f
+       ldc p2, cr4, [ip], #48
+#endif
+2:     tst r1,#0x40
+       beq 2f
+       .fpu vfp
+       vldmia ip!, {d8-d15}
+       .fpu softvfp
+       .eabi_attribute 10, 0
+       .eabi_attribute 27, 0
+#if __ARM_ARCH < 8
+       // HWCAP_ARM_IWMMXT
+2:     tst r1,#0x200
+       beq 3f
+       ldcl p1, cr10, [ip], #8
+       ldcl p1, cr11, [ip], #8
+       ldcl p1, cr12, [ip], #8
+       ldcl p1, cr13, [ip], #8
+       ldcl p1, cr14, [ip], #8
+       ldcl p1, cr15, [ip], #8
+#endif
+2:
+3:     bx lr
+
+.hidden __hwcap
+.align 2
+1:     .word __hwcap-1b
diff --git a/libc-top-half/musl/src/setjmp/arm/longjmp.s b/libc-top-half/musl/src/setjmp/arm/longjmp.s
deleted file mode 100644 (file)
index 76cc292..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-.syntax unified
-.global _longjmp
-.global longjmp
-.type _longjmp,%function
-.type longjmp,%function
-_longjmp:
-longjmp:
-       mov ip,r0
-       movs r0,r1
-       moveq r0,#1
-       ldmia ip!, {v1,v2,v3,v4,v5,v6,sl,fp}
-       ldmia ip!, {r2,lr}
-       mov sp,r2
-
-       adr r1,1f
-       ldr r2,1f
-       ldr r1,[r1,r2]
-
-       tst r1,#0x260
-       beq 3f
-       tst r1,#0x20
-       beq 2f
-       ldc p2, cr4, [ip], #48
-2:     tst r1,#0x40
-       beq 2f
-       .fpu vfp
-       vldmia ip!, {d8-d15}
-       .fpu softvfp
-       .eabi_attribute 10, 0
-       .eabi_attribute 27, 0
-2:     tst r1,#0x200
-       beq 3f
-       ldcl p1, cr10, [ip], #8
-       ldcl p1, cr11, [ip], #8
-       ldcl p1, cr12, [ip], #8
-       ldcl p1, cr13, [ip], #8
-       ldcl p1, cr14, [ip], #8
-       ldcl p1, cr15, [ip], #8
-3:     bx lr
-
-.hidden __hwcap
-.align 2
-1:     .word __hwcap-1b
diff --git a/libc-top-half/musl/src/setjmp/arm/setjmp.S b/libc-top-half/musl/src/setjmp/arm/setjmp.S
new file mode 100644 (file)
index 0000000..45731d2
--- /dev/null
@@ -0,0 +1,52 @@
+.syntax unified
+.global __setjmp
+.global _setjmp
+.global setjmp
+.type __setjmp,%function
+.type _setjmp,%function
+.type setjmp,%function
+__setjmp:
+_setjmp:
+setjmp:
+       mov ip,r0
+       stmia ip!,{v1,v2,v3,v4,v5,v6,sl,fp}
+       mov r2,sp
+       stmia ip!,{r2,lr}
+       mov r0,#0
+
+       adr r1,1f
+       ldr r2,1f
+       ldr r1,[r1,r2]
+
+#if __ARM_ARCH < 8
+       tst r1,#0x260
+       beq 3f
+       // HWCAP_ARM_FPA
+       tst r1,#0x20
+       beq 2f
+       stc p2, cr4, [ip], #48
+#endif
+2:     tst r1,#0x40
+       beq 2f
+       .fpu vfp
+       vstmia ip!, {d8-d15}
+       .fpu softvfp
+       .eabi_attribute 10, 0
+       .eabi_attribute 27, 0
+#if __ARM_ARCH < 8
+       // HWCAP_ARM_IWMMXT
+2:     tst r1,#0x200
+       beq 3f
+       stcl p1, cr10, [ip], #8
+       stcl p1, cr11, [ip], #8
+       stcl p1, cr12, [ip], #8
+       stcl p1, cr13, [ip], #8
+       stcl p1, cr14, [ip], #8
+       stcl p1, cr15, [ip], #8
+#endif
+2:
+3:     bx lr
+
+.hidden __hwcap
+.align 2
+1:     .word __hwcap-1b
diff --git a/libc-top-half/musl/src/setjmp/arm/setjmp.s b/libc-top-half/musl/src/setjmp/arm/setjmp.s
deleted file mode 100644 (file)
index 011315b..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-.syntax unified
-.global __setjmp
-.global _setjmp
-.global setjmp
-.type __setjmp,%function
-.type _setjmp,%function
-.type setjmp,%function
-__setjmp:
-_setjmp:
-setjmp:
-       mov ip,r0
-       stmia ip!,{v1,v2,v3,v4,v5,v6,sl,fp}
-       mov r2,sp
-       stmia ip!,{r2,lr}
-       mov r0,#0
-
-       adr r1,1f
-       ldr r2,1f
-       ldr r1,[r1,r2]
-
-       tst r1,#0x260
-       beq 3f
-       tst r1,#0x20
-       beq 2f
-       stc p2, cr4, [ip], #48
-2:     tst r1,#0x40
-       beq 2f
-       .fpu vfp
-       vstmia ip!, {d8-d15}
-       .fpu softvfp
-       .eabi_attribute 10, 0
-       .eabi_attribute 27, 0
-2:     tst r1,#0x200
-       beq 3f
-       stcl p1, cr10, [ip], #8
-       stcl p1, cr11, [ip], #8
-       stcl p1, cr12, [ip], #8
-       stcl p1, cr13, [ip], #8
-       stcl p1, cr14, [ip], #8
-       stcl p1, cr15, [ip], #8
-3:     bx lr
-
-.hidden __hwcap
-.align 2
-1:     .word __hwcap-1b
index fdb6c95d25609b465b5638d5a63b76a8d03f57c6..ecf408553880754cd599c62b8d4d51e6ba094aa3 100644 (file)
@@ -12,18 +12,12 @@ longjmp:
        addu    $2, $2, 1
 1:
 #ifndef __mips_soft_float
-       lwc1    $20, 56($4)
-       lwc1    $21, 60($4)
-       lwc1    $22, 64($4)
-       lwc1    $23, 68($4)
-       lwc1    $24, 72($4)
-       lwc1    $25, 76($4)
-       lwc1    $26, 80($4)
-       lwc1    $27, 84($4)
-       lwc1    $28, 88($4)
-       lwc1    $29, 92($4)
-       lwc1    $30, 96($4)
-       lwc1    $31, 100($4)
+       l.d     $f20, 56($4)
+       l.d     $f22, 64($4)
+       l.d     $f24, 72($4)
+       l.d     $f26, 80($4)
+       l.d     $f28, 88($4)
+       l.d     $f30, 96($4)
 #endif
        lw      $ra,  0($4)
        lw      $sp,  4($4)
index 501d5264e6b56d99df70134858ad0359993b8e39..7ae8832d516b57fa39e7dcc70987040befedb6d3 100644 (file)
@@ -22,18 +22,12 @@ setjmp:
        sw      $30, 40($4)
        sw      $28, 44($4)
 #ifndef __mips_soft_float
-       swc1    $20, 56($4)
-       swc1    $21, 60($4)
-       swc1    $22, 64($4)
-       swc1    $23, 68($4)
-       swc1    $24, 72($4)
-       swc1    $25, 76($4)
-       swc1    $26, 80($4)
-       swc1    $27, 84($4)
-       swc1    $28, 88($4)
-       swc1    $29, 92($4)
-       swc1    $30, 96($4)
-       swc1    $31, 100($4)
+       s.d     $f20, 56($4)
+       s.d     $f22, 64($4)
+       s.d     $f24, 72($4)
+       s.d     $f26, 80($4)
+       s.d     $f28, 88($4)
+       s.d     $f30, 96($4)
 #endif
        jr      $ra
        li      $2, 0
index 8a8046a76b5c6511b8b8a81614622a39dd6ced97..36d1eb9dc6e991af1ed4b5d0c85b851eb243d697 100644 (file)
@@ -3,5 +3,16 @@
 
 int getitimer(int which, struct itimerval *old)
 {
+       if (sizeof(time_t) > sizeof(long)) {
+               long old32[4];
+               int r = __syscall(SYS_getitimer, which, old32);
+               if (!r) {
+                       old->it_interval.tv_sec = old32[0];
+                       old->it_interval.tv_usec = old32[1];
+                       old->it_value.tv_sec = old32[2];
+                       old->it_value.tv_usec = old32[3];
+               }
+               return __syscall_ret(r);
+       }
        return syscall(SYS_getitimer, which, old);
 }
index 21b1f45da9b7a87a67568e20991d1f4b73188f0a..0dfbeb4db5a7ad65faeac76e6039a11807645f2b 100644 (file)
@@ -1,7 +1,26 @@
 #include <sys/time.h>
+#include <errno.h>
 #include "syscall.h"
 
+#define IS32BIT(x) !((x)+0x80000000ULL>>32)
+
 int setitimer(int which, const struct itimerval *restrict new, struct itimerval *restrict old)
 {
+       if (sizeof(time_t) > sizeof(long)) {
+               time_t is = new->it_interval.tv_sec, vs = new->it_value.tv_sec;
+               long ius = new->it_interval.tv_usec, vus = new->it_value.tv_usec;
+               if (!IS32BIT(is) || !IS32BIT(vs))
+                       return __syscall_ret(-ENOTSUP);
+               long old32[4];
+               int r = __syscall(SYS_setitimer, which,
+                       ((long[]){is, ius, vs, vus}), old32);
+               if (!r && old) {
+                       old->it_interval.tv_sec = old32[0];
+                       old->it_interval.tv_usec = old32[1];
+                       old->it_value.tv_sec = old32[2];
+                       old->it_value.tv_usec = old32[3];
+               }
+               return __syscall_ret(r);
+       }
        return syscall(SYS_setitimer, which, new, old);
 }
index 05445089f23f3608019db00680a5d74a62fa38e2..c109bea0cfe360ce4191a175c1e561c2d7fb6419 100644 (file)
@@ -7,7 +7,7 @@
 #include "lock.h"
 #include "ksigaction.h"
 
-volatile int dummy_lock[1] = { 0 };
+static volatile int dummy_lock[1] = { 0 };
 
 extern hidden volatile int __abort_lock[1];
 
index 7bcfe720deae216951d2cdfde5d8ca2cf82a825a..1287174ebafdf6114c60f1d703745e703cf28a1e 100644 (file)
@@ -2,11 +2,31 @@
 #include <errno.h>
 #include "syscall.h"
 
+#define IS32BIT(x) !((x)+0x80000000ULL>>32)
+#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63))
+
+static int do_sigtimedwait(const sigset_t *restrict mask, siginfo_t *restrict si, const struct timespec *restrict ts)
+{
+#ifdef SYS_rt_sigtimedwait_time64
+       time_t s = ts ? ts->tv_sec : 0;
+       long ns = ts ? ts->tv_nsec : 0;
+       int r = -ENOSYS;
+       if (SYS_rt_sigtimedwait == SYS_rt_sigtimedwait_time64 || !IS32BIT(s))
+               r = __syscall_cp(SYS_rt_sigtimedwait_time64, mask, si,
+                       ts ? ((long long[]){s, ns}) : 0, _NSIG/8);
+       if (SYS_rt_sigtimedwait == SYS_rt_sigtimedwait_time64 || r!=-ENOSYS)
+               return r;
+       return __syscall_cp(SYS_rt_sigtimedwait, mask, si,
+               ts ? ((long[]){CLAMP(s), ns}) : 0, _NSIG/8);;
+#else
+       return __syscall_cp(SYS_rt_sigtimedwait, mask, si, ts, _NSIG/8);
+#endif
+}
+
 int sigtimedwait(const sigset_t *restrict mask, siginfo_t *restrict si, const struct timespec *restrict timeout)
 {
        int ret;
-       do ret = syscall_cp(SYS_rt_sigtimedwait, mask,
-               si, timeout, _NSIG/8);
-       while (ret<0 && errno==EINTR);
-       return ret;
+       do ret = do_sigtimedwait(mask, si, timeout);
+       while (ret==-EINTR);
+       return __syscall_ret(ret);
 }
diff --git a/libc-top-half/musl/src/signal/x32/getitimer.c b/libc-top-half/musl/src/signal/x32/getitimer.c
new file mode 100644 (file)
index 0000000..8a8046a
--- /dev/null
@@ -0,0 +1,7 @@
+#include <sys/time.h>
+#include "syscall.h"
+
+int getitimer(int which, struct itimerval *old)
+{
+       return syscall(SYS_getitimer, which, old);
+}
diff --git a/libc-top-half/musl/src/signal/x32/setitimer.c b/libc-top-half/musl/src/signal/x32/setitimer.c
new file mode 100644 (file)
index 0000000..21b1f45
--- /dev/null
@@ -0,0 +1,7 @@
+#include <sys/time.h>
+#include "syscall.h"
+
+int setitimer(int which, const struct itimerval *restrict new, struct itimerval *restrict old)
+{
+       return syscall(SYS_setitimer, which, new, old);
+}
index 4f13f4f0e39eacfb63010353810c5387bba817f6..07f9a5de15e8a54b4f7b1c37ddcb0119190fef5b 100644 (file)
@@ -1,3 +1,4 @@
+#define _BSD_SOURCE
 #include <sys/stat.h>
 #include <errno.h>
 #include <fcntl.h>
@@ -5,17 +6,8 @@
 
 int fstat(int fd, struct stat *st)
 {
-       int ret = __syscall(SYS_fstat, fd, st);
-       if (ret != -EBADF || __syscall(SYS_fcntl, fd, F_GETFD) < 0)
-               return __syscall_ret(ret);
-
-       char buf[15+3*sizeof(int)];
-       __procfdname(buf, fd);
-#ifdef SYS_stat
-       return syscall(SYS_stat, buf, st);
-#else
-       return syscall(SYS_fstatat, AT_FDCWD, buf, st, 0);
-#endif
+       if (fd<0) return __syscall_ret(-EBADF);
+       return fstatat(fd, "", st, AT_EMPTY_PATH);
 }
 
 weak_alias(fstat, fstat64);
index 582db44292d9965b6a38532d02d739b4d86bc5bb..d915fa1060ee99dda509f953da70a22381209643 100644 (file)
@@ -1,9 +1,129 @@
+#define _BSD_SOURCE
 #include <sys/stat.h>
+#include <string.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <stdint.h>
+#include <sys/sysmacros.h>
 #include "syscall.h"
+#include "kstat.h"
 
-int fstatat(int fd, const char *restrict path, struct stat *restrict buf, int flag)
+struct statx {
+       uint32_t stx_mask;
+       uint32_t stx_blksize;
+       uint64_t stx_attributes;
+       uint32_t stx_nlink;
+       uint32_t stx_uid;
+       uint32_t stx_gid;
+       uint16_t stx_mode;
+       uint16_t pad1;
+       uint64_t stx_ino;
+       uint64_t stx_size;
+       uint64_t stx_blocks;
+       uint64_t stx_attributes_mask;
+       struct {
+               int64_t tv_sec;
+               uint32_t tv_nsec;
+               int32_t pad;
+       } stx_atime, stx_btime, stx_ctime, stx_mtime;
+       uint32_t stx_rdev_major;
+       uint32_t stx_rdev_minor;
+       uint32_t stx_dev_major;
+       uint32_t stx_dev_minor;
+       uint64_t spare[14];
+};
+
+static int fstatat_statx(int fd, const char *restrict path, struct stat *restrict st, int flag)
+{
+       struct statx stx;
+
+       int ret = __syscall(SYS_statx, fd, path, flag, 0x7ff, &stx);
+       if (ret) return ret;
+
+       *st = (struct stat){
+               .st_dev = makedev(stx.stx_dev_major, stx.stx_dev_minor),
+               .st_ino = stx.stx_ino,
+               .st_mode = stx.stx_mode,
+               .st_nlink = stx.stx_nlink,
+               .st_uid = stx.stx_uid,
+               .st_gid = stx.stx_gid,
+               .st_rdev = makedev(stx.stx_rdev_major, stx.stx_rdev_minor),
+               .st_size = stx.stx_size,
+               .st_blksize = stx.stx_blksize,
+               .st_blocks = stx.stx_blocks,
+               .st_atim.tv_sec = stx.stx_atime.tv_sec,
+               .st_atim.tv_nsec = stx.stx_atime.tv_nsec,
+               .st_mtim.tv_sec = stx.stx_mtime.tv_sec,
+               .st_mtim.tv_nsec = stx.stx_mtime.tv_nsec,
+               .st_ctim.tv_sec = stx.stx_ctime.tv_sec,
+               .st_ctim.tv_nsec = stx.stx_ctime.tv_nsec,
+       };
+       return 0;
+}
+
+static int fstatat_kstat(int fd, const char *restrict path, struct stat *restrict st, int flag)
+{
+       int ret;
+       struct kstat kst;
+
+       if (flag==AT_EMPTY_PATH && fd>=0 && !*path) {
+               ret = __syscall(SYS_fstat, fd, &kst);
+               if (ret==-EBADF && __syscall(SYS_fcntl, fd, F_GETFD)>=0) {
+                       ret = __syscall(SYS_fstatat, fd, path, &kst, flag);
+                       if (ret==-EINVAL) {
+                               char buf[15+3*sizeof(int)];
+                               __procfdname(buf, fd);
+#ifdef SYS_stat
+                               ret = __syscall(SYS_stat, buf, &kst);
+#else
+                               ret = __syscall(SYS_fstatat, AT_FDCWD, buf, &kst, 0);
+#endif
+                       }
+               }
+       }
+#ifdef SYS_lstat
+       else if ((fd == AT_FDCWD || *path=='/') && flag==AT_SYMLINK_NOFOLLOW)
+               ret = __syscall(SYS_lstat, path, &kst);
+#endif
+#ifdef SYS_stat
+       else if ((fd == AT_FDCWD || *path=='/') && !flag)
+               ret = __syscall(SYS_stat, path, &kst);
+#endif
+       else ret = __syscall(SYS_fstatat, fd, path, &kst, flag);
+
+       if (ret) return ret;
+
+       *st = (struct stat){
+               .st_dev = kst.st_dev,
+               .st_ino = kst.st_ino,
+               .st_mode = kst.st_mode,
+               .st_nlink = kst.st_nlink,
+               .st_uid = kst.st_uid,
+               .st_gid = kst.st_gid,
+               .st_rdev = kst.st_rdev,
+               .st_size = kst.st_size,
+               .st_blksize = kst.st_blksize,
+               .st_blocks = kst.st_blocks,
+               .st_atim.tv_sec = kst.st_atime_sec,
+               .st_atim.tv_nsec = kst.st_atime_nsec,
+               .st_mtim.tv_sec = kst.st_mtime_sec,
+               .st_mtim.tv_nsec = kst.st_mtime_nsec,
+               .st_ctim.tv_sec = kst.st_ctime_sec,
+               .st_ctim.tv_nsec = kst.st_ctime_nsec,
+       };
+
+       return 0;
+}
+
+int fstatat(int fd, const char *restrict path, struct stat *restrict st, int flag)
 {
-       return syscall(SYS_fstatat, fd, path, buf, flag);
+       int ret;
+       if (sizeof((struct kstat){0}.st_atime_sec) < sizeof(time_t)) {
+               ret = fstatat_statx(fd, path, st, flag);
+               if (ret!=-ENOSYS) return __syscall_ret(ret);
+       }
+       ret = fstatat_kstat(fd, path, st, flag);
+       return __syscall_ret(ret);
 }
 
 weak_alias(fstatat, fstatat64);
index 5b89f290dc1292c2c1e4abf0fc079f7e031c377e..9f95218a4e83e38929542861b4d3349f78ef3a85 100644 (file)
@@ -1,14 +1,9 @@
 #include <sys/stat.h>
 #include <fcntl.h>
-#include "syscall.h"
 
 int lstat(const char *restrict path, struct stat *restrict buf)
 {
-#ifdef SYS_lstat
-       return syscall(SYS_lstat, path, buf);
-#else
-       return syscall(SYS_fstatat, AT_FDCWD, path, buf, AT_SYMLINK_NOFOLLOW);
-#endif
+       return fstatat(AT_FDCWD, path, buf, AT_SYMLINK_NOFOLLOW);
 }
 
 weak_alias(lstat, lstat64);
index 0bec9d6fa972e7dab9c1611a867214fa85f28917..528870d2fcb786060aef053ad1b1ddddabf5ee02 100644 (file)
@@ -1,14 +1,9 @@
 #include <sys/stat.h>
 #include <fcntl.h>
-#include "syscall.h"
 
 int stat(const char *restrict path, struct stat *restrict buf)
 {
-#ifdef SYS_stat
-       return syscall(SYS_stat, path, buf);
-#else
-       return syscall(SYS_fstatat, AT_FDCWD, path, buf, 0);
-#endif
+       return fstatat(AT_FDCWD, path, buf, 0);
 }
 
 weak_alias(stat, stat64);
index 159c8be3b3c71109f2b72c36cc2c4027683a8cf6..730723a9ea70d4f88e20155f1f7e33b366a2281e 100644 (file)
@@ -4,28 +4,51 @@
 #include <errno.h>
 #include "syscall.h"
 
+#define IS32BIT(x) !((x)+0x80000000ULL>>32)
+#define NS_SPECIAL(ns) ((ns)==UTIME_NOW || (ns)==UTIME_OMIT)
+
 int utimensat(int fd, const char *path, const struct timespec times[2], int flags)
 {
-       int r = __syscall(SYS_utimensat, fd, path, times, flags);
+       int r;
+       if (times && times[0].tv_nsec==UTIME_NOW && times[1].tv_nsec==UTIME_NOW)
+               times = 0;
+#ifdef SYS_utimensat_time64
+       r = -ENOSYS;
+       time_t s0=0, s1=0;
+       long ns0=0, ns1=0;
+       if (times) {
+               ns0 = times[0].tv_nsec;
+               ns1 = times[1].tv_nsec;
+               if (!NS_SPECIAL(ns0)) s0 = times[0].tv_sec;
+               if (!NS_SPECIAL(ns1)) s1 = times[1].tv_sec;
+       }
+       if (SYS_utimensat == SYS_utimensat_time64 || !IS32BIT(s0) || !IS32BIT(s1))
+               r = __syscall(SYS_utimensat_time64, fd, path, times ?
+                       ((long long[]){s0, ns0, s1, ns1}) : 0, flags);
+       if (SYS_utimensat == SYS_utimensat_time64 || r!=-ENOSYS)
+               return __syscall_ret(r);
+       if (!IS32BIT(s0) || !IS32BIT(s1))
+               return __syscall_ret(-ENOTSUP);
+       r = __syscall(SYS_utimensat, fd, path,
+               times ? ((long[]){s0, ns0, s1, ns1}) : 0, flags);
+#else
+       r = __syscall(SYS_utimensat, fd, path, times, flags);
+#endif
+
 #ifdef SYS_futimesat
        if (r != -ENOSYS || flags) return __syscall_ret(r);
-       struct timeval *tv = 0, tmp[2];
+       long *tv=0, tmp[4];
        if (times) {
                int i;
                tv = tmp;
                for (i=0; i<2; i++) {
                        if (times[i].tv_nsec >= 1000000000ULL) {
-                               if (times[i].tv_nsec == UTIME_NOW &&
-                                   times[1-i].tv_nsec == UTIME_NOW) {
-                                       tv = 0;
-                                       break;
-                               }
-                               if (times[i].tv_nsec == UTIME_OMIT)
+                               if (NS_SPECIAL(times[i].tv_nsec))
                                        return __syscall_ret(-ENOSYS);
                                return __syscall_ret(-EINVAL);
                        }
-                       tmp[i].tv_sec = times[i].tv_sec;
-                       tmp[i].tv_usec = times[i].tv_nsec / 1000;
+                       tmp[2*i+0] = times[i].tv_sec;
+                       tmp[2*i+1] = times[i].tv_nsec / 1000;
                }
        }
 
index 709904fa15b42cf0bbe10d88e50194a0c9a5358b..782c6784224b336fb7f2a75c632596ca92643636 100644 (file)
@@ -7,20 +7,5 @@
 
 off_t __stdio_seek(FILE *f, off_t off, int whence)
 {
-       off_t ret;
-#ifdef SYS__llseek
-#ifdef __wasilibc_unmodified_upstream // WASI has no syscall
-       if (syscall(SYS__llseek, f->fd, off>>32, off, &ret, whence)<0)
-#else
-       if (llseek(f->fd, off>>32, off, &ret, whence)<0)
-#endif
-               ret = -1;
-#else
-#ifdef __wasilibc_unmodified_upstream // WASI has no syscall
-       ret = syscall(SYS_lseek, f->fd, off, whence);
-#else
-       ret = lseek(f->fd, off, whence);
-#endif
-#endif
-       return ret;
+       return __lseek(f->fd, off, whence);
 }
index ea6285ed5ad8cf22e3e6826f3deddf32e0e67f07..e660fcc2fae39d64e4328f6f01fb9201d2f9e19b 100644 (file)
@@ -57,6 +57,8 @@ static const unsigned char states[]['z'-'A'+1] = {
        }, { /* 1: l-prefixed */
                S('d') = LONG, S('i') = LONG,
                S('o') = ULONG, S('u') = ULONG, S('x') = ULONG, S('X') = ULONG,
+               S('e') = DBL, S('f') = DBL, S('g') = DBL, S('a') = DBL,
+               S('E') = DBL, S('F') = DBL, S('G') = DBL, S('A') = DBL,
                S('c') = INT, S('s') = PTR, S('n') = PTR,
                S('l') = LLPRE,
        }, { /* 2: ll-prefixed */
index ae19bd6308a94b2ef24d32611dcad1f061541ece..666093be98516a1c84b2997f075a8dbfcb797b2c 100644 (file)
@@ -5,6 +5,27 @@
 #include "syscall.h"
 #include "pthread_impl.h"
 
+#define IS32BIT(x) !((x)+0x80000000ULL>>32)
+#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63))
+
+static int __futex4_cp(volatile void *addr, int op, int val, const struct timespec *to)
+{
+       int r;
+#ifdef SYS_futex_time64
+       time_t s = to ? to->tv_sec : 0;
+       long ns = to ? to->tv_nsec : 0;
+       r = -ENOSYS;
+       if (SYS_futex == SYS_futex_time64 || !IS32BIT(s))
+               r = __syscall_cp(SYS_futex_time64, addr, op, val,
+                       to ? ((long long[]){s, ns}) : 0);
+       if (SYS_futex == SYS_futex_time64 || r!=-ENOSYS) return r;
+       to = to ? (void *)(long[]){CLAMP(s), ns} : 0;
+#endif
+       r = __syscall_cp(SYS_futex, addr, op, val, to);
+       if (r != -ENOSYS) return r;
+       return __syscall_cp(SYS_futex, addr, op & ~FUTEX_PRIVATE, val, to);
+}
+
 static volatile int dummy = 0;
 weak_alias(dummy, __eintr_valid_flag);
 
@@ -28,8 +49,7 @@ int __timedwait_cp(volatile int *addr, int val,
                top = &to;
        }
 
-       r = -__syscall_cp(SYS_futex, addr, FUTEX_WAIT|priv, val, top);
-       if (r == ENOSYS) r = -__syscall_cp(SYS_futex, addr, FUTEX_WAIT, val, top);
+       r = -__futex4_cp(addr, FUTEX_WAIT|priv, val, top);
        if (r != EINTR && r != ETIMEDOUT && r != ECANCELED) r = 0;
        /* Mitigate bug in old kernels wrongly reporting EINTR for non-
         * interrupting (SA_RESTART) signal handlers. This is only practical
index 101ad391e838021bc86eddb0627e6f85bafc587f..da50508d8d45ceb659fdd2ea4883a0b60f979925 100644 (file)
@@ -15,10 +15,10 @@ __a_barrier_oldkuser:
        mov r1,r0
        mov r2,sp
        ldr ip,=0xffff0fc0
-       mov lr,pc
-       mov pc,ip
+       bl 1f
        pop {r0,r1,r2,r3,ip,lr}
        bx lr
+1:     bx ip
 
 .global __a_barrier_v6
 .hidden __a_barrier_v6
index e16b13260e60c9699aa084b1c98471b919d00e8d..bb0965dafe8298e652a5291dd443893153c748af 100644 (file)
@@ -20,13 +20,9 @@ __clone:
        bx lr
 
 1:     mov r0,r6
-       tst r5,#1
-       bne 1f
-       mov lr,pc
-       mov pc,r5
+       bl 3f
 2:     mov r7,#1
        svc 0
-
-1:     mov lr,pc
-       bx r5
        b 2b
+
+3:     bx r5
index a5730c08b826334f550055f31703e1c69227af27..e607dd426afc66923299a6c5f1c3038893474863 100644 (file)
 .type __syscall_cp_asm,%function
 __syscall_cp_asm:
        mov ip,sp
-       stmfd sp!,{r4,r5,r6,r7,lr}
+       stmfd sp!,{r4,r5,r6,r7}
 __cp_begin:
        ldr r0,[r0]
        cmp r0,#0
-       blne __cp_cancel
+       bne __cp_cancel
        mov r7,r1
        mov r0,r2
        mov r1,r3
        ldmfd ip,{r2,r3,r4,r5,r6}
        svc 0
 __cp_end:
-       ldmfd sp!,{r4,r5,r6,r7,lr}
+       ldmfd sp!,{r4,r5,r6,r7}
        bx lr
 __cp_cancel:
-       ldmfd sp!,{r4,r5,r6,r7,lr}
+       ldmfd sp!,{r4,r5,r6,r7}
        b __cancel
index ebf61dedcd3628229de1a6d605e404da90059b10..5f491092597eca1fe5554357cead7b1b73192be3 100644 (file)
@@ -172,23 +172,20 @@ void __do_cleanup_pop(struct __ptcb *cb)
 struct start_args {
        void *(*start_func)(void *);
        void *start_arg;
-       pthread_attr_t *attr;
-       volatile int *perr;
+       volatile int control;
        unsigned long sig_mask[_NSIG/8/sizeof(long)];
 };
 
 static int start(void *p)
 {
        struct start_args *args = p;
-       if (args->attr) {
-               pthread_t self = __pthread_self();
-               int ret = -__syscall(SYS_sched_setscheduler, self->tid,
-                       args->attr->_a_policy, &args->attr->_a_prio);
-               if (a_swap(args->perr, ret)==-2)
-                       __wake(args->perr, 1, 1);
-               if (ret) {
-                       self->detach_state = DT_DETACHED;
-                       __pthread_exit(0);
+       int state = args->control;
+       if (state) {
+               if (a_cas(&args->control, 1, 2)==1)
+                       __wait(&args->control, 0, 2, 1);
+               if (args->control) {
+                       __syscall(SYS_set_tid_address, &args->control);
+                       for (;;) __syscall(SYS_exit, 0);
                }
        }
        __syscall(SYS_rt_sigprocmask, SIG_SETMASK, &args->sig_mask, 0, _NSIG/8);
@@ -233,7 +230,6 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att
                | CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID | CLONE_DETACHED;
        pthread_attr_t attr = { 0 };
        sigset_t set;
-       volatile int err = -1;
 
        if (!libc.can_do_threads) return ENOSYS;
        self = __pthread_self();
@@ -325,13 +321,7 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att
        struct start_args *args = (void *)stack;
        args->start_func = entry;
        args->start_arg = arg;
-       if (attr._a_sched) {
-               args->attr = &attr;
-               args->perr = &err;
-       } else {
-               args->attr = 0;
-               args->perr = 0;
-       }
+       args->control = attr._a_sched ? 1 : 0;
 
        /* Application signals (but not the synccall signal) must be
         * blocked before the thread list lock can be taken, to ensure
@@ -349,29 +339,36 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att
        libc.threads_minus_1++;
        ret = __clone((c11 ? start_c11 : start), stack, flags, args, &new->tid, TP_ADJ(new), &__thread_list_lock);
 
-       /* If clone succeeded, new thread must be linked on the thread
-        * list before unlocking it, even if scheduling may still fail. */
+       /* All clone failures translate to EAGAIN. If explicit scheduling
+        * was requested, attempt it before unlocking the thread list so
+        * that the failed thread is never exposed and so that we can
+        * clean up all transient resource usage before returning. */
+       if (ret < 0) {
+               ret = -EAGAIN;
+       } else if (attr._a_sched) {
+               ret = __syscall(SYS_sched_setscheduler,
+                       new->tid, attr._a_policy, &attr._a_prio);
+               if (a_swap(&args->control, ret ? 3 : 0)==2)
+                       __wake(&args->control, 1, 1);
+               if (ret)
+                       __wait(&args->control, 0, 3, 0);
+       }
+
        if (ret >= 0) {
                new->next = self->next;
                new->prev = self;
                new->next->prev = new;
                new->prev->next = new;
+       } else {
+               libc.threads_minus_1--;
        }
        __tl_unlock();
        __restore_sigs(&set);
        __release_ptc();
 
        if (ret < 0) {
-               libc.threads_minus_1--;
                if (map) __munmap(map, size);
-               return EAGAIN;
-       }
-
-       if (attr._a_sched) {
-               if (a_cas(&err, -1, -2)==-1)
-                       __wait(&err, 0, -2, 1);
-               ret = err;
-               if (ret) return ret;
+               return -ret;
        }
 
        *res = new;
index b8813e0265e625946bd48dbdcc46cb925110e31c..17dae85d7086155a78b89052b6f0b551429a2987 100644 (file)
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
 #include "pthread_impl.h"
 #include <sys/mman.h>
 
index 6b893627787cfeb63ef29de04e83cc1be1182c73..9279fc54308ad6d8b1e1b6ada6ffb32f91c1fa15 100644 (file)
@@ -1,5 +1,23 @@
 #include "pthread_impl.h"
 
+#define IS32BIT(x) !((x)+0x80000000ULL>>32)
+#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63))
+
+static int __futex4(volatile void *addr, int op, int val, const struct timespec *to)
+{
+#ifdef SYS_futex_time64
+       time_t s = to ? to->tv_sec : 0;
+       long ns = to ? to->tv_nsec : 0;
+       int r = -ENOSYS;
+       if (SYS_futex == SYS_futex_time64 || !IS32BIT(s))
+               r = __syscall(SYS_futex_time64, addr, op, val,
+                       to ? ((long long[]){s, ns}) : 0);
+       if (SYS_futex == SYS_futex_time64 || r!=-ENOSYS) return r;
+       to = to ? (void *)(long[]){CLAMP(s), ns} : 0;
+#endif
+       return __syscall(SYS_futex, addr, op, val, to);
+}
+
 static int pthread_mutex_timedlock_pi(pthread_mutex_t *restrict m, const struct timespec *restrict at)
 {
        int type = m->_m_type;
@@ -9,7 +27,7 @@ static int pthread_mutex_timedlock_pi(pthread_mutex_t *restrict m, const struct
 
        if (!priv) self->robust_list.pending = &m->_m_next;
 
-       do e = -__syscall(SYS_futex, &m->_m_lock, FUTEX_LOCK_PI|priv, 0, at);
+       do e = -__futex4(&m->_m_lock, FUTEX_LOCK_PI|priv, 0, at);
        while (e==EINTR);
        if (e) self->robust_list.pending = 0;
 
index e8dfe400cb701f7ae470b192ec04c495a7bfbb18..97de53455ede450885fcd6bdd6bb6de09b97071a 100644 (file)
@@ -1,10 +1,11 @@
 #include <threads.h>
+#include <time.h>
 #include <errno.h>
 #include "syscall.h"
 
 int thrd_sleep(const struct timespec *req, struct timespec *rem)
 {
-       int ret = __syscall(SYS_nanosleep, req, rem);
+       int ret = -__clock_nanosleep(CLOCK_REALTIME, 0, req, rem);
        switch (ret) {
        case 0:      return 0;
        case -EINTR: return -1; /* value specified by C11 */
index 9805af0ae98996a7d2d6d9c7680c140689d82068..4f101716d4ee0cd50461f45a0da6b2edb2be3d4c 100644 (file)
@@ -6,10 +6,10 @@
 .global __cp_cancel
 .hidden __cp_cancel
 .hidden __cancel
-.global __syscall_cp_internal
-.hidden __syscall_cp_internal
-.type   __syscall_cp_internal,@function
-__syscall_cp_internal:
+.global __syscall_cp_asm
+.hidden __syscall_cp_asm
+.type   __syscall_cp_asm,@function
+__syscall_cp_asm:
 
 __cp_begin:
        mov (%rdi),%eax
diff --git a/libc-top-half/musl/src/thread/x32/syscall_cp_fixup.c b/libc-top-half/musl/src/thread/x32/syscall_cp_fixup.c
deleted file mode 100644 (file)
index 4956610..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-#include <sys/syscall.h>
-#include <features.h>
-
-hidden long __syscall_cp_internal(volatile void*, long long, long long,
-                                  long long, long long, long long,
-                                  long long, long long);
-
-struct __timespec { long long tv_sec; long tv_nsec; };
-struct __timespec_kernel { long long tv_sec; long long tv_nsec; };
-#define __tsc(X) ((struct __timespec*)(unsigned long)(X))
-#define __fixup(X) do { if(X) { \
-       ts->tv_sec = __tsc(X)->tv_sec; \
-       ts->tv_nsec = __tsc(X)->tv_nsec; \
-       (X) = (unsigned long)ts; } } while(0)
-
-hidden long __syscall_cp_asm (volatile void * foo, long long n, long long a1,
-                              long long a2, long long a3, long long a4,
-                              long long a5, long long a6)
-{
-       struct __timespec_kernel ts[1];
-       switch (n) {
-       case SYS_mq_timedsend: case SYS_mq_timedreceive: case SYS_pselect6:
-               __fixup(a5);
-               break;
-       case SYS_futex:
-               if((a2 & (~128 /* FUTEX_PRIVATE_FLAG */)) == 0 /* FUTEX_WAIT */)
-                       __fixup(a4);
-               break;
-       case SYS_clock_nanosleep:
-       case SYS_rt_sigtimedwait: case SYS_ppoll:
-               __fixup(a3);
-               break;
-       case SYS_nanosleep:
-               __fixup(a1);
-               break;
-       }
-       return __syscall_cp_internal(foo, n, a1, a2, a3, a4, a5, a6);
-}
-
index 36a0d695b02e29b1bbfd162061cb113c8550bfc2..81c6703761d4484f4001d10a22123a9a5b859ce6 100644 (file)
@@ -3,5 +3,19 @@
 
 int clock_getres(clockid_t clk, struct timespec *ts)
 {
+#ifdef SYS_clock_getres_time64
+       /* On a 32-bit arch, use the old syscall if it exists. */
+       if (SYS_clock_getres != SYS_clock_getres_time64) {
+               long ts32[2];
+               int r = __syscall(SYS_clock_getres, clk, ts32);
+               if (!r && ts) {
+                       ts->tv_sec = ts32[0];
+                       ts->tv_nsec = ts32[1];
+               }
+               return __syscall_ret(r);
+       }
+#endif
+       /* If reaching this point, it's a 64-bit arch or time64-only
+        * 32-bit arch and we can get result directly into timespec. */
        return syscall(SYS_clock_getres, clk, ts);
 }
index 8fd1b8f58ae2e156a0995aa3b3613ea72521e3f8..3e1d0975b1226548375a8403c2fa4161e1021951 100644 (file)
@@ -8,9 +8,41 @@
 
 static void *volatile vdso_func;
 
+#ifdef VDSO_CGT32_SYM
+static void *volatile vdso_func_32;
+static int cgt_time32_wrap(clockid_t clk, struct timespec *ts)
+{
+       long ts32[2];
+       int (*f)(clockid_t, long[2]) =
+               (int (*)(clockid_t, long[2]))vdso_func_32;
+       int r = f(clk, ts32);
+       if (!r) {
+               /* Fallback to syscalls if time32 overflowed. Maybe
+                * we lucked out and somehow migrated to a kernel with
+                * time64 syscalls available. */
+               if (ts32[0] < 0) {
+                       a_cas_p(&vdso_func, (void *)cgt_time32_wrap, 0);
+                       return -ENOSYS;
+               }
+               ts->tv_sec = ts32[0];
+               ts->tv_nsec = ts32[1];
+       }
+       return r;
+}
+#endif
+
 static int cgt_init(clockid_t clk, struct timespec *ts)
 {
        void *p = __vdsosym(VDSO_CGT_VER, VDSO_CGT_SYM);
+#ifdef VDSO_CGT32_SYM
+       if (!p) {
+               void *q = __vdsosym(VDSO_CGT32_VER, VDSO_CGT32_SYM);
+               if (q) {
+                       a_cas_p(&vdso_func_32, 0, q);
+                       p = cgt_time32_wrap;
+               }
+       }
+#endif
        int (*f)(clockid_t, struct timespec *) =
                (int (*)(clockid_t, struct timespec *))p;
        a_cas_p(&vdso_func, (void *)cgt_init, p);
@@ -40,6 +72,25 @@ int __clock_gettime(clockid_t clk, struct timespec *ts)
        }
 #endif
 
+#ifdef SYS_clock_gettime64
+       r = -ENOSYS;
+       if (sizeof(time_t) > 4)
+               r = __syscall(SYS_clock_gettime64, clk, ts);
+       if (SYS_clock_gettime == SYS_clock_gettime64 || r!=-ENOSYS)
+               return __syscall_ret(r);
+       long ts32[2];
+       r = __syscall(SYS_clock_gettime, clk, ts32);
+       if (r==-ENOSYS && clk==CLOCK_REALTIME) {
+               r = __syscall(SYS_gettimeofday, ts32, 0);
+               ts32[1] *= 1000;
+       }
+       if (!r) {
+               ts->tv_sec = ts32[0];
+               ts->tv_nsec = ts32[1];
+               return r;
+       }
+       return __syscall_ret(r);
+#else
        r = __syscall(SYS_clock_gettime, clk, ts);
        if (r == -ENOSYS) {
                if (clk == CLOCK_REALTIME) {
@@ -50,6 +101,7 @@ int __clock_gettime(clockid_t clk, struct timespec *ts)
                r = -EINVAL;
        }
        return __syscall_ret(r);
+#endif
 }
 
 weak_alias(__clock_gettime, clock_gettime);
index 32f0c07e3dbe19ac99a216463f2fd5d774831457..e195499cc0729ad4561e5244445f3e570b3aed1d 100644 (file)
@@ -2,8 +2,37 @@
 #include <errno.h>
 #include "syscall.h"
 
-int clock_nanosleep(clockid_t clk, int flags, const struct timespec *req, struct timespec *rem)
+#define IS32BIT(x) !((x)+0x80000000ULL>>32)
+#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63))
+
+int __clock_nanosleep(clockid_t clk, int flags, const struct timespec *req, struct timespec *rem)
 {
-       int r = -__syscall_cp(SYS_clock_nanosleep, clk, flags, req, rem);
-       return clk == CLOCK_THREAD_CPUTIME_ID ? EINVAL : r;
+       if (clk == CLOCK_THREAD_CPUTIME_ID) return EINVAL;
+#ifdef SYS_clock_nanosleep_time64
+       time_t s = req->tv_sec;
+       long ns = req->tv_nsec;
+       int r = -ENOSYS;
+       if (SYS_clock_nanosleep == SYS_clock_nanosleep_time64 || !IS32BIT(s))
+               r = __syscall_cp(SYS_clock_nanosleep_time64, clk, flags,
+                       ((long long[]){s, ns}), rem);
+       if (SYS_clock_nanosleep == SYS_clock_nanosleep_time64 || r!=-ENOSYS)
+               return -r;
+       long long extra = s - CLAMP(s);
+       long ts32[2] = { CLAMP(s), ns };
+       if (clk == CLOCK_REALTIME && !flags)
+               r = __syscall_cp(SYS_nanosleep, &ts32, &ts32);
+       else
+               r = __syscall_cp(SYS_clock_nanosleep, clk, flags, &ts32, &ts32);
+       if (r==-EINTR && rem && !(flags & TIMER_ABSTIME)) {
+               rem->tv_sec = ts32[0] + extra;
+               rem->tv_nsec = ts32[1];
+       }
+       return -r;
+#else
+       if (clk == CLOCK_REALTIME && !flags)
+               return -__syscall_cp(SYS_nanosleep, req, rem);
+       return -__syscall_cp(SYS_clock_nanosleep, clk, flags, req, rem);
+#endif
 }
+
+weak_alias(__clock_nanosleep, clock_nanosleep);
index 66b8162d72b540de5cefdbb62e8af6d3963d166c..1004ed15284621129789270d0f97e30c5c462095 100644 (file)
@@ -1,7 +1,24 @@
 #include <time.h>
+#include <errno.h>
 #include "syscall.h"
 
+#define IS32BIT(x) !((x)+0x80000000ULL>>32)
+
 int clock_settime(clockid_t clk, const struct timespec *ts)
 {
+#ifdef SYS_clock_settime64
+       time_t s = ts->tv_sec;
+       long ns = ts->tv_nsec;
+       int r = -ENOSYS;
+       if (SYS_clock_settime == SYS_clock_settime64 || !IS32BIT(s))
+               r = __syscall(SYS_clock_settime64, clk,
+                       ((long long[]){s, ns}));
+       if (SYS_clock_settime == SYS_clock_settime64 || r!=-ENOSYS)
+               return __syscall_ret(r);
+       if (!IS32BIT(s))
+               return __syscall_ret(-ENOTSUP);
+       return syscall(SYS_clock_settime, clk, ((long[]){s, ns}));
+#else
        return syscall(SYS_clock_settime, clk, ts);
+#endif
 }
index 1e6f39224a0324729d3ea837f1324d4a4a323534..bc9f7895fa0878be08bdfc01634eede6cbcf81b1 100644 (file)
@@ -3,5 +3,5 @@
 
 int nanosleep(const struct timespec *req, struct timespec *rem)
 {
-       return syscall_cp(SYS_nanosleep, req, rem);
+       return __syscall_ret(-__clock_nanosleep(CLOCK_REALTIME, 0, req, rem));
 }
index cc53d5369ca717900ef5816ed7bdc400d149dc6b..a1db9cbd8e72f4c1296a4d8b27c1a6158caa8886 100644 (file)
@@ -175,7 +175,11 @@ const char *__strftime_fmt_1(char (*s)[100], size_t *l, int f, const struct tm *
                        *l = 0;
                        return "";
                }
+#ifdef __wasilibc_unmodified_upstream // wasi-libc's __tm_gmtoff is an int
                *l = snprintf(*s, sizeof *s, "%+.4ld",
+#else
+               *l = snprintf(*s, sizeof *s, "%+.4d",
+#endif
                        tm->__tm_gmtoff/3600*100 + tm->__tm_gmtoff%3600/60);
                return *s;
        case 'Z':
index c5e40a195801d19afb9a4a1075835b8f0af1f289..455d49fc5035beca4b3f2b97553311d389cff164 100644 (file)
@@ -1,5 +1,6 @@
 #include <time.h>
 #include <setjmp.h>
+#include <limits.h>
 #include "pthread_impl.h"
 
 struct ksigevent {
@@ -48,7 +49,6 @@ static void *start(void *arg)
 {
        pthread_t self = __pthread_self();
        struct start_args *args = arg;
-       int id = self->timer_id;
        jmp_buf jb;
 
        void (*notify)(union sigval) = args->sev->sigev_notify_function;
@@ -65,7 +65,7 @@ static void *start(void *arg)
                }
                if (self->timer_id < 0) break;
        }
-       __syscall(SYS_timer_delete, id);
+       __syscall(SYS_timer_delete, self->timer_id & INT_MAX);
        return 0;
 }
 
index ed6d8d65ce1ac0b488002e5a9503b1fbd84ddea3..21c9d32c3fe52e7502f10af91380ce4faead2c55 100644 (file)
@@ -8,5 +8,21 @@ int timer_gettime(timer_t t, struct itimerspec *val)
                pthread_t td = (void *)((uintptr_t)t << 1);
                t = (void *)(uintptr_t)(td->timer_id & INT_MAX);
        }
+#ifdef SYS_timer_gettime64
+       int r = -ENOSYS;
+       if (sizeof(time_t) > 4)
+               r = __syscall(SYS_timer_gettime64, t, val);
+       if (SYS_timer_gettime == SYS_timer_gettime64 || r!=-ENOSYS)
+               return __syscall_ret(r);
+       long val32[4];
+       r = __syscall(SYS_timer_gettime, t, val32);
+       if (!r) {
+               val->it_interval.tv_sec = val32[0];
+               val->it_interval.tv_nsec = val32[1];
+               val->it_value.tv_sec = val32[2];
+               val->it_value.tv_nsec = val32[3];
+       }
+       return __syscall_ret(r);
+#endif
        return syscall(SYS_timer_gettime, t, val);
 }
index 62631aa49cda75f49fba047163747cd29faa60e3..373f00ced7f28f88f2b9981d9914875de162bda7 100644 (file)
@@ -2,11 +2,36 @@
 #include <limits.h>
 #include "pthread_impl.h"
 
+#define IS32BIT(x) !((x)+0x80000000ULL>>32)
+
 int timer_settime(timer_t t, int flags, const struct itimerspec *restrict val, struct itimerspec *restrict old)
 {
        if ((intptr_t)t < 0) {
                pthread_t td = (void *)((uintptr_t)t << 1);
                t = (void *)(uintptr_t)(td->timer_id & INT_MAX);
        }
+#ifdef SYS_timer_settime64
+       time_t is = val->it_interval.tv_sec, vs = val->it_value.tv_sec;
+       long ins = val->it_interval.tv_nsec, vns = val->it_value.tv_nsec;
+       int r = -ENOSYS;
+       if (SYS_timer_settime == SYS_timer_settime64
+           || !IS32BIT(is) || !IS32BIT(vs) || (sizeof(time_t)>4 && old))
+               r = __syscall(SYS_timer_settime64, t, flags,
+                       ((long long[]){is, ins, vs, vns}), old);
+       if (SYS_timer_settime == SYS_timer_settime64 || r!=-ENOSYS)
+               return __syscall_ret(r);
+       if (!IS32BIT(is) || !IS32BIT(vs))
+               return __syscall_ret(-ENOTSUP);
+       long old32[4];
+       r = __syscall(SYS_timer_settime, t, flags,
+               ((long[]){is, ins, vs, vns}), old32);
+       if (!r && old) {
+               old->it_interval.tv_sec = old32[0];
+               old->it_interval.tv_nsec = old32[1];
+               old->it_value.tv_sec = old32[2];
+               old->it_value.tv_nsec = old32[3];
+       }
+       return __syscall_ret(r);
+#endif
        return syscall(SYS_timer_settime, t, flags, val, old);
 }
index 2e3263ac5986019f57576f6b0777f483b449eba7..a5e0c822a05559ffaa2023ab8b6fca3d20f1af63 100644 (file)
@@ -4,7 +4,7 @@
 
 unsigned alarm(unsigned seconds)
 {
-       struct itimerval it = { .it_value.tv_sec = seconds };
-       __syscall(SYS_setitimer, ITIMER_REAL, &it, &it);
-       return it.it_value.tv_sec + !!it.it_value.tv_usec;
+       struct itimerval it = { .it_value.tv_sec = seconds }, old = { 0 };
+       setitimer(ITIMER_REAL, &it, &old);
+       return old.it_value.tv_sec + !!old.it_value.tv_usec;
 }
index bf8cd8528e13b28dae03b771f2aa311555124bdf..48a638a37cfe93b6b997e3d9773b1c82da0841fd 100644 (file)
@@ -1,14 +1,23 @@
 #include <unistd.h>
 #include "syscall.h"
 
-off_t lseek(int fd, off_t offset, int whence)
+off_t __lseek(int fd, off_t offset, int whence)
 {
 #ifdef SYS__llseek
        off_t result;
+#ifdef __wasilibc_unmodified_upstream // WASI has no syscall
        return syscall(SYS__llseek, fd, offset>>32, offset, &result, whence) ? -1 : result;
 #else
+       return llseek(fd, offset>>32, offset, &result, whence) ? -1 : result;
+#endif
+#else
+#ifdef __wasilibc_unmodified_upstream // WASI has no syscall
        return syscall(SYS_lseek, fd, offset, whence);
+#else
+       return lseek(fd, offset, whence);
+#endif
 #endif
 }
 
-weak_alias(lseek, lseek64);
+weak_alias(__lseek, lseek);
+weak_alias(__lseek, lseek64);
diff --git a/libc-top-half/musl/src/unistd/mipsn32/lseek.c b/libc-top-half/musl/src/unistd/mipsn32/lseek.c
new file mode 100644 (file)
index 0000000..60e74a5
--- /dev/null
@@ -0,0 +1,20 @@
+#include <unistd.h>
+#include "syscall.h"
+
+off_t __lseek(int fd, off_t offset, int whence)
+{
+       register long long r4 __asm__("$4") = fd;
+       register long long r5 __asm__("$5") = offset;
+       register long long r6 __asm__("$6") = whence;
+       register long long r7 __asm__("$7");
+       register long long r2 __asm__("$2") = SYS_lseek;
+       __asm__ __volatile__ (
+               "syscall"
+               : "+&r"(r2), "=r"(r7)
+               : "r"(r4), "r"(r5), "r"(r6)
+               : SYSCALL_CLOBBERLIST);
+       return r7 ? __syscall_ret(-r2) : r2;
+}
+
+weak_alias(__lseek, lseek);
+weak_alias(__lseek, lseek64);
diff --git a/libc-top-half/musl/src/unistd/x32/lseek.c b/libc-top-half/musl/src/unistd/x32/lseek.c
new file mode 100644 (file)
index 0000000..3263642
--- /dev/null
@@ -0,0 +1,15 @@
+#include <unistd.h>
+#include "syscall.h"
+
+off_t __lseek(int fd, off_t offset, int whence)
+{
+       off_t ret;
+       __asm__ __volatile__ ("syscall"
+               : "=a"(ret)
+               : "a"(SYS_lseek), "D"(fd), "S"(offset), "d"(whence)
+               : "rcx", "r11", "memory");
+       return ret < 0 ? __syscall_ret(ret) : ret;
+}
+
+weak_alias(__lseek, lseek);
+weak_alias(__lseek, lseek64);