diff options
| author | Joseph Huber <huberjn@outlook.com> | 2025-07-02 12:29:01 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-02 12:29:01 -0500 |
| commit | 50f40a5327ad9f8a4a57bb2bf7679f489f86b726 (patch) | |
| tree | 45b71a96de2e5da59e4003772bf50d0009893b06 /libc/test/integration/src/stdlib/gpu/aligned_alloc.cpp | |
| parent | e9be5286e14e2c290232e6dd6e04c7f5e9410885 (diff) | |
[libc] Fix internal alignment in allcoator (#146738)
Summary:
The allocator interface is supposed to have 16 byte alignment (to keep
it consistent with the CPU allocator. We could probably drop this to 8
if desires.) But this was not enforced because the number of bytes used
for the bitfield sometimes resulted in alignment of 8 instead of 16.
Explicitly align the number of bytes to be a multiple of 16 even if
unused.
Diffstat (limited to 'libc/test/integration/src/stdlib/gpu/aligned_alloc.cpp')
| -rw-r--r-- | libc/test/integration/src/stdlib/gpu/aligned_alloc.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libc/test/integration/src/stdlib/gpu/aligned_alloc.cpp b/libc/test/integration/src/stdlib/gpu/aligned_alloc.cpp index b966e6953cc2..6e00eb86c680 100644 --- a/libc/test/integration/src/stdlib/gpu/aligned_alloc.cpp +++ b/libc/test/integration/src/stdlib/gpu/aligned_alloc.cpp @@ -10,7 +10,7 @@ TEST_MAIN(int, char **, char **) { // aligned_alloc with valid alignment and size void *ptr = LIBC_NAMESPACE::aligned_alloc(32, 16); EXPECT_NE(ptr, nullptr); - EXPECT_EQ(__builtin_is_aligned(ptr, 32), 0U); + EXPECT_TRUE(__builtin_is_aligned(ptr, 32)); LIBC_NAMESPACE::free(ptr); @@ -23,7 +23,7 @@ TEST_MAIN(int, char **, char **) { void *div = LIBC_NAMESPACE::aligned_alloc(alignment, (gpu::get_thread_id() + 1) * 4); EXPECT_NE(div, nullptr); - EXPECT_EQ(__builtin_is_aligned(div, alignment), 0U); + EXPECT_TRUE(__builtin_is_aligned(div, alignment)); return 0; } |
