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

Connector Switch via libc-commits libc-commits at lists.llvm.org
Fri Oct 16 04:19:57 PDT 2026


https://github.com/c8ef created https://github.com/llvm/llvm-project/pull/232689

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

>From d7f66840a4a1d90f4259b21339c805a4879006c2 Mon Sep 17 00:00:00 2001
From: c8ef <c8ef at outlook.com>
Date: Fri, 16 Oct 2026 19:18:42 +0800
Subject: [PATCH] [libc] Use a syscall wrapper for sched_getparam

---
 libc/src/sched/linux/CMakeLists.txt               |  7 ++++---
 libc/src/sched/linux/sched_getparam.cpp           | 10 ++++------
 utils/bazel/llvm-project-overlay/libc/BUILD.bazel | 15 +++++++++++++++
 3 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/libc/src/sched/linux/CMakeLists.txt b/libc/src/sched/linux/CMakeLists.txt
index ab6aaaed34103a..81c29f42469173 100644
--- a/libc/src/sched/linux/CMakeLists.txt
+++ b/libc/src/sched/linux/CMakeLists.txt
@@ -122,9 +122,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_getparam
+    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_getparam.cpp b/libc/src/sched/linux/sched_getparam.cpp
index b0576c3ac65b85..7f112177d9293b 100644
--- a/libc/src/sched/linux/sched_getparam.cpp
+++ b/libc/src/sched/linux/sched_getparam.cpp
@@ -8,20 +8,18 @@
 
 #include "src/sched/sched_getparam.h"
 
-#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
+#include "src/__support/OSUtil/linux/syscall_wrappers/sched_getparam.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_getparam,
                    (pid_t tid, struct sched_param *param)) {
-  int ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_sched_getparam, tid, param);
-  if (ret < 0) {
-    libc_errno = -ret;
+  auto result = linux_syscalls::sched_getparam(tid, param);
+  if (!result) {
+    libc_errno = result.error();
     return -1;
   }
   return 0;
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 781a1d1922d8ea..e7de2b1569fcc3 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -16973,6 +16973,21 @@ libc_function(
     ],
 )
 
+libc_function(
+    name = "sched_getparam",
+    srcs = ["src/sched/linux/sched_getparam.cpp"],
+    hdrs = ["src/sched/sched_getparam.h"],
+    deps = [
+        ":__support_common",
+        ":__support_libc_errno",
+        ":__support_macros_config",
+        ":__support_osutil_linux_syscall_wrappers_sched_getparam",
+        ":errno",
+        ":types_pid_t",
+        ":types_struct_sched_param",
+    ],
+)
+
 libc_function(
     name = "sched_getscheduler",
     srcs = ["src/sched/linux/sched_getscheduler.cpp"],



More information about the libc-commits mailing list