From: Tomas Valla Date: Mon, 17 Jan 2005 19:41:30 +0000 (+0000) Subject: useful macro to align pointer p to size s X-Git-Tag: holmes-import~839 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=d25c429c8d9d8a27badca482be4ea33c525200e2;p=libucw.git useful macro to align pointer p to size s --- diff --git a/lib/lib.h b/lib/lib.h index 80857c9c..07c66e9e 100644 --- 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 */