Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/utils/utils_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ void utils_align_ptr_up_size_down(void **ptr, size_t *size, size_t alignment) {
}

ASSERT(IS_ALIGNED(p, alignment));
ASSERT(IS_ALIGNED(s, alignment));

*ptr = (void *)p;
*size = s;
Expand Down
17 changes: 17 additions & 0 deletions test/utils/utils_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <cstdint>
#include <sys/mman.h>

#include "base.hpp"
Expand Down Expand Up @@ -169,3 +170,19 @@ TEST_F(test, utils_open) {
EXPECT_EQ(utils_file_open(NULL), -1);
EXPECT_EQ(utils_file_open_or_create(NULL), -1);
}

TEST_F(test, utils_align_ptr_up_size_down) {
uintptr_t ptr = 0x4000;
size_t size = 0x8000;
size_t alignment = 0x4000;
utils_align_ptr_up_size_down((void **)&ptr, &size, alignment);
EXPECT_EQ(ptr, 0x4000);
EXPECT_EQ(size, 0x8000);

ptr = 0x4001;
size = 0x8000;
alignment = 0x4000;
utils_align_ptr_up_size_down((void **)&ptr, &size, alignment);
EXPECT_EQ(ptr, 0x8000);
EXPECT_EQ(size, 0x4001);
}
Loading