Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Unified Diff: fusl/src/linux/prlimit.c

Issue 1573973002: Add a "fork" of musl as //fusl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fusl/src/linux/prctl.c ('k') | fusl/src/linux/process_vm.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fusl/src/linux/prlimit.c
diff --git a/fusl/src/linux/prlimit.c b/fusl/src/linux/prlimit.c
new file mode 100644
index 0000000000000000000000000000000000000000..0fe28e10664e9047b1ca1a75bdab78c3e0407723
--- /dev/null
+++ b/fusl/src/linux/prlimit.c
@@ -0,0 +1,27 @@
+#define _GNU_SOURCE
+#include <sys/resource.h>
+#include "syscall.h"
+#include "libc.h"
+
+#define FIX(x) do{ if ((x)>=SYSCALL_RLIM_INFINITY) (x)=RLIM_INFINITY; }while(0)
+
+int prlimit(pid_t pid, int resource, const struct rlimit *new_limit, struct rlimit *old_limit)
+{
+ struct rlimit tmp;
+ int r;
+ if (new_limit && SYSCALL_RLIM_INFINITY != RLIM_INFINITY) {
+ tmp = *new_limit;
+ FIX(tmp.rlim_cur);
+ FIX(tmp.rlim_max);
+ new_limit = &tmp;
+ }
+ r = syscall(SYS_prlimit64, pid, resource, new_limit, old_limit);
+ if (!r && old_limit && SYSCALL_RLIM_INFINITY != RLIM_INFINITY) {
+ FIX(old_limit->rlim_cur);
+ FIX(old_limit->rlim_max);
+ }
+ return r;
+}
+
+#undef prlimit64
+LFS64(prlimit);
« no previous file with comments | « fusl/src/linux/prctl.c ('k') | fusl/src/linux/process_vm.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698