diff mbox

[v2] Consolidate Linux setrlimit and getrlimit implementation

Message ID 1477592495-22272-1-git-send-email-adhemerval.zanella@linaro.org
State New
Headers show

Commit Message

Adhemerval Zanella Oct. 27, 2016, 6:21 p.m. UTC
Changes from previous version:

 - Simplify linux getrlimit.c by removing prlimit call and use either
   getrlimit or ugetrlimit syscall.  This remove the need to adjust
   prlimit output to expect 32 bits rlim_t.  New architectures ideally
   will set __RLIM_T_MATCHES_RLIM64_T and use prlimit64 on {set,get}rlimit64.

 - Handle the case of possible new architectures that only define prlimit64
   syscall (as per the kernel patch [1]).  This new version handle 3
   architecture scenarios:

   1. New architectures that only define prlimit64.  These are expected to
      define __RLIM_T_MATCHES_RLIM64_T and thus {set,get}rlimit{64} will
      aliased to {set,get}rlimit symbols.

   2. Possible existence of prlimit64 syscall along with {get,set}{u}rlimit.
      In this case prlimit will be used if kernel header provide the
      definition and if runtime fails with ENOSYS the old {get,set}rlimit
      will be used.

   3. Only the existance of {get,set}rlimit. In this case the syscalls
      will be used and adjustments will be made wheter __RLIM_T_MATCHES_RLIM64_T
      is defined.

 - Set __RLIM_T_MATCHES_RLIM64_T for all possible architectures so we can
   evaluate with #if and get possible -Wundef errors.

 - Remove ununsed arm old{get,set}rlimit implementations.

[1] https://patchwork.kernel.org/patch/9390685/

--

This patch consolidates all Linux setrlimit and getrlimit on the default
sysdeps/unix/sysv/linux/{set,get}rlimit{64}.c.  It contains two exceptions:

  1. mips32 and mips64n32 which requires a versioned symbol for GLIBC 2.19
     and higher due a broken RLIM64_INFINITY constant.
  2. sparc32 does not define a compat symbol for getrlimit64 for old 2GB
     limit. I am not sure if it is required, but a RLIM_INFINITY fix [1]
     change its definition without adding a compat symbol.  This patch does
     not aim to address this possible issue, it follow current symbol
     export.

The default implementation uses prlimit64 for 64 bit rlim_t ({set,get}rlimit64)
and if it fails with ENOSYS it fall back to {get,set}rlimit syscall.  This
code path is only used on kernel older than 2.6.36 (basically now only x86)
and I avoid to user __ASSUME_PRLIMTI64 to simplify the implementation.  Once
x86 moves to be on par with other architectures regarding minimum kernel
supported we can get rid of using old syscalls and default path.

A new type size define is added, __RLIM_T_MATCHES_RLIM64_T, where is set as
default for 64 bits ports.  This allows the default implementation to avoid
{get,set}rlimit building and alias {get,set}rlimit64 to {get,set}rlimit.

Checked on x86_64, i386, armhf, aarch64, and powerpc64le.  I also did a
sanity build plus check-abi on all other supported architectures.

[1] Commit 9c96ff23858b0759e12ad69e3c4599931c90bee8

	Adhemerval Zanella  <adhemerval.zanella@linaro.org>
	Yury Norov  <ynorov@caviumnetworks.com>

	* bits/typesizes.h (__RLIM_T_MATCHES_RLIM64_T): define.
	* sysdeps/unix/sysv/linux/alpha/bits/typesizes.h
	(__RLIM_T_MATCHES_RLIM64_T): Likewise.
	* sysdeps/unix/sysv/linux/generic/bits/typesizes.h
	(__RLIM_T_MATCHES_RLIM64_T): Likewise.
	* sysdeps/unix/sysv/linux/s390/bits/typesizes.h [__s390x__]
	(__RLIM_T_MATCHES_RLIM64_T): Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
	[__arch64__ || __sparcv9] (__RLIM_T_MATCHES_RLIM64_T): Likewise.
	* sysdeps/unix/sysv/linux/x86/bits/typesizes.h [__86_64__]
	(__RLIM_T_MATCHES_RLIM64_T): Likewise.
	* sysdeps/unix/sysv/linux/arm/Makefile [$(subdir) = resource]
	(sysdep_routines): Remove oldgetrlimit64.
	* sysdeps/unix/sysv/linux/i386/Makefile [$(subdir) = resource]
	(sysdep_routines): Likewise.
	* sysdeps/unix/sysv/linux/m68k/Makefile [$(subdir) = resource]
	(sysdep_routines): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/Makefile
	[$(subdir) = resource] (sysdep_routines): Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/Makefile
	[$(subdir) = resource] (sysdep_routines): Likewise.
	* sysdeps/unix/sysv/linux/arm/getrlimit64.c: Remove file.
	* sysdeps/unix/sysv/linux/arm/oldgetrlimit64.c: Likewise.
	* sysdeps/unix/sysv/linux/arm/oldgetrlimit.c: Likewise.
	* sysdeps/unix/sysv/linux/arm/oldsetrlimit.c: Likewise.
	* sysdeps/unix/sysv/linux/hppa/getrlimit64.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/getrlimit64.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/oldgetrlimit64.c: Likewise.
	* sysdeps/unix/sysv/linux/m68k/getrlimit64.c: Likewise.
	* sysdeps/unix/sysv/linux/m68k/oldgetrlimit64.c: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/getrlimit64.c: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/oldgetrlimit64.c: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/getrlimit64.c: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/oldgetrlimit64.c: Likewise.
	* sysdeps/unix/sysv/linux/sh/getrlimit64.c: Likewise.
	* sysdeps/unix/sysv/linux/wordsize-64/getrlimit64.c: Likewise.
	* sysdeps/unix/sysv/linux/wordsize-64/setrlimit64.c: Likewise.
	* sysdeps/sysv/linux/generic/wordsize-32/syscalls.list: Remove
	setrlimit and getrlimit.
	* sysdeps/unix/sysv/linux/hppa/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/i386/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/wordsize-64/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/getrlimit.c: New file.
	* sysdeps/unix/sysv/linux/sparc/getrlimit64.c: Likewise.
	* sysdeps/unix/sysv/linux/setrlimit.c: Likewise.
	* sysdeps/unix/sysv/linux/getrlimit64.c (__getrlimit64): Handle
	__RLIM_T_MATCHES_RLIM64_T and add alias if defined.
	(__old_getrlimit64): Add compatibility symbol.
	* sysdeps/unix/sysv/linux/setrlimit64.c (__setrlimit): Likewise.
---
 ChangeLog                                          | 59 +++++++++++++++
 bits/typesizes.h                                   |  5 ++
 sysdeps/unix/sysv/linux/alpha/bits/typesizes.h     |  3 +
 sysdeps/unix/sysv/linux/arm/Makefile               |  4 -
 sysdeps/unix/sysv/linux/arm/getrlimit64.c          |  1 -
 sysdeps/unix/sysv/linux/arm/oldgetrlimit.c         |  1 -
 sysdeps/unix/sysv/linux/arm/oldgetrlimit64.c       |  1 -
 sysdeps/unix/sysv/linux/arm/oldsetrlimit.c         |  1 -
 sysdeps/unix/sysv/linux/generic/bits/typesizes.h   |  5 ++
 .../sysv/linux/generic/wordsize-32/syscalls.list   |  2 -
 sysdeps/unix/sysv/linux/getrlimit.c                | 56 ++++++++++++++
 sysdeps/unix/sysv/linux/getrlimit64.c              | 86 +++++++++++++++++++---
 sysdeps/unix/sysv/linux/hppa/getrlimit64.c         |  1 -
 sysdeps/unix/sysv/linux/hppa/syscalls.list         |  2 -
 sysdeps/unix/sysv/linux/i386/Makefile              |  4 -
 sysdeps/unix/sysv/linux/i386/getrlimit64.c         | 25 -------
 sysdeps/unix/sysv/linux/i386/oldgetrlimit64.c      | 57 --------------
 sysdeps/unix/sysv/linux/i386/syscalls.list         |  2 -
 sysdeps/unix/sysv/linux/m68k/Makefile              |  4 -
 sysdeps/unix/sysv/linux/m68k/getrlimit64.c         |  1 -
 sysdeps/unix/sysv/linux/m68k/m680x0/syscalls.list  |  4 -
 sysdeps/unix/sysv/linux/m68k/oldgetrlimit64.c      |  1 -
 sysdeps/unix/sysv/linux/powerpc/getrlimit64.c      |  1 -
 sysdeps/unix/sysv/linux/powerpc/oldgetrlimit64.c   |  1 -
 sysdeps/unix/sysv/linux/powerpc/powerpc32/Makefile |  4 -
 .../sysv/linux/powerpc/powerpc32/syscalls.list     |  4 -
 .../sysv/linux/powerpc/powerpc64/syscalls.list     |  3 -
 sysdeps/unix/sysv/linux/s390/bits/typesizes.h      |  5 ++
 sysdeps/unix/sysv/linux/s390/s390-32/Makefile      |  4 -
 sysdeps/unix/sysv/linux/s390/s390-32/getrlimit64.c |  1 -
 .../unix/sysv/linux/s390/s390-32/oldgetrlimit64.c  |  1 -
 sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list |  3 -
 sysdeps/unix/sysv/linux/setrlimit.c                | 64 ++++++++++++++++
 sysdeps/unix/sysv/linux/setrlimit64.c              | 48 +++++++++---
 sysdeps/unix/sysv/linux/sh/getrlimit64.c           |  1 -
 sysdeps/unix/sysv/linux/sparc/bits/typesizes.h     |  5 ++
 sysdeps/unix/sysv/linux/sparc/getrlimit64.c        | 24 ++++++
 .../unix/sysv/linux/sparc/sparc32/syscalls.list    |  2 -
 sysdeps/unix/sysv/linux/syscalls.list              |  1 -
 sysdeps/unix/sysv/linux/wordsize-64/getrlimit64.c  |  1 -
 sysdeps/unix/sysv/linux/wordsize-64/setrlimit64.c  |  1 -
 sysdeps/unix/sysv/linux/wordsize-64/syscalls.list  |  2 -
 sysdeps/unix/sysv/linux/x86/bits/typesizes.h       |  5 ++
 43 files changed, 341 insertions(+), 165 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/arm/getrlimit64.c
 delete mode 100644 sysdeps/unix/sysv/linux/arm/oldgetrlimit.c
 delete mode 100644 sysdeps/unix/sysv/linux/arm/oldgetrlimit64.c
 delete mode 100644 sysdeps/unix/sysv/linux/arm/oldsetrlimit.c
 create mode 100644 sysdeps/unix/sysv/linux/getrlimit.c
 delete mode 100644 sysdeps/unix/sysv/linux/hppa/getrlimit64.c
 delete mode 100644 sysdeps/unix/sysv/linux/i386/getrlimit64.c
 delete mode 100644 sysdeps/unix/sysv/linux/i386/oldgetrlimit64.c
 delete mode 100644 sysdeps/unix/sysv/linux/m68k/getrlimit64.c
 delete mode 100644 sysdeps/unix/sysv/linux/m68k/m680x0/syscalls.list
 delete mode 100644 sysdeps/unix/sysv/linux/m68k/oldgetrlimit64.c
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/getrlimit64.c
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/oldgetrlimit64.c
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list
 delete mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/getrlimit64.c
 delete mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/oldgetrlimit64.c
 create mode 100644 sysdeps/unix/sysv/linux/setrlimit.c
 delete mode 100644 sysdeps/unix/sysv/linux/sh/getrlimit64.c
 create mode 100644 sysdeps/unix/sysv/linux/sparc/getrlimit64.c
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/getrlimit64.c
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/setrlimit64.c

-- 
2.7.4

Comments

Adhemerval Zanella Nov. 16, 2016, 12:11 p.m. UTC | #1
Ping.

On 27/10/2016 16:21, Adhemerval Zanella wrote:
> Changes from previous version:

> 

>  - Simplify linux getrlimit.c by removing prlimit call and use either

>    getrlimit or ugetrlimit syscall.  This remove the need to adjust

>    prlimit output to expect 32 bits rlim_t.  New architectures ideally

>    will set __RLIM_T_MATCHES_RLIM64_T and use prlimit64 on {set,get}rlimit64.

> 

>  - Handle the case of possible new architectures that only define prlimit64

>    syscall (as per the kernel patch [1]).  This new version handle 3

>    architecture scenarios:

> 

>    1. New architectures that only define prlimit64.  These are expected to

>       define __RLIM_T_MATCHES_RLIM64_T and thus {set,get}rlimit{64} will

>       aliased to {set,get}rlimit symbols.

> 

>    2. Possible existence of prlimit64 syscall along with {get,set}{u}rlimit.

>       In this case prlimit will be used if kernel header provide the

>       definition and if runtime fails with ENOSYS the old {get,set}rlimit

>       will be used.

> 

>    3. Only the existance of {get,set}rlimit. In this case the syscalls

>       will be used and adjustments will be made wheter __RLIM_T_MATCHES_RLIM64_T

>       is defined.

> 

>  - Set __RLIM_T_MATCHES_RLIM64_T for all possible architectures so we can

>    evaluate with #if and get possible -Wundef errors.

> 

>  - Remove ununsed arm old{get,set}rlimit implementations.

> 

> [1] https://patchwork.kernel.org/patch/9390685/

> 

> --

> 

> This patch consolidates all Linux setrlimit and getrlimit on the default

> sysdeps/unix/sysv/linux/{set,get}rlimit{64}.c.  It contains two exceptions:

> 

>   1. mips32 and mips64n32 which requires a versioned symbol for GLIBC 2.19

>      and higher due a broken RLIM64_INFINITY constant.

>   2. sparc32 does not define a compat symbol for getrlimit64 for old 2GB

>      limit. I am not sure if it is required, but a RLIM_INFINITY fix [1]

>      change its definition without adding a compat symbol.  This patch does

>      not aim to address this possible issue, it follow current symbol

>      export.

> 

> The default implementation uses prlimit64 for 64 bit rlim_t ({set,get}rlimit64)

> and if it fails with ENOSYS it fall back to {get,set}rlimit syscall.  This

> code path is only used on kernel older than 2.6.36 (basically now only x86)

> and I avoid to user __ASSUME_PRLIMTI64 to simplify the implementation.  Once

> x86 moves to be on par with other architectures regarding minimum kernel

> supported we can get rid of using old syscalls and default path.

> 

