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 #define getrlimit64 __hide_getrlimit64
11 #include <sys/syscall.h>
13 #include <sys/resource.h>
16 /* libc_hidden_proto(getrlimit) */
18 /* Only wrap getrlimit if the new ugetrlimit is not present and getrlimit sucks */
20 #if defined __NR_ugetrlimit
22 /* just call ugetrlimit() */
23 # define __NR___syscall_ugetrlimit __NR_ugetrlimit
24 static __always_inline
25 _syscall2(int, __syscall_ugetrlimit, enum __rlimit_resource, resource,
26 struct rlimit *, rlim)
27 int getrlimit(__rlimit_resource_t resource, struct rlimit *rlimits)
29 return (__syscall_ugetrlimit(resource, rlimits));
32 #elif !defined(__UCLIBC_HANDLE_OLDER_RLIMIT__)
34 /* We don't need to wrap getrlimit() */
35 _syscall2(int, getrlimit, __rlimit_resource_t, resource,
36 struct rlimit *, rlim)
40 /* we have to handle old style getrlimit() */
41 # define __NR___syscall_getrlimit __NR_getrlimit
42 static __always_inline
43 _syscall2(int, __syscall_getrlimit, int, resource, struct rlimit *, rlim)
45 int getrlimit(__rlimit_resource_t resource, struct rlimit *rlimits)
49 result = __syscall_getrlimit(resource, rlimits);
54 /* We might have to correct the limits values. Since the old values
55 * were signed the infinity value is too small. */
56 if (rlimits->rlim_cur == RLIM_INFINITY >> 1)
57 rlimits->rlim_cur = RLIM_INFINITY;
58 if (rlimits->rlim_max == RLIM_INFINITY >> 1)
59 rlimits->rlim_max = RLIM_INFINITY;
64 libc_hidden_def(getrlimit)
66 #if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 64
67 strong_alias(getrlimit, getrlimit64)