[libc-commits] [libc] 46944b0 - [libc] remove errno.h includes (#110934)

via libc-commits libc-commits at lists.llvm.org
Sat Oct 5 16:31:39 PDT 2024


Author: Job Henandez Lara
Date: 2024-10-05T19:31:36-04:00
New Revision: 46944b0cbc9a9d8daad0182c40fcd3560bc9ca35

URL: https://github.com/llvm/llvm-project/commit/46944b0cbc9a9d8daad0182c40fcd3560bc9ca35
DIFF: https://github.com/llvm/llvm-project/commit/46944b0cbc9a9d8daad0182c40fcd3560bc9ca35.diff

LOG: [libc] remove errno.h includes (#110934)

Added: 
    

Modified: 
    libc/include/llvm-libc-macros/linux/error-number-macros.h
    libc/src/__support/StringUtil/tables/CMakeLists.txt
    libc/src/__support/StringUtil/tables/linux_extension_errors.h
    libc/src/__support/StringUtil/tables/posix_errors.h
    libc/src/__support/StringUtil/tables/stdc_errors.h
    libc/src/math/generic/CMakeLists.txt
    libc/src/math/generic/acosf.cpp
    libc/src/math/generic/asinf.cpp
    libc/src/math/generic/cosf.cpp
    libc/src/math/generic/exp.cpp
    libc/src/math/generic/exp10.cpp
    libc/src/math/generic/exp10f_impl.h
    libc/src/math/generic/exp2.cpp
    libc/src/math/generic/exp2f_impl.h
    libc/src/math/generic/expf.cpp
    libc/src/math/generic/explogxf.h
    libc/src/math/generic/expm1f.cpp
    libc/src/math/generic/powf.cpp
    libc/src/math/generic/sincosf.cpp
    libc/src/math/generic/sinf.cpp
    libc/src/math/generic/tanf.cpp
    libc/src/pthread/CMakeLists.txt
    libc/src/pthread/pthread_atfork.cpp
    libc/src/pthread/pthread_attr_setdetachstate.cpp
    libc/src/pthread/pthread_attr_setguardsize.cpp
    libc/src/pthread/pthread_attr_setstack.cpp
    libc/src/pthread/pthread_attr_setstacksize.cpp
    libc/src/pthread/pthread_condattr_setclock.cpp
    libc/src/pthread/pthread_condattr_setpshared.cpp
    libc/src/pthread/pthread_create.cpp
    libc/src/pthread/pthread_key_create.cpp
    libc/src/pthread/pthread_key_delete.cpp
    libc/src/pthread/pthread_mutex_init.cpp
    libc/src/pthread/pthread_mutexattr_destroy.cpp
    libc/src/pthread/pthread_mutexattr_getpshared.cpp
    libc/src/pthread/pthread_mutexattr_getrobust.cpp
    libc/src/pthread/pthread_mutexattr_gettype.cpp
    libc/src/pthread/pthread_mutexattr_setpshared.cpp
    libc/src/pthread/pthread_mutexattr_setrobust.cpp
    libc/src/pthread/pthread_mutexattr_settype.cpp
    libc/src/pthread/pthread_rwlock_destroy.cpp
    libc/src/pthread/pthread_rwlock_init.cpp
    libc/src/pthread/pthread_rwlock_rdlock.cpp
    libc/src/pthread/pthread_rwlock_timedrdlock.cpp
    libc/src/pthread/pthread_rwlock_timedwrlock.cpp
    libc/src/pthread/pthread_rwlock_tryrdlock.cpp
    libc/src/pthread/pthread_rwlock_trywrlock.cpp
    libc/src/pthread/pthread_rwlock_unlock.cpp
    libc/src/pthread/pthread_rwlock_wrlock.cpp
    libc/src/pthread/pthread_rwlockattr_setkind_np.cpp
    libc/src/pthread/pthread_rwlockattr_setpshared.cpp
    libc/src/pthread/pthread_setspecific.cpp
    libc/src/spawn/CMakeLists.txt
    libc/src/spawn/posix_spawn_file_actions_addclose.cpp
    libc/src/spawn/posix_spawn_file_actions_adddup2.cpp
    libc/src/spawn/posix_spawn_file_actions_addopen.cpp
    libc/src/spawn/posix_spawn_file_actions_destroy.cpp
    libc/src/threads/CMakeLists.txt
    libc/src/threads/thrd_create.cpp
    libc/test/UnitTest/PrintfMatcher.h
    libc/test/UnitTest/ScanfMatcher.h
    libc/test/integration/src/pthread/CMakeLists.txt
    libc/test/integration/src/pthread/pthread_name_test.cpp
    libc/test/integration/src/spawn/posix_spawn_test_binary.cpp
    libc/test/integration/src/unistd/CMakeLists.txt
    libc/test/integration/src/unistd/fork_test.cpp
    libc/test/integration/src/unistd/stack_smashing_test.cpp
    libc/test/integration/startup/linux/CMakeLists.txt
    libc/test/integration/startup/linux/tls_test.cpp
    libc/test/src/__support/File/CMakeLists.txt
    libc/test/src/math/RoundToIntegerTest.h
    libc/test/src/math/acosf_test.cpp
    libc/test/src/math/acoshf_test.cpp
    libc/test/src/math/asinf_test.cpp
    libc/test/src/math/asinhf_test.cpp
    libc/test/src/math/atanf_test.cpp
    libc/test/src/math/atanhf_test.cpp
    libc/test/src/math/cosf_test.cpp
    libc/test/src/math/coshf_test.cpp
    libc/test/src/math/erff_test.cpp
    libc/test/src/math/exp10_test.cpp
    libc/test/src/math/exp2_test.cpp
    libc/test/src/math/exp_test.cpp
    libc/test/src/math/log10_test.cpp
    libc/test/src/math/log10f_test.cpp
    libc/test/src/math/log1p_test.cpp
    libc/test/src/math/log1pf_test.cpp
    libc/test/src/math/log2_test.cpp
    libc/test/src/math/log_test.cpp
    libc/test/src/math/powf_test.cpp
    libc/test/src/math/sincosf_test.cpp
    libc/test/src/math/sinf_test.cpp
    libc/test/src/math/sinhf_test.cpp
    libc/test/src/math/smoke/RoundToIntegerTest.h
    libc/test/src/math/smoke/acosf_test.cpp
    libc/test/src/math/smoke/acoshf_test.cpp
    libc/test/src/math/smoke/asinf_test.cpp
    libc/test/src/math/smoke/asinhf_test.cpp
    libc/test/src/math/smoke/atanf_test.cpp
    libc/test/src/math/smoke/atanhf_test.cpp
    libc/test/src/math/smoke/cosf_test.cpp
    libc/test/src/math/smoke/coshf_test.cpp
    libc/test/src/math/smoke/erff_test.cpp
    libc/test/src/math/smoke/exp10_test.cpp
    libc/test/src/math/smoke/exp2_test.cpp
    libc/test/src/math/smoke/exp_test.cpp
    libc/test/src/math/smoke/expm1_test.cpp
    libc/test/src/math/smoke/log10_test.cpp
    libc/test/src/math/smoke/log10f_test.cpp
    libc/test/src/math/smoke/log1p_test.cpp
    libc/test/src/math/smoke/log1pf_test.cpp
    libc/test/src/math/smoke/log2_test.cpp
    libc/test/src/math/smoke/log_test.cpp
    libc/test/src/math/smoke/powf_test.cpp
    libc/test/src/math/smoke/sincosf_test.cpp
    libc/test/src/math/smoke/sinf_test.cpp
    libc/test/src/math/smoke/sinhf_test.cpp
    libc/test/src/math/smoke/tanf_test.cpp
    libc/test/src/math/smoke/tanhf_test.cpp
    libc/test/src/math/tanf_test.cpp
    libc/test/src/math/tanhf_test.cpp
    libc/test/src/pthread/CMakeLists.txt
    libc/test/src/pthread/pthread_attr_test.cpp
    libc/test/src/pthread/pthread_mutexattr_test.cpp
    libc/test/src/signal/CMakeLists.txt
    libc/test/src/signal/sigaddset_test.cpp
    libc/test/src/signal/sigdelset_test.cpp
    libc/test/src/signal/sigfillset_test.cpp
    libc/test/src/spawn/CMakeLists.txt
    libc/test/src/spawn/posix_spawn_file_actions_test.cpp
    libc/test/src/sys/prctl/linux/CMakeLists.txt
    libc/test/src/sys/prctl/linux/prctl_test.cpp
    libc/test/src/sys/resource/CMakeLists.txt
    libc/test/src/sys/select/CMakeLists.txt
    libc/test/src/sys/select/select_failure_test.cpp
    libc/test/src/sys/sendfile/CMakeLists.txt
    libc/test/src/sys/utsname/CMakeLists.txt
    libc/test/src/sys/utsname/uname_test.cpp
    libc/test/src/sys/wait/CMakeLists.txt
    libc/test/src/sys/wait/wait4_test.cpp
    libc/test/src/sys/wait/waitpid_test.cpp
    libc/test/src/unistd/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/libc/include/llvm-libc-macros/linux/error-number-macros.h b/libc/include/llvm-libc-macros/linux/error-number-macros.h
index 1643a70918da49..9a7304fa161ad0 100644
--- a/libc/include/llvm-libc-macros/linux/error-number-macros.h
+++ b/libc/include/llvm-libc-macros/linux/error-number-macros.h
@@ -21,4 +21,12 @@
 #define EHWPOISON 133
 #endif // EHWPOISON
 
+#ifndef EOPNOTSUPP
+#define EOPNOTSUPP 95
+#endif
+
+#ifndef ENOTSUP
+#define ENOTSUP EOPNOTSUPP
+#endif
+
 #endif // LLVM_LIBC_MACROS_LINUX_ERROR_NUMBER_MACROS_H

diff  --git a/libc/src/__support/StringUtil/tables/CMakeLists.txt b/libc/src/__support/StringUtil/tables/CMakeLists.txt
index b7bb33ee0a0fe2..ad4007f494749e 100644
--- a/libc/src/__support/StringUtil/tables/CMakeLists.txt
+++ b/libc/src/__support/StringUtil/tables/CMakeLists.txt
@@ -3,7 +3,7 @@ add_header_library(
   HDRS
     stdc_errors.h
   DEPENDS
-    libc.include.errno
+    libc.src.errno.errno
     libc.src.__support.StringUtil.message_mapper
 )
 
@@ -12,7 +12,7 @@ add_header_library(
   HDRS
     posix_errors.h
   DEPENDS
-    libc.include.errno
+    libc.src.errno.errno
     libc.src.__support.StringUtil.message_mapper
 )
 
@@ -21,8 +21,8 @@ add_header_library(
   HDRS
     linux_extension_errors.h
   DEPENDS
-    libc.include.errno
     libc.src.__support.StringUtil.message_mapper
+    libc.src.errno.errno
 )
 
 add_header_library(

diff  --git a/libc/src/__support/StringUtil/tables/linux_extension_errors.h b/libc/src/__support/StringUtil/tables/linux_extension_errors.h
index f6e8dea154d3be..425590f6e91c9b 100644
--- a/libc/src/__support/StringUtil/tables/linux_extension_errors.h
+++ b/libc/src/__support/StringUtil/tables/linux_extension_errors.h
@@ -11,8 +11,7 @@
 
 #include "src/__support/StringUtil/message_mapper.h"
 #include "src/__support/macros/config.h"
-
-#include <errno.h> // For error macros
+#include "src/errno/libc_errno.h"
 
 namespace LIBC_NAMESPACE_DECL {
 

diff  --git a/libc/src/__support/StringUtil/tables/posix_errors.h b/libc/src/__support/StringUtil/tables/posix_errors.h
index 5294f85eb8d24e..b21f28f0b1321c 100644
--- a/libc/src/__support/StringUtil/tables/posix_errors.h
+++ b/libc/src/__support/StringUtil/tables/posix_errors.h
@@ -9,11 +9,10 @@
 #ifndef LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_TABLES_POSIX_ERRORS_H
 #define LLVM_LIBC_SRC___SUPPORT_STRINGUTIL_TABLES_POSIX_ERRORS_H
 
+#include "hdr/errno_macros.h"
 #include "src/__support/StringUtil/message_mapper.h"
 #include "src/__support/macros/config.h"
 
-#include <errno.h> // For error macros
-
 namespace LIBC_NAMESPACE_DECL {
 
 LIBC_INLINE_VAR constexpr MsgTable<76> POSIX_ERRORS = {

diff  --git a/libc/src/__support/StringUtil/tables/stdc_errors.h b/libc/src/__support/StringUtil/tables/stdc_errors.h
index 1f0beef82001cd..b2a0d36a53637c 100644
--- a/libc/src/__support/StringUtil/tables/stdc_errors.h
+++ b/libc/src/__support/StringUtil/tables/stdc_errors.h
@@ -12,8 +12,6 @@
 #include "src/__support/StringUtil/message_mapper.h"
 #include "src/__support/macros/config.h"
 
-#include <errno.h> // For error macros
-
 namespace LIBC_NAMESPACE_DECL {
 
 LIBC_INLINE_VAR constexpr const MsgTable<4> STDC_ERRORS = {

diff  --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 93e632c38af238..627168ee136997 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -1372,7 +1372,6 @@ add_entrypoint_object(
   DEPENDS
     .common_constants
     .explogxf
-    libc.include.errno
     libc.src.__support.CPP.bit
     libc.src.__support.CPP.optional
     libc.src.__support.FPUtil.dyadic_float
@@ -1406,7 +1405,6 @@ add_entrypoint_object(
     libc.src.__support.FPUtil.polyeval
     libc.src.__support.FPUtil.rounding_mode
     libc.src.__support.macros.optimization
-    libc.include.errno
     libc.src.errno.errno
   COMPILE_OPTIONS
     -O3
@@ -1445,7 +1443,6 @@ add_entrypoint_object(
   DEPENDS
     .common_constants
     .explogxf
-    libc.include.errno
     libc.src.__support.CPP.bit
     libc.src.__support.CPP.optional
     libc.src.__support.FPUtil.dyadic_float
@@ -1478,7 +1475,6 @@ add_header_library(
     libc.src.__support.FPUtil.rounding_mode
     libc.src.__support.macros.optimization
     libc.src.__support.common
-    libc.include.errno
     libc.src.errno.errno
 )
 
@@ -1548,7 +1544,6 @@ add_entrypoint_object(
   DEPENDS
     .common_constants
     .explogxf
-    libc.include.errno
     libc.src.__support.CPP.bit
     libc.src.__support.CPP.optional
     libc.src.__support.FPUtil.dyadic_float
@@ -1580,7 +1575,6 @@ add_header_library(
     libc.src.__support.FPUtil.rounding_mode
     libc.src.__support.macros.optimization
     libc.src.__support.common
-    libc.include.errno
     libc.src.errno.errno
   COMPILE_OPTIONS
     -O3
@@ -1632,7 +1626,6 @@ add_entrypoint_object(
   DEPENDS
     .common_constants
     .explogxf
-    libc.include.errno
     libc.src.__support.CPP.bit
     libc.src.__support.CPP.optional
     libc.src.__support.FPUtil.dyadic_float
@@ -1666,7 +1659,6 @@ add_entrypoint_object(
     libc.src.__support.FPUtil.polyeval
     libc.src.__support.FPUtil.rounding_mode
     libc.src.__support.macros.optimization
-    libc.include.errno
     libc.src.errno.errno
   COMPILE_OPTIONS
     -O3
@@ -1705,7 +1697,6 @@ add_entrypoint_object(
     .exp10f_impl
     .exp2f_impl
     .explogxf
-    libc.include.errno
     libc.src.__support.CPP.bit
     libc.src.__support.CPP.optional
     libc.src.__support.FPUtil.fenv_impl
@@ -4144,7 +4135,6 @@ add_object_library(
     libc.src.__support.FPUtil.nearest_integer
     libc.src.__support.FPUtil.polyeval
     libc.src.__support.common
-    libc.include.errno
     libc.src.errno.errno
   COMPILE_OPTIONS
     -O3

diff  --git a/libc/src/math/generic/acosf.cpp b/libc/src/math/generic/acosf.cpp
index 95d8bc0213cba7..3c097a7871380d 100644
--- a/libc/src/math/generic/acosf.cpp
+++ b/libc/src/math/generic/acosf.cpp
@@ -16,8 +16,6 @@
 #include "src/__support/macros/config.h"
 #include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
 
-#include <errno.h>
-
 #include "inv_trigf_utils.h"
 
 namespace LIBC_NAMESPACE_DECL {

diff  --git a/libc/src/math/generic/asinf.cpp b/libc/src/math/generic/asinf.cpp
index d6acc3a1692bc4..3a89def8f6e0c1 100644
--- a/libc/src/math/generic/asinf.cpp
+++ b/libc/src/math/generic/asinf.cpp
@@ -17,8 +17,6 @@
 #include "src/__support/macros/optimization.h"            // LIBC_UNLIKELY
 #include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA
 
-#include <errno.h>
-
 #include "inv_trigf_utils.h"
 
 namespace LIBC_NAMESPACE_DECL {

diff  --git a/libc/src/math/generic/cosf.cpp b/libc/src/math/generic/cosf.cpp
index 6a59b3763b6e87..972ffa923aedf8 100644
--- a/libc/src/math/generic/cosf.cpp
+++ b/libc/src/math/generic/cosf.cpp
@@ -18,8 +18,6 @@
 #include "src/__support/macros/optimization.h"            // LIBC_UNLIKELY
 #include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA
 
-#include <errno.h>
-
 namespace LIBC_NAMESPACE_DECL {
 
 // Exceptional cases for cosf.

diff  --git a/libc/src/math/generic/exp.cpp b/libc/src/math/generic/exp.cpp
index df0c2eab7155c6..38b683aa011664 100644
--- a/libc/src/math/generic/exp.cpp
+++ b/libc/src/math/generic/exp.cpp
@@ -25,8 +25,6 @@
 #include "src/__support/macros/config.h"
 #include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
 
-#include <errno.h>
-
 namespace LIBC_NAMESPACE_DECL {
 
 using fputil::DoubleDouble;

diff  --git a/libc/src/math/generic/exp10.cpp b/libc/src/math/generic/exp10.cpp
index d01bbd8fc01c32..748c8a22b23688 100644
--- a/libc/src/math/generic/exp10.cpp
+++ b/libc/src/math/generic/exp10.cpp
@@ -25,8 +25,6 @@
 #include "src/__support/macros/config.h"
 #include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
 
-#include <errno.h>
-
 namespace LIBC_NAMESPACE_DECL {
 
 using fputil::DoubleDouble;

diff  --git a/libc/src/math/generic/exp10f_impl.h b/libc/src/math/generic/exp10f_impl.h
index fe2195c6e04739..d741318382e1f2 100644
--- a/libc/src/math/generic/exp10f_impl.h
+++ b/libc/src/math/generic/exp10f_impl.h
@@ -21,8 +21,6 @@
 #include "src/__support/macros/config.h"
 #include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
 
-#include <errno.h>
-
 namespace LIBC_NAMESPACE_DECL {
 namespace generic {
 

diff  --git a/libc/src/math/generic/exp2.cpp b/libc/src/math/generic/exp2.cpp
index fbabb625af51fa..935548b538b94f 100644
--- a/libc/src/math/generic/exp2.cpp
+++ b/libc/src/math/generic/exp2.cpp
@@ -25,8 +25,6 @@
 #include "src/__support/macros/config.h"
 #include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
 
-#include <errno.h>
-
 namespace LIBC_NAMESPACE_DECL {
 
 using fputil::DoubleDouble;

diff  --git a/libc/src/math/generic/exp2f_impl.h b/libc/src/math/generic/exp2f_impl.h
index 3f1c5ee68f081e..ae2d0628c12051 100644
--- a/libc/src/math/generic/exp2f_impl.h
+++ b/libc/src/math/generic/exp2f_impl.h
@@ -21,8 +21,6 @@
 #include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
 #include "src/__support/macros/properties/cpu_features.h"
 
-#include <errno.h>
-
 #include "explogxf.h"
 
 namespace LIBC_NAMESPACE_DECL {

diff  --git a/libc/src/math/generic/expf.cpp b/libc/src/math/generic/expf.cpp
index 1d7c0478eb2250..ee5c2a32b6c6ba 100644
--- a/libc/src/math/generic/expf.cpp
+++ b/libc/src/math/generic/expf.cpp
@@ -19,8 +19,6 @@
 #include "src/__support/macros/config.h"
 #include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
 
-#include <errno.h>
-
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(float, expf, (float x)) {

diff  --git a/libc/src/math/generic/explogxf.h b/libc/src/math/generic/explogxf.h
index 7daed558f74b1e..f3f50c21aacce7 100644
--- a/libc/src/math/generic/explogxf.h
+++ b/libc/src/math/generic/explogxf.h
@@ -20,8 +20,6 @@
 #include "src/__support/macros/config.h"
 #include "src/__support/macros/properties/cpu_features.h"
 
-#include <errno.h>
-
 namespace LIBC_NAMESPACE_DECL {
 
 struct ExpBase {

diff  --git a/libc/src/math/generic/expm1f.cpp b/libc/src/math/generic/expm1f.cpp
index b1a0fe16de0771..d5e9e85ed4bd35 100644
--- a/libc/src/math/generic/expm1f.cpp
+++ b/libc/src/math/generic/expm1f.cpp
@@ -21,8 +21,6 @@
 #include "src/__support/macros/optimization.h"            // LIBC_UNLIKELY
 #include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA
 
-#include <errno.h>
-
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(float, expm1f, (float x)) {

diff  --git a/libc/src/math/generic/powf.cpp b/libc/src/math/generic/powf.cpp
index e3dee678a1a70a..8ce2465ba229cb 100644
--- a/libc/src/math/generic/powf.cpp
+++ b/libc/src/math/generic/powf.cpp
@@ -25,8 +25,6 @@
 #include "exp10f_impl.h" // Speedup for powf(10, y) = exp10f(y)
 #include "exp2f_impl.h"  // Speedup for powf(2, y) = exp2f(y)
 
-#include <errno.h>
-
 namespace LIBC_NAMESPACE_DECL {
 
 using fputil::DoubleDouble;

diff  --git a/libc/src/math/generic/sincosf.cpp b/libc/src/math/generic/sincosf.cpp
index 3bf8e9772231d6..ccaa29c10c4c68 100644
--- a/libc/src/math/generic/sincosf.cpp
+++ b/libc/src/math/generic/sincosf.cpp
@@ -17,8 +17,6 @@
 #include "src/__support/macros/optimization.h"            // LIBC_UNLIKELY
 #include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA
 
-#include <errno.h>
-
 namespace LIBC_NAMESPACE_DECL {
 
 // Exceptional values

diff  --git a/libc/src/math/generic/sinf.cpp b/libc/src/math/generic/sinf.cpp
index 43c2c2a8d883d2..cea267d4c683e5 100644
--- a/libc/src/math/generic/sinf.cpp
+++ b/libc/src/math/generic/sinf.cpp
@@ -19,8 +19,6 @@
 #include "src/__support/macros/optimization.h"            // LIBC_UNLIKELY
 #include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA
 
-#include <errno.h>
-
 #if defined(LIBC_TARGET_CPU_HAS_FMA)
 #include "range_reduction_fma.h"
 #else

diff  --git a/libc/src/math/generic/tanf.cpp b/libc/src/math/generic/tanf.cpp
index 01d8c9855d461b..6fd5f9a103676c 100644
--- a/libc/src/math/generic/tanf.cpp
+++ b/libc/src/math/generic/tanf.cpp
@@ -19,8 +19,6 @@
 #include "src/__support/macros/optimization.h"            // LIBC_UNLIKELY
 #include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA
 
-#include <errno.h>
-
 namespace LIBC_NAMESPACE_DECL {
 
 // Exceptional cases for tanf.

diff  --git a/libc/src/pthread/CMakeLists.txt b/libc/src/pthread/CMakeLists.txt
index e7e92e5b60dc2a..8480fd89422223 100644
--- a/libc/src/pthread/CMakeLists.txt
+++ b/libc/src/pthread/CMakeLists.txt
@@ -36,6 +36,7 @@ add_entrypoint_object(
     pthread_attr_setdetachstate.h
   DEPENDS
     libc.include.pthread
+    libc.src.errno.errno
 )
 
 add_entrypoint_object(
@@ -56,6 +57,7 @@ add_entrypoint_object(
     pthread_attr_setguardsize.h
   DEPENDS
     libc.include.pthread
+    libc.src.errno.errno
 )
 
 add_entrypoint_object(
@@ -76,6 +78,7 @@ add_entrypoint_object(
     pthread_attr_setstacksize.h
   DEPENDS
     libc.include.pthread
+    libc.src.errno.errno
 )
 
 add_entrypoint_object(
@@ -98,6 +101,7 @@ add_entrypoint_object(
   DEPENDS
     libc.include.pthread
     libc.src.pthread.pthread_attr_setstacksize
+    libc.src.errno.errno
 )
 
 add_entrypoint_object(
@@ -149,10 +153,10 @@ add_entrypoint_object(
   HDRS
     pthread_condattr_setclock.h
   DEPENDS
-    libc.include.errno
     libc.include.pthread
     libc.include.sys_types
     libc.include.time
+    libc.src.errno.errno
 )
 
 add_entrypoint_object(
@@ -163,6 +167,7 @@ add_entrypoint_object(
     pthread_condattr_setpshared.h
   DEPENDS
     libc.include.pthread
+    libc.src.errno.errno
 )
 
 add_header_library(
@@ -205,6 +210,7 @@ add_entrypoint_object(
   DEPENDS
     .pthread_mutexattr
     libc.include.pthread
+    libc.src.errno.errno
 )
 
 add_entrypoint_object(
@@ -215,7 +221,7 @@ add_entrypoint_object(
     pthread_mutexattr_destroy.h
   DEPENDS
     .pthread_mutexattr
-    libc.include.errno
+    libc.src.errno.errno
     libc.include.pthread
 )
 
@@ -238,8 +244,8 @@ add_entrypoint_object(
     pthread_mutexattr_setrobust.h
   DEPENDS
     .pthread_mutexattr
-    libc.include.errno
     libc.include.pthread
+    libc.src.errno.errno
 )
 
 add_entrypoint_object(
@@ -261,8 +267,8 @@ add_entrypoint_object(
     pthread_mutexattr_setpshared.h
   DEPENDS
     .pthread_mutexattr
-    libc.include.errno
     libc.include.pthread
+    libc.src.errno.errno
 )
 
 add_entrypoint_object(
@@ -273,7 +279,7 @@ add_entrypoint_object(
     pthread_mutex_init.h
   DEPENDS
     .pthread_mutexattr
-    libc.include.errno
+    libc.src.errno.errno
     libc.include.pthread
     libc.src.__support.threads.mutex
 )
@@ -318,7 +324,6 @@ add_entrypoint_object(
   HDRS
     pthread_create.h
   DEPENDS
-    libc.include.errno
     libc.include.pthread
     libc.src.__support.threads.thread
     libc.src.pthread.pthread_attr_destroy
@@ -326,6 +331,7 @@ add_entrypoint_object(
     libc.src.pthread.pthread_attr_getdetachstate
     libc.src.pthread.pthread_attr_getguardsize
     libc.src.pthread.pthread_attr_getstack
+    libc.src.errno.errno
   COMPILE_OPTIONS
     -O3
     -fno-omit-frame-pointer
@@ -419,9 +425,9 @@ add_entrypoint_object(
   HDRS
     pthread_key_create.h
   DEPENDS
-    libc.include.errno
     libc.include.pthread
     libc.src.__support.threads.thread
+    libc.src.errno.errno
 )
 
 add_entrypoint_object(
@@ -431,9 +437,9 @@ add_entrypoint_object(
   HDRS
     pthread_key_delete.h
   DEPENDS
-    libc.include.errno
     libc.include.pthread
     libc.src.__support.threads.thread
+    libc.src.errno.errno
 )
 
 add_entrypoint_object(
@@ -443,8 +449,8 @@ add_entrypoint_object(
   HDRS
     pthread_getspecific.h
   DEPENDS
-    libc.include.errno
     libc.include.pthread
+    libc.src.errno.errno
     libc.src.__support.threads.thread
 )
 
@@ -455,9 +461,9 @@ add_entrypoint_object(
   HDRS
     pthread_setspecific.h
   DEPENDS
-    libc.include.errno
     libc.include.pthread
     libc.src.__support.threads.thread
+    libc.src.errno.errno
 )
 
 add_entrypoint_object(
@@ -508,7 +514,7 @@ add_entrypoint_object(
     pthread_rwlockattr_setkind_np.h
   DEPENDS
     libc.include.pthread
-    libc.include.errno
+    libc.src.errno.errno
 )
 
 add_entrypoint_object(
@@ -519,7 +525,7 @@ add_entrypoint_object(
     pthread_rwlockattr_setpshared.h
   DEPENDS
     libc.include.pthread
-    libc.include.errno
+    libc.src.errno.errno
 )
 
 add_entrypoint_object(
@@ -554,6 +560,7 @@ add_entrypoint_object(
   DEPENDS
     libc.include.pthread
     libc.src.__support.threads.linux.rwlock
+    libc.src.errno.errno
 )
 
 add_entrypoint_object(
@@ -587,6 +594,7 @@ add_entrypoint_object(
   DEPENDS
     libc.include.pthread
     libc.src.__support.threads.linux.rwlock
+    libc.src.errno.errno
 )
 
 add_entrypoint_object(
@@ -631,6 +639,7 @@ add_entrypoint_object(
   DEPENDS
     libc.include.pthread
     libc.src.__support.threads.linux.rwlock
+    libc.src.errno.errno
 )
 
 add_entrypoint_object(
@@ -727,7 +736,7 @@ add_entrypoint_object(
   HDRS
     pthread_atfork.h
   DEPENDS
-    libc.include.errno
     libc.include.pthread
     libc.src.__support.threads.fork_callbacks
+    libc.src.errno.errno
 )

diff  --git a/libc/src/pthread/pthread_atfork.cpp b/libc/src/pthread/pthread_atfork.cpp
index d3f3c259992ec2..b2c67c78e5d94e 100644
--- a/libc/src/pthread/pthread_atfork.cpp
+++ b/libc/src/pthread/pthread_atfork.cpp
@@ -11,8 +11,8 @@
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
 #include "src/__support/threads/fork_callbacks.h"
+#include "src/errno/libc_errno.h"
 
-#include <errno.h>
 #include <pthread.h> // For pthread_* type definitions.
 
 namespace LIBC_NAMESPACE_DECL {

diff  --git a/libc/src/pthread/pthread_attr_setdetachstate.cpp b/libc/src/pthread/pthread_attr_setdetachstate.cpp
index 3aa72d217f28b3..872f694e01f3ae 100644
--- a/libc/src/pthread/pthread_attr_setdetachstate.cpp
+++ b/libc/src/pthread/pthread_attr_setdetachstate.cpp
@@ -10,8 +10,8 @@
 
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
+#include "src/errno/libc_errno.h"
 
-#include <errno.h>
 #include <pthread.h>
 
 namespace LIBC_NAMESPACE_DECL {

diff  --git a/libc/src/pthread/pthread_attr_setguardsize.cpp b/libc/src/pthread/pthread_attr_setguardsize.cpp
index 389ee773fc5db5..fa4375e915ab47 100644
--- a/libc/src/pthread/pthread_attr_setguardsize.cpp
+++ b/libc/src/pthread/pthread_attr_setguardsize.cpp
@@ -10,8 +10,8 @@
 
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
+#include "src/errno/libc_errno.h"
 
-#include <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 f4f2d1450633ea..1154055a63a7ef 100644
--- a/libc/src/pthread/pthread_attr_setstack.cpp
+++ b/libc/src/pthread/pthread_attr_setstack.cpp
@@ -12,8 +12,8 @@
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
 #include "src/__support/threads/thread.h" // For STACK_ALIGNMENT
+#include "src/errno/libc_errno.h"
 
-#include <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 f327d3365b5d85..0a5d1af661abfa 100644
--- a/libc/src/pthread/pthread_attr_setstacksize.cpp
+++ b/libc/src/pthread/pthread_attr_setstacksize.cpp
@@ -10,8 +10,8 @@
 
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
+#include "src/errno/libc_errno.h"
 
-#include <errno.h>
 #include <pthread.h>
 
 namespace LIBC_NAMESPACE_DECL {

diff  --git a/libc/src/pthread/pthread_condattr_setclock.cpp b/libc/src/pthread/pthread_condattr_setclock.cpp
index 5c0144523f93e6..37fbd6b27143dd 100644
--- a/libc/src/pthread/pthread_condattr_setclock.cpp
+++ b/libc/src/pthread/pthread_condattr_setclock.cpp
@@ -10,8 +10,8 @@
 
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
+#include "src/errno/libc_errno.h"
 
-#include <errno.h>     // EINVAL
 #include <pthread.h>   // pthread_condattr_t
 #include <sys/types.h> // clockid_t
 #include <time.h>      // CLOCK_MONOTONIC, CLOCK_REALTIME

diff  --git a/libc/src/pthread/pthread_condattr_setpshared.cpp b/libc/src/pthread/pthread_condattr_setpshared.cpp
index 536aeadac5d446..433b2dc1d2d931 100644
--- a/libc/src/pthread/pthread_condattr_setpshared.cpp
+++ b/libc/src/pthread/pthread_condattr_setpshared.cpp
@@ -10,8 +10,8 @@
 
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
+#include "src/errno/libc_errno.h"
 
-#include <errno.h> // EINVAL
 #include <pthread.h> // pthread_condattr_t, PTHREAD_PROCESS_SHARED, PTHREAD_PROCESS_PRIVATE
 
 namespace LIBC_NAMESPACE_DECL {

diff  --git a/libc/src/pthread/pthread_create.cpp b/libc/src/pthread/pthread_create.cpp
index 1fb4b50109401c..e1b1f3b325d1cb 100644
--- a/libc/src/pthread/pthread_create.cpp
+++ b/libc/src/pthread/pthread_create.cpp
@@ -19,8 +19,8 @@
 #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 <errno.h>
 #include <pthread.h> // For pthread_* type definitions.
 
 namespace LIBC_NAMESPACE_DECL {

diff  --git a/libc/src/pthread/pthread_key_create.cpp b/libc/src/pthread/pthread_key_create.cpp
index 0583baca22f4d4..383762f273e7a7 100644
--- a/libc/src/pthread/pthread_key_create.cpp
+++ b/libc/src/pthread/pthread_key_create.cpp
@@ -11,8 +11,8 @@
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
 #include "src/__support/threads/thread.h"
+#include "src/errno/libc_errno.h"
 
-#include <errno.h>
 #include <pthread.h>
 
 namespace LIBC_NAMESPACE_DECL {

diff  --git a/libc/src/pthread/pthread_key_delete.cpp b/libc/src/pthread/pthread_key_delete.cpp
index 20484fa9bdf828..b54db821ab05a8 100644
--- a/libc/src/pthread/pthread_key_delete.cpp
+++ b/libc/src/pthread/pthread_key_delete.cpp
@@ -11,8 +11,8 @@
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
 #include "src/__support/threads/thread.h"
+#include "src/errno/libc_errno.h"
 
-#include <errno.h>
 #include <pthread.h>
 
 namespace LIBC_NAMESPACE_DECL {

diff  --git a/libc/src/pthread/pthread_mutex_init.cpp b/libc/src/pthread/pthread_mutex_init.cpp
index 0281f732473d9d..94052e53d8c0ab 100644
--- a/libc/src/pthread/pthread_mutex_init.cpp
+++ b/libc/src/pthread/pthread_mutex_init.cpp
@@ -13,7 +13,6 @@
 #include "src/__support/macros/config.h"
 #include "src/__support/threads/mutex.h"
 
-#include <errno.h>
 #include <pthread.h>
 
 namespace LIBC_NAMESPACE_DECL {

diff  --git a/libc/src/pthread/pthread_mutexattr_destroy.cpp b/libc/src/pthread/pthread_mutexattr_destroy.cpp
index 3b2551afd11b55..bddeb8b75acd15 100644
--- a/libc/src/pthread/pthread_mutexattr_destroy.cpp
+++ b/libc/src/pthread/pthread_mutexattr_destroy.cpp
@@ -12,8 +12,6 @@
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
 
-#include <errno.h>
-
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(int, pthread_mutexattr_destroy, (pthread_mutexattr_t *)) {

diff  --git a/libc/src/pthread/pthread_mutexattr_getpshared.cpp b/libc/src/pthread/pthread_mutexattr_getpshared.cpp
index 2d83a5229e9ecd..0ea5d428346183 100644
--- a/libc/src/pthread/pthread_mutexattr_getpshared.cpp
+++ b/libc/src/pthread/pthread_mutexattr_getpshared.cpp
@@ -12,8 +12,6 @@
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
 
-#include <errno.h>
-
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(int, pthread_mutexattr_getpshared,

diff  --git a/libc/src/pthread/pthread_mutexattr_getrobust.cpp b/libc/src/pthread/pthread_mutexattr_getrobust.cpp
index 508b502a580087..b2359e0ac8c9c2 100644
--- a/libc/src/pthread/pthread_mutexattr_getrobust.cpp
+++ b/libc/src/pthread/pthread_mutexattr_getrobust.cpp
@@ -12,8 +12,6 @@
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
 
-#include <errno.h>
-
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(int, pthread_mutexattr_getrobust,

diff  --git a/libc/src/pthread/pthread_mutexattr_gettype.cpp b/libc/src/pthread/pthread_mutexattr_gettype.cpp
index 3747bf5ce73e94..0bd226ef89e5ed 100644
--- a/libc/src/pthread/pthread_mutexattr_gettype.cpp
+++ b/libc/src/pthread/pthread_mutexattr_gettype.cpp
@@ -12,8 +12,6 @@
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
 
-#include <errno.h>
-
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(int, pthread_mutexattr_gettype,

diff  --git a/libc/src/pthread/pthread_mutexattr_setpshared.cpp b/libc/src/pthread/pthread_mutexattr_setpshared.cpp
index b290de764c91b6..deeae15be23035 100644
--- a/libc/src/pthread/pthread_mutexattr_setpshared.cpp
+++ b/libc/src/pthread/pthread_mutexattr_setpshared.cpp
@@ -11,8 +11,8 @@
 
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
+#include "src/errno/libc_errno.h"
 
-#include <errno.h>
 #include <pthread.h>
 
 namespace LIBC_NAMESPACE_DECL {

diff  --git a/libc/src/pthread/pthread_mutexattr_setrobust.cpp b/libc/src/pthread/pthread_mutexattr_setrobust.cpp
index e572827486c077..9fd46f4c928d70 100644
--- a/libc/src/pthread/pthread_mutexattr_setrobust.cpp
+++ b/libc/src/pthread/pthread_mutexattr_setrobust.cpp
@@ -11,8 +11,8 @@
 
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
+#include "src/errno/libc_errno.h"
 
-#include <errno.h>
 #include <pthread.h>
 
 namespace LIBC_NAMESPACE_DECL {

diff  --git a/libc/src/pthread/pthread_mutexattr_settype.cpp b/libc/src/pthread/pthread_mutexattr_settype.cpp
index 27e8ff859ba347..c7e78271f9c38b 100644
--- a/libc/src/pthread/pthread_mutexattr_settype.cpp
+++ b/libc/src/pthread/pthread_mutexattr_settype.cpp
@@ -11,8 +11,8 @@
 
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
+#include "src/errno/libc_errno.h"
 
-#include <errno.h>
 #include <pthread.h>
 
 namespace LIBC_NAMESPACE_DECL {

diff  --git a/libc/src/pthread/pthread_rwlock_destroy.cpp b/libc/src/pthread/pthread_rwlock_destroy.cpp
index 345076aae43488..afc5622e54a003 100644
--- a/libc/src/pthread/pthread_rwlock_destroy.cpp
+++ b/libc/src/pthread/pthread_rwlock_destroy.cpp
@@ -12,7 +12,6 @@
 #include "src/__support/macros/config.h"
 #include "src/__support/threads/linux/rwlock.h"
 
-#include <errno.h>
 #include <pthread.h>
 
 namespace LIBC_NAMESPACE_DECL {

diff  --git a/libc/src/pthread/pthread_rwlock_init.cpp b/libc/src/pthread/pthread_rwlock_init.cpp
index d1a31625d0dabd..dc5424cbc4838d 100644
--- a/libc/src/pthread/pthread_rwlock_init.cpp
+++ b/libc/src/pthread/pthread_rwlock_init.cpp
@@ -14,7 +14,6 @@
 #include "src/__support/macros/config.h"
 #include "src/__support/threads/linux/rwlock.h"
 
-#include <errno.h>
 #include <pthread.h>
 
 namespace LIBC_NAMESPACE_DECL {

diff  --git a/libc/src/pthread/pthread_rwlock_rdlock.cpp b/libc/src/pthread/pthread_rwlock_rdlock.cpp
index 16d82301c54a9a..7dee8eb9a44b12 100644
--- a/libc/src/pthread/pthread_rwlock_rdlock.cpp
+++ b/libc/src/pthread/pthread_rwlock_rdlock.cpp
@@ -12,7 +12,6 @@
 #include "src/__support/macros/config.h"
 #include "src/__support/threads/linux/rwlock.h"
 
-#include <errno.h>
 #include <pthread.h>
 
 namespace LIBC_NAMESPACE_DECL {

diff  --git a/libc/src/pthread/pthread_rwlock_timedrdlock.cpp b/libc/src/pthread/pthread_rwlock_timedrdlock.cpp
index 905541014a4a46..112ff5c9cdad35 100644
--- a/libc/src/pthread/pthread_rwlock_timedrdlock.cpp
+++ b/libc/src/pthread/pthread_rwlock_timedrdlock.cpp
@@ -7,15 +7,14 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/pthread/pthread_rwlock_timedrdlock.h"
-
 #include "src/__support/common.h"
 #include "src/__support/libc_assert.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 <errno.h>
 #include <pthread.h>
 
 namespace LIBC_NAMESPACE_DECL {

diff  --git a/libc/src/pthread/pthread_rwlock_timedwrlock.cpp b/libc/src/pthread/pthread_rwlock_timedwrlock.cpp
index f77ac40f22b897..d2dc70e992e82e 100644
--- a/libc/src/pthread/pthread_rwlock_timedwrlock.cpp
+++ b/libc/src/pthread/pthread_rwlock_timedwrlock.cpp
@@ -15,7 +15,6 @@
 #include "src/__support/threads/linux/rwlock.h"
 #include "src/__support/time/linux/abs_timeout.h"
 
-#include <errno.h>
 #include <pthread.h>
 
 namespace LIBC_NAMESPACE_DECL {

diff  --git a/libc/src/pthread/pthread_rwlock_tryrdlock.cpp b/libc/src/pthread/pthread_rwlock_tryrdlock.cpp
index da59a576b82747..d54b57f0560908 100644
--- a/libc/src/pthread/pthread_rwlock_tryrdlock.cpp
+++ b/libc/src/pthread/pthread_rwlock_tryrdlock.cpp
@@ -12,7 +12,6 @@
 #include "src/__support/macros/config.h"
 #include "src/__support/threads/linux/rwlock.h"
 
-#include <errno.h>
 #include <pthread.h>
 
 namespace LIBC_NAMESPACE_DECL {

diff  --git a/libc/src/pthread/pthread_rwlock_trywrlock.cpp b/libc/src/pthread/pthread_rwlock_trywrlock.cpp
index ccd1bd49c402c6..a63dc893e7169c 100644
--- a/libc/src/pthread/pthread_rwlock_trywrlock.cpp
+++ b/libc/src/pthread/pthread_rwlock_trywrlock.cpp
@@ -11,8 +11,8 @@
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
 #include "src/__support/threads/linux/rwlock.h"
+#include "src/errno/libc_errno.h"
 
-#include <errno.h>
 #include <pthread.h>
 
 namespace LIBC_NAMESPACE_DECL {

diff  --git a/libc/src/pthread/pthread_rwlock_unlock.cpp b/libc/src/pthread/pthread_rwlock_unlock.cpp
index 77c50a8e65fdfb..e61290179bd629 100644
--- a/libc/src/pthread/pthread_rwlock_unlock.cpp
+++ b/libc/src/pthread/pthread_rwlock_unlock.cpp
@@ -11,8 +11,8 @@
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
 #include "src/__support/threads/linux/rwlock.h"
+#include "src/errno/libc_errno.h"
 
-#include <errno.h>
 #include <pthread.h>
 
 namespace LIBC_NAMESPACE_DECL {

diff  --git a/libc/src/pthread/pthread_rwlock_wrlock.cpp b/libc/src/pthread/pthread_rwlock_wrlock.cpp
index c2561c81f4bd0e..f02fb6b5db9c09 100644
--- a/libc/src/pthread/pthread_rwlock_wrlock.cpp
+++ b/libc/src/pthread/pthread_rwlock_wrlock.cpp
@@ -12,7 +12,6 @@
 #include "src/__support/macros/config.h"
 #include "src/__support/threads/linux/rwlock.h"
 
-#include <errno.h>
 #include <pthread.h>
 
 namespace LIBC_NAMESPACE_DECL {

diff  --git a/libc/src/pthread/pthread_rwlockattr_setkind_np.cpp b/libc/src/pthread/pthread_rwlockattr_setkind_np.cpp
index 45dbb05c7ab893..80d34a35c717ad 100644
--- a/libc/src/pthread/pthread_rwlockattr_setkind_np.cpp
+++ b/libc/src/pthread/pthread_rwlockattr_setkind_np.cpp
@@ -10,8 +10,8 @@
 
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
+#include "src/errno/libc_errno.h"
 
-#include <errno.h>
 #include <pthread.h> // pthread_rwlockattr_t
 
 namespace LIBC_NAMESPACE_DECL {

diff  --git a/libc/src/pthread/pthread_rwlockattr_setpshared.cpp b/libc/src/pthread/pthread_rwlockattr_setpshared.cpp
index 8088b68fdf33f4..5a7191aefd3d0d 100644
--- a/libc/src/pthread/pthread_rwlockattr_setpshared.cpp
+++ b/libc/src/pthread/pthread_rwlockattr_setpshared.cpp
@@ -10,8 +10,8 @@
 
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
+#include "src/errno/libc_errno.h"
 
-#include <errno.h> // EINVAL
 #include <pthread.h> // pthread_rwlockattr_t, PTHREAD_PROCESS_SHARED, PTHREAD_PROCESS_PRIVATE
 
 namespace LIBC_NAMESPACE_DECL {

diff  --git a/libc/src/pthread/pthread_setspecific.cpp b/libc/src/pthread/pthread_setspecific.cpp
index 5587a2d937abbb..70c29c16708411 100644
--- a/libc/src/pthread/pthread_setspecific.cpp
+++ b/libc/src/pthread/pthread_setspecific.cpp
@@ -11,8 +11,8 @@
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
 #include "src/__support/threads/thread.h"
+#include "src/errno/libc_errno.h"
 
-#include <errno.h>
 #include <pthread.h>
 
 namespace LIBC_NAMESPACE_DECL {

diff  --git a/libc/src/spawn/CMakeLists.txt b/libc/src/spawn/CMakeLists.txt
index 4fbbaacb10d265..11621da782ed12 100644
--- a/libc/src/spawn/CMakeLists.txt
+++ b/libc/src/spawn/CMakeLists.txt
@@ -28,9 +28,9 @@ add_entrypoint_object(
     posix_spawn_file_actions_destroy.h
   DEPENDS
     .file_actions
-    libc.include.errno
     libc.include.spawn
     libc.src.__support.CPP.new
+    libc.src.errno.errno
 )
 
 add_entrypoint_object(
@@ -41,9 +41,9 @@ add_entrypoint_object(
     posix_spawn_file_actions_adddup2.h
   DEPENDS
     .file_actions
-    libc.include.errno
     libc.include.spawn
     libc.src.__support.CPP.new
+    libc.src.errno.errno
 )
 
 add_entrypoint_object(
@@ -54,9 +54,9 @@ add_entrypoint_object(
     posix_spawn_file_actions_addopen.h
   DEPENDS
     .file_actions
-    libc.include.errno
     libc.include.spawn
     libc.src.__support.CPP.new
+    libc.src.errno.errno
 )
 
 add_entrypoint_object(
@@ -67,9 +67,9 @@ add_entrypoint_object(
     posix_spawn_file_actions_addclose.h
   DEPENDS
     .file_actions
-    libc.include.errno
     libc.include.spawn
     libc.src.__support.CPP.new
+    libc.src.errno.errno
 )
 
 add_entrypoint_object(

diff  --git a/libc/src/spawn/posix_spawn_file_actions_addclose.cpp b/libc/src/spawn/posix_spawn_file_actions_addclose.cpp
index e43af8f665f959..bb8504f655c4a2 100644
--- a/libc/src/spawn/posix_spawn_file_actions_addclose.cpp
+++ b/libc/src/spawn/posix_spawn_file_actions_addclose.cpp
@@ -12,8 +12,8 @@
 #include "src/__support/CPP/new.h"
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
+#include "src/errno/libc_errno.h"
 
-#include <errno.h>
 #include <spawn.h>
 
 namespace LIBC_NAMESPACE_DECL {

diff  --git a/libc/src/spawn/posix_spawn_file_actions_adddup2.cpp b/libc/src/spawn/posix_spawn_file_actions_adddup2.cpp
index 9f28ffa48bee04..710063d52e74dd 100644
--- a/libc/src/spawn/posix_spawn_file_actions_adddup2.cpp
+++ b/libc/src/spawn/posix_spawn_file_actions_adddup2.cpp
@@ -12,8 +12,8 @@
 #include "src/__support/CPP/new.h"
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
+#include "src/errno/libc_errno.h"
 
-#include <errno.h>
 #include <spawn.h>
 
 namespace LIBC_NAMESPACE_DECL {

diff  --git a/libc/src/spawn/posix_spawn_file_actions_addopen.cpp b/libc/src/spawn/posix_spawn_file_actions_addopen.cpp
index 7f9286099573e2..028d6e895f3c44 100644
--- a/libc/src/spawn/posix_spawn_file_actions_addopen.cpp
+++ b/libc/src/spawn/posix_spawn_file_actions_addopen.cpp
@@ -12,8 +12,8 @@
 #include "src/__support/CPP/new.h"
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
+#include "src/errno/libc_errno.h"
 
-#include <errno.h>
 #include <spawn.h>
 
 namespace LIBC_NAMESPACE_DECL {

diff  --git a/libc/src/spawn/posix_spawn_file_actions_destroy.cpp b/libc/src/spawn/posix_spawn_file_actions_destroy.cpp
index 155e4c6a3b2bee..168118da249d1e 100644
--- a/libc/src/spawn/posix_spawn_file_actions_destroy.cpp
+++ b/libc/src/spawn/posix_spawn_file_actions_destroy.cpp
@@ -9,11 +9,12 @@
 #include "posix_spawn_file_actions_destroy.h"
 
 #include "file_actions.h"
+
 #include "src/__support/CPP/new.h"
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
+#include "src/errno/libc_errno.h"
 
-#include <errno.h>
 #include <spawn.h>
 
 namespace LIBC_NAMESPACE_DECL {

diff  --git a/libc/src/threads/CMakeLists.txt b/libc/src/threads/CMakeLists.txt
index b3b22e7f5c735a..c33be265369fec 100644
--- a/libc/src/threads/CMakeLists.txt
+++ b/libc/src/threads/CMakeLists.txt
@@ -22,6 +22,7 @@ add_entrypoint_object(
   DEPENDS
     libc.src.__support.threads.thread
     libc.include.threads
+    libc.src.errno.errno
   COMPILE_OPTIONS
     -O3
     -fno-omit-frame-pointer # This allows us to sniff out the thread args from

diff  --git a/libc/src/threads/thrd_create.cpp b/libc/src/threads/thrd_create.cpp
index 52af72b07c8a80..4680944c2eee09 100644
--- a/libc/src/threads/thrd_create.cpp
+++ b/libc/src/threads/thrd_create.cpp
@@ -10,8 +10,8 @@
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
 #include "src/__support/threads/thread.h"
+#include "src/errno/libc_errno.h"
 
-#include <errno.h>
 #include <threads.h> // For thrd_* type definitions.
 
 namespace LIBC_NAMESPACE_DECL {

diff  --git a/libc/test/UnitTest/PrintfMatcher.h b/libc/test/UnitTest/PrintfMatcher.h
index e0c16cf05f2816..4f79832ab59fac 100644
--- a/libc/test/UnitTest/PrintfMatcher.h
+++ b/libc/test/UnitTest/PrintfMatcher.h
@@ -13,8 +13,6 @@
 #include "src/stdio/printf_core/core_structs.h"
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
-
 namespace LIBC_NAMESPACE_DECL {
 namespace testing {
 

diff  --git a/libc/test/UnitTest/ScanfMatcher.h b/libc/test/UnitTest/ScanfMatcher.h
index d64258f3f4f2c0..cb9d13f7572b75 100644
--- a/libc/test/UnitTest/ScanfMatcher.h
+++ b/libc/test/UnitTest/ScanfMatcher.h
@@ -13,8 +13,6 @@
 #include "src/stdio/scanf_core/core_structs.h"
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
-
 namespace LIBC_NAMESPACE_DECL {
 namespace testing {
 

diff  --git a/libc/test/integration/src/pthread/CMakeLists.txt b/libc/test/integration/src/pthread/CMakeLists.txt
index 48d4368df156d8..208ba3fd435079 100644
--- a/libc/test/integration/src/pthread/CMakeLists.txt
+++ b/libc/test/integration/src/pthread/CMakeLists.txt
@@ -115,7 +115,6 @@ add_integration_test(
   SRCS
     pthread_name_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.pthread
     libc.src.errno.errno
     libc.src.pthread.pthread_create
@@ -185,8 +184,8 @@ add_integration_test(
     pthread_join_test.cpp
   DEPENDS
     libc.include.pthread
-    libc.include.errno
     libc.include.stdio
+    libc.src.errno.errno
     libc.src.pthread.pthread_create
     libc.src.pthread.pthread_join
 )
@@ -199,7 +198,7 @@ add_integration_test(
     pthread_create_test.cpp
   DEPENDS
     libc.include.pthread
-    libc.include.errno
+    libc.src.errno.errno
     libc.src.pthread.pthread_create
     libc.src.pthread.pthread_join
     libc.src.pthread.pthread_attr_getdetachstate

diff  --git a/libc/test/integration/src/pthread/pthread_name_test.cpp b/libc/test/integration/src/pthread/pthread_name_test.cpp
index d341792d11d6cb..37ceceee880de2 100644
--- a/libc/test/integration/src/pthread/pthread_name_test.cpp
+++ b/libc/test/integration/src/pthread/pthread_name_test.cpp
@@ -7,6 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/__support/CPP/string_view.h"
+#include "src/errno/libc_errno.h"
 #include "src/pthread/pthread_create.h"
 #include "src/pthread/pthread_getname_np.h"
 #include "src/pthread/pthread_join.h"
@@ -19,7 +20,6 @@
 
 #include "test/IntegrationTest/test.h"
 
-#include <errno.h>
 #include <pthread.h>
 #include <stdint.h> // uintptr_t
 

diff  --git a/libc/test/integration/src/spawn/posix_spawn_test_binary.cpp b/libc/test/integration/src/spawn/posix_spawn_test_binary.cpp
index 7aec39c1929287..c1b0cd671da718 100644
--- a/libc/test/integration/src/spawn/posix_spawn_test_binary.cpp
+++ b/libc/test/integration/src/spawn/posix_spawn_test_binary.cpp
@@ -1,5 +1,4 @@
 #include "test_binary_properties.h"
-#include <errno.h>
 #include <string.h>
 #include <unistd.h>
 

diff  --git a/libc/test/integration/src/unistd/CMakeLists.txt b/libc/test/integration/src/unistd/CMakeLists.txt
index 644f16fa46347a..5bcb712dd56d37 100644
--- a/libc/test/integration/src/unistd/CMakeLists.txt
+++ b/libc/test/integration/src/unistd/CMakeLists.txt
@@ -21,10 +21,10 @@ add_integration_test(
   SRCS
     fork_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.signal
     libc.include.sys_wait
     libc.include.unistd
+    libc.src.errno.errno
     libc.src.pthread.pthread_atfork
     libc.src.signal.raise
     libc.src.sys.wait.wait
@@ -45,11 +45,11 @@ if((${LIBC_TARGET_OS} STREQUAL "linux") AND (${LIBC_TARGET_ARCHITECTURE_IS_X86})
     SRCS
       stack_smashing_test.cpp
     DEPENDS
-      libc.include.errno
       libc.include.signal
       libc.include.sys_wait
       libc.include.unistd
       libc.src.compiler.__stack_chk_fail
+      libc.src.errno.errno
       libc.src.pthread.pthread_atfork
       libc.src.signal.raise
       libc.src.sys.wait.wait
@@ -94,7 +94,7 @@ add_integration_test(
   DEPENDS
     libc_execv_test_normal_exit
     libc_execv_test_signal_exit
-    libc.include.errno
+    libc.src.errno.errno
     libc.src.sys.wait.waitpid
     libc.src.unistd.execv
     libc.src.unistd.fork
@@ -111,7 +111,7 @@ add_integration_test(
   DEPENDS
     libc_execv_test_normal_exit
     libc_execv_test_signal_exit
-    libc.include.errno
+    libc.errno.errno
     libc.src.sys.wait.waitpid
     libc.src.unistd.execve
     libc.src.unistd.fork

diff  --git a/libc/test/integration/src/unistd/fork_test.cpp b/libc/test/integration/src/unistd/fork_test.cpp
index 87f314f305101c..010f57a7d24486 100644
--- a/libc/test/integration/src/unistd/fork_test.cpp
+++ b/libc/test/integration/src/unistd/fork_test.cpp
@@ -18,7 +18,6 @@
 
 #include "test/IntegrationTest/test.h"
 
-#include <errno.h>
 #include <signal.h>
 #include <sys/syscall.h>
 #include <sys/wait.h>

diff  --git a/libc/test/integration/src/unistd/stack_smashing_test.cpp b/libc/test/integration/src/unistd/stack_smashing_test.cpp
index 89fc53dac506ac..3508b1695cfdc5 100644
--- a/libc/test/integration/src/unistd/stack_smashing_test.cpp
+++ b/libc/test/integration/src/unistd/stack_smashing_test.cpp
@@ -17,7 +17,6 @@
 
 #include "test/IntegrationTest/test.h"
 
-#include <errno.h>
 #include <signal.h>
 #include <sys/wait.h>
 #include <unistd.h>

diff  --git a/libc/test/integration/startup/linux/CMakeLists.txt b/libc/test/integration/startup/linux/CMakeLists.txt
index 6f0517a832d200..511b16d6130261 100644
--- a/libc/test/integration/startup/linux/CMakeLists.txt
+++ b/libc/test/integration/startup/linux/CMakeLists.txt
@@ -38,7 +38,6 @@ add_integration_test(
   SRCS
     tls_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.sys_mman
     libc.src.errno.errno
     libc.src.sys.mman.mmap

diff  --git a/libc/test/integration/startup/linux/tls_test.cpp b/libc/test/integration/startup/linux/tls_test.cpp
index 2a6385e195a496..ef9fd9fcb7ff42 100644
--- a/libc/test/integration/startup/linux/tls_test.cpp
+++ b/libc/test/integration/startup/linux/tls_test.cpp
@@ -10,7 +10,6 @@
 #include "src/sys/mman/mmap.h"
 #include "test/IntegrationTest/test.h"
 
-#include <errno.h>
 #include <sys/mman.h>
 
 constexpr int threadLocalDataSize = 101;

diff  --git a/libc/test/src/__support/File/CMakeLists.txt b/libc/test/src/__support/File/CMakeLists.txt
index 9191469b4927c2..9fa3b518421ccb 100644
--- a/libc/test/src/__support/File/CMakeLists.txt
+++ b/libc/test/src/__support/File/CMakeLists.txt
@@ -14,9 +14,9 @@ add_libc_test(
   LINK_LIBRARIES
     LibcMemoryHelpers
   DEPENDS
-    libc.include.errno
     libc.include.stdio
     libc.include.stdlib
+    libc.src.errno.errno 
     libc.src.__support.CPP.new
     libc.src.__support.File.file
 )

diff  --git a/libc/test/src/math/RoundToIntegerTest.h b/libc/test/src/math/RoundToIntegerTest.h
index 910ff968c1a035..995aba7b233ec8 100644
--- a/libc/test/src/math/RoundToIntegerTest.h
+++ b/libc/test/src/math/RoundToIntegerTest.h
@@ -19,7 +19,6 @@
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
 #include "hdr/math_macros.h"
-#include <errno.h>
 
 namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
 using LIBC_NAMESPACE::Sign;

diff  --git a/libc/test/src/math/acosf_test.cpp b/libc/test/src/math/acosf_test.cpp
index 488058237d191e..2e4c8eb2ab9610 100644
--- a/libc/test/src/math/acosf_test.cpp
+++ b/libc/test/src/math/acosf_test.cpp
@@ -14,7 +14,6 @@
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 namespace mpfr = LIBC_NAMESPACE::testing::mpfr;

diff  --git a/libc/test/src/math/acoshf_test.cpp b/libc/test/src/math/acoshf_test.cpp
index 5d7f59792b52be..18ed5a11d50a7e 100644
--- a/libc/test/src/math/acoshf_test.cpp
+++ b/libc/test/src/math/acoshf_test.cpp
@@ -14,7 +14,6 @@
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcAcoshfTest = LIBC_NAMESPACE::testing::FPTest<float>;

diff  --git a/libc/test/src/math/asinf_test.cpp b/libc/test/src/math/asinf_test.cpp
index 09dc3c960ed9ab..5197810d8bd583 100644
--- a/libc/test/src/math/asinf_test.cpp
+++ b/libc/test/src/math/asinf_test.cpp
@@ -15,7 +15,6 @@
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcAsinfTest = LIBC_NAMESPACE::testing::FPTest<float>;

diff  --git a/libc/test/src/math/asinhf_test.cpp b/libc/test/src/math/asinhf_test.cpp
index 3e55a563879d03..ac125c3520c44d 100644
--- a/libc/test/src/math/asinhf_test.cpp
+++ b/libc/test/src/math/asinhf_test.cpp
@@ -14,7 +14,6 @@
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcAsinhfTest = LIBC_NAMESPACE::testing::FPTest<float>;

diff  --git a/libc/test/src/math/atanf_test.cpp b/libc/test/src/math/atanf_test.cpp
index 376b4724b5a3a2..575ec89bd493c4 100644
--- a/libc/test/src/math/atanf_test.cpp
+++ b/libc/test/src/math/atanf_test.cpp
@@ -14,7 +14,6 @@
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcAtanfTest = LIBC_NAMESPACE::testing::FPTest<float>;

diff  --git a/libc/test/src/math/atanhf_test.cpp b/libc/test/src/math/atanhf_test.cpp
index 488a9a942ce913..8b9db1dfdd9763 100644
--- a/libc/test/src/math/atanhf_test.cpp
+++ b/libc/test/src/math/atanhf_test.cpp
@@ -14,7 +14,6 @@
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcAtanhfTest = LIBC_NAMESPACE::testing::FPTest<float>;

diff  --git a/libc/test/src/math/cosf_test.cpp b/libc/test/src/math/cosf_test.cpp
index 82790e3a9d4809..2143c36f3d30b7 100644
--- a/libc/test/src/math/cosf_test.cpp
+++ b/libc/test/src/math/cosf_test.cpp
@@ -15,7 +15,6 @@
 #include "test/src/math/sdcomp26094.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LIBC_NAMESPACE::testing::SDCOMP26094_VALUES;

diff  --git a/libc/test/src/math/coshf_test.cpp b/libc/test/src/math/coshf_test.cpp
index 00bbf4b0bd9465..0d1c322b8e6222 100644
--- a/libc/test/src/math/coshf_test.cpp
+++ b/libc/test/src/math/coshf_test.cpp
@@ -15,7 +15,6 @@
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcCoshfTest = LIBC_NAMESPACE::testing::FPTest<float>;

diff  --git a/libc/test/src/math/erff_test.cpp b/libc/test/src/math/erff_test.cpp
index 851eda4b1542fd..f9b03377daa9b1 100644
--- a/libc/test/src/math/erff_test.cpp
+++ b/libc/test/src/math/erff_test.cpp
@@ -13,7 +13,6 @@
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcErffTest = LIBC_NAMESPACE::testing::FPTest<float>;

diff  --git a/libc/test/src/math/exp10_test.cpp b/libc/test/src/math/exp10_test.cpp
index 61ae33ecae525e..6fb1d2d9d925e6 100644
--- a/libc/test/src/math/exp10_test.cpp
+++ b/libc/test/src/math/exp10_test.cpp
@@ -14,7 +14,6 @@
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcExp10Test = LIBC_NAMESPACE::testing::FPTest<double>;

diff  --git a/libc/test/src/math/exp2_test.cpp b/libc/test/src/math/exp2_test.cpp
index f218eea0b358f1..adfceceeef4b76 100644
--- a/libc/test/src/math/exp2_test.cpp
+++ b/libc/test/src/math/exp2_test.cpp
@@ -14,7 +14,6 @@
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcExp2Test = LIBC_NAMESPACE::testing::FPTest<double>;

diff  --git a/libc/test/src/math/exp_test.cpp b/libc/test/src/math/exp_test.cpp
index ee674c5fe6cb52..0ab3a4e543464b 100644
--- a/libc/test/src/math/exp_test.cpp
+++ b/libc/test/src/math/exp_test.cpp
@@ -14,7 +14,6 @@
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcExpTest = LIBC_NAMESPACE::testing::FPTest<double>;

diff  --git a/libc/test/src/math/log10_test.cpp b/libc/test/src/math/log10_test.cpp
index 32b84686badea7..01aa1f82ae5d87 100644
--- a/libc/test/src/math/log10_test.cpp
+++ b/libc/test/src/math/log10_test.cpp
@@ -14,7 +14,6 @@
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcLog10Test = LIBC_NAMESPACE::testing::FPTest<double>;

diff  --git a/libc/test/src/math/log10f_test.cpp b/libc/test/src/math/log10f_test.cpp
index 4ba118455df4dd..b2c1c283e08e5c 100644
--- a/libc/test/src/math/log10f_test.cpp
+++ b/libc/test/src/math/log10f_test.cpp
@@ -13,7 +13,6 @@
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcLog10fTest = LIBC_NAMESPACE::testing::FPTest<float>;

diff  --git a/libc/test/src/math/log1p_test.cpp b/libc/test/src/math/log1p_test.cpp
index 98486deb12c744..107e965a0d3aec 100644
--- a/libc/test/src/math/log1p_test.cpp
+++ b/libc/test/src/math/log1p_test.cpp
@@ -14,7 +14,6 @@
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcLog1pTest = LIBC_NAMESPACE::testing::FPTest<double>;

diff  --git a/libc/test/src/math/log1pf_test.cpp b/libc/test/src/math/log1pf_test.cpp
index b42cf3b8681b22..bb181dc5e43b04 100644
--- a/libc/test/src/math/log1pf_test.cpp
+++ b/libc/test/src/math/log1pf_test.cpp
@@ -14,7 +14,6 @@
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcLog1pfTest = LIBC_NAMESPACE::testing::FPTest<float>;

diff  --git a/libc/test/src/math/log2_test.cpp b/libc/test/src/math/log2_test.cpp
index f9bd93d44e50f5..8a07991a688867 100644
--- a/libc/test/src/math/log2_test.cpp
+++ b/libc/test/src/math/log2_test.cpp
@@ -14,7 +14,6 @@
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcLog2Test = LIBC_NAMESPACE::testing::FPTest<double>;

diff  --git a/libc/test/src/math/log_test.cpp b/libc/test/src/math/log_test.cpp
index c0f9edfc540a1e..969a469b2e1c63 100644
--- a/libc/test/src/math/log_test.cpp
+++ b/libc/test/src/math/log_test.cpp
@@ -14,7 +14,6 @@
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcLogTest = LIBC_NAMESPACE::testing::FPTest<double>;

diff  --git a/libc/test/src/math/powf_test.cpp b/libc/test/src/math/powf_test.cpp
index c13231f9d83b86..448dcc0035e9b0 100644
--- a/libc/test/src/math/powf_test.cpp
+++ b/libc/test/src/math/powf_test.cpp
@@ -13,7 +13,6 @@
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcPowfTest = LIBC_NAMESPACE::testing::FPTest<float>;

diff  --git a/libc/test/src/math/sincosf_test.cpp b/libc/test/src/math/sincosf_test.cpp
index 7254c3be5b75f3..2823110331f302 100644
--- a/libc/test/src/math/sincosf_test.cpp
+++ b/libc/test/src/math/sincosf_test.cpp
@@ -15,7 +15,6 @@
 #include "test/src/math/sdcomp26094.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcSinCosfTest = LIBC_NAMESPACE::testing::FPTest<float>;

diff  --git a/libc/test/src/math/sinf_test.cpp b/libc/test/src/math/sinf_test.cpp
index 370362639490b4..8fd3ed1577ceeb 100644
--- a/libc/test/src/math/sinf_test.cpp
+++ b/libc/test/src/math/sinf_test.cpp
@@ -15,7 +15,6 @@
 #include "test/src/math/sdcomp26094.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcSinfTest = LIBC_NAMESPACE::testing::FPTest<float>;

diff  --git a/libc/test/src/math/sinhf_test.cpp b/libc/test/src/math/sinhf_test.cpp
index 400df2f18dabc9..6867c7aec57dff 100644
--- a/libc/test/src/math/sinhf_test.cpp
+++ b/libc/test/src/math/sinhf_test.cpp
@@ -15,7 +15,6 @@
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcSinhfTest = LIBC_NAMESPACE::testing::FPTest<float>;

diff  --git a/libc/test/src/math/smoke/RoundToIntegerTest.h b/libc/test/src/math/smoke/RoundToIntegerTest.h
index 8b5f678b32449f..6ae97ce35a0d63 100644
--- a/libc/test/src/math/smoke/RoundToIntegerTest.h
+++ b/libc/test/src/math/smoke/RoundToIntegerTest.h
@@ -17,7 +17,6 @@
 #include "test/UnitTest/Test.h"
 
 #include "hdr/math_macros.h"
-#include <errno.h>
 
 static constexpr int ROUNDING_MODES[4] = {FE_UPWARD, FE_DOWNWARD, FE_TOWARDZERO,
                                           FE_TONEAREST};

diff  --git a/libc/test/src/math/smoke/acosf_test.cpp b/libc/test/src/math/smoke/acosf_test.cpp
index 732c29548c60d3..039d8c2013830d 100644
--- a/libc/test/src/math/smoke/acosf_test.cpp
+++ b/libc/test/src/math/smoke/acosf_test.cpp
@@ -13,7 +13,6 @@
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcAcosfTest = LIBC_NAMESPACE::testing::FPTest<float>;

diff  --git a/libc/test/src/math/smoke/acoshf_test.cpp b/libc/test/src/math/smoke/acoshf_test.cpp
index 2e94216ede364b..91d433df80558d 100644
--- a/libc/test/src/math/smoke/acoshf_test.cpp
+++ b/libc/test/src/math/smoke/acoshf_test.cpp
@@ -13,7 +13,6 @@
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcAcoshfTest = LIBC_NAMESPACE::testing::FPTest<float>;

diff  --git a/libc/test/src/math/smoke/asinf_test.cpp b/libc/test/src/math/smoke/asinf_test.cpp
index c67d07711cd132..450255ccd3020d 100644
--- a/libc/test/src/math/smoke/asinf_test.cpp
+++ b/libc/test/src/math/smoke/asinf_test.cpp
@@ -13,7 +13,6 @@
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcAsinfTest = LIBC_NAMESPACE::testing::FPTest<float>;

diff  --git a/libc/test/src/math/smoke/asinhf_test.cpp b/libc/test/src/math/smoke/asinhf_test.cpp
index f95184676303d6..a8e54f379a1fd0 100644
--- a/libc/test/src/math/smoke/asinhf_test.cpp
+++ b/libc/test/src/math/smoke/asinhf_test.cpp
@@ -13,7 +13,6 @@
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcAsinhfTest = LIBC_NAMESPACE::testing::FPTest<float>;

diff  --git a/libc/test/src/math/smoke/atanf_test.cpp b/libc/test/src/math/smoke/atanf_test.cpp
index 56bf2f951b3361..0fe11d79533810 100644
--- a/libc/test/src/math/smoke/atanf_test.cpp
+++ b/libc/test/src/math/smoke/atanf_test.cpp
@@ -13,7 +13,6 @@
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcAtanfTest = LIBC_NAMESPACE::testing::FPTest<float>;

diff  --git a/libc/test/src/math/smoke/atanhf_test.cpp b/libc/test/src/math/smoke/atanhf_test.cpp
index fa07b62e9f43f5..e22926bd2f0376 100644
--- a/libc/test/src/math/smoke/atanhf_test.cpp
+++ b/libc/test/src/math/smoke/atanhf_test.cpp
@@ -13,7 +13,6 @@
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LIBC_NAMESPACE::Sign;

diff  --git a/libc/test/src/math/smoke/cosf_test.cpp b/libc/test/src/math/smoke/cosf_test.cpp
index 7000fe2f2b07de..62f7ede9cf1781 100644
--- a/libc/test/src/math/smoke/cosf_test.cpp
+++ b/libc/test/src/math/smoke/cosf_test.cpp
@@ -13,7 +13,6 @@
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcCosfTest = LIBC_NAMESPACE::testing::FPTest<float>;

diff  --git a/libc/test/src/math/smoke/coshf_test.cpp b/libc/test/src/math/smoke/coshf_test.cpp
index 4d915b12dee164..ddaa19f4c392f7 100644
--- a/libc/test/src/math/smoke/coshf_test.cpp
+++ b/libc/test/src/math/smoke/coshf_test.cpp
@@ -14,7 +14,6 @@
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcCoshfTest = LIBC_NAMESPACE::testing::FPTest<float>;

diff  --git a/libc/test/src/math/smoke/erff_test.cpp b/libc/test/src/math/smoke/erff_test.cpp
index 102126ee4e23fe..8a970f3a4b7ed1 100644
--- a/libc/test/src/math/smoke/erff_test.cpp
+++ b/libc/test/src/math/smoke/erff_test.cpp
@@ -12,7 +12,6 @@
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcErffTest = LIBC_NAMESPACE::testing::FPTest<float>;

diff  --git a/libc/test/src/math/smoke/exp10_test.cpp b/libc/test/src/math/smoke/exp10_test.cpp
index 7154cb176038c2..282ddc987b4993 100644
--- a/libc/test/src/math/smoke/exp10_test.cpp
+++ b/libc/test/src/math/smoke/exp10_test.cpp
@@ -13,7 +13,6 @@
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcExp10Test = LIBC_NAMESPACE::testing::FPTest<double>;

diff  --git a/libc/test/src/math/smoke/exp2_test.cpp b/libc/test/src/math/smoke/exp2_test.cpp
index a8ef6cfa7f6a12..d148d27fad38dc 100644
--- a/libc/test/src/math/smoke/exp2_test.cpp
+++ b/libc/test/src/math/smoke/exp2_test.cpp
@@ -13,7 +13,6 @@
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcExp2Test = LIBC_NAMESPACE::testing::FPTest<double>;

diff  --git a/libc/test/src/math/smoke/exp_test.cpp b/libc/test/src/math/smoke/exp_test.cpp
index 2abaa7230831f2..5fe6f3e92f4a6a 100644
--- a/libc/test/src/math/smoke/exp_test.cpp
+++ b/libc/test/src/math/smoke/exp_test.cpp
@@ -13,7 +13,6 @@
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcExpTest = LIBC_NAMESPACE::testing::FPTest<double>;

diff  --git a/libc/test/src/math/smoke/expm1_test.cpp b/libc/test/src/math/smoke/expm1_test.cpp
index d5f166d53a50eb..bafdbda8af03bd 100644
--- a/libc/test/src/math/smoke/expm1_test.cpp
+++ b/libc/test/src/math/smoke/expm1_test.cpp
@@ -13,7 +13,6 @@
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcExpm1Test = LIBC_NAMESPACE::testing::FPTest<double>;

diff  --git a/libc/test/src/math/smoke/log10_test.cpp b/libc/test/src/math/smoke/log10_test.cpp
index 37baf89128f2ec..e03416ae20c8f3 100644
--- a/libc/test/src/math/smoke/log10_test.cpp
+++ b/libc/test/src/math/smoke/log10_test.cpp
@@ -13,7 +13,6 @@
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcLog10Test = LIBC_NAMESPACE::testing::FPTest<double>;

diff  --git a/libc/test/src/math/smoke/log10f_test.cpp b/libc/test/src/math/smoke/log10f_test.cpp
index 721045d355da8c..2524545e018123 100644
--- a/libc/test/src/math/smoke/log10f_test.cpp
+++ b/libc/test/src/math/smoke/log10f_test.cpp
@@ -12,7 +12,6 @@
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcLog10fTest = LIBC_NAMESPACE::testing::FPTest<float>;

diff  --git a/libc/test/src/math/smoke/log1p_test.cpp b/libc/test/src/math/smoke/log1p_test.cpp
index 993dbf8001df86..63237f3259b215 100644
--- a/libc/test/src/math/smoke/log1p_test.cpp
+++ b/libc/test/src/math/smoke/log1p_test.cpp
@@ -13,7 +13,6 @@
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcLog1pTest = LIBC_NAMESPACE::testing::FPTest<double>;

diff  --git a/libc/test/src/math/smoke/log1pf_test.cpp b/libc/test/src/math/smoke/log1pf_test.cpp
index 6127cc89a74216..c14d6552946979 100644
--- a/libc/test/src/math/smoke/log1pf_test.cpp
+++ b/libc/test/src/math/smoke/log1pf_test.cpp
@@ -13,7 +13,6 @@
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcLog1pfTest = LIBC_NAMESPACE::testing::FPTest<float>;

diff  --git a/libc/test/src/math/smoke/log2_test.cpp b/libc/test/src/math/smoke/log2_test.cpp
index b59767e668eb61..89d8e565109118 100644
--- a/libc/test/src/math/smoke/log2_test.cpp
+++ b/libc/test/src/math/smoke/log2_test.cpp
@@ -13,7 +13,6 @@
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcLog2Test = LIBC_NAMESPACE::testing::FPTest<double>;

diff  --git a/libc/test/src/math/smoke/log_test.cpp b/libc/test/src/math/smoke/log_test.cpp
index fd527dee50847c..e7897add575fad 100644
--- a/libc/test/src/math/smoke/log_test.cpp
+++ b/libc/test/src/math/smoke/log_test.cpp
@@ -13,7 +13,6 @@
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcLogTest = LIBC_NAMESPACE::testing::FPTest<double>;

diff  --git a/libc/test/src/math/smoke/powf_test.cpp b/libc/test/src/math/smoke/powf_test.cpp
index 6aa1ac2b661be2..bd4f98e30fbdc7 100644
--- a/libc/test/src/math/smoke/powf_test.cpp
+++ b/libc/test/src/math/smoke/powf_test.cpp
@@ -12,7 +12,6 @@
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcPowfTest = LIBC_NAMESPACE::testing::FPTest<float>;

diff  --git a/libc/test/src/math/smoke/sincosf_test.cpp b/libc/test/src/math/smoke/sincosf_test.cpp
index 8c35953240d8da..e6896ca3dc21ac 100644
--- a/libc/test/src/math/smoke/sincosf_test.cpp
+++ b/libc/test/src/math/smoke/sincosf_test.cpp
@@ -13,7 +13,6 @@
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcSinCosfTest = LIBC_NAMESPACE::testing::FPTest<float>;

diff  --git a/libc/test/src/math/smoke/sinf_test.cpp b/libc/test/src/math/smoke/sinf_test.cpp
index 9fc208dd545b2d..1bf6eaa8b78d7d 100644
--- a/libc/test/src/math/smoke/sinf_test.cpp
+++ b/libc/test/src/math/smoke/sinf_test.cpp
@@ -13,7 +13,6 @@
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcSinfTest = LIBC_NAMESPACE::testing::FPTest<float>;

diff  --git a/libc/test/src/math/smoke/sinhf_test.cpp b/libc/test/src/math/smoke/sinhf_test.cpp
index 1e052988eb2862..635a10627a2109 100644
--- a/libc/test/src/math/smoke/sinhf_test.cpp
+++ b/libc/test/src/math/smoke/sinhf_test.cpp
@@ -14,7 +14,6 @@
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcSinhfTest = LIBC_NAMESPACE::testing::FPTest<float>;

diff  --git a/libc/test/src/math/smoke/tanf_test.cpp b/libc/test/src/math/smoke/tanf_test.cpp
index ab3f7c1aeb7e4e..b90c5da8741892 100644
--- a/libc/test/src/math/smoke/tanf_test.cpp
+++ b/libc/test/src/math/smoke/tanf_test.cpp
@@ -13,7 +13,6 @@
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcTanfTest = LIBC_NAMESPACE::testing::FPTest<float>;

diff  --git a/libc/test/src/math/smoke/tanhf_test.cpp b/libc/test/src/math/smoke/tanhf_test.cpp
index ddae021d2bc423..748e6fe8c62693 100644
--- a/libc/test/src/math/smoke/tanhf_test.cpp
+++ b/libc/test/src/math/smoke/tanhf_test.cpp
@@ -13,7 +13,6 @@
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcTanhfTest = LIBC_NAMESPACE::testing::FPTest<float>;

diff  --git a/libc/test/src/math/tanf_test.cpp b/libc/test/src/math/tanf_test.cpp
index 9b9e1278cf5636..9061cf6fb30b82 100644
--- a/libc/test/src/math/tanf_test.cpp
+++ b/libc/test/src/math/tanf_test.cpp
@@ -15,7 +15,6 @@
 #include "test/src/math/sdcomp26094.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcTanfTest = LIBC_NAMESPACE::testing::FPTest<float>;

diff  --git a/libc/test/src/math/tanhf_test.cpp b/libc/test/src/math/tanhf_test.cpp
index 2e74984ad9549f..389abe4d858979 100644
--- a/libc/test/src/math/tanhf_test.cpp
+++ b/libc/test/src/math/tanhf_test.cpp
@@ -14,7 +14,6 @@
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include <errno.h>
 #include <stdint.h>
 
 using LlvmLibcTanhfTest = LIBC_NAMESPACE::testing::FPTest<float>;

diff  --git a/libc/test/src/pthread/CMakeLists.txt b/libc/test/src/pthread/CMakeLists.txt
index 0eeec445d5f49c..2cb80e2b6ae2e9 100644
--- a/libc/test/src/pthread/CMakeLists.txt
+++ b/libc/test/src/pthread/CMakeLists.txt
@@ -7,7 +7,6 @@ add_libc_unittest(
   SRCS
     pthread_attr_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.pthread
     libc.src.pthread.pthread_attr_destroy
     libc.src.pthread.pthread_attr_init
@@ -19,6 +18,7 @@ add_libc_unittest(
     libc.src.pthread.pthread_attr_setguardsize
     libc.src.pthread.pthread_attr_setstacksize
     libc.src.pthread.pthread_attr_setstack
+    libc.hdr.errno_macros
 )
 
 add_libc_unittest(
@@ -28,7 +28,6 @@ add_libc_unittest(
   SRCS
     pthread_mutexattr_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.pthread
     libc.src.pthread.pthread_mutexattr_destroy
     libc.src.pthread.pthread_mutexattr_init
@@ -38,6 +37,7 @@ add_libc_unittest(
     libc.src.pthread.pthread_mutexattr_setpshared
     libc.src.pthread.pthread_mutexattr_setrobust
     libc.src.pthread.pthread_mutexattr_settype
+    libc.hdr.errno_macros
 )
 
 add_libc_unittest(
@@ -65,8 +65,8 @@ add_libc_unittest(
   SRCS
     pthread_rwlockattr_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.pthread
+    libc.src.errno.errno
     libc.src.pthread.pthread_rwlockattr_destroy
     libc.src.pthread.pthread_rwlockattr_getkind_np
     libc.src.pthread.pthread_rwlockattr_getpshared

diff  --git a/libc/test/src/pthread/pthread_attr_test.cpp b/libc/test/src/pthread/pthread_attr_test.cpp
index 1af585a003e3b0..bee9a1ca4f893a 100644
--- a/libc/test/src/pthread/pthread_attr_test.cpp
+++ b/libc/test/src/pthread/pthread_attr_test.cpp
@@ -6,6 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "hdr/errno_macros.h"
 #include "src/pthread/pthread_attr_destroy.h"
 #include "src/pthread/pthread_attr_getdetachstate.h"
 #include "src/pthread/pthread_attr_getguardsize.h"
@@ -19,7 +20,6 @@
 
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
 #include <linux/param.h> // For EXEC_PAGESIZE.
 #include <pthread.h>
 

diff  --git a/libc/test/src/pthread/pthread_mutexattr_test.cpp b/libc/test/src/pthread/pthread_mutexattr_test.cpp
index a7acd580a6b8e5..7fbdd2efd9858e 100644
--- a/libc/test/src/pthread/pthread_mutexattr_test.cpp
+++ b/libc/test/src/pthread/pthread_mutexattr_test.cpp
@@ -6,6 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "hdr/errno_macros.h"
 #include "src/pthread/pthread_mutexattr_destroy.h"
 #include "src/pthread/pthread_mutexattr_getpshared.h"
 #include "src/pthread/pthread_mutexattr_getrobust.h"
@@ -15,8 +16,6 @@
 #include "src/pthread/pthread_mutexattr_setrobust.h"
 #include "src/pthread/pthread_mutexattr_settype.h"
 #include "test/UnitTest/Test.h"
-
-#include <errno.h>
 #include <pthread.h>
 
 TEST(LlvmLibcPThreadMutexAttrTest, InitAndDestroy) {

diff  --git a/libc/test/src/signal/CMakeLists.txt b/libc/test/src/signal/CMakeLists.txt
index f7923204eaf499..87aa42faae8e5f 100644
--- a/libc/test/src/signal/CMakeLists.txt
+++ b/libc/test/src/signal/CMakeLists.txt
@@ -61,8 +61,8 @@ add_libc_unittest(
   SRCS
     sigaddset_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.signal
+    libc.src.errno.errno 
     libc.src.signal.sigaddset
     libc.test.UnitTest.ErrnoSetterMatcher
 )
@@ -88,8 +88,8 @@ add_libc_unittest(
   SRCS
     sigfillset_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.signal
+    libc.src.errno.errno 
     libc.src.signal.raise
     libc.src.signal.sigfillset
     libc.src.signal.sigprocmask
@@ -103,8 +103,8 @@ add_libc_unittest(
   SRCS
     sigdelset_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.signal
+    libc.src.errno.errno 
     libc.src.signal.raise
     libc.src.signal.sigdelset
     libc.src.signal.sigfillset

diff  --git a/libc/test/src/signal/sigaddset_test.cpp b/libc/test/src/signal/sigaddset_test.cpp
index ac9334f4ff68c0..bc33750cf787d7 100644
--- a/libc/test/src/signal/sigaddset_test.cpp
+++ b/libc/test/src/signal/sigaddset_test.cpp
@@ -11,7 +11,6 @@
 #include "test/UnitTest/ErrnoSetterMatcher.h"
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
 #include <signal.h>
 
 // This tests invalid inputs and ensures errno is properly set.

diff  --git a/libc/test/src/signal/sigdelset_test.cpp b/libc/test/src/signal/sigdelset_test.cpp
index aeae66f86bf886..622f1a32fbbe9a 100644
--- a/libc/test/src/signal/sigdelset_test.cpp
+++ b/libc/test/src/signal/sigdelset_test.cpp
@@ -14,7 +14,6 @@
 #include "test/UnitTest/ErrnoSetterMatcher.h"
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
 #include <signal.h>
 
 TEST(LlvmLibcSigdelset, Invalid) {

diff  --git a/libc/test/src/signal/sigfillset_test.cpp b/libc/test/src/signal/sigfillset_test.cpp
index 7922b3a4e11902..0604bc2a95bf6f 100644
--- a/libc/test/src/signal/sigfillset_test.cpp
+++ b/libc/test/src/signal/sigfillset_test.cpp
@@ -13,7 +13,6 @@
 #include "test/UnitTest/ErrnoSetterMatcher.h"
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
 #include <signal.h>
 
 TEST(LlvmLibcSigfillset, Invalid) {

diff  --git a/libc/test/src/spawn/CMakeLists.txt b/libc/test/src/spawn/CMakeLists.txt
index 39b63df1908494..ce246d4a1b7749 100644
--- a/libc/test/src/spawn/CMakeLists.txt
+++ b/libc/test/src/spawn/CMakeLists.txt
@@ -7,7 +7,6 @@ add_libc_unittest(
   SRCS
     posix_spawn_file_actions_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.spawn
     libc.src.spawn.file_actions
     libc.src.spawn.posix_spawn_file_actions_addclose
@@ -15,4 +14,5 @@ add_libc_unittest(
     libc.src.spawn.posix_spawn_file_actions_addopen
     libc.src.spawn.posix_spawn_file_actions_destroy
     libc.src.spawn.posix_spawn_file_actions_init
+    libc.src.errno.errno
 )

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 008167e07221f4..c1edf56bdbd87c 100644
--- a/libc/test/src/spawn/posix_spawn_file_actions_test.cpp
+++ b/libc/test/src/spawn/posix_spawn_file_actions_test.cpp
@@ -6,6 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "src/errno/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"
@@ -14,7 +15,6 @@
 #include "src/spawn/posix_spawn_file_actions_init.h"
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
 #include <spawn.h>
 #include <stdint.h>
 

diff  --git a/libc/test/src/sys/prctl/linux/CMakeLists.txt b/libc/test/src/sys/prctl/linux/CMakeLists.txt
index 25e9b8fd8a0070..845452c9099eb1 100644
--- a/libc/test/src/sys/prctl/linux/CMakeLists.txt
+++ b/libc/test/src/sys/prctl/linux/CMakeLists.txt
@@ -8,7 +8,6 @@ add_libc_unittest(
     prctl_test.cpp
   DEPENDS
     libc.include.sys_prctl
-    libc.include.errno
     libc.src.sys.prctl.prctl
     libc.src.errno.errno
 )

diff  --git a/libc/test/src/sys/prctl/linux/prctl_test.cpp b/libc/test/src/sys/prctl/linux/prctl_test.cpp
index b528edc65595d8..987c35d5534707 100644
--- a/libc/test/src/sys/prctl/linux/prctl_test.cpp
+++ b/libc/test/src/sys/prctl/linux/prctl_test.cpp
@@ -9,7 +9,6 @@
 #include "src/errno/libc_errno.h"
 #include "src/sys/prctl/prctl.h"
 #include "test/UnitTest/ErrnoSetterMatcher.h"
-#include <errno.h>
 #include <sys/prctl.h>
 
 using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;

diff  --git a/libc/test/src/sys/resource/CMakeLists.txt b/libc/test/src/sys/resource/CMakeLists.txt
index 90dc0e846df6d9..32186de4b111be 100644
--- a/libc/test/src/sys/resource/CMakeLists.txt
+++ b/libc/test/src/sys/resource/CMakeLists.txt
@@ -9,9 +9,9 @@ add_libc_unittest(
   SRCS
     getrlimit_setrlimit_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.fcntl
     libc.include.sys_resource
+    libc.src.errno.errno 
     libc.src.fcntl.open
     libc.src.sys.resource.getrlimit
     libc.src.sys.resource.setrlimit

diff  --git a/libc/test/src/sys/select/CMakeLists.txt b/libc/test/src/sys/select/CMakeLists.txt
index c2d57052c38376..2b465d32c2c33e 100644
--- a/libc/test/src/sys/select/CMakeLists.txt
+++ b/libc/test/src/sys/select/CMakeLists.txt
@@ -8,8 +8,8 @@ add_libc_unittest(
   SRCS
     select_ui_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.unistd
+    libc.src.errno.errno 
     libc.src.sys.select.select
     libc.src.unistd.read
 )
@@ -21,8 +21,8 @@ add_libc_unittest(
   SRCS
     select_failure_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.unistd
+    libc.src.errno.errno 
     libc.src.sys.select.select
     libc.src.unistd.read
     libc.test.UnitTest.ErrnoSetterMatcher

diff  --git a/libc/test/src/sys/select/select_failure_test.cpp b/libc/test/src/sys/select/select_failure_test.cpp
index 61df532b3e96cc..a4990bfd4b1b53 100644
--- a/libc/test/src/sys/select/select_failure_test.cpp
+++ b/libc/test/src/sys/select/select_failure_test.cpp
@@ -11,7 +11,6 @@
 #include "test/UnitTest/ErrnoSetterMatcher.h"
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
 #include <sys/select.h>
 #include <unistd.h>
 

diff  --git a/libc/test/src/sys/sendfile/CMakeLists.txt b/libc/test/src/sys/sendfile/CMakeLists.txt
index 57dac4accd8286..82efaa147bd89d 100644
--- a/libc/test/src/sys/sendfile/CMakeLists.txt
+++ b/libc/test/src/sys/sendfile/CMakeLists.txt
@@ -9,9 +9,9 @@ add_libc_unittest(
   SRCS
     sendfile_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.fcntl
     libc.include.sys_stat
+    libc.src.errno.errno 
     libc.src.fcntl.open
     libc.src.sys.sendfile.sendfile
     libc.src.unistd.close

diff  --git a/libc/test/src/sys/utsname/CMakeLists.txt b/libc/test/src/sys/utsname/CMakeLists.txt
index 435c190cc6212d..3640fc3bc5e251 100644
--- a/libc/test/src/sys/utsname/CMakeLists.txt
+++ b/libc/test/src/sys/utsname/CMakeLists.txt
@@ -7,8 +7,8 @@ add_libc_unittest(
   SRCS
     uname_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.sys_utsname
+    libc.src.errno.errno
     libc.src.__support.common
     libc.src.sys.utsname.uname
     libc.test.UnitTest.ErrnoSetterMatcher

diff  --git a/libc/test/src/sys/utsname/uname_test.cpp b/libc/test/src/sys/utsname/uname_test.cpp
index 79822c112a5b6b..6452021bd6c358 100644
--- a/libc/test/src/sys/utsname/uname_test.cpp
+++ b/libc/test/src/sys/utsname/uname_test.cpp
@@ -12,7 +12,6 @@
 #include "test/UnitTest/ErrnoSetterMatcher.h"
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
 #include <sys/utsname.h>
 
 TEST(LlvmLibcUnameTest, GetMachineName) {

diff  --git a/libc/test/src/sys/wait/CMakeLists.txt b/libc/test/src/sys/wait/CMakeLists.txt
index 4ba1a939d6a8e5..db737a46f0d0f3 100644
--- a/libc/test/src/sys/wait/CMakeLists.txt
+++ b/libc/test/src/sys/wait/CMakeLists.txt
@@ -7,8 +7,8 @@ add_libc_unittest(
   SRCS
     waitpid_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.sys_wait
+    libc.src.errno.errno 
     libc.src.sys.wait.waitpid
 )
 
@@ -19,7 +19,7 @@ add_libc_unittest(
   SRCS
     wait4_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.sys_wait
+    libc.src.errno.errno 
     libc.src.sys.wait.wait4
 )

diff  --git a/libc/test/src/sys/wait/wait4_test.cpp b/libc/test/src/sys/wait/wait4_test.cpp
index 70d4d436927e6b..c4080047ee38f8 100644
--- a/libc/test/src/sys/wait/wait4_test.cpp
+++ b/libc/test/src/sys/wait/wait4_test.cpp
@@ -10,7 +10,6 @@
 #include "test/UnitTest/ErrnoSetterMatcher.h"
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
 #include <sys/wait.h>
 
 // The test here is a simpl test for WNOHANG functionality. For a more

diff  --git a/libc/test/src/sys/wait/waitpid_test.cpp b/libc/test/src/sys/wait/waitpid_test.cpp
index b2ace2617d2d3f..fb456bfaedc7df 100644
--- a/libc/test/src/sys/wait/waitpid_test.cpp
+++ b/libc/test/src/sys/wait/waitpid_test.cpp
@@ -10,7 +10,6 @@
 #include "test/UnitTest/ErrnoSetterMatcher.h"
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
 #include <sys/wait.h>
 
 // The test here is a simpl test for WNOHANG functionality. For a more

diff  --git a/libc/test/src/unistd/CMakeLists.txt b/libc/test/src/unistd/CMakeLists.txt
index 332455b791aee5..e03e56b3cf8ad7 100644
--- a/libc/test/src/unistd/CMakeLists.txt
+++ b/libc/test/src/unistd/CMakeLists.txt
@@ -39,7 +39,6 @@ add_libc_unittest(
   SRCS
     dup_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.unistd
     libc.src.errno.errno
     libc.src.fcntl.open
@@ -58,7 +57,6 @@ add_libc_unittest(
   SRCS
     dup2_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.unistd
     libc.src.errno.errno
     libc.src.fcntl.open
@@ -77,7 +75,6 @@ add_libc_unittest(
   SRCS
     dup3_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.unistd
     libc.src.errno.errno
     libc.src.fcntl.open
@@ -96,7 +93,6 @@ add_libc_unittest(
   SRCS
     fchdir_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.unistd
     libc.src.errno.errno
     libc.src.fcntl.open
@@ -112,7 +108,6 @@ add_libc_unittest(
   SRCS
     ftruncate_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.unistd
     libc.src.errno.errno
     libc.src.fcntl.open
@@ -131,7 +126,6 @@ add_libc_unittest(
   SRCS
     pread_pwrite_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.unistd
     libc.src.errno.errno
     libc.src.fcntl.open
@@ -151,7 +145,6 @@ add_libc_unittest(
   SRCS
     read_write_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.unistd
     libc.src.errno.errno
     libc.src.fcntl.open
@@ -170,7 +163,6 @@ add_libc_unittest(
   SRCS
     link_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.unistd
     libc.src.errno.errno
     libc.src.fcntl.open
@@ -186,7 +178,6 @@ add_libc_unittest(
   SRCS
     linkat_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.unistd
     libc.src.errno.errno
     libc.src.fcntl.open
@@ -202,7 +193,6 @@ add_libc_unittest(
   SRCS
     lseek_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.unistd
     libc.src.errno.errno
     libc.src.fcntl.open
@@ -219,7 +209,6 @@ add_libc_unittest(
   SRCS
     pipe_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.unistd
     libc.src.errno.errno
     libc.src.unistd.close
@@ -234,7 +223,6 @@ add_libc_unittest(
   SRCS
     rmdir_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.fcntl
     libc.src.errno.errno
     libc.src.sys.stat.mkdir
@@ -258,7 +246,6 @@ add_libc_unittest(
   SRCS
     readlink_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.unistd
     libc.src.errno.errno
     libc.src.unistd.readlink
@@ -275,7 +262,6 @@ add_libc_unittest(
   SRCS
     readlinkat_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.fcntl
     libc.include.unistd
     libc.src.errno.errno
@@ -293,7 +279,6 @@ add_libc_unittest(
   SRCS
     symlink_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.unistd
     libc.src.errno.errno
     libc.src.fcntl.open
@@ -309,7 +294,6 @@ add_libc_unittest(
   SRCS
     symlinkat_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.unistd
     libc.src.errno.errno
     libc.src.fcntl.open
@@ -325,7 +309,6 @@ add_libc_unittest(
   SRCS
     truncate_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.unistd
     libc.src.errno.errno
     libc.src.fcntl.open
@@ -344,7 +327,6 @@ add_libc_unittest(
   SRCS
     unlink_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.unistd
     libc.src.errno.errno
     libc.src.fcntl.open
@@ -359,7 +341,6 @@ add_libc_unittest(
   SRCS
     unlinkat_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.unistd
     libc.src.errno.errno
     libc.src.fcntl.open
@@ -428,10 +409,10 @@ add_libc_unittest(
   SRCS
     syscall_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.unistd
     libc.include.fcntl
     libc.include.sys_syscall
+    libc.src.errno.errno 
     libc.src.unistd.__llvm_libc_syscall
     libc.test.UnitTest.ErrnoSetterMatcher
 )


        


More information about the libc-commits mailing list