> A new type size define is added, __RLIM_T_MATCHES_RLIM64_T, where is set as

> default for 64 bits ports.  This allows the default implementation to avoid

> {get,set}rlimit building and alias {get,set}rlimit64 to {get,set}rlimit.

> 

> Checked on x86_64, i386, armhf, aarch64, and powerpc64le.  I also did a

> sanity build plus check-abi on all other supported architectures.

> 

> [1] Commit 9c96ff23858b0759e12ad69e3c4599931c90bee8

> 

> 	Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> 	Yury Norov  <ynorov@caviumnetworks.com>

> 

> 	* bits/typesizes.h (__RLIM_T_MATCHES_RLIM64_T): define.

> 	* sysdeps/unix/sysv/linux/alpha/bits/typesizes.h

> 	(__RLIM_T_MATCHES_RLIM64_T): Likewise.

> 	* sysdeps/unix/sysv/linux/generic/bits/typesizes.h

> 	(__RLIM_T_MATCHES_RLIM64_T): Likewise.

> 	* sysdeps/unix/sysv/linux/s390/bits/typesizes.h [__s390x__]

> 	(__RLIM_T_MATCHES_RLIM64_T): Likewise.

> 	* sysdeps/unix/sysv/linux/sparc/bits/typesizes.h

> 	[__arch64__ || __sparcv9] (__RLIM_T_MATCHES_RLIM64_T): Likewise.

> 	* sysdeps/unix/sysv/linux/x86/bits/typesizes.h [__86_64__]

> 	(__RLIM_T_MATCHES_RLIM64_T): Likewise.

> 	* sysdeps/unix/sysv/linux/arm/Makefile [$(subdir) = resource]

> 	(sysdep_routines): Remove oldgetrlimit64.

> 	* sysdeps/unix/sysv/linux/i386/Makefile [$(subdir) = resource]

> 	(sysdep_routines): Likewise.

> 	* sysdeps/unix/sysv/linux/m68k/Makefile [$(subdir) = resource]

> 	(sysdep_routines): Likewise.

> 	* sysdeps/unix/sysv/linux/powerpc/powerpc32/Makefile

> 	[$(subdir) = resource] (sysdep_routines): Likewise.

> 	* sysdeps/unix/sysv/linux/s390/s390-32/Makefile

> 	[$(subdir) = resource] (sysdep_routines): Likewise.

> 	* sysdeps/unix/sysv/linux/arm/getrlimit64.c: Remove file.

> 	* sysdeps/unix/sysv/linux/arm/oldgetrlimit64.c: Likewise.

> 	* sysdeps/unix/sysv/linux/arm/oldgetrlimit.c: Likewise.

> 	* sysdeps/unix/sysv/linux/arm/oldsetrlimit.c: Likewise.

> 	* sysdeps/unix/sysv/linux/hppa/getrlimit64.c: Likewise.

> 	* sysdeps/unix/sysv/linux/i386/getrlimit64.c: Likewise.

> 	* sysdeps/unix/sysv/linux/i386/oldgetrlimit64.c: Likewise.

> 	* sysdeps/unix/sysv/linux/m68k/getrlimit64.c: Likewise.

> 	* sysdeps/unix/sysv/linux/m68k/oldgetrlimit64.c: Likewise.

> 	* sysdeps/unix/sysv/linux/powerpc/getrlimit64.c: Likewise.

> 	* sysdeps/unix/sysv/linux/powerpc/oldgetrlimit64.c: Likewise.

> 	* sysdeps/unix/sysv/linux/s390/s390-32/getrlimit64.c: Likewise.

> 	* sysdeps/unix/sysv/linux/s390/s390-32/oldgetrlimit64.c: Likewise.

> 	* sysdeps/unix/sysv/linux/sh/getrlimit64.c: Likewise.

> 	* sysdeps/unix/sysv/linux/wordsize-64/getrlimit64.c: Likewise.

> 	* sysdeps/unix/sysv/linux/wordsize-64/setrlimit64.c: Likewise.

> 	* sysdeps/sysv/linux/generic/wordsize-32/syscalls.list: Remove

> 	setrlimit and getrlimit.

> 	* sysdeps/unix/sysv/linux/hppa/syscalls.list: Likewise.

> 	* sysdeps/unix/sysv/linux/i386/syscalls.list: Likewise.

> 	* sysdeps/unix/sysv/linux/m68k/m680x0/syscalls.list: Likewise.

> 	* sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list: Likewise.

> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list: Likewise.

> 	* sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list: Likewise.

> 	* sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list: Likewise.

> 	* sysdeps/unix/sysv/linux/syscalls.list: Likewise.

> 	* sysdeps/unix/sysv/linux/wordsize-64/syscalls.list: Likewise.

> 	* sysdeps/unix/sysv/linux/getrlimit.c: New file.

> 	* sysdeps/unix/sysv/linux/sparc/getrlimit64.c: Likewise.

> 	* sysdeps/unix/sysv/linux/setrlimit.c: Likewise.

> 	* sysdeps/unix/sysv/linux/getrlimit64.c (__getrlimit64): Handle

> 	__RLIM_T_MATCHES_RLIM64_T and add alias if defined.

> 	(__old_getrlimit64): Add compatibility symbol.

> 	* sysdeps/unix/sysv/linux/setrlimit64.c (__setrlimit): Likewise.

> ---

>  ChangeLog                                          | 59 +++++++++++++++

>  bits/typesizes.h                                   |  5 ++

>  sysdeps/unix/sysv/linux/alpha/bits/typesizes.h     |  3 +

>  sysdeps/unix/sysv/linux/arm/Makefile               |  4 -

>  sysdeps/unix/sysv/linux/arm/getrlimit64.c          |  1 -

>  sysdeps/unix/sysv/linux/arm/oldgetrlimit.c         |  1 -

>  sysdeps/unix/sysv/linux/arm/oldgetrlimit64.c       |  1 -

>  sysdeps/unix/sysv/linux/arm/oldsetrlimit.c         |  1 -

>  sysdeps/unix/sysv/linux/generic/bits/typesizes.h   |  5 ++

>  .../sysv/linux/generic/wordsize-32/syscalls.list   |  2 -

>  sysdeps/unix/sysv/linux/getrlimit.c                | 56 ++++++++++++++

>  sysdeps/unix/sysv/linux/getrlimit64.c              | 86 +++++++++++++++++++---

>  sysdeps/unix/sysv/linux/hppa/getrlimit64.c         |  1 -

>  sysdeps/unix/sysv/linux/hppa/syscalls.list         |  2 -

>  sysdeps/unix/sysv/linux/i386/Makefile              |  4 -

>  sysdeps/unix/sysv/linux/i386/getrlimit64.c         | 25 -------

>  sysdeps/unix/sysv/linux/i386/oldgetrlimit64.c      | 57 --------------

>  sysdeps/unix/sysv/linux/i386/syscalls.list         |  2 -

>  sysdeps/unix/sysv/linux/m68k/Makefile              |  4 -

>  sysdeps/unix/sysv/linux/m68k/getrlimit64.c         |  1 -

>  sysdeps/unix/sysv/linux/m68k/m680x0/syscalls.list  |  4 -

>  sysdeps/unix/sysv/linux/m68k/oldgetrlimit64.c      |  1 -

>  sysdeps/unix/sysv/linux/powerpc/getrlimit64.c      |  1 -

>  sysdeps/unix/sysv/linux/powerpc/oldgetrlimit64.c   |  1 -

>  sysdeps/unix/sysv/linux/powerpc/powerpc32/Makefile |  4 -

>  .../sysv/linux/powerpc/powerpc32/syscalls.list     |  4 -

>  .../sysv/linux/powerpc/powerpc64/syscalls.list     |  3 -

>  sysdeps/unix/sysv/linux/s390/bits/typesizes.h      |  5 ++

>  sysdeps/unix/sysv/linux/s390/s390-32/Makefile      |  4 -

>  sysdeps/unix/sysv/linux/s390/s390-32/getrlimit64.c |  1 -

>  .../unix/sysv/linux/s390/s390-32/oldgetrlimit64.c  |  1 -

>  sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list |  3 -

>  sysdeps/unix/sysv/linux/setrlimit.c                | 64 ++++++++++++++++

>  sysdeps/unix/sysv/linux/setrlimit64.c              | 48 +++++++++---

>  sysdeps/unix/sysv/linux/sh/getrlimit64.c           |  1 -

>  sysdeps/unix/sysv/linux/sparc/bits/typesizes.h     |  5 ++

>  sysdeps/unix/sysv/linux/sparc/getrlimit64.c        | 24 ++++++

>  .../unix/sysv/linux/sparc/sparc32/syscalls.list    |  2 -

>  sysdeps/unix/sysv/linux/syscalls.list              |  1 -

>  sysdeps/unix/sysv/linux/wordsize-64/getrlimit64.c  |  1 -

>  sysdeps/unix/sysv/linux/wordsize-64/setrlimit64.c  |  1 -

>  sysdeps/unix/sysv/linux/wordsize-64/syscalls.list  |  2 -

>  sysdeps/unix/sysv/linux/x86/bits/typesizes.h       |  5 ++

>  43 files changed, 341 insertions(+), 165 deletions(-)

>  delete mode 100644 sysdeps/unix/sysv/linux/arm/getrlimit64.c

>  delete mode 100644 sysdeps/unix/sysv/linux/arm/oldgetrlimit.c

>  delete mode 100644 sysdeps/unix/sysv/linux/arm/oldgetrlimit64.c

>  delete mode 100644 sysdeps/unix/sysv/linux/arm/oldsetrlimit.c

>  create mode 100644 sysdeps/unix/sysv/linux/getrlimit.c

>  delete mode 100644 sysdeps/unix/sysv/linux/hppa/getrlimit64.c

>  delete mode 100644 sysdeps/unix/sysv/linux/i386/getrlimit64.c

>  delete mode 100644 sysdeps/unix/sysv/linux/i386/oldgetrlimit64.c

>  delete mode 100644 sysdeps/unix/sysv/linux/m68k/getrlimit64.c

>  delete mode 100644 sysdeps/unix/sysv/linux/m68k/m680x0/syscalls.list

>  delete mode 100644 sysdeps/unix/sysv/linux/m68k/oldgetrlimit64.c

>  delete mode 100644 sysdeps/unix/sysv/linux/powerpc/getrlimit64.c

>  delete mode 100644 sysdeps/unix/sysv/linux/powerpc/oldgetrlimit64.c

>  delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list

>  delete mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/getrlimit64.c

>  delete mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/oldgetrlimit64.c

>  create mode 100644 sysdeps/unix/sysv/linux/setrlimit.c

>  delete mode 100644 sysdeps/unix/sysv/linux/sh/getrlimit64.c

>  create mode 100644 sysdeps/unix/sysv/linux/sparc/getrlimit64.c

>  delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/getrlimit64.c

>  delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/setrlimit64.c

> 

> diff --git a/bits/typesizes.h b/bits/typesizes.h

> index 53047b8..ff20601 100644

> --- a/bits/typesizes.h

> +++ b/bits/typesizes.h

> @@ -69,6 +69,11 @@

>  

>  /* Same for ino_t and ino64_t.  */

>  # define __INO_T_MATCHES_INO64_T	1

> +

> +/* And for rlim_t and rlim64_t.  */

> +# define __RLIM_T_MATCHES_RLIM64_T	1

> +#else

> +# define __RLIM_T_MATCHES_RLIM64_T	0

>  #endif

>  

>  /* Number of descriptors that can fit in an `fd_set'.  */

> diff --git a/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h b/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h

> index 3cfd887..ce96501 100644

> --- a/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h

> +++ b/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h

> @@ -66,6 +66,9 @@

>     for C type-checking purposes.  */

>  #define __OFF_T_MATCHES_OFF64_T	1

>  

> +/* And for __rlim_t and __rlim64_t.  */

> +#define __RLIM_T_MATCHES_RLIM64_T 1

> +

>  /* Number of descriptors that can fit in an `fd_set'.  */

>  #define	__FD_SETSIZE		1024

>  

> diff --git a/sysdeps/unix/sysv/linux/arm/Makefile b/sysdeps/unix/sysv/linux/arm/Makefile

> index 270cb73..b9b8f71 100644

> --- a/sysdeps/unix/sysv/linux/arm/Makefile

> +++ b/sysdeps/unix/sysv/linux/arm/Makefile

> @@ -12,10 +12,6 @@ ifeq ($(subdir),signal)

>  sysdep_routines += sigrestorer

>  endif

>  

> -ifeq ($(subdir),resource)

> -sysdep_routines += oldgetrlimit64

> -endif

> -

>  ifeq ($(subdir),stdlib)

>  gen-as-const-headers += ucontext_i.sym

>  endif

> diff --git a/sysdeps/unix/sysv/linux/arm/getrlimit64.c b/sysdeps/unix/sysv/linux/arm/getrlimit64.c

> deleted file mode 100644

> index fef018f..0000000

> --- a/sysdeps/unix/sysv/linux/arm/getrlimit64.c

> +++ /dev/null

> @@ -1 +0,0 @@

> -#include <sysdeps/unix/sysv/linux/i386/getrlimit64.c>

> diff --git a/sysdeps/unix/sysv/linux/arm/oldgetrlimit.c b/sysdeps/unix/sysv/linux/arm/oldgetrlimit.c

> deleted file mode 100644

> index 6e25b02..0000000

> --- a/sysdeps/unix/sysv/linux/arm/oldgetrlimit.c

> +++ /dev/null

> @@ -1 +0,0 @@

> -/* Empty.  */

> diff --git a/sysdeps/unix/sysv/linux/arm/oldgetrlimit64.c b/sysdeps/unix/sysv/linux/arm/oldgetrlimit64.c

> deleted file mode 100644

> index 4c27e95..0000000

> --- a/sysdeps/unix/sysv/linux/arm/oldgetrlimit64.c

> +++ /dev/null

> @@ -1 +0,0 @@

> -#include <sysdeps/unix/sysv/linux/i386/oldgetrlimit64.c>

> diff --git a/sysdeps/unix/sysv/linux/arm/oldsetrlimit.c b/sysdeps/unix/sysv/linux/arm/oldsetrlimit.c

> deleted file mode 100644

> index 6e25b02..0000000

> --- a/sysdeps/unix/sysv/linux/arm/oldsetrlimit.c

> +++ /dev/null

> @@ -1 +0,0 @@

> -/* Empty.  */

> diff --git a/sysdeps/unix/sysv/linux/generic/bits/typesizes.h b/sysdeps/unix/sysv/linux/generic/bits/typesizes.h

