| author | |
| committer | |
| log | a5d8c310eef494594ae29a2319a5baf496c3434f |
| tree | fbe66673e85f0115b62191cbb2f4bc224ce9786b |
| parent | cdcfd15d3c7b573dcba21b64ffdf982e26524e50 |
173 files changed, 735 insertions(+), 441 deletions(-)
lib/libc/musl/arch/arm/syscall_arch.h+7| ... | @@ -101,3 +101,10 @@ static inline long __syscall6(long n, long a, long b, long c, long d, long e, lo | ... | @@ -101,3 +101,10 @@ static inline long __syscall6(long n, long a, long b, long c, long d, long e, lo |
| 101 | #define SYSCALL_FADVISE_6_ARG | 101 | #define SYSCALL_FADVISE_6_ARG |
| 102 | 102 | ||
| 103 | #define SYSCALL_IPC_BROKEN_MODE | 103 | #define SYSCALL_IPC_BROKEN_MODE |
| 104 | |||
| 105 | #define VDSO_USEFUL | ||
| 106 | #define VDSO_CGT32_SYM "__vdso_clock_gettime" | ||
| 107 | #define VDSO_CGT32_VER "LINUX_2.6" | ||
| 108 | #define VDSO_CGT_SYM "__vdso_clock_gettime64" | ||
| 109 | #define VDSO_CGT_VER "LINUX_2.6" | ||
| 110 | #define VDSO_CGT_WORKAROUND 1 |
lib/libc/musl/arch/i386/arch.mak deleted-1| ... | @@ -1 +0,0 @@ | ||
| 1 | COMPAT_SRC_DIRS = compat/time32 | ||
lib/libc/musl/arch/m68k/arch.mak deleted-1| ... | @@ -1 +0,0 @@ | ||
| 1 | COMPAT_SRC_DIRS = compat/time32 | ||
lib/libc/musl/arch/mips/arch.mak deleted-1| ... | @@ -1 +0,0 @@ | ||
| 1 | COMPAT_SRC_DIRS = compat/time32 | ||
lib/libc/musl/arch/mips/bits/signal.h-1| ... | @@ -66,7 +66,6 @@ typedef struct __ucontext { | ... | @@ -66,7 +66,6 @@ typedef struct __ucontext { |
| 66 | #define SA_RESTART 0x10000000 | 66 | #define SA_RESTART 0x10000000 |
| 67 | #define SA_NODEFER 0x40000000 | 67 | #define SA_NODEFER 0x40000000 |
| 68 | #define SA_RESETHAND 0x80000000 | 68 | #define SA_RESETHAND 0x80000000 |
| 69 | #define SA_RESTORER 0x04000000 | ||
| 70 | 69 | ||
| 71 | #undef SIG_BLOCK | 70 | #undef SIG_BLOCK |
| 72 | #undef SIG_UNBLOCK | 71 | #undef SIG_UNBLOCK |
lib/libc/musl/arch/mips/ksigaction.h+1-4| ... | @@ -4,10 +4,7 @@ struct k_sigaction { | ... | @@ -4,10 +4,7 @@ struct k_sigaction { |
| 4 | 	unsigned flags; | 4 | 	unsigned flags; |
| 5 | 	void (*handler)(int); | 5 | 	void (*handler)(int); |
| 6 | 	unsigned long mask[4]; | 6 | 	unsigned long mask[4]; |
| 7 | 	/* The following field is past the end of the structure the | 7 | 	void *unused; |
| 8 | 	 * kernel will read or write, and exists only to avoid having | ||
| 9 | 	 * mips-specific preprocessor conditionals in sigaction.c. */ | ||
| 10 | 	void (*restorer)(); | ||
| 11 | }; | 8 | }; |
| 12 | 9 | ||
| 13 | hidden void __restore(), __restore_rt(); | 10 | hidden void __restore(), __restore_rt(); |
lib/libc/musl/arch/mips/reloc.h+1| ... | @@ -29,6 +29,7 @@ | ... | @@ -29,6 +29,7 @@ |
| 29 | 29 | ||
| 30 | #define NEED_MIPS_GOT_RELOCS 1 | 30 | #define NEED_MIPS_GOT_RELOCS 1 |
| 31 | #define DT_DEBUG_INDIRECT DT_MIPS_RLD_MAP | 31 | #define DT_DEBUG_INDIRECT DT_MIPS_RLD_MAP |
| 32 | #define DT_DEBUG_INDIRECT_REL DT_MIPS_RLD_MAP_REL | ||
| 32 | #define ARCH_SYM_REJECT_UND(s) (!((s)->st_other & STO_MIPS_PLT)) | 33 | #define ARCH_SYM_REJECT_UND(s) (!((s)->st_other & STO_MIPS_PLT)) |
| 33 | 34 | ||
| 34 | #define CRTJMP(pc,sp) __asm__ __volatile__( \ | 35 | #define CRTJMP(pc,sp) __asm__ __volatile__( \ |
lib/libc/musl/arch/mips64/bits/signal.h-1| ... | @@ -85,7 +85,6 @@ typedef struct __ucontext { | ... | @@ -85,7 +85,6 @@ typedef struct __ucontext { |
| 85 | #define SA_RESTART 0x10000000 | 85 | #define SA_RESTART 0x10000000 |
| 86 | #define SA_NODEFER 0x40000000 | 86 | #define SA_NODEFER 0x40000000 |
| 87 | #define SA_RESETHAND 0x80000000 | 87 | #define SA_RESETHAND 0x80000000 |
| 88 | #define SA_RESTORER 0x04000000 | ||
| 89 | 88 | ||
| 90 | #undef SIG_BLOCK | 89 | #undef SIG_BLOCK |
| 91 | #undef SIG_UNBLOCK | 90 | #undef SIG_UNBLOCK |
lib/libc/musl/arch/mips64/ksigaction.h+1-1| ... | @@ -4,7 +4,7 @@ struct k_sigaction { | ... | @@ -4,7 +4,7 @@ struct k_sigaction { |
| 4 | 	unsigned flags; | 4 | 	unsigned flags; |
| 5 | 	void (*handler)(int); | 5 | 	void (*handler)(int); |
| 6 | 	unsigned long mask[2]; | 6 | 	unsigned long mask[2]; |
| 7 | 	void (*restorer)(); | 7 | 	void *unused; |
| 8 | }; | 8 | }; |
| 9 | 9 | ||
| 10 | hidden void __restore(), __restore_rt(); | 10 | hidden void __restore(), __restore_rt(); |
lib/libc/musl/arch/mips64/reloc.h+1| ... | @@ -38,6 +38,7 @@ | ... | @@ -38,6 +38,7 @@ |
| 38 | 38 | ||
| 39 | #define NEED_MIPS_GOT_RELOCS 1 | 39 | #define NEED_MIPS_GOT_RELOCS 1 |
| 40 | #define DT_DEBUG_INDIRECT DT_MIPS_RLD_MAP | 40 | #define DT_DEBUG_INDIRECT DT_MIPS_RLD_MAP |
| 41 | #define DT_DEBUG_INDIRECT_REL DT_MIPS_RLD_MAP_REL | ||
| 41 | #define ARCH_SYM_REJECT_UND(s) (!((s)->st_other & STO_MIPS_PLT)) | 42 | #define ARCH_SYM_REJECT_UND(s) (!((s)->st_other & STO_MIPS_PLT)) |
| 42 | 43 | ||
| 43 | #define CRTJMP(pc,sp) __asm__ __volatile__( \ | 44 | #define CRTJMP(pc,sp) __asm__ __volatile__( \ |
lib/libc/musl/arch/powerpc/arch.mak deleted-1| ... | @@ -1 +0,0 @@ | ||
| 1 | COMPAT_SRC_DIRS = compat/time32 | ||
lib/libc/musl/arch/riscv64/bits/signal.h-1| ... | @@ -76,7 +76,6 @@ typedef struct __ucontext | ... | @@ -76,7 +76,6 @@ typedef struct __ucontext |
| 76 | #define SA_RESTART 0x10000000 | 76 | #define SA_RESTART 0x10000000 |
| 77 | #define SA_NODEFER 0x40000000 | 77 | #define SA_NODEFER 0x40000000 |
| 78 | #define SA_RESETHAND 0x80000000 | 78 | #define SA_RESETHAND 0x80000000 |
| 79 | #define SA_RESTORER 0x04000000 | ||
| 80 | 79 | ||
| 81 | #endif | 80 | #endif |
| 82 | 81 |
lib/libc/musl/compat/time32/__xstat.c+4-4| ... | @@ -3,22 +3,22 @@ | ... | @@ -3,22 +3,22 @@ |
| 3 | 3 | ||
| 4 | struct stat32; | 4 | struct stat32; |
| 5 | 5 | ||
| 6 | int __fxstat64(int ver, int fd, struct stat32 *buf) | 6 | int __fxstat(int ver, int fd, struct stat32 *buf) |
| 7 | { | 7 | { |
| 8 | 	return __fstat_time32(fd, buf); | 8 | 	return __fstat_time32(fd, buf); |
| 9 | } | 9 | } |
| 10 | 10 | ||
| 11 | int __fxstatat64(int ver, int fd, const char *path, struct stat32 *buf, int flag) | 11 | int __fxstatat(int ver, int fd, const char *path, struct stat32 *buf, int flag) |
| 12 | { | 12 | { |
| 13 | 	return __fstatat_time32(fd, path, buf, flag); | 13 | 	return __fstatat_time32(fd, path, buf, flag); |
| 14 | } | 14 | } |
| 15 | 15 | ||
| 16 | int __lxstat64(int ver, const char *path, struct stat32 *buf) | 16 | int __lxstat(int ver, const char *path, struct stat32 *buf) |
| 17 | { | 17 | { |
| 18 | 	return __lstat_time32(path, buf); | 18 | 	return __lstat_time32(path, buf); |
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | int __xstat64(int ver, const char *path, struct stat32 *buf) | 21 | int __xstat(int ver, const char *path, struct stat32 *buf) |
| 22 | { | 22 | { |
| 23 | 	return __stat_time32(path, buf); | 23 | 	return __stat_time32(path, buf); |
| 24 | } | 24 | } |
lib/libc/musl/compat/time32/aio_suspend_time32.c-2| ... | @@ -7,5 +7,3 @@ int __aio_suspend_time32(const struct aiocb *const cbs[], int cnt, const struct | ... | @@ -7,5 +7,3 @@ int __aio_suspend_time32(const struct aiocb *const cbs[], int cnt, const struct |
| 7 | 	return aio_suspend(cbs, cnt, ts32 ? (&(struct timespec){ | 7 | 	return aio_suspend(cbs, cnt, ts32 ? (&(struct timespec){ |
| 8 | 		.tv_sec = ts32->tv_sec, .tv_nsec = ts32->tv_nsec}) : 0); | 8 | 		.tv_sec = ts32->tv_sec, .tv_nsec = ts32->tv_nsec}) : 0); |
| 9 | } | 9 | } |
| 10 | |||
| 11 | weak_alias(aio_suspend, aio_suspend64); |
lib/libc/musl/compat/time32/fstat_time32.c-2| ... | @@ -13,5 +13,3 @@ int __fstat_time32(int fd, struct stat32 *restrict st32) | ... | @@ -13,5 +13,3 @@ int __fstat_time32(int fd, struct stat32 *restrict st32) |
| 13 | 	if (!r) memcpy(st32, &st, offsetof(struct stat, st_atim)); | 13 | 	if (!r) memcpy(st32, &st, offsetof(struct stat, st_atim)); |
| 14 | 	return r; | 14 | 	return r; |
| 15 | } | 15 | } |
| 16 | |||
| 17 | weak_alias(fstat, fstat64); |
lib/libc/musl/compat/time32/fstatat_time32.c-2| ... | @@ -13,5 +13,3 @@ int __fstatat_time32(int fd, const char *restrict path, struct stat32 *restrict | ... | @@ -13,5 +13,3 @@ int __fstatat_time32(int fd, const char *restrict path, struct stat32 *restrict |
| 13 | 	if (!r) memcpy(st32, &st, offsetof(struct stat, st_atim)); | 13 | 	if (!r) memcpy(st32, &st, offsetof(struct stat, st_atim)); |
| 14 | 	return r; | 14 | 	return r; |
| 15 | } | 15 | } |
| 16 | |||
| 17 | weak_alias(fstatat, fstatat64); |
lib/libc/musl/compat/time32/lstat_time32.c-2| ... | @@ -13,5 +13,3 @@ int __lstat_time32(const char *restrict path, struct stat32 *restrict st32) | ... | @@ -13,5 +13,3 @@ int __lstat_time32(const char *restrict path, struct stat32 *restrict st32) |
| 13 | 	if (!r) memcpy(st32, &st, offsetof(struct stat, st_atim)); | 13 | 	if (!r) memcpy(st32, &st, offsetof(struct stat, st_atim)); |
| 14 | 	return r; | 14 | 	return r; |
| 15 | } | 15 | } |
| 16 | |||
| 17 | weak_alias(lstat, lstat64); |
lib/libc/musl/compat/time32/stat_time32.c-2| ... | @@ -13,5 +13,3 @@ int __stat_time32(const char *restrict path, struct stat32 *restrict st32) | ... | @@ -13,5 +13,3 @@ int __stat_time32(const char *restrict path, struct stat32 *restrict st32) |
| 13 | 	if (!r) memcpy(st32, &st, offsetof(struct stat, st_atim)); | 13 | 	if (!r) memcpy(st32, &st, offsetof(struct stat, st_atim)); |
| 14 | 	return r; | 14 | 	return r; |
| 15 | } | 15 | } |
| 16 | |||
| 17 | weak_alias(stat, stat64); |
lib/libc/musl/include/aio.h+1-1| ... | @@ -49,7 +49,7 @@ int aio_fsync(int, struct aiocb *); | ... | @@ -49,7 +49,7 @@ int aio_fsync(int, struct aiocb *); |
| 49 | 49 | ||
| 50 | int lio_listio(int, struct aiocb *__restrict const *__restrict, int, struct sigevent *__restrict); | 50 | int lio_listio(int, struct aiocb *__restrict const *__restrict, int, struct sigevent *__restrict); |
| 51 | 51 | ||
| 52 | #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) | 52 | #if defined(_LARGEFILE64_SOURCE) |
| 53 | #define aiocb64 aiocb | 53 | #define aiocb64 aiocb |
| 54 | #define aio_read64 aio_read | 54 | #define aio_read64 aio_read |
| 55 | #define aio_write64 aio_write | 55 | #define aio_write64 aio_write |
lib/libc/musl/include/arpa/nameser.h+71| ... | @@ -188,6 +188,36 @@ typedef enum __ns_type { | ... | @@ -188,6 +188,36 @@ typedef enum __ns_type { |
| 188 | 	ns_t_sink = 40, | 188 | 	ns_t_sink = 40, |
| 189 | 	ns_t_opt = 41, | 189 | 	ns_t_opt = 41, |
| 190 | 	ns_t_apl = 42, | 190 | 	ns_t_apl = 42, |
| 191 | 	ns_t_ds = 43, | ||
| 192 | 	ns_t_sshfp = 44, | ||
| 193 | 	ns_t_ipseckey = 45, | ||
| 194 | 	ns_t_rrsig = 46, | ||
| 195 | 	ns_t_nsec = 47, | ||
| 196 | 	ns_t_dnskey = 48, | ||
| 197 | 	ns_t_dhcid = 49, | ||
| 198 | 	ns_t_nsec3 = 50, | ||
| 199 | 	ns_t_nsec3param = 51, | ||
| 200 | 	ns_t_tlsa = 52, | ||
| 201 | 	ns_t_smimea = 53, | ||
| 202 | 	ns_t_hip = 55, | ||
| 203 | 	ns_t_ninfo = 56, | ||
| 204 | 	ns_t_rkey = 57, | ||
| 205 | 	ns_t_talink = 58, | ||
| 206 | 	ns_t_cds = 59, | ||
| 207 | 	ns_t_cdnskey = 60, | ||
| 208 | 	ns_t_openpgpkey = 61, | ||
| 209 | 	ns_t_csync = 62, | ||
| 210 | 	ns_t_spf = 99, | ||
| 211 | 	ns_t_uinfo = 100, | ||
| 212 | 	ns_t_uid = 101, | ||
| 213 | 	ns_t_gid = 102, | ||
| 214 | 	ns_t_unspec = 103, | ||
| 215 | 	ns_t_nid = 104, | ||
| 216 | 	ns_t_l32 = 105, | ||
| 217 | 	ns_t_l64 = 106, | ||
| 218 | 	ns_t_lp = 107, | ||
| 219 | 	ns_t_eui48 = 108, | ||
| 220 | 	ns_t_eui64 = 109, | ||
| 191 | 	ns_t_tkey = 249, | 221 | 	ns_t_tkey = 249, |
| 192 | 	ns_t_tsig = 250, | 222 | 	ns_t_tsig = 250, |
| 193 | 	ns_t_ixfr = 251, | 223 | 	ns_t_ixfr = 251, |
| ... | @@ -196,6 +226,11 @@ typedef enum __ns_type { | ... | @@ -196,6 +226,11 @@ typedef enum __ns_type { |
| 196 | 	ns_t_maila = 254, | 226 | 	ns_t_maila = 254, |
| 197 | 	ns_t_any = 255, | 227 | 	ns_t_any = 255, |
| 198 | 	ns_t_zxfr = 256, | 228 | 	ns_t_zxfr = 256, |
| 229 | 	ns_t_uri = 256, | ||
| 230 | 	ns_t_caa = 257, | ||
| 231 | 	ns_t_avc = 258, | ||
| 232 | 	ns_t_ta = 32768, | ||
| 233 | 	ns_t_dlv = 32769, | ||
| 199 | 	ns_t_max = 65536 | 234 | 	ns_t_max = 65536 |
| 200 | } ns_type; | 235 | } ns_type; |
| 201 | 236 | ||
| ... | @@ -430,12 +465,48 @@ typedef struct { | ... | @@ -430,12 +465,48 @@ typedef struct { |
| 430 | #define T_NAPTR		ns_t_naptr | 465 | #define T_NAPTR		ns_t_naptr |
| 431 | #define T_A6		ns_t_a6 | 466 | #define T_A6		ns_t_a6 |
| 432 | #define T_DNAME		ns_t_dname | 467 | #define T_DNAME		ns_t_dname |
| 468 | #define T_DS		ns_t_ds | ||
| 469 | #define T_SSHFP		ns_t_sshfp | ||
| 470 | #define T_IPSECKEY	ns_t_ipseckey | ||
| 471 | #define T_RRSIG		ns_t_rrsig | ||
| 472 | #define T_NSEC		ns_t_nsec | ||
| 473 | #define T_DNSKEY	ns_t_dnskey | ||
| 474 | #define T_DHCID		ns_t_dhcid | ||
| 475 | #define T_NSEC3		ns_t_nsec3 | ||
| 476 | #define T_NSEC3PARAM	ns_t_nsec3param | ||
| 477 | #define T_TLSA		ns_t_tlsa | ||
| 478 | #define T_SMIMEA	ns_t_smimea | ||
| 479 | #define T_HIP		ns_t_hip | ||
| 480 | #define T_NINFO		ns_t_ninfo | ||
| 481 | #define T_RKEY		ns_t_rkey | ||
| 482 | #define T_TALINK	ns_t_talink | ||
| 483 | #define T_CDS		ns_t_cds | ||
| 484 | #define T_CDNSKEY	ns_t_cdnskey | ||
| 485 | #define T_OPENPGPKEY	ns_t_openpgpkey | ||
| 486 | #define T_CSYNC		ns_t_csync | ||
| 487 | #define T_SPF		ns_t_spf | ||
| 488 | #define T_UINFO		ns_t_uinfo | ||
| 489 | #define T_UID		ns_t_uid | ||
| 490 | #define T_GID		ns_t_gid | ||
| 491 | #define T_UNSPEC	ns_t_unspec | ||
| 492 | #define T_NID		ns_t_nid | ||
| 493 | #define T_L32		ns_t_l32 | ||
| 494 | #define T_L64		ns_t_l64 | ||
| 495 | #define T_LP		ns_t_lp | ||
| 496 | #define T_EUI48		ns_t_eui48 | ||
| 497 | #define T_EUI64		ns_t_eui64 | ||
| 498 | #define T_TKEY		ns_t_tkey | ||
| 433 | #define	T_TSIG		ns_t_tsig | 499 | #define	T_TSIG		ns_t_tsig |
| 434 | #define	T_IXFR		ns_t_ixfr | 500 | #define	T_IXFR		ns_t_ixfr |
| 435 | #define T_AXFR		ns_t_axfr | 501 | #define T_AXFR		ns_t_axfr |
| 436 | #define T_MAILB		ns_t_mailb | 502 | #define T_MAILB		ns_t_mailb |
| 437 | #define T_MAILA		ns_t_maila | 503 | #define T_MAILA		ns_t_maila |
| 438 | #define T_ANY		ns_t_any | 504 | #define T_ANY		ns_t_any |
| 505 | #define T_URI		ns_t_uri | ||
| 506 | #define T_CAA		ns_t_caa | ||
| 507 | #define T_AVC		ns_t_avc | ||
| 508 | #define T_TA		ns_t_ta | ||
| 509 | #define T_DLV		ns_t_dlv | ||
| 439 | 510 | ||
| 440 | #define C_IN		ns_c_in | 511 | #define C_IN		ns_c_in |
| 441 | #define C_CHAOS		ns_c_chaos | 512 | #define C_CHAOS		ns_c_chaos |
lib/libc/musl/include/dirent.h+1-1| ... | @@ -56,7 +56,7 @@ int getdents(int, struct dirent *, size_t); | ... | @@ -56,7 +56,7 @@ int getdents(int, struct dirent *, size_t); |
| 56 | int versionsort(const struct dirent **, const struct dirent **); | 56 | int versionsort(const struct dirent **, const struct dirent **); |
| 57 | #endif | 57 | #endif |
| 58 | 58 | ||
| 59 | #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) | 59 | #if defined(_LARGEFILE64_SOURCE) |
| 60 | #define dirent64 dirent | 60 | #define dirent64 dirent |
| 61 | #define readdir64 readdir | 61 | #define readdir64 readdir |
| 62 | #define readdir64_r readdir_r | 62 | #define readdir64_r readdir_r |
lib/libc/musl/include/elf.h+7-2| ... | @@ -385,7 +385,8 @@ typedef struct { | ... | @@ -385,7 +385,8 @@ typedef struct { |
| 385 | #define SHT_PREINIT_ARRAY 16 | 385 | #define SHT_PREINIT_ARRAY 16 |
| 386 | #define SHT_GROUP	 17 | 386 | #define SHT_GROUP	 17 |
| 387 | #define SHT_SYMTAB_SHNDX 18 | 387 | #define SHT_SYMTAB_SHNDX 18 |
| 388 | #define	SHT_NUM		 19 | 388 | #define SHT_RELR	 19 |
| 389 | #define	SHT_NUM		 20 | ||
| 389 | #define SHT_LOOS	 0x60000000 | 390 | #define SHT_LOOS	 0x60000000 |
| 390 | #define SHT_GNU_ATTRIBUTES 0x6ffffff5 | 391 | #define SHT_GNU_ATTRIBUTES 0x6ffffff5 |
| 391 | #define SHT_GNU_HASH	 0x6ffffff6 | 392 | #define SHT_GNU_HASH	 0x6ffffff6 |
| ... | @@ -436,6 +437,7 @@ typedef struct { | ... | @@ -436,6 +437,7 @@ typedef struct { |
| 436 | } Elf64_Chdr; | 437 | } Elf64_Chdr; |
| 437 | 438 | ||
| 438 | #define ELFCOMPRESS_ZLIB	1 | 439 | #define ELFCOMPRESS_ZLIB	1 |
| 440 | #define ELFCOMPRESS_ZSTD	2 | ||
| 439 | #define ELFCOMPRESS_LOOS	0x60000000 | 441 | #define ELFCOMPRESS_LOOS	0x60000000 |
| 440 | #define ELFCOMPRESS_HIOS	0x6fffffff | 442 | #define ELFCOMPRESS_HIOS	0x6fffffff |
| 441 | #define ELFCOMPRESS_LOPROC	0x70000000 | 443 | #define ELFCOMPRESS_LOPROC	0x70000000 |
| ... | @@ -754,7 +756,10 @@ typedef struct { | ... | @@ -754,7 +756,10 @@ typedef struct { |
| 754 | #define DT_PREINIT_ARRAY 32 | 756 | #define DT_PREINIT_ARRAY 32 |
| 755 | #define DT_PREINIT_ARRAYSZ 33 | 757 | #define DT_PREINIT_ARRAYSZ 33 |
| 756 | #define DT_SYMTAB_SHNDX	34 | 758 | #define DT_SYMTAB_SHNDX	34 |
| 757 | #define	DT_NUM		35 | 759 | #define DT_RELRSZ	35 |
| 760 | #define DT_RELR		36 | ||
| 761 | #define DT_RELRENT	37 | ||
| 762 | #define	DT_NUM		38 | ||
| 758 | #define DT_LOOS		0x6000000d | 763 | #define DT_LOOS		0x6000000d |
| 759 | #define DT_HIOS		0x6ffff000 | 764 | #define DT_HIOS		0x6ffff000 |
| 760 | #define DT_LOPROC	0x70000000 | 765 | #define DT_LOPROC	0x70000000 |
lib/libc/musl/include/fcntl.h+1-1| ... | @@ -195,7 +195,7 @@ ssize_t tee(int, int, size_t, unsigned); | ... | @@ -195,7 +195,7 @@ ssize_t tee(int, int, size_t, unsigned); |
| 195 | #define loff_t off_t | 195 | #define loff_t off_t |
| 196 | #endif | 196 | #endif |
| 197 | 197 | ||
| 198 | #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) | 198 | #if defined(_LARGEFILE64_SOURCE) |
| 199 | #define F_GETLK64 F_GETLK | 199 | #define F_GETLK64 F_GETLK |
| 200 | #define F_SETLK64 F_SETLK | 200 | #define F_SETLK64 F_SETLK |
| 201 | #define F_SETLKW64 F_SETLKW | 201 | #define F_SETLKW64 F_SETLKW |
lib/libc/musl/include/ftw.h+1-1| ... | @@ -29,7 +29,7 @@ struct FTW { | ... | @@ -29,7 +29,7 @@ struct FTW { |
| 29 | int ftw(const char *, int (*)(const char *, const struct stat *, int), int); | 29 | int ftw(const char *, int (*)(const char *, const struct stat *, int), int); |
| 30 | int nftw(const char *, int (*)(const char *, const struct stat *, int, struct FTW *), int, int); | 30 | int nftw(const char *, int (*)(const char *, const struct stat *, int, struct FTW *), int, int); |
| 31 | 31 | ||
| 32 | #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) | 32 | #if defined(_LARGEFILE64_SOURCE) |
| 33 | #define ftw64 ftw | 33 | #define ftw64 ftw |
| 34 | #define nftw64 nftw | 34 | #define nftw64 nftw |
| 35 | #endif | 35 | #endif |
lib/libc/musl/include/glob.h+1-1| ... | @@ -39,7 +39,7 @@ void globfree(glob_t *); | ... | @@ -39,7 +39,7 @@ void globfree(glob_t *); |
| 39 | #define GLOB_NOMATCH 3 | 39 | #define GLOB_NOMATCH 3 |
| 40 | #define GLOB_NOSYS 4 | 40 | #define GLOB_NOSYS 4 |
| 41 | 41 | ||
| 42 | #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) | 42 | #if defined(_LARGEFILE64_SOURCE) |
| 43 | #define glob64 glob | 43 | #define glob64 glob |
| 44 | #define globfree64 globfree | 44 | #define globfree64 globfree |
| 45 | #define glob64_t glob_t | 45 | #define glob64_t glob_t |
lib/libc/musl/include/netdb.h+1| ... | @@ -44,6 +44,7 @@ struct addrinfo { | ... | @@ -44,6 +44,7 @@ struct addrinfo { |
| 44 | #define EAI_NONAME -2 | 44 | #define EAI_NONAME -2 |
| 45 | #define EAI_AGAIN -3 | 45 | #define EAI_AGAIN -3 |
| 46 | #define EAI_FAIL -4 | 46 | #define EAI_FAIL -4 |
| 47 | #define EAI_NODATA -5 | ||
| 47 | #define EAI_FAMILY -6 | 48 | #define EAI_FAMILY -6 |
| 48 | #define EAI_SOCKTYPE -7 | 49 | #define EAI_SOCKTYPE -7 |
| 49 | #define EAI_SERVICE -8 | 50 | #define EAI_SERVICE -8 |
lib/libc/musl/include/sched.h+1-1| ... | @@ -124,7 +124,7 @@ __CPU_op_func_S(XOR, ^) | ... | @@ -124,7 +124,7 @@ __CPU_op_func_S(XOR, ^) |
| 124 | #define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n))) | 124 | #define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n))) |
| 125 | #define CPU_FREE(set) free(set) | 125 | #define CPU_FREE(set) free(set) |
| 126 | 126 | ||
| 127 | #define CPU_SETSIZE 128 | 127 | #define CPU_SETSIZE 1024 |
| 128 | 128 | ||
| 129 | #define CPU_SET(i, set) CPU_SET_S(i,sizeof(cpu_set_t),set) | 129 | #define CPU_SET(i, set) CPU_SET_S(i,sizeof(cpu_set_t),set) |
| 130 | #define CPU_CLR(i, set) CPU_CLR_S(i,sizeof(cpu_set_t),set) | 130 | #define CPU_CLR(i, set) CPU_CLR_S(i,sizeof(cpu_set_t),set) |
lib/libc/musl/include/stdio.h+1-1| ... | @@ -205,7 +205,7 @@ typedef struct _IO_cookie_io_functions_t { | ... | @@ -205,7 +205,7 @@ typedef struct _IO_cookie_io_functions_t { |
| 205 | FILE *fopencookie(void *, const char *, cookie_io_functions_t); | 205 | FILE *fopencookie(void *, const char *, cookie_io_functions_t); |
| 206 | #endif | 206 | #endif |
| 207 | 207 | ||
| 208 | #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) | 208 | #if defined(_LARGEFILE64_SOURCE) |
| 209 | #define tmpfile64 tmpfile | 209 | #define tmpfile64 tmpfile |
| 210 | #define fopen64 fopen | 210 | #define fopen64 fopen |
| 211 | #define freopen64 freopen | 211 | #define freopen64 freopen |
lib/libc/musl/include/stdlib.h+2-2| ... | @@ -95,7 +95,7 @@ size_t __ctype_get_mb_cur_max(void); | ... | @@ -95,7 +95,7 @@ size_t __ctype_get_mb_cur_max(void); |
| 95 | #define WTERMSIG(s) ((s) & 0x7f) | 95 | #define WTERMSIG(s) ((s) & 0x7f) |
| 96 | #define WSTOPSIG(s) WEXITSTATUS(s) | 96 | #define WSTOPSIG(s) WEXITSTATUS(s) |
| 97 | #define WIFEXITED(s) (!WTERMSIG(s)) | 97 | #define WIFEXITED(s) (!WTERMSIG(s)) |
| 98 | #define WIFSTOPPED(s) ((short)((((s)&0xffff)*0x10001)>>8) > 0x7f00) | 98 | #define WIFSTOPPED(s) ((short)((((s)&0xffff)*0x10001U)>>8) > 0x7f00) |
| 99 | #define WIFSIGNALED(s) (((s)&0xffff)-1U < 0xffu) | 99 | #define WIFSIGNALED(s) (((s)&0xffff)-1U < 0xffu) |
| 100 | 100 | ||
| 101 | int posix_memalign (void **, size_t, size_t); | 101 | int posix_memalign (void **, size_t, size_t); |
| ... | @@ -163,7 +163,7 @@ double strtod_l(const char *__restrict, char **__restrict, struct __locale_struc | ... | @@ -163,7 +163,7 @@ double strtod_l(const char *__restrict, char **__restrict, struct __locale_struc |
| 163 | long double strtold_l(const char *__restrict, char **__restrict, struct __locale_struct *); | 163 | long double strtold_l(const char *__restrict, char **__restrict, struct __locale_struct *); |
| 164 | #endif | 164 | #endif |
| 165 | 165 | ||
| 166 | #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) | 166 | #if defined(_LARGEFILE64_SOURCE) |
| 167 | #define mkstemp64 mkstemp | 167 | #define mkstemp64 mkstemp |
| 168 | #define mkostemp64 mkostemp | 168 | #define mkostemp64 mkostemp |
| 169 | #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) | 169 | #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) |
lib/libc/musl/include/string.h+1-1| ... | @@ -73,6 +73,7 @@ char *strsignal(int); | ... | @@ -73,6 +73,7 @@ char *strsignal(int); |
| 73 | char *strerror_l (int, locale_t); | 73 | char *strerror_l (int, locale_t); |
| 74 | int strcoll_l (const char *, const char *, locale_t); | 74 | int strcoll_l (const char *, const char *, locale_t); |
| 75 | size_t strxfrm_l (char *__restrict, const char *__restrict, size_t, locale_t); | 75 | size_t strxfrm_l (char *__restrict, const char *__restrict, size_t, locale_t); |
| 76 | void *memmem(const void *, size_t, const void *, size_t); | ||
| 76 | #endif | 77 | #endif |
| 77 | 78 | ||
| 78 | #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ | 79 | #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ |
| ... | @@ -92,7 +93,6 @@ void explicit_bzero (void *, size_t); | ... | @@ -92,7 +93,6 @@ void explicit_bzero (void *, size_t); |
| 92 | int strverscmp (const char *, const char *); | 93 | int strverscmp (const char *, const char *); |
| 93 | char *strchrnul(const char *, int); | 94 | char *strchrnul(const char *, int); |
| 94 | char *strcasestr(const char *, const char *); | 95 | char *strcasestr(const char *, const char *); |
| 95 | void *memmem(const void *, size_t, const void *, size_t); | ||
| 96 | void *memrchr(const void *, int, size_t); | 96 | void *memrchr(const void *, int, size_t); |
| 97 | void *mempcpy(void *, const void *, size_t); | 97 | void *mempcpy(void *, const void *, size_t); |
| 98 | #ifndef __cplusplus | 98 | #ifndef __cplusplus |
lib/libc/musl/include/strings.h+1| ... | @@ -5,6 +5,7 @@ | ... | @@ -5,6 +5,7 @@ |
| 5 | extern "C" { | 5 | extern "C" { |
| 6 | #endif | 6 | #endif |
| 7 | 7 | ||
| 8 | #include <features.h> | ||
| 8 | 9 | ||
| 9 | #define __NEED_size_t | 10 | #define __NEED_size_t |
| 10 | #define __NEED_locale_t | 11 | #define __NEED_locale_t |
lib/libc/musl/include/sys/mman.h+1-1| ... | @@ -141,7 +141,7 @@ int mincore (void *, size_t, unsigned char *); | ... | @@ -141,7 +141,7 @@ int mincore (void *, size_t, unsigned char *); |
| 141 | int shm_open (const char *, int, mode_t); | 141 | int shm_open (const char *, int, mode_t); |
| 142 | int shm_unlink (const char *); | 142 | int shm_unlink (const char *); |
| 143 | 143 | ||
| 144 | #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) | 144 | #if defined(_LARGEFILE64_SOURCE) |
| 145 | #define mmap64 mmap | 145 | #define mmap64 mmap |
| 146 | #define off64_t off_t | 146 | #define off64_t off_t |
| 147 | #endif | 147 | #endif |
lib/libc/musl/include/sys/resource.h+1-1| ... | @@ -95,7 +95,7 @@ int prlimit(pid_t, int, const struct rlimit *, struct rlimit *); | ... | @@ -95,7 +95,7 @@ int prlimit(pid_t, int, const struct rlimit *, struct rlimit *); |
| 95 | 95 | ||
| 96 | #define RLIM_NLIMITS RLIMIT_NLIMITS | 96 | #define RLIM_NLIMITS RLIMIT_NLIMITS |
| 97 | 97 | ||
| 98 | #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) | 98 | #if defined(_LARGEFILE64_SOURCE) |
| 99 | #define RLIM64_INFINITY RLIM_INFINITY | 99 | #define RLIM64_INFINITY RLIM_INFINITY |
| 100 | #define RLIM64_SAVED_CUR RLIM_SAVED_CUR | 100 | #define RLIM64_SAVED_CUR RLIM_SAVED_CUR |
| 101 | #define RLIM64_SAVED_MAX RLIM_SAVED_MAX | 101 | #define RLIM64_SAVED_MAX RLIM_SAVED_MAX |
lib/libc/musl/include/sys/sendfile.h+1-1| ... | @@ -10,7 +10,7 @@ extern "C" { | ... | @@ -10,7 +10,7 @@ extern "C" { |
| 10 | 10 | ||
| 11 | ssize_t sendfile(int, int, off_t *, size_t); | 11 | ssize_t sendfile(int, int, off_t *, size_t); |
| 12 | 12 | ||
| 13 | #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) | 13 | #if defined(_LARGEFILE64_SOURCE) |
| 14 | #define sendfile64 sendfile | 14 | #define sendfile64 sendfile |
| 15 | #define off64_t off_t | 15 | #define off64_t off_t |
| 16 | #endif | 16 | #endif |
lib/libc/musl/include/sys/stat.h+1-1| ... | @@ -98,7 +98,7 @@ int lchmod(const char *, mode_t); | ... | @@ -98,7 +98,7 @@ int lchmod(const char *, mode_t); |
| 98 | #define S_IEXEC S_IXUSR | 98 | #define S_IEXEC S_IXUSR |
| 99 | #endif | 99 | #endif |
| 100 | 100 | ||
| 101 | #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) | 101 | #if defined(_LARGEFILE64_SOURCE) |
| 102 | #define stat64 stat | 102 | #define stat64 stat |
| 103 | #define fstat64 fstat | 103 | #define fstat64 fstat |
| 104 | #define lstat64 lstat | 104 | #define lstat64 lstat |
lib/libc/musl/include/sys/statfs.h+1-1| ... | @@ -18,7 +18,7 @@ typedef struct __fsid_t { | ... | @@ -18,7 +18,7 @@ typedef struct __fsid_t { |
| 18 | int statfs (const char *, struct statfs *); | 18 | int statfs (const char *, struct statfs *); |
| 19 | int fstatfs (int, struct statfs *); | 19 | int fstatfs (int, struct statfs *); |
| 20 | 20 | ||
| 21 | #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) | 21 | #if defined(_LARGEFILE64_SOURCE) |
| 22 | #define statfs64 statfs | 22 | #define statfs64 statfs |
| 23 | #define fstatfs64 fstatfs | 23 | #define fstatfs64 fstatfs |
| 24 | #define fsblkcnt64_t fsblkcnt_t | 24 | #define fsblkcnt64_t fsblkcnt_t |
lib/libc/musl/include/sys/statvfs.h+1-1| ... | @@ -42,7 +42,7 @@ int fstatvfs (int, struct statvfs *); | ... | @@ -42,7 +42,7 @@ int fstatvfs (int, struct statvfs *); |
| 42 | #define ST_NODIRATIME 2048 | 42 | #define ST_NODIRATIME 2048 |
| 43 | #define ST_RELATIME 4096 | 43 | #define ST_RELATIME 4096 |
| 44 | 44 | ||
| 45 | #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) | 45 | #if defined(_LARGEFILE64_SOURCE) |
| 46 | #define statvfs64 statvfs | 46 | #define statvfs64 statvfs |
| 47 | #define fstatvfs64 fstatvfs | 47 | #define fstatvfs64 fstatvfs |
| 48 | #define fsblkcnt64_t fsblkcnt_t | 48 | #define fsblkcnt64_t fsblkcnt_t |
lib/libc/musl/include/sys/types.h+1-1| ... | @@ -71,7 +71,7 @@ typedef unsigned long long u_quad_t; | ... | @@ -71,7 +71,7 @@ typedef unsigned long long u_quad_t; |
| 71 | #include <sys/select.h> | 71 | #include <sys/select.h> |
| 72 | #endif | 72 | #endif |
| 73 | 73 | ||
| 74 | #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) | 74 | #if defined(_LARGEFILE64_SOURCE) |
| 75 | #define blkcnt64_t blkcnt_t | 75 | #define blkcnt64_t blkcnt_t |
| 76 | #define fsblkcnt64_t fsblkcnt_t | 76 | #define fsblkcnt64_t fsblkcnt_t |
| 77 | #define fsfilcnt64_t fsfilcnt_t | 77 | #define fsfilcnt64_t fsfilcnt_t |
lib/libc/musl/include/sys/uio.h+1-1| ... | @@ -29,7 +29,7 @@ ssize_t writev (int, const struct iovec *, int); | ... | @@ -29,7 +29,7 @@ ssize_t writev (int, const struct iovec *, int); |
| 29 | #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) | 29 | #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) |
| 30 | ssize_t preadv (int, const struct iovec *, int, off_t); | 30 | ssize_t preadv (int, const struct iovec *, int, off_t); |
| 31 | ssize_t pwritev (int, const struct iovec *, int, off_t); | 31 | ssize_t pwritev (int, const struct iovec *, int, off_t); |
| 32 | #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) | 32 | #if defined(_LARGEFILE64_SOURCE) |
| 33 | #define preadv64 preadv | 33 | #define preadv64 preadv |
| 34 | #define pwritev64 pwritev | 34 | #define pwritev64 pwritev |
| 35 | #define off64_t off_t | 35 | #define off64_t off_t |
lib/libc/musl/include/sys/wait.h+1-1| ... | @@ -50,7 +50,7 @@ pid_t wait4 (pid_t, int *, int, struct rusage *); | ... | @@ -50,7 +50,7 @@ pid_t wait4 (pid_t, int *, int, struct rusage *); |
| 50 | #define WSTOPSIG(s) WEXITSTATUS(s) | 50 | #define WSTOPSIG(s) WEXITSTATUS(s) |
| 51 | #define WCOREDUMP(s) ((s) & 0x80) | 51 | #define WCOREDUMP(s) ((s) & 0x80) |
| 52 | #define WIFEXITED(s) (!WTERMSIG(s)) | 52 | #define WIFEXITED(s) (!WTERMSIG(s)) |
| 53 | #define WIFSTOPPED(s) ((short)((((s)&0xffff)*0x10001)>>8) > 0x7f00) | 53 | #define WIFSTOPPED(s) ((short)((((s)&0xffff)*0x10001U)>>8) > 0x7f00) |
| 54 | #define WIFSIGNALED(s) (((s)&0xffff)-1U < 0xffu) | 54 | #define WIFSIGNALED(s) (((s)&0xffff)-1U < 0xffu) |
| 55 | #define WIFCONTINUED(s) ((s) == 0xffff) | 55 | #define WIFCONTINUED(s) ((s) == 0xffff) |
| 56 | 56 |
lib/libc/musl/include/unistd.h+5-1| ... | @@ -198,7 +198,7 @@ ssize_t copy_file_range(int, off_t *, int, off_t *, size_t, unsigned); | ... | @@ -198,7 +198,7 @@ ssize_t copy_file_range(int, off_t *, int, off_t *, size_t, unsigned); |
| 198 | pid_t gettid(void); | 198 | pid_t gettid(void); |
| 199 | #endif | 199 | #endif |
| 200 | 200 | ||
| 201 | #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) | 201 | #if defined(_LARGEFILE64_SOURCE) |
| 202 | #define lseek64 lseek | 202 | #define lseek64 lseek |
| 203 | #define pread64 pread | 203 | #define pread64 pread |
| 204 | #define pwrite64 pwrite | 204 | #define pwrite64 pwrite |
| ... | @@ -425,6 +425,8 @@ pid_t gettid(void); | ... | @@ -425,6 +425,8 @@ pid_t gettid(void); |
| 425 | #define _SC_XOPEN_STREAMS	246 | 425 | #define _SC_XOPEN_STREAMS	246 |
| 426 | #define _SC_THREAD_ROBUST_PRIO_INHERIT	247 | 426 | #define _SC_THREAD_ROBUST_PRIO_INHERIT	247 |
| 427 | #define _SC_THREAD_ROBUST_PRIO_PROTECT	248 | 427 | #define _SC_THREAD_ROBUST_PRIO_PROTECT	248 |
| 428 | #define _SC_MINSIGSTKSZ	249 | ||
| 429 | #define _SC_SIGSTKSZ	250 | ||
| 428 | 430 | ||
| 429 | #define _CS_PATH	0 | 431 | #define _CS_PATH	0 |
| 430 | #define _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS	1 | 432 | #define _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS	1 |
| ... | @@ -467,6 +469,8 @@ pid_t gettid(void); | ... | @@ -467,6 +469,8 @@ pid_t gettid(void); |
| 467 | #define _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS	1147 | 469 | #define _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS	1147 |
| 468 | #define _CS_V6_ENV	1148 | 470 | #define _CS_V6_ENV	1148 |
| 469 | #define _CS_V7_ENV	1149 | 471 | #define _CS_V7_ENV	1149 |
| 472 | #define _CS_POSIX_V7_THREADS_CFLAGS	1150 | ||
| 473 | #define _CS_POSIX_V7_THREADS_LDFLAGS	1151 | ||
| 470 | 474 | ||
| 471 | #ifdef __cplusplus | 475 | #ifdef __cplusplus |
| 472 | } | 476 | } |
lib/libc/musl/src/aio/aio.c+23-9| ... | @@ -82,6 +82,8 @@ static size_t io_thread_stack_size; | ... | @@ -82,6 +82,8 @@ static size_t io_thread_stack_size; |
| 82 | 82 | ||
| 83 | static struct aio_queue *__aio_get_queue(int fd, int need) | 83 | static struct aio_queue *__aio_get_queue(int fd, int need) |
| 84 | { | 84 | { |
| 85 | 	sigset_t allmask, origmask; | ||
| 86 | 	int masked = 0; | ||
| 85 | 	if (fd < 0) { | 87 | 	if (fd < 0) { |
| 86 | 		errno = EBADF; | 88 | 		errno = EBADF; |
| 87 | 		return 0; | 89 | 		return 0; |
| ... | @@ -93,6 +95,9 @@ static struct aio_queue *__aio_get_queue(int fd, int need) | ... | @@ -93,6 +95,9 @@ static struct aio_queue *__aio_get_queue(int fd, int need) |
| 93 | 	if ((!map || !map[a] || !map[a][b] || !map[a][b][c] || !(q=map[a][b][c][d])) && need) { | 95 | 	if ((!map || !map[a] || !map[a][b] || !map[a][b][c] || !(q=map[a][b][c][d])) && need) { |
| 94 | 		pthread_rwlock_unlock(&maplock); | 96 | 		pthread_rwlock_unlock(&maplock); |
| 95 | 		if (fcntl(fd, F_GETFD) < 0) return 0; | 97 | 		if (fcntl(fd, F_GETFD) < 0) return 0; |
| 98 | 		sigfillset(&allmask); | ||
| 99 | 		masked = 1; | ||
| 100 | 		pthread_sigmask(SIG_BLOCK, &allmask, &origmask); | ||
| 96 | 		pthread_rwlock_wrlock(&maplock); | 101 | 		pthread_rwlock_wrlock(&maplock); |
| 97 | 		if (!io_thread_stack_size) { | 102 | 		if (!io_thread_stack_size) { |
| 98 | 			unsigned long val = __getauxval(AT_MINSIGSTKSZ); | 103 | 			unsigned long val = __getauxval(AT_MINSIGSTKSZ); |
| ... | @@ -119,6 +124,7 @@ static struct aio_queue *__aio_get_queue(int fd, int need) | ... | @@ -119,6 +124,7 @@ static struct aio_queue *__aio_get_queue(int fd, int need) |
| 119 | 	if (q) pthread_mutex_lock(&q->lock); | 124 | 	if (q) pthread_mutex_lock(&q->lock); |
| 120 | out: | 125 | out: |
| 121 | 	pthread_rwlock_unlock(&maplock); | 126 | 	pthread_rwlock_unlock(&maplock); |
| 127 | 	if (masked) pthread_sigmask(SIG_SETMASK, &origmask, 0); | ||
| 122 | 	return q; | 128 | 	return q; |
| 123 | } | 129 | } |
| 124 | 130 | ||
| ... | @@ -401,18 +407,26 @@ void __aio_atfork(int who) | ... | @@ -401,18 +407,26 @@ void __aio_atfork(int who) |
| 401 | 	if (who<0) { | 407 | 	if (who<0) { |
| 402 | 		pthread_rwlock_rdlock(&maplock); | 408 | 		pthread_rwlock_rdlock(&maplock); |
| 403 | 		return; | 409 | 		return; |
| 410 | 	} else if (!who) { | ||
| 411 | 		pthread_rwlock_unlock(&maplock); | ||
| 412 | 		return; | ||
| 404 | 	} | 413 | 	} |
| 405 | 	if (who>0 && map) for (int a=0; a<(-1U/2+1)>>24; a++) | 414 | 	aio_fd_cnt = 0; |
| 415 | 	if (pthread_rwlock_tryrdlock(&maplock)) { | ||
| 416 | 		/* Obtaining lock may fail if _Fork was called nor via | ||
| 417 | 		 * fork. In this case, no further aio is possible from | ||
| 418 | 		 * child and we can just null out map so __aio_close | ||
| 419 | 		 * does not attempt to do anything. */ | ||
| 420 | 		map = 0; | ||
| 421 | 		return; | ||
| 422 | 	} | ||
| 423 | 	if (map) for (int a=0; a<(-1U/2+1)>>24; a++) | ||
| 406 | 		if (map[a]) for (int b=0; b<256; b++) | 424 | 		if (map[a]) for (int b=0; b<256; b++) |
| 407 | 			if (map[a][b]) for (int c=0; c<256; c++) | 425 | 			if (map[a][b]) for (int c=0; c<256; c++) |
| 408 | 				if (map[a][b][c]) for (int d=0; d<256; d++) | 426 | 				if (map[a][b][c]) for (int d=0; d<256; d++) |
| 409 | 					map[a][b][c][d] = 0; | 427 | 					map[a][b][c][d] = 0; |
| 410 | 	pthread_rwlock_unlock(&maplock); | 428 | 	/* Re-initialize the rwlock rather than unlocking since there |
| 429 | 	 * may have been more than one reference on it in the parent. | ||
| 430 | 	 * We are not a lock holder anyway; the thread in the parent was. */ | ||
| 431 | 	pthread_rwlock_init(&maplock, 0); | ||
| 411 | } | 432 | } |
| 412 | |||
| 413 | weak_alias(aio_cancel, aio_cancel64); | ||
| 414 | weak_alias(aio_error, aio_error64); | ||
| 415 | weak_alias(aio_fsync, aio_fsync64); | ||
| 416 | weak_alias(aio_read, aio_read64); | ||
| 417 | weak_alias(aio_write, aio_write64); | ||
| 418 | weak_alias(aio_return, aio_return64); |
lib/libc/musl/src/aio/aio_suspend.c+1-5| ... | @@ -9,7 +9,7 @@ int aio_suspend(const struct aiocb *const cbs[], int cnt, const struct timespec | ... | @@ -9,7 +9,7 @@ int aio_suspend(const struct aiocb *const cbs[], int cnt, const struct timespec |
| 9 | { | 9 | { |
| 10 | 	int i, tid = 0, ret, expect = 0; | 10 | 	int i, tid = 0, ret, expect = 0; |
| 11 | 	struct timespec at; | 11 | 	struct timespec at; |
| 12 | 	volatile int dummy_fut, *pfut; | 12 | 	volatile int dummy_fut = 0, *pfut; |
| 13 | 	int nzcnt = 0; | 13 | 	int nzcnt = 0; |
| 14 | 	const struct aiocb *cb = 0; | 14 | 	const struct aiocb *cb = 0; |
| 15 | 15 | ||
| ... | @@ -73,7 +73,3 @@ int aio_suspend(const struct aiocb *const cbs[], int cnt, const struct timespec | ... | @@ -73,7 +73,3 @@ int aio_suspend(const struct aiocb *const cbs[], int cnt, const struct timespec |
| 73 | 		} | 73 | 		} |
| 74 | 	} | 74 | 	} |
| 75 | } | 75 | } |
| 76 | |||
| 77 | #if !_REDIR_TIME64 | ||
| 78 | weak_alias(aio_suspend, aio_suspend64); | ||
| 79 | #endif |
lib/libc/musl/src/aio/lio_listio.c-2| ... | @@ -139,5 +139,3 @@ int lio_listio(int mode, struct aiocb *restrict const *restrict cbs, int cnt, st | ... | @@ -139,5 +139,3 @@ int lio_listio(int mode, struct aiocb *restrict const *restrict cbs, int cnt, st |
| 139 | 139 | ||
| 140 | 	return 0; | 140 | 	return 0; |
| 141 | } | 141 | } |
| 142 | |||
| 143 | weak_alias(lio_listio, lio_listio64); |
lib/libc/musl/src/conf/confstr.c+1-1| ... | @@ -7,7 +7,7 @@ size_t confstr(int name, char *buf, size_t len) | ... | @@ -7,7 +7,7 @@ size_t confstr(int name, char *buf, size_t len) |
| 7 | 	const char *s = ""; | 7 | 	const char *s = ""; |
| 8 | 	if (!name) { | 8 | 	if (!name) { |
| 9 | 		s = "/bin:/usr/bin"; | 9 | 		s = "/bin:/usr/bin"; |
| 10 | 	} else if ((name&~4U)!=1 && name-_CS_POSIX_V6_ILP32_OFF32_CFLAGS>33U) { | 10 | 	} else if ((name&~4U)!=1 && name-_CS_POSIX_V6_ILP32_OFF32_CFLAGS>35U) { |
| 11 | 		errno = EINVAL; | 11 | 		errno = EINVAL; |
| 12 | 		return 0; | 12 | 		return 0; |
| 13 | 	} | 13 | 	} |
lib/libc/musl/src/conf/sysconf.c+13| ... | @@ -4,6 +4,7 @@ | ... | @@ -4,6 +4,7 @@ |
| 4 | #include <sys/resource.h> | 4 | #include <sys/resource.h> |
| 5 | #include <signal.h> | 5 | #include <signal.h> |
| 6 | #include <sys/sysinfo.h> | 6 | #include <sys/sysinfo.h> |
| 7 | #include <sys/auxv.h> | ||
| 7 | #include "syscall.h" | 8 | #include "syscall.h" |
| 8 | #include "libc.h" | 9 | #include "libc.h" |
| 9 | 10 | ||
| ... | @@ -19,6 +20,8 @@ | ... | @@ -19,6 +20,8 @@ |
| 19 | #define JT_AVPHYS_PAGES JT(9) | 20 | #define JT_AVPHYS_PAGES JT(9) |
| 20 | #define JT_ZERO JT(10) | 21 | #define JT_ZERO JT(10) |
| 21 | #define JT_DELAYTIMER_MAX JT(11) | 22 | #define JT_DELAYTIMER_MAX JT(11) |
| 23 | #define JT_MINSIGSTKSZ JT(12) | ||
| 24 | #define JT_SIGSTKSZ JT(13) | ||
| 22 | 25 | ||
| 23 | #define RLIM(x) (-32768|(RLIMIT_ ## x)) | 26 | #define RLIM(x) (-32768|(RLIMIT_ ## x)) |
| 24 | 27 | ||
| ... | @@ -165,6 +168,9 @@ long sysconf(int name) | ... | @@ -165,6 +168,9 @@ long sysconf(int name) |
| 165 | 		[_SC_XOPEN_STREAMS] = JT_ZERO, | 168 | 		[_SC_XOPEN_STREAMS] = JT_ZERO, |
| 166 | 		[_SC_THREAD_ROBUST_PRIO_INHERIT] = -1, | 169 | 		[_SC_THREAD_ROBUST_PRIO_INHERIT] = -1, |
| 167 | 		[_SC_THREAD_ROBUST_PRIO_PROTECT] = -1, | 170 | 		[_SC_THREAD_ROBUST_PRIO_PROTECT] = -1, |
| 171 | |||
| 172 | 		[_SC_MINSIGSTKSZ] = JT_MINSIGSTKSZ, | ||
| 173 | 		[_SC_SIGSTKSZ] = JT_SIGSTKSZ, | ||
| 168 | 	}; | 174 | 	}; |
| 169 | 175 | ||
| 170 | 	if (name >= sizeof(values)/sizeof(values[0]) || !values[name]) { | 176 | 	if (name >= sizeof(values)/sizeof(values[0]) || !values[name]) { |
| ... | @@ -212,6 +218,13 @@ long sysconf(int name) | ... | @@ -212,6 +218,13 @@ long sysconf(int name) |
| 212 | 		mem *= si.mem_unit; | 218 | 		mem *= si.mem_unit; |
| 213 | 		mem /= PAGE_SIZE; | 219 | 		mem /= PAGE_SIZE; |
| 214 | 		return (mem > LONG_MAX) ? LONG_MAX : mem; | 220 | 		return (mem > LONG_MAX) ? LONG_MAX : mem; |
| 221 | 	case JT_MINSIGSTKSZ & 255: | ||
| 222 | 	case JT_SIGSTKSZ & 255: ; | ||
| 223 | 		long val = __getauxval(AT_MINSIGSTKSZ); | ||
| 224 | 		if (val < MINSIGSTKSZ) val = MINSIGSTKSZ; | ||
| 225 | 		if (values[name] == JT_SIGSTKSZ) | ||
| 226 | 			val += SIGSTKSZ - MINSIGSTKSZ; | ||
| 227 | 		return val; | ||
| 215 | 	case JT_ZERO & 255: | 228 | 	case JT_ZERO & 255: |
| 216 | 		return 0; | 229 | 		return 0; |
| 217 | 	} | 230 | 	} |
lib/libc/musl/src/dirent/alphasort.c-2| ... | @@ -5,5 +5,3 @@ int alphasort(const struct dirent **a, const struct dirent **b) | ... | @@ -5,5 +5,3 @@ int alphasort(const struct dirent **a, const struct dirent **b) |
| 5 | { | 5 | { |
| 6 | 	return strcoll((*a)->d_name, (*b)->d_name); | 6 | 	return strcoll((*a)->d_name, (*b)->d_name); |
| 7 | } | 7 | } |
| 8 | |||
| 9 | weak_alias(alphasort, alphasort64); |
lib/libc/musl/src/dirent/readdir.c-2| ... | @@ -25,5 +25,3 @@ struct dirent *readdir(DIR *dir) | ... | @@ -25,5 +25,3 @@ struct dirent *readdir(DIR *dir) |
| 25 | 	dir->tell = de->d_off; | 25 | 	dir->tell = de->d_off; |
| 26 | 	return de; | 26 | 	return de; |
| 27 | } | 27 | } |
| 28 | |||
| 29 | weak_alias(readdir, readdir64); |
lib/libc/musl/src/dirent/readdir_r.c-2| ... | @@ -25,5 +25,3 @@ int readdir_r(DIR *restrict dir, struct dirent *restrict buf, struct dirent **re | ... | @@ -25,5 +25,3 @@ int readdir_r(DIR *restrict dir, struct dirent *restrict buf, struct dirent **re |
| 25 | 	*result = buf; | 25 | 	*result = buf; |
| 26 | 	return 0; | 26 | 	return 0; |
| 27 | } | 27 | } |
| 28 | |||
| 29 | weak_alias(readdir_r, readdir64_r); |
lib/libc/musl/src/dirent/scandir.c-2| ... | @@ -43,5 +43,3 @@ int scandir(const char *path, struct dirent ***res, | ... | @@ -43,5 +43,3 @@ int scandir(const char *path, struct dirent ***res, |
| 43 | 	*res = names; | 43 | 	*res = names; |
| 44 | 	return cnt; | 44 | 	return cnt; |
| 45 | } | 45 | } |
| 46 | |||
| 47 | weak_alias(scandir, scandir64); |
lib/libc/musl/src/dirent/versionsort.c-3| ... | @@ -6,6 +6,3 @@ int versionsort(const struct dirent **a, const struct dirent **b) | ... | @@ -6,6 +6,3 @@ int versionsort(const struct dirent **a, const struct dirent **b) |
| 6 | { | 6 | { |
| 7 | 	return strverscmp((*a)->d_name, (*b)->d_name); | 7 | 	return strverscmp((*a)->d_name, (*b)->d_name); |
| 8 | } | 8 | } |
| 9 | |||
| 10 | #undef versionsort64 | ||
| 11 | weak_alias(versionsort, versionsort64); |
lib/libc/musl/src/fcntl/creat.c-2| ... | @@ -4,5 +4,3 @@ int creat(const char *filename, mode_t mode) | ... | @@ -4,5 +4,3 @@ int creat(const char *filename, mode_t mode) |
| 4 | { | 4 | { |
| 5 | 	return open(filename, O_CREAT|O_WRONLY|O_TRUNC, mode); | 5 | 	return open(filename, O_CREAT|O_WRONLY|O_TRUNC, mode); |
| 6 | } | 6 | } |
| 7 | |||
| 8 | weak_alias(creat, creat64); |
lib/libc/musl/src/fcntl/open.c-2| ... | @@ -19,5 +19,3 @@ int open(const char *filename, int flags, ...) | ... | @@ -19,5 +19,3 @@ int open(const char *filename, int flags, ...) |
| 19 | 19 | ||
| 20 | 	return __syscall_ret(fd); | 20 | 	return __syscall_ret(fd); |
| 21 | } | 21 | } |
| 22 | |||
| 23 | weak_alias(open, open64); |
lib/libc/musl/src/fcntl/openat.c-2| ... | @@ -15,5 +15,3 @@ int openat(int fd, const char *filename, int flags, ...) | ... | @@ -15,5 +15,3 @@ int openat(int fd, const char *filename, int flags, ...) |
| 15 | 15 | ||
| 16 | 	return syscall_cp(SYS_openat, fd, filename, flags|O_LARGEFILE, mode); | 16 | 	return syscall_cp(SYS_openat, fd, filename, flags|O_LARGEFILE, mode); |
| 17 | } | 17 | } |
| 18 | |||
| 19 | weak_alias(openat, openat64); |
lib/libc/musl/src/fcntl/posix_fadvise.c-2| ... | @@ -14,5 +14,3 @@ int posix_fadvise(int fd, off_t base, off_t len, int advice) | ... | @@ -14,5 +14,3 @@ int posix_fadvise(int fd, off_t base, off_t len, int advice) |
| 14 | 		__SYSCALL_LL_E(len), advice); | 14 | 		__SYSCALL_LL_E(len), advice); |
| 15 | #endif | 15 | #endif |
| 16 | } | 16 | } |
| 17 | |||
| 18 | weak_alias(posix_fadvise, posix_fadvise64); |
lib/libc/musl/src/fcntl/posix_fallocate.c-2| ... | @@ -6,5 +6,3 @@ int posix_fallocate(int fd, off_t base, off_t len) | ... | @@ -6,5 +6,3 @@ int posix_fallocate(int fd, off_t base, off_t len) |
| 6 | 	return -__syscall(SYS_fallocate, fd, 0, __SYSCALL_LL_E(base), | 6 | 	return -__syscall(SYS_fallocate, fd, 0, __SYSCALL_LL_E(base), |
| 7 | 		__SYSCALL_LL_E(len)); | 7 | 		__SYSCALL_LL_E(len)); |
| 8 | } | 8 | } |
| 9 | |||
| 10 | weak_alias(posix_fallocate, posix_fallocate64); |
lib/libc/musl/src/include/sys/stat.h created+9| ... | @@ -0,0 +1,9 @@ | ||
| 1 | #ifndef SYS_STAT_H | ||
| 2 | #define SYS_STAT_H | ||
| 3 | |||
| 4 | #include "../../../include/sys/stat.h" | ||
| 5 | |||
| 6 | hidden int __fstat(int, struct stat *); | ||
| 7 | hidden int __fstatat(int, const char *restrict, struct stat *restrict, int); | ||
| 8 | |||
| 9 | #endif | ||
lib/libc/musl/src/internal/dynlink.h+5-1| ... | @@ -92,8 +92,12 @@ struct fdpic_dummy_loadmap { | ... | @@ -92,8 +92,12 @@ struct fdpic_dummy_loadmap { |
| 92 | #define DT_DEBUG_INDIRECT 0 | 92 | #define DT_DEBUG_INDIRECT 0 |
| 93 | #endif | 93 | #endif |
| 94 | 94 | ||
| 95 | #ifndef DT_DEBUG_INDIRECT_REL | ||
| 96 | #define DT_DEBUG_INDIRECT_REL 0 | ||
| 97 | #endif | ||
| 98 | |||
| 95 | #define AUX_CNT 32 | 99 | #define AUX_CNT 32 |
| 96 | #define DYN_CNT 32 | 100 | #define DYN_CNT 37 |
| 97 | 101 | ||
| 98 | typedef void (*stage2_func)(unsigned char *, size_t *); | 102 | typedef void (*stage2_func)(unsigned char *, size_t *); |
| 99 | 103 |
lib/libc/musl/src/internal/fork_impl.h+1-1| ... | @@ -2,7 +2,6 @@ | ... | @@ -2,7 +2,6 @@ |
| 2 | 2 | ||
| 3 | extern hidden volatile int *const __at_quick_exit_lockptr; | 3 | extern hidden volatile int *const __at_quick_exit_lockptr; |
| 4 | extern hidden volatile int *const __atexit_lockptr; | 4 | extern hidden volatile int *const __atexit_lockptr; |
| 5 | extern hidden volatile int *const __dlerror_lockptr; | ||
| 6 | extern hidden volatile int *const __gettext_lockptr; | 5 | extern hidden volatile int *const __gettext_lockptr; |
| 7 | extern hidden volatile int *const __locale_lockptr; | 6 | extern hidden volatile int *const __locale_lockptr; |
| 8 | extern hidden volatile int *const __random_lockptr; | 7 | extern hidden volatile int *const __random_lockptr; |
| ... | @@ -17,3 +16,4 @@ extern hidden volatile int *const __vmlock_lockptr; | ... | @@ -17,3 +16,4 @@ extern hidden volatile int *const __vmlock_lockptr; |
| 17 | 16 | ||
| 18 | hidden void __malloc_atfork(int); | 17 | hidden void __malloc_atfork(int); |
| 19 | hidden void __ldso_atfork(int); | 18 | hidden void __ldso_atfork(int); |
| 19 | hidden void __pthread_key_atfork(int); |
lib/libc/musl/src/internal/ksigaction.h+5| ... | @@ -6,8 +6,13 @@ | ... | @@ -6,8 +6,13 @@ |
| 6 | struct k_sigaction { | 6 | struct k_sigaction { |
| 7 | 	void (*handler)(int); | 7 | 	void (*handler)(int); |
| 8 | 	unsigned long flags; | 8 | 	unsigned long flags; |
| 9 | #ifdef SA_RESTORER | ||
| 9 | 	void (*restorer)(void); | 10 | 	void (*restorer)(void); |
| 11 | #endif | ||
| 10 | 	unsigned mask[2]; | 12 | 	unsigned mask[2]; |
| 13 | #ifndef SA_RESTORER | ||
| 14 | 	void *unused; | ||
| 15 | #endif | ||
| 11 | }; | 16 | }; |
| 12 | 17 | ||
| 13 | hidden void __restore(), __restore_rt(); | 18 | hidden void __restore(), __restore_rt(); |
lib/libc/musl/src/internal/syscall.h+13-13| ... | @@ -58,7 +58,7 @@ hidden long __syscall_ret(unsigned long), | ... | @@ -58,7 +58,7 @@ hidden long __syscall_ret(unsigned long), |
| 58 | #define __syscall_cp(...) __SYSCALL_DISP(__syscall_cp,__VA_ARGS__) | 58 | #define __syscall_cp(...) __SYSCALL_DISP(__syscall_cp,__VA_ARGS__) |
| 59 | #define syscall_cp(...) __syscall_ret(__syscall_cp(__VA_ARGS__)) | 59 | #define syscall_cp(...) __syscall_ret(__syscall_cp(__VA_ARGS__)) |
| 60 | 60 | ||
| 61 | static inline long __alt_socketcall(int sys, int sock, int cp, long a, long b, long c, long d, long e, long f) | 61 | static inline long __alt_socketcall(int sys, int sock, int cp, syscall_arg_t a, syscall_arg_t b, syscall_arg_t c, syscall_arg_t d, syscall_arg_t e, syscall_arg_t f) |
| 62 | { | 62 | { |
| 63 | 	long r; | 63 | 	long r; |
| 64 | 	if (cp) r = __syscall_cp(sys, a, b, c, d, e, f); | 64 | 	if (cp) r = __syscall_cp(sys, a, b, c, d, e, f); |
| ... | @@ -71,9 +71,9 @@ static inline long __alt_socketcall(int sys, int sock, int cp, long a, long b, l | ... | @@ -71,9 +71,9 @@ static inline long __alt_socketcall(int sys, int sock, int cp, long a, long b, l |
| 71 | 	return r; | 71 | 	return r; |
| 72 | } | 72 | } |
| 73 | #define __socketcall(nm, a, b, c, d, e, f) __alt_socketcall(SYS_##nm, __SC_##nm, 0, \ | 73 | #define __socketcall(nm, a, b, c, d, e, f) __alt_socketcall(SYS_##nm, __SC_##nm, 0, \ |
| 74 | 	(long)(a), (long)(b), (long)(c), (long)(d), (long)(e), (long)(f)) | 74 | 	__scc(a), __scc(b), __scc(c), __scc(d), __scc(e), __scc(f)) |
| 75 | #define __socketcall_cp(nm, a, b, c, d, e, f) __alt_socketcall(SYS_##nm, __SC_##nm, 1, \ | 75 | #define __socketcall_cp(nm, a, b, c, d, e, f) __alt_socketcall(SYS_##nm, __SC_##nm, 1, \ |
| 76 | 	(long)(a), (long)(b), (long)(c), (long)(d), (long)(e), (long)(f)) | 76 | 	__scc(a), __scc(b), __scc(c), __scc(d), __scc(e), __scc(f)) |
| 77 | 77 | ||
| 78 | /* fixup legacy 16-bit junk */ | 78 | /* fixup legacy 16-bit junk */ |
| 79 | 79 | ||
| ... | @@ -201,43 +201,43 @@ static inline long __alt_socketcall(int sys, int sock, int cp, long a, long b, l | ... | @@ -201,43 +201,43 @@ static inline long __alt_socketcall(int sys, int sock, int cp, long a, long b, l |
| 201 | #define SYS_sendfile SYS_sendfile64 | 201 | #define SYS_sendfile SYS_sendfile64 |
| 202 | #endif | 202 | #endif |
| 203 | 203 | ||
| 204 | #ifndef SYS_timer_settime | 204 | #ifdef SYS_timer_settime32 |
| 205 | #define SYS_timer_settime SYS_timer_settime32 | 205 | #define SYS_timer_settime SYS_timer_settime32 |
| 206 | #endif | 206 | #endif |
| 207 | 207 | ||
| 208 | #ifndef SYS_timer_gettime | 208 | #ifdef SYS_timer_gettime32 |
| 209 | #define SYS_timer_gettime SYS_timer_gettime32 | 209 | #define SYS_timer_gettime SYS_timer_gettime32 |
| 210 | #endif | 210 | #endif |
| 211 | 211 | ||
| 212 | #ifndef SYS_timerfd_settime | 212 | #ifdef SYS_timerfd_settime32 |
| 213 | #define SYS_timerfd_settime SYS_timerfd_settime32 | 213 | #define SYS_timerfd_settime SYS_timerfd_settime32 |
| 214 | #endif | 214 | #endif |
| 215 | 215 | ||
| 216 | #ifndef SYS_timerfd_gettime | 216 | #ifdef SYS_timerfd_gettime32 |
| 217 | #define SYS_timerfd_gettime SYS_timerfd_gettime32 | 217 | #define SYS_timerfd_gettime SYS_timerfd_gettime32 |
| 218 | #endif | 218 | #endif |
| 219 | 219 | ||
| 220 | #ifndef SYS_clock_settime | 220 | #ifdef SYS_clock_settime32 |
| 221 | #define SYS_clock_settime SYS_clock_settime32 | 221 | #define SYS_clock_settime SYS_clock_settime32 |
| 222 | #endif | 222 | #endif |
| 223 | 223 | ||
| 224 | #ifndef SYS_clock_gettime | 224 | #ifdef SYS_clock_gettime32 |
| 225 | #define SYS_clock_gettime SYS_clock_gettime32 | 225 | #define SYS_clock_gettime SYS_clock_gettime32 |
| 226 | #endif | 226 | #endif |
| 227 | 227 | ||
| 228 | #ifndef SYS_clock_getres | 228 | #ifdef SYS_clock_getres_time32 |
| 229 | #define SYS_clock_getres SYS_clock_getres_time32 | 229 | #define SYS_clock_getres SYS_clock_getres_time32 |
| 230 | #endif | 230 | #endif |
| 231 | 231 | ||
| 232 | #ifndef SYS_clock_nanosleep | 232 | #ifdef SYS_clock_nanosleep_time32 |
| 233 | #define SYS_clock_nanosleep SYS_clock_nanosleep_time32 | 233 | #define SYS_clock_nanosleep SYS_clock_nanosleep_time32 |
| 234 | #endif | 234 | #endif |
| 235 | 235 | ||
| 236 | #ifndef SYS_gettimeofday | 236 | #ifdef SYS_gettimeofday_time32 |
| 237 | #define SYS_gettimeofday SYS_gettimeofday_time32 | 237 | #define SYS_gettimeofday SYS_gettimeofday_time32 |
| 238 | #endif | 238 | #endif |
| 239 | 239 | ||
| 240 | #ifndef SYS_settimeofday | 240 | #ifdef SYS_settimeofday_time32 |
| 241 | #define SYS_settimeofday SYS_settimeofday_time32 | 241 | #define SYS_settimeofday SYS_settimeofday_time32 |
| 242 | #endif | 242 | #endif |
| 243 | 243 |
lib/libc/musl/src/internal/version.h+1-1| ... | @@ -1 +1 @@ | ... | @@ -1 +1 @@ |
| 1 | #define VERSION "1.2.3" | 1 | #define VERSION "1.2.4" |
lib/libc/musl/src/ipc/semtimedop.c+2-1| ... | @@ -7,7 +7,8 @@ | ... | @@ -7,7 +7,8 @@ |
| 7 | #define IS32BIT(x) !((x)+0x80000000ULL>>32) | 7 | #define IS32BIT(x) !((x)+0x80000000ULL>>32) |
| 8 | #define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63)) | 8 | #define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63)) |
| 9 | 9 | ||
| 10 | #if !defined(SYS_semtimedop) && !defined(SYS_ipc) | 10 | #if !defined(SYS_semtimedop) && !defined(SYS_ipc) || \ |
| 11 | 	SYS_semtimedop == SYS_semtimedop_time64 | ||
| 11 | #define NO_TIME32 1 | 12 | #define NO_TIME32 1 |
| 12 | #else | 13 | #else |
| 13 | #define NO_TIME32 0 | 14 | #define NO_TIME32 0 |
lib/libc/musl/src/ldso/dlerror.c+18-16| ... | @@ -3,8 +3,7 @@ | ... | @@ -3,8 +3,7 @@ |
| 3 | #include <stdarg.h> | 3 | #include <stdarg.h> |
| 4 | #include "pthread_impl.h" | 4 | #include "pthread_impl.h" |
| 5 | #include "dynlink.h" | 5 | #include "dynlink.h" |
| 6 | #include "lock.h" | 6 | #include "atomic.h" |
| 7 | #include "fork_impl.h" | ||
| 8 | 7 | ||
| 9 | #define malloc __libc_malloc | 8 | #define malloc __libc_malloc |
| 10 | #define calloc __libc_calloc | 9 | #define calloc __libc_calloc |
| ... | @@ -23,28 +22,31 @@ char *dlerror() | ... | @@ -23,28 +22,31 @@ char *dlerror() |
| 23 | 		return s; | 22 | 		return s; |
| 24 | } | 23 | } |
| 25 | 24 | ||
| 26 | static volatile int freebuf_queue_lock[1]; | 25 | /* Atomic singly-linked list, used to store list of thread-local dlerror |
| 27 | static void **freebuf_queue; | 26 | * buffers for deferred free. They cannot be freed at thread exit time |
| 28 | volatile int *const __dlerror_lockptr = freebuf_queue_lock; | 27 | * because, by the time it's known they can be freed, the exiting thread |
| 28 | * is in a highly restrictive context where it cannot call (even the | ||
| 29 | * libc-internal) free. It also can't take locks; thus the atomic list. */ | ||
| 30 | |||
| 31 | static void *volatile freebuf_queue; | ||
| 29 | 32 | ||
| 30 | void __dl_thread_cleanup(void) | 33 | void __dl_thread_cleanup(void) |
| 31 | { | 34 | { |
| 32 | 	pthread_t self = __pthread_self(); | 35 | 	pthread_t self = __pthread_self(); |
| 33 | 	if (self->dlerror_buf && self->dlerror_buf != (void *)-1) { | 36 | 	if (!self->dlerror_buf || self->dlerror_buf == (void *)-1) |
| 34 | 		LOCK(freebuf_queue_lock); | 37 | 		return; |
| 35 | 		void **p = (void **)self->dlerror_buf; | 38 | 	void *h; |
| 36 | 		*p = freebuf_queue; | 39 | 	do { |
| 37 | 		freebuf_queue = p; | 40 | 		h = freebuf_queue; |
| 38 | 		UNLOCK(freebuf_queue_lock); | 41 | 		*(void **)self->dlerror_buf = h; |
| 39 | 	} | 42 | 	} while (a_cas_p(&freebuf_queue, h, self->dlerror_buf) != h); |
| 40 | } | 43 | } |
| 41 | 44 | ||
| 42 | hidden void __dl_vseterr(const char *fmt, va_list ap) | 45 | hidden void __dl_vseterr(const char *fmt, va_list ap) |
| 43 | { | 46 | { |
| 44 | 	LOCK(freebuf_queue_lock); | 47 | 	void **q; |
| 45 | 	void **q = freebuf_queue; | 48 | 	do q = freebuf_queue; |
| 46 | 	freebuf_queue = 0; | 49 | 	while (q && a_cas_p(&freebuf_queue, q, 0) != q); |
| 47 | 	UNLOCK(freebuf_queue_lock); | ||
| 48 | 50 | ||
| 49 | 	while (q) { | 51 | 	while (q) { |
| 50 | 		void **p = *q; | 52 | 		void **p = *q; |
lib/libc/musl/src/legacy/ftw.c-2| ... | @@ -7,5 +7,3 @@ int ftw(const char *path, int (*fn)(const char *, const struct stat *, int), int | ... | @@ -7,5 +7,3 @@ int ftw(const char *path, int (*fn)(const char *, const struct stat *, int), int |
| 7 | 	 * actually undefined, but works on all real-world machines. */ | 7 | 	 * actually undefined, but works on all real-world machines. */ |
| 8 | 	return nftw(path, (int (*)())fn, fd_limit, FTW_PHYS); | 8 | 	return nftw(path, (int (*)())fn, fd_limit, FTW_PHYS); |
| 9 | } | 9 | } |
| 10 | |||
| 11 | weak_alias(ftw, ftw64); |
lib/libc/musl/src/linux/epoll.c+1| ... | @@ -5,6 +5,7 @@ | ... | @@ -5,6 +5,7 @@ |
| 5 | 5 | ||
| 6 | int epoll_create(int size) | 6 | int epoll_create(int size) |
| 7 | { | 7 | { |
| 8 | 	if (size<=0) return __syscall_ret(-EINVAL); | ||
| 8 | 	return epoll_create1(0); | 9 | 	return epoll_create1(0); |
| 9 | } | 10 | } |
| 10 | 11 |
lib/libc/musl/src/linux/fallocate.c-3| ... | @@ -7,6 +7,3 @@ int fallocate(int fd, int mode, off_t base, off_t len) | ... | @@ -7,6 +7,3 @@ int fallocate(int fd, int mode, off_t base, off_t len) |
| 7 | 	return syscall(SYS_fallocate, fd, mode, __SYSCALL_LL_E(base), | 7 | 	return syscall(SYS_fallocate, fd, mode, __SYSCALL_LL_E(base), |
| 8 | 		__SYSCALL_LL_E(len)); | 8 | 		__SYSCALL_LL_E(len)); |
| 9 | } | 9 | } |
| 10 | |||
| 11 | #undef fallocate64 | ||
| 12 | weak_alias(fallocate, fallocate64); |
lib/libc/musl/src/linux/getdents.c-2| ... | @@ -8,5 +8,3 @@ int getdents(int fd, struct dirent *buf, size_t len) | ... | @@ -8,5 +8,3 @@ int getdents(int fd, struct dirent *buf, size_t len) |
| 8 | 	if (len>INT_MAX) len = INT_MAX; | 8 | 	if (len>INT_MAX) len = INT_MAX; |
| 9 | 	return syscall(SYS_getdents, fd, buf, len); | 9 | 	return syscall(SYS_getdents, fd, buf, len); |
| 10 | } | 10 | } |
| 11 | |||
| 12 | weak_alias(getdents, getdents64); |
lib/libc/musl/src/linux/membarrier.c+1-1| ... | @@ -35,7 +35,7 @@ int __membarrier(int cmd, int flags) | ... | @@ -35,7 +35,7 @@ int __membarrier(int cmd, int flags) |
| 35 | 		__tl_lock(); | 35 | 		__tl_lock(); |
| 36 | 		sem_init(&barrier_sem, 0, 0); | 36 | 		sem_init(&barrier_sem, 0, 0); |
| 37 | 		struct sigaction sa = { | 37 | 		struct sigaction sa = { |
| 38 | 			.sa_flags = SA_RESTART, | 38 | 			.sa_flags = SA_RESTART | SA_ONSTACK, |
| 39 | 			.sa_handler = bcast_barrier | 39 | 			.sa_handler = bcast_barrier |
| 40 | 		}; | 40 | 		}; |
| 41 | 		memset(&sa.sa_mask, -1, sizeof sa.sa_mask); | 41 | 		memset(&sa.sa_mask, -1, sizeof sa.sa_mask); |
lib/libc/musl/src/linux/prlimit.c-3| ... | @@ -21,6 +21,3 @@ int prlimit(pid_t pid, int resource, const struct rlimit *new_limit, struct rlim | ... | @@ -21,6 +21,3 @@ int prlimit(pid_t pid, int resource, const struct rlimit *new_limit, struct rlim |
| 21 | 	} | 21 | 	} |
| 22 | 	return r; | 22 | 	return r; |
| 23 | } | 23 | } |
| 24 | |||
| 25 | #undef prlimit64 | ||
| 26 | weak_alias(prlimit, prlimit64); |
lib/libc/musl/src/linux/sendfile.c-2| ... | @@ -5,5 +5,3 @@ ssize_t sendfile(int out_fd, int in_fd, off_t *ofs, size_t count) | ... | @@ -5,5 +5,3 @@ ssize_t sendfile(int out_fd, int in_fd, off_t *ofs, size_t count) |
| 5 | { | 5 | { |
| 6 | 	return syscall(SYS_sendfile, out_fd, in_fd, ofs, count); | 6 | 	return syscall(SYS_sendfile, out_fd, in_fd, ofs, count); |
| 7 | } | 7 | } |
| 8 | |||
| 9 | weak_alias(sendfile, sendfile64); |
lib/libc/musl/src/linux/wait4.c+1-1| ... | @@ -12,7 +12,7 @@ pid_t wait4(pid_t pid, int *status, int options, struct rusage *ru) | ... | @@ -12,7 +12,7 @@ pid_t wait4(pid_t pid, int *status, int options, struct rusage *ru) |
| 12 | 	if (ru) { | 12 | 	if (ru) { |
| 13 | 		long long kru64[18]; | 13 | 		long long kru64[18]; |
| 14 | 		r = __syscall(SYS_wait4_time64, pid, status, options, kru64); | 14 | 		r = __syscall(SYS_wait4_time64, pid, status, options, kru64); |
| 15 | 		if (!r) { | 15 | 		if (r > 0) { |
| 16 | 			ru->ru_utime = (struct timeval) | 16 | 			ru->ru_utime = (struct timeval) |
| 17 | 				{ .tv_sec = kru64[0], .tv_usec = kru64[1] }; | 17 | 				{ .tv_sec = kru64[0], .tv_usec = kru64[1] }; |
| 18 | 			ru->ru_stime = (struct timeval) | 18 | 			ru->ru_stime = (struct timeval) |
lib/libc/musl/src/malloc/mallocng/free.c+1-1| ... | @@ -119,7 +119,7 @@ void free(void *p) | ... | @@ -119,7 +119,7 @@ void free(void *p) |
| 119 | 	if (((uintptr_t)(start-1) ^ (uintptr_t)end) >= 2*PGSZ && g->last_idx) { | 119 | 	if (((uintptr_t)(start-1) ^ (uintptr_t)end) >= 2*PGSZ && g->last_idx) { |
| 120 | 		unsigned char *base = start + (-(uintptr_t)start & (PGSZ-1)); | 120 | 		unsigned char *base = start + (-(uintptr_t)start & (PGSZ-1)); |
| 121 | 		size_t len = (end-base) & -PGSZ; | 121 | 		size_t len = (end-base) & -PGSZ; |
| 122 | 		if (len) { | 122 | 		if (len && USE_MADV_FREE) { |
| 123 | 			int e = errno; | 123 | 			int e = errno; |
| 124 | 			madvise(base, len, MADV_FREE); | 124 | 			madvise(base, len, MADV_FREE); |
| 125 | 			errno = e; | 125 | 			errno = e; |
lib/libc/musl/src/malloc/mallocng/glue.h+2| ... | @@ -24,6 +24,8 @@ | ... | @@ -24,6 +24,8 @@ |
| 24 | #define realloc __libc_realloc | 24 | #define realloc __libc_realloc |
| 25 | #define free __libc_free | 25 | #define free __libc_free |
| 26 | 26 | ||
| 27 | #define USE_MADV_FREE 0 | ||
| 28 | |||
| 27 | #if USE_REAL_ASSERT | 29 | #if USE_REAL_ASSERT |
| 28 | #include <assert.h> | 30 | #include <assert.h> |
| 29 | #else | 31 | #else |
lib/libc/musl/src/math/logf.c+1-1| ... | @@ -53,7 +53,7 @@ float logf(float x) | ... | @@ -53,7 +53,7 @@ float logf(float x) |
| 53 | 	tmp = ix - OFF; | 53 | 	tmp = ix - OFF; |
| 54 | 	i = (tmp >> (23 - LOGF_TABLE_BITS)) % N; | 54 | 	i = (tmp >> (23 - LOGF_TABLE_BITS)) % N; |
| 55 | 	k = (int32_t)tmp >> 23; /* arithmetic shift */ | 55 | 	k = (int32_t)tmp >> 23; /* arithmetic shift */ |
| 56 | 	iz = ix - (tmp & 0x1ff << 23); | 56 | 	iz = ix - (tmp & 0xff800000); |
| 57 | 	invc = T[i].invc; | 57 | 	invc = T[i].invc; |
| 58 | 	logc = T[i].logc; | 58 | 	logc = T[i].logc; |
| 59 | 	z = (double_t)asfloat(iz); | 59 | 	z = (double_t)asfloat(iz); |
lib/libc/musl/src/misc/getopt.c+2-1| ... | @@ -87,7 +87,8 @@ int getopt(int argc, char * const argv[], const char *optstring) | ... | @@ -87,7 +87,8 @@ int getopt(int argc, char * const argv[], const char *optstring) |
| 87 | 	if (optstring[i] == ':') { | 87 | 	if (optstring[i] == ':') { |
| 88 | 		optarg = 0; | 88 | 		optarg = 0; |
| 89 | 		if (optstring[i+1] != ':' || optpos) { | 89 | 		if (optstring[i+1] != ':' || optpos) { |
| 90 | 			optarg = argv[optind++] + optpos; | 90 | 			optarg = argv[optind++]; |
| 91 | 			if (optpos) optarg += optpos; | ||
| 91 | 			optpos = 0; | 92 | 			optpos = 0; |
| 92 | 		} | 93 | 		} |
| 93 | 		if (optind > argc) { | 94 | 		if (optind > argc) { |
lib/libc/musl/src/misc/getrlimit.c+5-3| ... | @@ -6,12 +6,13 @@ | ... | @@ -6,12 +6,13 @@ |
| 6 | 6 | ||
| 7 | int getrlimit(int resource, struct rlimit *rlim) | 7 | int getrlimit(int resource, struct rlimit *rlim) |
| 8 | { | 8 | { |
| 9 | 	unsigned long k_rlim[2]; | ||
| 10 | 	int ret = syscall(SYS_prlimit64, 0, resource, 0, rlim); | 9 | 	int ret = syscall(SYS_prlimit64, 0, resource, 0, rlim); |
| 11 | 	if (!ret) { | 10 | 	if (!ret) { |
| 12 | 		FIX(rlim->rlim_cur); | 11 | 		FIX(rlim->rlim_cur); |
| 13 | 		FIX(rlim->rlim_max); | 12 | 		FIX(rlim->rlim_max); |
| 14 | 	} | 13 | 	} |
| 14 | #ifdef SYS_getrlimit | ||
| 15 | 	unsigned long k_rlim[2]; | ||
| 15 | 	if (!ret || errno != ENOSYS) | 16 | 	if (!ret || errno != ENOSYS) |
| 16 | 		return ret; | 17 | 		return ret; |
| 17 | 	if (syscall(SYS_getrlimit, resource, k_rlim) < 0) | 18 | 	if (syscall(SYS_getrlimit, resource, k_rlim) < 0) |
| ... | @@ -21,6 +22,7 @@ int getrlimit(int resource, struct rlimit *rlim) | ... | @@ -21,6 +22,7 @@ int getrlimit(int resource, struct rlimit *rlim) |
| 21 | 	FIX(rlim->rlim_cur); | 22 | 	FIX(rlim->rlim_cur); |
| 22 | 	FIX(rlim->rlim_max); | 23 | 	FIX(rlim->rlim_max); |
| 23 | 	return 0; | 24 | 	return 0; |
| 25 | #else | ||
| 26 | 	return ret; | ||
| 27 | #endif | ||
| 24 | } | 28 | } |
| 25 | |||
| 26 | weak_alias(getrlimit, getrlimit64); |
lib/libc/musl/src/misc/lockf.c-2| ... | @@ -28,5 +28,3 @@ int lockf(int fd, int op, off_t size) | ... | @@ -28,5 +28,3 @@ int lockf(int fd, int op, off_t size) |
| 28 | 	errno = EINVAL; | 28 | 	errno = EINVAL; |
| 29 | 	return -1; | 29 | 	return -1; |
| 30 | } | 30 | } |
| 31 | |||
| 32 | weak_alias(lockf, lockf64); |
lib/libc/musl/src/misc/mntent.c+9-3| ... | @@ -2,6 +2,7 @@ | ... | @@ -2,6 +2,7 @@ |
| 2 | #include <string.h> | 2 | #include <string.h> |
| 3 | #include <mntent.h> | 3 | #include <mntent.h> |
| 4 | #include <errno.h> | 4 | #include <errno.h> |
| 5 | #include <limits.h> | ||
| 5 | 6 | ||
| 6 | static char *internal_buf; | 7 | static char *internal_buf; |
| 7 | static size_t internal_bufsize; | 8 | static size_t internal_bufsize; |
| ... | @@ -21,7 +22,8 @@ int endmntent(FILE *f) | ... | @@ -21,7 +22,8 @@ int endmntent(FILE *f) |
| 21 | 22 | ||
| 22 | struct mntent *getmntent_r(FILE *f, struct mntent *mnt, char *linebuf, int buflen) | 23 | struct mntent *getmntent_r(FILE *f, struct mntent *mnt, char *linebuf, int buflen) |
| 23 | { | 24 | { |
| 24 | 	int cnt, n[8], use_internal = (linebuf == SENTINEL); | 25 | 	int n[8], use_internal = (linebuf == SENTINEL); |
| 26 | 	size_t len, i; | ||
| 25 | 27 | ||
| 26 | 	mnt->mnt_freq = 0; | 28 | 	mnt->mnt_freq = 0; |
| 27 | 	mnt->mnt_passno = 0; | 29 | 	mnt->mnt_passno = 0; |
| ... | @@ -39,10 +41,14 @@ struct mntent *getmntent_r(FILE *f, struct mntent *mnt, char *linebuf, int bufle | ... | @@ -39,10 +41,14 @@ struct mntent *getmntent_r(FILE *f, struct mntent *mnt, char *linebuf, int bufle |
| 39 | 			errno = ERANGE; | 41 | 			errno = ERANGE; |
| 40 | 			return 0; | 42 | 			return 0; |
| 41 | 		} | 43 | 		} |
| 42 | 		cnt = sscanf(linebuf, " %n%*s%n %n%*s%n %n%*s%n %n%*s%n %d %d", | 44 | |
| 45 | 		len = strlen(linebuf); | ||
| 46 | 		if (len > INT_MAX) continue; | ||
| 47 | 		for (i = 0; i < sizeof n / sizeof *n; i++) n[i] = len; | ||
| 48 | 		sscanf(linebuf, " %n%*s%n %n%*s%n %n%*s%n %n%*s%n %d %d", | ||
| 43 | 			n, n+1, n+2, n+3, n+4, n+5, n+6, n+7, | 49 | 			n, n+1, n+2, n+3, n+4, n+5, n+6, n+7, |
| 44 | 			&mnt->mnt_freq, &mnt->mnt_passno); | 50 | 			&mnt->mnt_freq, &mnt->mnt_passno); |
| 45 | 	} while (cnt < 2 || linebuf[n[0]] == '#'); | 51 | 	} while (linebuf[n[0]] == '#' || n[1]==len); |
| 46 | 52 | ||
| 47 | 	linebuf[n[1]] = 0; | 53 | 	linebuf[n[1]] = 0; |
| 48 | 	linebuf[n[3]] = 0; | 54 | 	linebuf[n[3]] = 0; |
lib/libc/musl/src/misc/nftw.c+3-3| ... | @@ -31,6 +31,8 @@ static int do_nftw(char *path, int (*fn)(const char *, const struct stat *, int, | ... | @@ -31,6 +31,8 @@ static int do_nftw(char *path, int (*fn)(const char *, const struct stat *, int, |
| 31 | 	int err; | 31 | 	int err; |
| 32 | 	struct FTW lev; | 32 | 	struct FTW lev; |
| 33 | 33 | ||
| 34 | 	st.st_dev = st.st_ino = 0; | ||
| 35 | |||
| 34 | 	if ((flags & FTW_PHYS) ? lstat(path, &st) : stat(path, &st) < 0) { | 36 | 	if ((flags & FTW_PHYS) ? lstat(path, &st) : stat(path, &st) < 0) { |
| 35 | 		if (!(flags & FTW_PHYS) && errno==ENOENT && !lstat(path, &st)) | 37 | 		if (!(flags & FTW_PHYS) && errno==ENOENT && !lstat(path, &st)) |
| 36 | 			type = FTW_SLN; | 38 | 			type = FTW_SLN; |
| ... | @@ -46,7 +48,7 @@ static int do_nftw(char *path, int (*fn)(const char *, const struct stat *, int, | ... | @@ -46,7 +48,7 @@ static int do_nftw(char *path, int (*fn)(const char *, const struct stat *, int, |
| 46 | 		type = FTW_F; | 48 | 		type = FTW_F; |
| 47 | 	} | 49 | 	} |
| 48 | 50 | ||
| 49 | 	if ((flags & FTW_MOUNT) && h && st.st_dev != h->dev) | 51 | 	if ((flags & FTW_MOUNT) && h && type != FTW_NS && st.st_dev != h->dev) |
| 50 | 		return 0; | 52 | 		return 0; |
| 51 | 	 | 53 | 	 |
| 52 | 	new.chain = h; | 54 | 	new.chain = h; |
| ... | @@ -138,5 +140,3 @@ int nftw(const char *path, int (*fn)(const char *, const struct stat *, int, str | ... | @@ -138,5 +140,3 @@ int nftw(const char *path, int (*fn)(const char *, const struct stat *, int, str |
| 138 | 	pthread_setcancelstate(cs, 0); | 140 | 	pthread_setcancelstate(cs, 0); |
| 139 | 	return r; | 141 | 	return r; |
| 140 | } | 142 | } |
| 141 | |||
| 142 | weak_alias(nftw, nftw64); |
lib/libc/musl/src/misc/setrlimit.c+6-2| ... | @@ -12,12 +12,14 @@ struct ctx { | ... | @@ -12,12 +12,14 @@ struct ctx { |
| 12 | 	int err; | 12 | 	int err; |
| 13 | }; | 13 | }; |
| 14 | 14 | ||
| 15 | #ifdef SYS_setrlimit | ||
| 15 | static void do_setrlimit(void *p) | 16 | static void do_setrlimit(void *p) |
| 16 | { | 17 | { |
| 17 | 	struct ctx *c = p; | 18 | 	struct ctx *c = p; |
| 18 | 	if (c->err>0) return; | 19 | 	if (c->err>0) return; |
| 19 | 	c->err = -__syscall(SYS_setrlimit, c->res, c->lim); | 20 | 	c->err = -__syscall(SYS_setrlimit, c->res, c->lim); |
| 20 | } | 21 | } |
| 22 | #endif | ||
| 21 | 23 | ||
| 22 | int setrlimit(int resource, const struct rlimit *rlim) | 24 | int setrlimit(int resource, const struct rlimit *rlim) |
| 23 | { | 25 | { |
| ... | @@ -29,6 +31,7 @@ int setrlimit(int resource, const struct rlimit *rlim) | ... | @@ -29,6 +31,7 @@ int setrlimit(int resource, const struct rlimit *rlim) |
| 29 | 		rlim = &tmp; | 31 | 		rlim = &tmp; |
| 30 | 	} | 32 | 	} |
| 31 | 	int ret = __syscall(SYS_prlimit64, 0, resource, rlim, 0); | 33 | 	int ret = __syscall(SYS_prlimit64, 0, resource, rlim, 0); |
| 34 | #ifdef SYS_setrlimit | ||
| 32 | 	if (ret != -ENOSYS) return __syscall_ret(ret); | 35 | 	if (ret != -ENOSYS) return __syscall_ret(ret); |
| 33 | 36 | ||
| 34 | 	struct ctx c = { | 37 | 	struct ctx c = { |
| ... | @@ -42,6 +45,7 @@ int setrlimit(int resource, const struct rlimit *rlim) | ... | @@ -42,6 +45,7 @@ int setrlimit(int resource, const struct rlimit *rlim) |
| 42 | 		return -1; | 45 | 		return -1; |
| 43 | 	} | 46 | 	} |
| 44 | 	return 0; | 47 | 	return 0; |
| 48 | #else | ||
| 49 | 	return __syscall_ret(ret); | ||
| 50 | #endif | ||
| 45 | } | 51 | } |
| 46 | |||
| 47 | weak_alias(setrlimit, setrlimit64); |
lib/libc/musl/src/mman/mmap.c-2| ... | @@ -37,5 +37,3 @@ void *__mmap(void *start, size_t len, int prot, int flags, int fd, off_t off) | ... | @@ -37,5 +37,3 @@ void *__mmap(void *start, size_t len, int prot, int flags, int fd, off_t off) |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | weak_alias(__mmap, mmap); | 39 | weak_alias(__mmap, mmap); |
| 40 | |||
| 41 | weak_alias(mmap, mmap64); |
lib/libc/musl/src/mq/mq_notify.c+33-14| ... | @@ -4,11 +4,14 @@ | ... | @@ -4,11 +4,14 @@ |
| 4 | #include <sys/socket.h> | 4 | #include <sys/socket.h> |
| 5 | #include <signal.h> | 5 | #include <signal.h> |
| 6 | #include <unistd.h> | 6 | #include <unistd.h> |
| 7 | #include <semaphore.h> | ||
| 7 | #include "syscall.h" | 8 | #include "syscall.h" |
| 8 | 9 | ||
| 9 | struct args { | 10 | struct args { |
| 10 | 	pthread_barrier_t barrier; | 11 | 	sem_t sem; |
| 11 | 	int sock; | 12 | 	int sock; |
| 13 | 	mqd_t mqd; | ||
| 14 | 	int err; | ||
| 12 | 	const struct sigevent *sev; | 15 | 	const struct sigevent *sev; |
| 13 | }; | 16 | }; |
| 14 | 17 | ||
| ... | @@ -20,8 +23,19 @@ static void *start(void *p) | ... | @@ -20,8 +23,19 @@ static void *start(void *p) |
| 20 | 	int s = args->sock; | 23 | 	int s = args->sock; |
| 21 | 	void (*func)(union sigval) = args->sev->sigev_notify_function; | 24 | 	void (*func)(union sigval) = args->sev->sigev_notify_function; |
| 22 | 	union sigval val = args->sev->sigev_value; | 25 | 	union sigval val = args->sev->sigev_value; |
| 26 | 	struct sigevent sev2; | ||
| 27 | 	static const char zeros[32]; | ||
| 28 | 	int err; | ||
| 29 | |||
| 30 | 	sev2.sigev_notify = SIGEV_THREAD; | ||
| 31 | 	sev2.sigev_signo = s; | ||
| 32 | 	sev2.sigev_value.sival_ptr = (void *)&zeros; | ||
| 33 | |||
| 34 | 	args->err = err = -__syscall(SYS_mq_notify, args->mqd, &sev2); | ||
| 35 | 	sem_post(&args->sem); | ||
| 36 | 	if (err) return 0; | ||
| 23 | 37 | ||
| 24 | 	pthread_barrier_wait(&args->barrier); | 38 | 	pthread_detach(pthread_self()); |
| 25 | 	n = recv(s, buf, sizeof(buf), MSG_NOSIGNAL|MSG_WAITALL); | 39 | 	n = recv(s, buf, sizeof(buf), MSG_NOSIGNAL|MSG_WAITALL); |
| 26 | 	close(s); | 40 | 	close(s); |
| 27 | 	if (n==sizeof buf && buf[sizeof buf - 1] == 1) | 41 | 	if (n==sizeof buf && buf[sizeof buf - 1] == 1) |
| ... | @@ -35,8 +49,8 @@ int mq_notify(mqd_t mqd, const struct sigevent *sev) | ... | @@ -35,8 +49,8 @@ int mq_notify(mqd_t mqd, const struct sigevent *sev) |
| 35 | 	pthread_attr_t attr; | 49 | 	pthread_attr_t attr; |
| 36 | 	pthread_t td; | 50 | 	pthread_t td; |
| 37 | 	int s; | 51 | 	int s; |
| 38 | 	struct sigevent sev2; | 52 | 	int cs; |
| 39 | 	static const char zeros[32]; | 53 | 	sigset_t allmask, origmask; |
| 40 | 54 | ||
| 41 | 	if (!sev || sev->sigev_notify != SIGEV_THREAD) | 55 | 	if (!sev || sev->sigev_notify != SIGEV_THREAD) |
| 42 | 		return syscall(SYS_mq_notify, mqd, sev); | 56 | 		return syscall(SYS_mq_notify, mqd, sev); |
| ... | @@ -44,30 +58,35 @@ int mq_notify(mqd_t mqd, const struct sigevent *sev) | ... | @@ -44,30 +58,35 @@ int mq_notify(mqd_t mqd, const struct sigevent *sev) |
| 44 | 	s = socket(AF_NETLINK, SOCK_RAW|SOCK_CLOEXEC, 0); | 58 | 	s = socket(AF_NETLINK, SOCK_RAW|SOCK_CLOEXEC, 0); |
| 45 | 	if (s < 0) return -1; | 59 | 	if (s < 0) return -1; |
| 46 | 	args.sock = s; | 60 | 	args.sock = s; |
| 61 | 	args.mqd = mqd; | ||
| 47 | 62 | ||
| 48 | 	if (sev->sigev_notify_attributes) attr = *sev->sigev_notify_attributes; | 63 | 	if (sev->sigev_notify_attributes) attr = *sev->sigev_notify_attributes; |
| 49 | 	else pthread_attr_init(&attr); | 64 | 	else pthread_attr_init(&attr); |
| 50 | 	pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); | 65 | 	pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); |
| 51 | 	pthread_barrier_init(&args.barrier, 0, 2); | 66 | 	sem_init(&args.sem, 0, 0); |
| 52 | 67 | ||
| 68 | 	sigfillset(&allmask); | ||
| 69 | 	pthread_sigmask(SIG_BLOCK, &allmask, &origmask); | ||
| 53 | 	if (pthread_create(&td, &attr, start, &args)) { | 70 | 	if (pthread_create(&td, &attr, start, &args)) { |
| 54 | 		__syscall(SYS_close, s); | 71 | 		__syscall(SYS_close, s); |
| 72 | 		pthread_sigmask(SIG_SETMASK, &origmask, 0); | ||
| 55 | 		errno = EAGAIN; | 73 | 		errno = EAGAIN; |
| 56 | 		return -1; | 74 | 		return -1; |
| 57 | 	} | 75 | 	} |
| 76 | 	pthread_sigmask(SIG_SETMASK, &origmask, 0); | ||
| 58 | 77 | ||
| 59 | 	pthread_barrier_wait(&args.barrier); | 78 | 	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs); |
| 60 | 	pthread_barrier_destroy(&args.barrier); | 79 | 	sem_wait(&args.sem); |
| 61 | 80 | 	sem_destroy(&args.sem); | |
| 62 | 	sev2.sigev_notify = SIGEV_THREAD; | ||
| 63 | 	sev2.sigev_signo = s; | ||
| 64 | 	sev2.sigev_value.sival_ptr = (void *)&zeros; | ||
| 65 | 81 | ||
| 66 | 	if (syscall(SYS_mq_notify, mqd, &sev2) < 0) { | 82 | 	if (args.err) { |
| 67 | 		pthread_cancel(td); | ||
| 68 | 		__syscall(SYS_close, s); | 83 | 		__syscall(SYS_close, s); |
| 84 | 		pthread_join(td, 0); | ||
| 85 | 		pthread_setcancelstate(cs, 0); | ||
| 86 | 		errno = args.err; | ||
| 69 | 		return -1; | 87 | 		return -1; |
| 70 | 	} | 88 | 	} |
| 71 | 89 | ||
| 90 | 	pthread_setcancelstate(cs, 0); | ||
| 72 | 	return 0; | 91 | 	return 0; |
| 73 | } | 92 | } |
lib/libc/musl/src/network/accept4.c+4| ... | @@ -9,6 +9,10 @@ int accept4(int fd, struct sockaddr *restrict addr, socklen_t *restrict len, int | ... | @@ -9,6 +9,10 @@ int accept4(int fd, struct sockaddr *restrict addr, socklen_t *restrict len, int |
| 9 | 	if (!flg) return accept(fd, addr, len); | 9 | 	if (!flg) return accept(fd, addr, len); |
| 10 | 	int ret = socketcall_cp(accept4, fd, addr, len, flg, 0, 0); | 10 | 	int ret = socketcall_cp(accept4, fd, addr, len, flg, 0, 0); |
| 11 | 	if (ret>=0 || (errno != ENOSYS && errno != EINVAL)) return ret; | 11 | 	if (ret>=0 || (errno != ENOSYS && errno != EINVAL)) return ret; |
| 12 | 	if (flg & ~(SOCK_CLOEXEC|SOCK_NONBLOCK)) { | ||
| 13 | 		errno = EINVAL; | ||
| 14 | 		return -1; | ||
| 15 | 	} | ||
| 12 | 	ret = accept(fd, addr, len); | 16 | 	ret = accept(fd, addr, len); |
| 13 | 	if (ret<0) return ret; | 17 | 	if (ret<0) return ret; |
| 14 | 	if (flg & SOCK_CLOEXEC) | 18 | 	if (flg & SOCK_CLOEXEC) |
lib/libc/musl/src/network/dns_parse.c+5-5| ... | @@ -1,7 +1,7 @@ | ... | @@ -1,7 +1,7 @@ |
| 1 | #include <string.h> | 1 | #include <string.h> |
| 2 | #include "lookup.h" | 2 | #include "lookup.h" |
| 3 | 3 | ||
| 4 | int __dns_parse(const unsigned char *r, int rlen, int (*callback)(void *, int, const void *, int, const void *), void *ctx) | 4 | int __dns_parse(const unsigned char *r, int rlen, int (*callback)(void *, int, const void *, int, const void *, int), void *ctx) |
| 5 | { | 5 | { |
| 6 | 	int qdcount, ancount; | 6 | 	int qdcount, ancount; |
| 7 | 	const unsigned char *p; | 7 | 	const unsigned char *p; |
| ... | @@ -15,18 +15,18 @@ int __dns_parse(const unsigned char *r, int rlen, int (*callback)(void *, int, c | ... | @@ -15,18 +15,18 @@ int __dns_parse(const unsigned char *r, int rlen, int (*callback)(void *, int, c |
| 15 | 	if (qdcount+ancount > 64) return -1; | 15 | 	if (qdcount+ancount > 64) return -1; |
| 16 | 	while (qdcount--) { | 16 | 	while (qdcount--) { |
| 17 | 		while (p-r < rlen && *p-1U < 127) p++; | 17 | 		while (p-r < rlen && *p-1U < 127) p++; |
| 18 | 		if (*p>193 || (*p==193 && p[1]>254) || p>r+rlen-6) | 18 | 		if (p>r+rlen-6 || *p>193 || (*p==193 && p[1]>254)) |
| 19 | 			return -1; | 19 | 			return -1; |
| 20 | 		p += 5 + !!*p; | 20 | 		p += 5 + !!*p; |
| 21 | 	} | 21 | 	} |
| 22 | 	while (ancount--) { | 22 | 	while (ancount--) { |
| 23 | 		while (p-r < rlen && *p-1U < 127) p++; | 23 | 		while (p-r < rlen && *p-1U < 127) p++; |
| 24 | 		if (*p>193 || (*p==193 && p[1]>254) || p>r+rlen-6) | 24 | 		if (p>r+rlen-12 || *p>193 || (*p==193 && p[1]>254)) |
| 25 | 			return -1; | 25 | 			return -1; |
| 26 | 		p += 1 + !!*p; | 26 | 		p += 1 + !!*p; |
| 27 | 		len = p[8]*256 + p[9]; | 27 | 		len = p[8]*256 + p[9]; |
| 28 | 		if (p+len > r+rlen) return -1; | 28 | 		if (len+10 > r+rlen-p) return -1; |
| 29 | 		if (callback(ctx, p[1], p+10, len, r) < 0) return -1; | 29 | 		if (callback(ctx, p[1], p+10, len, r, rlen) < 0) return -1; |
| 30 | 		p += 10 + len; | 30 | 		p += 10 + len; |
| 31 | 	} | 31 | 	} |
| 32 | 	return 0; | 32 | 	return 0; |
lib/libc/musl/src/network/gai_strerror.c+1-1| ... | @@ -6,7 +6,7 @@ static const char msgs[] = | ... | @@ -6,7 +6,7 @@ static const char msgs[] = |
| 6 | 	"Name does not resolve\0" | 6 | 	"Name does not resolve\0" |
| 7 | 	"Try again\0" | 7 | 	"Try again\0" |
| 8 | 	"Non-recoverable error\0" | 8 | 	"Non-recoverable error\0" |
| 9 | 	"Unknown error\0" | 9 | 	"Name has no usable address\0" |
| 10 | 	"Unrecognized address family or invalid length\0" | 10 | 	"Unrecognized address family or invalid length\0" |
| 11 | 	"Unrecognized socket type\0" | 11 | 	"Unrecognized socket type\0" |
| 12 | 	"Unrecognized service\0" | 12 | 	"Unrecognized service\0" |
lib/libc/musl/src/network/getaddrinfo.c+6-1| ... | @@ -16,6 +16,7 @@ int getaddrinfo(const char *restrict host, const char *restrict serv, const stru | ... | @@ -16,6 +16,7 @@ int getaddrinfo(const char *restrict host, const char *restrict serv, const stru |
| 16 | 	char canon[256], *outcanon; | 16 | 	char canon[256], *outcanon; |
| 17 | 	int nservs, naddrs, nais, canon_len, i, j, k; | 17 | 	int nservs, naddrs, nais, canon_len, i, j, k; |
| 18 | 	int family = AF_UNSPEC, flags = 0, proto = 0, socktype = 0; | 18 | 	int family = AF_UNSPEC, flags = 0, proto = 0, socktype = 0; |
| 19 | 	int no_family = 0; | ||
| 19 | 	struct aibuf *out; | 20 | 	struct aibuf *out; |
| 20 | 21 | ||
| 21 | 	if (!host && !serv) return EAI_NONAME; | 22 | 	if (!host && !serv) return EAI_NONAME; |
| ... | @@ -66,9 +67,11 @@ int getaddrinfo(const char *restrict host, const char *restrict serv, const stru | ... | @@ -66,9 +67,11 @@ int getaddrinfo(const char *restrict host, const char *restrict serv, const stru |
| 66 | 				pthread_setcancelstate( | 67 | 				pthread_setcancelstate( |
| 67 | 					PTHREAD_CANCEL_DISABLE, &cs); | 68 | 					PTHREAD_CANCEL_DISABLE, &cs); |
| 68 | 				int r = connect(s, ta[i], tl[i]); | 69 | 				int r = connect(s, ta[i], tl[i]); |
| 70 | 				int saved_errno = errno; | ||
| 69 | 				pthread_setcancelstate(cs, 0); | 71 | 				pthread_setcancelstate(cs, 0); |
| 70 | 				close(s); | 72 | 				close(s); |
| 71 | 				if (!r) continue; | 73 | 				if (!r) continue; |
| 74 | 				errno = saved_errno; | ||
| 72 | 			} | 75 | 			} |
| 73 | 			switch (errno) { | 76 | 			switch (errno) { |
| 74 | 			case EADDRNOTAVAIL: | 77 | 			case EADDRNOTAVAIL: |
| ... | @@ -80,7 +83,7 @@ int getaddrinfo(const char *restrict host, const char *restrict serv, const stru | ... | @@ -80,7 +83,7 @@ int getaddrinfo(const char *restrict host, const char *restrict serv, const stru |
| 80 | 			default: | 83 | 			default: |
| 81 | 				return EAI_SYSTEM; | 84 | 				return EAI_SYSTEM; |
| 82 | 			} | 85 | 			} |
| 83 | 			if (family == tf[i]) return EAI_NONAME; | 86 | 			if (family == tf[i]) no_family = 1; |
| 84 | 			family = tf[1-i]; | 87 | 			family = tf[1-i]; |
| 85 | 		} | 88 | 		} |
| 86 | 	} | 89 | 	} |
| ... | @@ -91,6 +94,8 @@ int getaddrinfo(const char *restrict host, const char *restrict serv, const stru | ... | @@ -91,6 +94,8 @@ int getaddrinfo(const char *restrict host, const char *restrict serv, const stru |
| 91 | 	naddrs = __lookup_name(addrs, canon, host, family, flags); | 94 | 	naddrs = __lookup_name(addrs, canon, host, family, flags); |
| 92 | 	if (naddrs < 0) return naddrs; | 95 | 	if (naddrs < 0) return naddrs; |
| 93 | 96 | ||
| 97 | 	if (no_family) return EAI_NODATA; | ||
| 98 | |||
| 94 | 	nais = nservs * naddrs; | 99 | 	nais = nservs * naddrs; |
| 95 | 	canon_len = strlen(canon); | 100 | 	canon_len = strlen(canon); |
| 96 | 	out = calloc(1, nais * sizeof(*out) + canon_len + 1); | 101 | 	out = calloc(1, nais * sizeof(*out) + canon_len + 1); |
lib/libc/musl/src/network/gethostbyaddr.c+1-1| ... | @@ -20,5 +20,5 @@ struct hostent *gethostbyaddr(const void *a, socklen_t l, int af) | ... | @@ -20,5 +20,5 @@ struct hostent *gethostbyaddr(const void *a, socklen_t l, int af) |
| 20 | 		err = gethostbyaddr_r(a, l, af, h, | 20 | 		err = gethostbyaddr_r(a, l, af, h, |
| 21 | 			(void *)(h+1), size-sizeof *h, &res, &h_errno); | 21 | 			(void *)(h+1), size-sizeof *h, &res, &h_errno); |
| 22 | 	} while (err == ERANGE); | 22 | 	} while (err == ERANGE); |
| 23 | 	return err ? 0 : h; | 23 | 	return res; |
| 24 | } | 24 | } |
lib/libc/musl/src/network/gethostbyaddr_r.c+3-2| ... | @@ -54,9 +54,10 @@ int gethostbyaddr_r(const void *a, socklen_t l, int af, | ... | @@ -54,9 +54,10 @@ int gethostbyaddr_r(const void *a, socklen_t l, int af, |
| 54 | 	case EAI_OVERFLOW: | 54 | 	case EAI_OVERFLOW: |
| 55 | 		return ERANGE; | 55 | 		return ERANGE; |
| 56 | 	default: | 56 | 	default: |
| 57 | 	case EAI_MEMORY: | ||
| 58 | 	case EAI_SYSTEM: | ||
| 59 | 	case EAI_FAIL: | 57 | 	case EAI_FAIL: |
| 58 | 		*err = NO_RECOVERY; | ||
| 59 | 		return EBADMSG; | ||
| 60 | 	case EAI_SYSTEM: | ||
| 60 | 		*err = NO_RECOVERY; | 61 | 		*err = NO_RECOVERY; |
| 61 | 		return errno; | 62 | 		return errno; |
| 62 | 	case 0: | 63 | 	case 0: |
lib/libc/musl/src/network/gethostbyname2.c+1-1| ... | @@ -21,5 +21,5 @@ struct hostent *gethostbyname2(const char *name, int af) | ... | @@ -21,5 +21,5 @@ struct hostent *gethostbyname2(const char *name, int af) |
| 21 | 		err = gethostbyname2_r(name, af, h, | 21 | 		err = gethostbyname2_r(name, af, h, |
| 22 | 			(void *)(h+1), size-sizeof *h, &res, &h_errno); | 22 | 			(void *)(h+1), size-sizeof *h, &res, &h_errno); |
| 23 | 	} while (err == ERANGE); | 23 | 	} while (err == ERANGE); |
| 24 | 	return err ? 0 : h; | 24 | 	return res; |
| 25 | } | 25 | } |
lib/libc/musl/src/network/gethostbyname2_r.c+4-2| ... | @@ -22,7 +22,10 @@ int gethostbyname2_r(const char *name, int af, | ... | @@ -22,7 +22,10 @@ int gethostbyname2_r(const char *name, int af, |
| 22 | 	if (cnt<0) switch (cnt) { | 22 | 	if (cnt<0) switch (cnt) { |
| 23 | 	case EAI_NONAME: | 23 | 	case EAI_NONAME: |
| 24 | 		*err = HOST_NOT_FOUND; | 24 | 		*err = HOST_NOT_FOUND; |
| 25 | 		return ENOENT; | 25 | 		return 0; |
| 26 | 	case EAI_NODATA: | ||
| 27 | 		*err = NO_DATA; | ||
| 28 | 		return 0; | ||
| 26 | 	case EAI_AGAIN: | 29 | 	case EAI_AGAIN: |
| 27 | 		*err = TRY_AGAIN; | 30 | 		*err = TRY_AGAIN; |
| 28 | 		return EAGAIN; | 31 | 		return EAGAIN; |
| ... | @@ -30,7 +33,6 @@ int gethostbyname2_r(const char *name, int af, | ... | @@ -30,7 +33,6 @@ int gethostbyname2_r(const char *name, int af, |
| 30 | 	case EAI_FAIL: | 33 | 	case EAI_FAIL: |
| 31 | 		*err = NO_RECOVERY; | 34 | 		*err = NO_RECOVERY; |
| 32 | 		return EBADMSG; | 35 | 		return EBADMSG; |
| 33 | 	case EAI_MEMORY: | ||
| 34 | 	case EAI_SYSTEM: | 36 | 	case EAI_SYSTEM: |
| 35 | 		*err = NO_RECOVERY; | 37 | 		*err = NO_RECOVERY; |
| 36 | 		return errno; | 38 | 		return errno; |
lib/libc/musl/src/network/getifaddrs.c+7-7| ... | @@ -39,8 +39,8 @@ struct ifaddrs_storage { | ... | @@ -39,8 +39,8 @@ struct ifaddrs_storage { |
| 39 | }; | 39 | }; |
| 40 | 40 | ||
| 41 | struct ifaddrs_ctx { | 41 | struct ifaddrs_ctx { |
| 42 | 	struct ifaddrs_storage *first; | 42 | 	struct ifaddrs *first; |
| 43 | 	struct ifaddrs_storage *last; | 43 | 	struct ifaddrs *last; |
| 44 | 	struct ifaddrs_storage *hash[IFADDRS_HASH_SIZE]; | 44 | 	struct ifaddrs_storage *hash[IFADDRS_HASH_SIZE]; |
| 45 | }; | 45 | }; |
| 46 | 46 | ||
| ... | @@ -195,9 +195,9 @@ static int netlink_msg_to_ifaddr(void *pctx, struct nlmsghdr *h) | ... | @@ -195,9 +195,9 @@ static int netlink_msg_to_ifaddr(void *pctx, struct nlmsghdr *h) |
| 195 | 	} | 195 | 	} |
| 196 | 196 | ||
| 197 | 	if (ifs->ifa.ifa_name) { | 197 | 	if (ifs->ifa.ifa_name) { |
| 198 | 		if (!ctx->first) ctx->first = ifs; | 198 | 		if (!ctx->first) ctx->first = &ifs->ifa; |
| 199 | 		if (ctx->last) ctx->last->ifa.ifa_next = &ifs->ifa; | 199 | 		if (ctx->last) ctx->last->ifa_next = &ifs->ifa; |
| 200 | 		ctx->last = ifs; | 200 | 		ctx->last = &ifs->ifa; |
| 201 | 	} else { | 201 | 	} else { |
| 202 | 		free(ifs); | 202 | 		free(ifs); |
| 203 | 	} | 203 | 	} |
| ... | @@ -210,7 +210,7 @@ int getifaddrs(struct ifaddrs **ifap) | ... | @@ -210,7 +210,7 @@ int getifaddrs(struct ifaddrs **ifap) |
| 210 | 	int r; | 210 | 	int r; |
| 211 | 	memset(ctx, 0, sizeof *ctx); | 211 | 	memset(ctx, 0, sizeof *ctx); |
| 212 | 	r = __rtnetlink_enumerate(AF_UNSPEC, AF_UNSPEC, netlink_msg_to_ifaddr, ctx); | 212 | 	r = __rtnetlink_enumerate(AF_UNSPEC, AF_UNSPEC, netlink_msg_to_ifaddr, ctx); |
| 213 | 	if (r == 0) *ifap = &ctx->first->ifa; | 213 | 	if (r == 0) *ifap = ctx->first; |
| 214 | 	else freeifaddrs(&ctx->first->ifa); | 214 | 	else freeifaddrs(ctx->first); |
| 215 | 	return r; | 215 | 	return r; |
| 216 | } | 216 | } |
lib/libc/musl/src/network/getnameinfo.c+3-2| ... | @@ -58,6 +58,7 @@ static void reverse_hosts(char *buf, const unsigned char *a, unsigned scopeid, i | ... | @@ -58,6 +58,7 @@ static void reverse_hosts(char *buf, const unsigned char *a, unsigned scopeid, i |
| 58 | 		if ((p=strchr(line, '#'))) *p++='\n', *p=0; | 58 | 		if ((p=strchr(line, '#'))) *p++='\n', *p=0; |
| 59 | 59 | ||
| 60 | 		for (p=line; *p && !isspace(*p); p++); | 60 | 		for (p=line; *p && !isspace(*p); p++); |
| 61 | 		if (!*p) continue; | ||
| 61 | 		*p++ = 0; | 62 | 		*p++ = 0; |
| 62 | 		if (__lookup_ipliteral(&iplit, line, AF_UNSPEC)<=0) | 63 | 		if (__lookup_ipliteral(&iplit, line, AF_UNSPEC)<=0) |
| 63 | 			continue; | 64 | 			continue; |
| ... | @@ -108,10 +109,10 @@ static void reverse_services(char *buf, int port, int dgram) | ... | @@ -108,10 +109,10 @@ static void reverse_services(char *buf, int port, int dgram) |
| 108 | 	__fclose_ca(f); | 109 | 	__fclose_ca(f); |
| 109 | } | 110 | } |
| 110 | 111 | ||
| 111 | static int dns_parse_callback(void *c, int rr, const void *data, int len, const void *packet) | 112 | static int dns_parse_callback(void *c, int rr, const void *data, int len, const void *packet, int plen) |
| 112 | { | 113 | { |
| 113 | 	if (rr != RR_PTR) return 0; | 114 | 	if (rr != RR_PTR) return 0; |
| 114 | 	if (__dn_expand(packet, (const unsigned char *)packet + 512, | 115 | 	if (__dn_expand(packet, (const unsigned char *)packet + plen, |
| 115 | 	 data, c, 256) <= 0) | 116 | 	 data, c, 256) <= 0) |
| 116 | 		*(char *)c = 0; | 117 | 		*(char *)c = 0; |
| 117 | 	return 0; | 118 | 	return 0; |
lib/libc/musl/src/network/getservbyport_r.c+3-1| ... | @@ -26,7 +26,7 @@ int getservbyport_r(int port, const char *prots, | ... | @@ -26,7 +26,7 @@ int getservbyport_r(int port, const char *prots, |
| 26 | 	/* Align buffer */ | 26 | 	/* Align buffer */ |
| 27 | 	i = (uintptr_t)buf & sizeof(char *)-1; | 27 | 	i = (uintptr_t)buf & sizeof(char *)-1; |
| 28 | 	if (!i) i = sizeof(char *); | 28 | 	if (!i) i = sizeof(char *); |
| 29 | 	if (buflen < 3*sizeof(char *)-i) | 29 | 	if (buflen <= 3*sizeof(char *)-i) |
| 30 | 		return ERANGE; | 30 | 		return ERANGE; |
| 31 | 	buf += sizeof(char *)-i; | 31 | 	buf += sizeof(char *)-i; |
| 32 | 	buflen -= sizeof(char *)-i; | 32 | 	buflen -= sizeof(char *)-i; |
| ... | @@ -46,6 +46,8 @@ int getservbyport_r(int port, const char *prots, | ... | @@ -46,6 +46,8 @@ int getservbyport_r(int port, const char *prots, |
| 46 | 	case EAI_MEMORY: | 46 | 	case EAI_MEMORY: |
| 47 | 	case EAI_SYSTEM: | 47 | 	case EAI_SYSTEM: |
| 48 | 		return ENOMEM; | 48 | 		return ENOMEM; |
| 49 | 	case EAI_OVERFLOW: | ||
| 50 | 		return ERANGE; | ||
| 49 | 	default: | 51 | 	default: |
| 50 | 		return ENOENT; | 52 | 		return ENOENT; |
| 51 | 	case 0: | 53 | 	case 0: |
lib/libc/musl/src/network/inet_pton.c+1| ... | @@ -54,6 +54,7 @@ int inet_pton(int af, const char *restrict s, void *restrict a0) | ... | @@ -54,6 +54,7 @@ int inet_pton(int af, const char *restrict s, void *restrict a0) |
| 54 | 			if (s[j]!='.' || (i<6 && brk<0)) return 0; | 54 | 			if (s[j]!='.' || (i<6 && brk<0)) return 0; |
| 55 | 			need_v4=1; | 55 | 			need_v4=1; |
| 56 | 			i++; | 56 | 			i++; |
| 57 | 			ip[i&7]=0; | ||
| 57 | 			break; | 58 | 			break; |
| 58 | 		} | 59 | 		} |
| 59 | 		s += j+1; | 60 | 		s += j+1; |
lib/libc/musl/src/network/lookup.h+1-1| ... | @@ -50,6 +50,6 @@ hidden int __lookup_ipliteral(struct address buf[static 1], const char *name, in | ... | @@ -50,6 +50,6 @@ hidden int __lookup_ipliteral(struct address buf[static 1], const char *name, in |
| 50 | hidden int __get_resolv_conf(struct resolvconf *, char *, size_t); | 50 | hidden int __get_resolv_conf(struct resolvconf *, char *, size_t); |
| 51 | hidden int __res_msend_rc(int, const unsigned char *const *, const int *, unsigned char *const *, int *, int, const struct resolvconf *); | 51 | hidden int __res_msend_rc(int, const unsigned char *const *, const int *, unsigned char *const *, int *, int, const struct resolvconf *); |
| 52 | 52 | ||
| 53 | hidden int __dns_parse(const unsigned char *, int, int (*)(void *, int, const void *, int, const void *), void *); | 53 | hidden int __dns_parse(const unsigned char *, int, int (*)(void *, int, const void *, int, const void *, int), void *); |
| 54 | 54 | ||
| 55 | #endif | 55 | #endif |
lib/libc/musl/src/network/lookup_ipliteral.c+2-2| ... | @@ -15,7 +15,7 @@ int __lookup_ipliteral(struct address buf[static 1], const char *name, int famil | ... | @@ -15,7 +15,7 @@ int __lookup_ipliteral(struct address buf[static 1], const char *name, int famil |
| 15 | 	struct in6_addr a6; | 15 | 	struct in6_addr a6; |
| 16 | 	if (__inet_aton(name, &a4) > 0) { | 16 | 	if (__inet_aton(name, &a4) > 0) { |
| 17 | 		if (family == AF_INET6) /* wrong family */ | 17 | 		if (family == AF_INET6) /* wrong family */ |
| 18 | 			return EAI_NONAME; | 18 | 			return EAI_NODATA; |
| 19 | 		memcpy(&buf[0].addr, &a4, sizeof a4); | 19 | 		memcpy(&buf[0].addr, &a4, sizeof a4); |
| 20 | 		buf[0].family = AF_INET; | 20 | 		buf[0].family = AF_INET; |
| 21 | 		buf[0].scopeid = 0; | 21 | 		buf[0].scopeid = 0; |
| ... | @@ -34,7 +34,7 @@ int __lookup_ipliteral(struct address buf[static 1], const char *name, int famil | ... | @@ -34,7 +34,7 @@ int __lookup_ipliteral(struct address buf[static 1], const char *name, int famil |
| 34 | 	if (inet_pton(AF_INET6, name, &a6) <= 0) | 34 | 	if (inet_pton(AF_INET6, name, &a6) <= 0) |
| 35 | 		return 0; | 35 | 		return 0; |
| 36 | 	if (family == AF_INET) /* wrong family */ | 36 | 	if (family == AF_INET) /* wrong family */ |
| 37 | 		return EAI_NONAME; | 37 | 		return EAI_NODATA; |
| 38 | 38 | ||
| 39 | 	memcpy(&buf[0].addr, &a6, sizeof a6); | 39 | 	memcpy(&buf[0].addr, &a6, sizeof a6); |
| 40 | 	buf[0].family = AF_INET6; | 40 | 	buf[0].family = AF_INET6; |
lib/libc/musl/src/network/lookup_name.c+31-19| ... | @@ -79,7 +79,7 @@ static int name_from_hosts(struct address buf[static MAXADDRS], char canon[stati | ... | @@ -79,7 +79,7 @@ static int name_from_hosts(struct address buf[static MAXADDRS], char canon[stati |
| 79 | 		case 0: | 79 | 		case 0: |
| 80 | 			continue; | 80 | 			continue; |
| 81 | 		default: | 81 | 		default: |
| 82 | 			badfam = EAI_NONAME; | 82 | 			badfam = EAI_NODATA; |
| 83 | 			break; | 83 | 			break; |
| 84 | 		} | 84 | 		} |
| 85 | 85 | ||
| ... | @@ -102,45 +102,50 @@ struct dpc_ctx { | ... | @@ -102,45 +102,50 @@ struct dpc_ctx { |
| 102 | 	struct address *addrs; | 102 | 	struct address *addrs; |
| 103 | 	char *canon; | 103 | 	char *canon; |
| 104 | 	int cnt; | 104 | 	int cnt; |
| 105 | 	int rrtype; | ||
| 105 | }; | 106 | }; |
| 106 | 107 | ||
| 107 | #define RR_A 1 | 108 | #define RR_A 1 |
| 108 | #define RR_CNAME 5 | 109 | #define RR_CNAME 5 |
| 109 | #define RR_AAAA 28 | 110 | #define RR_AAAA 28 |
| 110 | 111 | ||
| 111 | static int dns_parse_callback(void *c, int rr, const void *data, int len, const void *packet) | 112 | #define ABUF_SIZE 768 |
| 113 | |||
| 114 | static int dns_parse_callback(void *c, int rr, const void *data, int len, const void *packet, int plen) | ||
| 112 | { | 115 | { |
| 113 | 	char tmp[256]; | 116 | 	char tmp[256]; |
| 117 | 	int family; | ||
| 114 | 	struct dpc_ctx *ctx = c; | 118 | 	struct dpc_ctx *ctx = c; |
| 115 | 	if (ctx->cnt >= MAXADDRS) return -1; | 119 | 	if (rr == RR_CNAME) { |
| 120 | 		if (__dn_expand(packet, (const unsigned char *)packet + plen, | ||
| 121 | 		 data, tmp, sizeof tmp) > 0 && is_valid_hostname(tmp)) | ||
| 122 | 			strcpy(ctx->canon, tmp); | ||
| 123 | 		return 0; | ||
| 124 | 	} | ||
| 125 | 	if (ctx->cnt >= MAXADDRS) return 0; | ||
| 126 | 	if (rr != ctx->rrtype) return 0; | ||
| 116 | 	switch (rr) { | 127 | 	switch (rr) { |
| 117 | 	case RR_A: | 128 | 	case RR_A: |
| 118 | 		if (len != 4) return -1; | 129 | 		if (len != 4) return -1; |
| 119 | 		ctx->addrs[ctx->cnt].family = AF_INET; | 130 | 		family = AF_INET; |
| 120 | 		ctx->addrs[ctx->cnt].scopeid = 0; | ||
| 121 | 		memcpy(ctx->addrs[ctx->cnt++].addr, data, 4); | ||
| 122 | 		break; | 131 | 		break; |
| 123 | 	case RR_AAAA: | 132 | 	case RR_AAAA: |
| 124 | 		if (len != 16) return -1; | 133 | 		if (len != 16) return -1; |
| 125 | 		ctx->addrs[ctx->cnt].family = AF_INET6; | 134 | 		family = AF_INET6; |
| 126 | 		ctx->addrs[ctx->cnt].scopeid = 0; | ||
| 127 | 		memcpy(ctx->addrs[ctx->cnt++].addr, data, 16); | ||
| 128 | 		break; | ||
| 129 | 	case RR_CNAME: | ||
| 130 | 		if (__dn_expand(packet, (const unsigned char *)packet + 512, | ||
| 131 | 		 data, tmp, sizeof tmp) > 0 && is_valid_hostname(tmp)) | ||
| 132 | 			strcpy(ctx->canon, tmp); | ||
| 133 | 		break; | 135 | 		break; |
| 134 | 	} | 136 | 	} |
| 137 | 	ctx->addrs[ctx->cnt].family = family; | ||
| 138 | 	ctx->addrs[ctx->cnt].scopeid = 0; | ||
| 139 | 	memcpy(ctx->addrs[ctx->cnt++].addr, data, len); | ||
| 135 | 	return 0; | 140 | 	return 0; |
| 136 | } | 141 | } |
| 137 | 142 | ||
| 138 | static int name_from_dns(struct address buf[static MAXADDRS], char canon[static 256], const char *name, int family, const struct resolvconf *conf) | 143 | static int name_from_dns(struct address buf[static MAXADDRS], char canon[static 256], const char *name, int family, const struct resolvconf *conf) |
| 139 | { | 144 | { |
| 140 | 	unsigned char qbuf[2][280], abuf[2][512]; | 145 | 	unsigned char qbuf[2][280], abuf[2][ABUF_SIZE]; |
| 141 | 	const unsigned char *qp[2] = { qbuf[0], qbuf[1] }; | 146 | 	const unsigned char *qp[2] = { qbuf[0], qbuf[1] }; |
| 142 | 	unsigned char *ap[2] = { abuf[0], abuf[1] }; | 147 | 	unsigned char *ap[2] = { abuf[0], abuf[1] }; |
| 143 | 	int qlens[2], alens[2]; | 148 | 	int qlens[2], alens[2], qtypes[2]; |
| 144 | 	int i, nq = 0; | 149 | 	int i, nq = 0; |
| 145 | 	struct dpc_ctx ctx = { .addrs = buf, .canon = canon }; | 150 | 	struct dpc_ctx ctx = { .addrs = buf, .canon = canon }; |
| 146 | 	static const struct { int af; int rr; } afrr[2] = { | 151 | 	static const struct { int af; int rr; } afrr[2] = { |
| ... | @@ -153,8 +158,12 @@ static int name_from_dns(struct address buf[static MAXADDRS], char canon[static | ... | @@ -153,8 +158,12 @@ static int name_from_dns(struct address buf[static MAXADDRS], char canon[static |
| 153 | 			qlens[nq] = __res_mkquery(0, name, 1, afrr[i].rr, | 158 | 			qlens[nq] = __res_mkquery(0, name, 1, afrr[i].rr, |
| 154 | 				0, 0, 0, qbuf[nq], sizeof *qbuf); | 159 | 				0, 0, 0, qbuf[nq], sizeof *qbuf); |
| 155 | 			if (qlens[nq] == -1) | 160 | 			if (qlens[nq] == -1) |
| 156 | 				return EAI_NONAME; | 161 | 				return 0; |
| 162 | 			qtypes[nq] = afrr[i].rr; | ||
| 157 | 			qbuf[nq][3] = 0; /* don't need AD flag */ | 163 | 			qbuf[nq][3] = 0; /* don't need AD flag */ |
| 164 | 			/* Ensure query IDs are distinct. */ | ||
| 165 | 			if (nq && qbuf[nq][0] == qbuf[0][0]) | ||
| 166 | 				qbuf[nq][0]++; | ||
| 158 | 			nq++; | 167 | 			nq++; |
| 159 | 		} | 168 | 		} |
| 160 | 	} | 169 | 	} |
| ... | @@ -168,11 +177,14 @@ static int name_from_dns(struct address buf[static MAXADDRS], char canon[static | ... | @@ -168,11 +177,14 @@ static int name_from_dns(struct address buf[static MAXADDRS], char canon[static |
| 168 | 		if ((abuf[i][3] & 15) != 0) return EAI_FAIL; | 177 | 		if ((abuf[i][3] & 15) != 0) return EAI_FAIL; |
| 169 | 	} | 178 | 	} |
| 170 | 179 | ||
| 171 | 	for (i=0; i<nq; i++) | 180 | 	for (i=nq-1; i>=0; i--) { |
| 181 | 		ctx.rrtype = qtypes[i]; | ||
| 182 | 		if (alens[i] > sizeof(abuf[i])) alens[i] = sizeof abuf[i]; | ||
| 172 | 		__dns_parse(abuf[i], alens[i], dns_parse_callback, &ctx); | 183 | 		__dns_parse(abuf[i], alens[i], dns_parse_callback, &ctx); |
| 184 | 	} | ||
| 173 | 185 | ||
| 174 | 	if (ctx.cnt) return ctx.cnt; | 186 | 	if (ctx.cnt) return ctx.cnt; |
| 175 | 	return EAI_NONAME; | 187 | 	return EAI_NODATA; |
| 176 | } | 188 | } |
| 177 | 189 | ||
| 178 | static int name_from_dns_search(struct address buf[static MAXADDRS], char canon[static 256], const char *name, int family) | 190 | static int name_from_dns_search(struct address buf[static MAXADDRS], char canon[static 256], const char *name, int family) |
lib/libc/musl/src/network/netlink.h+1-1| ... | @@ -86,7 +86,7 @@ struct ifaddrmsg { | ... | @@ -86,7 +86,7 @@ struct ifaddrmsg { |
| 86 | #define RTA_DATALEN(rta)	((rta)->rta_len-sizeof(struct rtattr)) | 86 | #define RTA_DATALEN(rta)	((rta)->rta_len-sizeof(struct rtattr)) |
| 87 | #define RTA_DATAEND(rta)	((char*)(rta)+(rta)->rta_len) | 87 | #define RTA_DATAEND(rta)	((char*)(rta)+(rta)->rta_len) |
| 88 | #define RTA_NEXT(rta)		(struct rtattr*)((char*)(rta)+NETLINK_ALIGN((rta)->rta_len)) | 88 | #define RTA_NEXT(rta)		(struct rtattr*)((char*)(rta)+NETLINK_ALIGN((rta)->rta_len)) |
| 89 | #define RTA_OK(nlh,end)		((char*)(end)-(char*)(rta) >= sizeof(struct rtattr)) | 89 | #define RTA_OK(rta,end)		((char*)(end)-(char*)(rta) >= sizeof(struct rtattr)) |
| 90 | 90 | ||
| 91 | #define NLMSG_RTA(nlh,len)	((void*)((char*)(nlh)+sizeof(struct nlmsghdr)+NETLINK_ALIGN(len))) | 91 | #define NLMSG_RTA(nlh,len)	((void*)((char*)(nlh)+sizeof(struct nlmsghdr)+NETLINK_ALIGN(len))) |
| 92 | #define NLMSG_RTAOK(rta,nlh)	RTA_OK(rta,NLMSG_DATAEND(nlh)) | 92 | #define NLMSG_RTAOK(rta,nlh)	RTA_OK(rta,NLMSG_DATAEND(nlh)) |
lib/libc/musl/src/network/res_mkquery.c+1| ... | @@ -13,6 +13,7 @@ int __res_mkquery(int op, const char *dname, int class, int type, | ... | @@ -13,6 +13,7 @@ int __res_mkquery(int op, const char *dname, int class, int type, |
| 13 | 	int n; | 13 | 	int n; |
| 14 | 14 | ||
| 15 | 	if (l && dname[l-1]=='.') l--; | 15 | 	if (l && dname[l-1]=='.') l--; |
| 16 | 	if (l && dname[l-1]=='.') return -1; | ||
| 16 | 	n = 17+l+!!l; | 17 | 	n = 17+l+!!l; |
| 17 | 	if (l>253 || buflen<n || op>15u || class>255u || type>255u) | 18 | 	if (l>253 || buflen<n || op>15u || class>255u || type>255u) |
| 18 | 		return -1; | 19 | 		return -1; |
lib/libc/musl/src/network/res_msend.c+160-23| ... | @@ -1,5 +1,6 @@ | ... | @@ -1,5 +1,6 @@ |
| 1 | #include <sys/socket.h> | 1 | #include <sys/socket.h> |
| 2 | #include <netinet/in.h> | 2 | #include <netinet/in.h> |
| 3 | #include <netinet/tcp.h> | ||
| 3 | #include <netdb.h> | 4 | #include <netdb.h> |
| 4 | #include <arpa/inet.h> | 5 | #include <arpa/inet.h> |
| 5 | #include <stdint.h> | 6 | #include <stdint.h> |
| ... | @@ -16,17 +17,65 @@ | ... | @@ -16,17 +17,65 @@ |
| 16 | 17 | ||
| 17 | static void cleanup(void *p) | 18 | static void cleanup(void *p) |
| 18 | { | 19 | { |
| 19 | 	__syscall(SYS_close, (intptr_t)p); | 20 | 	struct pollfd *pfd = p; |
| 21 | 	for (int i=0; pfd[i].fd >= -1; i++) | ||
| 22 | 		if (pfd[i].fd >= 0) __syscall(SYS_close, pfd[i].fd); | ||
| 20 | } | 23 | } |
| 21 | 24 | ||
| 22 | static unsigned long mtime() | 25 | static unsigned long mtime() |
| 23 | { | 26 | { |
| 24 | 	struct timespec ts; | 27 | 	struct timespec ts; |
| 25 | 	clock_gettime(CLOCK_REALTIME, &ts); | 28 | 	if (clock_gettime(CLOCK_MONOTONIC, &ts) < 0 && errno == ENOSYS) |
| 29 | 		clock_gettime(CLOCK_REALTIME, &ts); | ||
| 26 | 	return (unsigned long)ts.tv_sec * 1000 | 30 | 	return (unsigned long)ts.tv_sec * 1000 |
| 27 | 		+ ts.tv_nsec / 1000000; | 31 | 		+ ts.tv_nsec / 1000000; |
| 28 | } | 32 | } |
| 29 | 33 | ||
| 34 | static int start_tcp(struct pollfd *pfd, int family, const void *sa, socklen_t sl, const unsigned char *q, int ql) | ||
| 35 | { | ||
| 36 | 	struct msghdr mh = { | ||
| 37 | 		.msg_name = (void *)sa, | ||
| 38 | 		.msg_namelen = sl, | ||
| 39 | 		.msg_iovlen = 2, | ||
| 40 | 		.msg_iov = (struct iovec [2]){ | ||
| 41 | 			{ .iov_base = (uint8_t[]){ ql>>8, ql }, .iov_len = 2 }, | ||
| 42 | 			{ .iov_base = (void *)q, .iov_len = ql } } | ||
| 43 | 	}; | ||
| 44 | 	int r; | ||
| 45 | 	int fd = socket(family, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0); | ||
| 46 | 	pfd->fd = fd; | ||
| 47 | 	pfd->events = POLLOUT; | ||
| 48 | 	if (!setsockopt(fd, IPPROTO_TCP, TCP_FASTOPEN_CONNECT, | ||
| 49 | 	 &(int){1}, sizeof(int))) { | ||
| 50 | 		r = sendmsg(fd, &mh, MSG_FASTOPEN|MSG_NOSIGNAL); | ||
| 51 | 		if (r == ql+2) pfd->events = POLLIN; | ||
| 52 | 		if (r >= 0) return r; | ||
| 53 | 		if (errno == EINPROGRESS) return 0; | ||
| 54 | 	} | ||
| 55 | 	r = connect(fd, sa, sl); | ||
| 56 | 	if (!r || errno == EINPROGRESS) return 0; | ||
| 57 | 	close(fd); | ||
| 58 | 	pfd->fd = -1; | ||
| 59 | 	return -1; | ||
| 60 | } | ||
| 61 | |||
| 62 | static void step_mh(struct msghdr *mh, size_t n) | ||
| 63 | { | ||
| 64 | 	/* Adjust iovec in msghdr to skip first n bytes. */ | ||
| 65 | 	while (mh->msg_iovlen && n >= mh->msg_iov->iov_len) { | ||
| 66 | 		n -= mh->msg_iov->iov_len; | ||
| 67 | 		mh->msg_iov++; | ||
| 68 | 		mh->msg_iovlen--; | ||
| 69 | 	} | ||
| 70 | 	if (!mh->msg_iovlen) return; | ||
| 71 | 	mh->msg_iov->iov_base = (char *)mh->msg_iov->iov_base + n; | ||
| 72 | 	mh->msg_iov->iov_len -= n; | ||
| 73 | } | ||
| 74 | |||
| 75 | /* Internal contract for __res_msend[_rc]: asize must be >=512, nqueries | ||
| 76 | * must be sufficiently small to be safe as VLA size. In practice it's | ||
| 77 | * either 1 or 2, anyway. */ | ||
| 78 | |||
| 30 | int __res_msend_rc(int nqueries, const unsigned char *const *queries, | 79 | int __res_msend_rc(int nqueries, const unsigned char *const *queries, |
| 31 | 	const int *qlens, unsigned char *const *answers, int *alens, int asize, | 80 | 	const int *qlens, unsigned char *const *answers, int *alens, int asize, |
| 32 | 	const struct resolvconf *conf) | 81 | 	const struct resolvconf *conf) |
| ... | @@ -44,7 +93,10 @@ int __res_msend_rc(int nqueries, const unsigned char *const *queries, | ... | @@ -44,7 +93,10 @@ int __res_msend_rc(int nqueries, const unsigned char *const *queries, |
| 44 | 	int next; | 93 | 	int next; |
| 45 | 	int i, j; | 94 | 	int i, j; |
| 46 | 	int cs; | 95 | 	int cs; |
| 47 | 	struct pollfd pfd; | 96 | 	struct pollfd pfd[nqueries+2]; |
| 97 | 	int qpos[nqueries], apos[nqueries]; | ||
| 98 | 	unsigned char alen_buf[nqueries][2]; | ||
| 99 | 	int r; | ||
| 48 | 	unsigned long t0, t1, t2; | 100 | 	unsigned long t0, t1, t2; |
| 49 | 101 | ||
| 50 | 	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs); | 102 | 	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs); |
| ... | @@ -68,29 +120,22 @@ int __res_msend_rc(int nqueries, const unsigned char *const *queries, | ... | @@ -68,29 +120,22 @@ int __res_msend_rc(int nqueries, const unsigned char *const *queries, |
| 68 | 	} | 120 | 	} |
| 69 | 121 | ||
| 70 | 	/* Get local address and open/bind a socket */ | 122 | 	/* Get local address and open/bind a socket */ |
| 71 | 	sa.sin.sin_family = family; | ||
| 72 | 	fd = socket(family, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0); | 123 | 	fd = socket(family, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0); |
| 73 | 124 | ||
| 74 | 	/* Handle case where system lacks IPv6 support */ | 125 | 	/* Handle case where system lacks IPv6 support */ |
| 75 | 	if (fd < 0 && family == AF_INET6 && errno == EAFNOSUPPORT) { | 126 | 	if (fd < 0 && family == AF_INET6 && errno == EAFNOSUPPORT) { |
| 127 | 		for (i=0; i<nns && conf->ns[nns].family == AF_INET6; i++); | ||
| 128 | 		if (i==nns) { | ||
| 129 | 			pthread_setcancelstate(cs, 0); | ||
| 130 | 			return -1; | ||
| 131 | 		} | ||
| 76 | 		fd = socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0); | 132 | 		fd = socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0); |
| 77 | 		family = AF_INET; | 133 | 		family = AF_INET; |
| 134 | 		sl = sizeof sa.sin; | ||
| 78 | 	} | 135 | 	} |
| 79 | 	if (fd < 0 || bind(fd, (void *)&sa, sl) < 0) { | ||
| 80 | 		if (fd >= 0) close(fd); | ||
| 81 | 		pthread_setcancelstate(cs, 0); | ||
| 82 | 		return -1; | ||
| 83 | 	} | ||
| 84 | |||
| 85 | 	/* Past this point, there are no errors. Each individual query will | ||
| 86 | 	 * yield either no reply (indicated by zero length) or an answer | ||
| 87 | 	 * packet which is up to the caller to interpret. */ | ||
| 88 | |||
| 89 | 	pthread_cleanup_push(cleanup, (void *)(intptr_t)fd); | ||
| 90 | 	pthread_setcancelstate(cs, 0); | ||
| 91 | 136 | ||
| 92 | 	/* Convert any IPv4 addresses in a mixed environment to v4-mapped */ | 137 | 	/* Convert any IPv4 addresses in a mixed environment to v4-mapped */ |
| 93 | 	if (family == AF_INET6) { | 138 | 	if (fd >= 0 && family == AF_INET6) { |
| 94 | 		setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &(int){0}, sizeof 0); | 139 | 		setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &(int){0}, sizeof 0); |
| 95 | 		for (i=0; i<nns; i++) { | 140 | 		for (i=0; i<nns; i++) { |
| 96 | 			if (ns[i].sin.sin_family != AF_INET) continue; | 141 | 			if (ns[i].sin.sin_family != AF_INET) continue; |
| ... | @@ -104,16 +149,38 @@ int __res_msend_rc(int nqueries, const unsigned char *const *queries, | ... | @@ -104,16 +149,38 @@ int __res_msend_rc(int nqueries, const unsigned char *const *queries, |
| 104 | 		} | 149 | 		} |
| 105 | 	} | 150 | 	} |
| 106 | 151 | ||
| 152 | 	sa.sin.sin_family = family; | ||
| 153 | 	if (fd < 0 || bind(fd, (void *)&sa, sl) < 0) { | ||
| 154 | 		if (fd >= 0) close(fd); | ||
| 155 | 		pthread_setcancelstate(cs, 0); | ||
| 156 | 		return -1; | ||
| 157 | 	} | ||
| 158 | |||
| 159 | 	/* Past this point, there are no errors. Each individual query will | ||
| 160 | 	 * yield either no reply (indicated by zero length) or an answer | ||
| 161 | 	 * packet which is up to the caller to interpret. */ | ||
| 162 | |||
| 163 | 	for (i=0; i<nqueries; i++) pfd[i].fd = -1; | ||
| 164 | 	pfd[nqueries].fd = fd; | ||
| 165 | 	pfd[nqueries].events = POLLIN; | ||
| 166 | 	pfd[nqueries+1].fd = -2; | ||
| 167 | |||
| 168 | 	pthread_cleanup_push(cleanup, pfd); | ||
| 169 | 	pthread_setcancelstate(cs, 0); | ||
| 170 | |||
| 107 | 	memset(alens, 0, sizeof *alens * nqueries); | 171 | 	memset(alens, 0, sizeof *alens * nqueries); |
| 108 | 172 | ||
| 109 | 	pfd.fd = fd; | ||
| 110 | 	pfd.events = POLLIN; | ||
| 111 | 	retry_interval = timeout / attempts; | 173 | 	retry_interval = timeout / attempts; |
| 112 | 	next = 0; | 174 | 	next = 0; |
| 113 | 	t0 = t2 = mtime(); | 175 | 	t0 = t2 = mtime(); |
| 114 | 	t1 = t2 - retry_interval; | 176 | 	t1 = t2 - retry_interval; |
| 115 | 177 | ||
| 116 | 	for (; t2-t0 < timeout; t2=mtime()) { | 178 | 	for (; t2-t0 < timeout; t2=mtime()) { |
| 179 | 		/* This is the loop exit condition: that all queries | ||
| 180 | 		 * have an accepted answer. */ | ||
| 181 | 		for (i=0; i<nqueries && alens[i]>0; i++); | ||
| 182 | 		if (i==nqueries) break; | ||
| 183 | |||
| 117 | 		if (t2-t1 >= retry_interval) { | 184 | 		if (t2-t1 >= retry_interval) { |
| 118 | 			/* Query all configured namservers in parallel */ | 185 | 			/* Query all configured namservers in parallel */ |
| 119 | 			for (i=0; i<nqueries; i++) | 186 | 			for (i=0; i<nqueries; i++) |
| ... | @@ -127,10 +194,20 @@ int __res_msend_rc(int nqueries, const unsigned char *const *queries, | ... | @@ -127,10 +194,20 @@ int __res_msend_rc(int nqueries, const unsigned char *const *queries, |
| 127 | 		} | 194 | 		} |
| 128 | 195 | ||
| 129 | 		/* Wait for a response, or until time to retry */ | 196 | 		/* Wait for a response, or until time to retry */ |
| 130 | 		if (poll(&pfd, 1, t1+retry_interval-t2) <= 0) continue; | 197 | 		if (poll(pfd, nqueries+1, t1+retry_interval-t2) <= 0) continue; |
| 131 | 198 | ||
| 132 | 		while ((rlen = recvfrom(fd, answers[next], asize, 0, | 199 | 		while (next < nqueries) { |
| 133 | 		 (void *)&sa, (socklen_t[1]){sl})) >= 0) { | 200 | 			struct msghdr mh = { |
| 201 | 				.msg_name = (void *)&sa, | ||
| 202 | 				.msg_namelen = sl, | ||
| 203 | 				.msg_iovlen = 1, | ||
| 204 | 				.msg_iov = (struct iovec []){ | ||
| 205 | 					{ .iov_base = (void *)answers[next], | ||
| 206 | 					 .iov_len = asize } | ||
| 207 | 				} | ||
| 208 | 			}; | ||
| 209 | 			rlen = recvmsg(fd, &mh, 0); | ||
| 210 | 			if (rlen < 0) break; | ||
| 134 | 211 | ||
| 135 | 			/* Ignore non-identifiable packets */ | 212 | 			/* Ignore non-identifiable packets */ |
| 136 | 			if (rlen < 4) continue; | 213 | 			if (rlen < 4) continue; |
| ... | @@ -170,12 +247,72 @@ int __res_msend_rc(int nqueries, const unsigned char *const *queries, | ... | @@ -170,12 +247,72 @@ int __res_msend_rc(int nqueries, const unsigned char *const *queries, |
| 170 | 			else | 247 | 			else |
| 171 | 				memcpy(answers[i], answers[next], rlen); | 248 | 				memcpy(answers[i], answers[next], rlen); |
| 172 | 249 | ||
| 173 | 			if (next == nqueries) goto out; | 250 | 			/* Ignore further UDP if all slots full or TCP-mode */ |
| 251 | 			if (next == nqueries) pfd[nqueries].events = 0; | ||
| 252 | |||
| 253 | 			/* If answer is truncated (TC bit), fallback to TCP */ | ||
| 254 | 			if ((answers[i][2] & 2) || (mh.msg_flags & MSG_TRUNC)) { | ||
| 255 | 				alens[i] = -1; | ||
| 256 | 				pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, 0); | ||
| 257 | 				r = start_tcp(pfd+i, family, ns+j, sl, queries[i], qlens[i]); | ||
| 258 | 				pthread_setcancelstate(cs, 0); | ||
| 259 | 				if (r >= 0) { | ||
| 260 | 					qpos[i] = r; | ||
| 261 | 					apos[i] = 0; | ||
| 262 | 				} | ||
| 263 | 				continue; | ||
| 264 | 			} | ||
| 265 | 		} | ||
| 266 | |||
| 267 | 		for (i=0; i<nqueries; i++) if (pfd[i].revents & POLLOUT) { | ||
| 268 | 			struct msghdr mh = { | ||
| 269 | 				.msg_iovlen = 2, | ||
| 270 | 				.msg_iov = (struct iovec [2]){ | ||
| 271 | 					{ .iov_base = (uint8_t[]){ qlens[i]>>8, qlens[i] }, .iov_len = 2 }, | ||
| 272 | 					{ .iov_base = (void *)queries[i], .iov_len = qlens[i] } } | ||
| 273 | 			}; | ||
| 274 | 			step_mh(&mh, qpos[i]); | ||
| 275 | 			r = sendmsg(pfd[i].fd, &mh, MSG_NOSIGNAL); | ||
| 276 | 			if (r < 0) goto out; | ||
| 277 | 			qpos[i] += r; | ||
| 278 | 			if (qpos[i] == qlens[i]+2) | ||
| 279 | 				pfd[i].events = POLLIN; | ||
| 280 | 		} | ||
| 281 | |||
| 282 | 		for (i=0; i<nqueries; i++) if (pfd[i].revents & POLLIN) { | ||
| 283 | 			struct msghdr mh = { | ||
| 284 | 				.msg_iovlen = 2, | ||
| 285 | 				.msg_iov = (struct iovec [2]){ | ||
| 286 | 					{ .iov_base = alen_buf[i], .iov_len = 2 }, | ||
| 287 | 					{ .iov_base = answers[i], .iov_len = asize } } | ||
| 288 | 			}; | ||
| 289 | 			step_mh(&mh, apos[i]); | ||
| 290 | 			r = recvmsg(pfd[i].fd, &mh, 0); | ||
| 291 | 			if (r <= 0) goto out; | ||
| 292 | 			apos[i] += r; | ||
| 293 | 			if (apos[i] < 2) continue; | ||
| 294 | 			int alen = alen_buf[i][0]*256 + alen_buf[i][1]; | ||
| 295 | 			if (alen < 13) goto out; | ||
| 296 | 			if (apos[i] < alen+2 && apos[i] < asize+2) | ||
| 297 | 				continue; | ||
| 298 | 			int rcode = answers[i][3] & 15; | ||
| 299 | 			if (rcode != 0 && rcode != 3) | ||
| 300 | 				goto out; | ||
| 301 | |||
| 302 | 			/* Storing the length here commits the accepted answer. | ||
| 303 | 			 * Immediately close TCP socket so as not to consume | ||
| 304 | 			 * resources we no longer need. */ | ||
| 305 | 			alens[i] = alen; | ||
| 306 | 			__syscall(SYS_close, pfd[i].fd); | ||
| 307 | 			pfd[i].fd = -1; | ||
| 174 | 		} | 308 | 		} |
| 175 | 	} | 309 | 	} |
| 176 | out: | 310 | out: |
| 177 | 	pthread_cleanup_pop(1); | 311 | 	pthread_cleanup_pop(1); |
| 178 | 312 | ||
| 313 | 	/* Disregard any incomplete TCP results */ | ||
| 314 | 	for (i=0; i<nqueries; i++) if (alens[i]<0) alens[i] = 0; | ||
| 315 | |||
| 179 | 	return 0; | 316 | 	return 0; |
| 180 | } | 317 | } |
| 181 | 318 |
lib/libc/musl/src/network/res_send.c+9-1| ... | @@ -1,8 +1,16 @@ | ... | @@ -1,8 +1,16 @@ |
| 1 | #include <resolv.h> | 1 | #include <resolv.h> |
| 2 | #include <string.h> | ||
| 2 | 3 | ||
| 3 | int __res_send(const unsigned char *msg, int msglen, unsigned char *answer, int anslen) | 4 | int __res_send(const unsigned char *msg, int msglen, unsigned char *answer, int anslen) |
| 4 | { | 5 | { |
| 5 | 	int r = __res_msend(1, &msg, &msglen, &answer, &anslen, anslen); | 6 | 	int r; |
| 7 | 	if (anslen < 512) { | ||
| 8 | 		unsigned char buf[512]; | ||
| 9 | 		r = __res_send(msg, msglen, buf, sizeof buf); | ||
| 10 | 		if (r >= 0) memcpy(answer, buf, r < anslen ? r : anslen); | ||
| 11 | 		return r; | ||
| 12 | 	} | ||
| 13 | 	r = __res_msend(1, &msg, &msglen, &answer, &anslen, anslen); | ||
| 6 | 	return r<0 || !anslen ? -1 : anslen; | 14 | 	return r<0 || !anslen ? -1 : anslen; |
| 7 | } | 15 | } |
| 8 | 16 |
lib/libc/musl/src/network/sendmsg.c+5-2| ... | @@ -8,13 +8,16 @@ ssize_t sendmsg(int fd, const struct msghdr *msg, int flags) | ... | @@ -8,13 +8,16 @@ ssize_t sendmsg(int fd, const struct msghdr *msg, int flags) |
| 8 | { | 8 | { |
| 9 | #if LONG_MAX > INT_MAX | 9 | #if LONG_MAX > INT_MAX |
| 10 | 	struct msghdr h; | 10 | 	struct msghdr h; |
| 11 | 	struct cmsghdr chbuf[1024/sizeof(struct cmsghdr)+1], *c; | 11 | 	/* Kernels before 2.6.38 set SCM_MAX_FD to 255, allocate enough |
| 12 | 	 * space to support an SCM_RIGHTS ancillary message with 255 fds. | ||
| 13 | 	 * Kernels since 2.6.38 set SCM_MAX_FD to 253. */ | ||
| 14 | 	struct cmsghdr chbuf[CMSG_SPACE(255*sizeof(int))/sizeof(struct cmsghdr)+1], *c; | ||
| 12 | 	if (msg) { | 15 | 	if (msg) { |
| 13 | 		h = *msg; | 16 | 		h = *msg; |
| 14 | 		h.__pad1 = h.__pad2 = 0; | 17 | 		h.__pad1 = h.__pad2 = 0; |
| 15 | 		msg = &h; | 18 | 		msg = &h; |
| 16 | 		if (h.msg_controllen) { | 19 | 		if (h.msg_controllen) { |
| 17 | 			if (h.msg_controllen > 1024) { | 20 | 			if (h.msg_controllen > sizeof chbuf) { |
| 18 | 				errno = ENOMEM; | 21 | 				errno = ENOMEM; |
| 19 | 				return -1; | 22 | 				return -1; |
| 20 | 			} | 23 | 			} |
lib/libc/musl/src/process/_Fork.c+1-2| ... | @@ -14,7 +14,6 @@ pid_t _Fork(void) | ... | @@ -14,7 +14,6 @@ pid_t _Fork(void) |
| 14 | 	pid_t ret; | 14 | 	pid_t ret; |
| 15 | 	sigset_t set; | 15 | 	sigset_t set; |
| 16 | 	__block_all_sigs(&set); | 16 | 	__block_all_sigs(&set); |
| 17 | 	__aio_atfork(-1); | ||
| 18 | 	LOCK(__abort_lock); | 17 | 	LOCK(__abort_lock); |
| 19 | #ifdef SYS_fork | 18 | #ifdef SYS_fork |
| 20 | 	ret = __syscall(SYS_fork); | 19 | 	ret = __syscall(SYS_fork); |
| ... | @@ -32,7 +31,7 @@ pid_t _Fork(void) | ... | @@ -32,7 +31,7 @@ pid_t _Fork(void) |
| 32 | 		if (libc.need_locks) libc.need_locks = -1; | 31 | 		if (libc.need_locks) libc.need_locks = -1; |
| 33 | 	} | 32 | 	} |
| 34 | 	UNLOCK(__abort_lock); | 33 | 	UNLOCK(__abort_lock); |
| 35 | 	__aio_atfork(!ret); | 34 | 	if (!ret) __aio_atfork(1); |
| 36 | 	__restore_sigs(&set); | 35 | 	__restore_sigs(&set); |
| 37 | 	return __syscall_ret(ret); | 36 | 	return __syscall_ret(ret); |
| 38 | } | 37 | } |
lib/libc/musl/src/process/aarch64/vfork.s created+9| ... | @@ -0,0 +1,9 @@ | ||
| 1 | .global vfork | ||
| 2 | .type vfork,%function | ||
| 3 | vfork: | ||
| 4 | 	mov x8, 220 // SYS_clone | ||
| 5 | 	mov x0, 0x4111 // SIGCHLD | CLONE_VM | CLONE_VFORK | ||
| 6 | 	mov x1, 0 | ||
| 7 | 	svc 0 | ||
| 8 | 	.hidden __syscall_ret | ||
| 9 | 	b __syscall_ret | ||
lib/libc/musl/src/process/fork.c+6-2| ... | @@ -9,7 +9,6 @@ static volatile int *const dummy_lockptr = 0; | ... | @@ -9,7 +9,6 @@ static volatile int *const dummy_lockptr = 0; |
| 9 | 9 | ||
| 10 | weak_alias(dummy_lockptr, __at_quick_exit_lockptr); | 10 | weak_alias(dummy_lockptr, __at_quick_exit_lockptr); |
| 11 | weak_alias(dummy_lockptr, __atexit_lockptr); | 11 | weak_alias(dummy_lockptr, __atexit_lockptr); |
| 12 | weak_alias(dummy_lockptr, __dlerror_lockptr); | ||
| 13 | weak_alias(dummy_lockptr, __gettext_lockptr); | 12 | weak_alias(dummy_lockptr, __gettext_lockptr); |
| 14 | weak_alias(dummy_lockptr, __locale_lockptr); | 13 | weak_alias(dummy_lockptr, __locale_lockptr); |
| 15 | weak_alias(dummy_lockptr, __random_lockptr); | 14 | weak_alias(dummy_lockptr, __random_lockptr); |
| ... | @@ -24,7 +23,6 @@ weak_alias(dummy_lockptr, __vmlock_lockptr); | ... | @@ -24,7 +23,6 @@ weak_alias(dummy_lockptr, __vmlock_lockptr); |
| 24 | static volatile int *const *const atfork_locks[] = { | 23 | static volatile int *const *const atfork_locks[] = { |
| 25 | 	&__at_quick_exit_lockptr, | 24 | 	&__at_quick_exit_lockptr, |
| 26 | 	&__atexit_lockptr, | 25 | 	&__atexit_lockptr, |
| 27 | 	&__dlerror_lockptr, | ||
| 28 | 	&__gettext_lockptr, | 26 | 	&__gettext_lockptr, |
| 29 | 	&__locale_lockptr, | 27 | 	&__locale_lockptr, |
| 30 | 	&__random_lockptr, | 28 | 	&__random_lockptr, |
| ... | @@ -38,6 +36,8 @@ static volatile int *const *const atfork_locks[] = { | ... | @@ -38,6 +36,8 @@ static volatile int *const *const atfork_locks[] = { |
| 38 | static void dummy(int x) { } | 36 | static void dummy(int x) { } |
| 39 | weak_alias(dummy, __fork_handler); | 37 | weak_alias(dummy, __fork_handler); |
| 40 | weak_alias(dummy, __malloc_atfork); | 38 | weak_alias(dummy, __malloc_atfork); |
| 39 | weak_alias(dummy, __aio_atfork); | ||
| 40 | weak_alias(dummy, __pthread_key_atfork); | ||
| 41 | weak_alias(dummy, __ldso_atfork); | 41 | weak_alias(dummy, __ldso_atfork); |
| 42 | 42 | ||
| 43 | static void dummy_0(void) { } | 43 | static void dummy_0(void) { } |
| ... | @@ -52,6 +52,8 @@ pid_t fork(void) | ... | @@ -52,6 +52,8 @@ pid_t fork(void) |
| 52 | 	int need_locks = libc.need_locks > 0; | 52 | 	int need_locks = libc.need_locks > 0; |
| 53 | 	if (need_locks) { | 53 | 	if (need_locks) { |
| 54 | 		__ldso_atfork(-1); | 54 | 		__ldso_atfork(-1); |
| 55 | 		__pthread_key_atfork(-1); | ||
| 56 | 		__aio_atfork(-1); | ||
| 55 | 		__inhibit_ptc(); | 57 | 		__inhibit_ptc(); |
| 56 | 		for (int i=0; i<sizeof atfork_locks/sizeof *atfork_locks; i++) | 58 | 		for (int i=0; i<sizeof atfork_locks/sizeof *atfork_locks; i++) |
| 57 | 			if (*atfork_locks[i]) LOCK(*atfork_locks[i]); | 59 | 			if (*atfork_locks[i]) LOCK(*atfork_locks[i]); |
| ... | @@ -77,6 +79,8 @@ pid_t fork(void) | ... | @@ -77,6 +79,8 @@ pid_t fork(void) |
| 77 | 				if (ret) UNLOCK(*atfork_locks[i]); | 79 | 				if (ret) UNLOCK(*atfork_locks[i]); |
| 78 | 				else **atfork_locks[i] = 0; | 80 | 				else **atfork_locks[i] = 0; |
| 79 | 		__release_ptc(); | 81 | 		__release_ptc(); |
| 82 | 		if (ret) __aio_atfork(0); | ||
| 83 | 		__pthread_key_atfork(!ret); | ||
| 80 | 		__ldso_atfork(!ret); | 84 | 		__ldso_atfork(!ret); |
| 81 | 	} | 85 | 	} |
| 82 | 	__restore_sigs(&set); | 86 | 	__restore_sigs(&set); |
lib/libc/musl/src/process/riscv64/vfork.s created+12| ... | @@ -0,0 +1,12 @@ | ||
| 1 | .global vfork | ||
| 2 | .type vfork,@function | ||
| 3 | vfork: | ||
| 4 | 	/* riscv does not have SYS_vfork, so we must use clone instead */ | ||
| 5 | 	/* note: riscv's clone = clone(flags, sp, ptidptr, tls, ctidptr) */ | ||
| 6 | 	li a7, 220 | ||
| 7 | 	li a0, 0x100 | 0x4000 | 17 /* flags = CLONE_VM | CLONE_VFORK | SIGCHLD */ | ||
| 8 | 	mv a1, sp | ||
| 9 | 	/* the other arguments are ignoreable */ | ||
| 10 | 	ecall | ||
| 11 | 	.hidden __syscall_ret | ||
| 12 | 	j __syscall_ret | ||
lib/libc/musl/src/regex/glob.c-3| ... | @@ -306,6 +306,3 @@ void globfree(glob_t *g) | ... | @@ -306,6 +306,3 @@ void globfree(glob_t *g) |
| 306 | 	g->gl_pathc = 0; | 306 | 	g->gl_pathc = 0; |
| 307 | 	g->gl_pathv = NULL; | 307 | 	g->gl_pathv = NULL; |
| 308 | } | 308 | } |
| 309 | |||
| 310 | weak_alias(glob, glob64); | ||
| 311 | weak_alias(globfree, globfree64); |
lib/libc/musl/src/search/hsearch.c+2-2| ... | @@ -41,9 +41,9 @@ static int resize(size_t nel, struct hsearch_data *htab) | ... | @@ -41,9 +41,9 @@ static int resize(size_t nel, struct hsearch_data *htab) |
| 41 | { | 41 | { |
| 42 | 	size_t newsize; | 42 | 	size_t newsize; |
| 43 | 	size_t i, j; | 43 | 	size_t i, j; |
| 44 | 	size_t oldsize = htab->__tab->mask + 1; | ||
| 44 | 	ENTRY *e, *newe; | 45 | 	ENTRY *e, *newe; |
| 45 | 	ENTRY *oldtab = htab->__tab->entries; | 46 | 	ENTRY *oldtab = htab->__tab->entries; |
| 46 | 	ENTRY *oldend = htab->__tab->entries + htab->__tab->mask + 1; | ||
| 47 | 47 | ||
| 48 | 	if (nel > MAXSIZE) | 48 | 	if (nel > MAXSIZE) |
| 49 | 		nel = MAXSIZE; | 49 | 		nel = MAXSIZE; |
| ... | @@ -56,7 +56,7 @@ static int resize(size_t nel, struct hsearch_data *htab) | ... | @@ -56,7 +56,7 @@ static int resize(size_t nel, struct hsearch_data *htab) |
| 56 | 	htab->__tab->mask = newsize - 1; | 56 | 	htab->__tab->mask = newsize - 1; |
| 57 | 	if (!oldtab) | 57 | 	if (!oldtab) |
| 58 | 		return 1; | 58 | 		return 1; |
| 59 | 	for (e = oldtab; e < oldend; e++) | 59 | 	for (e = oldtab; e < oldtab + oldsize; e++) |
| 60 | 		if (e->key) { | 60 | 		if (e->key) { |
| 61 | 			for (i=keyhash(e->key),j=1; ; i+=j++) { | 61 | 			for (i=keyhash(e->key),j=1; ; i+=j++) { |
| 62 | 				newe = htab->__tab->entries + (i & htab->__tab->mask); | 62 | 				newe = htab->__tab->entries + (i & htab->__tab->mask); |
lib/libc/musl/src/select/poll.c+7-2| ... | @@ -8,8 +8,13 @@ int poll(struct pollfd *fds, nfds_t n, int timeout) | ... | @@ -8,8 +8,13 @@ int poll(struct pollfd *fds, nfds_t n, int timeout) |
| 8 | #ifdef SYS_poll | 8 | #ifdef SYS_poll |
| 9 | 	return syscall_cp(SYS_poll, fds, n, timeout); | 9 | 	return syscall_cp(SYS_poll, fds, n, timeout); |
| 10 | #else | 10 | #else |
| 11 | #if SYS_ppoll_time64 == SYS_ppoll | ||
| 12 | 	typedef long long ppoll_ts_t[2]; | ||
| 13 | #else | ||
| 14 | 	typedef long ppoll_ts_t[2]; | ||
| 15 | #endif | ||
| 11 | 	return syscall_cp(SYS_ppoll, fds, n, timeout>=0 ? | 16 | 	return syscall_cp(SYS_ppoll, fds, n, timeout>=0 ? |
| 12 | 		&((struct timespec){ .tv_sec = timeout/1000, | 17 | 		((ppoll_ts_t){ timeout/1000, timeout%1000*1000000 }) : 0, |
| 13 | 		.tv_nsec = timeout%1000*1000000 }) : 0, 0, _NSIG/8); | 18 | 		0, _NSIG/8); |
| 14 | #endif | 19 | #endif |
| 15 | } | 20 | } |
lib/libc/musl/src/select/select.c+1| ... | @@ -33,6 +33,7 @@ int select(int n, fd_set *restrict rfds, fd_set *restrict wfds, fd_set *restrict | ... | @@ -33,6 +33,7 @@ int select(int n, fd_set *restrict rfds, fd_set *restrict wfds, fd_set *restrict |
| 33 | 			((syscall_arg_t[]){ 0, _NSIG/8 })); | 33 | 			((syscall_arg_t[]){ 0, _NSIG/8 })); |
| 34 | 	if (SYS_pselect6 == SYS_pselect6_time64 || r!=-ENOSYS) | 34 | 	if (SYS_pselect6 == SYS_pselect6_time64 || r!=-ENOSYS) |
| 35 | 		return __syscall_ret(r); | 35 | 		return __syscall_ret(r); |
| 36 | 	s = CLAMP(s); | ||
| 36 | #endif | 37 | #endif |
| 37 | #ifdef SYS_select | 38 | #ifdef SYS_select |
| 38 | 	return syscall_cp(SYS_select, n, rfds, wfds, efds, | 39 | 	return syscall_cp(SYS_select, n, rfds, wfds, efds, |
lib/libc/musl/src/setjmp/powerpc/longjmp.S+4-4| ... | @@ -42,10 +42,10 @@ longjmp: | ... | @@ -42,10 +42,10 @@ longjmp: |
| 42 | 	bl 1f | 42 | 	bl 1f |
| 43 | 	.hidden __hwcap | 43 | 	.hidden __hwcap |
| 44 | 	.long __hwcap-. | 44 | 	.long __hwcap-. |
| 45 | 1:	mflr 4 | 45 | 1:	mflr 6 |
| 46 | 	lwz 5, 0(4) | 46 | 	lwz 5, 0(6) |
| 47 | 	lwzx 4, 4, 5 | 47 | 	lwzx 6, 6, 5 |
| 48 | 	andis. 4, 4, 0x80 | 48 | 	andis. 6, 6, 0x80 |
| 49 | 	beq 1f | 49 | 	beq 1f |
| 50 | 	.long 0x11c35b01 /* evldd 14,88(3) */ | 50 | 	.long 0x11c35b01 /* evldd 14,88(3) */ |
| 51 | 	.long 0x11e36301 /* ... */ | 51 | 	.long 0x11e36301 /* ... */ |
lib/libc/musl/src/signal/mips/restore.s deleted-15| ... | @@ -1,15 +0,0 @@ | ||
| 1 | .set noreorder | ||
| 2 | |||
| 3 | .global __restore_rt | ||
| 4 | .hidden __restore_rt | ||
| 5 | .type __restore_rt,@function | ||
| 6 | __restore_rt: | ||
| 7 | 	li $2, 4193 | ||
| 8 | 	syscall | ||
| 9 | |||
| 10 | .global __restore | ||
| 11 | .hidden __restore | ||
| 12 | .type __restore,@function | ||
| 13 | __restore: | ||
| 14 | 	li $2, 4119 | ||
| 15 | 	syscall | ||
lib/libc/musl/src/signal/mips64/restore.s deleted-11| ... | @@ -1,11 +0,0 @@ | ||
| 1 | .set	noreorder | ||
| 2 | .global	__restore_rt | ||
| 3 | .global	__restore | ||
| 4 | .hidden __restore_rt | ||
| 5 | .hidden __restore | ||
| 6 | .type	__restore_rt,@function | ||
| 7 | .type	__restore,@function | ||
| 8 | __restore_rt: | ||
| 9 | __restore: | ||
| 10 | 	li	$2,5211 | ||
| 11 | 	syscall | ||
lib/libc/musl/src/signal/mipsn32/restore.s deleted-11| ... | @@ -1,11 +0,0 @@ | ||
| 1 | .set	noreorder | ||
| 2 | .global	__restore_rt | ||
| 3 | .global	__restore | ||
| 4 | .hidden __restore_rt | ||
| 5 | .hidden __restore | ||
| 6 | .type	__restore_rt,@function | ||
| 7 | .type	__restore,@function | ||
| 8 | __restore_rt: | ||
| 9 | __restore: | ||
| 10 | 	li	$2,6211 | ||
| 11 | 	syscall | ||
lib/libc/musl/src/signal/sigaction.c+4-1| ... | @@ -44,8 +44,11 @@ int __libc_sigaction(int sig, const struct sigaction *restrict sa, struct sigact | ... | @@ -44,8 +44,11 @@ int __libc_sigaction(int sig, const struct sigaction *restrict sa, struct sigact |
| 44 | 			} | 44 | 			} |
| 45 | 		} | 45 | 		} |
| 46 | 		ksa.handler = sa->sa_handler; | 46 | 		ksa.handler = sa->sa_handler; |
| 47 | 		ksa.flags = sa->sa_flags | SA_RESTORER; | 47 | 		ksa.flags = sa->sa_flags; |
| 48 | #ifdef SA_RESTORER | ||
| 49 | 		ksa.flags |= SA_RESTORER; | ||
| 48 | 		ksa.restorer = (sa->sa_flags & SA_SIGINFO) ? __restore_rt : __restore; | 50 | 		ksa.restorer = (sa->sa_flags & SA_SIGINFO) ? __restore_rt : __restore; |
| 51 | #endif | ||
| 49 | 		memcpy(&ksa.mask, &sa->sa_mask, _NSIG/8); | 52 | 		memcpy(&ksa.mask, &sa->sa_mask, _NSIG/8); |
| 50 | 	} | 53 | 	} |
| 51 | 	int r = __syscall(SYS_rt_sigaction, sig, sa?&ksa:0, old?&ksa_old:0, _NSIG/8); | 54 | 	int r = __syscall(SYS_rt_sigaction, sig, sa?&ksa:0, old?&ksa_old:0, _NSIG/8); |
lib/libc/musl/src/stat/__xstat.c-5| ... | @@ -22,11 +22,6 @@ int __xstat(int ver, const char *path, struct stat *buf) | ... | @@ -22,11 +22,6 @@ int __xstat(int ver, const char *path, struct stat *buf) |
| 22 | 	return stat(path, buf); | 22 | 	return stat(path, buf); |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | weak_alias(__fxstat, __fxstat64); | ||
| 26 | weak_alias(__fxstatat, __fxstatat64); | ||
| 27 | weak_alias(__lxstat, __lxstat64); | ||
| 28 | weak_alias(__xstat, __xstat64); | ||
| 29 | |||
| 30 | #endif | 25 | #endif |
| 31 | 26 | ||
| 32 | int __xmknod(int ver, const char *path, mode_t mode, dev_t *dev) | 27 | int __xmknod(int ver, const char *path, mode_t mode, dev_t *dev) |
lib/libc/musl/src/stat/fchmodat.c+7-8| ... | @@ -2,7 +2,6 @@ | ... | @@ -2,7 +2,6 @@ |
| 2 | #include <fcntl.h> | 2 | #include <fcntl.h> |
| 3 | #include <errno.h> | 3 | #include <errno.h> |
| 4 | #include "syscall.h" | 4 | #include "syscall.h" |
| 5 | #include "kstat.h" | ||
| 6 | 5 | ||
| 7 | int fchmodat(int fd, const char *path, mode_t mode, int flag) | 6 | int fchmodat(int fd, const char *path, mode_t mode, int flag) |
| 8 | { | 7 | { |
| ... | @@ -11,12 +10,12 @@ int fchmodat(int fd, const char *path, mode_t mode, int flag) | ... | @@ -11,12 +10,12 @@ int fchmodat(int fd, const char *path, mode_t mode, int flag) |
| 11 | 	if (flag != AT_SYMLINK_NOFOLLOW) | 10 | 	if (flag != AT_SYMLINK_NOFOLLOW) |
| 12 | 		return __syscall_ret(-EINVAL); | 11 | 		return __syscall_ret(-EINVAL); |
| 13 | 12 | ||
| 14 | 	struct kstat st; | 13 | 	struct stat st; |
| 15 | 	int ret, fd2; | 14 | 	int ret, fd2; |
| 16 | 	char proc[15+3*sizeof(int)]; | 15 | 	char proc[15+3*sizeof(int)]; |
| 17 | 16 | ||
| 18 | 	if ((ret = __syscall(SYS_fstatat, fd, path, &st, flag))) | 17 | 	if (fstatat(fd, path, &st, flag)) |
| 19 | 		return __syscall_ret(ret); | 18 | 		return -1; |
| 20 | 	if (S_ISLNK(st.st_mode)) | 19 | 	if (S_ISLNK(st.st_mode)) |
| 21 | 		return __syscall_ret(-EOPNOTSUPP); | 20 | 		return __syscall_ret(-EOPNOTSUPP); |
| 22 | 21 | ||
| ... | @@ -27,12 +26,12 @@ int fchmodat(int fd, const char *path, mode_t mode, int flag) | ... | @@ -27,12 +26,12 @@ int fchmodat(int fd, const char *path, mode_t mode, int flag) |
| 27 | 	} | 26 | 	} |
| 28 | 27 | ||
| 29 | 	__procfdname(proc, fd2); | 28 | 	__procfdname(proc, fd2); |
| 30 | 	ret = __syscall(SYS_fstatat, AT_FDCWD, proc, &st, 0); | 29 | 	ret = stat(proc, &st); |
| 31 | 	if (!ret) { | 30 | 	if (!ret) { |
| 32 | 		if (S_ISLNK(st.st_mode)) ret = -EOPNOTSUPP; | 31 | 		if (S_ISLNK(st.st_mode)) ret = __syscall_ret(-EOPNOTSUPP); |
| 33 | 		else ret = __syscall(SYS_fchmodat, AT_FDCWD, proc, mode); | 32 | 		else ret = syscall(SYS_fchmodat, AT_FDCWD, proc, mode); |
| 34 | 	} | 33 | 	} |
| 35 | 34 | ||
| 36 | 	__syscall(SYS_close, fd2); | 35 | 	__syscall(SYS_close, fd2); |
| 37 | 	return __syscall_ret(ret); | 36 | 	return ret; |
| 38 | } | 37 | } |
lib/libc/musl/src/stat/fstat.c+3-5| ... | @@ -4,12 +4,10 @@ | ... | @@ -4,12 +4,10 @@ |
| 4 | #include <fcntl.h> | 4 | #include <fcntl.h> |
| 5 | #include "syscall.h" | 5 | #include "syscall.h" |
| 6 | 6 | ||
| 7 | int fstat(int fd, struct stat *st) | 7 | int __fstat(int fd, struct stat *st) |
| 8 | { | 8 | { |
| 9 | 	if (fd<0) return __syscall_ret(-EBADF); | 9 | 	if (fd<0) return __syscall_ret(-EBADF); |
| 10 | 	return fstatat(fd, "", st, AT_EMPTY_PATH); | 10 | 	return __fstatat(fd, "", st, AT_EMPTY_PATH); |
| 11 | } | 11 | } |
| 12 | 12 | ||
| 13 | #if !_REDIR_TIME64 | 13 | weak_alias(__fstat, fstat); |
| 14 | weak_alias(fstat, fstat64); | ||
| 15 | #endif |
lib/libc/musl/src/stat/fstatat.c+11-5| ... | @@ -6,7 +6,6 @@ | ... | @@ -6,7 +6,6 @@ |
| 6 | #include <stdint.h> | 6 | #include <stdint.h> |
| 7 | #include <sys/sysmacros.h> | 7 | #include <sys/sysmacros.h> |
| 8 | #include "syscall.h" | 8 | #include "syscall.h" |
| 9 | #include "kstat.h" | ||
| 10 | 9 | ||
| 11 | struct statx { | 10 | struct statx { |
| 12 | 	uint32_t stx_mask; | 11 | 	uint32_t stx_mask; |
| ... | @@ -69,6 +68,10 @@ static int fstatat_statx(int fd, const char *restrict path, struct stat *restric | ... | @@ -69,6 +68,10 @@ static int fstatat_statx(int fd, const char *restrict path, struct stat *restric |
| 69 | 	return 0; | 68 | 	return 0; |
| 70 | } | 69 | } |
| 71 | 70 | ||
| 71 | #ifdef SYS_fstatat | ||
| 72 | |||
| 73 | #include "kstat.h" | ||
| 74 | |||
| 72 | static int fstatat_kstat(int fd, const char *restrict path, struct stat *restrict st, int flag) | 75 | static int fstatat_kstat(int fd, const char *restrict path, struct stat *restrict st, int flag) |
| 73 | { | 76 | { |
| 74 | 	int ret; | 77 | 	int ret; |
| ... | @@ -130,18 +133,21 @@ static int fstatat_kstat(int fd, const char *restrict path, struct stat *restric | ... | @@ -130,18 +133,21 @@ static int fstatat_kstat(int fd, const char *restrict path, struct stat *restric |
| 130 | 133 | ||
| 131 | 	return 0; | 134 | 	return 0; |
| 132 | } | 135 | } |
| 136 | #endif | ||
| 133 | 137 | ||
| 134 | int fstatat(int fd, const char *restrict path, struct stat *restrict st, int flag) | 138 | int __fstatat(int fd, const char *restrict path, struct stat *restrict st, int flag) |
| 135 | { | 139 | { |
| 136 | 	int ret; | 140 | 	int ret; |
| 141 | #ifdef SYS_fstatat | ||
| 137 | 	if (sizeof((struct kstat){0}.st_atime_sec) < sizeof(time_t)) { | 142 | 	if (sizeof((struct kstat){0}.st_atime_sec) < sizeof(time_t)) { |
| 138 | 		ret = fstatat_statx(fd, path, st, flag); | 143 | 		ret = fstatat_statx(fd, path, st, flag); |
| 139 | 		if (ret!=-ENOSYS) return __syscall_ret(ret); | 144 | 		if (ret!=-ENOSYS) return __syscall_ret(ret); |
| 140 | 	} | 145 | 	} |
| 141 | 	ret = fstatat_kstat(fd, path, st, flag); | 146 | 	ret = fstatat_kstat(fd, path, st, flag); |
| 147 | #else | ||
| 148 | 	ret = fstatat_statx(fd, path, st, flag); | ||
| 149 | #endif | ||
| 142 | 	return __syscall_ret(ret); | 150 | 	return __syscall_ret(ret); |
| 143 | } | 151 | } |
| 144 | 152 | ||
| 145 | #if !_REDIR_TIME64 | 153 | weak_alias(__fstatat, fstatat); |
| 146 | weak_alias(fstatat, fstatat64); | ||
| 147 | #endif |
lib/libc/musl/src/stat/lstat.c-4| ... | @@ -5,7 +5,3 @@ int lstat(const char *restrict path, struct stat *restrict buf) | ... | @@ -5,7 +5,3 @@ int lstat(const char *restrict path, struct stat *restrict buf) |
| 5 | { | 5 | { |
| 6 | 	return fstatat(AT_FDCWD, path, buf, AT_SYMLINK_NOFOLLOW); | 6 | 	return fstatat(AT_FDCWD, path, buf, AT_SYMLINK_NOFOLLOW); |
| 7 | } | 7 | } |
| 8 | |||
| 9 | #if !_REDIR_TIME64 | ||
| 10 | weak_alias(lstat, lstat64); | ||
| 11 | #endif |
lib/libc/musl/src/stat/stat.c-4| ... | @@ -5,7 +5,3 @@ int stat(const char *restrict path, struct stat *restrict buf) | ... | @@ -5,7 +5,3 @@ int stat(const char *restrict path, struct stat *restrict buf) |
| 5 | { | 5 | { |
| 6 | 	return fstatat(AT_FDCWD, path, buf, 0); | 6 | 	return fstatat(AT_FDCWD, path, buf, 0); |
| 7 | } | 7 | } |
| 8 | |||
| 9 | #if !_REDIR_TIME64 | ||
| 10 | weak_alias(stat, stat64); | ||
| 11 | #endif |
lib/libc/musl/src/stat/statvfs.c-5| ... | @@ -56,8 +56,3 @@ int fstatvfs(int fd, struct statvfs *buf) | ... | @@ -56,8 +56,3 @@ int fstatvfs(int fd, struct statvfs *buf) |
| 56 | 	fixup(buf, &kbuf); | 56 | 	fixup(buf, &kbuf); |
| 57 | 	return 0; | 57 | 	return 0; |
| 58 | } | 58 | } |
| 59 | |||
| 60 | weak_alias(statvfs, statvfs64); | ||
| 61 | weak_alias(statfs, statfs64); | ||
| 62 | weak_alias(fstatvfs, fstatvfs64); | ||
| 63 | weak_alias(fstatfs, fstatfs64); |
lib/libc/musl/src/stdio/fgetpos.c-2| ... | @@ -7,5 +7,3 @@ int fgetpos(FILE *restrict f, fpos_t *restrict pos) | ... | @@ -7,5 +7,3 @@ int fgetpos(FILE *restrict f, fpos_t *restrict pos) |
| 7 | 	*(long long *)pos = off; | 7 | 	*(long long *)pos = off; |
| 8 | 	return 0; | 8 | 	return 0; |
| 9 | } | 9 | } |
| 10 | |||
| 11 | weak_alias(fgetpos, fgetpos64); |
lib/libc/musl/src/stdio/fgets.c+3-2| ... | @@ -12,13 +12,14 @@ char *fgets(char *restrict s, int n, FILE *restrict f) | ... | @@ -12,13 +12,14 @@ char *fgets(char *restrict s, int n, FILE *restrict f) |
| 12 | 12 | ||
| 13 | 	FLOCK(f); | 13 | 	FLOCK(f); |
| 14 | 14 | ||
| 15 | 	if (n--<=1) { | 15 | 	if (n<=1) { |
| 16 | 		f->mode |= f->mode-1; | 16 | 		f->mode |= f->mode-1; |
| 17 | 		FUNLOCK(f); | 17 | 		FUNLOCK(f); |
| 18 | 		if (n) return 0; | 18 | 		if (n<1) return 0; |
| 19 | 		*s = 0; | 19 | 		*s = 0; |
| 20 | 		return s; | 20 | 		return s; |
| 21 | 	} | 21 | 	} |
| 22 | 	n--; | ||
| 22 | 23 | ||
| 23 | 	while (n) { | 24 | 	while (n) { |
| 24 | 		if (f->rpos != f->rend) { | 25 | 		if (f->rpos != f->rend) { |
lib/libc/musl/src/stdio/fopen.c-2| ... | @@ -29,5 +29,3 @@ FILE *fopen(const char *restrict filename, const char *restrict mode) | ... | @@ -29,5 +29,3 @@ FILE *fopen(const char *restrict filename, const char *restrict mode) |
| 29 | 	__syscall(SYS_close, fd); | 29 | 	__syscall(SYS_close, fd); |
| 30 | 	return 0; | 30 | 	return 0; |
| 31 | } | 31 | } |
| 32 | |||
| 33 | weak_alias(fopen, fopen64); |
lib/libc/musl/src/stdio/freopen.c+2-2| ... | @@ -40,6 +40,8 @@ FILE *freopen(const char *restrict filename, const char *restrict mode, FILE *re | ... | @@ -40,6 +40,8 @@ FILE *freopen(const char *restrict filename, const char *restrict mode, FILE *re |
| 40 | 		fclose(f2); | 40 | 		fclose(f2); |
| 41 | 	} | 41 | 	} |
| 42 | 42 | ||
| 43 | 	f->mode = 0; | ||
| 44 | 	f->locale = 0; | ||
| 43 | 	FUNLOCK(f); | 45 | 	FUNLOCK(f); |
| 44 | 	return f; | 46 | 	return f; |
| 45 | 47 | ||
| ... | @@ -49,5 +51,3 @@ fail: | ... | @@ -49,5 +51,3 @@ fail: |
| 49 | 	fclose(f); | 51 | 	fclose(f); |
| 50 | 	return NULL; | 52 | 	return NULL; |
| 51 | } | 53 | } |
| 52 | |||
| 53 | weak_alias(freopen, freopen64); |
lib/libc/musl/src/stdio/fseek.c-2| ... | @@ -46,5 +46,3 @@ int fseek(FILE *f, long off, int whence) | ... | @@ -46,5 +46,3 @@ int fseek(FILE *f, long off, int whence) |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | weak_alias(__fseeko, fseeko); | 48 | weak_alias(__fseeko, fseeko); |
| 49 | |||
| 50 | weak_alias(fseeko, fseeko64); |
lib/libc/musl/src/stdio/fsetpos.c-2| ... | @@ -4,5 +4,3 @@ int fsetpos(FILE *f, const fpos_t *pos) | ... | @@ -4,5 +4,3 @@ int fsetpos(FILE *f, const fpos_t *pos) |
| 4 | { | 4 | { |
| 5 | 	return __fseeko(f, *(const long long *)pos, SEEK_SET); | 5 | 	return __fseeko(f, *(const long long *)pos, SEEK_SET); |
| 6 | } | 6 | } |
| 7 | |||
| 8 | weak_alias(fsetpos, fsetpos64); |
lib/libc/musl/src/stdio/ftell.c-2| ... | @@ -37,5 +37,3 @@ long ftell(FILE *f) | ... | @@ -37,5 +37,3 @@ long ftell(FILE *f) |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | weak_alias(__ftello, ftello); | 39 | weak_alias(__ftello, ftello); |
| 40 | |||
| 41 | weak_alias(ftello, ftello64); |
lib/libc/musl/src/stdio/open_wmemstream.c+5-1| ... | @@ -40,8 +40,12 @@ fail: | ... | @@ -40,8 +40,12 @@ fail: |
| 40 | static size_t wms_write(FILE *f, const unsigned char *buf, size_t len) | 40 | static size_t wms_write(FILE *f, const unsigned char *buf, size_t len) |
| 41 | { | 41 | { |
| 42 | 	struct cookie *c = f->cookie; | 42 | 	struct cookie *c = f->cookie; |
| 43 | 	size_t len2; | 43 | 	size_t len2 = f->wpos - f->wbase; |
| 44 | 	wchar_t *newbuf; | 44 | 	wchar_t *newbuf; |
| 45 | 	if (len2) { | ||
| 46 | 		f->wpos = f->wbase; | ||
| 47 | 		if (wms_write(f, f->wbase, len2) < len2) return 0; | ||
| 48 | 	} | ||
| 45 | 	if (len + c->pos >= c->space) { | 49 | 	if (len + c->pos >= c->space) { |
| 46 | 		len2 = 2*c->space+1 | c->pos+len+1; | 50 | 		len2 = 2*c->space+1 | c->pos+len+1; |
| 47 | 		if (len2 > SSIZE_MAX/4) return 0; | 51 | 		if (len2 > SSIZE_MAX/4) return 0; |
lib/libc/musl/src/stdio/tempnam.c+3-5| ... | @@ -6,7 +6,6 @@ | ... | @@ -6,7 +6,6 @@ |
| 6 | #include <string.h> | 6 | #include <string.h> |
| 7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
| 8 | #include "syscall.h" | 8 | #include "syscall.h" |
| 9 | #include "kstat.h" | ||
| 10 | 9 | ||
| 11 | #define MAXTRIES 100 | 10 | #define MAXTRIES 100 |
| 12 | 11 | ||
| ... | @@ -37,11 +36,10 @@ char *tempnam(const char *dir, const char *pfx) | ... | @@ -37,11 +36,10 @@ char *tempnam(const char *dir, const char *pfx) |
| 37 | 36 | ||
| 38 | 	for (try=0; try<MAXTRIES; try++) { | 37 | 	for (try=0; try<MAXTRIES; try++) { |
| 39 | 		__randname(s+l-6); | 38 | 		__randname(s+l-6); |
| 40 | #ifdef SYS_lstat | 39 | #ifdef SYS_readlink |
| 41 | 		r = __syscall(SYS_lstat, s, &(struct kstat){0}); | 40 | 		r = __syscall(SYS_readlink, s, (char[1]){0}, 1); |
| 42 | #else | 41 | #else |
| 43 | 		r = __syscall(SYS_fstatat, AT_FDCWD, s, | 42 | 		r = __syscall(SYS_readlinkat, AT_FDCWD, s, (char[1]){0}, 1); |
| 44 | 			&(struct kstat){0}, AT_SYMLINK_NOFOLLOW); | ||
| 45 | #endif | 43 | #endif |
| 46 | 		if (r == -ENOENT) return strdup(s); | 44 | 		if (r == -ENOENT) return strdup(s); |
| 47 | 	} | 45 | 	} |
lib/libc/musl/src/stdio/tmpfile.c-2| ... | @@ -27,5 +27,3 @@ FILE *tmpfile(void) | ... | @@ -27,5 +27,3 @@ FILE *tmpfile(void) |
| 27 | 	} | 27 | 	} |
| 28 | 	return 0; | 28 | 	return 0; |
| 29 | } | 29 | } |
| 30 | |||
| 31 | weak_alias(tmpfile, tmpfile64); |
lib/libc/musl/src/stdio/tmpnam.c+3-5| ... | @@ -5,7 +5,6 @@ | ... | @@ -5,7 +5,6 @@ |
| 5 | #include <string.h> | 5 | #include <string.h> |
| 6 | #include <stdlib.h> | 6 | #include <stdlib.h> |
| 7 | #include "syscall.h" | 7 | #include "syscall.h" |
| 8 | #include "kstat.h" | ||
| 9 | 8 | ||
| 10 | #define MAXTRIES 100 | 9 | #define MAXTRIES 100 |
| 11 | 10 | ||
| ... | @@ -17,11 +16,10 @@ char *tmpnam(char *buf) | ... | @@ -17,11 +16,10 @@ char *tmpnam(char *buf) |
| 17 | 	int r; | 16 | 	int r; |
| 18 | 	for (try=0; try<MAXTRIES; try++) { | 17 | 	for (try=0; try<MAXTRIES; try++) { |
| 19 | 		__randname(s+12); | 18 | 		__randname(s+12); |
| 20 | #ifdef SYS_lstat | 19 | #ifdef SYS_readlink |
| 21 | 		r = __syscall(SYS_lstat, s, &(struct kstat){0}); | 20 | 		r = __syscall(SYS_readlink, s, (char[1]){0}, 1); |
| 22 | #else | 21 | #else |
| 23 | 		r = __syscall(SYS_fstatat, AT_FDCWD, s, | 22 | 		r = __syscall(SYS_readlinkat, AT_FDCWD, s, (char[1]){0}, 1); |
| 24 | 			&(struct kstat){0}, AT_SYMLINK_NOFOLLOW); | ||
| 25 | #endif | 23 | #endif |
| 26 | 		if (r == -ENOENT) return strcpy(buf ? buf : internal, s); | 24 | 		if (r == -ENOENT) return strcpy(buf ? buf : internal, s); |
| 27 | 	} | 25 | 	} |
lib/libc/musl/src/stdio/vfprintf.c+14-9| ... | @@ -132,7 +132,7 @@ static void pop_arg(union arg *arg, int type, va_list *ap) | ... | @@ -132,7 +132,7 @@ static void pop_arg(union arg *arg, int type, va_list *ap) |
| 132 | 132 | ||
| 133 | static void out(FILE *f, const char *s, size_t l) | 133 | static void out(FILE *f, const char *s, size_t l) |
| 134 | { | 134 | { |
| 135 | 	if (!(f->flags & F_ERR)) __fwritex((void *)s, l, f); | 135 | 	if (!ferror(f)) __fwritex((void *)s, l, f); |
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | static void pad(FILE *f, char c, int w, int l, int fl) | 138 | static void pad(FILE *f, char c, int w, int l, int fl) |
| ... | @@ -478,8 +478,8 @@ static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg, | ... | @@ -478,8 +478,8 @@ static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg, |
| 478 | 		if (*s=='*') { | 478 | 		if (*s=='*') { |
| 479 | 			if (isdigit(s[1]) && s[2]=='$') { | 479 | 			if (isdigit(s[1]) && s[2]=='$') { |
| 480 | 				l10n=1; | 480 | 				l10n=1; |
| 481 | 				nl_type[s[1]-'0'] = INT; | 481 | 				if (!f) nl_type[s[1]-'0'] = INT, w = 0; |
| 482 | 				w = nl_arg[s[1]-'0'].i; | 482 | 				else w = nl_arg[s[1]-'0'].i; |
| 483 | 				s+=3; | 483 | 				s+=3; |
| 484 | 			} else if (!l10n) { | 484 | 			} else if (!l10n) { |
| 485 | 				w = f ? va_arg(*ap, int) : 0; | 485 | 				w = f ? va_arg(*ap, int) : 0; |
| ... | @@ -491,8 +491,8 @@ static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg, | ... | @@ -491,8 +491,8 @@ static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg, |
| 491 | 		/* Read precision */ | 491 | 		/* Read precision */ |
| 492 | 		if (*s=='.' && s[1]=='*') { | 492 | 		if (*s=='.' && s[1]=='*') { |
| 493 | 			if (isdigit(s[2]) && s[3]=='$') { | 493 | 			if (isdigit(s[2]) && s[3]=='$') { |
| 494 | 				nl_type[s[2]-'0'] = INT; | 494 | 				if (!f) nl_type[s[2]-'0'] = INT, p = 0; |
| 495 | 				p = nl_arg[s[2]-'0'].i; | 495 | 				else p = nl_arg[s[2]-'0'].i; |
| 496 | 				s+=4; | 496 | 				s+=4; |
| 497 | 			} else if (!l10n) { | 497 | 			} else if (!l10n) { |
| 498 | 				p = f ? va_arg(*ap, int) : 0; | 498 | 				p = f ? va_arg(*ap, int) : 0; |
| ... | @@ -521,13 +521,18 @@ static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg, | ... | @@ -521,13 +521,18 @@ static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg, |
| 521 | 		if (st==NOARG) { | 521 | 		if (st==NOARG) { |
| 522 | 			if (argpos>=0) goto inval; | 522 | 			if (argpos>=0) goto inval; |
| 523 | 		} else { | 523 | 		} else { |
| 524 | 			if (argpos>=0) nl_type[argpos]=st, arg=nl_arg[argpos]; | 524 | 			if (argpos>=0) { |
| 525 | 			else if (f) pop_arg(&arg, st, ap); | 525 | 				if (!f) nl_type[argpos]=st; |
| 526 | 				else arg=nl_arg[argpos]; | ||
| 527 | 			} else if (f) pop_arg(&arg, st, ap); | ||
| 526 | 			else return 0; | 528 | 			else return 0; |
| 527 | 		} | 529 | 		} |
| 528 | 530 | ||
| 529 | 		if (!f) continue; | 531 | 		if (!f) continue; |
| 530 | 532 | ||
| 533 | 		/* Do not process any new directives once in error state. */ | ||
| 534 | 		if (ferror(f)) return -1; | ||
| 535 | |||
| 531 | 		z = buf + sizeof(buf); | 536 | 		z = buf + sizeof(buf); |
| 532 | 		prefix = "-+ 0X0x"; | 537 | 		prefix = "-+ 0X0x"; |
| 533 | 		pl = 0; | 538 | 		pl = 0; |
| ... | @@ -672,7 +677,7 @@ int vfprintf(FILE *restrict f, const char *restrict fmt, va_list ap) | ... | @@ -672,7 +677,7 @@ int vfprintf(FILE *restrict f, const char *restrict fmt, va_list ap) |
| 672 | 677 | ||
| 673 | 	FLOCK(f); | 678 | 	FLOCK(f); |
| 674 | 	olderr = f->flags & F_ERR; | 679 | 	olderr = f->flags & F_ERR; |
| 675 | 	if (f->mode < 1) f->flags &= ~F_ERR; | 680 | 	f->flags &= ~F_ERR; |
| 676 | 	if (!f->buf_size) { | 681 | 	if (!f->buf_size) { |
| 677 | 		saved_buf = f->buf; | 682 | 		saved_buf = f->buf; |
| 678 | 		f->buf = internal_buf; | 683 | 		f->buf = internal_buf; |
| ... | @@ -688,7 +693,7 @@ int vfprintf(FILE *restrict f, const char *restrict fmt, va_list ap) | ... | @@ -688,7 +693,7 @@ int vfprintf(FILE *restrict f, const char *restrict fmt, va_list ap) |
| 688 | 		f->buf_size = 0; | 693 | 		f->buf_size = 0; |
| 689 | 		f->wpos = f->wbase = f->wend = 0; | 694 | 		f->wpos = f->wbase = f->wend = 0; |
| 690 | 	} | 695 | 	} |
| 691 | 	if (f->flags & F_ERR) ret = -1; | 696 | 	if (ferror(f)) ret = -1; |
| 692 | 	f->flags |= olderr; | 697 | 	f->flags |= olderr; |
| 693 | 	FUNLOCK(f); | 698 | 	FUNLOCK(f); |
| 694 | 	va_end(ap2); | 699 | 	va_end(ap2); |
lib/libc/musl/src/stdio/vfwprintf.c+23-16| ... | @@ -125,7 +125,13 @@ static void pop_arg(union arg *arg, int type, va_list *ap) | ... | @@ -125,7 +125,13 @@ static void pop_arg(union arg *arg, int type, va_list *ap) |
| 125 | 125 | ||
| 126 | static void out(FILE *f, const wchar_t *s, size_t l) | 126 | static void out(FILE *f, const wchar_t *s, size_t l) |
| 127 | { | 127 | { |
| 128 | 	while (l-- && !(f->flags & F_ERR)) fputwc(*s++, f); | 128 | 	while (l-- && !ferror(f)) fputwc(*s++, f); |
| 129 | } | ||
| 130 | |||
| 131 | static void pad(FILE *f, int n, int fl) | ||
| 132 | { | ||
| 133 | 	if ((fl & LEFT_ADJ) || !n || ferror(f)) return; | ||
| 134 | 	fprintf(f, "%*s", n, ""); | ||
| 129 | } | 135 | } |
| 130 | 136 | ||
| 131 | static int getint(wchar_t **s) { | 137 | static int getint(wchar_t **s) { |
| ... | @@ -242,6 +248,10 @@ static int wprintf_core(FILE *f, const wchar_t *fmt, va_list *ap, union arg *nl_ | ... | @@ -242,6 +248,10 @@ static int wprintf_core(FILE *f, const wchar_t *fmt, va_list *ap, union arg *nl_ |
| 242 | 		} | 248 | 		} |
| 243 | 249 | ||
| 244 | 		if (!f) continue; | 250 | 		if (!f) continue; |
| 251 | |||
| 252 | 		/* Do not process any new directives once in error state. */ | ||
| 253 | 		if (ferror(f)) return -1; | ||
| 254 | |||
| 245 | 		t = s[-1]; | 255 | 		t = s[-1]; |
| 246 | 		if (ps && (t&15)==3) t&=~32; | 256 | 		if (ps && (t&15)==3) t&=~32; |
| 247 | 257 | ||
| ... | @@ -258,25 +268,22 @@ static int wprintf_core(FILE *f, const wchar_t *fmt, va_list *ap, union arg *nl_ | ... | @@ -258,25 +268,22 @@ static int wprintf_core(FILE *f, const wchar_t *fmt, va_list *ap, union arg *nl_ |
| 258 | 			} | 268 | 			} |
| 259 | 			continue; | 269 | 			continue; |
| 260 | 		case 'c': | 270 | 		case 'c': |
| 271 | 		case 'C': | ||
| 261 | 			if (w<1) w=1; | 272 | 			if (w<1) w=1; |
| 262 | 			if (w>1 && !(fl&LEFT_ADJ)) fprintf(f, "%*s", w-1, ""); | 273 | 			pad(f, w-1, fl); |
| 263 | 			fputwc(btowc(arg.i), f); | 274 | 			out(f, &(wchar_t){t=='C' ? arg.i : btowc(arg.i)}, 1); |
| 264 | 			if (w>1 && (fl&LEFT_ADJ)) fprintf(f, "%*s", w-1, ""); | 275 | 			pad(f, w-1, fl^LEFT_ADJ); |
| 265 | 			l = w; | 276 | 			l = w; |
| 266 | 			continue; | 277 | 			continue; |
| 267 | 		case 'C': | ||
| 268 | 			fputwc(arg.i, f); | ||
| 269 | 			l = 1; | ||
| 270 | 			continue; | ||
| 271 | 		case 'S': | 278 | 		case 'S': |
| 272 | 			a = arg.p; | 279 | 			a = arg.p; |
| 273 | 			z = a + wcsnlen(a, p<0 ? INT_MAX : p); | 280 | 			z = a + wcsnlen(a, p<0 ? INT_MAX : p); |
| 274 | 			if (p<0 && *z) goto overflow; | 281 | 			if (p<0 && *z) goto overflow; |
| 275 | 			p = z-a; | 282 | 			p = z-a; |
| 276 | 			if (w<p) w=p; | 283 | 			if (w<p) w=p; |
| 277 | 			if (!(fl&LEFT_ADJ)) fprintf(f, "%*s", w-p, ""); | 284 | 			pad(f, w-p, fl); |
| 278 | 			out(f, a, p); | 285 | 			out(f, a, p); |
| 279 | 			if ((fl&LEFT_ADJ)) fprintf(f, "%*s", w-p, ""); | 286 | 			pad(f, w-p, fl^LEFT_ADJ); |
| 280 | 			l=w; | 287 | 			l=w; |
| 281 | 			continue; | 288 | 			continue; |
| 282 | 		case 'm': | 289 | 		case 'm': |
| ... | @@ -289,14 +296,14 @@ static int wprintf_core(FILE *f, const wchar_t *fmt, va_list *ap, union arg *nl_ | ... | @@ -289,14 +296,14 @@ static int wprintf_core(FILE *f, const wchar_t *fmt, va_list *ap, union arg *nl_ |
| 289 | 			if (p<0 && *bs) goto overflow; | 296 | 			if (p<0 && *bs) goto overflow; |
| 290 | 			p=l; | 297 | 			p=l; |
| 291 | 			if (w<p) w=p; | 298 | 			if (w<p) w=p; |
| 292 | 			if (!(fl&LEFT_ADJ)) fprintf(f, "%*s", w-p, ""); | 299 | 			pad(f, w-p, fl); |
| 293 | 			bs = arg.p; | 300 | 			bs = arg.p; |
| 294 | 			while (l--) { | 301 | 			while (l--) { |
| 295 | 				i=mbtowc(&wc, bs, MB_LEN_MAX); | 302 | 				i=mbtowc(&wc, bs, MB_LEN_MAX); |
| 296 | 				bs+=i; | 303 | 				bs+=i; |
| 297 | 				fputwc(wc, f); | 304 | 				out(f, &wc, 1); |
| 298 | 			} | 305 | 			} |
| 299 | 			if ((fl&LEFT_ADJ)) fprintf(f, "%*s", w-p, ""); | 306 | 			pad(f, w-p, fl^LEFT_ADJ); |
| 300 | 			l=w; | 307 | 			l=w; |
| 301 | 			continue; | 308 | 			continue; |
| 302 | 		} | 309 | 		} |
| ... | @@ -340,8 +347,8 @@ overflow: | ... | @@ -340,8 +347,8 @@ overflow: |
| 340 | int vfwprintf(FILE *restrict f, const wchar_t *restrict fmt, va_list ap) | 347 | int vfwprintf(FILE *restrict f, const wchar_t *restrict fmt, va_list ap) |
| 341 | { | 348 | { |
| 342 | 	va_list ap2; | 349 | 	va_list ap2; |
| 343 | 	int nl_type[NL_ARGMAX] = {0}; | 350 | 	int nl_type[NL_ARGMAX+1] = {0}; |
| 344 | 	union arg nl_arg[NL_ARGMAX]; | 351 | 	union arg nl_arg[NL_ARGMAX+1]; |
| 345 | 	int olderr; | 352 | 	int olderr; |
| 346 | 	int ret; | 353 | 	int ret; |
| 347 | 354 | ||
| ... | @@ -357,7 +364,7 @@ int vfwprintf(FILE *restrict f, const wchar_t *restrict fmt, va_list ap) | ... | @@ -357,7 +364,7 @@ int vfwprintf(FILE *restrict f, const wchar_t *restrict fmt, va_list ap) |
| 357 | 	olderr = f->flags & F_ERR; | 364 | 	olderr = f->flags & F_ERR; |
| 358 | 	f->flags &= ~F_ERR; | 365 | 	f->flags &= ~F_ERR; |
| 359 | 	ret = wprintf_core(f, fmt, &ap2, nl_arg, nl_type); | 366 | 	ret = wprintf_core(f, fmt, &ap2, nl_arg, nl_type); |
| 360 | 	if (f->flags & F_ERR) ret = -1; | 367 | 	if (ferror(f)) ret = -1; |
| 361 | 	f->flags |= olderr; | 368 | 	f->flags |= olderr; |
| 362 | 	FUNLOCK(f); | 369 | 	FUNLOCK(f); |
| 363 | 	va_end(ap2); | 370 | 	va_end(ap2); |
lib/libc/musl/src/stdio/vswprintf.c+1| ... | @@ -18,6 +18,7 @@ static size_t sw_write(FILE *f, const unsigned char *s, size_t l) | ... | @@ -18,6 +18,7 @@ static size_t sw_write(FILE *f, const unsigned char *s, size_t l) |
| 18 | 	if (s!=f->wbase && sw_write(f, f->wbase, f->wpos-f->wbase)==-1) | 18 | 	if (s!=f->wbase && sw_write(f, f->wbase, f->wpos-f->wbase)==-1) |
| 19 | 		return -1; | 19 | 		return -1; |
| 20 | 	while (c->l && l && (i=mbtowc(c->ws, (void *)s, l))>=0) { | 20 | 	while (c->l && l && (i=mbtowc(c->ws, (void *)s, l))>=0) { |
| 21 | 		if (!i) i=1; | ||
| 21 | 		s+=i; | 22 | 		s+=i; |
| 22 | 		l-=i; | 23 | 		l-=i; |
| 23 | 		c->l--; | 24 | 		c->l--; |
lib/libc/musl/src/stdlib/qsort_nr.c+1-1| ... | @@ -10,5 +10,5 @@ static int wrapper_cmp(const void *v1, const void *v2, void *cmp) | ... | @@ -10,5 +10,5 @@ static int wrapper_cmp(const void *v1, const void *v2, void *cmp) |
| 10 | 10 | ||
| 11 | void qsort(void *base, size_t nel, size_t width, cmpfun cmp) | 11 | void qsort(void *base, size_t nel, size_t width, cmpfun cmp) |
| 12 | { | 12 | { |
| 13 | 	__qsort_r(base, nel, width, wrapper_cmp, cmp); | 13 | 	__qsort_r(base, nel, width, wrapper_cmp, (void *)cmp); |
| 14 | } | 14 | } |
lib/libc/musl/src/string/strverscmp.c+3-3| ... | @@ -18,9 +18,9 @@ int strverscmp(const char *l0, const char *r0) | ... | @@ -18,9 +18,9 @@ int strverscmp(const char *l0, const char *r0) |
| 18 | 		else if (c!='0') z=0; | 18 | 		else if (c!='0') z=0; |
| 19 | 	} | 19 | 	} |
| 20 | 20 | ||
| 21 | 	if (l[dp]!='0' && r[dp]!='0') { | 21 | 	if (l[dp]-'1'<9U && r[dp]-'1'<9U) { |
| 22 | 		/* If we're not looking at a digit sequence that began | 22 | 		/* If we're looking at non-degenerate digit sequences starting |
| 23 | 		 * with a zero, longest digit string is greater. */ | 23 | 		 * with nonzero digits, longest digit string is greater. */ |
| 24 | 		for (j=i; isdigit(l[j]); j++) | 24 | 		for (j=i; isdigit(l[j]); j++) |
| 25 | 			if (!isdigit(r[j])) return 1; | 25 | 			if (!isdigit(r[j])) return 1; |
| 26 | 		if (isdigit(r[j])) return -1; | 26 | 		if (isdigit(r[j])) return -1; |
lib/libc/musl/src/string/wcscmp.c+1-1| ... | @@ -3,5 +3,5 @@ | ... | @@ -3,5 +3,5 @@ |
| 3 | int wcscmp(const wchar_t *l, const wchar_t *r) | 3 | int wcscmp(const wchar_t *l, const wchar_t *r) |
| 4 | { | 4 | { |
| 5 | 	for (; *l==*r && *l && *r; l++, r++); | 5 | 	for (; *l==*r && *l && *r; l++, r++); |
| 6 | 	return *l - *r; | 6 | 	return *l < *r ? -1 : *l > *r; |
| 7 | } | 7 | } |
lib/libc/musl/src/string/wcsncmp.c+1-1| ... | @@ -3,5 +3,5 @@ | ... | @@ -3,5 +3,5 @@ |
| 3 | int wcsncmp(const wchar_t *l, const wchar_t *r, size_t n) | 3 | int wcsncmp(const wchar_t *l, const wchar_t *r, size_t n) |
| 4 | { | 4 | { |
| 5 | 	for (; n && *l==*r && *l && *r; n--, l++, r++); | 5 | 	for (; n && *l==*r && *l && *r; n--, l++, r++); |
| 6 | 	return n ? *l - *r : 0; | 6 | 	return n ? (*l < *r ? -1 : *l > *r) : 0; |
| 7 | } | 7 | } |
lib/libc/musl/src/string/wmemcmp.c+1-1| ... | @@ -3,5 +3,5 @@ | ... | @@ -3,5 +3,5 @@ |
| 3 | int wmemcmp(const wchar_t *l, const wchar_t *r, size_t n) | 3 | int wmemcmp(const wchar_t *l, const wchar_t *r, size_t n) |
| 4 | { | 4 | { |
| 5 | 	for (; n && *l==*r; n--, l++, r++); | 5 | 	for (; n && *l==*r; n--, l++, r++); |
| 6 | 	return n ? *l-*r : 0; | 6 | 	return n ? (*l < *r ? -1 : *l > *r) : 0; |
| 7 | } | 7 | } |
lib/libc/musl/src/temp/__randname.c+2-1| ... | @@ -1,5 +1,6 @@ | ... | @@ -1,5 +1,6 @@ |
| 1 | #include <time.h> | 1 | #include <time.h> |
| 2 | #include <stdint.h> | 2 | #include <stdint.h> |
| 3 | #include "pthread_impl.h" | ||
| 3 | 4 | ||
| 4 | /* This assumes that a check for the | 5 | /* This assumes that a check for the |
| 5 | template size has already been made */ | 6 | template size has already been made */ |
| ... | @@ -10,7 +11,7 @@ char *__randname(char *template) | ... | @@ -10,7 +11,7 @@ char *__randname(char *template) |
| 10 | 	unsigned long r; | 11 | 	unsigned long r; |
| 11 | 12 | ||
| 12 | 	__clock_gettime(CLOCK_REALTIME, &ts); | 13 | 	__clock_gettime(CLOCK_REALTIME, &ts); |
| 13 | 	r = ts.tv_nsec*65537 ^ (uintptr_t)&ts / 16 + (uintptr_t)template; | 14 | 	r = ts.tv_sec + ts.tv_nsec + __pthread_self()->tid * 65537UL; |
| 14 | 	for (i=0; i<6; i++, r>>=5) | 15 | 	for (i=0; i<6; i++, r>>=5) |
| 15 | 		template[i] = 'A'+(r&15)+(r&16)*2; | 16 | 		template[i] = 'A'+(r&15)+(r&16)*2; |
| 16 | 17 |
lib/libc/musl/src/temp/mkostemp.c-2| ... | @@ -5,5 +5,3 @@ int mkostemp(char *template, int flags) | ... | @@ -5,5 +5,3 @@ int mkostemp(char *template, int flags) |
| 5 | { | 5 | { |
| 6 | 	return __mkostemps(template, 0, flags); | 6 | 	return __mkostemps(template, 0, flags); |
| 7 | } | 7 | } |
| 8 | |||
| 9 | weak_alias(mkostemp, mkostemp64); |
lib/libc/musl/src/temp/mkostemps.c-1| ... | @@ -26,4 +26,3 @@ int __mkostemps(char *template, int len, int flags) | ... | @@ -26,4 +26,3 @@ int __mkostemps(char *template, int len, int flags) |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | weak_alias(__mkostemps, mkostemps); | 28 | weak_alias(__mkostemps, mkostemps); |
| 29 | weak_alias(__mkostemps, mkostemps64); |
lib/libc/musl/src/temp/mkstemp.c-2| ... | @@ -4,5 +4,3 @@ int mkstemp(char *template) | ... | @@ -4,5 +4,3 @@ int mkstemp(char *template) |
| 4 | { | 4 | { |
| 5 | 	return __mkostemps(template, 0, 0); | 5 | 	return __mkostemps(template, 0, 0); |
| 6 | } | 6 | } |
| 7 | |||
| 8 | weak_alias(mkstemp, mkstemp64); |
lib/libc/musl/src/temp/mkstemps.c-2| ... | @@ -5,5 +5,3 @@ int mkstemps(char *template, int len) | ... | @@ -5,5 +5,3 @@ int mkstemps(char *template, int len) |
| 5 | { | 5 | { |
| 6 | 	return __mkostemps(template, len, 0); | 6 | 	return __mkostemps(template, len, 0); |
| 7 | } | 7 | } |
| 8 | |||
| 9 | weak_alias(mkstemps, mkstemps64); |
lib/libc/musl/src/thread/pthread_atfork.c+7-1| ... | @@ -1,7 +1,13 @@ | ... | @@ -1,7 +1,13 @@ |
| 1 | #include <pthread.h> | 1 | #include <pthread.h> |
| 2 | #include <errno.h> | ||
| 2 | #include "libc.h" | 3 | #include "libc.h" |
| 3 | #include "lock.h" | 4 | #include "lock.h" |
| 4 | 5 | ||
| 6 | #define malloc __libc_malloc | ||
| 7 | #define calloc undef | ||
| 8 | #define realloc undef | ||
| 9 | #define free undef | ||
| 10 | |||
| 5 | static struct atfork_funcs { | 11 | static struct atfork_funcs { |
| 6 | 	void (*prepare)(void); | 12 | 	void (*prepare)(void); |
| 7 | 	void (*parent)(void); | 13 | 	void (*parent)(void); |
| ... | @@ -34,7 +40,7 @@ void __fork_handler(int who) | ... | @@ -34,7 +40,7 @@ void __fork_handler(int who) |
| 34 | int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void)) | 40 | int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void)) |
| 35 | { | 41 | { |
| 36 | 	struct atfork_funcs *new = malloc(sizeof *new); | 42 | 	struct atfork_funcs *new = malloc(sizeof *new); |
| 37 | 	if (!new) return -1; | 43 | 	if (!new) return ENOMEM; |
| 38 | 44 | ||
| 39 | 	LOCK(lock); | 45 | 	LOCK(lock); |
| 40 | 	new->next = funcs; | 46 | 	new->next = funcs; |
lib/libc/musl/src/thread/pthread_cancel.c+7-2| ... | @@ -56,7 +56,12 @@ static void cancel_handler(int sig, siginfo_t *si, void *ctx) | ... | @@ -56,7 +56,12 @@ static void cancel_handler(int sig, siginfo_t *si, void *ctx) |
| 56 | 56 | ||
| 57 | 	_sigaddset(&uc->uc_sigmask, SIGCANCEL); | 57 | 	_sigaddset(&uc->uc_sigmask, SIGCANCEL); |
| 58 | 58 | ||
| 59 | 	if (self->cancelasync || pc >= (uintptr_t)__cp_begin && pc < (uintptr_t)__cp_end) { | 59 | 	if (self->cancelasync) { |
| 60 | 		pthread_sigmask(SIG_SETMASK, &uc->uc_sigmask, 0); | ||
| 61 | 		__cancel(); | ||
| 62 | 	} | ||
| 63 | |||
| 64 | 	if (pc >= (uintptr_t)__cp_begin && pc < (uintptr_t)__cp_end) { | ||
| 60 | 		uc->uc_mcontext.MC_PC = (uintptr_t)__cp_cancel; | 65 | 		uc->uc_mcontext.MC_PC = (uintptr_t)__cp_cancel; |
| 61 | #ifdef CANCEL_GOT | 66 | #ifdef CANCEL_GOT |
| 62 | 		uc->uc_mcontext.MC_GOT = CANCEL_GOT; | 67 | 		uc->uc_mcontext.MC_GOT = CANCEL_GOT; |
| ... | @@ -77,7 +82,7 @@ void __testcancel() | ... | @@ -77,7 +82,7 @@ void __testcancel() |
| 77 | static void init_cancellation() | 82 | static void init_cancellation() |
| 78 | { | 83 | { |
| 79 | 	struct sigaction sa = { | 84 | 	struct sigaction sa = { |
| 80 | 		.sa_flags = SA_SIGINFO | SA_RESTART, | 85 | 		.sa_flags = SA_SIGINFO | SA_RESTART | SA_ONSTACK, |
| 81 | 		.sa_sigaction = cancel_handler | 86 | 		.sa_sigaction = cancel_handler |
| 82 | 	}; | 87 | 	}; |
| 83 | 	memset(&sa.sa_mask, -1, _NSIG/8); | 88 | 	memset(&sa.sa_mask, -1, _NSIG/8); |
lib/libc/musl/src/thread/pthread_create.c+10-6| ... | @@ -107,6 +107,16 @@ _Noreturn void __pthread_exit(void *result) | ... | @@ -107,6 +107,16 @@ _Noreturn void __pthread_exit(void *result) |
| 107 | 107 | ||
| 108 | 	/* At this point we are committed to thread termination. */ | 108 | 	/* At this point we are committed to thread termination. */ |
| 109 | 109 | ||
| 110 | 	/* After the kernel thread exits, its tid may be reused. Clear it | ||
| 111 | 	 * to prevent inadvertent use and inform functions that would use | ||
| 112 | 	 * it that it's no longer available. At this point the killlock | ||
| 113 | 	 * may be released, since functions that use it will consistently | ||
| 114 | 	 * see the thread as having exited. Release it now so that no | ||
| 115 | 	 * remaining locks (except thread list) are held if we end up | ||
| 116 | 	 * resetting need_locks below. */ | ||
| 117 | 	self->tid = 0; | ||
| 118 | 	UNLOCK(self->killlock); | ||
| 119 | |||
| 110 | 	/* Process robust list in userspace to handle non-pshared mutexes | 120 | 	/* Process robust list in userspace to handle non-pshared mutexes |
| 111 | 	 * and the detached thread case where the robust list head will | 121 | 	 * and the detached thread case where the robust list head will |
| 112 | 	 * be invalid when the kernel would process it. */ | 122 | 	 * be invalid when the kernel would process it. */ |
| ... | @@ -159,12 +169,6 @@ _Noreturn void __pthread_exit(void *result) | ... | @@ -159,12 +169,6 @@ _Noreturn void __pthread_exit(void *result) |
| 159 | 	a_store(&self->detach_state, DT_EXITED); | 169 | 	a_store(&self->detach_state, DT_EXITED); |
| 160 | 	__wake(&self->detach_state, 1, 1); | 170 | 	__wake(&self->detach_state, 1, 1); |
| 161 | 171 | ||
| 162 | 	/* After the kernel thread exits, its tid may be reused. Clear it | ||
| 163 | 	 * to prevent inadvertent use and inform functions that would use | ||
| 164 | 	 * it that it's no longer available. */ | ||
| 165 | 	self->tid = 0; | ||
| 166 | 	UNLOCK(self->killlock); | ||
| 167 | |||
| 168 | 	for (;;) __syscall(SYS_exit, 0); | 172 | 	for (;;) __syscall(SYS_exit, 0); |
| 169 | } | 173 | } |
| 170 | 174 |
lib/libc/musl/src/thread/pthread_detach.c+6-2| ... | @@ -5,8 +5,12 @@ static int __pthread_detach(pthread_t t) | ... | @@ -5,8 +5,12 @@ static int __pthread_detach(pthread_t t) |
| 5 | { | 5 | { |
| 6 | 	/* If the cas fails, detach state is either already-detached | 6 | 	/* If the cas fails, detach state is either already-detached |
| 7 | 	 * or exiting/exited, and pthread_join will trap or cleanup. */ | 7 | 	 * or exiting/exited, and pthread_join will trap or cleanup. */ |
| 8 | 	if (a_cas(&t->detach_state, DT_JOINABLE, DT_DETACHED) != DT_JOINABLE) | 8 | 	if (a_cas(&t->detach_state, DT_JOINABLE, DT_DETACHED) != DT_JOINABLE) { |
| 9 | 		return __pthread_join(t, 0); | 9 | 		int cs; |
| 10 | 		__pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs); | ||
| 11 | 		__pthread_join(t, 0); | ||
| 12 | 		__pthread_setcancelstate(cs, 0); | ||
| 13 | 	} | ||
| 10 | 	return 0; | 14 | 	return 0; |
| 11 | } | 15 | } |
| 12 | 16 |
lib/libc/musl/src/thread/pthread_key_create.c+8| ... | @@ -1,4 +1,5 @@ | ... | @@ -1,4 +1,5 @@ |
| 1 | #include "pthread_impl.h" | 1 | #include "pthread_impl.h" |
| 2 | #include "fork_impl.h" | ||
| 2 | 3 | ||
| 3 | volatile size_t __pthread_tsd_size = sizeof(void *) * PTHREAD_KEYS_MAX; | 4 | volatile size_t __pthread_tsd_size = sizeof(void *) * PTHREAD_KEYS_MAX; |
| 4 | void *__pthread_tsd_main[PTHREAD_KEYS_MAX] = { 0 }; | 5 | void *__pthread_tsd_main[PTHREAD_KEYS_MAX] = { 0 }; |
| ... | @@ -20,6 +21,13 @@ static void dummy_0(void) | ... | @@ -20,6 +21,13 @@ static void dummy_0(void) |
| 20 | weak_alias(dummy_0, __tl_lock); | 21 | weak_alias(dummy_0, __tl_lock); |
| 21 | weak_alias(dummy_0, __tl_unlock); | 22 | weak_alias(dummy_0, __tl_unlock); |
| 22 | 23 | ||
| 24 | void __pthread_key_atfork(int who) | ||
| 25 | { | ||
| 26 | 	if (who<0) __pthread_rwlock_rdlock(&key_lock); | ||
| 27 | 	else if (!who) __pthread_rwlock_unlock(&key_lock); | ||
| 28 | 	else key_lock = (pthread_rwlock_t)PTHREAD_RWLOCK_INITIALIZER; | ||
| 29 | } | ||
| 30 | |||
| 23 | int __pthread_key_create(pthread_key_t *k, void (*dtor)(void *)) | 31 | int __pthread_key_create(pthread_key_t *k, void (*dtor)(void *)) |
| 24 | { | 32 | { |
| 25 | 	pthread_t self = __pthread_self(); | 33 | 	pthread_t self = __pthread_self(); |
lib/libc/musl/src/thread/sem_getvalue.c+2-1| ... | @@ -1,8 +1,9 @@ | ... | @@ -1,8 +1,9 @@ |
| 1 | #include <semaphore.h> | 1 | #include <semaphore.h> |
| 2 | #include <limits.h> | ||
| 2 | 3 | ||
| 3 | int sem_getvalue(sem_t *restrict sem, int *restrict valp) | 4 | int sem_getvalue(sem_t *restrict sem, int *restrict valp) |
| 4 | { | 5 | { |
| 5 | 	int val = sem->__val[0]; | 6 | 	int val = sem->__val[0]; |
| 6 | 	*valp = val < 0 ? 0 : val; | 7 | 	*valp = val & SEM_VALUE_MAX; |
| 7 | 	return 0; | 8 | 	return 0; |
| 8 | } | 9 | } |
lib/libc/musl/src/thread/sem_post.c+8-4| ... | @@ -1,17 +1,21 @@ | ... | @@ -1,17 +1,21 @@ |
| 1 | #include <semaphore.h> | 1 | #include <semaphore.h> |
| 2 | #include <limits.h> | ||
| 2 | #include "pthread_impl.h" | 3 | #include "pthread_impl.h" |
| 3 | 4 | ||
| 4 | int sem_post(sem_t *sem) | 5 | int sem_post(sem_t *sem) |
| 5 | { | 6 | { |
| 6 | 	int val, waiters, priv = sem->__val[2]; | 7 | 	int val, new, waiters, priv = sem->__val[2]; |
| 7 | 	do { | 8 | 	do { |
| 8 | 		val = sem->__val[0]; | 9 | 		val = sem->__val[0]; |
| 9 | 		waiters = sem->__val[1]; | 10 | 		waiters = sem->__val[1]; |
| 10 | 		if (val == SEM_VALUE_MAX) { | 11 | 		if ((val & SEM_VALUE_MAX) == SEM_VALUE_MAX) { |
| 11 | 			errno = EOVERFLOW; | 12 | 			errno = EOVERFLOW; |
| 12 | 			return -1; | 13 | 			return -1; |
| 13 | 		} | 14 | 		} |
| 14 | 	} while (a_cas(sem->__val, val, val+1+(val<0)) != val); | 15 | 		new = val + 1; |
| 15 | 	if (val<0 || waiters) __wake(sem->__val, 1, priv); | 16 | 		if (waiters <= 1) |
| 17 | 			new &= ~0x80000000; | ||
| 18 | 	} while (a_cas(sem->__val, val, new) != val); | ||
| 19 | 	if (val<0) __wake(sem->__val, waiters>1 ? 1 : -1, priv); | ||
| 16 | 	return 0; | 20 | 	return 0; |
| 17 | } | 21 | } |
lib/libc/musl/src/thread/sem_timedwait.c+6-4| ... | @@ -1,4 +1,5 @@ | ... | @@ -1,4 +1,5 @@ |
| 1 | #include <semaphore.h> | 1 | #include <semaphore.h> |
| 2 | #include <limits.h> | ||
| 2 | #include "pthread_impl.h" | 3 | #include "pthread_impl.h" |
| 3 | 4 | ||
| 4 | static void cleanup(void *p) | 5 | static void cleanup(void *p) |
| ... | @@ -13,14 +14,15 @@ int sem_timedwait(sem_t *restrict sem, const struct timespec *restrict at) | ... | @@ -13,14 +14,15 @@ int sem_timedwait(sem_t *restrict sem, const struct timespec *restrict at) |
| 13 | 	if (!sem_trywait(sem)) return 0; | 14 | 	if (!sem_trywait(sem)) return 0; |
| 14 | 15 | ||
| 15 | 	int spins = 100; | 16 | 	int spins = 100; |
| 16 | 	while (spins-- && sem->__val[0] <= 0 && !sem->__val[1]) a_spin(); | 17 | 	while (spins-- && !(sem->__val[0] & SEM_VALUE_MAX) && !sem->__val[1]) |
| 18 | 		a_spin(); | ||
| 17 | 19 | ||
| 18 | 	while (sem_trywait(sem)) { | 20 | 	while (sem_trywait(sem)) { |
| 19 | 		int r; | 21 | 		int r, priv = sem->__val[2]; |
| 20 | 		a_inc(sem->__val+1); | 22 | 		a_inc(sem->__val+1); |
| 21 | 		a_cas(sem->__val, 0, -1); | 23 | 		a_cas(sem->__val, 0, 0x80000000); |
| 22 | 		pthread_cleanup_push(cleanup, (void *)(sem->__val+1)); | 24 | 		pthread_cleanup_push(cleanup, (void *)(sem->__val+1)); |
| 23 | 		r = __timedwait_cp(sem->__val, -1, CLOCK_REALTIME, at, sem->__val[2]); | 25 | 		r = __timedwait_cp(sem->__val, 0x80000000, CLOCK_REALTIME, at, priv); |
| 24 | 		pthread_cleanup_pop(1); | 26 | 		pthread_cleanup_pop(1); |
| 25 | 		if (r) { | 27 | 		if (r) { |
| 26 | 			errno = r; | 28 | 			errno = r; |
lib/libc/musl/src/thread/sem_trywait.c+3-3| ... | @@ -1,12 +1,12 @@ | ... | @@ -1,12 +1,12 @@ |
| 1 | #include <semaphore.h> | 1 | #include <semaphore.h> |
| 2 | #include <limits.h> | ||
| 2 | #include "pthread_impl.h" | 3 | #include "pthread_impl.h" |
| 3 | 4 | ||
| 4 | int sem_trywait(sem_t *sem) | 5 | int sem_trywait(sem_t *sem) |
| 5 | { | 6 | { |
| 6 | 	int val; | 7 | 	int val; |
| 7 | 	while ((val=sem->__val[0]) > 0) { | 8 | 	while ((val=sem->__val[0]) & SEM_VALUE_MAX) { |
| 8 | 		int new = val-1-(val==1 && sem->__val[1]); | 9 | 		if (a_cas(sem->__val, val, val-1)==val) return 0; |
| 9 | 		if (a_cas(sem->__val, val, new)==val) return 0; | ||
| 10 | 	} | 10 | 	} |
| 11 | 	errno = EAGAIN; | 11 | 	errno = EAGAIN; |
| 12 | 	return -1; | 12 | 	return -1; |
lib/libc/musl/src/thread/synccall.c+1-1| ... | @@ -45,7 +45,7 @@ void __synccall(void (*func)(void *), void *ctx) | ... | @@ -45,7 +45,7 @@ void __synccall(void (*func)(void *), void *ctx) |
| 45 | { | 45 | { |
| 46 | 	sigset_t oldmask; | 46 | 	sigset_t oldmask; |
| 47 | 	int cs, i, r; | 47 | 	int cs, i, r; |
| 48 | 	struct sigaction sa = { .sa_flags = SA_RESTART, .sa_handler = handler }; | 48 | 	struct sigaction sa = { .sa_flags = SA_RESTART | SA_ONSTACK, .sa_handler = handler }; |
| 49 | 	pthread_t self = __pthread_self(), td; | 49 | 	pthread_t self = __pthread_self(), td; |
| 50 | 	int count = 0; | 50 | 	int count = 0; |
| 51 | 51 |
lib/libc/musl/src/time/__map_file.c+2-3| ... | @@ -2,15 +2,14 @@ | ... | @@ -2,15 +2,14 @@ |
| 2 | #include <fcntl.h> | 2 | #include <fcntl.h> |
| 3 | #include <sys/stat.h> | 3 | #include <sys/stat.h> |
| 4 | #include "syscall.h" | 4 | #include "syscall.h" |
| 5 | #include "kstat.h" | ||
| 6 | 5 | ||
| 7 | const char unsigned *__map_file(const char *pathname, size_t *size) | 6 | const char unsigned *__map_file(const char *pathname, size_t *size) |
| 8 | { | 7 | { |
| 9 | 	struct kstat st; | 8 | 	struct stat st; |
| 10 | 	const unsigned char *map = MAP_FAILED; | 9 | 	const unsigned char *map = MAP_FAILED; |
| 11 | 	int fd = sys_open(pathname, O_RDONLY|O_CLOEXEC|O_NONBLOCK); | 10 | 	int fd = sys_open(pathname, O_RDONLY|O_CLOEXEC|O_NONBLOCK); |
| 12 | 	if (fd < 0) return 0; | 11 | 	if (fd < 0) return 0; |
| 13 | 	if (!syscall(SYS_fstat, fd, &st)) { | 12 | 	if (!__fstat(fd, &st)) { |
| 14 | 		map = __mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0); | 13 | 		map = __mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0); |
| 15 | 		*size = st.st_size; | 14 | 		*size = st.st_size; |
| 16 | 	} | 15 | 	} |
lib/libc/musl/src/time/clock_getcpuclockid.c+1| ... | @@ -8,6 +8,7 @@ int clock_getcpuclockid(pid_t pid, clockid_t *clk) | ... | @@ -8,6 +8,7 @@ int clock_getcpuclockid(pid_t pid, clockid_t *clk) |
| 8 | 	struct timespec ts; | 8 | 	struct timespec ts; |
| 9 | 	clockid_t id = (-pid-1)*8U + 2; | 9 | 	clockid_t id = (-pid-1)*8U + 2; |
| 10 | 	int ret = __syscall(SYS_clock_getres, id, &ts); | 10 | 	int ret = __syscall(SYS_clock_getres, id, &ts); |
| 11 | 	if (ret == -EINVAL) ret = -ESRCH; | ||
| 11 | 	if (ret) return -ret; | 12 | 	if (ret) return -ret; |
| 12 | 	*clk = id; | 13 | 	*clk = id; |
| 13 | 	return 0; | 14 | 	return 0; |
lib/libc/musl/src/time/clock_gettime.c+7| ... | @@ -42,6 +42,9 @@ static int cgt_init(clockid_t clk, struct timespec *ts) | ... | @@ -42,6 +42,9 @@ static int cgt_init(clockid_t clk, struct timespec *ts) |
| 42 | 			p = cgt_time32_wrap; | 42 | 			p = cgt_time32_wrap; |
| 43 | 		} | 43 | 		} |
| 44 | 	} | 44 | 	} |
| 45 | #ifdef VDSO_CGT_WORKAROUND | ||
| 46 | 	if (!__vdsosym(VDSO_CGT32_VER, VDSO_CGT32_SYM)) p = 0; | ||
| 47 | #endif | ||
| 45 | #endif | 48 | #endif |
| 46 | 	int (*f)(clockid_t, struct timespec *) = | 49 | 	int (*f)(clockid_t, struct timespec *) = |
| 47 | 		(int (*)(clockid_t, struct timespec *))p; | 50 | 		(int (*)(clockid_t, struct timespec *))p; |
| ... | @@ -80,10 +83,12 @@ int __clock_gettime(clockid_t clk, struct timespec *ts) | ... | @@ -80,10 +83,12 @@ int __clock_gettime(clockid_t clk, struct timespec *ts) |
| 80 | 		return __syscall_ret(r); | 83 | 		return __syscall_ret(r); |
| 81 | 	long ts32[2]; | 84 | 	long ts32[2]; |
| 82 | 	r = __syscall(SYS_clock_gettime, clk, ts32); | 85 | 	r = __syscall(SYS_clock_gettime, clk, ts32); |
| 86 | #ifdef SYS_gettimeofday | ||
| 83 | 	if (r==-ENOSYS && clk==CLOCK_REALTIME) { | 87 | 	if (r==-ENOSYS && clk==CLOCK_REALTIME) { |
| 84 | 		r = __syscall(SYS_gettimeofday, ts32, 0); | 88 | 		r = __syscall(SYS_gettimeofday, ts32, 0); |
| 85 | 		ts32[1] *= 1000; | 89 | 		ts32[1] *= 1000; |
| 86 | 	} | 90 | 	} |
| 91 | #endif | ||
| 87 | 	if (!r) { | 92 | 	if (!r) { |
| 88 | 		ts->tv_sec = ts32[0]; | 93 | 		ts->tv_sec = ts32[0]; |
| 89 | 		ts->tv_nsec = ts32[1]; | 94 | 		ts->tv_nsec = ts32[1]; |
| ... | @@ -92,6 +97,7 @@ int __clock_gettime(clockid_t clk, struct timespec *ts) | ... | @@ -92,6 +97,7 @@ int __clock_gettime(clockid_t clk, struct timespec *ts) |
| 92 | 	return __syscall_ret(r); | 97 | 	return __syscall_ret(r); |
| 93 | #else | 98 | #else |
| 94 | 	r = __syscall(SYS_clock_gettime, clk, ts); | 99 | 	r = __syscall(SYS_clock_gettime, clk, ts); |
| 100 | #ifdef SYS_gettimeofday | ||
| 95 | 	if (r == -ENOSYS) { | 101 | 	if (r == -ENOSYS) { |
| 96 | 		if (clk == CLOCK_REALTIME) { | 102 | 		if (clk == CLOCK_REALTIME) { |
| 97 | 			__syscall(SYS_gettimeofday, ts, 0); | 103 | 			__syscall(SYS_gettimeofday, ts, 0); |
| ... | @@ -100,6 +106,7 @@ int __clock_gettime(clockid_t clk, struct timespec *ts) | ... | @@ -100,6 +106,7 @@ int __clock_gettime(clockid_t clk, struct timespec *ts) |
| 100 | 		} | 106 | 		} |
| 101 | 		r = -EINVAL; | 107 | 		r = -EINVAL; |
| 102 | 	} | 108 | 	} |
| 109 | #endif | ||
| 103 | 	return __syscall_ret(r); | 110 | 	return __syscall_ret(r); |
| 104 | #endif | 111 | #endif |
| 105 | } | 112 | } |
lib/libc/musl/src/time/timer_create.c+5-1| ... | @@ -43,6 +43,8 @@ static void *start(void *arg) | ... | @@ -43,6 +43,8 @@ static void *start(void *arg) |
| 43 | 	union sigval val = args->sev->sigev_value; | 43 | 	union sigval val = args->sev->sigev_value; |
| 44 | 44 | ||
| 45 | 	pthread_barrier_wait(&args->b); | 45 | 	pthread_barrier_wait(&args->b); |
| 46 | 	if (self->cancel) | ||
| 47 | 		return 0; | ||
| 46 | 	for (;;) { | 48 | 	for (;;) { |
| 47 | 		siginfo_t si; | 49 | 		siginfo_t si; |
| 48 | 		while (sigwaitinfo(SIGTIMER_SET, &si) < 0); | 50 | 		while (sigwaitinfo(SIGTIMER_SET, &si) < 0); |
| ... | @@ -113,8 +115,10 @@ int timer_create(clockid_t clk, struct sigevent *restrict evp, timer_t *restrict | ... | @@ -113,8 +115,10 @@ int timer_create(clockid_t clk, struct sigevent *restrict evp, timer_t *restrict |
| 113 | 		ksev.sigev_signo = SIGTIMER; | 115 | 		ksev.sigev_signo = SIGTIMER; |
| 114 | 		ksev.sigev_notify = SIGEV_THREAD_ID; | 116 | 		ksev.sigev_notify = SIGEV_THREAD_ID; |
| 115 | 		ksev.sigev_tid = td->tid; | 117 | 		ksev.sigev_tid = td->tid; |
| 116 | 		if (syscall(SYS_timer_create, clk, &ksev, &timerid) < 0) | 118 | 		if (syscall(SYS_timer_create, clk, &ksev, &timerid) < 0) { |
| 117 | 			timerid = -1; | 119 | 			timerid = -1; |
| 120 | 			td->cancel = 1; | ||
| 121 | 		} | ||
| 118 | 		td->timer_id = timerid; | 122 | 		td->timer_id = timerid; |
| 119 | 		pthread_barrier_wait(&args.b); | 123 | 		pthread_barrier_wait(&args.b); |
| 120 | 		if (timerid < 0) return -1; | 124 | 		if (timerid < 0) return -1; |
lib/libc/musl/src/unistd/dup3.c+4-2| ... | @@ -9,12 +9,14 @@ int __dup3(int old, int new, int flags) | ... | @@ -9,12 +9,14 @@ int __dup3(int old, int new, int flags) |
| 9 | 	int r; | 9 | 	int r; |
| 10 | #ifdef SYS_dup2 | 10 | #ifdef SYS_dup2 |
| 11 | 	if (old==new) return __syscall_ret(-EINVAL); | 11 | 	if (old==new) return __syscall_ret(-EINVAL); |
| 12 | 	if (flags & O_CLOEXEC) { | 12 | 	if (flags) { |
| 13 | 		while ((r=__syscall(SYS_dup3, old, new, flags))==-EBUSY); | 13 | 		while ((r=__syscall(SYS_dup3, old, new, flags))==-EBUSY); |
| 14 | 		if (r!=-ENOSYS) return __syscall_ret(r); | 14 | 		if (r!=-ENOSYS) return __syscall_ret(r); |
| 15 | 		if (flags & ~O_CLOEXEC) return __syscall_ret(-EINVAL); | ||
| 15 | 	} | 16 | 	} |
| 16 | 	while ((r=__syscall(SYS_dup2, old, new))==-EBUSY); | 17 | 	while ((r=__syscall(SYS_dup2, old, new))==-EBUSY); |
| 17 | 	if (flags & O_CLOEXEC) __syscall(SYS_fcntl, new, F_SETFD, FD_CLOEXEC); | 18 | 	if (r >= 0 && (flags & O_CLOEXEC)) |
| 19 | 		__syscall(SYS_fcntl, new, F_SETFD, FD_CLOEXEC); | ||
| 18 | #else | 20 | #else |
| 19 | 	while ((r=__syscall(SYS_dup3, old, new, flags))==-EBUSY); | 21 | 	while ((r=__syscall(SYS_dup3, old, new, flags))==-EBUSY); |
| 20 | #endif | 22 | #endif |
lib/libc/musl/src/unistd/ftruncate.c-2| ... | @@ -5,5 +5,3 @@ int ftruncate(int fd, off_t length) | ... | @@ -5,5 +5,3 @@ int ftruncate(int fd, off_t length) |
| 5 | { | 5 | { |
| 6 | 	return syscall(SYS_ftruncate, fd, __SYSCALL_LL_O(length)); | 6 | 	return syscall(SYS_ftruncate, fd, __SYSCALL_LL_O(length)); |
| 7 | } | 7 | } |
| 8 | |||
| 9 | weak_alias(ftruncate, ftruncate64); |
lib/libc/musl/src/unistd/lseek.c-1| ... | @@ -12,4 +12,3 @@ off_t __lseek(int fd, off_t offset, int whence) | ... | @@ -12,4 +12,3 @@ off_t __lseek(int fd, off_t offset, int whence) |
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | weak_alias(__lseek, lseek); | 14 | weak_alias(__lseek, lseek); |
| 15 | weak_alias(__lseek, lseek64); |
lib/libc/musl/src/unistd/mipsn32/lseek.c-1| ... | @@ -17,4 +17,3 @@ off_t __lseek(int fd, off_t offset, int whence) | ... | @@ -17,4 +17,3 @@ off_t __lseek(int fd, off_t offset, int whence) |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | weak_alias(__lseek, lseek); | 19 | weak_alias(__lseek, lseek); |
| 20 | weak_alias(__lseek, lseek64); |
lib/libc/musl/src/unistd/pipe2.c+1| ... | @@ -8,6 +8,7 @@ int pipe2(int fd[2], int flag) | ... | @@ -8,6 +8,7 @@ int pipe2(int fd[2], int flag) |
| 8 | 	if (!flag) return pipe(fd); | 8 | 	if (!flag) return pipe(fd); |
| 9 | 	int ret = __syscall(SYS_pipe2, fd, flag); | 9 | 	int ret = __syscall(SYS_pipe2, fd, flag); |
| 10 | 	if (ret != -ENOSYS) return __syscall_ret(ret); | 10 | 	if (ret != -ENOSYS) return __syscall_ret(ret); |
| 11 | 	if (flag & ~(O_CLOEXEC|O_NONBLOCK)) return __syscall_ret(-EINVAL); | ||
| 11 | 	ret = pipe(fd); | 12 | 	ret = pipe(fd); |
| 12 | 	if (ret) return ret; | 13 | 	if (ret) return ret; |
| 13 | 	if (flag & O_CLOEXEC) { | 14 | 	if (flag & O_CLOEXEC) { |
lib/libc/musl/src/unistd/pread.c-2| ... | @@ -5,5 +5,3 @@ ssize_t pread(int fd, void *buf, size_t size, off_t ofs) | ... | @@ -5,5 +5,3 @@ ssize_t pread(int fd, void *buf, size_t size, off_t ofs) |
| 5 | { | 5 | { |
| 6 | 	return syscall_cp(SYS_pread, fd, buf, size, __SYSCALL_LL_PRW(ofs)); | 6 | 	return syscall_cp(SYS_pread, fd, buf, size, __SYSCALL_LL_PRW(ofs)); |
| 7 | } | 7 | } |
| 8 | |||
| 9 | weak_alias(pread, pread64); |
lib/libc/musl/src/unistd/preadv.c-2| ... | @@ -8,5 +8,3 @@ ssize_t preadv(int fd, const struct iovec *iov, int count, off_t ofs) | ... | @@ -8,5 +8,3 @@ ssize_t preadv(int fd, const struct iovec *iov, int count, off_t ofs) |
| 8 | 	return syscall_cp(SYS_preadv, fd, iov, count, | 8 | 	return syscall_cp(SYS_preadv, fd, iov, count, |
| 9 | 		(long)(ofs), (long)(ofs>>32)); | 9 | 		(long)(ofs), (long)(ofs>>32)); |
| 10 | } | 10 | } |
| 11 | |||
| 12 | weak_alias(preadv, preadv64); |
lib/libc/musl/src/unistd/pwrite.c-2| ... | @@ -5,5 +5,3 @@ ssize_t pwrite(int fd, const void *buf, size_t size, off_t ofs) | ... | @@ -5,5 +5,3 @@ ssize_t pwrite(int fd, const void *buf, size_t size, off_t ofs) |
| 5 | { | 5 | { |
| 6 | 	return syscall_cp(SYS_pwrite, fd, buf, size, __SYSCALL_LL_PRW(ofs)); | 6 | 	return syscall_cp(SYS_pwrite, fd, buf, size, __SYSCALL_LL_PRW(ofs)); |
| 7 | } | 7 | } |
| 8 | |||
| 9 | weak_alias(pwrite, pwrite64); |
lib/libc/musl/src/unistd/pwritev.c-2| ... | @@ -8,5 +8,3 @@ ssize_t pwritev(int fd, const struct iovec *iov, int count, off_t ofs) | ... | @@ -8,5 +8,3 @@ ssize_t pwritev(int fd, const struct iovec *iov, int count, off_t ofs) |
| 8 | 	return syscall_cp(SYS_pwritev, fd, iov, count, | 8 | 	return syscall_cp(SYS_pwritev, fd, iov, count, |
| 9 | 		(long)(ofs), (long)(ofs>>32)); | 9 | 		(long)(ofs), (long)(ofs>>32)); |
| 10 | } | 10 | } |
| 11 | |||
| 12 | weak_alias(pwritev, pwritev64); |
lib/libc/musl/src/unistd/truncate.c-2| ... | @@ -5,5 +5,3 @@ int truncate(const char *path, off_t length) | ... | @@ -5,5 +5,3 @@ int truncate(const char *path, off_t length) |
| 5 | { | 5 | { |
| 6 | 	return syscall(SYS_truncate, path, __SYSCALL_LL_O(length)); | 6 | 	return syscall(SYS_truncate, path, __SYSCALL_LL_O(length)); |
| 7 | } | 7 | } |
| 8 | |||
| 9 | weak_alias(truncate, truncate64); |
lib/libc/musl/src/unistd/x32/lseek.c-1| ... | @@ -12,4 +12,3 @@ off_t __lseek(int fd, off_t offset, int whence) | ... | @@ -12,4 +12,3 @@ off_t __lseek(int fd, off_t offset, int whence) |
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | weak_alias(__lseek, lseek); | 14 | weak_alias(__lseek, lseek); |
| 15 | weak_alias(__lseek, lseek64); |
src/musl.zig+2-3| ... | @@ -1466,6 +1466,7 @@ const src_files = [_][]const u8{ | ... | @@ -1466,6 +1466,7 @@ const src_files = [_][]const u8{ |
| 1466 | "musl/src/prng/seed48.c", | 1466 | "musl/src/prng/seed48.c", |
| 1467 | "musl/src/prng/srand48.c", | 1467 | "musl/src/prng/srand48.c", |
| 1468 | "musl/src/process/_Fork.c", | 1468 | "musl/src/process/_Fork.c", |
| 1469 | "musl/src/process/aarch64/vfork.s", | ||
| 1469 | "musl/src/process/arm/vfork.s", | 1470 | "musl/src/process/arm/vfork.s", |
| 1470 | "musl/src/process/execl.c", | 1471 | "musl/src/process/execl.c", |
| 1471 | "musl/src/process/execle.c", | 1472 | "musl/src/process/execle.c", |
| ... | @@ -1496,6 +1497,7 @@ const src_files = [_][]const u8{ | ... | @@ -1496,6 +1497,7 @@ const src_files = [_][]const u8{ |
| 1496 | "musl/src/process/posix_spawnattr_setsigdefault.c", | 1497 | "musl/src/process/posix_spawnattr_setsigdefault.c", |
| 1497 | "musl/src/process/posix_spawnattr_setsigmask.c", | 1498 | "musl/src/process/posix_spawnattr_setsigmask.c", |
| 1498 | "musl/src/process/posix_spawnp.c", | 1499 | "musl/src/process/posix_spawnp.c", |
| 1500 | "musl/src/process/riscv64/vfork.s", | ||
| 1499 | "musl/src/process/s390x/vfork.s", | 1501 | "musl/src/process/s390x/vfork.s", |
| 1500 | "musl/src/process/sh/vfork.s", | 1502 | "musl/src/process/sh/vfork.s", |
| 1501 | "musl/src/process/system.c", | 1503 | "musl/src/process/system.c", |
| ... | @@ -1579,11 +1581,8 @@ const src_files = [_][]const u8{ | ... | @@ -1579,11 +1581,8 @@ const src_files = [_][]const u8{ |
| 1579 | "musl/src/signal/m68k/sigsetjmp.s", | 1581 | "musl/src/signal/m68k/sigsetjmp.s", |
| 1580 | "musl/src/signal/microblaze/restore.s", | 1582 | "musl/src/signal/microblaze/restore.s", |
| 1581 | "musl/src/signal/microblaze/sigsetjmp.s", | 1583 | "musl/src/signal/microblaze/sigsetjmp.s", |
| 1582 | "musl/src/signal/mips/restore.s", | ||
| 1583 | "musl/src/signal/mips/sigsetjmp.s", | 1584 | "musl/src/signal/mips/sigsetjmp.s", |
| 1584 | "musl/src/signal/mips64/restore.s", | ||
| 1585 | "musl/src/signal/mips64/sigsetjmp.s", | 1585 | "musl/src/signal/mips64/sigsetjmp.s", |
| 1586 | "musl/src/signal/mipsn32/restore.s", | ||
| 1587 | "musl/src/signal/mipsn32/sigsetjmp.s", | 1586 | "musl/src/signal/mipsn32/sigsetjmp.s", |
| 1588 | "musl/src/signal/or1k/sigsetjmp.s", | 1587 | "musl/src/signal/or1k/sigsetjmp.s", |
| 1589 | "musl/src/signal/powerpc/restore.s", | 1588 | "musl/src/signal/powerpc/restore.s", |