[libc-commits] [libc] b790c5c - [libc] Remove #include <sys/whatever.h> (#209449)
via libc-commits
libc-commits at lists.llvm.org
Wed Jul 15 00:50:32 PDT 2026
Author: Pavel Labath
Date: 2026-07-15T07:50:27Z
New Revision: b790c5cd267974456806773f01dfb8936b22e4f2
URL: https://github.com/llvm/llvm-project/commit/b790c5cd267974456806773f01dfb8936b22e4f2
DIFF: https://github.com/llvm/llvm-project/commit/b790c5cd267974456806773f01dfb8936b22e4f2.diff
LOG: [libc] Remove #include <sys/whatever.h> (#209449)
and replace with granular includes of type/macro proxy headers -- where
those headers exist. I'm leaving the creation of new proxy headers for
another patch.
Assisted by Gemini.
Added:
Modified:
libc/src/__support/File/linux/CMakeLists.txt
libc/src/__support/File/linux/file.cpp
libc/src/pthread/CMakeLists.txt
libc/src/pthread/pthread_condattr_getclock.cpp
libc/src/pthread/pthread_condattr_getclock.h
libc/src/pthread/pthread_condattr_setclock.cpp
libc/src/pthread/pthread_condattr_setclock.h
libc/src/sys/prctl/linux/CMakeLists.txt
libc/src/sys/prctl/prctl.h
libc/src/sys/random/getrandom.h
libc/src/sys/random/linux/CMakeLists.txt
libc/src/sys/resource/getrlimit.h
libc/src/sys/resource/linux/CMakeLists.txt
libc/src/sys/resource/setrlimit.h
libc/src/sys/sendfile/linux/CMakeLists.txt
libc/src/sys/sendfile/linux/sendfile.cpp
libc/src/sys/sendfile/sendfile.h
libc/src/sys/socket/linux/CMakeLists.txt
libc/src/sys/socket/recv.h
libc/src/sys/socket/send.h
libc/src/sys/wait/linux/CMakeLists.txt
libc/src/sys/wait/wait.h
libc/src/sys/wait/waitpid.h
libc/src/unistd/linux/CMakeLists.txt
libc/src/unistd/linux/isatty.cpp
libc/startup/linux/CMakeLists.txt
libc/startup/linux/do_start.cpp
libc/test/integration/src/sys/ptrace/linux/ptrace_test.cpp
libc/test/src/fcntl/CMakeLists.txt
libc/test/src/fcntl/creat_test.cpp
libc/test/src/fcntl/fcntl_test.cpp
libc/test/src/stdio/CMakeLists.txt
libc/test/src/stdio/fdopen_test.cpp
libc/test/src/string/memory_utils/protected_pages.h
libc/test/src/sys/auxv/linux/CMakeLists.txt
libc/test/src/sys/auxv/linux/getauxval_test.cpp
libc/test/src/sys/mman/linux/CMakeLists.txt
libc/test/src/sys/mman/linux/mlock_test.cpp
libc/test/src/sys/mman/linux/mprotect_test.cpp
libc/test/src/sys/mman/linux/posix_madvise_test.cpp
libc/test/src/sys/mman/linux/remap_file_pages_test.cpp
libc/test/src/sys/resource/CMakeLists.txt
libc/test/src/sys/resource/getrlimit_setrlimit_test.cpp
libc/test/src/sys/sendfile/CMakeLists.txt
libc/test/src/sys/sendfile/sendfile_test.cpp
libc/test/src/sys/socket/linux/CMakeLists.txt
libc/test/src/sys/socket/linux/sendto_recvfrom_test.cpp
libc/test/src/sys/socket/linux/socket_test.cpp
libc/test/src/sys/socket/linux/socketopt_test.cpp
libc/test/src/sys/socket/linux/socketpair_test.cpp
libc/test/src/sys/stat/CMakeLists.txt
libc/test/src/sys/stat/chmod_test.cpp
libc/test/src/sys/stat/fchmod_test.cpp
libc/test/src/sys/stat/fchmodat_test.cpp
libc/test/src/sys/stat/fstat_test.cpp
libc/test/src/sys/stat/lstat_test.cpp
libc/test/src/sys/stat/stat_test.cpp
libc/test/src/unistd/CMakeLists.txt
libc/test/src/unistd/access_test.cpp
libc/test/src/unistd/chown_test.cpp
libc/test/src/unistd/dup2_test.cpp
libc/test/src/unistd/dup3_test.cpp
libc/test/src/unistd/dup_test.cpp
libc/test/src/unistd/faccessat_test.cpp
libc/test/src/unistd/fchown_test.cpp
libc/test/src/unistd/ftruncate_test.cpp
libc/test/src/unistd/isatty_test.cpp
libc/test/src/unistd/link_test.cpp
libc/test/src/unistd/linkat_test.cpp
libc/test/src/unistd/pread_pwrite_test.cpp
libc/test/src/unistd/read_write_test.cpp
libc/test/src/unistd/symlink_test.cpp
libc/test/src/unistd/symlinkat_test.cpp
libc/test/src/unistd/syscall_test.cpp
libc/test/src/unistd/truncate_test.cpp
libc/test/src/unistd/unlink_test.cpp
libc/test/src/unistd/unlinkat_test.cpp
Removed:
################################################################################
diff --git a/libc/src/__support/File/linux/CMakeLists.txt b/libc/src/__support/File/linux/CMakeLists.txt
index 76ba4bd062446..87ee7423a3627 100644
--- a/libc/src/__support/File/linux/CMakeLists.txt
+++ b/libc/src/__support/File/linux/CMakeLists.txt
@@ -8,9 +8,10 @@ add_object_library(
DEPENDS
libc.hdr.fcntl_macros
libc.hdr.stdio_macros
+ libc.hdr.sys_stat_macros
libc.hdr.types.FILE
+ libc.hdr.types.off_t
libc.include.sys_syscall
- libc.include.sys_stat
libc.src.__support.CPP.new
libc.src.__support.OSUtil.osutil
libc.src.__support.OSUtil.linux.syscall_wrappers.fcntl
diff --git a/libc/src/__support/File/linux/file.cpp b/libc/src/__support/File/linux/file.cpp
index 82395f9774ca7..61735e1530863 100644
--- a/libc/src/__support/File/linux/file.cpp
+++ b/libc/src/__support/File/linux/file.cpp
@@ -8,7 +8,9 @@
#include "file.h"
+#include "hdr/fcntl_macros.h" // For mode_t and other flags to the open syscall
#include "hdr/stdio_macros.h"
+#include "hdr/sys_stat_macros.h" // For S_IS*, S_IF*, and S_IR* flags.
#include "hdr/types/off_t.h"
#include "src/__support/CPP/new.h"
#include "src/__support/File/file.h"
@@ -20,8 +22,6 @@
#include "src/__support/libc_errno.h" // For error macros
#include "src/__support/macros/config.h"
-#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.
#include <sys/syscall.h> // For syscall numbers
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/pthread/CMakeLists.txt b/libc/src/pthread/CMakeLists.txt
index 7901d5ce67a5e..422116c978fb5 100644
--- a/libc/src/pthread/CMakeLists.txt
+++ b/libc/src/pthread/CMakeLists.txt
@@ -143,7 +143,7 @@ add_entrypoint_object(
pthread_condattr_getclock.h
DEPENDS
libc.include.pthread
- libc.include.sys_types
+ libc.hdr.types.clockid_t
)
add_entrypoint_object(
@@ -174,8 +174,9 @@ add_entrypoint_object(
HDRS
pthread_condattr_setclock.h
DEPENDS
+ libc.hdr.time_macros
+ libc.hdr.types.clockid_t
libc.include.pthread
- libc.include.sys_types
libc.include.time
libc.src.errno.errno
)
diff --git a/libc/src/pthread/pthread_condattr_getclock.cpp b/libc/src/pthread/pthread_condattr_getclock.cpp
index 75fd9308c7b8d..56d66afd4bf9a 100644
--- a/libc/src/pthread/pthread_condattr_getclock.cpp
+++ b/libc/src/pthread/pthread_condattr_getclock.cpp
@@ -7,12 +7,11 @@
//===----------------------------------------------------------------------===//
#include "pthread_condattr_getclock.h"
-
+#include "hdr/types/clockid_t.h" // clockid_t
#include "src/__support/common.h"
#include "src/__support/macros/config.h"
-#include <pthread.h> // pthread_condattr_t
-#include <sys/types.h> // clockid_t
+#include <pthread.h> // pthread_condattr_t
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/pthread/pthread_condattr_getclock.h b/libc/src/pthread/pthread_condattr_getclock.h
index 52025b3040c1a..3b92e590306fb 100644
--- a/libc/src/pthread/pthread_condattr_getclock.h
+++ b/libc/src/pthread/pthread_condattr_getclock.h
@@ -9,9 +9,9 @@
#ifndef LLVM_LIBC_SRC_PTHREAD_PTHREAD_CONDATTR_GETCLOCK_H
#define LLVM_LIBC_SRC_PTHREAD_PTHREAD_CONDATTR_GETCLOCK_H
+#include "hdr/types/clockid_t.h" // clockid_t
#include "src/__support/macros/config.h"
-#include <pthread.h> // pthread_condattr_t
-#include <sys/types.h> // clockid_t
+#include <pthread.h> // pthread_condattr_t
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/pthread/pthread_condattr_setclock.cpp b/libc/src/pthread/pthread_condattr_setclock.cpp
index 2f63d5e9d1942..5e296ff0ec6db 100644
--- a/libc/src/pthread/pthread_condattr_setclock.cpp
+++ b/libc/src/pthread/pthread_condattr_setclock.cpp
@@ -7,14 +7,13 @@
//===----------------------------------------------------------------------===//
#include "pthread_condattr_setclock.h"
-
+#include "hdr/time_macros.h" // CLOCK_MONOTONIC, CLOCK_REALTIME
+#include "hdr/types/clockid_t.h" // clockid_t
#include "src/__support/common.h"
#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include "hdr/time_macros.h" // CLOCK_MONOTONIC, CLOCK_REALTIME
-#include <pthread.h> // pthread_condattr_t
-#include <sys/types.h> // clockid_t
+#include <pthread.h> // pthread_condattr_t
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/pthread/pthread_condattr_setclock.h b/libc/src/pthread/pthread_condattr_setclock.h
index e9fd77a2d5d5a..c69d3dc9d8dfb 100644
--- a/libc/src/pthread/pthread_condattr_setclock.h
+++ b/libc/src/pthread/pthread_condattr_setclock.h
@@ -9,9 +9,9 @@
#ifndef LLVM_LIBC_SRC_PTHREAD_PTHREAD_CONDATTR_SETCLOCK_H
#define LLVM_LIBC_SRC_PTHREAD_PTHREAD_CONDATTR_SETCLOCK_H
+#include "hdr/types/clockid_t.h" // clockid_t
#include "src/__support/macros/config.h"
#include <pthread.h>
-#include <sys/types.h> // clockid_t
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/prctl/linux/CMakeLists.txt b/libc/src/sys/prctl/linux/CMakeLists.txt
index 05d336441f4d0..735d22f83e615 100644
--- a/libc/src/sys/prctl/linux/CMakeLists.txt
+++ b/libc/src/sys/prctl/linux/CMakeLists.txt
@@ -5,7 +5,6 @@ add_entrypoint_object(
HDRS
../prctl.h
DEPENDS
- libc.include.sys_prctl
libc.include.sys_syscall
libc.src.__support.OSUtil.osutil
libc.src.errno.errno
diff --git a/libc/src/sys/prctl/prctl.h b/libc/src/sys/prctl/prctl.h
index b88c6abb7eab5..55f9fb01bee38 100644
--- a/libc/src/sys/prctl/prctl.h
+++ b/libc/src/sys/prctl/prctl.h
@@ -10,7 +10,6 @@
#define LLVM_LIBC_SRC_SYS_PRCTL_PRCTL_H
#include "src/__support/macros/config.h"
-#include <sys/prctl.h>
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/random/getrandom.h b/libc/src/sys/random/getrandom.h
index 134bd0cd9468d..52d0e17e32e63 100644
--- a/libc/src/sys/random/getrandom.h
+++ b/libc/src/sys/random/getrandom.h
@@ -9,8 +9,9 @@
#ifndef LLVM_LIBC_SRC_SYS_RANDOM_GETRANDOM_H
#define LLVM_LIBC_SRC_SYS_RANDOM_GETRANDOM_H
+#include "hdr/types/size_t.h"
+#include "hdr/types/ssize_t.h"
#include "src/__support/macros/config.h"
-#include <sys/random.h>
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/random/linux/CMakeLists.txt b/libc/src/sys/random/linux/CMakeLists.txt
index 60f6e486967ad..249de1025b173 100644
--- a/libc/src/sys/random/linux/CMakeLists.txt
+++ b/libc/src/sys/random/linux/CMakeLists.txt
@@ -5,7 +5,8 @@ add_entrypoint_object(
HDRS
../getrandom.h
DEPENDS
- libc.include.sys_random
+ libc.hdr.types.size_t
+ libc.hdr.types.ssize_t
libc.src.__support.OSUtil.linux.syscall_wrappers.getrandom
libc.src.errno.errno
)
diff --git a/libc/src/sys/resource/getrlimit.h b/libc/src/sys/resource/getrlimit.h
index c369744a5c4ba..d270c6d71c16e 100644
--- a/libc/src/sys/resource/getrlimit.h
+++ b/libc/src/sys/resource/getrlimit.h
@@ -9,8 +9,8 @@
#ifndef LLVM_LIBC_SRC_SYS_RESOURCE_GETRLIMIT_H
#define LLVM_LIBC_SRC_SYS_RESOURCE_GETRLIMIT_H
+#include "hdr/types/struct_rlimit.h"
#include "src/__support/macros/config.h"
-#include <sys/resource.h>
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/resource/linux/CMakeLists.txt b/libc/src/sys/resource/linux/CMakeLists.txt
index ac59621f96f13..3d2aa3888887c 100644
--- a/libc/src/sys/resource/linux/CMakeLists.txt
+++ b/libc/src/sys/resource/linux/CMakeLists.txt
@@ -6,7 +6,6 @@ add_entrypoint_object(
../getrlimit.h
DEPENDS
libc.hdr.types.struct_rlimit
- libc.include.sys_resource
libc.src.__support.OSUtil.linux.syscall_wrappers.prlimit
libc.src.errno.errno
)
@@ -19,7 +18,6 @@ add_entrypoint_object(
../setrlimit.h
DEPENDS
libc.hdr.types.struct_rlimit
- libc.include.sys_resource
libc.src.__support.OSUtil.linux.syscall_wrappers.prlimit
libc.src.errno.errno
)
diff --git a/libc/src/sys/resource/setrlimit.h b/libc/src/sys/resource/setrlimit.h
index 6f966791f09b8..42c25d9b29ac8 100644
--- a/libc/src/sys/resource/setrlimit.h
+++ b/libc/src/sys/resource/setrlimit.h
@@ -9,8 +9,8 @@
#ifndef LLVM_LIBC_SRC_SYS_RESOURCE_SETRLIMIT_H
#define LLVM_LIBC_SRC_SYS_RESOURCE_SETRLIMIT_H
+#include "hdr/types/struct_rlimit.h"
#include "src/__support/macros/config.h"
-#include <sys/resource.h>
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/sendfile/linux/CMakeLists.txt b/libc/src/sys/sendfile/linux/CMakeLists.txt
index f6d4fa30fb46c..2998fef2e92b4 100644
--- a/libc/src/sys/sendfile/linux/CMakeLists.txt
+++ b/libc/src/sys/sendfile/linux/CMakeLists.txt
@@ -5,7 +5,9 @@ add_entrypoint_object(
HDRS
../sendfile.h
DEPENDS
- libc.include.sys_sendfile
+ libc.hdr.types.off_t
+ libc.hdr.types.size_t
+ libc.hdr.types.ssize_t
libc.include.sys_syscall
libc.src.__support.OSUtil.osutil
libc.src.errno.errno
diff --git a/libc/src/sys/sendfile/linux/sendfile.cpp b/libc/src/sys/sendfile/linux/sendfile.cpp
index ec892323def50..fffbc97495635 100644
--- a/libc/src/sys/sendfile/linux/sendfile.cpp
+++ b/libc/src/sys/sendfile/linux/sendfile.cpp
@@ -13,7 +13,6 @@
#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include <sys/sendfile.h>
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/sendfile/sendfile.h b/libc/src/sys/sendfile/sendfile.h
index 95c3fd4db470c..5cea300c7ab74 100644
--- a/libc/src/sys/sendfile/sendfile.h
+++ b/libc/src/sys/sendfile/sendfile.h
@@ -9,8 +9,10 @@
#ifndef LLVM_LIBC_SRC_SYS_SENDFILE_SENDFILE_H
#define LLVM_LIBC_SRC_SYS_SENDFILE_SENDFILE_H
+#include "hdr/types/off_t.h"
+#include "hdr/types/size_t.h"
+#include "hdr/types/ssize_t.h"
#include "src/__support/macros/config.h"
-#include <sys/sendfile.h>
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/socket/linux/CMakeLists.txt b/libc/src/sys/socket/linux/CMakeLists.txt
index 4e711ffeac58a..f291b362ff2b4 100644
--- a/libc/src/sys/socket/linux/CMakeLists.txt
+++ b/libc/src/sys/socket/linux/CMakeLists.txt
@@ -145,6 +145,7 @@ add_entrypoint_object(
HDRS
../send.h
DEPENDS
+ libc.hdr.types.size_t
libc.hdr.types.ssize_t
libc.src.__support.common
libc.src.__support.OSUtil.linux.syscall_wrappers.sendto
@@ -214,6 +215,7 @@ add_entrypoint_object(
../recv.h
DEPENDS
libc.src.__support.macros.sanitizer
+ libc.hdr.types.size_t
libc.hdr.types.ssize_t
libc.src.__support.common
libc.src.__support.OSUtil.linux.syscall_wrappers.recvfrom
diff --git a/libc/src/sys/socket/recv.h b/libc/src/sys/socket/recv.h
index ea64daa1183fe..30c2ed9610214 100644
--- a/libc/src/sys/socket/recv.h
+++ b/libc/src/sys/socket/recv.h
@@ -9,8 +9,9 @@
#ifndef LLVM_LIBC_SRC_SYS_SOCKET_RECV_H
#define LLVM_LIBC_SRC_SYS_SOCKET_RECV_H
+#include "hdr/types/size_t.h"
+#include "hdr/types/ssize_t.h"
#include "src/__support/macros/config.h"
-#include <sys/socket.h>
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/socket/send.h b/libc/src/sys/socket/send.h
index e1706694cd5f5..2e264c77f007f 100644
--- a/libc/src/sys/socket/send.h
+++ b/libc/src/sys/socket/send.h
@@ -9,8 +9,9 @@
#ifndef LLVM_LIBC_SRC_SYS_SOCKET_SEND_H
#define LLVM_LIBC_SRC_SYS_SOCKET_SEND_H
+#include "hdr/types/size_t.h"
+#include "hdr/types/ssize_t.h"
#include "src/__support/macros/config.h"
-#include <sys/socket.h>
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/wait/linux/CMakeLists.txt b/libc/src/sys/wait/linux/CMakeLists.txt
index 24a799f1dabb1..894396f719e7c 100644
--- a/libc/src/sys/wait/linux/CMakeLists.txt
+++ b/libc/src/sys/wait/linux/CMakeLists.txt
@@ -6,6 +6,7 @@ add_entrypoint_object(
../wait.h
DEPENDS
libc.hdr.signal_macros
+ libc.hdr.types.pid_t
libc.hdr.types.siginfo_t
libc.include.sys_wait
libc.include.sys_syscall
@@ -36,6 +37,7 @@ add_entrypoint_object(
../waitpid.h
DEPENDS
libc.hdr.signal_macros
+ libc.hdr.types.pid_t
libc.hdr.types.siginfo_t
libc.include.sys_wait
libc.include.sys_syscall
diff --git a/libc/src/sys/wait/wait.h b/libc/src/sys/wait/wait.h
index 03b53a54ae888..b6aac1d310914 100644
--- a/libc/src/sys/wait/wait.h
+++ b/libc/src/sys/wait/wait.h
@@ -9,8 +9,8 @@
#ifndef LLVM_LIBC_SRC_SYS_WAIT_WAIT_H
#define LLVM_LIBC_SRC_SYS_WAIT_WAIT_H
+#include "hdr/types/pid_t.h"
#include "src/__support/macros/config.h"
-#include <sys/wait.h>
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/wait/waitpid.h b/libc/src/sys/wait/waitpid.h
index 883b5375787e2..297c0894a8abf 100644
--- a/libc/src/sys/wait/waitpid.h
+++ b/libc/src/sys/wait/waitpid.h
@@ -9,8 +9,8 @@
#ifndef LLVM_LIBC_SRC_SYS_WAIT_WAITPID_H
#define LLVM_LIBC_SRC_SYS_WAIT_WAITPID_H
+#include "hdr/types/pid_t.h"
#include "src/__support/macros/config.h"
-#include <sys/wait.h>
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/unistd/linux/CMakeLists.txt b/libc/src/unistd/linux/CMakeLists.txt
index ef51f20f62a77..203291481957d 100644
--- a/libc/src/unistd/linux/CMakeLists.txt
+++ b/libc/src/unistd/linux/CMakeLists.txt
@@ -343,7 +343,7 @@ add_entrypoint_object(
DEPENDS
libc.hdr.unistd_macros
libc.include.unistd
- libc.include.sys_ioctl
+ libc.hdr.sys_ioctl_macros
libc.src.__support.OSUtil.linux.syscall_wrappers.ioctl
libc.src.errno.errno
)
diff --git a/libc/src/unistd/linux/isatty.cpp b/libc/src/unistd/linux/isatty.cpp
index 4418feb2229a3..963ea40c00679 100644
--- a/libc/src/unistd/linux/isatty.cpp
+++ b/libc/src/unistd/linux/isatty.cpp
@@ -8,11 +8,11 @@
#include "src/unistd/isatty.h"
+#include "hdr/sys_ioctl_macros.h" // For ioctl numbers.
#include "src/__support/OSUtil/linux/syscall_wrappers/ioctl.h"
#include "src/__support/common.h"
#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include <sys/ioctl.h> // For ioctl numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/startup/linux/CMakeLists.txt b/libc/startup/linux/CMakeLists.txt
index 015b08780da23..e2c0b5cf791fe 100644
--- a/libc/startup/linux/CMakeLists.txt
+++ b/libc/startup/linux/CMakeLists.txt
@@ -113,7 +113,7 @@ add_object_library(
libc.hdr.elf_proxy
libc.hdr.link_macros
libc.hdr.stdint_proxy
- libc.include.sys_mman
+ libc.hdr.sys_mman_macros
libc.include.sys_syscall
libc.src.__support.OSUtil.linux.auxv
libc.src.__support.OSUtil.osutil
diff --git a/libc/startup/linux/do_start.cpp b/libc/startup/linux/do_start.cpp
index b1faaf7d90dd3..a54513654a803 100644
--- a/libc/startup/linux/do_start.cpp
+++ b/libc/startup/linux/do_start.cpp
@@ -10,6 +10,7 @@
#include "hdr/elf_proxy.h"
#include "hdr/link_macros.h"
#include "hdr/stdint_proxy.h"
+#include "hdr/sys_mman_macros.h"
#include "src/__support/OSUtil/linux/auxv.h"
#include "src/__support/OSUtil/syscall.h"
#include "src/__support/macros/config.h"
@@ -20,7 +21,6 @@
#include "startup/linux/gnu_property_section.h"
#include "startup/linux/irelative.h"
-#include <sys/mman.h>
#include <sys/syscall.h>
extern "C" int main(int argc, char **argv, char **envp);
diff --git a/libc/test/integration/src/sys/ptrace/linux/ptrace_test.cpp b/libc/test/integration/src/sys/ptrace/linux/ptrace_test.cpp
index 228054a80ee76..cfbb25044278d 100644
--- a/libc/test/integration/src/sys/ptrace/linux/ptrace_test.cpp
+++ b/libc/test/integration/src/sys/ptrace/linux/ptrace_test.cpp
@@ -21,6 +21,7 @@
#include "test/IntegrationTest/test.h"
#include <errno.h>
#include <sys/ptrace.h>
+#include <sys/wait.h>
void basic_ptrace_test() {
// This variable will be read and written to via ptrace.
diff --git a/libc/test/src/fcntl/CMakeLists.txt b/libc/test/src/fcntl/CMakeLists.txt
index ff62210c13f43..b8202e5279c48 100644
--- a/libc/test/src/fcntl/CMakeLists.txt
+++ b/libc/test/src/fcntl/CMakeLists.txt
@@ -9,6 +9,7 @@ add_libc_unittest(
SRCS
creat_test.cpp
DEPENDS
+ libc.hdr.sys_stat_macros
libc.include.fcntl
libc.src.errno.errno
libc.src.fcntl.creat
@@ -33,6 +34,8 @@ add_libc_unittest(
libc.src.unistd.getpid
libc.hdr.types.struct_flock
libc.hdr.fcntl_macros
+ libc.hdr.stdio_macros
+ libc.hdr.sys_stat_macros
libc.test.UnitTest.ErrnoCheckingTest
libc.test.UnitTest.ErrnoSetterMatcher
)
diff --git a/libc/test/src/fcntl/creat_test.cpp b/libc/test/src/fcntl/creat_test.cpp
index c578cf289689b..7c98f229bea7c 100644
--- a/libc/test/src/fcntl/creat_test.cpp
+++ b/libc/test/src/fcntl/creat_test.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "hdr/sys_stat_macros.h"
#include "src/fcntl/creat.h"
#include "src/fcntl/open.h"
#include "src/unistd/close.h"
@@ -13,8 +14,6 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include <sys/stat.h>
-
using LlvmLibcCreatTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
TEST_F(LlvmLibcCreatTest, CreatAndOpen) {
diff --git a/libc/test/src/fcntl/fcntl_test.cpp b/libc/test/src/fcntl/fcntl_test.cpp
index d008aea54b425..e2a4ce4f8977e 100644
--- a/libc/test/src/fcntl/fcntl_test.cpp
+++ b/libc/test/src/fcntl/fcntl_test.cpp
@@ -8,6 +8,7 @@
#include "hdr/fcntl_macros.h"
#include "hdr/stdio_macros.h"
+#include "hdr/sys_stat_macros.h" // For S_IRWXU
#include "hdr/types/struct_flock.h"
#include "src/fcntl/fcntl.h"
#include "src/fcntl/open.h"
@@ -17,8 +18,6 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include <sys/stat.h> // For S_IRWXU
-
using LlvmLibcFcntlTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
TEST_F(LlvmLibcFcntlTest, FcntlDupfd) {
diff --git a/libc/test/src/stdio/CMakeLists.txt b/libc/test/src/stdio/CMakeLists.txt
index 5f586238dc1e9..465e3c8698076 100644
--- a/libc/test/src/stdio/CMakeLists.txt
+++ b/libc/test/src/stdio/CMakeLists.txt
@@ -503,6 +503,8 @@ if(${LIBC_TARGET_OS} STREQUAL "linux")
SRCS
fdopen_test.cpp
DEPENDS
+ libc.hdr.fcntl_macros
+ libc.hdr.sys_stat_macros
libc.src.fcntl.open
libc.src.stdio.fclose
libc.src.stdio.fdopen
diff --git a/libc/test/src/stdio/fdopen_test.cpp b/libc/test/src/stdio/fdopen_test.cpp
index bab1d33edcb04..cf971e218b828 100644
--- a/libc/test/src/stdio/fdopen_test.cpp
+++ b/libc/test/src/stdio/fdopen_test.cpp
@@ -9,6 +9,7 @@
#include "src/stdio/fdopen.h"
#include "hdr/fcntl_macros.h"
+#include "hdr/sys_stat_macros.h" // For S_IRWXU
#include "src/fcntl/open.h"
#include "src/stdio/fclose.h"
#include "src/stdio/fgets.h"
@@ -18,8 +19,6 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include <sys/stat.h> // For S_IRWXU
-
using LlvmLibcStdioFdopenTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
TEST_F(LlvmLibcStdioFdopenTest, WriteAppendRead) {
diff --git a/libc/test/src/string/memory_utils/protected_pages.h b/libc/test/src/string/memory_utils/protected_pages.h
index 65578d106ce53..f8381b0d09770 100644
--- a/libc/test/src/string/memory_utils/protected_pages.h
+++ b/libc/test/src/string/memory_utils/protected_pages.h
@@ -19,9 +19,9 @@
#endif // defined(LIBC_FULL_BUILD) || !defined(LIBC_TARGET_OS_IS_LINUX)
#include "hdr/stdint_proxy.h" // uint8_t
+#include "hdr/sys_mman_macros.h" // mmap, munmap
#include "src/__support/macros/attributes.h" // LIBC_INLINE
#include <stddef.h> // size_t
-#include <sys/mman.h> // mmap, munmap
#include <unistd.h> // sysconf, _SC_PAGESIZE
// Returns mmap page size.
diff --git a/libc/test/src/sys/auxv/linux/CMakeLists.txt b/libc/test/src/sys/auxv/linux/CMakeLists.txt
index 66370118bf6d6..e4c3b782cd326 100644
--- a/libc/test/src/sys/auxv/linux/CMakeLists.txt
+++ b/libc/test/src/sys/auxv/linux/CMakeLists.txt
@@ -6,7 +6,7 @@ add_libc_unittest(
SRCS
getauxval_test.cpp
DEPENDS
- libc.include.sys_auxv
+ libc.hdr.sys_auxv_macros
libc.src.errno.errno
libc.src.sys.auxv.getauxval
libc.test.UnitTest.ErrnoCheckingTest
diff --git a/libc/test/src/sys/auxv/linux/getauxval_test.cpp b/libc/test/src/sys/auxv/linux/getauxval_test.cpp
index b8728b7ad775c..07fe3a381f22c 100644
--- a/libc/test/src/sys/auxv/linux/getauxval_test.cpp
+++ b/libc/test/src/sys/auxv/linux/getauxval_test.cpp
@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
+#include "hdr/sys_auxv_macros.h"
+#include "src/string/strstr.h"
#include "src/sys/auxv/getauxval.h"
#include "test/UnitTest/ErrnoCheckingTest.h"
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include <src/string/strstr.h>
-#include <sys/auxv.h>
using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher;
using LlvmLibcGetauxvalTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
diff --git a/libc/test/src/sys/mman/linux/CMakeLists.txt b/libc/test/src/sys/mman/linux/CMakeLists.txt
index 9d989d4f877c2..627952f654d5f 100644
--- a/libc/test/src/sys/mman/linux/CMakeLists.txt
+++ b/libc/test/src/sys/mman/linux/CMakeLists.txt
@@ -44,7 +44,6 @@ if (NOT LLVM_USE_SANITIZER)
mprotect_test.cpp
DEPENDS
libc.hdr.sys_mman_macros
- libc.include.sys_mman
libc.include.signal
libc.src.errno.errno
libc.src.sys.mman.mmap
@@ -158,6 +157,7 @@ add_libc_unittest(
libc.src.sys.mman.munlock
libc.src.sys.mman.mlockall
libc.src.sys.mman.munlockall
+ libc.hdr.sys_resource_macros
libc.src.sys.resource.getrlimit
libc.src.unistd.sysconf
libc.src.__support.OSUtil.osutil
@@ -200,8 +200,7 @@ add_libc_unittest(
remap_file_pages_test.cpp
DEPENDS
libc.hdr.sys_mman_macros
- libc.include.sys_mman
- libc.include.sys_stat
+ libc.hdr.sys_stat_macros
libc.test.UnitTest.ErrnoCheckingTest
libc.test.UnitTest.ErrnoSetterMatcher
libc.src.sys.mman.remap_file_pages
diff --git a/libc/test/src/sys/mman/linux/mlock_test.cpp b/libc/test/src/sys/mman/linux/mlock_test.cpp
index 4e81cf4a3d9e4..b166dc789f343 100644
--- a/libc/test/src/sys/mman/linux/mlock_test.cpp
+++ b/libc/test/src/sys/mman/linux/mlock_test.cpp
@@ -11,6 +11,7 @@
// check our code paths (succeeds and errors).
#include "hdr/sys_mman_macros.h"
+#include "hdr/sys_resource_macros.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/libc_errno.h"
#include "src/sys/mman/madvise.h"
diff --git a/libc/test/src/sys/mman/linux/mprotect_test.cpp b/libc/test/src/sys/mman/linux/mprotect_test.cpp
index e34c21d8e0446..210b12430160b 100644
--- a/libc/test/src/sys/mman/linux/mprotect_test.cpp
+++ b/libc/test/src/sys/mman/linux/mprotect_test.cpp
@@ -15,8 +15,6 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include <sys/mman.h>
-
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
using LlvmLibcMProtectTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
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 eab8abe3fc2a0..d4a155e6d52e0 100644
--- a/libc/test/src/sys/mman/linux/posix_madvise_test.cpp
+++ b/libc/test/src/sys/mman/linux/posix_madvise_test.cpp
@@ -14,8 +14,6 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include <sys/mman.h>
-
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
using LlvmLibcPosixMadviseTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
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 94e4c63286ad2..7d3f89440043d 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
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "hdr/sys_mman_macros.h"
+#include "hdr/sys_stat_macros.h" // For S_IRWXU
#include "src/fcntl/open.h"
#include "src/sys/mman/mmap.h"
#include "src/sys/mman/munmap.h"
@@ -17,9 +18,6 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include <sys/mman.h>
-#include <sys/stat.h> // For S_IRWXU
-
const size_t PAGE_SIZE = LIBC_NAMESPACE::sysconf(_SC_PAGESIZE);
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 2097a2c501fbd..accb50270d3c3 100644
--- a/libc/test/src/sys/resource/CMakeLists.txt
+++ b/libc/test/src/sys/resource/CMakeLists.txt
@@ -8,7 +8,9 @@ add_libc_unittest(
getrlimit_setrlimit_test.cpp
DEPENDS
libc.include.fcntl
- libc.include.sys_resource
+ libc.hdr.sys_resource_macros
+ libc.hdr.sys_stat_macros
+ libc.hdr.types.struct_rlimit
libc.src.errno.errno
libc.src.fcntl.open
libc.src.sys.resource.getrlimit
diff --git a/libc/test/src/sys/resource/getrlimit_setrlimit_test.cpp b/libc/test/src/sys/resource/getrlimit_setrlimit_test.cpp
index 4e0a3c7d10b5f..148183260ca41 100644
--- a/libc/test/src/sys/resource/getrlimit_setrlimit_test.cpp
+++ b/libc/test/src/sys/resource/getrlimit_setrlimit_test.cpp
@@ -6,6 +6,9 @@
//
//===----------------------------------------------------------------------===//
+#include "hdr/sys_resource_macros.h"
+#include "hdr/sys_stat_macros.h"
+#include "hdr/types/struct_rlimit.h"
#include "src/__support/CPP/string_view.h"
#include "src/fcntl/open.h"
#include "src/sys/resource/getrlimit.h"
@@ -16,9 +19,6 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include <sys/resource.h>
-#include <sys/stat.h>
-
using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher;
using LlvmLibcResourceLimitsTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
diff --git a/libc/test/src/sys/sendfile/CMakeLists.txt b/libc/test/src/sys/sendfile/CMakeLists.txt
index 45b2d48cf4a7a..dfcac18b7808b 100644
--- a/libc/test/src/sys/sendfile/CMakeLists.txt
+++ b/libc/test/src/sys/sendfile/CMakeLists.txt
@@ -10,7 +10,7 @@ add_libc_unittest(
sendfile_test.cpp
DEPENDS
libc.hdr.fcntl_macros
- libc.include.sys_stat
+ libc.hdr.sys_stat_macros
libc.src.errno.errno
libc.src.fcntl.open
libc.src.sys.sendfile.sendfile
diff --git a/libc/test/src/sys/sendfile/sendfile_test.cpp b/libc/test/src/sys/sendfile/sendfile_test.cpp
index 4e789ba0cd513..7eea3eeca23ef 100644
--- a/libc/test/src/sys/sendfile/sendfile_test.cpp
+++ b/libc/test/src/sys/sendfile/sendfile_test.cpp
@@ -6,6 +6,8 @@
//
//===----------------------------------------------------------------------===//
+#include "hdr/fcntl_macros.h"
+#include "hdr/sys_stat_macros.h"
#include "src/__support/CPP/string_view.h"
#include "src/fcntl/open.h"
#include "src/sys/sendfile/sendfile.h"
@@ -17,9 +19,6 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include "hdr/fcntl_macros.h"
-#include <sys/stat.h>
-
using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher;
using LlvmLibcSendfileTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
namespace cpp = LIBC_NAMESPACE::cpp;
diff --git a/libc/test/src/sys/socket/linux/CMakeLists.txt b/libc/test/src/sys/socket/linux/CMakeLists.txt
index 1f28b99601e61..e444d2168979e 100644
--- a/libc/test/src/sys/socket/linux/CMakeLists.txt
+++ b/libc/test/src/sys/socket/linux/CMakeLists.txt
@@ -22,7 +22,7 @@ add_libc_unittest(
SRCS
socket_test.cpp
DEPENDS
- libc.include.sys_socket
+ libc.hdr.sys_socket_macros
libc.src.errno.errno
libc.src.sys.socket.socket
libc.src.unistd.close
@@ -144,7 +144,7 @@ add_libc_unittest(
SRCS
socketpair_test.cpp
DEPENDS
- libc.include.sys_socket
+ libc.hdr.sys_socket_macros
libc.src.errno.errno
libc.src.sys.socket.socketpair
libc.src.unistd.close
@@ -178,7 +178,7 @@ add_libc_unittest(
sockname_test.cpp
DEPENDS
.socket_test_support
- libc.include.sys_socket
+ libc.hdr.sys_socket_macros
libc.hdr.sys_socket_macros
libc.hdr.types.sa_family_t
libc.hdr.types.socklen_t
@@ -223,7 +223,7 @@ add_libc_unittest(
SRCS
sendto_recvfrom_test.cpp
DEPENDS
- libc.include.sys_socket
+ libc.hdr.sys_socket_macros
libc.src.errno.errno
libc.src.sys.socket.socketpair
libc.src.sys.socket.sendto
diff --git a/libc/test/src/sys/socket/linux/sendto_recvfrom_test.cpp b/libc/test/src/sys/socket/linux/sendto_recvfrom_test.cpp
index e10e572159a8c..bbbad64dd7ccc 100644
--- a/libc/test/src/sys/socket/linux/sendto_recvfrom_test.cpp
+++ b/libc/test/src/sys/socket/linux/sendto_recvfrom_test.cpp
@@ -12,13 +12,12 @@
#include "src/unistd/close.h"
+#include "hdr/sys_socket_macros.h" // For AF_UNIX and SOCK_DGRAM
#include "src/__support/CPP/scope.h"
#include "test/UnitTest/ErrnoCheckingTest.h"
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include <sys/socket.h> // For AF_UNIX and SOCK_DGRAM
-
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
using LlvmLibcSendToRecvFromTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
diff --git a/libc/test/src/sys/socket/linux/socket_test.cpp b/libc/test/src/sys/socket/linux/socket_test.cpp
index 9f16be97e926a..943389c1ebeb6 100644
--- a/libc/test/src/sys/socket/linux/socket_test.cpp
+++ b/libc/test/src/sys/socket/linux/socket_test.cpp
@@ -10,12 +10,11 @@
#include "src/unistd/close.h"
+#include "hdr/sys_socket_macros.h" // For AF_UNIX and SOCK_DGRAM
#include "test/UnitTest/ErrnoCheckingTest.h"
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include <sys/socket.h> // For AF_UNIX and SOCK_DGRAM
-
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
using LlvmLibcSocketTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
diff --git a/libc/test/src/sys/socket/linux/socketopt_test.cpp b/libc/test/src/sys/socket/linux/socketopt_test.cpp
index 629f1b6ae75b9..43071121e052c 100644
--- a/libc/test/src/sys/socket/linux/socketopt_test.cpp
+++ b/libc/test/src/sys/socket/linux/socketopt_test.cpp
@@ -24,7 +24,6 @@
#include "test/UnitTest/ErrnoCheckingTest.h"
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include <sys/socket.h>
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
diff --git a/libc/test/src/sys/socket/linux/socketpair_test.cpp b/libc/test/src/sys/socket/linux/socketpair_test.cpp
index b7a5f0ae6a251..33b6f3c1aef0d 100644
--- a/libc/test/src/sys/socket/linux/socketpair_test.cpp
+++ b/libc/test/src/sys/socket/linux/socketpair_test.cpp
@@ -10,12 +10,11 @@
#include "src/unistd/close.h"
+#include "hdr/sys_socket_macros.h" // For AF_UNIX and SOCK_DGRAM
#include "test/UnitTest/ErrnoCheckingTest.h"
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include <sys/socket.h> // For AF_UNIX and SOCK_DGRAM
-
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::any_of;
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
diff --git a/libc/test/src/sys/stat/CMakeLists.txt b/libc/test/src/sys/stat/CMakeLists.txt
index 7786baf1cf20b..86881bd21ac51 100644
--- a/libc/test/src/sys/stat/CMakeLists.txt
+++ b/libc/test/src/sys/stat/CMakeLists.txt
@@ -10,7 +10,8 @@ add_libc_unittest(
chmod_test.cpp
DEPENDS
libc.hdr.fcntl_macros
- libc.include.sys_stat
+ libc.hdr.sys_stat_macros
+ libc.hdr.types.struct_stat
libc.src.errno.errno
libc.src.fcntl.open
libc.src.sys.stat.chmod
@@ -28,7 +29,8 @@ add_libc_unittest(
fchmodat_test.cpp
DEPENDS
libc.hdr.fcntl_macros
- libc.include.sys_stat
+ libc.hdr.sys_stat_macros
+ libc.hdr.types.struct_stat
libc.src.errno.errno
libc.src.fcntl.open
libc.src.sys.stat.fchmodat
@@ -46,7 +48,8 @@ add_libc_unittest(
fchmod_test.cpp
DEPENDS
libc.hdr.fcntl_macros
- libc.include.sys_stat
+ libc.hdr.sys_stat_macros
+ libc.hdr.types.struct_stat
libc.src.errno.errno
libc.src.fcntl.open
libc.src.sys.stat.fchmod
@@ -80,7 +83,8 @@ add_libc_unittest(
stat_test.cpp
DEPENDS
libc.hdr.fcntl_macros
- libc.include.sys_stat
+ libc.hdr.sys_stat_macros
+ libc.hdr.types.struct_stat
libc.src.errno.errno
libc.src.sys.stat.stat
libc.src.fcntl.open
@@ -98,7 +102,8 @@ add_libc_unittest(
lstat_test.cpp
DEPENDS
libc.hdr.fcntl_macros
- libc.include.sys_stat
+ libc.hdr.sys_stat_macros
+ libc.hdr.types.struct_stat
libc.src.errno.errno
libc.src.sys.stat.lstat
libc.src.fcntl.open
@@ -116,7 +121,8 @@ add_libc_unittest(
fstat_test.cpp
DEPENDS
libc.hdr.fcntl_macros
- libc.include.sys_stat
+ libc.hdr.sys_stat_macros
+ libc.hdr.types.struct_stat
libc.src.errno.errno
libc.src.sys.stat.fstat
libc.src.fcntl.open
@@ -136,7 +142,8 @@ add_libc_unittest(
libc.hdr.fcntl_macros
libc.hdr.sys_stat_macros
libc.hdr.types.struct_timespec
- libc.include.sys_stat
+ libc.hdr.sys_stat_macros
+ libc.hdr.types.struct_stat
libc.src.errno.errno
libc.src.sys.stat.utimensat
libc.src.fcntl.open
diff --git a/libc/test/src/sys/stat/chmod_test.cpp b/libc/test/src/sys/stat/chmod_test.cpp
index fbdb1fb89568a..0a8884d7aa84b 100644
--- a/libc/test/src/sys/stat/chmod_test.cpp
+++ b/libc/test/src/sys/stat/chmod_test.cpp
@@ -6,6 +6,9 @@
//
//===----------------------------------------------------------------------===//
+#include "hdr/fcntl_macros.h"
+#include "hdr/sys_stat_macros.h"
+#include "hdr/types/struct_stat.h"
#include "src/fcntl/open.h"
#include "src/sys/stat/chmod.h"
#include "src/unistd/close.h"
@@ -14,9 +17,6 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include "hdr/fcntl_macros.h"
-#include <sys/stat.h>
-
using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher;
using LlvmLibcChmodTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
diff --git a/libc/test/src/sys/stat/fchmod_test.cpp b/libc/test/src/sys/stat/fchmod_test.cpp
index eff6924327d75..c132245b90cc5 100644
--- a/libc/test/src/sys/stat/fchmod_test.cpp
+++ b/libc/test/src/sys/stat/fchmod_test.cpp
@@ -6,6 +6,9 @@
//
//===----------------------------------------------------------------------===//
+#include "hdr/fcntl_macros.h"
+#include "hdr/sys_stat_macros.h"
+#include "hdr/types/struct_stat.h"
#include "src/fcntl/open.h"
#include "src/sys/stat/fchmod.h"
#include "src/unistd/close.h"
@@ -14,9 +17,6 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include "hdr/fcntl_macros.h"
-#include <sys/stat.h>
-
using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher;
using LlvmLibcFchmodTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
diff --git a/libc/test/src/sys/stat/fchmodat_test.cpp b/libc/test/src/sys/stat/fchmodat_test.cpp
index c8b2631c608c5..8a1a9379aca71 100644
--- a/libc/test/src/sys/stat/fchmodat_test.cpp
+++ b/libc/test/src/sys/stat/fchmodat_test.cpp
@@ -6,6 +6,9 @@
//
//===----------------------------------------------------------------------===//
+#include "hdr/fcntl_macros.h"
+#include "hdr/sys_stat_macros.h"
+#include "hdr/types/struct_stat.h"
#include "src/fcntl/open.h"
#include "src/sys/stat/fchmodat.h"
#include "src/unistd/close.h"
@@ -14,9 +17,6 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include "hdr/fcntl_macros.h"
-#include <sys/stat.h>
-
using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher;
using LlvmLibcFchmodatTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
diff --git a/libc/test/src/sys/stat/fstat_test.cpp b/libc/test/src/sys/stat/fstat_test.cpp
index 3a0fb69cfef94..50f4509d278b7 100644
--- a/libc/test/src/sys/stat/fstat_test.cpp
+++ b/libc/test/src/sys/stat/fstat_test.cpp
@@ -6,6 +6,9 @@
//
//===----------------------------------------------------------------------===//
+#include "hdr/fcntl_macros.h"
+#include "hdr/sys_stat_macros.h"
+#include "hdr/types/struct_stat.h"
#include "src/fcntl/open.h"
#include "src/sys/stat/fstat.h"
#include "src/unistd/close.h"
@@ -14,9 +17,6 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include "hdr/fcntl_macros.h"
-#include <sys/stat.h>
-
using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher;
using LlvmLibcFStatTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
diff --git a/libc/test/src/sys/stat/lstat_test.cpp b/libc/test/src/sys/stat/lstat_test.cpp
index 1da19c934ad56..1b4cd7ac25676 100644
--- a/libc/test/src/sys/stat/lstat_test.cpp
+++ b/libc/test/src/sys/stat/lstat_test.cpp
@@ -6,6 +6,9 @@
//
//===----------------------------------------------------------------------===//
+#include "hdr/fcntl_macros.h"
+#include "hdr/sys_stat_macros.h"
+#include "hdr/types/struct_stat.h"
#include "src/fcntl/open.h"
#include "src/sys/stat/lstat.h"
#include "src/unistd/close.h"
@@ -14,9 +17,6 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include "hdr/fcntl_macros.h"
-#include <sys/stat.h>
-
using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher;
using LlvmLibcLStatTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
diff --git a/libc/test/src/sys/stat/stat_test.cpp b/libc/test/src/sys/stat/stat_test.cpp
index 88ef37e7d1b76..9ce9e619be522 100644
--- a/libc/test/src/sys/stat/stat_test.cpp
+++ b/libc/test/src/sys/stat/stat_test.cpp
@@ -6,6 +6,9 @@
//
//===----------------------------------------------------------------------===//
+#include "hdr/fcntl_macros.h"
+#include "hdr/sys_stat_macros.h"
+#include "hdr/types/struct_stat.h"
#include "src/fcntl/open.h"
#include "src/sys/stat/stat.h"
#include "src/unistd/close.h"
@@ -14,9 +17,6 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include "hdr/fcntl_macros.h"
-#include <sys/stat.h>
-
using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher;
using LlvmLibcStatTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
diff --git a/libc/test/src/unistd/CMakeLists.txt b/libc/test/src/unistd/CMakeLists.txt
index 57e62e71e90a3..070c25f24e61a 100644
--- a/libc/test/src/unistd/CMakeLists.txt
+++ b/libc/test/src/unistd/CMakeLists.txt
@@ -24,6 +24,7 @@ add_libc_unittest(
SRCS
access_test.cpp
DEPENDS
+ libc.hdr.sys_stat_macros
libc.include.unistd
libc.src.errno.errno
libc.src.fcntl.open
@@ -58,6 +59,7 @@ add_libc_unittest(
SRCS
chown_test.cpp
DEPENDS
+ libc.hdr.sys_stat_macros
libc.hdr.fcntl_macros
libc.include.unistd
libc.src.errno.errno
@@ -78,6 +80,7 @@ add_libc_unittest(
SRCS
dup_test.cpp
DEPENDS
+ libc.hdr.sys_stat_macros
libc.include.unistd
libc.src.errno.errno
libc.src.fcntl.open
@@ -97,6 +100,7 @@ add_libc_unittest(
SRCS
dup2_test.cpp
DEPENDS
+ libc.hdr.sys_stat_macros
libc.include.unistd
libc.src.errno.errno
libc.src.fcntl.open
@@ -116,6 +120,7 @@ add_libc_unittest(
SRCS
dup3_test.cpp
DEPENDS
+ libc.hdr.sys_stat_macros
libc.include.unistd
libc.src.errno.errno
libc.src.fcntl.open
@@ -135,6 +140,7 @@ add_libc_unittest(
SRCS
faccessat_test.cpp
DEPENDS
+ libc.hdr.sys_stat_macros
libc.include.unistd
libc.src.errno.errno
libc.src.fcntl.open
@@ -168,6 +174,7 @@ add_libc_unittest(
SRCS
fchown_test.cpp
DEPENDS
+ libc.hdr.sys_stat_macros
libc.hdr.fcntl_macros
libc.include.unistd
libc.src.errno.errno
@@ -188,6 +195,7 @@ add_libc_unittest(
SRCS
ftruncate_test.cpp
DEPENDS
+ libc.hdr.sys_stat_macros
libc.include.unistd
libc.src.errno.errno
libc.src.fcntl.open
@@ -208,6 +216,7 @@ add_libc_unittest(
SRCS
pread_pwrite_test.cpp
DEPENDS
+ libc.hdr.sys_stat_macros
libc.include.unistd
libc.src.errno.errno
libc.src.fcntl.open
@@ -228,6 +237,7 @@ add_libc_unittest(
SRCS
read_write_test.cpp
DEPENDS
+ libc.hdr.sys_stat_macros
libc.include.unistd
libc.src.errno.errno
libc.src.fcntl.open
@@ -247,6 +257,7 @@ add_libc_unittest(
SRCS
link_test.cpp
DEPENDS
+ libc.hdr.sys_stat_macros
libc.include.unistd
libc.src.errno.errno
libc.src.fcntl.open
@@ -264,6 +275,7 @@ add_libc_unittest(
SRCS
linkat_test.cpp
DEPENDS
+ libc.hdr.sys_stat_macros
libc.include.unistd
libc.src.errno.errno
libc.src.fcntl.open
@@ -401,6 +413,7 @@ add_libc_unittest(
SRCS
symlink_test.cpp
DEPENDS
+ libc.hdr.sys_stat_macros
libc.include.unistd
libc.src.errno.errno
libc.src.fcntl.open
@@ -418,6 +431,7 @@ add_libc_unittest(
SRCS
symlinkat_test.cpp
DEPENDS
+ libc.hdr.sys_stat_macros
libc.include.unistd
libc.src.errno.errno
libc.src.fcntl.open
@@ -435,6 +449,7 @@ add_libc_unittest(
SRCS
truncate_test.cpp
DEPENDS
+ libc.hdr.sys_stat_macros
libc.include.unistd
libc.src.errno.errno
libc.src.fcntl.open
@@ -455,6 +470,7 @@ add_libc_unittest(
SRCS
unlink_test.cpp
DEPENDS
+ libc.hdr.sys_stat_macros
libc.include.unistd
libc.src.errno.errno
libc.src.fcntl.open
@@ -471,6 +487,7 @@ add_libc_unittest(
SRCS
unlinkat_test.cpp
DEPENDS
+ libc.hdr.sys_stat_macros
libc.include.unistd
libc.src.errno.errno
libc.src.fcntl.open
@@ -563,6 +580,7 @@ add_libc_unittest(
SRCS
isatty_test.cpp
DEPENDS
+ libc.hdr.sys_stat_macros
libc.src.unistd.isatty
libc.src.fcntl.open
libc.src.unistd.close
@@ -588,6 +606,7 @@ add_libc_unittest(
SRCS
syscall_test.cpp
DEPENDS
+ libc.hdr.sys_stat_macros
libc.include.unistd
libc.hdr.fcntl_macros
libc.include.sys_syscall
diff --git a/libc/test/src/unistd/access_test.cpp b/libc/test/src/unistd/access_test.cpp
index 693f15c767e5e..aebc50a76324d 100644
--- a/libc/test/src/unistd/access_test.cpp
+++ b/libc/test/src/unistd/access_test.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "hdr/sys_stat_macros.h"
#include "src/fcntl/open.h"
#include "src/unistd/access.h"
#include "src/unistd/close.h"
@@ -14,7 +15,6 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include <sys/stat.h>
#include <unistd.h>
using LlvmLibcAccessTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
diff --git a/libc/test/src/unistd/chown_test.cpp b/libc/test/src/unistd/chown_test.cpp
index 8b1f783273624..66413bedb3b45 100644
--- a/libc/test/src/unistd/chown_test.cpp
+++ b/libc/test/src/unistd/chown_test.cpp
@@ -13,13 +13,12 @@
#include "src/unistd/getuid.h"
#include "src/unistd/unlink.h"
+#include "hdr/fcntl_macros.h"
+#include "hdr/sys_stat_macros.h"
#include "test/UnitTest/ErrnoCheckingTest.h"
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include "hdr/fcntl_macros.h"
-#include <sys/stat.h>
-
using LlvmLibcChownTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
TEST_F(LlvmLibcChownTest, ChownSuccess) {
diff --git a/libc/test/src/unistd/dup2_test.cpp b/libc/test/src/unistd/dup2_test.cpp
index f6d546def33ec..d8b8900f14374 100644
--- a/libc/test/src/unistd/dup2_test.cpp
+++ b/libc/test/src/unistd/dup2_test.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "hdr/sys_stat_macros.h"
#include "src/fcntl/open.h"
#include "src/unistd/close.h"
#include "src/unistd/dup2.h"
@@ -16,8 +17,6 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include <sys/stat.h>
-
using LlvmLibcdupTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
TEST_F(LlvmLibcdupTest, ReadAndWriteViaDup) {
diff --git a/libc/test/src/unistd/dup3_test.cpp b/libc/test/src/unistd/dup3_test.cpp
index 598940b1c456d..8f187b442c09f 100644
--- a/libc/test/src/unistd/dup3_test.cpp
+++ b/libc/test/src/unistd/dup3_test.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "hdr/sys_stat_macros.h"
#include "src/fcntl/open.h"
#include "src/unistd/close.h"
#include "src/unistd/dup3.h"
@@ -16,8 +17,6 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include <sys/stat.h>
-
using LlvmLibcdupTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
// The tests here are exactly the same as those of dup2. We only test the
diff --git a/libc/test/src/unistd/dup_test.cpp b/libc/test/src/unistd/dup_test.cpp
index 8e0b662c3961b..62ce6d084e03d 100644
--- a/libc/test/src/unistd/dup_test.cpp
+++ b/libc/test/src/unistd/dup_test.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "hdr/sys_stat_macros.h"
#include "src/fcntl/open.h"
#include "src/unistd/close.h"
#include "src/unistd/dup.h"
@@ -16,8 +17,6 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include <sys/stat.h>
-
using LlvmLibcdupTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
TEST_F(LlvmLibcdupTest, ReadAndWriteViaDup) {
diff --git a/libc/test/src/unistd/faccessat_test.cpp b/libc/test/src/unistd/faccessat_test.cpp
index 6280b147c6d58..ca4e19f1aec75 100644
--- a/libc/test/src/unistd/faccessat_test.cpp
+++ b/libc/test/src/unistd/faccessat_test.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "hdr/sys_stat_macros.h"
#include "src/fcntl/open.h"
#include "src/unistd/close.h"
#include "src/unistd/faccessat.h"
@@ -15,7 +16,6 @@
#include "test/UnitTest/Test.h"
#include <fcntl.h>
-#include <sys/stat.h>
#include <unistd.h>
namespace {
diff --git a/libc/test/src/unistd/fchown_test.cpp b/libc/test/src/unistd/fchown_test.cpp
index 7954410afb929..9e0a35bfad6dc 100644
--- a/libc/test/src/unistd/fchown_test.cpp
+++ b/libc/test/src/unistd/fchown_test.cpp
@@ -13,13 +13,12 @@
#include "src/unistd/getuid.h"
#include "src/unistd/unlink.h"
+#include "hdr/fcntl_macros.h"
+#include "hdr/sys_stat_macros.h"
#include "test/UnitTest/ErrnoCheckingTest.h"
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include "hdr/fcntl_macros.h"
-#include <sys/stat.h>
-
using LlvmLibcFchownTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
TEST_F(LlvmLibcFchownTest, FchownSuccess) {
diff --git a/libc/test/src/unistd/ftruncate_test.cpp b/libc/test/src/unistd/ftruncate_test.cpp
index c50a07f15f1e0..b23a208e9cb70 100644
--- a/libc/test/src/unistd/ftruncate_test.cpp
+++ b/libc/test/src/unistd/ftruncate_test.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "hdr/sys_stat_macros.h"
#include "src/__support/CPP/string_view.h"
#include "src/fcntl/open.h"
#include "src/unistd/close.h"
@@ -17,8 +18,6 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include <sys/stat.h>
-
namespace cpp = LIBC_NAMESPACE::cpp;
using LlvmLibcFtruncateTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
diff --git a/libc/test/src/unistd/isatty_test.cpp b/libc/test/src/unistd/isatty_test.cpp
index 63a0bf7e059b0..f7174c2cf163b 100644
--- a/libc/test/src/unistd/isatty_test.cpp
+++ b/libc/test/src/unistd/isatty_test.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "hdr/sys_stat_macros.h"
#include "src/fcntl/open.h"
#include "src/unistd/close.h"
#include "src/unistd/isatty.h"
@@ -13,8 +14,6 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include <sys/stat.h>
-
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
using LlvmLibcIsATTYTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
diff --git a/libc/test/src/unistd/link_test.cpp b/libc/test/src/unistd/link_test.cpp
index e91edd55e67ca..eda5ce5c30a09 100644
--- a/libc/test/src/unistd/link_test.cpp
+++ b/libc/test/src/unistd/link_test.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "hdr/sys_stat_macros.h"
#include "src/fcntl/open.h"
#include "src/unistd/close.h"
#include "src/unistd/link.h"
@@ -14,8 +15,6 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include <sys/stat.h>
-
using LlvmLibcLinkTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
TEST_F(LlvmLibcLinkTest, CreateAndUnlink) {
diff --git a/libc/test/src/unistd/linkat_test.cpp b/libc/test/src/unistd/linkat_test.cpp
index 1d8290832b027..04b9357590f89 100644
--- a/libc/test/src/unistd/linkat_test.cpp
+++ b/libc/test/src/unistd/linkat_test.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "hdr/sys_stat_macros.h"
#include "src/fcntl/open.h"
#include "src/unistd/close.h"
#include "src/unistd/linkat.h"
@@ -14,8 +15,6 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include <sys/stat.h>
-
using LlvmLibcLinkatTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
TEST_F(LlvmLibcLinkatTest, CreateAndUnlink) {
diff --git a/libc/test/src/unistd/pread_pwrite_test.cpp b/libc/test/src/unistd/pread_pwrite_test.cpp
index b1491a07f15fb..5ac2410d5f986 100644
--- a/libc/test/src/unistd/pread_pwrite_test.cpp
+++ b/libc/test/src/unistd/pread_pwrite_test.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "hdr/sys_stat_macros.h"
#include "src/fcntl/open.h"
#include "src/unistd/close.h"
#include "src/unistd/fsync.h"
@@ -17,8 +18,6 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include <sys/stat.h>
-
using LlvmLibcUniStd = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
TEST_F(LlvmLibcUniStd, PWriteAndPReadBackTest) {
diff --git a/libc/test/src/unistd/read_write_test.cpp b/libc/test/src/unistd/read_write_test.cpp
index 3fd9c5047fb5d..17cd4f6ce8b44 100644
--- a/libc/test/src/unistd/read_write_test.cpp
+++ b/libc/test/src/unistd/read_write_test.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "hdr/sys_stat_macros.h"
#include "src/fcntl/open.h"
#include "src/stdio/remove.h"
#include "src/unistd/close.h"
@@ -16,8 +17,6 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include <sys/stat.h>
-
using LlvmLibcUniStd = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
TEST_F(LlvmLibcUniStd, WriteAndReadBackTest) {
diff --git a/libc/test/src/unistd/symlink_test.cpp b/libc/test/src/unistd/symlink_test.cpp
index 1cc90becb5fd3..f5154a9b9de03 100644
--- a/libc/test/src/unistd/symlink_test.cpp
+++ b/libc/test/src/unistd/symlink_test.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "hdr/sys_stat_macros.h"
#include "src/fcntl/open.h"
#include "src/unistd/close.h"
#include "src/unistd/symlink.h"
@@ -14,8 +15,6 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include <sys/stat.h>
-
using LlvmLibcSymlinkTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
TEST_F(LlvmLibcSymlinkTest, CreateAndUnlink) {
diff --git a/libc/test/src/unistd/symlinkat_test.cpp b/libc/test/src/unistd/symlinkat_test.cpp
index 85970be6e2286..8679185758407 100644
--- a/libc/test/src/unistd/symlinkat_test.cpp
+++ b/libc/test/src/unistd/symlinkat_test.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "hdr/sys_stat_macros.h"
#include "src/fcntl/open.h"
#include "src/unistd/close.h"
#include "src/unistd/symlinkat.h"
@@ -14,8 +15,6 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include <sys/stat.h>
-
using LlvmLibcSymlinkatTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
TEST_F(LlvmLibcSymlinkatTest, CreateAndUnlink) {
diff --git a/libc/test/src/unistd/syscall_test.cpp b/libc/test/src/unistd/syscall_test.cpp
index 85caef297cab3..1c696dd7b2ea1 100644
--- a/libc/test/src/unistd/syscall_test.cpp
+++ b/libc/test/src/unistd/syscall_test.cpp
@@ -12,7 +12,7 @@
#include "test/UnitTest/Test.h"
#include "hdr/fcntl_macros.h"
-#include <sys/stat.h> // For S_* flags.
+#include "hdr/sys_stat_macros.h" // For S_* flags.
#include <sys/syscall.h> // For syscall numbers.
#include <unistd.h>
diff --git a/libc/test/src/unistd/truncate_test.cpp b/libc/test/src/unistd/truncate_test.cpp
index 0af3b63e66871..86fcdcfa96ac8 100644
--- a/libc/test/src/unistd/truncate_test.cpp
+++ b/libc/test/src/unistd/truncate_test.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "hdr/sys_stat_macros.h"
#include "src/__support/CPP/string_view.h"
#include "src/fcntl/open.h"
#include "src/unistd/close.h"
@@ -17,8 +18,6 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include <sys/stat.h>
-
namespace cpp = LIBC_NAMESPACE::cpp;
using LlvmLibcTruncateTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
diff --git a/libc/test/src/unistd/unlink_test.cpp b/libc/test/src/unistd/unlink_test.cpp
index 892779b30cb8e..5b498fbcf29a5 100644
--- a/libc/test/src/unistd/unlink_test.cpp
+++ b/libc/test/src/unistd/unlink_test.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "hdr/sys_stat_macros.h"
#include "src/fcntl/open.h"
#include "src/unistd/close.h"
#include "src/unistd/unlink.h"
@@ -13,8 +14,6 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include <sys/stat.h>
-
using LlvmLibcUnlinkTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
TEST_F(LlvmLibcUnlinkTest, CreateAndUnlink) {
diff --git a/libc/test/src/unistd/unlinkat_test.cpp b/libc/test/src/unistd/unlinkat_test.cpp
index e862ad1142095..b7ac37ac9fa00 100644
--- a/libc/test/src/unistd/unlinkat_test.cpp
+++ b/libc/test/src/unistd/unlinkat_test.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "hdr/sys_stat_macros.h"
#include "src/fcntl/open.h"
#include "src/fcntl/openat.h"
#include "src/unistd/close.h"
@@ -14,8 +15,6 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include <sys/stat.h>
-
using LlvmLibcUnlinkatTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
TEST_F(LlvmLibcUnlinkatTest, CreateAndDeleteTest) {
More information about the libc-commits
mailing list