summaryrefslogtreecommitdiff
path: root/libc/include
diff options
context:
space:
mode:
authorNoah Goldstein <goldstein.w.n@gmail.com>2023-04-20 14:51:10 -0500
committerNoah Goldstein <goldstein.w.n@gmail.com>2023-04-20 14:53:41 -0500
commit0432b85d8e800439e57642bb25e93c32fa864f5c (patch)
treef41bbf81fdb459279eabc7159a8239c42ddcc10c /libc/include
parentef0949828e15d28a92ea04b84d803f1e05bdb1d6 (diff)
downloadllvm-0432b85d8e800439e57642bb25e93c32fa864f5c.tar.gz
[LIBC] Implement remainder of posix 'sched.h' minus `SCHED_SPORADIC`
Includes macros: linux/SCHED_OTHER // posix req linux/SCHED_FIFO // posix req linux/SCHED_RR // posix req linux/SCHED_BATCH linux/SCHED_ISO linux/SCHED_IDLE linux/SCHED_DEADLINE Includes types: struct sched_param { int sched_priority; } Includes functions: sched_setparam sched_getparam sched_setscheduler sched_getscheduler sched_get_priority_max sched_get_priority_min sched_rr_get_interval Reviewed By: michaelrj Differential Revision: https://reviews.llvm.org/D148069
Diffstat (limited to 'libc/include')
-rw-r--r--libc/include/CMakeLists.txt6
-rw-r--r--libc/include/llvm-libc-macros/linux/sched-macros.h14
-rw-r--r--libc/include/llvm-libc-types/CMakeLists.txt1
-rw-r--r--libc/include/llvm-libc-types/struct_sched_param.h21
4 files changed, 41 insertions, 1 deletions
diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index bd2458eb3856..f3b23a5e3e26 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -248,9 +248,13 @@ add_gen_header(
DEPENDS
.llvm_libc_common_h
.llvm-libc-macros.sched_macros
+ .llvm-libc-types.cpu_set_t
.llvm-libc-types.pid_t
.llvm-libc-types.size_t
- .llvm-libc-types.cpu_set_t
+ .llvm-libc-types.struct_sched_param
+ # Needed according to posix standard
+ .llvm-libc-types.time_t
+ .llvm-libc-types.struct_timespec
)
add_gen_header(
diff --git a/libc/include/llvm-libc-macros/linux/sched-macros.h b/libc/include/llvm-libc-macros/linux/sched-macros.h
index f9980b060fd3..0c574440ccbc 100644
--- a/libc/include/llvm-libc-macros/linux/sched-macros.h
+++ b/libc/include/llvm-libc-macros/linux/sched-macros.h
@@ -9,6 +9,20 @@
#ifndef __LLVM_LIBC_MACROS_LINUX_SCHED_MACROS_H
#define __LLVM_LIBC_MACROS_LINUX_SCHED_MACROS_H
+// Definitions of SCHED_* macros must match was linux as at:
+// https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/sched.h
+
+// Posix required
+#define SCHED_OTHER 0
+#define SCHED_FIFO 1
+#define SCHED_RR 2
+
+// Linux extentions
+#define SCHED_BATCH 3
+#define SCHED_ISO 4 // Not yet implemented, reserved.
+#define SCHED_IDLE 5
+#define SCHED_DEADLINE 6
+
#define CPU_COUNT_S(setsize, set) __sched_getcpucount(setsize, set)
#define CPU_COUNT(set) CPU_COUNT_S(sizeof(cpu_set_t), set)
diff --git a/libc/include/llvm-libc-types/CMakeLists.txt b/libc/include/llvm-libc-types/CMakeLists.txt
index 289307b76bbd..37230208e458 100644
--- a/libc/include/llvm-libc-types/CMakeLists.txt
+++ b/libc/include/llvm-libc-types/CMakeLists.txt
@@ -60,6 +60,7 @@ add_header(struct_timeval HDR struct_timeval.h DEPENDS .suseconds_t .time_t)
add_header(struct_rlimit HDR struct_rlimit.h DEPENDS .rlim_t)
add_header(struct_rusage HDR struct_rusage.h DEPENDS .struct_timeval)
add_header(struct_dirent HDR struct_dirent.h DEPENDS .ino_t .off_t)
+add_header(struct_sched_param HDR struct_sched_param.h)
add_header(union_sigval HDR union_sigval.h)
add_header(siginfo_t HDR siginfo_t.h DEPENDS .union_sigval .pid_t .uid_t)
add_header(sig_atomic_t HDR sig_atomic_t.h)
diff --git a/libc/include/llvm-libc-types/struct_sched_param.h b/libc/include/llvm-libc-types/struct_sched_param.h
new file mode 100644
index 000000000000..4f31881ceeb6
--- /dev/null
+++ b/libc/include/llvm-libc-types/struct_sched_param.h
@@ -0,0 +1,21 @@
+//===-- Definition of type 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_TYPES_STRUCT_SCHED_PARAM_H__
+#define __LLVM_LIBC_TYPES_STRUCT_SCHED_PARAM_H__
+
+#include <llvm-libc-types/pid_t.h>
+#include <llvm-libc-types/struct_timespec.h>
+#include <llvm-libc-types/time_t.h>
+
+struct sched_param {
+ // Process or thread execution scheduling priority.
+ int sched_priority;
+};
+
+#endif // __LLVM_LIBC_TYPES_STRUCT_SCHED_PARAM_H__