1 /* vi: set sw=4 ts=4: */
3 * getrlimit() for uClibc
5 * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
7 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
10 #include <sys/syscall.h>
11 #include <sys/resource.h>
12 #include <bits/wordsize.h>
14 /* Only wrap getrlimit if the new ugetrlimit is not present and getrlimit sucks */
16 #if defined __NR_ugetrlimit
18 /* just call ugetrlimit() */
19 # define __NR___syscall_ugetrlimit __NR_ugetrlimit
20 static __always_inline
21 _syscall2(int, __syscall_ugetrlimit, enum __rlimit_resource, resource,
22 struct rlimit *, rlim)
23 int getrlimit(__rlimit_resource_t resource, struct rlimit *rlimits)
25 return __syscall_ugetrlimit(resource, rlimits);
28 #elif !defined(__UCLIBC_HANDLE_OLDER_RLIMIT__)
30 /* We don't need to wrap getrlimit() */
31 _syscall2(int, getrlimit, __rlimit_resource_t, resource,
32 struct rlimit *, rlim)
36 /* we have to handle old style getrlimit() */
37 # define __NR___syscall_getrlimit __NR_getrlimit
38 static __always_inline
39 _syscall2(int, __syscall_getrlimit, int, resource, struct rlimit *, rlim)
41 int getrlimit(__rlimit_resource_t resource, struct rlimit *rlimits)
45 result = __syscall_getrlimit(resource, rlimits);
50 /* We might have to correct the limits values. Since the old values
51 * were signed the infinity value is too small. */
52 if (rlimits->rlim_cur == RLIM_INFINITY >> 1)
53 rlimits->rlim_cur = RLIM_INFINITY;
54 if (rlimits->rlim_max == RLIM_INFINITY >> 1)
55 rlimits->rlim_max = RLIM_INFINITY;
59 libc_hidden_def(getrlimit)
61 #if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 64
62 strong_alias_untyped(getrlimit, getrlimit64)