| 1 | /* Linux getrlimit implementation (32 bits rlim_t). |
| 2 | Copyright (C) 2016-2020 Free Software Foundation, Inc. |
| 3 | This file is part of the GNU C Library. |
| 4 | |
| 5 | The GNU C Library is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU Lesser General Public |
| 7 | License as published by the Free Software Foundation; either |
| 8 | version 2.1 of the License, or (at your option) any later version. |
| 9 | |
| 10 | The GNU C Library is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | Lesser General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU Lesser General Public |
| 16 | License along with the GNU C Library. If not, see |
| 17 | <https://www.gnu.org/licenses/>. */ |
| 18 | |
| 19 | #include <errno.h> |
| 20 | #include <sys/resource.h> |
| 21 | #include <sys/types.h> |
| 22 | #include <shlib-compat.h> |
| 23 | |
| 24 | #if !__RLIM_T_MATCHES_RLIM64_T |
| 25 | |
| 26 | /* The __NR_getrlimit compatibility implementation is required iff |
| 27 | __NR_ugetrlimit is also defined (meaning an old broken RLIM_INFINITY |
| 28 | definition). */ |
| 29 | # ifndef __NR_ugetrlimit |
| 30 | # define __NR_ugetrlimit __NR_getrlimit |
| 31 | # undef SHLIB_COMPAT |
| 32 | # define SHLIB_COMPAT(a, b, c) 0 |
| 33 | # endif |
| 34 | |
| 35 | int |
| 36 | __new_getrlimit (enum __rlimit_resource resource, struct rlimit *rlim) |
| 37 | { |
| 38 | return INLINE_SYSCALL_CALL (ugetrlimit, resource, rlim); |
| 39 | } |
| 40 | weak_alias (__new_getrlimit, __getrlimit) |
| 41 | hidden_weak (__getrlimit) |
| 42 | |
| 43 | # if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2) |
| 44 | /* Back compatible 2Gig limited rlimit. */ |
| 45 | int |
| 46 | __old_getrlimit (enum __rlimit_resource resource, struct rlimit *rlim) |
| 47 | { |
| 48 | return INLINE_SYSCALL_CALL (getrlimit, resource, rlim); |
| 49 | } |
| 50 | compat_symbol (libc, __old_getrlimit, getrlimit, GLIBC_2_0); |
| 51 | versioned_symbol (libc, __new_getrlimit, getrlimit, GLIBC_2_2); |
| 52 | # else |
| 53 | weak_alias (__new_getrlimit, getrlimit) |
| 54 | # endif |
| 55 | |
| 56 | #endif /* __RLIM_T_MATCHES_RLIM64_T */ |
| 57 | |