]> mj.ucw.cz Git - libucw.git/commitdiff
useful macro to align pointer p to size s
authorTomas Valla <tom@ucw.cz>
Mon, 17 Jan 2005 19:41:30 +0000 (19:41 +0000)
committerTomas Valla <tom@ucw.cz>
Mon, 17 Jan 2005 19:41:30 +0000 (19:41 +0000)
lib/lib.h

index 80857c9ce3f895ba08eacaff85248813463c40d2..07c66e9e1df5dfd98e95db5ff756eb155066b2b0 100644 (file)
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -22,6 +22,7 @@
 #define OFFSETOF(s, i) ((unsigned int)&((s *)0)->i)
 #define SKIP_BACK(s, i, p) ((s *)((char *)p - OFFSETOF(s, i)))
 #define ALIGN(s, a) (((s)+a-1)&~(a-1))
+#define ALIGN_PTR(p, s) ((typeof(p)) ((addr_int_t)(p) + (s) - (addr_int_t)(p) % (s)))
 #define UNALIGNED_PART(ptr, type) (((long) (ptr)) % sizeof(type))
 
 /* Some other macros */