1 #include <sys/resource.h>
6 #define MIN(a, b) ((a)<(b) ? (a) : (b))
7 #define FIX(x) do{ if ((x)>=SYSCALL_RLIM_INFINITY) (x)=RLIM_INFINITY; }while(0)
16 static void do_setrlimit(void *p
)
20 c
->err
= -__syscall(SYS_setrlimit
, c
->res
, c
->lim
);
24 int setrlimit(int resource
, const struct rlimit
*rlim
)
27 if (SYSCALL_RLIM_INFINITY
!= RLIM_INFINITY
) {
33 int ret
= __syscall(SYS_prlimit64
, 0, resource
, rlim
, 0);
35 if (ret
!= -ENOSYS
) return __syscall_ret(ret
);
38 .lim
[0] = MIN(rlim
->rlim_cur
, MIN(-1UL, SYSCALL_RLIM_INFINITY
)),
39 .lim
[1] = MIN(rlim
->rlim_max
, MIN(-1UL, SYSCALL_RLIM_INFINITY
)),
40 .res
= resource
, .err
= -1
42 __synccall(do_setrlimit
, &c
);
44 if (c
.err
>0) errno
= c
.err
;
49 return __syscall_ret(ret
);