From 695d7d138eda449678a1650a8b8b58181033353f Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Tue, 9 May 2017 14:05:09 +0000 Subject: 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. --- sysdeps/unix/sysv/linux/setrlimit64.c | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) (limited to 'sysdeps/unix/sysv/linux/setrlimit64.c') diff --git a/sysdeps/unix/sysv/linux/setrlimit64.c b/sysdeps/unix/sysv/linux/setrlimit64.c index 2dd129d99e..db1960fc18 100644 --- a/sysdeps/unix/sysv/linux/setrlimit64.c +++ b/sysdeps/unix/sysv/linux/setrlimit64.c @@ -36,36 +36,7 @@ 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) -- cgit v1.2.3-70-g09d2