summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/common/setrlimit.c
diff options
context:
space:
mode:
authorPeter S. Mazinger <ps.m@gmx.net>2011-04-16 01:20:21 +0200
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2012-06-15 14:00:38 +0200
commitc28cabb17933d98c9046d4b2492e39757bbacf5a (patch)
tree0357aec448b18e219338dd25db9933c40f3cf5c4 /libc/sysdeps/linux/common/setrlimit.c
parente21479da34bbe39fb9d99e2f6e323fd1a942d9cb (diff)
Reorder includes and include only what is necessary
Use param.h instead of MIN. Use stddef.h instead of offsetof. Signed-off-by: Peter S. Mazinger <ps.m@gmx.net> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Diffstat (limited to 'libc/sysdeps/linux/common/setrlimit.c')
-rw-r--r--libc/sysdeps/linux/common/setrlimit.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/libc/sysdeps/linux/common/setrlimit.c b/libc/sysdeps/linux/common/setrlimit.c
index 6817a9c92..d96700aec 100644
--- a/libc/sysdeps/linux/common/setrlimit.c
+++ b/libc/sysdeps/linux/common/setrlimit.c
@@ -8,8 +8,8 @@
*/
#include <sys/syscall.h>
-#include <unistd.h>
#include <sys/resource.h>
+#include <bits/wordsize.h>
/* Only wrap setrlimit if the new usetrlimit is not present and setrlimit sucks */
@@ -22,7 +22,7 @@ _syscall2(int, __syscall_usetrlimit, enum __rlimit_resource, resource,
const struct rlimit *, rlim)
int setrlimit(__rlimit_resource_t resource, struct rlimit *rlimits)
{
- return (__syscall_usetrlimit(resource, rlimits));
+ return __syscall_usetrlimit(resource, rlimits);
}
#elif !defined(__UCLIBC_HANDLE_OLDER_RLIMIT__)
@@ -33,6 +33,11 @@ _syscall2(int, setrlimit, __rlimit_resource_t, resource,
#else
+# define __need_NULL
+# include <stddef.h>
+# include <errno.h>
+# include <sys/param.h>
+
/* we have to handle old style setrlimit() */
# define __NR___syscall_setrlimit __NR_setrlimit
static __always_inline
@@ -49,16 +54,13 @@ int setrlimit(__rlimit_resource_t resource, const struct rlimit *rlimits)
/* We might have to correct the limits values. Since the old values
* were signed the new values might be too large. */
-# define RMIN(x, y) ((x) < (y) ? (x) : (y))
- rlimits_small.rlim_cur = RMIN((unsigned long int) rlimits->rlim_cur,
+ rlimits_small.rlim_cur = MIN((unsigned long int) rlimits->rlim_cur,
RLIM_INFINITY >> 1);
- rlimits_small.rlim_max = RMIN((unsigned long int) rlimits->rlim_max,
+ rlimits_small.rlim_max = MIN((unsigned long int) rlimits->rlim_max,
RLIM_INFINITY >> 1);
-#undef RMIN
- return (__syscall_setrlimit(resource, &rlimits_small));
+ return __syscall_setrlimit(resource, &rlimits_small);
}
#endif
-
libc_hidden_def(setrlimit)
#if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 64