From 89fe355ad00d49aa0a8514a76dfd0745d29cfd09 Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Thu, 11 Feb 2010 09:03:51 +0300 Subject: [PATCH] nasmlib.h: Introduce ALIGN helpers Signed-off-by: Cyrill Gorcunov --- nasmlib.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nasmlib.h b/nasmlib.h index 372095c7..793fccd9 100644 --- a/nasmlib.h +++ b/nasmlib.h @@ -255,6 +255,13 @@ void standard_extension(char *inname, char *outname, char *extension); pos = n, n = (n ? n->next : NULL)) /* + * Power of 2 align helpers + */ +#define ALIGN_MASK(v, mask) (((v) + (mask)) & ~(mask)) +#define ALIGN(v, a) ALIGN_MASK(v, (a) - 1) +#define IS_ALIGNED(v, a) (((v) & ((a) - 1)) == 0) + +/* * some handy macros that will probably be of use in more than one * output format: convert integers into little-endian byte packed * format in memory -- 2.11.4.GIT