[RFC,v1,05/16] sysdeps/getrlimit: Use __NR_prlimit64 if avaliable

Message ID 6fb166d85bf67a6d49f64064a84156bd10f63225.1561177967.git.alistair.francis@wdc.com
State New
Headers show
Series
  • RISC-V glibc port for the 32-bit
Related show

Commit Message

Alistair Francis June 22, 2019, 4:37 a.m.
If the __NR_prlimit64 syscall is avaliable let's use that instead of
__NR_ugetrlimit as it isn't always avaliable (they aren't avaliable
on RV32).

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>

---
 ChangeLog                           | 1 +
 sysdeps/unix/sysv/linux/getrlimit.c | 4 ++++
 2 files changed, 5 insertions(+)

-- 
2.22.0

Comments

Arnd Bergmann June 23, 2019, 7:47 p.m. | #1
On Sat, Jun 22, 2019 at 6:47 AM Alistair Francis
<alistair.francis@wdc.com> wrote:

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

> index 10c0176619..2917029afd 100644

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

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

> @@ -35,7 +35,11 @@

>  int

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

>  {

> +#ifdef __NR_prlimit64

> +  return INLINE_SYSCALL_CALL (prlimit64, 0, resource, rlim, NULL);

> +#else

>    return INLINE_SYSCALL_CALL (ugetrlimit, resource, rlim);

> +#endif

>  }

>  weak_alias (__new_getrlimit, __getrlimit)

>  hidden_weak (__getrlimit)


This breaks all other 32-bit architectures, since glibc traditionally uses
32-bit limits even on architectures that always supported the 64-bit
interface.

      Arnd
Alistair Francis June 23, 2019, 11:33 p.m. | #2
On Sun, Jun 23, 2019 at 12:48 PM Arnd Bergmann <arnd@arndb.de> wrote:
>

> On Sat, Jun 22, 2019 at 6:47 AM Alistair Francis

> <alistair.francis@wdc.com> wrote:

>

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

> > index 10c0176619..2917029afd 100644

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

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

> > @@ -35,7 +35,11 @@

> >  int

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

> >  {

> > +#ifdef __NR_prlimit64

> > +  return INLINE_SYSCALL_CALL (prlimit64, 0, resource, rlim, NULL);

> > +#else

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

> > +#endif

> >  }

> >  weak_alias (__new_getrlimit, __getrlimit)

> >  hidden_weak (__getrlimit)

>

> This breaks all other 32-bit architectures, since glibc traditionally uses

> 32-bit limits even on architectures that always supported the 64-bit

> interface.


If we just mask out the high bits will that fix the problem?

Alistair

>

>       Arnd

Patch

diff --git a/ChangeLog b/ChangeLog
index 9ed9bea8b1..1f1070ebc3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,7 @@ 
 	* sysdeps/unix/sysv/linux/wait.c: Use __NR_waitid if avaliable.
 	* sysdeps/unix/sysv/linux/waitpid.c: Likewise.
 	* sysdeps/unix/sysv/linux/waitpid_nocancel.c: Likewise.
+	* sysdeps/unix/sysv/linux/getrlimit.c: Use __NR_prlimit64 if avaliable
 
 2019-06-20  Dmitry V. Levin  <ldv@altlinux.org>
 	    Florian Weimer  <fweimer@redhat.com>
diff --git a/sysdeps/unix/sysv/linux/getrlimit.c b/sysdeps/unix/sysv/linux/getrlimit.c
index 10c0176619..2917029afd 100644
--- a/sysdeps/unix/sysv/linux/getrlimit.c
+++ b/sysdeps/unix/sysv/linux/getrlimit.c
@@ -35,7 +35,11 @@ 
 int
 __new_getrlimit (enum __rlimit_resource resource, struct rlimit *rlim)
 {
+#ifdef __NR_prlimit64
+  return INLINE_SYSCALL_CALL (prlimit64, 0, resource, rlim, NULL);
+#else
   return INLINE_SYSCALL_CALL (ugetrlimit, resource, rlim);
+#endif
 }
 weak_alias (__new_getrlimit, __getrlimit)
 hidden_weak (__getrlimit)