-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[libc] Add struct_sched_param proxy header #151722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[libc] Add struct_sched_param proxy header #151722
Conversation
This enables cleaning up the remaining sched.h includes littered around the code base.
@llvm/pr-subscribers-libc Author: Aiden Grossman (boomanaiden154) ChangesThis enables cleaning up the remaining sched.h includes littered around the code base. Full diff: https://github.com/llvm/llvm-project/pull/151722.diff 9 Files Affected:
diff --git a/libc/hdr/types/CMakeLists.txt b/libc/hdr/types/CMakeLists.txt
index 1c1f242e84341..7db38e528a9c0 100644
--- a/libc/hdr/types/CMakeLists.txt
+++ b/libc/hdr/types/CMakeLists.txt
@@ -451,3 +451,11 @@ add_proxy_header_library(
libc.include.llvm-libc-types.ACTION
libc.include.search
)
+
+add_proxy_header_library(
+ struct_sched_param
+ HDRS
+ struct_sched_param.h
+ FULL_BUILD_DEPENDS
+ libc.include.llvm-libc-types.struct_sched_param
+)
diff --git a/libc/hdr/types/struct_sched_param.h b/libc/hdr/types/struct_sched_param.h
new file mode 100644
index 0000000000000..b1bdcf9573243
--- /dev/null
+++ b/libc/hdr/types/struct_sched_param.h
@@ -0,0 +1,22 @@
+//===-- Proxy for struct sched_param --------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_STRUCT_SCHED_PARAM_H
+#define LLVM_LIBC_HDR_TYPES_STRUCT_SCHED_PARAM_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/struct_sched_param.h"
+
+#else // Overlay mode
+
+#include <sched.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_STRUCT_SCHED_PARAM_H
diff --git a/libc/src/sched/linux/CMakeLists.txt b/libc/src/sched/linux/CMakeLists.txt
index bb5000288d0e7..ceb755f8e1d1a 100644
--- a/libc/src/sched/linux/CMakeLists.txt
+++ b/libc/src/sched/linux/CMakeLists.txt
@@ -5,7 +5,6 @@ add_entrypoint_object(
HDRS
../getcpu.h
DEPENDS
- libc.include.sched
libc.src.__support.OSUtil.osutil
libc.src.errno.errno
)
@@ -69,9 +68,10 @@ add_entrypoint_object(
HDRS
../sched_setparam.h
DEPENDS
+ libc.hdr.types.pid_t
+ libc.hdr.types.struct_sched_param
libc.include.sys_syscall
libc.include.time
- libc.include.sched
libc.src.__support.OSUtil.osutil
libc.src.errno.errno
)
@@ -83,9 +83,10 @@ add_entrypoint_object(
HDRS
../sched_getparam.h
DEPENDS
+ libc.hdr.types.pid_t
+ libc.hdr.types.struct_sched_param
libc.include.sys_syscall
libc.include.time
- libc.include.sched
libc.src.__support.OSUtil.osutil
libc.src.errno.errno
)
@@ -97,9 +98,10 @@ add_entrypoint_object(
HDRS
../sched_setscheduler.h
DEPENDS
+ libc.hdr.types.pid_t
+ libc.hdr.types.struct_sched_param
libc.include.sys_syscall
libc.include.time
- libc.include.sched
libc.src.__support.OSUtil.osutil
libc.src.errno.errno
)
diff --git a/libc/src/sched/sched_getparam.h b/libc/src/sched/sched_getparam.h
index e1b23656d5859..00defdf816b3e 100644
--- a/libc/src/sched/sched_getparam.h
+++ b/libc/src/sched/sched_getparam.h
@@ -10,7 +10,9 @@
#define LLVM_LIBC_SRC_SCHED_SCHED_GETPARAM_H
#include "src/__support/macros/config.h"
-#include <sched.h>
+
+#include "hdr/types/pid_t.h"
+#include "hdr/types/struct_sched_param.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sched/sched_setparam.h b/libc/src/sched/sched_setparam.h
index e4691a7912000..5a69b09c4e704 100644
--- a/libc/src/sched/sched_setparam.h
+++ b/libc/src/sched/sched_setparam.h
@@ -10,7 +10,9 @@
#define LLVM_LIBC_SRC_SCHED_SCHED_SETPARAM_H
#include "src/__support/macros/config.h"
-#include <sched.h>
+
+#include "hdr/types/pid_t.h"
+#include "hdr/types/struct_sched_param.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sched/sched_setscheduler.h b/libc/src/sched/sched_setscheduler.h
index e745002c0d961..c5cb148378ec8 100644
--- a/libc/src/sched/sched_setscheduler.h
+++ b/libc/src/sched/sched_setscheduler.h
@@ -10,7 +10,9 @@
#define LLVM_LIBC_SRC_SCHED_SCHED_SETSCHEDULER_H
#include "src/__support/macros/config.h"
-#include <sched.h>
+
+#include "hdr/types/pid_t.h"
+#include "hdr/types/struct_sched_param.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/test/src/sched/CMakeLists.txt b/libc/test/src/sched/CMakeLists.txt
index f6151d0c9b33b..362c526312d42 100644
--- a/libc/test/src/sched/CMakeLists.txt
+++ b/libc/test/src/sched/CMakeLists.txt
@@ -48,7 +48,6 @@ add_libc_unittest(
SRCS
getcpu_test.cpp
DEPENDS
- libc.include.sched
libc.src.errno.errno
libc.src.sched.getcpu
libc.test.UnitTest.ErrnoCheckingTest
@@ -61,7 +60,8 @@ add_libc_unittest(
SRCS
param_and_scheduler_test.cpp
DEPENDS
- libc.include.sched
+ libc.hdr.sched_macros
+ libc.hdr.types.struct_sched_param
libc.src.errno.errno
libc.src.sched.sched_getscheduler
libc.src.sched.sched_setscheduler
@@ -79,6 +79,7 @@ add_libc_unittest(
SRCS
sched_rr_get_interval_test.cpp
DEPENDS
+ libc.hdr.sched_macros
libc.hdr.types.struct_timespec
libc.src.errno.errno
libc.src.sched.sched_getscheduler
diff --git a/libc/test/src/sched/param_and_scheduler_test.cpp b/libc/test/src/sched/param_and_scheduler_test.cpp
index 4f2b6e412a4b7..b8ee1233dfb86 100644
--- a/libc/test/src/sched/param_and_scheduler_test.cpp
+++ b/libc/test/src/sched/param_and_scheduler_test.cpp
@@ -16,7 +16,8 @@
#include "src/unistd/getuid.h"
#include "test/UnitTest/Test.h"
-#include <sched.h>
+#include "hdr/sched_macros.h"
+#include "hdr/types/struct_sched_param.h"
// We Test:
// SCHED_OTHER, SCHED_FIFO, SCHED_RR
diff --git a/libc/test/src/sched/sched_rr_get_interval_test.cpp b/libc/test/src/sched/sched_rr_get_interval_test.cpp
index 272cf866a3363..e5dc4e31d1c9d 100644
--- a/libc/test/src/sched/sched_rr_get_interval_test.cpp
+++ b/libc/test/src/sched/sched_rr_get_interval_test.cpp
@@ -14,6 +14,7 @@
#include "src/unistd/getuid.h"
#include "test/UnitTest/Test.h"
+#include "hdr/sched_macros.h"
#include "hdr/types/struct_timespec.h"
TEST(LlvmLibcSchedRRGetIntervalTest, SmokeTest) {
|
HDRS | ||
struct_sched_param.h | ||
FULL_BUILD_DEPENDS | ||
libc.include.llvm-libc-types.struct_sched_param |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add libc.include.sched to its full build dependency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would that be needed? The #include <sched.h>
gets removed by the preprocessor in full build mode.
The proxy header for cpu_set_t
does not include this either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is so that in full build mode, it will bring in our own generated sched.h
header, and forcing some build ordering with those generated headers. All the proxy headers should have that in their full build dependency. Sorry we might have not enforced that consistently. Can you also add that for something like cpu_set_t
also? Thanks,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused now.
How would it bring in the generated sched.h
header in full build mode? I thought the point of proxy headers was that you did not need to pull in the generated header.
I also don't understand how this is needed for build ordering. The headergen generated header shouldn't be needed until you actually want to use the libc given all of the definitions you'd normally need are in the proxy headers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is essentially making sure that if someone has targets using these types, the public sched.h
is generated in full build mode even if they don't or forget to include that in their list of public headers to be generated.
And ideally, all the generated headers should be done before all the code compilations, but our dependency management is not complete yet, and there are still quite some missing dependency that only show up as flaky tests once in awhile. Forcing public headers full build dependency is one way for us to mitigate this issue for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, okay. That makes sense.
Updated.
This enables cleaning up the remaining sched.h includes littered around the code base.