feat: exclude fewer files from checkpatch
* `src/arch/aarch64/inc/hf/arch/sve.h`, `inc/hf/dlog.h`,
`inc/hf/panic.h` and `inc/system/sys/cdefs.h` were ignored because
they were triggering the `PREFER_DEFINED_ATTRIBUTE_MACRO` lint. This
lint used to be 3 different lints (`PREFER_ALIGNED`, `PREFER_PACKED`
and `PREFER_PRINTF`) but they have been replaced by a single
`PREFER_DEFINED_ATTRIBUTE_MACRO` lint. By ignoring the correct lint,
we can remove these files from the ignore list.
* `inc/hf/arch/std.h` was ignored because the fallback definition of
`__has_builtin` was ignoring its argument. Remove the fallback
definition, because we don't support older versions of clang anyway.
* `inc/hf/bits.h` was ignored because the `STATIC_ASSERT` macro was
ignoring its argument if `__ASSEMBLY__` was defined. This was intended
to allow the `GET_BIT` macro to be used in assembly files, but it is
not currently used in any assembly files, and if it was, it would not
expand to valid assembly anyway.
Change-Id: I5cb27f4b2113a96711fca74ba32429581d828c11
Signed-off-by: Karl Meakin <karl.meakin@arm.com>
diff --git a/inc/hf/bits.h b/inc/hf/bits.h
index a137b31..cfb534e 100644
--- a/inc/hf/bits.h
+++ b/inc/hf/bits.h
@@ -6,19 +6,6 @@
* https://opensource.org/licenses/BSD-3-Clause.
*/
-#include <stdbool.h>
-#include <stdint.h>
-
-#if defined(__ASSEMBLY__)
-#define STATIC_ASSERT(expr, msg) 0
-#else
-#define STATIC_ASSERT(expr, msg) \
- __extension__({ \
- static_assert(expr, msg); \
- 0; \
- })
-#endif
-
/**
* NOTE: The below macroos use the notation `[hi:lo]` to mean the bits
* from `lo` up-to and including `hi`. This matches the notation used in the
@@ -34,9 +21,12 @@
/**
* Isolate the `n`th bit of `value`.
*/
-#define GET_BIT(value, n) \
- (STATIC_ASSERT((n) < 64, "n out of bounds") + \
- ((value) & (UINT64_C(1) << (n))))
+
+#define GET_BIT(value, n) \
+ __extension__({ \
+ static_assert((n) < 64, "n out of bounds"); \
+ ((value) & (UINT64_C(1) << (n))); \
+ })
/**
* Return true if the `n`th bit of `value` is 1.
@@ -52,11 +42,14 @@
* Return a mask suitable for isolating bits `[hi:lo]` of a 64-bit
* integer.
*/
-#define GET_BITS_MASK(hi, lo) \
- (STATIC_ASSERT((hi) < 64, "hi out of bounds") + \
- STATIC_ASSERT((hi) >= (lo), "hi must be >= lo") + \
- (((~UINT64_C(0)) - (UINT64_C(1) << (lo)) + 1) & \
- (~UINT64_C(0) >> (64 - 1 - (hi)))))
+
+#define GET_BITS_MASK(hi, lo) \
+ __extension__({ \
+ static_assert((hi) < 64, "hi out of bounds"); \
+ static_assert((hi) >= (lo), "hi must be >= lo"); \
+ (((~UINT64_C(0)) - (UINT64_C(1) << (lo)) + 1) & \
+ (~UINT64_C(0) >> (64 - 1 - (hi)))); \
+ })
/**
* Isolate bits `[hi:lo]` of `value`.