[libc-commits] [PATCH] D149863: [libc] Maintain proper alignment for the hermetic tests malloc
Siva Chandra via Phabricator via libc-commits
libc-commits at lists.llvm.org
Thu May 4 10:51:56 PDT 2023
sivachandra accepted this revision.
sivachandra added a comment.
This revision is now accepted and ready to land.
Using `alignof(long double)` is the best I think. Feel free to change to it.
================
Comment at: libc/test/UnitTest/HermeticTestUtils.cpp:66
+ // Keep the bump pointer aligned on an eight byte boundary.
+ s = ((s + 8 - 1) / 8) * 8;
void *mem = ptr;
----------------
jhuber6 wrote:
> sivachandra wrote:
> > Is it 8 that we want or is it `alignof(uintptr_t)`?
> Eight is just a good number. I think to be consistent with most implementations of malloc it's `alignof(long double)` or something. But I could change it to use that number since it's clearer to say "We want alignment for at least a 64-bit type"
Nit: If you want to do `long double`, you should use a convenience var:
```
constexpr size_t ALIGNMENT = aligngof(long double);
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D149863/new/
https://reviews.llvm.org/D149863
More information about the libc-commits
mailing list