projects
/
bertos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add IS_ALIGNED macro to test alignment of a pointer
[bertos.git]
/
bertos
/
cfg
/
macros.h
diff --git
a/bertos/cfg/macros.h
b/bertos/cfg/macros.h
index 6c9b63ef0001b0877a0086a162f83b312cc7f10d..ff682fe214d3cdb22f2e4ab5242ba07ada65e510 100644
(file)
--- 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 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 : \
/** Calculate a compile-time log2 for a uint8_t */
#define UINT8_LOG2(x) \
((x) < 2 ? 0 : \