utils: Add BIT_32 and BIT_64 macros
authorYann Gautier <[email protected]>
Thu, 14 Jun 2018 11:28:31 +0000 (13:28 +0200)
committerYann Gautier <[email protected]>
Thu, 14 Jun 2018 16:35:38 +0000 (18:35 +0200)
When applying some MISRA rules, lots of issues are raised with BIT macro
on AARCH32, and cast on uint32_t would be required (Rule 10.3).
The macros BIT_32 and BIT_64 are then created for 32bit and 64bit.
Then the BIT macro defaults on BIT_64 on AARCH64,
and on BIT_32 on AARCH32.

Signed-off-by: Yann Gautier <[email protected]>
include/lib/utils_def.h

index 2975103f5e14629b598897c52eecc2f9cd4458a1..7335103b1b1521931535a4d27e6e4ade7cf02997 100644 (file)
 
 #define SIZE_FROM_LOG2_WORDS(n)                (4 << (n))
 
-#define BIT(nr)                                (ULL(1) << (nr))
+#define BIT_32(nr)                     (U(1) << (nr))
+#define BIT_64(nr)                     (ULL(1) << (nr))
+
+#ifdef AARCH32
+#define BIT                            BIT_32
+#else
+#define BIT                            BIT_64
+#endif
 
 /*
  * Create a contiguous bitmask starting at bit position @l and ending at