This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC v2 09/20] sysdeps/getrlimit: Use prlimit64 if avaliable


On Tue, Jun 25, 2019 at 2:10 PM Florian Weimer <fweimer@redhat.com> wrote:
>
> * Alistair Francis:
>
> > On Tue, Jun 25, 2019 at 4:11 AM Florian Weimer <fweimer@redhat.com> wrote:
> >>
> >> * Alistair Francis:
> >>
> >> > If the prlimit64 syscall is avaliable let's use that instead of
> >> > ugetrlimit as it isn't always avaliable (they aren't avaliable
> >> > on RV32).
> >>
> >> > diff --git a/sysdeps/unix/sysv/linux/getrlimit.c b/sysdeps/unix/sysv/linux/getrlimit.c
> >> > index 10c0176619..741b065b25 100644
> >> > --- a/sysdeps/unix/sysv/linux/getrlimit.c
> >> > +++ b/sysdeps/unix/sysv/linux/getrlimit.c
> >> > @@ -35,7 +35,16 @@
> >> >  int
> >> >  __new_getrlimit (enum __rlimit_resource resource, struct rlimit *rlim)
> >> >  {
> >> > +#ifdef __ASSUME_RLIM64_SYSCALLS
> >> > +  return INLINE_SYSCALL_CALL (prlimit64, 0, resource, rlim, NULL);
> >> > +#else
> >> > +# ifdef __NR_prlimit64
> >> > +  long int ret = INLINE_SYSCALL_CALL (prlimit64, 0, resource, rlim, NULL);
> >> > +  if (ret == 0 || errno != ENOSYS)
> >> > +    return ret;
> >> > +# endif
> >> >    return INLINE_SYSCALL_CALL (ugetrlimit, resource, rlim);
> >> > +#endif
> >>
> >> I think that's not correct because with this change, defining
> >> __ASSUME_RLIM64_SYSCALLS changes the struct expected by getrlimit.
> >
> > I'm not clear what you mean here, why is the struct expected by
> > getrlimit different?
>
> On current 32-bit architectures, ugetrlimit expects a 32-bit rlim_t
> type.  But prlimit64 assumes a 64-bit rlim_t type.  Maybe this goes
> wrong in either case, just by the existence of the prlimit64 system call
> number, whether or not __ASSUME_RLIM64_SYSCALLS is defined.

Ah, I see what you mean now. Yes they do end up being different rlimit structs.

I also just realised that I don't need this patch, as
__RLIM_T_MATCHES_RLIM64_T is now defined, I'm going to drop this
patch.


Alistair

>
> But maybe I'm missing something?
>
> Thanks,
> Florian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]