> index c31bba2..f7766c7 100644

> --- a/sysdeps/unix/sysv/linux/generic/bits/typesizes.h

> +++ b/sysdeps/unix/sysv/linux/generic/bits/typesizes.h

> @@ -70,6 +70,11 @@

>  

>  /* Same for ino_t and ino64_t.  */

>  # define __INO_T_MATCHES_INO64_T	1

> +

> +/* And for __rlim_t and __rlim64_t.  */

> +# define __RLIM_T_MATCHES_RLIM64_T	1

> +#else

> +# define __RLIM_T_MATCHES_RLIM64_T	0

>  #endif

>  

>  /* Number of descriptors that can fit in an `fd_set'.  */

> diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list b/sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list

> index f055c68..b775008 100644

> --- a/sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list

> +++ b/sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list

> @@ -1,7 +1,5 @@

>  # File name	Caller	Syscall name	# args	Strong name	Weak names

>  

>  # rlimit APIs

> -getrlimit	-	getrlimit	i:ip	__getrlimit	getrlimit

> -setrlimit	-	setrlimit	i:ip	__setrlimit	setrlimit

>  prlimit64	EXTRA	prlimit64	i:iipp	prlimit64

>  fanotify_mark	EXTRA	fanotify_mark	i:iiiiis	fanotify_mark

> diff --git a/sysdeps/unix/sysv/linux/getrlimit.c b/sysdeps/unix/sysv/linux/getrlimit.c

> new file mode 100644

> index 0000000..bd340fb

> --- /dev/null

> +++ b/sysdeps/unix/sysv/linux/getrlimit.c

> @@ -0,0 +1,56 @@

> +/* Linux getrlimit implementation (32 bits rlim_t).

> +   Copyright (C) 2016 Free Software Foundation, Inc.

> +   This file is part of the GNU C Library.

> +

> +   The GNU C Library is free software; you can redistribute it and/or

> +   modify it under the terms of the GNU Lesser General Public

> +   License as published by the Free Software Foundation; either

> +   version 2.1 of the License, or (at your option) any later version.

> +

> +   The GNU C Library is distributed in the hope that it will be useful,

> +   but WITHOUT ANY WARRANTY; without even the implied warranty of

> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU

> +   Lesser General Public License for more details.

> +

> +   You should have received a copy of the GNU Lesser General Public

> +   License along with the GNU C Library.  If not, see

> +   <http://www.gnu.org/licenses/>.  */

> +

> +#include <errno.h>

> +#include <sys/resource.h>

> +#include <sys/types.h>

> +#include <shlib-compat.h>

> +

> +#if !__RLIM_T_MATCHES_RLIM64_T

> +

> +/* The __NR_getrlimit compatibility implementation is required iff

> +   __NR_ugetrlimit is also defined (meaning an old broken RLIM_INFINITY

> +   definition).  */

> +# ifndef __NR_ugetrlimit

> +#  define __NR_ugetrlimit __NR_getrlimit

> +#  undef SHLIB_COMPAT

> +#  define SHLIB_COMPAT(a, b, c) 0

> +# endif

> +

> +int

> +__new_getrlimit (enum __rlimit_resource resource, struct rlimit *rlim)

> +{

> +  return INLINE_SYSCALL_CALL (ugetrlimit, resource, rlim);

> +}

> +weak_alias (__new_getrlimit, __getrlimit)

> +hidden_weak (__getrlimit)

> +

> +# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2)

> +/* Back compatible 2Gig limited rlimit.  */

> +int

> +__old_getrlimit (enum __rlimit_resource resource, struct rlimit *rlim)

> +{

> +  return INLINE_SYSCALL_CALL (getrlimit, resource, rlim);

> +}

> +compat_symbol (libc, __old_getrlimit, getrlimit, GLIBC_2_0);

> +versioned_symbol (libc, __new_getrlimit, getrlimit, GLIBC_2_2);

> +# else

> +weak_alias (__new_getrlimit, getrlimit)

> +# endif

> +

> +#endif /* __RLIM_T_MATCHES_RLIM64_T  */

> diff --git a/sysdeps/unix/sysv/linux/getrlimit64.c b/sysdeps/unix/sysv/linux/getrlimit64.c

> index d055a7f..739d054 100644

> --- a/sysdeps/unix/sysv/linux/getrlimit64.c

> +++ b/sysdeps/unix/sysv/linux/getrlimit64.c

> @@ -1,4 +1,5 @@

> -/* Copyright (C) 2010-2016 Free Software Foundation, Inc.

> +/* Linux getrlimit64 implementation (64 bits rlim_t).

> +   Copyright (C) 2010-2016 Free Software Foundation, Inc.

>     This file is part of the GNU C Library.

>  

>     The GNU C Library is free software; you can redistribute it and/or

> @@ -16,29 +17,46 @@

>     <http://www.gnu.org/licenses/>.  */

>  

>  #include <errno.h>

> -#include <sys/resource.h>

>  #include <sys/types.h>

> -#include <sysdep.h>

> -#include <kernel-features.h>

> +#include <shlib-compat.h>

> +

> +/* Add this redirection so the strong_alias for __RLIM_T_MATCHES_RLIM64_T

> +   linking getlimit64 to {__}getrlimit does not thrown a type error.  */

> +#undef getrlimit

> +#undef __getrlimit

> +#define getrlimit getrlimit_redirect

> +#define __getrlimit __getrlimit_redirect

> +#include <sys/resource.h>

> +#undef getrlimit

> +#undef __getrlimit

>  

>  /* Put the soft and hard limits for RESOURCE in *RLIMITS.

>     Returns 0 if successful, -1 if not (and sets errno).  */

>  int

>  __getrlimit64 (enum __rlimit_resource resource, struct rlimit64 *rlimits)

