xref: /haiku/src/system/libroot/posix/sys/rlimit.c (revision 323b65468e5836bb27a5e373b14027d902349437)
1 /*
2 ** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 ** Distributed under the terms of the Haiku License.
4 */
5 
6 
7 #include <sys/resource.h>
8 #include <syscalls.h>
9 #include <errno.h>
10 
11 #include <errno_private.h>
12 
13 
14 #define RETURN_AND_SET_ERRNO(err) \
15 	if (err < 0) { \
16 		__set_errno(err); \
17 		return -1; \
18 	} \
19 	return err;
20 
21 
22 int
23 getrlimit(int resource, struct rlimit *rlimit)
24 {
25 	int status = _kern_getrlimit(resource, rlimit);
26 
27 	RETURN_AND_SET_ERRNO(status);
28 }
29 
30 
31 int
32 setrlimit(int resource, const struct rlimit *rlimit)
33 {
34 	int status = _kern_setrlimit(resource, rlimit);
35 
36 	RETURN_AND_SET_ERRNO(status);
37 }
38 
39