include: Add a macro to check pointer alignment

Add a new macro, IS_PTR_ALIGNED() that verifies if a pointer is aligned
sufficiently for a particular data type provided as an argument.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This commit is contained in:
Carles Cufi 2021-12-04 12:02:21 +01:00 committed by Carles Cufí
commit 944a02d18a

View file

@ -187,6 +187,9 @@
*/
#define Z_DECL_ALIGN(type) __aligned(__alignof(type)) type
/* Check if a pointer is aligned enough for a particular data type. */
#define IS_PTR_ALIGNED(ptr, type) ((((uintptr_t)ptr) % __alignof(type)) == 0)
/**
* @brief Iterable Sections APIs
* @defgroup iterable_section_apis Iterable Sections APIs