| author | |
| committer | |
| log | 6dc2236054dfcf911ce848f67a4078740a90783a |
| tree | 37deb296f0fafbc258ea130045e23d224a3f499a |
| parent | a2ec77041bc4a58d922cd3f8db923b7272b1f8f7 |
188 files changed, 2522 insertions(+), 784 deletions(-)
lib/libc/include/aarch64-linux-musl/bits/alltypes.h+6| ... | @@ -365,6 +365,12 @@ struct iovec { void *iov_base; size_t iov_len; }; | ... | @@ -365,6 +365,12 @@ struct iovec { void *iov_base; size_t iov_len; }; |
| 365 | #endif | 365 | #endif |
| 366 | 366 | ||
| 367 | 367 | ||
| 368 | #if defined(__NEED_struct_winsize) && !defined(__DEFINED_struct_winsize) | ||
| 369 | struct winsize { unsigned short ws_row, ws_col, ws_xpixel, ws_ypixel; }; | ||
| 370 | #define __DEFINED_struct_winsize | ||
| 371 | #endif | ||
| 372 | |||
| 373 | |||
| 368 | #if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t) | 374 | #if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t) |
| 369 | typedef unsigned socklen_t; | 375 | typedef unsigned socklen_t; |
| 370 | #define __DEFINED_socklen_t | 376 | #define __DEFINED_socklen_t |
lib/libc/include/aarch64-linux-musl/bits/hwcap.h+11-1| ... | @@ -37,4 +37,14 @@ | ... | @@ -37,4 +37,14 @@ |
| 37 | #define HWCAP2_SVEPMULL		(1 << 3) | 37 | #define HWCAP2_SVEPMULL		(1 << 3) |
| 38 | #define HWCAP2_SVEBITPERM	(1 << 4) | 38 | #define HWCAP2_SVEBITPERM	(1 << 4) |
| 39 | #define HWCAP2_SVESHA3		(1 << 5) | 39 | #define HWCAP2_SVESHA3		(1 << 5) |
| 40 | #define HWCAP2_SVESM4		(1 << 6) | ||
| \ No newline at end of file | |||
| 40 | #define HWCAP2_SVESM4		(1 << 6) | ||
| 41 | #define HWCAP2_FLAGM2		(1 << 7) | ||
| 42 | #define HWCAP2_FRINT		(1 << 8) | ||
| 43 | #define HWCAP2_SVEI8MM		(1 << 9) | ||
| 44 | #define HWCAP2_SVEF32MM		(1 << 10) | ||
| 45 | #define HWCAP2_SVEF64MM		(1 << 11) | ||
| 46 | #define HWCAP2_SVEBF16		(1 << 12) | ||
| 47 | #define HWCAP2_I8MM		(1 << 13) | ||
| 48 | #define HWCAP2_BF16		(1 << 14) | ||
| 49 | #define HWCAP2_DGH		(1 << 15) | ||
| 50 | #define HWCAP2_RNG		(1 << 16) | ||
| \ No newline at end of file | |||
lib/libc/include/aarch64-linux-musl/bits/signal.h+2-2| ... | @@ -11,7 +11,7 @@ typedef unsigned long greg_t; | ... | @@ -11,7 +11,7 @@ typedef unsigned long greg_t; |
| 11 | typedef unsigned long gregset_t[34]; | 11 | typedef unsigned long gregset_t[34]; |
| 12 | 12 | ||
| 13 | typedef struct { | 13 | typedef struct { |
| 14 | 	long double vregs[32]; | 14 | 	__uint128_t vregs[32]; |
| 15 | 	unsigned int fpsr; | 15 | 	unsigned int fpsr; |
| 16 | 	unsigned int fpcr; | 16 | 	unsigned int fpcr; |
| 17 | } fpregset_t; | 17 | } fpregset_t; |
| ... | @@ -34,7 +34,7 @@ struct fpsimd_context { | ... | @@ -34,7 +34,7 @@ struct fpsimd_context { |
| 34 | 	struct _aarch64_ctx head; | 34 | 	struct _aarch64_ctx head; |
| 35 | 	unsigned int fpsr; | 35 | 	unsigned int fpsr; |
| 36 | 	unsigned int fpcr; | 36 | 	unsigned int fpcr; |
| 37 | 	long double vregs[32]; | 37 | 	__uint128_t vregs[32]; |
| 38 | }; | 38 | }; |
| 39 | struct esr_context { | 39 | struct esr_context { |
| 40 | 	struct _aarch64_ctx head; | 40 | 	struct _aarch64_ctx head; |
lib/libc/include/aarch64-linux-musl/bits/syscall.h+9-1| ... | @@ -289,6 +289,10 @@ | ... | @@ -289,6 +289,10 @@ |
| 289 | #define __NR_fspick		433 | 289 | #define __NR_fspick		433 |
| 290 | #define __NR_pidfd_open		434 | 290 | #define __NR_pidfd_open		434 |
| 291 | #define __NR_clone3		435 | 291 | #define __NR_clone3		435 |
| 292 | #define __NR_close_range	436 | ||
| 293 | #define __NR_openat2		437 | ||
| 294 | #define __NR_pidfd_getfd	438 | ||
| 295 | #define __NR_faccessat2		439 | ||
| 292 | 296 | ||
| 293 | #define SYS_io_setup 0 | 297 | #define SYS_io_setup 0 |
| 294 | #define SYS_io_destroy 1 | 298 | #define SYS_io_destroy 1 |
| ... | @@ -580,4 +584,8 @@ | ... | @@ -580,4 +584,8 @@ |
| 580 | #define SYS_fsmount		432 | 584 | #define SYS_fsmount		432 |
| 581 | #define SYS_fspick		433 | 585 | #define SYS_fspick		433 |
| 582 | #define SYS_pidfd_open		434 | 586 | #define SYS_pidfd_open		434 |
| 583 | #define SYS_clone3		435 | ||
| \ No newline at end of file | |||
| 587 | #define SYS_clone3		435 | ||
| 588 | #define SYS_close_range	436 | ||
| 589 | #define SYS_openat2		437 | ||
| 590 | #define SYS_pidfd_getfd	438 | ||
| 591 | #define SYS_faccessat2		439 | ||
| \ No newline at end of file | |||
lib/libc/include/aarch64-linux-musl/bits/user.h+1-1| ... | @@ -6,7 +6,7 @@ struct user_regs_struct { | ... | @@ -6,7 +6,7 @@ struct user_regs_struct { |
| 6 | }; | 6 | }; |
| 7 | 7 | ||
| 8 | struct user_fpsimd_struct { | 8 | struct user_fpsimd_struct { |
| 9 | 	long double vregs[32]; | 9 | 	__uint128_t vregs[32]; |
| 10 | 	unsigned int fpsr; | 10 | 	unsigned int fpsr; |
| 11 | 	unsigned int fpcr; | 11 | 	unsigned int fpcr; |
| 12 | }; | 12 | }; |
lib/libc/include/arm-linux-musl/bits/alltypes.h+6| ... | @@ -350,6 +350,12 @@ struct iovec { void *iov_base; size_t iov_len; }; | ... | @@ -350,6 +350,12 @@ struct iovec { void *iov_base; size_t iov_len; }; |
| 350 | #endif | 350 | #endif |
| 351 | 351 | ||
| 352 | 352 | ||
| 353 | #if defined(__NEED_struct_winsize) && !defined(__DEFINED_struct_winsize) | ||
| 354 | struct winsize { unsigned short ws_row, ws_col, ws_xpixel, ws_ypixel; }; | ||
| 355 | #define __DEFINED_struct_winsize | ||
| 356 | #endif | ||
| 357 | |||
| 358 | |||
| 353 | #if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t) | 359 | #if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t) |
| 354 | typedef unsigned socklen_t; | 360 | typedef unsigned socklen_t; |
| 355 | #define __DEFINED_socklen_t | 361 | #define __DEFINED_socklen_t |
lib/libc/include/arm-linux-musl/bits/syscall.h+9-1| ... | @@ -389,6 +389,10 @@ | ... | @@ -389,6 +389,10 @@ |
| 389 | #define __NR_fspick		433 | 389 | #define __NR_fspick		433 |
| 390 | #define __NR_pidfd_open		434 | 390 | #define __NR_pidfd_open		434 |
| 391 | #define __NR_clone3		435 | 391 | #define __NR_clone3		435 |
| 392 | #define __NR_close_range	436 | ||
| 393 | #define __NR_openat2		437 | ||
| 394 | #define __NR_pidfd_getfd	438 | ||
| 395 | #define __NR_faccessat2		439 | ||
| 392 | 396 | ||
| 393 | #define __ARM_NR_breakpoint	0x0f0001 | 397 | #define __ARM_NR_breakpoint	0x0f0001 |
| 394 | #define __ARM_NR_cacheflush	0x0f0002 | 398 | #define __ARM_NR_cacheflush	0x0f0002 |
| ... | @@ -787,4 +791,8 @@ | ... | @@ -787,4 +791,8 @@ |
| 787 | #define SYS_fsmount		432 | 791 | #define SYS_fsmount		432 |
| 788 | #define SYS_fspick		433 | 792 | #define SYS_fspick		433 |
| 789 | #define SYS_pidfd_open		434 | 793 | #define SYS_pidfd_open		434 |
| 790 | #define SYS_clone3		435 | ||
| \ No newline at end of file | |||
| 794 | #define SYS_clone3		435 | ||
| 795 | #define SYS_close_range	436 | ||
| 796 | #define SYS_openat2		437 | ||
| 797 | #define SYS_pidfd_getfd	438 | ||
| 798 | #define SYS_faccessat2		439 | ||
| \ No newline at end of file | |||
lib/libc/include/generic-musl/bits/fcntl.h created+46| ... | @@ -0,0 +1,46 @@ | ||
| 1 | #define O_CREAT 0100 | ||
| 2 | #define O_EXCL 0200 | ||
| 3 | #define O_NOCTTY 0400 | ||
| 4 | #define O_TRUNC 01000 | ||
| 5 | #define O_APPEND 02000 | ||
| 6 | #define O_NONBLOCK 04000 | ||
| 7 | #define O_DSYNC 010000 | ||
| 8 | #define O_SYNC 04010000 | ||
| 9 | #define O_RSYNC 04010000 | ||
| 10 | #define O_DIRECTORY 0200000 | ||
| 11 | #define O_NOFOLLOW 0400000 | ||
| 12 | #define O_CLOEXEC 02000000 | ||
| 13 | |||
| 14 | #define O_ASYNC 020000 | ||
| 15 | #define O_DIRECT 040000 | ||
| 16 | #define O_LARGEFILE 0100000 | ||
| 17 | #define O_NOATIME 01000000 | ||
| 18 | #define O_PATH 010000000 | ||
| 19 | #define O_TMPFILE 020200000 | ||
| 20 | #define O_NDELAY O_NONBLOCK | ||
| 21 | |||
| 22 | #define F_DUPFD 0 | ||
| 23 | #define F_GETFD 1 | ||
| 24 | #define F_SETFD 2 | ||
| 25 | #define F_GETFL 3 | ||
| 26 | #define F_SETFL 4 | ||
| 27 | |||
| 28 | #define F_SETOWN 8 | ||
| 29 | #define F_GETOWN 9 | ||
| 30 | #define F_SETSIG 10 | ||
| 31 | #define F_GETSIG 11 | ||
| 32 | |||
| 33 | #if __LONG_MAX == 0x7fffffffL | ||
| 34 | #define F_GETLK 12 | ||
| 35 | #define F_SETLK 13 | ||
| 36 | #define F_SETLKW 14 | ||
| 37 | #else | ||
| 38 | #define F_GETLK 5 | ||
| 39 | #define F_SETLK 6 | ||
| 40 | #define F_SETLKW 7 | ||
| 41 | #endif | ||
| 42 | |||
| 43 | #define F_SETOWN_EX 15 | ||
| 44 | #define F_GETOWN_EX 16 | ||
| 45 | |||
| 46 | #define F_GETOWNER_UIDS 17 | ||
| \ No newline at end of file | |||
lib/libc/include/generic-musl/elf.h+2| ... | @@ -603,6 +603,7 @@ typedef struct { | ... | @@ -603,6 +603,7 @@ typedef struct { |
| 603 | #define PT_GNU_EH_FRAME	0x6474e550 | 603 | #define PT_GNU_EH_FRAME	0x6474e550 |
| 604 | #define PT_GNU_STACK	0x6474e551 | 604 | #define PT_GNU_STACK	0x6474e551 |
| 605 | #define PT_GNU_RELRO	0x6474e552 | 605 | #define PT_GNU_RELRO	0x6474e552 |
| 606 | #define PT_GNU_PROPERTY	0x6474e553 | ||
| 606 | #define PT_LOSUNW	0x6ffffffa | 607 | #define PT_LOSUNW	0x6ffffffa |
| 607 | #define PT_SUNWBSS	0x6ffffffa | 608 | #define PT_SUNWBSS	0x6ffffffa |
| 608 | #define PT_SUNWSTACK	0x6ffffffb | 609 | #define PT_SUNWSTACK	0x6ffffffb |
| ... | @@ -1085,6 +1086,7 @@ typedef struct { | ... | @@ -1085,6 +1086,7 @@ typedef struct { |
| 1085 | 1086 | ||
| 1086 | #define NT_GNU_BUILD_ID	3 | 1087 | #define NT_GNU_BUILD_ID	3 |
| 1087 | #define NT_GNU_GOLD_VERSION	4 | 1088 | #define NT_GNU_GOLD_VERSION	4 |
| 1089 | #define NT_GNU_PROPERTY_TYPE_0	5 | ||
| 1088 | 1090 | ||
| 1089 | 1091 | ||
| 1090 | 1092 |
lib/libc/include/generic-musl/netinet/if_ether.h+1| ... | @@ -59,6 +59,7 @@ | ... | @@ -59,6 +59,7 @@ |
| 59 | #define ETH_P_PREAUTH	0x88C7 | 59 | #define ETH_P_PREAUTH	0x88C7 |
| 60 | #define ETH_P_TIPC	0x88CA | 60 | #define ETH_P_TIPC	0x88CA |
| 61 | #define ETH_P_LLDP	0x88CC | 61 | #define ETH_P_LLDP	0x88CC |
| 62 | #define ETH_P_MRP	0x88E3 | ||
| 62 | #define ETH_P_MACSEC	0x88E5 | 63 | #define ETH_P_MACSEC	0x88E5 |
| 63 | #define ETH_P_8021AH	0x88E7 | 64 | #define ETH_P_8021AH	0x88E7 |
| 64 | #define ETH_P_MVRP	0x88F5 | 65 | #define ETH_P_MVRP	0x88F5 |
lib/libc/include/generic-musl/netinet/in.h+4-1| ... | @@ -101,8 +101,10 @@ uint16_t ntohs(uint16_t); | ... | @@ -101,8 +101,10 @@ uint16_t ntohs(uint16_t); |
| 101 | #define IPPROTO_MH 135 | 101 | #define IPPROTO_MH 135 |
| 102 | #define IPPROTO_UDPLITE 136 | 102 | #define IPPROTO_UDPLITE 136 |
| 103 | #define IPPROTO_MPLS 137 | 103 | #define IPPROTO_MPLS 137 |
| 104 | #define IPPROTO_ETHERNET 143 | ||
| 104 | #define IPPROTO_RAW 255 | 105 | #define IPPROTO_RAW 255 |
| 105 | #define IPPROTO_MAX 256 | 106 | #define IPPROTO_MPTCP 262 |
| 107 | #define IPPROTO_MAX 263 | ||
| 106 | 108 | ||
| 107 | #define IN6_IS_ADDR_UNSPECIFIED(a) \ | 109 | #define IN6_IS_ADDR_UNSPECIFIED(a) \ |
| 108 | (((uint32_t *) (a))[0] == 0 && ((uint32_t *) (a))[1] == 0 && \ | 110 | (((uint32_t *) (a))[0] == 0 && ((uint32_t *) (a))[1] == 0 && \ |
| ... | @@ -200,6 +202,7 @@ uint16_t ntohs(uint16_t); | ... | @@ -200,6 +202,7 @@ uint16_t ntohs(uint16_t); |
| 200 | #define IP_CHECKSUM 23 | 202 | #define IP_CHECKSUM 23 |
| 201 | #define IP_BIND_ADDRESS_NO_PORT 24 | 203 | #define IP_BIND_ADDRESS_NO_PORT 24 |
| 202 | #define IP_RECVFRAGSIZE 25 | 204 | #define IP_RECVFRAGSIZE 25 |
| 205 | #define IP_RECVERR_RFC4884 26 | ||
| 203 | #define IP_MULTICAST_IF 32 | 206 | #define IP_MULTICAST_IF 32 |
| 204 | #define IP_MULTICAST_TTL 33 | 207 | #define IP_MULTICAST_TTL 33 |
| 205 | #define IP_MULTICAST_LOOP 34 | 208 | #define IP_MULTICAST_LOOP 34 |
lib/libc/include/generic-musl/netinet/tcp.h+15-3| ... | @@ -78,6 +78,8 @@ enum { | ... | @@ -78,6 +78,8 @@ enum { |
| 78 | 	TCP_NLA_DSACK_DUPS, | 78 | 	TCP_NLA_DSACK_DUPS, |
| 79 | 	TCP_NLA_REORD_SEEN, | 79 | 	TCP_NLA_REORD_SEEN, |
| 80 | 	TCP_NLA_SRTT, | 80 | 	TCP_NLA_SRTT, |
| 81 | 	TCP_NLA_TIMEOUT_REHASH, | ||
| 82 | 	TCP_NLA_BYTES_NOTSENT, | ||
| 81 | }; | 83 | }; |
| 82 | 84 | ||
| 83 | #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) | 85 | #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) |
| ... | @@ -181,6 +183,13 @@ struct tcphdr { | ... | @@ -181,6 +183,13 @@ struct tcphdr { |
| 181 | #define TCP_CA_Recovery		3 | 183 | #define TCP_CA_Recovery		3 |
| 182 | #define TCP_CA_Loss		4 | 184 | #define TCP_CA_Loss		4 |
| 183 | 185 | ||
| 186 | enum tcp_fastopen_client_fail { | ||
| 187 | 	TFO_STATUS_UNSPEC, | ||
| 188 | 	TFO_COOKIE_UNAVAILABLE, | ||
| 189 | 	TFO_DATA_NOT_ACKED, | ||
| 190 | 	TFO_SYN_RETRANSMITTED, | ||
| 191 | }; | ||
| 192 | |||
| 184 | struct tcp_info { | 193 | struct tcp_info { |
| 185 | 	uint8_t tcpi_state; | 194 | 	uint8_t tcpi_state; |
| 186 | 	uint8_t tcpi_ca_state; | 195 | 	uint8_t tcpi_ca_state; |
| ... | @@ -189,7 +198,7 @@ struct tcp_info { | ... | @@ -189,7 +198,7 @@ struct tcp_info { |
| 189 | 	uint8_t tcpi_backoff; | 198 | 	uint8_t tcpi_backoff; |
| 190 | 	uint8_t tcpi_options; | 199 | 	uint8_t tcpi_options; |
| 191 | 	uint8_t tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4; | 200 | 	uint8_t tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4; |
| 192 | 	uint8_t tcpi_delivery_rate_app_limited : 1; | 201 | 	uint8_t tcpi_delivery_rate_app_limited : 1, tcpi_fastopen_client_fail : 2; |
| 193 | 	uint32_t tcpi_rto; | 202 | 	uint32_t tcpi_rto; |
| 194 | 	uint32_t tcpi_ato; | 203 | 	uint32_t tcpi_ato; |
| 195 | 	uint32_t tcpi_snd_mss; | 204 | 	uint32_t tcpi_snd_mss; |
| ... | @@ -240,14 +249,15 @@ struct tcp_info { | ... | @@ -240,14 +249,15 @@ struct tcp_info { |
| 240 | 249 | ||
| 241 | #define TCP_MD5SIG_MAXKEYLEN 80 | 250 | #define TCP_MD5SIG_MAXKEYLEN 80 |
| 242 | 251 | ||
| 243 | #define TCP_MD5SIG_FLAG_PREFIX 1 | 252 | #define TCP_MD5SIG_FLAG_PREFIX 0x1 |
| 253 | #define TCP_MD5SIG_FLAG_IFINDEX 0x2 | ||
| 244 | 254 | ||
| 245 | struct tcp_md5sig { | 255 | struct tcp_md5sig { |
| 246 | 	struct sockaddr_storage tcpm_addr; | 256 | 	struct sockaddr_storage tcpm_addr; |
| 247 | 	uint8_t tcpm_flags; | 257 | 	uint8_t tcpm_flags; |
| 248 | 	uint8_t tcpm_prefixlen; | 258 | 	uint8_t tcpm_prefixlen; |
| 249 | 	uint16_t tcpm_keylen; | 259 | 	uint16_t tcpm_keylen; |
| 250 | 	uint32_t __tcpm_pad; | 260 | 	int tcpm_ifindex; |
| 251 | 	uint8_t tcpm_key[TCP_MD5SIG_MAXKEYLEN]; | 261 | 	uint8_t tcpm_key[TCP_MD5SIG_MAXKEYLEN]; |
| 252 | }; | 262 | }; |
| 253 | 263 | ||
| ... | @@ -275,6 +285,8 @@ struct tcp_zerocopy_receive { | ... | @@ -275,6 +285,8 @@ struct tcp_zerocopy_receive { |
| 275 | 	uint64_t address; | 285 | 	uint64_t address; |
| 276 | 	uint32_t length; | 286 | 	uint32_t length; |
| 277 | 	uint32_t recv_skip_hint; | 287 | 	uint32_t recv_skip_hint; |
| 288 | 	uint32_t inq; | ||
| 289 | 	int32_t err; | ||
| 278 | }; | 290 | }; |
| 279 | 291 | ||
| 280 | #endif | 292 | #endif |
lib/libc/include/generic-musl/netinet/udp.h+1| ... | @@ -35,6 +35,7 @@ struct udphdr { | ... | @@ -35,6 +35,7 @@ struct udphdr { |
| 35 | #define UDP_ENCAP_GTP0		4 | 35 | #define UDP_ENCAP_GTP0		4 |
| 36 | #define UDP_ENCAP_GTP1U		5 | 36 | #define UDP_ENCAP_GTP1U		5 |
| 37 | #define UDP_ENCAP_RXRPC		6 | 37 | #define UDP_ENCAP_RXRPC		6 |
| 38 | #define TCP_ENCAP_ESPINTCP	7 | ||
| 38 | 39 | ||
| 39 | #define SOL_UDP 17 | 40 | #define SOL_UDP 17 |
| 40 | 41 |
lib/libc/include/generic-musl/sched.h+1| ... | @@ -49,6 +49,7 @@ int sched_yield(void); | ... | @@ -49,6 +49,7 @@ int sched_yield(void); |
| 49 | 49 | ||
| 50 | #ifdef _GNU_SOURCE | 50 | #ifdef _GNU_SOURCE |
| 51 | #define CSIGNAL		0x000000ff | 51 | #define CSIGNAL		0x000000ff |
| 52 | #define CLONE_NEWTIME	0x00000080 | ||
| 52 | #define CLONE_VM	0x00000100 | 53 | #define CLONE_VM	0x00000100 |
| 53 | #define CLONE_FS	0x00000200 | 54 | #define CLONE_FS	0x00000200 |
| 54 | #define CLONE_FILES	0x00000400 | 55 | #define CLONE_FILES	0x00000400 |
lib/libc/include/generic-musl/signal.h+13-3| ... | @@ -180,14 +180,24 @@ struct sigevent { | ... | @@ -180,14 +180,24 @@ struct sigevent { |
| 180 | 	union sigval sigev_value; | 180 | 	union sigval sigev_value; |
| 181 | 	int sigev_signo; | 181 | 	int sigev_signo; |
| 182 | 	int sigev_notify; | 182 | 	int sigev_notify; |
| 183 | 	void (*sigev_notify_function)(union sigval); | 183 | 	union { |
| 184 | 	pthread_attr_t *sigev_notify_attributes; | 184 | 		char __pad[64 - 2*sizeof(int) - sizeof(union sigval)]; |
| 185 | 	char __pad[56-3*sizeof(long)]; | 185 | 		pid_t sigev_notify_thread_id; |
| 186 | 		struct { | ||
| 187 | 			void (*sigev_notify_function)(union sigval); | ||
| 188 | 			pthread_attr_t *sigev_notify_attributes; | ||
| 189 | 		} __sev_thread; | ||
| 190 | 	} __sev_fields; | ||
| 186 | }; | 191 | }; |
| 187 | 192 | ||
| 193 | #define sigev_notify_thread_id __sev_fields.sigev_notify_thread_id | ||
| 194 | #define sigev_notify_function __sev_fields.__sev_thread.sigev_notify_function | ||
| 195 | #define sigev_notify_attributes __sev_fields.__sev_thread.sigev_notify_attributes | ||
| 196 | |||
| 188 | #define SIGEV_SIGNAL 0 | 197 | #define SIGEV_SIGNAL 0 |
| 189 | #define SIGEV_NONE 1 | 198 | #define SIGEV_NONE 1 |
| 190 | #define SIGEV_THREAD 2 | 199 | #define SIGEV_THREAD 2 |
| 200 | #define SIGEV_THREAD_ID 4 | ||
| 191 | 201 | ||
| 192 | int __libc_current_sigrtmin(void); | 202 | int __libc_current_sigrtmin(void); |
| 193 | int __libc_current_sigrtmax(void); | 203 | int __libc_current_sigrtmax(void); |
lib/libc/include/generic-musl/stdlib.h+1| ... | @@ -145,6 +145,7 @@ int getloadavg(double *, int); | ... | @@ -145,6 +145,7 @@ int getloadavg(double *, int); |
| 145 | int clearenv(void); | 145 | int clearenv(void); |
| 146 | #define WCOREDUMP(s) ((s) & 0x80) | 146 | #define WCOREDUMP(s) ((s) & 0x80) |
| 147 | #define WIFCONTINUED(s) ((s) == 0xffff) | 147 | #define WIFCONTINUED(s) ((s) == 0xffff) |
| 148 | void *reallocarray (void *, size_t, size_t); | ||
| 148 | #endif | 149 | #endif |
| 149 | 150 | ||
| 150 | #ifdef _GNU_SOURCE | 151 | #ifdef _GNU_SOURCE |
lib/libc/include/generic-musl/sys/fanotify.h+7-1| ... | @@ -55,8 +55,9 @@ struct fanotify_response { | ... | @@ -55,8 +55,9 @@ struct fanotify_response { |
| 55 | #define FAN_OPEN_PERM 0x10000 | 55 | #define FAN_OPEN_PERM 0x10000 |
| 56 | #define FAN_ACCESS_PERM 0x20000 | 56 | #define FAN_ACCESS_PERM 0x20000 |
| 57 | #define FAN_OPEN_EXEC_PERM 0x40000 | 57 | #define FAN_OPEN_EXEC_PERM 0x40000 |
| 58 | #define FAN_ONDIR 0x40000000 | 58 | #define FAN_DIR_MODIFY 0x00080000 |
| 59 | #define FAN_EVENT_ON_CHILD 0x08000000 | 59 | #define FAN_EVENT_ON_CHILD 0x08000000 |
| 60 | #define FAN_ONDIR 0x40000000 | ||
| 60 | #define FAN_CLOSE (FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE) | 61 | #define FAN_CLOSE (FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE) |
| 61 | #define FAN_MOVE (FAN_MOVED_FROM | FAN_MOVED_TO) | 62 | #define FAN_MOVE (FAN_MOVED_FROM | FAN_MOVED_TO) |
| 62 | #define FAN_CLOEXEC 0x01 | 63 | #define FAN_CLOEXEC 0x01 |
| ... | @@ -70,6 +71,9 @@ struct fanotify_response { | ... | @@ -70,6 +71,9 @@ struct fanotify_response { |
| 70 | #define FAN_ENABLE_AUDIT 0x40 | 71 | #define FAN_ENABLE_AUDIT 0x40 |
| 71 | #define FAN_REPORT_TID 0x100 | 72 | #define FAN_REPORT_TID 0x100 |
| 72 | #define FAN_REPORT_FID 0x200 | 73 | #define FAN_REPORT_FID 0x200 |
| 74 | #define FAN_REPORT_DIR_FID 0x00000400 | ||
| 75 | #define FAN_REPORT_NAME 0x00000800 | ||
| 76 | #define FAN_REPORT_DFID_NAME (FAN_REPORT_DIR_FID | FAN_REPORT_NAME) | ||
| 73 | #define FAN_ALL_INIT_FLAGS (FAN_CLOEXEC | FAN_NONBLOCK | FAN_ALL_CLASS_BITS | FAN_UNLIMITED_QUEUE | FAN_UNLIMITED_MARKS) | 77 | #define FAN_ALL_INIT_FLAGS (FAN_CLOEXEC | FAN_NONBLOCK | FAN_ALL_CLASS_BITS | FAN_UNLIMITED_QUEUE | FAN_UNLIMITED_MARKS) |
| 74 | #define FAN_MARK_ADD 0x01 | 78 | #define FAN_MARK_ADD 0x01 |
| 75 | #define FAN_MARK_REMOVE 0x02 | 79 | #define FAN_MARK_REMOVE 0x02 |
| ... | @@ -88,6 +92,8 @@ struct fanotify_response { | ... | @@ -88,6 +92,8 @@ struct fanotify_response { |
| 88 | #define FAN_ALL_OUTGOING_EVENTS (FAN_ALL_EVENTS | FAN_ALL_PERM_EVENTS | FAN_Q_OVERFLOW) | 92 | #define FAN_ALL_OUTGOING_EVENTS (FAN_ALL_EVENTS | FAN_ALL_PERM_EVENTS | FAN_Q_OVERFLOW) |
| 89 | #define FANOTIFY_METADATA_VERSION 3 | 93 | #define FANOTIFY_METADATA_VERSION 3 |
| 90 | #define FAN_EVENT_INFO_TYPE_FID 1 | 94 | #define FAN_EVENT_INFO_TYPE_FID 1 |
| 95 | #define FAN_EVENT_INFO_TYPE_DFID_NAME 2 | ||
| 96 | #define FAN_EVENT_INFO_TYPE_DFID 3 | ||
| 91 | #define FAN_ALLOW 0x01 | 97 | #define FAN_ALLOW 0x01 |
| 92 | #define FAN_DENY 0x02 | 98 | #define FAN_DENY 0x02 |
| 93 | #define FAN_AUDIT 0x10 | 99 | #define FAN_AUDIT 0x10 |
lib/libc/include/generic-musl/sys/ioctl.h+2-7| ... | @@ -4,6 +4,8 @@ | ... | @@ -4,6 +4,8 @@ |
| 4 | extern "C" { | 4 | extern "C" { |
| 5 | #endif | 5 | #endif |
| 6 | 6 | ||
| 7 | #define __NEED_struct_winsize | ||
| 8 | |||
| 7 | #include <bits/alltypes.h> | 9 | #include <bits/alltypes.h> |
| 8 | #include <bits/ioctl.h> | 10 | #include <bits/ioctl.h> |
| 9 | 11 | ||
| ... | @@ -47,13 +49,6 @@ extern "C" { | ... | @@ -47,13 +49,6 @@ extern "C" { |
| 47 | 49 | ||
| 48 | #define TIOCSER_TEMT 1 | 50 | #define TIOCSER_TEMT 1 |
| 49 | 51 | ||
| 50 | struct winsize { | ||
| 51 | 	unsigned short ws_row; | ||
| 52 | 	unsigned short ws_col; | ||
| 53 | 	unsigned short ws_xpixel; | ||
| 54 | 	unsigned short ws_ypixel; | ||
| 55 | }; | ||
| 56 | |||
| 57 | #define SIOCADDRT 0x890B | 52 | #define SIOCADDRT 0x890B |
| 58 | #define SIOCDELRT 0x890C | 53 | #define SIOCDELRT 0x890C |
| 59 | #define SIOCRTMSG 0x890D | 54 | #define SIOCRTMSG 0x890D |
lib/libc/include/generic-musl/sys/mman.h+1| ... | @@ -101,6 +101,7 @@ extern "C" { | ... | @@ -101,6 +101,7 @@ extern "C" { |
| 101 | #ifdef _GNU_SOURCE | 101 | #ifdef _GNU_SOURCE |
| 102 | #define MREMAP_MAYMOVE 1 | 102 | #define MREMAP_MAYMOVE 1 |
| 103 | #define MREMAP_FIXED 2 | 103 | #define MREMAP_FIXED 2 |
| 104 | #define MREMAP_DONTUNMAP 4 | ||
| 104 | 105 | ||
| 105 | #define MLOCK_ONFAULT 0x01 | 106 | #define MLOCK_ONFAULT 0x01 |
| 106 | 107 |
lib/libc/include/generic-musl/sys/personality.h+3| ... | @@ -5,7 +5,9 @@ | ... | @@ -5,7 +5,9 @@ |
| 5 | extern "C" { | 5 | extern "C" { |
| 6 | #endif | 6 | #endif |
| 7 | 7 | ||
| 8 | #define UNAME26 0x0020000 | ||
| 8 | #define ADDR_NO_RANDOMIZE 0x0040000 | 9 | #define ADDR_NO_RANDOMIZE 0x0040000 |
| 10 | #define FDPIC_FUNCPTRS 0x0080000 | ||
| 9 | #define MMAP_PAGE_ZERO 0x0100000 | 11 | #define MMAP_PAGE_ZERO 0x0100000 |
| 10 | #define ADDR_COMPAT_LAYOUT 0x0200000 | 12 | #define ADDR_COMPAT_LAYOUT 0x0200000 |
| 11 | #define READ_IMPLIES_EXEC 0x0400000 | 13 | #define READ_IMPLIES_EXEC 0x0400000 |
| ... | @@ -17,6 +19,7 @@ extern "C" { | ... | @@ -17,6 +19,7 @@ extern "C" { |
| 17 | 19 | ||
| 18 | #define PER_LINUX 0 | 20 | #define PER_LINUX 0 |
| 19 | #define PER_LINUX_32BIT ADDR_LIMIT_32BIT | 21 | #define PER_LINUX_32BIT ADDR_LIMIT_32BIT |
| 22 | #define PER_LINUX_FDPIC FDPIC_FUNCPTRS | ||
| 20 | #define PER_SVR4 (1 | STICKY_TIMEOUTS | MMAP_PAGE_ZERO) | 23 | #define PER_SVR4 (1 | STICKY_TIMEOUTS | MMAP_PAGE_ZERO) |
| 21 | #define PER_SVR3 (2 | STICKY_TIMEOUTS | SHORT_INODE) | 24 | #define PER_SVR3 (2 | STICKY_TIMEOUTS | SHORT_INODE) |
| 22 | #define PER_SCOSVR3 (3 | STICKY_TIMEOUTS | WHOLE_SECONDS | SHORT_INODE) | 25 | #define PER_SCOSVR3 (3 | STICKY_TIMEOUTS | WHOLE_SECONDS | SHORT_INODE) |
lib/libc/include/generic-musl/sys/prctl.h+3| ... | @@ -158,6 +158,9 @@ struct prctl_mm_map { | ... | @@ -158,6 +158,9 @@ struct prctl_mm_map { |
| 158 | #define PR_GET_TAGGED_ADDR_CTRL 56 | 158 | #define PR_GET_TAGGED_ADDR_CTRL 56 |
| 159 | #define PR_TAGGED_ADDR_ENABLE (1UL << 0) | 159 | #define PR_TAGGED_ADDR_ENABLE (1UL << 0) |
| 160 | 160 | ||
| 161 | #define PR_SET_IO_FLUSHER 57 | ||
| 162 | #define PR_GET_IO_FLUSHER 58 | ||
| 163 | |||
| 161 | int prctl (int, ...); | 164 | int prctl (int, ...); |
| 162 | 165 | ||
| 163 | #ifdef __cplusplus | 166 | #ifdef __cplusplus |
lib/libc/include/generic-musl/sys/random.h+1| ... | @@ -10,6 +10,7 @@ extern "C" { | ... | @@ -10,6 +10,7 @@ extern "C" { |
| 10 | 10 | ||
| 11 | #define GRND_NONBLOCK	0x0001 | 11 | #define GRND_NONBLOCK	0x0001 |
| 12 | #define GRND_RANDOM	0x0002 | 12 | #define GRND_RANDOM	0x0002 |
| 13 | #define GRND_INSECURE	0x0004 | ||
| 13 | 14 | ||
| 14 | ssize_t getrandom(void *, size_t, unsigned); | 15 | ssize_t getrandom(void *, size_t, unsigned); |
| 15 | 16 |
lib/libc/include/generic-musl/termios.h+4| ... | @@ -8,6 +8,7 @@ extern "C" { | ... | @@ -8,6 +8,7 @@ extern "C" { |
| 8 | #include <features.h> | 8 | #include <features.h> |
| 9 | 9 | ||
| 10 | #define __NEED_pid_t | 10 | #define __NEED_pid_t |
| 11 | #define __NEED_struct_winsize | ||
| 11 | 12 | ||
| 12 | #include <bits/alltypes.h> | 13 | #include <bits/alltypes.h> |
| 13 | 14 | ||
| ... | @@ -27,6 +28,9 @@ int cfsetispeed (struct termios *, speed_t); | ... | @@ -27,6 +28,9 @@ int cfsetispeed (struct termios *, speed_t); |
| 27 | int tcgetattr (int, struct termios *); | 28 | int tcgetattr (int, struct termios *); |
| 28 | int tcsetattr (int, int, const struct termios *); | 29 | int tcsetattr (int, int, const struct termios *); |
| 29 | 30 | ||
| 31 | int tcgetwinsize (int, struct winsize *); | ||
| 32 | int tcsetwinsize (int, const struct winsize *); | ||
| 33 | |||
| 30 | int tcsendbreak (int, int); | 34 | int tcsendbreak (int, int); |
| 31 | int tcdrain (int); | 35 | int tcdrain (int); |
| 32 | int tcflush (int, int); | 36 | int tcflush (int, int); |
lib/libc/include/generic-musl/unistd.h+2| ... | @@ -82,6 +82,7 @@ unsigned sleep(unsigned); | ... | @@ -82,6 +82,7 @@ unsigned sleep(unsigned); |
| 82 | int pause(void); | 82 | int pause(void); |
| 83 | 83 | ||
| 84 | pid_t fork(void); | 84 | pid_t fork(void); |
| 85 | pid_t _Fork(void); | ||
| 85 | int execve(const char *, char *const [], char *const []); | 86 | int execve(const char *, char *const [], char *const []); |
| 86 | int execv(const char *, char *const []); | 87 | int execv(const char *, char *const []); |
| 87 | int execle(const char *, const char *, ...); | 88 | int execle(const char *, const char *, ...); |
| ... | @@ -190,6 +191,7 @@ int syncfs(int); | ... | @@ -190,6 +191,7 @@ int syncfs(int); |
| 190 | int euidaccess(const char *, int); | 191 | int euidaccess(const char *, int); |
| 191 | int eaccess(const char *, int); | 192 | int eaccess(const char *, int); |
| 192 | ssize_t copy_file_range(int, off_t *, int, off_t *, size_t, unsigned); | 193 | ssize_t copy_file_range(int, off_t *, int, off_t *, size_t, unsigned); |
| 194 | pid_t gettid(void); | ||
| 193 | #endif | 195 | #endif |
| 194 | 196 | ||
| 195 | #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) | 197 | #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) |
lib/libc/include/i386-linux-musl/bits/alltypes.h+6| ... | @@ -380,6 +380,12 @@ struct iovec { void *iov_base; size_t iov_len; }; | ... | @@ -380,6 +380,12 @@ struct iovec { void *iov_base; size_t iov_len; }; |
| 380 | #endif | 380 | #endif |
| 381 | 381 | ||
| 382 | 382 | ||
| 383 | #if defined(__NEED_struct_winsize) && !defined(__DEFINED_struct_winsize) | ||
| 384 | struct winsize { unsigned short ws_row, ws_col, ws_xpixel, ws_ypixel; }; | ||
| 385 | #define __DEFINED_struct_winsize | ||
| 386 | #endif | ||
| 387 | |||
| 388 | |||
| 383 | #if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t) | 389 | #if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t) |
| 384 | typedef unsigned socklen_t; | 390 | typedef unsigned socklen_t; |
| 385 | #define __DEFINED_socklen_t | 391 | #define __DEFINED_socklen_t |
lib/libc/include/i386-linux-musl/bits/syscall.h+9-1| ... | @@ -426,6 +426,10 @@ | ... | @@ -426,6 +426,10 @@ |
| 426 | #define __NR_fspick		433 | 426 | #define __NR_fspick		433 |
| 427 | #define __NR_pidfd_open		434 | 427 | #define __NR_pidfd_open		434 |
| 428 | #define __NR_clone3		435 | 428 | #define __NR_clone3		435 |
| 429 | #define __NR_close_range	436 | ||
| 430 | #define __NR_openat2		437 | ||
| 431 | #define __NR_pidfd_getfd	438 | ||
| 432 | #define __NR_faccessat2		439 | ||
| 429 | 433 | ||
| 430 | #define SYS_restart_syscall 0 | 434 | #define SYS_restart_syscall 0 |
| 431 | #define SYS_exit		 1 | 435 | #define SYS_exit		 1 |
| ... | @@ -852,4 +856,8 @@ | ... | @@ -852,4 +856,8 @@ |
| 852 | #define SYS_fsmount		432 | 856 | #define SYS_fsmount		432 |
| 853 | #define SYS_fspick		433 | 857 | #define SYS_fspick		433 |
| 854 | #define SYS_pidfd_open		434 | 858 | #define SYS_pidfd_open		434 |
| 855 | #define SYS_clone3		435 | ||
| \ No newline at end of file | |||
| 859 | #define SYS_clone3		435 | ||
| 860 | #define SYS_close_range	436 | ||
| 861 | #define SYS_openat2		437 | ||
| 862 | #define SYS_pidfd_getfd	438 | ||
| 863 | #define SYS_faccessat2		439 | ||
| \ No newline at end of file | |||
lib/libc/include/mips-linux-musl/bits/alltypes.h+6| ... | @@ -350,6 +350,12 @@ struct iovec { void *iov_base; size_t iov_len; }; | ... | @@ -350,6 +350,12 @@ struct iovec { void *iov_base; size_t iov_len; }; |
| 350 | #endif | 350 | #endif |
| 351 | 351 | ||
| 352 | 352 | ||
| 353 | #if defined(__NEED_struct_winsize) && !defined(__DEFINED_struct_winsize) | ||
| 354 | struct winsize { unsigned short ws_row, ws_col, ws_xpixel, ws_ypixel; }; | ||
| 355 | #define __DEFINED_struct_winsize | ||
| 356 | #endif | ||
| 357 | |||
| 358 | |||
| 353 | #if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t) | 359 | #if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t) |
| 354 | typedef unsigned socklen_t; | 360 | typedef unsigned socklen_t; |
| 355 | #define __DEFINED_socklen_t | 361 | #define __DEFINED_socklen_t |
lib/libc/include/mips-linux-musl/bits/syscall.h+9-1| ... | @@ -408,6 +408,10 @@ | ... | @@ -408,6 +408,10 @@ |
| 408 | #define __NR_fspick		4433 | 408 | #define __NR_fspick		4433 |
| 409 | #define __NR_pidfd_open		4434 | 409 | #define __NR_pidfd_open		4434 |
| 410 | #define __NR_clone3		4435 | 410 | #define __NR_clone3		4435 |
| 411 | #define __NR_close_range	4436 | ||
| 412 | #define __NR_openat2		4437 | ||
| 413 | #define __NR_pidfd_getfd	4438 | ||
| 414 | #define __NR_faccessat2		4439 | ||
| 411 | 415 | ||
| 412 | #define SYS_syscall 4000 | 416 | #define SYS_syscall 4000 |
| 413 | #define SYS_exit 4001 | 417 | #define SYS_exit 4001 |
| ... | @@ -818,4 +822,8 @@ | ... | @@ -818,4 +822,8 @@ |
| 818 | #define SYS_fsmount		4432 | 822 | #define SYS_fsmount		4432 |
| 819 | #define SYS_fspick		4433 | 823 | #define SYS_fspick		4433 |
| 820 | #define SYS_pidfd_open		4434 | 824 | #define SYS_pidfd_open		4434 |
| 821 | #define SYS_clone3		4435 | ||
| \ No newline at end of file | |||
| 825 | #define SYS_clone3		4435 | ||
| 826 | #define SYS_close_range	4436 | ||
| 827 | #define SYS_openat2		4437 | ||
| 828 | #define SYS_pidfd_getfd	4438 | ||
| 829 | #define SYS_faccessat2		4439 | ||
| \ No newline at end of file | |||
lib/libc/include/mips64-linux-musl/bits/alltypes.h+6| ... | @@ -355,6 +355,12 @@ struct iovec { void *iov_base; size_t iov_len; }; | ... | @@ -355,6 +355,12 @@ struct iovec { void *iov_base; size_t iov_len; }; |
| 355 | #endif | 355 | #endif |
| 356 | 356 | ||
| 357 | 357 | ||
| 358 | #if defined(__NEED_struct_winsize) && !defined(__DEFINED_struct_winsize) | ||
| 359 | struct winsize { unsigned short ws_row, ws_col, ws_xpixel, ws_ypixel; }; | ||
| 360 | #define __DEFINED_struct_winsize | ||
| 361 | #endif | ||
| 362 | |||
| 363 | |||
| 358 | #if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t) | 364 | #if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t) |
| 359 | typedef unsigned socklen_t; | 365 | typedef unsigned socklen_t; |
| 360 | #define __DEFINED_socklen_t | 366 | #define __DEFINED_socklen_t |
lib/libc/include/mips64-linux-musl/bits/fcntl.h+1-1| ... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | ||
| 14 | #define O_ASYNC 010000 | 14 | #define O_ASYNC 010000 |
| 15 | #define O_DIRECT 0100000 | 15 | #define O_DIRECT 0100000 |
| 16 | #define O_LARGEFILE 0 | 16 | #define O_LARGEFILE 020000 |
| 17 | #define O_NOATIME 01000000 | 17 | #define O_NOATIME 01000000 |
| 18 | #define O_PATH 010000000 | 18 | #define O_PATH 010000000 |
| 19 | #define O_TMPFILE 020200000 | 19 | #define O_TMPFILE 020200000 |
lib/libc/include/mips64-linux-musl/bits/syscall.h+9-1| ... | @@ -338,6 +338,10 @@ | ... | @@ -338,6 +338,10 @@ |
| 338 | #define __NR_fspick		5433 | 338 | #define __NR_fspick		5433 |
| 339 | #define __NR_pidfd_open		5434 | 339 | #define __NR_pidfd_open		5434 |
| 340 | #define __NR_clone3		5435 | 340 | #define __NR_clone3		5435 |
| 341 | #define __NR_close_range	5436 | ||
| 342 | #define __NR_openat2		5437 | ||
| 343 | #define __NR_pidfd_getfd	5438 | ||
| 344 | #define __NR_faccessat2		5439 | ||
| 341 | 345 | ||
| 342 | #define SYS_read			5000 | 346 | #define SYS_read			5000 |
| 343 | #define SYS_write			5001 | 347 | #define SYS_write			5001 |
| ... | @@ -678,4 +682,8 @@ | ... | @@ -678,4 +682,8 @@ |
| 678 | #define SYS_fsmount		5432 | 682 | #define SYS_fsmount		5432 |
| 679 | #define SYS_fspick		5433 | 683 | #define SYS_fspick		5433 |
| 680 | #define SYS_pidfd_open		5434 | 684 | #define SYS_pidfd_open		5434 |
| 681 | #define SYS_clone3		5435 | ||
| \ No newline at end of file | |||
| 685 | #define SYS_clone3		5435 | ||
| 686 | #define SYS_close_range	5436 | ||
| 687 | #define SYS_openat2		5437 | ||
| 688 | #define SYS_pidfd_getfd	5438 | ||
| 689 | #define SYS_faccessat2		5439 | ||
| \ No newline at end of file | |||
lib/libc/include/powerpc-linux-musl/bits/alltypes.h+6| ... | @@ -353,6 +353,12 @@ struct iovec { void *iov_base; size_t iov_len; }; | ... | @@ -353,6 +353,12 @@ struct iovec { void *iov_base; size_t iov_len; }; |
| 353 | #endif | 353 | #endif |
| 354 | 354 | ||
| 355 | 355 | ||
| 356 | #if defined(__NEED_struct_winsize) && !defined(__DEFINED_struct_winsize) | ||
| 357 | struct winsize { unsigned short ws_row, ws_col, ws_xpixel, ws_ypixel; }; | ||
| 358 | #define __DEFINED_struct_winsize | ||
| 359 | #endif | ||
| 360 | |||
| 361 | |||
| 356 | #if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t) | 362 | #if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t) |
| 357 | typedef unsigned socklen_t; | 363 | typedef unsigned socklen_t; |
| 358 | #define __DEFINED_socklen_t | 364 | #define __DEFINED_socklen_t |
lib/libc/include/powerpc-linux-musl/bits/syscall.h+9-1| ... | @@ -415,6 +415,10 @@ | ... | @@ -415,6 +415,10 @@ |
| 415 | #define __NR_fspick		433 | 415 | #define __NR_fspick		433 |
| 416 | #define __NR_pidfd_open		434 | 416 | #define __NR_pidfd_open		434 |
| 417 | #define __NR_clone3		435 | 417 | #define __NR_clone3		435 |
| 418 | #define __NR_close_range	436 | ||
| 419 | #define __NR_openat2		437 | ||
| 420 | #define __NR_pidfd_getfd	438 | ||
| 421 | #define __NR_faccessat2		439 | ||
| 418 | 422 | ||
| 419 | #define SYS_restart_syscall 0 | 423 | #define SYS_restart_syscall 0 |
| 420 | #define SYS_exit 1 | 424 | #define SYS_exit 1 |
| ... | @@ -832,4 +836,8 @@ | ... | @@ -832,4 +836,8 @@ |
| 832 | #define SYS_fsmount		432 | 836 | #define SYS_fsmount		432 |
| 833 | #define SYS_fspick		433 | 837 | #define SYS_fspick		433 |
| 834 | #define SYS_pidfd_open		434 | 838 | #define SYS_pidfd_open		434 |
| 835 | #define SYS_clone3		435 | ||
| \ No newline at end of file | |||
| 839 | #define SYS_clone3		435 | ||
| 840 | #define SYS_close_range	436 | ||
| 841 | #define SYS_openat2		437 | ||
| 842 | #define SYS_pidfd_getfd	438 | ||
| 843 | #define SYS_faccessat2		439 | ||
| \ No newline at end of file | |||
lib/libc/include/powerpc64-linux-musl/bits/alltypes.h+6| ... | @@ -349,6 +349,12 @@ struct iovec { void *iov_base; size_t iov_len; }; | ... | @@ -349,6 +349,12 @@ struct iovec { void *iov_base; size_t iov_len; }; |
| 349 | #endif | 349 | #endif |
| 350 | 350 | ||
| 351 | 351 | ||
| 352 | #if defined(__NEED_struct_winsize) && !defined(__DEFINED_struct_winsize) | ||
| 353 | struct winsize { unsigned short ws_row, ws_col, ws_xpixel, ws_ypixel; }; | ||
| 354 | #define __DEFINED_struct_winsize | ||
| 355 | #endif | ||
| 356 | |||
| 357 | |||
| 352 | #if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t) | 358 | #if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t) |
| 353 | typedef unsigned socklen_t; | 359 | typedef unsigned socklen_t; |
| 354 | #define __DEFINED_socklen_t | 360 | #define __DEFINED_socklen_t |
lib/libc/include/powerpc64-linux-musl/bits/syscall.h+9-1| ... | @@ -387,6 +387,10 @@ | ... | @@ -387,6 +387,10 @@ |
| 387 | #define __NR_fspick		433 | 387 | #define __NR_fspick		433 |
| 388 | #define __NR_pidfd_open		434 | 388 | #define __NR_pidfd_open		434 |
| 389 | #define __NR_clone3		435 | 389 | #define __NR_clone3		435 |
| 390 | #define __NR_close_range	436 | ||
| 391 | #define __NR_openat2		437 | ||
| 392 | #define __NR_pidfd_getfd	438 | ||
| 393 | #define __NR_faccessat2		439 | ||
| 390 | 394 | ||
| 391 | #define SYS_restart_syscall 0 | 395 | #define SYS_restart_syscall 0 |
| 392 | #define SYS_exit 1 | 396 | #define SYS_exit 1 |
| ... | @@ -776,4 +780,8 @@ | ... | @@ -776,4 +780,8 @@ |
| 776 | #define SYS_fsmount		432 | 780 | #define SYS_fsmount		432 |
| 777 | #define SYS_fspick		433 | 781 | #define SYS_fspick		433 |
| 778 | #define SYS_pidfd_open		434 | 782 | #define SYS_pidfd_open		434 |
| 779 | #define SYS_clone3		435 | ||
| \ No newline at end of file | |||
| 783 | #define SYS_clone3		435 | ||
| 784 | #define SYS_close_range	436 | ||
| 785 | #define SYS_openat2		437 | ||
| 786 | #define SYS_pidfd_getfd	438 | ||
| 787 | #define SYS_faccessat2		439 | ||
| \ No newline at end of file | |||
lib/libc/include/riscv64-linux-musl/bits/alltypes.h+6| ... | @@ -355,6 +355,12 @@ struct iovec { void *iov_base; size_t iov_len; }; | ... | @@ -355,6 +355,12 @@ struct iovec { void *iov_base; size_t iov_len; }; |
| 355 | #endif | 355 | #endif |
| 356 | 356 | ||
| 357 | 357 | ||
| 358 | #if defined(__NEED_struct_winsize) && !defined(__DEFINED_struct_winsize) | ||
| 359 | struct winsize { unsigned short ws_row, ws_col, ws_xpixel, ws_ypixel; }; | ||
| 360 | #define __DEFINED_struct_winsize | ||
| 361 | #endif | ||
| 362 | |||
| 363 | |||
| 358 | #if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t) | 364 | #if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t) |
| 359 | typedef unsigned socklen_t; | 365 | typedef unsigned socklen_t; |
| 360 | #define __DEFINED_socklen_t | 366 | #define __DEFINED_socklen_t |
lib/libc/include/riscv64-linux-musl/bits/signal.h+2-2| ... | @@ -60,10 +60,10 @@ struct sigaltstack { | ... | @@ -60,10 +60,10 @@ struct sigaltstack { |
| 60 | 	size_t ss_size; | 60 | 	size_t ss_size; |
| 61 | }; | 61 | }; |
| 62 | 62 | ||
| 63 | typedef struct ucontext_t | 63 | typedef struct __ucontext |
| 64 | { | 64 | { |
| 65 | 	unsigned long uc_flags; | 65 | 	unsigned long uc_flags; |
| 66 | 	struct ucontext_t *uc_link; | 66 | 	struct __ucontext *uc_link; |
| 67 | 	stack_t uc_stack; | 67 | 	stack_t uc_stack; |
| 68 | 	sigset_t uc_sigmask; | 68 | 	sigset_t uc_sigmask; |
| 69 | 	mcontext_t uc_mcontext; | 69 | 	mcontext_t uc_mcontext; |
lib/libc/include/riscv64-linux-musl/bits/syscall.h+8| ... | @@ -289,6 +289,10 @@ | ... | @@ -289,6 +289,10 @@ |
| 289 | #define __NR_fspick		433 | 289 | #define __NR_fspick		433 |
| 290 | #define __NR_pidfd_open		434 | 290 | #define __NR_pidfd_open		434 |
| 291 | #define __NR_clone3		435 | 291 | #define __NR_clone3		435 |
| 292 | #define __NR_close_range	436 | ||
| 293 | #define __NR_openat2		437 | ||
| 294 | #define __NR_pidfd_getfd	438 | ||
| 295 | #define __NR_faccessat2		439 | ||
| 292 | 296 | ||
| 293 | #define __NR_sysriscv __NR_arch_specific_syscall | 297 | #define __NR_sysriscv __NR_arch_specific_syscall |
| 294 | #define __NR_riscv_flush_icache (__NR_sysriscv + 15) | 298 | #define __NR_riscv_flush_icache (__NR_sysriscv + 15) |
| ... | @@ -583,5 +587,9 @@ | ... | @@ -583,5 +587,9 @@ |
| 583 | #define SYS_fspick		433 | 587 | #define SYS_fspick		433 |
| 584 | #define SYS_pidfd_open		434 | 588 | #define SYS_pidfd_open		434 |
| 585 | #define SYS_clone3		435 | 589 | #define SYS_clone3		435 |
| 590 | #define SYS_close_range	436 | ||
| 591 | #define SYS_openat2		437 | ||
| 592 | #define SYS_pidfd_getfd	438 | ||
| 593 | #define SYS_faccessat2		439 | ||
| 586 | #define SYS_sysriscv __NR_arch_specific_syscall | 594 | #define SYS_sysriscv __NR_arch_specific_syscall |
| 587 | #define SYS_riscv_flush_icache (__NR_sysriscv + 15) | 595 | #define SYS_riscv_flush_icache (__NR_sysriscv + 15) |
| \ No newline at end of file | |||
lib/libc/include/s390x-linux-musl/bits/alltypes.h+14| ... | @@ -13,11 +13,19 @@ typedef int wchar_t; | ... | @@ -13,11 +13,19 @@ typedef int wchar_t; |
| 13 | 13 | ||
| 14 | #endif | 14 | #endif |
| 15 | 15 | ||
| 16 | #if defined(__FLT_EVAL_METHOD__) && __FLT_EVAL_METHOD__ == 1 | ||
| 16 | #if defined(__NEED_float_t) && !defined(__DEFINED_float_t) | 17 | #if defined(__NEED_float_t) && !defined(__DEFINED_float_t) |
| 17 | typedef double float_t; | 18 | typedef double float_t; |
| 18 | #define __DEFINED_float_t | 19 | #define __DEFINED_float_t |
| 19 | #endif | 20 | #endif |
| 20 | 21 | ||
| 22 | #else | ||
| 23 | #if defined(__NEED_float_t) && !defined(__DEFINED_float_t) | ||
| 24 | typedef float float_t; | ||
| 25 | #define __DEFINED_float_t | ||
| 26 | #endif | ||
| 27 | |||
| 28 | #endif | ||
| 21 | #if defined(__NEED_double_t) && !defined(__DEFINED_double_t) | 29 | #if defined(__NEED_double_t) && !defined(__DEFINED_double_t) |
| 22 | typedef double double_t; | 30 | typedef double double_t; |
| 23 | #define __DEFINED_double_t | 31 | #define __DEFINED_double_t |
| ... | @@ -344,6 +352,12 @@ struct iovec { void *iov_base; size_t iov_len; }; | ... | @@ -344,6 +352,12 @@ struct iovec { void *iov_base; size_t iov_len; }; |
| 344 | #endif | 352 | #endif |
| 345 | 353 | ||
| 346 | 354 | ||
| 355 | #if defined(__NEED_struct_winsize) && !defined(__DEFINED_struct_winsize) | ||
| 356 | struct winsize { unsigned short ws_row, ws_col, ws_xpixel, ws_ypixel; }; | ||
| 357 | #define __DEFINED_struct_winsize | ||
| 358 | #endif | ||
| 359 | |||
| 360 | |||
| 347 | #if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t) | 361 | #if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t) |
| 348 | typedef unsigned socklen_t; | 362 | typedef unsigned socklen_t; |
| 349 | #define __DEFINED_socklen_t | 363 | #define __DEFINED_socklen_t |
lib/libc/include/s390x-linux-musl/bits/float.h+5-1| ... | @@ -1,4 +1,8 @@ | ... | @@ -1,4 +1,8 @@ |
| 1 | #define FLT_EVAL_METHOD 1 | 1 | #ifdef __FLT_EVAL_METHOD__ |
| 2 | #define FLT_EVAL_METHOD __FLT_EVAL_METHOD__ | ||
| 3 | #else | ||
| 4 | #define FLT_EVAL_METHOD 0 | ||
| 5 | #endif | ||
| 2 | 6 | ||
| 3 | #define LDBL_TRUE_MIN 6.47517511943802511092443895822764655e-4966L | 7 | #define LDBL_TRUE_MIN 6.47517511943802511092443895822764655e-4966L |
| 4 | #define LDBL_MIN 3.36210314311209350626267781732175260e-4932L | 8 | #define LDBL_MIN 3.36210314311209350626267781732175260e-4932L |
lib/libc/include/s390x-linux-musl/bits/syscall.h+9-1| ... | @@ -352,6 +352,10 @@ | ... | @@ -352,6 +352,10 @@ |
| 352 | #define __NR_fspick		433 | 352 | #define __NR_fspick		433 |
| 353 | #define __NR_pidfd_open		434 | 353 | #define __NR_pidfd_open		434 |
| 354 | #define __NR_clone3		435 | 354 | #define __NR_clone3		435 |
| 355 | #define __NR_close_range	436 | ||
| 356 | #define __NR_openat2		437 | ||
| 357 | #define __NR_pidfd_getfd	438 | ||
| 358 | #define __NR_faccessat2		439 | ||
| 355 | 359 | ||
| 356 | #define SYS_exit 1 | 360 | #define SYS_exit 1 |
| 357 | #define SYS_fork 2 | 361 | #define SYS_fork 2 |
| ... | @@ -706,4 +710,8 @@ | ... | @@ -706,4 +710,8 @@ |
| 706 | #define SYS_fsmount		432 | 710 | #define SYS_fsmount		432 |
| 707 | #define SYS_fspick		433 | 711 | #define SYS_fspick		433 |
| 708 | #define SYS_pidfd_open		434 | 712 | #define SYS_pidfd_open		434 |
| 709 | #define SYS_clone3		435 | ||
| \ No newline at end of file | |||
| 713 | #define SYS_clone3		435 | ||
| 714 | #define SYS_close_range	436 | ||
| 715 | #define SYS_openat2		437 | ||
| 716 | #define SYS_pidfd_getfd	438 | ||
| 717 | #define SYS_faccessat2		439 | ||
| \ No newline at end of file | |||
lib/libc/include/x86_64-linux-musl/bits/alltypes.h+6| ... | @@ -357,6 +357,12 @@ struct iovec { void *iov_base; size_t iov_len; }; | ... | @@ -357,6 +357,12 @@ struct iovec { void *iov_base; size_t iov_len; }; |
| 357 | #endif | 357 | #endif |
| 358 | 358 | ||
| 359 | 359 | ||
| 360 | #if defined(__NEED_struct_winsize) && !defined(__DEFINED_struct_winsize) | ||
| 361 | struct winsize { unsigned short ws_row, ws_col, ws_xpixel, ws_ypixel; }; | ||
| 362 | #define __DEFINED_struct_winsize | ||
| 363 | #endif | ||
| 364 | |||
| 365 | |||
| 360 | #if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t) | 366 | #if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t) |
| 361 | typedef unsigned socklen_t; | 367 | typedef unsigned socklen_t; |
| 362 | #define __DEFINED_socklen_t | 368 | #define __DEFINED_socklen_t |
lib/libc/include/x86_64-linux-musl/bits/syscall.h+9-1| ... | @@ -345,6 +345,10 @@ | ... | @@ -345,6 +345,10 @@ |
| 345 | #define __NR_fspick		433 | 345 | #define __NR_fspick		433 |
| 346 | #define __NR_pidfd_open		434 | 346 | #define __NR_pidfd_open		434 |
| 347 | #define __NR_clone3		435 | 347 | #define __NR_clone3		435 |
| 348 | #define __NR_close_range	436 | ||
| 349 | #define __NR_openat2		437 | ||
| 350 | #define __NR_pidfd_getfd	438 | ||
| 351 | #define __NR_faccessat2		439 | ||
| 348 | 352 | ||
| 349 | #define SYS_read				0 | 353 | #define SYS_read				0 |
| 350 | #define SYS_write				1 | 354 | #define SYS_write				1 |
| ... | @@ -692,4 +696,8 @@ | ... | @@ -692,4 +696,8 @@ |
| 692 | #define SYS_fsmount		432 | 696 | #define SYS_fsmount		432 |
| 693 | #define SYS_fspick		433 | 697 | #define SYS_fspick		433 |
| 694 | #define SYS_pidfd_open		434 | 698 | #define SYS_pidfd_open		434 |
| 695 | #define SYS_clone3		435 | ||
| \ No newline at end of file | |||
| 699 | #define SYS_clone3		435 | ||
| 700 | #define SYS_close_range	436 | ||
| 701 | #define SYS_openat2		437 | ||
| 702 | #define SYS_pidfd_getfd	438 | ||
| 703 | #define SYS_faccessat2		439 | ||
| \ No newline at end of file | |||
lib/libc/musl/arch/aarch64/bits/hwcap.h+10| ... | @@ -38,3 +38,13 @@ | ... | @@ -38,3 +38,13 @@ |
| 38 | #define HWCAP2_SVEBITPERM	(1 << 4) | 38 | #define HWCAP2_SVEBITPERM	(1 << 4) |
| 39 | #define HWCAP2_SVESHA3		(1 << 5) | 39 | #define HWCAP2_SVESHA3		(1 << 5) |
| 40 | #define HWCAP2_SVESM4		(1 << 6) | 40 | #define HWCAP2_SVESM4		(1 << 6) |
| 41 | #define HWCAP2_FLAGM2		(1 << 7) | ||
| 42 | #define HWCAP2_FRINT		(1 << 8) | ||
| 43 | #define HWCAP2_SVEI8MM		(1 << 9) | ||
| 44 | #define HWCAP2_SVEF32MM		(1 << 10) | ||
| 45 | #define HWCAP2_SVEF64MM		(1 << 11) | ||
| 46 | #define HWCAP2_SVEBF16		(1 << 12) | ||
| 47 | #define HWCAP2_I8MM		(1 << 13) | ||
| 48 | #define HWCAP2_BF16		(1 << 14) | ||
| 49 | #define HWCAP2_DGH		(1 << 15) | ||
| 50 | #define HWCAP2_RNG		(1 << 16) |
lib/libc/musl/arch/aarch64/bits/signal.h+2-2| ... | @@ -11,7 +11,7 @@ typedef unsigned long greg_t; | ... | @@ -11,7 +11,7 @@ typedef unsigned long greg_t; |
| 11 | typedef unsigned long gregset_t[34]; | 11 | typedef unsigned long gregset_t[34]; |
| 12 | 12 | ||
| 13 | typedef struct { | 13 | typedef struct { |
| 14 | 	long double vregs[32]; | 14 | 	__uint128_t vregs[32]; |
| 15 | 	unsigned int fpsr; | 15 | 	unsigned int fpsr; |
| 16 | 	unsigned int fpcr; | 16 | 	unsigned int fpcr; |
| 17 | } fpregset_t; | 17 | } fpregset_t; |
| ... | @@ -34,7 +34,7 @@ struct fpsimd_context { | ... | @@ -34,7 +34,7 @@ struct fpsimd_context { |
| 34 | 	struct _aarch64_ctx head; | 34 | 	struct _aarch64_ctx head; |
| 35 | 	unsigned int fpsr; | 35 | 	unsigned int fpsr; |
| 36 | 	unsigned int fpcr; | 36 | 	unsigned int fpcr; |
| 37 | 	long double vregs[32]; | 37 | 	__uint128_t vregs[32]; |
| 38 | }; | 38 | }; |
| 39 | struct esr_context { | 39 | struct esr_context { |
| 40 | 	struct _aarch64_ctx head; | 40 | 	struct _aarch64_ctx head; |
lib/libc/musl/arch/aarch64/bits/syscall.h.in+4| ... | @@ -289,4 +289,8 @@ | ... | @@ -289,4 +289,8 @@ |
| 289 | #define __NR_fspick		433 | 289 | #define __NR_fspick		433 |
| 290 | #define __NR_pidfd_open		434 | 290 | #define __NR_pidfd_open		434 |
| 291 | #define __NR_clone3		435 | 291 | #define __NR_clone3		435 |
| 292 | #define __NR_close_range	436 | ||
| 293 | #define __NR_openat2		437 | ||
| 294 | #define __NR_pidfd_getfd	438 | ||
| 295 | #define __NR_faccessat2		439 | ||
| 292 | 296 |
lib/libc/musl/arch/aarch64/bits/user.h+1-1| ... | @@ -6,7 +6,7 @@ struct user_regs_struct { | ... | @@ -6,7 +6,7 @@ struct user_regs_struct { |
| 6 | }; | 6 | }; |
| 7 | 7 | ||
| 8 | struct user_fpsimd_struct { | 8 | struct user_fpsimd_struct { |
| 9 | 	long double vregs[32]; | 9 | 	__uint128_t vregs[32]; |
| 10 | 	unsigned int fpsr; | 10 | 	unsigned int fpsr; |
| 11 | 	unsigned int fpcr; | 11 | 	unsigned int fpcr; |
| 12 | }; | 12 | }; |
lib/libc/musl/arch/aarch64/pthread_arch.h+4-5| ... | @@ -1,12 +1,11 @@ | ... | @@ -1,12 +1,11 @@ |
| 1 | static inline struct pthread *__pthread_self() | 1 | static inline uintptr_t __get_tp() |
| 2 | { | 2 | { |
| 3 | 	char *self; | 3 | 	uintptr_t tp; |
| 4 | 	__asm__ ("mrs %0,tpidr_el0" : "=r"(self)); | 4 | 	__asm__ ("mrs %0,tpidr_el0" : "=r"(tp)); |
| 5 | 	return (void*)(self - sizeof(struct pthread)); | 5 | 	return tp; |
| 6 | } | 6 | } |
| 7 | 7 | ||
| 8 | #define TLS_ABOVE_TP | 8 | #define TLS_ABOVE_TP |
| 9 | #define GAP_ABOVE_TP 16 | 9 | #define GAP_ABOVE_TP 16 |
| 10 | #define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread)) | ||
| 11 | 10 | ||
| 12 | #define MC_PC pc | 11 | #define MC_PC pc |
lib/libc/musl/arch/arm/bits/syscall.h.in+4| ... | @@ -389,6 +389,10 @@ | ... | @@ -389,6 +389,10 @@ |
| 389 | #define __NR_fspick		433 | 389 | #define __NR_fspick		433 |
| 390 | #define __NR_pidfd_open		434 | 390 | #define __NR_pidfd_open		434 |
| 391 | #define __NR_clone3		435 | 391 | #define __NR_clone3		435 |
| 392 | #define __NR_close_range	436 | ||
| 393 | #define __NR_openat2		437 | ||
| 394 | #define __NR_pidfd_getfd	438 | ||
| 395 | #define __NR_faccessat2		439 | ||
| 392 | 396 | ||
| 393 | #define __ARM_NR_breakpoint	0x0f0001 | 397 | #define __ARM_NR_breakpoint	0x0f0001 |
| 394 | #define __ARM_NR_cacheflush	0x0f0002 | 398 | #define __ARM_NR_cacheflush	0x0f0002 |
lib/libc/musl/arch/arm/pthread_arch.h+8-9| ... | @@ -1,11 +1,11 @@ | ... | @@ -1,11 +1,11 @@ |
| 1 | #if ((__ARM_ARCH_6K__ || __ARM_ARCH_6KZ__ || __ARM_ARCH_6ZK__) && !__thumb__) \ | 1 | #if ((__ARM_ARCH_6K__ || __ARM_ARCH_6KZ__ || __ARM_ARCH_6ZK__) && !__thumb__) \ |
| 2 | || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ || __ARM_ARCH >= 7 | 2 | || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ || __ARM_ARCH >= 7 |
| 3 | 3 | ||
| 4 | static inline pthread_t __pthread_self() | 4 | static inline uintptr_t __get_tp() |
| 5 | { | 5 | { |
| 6 | 	char *p; | 6 | 	uintptr_t tp; |
| 7 | 	__asm__ ( "mrc p15,0,%0,c13,c0,3" : "=r"(p) ); | 7 | 	__asm__ ( "mrc p15,0,%0,c13,c0,3" : "=r"(tp) ); |
| 8 | 	return (void *)(p-sizeof(struct pthread)); | 8 | 	return tp; |
| 9 | } | 9 | } |
| 10 | 10 | ||
| 11 | #else | 11 | #else |
| ... | @@ -16,18 +16,17 @@ static inline pthread_t __pthread_self() | ... | @@ -16,18 +16,17 @@ static inline pthread_t __pthread_self() |
| 16 | #define BLX "blx" | 16 | #define BLX "blx" |
| 17 | #endif | 17 | #endif |
| 18 | 18 | ||
| 19 | static inline pthread_t __pthread_self() | 19 | static inline uintptr_t __get_tp() |
| 20 | { | 20 | { |
| 21 | 	extern hidden uintptr_t __a_gettp_ptr; | 21 | 	extern hidden uintptr_t __a_gettp_ptr; |
| 22 | 	register uintptr_t p __asm__("r0"); | 22 | 	register uintptr_t tp __asm__("r0"); |
| 23 | 	__asm__ ( BLX " %1" : "=r"(p) : "r"(__a_gettp_ptr) : "cc", "lr" ); | 23 | 	__asm__ ( BLX " %1" : "=r"(tp) : "r"(__a_gettp_ptr) : "cc", "lr" ); |
| 24 | 	return (void *)(p-sizeof(struct pthread)); | 24 | 	return tp; |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | #endif | 27 | #endif |
| 28 | 28 | ||
| 29 | #define TLS_ABOVE_TP | 29 | #define TLS_ABOVE_TP |
| 30 | #define GAP_ABOVE_TP 8 | 30 | #define GAP_ABOVE_TP 8 |
| 31 | #define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread)) | ||
| 32 | 31 | ||
| 33 | #define MC_PC arm_pc | 32 | #define MC_PC arm_pc |
lib/libc/musl/arch/generic/bits/fcntl.h+6| ... | @@ -30,9 +30,15 @@ | ... | @@ -30,9 +30,15 @@ |
| 30 | #define F_SETSIG 10 | 30 | #define F_SETSIG 10 |
| 31 | #define F_GETSIG 11 | 31 | #define F_GETSIG 11 |
| 32 | 32 | ||
| 33 | #if __LONG_MAX == 0x7fffffffL | ||
| 33 | #define F_GETLK 12 | 34 | #define F_GETLK 12 |
| 34 | #define F_SETLK 13 | 35 | #define F_SETLK 13 |
| 35 | #define F_SETLKW 14 | 36 | #define F_SETLKW 14 |
| 37 | #else | ||
| 38 | #define F_GETLK 5 | ||
| 39 | #define F_SETLK 6 | ||
| 40 | #define F_SETLKW 7 | ||
| 41 | #endif | ||
| 36 | 42 | ||
| 37 | #define F_SETOWN_EX 15 | 43 | #define F_SETOWN_EX 15 |
| 38 | #define F_GETOWN_EX 16 | 44 | #define F_GETOWN_EX 16 |
lib/libc/musl/arch/i386/bits/syscall.h.in+4| ... | @@ -426,4 +426,8 @@ | ... | @@ -426,4 +426,8 @@ |
| 426 | #define __NR_fspick		433 | 426 | #define __NR_fspick		433 |
| 427 | #define __NR_pidfd_open		434 | 427 | #define __NR_pidfd_open		434 |
| 428 | #define __NR_clone3		435 | 428 | #define __NR_clone3		435 |
| 429 | #define __NR_close_range	436 | ||
| 430 | #define __NR_openat2		437 | ||
| 431 | #define __NR_pidfd_getfd	438 | ||
| 432 | #define __NR_faccessat2		439 | ||
| 429 | 433 |
lib/libc/musl/arch/i386/pthread_arch.h+4-6| ... | @@ -1,10 +1,8 @@ | ... | @@ -1,10 +1,8 @@ |
| 1 | static inline struct pthread *__pthread_self() | 1 | static inline uintptr_t __get_tp() |
| 2 | { | 2 | { |
| 3 | 	struct pthread *self; | 3 | 	uintptr_t tp; |
| 4 | 	__asm__ ("movl %%gs:0,%0" : "=r" (self) ); | 4 | 	__asm__ ("movl %%gs:0,%0" : "=r" (tp) ); |
| 5 | 	return self; | 5 | 	return tp; |
| 6 | } | 6 | } |
| 7 | 7 | ||
| 8 | #define TP_ADJ(p) (p) | ||
| 9 | |||
| 10 | #define MC_PC gregs[REG_EIP] | 8 | #define MC_PC gregs[REG_EIP] |
lib/libc/musl/arch/i386/syscall_arch.h-2| ... | @@ -87,5 +87,3 @@ static inline long __syscall6(long n, long a1, long a2, long a3, long a4, long a | ... | @@ -87,5 +87,3 @@ static inline long __syscall6(long n, long a1, long a2, long a3, long a4, long a |
| 87 | #define VDSO_CGT32_VER "LINUX_2.6" | 87 | #define VDSO_CGT32_VER "LINUX_2.6" |
| 88 | #define VDSO_CGT_SYM "__vdso_clock_gettime64" | 88 | #define VDSO_CGT_SYM "__vdso_clock_gettime64" |
| 89 | #define VDSO_CGT_VER "LINUX_2.6" | 89 | #define VDSO_CGT_VER "LINUX_2.6" |
| 90 | |||
| 91 | #define SYSCALL_USE_SOCKETCALL |
lib/libc/musl/arch/mips/bits/syscall.h.in+4| ... | @@ -408,4 +408,8 @@ | ... | @@ -408,4 +408,8 @@ |
| 408 | #define __NR_fspick		4433 | 408 | #define __NR_fspick		4433 |
| 409 | #define __NR_pidfd_open		4434 | 409 | #define __NR_pidfd_open		4434 |
| 410 | #define __NR_clone3		4435 | 410 | #define __NR_clone3		4435 |
| 411 | #define __NR_close_range	4436 | ||
| 412 | #define __NR_openat2		4437 | ||
| 413 | #define __NR_pidfd_getfd	4438 | ||
| 414 | #define __NR_faccessat2		4439 | ||
| 411 | 415 |
lib/libc/musl/arch/mips/pthread_arch.h+5-5| ... | @@ -1,19 +1,19 @@ | ... | @@ -1,19 +1,19 @@ |
| 1 | static inline struct pthread *__pthread_self() | 1 | static inline uintptr_t __get_tp() |
| 2 | { | 2 | { |
| 3 | #if __mips_isa_rev < 2 | 3 | #if __mips_isa_rev < 2 |
| 4 | 	register char *tp __asm__("$3"); | 4 | 	register uintptr_t tp __asm__("$3"); |
| 5 | 	__asm__ (".word 0x7c03e83b" : "=r" (tp) ); | 5 | 	__asm__ (".word 0x7c03e83b" : "=r" (tp) ); |
| 6 | #else | 6 | #else |
| 7 | 	char *tp; | 7 | 	uintptr_t tp; |
| 8 | 	__asm__ ("rdhwr %0, $29" : "=r" (tp) ); | 8 | 	__asm__ ("rdhwr %0, $29" : "=r" (tp) ); |
| 9 | #endif | 9 | #endif |
| 10 | 	return (pthread_t)(tp - 0x7000 - sizeof(struct pthread)); | 10 | 	return tp; |
| 11 | } | 11 | } |
| 12 | 12 | ||
| 13 | #define TLS_ABOVE_TP | 13 | #define TLS_ABOVE_TP |
| 14 | #define GAP_ABOVE_TP 0 | 14 | #define GAP_ABOVE_TP 0 |
| 15 | #define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread) + 0x7000) | ||
| 16 | 15 | ||
| 16 | #define TP_OFFSET 0x7000 | ||
| 17 | #define DTP_OFFSET 0x8000 | 17 | #define DTP_OFFSET 0x8000 |
| 18 | 18 | ||
| 19 | #define MC_PC pc | 19 | #define MC_PC pc |
lib/libc/musl/arch/mips/syscall_arch.h+2| ... | @@ -149,3 +149,5 @@ static inline long __syscall7(long n, long a, long b, long c, long d, long e, lo | ... | @@ -149,3 +149,5 @@ static inline long __syscall7(long n, long a, long b, long c, long d, long e, lo |
| 149 | 149 | ||
| 150 | #define SO_SNDTIMEO_OLD 0x1005 | 150 | #define SO_SNDTIMEO_OLD 0x1005 |
| 151 | #define SO_RCVTIMEO_OLD 0x1006 | 151 | #define SO_RCVTIMEO_OLD 0x1006 |
| 152 | |||
| 153 | #undef SYS_socketcall |
lib/libc/musl/arch/mips64/bits/fcntl.h+1-1| ... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | ||
| 14 | #define O_ASYNC 010000 | 14 | #define O_ASYNC 010000 |
| 15 | #define O_DIRECT 0100000 | 15 | #define O_DIRECT 0100000 |
| 16 | #define O_LARGEFILE 0 | 16 | #define O_LARGEFILE 020000 |
| 17 | #define O_NOATIME 01000000 | 17 | #define O_NOATIME 01000000 |
| 18 | #define O_PATH 010000000 | 18 | #define O_PATH 010000000 |
| 19 | #define O_TMPFILE 020200000 | 19 | #define O_TMPFILE 020200000 |
lib/libc/musl/arch/mips64/bits/syscall.h.in+4| ... | @@ -338,4 +338,8 @@ | ... | @@ -338,4 +338,8 @@ |
| 338 | #define __NR_fspick		5433 | 338 | #define __NR_fspick		5433 |
| 339 | #define __NR_pidfd_open		5434 | 339 | #define __NR_pidfd_open		5434 |
| 340 | #define __NR_clone3		5435 | 340 | #define __NR_clone3		5435 |
| 341 | #define __NR_close_range	5436 | ||
| 342 | #define __NR_openat2		5437 | ||
| 343 | #define __NR_pidfd_getfd	5438 | ||
| 344 | #define __NR_faccessat2		5439 | ||
| 341 | 345 |
lib/libc/musl/arch/mips64/pthread_arch.h+5-5| ... | @@ -1,19 +1,19 @@ | ... | @@ -1,19 +1,19 @@ |
| 1 | static inline struct pthread *__pthread_self() | 1 | static inline uintptr_t __get_tp() |
| 2 | { | 2 | { |
| 3 | #if __mips_isa_rev < 2 | 3 | #if __mips_isa_rev < 2 |
| 4 | 	register char *tp __asm__("$3"); | 4 | 	register uintptr_t tp __asm__("$3"); |
| 5 | 	__asm__ (".word 0x7c03e83b" : "=r" (tp) ); | 5 | 	__asm__ (".word 0x7c03e83b" : "=r" (tp) ); |
| 6 | #else | 6 | #else |
| 7 | 	char *tp; | 7 | 	uintptr_t tp; |
| 8 | 	__asm__ ("rdhwr %0, $29" : "=r" (tp) ); | 8 | 	__asm__ ("rdhwr %0, $29" : "=r" (tp) ); |
| 9 | #endif | 9 | #endif |
| 10 | 	return (pthread_t)(tp - 0x7000 - sizeof(struct pthread)); | 10 | 	return tp; |
| 11 | } | 11 | } |
| 12 | 12 | ||
| 13 | #define TLS_ABOVE_TP | 13 | #define TLS_ABOVE_TP |
| 14 | #define GAP_ABOVE_TP 0 | 14 | #define GAP_ABOVE_TP 0 |
| 15 | #define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread) + 0x7000) | ||
| 16 | 15 | ||
| 16 | #define TP_OFFSET 0x7000 | ||
| 17 | #define DTP_OFFSET 0x8000 | 17 | #define DTP_OFFSET 0x8000 |
| 18 | 18 | ||
| 19 | #define MC_PC pc | 19 | #define MC_PC pc |
lib/libc/musl/arch/powerpc/bits/syscall.h.in+4| ... | @@ -415,4 +415,8 @@ | ... | @@ -415,4 +415,8 @@ |
| 415 | #define __NR_fspick		433 | 415 | #define __NR_fspick		433 |
| 416 | #define __NR_pidfd_open		434 | 416 | #define __NR_pidfd_open		434 |
| 417 | #define __NR_clone3		435 | 417 | #define __NR_clone3		435 |
| 418 | #define __NR_close_range	436 | ||
| 419 | #define __NR_openat2		437 | ||
| 420 | #define __NR_pidfd_getfd	438 | ||
| 421 | #define __NR_faccessat2		439 | ||
| 418 | 422 |
lib/libc/musl/arch/powerpc/pthread_arch.h+4-6| ... | @@ -1,18 +1,16 @@ | ... | @@ -1,18 +1,16 @@ |
| 1 | static inline struct pthread *__pthread_self() | 1 | static inline uintptr_t __get_tp() |
| 2 | { | 2 | { |
| 3 | 	register char *tp __asm__("r2"); | 3 | 	register uintptr_t tp __asm__("r2"); |
| 4 | 	__asm__ ("" : "=r" (tp) ); | 4 | 	__asm__ ("" : "=r" (tp) ); |
| 5 | 	return (pthread_t)(tp - 0x7000 - sizeof(struct pthread)); | 5 | 	return tp; |
| 6 | } | 6 | } |
| 7 | 7 | ||
| 8 | #define TLS_ABOVE_TP | 8 | #define TLS_ABOVE_TP |
| 9 | #define GAP_ABOVE_TP 0 | 9 | #define GAP_ABOVE_TP 0 |
| 10 | #define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread) + 0x7000) | ||
| 11 | 10 | ||
| 11 | #define TP_OFFSET 0x7000 | ||
| 12 | #define DTP_OFFSET 0x8000 | 12 | #define DTP_OFFSET 0x8000 |
| 13 | 13 | ||
| 14 | // the kernel calls the ip "nip", it's the first saved value after the 32 | 14 | // the kernel calls the ip "nip", it's the first saved value after the 32 |
| 15 | // GPRs. | 15 | // GPRs. |
| 16 | #define MC_PC gregs[32] | 16 | #define MC_PC gregs[32] |
| 17 | |||
| 18 | #define CANARY canary_at_end |
lib/libc/musl/arch/powerpc64/bits/syscall.h.in+4| ... | @@ -387,4 +387,8 @@ | ... | @@ -387,4 +387,8 @@ |
| 387 | #define __NR_fspick		433 | 387 | #define __NR_fspick		433 |
| 388 | #define __NR_pidfd_open		434 | 388 | #define __NR_pidfd_open		434 |
| 389 | #define __NR_clone3		435 | 389 | #define __NR_clone3		435 |
| 390 | #define __NR_close_range	436 | ||
| 391 | #define __NR_openat2		437 | ||
| 392 | #define __NR_pidfd_getfd	438 | ||
| 393 | #define __NR_faccessat2		439 | ||
| 390 | 394 |
lib/libc/musl/arch/powerpc64/pthread_arch.h+4-6| ... | @@ -1,18 +1,16 @@ | ... | @@ -1,18 +1,16 @@ |
| 1 | static inline struct pthread *__pthread_self() | 1 | static inline uintptr_t __get_tp() |
| 2 | { | 2 | { |
| 3 | 	register char *tp __asm__("r13"); | 3 | 	register uintptr_t tp __asm__("r13"); |
| 4 | 	__asm__ ("" : "=r" (tp) ); | 4 | 	__asm__ ("" : "=r" (tp) ); |
| 5 | 	return (pthread_t)(tp - 0x7000 - sizeof(struct pthread)); | 5 | 	return tp; |
| 6 | } | 6 | } |
| 7 | 7 | ||
| 8 | #define TLS_ABOVE_TP | 8 | #define TLS_ABOVE_TP |
| 9 | #define GAP_ABOVE_TP 0 | 9 | #define GAP_ABOVE_TP 0 |
| 10 | #define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread) + 0x7000) | ||
| 11 | 10 | ||
| 11 | #define TP_OFFSET 0x7000 | ||
| 12 | #define DTP_OFFSET 0x8000 | 12 | #define DTP_OFFSET 0x8000 |
| 13 | 13 | ||
| 14 | // the kernel calls the ip "nip", it's the first saved value after the 32 | 14 | // the kernel calls the ip "nip", it's the first saved value after the 32 |
| 15 | // GPRs. | 15 | // GPRs. |
| 16 | #define MC_PC gp_regs[32] | 16 | #define MC_PC gp_regs[32] |
| 17 | |||
| 18 | #define CANARY canary_at_end |
lib/libc/musl/arch/riscv64/bits/fcntl.h deleted-38| ... | @@ -1,38 +0,0 @@ | ||
| 1 | #define O_CREAT 0100 | ||
| 2 | #define O_EXCL 0200 | ||
| 3 | #define O_NOCTTY 0400 | ||
| 4 | #define O_TRUNC 01000 | ||
| 5 | #define O_APPEND 02000 | ||
| 6 | #define O_NONBLOCK 04000 | ||
| 7 | #define O_DSYNC 010000 | ||
| 8 | #define O_SYNC 04010000 | ||
| 9 | #define O_RSYNC 04010000 | ||
| 10 | #define O_DIRECTORY 0200000 | ||
| 11 | #define O_NOFOLLOW 0400000 | ||
| 12 | #define O_CLOEXEC 02000000 | ||
| 13 | |||
| 14 | #define O_ASYNC 020000 | ||
| 15 | #define O_DIRECT 040000 | ||
| 16 | #define O_LARGEFILE 0100000 | ||
| 17 | #define O_NOATIME 01000000 | ||
| 18 | #define O_PATH 010000000 | ||
| 19 | #define O_TMPFILE 020200000 | ||
| 20 | #define O_NDELAY O_NONBLOCK | ||
| 21 | |||
| 22 | #define F_DUPFD 0 | ||
| 23 | #define F_GETFD 1 | ||
| 24 | #define F_SETFD 2 | ||
| 25 | #define F_GETFL 3 | ||
| 26 | #define F_SETFL 4 | ||
| 27 | #define F_GETLK 5 | ||
| 28 | #define F_SETLK 6 | ||
| 29 | #define F_SETLKW 7 | ||
| 30 | #define F_SETOWN 8 | ||
| 31 | #define F_GETOWN 9 | ||
| 32 | #define F_SETSIG 10 | ||
| 33 | #define F_GETSIG 11 | ||
| 34 | |||
| 35 | #define F_SETOWN_EX 15 | ||
| 36 | #define F_GETOWN_EX 16 | ||
| 37 | |||
| 38 | #define F_GETOWNER_UIDS 17 | ||
lib/libc/musl/arch/riscv64/bits/signal.h+2-2| ... | @@ -60,10 +60,10 @@ struct sigaltstack { | ... | @@ -60,10 +60,10 @@ struct sigaltstack { |
| 60 | 	size_t ss_size; | 60 | 	size_t ss_size; |
| 61 | }; | 61 | }; |
| 62 | 62 | ||
| 63 | typedef struct ucontext_t | 63 | typedef struct __ucontext |
| 64 | { | 64 | { |
| 65 | 	unsigned long uc_flags; | 65 | 	unsigned long uc_flags; |
| 66 | 	struct ucontext_t *uc_link; | 66 | 	struct __ucontext *uc_link; |
| 67 | 	stack_t uc_stack; | 67 | 	stack_t uc_stack; |
| 68 | 	sigset_t uc_sigmask; | 68 | 	sigset_t uc_sigmask; |
| 69 | 	mcontext_t uc_mcontext; | 69 | 	mcontext_t uc_mcontext; |
lib/libc/musl/arch/riscv64/bits/syscall.h.in+4| ... | @@ -289,6 +289,10 @@ | ... | @@ -289,6 +289,10 @@ |
| 289 | #define __NR_fspick		433 | 289 | #define __NR_fspick		433 |
| 290 | #define __NR_pidfd_open		434 | 290 | #define __NR_pidfd_open		434 |
| 291 | #define __NR_clone3		435 | 291 | #define __NR_clone3		435 |
| 292 | #define __NR_close_range	436 | ||
| 293 | #define __NR_openat2		437 | ||
| 294 | #define __NR_pidfd_getfd	438 | ||
| 295 | #define __NR_faccessat2		439 | ||
| 292 | 296 | ||
| 293 | #define __NR_sysriscv __NR_arch_specific_syscall | 297 | #define __NR_sysriscv __NR_arch_specific_syscall |
| 294 | #define __NR_riscv_flush_icache (__NR_sysriscv + 15) | 298 | #define __NR_riscv_flush_icache (__NR_sysriscv + 15) |
lib/libc/musl/arch/riscv64/pthread_arch.h+3-4| ... | @@ -1,13 +1,12 @@ | ... | @@ -1,13 +1,12 @@ |
| 1 | static inline struct pthread *__pthread_self() | 1 | static inline uintptr_t __get_tp() |
| 2 | { | 2 | { |
| 3 | 	char *tp; | 3 | 	uintptr_t tp; |
| 4 | 	__asm__ __volatile__("mv %0, tp" : "=r"(tp)); | 4 | 	__asm__ __volatile__("mv %0, tp" : "=r"(tp)); |
| 5 | 	return (void *)(tp - sizeof(struct pthread)); | 5 | 	return tp; |
| 6 | } | 6 | } |
| 7 | 7 | ||
| 8 | #define TLS_ABOVE_TP | 8 | #define TLS_ABOVE_TP |
| 9 | #define GAP_ABOVE_TP 0 | 9 | #define GAP_ABOVE_TP 0 |
| 10 | #define TP_ADJ(p) ((char *)p + sizeof(struct pthread)) | ||
| 11 | 10 | ||
| 12 | #define DTP_OFFSET 0x800 | 11 | #define DTP_OFFSET 0x800 |
| 13 | 12 |
lib/libc/musl/arch/s390x/bits/alltypes.h.in+4| ... | @@ -9,7 +9,11 @@ | ... | @@ -9,7 +9,11 @@ |
| 9 | TYPEDEF int wchar_t; | 9 | TYPEDEF int wchar_t; |
| 10 | #endif | 10 | #endif |
| 11 | 11 | ||
| 12 | #if defined(__FLT_EVAL_METHOD__) && __FLT_EVAL_METHOD__ == 1 | ||
| 12 | TYPEDEF double float_t; | 13 | TYPEDEF double float_t; |
| 14 | #else | ||
| 15 | TYPEDEF float float_t; | ||
| 16 | #endif | ||
| 13 | TYPEDEF double double_t; | 17 | TYPEDEF double double_t; |
| 14 | 18 | ||
| 15 | TYPEDEF struct { long long __ll; long double __ld; } max_align_t; | 19 | TYPEDEF struct { long long __ll; long double __ld; } max_align_t; |
lib/libc/musl/arch/s390x/bits/float.h+5-1| ... | @@ -1,4 +1,8 @@ | ... | @@ -1,4 +1,8 @@ |
| 1 | #define FLT_EVAL_METHOD 1 | 1 | #ifdef __FLT_EVAL_METHOD__ |
| 2 | #define FLT_EVAL_METHOD __FLT_EVAL_METHOD__ | ||
| 3 | #else | ||
| 4 | #define FLT_EVAL_METHOD 0 | ||
| 5 | #endif | ||
| 2 | 6 | ||
| 3 | #define LDBL_TRUE_MIN 6.47517511943802511092443895822764655e-4966L | 7 | #define LDBL_TRUE_MIN 6.47517511943802511092443895822764655e-4966L |
| 4 | #define LDBL_MIN 3.36210314311209350626267781732175260e-4932L | 8 | #define LDBL_MIN 3.36210314311209350626267781732175260e-4932L |
lib/libc/musl/arch/s390x/bits/syscall.h.in+4| ... | @@ -352,4 +352,8 @@ | ... | @@ -352,4 +352,8 @@ |
| 352 | #define __NR_fspick		433 | 352 | #define __NR_fspick		433 |
| 353 | #define __NR_pidfd_open		434 | 353 | #define __NR_pidfd_open		434 |
| 354 | #define __NR_clone3		435 | 354 | #define __NR_clone3		435 |
| 355 | #define __NR_close_range	436 | ||
| 356 | #define __NR_openat2		437 | ||
| 357 | #define __NR_pidfd_getfd	438 | ||
| 358 | #define __NR_faccessat2		439 | ||
| 355 | 359 |
lib/libc/musl/arch/s390x/pthread_arch.h+4-6| ... | @@ -1,14 +1,12 @@ | ... | @@ -1,14 +1,12 @@ |
| 1 | static inline struct pthread *__pthread_self() | 1 | static inline uintptr_t __get_tp() |
| 2 | { | 2 | { |
| 3 | 	struct pthread *self; | 3 | 	uintptr_t tp; |
| 4 | 	__asm__ ( | 4 | 	__asm__ ( |
| 5 | 		"ear %0, %%a0\n" | 5 | 		"ear %0, %%a0\n" |
| 6 | 		"sllg %0, %0, 32\n" | 6 | 		"sllg %0, %0, 32\n" |
| 7 | 		"ear %0, %%a1\n" | 7 | 		"ear %0, %%a1\n" |
| 8 | 		: "=r"(self)); | 8 | 		: "=r"(tp)); |
| 9 | 	return self; | 9 | 	return tp; |
| 10 | } | 10 | } |
| 11 | 11 | ||
| 12 | #define TP_ADJ(p) (p) | ||
| 13 | |||
| 14 | #define MC_PC psw.addr | 12 | #define MC_PC psw.addr |
lib/libc/musl/arch/s390x/syscall_arch.h-2| ... | @@ -72,5 +72,3 @@ static inline long __syscall6(long n, long a, long b, long c, long d, long e, lo | ... | @@ -72,5 +72,3 @@ static inline long __syscall6(long n, long a, long b, long c, long d, long e, lo |
| 72 | 	register long r7 __asm__("r7") = f; | 72 | 	register long r7 __asm__("r7") = f; |
| 73 | 	__asm_syscall("+r"(r2), "r"(r1), "r"(r3), "r"(r4), "r"(r5), "r"(r6), "r"(r7)); | 73 | 	__asm_syscall("+r"(r2), "r"(r1), "r"(r3), "r"(r4), "r"(r5), "r"(r6), "r"(r7)); |
| 74 | } | 74 | } |
| 75 | |||
| 76 | #define SYSCALL_USE_SOCKETCALL |
lib/libc/musl/arch/x86_64/bits/fcntl.h deleted-40| ... | @@ -1,40 +0,0 @@ | ||
| 1 | #define O_CREAT 0100 | ||
| 2 | #define O_EXCL 0200 | ||
| 3 | #define O_NOCTTY 0400 | ||
| 4 | #define O_TRUNC 01000 | ||
| 5 | #define O_APPEND 02000 | ||
| 6 | #define O_NONBLOCK 04000 | ||
| 7 | #define O_DSYNC 010000 | ||
| 8 | #define O_SYNC 04010000 | ||
| 9 | #define O_RSYNC 04010000 | ||
| 10 | #define O_DIRECTORY 0200000 | ||
| 11 | #define O_NOFOLLOW 0400000 | ||
| 12 | #define O_CLOEXEC 02000000 | ||
| 13 | |||
| 14 | #define O_ASYNC 020000 | ||
| 15 | #define O_DIRECT 040000 | ||
| 16 | #define O_LARGEFILE 0 | ||
| 17 | #define O_NOATIME 01000000 | ||
| 18 | #define O_PATH 010000000 | ||
| 19 | #define O_TMPFILE 020200000 | ||
| 20 | #define O_NDELAY O_NONBLOCK | ||
| 21 | |||
| 22 | #define F_DUPFD 0 | ||
| 23 | #define F_GETFD 1 | ||
| 24 | #define F_SETFD 2 | ||
| 25 | #define F_GETFL 3 | ||
| 26 | #define F_SETFL 4 | ||
| 27 | |||
| 28 | #define F_SETOWN 8 | ||
| 29 | #define F_GETOWN 9 | ||
| 30 | #define F_SETSIG 10 | ||
| 31 | #define F_GETSIG 11 | ||
| 32 | |||
| 33 | #define F_GETLK 5 | ||
| 34 | #define F_SETLK 6 | ||
| 35 | #define F_SETLKW 7 | ||
| 36 | |||
| 37 | #define F_SETOWN_EX 15 | ||
| 38 | #define F_GETOWN_EX 16 | ||
| 39 | |||
| 40 | #define F_GETOWNER_UIDS 17 | ||
lib/libc/musl/arch/x86_64/bits/syscall.h.in+4| ... | @@ -345,4 +345,8 @@ | ... | @@ -345,4 +345,8 @@ |
| 345 | #define __NR_fspick		433 | 345 | #define __NR_fspick		433 |
| 346 | #define __NR_pidfd_open		434 | 346 | #define __NR_pidfd_open		434 |
| 347 | #define __NR_clone3		435 | 347 | #define __NR_clone3		435 |
| 348 | #define __NR_close_range	436 | ||
| 349 | #define __NR_openat2		437 | ||
| 350 | #define __NR_pidfd_getfd	438 | ||
| 351 | #define __NR_faccessat2		439 | ||
| 348 | 352 |
lib/libc/musl/arch/x86_64/pthread_arch.h+4-6| ... | @@ -1,10 +1,8 @@ | ... | @@ -1,10 +1,8 @@ |
| 1 | static inline struct pthread *__pthread_self() | 1 | static inline uintptr_t __get_tp() |
| 2 | { | 2 | { |
| 3 | 	struct pthread *self; | 3 | 	uintptr_t tp; |
| 4 | 	__asm__ ("mov %%fs:0,%0" : "=r" (self) ); | 4 | 	__asm__ ("mov %%fs:0,%0" : "=r" (tp) ); |
| 5 | 	return self; | 5 | 	return tp; |
| 6 | } | 6 | } |
| 7 | 7 | ||
| 8 | #define TP_ADJ(p) (p) | ||
| 9 | |||
| 10 | #define MC_PC gregs[REG_RIP] | 8 | #define MC_PC gregs[REG_RIP] |
lib/libc/musl/include/alltypes.h.in+2| ... | @@ -77,6 +77,8 @@ TYPEDEF struct __sigset_t { unsigned long __bits[128/sizeof(long)]; } sigset_t; | ... | @@ -77,6 +77,8 @@ TYPEDEF struct __sigset_t { unsigned long __bits[128/sizeof(long)]; } sigset_t; |
| 77 | 77 | ||
| 78 | STRUCT iovec { void *iov_base; size_t iov_len; }; | 78 | STRUCT iovec { void *iov_base; size_t iov_len; }; |
| 79 | 79 | ||
| 80 | STRUCT winsize { unsigned short ws_row, ws_col, ws_xpixel, ws_ypixel; }; | ||
| 81 | |||
| 80 | TYPEDEF unsigned socklen_t; | 82 | TYPEDEF unsigned socklen_t; |
| 81 | TYPEDEF unsigned short sa_family_t; | 83 | TYPEDEF unsigned short sa_family_t; |
| 82 | 84 |
lib/libc/musl/include/elf.h+2| ... | @@ -603,6 +603,7 @@ typedef struct { | ... | @@ -603,6 +603,7 @@ typedef struct { |
| 603 | #define PT_GNU_EH_FRAME	0x6474e550 | 603 | #define PT_GNU_EH_FRAME	0x6474e550 |
| 604 | #define PT_GNU_STACK	0x6474e551 | 604 | #define PT_GNU_STACK	0x6474e551 |
| 605 | #define PT_GNU_RELRO	0x6474e552 | 605 | #define PT_GNU_RELRO	0x6474e552 |
| 606 | #define PT_GNU_PROPERTY	0x6474e553 | ||
| 606 | #define PT_LOSUNW	0x6ffffffa | 607 | #define PT_LOSUNW	0x6ffffffa |
| 607 | #define PT_SUNWBSS	0x6ffffffa | 608 | #define PT_SUNWBSS	0x6ffffffa |
| 608 | #define PT_SUNWSTACK	0x6ffffffb | 609 | #define PT_SUNWSTACK	0x6ffffffb |
| ... | @@ -1085,6 +1086,7 @@ typedef struct { | ... | @@ -1085,6 +1086,7 @@ typedef struct { |
| 1085 | 1086 | ||
| 1086 | #define NT_GNU_BUILD_ID	3 | 1087 | #define NT_GNU_BUILD_ID	3 |
| 1087 | #define NT_GNU_GOLD_VERSION	4 | 1088 | #define NT_GNU_GOLD_VERSION	4 |
| 1089 | #define NT_GNU_PROPERTY_TYPE_0	5 | ||
| 1088 | 1090 | ||
| 1089 | 1091 | ||
| 1090 | 1092 |
lib/libc/musl/include/netinet/if_ether.h+1| ... | @@ -59,6 +59,7 @@ | ... | @@ -59,6 +59,7 @@ |
| 59 | #define ETH_P_PREAUTH	0x88C7 | 59 | #define ETH_P_PREAUTH	0x88C7 |
| 60 | #define ETH_P_TIPC	0x88CA | 60 | #define ETH_P_TIPC	0x88CA |
| 61 | #define ETH_P_LLDP	0x88CC | 61 | #define ETH_P_LLDP	0x88CC |
| 62 | #define ETH_P_MRP	0x88E3 | ||
| 62 | #define ETH_P_MACSEC	0x88E5 | 63 | #define ETH_P_MACSEC	0x88E5 |
| 63 | #define ETH_P_8021AH	0x88E7 | 64 | #define ETH_P_8021AH	0x88E7 |
| 64 | #define ETH_P_MVRP	0x88F5 | 65 | #define ETH_P_MVRP	0x88F5 |
lib/libc/musl/include/netinet/in.h+4-1| ... | @@ -101,8 +101,10 @@ uint16_t ntohs(uint16_t); | ... | @@ -101,8 +101,10 @@ uint16_t ntohs(uint16_t); |
| 101 | #define IPPROTO_MH 135 | 101 | #define IPPROTO_MH 135 |
| 102 | #define IPPROTO_UDPLITE 136 | 102 | #define IPPROTO_UDPLITE 136 |
| 103 | #define IPPROTO_MPLS 137 | 103 | #define IPPROTO_MPLS 137 |
| 104 | #define IPPROTO_ETHERNET 143 | ||
| 104 | #define IPPROTO_RAW 255 | 105 | #define IPPROTO_RAW 255 |
| 105 | #define IPPROTO_MAX 256 | 106 | #define IPPROTO_MPTCP 262 |
| 107 | #define IPPROTO_MAX 263 | ||
| 106 | 108 | ||
| 107 | #define IN6_IS_ADDR_UNSPECIFIED(a) \ | 109 | #define IN6_IS_ADDR_UNSPECIFIED(a) \ |
| 108 | (((uint32_t *) (a))[0] == 0 && ((uint32_t *) (a))[1] == 0 && \ | 110 | (((uint32_t *) (a))[0] == 0 && ((uint32_t *) (a))[1] == 0 && \ |
| ... | @@ -200,6 +202,7 @@ uint16_t ntohs(uint16_t); | ... | @@ -200,6 +202,7 @@ uint16_t ntohs(uint16_t); |
| 200 | #define IP_CHECKSUM 23 | 202 | #define IP_CHECKSUM 23 |
| 201 | #define IP_BIND_ADDRESS_NO_PORT 24 | 203 | #define IP_BIND_ADDRESS_NO_PORT 24 |
| 202 | #define IP_RECVFRAGSIZE 25 | 204 | #define IP_RECVFRAGSIZE 25 |
| 205 | #define IP_RECVERR_RFC4884 26 | ||
| 203 | #define IP_MULTICAST_IF 32 | 206 | #define IP_MULTICAST_IF 32 |
| 204 | #define IP_MULTICAST_TTL 33 | 207 | #define IP_MULTICAST_TTL 33 |
| 205 | #define IP_MULTICAST_LOOP 34 | 208 | #define IP_MULTICAST_LOOP 34 |
lib/libc/musl/include/netinet/tcp.h+15-3| ... | @@ -78,6 +78,8 @@ enum { | ... | @@ -78,6 +78,8 @@ enum { |
| 78 | 	TCP_NLA_DSACK_DUPS, | 78 | 	TCP_NLA_DSACK_DUPS, |
| 79 | 	TCP_NLA_REORD_SEEN, | 79 | 	TCP_NLA_REORD_SEEN, |
| 80 | 	TCP_NLA_SRTT, | 80 | 	TCP_NLA_SRTT, |
| 81 | 	TCP_NLA_TIMEOUT_REHASH, | ||
| 82 | 	TCP_NLA_BYTES_NOTSENT, | ||
| 81 | }; | 83 | }; |
| 82 | 84 | ||
| 83 | #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) | 85 | #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) |
| ... | @@ -181,6 +183,13 @@ struct tcphdr { | ... | @@ -181,6 +183,13 @@ struct tcphdr { |
| 181 | #define TCP_CA_Recovery		3 | 183 | #define TCP_CA_Recovery		3 |
| 182 | #define TCP_CA_Loss		4 | 184 | #define TCP_CA_Loss		4 |
| 183 | 185 | ||
| 186 | enum tcp_fastopen_client_fail { | ||
| 187 | 	TFO_STATUS_UNSPEC, | ||
| 188 | 	TFO_COOKIE_UNAVAILABLE, | ||
| 189 | 	TFO_DATA_NOT_ACKED, | ||
| 190 | 	TFO_SYN_RETRANSMITTED, | ||
| 191 | }; | ||
| 192 | |||
| 184 | struct tcp_info { | 193 | struct tcp_info { |
| 185 | 	uint8_t tcpi_state; | 194 | 	uint8_t tcpi_state; |
| 186 | 	uint8_t tcpi_ca_state; | 195 | 	uint8_t tcpi_ca_state; |
| ... | @@ -189,7 +198,7 @@ struct tcp_info { | ... | @@ -189,7 +198,7 @@ struct tcp_info { |
| 189 | 	uint8_t tcpi_backoff; | 198 | 	uint8_t tcpi_backoff; |
| 190 | 	uint8_t tcpi_options; | 199 | 	uint8_t tcpi_options; |
| 191 | 	uint8_t tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4; | 200 | 	uint8_t tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4; |
| 192 | 	uint8_t tcpi_delivery_rate_app_limited : 1; | 201 | 	uint8_t tcpi_delivery_rate_app_limited : 1, tcpi_fastopen_client_fail : 2; |
| 193 | 	uint32_t tcpi_rto; | 202 | 	uint32_t tcpi_rto; |
| 194 | 	uint32_t tcpi_ato; | 203 | 	uint32_t tcpi_ato; |
| 195 | 	uint32_t tcpi_snd_mss; | 204 | 	uint32_t tcpi_snd_mss; |
| ... | @@ -240,14 +249,15 @@ struct tcp_info { | ... | @@ -240,14 +249,15 @@ struct tcp_info { |
| 240 | 249 | ||
| 241 | #define TCP_MD5SIG_MAXKEYLEN 80 | 250 | #define TCP_MD5SIG_MAXKEYLEN 80 |
| 242 | 251 | ||
| 243 | #define TCP_MD5SIG_FLAG_PREFIX 1 | 252 | #define TCP_MD5SIG_FLAG_PREFIX 0x1 |
| 253 | #define TCP_MD5SIG_FLAG_IFINDEX 0x2 | ||
| 244 | 254 | ||
| 245 | struct tcp_md5sig { | 255 | struct tcp_md5sig { |
| 246 | 	struct sockaddr_storage tcpm_addr; | 256 | 	struct sockaddr_storage tcpm_addr; |
| 247 | 	uint8_t tcpm_flags; | 257 | 	uint8_t tcpm_flags; |
| 248 | 	uint8_t tcpm_prefixlen; | 258 | 	uint8_t tcpm_prefixlen; |
| 249 | 	uint16_t tcpm_keylen; | 259 | 	uint16_t tcpm_keylen; |
| 250 | 	uint32_t __tcpm_pad; | 260 | 	int tcpm_ifindex; |
| 251 | 	uint8_t tcpm_key[TCP_MD5SIG_MAXKEYLEN]; | 261 | 	uint8_t tcpm_key[TCP_MD5SIG_MAXKEYLEN]; |
| 252 | }; | 262 | }; |
| 253 | 263 | ||
| ... | @@ -275,6 +285,8 @@ struct tcp_zerocopy_receive { | ... | @@ -275,6 +285,8 @@ struct tcp_zerocopy_receive { |
| 275 | 	uint64_t address; | 285 | 	uint64_t address; |
| 276 | 	uint32_t length; | 286 | 	uint32_t length; |
| 277 | 	uint32_t recv_skip_hint; | 287 | 	uint32_t recv_skip_hint; |
| 288 | 	uint32_t inq; | ||
| 289 | 	int32_t err; | ||
| 278 | }; | 290 | }; |
| 279 | 291 | ||
| 280 | #endif | 292 | #endif |
lib/libc/musl/include/netinet/udp.h+1| ... | @@ -35,6 +35,7 @@ struct udphdr { | ... | @@ -35,6 +35,7 @@ struct udphdr { |
| 35 | #define UDP_ENCAP_GTP0		4 | 35 | #define UDP_ENCAP_GTP0		4 |
| 36 | #define UDP_ENCAP_GTP1U		5 | 36 | #define UDP_ENCAP_GTP1U		5 |
| 37 | #define UDP_ENCAP_RXRPC		6 | 37 | #define UDP_ENCAP_RXRPC		6 |
| 38 | #define TCP_ENCAP_ESPINTCP	7 | ||
| 38 | 39 | ||
| 39 | #define SOL_UDP 17 | 40 | #define SOL_UDP 17 |
| 40 | 41 |
lib/libc/musl/include/sched.h+1| ... | @@ -49,6 +49,7 @@ int sched_yield(void); | ... | @@ -49,6 +49,7 @@ int sched_yield(void); |
| 49 | 49 | ||
| 50 | #ifdef _GNU_SOURCE | 50 | #ifdef _GNU_SOURCE |
| 51 | #define CSIGNAL		0x000000ff | 51 | #define CSIGNAL		0x000000ff |
| 52 | #define CLONE_NEWTIME	0x00000080 | ||
| 52 | #define CLONE_VM	0x00000100 | 53 | #define CLONE_VM	0x00000100 |
| 53 | #define CLONE_FS	0x00000200 | 54 | #define CLONE_FS	0x00000200 |
| 54 | #define CLONE_FILES	0x00000400 | 55 | #define CLONE_FILES	0x00000400 |
lib/libc/musl/include/signal.h+13-3| ... | @@ -180,14 +180,24 @@ struct sigevent { | ... | @@ -180,14 +180,24 @@ struct sigevent { |
| 180 | 	union sigval sigev_value; | 180 | 	union sigval sigev_value; |
| 181 | 	int sigev_signo; | 181 | 	int sigev_signo; |
| 182 | 	int sigev_notify; | 182 | 	int sigev_notify; |
| 183 | 	void (*sigev_notify_function)(union sigval); | 183 | 	union { |
| 184 | 	pthread_attr_t *sigev_notify_attributes; | 184 | 		char __pad[64 - 2*sizeof(int) - sizeof(union sigval)]; |
| 185 | 	char __pad[56-3*sizeof(long)]; | 185 | 		pid_t sigev_notify_thread_id; |
| 186 | 		struct { | ||
| 187 | 			void (*sigev_notify_function)(union sigval); | ||
| 188 | 			pthread_attr_t *sigev_notify_attributes; | ||
| 189 | 		} __sev_thread; | ||
| 190 | 	} __sev_fields; | ||
| 186 | }; | 191 | }; |
| 187 | 192 | ||
| 193 | #define sigev_notify_thread_id __sev_fields.sigev_notify_thread_id | ||
| 194 | #define sigev_notify_function __sev_fields.__sev_thread.sigev_notify_function | ||
| 195 | #define sigev_notify_attributes __sev_fields.__sev_thread.sigev_notify_attributes | ||
| 196 | |||
| 188 | #define SIGEV_SIGNAL 0 | 197 | #define SIGEV_SIGNAL 0 |
| 189 | #define SIGEV_NONE 1 | 198 | #define SIGEV_NONE 1 |
| 190 | #define SIGEV_THREAD 2 | 199 | #define SIGEV_THREAD 2 |
| 200 | #define SIGEV_THREAD_ID 4 | ||
| 191 | 201 | ||
| 192 | int __libc_current_sigrtmin(void); | 202 | int __libc_current_sigrtmin(void); |
| 193 | int __libc_current_sigrtmax(void); | 203 | int __libc_current_sigrtmax(void); |
lib/libc/musl/include/stdlib.h+1| ... | @@ -145,6 +145,7 @@ int getloadavg(double *, int); | ... | @@ -145,6 +145,7 @@ int getloadavg(double *, int); |
| 145 | int clearenv(void); | 145 | int clearenv(void); |
| 146 | #define WCOREDUMP(s) ((s) & 0x80) | 146 | #define WCOREDUMP(s) ((s) & 0x80) |
| 147 | #define WIFCONTINUED(s) ((s) == 0xffff) | 147 | #define WIFCONTINUED(s) ((s) == 0xffff) |
| 148 | void *reallocarray (void *, size_t, size_t); | ||
| 148 | #endif | 149 | #endif |
| 149 | 150 | ||
| 150 | #ifdef _GNU_SOURCE | 151 | #ifdef _GNU_SOURCE |
lib/libc/musl/include/sys/fanotify.h+7-1| ... | @@ -55,8 +55,9 @@ struct fanotify_response { | ... | @@ -55,8 +55,9 @@ struct fanotify_response { |
| 55 | #define FAN_OPEN_PERM 0x10000 | 55 | #define FAN_OPEN_PERM 0x10000 |
| 56 | #define FAN_ACCESS_PERM 0x20000 | 56 | #define FAN_ACCESS_PERM 0x20000 |
| 57 | #define FAN_OPEN_EXEC_PERM 0x40000 | 57 | #define FAN_OPEN_EXEC_PERM 0x40000 |
| 58 | #define FAN_ONDIR 0x40000000 | 58 | #define FAN_DIR_MODIFY 0x00080000 |
| 59 | #define FAN_EVENT_ON_CHILD 0x08000000 | 59 | #define FAN_EVENT_ON_CHILD 0x08000000 |
| 60 | #define FAN_ONDIR 0x40000000 | ||
| 60 | #define FAN_CLOSE (FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE) | 61 | #define FAN_CLOSE (FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE) |
| 61 | #define FAN_MOVE (FAN_MOVED_FROM | FAN_MOVED_TO) | 62 | #define FAN_MOVE (FAN_MOVED_FROM | FAN_MOVED_TO) |
| 62 | #define FAN_CLOEXEC 0x01 | 63 | #define FAN_CLOEXEC 0x01 |
| ... | @@ -70,6 +71,9 @@ struct fanotify_response { | ... | @@ -70,6 +71,9 @@ struct fanotify_response { |
| 70 | #define FAN_ENABLE_AUDIT 0x40 | 71 | #define FAN_ENABLE_AUDIT 0x40 |
| 71 | #define FAN_REPORT_TID 0x100 | 72 | #define FAN_REPORT_TID 0x100 |
| 72 | #define FAN_REPORT_FID 0x200 | 73 | #define FAN_REPORT_FID 0x200 |
| 74 | #define FAN_REPORT_DIR_FID 0x00000400 | ||
| 75 | #define FAN_REPORT_NAME 0x00000800 | ||
| 76 | #define FAN_REPORT_DFID_NAME (FAN_REPORT_DIR_FID | FAN_REPORT_NAME) | ||
| 73 | #define FAN_ALL_INIT_FLAGS (FAN_CLOEXEC | FAN_NONBLOCK | FAN_ALL_CLASS_BITS | FAN_UNLIMITED_QUEUE | FAN_UNLIMITED_MARKS) | 77 | #define FAN_ALL_INIT_FLAGS (FAN_CLOEXEC | FAN_NONBLOCK | FAN_ALL_CLASS_BITS | FAN_UNLIMITED_QUEUE | FAN_UNLIMITED_MARKS) |
| 74 | #define FAN_MARK_ADD 0x01 | 78 | #define FAN_MARK_ADD 0x01 |
| 75 | #define FAN_MARK_REMOVE 0x02 | 79 | #define FAN_MARK_REMOVE 0x02 |
| ... | @@ -88,6 +92,8 @@ struct fanotify_response { | ... | @@ -88,6 +92,8 @@ struct fanotify_response { |
| 88 | #define FAN_ALL_OUTGOING_EVENTS (FAN_ALL_EVENTS | FAN_ALL_PERM_EVENTS | FAN_Q_OVERFLOW) | 92 | #define FAN_ALL_OUTGOING_EVENTS (FAN_ALL_EVENTS | FAN_ALL_PERM_EVENTS | FAN_Q_OVERFLOW) |
| 89 | #define FANOTIFY_METADATA_VERSION 3 | 93 | #define FANOTIFY_METADATA_VERSION 3 |
| 90 | #define FAN_EVENT_INFO_TYPE_FID 1 | 94 | #define FAN_EVENT_INFO_TYPE_FID 1 |
| 95 | #define FAN_EVENT_INFO_TYPE_DFID_NAME 2 | ||
| 96 | #define FAN_EVENT_INFO_TYPE_DFID 3 | ||
| 91 | #define FAN_ALLOW 0x01 | 97 | #define FAN_ALLOW 0x01 |
| 92 | #define FAN_DENY 0x02 | 98 | #define FAN_DENY 0x02 |
| 93 | #define FAN_AUDIT 0x10 | 99 | #define FAN_AUDIT 0x10 |
lib/libc/musl/include/sys/ioctl.h+2-7| ... | @@ -4,6 +4,8 @@ | ... | @@ -4,6 +4,8 @@ |
| 4 | extern "C" { | 4 | extern "C" { |
| 5 | #endif | 5 | #endif |
| 6 | 6 | ||
| 7 | #define __NEED_struct_winsize | ||
| 8 | |||
| 7 | #include <bits/alltypes.h> | 9 | #include <bits/alltypes.h> |
| 8 | #include <bits/ioctl.h> | 10 | #include <bits/ioctl.h> |
| 9 | 11 | ||
| ... | @@ -47,13 +49,6 @@ extern "C" { | ... | @@ -47,13 +49,6 @@ extern "C" { |
| 47 | 49 | ||
| 48 | #define TIOCSER_TEMT 1 | 50 | #define TIOCSER_TEMT 1 |
| 49 | 51 | ||
| 50 | struct winsize { | ||
| 51 | 	unsigned short ws_row; | ||
| 52 | 	unsigned short ws_col; | ||
| 53 | 	unsigned short ws_xpixel; | ||
| 54 | 	unsigned short ws_ypixel; | ||
| 55 | }; | ||
| 56 | |||
| 57 | #define SIOCADDRT 0x890B | 52 | #define SIOCADDRT 0x890B |
| 58 | #define SIOCDELRT 0x890C | 53 | #define SIOCDELRT 0x890C |
| 59 | #define SIOCRTMSG 0x890D | 54 | #define SIOCRTMSG 0x890D |
lib/libc/musl/include/sys/mman.h+1| ... | @@ -101,6 +101,7 @@ extern "C" { | ... | @@ -101,6 +101,7 @@ extern "C" { |
| 101 | #ifdef _GNU_SOURCE | 101 | #ifdef _GNU_SOURCE |
| 102 | #define MREMAP_MAYMOVE 1 | 102 | #define MREMAP_MAYMOVE 1 |
| 103 | #define MREMAP_FIXED 2 | 103 | #define MREMAP_FIXED 2 |
| 104 | #define MREMAP_DONTUNMAP 4 | ||
| 104 | 105 | ||
| 105 | #define MLOCK_ONFAULT 0x01 | 106 | #define MLOCK_ONFAULT 0x01 |
| 106 | 107 |
lib/libc/musl/include/sys/personality.h+3| ... | @@ -5,7 +5,9 @@ | ... | @@ -5,7 +5,9 @@ |
| 5 | extern "C" { | 5 | extern "C" { |
| 6 | #endif | 6 | #endif |
| 7 | 7 | ||
| 8 | #define UNAME26 0x0020000 | ||
| 8 | #define ADDR_NO_RANDOMIZE 0x0040000 | 9 | #define ADDR_NO_RANDOMIZE 0x0040000 |
| 10 | #define FDPIC_FUNCPTRS 0x0080000 | ||
| 9 | #define MMAP_PAGE_ZERO 0x0100000 | 11 | #define MMAP_PAGE_ZERO 0x0100000 |
| 10 | #define ADDR_COMPAT_LAYOUT 0x0200000 | 12 | #define ADDR_COMPAT_LAYOUT 0x0200000 |
| 11 | #define READ_IMPLIES_EXEC 0x0400000 | 13 | #define READ_IMPLIES_EXEC 0x0400000 |
| ... | @@ -17,6 +19,7 @@ extern "C" { | ... | @@ -17,6 +19,7 @@ extern "C" { |
| 17 | 19 | ||
| 18 | #define PER_LINUX 0 | 20 | #define PER_LINUX 0 |
| 19 | #define PER_LINUX_32BIT ADDR_LIMIT_32BIT | 21 | #define PER_LINUX_32BIT ADDR_LIMIT_32BIT |
| 22 | #define PER_LINUX_FDPIC FDPIC_FUNCPTRS | ||
| 20 | #define PER_SVR4 (1 | STICKY_TIMEOUTS | MMAP_PAGE_ZERO) | 23 | #define PER_SVR4 (1 | STICKY_TIMEOUTS | MMAP_PAGE_ZERO) |
| 21 | #define PER_SVR3 (2 | STICKY_TIMEOUTS | SHORT_INODE) | 24 | #define PER_SVR3 (2 | STICKY_TIMEOUTS | SHORT_INODE) |
| 22 | #define PER_SCOSVR3 (3 | STICKY_TIMEOUTS | WHOLE_SECONDS | SHORT_INODE) | 25 | #define PER_SCOSVR3 (3 | STICKY_TIMEOUTS | WHOLE_SECONDS | SHORT_INODE) |
lib/libc/musl/include/sys/prctl.h+3| ... | @@ -158,6 +158,9 @@ struct prctl_mm_map { | ... | @@ -158,6 +158,9 @@ struct prctl_mm_map { |
| 158 | #define PR_GET_TAGGED_ADDR_CTRL 56 | 158 | #define PR_GET_TAGGED_ADDR_CTRL 56 |
| 159 | #define PR_TAGGED_ADDR_ENABLE (1UL << 0) | 159 | #define PR_TAGGED_ADDR_ENABLE (1UL << 0) |
| 160 | 160 | ||
| 161 | #define PR_SET_IO_FLUSHER 57 | ||
| 162 | #define PR_GET_IO_FLUSHER 58 | ||
| 163 | |||
| 161 | int prctl (int, ...); | 164 | int prctl (int, ...); |
| 162 | 165 | ||
| 163 | #ifdef __cplusplus | 166 | #ifdef __cplusplus |
lib/libc/musl/include/sys/random.h+1| ... | @@ -10,6 +10,7 @@ extern "C" { | ... | @@ -10,6 +10,7 @@ extern "C" { |
| 10 | 10 | ||
| 11 | #define GRND_NONBLOCK	0x0001 | 11 | #define GRND_NONBLOCK	0x0001 |
| 12 | #define GRND_RANDOM	0x0002 | 12 | #define GRND_RANDOM	0x0002 |
| 13 | #define GRND_INSECURE	0x0004 | ||
| 13 | 14 | ||
| 14 | ssize_t getrandom(void *, size_t, unsigned); | 15 | ssize_t getrandom(void *, size_t, unsigned); |
| 15 | 16 |
lib/libc/musl/include/termios.h+4| ... | @@ -8,6 +8,7 @@ extern "C" { | ... | @@ -8,6 +8,7 @@ extern "C" { |
| 8 | #include <features.h> | 8 | #include <features.h> |
| 9 | 9 | ||
| 10 | #define __NEED_pid_t | 10 | #define __NEED_pid_t |
| 11 | #define __NEED_struct_winsize | ||
| 11 | 12 | ||
| 12 | #include <bits/alltypes.h> | 13 | #include <bits/alltypes.h> |
| 13 | 14 | ||
| ... | @@ -27,6 +28,9 @@ int cfsetispeed (struct termios *, speed_t); | ... | @@ -27,6 +28,9 @@ int cfsetispeed (struct termios *, speed_t); |
| 27 | int tcgetattr (int, struct termios *); | 28 | int tcgetattr (int, struct termios *); |
| 28 | int tcsetattr (int, int, const struct termios *); | 29 | int tcsetattr (int, int, const struct termios *); |
| 29 | 30 | ||
| 31 | int tcgetwinsize (int, struct winsize *); | ||
| 32 | int tcsetwinsize (int, const struct winsize *); | ||
| 33 | |||
| 30 | int tcsendbreak (int, int); | 34 | int tcsendbreak (int, int); |
| 31 | int tcdrain (int); | 35 | int tcdrain (int); |
| 32 | int tcflush (int, int); | 36 | int tcflush (int, int); |
lib/libc/musl/include/unistd.h+2| ... | @@ -82,6 +82,7 @@ unsigned sleep(unsigned); | ... | @@ -82,6 +82,7 @@ unsigned sleep(unsigned); |
| 82 | int pause(void); | 82 | int pause(void); |
| 83 | 83 | ||
| 84 | pid_t fork(void); | 84 | pid_t fork(void); |
| 85 | pid_t _Fork(void); | ||
| 85 | int execve(const char *, char *const [], char *const []); | 86 | int execve(const char *, char *const [], char *const []); |
| 86 | int execv(const char *, char *const []); | 87 | int execv(const char *, char *const []); |
| 87 | int execle(const char *, const char *, ...); | 88 | int execle(const char *, const char *, ...); |
| ... | @@ -190,6 +191,7 @@ int syncfs(int); | ... | @@ -190,6 +191,7 @@ int syncfs(int); |
| 190 | int euidaccess(const char *, int); | 191 | int euidaccess(const char *, int); |
| 191 | int eaccess(const char *, int); | 192 | int eaccess(const char *, int); |
| 192 | ssize_t copy_file_range(int, off_t *, int, off_t *, size_t, unsigned); | 193 | ssize_t copy_file_range(int, off_t *, int, off_t *, size_t, unsigned); |
| 194 | pid_t gettid(void); | ||
| 193 | #endif | 195 | #endif |
| 194 | 196 | ||
| 195 | #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) | 197 | #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) |
lib/libc/musl/libc.s+16-1| ... | @@ -105,6 +105,9 @@ in6addr_loopback: | ... | @@ -105,6 +105,9 @@ in6addr_loopback: |
| 105 | .globl _Exit | 105 | .globl _Exit |
| 106 | .type _Exit, %function; | 106 | .type _Exit, %function; |
| 107 | _Exit: | 107 | _Exit: |
| 108 | .globl _Fork | ||
| 109 | .type _Fork, %function; | ||
| 110 | _Fork: | ||
| 108 | .weak _IO_feof_unlocked | 111 | .weak _IO_feof_unlocked |
| 109 | .type _IO_feof_unlocked, %function; | 112 | .type _IO_feof_unlocked, %function; |
| 110 | _IO_feof_unlocked: | 113 | _IO_feof_unlocked: |
| ... | @@ -2116,6 +2119,9 @@ getsubopt: | ... | @@ -2116,6 +2119,9 @@ getsubopt: |
| 2116 | .globl gettext | 2119 | .globl gettext |
| 2117 | .type gettext, %function; | 2120 | .type gettext, %function; |
| 2118 | gettext: | 2121 | gettext: |
| 2122 | .globl gettid | ||
| 2123 | .type gettid, %function; | ||
| 2124 | gettid: | ||
| 2119 | .globl gettimeofday | 2125 | .globl gettimeofday |
| 2120 | .type gettimeofday, %function; | 2126 | .type gettimeofday, %function; |
| 2121 | gettimeofday: | 2127 | gettimeofday: |
| ... | @@ -2728,7 +2734,7 @@ lutimes: | ... | @@ -2728,7 +2734,7 @@ lutimes: |
| 2728 | .weak madvise | 2734 | .weak madvise |
| 2729 | .type madvise, %function; | 2735 | .type madvise, %function; |
| 2730 | madvise: | 2736 | madvise: |
| 2731 | .globl malloc | 2737 | .weak malloc |
| 2732 | .type malloc, %function; | 2738 | .type malloc, %function; |
| 2733 | malloc: | 2739 | malloc: |
| 2734 | .globl malloc_usable_size | 2740 | .globl malloc_usable_size |
| ... | @@ -3709,6 +3715,9 @@ readv: | ... | @@ -3709,6 +3715,9 @@ readv: |
| 3709 | .globl realloc | 3715 | .globl realloc |
| 3710 | .type realloc, %function; | 3716 | .type realloc, %function; |
| 3711 | realloc: | 3717 | realloc: |
| 3718 | .globl reallocarray | ||
| 3719 | .type reallocarray, %function; | ||
| 3720 | reallocarray: | ||
| 3712 | .globl realpath | 3721 | .globl realpath |
| 3713 | .type realpath, %function; | 3722 | .type realpath, %function; |
| 3714 | realpath: | 3723 | realpath: |
| ... | @@ -4543,6 +4552,9 @@ tcgetpgrp: | ... | @@ -4543,6 +4552,9 @@ tcgetpgrp: |
| 4543 | .globl tcgetsid | 4552 | .globl tcgetsid |
| 4544 | .type tcgetsid, %function; | 4553 | .type tcgetsid, %function; |
| 4545 | tcgetsid: | 4554 | tcgetsid: |
| 4555 | .globl tcgetwinsize | ||
| 4556 | .type tcgetwinsize, %function; | ||
| 4557 | tcgetwinsize: | ||
| 4546 | .globl tcsendbreak | 4558 | .globl tcsendbreak |
| 4547 | .type tcsendbreak, %function; | 4559 | .type tcsendbreak, %function; |
| 4548 | tcsendbreak: | 4560 | tcsendbreak: |
| ... | @@ -4552,6 +4564,9 @@ tcsetattr: | ... | @@ -4552,6 +4564,9 @@ tcsetattr: |
| 4552 | .globl tcsetpgrp | 4564 | .globl tcsetpgrp |
| 4553 | .type tcsetpgrp, %function; | 4565 | .type tcsetpgrp, %function; |
| 4554 | tcsetpgrp: | 4566 | tcsetpgrp: |
| 4567 | .globl tcsetwinsize | ||
| 4568 | .type tcsetwinsize, %function; | ||
| 4569 | tcsetwinsize: | ||
| 4555 | .globl tdelete | 4570 | .globl tdelete |
| 4556 | .type tdelete, %function; | 4571 | .type tdelete, %function; |
| 4557 | tdelete: | 4572 | tdelete: |
lib/libc/musl/src/aio/aio.c+28-10| ... | @@ -9,6 +9,12 @@ | ... | @@ -9,6 +9,12 @@ |
| 9 | #include "syscall.h" | 9 | #include "syscall.h" |
| 10 | #include "atomic.h" | 10 | #include "atomic.h" |
| 11 | #include "pthread_impl.h" | 11 | #include "pthread_impl.h" |
| 12 | #include "aio_impl.h" | ||
| 13 | |||
| 14 | #define malloc __libc_malloc | ||
| 15 | #define calloc __libc_calloc | ||
| 16 | #define realloc __libc_realloc | ||
| 17 | #define free __libc_free | ||
| 12 | 18 | ||
| 13 | /* The following is a threads-based implementation of AIO with minimal | 19 | /* The following is a threads-based implementation of AIO with minimal |
| 14 | * dependence on implementation details. Most synchronization is | 20 | * dependence on implementation details. Most synchronization is |
| ... | @@ -70,6 +76,10 @@ static struct aio_queue *****map; | ... | @@ -70,6 +76,10 @@ static struct aio_queue *****map; |
| 70 | static volatile int aio_fd_cnt; | 76 | static volatile int aio_fd_cnt; |
| 71 | volatile int __aio_fut; | 77 | volatile int __aio_fut; |
| 72 | 78 | ||
| 79 | static size_t io_thread_stack_size; | ||
| 80 | |||
| 81 | #define MAX(a,b) ((a)>(b) ? (a) : (b)) | ||
| 82 | |||
| 73 | static struct aio_queue *__aio_get_queue(int fd, int need) | 83 | static struct aio_queue *__aio_get_queue(int fd, int need) |
| 74 | { | 84 | { |
| 75 | 	if (fd < 0) { | 85 | 	if (fd < 0) { |
| ... | @@ -84,6 +94,10 @@ static struct aio_queue *__aio_get_queue(int fd, int need) | ... | @@ -84,6 +94,10 @@ static struct aio_queue *__aio_get_queue(int fd, int need) |
| 84 | 		pthread_rwlock_unlock(&maplock); | 94 | 		pthread_rwlock_unlock(&maplock); |
| 85 | 		if (fcntl(fd, F_GETFD) < 0) return 0; | 95 | 		if (fcntl(fd, F_GETFD) < 0) return 0; |
| 86 | 		pthread_rwlock_wrlock(&maplock); | 96 | 		pthread_rwlock_wrlock(&maplock); |
| 97 | 		if (!io_thread_stack_size) { | ||
| 98 | 			unsigned long val = __getauxval(AT_MINSIGSTKSZ); | ||
| 99 | 			io_thread_stack_size = MAX(MINSIGSTKSZ+2048, val+512); | ||
| 100 | 		} | ||
| 87 | 		if (!map) map = calloc(sizeof *map, (-1U/2+1)>>24); | 101 | 		if (!map) map = calloc(sizeof *map, (-1U/2+1)>>24); |
| 88 | 		if (!map) goto out; | 102 | 		if (!map) goto out; |
| 89 | 		if (!map[a]) map[a] = calloc(sizeof **map, 256); | 103 | 		if (!map[a]) map[a] = calloc(sizeof **map, 256); |
| ... | @@ -259,15 +273,6 @@ static void *io_thread_func(void *ctx) | ... | @@ -259,15 +273,6 @@ static void *io_thread_func(void *ctx) |
| 259 | 	return 0; | 273 | 	return 0; |
| 260 | } | 274 | } |
| 261 | 275 | ||
| 262 | static size_t io_thread_stack_size = MINSIGSTKSZ+2048; | ||
| 263 | static pthread_once_t init_stack_size_once; | ||
| 264 | |||
| 265 | static void init_stack_size() | ||
| 266 | { | ||
| 267 | 	unsigned long val = __getauxval(AT_MINSIGSTKSZ); | ||
| 268 | 	if (val > MINSIGSTKSZ) io_thread_stack_size = val + 512; | ||
| 269 | } | ||
| 270 | |||
| 271 | static int submit(struct aiocb *cb, int op) | 276 | static int submit(struct aiocb *cb, int op) |
| 272 | { | 277 | { |
| 273 | 	int ret = 0; | 278 | 	int ret = 0; |
| ... | @@ -293,7 +298,6 @@ static int submit(struct aiocb *cb, int op) | ... | @@ -293,7 +298,6 @@ static int submit(struct aiocb *cb, int op) |
| 293 | 		else | 298 | 		else |
| 294 | 			pthread_attr_init(&a); | 299 | 			pthread_attr_init(&a); |
| 295 | 	} else { | 300 | 	} else { |
| 296 | 		pthread_once(&init_stack_size_once, init_stack_size); | ||
| 297 | 		pthread_attr_init(&a); | 301 | 		pthread_attr_init(&a); |
| 298 | 		pthread_attr_setstacksize(&a, io_thread_stack_size); | 302 | 		pthread_attr_setstacksize(&a, io_thread_stack_size); |
| 299 | 		pthread_attr_setguardsize(&a, 0); | 303 | 		pthread_attr_setguardsize(&a, 0); |
| ... | @@ -392,6 +396,20 @@ int __aio_close(int fd) | ... | @@ -392,6 +396,20 @@ int __aio_close(int fd) |
| 392 | 	return fd; | 396 | 	return fd; |
| 393 | } | 397 | } |
| 394 | 398 | ||
| 399 | void __aio_atfork(int who) | ||
| 400 | { | ||
| 401 | 	if (who<0) { | ||
| 402 | 		pthread_rwlock_rdlock(&maplock); | ||
| 403 | 		return; | ||
| 404 | 	} | ||
| 405 | 	if (who>0 && map) for (int a=0; a<(-1U/2+1)>>24; a++) | ||
| 406 | 		if (map[a]) for (int b=0; b<256; b++) | ||
| 407 | 			if (map[a][b]) for (int c=0; c<256; c++) | ||
| 408 | 				if (map[a][b][c]) for (int d=0; d<256; d++) | ||
| 409 | 					map[a][b][c][d] = 0; | ||
| 410 | 	pthread_rwlock_unlock(&maplock); | ||
| 411 | } | ||
| 412 | |||
| 395 | weak_alias(aio_cancel, aio_cancel64); | 413 | weak_alias(aio_cancel, aio_cancel64); |
| 396 | weak_alias(aio_error, aio_error64); | 414 | weak_alias(aio_error, aio_error64); |
| 397 | weak_alias(aio_fsync, aio_fsync64); | 415 | weak_alias(aio_fsync, aio_fsync64); |
lib/libc/musl/src/aio/aio_suspend.c+1| ... | @@ -3,6 +3,7 @@ | ... | @@ -3,6 +3,7 @@ |
| 3 | #include <time.h> | 3 | #include <time.h> |
| 4 | #include "atomic.h" | 4 | #include "atomic.h" |
| 5 | #include "pthread_impl.h" | 5 | #include "pthread_impl.h" |
| 6 | #include "aio_impl.h" | ||
| 6 | 7 | ||
| 7 | int aio_suspend(const struct aiocb *const cbs[], int cnt, const struct timespec *ts) | 8 | int aio_suspend(const struct aiocb *const cbs[], int cnt, const struct timespec *ts) |
| 8 | { | 9 | { |
lib/libc/musl/src/crypt/crypt_blowfish.c+23-15| ... | @@ -15,7 +15,7 @@ | ... | @@ -15,7 +15,7 @@ |
| 15 | * No copyright is claimed, and the software is hereby placed in the public | 15 | * No copyright is claimed, and the software is hereby placed in the public |
| 16 | * domain. In case this attempt to disclaim copyright and place the software | 16 | * domain. In case this attempt to disclaim copyright and place the software |
| 17 | * in the public domain is deemed null and void, then the software is | 17 | * in the public domain is deemed null and void, then the software is |
| 18 | * Copyright (c) 1998-2012 Solar Designer and it is hereby released to the | 18 | * Copyright (c) 1998-2014 Solar Designer and it is hereby released to the |
| 19 | * general public under the following terms: | 19 | * general public under the following terms: |
| 20 | * | 20 | * |
| 21 | * Redistribution and use in source and binary forms, with or without | 21 | * Redistribution and use in source and binary forms, with or without |
| ... | @@ -31,12 +31,12 @@ | ... | @@ -31,12 +31,12 @@ |
| 31 | * you place this code and any modifications you make under a license | 31 | * you place this code and any modifications you make under a license |
| 32 | * of your choice. | 32 | * of your choice. |
| 33 | * | 33 | * |
| 34 | * This implementation is mostly compatible with OpenBSD's bcrypt.c (prefix | 34 | * This implementation is fully compatible with OpenBSD's bcrypt.c for prefix |
| 35 | * "$2a$") by Niels Provos <provos at citi.umich.edu>, and uses some of his | 35 | * "$2b$", originally by Niels Provos <provos at citi.umich.edu>, and it uses |
| 36 | * ideas. The password hashing algorithm was designed by David Mazieres | 36 | * some of his ideas. The password hashing algorithm was designed by David |
| 37 | * <dm at lcs.mit.edu>. For more information on the level of compatibility, | 37 | * Mazieres <dm at lcs.mit.edu>. For information on the level of |
| 38 | * please refer to the comments in BF_set_key() below and to the included | 38 | * compatibility for bcrypt hash prefixes other than "$2b$", please refer to |
| 39 | * crypt(3) man page. | 39 | * the comments in BF_set_key() below and to the included crypt(3) man page. |
| 40 | * | 40 | * |
| 41 | * There's a paper on the algorithm that explains its design decisions: | 41 | * There's a paper on the algorithm that explains its design decisions: |
| 42 | * | 42 | * |
| ... | @@ -533,6 +533,7 @@ static void BF_set_key(const char *key, BF_key expanded, BF_key initial, | ... | @@ -533,6 +533,7 @@ static void BF_set_key(const char *key, BF_key expanded, BF_key initial, |
| 533 | * Valid combinations of settings are: | 533 | * Valid combinations of settings are: |
| 534 | * | 534 | * |
| 535 | * Prefix "$2a$": bug = 0, safety = 0x10000 | 535 | * Prefix "$2a$": bug = 0, safety = 0x10000 |
| 536 | * Prefix "$2b$": bug = 0, safety = 0 | ||
| 536 | * Prefix "$2x$": bug = 1, safety = 0 | 537 | * Prefix "$2x$": bug = 1, safety = 0 |
| 537 | * Prefix "$2y$": bug = 0, safety = 0 | 538 | * Prefix "$2y$": bug = 0, safety = 0 |
| 538 | */ | 539 | */ |
| ... | @@ -596,12 +597,14 @@ static void BF_set_key(const char *key, BF_key expanded, BF_key initial, | ... | @@ -596,12 +597,14 @@ static void BF_set_key(const char *key, BF_key expanded, BF_key initial, |
| 596 | 	initial[0] ^= sign; | 597 | 	initial[0] ^= sign; |
| 597 | } | 598 | } |
| 598 | 599 | ||
| 600 | static const unsigned char flags_by_subtype[26] = { | ||
| 601 | 	2, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 602 | 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 4, 0 | ||
| 603 | }; | ||
| 604 | |||
| 599 | static char *BF_crypt(const char *key, const char *setting, | 605 | static char *BF_crypt(const char *key, const char *setting, |
| 600 | 	char *output, BF_word min) | 606 | 	char *output, BF_word min) |
| 601 | { | 607 | { |
| 602 | 	static const unsigned char flags_by_subtype[26] = | ||
| 603 | 		{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 604 | 		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 4, 0}; | ||
| 605 | 	struct { | 608 | 	struct { |
| 606 | 		BF_ctx ctx; | 609 | 		BF_ctx ctx; |
| 607 | 		BF_key expanded_key; | 610 | 		BF_key expanded_key; |
| ... | @@ -746,9 +749,11 @@ char *__crypt_blowfish(const char *key, const char *setting, char *output) | ... | @@ -746,9 +749,11 @@ char *__crypt_blowfish(const char *key, const char *setting, char *output) |
| 746 | { | 749 | { |
| 747 | 	const char *test_key = "8b \xd0\xc1\xd2\xcf\xcc\xd8"; | 750 | 	const char *test_key = "8b \xd0\xc1\xd2\xcf\xcc\xd8"; |
| 748 | 	const char *test_setting = "$2a$00$abcdefghijklmnopqrstuu"; | 751 | 	const char *test_setting = "$2a$00$abcdefghijklmnopqrstuu"; |
| 749 | 	static const char test_hash[2][34] = | 752 | 	static const char test_hashes[2][34] = { |
| 750 | 		{"VUrPmXD6q/nVSSp7pNDhCR9071IfIRe\0\x55", /* $2x$ */ | 753 | 		"i1D709vfamulimlGcq0qq3UvuUasvEa\0\x55", /* 'a', 'b', 'y' */ |
| 751 | 		"i1D709vfamulimlGcq0qq3UvuUasvEa\0\x55"}; /* $2a$, $2y$ */ | 754 | 		"VUrPmXD6q/nVSSp7pNDhCR9071IfIRe\0\x55", /* 'x' */ |
| 755 | 	}; | ||
| 756 | 	const char *test_hash = test_hashes[0]; | ||
| 752 | 	char *retval; | 757 | 	char *retval; |
| 753 | 	const char *p; | 758 | 	const char *p; |
| 754 | 	int ok; | 759 | 	int ok; |
| ... | @@ -768,8 +773,11 @@ char *__crypt_blowfish(const char *key, const char *setting, char *output) | ... | @@ -768,8 +773,11 @@ char *__crypt_blowfish(const char *key, const char *setting, char *output) |
| 768 | * detected by the self-test. | 773 | * detected by the self-test. |
| 769 | */ | 774 | */ |
| 770 | 	memcpy(buf.s, test_setting, sizeof(buf.s)); | 775 | 	memcpy(buf.s, test_setting, sizeof(buf.s)); |
| 771 | 	if (retval) | 776 | 	if (retval) { |
| 777 | 		unsigned int flags = flags_by_subtype[setting[2] - 'a']; | ||
| 778 | 		test_hash = test_hashes[flags & 1]; | ||
| 772 | 		buf.s[2] = setting[2]; | 779 | 		buf.s[2] = setting[2]; |
| 780 | 	} | ||
| 773 | 	memset(buf.o, 0x55, sizeof(buf.o)); | 781 | 	memset(buf.o, 0x55, sizeof(buf.o)); |
| 774 | 	buf.o[sizeof(buf.o) - 1] = 0; | 782 | 	buf.o[sizeof(buf.o) - 1] = 0; |
| 775 | 	p = BF_crypt(test_key, buf.s, buf.o, 1); | 783 | 	p = BF_crypt(test_key, buf.s, buf.o, 1); |
| ... | @@ -777,7 +785,7 @@ char *__crypt_blowfish(const char *key, const char *setting, char *output) | ... | @@ -777,7 +785,7 @@ char *__crypt_blowfish(const char *key, const char *setting, char *output) |
| 777 | 	ok = (p == buf.o && | 785 | 	ok = (p == buf.o && |
| 778 | 	 !memcmp(p, buf.s, 7 + 22) && | 786 | 	 !memcmp(p, buf.s, 7 + 22) && |
| 779 | 	 !memcmp(p + (7 + 22), | 787 | 	 !memcmp(p + (7 + 22), |
| 780 | 	 test_hash[buf.s[2] & 1], | 788 | 	 test_hash, |
| 781 | 	 31 + 1 + 1 + 1)); | 789 | 	 31 + 1 + 1 + 1)); |
| 782 | 790 | ||
| 783 | 	{ | 791 | 	{ |
lib/libc/musl/src/env/__init_tls.c+1-1| ... | @@ -67,7 +67,7 @@ void *__copy_tls(unsigned char *mem) | ... | @@ -67,7 +67,7 @@ void *__copy_tls(unsigned char *mem) |
| 67 | 	} | 67 | 	} |
| 68 | #endif | 68 | #endif |
| 69 | 	dtv[0] = libc.tls_cnt; | 69 | 	dtv[0] = libc.tls_cnt; |
| 70 | 	td->dtv = td->dtv_copy = dtv; | 70 | 	td->dtv = dtv; |
| 71 | 	return td; | 71 | 	return td; |
| 72 | } | 72 | } |
| 73 | 73 |
lib/libc/musl/src/env/__stack_chk_fail.c+1-1| ... | @@ -9,7 +9,7 @@ void __init_ssp(void *entropy) | ... | @@ -9,7 +9,7 @@ void __init_ssp(void *entropy) |
| 9 | 	if (entropy) memcpy(&__stack_chk_guard, entropy, sizeof(uintptr_t)); | 9 | 	if (entropy) memcpy(&__stack_chk_guard, entropy, sizeof(uintptr_t)); |
| 10 | 	else __stack_chk_guard = (uintptr_t)&__stack_chk_guard * 1103515245; | 10 | 	else __stack_chk_guard = (uintptr_t)&__stack_chk_guard * 1103515245; |
| 11 | 11 | ||
| 12 | 	__pthread_self()->CANARY = __stack_chk_guard; | 12 | 	__pthread_self()->canary = __stack_chk_guard; |
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | void __stack_chk_fail(void) | 15 | void __stack_chk_fail(void) |
lib/libc/musl/src/exit/abort.c-2| ... | @@ -6,8 +6,6 @@ | ... | @@ -6,8 +6,6 @@ |
| 6 | #include "lock.h" | 6 | #include "lock.h" |
| 7 | #include "ksigaction.h" | 7 | #include "ksigaction.h" |
| 8 | 8 | ||
| 9 | hidden volatile int __abort_lock[1]; | ||
| 10 | |||
| 11 | _Noreturn void abort(void) | 9 | _Noreturn void abort(void) |
| 12 | { | 10 | { |
| 13 | 	raise(SIGABRT); | 11 | 	raise(SIGABRT); |
lib/libc/musl/src/exit/abort_lock.c created+3| ... | @@ -0,0 +1,3 @@ | ||
| 1 | #include "pthread_impl.h" | ||
| 2 | |||
| 3 | volatile int __abort_lock[1]; | ||
lib/libc/musl/src/exit/assert.c-1| ... | @@ -4,6 +4,5 @@ | ... | @@ -4,6 +4,5 @@ |
| 4 | _Noreturn void __assert_fail(const char *expr, const char *file, int line, const char *func) | 4 | _Noreturn void __assert_fail(const char *expr, const char *file, int line, const char *func) |
| 5 | { | 5 | { |
| 6 | 	fprintf(stderr, "Assertion failed: %s (%s: %s: %d)\n", expr, file, func, line); | 6 | 	fprintf(stderr, "Assertion failed: %s (%s: %s: %d)\n", expr, file, func, line); |
| 7 | 	fflush(NULL); | ||
| 8 | 	abort(); | 7 | 	abort(); |
| 9 | } | 8 | } |
lib/libc/musl/src/exit/at_quick_exit.c+2| ... | @@ -1,12 +1,14 @@ | ... | @@ -1,12 +1,14 @@ |
| 1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
| 2 | #include "libc.h" | 2 | #include "libc.h" |
| 3 | #include "lock.h" | 3 | #include "lock.h" |
| 4 | #include "fork_impl.h" | ||
| 4 | 5 | ||
| 5 | #define COUNT 32 | 6 | #define COUNT 32 |
| 6 | 7 | ||
| 7 | static void (*funcs[COUNT])(void); | 8 | static void (*funcs[COUNT])(void); |
| 8 | static int count; | 9 | static int count; |
| 9 | static volatile int lock[1]; | 10 | static volatile int lock[1]; |
| 11 | volatile int *const __at_quick_exit_lockptr = lock; | ||
| 10 | 12 | ||
| 11 | void __funcs_on_quick_exit() | 13 | void __funcs_on_quick_exit() |
| 12 | { | 14 | { |
lib/libc/musl/src/exit/atexit.c+7| ... | @@ -2,6 +2,12 @@ | ... | @@ -2,6 +2,12 @@ |
| 2 | #include <stdint.h> | 2 | #include <stdint.h> |
| 3 | #include "libc.h" | 3 | #include "libc.h" |
| 4 | #include "lock.h" | 4 | #include "lock.h" |
| 5 | #include "fork_impl.h" | ||
| 6 | |||
| 7 | #define malloc __libc_malloc | ||
| 8 | #define calloc __libc_calloc | ||
| 9 | #define realloc undef | ||
| 10 | #define free undef | ||
| 5 | 11 | ||
| 6 | /* Ensure that at least 32 atexit handlers can be registered without malloc */ | 12 | /* Ensure that at least 32 atexit handlers can be registered without malloc */ |
| 7 | #define COUNT 32 | 13 | #define COUNT 32 |
| ... | @@ -15,6 +21,7 @@ static struct fl | ... | @@ -15,6 +21,7 @@ static struct fl |
| 15 | 21 | ||
| 16 | static int slot; | 22 | static int slot; |
| 17 | static volatile int lock[1]; | 23 | static volatile int lock[1]; |
| 24 | volatile int *const __atexit_lockptr = lock; | ||
| 18 | 25 | ||
| 19 | void __funcs_on_exit() | 26 | void __funcs_on_exit() |
| 20 | { | 27 | { |
lib/libc/musl/src/include/stdlib.h+6| ... | @@ -9,4 +9,10 @@ hidden int __mkostemps(char *, int, int); | ... | @@ -9,4 +9,10 @@ hidden int __mkostemps(char *, int, int); |
| 9 | hidden int __ptsname_r(int, char *, size_t); | 9 | hidden int __ptsname_r(int, char *, size_t); |
| 10 | hidden char *__randname(char *); | 10 | hidden char *__randname(char *); |
| 11 | 11 | ||
| 12 | hidden void *__libc_malloc(size_t); | ||
| 13 | hidden void *__libc_malloc_impl(size_t); | ||
| 14 | hidden void *__libc_calloc(size_t, size_t); | ||
| 15 | hidden void *__libc_realloc(void *, size_t); | ||
| 16 | hidden void __libc_free(void *); | ||
| 17 | |||
| 12 | #endif | 18 | #endif |
lib/libc/musl/src/include/unistd.h-1| ... | @@ -8,7 +8,6 @@ extern char **__environ; | ... | @@ -8,7 +8,6 @@ extern char **__environ; |
| 8 | hidden int __dup3(int, int, int); | 8 | hidden int __dup3(int, int, int); |
| 9 | hidden int __mkostemps(char *, int, int); | 9 | hidden int __mkostemps(char *, int, int); |
| 10 | hidden int __execvpe(const char *, char *const *, char *const *); | 10 | hidden int __execvpe(const char *, char *const *, char *const *); |
| 11 | hidden int __aio_close(int); | ||
| 12 | hidden off_t __lseek(int, off_t, int); | 11 | hidden off_t __lseek(int, off_t, int); |
| 13 | 12 | ||
| 14 | #endif | 13 | #endif |
lib/libc/musl/src/internal/aio_impl.h created+9| ... | @@ -0,0 +1,9 @@ | ||
| 1 | #ifndef AIO_IMPL_H | ||
| 2 | #define AIO_IMPL_H | ||
| 3 | |||
| 4 | extern hidden volatile int __aio_fut; | ||
| 5 | |||
| 6 | extern hidden int __aio_close(int); | ||
| 7 | extern hidden void __aio_atfork(int); | ||
| 8 | |||
| 9 | #endif | ||
lib/libc/musl/src/internal/fork_impl.h created+19| ... | @@ -0,0 +1,19 @@ | ||
| 1 | #include <features.h> | ||
| 2 | |||
| 3 | extern hidden volatile int *const __at_quick_exit_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; | ||
| 7 | extern hidden volatile int *const __locale_lockptr; | ||
| 8 | extern hidden volatile int *const __random_lockptr; | ||
| 9 | extern hidden volatile int *const __sem_open_lockptr; | ||
| 10 | extern hidden volatile int *const __stdio_ofl_lockptr; | ||
| 11 | extern hidden volatile int *const __syslog_lockptr; | ||
| 12 | extern hidden volatile int *const __timezone_lockptr; | ||
| 13 | |||
| 14 | extern hidden volatile int *const __bump_lockptr; | ||
| 15 | |||
| 16 | extern hidden volatile int *const __vmlock_lockptr; | ||
| 17 | |||
| 18 | hidden void __malloc_atfork(int); | ||
| 19 | hidden void __ldso_atfork(int); | ||
lib/libc/musl/src/internal/libm.h+3| ... | @@ -267,5 +267,8 @@ hidden double __math_uflow(uint32_t); | ... | @@ -267,5 +267,8 @@ hidden double __math_uflow(uint32_t); |
| 267 | hidden double __math_oflow(uint32_t); | 267 | hidden double __math_oflow(uint32_t); |
| 268 | hidden double __math_divzero(uint32_t); | 268 | hidden double __math_divzero(uint32_t); |
| 269 | hidden double __math_invalid(double); | 269 | hidden double __math_invalid(double); |
| 270 | #if LDBL_MANT_DIG != DBL_MANT_DIG | ||
| 271 | hidden long double __math_invalidl(long double); | ||
| 272 | #endif | ||
| 270 | 273 | ||
| 271 | #endif | 274 | #endif |
lib/libc/musl/src/internal/locale_impl.h+2| ... | @@ -15,6 +15,8 @@ struct __locale_map { | ... | @@ -15,6 +15,8 @@ struct __locale_map { |
| 15 | 	const struct __locale_map *next; | 15 | 	const struct __locale_map *next; |
| 16 | }; | 16 | }; |
| 17 | 17 | ||
| 18 | extern hidden volatile int __locale_lock[1]; | ||
| 19 | |||
| 18 | extern hidden const struct __locale_map __c_dot_utf8; | 20 | extern hidden const struct __locale_map __c_dot_utf8; |
| 19 | extern hidden const struct __locale_struct __c_locale; | 21 | extern hidden const struct __locale_struct __c_locale; |
| 20 | extern hidden const struct __locale_struct __c_dot_utf8_locale; | 22 | extern hidden const struct __locale_struct __c_dot_utf8_locale; |
lib/libc/musl/src/internal/pthread_impl.h+29-14| ... | @@ -11,16 +11,25 @@ | ... | @@ -11,16 +11,25 @@ |
| 11 | #include "atomic.h" | 11 | #include "atomic.h" |
| 12 | #include "futex.h" | 12 | #include "futex.h" |
| 13 | 13 | ||
| 14 | #include "pthread_arch.h" | ||
| 15 | |||
| 14 | #define pthread __pthread | 16 | #define pthread __pthread |
| 15 | 17 | ||
| 16 | struct pthread { | 18 | struct pthread { |
| 17 | 	/* Part 1 -- these fields may be external or | 19 | 	/* Part 1 -- these fields may be external or |
| 18 | 	 * internal (accessed via asm) ABI. Do not change. */ | 20 | 	 * internal (accessed via asm) ABI. Do not change. */ |
| 19 | 	struct pthread *self; | 21 | 	struct pthread *self; |
| 22 | #ifndef TLS_ABOVE_TP | ||
| 20 | 	uintptr_t *dtv; | 23 | 	uintptr_t *dtv; |
| 24 | #endif | ||
| 21 | 	struct pthread *prev, *next; /* non-ABI */ | 25 | 	struct pthread *prev, *next; /* non-ABI */ |
| 22 | 	uintptr_t sysinfo; | 26 | 	uintptr_t sysinfo; |
| 23 | 	uintptr_t canary, canary2; | 27 | #ifndef TLS_ABOVE_TP |
| 28 | #ifdef CANARY_PAD | ||
| 29 | 	uintptr_t canary_pad; | ||
| 30 | #endif | ||
| 31 | 	uintptr_t canary; | ||
| 32 | #endif | ||
| 24 | 33 | ||
| 25 | 	/* Part 2 -- implementation details, non-ABI. */ | 34 | 	/* Part 2 -- implementation details, non-ABI. */ |
| 26 | 	int tid; | 35 | 	int tid; |
| ... | @@ -43,6 +52,7 @@ struct pthread { | ... | @@ -43,6 +52,7 @@ struct pthread { |
| 43 | 		long off; | 52 | 		long off; |
| 44 | 		volatile void *volatile pending; | 53 | 		volatile void *volatile pending; |
| 45 | 	} robust_list; | 54 | 	} robust_list; |
| 55 | 	int h_errno_val; | ||
| 46 | 	volatile int timer_id; | 56 | 	volatile int timer_id; |
| 47 | 	locale_t locale; | 57 | 	locale_t locale; |
| 48 | 	volatile int killlock[1]; | 58 | 	volatile int killlock[1]; |
| ... | @@ -51,21 +61,19 @@ struct pthread { | ... | @@ -51,21 +61,19 @@ struct pthread { |
| 51 | 61 | ||
| 52 | 	/* Part 3 -- the positions of these fields relative to | 62 | 	/* Part 3 -- the positions of these fields relative to |
| 53 | 	 * the end of the structure is external and internal ABI. */ | 63 | 	 * the end of the structure is external and internal ABI. */ |
| 54 | 	uintptr_t canary_at_end; | 64 | #ifdef TLS_ABOVE_TP |
| 55 | 	uintptr_t *dtv_copy; | 65 | 	uintptr_t canary; |
| 66 | 	uintptr_t *dtv; | ||
| 67 | #endif | ||
| 56 | }; | 68 | }; |
| 57 | 69 | ||
| 58 | enum { | 70 | enum { |
| 59 | 	DT_EXITING = 0, | 71 | 	DT_EXITED = 0, |
| 72 | 	DT_EXITING, | ||
| 60 | 	DT_JOINABLE, | 73 | 	DT_JOINABLE, |
| 61 | 	DT_DETACHED, | 74 | 	DT_DETACHED, |
| 62 | }; | 75 | }; |
| 63 | 76 | ||
| 64 | struct __timer { | ||
| 65 | 	int timerid; | ||
| 66 | 	pthread_t thread; | ||
| 67 | }; | ||
| 68 | |||
| 69 | #define __SU (sizeof(size_t)/sizeof(int)) | 77 | #define __SU (sizeof(size_t)/sizeof(int)) |
| 70 | 78 | ||
| 71 | #define _a_stacksize __u.__s[0] | 79 | #define _a_stacksize __u.__s[0] |
| ... | @@ -98,16 +106,22 @@ struct __timer { | ... | @@ -98,16 +106,22 @@ struct __timer { |
| 98 | #define _b_waiters2 __u.__vi[4] | 106 | #define _b_waiters2 __u.__vi[4] |
| 99 | #define _b_inst __u.__p[3] | 107 | #define _b_inst __u.__p[3] |
| 100 | 108 | ||
| 101 | #include "pthread_arch.h" | 109 | #ifndef TP_OFFSET |
| 102 | 110 | #define TP_OFFSET 0 | |
| 103 | #ifndef CANARY | ||
| 104 | #define CANARY canary | ||
| 105 | #endif | 111 | #endif |
| 106 | 112 | ||
| 107 | #ifndef DTP_OFFSET | 113 | #ifndef DTP_OFFSET |
| 108 | #define DTP_OFFSET 0 | 114 | #define DTP_OFFSET 0 |
| 109 | #endif | 115 | #endif |
| 110 | 116 | ||
| 117 | #ifdef TLS_ABOVE_TP | ||
| 118 | #define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread) + TP_OFFSET) | ||
| 119 | #define __pthread_self() ((pthread_t)(__get_tp() - sizeof(struct __pthread) - TP_OFFSET)) | ||
| 120 | #else | ||
| 121 | #define TP_ADJ(p) (p) | ||
| 122 | #define __pthread_self() ((pthread_t)__get_tp()) | ||
| 123 | #endif | ||
| 124 | |||
| 111 | #ifndef tls_mod_off_t | 125 | #ifndef tls_mod_off_t |
| 112 | #define tls_mod_off_t size_t | 126 | #define tls_mod_off_t size_t |
| 113 | #endif | 127 | #endif |
| ... | @@ -141,7 +155,6 @@ hidden int __pthread_key_delete_impl(pthread_key_t); | ... | @@ -141,7 +155,6 @@ hidden int __pthread_key_delete_impl(pthread_key_t); |
| 141 | 155 | ||
| 142 | extern hidden volatile size_t __pthread_tsd_size; | 156 | extern hidden volatile size_t __pthread_tsd_size; |
| 143 | extern hidden void *__pthread_tsd_main[]; | 157 | extern hidden void *__pthread_tsd_main[]; |
| 144 | extern hidden volatile int __aio_fut; | ||
| 145 | extern hidden volatile int __eintr_valid_flag; | 158 | extern hidden volatile int __eintr_valid_flag; |
| 146 | 159 | ||
| 147 | hidden int __clone(int (*)(void *), void *, int, void *, ...); | 160 | hidden int __clone(int (*)(void *), void *, int, void *, ...); |
| ... | @@ -176,6 +189,8 @@ hidden void __tl_sync(pthread_t); | ... | @@ -176,6 +189,8 @@ hidden void __tl_sync(pthread_t); |
| 176 | 189 | ||
| 177 | extern hidden volatile int __thread_list_lock; | 190 | extern hidden volatile int __thread_list_lock; |
| 178 | 191 | ||
| 192 | extern hidden volatile int __abort_lock[1]; | ||
| 193 | |||
| 179 | extern hidden unsigned __default_stacksize; | 194 | extern hidden unsigned __default_stacksize; |
| 180 | extern hidden unsigned __default_guardsize; | 195 | extern hidden unsigned __default_guardsize; |
| 181 | 196 |
lib/libc/musl/src/internal/syscall.h+23-9| ... | @@ -2,6 +2,7 @@ | ... | @@ -2,6 +2,7 @@ |
| 2 | #define _INTERNAL_SYSCALL_H | 2 | #define _INTERNAL_SYSCALL_H |
| 3 | 3 | ||
| 4 | #include <features.h> | 4 | #include <features.h> |
| 5 | #include <errno.h> | ||
| 5 | #include <sys/syscall.h> | 6 | #include <sys/syscall.h> |
| 6 | #include "syscall_arch.h" | 7 | #include "syscall_arch.h" |
| 7 | 8 | ||
| ... | @@ -57,15 +58,22 @@ hidden long __syscall_ret(unsigned long), | ... | @@ -57,15 +58,22 @@ hidden long __syscall_ret(unsigned long), |
| 57 | #define __syscall_cp(...) __SYSCALL_DISP(__syscall_cp,__VA_ARGS__) | 58 | #define __syscall_cp(...) __SYSCALL_DISP(__syscall_cp,__VA_ARGS__) |
| 58 | #define syscall_cp(...) __syscall_ret(__syscall_cp(__VA_ARGS__)) | 59 | #define syscall_cp(...) __syscall_ret(__syscall_cp(__VA_ARGS__)) |
| 59 | 60 | ||
| 60 | #ifndef SYSCALL_USE_SOCKETCALL | 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 | #define __socketcall(nm,a,b,c,d,e,f) __syscall(SYS_##nm, a, b, c, d, e, f) | 62 | { |
| 62 | #define __socketcall_cp(nm,a,b,c,d,e,f) __syscall_cp(SYS_##nm, a, b, c, d, e, f) | 63 | 	long r; |
| 63 | #else | 64 | 	if (cp) r = __syscall_cp(sys, a, b, c, d, e, f); |
| 64 | #define __socketcall(nm,a,b,c,d,e,f) __syscall(SYS_socketcall, __SC_##nm, \ | 65 | 	else r = __syscall(sys, a, b, c, d, e, f); |
| 65 | ((long [6]){ (long)a, (long)b, (long)c, (long)d, (long)e, (long)f })) | 66 | 	if (r != -ENOSYS) return r; |
| 66 | #define __socketcall_cp(nm,a,b,c,d,e,f) __syscall_cp(SYS_socketcall, __SC_##nm, \ | 67 | #ifdef SYS_socketcall |
| 67 | ((long [6]){ (long)a, (long)b, (long)c, (long)d, (long)e, (long)f })) | 68 | 	if (cp) r = __syscall_cp(SYS_socketcall, sock, ((long[6]){a, b, c, d, e, f})); |
| 68 | #endif | 69 | 	else r = __syscall(SYS_socketcall, sock, ((long[6]){a, b, c, d, e, f})); |
| 70 | #endif | ||
| 71 | 	return r; | ||
| 72 | } | ||
| 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)) | ||
| 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)) | ||
| 69 | 77 | ||
| 70 | /* fixup legacy 16-bit junk */ | 78 | /* fixup legacy 16-bit junk */ |
| 71 | 79 | ||
| ... | @@ -338,6 +346,12 @@ hidden long __syscall_ret(unsigned long), | ... | @@ -338,6 +346,12 @@ hidden long __syscall_ret(unsigned long), |
| 338 | #define __SC_recvmmsg 19 | 346 | #define __SC_recvmmsg 19 |
| 339 | #define __SC_sendmmsg 20 | 347 | #define __SC_sendmmsg 20 |
| 340 | 348 | ||
| 349 | /* This is valid only because all socket syscalls are made via | ||
| 350 | * socketcall, which always fills unused argument slots with zeros. */ | ||
| 351 | #ifndef SYS_accept | ||
| 352 | #define SYS_accept SYS_accept4 | ||
| 353 | #endif | ||
| 354 | |||
| 341 | #ifndef SO_RCVTIMEO_OLD | 355 | #ifndef SO_RCVTIMEO_OLD |
| 342 | #define SO_RCVTIMEO_OLD 20 | 356 | #define SO_RCVTIMEO_OLD 20 |
| 343 | #endif | 357 | #endif |
lib/libc/musl/src/internal/version.h+1-1| ... | @@ -1 +1 @@ | ... | @@ -1 +1 @@ |
| 1 | #define VERSION "1.2.1" | 1 | #define VERSION "1.2.2" |
lib/libc/musl/src/ldso/dlerror.c+15-5| ... | @@ -4,6 +4,12 @@ | ... | @@ -4,6 +4,12 @@ |
| 4 | #include "pthread_impl.h" | 4 | #include "pthread_impl.h" |
| 5 | #include "dynlink.h" | 5 | #include "dynlink.h" |
| 6 | #include "lock.h" | 6 | #include "lock.h" |
| 7 | #include "fork_impl.h" | ||
| 8 | |||
| 9 | #define malloc __libc_malloc | ||
| 10 | #define calloc __libc_calloc | ||
| 11 | #define realloc __libc_realloc | ||
| 12 | #define free __libc_free | ||
| 7 | 13 | ||
| 8 | char *dlerror() | 14 | char *dlerror() |
| 9 | { | 15 | { |
| ... | @@ -19,6 +25,7 @@ char *dlerror() | ... | @@ -19,6 +25,7 @@ char *dlerror() |
| 19 | 25 | ||
| 20 | static volatile int freebuf_queue_lock[1]; | 26 | static volatile int freebuf_queue_lock[1]; |
| 21 | static void **freebuf_queue; | 27 | static void **freebuf_queue; |
| 28 | volatile int *const __dlerror_lockptr = freebuf_queue_lock; | ||
| 22 | 29 | ||
| 23 | void __dl_thread_cleanup(void) | 30 | void __dl_thread_cleanup(void) |
| 24 | { | 31 | { |
| ... | @@ -35,13 +42,16 @@ void __dl_thread_cleanup(void) | ... | @@ -35,13 +42,16 @@ void __dl_thread_cleanup(void) |
| 35 | hidden void __dl_vseterr(const char *fmt, va_list ap) | 42 | hidden void __dl_vseterr(const char *fmt, va_list ap) |
| 36 | { | 43 | { |
| 37 | 	LOCK(freebuf_queue_lock); | 44 | 	LOCK(freebuf_queue_lock); |
| 38 | 	while (freebuf_queue) { | 45 | 	void **q = freebuf_queue; |
| 39 | 		void **p = freebuf_queue; | 46 | 	freebuf_queue = 0; |
| 40 | 		freebuf_queue = *p; | ||
| 41 | 		free(p); | ||
| 42 | 	} | ||
| 43 | 	UNLOCK(freebuf_queue_lock); | 47 | 	UNLOCK(freebuf_queue_lock); |
| 44 | 48 | ||
| 49 | 	while (q) { | ||
| 50 | 		void **p = *q; | ||
| 51 | 		free(q); | ||
| 52 | 		q = p; | ||
| 53 | 	} | ||
| 54 | |||
| 45 | 	va_list ap2; | 55 | 	va_list ap2; |
| 46 | 	va_copy(ap2, ap); | 56 | 	va_copy(ap2, ap); |
| 47 | 	pthread_t self = __pthread_self(); | 57 | 	pthread_t self = __pthread_self(); |
lib/libc/musl/src/legacy/lutimes.c+7-5| ... | @@ -6,9 +6,11 @@ | ... | @@ -6,9 +6,11 @@ |
| 6 | int lutimes(const char *filename, const struct timeval tv[2]) | 6 | int lutimes(const char *filename, const struct timeval tv[2]) |
| 7 | { | 7 | { |
| 8 | 	struct timespec times[2]; | 8 | 	struct timespec times[2]; |
| 9 | 	times[0].tv_sec = tv[0].tv_sec; | 9 | 	if (tv) { |
| 10 | 	times[0].tv_nsec = tv[0].tv_usec * 1000; | 10 | 		times[0].tv_sec = tv[0].tv_sec; |
| 11 | 	times[1].tv_sec = tv[1].tv_sec; | 11 | 		times[0].tv_nsec = tv[0].tv_usec * 1000; |
| 12 | 	times[1].tv_nsec = tv[1].tv_usec * 1000; | 12 | 		times[1].tv_sec = tv[1].tv_sec; |
| 13 | 	return utimensat(AT_FDCWD, filename, times, AT_SYMLINK_NOFOLLOW); | 13 | 		times[1].tv_nsec = tv[1].tv_usec * 1000; |
| 14 | 	} | ||
| 15 | 	return utimensat(AT_FDCWD, filename, tv ? times : 0, AT_SYMLINK_NOFOLLOW); | ||
| 14 | } | 16 | } |
lib/libc/musl/src/linux/gettid.c created+8| ... | @@ -0,0 +1,8 @@ | ||
| 1 | #define _GNU_SOURCE | ||
| 2 | #include <unistd.h> | ||
| 3 | #include "pthread_impl.h" | ||
| 4 | |||
| 5 | pid_t gettid(void) | ||
| 6 | { | ||
| 7 | 	return __pthread_self()->tid; | ||
| 8 | } | ||
lib/libc/musl/src/linux/membarrier.c-5| ... | @@ -9,13 +9,8 @@ static void dummy_0(void) | ... | @@ -9,13 +9,8 @@ static void dummy_0(void) |
| 9 | { | 9 | { |
| 10 | } | 10 | } |
| 11 | 11 | ||
| 12 | static void dummy_1(pthread_t t) | ||
| 13 | { | ||
| 14 | } | ||
| 15 | |||
| 16 | weak_alias(dummy_0, __tl_lock); | 12 | weak_alias(dummy_0, __tl_lock); |
| 17 | weak_alias(dummy_0, __tl_unlock); | 13 | weak_alias(dummy_0, __tl_unlock); |
| 18 | weak_alias(dummy_1, __tl_sync); | ||
| 19 | 14 | ||
| 20 | static sem_t barrier_sem; | 15 | static sem_t barrier_sem; |
| 21 | 16 |
lib/libc/musl/src/linux/setgroups.c+29-1| ... | @@ -1,8 +1,36 @@ | ... | @@ -1,8 +1,36 @@ |
| 1 | #define _GNU_SOURCE | 1 | #define _GNU_SOURCE |
| 2 | #include <unistd.h> | 2 | #include <unistd.h> |
| 3 | #include <signal.h> | ||
| 3 | #include "syscall.h" | 4 | #include "syscall.h" |
| 5 | #include "libc.h" | ||
| 6 | |||
| 7 | struct ctx { | ||
| 8 | 	size_t count; | ||
| 9 | 	const gid_t *list; | ||
| 10 | 	int ret; | ||
| 11 | }; | ||
| 12 | |||
| 13 | static void do_setgroups(void *p) | ||
| 14 | { | ||
| 15 | 	struct ctx *c = p; | ||
| 16 | 	if (c->ret<0) return; | ||
| 17 | 	int ret = __syscall(SYS_setgroups, c->count, c->list); | ||
| 18 | 	if (ret && !c->ret) { | ||
| 19 | 		/* If one thread fails to set groups after another has already | ||
| 20 | 		 * succeeded, forcibly killing the process is the only safe | ||
| 21 | 		 * thing to do. State is inconsistent and dangerous. Use | ||
| 22 | 		 * SIGKILL because it is uncatchable. */ | ||
| 23 | 		__block_all_sigs(0); | ||
| 24 | 		__syscall(SYS_kill, __syscall(SYS_getpid), SIGKILL); | ||
| 25 | 	} | ||
| 26 | 	c->ret = ret; | ||
| 27 | } | ||
| 4 | 28 | ||
| 5 | int setgroups(size_t count, const gid_t list[]) | 29 | int setgroups(size_t count, const gid_t list[]) |
| 6 | { | 30 | { |
| 7 | 	return syscall(SYS_setgroups, count, list); | 31 | 	/* ret is initially nonzero so that failure of the first thread does not |
| 32 | 	 * trigger the safety kill above. */ | ||
| 33 | 	struct ctx c = { .count = count, .list = list, .ret = 1 }; | ||
| 34 | 	__synccall(do_setgroups, &c); | ||
| 35 | 	return __syscall_ret(c.ret); | ||
| 8 | } | 36 | } |
lib/libc/musl/src/locale/dcngettext.c+9-1| ... | @@ -10,6 +10,12 @@ | ... | @@ -10,6 +10,12 @@ |
| 10 | #include "atomic.h" | 10 | #include "atomic.h" |
| 11 | #include "pleval.h" | 11 | #include "pleval.h" |
| 12 | #include "lock.h" | 12 | #include "lock.h" |
| 13 | #include "fork_impl.h" | ||
| 14 | |||
| 15 | #define malloc __libc_malloc | ||
| 16 | #define calloc __libc_calloc | ||
| 17 | #define realloc undef | ||
| 18 | #define free undef | ||
| 13 | 19 | ||
| 14 | struct binding { | 20 | struct binding { |
| 15 | 	struct binding *next; | 21 | 	struct binding *next; |
| ... | @@ -34,9 +40,11 @@ static char *gettextdir(const char *domainname, size_t *dirlen) | ... | @@ -34,9 +40,11 @@ static char *gettextdir(const char *domainname, size_t *dirlen) |
| 34 | 	return 0; | 40 | 	return 0; |
| 35 | } | 41 | } |
| 36 | 42 | ||
| 43 | static volatile int lock[1]; | ||
| 44 | volatile int *const __gettext_lockptr = lock; | ||
| 45 | |||
| 37 | char *bindtextdomain(const char *domainname, const char *dirname) | 46 | char *bindtextdomain(const char *domainname, const char *dirname) |
| 38 | { | 47 | { |
| 39 | 	static volatile int lock[1]; | ||
| 40 | 	struct binding *p, *q; | 48 | 	struct binding *p, *q; |
| 41 | 49 | ||
| 42 | 	if (!domainname) return 0; | 50 | 	if (!domainname) return 0; |
lib/libc/musl/src/locale/freelocale.c+5| ... | @@ -1,6 +1,11 @@ | ... | @@ -1,6 +1,11 @@ |
| 1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
| 2 | #include "locale_impl.h" | 2 | #include "locale_impl.h" |
| 3 | 3 | ||
| 4 | #define malloc undef | ||
| 5 | #define calloc undef | ||
| 6 | #define realloc undef | ||
| 7 | #define free __libc_free | ||
| 8 | |||
| 4 | void freelocale(locale_t l) | 9 | void freelocale(locale_t l) |
| 5 | { | 10 | { |
| 6 | 	if (__loc_is_allocated(l)) free(l); | 11 | 	if (__loc_is_allocated(l)) free(l); |
lib/libc/musl/src/locale/locale_map.c+11-11| ... | @@ -1,9 +1,16 @@ | ... | @@ -1,9 +1,16 @@ |
| 1 | #include <locale.h> | 1 | #include <locale.h> |
| 2 | #include <string.h> | 2 | #include <string.h> |
| 3 | #include <sys/mman.h> | 3 | #include <sys/mman.h> |
| 4 | #include <stdlib.h> | ||
| 4 | #include "locale_impl.h" | 5 | #include "locale_impl.h" |
| 5 | #include "libc.h" | 6 | #include "libc.h" |
| 6 | #include "lock.h" | 7 | #include "lock.h" |
| 8 | #include "fork_impl.h" | ||
| 9 | |||
| 10 | #define malloc __libc_malloc | ||
| 11 | #define calloc undef | ||
| 12 | #define realloc undef | ||
| 13 | #define free undef | ||
| 7 | 14 | ||
| 8 | const char *__lctrans_impl(const char *msg, const struct __locale_map *lm) | 15 | const char *__lctrans_impl(const char *msg, const struct __locale_map *lm) |
| 9 | { | 16 | { |
| ... | @@ -21,9 +28,11 @@ static const char envvars[][12] = { | ... | @@ -21,9 +28,11 @@ static const char envvars[][12] = { |
| 21 | 	"LC_MESSAGES", | 28 | 	"LC_MESSAGES", |
| 22 | }; | 29 | }; |
| 23 | 30 | ||
| 31 | volatile int __locale_lock[1]; | ||
| 32 | volatile int *const __locale_lockptr = __locale_lock; | ||
| 33 | |||
| 24 | const struct __locale_map *__get_locale(int cat, const char *val) | 34 | const struct __locale_map *__get_locale(int cat, const char *val) |
| 25 | { | 35 | { |
| 26 | 	static volatile int lock[1]; | ||
| 27 | 	static void *volatile loc_head; | 36 | 	static void *volatile loc_head; |
| 28 | 	const struct __locale_map *p; | 37 | 	const struct __locale_map *p; |
| 29 | 	struct __locale_map *new = 0; | 38 | 	struct __locale_map *new = 0; |
| ... | @@ -54,20 +63,12 @@ const struct __locale_map *__get_locale(int cat, const char *val) | ... | @@ -54,20 +63,12 @@ const struct __locale_map *__get_locale(int cat, const char *val) |
| 54 | 	for (p=loc_head; p; p=p->next) | 63 | 	for (p=loc_head; p; p=p->next) |
| 55 | 		if (!strcmp(val, p->name)) return p; | 64 | 		if (!strcmp(val, p->name)) return p; |
| 56 | 65 | ||
| 57 | 	LOCK(lock); | ||
| 58 | |||
| 59 | 	for (p=loc_head; p; p=p->next) | ||
| 60 | 		if (!strcmp(val, p->name)) { | ||
| 61 | 			UNLOCK(lock); | ||
| 62 | 			return p; | ||
| 63 | 		} | ||
| 64 | |||
| 65 | 	if (!libc.secure) path = getenv("MUSL_LOCPATH"); | 66 | 	if (!libc.secure) path = getenv("MUSL_LOCPATH"); |
| 66 | 	/* FIXME: add a default path? */ | 67 | 	/* FIXME: add a default path? */ |
| 67 | 68 | ||
| 68 | 	if (path) for (; *path; path=z+!!*z) { | 69 | 	if (path) for (; *path; path=z+!!*z) { |
| 69 | 		z = __strchrnul(path, ':'); | 70 | 		z = __strchrnul(path, ':'); |
| 70 | 		l = z - path - !!*z; | 71 | 		l = z - path; |
| 71 | 		if (l >= sizeof buf - n - 2) continue; | 72 | 		if (l >= sizeof buf - n - 2) continue; |
| 72 | 		memcpy(buf, path, l); | 73 | 		memcpy(buf, path, l); |
| 73 | 		buf[l] = '/'; | 74 | 		buf[l] = '/'; |
| ... | @@ -108,6 +109,5 @@ const struct __locale_map *__get_locale(int cat, const char *val) | ... | @@ -108,6 +109,5 @@ const struct __locale_map *__get_locale(int cat, const char *val) |
| 108 | 	 * requested name was "C" or "POSIX". */ | 109 | 	 * requested name was "C" or "POSIX". */ |
| 109 | 	if (!new && cat == LC_CTYPE) new = (void *)&__c_dot_utf8; | 110 | 	if (!new && cat == LC_CTYPE) new = (void *)&__c_dot_utf8; |
| 110 | 111 | ||
| 111 | 	UNLOCK(lock); | ||
| 112 | 	return new; | 112 | 	return new; |
| 113 | } | 113 | } |
lib/libc/musl/src/locale/newlocale.c+22-10| ... | @@ -2,16 +2,15 @@ | ... | @@ -2,16 +2,15 @@ |
| 2 | #include <string.h> | 2 | #include <string.h> |
| 3 | #include <pthread.h> | 3 | #include <pthread.h> |
| 4 | #include "locale_impl.h" | 4 | #include "locale_impl.h" |
| 5 | #include "lock.h" | ||
| 5 | 6 | ||
| 6 | static pthread_once_t default_locale_once; | 7 | #define malloc __libc_malloc |
| 7 | static struct __locale_struct default_locale, default_ctype_locale; | 8 | #define calloc undef |
| 9 | #define realloc undef | ||
| 10 | #define free undef | ||
| 8 | 11 | ||
| 9 | static void default_locale_init(void) | 12 | static int default_locale_init_done; |
| 10 | { | 13 | static struct __locale_struct default_locale, default_ctype_locale; |
| 11 | 	for (int i=0; i<LC_ALL; i++) | ||
| 12 | 		default_locale.cat[i] = __get_locale(i, ""); | ||
| 13 | 	default_ctype_locale.cat[LC_CTYPE] = default_locale.cat[LC_CTYPE]; | ||
| 14 | } | ||
| 15 | 14 | ||
| 16 | int __loc_is_allocated(locale_t loc) | 15 | int __loc_is_allocated(locale_t loc) |
| 17 | { | 16 | { |
| ... | @@ -19,7 +18,7 @@ int __loc_is_allocated(locale_t loc) | ... | @@ -19,7 +18,7 @@ int __loc_is_allocated(locale_t loc) |
| 19 | 		&& loc != &default_locale && loc != &default_ctype_locale; | 18 | 		&& loc != &default_locale && loc != &default_ctype_locale; |
| 20 | } | 19 | } |
| 21 | 20 | ||
| 22 | locale_t __newlocale(int mask, const char *name, locale_t loc) | 21 | static locale_t do_newlocale(int mask, const char *name, locale_t loc) |
| 23 | { | 22 | { |
| 24 | 	struct __locale_struct tmp; | 23 | 	struct __locale_struct tmp; |
| 25 | 24 | ||
| ... | @@ -44,7 +43,12 @@ locale_t __newlocale(int mask, const char *name, locale_t loc) | ... | @@ -44,7 +43,12 @@ locale_t __newlocale(int mask, const char *name, locale_t loc) |
| 44 | 43 | ||
| 45 | 	/* And provide builtins for the initial default locale, and a | 44 | 	/* And provide builtins for the initial default locale, and a |
| 46 | 	 * variant of the C locale honoring the default locale's encoding. */ | 45 | 	 * variant of the C locale honoring the default locale's encoding. */ |
| 47 | 	pthread_once(&default_locale_once, default_locale_init); | 46 | 	if (!default_locale_init_done) { |
| 47 | 		for (int i=0; i<LC_ALL; i++) | ||
| 48 | 			default_locale.cat[i] = __get_locale(i, ""); | ||
| 49 | 		default_ctype_locale.cat[LC_CTYPE] = default_locale.cat[LC_CTYPE]; | ||
| 50 | 		default_locale_init_done = 1; | ||
| 51 | 	} | ||
| 48 | 	if (!memcmp(&tmp, &default_locale, sizeof tmp)) return &default_locale; | 52 | 	if (!memcmp(&tmp, &default_locale, sizeof tmp)) return &default_locale; |
| 49 | 	if (!memcmp(&tmp, &default_ctype_locale, sizeof tmp)) | 53 | 	if (!memcmp(&tmp, &default_ctype_locale, sizeof tmp)) |
| 50 | 		return &default_ctype_locale; | 54 | 		return &default_ctype_locale; |
| ... | @@ -55,4 +59,12 @@ locale_t __newlocale(int mask, const char *name, locale_t loc) | ... | @@ -55,4 +59,12 @@ locale_t __newlocale(int mask, const char *name, locale_t loc) |
| 55 | 	return loc; | 59 | 	return loc; |
| 56 | } | 60 | } |
| 57 | 61 | ||
| 62 | locale_t __newlocale(int mask, const char *name, locale_t loc) | ||
| 63 | { | ||
| 64 | 	LOCK(__locale_lock); | ||
| 65 | 	loc = do_newlocale(mask, name, loc); | ||
| 66 | 	UNLOCK(__locale_lock); | ||
| 67 | 	return loc; | ||
| 68 | } | ||
| 69 | |||
| 58 | weak_alias(__newlocale, newlocale); | 70 | weak_alias(__newlocale, newlocale); |
lib/libc/musl/src/locale/setlocale.c+5-6| ... | @@ -9,12 +9,11 @@ static char buf[LC_ALL*(LOCALE_NAME_MAX+1)]; | ... | @@ -9,12 +9,11 @@ static char buf[LC_ALL*(LOCALE_NAME_MAX+1)]; |
| 9 | 9 | ||
| 10 | char *setlocale(int cat, const char *name) | 10 | char *setlocale(int cat, const char *name) |
| 11 | { | 11 | { |
| 12 | 	static volatile int lock[1]; | ||
| 13 | 	const struct __locale_map *lm; | 12 | 	const struct __locale_map *lm; |
| 14 | 13 | ||
| 15 | 	if ((unsigned)cat > LC_ALL) return 0; | 14 | 	if ((unsigned)cat > LC_ALL) return 0; |
| 16 | 15 | ||
| 17 | 	LOCK(lock); | 16 | 	LOCK(__locale_lock); |
| 18 | 17 | ||
| 19 | 	/* For LC_ALL, setlocale is required to return a string which | 18 | 	/* For LC_ALL, setlocale is required to return a string which |
| 20 | 	 * encodes the current setting for all categories. The format of | 19 | 	 * encodes the current setting for all categories. The format of |
| ... | @@ -36,7 +35,7 @@ char *setlocale(int cat, const char *name) | ... | @@ -36,7 +35,7 @@ char *setlocale(int cat, const char *name) |
| 36 | 				} | 35 | 				} |
| 37 | 				lm = __get_locale(i, part); | 36 | 				lm = __get_locale(i, part); |
| 38 | 				if (lm == LOC_MAP_FAILED) { | 37 | 				if (lm == LOC_MAP_FAILED) { |
| 39 | 					UNLOCK(lock); | 38 | 					UNLOCK(__locale_lock); |
| 40 | 					return 0; | 39 | 					return 0; |
| 41 | 				} | 40 | 				} |
| 42 | 				tmp_locale.cat[i] = lm; | 41 | 				tmp_locale.cat[i] = lm; |
| ... | @@ -57,14 +56,14 @@ char *setlocale(int cat, const char *name) | ... | @@ -57,14 +56,14 @@ char *setlocale(int cat, const char *name) |
| 57 | 			s += l+1; | 56 | 			s += l+1; |
| 58 | 		} | 57 | 		} |
| 59 | 		*--s = 0; | 58 | 		*--s = 0; |
| 60 | 		UNLOCK(lock); | 59 | 		UNLOCK(__locale_lock); |
| 61 | 		return same==LC_ALL ? (char *)part : buf; | 60 | 		return same==LC_ALL ? (char *)part : buf; |
| 62 | 	} | 61 | 	} |
| 63 | 62 | ||
| 64 | 	if (name) { | 63 | 	if (name) { |
| 65 | 		lm = __get_locale(cat, name); | 64 | 		lm = __get_locale(cat, name); |
| 66 | 		if (lm == LOC_MAP_FAILED) { | 65 | 		if (lm == LOC_MAP_FAILED) { |
| 67 | 			UNLOCK(lock); | 66 | 			UNLOCK(__locale_lock); |
| 68 | 			return 0; | 67 | 			return 0; |
| 69 | 		} | 68 | 		} |
| 70 | 		libc.global_locale.cat[cat] = lm; | 69 | 		libc.global_locale.cat[cat] = lm; |
| ... | @@ -73,7 +72,7 @@ char *setlocale(int cat, const char *name) | ... | @@ -73,7 +72,7 @@ char *setlocale(int cat, const char *name) |
| 73 | 	} | 72 | 	} |
| 74 | 	char *ret = lm ? (char *)lm->name : "C"; | 73 | 	char *ret = lm ? (char *)lm->name : "C"; |
| 75 | 74 | ||
| 76 | 	UNLOCK(lock); | 75 | 	UNLOCK(__locale_lock); |
| 77 | 76 | ||
| 78 | 	return ret; | 77 | 	return ret; |
| 79 | } | 78 | } |
lib/libc/musl/src/malloc/free.c created+6| ... | @@ -0,0 +1,6 @@ | ||
| 1 | #include <stdlib.h> | ||
| 2 | |||
| 3 | void free(void *p) | ||
| 4 | { | ||
| 5 | 	return __libc_free(p); | ||
| 6 | } | ||
lib/libc/musl/src/malloc/libc_calloc.c created+4| ... | @@ -0,0 +1,4 @@ | ||
| 1 | #define calloc __libc_calloc | ||
| 2 | #define malloc __libc_malloc | ||
| 3 | |||
| 4 | #include "calloc.c" | ||
lib/libc/musl/src/malloc/lite_malloc.c+17-2| ... | @@ -6,6 +6,7 @@ | ... | @@ -6,6 +6,7 @@ |
| 6 | #include "libc.h" | 6 | #include "libc.h" |
| 7 | #include "lock.h" | 7 | #include "lock.h" |
| 8 | #include "syscall.h" | 8 | #include "syscall.h" |
| 9 | #include "fork_impl.h" | ||
| 9 | 10 | ||
| 10 | #define ALIGN 16 | 11 | #define ALIGN 16 |
| 11 | 12 | ||
| ... | @@ -31,10 +32,12 @@ static int traverses_stack_p(uintptr_t old, uintptr_t new) | ... | @@ -31,10 +32,12 @@ static int traverses_stack_p(uintptr_t old, uintptr_t new) |
| 31 | 	return 0; | 32 | 	return 0; |
| 32 | } | 33 | } |
| 33 | 34 | ||
| 35 | static volatile int lock[1]; | ||
| 36 | volatile int *const __bump_lockptr = lock; | ||
| 37 | |||
| 34 | static void *__simple_malloc(size_t n) | 38 | static void *__simple_malloc(size_t n) |
| 35 | { | 39 | { |
| 36 | 	static uintptr_t brk, cur, end; | 40 | 	static uintptr_t brk, cur, end; |
| 37 | 	static volatile int lock[1]; | ||
| 38 | 	static unsigned mmap_step; | 41 | 	static unsigned mmap_step; |
| 39 | 	size_t align=1; | 42 | 	size_t align=1; |
| 40 | 	void *p; | 43 | 	void *p; |
| ... | @@ -100,4 +103,16 @@ static void *__simple_malloc(size_t n) | ... | @@ -100,4 +103,16 @@ static void *__simple_malloc(size_t n) |
| 100 | 	return p; | 103 | 	return p; |
| 101 | } | 104 | } |
| 102 | 105 | ||
| 103 | weak_alias(__simple_malloc, malloc); | 106 | weak_alias(__simple_malloc, __libc_malloc_impl); |
| 107 | |||
| 108 | void *__libc_malloc(size_t n) | ||
| 109 | { | ||
| 110 | 	return __libc_malloc_impl(n); | ||
| 111 | } | ||
| 112 | |||
| 113 | static void *default_malloc(size_t n) | ||
| 114 | { | ||
| 115 | 	return __libc_malloc_impl(n); | ||
| 116 | } | ||
| 117 | |||
| 118 | weak_alias(default_malloc, malloc); |
lib/libc/musl/src/malloc/mallocng/glue.h+17-1| ... | @@ -20,6 +20,10 @@ | ... | @@ -20,6 +20,10 @@ |
| 20 | #define is_allzero __malloc_allzerop | 20 | #define is_allzero __malloc_allzerop |
| 21 | #define dump_heap __dump_heap | 21 | #define dump_heap __dump_heap |
| 22 | 22 | ||
| 23 | #define malloc __libc_malloc_impl | ||
| 24 | #define realloc __libc_realloc | ||
| 25 | #define free __libc_free | ||
| 26 | |||
| 23 | #if USE_REAL_ASSERT | 27 | #if USE_REAL_ASSERT |
| 24 | #include <assert.h> | 28 | #include <assert.h> |
| 25 | #else | 29 | #else |
| ... | @@ -56,7 +60,8 @@ __attribute__((__visibility__("hidden"))) | ... | @@ -56,7 +60,8 @@ __attribute__((__visibility__("hidden"))) |
| 56 | extern int __malloc_lock[1]; | 60 | extern int __malloc_lock[1]; |
| 57 | 61 | ||
| 58 | #define LOCK_OBJ_DEF \ | 62 | #define LOCK_OBJ_DEF \ |
| 59 | int __malloc_lock[1]; | 63 | int __malloc_lock[1]; \ |
| 64 | void __malloc_atfork(int who) { malloc_atfork(who); } | ||
| 60 | 65 | ||
| 61 | static inline void rdlock() | 66 | static inline void rdlock() |
| 62 | { | 67 | { |
| ... | @@ -73,5 +78,16 @@ static inline void unlock() | ... | @@ -73,5 +78,16 @@ static inline void unlock() |
| 73 | static inline void upgradelock() | 78 | static inline void upgradelock() |
| 74 | { | 79 | { |
| 75 | } | 80 | } |
| 81 | static inline void resetlock() | ||
| 82 | { | ||
| 83 | 	__malloc_lock[0] = 0; | ||
| 84 | } | ||
| 85 | |||
| 86 | static inline void malloc_atfork(int who) | ||
| 87 | { | ||
| 88 | 	if (who<0) rdlock(); | ||
| 89 | 	else if (who>0) resetlock(); | ||
| 90 | 	else unlock(); | ||
| 91 | } | ||
| 76 | 92 | ||
| 77 | #endif | 93 | #endif |
lib/libc/musl/src/malloc/mallocng/malloc_usable_size.c+1| ... | @@ -3,6 +3,7 @@ | ... | @@ -3,6 +3,7 @@ |
| 3 | 3 | ||
| 4 | size_t malloc_usable_size(void *p) | 4 | size_t malloc_usable_size(void *p) |
| 5 | { | 5 | { |
| 6 | 	if (!p) return 0; | ||
| 6 | 	struct meta *g = get_meta(p); | 7 | 	struct meta *g = get_meta(p); |
| 7 | 	int idx = get_slot_index(p); | 8 | 	int idx = get_slot_index(p); |
| 8 | 	size_t stride = get_stride(g); | 9 | 	size_t stride = get_stride(g); |
lib/libc/musl/src/malloc/oldmalloc/aligned_alloc.c created+53| ... | @@ -0,0 +1,53 @@ | ||
| 1 | #include <stdlib.h> | ||
| 2 | #include <stdint.h> | ||
| 3 | #include <errno.h> | ||
| 4 | #include "malloc_impl.h" | ||
| 5 | |||
| 6 | void *aligned_alloc(size_t align, size_t len) | ||
| 7 | { | ||
| 8 | 	unsigned char *mem, *new; | ||
| 9 | |||
| 10 | 	if ((align & -align) != align) { | ||
| 11 | 		errno = EINVAL; | ||
| 12 | 		return 0; | ||
| 13 | 	} | ||
| 14 | |||
| 15 | 	if (len > SIZE_MAX - align || | ||
| 16 | 	 (__malloc_replaced && !__aligned_alloc_replaced)) { | ||
| 17 | 		errno = ENOMEM; | ||
| 18 | 		return 0; | ||
| 19 | 	} | ||
| 20 | |||
| 21 | 	if (align <= SIZE_ALIGN) | ||
| 22 | 		return malloc(len); | ||
| 23 | |||
| 24 | 	if (!(mem = malloc(len + align-1))) | ||
| 25 | 		return 0; | ||
| 26 | |||
| 27 | 	new = (void *)((uintptr_t)mem + align-1 & -align); | ||
| 28 | 	if (new == mem) return mem; | ||
| 29 | |||
| 30 | 	struct chunk *c = MEM_TO_CHUNK(mem); | ||
| 31 | 	struct chunk *n = MEM_TO_CHUNK(new); | ||
| 32 | |||
| 33 | 	if (IS_MMAPPED(c)) { | ||
| 34 | 		/* Apply difference between aligned and original | ||
| 35 | 		 * address to the "extra" field of mmapped chunk. */ | ||
| 36 | 		n->psize = c->psize + (new-mem); | ||
| 37 | 		n->csize = c->csize - (new-mem); | ||
| 38 | 		return new; | ||
| 39 | 	} | ||
| 40 | |||
| 41 | 	struct chunk *t = NEXT_CHUNK(c); | ||
| 42 | |||
| 43 | 	/* Split the allocated chunk into two chunks. The aligned part | ||
| 44 | 	 * that will be used has the size in its footer reduced by the | ||
| 45 | 	 * difference between the aligned and original addresses, and | ||
| 46 | 	 * the resulting size copied to its header. A new header and | ||
| 47 | 	 * footer are written for the split-off part to be freed. */ | ||
| 48 | 	n->psize = c->csize = C_INUSE | (new-mem); | ||
| 49 | 	n->csize = t->psize -= new-mem; | ||
| 50 | |||
| 51 | 	__bin_chunk(c); | ||
| 52 | 	return new; | ||
| 53 | } | ||
lib/libc/musl/src/malloc/oldmalloc/malloc.c created+552| ... | @@ -0,0 +1,552 @@ | ||
| 1 | #define _GNU_SOURCE | ||
| 2 | #include <stdlib.h> | ||
| 3 | #include <string.h> | ||
| 4 | #include <limits.h> | ||
| 5 | #include <stdint.h> | ||
| 6 | #include <errno.h> | ||
| 7 | #include <sys/mman.h> | ||
| 8 | #include "libc.h" | ||
| 9 | #include "atomic.h" | ||
| 10 | #include "pthread_impl.h" | ||
| 11 | #include "malloc_impl.h" | ||
| 12 | #include "fork_impl.h" | ||
| 13 | |||
| 14 | #define malloc __libc_malloc | ||
| 15 | #define realloc __libc_realloc | ||
| 16 | #define free __libc_free | ||
| 17 | |||
| 18 | #if defined(__GNUC__) && defined(__PIC__) | ||
| 19 | #define inline inline __attribute__((always_inline)) | ||
| 20 | #endif | ||
| 21 | |||
| 22 | static struct { | ||
| 23 | 	volatile uint64_t binmap; | ||
| 24 | 	struct bin bins[64]; | ||
| 25 | 	volatile int split_merge_lock[2]; | ||
| 26 | } mal; | ||
| 27 | |||
| 28 | /* Synchronization tools */ | ||
| 29 | |||
| 30 | static inline void lock(volatile int *lk) | ||
| 31 | { | ||
| 32 | 	int need_locks = libc.need_locks; | ||
| 33 | 	if (need_locks) { | ||
| 34 | 		while(a_swap(lk, 1)) __wait(lk, lk+1, 1, 1); | ||
| 35 | 		if (need_locks < 0) libc.need_locks = 0; | ||
| 36 | 	} | ||
| 37 | } | ||
| 38 | |||
| 39 | static inline void unlock(volatile int *lk) | ||
| 40 | { | ||
| 41 | 	if (lk[0]) { | ||
| 42 | 		a_store(lk, 0); | ||
| 43 | 		if (lk[1]) __wake(lk, 1, 1); | ||
| 44 | 	} | ||
| 45 | } | ||
| 46 | |||
| 47 | static inline void lock_bin(int i) | ||
| 48 | { | ||
| 49 | 	lock(mal.bins[i].lock); | ||
| 50 | 	if (!mal.bins[i].head) | ||
| 51 | 		mal.bins[i].head = mal.bins[i].tail = BIN_TO_CHUNK(i); | ||
| 52 | } | ||
| 53 | |||
| 54 | static inline void unlock_bin(int i) | ||
| 55 | { | ||
| 56 | 	unlock(mal.bins[i].lock); | ||
| 57 | } | ||
| 58 | |||
| 59 | static int first_set(uint64_t x) | ||
| 60 | { | ||
| 61 | #if 1 | ||
| 62 | 	return a_ctz_64(x); | ||
| 63 | #else | ||
| 64 | 	static const char debruijn64[64] = { | ||
| 65 | 		0, 1, 2, 53, 3, 7, 54, 27, 4, 38, 41, 8, 34, 55, 48, 28, | ||
| 66 | 		62, 5, 39, 46, 44, 42, 22, 9, 24, 35, 59, 56, 49, 18, 29, 11, | ||
| 67 | 		63, 52, 6, 26, 37, 40, 33, 47, 61, 45, 43, 21, 23, 58, 17, 10, | ||
| 68 | 		51, 25, 36, 32, 60, 20, 57, 16, 50, 31, 19, 15, 30, 14, 13, 12 | ||
| 69 | 	}; | ||
| 70 | 	static const char debruijn32[32] = { | ||
| 71 | 		0, 1, 23, 2, 29, 24, 19, 3, 30, 27, 25, 11, 20, 8, 4, 13, | ||
| 72 | 		31, 22, 28, 18, 26, 10, 7, 12, 21, 17, 9, 6, 16, 5, 15, 14 | ||
| 73 | 	}; | ||
| 74 | 	if (sizeof(long) < 8) { | ||
| 75 | 		uint32_t y = x; | ||
| 76 | 		if (!y) { | ||
| 77 | 			y = x>>32; | ||
| 78 | 			return 32 + debruijn32[(y&-y)*0x076be629 >> 27]; | ||
| 79 | 		} | ||
| 80 | 		return debruijn32[(y&-y)*0x076be629 >> 27]; | ||
| 81 | 	} | ||
| 82 | 	return debruijn64[(x&-x)*0x022fdd63cc95386dull >> 58]; | ||
| 83 | #endif | ||
| 84 | } | ||
| 85 | |||
| 86 | static const unsigned char bin_tab[60] = { | ||
| 87 | 	 32,33,34,35,36,36,37,37,38,38,39,39, | ||
| 88 | 	40,40,40,40,41,41,41,41,42,42,42,42,43,43,43,43, | ||
| 89 | 	44,44,44,44,44,44,44,44,45,45,45,45,45,45,45,45, | ||
| 90 | 	46,46,46,46,46,46,46,46,47,47,47,47,47,47,47,47, | ||
| 91 | }; | ||
| 92 | |||
| 93 | static int bin_index(size_t x) | ||
| 94 | { | ||
| 95 | 	x = x / SIZE_ALIGN - 1; | ||
| 96 | 	if (x <= 32) return x; | ||
| 97 | 	if (x < 512) return bin_tab[x/8-4]; | ||
| 98 | 	if (x > 0x1c00) return 63; | ||
| 99 | 	return bin_tab[x/128-4] + 16; | ||
| 100 | } | ||
| 101 | |||
| 102 | static int bin_index_up(size_t x) | ||
| 103 | { | ||
| 104 | 	x = x / SIZE_ALIGN - 1; | ||
| 105 | 	if (x <= 32) return x; | ||
| 106 | 	x--; | ||
| 107 | 	if (x < 512) return bin_tab[x/8-4] + 1; | ||
| 108 | 	return bin_tab[x/128-4] + 17; | ||
| 109 | } | ||
| 110 | |||
| 111 | #if 0 | ||
| 112 | void __dump_heap(int x) | ||
| 113 | { | ||
| 114 | 	struct chunk *c; | ||
| 115 | 	int i; | ||
| 116 | 	for (c = (void *)mal.heap; CHUNK_SIZE(c); c = NEXT_CHUNK(c)) | ||
| 117 | 		fprintf(stderr, "base %p size %zu (%d) flags %d/%d\n", | ||
| 118 | 			c, CHUNK_SIZE(c), bin_index(CHUNK_SIZE(c)), | ||
| 119 | 			c->csize & 15, | ||
| 120 | 			NEXT_CHUNK(c)->psize & 15); | ||
| 121 | 	for (i=0; i<64; i++) { | ||
| 122 | 		if (mal.bins[i].head != BIN_TO_CHUNK(i) && mal.bins[i].head) { | ||
| 123 | 			fprintf(stderr, "bin %d: %p\n", i, mal.bins[i].head); | ||
| 124 | 			if (!(mal.binmap & 1ULL<<i)) | ||
| 125 | 				fprintf(stderr, "missing from binmap!\n"); | ||
| 126 | 		} else if (mal.binmap & 1ULL<<i) | ||
| 127 | 			fprintf(stderr, "binmap wrongly contains %d!\n", i); | ||
| 128 | 	} | ||
| 129 | } | ||
| 130 | #endif | ||
| 131 | |||
| 132 | /* This function returns true if the interval [old,new] | ||
| 133 | * intersects the 'len'-sized interval below &libc.auxv | ||
| 134 | * (interpreted as the main-thread stack) or below &b | ||
| 135 | * (the current stack). It is used to defend against | ||
| 136 | * buggy brk implementations that can cross the stack. */ | ||
| 137 | |||
| 138 | static int traverses_stack_p(uintptr_t old, uintptr_t new) | ||
| 139 | { | ||
| 140 | 	const uintptr_t len = 8<<20; | ||
| 141 | 	uintptr_t a, b; | ||
| 142 | |||
| 143 | 	b = (uintptr_t)libc.auxv; | ||
| 144 | 	a = b > len ? b-len : 0; | ||
| 145 | 	if (new>a && old<b) return 1; | ||
| 146 | |||
| 147 | 	b = (uintptr_t)&b; | ||
| 148 | 	a = b > len ? b-len : 0; | ||
| 149 | 	if (new>a && old<b) return 1; | ||
| 150 | |||
| 151 | 	return 0; | ||
| 152 | } | ||
| 153 | |||
| 154 | /* Expand the heap in-place if brk can be used, or otherwise via mmap, | ||
| 155 | * using an exponential lower bound on growth by mmap to make | ||
| 156 | * fragmentation asymptotically irrelevant. The size argument is both | ||
| 157 | * an input and an output, since the caller needs to know the size | ||
| 158 | * allocated, which will be larger than requested due to page alignment | ||
| 159 | * and mmap minimum size rules. The caller is responsible for locking | ||
| 160 | * to prevent concurrent calls. */ | ||
| 161 | |||
| 162 | static void *__expand_heap(size_t *pn) | ||
| 163 | { | ||
| 164 | 	static uintptr_t brk; | ||
| 165 | 	static unsigned mmap_step; | ||
| 166 | 	size_t n = *pn; | ||
| 167 | |||
| 168 | 	if (n > SIZE_MAX/2 - PAGE_SIZE) { | ||
| 169 | 		errno = ENOMEM; | ||
| 170 | 		return 0; | ||
| 171 | 	} | ||
| 172 | 	n += -n & PAGE_SIZE-1; | ||
| 173 | |||
| 174 | 	if (!brk) { | ||
| 175 | 		brk = __syscall(SYS_brk, 0); | ||
| 176 | 		brk += -brk & PAGE_SIZE-1; | ||
| 177 | 	} | ||
| 178 | |||
| 179 | 	if (n < SIZE_MAX-brk && !traverses_stack_p(brk, brk+n) | ||
| 180 | 	 && __syscall(SYS_brk, brk+n)==brk+n) { | ||
| 181 | 		*pn = n; | ||
| 182 | 		brk += n; | ||
| 183 | 		return (void *)(brk-n); | ||
| 184 | 	} | ||
| 185 | |||
| 186 | 	size_t min = (size_t)PAGE_SIZE << mmap_step/2; | ||
| 187 | 	if (n < min) n = min; | ||
| 188 | 	void *area = __mmap(0, n, PROT_READ|PROT_WRITE, | ||
| 189 | 		MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); | ||
| 190 | 	if (area == MAP_FAILED) return 0; | ||
| 191 | 	*pn = n; | ||
| 192 | 	mmap_step++; | ||
| 193 | 	return area; | ||
| 194 | } | ||
| 195 | |||
| 196 | static struct chunk *expand_heap(size_t n) | ||
| 197 | { | ||
| 198 | 	static void *end; | ||
| 199 | 	void *p; | ||
| 200 | 	struct chunk *w; | ||
| 201 | |||
| 202 | 	/* The argument n already accounts for the caller's chunk | ||
| 203 | 	 * overhead needs, but if the heap can't be extended in-place, | ||
| 204 | 	 * we need room for an extra zero-sized sentinel chunk. */ | ||
| 205 | 	n += SIZE_ALIGN; | ||
| 206 | |||
| 207 | 	p = __expand_heap(&n); | ||
| 208 | 	if (!p) return 0; | ||
| 209 | |||
| 210 | 	/* If not just expanding existing space, we need to make a | ||
| 211 | 	 * new sentinel chunk below the allocated space. */ | ||
| 212 | 	if (p != end) { | ||
| 213 | 		/* Valid/safe because of the prologue increment. */ | ||
| 214 | 		n -= SIZE_ALIGN; | ||
| 215 | 		p = (char *)p + SIZE_ALIGN; | ||
| 216 | 		w = MEM_TO_CHUNK(p); | ||
| 217 | 		w->psize = 0 | C_INUSE; | ||
| 218 | 	} | ||
| 219 | |||
| 220 | 	/* Record new heap end and fill in footer. */ | ||
| 221 | 	end = (char *)p + n; | ||
| 222 | 	w = MEM_TO_CHUNK(end); | ||
| 223 | 	w->psize = n | C_INUSE; | ||
| 224 | 	w->csize = 0 | C_INUSE; | ||
| 225 | |||
| 226 | 	/* Fill in header, which may be new or may be replacing a | ||
| 227 | 	 * zero-size sentinel header at the old end-of-heap. */ | ||
| 228 | 	w = MEM_TO_CHUNK(p); | ||
| 229 | 	w->csize = n | C_INUSE; | ||
| 230 | |||
| 231 | 	return w; | ||
| 232 | } | ||
| 233 | |||
| 234 | static int adjust_size(size_t *n) | ||
| 235 | { | ||
| 236 | 	/* Result of pointer difference must fit in ptrdiff_t. */ | ||
| 237 | 	if (*n-1 > PTRDIFF_MAX - SIZE_ALIGN - PAGE_SIZE) { | ||
| 238 | 		if (*n) { | ||
| 239 | 			errno = ENOMEM; | ||
| 240 | 			return -1; | ||
| 241 | 		} else { | ||
| 242 | 			*n = SIZE_ALIGN; | ||
| 243 | 			return 0; | ||
| 244 | 		} | ||
| 245 | 	} | ||
| 246 | 	*n = (*n + OVERHEAD + SIZE_ALIGN - 1) & SIZE_MASK; | ||
| 247 | 	return 0; | ||
| 248 | } | ||
| 249 | |||
| 250 | static void unbin(struct chunk *c, int i) | ||
| 251 | { | ||
| 252 | 	if (c->prev == c->next) | ||
| 253 | 		a_and_64(&mal.binmap, ~(1ULL<<i)); | ||
| 254 | 	c->prev->next = c->next; | ||
| 255 | 	c->next->prev = c->prev; | ||
| 256 | 	c->csize |= C_INUSE; | ||
| 257 | 	NEXT_CHUNK(c)->psize |= C_INUSE; | ||
| 258 | } | ||
| 259 | |||
| 260 | static void bin_chunk(struct chunk *self, int i) | ||
| 261 | { | ||
| 262 | 	self->next = BIN_TO_CHUNK(i); | ||
| 263 | 	self->prev = mal.bins[i].tail; | ||
| 264 | 	self->next->prev = self; | ||
| 265 | 	self->prev->next = self; | ||
| 266 | 	if (self->prev == BIN_TO_CHUNK(i)) | ||
| 267 | 		a_or_64(&mal.binmap, 1ULL<<i); | ||
| 268 | } | ||
| 269 | |||
| 270 | static void trim(struct chunk *self, size_t n) | ||
| 271 | { | ||
| 272 | 	size_t n1 = CHUNK_SIZE(self); | ||
| 273 | 	struct chunk *next, *split; | ||
| 274 | |||
| 275 | 	if (n >= n1 - DONTCARE) return; | ||
| 276 | |||
| 277 | 	next = NEXT_CHUNK(self); | ||
| 278 | 	split = (void *)((char *)self + n); | ||
| 279 | |||
| 280 | 	split->psize = n | C_INUSE; | ||
| 281 | 	split->csize = n1-n; | ||
| 282 | 	next->psize = n1-n; | ||
| 283 | 	self->csize = n | C_INUSE; | ||
| 284 | |||
| 285 | 	int i = bin_index(n1-n); | ||
| 286 | 	lock_bin(i); | ||
| 287 | |||
| 288 | 	bin_chunk(split, i); | ||
| 289 | |||
| 290 | 	unlock_bin(i); | ||
| 291 | } | ||
| 292 | |||
| 293 | void *malloc(size_t n) | ||
| 294 | { | ||
| 295 | 	struct chunk *c; | ||
| 296 | 	int i, j; | ||
| 297 | 	uint64_t mask; | ||
| 298 | |||
| 299 | 	if (adjust_size(&n) < 0) return 0; | ||
| 300 | |||
| 301 | 	if (n > MMAP_THRESHOLD) { | ||
| 302 | 		size_t len = n + OVERHEAD + PAGE_SIZE - 1 & -PAGE_SIZE; | ||
| 303 | 		char *base = __mmap(0, len, PROT_READ|PROT_WRITE, | ||
| 304 | 			MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); | ||
| 305 | 		if (base == (void *)-1) return 0; | ||
| 306 | 		c = (void *)(base + SIZE_ALIGN - OVERHEAD); | ||
| 307 | 		c->csize = len - (SIZE_ALIGN - OVERHEAD); | ||
| 308 | 		c->psize = SIZE_ALIGN - OVERHEAD; | ||
| 309 | 		return CHUNK_TO_MEM(c); | ||
| 310 | 	} | ||
| 311 | |||
| 312 | 	i = bin_index_up(n); | ||
| 313 | 	if (i<63 && (mal.binmap & (1ULL<<i))) { | ||
| 314 | 		lock_bin(i); | ||
| 315 | 		c = mal.bins[i].head; | ||
| 316 | 		if (c != BIN_TO_CHUNK(i) && CHUNK_SIZE(c)-n <= DONTCARE) { | ||
| 317 | 			unbin(c, i); | ||
| 318 | 			unlock_bin(i); | ||
| 319 | 			return CHUNK_TO_MEM(c); | ||
| 320 | 		} | ||
| 321 | 		unlock_bin(i); | ||
| 322 | 	} | ||
| 323 | 	lock(mal.split_merge_lock); | ||
| 324 | 	for (mask = mal.binmap & -(1ULL<<i); mask; mask -= (mask&-mask)) { | ||
| 325 | 		j = first_set(mask); | ||
| 326 | 		lock_bin(j); | ||
| 327 | 		c = mal.bins[j].head; | ||
| 328 | 		if (c != BIN_TO_CHUNK(j)) { | ||
| 329 | 			unbin(c, j); | ||
| 330 | 			unlock_bin(j); | ||
| 331 | 			break; | ||
| 332 | 		} | ||
| 333 | 		unlock_bin(j); | ||
| 334 | 	} | ||
| 335 | 	if (!mask) { | ||
| 336 | 		c = expand_heap(n); | ||
| 337 | 		if (!c) { | ||
| 338 | 			unlock(mal.split_merge_lock); | ||
| 339 | 			return 0; | ||
| 340 | 		} | ||
| 341 | 	} | ||
| 342 | 	trim(c, n); | ||
| 343 | 	unlock(mal.split_merge_lock); | ||
| 344 | 	return CHUNK_TO_MEM(c); | ||
| 345 | } | ||
| 346 | |||
| 347 | int __malloc_allzerop(void *p) | ||
| 348 | { | ||
| 349 | 	return IS_MMAPPED(MEM_TO_CHUNK(p)); | ||
| 350 | } | ||
| 351 | |||
| 352 | void *realloc(void *p, size_t n) | ||
| 353 | { | ||
| 354 | 	struct chunk *self, *next; | ||
| 355 | 	size_t n0, n1; | ||
| 356 | 	void *new; | ||
| 357 | |||
| 358 | 	if (!p) return malloc(n); | ||
| 359 | |||
| 360 | 	if (adjust_size(&n) < 0) return 0; | ||
| 361 | |||
| 362 | 	self = MEM_TO_CHUNK(p); | ||
| 363 | 	n1 = n0 = CHUNK_SIZE(self); | ||
| 364 | |||
| 365 | 	if (n<=n0 && n0-n<=DONTCARE) return p; | ||
| 366 | |||
| 367 | 	if (IS_MMAPPED(self)) { | ||
| 368 | 		size_t extra = self->psize; | ||
| 369 | 		char *base = (char *)self - extra; | ||
| 370 | 		size_t oldlen = n0 + extra; | ||
| 371 | 		size_t newlen = n + extra; | ||
| 372 | 		/* Crash on realloc of freed chunk */ | ||
| 373 | 		if (extra & 1) a_crash(); | ||
| 374 | 		if (newlen < PAGE_SIZE && (new = malloc(n-OVERHEAD))) { | ||
| 375 | 			n0 = n; | ||
| 376 | 			goto copy_free_ret; | ||
| 377 | 		} | ||
| 378 | 		newlen = (newlen + PAGE_SIZE-1) & -PAGE_SIZE; | ||
| 379 | 		if (oldlen == newlen) return p; | ||
| 380 | 		base = __mremap(base, oldlen, newlen, MREMAP_MAYMOVE); | ||
| 381 | 		if (base == (void *)-1) | ||
| 382 | 			goto copy_realloc; | ||
| 383 | 		self = (void *)(base + extra); | ||
| 384 | 		self->csize = newlen - extra; | ||
| 385 | 		return CHUNK_TO_MEM(self); | ||
| 386 | 	} | ||
| 387 | |||
| 388 | 	next = NEXT_CHUNK(self); | ||
| 389 | |||
| 390 | 	/* Crash on corrupted footer (likely from buffer overflow) */ | ||
| 391 | 	if (next->psize != self->csize) a_crash(); | ||
| 392 | |||
| 393 | 	if (n < n0) { | ||
| 394 | 		int i = bin_index_up(n); | ||
| 395 | 		int j = bin_index(n0); | ||
| 396 | 		if (i<j && (mal.binmap & (1ULL << i))) | ||
| 397 | 			goto copy_realloc; | ||
| 398 | 		struct chunk *split = (void *)((char *)self + n); | ||
| 399 | 		self->csize = split->psize = n | C_INUSE; | ||
| 400 | 		split->csize = next->psize = n0-n | C_INUSE; | ||
| 401 | 		__bin_chunk(split); | ||
| 402 | 		return CHUNK_TO_MEM(self); | ||
| 403 | 	} | ||
| 404 | |||
| 405 | 	lock(mal.split_merge_lock); | ||
| 406 | |||
| 407 | 	size_t nsize = next->csize & C_INUSE ? 0 : CHUNK_SIZE(next); | ||
| 408 | 	if (n0+nsize >= n) { | ||
| 409 | 		int i = bin_index(nsize); | ||
| 410 | 		lock_bin(i); | ||
| 411 | 		if (!(next->csize & C_INUSE)) { | ||
| 412 | 			unbin(next, i); | ||
| 413 | 			unlock_bin(i); | ||
| 414 | 			next = NEXT_CHUNK(next); | ||
| 415 | 			self->csize = next->psize = n0+nsize | C_INUSE; | ||
| 416 | 			trim(self, n); | ||
| 417 | 			unlock(mal.split_merge_lock); | ||
| 418 | 			return CHUNK_TO_MEM(self); | ||
| 419 | 		} | ||
| 420 | 		unlock_bin(i); | ||
| 421 | 	} | ||
| 422 | 	unlock(mal.split_merge_lock); | ||
| 423 | |||
| 424 | copy_realloc: | ||
| 425 | 	/* As a last resort, allocate a new chunk and copy to it. */ | ||
| 426 | 	new = malloc(n-OVERHEAD); | ||
| 427 | 	if (!new) return 0; | ||
| 428 | copy_free_ret: | ||
| 429 | 	memcpy(new, p, (n<n0 ? n : n0) - OVERHEAD); | ||
| 430 | 	free(CHUNK_TO_MEM(self)); | ||
| 431 | 	return new; | ||
| 432 | } | ||
| 433 | |||
| 434 | void __bin_chunk(struct chunk *self) | ||
| 435 | { | ||
| 436 | 	struct chunk *next = NEXT_CHUNK(self); | ||
| 437 | |||
| 438 | 	/* Crash on corrupted footer (likely from buffer overflow) */ | ||
| 439 | 	if (next->psize != self->csize) a_crash(); | ||
| 440 | |||
| 441 | 	lock(mal.split_merge_lock); | ||
| 442 | |||
| 443 | 	size_t osize = CHUNK_SIZE(self), size = osize; | ||
| 444 | |||
| 445 | 	/* Since we hold split_merge_lock, only transition from free to | ||
| 446 | 	 * in-use can race; in-use to free is impossible */ | ||
| 447 | 	size_t psize = self->psize & C_INUSE ? 0 : CHUNK_PSIZE(self); | ||
| 448 | 	size_t nsize = next->csize & C_INUSE ? 0 : CHUNK_SIZE(next); | ||
| 449 | |||
| 450 | 	if (psize) { | ||
| 451 | 		int i = bin_index(psize); | ||
| 452 | 		lock_bin(i); | ||
| 453 | 		if (!(self->psize & C_INUSE)) { | ||
| 454 | 			struct chunk *prev = PREV_CHUNK(self); | ||
| 455 | 			unbin(prev, i); | ||
| 456 | 			self = prev; | ||
| 457 | 			size += psize; | ||
| 458 | 		} | ||
| 459 | 		unlock_bin(i); | ||
| 460 | 	} | ||
| 461 | 	if (nsize) { | ||
| 462 | 		int i = bin_index(nsize); | ||
| 463 | 		lock_bin(i); | ||
| 464 | 		if (!(next->csize & C_INUSE)) { | ||
| 465 | 			unbin(next, i); | ||
| 466 | 			next = NEXT_CHUNK(next); | ||
| 467 | 			size += nsize; | ||
| 468 | 		} | ||
| 469 | 		unlock_bin(i); | ||
| 470 | 	} | ||
| 471 | |||
| 472 | 	int i = bin_index(size); | ||
| 473 | 	lock_bin(i); | ||
| 474 | |||
| 475 | 	self->csize = size; | ||
| 476 | 	next->psize = size; | ||
| 477 | 	bin_chunk(self, i); | ||
| 478 | 	unlock(mal.split_merge_lock); | ||
| 479 | |||
| 480 | 	/* Replace middle of large chunks with fresh zero pages */ | ||
| 481 | 	if (size > RECLAIM && (size^(size-osize)) > size-osize) { | ||
| 482 | 		uintptr_t a = (uintptr_t)self + SIZE_ALIGN+PAGE_SIZE-1 & -PAGE_SIZE; | ||
| 483 | 		uintptr_t b = (uintptr_t)next - SIZE_ALIGN & -PAGE_SIZE; | ||
| 484 | #if 1 | ||
| 485 | 		__madvise((void *)a, b-a, MADV_DONTNEED); | ||
| 486 | #else | ||
| 487 | 		__mmap((void *)a, b-a, PROT_READ|PROT_WRITE, | ||
| 488 | 			MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED, -1, 0); | ||
| 489 | #endif | ||
| 490 | 	} | ||
| 491 | |||
| 492 | 	unlock_bin(i); | ||
| 493 | } | ||
| 494 | |||
| 495 | static void unmap_chunk(struct chunk *self) | ||
| 496 | { | ||
| 497 | 	size_t extra = self->psize; | ||
| 498 | 	char *base = (char *)self - extra; | ||
| 499 | 	size_t len = CHUNK_SIZE(self) + extra; | ||
| 500 | 	/* Crash on double free */ | ||
| 501 | 	if (extra & 1) a_crash(); | ||
| 502 | 	__munmap(base, len); | ||
| 503 | } | ||
| 504 | |||
| 505 | void free(void *p) | ||
| 506 | { | ||
| 507 | 	if (!p) return; | ||
| 508 | |||
| 509 | 	struct chunk *self = MEM_TO_CHUNK(p); | ||
| 510 | |||
| 511 | 	if (IS_MMAPPED(self)) | ||
| 512 | 		unmap_chunk(self); | ||
| 513 | 	else | ||
| 514 | 		__bin_chunk(self); | ||
| 515 | } | ||
| 516 | |||
| 517 | void __malloc_donate(char *start, char *end) | ||
| 518 | { | ||
| 519 | 	size_t align_start_up = (SIZE_ALIGN-1) & (-(uintptr_t)start - OVERHEAD); | ||
| 520 | 	size_t align_end_down = (SIZE_ALIGN-1) & (uintptr_t)end; | ||
| 521 | |||
| 522 | 	/* Getting past this condition ensures that the padding for alignment | ||
| 523 | 	 * and header overhead will not overflow and will leave a nonzero | ||
| 524 | 	 * multiple of SIZE_ALIGN bytes between start and end. */ | ||
| 525 | 	if (end - start <= OVERHEAD + align_start_up + align_end_down) | ||
| 526 | 		return; | ||
| 527 | 	start += align_start_up + OVERHEAD; | ||
| 528 | 	end -= align_end_down; | ||
| 529 | |||
| 530 | 	struct chunk *c = MEM_TO_CHUNK(start), *n = MEM_TO_CHUNK(end); | ||
| 531 | 	c->psize = n->csize = C_INUSE; | ||
| 532 | 	c->csize = n->psize = C_INUSE | (end-start); | ||
| 533 | 	__bin_chunk(c); | ||
| 534 | } | ||
| 535 | |||
| 536 | void __malloc_atfork(int who) | ||
| 537 | { | ||
| 538 | 	if (who<0) { | ||
| 539 | 		lock(mal.split_merge_lock); | ||
| 540 | 		for (int i=0; i<64; i++) | ||
| 541 | 			lock(mal.bins[i].lock); | ||
| 542 | 	} else if (!who) { | ||
| 543 | 		for (int i=0; i<64; i++) | ||
| 544 | 			unlock(mal.bins[i].lock); | ||
| 545 | 		unlock(mal.split_merge_lock); | ||
| 546 | 	} else { | ||
| 547 | 		for (int i=0; i<64; i++) | ||
| 548 | 			mal.bins[i].lock[0] = mal.bins[i].lock[1] = 0; | ||
| 549 | 		mal.split_merge_lock[1] = 0; | ||
| 550 | 		mal.split_merge_lock[0] = 0; | ||
| 551 | 	} | ||
| 552 | } | ||
lib/libc/musl/src/malloc/oldmalloc/malloc_impl.h created+39| ... | @@ -0,0 +1,39 @@ | ||
| 1 | #ifndef MALLOC_IMPL_H | ||
| 2 | #define MALLOC_IMPL_H | ||
| 3 | |||
| 4 | #include <sys/mman.h> | ||
| 5 | #include "dynlink.h" | ||
| 6 | |||
| 7 | struct chunk { | ||
| 8 | 	size_t psize, csize; | ||
| 9 | 	struct chunk *next, *prev; | ||
| 10 | }; | ||
| 11 | |||
| 12 | struct bin { | ||
| 13 | 	volatile int lock[2]; | ||
| 14 | 	struct chunk *head; | ||
| 15 | 	struct chunk *tail; | ||
| 16 | }; | ||
| 17 | |||
| 18 | #define SIZE_ALIGN (4*sizeof(size_t)) | ||
| 19 | #define SIZE_MASK (-SIZE_ALIGN) | ||
| 20 | #define OVERHEAD (2*sizeof(size_t)) | ||
| 21 | #define MMAP_THRESHOLD (0x1c00*SIZE_ALIGN) | ||
| 22 | #define DONTCARE 16 | ||
| 23 | #define RECLAIM 163840 | ||
| 24 | |||
| 25 | #define CHUNK_SIZE(c) ((c)->csize & -2) | ||
| 26 | #define CHUNK_PSIZE(c) ((c)->psize & -2) | ||
| 27 | #define PREV_CHUNK(c) ((struct chunk *)((char *)(c) - CHUNK_PSIZE(c))) | ||
| 28 | #define NEXT_CHUNK(c) ((struct chunk *)((char *)(c) + CHUNK_SIZE(c))) | ||
| 29 | #define MEM_TO_CHUNK(p) (struct chunk *)((char *)(p) - OVERHEAD) | ||
| 30 | #define CHUNK_TO_MEM(c) (void *)((char *)(c) + OVERHEAD) | ||
| 31 | #define BIN_TO_CHUNK(i) (MEM_TO_CHUNK(&mal.bins[i].head)) | ||
| 32 | |||
| 33 | #define C_INUSE ((size_t)1) | ||
| 34 | |||
| 35 | #define IS_MMAPPED(c) !((c)->csize & (C_INUSE)) | ||
| 36 | |||
| 37 | hidden void __bin_chunk(struct chunk *); | ||
| 38 | |||
| 39 | #endif | ||
lib/libc/musl/src/malloc/oldmalloc/malloc_usable_size.c created+9| ... | @@ -0,0 +1,9 @@ | ||
| 1 | #include <malloc.h> | ||
| 2 | #include "malloc_impl.h" | ||
| 3 | |||
| 4 | hidden void *(*const __realloc_dep)(void *, size_t) = realloc; | ||
| 5 | |||
| 6 | size_t malloc_usable_size(void *p) | ||
| 7 | { | ||
| 8 | 	return p ? CHUNK_SIZE(MEM_TO_CHUNK(p)) - OVERHEAD : 0; | ||
| 9 | } | ||
lib/libc/musl/src/malloc/realloc.c created+6| ... | @@ -0,0 +1,6 @@ | ||
| 1 | #include <stdlib.h> | ||
| 2 | |||
| 3 | void *realloc(void *p, size_t n) | ||
| 4 | { | ||
| 5 | 	return __libc_realloc(p, n); | ||
| 6 | } | ||
lib/libc/musl/src/malloc/reallocarray.c created+13| ... | @@ -0,0 +1,13 @@ | ||
| 1 | #define _BSD_SOURCE | ||
| 2 | #include <errno.h> | ||
| 3 | #include <stdlib.h> | ||
| 4 | |||
| 5 | void *reallocarray(void *ptr, size_t m, size_t n) | ||
| 6 | { | ||
| 7 | 	if (n && m > -1 / n) { | ||
| 8 | 		errno = ENOMEM; | ||
| 9 | 		return 0; | ||
| 10 | 	} | ||
| 11 | |||
| 12 | 	return realloc(ptr, m * n); | ||
| 13 | } | ||
lib/libc/musl/src/math/__math_invalidl.c created+9| ... | @@ -0,0 +1,9 @@ | ||
| 1 | #include <float.h> | ||
| 2 | #include "libm.h" | ||
| 3 | |||
| 4 | #if LDBL_MANT_DIG != DBL_MANT_DIG | ||
| 5 | long double __math_invalidl(long double x) | ||
| 6 | { | ||
| 7 | 	return (x - x) / (x - x); | ||
| 8 | } | ||
| 9 | #endif | ||
lib/libc/musl/src/math/arm/fabs.c+1-1| ... | @@ -1,6 +1,6 @@ | ... | @@ -1,6 +1,6 @@ |
| 1 | #include <math.h> | 1 | #include <math.h> |
| 2 | 2 | ||
| 3 | #if __ARM_PCS_VFP | 3 | #if __ARM_PCS_VFP && __ARM_FP&8 |
| 4 | 4 | ||
| 5 | double fabs(double x) | 5 | double fabs(double x) |
| 6 | { | 6 | { |
lib/libc/musl/src/math/arm/sqrt.c+1-1| ... | @@ -1,6 +1,6 @@ | ... | @@ -1,6 +1,6 @@ |
| 1 | #include <math.h> | 1 | #include <math.h> |
| 2 | 2 | ||
| 3 | #if __ARM_PCS_VFP || (__VFP_FP__ && !__SOFTFP__) | 3 | #if (__ARM_PCS_VFP || (__VFP_FP__ && !__SOFTFP__)) && (__ARM_FP&8) |
| 4 | 4 | ||
| 5 | double sqrt(double x) | 5 | double sqrt(double x) |
| 6 | { | 6 | { |
lib/libc/musl/src/math/sqrt.c+147-173| ... | @@ -1,184 +1,158 @@ | ... | @@ -1,184 +1,158 @@ |
| 1 | /* origin: FreeBSD /usr/src/lib/msun/src/e_sqrt.c */ | 1 | #include <stdint.h> |
| 2 | /* | 2 | #include <math.h> |
| 3 | * ==================================================== | ||
| 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. | ||
| 5 | * | ||
| 6 | * Developed at SunSoft, a Sun Microsystems, Inc. business. | ||
| 7 | * Permission to use, copy, modify, and distribute this | ||
| 8 | * software is freely granted, provided that this notice | ||
| 9 | * is preserved. | ||
| 10 | * ==================================================== | ||
| 11 | */ | ||
| 12 | /* sqrt(x) | ||
| 13 | * Return correctly rounded sqrt. | ||
| 14 | * ------------------------------------------ | ||
| 15 | * | Use the hardware sqrt if you have one | | ||
| 16 | * ------------------------------------------ | ||
| 17 | * Method: | ||
| 18 | * Bit by bit method using integer arithmetic. (Slow, but portable) | ||
| 19 | * 1. Normalization | ||
| 20 | * Scale x to y in [1,4) with even powers of 2: | ||
| 21 | * find an integer k such that 1 <= (y=x*2^(2k)) < 4, then | ||
| 22 | * sqrt(x) = 2^k * sqrt(y) | ||
| 23 | * 2. Bit by bit computation | ||
| 24 | * Let q = sqrt(y) truncated to i bit after binary point (q = 1), | ||
| 25 | * i 0 | ||
| 26 | * i+1 2 | ||
| 27 | * s = 2*q , and y = 2 * ( y - q ). (1) | ||
| 28 | * i i i i | ||
| 29 | * | ||
| 30 | * To compute q from q , one checks whether | ||
| 31 | * i+1 i | ||
| 32 | * | ||
| 33 | * -(i+1) 2 | ||
| 34 | * (q + 2 ) <= y. (2) | ||
| 35 | * i | ||
| 36 | * -(i+1) | ||
| 37 | * If (2) is false, then q = q ; otherwise q = q + 2 . | ||
| 38 | * i+1 i i+1 i | ||
| 39 | * | ||
| 40 | * With some algebric manipulation, it is not difficult to see | ||
| 41 | * that (2) is equivalent to | ||
| 42 | * -(i+1) | ||
| 43 | * s + 2 <= y (3) | ||
| 44 | * i i | ||
| 45 | * | ||
| 46 | * The advantage of (3) is that s and y can be computed by | ||
| 47 | * i i | ||
| 48 | * the following recurrence formula: | ||
| 49 | * if (3) is false | ||
| 50 | * | ||
| 51 | * s = s , y = y ; (4) | ||
| 52 | * i+1 i i+1 i | ||
| 53 | * | ||
| 54 | * otherwise, | ||
| 55 | * -i -(i+1) | ||
| 56 | * s = s + 2 , y = y - s - 2 (5) | ||
| 57 | * i+1 i i+1 i i | ||
| 58 | * | ||
| 59 | * One may easily use induction to prove (4) and (5). | ||
| 60 | * Note. Since the left hand side of (3) contain only i+2 bits, | ||
| 61 | * it does not necessary to do a full (53-bit) comparison | ||
| 62 | * in (3). | ||
| 63 | * 3. Final rounding | ||
| 64 | * After generating the 53 bits result, we compute one more bit. | ||
| 65 | * Together with the remainder, we can decide whether the | ||
| 66 | * result is exact, bigger than 1/2ulp, or less than 1/2ulp | ||
| 67 | * (it will never equal to 1/2ulp). | ||
| 68 | * The rounding mode can be detected by checking whether | ||
| 69 | * huge + tiny is equal to huge, and whether huge - tiny is | ||
| 70 | * equal to huge for some floating point number "huge" and "tiny". | ||
| 71 | * | ||
| 72 | * Special cases: | ||
| 73 | * sqrt(+-0) = +-0 ... exact | ||
| 74 | * sqrt(inf) = inf | ||
| 75 | * sqrt(-ve) = NaN ... with invalid signal | ||
| 76 | * sqrt(NaN) = NaN ... with invalid signal for signaling NaN | ||
| 77 | */ | ||
| 78 | |||
| 79 | #include "libm.h" | 3 | #include "libm.h" |
| 4 | #include "sqrt_data.h" | ||
| 80 | 5 | ||
| 81 | static const double tiny = 1.0e-300; | 6 | #define FENV_SUPPORT 1 |
| 82 | 7 | ||
| 83 | double sqrt(double x) | 8 | /* returns a*b*2^-32 - e, with error 0 <= e < 1. */ |
| 9 | static inline uint32_t mul32(uint32_t a, uint32_t b) | ||
| 84 | { | 10 | { |
| 85 | 	double z; | 11 | 	return (uint64_t)a*b >> 32; |
| 86 | 	int32_t sign = (int)0x80000000; | 12 | } |
| 87 | 	int32_t ix0,s0,q,m,t,i; | ||
| 88 | 	uint32_t r,t1,s1,ix1,q1; | ||
| 89 | 13 | ||
| 90 | 	EXTRACT_WORDS(ix0, ix1, x); | 14 | /* returns a*b*2^-64 - e, with error 0 <= e < 3. */ |
| 15 | static inline uint64_t mul64(uint64_t a, uint64_t b) | ||
| 16 | { | ||
| 17 | 	uint64_t ahi = a>>32; | ||
| 18 | 	uint64_t alo = a&0xffffffff; | ||
| 19 | 	uint64_t bhi = b>>32; | ||
| 20 | 	uint64_t blo = b&0xffffffff; | ||
| 21 | 	return ahi*bhi + (ahi*blo >> 32) + (alo*bhi >> 32); | ||
| 22 | } | ||
| 91 | 23 | ||
| 92 | 	/* take care of Inf and NaN */ | 24 | double sqrt(double x) |
| 93 | 	if ((ix0&0x7ff00000) == 0x7ff00000) { | 25 | { |
| 94 | 		return x*x + x; /* sqrt(NaN)=NaN, sqrt(+inf)=+inf, sqrt(-inf)=sNaN */ | 26 | 	uint64_t ix, top, m; |
| 95 | 	} | ||
| 96 | 	/* take care of zero */ | ||
| 97 | 	if (ix0 <= 0) { | ||
| 98 | 		if (((ix0&~sign)|ix1) == 0) | ||
| 99 | 			return x; /* sqrt(+-0) = +-0 */ | ||
| 100 | 		if (ix0 < 0) | ||
| 101 | 			return (x-x)/(x-x); /* sqrt(-ve) = sNaN */ | ||
| 102 | 	} | ||
| 103 | 	/* normalize x */ | ||
| 104 | 	m = ix0>>20; | ||
| 105 | 	if (m == 0) { /* subnormal x */ | ||
| 106 | 		while (ix0 == 0) { | ||
| 107 | 			m -= 21; | ||
| 108 | 			ix0 |= (ix1>>11); | ||
| 109 | 			ix1 <<= 21; | ||
| 110 | 		} | ||
| 111 | 		for (i=0; (ix0&0x00100000) == 0; i++) | ||
| 112 | 			ix0<<=1; | ||
| 113 | 		m -= i - 1; | ||
| 114 | 		ix0 |= ix1>>(32-i); | ||
| 115 | 		ix1 <<= i; | ||
| 116 | 	} | ||
| 117 | 	m -= 1023; /* unbias exponent */ | ||
| 118 | 	ix0 = (ix0&0x000fffff)|0x00100000; | ||
| 119 | 	if (m & 1) { /* odd m, double x to make it even */ | ||
| 120 | 		ix0 += ix0 + ((ix1&sign)>>31); | ||
| 121 | 		ix1 += ix1; | ||
| 122 | 	} | ||
| 123 | 	m >>= 1; /* m = [m/2] */ | ||
| 124 | |||
| 125 | 	/* generate sqrt(x) bit by bit */ | ||
| 126 | 	ix0 += ix0 + ((ix1&sign)>>31); | ||
| 127 | 	ix1 += ix1; | ||
| 128 | 	q = q1 = s0 = s1 = 0; /* [q,q1] = sqrt(x) */ | ||
| 129 | 	r = 0x00200000; /* r = moving bit from right to left */ | ||
| 130 | |||
| 131 | 	while (r != 0) { | ||
| 132 | 		t = s0 + r; | ||
| 133 | 		if (t <= ix0) { | ||
| 134 | 			s0 = t + r; | ||
| 135 | 			ix0 -= t; | ||
| 136 | 			q += r; | ||
| 137 | 		} | ||
| 138 | 		ix0 += ix0 + ((ix1&sign)>>31); | ||
| 139 | 		ix1 += ix1; | ||
| 140 | 		r >>= 1; | ||
| 141 | 	} | ||
| 142 | 27 | ||
| 143 | 	r = sign; | 28 | 	/* special case handling. */ |
| 144 | 	while (r != 0) { | 29 | 	ix = asuint64(x); |
| 145 | 		t1 = s1 + r; | 30 | 	top = ix >> 52; |
| 146 | 		t = s0; | 31 | 	if (predict_false(top - 0x001 >= 0x7ff - 0x001)) { |
| 147 | 		if (t < ix0 || (t == ix0 && t1 <= ix1)) { | 32 | 		/* x < 0x1p-1022 or inf or nan. */ |
| 148 | 			s1 = t1 + r; | 33 | 		if (ix * 2 == 0) |
| 149 | 			if ((t1&sign) == sign && (s1&sign) == 0) | 34 | 			return x; |
| 150 | 				s0++; | 35 | 		if (ix == 0x7ff0000000000000) |
| 151 | 			ix0 -= t; | 36 | 			return x; |
| 152 | 			if (ix1 < t1) | 37 | 		if (ix > 0x7ff0000000000000) |
| 153 | 				ix0--; | 38 | 			return __math_invalid(x); |
| 154 | 			ix1 -= t1; | 39 | 		/* x is subnormal, normalize it. */ |
| 155 | 			q1 += r; | 40 | 		ix = asuint64(x * 0x1p52); |
| 156 | 		} | 41 | 		top = ix >> 52; |
| 157 | 		ix0 += ix0 + ((ix1&sign)>>31); | 42 | 		top -= 52; |
| 158 | 		ix1 += ix1; | ||
| 159 | 		r >>= 1; | ||
| 160 | 	} | 43 | 	} |
| 161 | 44 | ||
| 162 | 	/* use floating add to find out rounding direction */ | 45 | 	/* argument reduction: |
| 163 | 	if ((ix0|ix1) != 0) { | 46 | 	 x = 4^e m; with integer e, and m in [1, 4) |
| 164 | 		z = 1.0 - tiny; /* raise inexact flag */ | 47 | 	 m: fixed point representation [2.62] |
| 165 | 		if (z >= 1.0) { | 48 | 	 2^e is the exponent part of the result. */ |
| 166 | 			z = 1.0 + tiny; | 49 | 	int even = top & 1; |
| 167 | 			if (q1 == (uint32_t)0xffffffff) { | 50 | 	m = (ix << 11) | 0x8000000000000000; |
| 168 | 				q1 = 0; | 51 | 	if (even) m >>= 1; |
| 169 | 				q++; | 52 | 	top = (top + 0x3ff) >> 1; |
| 170 | 			} else if (z > 1.0) { | 53 | |
| 171 | 				if (q1 == (uint32_t)0xfffffffe) | 54 | 	/* approximate r ~ 1/sqrt(m) and s ~ sqrt(m) when m in [1,4) |
| 172 | 					q++; | 55 | |
| 173 | 				q1 += 2; | 56 | 	 initial estimate: |
| 174 | 			} else | 57 | 	 7bit table lookup (1bit exponent and 6bit significand). |
| 175 | 				q1 += q1 & 1; | 58 | |
| 176 | 		} | 59 | 	 iterative approximation: |
| 60 | 	 using 2 goldschmidt iterations with 32bit int arithmetics | ||
| 61 | 	 and a final iteration with 64bit int arithmetics. | ||
| 62 | |||
| 63 | 	 details: | ||
| 64 | |||
| 65 | 	 the relative error (e = r0 sqrt(m)-1) of a linear estimate | ||
| 66 | 	 (r0 = a m + b) is |e| < 0.085955 ~ 0x1.6p-4 at best, | ||
| 67 | 	 a table lookup is faster and needs one less iteration | ||
| 68 | 	 6 bit lookup table (128b) gives |e| < 0x1.f9p-8 | ||
| 69 | 	 7 bit lookup table (256b) gives |e| < 0x1.fdp-9 | ||
| 70 | 	 for single and double prec 6bit is enough but for quad | ||
| 71 | 	 prec 7bit is needed (or modified iterations). to avoid | ||
| 72 | 	 one more iteration >=13bit table would be needed (16k). | ||
| 73 | |||
| 74 | 	 a newton-raphson iteration for r is | ||
| 75 | 	 w = r*r | ||
| 76 | 	 u = 3 - m*w | ||
| 77 | 	 r = r*u/2 | ||
| 78 | 	 can use a goldschmidt iteration for s at the end or | ||
| 79 | 	 s = m*r | ||
| 80 | |||
| 81 | 	 first goldschmidt iteration is | ||
| 82 | 	 s = m*r | ||
| 83 | 	 u = 3 - s*r | ||
| 84 | 	 r = r*u/2 | ||
| 85 | 	 s = s*u/2 | ||
| 86 | 	 next goldschmidt iteration is | ||
| 87 | 	 u = 3 - s*r | ||
| 88 | 	 r = r*u/2 | ||
| 89 | 	 s = s*u/2 | ||
| 90 | 	 and at the end r is not computed only s. | ||
| 91 | |||
| 92 | 	 they use the same amount of operations and converge at the | ||
| 93 | 	 same quadratic rate, i.e. if | ||
| 94 | 	 r1 sqrt(m) - 1 = e, then | ||
| 95 | 	 r2 sqrt(m) - 1 = -3/2 e^2 - 1/2 e^3 | ||
| 96 | 	 the advantage of goldschmidt is that the mul for s and r | ||
| 97 | 	 are independent (computed in parallel), however it is not | ||
| 98 | 	 "self synchronizing": it only uses the input m in the | ||
| 99 | 	 first iteration so rounding errors accumulate. at the end | ||
| 100 | 	 or when switching to larger precision arithmetics rounding | ||
| 101 | 	 errors dominate so the first iteration should be used. | ||
| 102 | |||
| 103 | 	 the fixed point representations are | ||
| 104 | 	 m: 2.30 r: 0.32, s: 2.30, d: 2.30, u: 2.30, three: 2.30 | ||
| 105 | 	 and after switching to 64 bit | ||
| 106 | 	 m: 2.62 r: 0.64, s: 2.62, d: 2.62, u: 2.62, three: 2.62 */ | ||
| 107 | |||
| 108 | 	static const uint64_t three = 0xc0000000; | ||
| 109 | 	uint64_t r, s, d, u, i; | ||
| 110 | |||
| 111 | 	i = (ix >> 46) % 128; | ||
| 112 | 	r = (uint32_t)__rsqrt_tab[i] << 16; | ||
| 113 | 	/* |r sqrt(m) - 1| < 0x1.fdp-9 */ | ||
| 114 | 	s = mul32(m>>32, r); | ||
| 115 | 	/* |s/sqrt(m) - 1| < 0x1.fdp-9 */ | ||
| 116 | 	d = mul32(s, r); | ||
| 117 | 	u = three - d; | ||
| 118 | 	r = mul32(r, u) << 1; | ||
| 119 | 	/* |r sqrt(m) - 1| < 0x1.7bp-16 */ | ||
| 120 | 	s = mul32(s, u) << 1; | ||
| 121 | 	/* |s/sqrt(m) - 1| < 0x1.7bp-16 */ | ||
| 122 | 	d = mul32(s, r); | ||
| 123 | 	u = three - d; | ||
| 124 | 	r = mul32(r, u) << 1; | ||
| 125 | 	/* |r sqrt(m) - 1| < 0x1.3704p-29 (measured worst-case) */ | ||
| 126 | 	r = r << 32; | ||
| 127 | 	s = mul64(m, r); | ||
| 128 | 	d = mul64(s, r); | ||
| 129 | 	u = (three<<32) - d; | ||
| 130 | 	s = mul64(s, u); /* repr: 3.61 */ | ||
| 131 | 	/* -0x1p-57 < s - sqrt(m) < 0x1.8001p-61 */ | ||
| 132 | 	s = (s - 2) >> 9; /* repr: 12.52 */ | ||
| 133 | 	/* -0x1.09p-52 < s - sqrt(m) < -0x1.fffcp-63 */ | ||
| 134 | |||
| 135 | 	/* s < sqrt(m) < s + 0x1.09p-52, | ||
| 136 | 	 compute nearest rounded result: | ||
| 137 | 	 the nearest result to 52 bits is either s or s+0x1p-52, | ||
| 138 | 	 we can decide by comparing (2^52 s + 0.5)^2 to 2^104 m. */ | ||
| 139 | 	uint64_t d0, d1, d2; | ||
| 140 | 	double y, t; | ||
| 141 | 	d0 = (m << 42) - s*s; | ||
| 142 | 	d1 = s - d0; | ||
| 143 | 	d2 = d1 + s + 1; | ||
| 144 | 	s += d1 >> 63; | ||
| 145 | 	s &= 0x000fffffffffffff; | ||
| 146 | 	s |= top << 52; | ||
| 147 | 	y = asdouble(s); | ||
| 148 | 	if (FENV_SUPPORT) { | ||
| 149 | 		/* handle rounding modes and inexact exception: | ||
| 150 | 		 only (s+1)^2 == 2^42 m case is exact otherwise | ||
| 151 | 		 add a tiny value to cause the fenv effects. */ | ||
| 152 | 		uint64_t tiny = predict_false(d2==0) ? 0 : 0x0010000000000000; | ||
| 153 | 		tiny |= (d1^d2) & 0x8000000000000000; | ||
| 154 | 		t = asdouble(tiny); | ||
| 155 | 		y = eval_as_double(y + t); | ||
| 177 | 	} | 156 | 	} |
| 178 | 	ix0 = (q>>1) + 0x3fe00000; | 157 | 	return y; |
| 179 | 	ix1 = q1>>1; | ||
| 180 | 	if (q&1) | ||
| 181 | 		ix1 |= sign; | ||
| 182 | 	INSERT_WORDS(z, ix0 + ((uint32_t)m << 20), ix1); | ||
| 183 | 	return z; | ||
| 184 | } | 158 | } |
lib/libc/musl/src/math/sqrt_data.c created+19| ... | @@ -0,0 +1,19 @@ | ||
| 1 | #include "sqrt_data.h" | ||
| 2 | const uint16_t __rsqrt_tab[128] = { | ||
| 3 | 0xb451,0xb2f0,0xb196,0xb044,0xaef9,0xadb6,0xac79,0xab43, | ||
| 4 | 0xaa14,0xa8eb,0xa7c8,0xa6aa,0xa592,0xa480,0xa373,0xa26b, | ||
| 5 | 0xa168,0xa06a,0x9f70,0x9e7b,0x9d8a,0x9c9d,0x9bb5,0x9ad1, | ||
| 6 | 0x99f0,0x9913,0x983a,0x9765,0x9693,0x95c4,0x94f8,0x9430, | ||
| 7 | 0x936b,0x92a9,0x91ea,0x912e,0x9075,0x8fbe,0x8f0a,0x8e59, | ||
| 8 | 0x8daa,0x8cfe,0x8c54,0x8bac,0x8b07,0x8a64,0x89c4,0x8925, | ||
| 9 | 0x8889,0x87ee,0x8756,0x86c0,0x862b,0x8599,0x8508,0x8479, | ||
| 10 | 0x83ec,0x8361,0x82d8,0x8250,0x81c9,0x8145,0x80c2,0x8040, | ||
| 11 | 0xff02,0xfd0e,0xfb25,0xf947,0xf773,0xf5aa,0xf3ea,0xf234, | ||
| 12 | 0xf087,0xeee3,0xed47,0xebb3,0xea27,0xe8a3,0xe727,0xe5b2, | ||
| 13 | 0xe443,0xe2dc,0xe17a,0xe020,0xdecb,0xdd7d,0xdc34,0xdaf1, | ||
| 14 | 0xd9b3,0xd87b,0xd748,0xd61a,0xd4f1,0xd3cd,0xd2ad,0xd192, | ||
| 15 | 0xd07b,0xcf69,0xce5b,0xcd51,0xcc4a,0xcb48,0xca4a,0xc94f, | ||
| 16 | 0xc858,0xc764,0xc674,0xc587,0xc49d,0xc3b7,0xc2d4,0xc1f4, | ||
| 17 | 0xc116,0xc03c,0xbf65,0xbe90,0xbdbe,0xbcef,0xbc23,0xbb59, | ||
| 18 | 0xba91,0xb9cc,0xb90a,0xb84a,0xb78c,0xb6d0,0xb617,0xb560, | ||
| 19 | }; | ||
lib/libc/musl/src/math/sqrt_data.h created+13| ... | @@ -0,0 +1,13 @@ | ||
| 1 | #ifndef _SQRT_DATA_H | ||
| 2 | #define _SQRT_DATA_H | ||
| 3 | |||
| 4 | #include <features.h> | ||
| 5 | #include <stdint.h> | ||
| 6 | |||
| 7 | /* if x in [1,2): i = (int)(64*x); | ||
| 8 | if x in [2,4): i = (int)(32*x-64); | ||
| 9 | __rsqrt_tab[i]*2^-16 is estimating 1/sqrt(x) with small relative error: | ||
| 10 | |__rsqrt_tab[i]*0x1p-16*sqrt(x) - 1| < -0x1.fdp-9 < 2^-8 */ | ||
| 11 | extern hidden const uint16_t __rsqrt_tab[128]; | ||
| 12 | |||
| 13 | #endif | ||
lib/libc/musl/src/math/sqrtf.c+70-70| ... | @@ -1,83 +1,83 @@ | ... | @@ -1,83 +1,83 @@ |
| 1 | /* origin: FreeBSD /usr/src/lib/msun/src/e_sqrtf.c */ | 1 | #include <stdint.h> |
| 2 | /* | 2 | #include <math.h> |
| 3 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. | ||
| 4 | */ | ||
| 5 | /* | ||
| 6 | * ==================================================== | ||
| 7 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. | ||
| 8 | * | ||
| 9 | * Developed at SunPro, a Sun Microsystems, Inc. business. | ||
| 10 | * Permission to use, copy, modify, and distribute this | ||
| 11 | * software is freely granted, provided that this notice | ||
| 12 | * is preserved. | ||
| 13 | * ==================================================== | ||
| 14 | */ | ||
| 15 | |||
| 16 | #include "libm.h" | 3 | #include "libm.h" |
| 4 | #include "sqrt_data.h" | ||
| 17 | 5 | ||
| 18 | static const float tiny = 1.0e-30; | 6 | #define FENV_SUPPORT 1 |
| 19 | 7 | ||
| 20 | float sqrtf(float x) | 8 | static inline uint32_t mul32(uint32_t a, uint32_t b) |
| 21 | { | 9 | { |
| 22 | 	float z; | 10 | 	return (uint64_t)a*b >> 32; |
| 23 | 	int32_t sign = (int)0x80000000; | 11 | } |
| 24 | 	int32_t ix,s,q,m,t,i; | ||
| 25 | 	uint32_t r; | ||
| 26 | 12 | ||
| 27 | 	GET_FLOAT_WORD(ix, x); | 13 | /* see sqrt.c for more detailed comments. */ |
| 28 | 14 | ||
| 29 | 	/* take care of Inf and NaN */ | 15 | float sqrtf(float x) |
| 30 | 	if ((ix&0x7f800000) == 0x7f800000) | 16 | { |
| 31 | 		return x*x + x; /* sqrt(NaN)=NaN, sqrt(+inf)=+inf, sqrt(-inf)=sNaN */ | 17 | 	uint32_t ix, m, m1, m0, even, ey; |
| 32 | 18 | ||
| 33 | 	/* take care of zero */ | 19 | 	ix = asuint(x); |
| 34 | 	if (ix <= 0) { | 20 | 	if (predict_false(ix - 0x00800000 >= 0x7f800000 - 0x00800000)) { |
| 35 | 		if ((ix&~sign) == 0) | 21 | 		/* x < 0x1p-126 or inf or nan. */ |
| 36 | 			return x; /* sqrt(+-0) = +-0 */ | 22 | 		if (ix * 2 == 0) |
| 37 | 		if (ix < 0) | 23 | 			return x; |
| 38 | 			return (x-x)/(x-x); /* sqrt(-ve) = sNaN */ | 24 | 		if (ix == 0x7f800000) |
| 39 | 	} | 25 | 			return x; |
| 40 | 	/* normalize x */ | 26 | 		if (ix > 0x7f800000) |
| 41 | 	m = ix>>23; | 27 | 			return __math_invalidf(x); |
| 42 | 	if (m == 0) { /* subnormal x */ | 28 | 		/* x is subnormal, normalize it. */ |
| 43 | 		for (i = 0; (ix&0x00800000) == 0; i++) | 29 | 		ix = asuint(x * 0x1p23f); |
| 44 | 			ix<<=1; | 30 | 		ix -= 23 << 23; |
| 45 | 		m -= i - 1; | ||
| 46 | 	} | 31 | 	} |
| 47 | 	m -= 127; /* unbias exponent */ | ||
| 48 | 	ix = (ix&0x007fffff)|0x00800000; | ||
| 49 | 	if (m&1) /* odd m, double x to make it even */ | ||
| 50 | 		ix += ix; | ||
| 51 | 	m >>= 1; /* m = [m/2] */ | ||
| 52 | 32 | ||
| 53 | 	/* generate sqrt(x) bit by bit */ | 33 | 	/* x = 4^e m; with int e and m in [1, 4). */ |
| 54 | 	ix += ix; | 34 | 	even = ix & 0x00800000; |
| 55 | 	q = s = 0; /* q = sqrt(x) */ | 35 | 	m1 = (ix << 8) | 0x80000000; |
| 56 | 	r = 0x01000000; /* r = moving bit from right to left */ | 36 | 	m0 = (ix << 7) & 0x7fffffff; |
| 37 | 	m = even ? m0 : m1; | ||
| 57 | 38 | ||
| 58 | 	while (r != 0) { | 39 | 	/* 2^e is the exponent part of the return value. */ |
| 59 | 		t = s + r; | 40 | 	ey = ix >> 1; |
| 60 | 		if (t <= ix) { | 41 | 	ey += 0x3f800000 >> 1; |
| 61 | 			s = t+r; | 42 | 	ey &= 0x7f800000; |
| 62 | 			ix -= t; | 43 | |
| 63 | 			q += r; | 44 | 	/* compute r ~ 1/sqrt(m), s ~ sqrt(m) with 2 goldschmidt iterations. */ |
| 64 | 		} | 45 | 	static const uint32_t three = 0xc0000000; |
| 65 | 		ix += ix; | 46 | 	uint32_t r, s, d, u, i; |
| 66 | 		r >>= 1; | 47 | 	i = (ix >> 17) % 128; |
| 67 | 	} | 48 | 	r = (uint32_t)__rsqrt_tab[i] << 16; |
| 49 | 	/* |r*sqrt(m) - 1| < 0x1p-8 */ | ||
| 50 | 	s = mul32(m, r); | ||
| 51 | 	/* |s/sqrt(m) - 1| < 0x1p-8 */ | ||
| 52 | 	d = mul32(s, r); | ||
| 53 | 	u = three - d; | ||
| 54 | 	r = mul32(r, u) << 1; | ||
| 55 | 	/* |r*sqrt(m) - 1| < 0x1.7bp-16 */ | ||
| 56 | 	s = mul32(s, u) << 1; | ||
| 57 | 	/* |s/sqrt(m) - 1| < 0x1.7bp-16 */ | ||
| 58 | 	d = mul32(s, r); | ||
| 59 | 	u = three - d; | ||
| 60 | 	s = mul32(s, u); | ||
| 61 | 	/* -0x1.03p-28 < s/sqrt(m) - 1 < 0x1.fp-31 */ | ||
| 62 | 	s = (s - 1)>>6; | ||
| 63 | 	/* s < sqrt(m) < s + 0x1.08p-23 */ | ||
| 68 | 64 | ||
| 69 | 	/* use floating add to find out rounding direction */ | 65 | 	/* compute nearest rounded result. */ |
| 70 | 	if (ix != 0) { | 66 | 	uint32_t d0, d1, d2; |
| 71 | 		z = 1.0f - tiny; /* raise inexact flag */ | 67 | 	float y, t; |
| 72 | 		if (z >= 1.0f) { | 68 | 	d0 = (m << 16) - s*s; |
| 73 | 			z = 1.0f + tiny; | 69 | 	d1 = s - d0; |
| 74 | 			if (z > 1.0f) | 70 | 	d2 = d1 + s + 1; |
| 75 | 				q += 2; | 71 | 	s += d1 >> 31; |
| 76 | 			else | 72 | 	s &= 0x007fffff; |
| 77 | 				q += q & 1; | 73 | 	s |= ey; |
| 78 | 		} | 74 | 	y = asfloat(s); |
| 75 | 	if (FENV_SUPPORT) { | ||
| 76 | 		/* handle rounding and inexact exception. */ | ||
| 77 | 		uint32_t tiny = predict_false(d2==0) ? 0 : 0x01000000; | ||
| 78 | 		tiny |= (d1^d2) & 0x80000000; | ||
| 79 | 		t = asfloat(tiny); | ||
| 80 | 		y = eval_as_float(y + t); | ||
| 79 | 	} | 81 | 	} |
| 80 | 	ix = (q>>1) + 0x3f000000; | 82 | 	return y; |
| 81 | 	SET_FLOAT_WORD(z, ix + ((uint32_t)m << 23)); | ||
| 82 | 	return z; | ||
| 83 | } | 83 | } |
lib/libc/musl/src/math/sqrtl.c+253-1| ... | @@ -1,7 +1,259 @@ | ... | @@ -1,7 +1,259 @@ |
| 1 | #include <stdint.h> | ||
| 1 | #include <math.h> | 2 | #include <math.h> |
| 3 | #include <float.h> | ||
| 4 | #include "libm.h" | ||
| 2 | 5 | ||
| 6 | #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 | ||
| 3 | long double sqrtl(long double x) | 7 | long double sqrtl(long double x) |
| 4 | { | 8 | { |
| 5 | 	/* FIXME: implement in C, this is for LDBL_MANT_DIG == 64 only */ | ||
| 6 | 	return sqrt(x); | 9 | 	return sqrt(x); |
| 7 | } | 10 | } |
| 11 | #elif (LDBL_MANT_DIG == 113 || LDBL_MANT_DIG == 64) && LDBL_MAX_EXP == 16384 | ||
| 12 | #include "sqrt_data.h" | ||
| 13 | |||
| 14 | #define FENV_SUPPORT 1 | ||
| 15 | |||
| 16 | typedef struct { | ||
| 17 | 	uint64_t hi; | ||
| 18 | 	uint64_t lo; | ||
| 19 | } u128; | ||
| 20 | |||
| 21 | /* top: 16 bit sign+exponent, x: significand. */ | ||
| 22 | static inline long double mkldbl(uint64_t top, u128 x) | ||
| 23 | { | ||
| 24 | 	union ldshape u; | ||
| 25 | #if LDBL_MANT_DIG == 113 | ||
| 26 | 	u.i2.hi = x.hi; | ||
| 27 | 	u.i2.lo = x.lo; | ||
| 28 | 	u.i2.hi &= 0x0000ffffffffffff; | ||
| 29 | 	u.i2.hi |= top << 48; | ||
| 30 | #elif LDBL_MANT_DIG == 64 | ||
| 31 | 	u.i.se = top; | ||
| 32 | 	u.i.m = x.lo; | ||
| 33 | 	/* force the top bit on non-zero (and non-subnormal) results. */ | ||
| 34 | 	if (top & 0x7fff) | ||
| 35 | 		u.i.m |= 0x8000000000000000; | ||
| 36 | #endif | ||
| 37 | 	return u.f; | ||
| 38 | } | ||
| 39 | |||
| 40 | /* return: top 16 bit is sign+exp and following bits are the significand. */ | ||
| 41 | static inline u128 asu128(long double x) | ||
| 42 | { | ||
| 43 | 	union ldshape u = {.f=x}; | ||
| 44 | 	u128 r; | ||
| 45 | #if LDBL_MANT_DIG == 113 | ||
| 46 | 	r.hi = u.i2.hi; | ||
| 47 | 	r.lo = u.i2.lo; | ||
| 48 | #elif LDBL_MANT_DIG == 64 | ||
| 49 | 	r.lo = u.i.m<<49; | ||
| 50 | 	/* ignore the top bit: pseudo numbers are not handled. */ | ||
| 51 | 	r.hi = u.i.m>>15; | ||
| 52 | 	r.hi &= 0x0000ffffffffffff; | ||
| 53 | 	r.hi |= (uint64_t)u.i.se << 48; | ||
| 54 | #endif | ||
| 55 | 	return r; | ||
| 56 | } | ||
| 57 | |||
| 58 | /* returns a*b*2^-32 - e, with error 0 <= e < 1. */ | ||
| 59 | static inline uint32_t mul32(uint32_t a, uint32_t b) | ||
| 60 | { | ||
| 61 | 	return (uint64_t)a*b >> 32; | ||
| 62 | } | ||
| 63 | |||
| 64 | /* returns a*b*2^-64 - e, with error 0 <= e < 3. */ | ||
| 65 | static inline uint64_t mul64(uint64_t a, uint64_t b) | ||
| 66 | { | ||
| 67 | 	uint64_t ahi = a>>32; | ||
| 68 | 	uint64_t alo = a&0xffffffff; | ||
| 69 | 	uint64_t bhi = b>>32; | ||
| 70 | 	uint64_t blo = b&0xffffffff; | ||
| 71 | 	return ahi*bhi + (ahi*blo >> 32) + (alo*bhi >> 32); | ||
| 72 | } | ||
| 73 | |||
| 74 | static inline u128 add64(u128 a, uint64_t b) | ||
| 75 | { | ||
| 76 | 	u128 r; | ||
| 77 | 	r.lo = a.lo + b; | ||
| 78 | 	r.hi = a.hi; | ||
| 79 | 	if (r.lo < a.lo) | ||
| 80 | 		r.hi++; | ||
| 81 | 	return r; | ||
| 82 | } | ||
| 83 | |||
| 84 | static inline u128 add128(u128 a, u128 b) | ||
| 85 | { | ||
| 86 | 	u128 r; | ||
| 87 | 	r.lo = a.lo + b.lo; | ||
| 88 | 	r.hi = a.hi + b.hi; | ||
| 89 | 	if (r.lo < a.lo) | ||
| 90 | 		r.hi++; | ||
| 91 | 	return r; | ||
| 92 | } | ||
| 93 | |||
| 94 | static inline u128 sub64(u128 a, uint64_t b) | ||
| 95 | { | ||
| 96 | 	u128 r; | ||
| 97 | 	r.lo = a.lo - b; | ||
| 98 | 	r.hi = a.hi; | ||
| 99 | 	if (a.lo < b) | ||
| 100 | 		r.hi--; | ||
| 101 | 	return r; | ||
| 102 | } | ||
| 103 | |||
| 104 | static inline u128 sub128(u128 a, u128 b) | ||
| 105 | { | ||
| 106 | 	u128 r; | ||
| 107 | 	r.lo = a.lo - b.lo; | ||
| 108 | 	r.hi = a.hi - b.hi; | ||
| 109 | 	if (a.lo < b.lo) | ||
| 110 | 		r.hi--; | ||
| 111 | 	return r; | ||
| 112 | } | ||
| 113 | |||
| 114 | /* a<<n, 0 <= n <= 127 */ | ||
| 115 | static inline u128 lsh(u128 a, int n) | ||
| 116 | { | ||
| 117 | 	if (n == 0) | ||
| 118 | 		return a; | ||
| 119 | 	if (n >= 64) { | ||
| 120 | 		a.hi = a.lo<<(n-64); | ||
| 121 | 		a.lo = 0; | ||
| 122 | 	} else { | ||
| 123 | 		a.hi = (a.hi<<n) | (a.lo>>(64-n)); | ||
| 124 | 		a.lo = a.lo<<n; | ||
| 125 | 	} | ||
| 126 | 	return a; | ||
| 127 | } | ||
| 128 | |||
| 129 | /* a>>n, 0 <= n <= 127 */ | ||
| 130 | static inline u128 rsh(u128 a, int n) | ||
| 131 | { | ||
| 132 | 	if (n == 0) | ||
| 133 | 		return a; | ||
| 134 | 	if (n >= 64) { | ||
| 135 | 		a.lo = a.hi>>(n-64); | ||
| 136 | 		a.hi = 0; | ||
| 137 | 	} else { | ||
| 138 | 		a.lo = (a.lo>>n) | (a.hi<<(64-n)); | ||
| 139 | 		a.hi = a.hi>>n; | ||
| 140 | 	} | ||
| 141 | 	return a; | ||
| 142 | } | ||
| 143 | |||
| 144 | /* returns a*b exactly. */ | ||
| 145 | static inline u128 mul64_128(uint64_t a, uint64_t b) | ||
| 146 | { | ||
| 147 | 	u128 r; | ||
| 148 | 	uint64_t ahi = a>>32; | ||
| 149 | 	uint64_t alo = a&0xffffffff; | ||
| 150 | 	uint64_t bhi = b>>32; | ||
| 151 | 	uint64_t blo = b&0xffffffff; | ||
| 152 | 	uint64_t lo1 = ((ahi*blo)&0xffffffff) + ((alo*bhi)&0xffffffff) + (alo*blo>>32); | ||
| 153 | 	uint64_t lo2 = (alo*blo)&0xffffffff; | ||
| 154 | 	r.hi = ahi*bhi + (ahi*blo>>32) + (alo*bhi>>32) + (lo1>>32); | ||
| 155 | 	r.lo = (lo1<<32) + lo2; | ||
| 156 | 	return r; | ||
| 157 | } | ||
| 158 | |||
| 159 | /* returns a*b*2^-128 - e, with error 0 <= e < 7. */ | ||
| 160 | static inline u128 mul128(u128 a, u128 b) | ||
| 161 | { | ||
| 162 | 	u128 hi = mul64_128(a.hi, b.hi); | ||
| 163 | 	uint64_t m1 = mul64(a.hi, b.lo); | ||
| 164 | 	uint64_t m2 = mul64(a.lo, b.hi); | ||
| 165 | 	return add64(add64(hi, m1), m2); | ||
| 166 | } | ||
| 167 | |||
| 168 | /* returns a*b % 2^128. */ | ||
| 169 | static inline u128 mul128_tail(u128 a, u128 b) | ||
| 170 | { | ||
| 171 | 	u128 lo = mul64_128(a.lo, b.lo); | ||
| 172 | 	lo.hi += a.hi*b.lo + a.lo*b.hi; | ||
| 173 | 	return lo; | ||
| 174 | } | ||
| 175 | |||
| 176 | |||
| 177 | /* see sqrt.c for detailed comments. */ | ||
| 178 | |||
| 179 | long double sqrtl(long double x) | ||
| 180 | { | ||
| 181 | 	u128 ix, ml; | ||
| 182 | 	uint64_t top; | ||
| 183 | |||
| 184 | 	ix = asu128(x); | ||
| 185 | 	top = ix.hi >> 48; | ||
| 186 | 	if (predict_false(top - 0x0001 >= 0x7fff - 0x0001)) { | ||
| 187 | 		/* x < 0x1p-16382 or inf or nan. */ | ||
| 188 | 		if (2*ix.hi == 0 && ix.lo == 0) | ||
| 189 | 			return x; | ||
| 190 | 		if (ix.hi == 0x7fff000000000000 && ix.lo == 0) | ||
| 191 | 			return x; | ||
| 192 | 		if (top >= 0x7fff) | ||
| 193 | 			return __math_invalidl(x); | ||
| 194 | 		/* x is subnormal, normalize it. */ | ||
| 195 | 		ix = asu128(x * 0x1p112); | ||
| 196 | 		top = ix.hi >> 48; | ||
| 197 | 		top -= 112; | ||
| 198 | 	} | ||
| 199 | |||
| 200 | 	/* x = 4^e m; with int e and m in [1, 4) */ | ||
| 201 | 	int even = top & 1; | ||
| 202 | 	ml = lsh(ix, 15); | ||
| 203 | 	ml.hi |= 0x8000000000000000; | ||
| 204 | 	if (even) ml = rsh(ml, 1); | ||
| 205 | 	top = (top + 0x3fff) >> 1; | ||
| 206 | |||
| 207 | 	/* r ~ 1/sqrt(m) */ | ||
| 208 | 	static const uint64_t three = 0xc0000000; | ||
| 209 | 	uint64_t r, s, d, u, i; | ||
| 210 | 	i = (ix.hi >> 42) % 128; | ||
| 211 | 	r = (uint32_t)__rsqrt_tab[i] << 16; | ||
| 212 | 	/* |r sqrt(m) - 1| < 0x1p-8 */ | ||
| 213 | 	s = mul32(ml.hi>>32, r); | ||
| 214 | 	d = mul32(s, r); | ||
| 215 | 	u = three - d; | ||
| 216 | 	r = mul32(u, r) << 1; | ||
| 217 | 	/* |r sqrt(m) - 1| < 0x1.7bp-16, switch to 64bit */ | ||
| 218 | 	r = r<<32; | ||
| 219 | 	s = mul64(ml.hi, r); | ||
| 220 | 	d = mul64(s, r); | ||
| 221 | 	u = (three<<32) - d; | ||
| 222 | 	r = mul64(u, r) << 1; | ||
| 223 | 	/* |r sqrt(m) - 1| < 0x1.a5p-31 */ | ||
| 224 | 	s = mul64(u, s) << 1; | ||
| 225 | 	d = mul64(s, r); | ||
| 226 | 	u = (three<<32) - d; | ||
| 227 | 	r = mul64(u, r) << 1; | ||
| 228 | 	/* |r sqrt(m) - 1| < 0x1.c001p-59, switch to 128bit */ | ||
| 229 | |||
| 230 | 	static const u128 threel = {.hi=three<<32, .lo=0}; | ||
| 231 | 	u128 rl, sl, dl, ul; | ||
| 232 | 	rl.hi = r; | ||
| 233 | 	rl.lo = 0; | ||
| 234 | 	sl = mul128(ml, rl); | ||
| 235 | 	dl = mul128(sl, rl); | ||
| 236 | 	ul = sub128(threel, dl); | ||
| 237 | 	sl = mul128(ul, sl); /* repr: 3.125 */ | ||
| 238 | 	/* -0x1p-116 < s - sqrt(m) < 0x3.8001p-125 */ | ||
| 239 | 	sl = rsh(sub64(sl, 4), 125-(LDBL_MANT_DIG-1)); | ||
| 240 | 	/* s < sqrt(m) < s + 1 ULP + tiny */ | ||
| 241 | |||
| 242 | 	long double y; | ||
| 243 | 	u128 d2, d1, d0; | ||
| 244 | 	d0 = sub128(lsh(ml, 2*(LDBL_MANT_DIG-1)-126), mul128_tail(sl,sl)); | ||
| 245 | 	d1 = sub128(sl, d0); | ||
| 246 | 	d2 = add128(add64(sl, 1), d1); | ||
| 247 | 	sl = add64(sl, d1.hi >> 63); | ||
| 248 | 	y = mkldbl(top, sl); | ||
| 249 | 	if (FENV_SUPPORT) { | ||
| 250 | 		/* handle rounding modes and inexact exception. */ | ||
| 251 | 		top = predict_false((d2.hi|d2.lo)==0) ? 0 : 1; | ||
| 252 | 		top |= ((d1.hi^d2.hi)&0x8000000000000000) >> 48; | ||
| 253 | 		y += mkldbl(top, (u128){0}); | ||
| 254 | 	} | ||
| 255 | 	return y; | ||
| 256 | } | ||
| 257 | #else | ||
| 258 | #error unsupported long double format | ||
| 259 | #endif |
lib/libc/musl/src/misc/ioctl.c+13-5| ... | @@ -4,6 +4,7 @@ | ... | @@ -4,6 +4,7 @@ |
| 4 | #include <time.h> | 4 | #include <time.h> |
| 5 | #include <sys/time.h> | 5 | #include <sys/time.h> |
| 6 | #include <stddef.h> | 6 | #include <stddef.h> |
| 7 | #include <stdint.h> | ||
| 7 | #include <string.h> | 8 | #include <string.h> |
| 8 | #include "syscall.h" | 9 | #include "syscall.h" |
| 9 | 10 | ||
| ... | @@ -28,6 +29,12 @@ struct ioctl_compat_map { | ... | @@ -28,6 +29,12 @@ struct ioctl_compat_map { |
| 28 | * number producing macros; only size of result is meaningful. */ | 29 | * number producing macros; only size of result is meaningful. */ |
| 29 | #define new_misaligned(n) struct { int i; time_t t; char c[(n)-4]; } | 30 | #define new_misaligned(n) struct { int i; time_t t; char c[(n)-4]; } |
| 30 | 31 | ||
| 32 | struct v4l2_event { | ||
| 33 | 	uint32_t a; | ||
| 34 | 	uint64_t b[8]; | ||
| 35 | 	uint32_t c[2], ts[2], d[9]; | ||
| 36 | }; | ||
| 37 | |||
| 31 | static const struct ioctl_compat_map compat_map[] = { | 38 | static const struct ioctl_compat_map compat_map[] = { |
| 32 | 	{ SIOCGSTAMP, SIOCGSTAMP_OLD, 8, R, 0, OFFS(0, 4) }, | 39 | 	{ SIOCGSTAMP, SIOCGSTAMP_OLD, 8, R, 0, OFFS(0, 4) }, |
| 33 | 	{ SIOCGSTAMPNS, SIOCGSTAMPNS_OLD, 8, R, 0, OFFS(0, 4) }, | 40 | 	{ SIOCGSTAMPNS, SIOCGSTAMPNS_OLD, 8, R, 0, OFFS(0, 4) }, |
| ... | @@ -49,13 +56,14 @@ static const struct ioctl_compat_map compat_map[] = { | ... | @@ -49,13 +56,14 @@ static const struct ioctl_compat_map compat_map[] = { |
| 49 | 	{ 0, 0, 8, WR, 1, OFFS(0,4) }, /* snd_pcm_mmap_control */ | 56 | 	{ 0, 0, 8, WR, 1, OFFS(0,4) }, /* snd_pcm_mmap_control */ |
| 50 | 57 | ||
| 51 | 	/* VIDIOC_QUERYBUF, VIDIOC_QBUF, VIDIOC_DQBUF, VIDIOC_PREPARE_BUF */ | 58 | 	/* VIDIOC_QUERYBUF, VIDIOC_QBUF, VIDIOC_DQBUF, VIDIOC_PREPARE_BUF */ |
| 52 | 	{ _IOWR('V', 9, new_misaligned(72)), _IOWR('V', 9, char[72]), 72, WR, 0, OFFS(20) }, | 59 | 	{ _IOWR('V', 9, new_misaligned(68)), _IOWR('V', 9, char[68]), 68, WR, 1, OFFS(20, 24) }, |
| 53 | 	{ _IOWR('V', 15, new_misaligned(72)), _IOWR('V', 15, char[72]), 72, WR, 0, OFFS(20) }, | 60 | 	{ _IOWR('V', 15, new_misaligned(68)), _IOWR('V', 15, char[68]), 68, WR, 1, OFFS(20, 24) }, |
| 54 | 	{ _IOWR('V', 17, new_misaligned(72)), _IOWR('V', 17, char[72]), 72, WR, 0, OFFS(20) }, | 61 | 	{ _IOWR('V', 17, new_misaligned(68)), _IOWR('V', 17, char[68]), 68, WR, 1, OFFS(20, 24) }, |
| 55 | 	{ _IOWR('V', 93, new_misaligned(72)), _IOWR('V', 93, char[72]), 72, WR, 0, OFFS(20) }, | 62 | 	{ _IOWR('V', 93, new_misaligned(68)), _IOWR('V', 93, char[68]), 68, WR, 1, OFFS(20, 24) }, |
| 56 | 63 | ||
| 57 | 	/* VIDIOC_DQEVENT */ | 64 | 	/* VIDIOC_DQEVENT */ |
| 58 | 	{ _IOR('V', 89, new_misaligned(96)), _IOR('V', 89, char[96]), 96, R, 0, OFFS(76,80) }, | 65 | 	{ _IOR('V', 89, new_misaligned(120)), _IOR('V', 89, struct v4l2_event), sizeof(struct v4l2_event), |
| 66 | 	 R, 0, OFFS(offsetof(struct v4l2_event, ts[0]), offsetof(struct v4l2_event, ts[1])) }, | ||
| 59 | 67 | ||
| 60 | 	/* VIDIOC_OMAP3ISP_STAT_REQ */ | 68 | 	/* VIDIOC_OMAP3ISP_STAT_REQ */ |
| 61 | 	{ _IOWR('V', 192+6, char[32]), _IOWR('V', 192+6, char[24]), 22, WR, 0, OFFS(0,4) }, | 69 | 	{ _IOWR('V', 192+6, char[32]), _IOWR('V', 192+6, char[24]), 22, WR, 0, OFFS(0,4) }, |
lib/libc/musl/src/misc/realpath.c+136-23| ... | @@ -1,43 +1,156 @@ | ... | @@ -1,43 +1,156 @@ |
| 1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
| 2 | #include <limits.h> | 2 | #include <limits.h> |
| 3 | #include <sys/stat.h> | ||
| 4 | #include <fcntl.h> | ||
| 5 | #include <errno.h> | 3 | #include <errno.h> |
| 6 | #include <unistd.h> | 4 | #include <unistd.h> |
| 7 | #include <string.h> | 5 | #include <string.h> |
| 8 | #include "syscall.h" | 6 | |
| 7 | static size_t slash_len(const char *s) | ||
| 8 | { | ||
| 9 | 	const char *s0 = s; | ||
| 10 | 	while (*s == '/') s++; | ||
| 11 | 	return s-s0; | ||
| 12 | } | ||
| 9 | 13 | ||
| 10 | char *realpath(const char *restrict filename, char *restrict resolved) | 14 | char *realpath(const char *restrict filename, char *restrict resolved) |
| 11 | { | 15 | { |
| 12 | 	int fd; | 16 | 	char stack[PATH_MAX+1]; |
| 13 | 	ssize_t r; | 17 | 	char output[PATH_MAX]; |
| 14 | 	struct stat st1, st2; | 18 | 	size_t p, q, l, l0, cnt=0, nup=0; |
| 15 | 	char buf[15+3*sizeof(int)]; | 19 | 	int check_dir=0; |
| 16 | 	char tmp[PATH_MAX]; | ||
| 17 | 20 | ||
| 18 | 	if (!filename) { | 21 | 	if (!filename) { |
| 19 | 		errno = EINVAL; | 22 | 		errno = EINVAL; |
| 20 | 		return 0; | 23 | 		return 0; |
| 21 | 	} | 24 | 	} |
| 25 | 	l = strnlen(filename, sizeof stack); | ||
| 26 | 	if (!l) { | ||
| 27 | 		errno = ENOENT; | ||
| 28 | 		return 0; | ||
| 29 | 	} | ||
| 30 | 	if (l >= PATH_MAX) goto toolong; | ||
| 31 | 	p = sizeof stack - l - 1; | ||
| 32 | 	q = 0; | ||
| 33 | 	memcpy(stack+p, filename, l+1); | ||
| 34 | |||
| 35 | 	/* Main loop. Each iteration pops the next part from stack of | ||
| 36 | 	 * remaining path components and consumes any slashes that follow. | ||
| 37 | 	 * If not a link, it's moved to output; if a link, contents are | ||
| 38 | 	 * pushed to the stack. */ | ||
| 39 | restart: | ||
| 40 | 	for (; ; p+=slash_len(stack+p)) { | ||
| 41 | 		/* If stack starts with /, the whole component is / or // | ||
| 42 | 		 * and the output state must be reset. */ | ||
| 43 | 		if (stack[p] == '/') { | ||
| 44 | 			check_dir=0; | ||
| 45 | 			nup=0; | ||
| 46 | 			q=0; | ||
| 47 | 			output[q++] = '/'; | ||
| 48 | 			p++; | ||
| 49 | 			/* Initial // is special. */ | ||
| 50 | 			if (stack[p] == '/' && stack[p+1] != '/') | ||
| 51 | 				output[q++] = '/'; | ||
| 52 | 			continue; | ||
| 53 | 		} | ||
| 54 | |||
| 55 | 		char *z = __strchrnul(stack+p, '/'); | ||
| 56 | 		l0 = l = z-(stack+p); | ||
| 22 | 57 | ||
| 23 | 	fd = sys_open(filename, O_PATH|O_NONBLOCK|O_CLOEXEC); | 58 | 		if (!l && !check_dir) break; |
| 24 | 	if (fd < 0) return 0; | ||
| 25 | 	__procfdname(buf, fd); | ||
| 26 | 59 | ||
| 27 | 	r = readlink(buf, tmp, sizeof tmp - 1); | 60 | 		/* Skip any . component but preserve check_dir status. */ |
| 28 | 	if (r < 0) goto err; | 61 | 		if (l==1 && stack[p]=='.') { |
| 29 | 	tmp[r] = 0; | 62 | 			p += l; |
| 63 | 			continue; | ||
| 64 | 		} | ||
| 30 | 65 | ||
| 31 | 	fstat(fd, &st1); | 66 | 		/* Copy next component onto output at least temporarily, to |
| 32 | 	r = stat(tmp, &st2); | 67 | 		 * call readlink, but wait to advance output position until |
| 33 | 	if (r<0 || st1.st_dev != st2.st_dev || st1.st_ino != st2.st_ino) { | 68 | 		 * determining it's not a link. */ |
| 34 | 		if (!r) errno = ELOOP; | 69 | 		if (q && output[q-1] != '/') { |
| 35 | 		goto err; | 70 | 			if (!p) goto toolong; |
| 71 | 			stack[--p] = '/'; | ||
| 72 | 			l++; | ||
| 73 | 		} | ||
| 74 | 		if (q+l >= PATH_MAX) goto toolong; | ||
| 75 | 		memcpy(output+q, stack+p, l); | ||
| 76 | 		output[q+l] = 0; | ||
| 77 | 		p += l; | ||
| 78 | |||
| 79 | 		int up = 0; | ||
| 80 | 		if (l0==2 && stack[p-2]=='.' && stack[p-1]=='.') { | ||
| 81 | 			up = 1; | ||
| 82 | 			/* Any non-.. path components we could cancel start | ||
| 83 | 			 * after nup repetitions of the 3-byte string "../"; | ||
| 84 | 			 * if there are none, accumulate .. components to | ||
| 85 | 			 * later apply to cwd, if needed. */ | ||
| 86 | 			if (q <= 3*nup) { | ||
| 87 | 				nup++; | ||
| 88 | 				q += l; | ||
| 89 | 				continue; | ||
| 90 | 			} | ||
| 91 | 			/* When previous components are already known to be | ||
| 92 | 			 * directories, processing .. can skip readlink. */ | ||
| 93 | 			if (!check_dir) goto skip_readlink; | ||
| 94 | 		} | ||
| 95 | 		ssize_t k = readlink(output, stack, p); | ||
| 96 | 		if (k==p) goto toolong; | ||
| 97 | 		if (!k) { | ||
| 98 | 			errno = ENOENT; | ||
| 99 | 			return 0; | ||
| 100 | 		} | ||
| 101 | 		if (k<0) { | ||
| 102 | 			if (errno != EINVAL) return 0; | ||
| 103 | skip_readlink: | ||
| 104 | 			check_dir = 0; | ||
| 105 | 			if (up) { | ||
| 106 | 				while(q && output[q-1]!='/') q--; | ||
| 107 | 				if (q>1 && (q>2 || output[0]!='/')) q--; | ||
| 108 | 				continue; | ||
| 109 | 			} | ||
| 110 | 			if (l0) q += l; | ||
| 111 | 			check_dir = stack[p]; | ||
| 112 | 			continue; | ||
| 113 | 		} | ||
| 114 | 		if (++cnt == SYMLOOP_MAX) { | ||
| 115 | 			errno = ELOOP; | ||
| 116 | 			return 0; | ||
| 117 | 		} | ||
| 118 | |||
| 119 | 		/* If link contents end in /, strip any slashes already on | ||
| 120 | 		 * stack to avoid /->// or //->/// or spurious toolong. */ | ||
| 121 | 		if (stack[k-1]=='/') while (stack[p]=='/') p++; | ||
| 122 | 		p -= k; | ||
| 123 | 		memmove(stack+p, stack, k); | ||
| 124 | |||
| 125 | 		/* Skip the stack advancement in case we have a new | ||
| 126 | 		 * absolute base path. */ | ||
| 127 | 		goto restart; | ||
| 36 | 	} | 128 | 	} |
| 37 | 129 | ||
| 38 | 	__syscall(SYS_close, fd); | 130 | 	output[q] = 0; |
| 39 | 	return resolved ? strcpy(resolved, tmp) : strdup(tmp); | 131 | |
| 40 | err: | 132 | 	if (output[0] != '/') { |
| 41 | 	__syscall(SYS_close, fd); | 133 | 		if (!getcwd(stack, sizeof stack)) return 0; |
| 134 | 		l = strlen(stack); | ||
| 135 | 		/* Cancel any initial .. components. */ | ||
| 136 | 		p = 0; | ||
| 137 | 		while (nup--) { | ||
| 138 | 			while(l>1 && stack[l-1]!='/') l--; | ||
| 139 | 			if (l>1) l--; | ||
| 140 | 			p += 2; | ||
| 141 | 			if (p<q) p++; | ||
| 142 | 		} | ||
| 143 | 		if (q-p && stack[l-1]!='/') stack[l++] = '/'; | ||
| 144 | 		if (l + (q-p) + 1 >= PATH_MAX) goto toolong; | ||
| 145 | 		memmove(output + l, output + p, q - p + 1); | ||
| 146 | 		memcpy(output, stack, l); | ||
| 147 | 		q = l + q-p; | ||
| 148 | 	} | ||
| 149 | |||
| 150 | 	if (resolved) return memcpy(resolved, output, q+1); | ||
| 151 | 	else return strdup(output); | ||
| 152 | |||
| 153 | toolong: | ||
| 154 | 	errno = ENAMETOOLONG; | ||
| 42 | 	return 0; | 155 | 	return 0; |
| 43 | } | 156 | } |
lib/libc/musl/src/misc/setrlimit.c+17-20| ... | @@ -6,25 +6,8 @@ | ... | @@ -6,25 +6,8 @@ |
| 6 | #define MIN(a, b) ((a)<(b) ? (a) : (b)) | 6 | #define MIN(a, b) ((a)<(b) ? (a) : (b)) |
| 7 | #define FIX(x) do{ if ((x)>=SYSCALL_RLIM_INFINITY) (x)=RLIM_INFINITY; }while(0) | 7 | #define FIX(x) do{ if ((x)>=SYSCALL_RLIM_INFINITY) (x)=RLIM_INFINITY; }while(0) |
| 8 | 8 | ||
| 9 | static int __setrlimit(int resource, const struct rlimit *rlim) | ||
| 10 | { | ||
| 11 | 	unsigned long k_rlim[2]; | ||
| 12 | 	struct rlimit tmp; | ||
| 13 | 	if (SYSCALL_RLIM_INFINITY != RLIM_INFINITY) { | ||
| 14 | 		tmp = *rlim; | ||
| 15 | 		FIX(tmp.rlim_cur); | ||
| 16 | 		FIX(tmp.rlim_max); | ||
| 17 | 		rlim = &tmp; | ||
| 18 | 	} | ||
| 19 | 	int ret = __syscall(SYS_prlimit64, 0, resource, rlim, 0); | ||
| 20 | 	if (ret != -ENOSYS) return ret; | ||
| 21 | 	k_rlim[0] = MIN(rlim->rlim_cur, MIN(-1UL, SYSCALL_RLIM_INFINITY)); | ||
| 22 | 	k_rlim[1] = MIN(rlim->rlim_max, MIN(-1UL, SYSCALL_RLIM_INFINITY)); | ||
| 23 | 	return __syscall(SYS_setrlimit, resource, k_rlim); | ||
| 24 | } | ||
| 25 | |||
| 26 | struct ctx { | 9 | struct ctx { |
| 27 | 	const struct rlimit *rlim; | 10 | 	unsigned long lim[2]; |
| 28 | 	int res; | 11 | 	int res; |
| 29 | 	int err; | 12 | 	int err; |
| 30 | }; | 13 | }; |
| ... | @@ -33,12 +16,26 @@ static void do_setrlimit(void *p) | ... | @@ -33,12 +16,26 @@ static void do_setrlimit(void *p) |
| 33 | { | 16 | { |
| 34 | 	struct ctx *c = p; | 17 | 	struct ctx *c = p; |
| 35 | 	if (c->err>0) return; | 18 | 	if (c->err>0) return; |
| 36 | 	c->err = -__setrlimit(c->res, c->rlim); | 19 | 	c->err = -__syscall(SYS_setrlimit, c->res, c->lim); |
| 37 | } | 20 | } |
| 38 | 21 | ||
| 39 | int setrlimit(int resource, const struct rlimit *rlim) | 22 | int setrlimit(int resource, const struct rlimit *rlim) |
| 40 | { | 23 | { |
| 41 | 	struct ctx c = { .res = resource, .rlim = rlim, .err = -1 }; | 24 | 	struct rlimit tmp; |
| 25 | 	if (SYSCALL_RLIM_INFINITY != RLIM_INFINITY) { | ||
| 26 | 		tmp = *rlim; | ||
| 27 | 		FIX(tmp.rlim_cur); | ||
| 28 | 		FIX(tmp.rlim_max); | ||
| 29 | 		rlim = &tmp; | ||
| 30 | 	} | ||
| 31 | 	int ret = __syscall(SYS_prlimit64, 0, resource, rlim, 0); | ||
| 32 | 	if (ret != -ENOSYS) return __syscall_ret(ret); | ||
| 33 | |||
| 34 | 	struct ctx c = { | ||
| 35 | 		.lim[0] = MIN(rlim->rlim_cur, MIN(-1UL, SYSCALL_RLIM_INFINITY)), | ||
| 36 | 		.lim[1] = MIN(rlim->rlim_max, MIN(-1UL, SYSCALL_RLIM_INFINITY)), | ||
| 37 | 		.res = resource, .err = -1 | ||
| 38 | 	}; | ||
| 42 | 	__synccall(do_setrlimit, &c); | 39 | 	__synccall(do_setrlimit, &c); |
| 43 | 	if (c.err) { | 40 | 	if (c.err) { |
| 44 | 		if (c.err>0) errno = c.err; | 41 | 		if (c.err>0) errno = c.err; |
lib/libc/musl/src/misc/syslog.c+2| ... | @@ -10,6 +10,7 @@ | ... | @@ -10,6 +10,7 @@ |
| 10 | #include <errno.h> | 10 | #include <errno.h> |
| 11 | #include <fcntl.h> | 11 | #include <fcntl.h> |
| 12 | #include "lock.h" | 12 | #include "lock.h" |
| 13 | #include "fork_impl.h" | ||
| 13 | 14 | ||
| 14 | static volatile int lock[1]; | 15 | static volatile int lock[1]; |
| 15 | static char log_ident[32]; | 16 | static char log_ident[32]; |
| ... | @@ -17,6 +18,7 @@ static int log_opt; | ... | @@ -17,6 +18,7 @@ static int log_opt; |
| 17 | static int log_facility = LOG_USER; | 18 | static int log_facility = LOG_USER; |
| 18 | static int log_mask = 0xff; | 19 | static int log_mask = 0xff; |
| 19 | static int log_fd = -1; | 20 | static int log_fd = -1; |
| 21 | volatile int *const __syslog_lockptr = lock; | ||
| 20 | 22 | ||
| 21 | int setlogmask(int maskpri) | 23 | int setlogmask(int maskpri) |
| 22 | { | 24 | { |
lib/libc/musl/src/multibyte/wcsnrtombs.c+19-27| ... | @@ -1,41 +1,33 @@ | ... | @@ -1,41 +1,33 @@ |
| 1 | #include <wchar.h> | 1 | #include <wchar.h> |
| 2 | #include <limits.h> | ||
| 3 | #include <string.h> | ||
| 2 | 4 | ||
| 3 | size_t wcsnrtombs(char *restrict dst, const wchar_t **restrict wcs, size_t wn, size_t n, mbstate_t *restrict st) | 5 | size_t wcsnrtombs(char *restrict dst, const wchar_t **restrict wcs, size_t wn, size_t n, mbstate_t *restrict st) |
| 4 | { | 6 | { |
| 5 | 	size_t l, cnt=0, n2; | ||
| 6 | 	char *s, buf[256]; | ||
| 7 | 	const wchar_t *ws = *wcs; | 7 | 	const wchar_t *ws = *wcs; |
| 8 | 	const wchar_t *tmp_ws; | 8 | 	size_t cnt = 0; |
| 9 | 9 | 	if (!dst) n=0; | |
| 10 | 	if (!dst) s = buf, n = sizeof buf; | 10 | 	while (ws && wn) { |
| 11 | 	else s = dst; | 11 | 		char tmp[MB_LEN_MAX]; |
| 12 | 12 | 		size_t l = wcrtomb(n<MB_LEN_MAX ? tmp : dst, *ws, 0); | |
| 13 | 	while ( ws && n && ( (n2=wn)>=n || n2>32 ) ) { | 13 | 		if (l==-1) { |
| 14 | 		if (n2>=n) n2=n; | 14 | 			cnt = -1; |
| 15 | 		tmp_ws = ws; | ||
| 16 | 		l = wcsrtombs(s, &ws, n2, 0); | ||
| 17 | 		if (!(l+1)) { | ||
| 18 | 			cnt = l; | ||
| 19 | 			n = 0; | ||
| 20 | 			break; | 15 | 			break; |
| 21 | 		} | 16 | 		} |
| 22 | 		if (s != buf) { | 17 | 		if (dst) { |
| 23 | 			s += l; | 18 | 			if (n<MB_LEN_MAX) { |
| 19 | 				if (l>n) break; | ||
| 20 | 				memcpy(dst, tmp, l); | ||
| 21 | 			} | ||
| 22 | 			dst += l; | ||
| 24 | 			n -= l; | 23 | 			n -= l; |
| 25 | 		} | 24 | 		} |
| 26 | 		wn = ws ? wn - (ws - tmp_ws) : 0; | 25 | 		if (!*ws) { |
| 27 | 		cnt += l; | 26 | 			ws = 0; |
| 28 | 	} | ||
| 29 | 	if (ws) while (n && wn) { | ||
| 30 | 		l = wcrtomb(s, *ws, 0); | ||
| 31 | 		if ((l+1)<=1) { | ||
| 32 | 			if (!l) ws = 0; | ||
| 33 | 			else cnt = l; | ||
| 34 | 			break; | 27 | 			break; |
| 35 | 		} | 28 | 		} |
| 36 | 		ws++; wn--; | 29 | 		ws++; |
| 37 | 		/* safe - this loop runs fewer than sizeof(buf) times */ | 30 | 		wn--; |
| 38 | 		s+=l; n-=l; | ||
| 39 | 		cnt += l; | 31 | 		cnt += l; |
| 40 | 	} | 32 | 	} |
| 41 | 	if (dst) *wcs = ws; | 33 | 	if (dst) *wcs = ws; |
lib/libc/musl/src/network/h_errno.c+3-1| ... | @@ -1,9 +1,11 @@ | ... | @@ -1,9 +1,11 @@ |
| 1 | #include <netdb.h> | 1 | #include <netdb.h> |
| 2 | #include "pthread_impl.h" | ||
| 2 | 3 | ||
| 3 | #undef h_errno | 4 | #undef h_errno |
| 4 | int h_errno; | 5 | int h_errno; |
| 5 | 6 | ||
| 6 | int *__h_errno_location(void) | 7 | int *__h_errno_location(void) |
| 7 | { | 8 | { |
| 8 | 	return &h_errno; | 9 | 	if (!__pthread_self()->stack) return &h_errno; |
| 10 | 	return &__pthread_self()->h_errno_val; | ||
| 9 | } | 11 | } |
lib/libc/musl/src/network/herror.c+1-1| ... | @@ -4,5 +4,5 @@ | ... | @@ -4,5 +4,5 @@ |
| 4 | 4 | ||
| 5 | void herror(const char *msg) | 5 | void herror(const char *msg) |
| 6 | { | 6 | { |
| 7 | 	fprintf(stderr, "%s%s%s", msg?msg:"", msg?": ":"", hstrerror(h_errno)); | 7 | 	fprintf(stderr, "%s%s%s\n", msg?msg:"", msg?": ":"", hstrerror(h_errno)); |
| 8 | } | 8 | } |
lib/libc/musl/src/network/lookup_name.c+8-3| ... | @@ -50,7 +50,7 @@ static int name_from_hosts(struct address buf[static MAXADDRS], char canon[stati | ... | @@ -50,7 +50,7 @@ static int name_from_hosts(struct address buf[static MAXADDRS], char canon[stati |
| 50 | { | 50 | { |
| 51 | 	char line[512]; | 51 | 	char line[512]; |
| 52 | 	size_t l = strlen(name); | 52 | 	size_t l = strlen(name); |
| 53 | 	int cnt = 0, badfam = 0; | 53 | 	int cnt = 0, badfam = 0, have_canon = 0; |
| 54 | 	unsigned char _buf[1032]; | 54 | 	unsigned char _buf[1032]; |
| 55 | 	FILE _f, *f = __fopen_rb_ca("/etc/hosts", &_f, _buf, sizeof _buf); | 55 | 	FILE _f, *f = __fopen_rb_ca("/etc/hosts", &_f, _buf, sizeof _buf); |
| 56 | 	if (!f) switch (errno) { | 56 | 	if (!f) switch (errno) { |
| ... | @@ -80,14 +80,19 @@ static int name_from_hosts(struct address buf[static MAXADDRS], char canon[stati | ... | @@ -80,14 +80,19 @@ static int name_from_hosts(struct address buf[static MAXADDRS], char canon[stati |
| 80 | 			continue; | 80 | 			continue; |
| 81 | 		default: | 81 | 		default: |
| 82 | 			badfam = EAI_NONAME; | 82 | 			badfam = EAI_NONAME; |
| 83 | 			continue; | 83 | 			break; |
| 84 | 		} | 84 | 		} |
| 85 | 85 | ||
| 86 | 		if (have_canon) continue; | ||
| 87 | |||
| 86 | 		/* Extract first name as canonical name */ | 88 | 		/* Extract first name as canonical name */ |
| 87 | 		for (; *p && isspace(*p); p++); | 89 | 		for (; *p && isspace(*p); p++); |
| 88 | 		for (z=p; *z && !isspace(*z); z++); | 90 | 		for (z=p; *z && !isspace(*z); z++); |
| 89 | 		*z = 0; | 91 | 		*z = 0; |
| 90 | 		if (is_valid_hostname(p)) memcpy(canon, p, z-p+1); | 92 | 		if (is_valid_hostname(p)) { |
| 93 | 			have_canon = 1; | ||
| 94 | 			memcpy(canon, p, z-p+1); | ||
| 95 | 		} | ||
| 91 | 	} | 96 | 	} |
| 92 | 	__fclose_ca(f); | 97 | 	__fclose_ca(f); |
| 93 | 	return cnt ? cnt : badfam; | 98 | 	return cnt ? cnt : badfam; |
lib/libc/musl/src/network/res_query.c+15-1| ... | @@ -1,3 +1,4 @@ | ... | @@ -1,3 +1,4 @@ |
| 1 | #define _BSD_SOURCE | ||
| 1 | #include <resolv.h> | 2 | #include <resolv.h> |
| 2 | #include <netdb.h> | 3 | #include <netdb.h> |
| 3 | 4 | ||
| ... | @@ -6,7 +7,20 @@ int res_query(const char *name, int class, int type, unsigned char *dest, int le | ... | @@ -6,7 +7,20 @@ int res_query(const char *name, int class, int type, unsigned char *dest, int le |
| 6 | 	unsigned char q[280]; | 7 | 	unsigned char q[280]; |
| 7 | 	int ql = __res_mkquery(0, name, class, type, 0, 0, 0, q, sizeof q); | 8 | 	int ql = __res_mkquery(0, name, class, type, 0, 0, 0, q, sizeof q); |
| 8 | 	if (ql < 0) return ql; | 9 | 	if (ql < 0) return ql; |
| 9 | 	return __res_send(q, ql, dest, len); | 10 | 	int r = __res_send(q, ql, dest, len); |
| 11 | 	if (r<12) { | ||
| 12 | 		h_errno = TRY_AGAIN; | ||
| 13 | 		return -1; | ||
| 14 | 	} | ||
| 15 | 	if ((dest[3] & 15) == 3) { | ||
| 16 | 		h_errno = HOST_NOT_FOUND; | ||
| 17 | 		return -1; | ||
| 18 | 	} | ||
| 19 | 	if ((dest[3] & 15) == 0 && !dest[6] && !dest[7]) { | ||
| 20 | 		h_errno = NO_DATA; | ||
| 21 | 		return -1; | ||
| 22 | 	} | ||
| 23 | 	return r; | ||
| 10 | } | 24 | } |
| 11 | 25 | ||
| 12 | weak_alias(res_query, res_search); | 26 | weak_alias(res_query, res_search); |
lib/libc/musl/src/passwd/getgrouplist.c+2-1| ... | @@ -31,7 +31,8 @@ int getgrouplist(const char *user, gid_t gid, gid_t *groups, int *ngroups) | ... | @@ -31,7 +31,8 @@ int getgrouplist(const char *user, gid_t gid, gid_t *groups, int *ngroups) |
| 31 | 	if (resp[INITGRFOUND]) { | 31 | 	if (resp[INITGRFOUND]) { |
| 32 | 		nscdbuf = calloc(resp[INITGRNGRPS], sizeof(uint32_t)); | 32 | 		nscdbuf = calloc(resp[INITGRNGRPS], sizeof(uint32_t)); |
| 33 | 		if (!nscdbuf) goto cleanup; | 33 | 		if (!nscdbuf) goto cleanup; |
| 34 | 		if (!fread(nscdbuf, sizeof(*nscdbuf)*resp[INITGRNGRPS], 1, f)) { | 34 | 		size_t nbytes = sizeof(*nscdbuf)*resp[INITGRNGRPS]; |
| 35 | 		if (nbytes && !fread(nscdbuf, nbytes, 1, f)) { | ||
| 35 | 			if (!ferror(f)) errno = EIO; | 36 | 			if (!ferror(f)) errno = EIO; |
| 36 | 			goto cleanup; | 37 | 			goto cleanup; |
| 37 | 		} | 38 | 		} |
lib/libc/musl/src/prng/random.c+2| ... | @@ -1,6 +1,7 @@ | ... | @@ -1,6 +1,7 @@ |
| 1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
| 2 | #include <stdint.h> | 2 | #include <stdint.h> |
| 3 | #include "lock.h" | 3 | #include "lock.h" |
| 4 | #include "fork_impl.h" | ||
| 4 | 5 | ||
| 5 | /* | 6 | /* |
| 6 | this code uses the same lagged fibonacci generator as the | 7 | this code uses the same lagged fibonacci generator as the |
| ... | @@ -23,6 +24,7 @@ static int i = 3; | ... | @@ -23,6 +24,7 @@ static int i = 3; |
| 23 | static int j = 0; | 24 | static int j = 0; |
| 24 | static uint32_t *x = init+1; | 25 | static uint32_t *x = init+1; |
| 25 | static volatile int lock[1]; | 26 | static volatile int lock[1]; |
| 27 | volatile int *const __random_lockptr = lock; | ||
| 26 | 28 | ||
| 27 | static uint32_t lcg31(uint32_t x) { | 29 | static uint32_t lcg31(uint32_t x) { |
| 28 | 	return (1103515245*x + 12345) & 0x7fffffff; | 30 | 	return (1103515245*x + 12345) & 0x7fffffff; |
lib/libc/musl/src/process/_Fork.c created+38| ... | @@ -0,0 +1,38 @@ | ||
| 1 | #include <unistd.h> | ||
| 2 | #include <signal.h> | ||
| 3 | #include "syscall.h" | ||
| 4 | #include "libc.h" | ||
| 5 | #include "lock.h" | ||
| 6 | #include "pthread_impl.h" | ||
| 7 | #include "aio_impl.h" | ||
| 8 | |||
| 9 | static void dummy(int x) { } | ||
| 10 | weak_alias(dummy, __aio_atfork); | ||
| 11 | |||
| 12 | pid_t _Fork(void) | ||
| 13 | { | ||
| 14 | 	pid_t ret; | ||
| 15 | 	sigset_t set; | ||
| 16 | 	__block_all_sigs(&set); | ||
| 17 | 	__aio_atfork(-1); | ||
| 18 | 	LOCK(__abort_lock); | ||
| 19 | #ifdef SYS_fork | ||
| 20 | 	ret = __syscall(SYS_fork); | ||
| 21 | #else | ||
| 22 | 	ret = __syscall(SYS_clone, SIGCHLD, 0); | ||
| 23 | #endif | ||
| 24 | 	if (!ret) { | ||
| 25 | 		pthread_t self = __pthread_self(); | ||
| 26 | 		self->tid = __syscall(SYS_gettid); | ||
| 27 | 		self->robust_list.off = 0; | ||
| 28 | 		self->robust_list.pending = 0; | ||
| 29 | 		self->next = self->prev = self; | ||
| 30 | 		__thread_list_lock = 0; | ||
| 31 | 		libc.threads_minus_1 = 0; | ||
| 32 | 		if (libc.need_locks) libc.need_locks = -1; | ||
| 33 | 	} | ||
| 34 | 	UNLOCK(__abort_lock); | ||
| 35 | 	__aio_atfork(!ret); | ||
| 36 | 	__restore_sigs(&set); | ||
| 37 | 	return __syscall_ret(ret); | ||
| 38 | } | ||
lib/libc/musl/src/process/fork.c+71-23| ... | @@ -1,38 +1,86 @@ | ... | @@ -1,38 +1,86 @@ |
| 1 | #include <unistd.h> | 1 | #include <unistd.h> |
| 2 | #include <string.h> | 2 | #include <errno.h> |
| 3 | #include <signal.h> | ||
| 4 | #include "syscall.h" | ||
| 5 | #include "libc.h" | 3 | #include "libc.h" |
| 4 | #include "lock.h" | ||
| 6 | #include "pthread_impl.h" | 5 | #include "pthread_impl.h" |
| 6 | #include "fork_impl.h" | ||
| 7 | 7 | ||
| 8 | static void dummy(int x) | 8 | static volatile int *const dummy_lockptr = 0; |
| 9 | { | 9 | |
| 10 | } | 10 | weak_alias(dummy_lockptr, __at_quick_exit_lockptr); |
| 11 | weak_alias(dummy_lockptr, __atexit_lockptr); | ||
| 12 | weak_alias(dummy_lockptr, __dlerror_lockptr); | ||
| 13 | weak_alias(dummy_lockptr, __gettext_lockptr); | ||
| 14 | weak_alias(dummy_lockptr, __locale_lockptr); | ||
| 15 | weak_alias(dummy_lockptr, __random_lockptr); | ||
| 16 | weak_alias(dummy_lockptr, __sem_open_lockptr); | ||
| 17 | weak_alias(dummy_lockptr, __stdio_ofl_lockptr); | ||
| 18 | weak_alias(dummy_lockptr, __syslog_lockptr); | ||
| 19 | weak_alias(dummy_lockptr, __timezone_lockptr); | ||
| 20 | weak_alias(dummy_lockptr, __bump_lockptr); | ||
| 21 | |||
| 22 | weak_alias(dummy_lockptr, __vmlock_lockptr); | ||
| 11 | 23 | ||
| 24 | static volatile int *const *const atfork_locks[] = { | ||
| 25 | 	&__at_quick_exit_lockptr, | ||
| 26 | 	&__atexit_lockptr, | ||
| 27 | 	&__dlerror_lockptr, | ||
| 28 | 	&__gettext_lockptr, | ||
| 29 | 	&__locale_lockptr, | ||
| 30 | 	&__random_lockptr, | ||
| 31 | 	&__sem_open_lockptr, | ||
| 32 | 	&__stdio_ofl_lockptr, | ||
| 33 | 	&__syslog_lockptr, | ||
| 34 | 	&__timezone_lockptr, | ||
| 35 | 	&__bump_lockptr, | ||
| 36 | }; | ||
| 37 | |||
| 38 | static void dummy(int x) { } | ||
| 12 | weak_alias(dummy, __fork_handler); | 39 | weak_alias(dummy, __fork_handler); |
| 40 | weak_alias(dummy, __malloc_atfork); | ||
| 41 | weak_alias(dummy, __ldso_atfork); | ||
| 42 | |||
| 43 | static void dummy_0(void) { } | ||
| 44 | weak_alias(dummy_0, __tl_lock); | ||
| 45 | weak_alias(dummy_0, __tl_unlock); | ||
| 13 | 46 | ||
| 14 | pid_t fork(void) | 47 | pid_t fork(void) |
| 15 | { | 48 | { |
| 16 | 	pid_t ret; | ||
| 17 | 	sigset_t set; | 49 | 	sigset_t set; |
| 18 | 	__fork_handler(-1); | 50 | 	__fork_handler(-1); |
| 19 | 	__block_all_sigs(&set); | 51 | 	__block_app_sigs(&set); |
| 20 | #ifdef SYS_fork | 52 | 	int need_locks = libc.need_locks > 0; |
| 21 | 	ret = __syscall(SYS_fork); | 53 | 	if (need_locks) { |
| 22 | #else | 54 | 		__ldso_atfork(-1); |
| 23 | 	ret = __syscall(SYS_clone, SIGCHLD, 0); | 55 | 		__inhibit_ptc(); |
| 24 | #endif | 56 | 		for (int i=0; i<sizeof atfork_locks/sizeof *atfork_locks; i++) |
| 25 | 	if (!ret) { | 57 | 			if (*atfork_locks[i]) LOCK(*atfork_locks[i]); |
| 26 | 		pthread_t self = __pthread_self(); | 58 | 		__malloc_atfork(-1); |
| 27 | 		self->tid = __syscall(SYS_gettid); | 59 | 		__tl_lock(); |
| 28 | 		self->robust_list.off = 0; | 60 | 	} |
| 29 | 		self->robust_list.pending = 0; | 61 | 	pthread_t self=__pthread_self(), next=self->next; |
| 30 | 		self->next = self->prev = self; | 62 | 	pid_t ret = _Fork(); |
| 31 | 		__thread_list_lock = 0; | 63 | 	int errno_save = errno; |
| 32 | 		libc.threads_minus_1 = 0; | 64 | 	if (need_locks) { |
| 33 | 		if (libc.need_locks) libc.need_locks = -1; | 65 | 		if (!ret) { |
| 66 | 			for (pthread_t td=next; td!=self; td=td->next) | ||
| 67 | 				td->tid = -1; | ||
| 68 | 			if (__vmlock_lockptr) { | ||
| 69 | 				__vmlock_lockptr[0] = 0; | ||
| 70 | 				__vmlock_lockptr[1] = 0; | ||
| 71 | 			} | ||
| 72 | 		} | ||
| 73 | 		__tl_unlock(); | ||
| 74 | 		__malloc_atfork(!ret); | ||
| 75 | 		for (int i=0; i<sizeof atfork_locks/sizeof *atfork_locks; i++) | ||
| 76 | 			if (*atfork_locks[i]) | ||
| 77 | 				if (ret) UNLOCK(*atfork_locks[i]); | ||
| 78 | 				else **atfork_locks[i] = 0; | ||
| 79 | 		__release_ptc(); | ||
| 80 | 		__ldso_atfork(!ret); | ||
| 34 | 	} | 81 | 	} |
| 35 | 	__restore_sigs(&set); | 82 | 	__restore_sigs(&set); |
| 36 | 	__fork_handler(!ret); | 83 | 	__fork_handler(!ret); |
| 37 | 	return __syscall_ret(ret); | 84 | 	if (ret<0) errno = errno_save; |
| 85 | 	return ret; | ||
| 38 | } | 86 | } |
lib/libc/musl/src/process/posix_spawn.c+13-3| ... | @@ -6,6 +6,7 @@ | ... | @@ -6,6 +6,7 @@ |
| 6 | #include <fcntl.h> | 6 | #include <fcntl.h> |
| 7 | #include <sys/wait.h> | 7 | #include <sys/wait.h> |
| 8 | #include "syscall.h" | 8 | #include "syscall.h" |
| 9 | #include "lock.h" | ||
| 9 | #include "pthread_impl.h" | 10 | #include "pthread_impl.h" |
| 10 | #include "fdop.h" | 11 | #include "fdop.h" |
| 11 | 12 | ||
| ... | @@ -170,9 +171,6 @@ int posix_spawn(pid_t *restrict res, const char *restrict path, | ... | @@ -170,9 +171,6 @@ int posix_spawn(pid_t *restrict res, const char *restrict path, |
| 170 | 	int ec=0, cs; | 171 | 	int ec=0, cs; |
| 171 | 	struct args args; | 172 | 	struct args args; |
| 172 | 173 | ||
| 173 | 	if (pipe2(args.p, O_CLOEXEC)) | ||
| 174 | 		return errno; | ||
| 175 | |||
| 176 | 	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs); | 174 | 	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs); |
| 177 | 175 | ||
| 178 | 	args.path = path; | 176 | 	args.path = path; |
| ... | @@ -182,9 +180,20 @@ int posix_spawn(pid_t *restrict res, const char *restrict path, | ... | @@ -182,9 +180,20 @@ int posix_spawn(pid_t *restrict res, const char *restrict path, |
| 182 | 	args.envp = envp; | 180 | 	args.envp = envp; |
| 183 | 	pthread_sigmask(SIG_BLOCK, SIGALL_SET, &args.oldmask); | 181 | 	pthread_sigmask(SIG_BLOCK, SIGALL_SET, &args.oldmask); |
| 184 | 182 | ||
| 183 | 	/* The lock guards both against seeing a SIGABRT disposition change | ||
| 184 | 	 * by abort and against leaking the pipe fd to fork-without-exec. */ | ||
| 185 | 	LOCK(__abort_lock); | ||
| 186 | |||
| 187 | 	if (pipe2(args.p, O_CLOEXEC)) { | ||
| 188 | 		UNLOCK(__abort_lock); | ||
| 189 | 		ec = errno; | ||
| 190 | 		goto fail; | ||
| 191 | 	} | ||
| 192 | |||
| 185 | 	pid = __clone(child, stack+sizeof stack, | 193 | 	pid = __clone(child, stack+sizeof stack, |
| 186 | 		CLONE_VM|CLONE_VFORK|SIGCHLD, &args); | 194 | 		CLONE_VM|CLONE_VFORK|SIGCHLD, &args); |
| 187 | 	close(args.p[1]); | 195 | 	close(args.p[1]); |
| 196 | 	UNLOCK(__abort_lock); | ||
| 188 | 197 | ||
| 189 | 	if (pid > 0) { | 198 | 	if (pid > 0) { |
| 190 | 		if (read(args.p[0], &ec, sizeof ec) != sizeof ec) ec = 0; | 199 | 		if (read(args.p[0], &ec, sizeof ec) != sizeof ec) ec = 0; |
| ... | @@ -197,6 +206,7 @@ int posix_spawn(pid_t *restrict res, const char *restrict path, | ... | @@ -197,6 +206,7 @@ int posix_spawn(pid_t *restrict res, const char *restrict path, |
| 197 | 206 | ||
| 198 | 	if (!ec && res) *res = pid; | 207 | 	if (!ec && res) *res = pid; |
| 199 | 208 | ||
| 209 | fail: | ||
| 200 | 	pthread_sigmask(SIG_SETMASK, &args.oldmask, 0); | 210 | 	pthread_sigmask(SIG_SETMASK, &args.oldmask, 0); |
| 201 | 	pthread_setcancelstate(cs, 0); | 211 | 	pthread_setcancelstate(cs, 0); |
| 202 | 212 |
lib/libc/musl/src/setjmp/aarch64/longjmp.s+3-4| ... | @@ -18,7 +18,6 @@ longjmp: | ... | @@ -18,7 +18,6 @@ longjmp: |
| 18 | 	ldp d12, d13, [x0,#144] | 18 | 	ldp d12, d13, [x0,#144] |
| 19 | 	ldp d14, d15, [x0,#160] | 19 | 	ldp d14, d15, [x0,#160] |
| 20 | 20 | ||
| 21 | 	mov x0, x1 | 21 | 	cmp w1, 0 |
| 22 | 	cbnz x1, 1f | 22 | 	csinc w0, w1, wzr, ne |
| 23 | 	mov x0, #1 | 23 | 	br x30 |
| 24 | 1:	br x30 |
lib/libc/musl/src/setjmp/i386/longjmp.s+4-8| ... | @@ -6,15 +6,11 @@ _longjmp: | ... | @@ -6,15 +6,11 @@ _longjmp: |
| 6 | longjmp: | 6 | longjmp: |
| 7 | 	mov 4(%esp),%edx | 7 | 	mov 4(%esp),%edx |
| 8 | 	mov 8(%esp),%eax | 8 | 	mov 8(%esp),%eax |
| 9 | 	test %eax,%eax | 9 | 	cmp $1,%eax |
| 10 | 	jnz 1f | 10 | 	adc $0, %al |
| 11 | 	inc %eax | ||
| 12 | 1: | ||
| 13 | 	mov (%edx),%ebx | 11 | 	mov (%edx),%ebx |
| 14 | 	mov 4(%edx),%esi | 12 | 	mov 4(%edx),%esi |
| 15 | 	mov 8(%edx),%edi | 13 | 	mov 8(%edx),%edi |
| 16 | 	mov 12(%edx),%ebp | 14 | 	mov 12(%edx),%ebp |
| 17 | 	mov 16(%edx),%ecx | 15 | 	mov 16(%edx),%esp |
| 18 | 	mov %ecx,%esp | 16 | 	jmp *20(%edx) |
| 19 | 	mov 20(%edx),%ecx | ||
| 20 | 	jmp *%ecx |
lib/libc/musl/src/setjmp/x32/longjmp.s+5-9| ... | @@ -5,18 +5,14 @@ | ... | @@ -5,18 +5,14 @@ |
| 5 | .type longjmp,@function | 5 | .type longjmp,@function |
| 6 | _longjmp: | 6 | _longjmp: |
| 7 | longjmp: | 7 | longjmp: |
| 8 | 	mov %rsi,%rax /* val will be longjmp return */ | 8 | 	xor %eax,%eax |
| 9 | 	test %rax,%rax | 9 | 	cmp $1,%esi /* CF = val ? 0 : 1 */ |
| 10 | 	jnz 1f | 10 | 	adc %esi,%eax /* eax = val + !val */ |
| 11 | 	inc %rax /* if val==0, val=1 per longjmp semantics */ | ||
| 12 | 1: | ||
| 13 | 	mov (%rdi),%rbx /* rdi is the jmp_buf, restore regs from it */ | 11 | 	mov (%rdi),%rbx /* rdi is the jmp_buf, restore regs from it */ |
| 14 | 	mov 8(%rdi),%rbp | 12 | 	mov 8(%rdi),%rbp |
| 15 | 	mov 16(%rdi),%r12 | 13 | 	mov 16(%rdi),%r12 |
| 16 | 	mov 24(%rdi),%r13 | 14 | 	mov 24(%rdi),%r13 |
| 17 | 	mov 32(%rdi),%r14 | 15 | 	mov 32(%rdi),%r14 |
| 18 | 	mov 40(%rdi),%r15 | 16 | 	mov 40(%rdi),%r15 |
| 19 | 	mov 48(%rdi),%rdx /* this ends up being the stack pointer */ | 17 | 	mov 48(%rdi),%rsp |
| 20 | 	mov %rdx,%rsp | 18 | 	jmp *56(%rdi) /* goto saved address without altering rsp */ |
| 21 | 	mov 56(%rdi),%rdx /* this is the instruction pointer */ | ||
| 22 | 	jmp *%rdx /* goto saved address without altering rsp */ |
lib/libc/musl/src/setjmp/x32/setjmp.s+1-1| ... | @@ -18,5 +18,5 @@ setjmp: | ... | @@ -18,5 +18,5 @@ setjmp: |
| 18 | 	mov %rdx,48(%rdi) | 18 | 	mov %rdx,48(%rdi) |
| 19 | 	mov (%rsp),%rdx /* save return addr ptr for new rip */ | 19 | 	mov (%rsp),%rdx /* save return addr ptr for new rip */ |
| 20 | 	mov %rdx,56(%rdi) | 20 | 	mov %rdx,56(%rdi) |
| 21 | 	xor %rax,%rax /* always return 0 */ | 21 | 	xor %eax,%eax /* always return 0 */ |
| 22 | 	ret | 22 | 	ret |
lib/libc/musl/src/setjmp/x86_64/longjmp.s+5-9| ... | @@ -5,18 +5,14 @@ | ... | @@ -5,18 +5,14 @@ |
| 5 | .type longjmp,@function | 5 | .type longjmp,@function |
| 6 | _longjmp: | 6 | _longjmp: |
| 7 | longjmp: | 7 | longjmp: |
| 8 | 	mov %rsi,%rax /* val will be longjmp return */ | 8 | 	xor %eax,%eax |
| 9 | 	test %rax,%rax | 9 | 	cmp $1,%esi /* CF = val ? 0 : 1 */ |
| 10 | 	jnz 1f | 10 | 	adc %esi,%eax /* eax = val + !val */ |
| 11 | 	inc %rax /* if val==0, val=1 per longjmp semantics */ | ||
| 12 | 1: | ||
| 13 | 	mov (%rdi),%rbx /* rdi is the jmp_buf, restore regs from it */ | 11 | 	mov (%rdi),%rbx /* rdi is the jmp_buf, restore regs from it */ |
| 14 | 	mov 8(%rdi),%rbp | 12 | 	mov 8(%rdi),%rbp |
| 15 | 	mov 16(%rdi),%r12 | 13 | 	mov 16(%rdi),%r12 |
| 16 | 	mov 24(%rdi),%r13 | 14 | 	mov 24(%rdi),%r13 |
| 17 | 	mov 32(%rdi),%r14 | 15 | 	mov 32(%rdi),%r14 |
| 18 | 	mov 40(%rdi),%r15 | 16 | 	mov 40(%rdi),%r15 |
| 19 | 	mov 48(%rdi),%rdx /* this ends up being the stack pointer */ | 17 | 	mov 48(%rdi),%rsp |
| 20 | 	mov %rdx,%rsp | 18 | 	jmp *56(%rdi) /* goto saved address without altering rsp */ |
| 21 | 	mov 56(%rdi),%rdx /* this is the instruction pointer */ | ||
| 22 | 	jmp *%rdx /* goto saved address without altering rsp */ |
lib/libc/musl/src/setjmp/x86_64/setjmp.s+1-1| ... | @@ -18,5 +18,5 @@ setjmp: | ... | @@ -18,5 +18,5 @@ setjmp: |
| 18 | 	mov %rdx,48(%rdi) | 18 | 	mov %rdx,48(%rdi) |
| 19 | 	mov (%rsp),%rdx /* save return addr ptr for new rip */ | 19 | 	mov (%rsp),%rdx /* save return addr ptr for new rip */ |
| 20 | 	mov %rdx,56(%rdi) | 20 | 	mov %rdx,56(%rdi) |
| 21 | 	xor %rax,%rax /* always return 0 */ | 21 | 	xor %eax,%eax /* always return 0 */ |
| 22 | 	ret | 22 | 	ret |
lib/libc/musl/src/signal/sigaction.c+16-20| ... | @@ -7,12 +7,6 @@ | ... | @@ -7,12 +7,6 @@ |
| 7 | #include "lock.h" | 7 | #include "lock.h" |
| 8 | #include "ksigaction.h" | 8 | #include "ksigaction.h" |
| 9 | 9 | ||
| 10 | static volatile int dummy_lock[1] = { 0 }; | ||
| 11 | |||
| 12 | extern hidden volatile int __abort_lock[1]; | ||
| 13 | |||
| 14 | weak_alias(dummy_lock, __abort_lock); | ||
| 15 | |||
| 16 | static int unmask_done; | 10 | static int unmask_done; |
| 17 | static unsigned long handler_set[_NSIG/(8*sizeof(long))]; | 11 | static unsigned long handler_set[_NSIG/(8*sizeof(long))]; |
| 18 | 12 | ||
| ... | @@ -26,7 +20,6 @@ volatile int __eintr_valid_flag; | ... | @@ -26,7 +20,6 @@ volatile int __eintr_valid_flag; |
| 26 | int __libc_sigaction(int sig, const struct sigaction *restrict sa, struct sigaction *restrict old) | 20 | int __libc_sigaction(int sig, const struct sigaction *restrict sa, struct sigaction *restrict old) |
| 27 | { | 21 | { |
| 28 | 	struct k_sigaction ksa, ksa_old; | 22 | 	struct k_sigaction ksa, ksa_old; |
| 29 | 	unsigned long set[_NSIG/(8*sizeof(long))]; | ||
| 30 | 	if (sa) { | 23 | 	if (sa) { |
| 31 | 		if ((uintptr_t)sa->sa_handler > 1UL) { | 24 | 		if ((uintptr_t)sa->sa_handler > 1UL) { |
| 32 | 			a_or_l(handler_set+(sig-1)/(8*sizeof(long)), | 25 | 			a_or_l(handler_set+(sig-1)/(8*sizeof(long)), |
| ... | @@ -50,24 +43,12 @@ int __libc_sigaction(int sig, const struct sigaction *restrict sa, struct sigact | ... | @@ -50,24 +43,12 @@ int __libc_sigaction(int sig, const struct sigaction *restrict sa, struct sigact |
| 50 | 				a_store(&__eintr_valid_flag, 1); | 43 | 				a_store(&__eintr_valid_flag, 1); |
| 51 | 			} | 44 | 			} |
| 52 | 		} | 45 | 		} |
| 53 | 		/* Changing the disposition of SIGABRT to anything but | ||
| 54 | 		 * SIG_DFL requires a lock, so that it cannot be changed | ||
| 55 | 		 * while abort is terminating the process after simply | ||
| 56 | 		 * calling raise(SIGABRT) failed to do so. */ | ||
| 57 | 		if (sa->sa_handler != SIG_DFL && sig == SIGABRT) { | ||
| 58 | 			__block_all_sigs(&set); | ||
| 59 | 			LOCK(__abort_lock); | ||
| 60 | 		} | ||
| 61 | 		ksa.handler = sa->sa_handler; | 46 | 		ksa.handler = sa->sa_handler; |
| 62 | 		ksa.flags = sa->sa_flags | SA_RESTORER; | 47 | 		ksa.flags = sa->sa_flags | SA_RESTORER; |
| 63 | 		ksa.restorer = (sa->sa_flags & SA_SIGINFO) ? __restore_rt : __restore; | 48 | 		ksa.restorer = (sa->sa_flags & SA_SIGINFO) ? __restore_rt : __restore; |
| 64 | 		memcpy(&ksa.mask, &sa->sa_mask, _NSIG/8); | 49 | 		memcpy(&ksa.mask, &sa->sa_mask, _NSIG/8); |
| 65 | 	} | 50 | 	} |
| 66 | 	int r = __syscall(SYS_rt_sigaction, sig, sa?&ksa:0, old?&ksa_old:0, _NSIG/8); | 51 | 	int r = __syscall(SYS_rt_sigaction, sig, sa?&ksa:0, old?&ksa_old:0, _NSIG/8); |
| 67 | 	if (sig == SIGABRT && sa && sa->sa_handler != SIG_DFL) { | ||
| 68 | 		UNLOCK(__abort_lock); | ||
| 69 | 		__restore_sigs(&set); | ||
| 70 | 	} | ||
| 71 | 	if (old && !r) { | 52 | 	if (old && !r) { |
| 72 | 		old->sa_handler = ksa_old.handler; | 53 | 		old->sa_handler = ksa_old.handler; |
| 73 | 		old->sa_flags = ksa_old.flags; | 54 | 		old->sa_flags = ksa_old.flags; |
| ... | @@ -78,11 +59,26 @@ int __libc_sigaction(int sig, const struct sigaction *restrict sa, struct sigact | ... | @@ -78,11 +59,26 @@ int __libc_sigaction(int sig, const struct sigaction *restrict sa, struct sigact |
| 78 | 59 | ||
| 79 | int __sigaction(int sig, const struct sigaction *restrict sa, struct sigaction *restrict old) | 60 | int __sigaction(int sig, const struct sigaction *restrict sa, struct sigaction *restrict old) |
| 80 | { | 61 | { |
| 62 | 	unsigned long set[_NSIG/(8*sizeof(long))]; | ||
| 63 | |||
| 81 | 	if (sig-32U < 3 || sig-1U >= _NSIG-1) { | 64 | 	if (sig-32U < 3 || sig-1U >= _NSIG-1) { |
| 82 | 		errno = EINVAL; | 65 | 		errno = EINVAL; |
| 83 | 		return -1; | 66 | 		return -1; |
| 84 | 	} | 67 | 	} |
| 85 | 	return __libc_sigaction(sig, sa, old); | 68 | |
| 69 | 	/* Doing anything with the disposition of SIGABRT requires a lock, | ||
| 70 | 	 * so that it cannot be changed while abort is terminating the | ||
| 71 | 	 * process and so any change made by abort can't be observed. */ | ||
| 72 | 	if (sig == SIGABRT) { | ||
| 73 | 		__block_all_sigs(&set); | ||
| 74 | 		LOCK(__abort_lock); | ||
| 75 | 	} | ||
| 76 | 	int r = __libc_sigaction(sig, sa, old); | ||
| 77 | 	if (sig == SIGABRT) { | ||
| 78 | 		UNLOCK(__abort_lock); | ||
| 79 | 		__restore_sigs(&set); | ||
| 80 | 	} | ||
| 81 | 	return r; | ||
| 86 | } | 82 | } |
| 87 | 83 | ||
| 88 | weak_alias(__sigaction, sigaction); | 84 | weak_alias(__sigaction, sigaction); |
lib/libc/musl/src/stdio/__stdio_close.c+1| ... | @@ -1,4 +1,5 @@ | ... | @@ -1,4 +1,5 @@ |
| 1 | #include "stdio_impl.h" | 1 | #include "stdio_impl.h" |
| 2 | #include "aio_impl.h" | ||
| 2 | 3 | ||
| 3 | static int dummy(int fd) | 4 | static int dummy(int fd) |
| 4 | { | 5 | { |
lib/libc/musl/src/stdio/ofl.c+2| ... | @@ -1,8 +1,10 @@ | ... | @@ -1,8 +1,10 @@ |
| 1 | #include "stdio_impl.h" | 1 | #include "stdio_impl.h" |
| 2 | #include "lock.h" | 2 | #include "lock.h" |
| 3 | #include "fork_impl.h" | ||
| 3 | 4 | ||
| 4 | static FILE *ofl_head; | 5 | static FILE *ofl_head; |
| 5 | static volatile int ofl_lock[1]; | 6 | static volatile int ofl_lock[1]; |
| 7 | volatile int *const __stdio_ofl_lockptr = ofl_lock; | ||
| 6 | 8 | ||
| 7 | FILE **__ofl_lock() | 9 | FILE **__ofl_lock() |
| 8 | { | 10 | { |
lib/libc/musl/src/string/strstr.c+1-1| ... | @@ -96,7 +96,7 @@ static char *twoway_strstr(const unsigned char *h, const unsigned char *n) | ... | @@ -96,7 +96,7 @@ static char *twoway_strstr(const unsigned char *h, const unsigned char *n) |
| 96 | 	for (;;) { | 96 | 	for (;;) { |
| 97 | 		/* Update incremental end-of-haystack pointer */ | 97 | 		/* Update incremental end-of-haystack pointer */ |
| 98 | 		if (z-h < l) { | 98 | 		if (z-h < l) { |
| 99 | 			/* Fast estimate for MIN(l,63) */ | 99 | 			/* Fast estimate for MAX(l,63) */ |
| 100 | 			size_t grow = l | 63; | 100 | 			size_t grow = l | 63; |
| 101 | 			const unsigned char *z2 = memchr(z, 0, grow); | 101 | 			const unsigned char *z2 = memchr(z, 0, grow); |
| 102 | 			if (z2) { | 102 | 			if (z2) { |
lib/libc/musl/src/termios/tcgetwinsize.c created+8| ... | @@ -0,0 +1,8 @@ | ||
| 1 | #include <termios.h> | ||
| 2 | #include <sys/ioctl.h> | ||
| 3 | #include "syscall.h" | ||
| 4 | |||
| 5 | int tcgetwinsize(int fd, struct winsize *wsz) | ||
| 6 | { | ||
| 7 | 	return syscall(SYS_ioctl, fd, TIOCGWINSZ, wsz); | ||
| 8 | } | ||
lib/libc/musl/src/termios/tcsetwinsize.c created+8| ... | @@ -0,0 +1,8 @@ | ||
| 1 | #include <termios.h> | ||
| 2 | #include <sys/ioctl.h> | ||
| 3 | #include "syscall.h" | ||
| 4 | |||
| 5 | int tcsetwinsize(int fd, const struct winsize *wsz) | ||
| 6 | { | ||
| 7 | 	return syscall(SYS_ioctl, fd, TIOCSWINSZ, wsz); | ||
| 8 | } | ||
lib/libc/musl/src/thread/i386/__set_thread_area.s+1| ... | @@ -28,6 +28,7 @@ __set_thread_area: | ... | @@ -28,6 +28,7 @@ __set_thread_area: |
| 28 | 	ret | 28 | 	ret |
| 29 | 2: | 29 | 2: |
| 30 | 	mov %ebx,%ecx | 30 | 	mov %ebx,%ecx |
| 31 | 	xor %eax,%eax | ||
| 31 | 	xor %ebx,%ebx | 32 | 	xor %ebx,%ebx |
| 32 | 	xor %edx,%edx | 33 | 	xor %edx,%edx |
| 33 | 	mov %ebx,(%esp) | 34 | 	mov %ebx,(%esp) |
lib/libc/musl/src/thread/pthread_attr_get.c+1-1| ... | @@ -70,7 +70,7 @@ int pthread_condattr_getpshared(const pthread_condattr_t *restrict a, int *restr | ... | @@ -70,7 +70,7 @@ int pthread_condattr_getpshared(const pthread_condattr_t *restrict a, int *restr |
| 70 | 70 | ||
| 71 | int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *restrict a, int *restrict protocol) | 71 | int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *restrict a, int *restrict protocol) |
| 72 | { | 72 | { |
| 73 | 	*protocol = PTHREAD_PRIO_NONE; | 73 | 	*protocol = a->__attr / 8U % 2; |
| 74 | 	return 0; | 74 | 	return 0; |
| 75 | } | 75 | } |
| 76 | int pthread_mutexattr_getpshared(const pthread_mutexattr_t *restrict a, int *restrict pshared) | 76 | int pthread_mutexattr_getpshared(const pthread_mutexattr_t *restrict a, int *restrict pshared) |
lib/libc/musl/src/thread/pthread_cond_timedwait.c+9-5| ... | @@ -146,14 +146,18 @@ relock: | ... | @@ -146,14 +146,18 @@ relock: |
| 146 | 146 | ||
| 147 | 	if (oldstate == WAITING) goto done; | 147 | 	if (oldstate == WAITING) goto done; |
| 148 | 148 | ||
| 149 | 	if (!node.next) a_inc(&m->_m_waiters); | 149 | 	if (!node.next && !(m->_m_type & 8)) |
| 150 | 		a_inc(&m->_m_waiters); | ||
| 150 | 151 | ||
| 151 | 	/* Unlock the barrier that's holding back the next waiter, and | 152 | 	/* Unlock the barrier that's holding back the next waiter, and |
| 152 | 	 * either wake it or requeue it to the mutex. */ | 153 | 	 * either wake it or requeue it to the mutex. */ |
| 153 | 	if (node.prev) | 154 | 	if (node.prev) { |
| 154 | 		unlock_requeue(&node.prev->barrier, &m->_m_lock, m->_m_type & 128); | 155 | 		int val = m->_m_lock; |
| 155 | 	else | 156 | 		if (val>0) a_cas(&m->_m_lock, val, val|0x80000000); |
| 156 | 		a_dec(&m->_m_waiters); | 157 | 		unlock_requeue(&node.prev->barrier, &m->_m_lock, m->_m_type & (8|128)); |
| 158 | 	} else if (!(m->_m_type & 8)) { | ||
| 159 | 		a_dec(&m->_m_waiters);		 | ||
| 160 | 	} | ||
| 157 | 161 | ||
| 158 | 	/* Since a signal was consumed, cancellation is not permitted. */ | 162 | 	/* Since a signal was consumed, cancellation is not permitted. */ |
| 159 | 	if (e == ECANCELED) e = 0; | 163 | 	if (e == ECANCELED) e = 0; |
lib/libc/musl/src/thread/pthread_create.c+17-10| ... | @@ -69,12 +69,25 @@ _Noreturn void __pthread_exit(void *result) | ... | @@ -69,12 +69,25 @@ _Noreturn void __pthread_exit(void *result) |
| 69 | 69 | ||
| 70 | 	__pthread_tsd_run_dtors(); | 70 | 	__pthread_tsd_run_dtors(); |
| 71 | 71 | ||
| 72 | 	__block_app_sigs(&set); | ||
| 73 | |||
| 74 | 	/* This atomic potentially competes with a concurrent pthread_detach | ||
| 75 | 	 * call; the loser is responsible for freeing thread resources. */ | ||
| 76 | 	int state = a_cas(&self->detach_state, DT_JOINABLE, DT_EXITING); | ||
| 77 | |||
| 78 | 	if (state==DT_DETACHED && self->map_base) { | ||
| 79 | 		/* Since __unmapself bypasses the normal munmap code path, | ||
| 80 | 		 * explicitly wait for vmlock holders first. This must be | ||
| 81 | 		 * done before any locks are taken, to avoid lock ordering | ||
| 82 | 		 * issues that could lead to deadlock. */ | ||
| 83 | 		__vm_wait(); | ||
| 84 | 	} | ||
| 85 | |||
| 72 | 	/* Access to target the exiting thread with syscalls that use | 86 | 	/* Access to target the exiting thread with syscalls that use |
| 73 | 	 * its kernel tid is controlled by killlock. For detached threads, | 87 | 	 * its kernel tid is controlled by killlock. For detached threads, |
| 74 | 	 * any use past this point would have undefined behavior, but for | 88 | 	 * any use past this point would have undefined behavior, but for |
| 75 | 	 * joinable threads it's a valid usage that must be handled. | 89 | 	 * joinable threads it's a valid usage that must be handled. |
| 76 | 	 * Signals must be blocked since pthread_kill must be AS-safe. */ | 90 | 	 * Signals must be blocked since pthread_kill must be AS-safe. */ |
| 77 | 	__block_app_sigs(&set); | ||
| 78 | 	LOCK(self->killlock); | 91 | 	LOCK(self->killlock); |
| 79 | 92 | ||
| 80 | 	/* The thread list lock must be AS-safe, and thus depends on | 93 | 	/* The thread list lock must be AS-safe, and thus depends on |
| ... | @@ -87,6 +100,7 @@ _Noreturn void __pthread_exit(void *result) | ... | @@ -87,6 +100,7 @@ _Noreturn void __pthread_exit(void *result) |
| 87 | 	if (self->next == self) { | 100 | 	if (self->next == self) { |
| 88 | 		__tl_unlock(); | 101 | 		__tl_unlock(); |
| 89 | 		UNLOCK(self->killlock); | 102 | 		UNLOCK(self->killlock); |
| 103 | 		self->detach_state = state; | ||
| 90 | 		__restore_sigs(&set); | 104 | 		__restore_sigs(&set); |
| 91 | 		exit(0); | 105 | 		exit(0); |
| 92 | 	} | 106 | 	} |
| ... | @@ -125,10 +139,6 @@ _Noreturn void __pthread_exit(void *result) | ... | @@ -125,10 +139,6 @@ _Noreturn void __pthread_exit(void *result) |
| 125 | 	self->prev->next = self->next; | 139 | 	self->prev->next = self->next; |
| 126 | 	self->prev = self->next = self; | 140 | 	self->prev = self->next = self; |
| 127 | 141 | ||
| 128 | 	/* This atomic potentially competes with a concurrent pthread_detach | ||
| 129 | 	 * call; the loser is responsible for freeing thread resources. */ | ||
| 130 | 	int state = a_cas(&self->detach_state, DT_JOINABLE, DT_EXITING); | ||
| 131 | |||
| 132 | 	if (state==DT_DETACHED && self->map_base) { | 142 | 	if (state==DT_DETACHED && self->map_base) { |
| 133 | 		/* Detached threads must block even implementation-internal | 143 | 		/* Detached threads must block even implementation-internal |
| 134 | 		 * signals, since they will not have a stack in their last | 144 | 		 * signals, since they will not have a stack in their last |
| ... | @@ -140,16 +150,13 @@ _Noreturn void __pthread_exit(void *result) | ... | @@ -140,16 +150,13 @@ _Noreturn void __pthread_exit(void *result) |
| 140 | 		if (self->robust_list.off) | 150 | 		if (self->robust_list.off) |
| 141 | 			__syscall(SYS_set_robust_list, 0, 3*sizeof(long)); | 151 | 			__syscall(SYS_set_robust_list, 0, 3*sizeof(long)); |
| 142 | 152 | ||
| 143 | 		/* Since __unmapself bypasses the normal munmap code path, | ||
| 144 | 		 * explicitly wait for vmlock holders first. */ | ||
| 145 | 		__vm_wait(); | ||
| 146 | |||
| 147 | 		/* The following call unmaps the thread's stack mapping | 153 | 		/* The following call unmaps the thread's stack mapping |
| 148 | 		 * and then exits without touching the stack. */ | 154 | 		 * and then exits without touching the stack. */ |
| 149 | 		__unmapself(self->map_base, self->map_size); | 155 | 		__unmapself(self->map_base, self->map_size); |
| 150 | 	} | 156 | 	} |
| 151 | 157 | ||
| 152 | 	/* Wake any joiner. */ | 158 | 	/* Wake any joiner. */ |
| 159 | 	a_store(&self->detach_state, DT_EXITED); | ||
| 153 | 	__wake(&self->detach_state, 1, 1); | 160 | 	__wake(&self->detach_state, 1, 1); |
| 154 | 161 | ||
| 155 | 	/* After the kernel thread exits, its tid may be reused. Clear it | 162 | 	/* After the kernel thread exits, its tid may be reused. Clear it |
| ... | @@ -314,7 +321,7 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att | ... | @@ -314,7 +321,7 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att |
| 314 | 		new->detach_state = DT_JOINABLE; | 321 | 		new->detach_state = DT_JOINABLE; |
| 315 | 	} | 322 | 	} |
| 316 | 	new->robust_list.head = &new->robust_list.head; | 323 | 	new->robust_list.head = &new->robust_list.head; |
| 317 | 	new->CANARY = self->CANARY; | 324 | 	new->canary = self->canary; |
| 318 | 	new->sysinfo = self->sysinfo; | 325 | 	new->sysinfo = self->sysinfo; |
| 319 | 326 | ||
| 320 | 	/* Setup argument structure for the new thread on its stack. | 327 | 	/* Setup argument structure for the new thread on its stack. |
lib/libc/musl/src/thread/pthread_mutex_destroy.c+5-1| ... | @@ -1,6 +1,10 @@ | ... | @@ -1,6 +1,10 @@ |
| 1 | #include <pthread.h> | 1 | #include "pthread_impl.h" |
| 2 | 2 | ||
| 3 | int pthread_mutex_destroy(pthread_mutex_t *mutex) | 3 | int pthread_mutex_destroy(pthread_mutex_t *mutex) |
| 4 | { | 4 | { |
| 5 | 	/* If the mutex being destroyed is process-shared and has nontrivial | ||
| 6 | 	 * type (tracking ownership), it might be in the pending slot of a | ||
| 7 | 	 * robust_list; wait for quiescence. */ | ||
| 8 | 	if (mutex->_m_type > 128) __vm_wait(); | ||
| 5 | 	return 0; | 9 | 	return 0; |
| 6 | } | 10 | } |
lib/libc/musl/src/thread/pthread_mutexattr_setprotocol.c+9-10| ... | @@ -1,24 +1,23 @@ | ... | @@ -1,24 +1,23 @@ |
| 1 | #include "pthread_impl.h" | 1 | #include "pthread_impl.h" |
| 2 | #include "syscall.h" | 2 | #include "syscall.h" |
| 3 | 3 | ||
| 4 | static pthread_once_t check_pi_once; | 4 | static volatile int check_pi_result = -1; |
| 5 | static int check_pi_result; | ||
| 6 | |||
| 7 | static void check_pi() | ||
| 8 | { | ||
| 9 | 	volatile int lk = 0; | ||
| 10 | 	check_pi_result = -__syscall(SYS_futex, &lk, FUTEX_LOCK_PI, 0, 0); | ||
| 11 | } | ||
| 12 | 5 | ||
| 13 | int pthread_mutexattr_setprotocol(pthread_mutexattr_t *a, int protocol) | 6 | int pthread_mutexattr_setprotocol(pthread_mutexattr_t *a, int protocol) |
| 14 | { | 7 | { |
| 8 | 	int r; | ||
| 15 | 	switch (protocol) { | 9 | 	switch (protocol) { |
| 16 | 	case PTHREAD_PRIO_NONE: | 10 | 	case PTHREAD_PRIO_NONE: |
| 17 | 		a->__attr &= ~8; | 11 | 		a->__attr &= ~8; |
| 18 | 		return 0; | 12 | 		return 0; |
| 19 | 	case PTHREAD_PRIO_INHERIT: | 13 | 	case PTHREAD_PRIO_INHERIT: |
| 20 | 		pthread_once(&check_pi_once, check_pi); | 14 | 		r = check_pi_result; |
| 21 | 		if (check_pi_result) return check_pi_result; | 15 | 		if (r < 0) { |
| 16 | 			volatile int lk = 0; | ||
| 17 | 			r = -__syscall(SYS_futex, &lk, FUTEX_LOCK_PI, 0, 0); | ||
| 18 | 			a_store(&check_pi_result, r); | ||
| 19 | 		} | ||
| 20 | 		if (r) return r; | ||
| 22 | 		a->__attr |= 8; | 21 | 		a->__attr |= 8; |
| 23 | 		return 0; | 22 | 		return 0; |
| 24 | 	case PTHREAD_PRIO_PROTECT: | 23 | 	case PTHREAD_PRIO_PROTECT: |
lib/libc/musl/src/thread/pthread_mutexattr_setrobust.c+9-11| ... | @@ -1,22 +1,20 @@ | ... | @@ -1,22 +1,20 @@ |
| 1 | #include "pthread_impl.h" | 1 | #include "pthread_impl.h" |
| 2 | #include "syscall.h" | 2 | #include "syscall.h" |
| 3 | 3 | ||
| 4 | static pthread_once_t check_robust_once; | 4 | static volatile int check_robust_result = -1; |
| 5 | static int check_robust_result; | ||
| 6 | |||
| 7 | static void check_robust() | ||
| 8 | { | ||
| 9 | 	void *p; | ||
| 10 | 	size_t l; | ||
| 11 | 	check_robust_result = -__syscall(SYS_get_robust_list, 0, &p, &l); | ||
| 12 | } | ||
| 13 | 5 | ||
| 14 | int pthread_mutexattr_setrobust(pthread_mutexattr_t *a, int robust) | 6 | int pthread_mutexattr_setrobust(pthread_mutexattr_t *a, int robust) |
| 15 | { | 7 | { |
| 16 | 	if (robust > 1U) return EINVAL; | 8 | 	if (robust > 1U) return EINVAL; |
| 17 | 	if (robust) { | 9 | 	if (robust) { |
| 18 | 		pthread_once(&check_robust_once, check_robust); | 10 | 		int r = check_robust_result; |
| 19 | 		if (check_robust_result) return check_robust_result; | 11 | 		if (r < 0) { |
| 12 | 			void *p; | ||
| 13 | 			size_t l; | ||
| 14 | 			r = -__syscall(SYS_get_robust_list, 0, &p, &l); | ||
| 15 | 			a_store(&check_robust_result, r); | ||
| 16 | 		} | ||
| 17 | 		if (r) return r; | ||
| 20 | 		a->__attr |= 4; | 18 | 		a->__attr |= 4; |
| 21 | 		return 0; | 19 | 		return 0; |
| 22 | 	} | 20 | 	} |
lib/libc/musl/src/thread/s390x/clone.s+6| ... | @@ -17,6 +17,9 @@ __clone: | ... | @@ -17,6 +17,9 @@ __clone: |
| 17 | 	# if (!tid) syscall(SYS_exit, a(d)); | 17 | 	# if (!tid) syscall(SYS_exit, a(d)); |
| 18 | 	# return tid; | 18 | 	# return tid; |
| 19 | 19 | ||
| 20 | 	# preserve call-saved register used as syscall arg | ||
| 21 | 	stg %r6, 48(%r15) | ||
| 22 | |||
| 20 | 	# create initial stack frame for new thread | 23 | 	# create initial stack frame for new thread |
| 21 | 	nill %r3, 0xfff8 | 24 | 	nill %r3, 0xfff8 |
| 22 | 	aghi %r3, -160 | 25 | 	aghi %r3, -160 |
| ... | @@ -35,6 +38,9 @@ __clone: | ... | @@ -35,6 +38,9 @@ __clone: |
| 35 | 	lg %r6, 160(%r15) | 38 | 	lg %r6, 160(%r15) |
| 36 | 	svc 120 | 39 | 	svc 120 |
| 37 | 40 | ||
| 41 | 	# restore call-saved register | ||
| 42 | 	lg %r6, 48(%r15) | ||
| 43 | |||
| 38 | 	# if error or if we're the parent, return | 44 | 	# if error or if we're the parent, return |
| 39 | 	ltgr %r2, %r2 | 45 | 	ltgr %r2, %r2 |
| 40 | 	bnzr %r14 | 46 | 	bnzr %r14 |
lib/libc/musl/src/thread/s390x/syscall_cp.s+2| ... | @@ -14,6 +14,7 @@ __cp_begin: | ... | @@ -14,6 +14,7 @@ __cp_begin: |
| 14 | 	icm %r2, 15, 0(%r2) | 14 | 	icm %r2, 15, 0(%r2) |
| 15 | 	jne __cp_cancel | 15 | 	jne __cp_cancel |
| 16 | 16 | ||
| 17 | 	stg %r6, 48(%r15) | ||
| 17 | 	stg %r7, 56(%r15) | 18 | 	stg %r7, 56(%r15) |
| 18 | 	lgr %r1, %r3 | 19 | 	lgr %r1, %r3 |
| 19 | 	lgr %r2, %r4 | 20 | 	lgr %r2, %r4 |
| ... | @@ -26,6 +27,7 @@ __cp_begin: | ... | @@ -26,6 +27,7 @@ __cp_begin: |
| 26 | 27 | ||
| 27 | __cp_end: | 28 | __cp_end: |
| 28 | 	lg %r7, 56(%r15) | 29 | 	lg %r7, 56(%r15) |
| 30 | 	lg %r6, 48(%r15) | ||
| 29 | 	br %r14 | 31 | 	br %r14 |
| 30 | 32 | ||
| 31 | __cp_cancel: | 33 | __cp_cancel: |
lib/libc/musl/src/thread/sem_open.c+12-3| ... | @@ -12,6 +12,12 @@ | ... | @@ -12,6 +12,12 @@ |
| 12 | #include <stdlib.h> | 12 | #include <stdlib.h> |
| 13 | #include <pthread.h> | 13 | #include <pthread.h> |
| 14 | #include "lock.h" | 14 | #include "lock.h" |
| 15 | #include "fork_impl.h" | ||
| 16 | |||
| 17 | #define malloc __libc_malloc | ||
| 18 | #define calloc __libc_calloc | ||
| 19 | #define realloc undef | ||
| 20 | #define free undef | ||
| 15 | 21 | ||
| 16 | static struct { | 22 | static struct { |
| 17 | 	ino_t ino; | 23 | 	ino_t ino; |
| ... | @@ -19,6 +25,7 @@ static struct { | ... | @@ -19,6 +25,7 @@ static struct { |
| 19 | 	int refcnt; | 25 | 	int refcnt; |
| 20 | } *semtab; | 26 | } *semtab; |
| 21 | static volatile int lock[1]; | 27 | static volatile int lock[1]; |
| 28 | volatile int *const __sem_open_lockptr = lock; | ||
| 22 | 29 | ||
| 23 | #define FLAGS (O_RDWR|O_NOFOLLOW|O_CLOEXEC|O_NONBLOCK) | 30 | #define FLAGS (O_RDWR|O_NOFOLLOW|O_CLOEXEC|O_NONBLOCK) |
| 24 | 31 | ||
| ... | @@ -163,10 +170,12 @@ int sem_close(sem_t *sem) | ... | @@ -163,10 +170,12 @@ int sem_close(sem_t *sem) |
| 163 | 	int i; | 170 | 	int i; |
| 164 | 	LOCK(lock); | 171 | 	LOCK(lock); |
| 165 | 	for (i=0; i<SEM_NSEMS_MAX && semtab[i].sem != sem; i++); | 172 | 	for (i=0; i<SEM_NSEMS_MAX && semtab[i].sem != sem; i++); |
| 166 | 	if (!--semtab[i].refcnt) { | 173 | 	if (--semtab[i].refcnt) { |
| 167 | 		semtab[i].sem = 0; | 174 | 		UNLOCK(lock); |
| 168 | 		semtab[i].ino = 0; | 175 | 		return 0; |
| 169 | 	} | 176 | 	} |
| 177 | 	semtab[i].sem = 0; | ||
| 178 | 	semtab[i].ino = 0; | ||
| 170 | 	UNLOCK(lock); | 179 | 	UNLOCK(lock); |
| 171 | 	munmap(sem, sizeof *sem); | 180 | 	munmap(sem, sizeof *sem); |
| 172 | 	return 0; | 181 | 	return 0; |
lib/libc/musl/src/thread/synccall.c+2-1| ... | @@ -63,7 +63,8 @@ void __synccall(void (*func)(void *), void *ctx) | ... | @@ -63,7 +63,8 @@ void __synccall(void (*func)(void *), void *ctx) |
| 63 | 	sem_init(&target_sem, 0, 0); | 63 | 	sem_init(&target_sem, 0, 0); |
| 64 | 	sem_init(&caller_sem, 0, 0); | 64 | 	sem_init(&caller_sem, 0, 0); |
| 65 | 65 | ||
| 66 | 	if (!libc.threads_minus_1) goto single_threaded; | 66 | 	if (!libc.threads_minus_1 || __syscall(SYS_gettid) != self->tid) |
| 67 | 		goto single_threaded; | ||
| 67 | 68 | ||
| 68 | 	callback = func; | 69 | 	callback = func; |
| 69 | 	context = ctx; | 70 | 	context = ctx; |
lib/libc/musl/src/thread/vmlock.c+2| ... | @@ -1,6 +1,8 @@ | ... | @@ -1,6 +1,8 @@ |
| 1 | #include "pthread_impl.h" | 1 | #include "pthread_impl.h" |
| 2 | #include "fork_impl.h" | ||
| 2 | 3 | ||
| 3 | static volatile int vmlock[2]; | 4 | static volatile int vmlock[2]; |
| 5 | volatile int *const __vmlock_lockptr = vmlock; | ||
| 4 | 6 | ||
| 5 | void __vm_wait() | 7 | void __vm_wait() |
| 6 | { | 8 | { |
lib/libc/musl/src/time/__tz.c+8-1| ... | @@ -6,6 +6,12 @@ | ... | @@ -6,6 +6,12 @@ |
| 6 | #include <sys/mman.h> | 6 | #include <sys/mman.h> |
| 7 | #include "libc.h" | 7 | #include "libc.h" |
| 8 | #include "lock.h" | 8 | #include "lock.h" |
| 9 | #include "fork_impl.h" | ||
| 10 | |||
| 11 | #define malloc __libc_malloc | ||
| 12 | #define calloc undef | ||
| 13 | #define realloc undef | ||
| 14 | #define free undef | ||
| 9 | 15 | ||
| 10 | long __timezone = 0; | 16 | long __timezone = 0; |
| 11 | int __daylight = 0; | 17 | int __daylight = 0; |
| ... | @@ -30,6 +36,7 @@ static char *old_tz = old_tz_buf; | ... | @@ -30,6 +36,7 @@ static char *old_tz = old_tz_buf; |
| 30 | static size_t old_tz_size = sizeof old_tz_buf; | 36 | static size_t old_tz_size = sizeof old_tz_buf; |
| 31 | 37 | ||
| 32 | static volatile int lock[1]; | 38 | static volatile int lock[1]; |
| 39 | volatile int *const __timezone_lockptr = lock; | ||
| 33 | 40 | ||
| 34 | static int getint(const char **p) | 41 | static int getint(const char **p) |
| 35 | { | 42 | { |
| ... | @@ -178,7 +185,7 @@ static void do_tzset() | ... | @@ -178,7 +185,7 @@ static void do_tzset() |
| 178 | 	zi = map; | 185 | 	zi = map; |
| 179 | 	if (map) { | 186 | 	if (map) { |
| 180 | 		int scale = 2; | 187 | 		int scale = 2; |
| 181 | 		if (sizeof(time_t) > 4 && map[4]=='2') { | 188 | 		if (map[4]!='1') { |
| 182 | 			size_t skip = zi_dotprod(zi+20, VEC(1,1,8,5,6,1), 6); | 189 | 			size_t skip = zi_dotprod(zi+20, VEC(1,1,8,5,6,1), 6); |
| 183 | 			trans = zi+skip+44+44; | 190 | 			trans = zi+skip+44+44; |
| 184 | 			scale++; | 191 | 			scale++; |
lib/libc/musl/src/time/timer_create.c+13-17| ... | @@ -2,6 +2,7 @@ | ... | @@ -2,6 +2,7 @@ |
| 2 | #include <setjmp.h> | 2 | #include <setjmp.h> |
| 3 | #include <limits.h> | 3 | #include <limits.h> |
| 4 | #include "pthread_impl.h" | 4 | #include "pthread_impl.h" |
| 5 | #include "atomic.h" | ||
| 5 | 6 | ||
| 6 | struct ksigevent { | 7 | struct ksigevent { |
| 7 | 	union sigval sigev_value; | 8 | 	union sigval sigev_value; |
| ... | @@ -32,19 +33,6 @@ static void cleanup_fromsig(void *p) | ... | @@ -32,19 +33,6 @@ static void cleanup_fromsig(void *p) |
| 32 | 	longjmp(p, 1); | 33 | 	longjmp(p, 1); |
| 33 | } | 34 | } |
| 34 | 35 | ||
| 35 | static void timer_handler(int sig, siginfo_t *si, void *ctx) | ||
| 36 | { | ||
| 37 | } | ||
| 38 | |||
| 39 | static void install_handler() | ||
| 40 | { | ||
| 41 | 	struct sigaction sa = { | ||
| 42 | 		.sa_sigaction = timer_handler, | ||
| 43 | 		.sa_flags = SA_SIGINFO | SA_RESTART | ||
| 44 | 	}; | ||
| 45 | 	__libc_sigaction(SIGTIMER, &sa, 0); | ||
| 46 | } | ||
| 47 | |||
| 48 | static void *start(void *arg) | 36 | static void *start(void *arg) |
| 49 | { | 37 | { |
| 50 | 	pthread_t self = __pthread_self(); | 38 | 	pthread_t self = __pthread_self(); |
| ... | @@ -71,7 +59,7 @@ static void *start(void *arg) | ... | @@ -71,7 +59,7 @@ static void *start(void *arg) |
| 71 | 59 | ||
| 72 | int timer_create(clockid_t clk, struct sigevent *restrict evp, timer_t *restrict res) | 60 | int timer_create(clockid_t clk, struct sigevent *restrict evp, timer_t *restrict res) |
| 73 | { | 61 | { |
| 74 | 	static pthread_once_t once = PTHREAD_ONCE_INIT; | 62 | 	volatile static int init = 0; |
| 75 | 	pthread_t td; | 63 | 	pthread_t td; |
| 76 | 	pthread_attr_t attr; | 64 | 	pthread_attr_t attr; |
| 77 | 	int r; | 65 | 	int r; |
| ... | @@ -83,11 +71,15 @@ int timer_create(clockid_t clk, struct sigevent *restrict evp, timer_t *restrict | ... | @@ -83,11 +71,15 @@ int timer_create(clockid_t clk, struct sigevent *restrict evp, timer_t *restrict |
| 83 | 	switch (evp ? evp->sigev_notify : SIGEV_SIGNAL) { | 71 | 	switch (evp ? evp->sigev_notify : SIGEV_SIGNAL) { |
| 84 | 	case SIGEV_NONE: | 72 | 	case SIGEV_NONE: |
| 85 | 	case SIGEV_SIGNAL: | 73 | 	case SIGEV_SIGNAL: |
| 74 | 	case SIGEV_THREAD_ID: | ||
| 86 | 		if (evp) { | 75 | 		if (evp) { |
| 87 | 			ksev.sigev_value = evp->sigev_value; | 76 | 			ksev.sigev_value = evp->sigev_value; |
| 88 | 			ksev.sigev_signo = evp->sigev_signo; | 77 | 			ksev.sigev_signo = evp->sigev_signo; |
| 89 | 			ksev.sigev_notify = evp->sigev_notify; | 78 | 			ksev.sigev_notify = evp->sigev_notify; |
| 90 | 			ksev.sigev_tid = 0; | 79 | 			if (evp->sigev_notify == SIGEV_THREAD_ID) |
| 80 | 				ksev.sigev_tid = evp->sigev_notify_thread_id; | ||
| 81 | 			else | ||
| 82 | 				ksev.sigev_tid = 0; | ||
| 91 | 			ksevp = &ksev; | 83 | 			ksevp = &ksev; |
| 92 | 		} | 84 | 		} |
| 93 | 		if (syscall(SYS_timer_create, clk, ksevp, &timerid) < 0) | 85 | 		if (syscall(SYS_timer_create, clk, ksevp, &timerid) < 0) |
| ... | @@ -95,7 +87,11 @@ int timer_create(clockid_t clk, struct sigevent *restrict evp, timer_t *restrict | ... | @@ -95,7 +87,11 @@ int timer_create(clockid_t clk, struct sigevent *restrict evp, timer_t *restrict |
| 95 | 		*res = (void *)(intptr_t)timerid; | 87 | 		*res = (void *)(intptr_t)timerid; |
| 96 | 		break; | 88 | 		break; |
| 97 | 	case SIGEV_THREAD: | 89 | 	case SIGEV_THREAD: |
| 98 | 		pthread_once(&once, install_handler); | 90 | 		if (!init) { |
| 91 | 			struct sigaction sa = { .sa_handler = SIG_DFL }; | ||
| 92 | 			__libc_sigaction(SIGTIMER, &sa, 0); | ||
| 93 | 			a_store(&init, 1); | ||
| 94 | 		} | ||
| 99 | 		if (evp->sigev_notify_attributes) | 95 | 		if (evp->sigev_notify_attributes) |
| 100 | 			attr = *evp->sigev_notify_attributes; | 96 | 			attr = *evp->sigev_notify_attributes; |
| 101 | 		else | 97 | 		else |
| ... | @@ -115,7 +111,7 @@ int timer_create(clockid_t clk, struct sigevent *restrict evp, timer_t *restrict | ... | @@ -115,7 +111,7 @@ int timer_create(clockid_t clk, struct sigevent *restrict evp, timer_t *restrict |
| 115 | 111 | ||
| 116 | 		ksev.sigev_value.sival_ptr = 0; | 112 | 		ksev.sigev_value.sival_ptr = 0; |
| 117 | 		ksev.sigev_signo = SIGTIMER; | 113 | 		ksev.sigev_signo = SIGTIMER; |
| 118 | 		ksev.sigev_notify = 4; /* SIGEV_THREAD_ID */ | 114 | 		ksev.sigev_notify = SIGEV_THREAD_ID; |
| 119 | 		ksev.sigev_tid = td->tid; | 115 | 		ksev.sigev_tid = td->tid; |
| 120 | 		if (syscall(SYS_timer_create, clk, &ksev, &timerid) < 0) | 116 | 		if (syscall(SYS_timer_create, clk, &ksev, &timerid) < 0) |
| 121 | 			timerid = -1; | 117 | 			timerid = -1; |
lib/libc/musl/src/unistd/close.c+1| ... | @@ -1,5 +1,6 @@ | ... | @@ -1,5 +1,6 @@ |
| 1 | #include <unistd.h> | 1 | #include <unistd.h> |
| 2 | #include <errno.h> | 2 | #include <errno.h> |
| 3 | #include "aio_impl.h" | ||
| 3 | #include "syscall.h" | 4 | #include "syscall.h" |
| 4 | 5 | ||
| 5 | static int dummy(int fd) | 6 | static int dummy(int fd) |
lib/libc/musl/src/unistd/faccessat.c+8-3| ... | @@ -25,12 +25,17 @@ static int checker(void *p) | ... | @@ -25,12 +25,17 @@ static int checker(void *p) |
| 25 | 25 | ||
| 26 | int faccessat(int fd, const char *filename, int amode, int flag) | 26 | int faccessat(int fd, const char *filename, int amode, int flag) |
| 27 | { | 27 | { |
| 28 | 	if (!flag || (flag==AT_EACCESS && getuid()==geteuid() && getgid()==getegid())) | 28 | 	if (flag) { |
| 29 | 		return syscall(SYS_faccessat, fd, filename, amode, flag); | 29 | 		int ret = __syscall(SYS_faccessat2, fd, filename, amode, flag); |
| 30 | 		if (ret != -ENOSYS) return __syscall_ret(ret); | ||
| 31 | 	} | ||
| 30 | 32 | ||
| 31 | 	if (flag != AT_EACCESS) | 33 | 	if (flag & ~AT_EACCESS) |
| 32 | 		return __syscall_ret(-EINVAL); | 34 | 		return __syscall_ret(-EINVAL); |
| 33 | 35 | ||
| 36 | 	if (!flag || (getuid()==geteuid() && getgid()==getegid())) | ||
| 37 | 		return syscall(SYS_faccessat, fd, filename, amode); | ||
| 38 | |||
| 34 | 	char stack[1024]; | 39 | 	char stack[1024]; |
| 35 | 	sigset_t set; | 40 | 	sigset_t set; |
| 36 | 	pid_t pid; | 41 | 	pid_t pid; |
lib/libc/musl/src/unistd/readlink.c+9-2| ... | @@ -4,9 +4,16 @@ | ... | @@ -4,9 +4,16 @@ |
| 4 | 4 | ||
| 5 | ssize_t readlink(const char *restrict path, char *restrict buf, size_t bufsize) | 5 | ssize_t readlink(const char *restrict path, char *restrict buf, size_t bufsize) |
| 6 | { | 6 | { |
| 7 | 	char dummy[1]; | ||
| 8 | 	if (!bufsize) { | ||
| 9 | 		buf = dummy; | ||
| 10 | 		bufsize = 1; | ||
| 11 | 	} | ||
| 7 | #ifdef SYS_readlink | 12 | #ifdef SYS_readlink |
| 8 | 	return syscall(SYS_readlink, path, buf, bufsize); | 13 | 	int r = __syscall(SYS_readlink, path, buf, bufsize); |
| 9 | #else | 14 | #else |
| 10 | 	return syscall(SYS_readlinkat, AT_FDCWD, path, buf, bufsize); | 15 | 	int r = __syscall(SYS_readlinkat, AT_FDCWD, path, buf, bufsize); |
| 11 | #endif | 16 | #endif |
| 17 | 	if (buf == dummy && r > 0) r = 0; | ||
| 18 | 	return __syscall_ret(r); | ||
| 12 | } | 19 | } |
lib/libc/musl/src/unistd/readlinkat.c+8-1| ... | @@ -3,5 +3,12 @@ | ... | @@ -3,5 +3,12 @@ |
| 3 | 3 | ||
| 4 | ssize_t readlinkat(int fd, const char *restrict path, char *restrict buf, size_t bufsize) | 4 | ssize_t readlinkat(int fd, const char *restrict path, char *restrict buf, size_t bufsize) |
| 5 | { | 5 | { |
| 6 | 	return syscall(SYS_readlinkat, fd, path, buf, bufsize); | 6 | 	char dummy[1]; |
| 7 | 	if (!bufsize) { | ||
| 8 | 		buf = dummy; | ||
| 9 | 		bufsize = 1; | ||
| 10 | 	} | ||
| 11 | 	int r = __syscall(SYS_readlinkat, fd, path, buf, bufsize); | ||
| 12 | 	if (buf == dummy && r > 0) r = 0; | ||
| 13 | 	return __syscall_ret(r); | ||
| 7 | } | 14 | } |
lib/libc/musl/src/unistd/setxid.c+9-14| ... | @@ -1,20 +1,19 @@ | ... | @@ -1,20 +1,19 @@ |
| 1 | #include <unistd.h> | 1 | #include <unistd.h> |
| 2 | #include <errno.h> | 2 | #include <signal.h> |
| 3 | #include "syscall.h" | 3 | #include "syscall.h" |
| 4 | #include "libc.h" | 4 | #include "libc.h" |
| 5 | #include "pthread_impl.h" | ||
| 6 | 5 | ||
| 7 | struct ctx { | 6 | struct ctx { |
| 8 | 	int id, eid, sid; | 7 | 	int id, eid, sid; |
| 9 | 	int nr, err; | 8 | 	int nr, ret; |
| 10 | }; | 9 | }; |
| 11 | 10 | ||
| 12 | static void do_setxid(void *p) | 11 | static void do_setxid(void *p) |
| 13 | { | 12 | { |
| 14 | 	struct ctx *c = p; | 13 | 	struct ctx *c = p; |
| 15 | 	if (c->err>0) return; | 14 | 	if (c->ret<0) return; |
| 16 | 	int ret = -__syscall(c->nr, c->id, c->eid, c->sid); | 15 | 	int ret = __syscall(c->nr, c->id, c->eid, c->sid); |
| 17 | 	if (ret && !c->err) { | 16 | 	if (ret && !c->ret) { |
| 18 | 		/* If one thread fails to set ids after another has already | 17 | 		/* If one thread fails to set ids after another has already |
| 19 | 		 * succeeded, forcibly killing the process is the only safe | 18 | 		 * succeeded, forcibly killing the process is the only safe |
| 20 | 		 * thing to do. State is inconsistent and dangerous. Use | 19 | 		 * thing to do. State is inconsistent and dangerous. Use |
| ... | @@ -22,18 +21,14 @@ static void do_setxid(void *p) | ... | @@ -22,18 +21,14 @@ static void do_setxid(void *p) |
| 22 | 		__block_all_sigs(0); | 21 | 		__block_all_sigs(0); |
| 23 | 		__syscall(SYS_kill, __syscall(SYS_getpid), SIGKILL); | 22 | 		__syscall(SYS_kill, __syscall(SYS_getpid), SIGKILL); |
| 24 | 	} | 23 | 	} |
| 25 | 	c->err = ret; | 24 | 	c->ret = ret; |
| 26 | } | 25 | } |
| 27 | 26 | ||
| 28 | int __setxid(int nr, int id, int eid, int sid) | 27 | int __setxid(int nr, int id, int eid, int sid) |
| 29 | { | 28 | { |
| 30 | 	/* err is initially nonzero so that failure of the first thread does not | 29 | 	/* ret is initially nonzero so that failure of the first thread does not |
| 31 | 	 * trigger the safety kill above. */ | 30 | 	 * trigger the safety kill above. */ |
| 32 | 	struct ctx c = { .nr = nr, .id = id, .eid = eid, .sid = sid, .err = -1 }; | 31 | 	struct ctx c = { .nr = nr, .id = id, .eid = eid, .sid = sid, .ret = 1 }; |
| 33 | 	__synccall(do_setxid, &c); | 32 | 	__synccall(do_setxid, &c); |
| 34 | 	if (c.err) { | 33 | 	return __syscall_ret(c.ret); |
| 35 | 		if (c.err>0) errno = c.err; | ||
| 36 | 		return -1; | ||
| 37 | 	} | ||
| 38 | 	return 0; | ||
| 39 | } | 34 | } |
src/musl.zig+14| ... | @@ -522,6 +522,7 @@ const src_files = [_][]const u8{ | ... | @@ -522,6 +522,7 @@ const src_files = [_][]const u8{ |
| 522 | "musl/src/errno/strerror.c", | 522 | "musl/src/errno/strerror.c", |
| 523 | "musl/src/exit/_Exit.c", | 523 | "musl/src/exit/_Exit.c", |
| 524 | "musl/src/exit/abort.c", | 524 | "musl/src/exit/abort.c", |
| 525 | "musl/src/exit/abort_lock.c", | ||
| 525 | "musl/src/exit/arm/__aeabi_atexit.c", | 526 | "musl/src/exit/arm/__aeabi_atexit.c", |
| 526 | "musl/src/exit/assert.c", | 527 | "musl/src/exit/assert.c", |
| 527 | "musl/src/exit/at_quick_exit.c", | 528 | "musl/src/exit/at_quick_exit.c", |
| ... | @@ -658,6 +659,7 @@ const src_files = [_][]const u8{ | ... | @@ -658,6 +659,7 @@ const src_files = [_][]const u8{ |
| 658 | "musl/src/linux/flock.c", | 659 | "musl/src/linux/flock.c", |
| 659 | "musl/src/linux/getdents.c", | 660 | "musl/src/linux/getdents.c", |
| 660 | "musl/src/linux/getrandom.c", | 661 | "musl/src/linux/getrandom.c", |
| 662 | "musl/src/linux/gettid.c", | ||
| 661 | "musl/src/linux/inotify.c", | 663 | "musl/src/linux/inotify.c", |
| 662 | "musl/src/linux/ioperm.c", | 664 | "musl/src/linux/ioperm.c", |
| 663 | "musl/src/linux/iopl.c", | 665 | "musl/src/linux/iopl.c", |
| ... | @@ -731,6 +733,8 @@ const src_files = [_][]const u8{ | ... | @@ -731,6 +733,8 @@ const src_files = [_][]const u8{ |
| 731 | "musl/src/locale/wcscoll.c", | 733 | "musl/src/locale/wcscoll.c", |
| 732 | "musl/src/locale/wcsxfrm.c", | 734 | "musl/src/locale/wcsxfrm.c", |
| 733 | "musl/src/malloc/calloc.c", | 735 | "musl/src/malloc/calloc.c", |
| 736 | "musl/src/malloc/free.c", | ||
| 737 | "musl/src/malloc/libc_calloc.c", | ||
| 734 | "musl/src/malloc/lite_malloc.c", | 738 | "musl/src/malloc/lite_malloc.c", |
| 735 | "musl/src/malloc/mallocng/aligned_alloc.c", | 739 | "musl/src/malloc/mallocng/aligned_alloc.c", |
| 736 | "musl/src/malloc/mallocng/donate.c", | 740 | "musl/src/malloc/mallocng/donate.c", |
| ... | @@ -739,7 +743,12 @@ const src_files = [_][]const u8{ | ... | @@ -739,7 +743,12 @@ const src_files = [_][]const u8{ |
| 739 | "musl/src/malloc/mallocng/malloc_usable_size.c", | 743 | "musl/src/malloc/mallocng/malloc_usable_size.c", |
| 740 | "musl/src/malloc/mallocng/realloc.c", | 744 | "musl/src/malloc/mallocng/realloc.c", |
| 741 | "musl/src/malloc/memalign.c", | 745 | "musl/src/malloc/memalign.c", |
| 746 | "musl/src/malloc/oldmalloc/aligned_alloc.c", | ||
| 747 | "musl/src/malloc/oldmalloc/malloc.c", | ||
| 748 | "musl/src/malloc/oldmalloc/malloc_usable_size.c", | ||
| 742 | "musl/src/malloc/posix_memalign.c", | 749 | "musl/src/malloc/posix_memalign.c", |
| 750 | "musl/src/malloc/realloc.c", | ||
| 751 | "musl/src/malloc/reallocarray.c", | ||
| 743 | "musl/src/malloc/replaced.c", | 752 | "musl/src/malloc/replaced.c", |
| 744 | "musl/src/math/__cos.c", | 753 | "musl/src/math/__cos.c", |
| 745 | "musl/src/math/__cosdf.c", | 754 | "musl/src/math/__cosdf.c", |
| ... | @@ -754,6 +763,7 @@ const src_files = [_][]const u8{ | ... | @@ -754,6 +763,7 @@ const src_files = [_][]const u8{ |
| 754 | "musl/src/math/__math_divzerof.c", | 763 | "musl/src/math/__math_divzerof.c", |
| 755 | "musl/src/math/__math_invalid.c", | 764 | "musl/src/math/__math_invalid.c", |
| 756 | "musl/src/math/__math_invalidf.c", | 765 | "musl/src/math/__math_invalidf.c", |
| 766 | "musl/src/math/__math_invalidl.c", | ||
| 757 | "musl/src/math/__math_oflow.c", | 767 | "musl/src/math/__math_oflow.c", |
| 758 | "musl/src/math/__math_oflowf.c", | 768 | "musl/src/math/__math_oflowf.c", |
| 759 | "musl/src/math/__math_uflow.c", | 769 | "musl/src/math/__math_uflow.c", |
| ... | @@ -1137,6 +1147,7 @@ const src_files = [_][]const u8{ | ... | @@ -1137,6 +1147,7 @@ const src_files = [_][]const u8{ |
| 1137 | "musl/src/math/sinhl.c", | 1147 | "musl/src/math/sinhl.c", |
| 1138 | "musl/src/math/sinl.c", | 1148 | "musl/src/math/sinl.c", |
| 1139 | "musl/src/math/sqrt.c", | 1149 | "musl/src/math/sqrt.c", |
| 1150 | "musl/src/math/sqrt_data.c", | ||
| 1140 | "musl/src/math/sqrtf.c", | 1151 | "musl/src/math/sqrtf.c", |
| 1141 | "musl/src/math/sqrtl.c", | 1152 | "musl/src/math/sqrtl.c", |
| 1142 | "musl/src/math/tan.c", | 1153 | "musl/src/math/tan.c", |
| ... | @@ -1406,6 +1417,7 @@ const src_files = [_][]const u8{ | ... | @@ -1406,6 +1417,7 @@ const src_files = [_][]const u8{ |
| 1406 | "musl/src/prng/random.c", | 1417 | "musl/src/prng/random.c", |
| 1407 | "musl/src/prng/seed48.c", | 1418 | "musl/src/prng/seed48.c", |
| 1408 | "musl/src/prng/srand48.c", | 1419 | "musl/src/prng/srand48.c", |
| 1420 | "musl/src/process/_Fork.c", | ||
| 1409 | "musl/src/process/arm/vfork.s", | 1421 | "musl/src/process/arm/vfork.s", |
| 1410 | "musl/src/process/execl.c", | 1422 | "musl/src/process/execl.c", |
| 1411 | "musl/src/process/execle.c", | 1423 | "musl/src/process/execle.c", |
| ... | @@ -1833,8 +1845,10 @@ const src_files = [_][]const u8{ | ... | @@ -1833,8 +1845,10 @@ const src_files = [_][]const u8{ |
| 1833 | "musl/src/termios/tcflush.c", | 1845 | "musl/src/termios/tcflush.c", |
| 1834 | "musl/src/termios/tcgetattr.c", | 1846 | "musl/src/termios/tcgetattr.c", |
| 1835 | "musl/src/termios/tcgetsid.c", | 1847 | "musl/src/termios/tcgetsid.c", |
| 1848 | "musl/src/termios/tcgetwinsize.c", | ||
| 1836 | "musl/src/termios/tcsendbreak.c", | 1849 | "musl/src/termios/tcsendbreak.c", |
| 1837 | "musl/src/termios/tcsetattr.c", | 1850 | "musl/src/termios/tcsetattr.c", |
| 1851 | "musl/src/termios/tcsetwinsize.c", | ||
| 1838 | "musl/src/thread/__lock.c", | 1852 | "musl/src/thread/__lock.c", |
| 1839 | "musl/src/thread/__set_thread_area.c", | 1853 | "musl/src/thread/__set_thread_area.c", |
| 1840 | "musl/src/thread/__syscall_cp.c", | 1854 | "musl/src/thread/__syscall_cp.c", |