about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux/getrlimit64.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2017-05-09 14:05:09 +0000
committerJoseph Myers <joseph@codesourcery.com>2017-05-09 14:05:09 +0000
commit695d7d138eda449678a1650a8b8b58181033353f (patch)
tree21808b08259cb3d73c1d3701adfbb98b0a4333a2 /sysdeps/unix/sysv/linux/getrlimit64.c
parenta972dc672c06845a024a0f98119dc3d9df0b9b77 (diff)
downloadglibc-695d7d138eda449678a1650a8b8b58181033353f.tar.gz
glibc-695d7d138eda449678a1650a8b8b58181033353f.tar.xz
glibc-695d7d138eda449678a1650a8b8b58181033353f.zip
Assume prlimit64 is available.
This patch makes sysdeps/unix/sysv/linux code assume the prlimit64
syscall is always available, given the minimum of a 3.2 kernel.

__ASSUME_PRLIMIT64, which in fact was no longer used, is removed.
Code conditional on __NR_prlimit64 being defined is made
unconditional.  Fallback code for the case where prlimit64 produces an
ENOSYS error is removed, substantially simplifying some functions.

Tested for x86_64 and x86.

	* sysdeps/unix/sysv/linux/kernel-features.h (__ASSUME_PRLIMIT64):
	Remove macro.
	* sysdeps/unix/sysv/linux/getrlimit64.c (__getrlimit64): Assume
	prlimit64 is always available and does not give an ENOSYS error.
	* sysdeps/unix/sysv/linux/prlimit.c [__NR_prlimit64]: Make code
	unconditional.
	[!__NR_prlimit64]: Remove conditional code.
	* sysdeps/unix/sysv/linux/setrlimit.c (__setrlimit): Assume
	prlimit64 is always available and does not give an ENOSYS error.
	* sysdeps/unix/sysv/linux/setrlimit64.c (__setrlimit64): Likewise.
Diffstat (limited to 'sysdeps/unix/sysv/linux/getrlimit64.c')
-rw-r--r--sysdeps/unix/sysv/linux/getrlimit64.c35
1 files changed, 1 insertions, 34 deletions
diff --git a/sysdeps/unix/sysv/linux/getrlimit64.c b/sysdeps/unix/sysv/linux/getrlimit64.c
index 37c173286f..56af3c0646 100644
--- a/sysdeps/unix/sysv/linux/getrlimit64.c
+++ b/sysdeps/unix/sysv/linux/getrlimit64.c
@@ -35,40 +35,7 @@
 int
 __getrlimit64 (enum __rlimit_resource resource, struct rlimit64 *rlimits)
 {
-#ifdef __NR_prlimit64
-  int res = INLINE_SYSCALL_CALL (prlimit64, 0, resource, NULL, rlimits);
-  if (res == 0 || errno != ENOSYS)
-    return res;
-#endif
-
-/* The fallback code only makes sense if the platform supports either
-   __NR_ugetrlimit and/or __NR_getrlimit.  */
-#if defined (__NR_ugetrlimit) || defined (__NR_getrlimit)
-# ifndef __NR_ugetrlimit
-#  define __NR_ugetrlimit __NR_getrlimit
-# endif
-# if __RLIM_T_MATCHES_RLIM64_T
-#  define rlimits32 (*rlimits)
-# else
-  struct rlimit rlimits32;
-# endif
-
-  if (INLINE_SYSCALL_CALL (ugetrlimit, resource, &rlimits32) < 0)
-    return -1;
-
-# if !__RLIM_T_MATCHES_RLIM64_T
-  if (rlimits32.rlim_cur == RLIM_INFINITY)
-    rlimits->rlim_cur = RLIM64_INFINITY;
-  else
-    rlimits->rlim_cur = rlimits32.rlim_cur;
-  if (rlimits32.rlim_max == RLIM_INFINITY)
-    rlimits->rlim_max = RLIM64_INFINITY;
-  else
-    rlimits->rlim_max = rlimits32.rlim_max;
-# endif /* !__RLIM_T_MATCHES_RLIM64_T */
-#endif /* defined (__NR_ugetrlimit) || defined (__NR_getrlimit)  */
-
-  return 0;
+  return INLINE_SYSCALL_CALL (prlimit64, 0, resource, NULL, rlimits);
 }
 libc_hidden_def (__getrlimit64)