From 640d1c456c977711774f0b7f58f1a97e4512fc4b Mon Sep 17 00:00:00 2001 From: Saurabh Mishra Date: Fri, 30 Aug 2024 14:02:06 +0530 Subject: src/include: Introduce a new BIT_FLAG_32(x) macro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduces the BIT_FLAG_32(x) macro to create a 32-bit mask with the designated bit set. This ensures compatibility with the 32-bit 'GEN_PMCON_A' register on 64-bit systems, where 1ul is 64 bits wide and could potentially cause an overflow when shifted beyond 31 bits. Change-Id: I70be1ccba59d25af2ba85a2014232072abf2f87d Signed-off-by: Saurabh Mishra Reviewed-on: https://review.coreboot.org/c/coreboot/+/84142 Tested-by: build bot (Jenkins) Reviewed-by: Jérémy Compostella Reviewed-by: Paul Menzel Reviewed-by: Subrata Banik Reviewed-by: Pratikkumar V Prajapati --- src/include/types.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/include/types.h b/src/include/types.h index ca4571777c..df5e7ae06d 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -21,6 +21,15 @@ #define BIT(x) (1ul << (x)) #endif +/* + * This macro declares a bit as a 32-bits unsigned integer. The common BIT_32(x) + * macro is already used by some external header file. To avoid any conflicts, we + * use a different name. + */ +#ifndef BIT_FLAG_32 +#define BIT_FLAG_32(x) (1u << (x)) +#endif + #define BITS_PER_BYTE 8 #endif /* __TYPES_H */ -- cgit v1.2.3