From 4a71fb58e067d3dc00fe1c29927f945bd34be49a Mon Sep 17 00:00:00 2001 From: asterix Date: Thu, 5 Jan 2012 17:25:53 +0000 Subject: [PATCH] Add IS_ALIGNED macro to test alignment of a pointer git-svn-id: https://src.develer.com/svnoss/bertos/trunk@5214 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/cfg/macros.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bertos/cfg/macros.h b/bertos/cfg/macros.h index 6c9b63ef..ff682fe2 100644 --- a/bertos/cfg/macros.h +++ b/bertos/cfg/macros.h @@ -250,6 +250,9 @@ /** Check if \a x is an integer power of 2. */ #define IS_POW2(x) (!(bool)((x) & ((x)-1))) +/** Check if \a x is aligned to \a byte_count bytes */ +#define IS_ALIGNED(x, byte_count) ((uintptr_t)(const void *)(x) % (byte_count) == 0) + /** Calculate a compile-time log2 for a uint8_t */ #define UINT8_LOG2(x) \ ((x) < 2 ? 0 : \ -- 2.25.1