summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKacper <kacper@mail.openlinux.dev>2025-12-09 23:14:53 +0100
committerKacper <kacper@mail.openlinux.dev>2025-12-09 23:14:53 +0100
commit169daa11155988a210fac949297381743f3cb400 (patch)
tree602ef5df5ae9ea075ab3d5dac3c8ad60da1ea2cc
parent4e2112e165fdd94dee58378e3ea32892f3710cd7 (diff)
feat: clang-tidy fixes
-rw-r--r--.clang-tidy2
-rw-r--r--.clangd2
-rw-r--r--bin/echo/echo.c6
-rw-r--r--bin/gzip/deflate.c12
-rw-r--r--bin/gzip/gzip.c38
-rw-r--r--bin/gzip/gzip.h6
-rw-r--r--bin/gzip/inflate.c11
-rw-r--r--bin/gzip/trees.c20
-rw-r--r--bin/gzip/unzip.c4
-rw-r--r--bin/gzip/util.c20
-rw-r--r--bin/gzip/zip.c3
-rw-r--r--include/aio.h2
-rw-r--r--include/arch/x86_64/drm/drm.h2
-rw-r--r--include/arch/x86_64/drm/i915_drm.h8
-rw-r--r--include/arch/x86_64/linux/can/isotp.h2
-rw-r--r--include/arch/x86_64/linux/hdlcdrv.h2
-rw-r--r--include/arch/x86_64/linux/scc.h2
-rw-r--r--include/arpa/inet.h1
-rw-r--r--include/complex.h1
-rw-r--r--include/devctl.h1
-rw-r--r--include/dirent.h1
-rw-r--r--include/endian.h1
-rw-r--r--include/fenv.h1
-rw-r--r--include/glob.h7
-rw-r--r--include/grp.h1
-rw-r--r--include/iconv.h1
-rw-r--r--include/inttypes.h4
-rw-r--r--include/iso646.h6
-rw-r--r--include/limits.h2
-rw-r--r--include/locale.h1
-rw-r--r--include/math.h1
-rw-r--r--include/mqueue.h2
-rw-r--r--include/ndbm.h1
-rw-r--r--include/netdb.h1
-rw-r--r--include/netinet/in.h1
-rw-r--r--include/poll.h1
-rw-r--r--include/pthread.h2
-rw-r--r--include/pwd.h1
-rw-r--r--include/setjmp.h1
-rw-r--r--include/signal.h7
-rw-r--r--include/stdatomic.h1
-rw-r--r--include/stdint.h1
-rw-r--r--include/stdio.h2
-rw-r--r--include/stdlib.h1
-rw-r--r--include/string.h1
-rw-r--r--include/strings.h1
-rw-r--r--include/sys/cdefs.h1
-rw-r--r--include/sys/mman.h1
-rw-r--r--include/sys/msg.h2
-rw-r--r--include/sys/resource.h1
-rw-r--r--include/sys/select.h6
-rw-r--r--include/sys/sem.h2
-rw-r--r--include/sys/socket.h1
-rw-r--r--include/sys/stat.h1
-rw-r--r--include/sys/times.h1
-rw-r--r--include/sys/uio.h1
-rw-r--r--include/threads.h2
-rw-r--r--include/time.h2
-rw-r--r--include/unistd.h1
-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
-rw-r--r--lib/libm/__complex.h3
-rw-r--r--lib/libm/__cos.c4
-rw-r--r--lib/libm/__cosdf.c4
-rw-r--r--lib/libm/__cosl.c13
-rw-r--r--lib/libm/__expo2.c5
-rw-r--r--lib/libm/__expo2f.c5
-rw-r--r--lib/libm/__fpclassify.c4
-rw-r--r--lib/libm/__fpclassifyf.c4
-rw-r--r--lib/libm/__fpclassifyl.c5
-rw-r--r--lib/libm/__invtrigl.c3
-rw-r--r--lib/libm/__math_divzero.c4
-rw-r--r--lib/libm/__math_divzerof.c4
-rw-r--r--lib/libm/__math_invalid.c2
-rw-r--r--lib/libm/__math_invalidf.c2
-rw-r--r--lib/libm/__math_invalidl.c5
-rw-r--r--lib/libm/__math_oflow.c4
-rw-r--r--lib/libm/__math_oflowf.c4
-rw-r--r--lib/libm/__math_uflow.c4
-rw-r--r--lib/libm/__math_uflowf.c4
-rw-r--r--lib/libm/__math_xflow.c4
-rw-r--r--lib/libm/__math_xflowf.c4
-rw-r--r--lib/libm/__polevll.c4
-rw-r--r--lib/libm/__rem_pio2.c72
-rw-r--r--lib/libm/__rem_pio2_large.c6
-rw-r--r--lib/libm/__rem_pio2f.c6
-rw-r--r--lib/libm/__rem_pio2l.c11
-rw-r--r--lib/libm/__signbit.c2
-rw-r--r--lib/libm/__signbitf.c2
-rw-r--r--lib/libm/__signbitl.c4
-rw-r--r--lib/libm/__sin.c7
-rw-r--r--lib/libm/__sindf.c4
-rw-r--r--lib/libm/__sinl.c10
-rw-r--r--lib/libm/__tan.c5
-rw-r--r--lib/libm/__tandf.c4
-rw-r--r--lib/libm/__tanl.c25
-rw-r--r--lib/libm/acos.c5
-rw-r--r--lib/libm/acosf.c5
-rw-r--r--lib/libm/acosh.c4
-rw-r--r--lib/libm/acoshf.c4
-rw-r--r--lib/libm/acoshl.c5
-rw-r--r--lib/libm/acosl.c10
-rw-r--r--lib/libm/asin.c5
-rw-r--r--lib/libm/asinf.c7
-rw-r--r--lib/libm/asinh.c5
-rw-r--r--lib/libm/asinhf.c5
-rw-r--r--lib/libm/asinhl.c5
-rw-r--r--lib/libm/asinl.c12
-rw-r--r--lib/libm/atan.c5
-rw-r--r--lib/libm/atan2.c5
-rw-r--r--lib/libm/atan2f.c5
-rw-r--r--lib/libm/atan2l.c7
-rw-r--r--lib/libm/atanf.c5
-rw-r--r--lib/libm/atanh.c5
-rw-r--r--lib/libm/atanhf.c5
-rw-r--r--lib/libm/atanhl.c5
-rw-r--r--lib/libm/atanl.c7
-rw-r--r--lib/libm/cabs.c4
-rw-r--r--lib/libm/cabsf.c4
-rw-r--r--lib/libm/cabsl.c4
-rw-r--r--lib/libm/cacos.c4
-rw-r--r--lib/libm/cacosf.c4
-rw-r--r--lib/libm/cacosh.c2
-rw-r--r--lib/libm/cacoshf.c2
-rw-r--r--lib/libm/cacoshl.c2
-rw-r--r--lib/libm/cacosl.c4
-rw-r--r--lib/libm/carg.c4
-rw-r--r--lib/libm/cargf.c4
-rw-r--r--lib/libm/cargl.c4
-rw-r--r--lib/libm/casin.c2
-rw-r--r--lib/libm/casinf.c2
-rw-r--r--lib/libm/casinh.c2
-rw-r--r--lib/libm/casinhf.c2
-rw-r--r--lib/libm/casinhl.c2
-rw-r--r--lib/libm/casinl.c2
-rw-r--r--lib/libm/catan.c7
-rw-r--r--lib/libm/catanf.c7
-rw-r--r--lib/libm/catanh.c2
-rw-r--r--lib/libm/catanhf.c2
-rw-r--r--lib/libm/catanhl.c2
-rw-r--r--lib/libm/catanl.c7
-rw-r--r--lib/libm/cbrt.c4
-rw-r--r--lib/libm/cbrtf.c4
-rw-r--r--lib/libm/cbrtl.c6
-rw-r--r--lib/libm/ccos.c7
-rw-r--r--lib/libm/ccosf.c5
-rw-r--r--lib/libm/ccosh.c4
-rw-r--r--lib/libm/ccoshf.c4
-rw-r--r--lib/libm/ccoshl.c4
-rw-r--r--lib/libm/ccosl.c5
-rw-r--r--lib/libm/ceil.c6
-rw-r--r--lib/libm/ceilf.c5
-rw-r--r--lib/libm/ceill.c5
-rw-r--r--lib/libm/cexp.c4
-rw-r--r--lib/libm/cexpl.c4
-rw-r--r--lib/libm/cexprf.c4
-rw-r--r--lib/libm/cimag.c5
-rw-r--r--lib/libm/cimagf.c4
-rw-r--r--lib/libm/cimagl.c4
-rw-r--r--lib/libm/clog.c3
-rw-r--r--lib/libm/clog10.c6
-rw-r--r--lib/libm/clog10f.c5
-rw-r--r--lib/libm/clog10l.c3
-rw-r--r--lib/libm/clogf.c3
-rw-r--r--lib/libm/clogl.c3
-rw-r--r--lib/libm/conj.c4
-rw-r--r--lib/libm/conjf.c4
-rw-r--r--lib/libm/conjl.c4
-rw-r--r--lib/libm/copysign.c3
-rw-r--r--lib/libm/copysignf.c4
-rw-r--r--lib/libm/copysignl.c5
-rw-r--r--lib/libm/cos.c5
-rw-r--r--lib/libm/cosf.c23
-rw-r--r--lib/libm/cosh.c5
-rw-r--r--lib/libm/coshf.c5
-rw-r--r--lib/libm/coshl.c6
-rw-r--r--lib/libm/cosl.c5
-rw-r--r--lib/libm/cpow.c3
-rw-r--r--lib/libm/cpowf.c3
-rw-r--r--lib/libm/cpowl.c3
-rw-r--r--lib/libm/cproj.c5
-rw-r--r--lib/libm/cprojl.c5
-rw-r--r--lib/libm/creal.c4
-rw-r--r--lib/libm/crealf.c4
-rw-r--r--lib/libm/creall.c4
-rw-r--r--lib/libm/csin.c5
-rw-r--r--lib/libm/csinf.c5
-rw-r--r--lib/libm/csinh.c3
-rw-r--r--lib/libm/csinhf.c3
-rw-r--r--lib/libm/csinhl.c3
-rw-r--r--lib/libm/csinl.c5
-rw-r--r--lib/libm/csqrt.c23
-rw-r--r--lib/libm/csqrtf.c15
-rw-r--r--lib/libm/csqrtl.c13
-rw-r--r--lib/libm/ctan.c5
-rw-r--r--lib/libm/ctanf.c5
-rw-r--r--lib/libm/ctanh.c4
-rw-r--r--lib/libm/ctanhf.c4
-rw-r--r--lib/libm/ctanhl.c4
-rw-r--r--lib/libm/ctanl.c5
-rw-r--r--lib/libm/erf.c5
-rw-r--r--lib/libm/erff.c5
-rw-r--r--lib/libm/erfl.c6
-rw-r--r--lib/libm/exp.c12
-rw-r--r--lib/libm/exp10.c6
-rw-r--r--lib/libm/exp10f.c6
-rw-r--r--lib/libm/exp10l.c7
-rw-r--r--lib/libm/exp2.c11
-rw-r--r--lib/libm/exp2f.c9
-rw-r--r--lib/libm/exp2f_data.h2
-rw-r--r--lib/libm/exp2l.c6
-rw-r--r--lib/libm/exp_data.h2
-rw-r--r--lib/libm/expf.c9
-rw-r--r--lib/libm/expl.c5
-rw-r--r--lib/libm/expm1.c5
-rw-r--r--lib/libm/expm1f.c5
-rw-r--r--lib/libm/expm1l.c3
-rw-r--r--lib/libm/fabs.c4
-rw-r--r--lib/libm/fabsf.c4
-rw-r--r--lib/libm/fabsl.c5
-rw-r--r--lib/libm/fdim.c2
-rw-r--r--lib/libm/fdimf.c2
-rw-r--r--lib/libm/fdiml.c4
-rw-r--r--lib/libm/finite.c2
-rw-r--r--lib/libm/finitef.c2
-rw-r--r--lib/libm/floor.c6
-rw-r--r--lib/libm/floorf.c5
-rw-r--r--lib/libm/floorl.c5
-rw-r--r--lib/libm/fma.c41
-rw-r--r--lib/libm/fmaf.c7
-rw-r--r--lib/libm/fmal.c12
-rw-r--r--lib/libm/fmax.c2
-rw-r--r--lib/libm/fmaxf.c2
-rw-r--r--lib/libm/fmaxl.c4
-rw-r--r--lib/libm/fmin.c2
-rw-r--r--lib/libm/fminf.c2
-rw-r--r--lib/libm/fminl.c4
-rw-r--r--lib/libm/fmod.c4
-rw-r--r--lib/libm/fmodf.c4
-rw-r--r--lib/libm/fmodl.c6
-rw-r--r--lib/libm/frexp.c7
-rw-r--r--lib/libm/frexpf.c7
-rw-r--r--lib/libm/frexpl.c8
-rw-r--r--lib/libm/hypot.c6
-rw-r--r--lib/libm/hypotf.c4
-rw-r--r--lib/libm/hypotl.c5
-rw-r--r--lib/libm/ilogb.c7
-rw-r--r--lib/libm/ilogbf.c7
-rw-r--r--lib/libm/ilogbl.c8
-rw-r--r--lib/libm/j0.c5
-rw-r--r--lib/libm/j0f.c5
-rw-r--r--lib/libm/j1.c5
-rw-r--r--lib/libm/j1f.c5
-rw-r--r--lib/libm/jn.c5
-rw-r--r--lib/libm/ldexp.c2
-rw-r--r--lib/libm/ldexpf.c2
-rw-r--r--lib/libm/ldexpl.c2
-rw-r--r--lib/libm/lgamma.c5
-rw-r--r--lib/libm/lgamma_r.c5
-rw-r--r--lib/libm/lgammaf.c5
-rw-r--r--lib/libm/lgammaf_r.c5
-rw-r--r--lib/libm/lgammal.c6
-rw-r--r--lib/libm/libm.abin1215786 -> 1175300 bytes
-rw-r--r--lib/libm/libm.h4
-rw-r--r--lib/libm/llrint.c2
-rw-r--r--lib/libm/llrintf.c2
-rw-r--r--lib/libm/llrintl.c9
-rw-r--r--lib/libm/llround.c2
-rw-r--r--lib/libm/llroundf.c2
-rw-r--r--lib/libm/llroundl.c2
-rw-r--r--lib/libm/log.c9
-rw-r--r--lib/libm/log10.c4
-rw-r--r--lib/libm/log10f.c4
-rw-r--r--lib/libm/log10l.c9
-rw-r--r--lib/libm/log1p.c5
-rw-r--r--lib/libm/log1pf.c5
-rw-r--r--lib/libm/log1pl.c5
-rw-r--r--lib/libm/log2.c9
-rw-r--r--lib/libm/log2f.c9
-rw-r--r--lib/libm/log2l.c5
-rw-r--r--lib/libm/logb.c2
-rw-r--r--lib/libm/logbf.c2
-rw-r--r--lib/libm/logbl.c2
-rw-r--r--lib/libm/logf.c9
-rw-r--r--lib/libm/logl.c5
-rw-r--r--lib/libm/lrint.c7
-rw-r--r--lib/libm/lrintf.c2
-rw-r--r--lib/libm/lrintl.c9
-rw-r--r--lib/libm/lround.c2
-rw-r--r--lib/libm/lroundf.c2
-rw-r--r--lib/libm/lroundl.c2
-rw-r--r--lib/libm/modf.c3
-rw-r--r--lib/libm/modff.c3
-rw-r--r--lib/libm/modfl.c5
-rw-r--r--lib/libm/nan.c4
-rw-r--r--lib/libm/nanf.c4
-rw-r--r--lib/libm/nanl.c4
-rw-r--r--lib/libm/nearbyint.c6
-rw-r--r--lib/libm/nearbyintf.c6
-rw-r--r--lib/libm/nearbyintl.c9
-rw-r--r--lib/libm/nextafter.c5
-rw-r--r--lib/libm/nextafterf.c5
-rw-r--r--lib/libm/nextafterl.c5
-rw-r--r--lib/libm/nexttoward.c6
-rw-r--r--lib/libm/nexttowardf.c5
-rw-r--r--lib/libm/nexttowardl.c2
-rw-r--r--lib/libm/pow.c17
-rw-r--r--lib/libm/powf.c11
-rw-r--r--lib/libm/powf_data.h3
-rw-r--r--lib/libm/powl.c5
-rw-r--r--lib/libm/projf.c5
-rw-r--r--lib/libm/remainder.c4
-rw-r--r--lib/libm/remainderf.c4
-rw-r--r--lib/libm/remainderl.c4
-rw-r--r--lib/libm/remquo.c4
-rw-r--r--lib/libm/remquof.c4
-rw-r--r--lib/libm/remquol.c6
-rw-r--r--lib/libm/rint.c6
-rw-r--r--lib/libm/rintf.c6
-rw-r--r--lib/libm/rintl.c5
-rw-r--r--lib/libm/round.c6
-rw-r--r--lib/libm/roundf.c6
-rw-r--r--lib/libm/roundl.c5
-rw-r--r--lib/libm/scalb.c5
-rw-r--r--lib/libm/scalbf.c5
-rw-r--r--lib/libm/scalbln.c4
-rw-r--r--lib/libm/scalblnf.c4
-rw-r--r--lib/libm/scalblnl.c6
-rw-r--r--lib/libm/scalbn.c4
-rw-r--r--lib/libm/scalbnf.c4
-rw-r--r--lib/libm/scalbnl.c5
-rw-r--r--lib/libm/signgam.c5
-rw-r--r--lib/libm/significand.c2
-rw-r--r--lib/libm/significandf.c2
-rw-r--r--lib/libm/sin.c5
-rw-r--r--lib/libm/sincos.c4
-rw-r--r--lib/libm/sincosf.c5
-rw-r--r--lib/libm/sincosl.c6
-rw-r--r--lib/libm/sinf.c11
-rw-r--r--lib/libm/sinh.c5
-rw-r--r--lib/libm/sinhf.c5
-rw-r--r--lib/libm/sinhl.c5
-rw-r--r--lib/libm/sinl.c5
-rw-r--r--lib/libm/sqrt.c9
-rw-r--r--lib/libm/sqrt_data.c3
-rw-r--r--lib/libm/sqrt_data.h2
-rw-r--r--lib/libm/sqrtf.c9
-rw-r--r--lib/libm/sqrtl.c11
-rw-r--r--lib/libm/tan.c5
-rw-r--r--lib/libm/tanf.c16
-rw-r--r--lib/libm/tanh.c7
-rw-r--r--lib/libm/tanhf.c7
-rw-r--r--lib/libm/tanhl.c6
-rw-r--r--lib/libm/tanl.c10
-rw-r--r--lib/libm/tgamma.c13
-rw-r--r--lib/libm/tgammaf.c4
-rw-r--r--lib/libm/tgammal.c7
-rw-r--r--lib/libm/trunc.c5
-rw-r--r--lib/libm/truncf.c5
-rw-r--r--lib/libm/truncl.c5
-rw-r--r--makefile4
662 files changed, 2146 insertions, 1372 deletions
diff --git a/.clang-tidy b/.clang-tidy
index 40ceb20b..1fe5f7e0 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -5,7 +5,9 @@ Checks: >
llvm-*,
performance-*,
concurrency-*,
+ misc-*,
-bugprone-reserved-identifier,
+ -bugprone-easily-swappable-parameters,
-llvm-header-guard
WarningsAsErrors: ""
diff --git a/.clangd b/.clangd
index 551d2c03..41e5e9d5 100644
--- a/.clangd
+++ b/.clangd
@@ -10,6 +10,8 @@ Diagnostics:
- llvm-*
- performance-*
- concurrency-*
+ - misc-*
Remove:
- bugprone-reserved-identifier
+ - bugprone-easily-swappable-parameters
- llvm-header-guard
diff --git a/bin/echo/echo.c b/bin/echo/echo.c
index b8e5bbe0..b5ceee1c 100644
--- a/bin/echo/echo.c
+++ b/bin/echo/echo.c
@@ -1,6 +1,6 @@
-#include <string.h>
-#include <unistd.h>
-#include <sys/uio.h>
+#include <string.h> // for strlen
+#include <sys/uio.h> // for iovec, writev
+#include <unistd.h> // for STDOUT_FILENO
int main(int argc, char **argv)
{
diff --git a/bin/gzip/deflate.c b/bin/gzip/deflate.c
index 61e4d92b..2f839851 100644
--- a/bin/gzip/deflate.c
+++ b/bin/gzip/deflate.c
@@ -61,10 +61,12 @@
* attributes.
*/
+#include "stddef.h"
#include <stdio.h>
-#include "tailor.h"
#include "gzip.h"
+#include "tailor.h"
+#include <string.h>
#ifdef RCSID
static char rcsid[] = "$Id: deflate.c,v 1.1 2002/08/18 00:59:21 hpa Exp $";
@@ -266,7 +268,7 @@ local void check_match OF((IPos start, IPos match, int length));
* input characters, so that a running hash key can be computed from the
* previous key instead of complete recalculation each time.
*/
-#define UPDATE_HASH(h, c) (h = (((h) << H_SHIFT) ^ (c)) & HASH_MASK)
+#define UPDATE_HASH(h, c) ((h) = (((h) << H_SHIFT) ^ (c)) & HASH_MASK)
/* ===========================================================================
* Insert string s in the dictionary and set match_head to the previous head
@@ -278,14 +280,12 @@ local void check_match OF((IPos start, IPos match, int length));
*/
#define INSERT_STRING(s, match_head) \
(UPDATE_HASH(ins_h, window[(s) + MIN_MATCH - 1]), \
- prev[(s) & WMASK] = match_head = head[ins_h], head[ins_h] = (s))
+ prev[(s) & WMASK] = (match_head) = head[ins_h], head[ins_h] = (s))
/* ===========================================================================
* Initialize the "longest match" routines for a new file
*/
-void lm_init(pack_level, flags) int pack_level; /* 0: store, 1: best speed, 9:
- best compression */
-ush *flags; /* general purpose bit flag */
+void lm_init(int pack_level, ush *flags)
{
register unsigned j;
diff --git a/bin/gzip/gzip.c b/bin/gzip/gzip.c
index bc7a4bf2..b0e20bb1 100644
--- a/bin/gzip/gzip.c
+++ b/bin/gzip/gzip.c
@@ -9,6 +9,11 @@
* See the file algorithm.doc for the compression algorithms and file formats.
*/
+#include "stddef.h" // for NULL
+
+#include <stdio.h> // for fprintf, stderr, perror, fileno, stdin, stdout
+#include <string.h> // for strcpy, strcmp, strlen, strcat, memcmp, strncmp
+
static char *license_msg[] = {
" Copyright (C) 1992-1993 Jean-loup Gailly",
" This program is free software; you can redistribute it and/or modify",
@@ -49,21 +54,18 @@ static char *license_msg[] = {
static char rcsid[] = "$Id: gzip.c,v 1.3 2005/02/12 21:03:28 olh Exp $";
#endif
-#include <sys/types.h>
-#include <signal.h>
-#include <sys/stat.h>
-#include <errno.h>
-
-#include "tailor.h"
#include "gzip.h"
-#include "revision.h"
-
-#include <time.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdlib.h>
-
-#include <utime.h>
+#include "revision.h" // for REVDATE, VERSION
+#include "tailor.h" // for MAX_SUFFIX, PATH_SEP, get_char, MIN_PART, OPTI...
+
+#include <errno.h> // for errno, ENAMETOOLONG, ENOENT
+#include <fcntl.h> // for open, O_RDONLY, O_CREAT, O_EXCL, O_WRONLY
+#include <signal.h> // for sysv_signal, SIG_IGN, SIGHUP, SIGTERM, SIGINT
+#include <stdlib.h> // for exit, free
+#include <sys/stat.h> // for stat, chmod, st_mtime, fstat, S_IRUSR, S_IWUSR
+#include <time.h> // for time_t
+#include <unistd.h> // for close, unlink, optarg, optind, chown, getopt
+#include <utime.h> // for utimbuf, utime
typedef void(*sig_type) OF((int));
@@ -1000,12 +1002,10 @@ local int get_method()
ifname);
exit_code = ERROR;
return -1;
- } else {
- WARN((stderr,
- "\n%s: %s: decompression OK, trailing garbage ignored\n",
- progname, ifname));
- return -2;
}
+ WARN((stderr, "\n%s: %s: decompression OK, trailing garbage ignored\n",
+ progname, ifname));
+ return -2;
}
/* ========================================================================
diff --git a/bin/gzip/gzip.h b/bin/gzip/gzip.h
index e2dcddfc..6e01f429 100644
--- a/bin/gzip/gzip.h
+++ b/bin/gzip/gzip.h
@@ -19,9 +19,9 @@ typedef char *voidp;
/* I don't like nested includes, but the string and io functions are used
* too often
*/
-#include <stdio.h>
-#include <string.h>
-#include <time.h>
+#include <stdio.h> // for fprintf, FILE
+#include <time.h> // for time_t
+
#define memzero(s, n) memset((voidp)(s), 0, (n))
#define local static
diff --git a/bin/gzip/inflate.c b/bin/gzip/inflate.c
index bf9774f0..af2e1e92 100644
--- a/bin/gzip/inflate.c
+++ b/bin/gzip/inflate.c
@@ -95,15 +95,18 @@
the two sets of lengths.
*/
+#include "stddef.h" // for NULL
+
+#include <stdio.h> // for fprintf, stderr
+#include <string.h> // for memcpy
#ifdef RCSID
static char rcsid[] = "$Id: inflate.c,v 1.1 2002/08/18 00:59:21 hpa Exp $";
#endif
-#include <sys/types.h>
-#include <stdlib.h>
+#include "gzip.h" // for uch, ulg, get_byte, ush, outcnt, OF, flush_window
+
+#include <stdlib.h> // for free, malloc
-#include "tailor.h"
-#include "gzip.h"
#define slide window
/* Huffman code lookup table entry--this entry is four bytes for machines
diff --git a/bin/gzip/trees.c b/bin/gzip/trees.c
index 28d2e236..1b73553d 100644
--- a/bin/gzip/trees.c
+++ b/bin/gzip/trees.c
@@ -53,8 +53,6 @@
*
*/
-#include <ctype.h>
-
#include "tailor.h"
#include "gzip.h"
@@ -307,7 +305,7 @@ local void compress_block OF((ct_data * ltree, ct_data *dtree));
local void set_file_type OF((void));
#ifndef DEBUG
-#define send_code(c, tree) send_bits(tree[c].Code, tree[c].Len)
+#define send_code(c, tree) send_bits((tree)[c].Code, (tree)[c].Len)
/* Send a code of the given tree. c and tree must not have side effects */
#else /* DEBUG */
@@ -326,7 +324,7 @@ local void set_file_type OF((void));
* used.
*/
-#define MAX(a, b) (a >= b ? a : b)
+#define MAX(a, b) ((a) >= (b) ? (a) : (b))
/* the arguments must not have side effects */
/* ===========================================================================
@@ -442,7 +440,7 @@ local void init_block()
*/
#define pqremove(tree, top) \
{ \
- top = heap[SMALLEST]; \
+ (top) = heap[SMALLEST]; \
heap[SMALLEST] = heap[heap_len--]; \
pqdownheap(tree, SMALLEST); \
}
@@ -451,9 +449,9 @@ local void init_block()
* Compares to subtrees, using the tree depth as tie breaker when
* the subtrees have equal frequency. This minimizes the worst case length.
*/
-#define smaller(tree, n, m) \
- (tree[n].Freq < tree[m].Freq || \
- (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m]))
+#define smaller(tree, n, m) \
+ ((tree)[n].Freq < (tree)[m].Freq || \
+ ((tree)[n].Freq == (tree)[m].Freq && depth[n] <= depth[m]))
/* ===========================================================================
* Restore the heap property by moving down the tree starting at node k,
@@ -743,7 +741,8 @@ int max_code; /* and its largest code of non zero frequency */
nextlen = tree[n + 1].Len;
if (++count < max_count && curlen == nextlen) {
continue;
- } else if (count < min_count) {
+ }
+ if (count < min_count) {
bl_tree[curlen].Freq += count;
} else if (curlen != 0) {
if (curlen != prevlen)
@@ -790,7 +789,8 @@ int max_code; /* and its largest code of non zero frequency */
nextlen = tree[n + 1].Len;
if (++count < max_count && curlen == nextlen) {
continue;
- } else if (count < min_count) {
+ }
+ if (count < min_count) {
do {
send_code(curlen, bl_tree);
} while (--count != 0);
diff --git a/bin/gzip/unzip.c b/bin/gzip/unzip.c
index ba259afa..ead7023f 100644
--- a/bin/gzip/unzip.c
+++ b/bin/gzip/unzip.c
@@ -13,12 +13,12 @@
either deflated or stored.
*/
+#include "stddef.h" // for NULL
#ifdef RCSID
static char rcsid[] = "$Id: unzip.c,v 1.1 2002/08/18 00:59:21 hpa Exp $";
#endif
-#include "tailor.h"
-#include "gzip.h"
+#include "gzip.h" // for error, updcrc, ulg, LG, inflate, uch, DEFLATED, OK
/* ===========================================================================
* Unzip in to out. This routine works on gzip files only.
diff --git a/bin/gzip/util.c b/bin/gzip/util.c
index ce580ff9..056f85e9 100644
--- a/bin/gzip/util.c
+++ b/bin/gzip/util.c
@@ -4,21 +4,21 @@
* terms of the GNU General Public License, see the file COPYING.
*/
+#include "stddef.h" // for NULL
+
+#include <stdio.h> // for fprintf, stderr, EOF, perror, FILE
+#include <string.h> // for strspn, strcpy, strcspn, strlen, strrchr
#ifdef RCSID
static char rcsid[] = "$Id: util.c,v 1.1 2002/08/18 00:59:21 hpa Exp $";
#endif
-#include <ctype.h>
-#include <errno.h>
-#include <sys/types.h>
-
-#include "tailor.h"
-
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdlib.h>
+#include "gzip.h" // for insize, outcnt, ulg, abort_gzip, bytes_out, voidp
+#include "tailor.h" // for PATH_SEP, casemap
-#include "gzip.h"
+#include <ctype.h> // for tolower
+#include <errno.h> // for errno
+#include <stdlib.h> // for calloc, free, getenv, malloc
+#include <unistd.h> // for read, write
extern ulg crc_32_tab[]; /* crc table, defined below */
diff --git a/bin/gzip/zip.c b/bin/gzip/zip.c
index 919be412..e373edff 100644
--- a/bin/gzip/zip.c
+++ b/bin/gzip/zip.c
@@ -8,10 +8,7 @@
static char rcsid[] = "$Id: zip.c,v 1.1 2002/08/18 00:59:21 hpa Exp $";
#endif
-#include <ctype.h>
-#include <sys/types.h>
#include <unistd.h>
-#include <fcntl.h>
#include "tailor.h"
#include "gzip.h"
diff --git a/include/aio.h b/include/aio.h
index 8481d9cf..9227cdfc 100644
--- a/include/aio.h
+++ b/include/aio.h
@@ -1,6 +1,8 @@
#ifndef __AIO_H
#define __AIO_H
+#include <stddef.h>
+#include <time.h>
#define __BITS_SIGEVENT_H_
#include <bits/sigevent.h>
#undef __BITS_SIGEVENT_H_
diff --git a/include/arch/x86_64/drm/drm.h b/include/arch/x86_64/drm/drm.h
index ebd6ebb5..a928f61f 100644
--- a/include/arch/x86_64/drm/drm.h
+++ b/include/arch/x86_64/drm/drm.h
@@ -253,7 +253,7 @@ enum drm_stat_type {
_DRM_STAT_DMA, /**< DMA */
_DRM_STAT_SPECIAL, /**< Special DMA (e.g., priority or polled) */
_DRM_STAT_MISSED /**< Missed DMA opportunity */
- /* Add to the *END* of the list */
+ /* Add to the *END* of the list */
};
/*
diff --git a/include/arch/x86_64/drm/i915_drm.h b/include/arch/x86_64/drm/i915_drm.h
index 68f08e16..e0403cb6 100644
--- a/include/arch/x86_64/drm/i915_drm.h
+++ b/include/arch/x86_64/drm/i915_drm.h
@@ -2115,10 +2115,10 @@ struct drm_i915_gem_context_param {
#define I915_CONTEXT_MAX_USER_PRIORITY 1023 /* inclusive */
#define I915_CONTEXT_DEFAULT_PRIORITY 0
#define I915_CONTEXT_MIN_USER_PRIORITY -1023 /* inclusive */
- /*
- * When using the following param, value should be a pointer to
- * drm_i915_gem_context_param_sseu.
- */
+ /*
+ * When using the following param, value should be a pointer to
+ * drm_i915_gem_context_param_sseu.
+ */
#define I915_CONTEXT_PARAM_SSEU 0x7
/*
diff --git a/include/arch/x86_64/linux/can/isotp.h b/include/arch/x86_64/linux/can/isotp.h
index 3d72f3d3..d986173d 100644
--- a/include/arch/x86_64/linux/can/isotp.h
+++ b/include/arch/x86_64/linux/can/isotp.h
@@ -85,7 +85,7 @@ struct can_isotp_options {
/* __u8 value : content on rx path */
__u8 rx_ext_address; /* set address for extended addressing */
- /* __u8 value : extended address (rx) */
+ /* __u8 value : extended address (rx) */
};
struct can_isotp_fc_options {
diff --git a/include/arch/x86_64/linux/hdlcdrv.h b/include/arch/x86_64/linux/hdlcdrv.h
index 0d3f0ba7..784d1dcf 100644
--- a/include/arch/x86_64/linux/hdlcdrv.h
+++ b/include/arch/x86_64/linux/hdlcdrv.h
@@ -29,7 +29,7 @@ struct hdlcdrv_channel_params {
int slottime; /* the slottime in 10ms; usually 10 = 100ms */
int ppersist; /* the p-persistence 0..255 */
int fulldup; /* some driver do not support full duplex, setting */
- /* this just makes them send even if DCD is on */
+ /* this just makes them send even if DCD is on */
};
struct hdlcdrv_old_channel_state {
diff --git a/include/arch/x86_64/linux/scc.h b/include/arch/x86_64/linux/scc.h
index ac19e3ef..ce9c783b 100644
--- a/include/arch/x86_64/linux/scc.h
+++ b/include/arch/x86_64/linux/scc.h
@@ -87,7 +87,7 @@ enum CLOCK_sources {
CLK_DIVIDER, /* Rx = DPLL, Tx = divider (fullduplex with */
/* modems without clock regeneration */
CLK_BRG /* experimental fullduplex mode with DPLL/BRG for */
- /* MODEMs without clock recovery */
+ /* MODEMs without clock recovery */
};
/* Tx state */
diff --git a/include/arpa/inet.h b/include/arpa/inet.h
index 030f2f0c..478fb1ac 100644
--- a/include/arpa/inet.h
+++ b/include/arpa/inet.h
@@ -1,6 +1,7 @@
#ifndef __ARPA_INET_H
#define __ARPA_INET_H
+#include <stdint.h>
#define __BITS_IN_ADDR_H_
#include <bits/in_addr.h>
#undef __BITS_IN_ADDR_H_
diff --git a/include/complex.h b/include/complex.h
index ced87a8f..e8cec9cc 100644
--- a/include/complex.h
+++ b/include/complex.h
@@ -1,6 +1,7 @@
#ifndef __COMPLEX_H
#define __COMPLEX_H
+#include <complex.h>
#define complex _Complex
#define _Complex_I (__extension__(0.0f + 1.0fi))
#define imaginary _Imaginary
diff --git a/include/devctl.h b/include/devctl.h
index 1010441d..6948af13 100644
--- a/include/devctl.h
+++ b/include/devctl.h
@@ -1,6 +1,7 @@
#ifndef __DEVCTL_H
#define __DEVCTL_H
+#include <stddef.h>
typedef __SIZE_TYPE__ size_t;
int posix_devctl(int, int, void *restrict, size_t, int *restrict);
diff --git a/include/dirent.h b/include/dirent.h
index f9892928..a926294b 100644
--- a/include/dirent.h
+++ b/include/dirent.h
@@ -1,6 +1,7 @@
#ifndef __DIRENT_H
#define __DIRENT_H
+#include <stddef.h>
#define DT_UNKNOWN 0x0
#define DT_FIFO 0x1
#define DT_CHR 0x2
diff --git a/include/endian.h b/include/endian.h
index fd7d900f..e03bc636 100644
--- a/include/endian.h
+++ b/include/endian.h
@@ -1,6 +1,7 @@
#ifndef __ENDIAN_H
#define __ENDIAN_H
+#include <stdint.h>
#define BYTE_ORDER __BYTE_ORDER__
#define LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
#define BIG_ENDIAN __ORDER_BIG_ENDIAN__
diff --git a/include/fenv.h b/include/fenv.h
index fa91d389..64c70870 100644
--- a/include/fenv.h
+++ b/include/fenv.h
@@ -2,6 +2,7 @@
#define __FENV_H
#include <bits/fenv.h>
+#include <fenv.h>
int feclearexcept(int);
int fegetenv(fenv_t *);
diff --git a/include/glob.h b/include/glob.h
index 9cbf80ac..ef253721 100644
--- a/include/glob.h
+++ b/include/glob.h
@@ -1,6 +1,7 @@
#ifndef __GLOB_H
#define __GLOB_H
+#include <stddef.h>
#define GLOB_APPEND 0x0001
#define GLOB_DOOFFS 0x0002
#define GLOB_ERR 0x0004
@@ -9,9 +10,9 @@
#define GLOB_NOESCAPE 0x0020
#define GLOB_NOSORT 0x0040
-#define GLOB_ABORTED -1
-#define GLOB_NOMATCH -2
-#define GLOB_NOSPACE -3
+#define GLOB_ABORTED (-1)
+#define GLOB_NOMATCH (-2)
+#define GLOB_NOSPACE (-3)
typedef __SIZE_TYPE__ size_t;
diff --git a/include/grp.h b/include/grp.h
index 02f023af..04ad0e44 100644
--- a/include/grp.h
+++ b/include/grp.h
@@ -1,6 +1,7 @@
#ifndef __GRP_H
#define __GRP_H
+#include <stddef.h>
typedef __SIZE_TYPE__ size_t;
typedef __UINT32_TYPE__ gid_t;
diff --git a/include/iconv.h b/include/iconv.h
index 5b25d2b2..cbaef7b7 100644
--- a/include/iconv.h
+++ b/include/iconv.h
@@ -1,6 +1,7 @@
#ifndef __ICONV_H
#define __ICONV_H
+#include <stddef.h>
typedef void *iconv_t;
typedef __SIZE_TYPE__ size_t;
diff --git a/include/inttypes.h b/include/inttypes.h
index 36d4bcba..17b86921 100644
--- a/include/inttypes.h
+++ b/include/inttypes.h
@@ -202,8 +202,6 @@
#define SCNuPTR __PRIPTR "u"
#define SCNxPTR __PRIPTR "x"
-typedef __WCHAR_TYPE__ wchar_t;
-
// TODO: make it private
typedef struct {
intmax_t quot, rem;
@@ -213,7 +211,5 @@ intmax_t imaxabs(intmax_t);
imaxdiv_t imaxdiv(intmax_t, intmax_t);
intmax_t strtoimax(const char *restrict, char **restrict, int);
uintmax_t strtoumax(const char *restrict, char **restrict, int);
-intmax_t wcstoimax(const wchar_t *restrict, wchar_t **restrict, int);
-uintmax_t wcstoumax(const wchar_t *restrict, wchar_t **restrict, int);
#endif
diff --git a/include/iso646.h b/include/iso646.h
index 109cf6d6..f92457b2 100644
--- a/include/iso646.h
+++ b/include/iso646.h
@@ -3,14 +3,14 @@
#define and &&
#define and_eq &=
-#define bitand &
-#define bitor |
+#define bitand (&)
+#define bitor (|)
#define compl ~
#define not !
#define not_eq !=
#define or ||
#define or_eq |=
-#define xor ^
+#define xor (^)
#define xor_eq ^=
#endif
diff --git a/include/limits.h b/include/limits.h
index af981c18..d42cce0a 100644
--- a/include/limits.h
+++ b/include/limits.h
@@ -1,6 +1,8 @@
#ifndef __LIMITS_H
#define __LIMITS_H
+#include <limits.h>
+#include <stdint.h>
#if '\xff' > 0
#define CHAR_MIN 0
#define CHAR_MAX 255
diff --git a/include/locale.h b/include/locale.h
index 0a7a01bc..f94b5225 100644
--- a/include/locale.h
+++ b/include/locale.h
@@ -1,6 +1,7 @@
#ifndef __LOCALE_H
#define __LOCALE_H
+#include <locale.h>
#undef NULL
#define NULL ((void *)0)
diff --git a/include/math.h b/include/math.h
index a8ea9f97..0f672d21 100644
--- a/include/math.h
+++ b/include/math.h
@@ -1,6 +1,7 @@
#ifndef __MATH_H
#define __MATH_H
+#include <math.h>
extern int signgam;
#if FLT_EVAL_METHOD == 1
diff --git a/include/mqueue.h b/include/mqueue.h
index 7af98b58..c4582748 100644
--- a/include/mqueue.h
+++ b/include/mqueue.h
@@ -1,6 +1,8 @@
#ifndef __MQUEUE_H
#define __MQUEUE_H
+#include <stddef.h>
+#include <time.h>
#define __BITS_TIMESPEC_H_
#include <bits/timespec.h>
#undef __BITS_TIMESPEC_H_
diff --git a/include/ndbm.h b/include/ndbm.h
index a0ffc667..35a8f156 100644
--- a/include/ndbm.h
+++ b/include/ndbm.h
@@ -1,6 +1,7 @@
#ifndef __NDBM_H
#define __NDBM_H
+#include <stddef.h>
#define DBM_INSERT 0
#define DBM_REPLACE 1
diff --git a/include/netdb.h b/include/netdb.h
index bdaba1e2..9f7c7195 100644
--- a/include/netdb.h
+++ b/include/netdb.h
@@ -1,6 +1,7 @@
#ifndef __NETDB_H
#define __NETDB_H
+#include <stdint.h>
#define IPPORT_RESERVED 1024
#define AI_PASSIVE 0x00000001
diff --git a/include/netinet/in.h b/include/netinet/in.h
index 39b23904..368a61c1 100644
--- a/include/netinet/in.h
+++ b/include/netinet/in.h
@@ -1,6 +1,7 @@
#ifndef __NETINET_IN_H
#define __NETINET_IN_H
+#include <stdint.h>
#define __BITS_IN_ADDR_H_
#include <bits/in_addr.h>
#undef __BITS_IN_ADDR_H_
diff --git a/include/poll.h b/include/poll.h
index 1e7e98bd..948666ba 100644
--- a/include/poll.h
+++ b/include/poll.h
@@ -1,6 +1,7 @@
#ifndef __POLL_H
#define __POLL_H
+#include <time.h>
#define POLLIN 0x0001
#define POLLRDNORM 0x0040
#define POLLRDBAND 0x0080
diff --git a/include/pthread.h b/include/pthread.h
index cc056888..5141a286 100644
--- a/include/pthread.h
+++ b/include/pthread.h
@@ -1,6 +1,8 @@
#ifndef __PTHREAD_H
#define __PTHREAD_H
+#include <stddef.h>
+#include <time.h>
#define __BITS_TIMESPEC_H_
#include <bits/timespec.h>
#undef __BITS_TIMESPEC_H_
diff --git a/include/pwd.h b/include/pwd.h
index f60dd81b..995edb83 100644
--- a/include/pwd.h
+++ b/include/pwd.h
@@ -1,6 +1,7 @@
#ifndef __PWD_H
#define __PWD_H
+#include <stddef.h>
typedef __SIZE_TYPE__ size_t;
typedef __UINT32_TYPE__ gid_t;
typedef __UINT32_TYPE__ uid_t;
diff --git a/include/setjmp.h b/include/setjmp.h
index feea9cc1..3470fd5e 100644
--- a/include/setjmp.h
+++ b/include/setjmp.h
@@ -2,6 +2,7 @@
#define __SETJMP_H
#include <bits/setjmp.h>
+#include <setjmp.h>
typedef jmp_buf sigjmp_buf;
diff --git a/include/signal.h b/include/signal.h
index 8e49fc8a..425f56e1 100644
--- a/include/signal.h
+++ b/include/signal.h
@@ -1,10 +1,15 @@
#ifndef __SIGNAL_H
#define __SIGNAL_H
+#include <signal.h>
+#include <stddef.h>
+#include <time.h>
+
#define __BITS_SIGEVENT_H_
-#include <bits/sigevent.h>
#define __BITS_SIGINFO_H_
+#include "signal.h"
+
#include <bits/siginfo.h> // for siginfo_t
union sigval;
diff --git a/include/stdatomic.h b/include/stdatomic.h
index fcc39f8c..8863815d 100644
--- a/include/stdatomic.h
+++ b/include/stdatomic.h
@@ -1,6 +1,7 @@
#ifndef __STDATOMIC_H
#define __STDATOMIC_H
+#include <stdatomic.h>
#define atomic_bool _Atomic _Bool
#define atomic_char _Atomic char
#define atomic_schar _Atomic signed char
diff --git a/include/stdint.h b/include/stdint.h
index a1a2768d..cb5bd89f 100644
--- a/include/stdint.h
+++ b/include/stdint.h
@@ -1,6 +1,7 @@
#ifndef __STDINT_H
#define __STDINT_H
+#include <stdint.h>
#undef WCHAR_MAX
#undef WCHAR_MIN
#if L'\0' - 1 > 0
diff --git a/include/stdio.h b/include/stdio.h
index c6067775..65aff35c 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -1,6 +1,8 @@
#ifndef __STDIO_H
#define __STDIO_H
+#include <stddef.h>
+#include <stdio.h>
#define __BITS_ERRNO_H_
#include <bits/errno.h>
diff --git a/include/stdlib.h b/include/stdlib.h
index e9686678..a75dbb43 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -1,6 +1,7 @@
#ifndef __STDLIB_H
#define __STDLIB_H
+#include <stddef.h>
#define __BITS_WAIT_H_
#include <bits/wait.h>
diff --git a/include/string.h b/include/string.h
index 707d9eeb..0b46dfa3 100644
--- a/include/string.h
+++ b/include/string.h
@@ -1,6 +1,7 @@
#ifndef __STRING_H
#define __STRING_H
+#include <stddef.h>
#define __BITS_ERRNO_H_
#include <bits/errno.h>
diff --git a/include/strings.h b/include/strings.h
index cd8743c4..72f04963 100644
--- a/include/strings.h
+++ b/include/strings.h
@@ -1,6 +1,7 @@
#ifndef __STRINGS_H
#define __STRINGS_H
+#include <stddef.h>
typedef __SIZE_TYPE__ size_t;
int ffs(int);
diff --git a/include/sys/cdefs.h b/include/sys/cdefs.h
index 0d6f6327..4c86d599 100644
--- a/include/sys/cdefs.h
+++ b/include/sys/cdefs.h
@@ -12,6 +12,7 @@
#define __malloc __attribute__((__malloc__))
#define __pure __attribute__((__pure__))
#define __nodiscard __attribute__((__warn_unused_result__))
+#define __weak __attribute__((__weak__))
#define __predict_true(exp) __builtin_expect((exp) != 0, 1)
#define __predict_false(exp) __builtin_expect((exp) != 0, 0)
diff --git a/include/sys/mman.h b/include/sys/mman.h
index 3e5dbf96..78b72c48 100644
--- a/include/sys/mman.h
+++ b/include/sys/mman.h
@@ -1,6 +1,7 @@
#ifndef __SYS_MMAN_H
#define __SYS_MMAN_H
+#include <stddef.h>
typedef __SIZE_TYPE__ size_t;
typedef __INT64_TYPE__ off_t;
typedef __UINT32_TYPE__ mode_t;
diff --git a/include/sys/msg.h b/include/sys/msg.h
index b9a16349..60c389bd 100644
--- a/include/sys/msg.h
+++ b/include/sys/msg.h
@@ -1,7 +1,9 @@
#ifndef __SYS_MSG_H
#define __SYS_MSG_H
+#include <stddef.h>
#include <sys/ipc.h>
+#include <time.h>
typedef __INT64_TYPE__ pid_t;
typedef __INT64_TYPE__ ssize_t;
diff --git a/include/sys/resource.h b/include/sys/resource.h
index 79fcf235..086d8cd8 100644
--- a/include/sys/resource.h
+++ b/include/sys/resource.h
@@ -1,6 +1,7 @@
#ifndef __SYS_RESOURCE_H
#define __SYS_RESOURCE_H
+#include <time.h>
typedef __INT64_TYPE__ time_t;
typedef __INT64_TYPE__ suseconds_t;
diff --git a/include/sys/select.h b/include/sys/select.h
index 16b391d1..9c1edcae 100644
--- a/include/sys/select.h
+++ b/include/sys/select.h
@@ -1,14 +1,12 @@
#ifndef __SYS_SELECT_H
#define __SYS_SELECT_H
+#include <time.h>
#define __BITS_SELECT_H_
-#include <bits/select.h>
+#include <bits/select.h> // for fd_set
#define __BITS_TIMESPEC_H_
-#include <bits/timespec.h>
-
struct timespec;
-struct timeval;
typedef __UINT64_TYPE__ sigset_t;
diff --git a/include/sys/sem.h b/include/sys/sem.h
index 2fdaa834..bdfe969e 100644
--- a/include/sys/sem.h
+++ b/include/sys/sem.h
@@ -1,7 +1,9 @@
#ifndef __SYS_SEM_H
#define __SYS_SEM_H
+#include <stddef.h>
#include <sys/ipc.h>
+#include <time.h>
#define SEM_UNDO 0x1000
#define GETNCNT 14
diff --git a/include/sys/socket.h b/include/sys/socket.h
index d8a48dd0..0dd4f454 100644
--- a/include/sys/socket.h
+++ b/include/sys/socket.h
@@ -1,6 +1,7 @@
#ifndef __SYS_SOCKET_H
#define __SYS_SOCKET_H
+#include <stddef.h>
#define SCM_RIGHTS 0x01
#define CMSG_DATA(cmsg) ((void *)(cmsg) + sizeof(struct cmsghdr))
diff --git a/include/sys/stat.h b/include/sys/stat.h
index ceb0826f..85efb075 100644
--- a/include/sys/stat.h
+++ b/include/sys/stat.h
@@ -1,6 +1,7 @@
#ifndef __SYS_STAT_H
#define __SYS_STAT_H
+#include <time.h>
#define __BITS_STAT_H_
#include <bits/stat.h>
#undef __BITS_STAT_H_
diff --git a/include/sys/times.h b/include/sys/times.h
index 4cc0e184..a14a6b6a 100644
--- a/include/sys/times.h
+++ b/include/sys/times.h
@@ -1,6 +1,7 @@
#ifndef __SYS_TIMES_H
#define __SYS_TIMES_H
+#include <time.h>
typedef __INT64_TYPE__ clock_t;
struct tms {
diff --git a/include/sys/uio.h b/include/sys/uio.h
index f14e2328..324dc00a 100644
--- a/include/sys/uio.h
+++ b/include/sys/uio.h
@@ -1,6 +1,7 @@
#ifndef __SYS_UIO_H
#define __SYS_UIO_H
+#include <stddef.h>
typedef __SIZE_TYPE__ size_t;
typedef __INT64_TYPE__ ssize_t;
diff --git a/include/threads.h b/include/threads.h
index 58fd8c87..54daec7b 100644
--- a/include/threads.h
+++ b/include/threads.h
@@ -1,6 +1,8 @@
#ifndef __THREADS_H
#define __THREADS_H
+#include <threads.h>
+#include <time.h>
#define thread_local _Thread_local
#define ONCE_FLAG_INIT
#define TSS_DTOR_ITERATIONS
diff --git a/include/time.h b/include/time.h
index fc089cda..e297ff59 100644
--- a/include/time.h
+++ b/include/time.h
@@ -1,6 +1,8 @@
#ifndef __TIME_H
#define __TIME_H
+#include <stddef.h>
+#include <time.h>
#define __BITS_TIMESPEC_H_
#include <bits/timespec.h>
diff --git a/include/unistd.h b/include/unistd.h
index 21822aed..dd8dba5a 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -1,6 +1,7 @@
#ifndef __UNISTD_H
#define __UNISTD_H
+#include <stddef.h>
#ifndef NULL
#define NULL ((void *)0)
#endif
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
diff --git a/lib/libm/__complex.h b/lib/libm/__complex.h
index 2c54d1e9..21b07c74 100644
--- a/lib/libm/__complex.h
+++ b/lib/libm/__complex.h
@@ -1,9 +1,8 @@
#ifndef __LIBC_COMPLEX_H__
#define __LIBC_COMPLEX_H__
-#include <sys/cdefs.h>
-#include <math.h>
#include <complex.h>
+#include <math.h>
typedef union {
float complex z;
diff --git a/lib/libm/__cos.c b/lib/libm/__cos.c
index 5e4665e2..a55d0eba 100644
--- a/lib/libm/__cos.c
+++ b/lib/libm/__cos.c
@@ -48,7 +48,9 @@
* any extra precision in w.
*/
-#include "libm.h"
+#include "libm.h" // for __cos
+
+#include <math.h> // for double_t
static const double C1 = 4.16666666666666019037e-02, /* 0x3FA55555, 0x5555554C
*/
diff --git a/lib/libm/__cosdf.c b/lib/libm/__cosdf.c
index cda7195c..d5469271 100644
--- a/lib/libm/__cosdf.c
+++ b/lib/libm/__cosdf.c
@@ -14,7 +14,9 @@
* ====================================================
*/
-#include "libm.h"
+#include "libm.h" // for __cosdf
+
+#include <math.h> // for double_t
/* |cos(x) - c(x)| < 2**-34.1 (~[-5.37e-11, 5.295e-11]). */
static const double C0 = -0x1ffffffd0c5e81.0p-54, /* -0.499999997251031003120 */
diff --git a/lib/libm/__cosl.c b/lib/libm/__cosl.c
index c7f72114..18858e6b 100644
--- a/lib/libm/__cosl.c
+++ b/lib/libm/__cosl.c
@@ -12,7 +12,9 @@
* ====================================================
*/
-#include "libm.h"
+#include "libm.h" // for __cosl
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
#if (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
#if LDBL_MANT_DIG == 64
@@ -51,9 +53,12 @@ static const double C2 = -0.0013888888888888874, /* -0x16c16c16c16c10.0p-62 */
C5 = 0.0000000020876754400407278, /* 0x11eed8caaeccf1.0p-81 */
C6 = -1.1470297442401303e-11, /* -0x19393412bd1529.0p-89 */
C7 = 4.7383039476436467e-14; /* 0x1aac9d9af5c43e.0p-97 */
-#define POLY(z) \
- (z * \
- (C1 + z * (C2 + z * (C3 + z * (C4 + z * (C5 + z * (C6 + z * C7)))))))
+#define POLY(z) \
+ ((z) * \
+ (C1 + \
+ (z) * (C2 + \
+ (z) * (C3 + \
+ (z) * (C4 + (z) * (C5 + (z) * (C6 + (z) * C7)))))))
#elif LDBL_MANT_DIG == 113
/*
* ld128 version of __cos.c. See __cos.c for most comments.
diff --git a/lib/libm/__expo2.c b/lib/libm/__expo2.c
index 0d025457..aa26d4ad 100644
--- a/lib/libm/__expo2.c
+++ b/lib/libm/__expo2.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for INSERT_WORDS, __expo2
+
+#include <math.h> // for exp
+#include <stdint.h> // for uint32_t
/* k is such that k*ln2 has minimal relative error and x - kln2 > log(DBL_MIN)
*/
diff --git a/lib/libm/__expo2f.c b/lib/libm/__expo2f.c
index 524be700..2bb6699c 100644
--- a/lib/libm/__expo2f.c
+++ b/lib/libm/__expo2f.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for SET_FLOAT_WORD, __expo2f
+
+#include <math.h> // for expf
+#include <stdint.h> // for uint32_t
/* k is such that k*ln2 has minimal relative error and x - kln2 > log(FLT_MIN)
*/
diff --git a/lib/libm/__fpclassify.c b/lib/libm/__fpclassify.c
index 41332adf..2a961b1c 100644
--- a/lib/libm/__fpclassify.c
+++ b/lib/libm/__fpclassify.c
@@ -1,5 +1,5 @@
-#include <math.h>
-#include <stdint.h>
+#include <math.h> // for FP_INFINITE, FP_NAN, FP_NORMAL, FP_SUBNORMAL
+#include <stdint.h> // for uint64_t
int __fpclassify(double x)
{
diff --git a/lib/libm/__fpclassifyf.c b/lib/libm/__fpclassifyf.c
index c8fc7585..d1b6d8bb 100644
--- a/lib/libm/__fpclassifyf.c
+++ b/lib/libm/__fpclassifyf.c
@@ -1,5 +1,5 @@
-#include <math.h>
-#include <stdint.h>
+#include <math.h> // for FP_INFINITE, FP_NAN, FP_NORMAL, FP_SUBNORMAL
+#include <stdint.h> // for uint32_t
int __fpclassifyf(float x)
{
diff --git a/lib/libm/__fpclassifyl.c b/lib/libm/__fpclassifyl.c
index 2c293803..e9f08a42 100644
--- a/lib/libm/__fpclassifyl.c
+++ b/lib/libm/__fpclassifyl.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for ldshape, ldshape::(anonymous), __BYTE_ORDER, __LI...
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_...
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
int __fpclassifyl(long double x)
diff --git a/lib/libm/__invtrigl.c b/lib/libm/__invtrigl.c
index 66e4c7eb..8e8273ae 100644
--- a/lib/libm/__invtrigl.c
+++ b/lib/libm/__invtrigl.c
@@ -1,6 +1,7 @@
-#include <float.h>
#include "__invtrigl.h"
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+
#if LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
static const long double pS0 = 1.66666666666666666631e-01L,
pS1 = -4.16313987993683104320e-01L,
diff --git a/lib/libm/__math_divzero.c b/lib/libm/__math_divzero.c
index 59d21350..0aefe12a 100644
--- a/lib/libm/__math_divzero.c
+++ b/lib/libm/__math_divzero.c
@@ -1,4 +1,6 @@
-#include "libm.h"
+#include "libm.h" // for __math_divzero, fp_barrier
+
+#include <stdint.h> // for uint32_t
double __math_divzero(uint32_t sign)
{
diff --git a/lib/libm/__math_divzerof.c b/lib/libm/__math_divzerof.c
index ce046f3e..33caf400 100644
--- a/lib/libm/__math_divzerof.c
+++ b/lib/libm/__math_divzerof.c
@@ -1,4 +1,6 @@
-#include "libm.h"
+#include "libm.h" // for __math_divzerof, fp_barrierf
+
+#include <stdint.h> // for uint32_t
float __math_divzerof(uint32_t sign)
{
diff --git a/lib/libm/__math_invalid.c b/lib/libm/__math_invalid.c
index 17740490..dbbbbfb8 100644
--- a/lib/libm/__math_invalid.c
+++ b/lib/libm/__math_invalid.c
@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "libm.h" // for __math_invalid
double __math_invalid(double x)
{
diff --git a/lib/libm/__math_invalidf.c b/lib/libm/__math_invalidf.c
index 357d4b12..f44a7f09 100644
--- a/lib/libm/__math_invalidf.c
+++ b/lib/libm/__math_invalidf.c
@@ -1,4 +1,4 @@
-#include "libm.h"
+#include "libm.h" // for __math_invalidf
float __math_invalidf(float x)
{
diff --git a/lib/libm/__math_invalidl.c b/lib/libm/__math_invalidl.c
index 1fca99de..8ab1f535 100644
--- a/lib/libm/__math_invalidl.c
+++ b/lib/libm/__math_invalidl.c
@@ -1,5 +1,6 @@
-#include <float.h>
-#include "libm.h"
+#include "libm.h" // for __math_invalidl
+
+#include <float.h> // for DBL_MANT_DIG, LDBL_MANT_DIG
#if LDBL_MANT_DIG != DBL_MANT_DIG
long double __math_invalidl(long double x)
diff --git a/lib/libm/__math_oflow.c b/lib/libm/__math_oflow.c
index c85dbf98..b87d6f0e 100644
--- a/lib/libm/__math_oflow.c
+++ b/lib/libm/__math_oflow.c
@@ -1,4 +1,6 @@
-#include "libm.h"
+#include "libm.h" // for __math_xflow, __math_oflow
+
+#include <stdint.h> // for uint32_t
double __math_oflow(uint32_t sign)
{
diff --git a/lib/libm/__math_oflowf.c b/lib/libm/__math_oflowf.c
index fa7d0620..71171b88 100644
--- a/lib/libm/__math_oflowf.c
+++ b/lib/libm/__math_oflowf.c
@@ -1,4 +1,6 @@
-#include "libm.h"
+#include "libm.h" // for __math_xflowf, __math_oflowf
+
+#include <stdint.h> // for uint32_t
float __math_oflowf(uint32_t sign)
{
diff --git a/lib/libm/__math_uflow.c b/lib/libm/__math_uflow.c
index b90594ae..6bf63f36 100644
--- a/lib/libm/__math_uflow.c
+++ b/lib/libm/__math_uflow.c
@@ -1,4 +1,6 @@
-#include "libm.h"
+#include "libm.h" // for __math_xflow, __math_uflow
+
+#include <stdint.h> // for uint32_t
double __math_uflow(uint32_t sign)
{
diff --git a/lib/libm/__math_uflowf.c b/lib/libm/__math_uflowf.c
index 94d50f2b..714fdb71 100644
--- a/lib/libm/__math_uflowf.c
+++ b/lib/libm/__math_uflowf.c
@@ -1,4 +1,6 @@
-#include "libm.h"
+#include "libm.h" // for __math_xflowf, __math_uflowf
+
+#include <stdint.h> // for uint32_t
float __math_uflowf(uint32_t sign)
{
diff --git a/lib/libm/__math_xflow.c b/lib/libm/__math_xflow.c
index 744203c4..c3626a2f 100644
--- a/lib/libm/__math_xflow.c
+++ b/lib/libm/__math_xflow.c
@@ -1,4 +1,6 @@
-#include "libm.h"
+#include "libm.h" // for eval_as_double, __math_xflow, fp_barrier
+
+#include <stdint.h> // for uint32_t
double __math_xflow(uint32_t sign, double y)
{
diff --git a/lib/libm/__math_xflowf.c b/lib/libm/__math_xflowf.c
index f2c84784..b660d92a 100644
--- a/lib/libm/__math_xflowf.c
+++ b/lib/libm/__math_xflowf.c
@@ -1,4 +1,6 @@
-#include "libm.h"
+#include "libm.h" // for eval_as_float, __math_xflowf, fp_barrierf
+
+#include <stdint.h> // for uint32_t
float __math_xflowf(uint32_t sign, float y)
{
diff --git a/lib/libm/__polevll.c b/lib/libm/__polevll.c
index ce1a8404..9028d48b 100644
--- a/lib/libm/__polevll.c
+++ b/lib/libm/__polevll.c
@@ -54,7 +54,9 @@
*
*/
-#include "libm.h"
+#include "libm.h" // for __p1evll, __polevll
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
#else
diff --git a/lib/libm/__rem_pio2.c b/lib/libm/__rem_pio2.c
index d01bc23b..1d81061f 100644
--- a/lib/libm/__rem_pio2.c
+++ b/lib/libm/__rem_pio2.c
@@ -17,7 +17,11 @@
* use __rem_pio2_large() for large x
*/
-#include "libm.h"
+#include "libm.h" // for __rem_pio2_large, predict_false, __rem_pio2
+
+#include <float.h> // for DBL_EPSILON, FLT_EVAL_METHOD
+#include <math.h> // for double_t
+#include <stdint.h> // for uint64_t, int32_t, uint32_t
#if FLT_EVAL_METHOD == 0 || FLT_EVAL_METHOD == 1
#define EPS DBL_EPSILON
@@ -67,25 +71,22 @@ int __rem_pio2(double x, double *y)
y[0] = z - pio2_1t;
y[1] = (z - y[0]) - pio2_1t;
return 1;
- } else {
- z = x + pio2_1;
- y[0] = z + pio2_1t;
- y[1] = (z - y[0]) + pio2_1t;
- return -1;
- }
- } else {
- if (!sign) {
- z = x - 2 * pio2_1;
- y[0] = z - 2 * pio2_1t;
- y[1] = (z - y[0]) - 2 * pio2_1t;
- return 2;
- } else {
- z = x + 2 * pio2_1;
- y[0] = z + 2 * pio2_1t;
- y[1] = (z - y[0]) + 2 * pio2_1t;
- return -2;
}
+ z = x + pio2_1;
+ y[0] = z + pio2_1t;
+ y[1] = (z - y[0]) + pio2_1t;
+ return -1;
+ }
+ if (!sign) {
+ z = x - 2 * pio2_1;
+ y[0] = z - 2 * pio2_1t;
+ y[1] = (z - y[0]) - 2 * pio2_1t;
+ return 2;
}
+ z = x + 2 * pio2_1;
+ y[0] = z + 2 * pio2_1t;
+ y[1] = (z - y[0]) + 2 * pio2_1t;
+ return -2;
}
if (ix <= 0x401c463b) { /* |x| ~<= 9pi/4 */
if (ix <= 0x4015fdbc) { /* |x| ~<= 7pi/4 */
@@ -96,27 +97,24 @@ int __rem_pio2(double x, double *y)
y[0] = z - 3 * pio2_1t;
y[1] = (z - y[0]) - 3 * pio2_1t;
return 3;
- } else {
- z = x + 3 * pio2_1;
- y[0] = z + 3 * pio2_1t;
- y[1] = (z - y[0]) + 3 * pio2_1t;
- return -3;
- }
- } else {
- if (ix == 0x401921fb) /* |x| ~= 4pi/2 */
- goto medium;
- if (!sign) {
- z = x - 4 * pio2_1;
- y[0] = z - 4 * pio2_1t;
- y[1] = (z - y[0]) - 4 * pio2_1t;
- return 4;
- } else {
- z = x + 4 * pio2_1;
- y[0] = z + 4 * pio2_1t;
- y[1] = (z - y[0]) + 4 * pio2_1t;
- return -4;
}
+ z = x + 3 * pio2_1;
+ y[0] = z + 3 * pio2_1t;
+ y[1] = (z - y[0]) + 3 * pio2_1t;
+ return -3;
+ }
+ if (ix == 0x401921fb) /* |x| ~= 4pi/2 */
+ goto medium;
+ if (!sign) {
+ z = x - 4 * pio2_1;
+ y[0] = z - 4 * pio2_1t;
+ y[1] = (z - y[0]) - 4 * pio2_1t;
+ return 4;
}
+ z = x + 4 * pio2_1;
+ y[0] = z + 4 * pio2_1t;
+ y[1] = (z - y[0]) + 4 * pio2_1t;
+ return -4;
}
if (ix < 0x413921fb) { /* |x| ~< 2^20*(pi/2), medium size */
medium:
diff --git a/lib/libm/__rem_pio2_large.c b/lib/libm/__rem_pio2_large.c
index 58defa09..8b97a6f6 100644
--- a/lib/libm/__rem_pio2_large.c
+++ b/lib/libm/__rem_pio2_large.c
@@ -122,7 +122,11 @@
* to produce the hexadecimal values shown.
*/
-#include "libm.h"
+#include "libm.h" // for __rem_pio2_large
+
+#include <float.h> // for LDBL_MAX_EXP
+#include <math.h> // for scalbn, floor
+#include <stdint.h> // for int32_t
static const int init_jk[] = { 3, 4, 4, 6 }; /* initial value for jk */
diff --git a/lib/libm/__rem_pio2f.c b/lib/libm/__rem_pio2f.c
index 8d58b491..6316b60a 100644
--- a/lib/libm/__rem_pio2f.c
+++ b/lib/libm/__rem_pio2f.c
@@ -20,7 +20,11 @@
* use __rem_pio2_large() for large x
*/
-#include "libm.h"
+#include "libm.h" // for __rem_pio2_large, predict_false, __rem_pio2f
+
+#include <float.h> // for DBL_EPSILON, FLT_EVAL_METHOD
+#include <math.h> // for double_t
+#include <stdint.h> // for uint32_t, int32_t
#if FLT_EVAL_METHOD == 0 || FLT_EVAL_METHOD == 1
#define EPS DBL_EPSILON
diff --git a/lib/libm/__rem_pio2l.c b/lib/libm/__rem_pio2l.c
index f6310774..f5d28dde 100644
--- a/lib/libm/__rem_pio2l.c
+++ b/lib/libm/__rem_pio2l.c
@@ -12,7 +12,10 @@
*
* Optimized by Bruce D. Evans.
*/
-#include "libm.h"
+#include "libm.h" // for ldshape, ldshape::(anonymous), __rem_pio2_large
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_EPSILON, LDBL_MAX_EXP
+#include <stdint.h> // for int32_t, uint32_t
#if (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
/* ld80 and ld128 version of __rem_pio2(x,y)
*
@@ -24,10 +27,10 @@ static const long double toint = 1.5 / LDBL_EPSILON;
#if LDBL_MANT_DIG == 64
/* u ~< 0x1p25*pi/2 */
-#define SMALL(u) \
- (((u.i.se & 0x7fffU) << 16 | u.i.m >> 48) < \
+#define SMALL(u) \
+ ((((u).i.se & 0x7fffU) << 16 | (u).i.m >> 48) < \
((0x3fff + 25) << 16 | 0x921f >> 1 | 0x8000))
-#define QUOBITS(x) ((uint32_t)(int32_t)x & 0x7fffffff)
+#define QUOBITS(x) ((uint32_t)(int32_t)(x) & 0x7fffffff)
#define ROUND1 22
#define ROUND2 61
#define NX 3
diff --git a/lib/libm/__signbit.c b/lib/libm/__signbit.c
index 5d145b63..54fecb88 100644
--- a/lib/libm/__signbit.c
+++ b/lib/libm/__signbit.c
@@ -1,4 +1,4 @@
-#include "libm.h"
+#include <stdint.h> // for uint64_t
// FIXME: macro in math.h
int __signbit(double x)
diff --git a/lib/libm/__signbitf.c b/lib/libm/__signbitf.c
index 3e6c4466..da4ba6a7 100644
--- a/lib/libm/__signbitf.c
+++ b/lib/libm/__signbitf.c
@@ -1,4 +1,4 @@
-#include "libm.h"
+#include <stdint.h> // for uint32_t
// FIXME: macro in math.h
int __signbitf(float x)
diff --git a/lib/libm/__signbitl.c b/lib/libm/__signbitl.c
index b66d419f..7b02186a 100644
--- a/lib/libm/__signbitl.c
+++ b/lib/libm/__signbitl.c
@@ -1,4 +1,6 @@
-#include "libm.h"
+#include "libm.h" // for ldshape, ldshape::(anonymous)
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
#if (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
int __signbitl(long double x)
diff --git a/lib/libm/__sin.c b/lib/libm/__sin.c
index c8b8cad8..e44c66e7 100644
--- a/lib/libm/__sin.c
+++ b/lib/libm/__sin.c
@@ -39,7 +39,9 @@
* sin(x) = x + (S1*x + (x *(r-y/2)+y))
*/
-#include "libm.h"
+#include "libm.h" // for __sin
+
+#include <math.h> // for double_t
static const double S1 = -1.66666666666666324348e-01, /* 0xBFC55555, 0x55555549
*/
@@ -59,6 +61,5 @@ double __sin(double x, double y, int iy)
v = z * x;
if (iy == 0)
return x + v * (S1 + z * r);
- else
- return x - ((z * (0.5 * y - v * r) - y) - v * S1);
+ return x - ((z * (0.5 * y - v * r) - y) - v * S1);
}
diff --git a/lib/libm/__sindf.c b/lib/libm/__sindf.c
index cf16370d..b6b9cf42 100644
--- a/lib/libm/__sindf.c
+++ b/lib/libm/__sindf.c
@@ -14,7 +14,9 @@
* ====================================================
*/
-#include "libm.h"
+#include "libm.h" // for __sindf
+
+#include <math.h> // for double_t
/* |sin(x)/x - s(x)| < 2**-37.5 (~[-4.89e-12, 4.824e-12]). */
static const double S1 = -0x15555554cbac77.0p-55, /* -0.166666666416265235595 */
diff --git a/lib/libm/__sinl.c b/lib/libm/__sinl.c
index 6b57783e..ecc23a1a 100644
--- a/lib/libm/__sinl.c
+++ b/lib/libm/__sinl.c
@@ -12,7 +12,9 @@
* ====================================================
*/
-#include "libm.h"
+#include "libm.h" // for __sinl
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
#if (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
#if LDBL_MANT_DIG == 64
@@ -35,8 +37,10 @@ static const double S2 = 0.0083333333333333332, /* 0x11111111111111.0p-59 */
S6 = 1.6059006598854211e-10, /* 0x161242b90243b5.0p-85 */
S7 = -7.6429779983024564e-13, /* -0x1ae42ebd1b2e00.0p-93 */
S8 = 2.6174587166648325e-15; /* 0x179372ea0b3f64.0p-101 */
-#define POLY(z) \
- (S2 + z * (S3 + z * (S4 + z * (S5 + z * (S6 + z * (S7 + z * S8))))))
+#define POLY(z) \
+ (S2 + \
+ (z) * (S3 + \
+ (z) * (S4 + (z) * (S5 + (z) * (S6 + (z) * (S7 + (z) * S8))))))
#elif LDBL_MANT_DIG == 113
/*
* ld128 version of __sin.c. See __sin.c for most comments.
diff --git a/lib/libm/__tan.c b/lib/libm/__tan.c
index 9fd6c41a..9abfff35 100644
--- a/lib/libm/__tan.c
+++ b/lib/libm/__tan.c
@@ -44,7 +44,10 @@
* = 1 - 2*(tan(y) - (tan(y)^2)/(1+tan(y)))
*/
-#include "libm.h"
+#include "libm.h" // for SET_LOW_WORD, GET_HIGH_WORD, __tan
+
+#include <math.h> // for double_t
+#include <stdint.h> // for uint32_t
static const double T[] = {
3.33333333333334091986e-01, /* 3FD55555, 55555563 */
diff --git a/lib/libm/__tandf.c b/lib/libm/__tandf.c
index 7219ed33..5bae8073 100644
--- a/lib/libm/__tandf.c
+++ b/lib/libm/__tandf.c
@@ -13,7 +13,9 @@
* ====================================================
*/
-#include "libm.h"
+#include "libm.h" // for __tandf
+
+#include <math.h> // for double_t
/* |tan(x)/x - t(x)| < 2**-25.5 (~[-2e-08, 2e-08]). */
static const double T[] = {
diff --git a/lib/libm/__tanl.c b/lib/libm/__tanl.c
index 7526735c..28167d02 100644
--- a/lib/libm/__tanl.c
+++ b/lib/libm/__tanl.c
@@ -11,7 +11,10 @@
* ====================================================
*/
-#include "libm.h"
+#include "libm.h" // for __tanl
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for fabsl
#if (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
#if LDBL_MANT_DIG == 64
@@ -44,14 +47,18 @@ static const double T9 = 0.021869488536312216, /* 0x1664f4882cc1c2.0p-58 */
T29 = 0.0000078293456938132840, /* 0x106b59141a6cb3.0p-69 */
T31 = -0.0000032609076735050182, /* -0x1b5abef3ba4b59.0p-71 */
T33 = 0.0000023261313142559411; /* 0x13835436c0c87f.0p-71 */
-#define RPOLY(w) \
- (T5 + \
- w * (T9 + \
- w * (T13 + \
- w * (T17 + w * (T21 + w * (T25 + w * (T29 + w * T33)))))))
-#define VPOLY(w) \
- (T7 + \
- w * (T11 + w * (T15 + w * (T19 + w * (T23 + w * (T27 + w * T31))))))
+#define RPOLY(w) \
+ (T5 + \
+ (w) * (T9 + (w) * (T13 + \
+ (w) * (T17 + \
+ (w) * (T21 + \
+ (w) * (T25 + \
+ (w) * (T29 + (w) * T33)))))))
+#define VPOLY(w) \
+ (T7 + \
+ (w) * (T11 + \
+ (w) * (T15 + \
+ (w) * (T19 + (w) * (T23 + (w) * (T27 + (w) * T31))))))
#elif LDBL_MANT_DIG == 113
/*
* ld128 version of __tan.c. See __tan.c for most comments.
diff --git a/lib/libm/acos.c b/lib/libm/acos.c
index cc798159..67c059af 100644
--- a/lib/libm/acos.c
+++ b/lib/libm/acos.c
@@ -33,7 +33,10 @@
* Function needed: sqrt
*/
-#include "libm.h"
+#include "libm.h" // for GET_HIGH_WORD, GET_LOW_WORD, SET_LOW_WORD
+
+#include <math.h> // for sqrt, acos, double_t
+#include <stdint.h> // for uint32_t
static const double pio2_hi = 1.57079632679489655800e+00, /* 0x3FF921FB,
0x54442D18 */
diff --git a/lib/libm/acosf.c b/lib/libm/acosf.c
index a428e8d6..51e5c5ea 100644
--- a/lib/libm/acosf.c
+++ b/lib/libm/acosf.c
@@ -13,7 +13,10 @@
* ====================================================
*/
-#include "libm.h"
+#include "libm.h" // for GET_FLOAT_WORD, SET_FLOAT_WORD
+
+#include <math.h> // for sqrtf, acosf, float_t
+#include <stdint.h> // for uint32_t
static const float pio2_hi = 1.5707962513e+00, /* 0x3fc90fda */
pio2_lo = 7.5497894159e-08, /* 0x33a22168 */
diff --git a/lib/libm/acosh.c b/lib/libm/acosh.c
index a53e01ed..cb4036e5 100644
--- a/lib/libm/acosh.c
+++ b/lib/libm/acosh.c
@@ -1,4 +1,6 @@
-#include "libm.h"
+#include <float.h> // for FLT_EVAL_METHOD
+#include <math.h> // for log, sqrt, acosh, log1p
+#include <stdint.h> // for uint64_t
#if FLT_EVAL_METHOD == 2
#undef sqrt
diff --git a/lib/libm/acoshf.c b/lib/libm/acoshf.c
index 515ca313..ddf87b7e 100644
--- a/lib/libm/acoshf.c
+++ b/lib/libm/acoshf.c
@@ -1,4 +1,6 @@
-#include "libm.h"
+#include <float.h> // for FLT_EVAL_METHOD
+#include <math.h> // for logf, sqrtf, acoshf, log1pf
+#include <stdint.h> // for uint32_t
#if FLT_EVAL_METHOD == 2
#undef sqrtf
diff --git a/lib/libm/acoshl.c b/lib/libm/acoshl.c
index f76c5b44..015dfc6a 100644
--- a/lib/libm/acoshl.c
+++ b/lib/libm/acoshl.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for ldshape, ldshape::(anonymous)
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for logl, sqrtl, acoshl, log1pl
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double acoshl(long double x)
diff --git a/lib/libm/acosl.c b/lib/libm/acosl.c
index f508a552..009df082 100644
--- a/lib/libm/acosl.c
+++ b/lib/libm/acosl.c
@@ -14,7 +14,11 @@
* Converted to long double by David Schultz <das@FreeBSD.ORG>.
*/
-#include "libm.h"
+#include "libm.h" // for ldshape, ldshape::(anonymous)
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for sqrtl, acosl
+#include <stdint.h> // for uint16_t
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double acosl(long double x)
@@ -22,9 +26,9 @@ long double acosl(long double x)
return acos(x);
}
#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-#include "__invtrigl.h"
+#include "__invtrigl.h" // for __invtrigl_R, pio2_hi, pio2_lo
#if LDBL_MANT_DIG == 64
-#define CLEARBOTTOM(u) (u.i.m &= -1ULL << 32)
+#define CLEARBOTTOM(u) ((u).i.m &= -1ULL << 32)
#elif LDBL_MANT_DIG == 113
#define CLEARBOTTOM(u) (u.i.lo = 0)
#endif
diff --git a/lib/libm/asin.c b/lib/libm/asin.c
index a7632829..eb669b87 100644
--- a/lib/libm/asin.c
+++ b/lib/libm/asin.c
@@ -39,7 +39,10 @@
*
*/
-#include "libm.h"
+#include "libm.h" // for GET_HIGH_WORD, GET_LOW_WORD, SET_LOW_WORD
+
+#include <math.h> // for asin, double_t, fabs, sqrt
+#include <stdint.h> // for uint32_t
static const double pio2_hi = 1.57079632679489655800e+00, /* 0x3FF921FB,
0x54442D18 */
diff --git a/lib/libm/asinf.c b/lib/libm/asinf.c
index 65ee2ae7..0175f4d5 100644
--- a/lib/libm/asinf.c
+++ b/lib/libm/asinf.c
@@ -12,7 +12,10 @@
* is preserved.
* ====================================================
*/
-#include "libm.h"
+#include "libm.h" // for GET_FLOAT_WORD
+
+#include <math.h> // for asinf, fabsf, float_t, sqrtf
+#include <stdint.h> // for uint32_t
static const double pio2 = 1.570796326794896558e+00;
@@ -52,7 +55,7 @@ float asinf(float x)
}
/* 1 > |x| >= 0.5 */
z = (1 - fabsf(x)) * 0.5f;
- s = sqrt(z);
+ s = sqrtf(z);
x = pio2 - 2 * (s + s * R(z));
if (hx >> 31)
return -x;
diff --git a/lib/libm/asinh.c b/lib/libm/asinh.c
index 196a81ef..f6018734 100644
--- a/lib/libm/asinh.c
+++ b/lib/libm/asinh.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for FORCE_EVAL
+
+#include <math.h> // for log, sqrt, asinh, log1p
+#include <stdint.h> // for uint64_t
/* asinh(x) = sign(x)*log(|x|+sqrt(x*x+1)) ~= x - x^3/6 + o(x^5) */
double asinh(double x)
diff --git a/lib/libm/asinhf.c b/lib/libm/asinhf.c
index 2f6c585b..72d3d232 100644
--- a/lib/libm/asinhf.c
+++ b/lib/libm/asinhf.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for FORCE_EVAL
+
+#include <math.h> // for logf, sqrtf, asinhf, log1pf
+#include <stdint.h> // for uint32_t
/* asinh(x) = sign(x)*log(|x|+sqrt(x*x+1)) ~= x - x^3/6 + o(x^5) */
float asinhf(float x)
diff --git a/lib/libm/asinhl.c b/lib/libm/asinhl.c
index 321f2a0f..8f8c2ab2 100644
--- a/lib/libm/asinhl.c
+++ b/lib/libm/asinhl.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for ldshape, ldshape::(anonymous), FORCE_EVAL
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for logl, sqrtl, asinhl, log1pl
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double asinhl(long double x)
diff --git a/lib/libm/asinl.c b/lib/libm/asinl.c
index 8dd0268c..7a5f6710 100644
--- a/lib/libm/asinl.c
+++ b/lib/libm/asinl.c
@@ -14,7 +14,11 @@
* Converted to long double by David Schultz <das@FreeBSD.ORG>.
*/
-#include "libm.h"
+#include "libm.h" // for ldshape, ldshape::(anonymous), FORCE_EVAL
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for asinl, fabsl, sqrtl
+#include <stdint.h> // for uint16_t
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double asinl(long double x)
@@ -22,10 +26,10 @@ long double asinl(long double x)
return asin(x);
}
#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-#include "__invtrigl.h"
+#include "__invtrigl.h" // for __invtrigl_R, pio2_hi, pio2_lo
#if LDBL_MANT_DIG == 64
-#define CLOSETO1(u) (u.i.m >> 56 >= 0xf7)
-#define CLEARBOTTOM(u) (u.i.m &= -1ULL << 32)
+#define CLOSETO1(u) ((u).i.m >> 56 >= 0xf7)
+#define CLEARBOTTOM(u) ((u).i.m &= -1ULL << 32)
#elif LDBL_MANT_DIG == 113
#define CLOSETO1(u) (u.i.top >= 0xee00)
#define CLEARBOTTOM(u) (u.i.lo = 0)
diff --git a/lib/libm/atan.c b/lib/libm/atan.c
index 6793af93..36d10d73 100644
--- a/lib/libm/atan.c
+++ b/lib/libm/atan.c
@@ -29,7 +29,10 @@
* to produce the hexadecimal values shown.
*/
-#include "libm.h"
+#include "libm.h" // for FORCE_EVAL, GET_HIGH_WORD
+
+#include <math.h> // for double_t, atan, fabs, isnan
+#include <stdint.h> // for uint32_t
static const double atanhi[] = {
4.63647609000806093515e-01, /* atan(0.5)hi 0x3FDDAC67, 0x0561BB4F */
diff --git a/lib/libm/atan2.c b/lib/libm/atan2.c
index 3298b6c4..912d9fb5 100644
--- a/lib/libm/atan2.c
+++ b/lib/libm/atan2.c
@@ -37,7 +37,10 @@
* to produce the hexadecimal values shown.
*/
-#include "libm.h"
+#include "libm.h" // for EXTRACT_WORDS
+
+#include <math.h> // for atan, atan2, fabs, isnan
+#include <stdint.h> // for uint32_t
static const double pi = 3.1415926535897931160E+00, /* 0x400921FB, 0x54442D18 */
pi_lo = 1.2246467991473531772E-16; /* 0x3CA1A626, 0x33145C07 */
diff --git a/lib/libm/atan2f.c b/lib/libm/atan2f.c
index 01f32d20..34e58db8 100644
--- a/lib/libm/atan2f.c
+++ b/lib/libm/atan2f.c
@@ -13,7 +13,10 @@
* ====================================================
*/
-#include "libm.h"
+#include "libm.h" // for GET_FLOAT_WORD
+
+#include <math.h> // for atanf, atan2f, fabsf, isnan
+#include <stdint.h> // for uint32_t
static const float pi = 3.1415927410e+00, /* 0x40490fdb */
pi_lo = -8.7422776573e-08; /* 0xb3bbbd2e */
diff --git a/lib/libm/atan2l.c b/lib/libm/atan2l.c
index f2f60986..ca47169a 100644
--- a/lib/libm/atan2l.c
+++ b/lib/libm/atan2l.c
@@ -15,7 +15,10 @@
* Converted to long double by David Schultz <das@FreeBSD.ORG>.
*/
-#include "libm.h"
+#include "libm.h" // for ldshape, ldshape::(anonymous)
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for atanl, atan2l, fabsl, isnan
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double atan2l(long double y, long double x)
@@ -23,7 +26,7 @@ long double atan2l(long double y, long double x)
return atan2(y, x);
}
#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-#include "__invtrigl.h"
+#include "__invtrigl.h" // for pio2_hi, pio2_lo
long double atan2l(long double y, long double x)
{
diff --git a/lib/libm/atanf.c b/lib/libm/atanf.c
index 48f18e30..74881a92 100644
--- a/lib/libm/atanf.c
+++ b/lib/libm/atanf.c
@@ -13,7 +13,10 @@
* ====================================================
*/
-#include "libm.h"
+#include "libm.h" // for FORCE_EVAL, GET_FLOAT_WORD
+
+#include <math.h> // for float_t, atanf, fabsf, isnan
+#include <stdint.h> // for uint32_t
static const float atanhi[] = {
4.6364760399e-01, /* atan(0.5)hi 0x3eed6338 */
diff --git a/lib/libm/atanh.c b/lib/libm/atanh.c
index 08a34d7e..ec0c7a61 100644
--- a/lib/libm/atanh.c
+++ b/lib/libm/atanh.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for FORCE_EVAL
+
+#include <math.h> // for log1p, atanh, double_t
+#include <stdint.h> // for uint64_t
/* atanh(x) = log((1+x)/(1-x))/2 = log1p(2x/(1-x))/2 ~= x + x^3/3 + o(x^5) */
double atanh(double x)
diff --git a/lib/libm/atanhf.c b/lib/libm/atanhf.c
index d1026974..b4591890 100644
--- a/lib/libm/atanhf.c
+++ b/lib/libm/atanhf.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for FORCE_EVAL
+
+#include <math.h> // for log1pf, atanhf, float_t
+#include <stdint.h> // for uint32_t
/* atanh(x) = log((1+x)/(1-x))/2 = log1p(2x/(1-x))/2 ~= x + x^3/3 + o(x^5) */
float atanhf(float x)
diff --git a/lib/libm/atanhl.c b/lib/libm/atanhl.c
index 8afd5a03..cc5351cb 100644
--- a/lib/libm/atanhl.c
+++ b/lib/libm/atanhl.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for ldshape, ldshape::(anonymous), FORCE_EVAL
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for log1pl, atanhl
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double atanhl(long double x)
diff --git a/lib/libm/atanl.c b/lib/libm/atanl.c
index c1c75c94..1f1bff44 100644
--- a/lib/libm/atanl.c
+++ b/lib/libm/atanl.c
@@ -14,7 +14,10 @@
* Converted to long double by David Schultz <das@FreeBSD.ORG>.
*/
-#include "libm.h"
+#include "libm.h" // for ldshape, ldshape::(anonymous), FORCE_EVAL
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for atanl, fabsl, isnan
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double atanl(long double x)
@@ -24,7 +27,7 @@ long double atanl(long double x)
#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
#if LDBL_MANT_DIG == 64
-#define EXPMAN(u) ((u.i.se & 0x7fff) << 8 | (u.i.m >> 55 & 0xff))
+#define EXPMAN(u) (((u).i.se & 0x7fff) << 8 | ((u).i.m >> 55 & 0xff))
static const long double atanhi[] = {
4.63647609000806116202e-01L,
diff --git a/lib/libm/cabs.c b/lib/libm/cabs.c
index 6bbcd878..79452553 100644
--- a/lib/libm/cabs.c
+++ b/lib/libm/cabs.c
@@ -1,5 +1,5 @@
-#include <math.h>
-#include <complex.h>
+#include <complex.h> // for cabs, cimag, creal, complex
+#include <math.h> // for hypot
double cabs(double complex z)
{
diff --git a/lib/libm/cabsf.c b/lib/libm/cabsf.c
index 667ba935..5eee73bc 100644
--- a/lib/libm/cabsf.c
+++ b/lib/libm/cabsf.c
@@ -1,5 +1,5 @@
-#include <math.h>
-#include <complex.h>
+#include <complex.h> // for cabsf, cimagf, crealf, complex
+#include <math.h> // for hypotf
float cabsf(float complex z)
{
diff --git a/lib/libm/cabsl.c b/lib/libm/cabsl.c
index 42d11909..e3878ec4 100644
--- a/lib/libm/cabsl.c
+++ b/lib/libm/cabsl.c
@@ -1,5 +1,5 @@
-#include <math.h>
-#include <complex.h>
+#include <complex.h> // for cabsl, cimagl, creall, complex
+#include <math.h> // for hypotl
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double cabsl(long double complex z)
diff --git a/lib/libm/cacos.c b/lib/libm/cacos.c
index 1248e72f..b472b778 100644
--- a/lib/libm/cacos.c
+++ b/lib/libm/cacos.c
@@ -1,5 +1,5 @@
-#include <math.h>
-#include <complex.h>
+#include <complex.h> // for complex, cacos, casin, cimag, creal, I
+#include <math.h> // for M_PI_2
double complex cacos(double complex z)
{
diff --git a/lib/libm/cacosf.c b/lib/libm/cacosf.c
index f44f0067..12f86362 100644
--- a/lib/libm/cacosf.c
+++ b/lib/libm/cacosf.c
@@ -1,5 +1,5 @@
-#include <math.h>
-#include <complex.h>
+#include <complex.h> // for complex, cacosf, casinf, cimagf, crealf, I
+#include <math.h> // for M_PI_2
float complex cacosf(float complex z)
{
diff --git a/lib/libm/cacosh.c b/lib/libm/cacosh.c
index 00f0e736..bf33b7c7 100644
--- a/lib/libm/cacosh.c
+++ b/lib/libm/cacosh.c
@@ -1,4 +1,4 @@
-#include <complex.h>
+#include <complex.h> // for csqrt, cacosh, clog, complex
double complex cacosh(double complex z)
{
diff --git a/lib/libm/cacoshf.c b/lib/libm/cacoshf.c
index 63d23257..0a290396 100644
--- a/lib/libm/cacoshf.c
+++ b/lib/libm/cacoshf.c
@@ -1,4 +1,4 @@
-#include <complex.h>
+#include <complex.h> // for csqrtf, cacoshf, clogf, complex
float complex cacoshf(float complex z)
{
diff --git a/lib/libm/cacoshl.c b/lib/libm/cacoshl.c
index abe906ef..058f85da 100644
--- a/lib/libm/cacoshl.c
+++ b/lib/libm/cacoshl.c
@@ -1,4 +1,4 @@
-#include <complex.h>
+#include <complex.h> // for csqrtl, cacoshl, clogl, complex
long double complex cacoshl(long double complex z)
{
diff --git a/lib/libm/cacosl.c b/lib/libm/cacosl.c
index c56076b3..484ef699 100644
--- a/lib/libm/cacosl.c
+++ b/lib/libm/cacosl.c
@@ -1,5 +1,5 @@
-#include <math.h>
-#include <complex.h>
+#include <complex.h> // for complex, cacosl, casinl, cimagl, creall, I
+#include <math.h> // for M_PI_2
long double complex cacosl(long double complex z)
{
diff --git a/lib/libm/carg.c b/lib/libm/carg.c
index 634ace3d..12cbd1a3 100644
--- a/lib/libm/carg.c
+++ b/lib/libm/carg.c
@@ -1,5 +1,5 @@
-#include <math.h>
-#include <complex.h>
+#include <complex.h> // for carg, complex
+#include <math.h> // for atan2
double carg(double complex z)
{
diff --git a/lib/libm/cargf.c b/lib/libm/cargf.c
index 138f19c3..f7cee9dc 100644
--- a/lib/libm/cargf.c
+++ b/lib/libm/cargf.c
@@ -1,5 +1,5 @@
-#include <math.h>
-#include <complex.h>
+#include <complex.h> // for cargf, complex
+#include <math.h> // for atan2f
float cargf(float complex z)
{
diff --git a/lib/libm/cargl.c b/lib/libm/cargl.c
index 9469bf3b..255affbf 100644
--- a/lib/libm/cargl.c
+++ b/lib/libm/cargl.c
@@ -1,5 +1,5 @@
-#include <math.h>
-#include <complex.h>
+#include <complex.h> // for cargl, complex
+#include <math.h> // for atan2l
long double cargl(long double complex z)
{
diff --git a/lib/libm/casin.c b/lib/libm/casin.c
index e23cdd15..f163dc02 100644
--- a/lib/libm/casin.c
+++ b/lib/libm/casin.c
@@ -1,4 +1,4 @@
-#include <complex.h>
+#include <complex.h> // for I, cimag, creal, complex, casin, clog, csqrt
double complex casin(double complex z)
{
diff --git a/lib/libm/casinf.c b/lib/libm/casinf.c
index b0887029..797ea94b 100644
--- a/lib/libm/casinf.c
+++ b/lib/libm/casinf.c
@@ -1,4 +1,4 @@
-#include <complex.h>
+#include <complex.h> // for I, cimagf, crealf, complex, casinf, clogf, csqrtf
float complex casinf(float complex z)
{
diff --git a/lib/libm/casinh.c b/lib/libm/casinh.c
index 75b1b5c9..69b73a39 100644
--- a/lib/libm/casinh.c
+++ b/lib/libm/casinh.c
@@ -1,4 +1,4 @@
-#include <complex.h>
+#include <complex.h> // for I, casin, casinh, complex
double complex casinh(double complex z)
{
diff --git a/lib/libm/casinhf.c b/lib/libm/casinhf.c
index b35ea8a2..d5e3391a 100644
--- a/lib/libm/casinhf.c
+++ b/lib/libm/casinhf.c
@@ -1,4 +1,4 @@
-#include <complex.h>
+#include <complex.h> // for I, casinf, casinhf, complex
float complex casinhf(float complex z)
{
diff --git a/lib/libm/casinhl.c b/lib/libm/casinhl.c
index 73c80203..52d84800 100644
--- a/lib/libm/casinhl.c
+++ b/lib/libm/casinhl.c
@@ -1,4 +1,4 @@
-#include <complex.h>
+#include <complex.h> // for I, casinhl, casinl, complex
long double complex casinhl(long double complex z)
{
diff --git a/lib/libm/casinl.c b/lib/libm/casinl.c
index 45c19582..07061cc4 100644
--- a/lib/libm/casinl.c
+++ b/lib/libm/casinl.c
@@ -1,4 +1,4 @@
-#include <complex.h>
+#include <complex.h> // for I, cimagl, creall, complex, casinl, clogl, csqrtl
long double complex casinl(long double complex z)
{
diff --git a/lib/libm/catan.c b/lib/libm/catan.c
index b6880811..f216394a 100644
--- a/lib/libm/catan.c
+++ b/lib/libm/catan.c
@@ -1,5 +1,8 @@
-#include <float.h>
-#include "__complex.h"
+#include "__complex.h" // for redupi
+
+#include <complex.h> // for complex, I, catan, cimag, creal
+#include <float.h> // for DBL_MAX
+#include <math.h> // for atan2, log
double complex catan(double complex z)
{
diff --git a/lib/libm/catanf.c b/lib/libm/catanf.c
index 16d480e0..89f75a9e 100644
--- a/lib/libm/catanf.c
+++ b/lib/libm/catanf.c
@@ -1,5 +1,8 @@
-#include <float.h>
-#include "__complex.h"
+#include "__complex.h" // for redupif
+
+#include <complex.h> // for complex, I, catanf, cimagf, crealf
+#include <float.h> // for FLT_MAX
+#include <math.h> // for atan2f, logf
float complex catanf(float complex z)
{
diff --git a/lib/libm/catanh.c b/lib/libm/catanh.c
index 5cfc4fc0..739cba4c 100644
--- a/lib/libm/catanh.c
+++ b/lib/libm/catanh.c
@@ -1,4 +1,4 @@
-#include <complex.h>
+#include <complex.h> // for I, catan, catanh, complex
double complex catanh(double complex z)
{
diff --git a/lib/libm/catanhf.c b/lib/libm/catanhf.c
index 0f16fc25..b4536225 100644
--- a/lib/libm/catanhf.c
+++ b/lib/libm/catanhf.c
@@ -1,4 +1,4 @@
-#include <complex.h>
+#include <complex.h> // for I, catanf, catanhf, complex
float complex catanhf(float complex z)
{
diff --git a/lib/libm/catanhl.c b/lib/libm/catanhl.c
index 1fd4275b..4c03e10a 100644
--- a/lib/libm/catanhl.c
+++ b/lib/libm/catanhl.c
@@ -1,4 +1,4 @@
-#include <complex.h>
+#include <complex.h> // for I, catanhl, catanl, complex
long double complex catanhl(long double complex z)
{
diff --git a/lib/libm/catanl.c b/lib/libm/catanl.c
index 949dc3d9..58b14a3c 100644
--- a/lib/libm/catanl.c
+++ b/lib/libm/catanl.c
@@ -1,5 +1,8 @@
-#include <float.h>
-#include "__complex.h"
+#include "__complex.h" // for redupil
+
+#include <complex.h> // for complex, I, catanl, cimagl, creall
+#include <float.h> // for LDBL_MAX
+#include <math.h> // for atan2l, logl
long double complex catanl(long double complex z)
{
diff --git a/lib/libm/cbrt.c b/lib/libm/cbrt.c
index 9f54517d..d583b062 100644
--- a/lib/libm/cbrt.c
+++ b/lib/libm/cbrt.c
@@ -15,8 +15,8 @@
* Return cube root of x
*/
-#include <math.h>
-#include <stdint.h>
+#include <math.h> // for double_t, cbrt
+#include <stdint.h> // for uint32_t, uint64_t
static const uint32_t B1 = 715094163, /* B1 = (1023-1023/3-0.03306235651)*2**20
*/
diff --git a/lib/libm/cbrtf.c b/lib/libm/cbrtf.c
index c394310d..f35aae33 100644
--- a/lib/libm/cbrtf.c
+++ b/lib/libm/cbrtf.c
@@ -17,8 +17,8 @@
* Return cube root of x
*/
-#include <math.h>
-#include <stdint.h>
+#include <math.h> // for double_t, cbrtf
+#include <stdint.h> // for uint32_t
static const unsigned B1 = 709958130, /* B1 = (127-127.0/3-0.03306235651)*2**23
*/
diff --git a/lib/libm/cbrtl.c b/lib/libm/cbrtl.c
index 12c82f03..cad8f153 100644
--- a/lib/libm/cbrtl.c
+++ b/lib/libm/cbrtl.c
@@ -15,7 +15,11 @@
* and David A. Schultz.
*/
-#include "libm.h"
+#include "libm.h" // for ldshape, ldshape::(anonymous)
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for double_t, cbrtl, float_t
+#include <stdint.h> // for uint32_t
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double cbrtl(long double x)
diff --git a/lib/libm/ccos.c b/lib/libm/ccos.c
index d5a8600d..331c5c49 100644
--- a/lib/libm/ccos.c
+++ b/lib/libm/ccos.c
@@ -1,6 +1,7 @@
-#include <math.h>
-#include <complex.h>
-#include "__complex.h"
+#include "__complex.h" // for cchsh
+
+#include <complex.h> // for creal, ccos, cimag, complex, I
+#include <math.h> // for cos, sin
double complex ccos(double complex z)
{
diff --git a/lib/libm/ccosf.c b/lib/libm/ccosf.c
index 8d4a8761..331c5c49 100644
--- a/lib/libm/ccosf.c
+++ b/lib/libm/ccosf.c
@@ -1,4 +1,7 @@
-#include "__complex.h"
+#include "__complex.h" // for cchsh
+
+#include <complex.h> // for creal, ccos, cimag, complex, I
+#include <math.h> // for cos, sin
double complex ccos(double complex z)
{
diff --git a/lib/libm/ccosh.c b/lib/libm/ccosh.c
index 9cfff54a..c96e76b7 100644
--- a/lib/libm/ccosh.c
+++ b/lib/libm/ccosh.c
@@ -1,5 +1,5 @@
-#include <math.h>
-#include <complex.h>
+#include <complex.h> // for ccosh, cimag, complex, creal, I
+#include <math.h> // for cos, cosh, sin, sinh
double complex ccosh(double complex z)
{
diff --git a/lib/libm/ccoshf.c b/lib/libm/ccoshf.c
index 12fc7e6d..f2a4d7ef 100644
--- a/lib/libm/ccoshf.c
+++ b/lib/libm/ccoshf.c
@@ -1,5 +1,5 @@
-#include <math.h>
-#include <complex.h>
+#include <complex.h> // for ccoshf, cimagf, complex, crealf, I
+#include <math.h> // for cosf, coshf, sinf, sinhf
float complex ccoshf(float complex z)
{
diff --git a/lib/libm/ccoshl.c b/lib/libm/ccoshl.c
index ba680068..8e81506d 100644
--- a/lib/libm/ccoshl.c
+++ b/lib/libm/ccoshl.c
@@ -1,5 +1,5 @@
-#include <math.h>
-#include <complex.h>
+#include <complex.h> // for ccoshl, cimagl, complex, creall, I
+#include <math.h> // for coshl, cosl, sinhl, sinl
long double complex ccoshl(long double complex z)
{
diff --git a/lib/libm/ccosl.c b/lib/libm/ccosl.c
index ee2a3fc0..b6aa2021 100644
--- a/lib/libm/ccosl.c
+++ b/lib/libm/ccosl.c
@@ -1,4 +1,7 @@
-#include "__complex.h"
+#include "__complex.h" // for cchshl
+
+#include <complex.h> // for creall, ccosl, cimagl, complex, I
+#include <math.h> // for cosl, sinl
long double complex ccosl(long double complex z)
{
diff --git a/lib/libm/ceil.c b/lib/libm/ceil.c
index fdf502ed..29f67598 100644
--- a/lib/libm/ceil.c
+++ b/lib/libm/ceil.c
@@ -1,4 +1,8 @@
-#include "libm.h"
+#include "libm.h" // for FORCE_EVAL
+
+#include <float.h> // for DBL_EPSILON, FLT_EVAL_METHOD
+#include <math.h> // for ceil, double_t
+#include <stdint.h> // for uint64_t
#if FLT_EVAL_METHOD == 0 || FLT_EVAL_METHOD == 1
#define EPS DBL_EPSILON
diff --git a/lib/libm/ceilf.c b/lib/libm/ceilf.c
index 1d9ffd14..49e4e140 100644
--- a/lib/libm/ceilf.c
+++ b/lib/libm/ceilf.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for FORCE_EVAL
+
+#include <math.h> // for ceilf
+#include <stdint.h> // for uint32_t
float ceilf(float x)
{
diff --git a/lib/libm/ceill.c b/lib/libm/ceill.c
index a9e8f28f..1623faac 100644
--- a/lib/libm/ceill.c
+++ b/lib/libm/ceill.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for ldshape, ldshape::(anonymous), FORCE_EVAL
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP, LDBL_EPSILON
+#include <math.h> // for ceill
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double ceill(long double x)
diff --git a/lib/libm/cexp.c b/lib/libm/cexp.c
index b8a4b903..1b653aa9 100644
--- a/lib/libm/cexp.c
+++ b/lib/libm/cexp.c
@@ -1,5 +1,5 @@
-#include <math.h>
-#include <complex.h>
+#include <complex.h> // for cexp, cimag, complex, creal, I
+#include <math.h> // for cos, exp, sin
double complex cexp(double complex z)
{
diff --git a/lib/libm/cexpl.c b/lib/libm/cexpl.c
index 0d3bdfb6..6a83dd84 100644
--- a/lib/libm/cexpl.c
+++ b/lib/libm/cexpl.c
@@ -1,5 +1,5 @@
-#include <math.h>
-#include <complex.h>
+#include <complex.h> // for cexpl, cimagl, complex, creall, I
+#include <math.h> // for cosl, expl, sinl
long double complex cexpl(long double complex z)
{
diff --git a/lib/libm/cexprf.c b/lib/libm/cexprf.c
index 27c5048d..41d98b1f 100644
--- a/lib/libm/cexprf.c
+++ b/lib/libm/cexprf.c
@@ -1,5 +1,5 @@
-#include <math.h>
-#include <complex.h>
+#include <complex.h> // for cexpf, cimagf, complex, crealf, I
+#include <math.h> // for cosf, expf, sinf
float complex cexpf(float complex z)
{
diff --git a/lib/libm/cimag.c b/lib/libm/cimag.c
index 88b5fd58..a52f3962 100644
--- a/lib/libm/cimag.c
+++ b/lib/libm/cimag.c
@@ -1,5 +1,6 @@
-#include <complex.h>
-#include "__complex.h"
+#include "__complex.h" // for IMAG_PART, double_complex
+
+#include <complex.h> // for cimag, complex
double cimag(double complex z)
{
diff --git a/lib/libm/cimagf.c b/lib/libm/cimagf.c
index 465dce6f..5fe56e60 100644
--- a/lib/libm/cimagf.c
+++ b/lib/libm/cimagf.c
@@ -1,4 +1,6 @@
-#include "__complex.h"
+#include "__complex.h" // for IMAG_PART, float_complex
+
+#include <complex.h> // for cimagf, complex
float cimagf(float complex z)
{
diff --git a/lib/libm/cimagl.c b/lib/libm/cimagl.c
index 5e63ab5d..553f7da1 100644
--- a/lib/libm/cimagl.c
+++ b/lib/libm/cimagl.c
@@ -1,4 +1,6 @@
-#include "__complex.h"
+#include "__complex.h" // for IMAG_PART, long_double_complex
+
+#include <complex.h> // for cimagl, complex
long double cimagl(long double complex z)
{
diff --git a/lib/libm/clog.c b/lib/libm/clog.c
index a119934b..0b83a4ea 100644
--- a/lib/libm/clog.c
+++ b/lib/libm/clog.c
@@ -1,4 +1,5 @@
-#include "__complex.h"
+#include <complex.h> // for complex, cabs, cimag, clog, creal, I
+#include <math.h> // for atan2, log
double complex clog(double complex z)
{
diff --git a/lib/libm/clog10.c b/lib/libm/clog10.c
index a1db1663..6e36572f 100644
--- a/lib/libm/clog10.c
+++ b/lib/libm/clog10.c
@@ -1,5 +1,7 @@
-#include <math.h>
-#include "__complex.h"
+#include "__complex.h" // for M_IVLN10
+
+#include <complex.h> // for complex, cabs, cimag, creal, I
+#include <math.h> // for atan2, log10
double complex clog10(double complex z)
{
diff --git a/lib/libm/clog10f.c b/lib/libm/clog10f.c
index d2994b0d..855069a3 100644
--- a/lib/libm/clog10f.c
+++ b/lib/libm/clog10f.c
@@ -1,4 +1,7 @@
-#include "__complex.h"
+#include "__complex.h" // for M_IVLN10
+
+#include <complex.h> // for cabsf, cimagf, complex, crealf, I
+#include <math.h> // for atan2f, log10f
float complex clog10f(float complex z)
{
diff --git a/lib/libm/clog10l.c b/lib/libm/clog10l.c
index dde228e2..cd4ddcb8 100644
--- a/lib/libm/clog10l.c
+++ b/lib/libm/clog10l.c
@@ -1,4 +1,5 @@
-#include "__complex.h"
+#include <complex.h> // for complex, cabsl, cimagl, creall, I
+#include <math.h> // for atan2l, log10l
long double complex clog10l(long double complex z)
{
diff --git a/lib/libm/clogf.c b/lib/libm/clogf.c
index f669c7a4..d2f8df33 100644
--- a/lib/libm/clogf.c
+++ b/lib/libm/clogf.c
@@ -1,4 +1,5 @@
-#include "__complex.h"
+#include <complex.h> // for cabsf, cimagf, clogf, complex, crealf, I
+#include <math.h> // for atan2f, logf
float complex clogf(float complex z)
{
diff --git a/lib/libm/clogl.c b/lib/libm/clogl.c
index f7e0bf0b..67bf4bb7 100644
--- a/lib/libm/clogl.c
+++ b/lib/libm/clogl.c
@@ -1,4 +1,5 @@
-#include "__complex.h"
+#include <complex.h> // for complex, cabsl, cimagl, clogl, creall, I
+#include <math.h> // for atan2l, logl
long double complex clogl(long double complex z)
{
diff --git a/lib/libm/conj.c b/lib/libm/conj.c
index 5982db3f..614e7bd2 100644
--- a/lib/libm/conj.c
+++ b/lib/libm/conj.c
@@ -1,4 +1,6 @@
-#include "__complex.h"
+#include "__complex.h" // for IMAG_PART, double_complex
+
+#include <complex.h> // for complex, conj
double complex conj(double complex z)
{
diff --git a/lib/libm/conjf.c b/lib/libm/conjf.c
index d7c6f4cd..31399fb7 100644
--- a/lib/libm/conjf.c
+++ b/lib/libm/conjf.c
@@ -1,4 +1,6 @@
-#include "__complex.h"
+#include "__complex.h" // for IMAG_PART, float_complex
+
+#include <complex.h> // for complex, conjf
float complex conjf(float complex z)
{
diff --git a/lib/libm/conjl.c b/lib/libm/conjl.c
index 4e633057..7371c11d 100644
--- a/lib/libm/conjl.c
+++ b/lib/libm/conjl.c
@@ -1,4 +1,6 @@
-#include "__complex.h"
+#include "__complex.h" // for IMAG_PART, long_double_complex
+
+#include <complex.h> // for complex, conjl
long double complex conjl(long double complex z)
{
diff --git a/lib/libm/copysign.c b/lib/libm/copysign.c
index 26982cea..58be427e 100644
--- a/lib/libm/copysign.c
+++ b/lib/libm/copysign.c
@@ -1,4 +1,5 @@
-#include "libm.h"
+#include <math.h> // for copysign
+#include <stdint.h> // for uint64_t
double copysign(double x, double y)
{
diff --git a/lib/libm/copysignf.c b/lib/libm/copysignf.c
index d71c9a5f..ee11604b 100644
--- a/lib/libm/copysignf.c
+++ b/lib/libm/copysignf.c
@@ -1,5 +1,5 @@
-#include <math.h>
-#include <stdint.h>
+#include <math.h> // for copysignf
+#include <stdint.h> // for uint32_t
float copysignf(float x, float y)
{
diff --git a/lib/libm/copysignl.c b/lib/libm/copysignl.c
index e5e40285..b0fd6b36 100644
--- a/lib/libm/copysignl.c
+++ b/lib/libm/copysignl.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for ldshape, ldshape::(anonymous)
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for copysignl
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double copysignl(long double x, long double y)
diff --git a/lib/libm/cos.c b/lib/libm/cos.c
index e3b3a6fe..251ed66a 100644
--- a/lib/libm/cos.c
+++ b/lib/libm/cos.c
@@ -40,7 +40,10 @@
* TRIG(x) returns trig(x) nearly rounded
*/
-#include "libm.h"
+#include "libm.h" // for __cos, __sin, __rem_pio2, FORCE_EVAL, GET_HIGH_WORD
+
+#include <math.h> // for cos
+#include <stdint.h> // for uint32_t
double cos(double x)
{
diff --git a/lib/libm/cosf.c b/lib/libm/cosf.c
index d49dc0ac..f82b68de 100644
--- a/lib/libm/cosf.c
+++ b/lib/libm/cosf.c
@@ -14,7 +14,10 @@
* ====================================================
*/
-#include "libm.h"
+#include "libm.h" // for __sindf, __cosdf, __rem_pio2f, FORCE_EVAL, GET_F...
+
+#include <math.h> // for M_PI_2, cosf
+#include <stdint.h> // for uint32_t
/* Small multiples of pi/2 rounded to double precision. */
static const double c1pio2 = 1 * M_PI_2, /* 0x3FF921FB, 0x54442D18 */
@@ -43,22 +46,16 @@ float cosf(float x)
if (ix <= 0x407b53d1) { /* |x| ~<= 5*pi/4 */
if (ix > 0x4016cbe3) /* |x| ~> 3*pi/4 */
return -__cosdf(sign ? x + c2pio2 : x - c2pio2);
- else {
- if (sign)
- return __sindf(x + c1pio2);
- else
- return __sindf(c1pio2 - x);
- }
+ if (sign)
+ return __sindf(x + c1pio2);
+ return __sindf(c1pio2 - x);
}
if (ix <= 0x40e231d5) { /* |x| ~<= 9*pi/4 */
if (ix > 0x40afeddf) /* |x| ~> 7*pi/4 */
return __cosdf(sign ? x + c4pio2 : x - c4pio2);
- else {
- if (sign)
- return __sindf(-x - c3pio2);
- else
- return __sindf(x - c3pio2);
- }
+ if (sign)
+ return __sindf(-x - c3pio2);
+ return __sindf(x - c3pio2);
}
/* cos(Inf or NaN) is NaN */
diff --git a/lib/libm/cosh.c b/lib/libm/cosh.c
index 7684d2fa..3dc5c618 100644
--- a/lib/libm/cosh.c
+++ b/lib/libm/cosh.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for __expo2, FORCE_EVAL
+
+#include <math.h> // for cosh, exp, expm1
+#include <stdint.h> // for uint64_t, uint32_t
/* cosh(x) = (exp(x) + 1/exp(x))/2
* = 1 + 0.5*(exp(x)-1)*(exp(x)-1)/exp(x)
diff --git a/lib/libm/coshf.c b/lib/libm/coshf.c
index 451e6928..e29a670f 100644
--- a/lib/libm/coshf.c
+++ b/lib/libm/coshf.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for __expo2f, FORCE_EVAL
+
+#include <math.h> // for coshf, expf, expm1f
+#include <stdint.h> // for uint32_t
float coshf(float x)
{
diff --git a/lib/libm/coshl.c b/lib/libm/coshl.c
index d1eb74ae..538b192f 100644
--- a/lib/libm/coshl.c
+++ b/lib/libm/coshl.c
@@ -1,4 +1,8 @@
-#include "libm.h"
+#include "libm.h" // for ldshape, ldshape::(anonymous), FORCE_EVAL
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for expl, coshl, expm1l
+#include <stdint.h> // for uint32_t
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double coshl(long double x)
diff --git a/lib/libm/cosl.c b/lib/libm/cosl.c
index 08e0d997..19f249f1 100644
--- a/lib/libm/cosl.c
+++ b/lib/libm/cosl.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for __cosl, ldshape, __sinl, ldshape::(anonymous)
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for cosl, M_PI_4
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double cosl(long double x)
diff --git a/lib/libm/cpow.c b/lib/libm/cpow.c
index d4aff129..885421ee 100644
--- a/lib/libm/cpow.c
+++ b/lib/libm/cpow.c
@@ -1,4 +1,5 @@
-#include "__complex.h"
+#include <complex.h> // for complex, I, cabs, carg, cimag, cpow, creal
+#include <math.h> // for cos, exp, log, pow, sin
double complex cpow(double complex a, double complex z)
{
diff --git a/lib/libm/cpowf.c b/lib/libm/cpowf.c
index 9bab4e8e..b63c6969 100644
--- a/lib/libm/cpowf.c
+++ b/lib/libm/cpowf.c
@@ -1,4 +1,5 @@
-#include "__complex.h"
+#include <complex.h> // for complex, I, cabsf, cargf, cimagf, cpowf, crealf
+#include <math.h> // for cosf, expf, logf, powf, sinf
float complex cpowf(float complex a, float complex z)
{
diff --git a/lib/libm/cpowl.c b/lib/libm/cpowl.c
index b7471f0a..aa6141f8 100644
--- a/lib/libm/cpowl.c
+++ b/lib/libm/cpowl.c
@@ -1,4 +1,5 @@
-#include "__complex.h"
+#include <complex.h> // for complex, I, cabsl, cargl, cimagl, cpowl, creall
+#include <math.h> // for cosl, expl, logl, powl, sinl
long double complex cpowl(long double complex a, long double complex z)
{
diff --git a/lib/libm/cproj.c b/lib/libm/cproj.c
index db16721f..d2db8af0 100644
--- a/lib/libm/cproj.c
+++ b/lib/libm/cproj.c
@@ -1,4 +1,7 @@
-#include "__complex.h"
+#include "__complex.h" // for IMAG_PART, REAL_PART, double_complex
+
+#include <complex.h> // for cimag, complex, cproj, creal
+#include <math.h> // for copysign, isinf, INFINITY
double complex cproj(double complex z)
{
diff --git a/lib/libm/cprojl.c b/lib/libm/cprojl.c
index 80c675ca..b5035230 100644
--- a/lib/libm/cprojl.c
+++ b/lib/libm/cprojl.c
@@ -1,4 +1,7 @@
-#include "__complex.h"
+#include "__complex.h" // for IMAG_PART, REAL_PART, long_double_complex
+
+#include <complex.h> // for cimagl, complex, cprojl, creall
+#include <math.h> // for copysignl, isinf, INFINITY
long double complex cprojl(long double complex z)
{
diff --git a/lib/libm/creal.c b/lib/libm/creal.c
index 03ec4c28..109a40bb 100644
--- a/lib/libm/creal.c
+++ b/lib/libm/creal.c
@@ -1,4 +1,6 @@
-#include "__complex.h"
+#include "__complex.h" // for REAL_PART, double_complex
+
+#include <complex.h> // for creal, complex
double creal(double complex z)
{
diff --git a/lib/libm/crealf.c b/lib/libm/crealf.c
index e9b07f57..c1c1a6a1 100644
--- a/lib/libm/crealf.c
+++ b/lib/libm/crealf.c
@@ -1,4 +1,6 @@
-#include "__complex.h"
+#include "__complex.h" // for REAL_PART, float_complex
+
+#include <complex.h> // for crealf, complex
float crealf(float complex z)
{
diff --git a/lib/libm/creall.c b/lib/libm/creall.c
index 4a340485..b6ce7ff0 100644
--- a/lib/libm/creall.c
+++ b/lib/libm/creall.c
@@ -1,4 +1,6 @@
-#include "__complex.h"
+#include "__complex.h" // for REAL_PART, long_double_complex
+
+#include <complex.h> // for creall, complex
long double creall(long double complex z)
{
diff --git a/lib/libm/csin.c b/lib/libm/csin.c
index 1299f10a..7c9b3b46 100644
--- a/lib/libm/csin.c
+++ b/lib/libm/csin.c
@@ -1,4 +1,7 @@
-#include "__complex.h"
+#include "__complex.h" // for cchsh
+
+#include <complex.h> // for creal, complex, cimag, csin, I
+#include <math.h> // for cos, sin
double complex csin(double complex z)
{
diff --git a/lib/libm/csinf.c b/lib/libm/csinf.c
index 34d072b8..fb7c971b 100644
--- a/lib/libm/csinf.c
+++ b/lib/libm/csinf.c
@@ -1,4 +1,7 @@
-#include "__complex.h"
+#include "__complex.h" // for cchshf
+
+#include <complex.h> // for crealf, cimagf, complex, csinf, I
+#include <math.h> // for cosf, sinf
float complex csinf(float complex z)
{
diff --git a/lib/libm/csinh.c b/lib/libm/csinh.c
index f03b61c0..276bd3a6 100644
--- a/lib/libm/csinh.c
+++ b/lib/libm/csinh.c
@@ -1,4 +1,5 @@
-#include "__complex.h"
+#include <complex.h> // for complex, cimag, creal, csinh, I
+#include <math.h> // for cos, cosh, sin, sinh
double complex csinh(double complex z)
{
diff --git a/lib/libm/csinhf.c b/lib/libm/csinhf.c
index 695f170e..6f786284 100644
--- a/lib/libm/csinhf.c
+++ b/lib/libm/csinhf.c
@@ -1,4 +1,5 @@
-#include "__complex.h"
+#include <complex.h> // for cimagf, complex, crealf, csinhf, I
+#include <math.h> // for cosf, coshf, sinf, sinhf
float complex csinhf(float complex z)
{
diff --git a/lib/libm/csinhl.c b/lib/libm/csinhl.c
index 3b840339..a8a2e4f3 100644
--- a/lib/libm/csinhl.c
+++ b/lib/libm/csinhl.c
@@ -1,4 +1,5 @@
-#include "__complex.h"
+#include <complex.h> // for complex, cimagl, creall, csinhl, I
+#include <math.h> // for coshl, cosl, sinhl, sinl
long double complex csinhl(long double complex z)
{
diff --git a/lib/libm/csinl.c b/lib/libm/csinl.c
index df049bcc..9793d4ad 100644
--- a/lib/libm/csinl.c
+++ b/lib/libm/csinl.c
@@ -1,4 +1,7 @@
-#include "__complex.h"
+#include "__complex.h" // for cchshl
+
+#include <complex.h> // for creall, complex, cimagl, csinl, I
+#include <math.h> // for cosl, sinl
long double complex csinl(long double complex z)
{
diff --git a/lib/libm/csqrt.c b/lib/libm/csqrt.c
index e98cb7c6..77d61ec2 100644
--- a/lib/libm/csqrt.c
+++ b/lib/libm/csqrt.c
@@ -1,4 +1,5 @@
-#include "__complex.h"
+#include <complex.h> // for complex, I, cabs, cimag, creal, csqrt
+#include <math.h> // for fabs, sqrt
double complex csqrt(double complex z)
{
@@ -10,15 +11,13 @@ double complex csqrt(double complex z)
if (y == 0.0) {
if (x == 0.0) {
return 0.0 + y * (double complex)I;
- } else {
- r = fabs(x);
- r = sqrt(r);
- if (x < 0.0) {
- return 0.0 + r * (double complex)I;
- } else {
- return r + y * (double complex)I;
- }
}
+ r = fabs(x);
+ r = sqrt(r);
+ if (x < 0.0) {
+ return 0.0 + r * (double complex)I;
+ }
+ return r + y * (double complex)I;
}
if (x == 0.0) {
@@ -27,8 +26,7 @@ double complex csqrt(double complex z)
if (y > 0)
return r + r * (double complex)I;
- else
- return r - r * (double complex)I;
+ return r - r * (double complex)I;
}
if ((fabs(x) > 4.0) || (fabs(y) > 4.0)) {
@@ -55,6 +53,5 @@ double complex csqrt(double complex z)
if (y < 0)
return t - r * (double complex)I;
- else
- return t + r * (double complex)I;
+ return t + r * (double complex)I;
}
diff --git a/lib/libm/csqrtf.c b/lib/libm/csqrtf.c
index 4ea894ab..79d03f4d 100644
--- a/lib/libm/csqrtf.c
+++ b/lib/libm/csqrtf.c
@@ -1,4 +1,5 @@
-#include "__complex.h"
+#include <complex.h> // for I, complex, cabsf, cimagf, crealf, csqrtf
+#include <math.h> // for fabsf, sqrtf
float complex csqrtf(float complex z)
{
@@ -10,11 +11,11 @@ float complex csqrtf(float complex z)
if (y == 0.0f) {
if (x < 0.0f) {
return 0.0f + sqrtf(-x) * I;
- } else if (x == 0.0f) {
+ }
+ if (x == 0.0f) {
return (0.0f + y * I);
- } else {
- return sqrtf(x) + y * I;
}
+ return sqrtf(x) + y * I;
}
if (x == 0.0f) {
@@ -22,8 +23,7 @@ float complex csqrtf(float complex z)
r = sqrtf(0.5f * r);
if (y > 0)
return r + r * I;
- else
- return r - r * I;
+ return r - r * I;
}
if ((fabsf(x) > 4.0f) || (fabsf(y) > 4.0f)) {
@@ -50,6 +50,5 @@ float complex csqrtf(float complex z)
if (y < 0)
return t - r * I;
- else
- return t + r * I;
+ return t + r * I;
}
diff --git a/lib/libm/csqrtl.c b/lib/libm/csqrtl.c
index 335e51d6..94bf52f1 100644
--- a/lib/libm/csqrtl.c
+++ b/lib/libm/csqrtl.c
@@ -1,6 +1,7 @@
-#include <stdbool.h>
-#include <float.h>
-#include "__complex.h"
+#include <complex.h> // for complex, I, cimagl, creall, csqrtl
+#include <float.h> // for LDBL_MAX
+#include <math.h> // for fabsl, copysignl, hypotl, sqrtl, isinf, INFINITY
+#include <stdbool.h> // for bool, false, true
#define THRESH (LDBL_MAX / 2.414213562373095048801688724209698L)
#define cpackl(r, i) ((r) + (i) * (long double complex)I)
@@ -31,8 +32,7 @@ long double complex csqrtl(long double complex z)
*/
if (signbit(a))
return (cpackl(fabsl(b - b), copysignl(a, b)));
- else
- return (cpackl(a, copysignl(b - b, b)));
+ return (cpackl(a, copysignl(b - b, b)));
}
/*
* The remaining special case (b is NaN) is handled just fine by
@@ -57,6 +57,5 @@ long double complex csqrtl(long double complex z)
/* Rescale. */
if (scale)
return (result * 2.0L);
- else
- return (result);
+ return (result);
}
diff --git a/lib/libm/ctan.c b/lib/libm/ctan.c
index 2bc6156c..b06e60a6 100644
--- a/lib/libm/ctan.c
+++ b/lib/libm/ctan.c
@@ -1,4 +1,7 @@
-#include "__complex.h"
+#include "__complex.h" // for redupi, MACHEP
+
+#include <complex.h> // for cimag, creal, complex, I, ctan
+#include <math.h> // for fabs, HUGE_VAL, cos, cosh, sin, sinh
double _ctans(double complex z)
{
diff --git a/lib/libm/ctanf.c b/lib/libm/ctanf.c
index fe117d7a..168abac2 100644
--- a/lib/libm/ctanf.c
+++ b/lib/libm/ctanf.c
@@ -1,4 +1,7 @@
-#include "__complex.h"
+#include "__complex.h" // for redupif, MACHEPF
+
+#include <complex.h> // for cimagf, crealf, complex, I, ctanf
+#include <math.h> // for fabsf, HUGE_VALF, cosf, coshf, sinf, sinhf
static float _ctansf(float complex z)
{
diff --git a/lib/libm/ctanh.c b/lib/libm/ctanh.c
index a99e1496..e2d550df 100644
--- a/lib/libm/ctanh.c
+++ b/lib/libm/ctanh.c
@@ -1,5 +1,5 @@
-#include <math.h>
-#include <complex.h>
+#include <complex.h> // for complex, cimag, creal, ctanh, I
+#include <math.h> // for cos, cosh, sin, sinh
double complex ctanh(double complex z)
{
diff --git a/lib/libm/ctanhf.c b/lib/libm/ctanhf.c
index 6574e2c5..3ecd9ed9 100644
--- a/lib/libm/ctanhf.c
+++ b/lib/libm/ctanhf.c
@@ -1,5 +1,5 @@
-#include <math.h>
-#include <complex.h>
+#include <complex.h> // for cimagf, complex, crealf, ctanhf, I
+#include <math.h> // for cosf, coshf, sinf, sinhf
float complex ctanhf(float complex z)
{
diff --git a/lib/libm/ctanhl.c b/lib/libm/ctanhl.c
index 9b798080..1c9b9b81 100644
--- a/lib/libm/ctanhl.c
+++ b/lib/libm/ctanhl.c
@@ -1,5 +1,5 @@
-#include <math.h>
-#include <complex.h>
+#include <complex.h> // for complex, cimagl, creall, ctanhl, I
+#include <math.h> // for coshl, cosl, sinhl, sinl
long double complex ctanhl(long double complex z)
{
diff --git a/lib/libm/ctanl.c b/lib/libm/ctanl.c
index a410db0e..65a9c2a5 100644
--- a/lib/libm/ctanl.c
+++ b/lib/libm/ctanl.c
@@ -1,4 +1,7 @@
-#include "__complex.h"
+#include "__complex.h" // for ctansl
+
+#include <complex.h> // for cimagl, complex, creall, I, ctanl
+#include <math.h> // for HUGE_VALL, coshl, cosl, fabsl, sinhl, sinl
long double complex ctanl(long double complex z)
{
diff --git a/lib/libm/erf.c b/lib/libm/erf.c
index 4a096387..e95fb98c 100644
--- a/lib/libm/erf.c
+++ b/lib/libm/erf.c
@@ -103,7 +103,10 @@
* erfc/erf(NaN) is NaN
*/
-#include "libm.h"
+#include "libm.h" // for GET_HIGH_WORD, SET_LOW_WORD
+
+#include <math.h> // for double_t, exp, fabs, erf, erfc
+#include <stdint.h> // for uint32_t
static const double erx = 8.45062911510467529297e-01, /* 0x3FEB0AC1, 0x60000000
*/
diff --git a/lib/libm/erff.c b/lib/libm/erff.c
index 26170f62..2bf5d39e 100644
--- a/lib/libm/erff.c
+++ b/lib/libm/erff.c
@@ -13,7 +13,10 @@
* ====================================================
*/
-#include "libm.h"
+#include "libm.h" // for GET_FLOAT_WORD, SET_FLOAT_WORD
+
+#include <math.h> // for float_t, expf, fabsf, erfcf, erff
+#include <stdint.h> // for uint32_t
static const float erx = 8.4506291151e-01, /* 0x3f58560b */
/*
diff --git a/lib/libm/erfl.c b/lib/libm/erfl.c
index d75acb24..bb571734 100644
--- a/lib/libm/erfl.c
+++ b/lib/libm/erfl.c
@@ -97,7 +97,11 @@
* erfc/erf(NaN) is NaN
*/
-#include "libm.h"
+#include "libm.h" // for ldshape, ldshape::(anonymous)
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for expl, fabsl, erfcl, erfl
+#include <stdint.h> // for uint32_t
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double erfl(long double x)
diff --git a/lib/libm/exp.c b/lib/libm/exp.c
index cbcd7623..088a0cbb 100644
--- a/lib/libm/exp.c
+++ b/lib/libm/exp.c
@@ -5,10 +5,11 @@
* SPDX-License-Identifier: MIT
*/
-#include <math.h>
-#include <stdint.h>
-#include "libm.h"
-#include "exp_data.h"
+#include "exp_data.h" // for __exp_data, exp_data, EXP_POLY_ORDER, EXP_TABL...
+#include "libm.h" // for eval_as_double, asuint64, asdouble, WANT_ROUNDING
+
+#include <math.h> // for double_t, INFINITY, exp
+#include <stdint.h> // for uint64_t, uint32_t
#define N (1 << EXP_TABLE_BITS)
#define InvLn2N __exp_data.invln2N
@@ -91,8 +92,7 @@ double exp(double x)
return 1.0 + x;
if (asuint64(x) >> 63)
return __math_uflow(0);
- else
- return __math_oflow(0);
+ return __math_oflow(0);
}
/* Large x is special cased below. */
abstop = 0;
diff --git a/lib/libm/exp10.c b/lib/libm/exp10.c
index fd3747a9..deed9dcb 100644
--- a/lib/libm/exp10.c
+++ b/lib/libm/exp10.c
@@ -1,8 +1,8 @@
#define _GNU_SOURCE
-#include "libm.h"
+#include "libm.h" // for weak_alias
-#include <math.h>
-#include <stdint.h>
+#include <math.h> // for exp2, modf, pow
+#include <stdint.h> // for uint64_t
double exp10(double x)
{
diff --git a/lib/libm/exp10f.c b/lib/libm/exp10f.c
index 64883569..a9cde41d 100644
--- a/lib/libm/exp10f.c
+++ b/lib/libm/exp10f.c
@@ -1,8 +1,8 @@
#define _GNU_SOURCE
-#include "libm.h"
+#include "libm.h" // for weak_alias
-#include <math.h>
-#include <stdint.h>
+#include <math.h> // for exp2, exp2f, modff
+#include <stdint.h> // for uint32_t
float exp10f(float x)
{
diff --git a/lib/libm/exp10l.c b/lib/libm/exp10l.c
index 53915621..f0bf23d9 100644
--- a/lib/libm/exp10l.c
+++ b/lib/libm/exp10l.c
@@ -1,7 +1,8 @@
#define _GNU_SOURCE
-#include <float.h>
-#include <math.h>
-#include "libm.h"
+#include "libm.h" // for ldshape, ldshape::(anonymous), weak_alias
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for exp2l, modfl, powl
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double exp10l(long double x)
diff --git a/lib/libm/exp2.c b/lib/libm/exp2.c
index 1a4be99d..b94232fa 100644
--- a/lib/libm/exp2.c
+++ b/lib/libm/exp2.c
@@ -5,10 +5,11 @@
* SPDX-License-Identifier: MIT
*/
-#include <math.h>
-#include <stdint.h>
-#include "libm.h"
-#include "exp_data.h"
+#include "exp_data.h" // for __exp_data, exp_data, EXP_TABLE_BITS
+#include "libm.h" // for eval_as_double, asuint64, asdouble, WANT_ROUNDING
+
+#include <math.h> // for double_t, INFINITY, exp2
+#include <stdint.h> // for uint64_t, uint32_t
#define N (1 << EXP_TABLE_BITS)
#define Shift __exp_data.exp2_shift
@@ -88,7 +89,7 @@ double exp2(double x)
return 1.0 + x;
if (!(asuint64(x) >> 63))
return __math_oflow(0);
- else if (asuint64(x) >= asuint64(-1075.0))
+ if (asuint64(x) >= asuint64(-1075.0))
return __math_uflow(0);
}
if (2 * asuint64(x) > 2 * asuint64(928.0))
diff --git a/lib/libm/exp2f.c b/lib/libm/exp2f.c
index 8892cf8f..4b58ca8b 100644
--- a/lib/libm/exp2f.c
+++ b/lib/libm/exp2f.c
@@ -5,10 +5,11 @@
* SPDX-License-Identifier: MIT
*/
-#include <math.h>
-#include <stdint.h>
-#include "libm.h"
-#include "exp2f_data.h"
+#include "exp2f_data.h" // for __exp2f_data, exp2f_data, EXP2F_TABLE_BITS
+#include "libm.h" // for asuint, __math_oflowf, __math_uflowf, eval_a...
+
+#include <math.h> // for double_t, INFINITY, exp2f
+#include <stdint.h> // for uint32_t, uint64_t
/*
EXP2F_TABLE_BITS = 5
diff --git a/lib/libm/exp2f_data.h b/lib/libm/exp2f_data.h
index af31f629..8985ea21 100644
--- a/lib/libm/exp2f_data.h
+++ b/lib/libm/exp2f_data.h
@@ -5,7 +5,7 @@
#ifndef _EXP2F_DATA_H
#define _EXP2F_DATA_H
-#include <stdint.h>
+#include <stdint.h> // for uint64_t
#define hidden __attribute__((visibility("hidden")))
diff --git a/lib/libm/exp2l.c b/lib/libm/exp2l.c
index 6d21d590..d5899e2d 100644
--- a/lib/libm/exp2l.c
+++ b/lib/libm/exp2l.c
@@ -26,7 +26,11 @@
* SUCH DAMAGE.
*/
-#include "libm.h"
+#include "libm.h" // for ldshape, ldshape::(anonymous), FORCE_EVAL
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for exp2l, scalbnl
+#include <stdint.h> // for uint32_t, int32_t
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double exp2l(long double x)
diff --git a/lib/libm/exp_data.h b/lib/libm/exp_data.h
index 76f016ad..ce7f3803 100644
--- a/lib/libm/exp_data.h
+++ b/lib/libm/exp_data.h
@@ -5,7 +5,7 @@
#ifndef _EXP_DATA_H
#define _EXP_DATA_H
-#include <stdint.h>
+#include <stdint.h> // for uint64_t
#define hidden __attribute__((visibility("hidden")))
diff --git a/lib/libm/expf.c b/lib/libm/expf.c
index 53108c44..419bfe77 100644
--- a/lib/libm/expf.c
+++ b/lib/libm/expf.c
@@ -5,10 +5,11 @@
* SPDX-License-Identifier: MIT
*/
-#include <math.h>
-#include <stdint.h>
-#include "libm.h"
-#include "exp2f_data.h"
+#include "exp2f_data.h" // for __exp2f_data, exp2f_data, EXP2F_TABLE_BITS
+#include "libm.h" // for asuint, __math_oflowf, __math_uflowf, eval_a...
+
+#include <math.h> // for double_t, INFINITY, expf
+#include <stdint.h> // for uint32_t, uint64_t
/*
EXP2F_TABLE_BITS = 5
diff --git a/lib/libm/expl.c b/lib/libm/expl.c
index 85ac4f10..5499a3f3 100644
--- a/lib/libm/expl.c
+++ b/lib/libm/expl.c
@@ -65,7 +65,10 @@
*
*/
-#include "libm.h"
+#include "libm.h" // for __polevll
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for expl, floorl, scalbnl, isnan
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double expl(long double x)
diff --git a/lib/libm/expm1.c b/lib/libm/expm1.c
index 4ce99a4d..c4022188 100644
--- a/lib/libm/expm1.c
+++ b/lib/libm/expm1.c
@@ -104,7 +104,10 @@
* to produce the hexadecimal values shown.
*/
-#include "libm.h"
+#include "libm.h" // for FORCE_EVAL
+
+#include <math.h> // for double_t, expm1, isnan
+#include <stdint.h> // for uint64_t, uint32_t
static const double o_threshold = 7.09782712893383973096e+02, /* 0x40862E42,
0xFEFA39EF */
diff --git a/lib/libm/expm1f.c b/lib/libm/expm1f.c
index 7cc13b91..6c966f3d 100644
--- a/lib/libm/expm1f.c
+++ b/lib/libm/expm1f.c
@@ -13,7 +13,10 @@
* ====================================================
*/
-#include "libm.h"
+#include "libm.h" // for FORCE_EVAL
+
+#include <math.h> // for float_t, expm1f
+#include <stdint.h> // for uint32_t
static const float ln2_hi = 6.9313812256e-01, /* 0x3f317180 */
ln2_lo = 9.0580006145e-06, /* 0x3717f7d1 */
diff --git a/lib/libm/expm1l.c b/lib/libm/expm1l.c
index 959751bf..e26e19c5 100644
--- a/lib/libm/expm1l.c
+++ b/lib/libm/expm1l.c
@@ -47,7 +47,8 @@
* IEEE -45,+maxarg 200,000 1.2e-19 2.5e-20
*/
-#include "libm.h"
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for expm1l, floorl, scalbnl, isnan
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double expm1l(long double x)
diff --git a/lib/libm/fabs.c b/lib/libm/fabs.c
index deb2dc42..167041f6 100644
--- a/lib/libm/fabs.c
+++ b/lib/libm/fabs.c
@@ -1,5 +1,5 @@
-#include <math.h>
-#include <stdint.h>
+#include <math.h> // for fabs
+#include <stdint.h> // for uint64_t
double fabs(double x)
{
diff --git a/lib/libm/fabsf.c b/lib/libm/fabsf.c
index 712dab65..71ffea4a 100644
--- a/lib/libm/fabsf.c
+++ b/lib/libm/fabsf.c
@@ -1,5 +1,5 @@
-#include <math.h>
-#include <stdint.h>
+#include <math.h> // for fabsf
+#include <stdint.h> // for uint32_t
float fabsf(float x)
{
diff --git a/lib/libm/fabsl.c b/lib/libm/fabsl.c
index 9ffe8bbf..9b344491 100644
--- a/lib/libm/fabsl.c
+++ b/lib/libm/fabsl.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for ldshape, ldshape::(anonymous)
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for fabsl
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double fabsl(long double x)
{
diff --git a/lib/libm/fdim.c b/lib/libm/fdim.c
index 95854606..64c865b1 100644
--- a/lib/libm/fdim.c
+++ b/lib/libm/fdim.c
@@ -1,4 +1,4 @@
-#include <math.h>
+#include <math.h> // for fdim, isnan
double fdim(double x, double y)
{
diff --git a/lib/libm/fdimf.c b/lib/libm/fdimf.c
index 543c3648..a7fa6783 100644
--- a/lib/libm/fdimf.c
+++ b/lib/libm/fdimf.c
@@ -1,4 +1,4 @@
-#include <math.h>
+#include <math.h> // for fdimf, isnan
float fdimf(float x, float y)
{
diff --git a/lib/libm/fdiml.c b/lib/libm/fdiml.c
index 62e29b7d..771b59e9 100644
--- a/lib/libm/fdiml.c
+++ b/lib/libm/fdiml.c
@@ -1,5 +1,5 @@
-#include <math.h>
-#include <float.h>
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for fdiml, isnan
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double fdiml(long double x, long double y)
diff --git a/lib/libm/finite.c b/lib/libm/finite.c
index 25a0575f..d05cfbdb 100644
--- a/lib/libm/finite.c
+++ b/lib/libm/finite.c
@@ -1,5 +1,5 @@
#define _GNU_SOURCE
-#include <math.h>
+#include <math.h> // for isfinite
int finite(double x)
{
diff --git a/lib/libm/finitef.c b/lib/libm/finitef.c
index 2c4c7714..2efe2161 100644
--- a/lib/libm/finitef.c
+++ b/lib/libm/finitef.c
@@ -1,5 +1,5 @@
#define _GNU_SOURCE
-#include <math.h>
+#include <math.h> // for isfinite
int finitef(float x)
{
diff --git a/lib/libm/floor.c b/lib/libm/floor.c
index 9972a974..1c5d9698 100644
--- a/lib/libm/floor.c
+++ b/lib/libm/floor.c
@@ -1,4 +1,8 @@
-#include "libm.h"
+#include "libm.h" // for FORCE_EVAL
+
+#include <float.h> // for DBL_EPSILON, FLT_EVAL_METHOD
+#include <math.h> // for double_t, floor
+#include <stdint.h> // for uint64_t
#if FLT_EVAL_METHOD == 0 || FLT_EVAL_METHOD == 1
#define EPS DBL_EPSILON
diff --git a/lib/libm/floorf.c b/lib/libm/floorf.c
index cd9e99bc..026e3569 100644
--- a/lib/libm/floorf.c
+++ b/lib/libm/floorf.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for FORCE_EVAL
+
+#include <math.h> // for floorf
+#include <stdint.h> // for uint32_t
float floorf(float x)
{
diff --git a/lib/libm/floorl.c b/lib/libm/floorl.c
index a1e49c69..9b7f4761 100644
--- a/lib/libm/floorl.c
+++ b/lib/libm/floorl.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for ldshape, ldshape::(anonymous), FORCE_EVAL
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP, LDBL_EPSILON
+#include <math.h> // for floorl
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double floorl(long double x)
diff --git a/lib/libm/fma.c b/lib/libm/fma.c
index b657b02a..77bc7b3c 100644
--- a/lib/libm/fma.c
+++ b/lib/libm/fma.c
@@ -1,7 +1,7 @@
-#include <stdint.h>
-#include <float.h>
-#include <math.h>
-#include "atomic.h"
+#include <asm/atomic.h> // for a_clz_64
+#include <float.h> // for FLT_MIN, DBL_MIN
+#include <math.h> // for fma, scalbn, double_t
+#include <stdint.h> // for uint64_t, int64_t, uint32_t
#define ASUINT64(x) \
((union { \
@@ -20,12 +20,12 @@ struct num {
static struct num normalize(double x)
{
uint64_t ix = ASUINT64(x);
- int e = ix >> 52;
+ int e = (int)(ix >> 52);
int sign = e & 0x800;
e &= 0x7ff;
if (!e) {
ix = ASUINT64(x * 0x1p63);
- e = ix >> 52 & 0x7ff;
+ e = (int)(ix >> 52) & 0x7ff;
e = e ? e - 63 : 0x800;
}
ix &= (1ull << 52) - 1;
@@ -146,10 +146,10 @@ double fma(double x, double y, double z)
e -= d;
/* convert to double */
- int64_t i = rhi; /* i is in [1<<62,(1<<63)-1] */
+ int64_t i = (int64_t)rhi; /* i is in [1<<62,(1<<63)-1] */
if (sign)
i = -i;
- double r = i; /* |r| is in [0x1p62,0x1p63] */
+ double r = (double)i; /* |r| is in [0x1p62,0x1p63] */
if (e < -1022 - 62) {
/* result is subnormal before rounding */
@@ -159,34 +159,39 @@ double fma(double x, double y, double z)
c = -c;
if (r == c) {
/* min normal after rounding, underflow depends
- on arch behaviour which can be imitated by
- a double to float conversion */
- float fltmin = 0x0.ffffff8p-63 * FLT_MIN * r;
+ on arch behaviour which
+ can be imitated by a double to float
+ conversion */
+ float fltmin = (float)(0x0.ffffff8p-63) *
+ FLT_MIN * (float)r;
return DBL_MIN / FLT_MIN * fltmin;
}
/* one bit is lost when scaled, add another top bit to
- only round once at conversion if it is inexact */
+ only round once at conversion if
+ it is inexact */
if (rhi << 53) {
- i = rhi >> 1 | (rhi & 1) | 1ull << 62;
+ i = (int64_t)(rhi >> 1 | (rhi & 1) |
+ 1ull << 62);
if (sign)
i = -i;
- r = i;
+ r = (double)i;
r = 2 * r - c; /* remove top bit */
/* raise underflow portably, such that it
- cannot be optimized away */
+ cannot be optimized away
+ */
{
double_t tiny = DBL_MIN / FLT_MIN * r;
- r += (double)(tiny * tiny) * (r - r);
+ r += (double)(tiny * tiny);
}
}
} else {
/* only round once when scaled */
d = 10;
- i = (rhi >> d | !!(rhi << (64 - d))) << d;
+ i = (int64_t)((rhi >> d | !!(rhi << (64 - d))) << d);
if (sign)
i = -i;
- r = i;
+ r = (double)i;
}
}
return scalbn(r, e);
diff --git a/lib/libm/fmaf.c b/lib/libm/fmaf.c
index 1952b210..b940283d 100644
--- a/lib/libm/fmaf.c
+++ b/lib/libm/fmaf.c
@@ -25,9 +25,10 @@
* SUCH DAMAGE.
*/
-#include <fenv.h>
-#include <math.h>
-#include <stdint.h>
+
+#include <fenv.h> // for feraiseexcept, fetestexcept, feclearexcept
+#include <math.h> // for fmaf
+#include <stdint.h> // for uint64_t
/*
* Fused multiply-add: Compute x * y + z with a single rounding error.
diff --git a/lib/libm/fmal.c b/lib/libm/fmal.c
index 1eceafd4..8dd0ac61 100644
--- a/lib/libm/fmal.c
+++ b/lib/libm/fmal.c
@@ -25,16 +25,19 @@
* SUCH DAMAGE.
*/
-#include "libm.h"
+#include "libm.h" // for ldshape, ldshape::(anonymous)
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP, LDBL_MIN
+#include <math.h> // for nextafterl, scalbnl, frexpl, INFINITY, ilogbl
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double fmal(long double x, long double y, long double z)
{
return fma(x, y, z);
}
#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-#include <fenv.h>
+#include <fenv.h> // for feraiseexcept, fesetround, fetestexcept, fecl...
#if LDBL_MANT_DIG == 64
-#define LASTBIT(u) (u.i.m & 1)
+#define LASTBIT(u) ((u).i.m & 1)
#define SPLIT (0x1p32L + 1)
#elif LDBL_MANT_DIG == 113
#define LASTBIT(u) (u.i.lo & 1)
@@ -288,7 +291,6 @@ long double fmal(long double x, long double y, long double z)
adj = add_adjusted(r.lo, xy.lo);
if (spread + ilogbl(r.hi) > -16383)
return scalbnl(r.hi + adj, spread);
- else
- return add_and_denormalize(r.hi, adj, spread);
+ return add_and_denormalize(r.hi, adj, spread);
}
#endif
diff --git a/lib/libm/fmax.c b/lib/libm/fmax.c
index 94f0caa1..1b3ff4fd 100644
--- a/lib/libm/fmax.c
+++ b/lib/libm/fmax.c
@@ -1,4 +1,4 @@
-#include <math.h>
+#include <math.h> // for signbit, fmax, isnan
double fmax(double x, double y)
{
diff --git a/lib/libm/fmaxf.c b/lib/libm/fmaxf.c
index 695d8179..6c464f4b 100644
--- a/lib/libm/fmaxf.c
+++ b/lib/libm/fmaxf.c
@@ -1,4 +1,4 @@
-#include <math.h>
+#include <math.h> // for signbit, fmaxf, isnan
float fmaxf(float x, float y)
{
diff --git a/lib/libm/fmaxl.c b/lib/libm/fmaxl.c
index 4b03158e..328ffcba 100644
--- a/lib/libm/fmaxl.c
+++ b/lib/libm/fmaxl.c
@@ -1,5 +1,5 @@
-#include <math.h>
-#include <float.h>
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for signbit, fmaxl, isnan
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double fmaxl(long double x, long double y)
diff --git a/lib/libm/fmin.c b/lib/libm/fmin.c
index 08a8fd17..42ab00a6 100644
--- a/lib/libm/fmin.c
+++ b/lib/libm/fmin.c
@@ -1,4 +1,4 @@
-#include <math.h>
+#include <math.h> // for signbit, fmin, isnan
double fmin(double x, double y)
{
diff --git a/lib/libm/fminf.c b/lib/libm/fminf.c
index 3573c7de..43303a52 100644
--- a/lib/libm/fminf.c
+++ b/lib/libm/fminf.c
@@ -1,4 +1,4 @@
-#include <math.h>
+#include <math.h> // for signbit, fminf, isnan
float fminf(float x, float y)
{
diff --git a/lib/libm/fminl.c b/lib/libm/fminl.c
index 69bc24a7..087b87b5 100644
--- a/lib/libm/fminl.c
+++ b/lib/libm/fminl.c
@@ -1,5 +1,5 @@
-#include <math.h>
-#include <float.h>
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for signbit, fminl, isnan
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double fminl(long double x, long double y)
diff --git a/lib/libm/fmod.c b/lib/libm/fmod.c
index 21607a63..8b503827 100644
--- a/lib/libm/fmod.c
+++ b/lib/libm/fmod.c
@@ -1,5 +1,5 @@
-#include <math.h>
-#include <stdint.h>
+#include <math.h> // for fmod, isnan
+#include <stdint.h> // for uint64_t
double fmod(double x, double y)
{
diff --git a/lib/libm/fmodf.c b/lib/libm/fmodf.c
index 6bcd398c..9109be96 100644
--- a/lib/libm/fmodf.c
+++ b/lib/libm/fmodf.c
@@ -1,5 +1,5 @@
-#include <math.h>
-#include <stdint.h>
+#include <math.h> // for fmodf, isnan
+#include <stdint.h> // for uint32_t
float fmodf(float x, float y)
{
diff --git a/lib/libm/fmodl.c b/lib/libm/fmodl.c
index 72111dc1..767a94f0 100644
--- a/lib/libm/fmodl.c
+++ b/lib/libm/fmodl.c
@@ -1,4 +1,8 @@
-#include "libm.h"
+#include "libm.h" // for ldshape, ldshape::(anonymous)
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for fmodl, isnan
+#include <stdint.h> // for uint64_t
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double fmodl(long double x, long double y)
diff --git a/lib/libm/frexp.c b/lib/libm/frexp.c
index 1148c7e9..4b8629f9 100644
--- a/lib/libm/frexp.c
+++ b/lib/libm/frexp.c
@@ -1,5 +1,5 @@
-#include <math.h>
-#include <stdint.h>
+#include <math.h> // for frexp
+#include <stdint.h> // for uint64_t
double frexp(double x, int *e)
{
@@ -16,7 +16,8 @@ double frexp(double x, int *e)
} else
*e = 0;
return x;
- } else if (ee == 0x7ff) {
+ }
+ if (ee == 0x7ff) {
return x;
}
diff --git a/lib/libm/frexpf.c b/lib/libm/frexpf.c
index 711129fb..9eb91c21 100644
--- a/lib/libm/frexpf.c
+++ b/lib/libm/frexpf.c
@@ -1,5 +1,5 @@
-#include <math.h>
-#include <stdint.h>
+#include <math.h> // for frexpf
+#include <stdint.h> // for uint32_t
float frexpf(float x, int *e)
{
@@ -16,7 +16,8 @@ float frexpf(float x, int *e)
} else
*e = 0;
return x;
- } else if (ee == 0xff) {
+ }
+ if (ee == 0xff) {
return x;
}
diff --git a/lib/libm/frexpl.c b/lib/libm/frexpl.c
index 102ade25..e3a32c06 100644
--- a/lib/libm/frexpl.c
+++ b/lib/libm/frexpl.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for ldshape, ldshape::(anonymous)
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for frexpl
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double frexpl(long double x, int *e)
@@ -18,7 +21,8 @@ long double frexpl(long double x, int *e)
} else
*e = 0;
return x;
- } else if (ee == 0x7fff) {
+ }
+ if (ee == 0x7fff) {
return x;
}
diff --git a/lib/libm/hypot.c b/lib/libm/hypot.c
index 5cee8345..744c7bb8 100644
--- a/lib/libm/hypot.c
+++ b/lib/libm/hypot.c
@@ -1,6 +1,6 @@
-#include <math.h>
-#include <stdint.h>
-#include <float.h>
+#include <float.h> // for FLT_EVAL_METHOD, LDBL_MANT_DIG
+#include <math.h> // for double_t, hypot, sqrt
+#include <stdint.h> // for uint64_t
#if FLT_EVAL_METHOD > 1U && LDBL_MANT_DIG == 64
#define SPLIT (0x1p32 + 1)
diff --git a/lib/libm/hypotf.c b/lib/libm/hypotf.c
index 60186e9e..ee91a9af 100644
--- a/lib/libm/hypotf.c
+++ b/lib/libm/hypotf.c
@@ -1,5 +1,5 @@
-#include <math.h>
-#include <stdint.h>
+#include <math.h> // for hypotf, sqrtf, float_t
+#include <stdint.h> // for uint32_t
float hypotf(float x, float y)
{
diff --git a/lib/libm/hypotl.c b/lib/libm/hypotl.c
index fb59067c..d37594d4 100644
--- a/lib/libm/hypotl.c
+++ b/lib/libm/hypotl.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for ldshape, ldshape::(anonymous)
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for hypotl, sqrtl, isinf
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double hypotl(long double x, long double y)
diff --git a/lib/libm/ilogb.c b/lib/libm/ilogb.c
index 3487d460..d5cdd469 100644
--- a/lib/libm/ilogb.c
+++ b/lib/libm/ilogb.c
@@ -1,5 +1,8 @@
-#include <limits.h>
-#include "libm.h"
+#include "libm.h" // for FORCE_EVAL
+
+#include <limits.h> // for INT_MAX
+#include <math.h> // for ilogb, FP_ILOGB0, FP_ILOGBNAN
+#include <stdint.h> // for uint64_t
int ilogb(double x)
{
diff --git a/lib/libm/ilogbf.c b/lib/libm/ilogbf.c
index 07599896..ecd5de0a 100644
--- a/lib/libm/ilogbf.c
+++ b/lib/libm/ilogbf.c
@@ -1,5 +1,8 @@
-#include <limits.h>
-#include "libm.h"
+#include "libm.h" // for FORCE_EVAL
+
+#include <limits.h> // for INT_MAX
+#include <math.h> // for ilogbf, FP_ILOGB0, FP_ILOGBNAN
+#include <stdint.h> // for uint32_t
int ilogbf(float x)
{
diff --git a/lib/libm/ilogbl.c b/lib/libm/ilogbl.c
index 3ddf29ca..5d626a79 100644
--- a/lib/libm/ilogbl.c
+++ b/lib/libm/ilogbl.c
@@ -1,5 +1,9 @@
-#include <limits.h>
-#include "libm.h"
+#include "libm.h" // for ldshape, FORCE_EVAL, ldshape::(anonymous)
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <limits.h> // for INT_MAX
+#include <math.h> // for ilogbl, FP_ILOGB0, FP_ILOGBNAN
+#include <stdint.h> // for uint64_t
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
int ilogbl(long double x)
diff --git a/lib/libm/j0.c b/lib/libm/j0.c
index be5df8ce..52d3f483 100644
--- a/lib/libm/j0.c
+++ b/lib/libm/j0.c
@@ -54,7 +54,10 @@
* 3. Special cases: y0(0)=-inf, y0(x<0)=NaN, y0(inf)=0.
*/
-#include "libm.h"
+#include "libm.h" // for GET_HIGH_WORD, EXTRACT_WORDS
+
+#include <math.h> // for double_t, cos, log, fabs, sin, sqrt, j0, y0
+#include <stdint.h> // for uint32_t
static double pzero(double), qzero(double);
diff --git a/lib/libm/j0f.c b/lib/libm/j0f.c
index 5c7ffcbc..46ffc758 100644
--- a/lib/libm/j0f.c
+++ b/lib/libm/j0f.c
@@ -13,8 +13,11 @@
* ====================================================
*/
+#include <math.h> // for float_t, cosf, logf, fabsf, sinf, sqrtf
+#include <stdint.h> // for uint32_t
+
#define _GNU_SOURCE
-#include "libm.h"
+#include "libm.h" // for GET_FLOAT_WORD
static float pzerof(float), qzerof(float);
diff --git a/lib/libm/j1.c b/lib/libm/j1.c
index 0762e739..839160c4 100644
--- a/lib/libm/j1.c
+++ b/lib/libm/j1.c
@@ -54,7 +54,10 @@
* by method mentioned above.
*/
-#include "libm.h"
+#include "libm.h" // for GET_HIGH_WORD, EXTRACT_WORDS
+
+#include <math.h> // for double_t, cos, fabs, log, sin, sqrt, j1, y1
+#include <stdint.h> // for uint32_t
static double pone(double), qone(double);
diff --git a/lib/libm/j1f.c b/lib/libm/j1f.c
index 1fec2690..6415ae14 100644
--- a/lib/libm/j1f.c
+++ b/lib/libm/j1f.c
@@ -13,8 +13,11 @@
* ====================================================
*/
+#include <math.h> // for float_t, cosf, fabsf, logf, sinf, sqrtf
+#include <stdint.h> // for uint32_t
+
#define _GNU_SOURCE
-#include "libm.h"
+#include "libm.h" // for GET_FLOAT_WORD
static float ponef(float), qonef(float);
diff --git a/lib/libm/jn.c b/lib/libm/jn.c
index a8515278..c79743a0 100644
--- a/lib/libm/jn.c
+++ b/lib/libm/jn.c
@@ -34,7 +34,10 @@
* values of n>1.
*/
-#include "libm.h"
+#include "libm.h" // for EXTRACT_WORDS, GET_HIGH_WORD
+
+#include <math.h> // for cos, sin, fabs, j0, j1, y1, sqrt, y0, log, jn, yn
+#include <stdint.h> // for uint32_t
static const double invsqrtpi = 5.64189583547756279280e-01; /* 0x3FE20DD7,
0x50429B6D */
diff --git a/lib/libm/ldexp.c b/lib/libm/ldexp.c
index f4d1cd6a..e1cb2acb 100644
--- a/lib/libm/ldexp.c
+++ b/lib/libm/ldexp.c
@@ -1,4 +1,4 @@
-#include <math.h>
+#include <math.h> // for ldexp, scalbn
double ldexp(double x, int n)
{
diff --git a/lib/libm/ldexpf.c b/lib/libm/ldexpf.c
index 3bad5f39..48422e32 100644
--- a/lib/libm/ldexpf.c
+++ b/lib/libm/ldexpf.c
@@ -1,4 +1,4 @@
-#include <math.h>
+#include <math.h> // for ldexpf, scalbnf
float ldexpf(float x, int n)
{
diff --git a/lib/libm/ldexpl.c b/lib/libm/ldexpl.c
index fd145ccc..8d47c090 100644
--- a/lib/libm/ldexpl.c
+++ b/lib/libm/ldexpl.c
@@ -1,4 +1,4 @@
-#include <math.h>
+#include <math.h> // for ldexpl, scalbnl
long double ldexpl(long double x, int n)
{
diff --git a/lib/libm/lgamma.c b/lib/libm/lgamma.c
index 2fc9b478..bb8931fe 100644
--- a/lib/libm/lgamma.c
+++ b/lib/libm/lgamma.c
@@ -1,5 +1,6 @@
-#include <math.h>
-#include "libm.h"
+#include "libm.h" // for __lgamma_r, __signgam
+
+#include <math.h> // for lgamma
double lgamma(double x)
{
diff --git a/lib/libm/lgamma_r.c b/lib/libm/lgamma_r.c
index 6cb89858..d3f901ae 100644
--- a/lib/libm/lgamma_r.c
+++ b/lib/libm/lgamma_r.c
@@ -78,7 +78,10 @@
*
*/
-#include "libm.h"
+#include "libm.h" // for __cos, __sin, __lgamma_r, weak_alias
+
+#include <math.h> // for log, double_t, floor
+#include <stdint.h> // for uint32_t, uint64_t
static const double pi = 3.14159265358979311600e+00, /* 0x400921FB, 0x54442D18
*/
diff --git a/lib/libm/lgammaf.c b/lib/libm/lgammaf.c
index 2ae051d0..2da954d5 100644
--- a/lib/libm/lgammaf.c
+++ b/lib/libm/lgammaf.c
@@ -1,5 +1,6 @@
-#include <math.h>
-#include "libm.h"
+#include "libm.h" // for __lgammaf_r, __signgam
+
+#include <math.h> // for lgammaf
float lgammaf(float x)
{
diff --git a/lib/libm/lgammaf_r.c b/lib/libm/lgammaf_r.c
index b1a02fb8..7cb25578 100644
--- a/lib/libm/lgammaf_r.c
+++ b/lib/libm/lgammaf_r.c
@@ -13,7 +13,10 @@
* ====================================================
*/
-#include "libm.h"
+#include "libm.h" // for __cosdf, __sindf, __lgammaf_r, weak_alias
+
+#include <math.h> // for logf, floorf, double_t
+#include <stdint.h> // for uint32_t
static const float pi = 3.1415927410e+00, /* 0x40490fdb */
a0 = 7.7215664089e-02, /* 0x3d9e233f */
diff --git a/lib/libm/lgammal.c b/lib/libm/lgammal.c
index 08835693..6c137e20 100644
--- a/lib/libm/lgammal.c
+++ b/lib/libm/lgammal.c
@@ -85,8 +85,12 @@
*
*/
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for logl, floorl, lgammal
+#include <stdint.h> // for uint32_t
+
#define _GNU_SOURCE
-#include "libm.h"
+#include "libm.h" // for ldshape, __cosl, __sinl, ldshape::(anonymous)
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double __lgammal_r(long double x, int *sg)
diff --git a/lib/libm/libm.a b/lib/libm/libm.a
index 036141da..ac371df8 100644
--- a/lib/libm/libm.a
+++ b/lib/libm/libm.a
Binary files differ
diff --git a/lib/libm/libm.h b/lib/libm/libm.h
index 6f57c128..5d37249e 100644
--- a/lib/libm/libm.h
+++ b/lib/libm/libm.h
@@ -1,9 +1,7 @@
#ifndef _LIBM_H
#define _LIBM_H
-#include <asm/fpmath.h>
#include <float.h>
-#include <math.h>
#include <stdint.h>
#define hidden __attribute__((visibility("hidden")))
@@ -346,6 +344,6 @@ hidden long double __math_invalidl(long double);
#endif
#define weak_alias(old, new) \
- extern __typeof(old) new __attribute__((__weak__, __alias__(#old)))
+ extern __typeof(old)(new) __attribute__((__weak__, __alias__(#old)))
#endif
diff --git a/lib/libm/llrint.c b/lib/libm/llrint.c
index 4f583ae5..e8dc4dc4 100644
--- a/lib/libm/llrint.c
+++ b/lib/libm/llrint.c
@@ -1,4 +1,4 @@
-#include <math.h>
+#include <math.h> // for llrint, rint
/* uses LLONG_MAX > 2^53, see comments in lrint.c */
diff --git a/lib/libm/llrintf.c b/lib/libm/llrintf.c
index 96949a00..2ca15e36 100644
--- a/lib/libm/llrintf.c
+++ b/lib/libm/llrintf.c
@@ -1,4 +1,4 @@
-#include <math.h>
+#include <math.h> // for llrintf, rintf
/* uses LLONG_MAX > 2^24, see comments in lrint.c */
diff --git a/lib/libm/llrintl.c b/lib/libm/llrintl.c
index 05f4bc82..99e38781 100644
--- a/lib/libm/llrintl.c
+++ b/lib/libm/llrintl.c
@@ -1,6 +1,9 @@
-#include <limits.h>
-#include <fenv.h>
-#include "libm.h"
+
+
+#include <fenv.h> // for feclearexcept, fetestexcept
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <limits.h> // for LLONG_MAX, LLONG_MIN
+#include <math.h> // for llrintl, rintl
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long long llrintl(long double x)
diff --git a/lib/libm/llround.c b/lib/libm/llround.c
index 4d94787d..73958710 100644
--- a/lib/libm/llround.c
+++ b/lib/libm/llround.c
@@ -1,4 +1,4 @@
-#include <math.h>
+#include <math.h> // for llround, round
long long llround(double x)
{
diff --git a/lib/libm/llroundf.c b/lib/libm/llroundf.c
index 19eb77ee..0e41625a 100644
--- a/lib/libm/llroundf.c
+++ b/lib/libm/llroundf.c
@@ -1,4 +1,4 @@
-#include <math.h>
+#include <math.h> // for llroundf, roundf
long long llroundf(float x)
{
diff --git a/lib/libm/llroundl.c b/lib/libm/llroundl.c
index 2c2ee5ec..e344aa08 100644
--- a/lib/libm/llroundl.c
+++ b/lib/libm/llroundl.c
@@ -1,4 +1,4 @@
-#include <math.h>
+#include <math.h> // for llroundl, roundl
long long llroundl(long double x)
{
diff --git a/lib/libm/log.c b/lib/libm/log.c
index 38c0ccc4..39d23cdd 100644
--- a/lib/libm/log.c
+++ b/lib/libm/log.c
@@ -5,10 +5,11 @@
* SPDX-License-Identifier: MIT
*/
-#include <math.h>
-#include <stdint.h>
-#include "libm.h"
-#include "log_data.h"
+#include "libm.h" // for asuint64, eval_as_double, predict_false, __mat...
+#include "log_data.h" // for __log_data, log_data, log_data::(anonymous)
+
+#include <math.h> // for double_t, log, INFINITY
+#include <stdint.h> // for uint64_t, uint32_t, int64_t
#define T __log_data.tab
#define T2 __log_data.tab2
diff --git a/lib/libm/log10.c b/lib/libm/log10.c
index 003df818..729ca4d6 100644
--- a/lib/libm/log10.c
+++ b/lib/libm/log10.c
@@ -17,8 +17,8 @@
* log10(x) = (f - f*f/2 + r)/log(10) + k*log10(2)
*/
-#include <math.h>
-#include <stdint.h>
+#include <math.h> // for double_t, log10
+#include <stdint.h> // for uint64_t, uint32_t
static const double ivln10hi = 4.34294481878168880939e-01, /* 0x3fdbcb7b,
0x15200000 */
diff --git a/lib/libm/log10f.c b/lib/libm/log10f.c
index c4f9e2ca..4bf26544 100644
--- a/lib/libm/log10f.c
+++ b/lib/libm/log10f.c
@@ -13,8 +13,8 @@
* See comments in log10.c.
*/
-#include <math.h>
-#include <stdint.h>
+#include <math.h> // for float_t, log10f
+#include <stdint.h> // for uint32_t
static const float ivln10hi = 4.3432617188e-01, /* 0x3ede6000 */
ivln10lo = -3.1689971365e-05, /* 0xb804ead9 */
diff --git a/lib/libm/log10l.c b/lib/libm/log10l.c
index f8546cdb..d462308f 100644
--- a/lib/libm/log10l.c
+++ b/lib/libm/log10l.c
@@ -57,7 +57,10 @@
* log domain: x < 0; returns MINLOG
*/
-#include "libm.h"
+#include "libm.h" // for __p1evll, __polevll
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for INFINITY, frexpl, log10l, isnan
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double log10l(long double x)
@@ -102,10 +105,10 @@ static const long double S[4] = {
};
/* log10(2) */
#define L102A 0.3125L
-#define L102B -1.1470004336018804786261e-2L
+#define L102B (-1.1470004336018804786261e-2L)
/* log10(e) */
#define L10EA 0.5L
-#define L10EB -6.5705518096748172348871e-2L
+#define L10EB (-6.5705518096748172348871e-2L)
#define SQRTH 0.70710678118654752440L
diff --git a/lib/libm/log1p.c b/lib/libm/log1p.c
index 1667260a..a02f9a5a 100644
--- a/lib/libm/log1p.c
+++ b/lib/libm/log1p.c
@@ -53,7 +53,10 @@
* See HP-15C Advanced Functions Handbook, p.193.
*/
-#include "libm.h"
+#include "libm.h" // for FORCE_EVAL
+
+#include <math.h> // for double_t, log1p
+#include <stdint.h> // for uint32_t, uint64_t
static const double ln2_hi = 6.93147180369123816490e-01, /* 3fe62e42 fee00000 */
ln2_lo = 1.90821492927058770002e-10, /* 3dea39ef 35793c76 */
diff --git a/lib/libm/log1pf.c b/lib/libm/log1pf.c
index bdd702d1..95337a38 100644
--- a/lib/libm/log1pf.c
+++ b/lib/libm/log1pf.c
@@ -10,7 +10,10 @@
* ====================================================
*/
-#include "libm.h"
+#include "libm.h" // for FORCE_EVAL
+
+#include <math.h> // for float_t, log1pf
+#include <stdint.h> // for uint32_t
static const float ln2_hi = 6.9313812256e-01, /* 0x3f317180 */
ln2_lo = 9.0580006145e-06, /* 0x3717f7d1 */
diff --git a/lib/libm/log1pl.c b/lib/libm/log1pl.c
index 6021ccf4..972e9467 100644
--- a/lib/libm/log1pl.c
+++ b/lib/libm/log1pl.c
@@ -48,7 +48,10 @@
* IEEE -1.0, 9.0 100000 8.2e-20 2.5e-20
*/
-#include "libm.h"
+#include "libm.h" // for __p1evll, __polevll
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for frexpl, log1pl, INFINITY, isnan
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double log1pl(long double x)
diff --git a/lib/libm/log2.c b/lib/libm/log2.c
index 21f31ec1..e240ac07 100644
--- a/lib/libm/log2.c
+++ b/lib/libm/log2.c
@@ -5,10 +5,11 @@
* SPDX-License-Identifier: MIT
*/
-#include <math.h>
-#include <stdint.h>
-#include "libm.h"
-#include "log2_data.h"
+#include "libm.h" // for asuint64, eval_as_double, asdouble, predict_f...
+#include "log2_data.h" // for __log2_data, log2_data, log2_data::(anonymous)
+
+#include <math.h> // for double_t, log2, INFINITY
+#include <stdint.h> // for uint64_t, uint32_t, int64_t
#define T __log2_data.tab
#define T2 __log2_data.tab2
diff --git a/lib/libm/log2f.c b/lib/libm/log2f.c
index edcb28c6..f838da32 100644
--- a/lib/libm/log2f.c
+++ b/lib/libm/log2f.c
@@ -5,10 +5,11 @@
* SPDX-License-Identifier: MIT
*/
-#include <math.h>
-#include <stdint.h>
-#include "libm.h"
-#include "log2f_data.h"
+#include "libm.h" // for __math_divzerof, __math_invalidf, asuint
+#include "log2f_data.h" // for __log2f_data, log2f_data, log2f_data::(anony...
+
+#include <math.h> // for double_t, log2f
+#include <stdint.h> // for uint32_t, int32_t
/*
LOG2F_TABLE_BITS = 4
diff --git a/lib/libm/log2l.c b/lib/libm/log2l.c
index 65fe6df0..bec1d02d 100644
--- a/lib/libm/log2l.c
+++ b/lib/libm/log2l.c
@@ -52,7 +52,10 @@
* [-10000, +10000].
*/
-#include "libm.h"
+#include "libm.h" // for __p1evll, __polevll
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for frexpl, log2l, INFINITY, isnan
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double log2l(long double x)
diff --git a/lib/libm/logb.c b/lib/libm/logb.c
index f36a9646..68895f7f 100644
--- a/lib/libm/logb.c
+++ b/lib/libm/logb.c
@@ -1,4 +1,4 @@
-#include <math.h>
+#include <math.h> // for ilogb, logb, isfinite
/*
special cases:
diff --git a/lib/libm/logbf.c b/lib/libm/logbf.c
index 2344ed3a..e664e597 100644
--- a/lib/libm/logbf.c
+++ b/lib/libm/logbf.c
@@ -1,4 +1,4 @@
-#include <math.h>
+#include <math.h> // for ilogbf, logbf, isfinite
float logbf(float x)
{
diff --git a/lib/libm/logbl.c b/lib/libm/logbl.c
index 4d7348a0..40ea514d 100644
--- a/lib/libm/logbl.c
+++ b/lib/libm/logbl.c
@@ -1,4 +1,4 @@
-#include <math.h>
+#include <math.h> // for ilogbl, logbl, isfinite
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double logbl(long double x)
{
diff --git a/lib/libm/logf.c b/lib/libm/logf.c
index 5db4edaf..16cff83e 100644
--- a/lib/libm/logf.c
+++ b/lib/libm/logf.c
@@ -5,10 +5,11 @@
* SPDX-License-Identifier: MIT
*/
-#include <math.h>
-#include <stdint.h>
-#include "libm.h"
-#include "logf_data.h"
+#include "libm.h" // for __math_divzerof, __math_invalidf, asuint, eva...
+#include "logf_data.h" // for __logf_data, logf_data, logf_data::(anonymous)
+
+#include <math.h> // for double_t, logf
+#include <stdint.h> // for uint32_t, int32_t
/*
LOGF_TABLE_BITS = 4
diff --git a/lib/libm/logl.c b/lib/libm/logl.c
index a46484fa..419f98b6 100644
--- a/lib/libm/logl.c
+++ b/lib/libm/logl.c
@@ -52,7 +52,10 @@
* [-10000, +10000].
*/
-#include "libm.h"
+#include "libm.h" // for __p1evll, __polevll
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for frexpl, logl, INFINITY, isnan
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double logl(long double x)
diff --git a/lib/libm/lrint.c b/lib/libm/lrint.c
index 5ddd5fa9..d4392dde 100644
--- a/lib/libm/lrint.c
+++ b/lib/libm/lrint.c
@@ -1,7 +1,6 @@
-#include <limits.h>
-#include <fenv.h>
-#include <math.h>
-#include "libm.h"
+
+#include <limits.h> // for LONG_MAX
+#include <math.h> // for lrint, rint
/*
If the result cannot be represented (overflow, nan), then
diff --git a/lib/libm/lrintf.c b/lib/libm/lrintf.c
index ca0b6a46..6c4f9ae4 100644
--- a/lib/libm/lrintf.c
+++ b/lib/libm/lrintf.c
@@ -1,4 +1,4 @@
-#include <math.h>
+#include <math.h> // for lrintf, rintf
/* uses LONG_MAX > 2^24, see comments in lrint.c */
diff --git a/lib/libm/lrintl.c b/lib/libm/lrintl.c
index 82ce6393..fc82d8a8 100644
--- a/lib/libm/lrintl.c
+++ b/lib/libm/lrintl.c
@@ -1,6 +1,9 @@
-#include <limits.h>
-#include <fenv.h>
-#include "libm.h"
+
+
+#include <fenv.h> // for feclearexcept, fetestexcept
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <limits.h> // for LONG_MAX, LONG_MIN
+#include <math.h> // for lrintl, rintl
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long lrintl(long double x)
diff --git a/lib/libm/lround.c b/lib/libm/lround.c
index b8b79547..cda90a01 100644
--- a/lib/libm/lround.c
+++ b/lib/libm/lround.c
@@ -1,4 +1,4 @@
-#include <math.h>
+#include <math.h> // for lround, round
long lround(double x)
{
diff --git a/lib/libm/lroundf.c b/lib/libm/lroundf.c
index c4707e7d..76a063be 100644
--- a/lib/libm/lroundf.c
+++ b/lib/libm/lroundf.c
@@ -1,4 +1,4 @@
-#include <math.h>
+#include <math.h> // for lroundf, roundf
long lroundf(float x)
{
diff --git a/lib/libm/lroundl.c b/lib/libm/lroundl.c
index 094fdf64..45d74c64 100644
--- a/lib/libm/lroundl.c
+++ b/lib/libm/lroundl.c
@@ -1,4 +1,4 @@
-#include <math.h>
+#include <math.h> // for lroundl, roundl
long lroundl(long double x)
{
diff --git a/lib/libm/modf.c b/lib/libm/modf.c
index 94fe5439..fd473871 100644
--- a/lib/libm/modf.c
+++ b/lib/libm/modf.c
@@ -1,4 +1,5 @@
-#include "libm.h"
+#include <math.h> // for modf
+#include <stdint.h> // for uint64_t
double modf(double x, double *iptr)
{
diff --git a/lib/libm/modff.c b/lib/libm/modff.c
index d40752ba..73a5a162 100644
--- a/lib/libm/modff.c
+++ b/lib/libm/modff.c
@@ -1,4 +1,5 @@
-#include "libm.h"
+#include <math.h> // for modff
+#include <stdint.h> // for uint32_t
float modff(float x, float *iptr)
{
diff --git a/lib/libm/modfl.c b/lib/libm/modfl.c
index d46ce9fb..2aecb410 100644
--- a/lib/libm/modfl.c
+++ b/lib/libm/modfl.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for ldshape, ldshape::(anonymous)
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP, LDBL_EPSILON
+#include <math.h> // for modfl, isnan
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double modfl(long double x, long double *iptr)
diff --git a/lib/libm/nan.c b/lib/libm/nan.c
index e0f545d4..905817ed 100644
--- a/lib/libm/nan.c
+++ b/lib/libm/nan.c
@@ -1,5 +1,5 @@
-#include <sys/cdefs.h>
-#include <math.h>
+#include <math.h> // for nan, NAN
+#include <sys/cdefs.h> // for __unused
double nan(const char *__unused s)
{
diff --git a/lib/libm/nanf.c b/lib/libm/nanf.c
index db7bff6e..476156b6 100644
--- a/lib/libm/nanf.c
+++ b/lib/libm/nanf.c
@@ -1,5 +1,5 @@
-#include <sys/cdefs.h>
-#include <math.h>
+#include <math.h> // for nanf, NAN
+#include <sys/cdefs.h> // for __unused
float nanf(const char *__unused s)
{
diff --git a/lib/libm/nanl.c b/lib/libm/nanl.c
index 6e3c1377..c3bc8e87 100644
--- a/lib/libm/nanl.c
+++ b/lib/libm/nanl.c
@@ -1,5 +1,5 @@
-#include <sys/cdefs.h>
-#include <math.h>
+#include <math.h> // for nanl, NAN
+#include <sys/cdefs.h> // for __unused
long double nanl(const char *__unused s)
{
diff --git a/lib/libm/nearbyint.c b/lib/libm/nearbyint.c
index b0ffcc8a..d075eac6 100644
--- a/lib/libm/nearbyint.c
+++ b/lib/libm/nearbyint.c
@@ -1,5 +1,7 @@
-#include <fenv.h>
-#include <math.h>
+
+
+#include <fenv.h> // for feclearexcept, fetestexcept
+#include <math.h> // for nearbyint, rint
/* nearbyint is the same as rint, but it must not raise the inexact exception */
diff --git a/lib/libm/nearbyintf.c b/lib/libm/nearbyintf.c
index c96002b0..a180ae22 100644
--- a/lib/libm/nearbyintf.c
+++ b/lib/libm/nearbyintf.c
@@ -1,5 +1,7 @@
-#include <fenv.h>
-#include <math.h>
+
+
+#include <fenv.h> // for feclearexcept, fetestexcept
+#include <math.h> // for nearbyintf, rintf
float nearbyintf(float x)
{
diff --git a/lib/libm/nearbyintl.c b/lib/libm/nearbyintl.c
index 7d97b661..fc19d84b 100644
--- a/lib/libm/nearbyintl.c
+++ b/lib/libm/nearbyintl.c
@@ -1,5 +1,7 @@
-#include <math.h>
-#include <float.h>
+
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for nearbyintl, rintl
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double nearbyintl(long double x)
@@ -7,7 +9,8 @@ long double nearbyintl(long double x)
return nearbyint(x);
}
#else
-#include <fenv.h>
+#include <fenv.h> // for feclearexcept, fetestexcept
+
long double nearbyintl(long double x)
{
#ifdef FE_INEXACT
diff --git a/lib/libm/nextafter.c b/lib/libm/nextafter.c
index f00857c3..ebe15d8d 100644
--- a/lib/libm/nextafter.c
+++ b/lib/libm/nextafter.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for FORCE_EVAL
+
+#include <math.h> // for isnan, nextafter
+#include <stdint.h> // for uint64_t
double nextafter(double x, double y)
{
diff --git a/lib/libm/nextafterf.c b/lib/libm/nextafterf.c
index 912e1578..6de8cce3 100644
--- a/lib/libm/nextafterf.c
+++ b/lib/libm/nextafterf.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for FORCE_EVAL
+
+#include <math.h> // for isnan, nextafterf
+#include <stdint.h> // for uint32_t
float nextafterf(float x, float y)
{
diff --git a/lib/libm/nextafterl.c b/lib/libm/nextafterl.c
index a50dd503..848dda11 100644
--- a/lib/libm/nextafterl.c
+++ b/lib/libm/nextafterl.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for ldshape, ldshape::(anonymous), FORCE_EVAL
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for isnan, nextafterl
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double nextafterl(long double x, long double y)
diff --git a/lib/libm/nexttoward.c b/lib/libm/nexttoward.c
index 2082dff1..e5dabb4a 100644
--- a/lib/libm/nexttoward.c
+++ b/lib/libm/nexttoward.c
@@ -1,4 +1,8 @@
-#include "libm.h"
+#include "libm.h" // for FORCE_EVAL
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for signbit, isnan, nexttoward
+#include <stdint.h> // for uint64_t
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
double nexttoward(double x, long double y)
diff --git a/lib/libm/nexttowardf.c b/lib/libm/nexttowardf.c
index a342bc4c..b66fd4f3 100644
--- a/lib/libm/nexttowardf.c
+++ b/lib/libm/nexttowardf.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for FORCE_EVAL
+
+#include <math.h> // for signbit, isnan, nexttowardf
+#include <stdint.h> // for uint32_t
float nexttowardf(float x, long double y)
{
diff --git a/lib/libm/nexttowardl.c b/lib/libm/nexttowardl.c
index 67a63403..b5bda05b 100644
--- a/lib/libm/nexttowardl.c
+++ b/lib/libm/nexttowardl.c
@@ -1,4 +1,4 @@
-#include <math.h>
+#include <math.h> // for nextafterl, nexttowardl
long double nexttowardl(long double x, long double y)
{
diff --git a/lib/libm/pow.c b/lib/libm/pow.c
index 63dcf5ca..f4f84703 100644
--- a/lib/libm/pow.c
+++ b/lib/libm/pow.c
@@ -5,11 +5,12 @@
* SPDX-License-Identifier: MIT
*/
-#include <math.h>
-#include <stdint.h>
-#include "libm.h"
-#include "exp_data.h"
-#include "pow_data.h"
+#include "exp_data.h" // for __exp_data, exp_data, EXP_POLY_ORDER, EXP_TABL...
+#include "libm.h" // for asuint64, eval_as_double, asdouble, predict_false
+#include "pow_data.h" // for __pow_log_data, pow_log_data, pow_log_data::(a...
+
+#include <math.h> // for double_t, INFINITY, fabs, pow
+#include <stdint.h> // for uint64_t, uint32_t, int64_t
/*
Worst-case error: 0.54 ULP (~= ulperr_exp + 1024*Ln2*relerr_log*2^53)
@@ -187,8 +188,7 @@ static inline double exp_inline(double_t x, double_t xtail, uint32_t sign_bias)
/* Note: inf and nan are already handled. */
if (asuint64(x) >> 63)
return __math_uflow(sign_bias);
- else
- return __math_oflow(sign_bias);
+ return __math_oflow(sign_bias);
}
/* Large x is special cased below. */
abstop = 0;
@@ -318,8 +318,7 @@ double pow(double x, double y)
if (WANT_ROUNDING)
return ix > asuint64(1.0) ? 1.0 + y :
1.0 - y;
- else
- return 1.0;
+ return 1.0;
}
return (ix > asuint64(1.0)) == (topy < 0x800) ?
__math_oflow(0) :
diff --git a/lib/libm/powf.c b/lib/libm/powf.c
index d20bb6af..f93a5877 100644
--- a/lib/libm/powf.c
+++ b/lib/libm/powf.c
@@ -3,11 +3,12 @@
* SPDX-License-Identifier: MIT
*/
-#include <math.h>
-#include <stdint.h>
-#include "libm.h"
-#include "exp2f_data.h"
-#include "powf_data.h"
+#include "exp2f_data.h" // for __exp2f_data, exp2f_data, EXP2F_TABLE_BITS
+#include "libm.h" // for predict_false, asuint, asuint64, __math_inva...
+#include "powf_data.h" // for __powf_log2_data, powf_log2_data, powf_log2_...
+
+#include <math.h> // for double_t, powf, float_t
+#include <stdint.h> // for uint32_t, uint64_t, int32_t
/*
POWF_LOG2_POLY_ORDER = 5
diff --git a/lib/libm/powf_data.h b/lib/libm/powf_data.h
index 5b136e28..951f28f2 100644
--- a/lib/libm/powf_data.h
+++ b/lib/libm/powf_data.h
@@ -5,8 +5,7 @@
#ifndef _POWF_DATA_H
#define _POWF_DATA_H
-#include "libm.h"
-#include "exp2f_data.h"
+#include "libm.h" // for TOINT_INTRINSICS, hidden
#define POWF_LOG2_TABLE_BITS 4
#define POWF_LOG2_POLY_ORDER 5
diff --git a/lib/libm/powl.c b/lib/libm/powl.c
index 1a2d48c8..26a9b5ae 100644
--- a/lib/libm/powl.c
+++ b/lib/libm/powl.c
@@ -59,7 +59,10 @@
*
*/
-#include "libm.h"
+#include "libm.h" // for __polevll, __p1evll
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP, LDBL_EPSILON, LDBL_M...
+#include <math.h> // for INFINITY, fabsl, floorl, frexpl, isnan, powl, sca...
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double powl(long double x, long double y)
diff --git a/lib/libm/projf.c b/lib/libm/projf.c
index a0bcf369..a04de5cc 100644
--- a/lib/libm/projf.c
+++ b/lib/libm/projf.c
@@ -1,4 +1,7 @@
-#include "__complex.h"
+#include "__complex.h" // for IMAG_PART, REAL_PART, float_complex
+
+#include <complex.h> // for cimagf, complex, cprojf, crealf
+#include <math.h> // for copysignf, isinf, INFINITY
float complex cprojf(float complex z)
{
diff --git a/lib/libm/remainder.c b/lib/libm/remainder.c
index 53b5c8f6..35f20ea5 100644
--- a/lib/libm/remainder.c
+++ b/lib/libm/remainder.c
@@ -1,6 +1,6 @@
-#include "libm.h"
+#include "libm.h" // for weak_alias
-#include <math.h>
+#include <math.h> // for remainder, remquo
double remainder(double x, double y)
{
diff --git a/lib/libm/remainderf.c b/lib/libm/remainderf.c
index 6a80a25c..375fa528 100644
--- a/lib/libm/remainderf.c
+++ b/lib/libm/remainderf.c
@@ -1,6 +1,6 @@
-#include "libm.h"
+#include "libm.h" // for weak_alias
-#include <math.h>
+#include <math.h> // for remainderf, remquof
float remainderf(float x, float y)
{
diff --git a/lib/libm/remainderl.c b/lib/libm/remainderl.c
index 2a13c1d5..270987df 100644
--- a/lib/libm/remainderl.c
+++ b/lib/libm/remainderl.c
@@ -1,5 +1,5 @@
-#include <math.h>
-#include <float.h>
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for remainderl, remquol
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double remainderl(long double x, long double y)
diff --git a/lib/libm/remquo.c b/lib/libm/remquo.c
index a412f8e1..8e27914f 100644
--- a/lib/libm/remquo.c
+++ b/lib/libm/remquo.c
@@ -1,5 +1,5 @@
-#include <math.h>
-#include <stdint.h>
+#include <math.h> // for remquo, isnan
+#include <stdint.h> // for uint64_t, uint32_t
double remquo(double x, double y, int *quo)
{
diff --git a/lib/libm/remquof.c b/lib/libm/remquof.c
index 82124c65..c50b1615 100644
--- a/lib/libm/remquof.c
+++ b/lib/libm/remquof.c
@@ -1,5 +1,5 @@
-#include <math.h>
-#include <stdint.h>
+#include <math.h> // for remquof, isnan
+#include <stdint.h> // for uint32_t
float remquof(float x, float y, int *quo)
{
diff --git a/lib/libm/remquol.c b/lib/libm/remquol.c
index 23c88487..1a58f2d3 100644
--- a/lib/libm/remquol.c
+++ b/lib/libm/remquol.c
@@ -1,4 +1,8 @@
-#include "libm.h"
+#include "libm.h" // for ldshape, ldshape::(anonymous)
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for remquol, isnan
+#include <stdint.h> // for uint64_t, uint32_t
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double remquol(long double x, long double y, int *quo)
diff --git a/lib/libm/rint.c b/lib/libm/rint.c
index f1159643..a1c64ea3 100644
--- a/lib/libm/rint.c
+++ b/lib/libm/rint.c
@@ -1,6 +1,6 @@
-#include <float.h>
-#include <math.h>
-#include <stdint.h>
+#include <float.h> // for DBL_EPSILON, FLT_EVAL_METHOD
+#include <math.h> // for double_t, rint
+#include <stdint.h> // for uint64_t
#if FLT_EVAL_METHOD == 0 || FLT_EVAL_METHOD == 1
#define EPS DBL_EPSILON
diff --git a/lib/libm/rintf.c b/lib/libm/rintf.c
index 5db9e0fe..6de51a6e 100644
--- a/lib/libm/rintf.c
+++ b/lib/libm/rintf.c
@@ -1,6 +1,6 @@
-#include <float.h>
-#include <math.h>
-#include <stdint.h>
+#include <float.h> // for FLT_EPSILON, FLT_EVAL_METHOD
+#include <math.h> // for float_t, rintf
+#include <stdint.h> // for uint32_t
#if FLT_EVAL_METHOD == 0
#define EPS FLT_EPSILON
diff --git a/lib/libm/rintl.c b/lib/libm/rintl.c
index e75fe870..acb68783 100644
--- a/lib/libm/rintl.c
+++ b/lib/libm/rintl.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for ldshape, ldshape::(anonymous)
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP, LDBL_EPSILON
+#include <math.h> // for rintl
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double rintl(long double x)
diff --git a/lib/libm/round.c b/lib/libm/round.c
index aa36cce4..f23364c4 100644
--- a/lib/libm/round.c
+++ b/lib/libm/round.c
@@ -1,4 +1,8 @@
-#include "libm.h"
+#include "libm.h" // for FORCE_EVAL
+
+#include <float.h> // for DBL_EPSILON, FLT_EVAL_METHOD
+#include <math.h> // for double_t, round
+#include <stdint.h> // for uint64_t
#if FLT_EVAL_METHOD == 0 || FLT_EVAL_METHOD == 1
#define EPS DBL_EPSILON
diff --git a/lib/libm/roundf.c b/lib/libm/roundf.c
index fef6a24b..3df4c83b 100644
--- a/lib/libm/roundf.c
+++ b/lib/libm/roundf.c
@@ -1,4 +1,8 @@
-#include "libm.h"
+#include "libm.h" // for FORCE_EVAL
+
+#include <float.h> // for FLT_EPSILON, FLT_EVAL_METHOD
+#include <math.h> // for float_t, roundf
+#include <stdint.h> // for uint32_t
#if FLT_EVAL_METHOD == 0
#define EPS FLT_EPSILON
diff --git a/lib/libm/roundl.c b/lib/libm/roundl.c
index cb148310..94b3aa89 100644
--- a/lib/libm/roundl.c
+++ b/lib/libm/roundl.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for ldshape, ldshape::(anonymous), FORCE_EVAL
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP, LDBL_EPSILON
+#include <math.h> // for roundl
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double roundl(long double x)
diff --git a/lib/libm/scalb.c b/lib/libm/scalb.c
index 478dd2ae..f5aeebfa 100644
--- a/lib/libm/scalb.c
+++ b/lib/libm/scalb.c
@@ -16,7 +16,7 @@
*/
#define _GNU_SOURCE
-#include <math.h>
+#include <math.h> // for scalbn, isnan, rint, isfinite
double scalb(double x, double fn)
{
@@ -25,8 +25,7 @@ double scalb(double x, double fn)
if (!isfinite(fn)) {
if (fn > 0.0)
return x * fn;
- else
- return x / (-fn);
+ return x / (-fn);
}
if (rint(fn) != fn)
return (fn - fn) / (fn - fn);
diff --git a/lib/libm/scalbf.c b/lib/libm/scalbf.c
index 7a938de2..bbe9549b 100644
--- a/lib/libm/scalbf.c
+++ b/lib/libm/scalbf.c
@@ -14,7 +14,7 @@
*/
#define _GNU_SOURCE
-#include <math.h>
+#include <math.h> // for scalbnf, isnan, rintf, isfinite
float scalbf(float x, float fn)
{
@@ -23,8 +23,7 @@ float scalbf(float x, float fn)
if (!isfinite(fn)) {
if (fn > 0.0f)
return x * fn;
- else
- return x / (-fn);
+ return x / (-fn);
}
if (rintf(fn) != fn)
return (fn - fn) / (fn - fn);
diff --git a/lib/libm/scalbln.c b/lib/libm/scalbln.c
index e6f3f195..78685eba 100644
--- a/lib/libm/scalbln.c
+++ b/lib/libm/scalbln.c
@@ -1,5 +1,5 @@
-#include <limits.h>
-#include <math.h>
+#include <limits.h> // for INT_MAX, INT_MIN
+#include <math.h> // for scalbln, scalbn
double scalbln(double x, long n)
{
diff --git a/lib/libm/scalblnf.c b/lib/libm/scalblnf.c
index d8e8166b..5c9d349d 100644
--- a/lib/libm/scalblnf.c
+++ b/lib/libm/scalblnf.c
@@ -1,5 +1,5 @@
-#include <limits.h>
-#include <math.h>
+#include <limits.h> // for INT_MAX, INT_MIN
+#include <math.h> // for scalblnf, scalbnf
float scalblnf(float x, long n)
{
diff --git a/lib/libm/scalblnl.c b/lib/libm/scalblnl.c
index 854c51c4..58a3f291 100644
--- a/lib/libm/scalblnl.c
+++ b/lib/libm/scalblnl.c
@@ -1,6 +1,6 @@
-#include <limits.h>
-#include <math.h>
-#include <float.h>
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <limits.h> // for INT_MAX, INT_MIN
+#include <math.h> // for scalblnl, scalbnl
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double scalblnl(long double x, long n)
diff --git a/lib/libm/scalbn.c b/lib/libm/scalbn.c
index d38d4338..7dc1b156 100644
--- a/lib/libm/scalbn.c
+++ b/lib/libm/scalbn.c
@@ -1,5 +1,5 @@
-#include <math.h>
-#include <stdint.h>
+#include <math.h> // for scalbn, double_t
+#include <stdint.h> // for uint64_t
double scalbn(double x, int n)
{
diff --git a/lib/libm/scalbnf.c b/lib/libm/scalbnf.c
index 38b7d5b3..f0526a47 100644
--- a/lib/libm/scalbnf.c
+++ b/lib/libm/scalbnf.c
@@ -1,5 +1,5 @@
-#include <math.h>
-#include <stdint.h>
+#include <math.h> // for scalbnf, float_t
+#include <stdint.h> // for uint32_t
float scalbnf(float x, int n)
{
diff --git a/lib/libm/scalbnl.c b/lib/libm/scalbnl.c
index db44dab0..2312d669 100644
--- a/lib/libm/scalbnl.c
+++ b/lib/libm/scalbnl.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for ldshape, ldshape::(anonymous)
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for scalbnl
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double scalbnl(long double x, int n)
diff --git a/lib/libm/signgam.c b/lib/libm/signgam.c
index ee331b27..2f4b82f9 100644
--- a/lib/libm/signgam.c
+++ b/lib/libm/signgam.c
@@ -1,5 +1,6 @@
-#include <math.h>
-#include "libm.h"
+#include "libm.h" // for __signgam, weak_alias
+
+#include <math.h> // for signgam
int __signgam = 0;
diff --git a/lib/libm/significand.c b/lib/libm/significand.c
index 40d9aa9f..744c0c65 100644
--- a/lib/libm/significand.c
+++ b/lib/libm/significand.c
@@ -1,5 +1,5 @@
#define _GNU_SOURCE
-#include <math.h>
+#include <math.h> // for ilogb, scalbn
double significand(double x)
{
diff --git a/lib/libm/significandf.c b/lib/libm/significandf.c
index 8a697e1a..43f0d096 100644
--- a/lib/libm/significandf.c
+++ b/lib/libm/significandf.c
@@ -1,5 +1,5 @@
#define _GNU_SOURCE
-#include <math.h>
+#include <math.h> // for ilogbf, scalbnf
float significandf(float x)
{
diff --git a/lib/libm/sin.c b/lib/libm/sin.c
index d836c705..4eff1001 100644
--- a/lib/libm/sin.c
+++ b/lib/libm/sin.c
@@ -40,7 +40,10 @@
* TRIG(x) returns trig(x) nearly rounded
*/
-#include "libm.h"
+#include "libm.h" // for __sin, __cos, __rem_pio2, FORCE_EVAL, GET_HIGH_WORD
+
+#include <math.h> // for sin
+#include <stdint.h> // for uint32_t
double sin(double x)
{
diff --git a/lib/libm/sincos.c b/lib/libm/sincos.c
index 50f22f46..c7300d7b 100644
--- a/lib/libm/sincos.c
+++ b/lib/libm/sincos.c
@@ -10,8 +10,10 @@
* ====================================================
*/
+#include <stdint.h> // for uint32_t
+
#define _GNU_SOURCE
-#include "libm.h"
+#include "libm.h" // for __cos, __sin, __rem_pio2, FORCE_EVAL, GET_HIGH_WORD
void sincos(double x, double *sin, double *cos)
{
diff --git a/lib/libm/sincosf.c b/lib/libm/sincosf.c
index 359c41cb..ea4bc567 100644
--- a/lib/libm/sincosf.c
+++ b/lib/libm/sincosf.c
@@ -14,8 +14,11 @@
* ====================================================
*/
+#include <math.h> // for M_PI_2, float_t
+#include <stdint.h> // for uint32_t
+
#define _GNU_SOURCE
-#include "libm.h"
+#include "libm.h" // for __cosdf, __sindf, __rem_pio2f, FORCE_EVAL, GET_F...
/* Small multiples of pi/2 rounded to double precision. */
static const double s1pio2 = 1 * M_PI_2, /* 0x3FF921FB, 0x54442D18 */
diff --git a/lib/libm/sincosl.c b/lib/libm/sincosl.c
index 21b19945..1dcba70b 100644
--- a/lib/libm/sincosl.c
+++ b/lib/libm/sincosl.c
@@ -1,5 +1,9 @@
+#include "math.h" // for M_PI_4
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+
#define _GNU_SOURCE
-#include "libm.h"
+#include "libm.h" // for ldshape, __cosl, __sinl, ldshape::(anonymous)
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
void sincosl(long double x, long double *sin, long double *cos)
diff --git a/lib/libm/sinf.c b/lib/libm/sinf.c
index f835ef8a..28513976 100644
--- a/lib/libm/sinf.c
+++ b/lib/libm/sinf.c
@@ -14,7 +14,10 @@
* ====================================================
*/
-#include "libm.h"
+#include "libm.h" // for __cosdf, __sindf, __rem_pio2f, FORCE_EVAL, GET_F...
+
+#include <math.h> // for M_PI_2, sinf
+#include <stdint.h> // for uint32_t
/* Small multiples of pi/2 rounded to double precision. */
static const double s1pio2 = 1 * M_PI_2, /* 0x3FF921FB, 0x54442D18 */
@@ -45,8 +48,7 @@ float sinf(float x)
if (ix <= 0x4016cbe3) { /* |x| ~<= 3pi/4 */
if (sign)
return -__cosdf(x + s1pio2);
- else
- return __cosdf(x - s1pio2);
+ return __cosdf(x - s1pio2);
}
return __sindf(sign ? -(x + s2pio2) : -(x - s2pio2));
}
@@ -54,8 +56,7 @@ float sinf(float x)
if (ix <= 0x40afeddf) { /* |x| ~<= 7*pi/4 */
if (sign)
return __cosdf(x + s3pio2);
- else
- return -__cosdf(x - s3pio2);
+ return -__cosdf(x - s3pio2);
}
return __sindf(sign ? x + s4pio2 : x - s4pio2);
}
diff --git a/lib/libm/sinh.c b/lib/libm/sinh.c
index b2b6e813..1c238c05 100644
--- a/lib/libm/sinh.c
+++ b/lib/libm/sinh.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for __expo2
+
+#include <math.h> // for expm1, sinh
+#include <stdint.h> // for uint64_t, uint32_t
/* sinh(x) = (exp(x) - 1/exp(x))/2
* = (exp(x)-1 + (exp(x)-1)/exp(x))/2
diff --git a/lib/libm/sinhf.c b/lib/libm/sinhf.c
index e5bd1a2a..8636c156 100644
--- a/lib/libm/sinhf.c
+++ b/lib/libm/sinhf.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for __expo2f
+
+#include <math.h> // for expm1f, sinhf
+#include <stdint.h> // for uint32_t
float sinhf(float x)
{
diff --git a/lib/libm/sinhl.c b/lib/libm/sinhl.c
index 55dc20a2..fa35e870 100644
--- a/lib/libm/sinhl.c
+++ b/lib/libm/sinhl.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for ldshape, ldshape::(anonymous)
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for expl, expm1l, sinhl
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double sinhl(long double x)
diff --git a/lib/libm/sinl.c b/lib/libm/sinl.c
index bb1352f1..3c650851 100644
--- a/lib/libm/sinl.c
+++ b/lib/libm/sinl.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for ldshape, ldshape::(anonymous), __sinl, __cosl
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for sinl, M_PI_4
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double sinl(long double x)
diff --git a/lib/libm/sqrt.c b/lib/libm/sqrt.c
index 9c54b70c..185a1190 100644
--- a/lib/libm/sqrt.c
+++ b/lib/libm/sqrt.c
@@ -1,7 +1,8 @@
-#include <stdint.h>
-#include <math.h>
-#include "libm.h"
-#include "sqrt_data.h"
+#include "libm.h" // for __math_invalid, asdouble, asuint64, eval_as_d...
+#include "sqrt_data.h" // for __rsqrt_tab
+
+#include <math.h> // for sqrt
+#include <stdint.h> // for uint64_t, uint32_t
#define FENV_SUPPORT 1
diff --git a/lib/libm/sqrt_data.c b/lib/libm/sqrt_data.c
index 4b15ae2b..4dc20a17 100644
--- a/lib/libm/sqrt_data.c
+++ b/lib/libm/sqrt_data.c
@@ -1,4 +1,7 @@
#include "sqrt_data.h"
+
+#include <stdint.h> // for uint16_t
+
const uint16_t __rsqrt_tab[128] = {
0xb451, 0xb2f0, 0xb196, 0xb044, 0xaef9, 0xadb6, 0xac79, 0xab43, 0xaa14,
0xa8eb, 0xa7c8, 0xa6aa, 0xa592, 0xa480, 0xa373, 0xa26b, 0xa168, 0xa06a,
diff --git a/lib/libm/sqrt_data.h b/lib/libm/sqrt_data.h
index f5929b8d..feff8a8b 100644
--- a/lib/libm/sqrt_data.h
+++ b/lib/libm/sqrt_data.h
@@ -1,7 +1,7 @@
#ifndef _SQRT_DATA_H
#define _SQRT_DATA_H
-#include <stdint.h>
+#include <stdint.h> // for uint16_t
#define hidden __attribute__((visibility("hidden")))
diff --git a/lib/libm/sqrtf.c b/lib/libm/sqrtf.c
index b9cd7961..e507455c 100644
--- a/lib/libm/sqrtf.c
+++ b/lib/libm/sqrtf.c
@@ -1,7 +1,8 @@
-#include <stdint.h>
-#include <math.h>
-#include "libm.h"
-#include "sqrt_data.h"
+#include "libm.h" // for __math_invalidf, asfloat, asuint, eval_as_float
+#include "sqrt_data.h" // for __rsqrt_tab
+
+#include <math.h> // for sqrtf
+#include <stdint.h> // for uint32_t, uint64_t
#define FENV_SUPPORT 1
diff --git a/lib/libm/sqrtl.c b/lib/libm/sqrtl.c
index 57249e9f..d71d455e 100644
--- a/lib/libm/sqrtl.c
+++ b/lib/libm/sqrtl.c
@@ -1,7 +1,8 @@
-#include <stdint.h>
-#include <math.h>
-#include <float.h>
-#include "libm.h"
+#include "libm.h" // for ldshape, ldshape::(anonymous), __math_invalidl
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for sqrtl
+#include <stdint.h> // for uint64_t, uint32_t
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double sqrtl(long double x)
@@ -9,7 +10,7 @@ long double sqrtl(long double x)
return sqrt(x);
}
#elif (LDBL_MANT_DIG == 113 || LDBL_MANT_DIG == 64) && LDBL_MAX_EXP == 16384
-#include "sqrt_data.h"
+#include "sqrt_data.h" // for __rsqrt_tab
#define FENV_SUPPORT 1
diff --git a/lib/libm/tan.c b/lib/libm/tan.c
index ecdf5515..5f37becc 100644
--- a/lib/libm/tan.c
+++ b/lib/libm/tan.c
@@ -39,7 +39,10 @@
* TRIG(x) returns trig(x) nearly rounded
*/
-#include "libm.h"
+#include "libm.h" // for __tan, __rem_pio2, FORCE_EVAL, GET_HIGH_WORD
+
+#include <math.h> // for tan
+#include <stdint.h> // for uint32_t
double tan(double x)
{
diff --git a/lib/libm/tanf.c b/lib/libm/tanf.c
index 1007aa91..ef808637 100644
--- a/lib/libm/tanf.c
+++ b/lib/libm/tanf.c
@@ -14,7 +14,10 @@
* ====================================================
*/
-#include "libm.h"
+#include "libm.h" // for __tandf, __rem_pio2f, FORCE_EVAL, GET_FLOAT_WORD
+
+#include <math.h> // for M_PI_2, tanf
+#include <stdint.h> // for uint32_t
/* Small multiples of pi/2 rounded to double precision. */
static const double t1pio2 = 1 * M_PI_2, /* 0x3FF921FB, 0x54442D18 */
@@ -26,7 +29,8 @@ float tanf(float x)
{
double y;
uint32_t ix;
- unsigned n, sign;
+ int n;
+ unsigned sign;
GET_FLOAT_WORD(ix, x);
sign = ix >> 31;
@@ -44,19 +48,17 @@ float tanf(float x)
if (ix <= 0x407b53d1) { /* |x| ~<= 5*pi/4 */
if (ix <= 0x4016cbe3) /* |x| ~<= 3pi/4 */
return __tandf((sign ? x + t1pio2 : x - t1pio2), 1);
- else
- return __tandf((sign ? x + t2pio2 : x - t2pio2), 0);
+ return __tandf((sign ? x + t2pio2 : x - t2pio2), 0);
}
if (ix <= 0x40e231d5) { /* |x| ~<= 9*pi/4 */
if (ix <= 0x40afeddf) /* |x| ~<= 7*pi/4 */
return __tandf((sign ? x + t3pio2 : x - t3pio2), 1);
- else
- return __tandf((sign ? x + t4pio2 : x - t4pio2), 0);
+ return __tandf((sign ? x + t4pio2 : x - t4pio2), 0);
}
/* tan(Inf or NaN) is NaN */
if (ix >= 0x7f800000)
- return x - x;
+ return NAN;
/* argument reduction */
n = __rem_pio2f(x, &y);
diff --git a/lib/libm/tanh.c b/lib/libm/tanh.c
index b32bf0b6..2b0951fd 100644
--- a/lib/libm/tanh.c
+++ b/lib/libm/tanh.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for FORCE_EVAL
+
+#include <math.h> // for expm1, tanh, double_t
+#include <stdint.h> // for uint64_t, uint32_t
/* tanh(x) = (exp(x) - exp(-x))/(exp(x) + exp(-x))
* = (exp(2*x) - 1)/(exp(2*x) - 1 + 2)
@@ -15,7 +18,7 @@ double tanh(double x)
double_t t;
/* x = |x| */
- sign = u.i >> 63;
+ sign = (int)(u.i >> 63);
u.i &= (uint64_t)-1 / 2;
x = u.f;
w = u.i >> 32;
diff --git a/lib/libm/tanhf.c b/lib/libm/tanhf.c
index f4ae759d..d8ec3aa3 100644
--- a/lib/libm/tanhf.c
+++ b/lib/libm/tanhf.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for FORCE_EVAL
+
+#include <math.h> // for expm1f, tanhf
+#include <stdint.h> // for uint32_t
float tanhf(float x)
{
@@ -7,7 +10,7 @@ float tanhf(float x)
uint32_t i;
} u = { .f = x };
uint32_t w;
- int sign;
+ uint32_t sign;
float t;
/* x = |x| */
diff --git a/lib/libm/tanhl.c b/lib/libm/tanhl.c
index a5be4a68..b302f34f 100644
--- a/lib/libm/tanhl.c
+++ b/lib/libm/tanhl.c
@@ -1,4 +1,8 @@
-#include "libm.h"
+#include "libm.h" // for ldshape, ldshape::(anonymous)
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for expm1l, tanhl
+#include <stdint.h> // for uint32_t
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double tanhl(long double x)
diff --git a/lib/libm/tanl.c b/lib/libm/tanl.c
index c8c0984b..22657cce 100644
--- a/lib/libm/tanl.c
+++ b/lib/libm/tanl.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for ldshape, ldshape::(anonymous), __tanl, __rem_pio2l
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for tanl, M_PI_4
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double tanl(long double x)
@@ -14,7 +17,8 @@ long double tanl(long double x)
u.i.se &= 0x7fff;
if (u.i.se == 0x7fff)
- return x - x;
+ return NAN;
+
if (u.f < M_PI_4) {
if (u.i.se < 0x3fff - LDBL_MANT_DIG / 2) {
/* raise inexact if x!=0 and underflow if subnormal */
@@ -24,6 +28,6 @@ long double tanl(long double x)
return __tanl(x, 0, 0);
}
n = __rem_pio2l(x, y);
- return __tanl(y[0], y[1], n & 1);
+ return __tanl(y[0], y[1], (int)(n & 1));
}
#endif
diff --git a/lib/libm/tgamma.c b/lib/libm/tgamma.c
index afc15b4b..69759fd8 100644
--- a/lib/libm/tgamma.c
+++ b/lib/libm/tgamma.c
@@ -22,7 +22,10 @@ Gamma(x)*Gamma(-x) = -pi/(x sin(pi x))
most ideas and constants are from boost and python
*/
-#include "libm.h"
+#include "libm.h" // for __cos, __sin, FORCE_EVAL
+
+#include <math.h> // for floor, double_t, exp, pow, tgamma, INFINITY
+#include <stdint.h> // for uint32_t, uint64_t
static const double pi = 3.141592653589793238462643383279502884;
@@ -37,7 +40,7 @@ static double sinpi(double x)
x = 2 * (x - floor(x));
/* reduce x into [-.25,.25] */
- n = 4 * x;
+ n = (int)(4 * x);
n = (n + 1) / 2;
x -= n * 0.5;
@@ -132,8 +135,8 @@ double tgamma(double x)
} u = { x };
double absx, y;
double_t dy, z, r;
- uint32_t ix = u.i >> 32 & 0x7fffffff;
- int sign = u.i >> 63;
+ uint32_t ix = (uint32_t)(u.i >> 32) & 0x7fffffff;
+ int sign = (int)(u.i >> 63);
/* special cases */
if (ix >= 0x7ff00000)
@@ -149,7 +152,7 @@ double tgamma(double x)
if (x == floor(x)) {
if (sign)
return 0 / 0.0;
- if (x <= sizeof fact / sizeof *fact)
+ if (x <= ((double)sizeof(fact) / (double)(sizeof *fact)))
return fact[(int)x - 1];
}
diff --git a/lib/libm/tgammaf.c b/lib/libm/tgammaf.c
index b4ca51c9..650f8dd7 100644
--- a/lib/libm/tgammaf.c
+++ b/lib/libm/tgammaf.c
@@ -1,6 +1,6 @@
-#include <math.h>
+#include <math.h> // for tgamma, tgammaf
float tgammaf(float x)
{
- return tgamma(x);
+ return (float)tgamma((double)x);
}
diff --git a/lib/libm/tgammal.c b/lib/libm/tgammal.c
index 1ebbfab8..54270091 100644
--- a/lib/libm/tgammal.c
+++ b/lib/libm/tgammal.c
@@ -48,7 +48,10 @@
*
*/
-#include "libm.h"
+#include "libm.h" // for __polevll
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP
+#include <math.h> // for fabsl, floorl, powl, expl, sinl, tgammal, INFINITY
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double tgammal(long double x)
@@ -250,7 +253,7 @@ long double tgammal(long double x)
small:
/* z==1 if x was originally +-0 */
if (x == 0 && z != 1)
- return x / x;
+ return NAN;
if (x < 0.0) {
x = -x;
q = z / (x * __polevll(x, SN, 8));
diff --git a/lib/libm/trunc.c b/lib/libm/trunc.c
index d76f9993..4e5fa18b 100644
--- a/lib/libm/trunc.c
+++ b/lib/libm/trunc.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for FORCE_EVAL
+
+#include <math.h> // for trunc
+#include <stdint.h> // for uint64_t
double trunc(double x)
{
diff --git a/lib/libm/truncf.c b/lib/libm/truncf.c
index 4cdf082e..fc44f6c7 100644
--- a/lib/libm/truncf.c
+++ b/lib/libm/truncf.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for FORCE_EVAL
+
+#include <math.h> // for truncf
+#include <stdint.h> // for uint32_t
float truncf(float x)
{
diff --git a/lib/libm/truncl.c b/lib/libm/truncl.c
index 00e459ce..1771e33c 100644
--- a/lib/libm/truncl.c
+++ b/lib/libm/truncl.c
@@ -1,4 +1,7 @@
-#include "libm.h"
+#include "libm.h" // for ldshape, ldshape::(anonymous), FORCE_EVAL
+
+#include <float.h> // for LDBL_MANT_DIG, LDBL_MAX_EXP, LDBL_EPSILON
+#include <math.h> // for truncl
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double truncl(long double x)
diff --git a/makefile b/makefile
index ed552e29..a322da35 100644
--- a/makefile
+++ b/makefile
@@ -57,7 +57,7 @@ endif
# CFLAGS
-KBUILD_CFLAGS :=
+KBUILD_CFLAGS := -x c
KBUILD_CFLAGS += -Wall -Wextra
KBUILD_CFLAGS += -nostdinc
@@ -152,7 +152,7 @@ include-what-you-use: compile_commands.json
--reorder
clang-tidy: compile_commands.json
- $(Q)clang-tidy -header-filter=.* -p=. -fix -fix-errors $(shell find . -name '*.c' -o -name '*.h' | grep -v './scripts/\|dtoa\|linux\|arch\|bits') \
+ $(Q)clang-tidy -header-filter=.* -p=. -fix -fix-errors $(shell find . -name '*.c' -o -name '*.h' | grep -v './scripts/\|dtoa\|linux\|arch\|bits\|libm') \
--export-fixes=clang-tidy-fixes.yaml
clang-format: