Merge branch 'development' of https://github.com/ETLCPP/etl into development

# Conflicts:
#	zephyr/module.yml
This commit is contained in:
John Wellbelove 2025-04-30 12:23:56 +01:00
commit aa0d8b322c
3 changed files with 22 additions and 3 deletions

View File

@ -88,7 +88,7 @@ namespace etl
//*****************************************************************************
/// Check that 'p' has 'required_alignment'.
//*****************************************************************************
inline bool is_aligned(void* p, size_t required_alignment)
inline bool is_aligned(const void* p, size_t required_alignment)
{
uintptr_t address = reinterpret_cast<uintptr_t>(p);
return (address % required_alignment) == 0U;
@ -98,7 +98,7 @@ namespace etl
/// Check that 'p' has 'Alignment'.
//*****************************************************************************
template <size_t Alignment>
bool is_aligned(void* p)
bool is_aligned(const void* p)
{
uintptr_t address = reinterpret_cast<uintptr_t>(p);
return (address % Alignment) == 0U;
@ -108,7 +108,7 @@ namespace etl
/// Check that 'p' has the alignment of 'T'.
//*****************************************************************************
template <typename T>
bool is_aligned(void* p)
bool is_aligned(const void* p)
{
return is_aligned<etl::alignment_of<T>::value>(p);
}

View File

@ -161,6 +161,23 @@ namespace
CHECK_FALSE(etl::is_aligned<uint32_t>(p));
}
//*************************************************************************
TEST(test_is_aligned_tests_const)
{
alignas(uint32_t) const char buffer[2U * sizeof(uint32_t)] = {0, 1};
const char* p = buffer;
CHECK_TRUE(etl::is_aligned(p, std::alignment_of<const uint32_t>()));
CHECK_TRUE(etl::is_aligned<alignof(const uint32_t)>(p));
CHECK_TRUE(etl::is_aligned<const uint32_t>(p));
++p;
CHECK_FALSE(etl::is_aligned(p, std::alignment_of<const uint32_t>()));
CHECK_FALSE(etl::is_aligned<alignof(const uint32_t)>(p));
CHECK_FALSE(etl::is_aligned<const uint32_t>(p));
}
//*************************************************************************
TEST(test_type_with_alignment)
{

View File

@ -1,4 +1,6 @@
name: etl
build:
cmake-ext: true
kconfig-ext: true
cmake: zephyr
kconfig: zephyr/Kconfig