Skip to content

Commit aa0d8b3

Browse files
author
John Wellbelove
committed
Merge branch 'development' of https://github.com/ETLCPP/etl into development
# Conflicts: # zephyr/module.yml
2 parents 99d899c + 6ed64f7 commit aa0d8b3

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

include/etl/alignment.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ namespace etl
8888
//*****************************************************************************
8989
/// Check that 'p' has 'required_alignment'.
9090
//*****************************************************************************
91-
inline bool is_aligned(void* p, size_t required_alignment)
91+
inline bool is_aligned(const void* p, size_t required_alignment)
9292
{
9393
uintptr_t address = reinterpret_cast<uintptr_t>(p);
9494
return (address % required_alignment) == 0U;
@@ -98,7 +98,7 @@ namespace etl
9898
/// Check that 'p' has 'Alignment'.
9999
//*****************************************************************************
100100
template <size_t Alignment>
101-
bool is_aligned(void* p)
101+
bool is_aligned(const void* p)
102102
{
103103
uintptr_t address = reinterpret_cast<uintptr_t>(p);
104104
return (address % Alignment) == 0U;
@@ -108,7 +108,7 @@ namespace etl
108108
/// Check that 'p' has the alignment of 'T'.
109109
//*****************************************************************************
110110
template <typename T>
111-
bool is_aligned(void* p)
111+
bool is_aligned(const void* p)
112112
{
113113
return is_aligned<etl::alignment_of<T>::value>(p);
114114
}

test/test_alignment.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,23 @@ namespace
161161
CHECK_FALSE(etl::is_aligned<uint32_t>(p));
162162
}
163163

164+
//*************************************************************************
165+
TEST(test_is_aligned_tests_const)
166+
{
167+
alignas(uint32_t) const char buffer[2U * sizeof(uint32_t)] = {0, 1};
168+
169+
const char* p = buffer;
170+
171+
CHECK_TRUE(etl::is_aligned(p, std::alignment_of<const uint32_t>()));
172+
CHECK_TRUE(etl::is_aligned<alignof(const uint32_t)>(p));
173+
CHECK_TRUE(etl::is_aligned<const uint32_t>(p));
174+
175+
++p;
176+
CHECK_FALSE(etl::is_aligned(p, std::alignment_of<const uint32_t>()));
177+
CHECK_FALSE(etl::is_aligned<alignof(const uint32_t)>(p));
178+
CHECK_FALSE(etl::is_aligned<const uint32_t>(p));
179+
}
180+
164181
//*************************************************************************
165182
TEST(test_type_with_alignment)
166183
{

zephyr/module.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
name: etl
22
build:
3+
cmake-ext: true
4+
kconfig-ext: true
35
cmake: zephyr
46
kconfig: zephyr/Kconfig

0 commit comments

Comments
 (0)