[clang] [libc] [llvm] [clang] Make __builtin_expf constexpr. (PR #140841)
via cfe-commits
cfe-commits at lists.llvm.org
Tue May 20 20:37:30 PDT 2025
https://github.com/lntue created https://github.com/llvm/llvm-project/pull/140841
A draft PR to make `__builtin_expf` constexpr using LLVM libc math implementation.
>From ae2e3361949981a48cb5aaeb60d9493a3d1e5f51 Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue.h at gmail.com>
Date: Wed, 21 May 2025 02:58:45 +0000
Subject: [PATCH 1/4] [libc] Refactor libc_errno.h to libc/src/__support
folder, making LIBC_ERRNO_MODE=LIBC_ERRNO_MODE_SYSTEM to be header-only.
---
.../modules/LLVMLibCCompileOptionRules.cmake | 4 +
libc/cmake/modules/LLVMLibCTestRules.cmake | 4 +-
libc/docs/configure.rst | 2 +-
libc/docs/dev/code_style.rst | 4 +-
libc/src/__support/FPUtil/FEnvImpl.h | 2 +-
libc/src/__support/File/dir.cpp | 2 +-
libc/src/__support/File/file.cpp | 2 +-
libc/src/__support/File/linux/file.cpp | 2 +-
libc/src/__support/File/linux/lseekImpl.h | 2 +-
libc/src/__support/HashTable/randomness.h | 2 +-
libc/src/__support/OSUtil/linux/fcntl.cpp | 2 +-
libc/src/__support/OSUtil/linux/vdso.cpp | 2 +-
.../tables/linux_extension_errors.h | 2 +-
libc/src/__support/libc_errno.h | 93 +++++++++++++++++++
libc/src/__support/threads/linux/thread.cpp | 2 +-
libc/src/dirent/closedir.cpp | 2 +-
libc/src/dirent/opendir.cpp | 2 +-
libc/src/dirent/readdir.cpp | 2 +-
libc/src/errno/CMakeLists.txt | 15 ---
libc/src/errno/libc_errno.cpp | 51 +---------
libc/src/errno/libc_errno.h | 47 ----------
libc/src/fcntl/linux/creat.cpp | 2 +-
libc/src/fcntl/linux/open.cpp | 2 +-
libc/src/fcntl/linux/openat.cpp | 2 +-
libc/src/inttypes/strtoimax.cpp | 2 +-
libc/src/inttypes/strtoumax.cpp | 2 +-
libc/src/math/generic/exp10m1f.cpp | 2 +-
libc/src/math/generic/exp2m1f.cpp | 2 +-
libc/src/math/generic/nan.cpp | 2 +-
libc/src/math/generic/nanf.cpp | 2 +-
libc/src/math/generic/nanf128.cpp | 2 +-
libc/src/math/generic/nanf16.cpp | 2 +-
libc/src/math/generic/nanl.cpp | 2 +-
libc/src/poll/linux/poll.cpp | 2 +-
libc/src/pthread/pthread_atfork.cpp | 2 +-
.../pthread/pthread_attr_setdetachstate.cpp | 2 +-
.../src/pthread/pthread_attr_setguardsize.cpp | 2 +-
libc/src/pthread/pthread_attr_setstack.cpp | 2 +-
.../src/pthread/pthread_attr_setstacksize.cpp | 2 +-
.../src/pthread/pthread_condattr_setclock.cpp | 2 +-
.../pthread/pthread_condattr_setpshared.cpp | 2 +-
libc/src/pthread/pthread_create.cpp | 2 +-
libc/src/pthread/pthread_key_create.cpp | 2 +-
libc/src/pthread/pthread_key_delete.cpp | 2 +-
.../pthread/pthread_mutexattr_setpshared.cpp | 2 +-
.../pthread/pthread_mutexattr_setrobust.cpp | 2 +-
.../src/pthread/pthread_mutexattr_settype.cpp | 2 +-
.../pthread/pthread_rwlock_timedrdlock.cpp | 2 +-
libc/src/pthread/pthread_rwlock_trywrlock.cpp | 2 +-
libc/src/pthread/pthread_rwlock_unlock.cpp | 2 +-
.../pthread/pthread_rwlockattr_setkind_np.cpp | 2 +-
.../pthread/pthread_rwlockattr_setpshared.cpp | 2 +-
libc/src/pthread/pthread_setspecific.cpp | 2 +-
.../sched/linux/sched_get_priority_max.cpp | 2 +-
.../sched/linux/sched_get_priority_min.cpp | 2 +-
libc/src/sched/linux/sched_getaffinity.cpp | 2 +-
libc/src/sched/linux/sched_getparam.cpp | 2 +-
libc/src/sched/linux/sched_getscheduler.cpp | 2 +-
.../src/sched/linux/sched_rr_get_interval.cpp | 2 +-
libc/src/sched/linux/sched_setaffinity.cpp | 2 +-
libc/src/sched/linux/sched_setparam.cpp | 2 +-
libc/src/sched/linux/sched_setscheduler.cpp | 2 +-
libc/src/sched/linux/sched_yield.cpp | 2 +-
libc/src/search/hcreate.cpp | 2 +-
libc/src/search/hcreate_r.cpp | 2 +-
libc/src/search/hdestroy_r.cpp | 2 +-
libc/src/search/hsearch.cpp | 2 +-
libc/src/search/hsearch_r.cpp | 2 +-
libc/src/signal/linux/kill.cpp | 2 +-
libc/src/signal/linux/sigaction.cpp | 2 +-
libc/src/signal/linux/sigaddset.cpp | 2 +-
libc/src/signal/linux/sigaltstack.cpp | 2 +-
libc/src/signal/linux/sigdelset.cpp | 2 +-
libc/src/signal/linux/sigemptyset.cpp | 2 +-
libc/src/signal/linux/sigfillset.cpp | 2 +-
libc/src/signal/linux/sigprocmask.cpp | 2 +-
.../posix_spawn_file_actions_addclose.cpp | 2 +-
.../posix_spawn_file_actions_adddup2.cpp | 2 +-
.../posix_spawn_file_actions_addopen.cpp | 2 +-
.../posix_spawn_file_actions_destroy.cpp | 2 +-
libc/src/stdio/fopencookie.cpp | 2 +-
libc/src/stdio/generic/fclose.cpp | 2 +-
libc/src/stdio/generic/fflush.cpp | 2 +-
libc/src/stdio/generic/fgetc.cpp | 2 +-
libc/src/stdio/generic/fgetc_unlocked.cpp | 2 +-
libc/src/stdio/generic/fgets.cpp | 2 +-
libc/src/stdio/generic/fopen.cpp | 2 +-
libc/src/stdio/generic/fputc.cpp | 2 +-
libc/src/stdio/generic/fputs.cpp | 2 +-
libc/src/stdio/generic/fread.cpp | 2 +-
libc/src/stdio/generic/fread_unlocked.cpp | 2 +-
libc/src/stdio/generic/fseek.cpp | 2 +-
libc/src/stdio/generic/fseeko.cpp | 2 +-
libc/src/stdio/generic/ftell.cpp | 2 +-
libc/src/stdio/generic/ftello.cpp | 2 +-
libc/src/stdio/generic/fwrite.cpp | 2 +-
libc/src/stdio/generic/fwrite_unlocked.cpp | 2 +-
libc/src/stdio/generic/getc.cpp | 2 +-
libc/src/stdio/generic/getc_unlocked.cpp | 2 +-
libc/src/stdio/generic/getchar.cpp | 2 +-
libc/src/stdio/generic/getchar_unlocked.cpp | 2 +-
libc/src/stdio/generic/putc.cpp | 2 +-
libc/src/stdio/generic/putchar.cpp | 2 +-
libc/src/stdio/generic/puts.cpp | 2 +-
libc/src/stdio/gpu/fprintf.cpp | 2 +-
libc/src/stdio/gpu/fputs.cpp | 2 +-
libc/src/stdio/gpu/printf.cpp | 2 +-
libc/src/stdio/gpu/puts.cpp | 2 +-
libc/src/stdio/gpu/vfprintf.cpp | 2 +-
libc/src/stdio/gpu/vprintf.cpp | 2 +-
libc/src/stdio/linux/fdopen.cpp | 2 +-
libc/src/stdio/linux/remove.cpp | 2 +-
libc/src/stdio/linux/rename.cpp | 2 +-
libc/src/stdio/printf_core/parser.h | 2 +-
libc/src/stdio/setbuf.cpp | 2 +-
libc/src/stdio/setvbuf.cpp | 2 +-
libc/src/stdlib/atof.cpp | 2 +-
libc/src/stdlib/atoi.cpp | 2 +-
libc/src/stdlib/atol.cpp | 2 +-
libc/src/stdlib/atoll.cpp | 2 +-
libc/src/stdlib/strtod.cpp | 2 +-
libc/src/stdlib/strtod_l.cpp | 2 +-
libc/src/stdlib/strtof.cpp | 2 +-
libc/src/stdlib/strtof_l.cpp | 2 +-
libc/src/stdlib/strtol.cpp | 2 +-
libc/src/stdlib/strtol_l.cpp | 2 +-
libc/src/stdlib/strtold.cpp | 2 +-
libc/src/stdlib/strtold_l.cpp | 2 +-
libc/src/stdlib/strtoll.cpp | 2 +-
libc/src/stdlib/strtoll_l.cpp | 2 +-
libc/src/stdlib/strtoul.cpp | 2 +-
libc/src/stdlib/strtoul_l.cpp | 2 +-
libc/src/stdlib/strtoull.cpp | 2 +-
libc/src/stdlib/strtoull_l.cpp | 2 +-
libc/src/string/strdup.cpp | 2 +-
libc/src/sys/auxv/linux/getauxval.cpp | 2 +-
libc/src/sys/epoll/linux/epoll_create.cpp | 2 +-
libc/src/sys/epoll/linux/epoll_create1.cpp | 2 +-
libc/src/sys/epoll/linux/epoll_ctl.cpp | 2 +-
libc/src/sys/epoll/linux/epoll_pwait.cpp | 2 +-
libc/src/sys/epoll/linux/epoll_pwait2.cpp | 2 +-
libc/src/sys/epoll/linux/epoll_wait.cpp | 2 +-
libc/src/sys/mman/linux/madvise.cpp | 2 +-
libc/src/sys/mman/linux/mincore.cpp | 2 +-
libc/src/sys/mman/linux/mlock.cpp | 2 +-
libc/src/sys/mman/linux/mlock2.cpp | 2 +-
libc/src/sys/mman/linux/mlockall.cpp | 2 +-
libc/src/sys/mman/linux/mmap.cpp | 2 +-
libc/src/sys/mman/linux/mprotect.cpp | 2 +-
libc/src/sys/mman/linux/mremap.cpp | 2 +-
libc/src/sys/mman/linux/msync.cpp | 2 +-
libc/src/sys/mman/linux/munlock.cpp | 2 +-
libc/src/sys/mman/linux/munlockall.cpp | 2 +-
libc/src/sys/mman/linux/munmap.cpp | 4 +-
libc/src/sys/mman/linux/remap_file_pages.cpp | 2 +-
libc/src/sys/mman/linux/shm_common.h | 2 +-
libc/src/sys/prctl/linux/prctl.cpp | 2 +-
libc/src/sys/random/linux/getrandom.cpp | 2 +-
libc/src/sys/resource/linux/getrlimit.cpp | 2 +-
libc/src/sys/resource/linux/setrlimit.cpp | 2 +-
libc/src/sys/select/linux/select.cpp | 2 +-
libc/src/sys/sendfile/linux/sendfile.cpp | 2 +-
libc/src/sys/socket/linux/bind.cpp | 2 +-
libc/src/sys/socket/linux/recv.cpp | 2 +-
libc/src/sys/socket/linux/recvfrom.cpp | 2 +-
libc/src/sys/socket/linux/recvmsg.cpp | 2 +-
libc/src/sys/socket/linux/send.cpp | 2 +-
libc/src/sys/socket/linux/sendmsg.cpp | 2 +-
libc/src/sys/socket/linux/sendto.cpp | 2 +-
libc/src/sys/socket/linux/socket.cpp | 2 +-
libc/src/sys/socket/linux/socketpair.cpp | 2 +-
libc/src/sys/stat/linux/chmod.cpp | 2 +-
libc/src/sys/stat/linux/fchmod.cpp | 2 +-
libc/src/sys/stat/linux/fchmodat.cpp | 2 +-
libc/src/sys/stat/linux/fstat.cpp | 2 +-
libc/src/sys/stat/linux/lstat.cpp | 2 +-
libc/src/sys/stat/linux/mkdir.cpp | 2 +-
libc/src/sys/stat/linux/mkdirat.cpp | 2 +-
libc/src/sys/stat/linux/stat.cpp | 2 +-
libc/src/sys/statvfs/linux/statfs_utils.h | 2 +-
libc/src/sys/time/linux/getitimer.cpp | 2 +-
libc/src/sys/time/linux/setitimer.cpp | 2 +-
libc/src/sys/time/linux/utimes.cpp | 2 +-
libc/src/sys/uio/linux/readv.cpp | 2 +-
libc/src/sys/uio/linux/writev.cpp | 2 +-
libc/src/sys/utsname/linux/uname.cpp | 2 +-
libc/src/sys/wait/wait4Impl.h | 2 +-
libc/src/termios/linux/cfsetispeed.cpp | 2 +-
libc/src/termios/linux/cfsetospeed.cpp | 2 +-
libc/src/termios/linux/tcdrain.cpp | 2 +-
libc/src/termios/linux/tcflow.cpp | 2 +-
libc/src/termios/linux/tcflush.cpp | 2 +-
libc/src/termios/linux/tcgetattr.cpp | 2 +-
libc/src/termios/linux/tcgetsid.cpp | 2 +-
libc/src/termios/linux/tcsendbreak.cpp | 2 +-
libc/src/termios/linux/tcsetattr.cpp | 2 +-
libc/src/threads/thrd_create.cpp | 2 +-
libc/src/time/linux/clock.cpp | 2 +-
libc/src/time/linux/clock_gettime.cpp | 2 +-
libc/src/time/linux/gettimeofday.cpp | 2 +-
libc/src/time/linux/nanosleep.cpp | 2 +-
libc/src/time/linux/timespec_get.cpp | 2 +-
libc/src/time/time.cpp | 2 +-
libc/src/time/time_utils.h | 2 +-
libc/src/time/windows/clock_getres.cpp | 2 +-
libc/src/unistd/linux/access.cpp | 2 +-
libc/src/unistd/linux/chdir.cpp | 2 +-
libc/src/unistd/linux/close.cpp | 2 +-
libc/src/unistd/linux/dup.cpp | 2 +-
libc/src/unistd/linux/dup2.cpp | 2 +-
libc/src/unistd/linux/dup3.cpp | 2 +-
libc/src/unistd/linux/execv.cpp | 2 +-
libc/src/unistd/linux/execve.cpp | 2 +-
libc/src/unistd/linux/fchdir.cpp | 2 +-
libc/src/unistd/linux/fork.cpp | 2 +-
libc/src/unistd/linux/fsync.cpp | 2 +-
libc/src/unistd/linux/ftruncate.cpp | 2 +-
libc/src/unistd/linux/getcwd.cpp | 2 +-
libc/src/unistd/linux/getentropy.cpp | 2 +-
libc/src/unistd/linux/getsid.cpp | 2 +-
libc/src/unistd/linux/isatty.cpp | 2 +-
libc/src/unistd/linux/link.cpp | 2 +-
libc/src/unistd/linux/linkat.cpp | 2 +-
libc/src/unistd/linux/lseek.cpp | 2 +-
libc/src/unistd/linux/pathconf.cpp | 2 +-
libc/src/unistd/linux/pathconf_utils.cpp | 2 +-
libc/src/unistd/linux/pipe.cpp | 4 +-
libc/src/unistd/linux/pipe2.cpp | 2 +-
libc/src/unistd/linux/pread.cpp | 6 +-
libc/src/unistd/linux/pwrite.cpp | 2 +-
libc/src/unistd/linux/read.cpp | 4 +-
libc/src/unistd/linux/readlink.cpp | 2 +-
libc/src/unistd/linux/readlinkat.cpp | 2 +-
libc/src/unistd/linux/rmdir.cpp | 2 +-
libc/src/unistd/linux/symlink.cpp | 2 +-
libc/src/unistd/linux/symlinkat.cpp | 2 +-
libc/src/unistd/linux/syscall.cpp | 2 +-
libc/src/unistd/linux/sysconf.cpp | 2 +-
libc/src/unistd/linux/truncate.cpp | 2 +-
libc/src/unistd/linux/unlink.cpp | 2 +-
libc/src/unistd/linux/unlinkat.cpp | 2 +-
libc/src/unistd/linux/write.cpp | 2 +-
libc/src/unistd/windows/getentropy.cpp | 2 +-
libc/test/UnitTest/ErrnoCheckingTest.h | 2 +-
libc/test/UnitTest/ErrnoSetterMatcher.h | 2 +-
.../src/pthread/pthread_create_test.cpp | 2 +-
.../src/pthread/pthread_join_test.cpp | 2 +-
.../src/pthread/pthread_name_test.cpp | 2 +-
.../integration/src/unistd/getcwd_test.cpp | 2 +-
.../integration/startup/linux/tls_test.cpp | 2 +-
libc/test/src/__support/str_to_fp_test.h | 2 +-
.../src/__support/str_to_integer_test.cpp | 2 +-
libc/test/src/dirent/dirent_test.cpp | 2 +-
libc/test/src/errno/errno_test.cpp | 2 +-
libc/test/src/fcntl/creat_test.cpp | 2 +-
libc/test/src/fcntl/fcntl_test.cpp | 2 +-
libc/test/src/fcntl/openat_test.cpp | 2 +-
libc/test/src/math/acosf_test.cpp | 2 +-
libc/test/src/math/acoshf16_test.cpp | 2 +-
libc/test/src/math/acoshf_test.cpp | 2 +-
libc/test/src/math/asinf_test.cpp | 2 +-
libc/test/src/math/asinhf_test.cpp | 2 +-
libc/test/src/math/atanf_test.cpp | 2 +-
libc/test/src/math/atanhf_test.cpp | 2 +-
libc/test/src/math/cosf_test.cpp | 2 +-
libc/test/src/math/coshf_test.cpp | 2 +-
libc/test/src/math/cospif_test.cpp | 2 +-
libc/test/src/math/exp10_test.cpp | 2 +-
libc/test/src/math/exp10f_test.cpp | 2 +-
libc/test/src/math/exp10m1f_test.cpp | 2 +-
libc/test/src/math/exp2_test.cpp | 2 +-
libc/test/src/math/exp2f_test.cpp | 2 +-
libc/test/src/math/exp2m1f_test.cpp | 2 +-
libc/test/src/math/exp_test.cpp | 2 +-
libc/test/src/math/expf_test.cpp | 2 +-
libc/test/src/math/expm1_test.cpp | 2 +-
libc/test/src/math/expm1f_test.cpp | 2 +-
libc/test/src/math/log10_test.cpp | 2 +-
libc/test/src/math/log1p_test.cpp | 2 +-
libc/test/src/math/log1pf_test.cpp | 2 +-
libc/test/src/math/log2_test.cpp | 2 +-
libc/test/src/math/log2f_test.cpp | 2 +-
libc/test/src/math/log_test.cpp | 2 +-
libc/test/src/math/sincosf_test.cpp | 2 +-
libc/test/src/math/sinf_test.cpp | 2 +-
libc/test/src/math/sinhf_test.cpp | 2 +-
libc/test/src/math/sinpif_test.cpp | 2 +-
libc/test/src/math/smoke/FModTest.h | 2 +-
libc/test/src/math/smoke/acos_test.cpp | 2 +-
libc/test/src/math/smoke/acosf16_test.cpp | 2 +-
libc/test/src/math/smoke/acosf_test.cpp | 2 +-
libc/test/src/math/smoke/acoshf16_test.cpp | 2 +-
libc/test/src/math/smoke/acoshf_test.cpp | 2 +-
libc/test/src/math/smoke/acospif16_test.cpp | 2 +-
libc/test/src/math/smoke/asinf16_test.cpp | 2 +-
libc/test/src/math/smoke/asinf_test.cpp | 2 +-
libc/test/src/math/smoke/asinhf16_test.cpp | 2 +-
libc/test/src/math/smoke/asinhf_test.cpp | 2 +-
libc/test/src/math/smoke/atan2f_test.cpp | 2 +-
libc/test/src/math/smoke/atanf_test.cpp | 2 +-
libc/test/src/math/smoke/atanhf16_test.cpp | 2 +-
libc/test/src/math/smoke/atanhf_test.cpp | 2 +-
libc/test/src/math/smoke/cosf16_test.cpp | 2 +-
libc/test/src/math/smoke/cosf_test.cpp | 2 +-
libc/test/src/math/smoke/coshf16_test.cpp | 2 +-
libc/test/src/math/smoke/coshf_test.cpp | 2 +-
libc/test/src/math/smoke/cospif16_test.cpp | 2 +-
libc/test/src/math/smoke/cospif_test.cpp | 2 +-
libc/test/src/math/smoke/exp10_test.cpp | 2 +-
libc/test/src/math/smoke/exp10f16_test.cpp | 2 +-
libc/test/src/math/smoke/exp10f_test.cpp | 2 +-
libc/test/src/math/smoke/exp10m1f16_test.cpp | 2 +-
libc/test/src/math/smoke/exp10m1f_test.cpp | 2 +-
libc/test/src/math/smoke/exp2_test.cpp | 2 +-
libc/test/src/math/smoke/exp2f16_test.cpp | 2 +-
libc/test/src/math/smoke/exp2f_test.cpp | 2 +-
libc/test/src/math/smoke/exp2m1f16_test.cpp | 2 +-
libc/test/src/math/smoke/exp2m1f_test.cpp | 2 +-
libc/test/src/math/smoke/exp_test.cpp | 2 +-
libc/test/src/math/smoke/expf16_test.cpp | 2 +-
libc/test/src/math/smoke/expf_test.cpp | 2 +-
libc/test/src/math/smoke/expm1_test.cpp | 2 +-
libc/test/src/math/smoke/expm1f16_test.cpp | 2 +-
libc/test/src/math/smoke/expm1f_test.cpp | 2 +-
libc/test/src/math/smoke/log10_test.cpp | 2 +-
libc/test/src/math/smoke/log10f16_test.cpp | 2 +-
libc/test/src/math/smoke/log1p_test.cpp | 2 +-
libc/test/src/math/smoke/log1pf_test.cpp | 2 +-
libc/test/src/math/smoke/log2_test.cpp | 2 +-
libc/test/src/math/smoke/log2f16_test.cpp | 2 +-
libc/test/src/math/smoke/log2f_test.cpp | 2 +-
libc/test/src/math/smoke/log_test.cpp | 2 +-
libc/test/src/math/smoke/logf16_test.cpp | 2 +-
libc/test/src/math/smoke/sincosf_test.cpp | 2 +-
libc/test/src/math/smoke/sinf16_test.cpp | 2 +-
libc/test/src/math/smoke/sinf_test.cpp | 2 +-
libc/test/src/math/smoke/sinhf16_test.cpp | 2 +-
libc/test/src/math/smoke/sinhf_test.cpp | 2 +-
libc/test/src/math/smoke/sinpif16_test.cpp | 2 +-
libc/test/src/math/smoke/sinpif_test.cpp | 2 +-
libc/test/src/math/smoke/tanf16_test.cpp | 2 +-
libc/test/src/math/smoke/tanf_test.cpp | 2 +-
libc/test/src/math/smoke/tanhf16_test.cpp | 2 +-
libc/test/src/math/smoke/tanhf_test.cpp | 2 +-
libc/test/src/math/smoke/tanpif16_test.cpp | 2 +-
libc/test/src/math/tanf_test.cpp | 2 +-
libc/test/src/math/tanhf_test.cpp | 2 +-
libc/test/src/poll/poll_test.cpp | 2 +-
libc/test/src/sched/affinity_test.cpp | 2 +-
libc/test/src/sched/cpu_count_test.cpp | 2 +-
libc/test/src/sched/get_priority_test.cpp | 2 +-
.../src/sched/param_and_scheduler_test.cpp | 2 +-
.../src/sched/sched_rr_get_interval_test.cpp | 2 +-
libc/test/src/sched/yield_test.cpp | 2 +-
libc/test/src/signal/sigaltstack_test.cpp | 2 +-
libc/test/src/signal/signal_test.cpp | 2 +-
libc/test/src/signal/sigprocmask_test.cpp | 2 +-
.../spawn/posix_spawn_file_actions_test.cpp | 2 +-
libc/test/src/stdio/fdopen_test.cpp | 2 +-
libc/test/src/stdio/fgetc_test.cpp | 2 +-
libc/test/src/stdio/fgetc_unlocked_test.cpp | 2 +-
libc/test/src/stdio/fgets_test.cpp | 2 +-
libc/test/src/stdio/fileop_test.cpp | 2 +-
libc/test/src/stdio/fopencookie_test.cpp | 2 +-
libc/test/src/stdio/remove_test.cpp | 2 +-
libc/test/src/stdio/rename_test.cpp | 2 +-
libc/test/src/stdio/setvbuf_test.cpp | 2 +-
libc/test/src/stdio/sprintf_test.cpp | 2 +-
libc/test/src/stdio/unlocked_fileop_test.cpp | 2 +-
libc/test/src/stdlib/StrtolTest.h | 2 +-
libc/test/src/stdlib/atof_test.cpp | 2 +-
libc/test/src/stdlib/strtod_test.cpp | 2 +-
libc/test/src/stdlib/strtof_test.cpp | 2 +-
libc/test/src/stdlib/strtoint32_test.cpp | 2 +-
libc/test/src/stdlib/strtoint64_test.cpp | 2 +-
libc/test/src/stdlib/strtold_test.cpp | 2 +-
libc/test/src/string/strdup_test.cpp | 2 +-
.../src/sys/auxv/linux/getauxval_test.cpp | 2 +-
libc/test/src/sys/mman/linux/madvise_test.cpp | 2 +-
libc/test/src/sys/mman/linux/mincore_test.cpp | 2 +-
libc/test/src/sys/mman/linux/mlock_test.cpp | 2 +-
libc/test/src/sys/mman/linux/mmap_test.cpp | 2 +-
.../test/src/sys/mman/linux/mprotect_test.cpp | 2 +-
libc/test/src/sys/mman/linux/mremap_test.cpp | 2 +-
libc/test/src/sys/mman/linux/msync_test.cpp | 2 +-
.../src/sys/mman/linux/posix_madvise_test.cpp | 2 +-
.../sys/mman/linux/remap_file_pages_test.cpp | 2 +-
libc/test/src/sys/prctl/linux/prctl_test.cpp | 2 +-
.../src/sys/random/linux/getrandom_test.cpp | 2 +-
.../sys/resource/getrlimit_setrlimit_test.cpp | 2 +-
libc/test/src/sys/select/select_ui_test.cpp | 2 +-
libc/test/src/sys/sendfile/sendfile_test.cpp | 2 +-
libc/test/src/sys/stat/chmod_test.cpp | 2 +-
libc/test/src/sys/stat/fchmod_test.cpp | 2 +-
libc/test/src/sys/stat/fchmodat_test.cpp | 2 +-
libc/test/src/sys/stat/fstat_test.cpp | 2 +-
libc/test/src/sys/stat/lstat_test.cpp | 2 +-
libc/test/src/sys/stat/stat_test.cpp | 2 +-
.../src/sys/statvfs/linux/statvfs_test.cpp | 2 +-
libc/test/src/sys/time/utimes_test.cpp | 2 +-
libc/test/src/termios/termios_test.cpp | 2 +-
libc/test/src/time/asctime_r_test.cpp | 2 +-
libc/test/src/time/asctime_test.cpp | 2 +-
libc/test/src/time/ctime_r_test.cpp | 2 +-
libc/test/src/time/ctime_test.cpp | 2 +-
libc/test/src/time/gmtime_test.cpp | 2 +-
libc/test/src/time/nanosleep_test.cpp | 2 +-
.../llvm-project-overlay/libc/BUILD.bazel | 2 +-
408 files changed, 513 insertions(+), 517 deletions(-)
create mode 100644 libc/src/__support/libc_errno.h
delete mode 100644 libc/src/errno/libc_errno.h
diff --git a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
index 0facb0b9be0c1..a98e7276bef80 100644
--- a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
+++ b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
@@ -106,6 +106,10 @@ function(_get_compile_options_from_config output_var)
list(APPEND config_options "-DLIBC_MATH=${LIBC_CONF_MATH_OPTIMIZATIONS}")
endif()
+ if(LIBC_CONF_ERRNO_MODE)
+ set(APPEND config_options "-DLIBC_ERRNO_MODE=${LIBC_CONF_ERRNO_MODE}")
+ endif()
+
set(${output_var} ${config_options} PARENT_SCOPE)
endfunction(_get_compile_options_from_config)
diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake
index 3f804694b5bae..0bef0763ec999 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -1,5 +1,6 @@
function(_get_common_test_compile_options output_var c_test flags)
_get_compile_options_from_flags(compile_flags ${flags})
+ _get_compile_options_from_config(config_flags)
# Remove -fno-math-errno if it was added.
if(LIBC_ADD_FNO_MATH_ERRNO)
@@ -9,7 +10,8 @@ function(_get_common_test_compile_options output_var c_test flags)
set(compile_options
${LIBC_COMPILE_OPTIONS_DEFAULT}
${LIBC_TEST_COMPILE_OPTIONS_DEFAULT}
- ${compile_flags})
+ ${compile_flags}
+ ${config_flags})
if(LLVM_LIBC_COMPILER_IS_GCC_COMPATIBLE)
list(APPEND compile_options "-fpie")
diff --git a/libc/docs/configure.rst b/libc/docs/configure.rst
index 8d53390ae19bf..dee9a63101eb9 100644
--- a/libc/docs/configure.rst
+++ b/libc/docs/configure.rst
@@ -33,7 +33,7 @@ to learn about the defaults for your platform and target.
* **"general" options**
- ``LIBC_ADD_NULL_CHECKS``: Add nullptr checks in the library's implementations to some functions for which passing nullptr is undefined behavior.
* **"math" options**
- - ``LIBC_CONF_FREXP_INF_NAN_EXPONENT``: The value written back to the second parameter when calling frexp/frexpf/frexpl` with `+/-Inf`/`NaN` is unspecified. Configure an explicit exp value for Inf/NaN inputs.
+ - ``LIBC_CONF_FREXP_INF_NAN_EXPONENT``: The value written back to the second parameter when calling frexp/frexpf/frexpl` with `+/-Inf`/`NaN` is unspecified. Configue an explicit exp value for Inf/NaN inputs.
- ``LIBC_CONF_MATH_OPTIMIZATIONS``: Configures optimizations for math functions. Values accepted are LIBC_MATH_SKIP_ACCURATE_PASS, LIBC_MATH_SMALL_TABLES, LIBC_MATH_NO_ERRNO, LIBC_MATH_NO_EXCEPT, and LIBC_MATH_FAST.
* **"printf" options**
- ``LIBC_CONF_PRINTF_DISABLE_FIXED_POINT``: Disable printing fixed point values in printf and friends.
diff --git a/libc/docs/dev/code_style.rst b/libc/docs/dev/code_style.rst
index 0bd3a69ae3ffe..86247966552f9 100644
--- a/libc/docs/dev/code_style.rst
+++ b/libc/docs/dev/code_style.rst
@@ -101,7 +101,7 @@ test infrastructure itself can be affected. To avoid perturbing the unit test
infrastructure around the setting of ``errno``, the following rules are to be
followed:
-#. A special macro named ``libc_errno`` defined in ``src/errno/libc_errno.h``
+#. A special macro named ``libc_errno`` defined in ``src/__support/libc_errno.h``
should be used when setting ``errno`` from libc runtime code. For example,
code to set ``errno`` to ``EINVAL`` should be:
@@ -117,7 +117,7 @@ followed:
`ErrorOr <https://github.com/llvm/llvm-project/blob/main/libc/src/__support/error_or.h>`_
to return error values.
-#. The header file ``src/errno/libc_errno.h`` is shipped as part of the target
+#. The header file ``src/__support/libc_errno.h`` is shipped as part of the target
corresponding to the ``errno`` entrypoint ``libc.src.errno.errno``. We do
not in general allow dependencies between entrypoints. However, the ``errno``
entrypoint is the only exceptional entrypoint on which other entrypoints
diff --git a/libc/src/__support/FPUtil/FEnvImpl.h b/libc/src/__support/FPUtil/FEnvImpl.h
index 4c8f34a435bdf..50a101f833c55 100644
--- a/libc/src/__support/FPUtil/FEnvImpl.h
+++ b/libc/src/__support/FPUtil/FEnvImpl.h
@@ -12,10 +12,10 @@
#include "hdr/fenv_macros.h"
#include "hdr/math_macros.h"
#include "hdr/types/fenv_t.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/attributes.h" // LIBC_INLINE
#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/architectures.h"
-#include "src/errno/libc_errno.h"
#if defined(LIBC_TARGET_ARCH_IS_AARCH64) && defined(__ARM_FP)
#if defined(__APPLE__)
diff --git a/libc/src/__support/File/dir.cpp b/libc/src/__support/File/dir.cpp
index 21b0106f70106..aea8862c15f7f 100644
--- a/libc/src/__support/File/dir.cpp
+++ b/libc/src/__support/File/dir.cpp
@@ -11,8 +11,8 @@
#include "src/__support/CPP/mutex.h" // lock_guard
#include "src/__support/CPP/new.h"
#include "src/__support/error_or.h"
+#include "src/__support/libc_errno.h" // For error macros
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h" // For error macros
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/__support/File/file.cpp b/libc/src/__support/File/file.cpp
index 528542cccf324..303852dbbb717 100644
--- a/libc/src/__support/File/file.cpp
+++ b/libc/src/__support/File/file.cpp
@@ -13,8 +13,8 @@
#include "hdr/types/off_t.h"
#include "src/__support/CPP/new.h"
#include "src/__support/CPP/span.h"
+#include "src/__support/libc_errno.h" // For error macros
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h" // For error macros
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/__support/File/linux/file.cpp b/libc/src/__support/File/linux/file.cpp
index 824c1f200e8c5..761e352f74ead 100644
--- a/libc/src/__support/File/linux/file.cpp
+++ b/libc/src/__support/File/linux/file.cpp
@@ -15,8 +15,8 @@
#include "src/__support/File/linux/lseekImpl.h"
#include "src/__support/OSUtil/fcntl.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
+#include "src/__support/libc_errno.h" // For error macros
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h" // For error macros
#include "hdr/fcntl_macros.h" // For mode_t and other flags to the open syscall
#include <sys/stat.h> // For S_IS*, S_IF*, and S_IR* flags.
diff --git a/libc/src/__support/File/linux/lseekImpl.h b/libc/src/__support/File/linux/lseekImpl.h
index a034913d9f6ec..300e5c5dd55bf 100644
--- a/libc/src/__support/File/linux/lseekImpl.h
+++ b/libc/src/__support/File/linux/lseekImpl.h
@@ -13,8 +13,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
#include "src/__support/error_or.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <stdint.h> // For uint64_t.
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/__support/HashTable/randomness.h b/libc/src/__support/HashTable/randomness.h
index 244dd41be3eec..6b58a4125f785 100644
--- a/libc/src/__support/HashTable/randomness.h
+++ b/libc/src/__support/HashTable/randomness.h
@@ -14,7 +14,7 @@
#include "src/__support/macros/attributes.h"
#include "src/__support/macros/config.h"
#if defined(LIBC_HASHTABLE_USE_GETRANDOM)
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/sys/random/getrandom.h"
#endif
diff --git a/libc/src/__support/OSUtil/linux/fcntl.cpp b/libc/src/__support/OSUtil/linux/fcntl.cpp
index 4742b2a00220b..99e16ad58c918 100644
--- a/libc/src/__support/OSUtil/linux/fcntl.cpp
+++ b/libc/src/__support/OSUtil/linux/fcntl.cpp
@@ -15,8 +15,8 @@
#include "hdr/types/struct_flock64.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <stdarg.h>
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/__support/OSUtil/linux/vdso.cpp b/libc/src/__support/OSUtil/linux/vdso.cpp
index 8c9bd3e1bcc72..e4e53c3c2a0f2 100644
--- a/libc/src/__support/OSUtil/linux/vdso.cpp
+++ b/libc/src/__support/OSUtil/linux/vdso.cpp
@@ -11,9 +11,9 @@
#include "src/__support/CPP/array.h"
#include "src/__support/CPP/optional.h"
#include "src/__support/CPP/string_view.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/threads/callonce.h"
#include "src/__support/threads/linux/futex_word.h"
-#include "src/errno/libc_errno.h"
#include "src/sys/auxv/getauxval.h"
#include <linux/auxvec.h>
diff --git a/libc/src/__support/StringUtil/tables/linux_extension_errors.h b/libc/src/__support/StringUtil/tables/linux_extension_errors.h
index 425590f6e91c9..de637d60bea97 100644
--- a/libc/src/__support/StringUtil/tables/linux_extension_errors.h
+++ b/libc/src/__support/StringUtil/tables/linux_extension_errors.h
@@ -10,8 +10,8 @@
#define LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_TABLES_LINUX_EXTENSION_ERRORS_H
#include "src/__support/StringUtil/message_mapper.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/__support/libc_errno.h b/libc/src/__support/libc_errno.h
new file mode 100644
index 0000000000000..cf971d0bd1ae3
--- /dev/null
+++ b/libc/src/__support/libc_errno.h
@@ -0,0 +1,93 @@
+//===-- Implementation header for libc_errno --------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_LIBC_ERRNO_H
+#define LLVM_LIBC_SRC___SUPPORT_LIBC_ERRNO_H
+
+#include "src/__support/macros/attributes.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/architectures.h"
+
+#include "hdr/errno_macros.h"
+
+// This header is to be consumed by internal implementations, in which all of
+// them should refer to `libc_errno` instead of using `errno` directly from
+// <errno.h> header.
+
+// Unit and hermetic tests should:
+// - #include "src/__support/libc_errno.h"
+// - NOT #include <errno.h>
+// - Only use `libc_errno` in the code
+// - Depend on libc.src.errno.errno
+
+// Integration tests should:
+// - NOT #include "src/__support/libc_errno.h"
+// - #include <errno.h>
+// - Use regular `errno` in the code
+// - Still depend on libc.src.errno.errno
+
+// libc uses a fallback default value, either system or thread local.
+#define LIBC_ERRNO_MODE_DEFAULT 0
+// libc never stores a value; `errno` macro uses get link-time failure.
+#define LIBC_ERRNO_MODE_UNDEFINED 1
+// libc maintains per-thread state (requires C++ `thread_local` support).
+#define LIBC_ERRNO_MODE_THREAD_LOCAL 2
+// libc maintains shared state used by all threads, contrary to standard C
+// semantics unless always single-threaded; nothing prevents data races.
+#define LIBC_ERRNO_MODE_SHARED 3
+// libc doesn't maintain any internal state, instead the embedder must define
+// `int *__llvm_libc_errno(void);` C function.
+#define LIBC_ERRNO_MODE_EXTERNAL 4
+// libc uses system `<errno.h>` `errno` macro directly in the overlay mode; in
+// fullbuild mode, effectively the same as `LIBC_ERRNO_MODE_EXTERNAL`.
+#define LIBC_ERRNO_MODE_SYSTEM 5
+
+#if !defined(LIBC_ERRNO_MODE) || LIBC_ERRNO_MODE == LIBC_ERRNO_MODE_DEFAULT
+#undef LIBC_ERRNO_MODE
+#if defined(LIBC_FULL_BUILD) || !defined(LIBC_COPT_PUBLIC_PACKAGING)
+#define LIBC_ERRNO_MODE LIBC_ERRNO_MODE_THREAD_LOCAL
+#else
+#define LIBC_ERRNO_MODE LIBC_ERRNO_MODE_SYSTEM
+#endif
+#endif // LIBC_ERRNO_MODE
+
+#if LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_DEFAULT && \
+ LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_UNDEFINED && \
+ LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_THREAD_LOCAL && \
+ LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_SHARED && \
+ LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_EXTERNAL && \
+ LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_SYSTEM
+#error LIBC_ERRNO_MODE must be one of the following values: \
+LIBC_ERRNO_MODE_DEFAULT, \
+LIBC_ERRNO_MODE_UNDEFINED, \
+LIBC_ERRNO_MODE_THREAD_LOCAL, \
+LIBC_ERRNO_MODE_SHARED, \
+LIBC_ERRNO_MODE_EXTERNAL, \
+LIBC_ERRNO_MODE_SYSTEM
+#endif
+
+#if LIBC_ERRNO_MODE == LIBC_ERRNO_MODE_SYSTEM
+#include <errno.h>
+
+#define libc_errno errno
+#else // !LIBC_ERRNO_MODE_SYSTEM
+namespace LIBC_NAMESPACE_DECL {
+
+extern "C" int *__llvm_libc_errno() noexcept;
+
+struct Errno {
+ void operator=(int);
+ operator int();
+};
+
+extern Errno libc_errno;
+
+} // namespace LIBC_NAMESPACE_DECL
+#endif // LIBC_ERRNO_MODE_SYSTEM
+
+#endif // LLVM_LIBC_SRC___SUPPORT_LIBC_ERRNO_H
diff --git a/libc/src/__support/threads/linux/thread.cpp b/libc/src/__support/threads/linux/thread.cpp
index c531d74c53355..baad26aed6851 100644
--- a/libc/src/__support/threads/linux/thread.cpp
+++ b/libc/src/__support/threads/linux/thread.cpp
@@ -14,9 +14,9 @@
#include "src/__support/OSUtil/syscall.h" // For syscall functions.
#include "src/__support/common.h"
#include "src/__support/error_or.h"
+#include "src/__support/libc_errno.h" // For error macros
#include "src/__support/macros/config.h"
#include "src/__support/threads/linux/futex_utils.h" // For FutexWordType
-#include "src/errno/libc_errno.h" // For error macros
#ifdef LIBC_TARGET_ARCH_IS_AARCH64
#include <arm_acle.h>
diff --git a/libc/src/dirent/closedir.cpp b/libc/src/dirent/closedir.cpp
index 1249ef94cf411..2f8f6f0c044db 100644
--- a/libc/src/dirent/closedir.cpp
+++ b/libc/src/dirent/closedir.cpp
@@ -10,8 +10,8 @@
#include "src/__support/File/dir.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <dirent.h>
diff --git a/libc/src/dirent/opendir.cpp b/libc/src/dirent/opendir.cpp
index fee14ef0f558d..bf47d0edac180 100644
--- a/libc/src/dirent/opendir.cpp
+++ b/libc/src/dirent/opendir.cpp
@@ -10,8 +10,8 @@
#include "src/__support/File/dir.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <dirent.h>
diff --git a/libc/src/dirent/readdir.cpp b/libc/src/dirent/readdir.cpp
index ad460b5e80b8b..f95f7c1ae8646 100644
--- a/libc/src/dirent/readdir.cpp
+++ b/libc/src/dirent/readdir.cpp
@@ -10,8 +10,8 @@
#include "src/__support/File/dir.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <dirent.h>
diff --git a/libc/src/errno/CMakeLists.txt b/libc/src/errno/CMakeLists.txt
index 1d78a5eedff96..8337ee4e3b818 100644
--- a/libc/src/errno/CMakeLists.txt
+++ b/libc/src/errno/CMakeLists.txt
@@ -3,25 +3,10 @@
# We are passing LIBC_FULL_BUILD flag in full build mode so that the
# implementation of libc_errno will know if we are in full build mode or not.
-# TODO: Move LIBC_FULL_BUILD flag to _get_common_compile_options.
-set(full_build_flag "")
-if(LLVM_LIBC_FULL_BUILD)
- set(full_build_flag "-DLIBC_FULL_BUILD")
-endif()
-
-if(LIBC_CONF_ERRNO_MODE)
- set(errno_config_copts "-DLIBC_ERRNO_MODE=${LIBC_CONF_ERRNO_MODE}")
-endif()
-
add_entrypoint_object(
errno
SRCS
libc_errno.cpp
- HDRS
- libc_errno.h # Include this
- COMPILE_OPTIONS
- ${full_build_flag}
- ${errno_config_copts}
DEPENDS
libc.hdr.errno_macros
libc.src.__support.common
diff --git a/libc/src/errno/libc_errno.cpp b/libc/src/errno/libc_errno.cpp
index d1600d1b050e3..69b69f4285d40 100644
--- a/libc/src/errno/libc_errno.cpp
+++ b/libc/src/errno/libc_errno.cpp
@@ -6,51 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#include "libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-// libc uses a fallback default value, either system or thread local.
-#define LIBC_ERRNO_MODE_DEFAULT 0
-// libc never stores a value; `errno` macro uses get link-time failure.
-#define LIBC_ERRNO_MODE_UNDEFINED 1
-// libc maintains per-thread state (requires C++ `thread_local` support).
-#define LIBC_ERRNO_MODE_THREAD_LOCAL 2
-// libc maintains shared state used by all threads, contrary to standard C
-// semantics unless always single-threaded; nothing prevents data races.
-#define LIBC_ERRNO_MODE_SHARED 3
-// libc doesn't maintain any internal state, instead the embedder must define
-// `int *__llvm_libc_errno(void);` C function.
-#define LIBC_ERRNO_MODE_EXTERNAL 4
-// libc uses system `<errno.h>` `errno` macro directly in the overlay mode; in
-// fullbuild mode, effectively the same as `LIBC_ERRNO_MODE_EXTERNAL`.
-#define LIBC_ERRNO_MODE_SYSTEM 5
-
-#if !defined(LIBC_ERRNO_MODE) || LIBC_ERRNO_MODE == LIBC_ERRNO_MODE_DEFAULT
-#undef LIBC_ERRNO_MODE
-#if defined(LIBC_FULL_BUILD) || !defined(LIBC_COPT_PUBLIC_PACKAGING)
-#define LIBC_ERRNO_MODE LIBC_ERRNO_MODE_THREAD_LOCAL
-#else
-#define LIBC_ERRNO_MODE LIBC_ERRNO_MODE_SYSTEM
-#endif
-#endif // LIBC_ERRNO_MODE
-
-#if LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_DEFAULT && \
- LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_UNDEFINED && \
- LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_THREAD_LOCAL && \
- LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_SHARED && \
- LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_EXTERNAL && \
- LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_SYSTEM
-#error LIBC_ERRNO_MODE must be one of the following values: \
-LIBC_ERRNO_MODE_DEFAULT, \
-LIBC_ERRNO_MODE_UNDEFINED, \
-LIBC_ERRNO_MODE_THREAD_LOCAL, \
-LIBC_ERRNO_MODE_SHARED, \
-LIBC_ERRNO_MODE_EXTERNAL, \
-LIBC_ERRNO_MODE_SYSTEM
-#endif
-
namespace LIBC_NAMESPACE_DECL {
+#if LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_SYSTEM
+
#if LIBC_ERRNO_MODE == LIBC_ERRNO_MODE_UNDEFINED
void Errno::operator=(int) {}
@@ -83,14 +45,11 @@ Errno::operator int() { return shared_errno; }
void Errno::operator=(int a) { *__llvm_libc_errno() = a; }
Errno::operator int() { return *__llvm_libc_errno(); }
-#elif LIBC_ERRNO_MODE == LIBC_ERRNO_MODE_SYSTEM
-
-void Errno::operator=(int a) { errno = a; }
-Errno::operator int() { return errno; }
-
#endif
// Define the global `libc_errno` instance.
Errno libc_errno;
+#endif // LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_SYSTEM
+
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/errno/libc_errno.h b/libc/src/errno/libc_errno.h
deleted file mode 100644
index 44ee2714843ba..0000000000000
--- a/libc/src/errno/libc_errno.h
+++ /dev/null
@@ -1,47 +0,0 @@
-//===-- Implementation header for libc_errno --------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_LIBC_SRC_ERRNO_LIBC_ERRNO_H
-#define LLVM_LIBC_SRC_ERRNO_LIBC_ERRNO_H
-
-#include "src/__support/macros/attributes.h"
-#include "src/__support/macros/config.h"
-#include "src/__support/macros/properties/architectures.h"
-
-#include "hdr/errno_macros.h"
-
-// This header is to be consumed by internal implementations, in which all of
-// them should refer to `libc_errno` instead of using `errno` directly from
-// <errno.h> header.
-
-// Unit and hermetic tests should:
-// - #include "src/errno/libc_errno.h"
-// - NOT #include <errno.h>
-// - Only use `libc_errno` in the code
-// - Depend on libc.src.errno.errno
-
-// Integration tests should:
-// - NOT #include "src/errno/libc_errno.h"
-// - #include <errno.h>
-// - Use regular `errno` in the code
-// - Still depend on libc.src.errno.errno
-
-namespace LIBC_NAMESPACE_DECL {
-
-extern "C" int *__llvm_libc_errno() noexcept;
-
-struct Errno {
- void operator=(int);
- operator int();
-};
-
-extern Errno libc_errno;
-
-} // namespace LIBC_NAMESPACE_DECL
-
-#endif // LLVM_LIBC_SRC_ERRNO_LIBC_ERRNO_H
diff --git a/libc/src/fcntl/linux/creat.cpp b/libc/src/fcntl/linux/creat.cpp
index 23abae243aed9..71412a8e68c53 100644
--- a/libc/src/fcntl/linux/creat.cpp
+++ b/libc/src/fcntl/linux/creat.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include "hdr/fcntl_macros.h"
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/fcntl/linux/open.cpp b/libc/src/fcntl/linux/open.cpp
index 8b699ecdd2043..a21a03788deaa 100644
--- a/libc/src/fcntl/linux/open.cpp
+++ b/libc/src/fcntl/linux/open.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include "hdr/fcntl_macros.h"
#include "hdr/types/mode_t.h"
diff --git a/libc/src/fcntl/linux/openat.cpp b/libc/src/fcntl/linux/openat.cpp
index 6063d9c00ad6c..b47ad1fb3bb0f 100644
--- a/libc/src/fcntl/linux/openat.cpp
+++ b/libc/src/fcntl/linux/openat.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include "hdr/types/mode_t.h"
#include <stdarg.h>
diff --git a/libc/src/inttypes/strtoimax.cpp b/libc/src/inttypes/strtoimax.cpp
index 85f197c75d90c..6e55a4b56aac7 100644
--- a/libc/src/inttypes/strtoimax.cpp
+++ b/libc/src/inttypes/strtoimax.cpp
@@ -8,9 +8,9 @@
#include "src/inttypes/strtoimax.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/str_to_integer.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/inttypes/strtoumax.cpp b/libc/src/inttypes/strtoumax.cpp
index 2e9cbc9acba75..ce5a0a782d979 100644
--- a/libc/src/inttypes/strtoumax.cpp
+++ b/libc/src/inttypes/strtoumax.cpp
@@ -8,9 +8,9 @@
#include "src/inttypes/strtoumax.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/str_to_integer.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/math/generic/exp10m1f.cpp b/libc/src/math/generic/exp10m1f.cpp
index e973b2921c2e4..27729104e038d 100644
--- a/libc/src/math/generic/exp10m1f.cpp
+++ b/libc/src/math/generic/exp10m1f.cpp
@@ -14,9 +14,9 @@
#include "src/__support/FPUtil/multiply_add.h"
#include "src/__support/FPUtil/rounding_mode.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/optimization.h"
-#include "src/errno/libc_errno.h"
#include "explogxf.h"
diff --git a/libc/src/math/generic/exp2m1f.cpp b/libc/src/math/generic/exp2m1f.cpp
index 4913a5e4277e4..127c6eaa494d4 100644
--- a/libc/src/math/generic/exp2m1f.cpp
+++ b/libc/src/math/generic/exp2m1f.cpp
@@ -14,10 +14,10 @@
#include "src/__support/FPUtil/multiply_add.h"
#include "src/__support/FPUtil/rounding_mode.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/optimization.h"
#include "src/__support/macros/properties/cpu_features.h"
-#include "src/errno/libc_errno.h"
#include "explogxf.h"
diff --git a/libc/src/math/generic/nan.cpp b/libc/src/math/generic/nan.cpp
index f92cd3ff5eb50..829a2ea435ac0 100644
--- a/libc/src/math/generic/nan.cpp
+++ b/libc/src/math/generic/nan.cpp
@@ -8,9 +8,9 @@
#include "src/math/nan.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/str_to_float.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/math/generic/nanf.cpp b/libc/src/math/generic/nanf.cpp
index 7287182406acd..1cb66160e736e 100644
--- a/libc/src/math/generic/nanf.cpp
+++ b/libc/src/math/generic/nanf.cpp
@@ -8,9 +8,9 @@
#include "src/math/nanf.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/str_to_float.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/math/generic/nanf128.cpp b/libc/src/math/generic/nanf128.cpp
index 3d8581afa0371..4155c5333a9c2 100644
--- a/libc/src/math/generic/nanf128.cpp
+++ b/libc/src/math/generic/nanf128.cpp
@@ -8,9 +8,9 @@
#include "src/math/nanf128.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/str_to_float.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/math/generic/nanf16.cpp b/libc/src/math/generic/nanf16.cpp
index 27d9d165f4a85..7b166400601bc 100644
--- a/libc/src/math/generic/nanf16.cpp
+++ b/libc/src/math/generic/nanf16.cpp
@@ -8,9 +8,9 @@
#include "src/math/nanf16.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/str_to_float.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/math/generic/nanl.cpp b/libc/src/math/generic/nanl.cpp
index 4f698cb3c88d0..58d638c4b531d 100644
--- a/libc/src/math/generic/nanl.cpp
+++ b/libc/src/math/generic/nanl.cpp
@@ -8,9 +8,9 @@
#include "src/math/nanl.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/str_to_float.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/poll/linux/poll.cpp b/libc/src/poll/linux/poll.cpp
index 2579ec04c1200..314e05288bc88 100644
--- a/libc/src/poll/linux/poll.cpp
+++ b/libc/src/poll/linux/poll.cpp
@@ -13,8 +13,8 @@
#include "hdr/types/struct_timespec.h"
#include "src/__support/OSUtil/syscall.h" // syscall_impl
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // SYS_poll, SYS_ppoll
diff --git a/libc/src/pthread/pthread_atfork.cpp b/libc/src/pthread/pthread_atfork.cpp
index b2c67c78e5d94..4cad16a02de70 100644
--- a/libc/src/pthread/pthread_atfork.cpp
+++ b/libc/src/pthread/pthread_atfork.cpp
@@ -9,9 +9,9 @@
#include "pthread_atfork.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/threads/fork_callbacks.h"
-#include "src/errno/libc_errno.h"
#include <pthread.h> // For pthread_* type definitions.
diff --git a/libc/src/pthread/pthread_attr_setdetachstate.cpp b/libc/src/pthread/pthread_attr_setdetachstate.cpp
index 872f694e01f3a..c482d25610c28 100644
--- a/libc/src/pthread/pthread_attr_setdetachstate.cpp
+++ b/libc/src/pthread/pthread_attr_setdetachstate.cpp
@@ -9,8 +9,8 @@
#include "pthread_attr_setdetachstate.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <pthread.h>
diff --git a/libc/src/pthread/pthread_attr_setguardsize.cpp b/libc/src/pthread/pthread_attr_setguardsize.cpp
index fa4375e915ab4..c996210a61d8a 100644
--- a/libc/src/pthread/pthread_attr_setguardsize.cpp
+++ b/libc/src/pthread/pthread_attr_setguardsize.cpp
@@ -9,8 +9,8 @@
#include "pthread_attr_setguardsize.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <linux/param.h> // For EXEC_PAGESIZE.
#include <pthread.h>
diff --git a/libc/src/pthread/pthread_attr_setstack.cpp b/libc/src/pthread/pthread_attr_setstack.cpp
index 1154055a63a7e..767f959b14003 100644
--- a/libc/src/pthread/pthread_attr_setstack.cpp
+++ b/libc/src/pthread/pthread_attr_setstack.cpp
@@ -10,9 +10,9 @@
#include "pthread_attr_setstacksize.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/threads/thread.h" // For STACK_ALIGNMENT
-#include "src/errno/libc_errno.h"
#include <pthread.h>
#include <stdint.h>
diff --git a/libc/src/pthread/pthread_attr_setstacksize.cpp b/libc/src/pthread/pthread_attr_setstacksize.cpp
index 0a5d1af661abf..38c77ca761d69 100644
--- a/libc/src/pthread/pthread_attr_setstacksize.cpp
+++ b/libc/src/pthread/pthread_attr_setstacksize.cpp
@@ -9,8 +9,8 @@
#include "pthread_attr_setstacksize.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <pthread.h>
diff --git a/libc/src/pthread/pthread_condattr_setclock.cpp b/libc/src/pthread/pthread_condattr_setclock.cpp
index 5e825d5ecea69..2f63d5e9d1942 100644
--- a/libc/src/pthread/pthread_condattr_setclock.cpp
+++ b/libc/src/pthread/pthread_condattr_setclock.cpp
@@ -9,8 +9,8 @@
#include "pthread_condattr_setclock.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include "hdr/time_macros.h" // CLOCK_MONOTONIC, CLOCK_REALTIME
#include <pthread.h> // pthread_condattr_t
diff --git a/libc/src/pthread/pthread_condattr_setpshared.cpp b/libc/src/pthread/pthread_condattr_setpshared.cpp
index 433b2dc1d2d93..9c117499a5592 100644
--- a/libc/src/pthread/pthread_condattr_setpshared.cpp
+++ b/libc/src/pthread/pthread_condattr_setpshared.cpp
@@ -9,8 +9,8 @@
#include "pthread_condattr_setpshared.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <pthread.h> // pthread_condattr_t, PTHREAD_PROCESS_SHARED, PTHREAD_PROCESS_PRIVATE
diff --git a/libc/src/pthread/pthread_create.cpp b/libc/src/pthread/pthread_create.cpp
index e1b1f3b325d1c..45be2807fa832 100644
--- a/libc/src/pthread/pthread_create.cpp
+++ b/libc/src/pthread/pthread_create.cpp
@@ -16,10 +16,10 @@
#include "pthread_attr_getstack.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/optimization.h"
#include "src/__support/threads/thread.h"
-#include "src/errno/libc_errno.h"
#include <pthread.h> // For pthread_* type definitions.
diff --git a/libc/src/pthread/pthread_key_create.cpp b/libc/src/pthread/pthread_key_create.cpp
index 383762f273e7a..7253de14cc0d5 100644
--- a/libc/src/pthread/pthread_key_create.cpp
+++ b/libc/src/pthread/pthread_key_create.cpp
@@ -9,9 +9,9 @@
#include "pthread_key_create.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/threads/thread.h"
-#include "src/errno/libc_errno.h"
#include <pthread.h>
diff --git a/libc/src/pthread/pthread_key_delete.cpp b/libc/src/pthread/pthread_key_delete.cpp
index b54db821ab05a..2b14d874fe31c 100644
--- a/libc/src/pthread/pthread_key_delete.cpp
+++ b/libc/src/pthread/pthread_key_delete.cpp
@@ -9,9 +9,9 @@
#include "pthread_key_delete.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/threads/thread.h"
-#include "src/errno/libc_errno.h"
#include <pthread.h>
diff --git a/libc/src/pthread/pthread_mutexattr_setpshared.cpp b/libc/src/pthread/pthread_mutexattr_setpshared.cpp
index deeae15be2303..a87a08259c4bb 100644
--- a/libc/src/pthread/pthread_mutexattr_setpshared.cpp
+++ b/libc/src/pthread/pthread_mutexattr_setpshared.cpp
@@ -10,8 +10,8 @@
#include "pthread_mutexattr.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <pthread.h>
diff --git a/libc/src/pthread/pthread_mutexattr_setrobust.cpp b/libc/src/pthread/pthread_mutexattr_setrobust.cpp
index 9fd46f4c928d7..fd7a8d7ce1d17 100644
--- a/libc/src/pthread/pthread_mutexattr_setrobust.cpp
+++ b/libc/src/pthread/pthread_mutexattr_setrobust.cpp
@@ -10,8 +10,8 @@
#include "pthread_mutexattr.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <pthread.h>
diff --git a/libc/src/pthread/pthread_mutexattr_settype.cpp b/libc/src/pthread/pthread_mutexattr_settype.cpp
index c7e78271f9c38..5a65f031045d6 100644
--- a/libc/src/pthread/pthread_mutexattr_settype.cpp
+++ b/libc/src/pthread/pthread_mutexattr_settype.cpp
@@ -10,8 +10,8 @@
#include "pthread_mutexattr.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <pthread.h>
diff --git a/libc/src/pthread/pthread_rwlock_timedrdlock.cpp b/libc/src/pthread/pthread_rwlock_timedrdlock.cpp
index 112ff5c9cdad3..fcddfed224906 100644
--- a/libc/src/pthread/pthread_rwlock_timedrdlock.cpp
+++ b/libc/src/pthread/pthread_rwlock_timedrdlock.cpp
@@ -9,11 +9,11 @@
#include "src/pthread/pthread_rwlock_timedrdlock.h"
#include "src/__support/common.h"
#include "src/__support/libc_assert.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/optimization.h"
#include "src/__support/threads/linux/rwlock.h"
#include "src/__support/time/linux/abs_timeout.h"
-#include "src/errno/libc_errno.h"
#include <pthread.h>
diff --git a/libc/src/pthread/pthread_rwlock_trywrlock.cpp b/libc/src/pthread/pthread_rwlock_trywrlock.cpp
index a63dc893e7169..660c15a87b36c 100644
--- a/libc/src/pthread/pthread_rwlock_trywrlock.cpp
+++ b/libc/src/pthread/pthread_rwlock_trywrlock.cpp
@@ -9,9 +9,9 @@
#include "src/pthread/pthread_rwlock_trywrlock.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/threads/linux/rwlock.h"
-#include "src/errno/libc_errno.h"
#include <pthread.h>
diff --git a/libc/src/pthread/pthread_rwlock_unlock.cpp b/libc/src/pthread/pthread_rwlock_unlock.cpp
index e61290179bd62..5496bea929c51 100644
--- a/libc/src/pthread/pthread_rwlock_unlock.cpp
+++ b/libc/src/pthread/pthread_rwlock_unlock.cpp
@@ -9,9 +9,9 @@
#include "src/pthread/pthread_rwlock_unlock.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/threads/linux/rwlock.h"
-#include "src/errno/libc_errno.h"
#include <pthread.h>
diff --git a/libc/src/pthread/pthread_rwlockattr_setkind_np.cpp b/libc/src/pthread/pthread_rwlockattr_setkind_np.cpp
index 80d34a35c717a..e6800311b8587 100644
--- a/libc/src/pthread/pthread_rwlockattr_setkind_np.cpp
+++ b/libc/src/pthread/pthread_rwlockattr_setkind_np.cpp
@@ -9,8 +9,8 @@
#include "pthread_rwlockattr_setkind_np.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <pthread.h> // pthread_rwlockattr_t
diff --git a/libc/src/pthread/pthread_rwlockattr_setpshared.cpp b/libc/src/pthread/pthread_rwlockattr_setpshared.cpp
index 5a7191aefd3d0..4fbd095ac2b46 100644
--- a/libc/src/pthread/pthread_rwlockattr_setpshared.cpp
+++ b/libc/src/pthread/pthread_rwlockattr_setpshared.cpp
@@ -9,8 +9,8 @@
#include "pthread_rwlockattr_setpshared.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <pthread.h> // pthread_rwlockattr_t, PTHREAD_PROCESS_SHARED, PTHREAD_PROCESS_PRIVATE
diff --git a/libc/src/pthread/pthread_setspecific.cpp b/libc/src/pthread/pthread_setspecific.cpp
index 70c29c1670841..b147a66d2fad7 100644
--- a/libc/src/pthread/pthread_setspecific.cpp
+++ b/libc/src/pthread/pthread_setspecific.cpp
@@ -9,9 +9,9 @@
#include "pthread_setspecific.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/threads/thread.h"
-#include "src/errno/libc_errno.h"
#include <pthread.h>
diff --git a/libc/src/sched/linux/sched_get_priority_max.cpp b/libc/src/sched/linux/sched_get_priority_max.cpp
index 77a82c77405f3..fb30b1e319e7b 100644
--- a/libc/src/sched/linux/sched_get_priority_max.cpp
+++ b/libc/src/sched/linux/sched_get_priority_max.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/sched/linux/sched_get_priority_min.cpp b/libc/src/sched/linux/sched_get_priority_min.cpp
index fca66a15edb55..54f67e915fc17 100644
--- a/libc/src/sched/linux/sched_get_priority_min.cpp
+++ b/libc/src/sched/linux/sched_get_priority_min.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/sched/linux/sched_getaffinity.cpp b/libc/src/sched/linux/sched_getaffinity.cpp
index 7b1fd8c5aa2af..e005819e2a978 100644
--- a/libc/src/sched/linux/sched_getaffinity.cpp
+++ b/libc/src/sched/linux/sched_getaffinity.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sched.h>
#include <stdint.h>
diff --git a/libc/src/sched/linux/sched_getparam.cpp b/libc/src/sched/linux/sched_getparam.cpp
index 75756a65f0ede..b0576c3ac65b8 100644
--- a/libc/src/sched/linux/sched_getparam.cpp
+++ b/libc/src/sched/linux/sched_getparam.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/sched/linux/sched_getscheduler.cpp b/libc/src/sched/linux/sched_getscheduler.cpp
index 545cda8e7484b..d8e02967a633d 100644
--- a/libc/src/sched/linux/sched_getscheduler.cpp
+++ b/libc/src/sched/linux/sched_getscheduler.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/sched/linux/sched_rr_get_interval.cpp b/libc/src/sched/linux/sched_rr_get_interval.cpp
index 1f0ef69dfc893..5668d596bce1f 100644
--- a/libc/src/sched/linux/sched_rr_get_interval.cpp
+++ b/libc/src/sched/linux/sched_rr_get_interval.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/sched/linux/sched_setaffinity.cpp b/libc/src/sched/linux/sched_setaffinity.cpp
index cad48c26bf938..93e930dcf2e3e 100644
--- a/libc/src/sched/linux/sched_setaffinity.cpp
+++ b/libc/src/sched/linux/sched_setaffinity.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sched.h>
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/sched/linux/sched_setparam.cpp b/libc/src/sched/linux/sched_setparam.cpp
index e78e78a707e05..7875d9e2f19bc 100644
--- a/libc/src/sched/linux/sched_setparam.cpp
+++ b/libc/src/sched/linux/sched_setparam.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/sched/linux/sched_setscheduler.cpp b/libc/src/sched/linux/sched_setscheduler.cpp
index b6b6f667b3f9e..232e5a59b1858 100644
--- a/libc/src/sched/linux/sched_setscheduler.cpp
+++ b/libc/src/sched/linux/sched_setscheduler.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/sched/linux/sched_yield.cpp b/libc/src/sched/linux/sched_yield.cpp
index 3de9d0ba35717..c1e9168f34d0e 100644
--- a/libc/src/sched/linux/sched_yield.cpp
+++ b/libc/src/sched/linux/sched_yield.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/search/hcreate.cpp b/libc/src/search/hcreate.cpp
index ac816a902e221..68bdb29e51dfb 100644
--- a/libc/src/search/hcreate.cpp
+++ b/libc/src/search/hcreate.cpp
@@ -9,8 +9,8 @@
#include "src/search/hcreate.h"
#include "src/__support/HashTable/randomness.h"
#include "src/__support/HashTable/table.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include "src/search/hsearch/global.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/search/hcreate_r.cpp b/libc/src/search/hcreate_r.cpp
index 17acd808c19a6..c89be803b4e16 100644
--- a/libc/src/search/hcreate_r.cpp
+++ b/libc/src/search/hcreate_r.cpp
@@ -9,8 +9,8 @@
#include "src/search/hcreate_r.h"
#include "src/__support/HashTable/randomness.h"
#include "src/__support/HashTable/table.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(int, hcreate_r,
diff --git a/libc/src/search/hdestroy_r.cpp b/libc/src/search/hdestroy_r.cpp
index 7eff5bb6fff9d..ba5476098be29 100644
--- a/libc/src/search/hdestroy_r.cpp
+++ b/libc/src/search/hdestroy_r.cpp
@@ -8,8 +8,8 @@
#include "src/search/hdestroy_r.h"
#include "src/__support/HashTable/table.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(void, hdestroy_r, (struct hsearch_data * htab)) {
diff --git a/libc/src/search/hsearch.cpp b/libc/src/search/hsearch.cpp
index c18b5d3d7f547..034333d170579 100644
--- a/libc/src/search/hsearch.cpp
+++ b/libc/src/search/hsearch.cpp
@@ -9,8 +9,8 @@
#include "src/search/hsearch.h"
#include "src/__support/HashTable/randomness.h"
#include "src/__support/HashTable/table.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include "src/search/hsearch/global.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/search/hsearch_r.cpp b/libc/src/search/hsearch_r.cpp
index f93e608a190b1..323001e1b103d 100644
--- a/libc/src/search/hsearch_r.cpp
+++ b/libc/src/search/hsearch_r.cpp
@@ -8,8 +8,8 @@
#include "src/search/hsearch_r.h"
#include "src/__support/HashTable/table.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(int, hsearch_r,
diff --git a/libc/src/signal/linux/kill.cpp b/libc/src/signal/linux/kill.cpp
index ed117858f51ef..0f5e88757acb8 100644
--- a/libc/src/signal/linux/kill.cpp
+++ b/libc/src/signal/linux/kill.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include "src/signal/linux/signal_utils.h"
#include <signal.h>
diff --git a/libc/src/signal/linux/sigaction.cpp b/libc/src/signal/linux/sigaction.cpp
index 65ec36741683c..43a3e195474e5 100644
--- a/libc/src/signal/linux/sigaction.cpp
+++ b/libc/src/signal/linux/sigaction.cpp
@@ -10,8 +10,8 @@
#include "hdr/types/sigset_t.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include "src/signal/linux/signal_utils.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/signal/linux/sigaddset.cpp b/libc/src/signal/linux/sigaddset.cpp
index 628883e13b887..2091e8b51453f 100644
--- a/libc/src/signal/linux/sigaddset.cpp
+++ b/libc/src/signal/linux/sigaddset.cpp
@@ -10,8 +10,8 @@
#include "hdr/types/sigset_t.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include "src/signal/linux/signal_utils.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/signal/linux/sigaltstack.cpp b/libc/src/signal/linux/sigaltstack.cpp
index c19394cd17912..990b841c6d904 100644
--- a/libc/src/signal/linux/sigaltstack.cpp
+++ b/libc/src/signal/linux/sigaltstack.cpp
@@ -8,8 +8,8 @@
#include "src/signal/sigaltstack.h"
#include "hdr/types/stack_t.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include "src/signal/linux/signal_utils.h"
#include "src/__support/common.h"
diff --git a/libc/src/signal/linux/sigdelset.cpp b/libc/src/signal/linux/sigdelset.cpp
index 2e964051ebde7..6fce0d7a6e147 100644
--- a/libc/src/signal/linux/sigdelset.cpp
+++ b/libc/src/signal/linux/sigdelset.cpp
@@ -10,8 +10,8 @@
#include "hdr/types/sigset_t.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include "src/signal/linux/signal_utils.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/signal/linux/sigemptyset.cpp b/libc/src/signal/linux/sigemptyset.cpp
index d347477695e6c..034a9e2cbe15e 100644
--- a/libc/src/signal/linux/sigemptyset.cpp
+++ b/libc/src/signal/linux/sigemptyset.cpp
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "src/signal/sigemptyset.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include "src/signal/linux/signal_utils.h"
#include "src/__support/common.h"
diff --git a/libc/src/signal/linux/sigfillset.cpp b/libc/src/signal/linux/sigfillset.cpp
index 3e9897a03bb73..f0b499093b319 100644
--- a/libc/src/signal/linux/sigfillset.cpp
+++ b/libc/src/signal/linux/sigfillset.cpp
@@ -10,8 +10,8 @@
#include "hdr/types/sigset_t.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include "src/signal/linux/signal_utils.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/signal/linux/sigprocmask.cpp b/libc/src/signal/linux/sigprocmask.cpp
index 8838379ae5d30..af3c424c5f34e 100644
--- a/libc/src/signal/linux/sigprocmask.cpp
+++ b/libc/src/signal/linux/sigprocmask.cpp
@@ -11,8 +11,8 @@
#include "hdr/types/sigset_t.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include "src/signal/linux/signal_utils.h"
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/spawn/posix_spawn_file_actions_addclose.cpp b/libc/src/spawn/posix_spawn_file_actions_addclose.cpp
index bb8504f655c4a..9a575bd591632 100644
--- a/libc/src/spawn/posix_spawn_file_actions_addclose.cpp
+++ b/libc/src/spawn/posix_spawn_file_actions_addclose.cpp
@@ -11,8 +11,8 @@
#include "file_actions.h"
#include "src/__support/CPP/new.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <spawn.h>
diff --git a/libc/src/spawn/posix_spawn_file_actions_adddup2.cpp b/libc/src/spawn/posix_spawn_file_actions_adddup2.cpp
index 710063d52e74d..1ad45ed942bb9 100644
--- a/libc/src/spawn/posix_spawn_file_actions_adddup2.cpp
+++ b/libc/src/spawn/posix_spawn_file_actions_adddup2.cpp
@@ -11,8 +11,8 @@
#include "file_actions.h"
#include "src/__support/CPP/new.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <spawn.h>
diff --git a/libc/src/spawn/posix_spawn_file_actions_addopen.cpp b/libc/src/spawn/posix_spawn_file_actions_addopen.cpp
index 028d6e895f3c4..9977fc2d0a218 100644
--- a/libc/src/spawn/posix_spawn_file_actions_addopen.cpp
+++ b/libc/src/spawn/posix_spawn_file_actions_addopen.cpp
@@ -11,8 +11,8 @@
#include "file_actions.h"
#include "src/__support/CPP/new.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <spawn.h>
diff --git a/libc/src/spawn/posix_spawn_file_actions_destroy.cpp b/libc/src/spawn/posix_spawn_file_actions_destroy.cpp
index 168118da249d1..affd338005cf4 100644
--- a/libc/src/spawn/posix_spawn_file_actions_destroy.cpp
+++ b/libc/src/spawn/posix_spawn_file_actions_destroy.cpp
@@ -12,8 +12,8 @@
#include "src/__support/CPP/new.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <spawn.h>
diff --git a/libc/src/stdio/fopencookie.cpp b/libc/src/stdio/fopencookie.cpp
index 9f5694e8e0581..da8a132a4db6e 100644
--- a/libc/src/stdio/fopencookie.cpp
+++ b/libc/src/stdio/fopencookie.cpp
@@ -14,8 +14,8 @@
#include "src/__support/CPP/new.h"
#include "src/__support/File/file.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdio/generic/fclose.cpp b/libc/src/stdio/generic/fclose.cpp
index 388407a58d414..902b4cf972373 100644
--- a/libc/src/stdio/generic/fclose.cpp
+++ b/libc/src/stdio/generic/fclose.cpp
@@ -10,8 +10,8 @@
#include "src/__support/File/file.h"
#include "hdr/types/FILE.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdio/generic/fflush.cpp b/libc/src/stdio/generic/fflush.cpp
index 5bdf71ad35940..d0271d9154c87 100644
--- a/libc/src/stdio/generic/fflush.cpp
+++ b/libc/src/stdio/generic/fflush.cpp
@@ -10,8 +10,8 @@
#include "src/__support/File/file.h"
#include "hdr/types/FILE.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdio/generic/fgetc.cpp b/libc/src/stdio/generic/fgetc.cpp
index aa6660ca180cf..e65ce2fda49bd 100644
--- a/libc/src/stdio/generic/fgetc.cpp
+++ b/libc/src/stdio/generic/fgetc.cpp
@@ -10,8 +10,8 @@
#include "src/__support/File/file.h"
#include "hdr/types/FILE.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <stddef.h>
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdio/generic/fgetc_unlocked.cpp b/libc/src/stdio/generic/fgetc_unlocked.cpp
index 34a27f1d1c420..5c07d4feb513e 100644
--- a/libc/src/stdio/generic/fgetc_unlocked.cpp
+++ b/libc/src/stdio/generic/fgetc_unlocked.cpp
@@ -10,8 +10,8 @@
#include "src/__support/File/file.h"
#include "hdr/types/FILE.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <stddef.h>
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdio/generic/fgets.cpp b/libc/src/stdio/generic/fgets.cpp
index de6474087a140..e0ad9b6e2f564 100644
--- a/libc/src/stdio/generic/fgets.cpp
+++ b/libc/src/stdio/generic/fgets.cpp
@@ -10,8 +10,8 @@
#include "src/__support/File/file.h"
#include "hdr/types/FILE.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <stddef.h>
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdio/generic/fopen.cpp b/libc/src/stdio/generic/fopen.cpp
index d6e418bacf37e..57c85c2e54e16 100644
--- a/libc/src/stdio/generic/fopen.cpp
+++ b/libc/src/stdio/generic/fopen.cpp
@@ -10,8 +10,8 @@
#include "src/__support/File/file.h"
#include "hdr/types/FILE.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdio/generic/fputc.cpp b/libc/src/stdio/generic/fputc.cpp
index 54a38aeb2f1e2..6639f0687c87a 100644
--- a/libc/src/stdio/generic/fputc.cpp
+++ b/libc/src/stdio/generic/fputc.cpp
@@ -10,8 +10,8 @@
#include "src/__support/File/file.h"
#include "hdr/types/FILE.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <stddef.h>
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdio/generic/fputs.cpp b/libc/src/stdio/generic/fputs.cpp
index 8aef7683b3ce3..621b40f63c912 100644
--- a/libc/src/stdio/generic/fputs.cpp
+++ b/libc/src/stdio/generic/fputs.cpp
@@ -11,8 +11,8 @@
#include "src/__support/File/file.h"
#include "hdr/types/FILE.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <stddef.h>
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdio/generic/fread.cpp b/libc/src/stdio/generic/fread.cpp
index 3a04094ea8b4b..1b576ec34688f 100644
--- a/libc/src/stdio/generic/fread.cpp
+++ b/libc/src/stdio/generic/fread.cpp
@@ -10,8 +10,8 @@
#include "src/__support/File/file.h"
#include "hdr/types/FILE.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <stddef.h>
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdio/generic/fread_unlocked.cpp b/libc/src/stdio/generic/fread_unlocked.cpp
index 151f43c6bbeba..257f1a212add4 100644
--- a/libc/src/stdio/generic/fread_unlocked.cpp
+++ b/libc/src/stdio/generic/fread_unlocked.cpp
@@ -10,8 +10,8 @@
#include "src/__support/File/file.h"
#include "hdr/types/FILE.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <stddef.h>
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdio/generic/fseek.cpp b/libc/src/stdio/generic/fseek.cpp
index 21820da18542a..99191e7c41949 100644
--- a/libc/src/stdio/generic/fseek.cpp
+++ b/libc/src/stdio/generic/fseek.cpp
@@ -9,8 +9,8 @@
#include "src/stdio/fseek.h"
#include "src/__support/File/file.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdio/generic/fseeko.cpp b/libc/src/stdio/generic/fseeko.cpp
index 7456b4a219079..afcfc71c7c09a 100644
--- a/libc/src/stdio/generic/fseeko.cpp
+++ b/libc/src/stdio/generic/fseeko.cpp
@@ -9,8 +9,8 @@
#include "src/stdio/fseeko.h"
#include "src/__support/File/file.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdio/generic/ftell.cpp b/libc/src/stdio/generic/ftell.cpp
index ec15ca4e96caf..b55a806007aff 100644
--- a/libc/src/stdio/generic/ftell.cpp
+++ b/libc/src/stdio/generic/ftell.cpp
@@ -9,8 +9,8 @@
#include "src/stdio/ftell.h"
#include "src/__support/File/file.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdio/generic/ftello.cpp b/libc/src/stdio/generic/ftello.cpp
index e3d0726ec4843..91031cb7fad70 100644
--- a/libc/src/stdio/generic/ftello.cpp
+++ b/libc/src/stdio/generic/ftello.cpp
@@ -9,8 +9,8 @@
#include "src/stdio/ftello.h"
#include "src/__support/File/file.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdio/generic/fwrite.cpp b/libc/src/stdio/generic/fwrite.cpp
index 66eb9a3c71855..b44ecb2838118 100644
--- a/libc/src/stdio/generic/fwrite.cpp
+++ b/libc/src/stdio/generic/fwrite.cpp
@@ -10,8 +10,8 @@
#include "src/__support/File/file.h"
#include "hdr/types/FILE.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <stddef.h>
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdio/generic/fwrite_unlocked.cpp b/libc/src/stdio/generic/fwrite_unlocked.cpp
index a0d9014cd68de..2f9ec26f2f80c 100644
--- a/libc/src/stdio/generic/fwrite_unlocked.cpp
+++ b/libc/src/stdio/generic/fwrite_unlocked.cpp
@@ -10,8 +10,8 @@
#include "src/__support/File/file.h"
#include "hdr/types/FILE.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <stddef.h>
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdio/generic/getc.cpp b/libc/src/stdio/generic/getc.cpp
index e988468898c53..0ac010ebc5994 100644
--- a/libc/src/stdio/generic/getc.cpp
+++ b/libc/src/stdio/generic/getc.cpp
@@ -10,8 +10,8 @@
#include "src/__support/File/file.h"
#include "hdr/types/FILE.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <stddef.h>
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdio/generic/getc_unlocked.cpp b/libc/src/stdio/generic/getc_unlocked.cpp
index 92d5092623ac5..eee23a18d05df 100644
--- a/libc/src/stdio/generic/getc_unlocked.cpp
+++ b/libc/src/stdio/generic/getc_unlocked.cpp
@@ -10,8 +10,8 @@
#include "src/__support/File/file.h"
#include "hdr/types/FILE.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <stddef.h>
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdio/generic/getchar.cpp b/libc/src/stdio/generic/getchar.cpp
index 371fc70eb214f..87d24a2b1f09e 100644
--- a/libc/src/stdio/generic/getchar.cpp
+++ b/libc/src/stdio/generic/getchar.cpp
@@ -10,8 +10,8 @@
#include "src/__support/File/file.h"
#include "hdr/types/FILE.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdio/generic/getchar_unlocked.cpp b/libc/src/stdio/generic/getchar_unlocked.cpp
index b898f5cb25963..f321969483e35 100644
--- a/libc/src/stdio/generic/getchar_unlocked.cpp
+++ b/libc/src/stdio/generic/getchar_unlocked.cpp
@@ -10,8 +10,8 @@
#include "src/__support/File/file.h"
#include "hdr/types/FILE.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdio/generic/putc.cpp b/libc/src/stdio/generic/putc.cpp
index b5f008fdce44a..83bc3d4131e76 100644
--- a/libc/src/stdio/generic/putc.cpp
+++ b/libc/src/stdio/generic/putc.cpp
@@ -10,8 +10,8 @@
#include "src/__support/File/file.h"
#include "hdr/types/FILE.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <stddef.h>
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdio/generic/putchar.cpp b/libc/src/stdio/generic/putchar.cpp
index e86df23d6716b..2b3509e5e414c 100644
--- a/libc/src/stdio/generic/putchar.cpp
+++ b/libc/src/stdio/generic/putchar.cpp
@@ -10,8 +10,8 @@
#include "src/__support/File/file.h"
#include "hdr/types/FILE.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <stddef.h>
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdio/generic/puts.cpp b/libc/src/stdio/generic/puts.cpp
index 7dbe2c79f920d..4267dd546c4dc 100644
--- a/libc/src/stdio/generic/puts.cpp
+++ b/libc/src/stdio/generic/puts.cpp
@@ -11,8 +11,8 @@
#include "src/__support/File/file.h"
#include "hdr/types/FILE.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <stddef.h>
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdio/gpu/fprintf.cpp b/libc/src/stdio/gpu/fprintf.cpp
index 46196d7d2b10f..130d41ac2b6ef 100644
--- a/libc/src/stdio/gpu/fprintf.cpp
+++ b/libc/src/stdio/gpu/fprintf.cpp
@@ -11,7 +11,7 @@
#include "hdr/types/FILE.h"
#include "src/__support/CPP/string_view.h"
#include "src/__support/arg_list.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/stdio/gpu/vfprintf_utils.h"
#include <stdarg.h>
diff --git a/libc/src/stdio/gpu/fputs.cpp b/libc/src/stdio/gpu/fputs.cpp
index 7a08244bc26e4..04d6e3cd5d086 100644
--- a/libc/src/stdio/gpu/fputs.cpp
+++ b/libc/src/stdio/gpu/fputs.cpp
@@ -8,8 +8,8 @@
#include "src/stdio/fputs.h"
#include "src/__support/CPP/string_view.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include "src/stdio/gpu/file.h"
#include "hdr/stdio_macros.h" // for EOF.
diff --git a/libc/src/stdio/gpu/printf.cpp b/libc/src/stdio/gpu/printf.cpp
index be1885fd6801d..a626758220af3 100644
--- a/libc/src/stdio/gpu/printf.cpp
+++ b/libc/src/stdio/gpu/printf.cpp
@@ -10,7 +10,7 @@
#include "src/__support/CPP/string_view.h"
#include "src/__support/arg_list.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/stdio/gpu/vfprintf_utils.h"
#include <stdarg.h>
diff --git a/libc/src/stdio/gpu/puts.cpp b/libc/src/stdio/gpu/puts.cpp
index fc252abe52d17..071b6dffedc35 100644
--- a/libc/src/stdio/gpu/puts.cpp
+++ b/libc/src/stdio/gpu/puts.cpp
@@ -8,8 +8,8 @@
#include "src/stdio/puts.h"
#include "src/__support/CPP/string_view.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include "src/stdio/gpu/file.h"
#include "hdr/stdio_macros.h" // for EOF and stdout.
diff --git a/libc/src/stdio/gpu/vfprintf.cpp b/libc/src/stdio/gpu/vfprintf.cpp
index c92685f48c728..8415458125456 100644
--- a/libc/src/stdio/gpu/vfprintf.cpp
+++ b/libc/src/stdio/gpu/vfprintf.cpp
@@ -11,7 +11,7 @@
#include "hdr/types/FILE.h"
#include "src/__support/CPP/string_view.h"
#include "src/__support/arg_list.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/stdio/gpu/vfprintf_utils.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdio/gpu/vprintf.cpp b/libc/src/stdio/gpu/vprintf.cpp
index 54012f3071844..9a4b6eb0e3477 100644
--- a/libc/src/stdio/gpu/vprintf.cpp
+++ b/libc/src/stdio/gpu/vprintf.cpp
@@ -10,7 +10,7 @@
#include "src/__support/CPP/string_view.h"
#include "src/__support/arg_list.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/stdio/gpu/vfprintf_utils.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdio/linux/fdopen.cpp b/libc/src/stdio/linux/fdopen.cpp
index 7d72fdc88e9fb..5623f06b7cff0 100644
--- a/libc/src/stdio/linux/fdopen.cpp
+++ b/libc/src/stdio/linux/fdopen.cpp
@@ -9,8 +9,8 @@
#include "src/stdio/fdopen.h"
#include "src/__support/File/linux/file.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdio/linux/remove.cpp b/libc/src/stdio/linux/remove.cpp
index dbb4491d0e6cc..ac755db0bc781 100644
--- a/libc/src/stdio/linux/remove.cpp
+++ b/libc/src/stdio/linux/remove.cpp
@@ -12,8 +12,8 @@
#include "src/__support/common.h"
#include "hdr/fcntl_macros.h" // For AT_* macros.
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdio/linux/rename.cpp b/libc/src/stdio/linux/rename.cpp
index fbcb29be48f4e..426c8698e557d 100644
--- a/libc/src/stdio/linux/rename.cpp
+++ b/libc/src/stdio/linux/rename.cpp
@@ -10,8 +10,8 @@
#include "hdr/fcntl_macros.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdio/printf_core/parser.h b/libc/src/stdio/printf_core/parser.h
index 89556f1a9e5f2..cef9b1ae58fa0 100644
--- a/libc/src/stdio/printf_core/parser.h
+++ b/libc/src/stdio/printf_core/parser.h
@@ -25,7 +25,7 @@
#include "src/__support/fixed_point/fx_rep.h"
#endif // LIBC_INTERNAL_PRINTF_HAS_FIXED_POINT
#ifndef LIBC_COPT_PRINTF_DISABLE_STRERROR
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#endif // LIBC_COPT_PRINTF_DISABLE_STRERROR
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdio/setbuf.cpp b/libc/src/stdio/setbuf.cpp
index f3db97de58371..fcc6df12ddb08 100644
--- a/libc/src/stdio/setbuf.cpp
+++ b/libc/src/stdio/setbuf.cpp
@@ -9,8 +9,8 @@
#include "src/stdio/setbuf.h"
#include "hdr/stdio_macros.h"
#include "src/__support/File/file.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdio/setvbuf.cpp b/libc/src/stdio/setvbuf.cpp
index 0a6b8cacb59c8..9fc6cb040233b 100644
--- a/libc/src/stdio/setvbuf.cpp
+++ b/libc/src/stdio/setvbuf.cpp
@@ -10,8 +10,8 @@
#include "src/__support/File/file.h"
#include "hdr/types/FILE.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <stddef.h>
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdlib/atof.cpp b/libc/src/stdlib/atof.cpp
index 18a65c67705d3..d0d8d211dea8c 100644
--- a/libc/src/stdlib/atof.cpp
+++ b/libc/src/stdlib/atof.cpp
@@ -8,9 +8,9 @@
#include "src/stdlib/atof.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/str_to_float.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdlib/atoi.cpp b/libc/src/stdlib/atoi.cpp
index 9e46b53b1aa0b..420bbc8143d55 100644
--- a/libc/src/stdlib/atoi.cpp
+++ b/libc/src/stdlib/atoi.cpp
@@ -8,9 +8,9 @@
#include "src/stdlib/atoi.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/str_to_integer.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdlib/atol.cpp b/libc/src/stdlib/atol.cpp
index 7f3414a4afdd2..e1110ffa449b0 100644
--- a/libc/src/stdlib/atol.cpp
+++ b/libc/src/stdlib/atol.cpp
@@ -8,9 +8,9 @@
#include "src/stdlib/atol.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/str_to_integer.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdlib/atoll.cpp b/libc/src/stdlib/atoll.cpp
index 4f1a02ad8315b..063e817f9b790 100644
--- a/libc/src/stdlib/atoll.cpp
+++ b/libc/src/stdlib/atoll.cpp
@@ -8,9 +8,9 @@
#include "src/stdlib/atoll.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/str_to_integer.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdlib/strtod.cpp b/libc/src/stdlib/strtod.cpp
index 2c6819163aa46..deb2390c7fcde 100644
--- a/libc/src/stdlib/strtod.cpp
+++ b/libc/src/stdlib/strtod.cpp
@@ -8,9 +8,9 @@
#include "src/stdlib/strtod.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/str_to_float.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdlib/strtod_l.cpp b/libc/src/stdlib/strtod_l.cpp
index 247314398315b..ad333b32d2406 100644
--- a/libc/src/stdlib/strtod_l.cpp
+++ b/libc/src/stdlib/strtod_l.cpp
@@ -8,9 +8,9 @@
#include "src/stdlib/strtod_l.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/str_to_float.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdlib/strtof.cpp b/libc/src/stdlib/strtof.cpp
index 351bf64ad4f70..fc52dc85ffc50 100644
--- a/libc/src/stdlib/strtof.cpp
+++ b/libc/src/stdlib/strtof.cpp
@@ -8,9 +8,9 @@
#include "src/stdlib/strtof.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/str_to_float.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdlib/strtof_l.cpp b/libc/src/stdlib/strtof_l.cpp
index d54efa66e0846..c6e03ff51fa2f 100644
--- a/libc/src/stdlib/strtof_l.cpp
+++ b/libc/src/stdlib/strtof_l.cpp
@@ -8,9 +8,9 @@
#include "src/stdlib/strtof_l.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/str_to_float.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdlib/strtol.cpp b/libc/src/stdlib/strtol.cpp
index 77f8712d7c136..42db36b2052b4 100644
--- a/libc/src/stdlib/strtol.cpp
+++ b/libc/src/stdlib/strtol.cpp
@@ -8,9 +8,9 @@
#include "src/stdlib/strtol.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/str_to_integer.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdlib/strtol_l.cpp b/libc/src/stdlib/strtol_l.cpp
index f94aff1a0d7b2..497a4403eff4b 100644
--- a/libc/src/stdlib/strtol_l.cpp
+++ b/libc/src/stdlib/strtol_l.cpp
@@ -8,9 +8,9 @@
#include "src/stdlib/strtol_l.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/str_to_integer.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdlib/strtold.cpp b/libc/src/stdlib/strtold.cpp
index 88d29c9f36278..44046c2c6f613 100644
--- a/libc/src/stdlib/strtold.cpp
+++ b/libc/src/stdlib/strtold.cpp
@@ -8,9 +8,9 @@
#include "src/stdlib/strtold.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/str_to_float.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdlib/strtold_l.cpp b/libc/src/stdlib/strtold_l.cpp
index d0c57f50246b5..c3af30a1b9ecc 100644
--- a/libc/src/stdlib/strtold_l.cpp
+++ b/libc/src/stdlib/strtold_l.cpp
@@ -8,9 +8,9 @@
#include "src/stdlib/strtold_l.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/str_to_float.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdlib/strtoll.cpp b/libc/src/stdlib/strtoll.cpp
index 8d1b3efdcf87d..c1dca13112e0f 100644
--- a/libc/src/stdlib/strtoll.cpp
+++ b/libc/src/stdlib/strtoll.cpp
@@ -8,9 +8,9 @@
#include "src/stdlib/strtoll.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/str_to_integer.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdlib/strtoll_l.cpp b/libc/src/stdlib/strtoll_l.cpp
index e82971d59c48d..6f30d7794c5ca 100644
--- a/libc/src/stdlib/strtoll_l.cpp
+++ b/libc/src/stdlib/strtoll_l.cpp
@@ -8,9 +8,9 @@
#include "src/stdlib/strtoll_l.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/str_to_integer.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdlib/strtoul.cpp b/libc/src/stdlib/strtoul.cpp
index 1d832318c4489..d26ca5e5a10a1 100644
--- a/libc/src/stdlib/strtoul.cpp
+++ b/libc/src/stdlib/strtoul.cpp
@@ -8,9 +8,9 @@
#include "src/stdlib/strtoul.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/str_to_integer.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdlib/strtoul_l.cpp b/libc/src/stdlib/strtoul_l.cpp
index 74fce00a0ac3c..9a875ddee9029 100644
--- a/libc/src/stdlib/strtoul_l.cpp
+++ b/libc/src/stdlib/strtoul_l.cpp
@@ -8,9 +8,9 @@
#include "src/stdlib/strtoul_l.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/str_to_integer.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdlib/strtoull.cpp b/libc/src/stdlib/strtoull.cpp
index dba22611cfb09..8f929f577311e 100644
--- a/libc/src/stdlib/strtoull.cpp
+++ b/libc/src/stdlib/strtoull.cpp
@@ -8,9 +8,9 @@
#include "src/stdlib/strtoull.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/str_to_integer.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/stdlib/strtoull_l.cpp b/libc/src/stdlib/strtoull_l.cpp
index 2ea8a43a40ef2..9eb056b0e59b4 100644
--- a/libc/src/stdlib/strtoull_l.cpp
+++ b/libc/src/stdlib/strtoull_l.cpp
@@ -8,9 +8,9 @@
#include "src/stdlib/strtoull_l.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/str_to_integer.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/string/strdup.cpp b/libc/src/string/strdup.cpp
index 4cf4173a27bf3..dab0ab4288c9e 100644
--- a/libc/src/string/strdup.cpp
+++ b/libc/src/string/strdup.cpp
@@ -8,8 +8,8 @@
#include "src/string/strdup.h"
#include "hdr/stdlib_macros.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include "src/string/allocating_string_utils.h"
#include "src/string/memory_utils/inline_memcpy.h"
diff --git a/libc/src/sys/auxv/linux/getauxval.cpp b/libc/src/sys/auxv/linux/getauxval.cpp
index 236fd25698f65..f3ae7c5c4e07a 100644
--- a/libc/src/sys/auxv/linux/getauxval.cpp
+++ b/libc/src/sys/auxv/linux/getauxval.cpp
@@ -9,8 +9,8 @@
#include "src/sys/auxv/getauxval.h"
#include "config/app.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <linux/auxvec.h>
// for guarded initialization
diff --git a/libc/src/sys/epoll/linux/epoll_create.cpp b/libc/src/sys/epoll/linux/epoll_create.cpp
index 7196ac7410c30..2e44e883ddf0a 100644
--- a/libc/src/sys/epoll/linux/epoll_create.cpp
+++ b/libc/src/sys/epoll/linux/epoll_create.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/epoll/linux/epoll_create1.cpp b/libc/src/sys/epoll/linux/epoll_create1.cpp
index efff282e2714d..3c60090fb7b41 100644
--- a/libc/src/sys/epoll/linux/epoll_create1.cpp
+++ b/libc/src/sys/epoll/linux/epoll_create1.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/epoll/linux/epoll_ctl.cpp b/libc/src/sys/epoll/linux/epoll_ctl.cpp
index 5f7dbb77b1e5b..079bd60403b09 100644
--- a/libc/src/sys/epoll/linux/epoll_ctl.cpp
+++ b/libc/src/sys/epoll/linux/epoll_ctl.cpp
@@ -11,8 +11,8 @@
#include "hdr/types/struct_epoll_event.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/epoll/linux/epoll_pwait.cpp b/libc/src/sys/epoll/linux/epoll_pwait.cpp
index d7836549928c4..24fd1dbdc467d 100644
--- a/libc/src/sys/epoll/linux/epoll_pwait.cpp
+++ b/libc/src/sys/epoll/linux/epoll_pwait.cpp
@@ -13,9 +13,9 @@
#include "hdr/types/struct_epoll_event.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/sanitizer.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/sys/epoll/linux/epoll_pwait2.cpp b/libc/src/sys/epoll/linux/epoll_pwait2.cpp
index 14b419399fe9b..219984528efdd 100644
--- a/libc/src/sys/epoll/linux/epoll_pwait2.cpp
+++ b/libc/src/sys/epoll/linux/epoll_pwait2.cpp
@@ -14,9 +14,9 @@
#include "hdr/types/struct_timespec.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/sanitizer.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/sys/epoll/linux/epoll_wait.cpp b/libc/src/sys/epoll/linux/epoll_wait.cpp
index 1a63be5e260fb..7fae7b55992fa 100644
--- a/libc/src/sys/epoll/linux/epoll_wait.cpp
+++ b/libc/src/sys/epoll/linux/epoll_wait.cpp
@@ -13,9 +13,9 @@
#include "hdr/types/struct_epoll_event.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/sanitizer.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/sys/mman/linux/madvise.cpp b/libc/src/sys/mman/linux/madvise.cpp
index 332d6c2db4acb..1bb284f62b892 100644
--- a/libc/src/sys/mman/linux/madvise.cpp
+++ b/libc/src/sys/mman/linux/madvise.cpp
@@ -11,8 +11,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/mman/linux/mincore.cpp b/libc/src/sys/mman/linux/mincore.cpp
index b5436fda3853a..d583f1ef85f3d 100644
--- a/libc/src/sys/mman/linux/mincore.cpp
+++ b/libc/src/sys/mman/linux/mincore.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/mman/linux/mlock.cpp b/libc/src/sys/mman/linux/mlock.cpp
index be7eb28e29c4f..8582eb7c00632 100644
--- a/libc/src/sys/mman/linux/mlock.cpp
+++ b/libc/src/sys/mman/linux/mlock.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/mman/linux/mlock2.cpp b/libc/src/sys/mman/linux/mlock2.cpp
index 7bc557f9bf58f..955cfe128de74 100644
--- a/libc/src/sys/mman/linux/mlock2.cpp
+++ b/libc/src/sys/mman/linux/mlock2.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/mman/linux/mlockall.cpp b/libc/src/sys/mman/linux/mlockall.cpp
index eae3a9ea0a183..c3502fbb3af39 100644
--- a/libc/src/sys/mman/linux/mlockall.cpp
+++ b/libc/src/sys/mman/linux/mlockall.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/mman/linux/mmap.cpp b/libc/src/sys/mman/linux/mmap.cpp
index ee9a0a32e8f55..33f9fe8ff3709 100644
--- a/libc/src/sys/mman/linux/mmap.cpp
+++ b/libc/src/sys/mman/linux/mmap.cpp
@@ -11,8 +11,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <linux/param.h> // For EXEC_PAGESIZE.
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/sys/mman/linux/mprotect.cpp b/libc/src/sys/mman/linux/mprotect.cpp
index e2351028e2c7f..6b14915b60c94 100644
--- a/libc/src/sys/mman/linux/mprotect.cpp
+++ b/libc/src/sys/mman/linux/mprotect.cpp
@@ -11,8 +11,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/mman/linux/mremap.cpp b/libc/src/sys/mman/linux/mremap.cpp
index 38bcfce833d3d..6cdda9435bb69 100644
--- a/libc/src/sys/mman/linux/mremap.cpp
+++ b/libc/src/sys/mman/linux/mremap.cpp
@@ -11,8 +11,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <linux/param.h> // For EXEC_PAGESIZE.
#include <stdarg.h>
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/sys/mman/linux/msync.cpp b/libc/src/sys/mman/linux/msync.cpp
index e2b4f81d616ad..650678bcb36e0 100644
--- a/libc/src/sys/mman/linux/msync.cpp
+++ b/libc/src/sys/mman/linux/msync.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/mman/linux/munlock.cpp b/libc/src/sys/mman/linux/munlock.cpp
index 93c25f844c6e8..9638949f5fcb3 100644
--- a/libc/src/sys/mman/linux/munlock.cpp
+++ b/libc/src/sys/mman/linux/munlock.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/mman/linux/munlockall.cpp b/libc/src/sys/mman/linux/munlockall.cpp
index f5911cb01bc28..f47eaece178e3 100644
--- a/libc/src/sys/mman/linux/munlockall.cpp
+++ b/libc/src/sys/mman/linux/munlockall.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/mman/linux/munmap.cpp b/libc/src/sys/mman/linux/munmap.cpp
index 9c01b15ac8dc2..61b1f1549dd18 100644
--- a/libc/src/sys/mman/linux/munmap.cpp
+++ b/libc/src/sys/mman/linux/munmap.cpp
@@ -11,9 +11,9 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
-#include <sys/syscall.h> // For syscall numbers.
+#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/mman/linux/remap_file_pages.cpp b/libc/src/sys/mman/linux/remap_file_pages.cpp
index f616e1915ecc5..58ae4017f6285 100644
--- a/libc/src/sys/mman/linux/remap_file_pages.cpp
+++ b/libc/src/sys/mman/linux/remap_file_pages.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/mman/linux/shm_common.h b/libc/src/sys/mman/linux/shm_common.h
index ce75c2b5b6991..69911012ff7e9 100644
--- a/libc/src/sys/mman/linux/shm_common.h
+++ b/libc/src/sys/mman/linux/shm_common.h
@@ -9,8 +9,8 @@
#include "src/__support/CPP/array.h"
#include "src/__support/CPP/optional.h"
#include "src/__support/CPP/string_view.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include "src/string/memory_utils/inline_memcpy.h"
// TODO: Get PATH_MAX via https://github.com/llvm/llvm-project/issues/85121
diff --git a/libc/src/sys/prctl/linux/prctl.cpp b/libc/src/sys/prctl/linux/prctl.cpp
index 5d4e9046b8777..c726b0a539591 100644
--- a/libc/src/sys/prctl/linux/prctl.cpp
+++ b/libc/src/sys/prctl/linux/prctl.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/random/linux/getrandom.cpp b/libc/src/sys/random/linux/getrandom.cpp
index 9a8869a2d6d38..0b8471ed8b374 100644
--- a/libc/src/sys/random/linux/getrandom.cpp
+++ b/libc/src/sys/random/linux/getrandom.cpp
@@ -11,8 +11,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/resource/linux/getrlimit.cpp b/libc/src/sys/resource/linux/getrlimit.cpp
index 30c2e91b036d1..d272134194949 100644
--- a/libc/src/sys/resource/linux/getrlimit.cpp
+++ b/libc/src/sys/resource/linux/getrlimit.cpp
@@ -11,8 +11,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/resource.h> // For struct rlimit
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/sys/resource/linux/setrlimit.cpp b/libc/src/sys/resource/linux/setrlimit.cpp
index 85f07900aaef4..300bad75baa63 100644
--- a/libc/src/sys/resource/linux/setrlimit.cpp
+++ b/libc/src/sys/resource/linux/setrlimit.cpp
@@ -11,8 +11,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/resource.h> // For struct rlimit
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/sys/select/linux/select.cpp b/libc/src/sys/select/linux/select.cpp
index 9ccb1e95f275c..6c434eb584596 100644
--- a/libc/src/sys/select/linux/select.cpp
+++ b/libc/src/sys/select/linux/select.cpp
@@ -13,8 +13,8 @@
#include "src/__support/CPP/limits.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <stddef.h> // For size_t
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/sys/sendfile/linux/sendfile.cpp b/libc/src/sys/sendfile/linux/sendfile.cpp
index 9d4174cb8c916..ec892323def50 100644
--- a/libc/src/sys/sendfile/linux/sendfile.cpp
+++ b/libc/src/sys/sendfile/linux/sendfile.cpp
@@ -11,8 +11,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/sendfile.h>
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/sys/socket/linux/bind.cpp b/libc/src/sys/socket/linux/bind.cpp
index 72a3307a91ddd..83a3d06f5380b 100644
--- a/libc/src/sys/socket/linux/bind.cpp
+++ b/libc/src/sys/socket/linux/bind.cpp
@@ -11,8 +11,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <linux/net.h> // For SYS_SOCKET socketcall number.
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/sys/socket/linux/recv.cpp b/libc/src/sys/socket/linux/recv.cpp
index 5e9f2d3233fcf..baf4de1b5eb54 100644
--- a/libc/src/sys/socket/linux/recv.cpp
+++ b/libc/src/sys/socket/linux/recv.cpp
@@ -16,8 +16,8 @@
#include "hdr/types/struct_sockaddr.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/sanitizer.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/socket/linux/recvfrom.cpp b/libc/src/sys/socket/linux/recvfrom.cpp
index 574e65f64a54b..3d8397b478cc4 100644
--- a/libc/src/sys/socket/linux/recvfrom.cpp
+++ b/libc/src/sys/socket/linux/recvfrom.cpp
@@ -16,8 +16,8 @@
#include "hdr/types/struct_sockaddr.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/sanitizer.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/socket/linux/recvmsg.cpp b/libc/src/sys/socket/linux/recvmsg.cpp
index e42b6346f330a..bc6d072dbf9a1 100644
--- a/libc/src/sys/socket/linux/recvmsg.cpp
+++ b/libc/src/sys/socket/linux/recvmsg.cpp
@@ -15,8 +15,8 @@
#include "hdr/types/struct_msghdr.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/sanitizer.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/socket/linux/send.cpp b/libc/src/sys/socket/linux/send.cpp
index cb3b4d5a9ece7..43b01e7e6e0f6 100644
--- a/libc/src/sys/socket/linux/send.cpp
+++ b/libc/src/sys/socket/linux/send.cpp
@@ -16,7 +16,7 @@
#include "hdr/types/struct_sockaddr.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/socket/linux/sendmsg.cpp b/libc/src/sys/socket/linux/sendmsg.cpp
index b4d9c9deda028..b04783ebfe7e7 100644
--- a/libc/src/sys/socket/linux/sendmsg.cpp
+++ b/libc/src/sys/socket/linux/sendmsg.cpp
@@ -15,7 +15,7 @@
#include "hdr/types/struct_msghdr.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/socket/linux/sendto.cpp b/libc/src/sys/socket/linux/sendto.cpp
index 2fada192b0865..9dda127f872d5 100644
--- a/libc/src/sys/socket/linux/sendto.cpp
+++ b/libc/src/sys/socket/linux/sendto.cpp
@@ -16,7 +16,7 @@
#include "hdr/types/struct_sockaddr.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/socket/linux/socket.cpp b/libc/src/sys/socket/linux/socket.cpp
index 3e6df4d487a53..69eb6cfa01ced 100644
--- a/libc/src/sys/socket/linux/socket.cpp
+++ b/libc/src/sys/socket/linux/socket.cpp
@@ -11,8 +11,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <linux/net.h> // For SYS_SOCKET socketcall number.
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/sys/socket/linux/socketpair.cpp b/libc/src/sys/socket/linux/socketpair.cpp
index 60612ac04d613..7ea8ca46cee58 100644
--- a/libc/src/sys/socket/linux/socketpair.cpp
+++ b/libc/src/sys/socket/linux/socketpair.cpp
@@ -10,9 +10,9 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/sanitizer.h"
-#include "src/errno/libc_errno.h"
#include <linux/net.h> // For SYS_SOCKET socketcall number.
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/sys/stat/linux/chmod.cpp b/libc/src/sys/stat/linux/chmod.cpp
index 1b787e47e7c68..2bd0788ec1dfd 100644
--- a/libc/src/sys/stat/linux/chmod.cpp
+++ b/libc/src/sys/stat/linux/chmod.cpp
@@ -13,8 +13,8 @@
#include "hdr/fcntl_macros.h"
#include "hdr/types/mode_t.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/stat.h>
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/sys/stat/linux/fchmod.cpp b/libc/src/sys/stat/linux/fchmod.cpp
index 0d6fd359169aa..3dadfdd1d943c 100644
--- a/libc/src/sys/stat/linux/fchmod.cpp
+++ b/libc/src/sys/stat/linux/fchmod.cpp
@@ -12,8 +12,8 @@
#include "src/__support/common.h"
#include "hdr/types/mode_t.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/stat.h>
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/sys/stat/linux/fchmodat.cpp b/libc/src/sys/stat/linux/fchmodat.cpp
index e76db4d160fb8..add2192a558a4 100644
--- a/libc/src/sys/stat/linux/fchmodat.cpp
+++ b/libc/src/sys/stat/linux/fchmodat.cpp
@@ -11,8 +11,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/stat.h>
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/sys/stat/linux/fstat.cpp b/libc/src/sys/stat/linux/fstat.cpp
index 35cf8f08f782d..dea002c5e12a5 100644
--- a/libc/src/sys/stat/linux/fstat.cpp
+++ b/libc/src/sys/stat/linux/fstat.cpp
@@ -8,8 +8,8 @@
#include "src/sys/stat/fstat.h"
#include "kernel_statx.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include "src/__support/common.h"
diff --git a/libc/src/sys/stat/linux/lstat.cpp b/libc/src/sys/stat/linux/lstat.cpp
index 354c5b6e029a4..5601dd5d78a98 100644
--- a/libc/src/sys/stat/linux/lstat.cpp
+++ b/libc/src/sys/stat/linux/lstat.cpp
@@ -8,8 +8,8 @@
#include "src/sys/stat/lstat.h"
#include "kernel_statx.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
diff --git a/libc/src/sys/stat/linux/mkdir.cpp b/libc/src/sys/stat/linux/mkdir.cpp
index b319b5c8393de..0829ff4f94322 100644
--- a/libc/src/sys/stat/linux/mkdir.cpp
+++ b/libc/src/sys/stat/linux/mkdir.cpp
@@ -13,8 +13,8 @@
#include "hdr/fcntl_macros.h"
#include "hdr/types/mode_t.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/stat.h>
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/sys/stat/linux/mkdirat.cpp b/libc/src/sys/stat/linux/mkdirat.cpp
index 097fc158010d1..8f4194dc32752 100644
--- a/libc/src/sys/stat/linux/mkdirat.cpp
+++ b/libc/src/sys/stat/linux/mkdirat.cpp
@@ -11,8 +11,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/stat.h>
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/sys/stat/linux/stat.cpp b/libc/src/sys/stat/linux/stat.cpp
index de9cdb197d687..5553eaf00be2a 100644
--- a/libc/src/sys/stat/linux/stat.cpp
+++ b/libc/src/sys/stat/linux/stat.cpp
@@ -8,8 +8,8 @@
#include "src/sys/stat/stat.h"
#include "kernel_statx.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include "src/__support/common.h"
diff --git a/libc/src/sys/statvfs/linux/statfs_utils.h b/libc/src/sys/statvfs/linux/statfs_utils.h
index 1e5be51531012..8ee4de288ef61 100644
--- a/libc/src/sys/statvfs/linux/statfs_utils.h
+++ b/libc/src/sys/statvfs/linux/statfs_utils.h
@@ -12,9 +12,9 @@
#include "include/llvm-libc-types/struct_statvfs.h"
#include "src/__support/CPP/optional.h"
#include "src/__support/OSUtil/syscall.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/attributes.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <asm/statfs.h>
#include <sys/syscall.h>
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/time/linux/getitimer.cpp b/libc/src/sys/time/linux/getitimer.cpp
index fec06aa4086e9..b874066796940 100644
--- a/libc/src/sys/time/linux/getitimer.cpp
+++ b/libc/src/sys/time/linux/getitimer.cpp
@@ -10,7 +10,7 @@
#include "hdr/types/struct_itimerval.h"
#include "src/__support/OSUtil/syscall.h"
#include "src/__support/common.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include <sys/syscall.h>
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/time/linux/setitimer.cpp b/libc/src/sys/time/linux/setitimer.cpp
index def04a4740118..1de0d43297760 100644
--- a/libc/src/sys/time/linux/setitimer.cpp
+++ b/libc/src/sys/time/linux/setitimer.cpp
@@ -9,7 +9,7 @@
#include "hdr/types/struct_itimerval.h"
#include "src/__support/OSUtil/syscall.h"
#include "src/__support/common.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include <sys/syscall.h>
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/time/linux/utimes.cpp b/libc/src/sys/time/linux/utimes.cpp
index 76b69937a5f48..ed37b42aedf6c 100644
--- a/libc/src/sys/time/linux/utimes.cpp
+++ b/libc/src/sys/time/linux/utimes.cpp
@@ -15,7 +15,7 @@
#include "src/__support/OSUtil/syscall.h"
#include "src/__support/common.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include <sys/syscall.h>
diff --git a/libc/src/sys/uio/linux/readv.cpp b/libc/src/sys/uio/linux/readv.cpp
index f1393a9749be9..c9d8d87ddc72b 100644
--- a/libc/src/sys/uio/linux/readv.cpp
+++ b/libc/src/sys/uio/linux/readv.cpp
@@ -10,7 +10,7 @@
#include "hdr/types/struct_iovec.h"
#include "src/__support/OSUtil/syscall.h"
#include "src/__support/common.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include <sys/syscall.h>
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/uio/linux/writev.cpp b/libc/src/sys/uio/linux/writev.cpp
index 8992bed95c982..b0b9e15207922 100644
--- a/libc/src/sys/uio/linux/writev.cpp
+++ b/libc/src/sys/uio/linux/writev.cpp
@@ -10,7 +10,7 @@
#include "hdr/types/struct_iovec.h"
#include "src/__support/OSUtil/syscall.h"
#include "src/__support/common.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include <sys/syscall.h>
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/utsname/linux/uname.cpp b/libc/src/sys/utsname/linux/uname.cpp
index 7bb227e801e3a..b47ba964faf0b 100644
--- a/libc/src/sys/utsname/linux/uname.cpp
+++ b/libc/src/sys/utsname/linux/uname.cpp
@@ -11,8 +11,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
#include <sys/utsname.h>
diff --git a/libc/src/sys/wait/wait4Impl.h b/libc/src/sys/wait/wait4Impl.h
index f2bdeb02f8668..77ed3ad22f148 100644
--- a/libc/src/sys/wait/wait4Impl.h
+++ b/libc/src/sys/wait/wait4Impl.h
@@ -12,8 +12,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
#include "src/__support/error_or.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <signal.h>
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/termios/linux/cfsetispeed.cpp b/libc/src/termios/linux/cfsetispeed.cpp
index 9656b714a8ed2..47b19974d21be 100644
--- a/libc/src/termios/linux/cfsetispeed.cpp
+++ b/libc/src/termios/linux/cfsetispeed.cpp
@@ -9,8 +9,8 @@
#include "src/termios/cfsetispeed.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <termios.h>
diff --git a/libc/src/termios/linux/cfsetospeed.cpp b/libc/src/termios/linux/cfsetospeed.cpp
index 6130d266dbff0..d2f138257a47a 100644
--- a/libc/src/termios/linux/cfsetospeed.cpp
+++ b/libc/src/termios/linux/cfsetospeed.cpp
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "src/termios/cfsetospeed.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include "src/__support/common.h"
diff --git a/libc/src/termios/linux/tcdrain.cpp b/libc/src/termios/linux/tcdrain.cpp
index 116e3f0e0cbc5..570b15c24fe7f 100644
--- a/libc/src/termios/linux/tcdrain.cpp
+++ b/libc/src/termios/linux/tcdrain.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <asm/ioctls.h> // Safe to include without the risk of name pollution.
#include <sys/syscall.h> // For syscall numbers
diff --git a/libc/src/termios/linux/tcflow.cpp b/libc/src/termios/linux/tcflow.cpp
index d229230b5d138..714ef6aa71298 100644
--- a/libc/src/termios/linux/tcflow.cpp
+++ b/libc/src/termios/linux/tcflow.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <asm/ioctls.h> // Safe to include without the risk of name pollution.
#include <sys/syscall.h> // For syscall numbers
diff --git a/libc/src/termios/linux/tcflush.cpp b/libc/src/termios/linux/tcflush.cpp
index 028a5414b1960..4c7b9fadc446d 100644
--- a/libc/src/termios/linux/tcflush.cpp
+++ b/libc/src/termios/linux/tcflush.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <asm/ioctls.h> // Safe to include without the risk of name pollution.
#include <sys/syscall.h> // For syscall numbers
diff --git a/libc/src/termios/linux/tcgetattr.cpp b/libc/src/termios/linux/tcgetattr.cpp
index 63c096ff88eba..2e768269c874d 100644
--- a/libc/src/termios/linux/tcgetattr.cpp
+++ b/libc/src/termios/linux/tcgetattr.cpp
@@ -11,8 +11,8 @@
#include "src/__support/OSUtil/syscall.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <asm/ioctls.h> // Safe to include without the risk of name pollution.
#include <sys/syscall.h> // For syscall numbers
diff --git a/libc/src/termios/linux/tcgetsid.cpp b/libc/src/termios/linux/tcgetsid.cpp
index c283d0e4fda9a..7487816cf2741 100644
--- a/libc/src/termios/linux/tcgetsid.cpp
+++ b/libc/src/termios/linux/tcgetsid.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <asm/ioctls.h> // Safe to include without the risk of name pollution.
#include <sys/syscall.h> // For syscall numbers
diff --git a/libc/src/termios/linux/tcsendbreak.cpp b/libc/src/termios/linux/tcsendbreak.cpp
index 30bc91cf3de0a..1d546c1d5953e 100644
--- a/libc/src/termios/linux/tcsendbreak.cpp
+++ b/libc/src/termios/linux/tcsendbreak.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <asm/ioctls.h> // Safe to include without the risk of name pollution.
#include <sys/syscall.h> // For syscall numbers
diff --git a/libc/src/termios/linux/tcsetattr.cpp b/libc/src/termios/linux/tcsetattr.cpp
index 8aa1e5c57b34e..8a2c7290217ba 100644
--- a/libc/src/termios/linux/tcsetattr.cpp
+++ b/libc/src/termios/linux/tcsetattr.cpp
@@ -11,8 +11,8 @@
#include "src/__support/OSUtil/syscall.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <asm/ioctls.h> // Safe to include without the risk of name pollution.
#include <sys/syscall.h> // For syscall numbers
diff --git a/libc/src/threads/thrd_create.cpp b/libc/src/threads/thrd_create.cpp
index 4680944c2eee0..67e22e72fd0e4 100644
--- a/libc/src/threads/thrd_create.cpp
+++ b/libc/src/threads/thrd_create.cpp
@@ -8,9 +8,9 @@
#include "src/threads/thrd_create.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/threads/thread.h"
-#include "src/errno/libc_errno.h"
#include <threads.h> // For thrd_* type definitions.
diff --git a/libc/src/time/linux/clock.cpp b/libc/src/time/linux/clock.cpp
index ee4fa82b4f894..c38697cd0668e 100644
--- a/libc/src/time/linux/clock.cpp
+++ b/libc/src/time/linux/clock.cpp
@@ -10,10 +10,10 @@
#include "hdr/time_macros.h"
#include "src/__support/CPP/limits.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/time/clock_gettime.h"
#include "src/__support/time/units.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/time/linux/clock_gettime.cpp b/libc/src/time/linux/clock_gettime.cpp
index 743c644d65d02..b3fcd2b22f9da 100644
--- a/libc/src/time/linux/clock_gettime.cpp
+++ b/libc/src/time/linux/clock_gettime.cpp
@@ -8,9 +8,9 @@
#include "src/time/clock_gettime.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/time/clock_gettime.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/time/linux/gettimeofday.cpp b/libc/src/time/linux/gettimeofday.cpp
index e8ddf482fc984..237b05903c70f 100644
--- a/libc/src/time/linux/gettimeofday.cpp
+++ b/libc/src/time/linux/gettimeofday.cpp
@@ -10,10 +10,10 @@
#include "hdr/time_macros.h"
#include "hdr/types/suseconds_t.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/time/clock_gettime.h"
#include "src/__support/time/units.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/time/linux/nanosleep.cpp b/libc/src/time/linux/nanosleep.cpp
index 7a856376ffb20..6b9704126a0a5 100644
--- a/libc/src/time/linux/nanosleep.cpp
+++ b/libc/src/time/linux/nanosleep.cpp
@@ -10,8 +10,8 @@
#include "hdr/time_macros.h"
#include "src/__support/OSUtil/syscall.h" // For syscall functions.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <stdint.h> // For int64_t.
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/time/linux/timespec_get.cpp b/libc/src/time/linux/timespec_get.cpp
index cf5174523aa4f..a4d4372332732 100644
--- a/libc/src/time/linux/timespec_get.cpp
+++ b/libc/src/time/linux/timespec_get.cpp
@@ -9,9 +9,9 @@
#include "src/time/timespec_get.h"
#include "hdr/time_macros.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/time/clock_gettime.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/time/time.cpp b/libc/src/time/time.cpp
index 860909af7488c..2a81f0182c313 100644
--- a/libc/src/time/time.cpp
+++ b/libc/src/time/time.cpp
@@ -10,9 +10,9 @@
#include "hdr/time_macros.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/time/clock_gettime.h"
-#include "src/errno/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
// avoid inconsitent clang-format behavior
diff --git a/libc/src/time/time_utils.h b/libc/src/time/time_utils.h
index bbbb1c08a4759..0541c24ece82b 100644
--- a/libc/src/time/time_utils.h
+++ b/libc/src/time/time_utils.h
@@ -15,8 +15,8 @@
#include "src/__support/CPP/optional.h"
#include "src/__support/CPP/string_view.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include "time_constants.h"
#include <stdint.h>
diff --git a/libc/src/time/windows/clock_getres.cpp b/libc/src/time/windows/clock_getres.cpp
index b8c0c82aa6419..969bb66be2d25 100644
--- a/libc/src/time/windows/clock_getres.cpp
+++ b/libc/src/time/windows/clock_getres.cpp
@@ -13,10 +13,10 @@
#include "src/__support/CPP/limits.h"
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/optimization.h"
#include "src/__support/time/units.h"
#include "src/__support/time/windows/performance_counter.h"
-#include "src/errno/libc_errno.h"
#include "src/time/clock_getres.h"
#define WIN32_LEAN_AND_MEAN
diff --git a/libc/src/unistd/linux/access.cpp b/libc/src/unistd/linux/access.cpp
index 2f7ebbcdf9e81..55cd6adca779d 100644
--- a/libc/src/unistd/linux/access.cpp
+++ b/libc/src/unistd/linux/access.cpp
@@ -12,8 +12,8 @@
#include "src/__support/common.h"
#include "hdr/fcntl_macros.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/unistd/linux/chdir.cpp b/libc/src/unistd/linux/chdir.cpp
index a30d1dc883be8..04ba509b49a56 100644
--- a/libc/src/unistd/linux/chdir.cpp
+++ b/libc/src/unistd/linux/chdir.cpp
@@ -11,8 +11,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/unistd/linux/close.cpp b/libc/src/unistd/linux/close.cpp
index 58d42a9673fbe..b5842f2b64d20 100644
--- a/libc/src/unistd/linux/close.cpp
+++ b/libc/src/unistd/linux/close.cpp
@@ -11,8 +11,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/unistd/linux/dup.cpp b/libc/src/unistd/linux/dup.cpp
index c1710a37f6119..81d30c6cdbc4c 100644
--- a/libc/src/unistd/linux/dup.cpp
+++ b/libc/src/unistd/linux/dup.cpp
@@ -11,8 +11,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/unistd/linux/dup2.cpp b/libc/src/unistd/linux/dup2.cpp
index 7ffc151a053c9..0a0e86573b34e 100644
--- a/libc/src/unistd/linux/dup2.cpp
+++ b/libc/src/unistd/linux/dup2.cpp
@@ -12,8 +12,8 @@
#include "src/__support/common.h"
#include "hdr/fcntl_macros.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/unistd/linux/dup3.cpp b/libc/src/unistd/linux/dup3.cpp
index c096ba73c96bd..770fb73515b21 100644
--- a/libc/src/unistd/linux/dup3.cpp
+++ b/libc/src/unistd/linux/dup3.cpp
@@ -11,8 +11,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/unistd/linux/execv.cpp b/libc/src/unistd/linux/execv.cpp
index a3f2525ed7ca1..d4f2bd9a51653 100644
--- a/libc/src/unistd/linux/execv.cpp
+++ b/libc/src/unistd/linux/execv.cpp
@@ -13,7 +13,7 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/unistd/linux/execve.cpp b/libc/src/unistd/linux/execve.cpp
index 37162c4121782..2214b6df493bd 100644
--- a/libc/src/unistd/linux/execve.cpp
+++ b/libc/src/unistd/linux/execve.cpp
@@ -13,7 +13,7 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/unistd/linux/fchdir.cpp b/libc/src/unistd/linux/fchdir.cpp
index 8196dc63ab1e1..f7a7422363e6e 100644
--- a/libc/src/unistd/linux/fchdir.cpp
+++ b/libc/src/unistd/linux/fchdir.cpp
@@ -11,8 +11,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/unistd/linux/fork.cpp b/libc/src/unistd/linux/fork.cpp
index 8aa0477a15d58..75a76fdea50b2 100644
--- a/libc/src/unistd/linux/fork.cpp
+++ b/libc/src/unistd/linux/fork.cpp
@@ -15,7 +15,7 @@
#include "src/__support/threads/identifier.h"
#include "src/__support/threads/thread.h" // For thread self object
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include <signal.h> // For SIGCHLD
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/unistd/linux/fsync.cpp b/libc/src/unistd/linux/fsync.cpp
index ae3895bab15f3..fe08aed61e250 100644
--- a/libc/src/unistd/linux/fsync.cpp
+++ b/libc/src/unistd/linux/fsync.cpp
@@ -11,8 +11,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/unistd/linux/ftruncate.cpp b/libc/src/unistd/linux/ftruncate.cpp
index ccbb0634664aa..f6aa6f8b48cc9 100644
--- a/libc/src/unistd/linux/ftruncate.cpp
+++ b/libc/src/unistd/linux/ftruncate.cpp
@@ -12,8 +12,8 @@
#include "src/__support/common.h"
#include "hdr/unistd_macros.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <stdint.h> // For uint64_t.
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/unistd/linux/getcwd.cpp b/libc/src/unistd/linux/getcwd.cpp
index 1bb11a7c8e7ba..c0e475dd3e8ff 100644
--- a/libc/src/unistd/linux/getcwd.cpp
+++ b/libc/src/unistd/linux/getcwd.cpp
@@ -13,7 +13,7 @@
#include "src/__support/macros/config.h"
#include "src/string/allocating_string_utils.h" // For strdup.
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include <linux/limits.h> // This is safe to include without any name pollution.
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/unistd/linux/getentropy.cpp b/libc/src/unistd/linux/getentropy.cpp
index 168a1197734ed..65bcbf27601da 100644
--- a/libc/src/unistd/linux/getentropy.cpp
+++ b/libc/src/unistd/linux/getentropy.cpp
@@ -10,7 +10,7 @@
#include "hdr/errno_macros.h"
#include "src/__support/OSUtil/syscall.h"
#include "src/__support/common.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/unistd/linux/getsid.cpp b/libc/src/unistd/linux/getsid.cpp
index 5977c5bf10e94..025b8d1691ac3 100644
--- a/libc/src/unistd/linux/getsid.cpp
+++ b/libc/src/unistd/linux/getsid.cpp
@@ -11,8 +11,8 @@
#include "hdr/types/pid_t.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/unistd/linux/isatty.cpp b/libc/src/unistd/linux/isatty.cpp
index e6ea22a714c78..a4d17912b57b0 100644
--- a/libc/src/unistd/linux/isatty.cpp
+++ b/libc/src/unistd/linux/isatty.cpp
@@ -11,8 +11,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/ioctl.h> // For ioctl numbers.
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/unistd/linux/link.cpp b/libc/src/unistd/linux/link.cpp
index 477806a70df74..205cf8a84a5cb 100644
--- a/libc/src/unistd/linux/link.cpp
+++ b/libc/src/unistd/linux/link.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include "hdr/fcntl_macros.h"
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/unistd/linux/linkat.cpp b/libc/src/unistd/linux/linkat.cpp
index 40f68cc90c480..ea5bc48cbedc5 100644
--- a/libc/src/unistd/linux/linkat.cpp
+++ b/libc/src/unistd/linux/linkat.cpp
@@ -12,8 +12,8 @@
#include "src/__support/common.h"
#include "hdr/fcntl_macros.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/unistd/linux/lseek.cpp b/libc/src/unistd/linux/lseek.cpp
index 0e957498da746..26a08269fd8de 100644
--- a/libc/src/unistd/linux/lseek.cpp
+++ b/libc/src/unistd/linux/lseek.cpp
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "src/unistd/lseek.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include "src/__support/File/linux/lseekImpl.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
diff --git a/libc/src/unistd/linux/pathconf.cpp b/libc/src/unistd/linux/pathconf.cpp
index ca1c10bb9f7f6..7dde857c1cfd8 100644
--- a/libc/src/unistd/linux/pathconf.cpp
+++ b/libc/src/unistd/linux/pathconf.cpp
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "src/unistd/pathconf.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include "src/sys/statvfs/linux/statfs_utils.h"
#include "src/unistd/linux/pathconf_utils.h"
diff --git a/libc/src/unistd/linux/pathconf_utils.cpp b/libc/src/unistd/linux/pathconf_utils.cpp
index 035e628dff253..9a62e31fd1880 100644
--- a/libc/src/unistd/linux/pathconf_utils.cpp
+++ b/libc/src/unistd/linux/pathconf_utils.cpp
@@ -14,8 +14,8 @@
#include "hdr/unistd_macros.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include "src/sys/statvfs/linux/statfs_utils.h"
// other linux specific includes
diff --git a/libc/src/unistd/linux/pipe.cpp b/libc/src/unistd/linux/pipe.cpp
index dfcd5bfdaf537..b9943c8338056 100644
--- a/libc/src/unistd/linux/pipe.cpp
+++ b/libc/src/unistd/linux/pipe.cpp
@@ -10,10 +10,10 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/sanitizer.h" // for MSAN_UNPOISON
-#include "src/errno/libc_errno.h"
-#include <sys/syscall.h> // For syscall numbers.
+#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/unistd/linux/pipe2.cpp b/libc/src/unistd/linux/pipe2.cpp
index ebe7e0114ae99..d30f3b37a1adc 100644
--- a/libc/src/unistd/linux/pipe2.cpp
+++ b/libc/src/unistd/linux/pipe2.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/unistd/linux/pread.cpp b/libc/src/unistd/linux/pread.cpp
index 3e27857f9a2b4..2f86e397feeff 100644
--- a/libc/src/unistd/linux/pread.cpp
+++ b/libc/src/unistd/linux/pread.cpp
@@ -10,11 +10,11 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/sanitizer.h" // for MSAN_UNPOISON
-#include "src/errno/libc_errno.h"
-#include <stdint.h> // For uint64_t.
-#include <sys/syscall.h> // For syscall numbers.
+#include <stdint.h> // For uint64_t.
+#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/unistd/linux/pwrite.cpp b/libc/src/unistd/linux/pwrite.cpp
index 1b81b2a059494..f4cf8e16d766f 100644
--- a/libc/src/unistd/linux/pwrite.cpp
+++ b/libc/src/unistd/linux/pwrite.cpp
@@ -11,8 +11,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <stdint.h> // For uint64_t.
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/unistd/linux/read.cpp b/libc/src/unistd/linux/read.cpp
index 4419900f2330e..55676f3f7010a 100644
--- a/libc/src/unistd/linux/read.cpp
+++ b/libc/src/unistd/linux/read.cpp
@@ -10,10 +10,10 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/sanitizer.h" // for MSAN_UNPOISON
-#include "src/errno/libc_errno.h"
-#include <sys/syscall.h> // For syscall numbers.
+#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/unistd/linux/readlink.cpp b/libc/src/unistd/linux/readlink.cpp
index 2055e6b3400f2..b297a41ca37bd 100644
--- a/libc/src/unistd/linux/readlink.cpp
+++ b/libc/src/unistd/linux/readlink.cpp
@@ -12,8 +12,8 @@
#include "src/__support/common.h"
#include "hdr/fcntl_macros.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/unistd/linux/readlinkat.cpp b/libc/src/unistd/linux/readlinkat.cpp
index e5e4d0d39bc9c..cd0dcb8e0ff02 100644
--- a/libc/src/unistd/linux/readlinkat.cpp
+++ b/libc/src/unistd/linux/readlinkat.cpp
@@ -12,8 +12,8 @@
#include "src/__support/common.h"
#include "hdr/fcntl_macros.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/unistd/linux/rmdir.cpp b/libc/src/unistd/linux/rmdir.cpp
index 075af12af64c5..eca6e954ef898 100644
--- a/libc/src/unistd/linux/rmdir.cpp
+++ b/libc/src/unistd/linux/rmdir.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include "hdr/fcntl_macros.h"
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/unistd/linux/symlink.cpp b/libc/src/unistd/linux/symlink.cpp
index 9e1b2886ea0f5..3f43de19d2f46 100644
--- a/libc/src/unistd/linux/symlink.cpp
+++ b/libc/src/unistd/linux/symlink.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include "hdr/fcntl_macros.h"
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/unistd/linux/symlinkat.cpp b/libc/src/unistd/linux/symlinkat.cpp
index bcf2d0f8cc055..8cee172f39dfa 100644
--- a/libc/src/unistd/linux/symlinkat.cpp
+++ b/libc/src/unistd/linux/symlinkat.cpp
@@ -12,8 +12,8 @@
#include "src/__support/common.h"
#include "hdr/fcntl_macros.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/unistd/linux/syscall.cpp b/libc/src/unistd/linux/syscall.cpp
index 5394bff46adfa..0f7b3da88d627 100644
--- a/libc/src/unistd/linux/syscall.cpp
+++ b/libc/src/unistd/linux/syscall.cpp
@@ -11,8 +11,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <stdarg.h>
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/unistd/linux/sysconf.cpp b/libc/src/unistd/linux/sysconf.cpp
index f785ff321c7d7..03f224b150273 100644
--- a/libc/src/unistd/linux/sysconf.cpp
+++ b/libc/src/unistd/linux/sysconf.cpp
@@ -11,8 +11,8 @@
#include "src/__support/common.h"
#include "hdr/unistd_macros.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include "src/sys/auxv/getauxval.h"
#include <sys/auxv.h>
diff --git a/libc/src/unistd/linux/truncate.cpp b/libc/src/unistd/linux/truncate.cpp
index 8236edb480d10..6103d4b51350b 100644
--- a/libc/src/unistd/linux/truncate.cpp
+++ b/libc/src/unistd/linux/truncate.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include "hdr/unistd_macros.h"
#include <stdint.h> // For uint64_t.
diff --git a/libc/src/unistd/linux/unlink.cpp b/libc/src/unistd/linux/unlink.cpp
index 72d8e2398e3d7..5fde2600937b2 100644
--- a/libc/src/unistd/linux/unlink.cpp
+++ b/libc/src/unistd/linux/unlink.cpp
@@ -12,8 +12,8 @@
#include "src/__support/common.h"
#include "hdr/fcntl_macros.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/unistd/linux/unlinkat.cpp b/libc/src/unistd/linux/unlinkat.cpp
index 4ed20f542f170..b2012c52b8854 100644
--- a/libc/src/unistd/linux/unlinkat.cpp
+++ b/libc/src/unistd/linux/unlinkat.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include "hdr/fcntl_macros.h"
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/unistd/linux/write.cpp b/libc/src/unistd/linux/write.cpp
index 99d5ab7e480b0..eecb74429182a 100644
--- a/libc/src/unistd/linux/write.cpp
+++ b/libc/src/unistd/linux/write.cpp
@@ -10,8 +10,8 @@
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include <sys/syscall.h> // For syscall numbers.
diff --git a/libc/src/unistd/windows/getentropy.cpp b/libc/src/unistd/windows/getentropy.cpp
index bfaec723ac63d..e25a7a8fed406 100644
--- a/libc/src/unistd/windows/getentropy.cpp
+++ b/libc/src/unistd/windows/getentropy.cpp
@@ -9,7 +9,7 @@
#include "src/unistd/getentropy.h"
#include "hdr/errno_macros.h"
#include "src/__support/common.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
diff --git a/libc/test/UnitTest/ErrnoCheckingTest.h b/libc/test/UnitTest/ErrnoCheckingTest.h
index 3d3b72f80544f..7fb35c042a601 100644
--- a/libc/test/UnitTest/ErrnoCheckingTest.h
+++ b/libc/test/UnitTest/ErrnoCheckingTest.h
@@ -9,8 +9,8 @@
#ifndef LLVM_LIBC_TEST_UNITTEST_ERRNOCHECKINGTEST_H
#define LLVM_LIBC_TEST_UNITTEST_ERRNOCHECKINGTEST_H
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include "test/UnitTest/Test.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/test/UnitTest/ErrnoSetterMatcher.h b/libc/test/UnitTest/ErrnoSetterMatcher.h
index c6eadd25858ea..39d95845b509d 100644
--- a/libc/test/UnitTest/ErrnoSetterMatcher.h
+++ b/libc/test/UnitTest/ErrnoSetterMatcher.h
@@ -12,9 +12,9 @@
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/FPUtil/fpbits_str.h"
#include "src/__support/StringUtil/error_to_string.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/architectures.h"
-#include "src/errno/libc_errno.h"
#include "test/UnitTest/Test.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/test/integration/src/pthread/pthread_create_test.cpp b/libc/test/integration/src/pthread/pthread_create_test.cpp
index 29da4d5c3c8d7..4f51f7634a186 100644
--- a/libc/test/integration/src/pthread/pthread_create_test.cpp
+++ b/libc/test/integration/src/pthread/pthread_create_test.cpp
@@ -29,7 +29,7 @@
#include "src/__support/CPP/new.h"
#include "src/__support/threads/thread.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "test/IntegrationTest/test.h"
diff --git a/libc/test/integration/src/pthread/pthread_join_test.cpp b/libc/test/integration/src/pthread/pthread_join_test.cpp
index 994fa57a6b337..c9ef5ae0c278f 100644
--- a/libc/test/integration/src/pthread/pthread_join_test.cpp
+++ b/libc/test/integration/src/pthread/pthread_join_test.cpp
@@ -9,7 +9,7 @@
#include "src/pthread/pthread_create.h"
#include "src/pthread/pthread_join.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "test/IntegrationTest/test.h"
#include <pthread.h>
diff --git a/libc/test/integration/src/pthread/pthread_name_test.cpp b/libc/test/integration/src/pthread/pthread_name_test.cpp
index 37ceceee880de..35dd3b165e0ee 100644
--- a/libc/test/integration/src/pthread/pthread_name_test.cpp
+++ b/libc/test/integration/src/pthread/pthread_name_test.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/CPP/string_view.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/pthread/pthread_create.h"
#include "src/pthread/pthread_getname_np.h"
#include "src/pthread/pthread_join.h"
diff --git a/libc/test/integration/src/unistd/getcwd_test.cpp b/libc/test/integration/src/unistd/getcwd_test.cpp
index 551768187bf01..9dddcc0a9e3e2 100644
--- a/libc/test/integration/src/unistd/getcwd_test.cpp
+++ b/libc/test/integration/src/unistd/getcwd_test.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/CPP/string_view.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/stdlib/getenv.h"
#include "src/unistd/getcwd.h"
diff --git a/libc/test/integration/startup/linux/tls_test.cpp b/libc/test/integration/startup/linux/tls_test.cpp
index ef9fd9fcb7ff4..de3bd06c39cf6 100644
--- a/libc/test/integration/startup/linux/tls_test.cpp
+++ b/libc/test/integration/startup/linux/tls_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/sys/mman/mmap.h"
#include "test/IntegrationTest/test.h"
diff --git a/libc/test/src/__support/str_to_fp_test.h b/libc/test/src/__support/str_to_fp_test.h
index c7bc57b845fe0..8bf7eb78526c0 100644
--- a/libc/test/src/__support/str_to_fp_test.h
+++ b/libc/test/src/__support/str_to_fp_test.h
@@ -7,10 +7,10 @@
//===----------------------------------------------------------------------===//
#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/str_to_float.h"
#include "src/__support/uint128.h"
-#include "src/errno/libc_errno.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/__support/str_to_integer_test.cpp b/libc/test/src/__support/str_to_integer_test.cpp
index 34b645b4b38c8..40cb76a8bd6a2 100644
--- a/libc/test/src/__support/str_to_integer_test.cpp
+++ b/libc/test/src/__support/str_to_integer_test.cpp
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
+#include "src/__support/libc_errno.h"
#include "src/__support/str_to_integer.h"
-#include "src/errno/libc_errno.h"
#include <stddef.h>
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/dirent/dirent_test.cpp b/libc/test/src/dirent/dirent_test.cpp
index 41f522a6a75fb..9f4cb5b68acf7 100644
--- a/libc/test/src/dirent/dirent_test.cpp
+++ b/libc/test/src/dirent/dirent_test.cpp
@@ -7,11 +7,11 @@
//===----------------------------------------------------------------------===//
#include "src/__support/CPP/string_view.h"
+#include "src/__support/libc_errno.h"
#include "src/dirent/closedir.h"
#include "src/dirent/dirfd.h"
#include "src/dirent/opendir.h"
#include "src/dirent/readdir.h"
-#include "src/errno/libc_errno.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/errno/errno_test.cpp b/libc/test/src/errno/errno_test.cpp
index b0db22a85f3bc..b93e540bac746 100644
--- a/libc/test/src/errno/errno_test.cpp
+++ b/libc/test/src/errno/errno_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "test/UnitTest/Test.h"
TEST(LlvmLibcErrnoTest, Basic) {
diff --git a/libc/test/src/fcntl/creat_test.cpp b/libc/test/src/fcntl/creat_test.cpp
index 4c9d2cbc33f47..d60c984934703 100644
--- a/libc/test/src/fcntl/creat_test.cpp
+++ b/libc/test/src/fcntl/creat_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/fcntl/creat.h"
#include "src/fcntl/open.h"
#include "src/unistd/close.h"
diff --git a/libc/test/src/fcntl/fcntl_test.cpp b/libc/test/src/fcntl/fcntl_test.cpp
index 1a21afe51085b..87ce4d710332e 100644
--- a/libc/test/src/fcntl/fcntl_test.cpp
+++ b/libc/test/src/fcntl/fcntl_test.cpp
@@ -9,7 +9,7 @@
#include "hdr/fcntl_macros.h"
#include "hdr/stdio_macros.h"
#include "hdr/types/struct_flock.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/fcntl/fcntl.h"
#include "src/fcntl/open.h"
#include "src/unistd/close.h"
diff --git a/libc/test/src/fcntl/openat_test.cpp b/libc/test/src/fcntl/openat_test.cpp
index 213b074799c8d..1997476f16a60 100644
--- a/libc/test/src/fcntl/openat_test.cpp
+++ b/libc/test/src/fcntl/openat_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/fcntl/open.h"
#include "src/fcntl/openat.h"
#include "src/unistd/close.h"
diff --git a/libc/test/src/math/acosf_test.cpp b/libc/test/src/math/acosf_test.cpp
index 2e4c8eb2ab961..ccdc4b4e4a26b 100644
--- a/libc/test/src/math/acosf_test.cpp
+++ b/libc/test/src/math/acosf_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/acosf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/acoshf16_test.cpp b/libc/test/src/math/acoshf16_test.cpp
index 7348018396bd7..2eb95215e4e8b 100644
--- a/libc/test/src/math/acoshf16_test.cpp
+++ b/libc/test/src/math/acoshf16_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/acoshf16.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/acoshf_test.cpp b/libc/test/src/math/acoshf_test.cpp
index 18ed5a11d50a7..82247f6bbc258 100644
--- a/libc/test/src/math/acoshf_test.cpp
+++ b/libc/test/src/math/acoshf_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/acoshf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/asinf_test.cpp b/libc/test/src/math/asinf_test.cpp
index 5197810d8bd58..1fe1b7e99d92e 100644
--- a/libc/test/src/math/asinf_test.cpp
+++ b/libc/test/src/math/asinf_test.cpp
@@ -9,7 +9,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/asinf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/asinhf_test.cpp b/libc/test/src/math/asinhf_test.cpp
index ac125c3520c44..507c1ade54bb9 100644
--- a/libc/test/src/math/asinhf_test.cpp
+++ b/libc/test/src/math/asinhf_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/asinhf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/atanf_test.cpp b/libc/test/src/math/atanf_test.cpp
index 575ec89bd493c..b05cc1b3c5a30 100644
--- a/libc/test/src/math/atanf_test.cpp
+++ b/libc/test/src/math/atanf_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/atanf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/atanhf_test.cpp b/libc/test/src/math/atanhf_test.cpp
index 8b9db1dfdd976..68e066eaa63e4 100644
--- a/libc/test/src/math/atanhf_test.cpp
+++ b/libc/test/src/math/atanhf_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/atanhf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/cosf_test.cpp b/libc/test/src/math/cosf_test.cpp
index 2143c36f3d30b..bcd37005f27b8 100644
--- a/libc/test/src/math/cosf_test.cpp
+++ b/libc/test/src/math/cosf_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/cosf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/coshf_test.cpp b/libc/test/src/math/coshf_test.cpp
index 0d1c322b8e622..f8c83703a07b3 100644
--- a/libc/test/src/math/coshf_test.cpp
+++ b/libc/test/src/math/coshf_test.cpp
@@ -9,7 +9,7 @@
#include "hdr/math_macros.h"
#include "src/__support/CPP/array.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/coshf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/cospif_test.cpp b/libc/test/src/math/cospif_test.cpp
index 37ec2516f6a35..3672557d21cfb 100644
--- a/libc/test/src/math/cospif_test.cpp
+++ b/libc/test/src/math/cospif_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/cospif.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/src/math/sdcomp26094.h"
diff --git a/libc/test/src/math/exp10_test.cpp b/libc/test/src/math/exp10_test.cpp
index 6fb1d2d9d925e..887e22f794ec6 100644
--- a/libc/test/src/math/exp10_test.cpp
+++ b/libc/test/src/math/exp10_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/exp10.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/exp10f_test.cpp b/libc/test/src/math/exp10f_test.cpp
index 001b37809d930..6132cb53c2f3f 100644
--- a/libc/test/src/math/exp10f_test.cpp
+++ b/libc/test/src/math/exp10f_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/exp10f.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/exp10m1f_test.cpp b/libc/test/src/math/exp10m1f_test.cpp
index aee273384f1a2..abe8acf3bd4ad 100644
--- a/libc/test/src/math/exp10m1f_test.cpp
+++ b/libc/test/src/math/exp10m1f_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/CPP/array.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/exp10m1f.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/exp2_test.cpp b/libc/test/src/math/exp2_test.cpp
index adfceceeef4b7..d8a7288266507 100644
--- a/libc/test/src/math/exp2_test.cpp
+++ b/libc/test/src/math/exp2_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/exp2.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/exp2f_test.cpp b/libc/test/src/math/exp2f_test.cpp
index 0c4c821534392..16ced7596e9ff 100644
--- a/libc/test/src/math/exp2f_test.cpp
+++ b/libc/test/src/math/exp2f_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/exp2f.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/exp2m1f_test.cpp b/libc/test/src/math/exp2m1f_test.cpp
index 793cf0cc2cbb4..7667c0ef022fd 100644
--- a/libc/test/src/math/exp2m1f_test.cpp
+++ b/libc/test/src/math/exp2m1f_test.cpp
@@ -9,7 +9,7 @@
#include "hdr/math_macros.h"
#include "src/__support/CPP/array.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/exp2m1f.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/exp_test.cpp b/libc/test/src/math/exp_test.cpp
index 0ab3a4e543464..a871437cad046 100644
--- a/libc/test/src/math/exp_test.cpp
+++ b/libc/test/src/math/exp_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/exp.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/expf_test.cpp b/libc/test/src/math/expf_test.cpp
index 26a0bca4ce253..46dd8f301d2ad 100644
--- a/libc/test/src/math/expf_test.cpp
+++ b/libc/test/src/math/expf_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/expf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/expm1_test.cpp b/libc/test/src/math/expm1_test.cpp
index 9720773d9f960..2530fdfbb1fda 100644
--- a/libc/test/src/math/expm1_test.cpp
+++ b/libc/test/src/math/expm1_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/expm1.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/expm1f_test.cpp b/libc/test/src/math/expm1f_test.cpp
index 274fe3bb7afb0..09fb4c008079f 100644
--- a/libc/test/src/math/expm1f_test.cpp
+++ b/libc/test/src/math/expm1f_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/expm1f.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/log10_test.cpp b/libc/test/src/math/log10_test.cpp
index 01aa1f82ae5d8..b06866e0262a8 100644
--- a/libc/test/src/math/log10_test.cpp
+++ b/libc/test/src/math/log10_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/log10.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/log1p_test.cpp b/libc/test/src/math/log1p_test.cpp
index 107e965a0d3ae..960faf8671520 100644
--- a/libc/test/src/math/log1p_test.cpp
+++ b/libc/test/src/math/log1p_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/log1p.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/log1pf_test.cpp b/libc/test/src/math/log1pf_test.cpp
index bb181dc5e43b0..f4999e8267311 100644
--- a/libc/test/src/math/log1pf_test.cpp
+++ b/libc/test/src/math/log1pf_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/log1pf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/log2_test.cpp b/libc/test/src/math/log2_test.cpp
index 8a07991a68886..e23dd99a078f2 100644
--- a/libc/test/src/math/log2_test.cpp
+++ b/libc/test/src/math/log2_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/log2.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/log2f_test.cpp b/libc/test/src/math/log2f_test.cpp
index 83691fb75300e..3a6d26df985a9 100644
--- a/libc/test/src/math/log2f_test.cpp
+++ b/libc/test/src/math/log2f_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/log2f.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/log_test.cpp b/libc/test/src/math/log_test.cpp
index 969a469b2e1c6..55744da402579 100644
--- a/libc/test/src/math/log_test.cpp
+++ b/libc/test/src/math/log_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/log.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/sincosf_test.cpp b/libc/test/src/math/sincosf_test.cpp
index 2823110331f30..b4730873fd930 100644
--- a/libc/test/src/math/sincosf_test.cpp
+++ b/libc/test/src/math/sincosf_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/sincosf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/sinf_test.cpp b/libc/test/src/math/sinf_test.cpp
index 8fd3ed1577cee..ba15742c15000 100644
--- a/libc/test/src/math/sinf_test.cpp
+++ b/libc/test/src/math/sinf_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/sinf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/sinhf_test.cpp b/libc/test/src/math/sinhf_test.cpp
index 6867c7aec57df..334463fb45600 100644
--- a/libc/test/src/math/sinhf_test.cpp
+++ b/libc/test/src/math/sinhf_test.cpp
@@ -9,7 +9,7 @@
#include "hdr/math_macros.h"
#include "src/__support/CPP/array.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/sinhf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/sinpif_test.cpp b/libc/test/src/math/sinpif_test.cpp
index d00fd77d288c6..35b2d120ff849 100644
--- a/libc/test/src/math/sinpif_test.cpp
+++ b/libc/test/src/math/sinpif_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/sinpif.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/src/math/sdcomp26094.h"
diff --git a/libc/test/src/math/smoke/FModTest.h b/libc/test/src/math/smoke/FModTest.h
index 8fbcc2a276542..04cbc659ece5d 100644
--- a/libc/test/src/math/smoke/FModTest.h
+++ b/libc/test/src/math/smoke/FModTest.h
@@ -10,7 +10,7 @@
#define LLVM_LIBC_TEST_SRC_MATH_FMODTEST_H
#include "src/__support/FPUtil/FEnvImpl.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/acos_test.cpp b/libc/test/src/math/smoke/acos_test.cpp
index 3a59bce264077..5af9fd3fa6890 100644
--- a/libc/test/src/math/smoke/acos_test.cpp
+++ b/libc/test/src/math/smoke/acos_test.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "hdr/fenv_macros.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/acos.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/acosf16_test.cpp b/libc/test/src/math/smoke/acosf16_test.cpp
index c4274b8245092..e50699b628222 100644
--- a/libc/test/src/math/smoke/acosf16_test.cpp
+++ b/libc/test/src/math/smoke/acosf16_test.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/acosf16.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/acosf_test.cpp b/libc/test/src/math/smoke/acosf_test.cpp
index 74f68e00011aa..3a4a1ec5d053b 100644
--- a/libc/test/src/math/smoke/acosf_test.cpp
+++ b/libc/test/src/math/smoke/acosf_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/acosf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/acoshf16_test.cpp b/libc/test/src/math/smoke/acoshf16_test.cpp
index 7681c2a4e7fbc..a1699119709b8 100644
--- a/libc/test/src/math/smoke/acoshf16_test.cpp
+++ b/libc/test/src/math/smoke/acoshf16_test.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/FPUtil/cast.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/acoshf16.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/acoshf_test.cpp b/libc/test/src/math/smoke/acoshf_test.cpp
index c5ba88055ac57..b787f1ebb61f8 100644
--- a/libc/test/src/math/smoke/acoshf_test.cpp
+++ b/libc/test/src/math/smoke/acoshf_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/acoshf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/acospif16_test.cpp b/libc/test/src/math/smoke/acospif16_test.cpp
index 66b94706eab94..9929a1a1b6e49 100644
--- a/libc/test/src/math/smoke/acospif16_test.cpp
+++ b/libc/test/src/math/smoke/acospif16_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/acospif16.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/asinf16_test.cpp b/libc/test/src/math/smoke/asinf16_test.cpp
index 9f675b08319c0..d3c7b7a517906 100644
--- a/libc/test/src/math/smoke/asinf16_test.cpp
+++ b/libc/test/src/math/smoke/asinf16_test.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/asinf16.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/asinf_test.cpp b/libc/test/src/math/smoke/asinf_test.cpp
index d817d2b366192..d97acf203b2c8 100644
--- a/libc/test/src/math/smoke/asinf_test.cpp
+++ b/libc/test/src/math/smoke/asinf_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/asinf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/asinhf16_test.cpp b/libc/test/src/math/smoke/asinhf16_test.cpp
index dcaab217331c7..0ba8af905a264 100644
--- a/libc/test/src/math/smoke/asinhf16_test.cpp
+++ b/libc/test/src/math/smoke/asinhf16_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/asinhf16.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/asinhf_test.cpp b/libc/test/src/math/smoke/asinhf_test.cpp
index 4a8743c50075f..a9e3319158e68 100644
--- a/libc/test/src/math/smoke/asinhf_test.cpp
+++ b/libc/test/src/math/smoke/asinhf_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/asinhf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/atan2f_test.cpp b/libc/test/src/math/smoke/atan2f_test.cpp
index 1fbcfbe96b2d7..abf2615a281be 100644
--- a/libc/test/src/math/smoke/atan2f_test.cpp
+++ b/libc/test/src/math/smoke/atan2f_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/atan2f.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/atanf_test.cpp b/libc/test/src/math/smoke/atanf_test.cpp
index 7d09a28beaa38..5e71e7f193087 100644
--- a/libc/test/src/math/smoke/atanf_test.cpp
+++ b/libc/test/src/math/smoke/atanf_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/atanf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/atanhf16_test.cpp b/libc/test/src/math/smoke/atanhf16_test.cpp
index 81df6da8cee26..e792c36152409 100644
--- a/libc/test/src/math/smoke/atanhf16_test.cpp
+++ b/libc/test/src/math/smoke/atanhf16_test.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/FPUtil/cast.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/atanhf16.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/atanhf_test.cpp b/libc/test/src/math/smoke/atanhf_test.cpp
index 73a5b81b0240b..edd55e21ed18d 100644
--- a/libc/test/src/math/smoke/atanhf_test.cpp
+++ b/libc/test/src/math/smoke/atanhf_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/atanhf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/cosf16_test.cpp b/libc/test/src/math/smoke/cosf16_test.cpp
index 2638551fb1d1b..a62b20cb8557c 100644
--- a/libc/test/src/math/smoke/cosf16_test.cpp
+++ b/libc/test/src/math/smoke/cosf16_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/cosf16.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/cosf_test.cpp b/libc/test/src/math/smoke/cosf_test.cpp
index 99773583dcb10..06bed7007da50 100644
--- a/libc/test/src/math/smoke/cosf_test.cpp
+++ b/libc/test/src/math/smoke/cosf_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/cosf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/coshf16_test.cpp b/libc/test/src/math/smoke/coshf16_test.cpp
index 08d05ecce86ba..7258b00c50de6 100644
--- a/libc/test/src/math/smoke/coshf16_test.cpp
+++ b/libc/test/src/math/smoke/coshf16_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/fenv_macros.h"
#include "src/__support/FPUtil/cast.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/coshf16.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/coshf_test.cpp b/libc/test/src/math/smoke/coshf_test.cpp
index 1611ea1b92926..484ffdbfd025b 100644
--- a/libc/test/src/math/smoke/coshf_test.cpp
+++ b/libc/test/src/math/smoke/coshf_test.cpp
@@ -9,7 +9,7 @@
#include "hdr/math_macros.h"
#include "src/__support/CPP/array.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/coshf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/cospif16_test.cpp b/libc/test/src/math/smoke/cospif16_test.cpp
index edd8ed97b30f6..3762a17d670ee 100644
--- a/libc/test/src/math/smoke/cospif16_test.cpp
+++ b/libc/test/src/math/smoke/cospif16_test.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/FPUtil/cast.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/cospif16.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/cospif_test.cpp b/libc/test/src/math/smoke/cospif_test.cpp
index 20153897dc459..dd096bad6ce20 100644
--- a/libc/test/src/math/smoke/cospif_test.cpp
+++ b/libc/test/src/math/smoke/cospif_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/cospif.h"
#include "test/UnitTest/FPMatcher.h"
diff --git a/libc/test/src/math/smoke/exp10_test.cpp b/libc/test/src/math/smoke/exp10_test.cpp
index baf8a76810970..50d3de0c7fe75 100644
--- a/libc/test/src/math/smoke/exp10_test.cpp
+++ b/libc/test/src/math/smoke/exp10_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/exp10.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/exp10f16_test.cpp b/libc/test/src/math/smoke/exp10f16_test.cpp
index 1c4ef2aa08a70..87a83be138b38 100644
--- a/libc/test/src/math/smoke/exp10f16_test.cpp
+++ b/libc/test/src/math/smoke/exp10f16_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/fenv_macros.h"
#include "src/__support/FPUtil/cast.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/exp10f16.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/exp10f_test.cpp b/libc/test/src/math/smoke/exp10f_test.cpp
index bf39e2cc12d0c..23d790cf2bc0e 100644
--- a/libc/test/src/math/smoke/exp10f_test.cpp
+++ b/libc/test/src/math/smoke/exp10f_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/exp10f.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/exp10m1f16_test.cpp b/libc/test/src/math/smoke/exp10m1f16_test.cpp
index dfa7fa477d3d1..83c67bfda3f43 100644
--- a/libc/test/src/math/smoke/exp10m1f16_test.cpp
+++ b/libc/test/src/math/smoke/exp10m1f16_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/fenv_macros.h"
#include "src/__support/FPUtil/cast.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/exp10m1f16.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/exp10m1f_test.cpp b/libc/test/src/math/smoke/exp10m1f_test.cpp
index 2c2cfdbb08a3f..d0668cb2a841d 100644
--- a/libc/test/src/math/smoke/exp10m1f_test.cpp
+++ b/libc/test/src/math/smoke/exp10m1f_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/exp10m1f.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/exp2_test.cpp b/libc/test/src/math/smoke/exp2_test.cpp
index 9ab9129416dad..aebf808350727 100644
--- a/libc/test/src/math/smoke/exp2_test.cpp
+++ b/libc/test/src/math/smoke/exp2_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/exp2.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/exp2f16_test.cpp b/libc/test/src/math/smoke/exp2f16_test.cpp
index f69b33a3cf37f..2a2697e8ef7da 100644
--- a/libc/test/src/math/smoke/exp2f16_test.cpp
+++ b/libc/test/src/math/smoke/exp2f16_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/fenv_macros.h"
#include "src/__support/FPUtil/cast.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/exp2f16.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/exp2f_test.cpp b/libc/test/src/math/smoke/exp2f_test.cpp
index a928389cc41b4..5faf47dcb7962 100644
--- a/libc/test/src/math/smoke/exp2f_test.cpp
+++ b/libc/test/src/math/smoke/exp2f_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/exp2f.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/exp2m1f16_test.cpp b/libc/test/src/math/smoke/exp2m1f16_test.cpp
index f423196a70360..6c0b39a0a8a32 100644
--- a/libc/test/src/math/smoke/exp2m1f16_test.cpp
+++ b/libc/test/src/math/smoke/exp2m1f16_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/fenv_macros.h"
#include "src/__support/FPUtil/cast.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/exp2m1f16.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/exp2m1f_test.cpp b/libc/test/src/math/smoke/exp2m1f_test.cpp
index 99bdf0035df0c..f974fe2e6d213 100644
--- a/libc/test/src/math/smoke/exp2m1f_test.cpp
+++ b/libc/test/src/math/smoke/exp2m1f_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/exp2m1f.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/exp_test.cpp b/libc/test/src/math/smoke/exp_test.cpp
index f86243092f1fb..c3b2ae70e1d99 100644
--- a/libc/test/src/math/smoke/exp_test.cpp
+++ b/libc/test/src/math/smoke/exp_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/exp.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/expf16_test.cpp b/libc/test/src/math/smoke/expf16_test.cpp
index ab745a3cf6f56..16857d8abe8f6 100644
--- a/libc/test/src/math/smoke/expf16_test.cpp
+++ b/libc/test/src/math/smoke/expf16_test.cpp
@@ -9,7 +9,7 @@
#include "hdr/errno_macros.h"
#include "hdr/fenv_macros.h"
#include "src/__support/FPUtil/cast.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/expf16.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/expf_test.cpp b/libc/test/src/math/smoke/expf_test.cpp
index eee8304999275..bc2fb829f40ce 100644
--- a/libc/test/src/math/smoke/expf_test.cpp
+++ b/libc/test/src/math/smoke/expf_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/expf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/expm1_test.cpp b/libc/test/src/math/smoke/expm1_test.cpp
index bc71c53abc7ac..c842fe3c45fe1 100644
--- a/libc/test/src/math/smoke/expm1_test.cpp
+++ b/libc/test/src/math/smoke/expm1_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/expm1.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/expm1f16_test.cpp b/libc/test/src/math/smoke/expm1f16_test.cpp
index f297c5dfc3c7e..633511dab2443 100644
--- a/libc/test/src/math/smoke/expm1f16_test.cpp
+++ b/libc/test/src/math/smoke/expm1f16_test.cpp
@@ -9,7 +9,7 @@
#include "hdr/errno_macros.h"
#include "hdr/fenv_macros.h"
#include "src/__support/FPUtil/cast.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/expm1f16.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/expm1f_test.cpp b/libc/test/src/math/smoke/expm1f_test.cpp
index dfb474d70fb6a..fec55aac9b3a5 100644
--- a/libc/test/src/math/smoke/expm1f_test.cpp
+++ b/libc/test/src/math/smoke/expm1f_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/expm1f.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/log10_test.cpp b/libc/test/src/math/smoke/log10_test.cpp
index ff73850c52101..49cfda85111a5 100644
--- a/libc/test/src/math/smoke/log10_test.cpp
+++ b/libc/test/src/math/smoke/log10_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/log10.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/log10f16_test.cpp b/libc/test/src/math/smoke/log10f16_test.cpp
index 471e198933326..babea2c42cd49 100644
--- a/libc/test/src/math/smoke/log10f16_test.cpp
+++ b/libc/test/src/math/smoke/log10f16_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/fenv_macros.h"
#include "src/__support/FPUtil/cast.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/log10f16.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/log1p_test.cpp b/libc/test/src/math/smoke/log1p_test.cpp
index 631c24b8abcf9..61c56cd2c6ddd 100644
--- a/libc/test/src/math/smoke/log1p_test.cpp
+++ b/libc/test/src/math/smoke/log1p_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/log1p.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/log1pf_test.cpp b/libc/test/src/math/smoke/log1pf_test.cpp
index bd828ad58c4c9..dc3489fddf99f 100644
--- a/libc/test/src/math/smoke/log1pf_test.cpp
+++ b/libc/test/src/math/smoke/log1pf_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/log1pf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/log2_test.cpp b/libc/test/src/math/smoke/log2_test.cpp
index 9993d442967cb..0534d00b1f408 100644
--- a/libc/test/src/math/smoke/log2_test.cpp
+++ b/libc/test/src/math/smoke/log2_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/log2.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/log2f16_test.cpp b/libc/test/src/math/smoke/log2f16_test.cpp
index 6d98482aa4499..e8e82784c49db 100644
--- a/libc/test/src/math/smoke/log2f16_test.cpp
+++ b/libc/test/src/math/smoke/log2f16_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/fenv_macros.h"
#include "src/__support/FPUtil/cast.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/log2f16.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/log2f_test.cpp b/libc/test/src/math/smoke/log2f_test.cpp
index 8648b75b88b83..53d54ac367639 100644
--- a/libc/test/src/math/smoke/log2f_test.cpp
+++ b/libc/test/src/math/smoke/log2f_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/log2f.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/log_test.cpp b/libc/test/src/math/smoke/log_test.cpp
index d31eb0c1db734..09e9ab0a9a4d8 100644
--- a/libc/test/src/math/smoke/log_test.cpp
+++ b/libc/test/src/math/smoke/log_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/log.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/logf16_test.cpp b/libc/test/src/math/smoke/logf16_test.cpp
index c7232aa1c1e32..20b8f7be10932 100644
--- a/libc/test/src/math/smoke/logf16_test.cpp
+++ b/libc/test/src/math/smoke/logf16_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/fenv_macros.h"
#include "src/__support/FPUtil/cast.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/logf16.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/sincosf_test.cpp b/libc/test/src/math/smoke/sincosf_test.cpp
index 5f66868f12a1c..57185415be14b 100644
--- a/libc/test/src/math/smoke/sincosf_test.cpp
+++ b/libc/test/src/math/smoke/sincosf_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/sincosf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/sinf16_test.cpp b/libc/test/src/math/smoke/sinf16_test.cpp
index a0e7a7ba321fd..ea01b3fa6328f 100644
--- a/libc/test/src/math/smoke/sinf16_test.cpp
+++ b/libc/test/src/math/smoke/sinf16_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/sinf16.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/sinf_test.cpp b/libc/test/src/math/smoke/sinf_test.cpp
index de504b4f5335c..636835383d866 100644
--- a/libc/test/src/math/smoke/sinf_test.cpp
+++ b/libc/test/src/math/smoke/sinf_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/sinf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/sinhf16_test.cpp b/libc/test/src/math/smoke/sinhf16_test.cpp
index 4f21d33ba78e0..c84235d4f12d3 100644
--- a/libc/test/src/math/smoke/sinhf16_test.cpp
+++ b/libc/test/src/math/smoke/sinhf16_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/fenv_macros.h"
#include "src/__support/FPUtil/cast.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/sinhf16.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/sinhf_test.cpp b/libc/test/src/math/smoke/sinhf_test.cpp
index e22cfc7ea14d8..82ddfbaadcd9b 100644
--- a/libc/test/src/math/smoke/sinhf_test.cpp
+++ b/libc/test/src/math/smoke/sinhf_test.cpp
@@ -9,7 +9,7 @@
#include "hdr/math_macros.h"
#include "src/__support/CPP/array.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/sinhf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/sinpif16_test.cpp b/libc/test/src/math/smoke/sinpif16_test.cpp
index b2db6fb9f8626..e1a46ece73619 100644
--- a/libc/test/src/math/smoke/sinpif16_test.cpp
+++ b/libc/test/src/math/smoke/sinpif16_test.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/FPUtil/cast.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/sinpif16.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/sinpif_test.cpp b/libc/test/src/math/smoke/sinpif_test.cpp
index 1ba5c1d2b720a..f466a794dfb29 100644
--- a/libc/test/src/math/smoke/sinpif_test.cpp
+++ b/libc/test/src/math/smoke/sinpif_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/sinpif.h"
#include "test/UnitTest/FPMatcher.h"
diff --git a/libc/test/src/math/smoke/tanf16_test.cpp b/libc/test/src/math/smoke/tanf16_test.cpp
index f65b9fced72c4..25f1976b3e819 100644
--- a/libc/test/src/math/smoke/tanf16_test.cpp
+++ b/libc/test/src/math/smoke/tanf16_test.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/tanf16.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/tanf_test.cpp b/libc/test/src/math/smoke/tanf_test.cpp
index 178e9065f430f..a37f9c5da71e6 100644
--- a/libc/test/src/math/smoke/tanf_test.cpp
+++ b/libc/test/src/math/smoke/tanf_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/tanf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/tanhf16_test.cpp b/libc/test/src/math/smoke/tanhf16_test.cpp
index fa6328e9ef0a6..74c352565447f 100644
--- a/libc/test/src/math/smoke/tanhf16_test.cpp
+++ b/libc/test/src/math/smoke/tanhf16_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/fenv_macros.h"
#include "src/__support/FPUtil/cast.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/tanhf16.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/tanhf_test.cpp b/libc/test/src/math/smoke/tanhf_test.cpp
index c09761ef531f2..f942953c6899b 100644
--- a/libc/test/src/math/smoke/tanhf_test.cpp
+++ b/libc/test/src/math/smoke/tanhf_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/tanhf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/smoke/tanpif16_test.cpp b/libc/test/src/math/smoke/tanpif16_test.cpp
index 74797d1649b1a..bca03a678e9e3 100644
--- a/libc/test/src/math/smoke/tanpif16_test.cpp
+++ b/libc/test/src/math/smoke/tanpif16_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/tanpif16.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/tanf_test.cpp b/libc/test/src/math/tanf_test.cpp
index 9061cf6fb30b8..0b3d044adce1d 100644
--- a/libc/test/src/math/tanf_test.cpp
+++ b/libc/test/src/math/tanf_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/tanf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/math/tanhf_test.cpp b/libc/test/src/math/tanhf_test.cpp
index 389abe4d85897..a2382e9cbcf04 100644
--- a/libc/test/src/math/tanhf_test.cpp
+++ b/libc/test/src/math/tanhf_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/tanhf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/poll/poll_test.cpp b/libc/test/src/poll/poll_test.cpp
index 30f5e41c61ecf..455c2786269e2 100644
--- a/libc/test/src/poll/poll_test.cpp
+++ b/libc/test/src/poll/poll_test.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "hdr/limits_macros.h" // UINT_MAX
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/poll/poll.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/sched/affinity_test.cpp b/libc/test/src/sched/affinity_test.cpp
index b5085203e5ce0..e6c242e7fa462 100644
--- a/libc/test/src/sched/affinity_test.cpp
+++ b/libc/test/src/sched/affinity_test.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/OSUtil/syscall.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/sched/sched_getaffinity.h"
#include "src/sched/sched_setaffinity.h"
#include "test/UnitTest/ErrnoSetterMatcher.h"
diff --git a/libc/test/src/sched/cpu_count_test.cpp b/libc/test/src/sched/cpu_count_test.cpp
index 5250368a26162..c473bde2dc672 100644
--- a/libc/test/src/sched/cpu_count_test.cpp
+++ b/libc/test/src/sched/cpu_count_test.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/OSUtil/syscall.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/sched/sched_getaffinity.h"
#include "src/sched/sched_getcpucount.h"
#include "test/UnitTest/ErrnoSetterMatcher.h"
diff --git a/libc/test/src/sched/get_priority_test.cpp b/libc/test/src/sched/get_priority_test.cpp
index 59205c51e4a16..117083fb82566 100644
--- a/libc/test/src/sched/get_priority_test.cpp
+++ b/libc/test/src/sched/get_priority_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/sched/sched_get_priority_max.h"
#include "src/sched/sched_get_priority_min.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/sched/param_and_scheduler_test.cpp b/libc/test/src/sched/param_and_scheduler_test.cpp
index 747c7e3409e41..fe8ed862d1e2f 100644
--- a/libc/test/src/sched/param_and_scheduler_test.cpp
+++ b/libc/test/src/sched/param_and_scheduler_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/sched/sched_get_priority_max.h"
#include "src/sched/sched_get_priority_min.h"
#include "src/sched/sched_getparam.h"
diff --git a/libc/test/src/sched/sched_rr_get_interval_test.cpp b/libc/test/src/sched/sched_rr_get_interval_test.cpp
index c22a2c76d743c..a503b2537e157 100644
--- a/libc/test/src/sched/sched_rr_get_interval_test.cpp
+++ b/libc/test/src/sched/sched_rr_get_interval_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/sched/sched_get_priority_min.h"
#include "src/sched/sched_getscheduler.h"
#include "src/sched/sched_rr_get_interval.h"
diff --git a/libc/test/src/sched/yield_test.cpp b/libc/test/src/sched/yield_test.cpp
index f1627a71fa9ad..67db018f8bda8 100644
--- a/libc/test/src/sched/yield_test.cpp
+++ b/libc/test/src/sched/yield_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/sched/sched_yield.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/signal/sigaltstack_test.cpp b/libc/test/src/signal/sigaltstack_test.cpp
index cc392da8f4731..1ec36b2a22c49 100644
--- a/libc/test/src/signal/sigaltstack_test.cpp
+++ b/libc/test/src/signal/sigaltstack_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/signal_macros.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/signal/linux/signal_utils.h"
#include "src/signal/raise.h"
#include "src/signal/sigaction.h"
diff --git a/libc/test/src/signal/signal_test.cpp b/libc/test/src/signal/signal_test.cpp
index bac9c3b8b68bb..5001a9cf2086f 100644
--- a/libc/test/src/signal/signal_test.cpp
+++ b/libc/test/src/signal/signal_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/signal/raise.h"
#include "src/signal/signal.h"
diff --git a/libc/test/src/signal/sigprocmask_test.cpp b/libc/test/src/signal/sigprocmask_test.cpp
index 12403f68b5930..27ddb7dc8bc9b 100644
--- a/libc/test/src/signal/sigprocmask_test.cpp
+++ b/libc/test/src/signal/sigprocmask_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/signal/raise.h"
#include "src/signal/sigaddset.h"
#include "src/signal/sigemptyset.h"
diff --git a/libc/test/src/spawn/posix_spawn_file_actions_test.cpp b/libc/test/src/spawn/posix_spawn_file_actions_test.cpp
index c1edf56bdbd87..01ccb8218ee20 100644
--- a/libc/test/src/spawn/posix_spawn_file_actions_test.cpp
+++ b/libc/test/src/spawn/posix_spawn_file_actions_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/spawn/file_actions.h"
#include "src/spawn/posix_spawn_file_actions_addclose.h"
#include "src/spawn/posix_spawn_file_actions_adddup2.h"
diff --git a/libc/test/src/stdio/fdopen_test.cpp b/libc/test/src/stdio/fdopen_test.cpp
index ef36cff2ffbd5..fb485d0ab6967 100644
--- a/libc/test/src/stdio/fdopen_test.cpp
+++ b/libc/test/src/stdio/fdopen_test.cpp
@@ -9,7 +9,7 @@
#include "src/stdio/fdopen.h"
#include "hdr/fcntl_macros.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/fcntl/open.h"
#include "src/stdio/fclose.h"
#include "src/stdio/fgets.h"
diff --git a/libc/test/src/stdio/fgetc_test.cpp b/libc/test/src/stdio/fgetc_test.cpp
index 2cc8436bd66f2..defcdb060ad84 100644
--- a/libc/test/src/stdio/fgetc_test.cpp
+++ b/libc/test/src/stdio/fgetc_test.cpp
@@ -17,7 +17,7 @@
#include "test/UnitTest/Test.h"
#include "hdr/stdio_macros.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
class LlvmLibcGetcTest : public LIBC_NAMESPACE::testing::Test {
public:
diff --git a/libc/test/src/stdio/fgetc_unlocked_test.cpp b/libc/test/src/stdio/fgetc_unlocked_test.cpp
index 46cf12c2c253b..6a0201d650c74 100644
--- a/libc/test/src/stdio/fgetc_unlocked_test.cpp
+++ b/libc/test/src/stdio/fgetc_unlocked_test.cpp
@@ -20,7 +20,7 @@
#include "test/UnitTest/Test.h"
#include "hdr/stdio_macros.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
class LlvmLibcGetcTest : public LIBC_NAMESPACE::testing::Test {
public:
diff --git a/libc/test/src/stdio/fgets_test.cpp b/libc/test/src/stdio/fgets_test.cpp
index a8a2c62f07b5e..85c1f4aadee3c 100644
--- a/libc/test/src/stdio/fgets_test.cpp
+++ b/libc/test/src/stdio/fgets_test.cpp
@@ -14,7 +14,7 @@
#include "src/stdio/fwrite.h"
#include "test/UnitTest/Test.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
TEST(LlvmLibcFgetsTest, WriteAndReadCharacters) {
constexpr char FILENAME[] = "testdata/fgets.test";
diff --git a/libc/test/src/stdio/fileop_test.cpp b/libc/test/src/stdio/fileop_test.cpp
index a0368d701a676..92bcf2aeace8c 100644
--- a/libc/test/src/stdio/fileop_test.cpp
+++ b/libc/test/src/stdio/fileop_test.cpp
@@ -21,7 +21,7 @@
#include "test/UnitTest/Test.h"
#include "hdr/stdio_macros.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::EQ;
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::NE;
diff --git a/libc/test/src/stdio/fopencookie_test.cpp b/libc/test/src/stdio/fopencookie_test.cpp
index 61ce2a207fa19..b05245bbf93e3 100644
--- a/libc/test/src/stdio/fopencookie_test.cpp
+++ b/libc/test/src/stdio/fopencookie_test.cpp
@@ -20,7 +20,7 @@
#include "hdr/stdio_macros.h"
#include "hdr/types/size_t.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
using MemoryView = LIBC_NAMESPACE::testing::MemoryView;
diff --git a/libc/test/src/stdio/remove_test.cpp b/libc/test/src/stdio/remove_test.cpp
index 72875600903a6..f0820b581311f 100644
--- a/libc/test/src/stdio/remove_test.cpp
+++ b/libc/test/src/stdio/remove_test.cpp
@@ -14,7 +14,7 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include <unistd.h>
TEST(LlvmLibcRemoveTest, CreateAndRemoveFile) {
diff --git a/libc/test/src/stdio/rename_test.cpp b/libc/test/src/stdio/rename_test.cpp
index a5dd734c63616..5f2671cbc5a1a 100644
--- a/libc/test/src/stdio/rename_test.cpp
+++ b/libc/test/src/stdio/rename_test.cpp
@@ -8,7 +8,7 @@
#include "include/llvm-libc-macros/linux/sys-stat-macros.h"
#include "include/llvm-libc-macros/linux/unistd-macros.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/fcntl/open.h"
#include "src/stdio/rename.h"
#include "src/unistd/access.h"
diff --git a/libc/test/src/stdio/setvbuf_test.cpp b/libc/test/src/stdio/setvbuf_test.cpp
index a1e1fee25db31..85f71f7100cfd 100644
--- a/libc/test/src/stdio/setvbuf_test.cpp
+++ b/libc/test/src/stdio/setvbuf_test.cpp
@@ -14,7 +14,7 @@
#include "test/UnitTest/Test.h"
#include "hdr/stdio_macros.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
TEST(LlvmLibcSetvbufTest, SetNBFBuffer) {
// The idea in this test is that we open a file for writing and reading, and
diff --git a/libc/test/src/stdio/sprintf_test.cpp b/libc/test/src/stdio/sprintf_test.cpp
index f6af6ad3e364b..54820407c0dc0 100644
--- a/libc/test/src/stdio/sprintf_test.cpp
+++ b/libc/test/src/stdio/sprintf_test.cpp
@@ -10,7 +10,7 @@
#include "src/stdio/sprintf.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "test/UnitTest/RoundingModeUtils.h"
#include "test/UnitTest/Test.h"
#include <inttypes.h>
diff --git a/libc/test/src/stdio/unlocked_fileop_test.cpp b/libc/test/src/stdio/unlocked_fileop_test.cpp
index 67f1b0ff513bc..a0e9870aefb8e 100644
--- a/libc/test/src/stdio/unlocked_fileop_test.cpp
+++ b/libc/test/src/stdio/unlocked_fileop_test.cpp
@@ -17,7 +17,7 @@
#include "src/stdio/fwrite_unlocked.h"
#include "test/UnitTest/Test.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
TEST(LlvmLibcFILETest, UnlockedReadAndWrite) {
constexpr char fNAME[] = "testdata/unlocked_read_and_write.test";
diff --git a/libc/test/src/stdlib/StrtolTest.h b/libc/test/src/stdlib/StrtolTest.h
index ed302f14d03ef..ce0a7d5c77706 100644
--- a/libc/test/src/stdlib/StrtolTest.h
+++ b/libc/test/src/stdlib/StrtolTest.h
@@ -9,8 +9,8 @@
#include "src/__support/CPP/limits.h"
#include "src/__support/CPP/type_traits.h"
#include "src/__support/ctype_utils.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/properties/architectures.h"
-#include "src/errno/libc_errno.h"
#include "test/UnitTest/Test.h"
#include <stddef.h>
diff --git a/libc/test/src/stdlib/atof_test.cpp b/libc/test/src/stdlib/atof_test.cpp
index 1e4259b792d7e..eb0b99a01d1dd 100644
--- a/libc/test/src/stdlib/atof_test.cpp
+++ b/libc/test/src/stdlib/atof_test.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/stdlib/atof.h"
#include "test/UnitTest/ErrnoSetterMatcher.h"
diff --git a/libc/test/src/stdlib/strtod_test.cpp b/libc/test/src/stdlib/strtod_test.cpp
index 92d14640e6533..38821dbc26bc6 100644
--- a/libc/test/src/stdlib/strtod_test.cpp
+++ b/libc/test/src/stdlib/strtod_test.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/stdlib/strtod.h"
#include "test/UnitTest/ErrnoSetterMatcher.h"
diff --git a/libc/test/src/stdlib/strtof_test.cpp b/libc/test/src/stdlib/strtof_test.cpp
index 6a716c956291c..6ca27e110f9fe 100644
--- a/libc/test/src/stdlib/strtof_test.cpp
+++ b/libc/test/src/stdlib/strtof_test.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/FPUtil/FPBits.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/stdlib/strtof.h"
#include "test/UnitTest/FPMatcher.h"
diff --git a/libc/test/src/stdlib/strtoint32_test.cpp b/libc/test/src/stdlib/strtoint32_test.cpp
index 17df432fc8e68..ee28cc1505c68 100644
--- a/libc/test/src/stdlib/strtoint32_test.cpp
+++ b/libc/test/src/stdlib/strtoint32_test.cpp
@@ -8,9 +8,9 @@
#include <stdint.h>
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/str_to_integer.h"
-#include "src/errno/libc_errno.h"
#include "StrtolTest.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/stdlib/strtoint64_test.cpp b/libc/test/src/stdlib/strtoint64_test.cpp
index b5fe69dfaa701..bdc384d03b364 100644
--- a/libc/test/src/stdlib/strtoint64_test.cpp
+++ b/libc/test/src/stdlib/strtoint64_test.cpp
@@ -8,9 +8,9 @@
#include <stdint.h>
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/str_to_integer.h"
-#include "src/errno/libc_errno.h"
#include "StrtolTest.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/stdlib/strtold_test.cpp b/libc/test/src/stdlib/strtold_test.cpp
index b209c85b88e36..bb140937ef1cf 100644
--- a/libc/test/src/stdlib/strtold_test.cpp
+++ b/libc/test/src/stdlib/strtold_test.cpp
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/uint128.h"
-#include "src/errno/libc_errno.h"
#include "src/stdlib/strtold.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/string/strdup_test.cpp b/libc/test/src/string/strdup_test.cpp
index 20b85c37637dd..ed9c3d4b15d9e 100644
--- a/libc/test/src/string/strdup_test.cpp
+++ b/libc/test/src/string/strdup_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/string/strdup.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/sys/auxv/linux/getauxval_test.cpp b/libc/test/src/sys/auxv/linux/getauxval_test.cpp
index 8811fd8dfbc3a..369f00b2ffd22 100644
--- a/libc/test/src/sys/auxv/linux/getauxval_test.cpp
+++ b/libc/test/src/sys/auxv/linux/getauxval_test.cpp
@@ -5,7 +5,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/sys/auxv/getauxval.h"
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/sys/mman/linux/madvise_test.cpp b/libc/test/src/sys/mman/linux/madvise_test.cpp
index 6768d111c0d91..9d46b103b7e9a 100644
--- a/libc/test/src/sys/mman/linux/madvise_test.cpp
+++ b/libc/test/src/sys/mman/linux/madvise_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/sys/mman/madvise.h"
#include "src/sys/mman/mmap.h"
#include "src/sys/mman/munmap.h"
diff --git a/libc/test/src/sys/mman/linux/mincore_test.cpp b/libc/test/src/sys/mman/linux/mincore_test.cpp
index e49e300e43c88..f4618af72f661 100644
--- a/libc/test/src/sys/mman/linux/mincore_test.cpp
+++ b/libc/test/src/sys/mman/linux/mincore_test.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/sys/mman/madvise.h"
#include "src/sys/mman/mincore.h"
#include "src/sys/mman/mlock.h"
diff --git a/libc/test/src/sys/mman/linux/mlock_test.cpp b/libc/test/src/sys/mman/linux/mlock_test.cpp
index 48cde1317655a..57ea2018078bf 100644
--- a/libc/test/src/sys/mman/linux/mlock_test.cpp
+++ b/libc/test/src/sys/mman/linux/mlock_test.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/sys/mman/madvise.h"
#include "src/sys/mman/mincore.h"
#include "src/sys/mman/mlock.h"
diff --git a/libc/test/src/sys/mman/linux/mmap_test.cpp b/libc/test/src/sys/mman/linux/mmap_test.cpp
index dcbc75808f13c..e1e594a6222e5 100644
--- a/libc/test/src/sys/mman/linux/mmap_test.cpp
+++ b/libc/test/src/sys/mman/linux/mmap_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/sys/mman/mmap.h"
#include "src/sys/mman/munmap.h"
#include "test/UnitTest/ErrnoSetterMatcher.h"
diff --git a/libc/test/src/sys/mman/linux/mprotect_test.cpp b/libc/test/src/sys/mman/linux/mprotect_test.cpp
index 46e449e54779f..0bdfec405c48e 100644
--- a/libc/test/src/sys/mman/linux/mprotect_test.cpp
+++ b/libc/test/src/sys/mman/linux/mprotect_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/sys/mman/mmap.h"
#include "src/sys/mman/mprotect.h"
#include "src/sys/mman/munmap.h"
diff --git a/libc/test/src/sys/mman/linux/mremap_test.cpp b/libc/test/src/sys/mman/linux/mremap_test.cpp
index 12e4485588421..2a1e253ada938 100644
--- a/libc/test/src/sys/mman/linux/mremap_test.cpp
+++ b/libc/test/src/sys/mman/linux/mremap_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/sys/mman/mmap.h"
#include "src/sys/mman/mremap.h"
#include "src/sys/mman/munmap.h"
diff --git a/libc/test/src/sys/mman/linux/msync_test.cpp b/libc/test/src/sys/mman/linux/msync_test.cpp
index 65eedb2b8232e..10ba1732adb8b 100644
--- a/libc/test/src/sys/mman/linux/msync_test.cpp
+++ b/libc/test/src/sys/mman/linux/msync_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/sys/mman/mlock.h"
#include "src/sys/mman/mmap.h"
#include "src/sys/mman/msync.h"
diff --git a/libc/test/src/sys/mman/linux/posix_madvise_test.cpp b/libc/test/src/sys/mman/linux/posix_madvise_test.cpp
index ee6489c5ed2f5..3b88c164d198e 100644
--- a/libc/test/src/sys/mman/linux/posix_madvise_test.cpp
+++ b/libc/test/src/sys/mman/linux/posix_madvise_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/sys/mman/mmap.h"
#include "src/sys/mman/munmap.h"
#include "src/sys/mman/posix_madvise.h"
diff --git a/libc/test/src/sys/mman/linux/remap_file_pages_test.cpp b/libc/test/src/sys/mman/linux/remap_file_pages_test.cpp
index ebc5c89a1ff57..efa096c5be2d8 100644
--- a/libc/test/src/sys/mman/linux/remap_file_pages_test.cpp
+++ b/libc/test/src/sys/mman/linux/remap_file_pages_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/fcntl/open.h"
#include "src/sys/mman/mmap.h"
#include "src/sys/mman/munmap.h"
diff --git a/libc/test/src/sys/prctl/linux/prctl_test.cpp b/libc/test/src/sys/prctl/linux/prctl_test.cpp
index 987c35d553470..42a2cdbf1de8b 100644
--- a/libc/test/src/sys/prctl/linux/prctl_test.cpp
+++ b/libc/test/src/sys/prctl/linux/prctl_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/sys/prctl/prctl.h"
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include <sys/prctl.h>
diff --git a/libc/test/src/sys/random/linux/getrandom_test.cpp b/libc/test/src/sys/random/linux/getrandom_test.cpp
index eb5b23cc4cd08..af42d2f644cdf 100644
--- a/libc/test/src/sys/random/linux/getrandom_test.cpp
+++ b/libc/test/src/sys/random/linux/getrandom_test.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/CPP/array.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/math/fabs.h"
#include "src/sys/random/getrandom.h"
#include "test/UnitTest/ErrnoSetterMatcher.h"
diff --git a/libc/test/src/sys/resource/getrlimit_setrlimit_test.cpp b/libc/test/src/sys/resource/getrlimit_setrlimit_test.cpp
index 62d21c33e9986..170f78430c968 100644
--- a/libc/test/src/sys/resource/getrlimit_setrlimit_test.cpp
+++ b/libc/test/src/sys/resource/getrlimit_setrlimit_test.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/CPP/string_view.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/fcntl/open.h"
#include "src/sys/resource/getrlimit.h"
#include "src/sys/resource/setrlimit.h"
diff --git a/libc/test/src/sys/select/select_ui_test.cpp b/libc/test/src/sys/select/select_ui_test.cpp
index a158cab8ff058..553f5c56f004b 100644
--- a/libc/test/src/sys/select/select_ui_test.cpp
+++ b/libc/test/src/sys/select/select_ui_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/sys/select/select.h"
#include "src/unistd/read.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/sys/sendfile/sendfile_test.cpp b/libc/test/src/sys/sendfile/sendfile_test.cpp
index a658212ddb72c..9108792b9c0ac 100644
--- a/libc/test/src/sys/sendfile/sendfile_test.cpp
+++ b/libc/test/src/sys/sendfile/sendfile_test.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/CPP/string_view.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/fcntl/open.h"
#include "src/sys/sendfile/sendfile.h"
#include "src/unistd/close.h"
diff --git a/libc/test/src/sys/stat/chmod_test.cpp b/libc/test/src/sys/stat/chmod_test.cpp
index 83ab0f45b6f08..6a6f0d4196fe8 100644
--- a/libc/test/src/sys/stat/chmod_test.cpp
+++ b/libc/test/src/sys/stat/chmod_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/fcntl/open.h"
#include "src/sys/stat/chmod.h"
#include "src/unistd/close.h"
diff --git a/libc/test/src/sys/stat/fchmod_test.cpp b/libc/test/src/sys/stat/fchmod_test.cpp
index 03eb79d95ddd6..6477f0b3786ab 100644
--- a/libc/test/src/sys/stat/fchmod_test.cpp
+++ b/libc/test/src/sys/stat/fchmod_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/fcntl/open.h"
#include "src/sys/stat/fchmod.h"
#include "src/unistd/close.h"
diff --git a/libc/test/src/sys/stat/fchmodat_test.cpp b/libc/test/src/sys/stat/fchmodat_test.cpp
index 09970b6e0fb16..74c8a5b57b260 100644
--- a/libc/test/src/sys/stat/fchmodat_test.cpp
+++ b/libc/test/src/sys/stat/fchmodat_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/fcntl/open.h"
#include "src/sys/stat/fchmodat.h"
#include "src/unistd/close.h"
diff --git a/libc/test/src/sys/stat/fstat_test.cpp b/libc/test/src/sys/stat/fstat_test.cpp
index 34c675d1a4e29..c2e934c51163a 100644
--- a/libc/test/src/sys/stat/fstat_test.cpp
+++ b/libc/test/src/sys/stat/fstat_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/fcntl/open.h"
#include "src/sys/stat/fstat.h"
#include "src/unistd/close.h"
diff --git a/libc/test/src/sys/stat/lstat_test.cpp b/libc/test/src/sys/stat/lstat_test.cpp
index a723d5ae2e297..fb4785ef2e851 100644
--- a/libc/test/src/sys/stat/lstat_test.cpp
+++ b/libc/test/src/sys/stat/lstat_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/fcntl/open.h"
#include "src/sys/stat/lstat.h"
#include "src/unistd/close.h"
diff --git a/libc/test/src/sys/stat/stat_test.cpp b/libc/test/src/sys/stat/stat_test.cpp
index 0ddd8baaec1c9..26427d75c24e8 100644
--- a/libc/test/src/sys/stat/stat_test.cpp
+++ b/libc/test/src/sys/stat/stat_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/fcntl/open.h"
#include "src/sys/stat/stat.h"
#include "src/unistd/close.h"
diff --git a/libc/test/src/sys/statvfs/linux/statvfs_test.cpp b/libc/test/src/sys/statvfs/linux/statvfs_test.cpp
index 32f8120e17b42..7062e7fe5828d 100644
--- a/libc/test/src/sys/statvfs/linux/statvfs_test.cpp
+++ b/libc/test/src/sys/statvfs/linux/statvfs_test.cpp
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "hdr/fcntl_macros.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "src/errno/libc_errno.h"
#include "src/sys/stat/mkdirat.h"
#include "src/sys/statvfs/statvfs.h"
#include "src/unistd/rmdir.h"
diff --git a/libc/test/src/sys/time/utimes_test.cpp b/libc/test/src/sys/time/utimes_test.cpp
index 66e69a1b2a700..f9f08ae0729fe 100644
--- a/libc/test/src/sys/time/utimes_test.cpp
+++ b/libc/test/src/sys/time/utimes_test.cpp
@@ -9,7 +9,7 @@
#include "hdr/fcntl_macros.h"
#include "hdr/sys_stat_macros.h"
#include "hdr/types/struct_timeval.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/fcntl/open.h"
#include "src/stdio/remove.h"
#include "src/sys/stat/stat.h"
diff --git a/libc/test/src/termios/termios_test.cpp b/libc/test/src/termios/termios_test.cpp
index f8fc09a8bbf0e..9cd2e8da07cdb 100644
--- a/libc/test/src/termios/termios_test.cpp
+++ b/libc/test/src/termios/termios_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/fcntl/open.h"
#include "src/termios/cfgetispeed.h"
#include "src/termios/cfgetospeed.h"
diff --git a/libc/test/src/time/asctime_r_test.cpp b/libc/test/src/time/asctime_r_test.cpp
index b595cfe024866..d840248b7df42 100644
--- a/libc/test/src/time/asctime_r_test.cpp
+++ b/libc/test/src/time/asctime_r_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/time/asctime_r.h"
#include "src/time/time_constants.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/time/asctime_test.cpp b/libc/test/src/time/asctime_test.cpp
index 169a7463a3037..cad25fffc65af 100644
--- a/libc/test/src/time/asctime_test.cpp
+++ b/libc/test/src/time/asctime_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/time/asctime.h"
#include "test/UnitTest/Test.h"
#include "test/src/time/TmHelper.h"
diff --git a/libc/test/src/time/ctime_r_test.cpp b/libc/test/src/time/ctime_r_test.cpp
index 27011b7e0fbd6..fe43877aa499d 100644
--- a/libc/test/src/time/ctime_r_test.cpp
+++ b/libc/test/src/time/ctime_r_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/time/ctime_r.h"
#include "src/time/time_constants.h"
#include "test/UnitTest/Test.h"
diff --git a/libc/test/src/time/ctime_test.cpp b/libc/test/src/time/ctime_test.cpp
index 6f1168f0b6685..5ff69f6619b4f 100644
--- a/libc/test/src/time/ctime_test.cpp
+++ b/libc/test/src/time/ctime_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/time/ctime.h"
#include "test/UnitTest/Test.h"
#include "test/src/time/TmHelper.h"
diff --git a/libc/test/src/time/gmtime_test.cpp b/libc/test/src/time/gmtime_test.cpp
index 6af5a18d36996..044637cbde870 100644
--- a/libc/test/src/time/gmtime_test.cpp
+++ b/libc/test/src/time/gmtime_test.cpp
@@ -8,7 +8,7 @@
#include "hdr/types/struct_tm.h"
#include "src/__support/CPP/limits.h" // INT_MAX, INT_MIN
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/time/gmtime.h"
#include "src/time/time_constants.h"
#include "test/UnitTest/ErrnoSetterMatcher.h"
diff --git a/libc/test/src/time/nanosleep_test.cpp b/libc/test/src/time/nanosleep_test.cpp
index d4f98e29bd980..d5d7f88126c37 100644
--- a/libc/test/src/time/nanosleep_test.cpp
+++ b/libc/test/src/time/nanosleep_test.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "hdr/types/struct_timespec.h"
-#include "src/errno/libc_errno.h"
+#include "src/__support/libc_errno.h"
#include "src/time/nanosleep.h"
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index d9a02a2fd85c5..81dcc1d1a4c87 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -1618,7 +1618,7 @@ libc_header_library(
libc_support_library(
name = "errno",
srcs = ["src/errno/libc_errno.cpp"],
- hdrs = ["src/errno/libc_errno.h"],
+ hdrs = ["src/__support/libc_errno.h"],
deps = [
":__support_common",
":__support_cpp_atomic",
>From 034380c9e08f3949bf397fd77dd3a722fee34e48 Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue.h at gmail.com>
Date: Wed, 21 May 2025 02:59:43 +0000
Subject: [PATCH 2/4] [libc] Refactor expf implementation to header-only in
src/__support/math folder and add libc/shared/math.h
---
libc/shared/math.h | 22 +++
libc/src/__support/CMakeLists.txt | 2 +
libc/src/__support/math/CMakeLists.txt | 0
libc/src/__support/math/exp_float_constants.h | 145 ++++++++++++++++++
libc/src/__support/math/expf.h | 116 ++++++++++++++
libc/src/math/generic/expf.cpp | 97 +-----------
6 files changed, 287 insertions(+), 95 deletions(-)
create mode 100644 libc/shared/math.h
create mode 100644 libc/src/__support/math/CMakeLists.txt
create mode 100644 libc/src/__support/math/exp_float_constants.h
create mode 100644 libc/src/__support/math/expf.h
diff --git a/libc/shared/math.h b/libc/shared/math.h
new file mode 100644
index 0000000000000..19c49bb23bc39
--- /dev/null
+++ b/libc/shared/math.h
@@ -0,0 +1,22 @@
+//===-- Floating point math functions ---------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_H
+#define LLVM_LIBC_SHARED_MATH_H
+
+#include "src/__support/math/expf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::expf;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_FP_BITS_H
diff --git a/libc/src/__support/CMakeLists.txt b/libc/src/__support/CMakeLists.txt
index f92499fdbf451..e4a3a7983e4de 100644
--- a/libc/src/__support/CMakeLists.txt
+++ b/libc/src/__support/CMakeLists.txt
@@ -381,3 +381,5 @@ add_subdirectory(HashTable)
add_subdirectory(fixed_point)
add_subdirectory(time)
+
+add_subdirectory(math)
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/libc/src/__support/math/exp_float_constants.h b/libc/src/__support/math/exp_float_constants.h
new file mode 100644
index 0000000000000..cabb227a034b5
--- /dev/null
+++ b/libc/src/__support/math/exp_float_constants.h
@@ -0,0 +1,145 @@
+//===-- Look-up tables for exp*f functions ----------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_EXP_FLOAT_CONSTANTS_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_EXP_FLOAT_CONSTANTS_H
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+// Lookup table for exp(m) with m = -104, ..., 89.
+// -104 = floor(log(single precision's min denormal))
+// 89 = ceil(log(single precision's max normal))
+// Table is generated with Sollya as follow:
+// > display = hexadecimal;
+// > for i from -104 to 89 do { D(exp(i)); };
+static constexpr double EXP_M1[195] = {
+ 0x1.f1e6b68529e33p-151, 0x1.525be4e4e601dp-149, 0x1.cbe0a45f75eb1p-148,
+ 0x1.3884e838aea68p-146, 0x1.a8c1f14e2af5dp-145, 0x1.20a717e64a9bdp-143,
+ 0x1.8851d84118908p-142, 0x1.0a9bdfb02d240p-140, 0x1.6a5bea046b42ep-139,
+ 0x1.ec7f3b269efa8p-138, 0x1.4eafb87eab0f2p-136, 0x1.c6e2d05bbc000p-135,
+ 0x1.35208867c2683p-133, 0x1.a425b317eeacdp-132, 0x1.1d8508fa8246ap-130,
+ 0x1.840fbc08fdc8ap-129, 0x1.07b7112bc1ffep-127, 0x1.666d0dad2961dp-126,
+ 0x1.e726c3f64d0fep-125, 0x1.4b0dc07cabf98p-123, 0x1.c1f2daf3b6a46p-122,
+ 0x1.31c5957a47de2p-120, 0x1.9f96445648b9fp-119, 0x1.1a6baeadb4fd1p-117,
+ 0x1.7fd974d372e45p-116, 0x1.04da4d1452919p-114, 0x1.62891f06b3450p-113,
+ 0x1.e1dd273aa8a4ap-112, 0x1.4775e0840bfddp-110, 0x1.bd109d9d94bdap-109,
+ 0x1.2e73f53fba844p-107, 0x1.9b138170d6bfep-106, 0x1.175af0cf60ec5p-104,
+ 0x1.7baee1bffa80bp-103, 0x1.02057d1245cebp-101, 0x1.5eafffb34ba31p-100,
+ 0x1.dca23bae16424p-99, 0x1.43e7fc88b8056p-97, 0x1.b83bf23a9a9ebp-96,
+ 0x1.2b2b8dd05b318p-94, 0x1.969d47321e4ccp-93, 0x1.1452b7723aed2p-91,
+ 0x1.778fe2497184cp-90, 0x1.fe7116182e9ccp-89, 0x1.5ae191a99585ap-87,
+ 0x1.d775d87da854dp-86, 0x1.4063f8cc8bb98p-84, 0x1.b374b315f87c1p-83,
+ 0x1.27ec458c65e3cp-81, 0x1.923372c67a074p-80, 0x1.1152eaeb73c08p-78,
+ 0x1.737c5645114b5p-77, 0x1.f8e6c24b5592ep-76, 0x1.571db733a9d61p-74,
+ 0x1.d257d547e083fp-73, 0x1.3ce9b9de78f85p-71, 0x1.aebabae3a41b5p-70,
+ 0x1.24b6031b49bdap-68, 0x1.8dd5e1bb09d7ep-67, 0x1.0e5b73d1ff53dp-65,
+ 0x1.6f741de1748ecp-64, 0x1.f36bd37f42f3ep-63, 0x1.536452ee2f75cp-61,
+ 0x1.cd480a1b74820p-60, 0x1.39792499b1a24p-58, 0x1.aa0de4bf35b38p-57,
+ 0x1.2188ad6ae3303p-55, 0x1.898471fca6055p-54, 0x1.0b6c3afdde064p-52,
+ 0x1.6b7719a59f0e0p-51, 0x1.ee001eed62aa0p-50, 0x1.4fb547c775da8p-48,
+ 0x1.c8464f7616468p-47, 0x1.36121e24d3bbap-45, 0x1.a56e0c2ac7f75p-44,
+ 0x1.1e642baeb84a0p-42, 0x1.853f01d6d53bap-41, 0x1.0885298767e9ap-39,
+ 0x1.67852a7007e42p-38, 0x1.e8a37a45fc32ep-37, 0x1.4c1078fe9228ap-35,
+ 0x1.c3527e433fab1p-34, 0x1.32b48bf117da2p-32, 0x1.a0db0d0ddb3ecp-31,
+ 0x1.1b48655f37267p-29, 0x1.81056ff2c5772p-28, 0x1.05a628c699fa1p-26,
+ 0x1.639e3175a689dp-25, 0x1.e355bbaee85cbp-24, 0x1.4875ca227ec38p-22,
+ 0x1.be6c6fdb01612p-21, 0x1.2f6053b981d98p-19, 0x1.9c54c3b43bc8bp-18,
+ 0x1.18354238f6764p-16, 0x1.7cd79b5647c9bp-15, 0x1.02cf22526545ap-13,
+ 0x1.5fc21041027adp-12, 0x1.de16b9c24a98fp-11, 0x1.44e51f113d4d6p-9,
+ 0x1.b993fe00d5376p-8, 0x1.2c155b8213cf4p-6, 0x1.97db0ccceb0afp-5,
+ 0x1.152aaa3bf81ccp-3, 0x1.78b56362cef38p-2, 0x1.0000000000000p+0,
+ 0x1.5bf0a8b145769p+1, 0x1.d8e64b8d4ddaep+2, 0x1.415e5bf6fb106p+4,
+ 0x1.b4c902e273a58p+5, 0x1.28d389970338fp+7, 0x1.936dc5690c08fp+8,
+ 0x1.122885aaeddaap+10, 0x1.749ea7d470c6ep+11, 0x1.fa7157c470f82p+12,
+ 0x1.5829dcf950560p+14, 0x1.d3c4488ee4f7fp+15, 0x1.3de1654d37c9ap+17,
+ 0x1.b00b5916ac955p+18, 0x1.259ac48bf05d7p+20, 0x1.8f0ccafad2a87p+21,
+ 0x1.0f2ebd0a80020p+23, 0x1.709348c0ea4f9p+24, 0x1.f4f22091940bdp+25,
+ 0x1.546d8f9ed26e1p+27, 0x1.ceb088b68e804p+28, 0x1.3a6e1fd9eecfdp+30,
+ 0x1.ab5adb9c43600p+31, 0x1.226af33b1fdc1p+33, 0x1.8ab7fb5475fb7p+34,
+ 0x1.0c3d3920962c9p+36, 0x1.6c932696a6b5dp+37, 0x1.ef822f7f6731dp+38,
+ 0x1.50bba3796379ap+40, 0x1.c9aae4631c056p+41, 0x1.370470aec28edp+43,
+ 0x1.a6b765d8cdf6dp+44, 0x1.1f43fcc4b662cp+46, 0x1.866f34a725782p+47,
+ 0x1.0953e2f3a1ef7p+49, 0x1.689e221bc8d5bp+50, 0x1.ea215a1d20d76p+51,
+ 0x1.4d13fbb1a001ap+53, 0x1.c4b334617cc67p+54, 0x1.33a43d282a519p+56,
+ 0x1.a220d397972ebp+57, 0x1.1c25c88df6862p+59, 0x1.8232558201159p+60,
+ 0x1.0672a3c9eb871p+62, 0x1.64b41c6d37832p+63, 0x1.e4cf766fe49bep+64,
+ 0x1.49767bc0483e3p+66, 0x1.bfc951eb8bb76p+67, 0x1.304d6aeca254bp+69,
+ 0x1.9d97010884251p+70, 0x1.19103e4080b45p+72, 0x1.7e013cd114461p+73,
+ 0x1.03996528e074cp+75, 0x1.60d4f6fdac731p+76, 0x1.df8c5af17ba3bp+77,
+ 0x1.45e3076d61699p+79, 0x1.baed16a6e0da7p+80, 0x1.2cffdfebde1a1p+82,
+ 0x1.9919cabefcb69p+83, 0x1.160345c9953e3p+85, 0x1.79dbc9dc53c66p+86,
+ 0x1.00c810d464097p+88, 0x1.5d009394c5c27p+89, 0x1.da57de8f107a8p+90,
+ 0x1.425982cf597cdp+92, 0x1.b61e5ca3a5e31p+93, 0x1.29bb825dfcf87p+95,
+ 0x1.94a90db0d6fe2p+96, 0x1.12fec759586fdp+98, 0x1.75c1dc469e3afp+99,
+ 0x1.fbfd219c43b04p+100, 0x1.5936d44e1a146p+102, 0x1.d531d8a7ee79cp+103,
+ 0x1.3ed9d24a2d51bp+105, 0x1.b15cfe5b6e17bp+106, 0x1.268038c2c0e00p+108,
+ 0x1.9044a73545d48p+109, 0x1.1002ab6218b38p+111, 0x1.71b3540cbf921p+112,
+ 0x1.f6799ea9c414ap+113, 0x1.55779b984f3ebp+115, 0x1.d01a210c44aa4p+116,
+ 0x1.3b63da8e91210p+118, 0x1.aca8d6b0116b8p+119, 0x1.234de9e0c74e9p+121,
+ 0x1.8bec7503ca477p+122, 0x1.0d0eda9796b90p+124, 0x1.6db0118477245p+125,
+ 0x1.f1056dc7bf22dp+126, 0x1.51c2cc3433801p+128, 0x1.cb108ffbec164p+129,
+};
+
+// Lookup table for exp(m * 2^(-7)) with m = 0, ..., 127.
+// Table is generated with Sollya as follow:
+// > display = hexadecimal;
+// > for i from 0 to 127 do { D(exp(i / 128)); };
+static constexpr double EXP_M2[128] = {
+ 0x1.0000000000000p0, 0x1.0202015600446p0, 0x1.04080ab55de39p0,
+ 0x1.06122436410ddp0, 0x1.08205601127edp0, 0x1.0a32a84e9c1f6p0,
+ 0x1.0c49236829e8cp0, 0x1.0e63cfa7ab09dp0, 0x1.1082b577d34edp0,
+ 0x1.12a5dd543ccc5p0, 0x1.14cd4fc989cd6p0, 0x1.16f9157587069p0,
+ 0x1.192937074e0cdp0, 0x1.1b5dbd3f68122p0, 0x1.1d96b0eff0e79p0,
+ 0x1.1fd41afcba45ep0, 0x1.2216045b6f5cdp0, 0x1.245c7613b8a9bp0,
+ 0x1.26a7793f60164p0, 0x1.28f7170a755fdp0, 0x1.2b4b58b372c79p0,
+ 0x1.2da4478b620c7p0, 0x1.3001ecf601af7p0, 0x1.32645269ea829p0,
+ 0x1.34cb8170b5835p0, 0x1.373783a722012p0, 0x1.39a862bd3c106p0,
+ 0x1.3c1e2876834aap0, 0x1.3e98deaa11dccp0, 0x1.41188f42c3e32p0,
+ 0x1.439d443f5f159p0, 0x1.462707b2bac21p0, 0x1.48b5e3c3e8186p0,
+ 0x1.4b49e2ae5ac67p0, 0x1.4de30ec211e60p0, 0x1.50817263c13cdp0,
+ 0x1.5325180cfacf7p0, 0x1.55ce0a4c58c7cp0, 0x1.587c53c5a7af0p0,
+ 0x1.5b2fff3210fd9p0, 0x1.5de9176045ff5p0, 0x1.60a7a734ab0e8p0,
+ 0x1.636bb9a983258p0, 0x1.663559cf1bc7cp0, 0x1.690492cbf9433p0,
+ 0x1.6bd96fdd034a2p0, 0x1.6eb3fc55b1e76p0, 0x1.719443a03acb9p0,
+ 0x1.747a513dbef6ap0, 0x1.776630c678bc1p0, 0x1.7a57ede9ea23ep0,
+ 0x1.7d4f946f0ba8dp0, 0x1.804d30347b546p0, 0x1.8350cd30ac390p0,
+ 0x1.865a7772164c5p0, 0x1.896a3b1f66a0ep0, 0x1.8c802477b0010p0,
+ 0x1.8f9c3fd29beafp0, 0x1.92be99a09bf00p0, 0x1.95e73e6b1b75ep0,
+ 0x1.99163ad4b1dccp0, 0x1.9c4b9b995509bp0, 0x1.9f876d8e8c566p0,
+ 0x1.a2c9bda3a3e78p0, 0x1.a61298e1e069cp0, 0x1.a9620c6cb3374p0,
+ 0x1.acb82581eee54p0, 0x1.b014f179fc3b8p0, 0x1.b3787dc80f95fp0,
+ 0x1.b6e2d7fa5eb18p0, 0x1.ba540dba56e56p0, 0x1.bdcc2cccd3c85p0,
+ 0x1.c14b431256446p0, 0x1.c4d15e873c193p0, 0x1.c85e8d43f7cd0p0,
+ 0x1.cbf2dd7d490f2p0, 0x1.cf8e5d84758a9p0, 0x1.d3311bc7822b4p0,
+ 0x1.d6db26d16cd67p0, 0x1.da8c8d4a66969p0, 0x1.de455df80e3c0p0,
+ 0x1.e205a7bdab73ep0, 0x1.e5cd799c6a54ep0, 0x1.e99ce2b397649p0,
+ 0x1.ed73f240dc142p0, 0x1.f152b7a07bb76p0, 0x1.f539424d90f5ep0,
+ 0x1.f927a1e24bb76p0, 0x1.fd1de6182f8c9p0, 0x1.008e0f64294abp1,
+ 0x1.02912df5ce72ap1, 0x1.049856cd84339p1, 0x1.06a39207f0a09p1,
+ 0x1.08b2e7d2035cfp1, 0x1.0ac6606916501p1, 0x1.0cde041b0e9aep1,
+ 0x1.0ef9db467dcf8p1, 0x1.1119ee5ac36b6p1, 0x1.133e45d82e952p1,
+ 0x1.1566ea50201d7p1, 0x1.1793e4652cc50p1, 0x1.19c53ccb3fc6bp1,
+ 0x1.1bfafc47bda73p1, 0x1.1e352bb1a74adp1, 0x1.2073d3f1bd518p1,
+ 0x1.22b6fe02a3b9cp1, 0x1.24feb2f105cb8p1, 0x1.274afbdbba4a6p1,
+ 0x1.299be1f3e7f1cp1, 0x1.2bf16e7d2a38cp1, 0x1.2e4baacdb6614p1,
+ 0x1.30aaa04e80d05p1, 0x1.330e587b62b28p1, 0x1.3576dce33feadp1,
+ 0x1.37e437282d4eep1, 0x1.3a5670ff972edp1, 0x1.3ccd9432682b4p1,
+ 0x1.3f49aa9d30590p1, 0x1.41cabe304cb34p1, 0x1.4450d8f00edd4p1,
+ 0x1.46dc04f4e5338p1, 0x1.496c4c6b832dap1, 0x1.4c01b9950a111p1,
+ 0x1.4e9c56c731f5dp1, 0x1.513c2e6c731d7p1, 0x1.53e14b042f9cap1,
+ 0x1.568bb722dd593p1, 0x1.593b7d72305bbp1,
+};
+
+} // namespace math
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_EXP_FLOAT_CONSTANTS_H
diff --git a/libc/src/__support/math/expf.h b/libc/src/__support/math/expf.h
new file mode 100644
index 0000000000000..88c151492a041
--- /dev/null
+++ b/libc/src/__support/math/expf.h
@@ -0,0 +1,116 @@
+//===-- Implementation header for expf --------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_EXPF_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_EXPF_H
+
+#include "exp_float_constants.h" // Lookup tables EXP_M1 and EXP_M2.
+#include "src/__support/FPUtil/FEnvImpl.h"
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/FPUtil/PolyEval.h"
+#include "src/__support/FPUtil/multiply_add.h"
+#include "src/__support/FPUtil/nearest_integer.h"
+#include "src/__support/FPUtil/rounding_mode.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+static constexpr float expf(float x) {
+ using FPBits = typename fputil::FPBits<float>;
+ FPBits xbits(x);
+
+ uint32_t x_u = xbits.uintval();
+ uint32_t x_abs = x_u & 0x7fff'ffffU;
+
+#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+ // Exceptional values
+ if (LIBC_UNLIKELY(x_u == 0xc236'bd8cU)) { // x = -0x1.6d7b18p+5f
+ return 0x1.108a58p-66f - x * 0x1.0p-95f;
+ }
+#endif // !LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+
+ // When |x| >= 89, |x| < 2^-25, or x is nan
+ if (LIBC_UNLIKELY(x_abs >= 0x42b2'0000U || x_abs <= 0x3280'0000U)) {
+ // |x| < 2^-25
+ if (xbits.get_biased_exponent() <= 101) {
+ return 1.0f + x;
+ }
+
+ // When x < log(2^-150) or nan
+ if (xbits.uintval() >= 0xc2cf'f1b5U) {
+ // exp(-Inf) = 0
+ if (xbits.is_inf())
+ return 0.0f;
+ // exp(nan) = nan
+ if (xbits.is_nan())
+ return x;
+ if (fputil::fenv_is_round_up())
+ return FPBits::min_subnormal().get_val();
+ fputil::set_errno_if_required(ERANGE);
+ fputil::raise_except_if_required(FE_UNDERFLOW);
+ return 0.0f;
+ }
+ // x >= 89 or nan
+ if (xbits.is_pos() && (xbits.uintval() >= 0x42b2'0000)) {
+ // x is finite
+ if (xbits.uintval() < 0x7f80'0000U) {
+ int rounding = fputil::quick_get_round();
+ if (rounding == FE_DOWNWARD || rounding == FE_TOWARDZERO)
+ return FPBits::max_normal().get_val();
+
+ fputil::set_errno_if_required(ERANGE);
+ fputil::raise_except_if_required(FE_OVERFLOW);
+ }
+ // x is +inf or nan
+ return x + FPBits::inf().get_val();
+ }
+ }
+ // For -104 < x < 89, to compute exp(x), we perform the following range
+ // reduction: find hi, mid, lo such that:
+ // x = hi + mid + lo, in which
+ // hi is an integer,
+ // mid * 2^7 is an integer
+ // -2^(-8) <= lo < 2^-8.
+ // In particular,
+ // hi + mid = round(x * 2^7) * 2^(-7).
+ // Then,
+ // exp(x) = exp(hi + mid + lo) = exp(hi) * exp(mid) * exp(lo).
+ // We store exp(hi) and exp(mid) in the lookup tables EXP_M1 and EXP_M2
+ // respectively. exp(lo) is computed using a degree-4 minimax polynomial
+ // generated by Sollya.
+
+ // x_hi = (hi + mid) * 2^7 = round(x * 2^7).
+ float kf = fputil::nearest_integer(x * 0x1.0p7f);
+ // Subtract (hi + mid) from x to get lo.
+ double xd = static_cast<double>(fputil::multiply_add(kf, -0x1.0p-7f, x));
+ int x_hi = static_cast<int>(kf);
+ x_hi += 104 << 7;
+ // hi = x_hi >> 7
+ double exp_hi = EXP_M1[x_hi >> 7];
+ // mid * 2^7 = x_hi & 0x0000'007fU;
+ double exp_mid = EXP_M2[x_hi & 0x7f];
+ // Degree-4 minimax polynomial generated by Sollya with the following
+ // commands:
+ // > display = hexadecimal;
+ // > Q = fpminimax(expm1(x)/x, 3, [|D...|], [-2^-8, 2^-8]);
+ // > Q;
+ double exp_lo =
+ fputil::polyeval(xd, 0x1p0, 0x1.ffffffffff777p-1, 0x1.000000000071cp-1,
+ 0x1.555566668e5e7p-3, 0x1.55555555ef243p-5);
+ return static_cast<float>(exp_hi * exp_mid * exp_lo);
+}
+
+} // namespace math
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_EXPF_H
diff --git a/libc/src/math/generic/expf.cpp b/libc/src/math/generic/expf.cpp
index fa507d4d9322c..de11f51ac64a0 100644
--- a/libc/src/math/generic/expf.cpp
+++ b/libc/src/math/generic/expf.cpp
@@ -7,103 +7,10 @@
//===----------------------------------------------------------------------===//
#include "src/math/expf.h"
-#include "common_constants.h" // Lookup tables EXP_M1 and EXP_M2.
-#include "src/__support/FPUtil/BasicOperations.h"
-#include "src/__support/FPUtil/FEnvImpl.h"
-#include "src/__support/FPUtil/FPBits.h"
-#include "src/__support/FPUtil/PolyEval.h"
-#include "src/__support/FPUtil/multiply_add.h"
-#include "src/__support/FPUtil/nearest_integer.h"
-#include "src/__support/FPUtil/rounding_mode.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
+#include "src/__support/math/expf.h"
namespace LIBC_NAMESPACE_DECL {
-LLVM_LIBC_FUNCTION(float, expf, (float x)) {
- using FPBits = typename fputil::FPBits<float>;
- FPBits xbits(x);
-
- uint32_t x_u = xbits.uintval();
- uint32_t x_abs = x_u & 0x7fff'ffffU;
-
-#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
- // Exceptional values
- if (LIBC_UNLIKELY(x_u == 0xc236'bd8cU)) { // x = -0x1.6d7b18p+5f
- return 0x1.108a58p-66f - x * 0x1.0p-95f;
- }
-#endif // !LIBC_MATH_HAS_SKIP_ACCURATE_PASS
-
- // When |x| >= 89, |x| < 2^-25, or x is nan
- if (LIBC_UNLIKELY(x_abs >= 0x42b2'0000U || x_abs <= 0x3280'0000U)) {
- // |x| < 2^-25
- if (xbits.get_biased_exponent() <= 101) {
- return 1.0f + x;
- }
-
- // When x < log(2^-150) or nan
- if (xbits.uintval() >= 0xc2cf'f1b5U) {
- // exp(-Inf) = 0
- if (xbits.is_inf())
- return 0.0f;
- // exp(nan) = nan
- if (xbits.is_nan())
- return x;
- if (fputil::fenv_is_round_up())
- return FPBits::min_subnormal().get_val();
- fputil::set_errno_if_required(ERANGE);
- fputil::raise_except_if_required(FE_UNDERFLOW);
- return 0.0f;
- }
- // x >= 89 or nan
- if (xbits.is_pos() && (xbits.uintval() >= 0x42b2'0000)) {
- // x is finite
- if (xbits.uintval() < 0x7f80'0000U) {
- int rounding = fputil::quick_get_round();
- if (rounding == FE_DOWNWARD || rounding == FE_TOWARDZERO)
- return FPBits::max_normal().get_val();
-
- fputil::set_errno_if_required(ERANGE);
- fputil::raise_except_if_required(FE_OVERFLOW);
- }
- // x is +inf or nan
- return x + FPBits::inf().get_val();
- }
- }
- // For -104 < x < 89, to compute exp(x), we perform the following range
- // reduction: find hi, mid, lo such that:
- // x = hi + mid + lo, in which
- // hi is an integer,
- // mid * 2^7 is an integer
- // -2^(-8) <= lo < 2^-8.
- // In particular,
- // hi + mid = round(x * 2^7) * 2^(-7).
- // Then,
- // exp(x) = exp(hi + mid + lo) = exp(hi) * exp(mid) * exp(lo).
- // We store exp(hi) and exp(mid) in the lookup tables EXP_M1 and EXP_M2
- // respectively. exp(lo) is computed using a degree-4 minimax polynomial
- // generated by Sollya.
-
- // x_hi = (hi + mid) * 2^7 = round(x * 2^7).
- float kf = fputil::nearest_integer(x * 0x1.0p7f);
- // Subtract (hi + mid) from x to get lo.
- double xd = static_cast<double>(fputil::multiply_add(kf, -0x1.0p-7f, x));
- int x_hi = static_cast<int>(kf);
- x_hi += 104 << 7;
- // hi = x_hi >> 7
- double exp_hi = EXP_M1[x_hi >> 7];
- // mid * 2^7 = x_hi & 0x0000'007fU;
- double exp_mid = EXP_M2[x_hi & 0x7f];
- // Degree-4 minimax polynomial generated by Sollya with the following
- // commands:
- // > display = hexadecimal;
- // > Q = fpminimax(expm1(x)/x, 3, [|D...|], [-2^-8, 2^-8]);
- // > Q;
- double exp_lo =
- fputil::polyeval(xd, 0x1p0, 0x1.ffffffffff777p-1, 0x1.000000000071cp-1,
- 0x1.555566668e5e7p-3, 0x1.55555555ef243p-5);
- return static_cast<float>(exp_hi * exp_mid * exp_lo);
-}
+LLVM_LIBC_FUNCTION(float, expf, (float x)) { return math::expf(x); }
} // namespace LIBC_NAMESPACE_DECL
>From 0e09901400cc59941f37eae32430271a4a8561a4 Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue.h at gmail.com>
Date: Wed, 21 May 2025 03:31:08 +0000
Subject: [PATCH 3/4] [APFloat] Add exp function for APFloat::IEEEsingle using
expf implementation from LLVM libc.
---
llvm/CMakeLists.txt | 10 ++++++++++
llvm/include/llvm/ADT/APFloat.h | 3 +++
llvm/include/llvm/Config/llvm-config.h.cmake | 3 +++
llvm/lib/Support/APFloat.cpp | 15 +++++++++++++++
llvm/lib/Support/CMakeLists.txt | 10 ++++++++++
llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp | 2 +-
llvm/unittests/ADT/APFloatTest.cpp | 7 +++++++
7 files changed, 49 insertions(+), 1 deletion(-)
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index ed44b16bf9aeb..4f6c1cd82da14 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -633,6 +633,16 @@ endif()
set(LLVM_ENABLE_Z3_SOLVER_DEFAULT "${Z3_FOUND}")
+set(LLVM_INTEGRATE_LIBC "OFF" CACHE STRING "Use LLVM libc codes directly if available.")
+
+if(LLVM_INTEGRATE_LIBC)
+ message(STATUS "LLVM_INTEGRATE_LIBC is ${LLVM_INTEGRATE_LIBC}")
+ include(FindLibcCommonUtils)
+ if(NOT TARGET llvm-libc-common-utilities)
+ message(STATUS "LLVM_INTEGRATE_LIBC is set but cannot find LLVM libc at ${libc_path}.")
+ set(LLVM_INTEGRATE_LIBC OFF)
+ endif()
+endif()
if( LLVM_TARGETS_TO_BUILD STREQUAL "all" )
set( LLVM_TARGETS_TO_BUILD ${LLVM_ALL_TARGETS} )
diff --git a/llvm/include/llvm/ADT/APFloat.h b/llvm/include/llvm/ADT/APFloat.h
index 13df838da3dad..23c30de1effda 100644
--- a/llvm/include/llvm/ADT/APFloat.h
+++ b/llvm/include/llvm/ADT/APFloat.h
@@ -1522,6 +1522,7 @@ class APFloat : public APFloatBase {
friend int ilogb(const APFloat &Arg) { return ilogb(Arg.getIEEE()); }
friend APFloat scalbn(APFloat X, int Exp, roundingMode RM);
friend APFloat frexp(const APFloat &X, int &Exp, roundingMode RM);
+ friend APFloat exp(const APFloat &X);
friend IEEEFloat;
friend DoubleAPFloat;
};
@@ -1565,6 +1566,8 @@ inline APFloat neg(APFloat X) {
return X;
}
+APFloat exp(const APFloat &X);
+
/// Implements IEEE-754 2008 minNum semantics. Returns the smaller of the
/// 2 arguments if both are not NaN. If either argument is a qNaN, returns the
/// other argument. If either argument is sNaN, return a qNaN.
diff --git a/llvm/include/llvm/Config/llvm-config.h.cmake b/llvm/include/llvm/Config/llvm-config.h.cmake
index dbc882937b4f4..e289ae70e9eb5 100644
--- a/llvm/include/llvm/Config/llvm-config.h.cmake
+++ b/llvm/include/llvm/Config/llvm-config.h.cmake
@@ -133,4 +133,7 @@
and to 0 otherwise. */
#cmakedefine01 LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING
+/* Define if LLVM and clang uses LLVM libc for constexpr math computations. */
+#cmakedefine LLVM_INTEGRATE_LIBC
+
#endif
diff --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp
index e99649d26ce88..172c760aed3df 100644
--- a/llvm/lib/Support/APFloat.cpp
+++ b/llvm/lib/Support/APFloat.cpp
@@ -28,6 +28,11 @@
#include <cstring>
#include <limits.h>
+#ifdef LLVM_INTEGRATE_LIBC
+// Headers from LLVM libc
+#include "shared/math.h"
+#endif // LLVM_INTEGRATE_LIBC
+
#define APFLOAT_DISPATCH_ON_SEMANTICS(METHOD_CALL) \
do { \
if (usesLayout<IEEEFloat>(getSemantics())) \
@@ -5598,6 +5603,16 @@ float APFloat::convertToFloat() const {
return Temp.getIEEE().convertToFloat();
}
+APFloat exp(const APFloat &X) {
+#ifdef LLVM_INTEGRATE_LIBC
+ if (&X.getSemantics() == (const llvm::fltSemantics *)&semIEEEsingle) {
+ float result = LIBC_NAMESPACE::shared::expf(X.convertToFloat());
+ return APFloat(result);
+ }
+#endif // LLVM_INTEGRATE_LIBC
+ llvm_unreachable("Unexpected semantics");
+}
+
} // namespace llvm
#undef APFLOAT_DISPATCH_ON_SEMANTICS
diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt
index 45d961e994a1a..717dda9c678ea 100644
--- a/llvm/lib/Support/CMakeLists.txt
+++ b/llvm/lib/Support/CMakeLists.txt
@@ -379,3 +379,13 @@ if(LLVM_WITH_Z3)
${Z3_INCLUDE_DIR}
)
endif()
+
+if(LLVM_INTEGRATE_LIBC)
+ set_property(TARGET LLVMSupport PROPERTY CXX_STANDARD 17)
+ target_compile_definitions(LLVMSupport PRIVATE
+ "LIBC_NAMESPACE=__llvm_libc_common_utils"
+ "LIBC_ERRNO_MODE=LIBC_ERRNO_MODE_SYSTEM"
+ )
+ target_include_directories(LLVMSupport PRIVATE "${LLVM_INCLUDE_DIR}/../../libc")
+ target_compile_options(LLVMSupport PRIVATE "-Wno-c99-extensions") # _Complex warnings.
+endif()
diff --git a/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp b/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp
index b65b4d67b3f8c..75307627c23a1 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp
@@ -1541,7 +1541,7 @@ bool AMDGPULibCalls::evaluateScalarMathFunc(const FuncInfo &FInfo, double &Res0,
return true;
case AMDGPULibFunc::EI_EXP:
- Res0 = exp(opr0);
+ Res0 = std::exp(opr0);
return true;
case AMDGPULibFunc::EI_EXP2:
diff --git a/llvm/unittests/ADT/APFloatTest.cpp b/llvm/unittests/ADT/APFloatTest.cpp
index 7a5fd83cd9581..1575a15b9ce40 100644
--- a/llvm/unittests/ADT/APFloatTest.cpp
+++ b/llvm/unittests/ADT/APFloatTest.cpp
@@ -8356,4 +8356,11 @@ TEST(APFloatTest, hasSignBitInMSB) {
EXPECT_FALSE(APFloat::hasSignBitInMSB(APFloat::Float8E8M0FNU()));
}
+#ifdef LLVM_INTEGRATE_LIBC
+TEST(APFloatTest, expf) {
+ EXPECT_EQ(1.0f, exp(APFloat(0.0f)).convertToFloat());
+ EXPECT_EQ(0x1.5bf0a8p1f, exp(APFloat(1.0f)).convertToFloat());
+}
+#endif // LLVM_INTEGRATE_LIBC
+
} // namespace
>From 81f48d26d2ddb9af6913e8c1a1842da7ea7ecc39 Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue.h at gmail.com>
Date: Wed, 21 May 2025 03:32:00 +0000
Subject: [PATCH 4/4] [clang] Make __builtin_expf constexpr.
---
clang/include/clang/Basic/Builtins.td | 18 ++++++++++++++++--
clang/lib/AST/ByteCode/InterpBuiltin.cpp | 22 ++++++++++++++++++++++
clang/lib/AST/ExprConstant.cpp | 19 +++++++++++++++++++
clang/test/CMakeLists.txt | 1 +
clang/test/Preprocessor/feature_tests.cpp | 10 ++++++++++
clang/test/Sema/constant-builtins-exp.cpp | 12 ++++++++++++
clang/test/lit.cfg.py | 3 +++
clang/test/lit.site.cfg.py.in | 1 +
8 files changed, 84 insertions(+), 2 deletions(-)
create mode 100644 clang/test/Sema/constant-builtins-exp.cpp
diff --git a/clang/include/clang/Basic/Builtins.td b/clang/include/clang/Basic/Builtins.td
index 187d3b5ed24a7..bbb443e249fae 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -161,7 +161,22 @@ def ErfcF128 : Builtin {
let Prototype = "__float128(__float128)";
}
-def ExpF16F128 : Builtin, F16F128MathTemplate {
+def BIExpF : Builtin {
+ let Spellings = ["__builtin_expf"];
+#ifdef LLVM_INTEGRATE_LIBC
+ let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const, Constexpr];
+#else
+ let Attributes = [FunctionWithBuiltinPrefix, NoThrow,
+ ConstIgnoringErrnoAndExceptions];
+#endif // LLVM_INTEGRATE_LIBC
+ let Prototype = "float(float)";
+}
+
+def BIExp
+ : Builtin,
+ Template<["double", "long double", "_Float16", "__float128"], ["", "l",
+ "f16",
+ "f128"]> {
let Spellings = ["__builtin_exp"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
let Prototype = "T(T)";
@@ -3742,7 +3757,6 @@ def Exp : FPMathTemplate, LibBuiltin<"math.h"> {
let Spellings = ["exp"];
let Attributes = [NoThrow, ConstIgnoringErrnoAndExceptions];
let Prototype = "T(T)";
- let AddBuiltinPrefixedAlias = 1;
}
def Exp2 : FPMathTemplate, LibBuiltin<"math.h"> {
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 8edc6248dcbfd..be64d93fb1345 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -18,6 +18,7 @@
#include "clang/Basic/TargetBuiltins.h"
#include "clang/Basic/TargetInfo.h"
#include "llvm/ADT/StringExtras.h"
+#include "llvm/Config/llvm-config.h"
#include "llvm/Support/SipHash.h"
namespace clang {
@@ -419,6 +420,13 @@ static bool interp__builtin_copysign(InterpState &S, CodePtr OpPC,
return true;
}
+static bool interp__builtin_exp(InterpState &S, CodePtr OpPC,
+ const InterpFrame *Frame) {
+ APFloat Result = exp(S.Stk.peek<Floating>().getAPFloat());
+ S.Stk.push<Floating>(Floating(Result));
+ return true;
+}
+
static bool interp__builtin_fmin(InterpState &S, CodePtr OpPC,
const InterpFrame *Frame, bool IsNumBuiltin) {
const Floating &LHS = S.Stk.peek<Floating>(align(primSize(PT_Float)) * 2);
@@ -2315,6 +2323,20 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
return false;
break;
+ case Builtin::BI__builtin_exp:
+ case Builtin::BI__builtin_expl:
+ case Builtin::BI__builtin_expf16:
+ case Builtin::BI__builtin_expf128:
+ return false;
+ case Builtin::BI__builtin_expf:
+#ifdef LLVM_INTEGRATE_LIBC
+ if (!interp__builtin_exp(S, OpPC, Frame))
+ return false;
+ break;
+#else
+ return false;
+#endif // LLVM_INTEGRATE_LIBC
+
case Builtin::BI__builtin_fmin:
case Builtin::BI__builtin_fminf:
case Builtin::BI__builtin_fminl:
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index e9a269337404a..f37e916f67560 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -57,6 +57,7 @@
#include "llvm/ADT/Sequence.h"
#include "llvm/ADT/SmallBitVector.h"
#include "llvm/ADT/StringExtras.h"
+#include "llvm/Config/llvm-config.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/SaveAndRestore.h"
@@ -15711,6 +15712,24 @@ bool FloatExprEvaluator::VisitCallExpr(const CallExpr *E) {
return true;
}
+ // FIXME: allow other __builtin_exp* to be constexpr.
+ case Builtin::BI__builtin_exp:
+ case Builtin::BI__builtin_expl:
+ case Builtin::BI__builtin_expf16:
+ case Builtin::BI__builtin_expf128:
+ return false;
+ case Builtin::BI__builtin_expf: {
+#ifdef LLVM_INTEGRATE_LIBC
+ APFloat Input(0.);
+ if (!EvaluateFloat(E->getArg(0), Input, Info))
+ return false;
+ Result = exp(Input);
+ return true;
+#else
+ return false;
+#endif // LLVM_INTEGRATE_LIBC
+ }
+
case Builtin::BI__builtin_fmax:
case Builtin::BI__builtin_fmaxf:
case Builtin::BI__builtin_fmaxl:
diff --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index 35a8042ac0e0a..5960601a90e8d 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -27,6 +27,7 @@ llvm_canonicalize_cmake_booleans(
LLVM_TOOL_LLVM_DRIVER_BUILD
LLVM_INCLUDE_SPIRV_TOOLS_TESTS
LLVM_EXPERIMENTAL_KEY_INSTRUCTIONS
+ LLVM_INTEGRATE_LIBC
)
configure_lit_site_cfg(
diff --git a/clang/test/Preprocessor/feature_tests.cpp b/clang/test/Preprocessor/feature_tests.cpp
index 029f446113af4..7fec4fef9835b 100644
--- a/clang/test/Preprocessor/feature_tests.cpp
+++ b/clang/test/Preprocessor/feature_tests.cpp
@@ -64,6 +64,16 @@
#error Clang should have these constexpr builtins
#endif
+#ifdef LLVM_INTEGRATE_LIBC
+#if !__has_constexpr_builtin(__builtin_expf)
+#error Clang should have these constexpr builtins
+#endif
+#else
+#if __has_constexpr_builtin(__builtin_expf)
+#error This builtin should not be constexpr in Clang
+#endif
+#endif // LLVM_INTEGRATE_LIBC
+
#if !__has_constexpr_builtin(__builtin_convertvector)
#error Clang should have these constexpr builtins
#endif
diff --git a/clang/test/Sema/constant-builtins-exp.cpp b/clang/test/Sema/constant-builtins-exp.cpp
new file mode 100644
index 0000000000000..6e9a2a070c192
--- /dev/null
+++ b/clang/test/Sema/constant-builtins-exp.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify -fexperimental-new-constant-interpreter %s
+// REQUIRES: llvm_integrate_libc
+// expected-no-diagnostics
+
+constexpr float Inf = __builtin_inff();
+constexpr float NegInf = -__builtin_inff();
+
+static_assert(Inf == __builtin_expf(Inf));
+static_assert(0.0f == __builtin_expf(NegInf));
+static_assert(1.0f == __builtin_expf(0.0f));
+static_assert(0x1.5bf0a8p1f == __builtin_expf(1.0f));
diff --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index 2b35bb5dcbdaf..a57e33ae70802 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -385,3 +385,6 @@ def calculate_arch_features(arch_string):
# possibly be present in system and user configuration files, so disable
# default configs for the test runs.
config.environment["CLANG_NO_DEFAULT_CONFIG"] = "1"
+
+if config.llvm_integrate_libc:
+ config.available_features.add("llvm_integrate_libc")
diff --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in
index 77c5f27f47c92..294d1b077ddf2 100644
--- a/clang/test/lit.site.cfg.py.in
+++ b/clang/test/lit.site.cfg.py.in
@@ -49,6 +49,7 @@ config.have_llvm_driver = @LLVM_TOOL_LLVM_DRIVER_BUILD@
config.spirv_tools_tests = @LLVM_INCLUDE_SPIRV_TOOLS_TESTS@
config.substitutions.append(("%llvm-version-major", "@LLVM_VERSION_MAJOR@"))
config.has_key_instructions = @LLVM_EXPERIMENTAL_KEY_INSTRUCTIONS@
+config.llvm_integrate_libc = @LLVM_INTEGRATE_LIBC@
import lit.llvm
lit.llvm.initialize(lit_config, config)
More information about the cfe-commits
mailing list