summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/arch/x86_64/vdso_setup.c4
-rw-r--r--lib/libc/arpa/htonl.c4
-rw-r--r--lib/libc/arpa/htons.c4
-rw-r--r--lib/libc/arpa/ntohl.c4
-rw-r--r--lib/libc/arpa/ntohs.c4
-rw-r--r--lib/libc/ctype/isalpha.c8
-rw-r--r--lib/libc/ctype/isblank.c8
-rw-r--r--lib/libc/ctype/iscntrl.c8
-rw-r--r--lib/libc/ctype/isdigit.c8
-rw-r--r--lib/libc/ctype/isgraph.c8
-rw-r--r--lib/libc/ctype/islower.c8
-rw-r--r--lib/libc/ctype/isprint.c8
-rw-r--r--lib/libc/ctype/ispunct.c8
-rw-r--r--lib/libc/ctype/isspace.c8
-rw-r--r--lib/libc/ctype/isupper.c8
-rw-r--r--lib/libc/ctype/tolower.c8
-rw-r--r--lib/libc/ctype/toupper.c5
-rw-r--r--lib/libc/devctl/posix_devctl.c4
-rw-r--r--lib/libc/dirent/readdir_r.c10
-rw-r--r--lib/libc/endian/be16toh.c4
-rw-r--r--lib/libc/endian/be32toh.c4
-rw-r--r--lib/libc/endian/be64toh.c4
-rw-r--r--lib/libc/endian/htobe16.c4
-rw-r--r--lib/libc/endian/htobe32.c4
-rw-r--r--lib/libc/endian/htobe64.c4
-rw-r--r--lib/libc/endian/htole16.c4
-rw-r--r--lib/libc/endian/htole32.c4
-rw-r--r--lib/libc/endian/htole64.c4
-rw-r--r--lib/libc/endian/le16toh.c4
-rw-r--r--lib/libc/endian/le32toh.c4
-rw-r--r--lib/libc/endian/le64toh.c4
-rw-r--r--lib/libc/fcntl/creat.c3
-rw-r--r--lib/libc/fcntl/fcntl.c1
-rw-r--r--lib/libc/fcntl/open.c3
-rw-r--r--lib/libc/fcntl/openat.c3
-rw-r--r--lib/libc/fcntl/posix_fadvise.c3
-rw-r--r--lib/libc/fcntl/posix_fallocate.c3
-rw-r--r--lib/libc/grp/getgrgid_r.c4
-rw-r--r--lib/libc/include/__dirent.h3
-rw-r--r--lib/libc/include/__stdio.h10
-rw-r--r--lib/libc/include/__thread.h (renamed from lib/libc/include/thread.h)0
-rw-r--r--lib/libc/include/atomic.h4
-rw-r--r--lib/libc/include/libc.h10
-rw-r--r--lib/libc/include/malloc.h10
-rw-r--r--lib/libc/inttypes/imaxabs.c3
-rw-r--r--lib/libc/inttypes/strtoumax.c5
-rw-r--r--lib/libc/libc.abin1354072 -> 1358016 bytes
-rw-r--r--lib/libc/libgen/basename.c4
-rw-r--r--lib/libc/libgen/dirname.c14
-rw-r--r--lib/libc/mman/mlock.c3
-rw-r--r--lib/libc/mman/mlockall.c3
-rw-r--r--lib/libc/mman/mmap.c3
-rw-r--r--lib/libc/mman/mprotect.c3
-rw-r--r--lib/libc/mman/msync.c3
-rw-r--r--lib/libc/mman/munlock.c3
-rw-r--r--lib/libc/mman/munlockall.c3
-rw-r--r--lib/libc/mman/munmap.c4
-rw-r--r--lib/libc/mman/posix_madvise.c4
-rw-r--r--lib/libc/msg/msgctl.c3
-rw-r--r--lib/libc/poll/poll.c3
-rw-r--r--lib/libc/poll/ppoll.c4
-rw-r--r--lib/libc/pwd/getgrgid_r.c4
-rw-r--r--lib/libc/select/pselect.c6
-rw-r--r--lib/libc/select/select.c6
-rw-r--r--lib/libc/sem/semctl.c3
-rw-r--r--lib/libc/sem/semget.c3
-rw-r--r--lib/libc/sem/semop.c4
-rw-r--r--lib/libc/signal/kill.c3
-rw-r--r--lib/libc/signal/pthread_kill.c3
-rw-r--r--lib/libc/signal/sigabbrev.h1
-rw-r--r--lib/libc/signal/sigaction.c3
-rw-r--r--lib/libc/signal/siglist.c1
-rw-r--r--lib/libc/signal/sigpending.c3
-rw-r--r--lib/libc/signal/sigprocmask.c3
-rw-r--r--lib/libc/signal/sigsuspend.c3
-rw-r--r--lib/libc/signal/sigtimedwait.c4
-rw-r--r--lib/libc/signal/str2sig.c4
-rw-r--r--lib/libc/signal/sysv_signal.c2
-rw-r--r--lib/libc/socket/accept.c3
-rw-r--r--lib/libc/socket/accept4.c3
-rw-r--r--lib/libc/socket/bind.c3
-rw-r--r--lib/libc/socket/connect.c3
-rw-r--r--lib/libc/socket/getpeername.c3
-rw-r--r--lib/libc/socket/getsockname.c3
-rw-r--r--lib/libc/socket/getsockopt.c3
-rw-r--r--lib/libc/socket/listen.c3
-rw-r--r--lib/libc/socket/recv.c4
-rw-r--r--lib/libc/socket/recvfrom.c4
-rw-r--r--lib/libc/socket/recvmsg.c3
-rw-r--r--lib/libc/socket/send.c4
-rw-r--r--lib/libc/socket/sendmsg.c3
-rw-r--r--lib/libc/socket/sendto.c4
-rw-r--r--lib/libc/socket/setsockopt.c3
-rw-r--r--lib/libc/socket/shutdown.c3
-rw-r--r--lib/libc/socket/sockatmark.c3
-rw-r--r--lib/libc/socket/socket.c3
-rw-r--r--lib/libc/socket/socketpair.c3
-rw-r--r--lib/libc/stat/chmod.c3
-rw-r--r--lib/libc/stat/fchmod.c3
-rw-r--r--lib/libc/stat/fchmodat.c3
-rw-r--r--lib/libc/stat/fstatat.c1
-rw-r--r--lib/libc/stat/futimens.c2
-rw-r--r--lib/libc/stat/mkdirat.c3
-rw-r--r--lib/libc/stat/mknod.c3
-rw-r--r--lib/libc/stat/mknodat.c3
-rw-r--r--lib/libc/stat/umask.c3
-rw-r--r--lib/libc/stat/utimensat.c3
-rw-r--r--lib/libc/statvfs/fstatvfs.c3
-rw-r--r--lib/libc/statvfs/statvfs.c3
-rw-r--r--lib/libc/stdio/clearerr.c7
-rw-r--r--lib/libc/stdio/dtoa.c8
-rw-r--r--lib/libc/stdio/fclose.c8
-rw-r--r--lib/libc/stdio/fdopen.c16
-rw-r--r--lib/libc/stdio/feof.c6
-rw-r--r--lib/libc/stdio/ferror.c5
-rw-r--r--lib/libc/stdio/fflush.c39
-rw-r--r--lib/libc/stdio/fileno.c14
-rw-r--r--lib/libc/stdio/fmemopen.c13
-rw-r--r--lib/libc/stdio/fopen.c15
-rw-r--r--lib/libc/stdio/fputc.c13
-rw-r--r--lib/libc/stdio/fread.c29
-rw-r--r--lib/libc/stdio/fseek.c21
-rw-r--r--lib/libc/stdio/fwrite.c53
-rw-r--r--lib/libc/stdio/pclose.c4
-rw-r--r--lib/libc/stdio/perror.c4
-rw-r--r--lib/libc/stdio/popen.c18
-rw-r--r--lib/libc/stdio/remove.c4
-rw-r--r--lib/libc/stdio/rename.c4
-rw-r--r--lib/libc/stdio/renameat.c3
-rw-r--r--lib/libc/stdio/setbuf.c4
-rw-r--r--lib/libc/stdio/setvbuf.c14
-rw-r--r--lib/libc/stdio/stderr.c3
-rw-r--r--lib/libc/stdio/stdin.c4
-rw-r--r--lib/libc/stdio/stdout.c1
-rw-r--r--lib/libc/stdlib/_Exit.c2
-rw-r--r--lib/libc/stdlib/abort.c21
-rw-r--r--lib/libc/stdlib/abs.c2
-rw-r--r--lib/libc/stdlib/aligned_alloc.c10
-rw-r--r--lib/libc/stdlib/atexit.c4
-rw-r--r--lib/libc/stdlib/atof.c4
-rw-r--r--lib/libc/stdlib/atoi.c4
-rw-r--r--lib/libc/stdlib/atol.c4
-rw-r--r--lib/libc/stdlib/atoll.c4
-rw-r--r--lib/libc/stdlib/bsearch.c5
-rw-r--r--lib/libc/stdlib/btowc.c2
-rw-r--r--lib/libc/stdlib/calloc.c8
-rw-r--r--lib/libc/stdlib/div.c2
-rw-r--r--lib/libc/stdlib/exit.c21
-rw-r--r--lib/libc/stdlib/free.c13
-rw-r--r--lib/libc/stdlib/getenv.c7
-rw-r--r--lib/libc/stdlib/heapsort.c92
-rw-r--r--lib/libc/stdlib/heapsort_r.c92
-rw-r--r--lib/libc/stdlib/labs.c2
-rw-r--r--lib/libc/stdlib/ldiv.c2
-rw-r--r--lib/libc/stdlib/llabs.c2
-rw-r--r--lib/libc/stdlib/lldiv.c2
-rw-r--r--lib/libc/stdlib/malloc.c21
-rw-r--r--lib/libc/stdlib/posix_memalign.c6
-rw-r--r--lib/libc/stdlib/putenv.c4
-rw-r--r--lib/libc/stdlib/qsort.c2
-rw-r--r--lib/libc/stdlib/qsort_r.c6
-rw-r--r--lib/libc/stdlib/quick_exit.c2
-rw-r--r--lib/libc/stdlib/rand.c4
-rw-r--r--lib/libc/stdlib/realloc.c29
-rw-r--r--lib/libc/stdlib/reallocarray.c8
-rw-r--r--lib/libc/stdlib/setenv.c17
-rw-r--r--lib/libc/stdlib/strtox.c37
-rw-r--r--lib/libc/stdlib/system.c2
-rw-r--r--lib/libc/stdlib/unsetenv.c8
-rw-r--r--lib/libc/stdlib/wctomb.c1
-rw-r--r--lib/libc/string/memchr.c3
-rw-r--r--lib/libc/string/memcmp.c2
-rw-r--r--lib/libc/string/memcpy.c3
-rw-r--r--lib/libc/string/memmem.c4
-rw-r--r--lib/libc/string/memmove.c2
-rw-r--r--lib/libc/string/stpncpy.c2
-rw-r--r--lib/libc/string/strcat.c2
-rw-r--r--lib/libc/string/strchr.c4
-rw-r--r--lib/libc/string/strcmp.c1
-rw-r--r--lib/libc/string/strcoll.c3
-rw-r--r--lib/libc/string/strcpy.c2
-rw-r--r--lib/libc/string/strcspn.c4
-rw-r--r--lib/libc/string/strdup.c4
-rw-r--r--lib/libc/string/strerror.c4
-rw-r--r--lib/libc/string/strlen.c3
-rw-r--r--lib/libc/string/strncmp.c2
-rw-r--r--lib/libc/string/strncpy.c2
-rw-r--r--lib/libc/string/strndup.c4
-rw-r--r--lib/libc/string/strpbrk.c1
-rw-r--r--lib/libc/string/strrchr.c1
-rw-r--r--lib/libc/string/strspn.c4
-rw-r--r--lib/libc/string/strstr.c1
-rw-r--r--lib/libc/string/strtok.c4
-rw-r--r--lib/libc/string/strtok_r.c4
-rw-r--r--lib/libc/string/strxfrm.c4
-rw-r--r--lib/libc/strings/strncasecmp.c2
-rw-r--r--lib/libc/sys/ioctl.c3
-rw-r--r--lib/libc/sys/mount.c3
-rw-r--r--lib/libc/sys/umount.c3
-rw-r--r--lib/libc/sys/umount2.c3
-rw-r--r--lib/libc/termios/cfgetispeed.c1
-rw-r--r--lib/libc/termios/cfgetospeed.c1
-rw-r--r--lib/libc/termios/cfsetispeed.c3
-rw-r--r--lib/libc/termios/cfsetospeed.c3
-rw-r--r--lib/libc/termios/tcflush.c4
-rw-r--r--lib/libc/termios/tcgetattr.c4
-rw-r--r--lib/libc/termios/tcgetsid.c4
-rw-r--r--lib/libc/termios/tcgetwinsize.c4
-rw-r--r--lib/libc/termios/tcsendbreak.c4
-rw-r--r--lib/libc/termios/tcsetattr.c4
-rw-r--r--lib/libc/termios/tcsetwinsize.c4
-rw-r--r--lib/libc/thread/thrd_current.c5
-rw-r--r--lib/libc/time/asctime.c4
-rw-r--r--lib/libc/time/clock.c4
-rw-r--r--lib/libc/time/clock_getcpuclockid.c6
-rw-r--r--lib/libc/time/clock_getres.c6
-rw-r--r--lib/libc/time/clock_nanosleep.c6
-rw-r--r--lib/libc/time/ctime.c2
-rw-r--r--lib/libc/time/difftime.c4
-rw-r--r--lib/libc/time/gmtime_r.c2
-rw-r--r--lib/libc/time/localtime.c2
-rw-r--r--lib/libc/time/localtime_r.c2
-rw-r--r--lib/libc/time/nanosleep.c6
-rw-r--r--lib/libc/time/strftime.c27
-rw-r--r--lib/libc/time/time.c5
-rw-r--r--lib/libc/time/tzset.c6
-rw-r--r--lib/libc/time/utimes.c11
-rw-r--r--lib/libc/times/times.c1
-rw-r--r--lib/libc/uio/readv.c7
-rw-r--r--lib/libc/uio/writev.c2
-rw-r--r--lib/libc/unistd/_Fork.c3
-rw-r--r--lib/libc/unistd/_exit.c3
-rw-r--r--lib/libc/unistd/access.c3
-rw-r--r--lib/libc/unistd/alarm.c3
-rw-r--r--lib/libc/unistd/chdir.c3
-rw-r--r--lib/libc/unistd/chown.c3
-rw-r--r--lib/libc/unistd/close.c3
-rw-r--r--lib/libc/unistd/dup.c3
-rw-r--r--lib/libc/unistd/dup2.c3
-rw-r--r--lib/libc/unistd/dup3.c3
-rw-r--r--lib/libc/unistd/execv.c3
-rw-r--r--lib/libc/unistd/execve.c3
-rw-r--r--lib/libc/unistd/execvp.c7
-rw-r--r--lib/libc/unistd/faccessat.c3
-rw-r--r--lib/libc/unistd/fchdir.c3
-rw-r--r--lib/libc/unistd/fchown.c3
-rw-r--r--lib/libc/unistd/fchownat.c3
-rw-r--r--lib/libc/unistd/fdatasync.c3
-rw-r--r--lib/libc/unistd/fsync.c3
-rw-r--r--lib/libc/unistd/ftruncate.c3
-rw-r--r--lib/libc/unistd/getcwd.c3
-rw-r--r--lib/libc/unistd/getegid.c3
-rw-r--r--lib/libc/unistd/getentropy.c1
-rw-r--r--lib/libc/unistd/geteuid.c3
-rw-r--r--lib/libc/unistd/getgid.c3
-rw-r--r--lib/libc/unistd/getgroups.c3
-rw-r--r--lib/libc/unistd/gethostname.c1
-rw-r--r--lib/libc/unistd/getlogin_r.c1
-rw-r--r--lib/libc/unistd/getopt.c4
-rw-r--r--lib/libc/unistd/getpgid.c3
-rw-r--r--lib/libc/unistd/getpid.c3
-rw-r--r--lib/libc/unistd/getppid.c3
-rw-r--r--lib/libc/unistd/getresgid.c3
-rw-r--r--lib/libc/unistd/getresuid.c3
-rw-r--r--lib/libc/unistd/getsid.c3
-rw-r--r--lib/libc/unistd/getuid.c3
-rw-r--r--lib/libc/unistd/isatty.c4
-rw-r--r--lib/libc/unistd/lchown.c3
-rw-r--r--lib/libc/unistd/link.c3
-rw-r--r--lib/libc/unistd/linkat.c3
-rw-r--r--lib/libc/unistd/lseek.c3
-rw-r--r--lib/libc/unistd/pause.c3
-rw-r--r--lib/libc/unistd/pipe.c3
-rw-r--r--lib/libc/unistd/pipe2.c3
-rw-r--r--lib/libc/unistd/posix_close.c3
-rw-r--r--lib/libc/unistd/pread.c1
-rw-r--r--lib/libc/unistd/pwrite.c1
-rw-r--r--lib/libc/unistd/read.c4
-rw-r--r--lib/libc/unistd/readlink.c4
-rw-r--r--lib/libc/unistd/readlinkat.c4
-rw-r--r--lib/libc/unistd/rmdir.c3
-rw-r--r--lib/libc/unistd/setegid.c3
-rw-r--r--lib/libc/unistd/seteuid.c3
-rw-r--r--lib/libc/unistd/setgid.c3
-rw-r--r--lib/libc/unistd/setpgid.c3
-rw-r--r--lib/libc/unistd/setregid.c3
-rw-r--r--lib/libc/unistd/setresgid.c3
-rw-r--r--lib/libc/unistd/setresuid.c3
-rw-r--r--lib/libc/unistd/setreuid.c3
-rw-r--r--lib/libc/unistd/setsid.c3
-rw-r--r--lib/libc/unistd/setuid.c3
-rw-r--r--lib/libc/unistd/symlink.c3
-rw-r--r--lib/libc/unistd/symlinkat.c3
-rw-r--r--lib/libc/unistd/sync.c3
-rw-r--r--lib/libc/unistd/truncate.c3
-rw-r--r--lib/libc/unistd/unlink.c3
-rw-r--r--lib/libc/unistd/unlinkat.c3
-rw-r--r--lib/libc/unistd/write.c4
-rw-r--r--lib/libc/utime/utime.c4
-rw-r--r--lib/libc/utsname/uname.c3
-rw-r--r--lib/libc/wait/wait.c1
-rw-r--r--lib/libc/wait/waitid.c3
-rw-r--r--lib/libc/wait/waitpid.c1
303 files changed, 953 insertions, 700 deletions
diff --git a/lib/libc/arch/x86_64/vdso_setup.c b/lib/libc/arch/x86_64/vdso_setup.c
index e1dbd0a3..059aa44a 100644
--- a/lib/libc/arch/x86_64/vdso_setup.c
+++ b/lib/libc/arch/x86_64/vdso_setup.c
@@ -1,5 +1,7 @@
#include <linux/elf.h> // for Elf64_Sym, (anonymous struct)::(anonymous)
-#include <string.h> // for NULL, strcmp
+#include "stddef.h" // for NULL
+
+#include <string.h> // for strcmp
struct timespec;
diff --git a/lib/libc/arpa/htonl.c b/lib/libc/arpa/htonl.c
index bab87482..365e457a 100644
--- a/lib/libc/arpa/htonl.c
+++ b/lib/libc/arpa/htonl.c
@@ -1,6 +1,6 @@
-#include <arpa/inet.h> // for htonl
+#include <arpa/inet.h> // for uint32_t, htonl
#include <byteswap.h> // for bswap32
-#include <stdint.h> // for uint32_t
+#include <stdint.h>
uint32_t htonl(uint32_t hostlong)
{
diff --git a/lib/libc/arpa/htons.c b/lib/libc/arpa/htons.c
index 9cfa42f6..bc119901 100644
--- a/lib/libc/arpa/htons.c
+++ b/lib/libc/arpa/htons.c
@@ -1,6 +1,6 @@
-#include <arpa/inet.h> // for htons
+#include <arpa/inet.h> // for uint16_t, htons
#include <byteswap.h> // for bswap16
-#include <stdint.h> // for uint16_t
+#include <stdint.h>
uint16_t htons(uint16_t hostshort)
{
diff --git a/lib/libc/arpa/ntohl.c b/lib/libc/arpa/ntohl.c
index 691c3543..f705b731 100644
--- a/lib/libc/arpa/ntohl.c
+++ b/lib/libc/arpa/ntohl.c
@@ -1,6 +1,6 @@
-#include <arpa/inet.h> // for ntohl
+#include <arpa/inet.h> // for uint32_t, ntohl
#include <byteswap.h> // for bswap32
-#include <stdint.h> // for uint32_t
+#include <stdint.h>
uint32_t ntohl(uint32_t netlong)
{
diff --git a/lib/libc/arpa/ntohs.c b/lib/libc/arpa/ntohs.c
index 6c7e55d6..8dc753fa 100644
--- a/lib/libc/arpa/ntohs.c
+++ b/lib/libc/arpa/ntohs.c
@@ -1,6 +1,6 @@
-#include <arpa/inet.h> // for ntohs
+#include <arpa/inet.h> // for uint16_t, ntohs
#include <byteswap.h> // for bswap16
-#include <stdint.h> // for uint16_t
+#include <stdint.h>
uint16_t ntohs(uint16_t netshort)
{
diff --git a/lib/libc/ctype/isalpha.c b/lib/libc/ctype/isalpha.c
index a1b89762..6727d22a 100644
--- a/lib/libc/ctype/isalpha.c
+++ b/lib/libc/ctype/isalpha.c
@@ -1,8 +1,12 @@
-#include <libc.h> // for weak_reference
+#include <ctype.h> // for isalpha, isalpha_l, locale_t
+#include <sys/cdefs.h> // for __unused, __weak
int isalpha(int c)
{
return ((unsigned)c | 32) - 'a' < 26;
}
-weak_reference(isalpha, isalpha_l);
+__weak int isalpha_l(int c, locale_t __unused locale)
+{
+ return isalpha(c);
+}
diff --git a/lib/libc/ctype/isblank.c b/lib/libc/ctype/isblank.c
index c4dacfb2..dfe9472c 100644
--- a/lib/libc/ctype/isblank.c
+++ b/lib/libc/ctype/isblank.c
@@ -1,8 +1,12 @@
-#include <libc.h> // for weak_reference
+#include <ctype.h> // for isblank, isblank_l, locale_t
+#include <sys/cdefs.h> // for __unused, __weak
int isblank(int c)
{
return (c == ' ' || c == '\t');
}
-weak_reference(isblank, isblank_l);
+__weak int isblank_l(int c, locale_t __unused locale)
+{
+ return isblank(c);
+}
diff --git a/lib/libc/ctype/iscntrl.c b/lib/libc/ctype/iscntrl.c
index c25773b6..53b8616a 100644
--- a/lib/libc/ctype/iscntrl.c
+++ b/lib/libc/ctype/iscntrl.c
@@ -1,8 +1,12 @@
-#include <libc.h> // for weak_reference
+#include <ctype.h> // for iscntrl, iscntrl_l, locale_t
+#include <sys/cdefs.h> // for __unused, __weak
int iscntrl(int c)
{
return (unsigned)c < 0x20 || c == 0x7f;
}
-weak_reference(iscntrl, iscntrl_l);
+__weak int iscntrl_l(int c, locale_t __unused locale)
+{
+ return iscntrl(c);
+}
diff --git a/lib/libc/ctype/isdigit.c b/lib/libc/ctype/isdigit.c
index fa36222d..c33dc1b9 100644
--- a/lib/libc/ctype/isdigit.c
+++ b/lib/libc/ctype/isdigit.c
@@ -1,8 +1,12 @@
-#include <libc.h> // for weak_reference
+#include <ctype.h> // for isdigit, isdigit_l, locale_t
+#include <sys/cdefs.h> // for __unused, __weak
int isdigit(int c)
{
return (unsigned)c - '0' < 10;
}
-weak_reference(isdigit, isdigit_l);
+__weak int isdigit_l(int c, locale_t __unused locale)
+{
+ return isdigit(c);
+}
diff --git a/lib/libc/ctype/isgraph.c b/lib/libc/ctype/isgraph.c
index 07df57d0..39e72159 100644
--- a/lib/libc/ctype/isgraph.c
+++ b/lib/libc/ctype/isgraph.c
@@ -1,8 +1,12 @@
-#include <libc.h> // for weak_reference
+#include <ctype.h> // for isgraph, isgraph_l, locale_t
+#include <sys/cdefs.h> // for __unused, __weak
int isgraph(int c)
{
return (unsigned)c - 0x21 < 0x5e;
}
-weak_reference(isgraph, isgraph_l);
+__weak int isgraph_l(int c, locale_t __unused locale)
+{
+ return isgraph(c);
+}
diff --git a/lib/libc/ctype/islower.c b/lib/libc/ctype/islower.c
index a6108e39..8438c8d1 100644
--- a/lib/libc/ctype/islower.c
+++ b/lib/libc/ctype/islower.c
@@ -1,8 +1,12 @@
-#include <libc.h> // for weak_reference
+#include <ctype.h> // for islower, islower_l, locale_t
+#include <sys/cdefs.h> // for __unused, __weak
int islower(int c)
{
return (unsigned)c - 'a' < 26;
}
-weak_reference(islower, islower_l);
+__weak int islower_l(int c, locale_t __unused locale)
+{
+ return islower(c);
+}
diff --git a/lib/libc/ctype/isprint.c b/lib/libc/ctype/isprint.c
index dbd381e7..b1d75a31 100644
--- a/lib/libc/ctype/isprint.c
+++ b/lib/libc/ctype/isprint.c
@@ -1,8 +1,12 @@
-#include <libc.h> // for weak_reference
+#include <ctype.h> // for isprint, isprint_l, locale_t
+#include <sys/cdefs.h> // for __unused, __weak
int isprint(int c)
{
return (unsigned)c - 0x20 < 0x5f;
}
-weak_reference(isprint, isprint_l);
+__weak int isprint_l(int c, locale_t __unused locale)
+{
+ return isprint(c);
+}
diff --git a/lib/libc/ctype/ispunct.c b/lib/libc/ctype/ispunct.c
index e0029757..fc60287f 100644
--- a/lib/libc/ctype/ispunct.c
+++ b/lib/libc/ctype/ispunct.c
@@ -1,8 +1,6 @@
-#include "features.h" // for __weak
-
-#include <ctype.h> // for isalnum, isgraph, ispunct, ispunct_l
-#include <libc.h> // for __unused
-#include <locale.h> // for locale_t
+#include <ctype.h> // for isalnum, isgraph, ispunct, ispunct_l
+#include <locale.h> // for locale_t
+#include <sys/cdefs.h> // for __unused, __weak
int ispunct(int c)
{
diff --git a/lib/libc/ctype/isspace.c b/lib/libc/ctype/isspace.c
index 468e755b..201daca0 100644
--- a/lib/libc/ctype/isspace.c
+++ b/lib/libc/ctype/isspace.c
@@ -1,8 +1,12 @@
-#include <libc.h> // for weak_reference
+#include <ctype.h> // for isspace, isspace_l, locale_t
+#include <sys/cdefs.h> // for __unused, __weak
int isspace(int c)
{
return c == ' ' || (unsigned)c - '\t' < 5;
}
-weak_reference(isspace, isspace_l);
+__weak int isspace_l(int c, locale_t __unused locale)
+{
+ return isspace(c);
+}
diff --git a/lib/libc/ctype/isupper.c b/lib/libc/ctype/isupper.c
index b46dce41..d831a3fa 100644
--- a/lib/libc/ctype/isupper.c
+++ b/lib/libc/ctype/isupper.c
@@ -1,8 +1,12 @@
-#include <libc.h> // for weak_reference
+#include <ctype.h> // for isupper, isupper_l, locale_t
+#include <sys/cdefs.h> // for __unused, __weak
int isupper(int c)
{
return (unsigned)c - 'A' < 26;
}
-weak_reference(isupper, isupper_l);
+__weak int isupper_l(int c, locale_t __unused locale)
+{
+ return isupper(c);
+}
diff --git a/lib/libc/ctype/tolower.c b/lib/libc/ctype/tolower.c
index af196d05..fcb1de85 100644
--- a/lib/libc/ctype/tolower.c
+++ b/lib/libc/ctype/tolower.c
@@ -1,8 +1,6 @@
-#include "features.h" // for __weak
-
-#include <ctype.h> // for isupper, tolower, tolower_l
-#include <libc.h> // for __unused
-#include <locale.h> // for locale_t
+#include <ctype.h> // for isupper, tolower, tolower_l
+#include <locale.h> // for locale_t
+#include <sys/cdefs.h> // for __unused, __weak
int tolower(int c)
{
diff --git a/lib/libc/ctype/toupper.c b/lib/libc/ctype/toupper.c
index 3f7ebf43..9dd4c8da 100644
--- a/lib/libc/ctype/toupper.c
+++ b/lib/libc/ctype/toupper.c
@@ -1,6 +1,5 @@
-#include <ctype.h> // for islower, toupper, toupper_l
-#include <libc.h> // for __unused
-#include <locale.h> // for locale_t
+#include <ctype.h> // for islower, toupper, locale_t, toupper_l
+#include <sys/cdefs.h> // for __unused
int toupper(int c)
{
diff --git a/lib/libc/devctl/posix_devctl.c b/lib/libc/devctl/posix_devctl.c
index 90eea9f9..1b9db522 100644
--- a/lib/libc/devctl/posix_devctl.c
+++ b/lib/libc/devctl/posix_devctl.c
@@ -1,8 +1,10 @@
-#include "asm/unistd_64.h" // for __NR_ioctl
+
+
#include <devctl.h> // for posix_devctl, size_t
#include <errno.h> // for errno
#include <libc.h> // for __unused
+#include <stddef.h>
#include <syscall.h> // for __syscall_3, syscall
int posix_devctl(int fildes, int dcmd, void *restrict dev_data_ptr,
diff --git a/lib/libc/dirent/readdir_r.c b/lib/libc/dirent/readdir_r.c
index 68f05fa3..d2ca9809 100644
--- a/lib/libc/dirent/readdir_r.c
+++ b/lib/libc/dirent/readdir_r.c
@@ -1,14 +1,12 @@
/* Maintainer: <contact@bellrise.net> */
-#include "asm/unistd_64.h" // for __NR_getdents64
-#include "stdio.h" // for NULL
-#include "sys/types.h" // for off_t
+#include "stdio.h" // for off_t
#include <__dirent.h> // for linux_dirent64
-#include <dirent.h> // for dirent, size_t, ssize_t, DIR, readdir_r
+#include <dirent.h> // for dirent, ssize_t, DIR, readdir_r
#include <errno.h> // for EINVAL, errno
-#include <stddef.h> // for offsetof
-#include <string.h> // for memcpy, memset
+#include <stddef.h> // for NULL, offsetof
+#include <string.h> // for memcpy, size_t, memset
#include <syscall.h> // for __syscall_3, syscall
int readdir_r(DIR *restrict dirp, struct dirent *restrict entry,
diff --git a/lib/libc/endian/be16toh.c b/lib/libc/endian/be16toh.c
index 9a5e8ff3..c5efa9a1 100644
--- a/lib/libc/endian/be16toh.c
+++ b/lib/libc/endian/be16toh.c
@@ -1,5 +1,5 @@
-#include <endian.h> // for be16toh
-#include <stdint.h> // for uint16_t
+#include <endian.h> // for uint16_t, be16toh
+#include <stdint.h>
uint16_t be16toh(uint16_t big_endian_16bits)
{
diff --git a/lib/libc/endian/be32toh.c b/lib/libc/endian/be32toh.c
index d87c9f58..18440dd5 100644
--- a/lib/libc/endian/be32toh.c
+++ b/lib/libc/endian/be32toh.c
@@ -1,5 +1,5 @@
-#include <endian.h> // for be32toh
-#include <stdint.h> // for uint32_t
+#include <endian.h> // for uint32_t, be32toh
+#include <stdint.h>
uint32_t be32toh(uint32_t big_endian_32bits)
{
diff --git a/lib/libc/endian/be64toh.c b/lib/libc/endian/be64toh.c
index 6ccdb175..6402fa07 100644
--- a/lib/libc/endian/be64toh.c
+++ b/lib/libc/endian/be64toh.c
@@ -1,5 +1,5 @@
-#include <endian.h> // for be64toh
-#include <stdint.h> // for uint64_t
+#include <endian.h> // for uint64_t, be64toh
+#include <stdint.h>
uint64_t be64toh(uint64_t big_endian_64bits)
{
diff --git a/lib/libc/endian/htobe16.c b/lib/libc/endian/htobe16.c
index 915296f3..2b5eff4d 100644
--- a/lib/libc/endian/htobe16.c
+++ b/lib/libc/endian/htobe16.c
@@ -1,5 +1,5 @@
-#include <endian.h> // for htobe16
-#include <stdint.h> // for uint16_t
+#include <endian.h> // for uint16_t, htobe16
+#include <stdint.h>
uint16_t htobe16(uint16_t host_16bits)
{
diff --git a/lib/libc/endian/htobe32.c b/lib/libc/endian/htobe32.c
index 378c6c20..cbc5037f 100644
--- a/lib/libc/endian/htobe32.c
+++ b/lib/libc/endian/htobe32.c
@@ -1,5 +1,5 @@
-#include <endian.h> // for htobe32
-#include <stdint.h> // for uint32_t
+#include <endian.h> // for uint32_t, htobe32
+#include <stdint.h>
uint32_t htobe32(uint32_t host_32bits)
{
diff --git a/lib/libc/endian/htobe64.c b/lib/libc/endian/htobe64.c
index 54a363c8..3d322096 100644
--- a/lib/libc/endian/htobe64.c
+++ b/lib/libc/endian/htobe64.c
@@ -1,5 +1,5 @@
-#include <endian.h> // for htobe64
-#include <stdint.h> // for uint64_t
+#include <endian.h> // for uint64_t, htobe64
+#include <stdint.h>
uint64_t htobe64(uint64_t host_64bits)
{
diff --git a/lib/libc/endian/htole16.c b/lib/libc/endian/htole16.c
index 9bdd1675..6689664f 100644
--- a/lib/libc/endian/htole16.c
+++ b/lib/libc/endian/htole16.c
@@ -1,5 +1,5 @@
-#include <endian.h> // for htole16
-#include <stdint.h> // for uint16_t
+#include <endian.h> // for uint16_t, htole16
+#include <stdint.h>
uint16_t htole16(uint16_t host_16bits)
{
diff --git a/lib/libc/endian/htole32.c b/lib/libc/endian/htole32.c
index bf4771bd..e5b0ae42 100644
--- a/lib/libc/endian/htole32.c
+++ b/lib/libc/endian/htole32.c
@@ -1,5 +1,5 @@
-#include <endian.h> // for htole32
-#include <stdint.h> // for uint32_t
+#include <endian.h> // for uint32_t, htole32
+#include <stdint.h>
uint32_t htole32(uint32_t host_32bits)
{
diff --git a/lib/libc/endian/htole64.c b/lib/libc/endian/htole64.c
index acd2fb14..848d61eb 100644
--- a/lib/libc/endian/htole64.c
+++ b/lib/libc/endian/htole64.c
@@ -1,5 +1,5 @@
-#include <endian.h> // for htole64
-#include <stdint.h> // for uint64_t
+#include <endian.h> // for uint64_t, htole64
+#include <stdint.h>
uint64_t htole64(uint64_t host_64bits)
{
diff --git a/lib/libc/endian/le16toh.c b/lib/libc/endian/le16toh.c
index 620be0c1..75b80fd1 100644
--- a/lib/libc/endian/le16toh.c
+++ b/lib/libc/endian/le16toh.c
@@ -1,5 +1,5 @@
-#include <endian.h> // for le16toh
-#include <stdint.h> // for uint16_t
+#include <endian.h> // for uint16_t, le16toh
+#include <stdint.h>
uint16_t le16toh(uint16_t little_endian_16bits)
{
diff --git a/lib/libc/endian/le32toh.c b/lib/libc/endian/le32toh.c
index c053c1b2..2316d559 100644
--- a/lib/libc/endian/le32toh.c
+++ b/lib/libc/endian/le32toh.c
@@ -1,5 +1,5 @@
-#include <endian.h> // for le32toh
-#include <stdint.h> // for uint32_t
+#include <endian.h> // for uint32_t, le32toh
+#include <stdint.h>
uint32_t le32toh(uint32_t little_endian_32bits)
{
diff --git a/lib/libc/endian/le64toh.c b/lib/libc/endian/le64toh.c
index 409863f2..445da0e3 100644
--- a/lib/libc/endian/le64toh.c
+++ b/lib/libc/endian/le64toh.c
@@ -1,5 +1,5 @@
-#include <endian.h> // for le64toh
-#include <stdint.h> // for uint64_t
+#include <endian.h> // for uint64_t, le64toh
+#include <stdint.h>
uint64_t le64toh(uint64_t little_endian_64bits)
{
diff --git a/lib/libc/fcntl/creat.c b/lib/libc/fcntl/creat.c
index 43110794..4b84ecae 100644
--- a/lib/libc/fcntl/creat.c
+++ b/lib/libc/fcntl/creat.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_creat
+
+
#include <fcntl.h> // for creat
#include <sys/types.h> // for mode_t
diff --git a/lib/libc/fcntl/fcntl.c b/lib/libc/fcntl/fcntl.c
index 6112567d..b3ca012f 100644
--- a/lib/libc/fcntl/fcntl.c
+++ b/lib/libc/fcntl/fcntl.c
@@ -1,4 +1,3 @@
-#include "asm/unistd_64.h" // for __NR_fcntl, __NR_close
#include "errno.h" // for EINVAL
#include <fcntl.h> // for F_DUPFD_CLOEXEC, FD_CLOEXEC, F_SETFD, F_D...
diff --git a/lib/libc/fcntl/open.c b/lib/libc/fcntl/open.c
index c00820c1..ab59e3c7 100644
--- a/lib/libc/fcntl/open.c
+++ b/lib/libc/fcntl/open.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_fcntl, __NR_open
+
+
#include <fcntl.h> // for FD_CLOEXEC, F_SETFD, O_CLOEXEC, O_CREAT
#include <stdarg.h> // for va_arg, va_end, va_list, va_start
diff --git a/lib/libc/fcntl/openat.c b/lib/libc/fcntl/openat.c
index d3475f6b..d99693dc 100644
--- a/lib/libc/fcntl/openat.c
+++ b/lib/libc/fcntl/openat.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_openat
+
+
#include <fcntl.h> // for O_CREAT, openat
#include <stdarg.h> // for va_arg, va_end, va_list, va_start
diff --git a/lib/libc/fcntl/posix_fadvise.c b/lib/libc/fcntl/posix_fadvise.c
index 08718294..51018a27 100644
--- a/lib/libc/fcntl/posix_fadvise.c
+++ b/lib/libc/fcntl/posix_fadvise.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_fadvise64
+
+
#include <fcntl.h> // for posix_fadvise
#include <sys/types.h> // for off_t
diff --git a/lib/libc/fcntl/posix_fallocate.c b/lib/libc/fcntl/posix_fallocate.c
index 61129c4a..c4a05fcc 100644
--- a/lib/libc/fcntl/posix_fallocate.c
+++ b/lib/libc/fcntl/posix_fallocate.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_fallocate
+
+
#include <fcntl.h> // for posix_fallocate
#include <sys/types.h> // for off_t
diff --git a/lib/libc/grp/getgrgid_r.c b/lib/libc/grp/getgrgid_r.c
index 2fa4bccd..13884fd5 100644
--- a/lib/libc/grp/getgrgid_r.c
+++ b/lib/libc/grp/getgrgid_r.c
@@ -1,7 +1,9 @@
+#include "stddef.h" // for NULL
+
#include <errno.h> // for ERANGE, errno
#include <grp.h> // for group, getgrgid_r
#include <limits.h> // for LINE_MAX
-#include <stdio.h> // for NULL, fclose, fgets, fopen, FILE
+#include <stdio.h> // for fclose, fgets, fopen, FILE
#include <stdlib.h> // for strtoul
#include <string.h> // for strtok, memcpy, strlen
#include <sys/types.h> // for gid_t, size_t
diff --git a/lib/libc/include/__dirent.h b/lib/libc/include/__dirent.h
index 9b23c9d2..4f9ead80 100644
--- a/lib/libc/include/__dirent.h
+++ b/lib/libc/include/__dirent.h
@@ -1,10 +1,9 @@
#ifndef __LIBC_DIRENT_H
#define __LIBC_DIRENT_H
-#include <libc.h>
+#include <stdint.h>
#include <stdio.h>
#include <sys/types.h>
-#include <stdint.h>
struct linux_dirent64 {
uint64_t d_ino;
diff --git a/lib/libc/include/__stdio.h b/lib/libc/include/__stdio.h
index ebda4b22..487a0382 100644
--- a/lib/libc/include/__stdio.h
+++ b/lib/libc/include/__stdio.h
@@ -1,12 +1,12 @@
-#ifndef __LIBC_IO
-#define __LIBC_IO
+#ifndef __LIBC_STDIO_H__
+#define __LIBC_STDIO_H__
+#include <stdatomic.h>
#include <stddef.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
-#include <stdint.h>
#include <sys/types.h>
-#include <stdatomic.h>
typedef __SIZE_TYPE__ size_t;
@@ -31,6 +31,8 @@ struct __FILE {
struct __FILE *next;
};
+#define __FILE(__stream) ((struct __FILE *)(__stream))
+
void __libc_fadd(struct __FILE *f);
#endif
diff --git a/lib/libc/include/thread.h b/lib/libc/include/__thread.h
index 662f1dc1..662f1dc1 100644
--- a/lib/libc/include/thread.h
+++ b/lib/libc/include/__thread.h
diff --git a/lib/libc/include/atomic.h b/lib/libc/include/atomic.h
index 94cd34db..e0593021 100644
--- a/lib/libc/include/atomic.h
+++ b/lib/libc/include/atomic.h
@@ -3,8 +3,8 @@
#include <stdatomic.h>
-#define LIBC_LOCK(__lock) __libc_lock(&__lock)
-#define LIBC_UNLOCK(__lock) atomic_flag_clear(&__lock)
+#define LIBC_LOCK(__lock) __libc_lock(&((__lock)))
+#define LIBC_UNLOCK(__lock) atomic_flag_clear(&((__lock)))
static __inline void __libc_lock(volatile atomic_flag *lock)
{
diff --git a/lib/libc/include/libc.h b/lib/libc/include/libc.h
index 6651feaa..6f233d35 100644
--- a/lib/libc/include/libc.h
+++ b/lib/libc/include/libc.h
@@ -2,21 +2,15 @@
#define __LIBC_LIBC_H
#include <stdatomic.h>
-#include <features.h>
-
-#include <__stdio.h>
-#include <thread.h>
-
-#define __IMPL(_v) ((__##typeof(_v))_v)
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#define __unused __attribute__((unused))
#define aligned(type) __attribute__((aligned(__alignof__(type))))
#define weak_reference(old, new) \
- extern __typeof(old) new __attribute__((__weak__, __alias__(#old)))
+ extern __typeof(old)((new)) __attribute__((__weak__, __alias__(#old)))
-static struct {
+static struct libc {
enum {
LIBC_ENVP_TOUCHED = 1 << 0,
} flags;
diff --git a/lib/libc/include/malloc.h b/lib/libc/include/malloc.h
index ba2755b0..b7cb0093 100644
--- a/lib/libc/include/malloc.h
+++ b/lib/libc/include/malloc.h
@@ -1,9 +1,8 @@
#ifndef __LIBC_MALLOC_H
#define __LIBC_MALLOC_H
-#include <stddef.h>
-#include <stdint.h>
#include <stdatomic.h>
+#include <stdint.h>
struct class {
uint32_t size;
@@ -47,11 +46,12 @@ extern struct page *__malloc_pvec;
#define LARGE_PAGE_MASK (~((uintptr_t)LARGE_PAGE_SIZE - 1))
#define SMALL_CLASS(n) \
- { (n * 16), (SMALL_PAGE_SIZE - sizeof(struct page)) / (n * 16) }
+ { (((n)) * 16), (SMALL_PAGE_SIZE - sizeof(struct page)) / (((n)) * 16) }
#define MEDIUM_CLASS(n) \
- { (n * 16), (MEDIUM_PAGE_SIZE - sizeof(struct page)) / (n * 16) }
+ { (((n)) * 16), \
+ (MEDIUM_PAGE_SIZE - sizeof(struct page)) / (((n)) * 16) }
#define LARGE_CLASS(n) \
- { (n * 16), (LARGE_PAGE_SIZE - sizeof(struct page)) / (n * 16) }
+ { (((n)) * 16), (LARGE_PAGE_SIZE - sizeof(struct page)) / (((n)) * 16) }
static const struct class global_size_class[] = {
SMALL_CLASS(1), SMALL_CLASS(1), SMALL_CLASS(2),
diff --git a/lib/libc/inttypes/imaxabs.c b/lib/libc/inttypes/imaxabs.c
index c5137ecc..cbf46d14 100644
--- a/lib/libc/inttypes/imaxabs.c
+++ b/lib/libc/inttypes/imaxabs.c
@@ -1,4 +1,5 @@
-#include <stdint.h> // for intmax_t
+#include <inttypes.h> // for imaxabs
+#include <stdint.h> // for intmax_t
intmax_t imaxabs(intmax_t j)
{
diff --git a/lib/libc/inttypes/strtoumax.c b/lib/libc/inttypes/strtoumax.c
index 46eecf06..73d2c77c 100644
--- a/lib/libc/inttypes/strtoumax.c
+++ b/lib/libc/inttypes/strtoumax.c
@@ -1,5 +1,6 @@
-#include <stdint.h> // for uintmax_t
-#include <stdlib.h> // for strtoull
+#include <inttypes.h> // for strtoumax
+#include <stdint.h> // for uintmax_t
+#include <stdlib.h> // for strtoull
uintmax_t strtoumax(const char *restrict s, char **restrict p, int base)
{
diff --git a/lib/libc/libc.a b/lib/libc/libc.a
index 55b3b5a6..7a52d590 100644
--- a/lib/libc/libc.a
+++ b/lib/libc/libc.a
Binary files differ
diff --git a/lib/libc/libgen/basename.c b/lib/libc/libgen/basename.c
index 3f2cc02b..17244dc8 100644
--- a/lib/libc/libgen/basename.c
+++ b/lib/libc/libgen/basename.c
@@ -16,10 +16,12 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#include "stddef.h" // for NULL
+
#include <errno.h> // for ENAMETOOLONG, errno
#include <libgen.h> // for basename
#include <limits.h> // for PATH_MAX
-#include <string.h> // for NULL, memcpy, strlen, size_t
+#include <string.h> // for memcpy, strlen, size_t
char *basename(char *path)
{
diff --git a/lib/libc/libgen/dirname.c b/lib/libc/libgen/dirname.c
index 0c6e1ac2..8baac85d 100644
--- a/lib/libc/libgen/dirname.c
+++ b/lib/libc/libgen/dirname.c
@@ -16,10 +16,12 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#include "stddef.h" // for NULL
+
#include <errno.h> // for ENAMETOOLONG, errno
#include <libgen.h> // for dirname
#include <limits.h> // for PATH_MAX
-#include <string.h> // for NULL, memcpy, strlen, size_t
+#include <string.h> // for memcpy, strlen, size_t
char *dirname(char *path)
{
@@ -48,12 +50,10 @@ char *dirname(char *path)
dname[0] = *endp == '/' ? '/' : '.';
dname[1] = '\0';
return (dname);
- } else {
- /* Move forward past the separating slashes */
- do {
- endp--;
- } while (endp > path && *endp == '/');
- }
+ } /* Move forward past the separating slashes */
+ do {
+ endp--;
+ } while (endp > path && *endp == '/');
len = endp - path + 1;
if (len >= sizeof(dname)) {
diff --git a/lib/libc/mman/mlock.c b/lib/libc/mman/mlock.c
index c46b9435..a8b029c6 100644
--- a/lib/libc/mman/mlock.c
+++ b/lib/libc/mman/mlock.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_mlock
+
+
#include <stddef.h> // for size_t
#include <syscall.h> // for __syscall_2, syscall
diff --git a/lib/libc/mman/mlockall.c b/lib/libc/mman/mlockall.c
index ef12edd3..9adb6b9e 100644
--- a/lib/libc/mman/mlockall.c
+++ b/lib/libc/mman/mlockall.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_mlockall
+
+
#include <syscall.h> // for __syscall_1, syscall
diff --git a/lib/libc/mman/mmap.c b/lib/libc/mman/mmap.c
index c2a3fa72..f5e09265 100644
--- a/lib/libc/mman/mmap.c
+++ b/lib/libc/mman/mmap.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_mmap
+
+
#include <stddef.h> // for size_t
#include <syscall.h> // for __syscall_6, syscall
diff --git a/lib/libc/mman/mprotect.c b/lib/libc/mman/mprotect.c
index 5c96f9b8..068d7e68 100644
--- a/lib/libc/mman/mprotect.c
+++ b/lib/libc/mman/mprotect.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_mprotect
+
+
#include <stddef.h> // for size_t
#include <syscall.h> // for __syscall_3, syscall
diff --git a/lib/libc/mman/msync.c b/lib/libc/mman/msync.c
index c25a18e7..6cf3688b 100644
--- a/lib/libc/mman/msync.c
+++ b/lib/libc/mman/msync.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_msync
+
+
#include <stddef.h> // for size_t
#include <syscall.h> // for __syscall_3, syscall
diff --git a/lib/libc/mman/munlock.c b/lib/libc/mman/munlock.c
index 2d62c032..4e1901ef 100644
--- a/lib/libc/mman/munlock.c
+++ b/lib/libc/mman/munlock.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_munlock
+
+
#include <stddef.h> // for size_t
#include <syscall.h> // for __syscall_2, syscall
diff --git a/lib/libc/mman/munlockall.c b/lib/libc/mman/munlockall.c
index ecf9ddbc..cdeb5253 100644
--- a/lib/libc/mman/munlockall.c
+++ b/lib/libc/mman/munlockall.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_munlockall
+
+
#include <syscall.h> // for __syscall_0, syscall
diff --git a/lib/libc/mman/munmap.c b/lib/libc/mman/munmap.c
index 04ad9800..7a4fe5fc 100644
--- a/lib/libc/mman/munmap.c
+++ b/lib/libc/mman/munmap.c
@@ -1,5 +1,7 @@
-#include "asm/unistd_64.h" // for __NR_munmap
+
+
+#include <stddef.h>
#include <sys/mman.h> // for munmap, size_t
#include <syscall.h> // for __syscall_2, syscall
diff --git a/lib/libc/mman/posix_madvise.c b/lib/libc/mman/posix_madvise.c
index e81c6712..6e9243ca 100644
--- a/lib/libc/mman/posix_madvise.c
+++ b/lib/libc/mman/posix_madvise.c
@@ -1,5 +1,7 @@
-#include "asm/unistd_64.h" // for __NR_madvise
+
+
+#include <stddef.h>
#include <sys/mman.h> // for posix_madvise, size_t
#include <syscall.h> // for __syscall_3, syscall
diff --git a/lib/libc/msg/msgctl.c b/lib/libc/msg/msgctl.c
index 0df2e3cf..a71bb9d9 100644
--- a/lib/libc/msg/msgctl.c
+++ b/lib/libc/msg/msgctl.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_msgctl
+
+
#include <sys/msg.h> // for msgctl
#include <syscall.h> // for __syscall_3, syscall
diff --git a/lib/libc/poll/poll.c b/lib/libc/poll/poll.c
index 24d91db6..4601b9b3 100644
--- a/lib/libc/poll/poll.c
+++ b/lib/libc/poll/poll.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_poll
+
+
#include <poll.h> // for nfds_t, poll, pollfd
#include <syscall.h> // for __syscall_3, syscall
diff --git a/lib/libc/poll/ppoll.c b/lib/libc/poll/ppoll.c
index 923784da..da23d412 100644
--- a/lib/libc/poll/ppoll.c
+++ b/lib/libc/poll/ppoll.c
@@ -1,8 +1,10 @@
-#include "asm/unistd_64.h" // for __NR_ppoll
+
+
#include <poll.h> // for nfds_t, pollfd, ppoll
#include <signal.h> // for sigset_t
#include <syscall.h> // for __syscall_5, syscall
+#include <time.h>
struct timespec;
diff --git a/lib/libc/pwd/getgrgid_r.c b/lib/libc/pwd/getgrgid_r.c
index a0d15c74..2f9c1952 100644
--- a/lib/libc/pwd/getgrgid_r.c
+++ b/lib/libc/pwd/getgrgid_r.c
@@ -1,7 +1,9 @@
+#include "stddef.h" // for NULL
+
#include <errno.h> // for ERANGE, errno
#include <limits.h> // for LINE_MAX
#include <pwd.h> // for passwd, getpwuid_r
-#include <stdio.h> // for NULL, fclose, fgets, fopen, FILE
+#include <stdio.h> // for fclose, fgets, fopen, FILE
#include <stdlib.h> // for strtoul
#include <string.h> // for strtok, memcpy, strlen
#include <sys/types.h> // for size_t, uid_t, gid_t
diff --git a/lib/libc/select/pselect.c b/lib/libc/select/pselect.c
index 70f63f2d..0f434533 100644
--- a/lib/libc/select/pselect.c
+++ b/lib/libc/select/pselect.c
@@ -1,8 +1,12 @@
-#include "asm/unistd_64.h" // for __NR_pselect6
+
+
#include <stdint.h> // for uintptr_t
#include <sys/select.h> // for fd_set, pselect, sigset_t
#include <syscall.h> // for __syscall_6, syscall, syscall_arg_t
+#include <time.h>
+
+struct timespec;
int pselect(int nfds, fd_set *restrict readfds, fd_set *restrict writefds,
fd_set *restrict errorfds, const struct timespec *restrict timeout,
diff --git a/lib/libc/select/select.c b/lib/libc/select/select.c
index 58c96348..786724a8 100644
--- a/lib/libc/select/select.c
+++ b/lib/libc/select/select.c
@@ -1,6 +1,8 @@
-#include "asm/unistd_64.h" // for __NR_pselect6
+#define __BITS_SELECT_H_
+#include "bits/select.h" // for fd_set, timeval (ptr only)
-#include <sys/select.h> // for fd_set, select
+
+#include <sys/select.h> // for select
#include <syscall.h> // for __syscall_6, syscall, syscall_arg_t
int select(int nfds, fd_set *restrict readfds, fd_set *restrict writefds,
diff --git a/lib/libc/sem/semctl.c b/lib/libc/sem/semctl.c
index 45b6d0e5..14f6698d 100644
--- a/lib/libc/sem/semctl.c
+++ b/lib/libc/sem/semctl.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_semctl
+
+
#include <stdarg.h> // for va_arg, va_end, va_list, va_start
#include <stddef.h> // for NULL
diff --git a/lib/libc/sem/semget.c b/lib/libc/sem/semget.c
index d3c0b41f..d9652179 100644
--- a/lib/libc/sem/semget.c
+++ b/lib/libc/sem/semget.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_semget
+
+
#include <sys/sem.h> // for semget
#include <sys/types.h> // for key_t
diff --git a/lib/libc/sem/semop.c b/lib/libc/sem/semop.c
index 6095d445..054c6a86 100644
--- a/lib/libc/sem/semop.c
+++ b/lib/libc/sem/semop.c
@@ -1,5 +1,7 @@
-#include "asm/unistd_64.h" // for __NR_semop
+
+
+#include <stddef.h>
#include <sys/sem.h> // for semop, size_t
#include <syscall.h> // for __syscall_3, syscall
diff --git a/lib/libc/signal/kill.c b/lib/libc/signal/kill.c
index 65676ed4..84d729f3 100644
--- a/lib/libc/signal/kill.c
+++ b/lib/libc/signal/kill.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_kill
+
+
#include <signal.h> // for kill
#include <sys/types.h> // for pid_t
diff --git a/lib/libc/signal/pthread_kill.c b/lib/libc/signal/pthread_kill.c
index d6855c0c..2c0bb40b 100644
--- a/lib/libc/signal/pthread_kill.c
+++ b/lib/libc/signal/pthread_kill.c
@@ -1,9 +1,8 @@
-#include "asm/unistd_64.h" // for __NR_tkill
#include "errno.h" // for EINVAL
+#include <__thread.h> // for __thread_self
#include <asm-generic/signal.h> // for _NSIG
#include <syscall.h> // for __syscall_2, syscall
-#include <thread.h> // for __thread_self
typedef struct __thread_self *pthread_t;
diff --git a/lib/libc/signal/sigabbrev.h b/lib/libc/signal/sigabbrev.h
index fa0ef1ce..4ed6d7d3 100644
--- a/lib/libc/signal/sigabbrev.h
+++ b/lib/libc/signal/sigabbrev.h
@@ -1,5 +1,4 @@
#include <signal.h>
-#include <unistd.h>
const char *const sys_sigabbrev[64] = {
[SIGABRT] = "ABRT", [SIGALRM] = "ALRM", [SIGBUS] = "BUS",
diff --git a/lib/libc/signal/sigaction.c b/lib/libc/signal/sigaction.c
index 6039574a..93e8aab2 100644
--- a/lib/libc/signal/sigaction.c
+++ b/lib/libc/signal/sigaction.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_rt_sigaction
+
+
#include <signal.h> // for sigaction, sigset_t
#include <syscall.h> // for __syscall_4, syscall
diff --git a/lib/libc/signal/siglist.c b/lib/libc/signal/siglist.c
index ba9ec746..ccecf05d 100644
--- a/lib/libc/signal/siglist.c
+++ b/lib/libc/signal/siglist.c
@@ -1,5 +1,4 @@
#include <signal.h>
-#include <unistd.h>
const char *const sys_siglist[64] = {
[SIGABRT] = "Aborted",
diff --git a/lib/libc/signal/sigpending.c b/lib/libc/signal/sigpending.c
index b0b4e92c..90414b1e 100644
--- a/lib/libc/signal/sigpending.c
+++ b/lib/libc/signal/sigpending.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_rt_sigpending
+
+
#include <signal.h> // for sigpending, sigset_t
#include <syscall.h> // for __syscall_1, syscall
diff --git a/lib/libc/signal/sigprocmask.c b/lib/libc/signal/sigprocmask.c
index f74d5774..4f766ec3 100644
--- a/lib/libc/signal/sigprocmask.c
+++ b/lib/libc/signal/sigprocmask.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_rt_sigprocmask
+
+
#include <signal.h> // for sigset_t, sigprocmask
#include <syscall.h> // for __syscall_4, syscall
diff --git a/lib/libc/signal/sigsuspend.c b/lib/libc/signal/sigsuspend.c
index 93701d55..214d7c39 100644
--- a/lib/libc/signal/sigsuspend.c
+++ b/lib/libc/signal/sigsuspend.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_rt_sigsuspend
+
+
#include <signal.h> // for sigset_t, sigsuspend
#include <syscall.h> // for __syscall_2, syscall
diff --git a/lib/libc/signal/sigtimedwait.c b/lib/libc/signal/sigtimedwait.c
index dc85e5d1..5445d1d7 100644
--- a/lib/libc/signal/sigtimedwait.c
+++ b/lib/libc/signal/sigtimedwait.c
@@ -1,7 +1,9 @@
-#include "asm/unistd_64.h" // for __NR_rt_sigtimedwait
+
+
#include <signal.h> // for siginfo_t, sigset_t, sigtimedwait
#include <syscall.h> // for __syscall_4, syscall
+#include <time.h>
struct timespec;
diff --git a/lib/libc/signal/str2sig.c b/lib/libc/signal/str2sig.c
index 77796c4d..59bcf1c0 100644
--- a/lib/libc/signal/str2sig.c
+++ b/lib/libc/signal/str2sig.c
@@ -1,8 +1,10 @@
+#include "stddef.h" // for NULL
+
#include <__signal.h> // for __sys_signame
#include <asm-generic/signal.h> // for SIGRTMAX, SIGRTMIN, SIGHUP, SIGSYS
#include <errno.h> // for errno
#include <stdbool.h> // for bool
-#include <stdlib.h> // for strtol, NULL
+#include <stdlib.h> // for strtol
#include <string.h> // for strcmp, strncmp, size_t
int str2sig(const char *restrict str, int *restrict pnum)
diff --git a/lib/libc/signal/sysv_signal.c b/lib/libc/signal/sysv_signal.c
index 2aa0221a..e466d1dd 100644
--- a/lib/libc/signal/sysv_signal.c
+++ b/lib/libc/signal/sysv_signal.c
@@ -1,4 +1,4 @@
-#include <signal.h>
+#include <signal.h> // for sigaction, sigemptyset, sighandler_t, SIG_ERR
sighandler_t sysv_signal(int signum, sighandler_t handler)
{
diff --git a/lib/libc/socket/accept.c b/lib/libc/socket/accept.c
index f3ec738d..d720b2e9 100644
--- a/lib/libc/socket/accept.c
+++ b/lib/libc/socket/accept.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_accept
+
+
#include <sys/socket.h> // for accept, socklen_t
#include <syscall.h> // for __syscall_3, syscall
diff --git a/lib/libc/socket/accept4.c b/lib/libc/socket/accept4.c
index 88c761f5..ff5cbc06 100644
--- a/lib/libc/socket/accept4.c
+++ b/lib/libc/socket/accept4.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_accept4
+
+
#include <sys/socket.h> // for accept4, socklen_t
#include <syscall.h> // for __syscall_4, syscall
diff --git a/lib/libc/socket/bind.c b/lib/libc/socket/bind.c
index ef39d03b..e605cfda 100644
--- a/lib/libc/socket/bind.c
+++ b/lib/libc/socket/bind.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_bind
+
+
#include <sys/socket.h> // for bind, socklen_t
#include <syscall.h> // for __syscall_3, syscall
diff --git a/lib/libc/socket/connect.c b/lib/libc/socket/connect.c
index 19c9ef95..e9f0795a 100644
--- a/lib/libc/socket/connect.c
+++ b/lib/libc/socket/connect.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_connect
+
+
#include <sys/socket.h> // for connect, socklen_t
#include <syscall.h> // for __syscall_3, syscall
diff --git a/lib/libc/socket/getpeername.c b/lib/libc/socket/getpeername.c
index f1bc35e8..d8edb334 100644
--- a/lib/libc/socket/getpeername.c
+++ b/lib/libc/socket/getpeername.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_getpeername
+
+
#include <sys/socket.h> // for getpeername, socklen_t
#include <syscall.h> // for __syscall_3, syscall
diff --git a/lib/libc/socket/getsockname.c b/lib/libc/socket/getsockname.c
index b8422261..3cb898fa 100644
--- a/lib/libc/socket/getsockname.c
+++ b/lib/libc/socket/getsockname.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_getsockname
+
+
#include <sys/socket.h> // for getsockname, socklen_t
#include <syscall.h> // for __syscall_3, syscall
diff --git a/lib/libc/socket/getsockopt.c b/lib/libc/socket/getsockopt.c
index 0c9db0ad..6c5694e8 100644
--- a/lib/libc/socket/getsockopt.c
+++ b/lib/libc/socket/getsockopt.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_getsockopt
+
+
#include <sys/socket.h> // for getsockopt, socklen_t
#include <syscall.h> // for __syscall_5, syscall
diff --git a/lib/libc/socket/listen.c b/lib/libc/socket/listen.c
index a204ba28..62fdb9b4 100644
--- a/lib/libc/socket/listen.c
+++ b/lib/libc/socket/listen.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_listen
+
+
#include <sys/socket.h> // for listen
#include <syscall.h> // for __syscall_2, syscall
diff --git a/lib/libc/socket/recv.c b/lib/libc/socket/recv.c
index 884b753f..a7ed4998 100644
--- a/lib/libc/socket/recv.c
+++ b/lib/libc/socket/recv.c
@@ -1,5 +1,7 @@
-#include "asm/unistd_64.h" // for __NR_recvfrom
+
+
+#include <stddef.h>
#include <sys/socket.h> // for recv
#include <sys/types.h> // for size_t, ssize_t
#include <syscall.h> // for __syscall_6, syscall
diff --git a/lib/libc/socket/recvfrom.c b/lib/libc/socket/recvfrom.c
index d37089d9..1afb088d 100644
--- a/lib/libc/socket/recvfrom.c
+++ b/lib/libc/socket/recvfrom.c
@@ -1,5 +1,7 @@
-#include "asm/unistd_64.h" // for __NR_recvfrom
+
+
+#include <stddef.h>
#include <sys/socket.h> // for recvfrom, socklen_t
#include <sys/types.h> // for size_t, ssize_t
#include <syscall.h> // for __syscall_6, syscall
diff --git a/lib/libc/socket/recvmsg.c b/lib/libc/socket/recvmsg.c
index 1b2cfdf1..a4b2cc13 100644
--- a/lib/libc/socket/recvmsg.c
+++ b/lib/libc/socket/recvmsg.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_recvmsg
+
+
#include <sys/socket.h> // for recvmsg
#include <sys/types.h> // for ssize_t
diff --git a/lib/libc/socket/send.c b/lib/libc/socket/send.c
index 7ba42525..45de1514 100644
--- a/lib/libc/socket/send.c
+++ b/lib/libc/socket/send.c
@@ -1,5 +1,7 @@
-#include "asm/unistd_64.h" // for __NR_sendto
+
+
+#include <stddef.h>
#include <sys/socket.h> // for send
#include <sys/types.h> // for size_t, ssize_t
#include <syscall.h> // for __syscall_6, syscall
diff --git a/lib/libc/socket/sendmsg.c b/lib/libc/socket/sendmsg.c
index b977f7da..11814d19 100644
--- a/lib/libc/socket/sendmsg.c
+++ b/lib/libc/socket/sendmsg.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_sendmsg
+
+
#include <sys/socket.h> // for sendmsg
#include <sys/types.h> // for ssize_t
diff --git a/lib/libc/socket/sendto.c b/lib/libc/socket/sendto.c
index 97376037..a9403917 100644
--- a/lib/libc/socket/sendto.c
+++ b/lib/libc/socket/sendto.c
@@ -1,5 +1,7 @@
-#include "asm/unistd_64.h" // for __NR_sendto
+
+
+#include <stddef.h>
#include <sys/socket.h> // for sendto, socklen_t
#include <sys/types.h> // for size_t, ssize_t
#include <syscall.h> // for __syscall_6, syscall
diff --git a/lib/libc/socket/setsockopt.c b/lib/libc/socket/setsockopt.c
index 740b2d08..c9ae6f88 100644
--- a/lib/libc/socket/setsockopt.c
+++ b/lib/libc/socket/setsockopt.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_setsockopt
+
+
#include <sys/socket.h> // for setsockopt, socklen_t
#include <syscall.h> // for __syscall_5, syscall
diff --git a/lib/libc/socket/shutdown.c b/lib/libc/socket/shutdown.c
index 7fcae79b..b667204e 100644
--- a/lib/libc/socket/shutdown.c
+++ b/lib/libc/socket/shutdown.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_shutdown
+
+
#include <syscall.h> // for __syscall_2, syscall
diff --git a/lib/libc/socket/sockatmark.c b/lib/libc/socket/sockatmark.c
index 4ae64d95..92045454 100644
--- a/lib/libc/socket/sockatmark.c
+++ b/lib/libc/socket/sockatmark.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_ioctl
+
+
#include <asm-generic/sockios.h> // for SIOCATMARK
#include <syscall.h> // for __syscall_3, syscall
diff --git a/lib/libc/socket/socket.c b/lib/libc/socket/socket.c
index 09847ff9..2c300be6 100644
--- a/lib/libc/socket/socket.c
+++ b/lib/libc/socket/socket.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_socket
+
+
#include <syscall.h> // for __syscall_3, syscall
diff --git a/lib/libc/socket/socketpair.c b/lib/libc/socket/socketpair.c
index e116c645..30749d3a 100644
--- a/lib/libc/socket/socketpair.c
+++ b/lib/libc/socket/socketpair.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_socketpair
+
+
#include <syscall.h> // for __syscall_4, syscall
diff --git a/lib/libc/stat/chmod.c b/lib/libc/stat/chmod.c
index f204df83..005869ba 100644
--- a/lib/libc/stat/chmod.c
+++ b/lib/libc/stat/chmod.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_chmod
+
+
#include <sys/stat.h> // for chmod
#include <sys/types.h> // for mode_t
diff --git a/lib/libc/stat/fchmod.c b/lib/libc/stat/fchmod.c
index c7b0b0f3..89ad637a 100644
--- a/lib/libc/stat/fchmod.c
+++ b/lib/libc/stat/fchmod.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_fchmod
+
+
#include <sys/stat.h> // for fchmod
#include <sys/types.h> // for mode_t
diff --git a/lib/libc/stat/fchmodat.c b/lib/libc/stat/fchmodat.c
index 30c8230c..7bf834b1 100644
--- a/lib/libc/stat/fchmodat.c
+++ b/lib/libc/stat/fchmodat.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_fchmodat2
+
+
#include <sys/stat.h> // for fchmodat
#include <sys/types.h> // for mode_t
diff --git a/lib/libc/stat/fstatat.c b/lib/libc/stat/fstatat.c
index c36ba3e3..08519fe3 100644
--- a/lib/libc/stat/fstatat.c
+++ b/lib/libc/stat/fstatat.c
@@ -3,7 +3,6 @@
#define __BITS_STAT_H_
-#include "asm/unistd_64.h" // for __NR_statx
#include <bits/stat.h> // for stat
#include <syscall.h> // for __syscall_5, syscall
diff --git a/lib/libc/stat/futimens.c b/lib/libc/stat/futimens.c
index f3bb425d..c44f8823 100644
--- a/lib/libc/stat/futimens.c
+++ b/lib/libc/stat/futimens.c
@@ -1,3 +1,5 @@
+#include <time.h> // for timespec
+
#define __BITS_STAT_H_
#include <bits/stat.h> // for timespec
#include <sys/stat.h> // for utimensat, futimens
diff --git a/lib/libc/stat/mkdirat.c b/lib/libc/stat/mkdirat.c
index 49a4cecf..dc075bb2 100644
--- a/lib/libc/stat/mkdirat.c
+++ b/lib/libc/stat/mkdirat.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_mkdirat
+
+
#include <sys/stat.h> // for mkdirat
#include <sys/types.h> // for mode_t
diff --git a/lib/libc/stat/mknod.c b/lib/libc/stat/mknod.c
index b8efed01..e76e232b 100644
--- a/lib/libc/stat/mknod.c
+++ b/lib/libc/stat/mknod.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_mknodat
+
+
#include <fcntl.h> // for AT_FDCWD
#include <sys/stat.h> // for mknod
diff --git a/lib/libc/stat/mknodat.c b/lib/libc/stat/mknodat.c
index 5ac50f5c..d19253e6 100644
--- a/lib/libc/stat/mknodat.c
+++ b/lib/libc/stat/mknodat.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_mknodat
+
+
#include <sys/stat.h> // for mknodat
#include <sys/types.h> // for dev_t, mode_t
diff --git a/lib/libc/stat/umask.c b/lib/libc/stat/umask.c
index f9026df8..e33ec9f4 100644
--- a/lib/libc/stat/umask.c
+++ b/lib/libc/stat/umask.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_umask
+
+
#include <sys/stat.h> // for umask
#include <sys/types.h> // for mode_t
diff --git a/lib/libc/stat/utimensat.c b/lib/libc/stat/utimensat.c
index 5193a819..984c1921 100644
--- a/lib/libc/stat/utimensat.c
+++ b/lib/libc/stat/utimensat.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_utimensat
+
+
#include <syscall.h> // for __syscall_4, syscall
#include <time.h> // for timespec
diff --git a/lib/libc/statvfs/fstatvfs.c b/lib/libc/statvfs/fstatvfs.c
index d48a92f0..e228de83 100644
--- a/lib/libc/statvfs/fstatvfs.c
+++ b/lib/libc/statvfs/fstatvfs.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_fstatfs
+
+
#include <__statvfs.h> // for __statvfs
#include <asm-generic/statfs.h> // for statfs
diff --git a/lib/libc/statvfs/statvfs.c b/lib/libc/statvfs/statvfs.c
index 93ab5afb..8316b169 100644
--- a/lib/libc/statvfs/statvfs.c
+++ b/lib/libc/statvfs/statvfs.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_statfs
+
+
#include <__statvfs.h> // for __statvfs
#include <asm-generic/statfs.h> // for statfs
diff --git a/lib/libc/stdio/clearerr.c b/lib/libc/stdio/clearerr.c
index 87d733ae..02244466 100644
--- a/lib/libc/stdio/clearerr.c
+++ b/lib/libc/stdio/clearerr.c
@@ -1,13 +1,14 @@
-#include "__stdio.h" // for _IO_EOF, _IO_ERR
+#include "__stdio.h" // for __FILE, _IO_EOF, _IO_ERR
#include "stddef.h" // for NULL
-#include <libc.h> // for __IMPL
#include <stdio.h> // for FILE, clearerr
void clearerr(FILE *stream)
{
+ struct __FILE *stream_impl = __FILE(stream);
+
if (stream == NULL)
return;
- __IMPL(stream)->flags &= ~(_IO_ERR | _IO_EOF);
+ stream_impl->flags &= ~(_IO_ERR | _IO_EOF);
}
diff --git a/lib/libc/stdio/dtoa.c b/lib/libc/stdio/dtoa.c
index faf4bd8c..0322162b 100644
--- a/lib/libc/stdio/dtoa.c
+++ b/lib/libc/stdio/dtoa.c
@@ -210,9 +210,9 @@
* used for input more than STRTOD_DIGLIM digits long (default 40).
*/
-#include <atomic.h> // for LIBC_LOCK, LIBC_UNLOCK
-#include <libc.h> // for __IMPL
-#include <threads.h> // for thrd_current
+#include <__thread.h> // for __thread_self
+#include <atomic.h> // for LIBC_LOCK, LIBC_UNLOCK
+#include <threads.h> // for thrd_current
static atomic_flag dtoa_lock[2] = { ATOMIC_FLAG_INIT, ATOMIC_FLAG_INIT };
@@ -1556,7 +1556,7 @@ void set_max_dtoa_threads(unsigned int n)
static ThInfo *get_TI(void)
{
- unsigned int thno = __IMPL(thrd_current())->tid;
+ unsigned int thno = ((struct __thread_self *)thrd_current())->tid;
if (thno < maxthreads)
return TI1 + thno;
diff --git a/lib/libc/stdio/fclose.c b/lib/libc/stdio/fclose.c
index 8b0586c6..4534715b 100644
--- a/lib/libc/stdio/fclose.c
+++ b/lib/libc/stdio/fclose.c
@@ -1,6 +1,6 @@
-#include <libc.h> // for __IMPL
-#include <stdio.h> // for fflush, FILE, fclose, stderr, stdin, stdout
-#include <unistd.h> // for close
+#include <__stdio.h> // for __FILE
+#include <stdio.h> // for fflush, FILE, fclose, stderr, stdin, stdout
+#include <unistd.h> // for close
int fclose(FILE *stream)
{
@@ -8,7 +8,7 @@ int fclose(FILE *stream)
return -1;
if (stream != stdin && stream != stdout && stream != stderr) {
- if (close(__IMPL(stream)->fd) == -1)
+ if (close((__FILE(stream))->fd) == -1)
return -1;
}
diff --git a/lib/libc/stdio/fdopen.c b/lib/libc/stdio/fdopen.c
index f762a83d..c5db3854 100644
--- a/lib/libc/stdio/fdopen.c
+++ b/lib/libc/stdio/fdopen.c
@@ -1,9 +1,8 @@
-#include "__stdio.h" // for __libc_fadd
+#include "__stdio.h" // for __FILE, __libc_fadd
#include "features.h" // for __weak
#include "stdatomic.h" // for atomic_flag_clear
#include "stddef.h" // for NULL
-#include <libc.h> // for __IMPL
#include <stdio.h> // for FILE, _IONBF, SEEK_END, _IOLBF, fdopen
#include <stdlib.h> // for calloc, free
#include <unistd.h> // for lseek, off_t
@@ -21,17 +20,18 @@ FILE *fdopen(int fildes, const char *mode)
return NULL;
}
- if ((stream = calloc(1, sizeof(FILE))) == NULL)
+ stream = calloc(1, sizeof(FILE));
+ if (stream == NULL)
return NULL;
- __IMPL(stream)->fd = fildes;
- atomic_flag_clear(&__IMPL(stream)->lock);
+ __FILE(stream)->fd = fildes;
+ atomic_flag_clear(&__FILE(stream)->lock);
if (mode[0] == 'r') {
- __IMPL(stream)->type = _IONBF;
+ __FILE(stream)->type = _IONBF;
} else if (mode[0] == 'w') {
- __IMPL(stream)->type = _IOLBF;
+ __FILE(stream)->type = _IOLBF;
} else if (mode[0] == 'a') {
- __IMPL(stream)->type = _IONBF;
+ __FILE(stream)->type = _IONBF;
off_t offset = lseek(fildes, 0, SEEK_END);
if (offset == (off_t)-1) {
diff --git a/lib/libc/stdio/feof.c b/lib/libc/stdio/feof.c
index f8478d03..f9245d06 100644
--- a/lib/libc/stdio/feof.c
+++ b/lib/libc/stdio/feof.c
@@ -1,12 +1,12 @@
#include "stddef.h" // for NULL
-#include <libc.h> // for __IMPL
-#include <stdio.h> // for FILE, feof
+#include <__stdio.h> // for __FILE
+#include <stdio.h> // for FILE, feof
int feof(FILE *stream)
{
if (stream == NULL)
return 0;
- return __IMPL(stream)->eof;
+ return (__FILE(stream))->eof;
}
diff --git a/lib/libc/stdio/ferror.c b/lib/libc/stdio/ferror.c
index 69ef439d..5e4b8dc4 100644
--- a/lib/libc/stdio/ferror.c
+++ b/lib/libc/stdio/ferror.c
@@ -1,7 +1,6 @@
-#include "__stdio.h" // for _IO_ERR
+#include "__stdio.h" // for __FILE, _IO_ERR
#include "stddef.h" // for NULL
-#include <libc.h> // for __IMPL
#include <stdio.h> // for FILE, ferror
int ferror(FILE *stream)
@@ -9,5 +8,5 @@ int ferror(FILE *stream)
if (stream == NULL)
return 0;
- return (__IMPL(stream)->flags & _IO_ERR) != 0;
+ return (__FILE(stream)->flags & _IO_ERR) != 0;
}
diff --git a/lib/libc/stdio/fflush.c b/lib/libc/stdio/fflush.c
index 001e3139..1cf4b7bd 100644
--- a/lib/libc/stdio/fflush.c
+++ b/lib/libc/stdio/fflush.c
@@ -1,10 +1,9 @@
-#include "__stdio.h" // for _IO_ERR
+#include "__stdio.h" // for __FILE, _IO_ERR
#include "stddef.h" // for NULL
#include <atomic.h> // for LIBC_UNLOCK, LIBC_LOCK
#include <errno.h> // for errno, EBADF, EIO
#include <fcntl.h> // for O_ACCMODE, O_RDONLY
-#include <libc.h> // for __IMPL
#include <stdio.h> // for EOF, FILE, fflush
#include <string.h> // for memmove
#include <unistd.h> // for size_t, write, ssize_t
@@ -17,39 +16,39 @@ int fflush(FILE *stream)
return 0;
}
- if (__IMPL(stream)->buf_len == 0) {
+ if (__FILE(stream)->buf_len == 0) {
return 0;
}
- if (__IMPL(stream)->fd == -1) {
- stream->buf_len = 0;
+ if (__FILE(stream)->fd == -1) {
+ __FILE(stream)->buf_len = 0;
return 0;
}
- if (__IMPL(stream)->flags & _IO_ERR) {
+ if (__FILE(stream)->flags & _IO_ERR) {
errno = EIO;
return EOF;
}
- if ((__IMPL(stream)->flags & O_ACCMODE) == O_RDONLY) {
+ if ((__FILE(stream)->flags & O_ACCMODE) == O_RDONLY) {
errno = EBADF;
return EOF;
}
- LIBC_LOCK(__IMPL(stream)->lock);
+ LIBC_LOCK(__FILE(stream)->lock);
- size_t bytes_to_write = __IMPL(stream)->buf_len;
+ size_t bytes_to_write = __FILE(stream)->buf_len;
size_t total_written = 0;
- char *buf_ptr = __IMPL(stream)->buf;
+ char *buf_ptr = __FILE(stream)->buf;
while (total_written < bytes_to_write) {
- ssize_t result = write(__IMPL(stream)->fd,
+ ssize_t result = write(__FILE(stream)->fd,
buf_ptr + total_written,
bytes_to_write - total_written);
if (result < 0) {
- __IMPL(stream)->flags |= _IO_ERR;
- LIBC_UNLOCK(__IMPL(stream)->lock);
+ __FILE(stream)->flags |= _IO_ERR;
+ LIBC_UNLOCK(__FILE(stream)->lock);
return EOF;
}
@@ -61,17 +60,17 @@ int fflush(FILE *stream)
}
if (total_written == bytes_to_write) {
- __IMPL(stream)->buf_len = 0;
- __IMPL(stream)->buf_pos = 0;
+ __FILE(stream)->buf_len = 0;
+ __FILE(stream)->buf_pos = 0;
} else {
size_t remaining = bytes_to_write - total_written;
- memmove(__IMPL(stream)->buf,
- __IMPL(stream)->buf + total_written, remaining);
- __IMPL(stream)->buf_len = remaining;
- __IMPL(stream)->buf_pos = 0;
+ memmove(__FILE(stream)->buf,
+ __FILE(stream)->buf + total_written, remaining);
+ __FILE(stream)->buf_len = remaining;
+ __FILE(stream)->buf_pos = 0;
}
- LIBC_UNLOCK(__IMPL(stream)->lock);
+ LIBC_UNLOCK(__FILE(stream)->lock);
return (total_written == bytes_to_write) ? 0 : EOF;
}
diff --git a/lib/libc/stdio/fileno.c b/lib/libc/stdio/fileno.c
index ad3eda7f..e27b56de 100644
--- a/lib/libc/stdio/fileno.c
+++ b/lib/libc/stdio/fileno.c
@@ -1,15 +1,15 @@
-#include <atomic.h> // for LIBC_LOCK, LIBC_UNLOCK
-#include <errno.h> // for EBADF, errno
-#include <libc.h> // for __IMPL
-#include <stdio.h> // for FILE, fileno
+#include <__stdio.h> // for __FILE
+#include <atomic.h> // for LIBC_LOCK, LIBC_UNLOCK
+#include <errno.h> // for EBADF, errno
+#include <stdio.h> // for FILE, fileno
int fileno(FILE *stream)
{
int fd;
- LIBC_LOCK(__IMPL(stream)->lock);
- fd = __IMPL(stream)->fd;
- LIBC_UNLOCK(__IMPL(stream)->lock);
+ LIBC_LOCK(__FILE(stream)->lock);
+ fd = __FILE(stream)->fd;
+ LIBC_UNLOCK(__FILE(stream)->lock);
if (fd < 0) {
errno = EBADF;
diff --git a/lib/libc/stdio/fmemopen.c b/lib/libc/stdio/fmemopen.c
index 21e811fd..920484b3 100644
--- a/lib/libc/stdio/fmemopen.c
+++ b/lib/libc/stdio/fmemopen.c
@@ -1,10 +1,9 @@
-#include "__stdio.h" // for __libc_fadd
+#include "__stdio.h" // for __FILE, __libc_fadd
#include "features.h" // for __weak
#include "stddef.h" // for NULL
#include <errno.h> // for EINVAL, errno
#include <fcntl.h> // for O_WRONLY, O_CREAT, O_RDONLY, O_APPEND, O_RDWR
-#include <libc.h> // for __IMPL
#include <stdio.h> // for FILE, _IOFBF, fmemopen, size_t
#include <stdlib.h> // for calloc, free
#include <string.h> // for strchr
@@ -21,10 +20,10 @@ FILE *fmemopen(void *restrict buf, size_t max_size, const char *restrict mode)
if (stream == NULL)
return stream;
- __IMPL(stream)->fd = -1;
- __IMPL(stream)->buf = buf;
- __IMPL(stream)->buf_size = max_size;
- __IMPL(stream)->type = _IOFBF;
+ __FILE(stream)->fd = -1;
+ __FILE(stream)->buf = buf;
+ __FILE(stream)->buf_size = max_size;
+ __FILE(stream)->type = _IOFBF;
if (mode[0] == 'r') {
flags = O_RDONLY;
@@ -42,7 +41,7 @@ FILE *fmemopen(void *restrict buf, size_t max_size, const char *restrict mode)
flags = (flags & ~(O_RDONLY | O_WRONLY)) | O_RDWR;
}
- __IMPL(stream)->flags = flags;
+ __FILE(stream)->flags = flags;
__libc_fadd(stream);
diff --git a/lib/libc/stdio/fopen.c b/lib/libc/stdio/fopen.c
index a56b907d..bef21f46 100644
--- a/lib/libc/stdio/fopen.c
+++ b/lib/libc/stdio/fopen.c
@@ -1,11 +1,10 @@
-#include "__stdio.h" // for __libc_fadd
+#include "__stdio.h" // for __FILE, __libc_fadd
#include "features.h" // for __weak
#include "stdatomic.h" // for atomic_flag_clear
#include "stddef.h" // for NULL
#include <errno.h> // for EINVAL, errno
#include <fcntl.h> // for O_WRONLY, O_CREAT, O_RDONLY, open, O_APPEND
-#include <libc.h> // for __IMPL
#include <stdio.h> // for FILE, BUFSIZ, fopen, _IOLBF
#include <stdlib.h> // for calloc, free, malloc
#include <string.h> // for strchr
@@ -43,13 +42,13 @@ FILE *fopen(const char *restrict pathname, const char *restrict mode)
if ((stream = calloc(1, sizeof(FILE))) == NULL)
return NULL;
- __IMPL(stream)->fd = fd;
- __IMPL(stream)->buf_size = BUFSIZ;
- __IMPL(stream)->flags = flags;
- __IMPL(stream)->type = _IOLBF;
- atomic_flag_clear(&stream->lock);
+ __FILE(stream)->fd = fd;
+ __FILE(stream)->buf_size = BUFSIZ;
+ __FILE(stream)->flags = flags;
+ __FILE(stream)->type = _IOLBF;
+ atomic_flag_clear(&__FILE(stream)->lock);
- if ((__IMPL(stream)->buf = malloc(BUFSIZ)) == NULL) {
+ if ((__FILE(stream)->buf = malloc(BUFSIZ)) == NULL) {
close(fd);
free(stream);
return NULL;
diff --git a/lib/libc/stdio/fputc.c b/lib/libc/stdio/fputc.c
index 08ab0cfc..922011f2 100644
--- a/lib/libc/stdio/fputc.c
+++ b/lib/libc/stdio/fputc.c
@@ -1,8 +1,8 @@
#include "stddef.h" // for NULL
-#include <errno.h> // for EINVAL, errno
-#include <libc.h> // for __IMPL
-#include <stdio.h> // for EOF, fwrite, FILE, fputc
+#include <__stdio.h> // for __FILE
+#include <errno.h> // for EINVAL, errno
+#include <stdio.h> // for EOF, fwrite, FILE, fputc
int fputc(int c, FILE *stream)
{
@@ -11,12 +11,13 @@ int fputc(int c, FILE *stream)
return EOF;
}
- if (__IMPL(stream)->fd == -1 && __IMPL(stream)->buf != NULL) {
- if (__IMPL(stream)->buf_len >= __IMPL(stream)->buf_size - 1) {
+ if ((__FILE(stream))->fd == -1 && (__FILE(stream))->buf != NULL) {
+ if ((__FILE(stream))->buf_len >=
+ (__FILE(stream))->buf_size - 1) {
return EOF;
}
- __IMPL(stream)->buf[__IMPL(stream)->buf_len++] = (char)c;
+ (__FILE(stream))->buf[(__FILE(stream))->buf_len++] = (char)c;
return (unsigned char)c;
}
diff --git a/lib/libc/stdio/fread.c b/lib/libc/stdio/fread.c
index fb4ca3f6..443b4874 100644
--- a/lib/libc/stdio/fread.c
+++ b/lib/libc/stdio/fread.c
@@ -1,7 +1,6 @@
-#include "__stdio.h" // for _IO_EOF, _IO_ERR
+#include "__stdio.h" // for __FILE, _IO_EOF, _IO_ERR
#include <atomic.h> // for LIBC_LOCK, LIBC_UNLOCK
-#include <libc.h> // for __IMPL
#include <stdio.h> // for fread, BUFSIZ, FILE
#include <string.h> // for memcpy
#include <unistd.h> // for size_t, read, ssize_t
@@ -18,38 +17,38 @@ size_t fread(void *restrict ptr, size_t size, size_t nitems,
size_t bytes_read = 0;
char *p = ptr;
- LIBC_LOCK(__IMPL(stream)->lock);
+ LIBC_LOCK(__FILE(stream)->lock);
while (total > 0) {
- if (__IMPL(stream)->buf_pos < __IMPL(stream)->buf_len) {
- size_t available = __IMPL(stream)->buf_len -
- __IMPL(stream)->buf_pos;
+ if (__FILE(stream)->buf_pos < __FILE(stream)->buf_len) {
+ size_t available = __FILE(stream)->buf_len -
+ __FILE(stream)->buf_pos;
size_t to_copy = total < available ? total : available;
- memcpy(p, __IMPL(stream)->buf + __IMPL(stream)->buf_pos,
+ memcpy(p, __FILE(stream)->buf + __FILE(stream)->buf_pos,
to_copy);
- __IMPL(stream)->buf_pos += to_copy;
+ __FILE(stream)->buf_pos += to_copy;
p += to_copy;
bytes_read += to_copy;
total -= to_copy;
continue;
}
- ssize_t ret = read(__IMPL(stream)->fd, __IMPL(stream)->buf,
- __IMPL(stream)->buf_size);
+ ssize_t ret = read(__FILE(stream)->fd, __FILE(stream)->buf,
+ __FILE(stream)->buf_size);
if (ret <= 0) {
if (ret < 0)
- __IMPL(stream)->flags |= _IO_ERR;
+ __FILE(stream)->flags |= _IO_ERR;
else
- __IMPL(stream)->flags |= _IO_EOF;
+ __FILE(stream)->flags |= _IO_EOF;
break;
}
- __IMPL(stream)->buf_len = ret;
- __IMPL(stream)->buf_pos = 0;
+ __FILE(stream)->buf_len = ret;
+ __FILE(stream)->buf_pos = 0;
}
- LIBC_UNLOCK(__IMPL(stream)->lock);
+ LIBC_UNLOCK(__FILE(stream)->lock);
return bytes_read / size;
}
diff --git a/lib/libc/stdio/fseek.c b/lib/libc/stdio/fseek.c
index 0e425e8e..7a6754f7 100644
--- a/lib/libc/stdio/fseek.c
+++ b/lib/libc/stdio/fseek.c
@@ -1,31 +1,30 @@
-#include "__stdio.h" // for _IO_EOF, _IO_ERR
+#include "__stdio.h" // for __FILE, _IO_EOF, _IO_ERR
#include "stddef.h" // for NULL
#include <atomic.h> // for LIBC_LOCK, LIBC_UNLOCK
-#include <libc.h> // for __IMPL
#include <stdio.h> // for FILE, fseek
#include <unistd.h> // for lseek, off_t
int fseek(FILE *stream, long offset, int whence)
{
- if (stream == NULL || __IMPL(stream)->fd < 0)
+ if (stream == NULL || __FILE(stream)->fd < 0)
return -1;
- LIBC_LOCK(__IMPL(stream)->lock);
+ LIBC_LOCK(__FILE(stream)->lock);
- __IMPL(stream)->buf_pos = 0;
- __IMPL(stream)->buf_len = 0;
- __IMPL(stream)->flags &= ~_IO_EOF;
+ __FILE(stream)->buf_pos = 0;
+ __FILE(stream)->buf_len = 0;
+ __FILE(stream)->flags &= ~_IO_EOF;
- off_t result = lseek(__IMPL(stream)->fd, offset, whence);
+ off_t result = lseek(__FILE(stream)->fd, offset, whence);
- LIBC_UNLOCK(__IMPL(stream)->lock);
+ LIBC_UNLOCK(__FILE(stream)->lock);
if (result == (off_t)-1) {
- __IMPL(stream)->flags |= _IO_ERR;
+ __FILE(stream)->flags |= _IO_ERR;
return -1;
}
- __IMPL(stream)->offset = result;
+ __FILE(stream)->offset = result;
return 0;
}
diff --git a/lib/libc/stdio/fwrite.c b/lib/libc/stdio/fwrite.c
index 4adbca81..c21054da 100644
--- a/lib/libc/stdio/fwrite.c
+++ b/lib/libc/stdio/fwrite.c
@@ -1,10 +1,9 @@
-#include "__stdio.h" // for _IO_ERR
+#include "__stdio.h" // for __FILE, _IO_ERR
#include "stddef.h" // for NULL
#include <atomic.h> // for LIBC_UNLOCK, LIBC_LOCK
#include <errno.h> // for errno, EOVERFLOW, EBADF, EINVAL, EIO
#include <fcntl.h> // for O_ACCMODE, O_RDONLY
-#include <libc.h> // for __IMPL
#include <stdio.h> // for fflush, fwrite, BUFSIZ, FILE, _IOFBF, _IOLBF
#include <string.h> // for memcpy, memchr
#include <unistd.h> // for size_t, ssize_t, write
@@ -27,16 +26,16 @@ size_t fwrite(const void *restrict ptr, size_t size, size_t nitems,
return 0;
}
- if (__IMPL(stream)->fd == -1 && __IMPL(stream)->buf != NULL) {
+ if (__FILE(stream)->fd == -1 && __FILE(stream)->buf != NULL) {
if (__builtin_mul_overflow(size, nitems, &total_bytes)) {
errno = EOVERFLOW;
return 0;
}
size_t space_left =
- __IMPL(stream)->buf_size > __IMPL(stream)->buf_len ?
- __IMPL(stream)->buf_size -
- __IMPL(stream)->buf_len - 1 :
+ __FILE(stream)->buf_size > __FILE(stream)->buf_len ?
+ __FILE(stream)->buf_size -
+ __FILE(stream)->buf_len - 1 :
0;
if (space_left == 0) {
@@ -47,9 +46,9 @@ size_t fwrite(const void *restrict ptr, size_t size, size_t nitems,
space_left;
if (to_copy > 0) {
- memcpy(__IMPL(stream)->buf + __IMPL(stream)->buf_len,
+ memcpy(__FILE(stream)->buf + __FILE(stream)->buf_len,
data, to_copy);
- __IMPL(stream)->buf_len += to_copy;
+ __FILE(stream)->buf_len += to_copy;
}
return to_copy == total_bytes ? nitems : to_copy / size;
@@ -60,24 +59,24 @@ size_t fwrite(const void *restrict ptr, size_t size, size_t nitems,
return 0;
}
- if ((__IMPL(stream)->flags & O_ACCMODE) == O_RDONLY) {
+ if ((__FILE(stream)->flags & O_ACCMODE) == O_RDONLY) {
errno = EBADF;
return 0;
}
- if (__IMPL(stream)->flags & _IO_ERR) {
+ if (__FILE(stream)->flags & _IO_ERR) {
errno = EIO;
return 0;
}
- LIBC_LOCK(__IMPL(stream)->lock);
+ LIBC_LOCK(__FILE(stream)->lock);
- if (__IMPL(stream)->type == _IONBF) {
- ssize_t result = write(__IMPL(stream)->fd, data, total_bytes);
- LIBC_UNLOCK(__IMPL(stream)->lock);
+ if (__FILE(stream)->type == _IONBF) {
+ ssize_t result = write(__FILE(stream)->fd, data, total_bytes);
+ LIBC_UNLOCK(__FILE(stream)->lock);
if (result < 0) {
- __IMPL(stream)->flags |= _IO_ERR;
+ __FILE(stream)->flags |= _IO_ERR;
return 0;
}
@@ -88,48 +87,48 @@ size_t fwrite(const void *restrict ptr, size_t size, size_t nitems,
while (remaining > 0) {
size_t space_available =
- __IMPL(stream)->buf_size - __IMPL(stream)->buf_len;
+ __FILE(stream)->buf_size - __FILE(stream)->buf_len;
if (space_available == 0) {
- LIBC_UNLOCK(__IMPL(stream)->lock);
+ LIBC_UNLOCK(__FILE(stream)->lock);
if (fflush(stream) != 0) {
return written / size;
}
- space_available = __IMPL(stream)->buf_size;
+ space_available = __FILE(stream)->buf_size;
}
size_t to_copy = remaining < space_available ? remaining :
space_available;
- memcpy(__IMPL(stream)->buf + __IMPL(stream)->buf_len,
+ memcpy(__FILE(stream)->buf + __FILE(stream)->buf_len,
data + written, to_copy);
- __IMPL(stream)->buf_len += to_copy;
+ __FILE(stream)->buf_len += to_copy;
written += to_copy;
remaining -= to_copy;
- if (__IMPL(stream)->type == _IOLBF) {
+ if (__FILE(stream)->type == _IOLBF) {
char *newline_pos = memchr(
- __IMPL(stream)->buf + __IMPL(stream)->buf_len -
+ __FILE(stream)->buf + __FILE(stream)->buf_len -
to_copy,
'\n', to_copy);
if (newline_pos != NULL) {
- LIBC_UNLOCK(__IMPL(stream)->lock);
+ LIBC_UNLOCK(__FILE(stream)->lock);
if (fflush(stream) != 0) {
return written / size;
}
}
}
- else if (__IMPL(stream)->type == _IOFBF &&
- __IMPL(stream)->buf_len == __IMPL(stream)->buf_size) {
- LIBC_UNLOCK(__IMPL(stream)->lock);
+ else if (__FILE(stream)->type == _IOFBF &&
+ __FILE(stream)->buf_len == __FILE(stream)->buf_size) {
+ LIBC_UNLOCK(__FILE(stream)->lock);
if (fflush(stream) != 0) {
return written / size;
}
}
}
- LIBC_UNLOCK(__IMPL(stream)->lock);
+ LIBC_UNLOCK(__FILE(stream)->lock);
return written == total_bytes ? nitems : written / size;
}
diff --git a/lib/libc/stdio/pclose.c b/lib/libc/stdio/pclose.c
index 241d4de0..a515981c 100644
--- a/lib/libc/stdio/pclose.c
+++ b/lib/libc/stdio/pclose.c
@@ -1,4 +1,4 @@
-#include <libc.h> // for __IMPL
+#include <__stdio.h> // for __FILE
#include <stdio.h> // for fclose, FILE, pclose
#include <sys/wait.h> // for waitpid
@@ -6,5 +6,5 @@ int pclose(FILE *stream)
{
int stat;
fclose(stream);
- return (waitpid(__IMPL(stream)->pid, &stat, 0) < 0) ? -1 : stat;
+ return (waitpid(__FILE(stream)->pid, &stat, 0) < 0) ? -1 : stat;
}
diff --git a/lib/libc/stdio/perror.c b/lib/libc/stdio/perror.c
index 63c708a9..ad314038 100644
--- a/lib/libc/stdio/perror.c
+++ b/lib/libc/stdio/perror.c
@@ -1,5 +1,7 @@
+#include "stddef.h" // for NULL
+
#include <errno.h> // for errno
-#include <stdio.h> // for NULL, perror
+#include <stdio.h> // for perror
#include <string.h> // for strlen, strerror
#include <sys/uio.h> // for iovec, writev
#include <unistd.h> // for STDERR_FILENO
diff --git a/lib/libc/stdio/popen.c b/lib/libc/stdio/popen.c
index 09c931ad..1fd5f991 100644
--- a/lib/libc/stdio/popen.c
+++ b/lib/libc/stdio/popen.c
@@ -1,10 +1,10 @@
#include "stddef.h" // for NULL
-#include <errno.h> // for EINVAL, errno
-#include <fcntl.h> // for O_RDONLY, O_CLOEXEC, O_WRONLY
-#include <libc.h> // for __IMPL
-#include <stdio.h> // for FILE, fclose, fdopen, popen
-#include <unistd.h> // for close, dup2, _exit, execl, fork, pipe2, STDIN_FI...
+#include <__stdio.h> // for __FILE
+#include <errno.h> // for EINVAL, errno
+#include <fcntl.h> // for O_RDONLY, O_CLOEXEC, O_WRONLY
+#include <stdio.h> // for FILE, fclose, fdopen, popen
+#include <unistd.h> // for close, dup2, _exit, execl, fork, pipe2, STDIN_F...
FILE *popen(const char *command, const char *mode)
{
@@ -41,7 +41,9 @@ FILE *popen(const char *command, const char *mode)
close(pipefd[1]);
fclose(stream);
return NULL;
- } else if (pid == 0) {
+ }
+
+ if (pid == 0) {
if (oflag == O_RDONLY) {
dup2(pipefd[1], STDOUT_FILENO);
close(pipefd[0]);
@@ -51,7 +53,7 @@ FILE *popen(const char *command, const char *mode)
close(pipefd[0]);
close(pipefd[1]);
}
- execl("/bin/sh", "sh", "-c", command, (char *)NULL);
+ execl("/bin/sh", "sh", "-c", command, (char *)0);
_exit(127);
} else {
if (oflag == O_RDONLY) {
@@ -60,7 +62,7 @@ FILE *popen(const char *command, const char *mode)
close(pipefd[0]);
}
- __IMPL(stream)->pid = pid;
+ __FILE(stream)->pid = pid;
return stream;
}
diff --git a/lib/libc/stdio/remove.c b/lib/libc/stdio/remove.c
index 25bbd3bd..9afd47b4 100644
--- a/lib/libc/stdio/remove.c
+++ b/lib/libc/stdio/remove.c
@@ -1,4 +1,3 @@
-#include "asm/unistd_64.h" // for __NR_unlinkat
#include "errno.h" // for EISDIR, errno
#include <fcntl.h> // for AT_FDCWD, AT_REMOVEDIR
@@ -10,9 +9,8 @@ int remove(const char *path)
if (syscall(unlinkat, AT_FDCWD, path, 0) < 0) {
if (errno == EISDIR) {
return syscall(unlinkat, AT_FDCWD, path, AT_REMOVEDIR);
- } else {
- return -1;
}
+ return -1;
}
return 0;
diff --git a/lib/libc/stdio/rename.c b/lib/libc/stdio/rename.c
index 8857f852..52426ab0 100644
--- a/lib/libc/stdio/rename.c
+++ b/lib/libc/stdio/rename.c
@@ -1,5 +1,7 @@
-#include "asm/unistd_64.h" // for __NR_rename
+
+
+#include <stdio.h> // for rename
#include <syscall.h> // for __syscall_2, syscall
int rename(const char *old, const char *new)
diff --git a/lib/libc/stdio/renameat.c b/lib/libc/stdio/renameat.c
index fde966c4..c7e9a683 100644
--- a/lib/libc/stdio/renameat.c
+++ b/lib/libc/stdio/renameat.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_renameat
+
+
#include <syscall.h> // for __syscall_4, syscall
diff --git a/lib/libc/stdio/setbuf.c b/lib/libc/stdio/setbuf.c
index ddddf4ac..48d15c51 100644
--- a/lib/libc/stdio/setbuf.c
+++ b/lib/libc/stdio/setbuf.c
@@ -1,4 +1,6 @@
-#include <stdio.h> // for setvbuf, BUFSIZ, FILE, NULL, _IOFBF, _IONBF, setbuf
+#include "stddef.h" // for NULL
+
+#include <stdio.h> // for setvbuf, BUFSIZ, FILE, _IOFBF, _IONBF, setbuf
void setbuf(FILE *restrict stream, char *restrict buf)
{
diff --git a/lib/libc/stdio/setvbuf.c b/lib/libc/stdio/setvbuf.c
index 02928a35..686640f4 100644
--- a/lib/libc/stdio/setvbuf.c
+++ b/lib/libc/stdio/setvbuf.c
@@ -1,7 +1,7 @@
#include "stddef.h" // for NULL
-#include <libc.h> // for __IMPL
-#include <stdio.h> // for _IONBF, FILE, _IOFBF, _IOLBF, setvbuf, size_t
+#include <__stdio.h> // for __FILE
+#include <stdio.h> // for _IONBF, FILE, _IOFBF, _IOLBF, setvbuf, size_t
int setvbuf(FILE *restrict stream, char *restrict buf, int type, size_t size)
{
@@ -10,13 +10,13 @@ int setvbuf(FILE *restrict stream, char *restrict buf, int type, size_t size)
if (type != _IONBF && (buf == NULL || size == 0))
return -1;
- if (__IMPL(stream)->fd < 0)
+ if (__FILE(stream)->fd < 0)
return -1;
- __IMPL(stream)->buf = buf;
- __IMPL(stream)->buf_size = size;
- __IMPL(stream)->buf_pos = 0;
- __IMPL(stream)->type = type;
+ __FILE(stream)->buf = buf;
+ __FILE(stream)->buf_size = size;
+ __FILE(stream)->buf_pos = 0;
+ __FILE(stream)->type = type;
return 0;
}
diff --git a/lib/libc/stdio/stderr.c b/lib/libc/stdio/stderr.c
index 155f0e3e..ec115fd0 100644
--- a/lib/libc/stdio/stderr.c
+++ b/lib/libc/stdio/stderr.c
@@ -2,6 +2,7 @@
#include "stdatomic.h" // for ATOMIC_FLAG_INIT
#include <fcntl.h> // for O_WRONLY
+#include <stdio.h> // for FILE, stderr
#include <unistd.h> // for STDERR_FILENO
#define BUFSIZ 4096
@@ -19,4 +20,4 @@ struct __FILE __stderr = { .fd = STDERR_FILENO,
.offset = 0,
.lock = ATOMIC_FLAG_INIT };
-struct FILE *const stderr = (struct FILE *)&__stderr;
+FILE *const stderr = (FILE *)&__stderr;
diff --git a/lib/libc/stdio/stdin.c b/lib/libc/stdio/stdin.c
index b4194704..45d42e27 100644
--- a/lib/libc/stdio/stdin.c
+++ b/lib/libc/stdio/stdin.c
@@ -2,10 +2,10 @@
#include "features.h" // for __weak
#include <fcntl.h> // for O_RDONLY
+#include <stdio.h> // for FILE, stdin
#include <unistd.h> // for STDOUT_FILENO
#define BUFSIZ 4096
-#define _IOLBF 0x1
__weak char __stdin_buffer[0];
struct __FILE __stdin = { .fd = STDOUT_FILENO,
@@ -16,4 +16,4 @@ struct __FILE __stdin = { .fd = STDOUT_FILENO,
.buf_pos = 0,
.offset = 0 };
-struct FILE *const stdin = (struct FILE *)&__stdin;
+FILE *const stdin = (FILE *)&__stdin;
diff --git a/lib/libc/stdio/stdout.c b/lib/libc/stdio/stdout.c
index a21125c3..14637368 100644
--- a/lib/libc/stdio/stdout.c
+++ b/lib/libc/stdio/stdout.c
@@ -5,6 +5,7 @@
#include <atomic.h> // for LIBC_LOCK, LIBC_UNLOCK
#include <fcntl.h> // for O_WRONLY
#include <stddef.h> // for NULL
+#include <stdio.h> // for stdout
#include <unistd.h> // for STDOUT_FILENO
#define BUFSIZ 4096
diff --git a/lib/libc/stdlib/_Exit.c b/lib/libc/stdlib/_Exit.c
index beb53e34..5a4d36e9 100644
--- a/lib/libc/stdlib/_Exit.c
+++ b/lib/libc/stdlib/_Exit.c
@@ -1,4 +1,4 @@
-#include <unistd.h>
+#include <unistd.h> // for _exit
_Noreturn void _Exit(int status)
{
diff --git a/lib/libc/stdlib/abort.c b/lib/libc/stdlib/abort.c
index 3d022e70..99001570 100644
--- a/lib/libc/stdlib/abort.c
+++ b/lib/libc/stdlib/abort.c
@@ -1,11 +1,11 @@
-#include <atomic.h>
-#include <stdlib.h>
-#include <syscall.h>
-#include <asm-generic/signal.h>
-#include <thread.h>
-#include <threads.h>
-#include <unistd.h>
-#include <libc.h>
+#include <__thread.h> // for __thread_self
+#include <atomic.h> // for LIBC_LOCK
+#include <libc.h> // for (anonymous struct)::(anonymous), (anonymous)
+#include <signal.h> // for SIGABRT, sigaction, SIGKILL, SIG_DFL
+#include <stdlib.h> // for abort
+#include <syscall.h> // for __syscall, __syscall_2, __syscall_4
+#include <threads.h> // for thrd_current
+#include <unistd.h> // for _exit
int raise(int);
@@ -18,8 +18,9 @@ _Noreturn void abort(void)
LIBC_LOCK(libc.lock.abort);
sa.sa_handler = SIG_DFL;
- __syscall(rt_sigaction, SIGABRT, &sa, NULL, _NSIG / 8);
- __syscall(tkill, thrd_current()->tid, SIGABRT);
+ __syscall(rt_sigaction, SIGABRT, &sa, 0, 64 / 8);
+ __syscall(tkill, ((struct __thread_self *)thrd_current())->tid,
+ SIGABRT);
// This point should never be reached
raise(SIGKILL);
diff --git a/lib/libc/stdlib/abs.c b/lib/libc/stdlib/abs.c
index ac2bc605..5c510567 100644
--- a/lib/libc/stdlib/abs.c
+++ b/lib/libc/stdlib/abs.c
@@ -1,3 +1,5 @@
+#include <stdlib.h> // for abs
+
int abs(int i)
{
return (i < 0) ? -i : i;
diff --git a/lib/libc/stdlib/aligned_alloc.c b/lib/libc/stdlib/aligned_alloc.c
index f978dfa9..f8ab24db 100644
--- a/lib/libc/stdlib/aligned_alloc.c
+++ b/lib/libc/stdlib/aligned_alloc.c
@@ -1,8 +1,8 @@
-#include <errno.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <sys/mman.h>
-#include <unistd.h>
+#include "stddef.h" // for NULL
+
+#include <errno.h> // for errno, EINVAL, ENOMEM
+#include <stdint.h> // for uintptr_t
+#include <stdlib.h> // for size_t, aligned_alloc, malloc
void *aligned_alloc(size_t alignment, size_t size)
{
diff --git a/lib/libc/stdlib/atexit.c b/lib/libc/stdlib/atexit.c
index 6c84fd4a..cf1f91e5 100644
--- a/lib/libc/stdlib/atexit.c
+++ b/lib/libc/stdlib/atexit.c
@@ -1,4 +1,6 @@
-#include <stdlib.h>
+#include "stddef.h" // for NULL
+
+#include <stdlib.h> // for atexit
static void (*__atexit_fvec[32])(void) = { NULL };
diff --git a/lib/libc/stdlib/atof.c b/lib/libc/stdlib/atof.c
index 5f5fc91f..aff6634b 100644
--- a/lib/libc/stdlib/atof.c
+++ b/lib/libc/stdlib/atof.c
@@ -1,4 +1,6 @@
-#include <stdlib.h>
+#include "stddef.h" // for NULL
+
+#include <stdlib.h> // for strtod, atof
double atof(const char *str)
{
diff --git a/lib/libc/stdlib/atoi.c b/lib/libc/stdlib/atoi.c
index 97b663d1..614bd75c 100644
--- a/lib/libc/stdlib/atoi.c
+++ b/lib/libc/stdlib/atoi.c
@@ -1,4 +1,6 @@
-#include <stdlib.h>
+#include "stddef.h" // for NULL
+
+#include <stdlib.h> // for strtol, atoi
int atoi(const char *str)
{
diff --git a/lib/libc/stdlib/atol.c b/lib/libc/stdlib/atol.c
index 976f9997..81bbbf82 100644
--- a/lib/libc/stdlib/atol.c
+++ b/lib/libc/stdlib/atol.c
@@ -1,4 +1,6 @@
-#include <stdlib.h>
+#include "stddef.h" // for NULL
+
+#include <stdlib.h> // for strtol, atol
long atol(const char *nptr)
{
diff --git a/lib/libc/stdlib/atoll.c b/lib/libc/stdlib/atoll.c
index bea1a031..c830e4df 100644
--- a/lib/libc/stdlib/atoll.c
+++ b/lib/libc/stdlib/atoll.c
@@ -1,4 +1,6 @@
-#include <stdlib.h>
+#include "stddef.h" // for NULL
+
+#include <stdlib.h> // for strtoll, atoll
long long atoll(const char *nptr)
{
diff --git a/lib/libc/stdlib/bsearch.c b/lib/libc/stdlib/bsearch.c
index a2793b0d..b4f83d55 100644
--- a/lib/libc/stdlib/bsearch.c
+++ b/lib/libc/stdlib/bsearch.c
@@ -47,8 +47,9 @@ is respectively less than, matching, or greater than the array member.
*/
-#include <sys/types.h> /* size_t */
-#include <stdio.h>
+#include "stddef.h" // for NULL
+
+#include <stdio.h> // for size_t
/*
* Perform a binary search.
diff --git a/lib/libc/stdlib/btowc.c b/lib/libc/stdlib/btowc.c
index f16865b7..36f392bf 100644
--- a/lib/libc/stdlib/btowc.c
+++ b/lib/libc/stdlib/btowc.c
@@ -1,6 +1,6 @@
-#include <wchar.h>
#include <stdio.h>
#include <stdlib.h>
+#include <wchar.h>
#define CODEUNIT(c) (0xdfff & (signed char)(c))
diff --git a/lib/libc/stdlib/calloc.c b/lib/libc/stdlib/calloc.c
index 408eef5e..89e16f80 100644
--- a/lib/libc/stdlib/calloc.c
+++ b/lib/libc/stdlib/calloc.c
@@ -1,6 +1,8 @@
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
+#include "stddef.h" // for NULL
+
+#include <errno.h> // for errno, EINVAL, ENOMEM
+#include <stdlib.h> // for calloc, malloc
+#include <string.h> // for size_t, memset
void *calloc(size_t nelem, size_t elsize)
{
diff --git a/lib/libc/stdlib/div.c b/lib/libc/stdlib/div.c
index cadc292e..e7a290a9 100644
--- a/lib/libc/stdlib/div.c
+++ b/lib/libc/stdlib/div.c
@@ -1,4 +1,4 @@
-#include <stdlib.h>
+#include <stdlib.h> // for div_t, div
div_t div(int numer, int denom)
{
diff --git a/lib/libc/stdlib/exit.c b/lib/libc/stdlib/exit.c
index 5fea520e..7fc96f28 100644
--- a/lib/libc/stdlib/exit.c
+++ b/lib/libc/stdlib/exit.c
@@ -1,7 +1,10 @@
-#include <libc.h>
-#include <libc.h>
-#include <unistd.h>
-#include <stdio.h>
+#include "__stdio.h" // for __FILE
+#include "stddef.h" // for NULL
+
+#include <libc.h> // for weak_reference
+#include <stdio.h> // for fflush, stdout, FILE, stderr, stdin
+#include <stdlib.h> // for free, exit
+#include <unistd.h> // for _exit, close, write, STDERR_FILENO
void (*__dummy_atexit_fvec)(void);
weak_reference(__dummy_atexit_fvec, __atexit_fvec);
@@ -15,16 +18,16 @@ static void __fclose(FILE *stream)
return;
}
- if (__IMPL(stream)->buf_len > 0) {
+ if (__FILE(stream)->buf_len > 0) {
fflush(stream);
}
- if (__IMPL(stream)->fd > STDERR_FILENO) {
- close(__IMPL(stream)->fd);
+ if (__FILE(stream)->fd > STDERR_FILENO) {
+ close(__FILE(stream)->fd);
}
- if (__IMPL(stream)->buf) {
- free(__IMPL(stream)->buf);
+ if (__FILE(stream)->buf) {
+ free(__FILE(stream)->buf);
}
if (stream != stdout && stream != stderr && stream != stdin) {
diff --git a/lib/libc/stdlib/free.c b/lib/libc/stdlib/free.c
index 40320dc7..e08b0170 100644
--- a/lib/libc/stdlib/free.c
+++ b/lib/libc/stdlib/free.c
@@ -1,9 +1,10 @@
-#include <libc.h>
-#include <sys/mman.h>
-#include <atomic.h>
-#include <malloc.h>
-#include <stdint.h>
-#include <stdbool.h>
+#include <atomic.h> // for LIBC_UNLOCK, LIBC_LOCK
+#include <libc.h> // for (anonymous struct)::(anonymous), (anonymous)
+#include <malloc.h> // for page, page::(anonymous), __malloc_pvec, LARGE_...
+#include <stddef.h> // for NULL
+#include <stdint.h> // for uintptr_t
+#include <stdlib.h> // for free
+#include <sys/mman.h> // for size_t, munmap
void free(void *ptr)
{
diff --git a/lib/libc/stdlib/getenv.c b/lib/libc/stdlib/getenv.c
index deb2b5f7..17975574 100644
--- a/lib/libc/stdlib/getenv.c
+++ b/lib/libc/stdlib/getenv.c
@@ -1,6 +1,7 @@
-#include <libc.h>
-#include <stddef.h>
-#include <atomic.h>
+#include <atomic.h> // for LIBC_UNLOCK, LIBC_LOCK
+#include <libc.h> // for (anonymous struct)::(anonymous), (anonymous), libc
+#include <stddef.h> // for NULL
+#include <stdlib.h> // for getenv, secure_getenv
extern char **environ;
diff --git a/lib/libc/stdlib/heapsort.c b/lib/libc/stdlib/heapsort.c
index 101720bb..20922f12 100644
--- a/lib/libc/stdlib/heapsort.c
+++ b/lib/libc/stdlib/heapsort.c
@@ -30,8 +30,8 @@
* SUCH DAMAGE.
*/
-#include <stddef.h>
-#include <stdlib.h>
+#include <stddef.h> // for NULL
+#include <stdlib.h> // for size_t, free, malloc
/*
* Swap two areas of size number of bytes. Although qsort(3) permits random
@@ -40,25 +40,25 @@
* isn't worth optimizing; the SWAP's get sped up by the cache, and pointer
* arithmetic gets lost in the time required for comparison function calls.
*/
-#define SWAP(a, b, count, size, tmp) \
- { \
- count = size; \
- do { \
- tmp = *a; \
- *a++ = *b; \
- *b++ = tmp; \
- } while (--count); \
+#define SWAP(a, b, count, size, tmp) \
+ { \
+ (count) = size; \
+ do { \
+ (tmp) = *(a); \
+ *(a)++ = *(b); \
+ *(b)++ = tmp; \
+ } while (--(count)); \
}
/* Copy one block of size size to another. */
-#define COPY(a, b, count, size, tmp1, tmp2) \
- { \
- count = size; \
- tmp1 = a; \
- tmp2 = b; \
- do { \
- *tmp1++ = *tmp2++; \
- } while (--count); \
+#define COPY(a, b, count, size, tmp1, tmp2) \
+ { \
+ (count) = size; \
+ (tmp1) = a; \
+ (tmp2) = b; \
+ do { \
+ *(tmp1)++ = *(tmp2)++; \
+ } while (--(count)); \
}
/*
@@ -68,21 +68,21 @@
* There two cases. If j == nmemb, select largest of Ki and Kj. If
* j < nmemb, select largest of Ki, Kj and Kj+1.
*/
-#define CREATE(initval, nmemb, par_i, child_i, par, child, size, count, tmp) \
- { \
- for (par_i = initval; (child_i = par_i * 2) <= nmemb; \
- par_i = child_i) { \
- child = base + child_i * size; \
- if (child_i < nmemb && \
- compar(child, child + size) < 0) { \
- child += size; \
- ++child_i; \
- } \
- par = base + par_i * size; \
- if (compar(child, par) <= 0) \
- break; \
- SWAP(par, child, count, size, tmp); \
- } \
+#define CREATE(initval, nmemb, par_i, child_i, par, child, size, count, tmp) \
+ { \
+ for ((par_i) = initval; ((child_i) = (par_i) * 2) <= (nmemb); \
+ (par_i) = (child_i)) { \
+ (child) = base + (child_i) * (size); \
+ if ((child_i) < (nmemb) && \
+ compar(child, (child) + (size)) < 0) { \
+ (child) += (size); \
+ ++(child_i); \
+ } \
+ (par) = base + (par_i) * (size); \
+ if (compar(child, par) <= 0) \
+ break; \
+ SWAP(par, child, count, size, tmp); \
+ } \
}
/*
@@ -104,23 +104,23 @@
*/
#define SELECT(par_i, child_i, nmemb, par, child, size, k, count, tmp1, tmp2) \
{ \
- for (par_i = 1; (child_i = par_i * 2) <= nmemb; \
- par_i = child_i) { \
- child = base + child_i * size; \
- if (child_i < nmemb && \
- compar(child, child + size) < 0) { \
- child += size; \
- ++child_i; \
+ for ((par_i) = 1; ((child_i) = (par_i) * 2) <= (nmemb); \
+ (par_i) = (child_i)) { \
+ (child) = base + (child_i) * (size); \
+ if ((child_i) < (nmemb) && \
+ compar(child, (child) + (size)) < 0) { \
+ (child) += (size); \
+ ++(child_i); \
} \
- par = base + par_i * size; \
+ (par) = base + (par_i) * (size); \
COPY(par, child, count, size, tmp1, tmp2); \
} \
for (;;) { \
- child_i = par_i; \
- par_i = child_i / 2; \
- child = base + child_i * size; \
- par = base + par_i * size; \
- if (child_i == 1 || compar(k, par) < 0) { \
+ (child_i) = par_i; \
+ (par_i) = (child_i) / 2; \
+ (child) = base + (child_i) * (size); \
+ (par) = base + (par_i) * (size); \
+ if ((child_i) == 1 || compar(k, par) < 0) { \
COPY(child, k, count, size, tmp1, tmp2); \
break; \
} \
diff --git a/lib/libc/stdlib/heapsort_r.c b/lib/libc/stdlib/heapsort_r.c
index 645f63b0..05c6e3ae 100644
--- a/lib/libc/stdlib/heapsort_r.c
+++ b/lib/libc/stdlib/heapsort_r.c
@@ -30,8 +30,8 @@
* SUCH DAMAGE.
*/
-#include <stddef.h>
-#include <stdlib.h>
+#include <stddef.h> // for NULL
+#include <stdlib.h> // for size_t, free, malloc
/*
* Swap two areas of size number of bytes. Although qsort(3) permits random
@@ -40,25 +40,25 @@
* isn't worth optimizing; the SWAP's get sped up by the cache, and pointer
* arithmetic gets lost in the time required for comparison function calls.
*/
-#define SWAP(a, b, count, size, tmp) \
- { \
- count = size; \
- do { \
- tmp = *a; \
- *a++ = *b; \
- *b++ = tmp; \
- } while (--count); \
+#define SWAP(a, b, count, size, tmp) \
+ { \
+ (count) = size; \
+ do { \
+ (tmp) = *(a); \
+ *(a)++ = *(b); \
+ *(b)++ = tmp; \
+ } while (--(count)); \
}
/* Copy one block of size size to another. */
-#define COPY(a, b, count, size, tmp1, tmp2) \
- { \
- count = size; \
- tmp1 = a; \
- tmp2 = b; \
- do { \
- *tmp1++ = *tmp2++; \
- } while (--count); \
+#define COPY(a, b, count, size, tmp1, tmp2) \
+ { \
+ (count) = size; \
+ (tmp1) = a; \
+ (tmp2) = b; \
+ do { \
+ *(tmp1)++ = *(tmp2)++; \
+ } while (--(count)); \
}
/*
@@ -68,21 +68,21 @@
* There two cases. If j == nmemb, select largest of Ki and Kj. If
* j < nmemb, select largest of Ki, Kj and Kj+1.
*/
-#define CREATE(initval, nmemb, par_i, child_i, par, child, size, count, tmp) \
- { \
- for (par_i = initval; (child_i = par_i * 2) <= nmemb; \
- par_i = child_i) { \
- child = base + child_i * size; \
- if (child_i < nmemb && \
- compar(thunk, child, child + size) < 0) { \
- child += size; \
- ++child_i; \
- } \
- par = base + par_i * size; \
- if (compar(thunk, child, par) <= 0) \
- break; \
- SWAP(par, child, count, size, tmp); \
- } \
+#define CREATE(initval, nmemb, par_i, child_i, par, child, size, count, tmp) \
+ { \
+ for ((par_i) = initval; ((child_i) = (par_i) * 2) <= (nmemb); \
+ (par_i) = (child_i)) { \
+ (child) = base + (child_i) * (size); \
+ if ((child_i) < (nmemb) && \
+ compar(thunk, child, (child) + (size)) < 0) { \
+ (child) += (size); \
+ ++(child_i); \
+ } \
+ (par) = base + (par_i) * (size); \
+ if (compar(thunk, child, par) <= 0) \
+ break; \
+ SWAP(par, child, count, size, tmp); \
+ } \
}
/*
@@ -104,23 +104,23 @@
*/
#define SELECT(par_i, child_i, nmemb, par, child, size, k, count, tmp1, tmp2) \
{ \
- for (par_i = 1; (child_i = par_i * 2) <= nmemb; \
- par_i = child_i) { \
- child = base + child_i * size; \
- if (child_i < nmemb && \
- compar(thunk, child, child + size) < 0) { \
- child += size; \
- ++child_i; \
+ for ((par_i) = 1; ((child_i) = (par_i) * 2) <= (nmemb); \
+ (par_i) = (child_i)) { \
+ (child) = base + (child_i) * (size); \
+ if ((child_i) < (nmemb) && \
+ compar(thunk, child, (child) + (size)) < 0) { \
+ (child) += (size); \
+ ++(child_i); \
} \
- par = base + par_i * size; \
+ (par) = base + (par_i) * (size); \
COPY(par, child, count, size, tmp1, tmp2); \
} \
for (;;) { \
- child_i = par_i; \
- par_i = child_i / 2; \
- child = base + child_i * size; \
- par = base + par_i * size; \
- if (child_i == 1 || compar(thunk, k, par) < 0) { \
+ (child_i) = par_i; \
+ (par_i) = (child_i) / 2; \
+ (child) = base + (child_i) * (size); \
+ (par) = base + (par_i) * (size); \
+ if ((child_i) == 1 || compar(thunk, k, par) < 0) { \
COPY(child, k, count, size, tmp1, tmp2); \
break; \
} \
diff --git a/lib/libc/stdlib/labs.c b/lib/libc/stdlib/labs.c
index 1413af3a..3b34c7e1 100644
--- a/lib/libc/stdlib/labs.c
+++ b/lib/libc/stdlib/labs.c
@@ -1,4 +1,4 @@
-#include <stdlib.h>
+#include <stdlib.h> // for labs
long labs(long i)
{
diff --git a/lib/libc/stdlib/ldiv.c b/lib/libc/stdlib/ldiv.c
index 9fc62b8d..e1fcdf50 100644
--- a/lib/libc/stdlib/ldiv.c
+++ b/lib/libc/stdlib/ldiv.c
@@ -1,4 +1,4 @@
-#include <stdlib.h>
+#include <stdlib.h> // for ldiv_t, ldiv
ldiv_t ldiv(long numer, long denom)
{
diff --git a/lib/libc/stdlib/llabs.c b/lib/libc/stdlib/llabs.c
index 1fadcb98..8cd4cc66 100644
--- a/lib/libc/stdlib/llabs.c
+++ b/lib/libc/stdlib/llabs.c
@@ -1,4 +1,4 @@
-#include <stdlib.h>
+#include <stdlib.h> // for llabs
long long llabs(long long i)
{
diff --git a/lib/libc/stdlib/lldiv.c b/lib/libc/stdlib/lldiv.c
index 6df419b3..0b962974 100644
--- a/lib/libc/stdlib/lldiv.c
+++ b/lib/libc/stdlib/lldiv.c
@@ -1,4 +1,4 @@
-#include <stdlib.h>
+#include <stdlib.h> // for lldiv_t, lldiv
lldiv_t lldiv(long long numer, long long denom)
{
diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c
index 555a45bc..344c9623 100644
--- a/lib/libc/stdlib/malloc.c
+++ b/lib/libc/stdlib/malloc.c
@@ -1,13 +1,14 @@
-#include <atomic.h>
-#include <features.h>
-#include <libc.h>
-#include <malloc.h>
-#include <linux/errno.h>
-#include <stdatomic.h>
-#include <stdint.h>
-#include <string.h>
-#include <sys/mman.h>
-#include <unistd.h>
+#include "stddef.h" // for NULL
+
+#include <atomic.h> // for LIBC_UNLOCK, LIBC_LOCK
+#include <features.h> // for __weak
+#include <libc.h> // for (anonymous struct)::(anonymous), (anonymous)
+#include <malloc.h> // for page, page::(anonymous), class, global_size_c...
+#include <stdatomic.h> // for atomic_flag_clear
+#include <stdint.h> // for uint32_t, uint8_t, uintptr_t
+#include <stdlib.h> // for malloc
+#include <string.h> // for memset
+#include <sys/mman.h> // for size_t, mmap, munmap, MAP_ANONYMOUS, MAP_FAILED
struct page *__malloc_pvec = NULL;
diff --git a/lib/libc/stdlib/posix_memalign.c b/lib/libc/stdlib/posix_memalign.c
index a7cbd2a2..f76e63fe 100644
--- a/lib/libc/stdlib/posix_memalign.c
+++ b/lib/libc/stdlib/posix_memalign.c
@@ -1,5 +1,7 @@
-#include <errno.h>
-#include <stdlib.h>
+#include "stddef.h" // for NULL
+
+#include <errno.h> // for EINVAL, ENOMEM
+#include <stdlib.h> // for size_t, aligned_alloc, posix_memalign
int posix_memalign(void **memptr, size_t alignment, size_t size)
{
diff --git a/lib/libc/stdlib/putenv.c b/lib/libc/stdlib/putenv.c
index b070cc4d..a3649982 100644
--- a/lib/libc/stdlib/putenv.c
+++ b/lib/libc/stdlib/putenv.c
@@ -1,5 +1,5 @@
-#include <stdlib.h>
-#include <string.h>
+#include <stdlib.h> // for setenv, unsetenv, putenv
+#include <string.h> // for memcpy, strchr
int putenv(char *string)
{
diff --git a/lib/libc/stdlib/qsort.c b/lib/libc/stdlib/qsort.c
index 896c79a1..ab0256a5 100644
--- a/lib/libc/stdlib/qsort.c
+++ b/lib/libc/stdlib/qsort.c
@@ -1,4 +1,4 @@
-#include <stdlib.h>
+#include <stdlib.h> // for qsort_r, size_t, qsort
static int wrapper(const void *a, const void *b, void *compar)
{
diff --git a/lib/libc/stdlib/qsort_r.c b/lib/libc/stdlib/qsort_r.c
index 646eeaff..25a3aa81 100644
--- a/lib/libc/stdlib/qsort_r.c
+++ b/lib/libc/stdlib/qsort_r.c
@@ -25,9 +25,11 @@
Run time: Worst case O(n log n), close to O(n) in the
mostly-sorted case. */
+#include "stddef.h" // for NULL
+
#define _BSD_SOURCE
-#include <stdlib.h>
-#include <string.h>
+#include <stdlib.h> // for qsort_r
+#include <string.h> // for size_t, memcpy
#define ntz(x) __builtin_ctzl((x))
diff --git a/lib/libc/stdlib/quick_exit.c b/lib/libc/stdlib/quick_exit.c
index 15587d17..c940c20c 100644
--- a/lib/libc/stdlib/quick_exit.c
+++ b/lib/libc/stdlib/quick_exit.c
@@ -1,4 +1,4 @@
-#include <stdlib.h>
+#include <stdlib.h> // for _Exit, quick_exit
_Noreturn void quick_exit(int status)
{
diff --git a/lib/libc/stdlib/rand.c b/lib/libc/stdlib/rand.c
index 878aa0e2..2fa5a3d0 100644
--- a/lib/libc/stdlib/rand.c
+++ b/lib/libc/stdlib/rand.c
@@ -15,8 +15,8 @@ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
-#include <stdlib.h>
-#include <stdint.h>
+#include <stdint.h> // for uint64_t
+#include <stdlib.h> // for RAND_MAX, drand48, erand48, jrand48, lrand48
#define UINT64_C(c) ((uint64_t)(c##ULL))
diff --git a/lib/libc/stdlib/realloc.c b/lib/libc/stdlib/realloc.c
index d90af70d..4722ac5e 100644
--- a/lib/libc/stdlib/realloc.c
+++ b/lib/libc/stdlib/realloc.c
@@ -1,10 +1,12 @@
-#include <errno.h>
-#include <string.h>
-#include <atomic.h>
-#include <libc.h>
-#include <malloc.h>
-#include <linux/errno.h>
-#include <stdlib.h>
+#include "stddef.h" // for NULL
+
+#include <atomic.h> // for LIBC_UNLOCK, LIBC_LOCK
+#include <errno.h> // for EINVAL, errno
+#include <libc.h> // for (anonymous struct)::(anonymous), (anonymous), libc
+#include <malloc.h> // for page, page::(anonymous), __malloc_pvec
+#include <stdint.h> // for uintptr_t
+#include <stdlib.h> // for free, malloc, realloc
+#include <string.h> // for memcpy, size_t
void *realloc(void *ptr, size_t size)
{
@@ -28,14 +30,13 @@ void *realloc(void *ptr, size_t size)
if (size <= old_size) {
return ptr;
- } else {
- void *new_ptr = malloc(size);
- if (new_ptr) {
- memcpy(new_ptr, ptr, old_size);
- free(ptr);
- }
- return new_ptr;
}
+ void *new_ptr = malloc(size);
+ if (new_ptr) {
+ memcpy(new_ptr, ptr, old_size);
+ free(ptr);
+ }
+ return new_ptr;
}
p = p->next;
}
diff --git a/lib/libc/stdlib/reallocarray.c b/lib/libc/stdlib/reallocarray.c
index 4dd1a6c8..0626f8ac 100644
--- a/lib/libc/stdlib/reallocarray.c
+++ b/lib/libc/stdlib/reallocarray.c
@@ -1,7 +1,7 @@
-#include <stdlib.h>
-#include <errno.h>
-#include <linux/errno.h>
-#include <malloc.h>
+#include "stddef.h" // for NULL
+
+#include <errno.h> // for ENOMEM, errno
+#include <stdlib.h> // for size_t, realloc, reallocarray
void *reallocarray(void *ptr, size_t nmemb, size_t size)
{
diff --git a/lib/libc/stdlib/setenv.c b/lib/libc/stdlib/setenv.c
index 1464fc1b..004a29bd 100644
--- a/lib/libc/stdlib/setenv.c
+++ b/lib/libc/stdlib/setenv.c
@@ -1,7 +1,9 @@
-#include <libc.h>
-#include <atomic.h>
-#include <stdlib.h>
-#include <string.h>
+#include "stddef.h" // for NULL
+
+#include <atomic.h> // for LIBC_LOCK, LIBC_UNLOCK
+#include <libc.h> // for (anonymous), libc, (anonymous struct)::(anonymous)
+#include <stdlib.h> // for malloc, realloc, setenv
+#include <string.h> // for strlen, size_t, memcpy, strcpy, strchr, strncmp
extern char **environ;
@@ -20,7 +22,7 @@ int setenv(const char *var, const char *value, int overwrite)
malloc(var_len + 1 + value_len + 1);
if (!new_env)
return -1;
- memcpy(new_env, var, var_len);
+ strcpy(new_env, var);
new_env[var_len] = '=';
memcpy(new_env + var_len + 1, value,
value_len + 1);
@@ -34,7 +36,8 @@ int setenv(const char *var, const char *value, int overwrite)
while (environ[env_count])
env_count++;
- char **new_envp = realloc(environ, (env_count + 2) * sizeof(char *));
+ char **new_envp = (char **)realloc((void *)environ,
+ (env_count + 2) * sizeof(char *));
if (!new_envp)
return -1;
@@ -43,7 +46,7 @@ int setenv(const char *var, const char *value, int overwrite)
if (!new_var)
return -1;
- memcpy(new_var, var, var_len);
+ strcpy(new_var, var);
new_var[var_len] = '=';
memcpy(new_var + var_len + 1, value, value_len + 1);
diff --git a/lib/libc/stdlib/strtox.c b/lib/libc/stdlib/strtox.c
index e924e5e6..b50a77a1 100644
--- a/lib/libc/stdlib/strtox.c
+++ b/lib/libc/stdlib/strtox.c
@@ -1,10 +1,10 @@
-#include <ctype.h>
-#include <float.h>
-#include <errno.h>
-#include <strings.h>
-#include <limits.h>
-#include <math.h>
-#include <stdlib.h>
+#include <ctype.h> // for isdigit, isspace, isalnum, isalpha, toupper
+#include <errno.h> // for errno, ERANGE, EINVAL
+#include <float.h> // for LDBL_MAX, FLT_MAX
+#include <limits.h> // for LLONG_MAX, LONG_MAX, ULLONG_MAX, ULONG_MAX, LLO...
+#include <math.h> // for HUGE_VALF, powl, INFINITY, NAN
+#include <stdlib.h> // for strtof, strtol, strtold, strtoll, strtoul, strt...
+#include <strings.h> // for strncasecmp
static unsigned long long
__scanint(const char *s, int base, unsigned long long lim, int *neg, char **end)
@@ -163,8 +163,7 @@ long strtol(const char *restrict nptr, char **restrict endptr, int base)
if (neg)
return (v == lim) ? LONG_MIN : -(long)v;
- else
- return (v > LONG_MAX) ? (errno = ERANGE, LONG_MAX) : (long)v;
+ return (v > LONG_MAX) ? (errno = ERANGE, LONG_MAX) : (long)v;
}
long long strtoll(const char *restrict nptr, char **restrict endptr, int base)
@@ -185,15 +184,13 @@ long long strtoll(const char *restrict nptr, char **restrict endptr, int base)
if (neg) {
if (v == lim)
return LLONG_MIN;
- else
- return -(long long)v;
- } else {
- if (v > LLONG_MAX) {
- errno = ERANGE;
- return LLONG_MAX;
- } else
- return (long long)v;
+ return -(long long)v;
+ }
+ if (v > LLONG_MAX) {
+ errno = ERANGE;
+ return LLONG_MAX;
}
+ return (long long)v;
}
unsigned long strtoul(const char *restrict nptr, char **restrict endptr,
@@ -245,7 +242,8 @@ float strtof(const char *restrict nptr, char **restrict endptr)
if (val > FLT_MAX) {
errno = ERANGE;
return HUGE_VALF;
- } else if (val < -FLT_MAX) {
+ }
+ if (val < -FLT_MAX) {
errno = ERANGE;
return -HUGE_VALF;
}
@@ -260,7 +258,8 @@ long double strtold(const char *restrict nptr, char **restrict endptr)
if (val > LDBL_MAX) {
errno = ERANGE;
return LDBL_MAX;
- } else if (val < -LDBL_MAX) {
+ }
+ if (val < -LDBL_MAX) {
errno = ERANGE;
return -LDBL_MAX;
}
diff --git a/lib/libc/stdlib/system.c b/lib/libc/stdlib/system.c
index 95f8d732..224493dc 100644
--- a/lib/libc/stdlib/system.c
+++ b/lib/libc/stdlib/system.c
@@ -1,4 +1,4 @@
-#include <stdlib.h>
+#include <stdlib.h> // for system
int system(const char *command)
{
diff --git a/lib/libc/stdlib/unsetenv.c b/lib/libc/stdlib/unsetenv.c
index 4eb11d57..bce55e97 100644
--- a/lib/libc/stdlib/unsetenv.c
+++ b/lib/libc/stdlib/unsetenv.c
@@ -1,6 +1,8 @@
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
+#include "stddef.h" // for NULL
+
+#include <errno.h> // for EINVAL, errno
+#include <stdlib.h> // for setenv, unsetenv
+#include <string.h> // for strchr
int unsetenv(const char *name)
{
diff --git a/lib/libc/stdlib/wctomb.c b/lib/libc/stdlib/wctomb.c
index d971ffae..8c66b2c2 100644
--- a/lib/libc/stdlib/wctomb.c
+++ b/lib/libc/stdlib/wctomb.c
@@ -1,3 +1,4 @@
+#include "stddef.h"
#include <stdlib.h>
#include <wchar.h>
diff --git a/lib/libc/string/memchr.c b/lib/libc/string/memchr.c
index 230e042f..f13a2a2c 100644
--- a/lib/libc/string/memchr.c
+++ b/lib/libc/string/memchr.c
@@ -1,4 +1,5 @@
-#include <stddef.h> // for NULL, size_t
+#include <stddef.h> // for NULL
+#include <string.h> // for memchr, size_t
void *memchr(const void *s, int c, size_t n)
{
diff --git a/lib/libc/string/memcmp.c b/lib/libc/string/memcmp.c
index da1766c4..23a18392 100644
--- a/lib/libc/string/memcmp.c
+++ b/lib/libc/string/memcmp.c
@@ -1,4 +1,4 @@
-#include <stddef.h> // for size_t
+#include <string.h> // for memcmp, size_t
int memcmp(const void *s1, const void *s2, size_t n)
{
diff --git a/lib/libc/string/memcpy.c b/lib/libc/string/memcpy.c
index 8af4577c..46e24e42 100644
--- a/lib/libc/string/memcpy.c
+++ b/lib/libc/string/memcpy.c
@@ -1,6 +1,7 @@
#include <errno.h> // for EINVAL, ERANGE
#include <features.h> // for __weak
-#include <string.h> // for rsize_t, NULL, memcpy, size_t, errno_t, memcpy_s
+#include <stddef.h> // for NULL, errno_t
+#include <string.h> // for rsize_t, memcpy, size_t, memcpy_s
__weak void *memcpy(void *restrict s1, const void *restrict s2, size_t n);
diff --git a/lib/libc/string/memmem.c b/lib/libc/string/memmem.c
index b30a700a..4f55cf41 100644
--- a/lib/libc/string/memmem.c
+++ b/lib/libc/string/memmem.c
@@ -1,4 +1,6 @@
-#include <string.h> // for memcmp, size_t, NULL, memmem
+#include "stddef.h" // for NULL
+
+#include <string.h> // for memcmp, size_t, memmem
void *memmem(const void *haystack, size_t haystacklen, const void *needle,
size_t needlelen)
diff --git a/lib/libc/string/memmove.c b/lib/libc/string/memmove.c
index db83694f..c4fe3635 100644
--- a/lib/libc/string/memmove.c
+++ b/lib/libc/string/memmove.c
@@ -1,5 +1,5 @@
-#include <stddef.h> // for size_t
#include <stdint.h> // for uint8_t, uintptr_t
+#include <string.h> // for size_t, memmove
void *memmove(void *dst, const void *src, size_t n)
{
diff --git a/lib/libc/string/stpncpy.c b/lib/libc/string/stpncpy.c
index 1afa59fc..331e8dc7 100644
--- a/lib/libc/string/stpncpy.c
+++ b/lib/libc/string/stpncpy.c
@@ -1,4 +1,4 @@
-#include <stddef.h> // for size_t
+#include <string.h> // for strncpy, size_t
char *strncpy(char *restrict s1, const char *restrict s2, size_t n)
{
diff --git a/lib/libc/string/strcat.c b/lib/libc/string/strcat.c
index 6caf8c78..f7267f00 100644
--- a/lib/libc/string/strcat.c
+++ b/lib/libc/string/strcat.c
@@ -1,3 +1,5 @@
+#include <string.h> // for strcat
+
char *strcat(char *restrict s1, const char *restrict s2)
{
char *d = s1;
diff --git a/lib/libc/string/strchr.c b/lib/libc/string/strchr.c
index 06fb51bc..01b2589a 100644
--- a/lib/libc/string/strchr.c
+++ b/lib/libc/string/strchr.c
@@ -1,4 +1,6 @@
-#include <string.h> // for strchr, NULL
+#include "stddef.h" // for NULL
+
+#include <string.h> // for strchr
char *strchr(const char *s, int c)
{
diff --git a/lib/libc/string/strcmp.c b/lib/libc/string/strcmp.c
index e3e5ca03..698aba62 100644
--- a/lib/libc/string/strcmp.c
+++ b/lib/libc/string/strcmp.c
@@ -1,4 +1,5 @@
#include <stddef.h> // for NULL
+#include <string.h> // for strcmp
int strcmp(const char *s1, const char *s2)
{
diff --git a/lib/libc/string/strcoll.c b/lib/libc/string/strcoll.c
index 7a1502f0..e862bb11 100644
--- a/lib/libc/string/strcoll.c
+++ b/lib/libc/string/strcoll.c
@@ -1,8 +1,7 @@
#include "features.h" // for __weak
#include <libc.h> // for __unused
-#include <locale.h> // for locale_t
-#include <string.h> // for strcmp, strcoll, strcoll_l
+#include <string.h> // for strcmp, locale_t, strcoll, strcoll_l
int strcoll(const char *s1, const char *s2)
{
diff --git a/lib/libc/string/strcpy.c b/lib/libc/string/strcpy.c
index 8e1dab69..eef2a5e4 100644
--- a/lib/libc/string/strcpy.c
+++ b/lib/libc/string/strcpy.c
@@ -1,3 +1,5 @@
+#include <string.h> // for strcpy
+
char *strcpy(char *restrict s1, const char *restrict s2)
{
char *p = s1;
diff --git a/lib/libc/string/strcspn.c b/lib/libc/string/strcspn.c
index 4efb38ae..bc377586 100644
--- a/lib/libc/string/strcspn.c
+++ b/lib/libc/string/strcspn.c
@@ -1,4 +1,6 @@
-#include <string.h> // for size_t, strchr, strcspn, NULL
+#include "stddef.h" // for NULL
+
+#include <string.h> // for size_t, strchr, strcspn
size_t strcspn(const char *s1, const char *s2)
{
diff --git a/lib/libc/string/strdup.c b/lib/libc/string/strdup.c
index 97b5d712..198b62cc 100644
--- a/lib/libc/string/strdup.c
+++ b/lib/libc/string/strdup.c
@@ -1,4 +1,6 @@
-#include <stdlib.h> // for NULL, malloc
+#include "stddef.h" // for NULL
+
+#include <stdlib.h> // for malloc
#include <string.h> // for memcpy, strlen, size_t, strdup
char *strdup(const char *s)
diff --git a/lib/libc/string/strerror.c b/lib/libc/string/strerror.c
index e7800d08..c0a73146 100644
--- a/lib/libc/string/strerror.c
+++ b/lib/libc/string/strerror.c
@@ -1,10 +1,8 @@
-#include "__stdio.h" // for size_t
#include "features.h" // for __weak
#include <errno.h> // for ERANGE, E2BIG, EACCES, EADDRINUSE, EADDRNOTAVAIL
#include <libc.h> // for __unused
-#include <locale.h> // for locale_t
-#include <string.h> // for memcpy, strerror, strlen, strerror_l, strerror_r
+#include <string.h> // for memcpy, size_t, strerror, strlen, locale_t
char *strerror(int errnum)
{
diff --git a/lib/libc/string/strlen.c b/lib/libc/string/strlen.c
index 6371b588..a7e30a49 100644
--- a/lib/libc/string/strlen.c
+++ b/lib/libc/string/strlen.c
@@ -1,4 +1,5 @@
-#include <stddef.h> // for size_t, NULL
+#include <stddef.h> // for NULL
+#include <string.h> // for size_t, strlen
size_t strlen(const char *str)
{
diff --git a/lib/libc/string/strncmp.c b/lib/libc/string/strncmp.c
index 1675890a..8290a95c 100644
--- a/lib/libc/string/strncmp.c
+++ b/lib/libc/string/strncmp.c
@@ -1,4 +1,4 @@
-#include <stddef.h> // for size_t
+#include <string.h> // for strncmp, size_t
int strncmp(const char *s1, const char *s2, size_t n)
{
diff --git a/lib/libc/string/strncpy.c b/lib/libc/string/strncpy.c
index b0541b44..720591ea 100644
--- a/lib/libc/string/strncpy.c
+++ b/lib/libc/string/strncpy.c
@@ -1,4 +1,4 @@
-#include <stddef.h> // for size_t
+#include <string.h> // for strncpy, size_t
char *strncpy(char *restrict s1, const char *restrict s2, size_t n)
{
diff --git a/lib/libc/string/strndup.c b/lib/libc/string/strndup.c
index 318561ca..18d1a718 100644
--- a/lib/libc/string/strndup.c
+++ b/lib/libc/string/strndup.c
@@ -1,4 +1,6 @@
-#include <stdlib.h> // for NULL, malloc
+#include "stddef.h" // for NULL
+
+#include <stdlib.h> // for malloc
#include <string.h> // for memcpy, size_t, strndup
char *strndup(const char *s, size_t size)
diff --git a/lib/libc/string/strpbrk.c b/lib/libc/string/strpbrk.c
index a03bb31a..d46019b6 100644
--- a/lib/libc/string/strpbrk.c
+++ b/lib/libc/string/strpbrk.c
@@ -1,4 +1,5 @@
#include <stddef.h> // for NULL
+#include <string.h> // for strpbrk
char *strpbrk(const char *s1, const char *s2)
{
diff --git a/lib/libc/string/strrchr.c b/lib/libc/string/strrchr.c
index 5d66035e..863e5ca0 100644
--- a/lib/libc/string/strrchr.c
+++ b/lib/libc/string/strrchr.c
@@ -1,4 +1,5 @@
#include <stddef.h> // for NULL
+#include <string.h> // for strrchr
char *strrchr(const char *s, int c)
{
diff --git a/lib/libc/string/strspn.c b/lib/libc/string/strspn.c
index 3b7036cc..afbfabe8 100644
--- a/lib/libc/string/strspn.c
+++ b/lib/libc/string/strspn.c
@@ -1,4 +1,6 @@
-#include <string.h> // for size_t, strchr, strspn, NULL
+#include "stddef.h" // for NULL
+
+#include <string.h> // for size_t, strchr, strspn
size_t strspn(const char *s1, const char *s2)
{
diff --git a/lib/libc/string/strstr.c b/lib/libc/string/strstr.c
index 1c35e826..d0c53b1b 100644
--- a/lib/libc/string/strstr.c
+++ b/lib/libc/string/strstr.c
@@ -1,4 +1,5 @@
#include <stddef.h> // for NULL
+#include <string.h> // for strstr
char *strstr(const char *s1, const char *s2)
{
diff --git a/lib/libc/string/strtok.c b/lib/libc/string/strtok.c
index 918765b1..a2cbb417 100644
--- a/lib/libc/string/strtok.c
+++ b/lib/libc/string/strtok.c
@@ -1,4 +1,6 @@
-#include <string.h> // for NULL, strchr, strtok
+#include "stddef.h" // for NULL
+
+#include <string.h> // for strchr, strtok
char *strtok(char *restrict s, const char *restrict sep)
{
diff --git a/lib/libc/string/strtok_r.c b/lib/libc/string/strtok_r.c
index ee3fc243..274f6f08 100644
--- a/lib/libc/string/strtok_r.c
+++ b/lib/libc/string/strtok_r.c
@@ -1,4 +1,6 @@
-#include <string.h> // for NULL, strchr, strtok_r
+#include "stddef.h" // for NULL
+
+#include <string.h> // for strchr, strtok_r
char *strtok_r(char *restrict s, const char *restrict sep,
char **restrict state)
diff --git a/lib/libc/string/strxfrm.c b/lib/libc/string/strxfrm.c
index 947a4331..ae51f984 100644
--- a/lib/libc/string/strxfrm.c
+++ b/lib/libc/string/strxfrm.c
@@ -1,9 +1,7 @@
-#include "__stdio.h" // for size_t
#include "features.h" // for __weak
#include <libc.h> // for __unused
-#include <locale.h> // for locale_t
-#include <string.h> // for strlcpy, strlen, strxfrm, strxfrm_l
+#include <string.h> // for size_t, strlcpy, strlen, strxfrm, locale_t
size_t strxfrm(char *restrict s1, const char *restrict s2, size_t n)
{
diff --git a/lib/libc/strings/strncasecmp.c b/lib/libc/strings/strncasecmp.c
index 12ae0fae..0c46d27f 100644
--- a/lib/libc/strings/strncasecmp.c
+++ b/lib/libc/strings/strncasecmp.c
@@ -1,9 +1,9 @@
-#include "__stdio.h" // for size_t
#include "features.h" // for __weak
#include <ctype.h> // for tolower
#include <libc.h> // for __unused
#include <locale.h> // for locale_t
+#include <stddef.h> // for size_t
int strncasecmp(const char *s1, const char *s2, size_t n)
{
diff --git a/lib/libc/sys/ioctl.c b/lib/libc/sys/ioctl.c
index 45fbdca7..0b9c3b82 100644
--- a/lib/libc/sys/ioctl.c
+++ b/lib/libc/sys/ioctl.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_ioctl
+
+
#include <stdarg.h> // for va_arg, va_end, va_list, va_start
#include <syscall.h> // for __syscall_3, syscall
diff --git a/lib/libc/sys/mount.c b/lib/libc/sys/mount.c
index 4ef617b9..c42dc90e 100644
--- a/lib/libc/sys/mount.c
+++ b/lib/libc/sys/mount.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_mount
+
+
#include <sys/mount.h> // for mount
#include <syscall.h> // for __syscall_5, syscall
diff --git a/lib/libc/sys/umount.c b/lib/libc/sys/umount.c
index 91ce5a77..ed2b2edc 100644
--- a/lib/libc/sys/umount.c
+++ b/lib/libc/sys/umount.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_umount2
+
+
#include <syscall.h> // for __syscall_2, syscall
diff --git a/lib/libc/sys/umount2.c b/lib/libc/sys/umount2.c
index 12f37f98..17ff73aa 100644
--- a/lib/libc/sys/umount2.c
+++ b/lib/libc/sys/umount2.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_umount2
+
+
#include <syscall.h> // for __syscall_2, syscall
diff --git a/lib/libc/termios/cfgetispeed.c b/lib/libc/termios/cfgetispeed.c
index f06ec65e..e407be7b 100644
--- a/lib/libc/termios/cfgetispeed.c
+++ b/lib/libc/termios/cfgetispeed.c
@@ -1,3 +1,4 @@
+#include "asm-generic/termbits-common.h"
#include <asm-generic/termbits.h>
speed_t cfgetispeed(const struct termios *termios_p)
diff --git a/lib/libc/termios/cfgetospeed.c b/lib/libc/termios/cfgetospeed.c
index e36befc3..c9f6cbd2 100644
--- a/lib/libc/termios/cfgetospeed.c
+++ b/lib/libc/termios/cfgetospeed.c
@@ -1,3 +1,4 @@
+#include "asm-generic/termbits-common.h"
#include <asm-generic/termbits.h>
speed_t cfgetospeed(const struct termios *termios_p)
diff --git a/lib/libc/termios/cfsetispeed.c b/lib/libc/termios/cfsetispeed.c
index b990d598..150973c1 100644
--- a/lib/libc/termios/cfsetispeed.c
+++ b/lib/libc/termios/cfsetispeed.c
@@ -1,5 +1,6 @@
-#include <errno.h>
+#include "asm-generic/termbits-common.h"
#include <asm-generic/termbits.h>
+#include <errno.h>
int cfsetispeed(struct termios *termios_p, speed_t speed)
{
diff --git a/lib/libc/termios/cfsetospeed.c b/lib/libc/termios/cfsetospeed.c
index 3f46b5c4..5f17c04f 100644
--- a/lib/libc/termios/cfsetospeed.c
+++ b/lib/libc/termios/cfsetospeed.c
@@ -1,5 +1,6 @@
-#include <errno.h>
+#include "asm-generic/termbits-common.h"
#include <asm-generic/termbits.h>
+#include <errno.h>
int cfsetospeed(struct termios *termios_p, speed_t speed)
{
diff --git a/lib/libc/termios/tcflush.c b/lib/libc/termios/tcflush.c
index b37b218d..20fbf0ac 100644
--- a/lib/libc/termios/tcflush.c
+++ b/lib/libc/termios/tcflush.c
@@ -1,6 +1,6 @@
-#include <termios.h>
-#include <syscall.h>
#include <asm-generic/ioctls.h>
+#include <syscall.h>
+#include <termios.h>
int tcflush(int fildes, int queue_selector)
{
diff --git a/lib/libc/termios/tcgetattr.c b/lib/libc/termios/tcgetattr.c
index a52eeedf..51830a31 100644
--- a/lib/libc/termios/tcgetattr.c
+++ b/lib/libc/termios/tcgetattr.c
@@ -1,6 +1,6 @@
-#include <termios.h>
-#include <syscall.h>
#include <asm-generic/ioctls.h>
+#include <syscall.h>
+#include <termios.h>
int tcgetattr(int fildes, struct termios *termios_p)
diff --git a/lib/libc/termios/tcgetsid.c b/lib/libc/termios/tcgetsid.c
index 076cf360..c91b7b44 100644
--- a/lib/libc/termios/tcgetsid.c
+++ b/lib/libc/termios/tcgetsid.c
@@ -1,6 +1,6 @@
-#include <termios.h>
-#include <syscall.h>
#include <asm-generic/ioctls.h>
+#include <syscall.h>
+#include <termios.h>
pid_t tcgetsid(int fildes)
{
diff --git a/lib/libc/termios/tcgetwinsize.c b/lib/libc/termios/tcgetwinsize.c
index 2c7c5786..364dae61 100644
--- a/lib/libc/termios/tcgetwinsize.c
+++ b/lib/libc/termios/tcgetwinsize.c
@@ -1,6 +1,6 @@
-#include <termios.h>
-#include <syscall.h>
#include <asm-generic/ioctls.h>
+#include <syscall.h>
+#include <termios.h>
struct __winsize {
unsigned short ws_row;
diff --git a/lib/libc/termios/tcsendbreak.c b/lib/libc/termios/tcsendbreak.c
index 65f1d5b0..a064e7bb 100644
--- a/lib/libc/termios/tcsendbreak.c
+++ b/lib/libc/termios/tcsendbreak.c
@@ -1,7 +1,7 @@
+#include <asm-generic/ioctls.h>
#include <libc.h>
-#include <termios.h>
#include <syscall.h>
-#include <asm-generic/ioctls.h>
+#include <termios.h>
int tcsendbreak(int fildes, int __unused duration)
{
diff --git a/lib/libc/termios/tcsetattr.c b/lib/libc/termios/tcsetattr.c
index a76e77a5..9a70efb6 100644
--- a/lib/libc/termios/tcsetattr.c
+++ b/lib/libc/termios/tcsetattr.c
@@ -1,7 +1,7 @@
-#include <termios.h>
-#include <syscall.h>
#include <asm-generic/ioctls.h>
#include <errno.h>
+#include <syscall.h>
+#include <termios.h>
int tcsetattr(int fildes, int optional_actions, const struct termios *termios_p)
{
diff --git a/lib/libc/termios/tcsetwinsize.c b/lib/libc/termios/tcsetwinsize.c
index 10a705d0..cfdced71 100644
--- a/lib/libc/termios/tcsetwinsize.c
+++ b/lib/libc/termios/tcsetwinsize.c
@@ -1,6 +1,6 @@
-#include <termios.h>
-#include <syscall.h>
#include <asm-generic/ioctls.h>
+#include <syscall.h>
+#include <termios.h>
int tcsetwinsize(int fildes, const struct winsize *winsize_p)
{
diff --git a/lib/libc/thread/thrd_current.c b/lib/libc/thread/thrd_current.c
index adbb4191..86a814da 100644
--- a/lib/libc/thread/thrd_current.c
+++ b/lib/libc/thread/thrd_current.c
@@ -1,6 +1,5 @@
-#include <thread.h>
-#include <threads.h>
-#include <unistd.h>
+#include <__thread.h> // for __thread_self
+#include <threads.h> // for thrd_current, thrd_t
thrd_t thrd_current(void)
{
diff --git a/lib/libc/time/asctime.c b/lib/libc/time/asctime.c
index ab5ff096..0bf76cb2 100644
--- a/lib/libc/time/asctime.c
+++ b/lib/libc/time/asctime.c
@@ -1,5 +1,5 @@
-#include <time.h>
-#include <stdio.h>
+#include <stdio.h> // for snprintf
+#include <time.h> // for tm, asctime
char *asctime(const struct tm *timeptr)
{
diff --git a/lib/libc/time/clock.c b/lib/libc/time/clock.c
index ec2e6084..50cc4a6e 100644
--- a/lib/libc/time/clock.c
+++ b/lib/libc/time/clock.c
@@ -1,5 +1,5 @@
-#include <time.h>
-#include <limits.h>
+#include <limits.h> // for LONG_MAX
+#include <time.h> // for timespec, clock_gettime, CLOCK_PROCESS_CPUTIME_ID
clock_t clock(void)
{
diff --git a/lib/libc/time/clock_getcpuclockid.c b/lib/libc/time/clock_getcpuclockid.c
index 5bb53221..a0f10b8a 100644
--- a/lib/libc/time/clock_getcpuclockid.c
+++ b/lib/libc/time/clock_getcpuclockid.c
@@ -1,5 +1,5 @@
-#include <time.h>
-#include <syscall.h>
+#include <syscall.h> // for __syscall_2, syscall
+#include <time.h> // for clockid_t, clock_getcpuclockid, pid_t
int clock_getcpuclockid(pid_t pid, clockid_t *clock_id)
{
@@ -7,7 +7,7 @@ int clock_getcpuclockid(pid_t pid, clockid_t *clock_id)
clockid_t id;
struct timespec ts;
- id = (-pid - 1) * 8U + 2;
+ id = (clockid_t)((-pid - 1) * 8U + 2);
ret = syscall(clock_getres, id, &ts);
if (ret >= 0) {
diff --git a/lib/libc/time/clock_getres.c b/lib/libc/time/clock_getres.c
index 5af37e8d..9eac94ef 100644
--- a/lib/libc/time/clock_getres.c
+++ b/lib/libc/time/clock_getres.c
@@ -1,5 +1,7 @@
-#include <time.h>
-#include <syscall.h>
+
+
+#include <syscall.h> // for __syscall_2, syscall
+#include <time.h> // for clock_getres, clockid_t
int clock_getres(clockid_t clock_id, struct timespec *res)
{
diff --git a/lib/libc/time/clock_nanosleep.c b/lib/libc/time/clock_nanosleep.c
index 63190d06..0722963f 100644
--- a/lib/libc/time/clock_nanosleep.c
+++ b/lib/libc/time/clock_nanosleep.c
@@ -1,5 +1,7 @@
-#include <time.h>
-#include <syscall.h>
+
+
+#include <syscall.h> // for __syscall, __syscall_4
+#include <time.h> // for clock_nanosleep, clockid_t
int clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *rqtp,
struct timespec *rmtp)
diff --git a/lib/libc/time/ctime.c b/lib/libc/time/ctime.c
index bddd30cf..989ddcfc 100644
--- a/lib/libc/time/ctime.c
+++ b/lib/libc/time/ctime.c
@@ -1,4 +1,4 @@
-#include <time.h>
+#include <time.h> // for asctime, localtime, ctime, time_t
char *ctime(const time_t *clock)
{
diff --git a/lib/libc/time/difftime.c b/lib/libc/time/difftime.c
index e7b567c1..e25e6e15 100644
--- a/lib/libc/time/difftime.c
+++ b/lib/libc/time/difftime.c
@@ -1,6 +1,6 @@
-#include <time.h>
+#include <time.h> // for time_t, difftime
double difftime(time_t time1, time_t time0)
{
- return time1 - time0;
+ return (double)(time1 - time0);
}
diff --git a/lib/libc/time/gmtime_r.c b/lib/libc/time/gmtime_r.c
index 2c741127..47dbd105 100644
--- a/lib/libc/time/gmtime_r.c
+++ b/lib/libc/time/gmtime_r.c
@@ -1,4 +1,4 @@
-#include <time.h>
+#include <time.h> // for tm, time_t, gmtime_r
struct tm *gmtime_r(const time_t *timer, struct tm *result)
{
diff --git a/lib/libc/time/localtime.c b/lib/libc/time/localtime.c
index 44029920..530c0f26 100644
--- a/lib/libc/time/localtime.c
+++ b/lib/libc/time/localtime.c
@@ -1,4 +1,4 @@
-#include <time.h>
+#include <time.h> // for localtime_r, localtime, time_t, tm
struct tm *localtime(const time_t *timer)
{
diff --git a/lib/libc/time/localtime_r.c b/lib/libc/time/localtime_r.c
index 1fb620a4..04c04509 100644
--- a/lib/libc/time/localtime_r.c
+++ b/lib/libc/time/localtime_r.c
@@ -1,4 +1,4 @@
-#include <time.h>
+#include <time.h> // for gmtime_r, time_t, localtime_r, timezone
struct tm *localtime_r(const time_t *restrict timer, struct tm *restrict result)
{
diff --git a/lib/libc/time/nanosleep.c b/lib/libc/time/nanosleep.c
index f5c5f7c9..2d433248 100644
--- a/lib/libc/time/nanosleep.c
+++ b/lib/libc/time/nanosleep.c
@@ -1,5 +1,7 @@
-#include <time.h>
-#include <syscall.h>
+
+
+#include <syscall.h> // for __syscall_2, syscall
+#include <time.h> // for nanosleep
int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
{
diff --git a/lib/libc/time/strftime.c b/lib/libc/time/strftime.c
index 3f54961b..e1078dd8 100644
--- a/lib/libc/time/strftime.c
+++ b/lib/libc/time/strftime.c
@@ -1,6 +1,8 @@
-#include <time.h>
-#include <libc.h>
-#include <string.h>
+#include "features.h" // for __weak
+
+#include <libc.h> // for __unused
+#include <string.h> // for strlcpy, strlen
+#include <time.h> // for tm, size_t, locale_t, strftime, strftime_l
static size_t append_string(char *restrict *s, size_t *remaining,
const char *str)
@@ -34,15 +36,18 @@ static size_t format_int(char *restrict *s, size_t *remaining, int value,
*ptr = '\0';
int negative = 0;
+ unsigned int uvalue;
if (value < 0) {
negative = 1;
- value = -value;
+ uvalue = (unsigned int)(-value);
+ } else {
+ uvalue = (unsigned int)value;
}
do {
- *--ptr = '0' + (value % 10);
- value /= 10;
- } while (value > 0);
+ *--ptr = (char)('0' + (uvalue % 10));
+ uvalue /= 10;
+ } while (uvalue > 0);
if (negative) {
*--ptr = '-';
@@ -50,9 +55,9 @@ static size_t format_int(char *restrict *s, size_t *remaining, int value,
*--ptr = '+';
}
- int len = (buffer + sizeof(buffer) - 1) - ptr;
+ size_t len = (size_t)((buffer + sizeof(buffer) - 1) - ptr);
- while (len < width) {
+ while ((int)len < width) {
*--ptr = pad;
len++;
}
@@ -497,8 +502,8 @@ size_t strftime(char *restrict s, size_t maxsize, const char *restrict format,
sign = '-';
offset = -offset;
}
- int hours = offset / 3600;
- int minutes = (offset % 3600) / 60;
+ int hours = (int)(offset / 3600);
+ int minutes = (int)((offset % 3600) / 60);
if (!append_char(&s, &remaining, sign) ||
!format_int(&s, &remaining, hours, 2, '0', 0) ||
!format_int(&s, &remaining, minutes, 2, '0', 0)) {
diff --git a/lib/libc/time/time.c b/lib/libc/time/time.c
index 134eed7b..3f8848a8 100644
--- a/lib/libc/time/time.c
+++ b/lib/libc/time/time.c
@@ -1,6 +1,5 @@
-#include <time.h>
-#include <asm/vdso.h>
-#include <syscall.h>
+#include <asm/vdso.h> // for __vdso_time
+#include <time.h> // for timespec, clock_gettime, time_t, CLOCK_REALTIME
time_t time(time_t *tloc)
{
diff --git a/lib/libc/time/tzset.c b/lib/libc/time/tzset.c
index 96f33702..eeb1d247 100644
--- a/lib/libc/time/tzset.c
+++ b/lib/libc/time/tzset.c
@@ -1,5 +1,7 @@
-#include <time.h>
-#include <ctype.h>
+#include "stddef.h" // for NULL
+
+#include <ctype.h> // for isdigit
+#include <time.h> // for daylight, timezone, tzname, tzset
int daylight = 0;
long timezone = 0;
diff --git a/lib/libc/time/utimes.c b/lib/libc/time/utimes.c
index 7b928e7a..af644481 100644
--- a/lib/libc/time/utimes.c
+++ b/lib/libc/time/utimes.c
@@ -1,8 +1,9 @@
-#include <fcntl.h>
-#include <errno.h>
-#include <stddef.h>
-#include <sys/stat.h>
-#include <sys/time.h>
+#include <errno.h> // for EINVAL, errno
+#include <fcntl.h> // for AT_FDCWD
+#include <stddef.h> // for NULL
+#include <sys/stat.h> // for utimensat
+#include <sys/time.h> // for timeval, utimes
+#include <time.h> // for timespec
int utimes(const char *path, const struct timeval times[2])
{
diff --git a/lib/libc/times/times.c b/lib/libc/times/times.c
index bd850215..0b8608e4 100644
--- a/lib/libc/times/times.c
+++ b/lib/libc/times/times.c
@@ -1,5 +1,6 @@
#include <sys/times.h>
#include <syscall.h>
+#include <time.h>
clock_t times(struct tms *buffer)
{
diff --git a/lib/libc/uio/readv.c b/lib/libc/uio/readv.c
index 2a69d02c..97e94f7d 100644
--- a/lib/libc/uio/readv.c
+++ b/lib/libc/uio/readv.c
@@ -1,5 +1,4 @@
-#include <linux/uio.h> // for iovec, UIO_MAXIOV
-#include "asm/unistd_64.h" // for __NR_readv
+#include <linux/uio.h> // for iovec, UIO_MAXIOV
#include <errno.h> // for errno, EAGAIN, EINTR, EINVAL
#include <string.h> // for memcpy
@@ -40,8 +39,8 @@ ssize_t readv(int fd, const struct iovec *iov, int iovcnt)
ssize_t remaining = ret;
while (remaining > 0 && iovcnt > 0) {
- if ((size_t)remaining >= iov->iov_len) {
- remaining -= iov->iov_len;
+ if (remaining >= (ssize_t)iov->iov_len) {
+ remaining -= (ssize_t)iov->iov_len;
iov++;
iovcnt--;
} else {
diff --git a/lib/libc/uio/writev.c b/lib/libc/uio/writev.c
index d59e7d8f..63089f3b 100644
--- a/lib/libc/uio/writev.c
+++ b/lib/libc/uio/writev.c
@@ -1,10 +1,10 @@
-#include "asm/unistd_64.h" // for __NR_writev
#include <errno.h> // for errno, EAGAIN, EINTR, EINVAL
#include <string.h> // for memcpy
#include <sys/types.h> // for ssize_t, size_t
#include <syscall.h> // for __syscall_3, syscall
+
#include <linux/uio.h> // for iovec, UIO_MAXIOV
ssize_t writev(int fd, const struct iovec *iov, int iovcnt)
diff --git a/lib/libc/unistd/_Fork.c b/lib/libc/unistd/_Fork.c
index 5ad326da..9286adfd 100644
--- a/lib/libc/unistd/_Fork.c
+++ b/lib/libc/unistd/_Fork.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_clone
+
+
#include <signal.h> // for SIGCHLD
#include <syscall.h> // for __syscall_2, syscall
diff --git a/lib/libc/unistd/_exit.c b/lib/libc/unistd/_exit.c
index f45312d3..9d356ef2 100644
--- a/lib/libc/unistd/_exit.c
+++ b/lib/libc/unistd/_exit.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_exit
+
+
#include <syscall.h> // for __syscall, __syscall_1
diff --git a/lib/libc/unistd/access.c b/lib/libc/unistd/access.c
index 17b910b4..7ae7e4c1 100644
--- a/lib/libc/unistd/access.c
+++ b/lib/libc/unistd/access.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_access
+
+
#include <syscall.h> // for __syscall_2, syscall
diff --git a/lib/libc/unistd/alarm.c b/lib/libc/unistd/alarm.c
index a1d61698..7dffd08a 100644
--- a/lib/libc/unistd/alarm.c
+++ b/lib/libc/unistd/alarm.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_alarm
+
+
#include <syscall.h> // for __syscall_1, syscall
diff --git a/lib/libc/unistd/chdir.c b/lib/libc/unistd/chdir.c
index 42f108ae..502b4c07 100644
--- a/lib/libc/unistd/chdir.c
+++ b/lib/libc/unistd/chdir.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_chdir
+
+
#include <syscall.h> // for __syscall_1, syscall
diff --git a/lib/libc/unistd/chown.c b/lib/libc/unistd/chown.c
index 50ce565e..02693a92 100644
--- a/lib/libc/unistd/chown.c
+++ b/lib/libc/unistd/chown.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_chown
+
+
#include <syscall.h> // for __syscall_3, syscall
#include <unistd.h> // for chown, gid_t, uid_t
diff --git a/lib/libc/unistd/close.c b/lib/libc/unistd/close.c
index fe55533e..f2b079a6 100644
--- a/lib/libc/unistd/close.c
+++ b/lib/libc/unistd/close.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_close
+
+
#include <syscall.h> // for __syscall_1, syscall
diff --git a/lib/libc/unistd/dup.c b/lib/libc/unistd/dup.c
index 9342a6a4..73fb1a6e 100644
--- a/lib/libc/unistd/dup.c
+++ b/lib/libc/unistd/dup.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_dup
+
+
#include <syscall.h> // for __syscall_1, syscall
diff --git a/lib/libc/unistd/dup2.c b/lib/libc/unistd/dup2.c
index f810424b..414086ed 100644
--- a/lib/libc/unistd/dup2.c
+++ b/lib/libc/unistd/dup2.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_dup2
+
+
#include <syscall.h> // for __syscall_2, syscall
diff --git a/lib/libc/unistd/dup3.c b/lib/libc/unistd/dup3.c
index bb9c6381..65cf5749 100644
--- a/lib/libc/unistd/dup3.c
+++ b/lib/libc/unistd/dup3.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_dup3
+
+
#include <syscall.h> // for __syscall_3, syscall
diff --git a/lib/libc/unistd/execv.c b/lib/libc/unistd/execv.c
index 99793833..a35a6aa4 100644
--- a/lib/libc/unistd/execv.c
+++ b/lib/libc/unistd/execv.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_execve
+
+
#include <syscall.h> // for __syscall_3, syscall
#include <unistd.h> // for execv
diff --git a/lib/libc/unistd/execve.c b/lib/libc/unistd/execve.c
index a91776f3..ec83fe92 100644
--- a/lib/libc/unistd/execve.c
+++ b/lib/libc/unistd/execve.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_execve
+
+
#include <syscall.h> // for __syscall_3, syscall
diff --git a/lib/libc/unistd/execvp.c b/lib/libc/unistd/execvp.c
index 88cde91e..26934a76 100644
--- a/lib/libc/unistd/execvp.c
+++ b/lib/libc/unistd/execvp.c
@@ -1,6 +1,8 @@
+#include "stddef.h" // for NULL
+
#include <errno.h> // for errno, ENAMETOOLONG, ENOENT
#include <limits.h> // for PATH_MAX
-#include <stdio.h> // for NULL, snprintf
+#include <stdio.h> // for snprintf
#include <stdlib.h> // for getenv
#include <string.h> // for strchr, strlen, strstr
#include <unistd.h> // for execv, execvp
@@ -27,7 +29,8 @@ int execvp(const char *file, char *const argv[])
do {
char buf[PATH_MAX];
- if ((ptr = strchr(path, ':')) == NULL) {
+ ptr = strchr(path, ':');
+ if (ptr == NULL) {
if (snprintf(buf, PATH_MAX, "%s/%s", path,
file) >= PATH_MAX) {
errno = ENAMETOOLONG;
diff --git a/lib/libc/unistd/faccessat.c b/lib/libc/unistd/faccessat.c
index 3087db1c..d5757785 100644
--- a/lib/libc/unistd/faccessat.c
+++ b/lib/libc/unistd/faccessat.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_faccessat
+
+
#include <syscall.h> // for __syscall_4, syscall
diff --git a/lib/libc/unistd/fchdir.c b/lib/libc/unistd/fchdir.c
index b2147b31..fd392fb3 100644
--- a/lib/libc/unistd/fchdir.c
+++ b/lib/libc/unistd/fchdir.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_fchdir
+
+
#include <syscall.h> // for __syscall_1, syscall
diff --git a/lib/libc/unistd/fchown.c b/lib/libc/unistd/fchown.c
index 29d5b969..03f0ca76 100644
--- a/lib/libc/unistd/fchown.c
+++ b/lib/libc/unistd/fchown.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_fchown
+
+
#include <syscall.h> // for __syscall_3, syscall
#include <unistd.h> // for fchown, gid_t, uid_t
diff --git a/lib/libc/unistd/fchownat.c b/lib/libc/unistd/fchownat.c
index c501ca65..f774d7d0 100644
--- a/lib/libc/unistd/fchownat.c
+++ b/lib/libc/unistd/fchownat.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_fchownat
+
+
#include <syscall.h> // for __syscall_5, syscall
#include <unistd.h> // for fchownat, gid_t, uid_t
diff --git a/lib/libc/unistd/fdatasync.c b/lib/libc/unistd/fdatasync.c
index 50a91225..592cae02 100644
--- a/lib/libc/unistd/fdatasync.c
+++ b/lib/libc/unistd/fdatasync.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_fdatasync
+
+
#include <syscall.h> // for __syscall_1, syscall
diff --git a/lib/libc/unistd/fsync.c b/lib/libc/unistd/fsync.c
index e821dc3e..e33afbd0 100644
--- a/lib/libc/unistd/fsync.c
+++ b/lib/libc/unistd/fsync.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_fsync
+
+
#include <syscall.h> // for __syscall_1, syscall
diff --git a/lib/libc/unistd/ftruncate.c b/lib/libc/unistd/ftruncate.c
index fc42046b..3300a3a4 100644
--- a/lib/libc/unistd/ftruncate.c
+++ b/lib/libc/unistd/ftruncate.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_ftruncate
+
+
#include <syscall.h> // for __syscall_2, syscall
#include <unistd.h> // for ftruncate, off_t
diff --git a/lib/libc/unistd/getcwd.c b/lib/libc/unistd/getcwd.c
index 54fa5ca9..61f6e872 100644
--- a/lib/libc/unistd/getcwd.c
+++ b/lib/libc/unistd/getcwd.c
@@ -1,5 +1,4 @@
-#include "asm/unistd_64.h" // for __NR_getcwd
-
+#include <stddef.h>
#include <syscall.h> // for __syscall_2, syscall
#include <unistd.h> // for getcwd, size_t
diff --git a/lib/libc/unistd/getegid.c b/lib/libc/unistd/getegid.c
index 696523e2..e59cc2a4 100644
--- a/lib/libc/unistd/getegid.c
+++ b/lib/libc/unistd/getegid.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_getegid
+
+
#include <syscall.h> // for __syscall_0, syscall
#include <unistd.h> // for getegid, gid_t
diff --git a/lib/libc/unistd/getentropy.c b/lib/libc/unistd/getentropy.c
index feab9328..60be17f7 100644
--- a/lib/libc/unistd/getentropy.c
+++ b/lib/libc/unistd/getentropy.c
@@ -1,3 +1,4 @@
+#include <stddef.h>
#include <unistd.h> // for getentropy, size_t
int getentropy(void *buffer, size_t length)
diff --git a/lib/libc/unistd/geteuid.c b/lib/libc/unistd/geteuid.c
index a66c159c..1044ac94 100644
--- a/lib/libc/unistd/geteuid.c
+++ b/lib/libc/unistd/geteuid.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_geteuid
+
+
#include <syscall.h> // for __syscall_0, syscall
#include <unistd.h> // for geteuid, gid_t
diff --git a/lib/libc/unistd/getgid.c b/lib/libc/unistd/getgid.c
index 1c206911..ffc5e9d2 100644
--- a/lib/libc/unistd/getgid.c
+++ b/lib/libc/unistd/getgid.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_getgid
+
+
#include <syscall.h> // for __syscall_0, syscall
#include <unistd.h> // for getgid, gid_t
diff --git a/lib/libc/unistd/getgroups.c b/lib/libc/unistd/getgroups.c
index dbb9abb3..3eee06f4 100644
--- a/lib/libc/unistd/getgroups.c
+++ b/lib/libc/unistd/getgroups.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_getgroups
+
+
#include <syscall.h> // for __syscall_2, syscall
#include <unistd.h> // for getgroups, gid_t
diff --git a/lib/libc/unistd/gethostname.c b/lib/libc/unistd/gethostname.c
index caa870da..8ef22fe4 100644
--- a/lib/libc/unistd/gethostname.c
+++ b/lib/libc/unistd/gethostname.c
@@ -1,3 +1,4 @@
+#include <stddef.h>
#include <unistd.h> // for gethostname, size_t
int gethostname(char *name, size_t namelen)
diff --git a/lib/libc/unistd/getlogin_r.c b/lib/libc/unistd/getlogin_r.c
index 018453fb..adfb6de1 100644
--- a/lib/libc/unistd/getlogin_r.c
+++ b/lib/libc/unistd/getlogin_r.c
@@ -1,3 +1,4 @@
+#include <stddef.h>
#include <unistd.h> // for getlogin_r, size_t
int getlogin_r(char *name, size_t namesize)
diff --git a/lib/libc/unistd/getopt.c b/lib/libc/unistd/getopt.c
index 0a3b38cb..c942da56 100644
--- a/lib/libc/unistd/getopt.c
+++ b/lib/libc/unistd/getopt.c
@@ -56,7 +56,7 @@ int getopt(int argc, char *const argv[], const char *optstring)
} while (d && d != c);
if (d != c || c == ':') {
- optopt = c;
+ optopt = (unsigned char)c;
if (optstring[0] != ':' && opterr) {
struct iovec iov[4];
char opt_char[2] = { *optchar, '\0' };
@@ -85,7 +85,7 @@ int getopt(int argc, char *const argv[], const char *optstring)
optpos = 0;
}
if (optind > argc) {
- optopt = c;
+ optopt = (unsigned char)c;
if (optstring[0] == ':') {
return ':';
}
diff --git a/lib/libc/unistd/getpgid.c b/lib/libc/unistd/getpgid.c
index d78396aa..11913277 100644
--- a/lib/libc/unistd/getpgid.c
+++ b/lib/libc/unistd/getpgid.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_getpgid
+
+
#include <syscall.h> // for __syscall_1, syscall
#include <unistd.h> // for pid_t, getpgid
diff --git a/lib/libc/unistd/getpid.c b/lib/libc/unistd/getpid.c
index 57ea18c6..72ac0c6b 100644
--- a/lib/libc/unistd/getpid.c
+++ b/lib/libc/unistd/getpid.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_getpid
+
+
#include <syscall.h> // for __syscall_0, syscall
#include <unistd.h> // for getpid, pid_t
diff --git a/lib/libc/unistd/getppid.c b/lib/libc/unistd/getppid.c
index bf994995..86c7209c 100644
--- a/lib/libc/unistd/getppid.c
+++ b/lib/libc/unistd/getppid.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_getppid
+
+
#include <syscall.h> // for __syscall_0, syscall
#include <unistd.h> // for getppid, pid_t
diff --git a/lib/libc/unistd/getresgid.c b/lib/libc/unistd/getresgid.c
index 60c818cc..bfecfbb2 100644
--- a/lib/libc/unistd/getresgid.c
+++ b/lib/libc/unistd/getresgid.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_getresgid
+
+
#include <syscall.h> // for __syscall_3, syscall
#include <unistd.h> // for gid_t, getresgid
diff --git a/lib/libc/unistd/getresuid.c b/lib/libc/unistd/getresuid.c
index 7d26f610..12dd7e20 100644
--- a/lib/libc/unistd/getresuid.c
+++ b/lib/libc/unistd/getresuid.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_getresuid
+
+
#include <syscall.h> // for __syscall_3, syscall
#include <unistd.h> // for uid_t, getresuid
diff --git a/lib/libc/unistd/getsid.c b/lib/libc/unistd/getsid.c
index 46518105..c3bbbfd5 100644
--- a/lib/libc/unistd/getsid.c
+++ b/lib/libc/unistd/getsid.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_getsid
+
+
#include <syscall.h> // for __syscall_1, syscall
#include <unistd.h> // for pid_t, getsid
diff --git a/lib/libc/unistd/getuid.c b/lib/libc/unistd/getuid.c
index 67289d54..1013a8cc 100644
--- a/lib/libc/unistd/getuid.c
+++ b/lib/libc/unistd/getuid.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_getuid
+
+
#include <syscall.h> // for __syscall_0, syscall
#include <unistd.h> // for getuid, uid_t
diff --git a/lib/libc/unistd/isatty.c b/lib/libc/unistd/isatty.c
index c253e14a..b356a694 100644
--- a/lib/libc/unistd/isatty.c
+++ b/lib/libc/unistd/isatty.c
@@ -1,4 +1,4 @@
-#include "asm/unistd_64.h" // for __NR_ioctl
+
#include <asm-generic/ioctls.h> // for TIOCGWINSZ
#include <syscall.h> // for __syscall_3, syscall
@@ -8,5 +8,5 @@
int isatty(int fildes)
{
struct winsize winsize;
- return 1 + syscall(ioctl, fildes, TIOCGWINSZ, &winsize);
+ return (int)(1 + syscall(ioctl, fildes, TIOCGWINSZ, &winsize));
}
diff --git a/lib/libc/unistd/lchown.c b/lib/libc/unistd/lchown.c
index ea5f4700..0812f26f 100644
--- a/lib/libc/unistd/lchown.c
+++ b/lib/libc/unistd/lchown.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_lchown
+
+
#include <syscall.h> // for __syscall_3, syscall
#include <unistd.h> // for gid_t, lchown, uid_t
diff --git a/lib/libc/unistd/link.c b/lib/libc/unistd/link.c
index 9b00d16c..a0a070ff 100644
--- a/lib/libc/unistd/link.c
+++ b/lib/libc/unistd/link.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_link
+
+
#include <syscall.h> // for __syscall_2, syscall
#include <unistd.h> // for link
diff --git a/lib/libc/unistd/linkat.c b/lib/libc/unistd/linkat.c
index 378bbb4d..f96987b3 100644
--- a/lib/libc/unistd/linkat.c
+++ b/lib/libc/unistd/linkat.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_linkat
+
+
#include <syscall.h> // for __syscall_5, syscall
#include <unistd.h> // for linkat
diff --git a/lib/libc/unistd/lseek.c b/lib/libc/unistd/lseek.c
index fb574f7b..39fab991 100644
--- a/lib/libc/unistd/lseek.c
+++ b/lib/libc/unistd/lseek.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_lseek
+
+
#include <syscall.h> // for __syscall_3, syscall
#include <unistd.h> // for off_t, lseek
diff --git a/lib/libc/unistd/pause.c b/lib/libc/unistd/pause.c
index 98ff98d4..cda0feaf 100644
--- a/lib/libc/unistd/pause.c
+++ b/lib/libc/unistd/pause.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_pause
+
+
#include <syscall.h> // for __syscall_0, syscall
diff --git a/lib/libc/unistd/pipe.c b/lib/libc/unistd/pipe.c
index 3c1509d0..a0d55b86 100644
--- a/lib/libc/unistd/pipe.c
+++ b/lib/libc/unistd/pipe.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_pipe
+
+
#include <syscall.h> // for __syscall_1, syscall
diff --git a/lib/libc/unistd/pipe2.c b/lib/libc/unistd/pipe2.c
index 5ac36338..eb91ff29 100644
--- a/lib/libc/unistd/pipe2.c
+++ b/lib/libc/unistd/pipe2.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_pipe2
+
+
#include <syscall.h> // for __syscall_2, syscall
diff --git a/lib/libc/unistd/posix_close.c b/lib/libc/unistd/posix_close.c
index 95c7686f..d77d4114 100644
--- a/lib/libc/unistd/posix_close.c
+++ b/lib/libc/unistd/posix_close.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_close
+
+
#include <libc.h> // for __unused
#include <syscall.h> // for __syscall_1, syscall
diff --git a/lib/libc/unistd/pread.c b/lib/libc/unistd/pread.c
index 0e7aaaff..ea56534d 100644
--- a/lib/libc/unistd/pread.c
+++ b/lib/libc/unistd/pread.c
@@ -1,3 +1,4 @@
+#include <stddef.h>
#include <syscall.h> // for __NR_pread, __syscall_4, syscall
#include <unistd.h> // for off_t, pread, size_t, ssize_t
diff --git a/lib/libc/unistd/pwrite.c b/lib/libc/unistd/pwrite.c
index 8c2e66f0..0ede4d45 100644
--- a/lib/libc/unistd/pwrite.c
+++ b/lib/libc/unistd/pwrite.c
@@ -1,3 +1,4 @@
+#include <stddef.h>
#include <syscall.h> // for __NR_pwrite, __syscall_4, syscall
#include <unistd.h> // for off_t, pwrite, size_t, ssize_t
diff --git a/lib/libc/unistd/read.c b/lib/libc/unistd/read.c
index cd9d4bf4..0a524f51 100644
--- a/lib/libc/unistd/read.c
+++ b/lib/libc/unistd/read.c
@@ -1,5 +1,7 @@
-#include "asm/unistd_64.h" // for __NR_read
+
+
+#include <stddef.h>
#include <syscall.h> // for __syscall_3, syscall
#include <unistd.h> // for read, size_t, ssize_t
diff --git a/lib/libc/unistd/readlink.c b/lib/libc/unistd/readlink.c
index e8d97d80..05001f06 100644
--- a/lib/libc/unistd/readlink.c
+++ b/lib/libc/unistd/readlink.c
@@ -1,5 +1,7 @@
-#include "asm/unistd_64.h" // for __NR_readlink
+
+
+#include <stddef.h>
#include <syscall.h> // for __syscall_3, syscall
#include <unistd.h> // for readlink, size_t, ssize_t
diff --git a/lib/libc/unistd/readlinkat.c b/lib/libc/unistd/readlinkat.c
index 0276f676..59e99d2d 100644
--- a/lib/libc/unistd/readlinkat.c
+++ b/lib/libc/unistd/readlinkat.c
@@ -1,5 +1,7 @@
-#include "asm/unistd_64.h" // for __NR_readlinkat
+
+
+#include <stddef.h>
#include <syscall.h> // for __syscall_4, syscall
#include <unistd.h> // for readlinkat, size_t, ssize_t
diff --git a/lib/libc/unistd/rmdir.c b/lib/libc/unistd/rmdir.c
index 70519c85..26afb14b 100644
--- a/lib/libc/unistd/rmdir.c
+++ b/lib/libc/unistd/rmdir.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_rmdir
+
+
#include <syscall.h> // for __syscall_1, syscall
diff --git a/lib/libc/unistd/setegid.c b/lib/libc/unistd/setegid.c
index 50fa2a52..c5159de7 100644
--- a/lib/libc/unistd/setegid.c
+++ b/lib/libc/unistd/setegid.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_setresgid
+
+
#include <syscall.h> // for __syscall_3, syscall
#include <unistd.h> // for gid_t, setegid
diff --git a/lib/libc/unistd/seteuid.c b/lib/libc/unistd/seteuid.c
index 48fb8b3d..41aea3ad 100644
--- a/lib/libc/unistd/seteuid.c
+++ b/lib/libc/unistd/seteuid.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_setresuid
+
+
#include <syscall.h> // for __syscall_3, syscall
#include <unistd.h> // for seteuid, uid_t
diff --git a/lib/libc/unistd/setgid.c b/lib/libc/unistd/setgid.c
index edf5619a..0d465480 100644
--- a/lib/libc/unistd/setgid.c
+++ b/lib/libc/unistd/setgid.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_setgid
+
+
#include <syscall.h> // for __syscall_1, syscall
#include <unistd.h> // for gid_t, setgid
diff --git a/lib/libc/unistd/setpgid.c b/lib/libc/unistd/setpgid.c
index 87f50e8f..aa7bc2b2 100644
--- a/lib/libc/unistd/setpgid.c
+++ b/lib/libc/unistd/setpgid.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_setpgid
+
+
#include <syscall.h> // for __syscall_2, syscall
#include <unistd.h> // for pid_t, setpgid
diff --git a/lib/libc/unistd/setregid.c b/lib/libc/unistd/setregid.c
index a4d61d8c..c66d9c85 100644
--- a/lib/libc/unistd/setregid.c
+++ b/lib/libc/unistd/setregid.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_setregid
+
+
#include <syscall.h> // for __syscall_2, syscall
#include <unistd.h> // for gid_t, setregid
diff --git a/lib/libc/unistd/setresgid.c b/lib/libc/unistd/setresgid.c
index 3f288103..fb0451bb 100644
--- a/lib/libc/unistd/setresgid.c
+++ b/lib/libc/unistd/setresgid.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_setresgid
+
+
#include <syscall.h> // for __syscall_3, syscall
#include <unistd.h> // for gid_t, setresgid
diff --git a/lib/libc/unistd/setresuid.c b/lib/libc/unistd/setresuid.c
index 4c01b523..4460022d 100644
--- a/lib/libc/unistd/setresuid.c
+++ b/lib/libc/unistd/setresuid.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_setresuid
+
+
#include <syscall.h> // for __syscall_3, syscall
#include <unistd.h> // for uid_t, setresuid
diff --git a/lib/libc/unistd/setreuid.c b/lib/libc/unistd/setreuid.c
index f41caa3c..122e1b1f 100644
--- a/lib/libc/unistd/setreuid.c
+++ b/lib/libc/unistd/setreuid.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_setreuid
+
+
#include <syscall.h> // for __syscall_2, syscall
#include <unistd.h> // for uid_t, setreuid
diff --git a/lib/libc/unistd/setsid.c b/lib/libc/unistd/setsid.c
index bd81b08a..cffe8bf3 100644
--- a/lib/libc/unistd/setsid.c
+++ b/lib/libc/unistd/setsid.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_setsid
+
+
#include <syscall.h> // for __syscall_0, syscall
#include <unistd.h> // for pid_t, setsid
diff --git a/lib/libc/unistd/setuid.c b/lib/libc/unistd/setuid.c
index 18d9cdc2..050cb62a 100644
--- a/lib/libc/unistd/setuid.c
+++ b/lib/libc/unistd/setuid.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_setuid
+
+
#include <syscall.h> // for __syscall_1, syscall
#include <unistd.h> // for setuid, uid_t
diff --git a/lib/libc/unistd/symlink.c b/lib/libc/unistd/symlink.c
index 29f10c07..28b1722f 100644
--- a/lib/libc/unistd/symlink.c
+++ b/lib/libc/unistd/symlink.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_symlink
+
+
#include <syscall.h> // for __syscall_2, syscall
diff --git a/lib/libc/unistd/symlinkat.c b/lib/libc/unistd/symlinkat.c
index e5d8135e..8a64387b 100644
--- a/lib/libc/unistd/symlinkat.c
+++ b/lib/libc/unistd/symlinkat.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_symlinkat
+
+
#include <syscall.h> // for __syscall_3, syscall
diff --git a/lib/libc/unistd/sync.c b/lib/libc/unistd/sync.c
index 47818ce9..e0b3aec6 100644
--- a/lib/libc/unistd/sync.c
+++ b/lib/libc/unistd/sync.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_sync
+
+
#include <syscall.h> // for __syscall_0, syscall
diff --git a/lib/libc/unistd/truncate.c b/lib/libc/unistd/truncate.c
index 21570da5..e318fd4c 100644
--- a/lib/libc/unistd/truncate.c
+++ b/lib/libc/unistd/truncate.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_truncate
+
+
#include <syscall.h> // for __syscall_2, syscall
#include <unistd.h> // for off_t, truncate
diff --git a/lib/libc/unistd/unlink.c b/lib/libc/unistd/unlink.c
index 6c699ac8..639f89d2 100644
--- a/lib/libc/unistd/unlink.c
+++ b/lib/libc/unistd/unlink.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_unlink
+
+
#include <syscall.h> // for __syscall_1, syscall
diff --git a/lib/libc/unistd/unlinkat.c b/lib/libc/unistd/unlinkat.c
index 4a6162ae..ef01e323 100644
--- a/lib/libc/unistd/unlinkat.c
+++ b/lib/libc/unistd/unlinkat.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_unlinkat
+
+
#include <syscall.h> // for __syscall_3, syscall
diff --git a/lib/libc/unistd/write.c b/lib/libc/unistd/write.c
index b0b22403..ad037ad6 100644
--- a/lib/libc/unistd/write.c
+++ b/lib/libc/unistd/write.c
@@ -1,5 +1,7 @@
-#include "asm/unistd_64.h" // for __NR_write
+
+
+#include <stddef.h>
#include <syscall.h> // for __syscall_3, syscall
#include <unistd.h> // for size_t, ssize_t, write
diff --git a/lib/libc/utime/utime.c b/lib/libc/utime/utime.c
index 8d6b91c6..896f8342 100644
--- a/lib/libc/utime/utime.c
+++ b/lib/libc/utime/utime.c
@@ -1,5 +1,5 @@
-#include <utime.h>
-#include <sys/time.h>
+#include <sys/time.h> // for timeval, utimes
+#include <utime.h> // for utimbuf, utime
int utime(const char *filename, const struct utimbuf *buf)
{
diff --git a/lib/libc/utsname/uname.c b/lib/libc/utsname/uname.c
index cefa26b6..e88142ab 100644
--- a/lib/libc/utsname/uname.c
+++ b/lib/libc/utsname/uname.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_uname
+
+
#include <sys/utsname.h> // for uname
#include <syscall.h> // for __syscall_1, syscall
diff --git a/lib/libc/wait/wait.c b/lib/libc/wait/wait.c
index 262c6b75..52765008 100644
--- a/lib/libc/wait/wait.c
+++ b/lib/libc/wait/wait.c
@@ -1,4 +1,3 @@
-#include "asm/unistd_64.h" // for __NR_wait4
#include "sys/types.h" // for pid_t
#include <sys/wait.h> // for wait
diff --git a/lib/libc/wait/waitid.c b/lib/libc/wait/waitid.c
index 31060ddc..f0f6bf0a 100644
--- a/lib/libc/wait/waitid.c
+++ b/lib/libc/wait/waitid.c
@@ -1,4 +1,5 @@
-#include "asm/unistd_64.h" // for __NR_waitid
+
+
#include <signal.h> // for siginfo_t
#include <sys/types.h> // for id_t
diff --git a/lib/libc/wait/waitpid.c b/lib/libc/wait/waitpid.c
index 30acd0f4..3512104b 100644
--- a/lib/libc/wait/waitpid.c
+++ b/lib/libc/wait/waitpid.c
@@ -1,4 +1,3 @@
-#include "asm/unistd_64.h" // for __NR_wait4
#include "sys/types.h" // for pid_t
#include <sys/wait.h> // for waitpid