From: Jammy Zhou Date: Mon, 13 Jul 2015 08:49:42 +0000 (+0800) Subject: drm: fix the ALIGN macro to avoid value clamp X-Git-Tag: libdrm-2.4.63~31 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=90e14d453ae8f08701e10c61264b53a233acfa3c;p=platform%2Fupstream%2Flibdrm.git drm: fix the ALIGN macro to avoid value clamp If the value is 64bit, but the alignment is 32bit type, the high 32bit will be clamped with previous definition Signed-off-by: Jammy Zhou Reviewed-by: Christian König --- diff --git a/util_math.h b/util_math.h index b8de0f8..3bc5f64 100644 --- a/util_math.h +++ b/util_math.h @@ -27,6 +27,7 @@ #define MIN2( A, B ) ( (A)<(B) ? (A) : (B) ) #define MAX2( A, B ) ( (A)>(B) ? (A) : (B) ) -#define ALIGN( value, alignment ) ( ((value) + (alignment) - 1) & ~((alignment) - 1) ) +#define __align_mask(value, mask) (((value) + (mask)) & ~(mask)) +#define ALIGN(value, alignment) __align_mask(value, (typeof(value))((alignment) - 1)) #endif /*_UTIL_MATH_H_*/