]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Assume prlimit64 is available.
authorJoseph Myers <joseph@codesourcery.com>
Tue, 9 May 2017 14:05:09 +0000 (14:05 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Tue, 9 May 2017 14:05:09 +0000 (14:05 +0000)
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.

ChangeLog
sysdeps/unix/sysv/linux/getrlimit64.c
sysdeps/unix/sysv/linux/kernel-features.h
sysdeps/unix/sysv/linux/prlimit.c
sysdeps/unix/sysv/linux/setrlimit.c
sysdeps/unix/sysv/linux/setrlimit64.c

index 932dc5895d339f5daa70556c129f6f4f6d7ac399..e53c4b0951fae960b1b1285d102ed446c18e5a28 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2017-05-09  Joseph Myers  <joseph@codesourcery.com>
+
+       * 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.
+
 2017-05-09  Zack Weinberg  <zackw@panix.com>
 
        * sunrpc/tst-xdrmem2.c: Include stdint.h.
index 37c173286f75b17bc639f06237919360da1ecaad..56af3c0646c4147e4432d4e1cb1d6a4066d39d9d 100644 (file)
 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)
 
index d837c221fb38c83c014295b9f45ba09aa904c21e..74ac6276e8a6e12a7b2bc943185f0411a037b711 100644 (file)
 # define __ASSUME_STATFS_F_FLAGS       1
 #endif
 
-/* prlimit64 is available in 2.6.36.  */
-#if __LINUX_KERNEL_VERSION >= 0x020624
-# define __ASSUME_PRLIMIT64    1
-#endif
-
 /* Support for sendmmsg functionality was added in 3.0.  The macros
    defined correspond to those for accept4 and recvmmsg.  */
 #if __LINUX_KERNEL_VERSION >= 0x030000
index 2996e73b81897a213d9fd463eeb853b99b469679..d31980f10c3f96a4386bf5a7730739d722358af0 100644 (file)
@@ -20,7 +20,6 @@
 #include <sys/syscall.h>
 
 
-#ifdef __NR_prlimit64
 int
 prlimit (__pid_t pid, enum __rlimit_resource resource,
         const struct rlimit *new_rlimit, struct rlimit *old_rlimit)
@@ -73,12 +72,3 @@ prlimit (__pid_t pid, enum __rlimit_resource resource,
 
   return res;
 }
-#else
-int
-prlimit (__pid_t pid, enum __rlimit_resource resource,
-        const struct rlimit *new_rlimit, struct rlimit *old_rlimit)
-{
-  return INLINE_SYSCALL_ERROR_RETURN_VALUE (ENOSYS);
-}
-stub_warning (prlimit)
-#endif
index 01812ac355b481520f3de61474cb8bb526f63e24..8773c782367dff5ddbfa684a553d2fe9de544ee8 100644 (file)
@@ -34,7 +34,6 @@
 int
 __setrlimit (enum __rlimit_resource resource, const struct rlimit *rlim)
 {
-# ifdef __NR_prlimit64
   struct rlimit64 rlim64;
 
   if (rlim->rlim_cur == RLIM_INFINITY)
@@ -46,11 +45,7 @@ __setrlimit (enum __rlimit_resource resource, const struct rlimit *rlim)
   else
     rlim64.rlim_max = rlim->rlim_max;
 
-  int res = INLINE_SYSCALL_CALL (prlimit64, 0, resource, &rlim64, NULL);
-  if (res == 0 || errno != ENOSYS)
-    return res;
-# endif
-  return INLINE_SYSCALL_CALL (setrlimit, resource, rlim);
+  return INLINE_SYSCALL_CALL (prlimit64, 0, resource, &rlim64, NULL);
 }
 
 # if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2)
index 2dd129d99eec61d5fd3f6e42da602cf2b716c940..db1960fc18abcb5575746887889651ce7ba47bb8 100644 (file)
 int
 __setrlimit64 (enum __rlimit_resource resource, const struct rlimit64 *rlimits)
 {
-  int res;
-
-#ifdef __NR_prlimit64
-  res = INLINE_SYSCALL_CALL (prlimit64, 0, resource, rlimits, NULL);
-  if (res == 0 || errno != ENOSYS)
-    return res;
-#endif
-
-/* The fallback code only makes sense if the platform supports
-   __NR_setrlimit.  */
-#ifdef __NR_setrlimit
-# if !__RLIM_T_MATCHES_RLIM64_T
-  struct rlimit rlimits32;
-
-  if (rlimits->rlim_cur >= RLIM_INFINITY)
-    rlimits32.rlim_cur = RLIM_INFINITY;
-  else
-    rlimits32.rlim_cur = rlimits->rlim_cur;
-  if (rlimits->rlim_max >= RLIM_INFINITY)
-    rlimits32.rlim_max = RLIM_INFINITY;
-  else
-    rlimits32.rlim_max = rlimits->rlim_max;
-# else
-#  define rlimits32 (*rlimits)
-# endif
-
-  res = INLINE_SYSCALL_CALL (setrlimit, resource, &rlimits32);
-#endif
-
-  return res;
+  return INLINE_SYSCALL_CALL (prlimit64, 0, resource, rlimits, NULL);
 }
 weak_alias (__setrlimit64, setrlimit64)