authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-07-16 19:54:14-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-07-16 19:54:14-04:00
logd99437917363d0b550af5e20360bd07bc98367ba
tree171a819106b059d667961fc883efb98dc4384bf1
parentf70ce707e2d35a5ed8349d03b6aa8d493792e180
signaturelock-open Commit is signed but in an unrecognized format.

update bundled musl source to 1.1.23


486 files changed, 21915 insertions(+), 3219 deletions(-)

lib/libc/musl/arch/aarch64/bits/hwcap.h+4
......@@ -26,3 +26,7 @@
2626#define HWCAP_USCAT (1 << 25)
2727#define HWCAP_ILRCPC (1 << 26)
2828#define HWCAP_FLAGM (1 << 27)
29#define HWCAP_SSBS (1 << 28)
30#define HWCAP_SB (1 << 29)
31#define HWCAP_PACA (1 << 30)
32#define HWCAP_PACG (1UL << 31)
lib/libc/musl/arch/aarch64/bits/syscall.h.in+6
......@@ -275,4 +275,10 @@
275275#define __NR_pkey_free 290
276276#define __NR_statx 291
277277#define __NR_io_pgetevents 292
278#define __NR_rseq 293
279#define __NR_kexec_file_load 294
280#define __NR_pidfd_send_signal 424
281#define __NR_io_uring_setup 425
282#define __NR_io_uring_enter 426
283#define __NR_io_uring_register 427
278284
lib/libc/musl/arch/aarch64/fp_arch.h created+25
......@@ -0,0 +1,25 @@
1#define fp_barrierf fp_barrierf
2static inline float fp_barrierf(float x)
3{
4 __asm__ __volatile__ ("" : "+w"(x));
5 return x;
6}
7
8#define fp_barrier fp_barrier
9static inline double fp_barrier(double x)
10{
11 __asm__ __volatile__ ("" : "+w"(x));
12 return x;
13}
14
15#define fp_force_evalf fp_force_evalf
16static inline void fp_force_evalf(float x)
17{
18 __asm__ __volatile__ ("" : "+w"(x));
19}
20
21#define fp_force_eval fp_force_eval
22static inline void fp_force_eval(double x)
23{
24 __asm__ __volatile__ ("" : "+w"(x));
25}
lib/libc/musl/arch/arm/atomic_arch.h+1-1
......@@ -83,7 +83,7 @@ static inline void a_crash()
8383 : : : "memory");
8484}
8585
86#if __ARM_ARCH >= 5
86#if __ARM_ARCH >= 5 && (!__thumb__ || __thumb2__)
8787
8888#define a_clz_32 a_clz_32
8989static inline int a_clz_32(uint32_t x)
lib/libc/musl/arch/arm/bits/syscall.h.in+27
......@@ -354,6 +354,33 @@
354354#define __NR_pkey_free 396
355355#define __NR_statx 397
356356#define __NR_rseq 398
357#define __NR_io_pgetevents 399
358#define __NR_migrate_pages 400
359#define __NR_kexec_file_load 401
360#define __NR_clock_gettime64 403
361#define __NR_clock_settime64 404
362#define __NR_clock_adjtime64 405
363#define __NR_clock_getres_time64 406
364#define __NR_clock_nanosleep_time64 407
365#define __NR_timer_gettime64 408
366#define __NR_timer_settime64 409
367#define __NR_timerfd_gettime64 410
368#define __NR_timerfd_settime64 411
369#define __NR_utimensat_time64 412
370#define __NR_pselect6_time64 413
371#define __NR_ppoll_time64 414
372#define __NR_io_pgetevents_time64 416
373#define __NR_recvmmsg_time64 417
374#define __NR_mq_timedsend_time64 418
375#define __NR_mq_timedreceive_time64 419
376#define __NR_semtimedop_time64 420
377#define __NR_rt_sigtimedwait_time64 421
378#define __NR_futex_time64 422
379#define __NR_sched_rr_get_interval_time64 423
380#define __NR_pidfd_send_signal 424
381#define __NR_io_uring_setup 425
382#define __NR_io_uring_enter 426
383#define __NR_io_uring_register 427
357384
358385#define __ARM_NR_breakpoint 0x0f0001
359386#define __ARM_NR_cacheflush 0x0f0002
lib/libc/musl/arch/generic/bits/ioctl.h+2-98
......@@ -64,6 +64,8 @@
6464#define TIOCGPTLCK 0x80045439
6565#define TIOCGEXCL 0x80045440
6666#define TIOCGPTPEER 0x5441
67#define TIOCGISO7816 0x80285442
68#define TIOCSISO7816 0xc0285443
6769
6870#define FIONCLEX 0x5450
6971#define FIOCLEX 0x5451
......@@ -82,24 +84,6 @@
8284#define TIOCGICOUNT 0x545D
8385#define FIOQSIZE 0x5460
8486
85#define TIOCPKT_DATA 0
86#define TIOCPKT_FLUSHREAD 1
87#define TIOCPKT_FLUSHWRITE 2
88#define TIOCPKT_STOP 4
89#define TIOCPKT_START 8
90#define TIOCPKT_NOSTOP 16
91#define TIOCPKT_DOSTOP 32
92#define TIOCPKT_IOCTL 64
93
94#define TIOCSER_TEMT 0x01
95
96struct winsize {
97 unsigned short ws_row;
98 unsigned short ws_col;
99 unsigned short ws_xpixel;
100 unsigned short ws_ypixel;
101};
102
10387#define TIOCM_LE 0x001
10488#define TIOCM_DTR 0x002
10589#define TIOCM_RTS 0x004
......@@ -115,23 +99,6 @@ struct winsize {
11599#define TIOCM_OUT2 0x4000
116100#define TIOCM_LOOP 0x8000
117101
118#define N_TTY 0
119#define N_SLIP 1
120#define N_MOUSE 2
121#define N_PPP 3
122#define N_STRIP 4
123#define N_AX25 5
124#define N_X25 6
125#define N_6PACK 7
126#define N_MASC 8
127#define N_R3964 9
128#define N_PROFIBUS_FDL 10
129#define N_IRDA 11
130#define N_SMSBLOCK 12
131#define N_HDLC 13
132#define N_SYNC_PPP 14
133#define N_HCI 15
134
135102#define FIOSETOWN 0x8901
136103#define SIOCSPGRP 0x8902
137104#define FIOGETOWN 0x8903
......@@ -140,67 +107,4 @@ struct winsize {
140107#define SIOCGSTAMP 0x8906
141108#define SIOCGSTAMPNS 0x8907
142109
143#define SIOCADDRT 0x890B
144#define SIOCDELRT 0x890C
145#define SIOCRTMSG 0x890D
146
147#define SIOCGIFNAME 0x8910
148#define SIOCSIFLINK 0x8911
149#define SIOCGIFCONF 0x8912
150#define SIOCGIFFLAGS 0x8913
151#define SIOCSIFFLAGS 0x8914
152#define SIOCGIFADDR 0x8915
153#define SIOCSIFADDR 0x8916
154#define SIOCGIFDSTADDR 0x8917
155#define SIOCSIFDSTADDR 0x8918
156#define SIOCGIFBRDADDR 0x8919
157#define SIOCSIFBRDADDR 0x891a
158#define SIOCGIFNETMASK 0x891b
159#define SIOCSIFNETMASK 0x891c
160#define SIOCGIFMETRIC 0x891d
161#define SIOCSIFMETRIC 0x891e
162#define SIOCGIFMEM 0x891f
163#define SIOCSIFMEM 0x8920
164#define SIOCGIFMTU 0x8921
165#define SIOCSIFMTU 0x8922
166#define SIOCSIFNAME 0x8923
167#define SIOCSIFHWADDR 0x8924
168#define SIOCGIFENCAP 0x8925
169#define SIOCSIFENCAP 0x8926
170#define SIOCGIFHWADDR 0x8927
171#define SIOCGIFSLAVE 0x8929
172#define SIOCSIFSLAVE 0x8930
173#define SIOCADDMULTI 0x8931
174#define SIOCDELMULTI 0x8932
175#define SIOCGIFINDEX 0x8933
176#define SIOGIFINDEX SIOCGIFINDEX
177#define SIOCSIFPFLAGS 0x8934
178#define SIOCGIFPFLAGS 0x8935
179#define SIOCDIFADDR 0x8936
180#define SIOCSIFHWBROADCAST 0x8937
181#define SIOCGIFCOUNT 0x8938
182
183#define SIOCGIFBR 0x8940
184#define SIOCSIFBR 0x8941
185
186#define SIOCGIFTXQLEN 0x8942
187#define SIOCSIFTXQLEN 0x8943
188
189#define SIOCDARP 0x8953
190#define SIOCGARP 0x8954
191#define SIOCSARP 0x8955
192
193#define SIOCDRARP 0x8960
194#define SIOCGRARP 0x8961
195#define SIOCSRARP 0x8962
196
197#define SIOCGIFMAP 0x8970
198#define SIOCSIFMAP 0x8971
199
200#define SIOCADDDLCI 0x8980
201#define SIOCDELDLCI 0x8981
202
203#define SIOCDEVPRIVATE 0x89F0
204#define SIOCPROTOPRIVATE 0x89E0
205
206110#include <bits/ioctl_fix.h>
lib/libc/musl/arch/generic/fp_arch.h created
lib/libc/musl/arch/i386/bits/syscall.h.in+34
......@@ -384,4 +384,38 @@
384384#define __NR_arch_prctl 384
385385#define __NR_io_pgetevents 385
386386#define __NR_rseq 386
387#define __NR_semget 393
388#define __NR_semctl 394
389#define __NR_shmget 395
390#define __NR_shmctl 396
391#define __NR_shmat 397
392#define __NR_shmdt 398
393#define __NR_msgget 399
394#define __NR_msgsnd 400
395#define __NR_msgrcv 401
396#define __NR_msgctl 402
397#define __NR_clock_gettime64 403
398#define __NR_clock_settime64 404
399#define __NR_clock_adjtime64 405
400#define __NR_clock_getres_time64 406
401#define __NR_clock_nanosleep_time64 407
402#define __NR_timer_gettime64 408
403#define __NR_timer_settime64 409
404#define __NR_timerfd_gettime64 410
405#define __NR_timerfd_settime64 411
406#define __NR_utimensat_time64 412
407#define __NR_pselect6_time64 413
408#define __NR_ppoll_time64 414
409#define __NR_io_pgetevents_time64 416
410#define __NR_recvmmsg_time64 417
411#define __NR_mq_timedsend_time64 418
412#define __NR_mq_timedreceive_time64 419
413#define __NR_semtimedop_time64 420
414#define __NR_rt_sigtimedwait_time64 421
415#define __NR_futex_time64 422
416#define __NR_sched_rr_get_interval_time64 423
417#define __NR_pidfd_send_signal 424
418#define __NR_io_uring_setup 425
419#define __NR_io_uring_enter 426
420#define __NR_io_uring_register 427
387421
lib/libc/musl/arch/i386/syscall_arch.h+37-7
......@@ -3,52 +3,82 @@
33((union { long long ll; long l[2]; }){ .ll = x }).l[1]
44#define __SYSCALL_LL_O(x) __SYSCALL_LL_E((x))
55
6#if SYSCALL_NO_TLS
7#define SYSCALL_INSNS "int $128"
8#else
9#define SYSCALL_INSNS "call *%%gs:16"
10#endif
11
12#define SYSCALL_INSNS_12 "xchg %%ebx,%%edx ; " SYSCALL_INSNS " ; xchg %%ebx,%%edx"
13#define SYSCALL_INSNS_34 "xchg %%ebx,%%edi ; " SYSCALL_INSNS " ; xchg %%ebx,%%edi"
14
615static inline long __syscall0(long n)
716{
817 unsigned long __ret;
9 __asm__ __volatile__ (".hidden __vsyscall ; call __vsyscall" : "=a"(__ret) : "a"(n) : "memory");
18 __asm__ __volatile__ (SYSCALL_INSNS : "=a"(__ret) : "a"(n) : "memory");
1019 return __ret;
1120}
1221
1322static inline long __syscall1(long n, long a1)
1423{
1524 unsigned long __ret;
16 __asm__ __volatile__ (".hidden __vsyscall ; call __vsyscall" : "=a"(__ret) : "a"(n), "d"(a1) : "memory");
25 __asm__ __volatile__ (SYSCALL_INSNS_12 : "=a"(__ret) : "a"(n), "d"(a1) : "memory");
1726 return __ret;
1827}
1928
2029static inline long __syscall2(long n, long a1, long a2)
2130{
2231 unsigned long __ret;
23 __asm__ __volatile__ (".hidden __vsyscall ; call __vsyscall" : "=a"(__ret) : "a"(n), "d"(a1), "c"(a2) : "memory");
32 __asm__ __volatile__ (SYSCALL_INSNS_12 : "=a"(__ret) : "a"(n), "d"(a1), "c"(a2) : "memory");
2433 return __ret;
2534}
2635
2736static inline long __syscall3(long n, long a1, long a2, long a3)
2837{
2938 unsigned long __ret;
30 __asm__ __volatile__ (".hidden __vsyscall ; call __vsyscall" : "=a"(__ret) : "a"(n), "d"(a1), "c"(a2), "D"(a3) : "memory");
39#if !defined(__PIC__) || !defined(BROKEN_EBX_ASM)
40 __asm__ __volatile__ (SYSCALL_INSNS : "=a"(__ret) : "a"(n), "b"(a1), "c"(a2), "d"(a3) : "memory");
41#else
42 __asm__ __volatile__ (SYSCALL_INSNS_34 : "=a"(__ret) : "a"(n), "D"(a1), "c"(a2), "d"(a3) : "memory");
43#endif
3144 return __ret;
3245}
3346
3447static inline long __syscall4(long n, long a1, long a2, long a3, long a4)
3548{
3649 unsigned long __ret;
37 __asm__ __volatile__ (".hidden __vsyscall ; call __vsyscall" : "=a"(__ret) : "a"(n), "d"(a1), "c"(a2), "D"(a3), "S"(a4) : "memory");
50#if !defined(__PIC__) || !defined(BROKEN_EBX_ASM)
51 __asm__ __volatile__ (SYSCALL_INSNS : "=a"(__ret) : "a"(n), "b"(a1), "c"(a2), "d"(a3), "S"(a4) : "memory");
52#else
53 __asm__ __volatile__ (SYSCALL_INSNS_34 : "=a"(__ret) : "a"(n), "D"(a1), "c"(a2), "d"(a3), "S"(a4) : "memory");
54#endif
3855 return __ret;
3956}
4057
4158static inline long __syscall5(long n, long a1, long a2, long a3, long a4, long a5)
4259{
4360 unsigned long __ret;
44 __asm__ __volatile__ ("push %6 ; .hidden __vsyscall ; call __vsyscall ; add $4,%%esp" : "=a"(__ret) : "a"(n), "d"(a1), "c"(a2), "D"(a3), "S"(a4), "g"(a5) : "memory");
61#if !defined(__PIC__) || !defined(BROKEN_EBX_ASM)
62 __asm__ __volatile__ (SYSCALL_INSNS
63 : "=a"(__ret) : "a"(n), "b"(a1), "c"(a2), "d"(a3), "S"(a4), "D"(a5) : "memory");
64#else
65 __asm__ __volatile__ ("pushl %2 ; push %%ebx ; mov 4(%%esp),%%ebx ; " SYSCALL_INSNS " ; pop %%ebx ; add $4,%%esp"
66 : "=a"(__ret) : "a"(n), "g"(a1), "c"(a2), "d"(a3), "S"(a4), "D"(a5) : "memory");
67#endif
4568 return __ret;
4669}
4770
4871static inline long __syscall6(long n, long a1, long a2, long a3, long a4, long a5, long a6)
4972{
5073 unsigned long __ret;
51 __asm__ __volatile__ ("push %6 ; .hidden __vsyscall6 ; call __vsyscall6 ; add $4,%%esp" : "=a"(__ret) : "a"(n), "d"(a1), "c"(a2), "D"(a3), "S"(a4), "g"(0+(long[]){a5, a6}) : "memory");
74#if !defined(__PIC__) || !defined(BROKEN_EBX_ASM)
75 __asm__ __volatile__ ("pushl %7 ; push %%ebp ; mov 4(%%esp),%%ebp ; " SYSCALL_INSNS " ; pop %%ebp ; add $4,%%esp"
76 : "=a"(__ret) : "a"(n), "b"(a1), "c"(a2), "d"(a3), "S"(a4), "D"(a5), "g"(a6) : "memory");
77#else
78 unsigned long a1a6[2] = { a1, a6 };
79 __asm__ __volatile__ ("pushl %1 ; push %%ebx ; push %%ebp ; mov 8(%%esp),%%ebx ; mov 4(%%ebx),%%ebp ; mov (%%ebx),%%ebx ; " SYSCALL_INSNS " ; pop %%ebp ; pop %%ebx ; add $4,%%esp"
80 : "=a"(__ret) : "g"(&a1a6), "a"(n), "c"(a2), "d"(a3), "S"(a4), "D"(a5) : "memory");
81#endif
5282 return __ret;
5383}
5484
lib/libc/musl/arch/mips/bits/ioctl.h-98
......@@ -90,24 +90,6 @@
9090#define TIOCMIWAIT 0x5491
9191#define TIOCGICOUNT 0x5492
9292
93#define TIOCPKT_DATA 0
94#define TIOCPKT_FLUSHREAD 1
95#define TIOCPKT_FLUSHWRITE 2
96#define TIOCPKT_STOP 4
97#define TIOCPKT_START 8
98#define TIOCPKT_NOSTOP 16
99#define TIOCPKT_DOSTOP 32
100#define TIOCPKT_IOCTL 64
101
102#define TIOCSER_TEMT 0x01
103
104struct winsize {
105 unsigned short ws_row;
106 unsigned short ws_col;
107 unsigned short ws_xpixel;
108 unsigned short ws_ypixel;
109};
110
11193#define TIOCM_LE 0x001
11294#define TIOCM_DTR 0x002
11395#define TIOCM_RTS 0x004
......@@ -123,23 +105,6 @@ struct winsize {
123105#define TIOCM_OUT2 0x4000
124106#define TIOCM_LOOP 0x8000
125107
126#define N_TTY 0
127#define N_SLIP 1
128#define N_MOUSE 2
129#define N_PPP 3
130#define N_STRIP 4
131#define N_AX25 5
132#define N_X25 6
133#define N_6PACK 7
134#define N_MASC 8
135#define N_R3964 9
136#define N_PROFIBUS_FDL 10
137#define N_IRDA 11
138#define N_SMSBLOCK 12
139#define N_HDLC 13
140#define N_SYNC_PPP 14
141#define N_HCI 15
142
143108#define FIOGETOWN _IOR('f', 123, int)
144109#define FIOSETOWN _IOW('f', 124, int)
145110#define SIOCATMARK _IOR('s', 7, int)
......@@ -147,66 +112,3 @@ struct winsize {
147112#define SIOCGPGRP _IOR('s', 9, pid_t)
148113#define SIOCGSTAMP 0x8906
149114#define SIOCGSTAMPNS 0x8907
150
151#define SIOCADDRT 0x890B
152#define SIOCDELRT 0x890C
153#define SIOCRTMSG 0x890D
154
155#define SIOCGIFNAME 0x8910
156#define SIOCSIFLINK 0x8911
157#define SIOCGIFCONF 0x8912
158#define SIOCGIFFLAGS 0x8913
159#define SIOCSIFFLAGS 0x8914
160#define SIOCGIFADDR 0x8915
161#define SIOCSIFADDR 0x8916
162#define SIOCGIFDSTADDR 0x8917
163#define SIOCSIFDSTADDR 0x8918
164#define SIOCGIFBRDADDR 0x8919
165#define SIOCSIFBRDADDR 0x891a
166#define SIOCGIFNETMASK 0x891b
167#define SIOCSIFNETMASK 0x891c
168#define SIOCGIFMETRIC 0x891d
169#define SIOCSIFMETRIC 0x891e
170#define SIOCGIFMEM 0x891f
171#define SIOCSIFMEM 0x8920
172#define SIOCGIFMTU 0x8921
173#define SIOCSIFMTU 0x8922
174#define SIOCSIFNAME 0x8923
175#define SIOCSIFHWADDR 0x8924
176#define SIOCGIFENCAP 0x8925
177#define SIOCSIFENCAP 0x8926
178#define SIOCGIFHWADDR 0x8927
179#define SIOCGIFSLAVE 0x8929
180#define SIOCSIFSLAVE 0x8930
181#define SIOCADDMULTI 0x8931
182#define SIOCDELMULTI 0x8932
183#define SIOCGIFINDEX 0x8933
184#define SIOGIFINDEX SIOCGIFINDEX
185#define SIOCSIFPFLAGS 0x8934
186#define SIOCGIFPFLAGS 0x8935
187#define SIOCDIFADDR 0x8936
188#define SIOCSIFHWBROADCAST 0x8937
189#define SIOCGIFCOUNT 0x8938
190
191#define SIOCGIFBR 0x8940
192#define SIOCSIFBR 0x8941
193
194#define SIOCGIFTXQLEN 0x8942
195#define SIOCSIFTXQLEN 0x8943
196
197#define SIOCDARP 0x8953
198#define SIOCGARP 0x8954
199#define SIOCSARP 0x8955
200
201#define SIOCDRARP 0x8960
202#define SIOCGRARP 0x8961
203#define SIOCSRARP 0x8962
204
205#define SIOCGIFMAP 0x8970
206#define SIOCSIFMAP 0x8971
207
208#define SIOCADDDLCI 0x8980
209#define SIOCDELDLCI 0x8981
210
211#define SIOCDEVPRIVATE 0x89F0
212#define SIOCPROTOPRIVATE 0x89E0
lib/libc/musl/arch/mips/bits/syscall.h.in+34
......@@ -366,4 +366,38 @@
366366#define __NR_statx 4366
367367#define __NR_rseq 4367
368368#define __NR_io_pgetevents 4368
369#define __NR_semget 4393
370#define __NR_semctl 4394
371#define __NR_shmget 4395
372#define __NR_shmctl 4396
373#define __NR_shmat 4397
374#define __NR_shmdt 4398
375#define __NR_msgget 4399
376#define __NR_msgsnd 4400
377#define __NR_msgrcv 4401
378#define __NR_msgctl 4402
379#define __NR_clock_gettime64 4403
380#define __NR_clock_settime64 4404
381#define __NR_clock_adjtime64 4405
382#define __NR_clock_getres_time64 4406
383#define __NR_clock_nanosleep_time64 4407
384#define __NR_timer_gettime64 4408
385#define __NR_timer_settime64 4409
386#define __NR_timerfd_gettime64 4410
387#define __NR_timerfd_settime64 4411
388#define __NR_utimensat_time64 4412
389#define __NR_pselect6_time64 4413
390#define __NR_ppoll_time64 4414
391#define __NR_io_pgetevents_time64 4416
392#define __NR_recvmmsg_time64 4417
393#define __NR_mq_timedsend_time64 4418
394#define __NR_mq_timedreceive_time64 4419
395#define __NR_semtimedop_time64 4420
396#define __NR_rt_sigtimedwait_time64 4421
397#define __NR_futex_time64 4422
398#define __NR_sched_rr_get_interval_time64 4423
399#define __NR_pidfd_send_signal 4424
400#define __NR_io_uring_setup 4425
401#define __NR_io_uring_enter 4426
402#define __NR_io_uring_register 4427
369403
lib/libc/musl/arch/mips/bits/termios.h+1-1
......@@ -165,5 +165,5 @@ struct termios {
165165#define EXTPROC 0200000
166166
167167#define XTABS 0014000
168#define TIOCSER_TEMT 0x01
168#define TIOCSER_TEMT 1
169169#endif
lib/libc/musl/arch/mips/syscall_arch.h+58-6
......@@ -3,8 +3,6 @@
33((union { long long ll; long l[2]; }){ .ll = x }).l[1]
44#define __SYSCALL_LL_O(x) 0, __SYSCALL_LL_E((x))
55
6hidden long (__syscall)(long, ...);
7
86#define SYSCALL_RLIM_INFINITY (-1UL/2)
97
108#if _MIPSEL || __MIPSEL || __MIPSEL__
......@@ -104,8 +102,22 @@ static inline long __syscall4(long n, long a, long b, long c, long d)
104102
105103static inline long __syscall5(long n, long a, long b, long c, long d, long e)
106104{
107 long r2 = (__syscall)(n, a, b, c, d, e);
108 if (r2 > -4096UL) return r2;
105 register long r4 __asm__("$4") = a;
106 register long r5 __asm__("$5") = b;
107 register long r6 __asm__("$6") = c;
108 register long r7 __asm__("$7") = d;
109 register long r8 __asm__("$8") = e;
110 register long r2 __asm__("$2");
111 __asm__ __volatile__ (
112 "subu $sp,$sp,32 ; sw $8,16($sp) ; "
113 "addu $2,$0,%3 ; syscall ;"
114 "addu $sp,$sp,32"
115 : "=&r"(r2), "=r"(r7), "+r"(r8)
116 : "ir"(n), "0"(r2), "1"(r7), "r"(r4), "r"(r5), "r"(r6)
117 : "$1", "$3", "$9", "$10", "$11", "$12", "$13",
118 "$14", "$15", "$24", "$25", "hi", "lo", "memory");
119 if (r7) return -r2;
120 long ret = r2;
109121 if (n == SYS_stat64 || n == SYS_fstat64 || n == SYS_lstat64) __stat_fix(b);
110122 if (n == SYS_fstatat64) __stat_fix(c);
111123 return r2;
......@@ -113,8 +125,48 @@ static inline long __syscall5(long n, long a, long b, long c, long d, long e)
113125
114126static inline long __syscall6(long n, long a, long b, long c, long d, long e, long f)
115127{
116 long r2 = (__syscall)(n, a, b, c, d, e, f);
117 if (r2 > -4096UL) return r2;
128 register long r4 __asm__("$4") = a;
129 register long r5 __asm__("$5") = b;
130 register long r6 __asm__("$6") = c;
131 register long r7 __asm__("$7") = d;
132 register long r8 __asm__("$8") = e;
133 register long r9 __asm__("$9") = f;
134 register long r2 __asm__("$2");
135 __asm__ __volatile__ (
136 "subu $sp,$sp,32 ; sw $8,16($sp) ; sw $9,20($sp) ; "
137 "addu $2,$0,%4 ; syscall ;"
138 "addu $sp,$sp,32"
139 : "=&r"(r2), "=r"(r7), "+r"(r8), "+r"(r9)
140 : "ir"(n), "0"(r2), "1"(r7), "r"(r4), "r"(r5), "r"(r6)
141 : "$1", "$3", "$10", "$11", "$12", "$13",
142 "$14", "$15", "$24", "$25", "hi", "lo", "memory");
143 if (r7) return -r2;
144 long ret = r2;
145 if (n == SYS_stat64 || n == SYS_fstat64 || n == SYS_lstat64) __stat_fix(b);
146 if (n == SYS_fstatat64) __stat_fix(c);
147 return r2;
148}
149
150static inline long __syscall7(long n, long a, long b, long c, long d, long e, long f, long g)
151{
152 register long r4 __asm__("$4") = a;
153 register long r5 __asm__("$5") = b;
154 register long r6 __asm__("$6") = c;
155 register long r7 __asm__("$7") = d;
156 register long r8 __asm__("$8") = e;
157 register long r9 __asm__("$9") = f;
158 register long r10 __asm__("$10") = g;
159 register long r2 __asm__("$2");
160 __asm__ __volatile__ (
161 "subu $sp,$sp,32 ; sw $8,16($sp) ; sw $9,20($sp) ; sw $10,24($sp) ; "
162 "addu $2,$0,%5 ; syscall ;"
163 "addu $sp,$sp,32"
164 : "=&r"(r2), "=r"(r7), "+r"(r8), "+r"(r9), "+r"(r10)
165 : "ir"(n), "0"(r2), "1"(r7), "r"(r4), "r"(r5), "r"(r6)
166 : "$1", "$3", "$11", "$12", "$13",
167 "$14", "$15", "$24", "$25", "hi", "lo", "memory");
168 if (r7) return -r2;
169 long ret = r2;
118170 if (n == SYS_stat64 || n == SYS_fstat64 || n == SYS_lstat64) __stat_fix(b);
119171 if (n == SYS_fstatat64) __stat_fix(c);
120172 return r2;
lib/libc/musl/arch/mips64/bits/ioctl.h-98
......@@ -90,24 +90,6 @@
9090#define TIOCMIWAIT 0x5491
9191#define TIOCGICOUNT 0x5492
9292
93#define TIOCPKT_DATA 0
94#define TIOCPKT_FLUSHREAD 1
95#define TIOCPKT_FLUSHWRITE 2
96#define TIOCPKT_STOP 4
97#define TIOCPKT_START 8
98#define TIOCPKT_NOSTOP 16
99#define TIOCPKT_DOSTOP 32
100#define TIOCPKT_IOCTL 64
101
102#define TIOCSER_TEMT 0x01
103
104struct winsize {
105 unsigned short ws_row;
106 unsigned short ws_col;
107 unsigned short ws_xpixel;
108 unsigned short ws_ypixel;
109};
110
11193#define TIOCM_LE 0x001
11294#define TIOCM_DTR 0x002
11395#define TIOCM_RTS 0x004
......@@ -123,23 +105,6 @@ struct winsize {
123105#define TIOCM_OUT2 0x4000
124106#define TIOCM_LOOP 0x8000
125107
126#define N_TTY 0
127#define N_SLIP 1
128#define N_MOUSE 2
129#define N_PPP 3
130#define N_STRIP 4
131#define N_AX25 5
132#define N_X25 6
133#define N_6PACK 7
134#define N_MASC 8
135#define N_R3964 9
136#define N_PROFIBUS_FDL 10
137#define N_IRDA 11
138#define N_SMSBLOCK 12
139#define N_HDLC 13
140#define N_SYNC_PPP 14
141#define N_HCI 15
142
143108#define FIOGETOWN _IOR('f', 123, int)
144109#define FIOSETOWN _IOW('f', 124, int)
145110#define SIOCATMARK _IOR('s', 7, int)
......@@ -147,66 +112,3 @@ struct winsize {
147112#define SIOCGPGRP _IOR('s', 9, pid_t)
148113#define SIOCGSTAMP 0x8906
149114#define SIOCGSTAMPNS 0x8907
150
151#define SIOCADDRT 0x890B
152#define SIOCDELRT 0x890C
153#define SIOCRTMSG 0x890D
154
155#define SIOCGIFNAME 0x8910
156#define SIOCSIFLINK 0x8911
157#define SIOCGIFCONF 0x8912
158#define SIOCGIFFLAGS 0x8913
159#define SIOCSIFFLAGS 0x8914
160#define SIOCGIFADDR 0x8915
161#define SIOCSIFADDR 0x8916
162#define SIOCGIFDSTADDR 0x8917
163#define SIOCSIFDSTADDR 0x8918
164#define SIOCGIFBRDADDR 0x8919
165#define SIOCSIFBRDADDR 0x891a
166#define SIOCGIFNETMASK 0x891b
167#define SIOCSIFNETMASK 0x891c
168#define SIOCGIFMETRIC 0x891d
169#define SIOCSIFMETRIC 0x891e
170#define SIOCGIFMEM 0x891f
171#define SIOCSIFMEM 0x8920
172#define SIOCGIFMTU 0x8921
173#define SIOCSIFMTU 0x8922
174#define SIOCSIFNAME 0x8923
175#define SIOCSIFHWADDR 0x8924
176#define SIOCGIFENCAP 0x8925
177#define SIOCSIFENCAP 0x8926
178#define SIOCGIFHWADDR 0x8927
179#define SIOCGIFSLAVE 0x8929
180#define SIOCSIFSLAVE 0x8930
181#define SIOCADDMULTI 0x8931
182#define SIOCDELMULTI 0x8932
183#define SIOCGIFINDEX 0x8933
184#define SIOGIFINDEX SIOCGIFINDEX
185#define SIOCSIFPFLAGS 0x8934
186#define SIOCGIFPFLAGS 0x8935
187#define SIOCDIFADDR 0x8936
188#define SIOCSIFHWBROADCAST 0x8937
189#define SIOCGIFCOUNT 0x8938
190
191#define SIOCGIFBR 0x8940
192#define SIOCSIFBR 0x8941
193
194#define SIOCGIFTXQLEN 0x8942
195#define SIOCSIFTXQLEN 0x8943
196
197#define SIOCDARP 0x8953
198#define SIOCGARP 0x8954
199#define SIOCSARP 0x8955
200
201#define SIOCDRARP 0x8960
202#define SIOCGRARP 0x8961
203#define SIOCSRARP 0x8962
204
205#define SIOCGIFMAP 0x8970
206#define SIOCSIFMAP 0x8971
207
208#define SIOCADDDLCI 0x8980
209#define SIOCDELDLCI 0x8981
210
211#define SIOCDEVPRIVATE 0x89F0
212#define SIOCPROTOPRIVATE 0x89E0
lib/libc/musl/arch/mips64/bits/syscall.h.in+6-2
......@@ -324,6 +324,10 @@
324324#define __NR_pkey_alloc 5324
325325#define __NR_pkey_free 5325
326326#define __NR_statx 5326
327#define __NR_rseq 4327
328#define __NR_io_pgetevents 4328
327#define __NR_rseq 5327
328#define __NR_io_pgetevents 5328
329#define __NR_pidfd_send_signal 5424
330#define __NR_io_uring_setup 5425
331#define __NR_io_uring_enter 5426
332#define __NR_io_uring_register 5427
329333
lib/libc/musl/arch/mips64/bits/termios.h+1-1
......@@ -165,5 +165,5 @@ struct termios {
165165#define EXTPROC 0200000
166166
167167#define XTABS 0014000
168#define TIOCSER_TEMT 0x01
168#define TIOCSER_TEMT 1
169169#endif
lib/libc/musl/arch/mips64/syscall_arch.h+52-41
......@@ -1,9 +1,6 @@
11#define __SYSCALL_LL_E(x) (x)
22#define __SYSCALL_LL_O(x) (x)
33
4__attribute__((visibility("hidden")))
5long (__syscall)(long, ...);
6
74#define SYSCALL_RLIM_INFINITY (-1UL/2)
85
96#include <sys/stat.h>
......@@ -79,16 +76,14 @@ static inline long __syscall2(long n, long a, long b)
7976{
8077 struct kernel_stat kst;
8178 long ret;
82 register long r4 __asm__("$4");
83 register long r5 __asm__("$5");
79 register long r4 __asm__("$4") = a;
80 register long r5 __asm__("$5") = b;
8481 register long r7 __asm__("$7");
8582 register long r2 __asm__("$2");
8683
87 r5 = b;
8884 if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat)
8985 r5 = (long) &kst;
9086
91 r4 = a;
9287 __asm__ __volatile__ (
9388 "daddu $2,$0,%2 ; syscall"
9489 : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7),
......@@ -109,18 +104,15 @@ static inline long __syscall3(long n, long a, long b, long c)
109104{
110105 struct kernel_stat kst;
111106 long ret;
112 register long r4 __asm__("$4");
113 register long r5 __asm__("$5");
114 register long r6 __asm__("$6");
107 register long r4 __asm__("$4") = a;
108 register long r5 __asm__("$5") = b;
109 register long r6 __asm__("$6") = c;
115110 register long r7 __asm__("$7");
116111 register long r2 __asm__("$2");
117112
118 r5 = b;
119113 if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat)
120114 r5 = (long) &kst;
121115
122 r4 = a;
123 r6 = c;
124116 __asm__ __volatile__ (
125117 "daddu $2,$0,%2 ; syscall"
126118 : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7),
......@@ -141,16 +133,12 @@ static inline long __syscall4(long n, long a, long b, long c, long d)
141133{
142134 struct kernel_stat kst;
143135 long ret;
144 register long r4 __asm__("$4");
145 register long r5 __asm__("$5");
146 register long r6 __asm__("$6");
147 register long r7 __asm__("$7");
136 register long r4 __asm__("$4") = a;
137 register long r5 __asm__("$5") = b;
138 register long r6 __asm__("$6") = c;
139 register long r7 __asm__("$7") = d;
148140 register long r2 __asm__("$2");
149141
150 r4 = a;
151 r5 = b;
152 r6 = c;
153 r7 = d;
154142 if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat)
155143 r5 = (long) &kst;
156144 if (n == SYS_newfstatat)
......@@ -176,48 +164,71 @@ static inline long __syscall4(long n, long a, long b, long c, long d)
176164
177165static inline long __syscall5(long n, long a, long b, long c, long d, long e)
178166{
179 long r2;
180 long old_b = b;
181 long old_c = c;
182167 struct kernel_stat kst;
168 long ret;
169 register long r4 __asm__("$4") = a;
170 register long r5 __asm__("$5") = b;
171 register long r6 __asm__("$6") = c;
172 register long r7 __asm__("$7") = d;
173 register long r8 __asm__("$8") = e;
174 register long r2 __asm__("$2");
183175
184176 if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat)
185 b = (long) &kst;
177 r5 = (long) &kst;
186178 if (n == SYS_newfstatat)
187 c = (long) &kst;
179 r6 = (long) &kst;
188180
189 r2 = (__syscall)(n, a, b, c, d, e);
190 if (r2 > -4096UL) return r2;
181 __asm__ __volatile__ (
182 "daddu $2,$0,%2 ; syscall"
183 : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7),
184 "r"(r4), "r"(r5), "r"(r6), "r"(r8)
185 : "$1", "$3", "$9", "$10", "$11", "$12", "$13",
186 "$14", "$15", "$24", "$25", "hi", "lo", "memory");
187
188 if (r7) return -r2;
189 ret = r2;
191190
192191 if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat)
193 __stat_fix(&kst, (struct stat *)old_b);
192 __stat_fix(&kst, (struct stat *)b);
194193 if (n == SYS_newfstatat)
195 __stat_fix(&kst, (struct stat *)old_c);
194 __stat_fix(&kst, (struct stat *)c);
196195
197 return r2;
196 return ret;
198197}
199198
200199static inline long __syscall6(long n, long a, long b, long c, long d, long e, long f)
201200{
202 long r2;
203 long old_b = b;
204 long old_c = c;
205201 struct kernel_stat kst;
202 long ret;
203 register long r4 __asm__("$4") = a;
204 register long r5 __asm__("$5") = b;
205 register long r6 __asm__("$6") = c;
206 register long r7 __asm__("$7") = d;
207 register long r8 __asm__("$8") = e;
208 register long r9 __asm__("$9") = f;
209 register long r2 __asm__("$2");
206210
207211 if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat)
208 b = (long) &kst;
212 r5 = (long) &kst;
209213 if (n == SYS_newfstatat)
210 c = (long) &kst;
214 r6 = (long) &kst;
211215
212 r2 = (__syscall)(n, a, b, c, d, e, f);
213 if (r2 > -4096UL) return r2;
216 __asm__ __volatile__ (
217 "daddu $2,$0,%2 ; syscall"
218 : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7),
219 "r"(r4), "r"(r5), "r"(r6), "r"(r8), "r"(r9)
220 : "$1", "$3", "$10", "$11", "$12", "$13",
221 "$14", "$15", "$24", "$25", "hi", "lo", "memory");
222
223 if (r7) return -r2;
224 ret = r2;
214225
215226 if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat)
216 __stat_fix(&kst, (struct stat *)old_b);
227 __stat_fix(&kst, (struct stat *)b);
217228 if (n == SYS_newfstatat)
218 __stat_fix(&kst, (struct stat *)old_c);
229 __stat_fix(&kst, (struct stat *)c);
219230
220 return r2;
231 return ret;
221232}
222233
223234#define VDSO_USEFUL
lib/libc/musl/arch/powerpc/bits/ioctl.h-97
......@@ -78,14 +78,6 @@
7878#define TIOCGSERIAL 0x541E
7979#define TIOCSSERIAL 0x541F
8080#define TIOCPKT 0x5420
81#define TIOCPKT_DATA 0
82#define TIOCPKT_FLUSHREAD 1
83#define TIOCPKT_FLUSHWRITE 2
84#define TIOCPKT_STOP 4
85#define TIOCPKT_START 8
86#define TIOCPKT_NOSTOP 16
87#define TIOCPKT_DOSTOP 32
88#define TIOCPKT_IOCTL 64
8981
9082#define TIOCNOTTY 0x5422
9183#define TIOCSETD 0x5423
......@@ -113,38 +105,12 @@
113105#define TIOCSLCKTRMIOS 0x5457
114106#define TIOCSERGSTRUCT 0x5458
115107#define TIOCSERGETLSR 0x5459
116#define TIOCSER_TEMT 0x01
117108#define TIOCSERGETMULTI 0x545A
118109#define TIOCSERSETMULTI 0x545B
119110
120111#define TIOCMIWAIT 0x545C
121112#define TIOCGICOUNT 0x545D
122113
123
124struct winsize {
125 unsigned short ws_row;
126 unsigned short ws_col;
127 unsigned short ws_xpixel;
128 unsigned short ws_ypixel;
129};
130
131#define N_TTY 0
132#define N_SLIP 1
133#define N_MOUSE 2
134#define N_PPP 3
135#define N_STRIP 4
136#define N_AX25 5
137#define N_X25 6
138#define N_6PACK 7
139#define N_MASC 8
140#define N_R3964 9
141#define N_PROFIBUS_FDL 10
142#define N_IRDA 11
143#define N_SMSBLOCK 12
144#define N_HDLC 13
145#define N_SYNC_PPP 14
146#define N_HCI 15
147
148114#define FIOSETOWN 0x8901
149115#define SIOCSPGRP 0x8902
150116#define FIOGETOWN 0x8903
......@@ -152,66 +118,3 @@ struct winsize {
152118#define SIOCATMARK 0x8905
153119#define SIOCGSTAMP 0x8906
154120#define SIOCGSTAMPNS 0x8907
155
156#define SIOCADDRT 0x890B
157#define SIOCDELRT 0x890C
158#define SIOCRTMSG 0x890D
159
160#define SIOCGIFNAME 0x8910
161#define SIOCSIFLINK 0x8911
162#define SIOCGIFCONF 0x8912
163#define SIOCGIFFLAGS 0x8913
164#define SIOCSIFFLAGS 0x8914
165#define SIOCGIFADDR 0x8915
166#define SIOCSIFADDR 0x8916
167#define SIOCGIFDSTADDR 0x8917
168#define SIOCSIFDSTADDR 0x8918
169#define SIOCGIFBRDADDR 0x8919
170#define SIOCSIFBRDADDR 0x891a
171#define SIOCGIFNETMASK 0x891b
172#define SIOCSIFNETMASK 0x891c
173#define SIOCGIFMETRIC 0x891d
174#define SIOCSIFMETRIC 0x891e
175#define SIOCGIFMEM 0x891f
176#define SIOCSIFMEM 0x8920
177#define SIOCGIFMTU 0x8921
178#define SIOCSIFMTU 0x8922
179#define SIOCSIFNAME 0x8923
180#define SIOCSIFHWADDR 0x8924
181#define SIOCGIFENCAP 0x8925
182#define SIOCSIFENCAP 0x8926
183#define SIOCGIFHWADDR 0x8927
184#define SIOCGIFSLAVE 0x8929
185#define SIOCSIFSLAVE 0x8930
186#define SIOCADDMULTI 0x8931
187#define SIOCDELMULTI 0x8932
188#define SIOCGIFINDEX 0x8933
189#define SIOGIFINDEX SIOCGIFINDEX
190#define SIOCSIFPFLAGS 0x8934
191#define SIOCGIFPFLAGS 0x8935
192#define SIOCDIFADDR 0x8936
193#define SIOCSIFHWBROADCAST 0x8937
194#define SIOCGIFCOUNT 0x8938
195
196#define SIOCGIFBR 0x8940
197#define SIOCSIFBR 0x8941
198
199#define SIOCGIFTXQLEN 0x8942
200#define SIOCSIFTXQLEN 0x8943
201
202#define SIOCDARP 0x8953
203#define SIOCGARP 0x8954
204#define SIOCSARP 0x8955
205
206#define SIOCDRARP 0x8960
207#define SIOCGRARP 0x8961
208#define SIOCSRARP 0x8962
209
210#define SIOCGIFMAP 0x8970
211#define SIOCSIFMAP 0x8971
212
213#define SIOCADDDLCI 0x8980
214#define SIOCDELDLCI 0x8981
215
216#define SIOCDEVPRIVATE 0x89F0
217#define SIOCPROTOPRIVATE 0x89E0
lib/libc/musl/arch/powerpc/bits/ptrace.h+2
......@@ -8,6 +8,8 @@
88#define PTRACE_SET_DEBUGREG 0x1a
99#define PTRACE_GETVSRREGS 0x1b
1010#define PTRACE_SETVSRREGS 0x1c
11#define PTRACE_SYSEMU 0x1d
12#define PTRACE_SYSEMU_SINGLESTEP 0x1e
1113#define PTRACE_SINGLEBLOCK 0x100
1214
1315#define PT_GETVRREGS PTRACE_GETVRREGS
lib/libc/musl/arch/powerpc/bits/syscall.h.in+34
......@@ -373,4 +373,38 @@
373373#define __NR_pkey_mprotect 386
374374#define __NR_rseq 387
375375#define __NR_io_pgetevents 388
376#define __NR_semget 393
377#define __NR_semctl 394
378#define __NR_shmget 395
379#define __NR_shmctl 396
380#define __NR_shmat 397
381#define __NR_shmdt 398
382#define __NR_msgget 399
383#define __NR_msgsnd 400
384#define __NR_msgrcv 401
385#define __NR_msgctl 402
386#define __NR_clock_gettime64 403
387#define __NR_clock_settime64 404
388#define __NR_clock_adjtime64 405
389#define __NR_clock_getres_time64 406
390#define __NR_clock_nanosleep_time64 407
391#define __NR_timer_gettime64 408
392#define __NR_timer_settime64 409
393#define __NR_timerfd_gettime64 410
394#define __NR_timerfd_settime64 411
395#define __NR_utimensat_time64 412
396#define __NR_pselect6_time64 413
397#define __NR_ppoll_time64 414
398#define __NR_io_pgetevents_time64 416
399#define __NR_recvmmsg_time64 417
400#define __NR_mq_timedsend_time64 418
401#define __NR_mq_timedreceive_time64 419
402#define __NR_semtimedop_time64 420
403#define __NR_rt_sigtimedwait_time64 421
404#define __NR_futex_time64 422
405#define __NR_sched_rr_get_interval_time64 423
406#define __NR_pidfd_send_signal 424
407#define __NR_io_uring_setup 425
408#define __NR_io_uring_enter 426
409#define __NR_io_uring_register 427
376410
lib/libc/musl/arch/powerpc/bits/termios.h+1-1
......@@ -167,5 +167,5 @@ struct termios {
167167#define EXTPROC 0x10000000
168168
169169#define XTABS 00006000
170#define TIOCSER_TEMT 0x01
170#define TIOCSER_TEMT 1
171171#endif
lib/libc/musl/arch/powerpc/syscall_arch.h+84-2
......@@ -3,7 +3,89 @@
33((union { long long ll; long l[2]; }){ .ll = x }).l[1]
44#define __SYSCALL_LL_O(x) 0, __SYSCALL_LL_E((x))
55
6#undef SYSCALL_NO_INLINE
7#define SYSCALL_NO_INLINE
6static inline long __syscall0(long n)
7{
8 register long r0 __asm__("r0") = n;
9 register long r3 __asm__("r3");
10 __asm__ __volatile__("sc ; bns+ 1f ; neg %1, %1 ; 1:"
11 : "+r"(r0), "=r"(r3)
12 :: "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12");
13 return r3;
14}
15
16static inline long __syscall1(long n, long a)
17{
18 register long r0 __asm__("r0") = n;
19 register long r3 __asm__("r3") = a;
20 __asm__ __volatile__("sc ; bns+ 1f ; neg %1, %1 ; 1:"
21 : "+r"(r0), "+r"(r3)
22 :: "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12");
23 return r3;
24}
25
26static inline long __syscall2(long n, long a, long b)
27{
28 register long r0 __asm__("r0") = n;
29 register long r3 __asm__("r3") = a;
30 register long r4 __asm__("r4") = b;
31 __asm__ __volatile__("sc ; bns+ 1f ; neg %1, %1 ; 1:"
32 : "+r"(r0), "+r"(r3), "+r"(r4)
33 :: "memory", "cr0", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12");
34 return r3;
35}
36
37static inline long __syscall3(long n, long a, long b, long c)
38{
39 register long r0 __asm__("r0") = n;
40 register long r3 __asm__("r3") = a;
41 register long r4 __asm__("r4") = b;
42 register long r5 __asm__("r5") = c;
43 __asm__ __volatile__("sc ; bns+ 1f ; neg %1, %1 ; 1:"
44 : "+r"(r0), "+r"(r3), "+r"(r4), "+r"(r5)
45 :: "memory", "cr0", "r6", "r7", "r8", "r9", "r10", "r11", "r12");
46 return r3;
47}
48
49static inline long __syscall4(long n, long a, long b, long c, long d)
50{
51 register long r0 __asm__("r0") = n;
52 register long r3 __asm__("r3") = a;
53 register long r4 __asm__("r4") = b;
54 register long r5 __asm__("r5") = c;
55 register long r6 __asm__("r6") = d;
56 __asm__ __volatile__("sc ; bns+ 1f ; neg %1, %1 ; 1:"
57 : "+r"(r0), "+r"(r3), "+r"(r4), "+r"(r5), "+r"(r6)
58 :: "memory", "cr0", "r7", "r8", "r9", "r10", "r11", "r12");
59 return r3;
60}
61
62static inline long __syscall5(long n, long a, long b, long c, long d, long e)
63{
64 register long r0 __asm__("r0") = n;
65 register long r3 __asm__("r3") = a;
66 register long r4 __asm__("r4") = b;
67 register long r5 __asm__("r5") = c;
68 register long r6 __asm__("r6") = d;
69 register long r7 __asm__("r7") = e;
70 __asm__ __volatile__("sc ; bns+ 1f ; neg %1, %1 ; 1:"
71 : "+r"(r0), "+r"(r3), "+r"(r4), "+r"(r5), "+r"(r6), "+r"(r7)
72 :: "memory", "cr0", "r8", "r9", "r10", "r11", "r12");
73 return r3;
74}
75
76static inline long __syscall6(long n, long a, long b, long c, long d, long e, long f)
77{
78 register long r0 __asm__("r0") = n;
79 register long r3 __asm__("r3") = a;
80 register long r4 __asm__("r4") = b;
81 register long r5 __asm__("r5") = c;
82 register long r6 __asm__("r6") = d;
83 register long r7 __asm__("r7") = e;
84 register long r8 __asm__("r8") = f;
85 __asm__ __volatile__("sc ; bns+ 1f ; neg %1, %1 ; 1:"
86 : "+r"(r0), "+r"(r3), "+r"(r4), "+r"(r5), "+r"(r6), "+r"(r7), "+r"(r8)
87 :: "memory", "cr0", "r9", "r10", "r11", "r12");
88 return r3;
89}
890
991#define SYSCALL_FADVISE_6_ARG
lib/libc/musl/arch/powerpc64/bits/ioctl.h-97
......@@ -78,14 +78,6 @@
7878#define TIOCGSERIAL 0x541E
7979#define TIOCSSERIAL 0x541F
8080#define TIOCPKT 0x5420
81#define TIOCPKT_DATA 0
82#define TIOCPKT_FLUSHREAD 1
83#define TIOCPKT_FLUSHWRITE 2
84#define TIOCPKT_STOP 4
85#define TIOCPKT_START 8
86#define TIOCPKT_NOSTOP 16
87#define TIOCPKT_DOSTOP 32
88#define TIOCPKT_IOCTL 64
8981
9082#define TIOCNOTTY 0x5422
9183#define TIOCSETD 0x5423
......@@ -113,38 +105,12 @@
113105#define TIOCSLCKTRMIOS 0x5457
114106#define TIOCSERGSTRUCT 0x5458
115107#define TIOCSERGETLSR 0x5459
116#define TIOCSER_TEMT 0x01
117108#define TIOCSERGETMULTI 0x545A
118109#define TIOCSERSETMULTI 0x545B
119110
120111#define TIOCMIWAIT 0x545C
121112#define TIOCGICOUNT 0x545D
122113
123
124struct winsize {
125 unsigned short ws_row;
126 unsigned short ws_col;
127 unsigned short ws_xpixel;
128 unsigned short ws_ypixel;
129};
130
131#define N_TTY 0
132#define N_SLIP 1
133#define N_MOUSE 2
134#define N_PPP 3
135#define N_STRIP 4
136#define N_AX25 5
137#define N_X25 6
138#define N_6PACK 7
139#define N_MASC 8
140#define N_R3964 9
141#define N_PROFIBUS_FDL 10
142#define N_IRDA 11
143#define N_SMSBLOCK 12
144#define N_HDLC 13
145#define N_SYNC_PPP 14
146#define N_HCI 15
147
148114#define FIOSETOWN 0x8901
149115#define SIOCSPGRP 0x8902
150116#define FIOGETOWN 0x8903
......@@ -152,66 +118,3 @@ struct winsize {
152118#define SIOCATMARK 0x8905
153119#define SIOCGSTAMP 0x8906
154120#define SIOCGSTAMPNS 0x8907
155
156#define SIOCADDRT 0x890B
157#define SIOCDELRT 0x890C
158#define SIOCRTMSG 0x890D
159
160#define SIOCGIFNAME 0x8910
161#define SIOCSIFLINK 0x8911
162#define SIOCGIFCONF 0x8912
163#define SIOCGIFFLAGS 0x8913
164#define SIOCSIFFLAGS 0x8914
165#define SIOCGIFADDR 0x8915
166#define SIOCSIFADDR 0x8916
167#define SIOCGIFDSTADDR 0x8917
168#define SIOCSIFDSTADDR 0x8918
169#define SIOCGIFBRDADDR 0x8919
170#define SIOCSIFBRDADDR 0x891a
171#define SIOCGIFNETMASK 0x891b
172#define SIOCSIFNETMASK 0x891c
173#define SIOCGIFMETRIC 0x891d
174#define SIOCSIFMETRIC 0x891e
175#define SIOCGIFMEM 0x891f
176#define SIOCSIFMEM 0x8920
177#define SIOCGIFMTU 0x8921
178#define SIOCSIFMTU 0x8922
179#define SIOCSIFNAME 0x8923
180#define SIOCSIFHWADDR 0x8924
181#define SIOCGIFENCAP 0x8925
182#define SIOCSIFENCAP 0x8926
183#define SIOCGIFHWADDR 0x8927
184#define SIOCGIFSLAVE 0x8929
185#define SIOCSIFSLAVE 0x8930
186#define SIOCADDMULTI 0x8931
187#define SIOCDELMULTI 0x8932
188#define SIOCGIFINDEX 0x8933
189#define SIOGIFINDEX SIOCGIFINDEX
190#define SIOCSIFPFLAGS 0x8934
191#define SIOCGIFPFLAGS 0x8935
192#define SIOCDIFADDR 0x8936
193#define SIOCSIFHWBROADCAST 0x8937
194#define SIOCGIFCOUNT 0x8938
195
196#define SIOCGIFBR 0x8940
197#define SIOCSIFBR 0x8941
198
199#define SIOCGIFTXQLEN 0x8942
200#define SIOCSIFTXQLEN 0x8943
201
202#define SIOCDARP 0x8953
203#define SIOCGARP 0x8954
204#define SIOCSARP 0x8955
205
206#define SIOCDRARP 0x8960
207#define SIOCGRARP 0x8961
208#define SIOCSRARP 0x8962
209
210#define SIOCGIFMAP 0x8970
211#define SIOCSIFMAP 0x8971
212
213#define SIOCADDDLCI 0x8980
214#define SIOCDELDLCI 0x8981
215
216#define SIOCDEVPRIVATE 0x89F0
217#define SIOCPROTOPRIVATE 0x89E0
lib/libc/musl/arch/powerpc64/bits/ptrace.h+2
......@@ -8,6 +8,8 @@
88#define PTRACE_SET_DEBUGREG 0x1a
99#define PTRACE_GETVSRREGS 0x1b
1010#define PTRACE_SETVSRREGS 0x1c
11#define PTRACE_SYSEMU 0x1d
12#define PTRACE_SYSEMU_SINGLESTEP 0x1e
1113#define PTRACE_SINGLEBLOCK 0x100
1214
1315#define PT_GETVRREGS PTRACE_GETVRREGS
lib/libc/musl/arch/powerpc64/bits/signal.h+12-5
......@@ -16,11 +16,18 @@ typedef struct {
1616} fpregset_t;
1717
1818typedef struct {
19 unsigned __int128 vrregs[32];
20 unsigned _pad[3];
21 unsigned vrsave;
22 unsigned vscr;
23 unsigned _pad2[3];
19#ifdef __GNUC__
20 __attribute__((__aligned__(16)))
21#endif
22 unsigned vrregs[32][4];
23 struct {
24#if __BIG_ENDIAN__
25 unsigned _pad[3], vscr_word;
26#else
27 unsigned vscr_word, _pad[3];
28#endif
29 } vscr;
30 unsigned vrsave, _pad[3];
2431} vrregset_t;
2532
2633typedef struct sigcontext {
lib/libc/musl/arch/powerpc64/bits/syscall.h.in+15
......@@ -364,4 +364,19 @@
364364#define __NR_pkey_mprotect 386
365365#define __NR_rseq 387
366366#define __NR_io_pgetevents 388
367#define __NR_semtimedop 392
368#define __NR_semget 393
369#define __NR_semctl 394
370#define __NR_shmget 395
371#define __NR_shmctl 396
372#define __NR_shmat 397
373#define __NR_shmdt 398
374#define __NR_msgget 399
375#define __NR_msgsnd 400
376#define __NR_msgrcv 401
377#define __NR_msgctl 402
378#define __NR_pidfd_send_signal 424
379#define __NR_io_uring_setup 425
380#define __NR_io_uring_enter 426
381#define __NR_io_uring_register 427
367382
lib/libc/musl/arch/powerpc64/bits/termios.h+1-1
......@@ -167,5 +167,5 @@ struct termios {
167167#define EXTPROC 0x10000000
168168
169169#define XTABS 00006000
170#define TIOCSER_TEMT 0x01
170#define TIOCSER_TEMT 1
171171#endif
lib/libc/musl/arch/riscv64/atomic_arch.h created+34
......@@ -0,0 +1,34 @@
1#define a_barrier a_barrier
2static inline void a_barrier()
3{
4 __asm__ __volatile__ ("fence rw,rw" : : : "memory");
5}
6
7#define a_cas a_cas
8static inline int a_cas(volatile int *p, int t, int s)
9{
10 int old, tmp;
11 __asm__("\n1: lr.w.aqrl %0, %2\n"
12 " bne %0, %3, 1f\n"
13 " sc.w.aqrl %1, %4, %2\n"
14 " bnez %1, 1b\n"
15 "1:"
16 : "=&r"(old), "+r"(tmp), "+A"(*p)
17 : "r"(t), "r"(s));
18 return old;
19}
20
21#define a_cas_p a_cas_p
22static inline void *a_cas_p(volatile void *p, void *t, void *s)
23{
24 void *old;
25 int tmp;
26 __asm__("\n1: lr.d.aqrl %0, %2\n"
27 " bne %0, %3, 1f\n"
28 " sc.d.aqrl %1, %4, %2\n"
29 " bnez %1, 1b\n"
30 "1:"
31 : "=&r"(old), "+r"(tmp), "+A"(*(long *)p)
32 : "r"(t), "r"(s));
33 return old;
34}
lib/libc/musl/arch/riscv64/bits/alltypes.h.in created+29
......@@ -0,0 +1,29 @@
1#define _Addr long
2#define _Int64 long
3#define _Reg long
4
5TYPEDEF __builtin_va_list va_list;
6TYPEDEF __builtin_va_list __isoc_va_list;
7
8#ifndef __cplusplus
9TYPEDEF int wchar_t;
10#endif
11
12TYPEDEF int blksize_t;
13TYPEDEF unsigned int nlink_t;
14
15TYPEDEF float float_t;
16TYPEDEF double double_t;
17
18TYPEDEF struct { long long __ll; long double __ld; } max_align_t;
19
20TYPEDEF long time_t;
21TYPEDEF long suseconds_t;
22
23TYPEDEF struct { union { int __i[14]; volatile int __vi[14]; unsigned long __s[7]; } __u; } pthread_attr_t;
24TYPEDEF struct { union { int __i[10]; volatile int __vi[10]; volatile void *volatile __p[5]; } __u; } pthread_mutex_t;
25TYPEDEF struct { union { int __i[10]; volatile int __vi[10]; volatile void *volatile __p[5]; } __u; } mtx_t;
26TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[6]; } __u; } pthread_cond_t;
27TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[6]; } __u; } cnd_t;
28TYPEDEF struct { union { int __i[14]; volatile int __vi[14]; void *__p[7]; } __u; } pthread_rwlock_t;
29TYPEDEF struct { union { int __i[8]; volatile int __vi[8]; void *__p[4]; } __u; } pthread_barrier_t;
lib/libc/musl/arch/riscv64/bits/endian.h created+1
......@@ -0,0 +1 @@
1#define __BYTE_ORDER __LITTLE_ENDIAN
lib/libc/musl/arch/riscv64/bits/fcntl.h created+38
......@@ -0,0 +1,38 @@
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/fenv.h created+17
......@@ -0,0 +1,17 @@
1#define FE_INVALID 16
2#define FE_DIVBYZERO 8
3#define FE_OVERFLOW 4
4#define FE_UNDERFLOW 2
5#define FE_INEXACT 1
6
7#define FE_ALL_EXCEPT 31
8
9#define FE_TONEAREST 0
10#define FE_DOWNWARD 2
11#define FE_UPWARD 3
12#define FE_TOWARDZERO 1
13
14typedef unsigned int fexcept_t;
15typedef unsigned int fenv_t;
16
17#define FE_DFL_ENV ((const fenv_t *) -1)
lib/libc/musl/arch/riscv64/bits/float.h created+16
......@@ -0,0 +1,16 @@
1#define FLT_EVAL_METHOD 0
2
3#define LDBL_TRUE_MIN 6.47517511943802511092443895822764655e-4966L
4#define LDBL_MIN 3.36210314311209350626267781732175260e-4932L
5#define LDBL_MAX 1.18973149535723176508575932662800702e+4932L
6#define LDBL_EPSILON 1.92592994438723585305597794258492732e-34L
7
8#define LDBL_MANT_DIG 113
9#define LDBL_MIN_EXP (-16381)
10#define LDBL_MAX_EXP 16384
11
12#define LDBL_DIG 33
13#define LDBL_MIN_10_EXP (-4931)
14#define LDBL_MAX_10_EXP 4932
15
16#define DECIMAL_DIG 36
lib/libc/musl/arch/riscv64/bits/ipc.h created+14
......@@ -0,0 +1,14 @@
1struct ipc_perm {
2 key_t __ipc_perm_key;
3 uid_t uid;
4 gid_t gid;
5 uid_t cuid;
6 gid_t cgid;
7 mode_t mode;
8 unsigned short __ipc_perm_seq;
9
10 unsigned long __pad1;
11 unsigned long __pad2;
12};
13
14#define IPC_64 0
lib/libc/musl/arch/riscv64/bits/limits.h created+7
......@@ -0,0 +1,7 @@
1#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
2 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
3#define LONG_BIT 64
4#endif
5
6#define LONG_MAX 0x7fffffffffffffffL
7#define LLONG_MAX 0x7fffffffffffffffLL
lib/libc/musl/arch/riscv64/bits/msg.h created+13
......@@ -0,0 +1,13 @@
1struct msqid_ds {
2 struct ipc_perm msg_perm;
3 time_t msg_stime;
4 time_t msg_rtime;
5 time_t msg_ctime;
6 unsigned long msg_cbytes;
7 msgqnum_t msg_qnum;
8 msglen_t msg_qbytes;
9 pid_t msg_lspid;
10 pid_t msg_lrpid;
11 unsigned long __pad1;
12 unsigned long __pad2;
13};
lib/libc/musl/arch/riscv64/bits/posix.h created+2
......@@ -0,0 +1,2 @@
1#define _POSIX_V6_LP64_OFF64 1
2#define _POSIX_V7_LP64_OFF64 1
lib/libc/musl/arch/riscv64/bits/reg.h created+8
......@@ -0,0 +1,8 @@
1#undef __WORDSIZE
2#define __WORDSIZE 64
3#define REG_PC 0
4#define REG_RA 1
5#define REG_SP 2
6#define REG_TP 4
7#define REG_S0 8
8#define REG_A0 10
lib/libc/musl/arch/riscv64/bits/sem.h created+9
......@@ -0,0 +1,9 @@
1struct semid_ds {
2 struct ipc_perm sem_perm;
3 time_t sem_otime;
4 time_t sem_ctime;
5 unsigned short sem_nsems;
6 char __sem_nsems_pad[sizeof(time_t)-sizeof(short)];
7 time_t __unused3;
8 time_t __unused4;
9};
lib/libc/musl/arch/riscv64/bits/setjmp.h created+1
......@@ -0,0 +1 @@
1typedef unsigned long __jmp_buf[26];
lib/libc/musl/arch/riscv64/bits/shm.h created+25
......@@ -0,0 +1,25 @@
1#define SHMLBA 4096
2
3struct shmid_ds
4{
5 struct ipc_perm shm_perm;
6 size_t shm_segsz;
7 time_t shm_atime;
8 time_t shm_dtime;
9 time_t shm_ctime;
10 pid_t shm_cpid;
11 pid_t shm_lpid;
12 unsigned long shm_nattch;
13 unsigned long __pad1;
14 unsigned long __pad2;
15};
16
17struct shminfo {
18 unsigned long shmmax, shmmin, shmmni, shmseg, shmall, __unused[4];
19};
20
21struct shm_info {
22 int __used_ids;
23 unsigned long shm_tot, shm_rss, shm_swp;
24 unsigned long __swap_attempts, __swap_successes;
25};
lib/libc/musl/arch/riscv64/bits/signal.h created+112
......@@ -0,0 +1,112 @@
1#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
2 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
3
4#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
5# define MINSIGSTKSZ 2048
6# define SIGSTKSZ 8192
7#endif
8
9/* gregs[0] holds the program counter. */
10
11#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
12typedef unsigned long greg_t;
13typedef unsigned long gregset_t[32];
14
15struct __riscv_f_ext_state {
16 unsigned int f[32];
17 unsigned int fcsr;
18};
19
20struct __riscv_d_ext_state {
21 unsigned long long f[32];
22 unsigned int fcsr;
23};
24
25struct __riscv_q_ext_state {
26 unsigned long long f[64] __attribute__((aligned(16)));
27 unsigned int fcsr;
28 unsigned int reserved[3];
29};
30
31union __riscv_fp_state {
32 struct __riscv_f_ext_state f;
33 struct __riscv_d_ext_state d;
34 struct __riscv_q_ext_state q;
35};
36
37typedef union __riscv_fp_state fpregset_t;
38
39typedef struct sigcontext {
40 gregset_t gregs;
41 fpregset_t fpregs;
42} mcontext_t;
43
44#else
45typedef struct {
46 unsigned long gregs[32];
47 unsigned long long fpregs[66];
48} mcontext_t;
49#endif
50
51struct sigaltstack {
52 void *ss_sp;
53 int ss_flags;
54 size_t ss_size;
55};
56
57typedef struct __ucontext
58{
59 unsigned long uc_flags;
60 struct __ucontext *uc_link;
61 stack_t uc_stack;
62 sigset_t uc_sigmask;
63 mcontext_t uc_mcontext;
64} ucontext_t;
65
66#define SA_NOCLDSTOP 1
67#define SA_NOCLDWAIT 2
68#define SA_SIGINFO 4
69#define SA_ONSTACK 0x08000000
70#define SA_RESTART 0x10000000
71#define SA_NODEFER 0x40000000
72#define SA_RESETHAND 0x80000000
73#define SA_RESTORER 0x04000000
74
75#endif
76
77#define SIGHUP 1
78#define SIGINT 2
79#define SIGQUIT 3
80#define SIGILL 4
81#define SIGTRAP 5
82#define SIGABRT 6
83#define SIGIOT SIGABRT
84#define SIGBUS 7
85#define SIGFPE 8
86#define SIGKILL 9
87#define SIGUSR1 10
88#define SIGSEGV 11
89#define SIGUSR2 12
90#define SIGPIPE 13
91#define SIGALRM 14
92#define SIGTERM 15
93#define SIGSTKFLT 16
94#define SIGCHLD 17
95#define SIGCONT 18
96#define SIGSTOP 19
97#define SIGTSTP 20
98#define SIGTTIN 21
99#define SIGTTOU 22
100#define SIGURG 23
101#define SIGXCPU 24
102#define SIGXFSZ 25
103#define SIGVTALRM 26
104#define SIGPROF 27
105#define SIGWINCH 28
106#define SIGIO 29
107#define SIGPOLL SIGIO
108#define SIGPWR 30
109#define SIGSYS 31
110#define SIGUNUSED SIGSYS
111
112#define _NSIG 65
lib/libc/musl/arch/riscv64/bits/socket.h created+19
......@@ -0,0 +1,19 @@
1#include <endian.h>
2
3struct msghdr {
4 void *msg_name;
5 socklen_t msg_namelen;
6 struct iovec *msg_iov;
7 int msg_iovlen, __pad1;
8 void *msg_control;
9 socklen_t msg_controllen;
10 int __pad2;
11 int msg_flags;
12};
13
14struct cmsghdr {
15 socklen_t cmsg_len;
16 int __pad1;
17 int cmsg_level;
18 int cmsg_type;
19};
lib/libc/musl/arch/riscv64/bits/stat.h created+18
......@@ -0,0 +1,18 @@
1struct stat {
2 dev_t st_dev;
3 ino_t st_ino;
4 mode_t st_mode;
5 nlink_t st_nlink;
6 uid_t st_uid;
7 gid_t st_gid;
8 dev_t st_rdev;
9 unsigned long __pad;
10 off_t st_size;
11 blksize_t st_blksize;
12 int __pad2;
13 blkcnt_t st_blocks;
14 struct timespec st_atim;
15 struct timespec st_mtim;
16 struct timespec st_ctim;
17 unsigned __unused[2];
18};
lib/libc/musl/arch/riscv64/bits/stdint.h created+20
......@@ -0,0 +1,20 @@
1typedef int32_t int_fast16_t;
2typedef int32_t int_fast32_t;
3typedef uint32_t uint_fast16_t;
4typedef uint32_t uint_fast32_t;
5
6#define INT_FAST16_MIN INT32_MIN
7#define INT_FAST32_MIN INT32_MIN
8
9#define INT_FAST16_MAX INT32_MAX
10#define INT_FAST32_MAX INT32_MAX
11
12#define UINT_FAST16_MAX UINT32_MAX
13#define UINT_FAST32_MAX UINT32_MAX
14
15#define INTPTR_MIN INT64_MIN
16#define INTPTR_MAX INT64_MAX
17#define UINTPTR_MAX UINT64_MAX
18#define PTRDIFF_MIN INT64_MIN
19#define PTRDIFF_MAX INT64_MAX
20#define SIZE_MAX UINT64_MAX
lib/libc/musl/arch/riscv64/bits/syscall.h.in created+277
......@@ -0,0 +1,277 @@
1#define __NR_io_setup 0
2#define __NR_io_destroy 1
3#define __NR_io_submit 2
4#define __NR_io_cancel 3
5#define __NR_io_getevents 4
6#define __NR_setxattr 5
7#define __NR_lsetxattr 6
8#define __NR_fsetxattr 7
9#define __NR_getxattr 8
10#define __NR_lgetxattr 9
11#define __NR_fgetxattr 10
12#define __NR_listxattr 11
13#define __NR_llistxattr 12
14#define __NR_flistxattr 13
15#define __NR_removexattr 14
16#define __NR_lremovexattr 15
17#define __NR_fremovexattr 16
18#define __NR_getcwd 17
19#define __NR_lookup_dcookie 18
20#define __NR_eventfd2 19
21#define __NR_epoll_create1 20
22#define __NR_epoll_ctl 21
23#define __NR_epoll_pwait 22
24#define __NR_dup 23
25#define __NR_dup3 24
26#define __NR_fcntl 25
27#define __NR_inotify_init1 26
28#define __NR_inotify_add_watch 27
29#define __NR_inotify_rm_watch 28
30#define __NR_ioctl 29
31#define __NR_ioprio_set 30
32#define __NR_ioprio_get 31
33#define __NR_flock 32
34#define __NR_mknodat 33
35#define __NR_mkdirat 34
36#define __NR_unlinkat 35
37#define __NR_symlinkat 36
38#define __NR_linkat 37
39#define __NR_umount2 39
40#define __NR_mount 40
41#define __NR_pivot_root 41
42#define __NR_nfsservctl 42
43#define __NR_statfs 43
44#define __NR_fstatfs 44
45#define __NR_truncate 45
46#define __NR_ftruncate 46
47#define __NR_fallocate 47
48#define __NR_faccessat 48
49#define __NR_chdir 49
50#define __NR_fchdir 50
51#define __NR_chroot 51
52#define __NR_fchmod 52
53#define __NR_fchmodat 53
54#define __NR_fchownat 54
55#define __NR_fchown 55
56#define __NR_openat 56
57#define __NR_close 57
58#define __NR_vhangup 58
59#define __NR_pipe2 59
60#define __NR_quotactl 60
61#define __NR_getdents64 61
62#define __NR_lseek 62
63#define __NR_read 63
64#define __NR_write 64
65#define __NR_readv 65
66#define __NR_writev 66
67#define __NR_pread64 67
68#define __NR_pwrite64 68
69#define __NR_preadv 69
70#define __NR_pwritev 70
71#define __NR_sendfile 71
72#define __NR_pselect6 72
73#define __NR_ppoll 73
74#define __NR_signalfd4 74
75#define __NR_vmsplice 75
76#define __NR_splice 76
77#define __NR_tee 77
78#define __NR_readlinkat 78
79#define __NR_fstatat 79
80#define __NR_fstat 80
81#define __NR_sync 81
82#define __NR_fsync 82
83#define __NR_fdatasync 83
84#define __NR_sync_file_range 84
85#define __NR_timerfd_create 85
86#define __NR_timerfd_settime 86
87#define __NR_timerfd_gettime 87
88#define __NR_utimensat 88
89#define __NR_acct 89
90#define __NR_capget 90
91#define __NR_capset 91
92#define __NR_personality 92
93#define __NR_exit 93
94#define __NR_exit_group 94
95#define __NR_waitid 95
96#define __NR_set_tid_address 96
97#define __NR_unshare 97
98#define __NR_futex 98
99#define __NR_set_robust_list 99
100#define __NR_get_robust_list 100
101#define __NR_nanosleep 101
102#define __NR_getitimer 102
103#define __NR_setitimer 103
104#define __NR_kexec_load 104
105#define __NR_init_module 105
106#define __NR_delete_module 106
107#define __NR_timer_create 107
108#define __NR_timer_gettime 108
109#define __NR_timer_getoverrun 109
110#define __NR_timer_settime 110
111#define __NR_timer_delete 111
112#define __NR_clock_settime 112
113#define __NR_clock_gettime 113
114#define __NR_clock_getres 114
115#define __NR_clock_nanosleep 115
116#define __NR_syslog 116
117#define __NR_ptrace 117
118#define __NR_sched_setparam 118
119#define __NR_sched_setscheduler 119
120#define __NR_sched_getscheduler 120
121#define __NR_sched_getparam 121
122#define __NR_sched_setaffinity 122
123#define __NR_sched_getaffinity 123
124#define __NR_sched_yield 124
125#define __NR_sched_get_priority_max 125
126#define __NR_sched_get_priority_min 126
127#define __NR_sched_rr_get_interval 127
128#define __NR_restart_syscall 128
129#define __NR_kill 129
130#define __NR_tkill 130
131#define __NR_tgkill 131
132#define __NR_sigaltstack 132
133#define __NR_rt_sigsuspend 133
134#define __NR_rt_sigaction 134
135#define __NR_rt_sigprocmask 135
136#define __NR_rt_sigpending 136
137#define __NR_rt_sigtimedwait 137
138#define __NR_rt_sigqueueinfo 138
139#define __NR_rt_sigreturn 139
140#define __NR_setpriority 140
141#define __NR_getpriority 141
142#define __NR_reboot 142
143#define __NR_setregid 143
144#define __NR_setgid 144
145#define __NR_setreuid 145
146#define __NR_setuid 146
147#define __NR_setresuid 147
148#define __NR_getresuid 148
149#define __NR_setresgid 149
150#define __NR_getresgid 150
151#define __NR_setfsuid 151
152#define __NR_setfsgid 152
153#define __NR_times 153
154#define __NR_setpgid 154
155#define __NR_getpgid 155
156#define __NR_getsid 156
157#define __NR_setsid 157
158#define __NR_getgroups 158
159#define __NR_setgroups 159
160#define __NR_uname 160
161#define __NR_sethostname 161
162#define __NR_setdomainname 162
163#define __NR_getrlimit 163
164#define __NR_setrlimit 164
165#define __NR_getrusage 165
166#define __NR_umask 166
167#define __NR_prctl 167
168#define __NR_getcpu 168
169#define __NR_gettimeofday 169
170#define __NR_settimeofday 170
171#define __NR_adjtimex 171
172#define __NR_getpid 172
173#define __NR_getppid 173
174#define __NR_getuid 174
175#define __NR_geteuid 175
176#define __NR_getgid 176
177#define __NR_getegid 177
178#define __NR_gettid 178
179#define __NR_sysinfo 179
180#define __NR_mq_open 180
181#define __NR_mq_unlink 181
182#define __NR_mq_timedsend 182
183#define __NR_mq_timedreceive 183
184#define __NR_mq_notify 184
185#define __NR_mq_getsetattr 185
186#define __NR_msgget 186
187#define __NR_msgctl 187
188#define __NR_msgrcv 188
189#define __NR_msgsnd 189
190#define __NR_semget 190
191#define __NR_semctl 191
192#define __NR_semtimedop 192
193#define __NR_semop 193
194#define __NR_shmget 194
195#define __NR_shmctl 195
196#define __NR_shmat 196
197#define __NR_shmdt 197
198#define __NR_socket 198
199#define __NR_socketpair 199
200#define __NR_bind 200
201#define __NR_listen 201
202#define __NR_accept 202
203#define __NR_connect 203
204#define __NR_getsockname 204
205#define __NR_getpeername 205
206#define __NR_sendto 206
207#define __NR_recvfrom 207
208#define __NR_setsockopt 208
209#define __NR_getsockopt 209
210#define __NR_shutdown 210
211#define __NR_sendmsg 211
212#define __NR_recvmsg 212
213#define __NR_readahead 213
214#define __NR_brk 214
215#define __NR_munmap 215
216#define __NR_mremap 216
217#define __NR_add_key 217
218#define __NR_request_key 218
219#define __NR_keyctl 219
220#define __NR_clone 220
221#define __NR_execve 221
222#define __NR_mmap 222
223#define __NR_fadvise64 223
224#define __NR_swapon 224
225#define __NR_swapoff 225
226#define __NR_mprotect 226
227#define __NR_msync 227
228#define __NR_mlock 228
229#define __NR_munlock 229
230#define __NR_mlockall 230
231#define __NR_munlockall 231
232#define __NR_mincore 232
233#define __NR_madvise 233
234#define __NR_remap_file_pages 234
235#define __NR_mbind 235
236#define __NR_get_mempolicy 236
237#define __NR_set_mempolicy 237
238#define __NR_migrate_pages 238
239#define __NR_move_pages 239
240#define __NR_rt_tgsigqueueinfo 240
241#define __NR_perf_event_open 241
242#define __NR_accept4 242
243#define __NR_recvmmsg 243
244#define __NR_arch_specific_syscall 244
245#define __NR_wait4 260
246#define __NR_prlimit64 261
247#define __NR_fanotify_init 262
248#define __NR_fanotify_mark 263
249#define __NR_name_to_handle_at 264
250#define __NR_open_by_handle_at 265
251#define __NR_clock_adjtime 266
252#define __NR_syncfs 267
253#define __NR_setns 268
254#define __NR_sendmmsg 269
255#define __NR_process_vm_readv 270
256#define __NR_process_vm_writev 271
257#define __NR_kcmp 272
258#define __NR_finit_module 273
259#define __NR_sched_setattr 274
260#define __NR_sched_getattr 275
261#define __NR_renameat2 276
262#define __NR_seccomp 277
263#define __NR_getrandom 278
264#define __NR_memfd_create 279
265#define __NR_bpf 280
266#define __NR_execveat 281
267#define __NR_userfaultfd 282
268#define __NR_membarrier 283
269#define __NR_mlock2 284
270#define __NR_copy_file_range 285
271#define __NR_preadv2 286
272#define __NR_pwritev2 287
273#define __NR_pkey_mprotect 288
274#define __NR_pkey_alloc 289
275#define __NR_pkey_free 290
276#define __NR_sysriscv __NR_arch_specific_syscall
277#define __NR_riscv_flush_icache (__NR_sysriscv + 15)
lib/libc/musl/arch/riscv64/bits/user.h created+43
......@@ -0,0 +1,43 @@
1struct user_regs_struct {
2 unsigned long pc;
3 unsigned long ra;
4 unsigned long sp;
5 unsigned long gp;
6 unsigned long tp;
7 unsigned long t0;
8 unsigned long t1;
9 unsigned long t2;
10 unsigned long s0;
11 unsigned long s1;
12 unsigned long a0;
13 unsigned long a1;
14 unsigned long a2;
15 unsigned long a3;
16 unsigned long a4;
17 unsigned long a5;
18 unsigned long a6;
19 unsigned long a7;
20 unsigned long s2;
21 unsigned long s3;
22 unsigned long s4;
23 unsigned long s5;
24 unsigned long s6;
25 unsigned long s7;
26 unsigned long s8;
27 unsigned long s9;
28 unsigned long s10;
29 unsigned long s11;
30 unsigned long t3;
31 unsigned long t4;
32 unsigned long t5;
33 unsigned long t6;
34};
35
36struct user_fpregs_struct {
37 double f[32];
38 unsigned int fcsr;
39};
40
41#define ELF_NGREG 32
42typedef unsigned long elf_greg_t, elf_gregset_t[ELF_NGREG];
43typedef struct user_fpregs_struct elf_fpregset_t;
lib/libc/musl/arch/riscv64/crt_arch.h created+19
......@@ -0,0 +1,19 @@
1__asm__(
2".section .sdata,\"aw\"\n"
3".text\n"
4".global " START "\n"
5".type " START ",%function\n"
6START ":\n"
7".weak __global_pointer$\n"
8".hidden __global_pointer$\n"
9".option push\n"
10".option norelax\n\t"
11"lla gp, __global_pointer$\n"
12".option pop\n\t"
13"mv a0, sp\n"
14".weak _DYNAMIC\n"
15".hidden _DYNAMIC\n\t"
16"lla a1, _DYNAMIC\n\t"
17"andi sp, sp, -16\n\t"
18"tail " START "_c"
19);
lib/libc/musl/arch/riscv64/pthread_arch.h created+14
......@@ -0,0 +1,14 @@
1static inline struct pthread *__pthread_self()
2{
3 char *tp;
4 __asm__ __volatile__("mv %0, tp" : "=r"(tp));
5 return (void *)(tp - sizeof(struct pthread));
6}
7
8#define TLS_ABOVE_TP
9#define GAP_ABOVE_TP 0
10#define TP_ADJ(p) ((char *)p + sizeof(struct pthread))
11
12#define DTP_OFFSET 0x800
13
14#define MC_PC gregs[0]
lib/libc/musl/arch/riscv64/reloc.h created+22
......@@ -0,0 +1,22 @@
1#if defined __riscv_float_abi_soft
2#define RISCV_FP_SUFFIX "-sf"
3#elif defined __riscv_float_abi_single
4#define RISCV_FP_SUFFIX "-sp"
5#elif defined __riscv_float_abi_double
6#define RISCV_FP_SUFFIX ""
7#endif
8
9#define LDSO_ARCH "riscv64" RISCV_FP_SUFFIX
10
11#define TPOFF_K 0
12
13#define REL_SYMBOLIC R_RISCV_64
14#define REL_PLT R_RISCV_JUMP_SLOT
15#define REL_RELATIVE R_RISCV_RELATIVE
16#define REL_COPY R_RISCV_COPY
17#define REL_DTPMOD R_RISCV_TLS_DTPMOD64
18#define REL_DTPOFF R_RISCV_TLS_DTPREL64
19#define REL_TPOFF R_RISCV_TLS_TPREL64
20
21#define CRTJMP(pc,sp) __asm__ __volatile__( \
22 "mv sp, %1 ; jr %0" : : "r"(pc), "r"(sp) : "memory" )
lib/libc/musl/arch/riscv64/syscall_arch.h created+76
......@@ -0,0 +1,76 @@
1#define __SYSCALL_LL_E(x) (x)
2#define __SYSCALL_LL_O(x) (x)
3
4#define __asm_syscall(...) \
5 __asm__ __volatile__ ("ecall\n\t" \
6 : "+r"(a0) : __VA_ARGS__ : "memory"); \
7 return a0; \
8
9static inline long __syscall0(long n)
10{
11 register long a7 __asm__("a7") = n;
12 register long a0 __asm__("a0");
13 __asm_syscall("r"(a7))
14}
15
16static inline long __syscall1(long n, long a)
17{
18 register long a7 __asm__("a7") = n;
19 register long a0 __asm__("a0") = a;
20 __asm_syscall("r"(a7), "0"(a0))
21}
22
23static inline long __syscall2(long n, long a, long b)
24{
25 register long a7 __asm__("a7") = n;
26 register long a0 __asm__("a0") = a;
27 register long a1 __asm__("a1") = b;
28 __asm_syscall("r"(a7), "0"(a0), "r"(a1))
29}
30
31static inline long __syscall3(long n, long a, long b, long c)
32{
33 register long a7 __asm__("a7") = n;
34 register long a0 __asm__("a0") = a;
35 register long a1 __asm__("a1") = b;
36 register long a2 __asm__("a2") = c;
37 __asm_syscall("r"(a7), "0"(a0), "r"(a1), "r"(a2))
38}
39
40static inline long __syscall4(long n, long a, long b, long c, long d)
41{
42 register long a7 __asm__("a7") = n;
43 register long a0 __asm__("a0") = a;
44 register long a1 __asm__("a1") = b;
45 register long a2 __asm__("a2") = c;
46 register long a3 __asm__("a3") = d;
47 __asm_syscall("r"(a7), "0"(a0), "r"(a1), "r"(a2), "r"(a3))
48}
49
50static inline long __syscall5(long n, long a, long b, long c, long d, long e)
51{
52 register long a7 __asm__("a7") = n;
53 register long a0 __asm__("a0") = a;
54 register long a1 __asm__("a1") = b;
55 register long a2 __asm__("a2") = c;
56 register long a3 __asm__("a3") = d;
57 register long a4 __asm__("a4") = e;
58 __asm_syscall("r"(a7), "0"(a0), "r"(a1), "r"(a2), "r"(a3), "r"(a4))
59}
60
61static inline long __syscall6(long n, long a, long b, long c, long d, long e, long f)
62{
63 register long a7 __asm__("a7") = n;
64 register long a0 __asm__("a0") = a;
65 register long a1 __asm__("a1") = b;
66 register long a2 __asm__("a2") = c;
67 register long a3 __asm__("a3") = d;
68 register long a4 __asm__("a4") = e;
69 register long a5 __asm__("a5") = f;
70 __asm_syscall("r"(a7), "0"(a0), "r"(a1), "r"(a2), "r"(a3), "r"(a4), "r"(a5))
71}
72
73#define VDSO_USEFUL
74/* We don't have a clock_gettime function.
75#define VDSO_CGT_SYM "__vdso_clock_gettime"
76#define VDSO_CGT_VER "LINUX_2.6" */
lib/libc/musl/arch/s390x/bits/fcntl.h+3
......@@ -38,3 +38,6 @@
3838#define F_GETOWN_EX 16
3939
4040#define F_GETOWNER_UIDS 17
41
42#define POSIX_FADV_DONTNEED 6
43#define POSIX_FADV_NOREUSE 7
lib/libc/musl/arch/s390x/bits/socket.h-27
......@@ -15,30 +15,3 @@ struct cmsghdr {
1515 int cmsg_level;
1616 int cmsg_type;
1717};
18
19#define SO_DEBUG 1
20#define SO_REUSEADDR 2
21#define SO_TYPE 3
22#define SO_ERROR 4
23#define SO_DONTROUTE 5
24#define SO_BROADCAST 6
25#define SO_SNDBUF 7
26#define SO_RCVBUF 8
27#define SO_KEEPALIVE 9
28#define SO_OOBINLINE 10
29#define SO_NO_CHECK 11
30#define SO_PRIORITY 12
31#define SO_LINGER 13
32#define SO_BSDCOMPAT 14
33#define SO_REUSEPORT 15
34#define SO_PASSCRED 16
35#define SO_PEERCRED 17
36#define SO_RCVLOWAT 18
37#define SO_SNDLOWAT 19
38#define SO_RCVTIMEO 20
39#define SO_SNDTIMEO 21
40#define SO_ACCEPTCONN 30
41#define SO_SNDBUFFORCE 32
42#define SO_RCVBUFFORCE 33
43#define SO_PROTOCOL 38
44#define SO_DOMAIN 39
lib/libc/musl/arch/s390x/bits/syscall.h.in+18
......@@ -326,4 +326,22 @@
326326#define __NR_kexec_file_load 381
327327#define __NR_io_pgetevents 382
328328#define __NR_rseq 383
329#define __NR_pkey_mprotect 384
330#define __NR_pkey_alloc 385
331#define __NR_pkey_free 386
332#define __NR_semtimedop 392
333#define __NR_semget 393
334#define __NR_semctl 394
335#define __NR_shmget 395
336#define __NR_shmctl 396
337#define __NR_shmat 397
338#define __NR_shmdt 398
339#define __NR_msgget 399
340#define __NR_msgsnd 400
341#define __NR_msgrcv 401
342#define __NR_msgctl 402
343#define __NR_pidfd_send_signal 424
344#define __NR_io_uring_setup 425
345#define __NR_io_uring_enter 426
346#define __NR_io_uring_register 427
329347
lib/libc/musl/arch/x86_64/bits/syscall.h.in+4
......@@ -333,4 +333,8 @@
333333#define __NR_statx 332
334334#define __NR_io_pgetevents 333
335335#define __NR_rseq 334
336#define __NR_pidfd_send_signal 424
337#define __NR_io_uring_setup 425
338#define __NR_io_uring_enter 426
339#define __NR_io_uring_register 427
336340
lib/libc/musl/crt/crt1.c+1-1
......@@ -8,7 +8,7 @@
88int main();
99weak void _init();
1010weak void _fini();
11_Noreturn int __libc_start_main(int (*)(), int, char **,
11int __libc_start_main(int (*)(), int, char **,
1212 void (*)(), void(*)(), void(*)());
1313
1414void _start_c(long *p)
lib/libc/musl/crt/rcrt1.c+2-2
......@@ -5,10 +5,10 @@
55int main();
66weak void _init();
77weak void _fini();
8_Noreturn int __libc_start_main(int (*)(), int, char **,
8int __libc_start_main(int (*)(), int, char **,
99 void (*)(), void(*)(), void(*)());
1010
11hidden _Noreturn void __dls2(unsigned char *base, size_t *sp)
11hidden void __dls2(unsigned char *base, size_t *sp)
1212{
1313 __libc_start_main(main, *sp, (void *)(sp+1), _init, _fini, 0);
1414}
lib/libc/musl/include/aio.h created+69
......@@ -0,0 +1,69 @@
1#ifndef _AIO_H
2#define _AIO_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9#include <signal.h>
10#include <time.h>
11
12#define __NEED_ssize_t
13#define __NEED_off_t
14
15#include <bits/alltypes.h>
16
17struct aiocb {
18 int aio_fildes, aio_lio_opcode, aio_reqprio;
19 volatile void *aio_buf;
20 size_t aio_nbytes;
21 struct sigevent aio_sigevent;
22 void *__td;
23 int __lock[2];
24 volatile int __err;
25 ssize_t __ret;
26 off_t aio_offset;
27 void *__next, *__prev;
28 char __dummy4[32-2*sizeof(void *)];
29};
30
31#define AIO_CANCELED 0
32#define AIO_NOTCANCELED 1
33#define AIO_ALLDONE 2
34
35#define LIO_READ 0
36#define LIO_WRITE 1
37#define LIO_NOP 2
38
39#define LIO_WAIT 0
40#define LIO_NOWAIT 1
41
42int aio_read(struct aiocb *);
43int aio_write(struct aiocb *);
44int aio_error(const struct aiocb *);
45ssize_t aio_return(struct aiocb *);
46int aio_cancel(int, struct aiocb *);
47int aio_suspend(const struct aiocb *const [], int, const struct timespec *);
48int aio_fsync(int, struct aiocb *);
49
50int lio_listio(int, struct aiocb *__restrict const *__restrict, int, struct sigevent *__restrict);
51
52#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
53#define aiocb64 aiocb
54#define aio_read64 aio_read
55#define aio_write64 aio_write
56#define aio_error64 aio_error
57#define aio_return64 aio_return
58#define aio_cancel64 aio_cancel
59#define aio_suspend64 aio_suspend
60#define aio_fsync64 aio_fsync
61#define lio_listio64 lio_listio
62#define off64_t off_t
63#endif
64
65#ifdef __cplusplus
66}
67#endif
68
69#endif
lib/libc/musl/include/alloca.h created+21
......@@ -0,0 +1,21 @@
1#ifndef _ALLOCA_H
2#define _ALLOCA_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define __NEED_size_t
9#include <bits/alltypes.h>
10
11void *alloca(size_t);
12
13#ifdef __GNUC__
14#define alloca __builtin_alloca
15#endif
16
17#ifdef __cplusplus
18}
19#endif
20
21#endif
lib/libc/musl/include/alltypes.h.in created+76
......@@ -0,0 +1,76 @@
1TYPEDEF unsigned _Addr size_t;
2TYPEDEF unsigned _Addr uintptr_t;
3TYPEDEF _Addr ptrdiff_t;
4TYPEDEF _Addr ssize_t;
5TYPEDEF _Addr intptr_t;
6TYPEDEF _Addr regoff_t;
7TYPEDEF _Reg register_t;
8
9TYPEDEF signed char int8_t;
10TYPEDEF signed short int16_t;
11TYPEDEF signed int int32_t;
12TYPEDEF signed _Int64 int64_t;
13TYPEDEF signed _Int64 intmax_t;
14TYPEDEF unsigned char uint8_t;
15TYPEDEF unsigned short uint16_t;
16TYPEDEF unsigned int uint32_t;
17TYPEDEF unsigned _Int64 uint64_t;
18TYPEDEF unsigned _Int64 u_int64_t;
19TYPEDEF unsigned _Int64 uintmax_t;
20
21TYPEDEF unsigned mode_t;
22TYPEDEF unsigned _Reg nlink_t;
23TYPEDEF _Int64 off_t;
24TYPEDEF unsigned _Int64 ino_t;
25TYPEDEF unsigned _Int64 dev_t;
26TYPEDEF long blksize_t;
27TYPEDEF _Int64 blkcnt_t;
28TYPEDEF unsigned _Int64 fsblkcnt_t;
29TYPEDEF unsigned _Int64 fsfilcnt_t;
30
31TYPEDEF unsigned wint_t;
32TYPEDEF unsigned long wctype_t;
33
34TYPEDEF void * timer_t;
35TYPEDEF int clockid_t;
36TYPEDEF long clock_t;
37STRUCT timeval { time_t tv_sec; suseconds_t tv_usec; };
38STRUCT timespec { time_t tv_sec; long tv_nsec; };
39
40TYPEDEF int pid_t;
41TYPEDEF unsigned id_t;
42TYPEDEF unsigned uid_t;
43TYPEDEF unsigned gid_t;
44TYPEDEF int key_t;
45TYPEDEF unsigned useconds_t;
46
47#ifdef __cplusplus
48TYPEDEF unsigned long pthread_t;
49#else
50TYPEDEF struct __pthread * pthread_t;
51#endif
52TYPEDEF int pthread_once_t;
53TYPEDEF unsigned pthread_key_t;
54TYPEDEF int pthread_spinlock_t;
55TYPEDEF struct { unsigned __attr; } pthread_mutexattr_t;
56TYPEDEF struct { unsigned __attr; } pthread_condattr_t;
57TYPEDEF struct { unsigned __attr; } pthread_barrierattr_t;
58TYPEDEF struct { unsigned __attr[2]; } pthread_rwlockattr_t;
59
60STRUCT _IO_FILE { char __x; };
61TYPEDEF struct _IO_FILE FILE;
62
63TYPEDEF struct __mbstate_t { unsigned __opaque1, __opaque2; } mbstate_t;
64
65TYPEDEF struct __locale_struct * locale_t;
66
67TYPEDEF struct __sigset_t { unsigned long __bits[128/sizeof(long)]; } sigset_t;
68
69STRUCT iovec { void *iov_base; size_t iov_len; };
70
71TYPEDEF unsigned socklen_t;
72TYPEDEF unsigned short sa_family_t;
73
74#undef _Addr
75#undef _Int64
76#undef _Reg
lib/libc/musl/include/ar.h created+25
......@@ -0,0 +1,25 @@
1#ifndef _AR_H
2#define _AR_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define ARMAG "!<arch>\n"
9#define SARMAG 8
10#define ARFMAG "`\n"
11
12struct ar_hdr {
13 char ar_name[16];
14 char ar_date[12];
15 char ar_uid[6], ar_gid[6];
16 char ar_mode[8];
17 char ar_size[10];
18 char ar_fmag[2];
19};
20
21#ifdef __cplusplus
22}
23#endif
24
25#endif
lib/libc/musl/include/arpa/ftp.h created+35
......@@ -0,0 +1,35 @@
1#ifndef _ARPA_FTP_H
2#define _ARPA_FTP_H
3#define PRELIM 1
4#define COMPLETE 2
5#define CONTINUE 3
6#define TRANSIENT 4
7#define ERROR 5
8#define TYPE_A 1
9#define TYPE_E 2
10#define TYPE_I 3
11#define TYPE_L 4
12#define FORM_N 1
13#define FORM_T 2
14#define FORM_C 3
15#define STRU_F 1
16#define STRU_R 2
17#define STRU_P 3
18#define MODE_S 1
19#define MODE_B 2
20#define MODE_C 3
21#define REC_ESC '\377'
22#define REC_EOR '\001'
23#define REC_EOF '\002'
24#define BLK_EOR 0x80
25#define BLK_EOF 0x40
26#define BLK_ERRORS 0x20
27#define BLK_RESTART 0x10
28#define BLK_BYTECOUNT 2
29#ifdef FTP_NAMES
30char *modenames[] = {"0", "Stream", "Block", "Compressed" };
31char *strunames[] = {"0", "File", "Record", "Page" };
32char *typenames[] = {"0", "ASCII", "EBCDIC", "Image", "Local" };
33char *formnames[] = {"0", "Nonprint", "Telnet", "Carriage-control" };
34#endif
35#endif
lib/libc/musl/include/arpa/inet.h created+36
......@@ -0,0 +1,36 @@
1#ifndef _ARPA_INET_H
2#define _ARPA_INET_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9#include <netinet/in.h>
10
11uint32_t htonl(uint32_t);
12uint16_t htons(uint16_t);
13uint32_t ntohl(uint32_t);
14uint16_t ntohs(uint16_t);
15
16in_addr_t inet_addr (const char *);
17in_addr_t inet_network (const char *);
18char *inet_ntoa (struct in_addr);
19int inet_pton (int, const char *__restrict, void *__restrict);
20const char *inet_ntop (int, const void *__restrict, char *__restrict, socklen_t);
21
22int inet_aton (const char *, struct in_addr *);
23struct in_addr inet_makeaddr(in_addr_t, in_addr_t);
24in_addr_t inet_lnaof(struct in_addr);
25in_addr_t inet_netof(struct in_addr);
26
27#undef INET_ADDRSTRLEN
28#undef INET6_ADDRSTRLEN
29#define INET_ADDRSTRLEN 16
30#define INET6_ADDRSTRLEN 46
31
32#ifdef __cplusplus
33}
34#endif
35
36#endif
lib/libc/musl/include/arpa/nameser.h created+456
......@@ -0,0 +1,456 @@
1#ifndef _ARPA_NAMESER_H
2#define _ARPA_NAMESER_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stddef.h>
9#include <stdint.h>
10#include <endian.h>
11
12#define __NAMESER 19991006
13#define NS_PACKETSZ 512
14#define NS_MAXDNAME 1025
15#define NS_MAXMSG 65535
16#define NS_MAXCDNAME 255
17#define NS_MAXLABEL 63
18#define NS_HFIXEDSZ 12
19#define NS_QFIXEDSZ 4
20#define NS_RRFIXEDSZ 10
21#define NS_INT32SZ 4
22#define NS_INT16SZ 2
23#define NS_INT8SZ 1
24#define NS_INADDRSZ 4
25#define NS_IN6ADDRSZ 16
26#define NS_CMPRSFLGS 0xc0
27#define NS_DEFAULTPORT 53
28
29typedef enum __ns_sect {
30 ns_s_qd = 0,
31 ns_s_zn = 0,
32 ns_s_an = 1,
33 ns_s_pr = 1,
34 ns_s_ns = 2,
35 ns_s_ud = 2,
36 ns_s_ar = 3,
37 ns_s_max = 4
38} ns_sect;
39
40typedef struct __ns_msg {
41 const unsigned char *_msg, *_eom;
42 uint16_t _id, _flags, _counts[ns_s_max];
43 const unsigned char *_sections[ns_s_max];
44 ns_sect _sect;
45 int _rrnum;
46 const unsigned char *_msg_ptr;
47} ns_msg;
48
49struct _ns_flagdata { int mask, shift; };
50extern const struct _ns_flagdata _ns_flagdata[];
51
52#define ns_msg_id(handle) ((handle)._id + 0)
53#define ns_msg_base(handle) ((handle)._msg + 0)
54#define ns_msg_end(handle) ((handle)._eom + 0)
55#define ns_msg_size(handle) ((handle)._eom - (handle)._msg)
56#define ns_msg_count(handle, section) ((handle)._counts[section] + 0)
57#define ns_msg_getflag(handle, flag) \
58 (((handle)._flags & _ns_flagdata[flag].mask) >> _ns_flagdata[flag].shift)
59
60typedef struct __ns_rr {
61 char name[NS_MAXDNAME];
62 uint16_t type;
63 uint16_t rr_class;
64 uint32_t ttl;
65 uint16_t rdlength;
66 const unsigned char *rdata;
67} ns_rr;
68
69#define ns_rr_name(rr) (((rr).name[0] != '\0') ? (rr).name : ".")
70#define ns_rr_type(rr) ((ns_type)((rr).type + 0))
71#define ns_rr_class(rr) ((ns_class)((rr).rr_class + 0))
72#define ns_rr_ttl(rr) ((rr).ttl + 0)
73#define ns_rr_rdlen(rr) ((rr).rdlength + 0)
74#define ns_rr_rdata(rr) ((rr).rdata + 0)
75
76typedef enum __ns_flag {
77 ns_f_qr,
78 ns_f_opcode,
79 ns_f_aa,
80 ns_f_tc,
81 ns_f_rd,
82 ns_f_ra,
83 ns_f_z,
84 ns_f_ad,
85 ns_f_cd,
86 ns_f_rcode,
87 ns_f_max
88} ns_flag;
89
90typedef enum __ns_opcode {
91 ns_o_query = 0,
92 ns_o_iquery = 1,
93 ns_o_status = 2,
94 ns_o_notify = 4,
95 ns_o_update = 5,
96 ns_o_max = 6
97} ns_opcode;
98
99typedef enum __ns_rcode {
100 ns_r_noerror = 0,
101 ns_r_formerr = 1,
102 ns_r_servfail = 2,
103 ns_r_nxdomain = 3,
104 ns_r_notimpl = 4,
105 ns_r_refused = 5,
106 ns_r_yxdomain = 6,
107 ns_r_yxrrset = 7,
108 ns_r_nxrrset = 8,
109 ns_r_notauth = 9,
110 ns_r_notzone = 10,
111 ns_r_max = 11,
112 ns_r_badvers = 16,
113 ns_r_badsig = 16,
114 ns_r_badkey = 17,
115 ns_r_badtime = 18
116} ns_rcode;
117
118typedef enum __ns_update_operation {
119 ns_uop_delete = 0,
120 ns_uop_add = 1,
121 ns_uop_max = 2
122} ns_update_operation;
123
124struct ns_tsig_key {
125 char name[NS_MAXDNAME], alg[NS_MAXDNAME];
126 unsigned char *data;
127 int len;
128};
129typedef struct ns_tsig_key ns_tsig_key;
130
131struct ns_tcp_tsig_state {
132 int counter;
133 struct dst_key *key;
134 void *ctx;
135 unsigned char sig[NS_PACKETSZ];
136 int siglen;
137};
138typedef struct ns_tcp_tsig_state ns_tcp_tsig_state;
139
140#define NS_TSIG_FUDGE 300
141#define NS_TSIG_TCP_COUNT 100
142#define NS_TSIG_ALG_HMAC_MD5 "HMAC-MD5.SIG-ALG.REG.INT"
143
144#define NS_TSIG_ERROR_NO_TSIG -10
145#define NS_TSIG_ERROR_NO_SPACE -11
146#define NS_TSIG_ERROR_FORMERR -12
147
148typedef enum __ns_type {
149 ns_t_invalid = 0,
150 ns_t_a = 1,
151 ns_t_ns = 2,
152 ns_t_md = 3,
153 ns_t_mf = 4,
154 ns_t_cname = 5,
155 ns_t_soa = 6,
156 ns_t_mb = 7,
157 ns_t_mg = 8,
158 ns_t_mr = 9,
159 ns_t_null = 10,
160 ns_t_wks = 11,
161 ns_t_ptr = 12,
162 ns_t_hinfo = 13,
163 ns_t_minfo = 14,
164 ns_t_mx = 15,
165 ns_t_txt = 16,
166 ns_t_rp = 17,
167 ns_t_afsdb = 18,
168 ns_t_x25 = 19,
169 ns_t_isdn = 20,
170 ns_t_rt = 21,
171 ns_t_nsap = 22,
172 ns_t_nsap_ptr = 23,
173 ns_t_sig = 24,
174 ns_t_key = 25,
175 ns_t_px = 26,
176 ns_t_gpos = 27,
177 ns_t_aaaa = 28,
178 ns_t_loc = 29,
179 ns_t_nxt = 30,
180 ns_t_eid = 31,
181 ns_t_nimloc = 32,
182 ns_t_srv = 33,
183 ns_t_atma = 34,
184 ns_t_naptr = 35,
185 ns_t_kx = 36,
186 ns_t_cert = 37,
187 ns_t_a6 = 38,
188 ns_t_dname = 39,
189 ns_t_sink = 40,
190 ns_t_opt = 41,
191 ns_t_apl = 42,
192 ns_t_tkey = 249,
193 ns_t_tsig = 250,
194 ns_t_ixfr = 251,
195 ns_t_axfr = 252,
196 ns_t_mailb = 253,
197 ns_t_maila = 254,
198 ns_t_any = 255,
199 ns_t_zxfr = 256,
200 ns_t_max = 65536
201} ns_type;
202
203#define ns_t_qt_p(t) (ns_t_xfr_p(t) || (t) == ns_t_any || \
204 (t) == ns_t_mailb || (t) == ns_t_maila)
205#define ns_t_mrr_p(t) ((t) == ns_t_tsig || (t) == ns_t_opt)
206#define ns_t_rr_p(t) (!ns_t_qt_p(t) && !ns_t_mrr_p(t))
207#define ns_t_udp_p(t) ((t) != ns_t_axfr && (t) != ns_t_zxfr)
208#define ns_t_xfr_p(t) ((t) == ns_t_axfr || (t) == ns_t_ixfr || \
209 (t) == ns_t_zxfr)
210
211typedef enum __ns_class {
212 ns_c_invalid = 0,
213 ns_c_in = 1,
214 ns_c_2 = 2,
215 ns_c_chaos = 3,
216 ns_c_hs = 4,
217 ns_c_none = 254,
218 ns_c_any = 255,
219 ns_c_max = 65536
220} ns_class;
221
222typedef enum __ns_key_types {
223 ns_kt_rsa = 1,
224 ns_kt_dh = 2,
225 ns_kt_dsa = 3,
226 ns_kt_private = 254
227} ns_key_types;
228
229typedef enum __ns_cert_types {
230 cert_t_pkix = 1,
231 cert_t_spki = 2,
232 cert_t_pgp = 3,
233 cert_t_url = 253,
234 cert_t_oid = 254
235} ns_cert_types;
236
237#define NS_KEY_TYPEMASK 0xC000
238#define NS_KEY_TYPE_AUTH_CONF 0x0000
239#define NS_KEY_TYPE_CONF_ONLY 0x8000
240#define NS_KEY_TYPE_AUTH_ONLY 0x4000
241#define NS_KEY_TYPE_NO_KEY 0xC000
242#define NS_KEY_NO_AUTH 0x8000
243#define NS_KEY_NO_CONF 0x4000
244#define NS_KEY_RESERVED2 0x2000
245#define NS_KEY_EXTENDED_FLAGS 0x1000
246#define NS_KEY_RESERVED4 0x0800
247#define NS_KEY_RESERVED5 0x0400
248#define NS_KEY_NAME_TYPE 0x0300
249#define NS_KEY_NAME_USER 0x0000
250#define NS_KEY_NAME_ENTITY 0x0200
251#define NS_KEY_NAME_ZONE 0x0100
252#define NS_KEY_NAME_RESERVED 0x0300
253#define NS_KEY_RESERVED8 0x0080
254#define NS_KEY_RESERVED9 0x0040
255#define NS_KEY_RESERVED10 0x0020
256#define NS_KEY_RESERVED11 0x0010
257#define NS_KEY_SIGNATORYMASK 0x000F
258#define NS_KEY_RESERVED_BITMASK ( NS_KEY_RESERVED2 | \
259 NS_KEY_RESERVED4 | \
260 NS_KEY_RESERVED5 | \
261 NS_KEY_RESERVED8 | \
262 NS_KEY_RESERVED9 | \
263 NS_KEY_RESERVED10 | \
264 NS_KEY_RESERVED11 )
265#define NS_KEY_RESERVED_BITMASK2 0xFFFF
266#define NS_ALG_MD5RSA 1
267#define NS_ALG_DH 2
268#define NS_ALG_DSA 3
269#define NS_ALG_DSS NS_ALG_DSA
270#define NS_ALG_EXPIRE_ONLY 253
271#define NS_ALG_PRIVATE_OID 254
272
273#define NS_KEY_PROT_TLS 1
274#define NS_KEY_PROT_EMAIL 2
275#define NS_KEY_PROT_DNSSEC 3
276#define NS_KEY_PROT_IPSEC 4
277#define NS_KEY_PROT_ANY 255
278
279#define NS_MD5RSA_MIN_BITS 512
280#define NS_MD5RSA_MAX_BITS 4096
281#define NS_MD5RSA_MAX_BYTES ((NS_MD5RSA_MAX_BITS+7/8)*2+3)
282#define NS_MD5RSA_MAX_BASE64 (((NS_MD5RSA_MAX_BYTES+2)/3)*4)
283#define NS_MD5RSA_MIN_SIZE ((NS_MD5RSA_MIN_BITS+7)/8)
284#define NS_MD5RSA_MAX_SIZE ((NS_MD5RSA_MAX_BITS+7)/8)
285
286#define NS_DSA_SIG_SIZE 41
287#define NS_DSA_MIN_SIZE 213
288#define NS_DSA_MAX_BYTES 405
289
290#define NS_SIG_TYPE 0
291#define NS_SIG_ALG 2
292#define NS_SIG_LABELS 3
293#define NS_SIG_OTTL 4
294#define NS_SIG_EXPIR 8
295#define NS_SIG_SIGNED 12
296#define NS_SIG_FOOT 16
297#define NS_SIG_SIGNER 18
298#define NS_NXT_BITS 8
299#define NS_NXT_BIT_SET( n,p) (p[(n)/NS_NXT_BITS] |= (0x80>>((n)%NS_NXT_BITS)))
300#define NS_NXT_BIT_CLEAR(n,p) (p[(n)/NS_NXT_BITS] &= ~(0x80>>((n)%NS_NXT_BITS)))
301#define NS_NXT_BIT_ISSET(n,p) (p[(n)/NS_NXT_BITS] & (0x80>>((n)%NS_NXT_BITS)))
302#define NS_NXT_MAX 127
303
304#define NS_OPT_DNSSEC_OK 0x8000U
305#define NS_OPT_NSID 3
306
307#define NS_GET16(s, cp) (void)((s) = ns_get16(((cp)+=2)-2))
308#define NS_GET32(l, cp) (void)((l) = ns_get32(((cp)+=4)-4))
309#define NS_PUT16(s, cp) ns_put16((s), ((cp)+=2)-2)
310#define NS_PUT32(l, cp) ns_put32((l), ((cp)+=4)-4)
311
312unsigned ns_get16(const unsigned char *);
313unsigned long ns_get32(const unsigned char *);
314void ns_put16(unsigned, unsigned char *);
315void ns_put32(unsigned long, unsigned char *);
316
317int ns_initparse(const unsigned char *, int, ns_msg *);
318int ns_parserr(ns_msg *, ns_sect, int, ns_rr *);
319int ns_skiprr(const unsigned char *, const unsigned char *, ns_sect, int);
320int ns_name_uncompress(const unsigned char *, const unsigned char *, const unsigned char *, char *, size_t);
321
322
323#define __BIND 19950621
324
325typedef struct {
326 unsigned id :16;
327#if __BYTE_ORDER == __BIG_ENDIAN
328 unsigned qr: 1;
329 unsigned opcode: 4;
330 unsigned aa: 1;
331 unsigned tc: 1;
332 unsigned rd: 1;
333 unsigned ra: 1;
334 unsigned unused :1;
335 unsigned ad: 1;
336 unsigned cd: 1;
337 unsigned rcode :4;
338#else
339 unsigned rd :1;
340 unsigned tc :1;
341 unsigned aa :1;
342 unsigned opcode :4;
343 unsigned qr :1;
344 unsigned rcode :4;
345 unsigned cd: 1;
346 unsigned ad: 1;
347 unsigned unused :1;
348 unsigned ra :1;
349#endif
350 unsigned qdcount :16;
351 unsigned ancount :16;
352 unsigned nscount :16;
353 unsigned arcount :16;
354} HEADER;
355
356#define PACKETSZ NS_PACKETSZ
357#define MAXDNAME NS_MAXDNAME
358#define MAXCDNAME NS_MAXCDNAME
359#define MAXLABEL NS_MAXLABEL
360#define HFIXEDSZ NS_HFIXEDSZ
361#define QFIXEDSZ NS_QFIXEDSZ
362#define RRFIXEDSZ NS_RRFIXEDSZ
363#define INT32SZ NS_INT32SZ
364#define INT16SZ NS_INT16SZ
365#define INT8SZ NS_INT8SZ
366#define INADDRSZ NS_INADDRSZ
367#define IN6ADDRSZ NS_IN6ADDRSZ
368#define INDIR_MASK NS_CMPRSFLGS
369#define NAMESERVER_PORT NS_DEFAULTPORT
370
371#define S_ZONE ns_s_zn
372#define S_PREREQ ns_s_pr
373#define S_UPDATE ns_s_ud
374#define S_ADDT ns_s_ar
375
376#define QUERY ns_o_query
377#define IQUERY ns_o_iquery
378#define STATUS ns_o_status
379#define NS_NOTIFY_OP ns_o_notify
380#define NS_UPDATE_OP ns_o_update
381
382#define NOERROR ns_r_noerror
383#define FORMERR ns_r_formerr
384#define SERVFAIL ns_r_servfail
385#define NXDOMAIN ns_r_nxdomain
386#define NOTIMP ns_r_notimpl
387#define REFUSED ns_r_refused
388#define YXDOMAIN ns_r_yxdomain
389#define YXRRSET ns_r_yxrrset
390#define NXRRSET ns_r_nxrrset
391#define NOTAUTH ns_r_notauth
392#define NOTZONE ns_r_notzone
393
394#define DELETE ns_uop_delete
395#define ADD ns_uop_add
396
397#define T_A ns_t_a
398#define T_NS ns_t_ns
399#define T_MD ns_t_md
400#define T_MF ns_t_mf
401#define T_CNAME ns_t_cname
402#define T_SOA ns_t_soa
403#define T_MB ns_t_mb
404#define T_MG ns_t_mg
405#define T_MR ns_t_mr
406#define T_NULL ns_t_null
407#define T_WKS ns_t_wks
408#define T_PTR ns_t_ptr
409#define T_HINFO ns_t_hinfo
410#define T_MINFO ns_t_minfo
411#define T_MX ns_t_mx
412#define T_TXT ns_t_txt
413#define T_RP ns_t_rp
414#define T_AFSDB ns_t_afsdb
415#define T_X25 ns_t_x25
416#define T_ISDN ns_t_isdn
417#define T_RT ns_t_rt
418#define T_NSAP ns_t_nsap
419#define T_NSAP_PTR ns_t_nsap_ptr
420#define T_SIG ns_t_sig
421#define T_KEY ns_t_key
422#define T_PX ns_t_px
423#define T_GPOS ns_t_gpos
424#define T_AAAA ns_t_aaaa
425#define T_LOC ns_t_loc
426#define T_NXT ns_t_nxt
427#define T_EID ns_t_eid
428#define T_NIMLOC ns_t_nimloc
429#define T_SRV ns_t_srv
430#define T_ATMA ns_t_atma
431#define T_NAPTR ns_t_naptr
432#define T_A6 ns_t_a6
433#define T_DNAME ns_t_dname
434#define T_TSIG ns_t_tsig
435#define T_IXFR ns_t_ixfr
436#define T_AXFR ns_t_axfr
437#define T_MAILB ns_t_mailb
438#define T_MAILA ns_t_maila
439#define T_ANY ns_t_any
440
441#define C_IN ns_c_in
442#define C_CHAOS ns_c_chaos
443#define C_HS ns_c_hs
444#define C_NONE ns_c_none
445#define C_ANY ns_c_any
446
447#define GETSHORT NS_GET16
448#define GETLONG NS_GET32
449#define PUTSHORT NS_PUT16
450#define PUTLONG NS_PUT32
451
452#ifdef __cplusplus
453}
454#endif
455
456#endif
lib/libc/musl/include/arpa/nameser_compat.h created+2
......@@ -0,0 +1,2 @@
1#include <arpa/nameser.h>
2
lib/libc/musl/include/arpa/telnet.h created+251
......@@ -0,0 +1,251 @@
1#ifndef _ARPA_TELNET_H
2#define _ARPA_TELNET_H
3
4#define IAC 255
5#define DONT 254
6#define DO 253
7#define WONT 252
8#define WILL 251
9#define SB 250
10#define GA 249
11#define EL 248
12#define EC 247
13#define AYT 246
14#define AO 245
15#define IP 244
16#define BREAK 243
17#define DM 242
18#define NOP 241
19#define SE 240
20#define EOR 239
21#define ABORT 238
22#define SUSP 237
23#define xEOF 236
24
25#define SYNCH 242
26
27#define telcmds ((char [][6]){ "EOF", "SUSP", "ABORT", "EOR", "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC", "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0 })
28
29#define TELCMD_FIRST xEOF
30#define TELCMD_LAST IAC
31#define TELCMD_OK(x) ((unsigned int)(x) <= TELCMD_LAST && \
32 (unsigned int)(x) >= TELCMD_FIRST)
33#define TELCMD(x) telcmds[(x)-TELCMD_FIRST]
34
35#define TELOPT_BINARY 0
36#define TELOPT_ECHO 1
37#define TELOPT_RCP 2
38#define TELOPT_SGA 3
39#define TELOPT_NAMS 4
40#define TELOPT_STATUS 5
41#define TELOPT_TM 6
42#define TELOPT_RCTE 7
43#define TELOPT_NAOL 8
44#define TELOPT_NAOP 9
45#define TELOPT_NAOCRD 10
46#define TELOPT_NAOHTS 11
47#define TELOPT_NAOHTD 12
48#define TELOPT_NAOFFD 13
49#define TELOPT_NAOVTS 14
50#define TELOPT_NAOVTD 15
51#define TELOPT_NAOLFD 16
52#define TELOPT_XASCII 17
53#define TELOPT_LOGOUT 18
54#define TELOPT_BM 19
55#define TELOPT_DET 20
56#define TELOPT_SUPDUP 21
57#define TELOPT_SUPDUPOUTPUT 22
58#define TELOPT_SNDLOC 23
59#define TELOPT_TTYPE 24
60#define TELOPT_EOR 25
61#define TELOPT_TUID 26
62#define TELOPT_OUTMRK 27
63#define TELOPT_TTYLOC 28
64#define TELOPT_3270REGIME 29
65#define TELOPT_X3PAD 30
66#define TELOPT_NAWS 31
67#define TELOPT_TSPEED 32
68#define TELOPT_LFLOW 33
69#define TELOPT_LINEMODE 34
70#define TELOPT_XDISPLOC 35
71#define TELOPT_OLD_ENVIRON 36
72#define TELOPT_AUTHENTICATION 37/* Authenticate */
73#define TELOPT_ENCRYPT 38
74#define TELOPT_NEW_ENVIRON 39
75#define TELOPT_EXOPL 255
76
77
78#define NTELOPTS (1+TELOPT_NEW_ENVIRON)
79#ifdef TELOPTS
80char *telopts[NTELOPTS+1] = {
81 "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
82 "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
83 "NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
84 "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
85 "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
86 "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD",
87 "TACACS UID", "OUTPUT MARKING", "TTYLOC",
88 "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
89 "LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
90 "ENCRYPT", "NEW-ENVIRON",
91 0,
92};
93#define TELOPT_FIRST TELOPT_BINARY
94#define TELOPT_LAST TELOPT_NEW_ENVIRON
95#define TELOPT_OK(x) ((unsigned int)(x) <= TELOPT_LAST)
96#define TELOPT(x) telopts[(x)-TELOPT_FIRST]
97#endif
98
99#define TELQUAL_IS 0
100#define TELQUAL_SEND 1
101#define TELQUAL_INFO 2
102#define TELQUAL_REPLY 2
103#define TELQUAL_NAME 3
104
105#define LFLOW_OFF 0
106#define LFLOW_ON 1
107#define LFLOW_RESTART_ANY 2
108#define LFLOW_RESTART_XON 3
109
110
111#define LM_MODE 1
112#define LM_FORWARDMASK 2
113#define LM_SLC 3
114
115#define MODE_EDIT 0x01
116#define MODE_TRAPSIG 0x02
117#define MODE_ACK 0x04
118#define MODE_SOFT_TAB 0x08
119#define MODE_LIT_ECHO 0x10
120
121#define MODE_MASK 0x1f
122
123#define MODE_FLOW 0x0100
124#define MODE_ECHO 0x0200
125#define MODE_INBIN 0x0400
126#define MODE_OUTBIN 0x0800
127#define MODE_FORCE 0x1000
128
129#define SLC_SYNCH 1
130#define SLC_BRK 2
131#define SLC_IP 3
132#define SLC_AO 4
133#define SLC_AYT 5
134#define SLC_EOR 6
135#define SLC_ABORT 7
136#define SLC_EOF 8
137#define SLC_SUSP 9
138#define SLC_EC 10
139#define SLC_EL 11
140#define SLC_EW 12
141#define SLC_RP 13
142#define SLC_LNEXT 14
143#define SLC_XON 15
144#define SLC_XOFF 16
145#define SLC_FORW1 17
146#define SLC_FORW2 18
147
148#define NSLC 18
149
150#define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \
151 "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \
152 "LNEXT", "XON", "XOFF", "FORW1", "FORW2", 0,
153#ifdef SLC_NAMES
154char *slc_names[] = {
155 SLC_NAMELIST
156};
157#else
158extern char *slc_names[];
159#define SLC_NAMES SLC_NAMELIST
160#endif
161
162#define SLC_NAME_OK(x) ((unsigned int)(x) <= NSLC)
163#define SLC_NAME(x) slc_names[x]
164
165#define SLC_NOSUPPORT 0
166#define SLC_CANTCHANGE 1
167#define SLC_VARIABLE 2
168#define SLC_DEFAULT 3
169#define SLC_LEVELBITS 0x03
170
171#define SLC_FUNC 0
172#define SLC_FLAGS 1
173#define SLC_VALUE 2
174
175#define SLC_ACK 0x80
176#define SLC_FLUSHIN 0x40
177#define SLC_FLUSHOUT 0x20
178
179#define OLD_ENV_VAR 1
180#define OLD_ENV_VALUE 0
181#define NEW_ENV_VAR 0
182#define NEW_ENV_VALUE 1
183#define ENV_ESC 2
184#define ENV_USERVAR 3
185
186#define AUTH_WHO_CLIENT 0
187#define AUTH_WHO_SERVER 1
188#define AUTH_WHO_MASK 1
189
190#define AUTH_HOW_ONE_WAY 0
191#define AUTH_HOW_MUTUAL 2
192#define AUTH_HOW_MASK 2
193
194#define AUTHTYPE_NULL 0
195#define AUTHTYPE_KERBEROS_V4 1
196#define AUTHTYPE_KERBEROS_V5 2
197#define AUTHTYPE_SPX 3
198#define AUTHTYPE_MINK 4
199#define AUTHTYPE_CNT 5
200
201#define AUTHTYPE_TEST 99
202
203#ifdef AUTH_NAMES
204char *authtype_names[] = {
205 "NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", 0,
206};
207#else
208extern char *authtype_names[];
209#endif
210
211#define AUTHTYPE_NAME_OK(x) ((unsigned int)(x) < AUTHTYPE_CNT)
212#define AUTHTYPE_NAME(x) authtype_names[x]
213
214#define ENCRYPT_IS 0
215#define ENCRYPT_SUPPORT 1
216#define ENCRYPT_REPLY 2
217#define ENCRYPT_START 3
218#define ENCRYPT_END 4
219#define ENCRYPT_REQSTART 5
220#define ENCRYPT_REQEND 6
221#define ENCRYPT_ENC_KEYID 7
222#define ENCRYPT_DEC_KEYID 8
223#define ENCRYPT_CNT 9
224
225#define ENCTYPE_ANY 0
226#define ENCTYPE_DES_CFB64 1
227#define ENCTYPE_DES_OFB64 2
228#define ENCTYPE_CNT 3
229
230#ifdef ENCRYPT_NAMES
231char *encrypt_names[] = {
232 "IS", "SUPPORT", "REPLY", "START", "END",
233 "REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
234 0,
235};
236char *enctype_names[] = {
237 "ANY", "DES_CFB64", "DES_OFB64", 0,
238};
239#else
240extern char *encrypt_names[];
241extern char *enctype_names[];
242#endif
243
244
245#define ENCRYPT_NAME_OK(x) ((unsigned int)(x) < ENCRYPT_CNT)
246#define ENCRYPT_NAME(x) encrypt_names[x]
247
248#define ENCTYPE_NAME_OK(x) ((unsigned int)(x) < ENCTYPE_CNT)
249#define ENCTYPE_NAME(x) enctype_names[x]
250
251#endif
lib/libc/musl/include/arpa/tftp.h created+31
......@@ -0,0 +1,31 @@
1#ifndef _ARPA_TFTP_H
2#define _ARPA_TFTP_H
3#define SEGSIZE 512
4#define RRQ 01
5#define WRQ 02
6#define DATA 03
7#define ACK 04
8#define ERROR 05
9struct tftphdr {
10 short th_opcode;
11 union {
12 unsigned short tu_block;
13 short tu_code;
14 char tu_stuff[1];
15 } th_u;
16 char th_data[1];
17};
18#define th_block th_u.tu_block
19#define th_code th_u.tu_code
20#define th_stuff th_u.tu_stuff
21#define th_msg th_data
22#define EUNDEF 0
23#define ENOTFOUND 1
24#define EACCESS 2
25#define ENOSPACE 3
26#define EBADOP 4
27#define EBADID 5
28#define EEXISTS 6
29#define ENOUSER 7
30#endif
31
lib/libc/musl/include/assert.h created+23
......@@ -0,0 +1,23 @@
1#include <features.h>
2
3#undef assert
4
5#ifdef NDEBUG
6#define assert(x) (void)0
7#else
8#define assert(x) ((void)((x) || (__assert_fail(#x, __FILE__, __LINE__, __func__),0)))
9#endif
10
11#if __STDC_VERSION__ >= 201112L && !defined(__cplusplus)
12#define static_assert _Static_assert
13#endif
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19_Noreturn void __assert_fail (const char *, const char *, int, const char *);
20
21#ifdef __cplusplus
22}
23#endif
lib/libc/musl/include/byteswap.h created+26
......@@ -0,0 +1,26 @@
1#ifndef _BYTESWAP_H
2#define _BYTESWAP_H
3
4#include <features.h>
5#include <stdint.h>
6
7static __inline uint16_t __bswap_16(uint16_t __x)
8{
9 return __x<<8 | __x>>8;
10}
11
12static __inline uint32_t __bswap_32(uint32_t __x)
13{
14 return __x>>24 | __x>>8&0xff00 | __x<<8&0xff0000 | __x<<24;
15}
16
17static __inline uint64_t __bswap_64(uint64_t __x)
18{
19 return __bswap_32(__x)+0ULL<<32 | __bswap_32(__x>>32);
20}
21
22#define bswap_16(x) __bswap_16(x)
23#define bswap_32(x) __bswap_32(x)
24#define bswap_64(x) __bswap_64(x)
25
26#endif
lib/libc/musl/include/complex.h created+133
......@@ -0,0 +1,133 @@
1#ifndef _COMPLEX_H
2#define _COMPLEX_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define complex _Complex
9#ifdef __GNUC__
10#define _Complex_I (__extension__ (0.0f+1.0fi))
11#else
12#define _Complex_I (0.0f+1.0fi)
13#endif
14#define I _Complex_I
15
16double complex cacos(double complex);
17float complex cacosf(float complex);
18long double complex cacosl(long double complex);
19
20double complex casin(double complex);
21float complex casinf(float complex);
22long double complex casinl(long double complex);
23
24double complex catan(double complex);
25float complex catanf(float complex);
26long double complex catanl(long double complex);
27
28double complex ccos(double complex);
29float complex ccosf(float complex);
30long double complex ccosl(long double complex);
31
32double complex csin(double complex);
33float complex csinf(float complex);
34long double complex csinl(long double complex);
35
36double complex ctan(double complex);
37float complex ctanf(float complex);
38long double complex ctanl(long double complex);
39
40double complex cacosh(double complex);
41float complex cacoshf(float complex);
42long double complex cacoshl(long double complex);
43
44double complex casinh(double complex);
45float complex casinhf(float complex);
46long double complex casinhl(long double complex);
47
48double complex catanh(double complex);
49float complex catanhf(float complex);
50long double complex catanhl(long double complex);
51
52double complex ccosh(double complex);
53float complex ccoshf(float complex);
54long double complex ccoshl(long double complex);
55
56double complex csinh(double complex);
57float complex csinhf(float complex);
58long double complex csinhl(long double complex);
59
60double complex ctanh(double complex);
61float complex ctanhf(float complex);
62long double complex ctanhl(long double complex);
63
64double complex cexp(double complex);
65float complex cexpf(float complex);
66long double complex cexpl(long double complex);
67
68double complex clog(double complex);
69float complex clogf(float complex);
70long double complex clogl(long double complex);
71
72double cabs(double complex);
73float cabsf(float complex);
74long double cabsl(long double complex);
75
76double complex cpow(double complex, double complex);
77float complex cpowf(float complex, float complex);
78long double complex cpowl(long double complex, long double complex);
79
80double complex csqrt(double complex);
81float complex csqrtf(float complex);
82long double complex csqrtl(long double complex);
83
84double carg(double complex);
85float cargf(float complex);
86long double cargl(long double complex);
87
88double cimag(double complex);
89float cimagf(float complex);
90long double cimagl(long double complex);
91
92double complex conj(double complex);
93float complex conjf(float complex);
94long double complex conjl(long double complex);
95
96double complex cproj(double complex);
97float complex cprojf(float complex);
98long double complex cprojl(long double complex);
99
100double creal(double complex);
101float crealf(float complex);
102long double creall(long double complex);
103
104#ifndef __cplusplus
105#define __CIMAG(x, t) \
106 (+(union { _Complex t __z; t __xy[2]; }){(_Complex t)(x)}.__xy[1])
107
108#define creal(x) ((double)(x))
109#define crealf(x) ((float)(x))
110#define creall(x) ((long double)(x))
111
112#define cimag(x) __CIMAG(x, double)
113#define cimagf(x) __CIMAG(x, float)
114#define cimagl(x) __CIMAG(x, long double)
115#endif
116
117#if __STDC_VERSION__ >= 201112L
118#if defined(_Imaginary_I)
119#define __CMPLX(x, y, t) ((t)(x) + _Imaginary_I*(t)(y))
120#elif defined(__clang__)
121#define __CMPLX(x, y, t) (+(_Complex t){ (t)(x), (t)(y) })
122#else
123#define __CMPLX(x, y, t) (__builtin_complex((t)(x), (t)(y)))
124#endif
125#define CMPLX(x, y) __CMPLX(x, y, double)
126#define CMPLXF(x, y) __CMPLX(x, y, float)
127#define CMPLXL(x, y) __CMPLX(x, y, long double)
128#endif
129
130#ifdef __cplusplus
131}
132#endif
133#endif
lib/libc/musl/include/cpio.h created+29
......@@ -0,0 +1,29 @@
1#ifndef _CPIO_H
2#define _CPIO_H
3
4#define MAGIC "070707"
5
6#define C_IRUSR 000400
7#define C_IWUSR 000200
8#define C_IXUSR 000100
9#define C_IRGRP 000040
10#define C_IWGRP 000020
11#define C_IXGRP 000010
12#define C_IROTH 000004
13#define C_IWOTH 000002
14#define C_IXOTH 000001
15
16#define C_ISUID 004000
17#define C_ISGID 002000
18#define C_ISVTX 001000
19
20#define C_ISBLK 060000
21#define C_ISCHR 020000
22#define C_ISDIR 040000
23#define C_ISFIFO 010000
24#define C_ISSOCK 0140000
25#define C_ISLNK 0120000
26#define C_ISCTG 0110000
27#define C_ISREG 0100000
28
29#endif
lib/libc/musl/include/crypt.h created+20
......@@ -0,0 +1,20 @@
1#ifndef _CRYPT_H
2#define _CRYPT_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8struct crypt_data {
9 int initialized;
10 char __buf[256];
11};
12
13char *crypt(const char *, const char *);
14char *crypt_r(const char *, const char *, struct crypt_data *);
15
16#ifdef __cplusplus
17}
18#endif
19
20#endif
lib/libc/musl/include/ctype.h created+75
......@@ -0,0 +1,75 @@
1#ifndef _CTYPE_H
2#define _CTYPE_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10int isalnum(int);
11int isalpha(int);
12int isblank(int);
13int iscntrl(int);
14int isdigit(int);
15int isgraph(int);
16int islower(int);
17int isprint(int);
18int ispunct(int);
19int isspace(int);
20int isupper(int);
21int isxdigit(int);
22int tolower(int);
23int toupper(int);
24
25#ifndef __cplusplus
26static __inline int __isspace(int _c)
27{
28 return _c == ' ' || (unsigned)_c-'\t' < 5;
29}
30
31#define isalpha(a) (0 ? isalpha(a) : (((unsigned)(a)|32)-'a') < 26)
32#define isdigit(a) (0 ? isdigit(a) : ((unsigned)(a)-'0') < 10)
33#define islower(a) (0 ? islower(a) : ((unsigned)(a)-'a') < 26)
34#define isupper(a) (0 ? isupper(a) : ((unsigned)(a)-'A') < 26)
35#define isprint(a) (0 ? isprint(a) : ((unsigned)(a)-0x20) < 0x5f)
36#define isgraph(a) (0 ? isgraph(a) : ((unsigned)(a)-0x21) < 0x5e)
37#define isspace(a) __isspace(a)
38#endif
39
40
41#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
42 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
43 || defined(_BSD_SOURCE)
44
45#define __NEED_locale_t
46#include <bits/alltypes.h>
47
48int isalnum_l(int, locale_t);
49int isalpha_l(int, locale_t);
50int isblank_l(int, locale_t);
51int iscntrl_l(int, locale_t);
52int isdigit_l(int, locale_t);
53int isgraph_l(int, locale_t);
54int islower_l(int, locale_t);
55int isprint_l(int, locale_t);
56int ispunct_l(int, locale_t);
57int isspace_l(int, locale_t);
58int isupper_l(int, locale_t);
59int isxdigit_l(int, locale_t);
60int tolower_l(int, locale_t);
61int toupper_l(int, locale_t);
62
63int isascii(int);
64int toascii(int);
65#define _tolower(a) ((a)|0x20)
66#define _toupper(a) ((a)&0x5f)
67#define isascii(a) (0 ? isascii(a) : (unsigned)(a) < 128)
68
69#endif
70
71#ifdef __cplusplus
72}
73#endif
74
75#endif
lib/libc/musl/include/dirent.h created+85
......@@ -0,0 +1,85 @@
1#ifndef _DIRENT_H
2#define _DIRENT_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_ino_t
11#define __NEED_off_t
12#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
13#define __NEED_size_t
14#endif
15
16#include <bits/alltypes.h>
17
18typedef struct __dirstream DIR;
19
20#define _DIRENT_HAVE_D_RECLEN
21#define _DIRENT_HAVE_D_OFF
22#define _DIRENT_HAVE_D_TYPE
23
24struct dirent {
25 ino_t d_ino;
26 off_t d_off;
27 unsigned short d_reclen;
28 unsigned char d_type;
29 char d_name[256];
30};
31
32#define d_fileno d_ino
33
34int closedir(DIR *);
35DIR *fdopendir(int);
36DIR *opendir(const char *);
37struct dirent *readdir(DIR *);
38int readdir_r(DIR *__restrict, struct dirent *__restrict, struct dirent **__restrict);
39void rewinddir(DIR *);
40int dirfd(DIR *);
41
42int alphasort(const struct dirent **, const struct dirent **);
43int scandir(const char *, struct dirent ***, int (*)(const struct dirent *), int (*)(const struct dirent **, const struct dirent **));
44
45#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
46void seekdir(DIR *, long);
47long telldir(DIR *);
48#endif
49
50#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
51#define DT_UNKNOWN 0
52#define DT_FIFO 1
53#define DT_CHR 2
54#define DT_DIR 4
55#define DT_BLK 6
56#define DT_REG 8
57#define DT_LNK 10
58#define DT_SOCK 12
59#define DT_WHT 14
60#define IFTODT(x) ((x)>>12 & 017)
61#define DTTOIF(x) ((x)<<12)
62int getdents(int, struct dirent *, size_t);
63#endif
64
65#ifdef _GNU_SOURCE
66int versionsort(const struct dirent **, const struct dirent **);
67#endif
68
69#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
70#define dirent64 dirent
71#define readdir64 readdir
72#define readdir64_r readdir_r
73#define scandir64 scandir
74#define alphasort64 alphasort
75#define versionsort64 versionsort
76#define off64_t off_t
77#define ino64_t ino_t
78#define getdents64 getdents
79#endif
80
81#ifdef __cplusplus
82}
83#endif
84
85#endif
lib/libc/musl/include/dlfcn.h created+42
......@@ -0,0 +1,42 @@
1#ifndef _DLFCN_H
2#define _DLFCN_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define RTLD_LAZY 1
11#define RTLD_NOW 2
12#define RTLD_NOLOAD 4
13#define RTLD_NODELETE 4096
14#define RTLD_GLOBAL 256
15#define RTLD_LOCAL 0
16
17#define RTLD_NEXT ((void *)-1)
18#define RTLD_DEFAULT ((void *)0)
19
20#define RTLD_DI_LINKMAP 2
21
22int dlclose(void *);
23char *dlerror(void);
24void *dlopen(const char *, int);
25void *dlsym(void *__restrict, const char *__restrict);
26
27#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
28typedef struct {
29 const char *dli_fname;
30 void *dli_fbase;
31 const char *dli_sname;
32 void *dli_saddr;
33} Dl_info;
34int dladdr(const void *, Dl_info *);
35int dlinfo(void *, int, void *);
36#endif
37
38#ifdef __cplusplus
39}
40#endif
41
42#endif
lib/libc/musl/include/elf.h created+3292
......@@ -0,0 +1,3292 @@
1#ifndef _ELF_H
2#define _ELF_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stdint.h>
9
10typedef uint16_t Elf32_Half;
11typedef uint16_t Elf64_Half;
12
13typedef uint32_t Elf32_Word;
14typedef int32_t Elf32_Sword;
15typedef uint32_t Elf64_Word;
16typedef int32_t Elf64_Sword;
17
18typedef uint64_t Elf32_Xword;
19typedef int64_t Elf32_Sxword;
20typedef uint64_t Elf64_Xword;
21typedef int64_t Elf64_Sxword;
22
23typedef uint32_t Elf32_Addr;
24typedef uint64_t Elf64_Addr;
25
26typedef uint32_t Elf32_Off;
27typedef uint64_t Elf64_Off;
28
29typedef uint16_t Elf32_Section;
30typedef uint16_t Elf64_Section;
31
32typedef Elf32_Half Elf32_Versym;
33typedef Elf64_Half Elf64_Versym;
34
35#define EI_NIDENT (16)
36
37typedef struct {
38 unsigned char e_ident[EI_NIDENT];
39 Elf32_Half e_type;
40 Elf32_Half e_machine;
41 Elf32_Word e_version;
42 Elf32_Addr e_entry;
43 Elf32_Off e_phoff;
44 Elf32_Off e_shoff;
45 Elf32_Word e_flags;
46 Elf32_Half e_ehsize;
47 Elf32_Half e_phentsize;
48 Elf32_Half e_phnum;
49 Elf32_Half e_shentsize;
50 Elf32_Half e_shnum;
51 Elf32_Half e_shstrndx;
52} Elf32_Ehdr;
53
54typedef struct {
55 unsigned char e_ident[EI_NIDENT];
56 Elf64_Half e_type;
57 Elf64_Half e_machine;
58 Elf64_Word e_version;
59 Elf64_Addr e_entry;
60 Elf64_Off e_phoff;
61 Elf64_Off e_shoff;
62 Elf64_Word e_flags;
63 Elf64_Half e_ehsize;
64 Elf64_Half e_phentsize;
65 Elf64_Half e_phnum;
66 Elf64_Half e_shentsize;
67 Elf64_Half e_shnum;
68 Elf64_Half e_shstrndx;
69} Elf64_Ehdr;
70
71#define EI_MAG0 0
72#define ELFMAG0 0x7f
73
74#define EI_MAG1 1
75#define ELFMAG1 'E'
76
77#define EI_MAG2 2
78#define ELFMAG2 'L'
79
80#define EI_MAG3 3
81#define ELFMAG3 'F'
82
83
84#define ELFMAG "\177ELF"
85#define SELFMAG 4
86
87#define EI_CLASS 4
88#define ELFCLASSNONE 0
89#define ELFCLASS32 1
90#define ELFCLASS64 2
91#define ELFCLASSNUM 3
92
93#define EI_DATA 5
94#define ELFDATANONE 0
95#define ELFDATA2LSB 1
96#define ELFDATA2MSB 2
97#define ELFDATANUM 3
98
99#define EI_VERSION 6
100
101
102#define EI_OSABI 7
103#define ELFOSABI_NONE 0
104#define ELFOSABI_SYSV 0
105#define ELFOSABI_HPUX 1
106#define ELFOSABI_NETBSD 2
107#define ELFOSABI_LINUX 3
108#define ELFOSABI_GNU 3
109#define ELFOSABI_SOLARIS 6
110#define ELFOSABI_AIX 7
111#define ELFOSABI_IRIX 8
112#define ELFOSABI_FREEBSD 9
113#define ELFOSABI_TRU64 10
114#define ELFOSABI_MODESTO 11
115#define ELFOSABI_OPENBSD 12
116#define ELFOSABI_ARM 97
117#define ELFOSABI_STANDALONE 255
118
119#define EI_ABIVERSION 8
120
121#define EI_PAD 9
122
123
124
125#define ET_NONE 0
126#define ET_REL 1
127#define ET_EXEC 2
128#define ET_DYN 3
129#define ET_CORE 4
130#define ET_NUM 5
131#define ET_LOOS 0xfe00
132#define ET_HIOS 0xfeff
133#define ET_LOPROC 0xff00
134#define ET_HIPROC 0xffff
135
136
137
138#define EM_NONE 0
139#define EM_M32 1
140#define EM_SPARC 2
141#define EM_386 3
142#define EM_68K 4
143#define EM_88K 5
144#define EM_860 7
145#define EM_MIPS 8
146#define EM_S370 9
147#define EM_MIPS_RS3_LE 10
148
149#define EM_PARISC 15
150#define EM_VPP500 17
151#define EM_SPARC32PLUS 18
152#define EM_960 19
153#define EM_PPC 20
154#define EM_PPC64 21
155#define EM_S390 22
156
157#define EM_V800 36
158#define EM_FR20 37
159#define EM_RH32 38
160#define EM_RCE 39
161#define EM_ARM 40
162#define EM_FAKE_ALPHA 41
163#define EM_SH 42
164#define EM_SPARCV9 43
165#define EM_TRICORE 44
166#define EM_ARC 45
167#define EM_H8_300 46
168#define EM_H8_300H 47
169#define EM_H8S 48
170#define EM_H8_500 49
171#define EM_IA_64 50
172#define EM_MIPS_X 51
173#define EM_COLDFIRE 52
174#define EM_68HC12 53
175#define EM_MMA 54
176#define EM_PCP 55
177#define EM_NCPU 56
178#define EM_NDR1 57
179#define EM_STARCORE 58
180#define EM_ME16 59
181#define EM_ST100 60
182#define EM_TINYJ 61
183#define EM_X86_64 62
184#define EM_PDSP 63
185
186#define EM_FX66 66
187#define EM_ST9PLUS 67
188#define EM_ST7 68
189#define EM_68HC16 69
190#define EM_68HC11 70
191#define EM_68HC08 71
192#define EM_68HC05 72
193#define EM_SVX 73
194#define EM_ST19 74
195#define EM_VAX 75
196#define EM_CRIS 76
197#define EM_JAVELIN 77
198#define EM_FIREPATH 78
199#define EM_ZSP 79
200#define EM_MMIX 80
201#define EM_HUANY 81
202#define EM_PRISM 82
203#define EM_AVR 83
204#define EM_FR30 84
205#define EM_D10V 85
206#define EM_D30V 86
207#define EM_V850 87
208#define EM_M32R 88
209#define EM_MN10300 89
210#define EM_MN10200 90
211#define EM_PJ 91
212#define EM_OR1K 92
213#define EM_OPENRISC 92
214#define EM_ARC_A5 93
215#define EM_ARC_COMPACT 93
216#define EM_XTENSA 94
217#define EM_VIDEOCORE 95
218#define EM_TMM_GPP 96
219#define EM_NS32K 97
220#define EM_TPC 98
221#define EM_SNP1K 99
222#define EM_ST200 100
223#define EM_IP2K 101
224#define EM_MAX 102
225#define EM_CR 103
226#define EM_F2MC16 104
227#define EM_MSP430 105
228#define EM_BLACKFIN 106
229#define EM_SE_C33 107
230#define EM_SEP 108
231#define EM_ARCA 109
232#define EM_UNICORE 110
233#define EM_EXCESS 111
234#define EM_DXP 112
235#define EM_ALTERA_NIOS2 113
236#define EM_CRX 114
237#define EM_XGATE 115
238#define EM_C166 116
239#define EM_M16C 117
240#define EM_DSPIC30F 118
241#define EM_CE 119
242#define EM_M32C 120
243#define EM_TSK3000 131
244#define EM_RS08 132
245#define EM_SHARC 133
246#define EM_ECOG2 134
247#define EM_SCORE7 135
248#define EM_DSP24 136
249#define EM_VIDEOCORE3 137
250#define EM_LATTICEMICO32 138
251#define EM_SE_C17 139
252#define EM_TI_C6000 140
253#define EM_TI_C2000 141
254#define EM_TI_C5500 142
255#define EM_TI_ARP32 143
256#define EM_TI_PRU 144
257#define EM_MMDSP_PLUS 160
258#define EM_CYPRESS_M8C 161
259#define EM_R32C 162
260#define EM_TRIMEDIA 163
261#define EM_QDSP6 164
262#define EM_8051 165
263#define EM_STXP7X 166
264#define EM_NDS32 167
265#define EM_ECOG1X 168
266#define EM_MAXQ30 169
267#define EM_XIMO16 170
268#define EM_MANIK 171
269#define EM_CRAYNV2 172
270#define EM_RX 173
271#define EM_METAG 174
272#define EM_MCST_ELBRUS 175
273#define EM_ECOG16 176
274#define EM_CR16 177
275#define EM_ETPU 178
276#define EM_SLE9X 179
277#define EM_L10M 180
278#define EM_K10M 181
279#define EM_AARCH64 183
280#define EM_AVR32 185
281#define EM_STM8 186
282#define EM_TILE64 187
283#define EM_TILEPRO 188
284#define EM_MICROBLAZE 189
285#define EM_CUDA 190
286#define EM_TILEGX 191
287#define EM_CLOUDSHIELD 192
288#define EM_COREA_1ST 193
289#define EM_COREA_2ND 194
290#define EM_ARC_COMPACT2 195
291#define EM_OPEN8 196
292#define EM_RL78 197
293#define EM_VIDEOCORE5 198
294#define EM_78KOR 199
295#define EM_56800EX 200
296#define EM_BA1 201
297#define EM_BA2 202
298#define EM_XCORE 203
299#define EM_MCHP_PIC 204
300#define EM_KM32 210
301#define EM_KMX32 211
302#define EM_EMX16 212
303#define EM_EMX8 213
304#define EM_KVARC 214
305#define EM_CDP 215
306#define EM_COGE 216
307#define EM_COOL 217
308#define EM_NORC 218
309#define EM_CSR_KALIMBA 219
310#define EM_Z80 220
311#define EM_VISIUM 221
312#define EM_FT32 222
313#define EM_MOXIE 223
314#define EM_AMDGPU 224
315#define EM_RISCV 243
316#define EM_BPF 247
317#define EM_CSKY 252
318#define EM_NUM 253
319
320#define EM_ALPHA 0x9026
321
322#define EV_NONE 0
323#define EV_CURRENT 1
324#define EV_NUM 2
325
326typedef struct {
327 Elf32_Word sh_name;
328 Elf32_Word sh_type;
329 Elf32_Word sh_flags;
330 Elf32_Addr sh_addr;
331 Elf32_Off sh_offset;
332 Elf32_Word sh_size;
333 Elf32_Word sh_link;
334 Elf32_Word sh_info;
335 Elf32_Word sh_addralign;
336 Elf32_Word sh_entsize;
337} Elf32_Shdr;
338
339typedef struct {
340 Elf64_Word sh_name;
341 Elf64_Word sh_type;
342 Elf64_Xword sh_flags;
343 Elf64_Addr sh_addr;
344 Elf64_Off sh_offset;
345 Elf64_Xword sh_size;
346 Elf64_Word sh_link;
347 Elf64_Word sh_info;
348 Elf64_Xword sh_addralign;
349 Elf64_Xword sh_entsize;
350} Elf64_Shdr;
351
352
353
354#define SHN_UNDEF 0
355#define SHN_LORESERVE 0xff00
356#define SHN_LOPROC 0xff00
357#define SHN_BEFORE 0xff00
358
359#define SHN_AFTER 0xff01
360
361#define SHN_HIPROC 0xff1f
362#define SHN_LOOS 0xff20
363#define SHN_HIOS 0xff3f
364#define SHN_ABS 0xfff1
365#define SHN_COMMON 0xfff2
366#define SHN_XINDEX 0xffff
367#define SHN_HIRESERVE 0xffff
368
369
370
371#define SHT_NULL 0
372#define SHT_PROGBITS 1
373#define SHT_SYMTAB 2
374#define SHT_STRTAB 3
375#define SHT_RELA 4
376#define SHT_HASH 5
377#define SHT_DYNAMIC 6
378#define SHT_NOTE 7
379#define SHT_NOBITS 8
380#define SHT_REL 9
381#define SHT_SHLIB 10
382#define SHT_DYNSYM 11
383#define SHT_INIT_ARRAY 14
384#define SHT_FINI_ARRAY 15
385#define SHT_PREINIT_ARRAY 16
386#define SHT_GROUP 17
387#define SHT_SYMTAB_SHNDX 18
388#define SHT_NUM 19
389#define SHT_LOOS 0x60000000
390#define SHT_GNU_ATTRIBUTES 0x6ffffff5
391#define SHT_GNU_HASH 0x6ffffff6
392#define SHT_GNU_LIBLIST 0x6ffffff7
393#define SHT_CHECKSUM 0x6ffffff8
394#define SHT_LOSUNW 0x6ffffffa
395#define SHT_SUNW_move 0x6ffffffa
396#define SHT_SUNW_COMDAT 0x6ffffffb
397#define SHT_SUNW_syminfo 0x6ffffffc
398#define SHT_GNU_verdef 0x6ffffffd
399#define SHT_GNU_verneed 0x6ffffffe
400#define SHT_GNU_versym 0x6fffffff
401#define SHT_HISUNW 0x6fffffff
402#define SHT_HIOS 0x6fffffff
403#define SHT_LOPROC 0x70000000
404#define SHT_HIPROC 0x7fffffff
405#define SHT_LOUSER 0x80000000
406#define SHT_HIUSER 0x8fffffff
407
408#define SHF_WRITE (1 << 0)
409#define SHF_ALLOC (1 << 1)
410#define SHF_EXECINSTR (1 << 2)
411#define SHF_MERGE (1 << 4)
412#define SHF_STRINGS (1 << 5)
413#define SHF_INFO_LINK (1 << 6)
414#define SHF_LINK_ORDER (1 << 7)
415#define SHF_OS_NONCONFORMING (1 << 8)
416
417#define SHF_GROUP (1 << 9)
418#define SHF_TLS (1 << 10)
419#define SHF_COMPRESSED (1 << 11)
420#define SHF_MASKOS 0x0ff00000
421#define SHF_MASKPROC 0xf0000000
422#define SHF_ORDERED (1 << 30)
423#define SHF_EXCLUDE (1U << 31)
424
425typedef struct {
426 Elf32_Word ch_type;
427 Elf32_Word ch_size;
428 Elf32_Word ch_addralign;
429} Elf32_Chdr;
430
431typedef struct {
432 Elf64_Word ch_type;
433 Elf64_Word ch_reserved;
434 Elf64_Xword ch_size;
435 Elf64_Xword ch_addralign;
436} Elf64_Chdr;
437
438#define ELFCOMPRESS_ZLIB 1
439#define ELFCOMPRESS_LOOS 0x60000000
440#define ELFCOMPRESS_HIOS 0x6fffffff
441#define ELFCOMPRESS_LOPROC 0x70000000
442#define ELFCOMPRESS_HIPROC 0x7fffffff
443
444
445#define GRP_COMDAT 0x1
446
447typedef struct {
448 Elf32_Word st_name;
449 Elf32_Addr st_value;
450 Elf32_Word st_size;
451 unsigned char st_info;
452 unsigned char st_other;
453 Elf32_Section st_shndx;
454} Elf32_Sym;
455
456typedef struct {
457 Elf64_Word st_name;
458 unsigned char st_info;
459 unsigned char st_other;
460 Elf64_Section st_shndx;
461 Elf64_Addr st_value;
462 Elf64_Xword st_size;
463} Elf64_Sym;
464
465typedef struct {
466 Elf32_Half si_boundto;
467 Elf32_Half si_flags;
468} Elf32_Syminfo;
469
470typedef struct {
471 Elf64_Half si_boundto;
472 Elf64_Half si_flags;
473} Elf64_Syminfo;
474
475#define SYMINFO_BT_SELF 0xffff
476#define SYMINFO_BT_PARENT 0xfffe
477#define SYMINFO_BT_LOWRESERVE 0xff00
478
479#define SYMINFO_FLG_DIRECT 0x0001
480#define SYMINFO_FLG_PASSTHRU 0x0002
481#define SYMINFO_FLG_COPY 0x0004
482#define SYMINFO_FLG_LAZYLOAD 0x0008
483
484#define SYMINFO_NONE 0
485#define SYMINFO_CURRENT 1
486#define SYMINFO_NUM 2
487
488#define ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4)
489#define ELF32_ST_TYPE(val) ((val) & 0xf)
490#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf))
491
492#define ELF64_ST_BIND(val) ELF32_ST_BIND (val)
493#define ELF64_ST_TYPE(val) ELF32_ST_TYPE (val)
494#define ELF64_ST_INFO(bind, type) ELF32_ST_INFO ((bind), (type))
495
496#define STB_LOCAL 0
497#define STB_GLOBAL 1
498#define STB_WEAK 2
499#define STB_NUM 3
500#define STB_LOOS 10
501#define STB_GNU_UNIQUE 10
502#define STB_HIOS 12
503#define STB_LOPROC 13
504#define STB_HIPROC 15
505
506#define STT_NOTYPE 0
507#define STT_OBJECT 1
508#define STT_FUNC 2
509#define STT_SECTION 3
510#define STT_FILE 4
511#define STT_COMMON 5
512#define STT_TLS 6
513#define STT_NUM 7
514#define STT_LOOS 10
515#define STT_GNU_IFUNC 10
516#define STT_HIOS 12
517#define STT_LOPROC 13
518#define STT_HIPROC 15
519
520#define STN_UNDEF 0
521
522#define ELF32_ST_VISIBILITY(o) ((o) & 0x03)
523#define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY (o)
524
525#define STV_DEFAULT 0
526#define STV_INTERNAL 1
527#define STV_HIDDEN 2
528#define STV_PROTECTED 3
529
530
531
532
533typedef struct {
534 Elf32_Addr r_offset;
535 Elf32_Word r_info;
536} Elf32_Rel;
537
538typedef struct {
539 Elf64_Addr r_offset;
540 Elf64_Xword r_info;
541} Elf64_Rel;
542
543
544
545typedef struct {
546 Elf32_Addr r_offset;
547 Elf32_Word r_info;
548 Elf32_Sword r_addend;
549} Elf32_Rela;
550
551typedef struct {
552 Elf64_Addr r_offset;
553 Elf64_Xword r_info;
554 Elf64_Sxword r_addend;
555} Elf64_Rela;
556
557
558
559#define ELF32_R_SYM(val) ((val) >> 8)
560#define ELF32_R_TYPE(val) ((val) & 0xff)
561#define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff))
562
563#define ELF64_R_SYM(i) ((i) >> 32)
564#define ELF64_R_TYPE(i) ((i) & 0xffffffff)
565#define ELF64_R_INFO(sym,type) ((((Elf64_Xword) (sym)) << 32) + (type))
566
567
568
569typedef struct {
570 Elf32_Word p_type;
571 Elf32_Off p_offset;
572 Elf32_Addr p_vaddr;
573 Elf32_Addr p_paddr;
574 Elf32_Word p_filesz;
575 Elf32_Word p_memsz;
576 Elf32_Word p_flags;
577 Elf32_Word p_align;
578} Elf32_Phdr;
579
580typedef struct {
581 Elf64_Word p_type;
582 Elf64_Word p_flags;
583 Elf64_Off p_offset;
584 Elf64_Addr p_vaddr;
585 Elf64_Addr p_paddr;
586 Elf64_Xword p_filesz;
587 Elf64_Xword p_memsz;
588 Elf64_Xword p_align;
589} Elf64_Phdr;
590
591
592
593#define PT_NULL 0
594#define PT_LOAD 1
595#define PT_DYNAMIC 2
596#define PT_INTERP 3
597#define PT_NOTE 4
598#define PT_SHLIB 5
599#define PT_PHDR 6
600#define PT_TLS 7
601#define PT_NUM 8
602#define PT_LOOS 0x60000000
603#define PT_GNU_EH_FRAME 0x6474e550
604#define PT_GNU_STACK 0x6474e551
605#define PT_GNU_RELRO 0x6474e552
606#define PT_LOSUNW 0x6ffffffa
607#define PT_SUNWBSS 0x6ffffffa
608#define PT_SUNWSTACK 0x6ffffffb
609#define PT_HISUNW 0x6fffffff
610#define PT_HIOS 0x6fffffff
611#define PT_LOPROC 0x70000000
612#define PT_HIPROC 0x7fffffff
613
614
615#define PN_XNUM 0xffff
616
617
618#define PF_X (1 << 0)
619#define PF_W (1 << 1)
620#define PF_R (1 << 2)
621#define PF_MASKOS 0x0ff00000
622#define PF_MASKPROC 0xf0000000
623
624
625
626#define NT_PRSTATUS 1
627#define NT_PRFPREG 2
628#define NT_FPREGSET 2
629#define NT_PRPSINFO 3
630#define NT_PRXREG 4
631#define NT_TASKSTRUCT 4
632#define NT_PLATFORM 5
633#define NT_AUXV 6
634#define NT_GWINDOWS 7
635#define NT_ASRS 8
636#define NT_PSTATUS 10
637#define NT_PSINFO 13
638#define NT_PRCRED 14
639#define NT_UTSNAME 15
640#define NT_LWPSTATUS 16
641#define NT_LWPSINFO 17
642#define NT_PRFPXREG 20
643#define NT_SIGINFO 0x53494749
644#define NT_FILE 0x46494c45
645#define NT_PRXFPREG 0x46e62b7f
646#define NT_PPC_VMX 0x100
647#define NT_PPC_SPE 0x101
648#define NT_PPC_VSX 0x102
649#define NT_PPC_TAR 0x103
650#define NT_PPC_PPR 0x104
651#define NT_PPC_DSCR 0x105
652#define NT_PPC_EBB 0x106
653#define NT_PPC_PMU 0x107
654#define NT_PPC_TM_CGPR 0x108
655#define NT_PPC_TM_CFPR 0x109
656#define NT_PPC_TM_CVMX 0x10a
657#define NT_PPC_TM_CVSX 0x10b
658#define NT_PPC_TM_SPR 0x10c
659#define NT_PPC_TM_CTAR 0x10d
660#define NT_PPC_TM_CPPR 0x10e
661#define NT_PPC_TM_CDSCR 0x10f
662#define NT_386_TLS 0x200
663#define NT_386_IOPERM 0x201
664#define NT_X86_XSTATE 0x202
665#define NT_S390_HIGH_GPRS 0x300
666#define NT_S390_TIMER 0x301
667#define NT_S390_TODCMP 0x302
668#define NT_S390_TODPREG 0x303
669#define NT_S390_CTRS 0x304
670#define NT_S390_PREFIX 0x305
671#define NT_S390_LAST_BREAK 0x306
672#define NT_S390_SYSTEM_CALL 0x307
673#define NT_S390_TDB 0x308
674#define NT_S390_VXRS_LOW 0x309
675#define NT_S390_VXRS_HIGH 0x30a
676#define NT_S390_GS_CB 0x30b
677#define NT_S390_GS_BC 0x30c
678#define NT_S390_RI_CB 0x30d
679#define NT_ARM_VFP 0x400
680#define NT_ARM_TLS 0x401
681#define NT_ARM_HW_BREAK 0x402
682#define NT_ARM_HW_WATCH 0x403
683#define NT_ARM_SYSTEM_CALL 0x404
684#define NT_ARM_SVE 0x405
685#define NT_ARM_PAC_MASK 0x406
686#define NT_ARM_PACA_KEYS 0x407
687#define NT_ARM_PACG_KEYS 0x408
688#define NT_METAG_CBUF 0x500
689#define NT_METAG_RPIPE 0x501
690#define NT_METAG_TLS 0x502
691#define NT_ARC_V2 0x600
692#define NT_VMCOREDD 0x700
693#define NT_MIPS_DSP 0x800
694#define NT_MIPS_FP_MODE 0x801
695#define NT_MIPS_MSA 0x802
696#define NT_VERSION 1
697
698
699
700
701typedef struct {
702 Elf32_Sword d_tag;
703 union {
704 Elf32_Word d_val;
705 Elf32_Addr d_ptr;
706 } d_un;
707} Elf32_Dyn;
708
709typedef struct {
710 Elf64_Sxword d_tag;
711 union {
712 Elf64_Xword d_val;
713 Elf64_Addr d_ptr;
714 } d_un;
715} Elf64_Dyn;
716
717
718
719#define DT_NULL 0
720#define DT_NEEDED 1
721#define DT_PLTRELSZ 2
722#define DT_PLTGOT 3
723#define DT_HASH 4
724#define DT_STRTAB 5
725#define DT_SYMTAB 6
726#define DT_RELA 7
727#define DT_RELASZ 8
728#define DT_RELAENT 9
729#define DT_STRSZ 10
730#define DT_SYMENT 11
731#define DT_INIT 12
732#define DT_FINI 13
733#define DT_SONAME 14
734#define DT_RPATH 15
735#define DT_SYMBOLIC 16
736#define DT_REL 17
737#define DT_RELSZ 18
738#define DT_RELENT 19
739#define DT_PLTREL 20
740#define DT_DEBUG 21
741#define DT_TEXTREL 22
742#define DT_JMPREL 23
743#define DT_BIND_NOW 24
744#define DT_INIT_ARRAY 25
745#define DT_FINI_ARRAY 26
746#define DT_INIT_ARRAYSZ 27
747#define DT_FINI_ARRAYSZ 28
748#define DT_RUNPATH 29
749#define DT_FLAGS 30
750#define DT_ENCODING 32
751#define DT_PREINIT_ARRAY 32
752#define DT_PREINIT_ARRAYSZ 33
753#define DT_SYMTAB_SHNDX 34
754#define DT_NUM 35
755#define DT_LOOS 0x6000000d
756#define DT_HIOS 0x6ffff000
757#define DT_LOPROC 0x70000000
758#define DT_HIPROC 0x7fffffff
759#define DT_PROCNUM DT_MIPS_NUM
760
761#define DT_VALRNGLO 0x6ffffd00
762#define DT_GNU_PRELINKED 0x6ffffdf5
763#define DT_GNU_CONFLICTSZ 0x6ffffdf6
764#define DT_GNU_LIBLISTSZ 0x6ffffdf7
765#define DT_CHECKSUM 0x6ffffdf8
766#define DT_PLTPADSZ 0x6ffffdf9
767#define DT_MOVEENT 0x6ffffdfa
768#define DT_MOVESZ 0x6ffffdfb
769#define DT_FEATURE_1 0x6ffffdfc
770#define DT_POSFLAG_1 0x6ffffdfd
771
772#define DT_SYMINSZ 0x6ffffdfe
773#define DT_SYMINENT 0x6ffffdff
774#define DT_VALRNGHI 0x6ffffdff
775#define DT_VALTAGIDX(tag) (DT_VALRNGHI - (tag))
776#define DT_VALNUM 12
777
778#define DT_ADDRRNGLO 0x6ffffe00
779#define DT_GNU_HASH 0x6ffffef5
780#define DT_TLSDESC_PLT 0x6ffffef6
781#define DT_TLSDESC_GOT 0x6ffffef7
782#define DT_GNU_CONFLICT 0x6ffffef8
783#define DT_GNU_LIBLIST 0x6ffffef9
784#define DT_CONFIG 0x6ffffefa
785#define DT_DEPAUDIT 0x6ffffefb
786#define DT_AUDIT 0x6ffffefc
787#define DT_PLTPAD 0x6ffffefd
788#define DT_MOVETAB 0x6ffffefe
789#define DT_SYMINFO 0x6ffffeff
790#define DT_ADDRRNGHI 0x6ffffeff
791#define DT_ADDRTAGIDX(tag) (DT_ADDRRNGHI - (tag))
792#define DT_ADDRNUM 11
793
794
795
796#define DT_VERSYM 0x6ffffff0
797
798#define DT_RELACOUNT 0x6ffffff9
799#define DT_RELCOUNT 0x6ffffffa
800
801
802#define DT_FLAGS_1 0x6ffffffb
803#define DT_VERDEF 0x6ffffffc
804
805#define DT_VERDEFNUM 0x6ffffffd
806#define DT_VERNEED 0x6ffffffe
807
808#define DT_VERNEEDNUM 0x6fffffff
809#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag))
810#define DT_VERSIONTAGNUM 16
811
812
813
814#define DT_AUXILIARY 0x7ffffffd
815#define DT_FILTER 0x7fffffff
816#define DT_EXTRATAGIDX(tag) ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1)
817#define DT_EXTRANUM 3
818
819
820#define DF_ORIGIN 0x00000001
821#define DF_SYMBOLIC 0x00000002
822#define DF_TEXTREL 0x00000004
823#define DF_BIND_NOW 0x00000008
824#define DF_STATIC_TLS 0x00000010
825
826
827
828#define DF_1_NOW 0x00000001
829#define DF_1_GLOBAL 0x00000002
830#define DF_1_GROUP 0x00000004
831#define DF_1_NODELETE 0x00000008
832#define DF_1_LOADFLTR 0x00000010
833#define DF_1_INITFIRST 0x00000020
834#define DF_1_NOOPEN 0x00000040
835#define DF_1_ORIGIN 0x00000080
836#define DF_1_DIRECT 0x00000100
837#define DF_1_TRANS 0x00000200
838#define DF_1_INTERPOSE 0x00000400
839#define DF_1_NODEFLIB 0x00000800
840#define DF_1_NODUMP 0x00001000
841#define DF_1_CONFALT 0x00002000
842#define DF_1_ENDFILTEE 0x00004000
843#define DF_1_DISPRELDNE 0x00008000
844#define DF_1_DISPRELPND 0x00010000
845#define DF_1_NODIRECT 0x00020000
846#define DF_1_IGNMULDEF 0x00040000
847#define DF_1_NOKSYMS 0x00080000
848#define DF_1_NOHDR 0x00100000
849#define DF_1_EDITED 0x00200000
850#define DF_1_NORELOC 0x00400000
851#define DF_1_SYMINTPOSE 0x00800000
852#define DF_1_GLOBAUDIT 0x01000000
853#define DF_1_SINGLETON 0x02000000
854#define DF_1_STUB 0x04000000
855#define DF_1_PIE 0x08000000
856
857#define DTF_1_PARINIT 0x00000001
858#define DTF_1_CONFEXP 0x00000002
859
860
861#define DF_P1_LAZYLOAD 0x00000001
862#define DF_P1_GROUPPERM 0x00000002
863
864
865
866
867typedef struct {
868 Elf32_Half vd_version;
869 Elf32_Half vd_flags;
870 Elf32_Half vd_ndx;
871 Elf32_Half vd_cnt;
872 Elf32_Word vd_hash;
873 Elf32_Word vd_aux;
874 Elf32_Word vd_next;
875} Elf32_Verdef;
876
877typedef struct {
878 Elf64_Half vd_version;
879 Elf64_Half vd_flags;
880 Elf64_Half vd_ndx;
881 Elf64_Half vd_cnt;
882 Elf64_Word vd_hash;
883 Elf64_Word vd_aux;
884 Elf64_Word vd_next;
885} Elf64_Verdef;
886
887
888
889#define VER_DEF_NONE 0
890#define VER_DEF_CURRENT 1
891#define VER_DEF_NUM 2
892
893
894#define VER_FLG_BASE 0x1
895#define VER_FLG_WEAK 0x2
896
897
898#define VER_NDX_LOCAL 0
899#define VER_NDX_GLOBAL 1
900#define VER_NDX_LORESERVE 0xff00
901#define VER_NDX_ELIMINATE 0xff01
902
903
904
905typedef struct {
906 Elf32_Word vda_name;
907 Elf32_Word vda_next;
908} Elf32_Verdaux;
909
910typedef struct {
911 Elf64_Word vda_name;
912 Elf64_Word vda_next;
913} Elf64_Verdaux;
914
915
916
917
918typedef struct {
919 Elf32_Half vn_version;
920 Elf32_Half vn_cnt;
921 Elf32_Word vn_file;
922 Elf32_Word vn_aux;
923 Elf32_Word vn_next;
924} Elf32_Verneed;
925
926typedef struct {
927 Elf64_Half vn_version;
928 Elf64_Half vn_cnt;
929 Elf64_Word vn_file;
930 Elf64_Word vn_aux;
931 Elf64_Word vn_next;
932} Elf64_Verneed;
933
934
935
936#define VER_NEED_NONE 0
937#define VER_NEED_CURRENT 1
938#define VER_NEED_NUM 2
939
940
941
942typedef struct {
943 Elf32_Word vna_hash;
944 Elf32_Half vna_flags;
945 Elf32_Half vna_other;
946 Elf32_Word vna_name;
947 Elf32_Word vna_next;
948} Elf32_Vernaux;
949
950typedef struct {
951 Elf64_Word vna_hash;
952 Elf64_Half vna_flags;
953 Elf64_Half vna_other;
954 Elf64_Word vna_name;
955 Elf64_Word vna_next;
956} Elf64_Vernaux;
957
958
959
960#define VER_FLG_WEAK 0x2
961
962
963
964typedef struct {
965 uint32_t a_type;
966 union {
967 uint32_t a_val;
968 } a_un;
969} Elf32_auxv_t;
970
971typedef struct {
972 uint64_t a_type;
973 union {
974 uint64_t a_val;
975 } a_un;
976} Elf64_auxv_t;
977
978
979
980#define AT_NULL 0
981#define AT_IGNORE 1
982#define AT_EXECFD 2
983#define AT_PHDR 3
984#define AT_PHENT 4
985#define AT_PHNUM 5
986#define AT_PAGESZ 6
987#define AT_BASE 7
988#define AT_FLAGS 8
989#define AT_ENTRY 9
990#define AT_NOTELF 10
991#define AT_UID 11
992#define AT_EUID 12
993#define AT_GID 13
994#define AT_EGID 14
995#define AT_CLKTCK 17
996
997
998#define AT_PLATFORM 15
999#define AT_HWCAP 16
1000
1001
1002
1003
1004#define AT_FPUCW 18
1005
1006
1007#define AT_DCACHEBSIZE 19
1008#define AT_ICACHEBSIZE 20
1009#define AT_UCACHEBSIZE 21
1010
1011
1012
1013#define AT_IGNOREPPC 22
1014
1015#define AT_SECURE 23
1016
1017#define AT_BASE_PLATFORM 24
1018
1019#define AT_RANDOM 25
1020
1021#define AT_HWCAP2 26
1022
1023#define AT_EXECFN 31
1024
1025
1026
1027#define AT_SYSINFO 32
1028#define AT_SYSINFO_EHDR 33
1029
1030
1031
1032#define AT_L1I_CACHESHAPE 34
1033#define AT_L1D_CACHESHAPE 35
1034#define AT_L2_CACHESHAPE 36
1035#define AT_L3_CACHESHAPE 37
1036
1037#define AT_L1I_CACHESIZE 40
1038#define AT_L1I_CACHEGEOMETRY 41
1039#define AT_L1D_CACHESIZE 42
1040#define AT_L1D_CACHEGEOMETRY 43
1041#define AT_L2_CACHESIZE 44
1042#define AT_L2_CACHEGEOMETRY 45
1043#define AT_L3_CACHESIZE 46
1044#define AT_L3_CACHEGEOMETRY 47
1045
1046#define AT_MINSIGSTKSZ 51
1047
1048
1049typedef struct {
1050 Elf32_Word n_namesz;
1051 Elf32_Word n_descsz;
1052 Elf32_Word n_type;
1053} Elf32_Nhdr;
1054
1055typedef struct {
1056 Elf64_Word n_namesz;
1057 Elf64_Word n_descsz;
1058 Elf64_Word n_type;
1059} Elf64_Nhdr;
1060
1061
1062
1063
1064#define ELF_NOTE_SOLARIS "SUNW Solaris"
1065
1066
1067#define ELF_NOTE_GNU "GNU"
1068
1069
1070
1071
1072
1073#define ELF_NOTE_PAGESIZE_HINT 1
1074
1075
1076#define NT_GNU_ABI_TAG 1
1077#define ELF_NOTE_ABI NT_GNU_ABI_TAG
1078
1079
1080
1081#define ELF_NOTE_OS_LINUX 0
1082#define ELF_NOTE_OS_GNU 1
1083#define ELF_NOTE_OS_SOLARIS2 2
1084#define ELF_NOTE_OS_FREEBSD 3
1085
1086#define NT_GNU_BUILD_ID 3
1087#define NT_GNU_GOLD_VERSION 4
1088
1089
1090
1091typedef struct {
1092 Elf32_Xword m_value;
1093 Elf32_Word m_info;
1094 Elf32_Word m_poffset;
1095 Elf32_Half m_repeat;
1096 Elf32_Half m_stride;
1097} Elf32_Move;
1098
1099typedef struct {
1100 Elf64_Xword m_value;
1101 Elf64_Xword m_info;
1102 Elf64_Xword m_poffset;
1103 Elf64_Half m_repeat;
1104 Elf64_Half m_stride;
1105} Elf64_Move;
1106
1107
1108#define ELF32_M_SYM(info) ((info) >> 8)
1109#define ELF32_M_SIZE(info) ((unsigned char) (info))
1110#define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char) (size))
1111
1112#define ELF64_M_SYM(info) ELF32_M_SYM (info)
1113#define ELF64_M_SIZE(info) ELF32_M_SIZE (info)
1114#define ELF64_M_INFO(sym, size) ELF32_M_INFO (sym, size)
1115
1116#define EF_CPU32 0x00810000
1117
1118#define R_68K_NONE 0
1119#define R_68K_32 1
1120#define R_68K_16 2
1121#define R_68K_8 3
1122#define R_68K_PC32 4
1123#define R_68K_PC16 5
1124#define R_68K_PC8 6
1125#define R_68K_GOT32 7
1126#define R_68K_GOT16 8
1127#define R_68K_GOT8 9
1128#define R_68K_GOT32O 10
1129#define R_68K_GOT16O 11
1130#define R_68K_GOT8O 12
1131#define R_68K_PLT32 13
1132#define R_68K_PLT16 14
1133#define R_68K_PLT8 15
1134#define R_68K_PLT32O 16
1135#define R_68K_PLT16O 17
1136#define R_68K_PLT8O 18
1137#define R_68K_COPY 19
1138#define R_68K_GLOB_DAT 20
1139#define R_68K_JMP_SLOT 21
1140#define R_68K_RELATIVE 22
1141#define R_68K_TLS_GD32 25
1142#define R_68K_TLS_GD16 26
1143#define R_68K_TLS_GD8 27
1144#define R_68K_TLS_LDM32 28
1145#define R_68K_TLS_LDM16 29
1146#define R_68K_TLS_LDM8 30
1147#define R_68K_TLS_LDO32 31
1148#define R_68K_TLS_LDO16 32
1149#define R_68K_TLS_LDO8 33
1150#define R_68K_TLS_IE32 34
1151#define R_68K_TLS_IE16 35
1152#define R_68K_TLS_IE8 36
1153#define R_68K_TLS_LE32 37
1154#define R_68K_TLS_LE16 38
1155#define R_68K_TLS_LE8 39
1156#define R_68K_TLS_DTPMOD32 40
1157#define R_68K_TLS_DTPREL32 41
1158#define R_68K_TLS_TPREL32 42
1159#define R_68K_NUM 43
1160
1161#define R_386_NONE 0
1162#define R_386_32 1
1163#define R_386_PC32 2
1164#define R_386_GOT32 3
1165#define R_386_PLT32 4
1166#define R_386_COPY 5
1167#define R_386_GLOB_DAT 6
1168#define R_386_JMP_SLOT 7
1169#define R_386_RELATIVE 8
1170#define R_386_GOTOFF 9
1171#define R_386_GOTPC 10
1172#define R_386_32PLT 11
1173#define R_386_TLS_TPOFF 14
1174#define R_386_TLS_IE 15
1175#define R_386_TLS_GOTIE 16
1176#define R_386_TLS_LE 17
1177#define R_386_TLS_GD 18
1178#define R_386_TLS_LDM 19
1179#define R_386_16 20
1180#define R_386_PC16 21
1181#define R_386_8 22
1182#define R_386_PC8 23
1183#define R_386_TLS_GD_32 24
1184#define R_386_TLS_GD_PUSH 25
1185#define R_386_TLS_GD_CALL 26
1186#define R_386_TLS_GD_POP 27
1187#define R_386_TLS_LDM_32 28
1188#define R_386_TLS_LDM_PUSH 29
1189#define R_386_TLS_LDM_CALL 30
1190#define R_386_TLS_LDM_POP 31
1191#define R_386_TLS_LDO_32 32
1192#define R_386_TLS_IE_32 33
1193#define R_386_TLS_LE_32 34
1194#define R_386_TLS_DTPMOD32 35
1195#define R_386_TLS_DTPOFF32 36
1196#define R_386_TLS_TPOFF32 37
1197#define R_386_SIZE32 38
1198#define R_386_TLS_GOTDESC 39
1199#define R_386_TLS_DESC_CALL 40
1200#define R_386_TLS_DESC 41
1201#define R_386_IRELATIVE 42
1202#define R_386_GOT32X 43
1203#define R_386_NUM 44
1204
1205
1206
1207
1208
1209#define STT_SPARC_REGISTER 13
1210
1211
1212
1213#define EF_SPARCV9_MM 3
1214#define EF_SPARCV9_TSO 0
1215#define EF_SPARCV9_PSO 1
1216#define EF_SPARCV9_RMO 2
1217#define EF_SPARC_LEDATA 0x800000
1218#define EF_SPARC_EXT_MASK 0xFFFF00
1219#define EF_SPARC_32PLUS 0x000100
1220#define EF_SPARC_SUN_US1 0x000200
1221#define EF_SPARC_HAL_R1 0x000400
1222#define EF_SPARC_SUN_US3 0x000800
1223
1224
1225
1226#define R_SPARC_NONE 0
1227#define R_SPARC_8 1
1228#define R_SPARC_16 2
1229#define R_SPARC_32 3
1230#define R_SPARC_DISP8 4
1231#define R_SPARC_DISP16 5
1232#define R_SPARC_DISP32 6
1233#define R_SPARC_WDISP30 7
1234#define R_SPARC_WDISP22 8
1235#define R_SPARC_HI22 9
1236#define R_SPARC_22 10
1237#define R_SPARC_13 11
1238#define R_SPARC_LO10 12
1239#define R_SPARC_GOT10 13
1240#define R_SPARC_GOT13 14
1241#define R_SPARC_GOT22 15
1242#define R_SPARC_PC10 16
1243#define R_SPARC_PC22 17
1244#define R_SPARC_WPLT30 18
1245#define R_SPARC_COPY 19
1246#define R_SPARC_GLOB_DAT 20
1247#define R_SPARC_JMP_SLOT 21
1248#define R_SPARC_RELATIVE 22
1249#define R_SPARC_UA32 23
1250
1251
1252
1253#define R_SPARC_PLT32 24
1254#define R_SPARC_HIPLT22 25
1255#define R_SPARC_LOPLT10 26
1256#define R_SPARC_PCPLT32 27
1257#define R_SPARC_PCPLT22 28
1258#define R_SPARC_PCPLT10 29
1259#define R_SPARC_10 30
1260#define R_SPARC_11 31
1261#define R_SPARC_64 32
1262#define R_SPARC_OLO10 33
1263#define R_SPARC_HH22 34
1264#define R_SPARC_HM10 35
1265#define R_SPARC_LM22 36
1266#define R_SPARC_PC_HH22 37
1267#define R_SPARC_PC_HM10 38
1268#define R_SPARC_PC_LM22 39
1269#define R_SPARC_WDISP16 40
1270#define R_SPARC_WDISP19 41
1271#define R_SPARC_GLOB_JMP 42
1272#define R_SPARC_7 43
1273#define R_SPARC_5 44
1274#define R_SPARC_6 45
1275#define R_SPARC_DISP64 46
1276#define R_SPARC_PLT64 47
1277#define R_SPARC_HIX22 48
1278#define R_SPARC_LOX10 49
1279#define R_SPARC_H44 50
1280#define R_SPARC_M44 51
1281#define R_SPARC_L44 52
1282#define R_SPARC_REGISTER 53
1283#define R_SPARC_UA64 54
1284#define R_SPARC_UA16 55
1285#define R_SPARC_TLS_GD_HI22 56
1286#define R_SPARC_TLS_GD_LO10 57
1287#define R_SPARC_TLS_GD_ADD 58
1288#define R_SPARC_TLS_GD_CALL 59
1289#define R_SPARC_TLS_LDM_HI22 60
1290#define R_SPARC_TLS_LDM_LO10 61
1291#define R_SPARC_TLS_LDM_ADD 62
1292#define R_SPARC_TLS_LDM_CALL 63
1293#define R_SPARC_TLS_LDO_HIX22 64
1294#define R_SPARC_TLS_LDO_LOX10 65
1295#define R_SPARC_TLS_LDO_ADD 66
1296#define R_SPARC_TLS_IE_HI22 67
1297#define R_SPARC_TLS_IE_LO10 68
1298#define R_SPARC_TLS_IE_LD 69
1299#define R_SPARC_TLS_IE_LDX 70
1300#define R_SPARC_TLS_IE_ADD 71
1301#define R_SPARC_TLS_LE_HIX22 72
1302#define R_SPARC_TLS_LE_LOX10 73
1303#define R_SPARC_TLS_DTPMOD32 74
1304#define R_SPARC_TLS_DTPMOD64 75
1305#define R_SPARC_TLS_DTPOFF32 76
1306#define R_SPARC_TLS_DTPOFF64 77
1307#define R_SPARC_TLS_TPOFF32 78
1308#define R_SPARC_TLS_TPOFF64 79
1309#define R_SPARC_GOTDATA_HIX22 80
1310#define R_SPARC_GOTDATA_LOX10 81
1311#define R_SPARC_GOTDATA_OP_HIX22 82
1312#define R_SPARC_GOTDATA_OP_LOX10 83
1313#define R_SPARC_GOTDATA_OP 84
1314#define R_SPARC_H34 85
1315#define R_SPARC_SIZE32 86
1316#define R_SPARC_SIZE64 87
1317#define R_SPARC_GNU_VTINHERIT 250
1318#define R_SPARC_GNU_VTENTRY 251
1319#define R_SPARC_REV32 252
1320
1321#define R_SPARC_NUM 253
1322
1323
1324
1325#define DT_SPARC_REGISTER 0x70000001
1326#define DT_SPARC_NUM 2
1327
1328
1329#define EF_MIPS_NOREORDER 1
1330#define EF_MIPS_PIC 2
1331#define EF_MIPS_CPIC 4
1332#define EF_MIPS_XGOT 8
1333#define EF_MIPS_64BIT_WHIRL 16
1334#define EF_MIPS_ABI2 32
1335#define EF_MIPS_ABI_ON32 64
1336#define EF_MIPS_FP64 512
1337#define EF_MIPS_NAN2008 1024
1338#define EF_MIPS_ARCH 0xf0000000
1339
1340
1341
1342#define EF_MIPS_ARCH_1 0x00000000
1343#define EF_MIPS_ARCH_2 0x10000000
1344#define EF_MIPS_ARCH_3 0x20000000
1345#define EF_MIPS_ARCH_4 0x30000000
1346#define EF_MIPS_ARCH_5 0x40000000
1347#define EF_MIPS_ARCH_32 0x50000000
1348#define EF_MIPS_ARCH_64 0x60000000
1349#define EF_MIPS_ARCH_32R2 0x70000000
1350#define EF_MIPS_ARCH_64R2 0x80000000
1351
1352
1353#define E_MIPS_ARCH_1 0x00000000
1354#define E_MIPS_ARCH_2 0x10000000
1355#define E_MIPS_ARCH_3 0x20000000
1356#define E_MIPS_ARCH_4 0x30000000
1357#define E_MIPS_ARCH_5 0x40000000
1358#define E_MIPS_ARCH_32 0x50000000
1359#define E_MIPS_ARCH_64 0x60000000
1360
1361
1362
1363#define SHN_MIPS_ACOMMON 0xff00
1364#define SHN_MIPS_TEXT 0xff01
1365#define SHN_MIPS_DATA 0xff02
1366#define SHN_MIPS_SCOMMON 0xff03
1367#define SHN_MIPS_SUNDEFINED 0xff04
1368
1369
1370
1371#define SHT_MIPS_LIBLIST 0x70000000
1372#define SHT_MIPS_MSYM 0x70000001
1373#define SHT_MIPS_CONFLICT 0x70000002
1374#define SHT_MIPS_GPTAB 0x70000003
1375#define SHT_MIPS_UCODE 0x70000004
1376#define SHT_MIPS_DEBUG 0x70000005
1377#define SHT_MIPS_REGINFO 0x70000006
1378#define SHT_MIPS_PACKAGE 0x70000007
1379#define SHT_MIPS_PACKSYM 0x70000008
1380#define SHT_MIPS_RELD 0x70000009
1381#define SHT_MIPS_IFACE 0x7000000b
1382#define SHT_MIPS_CONTENT 0x7000000c
1383#define SHT_MIPS_OPTIONS 0x7000000d
1384#define SHT_MIPS_SHDR 0x70000010
1385#define SHT_MIPS_FDESC 0x70000011
1386#define SHT_MIPS_EXTSYM 0x70000012
1387#define SHT_MIPS_DENSE 0x70000013
1388#define SHT_MIPS_PDESC 0x70000014
1389#define SHT_MIPS_LOCSYM 0x70000015
1390#define SHT_MIPS_AUXSYM 0x70000016
1391#define SHT_MIPS_OPTSYM 0x70000017
1392#define SHT_MIPS_LOCSTR 0x70000018
1393#define SHT_MIPS_LINE 0x70000019
1394#define SHT_MIPS_RFDESC 0x7000001a
1395#define SHT_MIPS_DELTASYM 0x7000001b
1396#define SHT_MIPS_DELTAINST 0x7000001c
1397#define SHT_MIPS_DELTACLASS 0x7000001d
1398#define SHT_MIPS_DWARF 0x7000001e
1399#define SHT_MIPS_DELTADECL 0x7000001f
1400#define SHT_MIPS_SYMBOL_LIB 0x70000020
1401#define SHT_MIPS_EVENTS 0x70000021
1402#define SHT_MIPS_TRANSLATE 0x70000022
1403#define SHT_MIPS_PIXIE 0x70000023
1404#define SHT_MIPS_XLATE 0x70000024
1405#define SHT_MIPS_XLATE_DEBUG 0x70000025
1406#define SHT_MIPS_WHIRL 0x70000026
1407#define SHT_MIPS_EH_REGION 0x70000027
1408#define SHT_MIPS_XLATE_OLD 0x70000028
1409#define SHT_MIPS_PDR_EXCEPTION 0x70000029
1410
1411
1412
1413#define SHF_MIPS_GPREL 0x10000000
1414#define SHF_MIPS_MERGE 0x20000000
1415#define SHF_MIPS_ADDR 0x40000000
1416#define SHF_MIPS_STRINGS 0x80000000
1417#define SHF_MIPS_NOSTRIP 0x08000000
1418#define SHF_MIPS_LOCAL 0x04000000
1419#define SHF_MIPS_NAMES 0x02000000
1420#define SHF_MIPS_NODUPE 0x01000000
1421
1422
1423
1424
1425
1426#define STO_MIPS_DEFAULT 0x0
1427#define STO_MIPS_INTERNAL 0x1
1428#define STO_MIPS_HIDDEN 0x2
1429#define STO_MIPS_PROTECTED 0x3
1430#define STO_MIPS_PLT 0x8
1431#define STO_MIPS_SC_ALIGN_UNUSED 0xff
1432
1433
1434#define STB_MIPS_SPLIT_COMMON 13
1435
1436
1437
1438typedef union {
1439 struct {
1440 Elf32_Word gt_current_g_value;
1441 Elf32_Word gt_unused;
1442 } gt_header;
1443 struct {
1444 Elf32_Word gt_g_value;
1445 Elf32_Word gt_bytes;
1446 } gt_entry;
1447} Elf32_gptab;
1448
1449
1450
1451typedef struct {
1452 Elf32_Word ri_gprmask;
1453 Elf32_Word ri_cprmask[4];
1454 Elf32_Sword ri_gp_value;
1455} Elf32_RegInfo;
1456
1457
1458
1459typedef struct {
1460 unsigned char kind;
1461
1462 unsigned char size;
1463 Elf32_Section section;
1464
1465 Elf32_Word info;
1466} Elf_Options;
1467
1468
1469
1470#define ODK_NULL 0
1471#define ODK_REGINFO 1
1472#define ODK_EXCEPTIONS 2
1473#define ODK_PAD 3
1474#define ODK_HWPATCH 4
1475#define ODK_FILL 5
1476#define ODK_TAGS 6
1477#define ODK_HWAND 7
1478#define ODK_HWOR 8
1479
1480
1481
1482#define OEX_FPU_MIN 0x1f
1483#define OEX_FPU_MAX 0x1f00
1484#define OEX_PAGE0 0x10000
1485#define OEX_SMM 0x20000
1486#define OEX_FPDBUG 0x40000
1487#define OEX_PRECISEFP OEX_FPDBUG
1488#define OEX_DISMISS 0x80000
1489
1490#define OEX_FPU_INVAL 0x10
1491#define OEX_FPU_DIV0 0x08
1492#define OEX_FPU_OFLO 0x04
1493#define OEX_FPU_UFLO 0x02
1494#define OEX_FPU_INEX 0x01
1495
1496
1497
1498#define OHW_R4KEOP 0x1
1499#define OHW_R8KPFETCH 0x2
1500#define OHW_R5KEOP 0x4
1501#define OHW_R5KCVTL 0x8
1502
1503#define OPAD_PREFIX 0x1
1504#define OPAD_POSTFIX 0x2
1505#define OPAD_SYMBOL 0x4
1506
1507
1508
1509typedef struct {
1510 Elf32_Word hwp_flags1;
1511 Elf32_Word hwp_flags2;
1512} Elf_Options_Hw;
1513
1514
1515
1516#define OHWA0_R4KEOP_CHECKED 0x00000001
1517#define OHWA1_R4KEOP_CLEAN 0x00000002
1518
1519
1520
1521#define R_MIPS_NONE 0
1522#define R_MIPS_16 1
1523#define R_MIPS_32 2
1524#define R_MIPS_REL32 3
1525#define R_MIPS_26 4
1526#define R_MIPS_HI16 5
1527#define R_MIPS_LO16 6
1528#define R_MIPS_GPREL16 7
1529#define R_MIPS_LITERAL 8
1530#define R_MIPS_GOT16 9
1531#define R_MIPS_PC16 10
1532#define R_MIPS_CALL16 11
1533#define R_MIPS_GPREL32 12
1534
1535#define R_MIPS_SHIFT5 16
1536#define R_MIPS_SHIFT6 17
1537#define R_MIPS_64 18
1538#define R_MIPS_GOT_DISP 19
1539#define R_MIPS_GOT_PAGE 20
1540#define R_MIPS_GOT_OFST 21
1541#define R_MIPS_GOT_HI16 22
1542#define R_MIPS_GOT_LO16 23
1543#define R_MIPS_SUB 24
1544#define R_MIPS_INSERT_A 25
1545#define R_MIPS_INSERT_B 26
1546#define R_MIPS_DELETE 27
1547#define R_MIPS_HIGHER 28
1548#define R_MIPS_HIGHEST 29
1549#define R_MIPS_CALL_HI16 30
1550#define R_MIPS_CALL_LO16 31
1551#define R_MIPS_SCN_DISP 32
1552#define R_MIPS_REL16 33
1553#define R_MIPS_ADD_IMMEDIATE 34
1554#define R_MIPS_PJUMP 35
1555#define R_MIPS_RELGOT 36
1556#define R_MIPS_JALR 37
1557#define R_MIPS_TLS_DTPMOD32 38
1558#define R_MIPS_TLS_DTPREL32 39
1559#define R_MIPS_TLS_DTPMOD64 40
1560#define R_MIPS_TLS_DTPREL64 41
1561#define R_MIPS_TLS_GD 42
1562#define R_MIPS_TLS_LDM 43
1563#define R_MIPS_TLS_DTPREL_HI16 44
1564#define R_MIPS_TLS_DTPREL_LO16 45
1565#define R_MIPS_TLS_GOTTPREL 46
1566#define R_MIPS_TLS_TPREL32 47
1567#define R_MIPS_TLS_TPREL64 48
1568#define R_MIPS_TLS_TPREL_HI16 49
1569#define R_MIPS_TLS_TPREL_LO16 50
1570#define R_MIPS_GLOB_DAT 51
1571#define R_MIPS_COPY 126
1572#define R_MIPS_JUMP_SLOT 127
1573
1574#define R_MIPS_NUM 128
1575
1576
1577
1578#define PT_MIPS_REGINFO 0x70000000
1579#define PT_MIPS_RTPROC 0x70000001
1580#define PT_MIPS_OPTIONS 0x70000002
1581#define PT_MIPS_ABIFLAGS 0x70000003
1582
1583
1584
1585#define PF_MIPS_LOCAL 0x10000000
1586
1587
1588
1589#define DT_MIPS_RLD_VERSION 0x70000001
1590#define DT_MIPS_TIME_STAMP 0x70000002
1591#define DT_MIPS_ICHECKSUM 0x70000003
1592#define DT_MIPS_IVERSION 0x70000004
1593#define DT_MIPS_FLAGS 0x70000005
1594#define DT_MIPS_BASE_ADDRESS 0x70000006
1595#define DT_MIPS_MSYM 0x70000007
1596#define DT_MIPS_CONFLICT 0x70000008
1597#define DT_MIPS_LIBLIST 0x70000009
1598#define DT_MIPS_LOCAL_GOTNO 0x7000000a
1599#define DT_MIPS_CONFLICTNO 0x7000000b
1600#define DT_MIPS_LIBLISTNO 0x70000010
1601#define DT_MIPS_SYMTABNO 0x70000011
1602#define DT_MIPS_UNREFEXTNO 0x70000012
1603#define DT_MIPS_GOTSYM 0x70000013
1604#define DT_MIPS_HIPAGENO 0x70000014
1605#define DT_MIPS_RLD_MAP 0x70000016
1606#define DT_MIPS_DELTA_CLASS 0x70000017
1607#define DT_MIPS_DELTA_CLASS_NO 0x70000018
1608
1609#define DT_MIPS_DELTA_INSTANCE 0x70000019
1610#define DT_MIPS_DELTA_INSTANCE_NO 0x7000001a
1611
1612#define DT_MIPS_DELTA_RELOC 0x7000001b
1613#define DT_MIPS_DELTA_RELOC_NO 0x7000001c
1614
1615#define DT_MIPS_DELTA_SYM 0x7000001d
1616
1617#define DT_MIPS_DELTA_SYM_NO 0x7000001e
1618
1619#define DT_MIPS_DELTA_CLASSSYM 0x70000020
1620
1621#define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021
1622
1623#define DT_MIPS_CXX_FLAGS 0x70000022
1624#define DT_MIPS_PIXIE_INIT 0x70000023
1625#define DT_MIPS_SYMBOL_LIB 0x70000024
1626#define DT_MIPS_LOCALPAGE_GOTIDX 0x70000025
1627#define DT_MIPS_LOCAL_GOTIDX 0x70000026
1628#define DT_MIPS_HIDDEN_GOTIDX 0x70000027
1629#define DT_MIPS_PROTECTED_GOTIDX 0x70000028
1630#define DT_MIPS_OPTIONS 0x70000029
1631#define DT_MIPS_INTERFACE 0x7000002a
1632#define DT_MIPS_DYNSTR_ALIGN 0x7000002b
1633#define DT_MIPS_INTERFACE_SIZE 0x7000002c
1634#define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002d
1635
1636#define DT_MIPS_PERF_SUFFIX 0x7000002e
1637
1638#define DT_MIPS_COMPACT_SIZE 0x7000002f
1639#define DT_MIPS_GP_VALUE 0x70000030
1640#define DT_MIPS_AUX_DYNAMIC 0x70000031
1641
1642#define DT_MIPS_PLTGOT 0x70000032
1643
1644#define DT_MIPS_RWPLT 0x70000034
1645#define DT_MIPS_RLD_MAP_REL 0x70000035
1646#define DT_MIPS_NUM 0x36
1647
1648
1649
1650#define RHF_NONE 0
1651#define RHF_QUICKSTART (1 << 0)
1652#define RHF_NOTPOT (1 << 1)
1653#define RHF_NO_LIBRARY_REPLACEMENT (1 << 2)
1654#define RHF_NO_MOVE (1 << 3)
1655#define RHF_SGI_ONLY (1 << 4)
1656#define RHF_GUARANTEE_INIT (1 << 5)
1657#define RHF_DELTA_C_PLUS_PLUS (1 << 6)
1658#define RHF_GUARANTEE_START_INIT (1 << 7)
1659#define RHF_PIXIE (1 << 8)
1660#define RHF_DEFAULT_DELAY_LOAD (1 << 9)
1661#define RHF_REQUICKSTART (1 << 10)
1662#define RHF_REQUICKSTARTED (1 << 11)
1663#define RHF_CORD (1 << 12)
1664#define RHF_NO_UNRES_UNDEF (1 << 13)
1665#define RHF_RLD_ORDER_SAFE (1 << 14)
1666
1667
1668
1669typedef struct {
1670 Elf32_Word l_name;
1671 Elf32_Word l_time_stamp;
1672 Elf32_Word l_checksum;
1673 Elf32_Word l_version;
1674 Elf32_Word l_flags;
1675} Elf32_Lib;
1676
1677typedef struct {
1678 Elf64_Word l_name;
1679 Elf64_Word l_time_stamp;
1680 Elf64_Word l_checksum;
1681 Elf64_Word l_version;
1682 Elf64_Word l_flags;
1683} Elf64_Lib;
1684
1685
1686
1687
1688#define LL_NONE 0
1689#define LL_EXACT_MATCH (1 << 0)
1690#define LL_IGNORE_INT_VER (1 << 1)
1691#define LL_REQUIRE_MINOR (1 << 2)
1692#define LL_EXPORTS (1 << 3)
1693#define LL_DELAY_LOAD (1 << 4)
1694#define LL_DELTA (1 << 5)
1695
1696
1697
1698typedef Elf32_Addr Elf32_Conflict;
1699
1700typedef struct {
1701 Elf32_Half version;
1702 unsigned char isa_level;
1703 unsigned char isa_rev;
1704 unsigned char gpr_size;
1705 unsigned char cpr1_size;
1706 unsigned char cpr2_size;
1707 unsigned char fp_abi;
1708 Elf32_Word isa_ext;
1709 Elf32_Word ases;
1710 Elf32_Word flags1;
1711 Elf32_Word flags2;
1712} Elf_MIPS_ABIFlags_v0;
1713
1714#define MIPS_AFL_REG_NONE 0x00
1715#define MIPS_AFL_REG_32 0x01
1716#define MIPS_AFL_REG_64 0x02
1717#define MIPS_AFL_REG_128 0x03
1718
1719#define MIPS_AFL_ASE_DSP 0x00000001
1720#define MIPS_AFL_ASE_DSPR2 0x00000002
1721#define MIPS_AFL_ASE_EVA 0x00000004
1722#define MIPS_AFL_ASE_MCU 0x00000008
1723#define MIPS_AFL_ASE_MDMX 0x00000010
1724#define MIPS_AFL_ASE_MIPS3D 0x00000020
1725#define MIPS_AFL_ASE_MT 0x00000040
1726#define MIPS_AFL_ASE_SMARTMIPS 0x00000080
1727#define MIPS_AFL_ASE_VIRT 0x00000100
1728#define MIPS_AFL_ASE_MSA 0x00000200
1729#define MIPS_AFL_ASE_MIPS16 0x00000400
1730#define MIPS_AFL_ASE_MICROMIPS 0x00000800
1731#define MIPS_AFL_ASE_XPA 0x00001000
1732#define MIPS_AFL_ASE_MASK 0x00001fff
1733
1734#define MIPS_AFL_EXT_XLR 1
1735#define MIPS_AFL_EXT_OCTEON2 2
1736#define MIPS_AFL_EXT_OCTEONP 3
1737#define MIPS_AFL_EXT_LOONGSON_3A 4
1738#define MIPS_AFL_EXT_OCTEON 5
1739#define MIPS_AFL_EXT_5900 6
1740#define MIPS_AFL_EXT_4650 7
1741#define MIPS_AFL_EXT_4010 8
1742#define MIPS_AFL_EXT_4100 9
1743#define MIPS_AFL_EXT_3900 10
1744#define MIPS_AFL_EXT_10000 11
1745#define MIPS_AFL_EXT_SB1 12
1746#define MIPS_AFL_EXT_4111 13
1747#define MIPS_AFL_EXT_4120 14
1748#define MIPS_AFL_EXT_5400 15
1749#define MIPS_AFL_EXT_5500 16
1750#define MIPS_AFL_EXT_LOONGSON_2E 17
1751#define MIPS_AFL_EXT_LOONGSON_2F 18
1752
1753#define MIPS_AFL_FLAGS1_ODDSPREG 1
1754
1755enum
1756{
1757 Val_GNU_MIPS_ABI_FP_ANY = 0,
1758 Val_GNU_MIPS_ABI_FP_DOUBLE = 1,
1759 Val_GNU_MIPS_ABI_FP_SINGLE = 2,
1760 Val_GNU_MIPS_ABI_FP_SOFT = 3,
1761 Val_GNU_MIPS_ABI_FP_OLD_64 = 4,
1762 Val_GNU_MIPS_ABI_FP_XX = 5,
1763 Val_GNU_MIPS_ABI_FP_64 = 6,
1764 Val_GNU_MIPS_ABI_FP_64A = 7,
1765 Val_GNU_MIPS_ABI_FP_MAX = 7
1766};
1767
1768
1769
1770
1771#define EF_PARISC_TRAPNIL 0x00010000
1772#define EF_PARISC_EXT 0x00020000
1773#define EF_PARISC_LSB 0x00040000
1774#define EF_PARISC_WIDE 0x00080000
1775#define EF_PARISC_NO_KABP 0x00100000
1776
1777#define EF_PARISC_LAZYSWAP 0x00400000
1778#define EF_PARISC_ARCH 0x0000ffff
1779
1780
1781
1782#define EFA_PARISC_1_0 0x020b
1783#define EFA_PARISC_1_1 0x0210
1784#define EFA_PARISC_2_0 0x0214
1785
1786
1787
1788#define SHN_PARISC_ANSI_COMMON 0xff00
1789
1790#define SHN_PARISC_HUGE_COMMON 0xff01
1791
1792
1793
1794#define SHT_PARISC_EXT 0x70000000
1795#define SHT_PARISC_UNWIND 0x70000001
1796#define SHT_PARISC_DOC 0x70000002
1797
1798
1799
1800#define SHF_PARISC_SHORT 0x20000000
1801#define SHF_PARISC_HUGE 0x40000000
1802#define SHF_PARISC_SBP 0x80000000
1803
1804
1805
1806#define STT_PARISC_MILLICODE 13
1807
1808#define STT_HP_OPAQUE (STT_LOOS + 0x1)
1809#define STT_HP_STUB (STT_LOOS + 0x2)
1810
1811
1812
1813#define R_PARISC_NONE 0
1814#define R_PARISC_DIR32 1
1815#define R_PARISC_DIR21L 2
1816#define R_PARISC_DIR17R 3
1817#define R_PARISC_DIR17F 4
1818#define R_PARISC_DIR14R 6
1819#define R_PARISC_PCREL32 9
1820#define R_PARISC_PCREL21L 10
1821#define R_PARISC_PCREL17R 11
1822#define R_PARISC_PCREL17F 12
1823#define R_PARISC_PCREL14R 14
1824#define R_PARISC_DPREL21L 18
1825#define R_PARISC_DPREL14R 22
1826#define R_PARISC_GPREL21L 26
1827#define R_PARISC_GPREL14R 30
1828#define R_PARISC_LTOFF21L 34
1829#define R_PARISC_LTOFF14R 38
1830#define R_PARISC_SECREL32 41
1831#define R_PARISC_SEGBASE 48
1832#define R_PARISC_SEGREL32 49
1833#define R_PARISC_PLTOFF21L 50
1834#define R_PARISC_PLTOFF14R 54
1835#define R_PARISC_LTOFF_FPTR32 57
1836#define R_PARISC_LTOFF_FPTR21L 58
1837#define R_PARISC_LTOFF_FPTR14R 62
1838#define R_PARISC_FPTR64 64
1839#define R_PARISC_PLABEL32 65
1840#define R_PARISC_PLABEL21L 66
1841#define R_PARISC_PLABEL14R 70
1842#define R_PARISC_PCREL64 72
1843#define R_PARISC_PCREL22F 74
1844#define R_PARISC_PCREL14WR 75
1845#define R_PARISC_PCREL14DR 76
1846#define R_PARISC_PCREL16F 77
1847#define R_PARISC_PCREL16WF 78
1848#define R_PARISC_PCREL16DF 79
1849#define R_PARISC_DIR64 80
1850#define R_PARISC_DIR14WR 83
1851#define R_PARISC_DIR14DR 84
1852#define R_PARISC_DIR16F 85
1853#define R_PARISC_DIR16WF 86
1854#define R_PARISC_DIR16DF 87
1855#define R_PARISC_GPREL64 88
1856#define R_PARISC_GPREL14WR 91
1857#define R_PARISC_GPREL14DR 92
1858#define R_PARISC_GPREL16F 93
1859#define R_PARISC_GPREL16WF 94
1860#define R_PARISC_GPREL16DF 95
1861#define R_PARISC_LTOFF64 96
1862#define R_PARISC_LTOFF14WR 99
1863#define R_PARISC_LTOFF14DR 100
1864#define R_PARISC_LTOFF16F 101
1865#define R_PARISC_LTOFF16WF 102
1866#define R_PARISC_LTOFF16DF 103
1867#define R_PARISC_SECREL64 104
1868#define R_PARISC_SEGREL64 112
1869#define R_PARISC_PLTOFF14WR 115
1870#define R_PARISC_PLTOFF14DR 116
1871#define R_PARISC_PLTOFF16F 117
1872#define R_PARISC_PLTOFF16WF 118
1873#define R_PARISC_PLTOFF16DF 119
1874#define R_PARISC_LTOFF_FPTR64 120
1875#define R_PARISC_LTOFF_FPTR14WR 123
1876#define R_PARISC_LTOFF_FPTR14DR 124
1877#define R_PARISC_LTOFF_FPTR16F 125
1878#define R_PARISC_LTOFF_FPTR16WF 126
1879#define R_PARISC_LTOFF_FPTR16DF 127
1880#define R_PARISC_LORESERVE 128
1881#define R_PARISC_COPY 128
1882#define R_PARISC_IPLT 129
1883#define R_PARISC_EPLT 130
1884#define R_PARISC_TPREL32 153
1885#define R_PARISC_TPREL21L 154
1886#define R_PARISC_TPREL14R 158
1887#define R_PARISC_LTOFF_TP21L 162
1888#define R_PARISC_LTOFF_TP14R 166
1889#define R_PARISC_LTOFF_TP14F 167
1890#define R_PARISC_TPREL64 216
1891#define R_PARISC_TPREL14WR 219
1892#define R_PARISC_TPREL14DR 220
1893#define R_PARISC_TPREL16F 221
1894#define R_PARISC_TPREL16WF 222
1895#define R_PARISC_TPREL16DF 223
1896#define R_PARISC_LTOFF_TP64 224
1897#define R_PARISC_LTOFF_TP14WR 227
1898#define R_PARISC_LTOFF_TP14DR 228
1899#define R_PARISC_LTOFF_TP16F 229
1900#define R_PARISC_LTOFF_TP16WF 230
1901#define R_PARISC_LTOFF_TP16DF 231
1902#define R_PARISC_GNU_VTENTRY 232
1903#define R_PARISC_GNU_VTINHERIT 233
1904#define R_PARISC_TLS_GD21L 234
1905#define R_PARISC_TLS_GD14R 235
1906#define R_PARISC_TLS_GDCALL 236
1907#define R_PARISC_TLS_LDM21L 237
1908#define R_PARISC_TLS_LDM14R 238
1909#define R_PARISC_TLS_LDMCALL 239
1910#define R_PARISC_TLS_LDO21L 240
1911#define R_PARISC_TLS_LDO14R 241
1912#define R_PARISC_TLS_DTPMOD32 242
1913#define R_PARISC_TLS_DTPMOD64 243
1914#define R_PARISC_TLS_DTPOFF32 244
1915#define R_PARISC_TLS_DTPOFF64 245
1916#define R_PARISC_TLS_LE21L R_PARISC_TPREL21L
1917#define R_PARISC_TLS_LE14R R_PARISC_TPREL14R
1918#define R_PARISC_TLS_IE21L R_PARISC_LTOFF_TP21L
1919#define R_PARISC_TLS_IE14R R_PARISC_LTOFF_TP14R
1920#define R_PARISC_TLS_TPREL32 R_PARISC_TPREL32
1921#define R_PARISC_TLS_TPREL64 R_PARISC_TPREL64
1922#define R_PARISC_HIRESERVE 255
1923
1924
1925
1926#define PT_HP_TLS (PT_LOOS + 0x0)
1927#define PT_HP_CORE_NONE (PT_LOOS + 0x1)
1928#define PT_HP_CORE_VERSION (PT_LOOS + 0x2)
1929#define PT_HP_CORE_KERNEL (PT_LOOS + 0x3)
1930#define PT_HP_CORE_COMM (PT_LOOS + 0x4)
1931#define PT_HP_CORE_PROC (PT_LOOS + 0x5)
1932#define PT_HP_CORE_LOADABLE (PT_LOOS + 0x6)
1933#define PT_HP_CORE_STACK (PT_LOOS + 0x7)
1934#define PT_HP_CORE_SHM (PT_LOOS + 0x8)
1935#define PT_HP_CORE_MMF (PT_LOOS + 0x9)
1936#define PT_HP_PARALLEL (PT_LOOS + 0x10)
1937#define PT_HP_FASTBIND (PT_LOOS + 0x11)
1938#define PT_HP_OPT_ANNOT (PT_LOOS + 0x12)
1939#define PT_HP_HSL_ANNOT (PT_LOOS + 0x13)
1940#define PT_HP_STACK (PT_LOOS + 0x14)
1941
1942#define PT_PARISC_ARCHEXT 0x70000000
1943#define PT_PARISC_UNWIND 0x70000001
1944
1945
1946
1947#define PF_PARISC_SBP 0x08000000
1948
1949#define PF_HP_PAGE_SIZE 0x00100000
1950#define PF_HP_FAR_SHARED 0x00200000
1951#define PF_HP_NEAR_SHARED 0x00400000
1952#define PF_HP_CODE 0x01000000
1953#define PF_HP_MODIFY 0x02000000
1954#define PF_HP_LAZYSWAP 0x04000000
1955#define PF_HP_SBP 0x08000000
1956
1957
1958
1959
1960
1961
1962#define EF_ALPHA_32BIT 1
1963#define EF_ALPHA_CANRELAX 2
1964
1965
1966
1967
1968#define SHT_ALPHA_DEBUG 0x70000001
1969#define SHT_ALPHA_REGINFO 0x70000002
1970
1971
1972
1973#define SHF_ALPHA_GPREL 0x10000000
1974
1975
1976#define STO_ALPHA_NOPV 0x80
1977#define STO_ALPHA_STD_GPLOAD 0x88
1978
1979
1980
1981#define R_ALPHA_NONE 0
1982#define R_ALPHA_REFLONG 1
1983#define R_ALPHA_REFQUAD 2
1984#define R_ALPHA_GPREL32 3
1985#define R_ALPHA_LITERAL 4
1986#define R_ALPHA_LITUSE 5
1987#define R_ALPHA_GPDISP 6
1988#define R_ALPHA_BRADDR 7
1989#define R_ALPHA_HINT 8
1990#define R_ALPHA_SREL16 9
1991#define R_ALPHA_SREL32 10
1992#define R_ALPHA_SREL64 11
1993#define R_ALPHA_GPRELHIGH 17
1994#define R_ALPHA_GPRELLOW 18
1995#define R_ALPHA_GPREL16 19
1996#define R_ALPHA_COPY 24
1997#define R_ALPHA_GLOB_DAT 25
1998#define R_ALPHA_JMP_SLOT 26
1999#define R_ALPHA_RELATIVE 27
2000#define R_ALPHA_TLS_GD_HI 28
2001#define R_ALPHA_TLSGD 29
2002#define R_ALPHA_TLS_LDM 30
2003#define R_ALPHA_DTPMOD64 31
2004#define R_ALPHA_GOTDTPREL 32
2005#define R_ALPHA_DTPREL64 33
2006#define R_ALPHA_DTPRELHI 34
2007#define R_ALPHA_DTPRELLO 35
2008#define R_ALPHA_DTPREL16 36
2009#define R_ALPHA_GOTTPREL 37
2010#define R_ALPHA_TPREL64 38
2011#define R_ALPHA_TPRELHI 39
2012#define R_ALPHA_TPRELLO 40
2013#define R_ALPHA_TPREL16 41
2014
2015#define R_ALPHA_NUM 46
2016
2017
2018#define LITUSE_ALPHA_ADDR 0
2019#define LITUSE_ALPHA_BASE 1
2020#define LITUSE_ALPHA_BYTOFF 2
2021#define LITUSE_ALPHA_JSR 3
2022#define LITUSE_ALPHA_TLS_GD 4
2023#define LITUSE_ALPHA_TLS_LDM 5
2024
2025
2026#define DT_ALPHA_PLTRO (DT_LOPROC + 0)
2027#define DT_ALPHA_NUM 1
2028
2029
2030
2031
2032#define EF_PPC_EMB 0x80000000
2033
2034
2035#define EF_PPC_RELOCATABLE 0x00010000
2036#define EF_PPC_RELOCATABLE_LIB 0x00008000
2037
2038
2039
2040#define R_PPC_NONE 0
2041#define R_PPC_ADDR32 1
2042#define R_PPC_ADDR24 2
2043#define R_PPC_ADDR16 3
2044#define R_PPC_ADDR16_LO 4
2045#define R_PPC_ADDR16_HI 5
2046#define R_PPC_ADDR16_HA 6
2047#define R_PPC_ADDR14 7
2048#define R_PPC_ADDR14_BRTAKEN 8
2049#define R_PPC_ADDR14_BRNTAKEN 9
2050#define R_PPC_REL24 10
2051#define R_PPC_REL14 11
2052#define R_PPC_REL14_BRTAKEN 12
2053#define R_PPC_REL14_BRNTAKEN 13
2054#define R_PPC_GOT16 14
2055#define R_PPC_GOT16_LO 15
2056#define R_PPC_GOT16_HI 16
2057#define R_PPC_GOT16_HA 17
2058#define R_PPC_PLTREL24 18
2059#define R_PPC_COPY 19
2060#define R_PPC_GLOB_DAT 20
2061#define R_PPC_JMP_SLOT 21
2062#define R_PPC_RELATIVE 22
2063#define R_PPC_LOCAL24PC 23
2064#define R_PPC_UADDR32 24
2065#define R_PPC_UADDR16 25
2066#define R_PPC_REL32 26
2067#define R_PPC_PLT32 27
2068#define R_PPC_PLTREL32 28
2069#define R_PPC_PLT16_LO 29
2070#define R_PPC_PLT16_HI 30
2071#define R_PPC_PLT16_HA 31
2072#define R_PPC_SDAREL16 32
2073#define R_PPC_SECTOFF 33
2074#define R_PPC_SECTOFF_LO 34
2075#define R_PPC_SECTOFF_HI 35
2076#define R_PPC_SECTOFF_HA 36
2077
2078
2079#define R_PPC_TLS 67
2080#define R_PPC_DTPMOD32 68
2081#define R_PPC_TPREL16 69
2082#define R_PPC_TPREL16_LO 70
2083#define R_PPC_TPREL16_HI 71
2084#define R_PPC_TPREL16_HA 72
2085#define R_PPC_TPREL32 73
2086#define R_PPC_DTPREL16 74
2087#define R_PPC_DTPREL16_LO 75
2088#define R_PPC_DTPREL16_HI 76
2089#define R_PPC_DTPREL16_HA 77
2090#define R_PPC_DTPREL32 78
2091#define R_PPC_GOT_TLSGD16 79
2092#define R_PPC_GOT_TLSGD16_LO 80
2093#define R_PPC_GOT_TLSGD16_HI 81
2094#define R_PPC_GOT_TLSGD16_HA 82
2095#define R_PPC_GOT_TLSLD16 83
2096#define R_PPC_GOT_TLSLD16_LO 84
2097#define R_PPC_GOT_TLSLD16_HI 85
2098#define R_PPC_GOT_TLSLD16_HA 86
2099#define R_PPC_GOT_TPREL16 87
2100#define R_PPC_GOT_TPREL16_LO 88
2101#define R_PPC_GOT_TPREL16_HI 89
2102#define R_PPC_GOT_TPREL16_HA 90
2103#define R_PPC_GOT_DTPREL16 91
2104#define R_PPC_GOT_DTPREL16_LO 92
2105#define R_PPC_GOT_DTPREL16_HI 93
2106#define R_PPC_GOT_DTPREL16_HA 94
2107#define R_PPC_TLSGD 95
2108#define R_PPC_TLSLD 96
2109
2110
2111#define R_PPC_EMB_NADDR32 101
2112#define R_PPC_EMB_NADDR16 102
2113#define R_PPC_EMB_NADDR16_LO 103
2114#define R_PPC_EMB_NADDR16_HI 104
2115#define R_PPC_EMB_NADDR16_HA 105
2116#define R_PPC_EMB_SDAI16 106
2117#define R_PPC_EMB_SDA2I16 107
2118#define R_PPC_EMB_SDA2REL 108
2119#define R_PPC_EMB_SDA21 109
2120#define R_PPC_EMB_MRKREF 110
2121#define R_PPC_EMB_RELSEC16 111
2122#define R_PPC_EMB_RELST_LO 112
2123#define R_PPC_EMB_RELST_HI 113
2124#define R_PPC_EMB_RELST_HA 114
2125#define R_PPC_EMB_BIT_FLD 115
2126#define R_PPC_EMB_RELSDA 116
2127
2128
2129#define R_PPC_DIAB_SDA21_LO 180
2130#define R_PPC_DIAB_SDA21_HI 181
2131#define R_PPC_DIAB_SDA21_HA 182
2132#define R_PPC_DIAB_RELSDA_LO 183
2133#define R_PPC_DIAB_RELSDA_HI 184
2134#define R_PPC_DIAB_RELSDA_HA 185
2135
2136
2137#define R_PPC_IRELATIVE 248
2138
2139
2140#define R_PPC_REL16 249
2141#define R_PPC_REL16_LO 250
2142#define R_PPC_REL16_HI 251
2143#define R_PPC_REL16_HA 252
2144
2145
2146
2147#define R_PPC_TOC16 255
2148
2149
2150#define DT_PPC_GOT (DT_LOPROC + 0)
2151#define DT_PPC_OPT (DT_LOPROC + 1)
2152#define DT_PPC_NUM 2
2153
2154#define PPC_OPT_TLS 1
2155
2156
2157#define R_PPC64_NONE R_PPC_NONE
2158#define R_PPC64_ADDR32 R_PPC_ADDR32
2159#define R_PPC64_ADDR24 R_PPC_ADDR24
2160#define R_PPC64_ADDR16 R_PPC_ADDR16
2161#define R_PPC64_ADDR16_LO R_PPC_ADDR16_LO
2162#define R_PPC64_ADDR16_HI R_PPC_ADDR16_HI
2163#define R_PPC64_ADDR16_HA R_PPC_ADDR16_HA
2164#define R_PPC64_ADDR14 R_PPC_ADDR14
2165#define R_PPC64_ADDR14_BRTAKEN R_PPC_ADDR14_BRTAKEN
2166#define R_PPC64_ADDR14_BRNTAKEN R_PPC_ADDR14_BRNTAKEN
2167#define R_PPC64_REL24 R_PPC_REL24
2168#define R_PPC64_REL14 R_PPC_REL14
2169#define R_PPC64_REL14_BRTAKEN R_PPC_REL14_BRTAKEN
2170#define R_PPC64_REL14_BRNTAKEN R_PPC_REL14_BRNTAKEN
2171#define R_PPC64_GOT16 R_PPC_GOT16
2172#define R_PPC64_GOT16_LO R_PPC_GOT16_LO
2173#define R_PPC64_GOT16_HI R_PPC_GOT16_HI
2174#define R_PPC64_GOT16_HA R_PPC_GOT16_HA
2175
2176#define R_PPC64_COPY R_PPC_COPY
2177#define R_PPC64_GLOB_DAT R_PPC_GLOB_DAT
2178#define R_PPC64_JMP_SLOT R_PPC_JMP_SLOT
2179#define R_PPC64_RELATIVE R_PPC_RELATIVE
2180
2181#define R_PPC64_UADDR32 R_PPC_UADDR32
2182#define R_PPC64_UADDR16 R_PPC_UADDR16
2183#define R_PPC64_REL32 R_PPC_REL32
2184#define R_PPC64_PLT32 R_PPC_PLT32
2185#define R_PPC64_PLTREL32 R_PPC_PLTREL32
2186#define R_PPC64_PLT16_LO R_PPC_PLT16_LO
2187#define R_PPC64_PLT16_HI R_PPC_PLT16_HI
2188#define R_PPC64_PLT16_HA R_PPC_PLT16_HA
2189
2190#define R_PPC64_SECTOFF R_PPC_SECTOFF
2191#define R_PPC64_SECTOFF_LO R_PPC_SECTOFF_LO
2192#define R_PPC64_SECTOFF_HI R_PPC_SECTOFF_HI
2193#define R_PPC64_SECTOFF_HA R_PPC_SECTOFF_HA
2194#define R_PPC64_ADDR30 37
2195#define R_PPC64_ADDR64 38
2196#define R_PPC64_ADDR16_HIGHER 39
2197#define R_PPC64_ADDR16_HIGHERA 40
2198#define R_PPC64_ADDR16_HIGHEST 41
2199#define R_PPC64_ADDR16_HIGHESTA 42
2200#define R_PPC64_UADDR64 43
2201#define R_PPC64_REL64 44
2202#define R_PPC64_PLT64 45
2203#define R_PPC64_PLTREL64 46
2204#define R_PPC64_TOC16 47
2205#define R_PPC64_TOC16_LO 48
2206#define R_PPC64_TOC16_HI 49
2207#define R_PPC64_TOC16_HA 50
2208#define R_PPC64_TOC 51
2209#define R_PPC64_PLTGOT16 52
2210#define R_PPC64_PLTGOT16_LO 53
2211#define R_PPC64_PLTGOT16_HI 54
2212#define R_PPC64_PLTGOT16_HA 55
2213
2214#define R_PPC64_ADDR16_DS 56
2215#define R_PPC64_ADDR16_LO_DS 57
2216#define R_PPC64_GOT16_DS 58
2217#define R_PPC64_GOT16_LO_DS 59
2218#define R_PPC64_PLT16_LO_DS 60
2219#define R_PPC64_SECTOFF_DS 61
2220#define R_PPC64_SECTOFF_LO_DS 62
2221#define R_PPC64_TOC16_DS 63
2222#define R_PPC64_TOC16_LO_DS 64
2223#define R_PPC64_PLTGOT16_DS 65
2224#define R_PPC64_PLTGOT16_LO_DS 66
2225
2226
2227#define R_PPC64_TLS 67
2228#define R_PPC64_DTPMOD64 68
2229#define R_PPC64_TPREL16 69
2230#define R_PPC64_TPREL16_LO 70
2231#define R_PPC64_TPREL16_HI 71
2232#define R_PPC64_TPREL16_HA 72
2233#define R_PPC64_TPREL64 73
2234#define R_PPC64_DTPREL16 74
2235#define R_PPC64_DTPREL16_LO 75
2236#define R_PPC64_DTPREL16_HI 76
2237#define R_PPC64_DTPREL16_HA 77
2238#define R_PPC64_DTPREL64 78
2239#define R_PPC64_GOT_TLSGD16 79
2240#define R_PPC64_GOT_TLSGD16_LO 80
2241#define R_PPC64_GOT_TLSGD16_HI 81
2242#define R_PPC64_GOT_TLSGD16_HA 82
2243#define R_PPC64_GOT_TLSLD16 83
2244#define R_PPC64_GOT_TLSLD16_LO 84
2245#define R_PPC64_GOT_TLSLD16_HI 85
2246#define R_PPC64_GOT_TLSLD16_HA 86
2247#define R_PPC64_GOT_TPREL16_DS 87
2248#define R_PPC64_GOT_TPREL16_LO_DS 88
2249#define R_PPC64_GOT_TPREL16_HI 89
2250#define R_PPC64_GOT_TPREL16_HA 90
2251#define R_PPC64_GOT_DTPREL16_DS 91
2252#define R_PPC64_GOT_DTPREL16_LO_DS 92
2253#define R_PPC64_GOT_DTPREL16_HI 93
2254#define R_PPC64_GOT_DTPREL16_HA 94
2255#define R_PPC64_TPREL16_DS 95
2256#define R_PPC64_TPREL16_LO_DS 96
2257#define R_PPC64_TPREL16_HIGHER 97
2258#define R_PPC64_TPREL16_HIGHERA 98
2259#define R_PPC64_TPREL16_HIGHEST 99
2260#define R_PPC64_TPREL16_HIGHESTA 100
2261#define R_PPC64_DTPREL16_DS 101
2262#define R_PPC64_DTPREL16_LO_DS 102
2263#define R_PPC64_DTPREL16_HIGHER 103
2264#define R_PPC64_DTPREL16_HIGHERA 104
2265#define R_PPC64_DTPREL16_HIGHEST 105
2266#define R_PPC64_DTPREL16_HIGHESTA 106
2267#define R_PPC64_TLSGD 107
2268#define R_PPC64_TLSLD 108
2269#define R_PPC64_TOCSAVE 109
2270#define R_PPC64_ADDR16_HIGH 110
2271#define R_PPC64_ADDR16_HIGHA 111
2272#define R_PPC64_TPREL16_HIGH 112
2273#define R_PPC64_TPREL16_HIGHA 113
2274#define R_PPC64_DTPREL16_HIGH 114
2275#define R_PPC64_DTPREL16_HIGHA 115
2276
2277
2278#define R_PPC64_JMP_IREL 247
2279#define R_PPC64_IRELATIVE 248
2280#define R_PPC64_REL16 249
2281#define R_PPC64_REL16_LO 250
2282#define R_PPC64_REL16_HI 251
2283#define R_PPC64_REL16_HA 252
2284
2285#define EF_PPC64_ABI 3
2286
2287#define DT_PPC64_GLINK (DT_LOPROC + 0)
2288#define DT_PPC64_OPD (DT_LOPROC + 1)
2289#define DT_PPC64_OPDSZ (DT_LOPROC + 2)
2290#define DT_PPC64_OPT (DT_LOPROC + 3)
2291#define DT_PPC64_NUM 4
2292
2293#define PPC64_OPT_TLS 1
2294#define PPC64_OPT_MULTI_TOC 2
2295#define PPC64_OPT_LOCALENTRY 4
2296
2297#define STO_PPC64_LOCAL_BIT 5
2298#define STO_PPC64_LOCAL_MASK 0xe0
2299#define PPC64_LOCAL_ENTRY_OFFSET(x) (1 << (((x)&0xe0)>>5) & 0xfc)
2300
2301
2302#define EF_ARM_RELEXEC 0x01
2303#define EF_ARM_HASENTRY 0x02
2304#define EF_ARM_INTERWORK 0x04
2305#define EF_ARM_APCS_26 0x08
2306#define EF_ARM_APCS_FLOAT 0x10
2307#define EF_ARM_PIC 0x20
2308#define EF_ARM_ALIGN8 0x40
2309#define EF_ARM_NEW_ABI 0x80
2310#define EF_ARM_OLD_ABI 0x100
2311#define EF_ARM_SOFT_FLOAT 0x200
2312#define EF_ARM_VFP_FLOAT 0x400
2313#define EF_ARM_MAVERICK_FLOAT 0x800
2314
2315#define EF_ARM_ABI_FLOAT_SOFT 0x200
2316#define EF_ARM_ABI_FLOAT_HARD 0x400
2317
2318
2319#define EF_ARM_SYMSARESORTED 0x04
2320#define EF_ARM_DYNSYMSUSESEGIDX 0x08
2321#define EF_ARM_MAPSYMSFIRST 0x10
2322#define EF_ARM_EABIMASK 0XFF000000
2323
2324
2325#define EF_ARM_BE8 0x00800000
2326#define EF_ARM_LE8 0x00400000
2327
2328#define EF_ARM_EABI_VERSION(flags) ((flags) & EF_ARM_EABIMASK)
2329#define EF_ARM_EABI_UNKNOWN 0x00000000
2330#define EF_ARM_EABI_VER1 0x01000000
2331#define EF_ARM_EABI_VER2 0x02000000
2332#define EF_ARM_EABI_VER3 0x03000000
2333#define EF_ARM_EABI_VER4 0x04000000
2334#define EF_ARM_EABI_VER5 0x05000000
2335
2336
2337#define STT_ARM_TFUNC STT_LOPROC
2338#define STT_ARM_16BIT STT_HIPROC
2339
2340
2341#define SHF_ARM_ENTRYSECT 0x10000000
2342#define SHF_ARM_COMDEF 0x80000000
2343
2344
2345
2346#define PF_ARM_SB 0x10000000
2347
2348#define PF_ARM_PI 0x20000000
2349#define PF_ARM_ABS 0x40000000
2350
2351
2352#define PT_ARM_EXIDX (PT_LOPROC + 1)
2353
2354
2355#define SHT_ARM_EXIDX (SHT_LOPROC + 1)
2356#define SHT_ARM_PREEMPTMAP (SHT_LOPROC + 2)
2357#define SHT_ARM_ATTRIBUTES (SHT_LOPROC + 3)
2358
2359#define R_AARCH64_NONE 0
2360#define R_AARCH64_P32_ABS32 1
2361#define R_AARCH64_P32_COPY 180
2362#define R_AARCH64_P32_GLOB_DAT 181
2363#define R_AARCH64_P32_JUMP_SLOT 182
2364#define R_AARCH64_P32_RELATIVE 183
2365#define R_AARCH64_P32_TLS_DTPMOD 184
2366#define R_AARCH64_P32_TLS_DTPREL 185
2367#define R_AARCH64_P32_TLS_TPREL 186
2368#define R_AARCH64_P32_TLSDESC 187
2369#define R_AARCH64_P32_IRELATIVE 188
2370#define R_AARCH64_ABS64 257
2371#define R_AARCH64_ABS32 258
2372#define R_AARCH64_ABS16 259
2373#define R_AARCH64_PREL64 260
2374#define R_AARCH64_PREL32 261
2375#define R_AARCH64_PREL16 262
2376#define R_AARCH64_MOVW_UABS_G0 263
2377#define R_AARCH64_MOVW_UABS_G0_NC 264
2378#define R_AARCH64_MOVW_UABS_G1 265
2379#define R_AARCH64_MOVW_UABS_G1_NC 266
2380#define R_AARCH64_MOVW_UABS_G2 267
2381#define R_AARCH64_MOVW_UABS_G2_NC 268
2382#define R_AARCH64_MOVW_UABS_G3 269
2383#define R_AARCH64_MOVW_SABS_G0 270
2384#define R_AARCH64_MOVW_SABS_G1 271
2385#define R_AARCH64_MOVW_SABS_G2 272
2386#define R_AARCH64_LD_PREL_LO19 273
2387#define R_AARCH64_ADR_PREL_LO21 274
2388#define R_AARCH64_ADR_PREL_PG_HI21 275
2389#define R_AARCH64_ADR_PREL_PG_HI21_NC 276
2390#define R_AARCH64_ADD_ABS_LO12_NC 277
2391#define R_AARCH64_LDST8_ABS_LO12_NC 278
2392#define R_AARCH64_TSTBR14 279
2393#define R_AARCH64_CONDBR19 280
2394#define R_AARCH64_JUMP26 282
2395#define R_AARCH64_CALL26 283
2396#define R_AARCH64_LDST16_ABS_LO12_NC 284
2397#define R_AARCH64_LDST32_ABS_LO12_NC 285
2398#define R_AARCH64_LDST64_ABS_LO12_NC 286
2399#define R_AARCH64_MOVW_PREL_G0 287
2400#define R_AARCH64_MOVW_PREL_G0_NC 288
2401#define R_AARCH64_MOVW_PREL_G1 289
2402#define R_AARCH64_MOVW_PREL_G1_NC 290
2403#define R_AARCH64_MOVW_PREL_G2 291
2404#define R_AARCH64_MOVW_PREL_G2_NC 292
2405#define R_AARCH64_MOVW_PREL_G3 293
2406#define R_AARCH64_LDST128_ABS_LO12_NC 299
2407#define R_AARCH64_MOVW_GOTOFF_G0 300
2408#define R_AARCH64_MOVW_GOTOFF_G0_NC 301
2409#define R_AARCH64_MOVW_GOTOFF_G1 302
2410#define R_AARCH64_MOVW_GOTOFF_G1_NC 303
2411#define R_AARCH64_MOVW_GOTOFF_G2 304
2412#define R_AARCH64_MOVW_GOTOFF_G2_NC 305
2413#define R_AARCH64_MOVW_GOTOFF_G3 306
2414#define R_AARCH64_GOTREL64 307
2415#define R_AARCH64_GOTREL32 308
2416#define R_AARCH64_GOT_LD_PREL19 309
2417#define R_AARCH64_LD64_GOTOFF_LO15 310
2418#define R_AARCH64_ADR_GOT_PAGE 311
2419#define R_AARCH64_LD64_GOT_LO12_NC 312
2420#define R_AARCH64_LD64_GOTPAGE_LO15 313
2421#define R_AARCH64_TLSGD_ADR_PREL21 512
2422#define R_AARCH64_TLSGD_ADR_PAGE21 513
2423#define R_AARCH64_TLSGD_ADD_LO12_NC 514
2424#define R_AARCH64_TLSGD_MOVW_G1 515
2425#define R_AARCH64_TLSGD_MOVW_G0_NC 516
2426#define R_AARCH64_TLSLD_ADR_PREL21 517
2427#define R_AARCH64_TLSLD_ADR_PAGE21 518
2428#define R_AARCH64_TLSLD_ADD_LO12_NC 519
2429#define R_AARCH64_TLSLD_MOVW_G1 520
2430#define R_AARCH64_TLSLD_MOVW_G0_NC 521
2431#define R_AARCH64_TLSLD_LD_PREL19 522
2432#define R_AARCH64_TLSLD_MOVW_DTPREL_G2 523
2433#define R_AARCH64_TLSLD_MOVW_DTPREL_G1 524
2434#define R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC 525
2435#define R_AARCH64_TLSLD_MOVW_DTPREL_G0 526
2436#define R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC 527
2437#define R_AARCH64_TLSLD_ADD_DTPREL_HI12 528
2438#define R_AARCH64_TLSLD_ADD_DTPREL_LO12 529
2439#define R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC 530
2440#define R_AARCH64_TLSLD_LDST8_DTPREL_LO12 531
2441#define R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC 532
2442#define R_AARCH64_TLSLD_LDST16_DTPREL_LO12 533
2443#define R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC 534
2444#define R_AARCH64_TLSLD_LDST32_DTPREL_LO12 535
2445#define R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC 536
2446#define R_AARCH64_TLSLD_LDST64_DTPREL_LO12 537
2447#define R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC 538
2448#define R_AARCH64_TLSIE_MOVW_GOTTPREL_G1 539
2449#define R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC 540
2450#define R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 541
2451#define R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC 542
2452#define R_AARCH64_TLSIE_LD_GOTTPREL_PREL19 543
2453#define R_AARCH64_TLSLE_MOVW_TPREL_G2 544
2454#define R_AARCH64_TLSLE_MOVW_TPREL_G1 545
2455#define R_AARCH64_TLSLE_MOVW_TPREL_G1_NC 546
2456#define R_AARCH64_TLSLE_MOVW_TPREL_G0 547
2457#define R_AARCH64_TLSLE_MOVW_TPREL_G0_NC 548
2458#define R_AARCH64_TLSLE_ADD_TPREL_HI12 549
2459#define R_AARCH64_TLSLE_ADD_TPREL_LO12 550
2460#define R_AARCH64_TLSLE_ADD_TPREL_LO12_NC 551
2461#define R_AARCH64_TLSLE_LDST8_TPREL_LO12 552
2462#define R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC 553
2463#define R_AARCH64_TLSLE_LDST16_TPREL_LO12 554
2464#define R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC 555
2465#define R_AARCH64_TLSLE_LDST32_TPREL_LO12 556
2466#define R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC 557
2467#define R_AARCH64_TLSLE_LDST64_TPREL_LO12 558
2468#define R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC 559
2469#define R_AARCH64_TLSDESC_LD_PREL19 560
2470#define R_AARCH64_TLSDESC_ADR_PREL21 561
2471#define R_AARCH64_TLSDESC_ADR_PAGE21 562
2472#define R_AARCH64_TLSDESC_LD64_LO12 563
2473#define R_AARCH64_TLSDESC_ADD_LO12 564
2474#define R_AARCH64_TLSDESC_OFF_G1 565
2475#define R_AARCH64_TLSDESC_OFF_G0_NC 566
2476#define R_AARCH64_TLSDESC_LDR 567
2477#define R_AARCH64_TLSDESC_ADD 568
2478#define R_AARCH64_TLSDESC_CALL 569
2479#define R_AARCH64_TLSLE_LDST128_TPREL_LO12 570
2480#define R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC 571
2481#define R_AARCH64_TLSLD_LDST128_DTPREL_LO12 572
2482#define R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC 573
2483#define R_AARCH64_COPY 1024
2484#define R_AARCH64_GLOB_DAT 1025
2485#define R_AARCH64_JUMP_SLOT 1026
2486#define R_AARCH64_RELATIVE 1027
2487#define R_AARCH64_TLS_DTPMOD 1028
2488#define R_AARCH64_TLS_DTPMOD64 1028
2489#define R_AARCH64_TLS_DTPREL 1029
2490#define R_AARCH64_TLS_DTPREL64 1029
2491#define R_AARCH64_TLS_TPREL 1030
2492#define R_AARCH64_TLS_TPREL64 1030
2493#define R_AARCH64_TLSDESC 1031
2494
2495
2496#define R_ARM_NONE 0
2497#define R_ARM_PC24 1
2498#define R_ARM_ABS32 2
2499#define R_ARM_REL32 3
2500#define R_ARM_PC13 4
2501#define R_ARM_ABS16 5
2502#define R_ARM_ABS12 6
2503#define R_ARM_THM_ABS5 7
2504#define R_ARM_ABS8 8
2505#define R_ARM_SBREL32 9
2506#define R_ARM_THM_PC22 10
2507#define R_ARM_THM_PC8 11
2508#define R_ARM_AMP_VCALL9 12
2509#define R_ARM_TLS_DESC 13
2510#define R_ARM_THM_SWI8 14
2511#define R_ARM_XPC25 15
2512#define R_ARM_THM_XPC22 16
2513#define R_ARM_TLS_DTPMOD32 17
2514#define R_ARM_TLS_DTPOFF32 18
2515#define R_ARM_TLS_TPOFF32 19
2516#define R_ARM_COPY 20
2517#define R_ARM_GLOB_DAT 21
2518#define R_ARM_JUMP_SLOT 22
2519#define R_ARM_RELATIVE 23
2520#define R_ARM_GOTOFF 24
2521#define R_ARM_GOTPC 25
2522#define R_ARM_GOT32 26
2523#define R_ARM_PLT32 27
2524#define R_ARM_CALL 28
2525#define R_ARM_JUMP24 29
2526#define R_ARM_THM_JUMP24 30
2527#define R_ARM_BASE_ABS 31
2528#define R_ARM_ALU_PCREL_7_0 32
2529#define R_ARM_ALU_PCREL_15_8 33
2530#define R_ARM_ALU_PCREL_23_15 34
2531#define R_ARM_LDR_SBREL_11_0 35
2532#define R_ARM_ALU_SBREL_19_12 36
2533#define R_ARM_ALU_SBREL_27_20 37
2534#define R_ARM_TARGET1 38
2535#define R_ARM_SBREL31 39
2536#define R_ARM_V4BX 40
2537#define R_ARM_TARGET2 41
2538#define R_ARM_PREL31 42
2539#define R_ARM_MOVW_ABS_NC 43
2540#define R_ARM_MOVT_ABS 44
2541#define R_ARM_MOVW_PREL_NC 45
2542#define R_ARM_MOVT_PREL 46
2543#define R_ARM_THM_MOVW_ABS_NC 47
2544#define R_ARM_THM_MOVT_ABS 48
2545#define R_ARM_THM_MOVW_PREL_NC 49
2546#define R_ARM_THM_MOVT_PREL 50
2547#define R_ARM_THM_JUMP19 51
2548#define R_ARM_THM_JUMP6 52
2549#define R_ARM_THM_ALU_PREL_11_0 53
2550#define R_ARM_THM_PC12 54
2551#define R_ARM_ABS32_NOI 55
2552#define R_ARM_REL32_NOI 56
2553#define R_ARM_ALU_PC_G0_NC 57
2554#define R_ARM_ALU_PC_G0 58
2555#define R_ARM_ALU_PC_G1_NC 59
2556#define R_ARM_ALU_PC_G1 60
2557#define R_ARM_ALU_PC_G2 61
2558#define R_ARM_LDR_PC_G1 62
2559#define R_ARM_LDR_PC_G2 63
2560#define R_ARM_LDRS_PC_G0 64
2561#define R_ARM_LDRS_PC_G1 65
2562#define R_ARM_LDRS_PC_G2 66
2563#define R_ARM_LDC_PC_G0 67
2564#define R_ARM_LDC_PC_G1 68
2565#define R_ARM_LDC_PC_G2 69
2566#define R_ARM_ALU_SB_G0_NC 70
2567#define R_ARM_ALU_SB_G0 71
2568#define R_ARM_ALU_SB_G1_NC 72
2569#define R_ARM_ALU_SB_G1 73
2570#define R_ARM_ALU_SB_G2 74
2571#define R_ARM_LDR_SB_G0 75
2572#define R_ARM_LDR_SB_G1 76
2573#define R_ARM_LDR_SB_G2 77
2574#define R_ARM_LDRS_SB_G0 78
2575#define R_ARM_LDRS_SB_G1 79
2576#define R_ARM_LDRS_SB_G2 80
2577#define R_ARM_LDC_SB_G0 81
2578#define R_ARM_LDC_SB_G1 82
2579#define R_ARM_LDC_SB_G2 83
2580#define R_ARM_MOVW_BREL_NC 84
2581#define R_ARM_MOVT_BREL 85
2582#define R_ARM_MOVW_BREL 86
2583#define R_ARM_THM_MOVW_BREL_NC 87
2584#define R_ARM_THM_MOVT_BREL 88
2585#define R_ARM_THM_MOVW_BREL 89
2586#define R_ARM_TLS_GOTDESC 90
2587#define R_ARM_TLS_CALL 91
2588#define R_ARM_TLS_DESCSEQ 92
2589#define R_ARM_THM_TLS_CALL 93
2590#define R_ARM_PLT32_ABS 94
2591#define R_ARM_GOT_ABS 95
2592#define R_ARM_GOT_PREL 96
2593#define R_ARM_GOT_BREL12 97
2594#define R_ARM_GOTOFF12 98
2595#define R_ARM_GOTRELAX 99
2596#define R_ARM_GNU_VTENTRY 100
2597#define R_ARM_GNU_VTINHERIT 101
2598#define R_ARM_THM_PC11 102
2599#define R_ARM_THM_PC9 103
2600#define R_ARM_TLS_GD32 104
2601
2602#define R_ARM_TLS_LDM32 105
2603
2604#define R_ARM_TLS_LDO32 106
2605
2606#define R_ARM_TLS_IE32 107
2607
2608#define R_ARM_TLS_LE32 108
2609#define R_ARM_TLS_LDO12 109
2610#define R_ARM_TLS_LE12 110
2611#define R_ARM_TLS_IE12GP 111
2612#define R_ARM_ME_TOO 128
2613#define R_ARM_THM_TLS_DESCSEQ 129
2614#define R_ARM_THM_TLS_DESCSEQ16 129
2615#define R_ARM_THM_TLS_DESCSEQ32 130
2616#define R_ARM_THM_GOT_BREL12 131
2617#define R_ARM_IRELATIVE 160
2618#define R_ARM_RXPC25 249
2619#define R_ARM_RSBREL32 250
2620#define R_ARM_THM_RPC22 251
2621#define R_ARM_RREL32 252
2622#define R_ARM_RABS22 253
2623#define R_ARM_RPC24 254
2624#define R_ARM_RBASE 255
2625
2626#define R_ARM_NUM 256
2627
2628
2629#define R_CKCORE_NONE 0
2630#define R_CKCORE_ADDR32 1
2631#define R_CKCORE_PCRELIMM8BY4 2
2632#define R_CKCORE_PCRELIMM11BY2 3
2633#define R_CKCORE_PCREL32 5
2634#define R_CKCORE_PCRELJSR_IMM11BY2 6
2635#define R_CKCORE_RELATIVE 9
2636#define R_CKCORE_COPY 10
2637#define R_CKCORE_GLOB_DAT 11
2638#define R_CKCORE_JUMP_SLOT 12
2639#define R_CKCORE_GOTOFF 13
2640#define R_CKCORE_GOTPC 14
2641#define R_CKCORE_GOT32 15
2642#define R_CKCORE_PLT32 16
2643#define R_CKCORE_ADDRGOT 17
2644#define R_CKCORE_ADDRPLT 18
2645#define R_CKCORE_PCREL_IMM26BY2 19
2646#define R_CKCORE_PCREL_IMM16BY2 20
2647#define R_CKCORE_PCREL_IMM16BY4 21
2648#define R_CKCORE_PCREL_IMM10BY2 22
2649#define R_CKCORE_PCREL_IMM10BY4 23
2650#define R_CKCORE_ADDR_HI16 24
2651#define R_CKCORE_ADDR_LO16 25
2652#define R_CKCORE_GOTPC_HI16 26
2653#define R_CKCORE_GOTPC_LO16 27
2654#define R_CKCORE_GOTOFF_HI16 28
2655#define R_CKCORE_GOTOFF_LO16 29
2656#define R_CKCORE_GOT12 30
2657#define R_CKCORE_GOT_HI16 31
2658#define R_CKCORE_GOT_LO16 32
2659#define R_CKCORE_PLT12 33
2660#define R_CKCORE_PLT_HI16 34
2661#define R_CKCORE_PLT_LO16 35
2662#define R_CKCORE_ADDRGOT_HI16 36
2663#define R_CKCORE_ADDRGOT_LO16 37
2664#define R_CKCORE_ADDRPLT_HI16 38
2665#define R_CKCORE_ADDRPLT_LO16 39
2666#define R_CKCORE_PCREL_JSR_IMM26BY2 40
2667#define R_CKCORE_TOFFSET_LO16 41
2668#define R_CKCORE_DOFFSET_LO16 42
2669#define R_CKCORE_PCREL_IMM18BY2 43
2670#define R_CKCORE_DOFFSET_IMM18 44
2671#define R_CKCORE_DOFFSET_IMM18BY2 45
2672#define R_CKCORE_DOFFSET_IMM18BY4 46
2673#define R_CKCORE_GOT_IMM18BY4 48
2674#define R_CKCORE_PLT_IMM18BY4 49
2675#define R_CKCORE_PCREL_IMM7BY4 50
2676#define R_CKCORE_TLS_LE32 51
2677#define R_CKCORE_TLS_IE32 52
2678#define R_CKCORE_TLS_GD32 53
2679#define R_CKCORE_TLS_LDM32 54
2680#define R_CKCORE_TLS_LDO32 55
2681#define R_CKCORE_TLS_DTPMOD32 56
2682#define R_CKCORE_TLS_DTPOFF32 57
2683#define R_CKCORE_TLS_TPOFF32 58
2684
2685
2686#define EF_IA_64_MASKOS 0x0000000f
2687#define EF_IA_64_ABI64 0x00000010
2688#define EF_IA_64_ARCH 0xff000000
2689
2690
2691#define PT_IA_64_ARCHEXT (PT_LOPROC + 0)
2692#define PT_IA_64_UNWIND (PT_LOPROC + 1)
2693#define PT_IA_64_HP_OPT_ANOT (PT_LOOS + 0x12)
2694#define PT_IA_64_HP_HSL_ANOT (PT_LOOS + 0x13)
2695#define PT_IA_64_HP_STACK (PT_LOOS + 0x14)
2696
2697
2698#define PF_IA_64_NORECOV 0x80000000
2699
2700
2701#define SHT_IA_64_EXT (SHT_LOPROC + 0)
2702#define SHT_IA_64_UNWIND (SHT_LOPROC + 1)
2703
2704
2705#define SHF_IA_64_SHORT 0x10000000
2706#define SHF_IA_64_NORECOV 0x20000000
2707
2708
2709#define DT_IA_64_PLT_RESERVE (DT_LOPROC + 0)
2710#define DT_IA_64_NUM 1
2711
2712
2713#define R_IA64_NONE 0x00
2714#define R_IA64_IMM14 0x21
2715#define R_IA64_IMM22 0x22
2716#define R_IA64_IMM64 0x23
2717#define R_IA64_DIR32MSB 0x24
2718#define R_IA64_DIR32LSB 0x25
2719#define R_IA64_DIR64MSB 0x26
2720#define R_IA64_DIR64LSB 0x27
2721#define R_IA64_GPREL22 0x2a
2722#define R_IA64_GPREL64I 0x2b
2723#define R_IA64_GPREL32MSB 0x2c
2724#define R_IA64_GPREL32LSB 0x2d
2725#define R_IA64_GPREL64MSB 0x2e
2726#define R_IA64_GPREL64LSB 0x2f
2727#define R_IA64_LTOFF22 0x32
2728#define R_IA64_LTOFF64I 0x33
2729#define R_IA64_PLTOFF22 0x3a
2730#define R_IA64_PLTOFF64I 0x3b
2731#define R_IA64_PLTOFF64MSB 0x3e
2732#define R_IA64_PLTOFF64LSB 0x3f
2733#define R_IA64_FPTR64I 0x43
2734#define R_IA64_FPTR32MSB 0x44
2735#define R_IA64_FPTR32LSB 0x45
2736#define R_IA64_FPTR64MSB 0x46
2737#define R_IA64_FPTR64LSB 0x47
2738#define R_IA64_PCREL60B 0x48
2739#define R_IA64_PCREL21B 0x49
2740#define R_IA64_PCREL21M 0x4a
2741#define R_IA64_PCREL21F 0x4b
2742#define R_IA64_PCREL32MSB 0x4c
2743#define R_IA64_PCREL32LSB 0x4d
2744#define R_IA64_PCREL64MSB 0x4e
2745#define R_IA64_PCREL64LSB 0x4f
2746#define R_IA64_LTOFF_FPTR22 0x52
2747#define R_IA64_LTOFF_FPTR64I 0x53
2748#define R_IA64_LTOFF_FPTR32MSB 0x54
2749#define R_IA64_LTOFF_FPTR32LSB 0x55
2750#define R_IA64_LTOFF_FPTR64MSB 0x56
2751#define R_IA64_LTOFF_FPTR64LSB 0x57
2752#define R_IA64_SEGREL32MSB 0x5c
2753#define R_IA64_SEGREL32LSB 0x5d
2754#define R_IA64_SEGREL64MSB 0x5e
2755#define R_IA64_SEGREL64LSB 0x5f
2756#define R_IA64_SECREL32MSB 0x64
2757#define R_IA64_SECREL32LSB 0x65
2758#define R_IA64_SECREL64MSB 0x66
2759#define R_IA64_SECREL64LSB 0x67
2760#define R_IA64_REL32MSB 0x6c
2761#define R_IA64_REL32LSB 0x6d
2762#define R_IA64_REL64MSB 0x6e
2763#define R_IA64_REL64LSB 0x6f
2764#define R_IA64_LTV32MSB 0x74
2765#define R_IA64_LTV32LSB 0x75
2766#define R_IA64_LTV64MSB 0x76
2767#define R_IA64_LTV64LSB 0x77
2768#define R_IA64_PCREL21BI 0x79
2769#define R_IA64_PCREL22 0x7a
2770#define R_IA64_PCREL64I 0x7b
2771#define R_IA64_IPLTMSB 0x80
2772#define R_IA64_IPLTLSB 0x81
2773#define R_IA64_COPY 0x84
2774#define R_IA64_SUB 0x85
2775#define R_IA64_LTOFF22X 0x86
2776#define R_IA64_LDXMOV 0x87
2777#define R_IA64_TPREL14 0x91
2778#define R_IA64_TPREL22 0x92
2779#define R_IA64_TPREL64I 0x93
2780#define R_IA64_TPREL64MSB 0x96
2781#define R_IA64_TPREL64LSB 0x97
2782#define R_IA64_LTOFF_TPREL22 0x9a
2783#define R_IA64_DTPMOD64MSB 0xa6
2784#define R_IA64_DTPMOD64LSB 0xa7
2785#define R_IA64_LTOFF_DTPMOD22 0xaa
2786#define R_IA64_DTPREL14 0xb1
2787#define R_IA64_DTPREL22 0xb2
2788#define R_IA64_DTPREL64I 0xb3
2789#define R_IA64_DTPREL32MSB 0xb4
2790#define R_IA64_DTPREL32LSB 0xb5
2791#define R_IA64_DTPREL64MSB 0xb6
2792#define R_IA64_DTPREL64LSB 0xb7
2793#define R_IA64_LTOFF_DTPREL22 0xba
2794
2795
2796#define EF_SH_MACH_MASK 0x1f
2797#define EF_SH_UNKNOWN 0x0
2798#define EF_SH1 0x1
2799#define EF_SH2 0x2
2800#define EF_SH3 0x3
2801#define EF_SH_DSP 0x4
2802#define EF_SH3_DSP 0x5
2803#define EF_SH4AL_DSP 0x6
2804#define EF_SH3E 0x8
2805#define EF_SH4 0x9
2806#define EF_SH2E 0xb
2807#define EF_SH4A 0xc
2808#define EF_SH2A 0xd
2809#define EF_SH4_NOFPU 0x10
2810#define EF_SH4A_NOFPU 0x11
2811#define EF_SH4_NOMMU_NOFPU 0x12
2812#define EF_SH2A_NOFPU 0x13
2813#define EF_SH3_NOMMU 0x14
2814#define EF_SH2A_SH4_NOFPU 0x15
2815#define EF_SH2A_SH3_NOFPU 0x16
2816#define EF_SH2A_SH4 0x17
2817#define EF_SH2A_SH3E 0x18
2818
2819#define R_SH_NONE 0
2820#define R_SH_DIR32 1
2821#define R_SH_REL32 2
2822#define R_SH_DIR8WPN 3
2823#define R_SH_IND12W 4
2824#define R_SH_DIR8WPL 5
2825#define R_SH_DIR8WPZ 6
2826#define R_SH_DIR8BP 7
2827#define R_SH_DIR8W 8
2828#define R_SH_DIR8L 9
2829#define R_SH_SWITCH16 25
2830#define R_SH_SWITCH32 26
2831#define R_SH_USES 27
2832#define R_SH_COUNT 28
2833#define R_SH_ALIGN 29
2834#define R_SH_CODE 30
2835#define R_SH_DATA 31
2836#define R_SH_LABEL 32
2837#define R_SH_SWITCH8 33
2838#define R_SH_GNU_VTINHERIT 34
2839#define R_SH_GNU_VTENTRY 35
2840#define R_SH_TLS_GD_32 144
2841#define R_SH_TLS_LD_32 145
2842#define R_SH_TLS_LDO_32 146
2843#define R_SH_TLS_IE_32 147
2844#define R_SH_TLS_LE_32 148
2845#define R_SH_TLS_DTPMOD32 149
2846#define R_SH_TLS_DTPOFF32 150
2847#define R_SH_TLS_TPOFF32 151
2848#define R_SH_GOT32 160
2849#define R_SH_PLT32 161
2850#define R_SH_COPY 162
2851#define R_SH_GLOB_DAT 163
2852#define R_SH_JMP_SLOT 164
2853#define R_SH_RELATIVE 165
2854#define R_SH_GOTOFF 166
2855#define R_SH_GOTPC 167
2856#define R_SH_GOT20 201
2857#define R_SH_GOTOFF20 202
2858#define R_SH_GOTFUNCDESC 203
2859#define R_SH_GOTFUNCDEST20 204
2860#define R_SH_GOTOFFFUNCDESC 205
2861#define R_SH_GOTOFFFUNCDEST20 206
2862#define R_SH_FUNCDESC 207
2863#define R_SH_FUNCDESC_VALUE 208
2864
2865#define R_SH_NUM 256
2866
2867
2868
2869#define R_390_NONE 0
2870#define R_390_8 1
2871#define R_390_12 2
2872#define R_390_16 3
2873#define R_390_32 4
2874#define R_390_PC32 5
2875#define R_390_GOT12 6
2876#define R_390_GOT32 7
2877#define R_390_PLT32 8
2878#define R_390_COPY 9
2879#define R_390_GLOB_DAT 10
2880#define R_390_JMP_SLOT 11
2881#define R_390_RELATIVE 12
2882#define R_390_GOTOFF32 13
2883#define R_390_GOTPC 14
2884#define R_390_GOT16 15
2885#define R_390_PC16 16
2886#define R_390_PC16DBL 17
2887#define R_390_PLT16DBL 18
2888#define R_390_PC32DBL 19
2889#define R_390_PLT32DBL 20
2890#define R_390_GOTPCDBL 21
2891#define R_390_64 22
2892#define R_390_PC64 23
2893#define R_390_GOT64 24
2894#define R_390_PLT64 25
2895#define R_390_GOTENT 26
2896#define R_390_GOTOFF16 27
2897#define R_390_GOTOFF64 28
2898#define R_390_GOTPLT12 29
2899#define R_390_GOTPLT16 30
2900#define R_390_GOTPLT32 31
2901#define R_390_GOTPLT64 32
2902#define R_390_GOTPLTENT 33
2903#define R_390_PLTOFF16 34
2904#define R_390_PLTOFF32 35
2905#define R_390_PLTOFF64 36
2906#define R_390_TLS_LOAD 37
2907#define R_390_TLS_GDCALL 38
2908
2909#define R_390_TLS_LDCALL 39
2910
2911#define R_390_TLS_GD32 40
2912
2913#define R_390_TLS_GD64 41
2914
2915#define R_390_TLS_GOTIE12 42
2916
2917#define R_390_TLS_GOTIE32 43
2918
2919#define R_390_TLS_GOTIE64 44
2920
2921#define R_390_TLS_LDM32 45
2922
2923#define R_390_TLS_LDM64 46
2924
2925#define R_390_TLS_IE32 47
2926
2927#define R_390_TLS_IE64 48
2928
2929#define R_390_TLS_IEENT 49
2930
2931#define R_390_TLS_LE32 50
2932
2933#define R_390_TLS_LE64 51
2934
2935#define R_390_TLS_LDO32 52
2936
2937#define R_390_TLS_LDO64 53
2938
2939#define R_390_TLS_DTPMOD 54
2940#define R_390_TLS_DTPOFF 55
2941#define R_390_TLS_TPOFF 56
2942
2943#define R_390_20 57
2944#define R_390_GOT20 58
2945#define R_390_GOTPLT20 59
2946#define R_390_TLS_GOTIE20 60
2947
2948
2949#define R_390_NUM 61
2950
2951
2952
2953#define R_CRIS_NONE 0
2954#define R_CRIS_8 1
2955#define R_CRIS_16 2
2956#define R_CRIS_32 3
2957#define R_CRIS_8_PCREL 4
2958#define R_CRIS_16_PCREL 5
2959#define R_CRIS_32_PCREL 6
2960#define R_CRIS_GNU_VTINHERIT 7
2961#define R_CRIS_GNU_VTENTRY 8
2962#define R_CRIS_COPY 9
2963#define R_CRIS_GLOB_DAT 10
2964#define R_CRIS_JUMP_SLOT 11
2965#define R_CRIS_RELATIVE 12
2966#define R_CRIS_16_GOT 13
2967#define R_CRIS_32_GOT 14
2968#define R_CRIS_16_GOTPLT 15
2969#define R_CRIS_32_GOTPLT 16
2970#define R_CRIS_32_GOTREL 17
2971#define R_CRIS_32_PLT_GOTREL 18
2972#define R_CRIS_32_PLT_PCREL 19
2973
2974#define R_CRIS_NUM 20
2975
2976
2977
2978#define R_X86_64_NONE 0
2979#define R_X86_64_64 1
2980#define R_X86_64_PC32 2
2981#define R_X86_64_GOT32 3
2982#define R_X86_64_PLT32 4
2983#define R_X86_64_COPY 5
2984#define R_X86_64_GLOB_DAT 6
2985#define R_X86_64_JUMP_SLOT 7
2986#define R_X86_64_RELATIVE 8
2987#define R_X86_64_GOTPCREL 9
2988
2989#define R_X86_64_32 10
2990#define R_X86_64_32S 11
2991#define R_X86_64_16 12
2992#define R_X86_64_PC16 13
2993#define R_X86_64_8 14
2994#define R_X86_64_PC8 15
2995#define R_X86_64_DTPMOD64 16
2996#define R_X86_64_DTPOFF64 17
2997#define R_X86_64_TPOFF64 18
2998#define R_X86_64_TLSGD 19
2999
3000#define R_X86_64_TLSLD 20
3001
3002#define R_X86_64_DTPOFF32 21
3003#define R_X86_64_GOTTPOFF 22
3004
3005#define R_X86_64_TPOFF32 23
3006#define R_X86_64_PC64 24
3007#define R_X86_64_GOTOFF64 25
3008#define R_X86_64_GOTPC32 26
3009#define R_X86_64_GOT64 27
3010#define R_X86_64_GOTPCREL64 28
3011#define R_X86_64_GOTPC64 29
3012#define R_X86_64_GOTPLT64 30
3013#define R_X86_64_PLTOFF64 31
3014#define R_X86_64_SIZE32 32
3015#define R_X86_64_SIZE64 33
3016
3017#define R_X86_64_GOTPC32_TLSDESC 34
3018#define R_X86_64_TLSDESC_CALL 35
3019
3020#define R_X86_64_TLSDESC 36
3021#define R_X86_64_IRELATIVE 37
3022#define R_X86_64_RELATIVE64 38
3023#define R_X86_64_GOTPCRELX 41
3024#define R_X86_64_REX_GOTPCRELX 42
3025#define R_X86_64_NUM 43
3026
3027
3028
3029#define R_MN10300_NONE 0
3030#define R_MN10300_32 1
3031#define R_MN10300_16 2
3032#define R_MN10300_8 3
3033#define R_MN10300_PCREL32 4
3034#define R_MN10300_PCREL16 5
3035#define R_MN10300_PCREL8 6
3036#define R_MN10300_GNU_VTINHERIT 7
3037#define R_MN10300_GNU_VTENTRY 8
3038#define R_MN10300_24 9
3039#define R_MN10300_GOTPC32 10
3040#define R_MN10300_GOTPC16 11
3041#define R_MN10300_GOTOFF32 12
3042#define R_MN10300_GOTOFF24 13
3043#define R_MN10300_GOTOFF16 14
3044#define R_MN10300_PLT32 15
3045#define R_MN10300_PLT16 16
3046#define R_MN10300_GOT32 17
3047#define R_MN10300_GOT24 18
3048#define R_MN10300_GOT16 19
3049#define R_MN10300_COPY 20
3050#define R_MN10300_GLOB_DAT 21
3051#define R_MN10300_JMP_SLOT 22
3052#define R_MN10300_RELATIVE 23
3053
3054#define R_MN10300_NUM 24
3055
3056
3057
3058#define R_M32R_NONE 0
3059#define R_M32R_16 1
3060#define R_M32R_32 2
3061#define R_M32R_24 3
3062#define R_M32R_10_PCREL 4
3063#define R_M32R_18_PCREL 5
3064#define R_M32R_26_PCREL 6
3065#define R_M32R_HI16_ULO 7
3066#define R_M32R_HI16_SLO 8
3067#define R_M32R_LO16 9
3068#define R_M32R_SDA16 10
3069#define R_M32R_GNU_VTINHERIT 11
3070#define R_M32R_GNU_VTENTRY 12
3071
3072#define R_M32R_16_RELA 33
3073#define R_M32R_32_RELA 34
3074#define R_M32R_24_RELA 35
3075#define R_M32R_10_PCREL_RELA 36
3076#define R_M32R_18_PCREL_RELA 37
3077#define R_M32R_26_PCREL_RELA 38
3078#define R_M32R_HI16_ULO_RELA 39
3079#define R_M32R_HI16_SLO_RELA 40
3080#define R_M32R_LO16_RELA 41
3081#define R_M32R_SDA16_RELA 42
3082#define R_M32R_RELA_GNU_VTINHERIT 43
3083#define R_M32R_RELA_GNU_VTENTRY 44
3084#define R_M32R_REL32 45
3085
3086#define R_M32R_GOT24 48
3087#define R_M32R_26_PLTREL 49
3088#define R_M32R_COPY 50
3089#define R_M32R_GLOB_DAT 51
3090#define R_M32R_JMP_SLOT 52
3091#define R_M32R_RELATIVE 53
3092#define R_M32R_GOTOFF 54
3093#define R_M32R_GOTPC24 55
3094#define R_M32R_GOT16_HI_ULO 56
3095
3096#define R_M32R_GOT16_HI_SLO 57
3097
3098#define R_M32R_GOT16_LO 58
3099#define R_M32R_GOTPC_HI_ULO 59
3100
3101#define R_M32R_GOTPC_HI_SLO 60
3102
3103#define R_M32R_GOTPC_LO 61
3104
3105#define R_M32R_GOTOFF_HI_ULO 62
3106
3107#define R_M32R_GOTOFF_HI_SLO 63
3108
3109#define R_M32R_GOTOFF_LO 64
3110#define R_M32R_NUM 256
3111
3112#define R_MICROBLAZE_NONE 0
3113#define R_MICROBLAZE_32 1
3114#define R_MICROBLAZE_32_PCREL 2
3115#define R_MICROBLAZE_64_PCREL 3
3116#define R_MICROBLAZE_32_PCREL_LO 4
3117#define R_MICROBLAZE_64 5
3118#define R_MICROBLAZE_32_LO 6
3119#define R_MICROBLAZE_SRO32 7
3120#define R_MICROBLAZE_SRW32 8
3121#define R_MICROBLAZE_64_NONE 9
3122#define R_MICROBLAZE_32_SYM_OP_SYM 10
3123#define R_MICROBLAZE_GNU_VTINHERIT 11
3124#define R_MICROBLAZE_GNU_VTENTRY 12
3125#define R_MICROBLAZE_GOTPC_64 13
3126#define R_MICROBLAZE_GOT_64 14
3127#define R_MICROBLAZE_PLT_64 15
3128#define R_MICROBLAZE_REL 16
3129#define R_MICROBLAZE_JUMP_SLOT 17
3130#define R_MICROBLAZE_GLOB_DAT 18
3131#define R_MICROBLAZE_GOTOFF_64 19
3132#define R_MICROBLAZE_GOTOFF_32 20
3133#define R_MICROBLAZE_COPY 21
3134#define R_MICROBLAZE_TLS 22
3135#define R_MICROBLAZE_TLSGD 23
3136#define R_MICROBLAZE_TLSLD 24
3137#define R_MICROBLAZE_TLSDTPMOD32 25
3138#define R_MICROBLAZE_TLSDTPREL32 26
3139#define R_MICROBLAZE_TLSDTPREL64 27
3140#define R_MICROBLAZE_TLSGOTTPREL32 28
3141#define R_MICROBLAZE_TLSTPREL32 29
3142
3143#define DT_NIOS2_GP 0x70000002
3144
3145#define R_NIOS2_NONE 0
3146#define R_NIOS2_S16 1
3147#define R_NIOS2_U16 2
3148#define R_NIOS2_PCREL16 3
3149#define R_NIOS2_CALL26 4
3150#define R_NIOS2_IMM5 5
3151#define R_NIOS2_CACHE_OPX 6
3152#define R_NIOS2_IMM6 7
3153#define R_NIOS2_IMM8 8
3154#define R_NIOS2_HI16 9
3155#define R_NIOS2_LO16 10
3156#define R_NIOS2_HIADJ16 11
3157#define R_NIOS2_BFD_RELOC_32 12
3158#define R_NIOS2_BFD_RELOC_16 13
3159#define R_NIOS2_BFD_RELOC_8 14
3160#define R_NIOS2_GPREL 15
3161#define R_NIOS2_GNU_VTINHERIT 16
3162#define R_NIOS2_GNU_VTENTRY 17
3163#define R_NIOS2_UJMP 18
3164#define R_NIOS2_CJMP 19
3165#define R_NIOS2_CALLR 20
3166#define R_NIOS2_ALIGN 21
3167#define R_NIOS2_GOT16 22
3168#define R_NIOS2_CALL16 23
3169#define R_NIOS2_GOTOFF_LO 24
3170#define R_NIOS2_GOTOFF_HA 25
3171#define R_NIOS2_PCREL_LO 26
3172#define R_NIOS2_PCREL_HA 27
3173#define R_NIOS2_TLS_GD16 28
3174#define R_NIOS2_TLS_LDM16 29
3175#define R_NIOS2_TLS_LDO16 30
3176#define R_NIOS2_TLS_IE16 31
3177#define R_NIOS2_TLS_LE16 32
3178#define R_NIOS2_TLS_DTPMOD 33
3179#define R_NIOS2_TLS_DTPREL 34
3180#define R_NIOS2_TLS_TPREL 35
3181#define R_NIOS2_COPY 36
3182#define R_NIOS2_GLOB_DAT 37
3183#define R_NIOS2_JUMP_SLOT 38
3184#define R_NIOS2_RELATIVE 39
3185#define R_NIOS2_GOTOFF 40
3186#define R_NIOS2_CALL26_NOAT 41
3187#define R_NIOS2_GOT_LO 42
3188#define R_NIOS2_GOT_HA 43
3189#define R_NIOS2_CALL_LO 44
3190#define R_NIOS2_CALL_HA 45
3191
3192#define R_OR1K_NONE 0
3193#define R_OR1K_32 1
3194#define R_OR1K_16 2
3195#define R_OR1K_8 3
3196#define R_OR1K_LO_16_IN_INSN 4
3197#define R_OR1K_HI_16_IN_INSN 5
3198#define R_OR1K_INSN_REL_26 6
3199#define R_OR1K_GNU_VTENTRY 7
3200#define R_OR1K_GNU_VTINHERIT 8
3201#define R_OR1K_32_PCREL 9
3202#define R_OR1K_16_PCREL 10
3203#define R_OR1K_8_PCREL 11
3204#define R_OR1K_GOTPC_HI16 12
3205#define R_OR1K_GOTPC_LO16 13
3206#define R_OR1K_GOT16 14
3207#define R_OR1K_PLT26 15
3208#define R_OR1K_GOTOFF_HI16 16
3209#define R_OR1K_GOTOFF_LO16 17
3210#define R_OR1K_COPY 18
3211#define R_OR1K_GLOB_DAT 19
3212#define R_OR1K_JMP_SLOT 20
3213#define R_OR1K_RELATIVE 21
3214#define R_OR1K_TLS_GD_HI16 22
3215#define R_OR1K_TLS_GD_LO16 23
3216#define R_OR1K_TLS_LDM_HI16 24
3217#define R_OR1K_TLS_LDM_LO16 25
3218#define R_OR1K_TLS_LDO_HI16 26
3219#define R_OR1K_TLS_LDO_LO16 27
3220#define R_OR1K_TLS_IE_HI16 28
3221#define R_OR1K_TLS_IE_LO16 29
3222#define R_OR1K_TLS_LE_HI16 30
3223#define R_OR1K_TLS_LE_LO16 31
3224#define R_OR1K_TLS_TPOFF 32
3225#define R_OR1K_TLS_DTPOFF 33
3226#define R_OR1K_TLS_DTPMOD 34
3227
3228#define R_BPF_NONE 0
3229#define R_BPF_MAP_FD 1
3230
3231#define R_RISCV_NONE 0
3232#define R_RISCV_32 1
3233#define R_RISCV_64 2
3234#define R_RISCV_RELATIVE 3
3235#define R_RISCV_COPY 4
3236#define R_RISCV_JUMP_SLOT 5
3237#define R_RISCV_TLS_DTPMOD32 6
3238#define R_RISCV_TLS_DTPMOD64 7
3239#define R_RISCV_TLS_DTPREL32 8
3240#define R_RISCV_TLS_DTPREL64 9
3241#define R_RISCV_TLS_TPREL32 10
3242#define R_RISCV_TLS_TPREL64 11
3243
3244#define R_RISCV_BRANCH 16
3245#define R_RISCV_JAL 17
3246#define R_RISCV_CALL 18
3247#define R_RISCV_CALL_PLT 19
3248#define R_RISCV_GOT_HI20 20
3249#define R_RISCV_TLS_GOT_HI20 21
3250#define R_RISCV_TLS_GD_HI20 22
3251#define R_RISCV_PCREL_HI20 23
3252#define R_RISCV_PCREL_LO12_I 24
3253#define R_RISCV_PCREL_LO12_S 25
3254#define R_RISCV_HI20 26
3255#define R_RISCV_LO12_I 27
3256#define R_RISCV_LO12_S 28
3257#define R_RISCV_TPREL_HI20 29
3258#define R_RISCV_TPREL_LO12_I 30
3259#define R_RISCV_TPREL_LO12_S 31
3260#define R_RISCV_TPREL_ADD 32
3261#define R_RISCV_ADD8 33
3262#define R_RISCV_ADD16 34
3263#define R_RISCV_ADD32 35
3264#define R_RISCV_ADD64 36
3265#define R_RISCV_SUB8 37
3266#define R_RISCV_SUB16 38
3267#define R_RISCV_SUB32 39
3268#define R_RISCV_SUB64 40
3269#define R_RISCV_GNU_VTINHERIT 41
3270#define R_RISCV_GNU_VTENTRY 42
3271#define R_RISCV_ALIGN 43
3272#define R_RISCV_RVC_BRANCH 44
3273#define R_RISCV_RVC_JUMP 45
3274#define R_RISCV_RVC_LUI 46
3275#define R_RISCV_GPREL_I 47
3276#define R_RISCV_GPREL_S 48
3277#define R_RISCV_TPREL_I 49
3278#define R_RISCV_TPREL_S 50
3279#define R_RISCV_RELAX 51
3280#define R_RISCV_SUB6 52
3281#define R_RISCV_SET6 53
3282#define R_RISCV_SET8 54
3283#define R_RISCV_SET16 55
3284#define R_RISCV_SET32 56
3285#define R_RISCV_32_PCREL 57
3286
3287#ifdef __cplusplus
3288}
3289#endif
3290
3291
3292#endif
lib/libc/musl/include/endian.h created+82
......@@ -0,0 +1,82 @@
1#ifndef _ENDIAN_H
2#define _ENDIAN_H
3
4#include <features.h>
5
6#define __LITTLE_ENDIAN 1234
7#define __BIG_ENDIAN 4321
8#define __PDP_ENDIAN 3412
9
10#if defined(__GNUC__) && defined(__BYTE_ORDER__)
11#define __BYTE_ORDER __BYTE_ORDER__
12#else
13#include <bits/endian.h>
14#endif
15
16#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
17
18#define BIG_ENDIAN __BIG_ENDIAN
19#define LITTLE_ENDIAN __LITTLE_ENDIAN
20#define PDP_ENDIAN __PDP_ENDIAN
21#define BYTE_ORDER __BYTE_ORDER
22
23#include <stdint.h>
24
25static __inline uint16_t __bswap16(uint16_t __x)
26{
27 return __x<<8 | __x>>8;
28}
29
30static __inline uint32_t __bswap32(uint32_t __x)
31{
32 return __x>>24 | __x>>8&0xff00 | __x<<8&0xff0000 | __x<<24;
33}
34
35static __inline uint64_t __bswap64(uint64_t __x)
36{
37 return __bswap32(__x)+0ULL<<32 | __bswap32(__x>>32);
38}
39
40#if __BYTE_ORDER == __LITTLE_ENDIAN
41#define htobe16(x) __bswap16(x)
42#define be16toh(x) __bswap16(x)
43#define betoh16(x) __bswap16(x)
44#define htobe32(x) __bswap32(x)
45#define be32toh(x) __bswap32(x)
46#define betoh32(x) __bswap32(x)
47#define htobe64(x) __bswap64(x)
48#define be64toh(x) __bswap64(x)
49#define betoh64(x) __bswap64(x)
50#define htole16(x) (uint16_t)(x)
51#define le16toh(x) (uint16_t)(x)
52#define letoh16(x) (uint16_t)(x)
53#define htole32(x) (uint32_t)(x)
54#define le32toh(x) (uint32_t)(x)
55#define letoh32(x) (uint32_t)(x)
56#define htole64(x) (uint64_t)(x)
57#define le64toh(x) (uint64_t)(x)
58#define letoh64(x) (uint64_t)(x)
59#else
60#define htobe16(x) (uint16_t)(x)
61#define be16toh(x) (uint16_t)(x)
62#define betoh16(x) (uint16_t)(x)
63#define htobe32(x) (uint32_t)(x)
64#define be32toh(x) (uint32_t)(x)
65#define betoh32(x) (uint32_t)(x)
66#define htobe64(x) (uint64_t)(x)
67#define be64toh(x) (uint64_t)(x)
68#define betoh64(x) (uint64_t)(x)
69#define htole16(x) __bswap16(x)
70#define le16toh(x) __bswap16(x)
71#define letoh16(x) __bswap16(x)
72#define htole32(x) __bswap32(x)
73#define le32toh(x) __bswap32(x)
74#define letoh32(x) __bswap32(x)
75#define htole64(x) __bswap64(x)
76#define le64toh(x) __bswap64(x)
77#define letoh64(x) __bswap64(x)
78#endif
79
80#endif
81
82#endif
lib/libc/musl/include/err.h created+25
......@@ -0,0 +1,25 @@
1#ifndef _ERR_H
2#define _ERR_H
3
4#include <features.h>
5#include <stdarg.h>
6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11void warn(const char *, ...);
12void vwarn(const char *, va_list);
13void warnx(const char *, ...);
14void vwarnx(const char *, va_list);
15
16_Noreturn void err(int, const char *, ...);
17_Noreturn void verr(int, const char *, va_list);
18_Noreturn void errx(int, const char *, ...);
19_Noreturn void verrx(int, const char *, va_list);
20
21#ifdef __cplusplus
22}
23#endif
24
25#endif
lib/libc/musl/include/errno.h created+27
......@@ -0,0 +1,27 @@
1#ifndef _ERRNO_H
2#define _ERRNO_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#include <bits/errno.h>
11
12#ifdef __GNUC__
13__attribute__((const))
14#endif
15int *__errno_location(void);
16#define errno (*__errno_location())
17
18#ifdef _GNU_SOURCE
19extern char *program_invocation_short_name, *program_invocation_name;
20#endif
21
22#ifdef __cplusplus
23}
24#endif
25
26#endif
27
lib/libc/musl/include/fcntl.h created+211
......@@ -0,0 +1,211 @@
1#ifndef _FCNTL_H
2#define _FCNTL_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_off_t
11#define __NEED_pid_t
12#define __NEED_mode_t
13
14#ifdef _GNU_SOURCE
15#define __NEED_size_t
16#define __NEED_ssize_t
17#define __NEED_struct_iovec
18#endif
19
20#include <bits/alltypes.h>
21
22#include <bits/fcntl.h>
23
24struct flock {
25 short l_type;
26 short l_whence;
27 off_t l_start;
28 off_t l_len;
29 pid_t l_pid;
30};
31
32int creat(const char *, mode_t);
33int fcntl(int, int, ...);
34int open(const char *, int, ...);
35int openat(int, const char *, int, ...);
36int posix_fadvise(int, off_t, off_t, int);
37int posix_fallocate(int, off_t, off_t);
38
39#define O_SEARCH O_PATH
40#define O_EXEC O_PATH
41#define O_TTY_INIT 0
42
43#define O_ACCMODE (03|O_SEARCH)
44#define O_RDONLY 00
45#define O_WRONLY 01
46#define O_RDWR 02
47
48#define F_OFD_GETLK 36
49#define F_OFD_SETLK 37
50#define F_OFD_SETLKW 38
51
52#define F_DUPFD_CLOEXEC 1030
53
54#define F_RDLCK 0
55#define F_WRLCK 1
56#define F_UNLCK 2
57
58#define FD_CLOEXEC 1
59
60#define AT_FDCWD (-100)
61#define AT_SYMLINK_NOFOLLOW 0x100
62#define AT_REMOVEDIR 0x200
63#define AT_SYMLINK_FOLLOW 0x400
64#define AT_EACCESS 0x200
65
66#define POSIX_FADV_NORMAL 0
67#define POSIX_FADV_RANDOM 1
68#define POSIX_FADV_SEQUENTIAL 2
69#define POSIX_FADV_WILLNEED 3
70#ifndef POSIX_FADV_DONTNEED
71#define POSIX_FADV_DONTNEED 4
72#define POSIX_FADV_NOREUSE 5
73#endif
74
75#undef SEEK_SET
76#undef SEEK_CUR
77#undef SEEK_END
78#define SEEK_SET 0
79#define SEEK_CUR 1
80#define SEEK_END 2
81
82#ifndef S_IRUSR
83#define S_ISUID 04000
84#define S_ISGID 02000
85#define S_ISVTX 01000
86#define S_IRUSR 0400
87#define S_IWUSR 0200
88#define S_IXUSR 0100
89#define S_IRWXU 0700
90#define S_IRGRP 0040
91#define S_IWGRP 0020
92#define S_IXGRP 0010
93#define S_IRWXG 0070
94#define S_IROTH 0004
95#define S_IWOTH 0002
96#define S_IXOTH 0001
97#define S_IRWXO 0007
98#endif
99
100#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
101#define AT_NO_AUTOMOUNT 0x800
102#define AT_EMPTY_PATH 0x1000
103
104#define FAPPEND O_APPEND
105#define FFSYNC O_SYNC
106#define FASYNC O_ASYNC
107#define FNONBLOCK O_NONBLOCK
108#define FNDELAY O_NDELAY
109
110#define F_OK 0
111#define R_OK 4
112#define W_OK 2
113#define X_OK 1
114#define F_ULOCK 0
115#define F_LOCK 1
116#define F_TLOCK 2
117#define F_TEST 3
118
119#define F_SETLEASE 1024
120#define F_GETLEASE 1025
121#define F_NOTIFY 1026
122#define F_CANCELLK 1029
123#define F_SETPIPE_SZ 1031
124#define F_GETPIPE_SZ 1032
125#define F_ADD_SEALS 1033
126#define F_GET_SEALS 1034
127
128#define F_SEAL_SEAL 0x0001
129#define F_SEAL_SHRINK 0x0002
130#define F_SEAL_GROW 0x0004
131#define F_SEAL_WRITE 0x0008
132#define F_SEAL_FUTURE_WRITE 0x0010
133
134#define F_GET_RW_HINT 1035
135#define F_SET_RW_HINT 1036
136#define F_GET_FILE_RW_HINT 1037
137#define F_SET_FILE_RW_HINT 1038
138
139#define RWF_WRITE_LIFE_NOT_SET 0
140#define RWH_WRITE_LIFE_NONE 1
141#define RWH_WRITE_LIFE_SHORT 2
142#define RWH_WRITE_LIFE_MEDIUM 3
143#define RWH_WRITE_LIFE_LONG 4
144#define RWH_WRITE_LIFE_EXTREME 5
145
146#define DN_ACCESS 0x00000001
147#define DN_MODIFY 0x00000002
148#define DN_CREATE 0x00000004
149#define DN_DELETE 0x00000008
150#define DN_RENAME 0x00000010
151#define DN_ATTRIB 0x00000020
152#define DN_MULTISHOT 0x80000000
153
154int lockf(int, int, off_t);
155#endif
156
157#if defined(_GNU_SOURCE)
158#define F_OWNER_TID 0
159#define F_OWNER_PID 1
160#define F_OWNER_PGRP 2
161#define F_OWNER_GID 2
162struct file_handle {
163 unsigned handle_bytes;
164 int handle_type;
165 unsigned char f_handle[];
166};
167struct f_owner_ex {
168 int type;
169 pid_t pid;
170};
171#define FALLOC_FL_KEEP_SIZE 1
172#define FALLOC_FL_PUNCH_HOLE 2
173#define MAX_HANDLE_SZ 128
174#define SYNC_FILE_RANGE_WAIT_BEFORE 1
175#define SYNC_FILE_RANGE_WRITE 2
176#define SYNC_FILE_RANGE_WAIT_AFTER 4
177#define SPLICE_F_MOVE 1
178#define SPLICE_F_NONBLOCK 2
179#define SPLICE_F_MORE 4
180#define SPLICE_F_GIFT 8
181int fallocate(int, int, off_t, off_t);
182#define fallocate64 fallocate
183int name_to_handle_at(int, const char *, struct file_handle *, int *, int);
184int open_by_handle_at(int, struct file_handle *, int);
185ssize_t readahead(int, off_t, size_t);
186int sync_file_range(int, off_t, off_t, unsigned);
187ssize_t vmsplice(int, const struct iovec *, size_t, unsigned);
188ssize_t splice(int, off_t *, int, off_t *, size_t, unsigned);
189ssize_t tee(int, int, size_t, unsigned);
190#define loff_t off_t
191#endif
192
193#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
194#define F_GETLK64 F_GETLK
195#define F_SETLK64 F_SETLK
196#define F_SETLKW64 F_SETLKW
197#define flock64 flock
198#define open64 open
199#define openat64 openat
200#define creat64 creat
201#define lockf64 lockf
202#define posix_fadvise64 posix_fadvise
203#define posix_fallocate64 posix_fallocate
204#define off64_t off_t
205#endif
206
207#ifdef __cplusplus
208}
209#endif
210
211#endif
lib/libc/musl/include/features.h created+38
......@@ -0,0 +1,38 @@
1#ifndef _FEATURES_H
2#define _FEATURES_H
3
4#if defined(_ALL_SOURCE) && !defined(_GNU_SOURCE)
5#define _GNU_SOURCE 1
6#endif
7
8#if defined(_DEFAULT_SOURCE) && !defined(_BSD_SOURCE)
9#define _BSD_SOURCE 1
10#endif
11
12#if !defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) \
13 && !defined(_XOPEN_SOURCE) && !defined(_GNU_SOURCE) \
14 && !defined(_BSD_SOURCE) && !defined(__STRICT_ANSI__)
15#define _BSD_SOURCE 1
16#define _XOPEN_SOURCE 700
17#endif
18
19#if __STDC_VERSION__ >= 199901L
20#define __restrict restrict
21#elif !defined(__GNUC__)
22#define __restrict
23#endif
24
25#if __STDC_VERSION__ >= 199901L || defined(__cplusplus)
26#define __inline inline
27#elif !defined(__GNUC__)
28#define __inline
29#endif
30
31#if __STDC_VERSION__ >= 201112L
32#elif defined(__GNUC__)
33#define _Noreturn __attribute__((__noreturn__))
34#else
35#define _Noreturn
36#endif
37
38#endif
lib/libc/musl/include/fenv.h created+28
......@@ -0,0 +1,28 @@
1#ifndef _FENV_H
2#define _FENV_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <bits/fenv.h>
9
10int feclearexcept(int);
11int fegetexceptflag(fexcept_t *, int);
12int feraiseexcept(int);
13int fesetexceptflag(const fexcept_t *, int);
14int fetestexcept(int);
15
16int fegetround(void);
17int fesetround(int);
18
19int fegetenv(fenv_t *);
20int feholdexcept(fenv_t *);
21int fesetenv(const fenv_t *);
22int feupdateenv(const fenv_t *);
23
24#ifdef __cplusplus
25}
26#endif
27#endif
28
lib/libc/musl/include/float.h created+52
......@@ -0,0 +1,52 @@
1#ifndef _FLOAT_H
2#define _FLOAT_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8int __flt_rounds(void);
9#define FLT_ROUNDS (__flt_rounds())
10
11#define FLT_RADIX 2
12
13#define FLT_TRUE_MIN 1.40129846432481707092e-45F
14#define FLT_MIN 1.17549435082228750797e-38F
15#define FLT_MAX 3.40282346638528859812e+38F
16#define FLT_EPSILON 1.1920928955078125e-07F
17
18#define FLT_MANT_DIG 24
19#define FLT_MIN_EXP (-125)
20#define FLT_MAX_EXP 128
21#define FLT_HAS_SUBNORM 1
22
23#define FLT_DIG 6
24#define FLT_DECIMAL_DIG 9
25#define FLT_MIN_10_EXP (-37)
26#define FLT_MAX_10_EXP 38
27
28#define DBL_TRUE_MIN 4.94065645841246544177e-324
29#define DBL_MIN 2.22507385850720138309e-308
30#define DBL_MAX 1.79769313486231570815e+308
31#define DBL_EPSILON 2.22044604925031308085e-16
32
33#define DBL_MANT_DIG 53
34#define DBL_MIN_EXP (-1021)
35#define DBL_MAX_EXP 1024
36#define DBL_HAS_SUBNORM 1
37
38#define DBL_DIG 15
39#define DBL_DECIMAL_DIG 17
40#define DBL_MIN_10_EXP (-307)
41#define DBL_MAX_10_EXP 308
42
43#define LDBL_HAS_SUBNORM 1
44#define LDBL_DECIMAL_DIG DECIMAL_DIG
45
46#include <bits/float.h>
47
48#ifdef __cplusplus
49}
50#endif
51
52#endif
lib/libc/musl/include/fmtmsg.h created+47
......@@ -0,0 +1,47 @@
1#ifndef _FMTMSG_H
2#define _FMTMSG_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define MM_HARD 1
9#define MM_SOFT 2
10#define MM_FIRM 4
11
12#define MM_APPL 8
13#define MM_UTIL 16
14#define MM_OPSYS 32
15
16#define MM_RECOVER 64
17#define MM_NRECOV 128
18
19#define MM_PRINT 256
20#define MM_CONSOLE 512
21
22#define MM_NULLMC 0L
23
24#define MM_HALT 1
25#define MM_ERROR 2
26#define MM_WARNING 3
27#define MM_INFO 4
28#define MM_NOSEV 0
29
30#define MM_OK 0
31#define MM_NOTOK (-1)
32#define MM_NOMSG 1
33#define MM_NOCON 4
34
35#define MM_NULLLBL ((char*)0)
36#define MM_NULLTXT ((char*)0)
37#define MM_NULLACT ((char*)0)
38#define MM_NULLTAG ((char*)0)
39#define MM_NULLSEV 0
40
41int fmtmsg(long, const char *, int, const char *, const char *, const char *);
42
43#ifdef __cplusplus
44}
45#endif
46
47#endif
lib/libc/musl/include/fnmatch.h created+24
......@@ -0,0 +1,24 @@
1#ifndef _FNMATCH_H
2#define _FNMATCH_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define FNM_PATHNAME 0x1
9#define FNM_NOESCAPE 0x2
10#define FNM_PERIOD 0x4
11#define FNM_LEADING_DIR 0x8
12#define FNM_CASEFOLD 0x10
13#define FNM_FILE_NAME FNM_PATHNAME
14
15#define FNM_NOMATCH 1
16#define FNM_NOSYS (-1)
17
18int fnmatch(const char *, const char *, int);
19
20#ifdef __cplusplus
21}
22#endif
23
24#endif
lib/libc/musl/include/ftw.h created+41
......@@ -0,0 +1,41 @@
1#ifndef _FTW_H
2#define _FTW_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9#include <sys/stat.h>
10
11#define FTW_F 1
12#define FTW_D 2
13#define FTW_DNR 3
14#define FTW_NS 4
15#define FTW_SL 5
16#define FTW_DP 6
17#define FTW_SLN 7
18
19#define FTW_PHYS 1
20#define FTW_MOUNT 2
21#define FTW_CHDIR 4
22#define FTW_DEPTH 8
23
24struct FTW {
25 int base;
26 int level;
27};
28
29int ftw(const char *, int (*)(const char *, const struct stat *, int), int);
30int nftw(const char *, int (*)(const char *, const struct stat *, int, struct FTW *), int, int);
31
32#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
33#define ftw64 ftw
34#define nftw64 nftw
35#endif
36
37#ifdef __cplusplus
38}
39#endif
40
41#endif
lib/libc/musl/include/getopt.h created+30
......@@ -0,0 +1,30 @@
1#ifndef _GETOPT_H
2#define _GETOPT_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8int getopt(int, char * const [], const char *);
9extern char *optarg;
10extern int optind, opterr, optopt, optreset;
11
12struct option {
13 const char *name;
14 int has_arg;
15 int *flag;
16 int val;
17};
18
19int getopt_long(int, char *const *, const char *, const struct option *, int *);
20int getopt_long_only(int, char *const *, const char *, const struct option *, int *);
21
22#define no_argument 0
23#define required_argument 1
24#define optional_argument 2
25
26#ifdef __cplusplus
27}
28#endif
29
30#endif
lib/libc/musl/include/glob.h created+49
......@@ -0,0 +1,49 @@
1#ifndef _GLOB_H
2#define _GLOB_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_size_t
11
12#include <bits/alltypes.h>
13
14typedef struct {
15 size_t gl_pathc;
16 char **gl_pathv;
17 size_t gl_offs;
18 int __dummy1;
19 void *__dummy2[5];
20} glob_t;
21
22int glob(const char *__restrict, int, int (*)(const char *, int), glob_t *__restrict);
23void globfree(glob_t *);
24
25#define GLOB_ERR 0x01
26#define GLOB_MARK 0x02
27#define GLOB_NOSORT 0x04
28#define GLOB_DOOFFS 0x08
29#define GLOB_NOCHECK 0x10
30#define GLOB_APPEND 0x20
31#define GLOB_NOESCAPE 0x40
32#define GLOB_PERIOD 0x80
33
34#define GLOB_NOSPACE 1
35#define GLOB_ABORTED 2
36#define GLOB_NOMATCH 3
37#define GLOB_NOSYS 4
38
39#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
40#define glob64 glob
41#define globfree64 globfree
42#define glob64_t glob_t
43#endif
44
45#ifdef __cplusplus
46}
47#endif
48
49#endif
lib/libc/musl/include/grp.h created+53
......@@ -0,0 +1,53 @@
1#ifndef _GRP_H
2#define _GRP_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_size_t
11#define __NEED_gid_t
12
13#ifdef _GNU_SOURCE
14#define __NEED_FILE
15#endif
16
17#include <bits/alltypes.h>
18
19struct group {
20 char *gr_name;
21 char *gr_passwd;
22 gid_t gr_gid;
23 char **gr_mem;
24};
25
26struct group *getgrgid(gid_t);
27struct group *getgrnam(const char *);
28
29int getgrgid_r(gid_t, struct group *, char *, size_t, struct group **);
30int getgrnam_r(const char *, struct group *, char *, size_t, struct group **);
31
32#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
33struct group *getgrent(void);
34void endgrent(void);
35void setgrent(void);
36#endif
37
38#ifdef _GNU_SOURCE
39struct group *fgetgrent(FILE *);
40int putgrent(const struct group *, FILE *);
41#endif
42
43#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
44int getgrouplist(const char *, gid_t, gid_t *, int *);
45int setgroups(size_t, const gid_t *);
46int initgroups(const char *, gid_t);
47#endif
48
49#ifdef __cplusplus
50}
51#endif
52
53#endif
lib/libc/musl/include/iconv.h created+24
......@@ -0,0 +1,24 @@
1#ifndef _ICONV_H
2#define _ICONV_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_size_t
11
12#include <bits/alltypes.h>
13
14typedef void *iconv_t;
15
16iconv_t iconv_open(const char *, const char *);
17size_t iconv(iconv_t, char **__restrict, size_t *__restrict, char **__restrict, size_t *__restrict);
18int iconv_close(iconv_t);
19
20#ifdef __cplusplus
21}
22#endif
23
24#endif
lib/libc/musl/include/ifaddrs.h created+35
......@@ -0,0 +1,35 @@
1#ifndef _IFADDRS_H
2#define _IFADDRS_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9#include <netinet/in.h>
10#include <sys/socket.h>
11
12struct ifaddrs {
13 struct ifaddrs *ifa_next;
14 char *ifa_name;
15 unsigned ifa_flags;
16 struct sockaddr *ifa_addr;
17 struct sockaddr *ifa_netmask;
18 union {
19 struct sockaddr *ifu_broadaddr;
20 struct sockaddr *ifu_dstaddr;
21 } ifa_ifu;
22 void *ifa_data;
23};
24#define ifa_broadaddr ifa_ifu.ifu_broadaddr
25#define ifa_dstaddr ifa_ifu.ifu_dstaddr
26
27void freeifaddrs(struct ifaddrs *);
28int getifaddrs(struct ifaddrs **);
29
30#ifdef __cplusplus
31}
32#endif
33
34#endif
35
lib/libc/musl/include/inttypes.h created+229
......@@ -0,0 +1,229 @@
1#ifndef _INTTYPES_H
2#define _INTTYPES_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9#include <stdint.h>
10
11#define __NEED_wchar_t
12#include <bits/alltypes.h>
13
14typedef struct { intmax_t quot, rem; } imaxdiv_t;
15
16intmax_t imaxabs(intmax_t);
17imaxdiv_t imaxdiv(intmax_t, intmax_t);
18
19intmax_t strtoimax(const char *__restrict, char **__restrict, int);
20uintmax_t strtoumax(const char *__restrict, char **__restrict, int);
21
22intmax_t wcstoimax(const wchar_t *__restrict, wchar_t **__restrict, int);
23uintmax_t wcstoumax(const wchar_t *__restrict, wchar_t **__restrict, int);
24
25#if UINTPTR_MAX == UINT64_MAX
26#define __PRI64 "l"
27#define __PRIPTR "l"
28#else
29#define __PRI64 "ll"
30#define __PRIPTR ""
31#endif
32
33#define PRId8 "d"
34#define PRId16 "d"
35#define PRId32 "d"
36#define PRId64 __PRI64 "d"
37
38#define PRIdLEAST8 "d"
39#define PRIdLEAST16 "d"
40#define PRIdLEAST32 "d"
41#define PRIdLEAST64 __PRI64 "d"
42
43#define PRIdFAST8 "d"
44#define PRIdFAST16 "d"
45#define PRIdFAST32 "d"
46#define PRIdFAST64 __PRI64 "d"
47
48#define PRIi8 "i"
49#define PRIi16 "i"
50#define PRIi32 "i"
51#define PRIi64 __PRI64 "i"
52
53#define PRIiLEAST8 "i"
54#define PRIiLEAST16 "i"
55#define PRIiLEAST32 "i"
56#define PRIiLEAST64 __PRI64 "i"
57
58#define PRIiFAST8 "i"
59#define PRIiFAST16 "i"
60#define PRIiFAST32 "i"
61#define PRIiFAST64 __PRI64 "i"
62
63#define PRIo8 "o"
64#define PRIo16 "o"
65#define PRIo32 "o"
66#define PRIo64 __PRI64 "o"
67
68#define PRIoLEAST8 "o"
69#define PRIoLEAST16 "o"
70#define PRIoLEAST32 "o"
71#define PRIoLEAST64 __PRI64 "o"
72
73#define PRIoFAST8 "o"
74#define PRIoFAST16 "o"
75#define PRIoFAST32 "o"
76#define PRIoFAST64 __PRI64 "o"
77
78#define PRIu8 "u"
79#define PRIu16 "u"
80#define PRIu32 "u"
81#define PRIu64 __PRI64 "u"
82
83#define PRIuLEAST8 "u"
84#define PRIuLEAST16 "u"
85#define PRIuLEAST32 "u"
86#define PRIuLEAST64 __PRI64 "u"
87
88#define PRIuFAST8 "u"
89#define PRIuFAST16 "u"
90#define PRIuFAST32 "u"
91#define PRIuFAST64 __PRI64 "u"
92
93#define PRIx8 "x"
94#define PRIx16 "x"
95#define PRIx32 "x"
96#define PRIx64 __PRI64 "x"
97
98#define PRIxLEAST8 "x"
99#define PRIxLEAST16 "x"
100#define PRIxLEAST32 "x"
101#define PRIxLEAST64 __PRI64 "x"
102
103#define PRIxFAST8 "x"
104#define PRIxFAST16 "x"
105#define PRIxFAST32 "x"
106#define PRIxFAST64 __PRI64 "x"
107
108#define PRIX8 "X"
109#define PRIX16 "X"
110#define PRIX32 "X"
111#define PRIX64 __PRI64 "X"
112
113#define PRIXLEAST8 "X"
114#define PRIXLEAST16 "X"
115#define PRIXLEAST32 "X"
116#define PRIXLEAST64 __PRI64 "X"
117
118#define PRIXFAST8 "X"
119#define PRIXFAST16 "X"
120#define PRIXFAST32 "X"
121#define PRIXFAST64 __PRI64 "X"
122
123#define PRIdMAX __PRI64 "d"
124#define PRIiMAX __PRI64 "i"
125#define PRIoMAX __PRI64 "o"
126#define PRIuMAX __PRI64 "u"
127#define PRIxMAX __PRI64 "x"
128#define PRIXMAX __PRI64 "X"
129
130#define PRIdPTR __PRIPTR "d"
131#define PRIiPTR __PRIPTR "i"
132#define PRIoPTR __PRIPTR "o"
133#define PRIuPTR __PRIPTR "u"
134#define PRIxPTR __PRIPTR "x"
135#define PRIXPTR __PRIPTR "X"
136
137#define SCNd8 "hhd"
138#define SCNd16 "hd"
139#define SCNd32 "d"
140#define SCNd64 __PRI64 "d"
141
142#define SCNdLEAST8 "hhd"
143#define SCNdLEAST16 "hd"
144#define SCNdLEAST32 "d"
145#define SCNdLEAST64 __PRI64 "d"
146
147#define SCNdFAST8 "hhd"
148#define SCNdFAST16 "d"
149#define SCNdFAST32 "d"
150#define SCNdFAST64 __PRI64 "d"
151
152#define SCNi8 "hhi"
153#define SCNi16 "hi"
154#define SCNi32 "i"
155#define SCNi64 __PRI64 "i"
156
157#define SCNiLEAST8 "hhi"
158#define SCNiLEAST16 "hi"
159#define SCNiLEAST32 "i"
160#define SCNiLEAST64 __PRI64 "i"
161
162#define SCNiFAST8 "hhi"
163#define SCNiFAST16 "i"
164#define SCNiFAST32 "i"
165#define SCNiFAST64 __PRI64 "i"
166
167#define SCNu8 "hhu"
168#define SCNu16 "hu"
169#define SCNu32 "u"
170#define SCNu64 __PRI64 "u"
171
172#define SCNuLEAST8 "hhu"
173#define SCNuLEAST16 "hu"
174#define SCNuLEAST32 "u"
175#define SCNuLEAST64 __PRI64 "u"
176
177#define SCNuFAST8 "hhu"
178#define SCNuFAST16 "u"
179#define SCNuFAST32 "u"
180#define SCNuFAST64 __PRI64 "u"
181
182#define SCNo8 "hho"
183#define SCNo16 "ho"
184#define SCNo32 "o"
185#define SCNo64 __PRI64 "o"
186
187#define SCNoLEAST8 "hho"
188#define SCNoLEAST16 "ho"
189#define SCNoLEAST32 "o"
190#define SCNoLEAST64 __PRI64 "o"
191
192#define SCNoFAST8 "hho"
193#define SCNoFAST16 "o"
194#define SCNoFAST32 "o"
195#define SCNoFAST64 __PRI64 "o"
196
197#define SCNx8 "hhx"
198#define SCNx16 "hx"
199#define SCNx32 "x"
200#define SCNx64 __PRI64 "x"
201
202#define SCNxLEAST8 "hhx"
203#define SCNxLEAST16 "hx"
204#define SCNxLEAST32 "x"
205#define SCNxLEAST64 __PRI64 "x"
206
207#define SCNxFAST8 "hhx"
208#define SCNxFAST16 "x"
209#define SCNxFAST32 "x"
210#define SCNxFAST64 __PRI64 "x"
211
212#define SCNdMAX __PRI64 "d"
213#define SCNiMAX __PRI64 "i"
214#define SCNoMAX __PRI64 "o"
215#define SCNuMAX __PRI64 "u"
216#define SCNxMAX __PRI64 "x"
217
218#define SCNdPTR __PRIPTR "d"
219#define SCNiPTR __PRIPTR "i"
220#define SCNoPTR __PRIPTR "o"
221#define SCNuPTR __PRIPTR "u"
222#define SCNxPTR __PRIPTR "x"
223
224#ifdef __cplusplus
225}
226#endif
227
228#endif
229
lib/libc/musl/include/iso646.h created+20
......@@ -0,0 +1,20 @@
1#ifndef _ISO646_H
2#define _ISO646_H
3
4#ifndef __cplusplus
5
6#define and &&
7#define and_eq &=
8#define bitand &
9#define bitor |
10#define compl ~
11#define not !
12#define not_eq !=
13#define or ||
14#define or_eq |=
15#define xor ^
16#define xor_eq ^=
17
18#endif
19
20#endif
lib/libc/musl/include/langinfo.h created+98
......@@ -0,0 +1,98 @@
1#ifndef _LANGINFO_H
2#define _LANGINFO_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9#include <nl_types.h>
10
11#define __NEED_locale_t
12
13#include <bits/alltypes.h>
14
15#define ABDAY_1 0x20000
16#define ABDAY_2 0x20001
17#define ABDAY_3 0x20002
18#define ABDAY_4 0x20003
19#define ABDAY_5 0x20004
20#define ABDAY_6 0x20005
21#define ABDAY_7 0x20006
22
23#define DAY_1 0x20007
24#define DAY_2 0x20008
25#define DAY_3 0x20009
26#define DAY_4 0x2000A
27#define DAY_5 0x2000B
28#define DAY_6 0x2000C
29#define DAY_7 0x2000D
30
31#define ABMON_1 0x2000E
32#define ABMON_2 0x2000F
33#define ABMON_3 0x20010
34#define ABMON_4 0x20011
35#define ABMON_5 0x20012
36#define ABMON_6 0x20013
37#define ABMON_7 0x20014
38#define ABMON_8 0x20015
39#define ABMON_9 0x20016
40#define ABMON_10 0x20017
41#define ABMON_11 0x20018
42#define ABMON_12 0x20019
43
44#define MON_1 0x2001A
45#define MON_2 0x2001B
46#define MON_3 0x2001C
47#define MON_4 0x2001D
48#define MON_5 0x2001E
49#define MON_6 0x2001F
50#define MON_7 0x20020
51#define MON_8 0x20021
52#define MON_9 0x20022
53#define MON_10 0x20023
54#define MON_11 0x20024
55#define MON_12 0x20025
56
57#define AM_STR 0x20026
58#define PM_STR 0x20027
59
60#define D_T_FMT 0x20028
61#define D_FMT 0x20029
62#define T_FMT 0x2002A
63#define T_FMT_AMPM 0x2002B
64
65#define ERA 0x2002C
66#define ERA_D_FMT 0x2002E
67#define ALT_DIGITS 0x2002F
68#define ERA_D_T_FMT 0x20030
69#define ERA_T_FMT 0x20031
70
71#define CODESET 14
72
73#define CRNCYSTR 0x4000F
74
75#define RADIXCHAR 0x10000
76#define THOUSEP 0x10001
77#define YESEXPR 0x50000
78#define NOEXPR 0x50001
79
80#define _NL_LOCALE_NAME(cat) (((cat)<<16) | 0xffff)
81
82#if defined(_GNU_SOURCE)
83#define NL_LOCALE_NAME(cat) _NL_LOCALE_NAME(cat)
84#endif
85
86#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
87#define YESSTR 0x50002
88#define NOSTR 0x50003
89#endif
90
91char *nl_langinfo(nl_item);
92char *nl_langinfo_l(nl_item, locale_t);
93
94#ifdef __cplusplus
95}
96#endif
97
98#endif
lib/libc/musl/include/lastlog.h created+1
......@@ -0,0 +1 @@
1#include <utmp.h>
lib/libc/musl/include/libgen.h created+15
......@@ -0,0 +1,15 @@
1#ifndef _LIBGEN_H
2#define _LIBGEN_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8char *dirname(char *);
9char *basename(char *);
10
11#ifdef __cplusplus
12}
13#endif
14
15#endif
lib/libc/musl/include/libintl.h created+33
......@@ -0,0 +1,33 @@
1#ifndef _LIBINTL_H
2#define _LIBINTL_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define __USE_GNU_GETTEXT 1
9#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 1 : -1)
10
11#if __GNUC__ >= 3
12#define __fa(n) __attribute__ ((__format_arg__ (n)))
13#else
14#define __fa(n)
15#endif
16
17char *gettext(const char *) __fa(1);
18char *dgettext(const char *, const char *) __fa(2);
19char *dcgettext(const char *, const char *, int) __fa(2);
20char *ngettext(const char *, const char *, unsigned long) __fa(1) __fa(2);
21char *dngettext(const char *, const char *, const char *, unsigned long) __fa(2) __fa(3);
22char *dcngettext(const char *, const char *, const char *, unsigned long, int) __fa(2) __fa(3);
23char *textdomain(const char *);
24char *bindtextdomain (const char *, const char *);
25char *bind_textdomain_codeset(const char *, const char *);
26
27#undef __fa
28
29#ifdef __cplusplus
30}
31#endif
32
33#endif
lib/libc/musl/include/limits.h created+158
......@@ -0,0 +1,158 @@
1#ifndef _LIMITS_H
2#define _LIMITS_H
3
4#include <features.h>
5
6/* Most limits are system-specific */
7
8#include <bits/limits.h>
9
10/* Support signed or unsigned plain-char */
11
12#if '\xff' > 0
13#define CHAR_MIN 0
14#define CHAR_MAX 255
15#else
16#define CHAR_MIN (-128)
17#define CHAR_MAX 127
18#endif
19
20/* Some universal constants... */
21
22#define CHAR_BIT 8
23#define SCHAR_MIN (-128)
24#define SCHAR_MAX 127
25#define UCHAR_MAX 255
26#define SHRT_MIN (-1-0x7fff)
27#define SHRT_MAX 0x7fff
28#define USHRT_MAX 0xffff
29#define INT_MIN (-1-0x7fffffff)
30#define INT_MAX 0x7fffffff
31#define UINT_MAX 0xffffffffU
32#define LONG_MIN (-LONG_MAX-1)
33#define ULONG_MAX (2UL*LONG_MAX+1)
34#define LLONG_MIN (-LLONG_MAX-1)
35#define ULLONG_MAX (2ULL*LLONG_MAX+1)
36
37#define MB_LEN_MAX 4
38
39#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
40 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
41
42#define PIPE_BUF 4096
43#define FILESIZEBITS 64
44#define NAME_MAX 255
45#define PATH_MAX 4096
46#define NGROUPS_MAX 32
47#define ARG_MAX 131072
48#define IOV_MAX 1024
49#define SYMLOOP_MAX 40
50#define WORD_BIT 32
51#define SSIZE_MAX LONG_MAX
52#define TZNAME_MAX 6
53#define TTY_NAME_MAX 32
54#define HOST_NAME_MAX 255
55
56/* Implementation choices... */
57
58#define PTHREAD_KEYS_MAX 128
59#define PTHREAD_STACK_MIN 2048
60#define PTHREAD_DESTRUCTOR_ITERATIONS 4
61#define SEM_VALUE_MAX 0x7fffffff
62#define SEM_NSEMS_MAX 256
63#define DELAYTIMER_MAX 0x7fffffff
64#define MQ_PRIO_MAX 32768
65#define LOGIN_NAME_MAX 256
66
67/* Arbitrary numbers... */
68
69#define BC_BASE_MAX 99
70#define BC_DIM_MAX 2048
71#define BC_SCALE_MAX 99
72#define BC_STRING_MAX 1000
73#define CHARCLASS_NAME_MAX 14
74#define COLL_WEIGHTS_MAX 2
75#define EXPR_NEST_MAX 32
76#define LINE_MAX 4096
77#define RE_DUP_MAX 255
78
79#define NL_ARGMAX 9
80#define NL_MSGMAX 32767
81#define NL_SETMAX 255
82#define NL_TEXTMAX 2048
83
84#endif
85
86#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_XOPEN_SOURCE)
87
88#ifdef PAGESIZE
89#define PAGE_SIZE PAGESIZE
90#endif
91#define NZERO 20
92#define NL_LANGMAX 32
93
94#endif
95
96#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) \
97 || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700)
98
99#define NL_NMAX 16
100
101#endif
102
103/* POSIX/SUS requirements follow. These numbers come directly
104 * from SUS and have nothing to do with the host system. */
105
106#define _POSIX_AIO_LISTIO_MAX 2
107#define _POSIX_AIO_MAX 1
108#define _POSIX_ARG_MAX 4096
109#define _POSIX_CHILD_MAX 25
110#define _POSIX_CLOCKRES_MIN 20000000
111#define _POSIX_DELAYTIMER_MAX 32
112#define _POSIX_HOST_NAME_MAX 255
113#define _POSIX_LINK_MAX 8
114#define _POSIX_LOGIN_NAME_MAX 9
115#define _POSIX_MAX_CANON 255
116#define _POSIX_MAX_INPUT 255
117#define _POSIX_MQ_OPEN_MAX 8
118#define _POSIX_MQ_PRIO_MAX 32
119#define _POSIX_NAME_MAX 14
120#define _POSIX_NGROUPS_MAX 8
121#define _POSIX_OPEN_MAX 20
122#define _POSIX_PATH_MAX 256
123#define _POSIX_PIPE_BUF 512
124#define _POSIX_RE_DUP_MAX 255
125#define _POSIX_RTSIG_MAX 8
126#define _POSIX_SEM_NSEMS_MAX 256
127#define _POSIX_SEM_VALUE_MAX 32767
128#define _POSIX_SIGQUEUE_MAX 32
129#define _POSIX_SSIZE_MAX 32767
130#define _POSIX_STREAM_MAX 8
131#define _POSIX_SS_REPL_MAX 4
132#define _POSIX_SYMLINK_MAX 255
133#define _POSIX_SYMLOOP_MAX 8
134#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
135#define _POSIX_THREAD_KEYS_MAX 128
136#define _POSIX_THREAD_THREADS_MAX 64
137#define _POSIX_TIMER_MAX 32
138#define _POSIX_TRACE_EVENT_NAME_MAX 30
139#define _POSIX_TRACE_NAME_MAX 8
140#define _POSIX_TRACE_SYS_MAX 8
141#define _POSIX_TRACE_USER_EVENT_MAX 32
142#define _POSIX_TTY_NAME_MAX 9
143#define _POSIX_TZNAME_MAX 6
144#define _POSIX2_BC_BASE_MAX 99
145#define _POSIX2_BC_DIM_MAX 2048
146#define _POSIX2_BC_SCALE_MAX 99
147#define _POSIX2_BC_STRING_MAX 1000
148#define _POSIX2_CHARCLASS_NAME_MAX 14
149#define _POSIX2_COLL_WEIGHTS_MAX 2
150#define _POSIX2_EXPR_NEST_MAX 32
151#define _POSIX2_LINE_MAX 2048
152#define _POSIX2_RE_DUP_MAX 255
153
154#define _XOPEN_IOV_MAX 16
155#define _XOPEN_NAME_MAX 255
156#define _XOPEN_PATH_MAX 1024
157
158#endif
lib/libc/musl/include/link.h created+53
......@@ -0,0 +1,53 @@
1#ifndef _LINK_H
2#define _LINK_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <elf.h>
9#define __NEED_size_t
10#define __NEED_uint32_t
11#include <bits/alltypes.h>
12
13#if UINTPTR_MAX > 0xffffffff
14#define ElfW(type) Elf64_ ## type
15#else
16#define ElfW(type) Elf32_ ## type
17#endif
18
19#include <bits/link.h>
20
21struct dl_phdr_info {
22 ElfW(Addr) dlpi_addr;
23 const char *dlpi_name;
24 const ElfW(Phdr) *dlpi_phdr;
25 ElfW(Half) dlpi_phnum;
26 unsigned long long int dlpi_adds;
27 unsigned long long int dlpi_subs;
28 size_t dlpi_tls_modid;
29 void *dlpi_tls_data;
30};
31
32struct link_map {
33 ElfW(Addr) l_addr;
34 char *l_name;
35 ElfW(Dyn) *l_ld;
36 struct link_map *l_next, *l_prev;
37};
38
39struct r_debug {
40 int r_version;
41 struct link_map *r_map;
42 ElfW(Addr) r_brk;
43 enum { RT_CONSISTENT, RT_ADD, RT_DELETE } r_state;
44 ElfW(Addr) r_ldbase;
45};
46
47int dl_iterate_phdr(int (*)(struct dl_phdr_info *, size_t, void *), void *);
48
49#ifdef __cplusplus
50}
51#endif
52
53#endif
lib/libc/musl/include/locale.h created+86
......@@ -0,0 +1,86 @@
1#ifndef _LOCALE_H
2#define _LOCALE_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#ifdef __cplusplus
11#define NULL 0L
12#else
13#define NULL ((void*)0)
14#endif
15
16#define LC_CTYPE 0
17#define LC_NUMERIC 1
18#define LC_TIME 2
19#define LC_COLLATE 3
20#define LC_MONETARY 4
21#define LC_MESSAGES 5
22#define LC_ALL 6
23
24struct lconv {
25 char *decimal_point;
26 char *thousands_sep;
27 char *grouping;
28
29 char *int_curr_symbol;
30 char *currency_symbol;
31 char *mon_decimal_point;
32 char *mon_thousands_sep;
33 char *mon_grouping;
34 char *positive_sign;
35 char *negative_sign;
36 char int_frac_digits;
37 char frac_digits;
38 char p_cs_precedes;
39 char p_sep_by_space;
40 char n_cs_precedes;
41 char n_sep_by_space;
42 char p_sign_posn;
43 char n_sign_posn;
44 char int_p_cs_precedes;
45 char int_p_sep_by_space;
46 char int_n_cs_precedes;
47 char int_n_sep_by_space;
48 char int_p_sign_posn;
49 char int_n_sign_posn;
50};
51
52
53char *setlocale (int, const char *);
54struct lconv *localeconv(void);
55
56
57#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
58 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
59
60#define __NEED_locale_t
61
62#include <bits/alltypes.h>
63
64#define LC_GLOBAL_LOCALE ((locale_t)-1)
65
66#define LC_CTYPE_MASK (1<<LC_CTYPE)
67#define LC_NUMERIC_MASK (1<<LC_NUMERIC)
68#define LC_TIME_MASK (1<<LC_TIME)
69#define LC_COLLATE_MASK (1<<LC_COLLATE)
70#define LC_MONETARY_MASK (1<<LC_MONETARY)
71#define LC_MESSAGES_MASK (1<<LC_MESSAGES)
72#define LC_ALL_MASK 0x7fffffff
73
74locale_t duplocale(locale_t);
75void freelocale(locale_t);
76locale_t newlocale(int, const char *, locale_t);
77locale_t uselocale(locale_t);
78
79#endif
80
81
82#ifdef __cplusplus
83}
84#endif
85
86#endif
lib/libc/musl/include/malloc.h created+25
......@@ -0,0 +1,25 @@
1#ifndef _MALLOC_H
2#define _MALLOC_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define __NEED_size_t
9
10#include <bits/alltypes.h>
11
12void *malloc (size_t);
13void *calloc (size_t, size_t);
14void *realloc (void *, size_t);
15void free (void *);
16void *valloc (size_t);
17void *memalign(size_t, size_t);
18
19size_t malloc_usable_size(void *);
20
21#ifdef __cplusplus
22}
23#endif
24
25#endif
lib/libc/musl/include/math.h created+442
......@@ -0,0 +1,442 @@
1#ifndef _MATH_H
2#define _MATH_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_float_t
11#define __NEED_double_t
12#include <bits/alltypes.h>
13
14#if 100*__GNUC__+__GNUC_MINOR__ >= 303
15#define NAN __builtin_nanf("")
16#define INFINITY __builtin_inff()
17#else
18#define NAN (0.0f/0.0f)
19#define INFINITY 1e5000f
20#endif
21
22#define HUGE_VALF INFINITY
23#define HUGE_VAL ((double)INFINITY)
24#define HUGE_VALL ((long double)INFINITY)
25
26#define MATH_ERRNO 1
27#define MATH_ERREXCEPT 2
28#define math_errhandling 2
29
30#define FP_ILOGBNAN (-1-0x7fffffff)
31#define FP_ILOGB0 FP_ILOGBNAN
32
33#define FP_NAN 0
34#define FP_INFINITE 1
35#define FP_ZERO 2
36#define FP_SUBNORMAL 3
37#define FP_NORMAL 4
38
39#ifdef __FP_FAST_FMA
40#define FP_FAST_FMA 1
41#endif
42
43#ifdef __FP_FAST_FMAF
44#define FP_FAST_FMAF 1
45#endif
46
47#ifdef __FP_FAST_FMAL
48#define FP_FAST_FMAL 1
49#endif
50
51int __fpclassify(double);
52int __fpclassifyf(float);
53int __fpclassifyl(long double);
54
55static __inline unsigned __FLOAT_BITS(float __f)
56{
57 union {float __f; unsigned __i;} __u;
58 __u.__f = __f;
59 return __u.__i;
60}
61static __inline unsigned long long __DOUBLE_BITS(double __f)
62{
63 union {double __f; unsigned long long __i;} __u;
64 __u.__f = __f;
65 return __u.__i;
66}
67
68#define fpclassify(x) ( \
69 sizeof(x) == sizeof(float) ? __fpclassifyf(x) : \
70 sizeof(x) == sizeof(double) ? __fpclassify(x) : \
71 __fpclassifyl(x) )
72
73#define isinf(x) ( \
74 sizeof(x) == sizeof(float) ? (__FLOAT_BITS(x) & 0x7fffffff) == 0x7f800000 : \
75 sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL>>1) == 0x7ffULL<<52 : \
76 __fpclassifyl(x) == FP_INFINITE)
77
78#define isnan(x) ( \
79 sizeof(x) == sizeof(float) ? (__FLOAT_BITS(x) & 0x7fffffff) > 0x7f800000 : \
80 sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL>>1) > 0x7ffULL<<52 : \
81 __fpclassifyl(x) == FP_NAN)
82
83#define isnormal(x) ( \
84 sizeof(x) == sizeof(float) ? ((__FLOAT_BITS(x)+0x00800000) & 0x7fffffff) >= 0x01000000 : \
85 sizeof(x) == sizeof(double) ? ((__DOUBLE_BITS(x)+(1ULL<<52)) & -1ULL>>1) >= 1ULL<<53 : \
86 __fpclassifyl(x) == FP_NORMAL)
87
88#define isfinite(x) ( \
89 sizeof(x) == sizeof(float) ? (__FLOAT_BITS(x) & 0x7fffffff) < 0x7f800000 : \
90 sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL>>1) < 0x7ffULL<<52 : \
91 __fpclassifyl(x) > FP_INFINITE)
92
93int __signbit(double);
94int __signbitf(float);
95int __signbitl(long double);
96
97#define signbit(x) ( \
98 sizeof(x) == sizeof(float) ? (int)(__FLOAT_BITS(x)>>31) : \
99 sizeof(x) == sizeof(double) ? (int)(__DOUBLE_BITS(x)>>63) : \
100 __signbitl(x) )
101
102#define isunordered(x,y) (isnan((x)) ? ((void)(y),1) : isnan((y)))
103
104#define __ISREL_DEF(rel, op, type) \
105static __inline int __is##rel(type __x, type __y) \
106{ return !isunordered(__x,__y) && __x op __y; }
107
108__ISREL_DEF(lessf, <, float_t)
109__ISREL_DEF(less, <, double_t)
110__ISREL_DEF(lessl, <, long double)
111__ISREL_DEF(lessequalf, <=, float_t)
112__ISREL_DEF(lessequal, <=, double_t)
113__ISREL_DEF(lessequall, <=, long double)
114__ISREL_DEF(lessgreaterf, !=, float_t)
115__ISREL_DEF(lessgreater, !=, double_t)
116__ISREL_DEF(lessgreaterl, !=, long double)
117__ISREL_DEF(greaterf, >, float_t)
118__ISREL_DEF(greater, >, double_t)
119__ISREL_DEF(greaterl, >, long double)
120__ISREL_DEF(greaterequalf, >=, float_t)
121__ISREL_DEF(greaterequal, >=, double_t)
122__ISREL_DEF(greaterequall, >=, long double)
123
124#define __tg_pred_2(x, y, p) ( \
125 sizeof((x)+(y)) == sizeof(float) ? p##f(x, y) : \
126 sizeof((x)+(y)) == sizeof(double) ? p(x, y) : \
127 p##l(x, y) )
128
129#define isless(x, y) __tg_pred_2(x, y, __isless)
130#define islessequal(x, y) __tg_pred_2(x, y, __islessequal)
131#define islessgreater(x, y) __tg_pred_2(x, y, __islessgreater)
132#define isgreater(x, y) __tg_pred_2(x, y, __isgreater)
133#define isgreaterequal(x, y) __tg_pred_2(x, y, __isgreaterequal)
134
135double acos(double);
136float acosf(float);
137long double acosl(long double);
138
139double acosh(double);
140float acoshf(float);
141long double acoshl(long double);
142
143double asin(double);
144float asinf(float);
145long double asinl(long double);
146
147double asinh(double);
148float asinhf(float);
149long double asinhl(long double);
150
151double atan(double);
152float atanf(float);
153long double atanl(long double);
154
155double atan2(double, double);
156float atan2f(float, float);
157long double atan2l(long double, long double);
158
159double atanh(double);
160float atanhf(float);
161long double atanhl(long double);
162
163double cbrt(double);
164float cbrtf(float);
165long double cbrtl(long double);
166
167double ceil(double);
168float ceilf(float);
169long double ceill(long double);
170
171double copysign(double, double);
172float copysignf(float, float);
173long double copysignl(long double, long double);
174
175double cos(double);
176float cosf(float);
177long double cosl(long double);
178
179double cosh(double);
180float coshf(float);
181long double coshl(long double);
182
183double erf(double);
184float erff(float);
185long double erfl(long double);
186
187double erfc(double);
188float erfcf(float);
189long double erfcl(long double);
190
191double exp(double);
192float expf(float);
193long double expl(long double);
194
195double exp2(double);
196float exp2f(float);
197long double exp2l(long double);
198
199double expm1(double);
200float expm1f(float);
201long double expm1l(long double);
202
203double fabs(double);
204float fabsf(float);
205long double fabsl(long double);
206
207double fdim(double, double);
208float fdimf(float, float);
209long double fdiml(long double, long double);
210
211double floor(double);
212float floorf(float);
213long double floorl(long double);
214
215double fma(double, double, double);
216float fmaf(float, float, float);
217long double fmal(long double, long double, long double);
218
219double fmax(double, double);
220float fmaxf(float, float);
221long double fmaxl(long double, long double);
222
223double fmin(double, double);
224float fminf(float, float);
225long double fminl(long double, long double);
226
227double fmod(double, double);
228float fmodf(float, float);
229long double fmodl(long double, long double);
230
231double frexp(double, int *);
232float frexpf(float, int *);
233long double frexpl(long double, int *);
234
235double hypot(double, double);
236float hypotf(float, float);
237long double hypotl(long double, long double);
238
239int ilogb(double);
240int ilogbf(float);
241int ilogbl(long double);
242
243double ldexp(double, int);
244float ldexpf(float, int);
245long double ldexpl(long double, int);
246
247double lgamma(double);
248float lgammaf(float);
249long double lgammal(long double);
250
251long long llrint(double);
252long long llrintf(float);
253long long llrintl(long double);
254
255long long llround(double);
256long long llroundf(float);
257long long llroundl(long double);
258
259double log(double);
260float logf(float);
261long double logl(long double);
262
263double log10(double);
264float log10f(float);
265long double log10l(long double);
266
267double log1p(double);
268float log1pf(float);
269long double log1pl(long double);
270
271double log2(double);
272float log2f(float);
273long double log2l(long double);
274
275double logb(double);
276float logbf(float);
277long double logbl(long double);
278
279long lrint(double);
280long lrintf(float);
281long lrintl(long double);
282
283long lround(double);
284long lroundf(float);
285long lroundl(long double);
286
287double modf(double, double *);
288float modff(float, float *);
289long double modfl(long double, long double *);
290
291double nan(const char *);
292float nanf(const char *);
293long double nanl(const char *);
294
295double nearbyint(double);
296float nearbyintf(float);
297long double nearbyintl(long double);
298
299double nextafter(double, double);
300float nextafterf(float, float);
301long double nextafterl(long double, long double);
302
303double nexttoward(double, long double);
304float nexttowardf(float, long double);
305long double nexttowardl(long double, long double);
306
307double pow(double, double);
308float powf(float, float);
309long double powl(long double, long double);
310
311double remainder(double, double);
312float remainderf(float, float);
313long double remainderl(long double, long double);
314
315double remquo(double, double, int *);
316float remquof(float, float, int *);
317long double remquol(long double, long double, int *);
318
319double rint(double);
320float rintf(float);
321long double rintl(long double);
322
323double round(double);
324float roundf(float);
325long double roundl(long double);
326
327double scalbln(double, long);
328float scalblnf(float, long);
329long double scalblnl(long double, long);
330
331double scalbn(double, int);
332float scalbnf(float, int);
333long double scalbnl(long double, int);
334
335double sin(double);
336float sinf(float);
337long double sinl(long double);
338
339double sinh(double);
340float sinhf(float);
341long double sinhl(long double);
342
343double sqrt(double);
344float sqrtf(float);
345long double sqrtl(long double);
346
347double tan(double);
348float tanf(float);
349long double tanl(long double);
350
351double tanh(double);
352float tanhf(float);
353long double tanhl(long double);
354
355double tgamma(double);
356float tgammaf(float);
357long double tgammal(long double);
358
359double trunc(double);
360float truncf(float);
361long double truncl(long double);
362
363
364#if defined(_XOPEN_SOURCE) || defined(_BSD_SOURCE)
365#undef MAXFLOAT
366#define MAXFLOAT 3.40282346638528859812e+38F
367#endif
368
369#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
370#define M_E 2.7182818284590452354 /* e */
371#define M_LOG2E 1.4426950408889634074 /* log_2 e */
372#define M_LOG10E 0.43429448190325182765 /* log_10 e */
373#define M_LN2 0.69314718055994530942 /* log_e 2 */
374#define M_LN10 2.30258509299404568402 /* log_e 10 */
375#define M_PI 3.14159265358979323846 /* pi */
376#define M_PI_2 1.57079632679489661923 /* pi/2 */
377#define M_PI_4 0.78539816339744830962 /* pi/4 */
378#define M_1_PI 0.31830988618379067154 /* 1/pi */
379#define M_2_PI 0.63661977236758134308 /* 2/pi */
380#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
381#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
382#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
383
384extern int signgam;
385
386double j0(double);
387double j1(double);
388double jn(int, double);
389
390double y0(double);
391double y1(double);
392double yn(int, double);
393#endif
394
395#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
396#define HUGE 3.40282346638528859812e+38F
397
398double drem(double, double);
399float dremf(float, float);
400
401int finite(double);
402int finitef(float);
403
404double scalb(double, double);
405float scalbf(float, float);
406
407double significand(double);
408float significandf(float);
409
410double lgamma_r(double, int*);
411float lgammaf_r(float, int*);
412
413float j0f(float);
414float j1f(float);
415float jnf(int, float);
416
417float y0f(float);
418float y1f(float);
419float ynf(int, float);
420#endif
421
422#ifdef _GNU_SOURCE
423long double lgammal_r(long double, int*);
424
425void sincos(double, double*, double*);
426void sincosf(float, float*, float*);
427void sincosl(long double, long double*, long double*);
428
429double exp10(double);
430float exp10f(float);
431long double exp10l(long double);
432
433double pow10(double);
434float pow10f(float);
435long double pow10l(long double);
436#endif
437
438#ifdef __cplusplus
439}
440#endif
441
442#endif
lib/libc/musl/include/memory.h created+1
......@@ -0,0 +1 @@
1#include <string.h>
lib/libc/musl/include/mntent.h created+43
......@@ -0,0 +1,43 @@
1#ifndef _MNTENT_H
2#define _MNTENT_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define __NEED_FILE
9#include <bits/alltypes.h>
10
11#define MOUNTED "/etc/mtab"
12
13#define MNTTYPE_IGNORE "ignore"
14#define MNTTYPE_NFS "nfs"
15#define MNTTYPE_SWAP "swap"
16#define MNTOPT_DEFAULTS "defaults"
17#define MNTOPT_RO "ro"
18#define MNTOPT_RW "rw"
19#define MNTOPT_SUID "suid"
20#define MNTOPT_NOSUID "nosuid"
21#define MNTOPT_NOAUTO "noauto"
22
23struct mntent {
24 char *mnt_fsname;
25 char *mnt_dir;
26 char *mnt_type;
27 char *mnt_opts;
28 int mnt_freq;
29 int mnt_passno;
30};
31
32FILE *setmntent(const char *, const char *);
33int endmntent(FILE *);
34struct mntent *getmntent(FILE *);
35struct mntent *getmntent_r(FILE *, struct mntent *, char *, int);
36int addmntent(FILE *, const struct mntent *);
37char *hasmntopt(const struct mntent *, const char *);
38
39#ifdef __cplusplus
40}
41#endif
42
43#endif
lib/libc/musl/include/monetary.h created+23
......@@ -0,0 +1,23 @@
1#ifndef _MONETARY_H
2#define _MONETARY_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_ssize_t
11#define __NEED_size_t
12#define __NEED_locale_t
13
14#include <bits/alltypes.h>
15
16ssize_t strfmon(char *__restrict, size_t, const char *__restrict, ...);
17ssize_t strfmon_l(char *__restrict, size_t, locale_t, const char *__restrict, ...);
18
19#ifdef __cplusplus
20}
21#endif
22
23#endif
lib/libc/musl/include/mqueue.h created+36
......@@ -0,0 +1,36 @@
1#ifndef _MQUEUE_H
2#define _MQUEUE_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <features.h>
8
9#define __NEED_size_t
10#define __NEED_ssize_t
11#define __NEED_pthread_attr_t
12#define __NEED_time_t
13#define __NEED_struct_timespec
14#include <bits/alltypes.h>
15
16typedef int mqd_t;
17struct mq_attr {
18 long mq_flags, mq_maxmsg, mq_msgsize, mq_curmsgs, __unused[4];
19};
20struct sigevent;
21
22int mq_close(mqd_t);
23int mq_getattr(mqd_t, struct mq_attr *);
24int mq_notify(mqd_t, const struct sigevent *);
25mqd_t mq_open(const char *, int, ...);
26ssize_t mq_receive(mqd_t, char *, size_t, unsigned *);
27int mq_send(mqd_t, const char *, size_t, unsigned);
28int mq_setattr(mqd_t, const struct mq_attr *__restrict, struct mq_attr *__restrict);
29ssize_t mq_timedreceive(mqd_t, char *__restrict, size_t, unsigned *__restrict, const struct timespec *__restrict);
30int mq_timedsend(mqd_t, const char *, size_t, unsigned, const struct timespec *);
31int mq_unlink(const char *);
32
33#ifdef __cplusplus
34}
35#endif
36#endif
lib/libc/musl/include/net/ethernet.h created+55
......@@ -0,0 +1,55 @@
1#ifndef _NET_ETHERNET_H
2#define _NET_ETHERNET_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stdint.h>
9#include <sys/types.h>
10#include <netinet/if_ether.h>
11
12struct ether_addr {
13 uint8_t ether_addr_octet[ETH_ALEN];
14};
15
16struct ether_header {
17 uint8_t ether_dhost[ETH_ALEN];
18 uint8_t ether_shost[ETH_ALEN];
19 uint16_t ether_type;
20};
21
22#define ETHERTYPE_PUP 0x0200
23#define ETHERTYPE_SPRITE 0x0500
24#define ETHERTYPE_IP 0x0800
25#define ETHERTYPE_ARP 0x0806
26#define ETHERTYPE_REVARP 0x8035
27#define ETHERTYPE_AT 0x809B
28#define ETHERTYPE_AARP 0x80F3
29#define ETHERTYPE_VLAN 0x8100
30#define ETHERTYPE_IPX 0x8137
31#define ETHERTYPE_IPV6 0x86dd
32#define ETHERTYPE_LOOPBACK 0x9000
33
34
35#define ETHER_ADDR_LEN ETH_ALEN
36#define ETHER_TYPE_LEN 2
37#define ETHER_CRC_LEN 4
38#define ETHER_HDR_LEN ETH_HLEN
39#define ETHER_MIN_LEN (ETH_ZLEN + ETHER_CRC_LEN)
40#define ETHER_MAX_LEN (ETH_FRAME_LEN + ETHER_CRC_LEN)
41
42#define ETHER_IS_VALID_LEN(foo) \
43 ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN)
44
45#define ETHERTYPE_TRAIL 0x1000
46#define ETHERTYPE_NTRAILER 16
47
48#define ETHERMTU ETH_DATA_LEN
49#define ETHERMIN (ETHER_MIN_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN)
50
51#ifdef __cplusplus
52}
53#endif
54
55#endif
lib/libc/musl/include/net/if.h created+141
......@@ -0,0 +1,141 @@
1#ifndef _NET_IF_H
2#define _NET_IF_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define IF_NAMESIZE 16
11
12struct if_nameindex {
13 unsigned int if_index;
14 char *if_name;
15};
16
17unsigned int if_nametoindex (const char *);
18char *if_indextoname (unsigned int, char *);
19struct if_nameindex *if_nameindex (void);
20void if_freenameindex (struct if_nameindex *);
21
22
23
24
25#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
26
27#include <sys/socket.h>
28
29#define IFF_UP 0x1
30#define IFF_BROADCAST 0x2
31#define IFF_DEBUG 0x4
32#define IFF_LOOPBACK 0x8
33#define IFF_POINTOPOINT 0x10
34#define IFF_NOTRAILERS 0x20
35#define IFF_RUNNING 0x40
36#define IFF_NOARP 0x80
37#define IFF_PROMISC 0x100
38#define IFF_ALLMULTI 0x200
39#define IFF_MASTER 0x400
40#define IFF_SLAVE 0x800
41#define IFF_MULTICAST 0x1000
42#define IFF_PORTSEL 0x2000
43#define IFF_AUTOMEDIA 0x4000
44#define IFF_DYNAMIC 0x8000
45#define IFF_LOWER_UP 0x10000
46#define IFF_DORMANT 0x20000
47#define IFF_ECHO 0x40000
48#define IFF_VOLATILE (IFF_LOOPBACK|IFF_POINTOPOINT|IFF_BROADCAST| \
49 IFF_ECHO|IFF_MASTER|IFF_SLAVE|IFF_RUNNING|IFF_LOWER_UP|IFF_DORMANT)
50
51struct ifaddr {
52 struct sockaddr ifa_addr;
53 union {
54 struct sockaddr ifu_broadaddr;
55 struct sockaddr ifu_dstaddr;
56 } ifa_ifu;
57 struct iface *ifa_ifp;
58 struct ifaddr *ifa_next;
59};
60
61#define ifa_broadaddr ifa_ifu.ifu_broadaddr
62#define ifa_dstaddr ifa_ifu.ifu_dstaddr
63
64struct ifmap {
65 unsigned long int mem_start;
66 unsigned long int mem_end;
67 unsigned short int base_addr;
68 unsigned char irq;
69 unsigned char dma;
70 unsigned char port;
71};
72
73#define IFHWADDRLEN 6
74#define IFNAMSIZ IF_NAMESIZE
75
76struct ifreq {
77 union {
78 char ifrn_name[IFNAMSIZ];
79 } ifr_ifrn;
80 union {
81 struct sockaddr ifru_addr;
82 struct sockaddr ifru_dstaddr;
83 struct sockaddr ifru_broadaddr;
84 struct sockaddr ifru_netmask;
85 struct sockaddr ifru_hwaddr;
86 short int ifru_flags;
87 int ifru_ivalue;
88 int ifru_mtu;
89 struct ifmap ifru_map;
90 char ifru_slave[IFNAMSIZ];
91 char ifru_newname[IFNAMSIZ];
92 char *ifru_data;
93 } ifr_ifru;
94};
95
96#define ifr_name ifr_ifrn.ifrn_name
97#define ifr_hwaddr ifr_ifru.ifru_hwaddr
98#define ifr_addr ifr_ifru.ifru_addr
99#define ifr_dstaddr ifr_ifru.ifru_dstaddr
100#define ifr_broadaddr ifr_ifru.ifru_broadaddr
101#define ifr_netmask ifr_ifru.ifru_netmask
102#define ifr_flags ifr_ifru.ifru_flags
103#define ifr_metric ifr_ifru.ifru_ivalue
104#define ifr_mtu ifr_ifru.ifru_mtu
105#define ifr_map ifr_ifru.ifru_map
106#define ifr_slave ifr_ifru.ifru_slave
107#define ifr_data ifr_ifru.ifru_data
108#define ifr_ifindex ifr_ifru.ifru_ivalue
109#define ifr_bandwidth ifr_ifru.ifru_ivalue
110#define ifr_qlen ifr_ifru.ifru_ivalue
111#define ifr_newname ifr_ifru.ifru_newname
112#define _IOT_ifreq _IOT(_IOTS(char),IFNAMSIZ,_IOTS(char),16,0,0)
113#define _IOT_ifreq_short _IOT(_IOTS(char),IFNAMSIZ,_IOTS(short),1,0,0)
114#define _IOT_ifreq_int _IOT(_IOTS(char),IFNAMSIZ,_IOTS(int),1,0,0)
115
116struct ifconf {
117 int ifc_len;
118 union {
119 char *ifcu_buf;
120 struct ifreq *ifcu_req;
121 } ifc_ifcu;
122};
123
124#define ifc_buf ifc_ifcu.ifcu_buf
125#define ifc_req ifc_ifcu.ifcu_req
126#define _IOT_ifconf _IOT(_IOTS(struct ifconf),1,0,0,0,0)
127
128#define __UAPI_DEF_IF_IFCONF 0
129#define __UAPI_DEF_IF_IFMAP 0
130#define __UAPI_DEF_IF_IFNAMSIZ 0
131#define __UAPI_DEF_IF_IFREQ 0
132#define __UAPI_DEF_IF_NET_DEVICE_FLAGS 0
133#define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 0
134
135#endif
136
137#ifdef __cplusplus
138}
139#endif
140
141#endif
lib/libc/musl/include/net/if_arp.h created+142
......@@ -0,0 +1,142 @@
1/* Nonstandard header */
2#ifndef _NET_IF_ARP_H
3#define _NET_IF_ARP_H
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <inttypes.h>
9#include <sys/types.h>
10#include <sys/socket.h>
11
12#define MAX_ADDR_LEN 7
13
14#define ARPOP_REQUEST 1
15#define ARPOP_REPLY 2
16#define ARPOP_RREQUEST 3
17#define ARPOP_RREPLY 4
18#define ARPOP_InREQUEST 8
19#define ARPOP_InREPLY 9
20#define ARPOP_NAK 10
21
22struct arphdr {
23 uint16_t ar_hrd;
24 uint16_t ar_pro;
25 uint8_t ar_hln;
26 uint8_t ar_pln;
27 uint16_t ar_op;
28};
29
30
31#define ARPHRD_NETROM 0
32#define ARPHRD_ETHER 1
33#define ARPHRD_EETHER 2
34#define ARPHRD_AX25 3
35#define ARPHRD_PRONET 4
36#define ARPHRD_CHAOS 5
37#define ARPHRD_IEEE802 6
38#define ARPHRD_ARCNET 7
39#define ARPHRD_APPLETLK 8
40#define ARPHRD_DLCI 15
41#define ARPHRD_ATM 19
42#define ARPHRD_METRICOM 23
43#define ARPHRD_IEEE1394 24
44#define ARPHRD_EUI64 27
45#define ARPHRD_INFINIBAND 32
46#define ARPHRD_SLIP 256
47#define ARPHRD_CSLIP 257
48#define ARPHRD_SLIP6 258
49#define ARPHRD_CSLIP6 259
50#define ARPHRD_RSRVD 260
51#define ARPHRD_ADAPT 264
52#define ARPHRD_ROSE 270
53#define ARPHRD_X25 271
54#define ARPHRD_HWX25 272
55#define ARPHRD_CAN 280
56#define ARPHRD_PPP 512
57#define ARPHRD_CISCO 513
58#define ARPHRD_HDLC ARPHRD_CISCO
59#define ARPHRD_LAPB 516
60#define ARPHRD_DDCMP 517
61#define ARPHRD_RAWHDLC 518
62#define ARPHRD_RAWIP 519
63
64#define ARPHRD_TUNNEL 768
65#define ARPHRD_TUNNEL6 769
66#define ARPHRD_FRAD 770
67#define ARPHRD_SKIP 771
68#define ARPHRD_LOOPBACK 772
69#define ARPHRD_LOCALTLK 773
70#define ARPHRD_FDDI 774
71#define ARPHRD_BIF 775
72#define ARPHRD_SIT 776
73#define ARPHRD_IPDDP 777
74#define ARPHRD_IPGRE 778
75#define ARPHRD_PIMREG 779
76#define ARPHRD_HIPPI 780
77#define ARPHRD_ASH 781
78#define ARPHRD_ECONET 782
79#define ARPHRD_IRDA 783
80#define ARPHRD_FCPP 784
81#define ARPHRD_FCAL 785
82#define ARPHRD_FCPL 786
83#define ARPHRD_FCFABRIC 787
84#define ARPHRD_IEEE802_TR 800
85#define ARPHRD_IEEE80211 801
86#define ARPHRD_IEEE80211_PRISM 802
87#define ARPHRD_IEEE80211_RADIOTAP 803
88#define ARPHRD_IEEE802154 804
89#define ARPHRD_IEEE802154_MONITOR 805
90#define ARPHRD_PHONET 820
91#define ARPHRD_PHONET_PIPE 821
92#define ARPHRD_CAIF 822
93#define ARPHRD_IP6GRE 823
94#define ARPHRD_NETLINK 824
95#define ARPHRD_6LOWPAN 825
96#define ARPHRD_VSOCKMON 826
97
98#define ARPHRD_VOID 0xFFFF
99#define ARPHRD_NONE 0xFFFE
100
101struct arpreq {
102 struct sockaddr arp_pa;
103 struct sockaddr arp_ha;
104 int arp_flags;
105 struct sockaddr arp_netmask;
106 char arp_dev[16];
107};
108
109struct arpreq_old {
110 struct sockaddr arp_pa;
111 struct sockaddr arp_ha;
112 int arp_flags;
113 struct sockaddr arp_netmask;
114};
115
116#define ATF_COM 0x02
117#define ATF_PERM 0x04
118#define ATF_PUBL 0x08
119#define ATF_USETRAILERS 0x10
120#define ATF_NETMASK 0x20
121#define ATF_DONTPUB 0x40
122#define ATF_MAGIC 0x80
123
124#define ARPD_UPDATE 0x01
125#define ARPD_LOOKUP 0x02
126#define ARPD_FLUSH 0x03
127
128struct arpd_request {
129 unsigned short req;
130 uint32_t ip;
131 unsigned long dev;
132 unsigned long stamp;
133 unsigned long updated;
134 unsigned char ha[MAX_ADDR_LEN];
135};
136
137
138
139#ifdef __cplusplus
140}
141#endif
142#endif
lib/libc/musl/include/net/route.h created+124
......@@ -0,0 +1,124 @@
1#ifndef _NET_ROUTE_H
2#define _NET_ROUTE_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stdint.h>
9#include <sys/socket.h>
10#include <sys/types.h>
11#include <netinet/in.h>
12
13
14struct rtentry {
15 unsigned long int rt_pad1;
16 struct sockaddr rt_dst;
17 struct sockaddr rt_gateway;
18 struct sockaddr rt_genmask;
19 unsigned short int rt_flags;
20 short int rt_pad2;
21 unsigned long int rt_pad3;
22 unsigned char rt_tos;
23 unsigned char rt_class;
24 short int rt_pad4[sizeof(long)/2-1];
25 short int rt_metric;
26 char *rt_dev;
27 unsigned long int rt_mtu;
28 unsigned long int rt_window;
29 unsigned short int rt_irtt;
30};
31
32#define rt_mss rt_mtu
33
34
35struct in6_rtmsg {
36 struct in6_addr rtmsg_dst;
37 struct in6_addr rtmsg_src;
38 struct in6_addr rtmsg_gateway;
39 uint32_t rtmsg_type;
40 uint16_t rtmsg_dst_len;
41 uint16_t rtmsg_src_len;
42 uint32_t rtmsg_metric;
43 unsigned long int rtmsg_info;
44 uint32_t rtmsg_flags;
45 int rtmsg_ifindex;
46};
47
48
49#define RTF_UP 0x0001
50#define RTF_GATEWAY 0x0002
51
52#define RTF_HOST 0x0004
53#define RTF_REINSTATE 0x0008
54#define RTF_DYNAMIC 0x0010
55#define RTF_MODIFIED 0x0020
56#define RTF_MTU 0x0040
57#define RTF_MSS RTF_MTU
58#define RTF_WINDOW 0x0080
59#define RTF_IRTT 0x0100
60#define RTF_REJECT 0x0200
61#define RTF_STATIC 0x0400
62#define RTF_XRESOLVE 0x0800
63#define RTF_NOFORWARD 0x1000
64#define RTF_THROW 0x2000
65#define RTF_NOPMTUDISC 0x4000
66
67#define RTF_DEFAULT 0x00010000
68#define RTF_ALLONLINK 0x00020000
69#define RTF_ADDRCONF 0x00040000
70
71#define RTF_LINKRT 0x00100000
72#define RTF_NONEXTHOP 0x00200000
73
74#define RTF_CACHE 0x01000000
75#define RTF_FLOW 0x02000000
76#define RTF_POLICY 0x04000000
77
78#define RTCF_VALVE 0x00200000
79#define RTCF_MASQ 0x00400000
80#define RTCF_NAT 0x00800000
81#define RTCF_DOREDIRECT 0x01000000
82#define RTCF_LOG 0x02000000
83#define RTCF_DIRECTSRC 0x04000000
84
85#define RTF_LOCAL 0x80000000
86#define RTF_INTERFACE 0x40000000
87#define RTF_MULTICAST 0x20000000
88#define RTF_BROADCAST 0x10000000
89#define RTF_NAT 0x08000000
90
91#define RTF_ADDRCLASSMASK 0xF8000000
92#define RT_ADDRCLASS(flags) ((uint32_t) flags >> 23)
93
94#define RT_TOS(tos) ((tos) & IPTOS_TOS_MASK)
95
96#define RT_LOCALADDR(flags) ((flags & RTF_ADDRCLASSMASK) \
97 == (RTF_LOCAL|RTF_INTERFACE))
98
99#define RT_CLASS_UNSPEC 0
100#define RT_CLASS_DEFAULT 253
101
102#define RT_CLASS_MAIN 254
103#define RT_CLASS_LOCAL 255
104#define RT_CLASS_MAX 255
105
106
107#define RTMSG_ACK NLMSG_ACK
108#define RTMSG_OVERRUN NLMSG_OVERRUN
109
110#define RTMSG_NEWDEVICE 0x11
111#define RTMSG_DELDEVICE 0x12
112#define RTMSG_NEWROUTE 0x21
113#define RTMSG_DELROUTE 0x22
114#define RTMSG_NEWRULE 0x31
115#define RTMSG_DELRULE 0x32
116#define RTMSG_CONTROL 0x40
117
118#define RTMSG_AR_FAILED 0x51
119
120#ifdef __cplusplus
121}
122#endif
123
124#endif
lib/libc/musl/include/netdb.h created+156
......@@ -0,0 +1,156 @@
1#ifndef _NETDB_H
2#define _NETDB_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9#include <netinet/in.h>
10
11#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
12#define __NEED_size_t
13#include <bits/alltypes.h>
14#endif
15
16struct addrinfo {
17 int ai_flags;
18 int ai_family;
19 int ai_socktype;
20 int ai_protocol;
21 socklen_t ai_addrlen;
22 struct sockaddr *ai_addr;
23 char *ai_canonname;
24 struct addrinfo *ai_next;
25};
26
27#define AI_PASSIVE 0x01
28#define AI_CANONNAME 0x02
29#define AI_NUMERICHOST 0x04
30#define AI_V4MAPPED 0x08
31#define AI_ALL 0x10
32#define AI_ADDRCONFIG 0x20
33#define AI_NUMERICSERV 0x400
34
35
36#define NI_NUMERICHOST 0x01
37#define NI_NUMERICSERV 0x02
38#define NI_NOFQDN 0x04
39#define NI_NAMEREQD 0x08
40#define NI_DGRAM 0x10
41#define NI_NUMERICSCOPE 0x100
42
43#define EAI_BADFLAGS -1
44#define EAI_NONAME -2
45#define EAI_AGAIN -3
46#define EAI_FAIL -4
47#define EAI_FAMILY -6
48#define EAI_SOCKTYPE -7
49#define EAI_SERVICE -8
50#define EAI_MEMORY -10
51#define EAI_SYSTEM -11
52#define EAI_OVERFLOW -12
53
54int getaddrinfo (const char *__restrict, const char *__restrict, const struct addrinfo *__restrict, struct addrinfo **__restrict);
55void freeaddrinfo (struct addrinfo *);
56int getnameinfo (const struct sockaddr *__restrict, socklen_t, char *__restrict, socklen_t, char *__restrict, socklen_t, int);
57const char *gai_strerror(int);
58
59
60/* Legacy functions follow (marked OBsolete in SUS) */
61
62struct netent {
63 char *n_name;
64 char **n_aliases;
65 int n_addrtype;
66 uint32_t n_net;
67};
68
69struct hostent {
70 char *h_name;
71 char **h_aliases;
72 int h_addrtype;
73 int h_length;
74 char **h_addr_list;
75};
76#define h_addr h_addr_list[0]
77
78struct servent {
79 char *s_name;
80 char **s_aliases;
81 int s_port;
82 char *s_proto;
83};
84
85struct protoent {
86 char *p_name;
87 char **p_aliases;
88 int p_proto;
89};
90
91void sethostent (int);
92void endhostent (void);
93struct hostent *gethostent (void);
94
95void setnetent (int);
96void endnetent (void);
97struct netent *getnetent (void);
98struct netent *getnetbyaddr (uint32_t, int);
99struct netent *getnetbyname (const char *);
100
101void setservent (int);
102void endservent (void);
103struct servent *getservent (void);
104struct servent *getservbyname (const char *, const char *);
105struct servent *getservbyport (int, const char *);
106
107void setprotoent (int);
108void endprotoent (void);
109struct protoent *getprotoent (void);
110struct protoent *getprotobyname (const char *);
111struct protoent *getprotobynumber (int);
112
113#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_POSIX_SOURCE) \
114 || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE+0 < 200809L) \
115 || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700)
116struct hostent *gethostbyname (const char *);
117struct hostent *gethostbyaddr (const void *, socklen_t, int);
118#ifdef __GNUC__
119__attribute__((const))
120#endif
121int *__h_errno_location(void);
122#define h_errno (*__h_errno_location())
123#define HOST_NOT_FOUND 1
124#define TRY_AGAIN 2
125#define NO_RECOVERY 3
126#define NO_DATA 4
127#define NO_ADDRESS NO_DATA
128#endif
129
130#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
131void herror(const char *);
132const char *hstrerror(int);
133int gethostbyname_r(const char *, struct hostent *, char *, size_t, struct hostent **, int *);
134int gethostbyname2_r(const char *, int, struct hostent *, char *, size_t, struct hostent **, int *);
135struct hostent *gethostbyname2(const char *, int);
136int gethostbyaddr_r(const void *, socklen_t, int, struct hostent *, char *, size_t, struct hostent **, int *);
137int getservbyport_r(int, const char *, struct servent *, char *, size_t, struct servent **);
138int getservbyname_r(const char *, const char *, struct servent *, char *, size_t, struct servent **);
139#define EAI_NODATA -5
140#define EAI_ADDRFAMILY -9
141#define EAI_INPROGRESS -100
142#define EAI_CANCELED -101
143#define EAI_NOTCANCELED -102
144#define EAI_ALLDONE -103
145#define EAI_INTR -104
146#define EAI_IDN_ENCODE -105
147#define NI_MAXHOST 255
148#define NI_MAXSERV 32
149#endif
150
151
152#ifdef __cplusplus
153}
154#endif
155
156#endif
lib/libc/musl/include/netinet/ether.h created+22
......@@ -0,0 +1,22 @@
1#ifndef _NETINET_ETHER_H
2#define _NETINET_ETHER_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <netinet/if_ether.h>
9
10char *ether_ntoa (const struct ether_addr *);
11struct ether_addr *ether_aton (const char *);
12char *ether_ntoa_r (const struct ether_addr *, char *);
13struct ether_addr *ether_aton_r (const char *, struct ether_addr *);
14int ether_line(const char *, struct ether_addr *, char *);
15int ether_ntohost(char *, const struct ether_addr *);
16int ether_hostton(const char *, struct ether_addr *);
17
18#ifdef __cplusplus
19}
20#endif
21
22#endif
lib/libc/musl/include/netinet/icmp6.h created+306
......@@ -0,0 +1,306 @@
1#ifndef _NETINET_ICMP6_H
2#define _NETINET_ICMP6_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stdint.h>
9#include <string.h>
10#include <sys/types.h>
11#include <netinet/in.h>
12#include <endian.h>
13
14#define ICMP6_FILTER 1
15
16#define ICMP6_FILTER_BLOCK 1
17#define ICMP6_FILTER_PASS 2
18#define ICMP6_FILTER_BLOCKOTHERS 3
19#define ICMP6_FILTER_PASSONLY 4
20
21struct icmp6_filter {
22 uint32_t icmp6_filt[8];
23};
24
25struct icmp6_hdr {
26 uint8_t icmp6_type;
27 uint8_t icmp6_code;
28 uint16_t icmp6_cksum;
29 union {
30 uint32_t icmp6_un_data32[1];
31 uint16_t icmp6_un_data16[2];
32 uint8_t icmp6_un_data8[4];
33 } icmp6_dataun;
34};
35
36#define icmp6_data32 icmp6_dataun.icmp6_un_data32
37#define icmp6_data16 icmp6_dataun.icmp6_un_data16
38#define icmp6_data8 icmp6_dataun.icmp6_un_data8
39#define icmp6_pptr icmp6_data32[0]
40#define icmp6_mtu icmp6_data32[0]
41#define icmp6_id icmp6_data16[0]
42#define icmp6_seq icmp6_data16[1]
43#define icmp6_maxdelay icmp6_data16[0]
44
45#define ICMP6_DST_UNREACH 1
46#define ICMP6_PACKET_TOO_BIG 2
47#define ICMP6_TIME_EXCEEDED 3
48#define ICMP6_PARAM_PROB 4
49
50#define ICMP6_INFOMSG_MASK 0x80
51
52#define ICMP6_ECHO_REQUEST 128
53#define ICMP6_ECHO_REPLY 129
54#define MLD_LISTENER_QUERY 130
55#define MLD_LISTENER_REPORT 131
56#define MLD_LISTENER_REDUCTION 132
57
58#define ICMP6_DST_UNREACH_NOROUTE 0
59#define ICMP6_DST_UNREACH_ADMIN 1
60#define ICMP6_DST_UNREACH_BEYONDSCOPE 2
61#define ICMP6_DST_UNREACH_ADDR 3
62#define ICMP6_DST_UNREACH_NOPORT 4
63
64#define ICMP6_TIME_EXCEED_TRANSIT 0
65#define ICMP6_TIME_EXCEED_REASSEMBLY 1
66
67#define ICMP6_PARAMPROB_HEADER 0
68#define ICMP6_PARAMPROB_NEXTHEADER 1
69#define ICMP6_PARAMPROB_OPTION 2
70
71#define ICMP6_FILTER_WILLPASS(type, filterp) \
72 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0)
73
74#define ICMP6_FILTER_WILLBLOCK(type, filterp) \
75 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0)
76
77#define ICMP6_FILTER_SETPASS(type, filterp) \
78 ((((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31))))
79
80#define ICMP6_FILTER_SETBLOCK(type, filterp) \
81 ((((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31))))
82
83#define ICMP6_FILTER_SETPASSALL(filterp) \
84 memset (filterp, 0, sizeof (struct icmp6_filter));
85
86#define ICMP6_FILTER_SETBLOCKALL(filterp) \
87 memset (filterp, 0xFF, sizeof (struct icmp6_filter));
88
89#define ND_ROUTER_SOLICIT 133
90#define ND_ROUTER_ADVERT 134
91#define ND_NEIGHBOR_SOLICIT 135
92#define ND_NEIGHBOR_ADVERT 136
93#define ND_REDIRECT 137
94
95struct nd_router_solicit {
96 struct icmp6_hdr nd_rs_hdr;
97};
98
99#define nd_rs_type nd_rs_hdr.icmp6_type
100#define nd_rs_code nd_rs_hdr.icmp6_code
101#define nd_rs_cksum nd_rs_hdr.icmp6_cksum
102#define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
103
104struct nd_router_advert {
105 struct icmp6_hdr nd_ra_hdr;
106 uint32_t nd_ra_reachable;
107 uint32_t nd_ra_retransmit;
108};
109
110#define nd_ra_type nd_ra_hdr.icmp6_type
111#define nd_ra_code nd_ra_hdr.icmp6_code
112#define nd_ra_cksum nd_ra_hdr.icmp6_cksum
113#define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
114#define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
115#define ND_RA_FLAG_MANAGED 0x80
116#define ND_RA_FLAG_OTHER 0x40
117#define ND_RA_FLAG_HOME_AGENT 0x20
118#define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
119
120struct nd_neighbor_solicit {
121 struct icmp6_hdr nd_ns_hdr;
122 struct in6_addr nd_ns_target;
123};
124
125#define nd_ns_type nd_ns_hdr.icmp6_type
126#define nd_ns_code nd_ns_hdr.icmp6_code
127#define nd_ns_cksum nd_ns_hdr.icmp6_cksum
128#define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
129
130struct nd_neighbor_advert {
131 struct icmp6_hdr nd_na_hdr;
132 struct in6_addr nd_na_target;
133};
134
135#define nd_na_type nd_na_hdr.icmp6_type
136#define nd_na_code nd_na_hdr.icmp6_code
137#define nd_na_cksum nd_na_hdr.icmp6_cksum
138#define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
139#if __BYTE_ORDER == __BIG_ENDIAN
140#define ND_NA_FLAG_ROUTER 0x80000000
141#define ND_NA_FLAG_SOLICITED 0x40000000
142#define ND_NA_FLAG_OVERRIDE 0x20000000
143#else
144#define ND_NA_FLAG_ROUTER 0x00000080
145#define ND_NA_FLAG_SOLICITED 0x00000040
146#define ND_NA_FLAG_OVERRIDE 0x00000020
147#endif
148
149struct nd_redirect {
150 struct icmp6_hdr nd_rd_hdr;
151 struct in6_addr nd_rd_target;
152 struct in6_addr nd_rd_dst;
153};
154
155#define nd_rd_type nd_rd_hdr.icmp6_type
156#define nd_rd_code nd_rd_hdr.icmp6_code
157#define nd_rd_cksum nd_rd_hdr.icmp6_cksum
158#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
159
160struct nd_opt_hdr {
161 uint8_t nd_opt_type;
162 uint8_t nd_opt_len;
163};
164
165#define ND_OPT_SOURCE_LINKADDR 1
166#define ND_OPT_TARGET_LINKADDR 2
167#define ND_OPT_PREFIX_INFORMATION 3
168#define ND_OPT_REDIRECTED_HEADER 4
169#define ND_OPT_MTU 5
170#define ND_OPT_RTR_ADV_INTERVAL 7
171#define ND_OPT_HOME_AGENT_INFO 8
172
173struct nd_opt_prefix_info {
174 uint8_t nd_opt_pi_type;
175 uint8_t nd_opt_pi_len;
176 uint8_t nd_opt_pi_prefix_len;
177 uint8_t nd_opt_pi_flags_reserved;
178 uint32_t nd_opt_pi_valid_time;
179 uint32_t nd_opt_pi_preferred_time;
180 uint32_t nd_opt_pi_reserved2;
181 struct in6_addr nd_opt_pi_prefix;
182};
183
184#define ND_OPT_PI_FLAG_ONLINK 0x80
185#define ND_OPT_PI_FLAG_AUTO 0x40
186#define ND_OPT_PI_FLAG_RADDR 0x20
187
188struct nd_opt_rd_hdr {
189 uint8_t nd_opt_rh_type;
190 uint8_t nd_opt_rh_len;
191 uint16_t nd_opt_rh_reserved1;
192 uint32_t nd_opt_rh_reserved2;
193};
194
195struct nd_opt_mtu {
196 uint8_t nd_opt_mtu_type;
197 uint8_t nd_opt_mtu_len;
198 uint16_t nd_opt_mtu_reserved;
199 uint32_t nd_opt_mtu_mtu;
200};
201
202struct mld_hdr {
203 struct icmp6_hdr mld_icmp6_hdr;
204 struct in6_addr mld_addr;
205};
206
207#define mld_type mld_icmp6_hdr.icmp6_type
208#define mld_code mld_icmp6_hdr.icmp6_code
209#define mld_cksum mld_icmp6_hdr.icmp6_cksum
210#define mld_maxdelay mld_icmp6_hdr.icmp6_data16[0]
211#define mld_reserved mld_icmp6_hdr.icmp6_data16[1]
212
213#define ICMP6_ROUTER_RENUMBERING 138
214
215struct icmp6_router_renum {
216 struct icmp6_hdr rr_hdr;
217 uint8_t rr_segnum;
218 uint8_t rr_flags;
219 uint16_t rr_maxdelay;
220 uint32_t rr_reserved;
221};
222
223#define rr_type rr_hdr.icmp6_type
224#define rr_code rr_hdr.icmp6_code
225#define rr_cksum rr_hdr.icmp6_cksum
226#define rr_seqnum rr_hdr.icmp6_data32[0]
227
228#define ICMP6_RR_FLAGS_TEST 0x80
229#define ICMP6_RR_FLAGS_REQRESULT 0x40
230#define ICMP6_RR_FLAGS_FORCEAPPLY 0x20
231#define ICMP6_RR_FLAGS_SPECSITE 0x10
232#define ICMP6_RR_FLAGS_PREVDONE 0x08
233
234struct rr_pco_match {
235 uint8_t rpm_code;
236 uint8_t rpm_len;
237 uint8_t rpm_ordinal;
238 uint8_t rpm_matchlen;
239 uint8_t rpm_minlen;
240 uint8_t rpm_maxlen;
241 uint16_t rpm_reserved;
242 struct in6_addr rpm_prefix;
243};
244
245#define RPM_PCO_ADD 1
246#define RPM_PCO_CHANGE 2
247#define RPM_PCO_SETGLOBAL 3
248
249struct rr_pco_use {
250 uint8_t rpu_uselen;
251 uint8_t rpu_keeplen;
252 uint8_t rpu_ramask;
253 uint8_t rpu_raflags;
254 uint32_t rpu_vltime;
255 uint32_t rpu_pltime;
256 uint32_t rpu_flags;
257 struct in6_addr rpu_prefix;
258};
259
260#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x20
261#define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x10
262
263#if __BYTE_ORDER == __BIG_ENDIAN
264#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000
265#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000
266#else
267#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80
268#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40
269#endif
270
271struct rr_result {
272 uint16_t rrr_flags;
273 uint8_t rrr_ordinal;
274 uint8_t rrr_matchedlen;
275 uint32_t rrr_ifid;
276 struct in6_addr rrr_prefix;
277};
278
279#if __BYTE_ORDER == __BIG_ENDIAN
280#define ICMP6_RR_RESULT_FLAGS_OOB 0x0002
281#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001
282#else
283#define ICMP6_RR_RESULT_FLAGS_OOB 0x0200
284#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100
285#endif
286
287struct nd_opt_adv_interval {
288 uint8_t nd_opt_adv_interval_type;
289 uint8_t nd_opt_adv_interval_len;
290 uint16_t nd_opt_adv_interval_reserved;
291 uint32_t nd_opt_adv_interval_ival;
292};
293
294struct nd_opt_home_agent_info {
295 uint8_t nd_opt_home_agent_info_type;
296 uint8_t nd_opt_home_agent_info_len;
297 uint16_t nd_opt_home_agent_info_reserved;
298 uint16_t nd_opt_home_agent_info_preference;
299 uint16_t nd_opt_home_agent_info_lifetime;
300};
301
302#ifdef __cplusplus
303}
304#endif
305
306#endif
lib/libc/musl/include/netinet/if_ether.h created+145
......@@ -0,0 +1,145 @@
1#ifndef _NETINET_IF_ETHER_H
2#define _NETINET_IF_ETHER_H
3
4#include <stdint.h>
5#include <sys/types.h>
6
7#define ETH_ALEN 6
8#define ETH_TLEN 2
9#define ETH_HLEN 14
10#define ETH_ZLEN 60
11#define ETH_DATA_LEN 1500
12#define ETH_FRAME_LEN 1514
13#define ETH_FCS_LEN 4
14#define ETH_MIN_MTU 68
15#define ETH_MAX_MTU 0xFFFFU
16
17#define ETH_P_LOOP 0x0060
18#define ETH_P_PUP 0x0200
19#define ETH_P_PUPAT 0x0201
20#define ETH_P_TSN 0x22F0
21#define ETH_P_ERSPAN2 0x22EB
22#define ETH_P_IP 0x0800
23#define ETH_P_X25 0x0805
24#define ETH_P_ARP 0x0806
25#define ETH_P_BPQ 0x08FF
26#define ETH_P_IEEEPUP 0x0a00
27#define ETH_P_IEEEPUPAT 0x0a01
28#define ETH_P_BATMAN 0x4305
29#define ETH_P_DEC 0x6000
30#define ETH_P_DNA_DL 0x6001
31#define ETH_P_DNA_RC 0x6002
32#define ETH_P_DNA_RT 0x6003
33#define ETH_P_LAT 0x6004
34#define ETH_P_DIAG 0x6005
35#define ETH_P_CUST 0x6006
36#define ETH_P_SCA 0x6007
37#define ETH_P_TEB 0x6558
38#define ETH_P_RARP 0x8035
39#define ETH_P_ATALK 0x809B
40#define ETH_P_AARP 0x80F3
41#define ETH_P_8021Q 0x8100
42#define ETH_P_IPX 0x8137
43#define ETH_P_IPV6 0x86DD
44#define ETH_P_PAUSE 0x8808
45#define ETH_P_SLOW 0x8809
46#define ETH_P_WCCP 0x883E
47#define ETH_P_MPLS_UC 0x8847
48#define ETH_P_MPLS_MC 0x8848
49#define ETH_P_ATMMPOA 0x884c
50#define ETH_P_PPP_DISC 0x8863
51#define ETH_P_PPP_SES 0x8864
52#define ETH_P_LINK_CTL 0x886c
53#define ETH_P_ATMFATE 0x8884
54#define ETH_P_PAE 0x888E
55#define ETH_P_AOE 0x88A2
56#define ETH_P_8021AD 0x88A8
57#define ETH_P_802_EX1 0x88B5
58#define ETH_P_ERSPAN 0x88BE
59#define ETH_P_PREAUTH 0x88C7
60#define ETH_P_TIPC 0x88CA
61#define ETH_P_MACSEC 0x88E5
62#define ETH_P_8021AH 0x88E7
63#define ETH_P_MVRP 0x88F5
64#define ETH_P_1588 0x88F7
65#define ETH_P_NCSI 0x88F8
66#define ETH_P_PRP 0x88FB
67#define ETH_P_FCOE 0x8906
68#define ETH_P_TDLS 0x890D
69#define ETH_P_FIP 0x8914
70#define ETH_P_IBOE 0x8915
71#define ETH_P_80221 0x8917
72#define ETH_P_HSR 0x892F
73#define ETH_P_NSH 0x894F
74#define ETH_P_LOOPBACK 0x9000
75#define ETH_P_QINQ1 0x9100
76#define ETH_P_QINQ2 0x9200
77#define ETH_P_QINQ3 0x9300
78#define ETH_P_EDSA 0xDADA
79#define ETH_P_IFE 0xED3E
80#define ETH_P_AF_IUCV 0xFBFB
81
82#define ETH_P_802_3_MIN 0x0600
83
84#define ETH_P_802_3 0x0001
85#define ETH_P_AX25 0x0002
86#define ETH_P_ALL 0x0003
87#define ETH_P_802_2 0x0004
88#define ETH_P_SNAP 0x0005
89#define ETH_P_DDCMP 0x0006
90#define ETH_P_WAN_PPP 0x0007
91#define ETH_P_PPP_MP 0x0008
92#define ETH_P_LOCALTALK 0x0009
93#define ETH_P_CAN 0x000C
94#define ETH_P_CANFD 0x000D
95#define ETH_P_PPPTALK 0x0010
96#define ETH_P_TR_802_2 0x0011
97#define ETH_P_MOBITEX 0x0015
98#define ETH_P_CONTROL 0x0016
99#define ETH_P_IRDA 0x0017
100#define ETH_P_ECONET 0x0018
101#define ETH_P_HDLC 0x0019
102#define ETH_P_ARCNET 0x001A
103#define ETH_P_DSA 0x001B
104#define ETH_P_TRAILER 0x001C
105#define ETH_P_PHONET 0x00F5
106#define ETH_P_IEEE802154 0x00F6
107#define ETH_P_CAIF 0x00F7
108#define ETH_P_XDSA 0x00F8
109#define ETH_P_MAP 0x00F9
110
111struct ethhdr {
112 uint8_t h_dest[ETH_ALEN];
113 uint8_t h_source[ETH_ALEN];
114 uint16_t h_proto;
115};
116
117#include <net/ethernet.h>
118#include <net/if_arp.h>
119
120struct ether_arp {
121 struct arphdr ea_hdr;
122 uint8_t arp_sha[ETH_ALEN];
123 uint8_t arp_spa[4];
124 uint8_t arp_tha[ETH_ALEN];
125 uint8_t arp_tpa[4];
126};
127#define arp_hrd ea_hdr.ar_hrd
128#define arp_pro ea_hdr.ar_pro
129#define arp_hln ea_hdr.ar_hln
130#define arp_pln ea_hdr.ar_pln
131#define arp_op ea_hdr.ar_op
132
133#define ETHER_MAP_IP_MULTICAST(ipaddr, enaddr) \
134do { \
135 (enaddr)[0] = 0x01; \
136 (enaddr)[1] = 0x00; \
137 (enaddr)[2] = 0x5e; \
138 (enaddr)[3] = ((uint8_t *)ipaddr)[1] & 0x7f; \
139 (enaddr)[4] = ((uint8_t *)ipaddr)[2]; \
140 (enaddr)[5] = ((uint8_t *)ipaddr)[3]; \
141} while(0)
142
143#define __UAPI_DEF_ETHHDR 0
144
145#endif
lib/libc/musl/include/netinet/igmp.h created+45
......@@ -0,0 +1,45 @@
1#ifndef _NETINET_IGMP_H
2#define _NETINET_IGMP_H
3
4#include <stdint.h>
5#include <netinet/in.h>
6
7struct igmp {
8 uint8_t igmp_type;
9 uint8_t igmp_code;
10 uint16_t igmp_cksum;
11 struct in_addr igmp_group;
12};
13
14#define IGMP_MINLEN 8
15
16#define IGMP_MEMBERSHIP_QUERY 0x11
17#define IGMP_V1_MEMBERSHIP_REPORT 0x12
18#define IGMP_V2_MEMBERSHIP_REPORT 0x16
19#define IGMP_V2_LEAVE_GROUP 0x17
20
21#define IGMP_DVMRP 0x13
22#define IGMP_PIM 0x14
23#define IGMP_TRACE 0x15
24
25#define IGMP_MTRACE_RESP 0x1e
26#define IGMP_MTRACE 0x1f
27
28#define IGMP_MAX_HOST_REPORT_DELAY 10
29#define IGMP_TIMER_SCALE 10
30
31#define IGMP_DELAYING_MEMBER 1
32#define IGMP_IDLE_MEMBER 2
33#define IGMP_LAZY_MEMBER 3
34#define IGMP_SLEEPING_MEMBER 4
35#define IGMP_AWAKENING_MEMBER 5
36
37#define IGMP_v1_ROUTER 1
38#define IGMP_v2_ROUTER 2
39
40#define IGMP_HOST_MEMBERSHIP_QUERY IGMP_MEMBERSHIP_QUERY
41#define IGMP_HOST_MEMBERSHIP_REPORT IGMP_V1_MEMBERSHIP_REPORT
42#define IGMP_HOST_NEW_MEMBERSHIP_REPORT IGMP_V2_MEMBERSHIP_REPORT
43#define IGMP_HOST_LEAVE_MESSAGE IGMP_V2_LEAVE_GROUP
44
45#endif
lib/libc/musl/include/netinet/in.h created+415
......@@ -0,0 +1,415 @@
1#ifndef _NETINET_IN_H
2#define _NETINET_IN_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9#include <inttypes.h>
10#include <sys/socket.h>
11
12typedef uint16_t in_port_t;
13typedef uint32_t in_addr_t;
14struct in_addr { in_addr_t s_addr; };
15
16struct sockaddr_in {
17 sa_family_t sin_family;
18 in_port_t sin_port;
19 struct in_addr sin_addr;
20 uint8_t sin_zero[8];
21};
22
23struct in6_addr {
24 union {
25 uint8_t __s6_addr[16];
26 uint16_t __s6_addr16[8];
27 uint32_t __s6_addr32[4];
28 } __in6_union;
29};
30#define s6_addr __in6_union.__s6_addr
31#define s6_addr16 __in6_union.__s6_addr16
32#define s6_addr32 __in6_union.__s6_addr32
33
34struct sockaddr_in6 {
35 sa_family_t sin6_family;
36 in_port_t sin6_port;
37 uint32_t sin6_flowinfo;
38 struct in6_addr sin6_addr;
39 uint32_t sin6_scope_id;
40};
41
42struct ipv6_mreq {
43 struct in6_addr ipv6mr_multiaddr;
44 unsigned ipv6mr_interface;
45};
46
47#define INADDR_ANY ((in_addr_t) 0x00000000)
48#define INADDR_BROADCAST ((in_addr_t) 0xffffffff)
49#define INADDR_NONE ((in_addr_t) 0xffffffff)
50#define INADDR_LOOPBACK ((in_addr_t) 0x7f000001)
51
52#define INADDR_UNSPEC_GROUP ((in_addr_t) 0xe0000000)
53#define INADDR_ALLHOSTS_GROUP ((in_addr_t) 0xe0000001)
54#define INADDR_ALLRTRS_GROUP ((in_addr_t) 0xe0000002)
55#define INADDR_ALLSNOOPERS_GROUP ((in_addr_t) 0xe000006a)
56#define INADDR_MAX_LOCAL_GROUP ((in_addr_t) 0xe00000ff)
57
58#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
59#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
60
61extern const struct in6_addr in6addr_any, in6addr_loopback;
62
63#undef INET_ADDRSTRLEN
64#undef INET6_ADDRSTRLEN
65#define INET_ADDRSTRLEN 16
66#define INET6_ADDRSTRLEN 46
67
68uint32_t htonl(uint32_t);
69uint16_t htons(uint16_t);
70uint32_t ntohl(uint32_t);
71uint16_t ntohs(uint16_t);
72
73#define IPPORT_RESERVED 1024
74
75#define IPPROTO_IP 0
76#define IPPROTO_HOPOPTS 0
77#define IPPROTO_ICMP 1
78#define IPPROTO_IGMP 2
79#define IPPROTO_IPIP 4
80#define IPPROTO_TCP 6
81#define IPPROTO_EGP 8
82#define IPPROTO_PUP 12
83#define IPPROTO_UDP 17
84#define IPPROTO_IDP 22
85#define IPPROTO_TP 29
86#define IPPROTO_DCCP 33
87#define IPPROTO_IPV6 41
88#define IPPROTO_ROUTING 43
89#define IPPROTO_FRAGMENT 44
90#define IPPROTO_RSVP 46
91#define IPPROTO_GRE 47
92#define IPPROTO_ESP 50
93#define IPPROTO_AH 51
94#define IPPROTO_ICMPV6 58
95#define IPPROTO_NONE 59
96#define IPPROTO_DSTOPTS 60
97#define IPPROTO_MTP 92
98#define IPPROTO_BEETPH 94
99#define IPPROTO_ENCAP 98
100#define IPPROTO_PIM 103
101#define IPPROTO_COMP 108
102#define IPPROTO_SCTP 132
103#define IPPROTO_MH 135
104#define IPPROTO_UDPLITE 136
105#define IPPROTO_MPLS 137
106#define IPPROTO_RAW 255
107#define IPPROTO_MAX 256
108
109#define IN6_IS_ADDR_UNSPECIFIED(a) \
110 (((uint32_t *) (a))[0] == 0 && ((uint32_t *) (a))[1] == 0 && \
111 ((uint32_t *) (a))[2] == 0 && ((uint32_t *) (a))[3] == 0)
112
113#define IN6_IS_ADDR_LOOPBACK(a) \
114 (((uint32_t *) (a))[0] == 0 && ((uint32_t *) (a))[1] == 0 && \
115 ((uint32_t *) (a))[2] == 0 && \
116 ((uint8_t *) (a))[12] == 0 && ((uint8_t *) (a))[13] == 0 && \
117 ((uint8_t *) (a))[14] == 0 && ((uint8_t *) (a))[15] == 1 )
118
119#define IN6_IS_ADDR_MULTICAST(a) (((uint8_t *) (a))[0] == 0xff)
120
121#define IN6_IS_ADDR_LINKLOCAL(a) \
122 ((((uint8_t *) (a))[0]) == 0xfe && (((uint8_t *) (a))[1] & 0xc0) == 0x80)
123
124#define IN6_IS_ADDR_SITELOCAL(a) \
125 ((((uint8_t *) (a))[0]) == 0xfe && (((uint8_t *) (a))[1] & 0xc0) == 0xc0)
126
127#define IN6_IS_ADDR_V4MAPPED(a) \
128 (((uint32_t *) (a))[0] == 0 && ((uint32_t *) (a))[1] == 0 && \
129 ((uint8_t *) (a))[8] == 0 && ((uint8_t *) (a))[9] == 0 && \
130 ((uint8_t *) (a))[10] == 0xff && ((uint8_t *) (a))[11] == 0xff)
131
132#define IN6_IS_ADDR_V4COMPAT(a) \
133 (((uint32_t *) (a))[0] == 0 && ((uint32_t *) (a))[1] == 0 && \
134 ((uint32_t *) (a))[2] == 0 && ((uint8_t *) (a))[15] > 1)
135
136#define IN6_IS_ADDR_MC_NODELOCAL(a) \
137 (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *) (a))[1] & 0xf) == 0x1))
138
139#define IN6_IS_ADDR_MC_LINKLOCAL(a) \
140 (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *) (a))[1] & 0xf) == 0x2))
141
142#define IN6_IS_ADDR_MC_SITELOCAL(a) \
143 (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *) (a))[1] & 0xf) == 0x5))
144
145#define IN6_IS_ADDR_MC_ORGLOCAL(a) \
146 (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *) (a))[1] & 0xf) == 0x8))
147
148#define IN6_IS_ADDR_MC_GLOBAL(a) \
149 (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *) (a))[1] & 0xf) == 0xe))
150
151#define __ARE_4_EQUAL(a,b) \
152 (!( (0[a]-0[b]) | (1[a]-1[b]) | (2[a]-2[b]) | (3[a]-3[b]) ))
153#define IN6_ARE_ADDR_EQUAL(a,b) \
154 __ARE_4_EQUAL((const uint32_t *)(a), (const uint32_t *)(b))
155
156#define IN_CLASSA(a) ((((in_addr_t)(a)) & 0x80000000) == 0)
157#define IN_CLASSA_NET 0xff000000
158#define IN_CLASSA_NSHIFT 24
159#define IN_CLASSA_HOST (0xffffffff & ~IN_CLASSA_NET)
160#define IN_CLASSA_MAX 128
161#define IN_CLASSB(a) ((((in_addr_t)(a)) & 0xc0000000) == 0x80000000)
162#define IN_CLASSB_NET 0xffff0000
163#define IN_CLASSB_NSHIFT 16
164#define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET)
165#define IN_CLASSB_MAX 65536
166#define IN_CLASSC(a) ((((in_addr_t)(a)) & 0xe0000000) == 0xc0000000)
167#define IN_CLASSC_NET 0xffffff00
168#define IN_CLASSC_NSHIFT 8
169#define IN_CLASSC_HOST (0xffffffff & ~IN_CLASSC_NET)
170#define IN_CLASSD(a) ((((in_addr_t)(a)) & 0xf0000000) == 0xe0000000)
171#define IN_MULTICAST(a) IN_CLASSD(a)
172#define IN_EXPERIMENTAL(a) ((((in_addr_t)(a)) & 0xe0000000) == 0xe0000000)
173#define IN_BADCLASS(a) ((((in_addr_t)(a)) & 0xf0000000) == 0xf0000000)
174
175#define IN_LOOPBACKNET 127
176
177
178#define IP_TOS 1
179#define IP_TTL 2
180#define IP_HDRINCL 3
181#define IP_OPTIONS 4
182#define IP_ROUTER_ALERT 5
183#define IP_RECVOPTS 6
184#define IP_RETOPTS 7
185#define IP_PKTINFO 8
186#define IP_PKTOPTIONS 9
187#define IP_PMTUDISC 10
188#define IP_MTU_DISCOVER 10
189#define IP_RECVERR 11
190#define IP_RECVTTL 12
191#define IP_RECVTOS 13
192#define IP_MTU 14
193#define IP_FREEBIND 15
194#define IP_IPSEC_POLICY 16
195#define IP_XFRM_POLICY 17
196#define IP_PASSSEC 18
197#define IP_TRANSPARENT 19
198#define IP_ORIGDSTADDR 20
199#define IP_RECVORIGDSTADDR IP_ORIGDSTADDR
200#define IP_MINTTL 21
201#define IP_NODEFRAG 22
202#define IP_CHECKSUM 23
203#define IP_BIND_ADDRESS_NO_PORT 24
204#define IP_RECVFRAGSIZE 25
205#define IP_MULTICAST_IF 32
206#define IP_MULTICAST_TTL 33
207#define IP_MULTICAST_LOOP 34
208#define IP_ADD_MEMBERSHIP 35
209#define IP_DROP_MEMBERSHIP 36
210#define IP_UNBLOCK_SOURCE 37
211#define IP_BLOCK_SOURCE 38
212#define IP_ADD_SOURCE_MEMBERSHIP 39
213#define IP_DROP_SOURCE_MEMBERSHIP 40
214#define IP_MSFILTER 41
215#define IP_MULTICAST_ALL 49
216#define IP_UNICAST_IF 50
217
218#define IP_RECVRETOPTS IP_RETOPTS
219
220#define IP_PMTUDISC_DONT 0
221#define IP_PMTUDISC_WANT 1
222#define IP_PMTUDISC_DO 2
223#define IP_PMTUDISC_PROBE 3
224#define IP_PMTUDISC_INTERFACE 4
225#define IP_PMTUDISC_OMIT 5
226
227#define IP_DEFAULT_MULTICAST_TTL 1
228#define IP_DEFAULT_MULTICAST_LOOP 1
229#define IP_MAX_MEMBERSHIPS 20
230
231struct ip_opts {
232 struct in_addr ip_dst;
233 char ip_opts[40];
234};
235
236#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
237
238#define MCAST_JOIN_GROUP 42
239#define MCAST_BLOCK_SOURCE 43
240#define MCAST_UNBLOCK_SOURCE 44
241#define MCAST_LEAVE_GROUP 45
242#define MCAST_JOIN_SOURCE_GROUP 46
243#define MCAST_LEAVE_SOURCE_GROUP 47
244#define MCAST_MSFILTER 48
245
246#define MCAST_EXCLUDE 0
247#define MCAST_INCLUDE 1
248
249struct ip_mreq {
250 struct in_addr imr_multiaddr;
251 struct in_addr imr_interface;
252};
253
254struct ip_mreqn {
255 struct in_addr imr_multiaddr;
256 struct in_addr imr_address;
257 int imr_ifindex;
258};
259
260struct ip_mreq_source {
261 struct in_addr imr_multiaddr;
262 struct in_addr imr_interface;
263 struct in_addr imr_sourceaddr;
264};
265
266struct ip_msfilter {
267 struct in_addr imsf_multiaddr;
268 struct in_addr imsf_interface;
269 uint32_t imsf_fmode;
270 uint32_t imsf_numsrc;
271 struct in_addr imsf_slist[1];
272};
273#define IP_MSFILTER_SIZE(numsrc) \
274 (sizeof(struct ip_msfilter) - sizeof(struct in_addr) \
275 + (numsrc) * sizeof(struct in_addr))
276
277struct group_req {
278 uint32_t gr_interface;
279 struct sockaddr_storage gr_group;
280};
281
282struct group_source_req {
283 uint32_t gsr_interface;
284 struct sockaddr_storage gsr_group;
285 struct sockaddr_storage gsr_source;
286};
287
288struct group_filter {
289 uint32_t gf_interface;
290 struct sockaddr_storage gf_group;
291 uint32_t gf_fmode;
292 uint32_t gf_numsrc;
293 struct sockaddr_storage gf_slist[1];
294};
295#define GROUP_FILTER_SIZE(numsrc) \
296 (sizeof(struct group_filter) - sizeof(struct sockaddr_storage) \
297 + (numsrc) * sizeof(struct sockaddr_storage))
298
299struct in_pktinfo {
300 int ipi_ifindex;
301 struct in_addr ipi_spec_dst;
302 struct in_addr ipi_addr;
303};
304
305struct in6_pktinfo {
306 struct in6_addr ipi6_addr;
307 unsigned ipi6_ifindex;
308};
309
310struct ip6_mtuinfo {
311 struct sockaddr_in6 ip6m_addr;
312 uint32_t ip6m_mtu;
313};
314#endif
315
316#define IPV6_ADDRFORM 1
317#define IPV6_2292PKTINFO 2
318#define IPV6_2292HOPOPTS 3
319#define IPV6_2292DSTOPTS 4
320#define IPV6_2292RTHDR 5
321#define IPV6_2292PKTOPTIONS 6
322#define IPV6_CHECKSUM 7
323#define IPV6_2292HOPLIMIT 8
324#define IPV6_NEXTHOP 9
325#define IPV6_AUTHHDR 10
326#define IPV6_UNICAST_HOPS 16
327#define IPV6_MULTICAST_IF 17
328#define IPV6_MULTICAST_HOPS 18
329#define IPV6_MULTICAST_LOOP 19
330#define IPV6_JOIN_GROUP 20
331#define IPV6_LEAVE_GROUP 21
332#define IPV6_ROUTER_ALERT 22
333#define IPV6_MTU_DISCOVER 23
334#define IPV6_MTU 24
335#define IPV6_RECVERR 25
336#define IPV6_V6ONLY 26
337#define IPV6_JOIN_ANYCAST 27
338#define IPV6_LEAVE_ANYCAST 28
339#define IPV6_MULTICAST_ALL 29
340#define IPV6_ROUTER_ALERT_ISOLATE 30
341#define IPV6_IPSEC_POLICY 34
342#define IPV6_XFRM_POLICY 35
343#define IPV6_HDRINCL 36
344
345#define IPV6_RECVPKTINFO 49
346#define IPV6_PKTINFO 50
347#define IPV6_RECVHOPLIMIT 51
348#define IPV6_HOPLIMIT 52
349#define IPV6_RECVHOPOPTS 53
350#define IPV6_HOPOPTS 54
351#define IPV6_RTHDRDSTOPTS 55
352#define IPV6_RECVRTHDR 56
353#define IPV6_RTHDR 57
354#define IPV6_RECVDSTOPTS 58
355#define IPV6_DSTOPTS 59
356#define IPV6_RECVPATHMTU 60
357#define IPV6_PATHMTU 61
358#define IPV6_DONTFRAG 62
359#define IPV6_RECVTCLASS 66
360#define IPV6_TCLASS 67
361#define IPV6_AUTOFLOWLABEL 70
362#define IPV6_ADDR_PREFERENCES 72
363#define IPV6_MINHOPCOUNT 73
364#define IPV6_ORIGDSTADDR 74
365#define IPV6_RECVORIGDSTADDR IPV6_ORIGDSTADDR
366#define IPV6_TRANSPARENT 75
367#define IPV6_UNICAST_IF 76
368#define IPV6_RECVFRAGSIZE 77
369#define IPV6_FREEBIND 78
370
371#define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
372#define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP
373#define IPV6_RXHOPOPTS IPV6_HOPOPTS
374#define IPV6_RXDSTOPTS IPV6_DSTOPTS
375
376#define IPV6_PMTUDISC_DONT 0
377#define IPV6_PMTUDISC_WANT 1
378#define IPV6_PMTUDISC_DO 2
379#define IPV6_PMTUDISC_PROBE 3
380#define IPV6_PMTUDISC_INTERFACE 4
381#define IPV6_PMTUDISC_OMIT 5
382
383#define IPV6_PREFER_SRC_TMP 0x0001
384#define IPV6_PREFER_SRC_PUBLIC 0x0002
385#define IPV6_PREFER_SRC_PUBTMP_DEFAULT 0x0100
386#define IPV6_PREFER_SRC_COA 0x0004
387#define IPV6_PREFER_SRC_HOME 0x0400
388#define IPV6_PREFER_SRC_CGA 0x0008
389#define IPV6_PREFER_SRC_NONCGA 0x0800
390
391#define IPV6_RTHDR_LOOSE 0
392#define IPV6_RTHDR_STRICT 1
393
394#define IPV6_RTHDR_TYPE_0 0
395
396#define __UAPI_DEF_IN_ADDR 0
397#define __UAPI_DEF_IN_IPPROTO 0
398#define __UAPI_DEF_IN_PKTINFO 0
399#define __UAPI_DEF_IP_MREQ 0
400#define __UAPI_DEF_SOCKADDR_IN 0
401#define __UAPI_DEF_IN_CLASS 0
402#define __UAPI_DEF_IN6_ADDR 0
403#define __UAPI_DEF_IN6_ADDR_ALT 0
404#define __UAPI_DEF_SOCKADDR_IN6 0
405#define __UAPI_DEF_IPV6_MREQ 0
406#define __UAPI_DEF_IPPROTO_V6 0
407#define __UAPI_DEF_IPV6_OPTIONS 0
408#define __UAPI_DEF_IN6_PKTINFO 0
409#define __UAPI_DEF_IP6_MTUINFO 0
410
411#ifdef __cplusplus
412}
413#endif
414
415#endif
lib/libc/musl/include/netinet/in_systm.h created+9
......@@ -0,0 +1,9 @@
1#ifndef _NETINET_IN_SYSTM_H
2#define _NETINET_IN_SYSTM_H
3
4#include <stdint.h>
5
6typedef uint16_t n_short;
7typedef uint32_t n_long, n_time;
8
9#endif
lib/libc/musl/include/netinet/ip.h created+198
......@@ -0,0 +1,198 @@
1#ifndef _NETINET_IP_H
2#define _NETINET_IP_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stdint.h>
9#include <netinet/in.h>
10#include <endian.h>
11
12struct timestamp {
13 uint8_t len;
14 uint8_t ptr;
15#if __BYTE_ORDER == __LITTLE_ENDIAN
16 unsigned int flags:4;
17 unsigned int overflow:4;
18#else
19 unsigned int overflow:4;
20 unsigned int flags:4;
21#endif
22 uint32_t data[9];
23 };
24
25struct iphdr {
26#if __BYTE_ORDER == __LITTLE_ENDIAN
27 unsigned int ihl:4;
28 unsigned int version:4;
29#else
30 unsigned int version:4;
31 unsigned int ihl:4;
32#endif
33 uint8_t tos;
34 uint16_t tot_len;
35 uint16_t id;
36 uint16_t frag_off;
37 uint8_t ttl;
38 uint8_t protocol;
39 uint16_t check;
40 uint32_t saddr;
41 uint32_t daddr;
42};
43
44struct ip {
45#if __BYTE_ORDER == __LITTLE_ENDIAN
46 unsigned int ip_hl:4;
47 unsigned int ip_v:4;
48#else
49 unsigned int ip_v:4;
50 unsigned int ip_hl:4;
51#endif
52 uint8_t ip_tos;
53 uint16_t ip_len;
54 uint16_t ip_id;
55 uint16_t ip_off;
56 uint8_t ip_ttl;
57 uint8_t ip_p;
58 uint16_t ip_sum;
59 struct in_addr ip_src, ip_dst;
60};
61
62#define IP_RF 0x8000
63#define IP_DF 0x4000
64#define IP_MF 0x2000
65#define IP_OFFMASK 0x1fff
66
67struct ip_timestamp {
68 uint8_t ipt_code;
69 uint8_t ipt_len;
70 uint8_t ipt_ptr;
71#if __BYTE_ORDER == __LITTLE_ENDIAN
72 unsigned int ipt_flg:4;
73 unsigned int ipt_oflw:4;
74#else
75 unsigned int ipt_oflw:4;
76 unsigned int ipt_flg:4;
77#endif
78 uint32_t data[9];
79};
80
81#define IPVERSION 4
82#define IP_MAXPACKET 65535
83
84#define IPTOS_ECN_MASK 0x03
85#define IPTOS_ECN(x) ((x) & IPTOS_ECN_MASK)
86#define IPTOS_ECN_NOT_ECT 0x00
87#define IPTOS_ECN_ECT1 0x01
88#define IPTOS_ECN_ECT0 0x02
89#define IPTOS_ECN_CE 0x03
90
91#define IPTOS_DSCP_MASK 0xfc
92#define IPTOS_DSCP(x) ((x) & IPTOS_DSCP_MASK)
93#define IPTOS_DSCP_AF11 0x28
94#define IPTOS_DSCP_AF12 0x30
95#define IPTOS_DSCP_AF13 0x38
96#define IPTOS_DSCP_AF21 0x48
97#define IPTOS_DSCP_AF22 0x50
98#define IPTOS_DSCP_AF23 0x58
99#define IPTOS_DSCP_AF31 0x68
100#define IPTOS_DSCP_AF32 0x70
101#define IPTOS_DSCP_AF33 0x78
102#define IPTOS_DSCP_AF41 0x88
103#define IPTOS_DSCP_AF42 0x90
104#define IPTOS_DSCP_AF43 0x98
105#define IPTOS_DSCP_EF 0xb8
106
107#define IPTOS_CLASS_MASK 0xe0
108#define IPTOS_CLASS(x) ((x) & IPTOS_CLASS_MASK)
109#define IPTOS_CLASS_CS0 0x00
110#define IPTOS_CLASS_CS1 0x20
111#define IPTOS_CLASS_CS2 0x40
112#define IPTOS_CLASS_CS3 0x60
113#define IPTOS_CLASS_CS4 0x80
114#define IPTOS_CLASS_CS5 0xa0
115#define IPTOS_CLASS_CS6 0xc0
116#define IPTOS_CLASS_CS7 0xe0
117#define IPTOS_CLASS_DEFAULT IPTOS_CLASS_CS0
118
119#define IPTOS_TOS_MASK 0x1E
120#define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK)
121#define IPTOS_LOWDELAY 0x10
122#define IPTOS_THROUGHPUT 0x08
123#define IPTOS_RELIABILITY 0x04
124#define IPTOS_LOWCOST 0x02
125#define IPTOS_MINCOST IPTOS_LOWCOST
126
127#define IPTOS_PREC_MASK 0xe0
128#define IPTOS_PREC(tos) ((tos) & IPTOS_PREC_MASK)
129#define IPTOS_PREC_NETCONTROL 0xe0
130#define IPTOS_PREC_INTERNETCONTROL 0xc0
131#define IPTOS_PREC_CRITIC_ECP 0xa0
132#define IPTOS_PREC_FLASHOVERRIDE 0x80
133#define IPTOS_PREC_FLASH 0x60
134#define IPTOS_PREC_IMMEDIATE 0x40
135#define IPTOS_PREC_PRIORITY 0x20
136#define IPTOS_PREC_ROUTINE 0x00
137
138#define IPOPT_COPY 0x80
139#define IPOPT_CLASS_MASK 0x60
140#define IPOPT_NUMBER_MASK 0x1f
141
142#define IPOPT_COPIED(o) ((o) & IPOPT_COPY)
143#define IPOPT_CLASS(o) ((o) & IPOPT_CLASS_MASK)
144#define IPOPT_NUMBER(o) ((o) & IPOPT_NUMBER_MASK)
145
146#define IPOPT_CONTROL 0x00
147#define IPOPT_RESERVED1 0x20
148#define IPOPT_DEBMEAS 0x40
149#define IPOPT_MEASUREMENT IPOPT_DEBMEAS
150#define IPOPT_RESERVED2 0x60
151
152#define IPOPT_EOL 0
153#define IPOPT_END IPOPT_EOL
154#define IPOPT_NOP 1
155#define IPOPT_NOOP IPOPT_NOP
156
157#define IPOPT_RR 7
158#define IPOPT_TS 68
159#define IPOPT_TIMESTAMP IPOPT_TS
160#define IPOPT_SECURITY 130
161#define IPOPT_SEC IPOPT_SECURITY
162#define IPOPT_LSRR 131
163#define IPOPT_SATID 136
164#define IPOPT_SID IPOPT_SATID
165#define IPOPT_SSRR 137
166#define IPOPT_RA 148
167
168#define IPOPT_OPTVAL 0
169#define IPOPT_OLEN 1
170#define IPOPT_OFFSET 2
171#define IPOPT_MINOFF 4
172
173#define MAX_IPOPTLEN 40
174
175#define IPOPT_TS_TSONLY 0
176#define IPOPT_TS_TSANDADDR 1
177#define IPOPT_TS_PRESPEC 3
178
179#define IPOPT_SECUR_UNCLASS 0x0000
180#define IPOPT_SECUR_CONFID 0xf135
181#define IPOPT_SECUR_EFTO 0x789a
182#define IPOPT_SECUR_MMMM 0xbc4d
183#define IPOPT_SECUR_RESTR 0xaf13
184#define IPOPT_SECUR_SECRET 0xd788
185#define IPOPT_SECUR_TOPSECRET 0x6bc5
186
187#define MAXTTL 255
188#define IPDEFTTL 64
189#define IPFRAGTTL 60
190#define IPTTLDEC 1
191
192#define IP_MSS 576
193
194#ifdef __cplusplus
195}
196#endif
197
198#endif
lib/libc/musl/include/netinet/ip6.h created+142
......@@ -0,0 +1,142 @@
1#ifndef _NETINET_IP6_H
2#define _NETINET_IP6_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stdint.h>
9#include <netinet/in.h>
10#include <endian.h>
11
12struct ip6_hdr {
13 union {
14 struct ip6_hdrctl {
15 uint32_t ip6_un1_flow;
16 uint16_t ip6_un1_plen;
17 uint8_t ip6_un1_nxt;
18 uint8_t ip6_un1_hlim;
19 } ip6_un1;
20 uint8_t ip6_un2_vfc;
21 } ip6_ctlun;
22 struct in6_addr ip6_src;
23 struct in6_addr ip6_dst;
24};
25
26#define ip6_vfc ip6_ctlun.ip6_un2_vfc
27#define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow
28#define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen
29#define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt
30#define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim
31#define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim
32
33struct ip6_ext {
34 uint8_t ip6e_nxt;
35 uint8_t ip6e_len;
36};
37
38struct ip6_hbh {
39 uint8_t ip6h_nxt;
40 uint8_t ip6h_len;
41};
42
43struct ip6_dest {
44 uint8_t ip6d_nxt;
45 uint8_t ip6d_len;
46};
47
48struct ip6_rthdr {
49 uint8_t ip6r_nxt;
50 uint8_t ip6r_len;
51 uint8_t ip6r_type;
52 uint8_t ip6r_segleft;
53};
54
55struct ip6_rthdr0 {
56 uint8_t ip6r0_nxt;
57 uint8_t ip6r0_len;
58 uint8_t ip6r0_type;
59 uint8_t ip6r0_segleft;
60 uint8_t ip6r0_reserved;
61 uint8_t ip6r0_slmap[3];
62 struct in6_addr ip6r0_addr[];
63};
64
65struct ip6_frag {
66 uint8_t ip6f_nxt;
67 uint8_t ip6f_reserved;
68 uint16_t ip6f_offlg;
69 uint32_t ip6f_ident;
70};
71
72#if __BYTE_ORDER == __BIG_ENDIAN
73#define IP6F_OFF_MASK 0xfff8
74#define IP6F_RESERVED_MASK 0x0006
75#define IP6F_MORE_FRAG 0x0001
76#else
77#define IP6F_OFF_MASK 0xf8ff
78#define IP6F_RESERVED_MASK 0x0600
79#define IP6F_MORE_FRAG 0x0100
80#endif
81
82struct ip6_opt {
83 uint8_t ip6o_type;
84 uint8_t ip6o_len;
85};
86
87#define IP6OPT_TYPE(o) ((o) & 0xc0)
88#define IP6OPT_TYPE_SKIP 0x00
89#define IP6OPT_TYPE_DISCARD 0x40
90#define IP6OPT_TYPE_FORCEICMP 0x80
91#define IP6OPT_TYPE_ICMP 0xc0
92#define IP6OPT_TYPE_MUTABLE 0x20
93
94#define IP6OPT_PAD1 0
95#define IP6OPT_PADN 1
96
97#define IP6OPT_JUMBO 0xc2
98#define IP6OPT_NSAP_ADDR 0xc3
99#define IP6OPT_TUNNEL_LIMIT 0x04
100#define IP6OPT_ROUTER_ALERT 0x05
101
102struct ip6_opt_jumbo {
103 uint8_t ip6oj_type;
104 uint8_t ip6oj_len;
105 uint8_t ip6oj_jumbo_len[4];
106};
107#define IP6OPT_JUMBO_LEN 6
108
109struct ip6_opt_nsap {
110 uint8_t ip6on_type;
111 uint8_t ip6on_len;
112 uint8_t ip6on_src_nsap_len;
113 uint8_t ip6on_dst_nsap_len;
114};
115
116struct ip6_opt_tunnel {
117 uint8_t ip6ot_type;
118 uint8_t ip6ot_len;
119 uint8_t ip6ot_encap_limit;
120};
121
122struct ip6_opt_router {
123 uint8_t ip6or_type;
124 uint8_t ip6or_len;
125 uint8_t ip6or_value[2];
126};
127
128#if __BYTE_ORDER == __BIG_ENDIAN
129#define IP6_ALERT_MLD 0x0000
130#define IP6_ALERT_RSVP 0x0001
131#define IP6_ALERT_AN 0x0002
132#else
133#define IP6_ALERT_MLD 0x0000
134#define IP6_ALERT_RSVP 0x0100
135#define IP6_ALERT_AN 0x0200
136#endif
137
138#ifdef __cplusplus
139}
140#endif
141
142#endif
lib/libc/musl/include/netinet/ip_icmp.h created+193
......@@ -0,0 +1,193 @@
1#ifndef _NETINET_IP_ICMP_H
2#define _NETINET_IP_ICMP_H
3
4#include <stdint.h>
5#include <netinet/in.h>
6#include <netinet/ip.h>
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12struct icmphdr {
13 uint8_t type;
14 uint8_t code;
15 uint16_t checksum;
16 union {
17 struct {
18 uint16_t id;
19 uint16_t sequence;
20 } echo;
21 uint32_t gateway;
22 struct {
23 uint16_t __unused;
24 uint16_t mtu;
25 } frag;
26 uint8_t reserved[4];
27 } un;
28};
29
30#define ICMP_ECHOREPLY 0
31#define ICMP_DEST_UNREACH 3
32#define ICMP_SOURCE_QUENCH 4
33#define ICMP_REDIRECT 5
34#define ICMP_ECHO 8
35#define ICMP_TIME_EXCEEDED 11
36#define ICMP_PARAMETERPROB 12
37#define ICMP_TIMESTAMP 13
38#define ICMP_TIMESTAMPREPLY 14
39#define ICMP_INFO_REQUEST 15
40#define ICMP_INFO_REPLY 16
41#define ICMP_ADDRESS 17
42#define ICMP_ADDRESSREPLY 18
43#define NR_ICMP_TYPES 18
44
45
46#define ICMP_NET_UNREACH 0
47#define ICMP_HOST_UNREACH 1
48#define ICMP_PROT_UNREACH 2
49#define ICMP_PORT_UNREACH 3
50#define ICMP_FRAG_NEEDED 4
51#define ICMP_SR_FAILED 5
52#define ICMP_NET_UNKNOWN 6
53#define ICMP_HOST_UNKNOWN 7
54#define ICMP_HOST_ISOLATED 8
55#define ICMP_NET_ANO 9
56#define ICMP_HOST_ANO 10
57#define ICMP_NET_UNR_TOS 11
58#define ICMP_HOST_UNR_TOS 12
59#define ICMP_PKT_FILTERED 13
60#define ICMP_PREC_VIOLATION 14
61#define ICMP_PREC_CUTOFF 15
62#define NR_ICMP_UNREACH 15
63
64#define ICMP_REDIR_NET 0
65#define ICMP_REDIR_HOST 1
66#define ICMP_REDIR_NETTOS 2
67#define ICMP_REDIR_HOSTTOS 3
68
69#define ICMP_EXC_TTL 0
70#define ICMP_EXC_FRAGTIME 1
71
72
73struct icmp_ra_addr {
74 uint32_t ira_addr;
75 uint32_t ira_preference;
76};
77
78struct icmp {
79 uint8_t icmp_type;
80 uint8_t icmp_code;
81 uint16_t icmp_cksum;
82 union {
83 uint8_t ih_pptr;
84 struct in_addr ih_gwaddr;
85 struct ih_idseq {
86 uint16_t icd_id;
87 uint16_t icd_seq;
88 } ih_idseq;
89 uint32_t ih_void;
90
91 struct ih_pmtu {
92 uint16_t ipm_void;
93 uint16_t ipm_nextmtu;
94 } ih_pmtu;
95
96 struct ih_rtradv {
97 uint8_t irt_num_addrs;
98 uint8_t irt_wpa;
99 uint16_t irt_lifetime;
100 } ih_rtradv;
101 } icmp_hun;
102 union {
103 struct {
104 uint32_t its_otime;
105 uint32_t its_rtime;
106 uint32_t its_ttime;
107 } id_ts;
108 struct {
109 struct ip idi_ip;
110 } id_ip;
111 struct icmp_ra_addr id_radv;
112 uint32_t id_mask;
113 uint8_t id_data[1];
114 } icmp_dun;
115};
116
117#define icmp_pptr icmp_hun.ih_pptr
118#define icmp_gwaddr icmp_hun.ih_gwaddr
119#define icmp_id icmp_hun.ih_idseq.icd_id
120#define icmp_seq icmp_hun.ih_idseq.icd_seq
121#define icmp_void icmp_hun.ih_void
122#define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void
123#define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu
124#define icmp_num_addrs icmp_hun.ih_rtradv.irt_num_addrs
125#define icmp_wpa icmp_hun.ih_rtradv.irt_wpa
126#define icmp_lifetime icmp_hun.ih_rtradv.irt_lifetime
127#define icmp_otime icmp_dun.id_ts.its_otime
128#define icmp_rtime icmp_dun.id_ts.its_rtime
129#define icmp_ttime icmp_dun.id_ts.its_ttime
130#define icmp_ip icmp_dun.id_ip.idi_ip
131#define icmp_radv icmp_dun.id_radv
132#define icmp_mask icmp_dun.id_mask
133#define icmp_data icmp_dun.id_data
134
135#define ICMP_MINLEN 8
136#define ICMP_TSLEN (8 + 3 * sizeof (n_time))
137#define ICMP_MASKLEN 12
138#define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8)
139#define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8)
140
141#define ICMP_UNREACH 3
142#define ICMP_SOURCEQUENCH 4
143#define ICMP_ROUTERADVERT 9
144#define ICMP_ROUTERSOLICIT 10
145#define ICMP_TIMXCEED 11
146#define ICMP_PARAMPROB 12
147#define ICMP_TSTAMP 13
148#define ICMP_TSTAMPREPLY 14
149#define ICMP_IREQ 15
150#define ICMP_IREQREPLY 16
151#define ICMP_MASKREQ 17
152#define ICMP_MASKREPLY 18
153#define ICMP_MAXTYPE 18
154
155#define ICMP_UNREACH_NET 0
156#define ICMP_UNREACH_HOST 1
157#define ICMP_UNREACH_PROTOCOL 2
158#define ICMP_UNREACH_PORT 3
159#define ICMP_UNREACH_NEEDFRAG 4
160#define ICMP_UNREACH_SRCFAIL 5
161#define ICMP_UNREACH_NET_UNKNOWN 6
162#define ICMP_UNREACH_HOST_UNKNOWN 7
163#define ICMP_UNREACH_ISOLATED 8
164#define ICMP_UNREACH_NET_PROHIB 9
165#define ICMP_UNREACH_HOST_PROHIB 10
166#define ICMP_UNREACH_TOSNET 11
167#define ICMP_UNREACH_TOSHOST 12
168#define ICMP_UNREACH_FILTER_PROHIB 13
169#define ICMP_UNREACH_HOST_PRECEDENCE 14
170#define ICMP_UNREACH_PRECEDENCE_CUTOFF 15
171
172#define ICMP_REDIRECT_NET 0
173#define ICMP_REDIRECT_HOST 1
174#define ICMP_REDIRECT_TOSNET 2
175#define ICMP_REDIRECT_TOSHOST 3
176
177#define ICMP_TIMXCEED_INTRANS 0
178#define ICMP_TIMXCEED_REASS 1
179
180#define ICMP_PARAMPROB_OPTABSENT 1
181
182#define ICMP_INFOTYPE(type) \
183 ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
184 (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \
185 (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
186 (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
187 (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
188
189#ifdef __cplusplus
190}
191#endif
192
193#endif
lib/libc/musl/include/netinet/tcp.h created+280
......@@ -0,0 +1,280 @@
1#ifndef _NETINET_TCP_H
2#define _NETINET_TCP_H
3
4#include <features.h>
5
6#define TCP_NODELAY 1
7#define TCP_MAXSEG 2
8#define TCP_CORK 3
9#define TCP_KEEPIDLE 4
10#define TCP_KEEPINTVL 5
11#define TCP_KEEPCNT 6
12#define TCP_SYNCNT 7
13#define TCP_LINGER2 8
14#define TCP_DEFER_ACCEPT 9
15#define TCP_WINDOW_CLAMP 10
16#define TCP_INFO 11
17#define TCP_QUICKACK 12
18#define TCP_CONGESTION 13
19#define TCP_MD5SIG 14
20#define TCP_THIN_LINEAR_TIMEOUTS 16
21#define TCP_THIN_DUPACK 17
22#define TCP_USER_TIMEOUT 18
23#define TCP_REPAIR 19
24#define TCP_REPAIR_QUEUE 20
25#define TCP_QUEUE_SEQ 21
26#define TCP_REPAIR_OPTIONS 22
27#define TCP_FASTOPEN 23
28#define TCP_TIMESTAMP 24
29#define TCP_NOTSENT_LOWAT 25
30#define TCP_CC_INFO 26
31#define TCP_SAVE_SYN 27
32#define TCP_SAVED_SYN 28
33#define TCP_REPAIR_WINDOW 29
34#define TCP_FASTOPEN_CONNECT 30
35#define TCP_ULP 31
36#define TCP_MD5SIG_EXT 32
37#define TCP_FASTOPEN_KEY 33
38#define TCP_FASTOPEN_NO_COOKIE 34
39#define TCP_ZEROCOPY_RECEIVE 35
40#define TCP_INQ 36
41
42#define TCP_CM_INQ TCP_INQ
43
44#define TCP_ESTABLISHED 1
45#define TCP_SYN_SENT 2
46#define TCP_SYN_RECV 3
47#define TCP_FIN_WAIT1 4
48#define TCP_FIN_WAIT2 5
49#define TCP_TIME_WAIT 6
50#define TCP_CLOSE 7
51#define TCP_CLOSE_WAIT 8
52#define TCP_LAST_ACK 9
53#define TCP_LISTEN 10
54#define TCP_CLOSING 11
55
56enum {
57 TCP_NLA_PAD,
58 TCP_NLA_BUSY,
59 TCP_NLA_RWND_LIMITED,
60 TCP_NLA_SNDBUF_LIMITED,
61 TCP_NLA_DATA_SEGS_OUT,
62 TCP_NLA_TOTAL_RETRANS,
63 TCP_NLA_PACING_RATE,
64 TCP_NLA_DELIVERY_RATE,
65 TCP_NLA_SND_CWND,
66 TCP_NLA_REORDERING,
67 TCP_NLA_MIN_RTT,
68 TCP_NLA_RECUR_RETRANS,
69 TCP_NLA_DELIVERY_RATE_APP_LMT,
70 TCP_NLA_SNDQ_SIZE,
71 TCP_NLA_CA_STATE,
72 TCP_NLA_SND_SSTHRESH,
73 TCP_NLA_DELIVERED,
74 TCP_NLA_DELIVERED_CE,
75 TCP_NLA_BYTES_SENT,
76 TCP_NLA_BYTES_RETRANS,
77 TCP_NLA_DSACK_DUPS,
78 TCP_NLA_REORD_SEEN,
79 TCP_NLA_SRTT,
80};
81
82#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
83#define TCPOPT_EOL 0
84#define TCPOPT_NOP 1
85#define TCPOPT_MAXSEG 2
86#define TCPOPT_WINDOW 3
87#define TCPOPT_SACK_PERMITTED 4
88#define TCPOPT_SACK 5
89#define TCPOPT_TIMESTAMP 8
90#define TCPOLEN_SACK_PERMITTED 2
91#define TCPOLEN_WINDOW 3
92#define TCPOLEN_MAXSEG 4
93#define TCPOLEN_TIMESTAMP 10
94
95#define SOL_TCP 6
96
97#include <sys/types.h>
98#include <sys/socket.h>
99#include <stdint.h>
100#include <endian.h>
101
102typedef uint32_t tcp_seq;
103
104#define TH_FIN 0x01
105#define TH_SYN 0x02
106#define TH_RST 0x04
107#define TH_PUSH 0x08
108#define TH_ACK 0x10
109#define TH_URG 0x20
110
111struct tcphdr {
112#ifdef _GNU_SOURCE
113#ifdef __GNUC__
114 __extension__
115#endif
116 union { struct {
117
118 uint16_t source;
119 uint16_t dest;
120 uint32_t seq;
121 uint32_t ack_seq;
122#if __BYTE_ORDER == __LITTLE_ENDIAN
123 uint16_t res1:4;
124 uint16_t doff:4;
125 uint16_t fin:1;
126 uint16_t syn:1;
127 uint16_t rst:1;
128 uint16_t psh:1;
129 uint16_t ack:1;
130 uint16_t urg:1;
131 uint16_t res2:2;
132#else
133 uint16_t doff:4;
134 uint16_t res1:4;
135 uint16_t res2:2;
136 uint16_t urg:1;
137 uint16_t ack:1;
138 uint16_t psh:1;
139 uint16_t rst:1;
140 uint16_t syn:1;
141 uint16_t fin:1;
142#endif
143 uint16_t window;
144 uint16_t check;
145 uint16_t urg_ptr;
146
147 }; struct {
148#endif
149
150 uint16_t th_sport;
151 uint16_t th_dport;
152 uint32_t th_seq;
153 uint32_t th_ack;
154#if __BYTE_ORDER == __LITTLE_ENDIAN
155 uint8_t th_x2:4;
156 uint8_t th_off:4;
157#else
158 uint8_t th_off:4;
159 uint8_t th_x2:4;
160#endif
161 uint8_t th_flags;
162 uint16_t th_win;
163 uint16_t th_sum;
164 uint16_t th_urp;
165
166#ifdef _GNU_SOURCE
167 }; };
168#endif
169};
170#endif
171
172#ifdef _GNU_SOURCE
173#define TCPI_OPT_TIMESTAMPS 1
174#define TCPI_OPT_SACK 2
175#define TCPI_OPT_WSCALE 4
176#define TCPI_OPT_ECN 8
177
178#define TCP_CA_Open 0
179#define TCP_CA_Disorder 1
180#define TCP_CA_CWR 2
181#define TCP_CA_Recovery 3
182#define TCP_CA_Loss 4
183
184struct tcp_info {
185 uint8_t tcpi_state;
186 uint8_t tcpi_ca_state;
187 uint8_t tcpi_retransmits;
188 uint8_t tcpi_probes;
189 uint8_t tcpi_backoff;
190 uint8_t tcpi_options;
191 uint8_t tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4;
192 uint8_t tcpi_delivery_rate_app_limited : 1;
193 uint32_t tcpi_rto;
194 uint32_t tcpi_ato;
195 uint32_t tcpi_snd_mss;
196 uint32_t tcpi_rcv_mss;
197 uint32_t tcpi_unacked;
198 uint32_t tcpi_sacked;
199 uint32_t tcpi_lost;
200 uint32_t tcpi_retrans;
201 uint32_t tcpi_fackets;
202 uint32_t tcpi_last_data_sent;
203 uint32_t tcpi_last_ack_sent;
204 uint32_t tcpi_last_data_recv;
205 uint32_t tcpi_last_ack_recv;
206 uint32_t tcpi_pmtu;
207 uint32_t tcpi_rcv_ssthresh;
208 uint32_t tcpi_rtt;
209 uint32_t tcpi_rttvar;
210 uint32_t tcpi_snd_ssthresh;
211 uint32_t tcpi_snd_cwnd;
212 uint32_t tcpi_advmss;
213 uint32_t tcpi_reordering;
214 uint32_t tcpi_rcv_rtt;
215 uint32_t tcpi_rcv_space;
216 uint32_t tcpi_total_retrans;
217 uint64_t tcpi_pacing_rate;
218 uint64_t tcpi_max_pacing_rate;
219 uint64_t tcpi_bytes_acked;
220 uint64_t tcpi_bytes_received;
221 uint32_t tcpi_segs_out;
222 uint32_t tcpi_segs_in;
223 uint32_t tcpi_notsent_bytes;
224 uint32_t tcpi_min_rtt;
225 uint32_t tcpi_data_segs_in;
226 uint32_t tcpi_data_segs_out;
227 uint64_t tcpi_delivery_rate;
228 uint64_t tcpi_busy_time;
229 uint64_t tcpi_rwnd_limited;
230 uint64_t tcpi_sndbuf_limited;
231 uint32_t tcpi_delivered;
232 uint32_t tcpi_delivered_ce;
233 uint64_t tcpi_bytes_sent;
234 uint64_t tcpi_bytes_retrans;
235 uint32_t tcpi_dsack_dups;
236 uint32_t tcpi_reord_seen;
237};
238
239#define TCP_MD5SIG_MAXKEYLEN 80
240
241#define TCP_MD5SIG_FLAG_PREFIX 1
242
243struct tcp_md5sig {
244 struct sockaddr_storage tcpm_addr;
245 uint8_t tcpm_flags;
246 uint8_t tcpm_prefixlen;
247 uint16_t tcpm_keylen;
248 uint32_t __tcpm_pad;
249 uint8_t tcpm_key[TCP_MD5SIG_MAXKEYLEN];
250};
251
252struct tcp_diag_md5sig {
253 uint8_t tcpm_family;
254 uint8_t tcpm_prefixlen;
255 uint16_t tcpm_keylen;
256 uint32_t tcpm_addr[4];
257 uint8_t tcpm_key[TCP_MD5SIG_MAXKEYLEN];
258};
259
260#define TCP_REPAIR_ON 1
261#define TCP_REPAIR_OFF 0
262#define TCP_REPAIR_OFF_NO_WP -1
263
264struct tcp_repair_window {
265 uint32_t snd_wl1;
266 uint32_t snd_wnd;
267 uint32_t max_window;
268 uint32_t rcv_wnd;
269 uint32_t rcv_wup;
270};
271
272struct tcp_zerocopy_receive {
273 uint64_t address;
274 uint32_t length;
275 uint32_t recv_skip_hint;
276};
277
278#endif
279
280#endif
lib/libc/musl/include/netinet/udp.h created+45
......@@ -0,0 +1,45 @@
1#ifndef _NETINET_UDP_H
2#define _NETINET_UDP_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9#include <stdint.h>
10
11#ifdef _GNU_SOURCE
12#define uh_sport source
13#define uh_dport dest
14#define uh_ulen len
15#define uh_sum check
16#endif
17
18struct udphdr {
19 uint16_t uh_sport;
20 uint16_t uh_dport;
21 uint16_t uh_ulen;
22 uint16_t uh_sum;
23};
24
25#define UDP_CORK 1
26#define UDP_ENCAP 100
27#define UDP_NO_CHECK6_TX 101
28#define UDP_NO_CHECK6_RX 102
29#define UDP_SEGMENT 103
30#define UDP_GRO 104
31
32#define UDP_ENCAP_ESPINUDP_NON_IKE 1
33#define UDP_ENCAP_ESPINUDP 2
34#define UDP_ENCAP_L2TPINUDP 3
35#define UDP_ENCAP_GTP0 4
36#define UDP_ENCAP_GTP1U 5
37#define UDP_ENCAP_RXRPC 6
38
39#define SOL_UDP 17
40
41#ifdef __cplusplus
42}
43#endif
44
45#endif
lib/libc/musl/include/netpacket/packet.h created+62
......@@ -0,0 +1,62 @@
1#ifndef _NETPACKET_PACKET_H
2#define _NETPACKET_PACKET_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8struct sockaddr_ll {
9 unsigned short sll_family, sll_protocol;
10 int sll_ifindex;
11 unsigned short sll_hatype;
12 unsigned char sll_pkttype, sll_halen;
13 unsigned char sll_addr[8];
14};
15
16struct packet_mreq {
17 int mr_ifindex;
18 unsigned short int mr_type, mr_alen;
19 unsigned char mr_address[8];
20};
21
22#define PACKET_HOST 0
23#define PACKET_BROADCAST 1
24#define PACKET_MULTICAST 2
25#define PACKET_OTHERHOST 3
26#define PACKET_OUTGOING 4
27#define PACKET_LOOPBACK 5
28#define PACKET_FASTROUTE 6
29
30#define PACKET_ADD_MEMBERSHIP 1
31#define PACKET_DROP_MEMBERSHIP 2
32#define PACKET_RECV_OUTPUT 3
33#define PACKET_RX_RING 5
34#define PACKET_STATISTICS 6
35#define PACKET_COPY_THRESH 7
36#define PACKET_AUXDATA 8
37#define PACKET_ORIGDEV 9
38#define PACKET_VERSION 10
39#define PACKET_HDRLEN 11
40#define PACKET_RESERVE 12
41#define PACKET_TX_RING 13
42#define PACKET_LOSS 14
43#define PACKET_VNET_HDR 15
44#define PACKET_TX_TIMESTAMP 16
45#define PACKET_TIMESTAMP 17
46#define PACKET_FANOUT 18
47#define PACKET_TX_HAS_OFF 19
48#define PACKET_QDISC_BYPASS 20
49#define PACKET_ROLLOVER_STATS 21
50#define PACKET_FANOUT_DATA 22
51#define PACKET_IGNORE_OUTGOING 23
52
53#define PACKET_MR_MULTICAST 0
54#define PACKET_MR_PROMISC 1
55#define PACKET_MR_ALLMULTI 2
56#define PACKET_MR_UNICAST 3
57
58#ifdef __cplusplus
59}
60#endif
61
62#endif
lib/libc/musl/include/nl_types.h created+22
......@@ -0,0 +1,22 @@
1#ifndef _NL_TYPES_H
2#define _NL_TYPES_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define NL_SETD 1
9#define NL_CAT_LOCALE 1
10
11typedef int nl_item;
12typedef void *nl_catd;
13
14nl_catd catopen (const char *, int);
15char *catgets (nl_catd, int, int, const char *);
16int catclose (nl_catd);
17
18#ifdef __cplusplus
19}
20#endif
21
22#endif
lib/libc/musl/include/paths.h created+31
......@@ -0,0 +1,31 @@
1#ifndef _PATHS_H
2#define _PATHS_H
3
4#define _PATH_DEFPATH "/usr/local/bin:/bin:/usr/bin"
5#define _PATH_STDPATH "/bin:/usr/bin:/sbin:/usr/sbin"
6
7#define _PATH_BSHELL "/bin/sh"
8#define _PATH_CONSOLE "/dev/console"
9#define _PATH_DEVNULL "/dev/null"
10#define _PATH_KLOG "/proc/kmsg"
11#define _PATH_LASTLOG "/var/log/lastlog"
12#define _PATH_MAILDIR "/var/mail"
13#define _PATH_MAN "/usr/share/man"
14#define _PATH_MNTTAB "/etc/fstab"
15#define _PATH_MOUNTED "/etc/mtab"
16#define _PATH_NOLOGIN "/etc/nologin"
17#define _PATH_SENDMAIL "/usr/sbin/sendmail"
18#define _PATH_SHADOW "/etc/shadow"
19#define _PATH_SHELLS "/etc/shells"
20#define _PATH_TTY "/dev/tty"
21#define _PATH_UTMP "/dev/null/utmp"
22#define _PATH_VI "/usr/bin/vi"
23#define _PATH_WTMP "/dev/null/wtmp"
24
25#define _PATH_DEV "/dev/"
26#define _PATH_TMP "/tmp/"
27#define _PATH_VARDB "/var/lib/misc/"
28#define _PATH_VARRUN "/var/run/"
29#define _PATH_VARTMP "/var/tmp/"
30
31#endif
lib/libc/musl/include/poll.h created+51
......@@ -0,0 +1,51 @@
1#ifndef _POLL_H
2#define _POLL_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#include <bits/poll.h>
11
12#define POLLIN 0x001
13#define POLLPRI 0x002
14#define POLLOUT 0x004
15#define POLLERR 0x008
16#define POLLHUP 0x010
17#define POLLNVAL 0x020
18#define POLLRDNORM 0x040
19#define POLLRDBAND 0x080
20#ifndef POLLWRNORM
21#define POLLWRNORM 0x100
22#define POLLWRBAND 0x200
23#endif
24#ifndef POLLMSG
25#define POLLMSG 0x400
26#define POLLRDHUP 0x2000
27#endif
28
29typedef unsigned long nfds_t;
30
31struct pollfd {
32 int fd;
33 short events;
34 short revents;
35};
36
37int poll (struct pollfd *, nfds_t, int);
38
39#ifdef _GNU_SOURCE
40#define __NEED_time_t
41#define __NEED_struct_timespec
42#define __NEED_sigset_t
43#include <bits/alltypes.h>
44int ppoll(struct pollfd *, nfds_t, const struct timespec *, const sigset_t *);
45#endif
46
47#ifdef __cplusplus
48}
49#endif
50
51#endif
lib/libc/musl/include/pthread.h created+230
......@@ -0,0 +1,230 @@
1#ifndef _PTHREAD_H
2#define _PTHREAD_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <features.h>
8
9#define __NEED_time_t
10#define __NEED_clockid_t
11#define __NEED_struct_timespec
12#define __NEED_sigset_t
13#define __NEED_pthread_t
14#define __NEED_pthread_attr_t
15#define __NEED_pthread_mutexattr_t
16#define __NEED_pthread_condattr_t
17#define __NEED_pthread_rwlockattr_t
18#define __NEED_pthread_barrierattr_t
19#define __NEED_pthread_mutex_t
20#define __NEED_pthread_cond_t
21#define __NEED_pthread_rwlock_t
22#define __NEED_pthread_barrier_t
23#define __NEED_pthread_spinlock_t
24#define __NEED_pthread_key_t
25#define __NEED_pthread_once_t
26#define __NEED_size_t
27
28#include <bits/alltypes.h>
29
30#include <sched.h>
31#include <time.h>
32
33#define PTHREAD_CREATE_JOINABLE 0
34#define PTHREAD_CREATE_DETACHED 1
35
36#define PTHREAD_MUTEX_NORMAL 0
37#define PTHREAD_MUTEX_DEFAULT 0
38#define PTHREAD_MUTEX_RECURSIVE 1
39#define PTHREAD_MUTEX_ERRORCHECK 2
40
41#define PTHREAD_MUTEX_STALLED 0
42#define PTHREAD_MUTEX_ROBUST 1
43
44#define PTHREAD_PRIO_NONE 0
45#define PTHREAD_PRIO_INHERIT 1
46#define PTHREAD_PRIO_PROTECT 2
47
48#define PTHREAD_INHERIT_SCHED 0
49#define PTHREAD_EXPLICIT_SCHED 1
50
51#define PTHREAD_SCOPE_SYSTEM 0
52#define PTHREAD_SCOPE_PROCESS 1
53
54#define PTHREAD_PROCESS_PRIVATE 0
55#define PTHREAD_PROCESS_SHARED 1
56
57
58#define PTHREAD_MUTEX_INITIALIZER {{{0}}}
59#define PTHREAD_RWLOCK_INITIALIZER {{{0}}}
60#define PTHREAD_COND_INITIALIZER {{{0}}}
61#define PTHREAD_ONCE_INIT 0
62
63
64#define PTHREAD_CANCEL_ENABLE 0
65#define PTHREAD_CANCEL_DISABLE 1
66#define PTHREAD_CANCEL_MASKED 2
67
68#define PTHREAD_CANCEL_DEFERRED 0
69#define PTHREAD_CANCEL_ASYNCHRONOUS 1
70
71#define PTHREAD_CANCELED ((void *)-1)
72
73
74#define PTHREAD_BARRIER_SERIAL_THREAD (-1)
75
76
77int pthread_create(pthread_t *__restrict, const pthread_attr_t *__restrict, void *(*)(void *), void *__restrict);
78int pthread_detach(pthread_t);
79_Noreturn void pthread_exit(void *);
80int pthread_join(pthread_t, void **);
81
82#ifdef __GNUC__
83__attribute__((const))
84#endif
85pthread_t pthread_self(void);
86
87int pthread_equal(pthread_t, pthread_t);
88#ifndef __cplusplus
89#define pthread_equal(x,y) ((x)==(y))
90#endif
91
92int pthread_setcancelstate(int, int *);
93int pthread_setcanceltype(int, int *);
94void pthread_testcancel(void);
95int pthread_cancel(pthread_t);
96
97int pthread_getschedparam(pthread_t, int *__restrict, struct sched_param *__restrict);
98int pthread_setschedparam(pthread_t, int, const struct sched_param *);
99int pthread_setschedprio(pthread_t, int);
100
101int pthread_once(pthread_once_t *, void (*)(void));
102
103int pthread_mutex_init(pthread_mutex_t *__restrict, const pthread_mutexattr_t *__restrict);
104int pthread_mutex_lock(pthread_mutex_t *);
105int pthread_mutex_unlock(pthread_mutex_t *);
106int pthread_mutex_trylock(pthread_mutex_t *);
107int pthread_mutex_timedlock(pthread_mutex_t *__restrict, const struct timespec *__restrict);
108int pthread_mutex_destroy(pthread_mutex_t *);
109int pthread_mutex_consistent(pthread_mutex_t *);
110
111int pthread_mutex_getprioceiling(const pthread_mutex_t *__restrict, int *__restrict);
112int pthread_mutex_setprioceiling(pthread_mutex_t *__restrict, int, int *__restrict);
113
114int pthread_cond_init(pthread_cond_t *__restrict, const pthread_condattr_t *__restrict);
115int pthread_cond_destroy(pthread_cond_t *);
116int pthread_cond_wait(pthread_cond_t *__restrict, pthread_mutex_t *__restrict);
117int pthread_cond_timedwait(pthread_cond_t *__restrict, pthread_mutex_t *__restrict, const struct timespec *__restrict);
118int pthread_cond_broadcast(pthread_cond_t *);
119int pthread_cond_signal(pthread_cond_t *);
120
121int pthread_rwlock_init(pthread_rwlock_t *__restrict, const pthread_rwlockattr_t *__restrict);
122int pthread_rwlock_destroy(pthread_rwlock_t *);
123int pthread_rwlock_rdlock(pthread_rwlock_t *);
124int pthread_rwlock_tryrdlock(pthread_rwlock_t *);
125int pthread_rwlock_timedrdlock(pthread_rwlock_t *__restrict, const struct timespec *__restrict);
126int pthread_rwlock_wrlock(pthread_rwlock_t *);
127int pthread_rwlock_trywrlock(pthread_rwlock_t *);
128int pthread_rwlock_timedwrlock(pthread_rwlock_t *__restrict, const struct timespec *__restrict);
129int pthread_rwlock_unlock(pthread_rwlock_t *);
130
131int pthread_spin_init(pthread_spinlock_t *, int);
132int pthread_spin_destroy(pthread_spinlock_t *);
133int pthread_spin_lock(pthread_spinlock_t *);
134int pthread_spin_trylock(pthread_spinlock_t *);
135int pthread_spin_unlock(pthread_spinlock_t *);
136
137int pthread_barrier_init(pthread_barrier_t *__restrict, const pthread_barrierattr_t *__restrict, unsigned);
138int pthread_barrier_destroy(pthread_barrier_t *);
139int pthread_barrier_wait(pthread_barrier_t *);
140
141int pthread_key_create(pthread_key_t *, void (*)(void *));
142int pthread_key_delete(pthread_key_t);
143void *pthread_getspecific(pthread_key_t);
144int pthread_setspecific(pthread_key_t, const void *);
145
146int pthread_attr_init(pthread_attr_t *);
147int pthread_attr_destroy(pthread_attr_t *);
148
149int pthread_attr_getguardsize(const pthread_attr_t *__restrict, size_t *__restrict);
150int pthread_attr_setguardsize(pthread_attr_t *, size_t);
151int pthread_attr_getstacksize(const pthread_attr_t *__restrict, size_t *__restrict);
152int pthread_attr_setstacksize(pthread_attr_t *, size_t);
153int pthread_attr_getdetachstate(const pthread_attr_t *, int *);
154int pthread_attr_setdetachstate(pthread_attr_t *, int);
155int pthread_attr_getstack(const pthread_attr_t *__restrict, void **__restrict, size_t *__restrict);
156int pthread_attr_setstack(pthread_attr_t *, void *, size_t);
157int pthread_attr_getscope(const pthread_attr_t *__restrict, int *__restrict);
158int pthread_attr_setscope(pthread_attr_t *, int);
159int pthread_attr_getschedpolicy(const pthread_attr_t *__restrict, int *__restrict);
160int pthread_attr_setschedpolicy(pthread_attr_t *, int);
161int pthread_attr_getschedparam(const pthread_attr_t *__restrict, struct sched_param *__restrict);
162int pthread_attr_setschedparam(pthread_attr_t *__restrict, const struct sched_param *__restrict);
163int pthread_attr_getinheritsched(const pthread_attr_t *__restrict, int *__restrict);
164int pthread_attr_setinheritsched(pthread_attr_t *, int);
165
166int pthread_mutexattr_destroy(pthread_mutexattr_t *);
167int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *__restrict, int *__restrict);
168int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *__restrict, int *__restrict);
169int pthread_mutexattr_getpshared(const pthread_mutexattr_t *__restrict, int *__restrict);
170int pthread_mutexattr_getrobust(const pthread_mutexattr_t *__restrict, int *__restrict);
171int pthread_mutexattr_gettype(const pthread_mutexattr_t *__restrict, int *__restrict);
172int pthread_mutexattr_init(pthread_mutexattr_t *);
173int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *, int);
174int pthread_mutexattr_setprotocol(pthread_mutexattr_t *, int);
175int pthread_mutexattr_setpshared(pthread_mutexattr_t *, int);
176int pthread_mutexattr_setrobust(pthread_mutexattr_t *, int);
177int pthread_mutexattr_settype(pthread_mutexattr_t *, int);
178
179int pthread_condattr_init(pthread_condattr_t *);
180int pthread_condattr_destroy(pthread_condattr_t *);
181int pthread_condattr_setclock(pthread_condattr_t *, clockid_t);
182int pthread_condattr_setpshared(pthread_condattr_t *, int);
183int pthread_condattr_getclock(const pthread_condattr_t *__restrict, clockid_t *__restrict);
184int pthread_condattr_getpshared(const pthread_condattr_t *__restrict, int *__restrict);
185
186int pthread_rwlockattr_init(pthread_rwlockattr_t *);
187int pthread_rwlockattr_destroy(pthread_rwlockattr_t *);
188int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *, int);
189int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *__restrict, int *__restrict);
190
191int pthread_barrierattr_destroy(pthread_barrierattr_t *);
192int pthread_barrierattr_getpshared(const pthread_barrierattr_t *__restrict, int *__restrict);
193int pthread_barrierattr_init(pthread_barrierattr_t *);
194int pthread_barrierattr_setpshared(pthread_barrierattr_t *, int);
195
196int pthread_atfork(void (*)(void), void (*)(void), void (*)(void));
197
198int pthread_getconcurrency(void);
199int pthread_setconcurrency(int);
200
201int pthread_getcpuclockid(pthread_t, clockid_t *);
202
203struct __ptcb {
204 void (*__f)(void *);
205 void *__x;
206 struct __ptcb *__next;
207};
208
209void _pthread_cleanup_push(struct __ptcb *, void (*)(void *), void *);
210void _pthread_cleanup_pop(struct __ptcb *, int);
211
212#define pthread_cleanup_push(f, x) do { struct __ptcb __cb; _pthread_cleanup_push(&__cb, f, x);
213#define pthread_cleanup_pop(r) _pthread_cleanup_pop(&__cb, (r)); } while(0)
214
215#ifdef _GNU_SOURCE
216struct cpu_set_t;
217int pthread_getaffinity_np(pthread_t, size_t, struct cpu_set_t *);
218int pthread_setaffinity_np(pthread_t, size_t, const struct cpu_set_t *);
219int pthread_getattr_np(pthread_t, pthread_attr_t *);
220int pthread_setname_np(pthread_t, const char *);
221int pthread_getattr_default_np(pthread_attr_t *);
222int pthread_setattr_default_np(const pthread_attr_t *);
223int pthread_tryjoin_np(pthread_t, void **);
224int pthread_timedjoin_np(pthread_t, void **, const struct timespec *);
225#endif
226
227#ifdef __cplusplus
228}
229#endif
230#endif
lib/libc/musl/include/pty.h created+18
......@@ -0,0 +1,18 @@
1#ifndef _PTY_H
2#define _PTY_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <termios.h>
9#include <sys/ioctl.h>
10
11int openpty(int *, int *, char *, const struct termios *, const struct winsize *);
12int forkpty(int *, char *, const struct termios *, const struct winsize *);
13
14#ifdef __cplusplus
15}
16#endif
17
18#endif
lib/libc/musl/include/pwd.h created+50
......@@ -0,0 +1,50 @@
1#ifndef _PWD_H
2#define _PWD_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_size_t
11#define __NEED_uid_t
12#define __NEED_gid_t
13
14#ifdef _GNU_SOURCE
15#define __NEED_FILE
16#endif
17
18#include <bits/alltypes.h>
19
20struct passwd {
21 char *pw_name;
22 char *pw_passwd;
23 uid_t pw_uid;
24 gid_t pw_gid;
25 char *pw_gecos;
26 char *pw_dir;
27 char *pw_shell;
28};
29
30#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
31void setpwent (void);
32void endpwent (void);
33struct passwd *getpwent (void);
34#endif
35
36struct passwd *getpwuid (uid_t);
37struct passwd *getpwnam (const char *);
38int getpwuid_r (uid_t, struct passwd *, char *, size_t, struct passwd **);
39int getpwnam_r (const char *, struct passwd *, char *, size_t, struct passwd **);
40
41#ifdef _GNU_SOURCE
42struct passwd *fgetpwent(FILE *);
43int putpwent(const struct passwd *, FILE *);
44#endif
45
46#ifdef __cplusplus
47}
48#endif
49
50#endif
lib/libc/musl/include/regex.h created+62
......@@ -0,0 +1,62 @@
1#ifndef _REGEX_H
2#define _REGEX_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_regoff_t
11#define __NEED_size_t
12
13#include <bits/alltypes.h>
14
15typedef struct re_pattern_buffer {
16 size_t re_nsub;
17 void *__opaque, *__padding[4];
18 size_t __nsub2;
19 char __padding2;
20} regex_t;
21
22typedef struct {
23 regoff_t rm_so;
24 regoff_t rm_eo;
25} regmatch_t;
26
27#define REG_EXTENDED 1
28#define REG_ICASE 2
29#define REG_NEWLINE 4
30#define REG_NOSUB 8
31
32#define REG_NOTBOL 1
33#define REG_NOTEOL 2
34
35#define REG_OK 0
36#define REG_NOMATCH 1
37#define REG_BADPAT 2
38#define REG_ECOLLATE 3
39#define REG_ECTYPE 4
40#define REG_EESCAPE 5
41#define REG_ESUBREG 6
42#define REG_EBRACK 7
43#define REG_EPAREN 8
44#define REG_EBRACE 9
45#define REG_BADBR 10
46#define REG_ERANGE 11
47#define REG_ESPACE 12
48#define REG_BADRPT 13
49
50#define REG_ENOSYS -1
51
52int regcomp(regex_t *__restrict, const char *__restrict, int);
53int regexec(const regex_t *__restrict, const char *__restrict, size_t, regmatch_t *__restrict, int);
54void regfree(regex_t *);
55
56size_t regerror(int, const regex_t *__restrict, char *__restrict, size_t);
57
58#ifdef __cplusplus
59}
60#endif
61
62#endif
lib/libc/musl/include/resolv.h created+142
......@@ -0,0 +1,142 @@
1#ifndef _RESOLV_H
2#define _RESOLV_H
3
4#include <stdint.h>
5#include <arpa/nameser.h>
6#include <netinet/in.h>
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#define MAXNS 3
13#define MAXDFLSRCH 3
14#define MAXDNSRCH 6
15#define LOCALDOMAINPARTS 2
16
17#define RES_TIMEOUT 5
18#define MAXRESOLVSORT 10
19#define RES_MAXNDOTS 15
20#define RES_MAXRETRANS 30
21#define RES_MAXRETRY 5
22#define RES_DFLRETRY 2
23#define RES_MAXTIME 65535
24
25/* unused; purely for broken apps */
26typedef struct __res_state {
27 int retrans;
28 int retry;
29 unsigned long options;
30 int nscount;
31 struct sockaddr_in nsaddr_list[MAXNS];
32# define nsaddr nsaddr_list[0]
33 unsigned short id;
34 char *dnsrch[MAXDNSRCH+1];
35 char defdname[256];
36 unsigned long pfcode;
37 unsigned ndots:4;
38 unsigned nsort:4;
39 unsigned ipv6_unavail:1;
40 unsigned unused:23;
41 struct {
42 struct in_addr addr;
43 uint32_t mask;
44 } sort_list[MAXRESOLVSORT];
45 void *qhook;
46 void *rhook;
47 int res_h_errno;
48 int _vcsock;
49 unsigned _flags;
50 union {
51 char pad[52];
52 struct {
53 uint16_t nscount;
54 uint16_t nsmap[MAXNS];
55 int nssocks[MAXNS];
56 uint16_t nscount6;
57 uint16_t nsinit;
58 struct sockaddr_in6 *nsaddrs[MAXNS];
59 unsigned int _initstamp[2];
60 } _ext;
61 } _u;
62} *res_state;
63
64#define __RES 19960801
65
66#ifndef _PATH_RESCONF
67#define _PATH_RESCONF "/etc/resolv.conf"
68#endif
69
70struct res_sym {
71 int number;
72 char *name;
73 char *humanname;
74};
75
76#define RES_F_VC 0x00000001
77#define RES_F_CONN 0x00000002
78#define RES_F_EDNS0ERR 0x00000004
79
80#define RES_EXHAUSTIVE 0x00000001
81
82#define RES_INIT 0x00000001
83#define RES_DEBUG 0x00000002
84#define RES_AAONLY 0x00000004
85#define RES_USEVC 0x00000008
86#define RES_PRIMARY 0x00000010
87#define RES_IGNTC 0x00000020
88#define RES_RECURSE 0x00000040
89#define RES_DEFNAMES 0x00000080
90#define RES_STAYOPEN 0x00000100
91#define RES_DNSRCH 0x00000200
92#define RES_INSECURE1 0x00000400
93#define RES_INSECURE2 0x00000800
94#define RES_NOALIASES 0x00001000
95#define RES_USE_INET6 0x00002000
96#define RES_ROTATE 0x00004000
97#define RES_NOCHECKNAME 0x00008000
98#define RES_KEEPTSIG 0x00010000
99#define RES_BLAST 0x00020000
100#define RES_USEBSTRING 0x00040000
101#define RES_NOIP6DOTINT 0x00080000
102#define RES_USE_EDNS0 0x00100000
103#define RES_SNGLKUP 0x00200000
104#define RES_SNGLKUPREOP 0x00400000
105#define RES_USE_DNSSEC 0x00800000
106
107#define RES_DEFAULT (RES_RECURSE|RES_DEFNAMES|RES_DNSRCH|RES_NOIP6DOTINT)
108
109#define RES_PRF_STATS 0x00000001
110#define RES_PRF_UPDATE 0x00000002
111#define RES_PRF_CLASS 0x00000004
112#define RES_PRF_CMD 0x00000008
113#define RES_PRF_QUES 0x00000010
114#define RES_PRF_ANS 0x00000020
115#define RES_PRF_AUTH 0x00000040
116#define RES_PRF_ADD 0x00000080
117#define RES_PRF_HEAD1 0x00000100
118#define RES_PRF_HEAD2 0x00000200
119#define RES_PRF_TTLID 0x00000400
120#define RES_PRF_HEADX 0x00000800
121#define RES_PRF_QUERY 0x00001000
122#define RES_PRF_REPLY 0x00002000
123#define RES_PRF_INIT 0x00004000
124
125struct __res_state *__res_state(void);
126#define _res (*__res_state())
127
128int res_init(void);
129int res_query(const char *, int, int, unsigned char *, int);
130int res_querydomain(const char *, const char *, int, int, unsigned char *, int);
131int res_search(const char *, int, int, unsigned char *, int);
132int res_mkquery(int, const char *, int, int, const unsigned char *, int, const unsigned char*, unsigned char *, int);
133int res_send(const unsigned char *, int, unsigned char *, int);
134int dn_comp(const char *, unsigned char *, int, unsigned char **, unsigned char **);
135int dn_expand(const unsigned char *, const unsigned char *, const unsigned char *, char *, int);
136int dn_skipname(const unsigned char *, const unsigned char *);
137
138#ifdef __cplusplus
139}
140#endif
141
142#endif
lib/libc/musl/include/sched.h created+136
......@@ -0,0 +1,136 @@
1#ifndef _SCHED_H
2#define _SCHED_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <features.h>
8
9#define __NEED_struct_timespec
10#define __NEED_pid_t
11#define __NEED_time_t
12
13#ifdef _GNU_SOURCE
14#define __NEED_size_t
15#endif
16
17#include <bits/alltypes.h>
18
19struct sched_param {
20 int sched_priority;
21 int sched_ss_low_priority;
22 struct timespec sched_ss_repl_period;
23 struct timespec sched_ss_init_budget;
24 int sched_ss_max_repl;
25};
26
27int sched_get_priority_max(int);
28int sched_get_priority_min(int);
29int sched_getparam(pid_t, struct sched_param *);
30int sched_getscheduler(pid_t);
31int sched_rr_get_interval(pid_t, struct timespec *);
32int sched_setparam(pid_t, const struct sched_param *);
33int sched_setscheduler(pid_t, int, const struct sched_param *);
34int sched_yield(void);
35
36#define SCHED_OTHER 0
37#define SCHED_FIFO 1
38#define SCHED_RR 2
39#define SCHED_BATCH 3
40#define SCHED_IDLE 5
41#define SCHED_DEADLINE 6
42#define SCHED_RESET_ON_FORK 0x40000000
43
44#ifdef _GNU_SOURCE
45#define CSIGNAL 0x000000ff
46#define CLONE_VM 0x00000100
47#define CLONE_FS 0x00000200
48#define CLONE_FILES 0x00000400
49#define CLONE_SIGHAND 0x00000800
50#define CLONE_PTRACE 0x00002000
51#define CLONE_VFORK 0x00004000
52#define CLONE_PARENT 0x00008000
53#define CLONE_THREAD 0x00010000
54#define CLONE_NEWNS 0x00020000
55#define CLONE_SYSVSEM 0x00040000
56#define CLONE_SETTLS 0x00080000
57#define CLONE_PARENT_SETTID 0x00100000
58#define CLONE_CHILD_CLEARTID 0x00200000
59#define CLONE_DETACHED 0x00400000
60#define CLONE_UNTRACED 0x00800000
61#define CLONE_CHILD_SETTID 0x01000000
62#define CLONE_NEWCGROUP 0x02000000
63#define CLONE_NEWUTS 0x04000000
64#define CLONE_NEWIPC 0x08000000
65#define CLONE_NEWUSER 0x10000000
66#define CLONE_NEWPID 0x20000000
67#define CLONE_NEWNET 0x40000000
68#define CLONE_IO 0x80000000
69int clone (int (*)(void *), void *, int, void *, ...);
70int unshare(int);
71int setns(int, int);
72
73void *memcpy(void *__restrict, const void *__restrict, size_t);
74int memcmp(const void *, const void *, size_t);
75void *memset (void *, int, size_t);
76void *calloc(size_t, size_t);
77void free(void *);
78
79typedef struct cpu_set_t { unsigned long __bits[128/sizeof(long)]; } cpu_set_t;
80int __sched_cpucount(size_t, const cpu_set_t *);
81int sched_getcpu(void);
82int sched_getaffinity(pid_t, size_t, cpu_set_t *);
83int sched_setaffinity(pid_t, size_t, const cpu_set_t *);
84
85#define __CPU_op_S(i, size, set, op) ( (i)/8U >= (size) ? 0 : \
86 (((unsigned long *)(set))[(i)/8/sizeof(long)] op (1UL<<((i)%(8*sizeof(long))))) )
87
88#define CPU_SET_S(i, size, set) __CPU_op_S(i, size, set, |=)
89#define CPU_CLR_S(i, size, set) __CPU_op_S(i, size, set, &=~)
90#define CPU_ISSET_S(i, size, set) __CPU_op_S(i, size, set, &)
91
92#define __CPU_op_func_S(func, op) \
93static __inline void __CPU_##func##_S(size_t __size, cpu_set_t *__dest, \
94 const cpu_set_t *__src1, const cpu_set_t *__src2) \
95{ \
96 size_t __i; \
97 for (__i=0; __i<__size/sizeof(long); __i++) \
98 ((unsigned long *)__dest)[__i] = ((unsigned long *)__src1)[__i] \
99 op ((unsigned long *)__src2)[__i] ; \
100}
101
102__CPU_op_func_S(AND, &)
103__CPU_op_func_S(OR, |)
104__CPU_op_func_S(XOR, ^)
105
106#define CPU_AND_S(a,b,c,d) __CPU_AND_S(a,b,c,d)
107#define CPU_OR_S(a,b,c,d) __CPU_OR_S(a,b,c,d)
108#define CPU_XOR_S(a,b,c,d) __CPU_XOR_S(a,b,c,d)
109
110#define CPU_COUNT_S(size,set) __sched_cpucount(size,set)
111#define CPU_ZERO_S(size,set) memset(set,0,size)
112#define CPU_EQUAL_S(size,set1,set2) (!memcmp(set1,set2,size))
113
114#define CPU_ALLOC_SIZE(n) (sizeof(long) * ( (n)/(8*sizeof(long)) \
115 + ((n)%(8*sizeof(long)) + 8*sizeof(long)-1)/(8*sizeof(long)) ) )
116#define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n)))
117#define CPU_FREE(set) free(set)
118
119#define CPU_SETSIZE 128
120
121#define CPU_SET(i, set) CPU_SET_S(i,sizeof(cpu_set_t),set)
122#define CPU_CLR(i, set) CPU_CLR_S(i,sizeof(cpu_set_t),set)
123#define CPU_ISSET(i, set) CPU_ISSET_S(i,sizeof(cpu_set_t),set)
124#define CPU_AND(d,s1,s2) CPU_AND_S(sizeof(cpu_set_t),d,s1,s2)
125#define CPU_OR(d,s1,s2) CPU_OR_S(sizeof(cpu_set_t),d,s1,s2)
126#define CPU_XOR(d,s1,s2) CPU_XOR_S(sizeof(cpu_set_t),d,s1,s2)
127#define CPU_COUNT(set) CPU_COUNT_S(sizeof(cpu_set_t),set)
128#define CPU_ZERO(set) CPU_ZERO_S(sizeof(cpu_set_t),set)
129#define CPU_EQUAL(s1,s2) CPU_EQUAL_S(sizeof(cpu_set_t),s1,s2)
130
131#endif
132
133#ifdef __cplusplus
134}
135#endif
136#endif
lib/libc/musl/include/scsi/scsi.h created+150
......@@ -0,0 +1,150 @@
1#ifndef _SCSI_SCSI_H
2#define _SCSI_SCSI_H
3
4#define TEST_UNIT_READY 0x00
5#define REZERO_UNIT 0x01
6#define REQUEST_SENSE 0x03
7#define FORMAT_UNIT 0x04
8#define READ_BLOCK_LIMITS 0x05
9#define REASSIGN_BLOCKS 0x07
10#define READ_6 0x08
11#define WRITE_6 0x0a
12#define SEEK_6 0x0b
13#define READ_REVERSE 0x0f
14#define WRITE_FILEMARKS 0x10
15#define SPACE 0x11
16#define INQUIRY 0x12
17#define RECOVER_BUFFERED_DATA 0x14
18#define MODE_SELECT 0x15
19#define RESERVE 0x16
20#define RELEASE 0x17
21#define COPY 0x18
22#define ERASE 0x19
23#define MODE_SENSE 0x1a
24#define START_STOP 0x1b
25#define RECEIVE_DIAGNOSTIC 0x1c
26#define SEND_DIAGNOSTIC 0x1d
27#define ALLOW_MEDIUM_REMOVAL 0x1e
28#define SET_WINDOW 0x24
29#define READ_CAPACITY 0x25
30#define READ_10 0x28
31#define WRITE_10 0x2a
32#define SEEK_10 0x2b
33#define WRITE_VERIFY 0x2e
34#define VERIFY 0x2f
35#define SEARCH_HIGH 0x30
36#define SEARCH_EQUAL 0x31
37#define SEARCH_LOW 0x32
38#define SET_LIMITS 0x33
39#define PRE_FETCH 0x34
40#define READ_POSITION 0x34
41#define SYNCHRONIZE_CACHE 0x35
42#define LOCK_UNLOCK_CACHE 0x36
43#define READ_DEFECT_DATA 0x37
44#define MEDIUM_SCAN 0x38
45#define COMPARE 0x39
46#define COPY_VERIFY 0x3a
47#define WRITE_BUFFER 0x3b
48#define READ_BUFFER 0x3c
49#define UPDATE_BLOCK 0x3d
50#define READ_LONG 0x3e
51#define WRITE_LONG 0x3f
52#define CHANGE_DEFINITION 0x40
53#define WRITE_SAME 0x41
54#define READ_TOC 0x43
55#define LOG_SELECT 0x4c
56#define LOG_SENSE 0x4d
57#define MODE_SELECT_10 0x55
58#define RESERVE_10 0x56
59#define RELEASE_10 0x57
60#define MODE_SENSE_10 0x5a
61#define PERSISTENT_RESERVE_IN 0x5e
62#define PERSISTENT_RESERVE_OUT 0x5f
63#define MOVE_MEDIUM 0xa5
64#define READ_12 0xa8
65#define WRITE_12 0xaa
66#define WRITE_VERIFY_12 0xae
67#define SEARCH_HIGH_12 0xb0
68#define SEARCH_EQUAL_12 0xb1
69#define SEARCH_LOW_12 0xb2
70#define READ_ELEMENT_STATUS 0xb8
71#define SEND_VOLUME_TAG 0xb6
72#define WRITE_LONG_2 0xea
73#define GOOD 0x00
74#define CHECK_CONDITION 0x01
75#define CONDITION_GOOD 0x02
76#define BUSY 0x04
77#define INTERMEDIATE_GOOD 0x08
78#define INTERMEDIATE_C_GOOD 0x0a
79#define RESERVATION_CONFLICT 0x0c
80#define COMMAND_TERMINATED 0x11
81#define QUEUE_FULL 0x14
82#define STATUS_MASK 0x3e
83#define NO_SENSE 0x00
84#define RECOVERED_ERROR 0x01
85#define NOT_READY 0x02
86#define MEDIUM_ERROR 0x03
87#define HARDWARE_ERROR 0x04
88#define ILLEGAL_REQUEST 0x05
89#define UNIT_ATTENTION 0x06
90#define DATA_PROTECT 0x07
91#define BLANK_CHECK 0x08
92#define COPY_ABORTED 0x0a
93#define ABORTED_COMMAND 0x0b
94#define VOLUME_OVERFLOW 0x0d
95#define MISCOMPARE 0x0e
96#define TYPE_DISK 0x00
97#define TYPE_TAPE 0x01
98#define TYPE_PROCESSOR 0x03
99#define TYPE_WORM 0x04
100#define TYPE_ROM 0x05
101#define TYPE_SCANNER 0x06
102#define TYPE_MOD 0x07
103#define TYPE_MEDIUM_CHANGER 0x08
104#define TYPE_ENCLOSURE 0x0d
105#define TYPE_NO_LUN 0x7f
106#define COMMAND_COMPLETE 0x00
107#define EXTENDED_MESSAGE 0x01
108#define EXTENDED_MODIFY_DATA_POINTER 0x00
109#define EXTENDED_SDTR 0x01
110#define EXTENDED_EXTENDED_IDENTIFY 0x02
111#define EXTENDED_WDTR 0x03
112#define SAVE_POINTERS 0x02
113#define RESTORE_POINTERS 0x03
114#define DISCONNECT 0x04
115#define INITIATOR_ERROR 0x05
116#define ABORT 0x06
117#define MESSAGE_REJECT 0x07
118#define NOP 0x08
119#define MSG_PARITY_ERROR 0x09
120#define LINKED_CMD_COMPLETE 0x0a
121#define LINKED_FLG_CMD_COMPLETE 0x0b
122#define BUS_DEVICE_RESET 0x0c
123#define INITIATE_RECOVERY 0x0f
124#define RELEASE_RECOVERY 0x10
125#define SIMPLE_QUEUE_TAG 0x20
126#define HEAD_OF_QUEUE_TAG 0x21
127#define ORDERED_QUEUE_TAG 0x22
128#define SCSI_IOCTL_GET_IDLUN 0x5382
129#define SCSI_IOCTL_TAGGED_ENABLE 0x5383
130#define SCSI_IOCTL_TAGGED_DISABLE 0x5384
131#define SCSI_IOCTL_PROBE_HOST 0x5385
132#define SCSI_IOCTL_GET_BUS_NUMBER 0x5386
133
134struct ccs_modesel_head {
135 unsigned char _r1;
136 unsigned char medium;
137 unsigned char _r2;
138 unsigned char block_desc_length;
139 unsigned char density;
140 unsigned char number_blocks_hi;
141 unsigned char number_blocks_med;
142 unsigned char number_blocks_lo;
143 unsigned char _r3;
144 unsigned char block_length_hi;
145 unsigned char block_length_med;
146 unsigned char block_length_lo;
147};
148
149#endif
150
lib/libc/musl/include/scsi/scsi_ioctl.h created+11
......@@ -0,0 +1,11 @@
1#ifndef _SCSI_IOCTL_H
2#define _SCSI_IOCTL_H
3#define SCSI_IOCTL_SEND_COMMAND 1
4#define SCSI_IOCTL_TEST_UNIT_READY 2
5#define SCSI_IOCTL_BENCHMARK_COMMAND 3
6#define SCSI_IOCTL_SYNC 4
7#define SCSI_IOCTL_START_UNIT 5
8#define SCSI_IOCTL_STOP_UNIT 6
9#define SCSI_IOCTL_DOORLOCK 0x5380
10#define SCSI_IOCTL_DOORUNLOCK 0x5381
11#endif
lib/libc/musl/include/scsi/sg.h created+129
......@@ -0,0 +1,129 @@
1#ifndef _SCSI_SG_H
2#define _SCSI_SG_H
3
4#define SG_DXFER_NONE -1
5#define SG_DXFER_TO_DEV -2
6#define SG_DXFER_FROM_DEV -3
7#define SG_DXFER_TO_FROM_DEV -4
8#define SG_FLAG_DIRECT_IO 1
9#define SG_FLAG_LUN_INHIBIT 2
10#define SG_FLAG_NO_DXFER 0x10000
11#define SG_INFO_OK_MASK 0x1
12#define SG_INFO_OK 0x0
13#define SG_INFO_CHECK 0x1
14#define SG_INFO_DIRECT_IO_MASK 0x6
15#define SG_INFO_INDIRECT_IO 0x0
16#define SG_INFO_DIRECT_IO 0x2
17#define SG_INFO_MIXED_IO 0x4
18#define SG_EMULATED_HOST 0x2203
19#define SG_SET_TRANSFORM 0x2204
20#define SG_GET_TRANSFORM 0x2205
21#define SG_SET_RESERVED_SIZE 0x2275
22#define SG_GET_RESERVED_SIZE 0x2272
23#define SG_GET_SCSI_ID 0x2276
24#define SG_SET_FORCE_LOW_DMA 0x2279
25#define SG_GET_LOW_DMA 0x227a
26#define SG_SET_FORCE_PACK_ID 0x227b
27#define SG_GET_PACK_ID 0x227c
28#define SG_GET_NUM_WAITING 0x227d
29#define SG_GET_SG_TABLESIZE 0x227F
30#define SG_GET_VERSION_NUM 0x2282
31#define SG_SCSI_RESET 0x2284
32#define SG_SCSI_RESET_NOTHING 0
33#define SG_SCSI_RESET_DEVICE 1
34#define SG_SCSI_RESET_BUS 2
35#define SG_SCSI_RESET_HOST 3
36#define SG_IO 0x2285
37#define SG_GET_REQUEST_TABLE 0x2286
38#define SG_SET_KEEP_ORPHAN 0x2287
39#define SG_GET_KEEP_ORPHAN 0x2288
40#define SG_SCATTER_SZ (8 * 4096)
41#define SG_DEFAULT_RETRIES 1
42#define SG_DEF_FORCE_LOW_DMA 0
43#define SG_DEF_FORCE_PACK_ID 0
44#define SG_DEF_KEEP_ORPHAN 0
45#define SG_DEF_RESERVED_SIZE SG_SCATTER_SZ
46#define SG_MAX_QUEUE 16
47#define SG_BIG_BUFF SG_DEF_RESERVED_SIZE
48#define SG_MAX_SENSE 16
49#define SG_SET_TIMEOUT 0x2201
50#define SG_GET_TIMEOUT 0x2202
51#define SG_GET_COMMAND_Q 0x2270
52#define SG_SET_COMMAND_Q 0x2271
53#define SG_SET_DEBUG 0x227e
54#define SG_NEXT_CMD_LEN 0x2283
55#define SG_DEFAULT_TIMEOUT (60*100) /* 60*HZ */
56#define SG_DEF_COMMAND_Q 0
57#define SG_DEF_UNDERRUN_FLAG 0
58
59typedef struct sg_iovec {
60 void *iov_base;
61 unsigned long iov_len;
62} sg_iovec_t;
63
64typedef struct sg_io_hdr {
65 int interface_id;
66 int dxfer_direction;
67 unsigned char cmd_len;
68 unsigned char mx_sb_len;
69 unsigned short iovec_count;
70 unsigned dxfer_len;
71 void *dxferp;
72 unsigned char *cmdp;
73 unsigned char *sbp;
74 unsigned timeout;
75 unsigned flags;
76 int pack_id;
77 void *usr_ptr;
78 unsigned char status;
79 unsigned char masked_status;
80 unsigned char msg_status;
81 unsigned char sb_len_wr;
82 unsigned short host_status;
83 unsigned short driver_status;
84 int resid;
85 unsigned int duration;
86 unsigned int info;
87} sg_io_hdr_t;
88
89struct sg_scsi_id {
90 int host_no;
91 int channel;
92 int scsi_id;
93 int lun;
94 int scsi_type;
95 short h_cmd_per_lun;
96 short d_queue_depth;
97 int unused[2];
98};
99
100typedef struct sg_req_info {
101 char req_state;
102 char orphan;
103 char sg_io_owned;
104 char problem;
105 int pack_id;
106 void *usr_ptr;
107 unsigned duration;
108 int unused;
109} sg_req_info_t;
110
111typedef struct sg_io_hdr Sg_io_hdr;
112typedef struct sg_io_vec Sg_io_vec;
113typedef struct sg_scsi_id Sg_scsi_id;
114typedef struct sg_req_info Sg_req_info;
115
116struct sg_header {
117 int pack_len;
118 int reply_len;
119 int pack_id;
120 int result;
121 unsigned twelve_byte:1;
122 unsigned target_status:5;
123 unsigned host_status:8;
124 unsigned driver_status:8;
125 unsigned other_flags:10;
126 unsigned char sense_buffer[SG_MAX_SENSE];
127};
128
129#endif
lib/libc/musl/include/search.h created+63
......@@ -0,0 +1,63 @@
1#ifndef _SEARCH_H
2#define _SEARCH_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_size_t
11#include <bits/alltypes.h>
12
13typedef enum { FIND, ENTER } ACTION;
14typedef enum { preorder, postorder, endorder, leaf } VISIT;
15
16typedef struct entry {
17 char *key;
18 void *data;
19} ENTRY;
20
21int hcreate(size_t);
22void hdestroy(void);
23ENTRY *hsearch(ENTRY, ACTION);
24
25#ifdef _GNU_SOURCE
26struct hsearch_data {
27 struct __tab *__tab;
28 unsigned int __unused1;
29 unsigned int __unused2;
30};
31
32int hcreate_r(size_t, struct hsearch_data *);
33void hdestroy_r(struct hsearch_data *);
34int hsearch_r(ENTRY, ACTION, ENTRY **, struct hsearch_data *);
35#endif
36
37void insque(void *, void *);
38void remque(void *);
39
40void *lsearch(const void *, void *, size_t *, size_t,
41 int (*)(const void *, const void *));
42void *lfind(const void *, const void *, size_t *, size_t,
43 int (*)(const void *, const void *));
44
45void *tdelete(const void *__restrict, void **__restrict, int(*)(const void *, const void *));
46void *tfind(const void *, void *const *, int(*)(const void *, const void *));
47void *tsearch(const void *, void **, int (*)(const void *, const void *));
48void twalk(const void *, void (*)(const void *, VISIT, int));
49
50#ifdef _GNU_SOURCE
51struct qelem {
52 struct qelem *q_forw, *q_back;
53 char q_data[1];
54};
55
56void tdestroy(void *, void (*)(void *));
57#endif
58
59#ifdef __cplusplus
60}
61#endif
62
63#endif
lib/libc/musl/include/semaphore.h created+35
......@@ -0,0 +1,35 @@
1#ifndef _SEMAPHORE_H
2#define _SEMAPHORE_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <features.h>
8
9#define __NEED_time_t
10#define __NEED_struct_timespec
11#include <bits/alltypes.h>
12
13#include <fcntl.h>
14
15#define SEM_FAILED ((sem_t *)0)
16
17typedef struct {
18 volatile int __val[4*sizeof(long)/sizeof(int)];
19} sem_t;
20
21int sem_close(sem_t *);
22int sem_destroy(sem_t *);
23int sem_getvalue(sem_t *__restrict, int *__restrict);
24int sem_init(sem_t *, int, unsigned);
25sem_t *sem_open(const char *, int, ...);
26int sem_post(sem_t *);
27int sem_timedwait(sem_t *__restrict, const struct timespec *__restrict);
28int sem_trywait(sem_t *);
29int sem_unlink(const char *);
30int sem_wait(sem_t *);
31
32#ifdef __cplusplus
33}
34#endif
35#endif
lib/libc/musl/include/setjmp.h created+41
......@@ -0,0 +1,41 @@
1#ifndef _SETJMP_H
2#define _SETJMP_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#include <bits/setjmp.h>
11
12typedef struct __jmp_buf_tag {
13 __jmp_buf __jb;
14 unsigned long __fl;
15 unsigned long __ss[128/sizeof(long)];
16} jmp_buf[1];
17
18#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
19 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
20 || defined(_BSD_SOURCE)
21typedef jmp_buf sigjmp_buf;
22int sigsetjmp (sigjmp_buf, int);
23_Noreturn void siglongjmp (sigjmp_buf, int);
24#endif
25
26#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
27 || defined(_BSD_SOURCE)
28int _setjmp (jmp_buf);
29_Noreturn void _longjmp (jmp_buf, int);
30#endif
31
32int setjmp (jmp_buf);
33_Noreturn void longjmp (jmp_buf, int);
34
35#define setjmp setjmp
36
37#ifdef __cplusplus
38}
39#endif
40
41#endif
lib/libc/musl/include/shadow.h created+44
......@@ -0,0 +1,44 @@
1#ifndef _SHADOW_H
2#define _SHADOW_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define __NEED_FILE
9#define __NEED_size_t
10
11#include <bits/alltypes.h>
12
13#define SHADOW "/etc/shadow"
14
15struct spwd {
16 char *sp_namp;
17 char *sp_pwdp;
18 long sp_lstchg;
19 long sp_min;
20 long sp_max;
21 long sp_warn;
22 long sp_inact;
23 long sp_expire;
24 unsigned long sp_flag;
25};
26
27void setspent(void);
28void endspent(void);
29struct spwd *getspent(void);
30struct spwd *fgetspent(FILE *);
31struct spwd *sgetspent(const char *);
32int putspent(const struct spwd *, FILE *);
33
34struct spwd *getspnam(const char *);
35int getspnam_r(const char *, struct spwd *, char *, size_t, struct spwd **);
36
37int lckpwdf(void);
38int ulckpwdf(void);
39
40#ifdef __cplusplus
41}
42#endif
43
44#endif
lib/libc/musl/include/signal.h created+278
......@@ -0,0 +1,278 @@
1#ifndef _SIGNAL_H
2#define _SIGNAL_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
11 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
12 || defined(_BSD_SOURCE)
13
14#ifdef _GNU_SOURCE
15#define __ucontext ucontext
16#endif
17
18#define __NEED_size_t
19#define __NEED_pid_t
20#define __NEED_uid_t
21#define __NEED_struct_timespec
22#define __NEED_pthread_t
23#define __NEED_pthread_attr_t
24#define __NEED_time_t
25#define __NEED_clock_t
26#define __NEED_sigset_t
27
28#include <bits/alltypes.h>
29
30#define SIG_BLOCK 0
31#define SIG_UNBLOCK 1
32#define SIG_SETMASK 2
33
34#define SI_ASYNCNL (-60)
35#define SI_TKILL (-6)
36#define SI_SIGIO (-5)
37#define SI_ASYNCIO (-4)
38#define SI_MESGQ (-3)
39#define SI_TIMER (-2)
40#define SI_QUEUE (-1)
41#define SI_USER 0
42#define SI_KERNEL 128
43
44typedef struct sigaltstack stack_t;
45
46#endif
47
48#include <bits/signal.h>
49
50#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
51 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
52 || defined(_BSD_SOURCE)
53
54#define SIG_HOLD ((void (*)(int)) 2)
55
56#define FPE_INTDIV 1
57#define FPE_INTOVF 2
58#define FPE_FLTDIV 3
59#define FPE_FLTOVF 4
60#define FPE_FLTUND 5
61#define FPE_FLTRES 6
62#define FPE_FLTINV 7
63#define FPE_FLTSUB 8
64
65#define ILL_ILLOPC 1
66#define ILL_ILLOPN 2
67#define ILL_ILLADR 3
68#define ILL_ILLTRP 4
69#define ILL_PRVOPC 5
70#define ILL_PRVREG 6
71#define ILL_COPROC 7
72#define ILL_BADSTK 8
73
74#define SEGV_MAPERR 1
75#define SEGV_ACCERR 2
76#define SEGV_BNDERR 3
77#define SEGV_PKUERR 4
78
79#define BUS_ADRALN 1
80#define BUS_ADRERR 2
81#define BUS_OBJERR 3
82#define BUS_MCEERR_AR 4
83#define BUS_MCEERR_AO 5
84
85#define CLD_EXITED 1
86#define CLD_KILLED 2
87#define CLD_DUMPED 3
88#define CLD_TRAPPED 4
89#define CLD_STOPPED 5
90#define CLD_CONTINUED 6
91
92union sigval {
93 int sival_int;
94 void *sival_ptr;
95};
96
97typedef struct {
98#ifdef __SI_SWAP_ERRNO_CODE
99 int si_signo, si_code, si_errno;
100#else
101 int si_signo, si_errno, si_code;
102#endif
103 union {
104 char __pad[128 - 2*sizeof(int) - sizeof(long)];
105 struct {
106 union {
107 struct {
108 pid_t si_pid;
109 uid_t si_uid;
110 } __piduid;
111 struct {
112 int si_timerid;
113 int si_overrun;
114 } __timer;
115 } __first;
116 union {
117 union sigval si_value;
118 struct {
119 int si_status;
120 clock_t si_utime, si_stime;
121 } __sigchld;
122 } __second;
123 } __si_common;
124 struct {
125 void *si_addr;
126 short si_addr_lsb;
127 union {
128 struct {
129 void *si_lower;
130 void *si_upper;
131 } __addr_bnd;
132 unsigned si_pkey;
133 } __first;
134 } __sigfault;
135 struct {
136 long si_band;
137 int si_fd;
138 } __sigpoll;
139 struct {
140 void *si_call_addr;
141 int si_syscall;
142 unsigned si_arch;
143 } __sigsys;
144 } __si_fields;
145} siginfo_t;
146#define si_pid __si_fields.__si_common.__first.__piduid.si_pid
147#define si_uid __si_fields.__si_common.__first.__piduid.si_uid
148#define si_status __si_fields.__si_common.__second.__sigchld.si_status
149#define si_utime __si_fields.__si_common.__second.__sigchld.si_utime
150#define si_stime __si_fields.__si_common.__second.__sigchld.si_stime
151#define si_value __si_fields.__si_common.__second.si_value
152#define si_addr __si_fields.__sigfault.si_addr
153#define si_addr_lsb __si_fields.__sigfault.si_addr_lsb
154#define si_lower __si_fields.__sigfault.__first.__addr_bnd.si_lower
155#define si_upper __si_fields.__sigfault.__first.__addr_bnd.si_upper
156#define si_pkey __si_fields.__sigfault.__first.si_pkey
157#define si_band __si_fields.__sigpoll.si_band
158#define si_fd __si_fields.__sigpoll.si_fd
159#define si_timerid __si_fields.__si_common.__first.__timer.si_timerid
160#define si_overrun __si_fields.__si_common.__first.__timer.si_overrun
161#define si_ptr si_value.sival_ptr
162#define si_int si_value.sival_int
163#define si_call_addr __si_fields.__sigsys.si_call_addr
164#define si_syscall __si_fields.__sigsys.si_syscall
165#define si_arch __si_fields.__sigsys.si_arch
166
167struct sigaction {
168 union {
169 void (*sa_handler)(int);
170 void (*sa_sigaction)(int, siginfo_t *, void *);
171 } __sa_handler;
172 sigset_t sa_mask;
173 int sa_flags;
174 void (*sa_restorer)(void);
175};
176#define sa_handler __sa_handler.sa_handler
177#define sa_sigaction __sa_handler.sa_sigaction
178
179struct sigevent {
180 union sigval sigev_value;
181 int sigev_signo;
182 int sigev_notify;
183 void (*sigev_notify_function)(union sigval);
184 pthread_attr_t *sigev_notify_attributes;
185 char __pad[56-3*sizeof(long)];
186};
187
188#define SIGEV_SIGNAL 0
189#define SIGEV_NONE 1
190#define SIGEV_THREAD 2
191
192int __libc_current_sigrtmin(void);
193int __libc_current_sigrtmax(void);
194
195#define SIGRTMIN (__libc_current_sigrtmin())
196#define SIGRTMAX (__libc_current_sigrtmax())
197
198int kill(pid_t, int);
199
200int sigemptyset(sigset_t *);
201int sigfillset(sigset_t *);
202int sigaddset(sigset_t *, int);
203int sigdelset(sigset_t *, int);
204int sigismember(const sigset_t *, int);
205
206int sigprocmask(int, const sigset_t *__restrict, sigset_t *__restrict);
207int sigsuspend(const sigset_t *);
208int sigaction(int, const struct sigaction *__restrict, struct sigaction *__restrict);
209int sigpending(sigset_t *);
210int sigwait(const sigset_t *__restrict, int *__restrict);
211int sigwaitinfo(const sigset_t *__restrict, siginfo_t *__restrict);
212int sigtimedwait(const sigset_t *__restrict, siginfo_t *__restrict, const struct timespec *__restrict);
213int sigqueue(pid_t, int, union sigval);
214
215int pthread_sigmask(int, const sigset_t *__restrict, sigset_t *__restrict);
216int pthread_kill(pthread_t, int);
217
218void psiginfo(const siginfo_t *, const char *);
219void psignal(int, const char *);
220
221#endif
222
223#if defined(_XOPEN_SOURCE) || defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
224int killpg(pid_t, int);
225int sigaltstack(const stack_t *__restrict, stack_t *__restrict);
226int sighold(int);
227int sigignore(int);
228int siginterrupt(int, int);
229int sigpause(int);
230int sigrelse(int);
231void (*sigset(int, void (*)(int)))(int);
232#define TRAP_BRKPT 1
233#define TRAP_TRACE 2
234#define TRAP_BRANCH 3
235#define TRAP_HWBKPT 4
236#define TRAP_UNK 5
237#define POLL_IN 1
238#define POLL_OUT 2
239#define POLL_MSG 3
240#define POLL_ERR 4
241#define POLL_PRI 5
242#define POLL_HUP 6
243#define SS_ONSTACK 1
244#define SS_DISABLE 2
245#define SS_AUTODISARM (1U << 31)
246#define SS_FLAG_BITS SS_AUTODISARM
247#endif
248
249#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
250#define NSIG _NSIG
251typedef void (*sig_t)(int);
252#endif
253
254#ifdef _GNU_SOURCE
255typedef void (*sighandler_t)(int);
256void (*bsd_signal(int, void (*)(int)))(int);
257int sigisemptyset(const sigset_t *);
258int sigorset (sigset_t *, const sigset_t *, const sigset_t *);
259int sigandset(sigset_t *, const sigset_t *, const sigset_t *);
260
261#define SA_NOMASK SA_NODEFER
262#define SA_ONESHOT SA_RESETHAND
263#endif
264
265#define SIG_ERR ((void (*)(int))-1)
266#define SIG_DFL ((void (*)(int)) 0)
267#define SIG_IGN ((void (*)(int)) 1)
268
269typedef int sig_atomic_t;
270
271void (*signal(int, void (*)(int)))(int);
272int raise(int);
273
274#ifdef __cplusplus
275}
276#endif
277
278#endif
lib/libc/musl/include/spawn.h created+78
......@@ -0,0 +1,78 @@
1#ifndef _SPAWN_H
2#define _SPAWN_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_mode_t
11#define __NEED_pid_t
12#define __NEED_sigset_t
13
14#include <bits/alltypes.h>
15
16struct sched_param;
17
18#define POSIX_SPAWN_RESETIDS 1
19#define POSIX_SPAWN_SETPGROUP 2
20#define POSIX_SPAWN_SETSIGDEF 4
21#define POSIX_SPAWN_SETSIGMASK 8
22#define POSIX_SPAWN_SETSCHEDPARAM 16
23#define POSIX_SPAWN_SETSCHEDULER 32
24#define POSIX_SPAWN_USEVFORK 64
25#define POSIX_SPAWN_SETSID 128
26
27typedef struct {
28 int __flags;
29 pid_t __pgrp;
30 sigset_t __def, __mask;
31 int __prio, __pol;
32 void *__fn;
33 char __pad[64-sizeof(void *)];
34} posix_spawnattr_t;
35
36typedef struct {
37 int __pad0[2];
38 void *__actions;
39 int __pad[16];
40} posix_spawn_file_actions_t;
41
42int posix_spawn(pid_t *__restrict, const char *__restrict, const posix_spawn_file_actions_t *,
43 const posix_spawnattr_t *__restrict, char *const *__restrict, char *const *__restrict);
44int posix_spawnp(pid_t *__restrict, const char *__restrict, const posix_spawn_file_actions_t *,
45 const posix_spawnattr_t *__restrict, char *const *__restrict, char *const *__restrict);
46
47int posix_spawnattr_init(posix_spawnattr_t *);
48int posix_spawnattr_destroy(posix_spawnattr_t *);
49
50int posix_spawnattr_setflags(posix_spawnattr_t *, short);
51int posix_spawnattr_getflags(const posix_spawnattr_t *__restrict, short *__restrict);
52
53int posix_spawnattr_setpgroup(posix_spawnattr_t *, pid_t);
54int posix_spawnattr_getpgroup(const posix_spawnattr_t *__restrict, pid_t *__restrict);
55
56int posix_spawnattr_setsigmask(posix_spawnattr_t *__restrict, const sigset_t *__restrict);
57int posix_spawnattr_getsigmask(const posix_spawnattr_t *__restrict, sigset_t *__restrict);
58
59int posix_spawnattr_setsigdefault(posix_spawnattr_t *__restrict, const sigset_t *__restrict);
60int posix_spawnattr_getsigdefault(const posix_spawnattr_t *__restrict, sigset_t *__restrict);
61
62int posix_spawnattr_setschedparam(posix_spawnattr_t *__restrict, const struct sched_param *__restrict);
63int posix_spawnattr_getschedparam(const posix_spawnattr_t *__restrict, struct sched_param *__restrict);
64int posix_spawnattr_setschedpolicy(posix_spawnattr_t *, int);
65int posix_spawnattr_getschedpolicy(const posix_spawnattr_t *__restrict, int *__restrict);
66
67int posix_spawn_file_actions_init(posix_spawn_file_actions_t *);
68int posix_spawn_file_actions_destroy(posix_spawn_file_actions_t *);
69
70int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *__restrict, int, const char *__restrict, int, mode_t);
71int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *, int);
72int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *, int, int);
73
74#ifdef __cplusplus
75}
76#endif
77
78#endif
lib/libc/musl/include/stdalign.h created+20
......@@ -0,0 +1,20 @@
1#ifndef _STDALIGN_H
2#define _STDALIGN_H
3
4#ifndef __cplusplus
5
6/* this whole header only works in C11 or with compiler extensions */
7#if __STDC_VERSION__ < 201112L && defined( __GNUC__)
8#define _Alignas(t) __attribute__((__aligned__(t)))
9#define _Alignof(t) __alignof__(t)
10#endif
11
12#define alignas _Alignas
13#define alignof _Alignof
14
15#endif
16
17#define __alignas_is_defined 1
18#define __alignof_is_defined 1
19
20#endif
lib/libc/musl/include/stdarg.h created+21
......@@ -0,0 +1,21 @@
1#ifndef _STDARG_H
2#define _STDARG_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define __NEED_va_list
9
10#include <bits/alltypes.h>
11
12#define va_start(v,l) __builtin_va_start(v,l)
13#define va_end(v) __builtin_va_end(v)
14#define va_arg(v,l) __builtin_va_arg(v,l)
15#define va_copy(d,s) __builtin_va_copy(d,s)
16
17#ifdef __cplusplus
18}
19#endif
20
21#endif
lib/libc/musl/include/stdbool.h created+14
......@@ -0,0 +1,14 @@
1#ifndef _STDBOOL_H
2#define _STDBOOL_H
3
4#ifndef __cplusplus
5
6#define true 1
7#define false 0
8#define bool _Bool
9
10#endif
11
12#define __bool_true_false_are_defined 1
13
14#endif
lib/libc/musl/include/stdc-predef.h created+10
......@@ -0,0 +1,10 @@
1#ifndef _STDC_PREDEF_H
2#define _STDC_PREDEF_H
3
4#define __STDC_ISO_10646__ 201206L
5
6#if !defined(__GCC_IEC_559) || __GCC_IEC_559 > 0
7#define __STDC_IEC_559__ 1
8#endif
9
10#endif
lib/libc/musl/include/stddef.h created+25
......@@ -0,0 +1,25 @@
1#ifndef _STDDEF_H
2#define _STDDEF_H
3
4#ifdef __cplusplus
5#define NULL 0L
6#else
7#define NULL ((void*)0)
8#endif
9
10#define __NEED_ptrdiff_t
11#define __NEED_size_t
12#define __NEED_wchar_t
13#if __STDC_VERSION__ >= 201112L || __cplusplus >= 201103L
14#define __NEED_max_align_t
15#endif
16
17#include <bits/alltypes.h>
18
19#if __GNUC__ > 3
20#define offsetof(type, member) __builtin_offsetof(type, member)
21#else
22#define offsetof(type, member) ((size_t)( (char *)&(((type *)0)->member) - (char *)0 ))
23#endif
24
25#endif
lib/libc/musl/include/stdint.h created+117
......@@ -0,0 +1,117 @@
1#ifndef _STDINT_H
2#define _STDINT_H
3
4#define __NEED_int8_t
5#define __NEED_int16_t
6#define __NEED_int32_t
7#define __NEED_int64_t
8
9#define __NEED_uint8_t
10#define __NEED_uint16_t
11#define __NEED_uint32_t
12#define __NEED_uint64_t
13
14#define __NEED_intptr_t
15#define __NEED_uintptr_t
16
17#define __NEED_intmax_t
18#define __NEED_uintmax_t
19
20#include <bits/alltypes.h>
21
22typedef int8_t int_fast8_t;
23typedef int64_t int_fast64_t;
24
25typedef int8_t int_least8_t;
26typedef int16_t int_least16_t;
27typedef int32_t int_least32_t;
28typedef int64_t int_least64_t;
29
30typedef uint8_t uint_fast8_t;
31typedef uint64_t uint_fast64_t;
32
33typedef uint8_t uint_least8_t;
34typedef uint16_t uint_least16_t;
35typedef uint32_t uint_least32_t;
36typedef uint64_t uint_least64_t;
37
38#define INT8_MIN (-1-0x7f)
39#define INT16_MIN (-1-0x7fff)
40#define INT32_MIN (-1-0x7fffffff)
41#define INT64_MIN (-1-0x7fffffffffffffff)
42
43#define INT8_MAX (0x7f)
44#define INT16_MAX (0x7fff)
45#define INT32_MAX (0x7fffffff)
46#define INT64_MAX (0x7fffffffffffffff)
47
48#define UINT8_MAX (0xff)
49#define UINT16_MAX (0xffff)
50#define UINT32_MAX (0xffffffffu)
51#define UINT64_MAX (0xffffffffffffffffu)
52
53#define INT_FAST8_MIN INT8_MIN
54#define INT_FAST64_MIN INT64_MIN
55
56#define INT_LEAST8_MIN INT8_MIN
57#define INT_LEAST16_MIN INT16_MIN
58#define INT_LEAST32_MIN INT32_MIN
59#define INT_LEAST64_MIN INT64_MIN
60
61#define INT_FAST8_MAX INT8_MAX
62#define INT_FAST64_MAX INT64_MAX
63
64#define INT_LEAST8_MAX INT8_MAX
65#define INT_LEAST16_MAX INT16_MAX
66#define INT_LEAST32_MAX INT32_MAX
67#define INT_LEAST64_MAX INT64_MAX
68
69#define UINT_FAST8_MAX UINT8_MAX
70#define UINT_FAST64_MAX UINT64_MAX
71
72#define UINT_LEAST8_MAX UINT8_MAX
73#define UINT_LEAST16_MAX UINT16_MAX
74#define UINT_LEAST32_MAX UINT32_MAX
75#define UINT_LEAST64_MAX UINT64_MAX
76
77#define INTMAX_MIN INT64_MIN
78#define INTMAX_MAX INT64_MAX
79#define UINTMAX_MAX UINT64_MAX
80
81#define WINT_MIN 0U
82#define WINT_MAX UINT32_MAX
83
84#if L'\0'-1 > 0
85#define WCHAR_MAX (0xffffffffu+L'\0')
86#define WCHAR_MIN (0+L'\0')
87#else
88#define WCHAR_MAX (0x7fffffff+L'\0')
89#define WCHAR_MIN (-1-0x7fffffff+L'\0')
90#endif
91
92#define SIG_ATOMIC_MIN INT32_MIN
93#define SIG_ATOMIC_MAX INT32_MAX
94
95#include <bits/stdint.h>
96
97#define INT8_C(c) c
98#define INT16_C(c) c
99#define INT32_C(c) c
100
101#define UINT8_C(c) c
102#define UINT16_C(c) c
103#define UINT32_C(c) c ## U
104
105#if UINTPTR_MAX == UINT64_MAX
106#define INT64_C(c) c ## L
107#define UINT64_C(c) c ## UL
108#define INTMAX_C(c) c ## L
109#define UINTMAX_C(c) c ## UL
110#else
111#define INT64_C(c) c ## LL
112#define UINT64_C(c) c ## ULL
113#define INTMAX_C(c) c ## LL
114#define UINTMAX_C(c) c ## ULL
115#endif
116
117#endif
lib/libc/musl/include/stdio.h created+222
......@@ -0,0 +1,222 @@
1#ifndef _STDIO_H
2#define _STDIO_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_FILE
11#define __NEED___isoc_va_list
12#define __NEED_size_t
13
14#if __STDC_VERSION__ < 201112L
15#define __NEED_struct__IO_FILE
16#endif
17
18#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
19 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
20 || defined(_BSD_SOURCE)
21#define __NEED_ssize_t
22#define __NEED_off_t
23#define __NEED_va_list
24#endif
25
26#include <bits/alltypes.h>
27
28#ifdef __cplusplus
29#define NULL 0L
30#else
31#define NULL ((void*)0)
32#endif
33
34#undef EOF
35#define EOF (-1)
36
37#undef SEEK_SET
38#undef SEEK_CUR
39#undef SEEK_END
40#define SEEK_SET 0
41#define SEEK_CUR 1
42#define SEEK_END 2
43
44#define _IOFBF 0
45#define _IOLBF 1
46#define _IONBF 2
47
48#define BUFSIZ 1024
49#define FILENAME_MAX 4096
50#define FOPEN_MAX 1000
51#define TMP_MAX 10000
52#define L_tmpnam 20
53
54typedef union _G_fpos64_t {
55 char __opaque[16];
56 long long __lldata;
57 double __align;
58} fpos_t;
59
60extern FILE *const stdin;
61extern FILE *const stdout;
62extern FILE *const stderr;
63
64#define stdin (stdin)
65#define stdout (stdout)
66#define stderr (stderr)
67
68FILE *fopen(const char *__restrict, const char *__restrict);
69FILE *freopen(const char *__restrict, const char *__restrict, FILE *__restrict);
70int fclose(FILE *);
71
72int remove(const char *);
73int rename(const char *, const char *);
74
75int feof(FILE *);
76int ferror(FILE *);
77int fflush(FILE *);
78void clearerr(FILE *);
79
80int fseek(FILE *, long, int);
81long ftell(FILE *);
82void rewind(FILE *);
83
84int fgetpos(FILE *__restrict, fpos_t *__restrict);
85int fsetpos(FILE *, const fpos_t *);
86
87size_t fread(void *__restrict, size_t, size_t, FILE *__restrict);
88size_t fwrite(const void *__restrict, size_t, size_t, FILE *__restrict);
89
90int fgetc(FILE *);
91int getc(FILE *);
92int getchar(void);
93int ungetc(int, FILE *);
94
95int fputc(int, FILE *);
96int putc(int, FILE *);
97int putchar(int);
98
99char *fgets(char *__restrict, int, FILE *__restrict);
100#if __STDC_VERSION__ < 201112L
101char *gets(char *);
102#endif
103
104int fputs(const char *__restrict, FILE *__restrict);
105int puts(const char *);
106
107int printf(const char *__restrict, ...);
108int fprintf(FILE *__restrict, const char *__restrict, ...);
109int sprintf(char *__restrict, const char *__restrict, ...);
110int snprintf(char *__restrict, size_t, const char *__restrict, ...);
111
112int vprintf(const char *__restrict, __isoc_va_list);
113int vfprintf(FILE *__restrict, const char *__restrict, __isoc_va_list);
114int vsprintf(char *__restrict, const char *__restrict, __isoc_va_list);
115int vsnprintf(char *__restrict, size_t, const char *__restrict, __isoc_va_list);
116
117int scanf(const char *__restrict, ...);
118int fscanf(FILE *__restrict, const char *__restrict, ...);
119int sscanf(const char *__restrict, const char *__restrict, ...);
120int vscanf(const char *__restrict, __isoc_va_list);
121int vfscanf(FILE *__restrict, const char *__restrict, __isoc_va_list);
122int vsscanf(const char *__restrict, const char *__restrict, __isoc_va_list);
123
124void perror(const char *);
125
126int setvbuf(FILE *__restrict, char *__restrict, int, size_t);
127void setbuf(FILE *__restrict, char *__restrict);
128
129char *tmpnam(char *);
130FILE *tmpfile(void);
131
132#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
133 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
134 || defined(_BSD_SOURCE)
135FILE *fmemopen(void *__restrict, size_t, const char *__restrict);
136FILE *open_memstream(char **, size_t *);
137FILE *fdopen(int, const char *);
138FILE *popen(const char *, const char *);
139int pclose(FILE *);
140int fileno(FILE *);
141int fseeko(FILE *, off_t, int);
142off_t ftello(FILE *);
143int dprintf(int, const char *__restrict, ...);
144int vdprintf(int, const char *__restrict, __isoc_va_list);
145void flockfile(FILE *);
146int ftrylockfile(FILE *);
147void funlockfile(FILE *);
148int getc_unlocked(FILE *);
149int getchar_unlocked(void);
150int putc_unlocked(int, FILE *);
151int putchar_unlocked(int);
152ssize_t getdelim(char **__restrict, size_t *__restrict, int, FILE *__restrict);
153ssize_t getline(char **__restrict, size_t *__restrict, FILE *__restrict);
154int renameat(int, const char *, int, const char *);
155char *ctermid(char *);
156#define L_ctermid 20
157#endif
158
159
160#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
161 || defined(_BSD_SOURCE)
162#define P_tmpdir "/tmp"
163char *tempnam(const char *, const char *);
164#endif
165
166#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
167#define L_cuserid 20
168char *cuserid(char *);
169void setlinebuf(FILE *);
170void setbuffer(FILE *, char *, size_t);
171int fgetc_unlocked(FILE *);
172int fputc_unlocked(int, FILE *);
173int fflush_unlocked(FILE *);
174size_t fread_unlocked(void *, size_t, size_t, FILE *);
175size_t fwrite_unlocked(const void *, size_t, size_t, FILE *);
176void clearerr_unlocked(FILE *);
177int feof_unlocked(FILE *);
178int ferror_unlocked(FILE *);
179int fileno_unlocked(FILE *);
180int getw(FILE *);
181int putw(int, FILE *);
182char *fgetln(FILE *, size_t *);
183int asprintf(char **, const char *, ...);
184int vasprintf(char **, const char *, __isoc_va_list);
185#endif
186
187#ifdef _GNU_SOURCE
188char *fgets_unlocked(char *, int, FILE *);
189int fputs_unlocked(const char *, FILE *);
190
191typedef ssize_t (cookie_read_function_t)(void *, char *, size_t);
192typedef ssize_t (cookie_write_function_t)(void *, const char *, size_t);
193typedef int (cookie_seek_function_t)(void *, off_t *, int);
194typedef int (cookie_close_function_t)(void *);
195
196typedef struct _IO_cookie_io_functions_t {
197 cookie_read_function_t *read;
198 cookie_write_function_t *write;
199 cookie_seek_function_t *seek;
200 cookie_close_function_t *close;
201} cookie_io_functions_t;
202
203FILE *fopencookie(void *, const char *, cookie_io_functions_t);
204#endif
205
206#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
207#define tmpfile64 tmpfile
208#define fopen64 fopen
209#define freopen64 freopen
210#define fseeko64 fseeko
211#define ftello64 ftello
212#define fgetpos64 fgetpos
213#define fsetpos64 fsetpos
214#define fpos64_t fpos_t
215#define off64_t off_t
216#endif
217
218#ifdef __cplusplus
219}
220#endif
221
222#endif
lib/libc/musl/include/stdio_ext.h created+34
......@@ -0,0 +1,34 @@
1#ifndef _STDIO_EXT_H
2#define _STDIO_EXT_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stdio.h>
9
10#define FSETLOCKING_QUERY 0
11#define FSETLOCKING_INTERNAL 1
12#define FSETLOCKING_BYCALLER 2
13
14void _flushlbf(void);
15int __fsetlocking(FILE *, int);
16int __fwriting(FILE *);
17int __freading(FILE *);
18int __freadable(FILE *);
19int __fwritable(FILE *);
20int __flbf(FILE *);
21size_t __fbufsize(FILE *);
22size_t __fpending(FILE *);
23int __fpurge(FILE *);
24
25size_t __freadahead(FILE *);
26const char *__freadptr(FILE *, size_t *);
27void __freadptrinc(FILE *, size_t);
28void __fseterr(FILE *);
29
30#ifdef __cplusplus
31}
32#endif
33
34#endif
lib/libc/musl/include/stdlib.h created+174
......@@ -0,0 +1,174 @@
1#ifndef _STDLIB_H
2#define _STDLIB_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#ifdef __cplusplus
11#define NULL 0L
12#else
13#define NULL ((void*)0)
14#endif
15
16#define __NEED_size_t
17#define __NEED_wchar_t
18
19#include <bits/alltypes.h>
20
21int atoi (const char *);
22long atol (const char *);
23long long atoll (const char *);
24double atof (const char *);
25
26float strtof (const char *__restrict, char **__restrict);
27double strtod (const char *__restrict, char **__restrict);
28long double strtold (const char *__restrict, char **__restrict);
29
30long strtol (const char *__restrict, char **__restrict, int);
31unsigned long strtoul (const char *__restrict, char **__restrict, int);
32long long strtoll (const char *__restrict, char **__restrict, int);
33unsigned long long strtoull (const char *__restrict, char **__restrict, int);
34
35int rand (void);
36void srand (unsigned);
37
38void *malloc (size_t);
39void *calloc (size_t, size_t);
40void *realloc (void *, size_t);
41void free (void *);
42void *aligned_alloc(size_t, size_t);
43
44_Noreturn void abort (void);
45int atexit (void (*) (void));
46_Noreturn void exit (int);
47_Noreturn void _Exit (int);
48int at_quick_exit (void (*) (void));
49_Noreturn void quick_exit (int);
50
51char *getenv (const char *);
52
53int system (const char *);
54
55void *bsearch (const void *, const void *, size_t, size_t, int (*)(const void *, const void *));
56void qsort (void *, size_t, size_t, int (*)(const void *, const void *));
57
58int abs (int);
59long labs (long);
60long long llabs (long long);
61
62typedef struct { int quot, rem; } div_t;
63typedef struct { long quot, rem; } ldiv_t;
64typedef struct { long long quot, rem; } lldiv_t;
65
66div_t div (int, int);
67ldiv_t ldiv (long, long);
68lldiv_t lldiv (long long, long long);
69
70int mblen (const char *, size_t);
71int mbtowc (wchar_t *__restrict, const char *__restrict, size_t);
72int wctomb (char *, wchar_t);
73size_t mbstowcs (wchar_t *__restrict, const char *__restrict, size_t);
74size_t wcstombs (char *__restrict, const wchar_t *__restrict, size_t);
75
76#define EXIT_FAILURE 1
77#define EXIT_SUCCESS 0
78
79size_t __ctype_get_mb_cur_max(void);
80#define MB_CUR_MAX (__ctype_get_mb_cur_max())
81
82#define RAND_MAX (0x7fffffff)
83
84
85#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
86 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
87 || defined(_BSD_SOURCE)
88
89#define WNOHANG 1
90#define WUNTRACED 2
91
92#define WEXITSTATUS(s) (((s) & 0xff00) >> 8)
93#define WTERMSIG(s) ((s) & 0x7f)
94#define WSTOPSIG(s) WEXITSTATUS(s)
95#define WIFEXITED(s) (!WTERMSIG(s))
96#define WIFSTOPPED(s) ((short)((((s)&0xffff)*0x10001)>>8) > 0x7f00)
97#define WIFSIGNALED(s) (((s)&0xffff)-1U < 0xffu)
98
99int posix_memalign (void **, size_t, size_t);
100int setenv (const char *, const char *, int);
101int unsetenv (const char *);
102int mkstemp (char *);
103int mkostemp (char *, int);
104char *mkdtemp (char *);
105int getsubopt (char **, char *const *, char **);
106int rand_r (unsigned *);
107
108#endif
109
110
111#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
112 || defined(_BSD_SOURCE)
113char *realpath (const char *__restrict, char *__restrict);
114long int random (void);
115void srandom (unsigned int);
116char *initstate (unsigned int, char *, size_t);
117char *setstate (char *);
118int putenv (char *);
119int posix_openpt (int);
120int grantpt (int);
121int unlockpt (int);
122char *ptsname (int);
123char *l64a (long);
124long a64l (const char *);
125void setkey (const char *);
126double drand48 (void);
127double erand48 (unsigned short [3]);
128long int lrand48 (void);
129long int nrand48 (unsigned short [3]);
130long mrand48 (void);
131long jrand48 (unsigned short [3]);
132void srand48 (long);
133unsigned short *seed48 (unsigned short [3]);
134void lcong48 (unsigned short [7]);
135#endif
136
137#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
138#include <alloca.h>
139char *mktemp (char *);
140int mkstemps (char *, int);
141int mkostemps (char *, int, int);
142void *valloc (size_t);
143void *memalign(size_t, size_t);
144int getloadavg(double *, int);
145int clearenv(void);
146#define WCOREDUMP(s) ((s) & 0x80)
147#define WIFCONTINUED(s) ((s) == 0xffff)
148#endif
149
150#ifdef _GNU_SOURCE
151int ptsname_r(int, char *, size_t);
152char *ecvt(double, int, int *, int *);
153char *fcvt(double, int, int *, int *);
154char *gcvt(double, int, char *);
155struct __locale_struct;
156float strtof_l(const char *__restrict, char **__restrict, struct __locale_struct *);
157double strtod_l(const char *__restrict, char **__restrict, struct __locale_struct *);
158long double strtold_l(const char *__restrict, char **__restrict, struct __locale_struct *);
159#endif
160
161#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
162#define mkstemp64 mkstemp
163#define mkostemp64 mkostemp
164#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
165#define mkstemps64 mkstemps
166#define mkostemps64 mkostemps
167#endif
168#endif
169
170#ifdef __cplusplus
171}
172#endif
173
174#endif
lib/libc/musl/include/stdnoreturn.h created+7
......@@ -0,0 +1,7 @@
1#ifndef _STDNORETURN_H
2#define _STDNORETURN_H
3#ifndef __cplusplus
4#include <features.h>
5#define noreturn _Noreturn
6#endif
7#endif
lib/libc/musl/include/string.h created+105
......@@ -0,0 +1,105 @@
1#ifndef _STRING_H
2#define _STRING_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#ifdef __cplusplus
11#define NULL 0L
12#else
13#define NULL ((void*)0)
14#endif
15
16#define __NEED_size_t
17#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
18 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
19 || defined(_BSD_SOURCE)
20#define __NEED_locale_t
21#endif
22
23#include <bits/alltypes.h>
24
25void *memcpy (void *__restrict, const void *__restrict, size_t);
26void *memmove (void *, const void *, size_t);
27void *memset (void *, int, size_t);
28int memcmp (const void *, const void *, size_t);
29void *memchr (const void *, int, size_t);
30
31char *strcpy (char *__restrict, const char *__restrict);
32char *strncpy (char *__restrict, const char *__restrict, size_t);
33
34char *strcat (char *__restrict, const char *__restrict);
35char *strncat (char *__restrict, const char *__restrict, size_t);
36
37int strcmp (const char *, const char *);
38int strncmp (const char *, const char *, size_t);
39
40int strcoll (const char *, const char *);
41size_t strxfrm (char *__restrict, const char *__restrict, size_t);
42
43char *strchr (const char *, int);
44char *strrchr (const char *, int);
45
46size_t strcspn (const char *, const char *);
47size_t strspn (const char *, const char *);
48char *strpbrk (const char *, const char *);
49char *strstr (const char *, const char *);
50char *strtok (char *__restrict, const char *__restrict);
51
52size_t strlen (const char *);
53
54char *strerror (int);
55
56#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
57#include <strings.h>
58#endif
59
60#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
61 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
62 || defined(_BSD_SOURCE)
63char *strtok_r (char *__restrict, const char *__restrict, char **__restrict);
64int strerror_r (int, char *, size_t);
65char *stpcpy(char *__restrict, const char *__restrict);
66char *stpncpy(char *__restrict, const char *__restrict, size_t);
67size_t strnlen (const char *, size_t);
68char *strdup (const char *);
69char *strndup (const char *, size_t);
70char *strsignal(int);
71char *strerror_l (int, locale_t);
72int strcoll_l (const char *, const char *, locale_t);
73size_t strxfrm_l (char *__restrict, const char *__restrict, size_t, locale_t);
74#endif
75
76#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
77 || defined(_BSD_SOURCE)
78void *memccpy (void *__restrict, const void *__restrict, int, size_t);
79#endif
80
81#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
82char *strsep(char **, const char *);
83size_t strlcat (char *, const char *, size_t);
84size_t strlcpy (char *, const char *, size_t);
85void explicit_bzero (void *, size_t);
86#endif
87
88#ifdef _GNU_SOURCE
89#define strdupa(x) strcpy(alloca(strlen(x)+1),x)
90int strverscmp (const char *, const char *);
91char *strchrnul(const char *, int);
92char *strcasestr(const char *, const char *);
93void *memmem(const void *, size_t, const void *, size_t);
94void *memrchr(const void *, int, size_t);
95void *mempcpy(void *, const void *, size_t);
96#ifndef __cplusplus
97char *basename();
98#endif
99#endif
100
101#ifdef __cplusplus
102}
103#endif
104
105#endif
lib/libc/musl/include/strings.h created+39
......@@ -0,0 +1,39 @@
1#ifndef _STRINGS_H
2#define _STRINGS_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8
9#define __NEED_size_t
10#define __NEED_locale_t
11#include <bits/alltypes.h>
12
13#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_POSIX_SOURCE) \
14 || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE+0 < 200809L) \
15 || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700)
16int bcmp (const void *, const void *, size_t);
17void bcopy (const void *, void *, size_t);
18void bzero (void *, size_t);
19char *index (const char *, int);
20char *rindex (const char *, int);
21#endif
22
23#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
24int ffs (int);
25int ffsl (long);
26int ffsll (long long);
27#endif
28
29int strcasecmp (const char *, const char *);
30int strncasecmp (const char *, const char *, size_t);
31
32int strcasecmp_l (const char *, const char *, locale_t);
33int strncasecmp_l (const char *, const char *, size_t, locale_t);
34
35#ifdef __cplusplus
36}
37#endif
38
39#endif
lib/libc/musl/include/stropts.h created+139
......@@ -0,0 +1,139 @@
1#ifndef _STROPTS_H
2#define _STROPTS_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define __SID ('S' << 8)
9
10#define I_NREAD (__SID | 1)
11#define I_PUSH (__SID | 2)
12#define I_POP (__SID | 3)
13#define I_LOOK (__SID | 4)
14#define I_FLUSH (__SID | 5)
15#define I_SRDOPT (__SID | 6)
16#define I_GRDOPT (__SID | 7)
17#define I_STR (__SID | 8)
18#define I_SETSIG (__SID | 9)
19#define I_GETSIG (__SID |10)
20#define I_FIND (__SID |11)
21#define I_LINK (__SID |12)
22#define I_UNLINK (__SID |13)
23#define I_PEEK (__SID |15)
24#define I_FDINSERT (__SID |16)
25#define I_SENDFD (__SID |17)
26#define I_RECVFD (__SID |14)
27#define I_SWROPT (__SID |19)
28#define I_GWROPT (__SID |20)
29#define I_LIST (__SID |21)
30#define I_PLINK (__SID |22)
31#define I_PUNLINK (__SID |23)
32#define I_FLUSHBAND (__SID |28)
33#define I_CKBAND (__SID |29)
34#define I_GETBAND (__SID |30)
35#define I_ATMARK (__SID |31)
36#define I_SETCLTIME (__SID |32)
37#define I_GETCLTIME (__SID |33)
38#define I_CANPUT (__SID |34)
39
40#define FMNAMESZ 8
41
42#define FLUSHR 0x01
43#define FLUSHW 0x02
44#define FLUSHRW 0x03
45#define FLUSHBAND 0x04
46
47#define S_INPUT 0x0001
48#define S_HIPRI 0x0002
49#define S_OUTPUT 0x0004
50#define S_MSG 0x0008
51#define S_ERROR 0x0010
52#define S_HANGUP 0x0020
53#define S_RDNORM 0x0040
54#define S_WRNORM S_OUTPUT
55#define S_RDBAND 0x0080
56#define S_WRBAND 0x0100
57#define S_BANDURG 0x0200
58
59#define RS_HIPRI 0x01
60
61#define RNORM 0x0000
62#define RMSGD 0x0001
63#define RMSGN 0x0002
64#define RPROTDAT 0x0004
65#define RPROTDIS 0x0008
66#define RPROTNORM 0x0010
67#define RPROTMASK 0x001C
68
69#define SNDZERO 0x001
70#define SNDPIPE 0x002
71
72#define ANYMARK 0x01
73#define LASTMARK 0x02
74
75#define MUXID_ALL (-1)
76
77#define MSG_HIPRI 0x01
78#define MSG_ANY 0x02
79#define MSG_BAND 0x04
80
81#define MORECTL 1
82#define MOREDATA 2
83
84struct bandinfo {
85 unsigned char bi_pri;
86 int bi_flag;
87};
88
89struct strbuf {
90 int maxlen;
91 int len;
92 char *buf;
93};
94
95struct strpeek {
96 struct strbuf ctlbuf;
97 struct strbuf databuf;
98 unsigned flags;
99};
100
101struct strfdinsert {
102 struct strbuf ctlbuf;
103 struct strbuf databuf;
104 unsigned flags;
105 int fildes;
106 int offset;
107};
108
109struct strioctl {
110 int ic_cmd;
111 int ic_timout;
112 int ic_len;
113 char *ic_dp;
114};
115
116struct strrecvfd {
117 int fd;
118 int uid;
119 int gid;
120 char __fill[8];
121};
122
123struct str_mlist {
124 char l_name[FMNAMESZ + 1];
125};
126
127struct str_list {
128 int sl_nmods;
129 struct str_mlist *sl_modlist;
130};
131
132int isastream(int);
133int ioctl(int, int, ...);
134
135#ifdef __cplusplus
136}
137#endif
138
139#endif
lib/libc/musl/include/sys/acct.h created+73
......@@ -0,0 +1,73 @@
1#ifndef _SYS_ACCT_H
2#define _SYS_ACCT_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9#include <endian.h>
10#include <time.h>
11#include <stdint.h>
12
13#define ACCT_COMM 16
14
15typedef uint16_t comp_t;
16
17struct acct {
18 char ac_flag;
19 uint16_t ac_uid;
20 uint16_t ac_gid;
21 uint16_t ac_tty;
22 uint32_t ac_btime;
23 comp_t ac_utime;
24 comp_t ac_stime;
25 comp_t ac_etime;
26 comp_t ac_mem;
27 comp_t ac_io;
28 comp_t ac_rw;
29 comp_t ac_minflt;
30 comp_t ac_majflt;
31 comp_t ac_swaps;
32 uint32_t ac_exitcode;
33 char ac_comm[ACCT_COMM+1];
34 char ac_pad[10];
35};
36
37
38struct acct_v3 {
39 char ac_flag;
40 char ac_version;
41 uint16_t ac_tty;
42 uint32_t ac_exitcode;
43 uint32_t ac_uid;
44 uint32_t ac_gid;
45 uint32_t ac_pid;
46 uint32_t ac_ppid;
47 uint32_t ac_btime;
48 float ac_etime;
49 comp_t ac_utime;
50 comp_t ac_stime;
51 comp_t ac_mem;
52 comp_t ac_io;
53 comp_t ac_rw;
54 comp_t ac_minflt;
55 comp_t ac_majflt;
56 comp_t ac_swaps;
57 char ac_comm[ACCT_COMM];
58};
59
60#define AFORK 1
61#define ASU 2
62#define ACORE 8
63#define AXSIG 16
64#define ACCT_BYTEORDER (128*(__BYTE_ORDER==__BIG_ENDIAN))
65#define AHZ 100
66
67int acct(const char *);
68
69#ifdef __cplusplus
70}
71#endif
72
73#endif
lib/libc/musl/include/sys/auxv.h created+17
......@@ -0,0 +1,17 @@
1#ifndef _SYS_AUXV_H
2#define _SYS_AUXV_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <elf.h>
9#include <bits/hwcap.h>
10
11unsigned long getauxval(unsigned long);
12
13#ifdef __cplusplus
14}
15#endif
16
17#endif
lib/libc/musl/include/sys/cachectl.h created+22
......@@ -0,0 +1,22 @@
1#ifndef _SYS_CACHECTL_H
2#define _SYS_CACHECTL_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define ICACHE (1<<0)
9#define DCACHE (1<<1)
10#define BCACHE (ICACHE|DCACHE)
11#define CACHEABLE 0
12#define UNCACHEABLE 1
13
14int cachectl(void *, int, int);
15int cacheflush(void *, int, int);
16int _flush_cache(void *, int, int);
17
18#ifdef __cplusplus
19}
20#endif
21
22#endif
lib/libc/musl/include/sys/dir.h created+2
......@@ -0,0 +1,2 @@
1#include <dirent.h>
2#define direct dirent
lib/libc/musl/include/sys/epoll.h created+69
......@@ -0,0 +1,69 @@
1#ifndef _SYS_EPOLL_H
2#define _SYS_EPOLL_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stdint.h>
9#include <sys/types.h>
10#include <fcntl.h>
11
12#define __NEED_sigset_t
13
14#include <bits/alltypes.h>
15
16#define EPOLL_CLOEXEC O_CLOEXEC
17#define EPOLL_NONBLOCK O_NONBLOCK
18
19enum EPOLL_EVENTS { __EPOLL_DUMMY };
20#define EPOLLIN 0x001
21#define EPOLLPRI 0x002
22#define EPOLLOUT 0x004
23#define EPOLLRDNORM 0x040
24#define EPOLLNVAL 0x020
25#define EPOLLRDBAND 0x080
26#define EPOLLWRNORM 0x100
27#define EPOLLWRBAND 0x200
28#define EPOLLMSG 0x400
29#define EPOLLERR 0x008
30#define EPOLLHUP 0x010
31#define EPOLLRDHUP 0x2000
32#define EPOLLEXCLUSIVE (1U<<28)
33#define EPOLLWAKEUP (1U<<29)
34#define EPOLLONESHOT (1U<<30)
35#define EPOLLET (1U<<31)
36
37#define EPOLL_CTL_ADD 1
38#define EPOLL_CTL_DEL 2
39#define EPOLL_CTL_MOD 3
40
41typedef union epoll_data {
42 void *ptr;
43 int fd;
44 uint32_t u32;
45 uint64_t u64;
46} epoll_data_t;
47
48struct epoll_event {
49 uint32_t events;
50 epoll_data_t data;
51}
52#ifdef __x86_64__
53__attribute__ ((__packed__))
54#endif
55;
56
57
58int epoll_create(int);
59int epoll_create1(int);
60int epoll_ctl(int, int, int, struct epoll_event *);
61int epoll_wait(int, struct epoll_event *, int, int);
62int epoll_pwait(int, struct epoll_event *, int, int, const sigset_t *);
63
64
65#ifdef __cplusplus
66}
67#endif
68
69#endif /* sys/epoll.h */
lib/libc/musl/include/sys/errno.h created+2
......@@ -0,0 +1,2 @@
1#warning redirecting incorrect #include <sys/errno.h> to <errno.h>
2#include <errno.h>
lib/libc/musl/include/sys/eventfd.h created+26
......@@ -0,0 +1,26 @@
1#ifndef _SYS_EVENTFD_H
2#define _SYS_EVENTFD_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stdint.h>
9#include <fcntl.h>
10
11typedef uint64_t eventfd_t;
12
13#define EFD_SEMAPHORE 1
14#define EFD_CLOEXEC O_CLOEXEC
15#define EFD_NONBLOCK O_NONBLOCK
16
17int eventfd(unsigned int, int);
18int eventfd_read(int, eventfd_t *);
19int eventfd_write(int, eventfd_t);
20
21
22#ifdef __cplusplus
23}
24#endif
25
26#endif /* sys/eventfd.h */
lib/libc/musl/include/sys/fanotify.h created+105
......@@ -0,0 +1,105 @@
1#ifndef _FANOTIFY_H
2#define _FANOTIFY_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <sys/statfs.h>
9
10struct fanotify_event_metadata {
11 unsigned event_len;
12 unsigned char vers;
13 unsigned char reserved;
14 unsigned short metadata_len;
15 unsigned long long mask
16#ifdef __GNUC__
17 __attribute__((__aligned__(8)))
18#endif
19 ;
20 int fd;
21 int pid;
22};
23
24struct fanotify_event_info_header {
25 unsigned char info_type;
26 unsigned char pad;
27 unsigned short len;
28};
29
30struct fanotify_event_info_fid {
31 struct fanotify_event_info_header hdr;
32 fsid_t fsid;
33 unsigned char handle[];
34};
35
36struct fanotify_response {
37 int fd;
38 unsigned response;
39};
40
41#define FAN_ACCESS 0x01
42#define FAN_MODIFY 0x02
43#define FAN_ATTRIB 0x04
44#define FAN_CLOSE_WRITE 0x08
45#define FAN_CLOSE_NOWRITE 0x10
46#define FAN_OPEN 0x20
47#define FAN_MOVED_FROM 0x40
48#define FAN_MOVED_TO 0x80
49#define FAN_CREATE 0x100
50#define FAN_DELETE 0x200
51#define FAN_DELETE_SELF 0x400
52#define FAN_MOVE_SELF 0x800
53#define FAN_OPEN_EXEC 0x1000
54#define FAN_Q_OVERFLOW 0x4000
55#define FAN_OPEN_PERM 0x10000
56#define FAN_ACCESS_PERM 0x20000
57#define FAN_OPEN_EXEC_PERM 0x40000
58#define FAN_ONDIR 0x40000000
59#define FAN_EVENT_ON_CHILD 0x08000000
60#define FAN_CLOSE (FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE)
61#define FAN_MOVE (FAN_MOVED_FROM | FAN_MOVED_TO)
62#define FAN_CLOEXEC 0x01
63#define FAN_NONBLOCK 0x02
64#define FAN_CLASS_NOTIF 0
65#define FAN_CLASS_CONTENT 0x04
66#define FAN_CLASS_PRE_CONTENT 0x08
67#define FAN_ALL_CLASS_BITS (FAN_CLASS_NOTIF | FAN_CLASS_CONTENT | FAN_CLASS_PRE_CONTENT)
68#define FAN_UNLIMITED_QUEUE 0x10
69#define FAN_UNLIMITED_MARKS 0x20
70#define FAN_ENABLE_AUDIT 0x40
71#define FAN_REPORT_TID 0x100
72#define FAN_REPORT_FID 0x200
73#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
75#define FAN_MARK_REMOVE 0x02
76#define FAN_MARK_DONT_FOLLOW 0x04
77#define FAN_MARK_ONLYDIR 0x08
78#define FAN_MARK_IGNORED_MASK 0x20
79#define FAN_MARK_IGNORED_SURV_MODIFY 0x40
80#define FAN_MARK_FLUSH 0x80
81#define FAN_MARK_INODE 0x00
82#define FAN_MARK_MOUNT 0x10
83#define FAN_MARK_FILESYSTEM 0x100
84#define FAN_MARK_TYPE_MASK (FAN_MARK_INODE | FAN_MARK_MOUNT | FAN_MARK_FILESYSTEM)
85#define FAN_ALL_MARK_FLAGS (FAN_MARK_ADD | FAN_MARK_REMOVE | FAN_MARK_DONT_FOLLOW | FAN_MARK_ONLYDIR | FAN_MARK_MOUNT | FAN_MARK_IGNORED_MASK | FAN_MARK_IGNORED_SURV_MODIFY | FAN_MARK_FLUSH)
86#define FAN_ALL_EVENTS (FAN_ACCESS | FAN_MODIFY | FAN_CLOSE | FAN_OPEN)
87#define FAN_ALL_PERM_EVENTS (FAN_OPEN_PERM | FAN_ACCESS_PERM)
88#define FAN_ALL_OUTGOING_EVENTS (FAN_ALL_EVENTS | FAN_ALL_PERM_EVENTS | FAN_Q_OVERFLOW)
89#define FANOTIFY_METADATA_VERSION 3
90#define FAN_EVENT_INFO_TYPE_FID 1
91#define FAN_ALLOW 0x01
92#define FAN_DENY 0x02
93#define FAN_AUDIT 0x10
94#define FAN_NOFD -1
95#define FAN_EVENT_METADATA_LEN (sizeof(struct fanotify_event_metadata))
96#define FAN_EVENT_NEXT(meta, len) ((len) -= (meta)->event_len, (struct fanotify_event_metadata*)(((char *)(meta)) + (meta)->event_len))
97#define FAN_EVENT_OK(meta, len) ((long)(len) >= (long)FAN_EVENT_METADATA_LEN && (long)(meta)->event_len >= (long)FAN_EVENT_METADATA_LEN && (long)(meta)->event_len <= (long)(len))
98
99int fanotify_init(unsigned, unsigned);
100int fanotify_mark(int, unsigned, unsigned long long, int, const char *);
101
102#ifdef __cplusplus
103}
104#endif
105#endif
lib/libc/musl/include/sys/fcntl.h created+2
......@@ -0,0 +1,2 @@
1#warning redirecting incorrect #include <sys/fcntl.h> to <fcntl.h>
2#include <fcntl.h>
lib/libc/musl/include/sys/file.h created+21
......@@ -0,0 +1,21 @@
1#ifndef _SYS_FILE_H
2#define _SYS_FILE_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#define LOCK_SH 1
8#define LOCK_EX 2
9#define LOCK_NB 4
10#define LOCK_UN 8
11
12#define L_SET 0
13#define L_INCR 1
14#define L_XTND 2
15
16int flock(int, int);
17
18#ifdef __cplusplus
19}
20#endif
21#endif
lib/libc/musl/include/sys/fsuid.h created+20
......@@ -0,0 +1,20 @@
1#ifndef _SYS_FSUID_H
2#define _SYS_FSUID_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define __NEED_uid_t
9#define __NEED_gid_t
10
11#include <bits/alltypes.h>
12
13int setfsuid(uid_t);
14int setfsgid(gid_t);
15
16#ifdef __cplusplus
17}
18#endif
19
20#endif
lib/libc/musl/include/sys/inotify.h created+58
......@@ -0,0 +1,58 @@
1#ifndef _SYS_INOTIFY_H
2#define _SYS_INOTIFY_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stdint.h>
9#include <fcntl.h>
10
11struct inotify_event {
12 int wd;
13 uint32_t mask, cookie, len;
14 char name[];
15};
16
17#define IN_CLOEXEC O_CLOEXEC
18#define IN_NONBLOCK O_NONBLOCK
19
20#define IN_ACCESS 0x00000001
21#define IN_MODIFY 0x00000002
22#define IN_ATTRIB 0x00000004
23#define IN_CLOSE_WRITE 0x00000008
24#define IN_CLOSE_NOWRITE 0x00000010
25#define IN_CLOSE (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE)
26#define IN_OPEN 0x00000020
27#define IN_MOVED_FROM 0x00000040
28#define IN_MOVED_TO 0x00000080
29#define IN_MOVE (IN_MOVED_FROM | IN_MOVED_TO)
30#define IN_CREATE 0x00000100
31#define IN_DELETE 0x00000200
32#define IN_DELETE_SELF 0x00000400
33#define IN_MOVE_SELF 0x00000800
34#define IN_ALL_EVENTS 0x00000fff
35
36#define IN_UNMOUNT 0x00002000
37#define IN_Q_OVERFLOW 0x00004000
38#define IN_IGNORED 0x00008000
39
40#define IN_ONLYDIR 0x01000000
41#define IN_DONT_FOLLOW 0x02000000
42#define IN_EXCL_UNLINK 0x04000000
43#define IN_MASK_CREATE 0x10000000
44#define IN_MASK_ADD 0x20000000
45
46#define IN_ISDIR 0x40000000
47#define IN_ONESHOT 0x80000000
48
49int inotify_init(void);
50int inotify_init1(int);
51int inotify_add_watch(int, const char *, uint32_t);
52int inotify_rm_watch(int, int);
53
54#ifdef __cplusplus
55}
56#endif
57
58#endif
lib/libc/musl/include/sys/io.h created+17
......@@ -0,0 +1,17 @@
1#ifndef _SYS_IO_H
2#define _SYS_IO_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <features.h>
8
9#include <bits/io.h>
10
11int iopl(int);
12int ioperm(unsigned long, unsigned long, int);
13
14#ifdef __cplusplus
15}
16#endif
17#endif
lib/libc/musl/include/sys/ioctl.h created+124
......@@ -0,0 +1,124 @@
1#ifndef _SYS_IOCTL_H
2#define _SYS_IOCTL_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <bits/ioctl.h>
8
9#define N_TTY 0
10#define N_SLIP 1
11#define N_MOUSE 2
12#define N_PPP 3
13#define N_STRIP 4
14#define N_AX25 5
15#define N_X25 6
16#define N_6PACK 7
17#define N_MASC 8
18#define N_R3964 9
19#define N_PROFIBUS_FDL 10
20#define N_IRDA 11
21#define N_SMSBLOCK 12
22#define N_HDLC 13
23#define N_SYNC_PPP 14
24#define N_HCI 15
25#define N_GIGASET_M101 16
26#define N_SLCAN 17
27#define N_PPS 18
28#define N_V253 19
29#define N_CAIF 20
30#define N_GSM0710 21
31#define N_TI_WL 22
32#define N_TRACESINK 23
33#define N_TRACEROUTER 24
34#define N_NCI 25
35#define N_SPEAKUP 26
36#define N_NULL 27
37
38#define TIOCPKT_DATA 0
39#define TIOCPKT_FLUSHREAD 1
40#define TIOCPKT_FLUSHWRITE 2
41#define TIOCPKT_STOP 4
42#define TIOCPKT_START 8
43#define TIOCPKT_NOSTOP 16
44#define TIOCPKT_DOSTOP 32
45#define TIOCPKT_IOCTL 64
46
47#define TIOCSER_TEMT 1
48
49struct winsize {
50 unsigned short ws_row;
51 unsigned short ws_col;
52 unsigned short ws_xpixel;
53 unsigned short ws_ypixel;
54};
55
56#define SIOCADDRT 0x890B
57#define SIOCDELRT 0x890C
58#define SIOCRTMSG 0x890D
59
60#define SIOCGIFNAME 0x8910
61#define SIOCSIFLINK 0x8911
62#define SIOCGIFCONF 0x8912
63#define SIOCGIFFLAGS 0x8913
64#define SIOCSIFFLAGS 0x8914
65#define SIOCGIFADDR 0x8915
66#define SIOCSIFADDR 0x8916
67#define SIOCGIFDSTADDR 0x8917
68#define SIOCSIFDSTADDR 0x8918
69#define SIOCGIFBRDADDR 0x8919
70#define SIOCSIFBRDADDR 0x891a
71#define SIOCGIFNETMASK 0x891b
72#define SIOCSIFNETMASK 0x891c
73#define SIOCGIFMETRIC 0x891d
74#define SIOCSIFMETRIC 0x891e
75#define SIOCGIFMEM 0x891f
76#define SIOCSIFMEM 0x8920
77#define SIOCGIFMTU 0x8921
78#define SIOCSIFMTU 0x8922
79#define SIOCSIFNAME 0x8923
80#define SIOCSIFHWADDR 0x8924
81#define SIOCGIFENCAP 0x8925
82#define SIOCSIFENCAP 0x8926
83#define SIOCGIFHWADDR 0x8927
84#define SIOCGIFSLAVE 0x8929
85#define SIOCSIFSLAVE 0x8930
86#define SIOCADDMULTI 0x8931
87#define SIOCDELMULTI 0x8932
88#define SIOCGIFINDEX 0x8933
89#define SIOGIFINDEX SIOCGIFINDEX
90#define SIOCSIFPFLAGS 0x8934
91#define SIOCGIFPFLAGS 0x8935
92#define SIOCDIFADDR 0x8936
93#define SIOCSIFHWBROADCAST 0x8937
94#define SIOCGIFCOUNT 0x8938
95
96#define SIOCGIFBR 0x8940
97#define SIOCSIFBR 0x8941
98
99#define SIOCGIFTXQLEN 0x8942
100#define SIOCSIFTXQLEN 0x8943
101
102#define SIOCDARP 0x8953
103#define SIOCGARP 0x8954
104#define SIOCSARP 0x8955
105
106#define SIOCDRARP 0x8960
107#define SIOCGRARP 0x8961
108#define SIOCSRARP 0x8962
109
110#define SIOCGIFMAP 0x8970
111#define SIOCSIFMAP 0x8971
112
113#define SIOCADDDLCI 0x8980
114#define SIOCDELDLCI 0x8981
115
116#define SIOCDEVPRIVATE 0x89F0
117#define SIOCPROTOPRIVATE 0x89E0
118
119int ioctl (int, int, ...);
120
121#ifdef __cplusplus
122}
123#endif
124#endif
lib/libc/musl/include/sys/ipc.h created+42
......@@ -0,0 +1,42 @@
1#ifndef _SYS_IPC_H
2#define _SYS_IPC_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <features.h>
8
9#define __NEED_uid_t
10#define __NEED_gid_t
11#define __NEED_mode_t
12#define __NEED_key_t
13
14#include <bits/alltypes.h>
15
16#define __ipc_perm_key __key
17#define __ipc_perm_seq __seq
18
19#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
20#define __key key
21#define __seq seq
22#endif
23
24#include <bits/ipc.h>
25
26#define IPC_CREAT 01000
27#define IPC_EXCL 02000
28#define IPC_NOWAIT 04000
29
30#define IPC_RMID 0
31#define IPC_SET 1
32#define IPC_STAT 2
33#define IPC_INFO 3
34
35#define IPC_PRIVATE ((key_t) 0)
36
37key_t ftok (const char *, int);
38
39#ifdef __cplusplus
40}
41#endif
42#endif
lib/libc/musl/include/sys/kd.h created+1
......@@ -0,0 +1 @@
1#include <bits/kd.h>
lib/libc/musl/include/sys/klog.h created+14
......@@ -0,0 +1,14 @@
1#ifndef _SYS_KLOG_H
2#define _SYS_KLOG_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8int klogctl (int, char *, int);
9
10#ifdef __cplusplus
11}
12#endif
13
14#endif
lib/libc/musl/include/sys/membarrier.h created+17
......@@ -0,0 +1,17 @@
1#ifndef _SYS_MEMBARRIER_H
2#define _SYS_MEMBARRIER_H
3
4#define MEMBARRIER_CMD_QUERY 0
5#define MEMBARRIER_CMD_GLOBAL 1
6#define MEMBARRIER_CMD_GLOBAL_EXPEDITED 2
7#define MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED 4
8#define MEMBARRIER_CMD_PRIVATE_EXPEDITED 8
9#define MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED 16
10#define MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE 32
11#define MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE 64
12
13#define MEMBARRIER_CMD_SHARED MEMBARRIER_CMD_GLOBAL
14
15int membarrier(int, int);
16
17#endif
lib/libc/musl/include/sys/mman.h created+148
......@@ -0,0 +1,148 @@
1#ifndef _SYS_MMAN_H
2#define _SYS_MMAN_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <features.h>
8
9#define __NEED_mode_t
10#define __NEED_size_t
11#define __NEED_off_t
12
13#if defined(_GNU_SOURCE)
14#define __NEED_ssize_t
15#endif
16
17#include <bits/alltypes.h>
18
19#define MAP_FAILED ((void *) -1)
20
21#define MAP_SHARED 0x01
22#define MAP_PRIVATE 0x02
23#define MAP_SHARED_VALIDATE 0x03
24#define MAP_TYPE 0x0f
25#define MAP_FIXED 0x10
26#define MAP_ANON 0x20
27#define MAP_ANONYMOUS MAP_ANON
28#define MAP_NORESERVE 0x4000
29#define MAP_GROWSDOWN 0x0100
30#define MAP_DENYWRITE 0x0800
31#define MAP_EXECUTABLE 0x1000
32#define MAP_LOCKED 0x2000
33#define MAP_POPULATE 0x8000
34#define MAP_NONBLOCK 0x10000
35#define MAP_STACK 0x20000
36#define MAP_HUGETLB 0x40000
37#define MAP_SYNC 0x80000
38#define MAP_FIXED_NOREPLACE 0x100000
39#define MAP_FILE 0
40
41#define MAP_HUGE_SHIFT 26
42#define MAP_HUGE_MASK 0x3f
43#define MAP_HUGE_64KB (16 << 26)
44#define MAP_HUGE_512KB (19 << 26)
45#define MAP_HUGE_1MB (20 << 26)
46#define MAP_HUGE_2MB (21 << 26)
47#define MAP_HUGE_8MB (23 << 26)
48#define MAP_HUGE_16MB (24 << 26)
49#define MAP_HUGE_32MB (25 << 26)
50#define MAP_HUGE_256MB (28 << 26)
51#define MAP_HUGE_512MB (29 << 26)
52#define MAP_HUGE_1GB (30 << 26)
53#define MAP_HUGE_2GB (31 << 26)
54#define MAP_HUGE_16GB (34U << 26)
55
56#define PROT_NONE 0
57#define PROT_READ 1
58#define PROT_WRITE 2
59#define PROT_EXEC 4
60#define PROT_GROWSDOWN 0x01000000
61#define PROT_GROWSUP 0x02000000
62
63#define MS_ASYNC 1
64#define MS_INVALIDATE 2
65#define MS_SYNC 4
66
67#define MCL_CURRENT 1
68#define MCL_FUTURE 2
69#define MCL_ONFAULT 4
70
71#define POSIX_MADV_NORMAL 0
72#define POSIX_MADV_RANDOM 1
73#define POSIX_MADV_SEQUENTIAL 2
74#define POSIX_MADV_WILLNEED 3
75#define POSIX_MADV_DONTNEED 4
76
77#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
78#define MADV_NORMAL 0
79#define MADV_RANDOM 1
80#define MADV_SEQUENTIAL 2
81#define MADV_WILLNEED 3
82#define MADV_DONTNEED 4
83#define MADV_FREE 8
84#define MADV_REMOVE 9
85#define MADV_DONTFORK 10
86#define MADV_DOFORK 11
87#define MADV_MERGEABLE 12
88#define MADV_UNMERGEABLE 13
89#define MADV_HUGEPAGE 14
90#define MADV_NOHUGEPAGE 15
91#define MADV_DONTDUMP 16
92#define MADV_DODUMP 17
93#define MADV_WIPEONFORK 18
94#define MADV_KEEPONFORK 19
95#define MADV_HWPOISON 100
96#define MADV_SOFT_OFFLINE 101
97#endif
98
99#ifdef _GNU_SOURCE
100#define MREMAP_MAYMOVE 1
101#define MREMAP_FIXED 2
102
103#define MLOCK_ONFAULT 0x01
104
105#define MFD_CLOEXEC 0x0001U
106#define MFD_ALLOW_SEALING 0x0002U
107#define MFD_HUGETLB 0x0004U
108#endif
109
110#include <bits/mman.h>
111
112void *mmap (void *, size_t, int, int, int, off_t);
113int munmap (void *, size_t);
114
115int mprotect (void *, size_t, int);
116int msync (void *, size_t, int);
117
118int posix_madvise (void *, size_t, int);
119
120int mlock (const void *, size_t);
121int munlock (const void *, size_t);
122int mlockall (int);
123int munlockall (void);
124
125#ifdef _GNU_SOURCE
126void *mremap (void *, size_t, size_t, int, ...);
127int remap_file_pages (void *, size_t, int, size_t, int);
128int memfd_create (const char *, unsigned);
129int mlock2 (const void *, size_t, unsigned);
130#endif
131
132#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
133int madvise (void *, size_t, int);
134int mincore (void *, size_t, unsigned char *);
135#endif
136
137int shm_open (const char *, int, mode_t);
138int shm_unlink (const char *);
139
140#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
141#define mmap64 mmap
142#define off64_t off_t
143#endif
144
145#ifdef __cplusplus
146}
147#endif
148#endif
lib/libc/musl/include/sys/mount.h created+74
......@@ -0,0 +1,74 @@
1#ifndef _SYS_MOUNT_H
2#define _SYS_MOUNT_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <sys/ioctl.h>
9
10#define BLKROSET _IO(0x12, 93)
11#define BLKROGET _IO(0x12, 94)
12#define BLKRRPART _IO(0x12, 95)
13#define BLKGETSIZE _IO(0x12, 96)
14#define BLKFLSBUF _IO(0x12, 97)
15#define BLKRASET _IO(0x12, 98)
16#define BLKRAGET _IO(0x12, 99)
17#define BLKFRASET _IO(0x12,100)
18#define BLKFRAGET _IO(0x12,101)
19#define BLKSECTSET _IO(0x12,102)
20#define BLKSECTGET _IO(0x12,103)
21#define BLKSSZGET _IO(0x12,104)
22#define BLKBSZGET _IOR(0x12,112,size_t)
23#define BLKBSZSET _IOW(0x12,113,size_t)
24#define BLKGETSIZE64 _IOR(0x12,114,size_t)
25
26#define MS_RDONLY 1
27#define MS_NOSUID 2
28#define MS_NODEV 4
29#define MS_NOEXEC 8
30#define MS_SYNCHRONOUS 16
31#define MS_REMOUNT 32
32#define MS_MANDLOCK 64
33#define MS_DIRSYNC 128
34#define MS_NOATIME 1024
35#define MS_NODIRATIME 2048
36#define MS_BIND 4096
37#define MS_MOVE 8192
38#define MS_REC 16384
39#define MS_SILENT 32768
40#define MS_POSIXACL (1<<16)
41#define MS_UNBINDABLE (1<<17)
42#define MS_PRIVATE (1<<18)
43#define MS_SLAVE (1<<19)
44#define MS_SHARED (1<<20)
45#define MS_RELATIME (1<<21)
46#define MS_KERNMOUNT (1<<22)
47#define MS_I_VERSION (1<<23)
48#define MS_STRICTATIME (1<<24)
49#define MS_LAZYTIME (1<<25)
50#define MS_NOREMOTELOCK (1<<27)
51#define MS_NOSEC (1<<28)
52#define MS_BORN (1<<29)
53#define MS_ACTIVE (1<<30)
54#define MS_NOUSER (1U<<31)
55
56#define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_I_VERSION|MS_LAZYTIME)
57
58#define MS_MGC_VAL 0xc0ed0000
59#define MS_MGC_MSK 0xffff0000
60
61#define MNT_FORCE 1
62#define MNT_DETACH 2
63#define MNT_EXPIRE 4
64#define UMOUNT_NOFOLLOW 8
65
66int mount(const char *, const char *, const char *, unsigned long, const void *);
67int umount(const char *);
68int umount2(const char *, int);
69
70#ifdef __cplusplus
71}
72#endif
73
74#endif
lib/libc/musl/include/sys/msg.h created+53
......@@ -0,0 +1,53 @@
1#ifndef _SYS_MSG_H
2#define _SYS_MSG_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <sys/ipc.h>
9
10#define __NEED_pid_t
11#define __NEED_key_t
12#define __NEED_time_t
13#define __NEED_size_t
14#define __NEED_ssize_t
15
16#include <bits/alltypes.h>
17
18typedef unsigned long msgqnum_t;
19typedef unsigned long msglen_t;
20
21#include <bits/msg.h>
22
23#define __msg_cbytes msg_cbytes
24
25#define MSG_NOERROR 010000
26#define MSG_EXCEPT 020000
27
28#define MSG_STAT 11
29#define MSG_INFO 12
30#define MSG_STAT_ANY 13
31
32struct msginfo {
33 int msgpool, msgmap, msgmax, msgmnb, msgmni, msgssz, msgtql;
34 unsigned short msgseg;
35};
36
37int msgctl (int, int, struct msqid_ds *);
38int msgget (key_t, int);
39ssize_t msgrcv (int, void *, size_t, long, int);
40int msgsnd (int, const void *, size_t, int);
41
42#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
43struct msgbuf {
44 long mtype;
45 char mtext[1];
46};
47#endif
48
49#ifdef __cplusplus
50}
51#endif
52
53#endif
lib/libc/musl/include/sys/mtio.h created+188
......@@ -0,0 +1,188 @@
1#ifndef _SYS_MTIO_H
2#define _SYS_MTIO_H
3
4#include <sys/types.h>
5#include <sys/ioctl.h>
6
7struct mtop {
8 short mt_op;
9 int mt_count;
10};
11
12#define _IOT_mtop _IOT (_IOTS (short), 1, _IOTS (int), 1, 0, 0)
13#define _IOT_mtget _IOT (_IOTS (long), 7, 0, 0, 0, 0)
14#define _IOT_mtpos _IOT_SIMPLE (long)
15#define _IOT_mtconfiginfo _IOT (_IOTS (long), 2, _IOTS (short), 3, _IOTS (long), 1)
16
17
18#define MTRESET 0
19#define MTFSF 1
20#define MTBSF 2
21#define MTFSR 3
22#define MTBSR 4
23#define MTWEOF 5
24#define MTREW 6
25#define MTOFFL 7
26#define MTNOP 8
27#define MTRETEN 9
28#define MTBSFM 10
29#define MTFSFM 11
30#define MTEOM 12
31#define MTERASE 13
32#define MTRAS1 14
33#define MTRAS2 15
34#define MTRAS3 16
35#define MTSETBLK 20
36#define MTSETDENSITY 21
37#define MTSEEK 22
38#define MTTELL 23
39#define MTSETDRVBUFFER 24
40#define MTFSS 25
41#define MTBSS 26
42#define MTWSM 27
43#define MTLOCK 28
44#define MTUNLOCK 29
45#define MTLOAD 30
46#define MTUNLOAD 31
47#define MTCOMPRESSION 32
48#define MTSETPART 33
49#define MTMKPART 34
50
51struct mtget {
52 long mt_type;
53 long mt_resid;
54 long mt_dsreg;
55 long mt_gstat;
56 long mt_erreg;
57 int mt_fileno;
58 int mt_blkno;
59};
60
61#define MT_ISUNKNOWN 0x01
62#define MT_ISQIC02 0x02
63#define MT_ISWT5150 0x03
64#define MT_ISARCHIVE_5945L2 0x04
65#define MT_ISCMSJ500 0x05
66#define MT_ISTDC3610 0x06
67#define MT_ISARCHIVE_VP60I 0x07
68#define MT_ISARCHIVE_2150L 0x08
69#define MT_ISARCHIVE_2060L 0x09
70#define MT_ISARCHIVESC499 0x0A
71#define MT_ISQIC02_ALL_FEATURES 0x0F
72#define MT_ISWT5099EEN24 0x11
73#define MT_ISTEAC_MT2ST 0x12
74#define MT_ISEVEREX_FT40A 0x32
75#define MT_ISDDS1 0x51
76#define MT_ISDDS2 0x52
77#define MT_ISSCSI1 0x71
78#define MT_ISSCSI2 0x72
79#define MT_ISFTAPE_UNKNOWN 0x800000
80#define MT_ISFTAPE_FLAG 0x800000
81
82struct mt_tape_info {
83 long t_type;
84 char *t_name;
85};
86
87#define MT_TAPE_INFO \
88{ \
89 {MT_ISUNKNOWN, "Unknown type of tape device"}, \
90 {MT_ISQIC02, "Generic QIC-02 tape streamer"}, \
91 {MT_ISWT5150, "Wangtek 5150, QIC-150"}, \
92 {MT_ISARCHIVE_5945L2, "Archive 5945L-2"}, \
93 {MT_ISCMSJ500, "CMS Jumbo 500"}, \
94 {MT_ISTDC3610, "Tandberg TDC 3610, QIC-24"}, \
95 {MT_ISARCHIVE_VP60I, "Archive VP60i, QIC-02"}, \
96 {MT_ISARCHIVE_2150L, "Archive Viper 2150L"}, \
97 {MT_ISARCHIVE_2060L, "Archive Viper 2060L"}, \
98 {MT_ISARCHIVESC499, "Archive SC-499 QIC-36 controller"}, \
99 {MT_ISQIC02_ALL_FEATURES, "Generic QIC-02 tape, all features"}, \
100 {MT_ISWT5099EEN24, "Wangtek 5099-een24, 60MB"}, \
101 {MT_ISTEAC_MT2ST, "Teac MT-2ST 155mb data cassette drive"}, \
102 {MT_ISEVEREX_FT40A, "Everex FT40A, QIC-40"}, \
103 {MT_ISSCSI1, "Generic SCSI-1 tape"}, \
104 {MT_ISSCSI2, "Generic SCSI-2 tape"}, \
105 {0, 0} \
106}
107
108struct mtpos {
109 long mt_blkno;
110};
111
112struct mtconfiginfo {
113 long mt_type;
114 long ifc_type;
115 unsigned short irqnr;
116 unsigned short dmanr;
117 unsigned short port;
118 unsigned long debug;
119 unsigned have_dens:1;
120 unsigned have_bsf:1;
121 unsigned have_fsr:1;
122 unsigned have_bsr:1;
123 unsigned have_eod:1;
124 unsigned have_seek:1;
125 unsigned have_tell:1;
126 unsigned have_ras1:1;
127 unsigned have_ras2:1;
128 unsigned have_ras3:1;
129 unsigned have_qfa:1;
130 unsigned pad1:5;
131 char reserved[10];
132};
133
134#define MTIOCTOP _IOW('m', 1, struct mtop)
135#define MTIOCGET _IOR('m', 2, struct mtget)
136#define MTIOCPOS _IOR('m', 3, struct mtpos)
137
138#define MTIOCGETCONFIG _IOR('m', 4, struct mtconfiginfo)
139#define MTIOCSETCONFIG _IOW('m', 5, struct mtconfiginfo)
140
141#define GMT_EOF(x) ((x) & 0x80000000)
142#define GMT_BOT(x) ((x) & 0x40000000)
143#define GMT_EOT(x) ((x) & 0x20000000)
144#define GMT_SM(x) ((x) & 0x10000000)
145#define GMT_EOD(x) ((x) & 0x08000000)
146#define GMT_WR_PROT(x) ((x) & 0x04000000)
147#define GMT_ONLINE(x) ((x) & 0x01000000)
148#define GMT_D_6250(x) ((x) & 0x00800000)
149#define GMT_D_1600(x) ((x) & 0x00400000)
150#define GMT_D_800(x) ((x) & 0x00200000)
151#define GMT_DR_OPEN(x) ((x) & 0x00040000)
152#define GMT_IM_REP_EN(x) ((x) & 0x00010000)
153
154#define MT_ST_BLKSIZE_SHIFT 0
155#define MT_ST_BLKSIZE_MASK 0xffffff
156#define MT_ST_DENSITY_SHIFT 24
157#define MT_ST_DENSITY_MASK 0xff000000
158#define MT_ST_SOFTERR_SHIFT 0
159#define MT_ST_SOFTERR_MASK 0xffff
160#define MT_ST_OPTIONS 0xf0000000
161#define MT_ST_BOOLEANS 0x10000000
162#define MT_ST_SETBOOLEANS 0x30000000
163#define MT_ST_CLEARBOOLEANS 0x40000000
164#define MT_ST_WRITE_THRESHOLD 0x20000000
165#define MT_ST_DEF_BLKSIZE 0x50000000
166#define MT_ST_DEF_OPTIONS 0x60000000
167#define MT_ST_BUFFER_WRITES 0x1
168#define MT_ST_ASYNC_WRITES 0x2
169#define MT_ST_READ_AHEAD 0x4
170#define MT_ST_DEBUGGING 0x8
171#define MT_ST_TWO_FM 0x10
172#define MT_ST_FAST_MTEOM 0x20
173#define MT_ST_AUTO_LOCK 0x40
174#define MT_ST_DEF_WRITES 0x80
175#define MT_ST_CAN_BSR 0x100
176#define MT_ST_NO_BLKLIMS 0x200
177#define MT_ST_CAN_PARTITIONS 0x400
178#define MT_ST_SCSI2LOGICAL 0x800
179#define MT_ST_CLEAR_DEFAULT 0xfffff
180#define MT_ST_DEF_DENSITY (MT_ST_DEF_OPTIONS | 0x100000)
181#define MT_ST_DEF_COMPRESSION (MT_ST_DEF_OPTIONS | 0x200000)
182#define MT_ST_DEF_DRVBUFFER (MT_ST_DEF_OPTIONS | 0x300000)
183#define MT_ST_HPLOADER_OFFSET 10000
184#ifndef DEFTAPE
185# define DEFTAPE "/dev/tape"
186#endif
187
188#endif
lib/libc/musl/include/sys/param.h created+35
......@@ -0,0 +1,35 @@
1#ifndef _SYS_PARAM_H
2#define _SYS_PARAM_H
3
4#define MAXSYMLINKS 20
5#define MAXHOSTNAMELEN 64
6#define MAXNAMLEN 255
7#define MAXPATHLEN 4096
8#define NBBY 8
9#define NGROUPS 32
10#define CANBSIZ 255
11#define NOFILE 256
12#define NCARGS 131072
13#define DEV_BSIZE 512
14#define NOGROUP (-1)
15
16#undef MIN
17#undef MAX
18#define MIN(a,b) (((a)<(b))?(a):(b))
19#define MAX(a,b) (((a)>(b))?(a):(b))
20
21#define __bitop(x,i,o) ((x)[(i)/8] o (1<<(i)%8))
22#define setbit(x,i) __bitop(x,i,|=)
23#define clrbit(x,i) __bitop(x,i,&=~)
24#define isset(x,i) __bitop(x,i,&)
25#define isclr(x,i) !isset(x,i)
26
27#define howmany(n,d) (((n)+((d)-1))/(d))
28#define roundup(n,d) (howmany(n,d)*(d))
29#define powerof2(n) !(((n)-1) & (n))
30
31#include <sys/resource.h>
32#include <endian.h>
33#include <limits.h>
34
35#endif
lib/libc/musl/include/sys/personality.h created+46
......@@ -0,0 +1,46 @@
1#ifndef _PERSONALITY_H
2#define _PERSONALITY_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define ADDR_NO_RANDOMIZE 0x0040000
9#define MMAP_PAGE_ZERO 0x0100000
10#define ADDR_COMPAT_LAYOUT 0x0200000
11#define READ_IMPLIES_EXEC 0x0400000
12#define ADDR_LIMIT_32BIT 0x0800000
13#define SHORT_INODE 0x1000000
14#define WHOLE_SECONDS 0x2000000
15#define STICKY_TIMEOUTS 0x4000000
16#define ADDR_LIMIT_3GB 0x8000000
17
18#define PER_LINUX 0
19#define PER_LINUX_32BIT ADDR_LIMIT_32BIT
20#define PER_SVR4 (1 | STICKY_TIMEOUTS | MMAP_PAGE_ZERO)
21#define PER_SVR3 (2 | STICKY_TIMEOUTS | SHORT_INODE)
22#define PER_SCOSVR3 (3 | STICKY_TIMEOUTS | WHOLE_SECONDS | SHORT_INODE)
23#define PER_OSR5 (3 | STICKY_TIMEOUTS | WHOLE_SECONDS)
24#define PER_WYSEV386 (4 | STICKY_TIMEOUTS | SHORT_INODE)
25#define PER_ISCR4 (5 | STICKY_TIMEOUTS)
26#define PER_BSD 6
27#define PER_SUNOS (6 | STICKY_TIMEOUTS)
28#define PER_XENIX (7 | STICKY_TIMEOUTS | SHORT_INODE)
29#define PER_LINUX32 8
30#define PER_LINUX32_3GB (8 | ADDR_LIMIT_3GB)
31#define PER_IRIX32 (9 | STICKY_TIMEOUTS)
32#define PER_IRIXN32 (0xa | STICKY_TIMEOUTS)
33#define PER_IRIX64 (0x0b | STICKY_TIMEOUTS)
34#define PER_RISCOS 0xc
35#define PER_SOLARIS (0xd | STICKY_TIMEOUTS)
36#define PER_UW7 (0xe | STICKY_TIMEOUTS | MMAP_PAGE_ZERO)
37#define PER_OSF4 0xf
38#define PER_HPUX 0x10
39#define PER_MASK 0xff
40
41int personality(unsigned long);
42
43#ifdef __cplusplus
44}
45#endif
46#endif
lib/libc/musl/include/sys/poll.h created+2
......@@ -0,0 +1,2 @@
1#warning redirecting incorrect #include <sys/poll.h> to <poll.h>
2#include <poll.h>
lib/libc/musl/include/sys/prctl.h created+163
......@@ -0,0 +1,163 @@
1#ifndef _SYS_PRCTL_H
2#define _SYS_PRCTL_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stdint.h>
9
10#define PR_SET_PDEATHSIG 1
11#define PR_GET_PDEATHSIG 2
12#define PR_GET_DUMPABLE 3
13#define PR_SET_DUMPABLE 4
14#define PR_GET_UNALIGN 5
15#define PR_SET_UNALIGN 6
16#define PR_UNALIGN_NOPRINT 1
17#define PR_UNALIGN_SIGBUS 2
18#define PR_GET_KEEPCAPS 7
19#define PR_SET_KEEPCAPS 8
20#define PR_GET_FPEMU 9
21#define PR_SET_FPEMU 10
22#define PR_FPEMU_NOPRINT 1
23#define PR_FPEMU_SIGFPE 2
24#define PR_GET_FPEXC 11
25#define PR_SET_FPEXC 12
26#define PR_FP_EXC_SW_ENABLE 0x80
27#define PR_FP_EXC_DIV 0x010000
28#define PR_FP_EXC_OVF 0x020000
29#define PR_FP_EXC_UND 0x040000
30#define PR_FP_EXC_RES 0x080000
31#define PR_FP_EXC_INV 0x100000
32#define PR_FP_EXC_DISABLED 0
33#define PR_FP_EXC_NONRECOV 1
34#define PR_FP_EXC_ASYNC 2
35#define PR_FP_EXC_PRECISE 3
36#define PR_GET_TIMING 13
37#define PR_SET_TIMING 14
38#define PR_TIMING_STATISTICAL 0
39#define PR_TIMING_TIMESTAMP 1
40#define PR_SET_NAME 15
41#define PR_GET_NAME 16
42#define PR_GET_ENDIAN 19
43#define PR_SET_ENDIAN 20
44#define PR_ENDIAN_BIG 0
45#define PR_ENDIAN_LITTLE 1
46#define PR_ENDIAN_PPC_LITTLE 2
47#define PR_GET_SECCOMP 21
48#define PR_SET_SECCOMP 22
49#define PR_CAPBSET_READ 23
50#define PR_CAPBSET_DROP 24
51#define PR_GET_TSC 25
52#define PR_SET_TSC 26
53#define PR_TSC_ENABLE 1
54#define PR_TSC_SIGSEGV 2
55#define PR_GET_SECUREBITS 27
56#define PR_SET_SECUREBITS 28
57#define PR_SET_TIMERSLACK 29
58#define PR_GET_TIMERSLACK 30
59
60#define PR_TASK_PERF_EVENTS_DISABLE 31
61#define PR_TASK_PERF_EVENTS_ENABLE 32
62
63#define PR_MCE_KILL 33
64#define PR_MCE_KILL_CLEAR 0
65#define PR_MCE_KILL_SET 1
66#define PR_MCE_KILL_LATE 0
67#define PR_MCE_KILL_EARLY 1
68#define PR_MCE_KILL_DEFAULT 2
69#define PR_MCE_KILL_GET 34
70
71#define PR_SET_MM 35
72#define PR_SET_MM_START_CODE 1
73#define PR_SET_MM_END_CODE 2
74#define PR_SET_MM_START_DATA 3
75#define PR_SET_MM_END_DATA 4
76#define PR_SET_MM_START_STACK 5
77#define PR_SET_MM_START_BRK 6
78#define PR_SET_MM_BRK 7
79#define PR_SET_MM_ARG_START 8
80#define PR_SET_MM_ARG_END 9
81#define PR_SET_MM_ENV_START 10
82#define PR_SET_MM_ENV_END 11
83#define PR_SET_MM_AUXV 12
84#define PR_SET_MM_EXE_FILE 13
85#define PR_SET_MM_MAP 14
86#define PR_SET_MM_MAP_SIZE 15
87
88struct prctl_mm_map {
89 uint64_t start_code;
90 uint64_t end_code;
91 uint64_t start_data;
92 uint64_t end_data;
93 uint64_t start_brk;
94 uint64_t brk;
95 uint64_t start_stack;
96 uint64_t arg_start;
97 uint64_t arg_end;
98 uint64_t env_start;
99 uint64_t env_end;
100 uint64_t *auxv;
101 uint32_t auxv_size;
102 uint32_t exe_fd;
103};
104
105#define PR_SET_PTRACER 0x59616d61
106#define PR_SET_PTRACER_ANY (-1UL)
107
108#define PR_SET_CHILD_SUBREAPER 36
109#define PR_GET_CHILD_SUBREAPER 37
110
111#define PR_SET_NO_NEW_PRIVS 38
112#define PR_GET_NO_NEW_PRIVS 39
113
114#define PR_GET_TID_ADDRESS 40
115
116#define PR_SET_THP_DISABLE 41
117#define PR_GET_THP_DISABLE 42
118
119#define PR_MPX_ENABLE_MANAGEMENT 43
120#define PR_MPX_DISABLE_MANAGEMENT 44
121
122#define PR_SET_FP_MODE 45
123#define PR_GET_FP_MODE 46
124#define PR_FP_MODE_FR (1 << 0)
125#define PR_FP_MODE_FRE (1 << 1)
126
127#define PR_CAP_AMBIENT 47
128#define PR_CAP_AMBIENT_IS_SET 1
129#define PR_CAP_AMBIENT_RAISE 2
130#define PR_CAP_AMBIENT_LOWER 3
131#define PR_CAP_AMBIENT_CLEAR_ALL 4
132
133#define PR_SVE_SET_VL 50
134#define PR_SVE_SET_VL_ONEXEC (1 << 18)
135#define PR_SVE_GET_VL 51
136#define PR_SVE_VL_LEN_MASK 0xffff
137#define PR_SVE_VL_INHERIT (1 << 17)
138
139#define PR_GET_SPECULATION_CTRL 52
140#define PR_SET_SPECULATION_CTRL 53
141#define PR_SPEC_STORE_BYPASS 0
142#define PR_SPEC_INDIRECT_BRANCH 1
143#define PR_SPEC_NOT_AFFECTED 0
144#define PR_SPEC_PRCTL (1UL << 0)
145#define PR_SPEC_ENABLE (1UL << 1)
146#define PR_SPEC_DISABLE (1UL << 2)
147#define PR_SPEC_FORCE_DISABLE (1UL << 3)
148#define PR_SPEC_DISABLE_NOEXEC (1UL << 4)
149
150#define PR_PAC_RESET_KEYS 54
151#define PR_PAC_APIAKEY (1UL << 0)
152#define PR_PAC_APIBKEY (1UL << 1)
153#define PR_PAC_APDAKEY (1UL << 2)
154#define PR_PAC_APDBKEY (1UL << 3)
155#define PR_PAC_APGAKEY (1UL << 4)
156
157int prctl (int, ...);
158
159#ifdef __cplusplus
160}
161#endif
162
163#endif
lib/libc/musl/include/sys/procfs.h created+64
......@@ -0,0 +1,64 @@
1#ifndef _SYS_PROCFS_H
2#define _SYS_PROCFS_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <sys/time.h>
8#include <sys/types.h>
9#include <sys/user.h>
10
11struct elf_siginfo {
12 int si_signo;
13 int si_code;
14 int si_errno;
15};
16
17struct elf_prstatus {
18 struct elf_siginfo pr_info;
19 short int pr_cursig;
20 unsigned long int pr_sigpend;
21 unsigned long int pr_sighold;
22 pid_t pr_pid;
23 pid_t pr_ppid;
24 pid_t pr_pgrp;
25 pid_t pr_sid;
26 struct timeval pr_utime;
27 struct timeval pr_stime;
28 struct timeval pr_cutime;
29 struct timeval pr_cstime;
30 elf_gregset_t pr_reg;
31 int pr_fpvalid;
32};
33
34#define ELF_PRARGSZ 80
35
36struct elf_prpsinfo {
37 char pr_state;
38 char pr_sname;
39 char pr_zomb;
40 char pr_nice;
41 unsigned long int pr_flag;
42#if UINTPTR_MAX == 0xffffffff
43 unsigned short int pr_uid;
44 unsigned short int pr_gid;
45#else
46 unsigned int pr_uid;
47 unsigned int pr_gid;
48#endif
49 int pr_pid, pr_ppid, pr_pgrp, pr_sid;
50 char pr_fname[16];
51 char pr_psargs[ELF_PRARGSZ];
52};
53
54typedef void *psaddr_t;
55typedef elf_gregset_t prgregset_t;
56typedef elf_fpregset_t prfpregset_t;
57typedef pid_t lwpid_t;
58typedef struct elf_prstatus prstatus_t;
59typedef struct elf_prpsinfo prpsinfo_t;
60
61#ifdef __cplusplus
62}
63#endif
64#endif
lib/libc/musl/include/sys/ptrace.h created+109
......@@ -0,0 +1,109 @@
1#ifndef _SYS_PTRACE_H
2#define _SYS_PTRACE_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <stdint.h>
8
9#define PTRACE_TRACEME 0
10#define PT_TRACE_ME PTRACE_TRACEME
11
12#define PTRACE_PEEKTEXT 1
13#define PTRACE_PEEKDATA 2
14#define PTRACE_PEEKUSER 3
15#define PTRACE_POKETEXT 4
16#define PTRACE_POKEDATA 5
17#define PTRACE_POKEUSER 6
18#define PTRACE_CONT 7
19#define PTRACE_KILL 8
20#define PTRACE_SINGLESTEP 9
21#define PTRACE_GETREGS 12
22#define PTRACE_SETREGS 13
23#define PTRACE_GETFPREGS 14
24#define PTRACE_SETFPREGS 15
25#define PTRACE_ATTACH 16
26#define PTRACE_DETACH 17
27#define PTRACE_GETFPXREGS 18
28#define PTRACE_SETFPXREGS 19
29#define PTRACE_SYSCALL 24
30#define PTRACE_SETOPTIONS 0x4200
31#define PTRACE_GETEVENTMSG 0x4201
32#define PTRACE_GETSIGINFO 0x4202
33#define PTRACE_SETSIGINFO 0x4203
34#define PTRACE_GETREGSET 0x4204
35#define PTRACE_SETREGSET 0x4205
36#define PTRACE_SEIZE 0x4206
37#define PTRACE_INTERRUPT 0x4207
38#define PTRACE_LISTEN 0x4208
39#define PTRACE_PEEKSIGINFO 0x4209
40#define PTRACE_GETSIGMASK 0x420a
41#define PTRACE_SETSIGMASK 0x420b
42#define PTRACE_SECCOMP_GET_FILTER 0x420c
43#define PTRACE_SECCOMP_GET_METADATA 0x420d
44
45#define PT_READ_I PTRACE_PEEKTEXT
46#define PT_READ_D PTRACE_PEEKDATA
47#define PT_READ_U PTRACE_PEEKUSER
48#define PT_WRITE_I PTRACE_POKETEXT
49#define PT_WRITE_D PTRACE_POKEDATA
50#define PT_WRITE_U PTRACE_POKEUSER
51#define PT_CONTINUE PTRACE_CONT
52#define PT_KILL PTRACE_KILL
53#define PT_STEP PTRACE_SINGLESTEP
54#define PT_GETREGS PTRACE_GETREGS
55#define PT_SETREGS PTRACE_SETREGS
56#define PT_GETFPREGS PTRACE_GETFPREGS
57#define PT_SETFPREGS PTRACE_SETFPREGS
58#define PT_ATTACH PTRACE_ATTACH
59#define PT_DETACH PTRACE_DETACH
60#define PT_GETFPXREGS PTRACE_GETFPXREGS
61#define PT_SETFPXREGS PTRACE_SETFPXREGS
62#define PT_SYSCALL PTRACE_SYSCALL
63#define PT_SETOPTIONS PTRACE_SETOPTIONS
64#define PT_GETEVENTMSG PTRACE_GETEVENTMSG
65#define PT_GETSIGINFO PTRACE_GETSIGINFO
66#define PT_SETSIGINFO PTRACE_SETSIGINFO
67
68#define PTRACE_O_TRACESYSGOOD 0x00000001
69#define PTRACE_O_TRACEFORK 0x00000002
70#define PTRACE_O_TRACEVFORK 0x00000004
71#define PTRACE_O_TRACECLONE 0x00000008
72#define PTRACE_O_TRACEEXEC 0x00000010
73#define PTRACE_O_TRACEVFORKDONE 0x00000020
74#define PTRACE_O_TRACEEXIT 0x00000040
75#define PTRACE_O_TRACESECCOMP 0x00000080
76#define PTRACE_O_EXITKILL 0x00100000
77#define PTRACE_O_SUSPEND_SECCOMP 0x00200000
78#define PTRACE_O_MASK 0x003000ff
79
80#define PTRACE_EVENT_FORK 1
81#define PTRACE_EVENT_VFORK 2
82#define PTRACE_EVENT_CLONE 3
83#define PTRACE_EVENT_EXEC 4
84#define PTRACE_EVENT_VFORK_DONE 5
85#define PTRACE_EVENT_EXIT 6
86#define PTRACE_EVENT_SECCOMP 7
87#define PTRACE_EVENT_STOP 128
88
89#define PTRACE_PEEKSIGINFO_SHARED 1
90
91#include <bits/ptrace.h>
92
93struct __ptrace_peeksiginfo_args {
94 uint64_t off;
95 uint32_t flags;
96 int32_t nr;
97};
98
99struct __ptrace_seccomp_metadata {
100 uint64_t filter_off;
101 uint64_t flags;
102};
103
104long ptrace(int, ...);
105
106#ifdef __cplusplus
107}
108#endif
109#endif
lib/libc/musl/include/sys/quota.h created+102
......@@ -0,0 +1,102 @@
1#ifndef _SYS_QUOTA_H
2#define _SYS_QUOTA_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stdint.h>
9
10#define _LINUX_QUOTA_VERSION 2
11
12#define dbtob(num) ((num) << 10)
13#define btodb(num) ((num) >> 10)
14#define fs_to_dq_blocks(num, blksize) (((num) * (blksize)) / 1024)
15
16#define MAX_IQ_TIME 604800
17#define MAX_DQ_TIME 604800
18
19#define MAXQUOTAS 2
20#define USRQUOTA 0
21#define GRPQUOTA 1
22
23#define INITQFNAMES { "user", "group", "undefined" };
24
25#define QUOTAFILENAME "quota"
26#define QUOTAGROUP "staff"
27
28#define NR_DQHASH 43
29#define NR_DQUOTS 256
30
31#define SUBCMDMASK 0x00ff
32#define SUBCMDSHIFT 8
33#define QCMD(cmd, type) (((cmd) << SUBCMDSHIFT) | ((type) & SUBCMDMASK))
34
35#define Q_SYNC 0x800001
36#define Q_QUOTAON 0x800002
37#define Q_QUOTAOFF 0x800003
38#define Q_GETFMT 0x800004
39#define Q_GETINFO 0x800005
40#define Q_SETINFO 0x800006
41#define Q_GETQUOTA 0x800007
42#define Q_SETQUOTA 0x800008
43
44#define QFMT_VFS_OLD 1
45#define QFMT_VFS_V0 2
46#define QFMT_OCFS2 3
47#define QFMT_VFS_V1 4
48
49#define QIF_BLIMITS 1
50#define QIF_SPACE 2
51#define QIF_ILIMITS 4
52#define QIF_INODES 8
53#define QIF_BTIME 16
54#define QIF_ITIME 32
55#define QIF_LIMITS (QIF_BLIMITS | QIF_ILIMITS)
56#define QIF_USAGE (QIF_SPACE | QIF_INODES)
57#define QIF_TIMES (QIF_BTIME | QIF_ITIME)
58#define QIF_ALL (QIF_LIMITS | QIF_USAGE | QIF_TIMES)
59
60struct dqblk {
61 uint64_t dqb_bhardlimit;
62 uint64_t dqb_bsoftlimit;
63 uint64_t dqb_curspace;
64 uint64_t dqb_ihardlimit;
65 uint64_t dqb_isoftlimit;
66 uint64_t dqb_curinodes;
67 uint64_t dqb_btime;
68 uint64_t dqb_itime;
69 uint32_t dqb_valid;
70};
71
72#define dq_bhardlimit dq_dqb.dqb_bhardlimit
73#define dq_bsoftlimit dq_dqb.dqb_bsoftlimit
74#define dq_curspace dq_dqb.dqb_curspace
75#define dq_valid dq_dqb.dqb_valid
76#define dq_ihardlimit dq_dqb.dqb_ihardlimit
77#define dq_isoftlimit dq_dqb.dqb_isoftlimit
78#define dq_curinodes dq_dqb.dqb_curinodes
79#define dq_btime dq_dqb.dqb_btime
80#define dq_itime dq_dqb.dqb_itime
81
82#define dqoff(UID) ((long long)(UID) * sizeof (struct dqblk))
83
84#define IIF_BGRACE 1
85#define IIF_IGRACE 2
86#define IIF_FLAGS 4
87#define IIF_ALL (IIF_BGRACE | IIF_IGRACE | IIF_FLAGS)
88
89struct dqinfo {
90 uint64_t dqi_bgrace;
91 uint64_t dqi_igrace;
92 uint32_t dqi_flags;
93 uint32_t dqi_valid;
94};
95
96int quotactl(int, const char *, int, char *);
97
98#ifdef __cplusplus
99}
100#endif
101
102#endif
lib/libc/musl/include/sys/random.h created+19
......@@ -0,0 +1,19 @@
1#ifndef _SYS_RANDOM_H
2#define _SYS_RANDOM_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#define __NEED_size_t
8#define __NEED_ssize_t
9#include <bits/alltypes.h>
10
11#define GRND_NONBLOCK 0x0001
12#define GRND_RANDOM 0x0002
13
14ssize_t getrandom(void *, size_t, unsigned);
15
16#ifdef __cplusplus
17}
18#endif
19#endif
lib/libc/musl/include/sys/reboot.h created+20
......@@ -0,0 +1,20 @@
1#ifndef _SYS_REBOOT_H
2#define _SYS_REBOOT_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#define RB_AUTOBOOT 0x01234567
8#define RB_HALT_SYSTEM 0xcdef0123
9#define RB_ENABLE_CAD 0x89abcdef
10#define RB_DISABLE_CAD 0
11#define RB_POWER_OFF 0x4321fedc
12#define RB_SW_SUSPEND 0xd000fce2
13#define RB_KEXEC 0x45584543
14
15int reboot(int);
16
17#ifdef __cplusplus
18}
19#endif
20#endif
lib/libc/musl/include/sys/reg.h created+9
......@@ -0,0 +1,9 @@
1#ifndef _SYS_REG_H
2#define _SYS_REG_H
3
4#include <limits.h>
5#include <unistd.h>
6
7#include <bits/reg.h>
8
9#endif
lib/libc/musl/include/sys/resource.h created+111
......@@ -0,0 +1,111 @@
1#ifndef _SYS_RESOURCE_H
2#define _SYS_RESOURCE_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9#include <sys/time.h>
10
11#define __NEED_id_t
12
13#ifdef _GNU_SOURCE
14#define __NEED_pid_t
15#endif
16
17#include <bits/alltypes.h>
18#include <bits/resource.h>
19
20typedef unsigned long long rlim_t;
21
22struct rlimit {
23 rlim_t rlim_cur;
24 rlim_t rlim_max;
25};
26
27struct rusage {
28 struct timeval ru_utime;
29 struct timeval ru_stime;
30 /* linux extentions, but useful */
31 long ru_maxrss;
32 long ru_ixrss;
33 long ru_idrss;
34 long ru_isrss;
35 long ru_minflt;
36 long ru_majflt;
37 long ru_nswap;
38 long ru_inblock;
39 long ru_oublock;
40 long ru_msgsnd;
41 long ru_msgrcv;
42 long ru_nsignals;
43 long ru_nvcsw;
44 long ru_nivcsw;
45 /* room for more... */
46 long __reserved[16];
47};
48
49int getrlimit (int, struct rlimit *);
50int setrlimit (int, const struct rlimit *);
51int getrusage (int, struct rusage *);
52
53int getpriority (int, id_t);
54int setpriority (int, id_t, int);
55
56#ifdef _GNU_SOURCE
57int prlimit(pid_t, int, const struct rlimit *, struct rlimit *);
58#define prlimit64 prlimit
59#endif
60
61#define PRIO_MIN (-20)
62#define PRIO_MAX 20
63
64#define PRIO_PROCESS 0
65#define PRIO_PGRP 1
66#define PRIO_USER 2
67
68#define RUSAGE_SELF 0
69#define RUSAGE_CHILDREN (-1)
70#define RUSAGE_THREAD 1
71
72#define RLIM_INFINITY (~0ULL)
73#define RLIM_SAVED_CUR RLIM_INFINITY
74#define RLIM_SAVED_MAX RLIM_INFINITY
75
76#define RLIMIT_CPU 0
77#define RLIMIT_FSIZE 1
78#define RLIMIT_DATA 2
79#define RLIMIT_STACK 3
80#define RLIMIT_CORE 4
81#ifndef RLIMIT_RSS
82#define RLIMIT_RSS 5
83#define RLIMIT_NPROC 6
84#define RLIMIT_NOFILE 7
85#define RLIMIT_MEMLOCK 8
86#define RLIMIT_AS 9
87#endif
88#define RLIMIT_LOCKS 10
89#define RLIMIT_SIGPENDING 11
90#define RLIMIT_MSGQUEUE 12
91#define RLIMIT_NICE 13
92#define RLIMIT_RTPRIO 14
93#define RLIMIT_NLIMITS 15
94
95#define RLIM_NLIMITS RLIMIT_NLIMITS
96
97#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
98#define RLIM64_INFINITY RLIM_INFINITY
99#define RLIM64_SAVED_CUR RLIM_SAVED_CUR
100#define RLIM64_SAVED_MAX RLIM_SAVED_MAX
101#define getrlimit64 getrlimit
102#define setrlimit64 setrlimit
103#define rlimit64 rlimit
104#define rlim64_t rlim_t
105#endif
106
107#ifdef __cplusplus
108}
109#endif
110
111#endif
lib/libc/musl/include/sys/select.h created+41
......@@ -0,0 +1,41 @@
1#ifndef _SYS_SELECT_H
2#define _SYS_SELECT_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <features.h>
8
9#define __NEED_size_t
10#define __NEED_time_t
11#define __NEED_suseconds_t
12#define __NEED_struct_timeval
13#define __NEED_struct_timespec
14#define __NEED_sigset_t
15
16#include <bits/alltypes.h>
17
18#define FD_SETSIZE 1024
19
20typedef unsigned long fd_mask;
21
22typedef struct {
23 unsigned long fds_bits[FD_SETSIZE / 8 / sizeof(long)];
24} fd_set;
25
26#define FD_ZERO(s) do { int __i; unsigned long *__b=(s)->fds_bits; for(__i=sizeof (fd_set)/sizeof (long); __i; __i--) *__b++=0; } while(0)
27#define FD_SET(d, s) ((s)->fds_bits[(d)/(8*sizeof(long))] |= (1UL<<((d)%(8*sizeof(long)))))
28#define FD_CLR(d, s) ((s)->fds_bits[(d)/(8*sizeof(long))] &= ~(1UL<<((d)%(8*sizeof(long)))))
29#define FD_ISSET(d, s) !!((s)->fds_bits[(d)/(8*sizeof(long))] & (1UL<<((d)%(8*sizeof(long)))))
30
31int select (int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict, struct timeval *__restrict);
32int pselect (int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict, const struct timespec *__restrict, const sigset_t *__restrict);
33
34#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
35#define NFDBITS (8*(int)sizeof(long))
36#endif
37
38#ifdef __cplusplus
39}
40#endif
41#endif
lib/libc/musl/include/sys/sem.h created+68
......@@ -0,0 +1,68 @@
1#ifndef _SYS_SEM_H
2#define _SYS_SEM_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <features.h>
8
9#define __NEED_size_t
10#define __NEED_pid_t
11#define __NEED_time_t
12#ifdef _GNU_SOURCE
13#define __NEED_struct_timespec
14#endif
15#include <bits/alltypes.h>
16
17#include <sys/ipc.h>
18
19#define SEM_UNDO 0x1000
20#define GETPID 11
21#define GETVAL 12
22#define GETALL 13
23#define GETNCNT 14
24#define GETZCNT 15
25#define SETVAL 16
26#define SETALL 17
27
28#include <endian.h>
29
30#include <bits/sem.h>
31
32#define _SEM_SEMUN_UNDEFINED 1
33
34#define SEM_STAT 18
35#define SEM_INFO 19
36#define SEM_STAT_ANY 20
37
38struct seminfo {
39 int semmap;
40 int semmni;
41 int semmns;
42 int semmnu;
43 int semmsl;
44 int semopm;
45 int semume;
46 int semusz;
47 int semvmx;
48 int semaem;
49};
50
51struct sembuf {
52 unsigned short sem_num;
53 short sem_op;
54 short sem_flg;
55};
56
57int semctl(int, int, int, ...);
58int semget(key_t, int, int);
59int semop(int, struct sembuf *, size_t);
60
61#ifdef _GNU_SOURCE
62int semtimedop(int, struct sembuf *, size_t, const struct timespec *);
63#endif
64
65#ifdef __cplusplus
66}
67#endif
68#endif
lib/libc/musl/include/sys/sendfile.h created+22
......@@ -0,0 +1,22 @@
1#ifndef _SYS_SENDFILE_H
2#define _SYS_SENDFILE_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9#include <unistd.h>
10
11ssize_t sendfile(int, int, off_t *, size_t);
12
13#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
14#define sendfile64 sendfile
15#define off64_t off_t
16#endif
17
18#ifdef __cplusplus
19}
20#endif
21
22#endif
lib/libc/musl/include/sys/shm.h created+70
......@@ -0,0 +1,70 @@
1#ifndef _SYS_SHM_H
2#define _SYS_SHM_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_time_t
11#define __NEED_size_t
12#define __NEED_pid_t
13
14#include <bits/alltypes.h>
15
16#include <sys/ipc.h>
17
18#ifdef _GNU_SOURCE
19#define __used_ids used_ids
20#define __swap_attempts swap_attempts
21#define __swap_successes swap_successes
22#endif
23
24#include <bits/shm.h>
25
26#define SHM_R 0400
27#define SHM_W 0200
28
29#define SHM_RDONLY 010000
30#define SHM_RND 020000
31#define SHM_REMAP 040000
32#define SHM_EXEC 0100000
33
34#define SHM_LOCK 11
35#define SHM_UNLOCK 12
36#define SHM_STAT 13
37#define SHM_INFO 14
38#define SHM_STAT_ANY 15
39#define SHM_DEST 01000
40#define SHM_LOCKED 02000
41#define SHM_HUGETLB 04000
42#define SHM_NORESERVE 010000
43
44#define SHM_HUGE_SHIFT 26
45#define SHM_HUGE_MASK 0x3f
46#define SHM_HUGE_64KB (16 << 26)
47#define SHM_HUGE_512KB (19 << 26)
48#define SHM_HUGE_1MB (20 << 26)
49#define SHM_HUGE_2MB (21 << 26)
50#define SHM_HUGE_8MB (23 << 26)
51#define SHM_HUGE_16MB (24 << 26)
52#define SHM_HUGE_32MB (25 << 26)
53#define SHM_HUGE_256MB (28 << 26)
54#define SHM_HUGE_512MB (29 << 26)
55#define SHM_HUGE_1GB (30 << 26)
56#define SHM_HUGE_2GB (31 << 26)
57#define SHM_HUGE_16GB (34U << 26)
58
59typedef unsigned long shmatt_t;
60
61void *shmat(int, const void *, int);
62int shmctl(int, int, struct shmid_ds *);
63int shmdt(const void *);
64int shmget(key_t, size_t, int);
65
66#ifdef __cplusplus
67}
68#endif
69
70#endif
lib/libc/musl/include/sys/signal.h created+2
......@@ -0,0 +1,2 @@
1#warning redirecting incorrect #include <sys/signal.h> to <signal.h>
2#include <signal.h>
lib/libc/musl/include/sys/signalfd.h created+49
......@@ -0,0 +1,49 @@
1#ifndef _SYS_SIGNALFD_H
2#define _SYS_SIGNALFD_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stdint.h>
9#include <fcntl.h>
10
11#define __NEED_sigset_t
12
13#include <bits/alltypes.h>
14
15#define SFD_CLOEXEC O_CLOEXEC
16#define SFD_NONBLOCK O_NONBLOCK
17
18int signalfd(int, const sigset_t *, int);
19
20struct signalfd_siginfo {
21 uint32_t ssi_signo;
22 int32_t ssi_errno;
23 int32_t ssi_code;
24 uint32_t ssi_pid;
25 uint32_t ssi_uid;
26 int32_t ssi_fd;
27 uint32_t ssi_tid;
28 uint32_t ssi_band;
29 uint32_t ssi_overrun;
30 uint32_t ssi_trapno;
31 int32_t ssi_status;
32 int32_t ssi_int;
33 uint64_t ssi_ptr;
34 uint64_t ssi_utime;
35 uint64_t ssi_stime;
36 uint64_t ssi_addr;
37 uint16_t ssi_addr_lsb;
38 uint16_t __pad2;
39 int32_t ssi_syscall;
40 uint64_t ssi_call_addr;
41 uint32_t ssi_arch;
42 uint8_t __pad[128-14*4-5*8-2*2];
43};
44
45#ifdef __cplusplus
46}
47#endif
48
49#endif
lib/libc/musl/include/sys/socket.h created+356
......@@ -0,0 +1,356 @@
1#ifndef _SYS_SOCKET_H
2#define _SYS_SOCKET_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <features.h>
8
9#define __NEED_socklen_t
10#define __NEED_sa_family_t
11#define __NEED_size_t
12#define __NEED_ssize_t
13#define __NEED_uid_t
14#define __NEED_pid_t
15#define __NEED_gid_t
16#define __NEED_struct_iovec
17
18#include <bits/alltypes.h>
19
20#include <bits/socket.h>
21
22#ifdef _GNU_SOURCE
23struct ucred {
24 pid_t pid;
25 uid_t uid;
26 gid_t gid;
27};
28
29struct mmsghdr {
30 struct msghdr msg_hdr;
31 unsigned int msg_len;
32};
33
34struct timespec;
35
36int sendmmsg (int, struct mmsghdr *, unsigned int, unsigned int);
37int recvmmsg (int, struct mmsghdr *, unsigned int, unsigned int, struct timespec *);
38#endif
39
40struct linger {
41 int l_onoff;
42 int l_linger;
43};
44
45#define SHUT_RD 0
46#define SHUT_WR 1
47#define SHUT_RDWR 2
48
49#ifndef SOCK_STREAM
50#define SOCK_STREAM 1
51#define SOCK_DGRAM 2
52#endif
53
54#define SOCK_RAW 3
55#define SOCK_RDM 4
56#define SOCK_SEQPACKET 5
57#define SOCK_DCCP 6
58#define SOCK_PACKET 10
59
60#ifndef SOCK_CLOEXEC
61#define SOCK_CLOEXEC 02000000
62#define SOCK_NONBLOCK 04000
63#endif
64
65#define PF_UNSPEC 0
66#define PF_LOCAL 1
67#define PF_UNIX PF_LOCAL
68#define PF_FILE PF_LOCAL
69#define PF_INET 2
70#define PF_AX25 3
71#define PF_IPX 4
72#define PF_APPLETALK 5
73#define PF_NETROM 6
74#define PF_BRIDGE 7
75#define PF_ATMPVC 8
76#define PF_X25 9
77#define PF_INET6 10
78#define PF_ROSE 11
79#define PF_DECnet 12
80#define PF_NETBEUI 13
81#define PF_SECURITY 14
82#define PF_KEY 15
83#define PF_NETLINK 16
84#define PF_ROUTE PF_NETLINK
85#define PF_PACKET 17
86#define PF_ASH 18
87#define PF_ECONET 19
88#define PF_ATMSVC 20
89#define PF_RDS 21
90#define PF_SNA 22
91#define PF_IRDA 23
92#define PF_PPPOX 24
93#define PF_WANPIPE 25
94#define PF_LLC 26
95#define PF_IB 27
96#define PF_MPLS 28
97#define PF_CAN 29
98#define PF_TIPC 30
99#define PF_BLUETOOTH 31
100#define PF_IUCV 32
101#define PF_RXRPC 33
102#define PF_ISDN 34
103#define PF_PHONET 35
104#define PF_IEEE802154 36
105#define PF_CAIF 37
106#define PF_ALG 38
107#define PF_NFC 39
108#define PF_VSOCK 40
109#define PF_KCM 41
110#define PF_QIPCRTR 42
111#define PF_SMC 43
112#define PF_XDP 44
113#define PF_MAX 45
114
115#define AF_UNSPEC PF_UNSPEC
116#define AF_LOCAL PF_LOCAL
117#define AF_UNIX AF_LOCAL
118#define AF_FILE AF_LOCAL
119#define AF_INET PF_INET
120#define AF_AX25 PF_AX25
121#define AF_IPX PF_IPX
122#define AF_APPLETALK PF_APPLETALK
123#define AF_NETROM PF_NETROM
124#define AF_BRIDGE PF_BRIDGE
125#define AF_ATMPVC PF_ATMPVC
126#define AF_X25 PF_X25
127#define AF_INET6 PF_INET6
128#define AF_ROSE PF_ROSE
129#define AF_DECnet PF_DECnet
130#define AF_NETBEUI PF_NETBEUI
131#define AF_SECURITY PF_SECURITY
132#define AF_KEY PF_KEY
133#define AF_NETLINK PF_NETLINK
134#define AF_ROUTE PF_ROUTE
135#define AF_PACKET PF_PACKET
136#define AF_ASH PF_ASH
137#define AF_ECONET PF_ECONET
138#define AF_ATMSVC PF_ATMSVC
139#define AF_RDS PF_RDS
140#define AF_SNA PF_SNA
141#define AF_IRDA PF_IRDA
142#define AF_PPPOX PF_PPPOX
143#define AF_WANPIPE PF_WANPIPE
144#define AF_LLC PF_LLC
145#define AF_IB PF_IB
146#define AF_MPLS PF_MPLS
147#define AF_CAN PF_CAN
148#define AF_TIPC PF_TIPC
149#define AF_BLUETOOTH PF_BLUETOOTH
150#define AF_IUCV PF_IUCV
151#define AF_RXRPC PF_RXRPC
152#define AF_ISDN PF_ISDN
153#define AF_PHONET PF_PHONET
154#define AF_IEEE802154 PF_IEEE802154
155#define AF_CAIF PF_CAIF
156#define AF_ALG PF_ALG
157#define AF_NFC PF_NFC
158#define AF_VSOCK PF_VSOCK
159#define AF_KCM PF_KCM
160#define AF_QIPCRTR PF_QIPCRTR
161#define AF_SMC PF_SMC
162#define AF_XDP PF_XDP
163#define AF_MAX PF_MAX
164
165#ifndef SO_DEBUG
166#define SO_DEBUG 1
167#define SO_REUSEADDR 2
168#define SO_TYPE 3
169#define SO_ERROR 4
170#define SO_DONTROUTE 5
171#define SO_BROADCAST 6
172#define SO_SNDBUF 7
173#define SO_RCVBUF 8
174#define SO_KEEPALIVE 9
175#define SO_OOBINLINE 10
176#define SO_NO_CHECK 11
177#define SO_PRIORITY 12
178#define SO_LINGER 13
179#define SO_BSDCOMPAT 14
180#define SO_REUSEPORT 15
181#define SO_PASSCRED 16
182#define SO_PEERCRED 17
183#define SO_RCVLOWAT 18
184#define SO_SNDLOWAT 19
185#define SO_RCVTIMEO 20
186#define SO_SNDTIMEO 21
187#define SO_ACCEPTCONN 30
188#define SO_PEERSEC 31
189#define SO_SNDBUFFORCE 32
190#define SO_RCVBUFFORCE 33
191#define SO_PROTOCOL 38
192#define SO_DOMAIN 39
193#endif
194
195#define SO_SECURITY_AUTHENTICATION 22
196#define SO_SECURITY_ENCRYPTION_TRANSPORT 23
197#define SO_SECURITY_ENCRYPTION_NETWORK 24
198
199#define SO_BINDTODEVICE 25
200
201#define SO_ATTACH_FILTER 26
202#define SO_DETACH_FILTER 27
203#define SO_GET_FILTER SO_ATTACH_FILTER
204
205#define SO_PEERNAME 28
206#define SO_TIMESTAMP 29
207#define SCM_TIMESTAMP SO_TIMESTAMP
208
209#define SO_PASSSEC 34
210#define SO_TIMESTAMPNS 35
211#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
212#define SO_MARK 36
213#define SO_TIMESTAMPING 37
214#define SCM_TIMESTAMPING SO_TIMESTAMPING
215#define SO_RXQ_OVFL 40
216#define SO_WIFI_STATUS 41
217#define SCM_WIFI_STATUS SO_WIFI_STATUS
218#define SO_PEEK_OFF 42
219#define SO_NOFCS 43
220#define SO_LOCK_FILTER 44
221#define SO_SELECT_ERR_QUEUE 45
222#define SO_BUSY_POLL 46
223#define SO_MAX_PACING_RATE 47
224#define SO_BPF_EXTENSIONS 48
225#define SO_INCOMING_CPU 49
226#define SO_ATTACH_BPF 50
227#define SO_DETACH_BPF SO_DETACH_FILTER
228#define SO_ATTACH_REUSEPORT_CBPF 51
229#define SO_ATTACH_REUSEPORT_EBPF 52
230#define SO_CNX_ADVICE 53
231#define SCM_TIMESTAMPING_OPT_STATS 54
232#define SO_MEMINFO 55
233#define SO_INCOMING_NAPI_ID 56
234#define SO_COOKIE 57
235#define SCM_TIMESTAMPING_PKTINFO 58
236#define SO_PEERGROUPS 59
237#define SO_ZEROCOPY 60
238#define SO_TXTIME 61
239#define SCM_TXTIME SO_TXTIME
240#define SO_BINDTOIFINDEX 62
241
242#ifndef SOL_SOCKET
243#define SOL_SOCKET 1
244#endif
245
246#define SOL_IP 0
247#define SOL_IPV6 41
248#define SOL_ICMPV6 58
249
250#define SOL_RAW 255
251#define SOL_DECNET 261
252#define SOL_X25 262
253#define SOL_PACKET 263
254#define SOL_ATM 264
255#define SOL_AAL 265
256#define SOL_IRDA 266
257#define SOL_NETBEUI 267
258#define SOL_LLC 268
259#define SOL_DCCP 269
260#define SOL_NETLINK 270
261#define SOL_TIPC 271
262#define SOL_RXRPC 272
263#define SOL_PPPOL2TP 273
264#define SOL_BLUETOOTH 274
265#define SOL_PNPIPE 275
266#define SOL_RDS 276
267#define SOL_IUCV 277
268#define SOL_CAIF 278
269#define SOL_ALG 279
270#define SOL_NFC 280
271#define SOL_KCM 281
272#define SOL_TLS 282
273#define SOL_XDP 283
274
275#define SOMAXCONN 128
276
277#define MSG_OOB 0x0001
278#define MSG_PEEK 0x0002
279#define MSG_DONTROUTE 0x0004
280#define MSG_CTRUNC 0x0008
281#define MSG_PROXY 0x0010
282#define MSG_TRUNC 0x0020
283#define MSG_DONTWAIT 0x0040
284#define MSG_EOR 0x0080
285#define MSG_WAITALL 0x0100
286#define MSG_FIN 0x0200
287#define MSG_SYN 0x0400
288#define MSG_CONFIRM 0x0800
289#define MSG_RST 0x1000
290#define MSG_ERRQUEUE 0x2000
291#define MSG_NOSIGNAL 0x4000
292#define MSG_MORE 0x8000
293#define MSG_WAITFORONE 0x10000
294#define MSG_BATCH 0x40000
295#define MSG_ZEROCOPY 0x4000000
296#define MSG_FASTOPEN 0x20000000
297#define MSG_CMSG_CLOEXEC 0x40000000
298
299#define __CMSG_LEN(cmsg) (((cmsg)->cmsg_len + sizeof(long) - 1) & ~(long)(sizeof(long) - 1))
300#define __CMSG_NEXT(cmsg) ((unsigned char *)(cmsg) + __CMSG_LEN(cmsg))
301#define __MHDR_END(mhdr) ((unsigned char *)(mhdr)->msg_control + (mhdr)->msg_controllen)
302
303#define CMSG_DATA(cmsg) ((unsigned char *) (((struct cmsghdr *)(cmsg)) + 1))
304#define CMSG_NXTHDR(mhdr, cmsg) ((cmsg)->cmsg_len < sizeof (struct cmsghdr) || \
305 __CMSG_LEN(cmsg) + sizeof(struct cmsghdr) >= __MHDR_END(mhdr) - (unsigned char *)(cmsg) \
306 ? 0 : (struct cmsghdr *)__CMSG_NEXT(cmsg))
307#define CMSG_FIRSTHDR(mhdr) ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr) ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) 0)
308
309#define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1))
310#define CMSG_SPACE(len) (CMSG_ALIGN (len) + CMSG_ALIGN (sizeof (struct cmsghdr)))
311#define CMSG_LEN(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len))
312
313#define SCM_RIGHTS 0x01
314#define SCM_CREDENTIALS 0x02
315
316struct sockaddr {
317 sa_family_t sa_family;
318 char sa_data[14];
319};
320
321struct sockaddr_storage {
322 sa_family_t ss_family;
323 char __ss_padding[128-sizeof(long)-sizeof(sa_family_t)];
324 unsigned long __ss_align;
325};
326
327int socket (int, int, int);
328int socketpair (int, int, int, int [2]);
329
330int shutdown (int, int);
331
332int bind (int, const struct sockaddr *, socklen_t);
333int connect (int, const struct sockaddr *, socklen_t);
334int listen (int, int);
335int accept (int, struct sockaddr *__restrict, socklen_t *__restrict);
336int accept4(int, struct sockaddr *__restrict, socklen_t *__restrict, int);
337
338int getsockname (int, struct sockaddr *__restrict, socklen_t *__restrict);
339int getpeername (int, struct sockaddr *__restrict, socklen_t *__restrict);
340
341ssize_t send (int, const void *, size_t, int);
342ssize_t recv (int, void *, size_t, int);
343ssize_t sendto (int, const void *, size_t, int, const struct sockaddr *, socklen_t);
344ssize_t recvfrom (int, void *__restrict, size_t, int, struct sockaddr *__restrict, socklen_t *__restrict);
345ssize_t sendmsg (int, const struct msghdr *, int);
346ssize_t recvmsg (int, struct msghdr *, int);
347
348int getsockopt (int, int, int, void *__restrict, socklen_t *__restrict);
349int setsockopt (int, int, int, const void *, socklen_t);
350
351int sockatmark (int);
352
353#ifdef __cplusplus
354}
355#endif
356#endif
lib/libc/musl/include/sys/soundcard.h created+1
......@@ -0,0 +1 @@
1#include <bits/soundcard.h>
lib/libc/musl/include/sys/stat.h created+118
......@@ -0,0 +1,118 @@
1#ifndef _SYS_STAT_H
2#define _SYS_STAT_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <features.h>
8
9#define __NEED_dev_t
10#define __NEED_ino_t
11#define __NEED_mode_t
12#define __NEED_nlink_t
13#define __NEED_uid_t
14#define __NEED_gid_t
15#define __NEED_off_t
16#define __NEED_time_t
17#define __NEED_blksize_t
18#define __NEED_blkcnt_t
19#define __NEED_struct_timespec
20
21#include <bits/alltypes.h>
22
23#include <bits/stat.h>
24
25#define st_atime st_atim.tv_sec
26#define st_mtime st_mtim.tv_sec
27#define st_ctime st_ctim.tv_sec
28
29#define S_IFMT 0170000
30
31#define S_IFDIR 0040000
32#define S_IFCHR 0020000
33#define S_IFBLK 0060000
34#define S_IFREG 0100000
35#define S_IFIFO 0010000
36#define S_IFLNK 0120000
37#define S_IFSOCK 0140000
38
39#define S_TYPEISMQ(buf) 0
40#define S_TYPEISSEM(buf) 0
41#define S_TYPEISSHM(buf) 0
42#define S_TYPEISTMO(buf) 0
43
44#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
45#define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
46#define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
47#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
48#define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
49#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
50#define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
51
52#ifndef S_IRUSR
53#define S_ISUID 04000
54#define S_ISGID 02000
55#define S_ISVTX 01000
56#define S_IRUSR 0400
57#define S_IWUSR 0200
58#define S_IXUSR 0100
59#define S_IRWXU 0700
60#define S_IRGRP 0040
61#define S_IWGRP 0020
62#define S_IXGRP 0010
63#define S_IRWXG 0070
64#define S_IROTH 0004
65#define S_IWOTH 0002
66#define S_IXOTH 0001
67#define S_IRWXO 0007
68#endif
69
70#define UTIME_NOW 0x3fffffff
71#define UTIME_OMIT 0x3ffffffe
72
73int stat(const char *__restrict, struct stat *__restrict);
74int fstat(int, struct stat *);
75int lstat(const char *__restrict, struct stat *__restrict);
76int fstatat(int, const char *__restrict, struct stat *__restrict, int);
77int chmod(const char *, mode_t);
78int fchmod(int, mode_t);
79int fchmodat(int, const char *, mode_t, int);
80mode_t umask(mode_t);
81int mkdir(const char *, mode_t);
82int mkfifo(const char *, mode_t);
83int mkdirat(int, const char *, mode_t);
84int mkfifoat(int, const char *, mode_t);
85
86#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
87int mknod(const char *, mode_t, dev_t);
88int mknodat(int, const char *, mode_t, dev_t);
89#endif
90
91int futimens(int, const struct timespec [2]);
92int utimensat(int, const char *, const struct timespec [2], int);
93
94#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
95int lchmod(const char *, mode_t);
96#define S_IREAD S_IRUSR
97#define S_IWRITE S_IWUSR
98#define S_IEXEC S_IXUSR
99#endif
100
101#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
102#define stat64 stat
103#define fstat64 fstat
104#define lstat64 lstat
105#define fstatat64 fstatat
106#define blkcnt64_t blkcnt_t
107#define fsblkcnt64_t fsblkcnt_t
108#define fsfilcnt64_t fsfilcnt_t
109#define ino64_t ino_t
110#define off64_t off_t
111#endif
112
113#ifdef __cplusplus
114}
115#endif
116#endif
117
118
lib/libc/musl/include/sys/statfs.h created+32
......@@ -0,0 +1,32 @@
1#ifndef _SYS_STATFS_H
2#define _SYS_STATFS_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#include <sys/statvfs.h>
11
12typedef struct __fsid_t {
13 int __val[2];
14} fsid_t;
15
16#include <bits/statfs.h>
17
18int statfs (const char *, struct statfs *);
19int fstatfs (int, struct statfs *);
20
21#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
22#define statfs64 statfs
23#define fstatfs64 fstatfs
24#define fsblkcnt64_t fsblkcnt_t
25#define fsfilcnt64_t fsfilcnt_t
26#endif
27
28#ifdef __cplusplus
29}
30#endif
31
32#endif
lib/libc/musl/include/sys/statvfs.h created+58
......@@ -0,0 +1,58 @@
1#ifndef _SYS_STATVFS_H
2#define _SYS_STATVFS_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_fsblkcnt_t
11#define __NEED_fsfilcnt_t
12#include <bits/alltypes.h>
13
14#include <endian.h>
15
16struct statvfs {
17 unsigned long f_bsize, f_frsize;
18 fsblkcnt_t f_blocks, f_bfree, f_bavail;
19 fsfilcnt_t f_files, f_ffree, f_favail;
20#if __BYTE_ORDER == __LITTLE_ENDIAN
21 unsigned long f_fsid;
22 unsigned :8*(2*sizeof(int)-sizeof(long));
23#else
24 unsigned :8*(2*sizeof(int)-sizeof(long));
25 unsigned long f_fsid;
26#endif
27 unsigned long f_flag, f_namemax;
28 int __reserved[6];
29};
30
31int statvfs (const char *__restrict, struct statvfs *__restrict);
32int fstatvfs (int, struct statvfs *);
33
34#define ST_RDONLY 1
35#define ST_NOSUID 2
36#define ST_NODEV 4
37#define ST_NOEXEC 8
38#define ST_SYNCHRONOUS 16
39#define ST_MANDLOCK 64
40#define ST_WRITE 128
41#define ST_APPEND 256
42#define ST_IMMUTABLE 512
43#define ST_NOATIME 1024
44#define ST_NODIRATIME 2048
45#define ST_RELATIME 4096
46
47#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
48#define statvfs64 statvfs
49#define fstatvfs64 fstatvfs
50#define fsblkcnt64_t fsblkcnt_t
51#define fsfilcnt64_t fsfilcnt_t
52#endif
53
54#ifdef __cplusplus
55}
56#endif
57
58#endif
lib/libc/musl/include/sys/stropts.h created+1
......@@ -0,0 +1 @@
1#include <stropts.h>
lib/libc/musl/include/sys/swap.h created+21
......@@ -0,0 +1,21 @@
1#ifndef _SYS_SWAP_H
2#define _SYS_SWAP_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8
9#define SWAP_FLAG_PREFER 0x8000
10#define SWAP_FLAG_PRIO_MASK 0x7fff
11#define SWAP_FLAG_PRIO_SHIFT 0
12#define SWAP_FLAG_DISCARD 0x10000
13
14int swapon (const char *, int);
15int swapoff (const char *);
16
17#ifdef __cplusplus
18}
19#endif
20
21#endif
lib/libc/musl/include/sys/syscall.h created+6
......@@ -0,0 +1,6 @@
1#ifndef _SYS_SYSCALL_H
2#define _SYS_SYSCALL_H
3
4#include <bits/syscall.h>
5
6#endif
lib/libc/musl/include/sys/sysinfo.h created+36
......@@ -0,0 +1,36 @@
1#ifndef _SYS_SYSINFO_H
2#define _SYS_SYSINFO_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define SI_LOAD_SHIFT 16
9
10struct sysinfo {
11 unsigned long uptime;
12 unsigned long loads[3];
13 unsigned long totalram;
14 unsigned long freeram;
15 unsigned long sharedram;
16 unsigned long bufferram;
17 unsigned long totalswap;
18 unsigned long freeswap;
19 unsigned short procs, pad;
20 unsigned long totalhigh;
21 unsigned long freehigh;
22 unsigned mem_unit;
23 char __reserved[256];
24};
25
26int sysinfo (struct sysinfo *);
27int get_nprocs_conf (void);
28int get_nprocs (void);
29long get_phys_pages (void);
30long get_avphys_pages (void);
31
32#ifdef __cplusplus
33}
34#endif
35
36#endif
lib/libc/musl/include/sys/syslog.h created+1
......@@ -0,0 +1 @@
1#include <syslog.h>
lib/libc/musl/include/sys/sysmacros.h created+15
......@@ -0,0 +1,15 @@
1#ifndef _SYS_SYSMACROS_H
2#define _SYS_SYSMACROS_H
3
4#define major(x) \
5 ((unsigned)( (((x)>>31>>1) & 0xfffff000) | (((x)>>8) & 0x00000fff) ))
6#define minor(x) \
7 ((unsigned)( (((x)>>12) & 0xffffff00) | ((x) & 0x000000ff) ))
8
9#define makedev(x,y) ( \
10 (((x)&0xfffff000ULL) << 32) | \
11 (((x)&0x00000fffULL) << 8) | \
12 (((y)&0xffffff00ULL) << 12) | \
13 (((y)&0x000000ffULL)) )
14
15#endif
lib/libc/musl/include/sys/termios.h created+2
......@@ -0,0 +1,2 @@
1#warning redirecting incorrect #include <sys/termios.h> to <termios.h>
2#include <termios.h>
lib/libc/musl/include/sys/time.h created+62
......@@ -0,0 +1,62 @@
1#ifndef _SYS_TIME_H
2#define _SYS_TIME_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <features.h>
8
9#include <sys/select.h>
10
11int gettimeofday (struct timeval *__restrict, void *__restrict);
12
13#define ITIMER_REAL 0
14#define ITIMER_VIRTUAL 1
15#define ITIMER_PROF 2
16
17struct itimerval {
18 struct timeval it_interval;
19 struct timeval it_value;
20};
21
22int getitimer (int, struct itimerval *);
23int setitimer (int, const struct itimerval *__restrict, struct itimerval *__restrict);
24int utimes (const char *, const struct timeval [2]);
25
26#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
27struct timezone {
28 int tz_minuteswest;
29 int tz_dsttime;
30};
31int futimes(int, const struct timeval [2]);
32int futimesat(int, const char *, const struct timeval [2]);
33int lutimes(const char *, const struct timeval [2]);
34int settimeofday(const struct timeval *, const struct timezone *);
35int adjtime (const struct timeval *, struct timeval *);
36#define timerisset(t) ((t)->tv_sec || (t)->tv_usec)
37#define timerclear(t) ((t)->tv_sec = (t)->tv_usec = 0)
38#define timercmp(s,t,op) ((s)->tv_sec == (t)->tv_sec ? \
39 (s)->tv_usec op (t)->tv_usec : (s)->tv_sec op (t)->tv_sec)
40#define timeradd(s,t,a) (void) ( (a)->tv_sec = (s)->tv_sec + (t)->tv_sec, \
41 ((a)->tv_usec = (s)->tv_usec + (t)->tv_usec) >= 1000000 && \
42 ((a)->tv_usec -= 1000000, (a)->tv_sec++) )
43#define timersub(s,t,a) (void) ( (a)->tv_sec = (s)->tv_sec - (t)->tv_sec, \
44 ((a)->tv_usec = (s)->tv_usec - (t)->tv_usec) < 0 && \
45 ((a)->tv_usec += 1000000, (a)->tv_sec--) )
46#endif
47
48#if defined(_GNU_SOURCE)
49#define TIMEVAL_TO_TIMESPEC(tv, ts) ( \
50 (ts)->tv_sec = (tv)->tv_sec, \
51 (ts)->tv_nsec = (tv)->tv_usec * 1000, \
52 (void)0 )
53#define TIMESPEC_TO_TIMEVAL(tv, ts) ( \
54 (tv)->tv_sec = (ts)->tv_sec, \
55 (tv)->tv_usec = (ts)->tv_nsec / 1000, \
56 (void)0 )
57#endif
58
59#ifdef __cplusplus
60}
61#endif
62#endif
lib/libc/musl/include/sys/timeb.h created+22
......@@ -0,0 +1,22 @@
1#ifndef _SYS_TIMEB_H
2#define _SYS_TIMEB_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#define __NEED_time_t
8
9#include <bits/alltypes.h>
10
11struct timeb {
12 time_t time;
13 unsigned short millitm;
14 short timezone, dstflag;
15};
16
17int ftime(struct timeb *);
18
19#ifdef __cplusplus
20}
21#endif
22#endif
lib/libc/musl/include/sys/timerfd.h created+27
......@@ -0,0 +1,27 @@
1#ifndef _SYS_TIMERFD_H
2#define _SYS_TIMERFD_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <time.h>
9#include <fcntl.h>
10
11#define TFD_NONBLOCK O_NONBLOCK
12#define TFD_CLOEXEC O_CLOEXEC
13
14#define TFD_TIMER_ABSTIME 1
15#define TFD_TIMER_CANCEL_ON_SET (1 << 1)
16
17struct itimerspec;
18
19int timerfd_create(int, int);
20int timerfd_settime(int, int, const struct itimerspec *, struct itimerspec *);
21int timerfd_gettime(int, struct itimerspec *);
22
23#ifdef __cplusplus
24}
25#endif
26
27#endif
lib/libc/musl/include/sys/times.h created+25
......@@ -0,0 +1,25 @@
1#ifndef _SYS_TIMES_H
2#define _SYS_TIMES_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define __NEED_clock_t
9#include <bits/alltypes.h>
10
11struct tms {
12 clock_t tms_utime;
13 clock_t tms_stime;
14 clock_t tms_cutime;
15 clock_t tms_cstime;
16};
17
18clock_t times (struct tms *);
19
20#ifdef __cplusplus
21}
22#endif
23
24#endif
25
lib/libc/musl/include/sys/timex.h created+98
......@@ -0,0 +1,98 @@
1#ifndef _SYS_TIMEX_H
2#define _SYS_TIMEX_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define __NEED_clockid_t
9
10#include <bits/alltypes.h>
11
12#include <sys/time.h>
13
14struct ntptimeval {
15 struct timeval time;
16 long maxerror, esterror;
17};
18
19struct timex {
20 unsigned modes;
21 long offset, freq, maxerror, esterror;
22 int status;
23 long constant, precision, tolerance;
24 struct timeval time;
25 long tick, ppsfreq, jitter;
26 int shift;
27 long stabil, jitcnt, calcnt, errcnt, stbcnt;
28 int tai;
29 int __padding[11];
30};
31
32#define ADJ_OFFSET 0x0001
33#define ADJ_FREQUENCY 0x0002
34#define ADJ_MAXERROR 0x0004
35#define ADJ_ESTERROR 0x0008
36#define ADJ_STATUS 0x0010
37#define ADJ_TIMECONST 0x0020
38#define ADJ_TAI 0x0080
39#define ADJ_SETOFFSET 0x0100
40#define ADJ_MICRO 0x1000
41#define ADJ_NANO 0x2000
42#define ADJ_TICK 0x4000
43#define ADJ_OFFSET_SINGLESHOT 0x8001
44#define ADJ_OFFSET_SS_READ 0xa001
45
46#define MOD_OFFSET ADJ_OFFSET
47#define MOD_FREQUENCY ADJ_FREQUENCY
48#define MOD_MAXERROR ADJ_MAXERROR
49#define MOD_ESTERROR ADJ_ESTERROR
50#define MOD_STATUS ADJ_STATUS
51#define MOD_TIMECONST ADJ_TIMECONST
52#define MOD_CLKB ADJ_TICK
53#define MOD_CLKA ADJ_OFFSET_SINGLESHOT
54#define MOD_TAI ADJ_TAI
55#define MOD_MICRO ADJ_MICRO
56#define MOD_NANO ADJ_NANO
57
58#define STA_PLL 0x0001
59#define STA_PPSFREQ 0x0002
60#define STA_PPSTIME 0x0004
61#define STA_FLL 0x0008
62
63#define STA_INS 0x0010
64#define STA_DEL 0x0020
65#define STA_UNSYNC 0x0040
66#define STA_FREQHOLD 0x0080
67
68#define STA_PPSSIGNAL 0x0100
69#define STA_PPSJITTER 0x0200
70#define STA_PPSWANDER 0x0400
71#define STA_PPSERROR 0x0800
72
73#define STA_CLOCKERR 0x1000
74#define STA_NANO 0x2000
75#define STA_MODE 0x4000
76#define STA_CLK 0x8000
77
78#define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \
79 STA_PPSERROR | STA_CLOCKERR | STA_NANO | STA_MODE | STA_CLK)
80
81#define TIME_OK 0
82#define TIME_INS 1
83#define TIME_DEL 2
84#define TIME_OOP 3
85#define TIME_WAIT 4
86#define TIME_ERROR 5
87#define TIME_BAD TIME_ERROR
88
89#define MAXTC 6
90
91int adjtimex(struct timex *);
92int clock_adjtime(clockid_t, struct timex *);
93
94#ifdef __cplusplus
95}
96#endif
97
98#endif
lib/libc/musl/include/sys/ttydefaults.h created+39
......@@ -0,0 +1,39 @@
1#ifndef _SYS_TTYDEFAULTS_H
2#define _SYS_TTYDEFAULTS_H
3
4#define TTYDEF_IFLAG (BRKINT | ISTRIP | ICRNL | IMAXBEL | IXON | IXANY)
5#define TTYDEF_OFLAG (OPOST | ONLCR | XTABS)
6#define TTYDEF_LFLAG (ECHO | ICANON | ISIG | IEXTEN | ECHOE|ECHOKE|ECHOCTL)
7#define TTYDEF_CFLAG (CREAD | CS7 | PARENB | HUPCL)
8#define TTYDEF_SPEED (B9600)
9#define CTRL(x) (x&037)
10#define CEOF CTRL('d')
11
12#ifdef _POSIX_VDISABLE
13#define CEOL _POSIX_VDISABLE
14#define CSTATUS _POSIX_VDISABLE
15#else
16#define CEOL '\0'
17#define CSTATUS '\0'
18#endif
19
20#define CERASE 0177
21#define CINTR CTRL('c')
22#define CKILL CTRL('u')
23#define CMIN 1
24#define CQUIT 034
25#define CSUSP CTRL('z')
26#define CTIME 0
27#define CDSUSP CTRL('y')
28#define CSTART CTRL('q')
29#define CSTOP CTRL('s')
30#define CLNEXT CTRL('v')
31#define CDISCARD CTRL('o')
32#define CWERASE CTRL('w')
33#define CREPRINT CTRL('r')
34#define CEOT CEOF
35#define CBRK CEOL
36#define CRPRNT CREPRINT
37#define CFLUSH CDISCARD
38
39#endif
lib/libc/musl/include/sys/types.h created+85
......@@ -0,0 +1,85 @@
1#ifndef _SYS_TYPES_H
2#define _SYS_TYPES_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <features.h>
8
9#define __NEED_ino_t
10#define __NEED_dev_t
11#define __NEED_uid_t
12#define __NEED_gid_t
13#define __NEED_mode_t
14#define __NEED_nlink_t
15#define __NEED_off_t
16#define __NEED_pid_t
17#define __NEED_size_t
18#define __NEED_ssize_t
19#define __NEED_time_t
20#define __NEED_timer_t
21#define __NEED_clockid_t
22
23#define __NEED_blkcnt_t
24#define __NEED_fsblkcnt_t
25#define __NEED_fsfilcnt_t
26
27#define __NEED_id_t
28#define __NEED_key_t
29#define __NEED_clock_t
30#define __NEED_suseconds_t
31#define __NEED_blksize_t
32
33#define __NEED_pthread_t
34#define __NEED_pthread_attr_t
35#define __NEED_pthread_mutexattr_t
36#define __NEED_pthread_condattr_t
37#define __NEED_pthread_rwlockattr_t
38#define __NEED_pthread_barrierattr_t
39#define __NEED_pthread_mutex_t
40#define __NEED_pthread_cond_t
41#define __NEED_pthread_rwlock_t
42#define __NEED_pthread_barrier_t
43#define __NEED_pthread_spinlock_t
44#define __NEED_pthread_key_t
45#define __NEED_pthread_once_t
46#define __NEED_useconds_t
47
48#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
49#define __NEED_int8_t
50#define __NEED_int16_t
51#define __NEED_int32_t
52#define __NEED_int64_t
53#define __NEED_u_int64_t
54#define __NEED_register_t
55#endif
56
57#include <bits/alltypes.h>
58
59#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
60typedef unsigned char u_int8_t;
61typedef unsigned short u_int16_t;
62typedef unsigned u_int32_t;
63typedef char *caddr_t;
64typedef unsigned char u_char;
65typedef unsigned short u_short, ushort;
66typedef unsigned u_int, uint;
67typedef unsigned long u_long, ulong;
68typedef long long quad_t;
69typedef unsigned long long u_quad_t;
70#include <endian.h>
71#include <sys/select.h>
72#endif
73
74#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
75#define blkcnt64_t blkcnt_t
76#define fsblkcnt64_t fsblkcnt_t
77#define fsfilcnt64_t fsfilcnt_t
78#define ino64_t ino_t
79#define off64_t off_t
80#endif
81
82#ifdef __cplusplus
83}
84#endif
85#endif
lib/libc/musl/include/sys/ucontext.h created+1
......@@ -0,0 +1 @@
1#include <ucontext.h>
lib/libc/musl/include/sys/uio.h created+48
......@@ -0,0 +1,48 @@
1#ifndef _SYS_UIO_H
2#define _SYS_UIO_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_size_t
11#define __NEED_ssize_t
12#define __NEED_struct_iovec
13
14#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
15#define __NEED_off_t
16#endif
17
18#ifdef _GNU_SOURCE
19#define __NEED_pid_t
20#endif
21
22#include <bits/alltypes.h>
23
24#define UIO_MAXIOV 1024
25
26ssize_t readv (int, const struct iovec *, int);
27ssize_t writev (int, const struct iovec *, int);
28
29#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
30ssize_t preadv (int, const struct iovec *, int, off_t);
31ssize_t pwritev (int, const struct iovec *, int, off_t);
32#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
33#define preadv64 preadv
34#define pwritev64 pwritev
35#define off64_t off_t
36#endif
37#endif
38
39#ifdef _GNU_SOURCE
40ssize_t process_vm_writev(pid_t, const struct iovec *, unsigned long, const struct iovec *, unsigned long, unsigned long);
41ssize_t process_vm_readv(pid_t, const struct iovec *, unsigned long, const struct iovec *, unsigned long, unsigned long);
42#endif
43
44#ifdef __cplusplus
45}
46#endif
47
48#endif
lib/libc/musl/include/sys/un.h created+31
......@@ -0,0 +1,31 @@
1#ifndef _SYS_UN_H
2#define _SYS_UN_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_sa_family_t
11#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
12#define __NEED_size_t
13#endif
14
15#include <bits/alltypes.h>
16
17struct sockaddr_un {
18 sa_family_t sun_family;
19 char sun_path[108];
20};
21
22#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
23size_t strlen(const char *);
24#define SUN_LEN(s) (2+strlen((s)->sun_path))
25#endif
26
27#ifdef __cplusplus
28}
29#endif
30
31#endif
lib/libc/musl/include/sys/user.h created+16
......@@ -0,0 +1,16 @@
1#ifndef _SYS_USER_H
2#define _SYS_USER_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <limits.h>
8#include <stdint.h>
9#include <unistd.h>
10
11#include <bits/user.h>
12
13#ifdef __cplusplus
14}
15#endif
16#endif
lib/libc/musl/include/sys/utsname.h created+29
......@@ -0,0 +1,29 @@
1#ifndef _SYS_UTSNAME_H
2#define _SYS_UTSNAME_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10struct utsname {
11 char sysname[65];
12 char nodename[65];
13 char release[65];
14 char version[65];
15 char machine[65];
16#ifdef _GNU_SOURCE
17 char domainname[65];
18#else
19 char __domainname[65];
20#endif
21};
22
23int uname (struct utsname *);
24
25#ifdef __cplusplus
26}
27#endif
28
29#endif
lib/libc/musl/include/sys/vfs.h created+1
......@@ -0,0 +1 @@
1#include <sys/statfs.h>
lib/libc/musl/include/sys/vt.h created+1
......@@ -0,0 +1 @@
1#include <bits/vt.h>
lib/libc/musl/include/sys/wait.h created+59
......@@ -0,0 +1,59 @@
1#ifndef _SYS_WAIT_H
2#define _SYS_WAIT_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <features.h>
8
9#define __NEED_pid_t
10#define __NEED_id_t
11#include <bits/alltypes.h>
12
13typedef enum {
14 P_ALL = 0,
15 P_PID = 1,
16 P_PGID = 2
17} idtype_t;
18
19pid_t wait (int *);
20pid_t waitpid (pid_t, int *, int );
21
22#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
23 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
24 || defined(_BSD_SOURCE)
25#include <signal.h>
26int waitid (idtype_t, id_t, siginfo_t *, int);
27#endif
28
29#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
30#include <sys/resource.h>
31pid_t wait3 (int *, int, struct rusage *);
32pid_t wait4 (pid_t, int *, int, struct rusage *);
33#endif
34
35#define WNOHANG 1
36#define WUNTRACED 2
37
38#define WSTOPPED 2
39#define WEXITED 4
40#define WCONTINUED 8
41#define WNOWAIT 0x1000000
42
43#define __WNOTHREAD 0x20000000
44#define __WALL 0x40000000
45#define __WCLONE 0x80000000
46
47#define WEXITSTATUS(s) (((s) & 0xff00) >> 8)
48#define WTERMSIG(s) ((s) & 0x7f)
49#define WSTOPSIG(s) WEXITSTATUS(s)
50#define WCOREDUMP(s) ((s) & 0x80)
51#define WIFEXITED(s) (!WTERMSIG(s))
52#define WIFSTOPPED(s) ((short)((((s)&0xffff)*0x10001)>>8) > 0x7f00)
53#define WIFSIGNALED(s) (((s)&0xffff)-1U < 0xffu)
54#define WIFCONTINUED(s) ((s) == 0xffff)
55
56#ifdef __cplusplus
57}
58#endif
59#endif
lib/libc/musl/include/sys/xattr.h created+32
......@@ -0,0 +1,32 @@
1#ifndef _SYS_XATTR_H
2#define _SYS_XATTR_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#define __NEED_ssize_t
8#define __NEED_size_t
9#include <bits/alltypes.h>
10
11#define XATTR_CREATE 1
12#define XATTR_REPLACE 2
13
14ssize_t getxattr(const char *, const char *, void *, size_t);
15ssize_t lgetxattr(const char *, const char *, void *, size_t);
16ssize_t fgetxattr(int, const char *, void *, size_t);
17ssize_t listxattr(const char *, char *, size_t);
18ssize_t llistxattr(const char *, char *, size_t);
19ssize_t flistxattr(int, char *, size_t);
20int setxattr(const char *, const char *, const void *, size_t, int);
21int lsetxattr(const char *, const char *, const void *, size_t, int);
22int fsetxattr(int, const char *, const void *, size_t, int);
23int removexattr(const char *, const char *);
24int lremovexattr(const char *, const char *);
25int fremovexattr(int, const char *);
26
27#define __UAPI_DEF_XATTR 0
28
29#ifdef __cplusplus
30}
31#endif
32#endif
lib/libc/musl/include/syscall.h created+1
......@@ -0,0 +1 @@
1#include <sys/syscall.h>
lib/libc/musl/include/sysexits.h created+21
......@@ -0,0 +1,21 @@
1#ifndef _SYSEXITS_H
2#define _SYSEXITS_H
3#define EX_OK 0
4#define EX__BASE 64
5#define EX_USAGE 64
6#define EX_DATAERR 65
7#define EX_NOINPUT 66
8#define EX_NOUSER 67
9#define EX_NOHOST 68
10#define EX_UNAVAILABLE 69
11#define EX_SOFTWARE 70
12#define EX_OSERR 71
13#define EX_OSFILE 72
14#define EX_CANTCREAT 73
15#define EX_IOERR 74
16#define EX_TEMPFAIL 75
17#define EX_PROTOCOL 76
18#define EX_NOPERM 77
19#define EX_CONFIG 78
20#define EX__MAX 78
21#endif
lib/libc/musl/include/syslog.h created+100
......@@ -0,0 +1,100 @@
1#ifndef _SYSLOG_H
2#define _SYSLOG_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define LOG_EMERG 0
11#define LOG_ALERT 1
12#define LOG_CRIT 2
13#define LOG_ERR 3
14#define LOG_WARNING 4
15#define LOG_NOTICE 5
16#define LOG_INFO 6
17#define LOG_DEBUG 7
18
19#define LOG_PRIMASK 7
20#define LOG_PRI(p) ((p)&LOG_PRIMASK)
21#define LOG_MAKEPRI(f, p) (((f)<<3)|(p))
22
23#define LOG_MASK(p) (1<<(p))
24#define LOG_UPTO(p) ((1<<((p)+1))-1)
25
26#define LOG_KERN (0<<3)
27#define LOG_USER (1<<3)
28#define LOG_MAIL (2<<3)
29#define LOG_DAEMON (3<<3)
30#define LOG_AUTH (4<<3)
31#define LOG_SYSLOG (5<<3)
32#define LOG_LPR (6<<3)
33#define LOG_NEWS (7<<3)
34#define LOG_UUCP (8<<3)
35#define LOG_CRON (9<<3)
36#define LOG_AUTHPRIV (10<<3)
37#define LOG_FTP (11<<3)
38
39#define LOG_LOCAL0 (16<<3)
40#define LOG_LOCAL1 (17<<3)
41#define LOG_LOCAL2 (18<<3)
42#define LOG_LOCAL3 (19<<3)
43#define LOG_LOCAL4 (20<<3)
44#define LOG_LOCAL5 (21<<3)
45#define LOG_LOCAL6 (22<<3)
46#define LOG_LOCAL7 (23<<3)
47
48#define LOG_NFACILITIES 24
49#define LOG_FACMASK 0x3f8
50#define LOG_FAC(p) (((p)&LOG_FACMASK)>>3)
51
52#define LOG_PID 0x01
53#define LOG_CONS 0x02
54#define LOG_ODELAY 0x04
55#define LOG_NDELAY 0x08
56#define LOG_NOWAIT 0x10
57#define LOG_PERROR 0x20
58
59void closelog (void);
60void openlog (const char *, int, int);
61int setlogmask (int);
62void syslog (int, const char *, ...);
63
64#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
65#define _PATH_LOG "/dev/log"
66#define __NEED_va_list
67#include <bits/alltypes.h>
68void vsyslog (int, const char *, va_list);
69#if defined(SYSLOG_NAMES)
70#define INTERNAL_NOPRI 0x10
71#define INTERNAL_MARK (LOG_NFACILITIES<<3)
72typedef struct {
73 char *c_name;
74 int c_val;
75} CODE;
76#define prioritynames ((CODE *)(const CODE []){ \
77 { "alert", LOG_ALERT }, { "crit", LOG_CRIT }, { "debug", LOG_DEBUG }, \
78 { "emerg", LOG_EMERG }, { "err", LOG_ERR }, { "error", LOG_ERR }, \
79 { "info", LOG_INFO }, { "none", INTERNAL_NOPRI }, \
80 { "notice", LOG_NOTICE }, { "panic", LOG_EMERG }, \
81 { "warn", LOG_WARNING }, { "warning", LOG_WARNING }, { 0, -1 } })
82#define facilitynames ((CODE *)(const CODE []){ \
83 { "auth", LOG_AUTH }, { "authpriv", LOG_AUTHPRIV }, \
84 { "cron", LOG_CRON }, { "daemon", LOG_DAEMON }, { "ftp", LOG_FTP }, \
85 { "kern", LOG_KERN }, { "lpr", LOG_LPR }, { "mail", LOG_MAIL }, \
86 { "mark", INTERNAL_MARK }, { "news", LOG_NEWS }, \
87 { "security", LOG_AUTH }, { "syslog", LOG_SYSLOG }, \
88 { "user", LOG_USER }, { "uucp", LOG_UUCP }, \
89 { "local0", LOG_LOCAL0 }, { "local1", LOG_LOCAL1 }, \
90 { "local2", LOG_LOCAL2 }, { "local3", LOG_LOCAL3 }, \
91 { "local4", LOG_LOCAL4 }, { "local5", LOG_LOCAL5 }, \
92 { "local6", LOG_LOCAL6 }, { "local7", LOG_LOCAL7 }, { 0, -1 } })
93#endif
94#endif
95
96#ifdef __cplusplus
97}
98#endif
99
100#endif
lib/libc/musl/include/tar.h created+33
......@@ -0,0 +1,33 @@
1#ifndef _TAR_H
2#define _TAR_H
3
4#define TSUID 04000
5#define TSGID 02000
6#define TSVTX 01000
7#define TUREAD 00400
8#define TUWRITE 00200
9#define TUEXEC 00100
10#define TGREAD 00040
11#define TGWRITE 00020
12#define TGEXEC 00010
13#define TOREAD 00004
14#define TOWRITE 00002
15#define TOEXEC 00001
16
17#define REGTYPE '0'
18#define AREGTYPE '\0'
19#define LNKTYPE '1'
20#define SYMTYPE '2'
21#define CHRTYPE '3'
22#define BLKTYPE '4'
23#define DIRTYPE '5'
24#define FIFOTYPE '6'
25#define CONTTYPE '7'
26
27#define TMAGIC "ustar"
28#define TMAGLEN 6
29
30#define TVERSION "00"
31#define TVERSLEN 2
32
33#endif
lib/libc/musl/include/termios.h created+46
......@@ -0,0 +1,46 @@
1#ifndef _TERMIOS_H
2#define _TERMIOS_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_pid_t
11
12#include <bits/alltypes.h>
13
14typedef unsigned char cc_t;
15typedef unsigned int speed_t;
16typedef unsigned int tcflag_t;
17
18#define NCCS 32
19
20#include <bits/termios.h>
21
22speed_t cfgetospeed (const struct termios *);
23speed_t cfgetispeed (const struct termios *);
24int cfsetospeed (struct termios *, speed_t);
25int cfsetispeed (struct termios *, speed_t);
26
27int tcgetattr (int, struct termios *);
28int tcsetattr (int, int, const struct termios *);
29
30int tcsendbreak (int, int);
31int tcdrain (int);
32int tcflush (int, int);
33int tcflow (int, int);
34
35pid_t tcgetsid (int);
36
37#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
38void cfmakeraw(struct termios *);
39int cfsetspeed(struct termios *, speed_t);
40#endif
41
42#ifdef __cplusplus
43}
44#endif
45
46#endif
lib/libc/musl/include/tgmath.h created+270
......@@ -0,0 +1,270 @@
1#ifndef _TGMATH_H
2#define _TGMATH_H
3
4/*
5the return types are only correct with gcc (__GNUC__)
6otherwise they are long double or long double complex
7
8the long double version of a function is never chosen when
9sizeof(double) == sizeof(long double)
10(but the return type is set correctly with gcc)
11*/
12
13#include <math.h>
14#include <complex.h>
15
16#define __IS_FP(x) (sizeof((x)+1ULL) == sizeof((x)+1.0f))
17#define __IS_CX(x) (__IS_FP(x) && sizeof(x) == sizeof((x)+I))
18#define __IS_REAL(x) (__IS_FP(x) && 2*sizeof(x) == sizeof((x)+I))
19
20#define __FLT(x) (__IS_REAL(x) && sizeof(x) == sizeof(float))
21#define __LDBL(x) (__IS_REAL(x) && sizeof(x) == sizeof(long double) && sizeof(long double) != sizeof(double))
22
23#define __FLTCX(x) (__IS_CX(x) && sizeof(x) == sizeof(float complex))
24#define __DBLCX(x) (__IS_CX(x) && sizeof(x) == sizeof(double complex))
25#define __LDBLCX(x) (__IS_CX(x) && sizeof(x) == sizeof(long double complex) && sizeof(long double) != sizeof(double))
26
27/* return type */
28
29#ifdef __GNUC__
30/*
31the result must be casted to the right type
32(otherwise the result type is determined by the conversion
33rules applied to all the function return types so it is long
34double or long double complex except for integral functions)
35
36this cannot be done in c99, so the typeof gcc extension is
37used and that the type of ?: depends on wether an operand is
38a null pointer constant or not
39(in c11 _Generic can be used)
40
41the c arguments below must be integer constant expressions
42so they can be in null pointer constants
43(__IS_FP above was carefully chosen this way)
44*/
45/* if c then t else void */
46#define __type1(c,t) __typeof__(*(0?(t*)0:(void*)!(c)))
47/* if c then t1 else t2 */
48#define __type2(c,t1,t2) __typeof__(*(0?(__type1(c,t1)*)0:(__type1(!(c),t2)*)0))
49/* cast to double when x is integral, otherwise use typeof(x) */
50#define __RETCAST(x) ( \
51 __type2(__IS_FP(x), __typeof__(x), double))
52/* 2 args case, should work for complex types (cpow) */
53#define __RETCAST_2(x, y) ( \
54 __type2(__IS_FP(x) && __IS_FP(y), \
55 __typeof__((x)+(y)), \
56 __typeof__((x)+(y)+1.0)))
57/* 3 args case (fma only) */
58#define __RETCAST_3(x, y, z) ( \
59 __type2(__IS_FP(x) && __IS_FP(y) && __IS_FP(z), \
60 __typeof__((x)+(y)+(z)), \
61 __typeof__((x)+(y)+(z)+1.0)))
62/* drop complex from the type of x */
63/* TODO: wrong when sizeof(long double)==sizeof(double) */
64#define __RETCAST_REAL(x) ( \
65 __type2(__IS_FP(x) && sizeof((x)+I) == sizeof(float complex), float, \
66 __type2(sizeof((x)+1.0+I) == sizeof(double complex), double, \
67 long double)))
68/* add complex to the type of x */
69#define __RETCAST_CX(x) (__typeof__(__RETCAST(x)0+I))
70#else
71#define __RETCAST(x)
72#define __RETCAST_2(x, y)
73#define __RETCAST_3(x, y, z)
74#define __RETCAST_REAL(x)
75#define __RETCAST_CX(x)
76#endif
77
78/* function selection */
79
80#define __tg_real_nocast(fun, x) ( \
81 __FLT(x) ? fun ## f (x) : \
82 __LDBL(x) ? fun ## l (x) : \
83 fun(x) )
84
85#define __tg_real(fun, x) (__RETCAST(x)__tg_real_nocast(fun, x))
86
87#define __tg_real_2_1(fun, x, y) (__RETCAST(x)( \
88 __FLT(x) ? fun ## f (x, y) : \
89 __LDBL(x) ? fun ## l (x, y) : \
90 fun(x, y) ))
91
92#define __tg_real_2(fun, x, y) (__RETCAST_2(x, y)( \
93 __FLT(x) && __FLT(y) ? fun ## f (x, y) : \
94 __LDBL((x)+(y)) ? fun ## l (x, y) : \
95 fun(x, y) ))
96
97#define __tg_complex(fun, x) (__RETCAST_CX(x)( \
98 __FLTCX((x)+I) && __IS_FP(x) ? fun ## f (x) : \
99 __LDBLCX((x)+I) ? fun ## l (x) : \
100 fun(x) ))
101
102#define __tg_complex_retreal(fun, x) (__RETCAST_REAL(x)( \
103 __FLTCX((x)+I) && __IS_FP(x) ? fun ## f (x) : \
104 __LDBLCX((x)+I) ? fun ## l (x) : \
105 fun(x) ))
106
107#define __tg_real_complex(fun, x) (__RETCAST(x)( \
108 __FLTCX(x) ? c ## fun ## f (x) : \
109 __DBLCX(x) ? c ## fun (x) : \
110 __LDBLCX(x) ? c ## fun ## l (x) : \
111 __FLT(x) ? fun ## f (x) : \
112 __LDBL(x) ? fun ## l (x) : \
113 fun(x) ))
114
115/* special cases */
116
117#define __tg_real_remquo(x, y, z) (__RETCAST_2(x, y)( \
118 __FLT(x) && __FLT(y) ? remquof(x, y, z) : \
119 __LDBL((x)+(y)) ? remquol(x, y, z) : \
120 remquo(x, y, z) ))
121
122#define __tg_real_fma(x, y, z) (__RETCAST_3(x, y, z)( \
123 __FLT(x) && __FLT(y) && __FLT(z) ? fmaf(x, y, z) : \
124 __LDBL((x)+(y)+(z)) ? fmal(x, y, z) : \
125 fma(x, y, z) ))
126
127#define __tg_real_complex_pow(x, y) (__RETCAST_2(x, y)( \
128 __FLTCX((x)+(y)) && __IS_FP(x) && __IS_FP(y) ? cpowf(x, y) : \
129 __FLTCX((x)+(y)) ? cpow(x, y) : \
130 __DBLCX((x)+(y)) ? cpow(x, y) : \
131 __LDBLCX((x)+(y)) ? cpowl(x, y) : \
132 __FLT(x) && __FLT(y) ? powf(x, y) : \
133 __LDBL((x)+(y)) ? powl(x, y) : \
134 pow(x, y) ))
135
136#define __tg_real_complex_fabs(x) (__RETCAST_REAL(x)( \
137 __FLTCX(x) ? cabsf(x) : \
138 __DBLCX(x) ? cabs(x) : \
139 __LDBLCX(x) ? cabsl(x) : \
140 __FLT(x) ? fabsf(x) : \
141 __LDBL(x) ? fabsl(x) : \
142 fabs(x) ))
143
144/* suppress any macros in math.h or complex.h */
145
146#undef acos
147#undef acosh
148#undef asin
149#undef asinh
150#undef atan
151#undef atan2
152#undef atanh
153#undef carg
154#undef cbrt
155#undef ceil
156#undef cimag
157#undef conj
158#undef copysign
159#undef cos
160#undef cosh
161#undef cproj
162#undef creal
163#undef erf
164#undef erfc
165#undef exp
166#undef exp2
167#undef expm1
168#undef fabs
169#undef fdim
170#undef floor
171#undef fma
172#undef fmax
173#undef fmin
174#undef fmod
175#undef frexp
176#undef hypot
177#undef ilogb
178#undef ldexp
179#undef lgamma
180#undef llrint
181#undef llround
182#undef log
183#undef log10
184#undef log1p
185#undef log2
186#undef logb
187#undef lrint
188#undef lround
189#undef nearbyint
190#undef nextafter
191#undef nexttoward
192#undef pow
193#undef remainder
194#undef remquo
195#undef rint
196#undef round
197#undef scalbln
198#undef scalbn
199#undef sin
200#undef sinh
201#undef sqrt
202#undef tan
203#undef tanh
204#undef tgamma
205#undef trunc
206
207/* tg functions */
208
209#define acos(x) __tg_real_complex(acos, (x))
210#define acosh(x) __tg_real_complex(acosh, (x))
211#define asin(x) __tg_real_complex(asin, (x))
212#define asinh(x) __tg_real_complex(asinh, (x))
213#define atan(x) __tg_real_complex(atan, (x))
214#define atan2(x,y) __tg_real_2(atan2, (x), (y))
215#define atanh(x) __tg_real_complex(atanh, (x))
216#define carg(x) __tg_complex_retreal(carg, (x))
217#define cbrt(x) __tg_real(cbrt, (x))
218#define ceil(x) __tg_real(ceil, (x))
219#define cimag(x) __tg_complex_retreal(cimag, (x))
220#define conj(x) __tg_complex(conj, (x))
221#define copysign(x,y) __tg_real_2(copysign, (x), (y))
222#define cos(x) __tg_real_complex(cos, (x))
223#define cosh(x) __tg_real_complex(cosh, (x))
224#define cproj(x) __tg_complex(cproj, (x))
225#define creal(x) __tg_complex_retreal(creal, (x))
226#define erf(x) __tg_real(erf, (x))
227#define erfc(x) __tg_real(erfc, (x))
228#define exp(x) __tg_real_complex(exp, (x))
229#define exp2(x) __tg_real(exp2, (x))
230#define expm1(x) __tg_real(expm1, (x))
231#define fabs(x) __tg_real_complex_fabs(x)
232#define fdim(x,y) __tg_real_2(fdim, (x), (y))
233#define floor(x) __tg_real(floor, (x))
234#define fma(x,y,z) __tg_real_fma((x), (y), (z))
235#define fmax(x,y) __tg_real_2(fmax, (x), (y))
236#define fmin(x,y) __tg_real_2(fmin, (x), (y))
237#define fmod(x,y) __tg_real_2(fmod, (x), (y))
238#define frexp(x,y) __tg_real_2_1(frexp, (x), (y))
239#define hypot(x,y) __tg_real_2(hypot, (x), (y))
240#define ilogb(x) __tg_real_nocast(ilogb, (x))
241#define ldexp(x,y) __tg_real_2_1(ldexp, (x), (y))
242#define lgamma(x) __tg_real(lgamma, (x))
243#define llrint(x) __tg_real_nocast(llrint, (x))
244#define llround(x) __tg_real_nocast(llround, (x))
245#define log(x) __tg_real_complex(log, (x))
246#define log10(x) __tg_real(log10, (x))
247#define log1p(x) __tg_real(log1p, (x))
248#define log2(x) __tg_real(log2, (x))
249#define logb(x) __tg_real(logb, (x))
250#define lrint(x) __tg_real_nocast(lrint, (x))
251#define lround(x) __tg_real_nocast(lround, (x))
252#define nearbyint(x) __tg_real(nearbyint, (x))
253#define nextafter(x,y) __tg_real_2(nextafter, (x), (y))
254#define nexttoward(x,y) __tg_real_2(nexttoward, (x), (y))
255#define pow(x,y) __tg_real_complex_pow((x), (y))
256#define remainder(x,y) __tg_real_2(remainder, (x), (y))
257#define remquo(x,y,z) __tg_real_remquo((x), (y), (z))
258#define rint(x) __tg_real(rint, (x))
259#define round(x) __tg_real(round, (x))
260#define scalbln(x,y) __tg_real_2_1(scalbln, (x), (y))
261#define scalbn(x,y) __tg_real_2_1(scalbn, (x), (y))
262#define sin(x) __tg_real_complex(sin, (x))
263#define sinh(x) __tg_real_complex(sinh, (x))
264#define sqrt(x) __tg_real_complex(sqrt, (x))
265#define tan(x) __tg_real_complex(tan, (x))
266#define tanh(x) __tg_real_complex(tanh, (x))
267#define tgamma(x) __tg_real(tgamma, (x))
268#define trunc(x) __tg_real(trunc, (x))
269
270#endif
lib/libc/musl/include/threads.h created+87
......@@ -0,0 +1,87 @@
1#ifndef _THREADS_H
2#define _THREADS_H
3
4#include <features.h>
5#include <time.h>
6
7#ifdef __cplusplus
8extern "C" {
9typedef unsigned long thrd_t;
10#else
11typedef struct __pthread *thrd_t;
12#define thread_local _Thread_local
13#endif
14
15typedef int once_flag;
16typedef unsigned tss_t;
17typedef int (*thrd_start_t)(void *);
18typedef void (*tss_dtor_t)(void *);
19
20#define __NEED_cnd_t
21#define __NEED_mtx_t
22
23#include <bits/alltypes.h>
24
25#define TSS_DTOR_ITERATIONS 4
26
27enum {
28 thrd_success = 0,
29 thrd_busy = 1,
30 thrd_error = 2,
31 thrd_nomem = 3,
32 thrd_timedout = 4,
33};
34
35enum {
36 mtx_plain = 0,
37 mtx_recursive = 1,
38 mtx_timed = 2,
39};
40
41#define ONCE_FLAG_INIT 0
42
43int thrd_create(thrd_t *, thrd_start_t, void *);
44_Noreturn void thrd_exit(int);
45
46int thrd_detach(thrd_t);
47int thrd_join(thrd_t, int *);
48
49int thrd_sleep(const struct timespec *, struct timespec *);
50void thrd_yield(void);
51
52thrd_t thrd_current(void);
53int thrd_equal(thrd_t, thrd_t);
54#ifndef __cplusplus
55#define thrd_equal(A, B) ((A) == (B))
56#endif
57
58void call_once(once_flag *, void (*)(void));
59
60int mtx_init(mtx_t *, int);
61void mtx_destroy(mtx_t *);
62
63int mtx_lock(mtx_t *);
64int mtx_timedlock(mtx_t *__restrict, const struct timespec *__restrict);
65int mtx_trylock(mtx_t *);
66int mtx_unlock(mtx_t *);
67
68int cnd_init(cnd_t *);
69void cnd_destroy(cnd_t *);
70
71int cnd_broadcast(cnd_t *);
72int cnd_signal(cnd_t *);
73
74int cnd_timedwait(cnd_t *__restrict, mtx_t *__restrict, const struct timespec *__restrict);
75int cnd_wait(cnd_t *, mtx_t *);
76
77int tss_create(tss_t *, tss_dtor_t);
78void tss_delete(tss_t);
79
80int tss_set(tss_t, void *);
81void *tss_get(tss_t);
82
83#ifdef __cplusplus
84}
85#endif
86
87#endif
lib/libc/musl/include/time.h created+138
......@@ -0,0 +1,138 @@
1#ifndef _TIME_H
2#define _TIME_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#ifdef __cplusplus
11#define NULL 0L
12#else
13#define NULL ((void*)0)
14#endif
15
16
17#define __NEED_size_t
18#define __NEED_time_t
19#define __NEED_clock_t
20#define __NEED_struct_timespec
21
22#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
23 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
24 || defined(_BSD_SOURCE)
25#define __NEED_clockid_t
26#define __NEED_timer_t
27#define __NEED_pid_t
28#define __NEED_locale_t
29#endif
30
31#include <bits/alltypes.h>
32
33#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
34#define __tm_gmtoff tm_gmtoff
35#define __tm_zone tm_zone
36#endif
37
38struct tm {
39 int tm_sec;
40 int tm_min;
41 int tm_hour;
42 int tm_mday;
43 int tm_mon;
44 int tm_year;
45 int tm_wday;
46 int tm_yday;
47 int tm_isdst;
48 long __tm_gmtoff;
49 const char *__tm_zone;
50};
51
52clock_t clock (void);
53time_t time (time_t *);
54double difftime (time_t, time_t);
55time_t mktime (struct tm *);
56size_t strftime (char *__restrict, size_t, const char *__restrict, const struct tm *__restrict);
57struct tm *gmtime (const time_t *);
58struct tm *localtime (const time_t *);
59char *asctime (const struct tm *);
60char *ctime (const time_t *);
61int timespec_get(struct timespec *, int);
62
63#define CLOCKS_PER_SEC 1000000L
64
65#define TIME_UTC 1
66
67#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
68 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
69 || defined(_BSD_SOURCE)
70
71size_t strftime_l (char * __restrict, size_t, const char * __restrict, const struct tm * __restrict, locale_t);
72
73struct tm *gmtime_r (const time_t *__restrict, struct tm *__restrict);
74struct tm *localtime_r (const time_t *__restrict, struct tm *__restrict);
75char *asctime_r (const struct tm *__restrict, char *__restrict);
76char *ctime_r (const time_t *, char *);
77
78void tzset (void);
79
80struct itimerspec {
81 struct timespec it_interval;
82 struct timespec it_value;
83};
84
85#define CLOCK_REALTIME 0
86#define CLOCK_MONOTONIC 1
87#define CLOCK_PROCESS_CPUTIME_ID 2
88#define CLOCK_THREAD_CPUTIME_ID 3
89#define CLOCK_MONOTONIC_RAW 4
90#define CLOCK_REALTIME_COARSE 5
91#define CLOCK_MONOTONIC_COARSE 6
92#define CLOCK_BOOTTIME 7
93#define CLOCK_REALTIME_ALARM 8
94#define CLOCK_BOOTTIME_ALARM 9
95#define CLOCK_SGI_CYCLE 10
96#define CLOCK_TAI 11
97
98#define TIMER_ABSTIME 1
99
100int nanosleep (const struct timespec *, struct timespec *);
101int clock_getres (clockid_t, struct timespec *);
102int clock_gettime (clockid_t, struct timespec *);
103int clock_settime (clockid_t, const struct timespec *);
104int clock_nanosleep (clockid_t, int, const struct timespec *, struct timespec *);
105int clock_getcpuclockid (pid_t, clockid_t *);
106
107struct sigevent;
108int timer_create (clockid_t, struct sigevent *__restrict, timer_t *__restrict);
109int timer_delete (timer_t);
110int timer_settime (timer_t, int, const struct itimerspec *__restrict, struct itimerspec *__restrict);
111int timer_gettime (timer_t, struct itimerspec *);
112int timer_getoverrun (timer_t);
113
114extern char *tzname[2];
115
116#endif
117
118
119#if defined(_XOPEN_SOURCE) || defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
120char *strptime (const char *__restrict, const char *__restrict, struct tm *__restrict);
121extern int daylight;
122extern long timezone;
123extern int getdate_err;
124struct tm *getdate (const char *);
125#endif
126
127
128#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
129int stime(const time_t *);
130time_t timegm(struct tm *);
131#endif
132
133#ifdef __cplusplus
134}
135#endif
136
137
138#endif
lib/libc/musl/include/uchar.h created+29
......@@ -0,0 +1,29 @@
1#ifndef _UCHAR_H
2#define _UCHAR_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#if __cplusplus < 201103L
9typedef unsigned short char16_t;
10typedef unsigned char32_t;
11#endif
12
13#define __NEED_mbstate_t
14#define __NEED_size_t
15
16#include <features.h>
17#include <bits/alltypes.h>
18
19size_t c16rtomb(char *__restrict, char16_t, mbstate_t *__restrict);
20size_t mbrtoc16(char16_t *__restrict, const char *__restrict, size_t, mbstate_t *__restrict);
21
22size_t c32rtomb(char *__restrict, char32_t, mbstate_t *__restrict);
23size_t mbrtoc32(char32_t *__restrict, const char *__restrict, size_t, mbstate_t *__restrict);
24
25#ifdef __cplusplus
26}
27#endif
28
29#endif
lib/libc/musl/include/ucontext.h created+25
......@@ -0,0 +1,25 @@
1#ifndef _UCONTEXT_H
2#define _UCONTEXT_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <features.h>
8
9#include <signal.h>
10
11#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
12#define NGREG (sizeof(gregset_t)/sizeof(greg_t))
13#endif
14
15struct __ucontext;
16
17int getcontext(struct __ucontext *);
18void makecontext(struct __ucontext *, void (*)(), int, ...);
19int setcontext(const struct __ucontext *);
20int swapcontext(struct __ucontext *, const struct __ucontext *);
21
22#ifdef __cplusplus
23}
24#endif
25#endif
lib/libc/musl/include/ulimit.h created+17
......@@ -0,0 +1,17 @@
1#ifndef _ULIMIT_H
2#define _ULIMIT_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define UL_GETFSIZE 1
9#define UL_SETFSIZE 2
10
11long ulimit (int, ...);
12
13#ifdef __cplusplus
14}
15#endif
16
17#endif
lib/libc/musl/include/unistd.h created+467
......@@ -0,0 +1,467 @@
1#ifndef _UNISTD_H
2#define _UNISTD_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define STDIN_FILENO 0
11#define STDOUT_FILENO 1
12#define STDERR_FILENO 2
13
14#define SEEK_SET 0
15#define SEEK_CUR 1
16#define SEEK_END 2
17
18#ifdef __cplusplus
19#define NULL 0L
20#else
21#define NULL ((void*)0)
22#endif
23
24#define __NEED_size_t
25#define __NEED_ssize_t
26#define __NEED_uid_t
27#define __NEED_gid_t
28#define __NEED_off_t
29#define __NEED_pid_t
30#define __NEED_intptr_t
31#define __NEED_useconds_t
32
33#include <bits/alltypes.h>
34
35int pipe(int [2]);
36int pipe2(int [2], int);
37int close(int);
38int posix_close(int, int);
39int dup(int);
40int dup2(int, int);
41int dup3(int, int, int);
42off_t lseek(int, off_t, int);
43int fsync(int);
44int fdatasync(int);
45
46ssize_t read(int, void *, size_t);
47ssize_t write(int, const void *, size_t);
48ssize_t pread(int, void *, size_t, off_t);
49ssize_t pwrite(int, const void *, size_t, off_t);
50
51int chown(const char *, uid_t, gid_t);
52int fchown(int, uid_t, gid_t);
53int lchown(const char *, uid_t, gid_t);
54int fchownat(int, const char *, uid_t, gid_t, int);
55
56int link(const char *, const char *);
57int linkat(int, const char *, int, const char *, int);
58int symlink(const char *, const char *);
59int symlinkat(const char *, int, const char *);
60ssize_t readlink(const char *__restrict, char *__restrict, size_t);
61ssize_t readlinkat(int, const char *__restrict, char *__restrict, size_t);
62int unlink(const char *);
63int unlinkat(int, const char *, int);
64int rmdir(const char *);
65int truncate(const char *, off_t);
66int ftruncate(int, off_t);
67
68#define F_OK 0
69#define R_OK 4
70#define W_OK 2
71#define X_OK 1
72
73int access(const char *, int);
74int faccessat(int, const char *, int, int);
75
76int chdir(const char *);
77int fchdir(int);
78char *getcwd(char *, size_t);
79
80unsigned alarm(unsigned);
81unsigned sleep(unsigned);
82int pause(void);
83
84pid_t fork(void);
85int execve(const char *, char *const [], char *const []);
86int execv(const char *, char *const []);
87int execle(const char *, const char *, ...);
88int execl(const char *, const char *, ...);
89int execvp(const char *, char *const []);
90int execlp(const char *, const char *, ...);
91int fexecve(int, char *const [], char *const []);
92_Noreturn void _exit(int);
93
94pid_t getpid(void);
95pid_t getppid(void);
96pid_t getpgrp(void);
97pid_t getpgid(pid_t);
98int setpgid(pid_t, pid_t);
99pid_t setsid(void);
100pid_t getsid(pid_t);
101char *ttyname(int);
102int ttyname_r(int, char *, size_t);
103int isatty(int);
104pid_t tcgetpgrp(int);
105int tcsetpgrp(int, pid_t);
106
107uid_t getuid(void);
108uid_t geteuid(void);
109gid_t getgid(void);
110gid_t getegid(void);
111int getgroups(int, gid_t []);
112int setuid(uid_t);
113int seteuid(uid_t);
114int setgid(gid_t);
115int setegid(gid_t);
116
117char *getlogin(void);
118int getlogin_r(char *, size_t);
119int gethostname(char *, size_t);
120char *ctermid(char *);
121
122int getopt(int, char * const [], const char *);
123extern char *optarg;
124extern int optind, opterr, optopt;
125
126long pathconf(const char *, int);
127long fpathconf(int, int);
128long sysconf(int);
129size_t confstr(int, char *, size_t);
130
131#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
132#define F_ULOCK 0
133#define F_LOCK 1
134#define F_TLOCK 2
135#define F_TEST 3
136int setreuid(uid_t, uid_t);
137int setregid(gid_t, gid_t);
138int lockf(int, int, off_t);
139long gethostid(void);
140int nice(int);
141void sync(void);
142pid_t setpgrp(void);
143char *crypt(const char *, const char *);
144void encrypt(char *, int);
145void swab(const void *__restrict, void *__restrict, ssize_t);
146#endif
147
148#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) \
149 || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700)
150int usleep(unsigned);
151unsigned ualarm(unsigned, unsigned);
152#endif
153
154#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
155#define L_SET 0
156#define L_INCR 1
157#define L_XTND 2
158int brk(void *);
159void *sbrk(intptr_t);
160pid_t vfork(void);
161int vhangup(void);
162int chroot(const char *);
163int getpagesize(void);
164int getdtablesize(void);
165int sethostname(const char *, size_t);
166int getdomainname(char *, size_t);
167int setdomainname(const char *, size_t);
168int setgroups(size_t, const gid_t *);
169char *getpass(const char *);
170int daemon(int, int);
171void setusershell(void);
172void endusershell(void);
173char *getusershell(void);
174int acct(const char *);
175long syscall(long, ...);
176int execvpe(const char *, char *const [], char *const []);
177int issetugid(void);
178int getentropy(void *, size_t);
179#endif
180
181#ifdef _GNU_SOURCE
182extern char **environ;
183int setresuid(uid_t, uid_t, uid_t);
184int setresgid(gid_t, gid_t, gid_t);
185int getresuid(uid_t *, uid_t *, uid_t *);
186int getresgid(gid_t *, gid_t *, gid_t *);
187char *get_current_dir_name(void);
188int syncfs(int);
189int euidaccess(const char *, int);
190int eaccess(const char *, int);
191#endif
192
193#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
194#define lseek64 lseek
195#define pread64 pread
196#define pwrite64 pwrite
197#define truncate64 truncate
198#define ftruncate64 ftruncate
199#define lockf64 lockf
200#define off64_t off_t
201#endif
202
203#define POSIX_CLOSE_RESTART 0
204
205#define _XOPEN_VERSION 700
206#define _XOPEN_UNIX 1
207#define _XOPEN_ENH_I18N 1
208
209#define _POSIX_VERSION 200809L
210#define _POSIX2_VERSION _POSIX_VERSION
211
212#define _POSIX_ADVISORY_INFO _POSIX_VERSION
213#define _POSIX_CHOWN_RESTRICTED 1
214#define _POSIX_IPV6 _POSIX_VERSION
215#define _POSIX_JOB_CONTROL 1
216#define _POSIX_MAPPED_FILES _POSIX_VERSION
217#define _POSIX_MEMLOCK _POSIX_VERSION
218#define _POSIX_MEMLOCK_RANGE _POSIX_VERSION
219#define _POSIX_MEMORY_PROTECTION _POSIX_VERSION
220#define _POSIX_MESSAGE_PASSING _POSIX_VERSION
221#define _POSIX_FSYNC _POSIX_VERSION
222#define _POSIX_NO_TRUNC 1
223#define _POSIX_RAW_SOCKETS _POSIX_VERSION
224#define _POSIX_REALTIME_SIGNALS _POSIX_VERSION
225#define _POSIX_REGEXP 1
226#define _POSIX_SAVED_IDS 1
227#define _POSIX_SHELL 1
228#define _POSIX_SPAWN _POSIX_VERSION
229#define _POSIX_VDISABLE 0
230
231#define _POSIX_THREADS _POSIX_VERSION
232#define _POSIX_THREAD_PROCESS_SHARED _POSIX_VERSION
233#define _POSIX_THREAD_SAFE_FUNCTIONS _POSIX_VERSION
234#define _POSIX_THREAD_ATTR_STACKADDR _POSIX_VERSION
235#define _POSIX_THREAD_ATTR_STACKSIZE _POSIX_VERSION
236#define _POSIX_THREAD_PRIORITY_SCHEDULING _POSIX_VERSION
237#define _POSIX_THREAD_CPUTIME _POSIX_VERSION
238#define _POSIX_TIMERS _POSIX_VERSION
239#define _POSIX_TIMEOUTS _POSIX_VERSION
240#define _POSIX_MONOTONIC_CLOCK _POSIX_VERSION
241#define _POSIX_CPUTIME _POSIX_VERSION
242#define _POSIX_CLOCK_SELECTION _POSIX_VERSION
243#define _POSIX_BARRIERS _POSIX_VERSION
244#define _POSIX_SPIN_LOCKS _POSIX_VERSION
245#define _POSIX_READER_WRITER_LOCKS _POSIX_VERSION
246#define _POSIX_ASYNCHRONOUS_IO _POSIX_VERSION
247#define _POSIX_SEMAPHORES _POSIX_VERSION
248#define _POSIX_SHARED_MEMORY_OBJECTS _POSIX_VERSION
249
250#define _POSIX2_C_BIND _POSIX_VERSION
251
252#include <bits/posix.h>
253
254
255
256#define _PC_LINK_MAX 0
257#define _PC_MAX_CANON 1
258#define _PC_MAX_INPUT 2
259#define _PC_NAME_MAX 3
260#define _PC_PATH_MAX 4
261#define _PC_PIPE_BUF 5
262#define _PC_CHOWN_RESTRICTED 6
263#define _PC_NO_TRUNC 7
264#define _PC_VDISABLE 8
265#define _PC_SYNC_IO 9
266#define _PC_ASYNC_IO 10
267#define _PC_PRIO_IO 11
268#define _PC_SOCK_MAXBUF 12
269#define _PC_FILESIZEBITS 13
270#define _PC_REC_INCR_XFER_SIZE 14
271#define _PC_REC_MAX_XFER_SIZE 15
272#define _PC_REC_MIN_XFER_SIZE 16
273#define _PC_REC_XFER_ALIGN 17
274#define _PC_ALLOC_SIZE_MIN 18
275#define _PC_SYMLINK_MAX 19
276#define _PC_2_SYMLINKS 20
277
278#define _SC_ARG_MAX 0
279#define _SC_CHILD_MAX 1
280#define _SC_CLK_TCK 2
281#define _SC_NGROUPS_MAX 3
282#define _SC_OPEN_MAX 4
283#define _SC_STREAM_MAX 5
284#define _SC_TZNAME_MAX 6
285#define _SC_JOB_CONTROL 7
286#define _SC_SAVED_IDS 8
287#define _SC_REALTIME_SIGNALS 9
288#define _SC_PRIORITY_SCHEDULING 10
289#define _SC_TIMERS 11
290#define _SC_ASYNCHRONOUS_IO 12
291#define _SC_PRIORITIZED_IO 13
292#define _SC_SYNCHRONIZED_IO 14
293#define _SC_FSYNC 15
294#define _SC_MAPPED_FILES 16
295#define _SC_MEMLOCK 17
296#define _SC_MEMLOCK_RANGE 18
297#define _SC_MEMORY_PROTECTION 19
298#define _SC_MESSAGE_PASSING 20
299#define _SC_SEMAPHORES 21
300#define _SC_SHARED_MEMORY_OBJECTS 22
301#define _SC_AIO_LISTIO_MAX 23
302#define _SC_AIO_MAX 24
303#define _SC_AIO_PRIO_DELTA_MAX 25
304#define _SC_DELAYTIMER_MAX 26
305#define _SC_MQ_OPEN_MAX 27
306#define _SC_MQ_PRIO_MAX 28
307#define _SC_VERSION 29
308#define _SC_PAGE_SIZE 30
309#define _SC_PAGESIZE 30 /* !! */
310#define _SC_RTSIG_MAX 31
311#define _SC_SEM_NSEMS_MAX 32
312#define _SC_SEM_VALUE_MAX 33
313#define _SC_SIGQUEUE_MAX 34
314#define _SC_TIMER_MAX 35
315#define _SC_BC_BASE_MAX 36
316#define _SC_BC_DIM_MAX 37
317#define _SC_BC_SCALE_MAX 38
318#define _SC_BC_STRING_MAX 39
319#define _SC_COLL_WEIGHTS_MAX 40
320#define _SC_EXPR_NEST_MAX 42
321#define _SC_LINE_MAX 43
322#define _SC_RE_DUP_MAX 44
323#define _SC_2_VERSION 46
324#define _SC_2_C_BIND 47
325#define _SC_2_C_DEV 48
326#define _SC_2_FORT_DEV 49
327#define _SC_2_FORT_RUN 50
328#define _SC_2_SW_DEV 51
329#define _SC_2_LOCALEDEF 52
330#define _SC_UIO_MAXIOV 60 /* !! */
331#define _SC_IOV_MAX 60
332#define _SC_THREADS 67
333#define _SC_THREAD_SAFE_FUNCTIONS 68
334#define _SC_GETGR_R_SIZE_MAX 69
335#define _SC_GETPW_R_SIZE_MAX 70
336#define _SC_LOGIN_NAME_MAX 71
337#define _SC_TTY_NAME_MAX 72
338#define _SC_THREAD_DESTRUCTOR_ITERATIONS 73
339#define _SC_THREAD_KEYS_MAX 74
340#define _SC_THREAD_STACK_MIN 75
341#define _SC_THREAD_THREADS_MAX 76
342#define _SC_THREAD_ATTR_STACKADDR 77
343#define _SC_THREAD_ATTR_STACKSIZE 78
344#define _SC_THREAD_PRIORITY_SCHEDULING 79
345#define _SC_THREAD_PRIO_INHERIT 80
346#define _SC_THREAD_PRIO_PROTECT 81
347#define _SC_THREAD_PROCESS_SHARED 82
348#define _SC_NPROCESSORS_CONF 83
349#define _SC_NPROCESSORS_ONLN 84
350#define _SC_PHYS_PAGES 85
351#define _SC_AVPHYS_PAGES 86
352#define _SC_ATEXIT_MAX 87
353#define _SC_PASS_MAX 88
354#define _SC_XOPEN_VERSION 89
355#define _SC_XOPEN_XCU_VERSION 90
356#define _SC_XOPEN_UNIX 91
357#define _SC_XOPEN_CRYPT 92
358#define _SC_XOPEN_ENH_I18N 93
359#define _SC_XOPEN_SHM 94
360#define _SC_2_CHAR_TERM 95
361#define _SC_2_UPE 97
362#define _SC_XOPEN_XPG2 98
363#define _SC_XOPEN_XPG3 99
364#define _SC_XOPEN_XPG4 100
365#define _SC_NZERO 109
366#define _SC_XBS5_ILP32_OFF32 125
367#define _SC_XBS5_ILP32_OFFBIG 126
368#define _SC_XBS5_LP64_OFF64 127
369#define _SC_XBS5_LPBIG_OFFBIG 128
370#define _SC_XOPEN_LEGACY 129
371#define _SC_XOPEN_REALTIME 130
372#define _SC_XOPEN_REALTIME_THREADS 131
373#define _SC_ADVISORY_INFO 132
374#define _SC_BARRIERS 133
375#define _SC_CLOCK_SELECTION 137
376#define _SC_CPUTIME 138
377#define _SC_THREAD_CPUTIME 139
378#define _SC_MONOTONIC_CLOCK 149
379#define _SC_READER_WRITER_LOCKS 153
380#define _SC_SPIN_LOCKS 154
381#define _SC_REGEXP 155
382#define _SC_SHELL 157
383#define _SC_SPAWN 159
384#define _SC_SPORADIC_SERVER 160
385#define _SC_THREAD_SPORADIC_SERVER 161
386#define _SC_TIMEOUTS 164
387#define _SC_TYPED_MEMORY_OBJECTS 165
388#define _SC_2_PBS 168
389#define _SC_2_PBS_ACCOUNTING 169
390#define _SC_2_PBS_LOCATE 170
391#define _SC_2_PBS_MESSAGE 171
392#define _SC_2_PBS_TRACK 172
393#define _SC_SYMLOOP_MAX 173
394#define _SC_STREAMS 174
395#define _SC_2_PBS_CHECKPOINT 175
396#define _SC_V6_ILP32_OFF32 176
397#define _SC_V6_ILP32_OFFBIG 177
398#define _SC_V6_LP64_OFF64 178
399#define _SC_V6_LPBIG_OFFBIG 179
400#define _SC_HOST_NAME_MAX 180
401#define _SC_TRACE 181
402#define _SC_TRACE_EVENT_FILTER 182
403#define _SC_TRACE_INHERIT 183
404#define _SC_TRACE_LOG 184
405
406#define _SC_IPV6 235
407#define _SC_RAW_SOCKETS 236
408#define _SC_V7_ILP32_OFF32 237
409#define _SC_V7_ILP32_OFFBIG 238
410#define _SC_V7_LP64_OFF64 239
411#define _SC_V7_LPBIG_OFFBIG 240
412#define _SC_SS_REPL_MAX 241
413#define _SC_TRACE_EVENT_NAME_MAX 242
414#define _SC_TRACE_NAME_MAX 243
415#define _SC_TRACE_SYS_MAX 244
416#define _SC_TRACE_USER_EVENT_MAX 245
417#define _SC_XOPEN_STREAMS 246
418#define _SC_THREAD_ROBUST_PRIO_INHERIT 247
419#define _SC_THREAD_ROBUST_PRIO_PROTECT 248
420
421#define _CS_PATH 0
422#define _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS 1
423#define _CS_GNU_LIBC_VERSION 2
424#define _CS_GNU_LIBPTHREAD_VERSION 3
425#define _CS_POSIX_V5_WIDTH_RESTRICTED_ENVS 4
426#define _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS 5
427
428#define _CS_POSIX_V6_ILP32_OFF32_CFLAGS 1116
429#define _CS_POSIX_V6_ILP32_OFF32_LDFLAGS 1117
430#define _CS_POSIX_V6_ILP32_OFF32_LIBS 1118
431#define _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS 1119
432#define _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS 1120
433#define _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS 1121
434#define _CS_POSIX_V6_ILP32_OFFBIG_LIBS 1122
435#define _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS 1123
436#define _CS_POSIX_V6_LP64_OFF64_CFLAGS 1124
437#define _CS_POSIX_V6_LP64_OFF64_LDFLAGS 1125
438#define _CS_POSIX_V6_LP64_OFF64_LIBS 1126
439#define _CS_POSIX_V6_LP64_OFF64_LINTFLAGS 1127
440#define _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS 1128
441#define _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS 1129
442#define _CS_POSIX_V6_LPBIG_OFFBIG_LIBS 1130
443#define _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS 1131
444#define _CS_POSIX_V7_ILP32_OFF32_CFLAGS 1132
445#define _CS_POSIX_V7_ILP32_OFF32_LDFLAGS 1133
446#define _CS_POSIX_V7_ILP32_OFF32_LIBS 1134
447#define _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS 1135
448#define _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS 1136
449#define _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS 1137
450#define _CS_POSIX_V7_ILP32_OFFBIG_LIBS 1138
451#define _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS 1139
452#define _CS_POSIX_V7_LP64_OFF64_CFLAGS 1140
453#define _CS_POSIX_V7_LP64_OFF64_LDFLAGS 1141
454#define _CS_POSIX_V7_LP64_OFF64_LIBS 1142
455#define _CS_POSIX_V7_LP64_OFF64_LINTFLAGS 1143
456#define _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS 1144
457#define _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS 1145
458#define _CS_POSIX_V7_LPBIG_OFFBIG_LIBS 1146
459#define _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS 1147
460#define _CS_V6_ENV 1148
461#define _CS_V7_ENV 1149
462
463#ifdef __cplusplus
464}
465#endif
466
467#endif
lib/libc/musl/include/utime.h created+23
......@@ -0,0 +1,23 @@
1#ifndef _UTIME_H
2#define _UTIME_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define __NEED_time_t
9
10#include <bits/alltypes.h>
11
12struct utimbuf {
13 time_t actime;
14 time_t modtime;
15};
16
17int utime (const char *, const struct utimbuf *);
18
19#ifdef __cplusplus
20}
21#endif
22
23#endif
lib/libc/musl/include/utmp.h created+52
......@@ -0,0 +1,52 @@
1#ifndef _UTMP_H
2#define _UTMP_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <utmpx.h>
9
10#define ACCOUNTING 9
11#define UT_NAMESIZE 32
12#define UT_HOSTSIZE 256
13#define UT_LINESIZE 32
14
15struct lastlog {
16 time_t ll_time;
17 char ll_line[UT_LINESIZE];
18 char ll_host[UT_HOSTSIZE];
19};
20
21#define ut_time ut_tv.tv_sec
22#define ut_name ut_user
23#define ut_addr ut_addr_v6[0]
24#define utmp utmpx
25#define e_exit __e_exit
26#define e_termination __e_termination
27
28void endutent(void);
29struct utmp *getutent(void);
30struct utmp *getutid(const struct utmp *);
31struct utmp *getutline(const struct utmp *);
32struct utmp *pututline(const struct utmp *);
33void setutent(void);
34
35void updwtmp(const char *, const struct utmp *);
36int utmpname(const char *);
37
38int login_tty(int);
39
40#define _PATH_UTMP "/dev/null/utmp"
41#define _PATH_WTMP "/dev/null/wtmp"
42
43#define UTMP_FILE _PATH_UTMP
44#define WTMP_FILE _PATH_WTMP
45#define UTMP_FILENAME _PATH_UTMP
46#define WTMP_FILENAME _PATH_WTMP
47
48#ifdef __cplusplus
49}
50#endif
51
52#endif
lib/libc/musl/include/utmpx.h created+62
......@@ -0,0 +1,62 @@
1#ifndef _UTMPX_H
2#define _UTMPX_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_pid_t
11#define __NEED_time_t
12#define __NEED_suseconds_t
13#define __NEED_struct_timeval
14
15#include <bits/alltypes.h>
16
17struct utmpx {
18 short ut_type;
19 pid_t ut_pid;
20 char ut_line[32];
21 char ut_id[4];
22 char ut_user[32];
23 char ut_host[256];
24 struct {
25 short __e_termination;
26 short __e_exit;
27 } ut_exit;
28 long ut_session;
29 struct timeval ut_tv;
30 unsigned ut_addr_v6[4];
31 char __unused[20];
32};
33
34void endutxent(void);
35struct utmpx *getutxent(void);
36struct utmpx *getutxid(const struct utmpx *);
37struct utmpx *getutxline(const struct utmpx *);
38struct utmpx *pututxline(const struct utmpx *);
39void setutxent(void);
40
41#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
42#define e_exit __e_exit
43#define e_termination __e_termination
44void updwtmpx(const char *, const struct utmpx *);
45int utmpxname(const char *);
46#endif
47
48#define EMPTY 0
49#define RUN_LVL 1
50#define BOOT_TIME 2
51#define NEW_TIME 3
52#define OLD_TIME 4
53#define INIT_PROCESS 5
54#define LOGIN_PROCESS 6
55#define USER_PROCESS 7
56#define DEAD_PROCESS 8
57
58#ifdef __cplusplus
59}
60#endif
61
62#endif
lib/libc/musl/include/values.h created+39
......@@ -0,0 +1,39 @@
1#ifndef _VALUES_H
2#define _VALUES_H
3
4#include <limits.h>
5
6#define CHARBITS (sizeof(char) * 8)
7#define SHORTBITS (sizeof(short) * 8)
8#define INTBITS (sizeof(int) * 8)
9#define LONGBITS (sizeof(long) * 8)
10#define PTRBITS (sizeof(char *) * 8)
11#define DOUBLEBITS (sizeof(double) * 8)
12#define FLOATBITS (sizeof(float) * 8)
13
14#define MINSHORT SHRT_MIN
15#define MININT INT_MIN
16#define MINLONG LONG_MIN
17
18#define MAXSHORT SHRT_MAX
19#define MAXINT INT_MAX
20#define MAXLONG LONG_MAX
21
22#define HIBITS MINSHORT
23#define HIBITL MINLONG
24
25#include <float.h>
26
27#define MAXDOUBLE DBL_MAX
28#undef MAXFLOAT
29#define MAXFLOAT FLT_MAX
30#define MINDOUBLE DBL_MIN
31#define MINFLOAT FLT_MIN
32#define DMINEXP DBL_MIN_EXP
33#define FMINEXP FLT_MIN_EXP
34#define DMAXEXP DBL_MAX_EXP
35#define FMAXEXP FLT_MAX_EXP
36
37#define BITSPERBYTE CHAR_BIT
38
39#endif
lib/libc/musl/include/wait.h created+2
......@@ -0,0 +1,2 @@
1#warning redirecting incorrect #include <wait.h> to <sys/wait.h>
2#include <sys/wait.h>
lib/libc/musl/include/wchar.h created+205
......@@ -0,0 +1,205 @@
1#ifndef _WCHAR_H
2#define _WCHAR_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_FILE
11#define __NEED___isoc_va_list
12#define __NEED_size_t
13#define __NEED_wchar_t
14#define __NEED_wint_t
15#define __NEED_mbstate_t
16
17#if __STDC_VERSION__ < 201112L
18#define __NEED_struct__IO_FILE
19#endif
20
21#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
22 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
23#define __NEED_locale_t
24#define __NEED_va_list
25#endif
26
27#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
28#define __NEED_wctype_t
29#endif
30
31#include <bits/alltypes.h>
32
33#if L'\0'-1 > 0
34#define WCHAR_MAX (0xffffffffu+L'\0')
35#define WCHAR_MIN (0+L'\0')
36#else
37#define WCHAR_MAX (0x7fffffff+L'\0')
38#define WCHAR_MIN (-1-0x7fffffff+L'\0')
39#endif
40
41#ifdef __cplusplus
42#define NULL 0L
43#else
44#define NULL ((void*)0)
45#endif
46
47#undef WEOF
48#define WEOF 0xffffffffU
49
50wchar_t *wcscpy (wchar_t *__restrict, const wchar_t *__restrict);
51wchar_t *wcsncpy (wchar_t *__restrict, const wchar_t *__restrict, size_t);
52
53wchar_t *wcscat (wchar_t *__restrict, const wchar_t *__restrict);
54wchar_t *wcsncat (wchar_t *__restrict, const wchar_t *__restrict, size_t);
55
56int wcscmp (const wchar_t *, const wchar_t *);
57int wcsncmp (const wchar_t *, const wchar_t *, size_t);
58
59int wcscoll(const wchar_t *, const wchar_t *);
60size_t wcsxfrm (wchar_t *__restrict, const wchar_t *__restrict, size_t);
61
62wchar_t *wcschr (const wchar_t *, wchar_t);
63wchar_t *wcsrchr (const wchar_t *, wchar_t);
64
65size_t wcscspn (const wchar_t *, const wchar_t *);
66size_t wcsspn (const wchar_t *, const wchar_t *);
67wchar_t *wcspbrk (const wchar_t *, const wchar_t *);
68
69wchar_t *wcstok (wchar_t *__restrict, const wchar_t *__restrict, wchar_t **__restrict);
70
71size_t wcslen (const wchar_t *);
72
73wchar_t *wcsstr (const wchar_t *__restrict, const wchar_t *__restrict);
74wchar_t *wcswcs (const wchar_t *, const wchar_t *);
75
76wchar_t *wmemchr (const wchar_t *, wchar_t, size_t);
77int wmemcmp (const wchar_t *, const wchar_t *, size_t);
78wchar_t *wmemcpy (wchar_t *__restrict, const wchar_t *__restrict, size_t);
79wchar_t *wmemmove (wchar_t *, const wchar_t *, size_t);
80wchar_t *wmemset (wchar_t *, wchar_t, size_t);
81
82wint_t btowc (int);
83int wctob (wint_t);
84
85int mbsinit (const mbstate_t *);
86size_t mbrtowc (wchar_t *__restrict, const char *__restrict, size_t, mbstate_t *__restrict);
87size_t wcrtomb (char *__restrict, wchar_t, mbstate_t *__restrict);
88
89size_t mbrlen (const char *__restrict, size_t, mbstate_t *__restrict);
90
91size_t mbsrtowcs (wchar_t *__restrict, const char **__restrict, size_t, mbstate_t *__restrict);
92size_t wcsrtombs (char *__restrict, const wchar_t **__restrict, size_t, mbstate_t *__restrict);
93
94float wcstof (const wchar_t *__restrict, wchar_t **__restrict);
95double wcstod (const wchar_t *__restrict, wchar_t **__restrict);
96long double wcstold (const wchar_t *__restrict, wchar_t **__restrict);
97
98long wcstol (const wchar_t *__restrict, wchar_t **__restrict, int);
99unsigned long wcstoul (const wchar_t *__restrict, wchar_t **__restrict, int);
100
101long long wcstoll (const wchar_t *__restrict, wchar_t **__restrict, int);
102unsigned long long wcstoull (const wchar_t *__restrict, wchar_t **__restrict, int);
103
104
105
106int fwide (FILE *, int);
107
108
109int wprintf (const wchar_t *__restrict, ...);
110int fwprintf (FILE *__restrict, const wchar_t *__restrict, ...);
111int swprintf (wchar_t *__restrict, size_t, const wchar_t *__restrict, ...);
112
113int vwprintf (const wchar_t *__restrict, __isoc_va_list);
114int vfwprintf (FILE *__restrict, const wchar_t *__restrict, __isoc_va_list);
115int vswprintf (wchar_t *__restrict, size_t, const wchar_t *__restrict, __isoc_va_list);
116
117int wscanf (const wchar_t *__restrict, ...);
118int fwscanf (FILE *__restrict, const wchar_t *__restrict, ...);
119int swscanf (const wchar_t *__restrict, const wchar_t *__restrict, ...);
120
121int vwscanf (const wchar_t *__restrict, __isoc_va_list);
122int vfwscanf (FILE *__restrict, const wchar_t *__restrict, __isoc_va_list);
123int vswscanf (const wchar_t *__restrict, const wchar_t *__restrict, __isoc_va_list);
124
125wint_t fgetwc (FILE *);
126wint_t getwc (FILE *);
127wint_t getwchar (void);
128
129wint_t fputwc (wchar_t, FILE *);
130wint_t putwc (wchar_t, FILE *);
131wint_t putwchar (wchar_t);
132
133wchar_t *fgetws (wchar_t *__restrict, int, FILE *__restrict);
134int fputws (const wchar_t *__restrict, FILE *__restrict);
135
136wint_t ungetwc (wint_t, FILE *);
137
138struct tm;
139size_t wcsftime (wchar_t *__restrict, size_t, const wchar_t *__restrict, const struct tm *__restrict);
140
141#undef iswdigit
142
143#if defined(_GNU_SOURCE)
144wint_t fgetwc_unlocked (FILE *);
145wint_t getwc_unlocked (FILE *);
146wint_t getwchar_unlocked (void);
147wint_t fputwc_unlocked (wchar_t, FILE *);
148wint_t putwc_unlocked (wchar_t, FILE *);
149wint_t putwchar_unlocked (wchar_t);
150wchar_t *fgetws_unlocked (wchar_t *__restrict, int, FILE *__restrict);
151int fputws_unlocked (const wchar_t *__restrict, FILE *__restrict);
152#endif
153
154#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
155size_t wcsftime_l (wchar_t *__restrict, size_t, const wchar_t *__restrict, const struct tm *__restrict, locale_t);
156#endif
157
158#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
159 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
160FILE *open_wmemstream(wchar_t **, size_t *);
161size_t mbsnrtowcs(wchar_t *__restrict, const char **__restrict, size_t, size_t, mbstate_t *__restrict);
162size_t wcsnrtombs(char *__restrict, const wchar_t **__restrict, size_t, size_t, mbstate_t *__restrict);
163wchar_t *wcsdup(const wchar_t *);
164size_t wcsnlen (const wchar_t *, size_t);
165wchar_t *wcpcpy (wchar_t *__restrict, const wchar_t *__restrict);
166wchar_t *wcpncpy (wchar_t *__restrict, const wchar_t *__restrict, size_t);
167int wcscasecmp(const wchar_t *, const wchar_t *);
168int wcscasecmp_l(const wchar_t *, const wchar_t *, locale_t);
169int wcsncasecmp(const wchar_t *, const wchar_t *, size_t);
170int wcsncasecmp_l(const wchar_t *, const wchar_t *, size_t, locale_t);
171int wcscoll_l(const wchar_t *, const wchar_t *, locale_t);
172size_t wcsxfrm_l(wchar_t *__restrict, const wchar_t *__restrict, size_t, locale_t);
173#endif
174
175#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
176int wcwidth (wchar_t);
177int wcswidth (const wchar_t *, size_t);
178int iswalnum(wint_t);
179int iswalpha(wint_t);
180int iswblank(wint_t);
181int iswcntrl(wint_t);
182int iswdigit(wint_t);
183int iswgraph(wint_t);
184int iswlower(wint_t);
185int iswprint(wint_t);
186int iswpunct(wint_t);
187int iswspace(wint_t);
188int iswupper(wint_t);
189int iswxdigit(wint_t);
190int iswctype(wint_t, wctype_t);
191wint_t towlower(wint_t);
192wint_t towupper(wint_t);
193wctype_t wctype(const char *);
194
195#ifndef __cplusplus
196#undef iswdigit
197#define iswdigit(a) (0 ? iswdigit(a) : ((unsigned)(a)-'0') < 10)
198#endif
199#endif
200
201#ifdef __cplusplus
202}
203#endif
204
205#endif
lib/libc/musl/include/wctype.h created+79
......@@ -0,0 +1,79 @@
1#ifndef _WCTYPE_H
2#define _WCTYPE_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_wint_t
11#define __NEED_wctype_t
12
13#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
14 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
15#define __NEED_locale_t
16#endif
17
18#include <bits/alltypes.h>
19
20typedef const int * wctrans_t;
21
22#undef WEOF
23#define WEOF 0xffffffffU
24
25#undef iswdigit
26
27int iswalnum(wint_t);
28int iswalpha(wint_t);
29int iswblank(wint_t);
30int iswcntrl(wint_t);
31int iswdigit(wint_t);
32int iswgraph(wint_t);
33int iswlower(wint_t);
34int iswprint(wint_t);
35int iswpunct(wint_t);
36int iswspace(wint_t);
37int iswupper(wint_t);
38int iswxdigit(wint_t);
39int iswctype(wint_t, wctype_t);
40wint_t towctrans(wint_t, wctrans_t);
41wint_t towlower(wint_t);
42wint_t towupper(wint_t);
43wctrans_t wctrans(const char *);
44wctype_t wctype(const char *);
45
46#ifndef __cplusplus
47#undef iswdigit
48#define iswdigit(a) (0 ? iswdigit(a) : ((unsigned)(a)-'0') < 10)
49#endif
50
51#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
52 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
53
54int iswalnum_l(wint_t, locale_t);
55int iswalpha_l(wint_t, locale_t);
56int iswblank_l(wint_t, locale_t);
57int iswcntrl_l(wint_t, locale_t);
58int iswdigit_l(wint_t, locale_t);
59int iswgraph_l(wint_t, locale_t);
60int iswlower_l(wint_t, locale_t);
61int iswprint_l(wint_t, locale_t);
62int iswpunct_l(wint_t, locale_t);
63int iswspace_l(wint_t, locale_t);
64int iswupper_l(wint_t, locale_t);
65int iswxdigit_l(wint_t, locale_t);
66int iswctype_l(wint_t, wctype_t, locale_t);
67wint_t towlower_l(wint_t, locale_t);
68wint_t towupper_l(wint_t, locale_t);
69wint_t towctrans_l(wint_t, wctrans_t, locale_t);
70wctrans_t wctrans_l(const char *, locale_t);
71wctype_t wctype_l(const char *, locale_t);
72
73#endif
74
75#ifdef __cplusplus
76}
77#endif
78
79#endif
lib/libc/musl/include/wordexp.h created+41
......@@ -0,0 +1,41 @@
1#ifndef _WORDEXP_H
2#define _WORDEXP_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_size_t
11
12#include <bits/alltypes.h>
13
14#define WRDE_DOOFFS 1
15#define WRDE_APPEND 2
16#define WRDE_NOCMD 4
17#define WRDE_REUSE 8
18#define WRDE_SHOWERR 16
19#define WRDE_UNDEF 32
20
21typedef struct {
22 size_t we_wordc;
23 char **we_wordv;
24 size_t we_offs;
25} wordexp_t;
26
27#define WRDE_NOSYS -1
28#define WRDE_NOSPACE 1
29#define WRDE_BADCHAR 2
30#define WRDE_BADVAL 3
31#define WRDE_CMDSUB 4
32#define WRDE_SYNTAX 5
33
34int wordexp (const char *__restrict, wordexp_t *__restrict, int);
35void wordfree (wordexp_t *);
36
37#ifdef __cplusplus
38}
39#endif
40
41#endif
lib/libc/musl/src/aio/lio_listio.c+3-3
......@@ -113,7 +113,7 @@ int lio_listio(int mode, struct aiocb *restrict const *restrict cbs, int cnt, st
113113
114114 if (st) {
115115 pthread_attr_t a;
116 sigset_t set;
116 sigset_t set, set_old;
117117 pthread_t td;
118118
119119 if (sev->sigev_notify == SIGEV_THREAD) {
......@@ -128,13 +128,13 @@ int lio_listio(int mode, struct aiocb *restrict const *restrict cbs, int cnt, st
128128 }
129129 pthread_attr_setdetachstate(&a, PTHREAD_CREATE_DETACHED);
130130 sigfillset(&set);
131 pthread_sigmask(SIG_BLOCK, &set, &set);
131 pthread_sigmask(SIG_BLOCK, &set, &set_old);
132132 if (pthread_create(&td, &a, wait_thread, st)) {
133133 free(st);
134134 errno = EAGAIN;
135135 return -1;
136136 }
137 pthread_sigmask(SIG_SETMASK, &set, 0);
137 pthread_sigmask(SIG_SETMASK, &set_old, 0);
138138 }
139139
140140 return 0;
lib/libc/musl/src/complex/__cexp.c+1-1
......@@ -25,7 +25,7 @@
2525 * SUCH DAMAGE.
2626 */
2727
28#include "libm.h"
28#include "complex_impl.h"
2929
3030static const uint32_t k = 1799; /* constant for reduction */
3131static const double kln2 = 1246.97177782734161156; /* k * ln2 */
lib/libc/musl/src/complex/__cexpf.c+1-1
......@@ -25,7 +25,7 @@
2525 * SUCH DAMAGE.
2626 */
2727
28#include "libm.h"
28#include "complex_impl.h"
2929
3030static const uint32_t k = 235; /* constant for reduction */
3131static const float kln2 = 162.88958740F; /* k * ln2 */
lib/libc/musl/src/complex/cabs.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33double cabs(double complex z)
44{
lib/libc/musl/src/complex/cabsf.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33float cabsf(float complex z)
44{
lib/libc/musl/src/complex/cabsl.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
44long double cabsl(long double complex z)
lib/libc/musl/src/complex/cacos.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33// FIXME: Hull et al. "Implementing the complex arcsine and arccosine functions using exception handling" 1997
44
lib/libc/musl/src/complex/cacosf.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33// FIXME
44
lib/libc/musl/src/complex/cacosh.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33/* acosh(z) = i acos(z) */
44
lib/libc/musl/src/complex/cacoshf.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33float complex cacoshf(float complex z)
44{
lib/libc/musl/src/complex/cacoshl.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
44long double complex cacoshl(long double complex z)
lib/libc/musl/src/complex/cacosl.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
44long double complex cacosl(long double complex z)
lib/libc/musl/src/complex/carg.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33double carg(double complex z)
44{
lib/libc/musl/src/complex/cargf.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33float cargf(float complex z)
44{
lib/libc/musl/src/complex/cargl.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
44long double cargl(long double complex z)
lib/libc/musl/src/complex/casin.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33// FIXME
44
lib/libc/musl/src/complex/casinf.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33// FIXME
44
lib/libc/musl/src/complex/casinh.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33/* asinh(z) = -i asin(i z) */
44
lib/libc/musl/src/complex/casinhf.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33float complex casinhf(float complex z)
44{
lib/libc/musl/src/complex/casinhl.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
44long double complex casinhl(long double complex z)
lib/libc/musl/src/complex/casinl.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
44long double complex casinl(long double complex z)
lib/libc/musl/src/complex/catan.c+1-1
......@@ -58,7 +58,7 @@
5858 * 2.9e-17. See also clog().
5959 */
6060
61#include "libm.h"
61#include "complex_impl.h"
6262
6363#define MAXNUM 1.0e308
6464
lib/libc/musl/src/complex/catanf.c+1-1
......@@ -53,7 +53,7 @@
5353 * IEEE -10,+10 30000 2.3e-6 5.2e-8
5454 */
5555
56#include "libm.h"
56#include "complex_impl.h"
5757
5858#define MAXNUMF 1.0e38F
5959
lib/libc/musl/src/complex/catanh.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33/* atanh = -i atan(i z) */
44
lib/libc/musl/src/complex/catanhf.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33float complex catanhf(float complex z)
44{
lib/libc/musl/src/complex/catanhl.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
44long double complex catanhl(long double complex z)
lib/libc/musl/src/complex/catanl.c+1-1
......@@ -59,7 +59,7 @@
5959
6060#include <complex.h>
6161#include <float.h>
62#include "libm.h"
62#include "complex_impl.h"
6363
6464#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
6565long double complex catanl(long double complex z)
lib/libc/musl/src/complex/ccos.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33/* cos(z) = cosh(i z) */
44
lib/libc/musl/src/complex/ccosf.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33float complex ccosf(float complex z)
44{
lib/libc/musl/src/complex/ccosh.c+1-1
......@@ -34,7 +34,7 @@
3434 * These values and the return value were taken from n1124.pdf.
3535 */
3636
37#include "libm.h"
37#include "complex_impl.h"
3838
3939static const double huge = 0x1p1023;
4040
lib/libc/musl/src/complex/ccoshf.c+1-1
......@@ -28,7 +28,7 @@
2828 * Hyperbolic cosine of a complex argument. See s_ccosh.c for details.
2929 */
3030
31#include "libm.h"
31#include "complex_impl.h"
3232
3333static const float huge = 0x1p127;
3434
lib/libc/musl/src/complex/ccoshl.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33//FIXME
44long double complex ccoshl(long double complex z)
lib/libc/musl/src/complex/ccosl.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
44long double complex ccosl(long double complex z)
lib/libc/musl/src/complex/cexp.c+1-1
......@@ -25,7 +25,7 @@
2525 * SUCH DAMAGE.
2626 */
2727
28#include "libm.h"
28#include "complex_impl.h"
2929
3030static const uint32_t
3131exp_ovfl = 0x40862e42, /* high bits of MAX_EXP * ln2 ~= 710 */
lib/libc/musl/src/complex/cexpf.c+1-1
......@@ -25,7 +25,7 @@
2525 * SUCH DAMAGE.
2626 */
2727
28#include "libm.h"
28#include "complex_impl.h"
2929
3030static const uint32_t
3131exp_ovfl = 0x42b17218, /* MAX_EXP * ln2 ~= 88.722839355 */
lib/libc/musl/src/complex/cexpl.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33//FIXME
44long double complex cexpl(long double complex z)
lib/libc/musl/src/complex/cimag.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33double (cimag)(double complex z)
44{
lib/libc/musl/src/complex/cimagf.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33float (cimagf)(float complex z)
44{
lib/libc/musl/src/complex/cimagl.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33long double (cimagl)(long double complex z)
44{
lib/libc/musl/src/complex/clog.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33// FIXME
44
lib/libc/musl/src/complex/clogf.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33// FIXME
44
lib/libc/musl/src/complex/clogl.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
44long double complex clogl(long double complex z)
lib/libc/musl/src/complex/conj.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33double complex conj(double complex z)
44{
lib/libc/musl/src/complex/conjf.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33float complex conjf(float complex z)
44{
lib/libc/musl/src/complex/conjl.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33long double complex conjl(long double complex z)
44{
lib/libc/musl/src/complex/cpow.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33/* pow(z, c) = exp(c log(z)), See C99 G.6.4.1 */
44
lib/libc/musl/src/complex/cpowf.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33float complex cpowf(float complex z, float complex c)
44{
lib/libc/musl/src/complex/cpowl.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
44long double complex cpowl(long double complex z, long double complex c)
lib/libc/musl/src/complex/cproj.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33double complex cproj(double complex z)
44{
lib/libc/musl/src/complex/cprojf.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33float complex cprojf(float complex z)
44{
lib/libc/musl/src/complex/cprojl.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
44long double complex cprojl(long double complex z)
lib/libc/musl/src/complex/csin.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33/* sin(z) = -i sinh(i z) */
44
lib/libc/musl/src/complex/csinf.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33float complex csinf(float complex z)
44{
lib/libc/musl/src/complex/csinh.c+1-1
......@@ -34,7 +34,7 @@
3434 * These values and the return value were taken from n1124.pdf.
3535 */
3636
37#include "libm.h"
37#include "complex_impl.h"
3838
3939static const double huge = 0x1p1023;
4040
lib/libc/musl/src/complex/csinhf.c+1-1
......@@ -28,7 +28,7 @@
2828 * Hyperbolic sine of a complex argument z. See s_csinh.c for details.
2929 */
3030
31#include "libm.h"
31#include "complex_impl.h"
3232
3333static const float huge = 0x1p127;
3434
lib/libc/musl/src/complex/csinhl.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33//FIXME
44long double complex csinhl(long double complex z)
lib/libc/musl/src/complex/csinl.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
44long double complex csinl(long double complex z)
lib/libc/musl/src/complex/csqrt.c+1-1
......@@ -25,7 +25,7 @@
2525 * SUCH DAMAGE.
2626 */
2727
28#include "libm.h"
28#include "complex_impl.h"
2929
3030/*
3131 * gcc doesn't implement complex multiplication or division correctly,
lib/libc/musl/src/complex/csqrtf.c+1-1
......@@ -25,7 +25,7 @@
2525 * SUCH DAMAGE.
2626 */
2727
28#include "libm.h"
28#include "complex_impl.h"
2929
3030/*
3131 * gcc doesn't implement complex multiplication or division correctly,
lib/libc/musl/src/complex/csqrtl.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33//FIXME
44long double complex csqrtl(long double complex z)
lib/libc/musl/src/complex/ctan.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33/* tan(z) = -i tanh(i z) */
44
lib/libc/musl/src/complex/ctanf.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33float complex ctanf(float complex z)
44{
lib/libc/musl/src/complex/ctanh.c+1-1
......@@ -63,7 +63,7 @@
6363 * precision. I also handle large x differently.
6464 */
6565
66#include "libm.h"
66#include "complex_impl.h"
6767
6868double complex ctanh(double complex z)
6969{
lib/libc/musl/src/complex/ctanhf.c+1-1
......@@ -28,7 +28,7 @@
2828 * Hyperbolic tangent of a complex argument z. See s_ctanh.c for details.
2929 */
3030
31#include "libm.h"
31#include "complex_impl.h"
3232
3333float complex ctanhf(float complex z)
3434{
lib/libc/musl/src/complex/ctanhl.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33//FIXME
44long double complex ctanhl(long double complex z)
lib/libc/musl/src/complex/ctanl.c+1-1
......@@ -1,4 +1,4 @@
1#include "libm.h"
1#include "complex_impl.h"
22
33#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
44long double complex ctanl(long double complex z)
lib/libc/musl/src/dirent/fdopendir.c+4
......@@ -13,6 +13,10 @@ DIR *fdopendir(int fd)
1313 if (fstat(fd, &st) < 0) {
1414 return 0;
1515 }
16 if (fcntl(fd, F_GETFL) & O_PATH) {
17 errno = EBADF;
18 return 0;
19 }
1620 if (!S_ISDIR(st.st_mode)) {
1721 errno = ENOTDIR;
1822 return 0;
lib/libc/musl/src/env/__init_tls.c+8-2
......@@ -1,3 +1,4 @@
1#define SYSCALL_NO_TLS 1
12#include <elf.h>
23#include <limits.h>
34#include <sys/mman.h>
......@@ -8,6 +9,8 @@
89#include "atomic.h"
910#include "syscall.h"
1011
12volatile int __thread_list_lock;
13
1114int __init_tp(void *p)
1215{
1316 pthread_t td = p;
......@@ -16,9 +19,11 @@ int __init_tp(void *p)
1619 if (r < 0) return -1;
1720 if (!r) libc.can_do_threads = 1;
1821 td->detach_state = DT_JOINABLE;
19 td->tid = __syscall(SYS_set_tid_address, &td->detach_state);
22 td->tid = __syscall(SYS_set_tid_address, &__thread_list_lock);
2023 td->locale = &libc.global_locale;
2124 td->robust_list.head = &td->robust_list.head;
25 td->sysinfo = __sysinfo;
26 td->next = td->prev = td;
2227 return 0;
2328}
2429
......@@ -110,7 +115,8 @@ static void static_init_tls(size_t *aux)
110115 & (main_tls.align-1);
111116#ifdef TLS_ABOVE_TP
112117 main_tls.offset = GAP_ABOVE_TP;
113 main_tls.offset += -GAP_ABOVE_TP & (main_tls.align-1);
118 main_tls.offset += (-GAP_ABOVE_TP + (uintptr_t)main_tls.image)
119 & (main_tls.align-1);
114120#else
115121 main_tls.offset = main_tls.size;
116122#endif
lib/libc/musl/src/env/__libc_start_main.c+1-1
......@@ -28,7 +28,7 @@ void __init_libc(char **envp, char *pn)
2828 libc.auxv = auxv = (void *)(envp+i+1);
2929 for (i=0; auxv[i]; i+=2) if (auxv[i]<AUX_CNT) aux[auxv[i]] = auxv[i+1];
3030 __hwcap = aux[AT_HWCAP];
31 __sysinfo = aux[AT_SYSINFO];
31 if (aux[AT_SYSINFO]) __sysinfo = aux[AT_SYSINFO];
3232 libc.page_size = aux[AT_PAGESZ];
3333
3434 if (!pn) pn = (void*)aux[AT_EXECFN];
lib/libc/musl/src/fenv/riscv64/fenv-sf.c created+3
......@@ -0,0 +1,3 @@
1#ifndef __riscv_flen
2#include "../fenv.c"
3#endif
lib/libc/musl/src/fenv/riscv64/fenv.S created+53
......@@ -0,0 +1,53 @@
1#ifdef __riscv_flen
2
3.global feclearexcept
4.type feclearexcept, %function
5feclearexcept:
6 csrc fflags, a0
7 li a0, 0
8 ret
9
10.global feraiseexcept
11.type feraiseexcept, %function
12feraiseexcept:
13 csrs fflags, a0
14 li a0, 0
15 ret
16
17.global fetestexcept
18.type fetestexcept, %function
19fetestexcept:
20 frflags t0
21 and a0, t0, a0
22 ret
23
24.global fegetround
25.type fegetround, %function
26fegetround:
27 frrm a0
28 ret
29
30.global __fesetround
31.type __fesetround, %function
32__fesetround:
33 fsrm t0, a0
34 li a0, 0
35 ret
36
37.global fegetenv
38.type fegetenv, %function
39fegetenv:
40 frcsr t0
41 sw t0, 0(a0)
42 li a0, 0
43 ret
44
45.global fesetenv
46.type fesetenv, %function
47fesetenv:
48 lw t1, 0(a0)
49 fscsr t0, t1
50 li a0, 0
51 ret
52
53#endif
lib/libc/musl/src/include/arpa/inet.h+1-1
......@@ -1,7 +1,7 @@
11#ifndef ARPA_INET_H
22#define ARPA_INET_H
33
4#include_next "arpa/inet.h"
4#include "../../../include/arpa/inet.h"
55
66hidden int __inet_aton(const char *, struct in_addr *);
77
lib/libc/musl/src/include/crypt.h+1-1
......@@ -1,7 +1,7 @@
11#ifndef CRYPT_H
22#define CRYPT_H
33
4#include_next "crypt.h"
4#include "../../include/crypt.h"
55
66#include <features.h>
77
lib/libc/musl/src/include/errno.h+4-1
......@@ -1,8 +1,11 @@
11#ifndef ERRNO_H
22#define ERRNO_H
33
4#include_next "errno.h"
4#include "../../include/errno.h"
55
6#ifdef __GNUC__
7__attribute__((const))
8#endif
69hidden int *___errno_location(void);
710
811#undef errno
lib/libc/musl/src/include/features.h+1-1
......@@ -1,7 +1,7 @@
11#ifndef FEATURES_H
22#define FEATURES_H
33
4#include_next "features.h"
4#include "../../include/features.h"
55
66#define weak __attribute__((__weak__))
77#define hidden __attribute__((__visibility__("hidden")))
lib/libc/musl/src/include/langinfo.h+1-1
......@@ -1,7 +1,7 @@
11#ifndef LANGINFO_H
22#define LANGINFO_H
33
4#include_next "langinfo.h"
4#include "../../include/langinfo.h"
55
66char *__nl_langinfo_l(nl_item, locale_t);
77
lib/libc/musl/src/include/pthread.h+8-1
......@@ -1,7 +1,7 @@
11#ifndef PTHREAD_H
22#define PTHREAD_H
33
4#include_next "pthread.h"
4#include "../../include/pthread.h"
55
66hidden int __pthread_once(pthread_once_t *, void (*)(void));
77hidden void __pthread_testcancel(void);
......@@ -18,5 +18,12 @@ hidden int __private_cond_signal(pthread_cond_t *, int);
1818hidden int __pthread_cond_timedwait(pthread_cond_t *restrict, pthread_mutex_t *restrict, const struct timespec *restrict);
1919hidden int __pthread_key_create(pthread_key_t *, void (*)(void *));
2020hidden int __pthread_key_delete(pthread_key_t);
21hidden int __pthread_rwlock_rdlock(pthread_rwlock_t *);
22hidden int __pthread_rwlock_tryrdlock(pthread_rwlock_t *);
23hidden int __pthread_rwlock_timedrdlock(pthread_rwlock_t *__restrict, const struct timespec *__restrict);
24hidden int __pthread_rwlock_wrlock(pthread_rwlock_t *);
25hidden int __pthread_rwlock_trywrlock(pthread_rwlock_t *);
26hidden int __pthread_rwlock_timedwrlock(pthread_rwlock_t *__restrict, const struct timespec *__restrict);
27hidden int __pthread_rwlock_unlock(pthread_rwlock_t *);
2128
2229#endif
lib/libc/musl/src/include/resolv.h+1-1
......@@ -1,7 +1,7 @@
11#ifndef RESOLV_H
22#define RESOLV_H
33
4#include_next "resolv.h"
4#include "../../include/resolv.h"
55
66hidden int __dn_expand(const unsigned char *, const unsigned char *, const unsigned char *, char *, int);
77
lib/libc/musl/src/include/signal.h+1-1
......@@ -1,7 +1,7 @@
11#ifndef SIGNAL_H
22#define SIGNAL_H
33
4#include_next "signal.h"
4#include "../../include/signal.h"
55
66hidden int __sigaction(int, const struct sigaction *, struct sigaction *);
77
lib/libc/musl/src/include/stdio.h+3-1
......@@ -1,7 +1,9 @@
11#ifndef STDIO_H
22#define STDIO_H
33
4#include_next "stdio.h"
4#define __DEFINED_struct__IO_FILE
5
6#include "../../include/stdio.h"
57
68#undef stdin
79#undef stdout
lib/libc/musl/src/include/stdlib.h+1-1
......@@ -1,7 +1,7 @@
11#ifndef STDLIB_H
22#define STDLIB_H
33
4#include_next "stdlib.h"
4#include "../../include/stdlib.h"
55
66hidden int __putenv(char *, size_t, char *);
77hidden void __env_rm_add(char *, char *);
lib/libc/musl/src/include/string.h+1-1
......@@ -1,7 +1,7 @@
11#ifndef STRING_H
22#define STRING_H
33
4#include_next "string.h"
4#include "../../include/string.h"
55
66hidden void *__memrchr(const void *, int, size_t);
77hidden char *__stpcpy(char *, const char *);
lib/libc/musl/src/include/sys/auxv.h+1-1
......@@ -1,7 +1,7 @@
11#ifndef SYS_AUXV_H
22#define SYS_AUXV_H
33
4#include_next "sys/auxv.h"
4#include "../../../include/sys/auxv.h"
55
66#include <features.h>
77
lib/libc/musl/src/include/sys/membarrier.h created+9
......@@ -0,0 +1,9 @@
1#ifndef SYS_MEMBARRIER_H
2#define SYS_MEMBARRIER_H
3
4#include "../../../include/sys/membarrier.h"
5#include <features.h>
6
7hidden int __membarrier(int, int);
8
9#endif
lib/libc/musl/src/include/sys/mman.h+1-1
......@@ -1,7 +1,7 @@
11#ifndef SYS_MMAN_H
22#define SYS_MMAN_H
33
4#include_next "sys/mman.h"
4#include "../../../include/sys/mman.h"
55
66hidden void __vm_wait(void);
77hidden void __vm_lock(void);
lib/libc/musl/src/include/sys/sysinfo.h+1-1
......@@ -1,7 +1,7 @@
11#ifndef SYS_SYSINFO_H
22#define SYS_SYSINFO_H
33
4#include_next "sys/sysinfo.h"
4#include "../../../include/sys/sysinfo.h"
55#include <features.h>
66
77hidden int __lsysinfo(struct sysinfo *);
lib/libc/musl/src/include/sys/time.h+1-1
......@@ -1,7 +1,7 @@
11#ifndef SYS_TIME_H
22#define SYS_TIME_H
33
4#include_next "sys/time.h"
4#include "../../../include/sys/time.h"
55
66hidden int __futimesat(int, const char *, const struct timeval [2]);
77
lib/libc/musl/src/include/time.h+1-1
......@@ -1,7 +1,7 @@
11#ifndef TIME_H
22#define TIME_H
33
4#include_next "time.h"
4#include "../../include/time.h"
55
66hidden int __clock_gettime(clockid_t, struct timespec *);
77
lib/libc/musl/src/include/unistd.h+1-1
......@@ -1,7 +1,7 @@
11#ifndef UNISTD_H
22#define UNISTD_H
33
4#include_next "unistd.h"
4#include "../../include/unistd.h"
55
66extern char **__environ;
77
lib/libc/musl/src/include/wchar.h created+9
......@@ -0,0 +1,9 @@
1#ifndef WCHAR_H
2#define WCHAR_H
3
4#define __DEFINED_struct__IO_FILE
5
6#include "../../include/wchar.h"
7
8#endif
9
lib/libc/musl/src/internal/aarch64/syscall.s deleted-14
......@@ -1,14 +0,0 @@
1.global __syscall
2.hidden __syscall
3.type __syscall,%function
4__syscall:
5 uxtw x8,w0
6 mov x0,x1
7 mov x1,x2
8 mov x2,x3
9 mov x3,x4
10 mov x4,x5
11 mov x5,x6
12 mov x6,x7
13 svc 0
14 ret
lib/libc/musl/src/internal/arm/syscall.s deleted-15
......@@ -1,15 +0,0 @@
1.syntax unified
2.global __syscall
3.hidden __syscall
4.type __syscall,%function
5__syscall:
6 mov ip,sp
7 stmfd sp!,{r4,r5,r6,r7}
8 mov r7,r0
9 mov r0,r1
10 mov r1,r2
11 mov r2,r3
12 ldmfd ip,{r3,r4,r5,r6}
13 svc 0
14 ldmfd sp!,{r4,r5,r6,r7}
15 bx lr
lib/libc/musl/src/internal/complex_impl.h created+22
......@@ -0,0 +1,22 @@
1#ifndef _COMPLEX_IMPL_H
2#define _COMPLEX_IMPL_H
3
4#include <complex.h>
5#include "libm.h"
6
7#undef __CMPLX
8#undef CMPLX
9#undef CMPLXF
10#undef CMPLXL
11
12#define __CMPLX(x, y, t) \
13 ((union { _Complex t __z; t __xy[2]; }){.__xy = {(x),(y)}}.__z)
14
15#define CMPLX(x, y) __CMPLX(x, y, double)
16#define CMPLXF(x, y) __CMPLX(x, y, float)
17#define CMPLXL(x, y) __CMPLX(x, y, long double)
18
19hidden double complex __ldexp_cexp(double complex,int);
20hidden float complex __ldexp_cexpf(float complex,int);
21
22#endif
lib/libc/musl/src/internal/defsysinfo.c created+3
......@@ -0,0 +1,3 @@
1#include "libc.h"
2
3size_t __sysinfo;
lib/libc/musl/src/internal/dynlink.h+1-1
......@@ -95,7 +95,7 @@ struct fdpic_dummy_loadmap {
9595#define DYN_CNT 32
9696
9797typedef void (*stage2_func)(unsigned char *, size_t *);
98typedef _Noreturn void (*stage3_func)(size_t *);
98typedef void (*stage3_func)(size_t *);
9999
100100hidden void *__dlsym(void *restrict, const char *restrict, void *restrict);
101101
lib/libc/musl/src/internal/i386/defsysinfo.s created+9
......@@ -0,0 +1,9 @@
11: int $128
2 ret
3
4.data
5.align 4
6.hidden __sysinfo
7.global __sysinfo
8__sysinfo:
9 .long 1b
lib/libc/musl/src/internal/i386/syscall.s deleted-78
......@@ -1,78 +0,0 @@
1.hidden __sysinfo
2
3# The calling convention for __vsyscall has the syscall number
4# and 5 args arriving as: eax, edx, ecx, edi, esi, 4(%esp).
5# This ensures that the inline asm in the C code never has to touch
6# ebx or ebp (which are unavailable in PIC and frame-pointer-using
7# code, respectively), and optimizes for size/simplicity in the caller.
8
9.global __vsyscall
10.hidden __vsyscall
11.type __vsyscall,@function
12__vsyscall:
13 push %edi
14 push %ebx
15 mov %edx,%ebx
16 mov %edi,%edx
17 mov 12(%esp),%edi
18 push %eax
19 call 1f
202: mov %ebx,%edx
21 pop %ebx
22 pop %ebx
23 pop %edi
24 ret
25
261: mov (%esp),%eax
27 add $[__sysinfo-2b],%eax
28 mov (%eax),%eax
29 test %eax,%eax
30 jz 1f
31 push %eax
32 mov 8(%esp),%eax
33 ret # tail call to kernel vsyscall entry
341: mov 4(%esp),%eax
35 int $128
36 ret
37
38# The __vsyscall6 entry point is used only for 6-argument syscalls.
39# Instead of passing the 5th argument on the stack, a pointer to the
40# 5th and 6th arguments is passed. This is ugly, but there are no
41# register constraints the inline asm could use that would make it
42# possible to pass two arguments on the stack.
43
44.global __vsyscall6
45.hidden __vsyscall6
46.type __vsyscall6,@function
47__vsyscall6:
48 push %ebp
49 push %eax
50 mov 12(%esp), %ebp
51 mov (%ebp), %eax
52 mov 4(%ebp), %ebp
53 push %eax
54 mov 4(%esp),%eax
55 call __vsyscall
56 pop %ebp
57 pop %ebp
58 pop %ebp
59 ret
60
61.global __syscall
62.hidden __syscall
63.type __syscall,@function
64__syscall:
65 lea 24(%esp),%eax
66 push %esi
67 push %edi
68 push %eax
69 mov 16(%esp),%eax
70 mov 20(%esp),%edx
71 mov 24(%esp),%ecx
72 mov 28(%esp),%edi
73 mov 32(%esp),%esi
74 call __vsyscall6
75 pop %edi
76 pop %edi
77 pop %esi
78 ret
lib/libc/musl/src/internal/libc.c-1
......@@ -3,7 +3,6 @@
33struct __libc __libc;
44
55size_t __hwcap;
6size_t __sysinfo;
76char *__progname=0, *__progname_full=0;
87
98weak_alias(__progname, program_invocation_short_name);
lib/libc/musl/src/internal/libm.h+149-77
......@@ -1,23 +1,11 @@
1/* origin: FreeBSD /usr/src/lib/msun/src/math_private.h */
2/*
3 * ====================================================
4 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5 *
6 * Developed at SunPro, 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
131#ifndef _LIBM_H
142#define _LIBM_H
153
164#include <stdint.h>
175#include <float.h>
186#include <math.h>
19#include <complex.h>
207#include <endian.h>
8#include "fp_arch.h"
219
2210#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
2311#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __LITTLE_ENDIAN
......@@ -71,102 +59,177 @@ union ldshape {
7159#error Unsupported long double representation
7260#endif
7361
62/* Support non-nearest rounding mode. */
63#define WANT_ROUNDING 1
64/* Support signaling NaNs. */
65#define WANT_SNAN 0
66
67#if WANT_SNAN
68#error SNaN is unsupported
69#else
70#define issignalingf_inline(x) 0
71#define issignaling_inline(x) 0
72#endif
73
74#ifndef TOINT_INTRINSICS
75#define TOINT_INTRINSICS 0
76#endif
77
78#if TOINT_INTRINSICS
79/* Round x to nearest int in all rounding modes, ties have to be rounded
80 consistently with converttoint so the results match. If the result
81 would be outside of [-2^31, 2^31-1] then the semantics is unspecified. */
82static double_t roundtoint(double_t);
83
84/* Convert x to nearest int in all rounding modes, ties have to be rounded
85 consistently with roundtoint. If the result is not representible in an
86 int32_t then the semantics is unspecified. */
87static int32_t converttoint(double_t);
88#endif
89
90/* Helps static branch prediction so hot path can be better optimized. */
91#ifdef __GNUC__
92#define predict_true(x) __builtin_expect(!!(x), 1)
93#define predict_false(x) __builtin_expect(x, 0)
94#else
95#define predict_true(x) (x)
96#define predict_false(x) (x)
97#endif
98
99/* Evaluate an expression as the specified type. With standard excess
100 precision handling a type cast or assignment is enough (with
101 -ffloat-store an assignment is required, in old compilers argument
102 passing and return statement may not drop excess precision). */
103
104static inline float eval_as_float(float x)
105{
106 float y = x;
107 return y;
108}
109
110static inline double eval_as_double(double x)
111{
112 double y = x;
113 return y;
114}
115
116/* fp_barrier returns its input, but limits code transformations
117 as if it had a side-effect (e.g. observable io) and returned
118 an arbitrary value. */
119
120#ifndef fp_barrierf
121#define fp_barrierf fp_barrierf
122static inline float fp_barrierf(float x)
123{
124 volatile float y = x;
125 return y;
126}
127#endif
128
129#ifndef fp_barrier
130#define fp_barrier fp_barrier
131static inline double fp_barrier(double x)
132{
133 volatile double y = x;
134 return y;
135}
136#endif
137
138#ifndef fp_barrierl
139#define fp_barrierl fp_barrierl
140static inline long double fp_barrierl(long double x)
141{
142 volatile long double y = x;
143 return y;
144}
145#endif
146
147/* fp_force_eval ensures that the input value is computed when that's
148 otherwise unused. To prevent the constant folding of the input
149 expression, an additional fp_barrier may be needed or a compilation
150 mode that does so (e.g. -frounding-math in gcc). Then it can be
151 used to evaluate an expression for its fenv side-effects only. */
152
153#ifndef fp_force_evalf
154#define fp_force_evalf fp_force_evalf
155static inline void fp_force_evalf(float x)
156{
157 volatile float y;
158 y = x;
159}
160#endif
161
162#ifndef fp_force_eval
163#define fp_force_eval fp_force_eval
164static inline void fp_force_eval(double x)
165{
166 volatile double y;
167 y = x;
168}
169#endif
170
171#ifndef fp_force_evall
172#define fp_force_evall fp_force_evall
173static inline void fp_force_evall(long double x)
174{
175 volatile long double y;
176 y = x;
177}
178#endif
179
74180#define FORCE_EVAL(x) do { \
75181 if (sizeof(x) == sizeof(float)) { \
76 volatile float __x; \
77 __x = (x); \
182 fp_force_evalf(x); \
78183 } else if (sizeof(x) == sizeof(double)) { \
79 volatile double __x; \
80 __x = (x); \
184 fp_force_eval(x); \
81185 } else { \
82 volatile long double __x; \
83 __x = (x); \
186 fp_force_evall(x); \
84187 } \
85188} while(0)
86189
87/* Get two 32 bit ints from a double. */
190#define asuint(f) ((union{float _f; uint32_t _i;}){f})._i
191#define asfloat(i) ((union{uint32_t _i; float _f;}){i})._f
192#define asuint64(f) ((union{double _f; uint64_t _i;}){f})._i
193#define asdouble(i) ((union{uint64_t _i; double _f;}){i})._f
194
88195#define EXTRACT_WORDS(hi,lo,d) \
89196do { \
90 union {double f; uint64_t i;} __u; \
91 __u.f = (d); \
92 (hi) = __u.i >> 32; \
93 (lo) = (uint32_t)__u.i; \
197 uint64_t __u = asuint64(d); \
198 (hi) = __u >> 32; \
199 (lo) = (uint32_t)__u; \
94200} while (0)
95201
96/* Get the more significant 32 bit int from a double. */
97202#define GET_HIGH_WORD(hi,d) \
98203do { \
99 union {double f; uint64_t i;} __u; \
100 __u.f = (d); \
101 (hi) = __u.i >> 32; \
204 (hi) = asuint64(d) >> 32; \
102205} while (0)
103206
104/* Get the less significant 32 bit int from a double. */
105207#define GET_LOW_WORD(lo,d) \
106208do { \
107 union {double f; uint64_t i;} __u; \
108 __u.f = (d); \
109 (lo) = (uint32_t)__u.i; \
209 (lo) = (uint32_t)asuint64(d); \
110210} while (0)
111211
112/* Set a double from two 32 bit ints. */
113212#define INSERT_WORDS(d,hi,lo) \
114213do { \
115 union {double f; uint64_t i;} __u; \
116 __u.i = ((uint64_t)(hi)<<32) | (uint32_t)(lo); \
117 (d) = __u.f; \
214 (d) = asdouble(((uint64_t)(hi)<<32) | (uint32_t)(lo)); \
118215} while (0)
119216
120/* Set the more significant 32 bits of a double from an int. */
121217#define SET_HIGH_WORD(d,hi) \
122do { \
123 union {double f; uint64_t i;} __u; \
124 __u.f = (d); \
125 __u.i &= 0xffffffff; \
126 __u.i |= (uint64_t)(hi) << 32; \
127 (d) = __u.f; \
128} while (0)
218 INSERT_WORDS(d, hi, (uint32_t)asuint64(d))
129219
130/* Set the less significant 32 bits of a double from an int. */
131220#define SET_LOW_WORD(d,lo) \
132do { \
133 union {double f; uint64_t i;} __u; \
134 __u.f = (d); \
135 __u.i &= 0xffffffff00000000ull; \
136 __u.i |= (uint32_t)(lo); \
137 (d) = __u.f; \
138} while (0)
221 INSERT_WORDS(d, asuint64(d)>>32, lo)
139222
140/* Get a 32 bit int from a float. */
141223#define GET_FLOAT_WORD(w,d) \
142224do { \
143 union {float f; uint32_t i;} __u; \
144 __u.f = (d); \
145 (w) = __u.i; \
225 (w) = asuint(d); \
146226} while (0)
147227
148/* Set a float from a 32 bit int. */
149228#define SET_FLOAT_WORD(d,w) \
150229do { \
151 union {float f; uint32_t i;} __u; \
152 __u.i = (w); \
153 (d) = __u.f; \
230 (d) = asfloat(w); \
154231} while (0)
155232
156#undef __CMPLX
157#undef CMPLX
158#undef CMPLXF
159#undef CMPLXL
160
161#define __CMPLX(x, y, t) \
162 ((union { _Complex t __z; t __xy[2]; }){.__xy = {(x),(y)}}.__z)
163
164#define CMPLX(x, y) __CMPLX(x, y, double)
165#define CMPLXF(x, y) __CMPLX(x, y, float)
166#define CMPLXL(x, y) __CMPLX(x, y, long double)
167
168/* fdlibm kernel functions */
169
170233hidden int __rem_pio2_large(double*,double*,int,int,int);
171234
172235hidden int __rem_pio2(double,double*);
......@@ -174,21 +237,18 @@ hidden double __sin(double,double,int);
174237hidden double __cos(double,double);
175238hidden double __tan(double,double,int);
176239hidden double __expo2(double);
177hidden double complex __ldexp_cexp(double complex,int);
178240
179241hidden int __rem_pio2f(float,double*);
180242hidden float __sindf(double);
181243hidden float __cosdf(double);
182244hidden float __tandf(double,int);
183245hidden float __expo2f(float);
184hidden float complex __ldexp_cexpf(float complex,int);
185246
186247hidden int __rem_pio2l(long double, long double *);
187248hidden long double __sinl(long double, long double, int);
188249hidden long double __cosl(long double, long double);
189250hidden long double __tanl(long double, long double, int);
190251
191/* polynomial evaluation */
192252hidden long double __polevll(long double, const long double *, int);
193253hidden long double __p1evll(long double, const long double *, int);
194254
......@@ -196,4 +256,16 @@ extern int __signgam;
196256hidden double __lgamma_r(double, int *);
197257hidden float __lgammaf_r(float, int *);
198258
259/* error handling functions */
260hidden float __math_xflowf(uint32_t, float);
261hidden float __math_uflowf(uint32_t);
262hidden float __math_oflowf(uint32_t);
263hidden float __math_divzerof(uint32_t);
264hidden float __math_invalidf(float);
265hidden double __math_xflow(uint32_t, double);
266hidden double __math_uflow(uint32_t);
267hidden double __math_oflow(uint32_t);
268hidden double __math_divzero(uint32_t);
269hidden double __math_invalid(double);
270
199271#endif
lib/libc/musl/src/internal/m68k/syscall.s deleted-9
......@@ -1,9 +0,0 @@
1.global __syscall
2.hidden __syscall
3.type __syscall,%function
4__syscall:
5 movem.l %d2-%d5,-(%sp)
6 movem.l 20(%sp),%d0-%d5/%a0
7 trap #0
8 movem.l (%sp)+,%d2-%d5
9 rts
lib/libc/musl/src/internal/microblaze/syscall.s deleted-14
......@@ -1,14 +0,0 @@
1.global __syscall
2.hidden __syscall
3.type __syscall,@function
4__syscall:
5 addi r12, r5, 0 # Save the system call number
6 add r5, r6, r0 # Shift the arguments, arg1
7 add r6, r7, r0 # arg2
8 add r7, r8, r0 # arg3
9 add r8, r9, r0 # arg4
10 add r9, r10, r0 # arg5
11 lwi r10, r1, 28 # Get arg6.
12 brki r14, 0x8 # syscall
13 rtsd r15, 8
14 nop
lib/libc/musl/src/internal/mips/syscall.s deleted-26
......@@ -1,26 +0,0 @@
1.set noreorder
2
3.global __syscall
4.hidden __syscall
5.type __syscall,@function
6__syscall:
7 move $2, $4
8 move $4, $5
9 move $5, $6
10 move $6, $7
11 lw $7, 16($sp)
12 lw $8, 20($sp)
13 lw $9, 24($sp)
14 lw $10,28($sp)
15 subu $sp, $sp, 32
16 sw $8, 16($sp)
17 sw $9, 20($sp)
18 sw $10,24($sp)
19 sw $2 ,28($sp)
20 lw $2, 28($sp)
21 syscall
22 beq $7, $0, 1f
23 addu $sp, $sp, 32
24 subu $2, $0, $2
251: jr $ra
26 nop
lib/libc/musl/src/internal/mips64/syscall.s deleted-19
......@@ -1,19 +0,0 @@
1.set noreorder
2.global __syscall
3.hidden __syscall
4.type __syscall,@function
5__syscall:
6 move $2, $4
7 move $4, $5
8 move $5, $6
9 move $6, $7
10 move $7, $8
11 move $8, $9
12 move $9, $10
13 move $10, $11
14 syscall
15 beq $7, $0, 1f
16 nop
17 dsubu $2, $0, $2
181: jr $ra
19 nop
lib/libc/musl/src/internal/mipsn32/syscall.s deleted-19
......@@ -1,19 +0,0 @@
1.set noreorder
2.global __syscall
3.hidden __syscall
4.type __syscall,@function
5__syscall:
6 move $2, $4
7 move $4, $5
8 move $5, $6
9 move $6, $7
10 move $7, $8
11 move $8, $9
12 move $9, $10
13 move $10, $11
14 syscall
15 beq $7, $0, 1f
16 nop
17 subu $2, $0, $2
181: jr $ra
19 nop
lib/libc/musl/src/internal/or1k/syscall.s deleted-14
......@@ -1,14 +0,0 @@
1.global __syscall
2.hidden __syscall
3.type __syscall,@function
4__syscall:
5 l.ori r11, r3, 0
6 l.lwz r3, 0(r1)
7 l.lwz r4, 4(r1)
8 l.lwz r5, 8(r1)
9 l.lwz r6, 12(r1)
10 l.lwz r7, 16(r1)
11 l.lwz r8, 20(r1)
12 l.sys 1
13 l.jr r9
14 l.nop
lib/libc/musl/src/internal/powerpc/syscall.s deleted-19
......@@ -1,19 +0,0 @@
1 .global __syscall
2 .hidden __syscall
3 .type __syscall,@function
4__syscall:
5 mr 0, 3 # Save the system call number
6 mr 3, 4 # Shift the arguments: arg1
7 mr 4, 5 # arg2
8 mr 5, 6 # arg3
9 mr 6, 7 # arg4
10 mr 7, 8 # arg5
11 mr 8, 9 # arg6
12 sc
13 bnslr+ # return if not summary overflow
14 #else error:
15 # return negated value.
16 neg 3, 3
17 blr
18 .end __syscall
19 .size __syscall, .-__syscall
lib/libc/musl/src/internal/powerpc64/syscall.s deleted-17
......@@ -1,17 +0,0 @@
1 .global __syscall
2 .hidden __syscall
3 .type __syscall,@function
4__syscall:
5 mr 0, 3 # Save the system call number
6 mr 3, 4 # Shift the arguments: arg1
7 mr 4, 5 # arg2
8 mr 5, 6 # arg3
9 mr 6, 7 # arg4
10 mr 7, 8 # arg5
11 mr 8, 9 # arg6
12 sc
13 bnslr+ # return if not summary overflow
14 neg 3, 3 # otherwise error: return negated value.
15 blr
16 .end __syscall
17 .size __syscall, .-__syscall
lib/libc/musl/src/internal/pthread_impl.h+9-16
......@@ -18,7 +18,7 @@ struct pthread {
1818 * internal (accessed via asm) ABI. Do not change. */
1919 struct pthread *self;
2020 uintptr_t *dtv;
21 void *unused1, *unused2;
21 struct pthread *prev, *next; /* non-ABI */
2222 uintptr_t sysinfo;
2323 uintptr_t canary, canary2;
2424
......@@ -29,15 +29,12 @@ struct pthread {
2929 volatile int cancel;
3030 volatile unsigned char canceldisable, cancelasync;
3131 unsigned char tsd_used:1;
32 unsigned char unblock_cancel:1;
3332 unsigned char dlerror_flag:1;
3433 unsigned char *map_base;
3534 size_t map_size;
3635 void *stack;
3736 size_t stack_size;
3837 size_t guard_size;
39 void *start_arg;
40 void *(*start)(void *);
4138 void *result;
4239 struct __ptcb *cancelbuf;
4340 void **tsd;
......@@ -58,20 +55,10 @@ struct pthread {
5855 uintptr_t *dtv_copy;
5956};
6057
61struct start_sched_args {
62 void *start_arg;
63 void *(*start_fn)(void *);
64 sigset_t mask;
65 pthread_attr_t *attr;
66 volatile int futex;
67};
68
6958enum {
70 DT_EXITED = 0,
71 DT_EXITING,
59 DT_EXITING = 0,
7260 DT_JOINABLE,
7361 DT_DETACHED,
74 DT_DYNAMIC,
7562};
7663
7764struct __timer {
......@@ -143,6 +130,7 @@ hidden int __init_tp(void *);
143130hidden void *__copy_tls(unsigned char *);
144131hidden void __reset_tls();
145132
133hidden void __membarrier_init(void);
146134hidden void __dl_thread_cleanup(void);
147135hidden void __testcancel();
148136hidden void __do_cleanup_push(struct __ptcb *);
......@@ -152,7 +140,6 @@ hidden void __pthread_tsd_run_dtors();
152140hidden void __pthread_key_delete_synccall(void (*)(void *), void *);
153141hidden int __pthread_key_delete_impl(pthread_key_t);
154142
155extern hidden volatile int __block_new_threads;
156143extern hidden volatile size_t __pthread_tsd_size;
157144extern hidden void *__pthread_tsd_main[];
158145extern hidden volatile int __aio_fut;
......@@ -184,6 +171,12 @@ hidden void __acquire_ptc(void);
184171hidden void __release_ptc(void);
185172hidden void __inhibit_ptc(void);
186173
174hidden void __tl_lock(void);
175hidden void __tl_unlock(void);
176hidden void __tl_sync(pthread_t);
177
178extern hidden volatile int __thread_list_lock;
179
187180extern hidden unsigned __default_stacksize;
188181extern hidden unsigned __default_guardsize;
189182
lib/libc/musl/src/internal/s390x/syscall.s deleted-15
......@@ -1,15 +0,0 @@
1.global __syscall
2.hidden __syscall
3.type __syscall, %function
4__syscall:
5 stg %r7, 56(%r15)
6 lgr %r1, %r2
7 lgr %r2, %r3
8 lgr %r3, %r4
9 lgr %r4, %r5
10 lgr %r5, %r6
11 lg %r6, 160(%r15)
12 lg %r7, 168(%r15)
13 svc 0
14 lg %r7, 56(%r15)
15 br %r14
lib/libc/musl/src/internal/sh/syscall.s deleted-23
......@@ -1,23 +0,0 @@
1.global __syscall
2.hidden __syscall
3.type __syscall, @function
4__syscall:
5 ! The kernel syscall entry point documents that the trap number indicates
6 ! the number of arguments being passed, but it then ignores that information.
7 ! Since we do not actually know how many arguments are being passed, we will
8 ! say there are six, since that is the maximum we support here.
9 mov r4, r3
10 mov r5, r4
11 mov r6, r5
12 mov r7, r6
13 mov.l @r15, r7
14 mov.l @(4,r15), r0
15 mov.l @(8,r15), r1
16 trapa #31
17 or r0, r0
18 or r0, r0
19 or r0, r0
20 or r0, r0
21 or r0, r0
22 rts
23 nop
lib/libc/musl/src/internal/shgetc.c+2-1
......@@ -22,7 +22,8 @@ int __shgetc(FILE *f)
2222 off_t cnt = shcnt(f);
2323 if (f->shlim && cnt >= f->shlim || (c=__uflow(f)) < 0) {
2424 f->shcnt = f->buf - f->rpos + cnt;
25 f->shend = 0;
25 f->shend = f->rpos;
26 f->shlim = -1;
2627 return EOF;
2728 }
2829 cnt++;
lib/libc/musl/src/internal/shgetc.h+1-1
......@@ -26,7 +26,7 @@ hidden int __shgetc(FILE *);
2626#define shcnt(f) ((f)->shcnt + ((f)->rpos - (f)->buf))
2727#define shlim(f, lim) __shlim((f), (lim))
2828#define shgetc(f) (((f)->rpos != (f)->shend) ? *(f)->rpos++ : __shgetc(f))
29#define shunget(f) ((f)->shend ? (void)(f)->rpos-- : (void)0)
29#define shunget(f) ((f)->shlim>=0 ? (void)(f)->rpos-- : (void)0)
3030
3131#define sh_fromstring(f, s) \
3232 ((f)->buf = (f)->rpos = (void *)(s), (f)->rend = (void*)-1)
lib/libc/musl/src/internal/syscall.c deleted
lib/libc/musl/src/internal/syscall.h+2-12
......@@ -22,27 +22,17 @@
2222typedef long syscall_arg_t;
2323#endif
2424
25hidden long __syscall_ret(unsigned long), __syscall(syscall_arg_t, ...),
25hidden long __syscall_ret(unsigned long),
2626 __syscall_cp(syscall_arg_t, syscall_arg_t, syscall_arg_t, syscall_arg_t,
2727 syscall_arg_t, syscall_arg_t, syscall_arg_t);
2828
29#ifdef SYSCALL_NO_INLINE
30#define __syscall0(n) (__syscall)(n)
31#define __syscall1(n,a) (__syscall)(n,__scc(a))
32#define __syscall2(n,a,b) (__syscall)(n,__scc(a),__scc(b))
33#define __syscall3(n,a,b,c) (__syscall)(n,__scc(a),__scc(b),__scc(c))
34#define __syscall4(n,a,b,c,d) (__syscall)(n,__scc(a),__scc(b),__scc(c),__scc(d))
35#define __syscall5(n,a,b,c,d,e) (__syscall)(n,__scc(a),__scc(b),__scc(c),__scc(d),__scc(e))
36#define __syscall6(n,a,b,c,d,e,f) (__syscall)(n,__scc(a),__scc(b),__scc(c),__scc(d),__scc(e),__scc(f))
37#else
3829#define __syscall1(n,a) __syscall1(n,__scc(a))
3930#define __syscall2(n,a,b) __syscall2(n,__scc(a),__scc(b))
4031#define __syscall3(n,a,b,c) __syscall3(n,__scc(a),__scc(b),__scc(c))
4132#define __syscall4(n,a,b,c,d) __syscall4(n,__scc(a),__scc(b),__scc(c),__scc(d))
4233#define __syscall5(n,a,b,c,d,e) __syscall5(n,__scc(a),__scc(b),__scc(c),__scc(d),__scc(e))
4334#define __syscall6(n,a,b,c,d,e,f) __syscall6(n,__scc(a),__scc(b),__scc(c),__scc(d),__scc(e),__scc(f))
44#endif
45#define __syscall7(n,a,b,c,d,e,f,g) (__syscall)(n,__scc(a),__scc(b),__scc(c),__scc(d),__scc(e),__scc(f),__scc(g))
35#define __syscall7(n,a,b,c,d,e,f,g) __syscall7(n,__scc(a),__scc(b),__scc(c),__scc(d),__scc(e),__scc(f),__scc(g))
4636
4737#define __SYSCALL_NARGS_X(a,b,c,d,e,f,g,h,n,...) n
4838#define __SYSCALL_NARGS(...) __SYSCALL_NARGS_X(__VA_ARGS__,7,6,5,4,3,2,1,0,)
lib/libc/musl/src/internal/version.h+1-1
......@@ -1 +1 @@
1#define VERSION "1.1.21"
1#define VERSION "1.1.23"
lib/libc/musl/src/internal/x32/syscall.s deleted-13
......@@ -1,13 +0,0 @@
1.global __syscall
2.hidden __syscall
3.type __syscall,@function
4__syscall:
5 movq %rdi,%rax
6 movq %rsi,%rdi
7 movq %rdx,%rsi
8 movq %rcx,%rdx
9 movq %r8,%r10
10 movq %r9,%r8
11 movq 8(%rsp),%r9
12 syscall
13 ret
lib/libc/musl/src/internal/x86_64/syscall.s deleted-13
......@@ -1,13 +0,0 @@
1.global __syscall
2.hidden __syscall
3.type __syscall,@function
4__syscall:
5 movq %rdi,%rax
6 movq %rsi,%rdi
7 movq %rdx,%rsi
8 movq %rcx,%rdx
9 movq %r8,%r10
10 movq %r9,%r8
11 movq 8(%rsp),%r9
12 syscall
13 ret
lib/libc/musl/src/ipc/msgctl.c+1-1
......@@ -17,7 +17,7 @@ int msgctl(int q, int cmd, struct msqid_ds *buf)
1717 buf = &tmp;
1818 }
1919#endif
20#ifdef SYS_msgctl
20#ifndef SYS_ipc
2121 int r = __syscall(SYS_msgctl, q, cmd | IPC_64, buf);
2222#else
2323 int r = __syscall(SYS_ipc, IPCOP_msgctl, q, cmd | IPC_64, 0, buf, 0);
lib/libc/musl/src/ipc/msgget.c+1-1
......@@ -4,7 +4,7 @@
44
55int msgget(key_t k, int flag)
66{
7#ifdef SYS_msgget
7#ifndef SYS_ipc
88 return syscall(SYS_msgget, k, flag);
99#else
1010 return syscall(SYS_ipc, IPCOP_msgget, k, flag);
lib/libc/musl/src/ipc/msgrcv.c+1-1
......@@ -4,7 +4,7 @@
44
55ssize_t msgrcv(int q, void *m, size_t len, long type, int flag)
66{
7#ifdef SYS_msgrcv
7#ifndef SYS_ipc
88 return syscall_cp(SYS_msgrcv, q, m, len, type, flag);
99#else
1010 return syscall_cp(SYS_ipc, IPCOP_msgrcv, q, len, flag, ((long[]){ (long)m, type }));
lib/libc/musl/src/ipc/msgsnd.c+1-1
......@@ -4,7 +4,7 @@
44
55int msgsnd(int q, const void *m, size_t len, int flag)
66{
7#ifdef SYS_msgsnd
7#ifndef SYS_ipc
88 return syscall_cp(SYS_msgsnd, q, m, len, flag);
99#else
1010 return syscall_cp(SYS_ipc, IPCOP_msgsnd, q, len, flag, m);
lib/libc/musl/src/ipc/semctl.c+1-1
......@@ -33,7 +33,7 @@ int semctl(int id, int num, int cmd, ...)
3333 arg.buf = &tmp;
3434 }
3535#endif
36#ifdef SYS_semctl
36#ifndef SYS_ipc
3737 int r = __syscall(SYS_semctl, id, num, cmd | IPC_64, arg.buf);
3838#else
3939 int r = __syscall(SYS_ipc, IPCOP_semctl, id, num, cmd | IPC_64, &arg.buf);
lib/libc/musl/src/ipc/semget.c+1-1
......@@ -11,7 +11,7 @@ int semget(key_t key, int n, int fl)
1111 * n fits in the correct (per POSIX) userspace type, so
1212 * we have to check here. */
1313 if (n > USHRT_MAX) return __syscall_ret(-EINVAL);
14#ifdef SYS_semget
14#ifndef SYS_ipc
1515 return syscall(SYS_semget, key, n, fl);
1616#else
1717 return syscall(SYS_ipc, IPCOP_semget, key, n, fl);
lib/libc/musl/src/ipc/semop.c+1-1
......@@ -4,7 +4,7 @@
44
55int semop(int id, struct sembuf *buf, size_t n)
66{
7#ifdef SYS_semop
7#ifndef SYS_ipc
88 return syscall(SYS_semop, id, buf, n);
99#else
1010 return syscall(SYS_ipc, IPCOP_semop, id, n, 0, buf);
lib/libc/musl/src/ipc/semtimedop.c+1-1
......@@ -5,7 +5,7 @@
55
66int semtimedop(int id, struct sembuf *buf, size_t n, const struct timespec *ts)
77{
8#ifdef SYS_semtimedop
8#ifndef SYS_ipc
99 return syscall(SYS_semtimedop, id, buf, n, ts);
1010#else
1111 return syscall(SYS_ipc, IPCOP_semtimedop, id, n, 0, buf, ts);
lib/libc/musl/src/ipc/shmat.c+1-1
......@@ -2,7 +2,7 @@
22#include "syscall.h"
33#include "ipc.h"
44
5#ifdef SYS_shmat
5#ifndef SYS_ipc
66void *shmat(int id, const void *addr, int flag)
77{
88 return (void *)syscall(SYS_shmat, id, addr, flag);
lib/libc/musl/src/ipc/shmctl.c+1-1
......@@ -17,7 +17,7 @@ int shmctl(int id, int cmd, struct shmid_ds *buf)
1717 buf = &tmp;
1818 }
1919#endif
20#ifdef SYS_shmctl
20#ifndef SYS_ipc
2121 int r = __syscall(SYS_shmctl, id, cmd | IPC_64, buf);
2222#else
2323 int r = __syscall(SYS_ipc, IPCOP_shmctl, id, cmd | IPC_64, 0, buf, 0);
lib/libc/musl/src/ipc/shmdt.c+1-1
......@@ -4,7 +4,7 @@
44
55int shmdt(const void *addr)
66{
7#ifdef SYS_shmdt
7#ifndef SYS_ipc
88 return syscall(SYS_shmdt, addr);
99#else
1010 return syscall(SYS_ipc, IPCOP_shmdt, 0, 0, 0, addr);
lib/libc/musl/src/ipc/shmget.c+1-1
......@@ -6,7 +6,7 @@
66int shmget(key_t key, size_t size, int flag)
77{
88 if (size > PTRDIFF_MAX) size = SIZE_MAX;
9#ifdef SYS_shmget
9#ifndef SYS_ipc
1010 return syscall(SYS_shmget, key, size, flag);
1111#else
1212 return syscall(SYS_ipc, IPCOP_shmget, key, size, flag);
lib/libc/musl/src/ldso/aarch64/tlsdesc.s+7-67
......@@ -23,73 +23,13 @@ __tlsdesc_static:
2323.hidden __tlsdesc_dynamic
2424.type __tlsdesc_dynamic,@function
2525__tlsdesc_dynamic:
26 stp x1,x2,[sp,#-32]!
27 stp x3,x4,[sp,#16]
26 stp x1,x2,[sp,#-16]!
2827 mrs x1,tpidr_el0 // tp
2928 ldr x0,[x0,#8] // p
30 ldr x2,[x0] // p->modidx
31 ldr x3,[x1,#-8] // dtv
32 ldr x4,[x3] // dtv[0]
33 cmp x2,x4
34 b.hi 1f
35 ldr x2,[x3,x2,lsl #3] // dtv[p->modidx]
36 ldr x0,[x0,#8] // p->off
37 add x0,x0,x2
382: sub x0,x0,x1
39 ldp x3,x4,[sp,#16]
40 ldp x1,x2,[sp],#32
29 ldp x0,x2,[x0] // p->modidx, p->off
30 sub x2,x2,x1 // p->off - tp
31 ldr x1,[x1,#-8] // dtv
32 ldr x1,[x1,x0,lsl #3] // dtv[p->modidx]
33 add x0,x1,x2 // dtv[p->modidx] + p->off - tp
34 ldp x1,x2,[sp],#16
4135 ret
42
43 // save all registers __tls_get_new may clobber
44 // update sp in two steps because offset must be in [-512,509]
451: stp x29,x30,[sp,#-160]!
46 stp x5,x6,[sp,#16]
47 stp x7,x8,[sp,#32]
48 stp x9,x10,[sp,#48]
49 stp x11,x12,[sp,#64]
50 stp x13,x14,[sp,#80]
51 stp x15,x16,[sp,#96]
52 stp x17,x18,[sp,#112]
53 stp q0,q1,[sp,#128]
54 stp q2,q3,[sp,#-480]!
55 stp q4,q5,[sp,#32]
56 stp q6,q7,[sp,#64]
57 stp q8,q9,[sp,#96]
58 stp q10,q11,[sp,#128]
59 stp q12,q13,[sp,#160]
60 stp q14,q15,[sp,#192]
61 stp q16,q17,[sp,#224]
62 stp q18,q19,[sp,#256]
63 stp q20,q21,[sp,#288]
64 stp q22,q23,[sp,#320]
65 stp q24,q25,[sp,#352]
66 stp q26,q27,[sp,#384]
67 stp q28,q29,[sp,#416]
68 stp q30,q31,[sp,#448]
69 bl __tls_get_new
70 mrs x1,tpidr_el0
71 ldp q4,q5,[sp,#32]
72 ldp q6,q7,[sp,#64]
73 ldp q8,q9,[sp,#96]
74 ldp q10,q11,[sp,#128]
75 ldp q12,q13,[sp,#160]
76 ldp q14,q15,[sp,#192]
77 ldp q16,q17,[sp,#224]
78 ldp q18,q19,[sp,#256]
79 ldp q20,q21,[sp,#288]
80 ldp q22,q23,[sp,#320]
81 ldp q24,q25,[sp,#352]
82 ldp q26,q27,[sp,#384]
83 ldp q28,q29,[sp,#416]
84 ldp q30,q31,[sp,#448]
85 ldp q2,q3,[sp],#480
86 ldp x5,x6,[sp,#16]
87 ldp x7,x8,[sp,#32]
88 ldp x9,x10,[sp,#48]
89 ldp x11,x12,[sp,#64]
90 ldp x13,x14,[sp,#80]
91 ldp x15,x16,[sp,#96]
92 ldp x17,x18,[sp,#112]
93 ldp q0,q1,[sp,#128]
94 ldp x29,x30,[sp],#160
95 b 2b
lib/libc/musl/src/ldso/arm/tlsdesc.S-19
......@@ -35,13 +35,9 @@ __tlsdesc_dynamic:
3535#endif
3636#endif
3737 ldr r3,[r0,#-4] // r3 = dtv
38 ldr ip,[r3] // ip = dtv slot count
39 cmp r1,ip
40 bhi 3f
4138 ldr ip,[r3,r1,LSL #2]
4239 sub r0,ip,r0
4340 add r0,r0,r2 // r0 = r3[r1]-r0+r2
444:
4541#if __ARM_ARCH >= 5
4642 pop {r2,r3,ip,pc}
4743#else
......@@ -49,21 +45,6 @@ __tlsdesc_dynamic:
4945 bx lr
5046#endif
5147
523:
53#if __ARM_PCS_VFP || !__SOFTFP__
54 .fpu vfp
55 vpush {d0-d7}
56#endif
57 push {r0-r3}
58 add r0,sp,#4
59 bl __tls_get_new
60 pop {r1-r3,ip}
61#if __ARM_PCS_VFP || !__SOFTFP__
62 vpop {d0-d7}
63#endif
64 sub r0,r0,r1 // r0 = retval-tp
65 b 4b
66
6748#if ((__ARM_ARCH_6K__ || __ARM_ARCH_6KZ__ || __ARM_ARCH_6ZK__) && !__thumb__) \
6849 || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ || __ARM_ARCH >= 7
6950#else
lib/libc/musl/src/ldso/dlerror.c+20-2
......@@ -3,6 +3,7 @@
33#include <stdarg.h>
44#include "pthread_impl.h"
55#include "dynlink.h"
6#include "lock.h"
67
78char *dlerror()
89{
......@@ -16,21 +17,38 @@ char *dlerror()
1617 return s;
1718}
1819
20static volatile int freebuf_queue_lock[1];
21static void **freebuf_queue;
22
1923void __dl_thread_cleanup(void)
2024{
2125 pthread_t self = __pthread_self();
22 if (self->dlerror_buf != (void *)-1)
23 free(self->dlerror_buf);
26 if (self->dlerror_buf && self->dlerror_buf != (void *)-1) {
27 LOCK(freebuf_queue_lock);
28 void **p = (void **)self->dlerror_buf;
29 *p = freebuf_queue;
30 freebuf_queue = p;
31 UNLOCK(freebuf_queue_lock);
32 }
2433}
2534
2635hidden void __dl_vseterr(const char *fmt, va_list ap)
2736{
37 LOCK(freebuf_queue_lock);
38 while (freebuf_queue) {
39 void **p = freebuf_queue;
40 freebuf_queue = *p;
41 free(p);
42 }
43 UNLOCK(freebuf_queue_lock);
44
2845 va_list ap2;
2946 va_copy(ap2, ap);
3047 pthread_t self = __pthread_self();
3148 if (self->dlerror_buf != (void *)-1)
3249 free(self->dlerror_buf);
3350 size_t len = vsnprintf(0, 0, fmt, ap2);
51 if (len < sizeof(void *)) len = sizeof(void *);
3452 va_end(ap2);
3553 char *buf = malloc(len+1);
3654 if (buf) {
lib/libc/musl/src/ldso/i386/tlsdesc.s+1-7
......@@ -17,15 +17,9 @@ __tlsdesc_dynamic:
1717 mov %gs:4,%edx
1818 push %ecx
1919 mov (%eax),%ecx
20 cmp %ecx,(%edx)
21 jc 1f
2220 mov 4(%eax),%eax
2321 add (%edx,%ecx,4),%eax
242: pop %ecx
22 pop %ecx
2523 sub %gs:0,%eax
2624 pop %edx
2725 ret
281: push %eax
29 call __tls_get_new
30 pop %ecx
31 jmp 2b
lib/libc/musl/src/ldso/powerpc/dlsym.s-1
......@@ -5,5 +5,4 @@
55dlsym:
66 mflr 5 # The return address is arg3.
77 b __dlsym
8 .end dlsym
98 .size dlsym, .-dlsym
lib/libc/musl/src/ldso/powerpc64/dlsym.s-1
......@@ -8,5 +8,4 @@ dlsym:
88 .localentry dlsym,.-dlsym
99 mflr 5 # The return address is arg3.
1010 b __dlsym
11 .end dlsym
1211 .size dlsym, .-dlsym
lib/libc/musl/src/ldso/riscv64/dlsym.s created+6
......@@ -0,0 +1,6 @@
1.global dlsym
2.hidden __dlsym
3.type dlsym, %function
4dlsym:
5 mv a2, ra
6 tail __dlsym
lib/libc/musl/src/ldso/x86_64/tlsdesc.s+1-20
......@@ -17,28 +17,9 @@ __tlsdesc_dynamic:
1717 mov %fs:8,%rdx
1818 push %rcx
1919 mov (%rax),%rcx
20 cmp %rcx,(%rdx)
21 jc 1f
2220 mov 8(%rax),%rax
2321 add (%rdx,%rcx,8),%rax
242: pop %rcx
22 pop %rcx
2523 sub %fs:0,%rax
2624 pop %rdx
2725 ret
281: push %rdi
29 push %rdi
30 push %rsi
31 push %r8
32 push %r9
33 push %r10
34 push %r11
35 mov %rax,%rdi
36 call __tls_get_new
37 pop %r11
38 pop %r10
39 pop %r9
40 pop %r8
41 pop %rsi
42 pop %rdi
43 pop %rdi
44 jmp 2b
lib/libc/musl/src/linux/cache.c+33
......@@ -1,4 +1,6 @@
1#include <errno.h>
12#include "syscall.h"
3#include "atomic.h"
24
35#ifdef SYS_cacheflush
46int _flush_cache(void *addr, int len, int op)
......@@ -15,3 +17,34 @@ int __cachectl(void *addr, int len, int op)
1517}
1618weak_alias(__cachectl, cachectl);
1719#endif
20
21#ifdef SYS_riscv_flush_icache
22
23#define VDSO_FLUSH_ICACHE_SYM "__vdso_flush_icache"
24#define VDSO_FLUSH_ICACHE_VER "LINUX_4.5"
25
26static void *volatile vdso_func;
27
28static int flush_icache_init(void *start, void *end, unsigned long int flags)
29{
30 void *p = __vdsosym(VDSO_FLUSH_ICACHE_VER, VDSO_FLUSH_ICACHE_SYM);
31 int (*f)(void *, void *, unsigned long int) =
32 (int (*)(void *, void *, unsigned long int))p;
33 a_cas_p(&vdso_func, (void *)flush_icache_init, p);
34 return f ? f(start, end, flags) : -ENOSYS;
35}
36
37static void *volatile vdso_func = (void *)flush_icache_init;
38
39int __riscv_flush_icache(void *start, void *end, unsigned long int flags)
40{
41 int (*f)(void *, void *, unsigned long int) =
42 (int (*)(void *, void *, unsigned long int))vdso_func;
43 if (f) {
44 int r = f(start, end, flags);
45 if (!r) return r;
46 if (r != -ENOSYS) return __syscall_ret(r);
47 }
48}
49weak_alias(__riscv_flush_icache, riscv_flush_icache);
50#endif
lib/libc/musl/src/linux/getdents.c+2
......@@ -1,9 +1,11 @@
11#define _BSD_SOURCE
22#include <dirent.h>
3#include <limits.h>
34#include "syscall.h"
45
56int getdents(int fd, struct dirent *buf, size_t len)
67{
8 if (len>INT_MAX) len = INT_MAX;
79 return syscall(SYS_getdents, fd, buf, len);
810}
911
lib/libc/musl/src/linux/membarrier.c created+77
......@@ -0,0 +1,77 @@
1#include <sys/membarrier.h>
2#include <semaphore.h>
3#include <signal.h>
4#include <string.h>
5#include "pthread_impl.h"
6#include "syscall.h"
7
8static void dummy_0(void)
9{
10}
11
12static void dummy_1(pthread_t t)
13{
14}
15
16weak_alias(dummy_0, __tl_lock);
17weak_alias(dummy_0, __tl_unlock);
18weak_alias(dummy_1, __tl_sync);
19
20static sem_t barrier_sem;
21
22static void bcast_barrier(int s)
23{
24 sem_post(&barrier_sem);
25}
26
27int __membarrier(int cmd, int flags)
28{
29 int r = __syscall(SYS_membarrier, cmd, flags);
30 /* Emulate the private expedited command, which is needed by the
31 * dynamic linker for installation of dynamic TLS, for older
32 * kernels that lack the syscall. Unlike the syscall, this only
33 * synchronizes with threads of the process, not other processes
34 * sharing the VM, but such sharing is not a supported usage
35 * anyway. */
36 if (r && cmd == MEMBARRIER_CMD_PRIVATE_EXPEDITED && !flags) {
37 pthread_t self=__pthread_self(), td;
38 sigset_t set;
39 __block_app_sigs(&set);
40 __tl_lock();
41 sem_init(&barrier_sem, 0, 0);
42 struct sigaction sa = {
43 .sa_flags = SA_RESTART,
44 .sa_handler = bcast_barrier
45 };
46 memset(&sa.sa_mask, -1, sizeof sa.sa_mask);
47 if (!__libc_sigaction(SIGSYNCCALL, &sa, 0)) {
48 for (td=self->next; td!=self; td=td->next)
49 __syscall(SYS_tkill, td->tid, SIGSYNCCALL);
50 for (td=self->next; td!=self; td=td->next)
51 sem_wait(&barrier_sem);
52 r = 0;
53 sa.sa_handler = SIG_IGN;
54 __libc_sigaction(SIGSYNCCALL, &sa, 0);
55 }
56 sem_destroy(&barrier_sem);
57 __tl_unlock();
58 __restore_sigs(&set);
59 }
60 return __syscall_ret(r);
61}
62
63void __membarrier_init(void)
64{
65 /* If membarrier is linked, attempt to pre-register to be able to use
66 * the private expedited command before the process becomes multi-
67 * threaded, since registering later has bad, potentially unbounded
68 * latency. This syscall should be essentially free, and it's arguably
69 * a mistake in the API design that registration was even required.
70 * For other commands, registration may impose some cost, so it's left
71 * to the application to do so if desired. Unfortunately this means
72 * library code initialized after the process becomes multi-threaded
73 * cannot use these features without accepting registration latency. */
74 __syscall(SYS_membarrier, MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED, 0);
75}
76
77weak_alias(__membarrier, membarrier);
lib/libc/musl/src/locale/dcngettext.c+3
......@@ -122,6 +122,7 @@ char *dcngettext(const char *domainname, const char *msgid1, const char *msgid2,
122122 const struct __locale_map *lm;
123123 size_t domlen;
124124 struct binding *q;
125 int old_errno = errno;
125126
126127 if ((unsigned)category >= LC_ALL) goto notrans;
127128
......@@ -138,6 +139,7 @@ char *dcngettext(const char *domainname, const char *msgid1, const char *msgid2,
138139 lm = loc->cat[category];
139140 if (!lm) {
140141notrans:
142 errno = old_errno;
141143 return (char *) ((n == 1) ? msgid1 : msgid2);
142144 }
143145
......@@ -250,6 +252,7 @@ notrans:
250252 trans += l+1;
251253 }
252254 }
255 errno = old_errno;
253256 return (char *)trans;
254257}
255258
lib/libc/musl/src/math/__math_divzero.c created+6
......@@ -0,0 +1,6 @@
1#include "libm.h"
2
3double __math_divzero(uint32_t sign)
4{
5 return fp_barrier(sign ? -1.0 : 1.0) / 0.0;
6}
lib/libc/musl/src/math/__math_divzerof.c created+6
......@@ -0,0 +1,6 @@
1#include "libm.h"
2
3float __math_divzerof(uint32_t sign)
4{
5 return fp_barrierf(sign ? -1.0f : 1.0f) / 0.0f;
6}
lib/libc/musl/src/math/__math_invalid.c created+6
......@@ -0,0 +1,6 @@
1#include "libm.h"
2
3double __math_invalid(double x)
4{
5 return (x - x) / (x - x);
6}
lib/libc/musl/src/math/__math_invalidf.c created+6
......@@ -0,0 +1,6 @@
1#include "libm.h"
2
3float __math_invalidf(float x)
4{
5 return (x - x) / (x - x);
6}
lib/libc/musl/src/math/__math_oflow.c created+6
......@@ -0,0 +1,6 @@
1#include "libm.h"
2
3double __math_oflow(uint32_t sign)
4{
5 return __math_xflow(sign, 0x1p769);
6}
lib/libc/musl/src/math/__math_oflowf.c created+6
......@@ -0,0 +1,6 @@
1#include "libm.h"
2
3float __math_oflowf(uint32_t sign)
4{
5 return __math_xflowf(sign, 0x1p97f);
6}
lib/libc/musl/src/math/__math_uflow.c created+6
......@@ -0,0 +1,6 @@
1#include "libm.h"
2
3double __math_uflow(uint32_t sign)
4{
5 return __math_xflow(sign, 0x1p-767);
6}
lib/libc/musl/src/math/__math_uflowf.c created+6
......@@ -0,0 +1,6 @@
1#include "libm.h"
2
3float __math_uflowf(uint32_t sign)
4{
5 return __math_xflowf(sign, 0x1p-95f);
6}
lib/libc/musl/src/math/__math_xflow.c created+6
......@@ -0,0 +1,6 @@
1#include "libm.h"
2
3double __math_xflow(uint32_t sign, double y)
4{
5 return eval_as_double(fp_barrier(sign ? -y : y) * y);
6}
lib/libc/musl/src/math/__math_xflowf.c created+6
......@@ -0,0 +1,6 @@
1#include "libm.h"
2
3float __math_xflowf(uint32_t sign, float y)
4{
5 return eval_as_float(fp_barrierf(sign ? -y : y) * y);
6}
lib/libc/musl/src/math/atanl.c+3-3
......@@ -70,21 +70,21 @@ static long double T_odd(long double x)
7070#elif LDBL_MANT_DIG == 113
7171#define EXPMAN(u) ((u.i.se & 0x7fff)<<8 | u.i.top>>8)
7272
73const long double atanhi[] = {
73static const long double atanhi[] = {
7474 4.63647609000806116214256231461214397e-01L,
7575 7.85398163397448309615660845819875699e-01L,
7676 9.82793723247329067985710611014666038e-01L,
7777 1.57079632679489661923132169163975140e+00L,
7878};
7979
80const long double atanlo[] = {
80static const long double atanlo[] = {
8181 4.89509642257333492668618435220297706e-36L,
8282 2.16795253253094525619926100651083806e-35L,
8383 -2.31288434538183565909319952098066272e-35L,
8484 4.33590506506189051239852201302167613e-35L,
8585};
8686
87const long double aT[] = {
87static const long double aT[] = {
8888 3.33333333333333333333333333333333125e-01L,
8989 -1.99999999999999999999999999999180430e-01L,
9090 1.42857142857142857142857142125269827e-01L,
lib/libc/musl/src/math/exp.c+120-120
......@@ -1,134 +1,134 @@
1/* origin: FreeBSD /usr/src/lib/msun/src/e_exp.c */
21/*
3 * ====================================================
4 * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
2 * Double-precision e^x function.
53 *
6 * Permission to use, copy, modify, and distribute this
7 * software is freely granted, provided that this notice
8 * is preserved.
9 * ====================================================
10 */
11/* exp(x)
12 * Returns the exponential of x.
13 *
14 * Method
15 * 1. Argument reduction:
16 * Reduce x to an r so that |r| <= 0.5*ln2 ~ 0.34658.
17 * Given x, find r and integer k such that
18 *
19 * x = k*ln2 + r, |r| <= 0.5*ln2.
20 *
21 * Here r will be represented as r = hi-lo for better
22 * accuracy.
23 *
24 * 2. Approximation of exp(r) by a special rational function on
25 * the interval [0,0.34658]:
26 * Write
27 * R(r**2) = r*(exp(r)+1)/(exp(r)-1) = 2 + r*r/6 - r**4/360 + ...
28 * We use a special Remez algorithm on [0,0.34658] to generate
29 * a polynomial of degree 5 to approximate R. The maximum error
30 * of this polynomial approximation is bounded by 2**-59. In
31 * other words,
32 * R(z) ~ 2.0 + P1*z + P2*z**2 + P3*z**3 + P4*z**4 + P5*z**5
33 * (where z=r*r, and the values of P1 to P5 are listed below)
34 * and
35 * | 5 | -59
36 * | 2.0+P1*z+...+P5*z - R(z) | <= 2
37 * | |
38 * The computation of exp(r) thus becomes
39 * 2*r
40 * exp(r) = 1 + ----------
41 * R(r) - r
42 * r*c(r)
43 * = 1 + r + ----------- (for better accuracy)
44 * 2 - c(r)
45 * where
46 * 2 4 10
47 * c(r) = r - (P1*r + P2*r + ... + P5*r ).
48 *
49 * 3. Scale back to obtain exp(x):
50 * From step 1, we have
51 * exp(x) = 2^k * exp(r)
52 *
53 * Special cases:
54 * exp(INF) is INF, exp(NaN) is NaN;
55 * exp(-INF) is 0, and
56 * for finite argument, only exp(0)=1 is exact.
57 *
58 * Accuracy:
59 * according to an error analysis, the error is always less than
60 * 1 ulp (unit in the last place).
61 *
62 * Misc. info.
63 * For IEEE double
64 * if x > 709.782712893383973096 then exp(x) overflows
65 * if x < -745.133219101941108420 then exp(x) underflows
4 * Copyright (c) 2018, Arm Limited.
5 * SPDX-License-Identifier: MIT
666 */
677
8#include <math.h>
9#include <stdint.h>
6810#include "libm.h"
11#include "exp_data.h"
6912
70static const double
71half[2] = {0.5,-0.5},
72ln2hi = 6.93147180369123816490e-01, /* 0x3fe62e42, 0xfee00000 */
73ln2lo = 1.90821492927058770002e-10, /* 0x3dea39ef, 0x35793c76 */
74invln2 = 1.44269504088896338700e+00, /* 0x3ff71547, 0x652b82fe */
75P1 = 1.66666666666666019037e-01, /* 0x3FC55555, 0x5555553E */
76P2 = -2.77777777770155933842e-03, /* 0xBF66C16C, 0x16BEBD93 */
77P3 = 6.61375632143793436117e-05, /* 0x3F11566A, 0xAF25DE2C */
78P4 = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */
79P5 = 4.13813679705723846039e-08; /* 0x3E663769, 0x72BEA4D0 */
13#define N (1 << EXP_TABLE_BITS)
14#define InvLn2N __exp_data.invln2N
15#define NegLn2hiN __exp_data.negln2hiN
16#define NegLn2loN __exp_data.negln2loN
17#define Shift __exp_data.shift
18#define T __exp_data.tab
19#define C2 __exp_data.poly[5 - EXP_POLY_ORDER]
20#define C3 __exp_data.poly[6 - EXP_POLY_ORDER]
21#define C4 __exp_data.poly[7 - EXP_POLY_ORDER]
22#define C5 __exp_data.poly[8 - EXP_POLY_ORDER]
8023
81double exp(double x)
24/* Handle cases that may overflow or underflow when computing the result that
25 is scale*(1+TMP) without intermediate rounding. The bit representation of
26 scale is in SBITS, however it has a computed exponent that may have
27 overflown into the sign bit so that needs to be adjusted before using it as
28 a double. (int32_t)KI is the k used in the argument reduction and exponent
29 adjustment of scale, positive k here means the result may overflow and
30 negative k means the result may underflow. */
31static inline double specialcase(double_t tmp, uint64_t sbits, uint64_t ki)
8232{
83 double_t hi, lo, c, xx, y;
84 int k, sign;
85 uint32_t hx;
86
87 GET_HIGH_WORD(hx, x);
88 sign = hx>>31;
89 hx &= 0x7fffffff; /* high word of |x| */
33 double_t scale, y;
9034
91 /* special cases */
92 if (hx >= 0x4086232b) { /* if |x| >= 708.39... */
93 if (isnan(x))
94 return x;
95 if (x > 709.782712893383973096) {
96 /* overflow if x!=inf */
97 x *= 0x1p1023;
98 return x;
99 }
100 if (x < -708.39641853226410622) {
101 /* underflow if x!=-inf */
102 FORCE_EVAL((float)(-0x1p-149/x));
103 if (x < -745.13321910194110842)
104 return 0;
105 }
35 if ((ki & 0x80000000) == 0) {
36 /* k > 0, the exponent of scale might have overflowed by <= 460. */
37 sbits -= 1009ull << 52;
38 scale = asdouble(sbits);
39 y = 0x1p1009 * (scale + scale * tmp);
40 return eval_as_double(y);
41 }
42 /* k < 0, need special care in the subnormal range. */
43 sbits += 1022ull << 52;
44 scale = asdouble(sbits);
45 y = scale + scale * tmp;
46 if (y < 1.0) {
47 /* Round y to the right precision before scaling it into the subnormal
48 range to avoid double rounding that can cause 0.5+E/2 ulp error where
49 E is the worst-case ulp error outside the subnormal range. So this
50 is only useful if the goal is better than 1 ulp worst-case error. */
51 double_t hi, lo;
52 lo = scale - y + scale * tmp;
53 hi = 1.0 + y;
54 lo = 1.0 - hi + y + lo;
55 y = eval_as_double(hi + lo) - 1.0;
56 /* Avoid -0.0 with downward rounding. */
57 if (WANT_ROUNDING && y == 0.0)
58 y = 0.0;
59 /* The underflow exception needs to be signaled explicitly. */
60 fp_force_eval(fp_barrier(0x1p-1022) * 0x1p-1022);
10661 }
62 y = 0x1p-1022 * y;
63 return eval_as_double(y);
64}
10765
108 /* argument reduction */
109 if (hx > 0x3fd62e42) { /* if |x| > 0.5 ln2 */
110 if (hx >= 0x3ff0a2b2) /* if |x| >= 1.5 ln2 */
111 k = (int)(invln2*x + half[sign]);
112 else
113 k = 1 - sign - sign;
114 hi = x - k*ln2hi; /* k*ln2hi is exact here */
115 lo = k*ln2lo;
116 x = hi - lo;
117 } else if (hx > 0x3e300000) { /* if |x| > 2**-28 */
118 k = 0;
119 hi = x;
120 lo = 0;
121 } else {
122 /* inexact if x!=0 */
123 FORCE_EVAL(0x1p1023 + x);
124 return 1 + x;
66/* Top 12 bits of a double (sign and exponent bits). */
67static inline uint32_t top12(double x)
68{
69 return asuint64(x) >> 52;
70}
71
72double exp(double x)
73{
74 uint32_t abstop;
75 uint64_t ki, idx, top, sbits;
76 double_t kd, z, r, r2, scale, tail, tmp;
77
78 abstop = top12(x) & 0x7ff;
79 if (predict_false(abstop - top12(0x1p-54) >= top12(512.0) - top12(0x1p-54))) {
80 if (abstop - top12(0x1p-54) >= 0x80000000)
81 /* Avoid spurious underflow for tiny x. */
82 /* Note: 0 is common input. */
83 return WANT_ROUNDING ? 1.0 + x : 1.0;
84 if (abstop >= top12(1024.0)) {
85 if (asuint64(x) == asuint64(-INFINITY))
86 return 0.0;
87 if (abstop >= top12(INFINITY))
88 return 1.0 + x;
89 if (asuint64(x) >> 63)
90 return __math_uflow(0);
91 else
92 return __math_oflow(0);
93 }
94 /* Large x is special cased below. */
95 abstop = 0;
12596 }
12697
127 /* x is now in primary range */
128 xx = x*x;
129 c = x - xx*(P1+xx*(P2+xx*(P3+xx*(P4+xx*P5))));
130 y = 1 + (x*c/(2-c) - lo + hi);
131 if (k == 0)
132 return y;
133 return scalbn(y, k);
98 /* exp(x) = 2^(k/N) * exp(r), with exp(r) in [2^(-1/2N),2^(1/2N)]. */
99 /* x = ln2/N*k + r, with int k and r in [-ln2/2N, ln2/2N]. */
100 z = InvLn2N * x;
101#if TOINT_INTRINSICS
102 kd = roundtoint(z);
103 ki = converttoint(z);
104#elif EXP_USE_TOINT_NARROW
105 /* z - kd is in [-0.5-2^-16, 0.5] in all rounding modes. */
106 kd = eval_as_double(z + Shift);
107 ki = asuint64(kd) >> 16;
108 kd = (double_t)(int32_t)ki;
109#else
110 /* z - kd is in [-1, 1] in non-nearest rounding modes. */
111 kd = eval_as_double(z + Shift);
112 ki = asuint64(kd);
113 kd -= Shift;
114#endif
115 r = x + kd * NegLn2hiN + kd * NegLn2loN;
116 /* 2^(k/N) ~= scale * (1 + tail). */
117 idx = 2 * (ki % N);
118 top = ki << (52 - EXP_TABLE_BITS);
119 tail = asdouble(T[idx]);
120 /* This is only a valid scale when -1023*N < k < 1024*N. */
121 sbits = T[idx + 1] + top;
122 /* exp(x) = 2^(k/N) * exp(r) ~= scale + scale * (tail + exp(r) - 1). */
123 /* Evaluation is optimized assuming superscalar pipelined execution. */
124 r2 = r * r;
125 /* Without fma the worst case error is 0.25/N ulp larger. */
126 /* Worst case error is less than 0.5+1.11/N+(abs poly error * 2^53) ulp. */
127 tmp = tail + r + r2 * (C2 + r * C3) + r2 * r2 * (C4 + r * C5);
128 if (predict_false(abstop == 0))
129 return specialcase(tmp, sbits, ki);
130 scale = asdouble(sbits);
131 /* Note: tmp == 0 or |tmp| > 2^-200 and scale > 2^-739, so there
132 is no spurious underflow here even without fma. */
133 return eval_as_double(scale + scale * tmp);
134134}
lib/libc/musl/src/math/exp2.c+106-360
......@@ -1,375 +1,121 @@
1/* origin: FreeBSD /usr/src/lib/msun/src/s_exp2.c */
2/*-
3 * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
1/*
2 * Double-precision 2^x function.
143 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
4 * Copyright (c) 2018, Arm Limited.
5 * SPDX-License-Identifier: MIT
266 */
277
8#include <math.h>
9#include <stdint.h>
2810#include "libm.h"
11#include "exp_data.h"
2912
30#define TBLSIZE 256
13#define N (1 << EXP_TABLE_BITS)
14#define Shift __exp_data.exp2_shift
15#define T __exp_data.tab
16#define C1 __exp_data.exp2_poly[0]
17#define C2 __exp_data.exp2_poly[1]
18#define C3 __exp_data.exp2_poly[2]
19#define C4 __exp_data.exp2_poly[3]
20#define C5 __exp_data.exp2_poly[4]
3121
32static const double
33redux = 0x1.8p52 / TBLSIZE,
34P1 = 0x1.62e42fefa39efp-1,
35P2 = 0x1.ebfbdff82c575p-3,
36P3 = 0x1.c6b08d704a0a6p-5,
37P4 = 0x1.3b2ab88f70400p-7,
38P5 = 0x1.5d88003875c74p-10;
22/* Handle cases that may overflow or underflow when computing the result that
23 is scale*(1+TMP) without intermediate rounding. The bit representation of
24 scale is in SBITS, however it has a computed exponent that may have
25 overflown into the sign bit so that needs to be adjusted before using it as
26 a double. (int32_t)KI is the k used in the argument reduction and exponent
27 adjustment of scale, positive k here means the result may overflow and
28 negative k means the result may underflow. */
29static inline double specialcase(double_t tmp, uint64_t sbits, uint64_t ki)
30{
31 double_t scale, y;
3932
40static const double tbl[TBLSIZE * 2] = {
41/* exp2(z + eps) eps */
42 0x1.6a09e667f3d5dp-1, 0x1.9880p-44,
43 0x1.6b052fa751744p-1, 0x1.8000p-50,
44 0x1.6c012750bd9fep-1, -0x1.8780p-45,
45 0x1.6cfdcddd476bfp-1, 0x1.ec00p-46,
46 0x1.6dfb23c651a29p-1, -0x1.8000p-50,
47 0x1.6ef9298593ae3p-1, -0x1.c000p-52,
48 0x1.6ff7df9519386p-1, -0x1.fd80p-45,
49 0x1.70f7466f42da3p-1, -0x1.c880p-45,
50 0x1.71f75e8ec5fc3p-1, 0x1.3c00p-46,
51 0x1.72f8286eacf05p-1, -0x1.8300p-44,
52 0x1.73f9a48a58152p-1, -0x1.0c00p-47,
53 0x1.74fbd35d7ccfcp-1, 0x1.f880p-45,
54 0x1.75feb564267f1p-1, 0x1.3e00p-47,
55 0x1.77024b1ab6d48p-1, -0x1.7d00p-45,
56 0x1.780694fde5d38p-1, -0x1.d000p-50,
57 0x1.790b938ac1d00p-1, 0x1.3000p-49,
58 0x1.7a11473eb0178p-1, -0x1.d000p-49,
59 0x1.7b17b0976d060p-1, 0x1.0400p-45,
60 0x1.7c1ed0130c133p-1, 0x1.0000p-53,
61 0x1.7d26a62ff8636p-1, -0x1.6900p-45,
62 0x1.7e2f336cf4e3bp-1, -0x1.2e00p-47,
63 0x1.7f3878491c3e8p-1, -0x1.4580p-45,
64 0x1.80427543e1b4ep-1, 0x1.3000p-44,
65 0x1.814d2add1071ap-1, 0x1.f000p-47,
66 0x1.82589994ccd7ep-1, -0x1.1c00p-45,
67 0x1.8364c1eb942d0p-1, 0x1.9d00p-45,
68 0x1.8471a4623cab5p-1, 0x1.7100p-43,
69 0x1.857f4179f5bbcp-1, 0x1.2600p-45,
70 0x1.868d99b4491afp-1, -0x1.2c40p-44,
71 0x1.879cad931a395p-1, -0x1.3000p-45,
72 0x1.88ac7d98a65b8p-1, -0x1.a800p-45,
73 0x1.89bd0a4785800p-1, -0x1.d000p-49,
74 0x1.8ace5422aa223p-1, 0x1.3280p-44,
75 0x1.8be05bad619fap-1, 0x1.2b40p-43,
76 0x1.8cf3216b54383p-1, -0x1.ed00p-45,
77 0x1.8e06a5e08664cp-1, -0x1.0500p-45,
78 0x1.8f1ae99157807p-1, 0x1.8280p-45,
79 0x1.902fed0282c0ep-1, -0x1.cb00p-46,
80 0x1.9145b0b91ff96p-1, -0x1.5e00p-47,
81 0x1.925c353aa2ff9p-1, 0x1.5400p-48,
82 0x1.93737b0cdc64ap-1, 0x1.7200p-46,
83 0x1.948b82b5f98aep-1, -0x1.9000p-47,
84 0x1.95a44cbc852cbp-1, 0x1.5680p-45,
85 0x1.96bdd9a766f21p-1, -0x1.6d00p-44,
86 0x1.97d829fde4e2ap-1, -0x1.1000p-47,
87 0x1.98f33e47a23a3p-1, 0x1.d000p-45,
88 0x1.9a0f170ca0604p-1, -0x1.8a40p-44,
89 0x1.9b2bb4d53ff89p-1, 0x1.55c0p-44,
90 0x1.9c49182a3f15bp-1, 0x1.6b80p-45,
91 0x1.9d674194bb8c5p-1, -0x1.c000p-49,
92 0x1.9e86319e3238ep-1, 0x1.7d00p-46,
93 0x1.9fa5e8d07f302p-1, 0x1.6400p-46,
94 0x1.a0c667b5de54dp-1, -0x1.5000p-48,
95 0x1.a1e7aed8eb8f6p-1, 0x1.9e00p-47,
96 0x1.a309bec4a2e27p-1, 0x1.ad80p-45,
97 0x1.a42c980460a5dp-1, -0x1.af00p-46,
98 0x1.a5503b23e259bp-1, 0x1.b600p-47,
99 0x1.a674a8af46213p-1, 0x1.8880p-44,
100 0x1.a799e1330b3a7p-1, 0x1.1200p-46,
101 0x1.a8bfe53c12e8dp-1, 0x1.6c00p-47,
102 0x1.a9e6b5579fcd2p-1, -0x1.9b80p-45,
103 0x1.ab0e521356fb8p-1, 0x1.b700p-45,
104 0x1.ac36bbfd3f381p-1, 0x1.9000p-50,
105 0x1.ad5ff3a3c2780p-1, 0x1.4000p-49,
106 0x1.ae89f995ad2a3p-1, -0x1.c900p-45,
107 0x1.afb4ce622f367p-1, 0x1.6500p-46,
108 0x1.b0e07298db790p-1, 0x1.fd40p-45,
109 0x1.b20ce6c9a89a9p-1, 0x1.2700p-46,
110 0x1.b33a2b84f1a4bp-1, 0x1.d470p-43,
111 0x1.b468415b747e7p-1, -0x1.8380p-44,
112 0x1.b59728de5593ap-1, 0x1.8000p-54,
113 0x1.b6c6e29f1c56ap-1, 0x1.ad00p-47,
114 0x1.b7f76f2fb5e50p-1, 0x1.e800p-50,
115 0x1.b928cf22749b2p-1, -0x1.4c00p-47,
116 0x1.ba5b030a10603p-1, -0x1.d700p-47,
117 0x1.bb8e0b79a6f66p-1, 0x1.d900p-47,
118 0x1.bcc1e904bc1ffp-1, 0x1.2a00p-47,
119 0x1.bdf69c3f3a16fp-1, -0x1.f780p-46,
120 0x1.bf2c25bd71db8p-1, -0x1.0a00p-46,
121 0x1.c06286141b2e9p-1, -0x1.1400p-46,
122 0x1.c199bdd8552e0p-1, 0x1.be00p-47,
123 0x1.c2d1cd9fa64eep-1, -0x1.9400p-47,
124 0x1.c40ab5fffd02fp-1, -0x1.ed00p-47,
125 0x1.c544778fafd15p-1, 0x1.9660p-44,
126 0x1.c67f12e57d0cbp-1, -0x1.a100p-46,
127 0x1.c7ba88988c1b6p-1, -0x1.8458p-42,
128 0x1.c8f6d9406e733p-1, -0x1.a480p-46,
129 0x1.ca3405751c4dfp-1, 0x1.b000p-51,
130 0x1.cb720dcef9094p-1, 0x1.1400p-47,
131 0x1.ccb0f2e6d1689p-1, 0x1.0200p-48,
132 0x1.cdf0b555dc412p-1, 0x1.3600p-48,
133 0x1.cf3155b5bab3bp-1, -0x1.6900p-47,
134 0x1.d072d4a0789bcp-1, 0x1.9a00p-47,
135 0x1.d1b532b08c8fap-1, -0x1.5e00p-46,
136 0x1.d2f87080d8a85p-1, 0x1.d280p-46,
137 0x1.d43c8eacaa203p-1, 0x1.1a00p-47,
138 0x1.d5818dcfba491p-1, 0x1.f000p-50,
139 0x1.d6c76e862e6a1p-1, -0x1.3a00p-47,
140 0x1.d80e316c9834ep-1, -0x1.cd80p-47,
141 0x1.d955d71ff6090p-1, 0x1.4c00p-48,
142 0x1.da9e603db32aep-1, 0x1.f900p-48,
143 0x1.dbe7cd63a8325p-1, 0x1.9800p-49,
144 0x1.dd321f301b445p-1, -0x1.5200p-48,
145 0x1.de7d5641c05bfp-1, -0x1.d700p-46,
146 0x1.dfc97337b9aecp-1, -0x1.6140p-46,
147 0x1.e11676b197d5ep-1, 0x1.b480p-47,
148 0x1.e264614f5a3e7p-1, 0x1.0ce0p-43,
149 0x1.e3b333b16ee5cp-1, 0x1.c680p-47,
150 0x1.e502ee78b3fb4p-1, -0x1.9300p-47,
151 0x1.e653924676d68p-1, -0x1.5000p-49,
152 0x1.e7a51fbc74c44p-1, -0x1.7f80p-47,
153 0x1.e8f7977cdb726p-1, -0x1.3700p-48,
154 0x1.ea4afa2a490e8p-1, 0x1.5d00p-49,
155 0x1.eb9f4867ccae4p-1, 0x1.61a0p-46,
156 0x1.ecf482d8e680dp-1, 0x1.5500p-48,
157 0x1.ee4aaa2188514p-1, 0x1.6400p-51,
158 0x1.efa1bee615a13p-1, -0x1.e800p-49,
159 0x1.f0f9c1cb64106p-1, -0x1.a880p-48,
160 0x1.f252b376bb963p-1, -0x1.c900p-45,
161 0x1.f3ac948dd7275p-1, 0x1.a000p-53,
162 0x1.f50765b6e4524p-1, -0x1.4f00p-48,
163 0x1.f6632798844fdp-1, 0x1.a800p-51,
164 0x1.f7bfdad9cbe38p-1, 0x1.abc0p-48,
165 0x1.f91d802243c82p-1, -0x1.4600p-50,
166 0x1.fa7c1819e908ep-1, -0x1.b0c0p-47,
167 0x1.fbdba3692d511p-1, -0x1.0e00p-51,
168 0x1.fd3c22b8f7194p-1, -0x1.0de8p-46,
169 0x1.fe9d96b2a23eep-1, 0x1.e430p-49,
170 0x1.0000000000000p+0, 0x0.0000p+0,
171 0x1.00b1afa5abcbep+0, -0x1.3400p-52,
172 0x1.0163da9fb3303p+0, -0x1.2170p-46,
173 0x1.02168143b0282p+0, 0x1.a400p-52,
174 0x1.02c9a3e77806cp+0, 0x1.f980p-49,
175 0x1.037d42e11bbcap+0, -0x1.7400p-51,
176 0x1.04315e86e7f89p+0, 0x1.8300p-50,
177 0x1.04e5f72f65467p+0, -0x1.a3f0p-46,
178 0x1.059b0d315855ap+0, -0x1.2840p-47,
179 0x1.0650a0e3c1f95p+0, 0x1.1600p-48,
180 0x1.0706b29ddf71ap+0, 0x1.5240p-46,
181 0x1.07bd42b72a82dp+0, -0x1.9a00p-49,
182 0x1.0874518759bd0p+0, 0x1.6400p-49,
183 0x1.092bdf66607c8p+0, -0x1.0780p-47,
184 0x1.09e3ecac6f383p+0, -0x1.8000p-54,
185 0x1.0a9c79b1f3930p+0, 0x1.fa00p-48,
186 0x1.0b5586cf988fcp+0, -0x1.ac80p-48,
187 0x1.0c0f145e46c8ap+0, 0x1.9c00p-50,
188 0x1.0cc922b724816p+0, 0x1.5200p-47,
189 0x1.0d83b23395dd8p+0, -0x1.ad00p-48,
190 0x1.0e3ec32d3d1f3p+0, 0x1.bac0p-46,
191 0x1.0efa55fdfa9a6p+0, -0x1.4e80p-47,
192 0x1.0fb66affed2f0p+0, -0x1.d300p-47,
193 0x1.1073028d7234bp+0, 0x1.1500p-48,
194 0x1.11301d0125b5bp+0, 0x1.c000p-49,
195 0x1.11edbab5e2af9p+0, 0x1.6bc0p-46,
196 0x1.12abdc06c31d5p+0, 0x1.8400p-49,
197 0x1.136a814f2047dp+0, -0x1.ed00p-47,
198 0x1.1429aaea92de9p+0, 0x1.8e00p-49,
199 0x1.14e95934f3138p+0, 0x1.b400p-49,
200 0x1.15a98c8a58e71p+0, 0x1.5300p-47,
201 0x1.166a45471c3dfp+0, 0x1.3380p-47,
202 0x1.172b83c7d5211p+0, 0x1.8d40p-45,
203 0x1.17ed48695bb9fp+0, -0x1.5d00p-47,
204 0x1.18af9388c8d93p+0, -0x1.c880p-46,
205 0x1.1972658375d66p+0, 0x1.1f00p-46,
206 0x1.1a35beb6fcba7p+0, 0x1.0480p-46,
207 0x1.1af99f81387e3p+0, -0x1.7390p-43,
208 0x1.1bbe084045d54p+0, 0x1.4e40p-45,
209 0x1.1c82f95281c43p+0, -0x1.a200p-47,
210 0x1.1d4873168b9b2p+0, 0x1.3800p-49,
211 0x1.1e0e75eb44031p+0, 0x1.ac00p-49,
212 0x1.1ed5022fcd938p+0, 0x1.1900p-47,
213 0x1.1f9c18438cdf7p+0, -0x1.b780p-46,
214 0x1.2063b88628d8fp+0, 0x1.d940p-45,
215 0x1.212be3578a81ep+0, 0x1.8000p-50,
216 0x1.21f49917ddd41p+0, 0x1.b340p-45,
217 0x1.22bdda2791323p+0, 0x1.9f80p-46,
218 0x1.2387a6e7561e7p+0, -0x1.9c80p-46,
219 0x1.2451ffb821427p+0, 0x1.2300p-47,
220 0x1.251ce4fb2a602p+0, -0x1.3480p-46,
221 0x1.25e85711eceb0p+0, 0x1.2700p-46,
222 0x1.26b4565e27d16p+0, 0x1.1d00p-46,
223 0x1.2780e341de00fp+0, 0x1.1ee0p-44,
224 0x1.284dfe1f5633ep+0, -0x1.4c00p-46,
225 0x1.291ba7591bb30p+0, -0x1.3d80p-46,
226 0x1.29e9df51fdf09p+0, 0x1.8b00p-47,
227 0x1.2ab8a66d10e9bp+0, -0x1.27c0p-45,
228 0x1.2b87fd0dada3ap+0, 0x1.a340p-45,
229 0x1.2c57e39771af9p+0, -0x1.0800p-46,
230 0x1.2d285a6e402d9p+0, -0x1.ed00p-47,
231 0x1.2df961f641579p+0, -0x1.4200p-48,
232 0x1.2ecafa93e2ecfp+0, -0x1.4980p-45,
233 0x1.2f9d24abd8822p+0, -0x1.6300p-46,
234 0x1.306fe0a31b625p+0, -0x1.2360p-44,
235 0x1.31432edeea50bp+0, -0x1.0df8p-40,
236 0x1.32170fc4cd7b8p+0, -0x1.2480p-45,
237 0x1.32eb83ba8e9a2p+0, -0x1.5980p-45,
238 0x1.33c08b2641766p+0, 0x1.ed00p-46,
239 0x1.3496266e3fa27p+0, -0x1.c000p-50,
240 0x1.356c55f929f0fp+0, -0x1.0d80p-44,
241 0x1.36431a2de88b9p+0, 0x1.2c80p-45,
242 0x1.371a7373aaa39p+0, 0x1.0600p-45,
243 0x1.37f26231e74fep+0, -0x1.6600p-46,
244 0x1.38cae6d05d838p+0, -0x1.ae00p-47,
245 0x1.39a401b713ec3p+0, -0x1.4720p-43,
246 0x1.3a7db34e5a020p+0, 0x1.8200p-47,
247 0x1.3b57fbfec6e95p+0, 0x1.e800p-44,
248 0x1.3c32dc313a8f2p+0, 0x1.f800p-49,
249 0x1.3d0e544ede122p+0, -0x1.7a00p-46,
250 0x1.3dea64c1234bbp+0, 0x1.6300p-45,
251 0x1.3ec70df1c4eccp+0, -0x1.8a60p-43,
252 0x1.3fa4504ac7e8cp+0, -0x1.cdc0p-44,
253 0x1.40822c367a0bbp+0, 0x1.5b80p-45,
254 0x1.4160a21f72e95p+0, 0x1.ec00p-46,
255 0x1.423fb27094646p+0, -0x1.3600p-46,
256 0x1.431f5d950a920p+0, 0x1.3980p-45,
257 0x1.43ffa3f84b9ebp+0, 0x1.a000p-48,
258 0x1.44e0860618919p+0, -0x1.6c00p-48,
259 0x1.45c2042a7d201p+0, -0x1.bc00p-47,
260 0x1.46a41ed1d0016p+0, -0x1.2800p-46,
261 0x1.4786d668b3326p+0, 0x1.0e00p-44,
262 0x1.486a2b5c13c00p+0, -0x1.d400p-45,
263 0x1.494e1e192af04p+0, 0x1.c200p-47,
264 0x1.4a32af0d7d372p+0, -0x1.e500p-46,
265 0x1.4b17dea6db801p+0, 0x1.7800p-47,
266 0x1.4bfdad53629e1p+0, -0x1.3800p-46,
267 0x1.4ce41b817c132p+0, 0x1.0800p-47,
268 0x1.4dcb299fddddbp+0, 0x1.c700p-45,
269 0x1.4eb2d81d8ab96p+0, -0x1.ce00p-46,
270 0x1.4f9b2769d2d02p+0, 0x1.9200p-46,
271 0x1.508417f4531c1p+0, -0x1.8c00p-47,
272 0x1.516daa2cf662ap+0, -0x1.a000p-48,
273 0x1.5257de83f51eap+0, 0x1.a080p-43,
274 0x1.5342b569d4edap+0, -0x1.6d80p-45,
275 0x1.542e2f4f6ac1ap+0, -0x1.2440p-44,
276 0x1.551a4ca5d94dbp+0, 0x1.83c0p-43,
277 0x1.56070dde9116bp+0, 0x1.4b00p-45,
278 0x1.56f4736b529dep+0, 0x1.15a0p-43,
279 0x1.57e27dbe2c40ep+0, -0x1.9e00p-45,
280 0x1.58d12d497c76fp+0, -0x1.3080p-45,
281 0x1.59c0827ff0b4cp+0, 0x1.dec0p-43,
282 0x1.5ab07dd485427p+0, -0x1.4000p-51,
283 0x1.5ba11fba87af4p+0, 0x1.0080p-44,
284 0x1.5c9268a59460bp+0, -0x1.6c80p-45,
285 0x1.5d84590998e3fp+0, 0x1.69a0p-43,
286 0x1.5e76f15ad20e1p+0, -0x1.b400p-46,
287 0x1.5f6a320dcebcap+0, 0x1.7700p-46,
288 0x1.605e1b976dcb8p+0, 0x1.6f80p-45,
289 0x1.6152ae6cdf715p+0, 0x1.1000p-47,
290 0x1.6247eb03a5531p+0, -0x1.5d00p-46,
291 0x1.633dd1d1929b5p+0, -0x1.2d00p-46,
292 0x1.6434634ccc313p+0, -0x1.a800p-49,
293 0x1.652b9febc8efap+0, -0x1.8600p-45,
294 0x1.6623882553397p+0, 0x1.1fe0p-40,
295 0x1.671c1c708328ep+0, -0x1.7200p-44,
296 0x1.68155d44ca97ep+0, 0x1.6800p-49,
297 0x1.690f4b19e9471p+0, -0x1.9780p-45,
298};
33 if ((ki & 0x80000000) == 0) {
34 /* k > 0, the exponent of scale might have overflowed by 1. */
35 sbits -= 1ull << 52;
36 scale = asdouble(sbits);
37 y = 2 * (scale + scale * tmp);
38 return eval_as_double(y);
39 }
40 /* k < 0, need special care in the subnormal range. */
41 sbits += 1022ull << 52;
42 scale = asdouble(sbits);
43 y = scale + scale * tmp;
44 if (y < 1.0) {
45 /* Round y to the right precision before scaling it into the subnormal
46 range to avoid double rounding that can cause 0.5+E/2 ulp error where
47 E is the worst-case ulp error outside the subnormal range. So this
48 is only useful if the goal is better than 1 ulp worst-case error. */
49 double_t hi, lo;
50 lo = scale - y + scale * tmp;
51 hi = 1.0 + y;
52 lo = 1.0 - hi + y + lo;
53 y = eval_as_double(hi + lo) - 1.0;
54 /* Avoid -0.0 with downward rounding. */
55 if (WANT_ROUNDING && y == 0.0)
56 y = 0.0;
57 /* The underflow exception needs to be signaled explicitly. */
58 fp_force_eval(fp_barrier(0x1p-1022) * 0x1p-1022);
59 }
60 y = 0x1p-1022 * y;
61 return eval_as_double(y);
62}
63
64/* Top 12 bits of a double (sign and exponent bits). */
65static inline uint32_t top12(double x)
66{
67 return asuint64(x) >> 52;
68}
29969
300/*
301 * exp2(x): compute the base 2 exponential of x
302 *
303 * Accuracy: Peak error < 0.503 ulp for normalized results.
304 *
305 * Method: (accurate tables)
306 *
307 * Reduce x:
308 * x = k + y, for integer k and |y| <= 1/2.
309 * Thus we have exp2(x) = 2**k * exp2(y).
310 *
311 * Reduce y:
312 * y = i/TBLSIZE + z - eps[i] for integer i near y * TBLSIZE.
313 * Thus we have exp2(y) = exp2(i/TBLSIZE) * exp2(z - eps[i]),
314 * with |z - eps[i]| <= 2**-9 + 2**-39 for the table used.
315 *
316 * We compute exp2(i/TBLSIZE) via table lookup and exp2(z - eps[i]) via
317 * a degree-5 minimax polynomial with maximum error under 1.3 * 2**-61.
318 * The values in exp2t[] and eps[] are chosen such that
319 * exp2t[i] = exp2(i/TBLSIZE + eps[i]), and eps[i] is a small offset such
320 * that exp2t[i] is accurate to 2**-64.
321 *
322 * Note that the range of i is +-TBLSIZE/2, so we actually index the tables
323 * by i0 = i + TBLSIZE/2. For cache efficiency, exp2t[] and eps[] are
324 * virtual tables, interleaved in the real table tbl[].
325 *
326 * This method is due to Gal, with many details due to Gal and Bachelis:
327 *
328 * Gal, S. and Bachelis, B. An Accurate Elementary Mathematical Library
329 * for the IEEE Floating Point Standard. TOMS 17(1), 26-46 (1991).
330 */
33170double exp2(double x)
33271{
333 double_t r, t, z;
334 uint32_t ix, i0;
335 union {double f; uint64_t i;} u = {x};
336 union {uint32_t u; int32_t i;} k;
72 uint32_t abstop;
73 uint64_t ki, idx, top, sbits;
74 double_t kd, r, r2, scale, tail, tmp;
33775
338 /* Filter out exceptional cases. */
339 ix = u.i>>32 & 0x7fffffff;
340 if (ix >= 0x408ff000) { /* |x| >= 1022 or nan */
341 if (ix >= 0x40900000 && u.i>>63 == 0) { /* x >= 1024 or nan */
342 /* overflow */
343 x *= 0x1p1023;
344 return x;
345 }
346 if (ix >= 0x7ff00000) /* -inf or -nan */
347 return -1/x;
348 if (u.i>>63) { /* x <= -1022 */
349 /* underflow */
350 if (x <= -1075 || x - 0x1p52 + 0x1p52 != x)
351 FORCE_EVAL((float)(-0x1p-149/x));
352 if (x <= -1075)
353 return 0;
76 abstop = top12(x) & 0x7ff;
77 if (predict_false(abstop - top12(0x1p-54) >= top12(512.0) - top12(0x1p-54))) {
78 if (abstop - top12(0x1p-54) >= 0x80000000)
79 /* Avoid spurious underflow for tiny x. */
80 /* Note: 0 is common input. */
81 return WANT_ROUNDING ? 1.0 + x : 1.0;
82 if (abstop >= top12(1024.0)) {
83 if (asuint64(x) == asuint64(-INFINITY))
84 return 0.0;
85 if (abstop >= top12(INFINITY))
86 return 1.0 + x;
87 if (!(asuint64(x) >> 63))
88 return __math_oflow(0);
89 else if (asuint64(x) >= asuint64(-1075.0))
90 return __math_uflow(0);
35491 }
355 } else if (ix < 0x3c900000) { /* |x| < 0x1p-54 */
356 return 1.0 + x;
92 if (2 * asuint64(x) > 2 * asuint64(928.0))
93 /* Large x is special cased below. */
94 abstop = 0;
35795 }
35896
359 /* Reduce x, computing z, i0, and k. */
360 u.f = x + redux;
361 i0 = u.i;
362 i0 += TBLSIZE / 2;
363 k.u = i0 / TBLSIZE * TBLSIZE;
364 k.i /= TBLSIZE;
365 i0 %= TBLSIZE;
366 u.f -= redux;
367 z = x - u.f;
368
369 /* Compute r = exp2(y) = exp2t[i0] * p(z - eps[i]). */
370 t = tbl[2*i0]; /* exp2t[i0] */
371 z -= tbl[2*i0 + 1]; /* eps[i0] */
372 r = t + t * z * (P1 + z * (P2 + z * (P3 + z * (P4 + z * P5))));
373
374 return scalbn(r, k.i);
97 /* exp2(x) = 2^(k/N) * 2^r, with 2^r in [2^(-1/2N),2^(1/2N)]. */
98 /* x = k/N + r, with int k and r in [-1/2N, 1/2N]. */
99 kd = eval_as_double(x + Shift);
100 ki = asuint64(kd); /* k. */
101 kd -= Shift; /* k/N for int k. */
102 r = x - kd;
103 /* 2^(k/N) ~= scale * (1 + tail). */
104 idx = 2 * (ki % N);
105 top = ki << (52 - EXP_TABLE_BITS);
106 tail = asdouble(T[idx]);
107 /* This is only a valid scale when -1023*N < k < 1024*N. */
108 sbits = T[idx + 1] + top;
109 /* exp2(x) = 2^(k/N) * 2^r ~= scale + scale * (tail + 2^r - 1). */
110 /* Evaluation is optimized assuming superscalar pipelined execution. */
111 r2 = r * r;
112 /* Without fma the worst case error is 0.5/N ulp larger. */
113 /* Worst case error is less than 0.5+0.86/N+(abs poly error * 2^53) ulp. */
114 tmp = tail + r * C1 + r2 * (C2 + r * C3) + r2 * r2 * (C4 + r * C5);
115 if (predict_false(abstop == 0))
116 return specialcase(tmp, sbits, ki);
117 scale = asdouble(sbits);
118 /* Note: tmp == 0 or |tmp| > 2^-65 and scale > 2^-928, so there
119 is no spurious underflow here even without fma. */
120 return eval_as_double(scale + scale * tmp);
375121}
lib/libc/musl/src/math/exp2f.c+54-111
......@@ -1,126 +1,69 @@
1/* origin: FreeBSD /usr/src/lib/msun/src/s_exp2f.c */
2/*-
3 * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
1/*
2 * Single-precision 2^x function.
143 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
4 * Copyright (c) 2017-2018, Arm Limited.
5 * SPDX-License-Identifier: MIT
266 */
277
8#include <math.h>
9#include <stdint.h>
2810#include "libm.h"
11#include "exp2f_data.h"
2912
30#define TBLSIZE 16
13/*
14EXP2F_TABLE_BITS = 5
15EXP2F_POLY_ORDER = 3
3116
32static const float
33redux = 0x1.8p23f / TBLSIZE,
34P1 = 0x1.62e430p-1f,
35P2 = 0x1.ebfbe0p-3f,
36P3 = 0x1.c6b348p-5f,
37P4 = 0x1.3b2c9cp-7f;
17ULP error: 0.502 (nearest rounding.)
18Relative error: 1.69 * 2^-34 in [-1/64, 1/64] (before rounding.)
19Wrong count: 168353 (all nearest rounding wrong results with fma.)
20Non-nearest ULP error: 1 (rounded ULP error)
21*/
3822
39static const double exp2ft[TBLSIZE] = {
40 0x1.6a09e667f3bcdp-1,
41 0x1.7a11473eb0187p-1,
42 0x1.8ace5422aa0dbp-1,
43 0x1.9c49182a3f090p-1,
44 0x1.ae89f995ad3adp-1,
45 0x1.c199bdd85529cp-1,
46 0x1.d5818dcfba487p-1,
47 0x1.ea4afa2a490dap-1,
48 0x1.0000000000000p+0,
49 0x1.0b5586cf9890fp+0,
50 0x1.172b83c7d517bp+0,
51 0x1.2387a6e756238p+0,
52 0x1.306fe0a31b715p+0,
53 0x1.3dea64c123422p+0,
54 0x1.4bfdad5362a27p+0,
55 0x1.5ab07dd485429p+0,
56};
23#define N (1 << EXP2F_TABLE_BITS)
24#define T __exp2f_data.tab
25#define C __exp2f_data.poly
26#define SHIFT __exp2f_data.shift_scaled
27
28static inline uint32_t top12(float x)
29{
30 return asuint(x) >> 20;
31}
5732
58/*
59 * exp2f(x): compute the base 2 exponential of x
60 *
61 * Accuracy: Peak error < 0.501 ulp; location of peak: -0.030110927.
62 *
63 * Method: (equally-spaced tables)
64 *
65 * Reduce x:
66 * x = k + y, for integer k and |y| <= 1/2.
67 * Thus we have exp2f(x) = 2**k * exp2(y).
68 *
69 * Reduce y:
70 * y = i/TBLSIZE + z for integer i near y * TBLSIZE.
71 * Thus we have exp2(y) = exp2(i/TBLSIZE) * exp2(z),
72 * with |z| <= 2**-(TBLSIZE+1).
73 *
74 * We compute exp2(i/TBLSIZE) via table lookup and exp2(z) via a
75 * degree-4 minimax polynomial with maximum error under 1.4 * 2**-33.
76 * Using double precision for everything except the reduction makes
77 * roundoff error insignificant and simplifies the scaling step.
78 *
79 * This method is due to Tang, but I do not use his suggested parameters:
80 *
81 * Tang, P. Table-driven Implementation of the Exponential Function
82 * in IEEE Floating-Point Arithmetic. TOMS 15(2), 144-157 (1989).
83 */
8433float exp2f(float x)
8534{
86 double_t t, r, z;
87 union {float f; uint32_t i;} u = {x};
88 union {double f; uint64_t i;} uk;
89 uint32_t ix, i0, k;
35 uint32_t abstop;
36 uint64_t ki, t;
37 double_t kd, xd, z, r, r2, y, s;
9038
91 /* Filter out exceptional cases. */
92 ix = u.i & 0x7fffffff;
93 if (ix > 0x42fc0000) { /* |x| > 126 */
94 if (ix > 0x7f800000) /* NaN */
95 return x;
96 if (u.i >= 0x43000000 && u.i < 0x80000000) { /* x >= 128 */
97 x *= 0x1p127f;
98 return x;
99 }
100 if (u.i >= 0x80000000) { /* x < -126 */
101 if (u.i >= 0xc3160000 || (u.i & 0x0000ffff))
102 FORCE_EVAL(-0x1p-149f/x);
103 if (u.i >= 0xc3160000) /* x <= -150 */
104 return 0;
105 }
106 } else if (ix <= 0x33000000) { /* |x| <= 0x1p-25 */
107 return 1.0f + x;
39 xd = (double_t)x;
40 abstop = top12(x) & 0x7ff;
41 if (predict_false(abstop >= top12(128.0f))) {
42 /* |x| >= 128 or x is nan. */
43 if (asuint(x) == asuint(-INFINITY))
44 return 0.0f;
45 if (abstop >= top12(INFINITY))
46 return x + x;
47 if (x > 0.0f)
48 return __math_oflowf(0);
49 if (x <= -150.0f)
50 return __math_uflowf(0);
10851 }
10952
110 /* Reduce x, computing z, i0, and k. */
111 u.f = x + redux;
112 i0 = u.i;
113 i0 += TBLSIZE / 2;
114 k = i0 / TBLSIZE;
115 uk.i = (uint64_t)(0x3ff + k)<<52;
116 i0 &= TBLSIZE - 1;
117 u.f -= redux;
118 z = x - u.f;
119 /* Compute r = exp2(y) = exp2ft[i0] * p(z). */
120 r = exp2ft[i0];
121 t = r * z;
122 r = r + t * (P1 + z * P2) + t * (z * z) * (P3 + z * P4);
53 /* x = k/N + r with r in [-1/(2N), 1/(2N)] and int k. */
54 kd = eval_as_double(xd + SHIFT);
55 ki = asuint64(kd);
56 kd -= SHIFT; /* k/N for int k. */
57 r = xd - kd;
12358
124 /* Scale by 2**k */
125 return r * uk.f;
59 /* exp2(x) = 2^(k/N) * 2^r ~= s * (C0*r^3 + C1*r^2 + C2*r + 1) */
60 t = T[ki % N];
61 t += ki << (52 - EXP2F_TABLE_BITS);
62 s = asdouble(t);
63 z = C[0] * r + C[1];
64 r2 = r * r;
65 y = C[2] * r + 1;
66 y = z * r2 + y;
67 y = y * s;
68 return eval_as_float(y);
12669}
lib/libc/musl/src/math/exp2f_data.c created+35
......@@ -0,0 +1,35 @@
1/*
2 * Shared data between expf, exp2f and powf.
3 *
4 * Copyright (c) 2017-2018, Arm Limited.
5 * SPDX-License-Identifier: MIT
6 */
7
8#include "exp2f_data.h"
9
10#define N (1 << EXP2F_TABLE_BITS)
11
12const struct exp2f_data __exp2f_data = {
13 /* tab[i] = uint(2^(i/N)) - (i << 52-BITS)
14 used for computing 2^(k/N) for an int |k| < 150 N as
15 double(tab[k%N] + (k << 52-BITS)) */
16 .tab = {
170x3ff0000000000000, 0x3fefd9b0d3158574, 0x3fefb5586cf9890f, 0x3fef9301d0125b51,
180x3fef72b83c7d517b, 0x3fef54873168b9aa, 0x3fef387a6e756238, 0x3fef1e9df51fdee1,
190x3fef06fe0a31b715, 0x3feef1a7373aa9cb, 0x3feedea64c123422, 0x3feece086061892d,
200x3feebfdad5362a27, 0x3feeb42b569d4f82, 0x3feeab07dd485429, 0x3feea47eb03a5585,
210x3feea09e667f3bcd, 0x3fee9f75e8ec5f74, 0x3feea11473eb0187, 0x3feea589994cce13,
220x3feeace5422aa0db, 0x3feeb737b0cdc5e5, 0x3feec49182a3f090, 0x3feed503b23e255d,
230x3feee89f995ad3ad, 0x3feeff76f2fb5e47, 0x3fef199bdd85529c, 0x3fef3720dcef9069,
240x3fef5818dcfba487, 0x3fef7c97337b9b5f, 0x3fefa4afa2a490da, 0x3fefd0765b6e4540,
25 },
26 .shift_scaled = 0x1.8p+52 / N,
27 .poly = {
28 0x1.c6af84b912394p-5, 0x1.ebfce50fac4f3p-3, 0x1.62e42ff0c52d6p-1,
29 },
30 .shift = 0x1.8p+52,
31 .invln2_scaled = 0x1.71547652b82fep+0 * N,
32 .poly_scaled = {
33 0x1.c6af84b912394p-5/N/N/N, 0x1.ebfce50fac4f3p-3/N/N, 0x1.62e42ff0c52d6p-1/N,
34 },
35};
lib/libc/musl/src/math/exp2f_data.h created+23
......@@ -0,0 +1,23 @@
1/*
2 * Copyright (c) 2017-2018, Arm Limited.
3 * SPDX-License-Identifier: MIT
4 */
5#ifndef _EXP2F_DATA_H
6#define _EXP2F_DATA_H
7
8#include <features.h>
9#include <stdint.h>
10
11/* Shared between expf, exp2f and powf. */
12#define EXP2F_TABLE_BITS 5
13#define EXP2F_POLY_ORDER 3
14extern hidden const struct exp2f_data {
15 uint64_t tab[1 << EXP2F_TABLE_BITS];
16 double shift_scaled;
17 double poly[EXP2F_POLY_ORDER];
18 double shift;
19 double invln2_scaled;
20 double poly_scaled[EXP2F_POLY_ORDER];
21} __exp2f_data;
22
23#endif
lib/libc/musl/src/math/exp_data.c created+182
......@@ -0,0 +1,182 @@
1/*
2 * Shared data between exp, exp2 and pow.
3 *
4 * Copyright (c) 2018, Arm Limited.
5 * SPDX-License-Identifier: MIT
6 */
7
8#include "exp_data.h"
9
10#define N (1 << EXP_TABLE_BITS)
11
12const struct exp_data __exp_data = {
13// N/ln2
14.invln2N = 0x1.71547652b82fep0 * N,
15// -ln2/N
16.negln2hiN = -0x1.62e42fefa0000p-8,
17.negln2loN = -0x1.cf79abc9e3b3ap-47,
18// Used for rounding when !TOINT_INTRINSICS
19#if EXP_USE_TOINT_NARROW
20.shift = 0x1800000000.8p0,
21#else
22.shift = 0x1.8p52,
23#endif
24// exp polynomial coefficients.
25.poly = {
26// abs error: 1.555*2^-66
27// ulp error: 0.509 (0.511 without fma)
28// if |x| < ln2/256+eps
29// abs error if |x| < ln2/256+0x1p-15: 1.09*2^-65
30// abs error if |x| < ln2/128: 1.7145*2^-56
310x1.ffffffffffdbdp-2,
320x1.555555555543cp-3,
330x1.55555cf172b91p-5,
340x1.1111167a4d017p-7,
35},
36.exp2_shift = 0x1.8p52 / N,
37// exp2 polynomial coefficients.
38.exp2_poly = {
39// abs error: 1.2195*2^-65
40// ulp error: 0.507 (0.511 without fma)
41// if |x| < 1/256
42// abs error if |x| < 1/128: 1.9941*2^-56
430x1.62e42fefa39efp-1,
440x1.ebfbdff82c424p-3,
450x1.c6b08d70cf4b5p-5,
460x1.3b2abd24650ccp-7,
470x1.5d7e09b4e3a84p-10,
48},
49// 2^(k/N) ~= H[k]*(1 + T[k]) for int k in [0,N)
50// tab[2*k] = asuint64(T[k])
51// tab[2*k+1] = asuint64(H[k]) - (k << 52)/N
52.tab = {
530x0, 0x3ff0000000000000,
540x3c9b3b4f1a88bf6e, 0x3feff63da9fb3335,
550xbc7160139cd8dc5d, 0x3fefec9a3e778061,
560xbc905e7a108766d1, 0x3fefe315e86e7f85,
570x3c8cd2523567f613, 0x3fefd9b0d3158574,
580xbc8bce8023f98efa, 0x3fefd06b29ddf6de,
590x3c60f74e61e6c861, 0x3fefc74518759bc8,
600x3c90a3e45b33d399, 0x3fefbe3ecac6f383,
610x3c979aa65d837b6d, 0x3fefb5586cf9890f,
620x3c8eb51a92fdeffc, 0x3fefac922b7247f7,
630x3c3ebe3d702f9cd1, 0x3fefa3ec32d3d1a2,
640xbc6a033489906e0b, 0x3fef9b66affed31b,
650xbc9556522a2fbd0e, 0x3fef9301d0125b51,
660xbc5080ef8c4eea55, 0x3fef8abdc06c31cc,
670xbc91c923b9d5f416, 0x3fef829aaea92de0,
680x3c80d3e3e95c55af, 0x3fef7a98c8a58e51,
690xbc801b15eaa59348, 0x3fef72b83c7d517b,
700xbc8f1ff055de323d, 0x3fef6af9388c8dea,
710x3c8b898c3f1353bf, 0x3fef635beb6fcb75,
720xbc96d99c7611eb26, 0x3fef5be084045cd4,
730x3c9aecf73e3a2f60, 0x3fef54873168b9aa,
740xbc8fe782cb86389d, 0x3fef4d5022fcd91d,
750x3c8a6f4144a6c38d, 0x3fef463b88628cd6,
760x3c807a05b0e4047d, 0x3fef3f49917ddc96,
770x3c968efde3a8a894, 0x3fef387a6e756238,
780x3c875e18f274487d, 0x3fef31ce4fb2a63f,
790x3c80472b981fe7f2, 0x3fef2b4565e27cdd,
800xbc96b87b3f71085e, 0x3fef24dfe1f56381,
810x3c82f7e16d09ab31, 0x3fef1e9df51fdee1,
820xbc3d219b1a6fbffa, 0x3fef187fd0dad990,
830x3c8b3782720c0ab4, 0x3fef1285a6e4030b,
840x3c6e149289cecb8f, 0x3fef0cafa93e2f56,
850x3c834d754db0abb6, 0x3fef06fe0a31b715,
860x3c864201e2ac744c, 0x3fef0170fc4cd831,
870x3c8fdd395dd3f84a, 0x3feefc08b26416ff,
880xbc86a3803b8e5b04, 0x3feef6c55f929ff1,
890xbc924aedcc4b5068, 0x3feef1a7373aa9cb,
900xbc9907f81b512d8e, 0x3feeecae6d05d866,
910xbc71d1e83e9436d2, 0x3feee7db34e59ff7,
920xbc991919b3ce1b15, 0x3feee32dc313a8e5,
930x3c859f48a72a4c6d, 0x3feedea64c123422,
940xbc9312607a28698a, 0x3feeda4504ac801c,
950xbc58a78f4817895b, 0x3feed60a21f72e2a,
960xbc7c2c9b67499a1b, 0x3feed1f5d950a897,
970x3c4363ed60c2ac11, 0x3feece086061892d,
980x3c9666093b0664ef, 0x3feeca41ed1d0057,
990x3c6ecce1daa10379, 0x3feec6a2b5c13cd0,
1000x3c93ff8e3f0f1230, 0x3feec32af0d7d3de,
1010x3c7690cebb7aafb0, 0x3feebfdad5362a27,
1020x3c931dbdeb54e077, 0x3feebcb299fddd0d,
1030xbc8f94340071a38e, 0x3feeb9b2769d2ca7,
1040xbc87deccdc93a349, 0x3feeb6daa2cf6642,
1050xbc78dec6bd0f385f, 0x3feeb42b569d4f82,
1060xbc861246ec7b5cf6, 0x3feeb1a4ca5d920f,
1070x3c93350518fdd78e, 0x3feeaf4736b527da,
1080x3c7b98b72f8a9b05, 0x3feead12d497c7fd,
1090x3c9063e1e21c5409, 0x3feeab07dd485429,
1100x3c34c7855019c6ea, 0x3feea9268a5946b7,
1110x3c9432e62b64c035, 0x3feea76f15ad2148,
1120xbc8ce44a6199769f, 0x3feea5e1b976dc09,
1130xbc8c33c53bef4da8, 0x3feea47eb03a5585,
1140xbc845378892be9ae, 0x3feea34634ccc320,
1150xbc93cedd78565858, 0x3feea23882552225,
1160x3c5710aa807e1964, 0x3feea155d44ca973,
1170xbc93b3efbf5e2228, 0x3feea09e667f3bcd,
1180xbc6a12ad8734b982, 0x3feea012750bdabf,
1190xbc6367efb86da9ee, 0x3fee9fb23c651a2f,
1200xbc80dc3d54e08851, 0x3fee9f7df9519484,
1210xbc781f647e5a3ecf, 0x3fee9f75e8ec5f74,
1220xbc86ee4ac08b7db0, 0x3fee9f9a48a58174,
1230xbc8619321e55e68a, 0x3fee9feb564267c9,
1240x3c909ccb5e09d4d3, 0x3feea0694fde5d3f,
1250xbc7b32dcb94da51d, 0x3feea11473eb0187,
1260x3c94ecfd5467c06b, 0x3feea1ed0130c132,
1270x3c65ebe1abd66c55, 0x3feea2f336cf4e62,
1280xbc88a1c52fb3cf42, 0x3feea427543e1a12,
1290xbc9369b6f13b3734, 0x3feea589994cce13,
1300xbc805e843a19ff1e, 0x3feea71a4623c7ad,
1310xbc94d450d872576e, 0x3feea8d99b4492ed,
1320x3c90ad675b0e8a00, 0x3feeaac7d98a6699,
1330x3c8db72fc1f0eab4, 0x3feeace5422aa0db,
1340xbc65b6609cc5e7ff, 0x3feeaf3216b5448c,
1350x3c7bf68359f35f44, 0x3feeb1ae99157736,
1360xbc93091fa71e3d83, 0x3feeb45b0b91ffc6,
1370xbc5da9b88b6c1e29, 0x3feeb737b0cdc5e5,
1380xbc6c23f97c90b959, 0x3feeba44cbc8520f,
1390xbc92434322f4f9aa, 0x3feebd829fde4e50,
1400xbc85ca6cd7668e4b, 0x3feec0f170ca07ba,
1410x3c71affc2b91ce27, 0x3feec49182a3f090,
1420x3c6dd235e10a73bb, 0x3feec86319e32323,
1430xbc87c50422622263, 0x3feecc667b5de565,
1440x3c8b1c86e3e231d5, 0x3feed09bec4a2d33,
1450xbc91bbd1d3bcbb15, 0x3feed503b23e255d,
1460x3c90cc319cee31d2, 0x3feed99e1330b358,
1470x3c8469846e735ab3, 0x3feede6b5579fdbf,
1480xbc82dfcd978e9db4, 0x3feee36bbfd3f37a,
1490x3c8c1a7792cb3387, 0x3feee89f995ad3ad,
1500xbc907b8f4ad1d9fa, 0x3feeee07298db666,
1510xbc55c3d956dcaeba, 0x3feef3a2b84f15fb,
1520xbc90a40e3da6f640, 0x3feef9728de5593a,
1530xbc68d6f438ad9334, 0x3feeff76f2fb5e47,
1540xbc91eee26b588a35, 0x3fef05b030a1064a,
1550x3c74ffd70a5fddcd, 0x3fef0c1e904bc1d2,
1560xbc91bdfbfa9298ac, 0x3fef12c25bd71e09,
1570x3c736eae30af0cb3, 0x3fef199bdd85529c,
1580x3c8ee3325c9ffd94, 0x3fef20ab5fffd07a,
1590x3c84e08fd10959ac, 0x3fef27f12e57d14b,
1600x3c63cdaf384e1a67, 0x3fef2f6d9406e7b5,
1610x3c676b2c6c921968, 0x3fef3720dcef9069,
1620xbc808a1883ccb5d2, 0x3fef3f0b555dc3fa,
1630xbc8fad5d3ffffa6f, 0x3fef472d4a07897c,
1640xbc900dae3875a949, 0x3fef4f87080d89f2,
1650x3c74a385a63d07a7, 0x3fef5818dcfba487,
1660xbc82919e2040220f, 0x3fef60e316c98398,
1670x3c8e5a50d5c192ac, 0x3fef69e603db3285,
1680x3c843a59ac016b4b, 0x3fef7321f301b460,
1690xbc82d52107b43e1f, 0x3fef7c97337b9b5f,
1700xbc892ab93b470dc9, 0x3fef864614f5a129,
1710x3c74b604603a88d3, 0x3fef902ee78b3ff6,
1720x3c83c5ec519d7271, 0x3fef9a51fbc74c83,
1730xbc8ff7128fd391f0, 0x3fefa4afa2a490da,
1740xbc8dae98e223747d, 0x3fefaf482d8e67f1,
1750x3c8ec3bc41aa2008, 0x3fefba1bee615a27,
1760x3c842b94c3a9eb32, 0x3fefc52b376bba97,
1770x3c8a64a931d185ee, 0x3fefd0765b6e4540,
1780xbc8e37bae43be3ed, 0x3fefdbfdad9cbe14,
1790x3c77893b4d91cd9d, 0x3fefe7c1819e90d8,
1800x3c5305c14160cc89, 0x3feff3c22b8f71f1,
181},
182};
lib/libc/musl/src/math/exp_data.h created+26
......@@ -0,0 +1,26 @@
1/*
2 * Copyright (c) 2018, Arm Limited.
3 * SPDX-License-Identifier: MIT
4 */
5#ifndef _EXP_DATA_H
6#define _EXP_DATA_H
7
8#include <features.h>
9#include <stdint.h>
10
11#define EXP_TABLE_BITS 7
12#define EXP_POLY_ORDER 5
13#define EXP_USE_TOINT_NARROW 0
14#define EXP2_POLY_ORDER 5
15extern hidden const struct exp_data {
16 double invln2N;
17 double shift;
18 double negln2hiN;
19 double negln2loN;
20 double poly[4]; /* Last four coefficients. */
21 double exp2_shift;
22 double exp2_poly[EXP2_POLY_ORDER];
23 uint64_t tab[2*(1 << EXP_TABLE_BITS)];
24} __exp_data;
25
26#endif
lib/libc/musl/src/math/expf.c+65-68
......@@ -1,83 +1,80 @@
1/* origin: FreeBSD /usr/src/lib/msun/src/e_expf.c */
21/*
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.
2 * Single-precision e^x function.
83 *
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 * ====================================================
4 * Copyright (c) 2017-2018, Arm Limited.
5 * SPDX-License-Identifier: MIT
146 */
157
8#include <math.h>
9#include <stdint.h>
1610#include "libm.h"
11#include "exp2f_data.h"
1712
18static const float
19half[2] = {0.5,-0.5},
20ln2hi = 6.9314575195e-1f, /* 0x3f317200 */
21ln2lo = 1.4286067653e-6f, /* 0x35bfbe8e */
22invln2 = 1.4426950216e+0f, /* 0x3fb8aa3b */
2313/*
24 * Domain [-0.34568, 0.34568], range ~[-4.278e-9, 4.447e-9]:
25 * |x*(exp(x)+1)/(exp(x)-1) - p(x)| < 2**-27.74
26 */
27P1 = 1.6666625440e-1f, /* 0xaaaa8f.0p-26 */
28P2 = -2.7667332906e-3f; /* -0xb55215.0p-32 */
14EXP2F_TABLE_BITS = 5
15EXP2F_POLY_ORDER = 3
2916
30float expf(float x)
17ULP error: 0.502 (nearest rounding.)
18Relative error: 1.69 * 2^-34 in [-ln2/64, ln2/64] (before rounding.)
19Wrong count: 170635 (all nearest rounding wrong results with fma.)
20Non-nearest ULP error: 1 (rounded ULP error)
21*/
22
23#define N (1 << EXP2F_TABLE_BITS)
24#define InvLn2N __exp2f_data.invln2_scaled
25#define T __exp2f_data.tab
26#define C __exp2f_data.poly_scaled
27
28static inline uint32_t top12(float x)
3129{
32 float_t hi, lo, c, xx, y;
33 int k, sign;
34 uint32_t hx;
30 return asuint(x) >> 20;
31}
3532
36 GET_FLOAT_WORD(hx, x);
37 sign = hx >> 31; /* sign bit of x */
38 hx &= 0x7fffffff; /* high word of |x| */
33float expf(float x)
34{
35 uint32_t abstop;
36 uint64_t ki, t;
37 double_t kd, xd, z, r, r2, y, s;
3938
40 /* special cases */
41 if (hx >= 0x42aeac50) { /* if |x| >= -87.33655f or NaN */
42 if (hx > 0x7f800000) /* NaN */
43 return x;
44 if (hx >= 0x42b17218 && !sign) { /* x >= 88.722839f */
45 /* overflow */
46 x *= 0x1p127f;
47 return x;
48 }
49 if (sign) {
50 /* underflow */
51 FORCE_EVAL(-0x1p-149f/x);
52 if (hx >= 0x42cff1b5) /* x <= -103.972084f */
53 return 0;
54 }
39 xd = (double_t)x;
40 abstop = top12(x) & 0x7ff;
41 if (predict_false(abstop >= top12(88.0f))) {
42 /* |x| >= 88 or x is nan. */
43 if (asuint(x) == asuint(-INFINITY))
44 return 0.0f;
45 if (abstop >= top12(INFINITY))
46 return x + x;
47 if (x > 0x1.62e42ep6f) /* x > log(0x1p128) ~= 88.72 */
48 return __math_oflowf(0);
49 if (x < -0x1.9fe368p6f) /* x < log(0x1p-150) ~= -103.97 */
50 return __math_uflowf(0);
5551 }
5652
57 /* argument reduction */
58 if (hx > 0x3eb17218) { /* if |x| > 0.5 ln2 */
59 if (hx > 0x3f851592) /* if |x| > 1.5 ln2 */
60 k = invln2*x + half[sign];
61 else
62 k = 1 - sign - sign;
63 hi = x - k*ln2hi; /* k*ln2hi is exact here */
64 lo = k*ln2lo;
65 x = hi - lo;
66 } else if (hx > 0x39000000) { /* |x| > 2**-14 */
67 k = 0;
68 hi = x;
69 lo = 0;
70 } else {
71 /* raise inexact */
72 FORCE_EVAL(0x1p127f + x);
73 return 1 + x;
74 }
53 /* x*N/Ln2 = k + r with r in [-1/2, 1/2] and int k. */
54 z = InvLn2N * xd;
55
56 /* Round and convert z to int, the result is in [-150*N, 128*N] and
57 ideally ties-to-even rule is used, otherwise the magnitude of r
58 can be bigger which gives larger approximation error. */
59#if TOINT_INTRINSICS
60 kd = roundtoint(z);
61 ki = converttoint(z);
62#else
63# define SHIFT __exp2f_data.shift
64 kd = eval_as_double(z + SHIFT);
65 ki = asuint64(kd);
66 kd -= SHIFT;
67#endif
68 r = z - kd;
7569
76 /* x is now in primary range */
77 xx = x*x;
78 c = x - xx*(P1+xx*P2);
79 y = 1 + (x*c/(2-c) - lo + hi);
80 if (k == 0)
81 return y;
82 return scalbnf(y, k);
70 /* exp(x) = 2^(k/N) * 2^(r/N) ~= s * (C0*r^3 + C1*r^2 + C2*r + 1) */
71 t = T[ki % N];
72 t += ki << (52 - EXP2F_TABLE_BITS);
73 s = asdouble(t);
74 z = C[0] * r + C[1];
75 r2 = r * r;
76 y = C[2] * r + 1;
77 y = z * r2 + y;
78 y = y * s;
79 return eval_as_float(y);
8380}
lib/libc/musl/src/math/log.c+98-104
......@@ -1,118 +1,112 @@
1/* origin: FreeBSD /usr/src/lib/msun/src/e_log.c */
21/*
3 * ====================================================
4 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
2 * Double-precision log(x) function.
53 *
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/* log(x)
13 * Return the logarithm of x
14 *
15 * Method :
16 * 1. Argument Reduction: find k and f such that
17 * x = 2^k * (1+f),
18 * where sqrt(2)/2 < 1+f < sqrt(2) .
19 *
20 * 2. Approximation of log(1+f).
21 * Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s)
22 * = 2s + 2/3 s**3 + 2/5 s**5 + .....,
23 * = 2s + s*R
24 * We use a special Remez algorithm on [0,0.1716] to generate
25 * a polynomial of degree 14 to approximate R The maximum error
26 * of this polynomial approximation is bounded by 2**-58.45. In
27 * other words,
28 * 2 4 6 8 10 12 14
29 * R(z) ~ Lg1*s +Lg2*s +Lg3*s +Lg4*s +Lg5*s +Lg6*s +Lg7*s
30 * (the values of Lg1 to Lg7 are listed in the program)
31 * and
32 * | 2 14 | -58.45
33 * | Lg1*s +...+Lg7*s - R(z) | <= 2
34 * | |
35 * Note that 2s = f - s*f = f - hfsq + s*hfsq, where hfsq = f*f/2.
36 * In order to guarantee error in log below 1ulp, we compute log
37 * by
38 * log(1+f) = f - s*(f - R) (if f is not too large)
39 * log(1+f) = f - (hfsq - s*(hfsq+R)). (better accuracy)
40 *
41 * 3. Finally, log(x) = k*ln2 + log(1+f).
42 * = k*ln2_hi+(f-(hfsq-(s*(hfsq+R)+k*ln2_lo)))
43 * Here ln2 is split into two floating point number:
44 * ln2_hi + ln2_lo,
45 * where n*ln2_hi is always exact for |n| < 2000.
46 *
47 * Special cases:
48 * log(x) is NaN with signal if x < 0 (including -INF) ;
49 * log(+INF) is +INF; log(0) is -INF with signal;
50 * log(NaN) is that NaN with no signal.
51 *
52 * Accuracy:
53 * according to an error analysis, the error is always less than
54 * 1 ulp (unit in the last place).
55 *
56 * Constants:
57 * The hexadecimal values are the intended ones for the following
58 * constants. The decimal values may be used, provided that the
59 * compiler will convert from decimal to binary accurately enough
60 * to produce the hexadecimal values shown.
4 * Copyright (c) 2018, Arm Limited.
5 * SPDX-License-Identifier: MIT
616 */
627
638#include <math.h>
649#include <stdint.h>
10#include "libm.h"
11#include "log_data.h"
12
13#define T __log_data.tab
14#define T2 __log_data.tab2
15#define B __log_data.poly1
16#define A __log_data.poly
17#define Ln2hi __log_data.ln2hi
18#define Ln2lo __log_data.ln2lo
19#define N (1 << LOG_TABLE_BITS)
20#define OFF 0x3fe6000000000000
6521
66static const double
67ln2_hi = 6.93147180369123816490e-01, /* 3fe62e42 fee00000 */
68ln2_lo = 1.90821492927058770002e-10, /* 3dea39ef 35793c76 */
69Lg1 = 6.666666666666735130e-01, /* 3FE55555 55555593 */
70Lg2 = 3.999999999940941908e-01, /* 3FD99999 9997FA04 */
71Lg3 = 2.857142874366239149e-01, /* 3FD24924 94229359 */
72Lg4 = 2.222219843214978396e-01, /* 3FCC71C5 1D8E78AF */
73Lg5 = 1.818357216161805012e-01, /* 3FC74664 96CB03DE */
74Lg6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */
75Lg7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
22/* Top 16 bits of a double. */
23static inline uint32_t top16(double x)
24{
25 return asuint64(x) >> 48;
26}
7627
7728double log(double x)
7829{
79 union {double f; uint64_t i;} u = {x};
80 double_t hfsq,f,s,z,R,w,t1,t2,dk;
81 uint32_t hx;
82 int k;
30 double_t w, z, r, r2, r3, y, invc, logc, kd, hi, lo;
31 uint64_t ix, iz, tmp;
32 uint32_t top;
33 int k, i;
34
35 ix = asuint64(x);
36 top = top16(x);
37#define LO asuint64(1.0 - 0x1p-4)
38#define HI asuint64(1.0 + 0x1.09p-4)
39 if (predict_false(ix - LO < HI - LO)) {
40 /* Handle close to 1.0 inputs separately. */
41 /* Fix sign of zero with downward rounding when x==1. */
42 if (WANT_ROUNDING && predict_false(ix == asuint64(1.0)))
43 return 0;
44 r = x - 1.0;
45 r2 = r * r;
46 r3 = r * r2;
47 y = r3 *
48 (B[1] + r * B[2] + r2 * B[3] +
49 r3 * (B[4] + r * B[5] + r2 * B[6] +
50 r3 * (B[7] + r * B[8] + r2 * B[9] + r3 * B[10])));
51 /* Worst-case error is around 0.507 ULP. */
52 w = r * 0x1p27;
53 double_t rhi = r + w - w;
54 double_t rlo = r - rhi;
55 w = rhi * rhi * B[0]; /* B[0] == -0.5. */
56 hi = r + w;
57 lo = r - hi + w;
58 lo += B[0] * rlo * (rhi + r);
59 y += lo;
60 y += hi;
61 return eval_as_double(y);
62 }
63 if (predict_false(top - 0x0010 >= 0x7ff0 - 0x0010)) {
64 /* x < 0x1p-1022 or inf or nan. */
65 if (ix * 2 == 0)
66 return __math_divzero(1);
67 if (ix == asuint64(INFINITY)) /* log(inf) == inf. */
68 return x;
69 if ((top & 0x8000) || (top & 0x7ff0) == 0x7ff0)
70 return __math_invalid(x);
71 /* x is subnormal, normalize it. */
72 ix = asuint64(x * 0x1p52);
73 ix -= 52ULL << 52;
74 }
75
76 /* x = 2^k z; where z is in range [OFF,2*OFF) and exact.
77 The range is split into N subintervals.
78 The ith subinterval contains z and c is near its center. */
79 tmp = ix - OFF;
80 i = (tmp >> (52 - LOG_TABLE_BITS)) % N;
81 k = (int64_t)tmp >> 52; /* arithmetic shift */
82 iz = ix - (tmp & 0xfffULL << 52);
83 invc = T[i].invc;
84 logc = T[i].logc;
85 z = asdouble(iz);
8386
84 hx = u.i>>32;
85 k = 0;
86 if (hx < 0x00100000 || hx>>31) {
87 if (u.i<<1 == 0)
88 return -1/(x*x); /* log(+-0)=-inf */
89 if (hx>>31)
90 return (x-x)/0.0; /* log(-#) = NaN */
91 /* subnormal number, scale x up */
92 k -= 54;
93 x *= 0x1p54;
94 u.f = x;
95 hx = u.i>>32;
96 } else if (hx >= 0x7ff00000) {
97 return x;
98 } else if (hx == 0x3ff00000 && u.i<<32 == 0)
99 return 0;
87 /* log(x) = log1p(z/c-1) + log(c) + k*Ln2. */
88 /* r ~= z/c - 1, |r| < 1/(2*N). */
89#if __FP_FAST_FMA
90 /* rounding error: 0x1p-55/N. */
91 r = __builtin_fma(z, invc, -1.0);
92#else
93 /* rounding error: 0x1p-55/N + 0x1p-66. */
94 r = (z - T2[i].chi - T2[i].clo) * invc;
95#endif
96 kd = (double_t)k;
10097
101 /* reduce x into [sqrt(2)/2, sqrt(2)] */
102 hx += 0x3ff00000 - 0x3fe6a09e;
103 k += (int)(hx>>20) - 0x3ff;
104 hx = (hx&0x000fffff) + 0x3fe6a09e;
105 u.i = (uint64_t)hx<<32 | (u.i&0xffffffff);
106 x = u.f;
98 /* hi + lo = r + log(c) + k*Ln2. */
99 w = kd * Ln2hi + logc;
100 hi = w + r;
101 lo = w - hi + r + kd * Ln2lo;
107102
108 f = x - 1.0;
109 hfsq = 0.5*f*f;
110 s = f/(2.0+f);
111 z = s*s;
112 w = z*z;
113 t1 = w*(Lg2+w*(Lg4+w*Lg6));
114 t2 = z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7)));
115 R = t2 + t1;
116 dk = k;
117 return s*(hfsq+R) + dk*ln2_lo - hfsq + f + dk*ln2_hi;
103 /* log(x) = lo + (log1p(r) - r) + hi. */
104 r2 = r * r; /* rounding error: 0x1p-54/N^2. */
105 /* Worst case error if |y| > 0x1p-5:
106 0.5 + 4.13/N + abs-poly-error*2^57 ULP (+ 0.002 ULP without fma)
107 Worst case error if |y| > 0x1p-4:
108 0.5 + 2.06/N + abs-poly-error*2^56 ULP (+ 0.001 ULP without fma). */
109 y = lo + r2 * A[0] +
110 r * r2 * (A[1] + r * A[2] + r2 * (A[3] + r * A[4])) + hi;
111 return eval_as_double(y);
118112}
lib/libc/musl/src/math/log2.c+106-106
......@@ -1,122 +1,122 @@
1/* origin: FreeBSD /usr/src/lib/msun/src/e_log2.c */
21/*
3 * ====================================================
4 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
2 * Double-precision log2(x) function.
53 *
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/*
13 * Return the base 2 logarithm of x. See log.c for most comments.
14 *
15 * Reduce x to 2^k (1+f) and calculate r = log(1+f) - f + f*f/2
16 * as in log.c, then combine and scale in extra precision:
17 * log2(x) = (f - f*f/2 + r)/log(2) + k
4 * Copyright (c) 2018, Arm Limited.
5 * SPDX-License-Identifier: MIT
186 */
197
208#include <math.h>
219#include <stdint.h>
10#include "libm.h"
11#include "log2_data.h"
2212
23static const double
24ivln2hi = 1.44269504072144627571e+00, /* 0x3ff71547, 0x65200000 */
25ivln2lo = 1.67517131648865118353e-10, /* 0x3de705fc, 0x2eefa200 */
26Lg1 = 6.666666666666735130e-01, /* 3FE55555 55555593 */
27Lg2 = 3.999999999940941908e-01, /* 3FD99999 9997FA04 */
28Lg3 = 2.857142874366239149e-01, /* 3FD24924 94229359 */
29Lg4 = 2.222219843214978396e-01, /* 3FCC71C5 1D8E78AF */
30Lg5 = 1.818357216161805012e-01, /* 3FC74664 96CB03DE */
31Lg6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */
32Lg7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
13#define T __log2_data.tab
14#define T2 __log2_data.tab2
15#define B __log2_data.poly1
16#define A __log2_data.poly
17#define InvLn2hi __log2_data.invln2hi
18#define InvLn2lo __log2_data.invln2lo
19#define N (1 << LOG2_TABLE_BITS)
20#define OFF 0x3fe6000000000000
3321
34double log2(double x)
22/* Top 16 bits of a double. */
23static inline uint32_t top16(double x)
3524{
36 union {double f; uint64_t i;} u = {x};
37 double_t hfsq,f,s,z,R,w,t1,t2,y,hi,lo,val_hi,val_lo;
38 uint32_t hx;
39 int k;
40
41 hx = u.i>>32;
42 k = 0;
43 if (hx < 0x00100000 || hx>>31) {
44 if (u.i<<1 == 0)
45 return -1/(x*x); /* log(+-0)=-inf */
46 if (hx>>31)
47 return (x-x)/0.0; /* log(-#) = NaN */
48 /* subnormal number, scale x up */
49 k -= 54;
50 x *= 0x1p54;
51 u.f = x;
52 hx = u.i>>32;
53 } else if (hx >= 0x7ff00000) {
54 return x;
55 } else if (hx == 0x3ff00000 && u.i<<32 == 0)
56 return 0;
57
58 /* reduce x into [sqrt(2)/2, sqrt(2)] */
59 hx += 0x3ff00000 - 0x3fe6a09e;
60 k += (int)(hx>>20) - 0x3ff;
61 hx = (hx&0x000fffff) + 0x3fe6a09e;
62 u.i = (uint64_t)hx<<32 | (u.i&0xffffffff);
63 x = u.f;
25 return asuint64(x) >> 48;
26}
6427
65 f = x - 1.0;
66 hfsq = 0.5*f*f;
67 s = f/(2.0+f);
68 z = s*s;
69 w = z*z;
70 t1 = w*(Lg2+w*(Lg4+w*Lg6));
71 t2 = z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7)));
72 R = t2 + t1;
28double log2(double x)
29{
30 double_t z, r, r2, r4, y, invc, logc, kd, hi, lo, t1, t2, t3, p;
31 uint64_t ix, iz, tmp;
32 uint32_t top;
33 int k, i;
7334
74 /*
75 * f-hfsq must (for args near 1) be evaluated in extra precision
76 * to avoid a large cancellation when x is near sqrt(2) or 1/sqrt(2).
77 * This is fairly efficient since f-hfsq only depends on f, so can
78 * be evaluated in parallel with R. Not combining hfsq with R also
79 * keeps R small (though not as small as a true `lo' term would be),
80 * so that extra precision is not needed for terms involving R.
81 *
82 * Compiler bugs involving extra precision used to break Dekker's
83 * theorem for spitting f-hfsq as hi+lo, unless double_t was used
84 * or the multi-precision calculations were avoided when double_t
85 * has extra precision. These problems are now automatically
86 * avoided as a side effect of the optimization of combining the
87 * Dekker splitting step with the clear-low-bits step.
88 *
89 * y must (for args near sqrt(2) and 1/sqrt(2)) be added in extra
90 * precision to avoid a very large cancellation when x is very near
91 * these values. Unlike the above cancellations, this problem is
92 * specific to base 2. It is strange that adding +-1 is so much
93 * harder than adding +-ln2 or +-log10_2.
94 *
95 * This uses Dekker's theorem to normalize y+val_hi, so the
96 * compiler bugs are back in some configurations, sigh. And I
97 * don't want to used double_t to avoid them, since that gives a
98 * pessimization and the support for avoiding the pessimization
99 * is not yet available.
100 *
101 * The multi-precision calculations for the multiplications are
102 * routine.
103 */
35 ix = asuint64(x);
36 top = top16(x);
37#define LO asuint64(1.0 - 0x1.5b51p-5)
38#define HI asuint64(1.0 + 0x1.6ab2p-5)
39 if (predict_false(ix - LO < HI - LO)) {
40 /* Handle close to 1.0 inputs separately. */
41 /* Fix sign of zero with downward rounding when x==1. */
42 if (WANT_ROUNDING && predict_false(ix == asuint64(1.0)))
43 return 0;
44 r = x - 1.0;
45#if __FP_FAST_FMA
46 hi = r * InvLn2hi;
47 lo = r * InvLn2lo + __builtin_fma(r, InvLn2hi, -hi);
48#else
49 double_t rhi, rlo;
50 rhi = asdouble(asuint64(r) & -1ULL << 32);
51 rlo = r - rhi;
52 hi = rhi * InvLn2hi;
53 lo = rlo * InvLn2hi + r * InvLn2lo;
54#endif
55 r2 = r * r; /* rounding error: 0x1p-62. */
56 r4 = r2 * r2;
57 /* Worst-case error is less than 0.54 ULP (0.55 ULP without fma). */
58 p = r2 * (B[0] + r * B[1]);
59 y = hi + p;
60 lo += hi - y + p;
61 lo += r4 * (B[2] + r * B[3] + r2 * (B[4] + r * B[5]) +
62 r4 * (B[6] + r * B[7] + r2 * (B[8] + r * B[9])));
63 y += lo;
64 return eval_as_double(y);
65 }
66 if (predict_false(top - 0x0010 >= 0x7ff0 - 0x0010)) {
67 /* x < 0x1p-1022 or inf or nan. */
68 if (ix * 2 == 0)
69 return __math_divzero(1);
70 if (ix == asuint64(INFINITY)) /* log(inf) == inf. */
71 return x;
72 if ((top & 0x8000) || (top & 0x7ff0) == 0x7ff0)
73 return __math_invalid(x);
74 /* x is subnormal, normalize it. */
75 ix = asuint64(x * 0x1p52);
76 ix -= 52ULL << 52;
77 }
10478
105 /* hi+lo = f - hfsq + s*(hfsq+R) ~ log(1+f) */
106 hi = f - hfsq;
107 u.f = hi;
108 u.i &= (uint64_t)-1<<32;
109 hi = u.f;
110 lo = f - hi - hfsq + s*(hfsq+R);
79 /* x = 2^k z; where z is in range [OFF,2*OFF) and exact.
80 The range is split into N subintervals.
81 The ith subinterval contains z and c is near its center. */
82 tmp = ix - OFF;
83 i = (tmp >> (52 - LOG2_TABLE_BITS)) % N;
84 k = (int64_t)tmp >> 52; /* arithmetic shift */
85 iz = ix - (tmp & 0xfffULL << 52);
86 invc = T[i].invc;
87 logc = T[i].logc;
88 z = asdouble(iz);
89 kd = (double_t)k;
11190
112 val_hi = hi*ivln2hi;
113 val_lo = (lo+hi)*ivln2lo + lo*ivln2hi;
91 /* log2(x) = log2(z/c) + log2(c) + k. */
92 /* r ~= z/c - 1, |r| < 1/(2*N). */
93#if __FP_FAST_FMA
94 /* rounding error: 0x1p-55/N. */
95 r = __builtin_fma(z, invc, -1.0);
96 t1 = r * InvLn2hi;
97 t2 = r * InvLn2lo + __builtin_fma(r, InvLn2hi, -t1);
98#else
99 double_t rhi, rlo;
100 /* rounding error: 0x1p-55/N + 0x1p-65. */
101 r = (z - T2[i].chi - T2[i].clo) * invc;
102 rhi = asdouble(asuint64(r) & -1ULL << 32);
103 rlo = r - rhi;
104 t1 = rhi * InvLn2hi;
105 t2 = rlo * InvLn2hi + r * InvLn2lo;
106#endif
114107
115 /* spadd(val_hi, val_lo, y), except for not using double_t: */
116 y = k;
117 w = y + val_hi;
118 val_lo += (y - w) + val_hi;
119 val_hi = w;
108 /* hi + lo = r/ln2 + log2(c) + k. */
109 t3 = kd + logc;
110 hi = t3 + t1;
111 lo = t3 - hi + t1 + t2;
120112
121 return val_lo + val_hi;
113 /* log2(r+1) = r/ln2 + r^2*poly(r). */
114 /* Evaluation is optimized assuming superscalar pipelined execution. */
115 r2 = r * r; /* rounding error: 0x1p-54/N^2. */
116 r4 = r2 * r2;
117 /* Worst-case error if |y| > 0x1p-4: 0.547 ULP (0.550 ULP without fma).
118 ~ 0.5 + 2/N/ln2 + abs-poly-error*0x1p56 ULP (+ 0.003 ULP without fma). */
119 p = A[0] + r * A[1] + r2 * (A[2] + r * A[3]) + r4 * (A[4] + r * A[5]);
120 y = lo + r2 * p + hi;
121 return eval_as_double(y);
122122}
lib/libc/musl/src/math/log2_data.c created+201
......@@ -0,0 +1,201 @@
1/*
2 * Data for log2.
3 *
4 * Copyright (c) 2018, Arm Limited.
5 * SPDX-License-Identifier: MIT
6 */
7
8#include "log2_data.h"
9
10#define N (1 << LOG2_TABLE_BITS)
11
12const struct log2_data __log2_data = {
13// First coefficient: 0x1.71547652b82fe1777d0ffda0d24p0
14.invln2hi = 0x1.7154765200000p+0,
15.invln2lo = 0x1.705fc2eefa200p-33,
16.poly1 = {
17// relative error: 0x1.2fad8188p-63
18// in -0x1.5b51p-5 0x1.6ab2p-5
19-0x1.71547652b82fep-1,
200x1.ec709dc3a03f7p-2,
21-0x1.71547652b7c3fp-2,
220x1.2776c50f05be4p-2,
23-0x1.ec709dd768fe5p-3,
240x1.a61761ec4e736p-3,
25-0x1.7153fbc64a79bp-3,
260x1.484d154f01b4ap-3,
27-0x1.289e4a72c383cp-3,
280x1.0b32f285aee66p-3,
29},
30.poly = {
31// relative error: 0x1.a72c2bf8p-58
32// abs error: 0x1.67a552c8p-66
33// in -0x1.f45p-8 0x1.f45p-8
34-0x1.71547652b8339p-1,
350x1.ec709dc3a04bep-2,
36-0x1.7154764702ffbp-2,
370x1.2776c50034c48p-2,
38-0x1.ec7b328ea92bcp-3,
390x1.a6225e117f92ep-3,
40},
41/* Algorithm:
42
43 x = 2^k z
44 log2(x) = k + log2(c) + log2(z/c)
45 log2(z/c) = poly(z/c - 1)
46
47where z is in [1.6p-1; 1.6p0] which is split into N subintervals and z falls
48into the ith one, then table entries are computed as
49
50 tab[i].invc = 1/c
51 tab[i].logc = (double)log2(c)
52 tab2[i].chi = (double)c
53 tab2[i].clo = (double)(c - (double)c)
54
55where c is near the center of the subinterval and is chosen by trying +-2^29
56floating point invc candidates around 1/center and selecting one for which
57
58 1) the rounding error in 0x1.8p10 + logc is 0,
59 2) the rounding error in z - chi - clo is < 0x1p-64 and
60 3) the rounding error in (double)log2(c) is minimized (< 0x1p-68).
61
62Note: 1) ensures that k + logc can be computed without rounding error, 2)
63ensures that z/c - 1 can be computed as (z - chi - clo)*invc with close to a
64single rounding error when there is no fast fma for z*invc - 1, 3) ensures
65that logc + poly(z/c - 1) has small error, however near x == 1 when
66|log2(x)| < 0x1p-4, this is not enough so that is special cased. */
67.tab = {
68{0x1.724286bb1acf8p+0, -0x1.1095feecdb000p-1},
69{0x1.6e1f766d2cca1p+0, -0x1.08494bd76d000p-1},
70{0x1.6a13d0e30d48ap+0, -0x1.00143aee8f800p-1},
71{0x1.661ec32d06c85p+0, -0x1.efec5360b4000p-2},
72{0x1.623fa951198f8p+0, -0x1.dfdd91ab7e000p-2},
73{0x1.5e75ba4cf026cp+0, -0x1.cffae0cc79000p-2},
74{0x1.5ac055a214fb8p+0, -0x1.c043811fda000p-2},
75{0x1.571ed0f166e1ep+0, -0x1.b0b67323ae000p-2},
76{0x1.53909590bf835p+0, -0x1.a152f5a2db000p-2},
77{0x1.5014fed61adddp+0, -0x1.9217f5af86000p-2},
78{0x1.4cab88e487bd0p+0, -0x1.8304db0719000p-2},
79{0x1.49539b4334feep+0, -0x1.74189f9a9e000p-2},
80{0x1.460cbdfafd569p+0, -0x1.6552bb5199000p-2},
81{0x1.42d664ee4b953p+0, -0x1.56b23a29b1000p-2},
82{0x1.3fb01111dd8a6p+0, -0x1.483650f5fa000p-2},
83{0x1.3c995b70c5836p+0, -0x1.39de937f6a000p-2},
84{0x1.3991c4ab6fd4ap+0, -0x1.2baa1538d6000p-2},
85{0x1.3698e0ce099b5p+0, -0x1.1d98340ca4000p-2},
86{0x1.33ae48213e7b2p+0, -0x1.0fa853a40e000p-2},
87{0x1.30d191985bdb1p+0, -0x1.01d9c32e73000p-2},
88{0x1.2e025cab271d7p+0, -0x1.e857da2fa6000p-3},
89{0x1.2b404cf13cd82p+0, -0x1.cd3c8633d8000p-3},
90{0x1.288b02c7ccb50p+0, -0x1.b26034c14a000p-3},
91{0x1.25e2263944de5p+0, -0x1.97c1c2f4fe000p-3},
92{0x1.234563d8615b1p+0, -0x1.7d6023f800000p-3},
93{0x1.20b46e33eaf38p+0, -0x1.633a71a05e000p-3},
94{0x1.1e2eefdcda3ddp+0, -0x1.494f5e9570000p-3},
95{0x1.1bb4a580b3930p+0, -0x1.2f9e424e0a000p-3},
96{0x1.19453847f2200p+0, -0x1.162595afdc000p-3},
97{0x1.16e06c0d5d73cp+0, -0x1.f9c9a75bd8000p-4},
98{0x1.1485f47b7e4c2p+0, -0x1.c7b575bf9c000p-4},
99{0x1.12358ad0085d1p+0, -0x1.960c60ff48000p-4},
100{0x1.0fef00f532227p+0, -0x1.64ce247b60000p-4},
101{0x1.0db2077d03a8fp+0, -0x1.33f78b2014000p-4},
102{0x1.0b7e6d65980d9p+0, -0x1.0387d1a42c000p-4},
103{0x1.0953efe7b408dp+0, -0x1.a6f9208b50000p-5},
104{0x1.07325cac53b83p+0, -0x1.47a954f770000p-5},
105{0x1.05197e40d1b5cp+0, -0x1.d23a8c50c0000p-6},
106{0x1.03091c1208ea2p+0, -0x1.16a2629780000p-6},
107{0x1.0101025b37e21p+0, -0x1.720f8d8e80000p-8},
108{0x1.fc07ef9caa76bp-1, 0x1.6fe53b1500000p-7},
109{0x1.f4465d3f6f184p-1, 0x1.11ccce10f8000p-5},
110{0x1.ecc079f84107fp-1, 0x1.c4dfc8c8b8000p-5},
111{0x1.e573a99975ae8p-1, 0x1.3aa321e574000p-4},
112{0x1.de5d6f0bd3de6p-1, 0x1.918a0d08b8000p-4},
113{0x1.d77b681ff38b3p-1, 0x1.e72e9da044000p-4},
114{0x1.d0cb5724de943p-1, 0x1.1dcd2507f6000p-3},
115{0x1.ca4b2dc0e7563p-1, 0x1.476ab03dea000p-3},
116{0x1.c3f8ee8d6cb51p-1, 0x1.7074377e22000p-3},
117{0x1.bdd2b4f020c4cp-1, 0x1.98ede8ba94000p-3},
118{0x1.b7d6c006015cap-1, 0x1.c0db86ad2e000p-3},
119{0x1.b20366e2e338fp-1, 0x1.e840aafcee000p-3},
120{0x1.ac57026295039p-1, 0x1.0790ab4678000p-2},
121{0x1.a6d01bc2731ddp-1, 0x1.1ac056801c000p-2},
122{0x1.a16d3bc3ff18bp-1, 0x1.2db11d4fee000p-2},
123{0x1.9c2d14967feadp-1, 0x1.406464ec58000p-2},
124{0x1.970e4f47c9902p-1, 0x1.52dbe093af000p-2},
125{0x1.920fb3982bcf2p-1, 0x1.651902050d000p-2},
126{0x1.8d30187f759f1p-1, 0x1.771d2cdeaf000p-2},
127{0x1.886e5ebb9f66dp-1, 0x1.88e9c857d9000p-2},
128{0x1.83c97b658b994p-1, 0x1.9a80155e16000p-2},
129{0x1.7f405ffc61022p-1, 0x1.abe186ed3d000p-2},
130{0x1.7ad22181415cap-1, 0x1.bd0f2aea0e000p-2},
131{0x1.767dcf99eff8cp-1, 0x1.ce0a43dbf4000p-2},
132},
133#if !__FP_FAST_FMA
134.tab2 = {
135{0x1.6200012b90a8ep-1, 0x1.904ab0644b605p-55},
136{0x1.66000045734a6p-1, 0x1.1ff9bea62f7a9p-57},
137{0x1.69fffc325f2c5p-1, 0x1.27ecfcb3c90bap-55},
138{0x1.6e00038b95a04p-1, 0x1.8ff8856739326p-55},
139{0x1.71fffe09994e3p-1, 0x1.afd40275f82b1p-55},
140{0x1.7600015590e1p-1, -0x1.2fd75b4238341p-56},
141{0x1.7a00012655bd5p-1, 0x1.808e67c242b76p-56},
142{0x1.7e0003259e9a6p-1, -0x1.208e426f622b7p-57},
143{0x1.81fffedb4b2d2p-1, -0x1.402461ea5c92fp-55},
144{0x1.860002dfafcc3p-1, 0x1.df7f4a2f29a1fp-57},
145{0x1.89ffff78c6b5p-1, -0x1.e0453094995fdp-55},
146{0x1.8e00039671566p-1, -0x1.a04f3bec77b45p-55},
147{0x1.91fffe2bf1745p-1, -0x1.7fa34400e203cp-56},
148{0x1.95fffcc5c9fd1p-1, -0x1.6ff8005a0695dp-56},
149{0x1.9a0003bba4767p-1, 0x1.0f8c4c4ec7e03p-56},
150{0x1.9dfffe7b92da5p-1, 0x1.e7fd9478c4602p-55},
151{0x1.a1fffd72efdafp-1, -0x1.a0c554dcdae7ep-57},
152{0x1.a5fffde04ff95p-1, 0x1.67da98ce9b26bp-55},
153{0x1.a9fffca5e8d2bp-1, -0x1.284c9b54c13dep-55},
154{0x1.adfffddad03eap-1, 0x1.812c8ea602e3cp-58},
155{0x1.b1ffff10d3d4dp-1, -0x1.efaddad27789cp-55},
156{0x1.b5fffce21165ap-1, 0x1.3cb1719c61237p-58},
157{0x1.b9fffd950e674p-1, 0x1.3f7d94194cep-56},
158{0x1.be000139ca8afp-1, 0x1.50ac4215d9bcp-56},
159{0x1.c20005b46df99p-1, 0x1.beea653e9c1c9p-57},
160{0x1.c600040b9f7aep-1, -0x1.c079f274a70d6p-56},
161{0x1.ca0006255fd8ap-1, -0x1.a0b4076e84c1fp-56},
162{0x1.cdfffd94c095dp-1, 0x1.8f933f99ab5d7p-55},
163{0x1.d1ffff975d6cfp-1, -0x1.82c08665fe1bep-58},
164{0x1.d5fffa2561c93p-1, -0x1.b04289bd295f3p-56},
165{0x1.d9fff9d228b0cp-1, 0x1.70251340fa236p-55},
166{0x1.de00065bc7e16p-1, -0x1.5011e16a4d80cp-56},
167{0x1.e200002f64791p-1, 0x1.9802f09ef62ep-55},
168{0x1.e600057d7a6d8p-1, -0x1.e0b75580cf7fap-56},
169{0x1.ea00027edc00cp-1, -0x1.c848309459811p-55},
170{0x1.ee0006cf5cb7cp-1, -0x1.f8027951576f4p-55},
171{0x1.f2000782b7dccp-1, -0x1.f81d97274538fp-55},
172{0x1.f6000260c450ap-1, -0x1.071002727ffdcp-59},
173{0x1.f9fffe88cd533p-1, -0x1.81bdce1fda8bp-58},
174{0x1.fdfffd50f8689p-1, 0x1.7f91acb918e6ep-55},
175{0x1.0200004292367p+0, 0x1.b7ff365324681p-54},
176{0x1.05fffe3e3d668p+0, 0x1.6fa08ddae957bp-55},
177{0x1.0a0000a85a757p+0, -0x1.7e2de80d3fb91p-58},
178{0x1.0e0001a5f3fccp+0, -0x1.1823305c5f014p-54},
179{0x1.11ffff8afbaf5p+0, -0x1.bfabb6680bac2p-55},
180{0x1.15fffe54d91adp+0, -0x1.d7f121737e7efp-54},
181{0x1.1a00011ac36e1p+0, 0x1.c000a0516f5ffp-54},
182{0x1.1e00019c84248p+0, -0x1.082fbe4da5dap-54},
183{0x1.220000ffe5e6ep+0, -0x1.8fdd04c9cfb43p-55},
184{0x1.26000269fd891p+0, 0x1.cfe2a7994d182p-55},
185{0x1.2a00029a6e6dap+0, -0x1.00273715e8bc5p-56},
186{0x1.2dfffe0293e39p+0, 0x1.b7c39dab2a6f9p-54},
187{0x1.31ffff7dcf082p+0, 0x1.df1336edc5254p-56},
188{0x1.35ffff05a8b6p+0, -0x1.e03564ccd31ebp-54},
189{0x1.3a0002e0eaeccp+0, 0x1.5f0e74bd3a477p-56},
190{0x1.3e000043bb236p+0, 0x1.c7dcb149d8833p-54},
191{0x1.4200002d187ffp+0, 0x1.e08afcf2d3d28p-56},
192{0x1.460000d387cb1p+0, 0x1.20837856599a6p-55},
193{0x1.4a00004569f89p+0, -0x1.9fa5c904fbcd2p-55},
194{0x1.4e000043543f3p+0, -0x1.81125ed175329p-56},
195{0x1.51fffcc027f0fp+0, 0x1.883d8847754dcp-54},
196{0x1.55ffffd87b36fp+0, -0x1.709e731d02807p-55},
197{0x1.59ffff21df7bap+0, 0x1.7f79f68727b02p-55},
198{0x1.5dfffebfc3481p+0, -0x1.180902e30e93ep-54},
199},
200#endif
201};
lib/libc/musl/src/math/log2_data.h created+28
......@@ -0,0 +1,28 @@
1/*
2 * Copyright (c) 2018, Arm Limited.
3 * SPDX-License-Identifier: MIT
4 */
5#ifndef _LOG2_DATA_H
6#define _LOG2_DATA_H
7
8#include <features.h>
9
10#define LOG2_TABLE_BITS 6
11#define LOG2_POLY_ORDER 7
12#define LOG2_POLY1_ORDER 11
13extern hidden const struct log2_data {
14 double invln2hi;
15 double invln2lo;
16 double poly[LOG2_POLY_ORDER - 1];
17 double poly1[LOG2_POLY1_ORDER - 1];
18 struct {
19 double invc, logc;
20 } tab[1 << LOG2_TABLE_BITS];
21#if !__FP_FAST_FMA
22 struct {
23 double chi, clo;
24 } tab2[1 << LOG2_TABLE_BITS];
25#endif
26} __log2_data;
27
28#endif
lib/libc/musl/src/math/log2f.c+56-58
......@@ -1,74 +1,72 @@
1/* origin: FreeBSD /usr/src/lib/msun/src/e_log2f.c */
21/*
3 * ====================================================
4 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
2 * Single-precision log2 function.
53 *
6 * Developed at SunPro, 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/*
13 * See comments in log2.c.
4 * Copyright (c) 2017-2018, Arm Limited.
5 * SPDX-License-Identifier: MIT
146 */
157
168#include <math.h>
179#include <stdint.h>
10#include "libm.h"
11#include "log2f_data.h"
12
13/*
14LOG2F_TABLE_BITS = 4
15LOG2F_POLY_ORDER = 4
16
17ULP error: 0.752 (nearest rounding.)
18Relative error: 1.9 * 2^-26 (before rounding.)
19*/
1820
19static const float
20ivln2hi = 1.4428710938e+00, /* 0x3fb8b000 */
21ivln2lo = -1.7605285393e-04, /* 0xb9389ad4 */
22/* |(log(1+s)-log(1-s))/s - Lg(s)| < 2**-34.24 (~[-4.95e-11, 4.97e-11]). */
23Lg1 = 0xaaaaaa.0p-24, /* 0.66666662693 */
24Lg2 = 0xccce13.0p-25, /* 0.40000972152 */
25Lg3 = 0x91e9ee.0p-25, /* 0.28498786688 */
26Lg4 = 0xf89e26.0p-26; /* 0.24279078841 */
21#define N (1 << LOG2F_TABLE_BITS)
22#define T __log2f_data.tab
23#define A __log2f_data.poly
24#define OFF 0x3f330000
2725
2826float log2f(float x)
2927{
30 union {float f; uint32_t i;} u = {x};
31 float_t hfsq,f,s,z,R,w,t1,t2,hi,lo;
32 uint32_t ix;
33 int k;
28 double_t z, r, r2, p, y, y0, invc, logc;
29 uint32_t ix, iz, top, tmp;
30 int k, i;
3431
35 ix = u.i;
36 k = 0;
37 if (ix < 0x00800000 || ix>>31) { /* x < 2**-126 */
38 if (ix<<1 == 0)
39 return -1/(x*x); /* log(+-0)=-inf */
40 if (ix>>31)
41 return (x-x)/0.0f; /* log(-#) = NaN */
42 /* subnormal number, scale up x */
43 k -= 25;
44 x *= 0x1p25f;
45 u.f = x;
46 ix = u.i;
47 } else if (ix >= 0x7f800000) {
48 return x;
49 } else if (ix == 0x3f800000)
32 ix = asuint(x);
33 /* Fix sign of zero with downward rounding when x==1. */
34 if (WANT_ROUNDING && predict_false(ix == 0x3f800000))
5035 return 0;
36 if (predict_false(ix - 0x00800000 >= 0x7f800000 - 0x00800000)) {
37 /* x < 0x1p-126 or inf or nan. */
38 if (ix * 2 == 0)
39 return __math_divzerof(1);
40 if (ix == 0x7f800000) /* log2(inf) == inf. */
41 return x;
42 if ((ix & 0x80000000) || ix * 2 >= 0xff000000)
43 return __math_invalidf(x);
44 /* x is subnormal, normalize it. */
45 ix = asuint(x * 0x1p23f);
46 ix -= 23 << 23;
47 }
5148
52 /* reduce x into [sqrt(2)/2, sqrt(2)] */
53 ix += 0x3f800000 - 0x3f3504f3;
54 k += (int)(ix>>23) - 0x7f;
55 ix = (ix&0x007fffff) + 0x3f3504f3;
56 u.i = ix;
57 x = u.f;
49 /* x = 2^k z; where z is in range [OFF,2*OFF] and exact.
50 The range is split into N subintervals.
51 The ith subinterval contains z and c is near its center. */
52 tmp = ix - OFF;
53 i = (tmp >> (23 - LOG2F_TABLE_BITS)) % N;
54 top = tmp & 0xff800000;
55 iz = ix - top;
56 k = (int32_t)tmp >> 23; /* arithmetic shift */
57 invc = T[i].invc;
58 logc = T[i].logc;
59 z = (double_t)asfloat(iz);
5860
59 f = x - 1.0f;
60 s = f/(2.0f + f);
61 z = s*s;
62 w = z*z;
63 t1= w*(Lg2+w*Lg4);
64 t2= z*(Lg1+w*Lg3);
65 R = t2 + t1;
66 hfsq = 0.5f*f*f;
61 /* log2(x) = log1p(z/c-1)/ln2 + log2(c) + k */
62 r = z * invc - 1;
63 y0 = logc + (double_t)k;
6764
68 hi = f - hfsq;
69 u.f = hi;
70 u.i &= 0xfffff000;
71 hi = u.f;
72 lo = f - hi - hfsq + s*(hfsq+R);
73 return (lo+hi)*ivln2lo + lo*ivln2hi + hi*ivln2hi + k;
65 /* Pipelined polynomial evaluation to approximate log1p(r)/ln2. */
66 r2 = r * r;
67 y = A[1] * r + A[2];
68 y = A[0] * r2 + y;
69 p = A[3] * r + y0;
70 y = y * r2 + p;
71 return eval_as_float(y);
7472}
lib/libc/musl/src/math/log2f_data.c created+33
......@@ -0,0 +1,33 @@
1/*
2 * Data definition for log2f.
3 *
4 * Copyright (c) 2017-2018, Arm Limited.
5 * SPDX-License-Identifier: MIT
6 */
7
8#include "log2f_data.h"
9
10const struct log2f_data __log2f_data = {
11 .tab = {
12 { 0x1.661ec79f8f3bep+0, -0x1.efec65b963019p-2 },
13 { 0x1.571ed4aaf883dp+0, -0x1.b0b6832d4fca4p-2 },
14 { 0x1.49539f0f010bp+0, -0x1.7418b0a1fb77bp-2 },
15 { 0x1.3c995b0b80385p+0, -0x1.39de91a6dcf7bp-2 },
16 { 0x1.30d190c8864a5p+0, -0x1.01d9bf3f2b631p-2 },
17 { 0x1.25e227b0b8eap+0, -0x1.97c1d1b3b7afp-3 },
18 { 0x1.1bb4a4a1a343fp+0, -0x1.2f9e393af3c9fp-3 },
19 { 0x1.12358f08ae5bap+0, -0x1.960cbbf788d5cp-4 },
20 { 0x1.0953f419900a7p+0, -0x1.a6f9db6475fcep-5 },
21 { 0x1p+0, 0x0p+0 },
22 { 0x1.e608cfd9a47acp-1, 0x1.338ca9f24f53dp-4 },
23 { 0x1.ca4b31f026aap-1, 0x1.476a9543891bap-3 },
24 { 0x1.b2036576afce6p-1, 0x1.e840b4ac4e4d2p-3 },
25 { 0x1.9c2d163a1aa2dp-1, 0x1.40645f0c6651cp-2 },
26 { 0x1.886e6037841edp-1, 0x1.88e9c2c1b9ff8p-2 },
27 { 0x1.767dcf5534862p-1, 0x1.ce0a44eb17bccp-2 },
28 },
29 .poly = {
30 -0x1.712b6f70a7e4dp-2, 0x1.ecabf496832ep-2, -0x1.715479ffae3dep-1,
31 0x1.715475f35c8b8p0,
32 }
33};
lib/libc/musl/src/math/log2f_data.h created+19
......@@ -0,0 +1,19 @@
1/*
2 * Copyright (c) 2017-2018, Arm Limited.
3 * SPDX-License-Identifier: MIT
4 */
5#ifndef _LOG2F_DATA_H
6#define _LOG2F_DATA_H
7
8#include <features.h>
9
10#define LOG2F_TABLE_BITS 4
11#define LOG2F_POLY_ORDER 4
12extern hidden const struct log2f_data {
13 struct {
14 double invc, logc;
15 } tab[1 << LOG2F_TABLE_BITS];
16 double poly[LOG2F_POLY_ORDER];
17} __log2f_data;
18
19#endif
lib/libc/musl/src/math/log_data.c created+328
......@@ -0,0 +1,328 @@
1/*
2 * Data for log.
3 *
4 * Copyright (c) 2018, Arm Limited.
5 * SPDX-License-Identifier: MIT
6 */
7
8#include "log_data.h"
9
10#define N (1 << LOG_TABLE_BITS)
11
12const struct log_data __log_data = {
13.ln2hi = 0x1.62e42fefa3800p-1,
14.ln2lo = 0x1.ef35793c76730p-45,
15.poly1 = {
16// relative error: 0x1.c04d76cp-63
17// in -0x1p-4 0x1.09p-4 (|log(1+x)| > 0x1p-4 outside the interval)
18-0x1p-1,
190x1.5555555555577p-2,
20-0x1.ffffffffffdcbp-3,
210x1.999999995dd0cp-3,
22-0x1.55555556745a7p-3,
230x1.24924a344de3p-3,
24-0x1.fffffa4423d65p-4,
250x1.c7184282ad6cap-4,
26-0x1.999eb43b068ffp-4,
270x1.78182f7afd085p-4,
28-0x1.5521375d145cdp-4,
29},
30.poly = {
31// relative error: 0x1.926199e8p-56
32// abs error: 0x1.882ff33p-65
33// in -0x1.fp-9 0x1.fp-9
34-0x1.0000000000001p-1,
350x1.555555551305bp-2,
36-0x1.fffffffeb459p-3,
370x1.999b324f10111p-3,
38-0x1.55575e506c89fp-3,
39},
40/* Algorithm:
41
42 x = 2^k z
43 log(x) = k ln2 + log(c) + log(z/c)
44 log(z/c) = poly(z/c - 1)
45
46where z is in [1.6p-1; 1.6p0] which is split into N subintervals and z falls
47into the ith one, then table entries are computed as
48
49 tab[i].invc = 1/c
50 tab[i].logc = (double)log(c)
51 tab2[i].chi = (double)c
52 tab2[i].clo = (double)(c - (double)c)
53
54where c is near the center of the subinterval and is chosen by trying +-2^29
55floating point invc candidates around 1/center and selecting one for which
56
57 1) the rounding error in 0x1.8p9 + logc is 0,
58 2) the rounding error in z - chi - clo is < 0x1p-66 and
59 3) the rounding error in (double)log(c) is minimized (< 0x1p-66).
60
61Note: 1) ensures that k*ln2hi + logc can be computed without rounding error,
622) ensures that z/c - 1 can be computed as (z - chi - clo)*invc with close to
63a single rounding error when there is no fast fma for z*invc - 1, 3) ensures
64that logc + poly(z/c - 1) has small error, however near x == 1 when
65|log(x)| < 0x1p-4, this is not enough so that is special cased. */
66.tab = {
67{0x1.734f0c3e0de9fp+0, -0x1.7cc7f79e69000p-2},
68{0x1.713786a2ce91fp+0, -0x1.76feec20d0000p-2},
69{0x1.6f26008fab5a0p+0, -0x1.713e31351e000p-2},
70{0x1.6d1a61f138c7dp+0, -0x1.6b85b38287800p-2},
71{0x1.6b1490bc5b4d1p+0, -0x1.65d5590807800p-2},
72{0x1.69147332f0cbap+0, -0x1.602d076180000p-2},
73{0x1.6719f18224223p+0, -0x1.5a8ca86909000p-2},
74{0x1.6524f99a51ed9p+0, -0x1.54f4356035000p-2},
75{0x1.63356aa8f24c4p+0, -0x1.4f637c36b4000p-2},
76{0x1.614b36b9ddc14p+0, -0x1.49da7fda85000p-2},
77{0x1.5f66452c65c4cp+0, -0x1.445923989a800p-2},
78{0x1.5d867b5912c4fp+0, -0x1.3edf439b0b800p-2},
79{0x1.5babccb5b90dep+0, -0x1.396ce448f7000p-2},
80{0x1.59d61f2d91a78p+0, -0x1.3401e17bda000p-2},
81{0x1.5805612465687p+0, -0x1.2e9e2ef468000p-2},
82{0x1.56397cee76bd3p+0, -0x1.2941b3830e000p-2},
83{0x1.54725e2a77f93p+0, -0x1.23ec58cda8800p-2},
84{0x1.52aff42064583p+0, -0x1.1e9e129279000p-2},
85{0x1.50f22dbb2bddfp+0, -0x1.1956d2b48f800p-2},
86{0x1.4f38f4734ded7p+0, -0x1.141679ab9f800p-2},
87{0x1.4d843cfde2840p+0, -0x1.0edd094ef9800p-2},
88{0x1.4bd3ec078a3c8p+0, -0x1.09aa518db1000p-2},
89{0x1.4a27fc3e0258ap+0, -0x1.047e65263b800p-2},
90{0x1.4880524d48434p+0, -0x1.feb224586f000p-3},
91{0x1.46dce1b192d0bp+0, -0x1.f474a7517b000p-3},
92{0x1.453d9d3391854p+0, -0x1.ea4443d103000p-3},
93{0x1.43a2744b4845ap+0, -0x1.e020d44e9b000p-3},
94{0x1.420b54115f8fbp+0, -0x1.d60a22977f000p-3},
95{0x1.40782da3ef4b1p+0, -0x1.cc00104959000p-3},
96{0x1.3ee8f5d57fe8fp+0, -0x1.c202956891000p-3},
97{0x1.3d5d9a00b4ce9p+0, -0x1.b81178d811000p-3},
98{0x1.3bd60c010c12bp+0, -0x1.ae2c9ccd3d000p-3},
99{0x1.3a5242b75dab8p+0, -0x1.a45402e129000p-3},
100{0x1.38d22cd9fd002p+0, -0x1.9a877681df000p-3},
101{0x1.3755bc5847a1cp+0, -0x1.90c6d69483000p-3},
102{0x1.35dce49ad36e2p+0, -0x1.87120a645c000p-3},
103{0x1.34679984dd440p+0, -0x1.7d68fb4143000p-3},
104{0x1.32f5cceffcb24p+0, -0x1.73cb83c627000p-3},
105{0x1.3187775a10d49p+0, -0x1.6a39a9b376000p-3},
106{0x1.301c8373e3990p+0, -0x1.60b3154b7a000p-3},
107{0x1.2eb4ebb95f841p+0, -0x1.5737d76243000p-3},
108{0x1.2d50a0219a9d1p+0, -0x1.4dc7b8fc23000p-3},
109{0x1.2bef9a8b7fd2ap+0, -0x1.4462c51d20000p-3},
110{0x1.2a91c7a0c1babp+0, -0x1.3b08abc830000p-3},
111{0x1.293726014b530p+0, -0x1.31b996b490000p-3},
112{0x1.27dfa5757a1f5p+0, -0x1.2875490a44000p-3},
113{0x1.268b39b1d3bbfp+0, -0x1.1f3b9f879a000p-3},
114{0x1.2539d838ff5bdp+0, -0x1.160c8252ca000p-3},
115{0x1.23eb7aac9083bp+0, -0x1.0ce7f57f72000p-3},
116{0x1.22a012ba940b6p+0, -0x1.03cdc49fea000p-3},
117{0x1.2157996cc4132p+0, -0x1.f57bdbc4b8000p-4},
118{0x1.201201dd2fc9bp+0, -0x1.e370896404000p-4},
119{0x1.1ecf4494d480bp+0, -0x1.d17983ef94000p-4},
120{0x1.1d8f5528f6569p+0, -0x1.bf9674ed8a000p-4},
121{0x1.1c52311577e7cp+0, -0x1.adc79202f6000p-4},
122{0x1.1b17c74cb26e9p+0, -0x1.9c0c3e7288000p-4},
123{0x1.19e010c2c1ab6p+0, -0x1.8a646b372c000p-4},
124{0x1.18ab07bb670bdp+0, -0x1.78d01b3ac0000p-4},
125{0x1.1778a25efbcb6p+0, -0x1.674f145380000p-4},
126{0x1.1648d354c31dap+0, -0x1.55e0e6d878000p-4},
127{0x1.151b990275fddp+0, -0x1.4485cdea1e000p-4},
128{0x1.13f0ea432d24cp+0, -0x1.333d94d6aa000p-4},
129{0x1.12c8b7210f9dap+0, -0x1.22079f8c56000p-4},
130{0x1.11a3028ecb531p+0, -0x1.10e4698622000p-4},
131{0x1.107fbda8434afp+0, -0x1.ffa6c6ad20000p-5},
132{0x1.0f5ee0f4e6bb3p+0, -0x1.dda8d4a774000p-5},
133{0x1.0e4065d2a9fcep+0, -0x1.bbcece4850000p-5},
134{0x1.0d244632ca521p+0, -0x1.9a1894012c000p-5},
135{0x1.0c0a77ce2981ap+0, -0x1.788583302c000p-5},
136{0x1.0af2f83c636d1p+0, -0x1.5715e67d68000p-5},
137{0x1.09ddb98a01339p+0, -0x1.35c8a49658000p-5},
138{0x1.08cabaf52e7dfp+0, -0x1.149e364154000p-5},
139{0x1.07b9f2f4e28fbp+0, -0x1.e72c082eb8000p-6},
140{0x1.06ab58c358f19p+0, -0x1.a55f152528000p-6},
141{0x1.059eea5ecf92cp+0, -0x1.63d62cf818000p-6},
142{0x1.04949cdd12c90p+0, -0x1.228fb8caa0000p-6},
143{0x1.038c6c6f0ada9p+0, -0x1.c317b20f90000p-7},
144{0x1.02865137932a9p+0, -0x1.419355daa0000p-7},
145{0x1.0182427ea7348p+0, -0x1.81203c2ec0000p-8},
146{0x1.008040614b195p+0, -0x1.0040979240000p-9},
147{0x1.fe01ff726fa1ap-1, 0x1.feff384900000p-9},
148{0x1.fa11cc261ea74p-1, 0x1.7dc41353d0000p-7},
149{0x1.f6310b081992ep-1, 0x1.3cea3c4c28000p-6},
150{0x1.f25f63ceeadcdp-1, 0x1.b9fc114890000p-6},
151{0x1.ee9c8039113e7p-1, 0x1.1b0d8ce110000p-5},
152{0x1.eae8078cbb1abp-1, 0x1.58a5bd001c000p-5},
153{0x1.e741aa29d0c9bp-1, 0x1.95c8340d88000p-5},
154{0x1.e3a91830a99b5p-1, 0x1.d276aef578000p-5},
155{0x1.e01e009609a56p-1, 0x1.07598e598c000p-4},
156{0x1.dca01e577bb98p-1, 0x1.253f5e30d2000p-4},
157{0x1.d92f20b7c9103p-1, 0x1.42edd8b380000p-4},
158{0x1.d5cac66fb5ccep-1, 0x1.606598757c000p-4},
159{0x1.d272caa5ede9dp-1, 0x1.7da76356a0000p-4},
160{0x1.cf26e3e6b2ccdp-1, 0x1.9ab434e1c6000p-4},
161{0x1.cbe6da2a77902p-1, 0x1.b78c7bb0d6000p-4},
162{0x1.c8b266d37086dp-1, 0x1.d431332e72000p-4},
163{0x1.c5894bd5d5804p-1, 0x1.f0a3171de6000p-4},
164{0x1.c26b533bb9f8cp-1, 0x1.067152b914000p-3},
165{0x1.bf583eeece73fp-1, 0x1.147858292b000p-3},
166{0x1.bc4fd75db96c1p-1, 0x1.2266ecdca3000p-3},
167{0x1.b951e0c864a28p-1, 0x1.303d7a6c55000p-3},
168{0x1.b65e2c5ef3e2cp-1, 0x1.3dfc33c331000p-3},
169{0x1.b374867c9888bp-1, 0x1.4ba366b7a8000p-3},
170{0x1.b094b211d304ap-1, 0x1.5933928d1f000p-3},
171{0x1.adbe885f2ef7ep-1, 0x1.66acd2418f000p-3},
172{0x1.aaf1d31603da2p-1, 0x1.740f8ec669000p-3},
173{0x1.a82e63fd358a7p-1, 0x1.815c0f51af000p-3},
174{0x1.a5740ef09738bp-1, 0x1.8e92954f68000p-3},
175{0x1.a2c2a90ab4b27p-1, 0x1.9bb3602f84000p-3},
176{0x1.a01a01393f2d1p-1, 0x1.a8bed1c2c0000p-3},
177{0x1.9d79f24db3c1bp-1, 0x1.b5b515c01d000p-3},
178{0x1.9ae2505c7b190p-1, 0x1.c2967ccbcc000p-3},
179{0x1.9852ef297ce2fp-1, 0x1.cf635d5486000p-3},
180{0x1.95cbaeea44b75p-1, 0x1.dc1bd3446c000p-3},
181{0x1.934c69de74838p-1, 0x1.e8c01b8cfe000p-3},
182{0x1.90d4f2f6752e6p-1, 0x1.f5509c0179000p-3},
183{0x1.8e6528effd79dp-1, 0x1.00e6c121fb800p-2},
184{0x1.8bfce9fcc007cp-1, 0x1.071b80e93d000p-2},
185{0x1.899c0dabec30ep-1, 0x1.0d46b9e867000p-2},
186{0x1.87427aa2317fbp-1, 0x1.13687334bd000p-2},
187{0x1.84f00acb39a08p-1, 0x1.1980d67234800p-2},
188{0x1.82a49e8653e55p-1, 0x1.1f8ffe0cc8000p-2},
189{0x1.8060195f40260p-1, 0x1.2595fd7636800p-2},
190{0x1.7e22563e0a329p-1, 0x1.2b9300914a800p-2},
191{0x1.7beb377dcb5adp-1, 0x1.3187210436000p-2},
192{0x1.79baa679725c2p-1, 0x1.377266dec1800p-2},
193{0x1.77907f2170657p-1, 0x1.3d54ffbaf3000p-2},
194{0x1.756cadbd6130cp-1, 0x1.432eee32fe000p-2},
195},
196#if !__FP_FAST_FMA
197.tab2 = {
198{0x1.61000014fb66bp-1, 0x1.e026c91425b3cp-56},
199{0x1.63000034db495p-1, 0x1.dbfea48005d41p-55},
200{0x1.650000d94d478p-1, 0x1.e7fa786d6a5b7p-55},
201{0x1.67000074e6fadp-1, 0x1.1fcea6b54254cp-57},
202{0x1.68ffffedf0faep-1, -0x1.c7e274c590efdp-56},
203{0x1.6b0000763c5bcp-1, -0x1.ac16848dcda01p-55},
204{0x1.6d0001e5cc1f6p-1, 0x1.33f1c9d499311p-55},
205{0x1.6efffeb05f63ep-1, -0x1.e80041ae22d53p-56},
206{0x1.710000e86978p-1, 0x1.bff6671097952p-56},
207{0x1.72ffffc67e912p-1, 0x1.c00e226bd8724p-55},
208{0x1.74fffdf81116ap-1, -0x1.e02916ef101d2p-57},
209{0x1.770000f679c9p-1, -0x1.7fc71cd549c74p-57},
210{0x1.78ffffa7ec835p-1, 0x1.1bec19ef50483p-55},
211{0x1.7affffe20c2e6p-1, -0x1.07e1729cc6465p-56},
212{0x1.7cfffed3fc9p-1, -0x1.08072087b8b1cp-55},
213{0x1.7efffe9261a76p-1, 0x1.dc0286d9df9aep-55},
214{0x1.81000049ca3e8p-1, 0x1.97fd251e54c33p-55},
215{0x1.8300017932c8fp-1, -0x1.afee9b630f381p-55},
216{0x1.850000633739cp-1, 0x1.9bfbf6b6535bcp-55},
217{0x1.87000204289c6p-1, -0x1.bbf65f3117b75p-55},
218{0x1.88fffebf57904p-1, -0x1.9006ea23dcb57p-55},
219{0x1.8b00022bc04dfp-1, -0x1.d00df38e04b0ap-56},
220{0x1.8cfffe50c1b8ap-1, -0x1.8007146ff9f05p-55},
221{0x1.8effffc918e43p-1, 0x1.3817bd07a7038p-55},
222{0x1.910001efa5fc7p-1, 0x1.93e9176dfb403p-55},
223{0x1.9300013467bb9p-1, 0x1.f804e4b980276p-56},
224{0x1.94fffe6ee076fp-1, -0x1.f7ef0d9ff622ep-55},
225{0x1.96fffde3c12d1p-1, -0x1.082aa962638bap-56},
226{0x1.98ffff4458a0dp-1, -0x1.7801b9164a8efp-55},
227{0x1.9afffdd982e3ep-1, -0x1.740e08a5a9337p-55},
228{0x1.9cfffed49fb66p-1, 0x1.fce08c19bep-60},
229{0x1.9f00020f19c51p-1, -0x1.a3faa27885b0ap-55},
230{0x1.a10001145b006p-1, 0x1.4ff489958da56p-56},
231{0x1.a300007bbf6fap-1, 0x1.cbeab8a2b6d18p-55},
232{0x1.a500010971d79p-1, 0x1.8fecadd78793p-55},
233{0x1.a70001df52e48p-1, -0x1.f41763dd8abdbp-55},
234{0x1.a90001c593352p-1, -0x1.ebf0284c27612p-55},
235{0x1.ab0002a4f3e4bp-1, -0x1.9fd043cff3f5fp-57},
236{0x1.acfffd7ae1ed1p-1, -0x1.23ee7129070b4p-55},
237{0x1.aefffee510478p-1, 0x1.a063ee00edea3p-57},
238{0x1.b0fffdb650d5bp-1, 0x1.a06c8381f0ab9p-58},
239{0x1.b2ffffeaaca57p-1, -0x1.9011e74233c1dp-56},
240{0x1.b4fffd995badcp-1, -0x1.9ff1068862a9fp-56},
241{0x1.b7000249e659cp-1, 0x1.aff45d0864f3ep-55},
242{0x1.b8ffff987164p-1, 0x1.cfe7796c2c3f9p-56},
243{0x1.bafffd204cb4fp-1, -0x1.3ff27eef22bc4p-57},
244{0x1.bcfffd2415c45p-1, -0x1.cffb7ee3bea21p-57},
245{0x1.beffff86309dfp-1, -0x1.14103972e0b5cp-55},
246{0x1.c0fffe1b57653p-1, 0x1.bc16494b76a19p-55},
247{0x1.c2ffff1fa57e3p-1, -0x1.4feef8d30c6edp-57},
248{0x1.c4fffdcbfe424p-1, -0x1.43f68bcec4775p-55},
249{0x1.c6fffed54b9f7p-1, 0x1.47ea3f053e0ecp-55},
250{0x1.c8fffeb998fd5p-1, 0x1.383068df992f1p-56},
251{0x1.cb0002125219ap-1, -0x1.8fd8e64180e04p-57},
252{0x1.ccfffdd94469cp-1, 0x1.e7ebe1cc7ea72p-55},
253{0x1.cefffeafdc476p-1, 0x1.ebe39ad9f88fep-55},
254{0x1.d1000169af82bp-1, 0x1.57d91a8b95a71p-56},
255{0x1.d30000d0ff71dp-1, 0x1.9c1906970c7dap-55},
256{0x1.d4fffea790fc4p-1, -0x1.80e37c558fe0cp-58},
257{0x1.d70002edc87e5p-1, -0x1.f80d64dc10f44p-56},
258{0x1.d900021dc82aap-1, -0x1.47c8f94fd5c5cp-56},
259{0x1.dafffd86b0283p-1, 0x1.c7f1dc521617ep-55},
260{0x1.dd000296c4739p-1, 0x1.8019eb2ffb153p-55},
261{0x1.defffe54490f5p-1, 0x1.e00d2c652cc89p-57},
262{0x1.e0fffcdabf694p-1, -0x1.f8340202d69d2p-56},
263{0x1.e2fffdb52c8ddp-1, 0x1.b00c1ca1b0864p-56},
264{0x1.e4ffff24216efp-1, 0x1.2ffa8b094ab51p-56},
265{0x1.e6fffe88a5e11p-1, -0x1.7f673b1efbe59p-58},
266{0x1.e9000119eff0dp-1, -0x1.4808d5e0bc801p-55},
267{0x1.eafffdfa51744p-1, 0x1.80006d54320b5p-56},
268{0x1.ed0001a127fa1p-1, -0x1.002f860565c92p-58},
269{0x1.ef00007babcc4p-1, -0x1.540445d35e611p-55},
270{0x1.f0ffff57a8d02p-1, -0x1.ffb3139ef9105p-59},
271{0x1.f30001ee58ac7p-1, 0x1.a81acf2731155p-55},
272{0x1.f4ffff5823494p-1, 0x1.a3f41d4d7c743p-55},
273{0x1.f6ffffca94c6bp-1, -0x1.202f41c987875p-57},
274{0x1.f8fffe1f9c441p-1, 0x1.77dd1f477e74bp-56},
275{0x1.fafffd2e0e37ep-1, -0x1.f01199a7ca331p-57},
276{0x1.fd0001c77e49ep-1, 0x1.181ee4bceacb1p-56},
277{0x1.feffff7e0c331p-1, -0x1.e05370170875ap-57},
278{0x1.00ffff465606ep+0, -0x1.a7ead491c0adap-55},
279{0x1.02ffff3867a58p+0, -0x1.77f69c3fcb2ep-54},
280{0x1.04ffffdfc0d17p+0, 0x1.7bffe34cb945bp-54},
281{0x1.0700003cd4d82p+0, 0x1.20083c0e456cbp-55},
282{0x1.08ffff9f2cbe8p+0, -0x1.dffdfbe37751ap-57},
283{0x1.0b000010cda65p+0, -0x1.13f7faee626ebp-54},
284{0x1.0d00001a4d338p+0, 0x1.07dfa79489ff7p-55},
285{0x1.0effffadafdfdp+0, -0x1.7040570d66bcp-56},
286{0x1.110000bbafd96p+0, 0x1.e80d4846d0b62p-55},
287{0x1.12ffffae5f45dp+0, 0x1.dbffa64fd36efp-54},
288{0x1.150000dd59ad9p+0, 0x1.a0077701250aep-54},
289{0x1.170000f21559ap+0, 0x1.dfdf9e2e3deeep-55},
290{0x1.18ffffc275426p+0, 0x1.10030dc3b7273p-54},
291{0x1.1b000123d3c59p+0, 0x1.97f7980030188p-54},
292{0x1.1cffff8299eb7p+0, -0x1.5f932ab9f8c67p-57},
293{0x1.1effff48ad4p+0, 0x1.37fbf9da75bebp-54},
294{0x1.210000c8b86a4p+0, 0x1.f806b91fd5b22p-54},
295{0x1.2300003854303p+0, 0x1.3ffc2eb9fbf33p-54},
296{0x1.24fffffbcf684p+0, 0x1.601e77e2e2e72p-56},
297{0x1.26ffff52921d9p+0, 0x1.ffcbb767f0c61p-56},
298{0x1.2900014933a3cp+0, -0x1.202ca3c02412bp-56},
299{0x1.2b00014556313p+0, -0x1.2808233f21f02p-54},
300{0x1.2cfffebfe523bp+0, -0x1.8ff7e384fdcf2p-55},
301{0x1.2f0000bb8ad96p+0, -0x1.5ff51503041c5p-55},
302{0x1.30ffffb7ae2afp+0, -0x1.10071885e289dp-55},
303{0x1.32ffffeac5f7fp+0, -0x1.1ff5d3fb7b715p-54},
304{0x1.350000ca66756p+0, 0x1.57f82228b82bdp-54},
305{0x1.3700011fbf721p+0, 0x1.000bac40dd5ccp-55},
306{0x1.38ffff9592fb9p+0, -0x1.43f9d2db2a751p-54},
307{0x1.3b00004ddd242p+0, 0x1.57f6b707638e1p-55},
308{0x1.3cffff5b2c957p+0, 0x1.a023a10bf1231p-56},
309{0x1.3efffeab0b418p+0, 0x1.87f6d66b152bp-54},
310{0x1.410001532aff4p+0, 0x1.7f8375f198524p-57},
311{0x1.4300017478b29p+0, 0x1.301e672dc5143p-55},
312{0x1.44fffe795b463p+0, 0x1.9ff69b8b2895ap-55},
313{0x1.46fffe80475ep+0, -0x1.5c0b19bc2f254p-54},
314{0x1.48fffef6fc1e7p+0, 0x1.b4009f23a2a72p-54},
315{0x1.4afffe5bea704p+0, -0x1.4ffb7bf0d7d45p-54},
316{0x1.4d000171027dep+0, -0x1.9c06471dc6a3dp-54},
317{0x1.4f0000ff03ee2p+0, 0x1.77f890b85531cp-54},
318{0x1.5100012dc4bd1p+0, 0x1.004657166a436p-57},
319{0x1.530001605277ap+0, -0x1.6bfcece233209p-54},
320{0x1.54fffecdb704cp+0, -0x1.902720505a1d7p-55},
321{0x1.56fffef5f54a9p+0, 0x1.bbfe60ec96412p-54},
322{0x1.5900017e61012p+0, 0x1.87ec581afef9p-55},
323{0x1.5b00003c93e92p+0, -0x1.f41080abf0ccp-54},
324{0x1.5d0001d4919bcp+0, -0x1.8812afb254729p-54},
325{0x1.5efffe7b87a89p+0, -0x1.47eb780ed6904p-54},
326},
327#endif
328};
lib/libc/musl/src/math/log_data.h created+28
......@@ -0,0 +1,28 @@
1/*
2 * Copyright (c) 2018, Arm Limited.
3 * SPDX-License-Identifier: MIT
4 */
5#ifndef _LOG_DATA_H
6#define _LOG_DATA_H
7
8#include <features.h>
9
10#define LOG_TABLE_BITS 7
11#define LOG_POLY_ORDER 6
12#define LOG_POLY1_ORDER 12
13extern hidden const struct log_data {
14 double ln2hi;
15 double ln2lo;
16 double poly[LOG_POLY_ORDER - 1]; /* First coefficient is 1. */
17 double poly1[LOG_POLY1_ORDER - 1];
18 struct {
19 double invc, logc;
20 } tab[1 << LOG_TABLE_BITS];
21#if !__FP_FAST_FMA
22 struct {
23 double chi, clo;
24 } tab2[1 << LOG_TABLE_BITS];
25#endif
26} __log_data;
27
28#endif
lib/libc/musl/src/math/logf.c+56-54
......@@ -1,69 +1,71 @@
1/* origin: FreeBSD /usr/src/lib/msun/src/e_logf.c */
21/*
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.
2 * Single-precision log function.
83 *
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 * ====================================================
4 * Copyright (c) 2017-2018, Arm Limited.
5 * SPDX-License-Identifier: MIT
146 */
157
168#include <math.h>
179#include <stdint.h>
10#include "libm.h"
11#include "logf_data.h"
12
13/*
14LOGF_TABLE_BITS = 4
15LOGF_POLY_ORDER = 4
16
17ULP error: 0.818 (nearest rounding.)
18Relative error: 1.957 * 2^-26 (before rounding.)
19*/
1820
19static const float
20ln2_hi = 6.9313812256e-01, /* 0x3f317180 */
21ln2_lo = 9.0580006145e-06, /* 0x3717f7d1 */
22/* |(log(1+s)-log(1-s))/s - Lg(s)| < 2**-34.24 (~[-4.95e-11, 4.97e-11]). */
23Lg1 = 0xaaaaaa.0p-24, /* 0.66666662693 */
24Lg2 = 0xccce13.0p-25, /* 0.40000972152 */
25Lg3 = 0x91e9ee.0p-25, /* 0.28498786688 */
26Lg4 = 0xf89e26.0p-26; /* 0.24279078841 */
21#define T __logf_data.tab
22#define A __logf_data.poly
23#define Ln2 __logf_data.ln2
24#define N (1 << LOGF_TABLE_BITS)
25#define OFF 0x3f330000
2726
2827float logf(float x)
2928{
30 union {float f; uint32_t i;} u = {x};
31 float_t hfsq,f,s,z,R,w,t1,t2,dk;
32 uint32_t ix;
33 int k;
29 double_t z, r, r2, y, y0, invc, logc;
30 uint32_t ix, iz, tmp;
31 int k, i;
3432
35 ix = u.i;
36 k = 0;
37 if (ix < 0x00800000 || ix>>31) { /* x < 2**-126 */
38 if (ix<<1 == 0)
39 return -1/(x*x); /* log(+-0)=-inf */
40 if (ix>>31)
41 return (x-x)/0.0f; /* log(-#) = NaN */
42 /* subnormal number, scale up x */
43 k -= 25;
44 x *= 0x1p25f;
45 u.f = x;
46 ix = u.i;
47 } else if (ix >= 0x7f800000) {
48 return x;
49 } else if (ix == 0x3f800000)
33 ix = asuint(x);
34 /* Fix sign of zero with downward rounding when x==1. */
35 if (WANT_ROUNDING && predict_false(ix == 0x3f800000))
5036 return 0;
37 if (predict_false(ix - 0x00800000 >= 0x7f800000 - 0x00800000)) {
38 /* x < 0x1p-126 or inf or nan. */
39 if (ix * 2 == 0)
40 return __math_divzerof(1);
41 if (ix == 0x7f800000) /* log(inf) == inf. */
42 return x;
43 if ((ix & 0x80000000) || ix * 2 >= 0xff000000)
44 return __math_invalidf(x);
45 /* x is subnormal, normalize it. */
46 ix = asuint(x * 0x1p23f);
47 ix -= 23 << 23;
48 }
49
50 /* x = 2^k z; where z is in range [OFF,2*OFF] and exact.
51 The range is split into N subintervals.
52 The ith subinterval contains z and c is near its center. */
53 tmp = ix - OFF;
54 i = (tmp >> (23 - LOGF_TABLE_BITS)) % N;
55 k = (int32_t)tmp >> 23; /* arithmetic shift */
56 iz = ix - (tmp & 0x1ff << 23);
57 invc = T[i].invc;
58 logc = T[i].logc;
59 z = (double_t)asfloat(iz);
5160
52 /* reduce x into [sqrt(2)/2, sqrt(2)] */
53 ix += 0x3f800000 - 0x3f3504f3;
54 k += (int)(ix>>23) - 0x7f;
55 ix = (ix&0x007fffff) + 0x3f3504f3;
56 u.i = ix;
57 x = u.f;
61 /* log(x) = log1p(z/c-1) + log(c) + k*Ln2 */
62 r = z * invc - 1;
63 y0 = logc + (double_t)k * Ln2;
5864
59 f = x - 1.0f;
60 s = f/(2.0f + f);
61 z = s*s;
62 w = z*z;
63 t1= w*(Lg2+w*Lg4);
64 t2= z*(Lg1+w*Lg3);
65 R = t2 + t1;
66 hfsq = 0.5f*f*f;
67 dk = k;
68 return s*(hfsq+R) + dk*ln2_lo - hfsq + f + dk*ln2_hi;
65 /* Pipelined polynomial evaluation to approximate log1p(r). */
66 r2 = r * r;
67 y = A[1] * r + A[2];
68 y = A[0] * r2 + y;
69 y = y * r2 + (y0 + r);
70 return eval_as_float(y);
6971}
lib/libc/musl/src/math/logf_data.c created+33
......@@ -0,0 +1,33 @@
1/*
2 * Data definition for logf.
3 *
4 * Copyright (c) 2017-2018, Arm Limited.
5 * SPDX-License-Identifier: MIT
6 */
7
8#include "logf_data.h"
9
10const struct logf_data __logf_data = {
11 .tab = {
12 { 0x1.661ec79f8f3bep+0, -0x1.57bf7808caadep-2 },
13 { 0x1.571ed4aaf883dp+0, -0x1.2bef0a7c06ddbp-2 },
14 { 0x1.49539f0f010bp+0, -0x1.01eae7f513a67p-2 },
15 { 0x1.3c995b0b80385p+0, -0x1.b31d8a68224e9p-3 },
16 { 0x1.30d190c8864a5p+0, -0x1.6574f0ac07758p-3 },
17 { 0x1.25e227b0b8eap+0, -0x1.1aa2bc79c81p-3 },
18 { 0x1.1bb4a4a1a343fp+0, -0x1.a4e76ce8c0e5ep-4 },
19 { 0x1.12358f08ae5bap+0, -0x1.1973c5a611cccp-4 },
20 { 0x1.0953f419900a7p+0, -0x1.252f438e10c1ep-5 },
21 { 0x1p+0, 0x0p+0 },
22 { 0x1.e608cfd9a47acp-1, 0x1.aa5aa5df25984p-5 },
23 { 0x1.ca4b31f026aap-1, 0x1.c5e53aa362eb4p-4 },
24 { 0x1.b2036576afce6p-1, 0x1.526e57720db08p-3 },
25 { 0x1.9c2d163a1aa2dp-1, 0x1.bc2860d22477p-3 },
26 { 0x1.886e6037841edp-1, 0x1.1058bc8a07ee1p-2 },
27 { 0x1.767dcf5534862p-1, 0x1.4043057b6ee09p-2 },
28 },
29 .ln2 = 0x1.62e42fefa39efp-1,
30 .poly = {
31 -0x1.00ea348b88334p-2, 0x1.5575b0be00b6ap-2, -0x1.ffffef20a4123p-2,
32 }
33};
lib/libc/musl/src/math/logf_data.h created+20
......@@ -0,0 +1,20 @@
1/*
2 * Copyright (c) 2017-2018, Arm Limited.
3 * SPDX-License-Identifier: MIT
4 */
5#ifndef _LOGF_DATA_H
6#define _LOGF_DATA_H
7
8#include <features.h>
9
10#define LOGF_TABLE_BITS 4
11#define LOGF_POLY_ORDER 4
12extern hidden const struct logf_data {
13 struct {
14 double invc, logc;
15 } tab[1 << LOGF_TABLE_BITS];
16 double ln2;
17 double poly[LOGF_POLY_ORDER - 1]; /* First order coefficient is 1. */
18} __logf_data;
19
20#endif
lib/libc/musl/src/math/pow.c+318-303
......@@ -1,328 +1,343 @@
1/* origin: FreeBSD /usr/src/lib/msun/src/e_pow.c */
21/*
3 * ====================================================
4 * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
2 * Double-precision x^y function.
53 *
6 * Permission to use, copy, modify, and distribute this
7 * software is freely granted, provided that this notice
8 * is preserved.
9 * ====================================================
10 */
11/* pow(x,y) return x**y
12 *
13 * n
14 * Method: Let x = 2 * (1+f)
15 * 1. Compute and return log2(x) in two pieces:
16 * log2(x) = w1 + w2,
17 * where w1 has 53-24 = 29 bit trailing zeros.
18 * 2. Perform y*log2(x) = n+y' by simulating muti-precision
19 * arithmetic, where |y'|<=0.5.
20 * 3. Return x**y = 2**n*exp(y'*log2)
21 *
22 * Special cases:
23 * 1. (anything) ** 0 is 1
24 * 2. 1 ** (anything) is 1
25 * 3. (anything except 1) ** NAN is NAN
26 * 4. NAN ** (anything except 0) is NAN
27 * 5. +-(|x| > 1) ** +INF is +INF
28 * 6. +-(|x| > 1) ** -INF is +0
29 * 7. +-(|x| < 1) ** +INF is +0
30 * 8. +-(|x| < 1) ** -INF is +INF
31 * 9. -1 ** +-INF is 1
32 * 10. +0 ** (+anything except 0, NAN) is +0
33 * 11. -0 ** (+anything except 0, NAN, odd integer) is +0
34 * 12. +0 ** (-anything except 0, NAN) is +INF, raise divbyzero
35 * 13. -0 ** (-anything except 0, NAN, odd integer) is +INF, raise divbyzero
36 * 14. -0 ** (+odd integer) is -0
37 * 15. -0 ** (-odd integer) is -INF, raise divbyzero
38 * 16. +INF ** (+anything except 0,NAN) is +INF
39 * 17. +INF ** (-anything except 0,NAN) is +0
40 * 18. -INF ** (+odd integer) is -INF
41 * 19. -INF ** (anything) = -0 ** (-anything), (anything except odd integer)
42 * 20. (anything) ** 1 is (anything)
43 * 21. (anything) ** -1 is 1/(anything)
44 * 22. (-anything) ** (integer) is (-1)**(integer)*(+anything**integer)
45 * 23. (-anything except 0 and inf) ** (non-integer) is NAN
46 *
47 * Accuracy:
48 * pow(x,y) returns x**y nearly rounded. In particular
49 * pow(integer,integer)
50 * always returns the correct integer provided it is
51 * representable.
52 *
53 * Constants :
54 * The hexadecimal values are the intended ones for the following
55 * constants. The decimal values may be used, provided that the
56 * compiler will convert from decimal to binary accurately enough
57 * to produce the hexadecimal values shown.
4 * Copyright (c) 2018, Arm Limited.
5 * SPDX-License-Identifier: MIT
586 */
597
8#include <math.h>
9#include <stdint.h>
6010#include "libm.h"
11#include "exp_data.h"
12#include "pow_data.h"
6113
62static const double
63bp[] = {1.0, 1.5,},
64dp_h[] = { 0.0, 5.84962487220764160156e-01,}, /* 0x3FE2B803, 0x40000000 */
65dp_l[] = { 0.0, 1.35003920212974897128e-08,}, /* 0x3E4CFDEB, 0x43CFD006 */
66two53 = 9007199254740992.0, /* 0x43400000, 0x00000000 */
67huge = 1.0e300,
68tiny = 1.0e-300,
69/* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */
70L1 = 5.99999999999994648725e-01, /* 0x3FE33333, 0x33333303 */
71L2 = 4.28571428578550184252e-01, /* 0x3FDB6DB6, 0xDB6FABFF */
72L3 = 3.33333329818377432918e-01, /* 0x3FD55555, 0x518F264D */
73L4 = 2.72728123808534006489e-01, /* 0x3FD17460, 0xA91D4101 */
74L5 = 2.30660745775561754067e-01, /* 0x3FCD864A, 0x93C9DB65 */
75L6 = 2.06975017800338417784e-01, /* 0x3FCA7E28, 0x4A454EEF */
76P1 = 1.66666666666666019037e-01, /* 0x3FC55555, 0x5555553E */
77P2 = -2.77777777770155933842e-03, /* 0xBF66C16C, 0x16BEBD93 */
78P3 = 6.61375632143793436117e-05, /* 0x3F11566A, 0xAF25DE2C */
79P4 = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */
80P5 = 4.13813679705723846039e-08, /* 0x3E663769, 0x72BEA4D0 */
81lg2 = 6.93147180559945286227e-01, /* 0x3FE62E42, 0xFEFA39EF */
82lg2_h = 6.93147182464599609375e-01, /* 0x3FE62E43, 0x00000000 */
83lg2_l = -1.90465429995776804525e-09, /* 0xBE205C61, 0x0CA86C39 */
84ovt = 8.0085662595372944372e-017, /* -(1024-log2(ovfl+.5ulp)) */
85cp = 9.61796693925975554329e-01, /* 0x3FEEC709, 0xDC3A03FD =2/(3ln2) */
86cp_h = 9.61796700954437255859e-01, /* 0x3FEEC709, 0xE0000000 =(float)cp */
87cp_l = -7.02846165095275826516e-09, /* 0xBE3E2FE0, 0x145B01F5 =tail of cp_h*/
88ivln2 = 1.44269504088896338700e+00, /* 0x3FF71547, 0x652B82FE =1/ln2 */
89ivln2_h = 1.44269502162933349609e+00, /* 0x3FF71547, 0x60000000 =24b 1/ln2*/
90ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/
14/*
15Worst-case error: 0.54 ULP (~= ulperr_exp + 1024*Ln2*relerr_log*2^53)
16relerr_log: 1.3 * 2^-68 (Relative error of log, 1.5 * 2^-68 without fma)
17ulperr_exp: 0.509 ULP (ULP error of exp, 0.511 ULP without fma)
18*/
9119
92double pow(double x, double y)
20#define T __pow_log_data.tab
21#define A __pow_log_data.poly
22#define Ln2hi __pow_log_data.ln2hi
23#define Ln2lo __pow_log_data.ln2lo
24#define N (1 << POW_LOG_TABLE_BITS)
25#define OFF 0x3fe6955500000000
26
27/* Top 12 bits of a double (sign and exponent bits). */
28static inline uint32_t top12(double x)
9329{
94 double z,ax,z_h,z_l,p_h,p_l;
95 double y1,t1,t2,r,s,t,u,v,w;
96 int32_t i,j,k,yisint,n;
97 int32_t hx,hy,ix,iy;
98 uint32_t lx,ly;
30 return asuint64(x) >> 52;
31}
9932
100 EXTRACT_WORDS(hx, lx, x);
101 EXTRACT_WORDS(hy, ly, y);
102 ix = hx & 0x7fffffff;
103 iy = hy & 0x7fffffff;
33/* Compute y+TAIL = log(x) where the rounded result is y and TAIL has about
34 additional 15 bits precision. IX is the bit representation of x, but
35 normalized in the subnormal range using the sign bit for the exponent. */
36static inline double_t log_inline(uint64_t ix, double_t *tail)
37{
38 /* double_t for better performance on targets with FLT_EVAL_METHOD==2. */
39 double_t z, r, y, invc, logc, logctail, kd, hi, t1, t2, lo, lo1, lo2, p;
40 uint64_t iz, tmp;
41 int k, i;
10442
105 /* x**0 = 1, even if x is NaN */
106 if ((iy|ly) == 0)
107 return 1.0;
108 /* 1**y = 1, even if y is NaN */
109 if (hx == 0x3ff00000 && lx == 0)
110 return 1.0;
111 /* NaN if either arg is NaN */
112 if (ix > 0x7ff00000 || (ix == 0x7ff00000 && lx != 0) ||
113 iy > 0x7ff00000 || (iy == 0x7ff00000 && ly != 0))
114 return x + y;
43 /* x = 2^k z; where z is in range [OFF,2*OFF) and exact.
44 The range is split into N subintervals.
45 The ith subinterval contains z and c is near its center. */
46 tmp = ix - OFF;
47 i = (tmp >> (52 - POW_LOG_TABLE_BITS)) % N;
48 k = (int64_t)tmp >> 52; /* arithmetic shift */
49 iz = ix - (tmp & 0xfffULL << 52);
50 z = asdouble(iz);
51 kd = (double_t)k;
11552
116 /* determine if y is an odd int when x < 0
117 * yisint = 0 ... y is not an integer
118 * yisint = 1 ... y is an odd int
119 * yisint = 2 ... y is an even int
120 */
121 yisint = 0;
122 if (hx < 0) {
123 if (iy >= 0x43400000)
124 yisint = 2; /* even integer y */
125 else if (iy >= 0x3ff00000) {
126 k = (iy>>20) - 0x3ff; /* exponent */
127 if (k > 20) {
128 uint32_t j = ly>>(52-k);
129 if ((j<<(52-k)) == ly)
130 yisint = 2 - (j&1);
131 } else if (ly == 0) {
132 uint32_t j = iy>>(20-k);
133 if ((j<<(20-k)) == iy)
134 yisint = 2 - (j&1);
135 }
136 }
137 }
53 /* log(x) = k*Ln2 + log(c) + log1p(z/c-1). */
54 invc = T[i].invc;
55 logc = T[i].logc;
56 logctail = T[i].logctail;
13857
139 /* special value of y */
140 if (ly == 0) {
141 if (iy == 0x7ff00000) { /* y is +-inf */
142 if (((ix-0x3ff00000)|lx) == 0) /* (-1)**+-inf is 1 */
143 return 1.0;
144 else if (ix >= 0x3ff00000) /* (|x|>1)**+-inf = inf,0 */
145 return hy >= 0 ? y : 0.0;
146 else /* (|x|<1)**+-inf = 0,inf */
147 return hy >= 0 ? 0.0 : -y;
148 }
149 if (iy == 0x3ff00000) { /* y is +-1 */
150 if (hy >= 0)
151 return x;
152 y = 1/x;
153#if FLT_EVAL_METHOD!=0
154 {
155 union {double f; uint64_t i;} u = {y};
156 uint64_t i = u.i & -1ULL/2;
157 if (i>>52 == 0 && (i&(i-1)))
158 FORCE_EVAL((float)y);
159 }
58 /* Note: 1/c is j/N or j/N/2 where j is an integer in [N,2N) and
59 |z/c - 1| < 1/N, so r = z/c - 1 is exactly representible. */
60#if __FP_FAST_FMA
61 r = __builtin_fma(z, invc, -1.0);
62#else
63 /* Split z such that rhi, rlo and rhi*rhi are exact and |rlo| <= |r|. */
64 double_t zhi = asdouble((iz + (1ULL << 31)) & (-1ULL << 32));
65 double_t zlo = z - zhi;
66 double_t rhi = zhi * invc - 1.0;
67 double_t rlo = zlo * invc;
68 r = rhi + rlo;
16069#endif
161 return y;
162 }
163 if (hy == 0x40000000) /* y is 2 */
164 return x*x;
165 if (hy == 0x3fe00000) { /* y is 0.5 */
166 if (hx >= 0) /* x >= +0 */
167 return sqrt(x);
168 }
70
71 /* k*Ln2 + log(c) + r. */
72 t1 = kd * Ln2hi + logc;
73 t2 = t1 + r;
74 lo1 = kd * Ln2lo + logctail;
75 lo2 = t1 - t2 + r;
76
77 /* Evaluation is optimized assuming superscalar pipelined execution. */
78 double_t ar, ar2, ar3, lo3, lo4;
79 ar = A[0] * r; /* A[0] = -0.5. */
80 ar2 = r * ar;
81 ar3 = r * ar2;
82 /* k*Ln2 + log(c) + r + A[0]*r*r. */
83#if __FP_FAST_FMA
84 hi = t2 + ar2;
85 lo3 = __builtin_fma(ar, r, -ar2);
86 lo4 = t2 - hi + ar2;
87#else
88 double_t arhi = A[0] * rhi;
89 double_t arhi2 = rhi * arhi;
90 hi = t2 + arhi2;
91 lo3 = rlo * (ar + arhi);
92 lo4 = t2 - hi + arhi2;
93#endif
94 /* p = log1p(r) - r - A[0]*r*r. */
95 p = (ar3 * (A[1] + r * A[2] +
96 ar2 * (A[3] + r * A[4] + ar2 * (A[5] + r * A[6]))));
97 lo = lo1 + lo2 + lo3 + lo4 + p;
98 y = hi + lo;
99 *tail = hi - y + lo;
100 return y;
101}
102
103#undef N
104#undef T
105#define N (1 << EXP_TABLE_BITS)
106#define InvLn2N __exp_data.invln2N
107#define NegLn2hiN __exp_data.negln2hiN
108#define NegLn2loN __exp_data.negln2loN
109#define Shift __exp_data.shift
110#define T __exp_data.tab
111#define C2 __exp_data.poly[5 - EXP_POLY_ORDER]
112#define C3 __exp_data.poly[6 - EXP_POLY_ORDER]
113#define C4 __exp_data.poly[7 - EXP_POLY_ORDER]
114#define C5 __exp_data.poly[8 - EXP_POLY_ORDER]
115#define C6 __exp_data.poly[9 - EXP_POLY_ORDER]
116
117/* Handle cases that may overflow or underflow when computing the result that
118 is scale*(1+TMP) without intermediate rounding. The bit representation of
119 scale is in SBITS, however it has a computed exponent that may have
120 overflown into the sign bit so that needs to be adjusted before using it as
121 a double. (int32_t)KI is the k used in the argument reduction and exponent
122 adjustment of scale, positive k here means the result may overflow and
123 negative k means the result may underflow. */
124static inline double specialcase(double_t tmp, uint64_t sbits, uint64_t ki)
125{
126 double_t scale, y;
127
128 if ((ki & 0x80000000) == 0) {
129 /* k > 0, the exponent of scale might have overflowed by <= 460. */
130 sbits -= 1009ull << 52;
131 scale = asdouble(sbits);
132 y = 0x1p1009 * (scale + scale * tmp);
133 return eval_as_double(y);
134 }
135 /* k < 0, need special care in the subnormal range. */
136 sbits += 1022ull << 52;
137 /* Note: sbits is signed scale. */
138 scale = asdouble(sbits);
139 y = scale + scale * tmp;
140 if (fabs(y) < 1.0) {
141 /* Round y to the right precision before scaling it into the subnormal
142 range to avoid double rounding that can cause 0.5+E/2 ulp error where
143 E is the worst-case ulp error outside the subnormal range. So this
144 is only useful if the goal is better than 1 ulp worst-case error. */
145 double_t hi, lo, one = 1.0;
146 if (y < 0.0)
147 one = -1.0;
148 lo = scale - y + scale * tmp;
149 hi = one + y;
150 lo = one - hi + y + lo;
151 y = eval_as_double(hi + lo) - one;
152 /* Fix the sign of 0. */
153 if (y == 0.0)
154 y = asdouble(sbits & 0x8000000000000000);
155 /* The underflow exception needs to be signaled explicitly. */
156 fp_force_eval(fp_barrier(0x1p-1022) * 0x1p-1022);
169157 }
158 y = 0x1p-1022 * y;
159 return eval_as_double(y);
160}
170161
171 ax = fabs(x);
172 /* special value of x */
173 if (lx == 0) {
174 if (ix == 0x7ff00000 || ix == 0 || ix == 0x3ff00000) { /* x is +-0,+-inf,+-1 */
175 z = ax;
176 if (hy < 0) /* z = (1/|x|) */
177 z = 1.0/z;
178 if (hx < 0) {
179 if (((ix-0x3ff00000)|yisint) == 0) {
180 z = (z-z)/(z-z); /* (-1)**non-int is NaN */
181 } else if (yisint == 1)
182 z = -z; /* (x<0)**odd = -(|x|**odd) */
183 }
184 return z;
162#define SIGN_BIAS (0x800 << EXP_TABLE_BITS)
163
164/* Computes sign*exp(x+xtail) where |xtail| < 2^-8/N and |xtail| <= |x|.
165 The sign_bias argument is SIGN_BIAS or 0 and sets the sign to -1 or 1. */
166static inline double exp_inline(double_t x, double_t xtail, uint32_t sign_bias)
167{
168 uint32_t abstop;
169 uint64_t ki, idx, top, sbits;
170 /* double_t for better performance on targets with FLT_EVAL_METHOD==2. */
171 double_t kd, z, r, r2, scale, tail, tmp;
172
173 abstop = top12(x) & 0x7ff;
174 if (predict_false(abstop - top12(0x1p-54) >=
175 top12(512.0) - top12(0x1p-54))) {
176 if (abstop - top12(0x1p-54) >= 0x80000000) {
177 /* Avoid spurious underflow for tiny x. */
178 /* Note: 0 is common input. */
179 double_t one = WANT_ROUNDING ? 1.0 + x : 1.0;
180 return sign_bias ? -one : one;
181 }
182 if (abstop >= top12(1024.0)) {
183 /* Note: inf and nan are already handled. */
184 if (asuint64(x) >> 63)
185 return __math_uflow(sign_bias);
186 else
187 return __math_oflow(sign_bias);
185188 }
189 /* Large x is special cased below. */
190 abstop = 0;
186191 }
187192
188 s = 1.0; /* sign of result */
189 if (hx < 0) {
190 if (yisint == 0) /* (x<0)**(non-int) is NaN */
191 return (x-x)/(x-x);
192 if (yisint == 1) /* (x<0)**(odd int) */
193 s = -1.0;
194 }
193 /* exp(x) = 2^(k/N) * exp(r), with exp(r) in [2^(-1/2N),2^(1/2N)]. */
194 /* x = ln2/N*k + r, with int k and r in [-ln2/2N, ln2/2N]. */
195 z = InvLn2N * x;
196#if TOINT_INTRINSICS
197 kd = roundtoint(z);
198 ki = converttoint(z);
199#elif EXP_USE_TOINT_NARROW
200 /* z - kd is in [-0.5-2^-16, 0.5] in all rounding modes. */
201 kd = eval_as_double(z + Shift);
202 ki = asuint64(kd) >> 16;
203 kd = (double_t)(int32_t)ki;
204#else
205 /* z - kd is in [-1, 1] in non-nearest rounding modes. */
206 kd = eval_as_double(z + Shift);
207 ki = asuint64(kd);
208 kd -= Shift;
209#endif
210 r = x + kd * NegLn2hiN + kd * NegLn2loN;
211 /* The code assumes 2^-200 < |xtail| < 2^-8/N. */
212 r += xtail;
213 /* 2^(k/N) ~= scale * (1 + tail). */
214 idx = 2 * (ki % N);
215 top = (ki + sign_bias) << (52 - EXP_TABLE_BITS);
216 tail = asdouble(T[idx]);
217 /* This is only a valid scale when -1023*N < k < 1024*N. */
218 sbits = T[idx + 1] + top;
219 /* exp(x) = 2^(k/N) * exp(r) ~= scale + scale * (tail + exp(r) - 1). */
220 /* Evaluation is optimized assuming superscalar pipelined execution. */
221 r2 = r * r;
222 /* Without fma the worst case error is 0.25/N ulp larger. */
223 /* Worst case error is less than 0.5+1.11/N+(abs poly error * 2^53) ulp. */
224 tmp = tail + r + r2 * (C2 + r * C3) + r2 * r2 * (C4 + r * C5);
225 if (predict_false(abstop == 0))
226 return specialcase(tmp, sbits, ki);
227 scale = asdouble(sbits);
228 /* Note: tmp == 0 or |tmp| > 2^-200 and scale > 2^-739, so there
229 is no spurious underflow here even without fma. */
230 return eval_as_double(scale + scale * tmp);
231}
195232
196 /* |y| is huge */
197 if (iy > 0x41e00000) { /* if |y| > 2**31 */
198 if (iy > 0x43f00000) { /* if |y| > 2**64, must o/uflow */
199 if (ix <= 0x3fefffff)
200 return hy < 0 ? huge*huge : tiny*tiny;
201 if (ix >= 0x3ff00000)
202 return hy > 0 ? huge*huge : tiny*tiny;
233/* Returns 0 if not int, 1 if odd int, 2 if even int. The argument is
234 the bit representation of a non-zero finite floating-point value. */
235static inline int checkint(uint64_t iy)
236{
237 int e = iy >> 52 & 0x7ff;
238 if (e < 0x3ff)
239 return 0;
240 if (e > 0x3ff + 52)
241 return 2;
242 if (iy & ((1ULL << (0x3ff + 52 - e)) - 1))
243 return 0;
244 if (iy & (1ULL << (0x3ff + 52 - e)))
245 return 1;
246 return 2;
247}
248
249/* Returns 1 if input is the bit representation of 0, infinity or nan. */
250static inline int zeroinfnan(uint64_t i)
251{
252 return 2 * i - 1 >= 2 * asuint64(INFINITY) - 1;
253}
254
255double pow(double x, double y)
256{
257 uint32_t sign_bias = 0;
258 uint64_t ix, iy;
259 uint32_t topx, topy;
260
261 ix = asuint64(x);
262 iy = asuint64(y);
263 topx = top12(x);
264 topy = top12(y);
265 if (predict_false(topx - 0x001 >= 0x7ff - 0x001 ||
266 (topy & 0x7ff) - 0x3be >= 0x43e - 0x3be)) {
267 /* Note: if |y| > 1075 * ln2 * 2^53 ~= 0x1.749p62 then pow(x,y) = inf/0
268 and if |y| < 2^-54 / 1075 ~= 0x1.e7b6p-65 then pow(x,y) = +-1. */
269 /* Special cases: (x < 0x1p-126 or inf or nan) or
270 (|y| < 0x1p-65 or |y| >= 0x1p63 or nan). */
271 if (predict_false(zeroinfnan(iy))) {
272 if (2 * iy == 0)
273 return issignaling_inline(x) ? x + y : 1.0;
274 if (ix == asuint64(1.0))
275 return issignaling_inline(y) ? x + y : 1.0;
276 if (2 * ix > 2 * asuint64(INFINITY) ||
277 2 * iy > 2 * asuint64(INFINITY))
278 return x + y;
279 if (2 * ix == 2 * asuint64(1.0))
280 return 1.0;
281 if ((2 * ix < 2 * asuint64(1.0)) == !(iy >> 63))
282 return 0.0; /* |x|<1 && y==inf or |x|>1 && y==-inf. */
283 return y * y;
203284 }
204 /* over/underflow if x is not close to one */
205 if (ix < 0x3fefffff)
206 return hy < 0 ? s*huge*huge : s*tiny*tiny;
207 if (ix > 0x3ff00000)
208 return hy > 0 ? s*huge*huge : s*tiny*tiny;
209 /* now |1-x| is tiny <= 2**-20, suffice to compute
210 log(x) by x-x^2/2+x^3/3-x^4/4 */
211 t = ax - 1.0; /* t has 20 trailing zeros */
212 w = (t*t)*(0.5 - t*(0.3333333333333333333333-t*0.25));
213 u = ivln2_h*t; /* ivln2_h has 21 sig. bits */
214 v = t*ivln2_l - w*ivln2;
215 t1 = u + v;
216 SET_LOW_WORD(t1, 0);
217 t2 = v - (t1-u);
218 } else {
219 double ss,s2,s_h,s_l,t_h,t_l;
220 n = 0;
221 /* take care subnormal number */
222 if (ix < 0x00100000) {
223 ax *= two53;
224 n -= 53;
225 GET_HIGH_WORD(ix,ax);
285 if (predict_false(zeroinfnan(ix))) {
286 double_t x2 = x * x;
287 if (ix >> 63 && checkint(iy) == 1)
288 x2 = -x2;
289 /* Without the barrier some versions of clang hoist the 1/x2 and
290 thus division by zero exception can be signaled spuriously. */
291 return iy >> 63 ? fp_barrier(1 / x2) : x2;
226292 }
227 n += ((ix)>>20) - 0x3ff;
228 j = ix & 0x000fffff;
229 /* determine interval */
230 ix = j | 0x3ff00000; /* normalize ix */
231 if (j <= 0x3988E) /* |x|<sqrt(3/2) */
232 k = 0;
233 else if (j < 0xBB67A) /* |x|<sqrt(3) */
234 k = 1;
235 else {
236 k = 0;
237 n += 1;
238 ix -= 0x00100000;
293 /* Here x and y are non-zero finite. */
294 if (ix >> 63) {
295 /* Finite x < 0. */
296 int yint = checkint(iy);
297 if (yint == 0)
298 return __math_invalid(x);
299 if (yint == 1)
300 sign_bias = SIGN_BIAS;
301 ix &= 0x7fffffffffffffff;
302 topx &= 0x7ff;
303 }
304 if ((topy & 0x7ff) - 0x3be >= 0x43e - 0x3be) {
305 /* Note: sign_bias == 0 here because y is not odd. */
306 if (ix == asuint64(1.0))
307 return 1.0;
308 if ((topy & 0x7ff) < 0x3be) {
309 /* |y| < 2^-65, x^y ~= 1 + y*log(x). */
310 if (WANT_ROUNDING)
311 return ix > asuint64(1.0) ? 1.0 + y :
312 1.0 - y;
313 else
314 return 1.0;
315 }
316 return (ix > asuint64(1.0)) == (topy < 0x800) ?
317 __math_oflow(0) :
318 __math_uflow(0);
319 }
320 if (topx == 0) {
321 /* Normalize subnormal x so exponent becomes negative. */
322 ix = asuint64(x * 0x1p52);
323 ix &= 0x7fffffffffffffff;
324 ix -= 52ULL << 52;
239325 }
240 SET_HIGH_WORD(ax, ix);
241
242 /* compute ss = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5) */
243 u = ax - bp[k]; /* bp[0]=1.0, bp[1]=1.5 */
244 v = 1.0/(ax+bp[k]);
245 ss = u*v;
246 s_h = ss;
247 SET_LOW_WORD(s_h, 0);
248 /* t_h=ax+bp[k] High */
249 t_h = 0.0;
250 SET_HIGH_WORD(t_h, ((ix>>1)|0x20000000) + 0x00080000 + (k<<18));
251 t_l = ax - (t_h-bp[k]);
252 s_l = v*((u-s_h*t_h)-s_h*t_l);
253 /* compute log(ax) */
254 s2 = ss*ss;
255 r = s2*s2*(L1+s2*(L2+s2*(L3+s2*(L4+s2*(L5+s2*L6)))));
256 r += s_l*(s_h+ss);
257 s2 = s_h*s_h;
258 t_h = 3.0 + s2 + r;
259 SET_LOW_WORD(t_h, 0);
260 t_l = r - ((t_h-3.0)-s2);
261 /* u+v = ss*(1+...) */
262 u = s_h*t_h;
263 v = s_l*t_h + t_l*ss;
264 /* 2/(3log2)*(ss+...) */
265 p_h = u + v;
266 SET_LOW_WORD(p_h, 0);
267 p_l = v - (p_h-u);
268 z_h = cp_h*p_h; /* cp_h+cp_l = 2/(3*log2) */
269 z_l = cp_l*p_h+p_l*cp + dp_l[k];
270 /* log2(ax) = (ss+..)*2/(3*log2) = n + dp_h + z_h + z_l */
271 t = (double)n;
272 t1 = ((z_h + z_l) + dp_h[k]) + t;
273 SET_LOW_WORD(t1, 0);
274 t2 = z_l - (((t1 - t) - dp_h[k]) - z_h);
275326 }
276327
277 /* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */
278 y1 = y;
279 SET_LOW_WORD(y1, 0);
280 p_l = (y-y1)*t1 + y*t2;
281 p_h = y1*t1;
282 z = p_l + p_h;
283 EXTRACT_WORDS(j, i, z);
284 if (j >= 0x40900000) { /* z >= 1024 */
285 if (((j-0x40900000)|i) != 0) /* if z > 1024 */
286 return s*huge*huge; /* overflow */
287 if (p_l + ovt > z - p_h)
288 return s*huge*huge; /* overflow */
289 } else if ((j&0x7fffffff) >= 0x4090cc00) { /* z <= -1075 */ // FIXME: instead of abs(j) use unsigned j
290 if (((j-0xc090cc00)|i) != 0) /* z < -1075 */
291 return s*tiny*tiny; /* underflow */
292 if (p_l <= z - p_h)
293 return s*tiny*tiny; /* underflow */
294 }
295 /*
296 * compute 2**(p_h+p_l)
297 */
298 i = j & 0x7fffffff;
299 k = (i>>20) - 0x3ff;
300 n = 0;
301 if (i > 0x3fe00000) { /* if |z| > 0.5, set n = [z+0.5] */
302 n = j + (0x00100000>>(k+1));
303 k = ((n&0x7fffffff)>>20) - 0x3ff; /* new k for n */
304 t = 0.0;
305 SET_HIGH_WORD(t, n & ~(0x000fffff>>k));
306 n = ((n&0x000fffff)|0x00100000)>>(20-k);
307 if (j < 0)
308 n = -n;
309 p_h -= t;
310 }
311 t = p_l + p_h;
312 SET_LOW_WORD(t, 0);
313 u = t*lg2_h;
314 v = (p_l-(t-p_h))*lg2 + t*lg2_l;
315 z = u + v;
316 w = v - (z-u);
317 t = z*z;
318 t1 = z - t*(P1+t*(P2+t*(P3+t*(P4+t*P5))));
319 r = (z*t1)/(t1-2.0) - (w + z*w);
320 z = 1.0 - (r-z);
321 GET_HIGH_WORD(j, z);
322 j += n<<20;
323 if ((j>>20) <= 0) /* subnormal output */
324 z = scalbn(z,n);
325 else
326 SET_HIGH_WORD(z, j);
327 return s*z;
328 double_t lo;
329 double_t hi = log_inline(ix, &lo);
330 double_t ehi, elo;
331#if __FP_FAST_FMA
332 ehi = y * hi;
333 elo = y * lo + __builtin_fma(y, hi, -ehi);
334#else
335 double_t yhi = asdouble(iy & -1ULL << 27);
336 double_t ylo = y - yhi;
337 double_t lhi = asdouble(asuint64(hi) & -1ULL << 27);
338 double_t llo = hi - lhi + lo;
339 ehi = yhi * lhi;
340 elo = ylo * lhi + y * llo; /* |elo| < |ehi| * 2^-25. */
341#endif
342 return exp_inline(ehi, elo, sign_bias);
328343}
lib/libc/musl/src/math/pow_data.c created+180
......@@ -0,0 +1,180 @@
1/*
2 * Data for the log part of pow.
3 *
4 * Copyright (c) 2018, Arm Limited.
5 * SPDX-License-Identifier: MIT
6 */
7
8#include "pow_data.h"
9
10#define N (1 << POW_LOG_TABLE_BITS)
11
12const struct pow_log_data __pow_log_data = {
13.ln2hi = 0x1.62e42fefa3800p-1,
14.ln2lo = 0x1.ef35793c76730p-45,
15.poly = {
16// relative error: 0x1.11922ap-70
17// in -0x1.6bp-8 0x1.6bp-8
18// Coefficients are scaled to match the scaling during evaluation.
19-0x1p-1,
200x1.555555555556p-2 * -2,
21-0x1.0000000000006p-2 * -2,
220x1.999999959554ep-3 * 4,
23-0x1.555555529a47ap-3 * 4,
240x1.2495b9b4845e9p-3 * -8,
25-0x1.0002b8b263fc3p-3 * -8,
26},
27/* Algorithm:
28
29 x = 2^k z
30 log(x) = k ln2 + log(c) + log(z/c)
31 log(z/c) = poly(z/c - 1)
32
33where z is in [0x1.69555p-1; 0x1.69555p0] which is split into N subintervals
34and z falls into the ith one, then table entries are computed as
35
36 tab[i].invc = 1/c
37 tab[i].logc = round(0x1p43*log(c))/0x1p43
38 tab[i].logctail = (double)(log(c) - logc)
39
40where c is chosen near the center of the subinterval such that 1/c has only a
41few precision bits so z/c - 1 is exactly representible as double:
42
43 1/c = center < 1 ? round(N/center)/N : round(2*N/center)/N/2
44
45Note: |z/c - 1| < 1/N for the chosen c, |log(c) - logc - logctail| < 0x1p-97,
46the last few bits of logc are rounded away so k*ln2hi + logc has no rounding
47error and the interval for z is selected such that near x == 1, where log(x)
48is tiny, large cancellation error is avoided in logc + poly(z/c - 1). */
49.tab = {
50#define A(a, b, c) {a, 0, b, c},
51A(0x1.6a00000000000p+0, -0x1.62c82f2b9c800p-2, 0x1.ab42428375680p-48)
52A(0x1.6800000000000p+0, -0x1.5d1bdbf580800p-2, -0x1.ca508d8e0f720p-46)
53A(0x1.6600000000000p+0, -0x1.5767717455800p-2, -0x1.362a4d5b6506dp-45)
54A(0x1.6400000000000p+0, -0x1.51aad872df800p-2, -0x1.684e49eb067d5p-49)
55A(0x1.6200000000000p+0, -0x1.4be5f95777800p-2, -0x1.41b6993293ee0p-47)
56A(0x1.6000000000000p+0, -0x1.4618bc21c6000p-2, 0x1.3d82f484c84ccp-46)
57A(0x1.5e00000000000p+0, -0x1.404308686a800p-2, 0x1.c42f3ed820b3ap-50)
58A(0x1.5c00000000000p+0, -0x1.3a64c55694800p-2, 0x1.0b1c686519460p-45)
59A(0x1.5a00000000000p+0, -0x1.347dd9a988000p-2, 0x1.5594dd4c58092p-45)
60A(0x1.5800000000000p+0, -0x1.2e8e2bae12000p-2, 0x1.67b1e99b72bd8p-45)
61A(0x1.5600000000000p+0, -0x1.2895a13de8800p-2, 0x1.5ca14b6cfb03fp-46)
62A(0x1.5600000000000p+0, -0x1.2895a13de8800p-2, 0x1.5ca14b6cfb03fp-46)
63A(0x1.5400000000000p+0, -0x1.22941fbcf7800p-2, -0x1.65a242853da76p-46)
64A(0x1.5200000000000p+0, -0x1.1c898c1699800p-2, -0x1.fafbc68e75404p-46)
65A(0x1.5000000000000p+0, -0x1.1675cababa800p-2, 0x1.f1fc63382a8f0p-46)
66A(0x1.4e00000000000p+0, -0x1.1058bf9ae4800p-2, -0x1.6a8c4fd055a66p-45)
67A(0x1.4c00000000000p+0, -0x1.0a324e2739000p-2, -0x1.c6bee7ef4030ep-47)
68A(0x1.4a00000000000p+0, -0x1.0402594b4d000p-2, -0x1.036b89ef42d7fp-48)
69A(0x1.4a00000000000p+0, -0x1.0402594b4d000p-2, -0x1.036b89ef42d7fp-48)
70A(0x1.4800000000000p+0, -0x1.fb9186d5e4000p-3, 0x1.d572aab993c87p-47)
71A(0x1.4600000000000p+0, -0x1.ef0adcbdc6000p-3, 0x1.b26b79c86af24p-45)
72A(0x1.4400000000000p+0, -0x1.e27076e2af000p-3, -0x1.72f4f543fff10p-46)
73A(0x1.4200000000000p+0, -0x1.d5c216b4fc000p-3, 0x1.1ba91bbca681bp-45)
74A(0x1.4000000000000p+0, -0x1.c8ff7c79aa000p-3, 0x1.7794f689f8434p-45)
75A(0x1.4000000000000p+0, -0x1.c8ff7c79aa000p-3, 0x1.7794f689f8434p-45)
76A(0x1.3e00000000000p+0, -0x1.bc286742d9000p-3, 0x1.94eb0318bb78fp-46)
77A(0x1.3c00000000000p+0, -0x1.af3c94e80c000p-3, 0x1.a4e633fcd9066p-52)
78A(0x1.3a00000000000p+0, -0x1.a23bc1fe2b000p-3, -0x1.58c64dc46c1eap-45)
79A(0x1.3a00000000000p+0, -0x1.a23bc1fe2b000p-3, -0x1.58c64dc46c1eap-45)
80A(0x1.3800000000000p+0, -0x1.9525a9cf45000p-3, -0x1.ad1d904c1d4e3p-45)
81A(0x1.3600000000000p+0, -0x1.87fa06520d000p-3, 0x1.bbdbf7fdbfa09p-45)
82A(0x1.3400000000000p+0, -0x1.7ab890210e000p-3, 0x1.bdb9072534a58p-45)
83A(0x1.3400000000000p+0, -0x1.7ab890210e000p-3, 0x1.bdb9072534a58p-45)
84A(0x1.3200000000000p+0, -0x1.6d60fe719d000p-3, -0x1.0e46aa3b2e266p-46)
85A(0x1.3000000000000p+0, -0x1.5ff3070a79000p-3, -0x1.e9e439f105039p-46)
86A(0x1.3000000000000p+0, -0x1.5ff3070a79000p-3, -0x1.e9e439f105039p-46)
87A(0x1.2e00000000000p+0, -0x1.526e5e3a1b000p-3, -0x1.0de8b90075b8fp-45)
88A(0x1.2c00000000000p+0, -0x1.44d2b6ccb8000p-3, 0x1.70cc16135783cp-46)
89A(0x1.2c00000000000p+0, -0x1.44d2b6ccb8000p-3, 0x1.70cc16135783cp-46)
90A(0x1.2a00000000000p+0, -0x1.371fc201e9000p-3, 0x1.178864d27543ap-48)
91A(0x1.2800000000000p+0, -0x1.29552f81ff000p-3, -0x1.48d301771c408p-45)
92A(0x1.2600000000000p+0, -0x1.1b72ad52f6000p-3, -0x1.e80a41811a396p-45)
93A(0x1.2600000000000p+0, -0x1.1b72ad52f6000p-3, -0x1.e80a41811a396p-45)
94A(0x1.2400000000000p+0, -0x1.0d77e7cd09000p-3, 0x1.a699688e85bf4p-47)
95A(0x1.2400000000000p+0, -0x1.0d77e7cd09000p-3, 0x1.a699688e85bf4p-47)
96A(0x1.2200000000000p+0, -0x1.fec9131dbe000p-4, -0x1.575545ca333f2p-45)
97A(0x1.2000000000000p+0, -0x1.e27076e2b0000p-4, 0x1.a342c2af0003cp-45)
98A(0x1.2000000000000p+0, -0x1.e27076e2b0000p-4, 0x1.a342c2af0003cp-45)
99A(0x1.1e00000000000p+0, -0x1.c5e548f5bc000p-4, -0x1.d0c57585fbe06p-46)
100A(0x1.1c00000000000p+0, -0x1.a926d3a4ae000p-4, 0x1.53935e85baac8p-45)
101A(0x1.1c00000000000p+0, -0x1.a926d3a4ae000p-4, 0x1.53935e85baac8p-45)
102A(0x1.1a00000000000p+0, -0x1.8c345d631a000p-4, 0x1.37c294d2f5668p-46)
103A(0x1.1a00000000000p+0, -0x1.8c345d631a000p-4, 0x1.37c294d2f5668p-46)
104A(0x1.1800000000000p+0, -0x1.6f0d28ae56000p-4, -0x1.69737c93373dap-45)
105A(0x1.1600000000000p+0, -0x1.51b073f062000p-4, 0x1.f025b61c65e57p-46)
106A(0x1.1600000000000p+0, -0x1.51b073f062000p-4, 0x1.f025b61c65e57p-46)
107A(0x1.1400000000000p+0, -0x1.341d7961be000p-4, 0x1.c5edaccf913dfp-45)
108A(0x1.1400000000000p+0, -0x1.341d7961be000p-4, 0x1.c5edaccf913dfp-45)
109A(0x1.1200000000000p+0, -0x1.16536eea38000p-4, 0x1.47c5e768fa309p-46)
110A(0x1.1000000000000p+0, -0x1.f0a30c0118000p-5, 0x1.d599e83368e91p-45)
111A(0x1.1000000000000p+0, -0x1.f0a30c0118000p-5, 0x1.d599e83368e91p-45)
112A(0x1.0e00000000000p+0, -0x1.b42dd71198000p-5, 0x1.c827ae5d6704cp-46)
113A(0x1.0e00000000000p+0, -0x1.b42dd71198000p-5, 0x1.c827ae5d6704cp-46)
114A(0x1.0c00000000000p+0, -0x1.77458f632c000p-5, -0x1.cfc4634f2a1eep-45)
115A(0x1.0c00000000000p+0, -0x1.77458f632c000p-5, -0x1.cfc4634f2a1eep-45)
116A(0x1.0a00000000000p+0, -0x1.39e87b9fec000p-5, 0x1.502b7f526feaap-48)
117A(0x1.0a00000000000p+0, -0x1.39e87b9fec000p-5, 0x1.502b7f526feaap-48)
118A(0x1.0800000000000p+0, -0x1.f829b0e780000p-6, -0x1.980267c7e09e4p-45)
119A(0x1.0800000000000p+0, -0x1.f829b0e780000p-6, -0x1.980267c7e09e4p-45)
120A(0x1.0600000000000p+0, -0x1.7b91b07d58000p-6, -0x1.88d5493faa639p-45)
121A(0x1.0400000000000p+0, -0x1.fc0a8b0fc0000p-7, -0x1.f1e7cf6d3a69cp-50)
122A(0x1.0400000000000p+0, -0x1.fc0a8b0fc0000p-7, -0x1.f1e7cf6d3a69cp-50)
123A(0x1.0200000000000p+0, -0x1.fe02a6b100000p-8, -0x1.9e23f0dda40e4p-46)
124A(0x1.0200000000000p+0, -0x1.fe02a6b100000p-8, -0x1.9e23f0dda40e4p-46)
125A(0x1.0000000000000p+0, 0x0.0000000000000p+0, 0x0.0000000000000p+0)
126A(0x1.0000000000000p+0, 0x0.0000000000000p+0, 0x0.0000000000000p+0)
127A(0x1.fc00000000000p-1, 0x1.0101575890000p-7, -0x1.0c76b999d2be8p-46)
128A(0x1.f800000000000p-1, 0x1.0205658938000p-6, -0x1.3dc5b06e2f7d2p-45)
129A(0x1.f400000000000p-1, 0x1.8492528c90000p-6, -0x1.aa0ba325a0c34p-45)
130A(0x1.f000000000000p-1, 0x1.0415d89e74000p-5, 0x1.111c05cf1d753p-47)
131A(0x1.ec00000000000p-1, 0x1.466aed42e0000p-5, -0x1.c167375bdfd28p-45)
132A(0x1.e800000000000p-1, 0x1.894aa149fc000p-5, -0x1.97995d05a267dp-46)
133A(0x1.e400000000000p-1, 0x1.ccb73cdddc000p-5, -0x1.a68f247d82807p-46)
134A(0x1.e200000000000p-1, 0x1.eea31c006c000p-5, -0x1.e113e4fc93b7bp-47)
135A(0x1.de00000000000p-1, 0x1.1973bd1466000p-4, -0x1.5325d560d9e9bp-45)
136A(0x1.da00000000000p-1, 0x1.3bdf5a7d1e000p-4, 0x1.cc85ea5db4ed7p-45)
137A(0x1.d600000000000p-1, 0x1.5e95a4d97a000p-4, -0x1.c69063c5d1d1ep-45)
138A(0x1.d400000000000p-1, 0x1.700d30aeac000p-4, 0x1.c1e8da99ded32p-49)
139A(0x1.d000000000000p-1, 0x1.9335e5d594000p-4, 0x1.3115c3abd47dap-45)
140A(0x1.cc00000000000p-1, 0x1.b6ac88dad6000p-4, -0x1.390802bf768e5p-46)
141A(0x1.ca00000000000p-1, 0x1.c885801bc4000p-4, 0x1.646d1c65aacd3p-45)
142A(0x1.c600000000000p-1, 0x1.ec739830a2000p-4, -0x1.dc068afe645e0p-45)
143A(0x1.c400000000000p-1, 0x1.fe89139dbe000p-4, -0x1.534d64fa10afdp-45)
144A(0x1.c000000000000p-1, 0x1.1178e8227e000p-3, 0x1.1ef78ce2d07f2p-45)
145A(0x1.be00000000000p-1, 0x1.1aa2b7e23f000p-3, 0x1.ca78e44389934p-45)
146A(0x1.ba00000000000p-1, 0x1.2d1610c868000p-3, 0x1.39d6ccb81b4a1p-47)
147A(0x1.b800000000000p-1, 0x1.365fcb0159000p-3, 0x1.62fa8234b7289p-51)
148A(0x1.b400000000000p-1, 0x1.4913d8333b000p-3, 0x1.5837954fdb678p-45)
149A(0x1.b200000000000p-1, 0x1.527e5e4a1b000p-3, 0x1.633e8e5697dc7p-45)
150A(0x1.ae00000000000p-1, 0x1.6574ebe8c1000p-3, 0x1.9cf8b2c3c2e78p-46)
151A(0x1.ac00000000000p-1, 0x1.6f0128b757000p-3, -0x1.5118de59c21e1p-45)
152A(0x1.aa00000000000p-1, 0x1.7898d85445000p-3, -0x1.c661070914305p-46)
153A(0x1.a600000000000p-1, 0x1.8beafeb390000p-3, -0x1.73d54aae92cd1p-47)
154A(0x1.a400000000000p-1, 0x1.95a5adcf70000p-3, 0x1.7f22858a0ff6fp-47)
155A(0x1.a000000000000p-1, 0x1.a93ed3c8ae000p-3, -0x1.8724350562169p-45)
156A(0x1.9e00000000000p-1, 0x1.b31d8575bd000p-3, -0x1.c358d4eace1aap-47)
157A(0x1.9c00000000000p-1, 0x1.bd087383be000p-3, -0x1.d4bc4595412b6p-45)
158A(0x1.9a00000000000p-1, 0x1.c6ffbc6f01000p-3, -0x1.1ec72c5962bd2p-48)
159A(0x1.9600000000000p-1, 0x1.db13db0d49000p-3, -0x1.aff2af715b035p-45)
160A(0x1.9400000000000p-1, 0x1.e530effe71000p-3, 0x1.212276041f430p-51)
161A(0x1.9200000000000p-1, 0x1.ef5ade4dd0000p-3, -0x1.a211565bb8e11p-51)
162A(0x1.9000000000000p-1, 0x1.f991c6cb3b000p-3, 0x1.bcbecca0cdf30p-46)
163A(0x1.8c00000000000p-1, 0x1.07138604d5800p-2, 0x1.89cdb16ed4e91p-48)
164A(0x1.8a00000000000p-1, 0x1.0c42d67616000p-2, 0x1.7188b163ceae9p-45)
165A(0x1.8800000000000p-1, 0x1.1178e8227e800p-2, -0x1.c210e63a5f01cp-45)
166A(0x1.8600000000000p-1, 0x1.16b5ccbacf800p-2, 0x1.b9acdf7a51681p-45)
167A(0x1.8400000000000p-1, 0x1.1bf99635a6800p-2, 0x1.ca6ed5147bdb7p-45)
168A(0x1.8200000000000p-1, 0x1.214456d0eb800p-2, 0x1.a87deba46baeap-47)
169A(0x1.7e00000000000p-1, 0x1.2bef07cdc9000p-2, 0x1.a9cfa4a5004f4p-45)
170A(0x1.7c00000000000p-1, 0x1.314f1e1d36000p-2, -0x1.8e27ad3213cb8p-45)
171A(0x1.7a00000000000p-1, 0x1.36b6776be1000p-2, 0x1.16ecdb0f177c8p-46)
172A(0x1.7800000000000p-1, 0x1.3c25277333000p-2, 0x1.83b54b606bd5cp-46)
173A(0x1.7600000000000p-1, 0x1.419b423d5e800p-2, 0x1.8e436ec90e09dp-47)
174A(0x1.7400000000000p-1, 0x1.4718dc271c800p-2, -0x1.f27ce0967d675p-45)
175A(0x1.7200000000000p-1, 0x1.4c9e09e173000p-2, -0x1.e20891b0ad8a4p-45)
176A(0x1.7000000000000p-1, 0x1.522ae0738a000p-2, 0x1.ebe708164c759p-45)
177A(0x1.6e00000000000p-1, 0x1.57bf753c8d000p-2, 0x1.fadedee5d40efp-46)
178A(0x1.6c00000000000p-1, 0x1.5d5bddf596000p-2, -0x1.a0b2a08a465dcp-47)
179},
180};
lib/libc/musl/src/math/pow_data.h created+22
......@@ -0,0 +1,22 @@
1/*
2 * Copyright (c) 2018, Arm Limited.
3 * SPDX-License-Identifier: MIT
4 */
5#ifndef _POW_DATA_H
6#define _POW_DATA_H
7
8#include <features.h>
9
10#define POW_LOG_TABLE_BITS 7
11#define POW_LOG_POLY_ORDER 8
12extern hidden const struct pow_log_data {
13 double ln2hi;
14 double ln2lo;
15 double poly[POW_LOG_POLY_ORDER - 1]; /* First coefficient is 1. */
16 /* Note: the pad field is unused, but allows slightly faster indexing. */
17 struct {
18 double invc, pad, logc, logctail;
19 } tab[1 << POW_LOG_TABLE_BITS];
20} __pow_log_data;
21
22#endif
lib/libc/musl/src/math/powf.c+166-240
......@@ -1,259 +1,185 @@
1/* origin: FreeBSD /usr/src/lib/msun/src/e_powf.c */
21/*
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 * ====================================================
2 * Copyright (c) 2017-2018, Arm Limited.
3 * SPDX-License-Identifier: MIT
144 */
155
6#include <math.h>
7#include <stdint.h>
168#include "libm.h"
9#include "exp2f_data.h"
10#include "powf_data.h"
1711
18static const float
19bp[] = {1.0, 1.5,},
20dp_h[] = { 0.0, 5.84960938e-01,}, /* 0x3f15c000 */
21dp_l[] = { 0.0, 1.56322085e-06,}, /* 0x35d1cfdc */
22two24 = 16777216.0, /* 0x4b800000 */
23huge = 1.0e30,
24tiny = 1.0e-30,
25/* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */
26L1 = 6.0000002384e-01, /* 0x3f19999a */
27L2 = 4.2857143283e-01, /* 0x3edb6db7 */
28L3 = 3.3333334327e-01, /* 0x3eaaaaab */
29L4 = 2.7272811532e-01, /* 0x3e8ba305 */
30L5 = 2.3066075146e-01, /* 0x3e6c3255 */
31L6 = 2.0697501302e-01, /* 0x3e53f142 */
32P1 = 1.6666667163e-01, /* 0x3e2aaaab */
33P2 = -2.7777778450e-03, /* 0xbb360b61 */
34P3 = 6.6137559770e-05, /* 0x388ab355 */
35P4 = -1.6533901999e-06, /* 0xb5ddea0e */
36P5 = 4.1381369442e-08, /* 0x3331bb4c */
37lg2 = 6.9314718246e-01, /* 0x3f317218 */
38lg2_h = 6.93145752e-01, /* 0x3f317200 */
39lg2_l = 1.42860654e-06, /* 0x35bfbe8c */
40ovt = 4.2995665694e-08, /* -(128-log2(ovfl+.5ulp)) */
41cp = 9.6179670095e-01, /* 0x3f76384f =2/(3ln2) */
42cp_h = 9.6191406250e-01, /* 0x3f764000 =12b cp */
43cp_l = -1.1736857402e-04, /* 0xb8f623c6 =tail of cp_h */
44ivln2 = 1.4426950216e+00, /* 0x3fb8aa3b =1/ln2 */
45ivln2_h = 1.4426879883e+00, /* 0x3fb8aa00 =16b 1/ln2*/
46ivln2_l = 7.0526075433e-06; /* 0x36eca570 =1/ln2 tail*/
12/*
13POWF_LOG2_POLY_ORDER = 5
14EXP2F_TABLE_BITS = 5
4715
48float powf(float x, float y)
16ULP error: 0.82 (~ 0.5 + relerr*2^24)
17relerr: 1.27 * 2^-26 (Relative error ~= 128*Ln2*relerr_log2 + relerr_exp2)
18relerr_log2: 1.83 * 2^-33 (Relative error of logx.)
19relerr_exp2: 1.69 * 2^-34 (Relative error of exp2(ylogx).)
20*/
21
22#define N (1 << POWF_LOG2_TABLE_BITS)
23#define T __powf_log2_data.tab
24#define A __powf_log2_data.poly
25#define OFF 0x3f330000
26
27/* Subnormal input is normalized so ix has negative biased exponent.
28 Output is multiplied by N (POWF_SCALE) if TOINT_INTRINICS is set. */
29static inline double_t log2_inline(uint32_t ix)
4930{
50 float z,ax,z_h,z_l,p_h,p_l;
51 float y1,t1,t2,r,s,sn,t,u,v,w;
52 int32_t i,j,k,yisint,n;
53 int32_t hx,hy,ix,iy,is;
31 double_t z, r, r2, r4, p, q, y, y0, invc, logc;
32 uint32_t iz, top, tmp;
33 int k, i;
5434
55 GET_FLOAT_WORD(hx, x);
56 GET_FLOAT_WORD(hy, y);
57 ix = hx & 0x7fffffff;
58 iy = hy & 0x7fffffff;
35 /* x = 2^k z; where z is in range [OFF,2*OFF] and exact.
36 The range is split into N subintervals.
37 The ith subinterval contains z and c is near its center. */
38 tmp = ix - OFF;
39 i = (tmp >> (23 - POWF_LOG2_TABLE_BITS)) % N;
40 top = tmp & 0xff800000;
41 iz = ix - top;
42 k = (int32_t)top >> (23 - POWF_SCALE_BITS); /* arithmetic shift */
43 invc = T[i].invc;
44 logc = T[i].logc;
45 z = (double_t)asfloat(iz);
5946
60 /* x**0 = 1, even if x is NaN */
61 if (iy == 0)
62 return 1.0f;
63 /* 1**y = 1, even if y is NaN */
64 if (hx == 0x3f800000)
65 return 1.0f;
66 /* NaN if either arg is NaN */
67 if (ix > 0x7f800000 || iy > 0x7f800000)
68 return x + y;
47 /* log2(x) = log1p(z/c-1)/ln2 + log2(c) + k */
48 r = z * invc - 1;
49 y0 = logc + (double_t)k;
6950
70 /* determine if y is an odd int when x < 0
71 * yisint = 0 ... y is not an integer
72 * yisint = 1 ... y is an odd int
73 * yisint = 2 ... y is an even int
74 */
75 yisint = 0;
76 if (hx < 0) {
77 if (iy >= 0x4b800000)
78 yisint = 2; /* even integer y */
79 else if (iy >= 0x3f800000) {
80 k = (iy>>23) - 0x7f; /* exponent */
81 j = iy>>(23-k);
82 if ((j<<(23-k)) == iy)
83 yisint = 2 - (j & 1);
84 }
85 }
51 /* Pipelined polynomial evaluation to approximate log1p(r)/ln2. */
52 r2 = r * r;
53 y = A[0] * r + A[1];
54 p = A[2] * r + A[3];
55 r4 = r2 * r2;
56 q = A[4] * r + y0;
57 q = p * r2 + q;
58 y = y * r4 + q;
59 return y;
60}
8661
87 /* special value of y */
88 if (iy == 0x7f800000) { /* y is +-inf */
89 if (ix == 0x3f800000) /* (-1)**+-inf is 1 */
90 return 1.0f;
91 else if (ix > 0x3f800000) /* (|x|>1)**+-inf = inf,0 */
92 return hy >= 0 ? y : 0.0f;
93 else /* (|x|<1)**+-inf = 0,inf */
94 return hy >= 0 ? 0.0f: -y;
95 }
96 if (iy == 0x3f800000) /* y is +-1 */
97 return hy >= 0 ? x : 1.0f/x;
98 if (hy == 0x40000000) /* y is 2 */
99 return x*x;
100 if (hy == 0x3f000000) { /* y is 0.5 */
101 if (hx >= 0) /* x >= +0 */
102 return sqrtf(x);
103 }
62#undef N
63#undef T
64#define N (1 << EXP2F_TABLE_BITS)
65#define T __exp2f_data.tab
66#define SIGN_BIAS (1 << (EXP2F_TABLE_BITS + 11))
10467
105 ax = fabsf(x);
106 /* special value of x */
107 if (ix == 0x7f800000 || ix == 0 || ix == 0x3f800000) { /* x is +-0,+-inf,+-1 */
108 z = ax;
109 if (hy < 0) /* z = (1/|x|) */
110 z = 1.0f/z;
111 if (hx < 0) {
112 if (((ix-0x3f800000)|yisint) == 0) {
113 z = (z-z)/(z-z); /* (-1)**non-int is NaN */
114 } else if (yisint == 1)
115 z = -z; /* (x<0)**odd = -(|x|**odd) */
116 }
117 return z;
118 }
68/* The output of log2 and thus the input of exp2 is either scaled by N
69 (in case of fast toint intrinsics) or not. The unscaled xd must be
70 in [-1021,1023], sign_bias sets the sign of the result. */
71static inline float exp2_inline(double_t xd, uint32_t sign_bias)
72{
73 uint64_t ki, ski, t;
74 double_t kd, z, r, r2, y, s;
11975
120 sn = 1.0f; /* sign of result */
121 if (hx < 0) {
122 if (yisint == 0) /* (x<0)**(non-int) is NaN */
123 return (x-x)/(x-x);
124 if (yisint == 1) /* (x<0)**(odd int) */
125 sn = -1.0f;
126 }
76#if TOINT_INTRINSICS
77#define C __exp2f_data.poly_scaled
78 /* N*x = k + r with r in [-1/2, 1/2] */
79 kd = roundtoint(xd); /* k */
80 ki = converttoint(xd);
81#else
82#define C __exp2f_data.poly
83#define SHIFT __exp2f_data.shift_scaled
84 /* x = k/N + r with r in [-1/(2N), 1/(2N)] */
85 kd = eval_as_double(xd + SHIFT);
86 ki = asuint64(kd);
87 kd -= SHIFT; /* k/N */
88#endif
89 r = xd - kd;
12790
128 /* |y| is huge */
129 if (iy > 0x4d000000) { /* if |y| > 2**27 */
130 /* over/underflow if x is not close to one */
131 if (ix < 0x3f7ffff8)
132 return hy < 0 ? sn*huge*huge : sn*tiny*tiny;
133 if (ix > 0x3f800007)
134 return hy > 0 ? sn*huge*huge : sn*tiny*tiny;
135 /* now |1-x| is tiny <= 2**-20, suffice to compute
136 log(x) by x-x^2/2+x^3/3-x^4/4 */
137 t = ax - 1; /* t has 20 trailing zeros */
138 w = (t*t)*(0.5f - t*(0.333333333333f - t*0.25f));
139 u = ivln2_h*t; /* ivln2_h has 16 sig. bits */
140 v = t*ivln2_l - w*ivln2;
141 t1 = u + v;
142 GET_FLOAT_WORD(is, t1);
143 SET_FLOAT_WORD(t1, is & 0xfffff000);
144 t2 = v - (t1-u);
145 } else {
146 float s2,s_h,s_l,t_h,t_l;
147 n = 0;
148 /* take care subnormal number */
149 if (ix < 0x00800000) {
150 ax *= two24;
151 n -= 24;
152 GET_FLOAT_WORD(ix, ax);
153 }
154 n += ((ix)>>23) - 0x7f;
155 j = ix & 0x007fffff;
156 /* determine interval */
157 ix = j | 0x3f800000; /* normalize ix */
158 if (j <= 0x1cc471) /* |x|<sqrt(3/2) */
159 k = 0;
160 else if (j < 0x5db3d7) /* |x|<sqrt(3) */
161 k = 1;
162 else {
163 k = 0;
164 n += 1;
165 ix -= 0x00800000;
166 }
167 SET_FLOAT_WORD(ax, ix);
91 /* exp2(x) = 2^(k/N) * 2^r ~= s * (C0*r^3 + C1*r^2 + C2*r + 1) */
92 t = T[ki % N];
93 ski = ki + sign_bias;
94 t += ski << (52 - EXP2F_TABLE_BITS);
95 s = asdouble(t);
96 z = C[0] * r + C[1];
97 r2 = r * r;
98 y = C[2] * r + 1;
99 y = z * r2 + y;
100 y = y * s;
101 return eval_as_float(y);
102}
168103
169 /* compute s = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5) */
170 u = ax - bp[k]; /* bp[0]=1.0, bp[1]=1.5 */
171 v = 1.0f/(ax+bp[k]);
172 s = u*v;
173 s_h = s;
174 GET_FLOAT_WORD(is, s_h);
175 SET_FLOAT_WORD(s_h, is & 0xfffff000);
176 /* t_h=ax+bp[k] High */
177 is = ((ix>>1) & 0xfffff000) | 0x20000000;
178 SET_FLOAT_WORD(t_h, is + 0x00400000 + (k<<21));
179 t_l = ax - (t_h - bp[k]);
180 s_l = v*((u - s_h*t_h) - s_h*t_l);
181 /* compute log(ax) */
182 s2 = s*s;
183 r = s2*s2*(L1+s2*(L2+s2*(L3+s2*(L4+s2*(L5+s2*L6)))));
184 r += s_l*(s_h+s);
185 s2 = s_h*s_h;
186 t_h = 3.0f + s2 + r;
187 GET_FLOAT_WORD(is, t_h);
188 SET_FLOAT_WORD(t_h, is & 0xfffff000);
189 t_l = r - ((t_h - 3.0f) - s2);
190 /* u+v = s*(1+...) */
191 u = s_h*t_h;
192 v = s_l*t_h + t_l*s;
193 /* 2/(3log2)*(s+...) */
194 p_h = u + v;
195 GET_FLOAT_WORD(is, p_h);
196 SET_FLOAT_WORD(p_h, is & 0xfffff000);
197 p_l = v - (p_h - u);
198 z_h = cp_h*p_h; /* cp_h+cp_l = 2/(3*log2) */
199 z_l = cp_l*p_h + p_l*cp+dp_l[k];
200 /* log2(ax) = (s+..)*2/(3*log2) = n + dp_h + z_h + z_l */
201 t = (float)n;
202 t1 = (((z_h + z_l) + dp_h[k]) + t);
203 GET_FLOAT_WORD(is, t1);
204 SET_FLOAT_WORD(t1, is & 0xfffff000);
205 t2 = z_l - (((t1 - t) - dp_h[k]) - z_h);
206 }
104/* Returns 0 if not int, 1 if odd int, 2 if even int. The argument is
105 the bit representation of a non-zero finite floating-point value. */
106static inline int checkint(uint32_t iy)
107{
108 int e = iy >> 23 & 0xff;
109 if (e < 0x7f)
110 return 0;
111 if (e > 0x7f + 23)
112 return 2;
113 if (iy & ((1 << (0x7f + 23 - e)) - 1))
114 return 0;
115 if (iy & (1 << (0x7f + 23 - e)))
116 return 1;
117 return 2;
118}
119
120static inline int zeroinfnan(uint32_t ix)
121{
122 return 2 * ix - 1 >= 2u * 0x7f800000 - 1;
123}
207124
208 /* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */
209 GET_FLOAT_WORD(is, y);
210 SET_FLOAT_WORD(y1, is & 0xfffff000);
211 p_l = (y-y1)*t1 + y*t2;
212 p_h = y1*t1;
213 z = p_l + p_h;
214 GET_FLOAT_WORD(j, z);
215 if (j > 0x43000000) /* if z > 128 */
216 return sn*huge*huge; /* overflow */
217 else if (j == 0x43000000) { /* if z == 128 */
218 if (p_l + ovt > z - p_h)
219 return sn*huge*huge; /* overflow */
220 } else if ((j&0x7fffffff) > 0x43160000) /* z < -150 */ // FIXME: check should be (uint32_t)j > 0xc3160000
221 return sn*tiny*tiny; /* underflow */
222 else if (j == 0xc3160000) { /* z == -150 */
223 if (p_l <= z-p_h)
224 return sn*tiny*tiny; /* underflow */
125float powf(float x, float y)
126{
127 uint32_t sign_bias = 0;
128 uint32_t ix, iy;
129
130 ix = asuint(x);
131 iy = asuint(y);
132 if (predict_false(ix - 0x00800000 >= 0x7f800000 - 0x00800000 ||
133 zeroinfnan(iy))) {
134 /* Either (x < 0x1p-126 or inf or nan) or (y is 0 or inf or nan). */
135 if (predict_false(zeroinfnan(iy))) {
136 if (2 * iy == 0)
137 return issignalingf_inline(x) ? x + y : 1.0f;
138 if (ix == 0x3f800000)
139 return issignalingf_inline(y) ? x + y : 1.0f;
140 if (2 * ix > 2u * 0x7f800000 ||
141 2 * iy > 2u * 0x7f800000)
142 return x + y;
143 if (2 * ix == 2 * 0x3f800000)
144 return 1.0f;
145 if ((2 * ix < 2 * 0x3f800000) == !(iy & 0x80000000))
146 return 0.0f; /* |x|<1 && y==inf or |x|>1 && y==-inf. */
147 return y * y;
148 }
149 if (predict_false(zeroinfnan(ix))) {
150 float_t x2 = x * x;
151 if (ix & 0x80000000 && checkint(iy) == 1)
152 x2 = -x2;
153 /* Without the barrier some versions of clang hoist the 1/x2 and
154 thus division by zero exception can be signaled spuriously. */
155 return iy & 0x80000000 ? fp_barrierf(1 / x2) : x2;
156 }
157 /* x and y are non-zero finite. */
158 if (ix & 0x80000000) {
159 /* Finite x < 0. */
160 int yint = checkint(iy);
161 if (yint == 0)
162 return __math_invalidf(x);
163 if (yint == 1)
164 sign_bias = SIGN_BIAS;
165 ix &= 0x7fffffff;
166 }
167 if (ix < 0x00800000) {
168 /* Normalize subnormal x so exponent becomes negative. */
169 ix = asuint(x * 0x1p23f);
170 ix &= 0x7fffffff;
171 ix -= 23 << 23;
172 }
225173 }
226 /*
227 * compute 2**(p_h+p_l)
228 */
229 i = j & 0x7fffffff;
230 k = (i>>23) - 0x7f;
231 n = 0;
232 if (i > 0x3f000000) { /* if |z| > 0.5, set n = [z+0.5] */
233 n = j + (0x00800000>>(k+1));
234 k = ((n&0x7fffffff)>>23) - 0x7f; /* new k for n */
235 SET_FLOAT_WORD(t, n & ~(0x007fffff>>k));
236 n = ((n&0x007fffff)|0x00800000)>>(23-k);
237 if (j < 0)
238 n = -n;
239 p_h -= t;
174 double_t logx = log2_inline(ix);
175 double_t ylogx = y * logx; /* cannot overflow, y is single prec. */
176 if (predict_false((asuint64(ylogx) >> 47 & 0xffff) >=
177 asuint64(126.0 * POWF_SCALE) >> 47)) {
178 /* |y*log(x)| >= 126. */
179 if (ylogx > 0x1.fffffffd1d571p+6 * POWF_SCALE)
180 return __math_oflowf(sign_bias);
181 if (ylogx <= -150.0 * POWF_SCALE)
182 return __math_uflowf(sign_bias);
240183 }
241 t = p_l + p_h;
242 GET_FLOAT_WORD(is, t);
243 SET_FLOAT_WORD(t, is & 0xffff8000);
244 u = t*lg2_h;
245 v = (p_l-(t-p_h))*lg2 + t*lg2_l;
246 z = u + v;
247 w = v - (z - u);
248 t = z*z;
249 t1 = z - t*(P1+t*(P2+t*(P3+t*(P4+t*P5))));
250 r = (z*t1)/(t1-2.0f) - (w+z*w);
251 z = 1.0f - (r - z);
252 GET_FLOAT_WORD(j, z);
253 j += n<<23;
254 if ((j>>23) <= 0) /* subnormal output */
255 z = scalbnf(z, n);
256 else
257 SET_FLOAT_WORD(z, j);
258 return sn*z;
184 return exp2_inline(ylogx, sign_bias);
259185}
lib/libc/musl/src/math/powf_data.c created+34
......@@ -0,0 +1,34 @@
1/*
2 * Data definition for powf.
3 *
4 * Copyright (c) 2017-2018, Arm Limited.
5 * SPDX-License-Identifier: MIT
6 */
7
8#include "powf_data.h"
9
10const struct powf_log2_data __powf_log2_data = {
11 .tab = {
12 { 0x1.661ec79f8f3bep+0, -0x1.efec65b963019p-2 * POWF_SCALE },
13 { 0x1.571ed4aaf883dp+0, -0x1.b0b6832d4fca4p-2 * POWF_SCALE },
14 { 0x1.49539f0f010bp+0, -0x1.7418b0a1fb77bp-2 * POWF_SCALE },
15 { 0x1.3c995b0b80385p+0, -0x1.39de91a6dcf7bp-2 * POWF_SCALE },
16 { 0x1.30d190c8864a5p+0, -0x1.01d9bf3f2b631p-2 * POWF_SCALE },
17 { 0x1.25e227b0b8eap+0, -0x1.97c1d1b3b7afp-3 * POWF_SCALE },
18 { 0x1.1bb4a4a1a343fp+0, -0x1.2f9e393af3c9fp-3 * POWF_SCALE },
19 { 0x1.12358f08ae5bap+0, -0x1.960cbbf788d5cp-4 * POWF_SCALE },
20 { 0x1.0953f419900a7p+0, -0x1.a6f9db6475fcep-5 * POWF_SCALE },
21 { 0x1p+0, 0x0p+0 * POWF_SCALE },
22 { 0x1.e608cfd9a47acp-1, 0x1.338ca9f24f53dp-4 * POWF_SCALE },
23 { 0x1.ca4b31f026aap-1, 0x1.476a9543891bap-3 * POWF_SCALE },
24 { 0x1.b2036576afce6p-1, 0x1.e840b4ac4e4d2p-3 * POWF_SCALE },
25 { 0x1.9c2d163a1aa2dp-1, 0x1.40645f0c6651cp-2 * POWF_SCALE },
26 { 0x1.886e6037841edp-1, 0x1.88e9c2c1b9ff8p-2 * POWF_SCALE },
27 { 0x1.767dcf5534862p-1, 0x1.ce0a44eb17bccp-2 * POWF_SCALE },
28 },
29 .poly = {
30 0x1.27616c9496e0bp-2 * POWF_SCALE, -0x1.71969a075c67ap-2 * POWF_SCALE,
31 0x1.ec70a6ca7baddp-2 * POWF_SCALE, -0x1.7154748bef6c8p-1 * POWF_SCALE,
32 0x1.71547652ab82bp0 * POWF_SCALE,
33 }
34};
lib/libc/musl/src/math/powf_data.h created+26
......@@ -0,0 +1,26 @@
1/*
2 * Copyright (c) 2017-2018, Arm Limited.
3 * SPDX-License-Identifier: MIT
4 */
5#ifndef _POWF_DATA_H
6#define _POWF_DATA_H
7
8#include "libm.h"
9#include "exp2f_data.h"
10
11#define POWF_LOG2_TABLE_BITS 4
12#define POWF_LOG2_POLY_ORDER 5
13#if TOINT_INTRINSICS
14#define POWF_SCALE_BITS EXP2F_TABLE_BITS
15#else
16#define POWF_SCALE_BITS 0
17#endif
18#define POWF_SCALE ((double)(1 << POWF_SCALE_BITS))
19extern hidden const struct powf_log2_data {
20 struct {
21 double invc, logc;
22 } tab[1 << POWF_LOG2_TABLE_BITS];
23 double poly[POWF_LOG2_POLY_ORDER];
24} __powf_log2_data;
25
26#endif
lib/libc/musl/src/math/riscv64/copysign.c created+15
......@@ -0,0 +1,15 @@
1#include <math.h>
2
3#if __riscv_flen >= 64
4
5double copysign(double x, double y)
6{
7 __asm__ ("fsgnj.d %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
8 return x;
9}
10
11#else
12
13#include "../copysign.c"
14
15#endif
lib/libc/musl/src/math/riscv64/copysignf.c created+15
......@@ -0,0 +1,15 @@
1#include <math.h>
2
3#if __riscv_flen >= 32
4
5float copysignf(float x, float y)
6{
7 __asm__ ("fsgnj.s %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
8 return x;
9}
10
11#else
12
13#include "../copysignf.c"
14
15#endif
lib/libc/musl/src/math/riscv64/fabs.c created+15
......@@ -0,0 +1,15 @@
1#include <math.h>
2
3#if __riscv_flen >= 64
4
5double fabs(double x)
6{
7 __asm__ ("fabs.d %0, %1" : "=f"(x) : "f"(x));
8 return x;
9}
10
11#else
12
13#include "../fabs.c"
14
15#endif
lib/libc/musl/src/math/riscv64/fabsf.c created+15
......@@ -0,0 +1,15 @@
1#include <math.h>
2
3#if __riscv_flen >= 32
4
5float fabsf(float x)
6{
7 __asm__ ("fabs.s %0, %1" : "=f"(x) : "f"(x));
8 return x;
9}
10
11#else
12
13#include "../fabsf.c"
14
15#endif
lib/libc/musl/src/math/riscv64/fma.c created+15
......@@ -0,0 +1,15 @@
1#include <math.h>
2
3#if __riscv_flen >= 64
4
5double fma(double x, double y, double z)
6{
7 __asm__ ("fmadd.d %0, %1, %2, %3" : "=f"(x) : "f"(x), "f"(y), "f"(z));
8 return x;
9}
10
11#else
12
13#include "../fma.c"
14
15#endif
lib/libc/musl/src/math/riscv64/fmaf.c created+15
......@@ -0,0 +1,15 @@
1#include <math.h>
2
3#if __riscv_flen >= 32
4
5float fmaf(float x, float y, float z)
6{
7 __asm__ ("fmadd.s %0, %1, %2, %3" : "=f"(x) : "f"(x), "f"(y), "f"(z));
8 return x;
9}
10
11#else
12
13#include "../fmaf.c"
14
15#endif
lib/libc/musl/src/math/riscv64/fmax.c created+15
......@@ -0,0 +1,15 @@
1#include <math.h>
2
3#if __riscv_flen >= 64
4
5double fmax(double x, double y)
6{
7 __asm__ ("fmax.d %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
8 return x;
9}
10
11#else
12
13#include "../fmax.c"
14
15#endif
lib/libc/musl/src/math/riscv64/fmaxf.c created+15
......@@ -0,0 +1,15 @@
1#include <math.h>
2
3#if __riscv_flen >= 32
4
5float fmaxf(float x, float y)
6{
7 __asm__ ("fmax.s %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
8 return x;
9}
10
11#else
12
13#include "../fmaxf.c"
14
15#endif
lib/libc/musl/src/math/riscv64/fmin.c created+15
......@@ -0,0 +1,15 @@
1#include <math.h>
2
3#if __riscv_flen >= 64
4
5double fmin(double x, double y)
6{
7 __asm__ ("fmin.d %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
8 return x;
9}
10
11#else
12
13#include "../fmin.c"
14
15#endif
lib/libc/musl/src/math/riscv64/fminf.c created+15
......@@ -0,0 +1,15 @@
1#include <math.h>
2
3#if __riscv_flen >= 32
4
5float fminf(float x, float y)
6{
7 __asm__ ("fmin.s %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
8 return x;
9}
10
11#else
12
13#include "../fminf.c"
14
15#endif
lib/libc/musl/src/math/riscv64/sqrt.c created+15
......@@ -0,0 +1,15 @@
1#include <math.h>
2
3#if __riscv_flen >= 64
4
5double sqrt(double x)
6{
7 __asm__ ("fsqrt.d %0, %1" : "=f"(x) : "f"(x));
8 return x;
9}
10
11#else
12
13#include "../sqrt.c"
14
15#endif
lib/libc/musl/src/math/riscv64/sqrtf.c created+15
......@@ -0,0 +1,15 @@
1#include <math.h>
2
3#if __riscv_flen >= 32
4
5float sqrtf(float x)
6{
7 __asm__ ("fsqrt.s %0, %1" : "=f"(x) : "f"(x));
8 return x;
9}
10
11#else
12
13#include "../sqrtf.c"
14
15#endif
lib/libc/musl/src/mman/mlock.c+4
......@@ -3,5 +3,9 @@
33
44int mlock(const void *addr, size_t len)
55{
6#ifdef SYS_mlock
67 return syscall(SYS_mlock, addr, len);
8#else
9 return syscall(SYS_mlock2, addr, len, 0);
10#endif
711}
lib/libc/musl/src/network/dn_skipname.c+5-2
......@@ -2,11 +2,14 @@
22
33int dn_skipname(const unsigned char *s, const unsigned char *end)
44{
5 const unsigned char *p;
6 for (p=s; p<end; p++)
5 const unsigned char *p = s;
6 while (p < end)
77 if (!*p) return p-s+1;
88 else if (*p>=192)
99 if (p+1<end) return p-s+2;
1010 else break;
11 else
12 if (end-p<*p+1) break;
13 else p += *p + 1;
1114 return -1;
1215}
lib/libc/musl/src/network/getaddrinfo.c+3-4
......@@ -104,7 +104,7 @@ int getaddrinfo(const char *restrict host, const char *restrict serv, const stru
104104 }
105105
106106 for (k=i=0; i<naddrs; i++) for (j=0; j<nservs; j++, k++) {
107 out[k].slot = i;
107 out[k].slot = k;
108108 out[k].ai = (struct addrinfo){
109109 .ai_family = addrs[i].family,
110110 .ai_socktype = ports[j].socktype,
......@@ -113,8 +113,8 @@ int getaddrinfo(const char *restrict host, const char *restrict serv, const stru
113113 ? sizeof(struct sockaddr_in)
114114 : sizeof(struct sockaddr_in6),
115115 .ai_addr = (void *)&out[k].sa,
116 .ai_canonname = outcanon,
117 .ai_next = &out[k+1].ai };
116 .ai_canonname = outcanon };
117 if (k) out[k-1].ai.ai_next = &out[k].ai;
118118 switch (addrs[i].family) {
119119 case AF_INET:
120120 out[k].sa.sin.sin_family = AF_INET;
......@@ -130,7 +130,6 @@ int getaddrinfo(const char *restrict host, const char *restrict serv, const stru
130130 }
131131 }
132132 out[0].ref = nais;
133 out[nais-1].ai.ai_next = 0;
134133 *res = &out->ai;
135134 return 0;
136135}
lib/libc/musl/src/passwd/putgrent.c+1-1
......@@ -7,7 +7,7 @@ int putgrent(const struct group *gr, FILE *f)
77 int r;
88 size_t i;
99 flockfile(f);
10 if ((r = fprintf(f, "%s:%s:%d:", gr->gr_name, gr->gr_passwd, gr->gr_gid))<0) goto done;
10 if ((r = fprintf(f, "%s:%s:%u:", gr->gr_name, gr->gr_passwd, gr->gr_gid))<0) goto done;
1111 if (gr->gr_mem) for (i=0; gr->gr_mem[i]; i++)
1212 if ((r = fprintf(f, "%s%s", i?",":"", gr->gr_mem[i]))<0) goto done;
1313 r = fputc('\n', f);
lib/libc/musl/src/passwd/putpwent.c+1-1
......@@ -4,7 +4,7 @@
44
55int putpwent(const struct passwd *pw, FILE *f)
66{
7 return fprintf(f, "%s:%s:%d:%d:%s:%s:%s\n",
7 return fprintf(f, "%s:%s:%u:%u:%s:%s:%s\n",
88 pw->pw_name, pw->pw_passwd, pw->pw_uid, pw->pw_gid,
99 pw->pw_gecos, pw->pw_dir, pw->pw_shell)<0 ? -1 : 0;
1010}
lib/libc/musl/src/process/execvp.c+1-2
......@@ -28,8 +28,7 @@ int __execvpe(const char *file, char *const argv[], char *const envp[])
2828
2929 for(p=path; ; p=z) {
3030 char b[l+k+1];
31 z = strchr(p, ':');
32 if (!z) z = p+strlen(p);
31 z = __strchrnul(p, ':');
3332 if (z-p >= l) {
3433 if (!*z++) break;
3534 continue;
lib/libc/musl/src/process/fork.c+2
......@@ -27,6 +27,8 @@ pid_t fork(void)
2727 self->tid = __syscall(SYS_gettid);
2828 self->robust_list.off = 0;
2929 self->robust_list.pending = 0;
30 self->next = self->prev = self;
31 __thread_list_lock = 0;
3032 libc.threads_minus_1 = 0;
3133 }
3234 __restore_sigs(&set);
lib/libc/musl/src/process/posix_spawn.c+4
......@@ -101,6 +101,10 @@ static int child(void *args_vp)
101101 break;
102102 case FDOP_DUP2:
103103 fd = op->srcfd;
104 if (fd == p) {
105 ret = -EBADF;
106 goto fail;
107 }
104108 if (fd != op->fd) {
105109 if ((ret=__sys_dup2(fd, op->fd))<0)
106110 goto fail;
lib/libc/musl/src/setjmp/riscv64/longjmp.S created+42
......@@ -0,0 +1,42 @@
1.global __longjmp
2.global _longjmp
3.global longjmp
4.type __longjmp, %function
5.type _longjmp, %function
6.type longjmp, %function
7__longjmp:
8_longjmp:
9longjmp:
10 ld s0, 0(a0)
11 ld s1, 8(a0)
12 ld s2, 16(a0)
13 ld s3, 24(a0)
14 ld s4, 32(a0)
15 ld s5, 40(a0)
16 ld s6, 48(a0)
17 ld s7, 56(a0)
18 ld s8, 64(a0)
19 ld s9, 72(a0)
20 ld s10, 80(a0)
21 ld s11, 88(a0)
22 ld sp, 96(a0)
23 ld ra, 104(a0)
24
25#ifndef __riscv_float_abi_soft
26 fld fs0, 112(a0)
27 fld fs1, 120(a0)
28 fld fs2, 128(a0)
29 fld fs3, 136(a0)
30 fld fs4, 144(a0)
31 fld fs5, 152(a0)
32 fld fs6, 160(a0)
33 fld fs7, 168(a0)
34 fld fs8, 176(a0)
35 fld fs9, 184(a0)
36 fld fs10, 192(a0)
37 fld fs11, 200(a0)
38#endif
39
40 seqz a0, a1
41 add a0, a0, a1
42 ret
lib/libc/musl/src/setjmp/riscv64/setjmp.S created+41
......@@ -0,0 +1,41 @@
1.global __setjmp
2.global _setjmp
3.global setjmp
4.type __setjmp, %function
5.type _setjmp, %function
6.type setjmp, %function
7__setjmp:
8_setjmp:
9setjmp:
10 sd s0, 0(a0)
11 sd s1, 8(a0)
12 sd s2, 16(a0)
13 sd s3, 24(a0)
14 sd s4, 32(a0)
15 sd s5, 40(a0)
16 sd s6, 48(a0)
17 sd s7, 56(a0)
18 sd s8, 64(a0)
19 sd s9, 72(a0)
20 sd s10, 80(a0)
21 sd s11, 88(a0)
22 sd sp, 96(a0)
23 sd ra, 104(a0)
24
25#ifndef __riscv_float_abi_soft
26 fsd fs0, 112(a0)
27 fsd fs1, 120(a0)
28 fsd fs2, 128(a0)
29 fsd fs3, 136(a0)
30 fsd fs4, 144(a0)
31 fsd fs5, 152(a0)
32 fsd fs6, 160(a0)
33 fsd fs7, 168(a0)
34 fsd fs8, 176(a0)
35 fsd fs9, 184(a0)
36 fsd fs10, 192(a0)
37 fsd fs11, 200(a0)
38#endif
39
40 li a0, 0
41 ret
lib/libc/musl/src/signal/riscv64/restore.s created+8
......@@ -0,0 +1,8 @@
1.global __restore
2.type __restore, %function
3__restore:
4.global __restore_rt
5.type __restore_rt, %function
6__restore_rt:
7 li a7, 139 # SYS_rt_sigreturn
8 ecall
lib/libc/musl/src/signal/riscv64/sigsetjmp.s created+23
......@@ -0,0 +1,23 @@
1.global sigsetjmp
2.global __sigsetjmp
3.type sigsetjmp, %function
4.type __sigsetjmp, %function
5sigsetjmp:
6__sigsetjmp:
7 bnez a1, 1f
8 tail setjmp
91:
10
11 sd ra, 208(a0)
12 sd s0, 224(a0)
13 mv s0, a0
14
15 call setjmp
16
17 mv a1, a0
18 mv a0, s0
19 ld s0, 224(a0)
20 ld ra, 208(a0)
21
22.hidden __sigsetjmp_tail
23 tail __sigsetjmp_tail
lib/libc/musl/src/signal/sigaltstack.c+2-2
......@@ -5,11 +5,11 @@
55int sigaltstack(const stack_t *restrict ss, stack_t *restrict old)
66{
77 if (ss) {
8 if (ss->ss_size < MINSIGSTKSZ) {
8 if (!(ss->ss_flags & SS_DISABLE) && ss->ss_size < MINSIGSTKSZ) {
99 errno = ENOMEM;
1010 return -1;
1111 }
12 if (ss->ss_flags & ~SS_DISABLE) {
12 if (ss->ss_flags & SS_ONSTACK) {
1313 errno = EINVAL;
1414 return -1;
1515 }
lib/libc/musl/src/signal/sigset.c+4-4
......@@ -3,7 +3,7 @@
33void (*sigset(int sig, void (*handler)(int)))(int)
44{
55 struct sigaction sa, sa_old;
6 sigset_t mask;
6 sigset_t mask, mask_old;
77
88 sigemptyset(&mask);
99 if (sigaddset(&mask, sig) < 0)
......@@ -12,7 +12,7 @@ void (*sigset(int sig, void (*handler)(int)))(int)
1212 if (handler == SIG_HOLD) {
1313 if (sigaction(sig, 0, &sa_old) < 0)
1414 return SIG_ERR;
15 if (sigprocmask(SIG_BLOCK, &mask, &mask) < 0)
15 if (sigprocmask(SIG_BLOCK, &mask, &mask_old) < 0)
1616 return SIG_ERR;
1717 } else {
1818 sa.sa_handler = handler;
......@@ -20,8 +20,8 @@ void (*sigset(int sig, void (*handler)(int)))(int)
2020 sigemptyset(&sa.sa_mask);
2121 if (sigaction(sig, &sa, &sa_old) < 0)
2222 return SIG_ERR;
23 if (sigprocmask(SIG_UNBLOCK, &mask, &mask) < 0)
23 if (sigprocmask(SIG_UNBLOCK, &mask, &mask_old) < 0)
2424 return SIG_ERR;
2525 }
26 return sigismember(&mask, sig) ? SIG_HOLD : sa_old.sa_handler;
26 return sigismember(&mask_old, sig) ? SIG_HOLD : sa_old.sa_handler;
2727}
lib/libc/musl/src/stdio/fgetwc.c+8-2
......@@ -25,12 +25,18 @@ static wint_t __fgetwc_unlocked_internal(FILE *f)
2525 do {
2626 b = c = getc_unlocked(f);
2727 if (c < 0) {
28 if (!first) errno = EILSEQ;
28 if (!first) {
29 f->flags |= F_ERR;
30 errno = EILSEQ;
31 }
2932 return WEOF;
3033 }
3134 l = mbrtowc(&wc, (void *)&b, 1, &st);
3235 if (l == -1) {
33 if (!first) ungetc(b, f);
36 if (!first) {
37 f->flags |= F_ERR;
38 ungetc(b, f);
39 }
3440 return WEOF;
3541 }
3642 first = 0;
lib/libc/musl/src/stdio/fmemopen.c+1-1
......@@ -83,7 +83,7 @@ FILE *fmemopen(void *restrict buf, size_t size, const char *restrict mode)
8383 struct mem_FILE *f;
8484 int plus = !!strchr(mode, '+');
8585
86 if (!size || !strchr("rwa", *mode)) {
86 if (!strchr("rwa", *mode)) {
8787 errno = EINVAL;
8888 return 0;
8989 }
lib/libc/musl/src/stdio/gets.c+8-3
......@@ -4,7 +4,12 @@
44
55char *gets(char *s)
66{
7 char *ret = fgets(s, INT_MAX, stdin);
8 if (ret && s[strlen(s)-1] == '\n') s[strlen(s)-1] = 0;
9 return ret;
7 size_t i=0;
8 int c;
9 FLOCK(stdin);
10 while ((c=getc_unlocked(stdin)) != EOF && c != '\n') s[i++] = c;
11 s[i] = 0;
12 if (c != '\n' && (!feof(stdin) || !i)) s = 0;
13 FUNLOCK(stdin);
14 return s;
1015}
lib/libc/musl/src/stdio/rename.c+4-2
......@@ -4,9 +4,11 @@
44
55int rename(const char *old, const char *new)
66{
7#ifdef SYS_rename
7#if defined(SYS_rename)
88 return syscall(SYS_rename, old, new);
9#else
9#elif defined(SYS_renameat)
1010 return syscall(SYS_renameat, AT_FDCWD, old, AT_FDCWD, new);
11#else
12 return syscall(SYS_renameat2, AT_FDCWD, old, AT_FDCWD, new, 0);
1113#endif
1214}
lib/libc/musl/src/stdio/setvbuf.c+3-1
......@@ -12,13 +12,15 @@ int setvbuf(FILE *restrict f, char *restrict buf, int type, size_t size)
1212
1313 if (type == _IONBF) {
1414 f->buf_size = 0;
15 } else {
15 } else if (type == _IOLBF || type == _IOFBF) {
1616 if (buf && size >= UNGET) {
1717 f->buf = (void *)(buf + UNGET);
1818 f->buf_size = size - UNGET;
1919 }
2020 if (type == _IOLBF && f->buf_size)
2121 f->lbf = '\n';
22 } else {
23 return -1;
2224 }
2325
2426 f->flags |= F_SVB;
lib/libc/musl/src/thread/__syscall_cp.c+1-1
......@@ -7,7 +7,7 @@ static long sccp(syscall_arg_t nr,
77 syscall_arg_t u, syscall_arg_t v, syscall_arg_t w,
88 syscall_arg_t x, syscall_arg_t y, syscall_arg_t z)
99{
10 return (__syscall)(nr, u, v, w, x, y, z);
10 return __syscall(nr, u, v, w, x, y, z);
1111}
1212
1313weak_alias(sccp, __syscall_cp_c);
lib/libc/musl/src/thread/__tls_get_addr.c+1-6
......@@ -1,12 +1,7 @@
1#include <stddef.h>
21#include "pthread_impl.h"
32
43void *__tls_get_addr(tls_mod_off_t *v)
54{
65 pthread_t self = __pthread_self();
7 if (v[0] <= self->dtv[0])
8 return (void *)(self->dtv[v[0]] + v[1]);
9 return __tls_get_new(v);
6 return (void *)(self->dtv[v[0]] + v[1]);
107}
11
12weak_alias(__tls_get_addr, __tls_get_new);
lib/libc/musl/src/thread/__unmapself.c-5
......@@ -4,7 +4,6 @@
44/* cheat and reuse CRTJMP macro from dynlink code */
55#include "dynlink.h"
66
7static volatile int lock;
87static void *unmap_base;
98static size_t unmap_size;
109static char shared_stack[256];
......@@ -17,12 +16,8 @@ static void do_unmap()
1716
1817void __unmapself(void *base, size_t size)
1918{
20 int tid=__pthread_self()->tid;
2119 char *stack = shared_stack + sizeof shared_stack;
2220 stack -= (uintptr_t)stack % 16;
23 while (lock || a_cas(&lock, 0, tid))
24 a_spin();
25 __syscall(SYS_set_tid_address, &lock);
2621 unmap_base = base;
2722 unmap_size = size;
2823 CRTJMP(do_unmap, stack);
lib/libc/musl/src/thread/i386/tls.s-8
......@@ -4,14 +4,6 @@
44___tls_get_addr:
55 mov %gs:4,%edx
66 mov (%eax),%ecx
7 cmp %ecx,(%edx)
8 jc 1f
97 mov 4(%eax),%eax
108 add (%edx,%ecx,4),%eax
119 ret
121: push %eax
13.weak __tls_get_new
14.hidden __tls_get_new
15 call __tls_get_new
16 pop %edx
17 ret
lib/libc/musl/src/thread/pthread_attr_setinheritsched.c-19
......@@ -1,25 +1,6 @@
11#include "pthread_impl.h"
22#include "syscall.h"
33
4hidden void *__start_sched(void *p)
5{
6 struct start_sched_args *ssa = p;
7 void *start_arg = ssa->start_arg;
8 void *(*start_fn)(void *) = ssa->start_fn;
9 pthread_t self = __pthread_self();
10
11 int ret = -__syscall(SYS_sched_setscheduler, self->tid,
12 ssa->attr->_a_policy, &ssa->attr->_a_prio);
13 if (!ret) __restore_sigs(&ssa->mask);
14 a_store(&ssa->futex, ret);
15 __wake(&ssa->futex, 1, 1);
16 if (ret) {
17 self->detach_state = DT_DYNAMIC;
18 return 0;
19 }
20 return start_fn(start_arg);
21}
22
234int pthread_attr_setinheritsched(pthread_attr_t *a, int inherit)
245{
256 if (inherit > 1U) return EINVAL;
lib/libc/musl/src/thread/pthread_create.c+136-65
......@@ -15,12 +15,41 @@ weak_alias(dummy_0, __release_ptc);
1515weak_alias(dummy_0, __pthread_tsd_run_dtors);
1616weak_alias(dummy_0, __do_orphaned_stdio_locks);
1717weak_alias(dummy_0, __dl_thread_cleanup);
18weak_alias(dummy_0, __membarrier_init);
1819
19static void *dummy_1(void *p)
20static int tl_lock_count;
21static int tl_lock_waiters;
22
23void __tl_lock(void)
2024{
21 return 0;
25 int tid = __pthread_self()->tid;
26 int val = __thread_list_lock;
27 if (val == tid) {
28 tl_lock_count++;
29 return;
30 }
31 while ((val = a_cas(&__thread_list_lock, 0, tid)))
32 __wait(&__thread_list_lock, &tl_lock_waiters, val, 0);
33}
34
35void __tl_unlock(void)
36{
37 if (tl_lock_count) {
38 tl_lock_count--;
39 return;
40 }
41 a_store(&__thread_list_lock, 0);
42 if (tl_lock_waiters) __wake(&__thread_list_lock, 1, 0);
43}
44
45void __tl_sync(pthread_t td)
46{
47 a_barrier();
48 int val = __thread_list_lock;
49 if (!val) return;
50 __wait(&__thread_list_lock, &tl_lock_waiters, val, 0);
51 if (tl_lock_waiters) __wake(&__thread_list_lock, 1, 0);
2252}
23weak_alias(dummy_1, __start_sched);
2453
2554_Noreturn void __pthread_exit(void *result)
2655{
......@@ -46,24 +75,30 @@ _Noreturn void __pthread_exit(void *result)
4675 * joinable threads it's a valid usage that must be handled. */
4776 LOCK(self->killlock);
4877
49 /* Block all signals before decrementing the live thread count.
50 * This is important to ensure that dynamically allocated TLS
51 * is not under-allocated/over-committed, and possibly for other
52 * reasons as well. */
53 __block_all_sigs(&set);
54
55 /* It's impossible to determine whether this is "the last thread"
56 * until performing the atomic decrement, since multiple threads
57 * could exit at the same time. For the last thread, revert the
58 * decrement, restore the tid, and unblock signals to give the
59 * atexit handlers and stdio cleanup code a consistent state. */
60 if (a_fetch_add(&libc.threads_minus_1, -1)==0) {
61 libc.threads_minus_1 = 0;
62 UNLOCK(self->killlock);
78 /* The thread list lock must be AS-safe, and thus requires
79 * application signals to be blocked before it can be taken. */
80 __block_app_sigs(&set);
81 __tl_lock();
82
83 /* If this is the only thread in the list, don't proceed with
84 * termination of the thread, but restore the previous lock and
85 * signal state to prepare for exit to call atexit handlers. */
86 if (self->next == self) {
87 __tl_unlock();
6388 __restore_sigs(&set);
89 UNLOCK(self->killlock);
6490 exit(0);
6591 }
6692
93 /* At this point we are committed to thread termination. Unlink
94 * the thread from the list. This change will not be visible
95 * until the lock is released, which only happens after SYS_exit
96 * has been called, via the exit futex address pointing at the lock. */
97 libc.threads_minus_1--;
98 self->next->prev = self->prev;
99 self->prev->next = self->next;
100 self->prev = self->next = self;
101
67102 /* Process robust list in userspace to handle non-pshared mutexes
68103 * and the detached thread case where the robust list head will
69104 * be invalid when the kernel would process it. */
......@@ -90,15 +125,11 @@ _Noreturn void __pthread_exit(void *result)
90125 * call; the loser is responsible for freeing thread resources. */
91126 int state = a_cas(&self->detach_state, DT_JOINABLE, DT_EXITING);
92127
93 if (state>=DT_DETACHED && self->map_base) {
94 /* Detached threads must avoid the kernel clear_child_tid
95 * feature, since the virtual address will have been
96 * unmapped and possibly already reused by a new mapping
97 * at the time the kernel would perform the write. In
98 * the case of threads that started out detached, the
99 * initial clone flags are correct, but if the thread was
100 * detached later, we need to clear it here. */
101 if (state == DT_DYNAMIC) __syscall(SYS_set_tid_address, 0);
128 if (state==DT_DETACHED && self->map_base) {
129 /* Detached threads must block even implementation-internal
130 * signals, since they will not have a stack in their last
131 * moments of existence. */
132 __block_all_sigs(&set);
102133
103134 /* Robust list will no longer be valid, and was already
104135 * processed above, so unregister it with the kernel. */
......@@ -114,6 +145,9 @@ _Noreturn void __pthread_exit(void *result)
114145 __unmapself(self->map_base, self->map_size);
115146 }
116147
148 /* Wake any joiner. */
149 __wake(&self->detach_state, 1, 1);
150
117151 /* After the kernel thread exits, its tid may be reused. Clear it
118152 * to prevent inadvertent use and inform functions that would use
119153 * it that it's no longer available. */
......@@ -135,21 +169,38 @@ void __do_cleanup_pop(struct __ptcb *cb)
135169 __pthread_self()->cancelbuf = cb->__next;
136170}
137171
172struct start_args {
173 void *(*start_func)(void *);
174 void *start_arg;
175 pthread_attr_t *attr;
176 volatile int *perr;
177 unsigned long sig_mask[_NSIG/8/sizeof(long)];
178};
179
138180static int start(void *p)
139181{
140 pthread_t self = p;
141 if (self->unblock_cancel)
142 __syscall(SYS_rt_sigprocmask, SIG_UNBLOCK,
143 SIGPT_SET, 0, _NSIG/8);
144 __pthread_exit(self->start(self->start_arg));
182 struct start_args *args = p;
183 if (args->attr) {
184 pthread_t self = __pthread_self();
185 int ret = -__syscall(SYS_sched_setscheduler, self->tid,
186 args->attr->_a_policy, &args->attr->_a_prio);
187 if (a_swap(args->perr, ret)==-2)
188 __wake(args->perr, 1, 1);
189 if (ret) {
190 self->detach_state = DT_DETACHED;
191 __pthread_exit(0);
192 }
193 }
194 __syscall(SYS_rt_sigprocmask, SIG_SETMASK, &args->sig_mask, 0, _NSIG/8);
195 __pthread_exit(args->start_func(args->start_arg));
145196 return 0;
146197}
147198
148199static int start_c11(void *p)
149200{
150 pthread_t self = p;
151 int (*start)(void*) = (int(*)(void*)) self->start;
152 __pthread_exit((void *)(uintptr_t)start(self->start_arg));
201 struct start_args *args = p;
202 int (*start)(void*) = (int(*)(void*)) args->start_func;
203 __pthread_exit((void *)(uintptr_t)start(args->start_arg));
153204 return 0;
154205}
155206
......@@ -161,8 +212,6 @@ weak_alias(dummy, __pthread_tsd_size);
161212static void *dummy_tsd[1] = { 0 };
162213weak_alias(dummy_tsd, __pthread_tsd_main);
163214
164volatile int __block_new_threads = 0;
165
166215static FILE *volatile dummy_file = 0;
167216weak_alias(dummy_file, __stdin_used);
168217weak_alias(dummy_file, __stdout_used);
......@@ -182,9 +231,9 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att
182231 unsigned flags = CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND
183232 | CLONE_THREAD | CLONE_SYSVSEM | CLONE_SETTLS
184233 | CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID | CLONE_DETACHED;
185 int do_sched = 0;
186234 pthread_attr_t attr = { 0 };
187 struct start_sched_args ssa;
235 sigset_t set;
236 volatile int err = -1;
188237
189238 if (!libc.can_do_threads) return ENOSYS;
190239 self = __pthread_self();
......@@ -197,6 +246,7 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att
197246 init_file_lock(__stderr_used);
198247 __syscall(SYS_rt_sigprocmask, SIG_UNBLOCK, SIGPT_SET, 0, _NSIG/8);
199248 self->tsd = (void **)__pthread_tsd_main;
249 __membarrier_init();
200250 libc.threaded = 1;
201251 }
202252 if (attrp && !c11) attr = *attrp;
......@@ -207,8 +257,6 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att
207257 attr._a_guardsize = __default_guardsize;
208258 }
209259
210 if (__block_new_threads) __wait(&__block_new_threads, 0, 1, 1);
211
212260 if (attr._a_stackaddr) {
213261 size_t need = libc.tls_size + __pthread_tsd_size;
214262 size = attr._a_stacksize;
......@@ -257,49 +305,72 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att
257305 new->stack = stack;
258306 new->stack_size = stack - stack_limit;
259307 new->guard_size = guard;
260 new->start = entry;
261 new->start_arg = arg;
262308 new->self = new;
263309 new->tsd = (void *)tsd;
264310 new->locale = &libc.global_locale;
265311 if (attr._a_detach) {
266312 new->detach_state = DT_DETACHED;
267 flags -= CLONE_CHILD_CLEARTID;
268313 } else {
269314 new->detach_state = DT_JOINABLE;
270315 }
271 if (attr._a_sched) {
272 do_sched = 1;
273 ssa.futex = -1;
274 ssa.start_fn = new->start;
275 ssa.start_arg = new->start_arg;
276 ssa.attr = &attr;
277 new->start = __start_sched;
278 new->start_arg = &ssa;
279 __block_app_sigs(&ssa.mask);
280 }
281316 new->robust_list.head = &new->robust_list.head;
282 new->unblock_cancel = self->cancel;
283317 new->CANARY = self->CANARY;
318 new->sysinfo = self->sysinfo;
319
320 /* Setup argument structure for the new thread on its stack.
321 * It's safe to access from the caller only until the thread
322 * list is unlocked. */
323 stack -= (uintptr_t)stack % sizeof(uintptr_t);
324 stack -= sizeof(struct start_args);
325 struct start_args *args = (void *)stack;
326 args->start_func = entry;
327 args->start_arg = arg;
328 if (attr._a_sched) {
329 args->attr = &attr;
330 args->perr = &err;
331 } else {
332 args->attr = 0;
333 args->perr = 0;
334 }
284335
285 a_inc(&libc.threads_minus_1);
286 ret = __clone((c11 ? start_c11 : start), stack, flags, new, &new->tid, TP_ADJ(new), &new->detach_state);
287
288 __release_ptc();
289
290 if (do_sched) {
291 __restore_sigs(&ssa.mask);
336 /* Application signals (but not the synccall signal) must be
337 * blocked before the thread list lock can be taken, to ensure
338 * that the lock is AS-safe. */
339 __block_app_sigs(&set);
340
341 /* Ensure SIGCANCEL is unblocked in new thread. This requires
342 * working with a copy of the set so we can restore the
343 * original mask in the calling thread. */
344 memcpy(&args->sig_mask, &set, sizeof args->sig_mask);
345 args->sig_mask[(SIGCANCEL-1)/8/sizeof(long)] &=
346 ~(1UL<<((SIGCANCEL-1)%(8*sizeof(long))));
347
348 __tl_lock();
349 libc.threads_minus_1++;
350 ret = __clone((c11 ? start_c11 : start), stack, flags, args, &new->tid, TP_ADJ(new), &__thread_list_lock);
351
352 /* If clone succeeded, new thread must be linked on the thread
353 * list before unlocking it, even if scheduling may still fail. */
354 if (ret >= 0) {
355 new->next = self->next;
356 new->prev = self;
357 new->next->prev = new;
358 new->prev->next = new;
292359 }
360 __tl_unlock();
361 __restore_sigs(&set);
362 __release_ptc();
293363
294364 if (ret < 0) {
295 a_dec(&libc.threads_minus_1);
365 libc.threads_minus_1--;
296366 if (map) __munmap(map, size);
297367 return EAGAIN;
298368 }
299369
300 if (do_sched) {
301 __futexwait(&ssa.futex, -1, 1);
302 ret = ssa.futex;
370 if (attr._a_sched) {
371 if (a_cas(&err, -1, -2)==-1)
372 __wait(&err, 0, -2, 1);
373 ret = err;
303374 if (ret) return ret;
304375 }
305376
lib/libc/musl/src/thread/pthread_detach.c+1-1
......@@ -5,7 +5,7 @@ static int __pthread_detach(pthread_t t)
55{
66 /* If the cas fails, detach state is either already-detached
77 * or exiting/exited, and pthread_join will trap or cleanup. */
8 if (a_cas(&t->detach_state, DT_JOINABLE, DT_DYNAMIC) != DT_JOINABLE)
8 if (a_cas(&t->detach_state, DT_JOINABLE, DT_DETACHED) != DT_JOINABLE)
99 return __pthread_join(t, 0);
1010 return 0;
1111}
lib/libc/musl/src/thread/pthread_join.c+7-2
......@@ -1,6 +1,11 @@
11#include "pthread_impl.h"
22#include <sys/mman.h>
33
4static void dummy1(pthread_t t)
5{
6}
7weak_alias(dummy1, __tl_sync);
8
49static int __pthread_timedjoin_np(pthread_t t, void **res, const struct timespec *at)
510{
611 int state, cs, r = 0;
......@@ -9,11 +14,11 @@ static int __pthread_timedjoin_np(pthread_t t, void **res, const struct timespec
914 if (cs == PTHREAD_CANCEL_ENABLE) __pthread_setcancelstate(cs, 0);
1015 while ((state = t->detach_state) && r != ETIMEDOUT && r != EINVAL) {
1116 if (state >= DT_DETACHED) a_crash();
12 r = __timedwait_cp(&t->detach_state, state, CLOCK_REALTIME, at, 0);
17 r = __timedwait_cp(&t->detach_state, state, CLOCK_REALTIME, at, 1);
1318 }
1419 __pthread_setcancelstate(cs, 0);
1520 if (r == ETIMEDOUT || r == EINVAL) return r;
16 a_barrier();
21 __tl_sync(t);
1722 if (res) *res = t->result;
1823 if (t->map_base) __munmap(t->map_base, t->map_size);
1924 return 0;
lib/libc/musl/src/thread/pthread_key_create.c+31-71
......@@ -13,49 +13,16 @@ static void nodtor(void *dummy)
1313{
1414}
1515
16static void dirty(void *dummy)
16static void dummy_0(void)
1717{
1818}
1919
20struct cleanup_args {
21 pthread_t caller;
22 int ret;
23};
24
25static void clean_dirty_tsd_callback(void *p)
26{
27 struct cleanup_args *args = p;
28 pthread_t self = __pthread_self();
29 pthread_key_t i;
30 for (i=0; i<PTHREAD_KEYS_MAX; i++) {
31 if (keys[i] == dirty && self->tsd[i])
32 self->tsd[i] = 0;
33 }
34 /* Arbitrary choice to avoid data race. */
35 if (args->caller == self) args->ret = 0;
36}
37
38static void dummy2(void (*f)(void *), void *p)
39{
40}
41
42weak_alias(dummy2, __pthread_key_delete_synccall);
43
44static int clean_dirty_tsd(void)
45{
46 struct cleanup_args args = {
47 .caller = __pthread_self(),
48 .ret = EAGAIN
49 };
50 __pthread_key_delete_synccall(clean_dirty_tsd_callback, &args);
51 return args.ret;
52}
20weak_alias(dummy_0, __tl_lock);
21weak_alias(dummy_0, __tl_unlock);
5322
5423int __pthread_key_create(pthread_key_t *k, void (*dtor)(void *))
5524{
56 pthread_key_t j = next_key;
5725 pthread_t self = __pthread_self();
58 int found_dirty = 0;
5926
6027 /* This can only happen in the main thread before
6128 * pthread_create has been called. */
......@@ -64,46 +31,38 @@ int __pthread_key_create(pthread_key_t *k, void (*dtor)(void *))
6431 /* Purely a sentinel value since null means slot is free. */
6532 if (!dtor) dtor = nodtor;
6633
67 pthread_rwlock_wrlock(&key_lock);
34 __pthread_rwlock_wrlock(&key_lock);
35 pthread_key_t j = next_key;
6836 do {
6937 if (!keys[j]) {
7038 keys[next_key = *k = j] = dtor;
71 pthread_rwlock_unlock(&key_lock);
39 __pthread_rwlock_unlock(&key_lock);
7240 return 0;
73 } else if (keys[j] == dirty) {
74 found_dirty = 1;
7541 }
7642 } while ((j=(j+1)%PTHREAD_KEYS_MAX) != next_key);
7743
78 /* It's possible that all slots are in use or __synccall fails. */
79 if (!found_dirty || clean_dirty_tsd()) {
80 pthread_rwlock_unlock(&key_lock);
81 return EAGAIN;
82 }
83
84 /* If this point is reached there is necessarily a newly-cleaned
85 * slot to allocate to satisfy the caller's request. Find it and
86 * mark any additional previously-dirty slots clean. */
87 for (j=0; j<PTHREAD_KEYS_MAX; j++) {
88 if (keys[j] == dirty) {
89 if (dtor) {
90 keys[next_key = *k = j] = dtor;
91 dtor = 0;
92 } else {
93 keys[j] = 0;
94 }
95 }
96 }
97
98 pthread_rwlock_unlock(&key_lock);
99 return 0;
44 __pthread_rwlock_unlock(&key_lock);
45 return EAGAIN;
10046}
10147
102int __pthread_key_delete_impl(pthread_key_t k)
48int __pthread_key_delete(pthread_key_t k)
10349{
104 pthread_rwlock_wrlock(&key_lock);
105 keys[k] = dirty;
106 pthread_rwlock_unlock(&key_lock);
50 sigset_t set;
51 pthread_t self = __pthread_self(), td=self;
52
53 __block_app_sigs(&set);
54 __pthread_rwlock_wrlock(&key_lock);
55
56 __tl_lock();
57 do td->tsd[k] = 0;
58 while ((td=td->next)!=self);
59 __tl_unlock();
60
61 keys[k] = 0;
62
63 __pthread_rwlock_unlock(&key_lock);
64 __restore_sigs(&set);
65
10766 return 0;
10867}
10968
......@@ -112,20 +71,21 @@ void __pthread_tsd_run_dtors()
11271 pthread_t self = __pthread_self();
11372 int i, j;
11473 for (j=0; self->tsd_used && j<PTHREAD_DESTRUCTOR_ITERATIONS; j++) {
115 pthread_rwlock_rdlock(&key_lock);
74 __pthread_rwlock_rdlock(&key_lock);
11675 self->tsd_used = 0;
11776 for (i=0; i<PTHREAD_KEYS_MAX; i++) {
11877 void *val = self->tsd[i];
11978 void (*dtor)(void *) = keys[i];
12079 self->tsd[i] = 0;
121 if (val && dtor && dtor != nodtor && dtor != dirty) {
122 pthread_rwlock_unlock(&key_lock);
80 if (val && dtor && dtor != nodtor) {
81 __pthread_rwlock_unlock(&key_lock);
12382 dtor(val);
124 pthread_rwlock_rdlock(&key_lock);
83 __pthread_rwlock_rdlock(&key_lock);
12584 }
12685 }
127 pthread_rwlock_unlock(&key_lock);
86 __pthread_rwlock_unlock(&key_lock);
12887 }
12988}
13089
13190weak_alias(__pthread_key_create, pthread_key_create);
91weak_alias(__pthread_key_delete, pthread_key_delete);
lib/libc/musl/src/thread/pthread_key_delete.c deleted-14
......@@ -1,14 +0,0 @@
1#include "pthread_impl.h"
2#include "libc.h"
3
4void __pthread_key_delete_synccall(void (*f)(void *), void *p)
5{
6 __synccall(f, p);
7}
8
9int __pthread_key_delete(pthread_key_t k)
10{
11 return __pthread_key_delete_impl(k);
12}
13
14weak_alias(__pthread_key_delete, pthread_key_delete);
lib/libc/musl/src/thread/pthread_mutex_consistent.c+7-3
......@@ -1,10 +1,14 @@
11#include "pthread_impl.h"
2#include "atomic.h"
23
34int pthread_mutex_consistent(pthread_mutex_t *m)
45{
5 if (!(m->_m_type & 8)) return EINVAL;
6 if ((m->_m_lock & 0x7fffffff) != __pthread_self()->tid)
6 int old = m->_m_lock;
7 int own = old & 0x3fffffff;
8 if (!(m->_m_type & 4) || !own || !(old & 0x40000000))
9 return EINVAL;
10 if (own != __pthread_self()->tid)
711 return EPERM;
8 m->_m_type &= ~8U;
12 a_and(&m->_m_lock, ~0x40000000);
913 return 0;
1014}
lib/libc/musl/src/thread/pthread_mutex_timedlock.c+42-3
......@@ -1,5 +1,40 @@
11#include "pthread_impl.h"
22
3static int pthread_mutex_timedlock_pi(pthread_mutex_t *restrict m, const struct timespec *restrict at)
4{
5 int type = m->_m_type;
6 int priv = (type & 128) ^ 128;
7 pthread_t self = __pthread_self();
8 int e;
9
10 if (!priv) self->robust_list.pending = &m->_m_next;
11
12 do e = -__syscall(SYS_futex, &m->_m_lock, FUTEX_LOCK_PI|priv, 0, at);
13 while (e==EINTR);
14 if (e) self->robust_list.pending = 0;
15
16 switch (e) {
17 case 0:
18 /* Catch spurious success for non-robust mutexes. */
19 if (!(type&4) && ((m->_m_lock & 0x40000000) || m->_m_waiters)) {
20 a_store(&m->_m_waiters, -1);
21 __syscall(SYS_futex, &m->_m_lock, FUTEX_UNLOCK_PI|priv);
22 self->robust_list.pending = 0;
23 break;
24 }
25 /* Signal to trylock that we already have the lock. */
26 m->_m_count = -1;
27 return __pthread_mutex_trylock(m);
28 case ETIMEDOUT:
29 return e;
30 case EDEADLK:
31 if ((type&3) == PTHREAD_MUTEX_ERRORCHECK) return e;
32 }
33 do e = __timedwait(&(int){0}, 0, CLOCK_REALTIME, at, 1);
34 while (e != ETIMEDOUT);
35 return e;
36}
37
338int __pthread_mutex_timedlock(pthread_mutex_t *restrict m, const struct timespec *restrict at)
439{
540 if ((m->_m_type&15) == PTHREAD_MUTEX_NORMAL
......@@ -9,17 +44,21 @@ int __pthread_mutex_timedlock(pthread_mutex_t *restrict m, const struct timespec
944 int type = m->_m_type;
1045 int r, t, priv = (type & 128) ^ 128;
1146
12 r = pthread_mutex_trylock(m);
47 r = __pthread_mutex_trylock(m);
1348 if (r != EBUSY) return r;
49
50 if (type&8) return pthread_mutex_timedlock_pi(m, at);
1451
1552 int spins = 100;
1653 while (spins-- && m->_m_lock && !m->_m_waiters) a_spin();
1754
1855 while ((r=__pthread_mutex_trylock(m)) == EBUSY) {
19 if (!(r=m->_m_lock) || ((r&0x40000000) && (type&4)))
56 r = m->_m_lock;
57 int own = r & 0x3fffffff;
58 if (!own && (!r || (type&4)))
2059 continue;
2160 if ((type&3) == PTHREAD_MUTEX_ERRORCHECK
22 && (r&0x7fffffff) == __pthread_self()->tid)
61 && own == __pthread_self()->tid)
2362 return EDEADLK;
2463
2564 a_inc(&m->_m_waiters);
lib/libc/musl/src/thread/pthread_mutex_trylock.c+27-11
......@@ -3,21 +3,28 @@
33int __pthread_mutex_trylock_owner(pthread_mutex_t *m)
44{
55 int old, own;
6 int type = m->_m_type & 15;
6 int type = m->_m_type;
77 pthread_t self = __pthread_self();
88 int tid = self->tid;
99
1010 old = m->_m_lock;
11 own = old & 0x7fffffff;
12 if (own == tid && (type&3) == PTHREAD_MUTEX_RECURSIVE) {
13 if ((unsigned)m->_m_count >= INT_MAX) return EAGAIN;
14 m->_m_count++;
15 return 0;
11 own = old & 0x3fffffff;
12 if (own == tid) {
13 if ((type&8) && m->_m_count<0) {
14 old &= 0x40000000;
15 m->_m_count = 0;
16 goto success;
17 }
18 if ((type&3) == PTHREAD_MUTEX_RECURSIVE) {
19 if ((unsigned)m->_m_count >= INT_MAX) return EAGAIN;
20 m->_m_count++;
21 return 0;
22 }
1623 }
17 if (own == 0x7fffffff) return ENOTRECOVERABLE;
18 if (own && (!(own & 0x40000000) || !(type & 4))) return EBUSY;
24 if (own == 0x3fffffff) return ENOTRECOVERABLE;
25 if (own || (old && !(type & 4))) return EBUSY;
1926
20 if (m->_m_type & 128) {
27 if (type & 128) {
2128 if (!self->robust_list.off) {
2229 self->robust_list.off = (char*)&m->_m_lock-(char *)&m->_m_next;
2330 __syscall(SYS_set_robust_list, &self->robust_list, 3*sizeof(long));
......@@ -25,12 +32,22 @@ int __pthread_mutex_trylock_owner(pthread_mutex_t *m)
2532 if (m->_m_waiters) tid |= 0x80000000;
2633 self->robust_list.pending = &m->_m_next;
2734 }
35 tid |= old & 0x40000000;
2836
2937 if (a_cas(&m->_m_lock, old, tid) != old) {
3038 self->robust_list.pending = 0;
39 if ((type&12)==12 && m->_m_waiters) return ENOTRECOVERABLE;
3140 return EBUSY;
3241 }
3342
43success:
44 if ((type&8) && m->_m_waiters) {
45 int priv = (type & 128) ^ 128;
46 __syscall(SYS_futex, &m->_m_lock, FUTEX_UNLOCK_PI|priv);
47 self->robust_list.pending = 0;
48 return (type&4) ? ENOTRECOVERABLE : EBUSY;
49 }
50
3451 volatile void *next = self->robust_list.head;
3552 m->_m_next = next;
3653 m->_m_prev = &self->robust_list.head;
......@@ -39,9 +56,8 @@ int __pthread_mutex_trylock_owner(pthread_mutex_t *m)
3956 self->robust_list.head = &m->_m_next;
4057 self->robust_list.pending = 0;
4158
42 if (own) {
59 if (old) {
4360 m->_m_count = 0;
44 m->_m_type |= 8;
4561 return EOWNERDEAD;
4662 }
4763
lib/libc/musl/src/thread/pthread_mutex_unlock.c+17-2
......@@ -7,13 +7,19 @@ int __pthread_mutex_unlock(pthread_mutex_t *m)
77 int cont;
88 int type = m->_m_type & 15;
99 int priv = (m->_m_type & 128) ^ 128;
10 int new = 0;
11 int old;
1012
1113 if (type != PTHREAD_MUTEX_NORMAL) {
1214 self = __pthread_self();
13 if ((m->_m_lock&0x7fffffff) != self->tid)
15 old = m->_m_lock;
16 int own = old & 0x3fffffff;
17 if (own != self->tid)
1418 return EPERM;
1519 if ((type&3) == PTHREAD_MUTEX_RECURSIVE && m->_m_count)
1620 return m->_m_count--, 0;
21 if ((type&4) && (old&0x40000000))
22 new = 0x7fffffff;
1723 if (!priv) {
1824 self->robust_list.pending = &m->_m_next;
1925 __vm_lock();
......@@ -24,7 +30,16 @@ int __pthread_mutex_unlock(pthread_mutex_t *m)
2430 if (next != &self->robust_list.head) *(volatile void *volatile *)
2531 ((char *)next - sizeof(void *)) = prev;
2632 }
27 cont = a_swap(&m->_m_lock, (type & 8) ? 0x7fffffff : 0);
33 if (type&8) {
34 if (old<0 || a_cas(&m->_m_lock, old, new)!=old) {
35 if (new) a_store(&m->_m_waiters, -1);
36 __syscall(SYS_futex, &m->_m_lock, FUTEX_UNLOCK_PI|priv);
37 }
38 cont = 0;
39 waiters = 0;
40 } else {
41 cont = a_swap(&m->_m_lock, new);
42 }
2843 if (type != PTHREAD_MUTEX_NORMAL && !priv) {
2944 self->robust_list.pending = 0;
3045 __vm_unlock();
lib/libc/musl/src/thread/pthread_mutexattr_setprotocol.c+24-2
......@@ -1,7 +1,29 @@
11#include "pthread_impl.h"
2#include "syscall.h"
3
4static pthread_once_t check_pi_once;
5static int check_pi_result;
6
7static void check_pi()
8{
9 volatile int lk = 0;
10 check_pi_result = -__syscall(SYS_futex, &lk, FUTEX_LOCK_PI, 0, 0);
11}
212
313int pthread_mutexattr_setprotocol(pthread_mutexattr_t *a, int protocol)
414{
5 if (protocol) return ENOTSUP;
6 return 0;
15 switch (protocol) {
16 case PTHREAD_PRIO_NONE:
17 a->__attr &= ~8;
18 return 0;
19 case PTHREAD_PRIO_INHERIT:
20 pthread_once(&check_pi_once, check_pi);
21 if (check_pi_result) return check_pi_result;
22 a->__attr |= 8;
23 return 0;
24 case PTHREAD_PRIO_PROTECT:
25 return ENOTSUP;
26 default:
27 return EINVAL;
28 }
729}
lib/libc/musl/src/thread/pthread_rwlock_rdlock.c+4-2
......@@ -1,6 +1,8 @@
11#include "pthread_impl.h"
22
3int pthread_rwlock_rdlock(pthread_rwlock_t *rw)
3int __pthread_rwlock_rdlock(pthread_rwlock_t *rw)
44{
5 return pthread_rwlock_timedrdlock(rw, 0);
5 return __pthread_rwlock_timedrdlock(rw, 0);
66}
7
8weak_alias(__pthread_rwlock_rdlock, pthread_rwlock_rdlock);
lib/libc/musl/src/thread/pthread_rwlock_timedrdlock.c+4-2
......@@ -1,6 +1,6 @@
11#include "pthread_impl.h"
22
3int pthread_rwlock_timedrdlock(pthread_rwlock_t *restrict rw, const struct timespec *restrict at)
3int __pthread_rwlock_timedrdlock(pthread_rwlock_t *restrict rw, const struct timespec *restrict at)
44{
55 int r, t;
66
......@@ -10,7 +10,7 @@ int pthread_rwlock_timedrdlock(pthread_rwlock_t *restrict rw, const struct times
1010 int spins = 100;
1111 while (spins-- && rw->_rw_lock && !rw->_rw_waiters) a_spin();
1212
13 while ((r=pthread_rwlock_tryrdlock(rw))==EBUSY) {
13 while ((r=__pthread_rwlock_tryrdlock(rw))==EBUSY) {
1414 if (!(r=rw->_rw_lock) || (r&0x7fffffff)!=0x7fffffff) continue;
1515 t = r | 0x80000000;
1616 a_inc(&rw->_rw_waiters);
......@@ -21,3 +21,5 @@ int pthread_rwlock_timedrdlock(pthread_rwlock_t *restrict rw, const struct times
2121 }
2222 return r;
2323}
24
25weak_alias(__pthread_rwlock_timedrdlock, pthread_rwlock_timedrdlock);
lib/libc/musl/src/thread/pthread_rwlock_timedwrlock.c+4-2
......@@ -1,6 +1,6 @@
11#include "pthread_impl.h"
22
3int pthread_rwlock_timedwrlock(pthread_rwlock_t *restrict rw, const struct timespec *restrict at)
3int __pthread_rwlock_timedwrlock(pthread_rwlock_t *restrict rw, const struct timespec *restrict at)
44{
55 int r, t;
66
......@@ -10,7 +10,7 @@ int pthread_rwlock_timedwrlock(pthread_rwlock_t *restrict rw, const struct times
1010 int spins = 100;
1111 while (spins-- && rw->_rw_lock && !rw->_rw_waiters) a_spin();
1212
13 while ((r=pthread_rwlock_trywrlock(rw))==EBUSY) {
13 while ((r=__pthread_rwlock_trywrlock(rw))==EBUSY) {
1414 if (!(r=rw->_rw_lock)) continue;
1515 t = r | 0x80000000;
1616 a_inc(&rw->_rw_waiters);
......@@ -21,3 +21,5 @@ int pthread_rwlock_timedwrlock(pthread_rwlock_t *restrict rw, const struct times
2121 }
2222 return r;
2323}
24
25weak_alias(__pthread_rwlock_timedwrlock, pthread_rwlock_timedwrlock);
lib/libc/musl/src/thread/pthread_rwlock_tryrdlock.c+3-1
......@@ -1,6 +1,6 @@
11#include "pthread_impl.h"
22
3int pthread_rwlock_tryrdlock(pthread_rwlock_t *rw)
3int __pthread_rwlock_tryrdlock(pthread_rwlock_t *rw)
44{
55 int val, cnt;
66 do {
......@@ -11,3 +11,5 @@ int pthread_rwlock_tryrdlock(pthread_rwlock_t *rw)
1111 } while (a_cas(&rw->_rw_lock, val, val+1) != val);
1212 return 0;
1313}
14
15weak_alias(__pthread_rwlock_tryrdlock, pthread_rwlock_tryrdlock);
lib/libc/musl/src/thread/pthread_rwlock_trywrlock.c+3-1
......@@ -1,7 +1,9 @@
11#include "pthread_impl.h"
22
3int pthread_rwlock_trywrlock(pthread_rwlock_t *rw)
3int __pthread_rwlock_trywrlock(pthread_rwlock_t *rw)
44{
55 if (a_cas(&rw->_rw_lock, 0, 0x7fffffff)) return EBUSY;
66 return 0;
77}
8
9weak_alias(__pthread_rwlock_trywrlock, pthread_rwlock_trywrlock);
lib/libc/musl/src/thread/pthread_rwlock_unlock.c+3-1
......@@ -1,6 +1,6 @@
11#include "pthread_impl.h"
22
3int pthread_rwlock_unlock(pthread_rwlock_t *rw)
3int __pthread_rwlock_unlock(pthread_rwlock_t *rw)
44{
55 int val, cnt, waiters, new, priv = rw->_rw_shared^128;
66
......@@ -16,3 +16,5 @@ int pthread_rwlock_unlock(pthread_rwlock_t *rw)
1616
1717 return 0;
1818}
19
20weak_alias(__pthread_rwlock_unlock, pthread_rwlock_unlock);
lib/libc/musl/src/thread/pthread_rwlock_wrlock.c+4-2
......@@ -1,6 +1,8 @@
11#include "pthread_impl.h"
22
3int pthread_rwlock_wrlock(pthread_rwlock_t *rw)
3int __pthread_rwlock_wrlock(pthread_rwlock_t *rw)
44{
5 return pthread_rwlock_timedwrlock(rw, 0);
5 return __pthread_rwlock_timedwrlock(rw, 0);
66}
7
8weak_alias(__pthread_rwlock_wrlock, pthread_rwlock_wrlock);
lib/libc/musl/src/thread/riscv64/__set_thread_area.s created+6
......@@ -0,0 +1,6 @@
1.global __set_thread_area
2.type __set_thread_area, %function
3__set_thread_area:
4 mv tp, a0
5 li a0, 0
6 ret
lib/libc/musl/src/thread/riscv64/__unmapself.s created+7
......@@ -0,0 +1,7 @@
1.global __unmapself
2.type __unmapself, %function
3__unmapself:
4 li a7, 215 # SYS_munmap
5 ecall
6 li a7, 93 # SYS_exit
7 ecall
lib/libc/musl/src/thread/riscv64/clone.s created+34
......@@ -0,0 +1,34 @@
1# __clone(func, stack, flags, arg, ptid, tls, ctid)
2# a0, a1, a2, a3, a4, a5, a6
3
4# syscall(SYS_clone, flags, stack, ptid, tls, ctid)
5# a7 a0, a1, a2, a3, a4
6
7.global __clone
8.type __clone, %function
9__clone:
10 # Save func and arg to stack
11 addi a1, a1, -16
12 sd a0, 0(a1)
13 sd a3, 8(a1)
14
15 # Call SYS_clone
16 mv a0, a2
17 mv a2, a4
18 mv a3, a5
19 mv a4, a6
20 li a7, 220 # SYS_clone
21 ecall
22
23 beqz a0, 1f
24 # Parent
25 ret
26
27 # Child
281: ld a1, 0(sp)
29 ld a0, 8(sp)
30 jalr a1
31
32 # Exit
33 li a7, 93 # SYS_exit
34 ecall
lib/libc/musl/src/thread/riscv64/syscall_cp.s created+29
......@@ -0,0 +1,29 @@
1.global __cp_begin
2.hidden __cp_begin
3.global __cp_end
4.hidden __cp_end
5.global __cp_cancel
6.hidden __cp_cancel
7.hidden __cancel
8.global __syscall_cp_asm
9.hidden __syscall_cp_asm
10.type __syscall_cp_asm, %function
11__syscall_cp_asm:
12__cp_begin:
13 lw t0, 0(a0)
14 bnez t0, __cp_cancel
15
16 mv t0, a1
17 mv a0, a2
18 mv a1, a3
19 mv a2, a4
20 mv a3, a5
21 mv a4, a6
22 mv a5, a7
23 ld a6, 0(sp)
24 mv a7, t0
25 ecall
26__cp_end:
27 ret
28__cp_cancel:
29 tail __cancel
lib/libc/musl/src/thread/synccall.c+59-119
......@@ -1,46 +1,42 @@
11#include "pthread_impl.h"
22#include <semaphore.h>
3#include <unistd.h>
4#include <dirent.h>
53#include <string.h>
6#include <ctype.h>
7#include "futex.h"
8#include "atomic.h"
9#include "../dirent/__dirent.h"
10#include "lock.h"
11
12static struct chain {
13 struct chain *next;
14 int tid;
15 sem_t target_sem, caller_sem;
16} *volatile head;
17
18static volatile int synccall_lock[1];
19static volatile int target_tid;
4
5static void dummy_0(void)
6{
7}
8
9weak_alias(dummy_0, __tl_lock);
10weak_alias(dummy_0, __tl_unlock);
11
12static int target_tid;
2013static void (*callback)(void *), *context;
21static volatile int dummy = 0;
22weak_alias(dummy, __block_new_threads);
14static sem_t target_sem, caller_sem;
15
16static void dummy(void *p)
17{
18}
2319
2420static void handler(int sig)
2521{
26 struct chain ch;
27 int old_errno = errno;
22 if (__pthread_self()->tid != target_tid) return;
2823
29 sem_init(&ch.target_sem, 0, 0);
30 sem_init(&ch.caller_sem, 0, 0);
24 int old_errno = errno;
3125
32 ch.tid = __syscall(SYS_gettid);
26 /* Inform caller we have received signal and wait for
27 * the caller to let us make the callback. */
28 sem_post(&caller_sem);
29 sem_wait(&target_sem);
3330
34 do ch.next = head;
35 while (a_cas_p(&head, ch.next, &ch) != ch.next);
31 callback(context);
3632
37 if (a_cas(&target_tid, ch.tid, 0) == (ch.tid | 0x80000000))
38 __syscall(SYS_futex, &target_tid, FUTEX_UNLOCK_PI|FUTEX_PRIVATE);
33 /* Inform caller we've complered the callback and wait
34 * for the caller to release us to return. */
35 sem_post(&caller_sem);
36 sem_wait(&target_sem);
3937
40 sem_wait(&ch.target_sem);
41 callback(context);
42 sem_post(&ch.caller_sem);
43 sem_wait(&ch.target_sem);
38 /* Inform caller we are returning and state is destroyable. */
39 sem_post(&caller_sem);
4440
4541 errno = old_errno;
4642}
......@@ -48,12 +44,10 @@ static void handler(int sig)
4844void __synccall(void (*func)(void *), void *ctx)
4945{
5046 sigset_t oldmask;
51 int cs, i, r, pid, self;;
52 DIR dir = {0};
53 struct dirent *de;
47 int cs, i, r;
5448 struct sigaction sa = { .sa_flags = SA_RESTART, .sa_handler = handler };
55 struct chain *cp, *next;
56 struct timespec ts;
49 pthread_t self = __pthread_self(), td;
50 int count = 0;
5751
5852 /* Blocking signals in two steps, first only app-level signals
5953 * before taking the lock, then all signals after taking the lock,
......@@ -62,98 +56,45 @@ void __synccall(void (*func)(void *), void *ctx)
6256 * any until after the lock would allow re-entry in the same thread
6357 * with the lock already held. */
6458 __block_app_sigs(&oldmask);
65 LOCK(synccall_lock);
59 __tl_lock();
6660 __block_all_sigs(0);
6761 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
6862
69 head = 0;
63 sem_init(&target_sem, 0, 0);
64 sem_init(&caller_sem, 0, 0);
7065
71 if (!libc.threaded) goto single_threaded;
66 if (!libc.threads_minus_1) goto single_threaded;
7267
7368 callback = func;
7469 context = ctx;
7570
76 /* This atomic store ensures that any signaled threads will see the
77 * above stores, and prevents more than a bounded number of threads,
78 * those already in pthread_create, from creating new threads until
79 * the value is cleared to zero again. */
80 a_store(&__block_new_threads, 1);
81
8271 /* Block even implementation-internal signals, so that nothing
8372 * interrupts the SIGSYNCCALL handlers. The main possible source
8473 * of trouble is asynchronous cancellation. */
8574 memset(&sa.sa_mask, -1, sizeof sa.sa_mask);
8675 __libc_sigaction(SIGSYNCCALL, &sa, 0);
8776
88 pid = __syscall(SYS_getpid);
89 self = __syscall(SYS_gettid);
90
91 /* Since opendir is not AS-safe, the DIR needs to be setup manually
92 * in automatic storage. Thankfully this is easy. */
93 dir.fd = open("/proc/self/task", O_RDONLY|O_DIRECTORY|O_CLOEXEC);
94 if (dir.fd < 0) goto out;
95
96 /* Initially send one signal per counted thread. But since we can't
97 * synchronize with thread creation/exit here, there could be too
98 * few signals. This initial signaling is just an optimization, not
99 * part of the logic. */
100 for (i=libc.threads_minus_1; i; i--)
101 __syscall(SYS_kill, pid, SIGSYNCCALL);
102
103 /* Loop scanning the kernel-provided thread list until it shows no
104 * threads that have not already replied to the signal. */
105 for (;;) {
106 int miss_cnt = 0;
107 while ((de = readdir(&dir))) {
108 if (!isdigit(de->d_name[0])) continue;
109 int tid = atoi(de->d_name);
110 if (tid == self || !tid) continue;
111
112 /* Set the target thread as the PI futex owner before
113 * checking if it's in the list of caught threads. If it
114 * adds itself to the list after we check for it, then
115 * it will see its own tid in the PI futex and perform
116 * the unlock operation. */
117 a_store(&target_tid, tid);
118
119 /* Thread-already-caught is a success condition. */
120 for (cp = head; cp && cp->tid != tid; cp=cp->next);
121 if (cp) continue;
122
123 r = -__syscall(SYS_tgkill, pid, tid, SIGSYNCCALL);
124
125 /* Target thread exit is a success condition. */
126 if (r == ESRCH) continue;
127
128 /* The FUTEX_LOCK_PI operation is used to loan priority
129 * to the target thread, which otherwise may be unable
130 * to run. Timeout is necessary because there is a race
131 * condition where the tid may be reused by a different
132 * process. */
133 clock_gettime(CLOCK_REALTIME, &ts);
134 ts.tv_nsec += 10000000;
135 if (ts.tv_nsec >= 1000000000) {
136 ts.tv_sec++;
137 ts.tv_nsec -= 1000000000;
138 }
139 r = -__syscall(SYS_futex, &target_tid,
140 FUTEX_LOCK_PI|FUTEX_PRIVATE, 0, &ts);
141
142 /* Obtaining the lock means the thread responded. ESRCH
143 * means the target thread exited, which is okay too. */
144 if (!r || r == ESRCH) continue;
145
146 miss_cnt++;
77
78 for (td=self->next; td!=self; td=td->next) {
79 target_tid = td->tid;
80 while ((r = -__syscall(SYS_tkill, td->tid, SIGSYNCCALL)) == EAGAIN);
81 if (r) {
82 /* If we failed to signal any thread, nop out the
83 * callback to abort the synccall and just release
84 * any threads already caught. */
85 callback = func = dummy;
86 break;
14787 }
148 if (!miss_cnt) break;
149 rewinddir(&dir);
88 sem_wait(&caller_sem);
89 count++;
15090 }
151 close(dir.fd);
91 target_tid = 0;
15292
153 /* Serialize execution of callback in caught threads. */
154 for (cp=head; cp; cp=cp->next) {
155 sem_post(&cp->target_sem);
156 sem_wait(&cp->caller_sem);
93 /* Serialize execution of callback in caught threads, or just
94 * release them all if synccall is being aborted. */
95 for (i=0; i<count; i++) {
96 sem_post(&target_sem);
97 sem_wait(&caller_sem);
15798 }
15899
159100 sa.sa_handler = SIG_IGN;
......@@ -164,16 +105,15 @@ single_threaded:
164105
165106 /* Only release the caught threads once all threads, including the
166107 * caller, have returned from the callback function. */
167 for (cp=head; cp; cp=next) {
168 next = cp->next;
169 sem_post(&cp->target_sem);
170 }
108 for (i=0; i<count; i++)
109 sem_post(&target_sem);
110 for (i=0; i<count; i++)
111 sem_wait(&caller_sem);
171112
172out:
173 a_store(&__block_new_threads, 0);
174 __wake(&__block_new_threads, -1, 1);
113 sem_destroy(&caller_sem);
114 sem_destroy(&target_sem);
175115
176116 pthread_setcancelstate(cs, 0);
177 UNLOCK(synccall_lock);
117 __tl_unlock();
178118 __restore_sigs(&oldmask);
179119}
lib/libc/musl/src/time/timer_create.c+15-21
......@@ -27,23 +27,12 @@ static void cleanup_fromsig(void *p)
2727 self->cancelbuf = 0;
2828 self->canceldisable = 0;
2929 self->cancelasync = 0;
30 self->unblock_cancel = 0;
3130 __reset_tls();
3231 longjmp(p, 1);
3332}
3433
3534static void timer_handler(int sig, siginfo_t *si, void *ctx)
3635{
37 pthread_t self = __pthread_self();
38 jmp_buf jb;
39 void (*notify)(union sigval) = (void (*)(union sigval))self->start;
40 union sigval val = { .sival_ptr = self->start_arg };
41
42 if (!setjmp(jb) && si->si_code == SI_TIMER) {
43 pthread_cleanup_push(cleanup_fromsig, jb);
44 notify(val);
45 pthread_cleanup_pop(1);
46 }
4736}
4837
4938static void install_handler()
......@@ -59,20 +48,24 @@ static void *start(void *arg)
5948{
6049 pthread_t self = __pthread_self();
6150 struct start_args *args = arg;
62 int id;
51 int id = self->timer_id;
52 jmp_buf jb;
6353
64 /* Reuse no-longer-needed thread structure fields to avoid
65 * needing the timer address in the signal handler. */
66 self->start = (void *(*)(void *))args->sev->sigev_notify_function;
67 self->start_arg = args->sev->sigev_value.sival_ptr;
54 void (*notify)(union sigval) = args->sev->sigev_notify_function;
55 union sigval val = args->sev->sigev_value;
6856
6957 pthread_barrier_wait(&args->b);
70 if ((id = self->timer_id) >= 0) {
71 __syscall(SYS_rt_sigprocmask, SIG_UNBLOCK,
72 SIGTIMER_SET, 0, _NSIG/8);
73 __wait(&self->timer_id, 0, id, 1);
74 __syscall(SYS_timer_delete, id);
58 for (;;) {
59 siginfo_t si;
60 while (sigwaitinfo(SIGTIMER_SET, &si) < 0);
61 if (si.si_code == SI_TIMER && !setjmp(jb)) {
62 pthread_cleanup_push(cleanup_fromsig, jb);
63 notify(val);
64 pthread_cleanup_pop(1);
65 }
66 if (self->timer_id < 0) break;
7567 }
68 __syscall(SYS_timer_delete, id);
7669 return 0;
7770}
7871
......@@ -112,6 +105,7 @@ int timer_create(clockid_t clk, struct sigevent *restrict evp, timer_t *restrict
112105 args.sev = evp;
113106
114107 __block_app_sigs(&set);
108 __syscall(SYS_rt_sigprocmask, SIG_BLOCK, SIGTIMER_SET, 0, _NSIG/8);
115109 r = pthread_create(&td, &attr, start, &args);
116110 __restore_sigs(&set);
117111 if (r) {
lib/libc/musl/src/time/timer_delete.c+1-1
......@@ -7,7 +7,7 @@ int timer_delete(timer_t t)
77 if ((intptr_t)t < 0) {
88 pthread_t td = (void *)((uintptr_t)t << 1);
99 a_store(&td->timer_id, td->timer_id | INT_MIN);
10 __wake(&td->timer_id, 1, 1);
10 __syscall(SYS_tkill, td->tid, SIGTIMER);
1111 return 0;
1212 }
1313 return __syscall(SYS_timer_delete, t);
lib/libc/musl/src/unistd/renameat.c+4
......@@ -3,5 +3,9 @@
33
44int renameat(int oldfd, const char *old, int newfd, const char *new)
55{
6#ifdef SYS_renameat
67 return syscall(SYS_renameat, oldfd, old, newfd, new);
8#else
9 return syscall(SYS_renameat2, oldfd, old, newfd, new, 0);
10#endif
711}
lib/libc/musl/src/unistd/ualarm.c+3-3
......@@ -7,7 +7,7 @@ unsigned ualarm(unsigned value, unsigned interval)
77 struct itimerval it = {
88 .it_interval.tv_usec = interval,
99 .it_value.tv_usec = value
10 };
11 setitimer(ITIMER_REAL, &it, &it);
12 return it.it_value.tv_sec*1000000 + it.it_value.tv_usec;
10 }, it_old;
11 setitimer(ITIMER_REAL, &it, &it_old);
12 return it_old.it_value.tv_sec*1000000 + it_old.it_value.tv_usec;
1313}
src/codegen.cpp+1-24
......@@ -8273,30 +8273,7 @@ static void detect_libc(CodeGen *g) {
82738273 // musl has some overrides. its headers are ABI-agnostic and so they all have the "musl" ABI name.
82748274 abi_name = "musl";
82758275 // some architectures are handled by the same set of headers
8276 switch (g->zig_target->arch) {
8277 case ZigLLVM_aarch64:
8278 case ZigLLVM_aarch64_be:
8279 arch_name = "aarch64";
8280 break;
8281 case ZigLLVM_arm:
8282 case ZigLLVM_armeb:
8283 arch_name = "arm";
8284 break;
8285 case ZigLLVM_mips:
8286 case ZigLLVM_mipsel:
8287 arch_name = "mips";
8288 break;
8289 case ZigLLVM_mips64:
8290 case ZigLLVM_mips64el:
8291 arch_name = "mips64";
8292 break;
8293 case ZigLLVM_ppc64:
8294 case ZigLLVM_ppc64le:
8295 arch_name = "powerpc64";
8296 break;
8297 default:
8298 break;
8299 }
8276 arch_name = target_arch_musl_name(g->zig_target->arch);
83008277 }
83018278 Buf *arch_include_dir = buf_sprintf("%s" OS_SEP "libc" OS_SEP "include" OS_SEP "%s-%s-%s",
83028279 buf_ptr(g->zig_lib_dir), arch_name, target_os_name(g->zig_target->os), abi_name);
src/install_files.h+55-18
......@@ -188,6 +188,8 @@ static const char *ZIG_MUSL_SRC_FILES[] = {
188188"musl/src/fenv/powerpc/fenv-sf.c",
189189"musl/src/fenv/powerpc/fenv.S",
190190"musl/src/fenv/powerpc64/fenv.c",
191"musl/src/fenv/riscv64/fenv-sf.c",
192"musl/src/fenv/riscv64/fenv.S",
191193"musl/src/fenv/s390x/fenv.c",
192194"musl/src/fenv/sh/fenv-nofpu.c",
193195"musl/src/fenv/sh/fenv.S",
......@@ -205,20 +207,22 @@ static const char *ZIG_MUSL_SRC_FILES[] = {
205207"musl/src/include/stdlib.h",
206208"musl/src/include/string.h",
207209"musl/src/include/sys/auxv.h",
210"musl/src/include/sys/membarrier.h",
208211"musl/src/include/sys/mman.h",
209212"musl/src/include/sys/sysinfo.h",
210213"musl/src/include/sys/time.h",
211214"musl/src/include/time.h",
212215"musl/src/include/unistd.h",
213"musl/src/internal/aarch64/syscall.s",
214"musl/src/internal/arm/syscall.s",
216"musl/src/include/wchar.h",
215217"musl/src/internal/atomic.h",
218"musl/src/internal/complex_impl.h",
219"musl/src/internal/defsysinfo.c",
216220"musl/src/internal/dynlink.h",
217221"musl/src/internal/fdpic_crt.h",
218222"musl/src/internal/floatscan.c",
219223"musl/src/internal/floatscan.h",
220224"musl/src/internal/futex.h",
221"musl/src/internal/i386/syscall.s",
225"musl/src/internal/i386/defsysinfo.s",
222226"musl/src/internal/intscan.c",
223227"musl/src/internal/intscan.h",
224228"musl/src/internal/ksigaction.h",
......@@ -227,31 +231,17 @@ static const char *ZIG_MUSL_SRC_FILES[] = {
227231"musl/src/internal/libm.h",
228232"musl/src/internal/locale_impl.h",
229233"musl/src/internal/lock.h",
230"musl/src/internal/m68k/syscall.s",
231234"musl/src/internal/malloc_impl.h",
232"musl/src/internal/microblaze/syscall.s",
233"musl/src/internal/mips/syscall.s",
234"musl/src/internal/mips64/syscall.s",
235"musl/src/internal/mipsn32/syscall.s",
236"musl/src/internal/or1k/syscall.s",
237"musl/src/internal/powerpc/syscall.s",
238"musl/src/internal/powerpc64/syscall.s",
239235"musl/src/internal/procfdname.c",
240236"musl/src/internal/pthread_impl.h",
241"musl/src/internal/s390x/syscall.s",
242237"musl/src/internal/sh/__shcall.c",
243"musl/src/internal/sh/syscall.s",
244238"musl/src/internal/shgetc.c",
245239"musl/src/internal/shgetc.h",
246240"musl/src/internal/stdio_impl.h",
247"musl/src/internal/syscall.c",
248241"musl/src/internal/syscall.h",
249242"musl/src/internal/syscall_ret.c",
250243"musl/src/internal/vdso.c",
251244"musl/src/internal/version.c",
252"musl/src/internal/version.h",
253"musl/src/internal/x32/syscall.s",
254"musl/src/internal/x86_64/syscall.s",
255245"musl/src/ipc/ftok.c",
256246"musl/src/ipc/ipc.h",
257247"musl/src/ipc/msgctl.c",
......@@ -289,6 +279,7 @@ static const char *ZIG_MUSL_SRC_FILES[] = {
289279"musl/src/ldso/or1k/dlsym.s",
290280"musl/src/ldso/powerpc/dlsym.s",
291281"musl/src/ldso/powerpc64/dlsym.s",
282"musl/src/ldso/riscv64/dlsym.s",
292283"musl/src/ldso/s390x/dlsym.s",
293284"musl/src/ldso/sh/dlsym.s",
294285"musl/src/ldso/tlsdesc.c",
......@@ -331,6 +322,7 @@ static const char *ZIG_MUSL_SRC_FILES[] = {
331322"musl/src/linux/ioperm.c",
332323"musl/src/linux/iopl.c",
333324"musl/src/linux/klogctl.c",
325"musl/src/linux/membarrier.c",
334326"musl/src/linux/memfd_create.c",
335327"musl/src/linux/mlock2.c",
336328"musl/src/linux/module.c",
......@@ -425,6 +417,16 @@ static const char *ZIG_MUSL_SRC_FILES[] = {
425417"musl/src/math/__fpclassifyl.c",
426418"musl/src/math/__invtrigl.c",
427419"musl/src/math/__invtrigl.h",
420"musl/src/math/__math_divzero.c",
421"musl/src/math/__math_divzerof.c",
422"musl/src/math/__math_invalid.c",
423"musl/src/math/__math_invalidf.c",
424"musl/src/math/__math_oflow.c",
425"musl/src/math/__math_oflowf.c",
426"musl/src/math/__math_uflow.c",
427"musl/src/math/__math_uflowf.c",
428"musl/src/math/__math_xflow.c",
429"musl/src/math/__math_xflowf.c",
428430"musl/src/math/__polevll.c",
429431"musl/src/math/__rem_pio2.c",
430432"musl/src/math/__rem_pio2_large.c",
......@@ -520,7 +522,11 @@ static const char *ZIG_MUSL_SRC_FILES[] = {
520522"musl/src/math/exp10l.c",
521523"musl/src/math/exp2.c",
522524"musl/src/math/exp2f.c",
525"musl/src/math/exp2f_data.c",
526"musl/src/math/exp2f_data.h",
523527"musl/src/math/exp2l.c",
528"musl/src/math/exp_data.c",
529"musl/src/math/exp_data.h",
524530"musl/src/math/expf.c",
525531"musl/src/math/expl.c",
526532"musl/src/math/expm1.c",
......@@ -664,12 +670,20 @@ static const char *ZIG_MUSL_SRC_FILES[] = {
664670"musl/src/math/log1pf.c",
665671"musl/src/math/log1pl.c",
666672"musl/src/math/log2.c",
673"musl/src/math/log2_data.c",
674"musl/src/math/log2_data.h",
667675"musl/src/math/log2f.c",
676"musl/src/math/log2f_data.c",
677"musl/src/math/log2f_data.h",
668678"musl/src/math/log2l.c",
679"musl/src/math/log_data.c",
680"musl/src/math/log_data.h",
669681"musl/src/math/logb.c",
670682"musl/src/math/logbf.c",
671683"musl/src/math/logbl.c",
672684"musl/src/math/logf.c",
685"musl/src/math/logf_data.c",
686"musl/src/math/logf_data.h",
673687"musl/src/math/logl.c",
674688"musl/src/math/lrint.c",
675689"musl/src/math/lrintf.c",
......@@ -693,6 +707,8 @@ static const char *ZIG_MUSL_SRC_FILES[] = {
693707"musl/src/math/nexttowardf.c",
694708"musl/src/math/nexttowardl.c",
695709"musl/src/math/pow.c",
710"musl/src/math/pow_data.c",
711"musl/src/math/pow_data.h",
696712"musl/src/math/powerpc/fabs.c",
697713"musl/src/math/powerpc/fabsf.c",
698714"musl/src/math/powerpc/fma.c",
......@@ -722,6 +738,8 @@ static const char *ZIG_MUSL_SRC_FILES[] = {
722738"musl/src/math/powerpc64/trunc.c",
723739"musl/src/math/powerpc64/truncf.c",
724740"musl/src/math/powf.c",
741"musl/src/math/powf_data.c",
742"musl/src/math/powf_data.h",
725743"musl/src/math/powl.c",
726744"musl/src/math/remainder.c",
727745"musl/src/math/remainderf.c",
......@@ -732,6 +750,18 @@ static const char *ZIG_MUSL_SRC_FILES[] = {
732750"musl/src/math/rint.c",
733751"musl/src/math/rintf.c",
734752"musl/src/math/rintl.c",
753"musl/src/math/riscv64/copysign.c",
754"musl/src/math/riscv64/copysignf.c",
755"musl/src/math/riscv64/fabs.c",
756"musl/src/math/riscv64/fabsf.c",
757"musl/src/math/riscv64/fma.c",
758"musl/src/math/riscv64/fmaf.c",
759"musl/src/math/riscv64/fmax.c",
760"musl/src/math/riscv64/fmaxf.c",
761"musl/src/math/riscv64/fmin.c",
762"musl/src/math/riscv64/fminf.c",
763"musl/src/math/riscv64/sqrt.c",
764"musl/src/math/riscv64/sqrtf.c",
735765"musl/src/math/round.c",
736766"musl/src/math/roundf.c",
737767"musl/src/math/roundl.c",
......@@ -1146,6 +1176,8 @@ static const char *ZIG_MUSL_SRC_FILES[] = {
11461176"musl/src/setjmp/powerpc/setjmp.S",
11471177"musl/src/setjmp/powerpc64/longjmp.s",
11481178"musl/src/setjmp/powerpc64/setjmp.s",
1179"musl/src/setjmp/riscv64/longjmp.S",
1180"musl/src/setjmp/riscv64/setjmp.S",
11491181"musl/src/setjmp/s390x/longjmp.s",
11501182"musl/src/setjmp/s390x/setjmp.s",
11511183"musl/src/setjmp/setjmp.c",
......@@ -1183,6 +1215,8 @@ static const char *ZIG_MUSL_SRC_FILES[] = {
11831215"musl/src/signal/psignal.c",
11841216"musl/src/signal/raise.c",
11851217"musl/src/signal/restore.c",
1218"musl/src/signal/riscv64/restore.s",
1219"musl/src/signal/riscv64/sigsetjmp.s",
11861220"musl/src/signal/s390x/restore.s",
11871221"musl/src/signal/s390x/sigsetjmp.s",
11881222"musl/src/signal/setitimer.c",
......@@ -1588,7 +1622,6 @@ static const char *ZIG_MUSL_SRC_FILES[] = {
15881622"musl/src/thread/pthread_getspecific.c",
15891623"musl/src/thread/pthread_join.c",
15901624"musl/src/thread/pthread_key_create.c",
1591"musl/src/thread/pthread_key_delete.c",
15921625"musl/src/thread/pthread_kill.c",
15931626"musl/src/thread/pthread_mutex_consistent.c",
15941627"musl/src/thread/pthread_mutex_destroy.c",
......@@ -1634,6 +1667,10 @@ static const char *ZIG_MUSL_SRC_FILES[] = {
16341667"musl/src/thread/pthread_spin_trylock.c",
16351668"musl/src/thread/pthread_spin_unlock.c",
16361669"musl/src/thread/pthread_testcancel.c",
1670"musl/src/thread/riscv64/__set_thread_area.s",
1671"musl/src/thread/riscv64/__unmapself.s",
1672"musl/src/thread/riscv64/clone.s",
1673"musl/src/thread/riscv64/syscall_cp.s",
16371674"musl/src/thread/s390x/__set_thread_area.s",
16381675"musl/src/thread/s390x/__tls_get_offset.s",
16391676"musl/src/thread/s390x/__unmapself.s",
src/link.cpp+9-34
......@@ -914,39 +914,9 @@ static const char *glibc_start_asm_path(CodeGen *parent, const char *file) {
914914 return buf_ptr(&result);
915915}
916916
917static const char *musl_arch_name(const ZigTarget *target) {
918 switch (target->arch) {
919 case ZigLLVM_aarch64:
920 case ZigLLVM_aarch64_be:
921 return "aarch64";
922 case ZigLLVM_arm:
923 case ZigLLVM_armeb:
924 return "arm";
925 case ZigLLVM_mips:
926 case ZigLLVM_mipsel:
927 return "mips";
928 case ZigLLVM_mips64el:
929 case ZigLLVM_mips64:
930 return "mips64";
931 case ZigLLVM_ppc:
932 return "powerpc";
933 case ZigLLVM_ppc64:
934 case ZigLLVM_ppc64le:
935 return "powerpc64";
936 case ZigLLVM_systemz:
937 return "s390x";
938 case ZigLLVM_x86:
939 return "i386";
940 case ZigLLVM_x86_64:
941 return "x86_64";
942 default:
943 zig_unreachable();
944 }
945}
946
947917static const char *musl_start_asm_path(CodeGen *parent, const char *file) {
948918 Buf *result = buf_sprintf("%s" OS_SEP "libc" OS_SEP "musl" OS_SEP "crt" OS_SEP "%s" OS_SEP "%s",
949 buf_ptr(parent->zig_lib_dir), musl_arch_name(parent->zig_target), file);
919 buf_ptr(parent->zig_lib_dir), target_arch_musl_name(parent->zig_target->arch), file);
950920 return buf_ptr(result);
951921}
952922
......@@ -961,18 +931,22 @@ static void musl_add_cc_args(CodeGen *parent, CFile *c_file, bool want_O3) {
961931
962932 c_file->args.append("-I");
963933 c_file->args.append(buf_ptr(buf_sprintf("%s" OS_SEP "libc" OS_SEP "musl" OS_SEP "arch" OS_SEP "%s",
964 buf_ptr(parent->zig_lib_dir), musl_arch_name(parent->zig_target))));
934 buf_ptr(parent->zig_lib_dir), target_arch_musl_name(parent->zig_target->arch))));
965935
966936 c_file->args.append("-I");
967937 c_file->args.append(buf_ptr(buf_sprintf("%s" OS_SEP "libc" OS_SEP "musl" OS_SEP "arch" OS_SEP "generic",
968938 buf_ptr(parent->zig_lib_dir))));
969939
940 c_file->args.append("-I");
941 c_file->args.append(buf_ptr(buf_sprintf("%s" OS_SEP "libc" OS_SEP "musl" OS_SEP "src" OS_SEP "include",
942 buf_ptr(parent->zig_lib_dir))));
943
970944 c_file->args.append("-I");
971945 c_file->args.append(buf_ptr(buf_sprintf("%s" OS_SEP "libc" OS_SEP "musl" OS_SEP "src" OS_SEP "internal",
972946 buf_ptr(parent->zig_lib_dir))));
973947
974948 c_file->args.append("-I");
975 c_file->args.append(buf_ptr(buf_sprintf("%s" OS_SEP "libc" OS_SEP "musl" OS_SEP "src" OS_SEP "include",
949 c_file->args.append(buf_ptr(buf_sprintf("%s" OS_SEP "libc" OS_SEP "musl" OS_SEP "include",
976950 buf_ptr(parent->zig_lib_dir))));
977951
978952 c_file->args.append("-I");
......@@ -1012,6 +986,7 @@ static const char *musl_arch_names[] = {
1012986 "or1k",
1013987 "powerpc",
1014988 "powerpc64",
989 "riscv64",
1015990 "s390x",
1016991 "sh",
1017992 "x32",
......@@ -1039,7 +1014,7 @@ static const char *build_musl(CodeGen *parent) {
10391014 MuslSrcO3,
10401015 };
10411016
1042 const char *target_musl_arch_name = musl_arch_name(parent->zig_target);
1017 const char *target_musl_arch_name = target_arch_musl_name(parent->zig_target->arch);
10431018
10441019 HashMap<Buf *, MuslSrc, buf_hash, buf_eql_buf> source_table = {};
10451020 source_table.init(1800);
src/target.cpp+34-2
......@@ -1524,7 +1524,7 @@ static const AvailableLibC libcs_available[] = {
15241524 {ZigLLVM_aarch64_be, OsLinux, ZigLLVM_Musl},
15251525 {ZigLLVM_aarch64_be, OsWindows, ZigLLVM_GNU},
15261526 {ZigLLVM_aarch64, OsLinux, ZigLLVM_GNU},
1527 {ZigLLVM_aarch64, OsLinux, ZigLLVM_MuslEABI},
1527 {ZigLLVM_aarch64, OsLinux, ZigLLVM_Musl},
15281528 {ZigLLVM_aarch64, OsWindows, ZigLLVM_GNU},
15291529 {ZigLLVM_armeb, OsLinux, ZigLLVM_GNUEABI},
15301530 {ZigLLVM_armeb, OsLinux, ZigLLVM_GNUEABIHF},
......@@ -1555,7 +1555,6 @@ static const AvailableLibC libcs_available[] = {
15551555 {ZigLLVM_ppc64, OsLinux, ZigLLVM_Musl},
15561556 {ZigLLVM_ppc, OsLinux, ZigLLVM_GNU},
15571557 {ZigLLVM_ppc, OsLinux, ZigLLVM_Musl},
1558 {ZigLLVM_riscv32, OsLinux, ZigLLVM_Musl},
15591558 {ZigLLVM_riscv64, OsLinux, ZigLLVM_GNU},
15601559 {ZigLLVM_riscv64, OsLinux, ZigLLVM_Musl},
15611560 {ZigLLVM_systemz, OsLinux, ZigLLVM_GNU},
......@@ -1655,3 +1654,36 @@ void target_libc_enum(size_t index, ZigTarget *out_target) {
16551654bool target_has_debug_info(const ZigTarget *target) {
16561655 return !target_is_wasm(target);
16571656}
1657
1658const char *target_arch_musl_name(ZigLLVM_ArchType arch) {
1659 switch (arch) {
1660 case ZigLLVM_aarch64:
1661 case ZigLLVM_aarch64_be:
1662 return "aarch64";
1663 case ZigLLVM_arm:
1664 case ZigLLVM_armeb:
1665 return "arm";
1666 case ZigLLVM_mips:
1667 case ZigLLVM_mipsel:
1668 return "mips";
1669 case ZigLLVM_mips64el:
1670 case ZigLLVM_mips64:
1671 return "mips64";
1672 case ZigLLVM_ppc:
1673 return "powerpc";
1674 case ZigLLVM_ppc64:
1675 case ZigLLVM_ppc64le:
1676 return "powerpc64";
1677 case ZigLLVM_systemz:
1678 return "s390x";
1679 case ZigLLVM_x86:
1680 return "i386";
1681 case ZigLLVM_x86_64:
1682 return "x86_64";
1683 case ZigLLVM_riscv64:
1684 return "riscv64";
1685 default:
1686 zig_unreachable();
1687 }
1688}
1689
src/target.hpp+1
......@@ -188,6 +188,7 @@ bool target_is_wasm(const ZigTarget *target);
188188bool target_is_single_threaded(const ZigTarget *target);
189189bool target_supports_stack_probing(const ZigTarget *target);
190190bool target_has_debug_info(const ZigTarget *target);
191const char *target_arch_musl_name(ZigLLVM_ArchType arch);
191192
192193uint32_t target_arch_pointer_bit_width(ZigLLVM_ArchType arch);
193194