mirror of
https://github.com/ETLCPP/etl.git
synced 2026-10-28 18:07:10 +08:00
Merge branch 'development' of https://github.com/ETLCPP/etl into development
# Conflicts: # zephyr/module.yml
This commit is contained in:
commit
aa0d8b322c
@ -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);
|
||||
}
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
name: etl
|
||||
build:
|
||||
cmake-ext: true
|
||||
kconfig-ext: true
|
||||
cmake: zephyr
|
||||
kconfig: zephyr/Kconfig
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user