Skip to content

Commit a9a6090

Browse files
committed
[libc] Fix alignment issue for HermeticTestUtils.cpp.
1 parent 303825d commit a9a6090

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

libc/test/UnitTest/HermeticTestUtils.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ int atexit(void (*func)(void));
3333

3434
} // namespace LIBC_NAMESPACE_DECL
3535

36+
extern "C" {
37+
constexpr uint64_t ALIGNMENT = alignof(uintptr_t);
38+
}
39+
3640
namespace {
3741

3842
// Integration tests cannot use the SCUDO standalone allocator as SCUDO pulls
@@ -42,7 +46,7 @@ namespace {
4246
// which just hands out continuous blocks from a statically allocated chunk of
4347
// memory.
4448
static constexpr uint64_t MEMORY_SIZE = 65336;
45-
static uint8_t memory[MEMORY_SIZE];
49+
alignas(ALIGNMENT) static uint8_t memory[MEMORY_SIZE];
4650
static uint8_t *ptr = memory;
4751

4852
} // anonymous namespace
@@ -74,8 +78,6 @@ void *memset(void *ptr, int value, size_t count) {
7478
// This is needed if the test was compiled with '-fno-use-cxa-atexit'.
7579
int atexit(void (*func)(void)) { return LIBC_NAMESPACE::atexit(func); }
7680

77-
constexpr uint64_t ALIGNMENT = alignof(uintptr_t);
78-
7981
void *malloc(size_t s) {
8082
// Keep the bump pointer aligned on an eight byte boundary.
8183
s = ((s + ALIGNMENT - 1) / ALIGNMENT) * ALIGNMENT;

0 commit comments

Comments
 (0)