[libc-commits] [libc] 97a03eb - [libc] Fix sched_get_priority_max() syscall invocation

Michael Jones via libc-commits libc-commits at lists.llvm.org
Tue Apr 25 16:17:52 PDT 2023


Author: Tal Zussman
Date: 2023-04-25T16:17:47-07:00
New Revision: 97a03eb2eb5acf269db6253fe540626b52950f97

URL: https://github.com/llvm/llvm-project/commit/97a03eb2eb5acf269db6253fe540626b52950f97
DIFF: https://github.com/llvm/llvm-project/commit/97a03eb2eb5acf269db6253fe540626b52950f97.diff

LOG: [libc] Fix sched_get_priority_max() syscall invocation

Previously used SYS_sched_get_priority_min. This also updates the tests
for SCHED_RR and SCHED_FIFO to check max_priority > min_priority, rather
than >= in order to catch future breakages.

Reviewed By: michaelrj, goldstein.w.n

Differential Revision: https://reviews.llvm.org/D149102

Added: 
    

Modified: 
    libc/src/sched/linux/sched_get_priority_max.cpp
    libc/test/src/sched/get_priority_test.cpp

Removed: 
    


################################################################################
diff  --git a/libc/src/sched/linux/sched_get_priority_max.cpp b/libc/src/sched/linux/sched_get_priority_max.cpp
index 87d52f43c915c..859c9755c783d 100644
--- a/libc/src/sched/linux/sched_get_priority_max.cpp
+++ b/libc/src/sched/linux/sched_get_priority_max.cpp
@@ -17,7 +17,7 @@
 namespace __llvm_libc {
 
 LLVM_LIBC_FUNCTION(int, sched_get_priority_max, (int policy)) {
-  long ret = __llvm_libc::syscall_impl(SYS_sched_get_priority_min, policy);
+  long ret = __llvm_libc::syscall_impl(SYS_sched_get_priority_max, policy);
   if (ret < 0) {
     libc_errno = -ret;
     return -1;

diff  --git a/libc/test/src/sched/get_priority_test.cpp b/libc/test/src/sched/get_priority_test.cpp
index fb532e25688e9..15ee958ec16f4 100644
--- a/libc/test/src/sched/get_priority_test.cpp
+++ b/libc/test/src/sched/get_priority_test.cpp
@@ -89,7 +89,7 @@ TEST(LlvmLibcSchedGetPriorityTest, SmokeTest) {
 
     ASSERT_LE(max_priority, 99);
     ASSERT_GE(min_priority, 0);
-    ASSERT_GE(max_priority, min_priority);
+    ASSERT_GT(max_priority, min_priority);
   }
 
   {
@@ -103,6 +103,6 @@ TEST(LlvmLibcSchedGetPriorityTest, SmokeTest) {
 
     ASSERT_LE(max_priority, 99);
     ASSERT_GE(min_priority, 0);
-    ASSERT_GE(max_priority, min_priority);
+    ASSERT_GT(max_priority, min_priority);
   }
 }


        


More information about the libc-commits mailing list