[libc-commits] [PATCH] D159104: [libc] Fix setrlimit/getrlimit on 32-bit systems

Mikhail R. Gadelha via libc-commits libc-commits at lists.llvm.org
Tue Sep 5 14:06:07 PDT 2023


I forgot to mention in the previous message that glibc and musl also
provide rlimit64, so changing rlim_t to always be 64 bit long makes
rlimit64 the same as limit, which simplifies the code.

btw, musl simply does:

#define rlimit64 rlimit
#define rlim64_t rlim_t

while glibc actually defines the types.

Which way do you prefer, to use defines in the headers or to add new
headers (like this PR does)? I'm assuming here that we want to define both
rlim64_t and rlimit64 types.

Em ter., 5 de set. de 2023 às 16:45, Siva Chandra via Phabricator <
reviews at reviews.llvm.org> escreveu:

> sivachandra added a comment.
>
> I think we can define `rlim_t` to be 64-bit type always and add an
> internal type for use with the syscall:
>
>   struct RLimits64 {
>     uint64_t rlim_cur;
>     uint64_t rlim_max;
>   };
>
>   .. getrlimit(... *limits) {
>     RLimits64 limits64;
>     syscall_impl(SYS_prlimit64, ..., &limits64);
>     limits->rlim_cur =
> static_cast<decltype(limits->rlim_cur)>(limits64.rlim_cur);
>     ...
>   }
>
> This way, we ensure that the implementation is overlay mode safe as well.
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D159104/new/
>
> https://reviews.llvm.org/D159104
>
>

-- 

Mikhail R. Gadelha, Ph.D.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230905/d822d719/attachment-0001.html>


More information about the libc-commits mailing list