delete a redundant if in dynamic linker ctor execution loop
[musl.git] / src / linux / prlimit.c
blob3df9ffba7af848c0b4fc0b231cbf2ca477b75166
1 #define _GNU_SOURCE
2 #include <sys/resource.h>
3 #include "syscall.h"
5 #define FIX(x) do{ if ((x)>=SYSCALL_RLIM_INFINITY) (x)=RLIM_INFINITY; }while(0)
7 int prlimit(pid_t pid, int resource, const struct rlimit *new_limit, struct rlimit *old_limit)
9 struct rlimit tmp;
10 int r;
11 if (new_limit && SYSCALL_RLIM_INFINITY != RLIM_INFINITY) {
12 tmp = *new_limit;
13 FIX(tmp.rlim_cur);
14 FIX(tmp.rlim_max);
15 new_limit = &tmp;
17 r = syscall(SYS_prlimit64, pid, resource, new_limit, old_limit);
18 if (!r && old_limit && SYSCALL_RLIM_INFINITY != RLIM_INFINITY) {
19 FIX(old_limit->rlim_cur);
20 FIX(old_limit->rlim_max);
22 return r;
25 #undef prlimit64
26 weak_alias(prlimit, prlimit64);