>  {

> -#ifdef __ASSUME_PRLIMIT64

> -  return INLINE_SYSCALL (prlimit64, 4, 0, resource, NULL, rlimits);

> -#else

> -# ifdef __NR_prlimit64

> -  int res = INLINE_SYSCALL (prlimit64, 4, 0, resource, NULL, 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 make 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 (__getrlimit (resource, &rlimits32) < 0)

> +  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

> @@ -47,12 +65,56 @@ __getrlimit64 (enum __rlimit_resource resource, struct rlimit64 *rlimits)

>      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;

> -#endif

>  }

>  libc_hidden_def (__getrlimit64)

> -#ifndef getrlimit64

> +

> +#if __RLIM_T_MATCHES_RLIM64_T

> +/* If both rlim_t and rlimt64_t are essentially the same type we can use

> +   alias both interfaces.  */

> +strong_alias (__getrlimit64, __GI_getrlimit)

> +strong_alias (__getrlimit64, __GI___getrlimit)

> +strong_alias (__getrlimit64, __getrlimit)

> +weak_alias (__getrlimit64, getrlimit)

> +/* And there is no need for compat symbols.  */

> +# undef SHLIB_COMPAT

> +# define SHLIB_COMPAT(a, b, c) 0

> +#endif

> +

> +#if SHLIB_COMPAT (libc, GLIBC_2_1, GLIBC_2_2)

> +/* Back compatible 2Gig limited rlimit.  */

> +extern int __new_getrlimit (enum __rlimit_resource, struct rlimit *);

> +

> +int

> +attribute_compat_text_section

> +__old_getrlimit64 (enum __rlimit_resource resource, struct rlimit64 *rlimits)

> +{

> +# if __RLIM_T_MATCHES_RLIM64_T

> +#  define rlimits32 (*rlimits)

> +# else

> +  struct rlimit rlimits32;

> +# endif

> +

> +  if (__new_getrlimit (resource, &rlimits32) < 0)

> +    return -1;

> +

> +  if (rlimits32.rlim_cur == RLIM_INFINITY)

> +    rlimits->rlim_cur = RLIM64_INFINITY >> 1;

> +  else

> +    rlimits->rlim_cur = rlimits32.rlim_cur;

> +  if (rlimits32.rlim_max == RLIM_INFINITY)

> +    rlimits->rlim_max = RLIM64_INFINITY >> 1;

> +  else

> +    rlimits->rlim_max = rlimits32.rlim_max;

> +

> +  return 0;

> +}

> +versioned_symbol (libc, __getrlimit64, getrlimit64, GLIBC_2_2);

> +compat_symbol (libc, __old_getrlimit64, getrlimit64, GLIBC_2_1);

> +#else

>  weak_alias (__getrlimit64, getrlimit64)

>  libc_hidden_weak (getrlimit64)

>  #endif

> diff --git a/sysdeps/unix/sysv/linux/hppa/getrlimit64.c b/sysdeps/unix/sysv/linux/hppa/getrlimit64.c

> deleted file mode 100644

> index fef018f..0000000

> --- a/sysdeps/unix/sysv/linux/hppa/getrlimit64.c

> +++ /dev/null

> @@ -1 +0,0 @@

> -#include <sysdeps/unix/sysv/linux/i386/getrlimit64.c>

> diff --git a/sysdeps/unix/sysv/linux/hppa/syscalls.list b/sysdeps/unix/sysv/linux/hppa/syscalls.list

> index 1f3dfb0..a95c3dd 100644

> --- a/sysdeps/unix/sysv/linux/hppa/syscalls.list

> +++ b/sysdeps/unix/sysv/linux/hppa/syscalls.list

> @@ -31,8 +31,6 @@ shutdown	-	shutdown	i:ii	__shutdown	shutdown

>  socket		-	socket		i:iii	__socket	socket

>  socketpair	-	socketpair	i:iiif	__socketpair	socketpair

>  

> -setrlimit	-	setrlimit	i:ip	__setrlimit	setrlimit

> -getrlimit	-	getrlimit	i:ip	__getrlimit	getrlimit

>  prlimit64	EXTRA	prlimit64	i:iipp	__prlimit64	prlimit64@@GLIBC_2.17

>  fanotify_mark	EXTRA	fanotify_mark	i:iiiiis	__fanotify_mark	fanotify_mark@@GLIBC_2.19

>  personality	EXTRA	personality	Ei:i	__personality	personality

> diff --git a/sysdeps/unix/sysv/linux/i386/Makefile b/sysdeps/unix/sysv/linux/i386/Makefile

> index 6073a9f..0a08e5e 100644

> --- a/sysdeps/unix/sysv/linux/i386/Makefile

> +++ b/sysdeps/unix/sysv/linux/i386/Makefile

> @@ -34,10 +34,6 @@ libpthread-sysdep_routines += libc-do-syscall

>  libpthread-shared-only-routines += libc-do-syscall

>  endif

>  

> -ifeq ($(subdir),resource)

> -sysdep_routines += oldgetrlimit64

> -endif

> -

>  ifeq ($(subdir),stdlib)

>  gen-as-const-headers += ucontext_i.sym

>  endif

> diff --git a/sysdeps/unix/sysv/linux/i386/getrlimit64.c b/sysdeps/unix/sysv/linux/i386/getrlimit64.c

> deleted file mode 100644

> index 7f3d227..0000000

> --- a/sysdeps/unix/sysv/linux/i386/getrlimit64.c

> +++ /dev/null

> @@ -1,25 +0,0 @@

> -/* Copyright (C) 1999-2016 Free Software Foundation, Inc.

> -   This file is part of the GNU C Library.

> -

> -   The GNU C Library is free software; you can redistribute it and/or

> -   modify it under the terms of the GNU Lesser General Public

> -   License as published by the Free Software Foundation; either

> -   version 2.1 of the License, or (at your option) any later version.

> -

> -   The GNU C Library is distributed in the hope that it will be useful,

> -   but WITHOUT ANY WARRANTY; without even the implied warranty of

> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU

> -   Lesser General Public License for more details.

> -

> -   You should have received a copy of the GNU Lesser General Public

> -   License along with the GNU C Library; if not, see

> -   <http://www.gnu.org/licenses/>.  */

> -

> -#define getrlimit64 __new_getrlimit64

> -

> -#include "../getrlimit64.c"

> -

> -#undef getrlimit64

> -#include <shlib-compat.h>

> -versioned_symbol (libc, __getrlimit64, getrlimit64, GLIBC_2_2);

> -strong_alias (__getrlimit64, __GI_getrlimit64)

> diff --git a/sysdeps/unix/sysv/linux/i386/oldgetrlimit64.c b/sysdeps/unix/sysv/linux/i386/oldgetrlimit64.c

> deleted file mode 100644

> index ad86a07..0000000

> --- a/sysdeps/unix/sysv/linux/i386/oldgetrlimit64.c

> +++ /dev/null

> @@ -1,57 +0,0 @@

> -/* Copyright (C) 1991-2016 Free Software Foundation, Inc.

> -   This file is part of the GNU C Library.

> -

> -   The GNU C Library is free software; you can redistribute it and/or

> -   modify it under the terms of the GNU Lesser General Public

> -   License as published by the Free Software Foundation; either

> -   version 2.1 of the License, or (at your option) any later version.

> -

> -   The GNU C Library is distributed in the hope that it will be useful,

> -   but WITHOUT ANY WARRANTY; without even the implied warranty of

> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU

> -   Lesser General Public License for more details.

> -

> -   You should have received a copy of the GNU Lesser General Public

> -   License along with the GNU C Library; if not, see

> -   <http://www.gnu.org/licenses/>.  */

> -

> -/* This is a compatibility file.  If we don't build the libc with

> -   versioning don't compile this file.  */

> -#include <shlib-compat.h>

> -#if SHLIB_COMPAT (libc, GLIBC_2_1, GLIBC_2_2)

> -

> -#include <errno.h>

> -#include <sys/resource.h>

> -#include <sys/types.h>

> -

> -extern int __new_getrlimit (enum __rlimit_resource, struct rlimit *);

> -extern int __old_getrlimit64 (enum __rlimit_resource resource,

> -			      struct rlimit64 *rlimits);

> -

> -

> -/* Put the soft and hard limits for RESOURCE in *RLIMITS.

> -   Returns 0 if successful, -1 if not (and sets errno).  */

> -int

> -attribute_compat_text_section

> -__old_getrlimit64 (enum __rlimit_resource resource, struct rlimit64 *rlimits)

> -{

> -  struct rlimit rlimits32;

> -

> -  if (__new_getrlimit (resource, &rlimits32) < 0)

> -    return -1;

> -

> -  if (rlimits32.rlim_cur == RLIM_INFINITY)

> -    rlimits->rlim_cur = RLIM64_INFINITY >> 1;

> -  else

> -    rlimits->rlim_cur = rlimits32.rlim_cur;

> -  if (rlimits32.rlim_max == RLIM_INFINITY)

> -    rlimits->rlim_max = RLIM64_INFINITY >> 1;

> -  else

> -    rlimits->rlim_max = rlimits32.rlim_max;

> -

> -  return 0;

> -}

> -

> -compat_symbol (libc, __old_getrlimit64, getrlimit64, GLIBC_2_1);

> -

> -#endif /* SHLIB_COMPAT */

> diff --git a/sysdeps/unix/sysv/linux/i386/syscalls.list b/sysdeps/unix/sysv/linux/i386/syscalls.list

> index 6282ff8..145393f 100644

> --- a/sysdeps/unix/sysv/linux/i386/syscalls.list

> +++ b/sysdeps/unix/sysv/linux/i386/syscalls.list

> @@ -18,8 +18,6 @@ setfsuid	-	setfsuid32	Ei:i	setfsuid

>  modify_ldt	EXTRA	modify_ldt	i:ipi	__modify_ldt	modify_ldt

>  vm86old		EXTRA	vm86old		i:p	__vm86old	vm86@GLIBC_2.0

>  vm86		-	vm86		i:ip	__vm86		vm86@@GLIBC_2.3.4

> -oldgetrlimit	EXTRA	getrlimit	i:ip	__old_getrlimit	getrlimit@GLIBC_2.0

> -setrlimit	-	setrlimit	i:ip	__setrlimit	setrlimit@GLIBC_2.0 setrlimit@@GLIBC_2.2

>  waitpid		-	waitpid		Ci:ipi	__waitpid	waitpid

>  

>  prlimit64	EXTRA	prlimit64	i:iipp	prlimit64

> diff --git a/sysdeps/unix/sysv/linux/m68k/Makefile b/sysdeps/unix/sysv/linux/m68k/Makefile

> index 61c355a..5c50ce6 100644

> --- a/sysdeps/unix/sysv/linux/m68k/Makefile

> +++ b/sysdeps/unix/sysv/linux/m68k/Makefile

> @@ -18,7 +18,3 @@ sysdep-rtld-routines += m68k-vdso

>  sysdep-others += lddlibc4

>  install-bin += lddlibc4

>  endif

> -

> -ifeq ($(subdir),resource)

> -sysdep_routines += oldgetrlimit64

> -endif

> diff --git a/sysdeps/unix/sysv/linux/m68k/getrlimit64.c b/sysdeps/unix/sysv/linux/m68k/getrlimit64.c

> deleted file mode 100644

> index fef018f..0000000

> --- a/sysdeps/unix/sysv/linux/m68k/getrlimit64.c

> +++ /dev/null

> @@ -1 +0,0 @@

> -#include <sysdeps/unix/sysv/linux/i386/getrlimit64.c>

> diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/syscalls.list b/sysdeps/unix/sysv/linux/m68k/m680x0/syscalls.list

> deleted file mode 100644

> index b0ad6893..0000000

> --- a/sysdeps/unix/sysv/linux/m68k/m680x0/syscalls.list

> +++ /dev/null

> @@ -1,4 +0,0 @@

> -# File name	Caller	Syscall name	Args	Strong name	Weak names

> -

> -oldgetrlimit	EXTRA	getrlimit	i:ip	__old_getrlimit	getrlimit@GLIBC_2.0

> -setrlimit	-	setrlimit	i:ip	__setrlimit	setrlimit@GLIBC_2.0 setrlimit@@GLIBC_2.2

> diff --git a/sysdeps/unix/sysv/linux/m68k/oldgetrlimit64.c b/sysdeps/unix/sysv/linux/m68k/oldgetrlimit64.c

> deleted file mode 100644

> index 4c27e95..0000000

> --- a/sysdeps/unix/sysv/linux/m68k/oldgetrlimit64.c

> +++ /dev/null

> @@ -1 +0,0 @@

> -#include <sysdeps/unix/sysv/linux/i386/oldgetrlimit64.c>

> diff --git a/sysdeps/unix/sysv/linux/powerpc/getrlimit64.c b/sysdeps/unix/sysv/linux/powerpc/getrlimit64.c

> deleted file mode 100644

> index fef018f..0000000

> --- a/sysdeps/unix/sysv/linux/powerpc/getrlimit64.c

> +++ /dev/null

> @@ -1 +0,0 @@

> -#include <sysdeps/unix/sysv/linux/i386/getrlimit64.c>

> diff --git a/sysdeps/unix/sysv/linux/powerpc/oldgetrlimit64.c b/sysdeps/unix/sysv/linux/powerpc/oldgetrlimit64.c

> deleted file mode 100644

> index 4c27e95..0000000

> --- a/sysdeps/unix/sysv/linux/powerpc/oldgetrlimit64.c

> +++ /dev/null

> @@ -1 +0,0 @@

> -#include <sysdeps/unix/sysv/linux/i386/oldgetrlimit64.c>

> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/Makefile b/sysdeps/unix/sysv/linux/powerpc/powerpc32/Makefile

> index 84324aa..3d6c150 100644

> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/Makefile

> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/Makefile

> @@ -1,6 +1,2 @@

>  # See Makeconfig regarding the use of default-abi.

>  default-abi := 32

> -

> -ifeq ($(subdir),resource)

> -sysdep_routines += oldgetrlimit64

> -endif

> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list b/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list

> index 451d508..9313747 100644

> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list

> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list

> @@ -3,10 +3,6 @@

>  chown		-	chown		i:sii	__chown		chown@@GLIBC_2.1

>  lchown		-	lchown		i:sii	__lchown	lchown@@GLIBC_2.0 chown@GLIBC_2.0

>  

> -# System calls with wrappers.

> -oldgetrlimit	EXTRA	getrlimit	i:ip	__old_getrlimit	getrlimit@GLIBC_2.0

> -setrlimit	-	setrlimit	i:ip	__setrlimit	setrlimit@GLIBC_2.0 setrlimit@@GLIBC_2.2

> -

>  # Due to 64bit alignment there is a dummy second parameter

>  readahead	-	readahead	i:iiiii	__readahead	readahead

>  

> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list b/sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list

> deleted file mode 100644

> index 6ba6f9b..0000000

> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list

> +++ /dev/null

> @@ -1,3 +0,0 @@

> -# File name	Caller	Syscall name	# args	Strong name	Weak names

> -

> -getrlimit	-	ugetrlimit	i:ip	__getrlimit	getrlimit getrlimit64 __getrlimit64

> diff --git a/sysdeps/unix/sysv/linux/s390/bits/typesizes.h b/sysdeps/unix/sysv/linux/s390/bits/typesizes.h

> index 7ee0cef..62b2418 100644

> --- a/sysdeps/unix/sysv/linux/s390/bits/typesizes.h

> +++ b/sysdeps/unix/sysv/linux/s390/bits/typesizes.h

> @@ -75,6 +75,11 @@

>  

>  /* Same for ino_t and ino64_t.  */

>  # define __INO_T_MATCHES_INO64_T	1

> +

> +/* And for __rlim_t and __rlim64_t.  */

> +# define __RLIM_T_MATCHES_RLIM64_T	1

> +#else

> +# define __RLIM_T_MATCHES_RLIM64_T	0

>  #endif

>  

>  /* Number of descriptors that can fit in an `fd_set'.  */

> diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/Makefile b/sysdeps/unix/sysv/linux/s390/s390-32/Makefile

> index 626a96f..da3b3c7 100644

> --- a/sysdeps/unix/sysv/linux/s390/s390-32/Makefile

> +++ b/sysdeps/unix/sysv/linux/s390/s390-32/Makefile

> @@ -10,10 +10,6 @@ ifeq ($(subdir),misc)

>  sysdep_headers += sys/elf.h

>  endif

>  

> -ifeq ($(subdir),resource)

> -sysdep_routines += oldgetrlimit64

> -endif

> -

>  ifeq ($(subdir),elf)

>  ifeq (yes,$(build-shared))

>  # This is needed to support g++ v2 and v3.

> diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/getrlimit64.c b/sysdeps/unix/sysv/linux/s390/s390-32/getrlimit64.c

> deleted file mode 100644

> index fef018f..0000000

> --- a/sysdeps/unix/sysv/linux/s390/s390-32/getrlimit64.c

> +++ /dev/null

> @@ -1 +0,0 @@

> -#include <sysdeps/unix/sysv/linux/i386/getrlimit64.c>

> diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/oldgetrlimit64.c b/sysdeps/unix/sysv/linux/s390/s390-32/oldgetrlimit64.c

> deleted file mode 100644

> index 4c27e95..0000000

> --- a/sysdeps/unix/sysv/linux/s390/s390-32/oldgetrlimit64.c

> +++ /dev/null

> @@ -1 +0,0 @@

> -#include <sysdeps/unix/sysv/linux/i386/oldgetrlimit64.c>

> diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list b/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list

> index 141b165..300b13d 100644

> --- a/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list

> +++ b/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list

> @@ -15,9 +15,6 @@ getgroups	-	getgroups32	i:ip	__getgroups	getgroups

>  setfsgid	-	setfsgid32	Ei:i	setfsgid

>  setfsuid	-	setfsuid32	Ei:i	setfsuid

>  

> -oldgetrlimit	EXTRA	getrlimit	i:ip	__old_getrlimit	getrlimit@GLIBC_2.0

> -setrlimit	-	setrlimit	i:ip	__setrlimit	setrlimit@GLIBC_2.0 setrlimit@@GLIBC_2.2

> -

>  prlimit64	EXTRA	prlimit64	i:iipp	prlimit64

>  fanotify_mark	EXTRA	fanotify_mark	i:iiiiis	fanotify_mark

>  personality	EXTRA	personality	Ei:i	__personality	personality

> diff --git a/sysdeps/unix/sysv/linux/setrlimit.c b/sysdeps/unix/sysv/linux/setrlimit.c

> new file mode 100644

> index 0000000..78a3c33

> --- /dev/null

> +++ b/sysdeps/unix/sysv/linux/setrlimit.c

> @@ -0,0 +1,64 @@

> +/* Linux setrlimit implementation (32 bits off_t).

> +   Copyright (C) 2016 Free Software Foundation, Inc.

> +   This file is part of the GNU C Library.

> +

> +   The GNU C Library is free software; you can redistribute it and/or

> +   modify it under the terms of the GNU Lesser General Public

> +   License as published by the Free Software Foundation; either

> +   version 2.1 of the License, or (at your option) any later version.

> +

> +   The GNU C Library is distributed in the hope that it will be useful,

> +   but WITHOUT ANY WARRANTY; without even the implied warranty of

> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU

> +   Lesser General Public License for more details.

> +

> +   You should have received a copy of the GNU Lesser General Public

> +   License along with the GNU C Library.  If not, see

> +   <http://www.gnu.org/licenses/>.  */

> +

> +#include <errno.h>

> +#include <sys/resource.h>

> +#include <sys/types.h>

> +#include <shlib-compat.h>

> +

> +#if !__RLIM_T_MATCHES_RLIM64_T

> +

> +/* The compatibility symbol is meant to match the old __NR_getrlimit syscall

> +   (with broken RLIM_INFINITY definition).  It should be provided iff

> +   __NR_getrlimit and __NR_ugetrlimit are both defined.  */

> +# ifndef __NR_ugetrlimit

> +#  undef SHLIB_COMPAT

> +#  define SHLIB_COMPAT(a, b, c) 0

> +# endif

> +

> +int

> +__setrlimit (enum __rlimit_resource resource, const struct rlimit *rlim)

> +{

> +# ifdef __NR_prlimit64

> +  struct rlimit64 rlim64;

> +

> +  if (rlim->rlim_cur == RLIM_INFINITY)

> +    rlim64.rlim_cur = RLIM64_INFINITY;

> +  else

> +    rlim64.rlim_cur = rlim->rlim_cur;

> +  if (rlim->rlim_max == RLIM_INFINITY)

> +    rlim64.rlim_max = RLIM64_INFINITY;

> +  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);

> +}

> +

> +# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2)

> +strong_alias (__setrlimit, __setrlimit_1)

> +compat_symbol (libc, __setrlimit, setrlimit, GLIBC_2_0);

> +versioned_symbol (libc, __setrlimit_1, setrlimit, GLIBC_2_2);

> +# else

> +weak_alias (__setrlimit, setrlimit)

> +# endif

> +

> +#endif /* __RLIM_T_MATCHES_RLIM64_T  */

> diff --git a/sysdeps/unix/sysv/linux/setrlimit64.c b/sysdeps/unix/sysv/linux/setrlimit64.c

> index 5f444d2..0825465 100644

> --- a/sysdeps/unix/sysv/linux/setrlimit64.c

> +++ b/sysdeps/unix/sysv/linux/setrlimit64.c

> @@ -1,4 +1,5 @@

> -/* Copyright (C) 2010-2016 Free Software Foundation, Inc.

> +/* Linux setrlimit64 implementation (64 bits off_t).

> +   Copyright (C) 2010-2016 Free Software Foundation, Inc.

>     This file is part of the GNU C Library.

>  

>     The GNU C Library is free software; you can redistribute it and/or

> @@ -16,25 +17,37 @@

>     <http://www.gnu.org/licenses/>.  */

>  

>  #include <errno.h>

> -#include <sys/resource.h>

>  #include <sys/types.h>

> -#include <sysdep.h>

> -#include <kernel-features.h>

> +#include <shlib-compat.h>

> +

> +/* Add this redirection so the strong_alias for __RLIM_T_MATCHES_RLIM64_T

> +   linking setlimit64 to {__}setrlimit does not thrown a type error.  */

> +#undef settrlimit

> +#undef __sttrlimit

> +#define setrlimit setrlimit_redirect

> +#define __setrlimit __setrlimit_redirect

> +#include <sys/resource.h>

> +#undef setrlimit

> +#undef __setrlimit

>  

>  /* Set the soft and hard limits for RESOURCE to *RLIMITS.

>     Only the super-user can increase hard limits.

>     Return 0 if successful, -1 if not (and sets errno).  */

>  int

> -setrlimit64 (enum __rlimit_resource resource, const struct rlimit64 *rlimits)

> +__setrlimit64 (enum __rlimit_resource resource, const struct rlimit64 *rlimits)

