Commit 88b9579488

Andrew Kelley <andrew@ziglang.org>
2019-10-17 17:55:43
update musl src to v1.1.24
1 parent 1135c95
Changed files (176)
lib
libc
musl
arch
include
src
src
lib/libc/musl/arch/aarch64/bits/hwcap.h
@@ -30,3 +30,11 @@
 #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)
lib/libc/musl/arch/aarch64/bits/ipc.h
@@ -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
lib/libc/musl/arch/aarch64/bits/msg.h
@@ -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;
-};
lib/libc/musl/arch/aarch64/bits/sem.h
@@ -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;
-};
lib/libc/musl/arch/aarch64/bits/shm.h
@@ -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;
-};
lib/libc/musl/arch/aarch64/bits/syscall.h.in
@@ -281,4 +281,10 @@
 #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
 
lib/libc/musl/arch/aarch64/kstat.h
@@ -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];
+};
lib/libc/musl/arch/aarch64/syscall_arch.h
@@ -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
lib/libc/musl/arch/arm/bits/ipcstat.h
@@ -0,0 +1,1 @@
+#define IPC_STAT 2
lib/libc/musl/arch/s390x/bits/msg.h โ†’ lib/libc/musl/arch/arm/bits/msg.h
@@ -1,8 +1,11 @@
 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;
lib/libc/musl/arch/mips64/bits/sem.h โ†’ lib/libc/musl/arch/arm/bits/sem.h
@@ -1,14 +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(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;
 };
lib/libc/musl/arch/x86_64/bits/shm.h โ†’ lib/libc/musl/arch/arm/bits/shm.h
@@ -4,8 +4,11 @@ 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;
@@ -22,4 +25,3 @@ struct shm_info {
 	unsigned long shm_tot, shm_rss, shm_swp;
 	unsigned long __swap_attempts, __swap_successes;
 };
-
lib/libc/musl/arch/arm/bits/syscall.h.in
@@ -381,6 +381,12 @@
 #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
lib/libc/musl/arch/arm/kstat.h
@@ -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;
+};
lib/libc/musl/arch/generic/bits/ipc.h
@@ -9,5 +9,3 @@ struct ipc_perm {
 	long __pad1;
 	long __pad2;
 };
-
-#define IPC_64 0x100
lib/libc/musl/arch/generic/bits/ipcstat.h
@@ -0,0 +1,1 @@
+#define IPC_STAT 2
lib/libc/musl/arch/generic/bits/msg.h
@@ -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;
lib/libc/musl/arch/generic/bits/sem.h
@@ -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;
 };
lib/libc/musl/arch/generic/bits/shm.h
@@ -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;
 };
-
lib/libc/musl/arch/i386/bits/ipcstat.h
@@ -0,0 +1,1 @@
+#define IPC_STAT 2
lib/libc/musl/arch/x86_64/bits/msg.h โ†’ lib/libc/musl/arch/i386/bits/msg.h
@@ -1,8 +1,11 @@
 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;
lib/libc/musl/arch/i386/bits/sem.h
@@ -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;
+};
lib/libc/musl/arch/mips64/bits/shm.h โ†’ lib/libc/musl/arch/i386/bits/shm.h
@@ -4,8 +4,11 @@ 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;
lib/libc/musl/arch/i386/bits/syscall.h.in
@@ -418,4 +418,10 @@
 #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
 
lib/libc/musl/arch/i386/kstat.h
@@ -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;
+};
lib/libc/musl/arch/mips/bits/ipcstat.h
@@ -0,0 +1,1 @@
+#define IPC_STAT 2
lib/libc/musl/arch/mips/bits/sem.h
@@ -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;
 };
lib/libc/musl/arch/mips/bits/shm.h
@@ -22,4 +22,3 @@ struct shm_info {
 	unsigned long shm_tot, shm_rss, shm_swp;
 	unsigned long __swap_attempts, __swap_successes;
 };
-
lib/libc/musl/arch/mips/bits/syscall.h.in
@@ -400,4 +400,10 @@
 #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
 
lib/libc/musl/arch/mips/kstat.h
@@ -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];
+};
lib/libc/musl/arch/mips/syscall_arch.h
@@ -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
lib/libc/musl/arch/mips64/bits/ipc.h
@@ -10,5 +10,3 @@ struct ipc_perm {
 	unsigned long __unused1;
 	unsigned long __unused2;
 };
