]>
Commit | Line | Data |
---|---|---|
2b778ceb | 1 | /* Copyright (C) 2013-2021 Free Software Foundation, Inc. |
9480dfe2 AJ |
2 | This file is part of the GNU C Library. |
3 | ||
4 | The GNU C Library is free software; you can redistribute it and/or | |
5 | modify it under the terms of the GNU Lesser General Public | |
6 | License as published by the Free Software Foundation; either | |
7 | version 2.1 of the License, or (at your option) any later version. | |
8 | ||
9 | The GNU C Library is distributed in the hope that it will be useful, | |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
12 | Lesser General Public License for more details. | |
13 | ||
14 | You should have received a copy of the GNU Lesser General Public | |
15 | License along with the GNU C Library; if not, see | |
5a82c748 | 16 | <https://www.gnu.org/licenses/>. */ |
9480dfe2 | 17 | |
1ca2d03e JM |
18 | #include <sgidefs.h> |
19 | ||
9480dfe2 AJ |
20 | #if _MIPS_SIM == _ABIO32 || _MIPS_SIM == _ABIN32 |
21 | ||
24d8773d AJ |
22 | # include <shlib-compat.h> |
23 | ||
24 | # define getrlimit64 __new_getrlimit64 | |
9480dfe2 AJ |
25 | # include <sysdeps/unix/sysv/linux/getrlimit64.c> |
26 | # undef getrlimit64 | |
24d8773d | 27 | |
1a2325c0 JM |
28 | versioned_symbol (libc, __getrlimit64, getrlimit64, GLIBC_2_19); |
29 | strong_alias (__getrlimit64, __GI_getrlimit64) | |
24d8773d AJ |
30 | |
31 | # if SHLIB_COMPAT (libc, GLIBC_2_2, GLIBC_2_19) | |
9480dfe2 AJ |
32 | |
33 | /* RLIM64_INFINITY was supposed to be a glibc convention rather than | |
34 | anything seen by the kernel, but it ended being passed to the kernel | |
35 | through the prlimit64 syscall. Given that a lot of binaries with | |
36 | the wrong constant value are in the wild, provide a wrapper function | |
37 | fixing the value after the syscall. */ | |
38 | ||
24d8773d | 39 | # define OLD_RLIM64_INFINITY 0x7fffffffffffffffULL |
9480dfe2 AJ |
40 | |
41 | int | |
24d8773d AJ |
42 | attribute_compat_text_section |
43 | __old_getrlimit64 (enum __rlimit_resource resource, | |
44 | struct rlimit64 *rlimits) | |
9480dfe2 AJ |
45 | { |
46 | struct rlimit64 krlimits; | |
47 | ||
1a2325c0 | 48 | if (__getrlimit64 (resource, &krlimits) < 0) |
9480dfe2 AJ |
49 | return -1; |
50 | ||
24d8773d AJ |
51 | if (krlimits.rlim_cur == RLIM64_INFINITY) |
52 | rlimits->rlim_cur = OLD_RLIM64_INFINITY; | |
9480dfe2 AJ |
53 | else |
54 | rlimits->rlim_cur = krlimits.rlim_cur; | |
24d8773d AJ |
55 | if (krlimits.rlim_max == RLIM64_INFINITY) |
56 | rlimits->rlim_max = OLD_RLIM64_INFINITY; | |
9480dfe2 AJ |
57 | else |
58 | rlimits->rlim_max = krlimits.rlim_max; | |
59 | ||
60 | return 0; | |
61 | } | |
62 | ||
24d8773d AJ |
63 | compat_symbol (libc, __old_getrlimit64, getrlimit64, GLIBC_2_2); |
64 | # endif | |
9480dfe2 AJ |
65 | |
66 | #else /* !_ABI_O32 && !_ABI_N32 */ | |
67 | # include <sysdeps/unix/sysv/linux/getrlimit64.c> | |
68 | #endif |