summaryrefslogtreecommitdiff
path: root/lib/libc/sys/resource
diff options
context:
space:
mode:
authorKacper <kacper@mail.openlinux.dev>2025-12-22 23:49:08 +0100
committerKacper <kacper@mail.openlinux.dev>2025-12-22 23:49:08 +0100
commit46fadf4bf14360be046b9b770ddf205fad96a0a7 (patch)
tree6e88bf6050e4f0cab877760e80f64bd708dd7400 /lib/libc/sys/resource
parent0f30d227497418c6d3bef7d52244407e30454504 (diff)
Add sys/resource.h implementation and nice(3)
Diffstat (limited to 'lib/libc/sys/resource')
-rw-r--r--lib/libc/sys/resource/getpriority.c12
-rw-r--r--lib/libc/sys/resource/getrlimit.c7
-rw-r--r--lib/libc/sys/resource/getrusage.c7
-rw-r--r--lib/libc/sys/resource/setpriority.c7
-rw-r--r--lib/libc/sys/resource/setrlimit.c7
5 files changed, 40 insertions, 0 deletions
diff --git a/lib/libc/sys/resource/getpriority.c b/lib/libc/sys/resource/getpriority.c
new file mode 100644
index 00000000..3df9eb30
--- /dev/null
+++ b/lib/libc/sys/resource/getpriority.c
@@ -0,0 +1,12 @@
+#include <sys/resource.h>
+#include <syscall.h>
+
+int getpriority(int which, int who)
+{
+ int r = syscall(getpriority, which, who);
+
+ if (r < 0)
+ return r;
+
+ return 20 - r;
+}
diff --git a/lib/libc/sys/resource/getrlimit.c b/lib/libc/sys/resource/getrlimit.c
new file mode 100644
index 00000000..7b7c8269
--- /dev/null
+++ b/lib/libc/sys/resource/getrlimit.c
@@ -0,0 +1,7 @@
+#include <sys/resource.h>
+#include <syscall.h>
+
+int getrlimit(int resource, struct rlimit *rlp)
+{
+ return syscall(getrlimit, resource, rlp);
+}
diff --git a/lib/libc/sys/resource/getrusage.c b/lib/libc/sys/resource/getrusage.c
new file mode 100644
index 00000000..a91ded16
--- /dev/null
+++ b/lib/libc/sys/resource/getrusage.c
@@ -0,0 +1,7 @@
+#include <sys/resource.h>
+#include <syscall.h>
+
+int getrusage(int who, struct rusage *r_usage)
+{
+ return syscall(getrusage, who, r_usage);
+}
diff --git a/lib/libc/sys/resource/setpriority.c b/lib/libc/sys/resource/setpriority.c
new file mode 100644
index 00000000..96bebbf2
--- /dev/null
+++ b/lib/libc/sys/resource/setpriority.c
@@ -0,0 +1,7 @@
+#include <sys/resource.h>
+#include <syscall.h>
+
+int setpriority(int which, int who, int value)
+{
+ return syscall(setpriority, which, who, value);
+}
diff --git a/lib/libc/sys/resource/setrlimit.c b/lib/libc/sys/resource/setrlimit.c
new file mode 100644
index 00000000..39148bc3
--- /dev/null
+++ b/lib/libc/sys/resource/setrlimit.c
@@ -0,0 +1,7 @@
+#include <sys/resource.h>
+#include <syscall.h>
+
+int setrlimit(int resource, const struct rlimit *rlp)
+{
+ return syscall(setrlimit, resource, rlp);
+}