-
-#define IPC_64 0x100
lib/libc/musl/arch/mips64/bits/msg.h
@@ -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;
-};
lib/libc/musl/arch/mips64/bits/stat.h
@@ -1,6 +1,3 @@
-#include <string.h>
-#include <bits/alltypes.h>
-
 struct stat {
 	dev_t st_dev;
 	int __pad1[3];
lib/libc/musl/arch/mips64/bits/syscall.h.in
@@ -330,4 +330,10 @@
 #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
 
lib/libc/musl/arch/mips64/kstat.h
@@ -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;
+};
lib/libc/musl/arch/mips64/syscall_arch.h
@@ -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
lib/libc/musl/arch/powerpc/bits/alltypes.h.in
@@ -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;
lib/libc/musl/arch/powerpc/bits/ipc.h
@@ -10,6 +10,3 @@ struct ipc_perm {
 	long long __pad2;
 	long long __pad3;
 };
-
-#define IPC_64 0x100
-
lib/libc/musl/arch/powerpc/bits/ipcstat.h
@@ -0,0 +1,1 @@
+#define IPC_STAT 2
lib/libc/musl/arch/powerpc/bits/shm.h
@@ -26,4 +26,3 @@ struct shm_info {
 	unsigned long shm_tot, shm_rss, shm_swp;
 	unsigned long __swap_attempts, __swap_successes;
 };
-
lib/libc/musl/arch/powerpc/bits/syscall.h.in
@@ -407,4 +407,10 @@
 #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
 
lib/libc/musl/arch/powerpc/bits/user.h
@@ -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;
lib/libc/musl/arch/powerpc/kstat.h
@@ -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];
+};
lib/libc/musl/arch/powerpc/reloc.h
@@ -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
lib/libc/musl/arch/powerpc/syscall_arch.h
@@ -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
lib/libc/musl/arch/powerpc64/bits/ipc.h
@@ -10,6 +10,3 @@ struct ipc_perm {
 	long long __pad2;
 	long long __pad3;
 };
-
-#define IPC_64 0x100
-
lib/libc/musl/arch/powerpc64/bits/msg.h
@@ -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];
-};
lib/libc/musl/arch/powerpc64/bits/sem.h
@@ -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];
-};
lib/libc/musl/arch/powerpc64/bits/shm.h
@@ -21,4 +21,3 @@ struct shm_info {
 	unsigned long shm_tot, shm_rss, shm_swp;
 	unsigned long __swap_attempts, __swap_successes;
 };
-
lib/libc/musl/arch/powerpc64/bits/syscall.h.in
@@ -379,4 +379,10 @@
 #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
 
lib/libc/musl/arch/powerpc64/bits/user.h
@@ -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;
lib/libc/musl/arch/powerpc64/kstat.h
@@ -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];
+};
lib/libc/musl/arch/powerpc64/reloc.h
@@ -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
lib/libc/musl/arch/powerpc64/syscall_arch.h
@@ -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
lib/libc/musl/arch/riscv64/bits/ipc.h
@@ -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
lib/libc/musl/arch/riscv64/bits/msg.h
@@ -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;
-};
lib/libc/musl/arch/riscv64/bits/sem.h
@@ -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;
-};
lib/libc/musl/arch/riscv64/bits/shm.h
@@ -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;
-};
lib/libc/musl/arch/riscv64/bits/signal.h
@@ -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;
lib/libc/musl/arch/riscv64/bits/syscall.h.in
@@ -273,5 +273,20 @@
 #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)
lib/libc/musl/arch/riscv64/bits/user.h
@@ -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;
lib/libc/musl/arch/riscv64/atomic_arch.h
@@ -14,7 +14,7 @@ static inline int a_cas(volatile int *p, int t, int s)
 		"	sc.w.aqrl %1, %4, (%2)\n"
 		"	bnez %1, 1b\n"
 		"1:"
-		: "=&r"(old), "=r"(tmp)
+		: "=&r"(old), "=&r"(tmp)
 		: "r"(p), "r"(t), "r"(s)
 		: "memory");
 	return old;
@@ -31,7 +31,7 @@ static inline void *a_cas_p(volatile void *p, void *t, void *s)
 		"	sc.d.aqrl %1, %4, (%2)\n"
 		"	bnez %1, 1b\n"
 		"1:"