>  {

> -#ifdef __ASSUME_PRLIMIT64

> -  return INLINE_SYSCALL (prlimit64, 4, 0, resource, rlimits, NULL);

> -#else

> -# ifdef __NR_prlimit64

> -  int res = INLINE_SYSCALL (prlimit64, 4, 0, resource, rlimits, NULL);

> +  int res;

> +

> +#ifdef __NR_prlimit64

> +  res = INLINE_SYSCALL_CALL (prlimit64, 0, resource, rlimits, NULL);

>    if (res == 0 || errno != ENOSYS)

>      return res;

> -# endif

> +#endif

> +

> +/* The fallback code only make 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)

> @@ -45,7 +58,18 @@ setrlimit64 (enum __rlimit_resource resource, const struct rlimit64 *rlimits)

>      rlimits32.rlim_max = RLIM_INFINITY;

>    else

>      rlimits32.rlim_max = rlimits->rlim_max;

> +# else

> +#  define rlimits32 (*rlimits)

> +# endif

>  

> -  return __setrlimit (resource, &rlimits32);

> +  res = INLINE_SYSCALL_CALL (setrlimit, resource, &rlimits32);

>  #endif

> +

> +  return res;

>  }

> +weak_alias (__setrlimit64, setrlimit64)

> +

> +#if __RLIM_T_MATCHES_RLIM64_T

> +strong_alias (__setrlimit64, __setrlimit)

> +weak_alias (__setrlimit64, setrlimit)

> +#endif

> diff --git a/sysdeps/unix/sysv/linux/sh/getrlimit64.c b/sysdeps/unix/sysv/linux/sh/getrlimit64.c

> deleted file mode 100644

> index fef018f..0000000

> --- a/sysdeps/unix/sysv/linux/sh/getrlimit64.c

> +++ /dev/null

> @@ -1 +0,0 @@

> -#include <sysdeps/unix/sysv/linux/i386/getrlimit64.c>

> diff --git a/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h b/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h

> index f98dd83..705c877 100644

> --- a/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h

> +++ b/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h

> @@ -69,6 +69,11 @@

>  

>  /* Same for ino_t and ino64_t.  */

>  # define __INO_T_MATCHES_INO64_T	1

> +

> +/* And for __rlim_t and __rlim64_t.  */

> +# define __RLIM_T_MATCHES_RLIM64_T	1

> +#else

> +# define __RLIM_T_MATCHES_RLIM64_T	0

>  #endif

>  

>  /* Number of descriptors that can fit in an `fd_set'.  */

> diff --git a/sysdeps/unix/sysv/linux/sparc/getrlimit64.c b/sysdeps/unix/sysv/linux/sparc/getrlimit64.c

> new file mode 100644

> index 0000000..3a19852

> --- /dev/null

> +++ b/sysdeps/unix/sysv/linux/sparc/getrlimit64.c

> @@ -0,0 +1,24 @@

> +/* Linux getrlimit64 sparc32 implementation (64 bits rlim_t).

> +   Copyright (C) 2016 Free Software Foundation, Inc.

> +   This file is part of the GNU C Library.

> +

> +   The GNU C Library is free software; you can redistribute it and/or

> +   modify it under the terms of the GNU Lesser General Public

> +   License as published by the Free Software Foundation; either

> +   version 2.1 of the License, or (at your option) any later version.

> +

> +   The GNU C Library is distributed in the hope that it will be useful,

> +   but WITHOUT ANY WARRANTY; without even the implied warranty of

> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU

> +   Lesser General Public License for more details.

> +

> +   You should have received a copy of the GNU Lesser General Public

> +   License along with the GNU C Library; if not, see

> +   <http://www.gnu.org/licenses/>.  */

> +

> +#include <shlib-compat.h>

> +

> +#undef SHLIB_COMPAT

> +#define SHLIB_COMPAT(a,b,c) 0

> +

> +#include <sysdeps/unix/sysv/linux/getrlimit64.c>

> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list b/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list

> index 6240cd3..0b6095f 100644

> --- a/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list

> +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list

> @@ -4,8 +4,6 @@ chown		-	chown32		i:sii	__chown		chown

>  lchown		-	lchown32	i:sii	__lchown	lchown

>  fchown		-	fchown32	i:iii	__fchown	fchown

>  

> -setrlimit	-	setrlimit	2	__setrlimit	setrlimit

> -getrlimit	-	getrlimit	2	__getrlimit	getrlimit

>  getegid		-	getegid32	Ei:	__getegid	getegid

>  geteuid		-	geteuid32	Ei:	__geteuid	geteuid

>  getgid		-	getgid32	Ei:	__getgid	getgid

> diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list

> index 7ae2541..68af897 100644

> --- a/sysdeps/unix/sysv/linux/syscalls.list

> +++ b/sysdeps/unix/sysv/linux/syscalls.list

> @@ -26,7 +26,6 @@ getpmsg		-	getpmsg		i:ipppp	getpmsg

>  getppid		-	getppid		Ei:	__getppid	getppid

>  getresuid	-	getresuid	i:ppp	getresuid

>  getresgid	-	getresgid	i:ppp	getresgid

> -getrlimit	-	ugetrlimit	i:ip	__new_getrlimit __getrlimit getrlimit@@GLIBC_2.2

>  getsid		-	getsid		i:i	getsid

>  init_module	EXTRA	init_module	5	init_module

>  inotify_add_watch	EXTRA	inotify_add_watch	i:isi	inotify_add_watch

> diff --git a/sysdeps/unix/sysv/linux/wordsize-64/getrlimit64.c b/sysdeps/unix/sysv/linux/wordsize-64/getrlimit64.c

> deleted file mode 100644

> index 9feab0e..0000000

> --- a/sysdeps/unix/sysv/linux/wordsize-64/getrlimit64.c

> +++ /dev/null

> @@ -1 +0,0 @@

> -/* getrlimit64 is the same as getrlimit. */

> diff --git a/sysdeps/unix/sysv/linux/wordsize-64/setrlimit64.c b/sysdeps/unix/sysv/linux/wordsize-64/setrlimit64.c

> deleted file mode 100644

> index 8edcff0..0000000

> --- a/sysdeps/unix/sysv/linux/wordsize-64/setrlimit64.c

> +++ /dev/null

> @@ -1 +0,0 @@

> -/* setrlimit64 is the same as setrlimit. */

> diff --git a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list

> index 2eb9419..1cb14ae 100644

> --- a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list

> +++ b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list

> @@ -8,8 +8,6 @@ statfs		-	statfs		i:sp	__statfs	statfs statfs64

>  mmap		-	mmap		b:aniiii __mmap		mmap __mmap64 mmap64

>  ftruncate	-	ftruncate	i:ii	__ftruncate	ftruncate ftruncate64 __ftruncate64

>  truncate	-	truncate	i:si	truncate	truncate64

> -getrlimit	-	getrlimit	i:ip	__getrlimit	getrlimit getrlimit64 __getrlimit64

> -setrlimit	-	setrlimit	i:ip	__setrlimit	setrlimit setrlimit64

>  readahead	-	readahead	i:iii	__readahead	readahead

>  sendfile	-	sendfile	i:iipi	sendfile	sendfile64

>  sync_file_range	-	sync_file_range	Ci:iiii	sync_file_range

> diff --git a/sysdeps/unix/sysv/linux/x86/bits/typesizes.h b/sysdeps/unix/sysv/linux/x86/bits/typesizes.h

> index 5817ef3..1fd90d3 100644

> --- a/sysdeps/unix/sysv/linux/x86/bits/typesizes.h

> +++ b/sysdeps/unix/sysv/linux/x86/bits/typesizes.h

> @@ -81,6 +81,11 @@

>  

>  /* Same for ino_t and ino64_t.  */

>  # define __INO_T_MATCHES_INO64_T	1

> +

> +/* And for __rlim_t and __rlim64_t.  */

> +# define __RLIM_T_MATCHES_RLIM64_T	1

> +#else

> +# define __RLIM_T_MATCHES_RLIM64_T	0

>  #endif

>  

>  /* Number of descriptors that can fit in an `fd_set'.  */

>
Andreas Schwab Nov. 16, 2016, 2:19 p.m. UTC | #2
On Okt 27 2016, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> 	Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> 	Yury Norov  <ynorov@caviumnetworks.com>

>

> 	* bits/typesizes.h (__RLIM_T_MATCHES_RLIM64_T): define.

> 	* sysdeps/unix/sysv/linux/alpha/bits/typesizes.h

> 	(__RLIM_T_MATCHES_RLIM64_T): Likewise.

> 	* sysdeps/unix/sysv/linux/generic/bits/typesizes.h

> 	(__RLIM_T_MATCHES_RLIM64_T): Likewise.

> 	* sysdeps/unix/sysv/linux/s390/bits/typesizes.h [__s390x__]

> 	(__RLIM_T_MATCHES_RLIM64_T): Likewise.

> 	* sysdeps/unix/sysv/linux/sparc/bits/typesizes.h

> 	[__arch64__ || __sparcv9] (__RLIM_T_MATCHES_RLIM64_T): Likewise.

> 	* sysdeps/unix/sysv/linux/x86/bits/typesizes.h [__86_64__]

> 	(__RLIM_T_MATCHES_RLIM64_T): Likewise.

> 	* sysdeps/unix/sysv/linux/arm/Makefile [$(subdir) = resource]

> 	(sysdep_routines): Remove oldgetrlimit64.

> 	* sysdeps/unix/sysv/linux/i386/Makefile [$(subdir) = resource]

> 	(sysdep_routines): Likewise.

> 	* sysdeps/unix/sysv/linux/m68k/Makefile [$(subdir) = resource]

> 	(sysdep_routines): Likewise.

> 	* sysdeps/unix/sysv/linux/powerpc/powerpc32/Makefile

> 	[$(subdir) = resource] (sysdep_routines): Likewise.

> 	* sysdeps/unix/sysv/linux/s390/s390-32/Makefile

> 	[$(subdir) = resource] (sysdep_routines): Likewise.

> 	* sysdeps/unix/sysv/linux/arm/getrlimit64.c: Remove file.

> 	* sysdeps/unix/sysv/linux/arm/oldgetrlimit64.c: Likewise.

> 	* sysdeps/unix/sysv/linux/arm/oldgetrlimit.c: Likewise.

> 	* sysdeps/unix/sysv/linux/arm/oldsetrlimit.c: Likewise.

> 	* sysdeps/unix/sysv/linux/hppa/getrlimit64.c: Likewise.

> 	* sysdeps/unix/sysv/linux/i386/getrlimit64.c: Likewise.

> 	* sysdeps/unix/sysv/linux/i386/oldgetrlimit64.c: Likewise.

> 	* sysdeps/unix/sysv/linux/m68k/getrlimit64.c: Likewise.

> 	* sysdeps/unix/sysv/linux/m68k/oldgetrlimit64.c: Likewise.

> 	* sysdeps/unix/sysv/linux/powerpc/getrlimit64.c: Likewise.

> 	* sysdeps/unix/sysv/linux/powerpc/oldgetrlimit64.c: Likewise.

> 	* sysdeps/unix/sysv/linux/s390/s390-32/getrlimit64.c: Likewise.

> 	* sysdeps/unix/sysv/linux/s390/s390-32/oldgetrlimit64.c: Likewise.

> 	* sysdeps/unix/sysv/linux/sh/getrlimit64.c: Likewise.

> 	* sysdeps/unix/sysv/linux/wordsize-64/getrlimit64.c: Likewise.

> 	* sysdeps/unix/sysv/linux/wordsize-64/setrlimit64.c: Likewise.

> 	* sysdeps/sysv/linux/generic/wordsize-32/syscalls.list: Remove

> 	setrlimit and getrlimit.

> 	* sysdeps/unix/sysv/linux/hppa/syscalls.list: Likewise.

> 	* sysdeps/unix/sysv/linux/i386/syscalls.list: Likewise.

> 	* sysdeps/unix/sysv/linux/m68k/m680x0/syscalls.list: Likewise.

> 	* sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list: Likewise.

> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list: Likewise.

> 	* sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list: Likewise.

> 	* sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list: Likewise.

> 	* sysdeps/unix/sysv/linux/syscalls.list: Likewise.

> 	* sysdeps/unix/sysv/linux/wordsize-64/syscalls.list: Likewise.

> 	* sysdeps/unix/sysv/linux/getrlimit.c: New file.

> 	* sysdeps/unix/sysv/linux/sparc/getrlimit64.c: Likewise.

> 	* sysdeps/unix/sysv/linux/setrlimit.c: Likewise.

> 	* sysdeps/unix/sysv/linux/getrlimit64.c (__getrlimit64): Handle

> 	__RLIM_T_MATCHES_RLIM64_T and add alias if defined.

> 	(__old_getrlimit64): Add compatibility symbol.

> 	* sysdeps/unix/sysv/linux/setrlimit64.c (__setrlimit): Likewise.


Ok.

> diff --git a/sysdeps/unix/sysv/linux/getrlimit64.c b/sysdeps/unix/sysv/linux/getrlimit64.c

> index d055a7f..739d054 100644

> --- a/sysdeps/unix/sysv/linux/getrlimit64.c

> +++ b/sysdeps/unix/sysv/linux/getrlimit64.c

> @@ -1,4 +1,5 @@

> -/* Copyright (C) 2010-2016 Free Software Foundation, Inc.

> +/* Linux getrlimit64 implementation (64 bits rlim_t).

> +   Copyright (C) 2010-2016 Free Software Foundation, Inc.

>     This file is part of the GNU C Library.

>  

>     The GNU C Library is free software; you can redistribute it and/or

> @@ -16,29 +17,46 @@

>     <http://www.gnu.org/licenses/>.  */

>  

>  #include <errno.h>

> -#include <sys/resource.h>

>  #include <sys/types.h>

> -#include <sysdep.h>

> -#include <kernel-features.h>

> +#include <shlib-compat.h>

> +

> +/* Add this redirection so the strong_alias for __RLIM_T_MATCHES_RLIM64_T

> +   linking getlimit64 to {__}getrlimit does not thrown a type error.  */


                                                   throw

> +/* The fallback code only make sense if the platform supports either


                             makes

> +#if SHLIB_COMPAT (libc, GLIBC_2_1, GLIBC_2_2)

> +/* Back compatible 2Gig limited rlimit.  */


                      2GiB

> diff --git a/sysdeps/unix/sysv/linux/setrlimit64.c b/sysdeps/unix/sysv/linux/setrlimit64.c

> index 5f444d2..0825465 100644

> --- a/sysdeps/unix/sysv/linux/setrlimit64.c

> +++ b/sysdeps/unix/sysv/linux/setrlimit64.c

> @@ -1,4 +1,5 @@

> -/* Copyright (C) 2010-2016 Free Software Foundation, Inc.

> +/* Linux setrlimit64 implementation (64 bits off_t).

> +   Copyright (C) 2010-2016 Free Software Foundation, Inc.

>     This file is part of the GNU C Library.

>  

>     The GNU C Library is free software; you can redistribute it and/or

> @@ -16,25 +17,37 @@

>     <http://www.gnu.org/licenses/>.  */

>  

>  #include <errno.h>

> -#include <sys/resource.h>

>  #include <sys/types.h>

> -#include <sysdep.h>

> -#include <kernel-features.h>

> +#include <shlib-compat.h>

> +

> +/* Add this redirection so the strong_alias for __RLIM_T_MATCHES_RLIM64_T

> +   linking setlimit64 to {__}setrlimit does not thrown a type error.  */


                                                   throw

> +/* The fallback code only make sense if the platform supports


                             makes


Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
Adhemerval Zanella Nov. 16, 2016, 2:38 p.m. UTC | #3
On 16/11/2016 12:19, Andreas Schwab wrote:
> On Okt 27 2016, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> 

>> 	Adhemerval Zanella  <adhemerval.zanella@linaro.org>

>> 	Yury Norov  <ynorov@caviumnetworks.com>

>>

>> 	* bits/typesizes.h (__RLIM_T_MATCHES_RLIM64_T): define.

>> 	* sysdeps/unix/sysv/linux/alpha/bits/typesizes.h

>> 	(__RLIM_T_MATCHES_RLIM64_T): Likewise.

>> 	* sysdeps/unix/sysv/linux/generic/bits/typesizes.h

>> 	(__RLIM_T_MATCHES_RLIM64_T): Likewise.

>> 	* sysdeps/unix/sysv/linux/s390/bits/typesizes.h [__s390x__]

>> 	(__RLIM_T_MATCHES_RLIM64_T): Likewise.

>> 	* sysdeps/unix/sysv/linux/sparc/bits/typesizes.h

>> 	[__arch64__ || __sparcv9] (__RLIM_T_MATCHES_RLIM64_T): Likewise.

>> 	* sysdeps/unix/sysv/linux/x86/bits/typesizes.h [__86_64__]

>> 	(__RLIM_T_MATCHES_RLIM64_T): Likewise.

>> 	* sysdeps/unix/sysv/linux/arm/Makefile [$(subdir) = resource]

>> 	(sysdep_routines): Remove oldgetrlimit64.

>> 	* sysdeps/unix/sysv/linux/i386/Makefile [$(subdir) = resource]

>> 	(sysdep_routines): Likewise.

>> 	* sysdeps/unix/sysv/linux/m68k/Makefile [$(subdir) = resource]

>> 	(sysdep_routines): Likewise.

>> 	* sysdeps/unix/sysv/linux/powerpc/powerpc32/Makefile

>> 	[$(subdir) = resource] (sysdep_routines): Likewise.

>> 	* sysdeps/unix/sysv/linux/s390/s390-32/Makefile

>> 	[$(subdir) = resource] (sysdep_routines): Likewise.

>> 	* sysdeps/unix/sysv/linux/arm/getrlimit64.c: Remove file.

>> 	* sysdeps/unix/sysv/linux/arm/oldgetrlimit64.c: Likewise.

>> 	* sysdeps/unix/sysv/linux/arm/oldgetrlimit.c: Likewise.

>> 	* sysdeps/unix/sysv/linux/arm/oldsetrlimit.c: Likewise.

>> 	* sysdeps/unix/sysv/linux/hppa/getrlimit64.c: Likewise.

>> 	* sysdeps/unix/sysv/linux/i386/getrlimit64.c: Likewise.

>> 	* sysdeps/unix/sysv/linux/i386/oldgetrlimit64.c: Likewise.

>> 	* sysdeps/unix/sysv/linux/m68k/getrlimit64.c: Likewise.

>> 	* sysdeps/unix/sysv/linux/m68k/oldgetrlimit64.c: Likewise.

>> 	* sysdeps/unix/sysv/linux/powerpc/getrlimit64.c: Likewise.

>> 	* sysdeps/unix/sysv/linux/powerpc/oldgetrlimit64.c: Likewise.

>> 	* sysdeps/unix/sysv/linux/s390/s390-32/getrlimit64.c: Likewise.

>> 	* sysdeps/unix/sysv/linux/s390/s390-32/oldgetrlimit64.c: Likewise.

>> 	* sysdeps/unix/sysv/linux/sh/getrlimit64.c: Likewise.

>> 	* sysdeps/unix/sysv/linux/wordsize-64/getrlimit64.c: Likewise.

>> 	* sysdeps/unix/sysv/linux/wordsize-64/setrlimit64.c: Likewise.

>> 	* sysdeps/sysv/linux/generic/wordsize-32/syscalls.list: Remove

>> 	setrlimit and getrlimit.

>> 	* sysdeps/unix/sysv/linux/hppa/syscalls.list: Likewise.

>> 	* sysdeps/unix/sysv/linux/i386/syscalls.list: Likewise.

>> 	* sysdeps/unix/sysv/linux/m68k/m680x0/syscalls.list: Likewise.

>> 	* sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list: Likewise.

>> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list: Likewise.

>> 	* sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list: Likewise.

>> 	* sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list: Likewise.

>> 	* sysdeps/unix/sysv/linux/syscalls.list: Likewise.

>> 	* sysdeps/unix/sysv/linux/wordsize-64/syscalls.list: Likewise.

>> 	* sysdeps/unix/sysv/linux/getrlimit.c: New file.

>> 	* sysdeps/unix/sysv/linux/sparc/getrlimit64.c: Likewise.

>> 	* sysdeps/unix/sysv/linux/setrlimit.c: Likewise.

>> 	* sysdeps/unix/sysv/linux/getrlimit64.c (__getrlimit64): Handle

>> 	__RLIM_T_MATCHES_RLIM64_T and add alias if defined.

>> 	(__old_getrlimit64): Add compatibility symbol.

>> 	* sysdeps/unix/sysv/linux/setrlimit64.c (__setrlimit): Likewise.

> 

> Ok.

> 

>> diff --git a/sysdeps/unix/sysv/linux/getrlimit64.c b/sysdeps/unix/sysv/linux/getrlimit64.c

>> index d055a7f..739d054 100644

>> --- a/sysdeps/unix/sysv/linux/getrlimit64.c

>> +++ b/sysdeps/unix/sysv/linux/getrlimit64.c

>> @@ -1,4 +1,5 @@

>> -/* Copyright (C) 2010-2016 Free Software Foundation, Inc.

>> +/* Linux getrlimit64 implementation (64 bits rlim_t).

>> +   Copyright (C) 2010-2016 Free Software Foundation, Inc.

>>     This file is part of the GNU C Library.

>>  

>>     The GNU C Library is free software; you can redistribute it and/or

>> @@ -16,29 +17,46 @@

>>     <http://www.gnu.org/licenses/>.  */

>>  

>>  #include <errno.h>

>> -#include <sys/resource.h>

>>  #include <sys/types.h>

>> -#include <sysdep.h>

>> -#include <kernel-features.h>

>> +#include <shlib-compat.h>

>> +

>> +/* Add this redirection so the strong_alias for __RLIM_T_MATCHES_RLIM64_T

>> +   linking getlimit64 to {__}getrlimit does not thrown a type error.  */

> 

>                                                    throw


Ack, I fixed it on my local branch.

> 

>> +/* The fallback code only make sense if the platform supports either

> 

>                              makes


Ack.

> 

>> +#if SHLIB_COMPAT (libc, GLIBC_2_1, GLIBC_2_2)

>> +/* Back compatible 2Gig limited rlimit.  */

> 

>                       2GiB

> 


Ack.

>> diff --git a/sysdeps/unix/sysv/linux/setrlimit64.c b/sysdeps/unix/sysv/linux/setrlimit64.c

>> index 5f444d2..0825465 100644

>> --- a/sysdeps/unix/sysv/linux/setrlimit64.c

>> +++ b/sysdeps/unix/sysv/linux/setrlimit64.c

>> @@ -1,4 +1,5 @@

>> -/* Copyright (C) 2010-2016 Free Software Foundation, Inc.

>> +/* Linux setrlimit64 implementation (64 bits off_t).

>> +   Copyright (C) 2010-2016 Free Software Foundation, Inc.

>>     This file is part of the GNU C Library.

>>  

>>     The GNU C Library is free software; you can redistribute it and/or

>> @@ -16,25 +17,37 @@

>>     <http://www.gnu.org/licenses/>.  */

>>  

>>  #include <errno.h>

>> -#include <sys/resource.h>

>>  #include <sys/types.h>

>> -#include <sysdep.h>

>> -#include <kernel-features.h>

>> +#include <shlib-compat.h>

>> +

>> +/* Add this redirection so the strong_alias for __RLIM_T_MATCHES_RLIM64_T

>> +   linking setlimit64 to {__}setrlimit does not thrown a type error.  */

> 

>                                                    throw


Ack.

> 

>> +/* The fallback code only make sense if the platform supports

> 

>                              makes


Ack.
diff mbox

Patch

diff --git a/bits/typesizes.h b/bits/typesizes.h
index 53047b8..ff20601 100644
--- a/bits/typesizes.h
+++ b/bits/typesizes.h
@@ -69,6 +69,11 @@ 
 
 /* Same for ino_t and ino64_t.  */
 # define __INO_T_MATCHES_INO64_T	1
+
+/* And for rlim_t and rlim64_t.  */
+# define __RLIM_T_MATCHES_RLIM64_T	1
+#else
+# define __RLIM_T_MATCHES_RLIM64_T	0
 #endif
 
 /* Number of descriptors that can fit in an `fd_set'.  */
diff --git a/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h b/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h
index 3cfd887..ce96501 100644
--- a/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h
+++ b/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h
@@ -66,6 +66,9 @@ 
    for C type-checking purposes.  */
 #define __OFF_T_MATCHES_OFF64_T	1
 
+/* And for __rlim_t and __rlim64_t.  */
+#define __RLIM_T_MATCHES_RLIM64_T 1
+
 /* Number of descriptors that can fit in an `fd_set'.  */
 #define	__FD_SETSIZE		1024
 
diff --git a/sysdeps/unix/sysv/linux/arm/Makefile b/sysdeps/unix/sysv/linux/arm/Makefile
index 270cb73..b9b8f71 100644
--- a/sysdeps/unix/sysv/linux/arm/Makefile
+++ b/sysdeps/unix/sysv/linux/arm/Makefile
@@ -12,10 +12,6 @@  ifeq ($(subdir),signal)
 sysdep_routines += sigrestorer
 endif
 
-ifeq ($(subdir),resource)
-sysdep_routines += oldgetrlimit64
-endif
-
 ifeq ($(subdir),stdlib)
 gen-as-const-headers += ucontext_i.sym
 endif
diff --git a/sysdeps/unix/sysv/linux/arm/getrlimit64.c b/sysdeps/unix/sysv/linux/arm/getrlimit64.c
deleted file mode 100644
index fef018f..0000000
--- a/sysdeps/unix/sysv/linux/arm/getrlimit64.c
+++ /dev/null
@@ -1 +0,0 @@ 
-#include <sysdeps/unix/sysv/linux/i386/getrlimit64.c>
diff --git a/sysdeps/unix/sysv/linux/arm/oldgetrlimit.c b/sysdeps/unix/sysv/linux/arm/oldgetrlimit.c
deleted file mode 100644
index 6e25b02..0000000
--- a/sysdeps/unix/sysv/linux/arm/oldgetrlimit.c
+++ /dev/null
@@ -1 +0,0 @@ 
-/* Empty.  */
diff --git a/sysdeps/unix/sysv/linux/arm/oldgetrlimit64.c b/sysdeps/unix/sysv/linux/arm/oldgetrlimit64.c
deleted file mode 100644
index 4c27e95..0000000
--- a/sysdeps/unix/sysv/linux/arm/oldgetrlimit64.c
+++ /dev/null
@@ -1 +0,0 @@ 
-#include <sysdeps/unix/sysv/linux/i386/oldgetrlimit64.c>
diff --git a/sysdeps/unix/sysv/linux/arm/oldsetrlimit.c b/sysdeps/unix/sysv/linux/arm/oldsetrlimit.c
deleted file mode 100644
index 6e25b02..0000000
--- a/sysdeps/unix/sysv/linux/arm/oldsetrlimit.c
+++ /dev/null
@@ -1 +0,0 @@ 
-/* Empty.  */
diff --git a/sysdeps/unix/sysv/linux/generic/bits/typesizes.h b/sysdeps/unix/sysv/linux/generic/bits/typesizes.h
index c31bba2..f7766c7 100644
--- a/sysdeps/unix/sysv/linux/generic/bits/typesizes.h
+++ b/sysdeps/unix/sysv/linux/generic/bits/typesizes.h
@@ -70,6 +70,11 @@ 
 
 /* Same for ino_t and ino64_t.  */
 # define __INO_T_MATCHES_INO64_T	1
+
+/* And for __rlim_t and __rlim64_t.  */
+# define __RLIM_T_MATCHES_RLIM64_T	1
+#else
+# define __RLIM_T_MATCHES_RLIM64_T	0
 #endif
 
 /* Number of descriptors that can fit in an `fd_set'.  */
diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list b/sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list
index f055c68..b775008 100644
--- a/sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list
+++ b/sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list
@@ -1,7 +1,5 @@ 
 # File name	Caller	Syscall name	# args	Strong name	Weak names
 
 # rlimit APIs
-getrlimit	-	getrlimit	i:ip	__getrlimit	getrlimit
-setrlimit	-	setrlimit	i:ip	__setrlimit	setrlimit
 prlimit64	EXTRA	prlimit64	i:iipp	prlimit64
 fanotify_mark	EXTRA	fanotify_mark	i:iiiiis	fanotify_mark
diff --git a/sysdeps/unix/sysv/linux/getrlimit.c b/sysdeps/unix/sysv/linux/getrlimit.c
new file mode 100644
index 0000000..bd340fb
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/getrlimit.c
@@ -0,0 +1,56 @@ 
+/* Linux getrlimit implementation (32 bits rlim_t).
+   Copyright (C) 2016 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <sys/resource.h>
+#include <sys/types.h>
+#include <shlib-compat.h>
+
+#if !__RLIM_T_MATCHES_RLIM64_T
+
+/* The __NR_getrlimit compatibility implementation is required iff
+   __NR_ugetrlimit is also defined (meaning an old broken RLIM_INFINITY
+   definition).  */
+# ifndef __NR_ugetrlimit
+#  define __NR_ugetrlimit __NR_getrlimit
+#  undef SHLIB_COMPAT
+#  define SHLIB_COMPAT(a, b, c) 0
+# endif
+
+int
+__new_getrlimit (enum __rlimit_resource resource, struct rlimit *rlim)
+{
+  return INLINE_SYSCALL_CALL (ugetrlimit, resource, rlim);
+}
+weak_alias (__new_getrlimit, __getrlimit)
+hidden_weak (__getrlimit)
+
+# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2)
+/* Back compatible 2Gig limited rlimit.  */
+int
+__old_getrlimit (enum __rlimit_resource resource, struct rlimit *rlim)
+{
+  return INLINE_SYSCALL_CALL (getrlimit, resource, rlim);
+}
+compat_symbol (libc, __old_getrlimit, getrlimit, GLIBC_2_0);
+versioned_symbol (libc, __new_getrlimit, getrlimit, GLIBC_2_2);
+# else
+weak_alias (__new_getrlimit, getrlimit)
+# endif
+
+#endif /* __RLIM_T_MATCHES_RLIM64_T  */
diff --git a/sysdeps/unix/sysv/linux/getrlimit64.c b/sysdeps/unix/sysv/linux/getrlimit64.c
index d055a7f..739d054 100644
--- a/sysdeps/unix/sysv/linux/getrlimit64.c
+++ b/sysdeps/unix/sysv/linux/getrlimit64.c
@@ -1,4 +1,5 @@ 
-/* Copyright (C) 2010-2016 Free Software Foundation, Inc.
+/* Linux getrlimit64 implementation (64 bits rlim_t).
+   Copyright (C) 2010-2016 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -16,29 +17,46 @@ 
    <http://www.gnu.org/licenses/>.  */
 
 #include <errno.h>
-#include <sys/resource.h>
 #include <sys/types.h>
-#include <sysdep.h>
-#include <kernel-features.h>
+#include <shlib-compat.h>
+
+/* Add this redirection so the strong_alias for __RLIM_T_MATCHES_RLIM64_T
+   linking getlimit64 to {__}getrlimit does not thrown a type error.  */
+#undef getrlimit
+#undef __getrlimit
+#define getrlimit getrlimit_redirect
+#define __getrlimit __getrlimit_redirect
+#include <sys/resource.h>
+#undef getrlimit
+#undef __getrlimit
 
 /* Put the soft and hard limits for RESOURCE in *RLIMITS.
    Returns 0 if successful, -1 if not (and sets errno).  */
 int
 __getrlimit64 (enum __rlimit_resource resource, struct rlimit64 *rlimits)
 {
-#ifdef __ASSUME_PRLIMIT64
-  return INLINE_SYSCALL (prlimit64, 4, 0, resource, NULL, rlimits);
-#else
-# ifdef __NR_prlimit64
-  int res = INLINE_SYSCALL (prlimit64, 4, 0, resource, NULL, 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 make 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 (__getrlimit (resource, &rlimits32) < 0)
+  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
@@ -47,12 +65,56 @@  __getrlimit64 (enum __rlimit_resource resource, struct rlimit64 *rlimits)
     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;
-#endif
 }
 libc_hidden_def (__getrlimit64)
-#ifndef getrlimit64
+
+#if __RLIM_T_MATCHES_RLIM64_T
+/* If both rlim_t and rlimt64_t are essentially the same type we can use
+   alias both interfaces.  */
+strong_alias (__getrlimit64, __GI_getrlimit)
+strong_alias (__getrlimit64, __GI___getrlimit)
+strong_alias (__getrlimit64, __getrlimit)
+weak_alias (__getrlimit64, getrlimit)
+/* And there is no need for compat symbols.  */
+# undef SHLIB_COMPAT
+# define SHLIB_COMPAT(a, b, c) 0
+#endif
+
+#if SHLIB_COMPAT (libc, GLIBC_2_1, GLIBC_2_2)
+/* Back compatible 2Gig limited rlimit.  */
+extern int __new_getrlimit (enum __rlimit_resource, struct rlimit *);
+
+int
+attribute_compat_text_section
+__old_getrlimit64 (enum __rlimit_resource resource, struct rlimit64 *rlimits)
+{
+# if __RLIM_T_MATCHES_RLIM64_T
+#  define rlimits32 (*rlimits)
+# else
+  struct rlimit rlimits32;
+# endif
+
+  if (__new_getrlimit (resource, &rlimits32) < 0)
+    return -1;
+
+  if (rlimits32.rlim_cur == RLIM_INFINITY)
+    rlimits->rlim_cur = RLIM64_INFINITY >> 1;
+  else
+    rlimits->rlim_cur = rlimits32.rlim_cur;
+  if (rlimits32.rlim_max == RLIM_INFINITY)
+    rlimits->rlim_max = RLIM64_INFINITY >> 1;
+  else
+    rlimits->rlim_max = rlimits32.rlim_max;
+
+  return 0;
+}
+versioned_symbol (libc, __getrlimit64, getrlimit64, GLIBC_2_2);
+compat_symbol (libc, __old_getrlimit64, getrlimit64, GLIBC_2_1);
+#else
 weak_alias (__getrlimit64, getrlimit64)
 libc_hidden_weak (getrlimit64)
 #endif
diff --git a/sysdeps/unix/sysv/linux/hppa/getrlimit64.c b/sysdeps/unix/sysv/linux/hppa/getrlimit64.c
deleted file mode 100644
index fef018f..0000000
--- a/sysdeps/unix/sysv/linux/hppa/getrlimit64.c
+++ /dev/null
@@ -1 +0,0 @@ 
-#include <sysdeps/unix/sysv/linux/i386/getrlimit64.c>
diff --git a/sysdeps/unix/sysv/linux/hppa/syscalls.list b/sysdeps/unix/sysv/linux/hppa/syscalls.list
index 1f3dfb0..a95c3dd 100644
--- a/sysdeps/unix/sysv/linux/hppa/syscalls.list
+++ b/sysdeps/unix/sysv/linux/hppa/syscalls.list
@@ -31,8 +31,6 @@  shutdown	-	shutdown	i:ii	__shutdown	shutdown
 socket		-	socket		i:iii	__socket	socket
 socketpair	-	socketpair	i:iiif	__socketpair	socketpair
 
-setrlimit	-	setrlimit	i:ip	__setrlimit	setrlimit
-getrlimit	-	getrlimit	i:ip	__getrlimit	getrlimit
 prlimit64	EXTRA	prlimit64	i:iipp	__prlimit64	prlimit64@@GLIBC_2.17
 fanotify_mark	EXTRA	fanotify_mark	i:iiiiis	__fanotify_mark	fanotify_mark@@GLIBC_2.19
 personality	EXTRA	personality	Ei:i	__personality	personality
diff --git a/sysdeps/unix/sysv/linux/i386/Makefile b/sysdeps/unix/sysv/linux/i386/Makefile
index 6073a9f..0a08e5e 100644
--- a/sysdeps/unix/sysv/linux/i386/Makefile
+++ b/sysdeps/unix/sysv/linux/i386/Makefile
@@ -34,10 +34,6 @@  libpthread-sysdep_routines += libc-do-syscall
 libpthread-shared-only-routines += libc-do-syscall
 endif
 
-ifeq ($(subdir),resource)
-sysdep_routines += oldgetrlimit64
-endif
-
 ifeq ($(subdir),stdlib)
 gen-as-const-headers += ucontext_i.sym
 endif
diff --git a/sysdeps/unix/sysv/linux/i386/getrlimit64.c b/sysdeps/unix/sysv/linux/i386/getrlimit64.c
deleted file mode 100644
index 7f3d227..0000000
--- a/sysdeps/unix/sysv/linux/i386/getrlimit64.c
+++ /dev/null
@@ -1,25 +0,0 @@ 
-/* Copyright (C) 1999-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#define getrlimit64 __new_getrlimit64
-
-#include "../getrlimit64.c"
-
-#undef getrlimit64
-#include <shlib-compat.h>
-versioned_symbol (libc, __getrlimit64, getrlimit64, GLIBC_2_2);
-strong_alias (__getrlimit64, __GI_getrlimit64)
diff --git a/sysdeps/unix/sysv/linux/i386/oldgetrlimit64.c b/sysdeps/unix/sysv/linux/i386/oldgetrlimit64.c
deleted file mode 100644
index ad86a07..0000000
--- a/sysdeps/unix/sysv/linux/i386/oldgetrlimit64.c
+++ /dev/null
@@ -1,57 +0,0 @@ 
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-/* This is a compatibility file.  If we don't build the libc with
-   versioning don't compile this file.  */
-#include <shlib-compat.h>
-#if SHLIB_COMPAT (libc, GLIBC_2_1, GLIBC_2_2)
-
-#include <errno.h>
-#include <sys/resource.h>
-#include <sys/types.h>
-
-extern int __new_getrlimit (enum __rlimit_resource, struct rlimit *);
-extern int __old_getrlimit64 (enum __rlimit_resource resource,
-			      struct rlimit64 *rlimits);
-
-
-/* Put the soft and hard limits for RESOURCE in *RLIMITS.
-   Returns 0 if successful, -1 if not (and sets errno).  */
-int
-attribute_compat_text_section
-__old_getrlimit64 (enum __rlimit_resource resource, struct rlimit64 *rlimits)
-{
-  struct rlimit rlimits32;
-
-  if (__new_getrlimit (resource, &rlimits32) < 0)
-    return -1;
-
-  if (rlimits32.rlim_cur == RLIM_INFINITY)
-    rlimits->rlim_cur = RLIM64_INFINITY >> 1;
-  else
-    rlimits->rlim_cur = rlimits32.rlim_cur;
-  if (rlimits32.rlim_max == RLIM_INFINITY)
-    rlimits->rlim_max = RLIM64_INFINITY >> 1;
-  else
-    rlimits->rlim_max = rlimits32.rlim_max;
-
-  return 0;
-}
-
-compat_symbol (libc, __old_getrlimit64, getrlimit64, GLIBC_2_1);
-
-#endif /* SHLIB_COMPAT */
diff --git a/sysdeps/unix/sysv/linux/i386/syscalls.list b/sysdeps/unix/sysv/linux/i386/syscalls.list
index 6282ff8..145393f 100644
--- a/sysdeps/unix/sysv/linux/i386/syscalls.list
+++ b/sysdeps/unix/sysv/linux/i386/syscalls.list
@@ -18,8 +18,6 @@  setfsuid	-	setfsuid32	Ei:i	setfsuid
 modify_ldt	EXTRA	modify_ldt	i:ipi	__modify_ldt	modify_ldt
 vm86old		EXTRA	vm86old		i:p	__vm86old	vm86@GLIBC_2.0
 vm86		-	vm86		i:ip	__vm86		vm86@@GLIBC_2.3.4
-oldgetrlimit	EXTRA	getrlimit	i:ip	__old_getrlimit	getrlimit@GLIBC_2.0
-setrlimit	-	setrlimit	i:ip	__setrlimit	setrlimit@GLIBC_2.0 setrlimit@@GLIBC_2.2
 waitpid		-	waitpid		Ci:ipi	__waitpid	waitpid
 
 prlimit64	EXTRA	prlimit64	i:iipp	prlimit64
diff --git a/sysdeps/unix/sysv/linux/m68k/Makefile b/sysdeps/unix/sysv/linux/m68k/Makefile
index 61c355a..5c50ce6 100644
--- a/sysdeps/unix/sysv/linux/m68k/Makefile
+++ b/sysdeps/unix/sysv/linux/m68k/Makefile
@@ -18,7 +18,3 @@  sysdep-rtld-routines += m68k-vdso
 sysdep-others += lddlibc4
 install-bin += lddlibc4
 endif
-
-ifeq ($(subdir),resource)
-sysdep_routines += oldgetrlimit64
-endif
diff --git a/sysdeps/unix/sysv/linux/m68k/getrlimit64.c b/sysdeps/unix/sysv/linux/m68k/getrlimit64.c
deleted file mode 100644
index fef018f..0000000
--- a/sysdeps/unix/sysv/linux/m68k/getrlimit64.c
+++ /dev/null
@@ -1 +0,0 @@ 
-#include <sysdeps/unix/sysv/linux/i386/getrlimit64.c>
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/syscalls.list b/sysdeps/unix/sysv/linux/m68k/m680x0/syscalls.list
deleted file mode 100644
index b0ad6893..0000000
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/syscalls.list
+++ /dev/null
@@ -1,4 +0,0 @@ 
-# File name	Caller	Syscall name	Args	Strong name	Weak names
-
-oldgetrlimit	EXTRA	getrlimit	i:ip	__old_getrlimit	getrlimit@GLIBC_2.0
-setrlimit	-	setrlimit	i:ip	__setrlimit	setrlimit@GLIBC_2.0 setrlimit@@GLIBC_2.2
diff --git a/sysdeps/unix/sysv/linux/m68k/oldgetrlimit64.c b/sysdeps/unix/sysv/linux/m68k/oldgetrlimit64.c
deleted file mode 100644
index 4c27e95..0000000
--- a/sysdeps/unix/sysv/linux/m68k/oldgetrlimit64.c
+++ /dev/null
@@ -1 +0,0 @@ 
-#include <sysdeps/unix/sysv/linux/i386/oldgetrlimit64.c>
diff --git a/sysdeps/unix/sysv/linux/powerpc/getrlimit64.c b/sysdeps/unix/sysv/linux/powerpc/getrlimit64.c
deleted file mode 100644
index fef018f..0000000
--- a/sysdeps/unix/sysv/linux/powerpc/getrlimit64.c
+++ /dev/null
@@ -1 +0,0 @@ 
-#include <sysdeps/unix/sysv/linux/i386/getrlimit64.c>
diff --git a/sysdeps/unix/sysv/linux/powerpc/oldgetrlimit64.c b/sysdeps/unix/sysv/linux/powerpc/oldgetrlimit64.c
deleted file mode 100644
index 4c27e95..0000000
--- a/sysdeps/unix/sysv/linux/powerpc/oldgetrlimit64.c
+++ /dev/null
@@ -1 +0,0 @@ 
-#include <sysdeps/unix/sysv/linux/i386/oldgetrlimit64.c>
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/Makefile b/sysdeps/unix/sysv/linux/powerpc/powerpc32/Makefile
index 84324aa..3d6c150 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/Makefile
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/Makefile
@@ -1,6 +1,2 @@ 
 # See Makeconfig regarding the use of default-abi.
 default-abi := 32
-
-ifeq ($(subdir),resource)
-sysdep_routines += oldgetrlimit64
-endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list b/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list
index 451d508..9313747 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list
@@ -3,10 +3,6 @@ 
 chown		-	chown		i:sii	__chown		chown@@GLIBC_2.1
 lchown		-	lchown		i:sii	__lchown	lchown@@GLIBC_2.0 chown@GLIBC_2.0
 
-# System calls with wrappers.
-oldgetrlimit	EXTRA	getrlimit	i:ip	__old_getrlimit	getrlimit@GLIBC_2.0
-setrlimit	-	setrlimit	i:ip	__setrlimit	setrlimit@GLIBC_2.0 setrlimit@@GLIBC_2.2
-
 # Due to 64bit alignment there is a dummy second parameter
 readahead	-	readahead	i:iiiii	__readahead	readahead
 
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list b/sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list
deleted file mode 100644
index 6ba6f9b..0000000
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list
+++ /dev/null
@@ -1,3 +0,0 @@ 
-# File name	Caller	Syscall name	# args	Strong name	Weak names
-
-getrlimit	-	ugetrlimit	i:ip	__getrlimit	getrlimit getrlimit64 __getrlimit64
diff --git a/sysdeps/unix/sysv/linux/s390/bits/typesizes.h b/sysdeps/unix/sysv/linux/s390/bits/typesizes.h
index 7ee0cef..62b2418 100644
--- a/sysdeps/unix/sysv/linux/s390/bits/typesizes.h
+++ b/sysdeps/unix/sysv/linux/s390/bits/typesizes.h
@@ -75,6 +75,11 @@ 
 
 /* Same for ino_t and ino64_t.  */
 # define __INO_T_MATCHES_INO64_T	1
+
+/* And for __rlim_t and __rlim64_t.  */
+# define __RLIM_T_MATCHES_RLIM64_T	1
+#else
+# define __RLIM_T_MATCHES_RLIM64_T	0
 #endif
 
 /* Number of descriptors that can fit in an `fd_set'.  */
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/Makefile b/sysdeps/unix/sysv/linux/s390/s390-32/Makefile
index 626a96f..da3b3c7 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/Makefile
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/Makefile
@@ -10,10 +10,6 @@  ifeq ($(subdir),misc)
 sysdep_headers += sys/elf.h
 endif
 
-ifeq ($(subdir),resource)
-sysdep_routines += oldgetrlimit64
-endif
-
 ifeq ($(subdir),elf)
 ifeq (yes,$(build-shared))
 # This is needed to support g++ v2 and v3.
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/getrlimit64.c b/sysdeps/unix/sysv/linux/s390/s390-32/getrlimit64.c
deleted file mode 100644
index fef018f..0000000
--- a/sysdeps/unix/sysv/linux/s390/s390-32/getrlimit64.c
+++ /dev/null
@@ -1 +0,0 @@ 
-#include <sysdeps/unix/sysv/linux/i386/getrlimit64.c>
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/oldgetrlimit64.c b/sysdeps/unix/sysv/linux/s390/s390-32/oldgetrlimit64.c
deleted file mode 100644
index 4c27e95..0000000
--- a/sysdeps/unix/sysv/linux/s390/s390-32/oldgetrlimit64.c
+++ /dev/null
@@ -1 +0,0 @@ 
-#include <sysdeps/unix/sysv/linux/i386/oldgetrlimit64.c>
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list b/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list
index 141b165..300b13d 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list
@@ -15,9 +15,6 @@  getgroups	-	getgroups32	i:ip	__getgroups	getgroups
 setfsgid	-	setfsgid32	Ei:i	setfsgid
 setfsuid	-	setfsuid32	Ei:i	setfsuid
 
-oldgetrlimit	EXTRA	getrlimit	i:ip	__old_getrlimit	getrlimit@GLIBC_2.0
-setrlimit	-	setrlimit	i:ip	__setrlimit	setrlimit@GLIBC_2.0 setrlimit@@GLIBC_2.2
-
 prlimit64	EXTRA	prlimit64	i:iipp	prlimit64
 fanotify_mark	EXTRA	fanotify_mark	i:iiiiis	fanotify_mark
 personality	EXTRA	personality	Ei:i	__personality	personality
diff --git a/sysdeps/unix/sysv/linux/setrlimit.c b/sysdeps/unix/sysv/linux/setrlimit.c
new file mode 100644
index 0000000..78a3c33
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/setrlimit.c
@@ -0,0 +1,64 @@ 
+/* Linux setrlimit implementation (32 bits off_t).
+   Copyright (C) 2016 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <sys/resource.h>
+#include <sys/types.h>
+#include <shlib-compat.h>
+
+#if !__RLIM_T_MATCHES_RLIM64_T
+
+/* The compatibility symbol is meant to match the old __NR_getrlimit syscall
+   (with broken RLIM_INFINITY definition).  It should be provided iff
+   __NR_getrlimit and __NR_ugetrlimit are both defined.  */
+# ifndef __NR_ugetrlimit
+#  undef SHLIB_COMPAT
+#  define SHLIB_COMPAT(a, b, c) 0
+# endif
+
+int
+__setrlimit (enum __rlimit_resource resource, const struct rlimit *rlim)
+{
+# ifdef __NR_prlimit64
+  struct rlimit64 rlim64;
+
+  if (rlim->rlim_cur == RLIM_INFINITY)
+    rlim64.rlim_cur = RLIM64_INFINITY;
+  else
+    rlim64.rlim_cur = rlim->rlim_cur;
+  if (rlim->rlim_max == RLIM_INFINITY)
+    rlim64.rlim_max = RLIM64_INFINITY;
+  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);
+}
+
+# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2)
+strong_alias (__setrlimit, __setrlimit_1)
+compat_symbol (libc, __setrlimit, setrlimit, GLIBC_2_0);
+versioned_symbol (libc, __setrlimit_1, setrlimit, GLIBC_2_2);
+# else
+weak_alias (__setrlimit, setrlimit)
+# endif
+
+#endif /* __RLIM_T_MATCHES_RLIM64_T  */
diff --git a/sysdeps/unix/sysv/linux/setrlimit64.c b/sysdeps/unix/sysv/linux/setrlimit64.c
index 5f444d2..0825465 100644
--- a/sysdeps/unix/sysv/linux/setrlimit64.c
+++ b/sysdeps/unix/sysv/linux/setrlimit64.c
@@ -1,4 +1,5 @@ 
-/* Copyright (C) 2010-2016 Free Software Foundation, Inc.
+/* Linux setrlimit64 implementation (64 bits off_t).
+   Copyright (C) 2010-2016 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -16,25 +17,37 @@ 
    <http://www.gnu.org/licenses/>.  */
 
 #include <errno.h>
-#include <sys/resource.h>
 #include <sys/types.h>
-#include <sysdep.h>
-#include <kernel-features.h>
+#include <shlib-compat.h>
+
+/* Add this redirection so the strong_alias for __RLIM_T_MATCHES_RLIM64_T
+   linking setlimit64 to {__}setrlimit does not thrown a type error.  */
+#undef settrlimit
+#undef __sttrlimit
+#define setrlimit setrlimit_redirect
+#define __setrlimit __setrlimit_redirect
+#include <sys/resource.h>
+#undef setrlimit
+#undef __setrlimit
 
 /* Set the soft and hard limits for RESOURCE to *RLIMITS.
    Only the super-user can increase hard limits.
    Return 0 if successful, -1 if not (and sets errno).  */
 int
-setrlimit64 (enum __rlimit_resource resource, const struct rlimit64 *rlimits)
+__setrlimit64 (enum __rlimit_resource resource, const struct rlimit64 *rlimits)
 {
-#ifdef __ASSUME_PRLIMIT64
-  return INLINE_SYSCALL (prlimit64, 4, 0, resource, rlimits, NULL);
-#else
-# ifdef __NR_prlimit64
-  int res = INLINE_SYSCALL (prlimit64, 4, 0, resource, rlimits, NULL);
+  int res;
+
+#ifdef __NR_prlimit64
+  res = INLINE_SYSCALL_CALL (prlimit64, 0, resource, rlimits, NULL);
   if (res == 0 || errno != ENOSYS)
     return res;
-# endif
+#endif
+
+/* The fallback code only make 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)
@@ -45,7 +58,18 @@  setrlimit64 (enum __rlimit_resource resource, const struct rlimit64 *rlimits)
     rlimits32.rlim_max = RLIM_INFINITY;
   else
     rlimits32.rlim_max = rlimits->rlim_max;
+# else
+#  define rlimits32 (*rlimits)
+# endif
 
-  return __setrlimit (resource, &rlimits32);
+  res = INLINE_SYSCALL_CALL (setrlimit, resource, &rlimits32);
 #endif
+
+  return res;
 }
+weak_alias (__setrlimit64, setrlimit64)
+
+#if __RLIM_T_MATCHES_RLIM64_T
+strong_alias (__setrlimit64, __setrlimit)
+weak_alias (__setrlimit64, setrlimit)
+#endif
diff --git a/sysdeps/unix/sysv/linux/sh/getrlimit64.c b/sysdeps/unix/sysv/linux/sh/getrlimit64.c
deleted file mode 100644
index fef018f..0000000
--- a/sysdeps/unix/sysv/linux/sh/getrlimit64.c
+++ /dev/null
@@ -1 +0,0 @@ 
-#include <sysdeps/unix/sysv/linux/i386/getrlimit64.c>
diff --git a/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h b/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
index f98dd83..705c877 100644
--- a/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
+++ b/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
@@ -69,6 +69,11 @@ 
 
 /* Same for ino_t and ino64_t.  */
 # define __INO_T_MATCHES_INO64_T	1
+
+/* And for __rlim_t and __rlim64_t.  */
+# define __RLIM_T_MATCHES_RLIM64_T	1
+#else
+# define __RLIM_T_MATCHES_RLIM64_T	0
 #endif
 
 /* Number of descriptors that can fit in an `fd_set'.  */
diff --git a/sysdeps/unix/sysv/linux/sparc/getrlimit64.c b/sysdeps/unix/sysv/linux/sparc/getrlimit64.c
new file mode 100644
index 0000000..3a19852
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sparc/getrlimit64.c
@@ -0,0 +1,24 @@ 
+/* Linux getrlimit64 sparc32 implementation (64 bits rlim_t).
+   Copyright (C) 2016 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <shlib-compat.h>
+
+#undef SHLIB_COMPAT
+#define SHLIB_COMPAT(a,b,c) 0
+
+#include <sysdeps/unix/sysv/linux/getrlimit64.c>
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list b/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list
index 6240cd3..0b6095f 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list
@@ -4,8 +4,6 @@  chown		-	chown32		i:sii	__chown		chown
 lchown		-	lchown32	i:sii	__lchown	lchown
 fchown		-	fchown32	i:iii	__fchown	fchown
 
-setrlimit	-	setrlimit	2	__setrlimit	setrlimit
-getrlimit	-	getrlimit	2	__getrlimit	getrlimit
 getegid		-	getegid32	Ei:	__getegid	getegid
 geteuid		-	geteuid32	Ei:	__geteuid	geteuid
 getgid		-	getgid32	Ei:	__getgid	getgid
diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list
index 7ae2541..68af897 100644
--- a/sysdeps/unix/sysv/linux/syscalls.list
+++ b/sysdeps/unix/sysv/linux/syscalls.list
@@ -26,7 +26,6 @@  getpmsg		-	getpmsg		i:ipppp	getpmsg
 getppid		-	getppid		Ei:	__getppid	getppid
 getresuid	-	getresuid	i:ppp	getresuid
 getresgid	-	getresgid	i:ppp	getresgid
-getrlimit	-	ugetrlimit	i:ip	__new_getrlimit __getrlimit getrlimit@@GLIBC_2.2
 getsid		-	getsid		i:i	getsid
 init_module	EXTRA	init_module	5	init_module
 inotify_add_watch	EXTRA	inotify_add_watch	i:isi	inotify_add_watch
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/getrlimit64.c b/sysdeps/unix/sysv/linux/wordsize-64/getrlimit64.c
deleted file mode 100644
index 9feab0e..0000000
--- a/sysdeps/unix/sysv/linux/wordsize-64/getrlimit64.c
+++ /dev/null
@@ -1 +0,0 @@ 
-/* getrlimit64 is the same as getrlimit. */
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/setrlimit64.c b/sysdeps/unix/sysv/linux/wordsize-64/setrlimit64.c
deleted file mode 100644
index 8edcff0..0000000
--- a/sysdeps/unix/sysv/linux/wordsize-64/setrlimit64.c
+++ /dev/null
@@ -1 +0,0 @@ 
-/* setrlimit64 is the same as setrlimit. */
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
index 2eb9419..1cb14ae 100644
--- a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
@@ -8,8 +8,6 @@  statfs		-	statfs		i:sp	__statfs	statfs statfs64
 mmap		-	mmap		b:aniiii __mmap		mmap __mmap64 mmap64
 ftruncate	-	ftruncate	i:ii	__ftruncate	ftruncate ftruncate64 __ftruncate64
 truncate	-	truncate	i:si	truncate	truncate64
-getrlimit	-	getrlimit	i:ip	__getrlimit	getrlimit getrlimit64 __getrlimit64
-setrlimit	-	setrlimit	i:ip	__setrlimit	setrlimit setrlimit64
 readahead	-	readahead	i:iii	__readahead	readahead
 sendfile	-	sendfile	i:iipi	sendfile	sendfile64
 sync_file_range	-	sync_file_range	Ci:iiii	sync_file_range
diff --git a/sysdeps/unix/sysv/linux/x86/bits/typesizes.h b/sysdeps/unix/sysv/linux/x86/bits/typesizes.h
index 5817ef3..1fd90d3 100644
--- a/sysdeps/unix/sysv/linux/x86/bits/typesizes.h
+++ b/sysdeps/unix/sysv/linux/x86/bits/typesizes.h
@@ -81,6 +81,11 @@ 
 
 /* Same for ino_t and ino64_t.  */
 # define __INO_T_MATCHES_INO64_T	1
+
+/* And for __rlim_t and __rlim64_t.  */
+# define __RLIM_T_MATCHES_RLIM64_T	1
+#else
+# define __RLIM_T_MATCHES_RLIM64_T	0
 #endif
 
 /* Number of descriptors that can fit in an `fd_set'.  */