sys/util.h: Add IS_ALIGNED macro

Added IS_ALIGNED macro to check if a pointer is aligned to
a given alignment. Additionally, removed a macro with a
conflicting name in drivers/crypto_intel.

Signed-off-by: Yonatan Schachter <yonatan.schachter@gmail.com>
This commit is contained in:
Yonatan Schachter 2023-12-20 01:13:17 +02:00 committed by Alberto Escolar
parent 7206737450
commit 4ef0e1221d
2 changed files with 6 additions and 1 deletions

View file

@ -8,6 +8,7 @@
#define ZEPHYR_DRIVERS_CRYPTO_CRYPTO_INTEL_SHA_PRIV_H_
#include <zephyr/kernel.h>
#include <zephyr/sys/util.h>
#include "crypto_intel_sha_registers.h"
#define SHA_HASH_DATA_BLOCK_LEN (64)
@ -30,7 +31,6 @@
#define SHA_MAX_SESSIONS 8
#define IS_ALIGNED(address, alignment) (((uintptr_t)(address)) % (alignment) == 0)
#define BYTE_SWAP32(x) \
(((x >> 24) & 0x000000FF) | ((x << 24) & 0xFF000000) | ((x >> 8) & 0x0000FF00) | \
((x << 8) & 0x00FF0000))

View file

@ -282,6 +282,11 @@ extern "C" {
#define CONCAT(...) \
UTIL_CAT(_CONCAT_, NUM_VA_ARGS_LESS_1(__VA_ARGS__))(__VA_ARGS__)
/**
* @brief Check if @p ptr is aligned to @p align alignment
*/
#define IS_ALIGNED(ptr, align) (((uintptr_t)(ptr)) % (align) == 0)
/**
* @brief Value of @p x rounded up to the next multiple of @p align.
*/