[libc-commits] [PATCH] D129543: [libc] Linux threads - Setup TLS area of a new thread and cleanup at exit.

Tue Ly via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Jul 13 02:37:23 PDT 2022

lntue added inline comments.

Comment at: libc/config/linux/app.h:83
+  // The size of the TLS area.
+  uintptr_t size = 0;
sivachandra wrote:
> lntue wrote:
> > Why is this `uintptr_t` but not `size_t`?
> This size value actually comes from the ELF TLS image description. In ELF64 it is a 64-bit value, and in ELF32 it is a 32-bit value. So, capturing it as a `uintptr_t` value will capture it without any potential mix ups.
In the implementation below, all the size computations were done with `size_t`, and then get converted to `uintptr_t` of TLSDescriptor.  Shall we add a static assertion to make sure that it won't silently overflow, i.e. `sizeof(size_t) <= sizeof(uintptr_t)`? At least they are the same for most of our platforms of interest anyway.

  rG LLVM Github Monorepo



More information about the libc-commits mailing list