summaryrefslogtreecommitdiff
path: root/macros.h
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2017-06-25 17:49:55 +0200
committerRichard Braun <rbraun@sceen.net>2017-06-25 17:49:55 +0200
commit9283065587c674e5f46bccc3406cd128570a14dc (patch)
tree450ea7ea397886a4e1a3219add6c3bdba8e4848a /macros.h
parent73b44d2c58018352ebe4b280431d4cdfd0019c1e (diff)
macros: add comments to power-of-two alignment macros
Diffstat (limited to 'macros.h')
-rw-r--r--macros.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/macros.h b/macros.h
index 04e2046..3b26976 100644
--- a/macros.h
+++ b/macros.h
@@ -54,9 +54,9 @@
#define P2ALIGNED(x, a) (((x) & ((a) - 1)) == 0)
#define ISP2(x) P2ALIGNED(x, x)
-#define P2ALIGN(x, a) ((x) & -(a))
-#define P2ROUND(x, a) (-(-(x) & -(a)))
-#define P2END(x, a) (-(~(x) & -(a)))
+#define P2ALIGN(x, a) ((x) & -(a)) /* decreases if not aligned */
+#define P2ROUND(x, a) (-(-(x) & -(a))) /* increases if not aligned */
+#define P2END(x, a) (-(~(x) & -(a))) /* always increases */
#define structof(ptr, type, member) \
((type *)((char *)(ptr) - offsetof(type, member)))