diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2017-08-02 13:43:44 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2017-08-07 23:41:39 +0900 |
commit | 29ea9f0f42c20d9cad137ea7f7b0e19b630e5235 (patch) | |
tree | dcbb1a841d35a5e7ec4c0a9858d0db0179bccf9e /src/basic | |
parent | 032cf8e4d2619ec6e51cf334fe4cd3e5315b8145 (diff) | |
download | systemd-29ea9f0f42c20d9cad137ea7f7b0e19b630e5235.tar.gz systemd-29ea9f0f42c20d9cad137ea7f7b0e19b630e5235.tar.bz2 systemd-29ea9f0f42c20d9cad137ea7f7b0e19b630e5235.zip |
process-util: add sched_{policy,priority}_is_valid()
Diffstat (limited to 'src/basic')
-rw-r--r-- | src/basic/process-util.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/basic/process-util.h b/src/basic/process-util.h index b45d60dbd1..913991b3cb 100644 --- a/src/basic/process-util.h +++ b/src/basic/process-util.h @@ -20,6 +20,7 @@ ***/ #include <alloca.h> +#include <sched.h> #include <signal.h> #include <stdbool.h> #include <stddef.h> @@ -110,6 +111,14 @@ static inline bool nice_is_valid(int n) { return n >= PRIO_MIN && n < PRIO_MAX; } +static inline bool sched_policy_is_valid(int i) { + return IN_SET(i, SCHED_OTHER, SCHED_BATCH, SCHED_IDLE, SCHED_FIFO, SCHED_RR); +} + +static inline bool sched_priority_is_valid(int i) { + return i >= 0 && i <= sched_get_priority_max(SCHED_RR); +} + static inline bool ioprio_class_is_valid(int i) { return IN_SET(i, IOPRIO_CLASS_NONE, IOPRIO_CLASS_RT, IOPRIO_CLASS_BE, IOPRIO_CLASS_IDLE); } |