Update copyright notices with scripts/update-copyrights
[glibc.git] / ports / sysdeps / unix / sysv / linux / mips / setrlimit64.c
blob73d60950f2b8af3bde284608b3a9cecdd9153df2
1 /* Copyright (C) 2013-2014 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
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.
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.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
19 #if _MIPS_SIM == _ABIO32 || _MIPS_SIM == _ABIN32
21 # include <shlib-compat.h>
23 # define setrlimit64 __new_setrlimit64
24 # include <sysdeps/unix/sysv/linux/setrlimit64.c>
25 # undef setrlimit64
27 versioned_symbol (libc, __new_setrlimit64, setrlimit64, GLIBC_2_19);
29 # if SHLIB_COMPAT (libc, GLIBC_2_2, GLIBC_2_19)
31 /* RLIM64_INFINITY was supposed to be a glibc convention rather than
32 anything seen by the kernel, but it ended being passed to the kernel
33 through the prlimit64 syscall. Given that a lot of binaries with
34 the wrong constant value are in the wild, provide a wrapper function
35 fixing the value before the syscall. */
37 # define OLD_RLIM64_INFINITY 0x7fffffffffffffffULL
39 int
40 attribute_compat_text_section
41 __old_setrlimit64 (enum __rlimit_resource resource,
42 const struct rlimit64 *rlimits)
44 struct rlimit64 krlimits;
46 if (rlimits->rlim_cur == OLD_RLIM64_INFINITY)
47 krlimits.rlim_cur = RLIM64_INFINITY;
48 else
49 krlimits.rlim_cur = rlimits->rlim_cur;
50 if (rlimits->rlim_max == OLD_RLIM64_INFINITY)
51 krlimits.rlim_max = RLIM64_INFINITY;
52 else
53 krlimits.rlim_max = rlimits->rlim_max;
55 return __new_setrlimit64 (resource, &krlimits);
58 compat_symbol (libc, __old_setrlimit64, setrlimit64, GLIBC_2_2);
59 # endif
61 #else /* !_ABI_O32 && !_ABI_N32 */
62 # include <sysdeps/unix/sysv/linux/setrlimit64.c>
63 #endif