-		: "=&r"(old), "=r"(tmp)
+		: "=&r"(old), "=&r"(tmp)
 		: "r"(p), "r"(t), "r"(s)
 		: "memory");
 	return old;
lib/libc/musl/arch/riscv64/kstat.h
@@ -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];
+};
lib/libc/musl/arch/riscv64/pthread_arch.h
@@ -11,4 +11,4 @@ static inline struct pthread *__pthread_self()
 
 #define DTP_OFFSET 0x800
 
-#define MC_PC gregs[0]
+#define MC_PC __gregs[0]
lib/libc/musl/arch/riscv64/syscall_arch.h
@@ -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
lib/libc/musl/arch/s390x/bits/ipc.h
@@ -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
lib/libc/musl/arch/s390x/bits/sem.h
@@ -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];
-};
lib/libc/musl/arch/s390x/bits/shm.h
@@ -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;
-};
-
lib/libc/musl/arch/s390x/bits/syscall.h.in
@@ -344,4 +344,10 @@
 #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
 
lib/libc/musl/arch/s390x/kstat.h
@@ -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];
+};
lib/libc/musl/arch/x86_64/bits/ipc.h
@@ -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
lib/libc/musl/arch/x86_64/bits/sem.h
@@ -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;
+};
lib/libc/musl/arch/x86_64/bits/syscall.h.in
@@ -337,4 +337,10 @@
 #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
 
lib/libc/musl/arch/x86_64/kstat.h
@@ -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];
+};
lib/libc/musl/arch/x86_64/syscall_arch.h
@@ -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
lib/libc/musl/include/netinet/if_ether.h
@@ -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
 
lib/libc/musl/include/sys/ipc.h
@@ -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)
lib/libc/musl/include/sys/msg.h
@@ -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;
lib/libc/musl/include/sys/sem.h
@@ -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;
lib/libc/musl/include/sys/shm.h
@@ -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
lib/libc/musl/include/fcntl.h
@@ -100,6 +100,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
lib/libc/musl/include/glob.h
@@ -31,6 +31,9 @@ void globfree(glob_t *);
 #define GLOB_NOESCAPE 0x40
 #define	GLOB_PERIOD   0x80
 
+#define GLOB_TILDE       0x1000
+#define GLOB_TILDE_CHECK 0x4000
+
 #define GLOB_NOSPACE 1
 #define GLOB_ABORTED 2
 #define GLOB_NOMATCH 3
lib/libc/musl/include/sched.h
@@ -18,10 +18,12 @@ extern "C" {
 
 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);
@@ -47,6 +49,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
lib/libc/musl/include/spawn.h
@@ -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
lib/libc/musl/include/stdlib.h
@@ -152,6 +152,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 *);
lib/libc/musl/include/unistd.h
@@ -176,6 +176,7 @@ long syscall(long, ...);
 int execvpe(const char *, char *const [], char *const []);
 int issetugid(void);
 int getentropy(void *, size_t);
+extern int optreset;
 #endif
 
 #ifdef _GNU_SOURCE
@@ -188,6 +189,7 @@ char *get_current_dir_name(void);
 int syncfs(int);
 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
 
 #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
lib/libc/musl/src/env/secure_getenv.c
@@ -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);
+}
lib/libc/musl/src/include/time.h
@@ -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);
lib/libc/musl/src/include/unistd.h
@@ -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
lib/libc/musl/src/internal/dynlink.h
@@ -28,6 +28,7 @@ typedef Elf64_Sym Sym;
 enum {
 	REL_NONE = 0,
 	REL_SYMBOLIC = -100,
+	REL_USYMBOLIC,
 	REL_GOT,
 	REL_PLT,
 	REL_RELATIVE,
lib/libc/musl/src/internal/pthread_impl.h
@@ -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();
lib/libc/musl/src/internal/syscall.h
@@ -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)
lib/libc/musl/src/internal/version.h
@@ -1,1 +1,1 @@
-#define VERSION "1.1.23"
+#define VERSION "1.1.24"
lib/libc/musl/src/ipc/ipc.h
@@ -1,3 +1,5 @@
+#include "syscall.h"
+
 #define IPCOP_semop      1
 #define IPCOP_semget     2
 #define IPCOP_semctl     3
