From 60efc68c14cb95fe9e150976a8021c58103ff2b2 Mon Sep 17 00:00:00 2001 From: Kedareswara rao Appana Date: Mon, 27 Jul 2015 15:07:13 +0530 Subject: [PATCH] lib: bsp: Add UPPER_32_BITS and LOWER_32_BITS macro's UPPER_32_BITS(x) macro to handle shifts that may be >= the width of the data type. LOWER_32_BITS(x) macro to handle masking of 32-bit data types. Signed-off-by: Kedareswara rao Appana Acked-by: Anirudha Sarangi --- lib/bsp/standalone/src/common/xil_types.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/bsp/standalone/src/common/xil_types.h b/lib/bsp/standalone/src/common/xil_types.h index b9ef3c18..21602ac1 100644 --- a/lib/bsp/standalone/src/common/xil_types.h +++ b/lib/bsp/standalone/src/common/xil_types.h @@ -164,6 +164,22 @@ typedef void (*XInterruptHandler) (void *InstancePtr); */ typedef void (*XExceptionHandler) (void *InstancePtr); +/** + * UPPER_32_BITS - return bits 32-63 of a number + * @n: the number we're accessing + * + * A basic shift-right of a 64- or 32-bit quantity. Use this to suppress + * the "right shift count >= width of type" warning when that quantity is + * 32-bits. + */ +#define UPPER_32_BITS(n) ((u32)(((n) >> 16) >> 16)) + +/** + * LOWER_32_BITS - return bits 0-31 of a number + * @n: the number we're accessing + */ +#define LOWER_32_BITS(n) ((u32)(n)) + /*@}*/