[libc-commits] [libc] [llvm] [libc] Use a syscall wrapper for `sched_setscheduler` (PR #231865)

via libc-commits libc-commits at lists.llvm.org
Wed Oct 14 04:16:10 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Connector Switch (c8ef)

<details>
<summary>Changes</summary>

Follow up of https://github.com/llvm/llvm-project/pull/231512.

This PR move `sched_setscheduler` behind the centralized syscall wrappers, following `libc/docs/dev/syscall_wrapper_refactor.md`.

---
Full diff: https://github.com/llvm/llvm-project/pull/231865.diff


3 Files Affected:

- (modified) libc/src/sched/linux/CMakeLists.txt (+4-3) 
- (modified) libc/src/sched/linux/sched_setscheduler.cpp (+5-8) 
- (modified) utils/bazel/llvm-project-overlay/libc/BUILD.bazel (+15) 


``````````diff
diff --git a/libc/src/sched/linux/CMakeLists.txt b/libc/src/sched/linux/CMakeLists.txt
index e43c482ce6988..8029d83c046a8 100644
--- a/libc/src/sched/linux/CMakeLists.txt
+++ b/libc/src/sched/linux/CMakeLists.txt
@@ -132,9 +132,10 @@ add_entrypoint_object(
   DEPENDS
     libc.hdr.types.pid_t
     libc.hdr.types.struct_sched_param
-    libc.include.sys_syscall
-    libc.include.time
-    libc.src.__support.OSUtil.osutil
+    libc.src.__support.OSUtil.linux.syscall_wrappers.sched_setscheduler
+    libc.src.__support.common
+    libc.src.__support.libc_errno
+    libc.src.__support.macros.config
     libc.src.errno.errno
 )
 
diff --git a/libc/src/sched/linux/sched_setscheduler.cpp b/libc/src/sched/linux/sched_setscheduler.cpp
index 232e5a59b1858..039dfbb88ed48 100644
--- a/libc/src/sched/linux/sched_setscheduler.cpp
+++ b/libc/src/sched/linux/sched_setscheduler.cpp
@@ -8,24 +8,21 @@
 
 #include "src/sched/sched_setscheduler.h"
 
-#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
+#include "src/__support/OSUtil/linux/syscall_wrappers/sched_setscheduler.h"
 #include "src/__support/common.h"
 #include "src/__support/libc_errno.h"
 #include "src/__support/macros/config.h"
 
-#include <sys/syscall.h> // For syscall numbers.
-
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(int, sched_setscheduler,
                    (pid_t tid, int policy, const struct sched_param *param)) {
-  int ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_sched_setscheduler, tid,
-                                              policy, param);
-  if (ret < 0) {
-    libc_errno = -ret;
+  auto result = linux_syscalls::sched_setscheduler(tid, policy, param);
+  if (!result) {
+    libc_errno = result.error();
     return -1;
   }
-  return ret;
+  return result.value();
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 47c0bc59b5cae..131288e8d43fe 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -16891,6 +16891,21 @@ libc_function(
     ],
 )
 
+libc_function(
+    name = "sched_setscheduler",
+    srcs = ["src/sched/linux/sched_setscheduler.cpp"],
+    hdrs = ["src/sched/sched_setscheduler.h"],
+    deps = [
+        ":__support_common",
+        ":__support_libc_errno",
+        ":__support_macros_config",
+        ":__support_osutil_linux_syscall_wrappers_sched_setscheduler",
+        ":errno",
+        ":types_pid_t",
+        ":types_struct_sched_param",
+    ],
+)
+
 libc_function(
     name = "sched_yield",
     srcs = ["src/sched/linux/sched_yield.cpp"],

``````````

</details>


https://github.com/llvm/llvm-project/pull/231865


More information about the libc-commits mailing list