@@ -10,3 +12,13 @@
 #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)
lib/libc/musl/src/ipc/msgctl.c
@@ -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);
 }
lib/libc/musl/src/ipc/semctl.c
@@ -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);
 }
lib/libc/musl/src/ipc/semtimedop.c
@@ -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
 }
lib/libc/musl/src/ipc/shmctl.c
@@ -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);
 }
lib/libc/musl/src/ldso/aarch64/tlsdesc.s
@@ -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
lib/libc/musl/src/ldso/arm/tlsdesc.S
@@ -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
lib/libc/musl/src/ldso/i386/tlsdesc.s
@@ -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
lib/libc/musl/src/ldso/x86_64/tlsdesc.s
@@ -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
lib/libc/musl/src/linux/adjtime.c
@@ -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) {
lib/libc/musl/src/linux/adjtimex.c
@@ -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);
 }
lib/libc/musl/src/linux/clock_adjtime.c
@@ -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);
 }
lib/libc/musl/src/linux/copy_file_range.c
@@ -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);
+}
lib/libc/musl/src/linux/ppoll.c
@@ -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);
 }
lib/libc/musl/src/linux/settimeofday.c
@@ -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}));
 }
lib/libc/musl/src/linux/timerfd.c
@@ -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);
 }
lib/libc/musl/src/locale/catclose.c
@@ -1,6 +1,14 @@
+#define _BSD_SOURCE
 #include <nl_types.h>
+#include <stdint.h>
+#include <endian.h>
+#include <sys/mman.h>
+
+#define V(p) be32toh(*(uint32_t *)(p))
 
 int catclose (nl_catd catd)
 {
+	char *map = (char *)catd;
+	munmap(map, V(map+8)+20);
 	return 0;
 }
lib/libc/musl/src/locale/catgets.c
@@ -1,6 +1,38 @@
+#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))
+
+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;
+}
 
 char *catgets (nl_catd catd, int set_id, int msg_id, const char *s)
 {
-	return (char *)s;
+	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));
 }
lib/libc/musl/src/locale/catopen.c
@@ -1,8 +1,79 @@
+#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>
+#include <sys/mman.h>
+#include "libc.h"
 
-nl_catd catopen (const char *name, int oflag)
+#define V(p) be32toh(*(uint32_t *)(p))
+
+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;
+}
+
+nl_catd catopen(const char *name, int oflag)
 {
-	errno = EOPNOTSUPP;
+	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;
 	return (nl_catd)-1;
 }
lib/libc/musl/src/math/i386/asin.s
@@ -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)
lib/libc/musl/src/math/i386/atan.s
@@ -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
lib/libc/musl/src/math/i386/atan2.s
@@ -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
lib/libc/musl/src/math/i386/atan2f.s
@@ -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)
lib/libc/musl/src/math/i386/atanf.s
@@ -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
lib/libc/musl/src/math/i386/exp.s
@@ -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
lib/libc/musl/src/math/i386/log1p.s
@@ -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
lib/libc/musl/src/math/i386/log1pf.s
@@ -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
lib/libc/musl/src/math/lrint.c
@@ -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)
 {
lib/libc/musl/src/math/sqrt.c
@@ -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;
 }
lib/libc/musl/src/math/sqrtf.c
@@ -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;
 }
lib/libc/musl/src/misc/getopt.c
@@ -1,3 +1,4 @@
+#define _BSD_SOURCE
 #include <unistd.h>
 #include <wchar.h>
 #include <string.h>
lib/libc/musl/src/misc/ioctl.c
@@ -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);
 }
lib/libc/musl/src/mq/mq_timedreceive.c
@@ -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
 }
lib/libc/musl/src/mq/mq_timedsend.c
@@ -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
 }
lib/libc/musl/src/multibyte/mbsrtowcs.c
@@ -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--;
lib/libc/musl/src/network/getsockopt.c
@@ -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);
 }
lib/libc/musl/src/network/recvmmsg.c
@@ -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
 }
lib/libc/musl/src/network/setsockopt.c
@@ -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);
 }
lib/libc/musl/src/process/fdop.h
@@ -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;
lib/libc/musl/src/process/posix_spawn.c
@@ -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;
 			}
 		}
 	}
lib/libc/musl/src/process/posix_spawn_file_actions_addchdir.c
@@ -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;
+}
lib/libc/musl/src/process/posix_spawn_file_actions_addfchdir.c
@@ -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;
+}
lib/libc/musl/src/regex/glob.c
@@ -8,6 +8,8 @@
 #include <stdlib.h>
 #include <errno.h>
 #include <stddef.h>
+#include <unistd.h>
+#include <pwd.h>
 
 struct match
 {
@@ -90,16 +92,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 +191,39 @@ static int sort(const void *a, const void *b)
 	return strcmp(*(const char **)a, *(const char **)b);
 }
 
+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;
+}
+
 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 +244,12 @@ 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;
+		if ((flags & (GLOB_TILDE | GLOB_TILDE_CHECK)) && *p == '~')
+			error = expand_tilde(&s, buf, &pos);
+		if (!error)
+			error = do_glob(buf, pos, 0, s, flags, errfunc, &tail);
 		free(p);
 	}
 
lib/libc/musl/src/sched/sched_rr_get_interval.c
@@ -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);
 }
lib/libc/musl/src/select/pselect.c
@@ -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);
 }
lib/libc/musl/src/select/select.c
@@ -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
 }
lib/libc/musl/src/signal/x32/getitimer.c
@@ -0,0 +1,7 @@
+#include <sys/time.h>
+#include "syscall.h"
+
+int getitimer(int which, struct itimerval *old)
+{
+	return syscall(SYS_getitimer, which, old);
+}
lib/libc/musl/src/signal/x32/setitimer.c
@@ -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);
+}
lib/libc/musl/src/signal/getitimer.c
@@ -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);
 }
lib/libc/musl/src/signal/setitimer.c
@@ -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);
 }
lib/libc/musl/src/signal/sigaction.c
@@ -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];
 
lib/libc/musl/src/signal/sigtimedwait.c
@@ -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);
 }
lib/libc/musl/src/stat/fstat.c
@@ -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);
lib/libc/musl/src/stat/fstatat.c
@@ -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);
lib/libc/musl/src/stat/lstat.c
@@ -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);
lib/libc/musl/src/stat/stat.c
@@ -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);
lib/libc/musl/src/stat/utimensat.c
@@ -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;
 		}
 	}
 
lib/libc/musl/src/stdio/__stdio_seek.c
@@ -1,13 +1,7 @@
 #include "stdio_impl.h"
+#include <unistd.h>
 
 off_t __stdio_seek(FILE *f, off_t off, int whence)
 {
-	off_t ret;
-#ifdef SYS__llseek
-	if (syscall(SYS__llseek, f->fd, off>>32, off, &ret, whence)<0)
-		ret = -1;
-#else
-	ret = syscall(SYS_lseek, f->fd, off, whence);
-#endif
-	return ret;
+	return __lseek(f->fd, off, whence);
 }
lib/libc/musl/src/stdio/vfwprintf.c
@@ -53,6 +53,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 */
lib/libc/musl/src/thread/arm/atomics.s
@@ -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
lib/libc/musl/src/thread/arm/clone.s
@@ -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
lib/libc/musl/src/thread/arm/syscall_cp.s
@@ -11,19 +11,19 @@
 .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
lib/libc/musl/src/thread/x32/syscall_cp.s
@@ -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
lib/libc/musl/src/thread/x32/syscall_cp_fixup.c
@@ -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);
-}
-
lib/libc/musl/src/thread/__timedwait.c
@@ -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
lib/libc/musl/src/thread/pthread_create.c
@@ -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;
lib/libc/musl/src/thread/pthread_join.c
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
 #include "pthread_impl.h"
 #include <sys/mman.h>
 
lib/libc/musl/src/thread/pthread_mutex_timedlock.c
@@ -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;
 
lib/libc/musl/src/thread/thrd_sleep.c
@@ -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 */
lib/libc/musl/src/time/clock_getres.c
@@ -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);
 }
lib/libc/musl/src/time/clock_gettime.c
@@ -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);
lib/libc/musl/src/time/clock_nanosleep.c
@@ -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);
lib/libc/musl/src/time/clock_settime.c
@@ -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
 }
lib/libc/musl/src/time/nanosleep.c
@@ -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));
 }
lib/libc/musl/src/time/timer_create.c
@@ -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;
 }
 
lib/libc/musl/src/time/timer_gettime.c
@@ -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);
 }
lib/libc/musl/src/time/timer_settime.c
@@ -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);
 }
lib/libc/musl/src/unistd/mipsn32/lseek.c
@@ -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);
lib/libc/musl/src/unistd/x32/lseek.c
@@ -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);
lib/libc/musl/src/unistd/alarm.c
@@ -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;
 }
lib/libc/musl/src/unistd/lseek.c
@@ -1,7 +1,7 @@
 #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;
@@ -11,4 +11,5 @@ off_t lseek(int fd, off_t offset, int whence)
 #endif
 }
 
-weak_alias(lseek, lseek64);
+weak_alias(__lseek, lseek);
+weak_alias(__lseek, lseek64);
src/install_files.h
@@ -148,6 +148,7 @@ static const char *ZIG_MUSL_SRC_FILES[] = {
 "musl/src/env/clearenv.c",
 "musl/src/env/getenv.c",
 "musl/src/env/putenv.c",
+"musl/src/env/secure_getenv.c",
 "musl/src/env/setenv.c",
 "musl/src/env/unsetenv.c",
 "musl/src/errno/__errno_location.c",
@@ -311,6 +312,7 @@ static const char *ZIG_MUSL_SRC_FILES[] = {
 "musl/src/linux/chroot.c",
 "musl/src/linux/clock_adjtime.c",
 "musl/src/linux/clone.c",
+"musl/src/linux/copy_file_range.c",
 "musl/src/linux/epoll.c",
 "musl/src/linux/eventfd.c",
 "musl/src/linux/fallocate.c",
@@ -1098,8 +1100,10 @@ static const char *ZIG_MUSL_SRC_FILES[] = {
 "musl/src/process/fork.c",
 "musl/src/process/i386/vfork.s",
 "musl/src/process/posix_spawn.c",
+"musl/src/process/posix_spawn_file_actions_addchdir.c",
 "musl/src/process/posix_spawn_file_actions_addclose.c",
 "musl/src/process/posix_spawn_file_actions_adddup2.c",
+"musl/src/process/posix_spawn_file_actions_addfchdir.c",
 "musl/src/process/posix_spawn_file_actions_addopen.c",
 "musl/src/process/posix_spawn_file_actions_destroy.c",
 "musl/src/process/posix_spawn_file_actions_init.c",
@@ -1251,7 +1255,9 @@ static const char *ZIG_MUSL_SRC_FILES[] = {
 "musl/src/signal/sigtimedwait.c",
 "musl/src/signal/sigwait.c",
 "musl/src/signal/sigwaitinfo.c",
+"musl/src/signal/x32/getitimer.c",
 "musl/src/signal/x32/restore.s",
+"musl/src/signal/x32/setitimer.c",
 "musl/src/signal/x32/sigsetjmp.s",
 "musl/src/signal/x86_64/restore.s",
 "musl/src/signal/x86_64/sigsetjmp.s",
@@ -1707,7 +1713,6 @@ static const char *ZIG_MUSL_SRC_FILES[] = {
 "musl/src/thread/x32/__unmapself.s",
 "musl/src/thread/x32/clone.s",
 "musl/src/thread/x32/syscall_cp.s",
-"musl/src/thread/x32/syscall_cp_fixup.c",
 "musl/src/thread/x86_64/__set_thread_area.s",
 "musl/src/thread/x86_64/__unmapself.s",
 "musl/src/thread/x86_64/clone.s",
@@ -1791,6 +1796,7 @@ static const char *ZIG_MUSL_SRC_FILES[] = {
 "musl/src/unistd/lseek.c",
 "musl/src/unistd/mips/pipe.s",
 "musl/src/unistd/mips64/pipe.s",
+"musl/src/unistd/mipsn32/lseek.c",
 "musl/src/unistd/mipsn32/pipe.s",
 "musl/src/unistd/nice.c",
 "musl/src/unistd/pause.c",
@@ -1835,5 +1841,6 @@ static const char *ZIG_MUSL_SRC_FILES[] = {
 "musl/src/unistd/usleep.c",
 "musl/src/unistd/write.c",
 "musl/src/unistd/writev.c",
+"musl/src/unistd/x32/lseek.c",
 };
 #endif