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/arch/std.h b/inc/hf/arch/std.h
index d1c8b7a..8c49fd6 100644
--- a/inc/hf/arch/std.h
+++ b/inc/hf/arch/std.h
@@ -21,38 +21,21 @@
#define ctz(x) __builtin_ctz(x)
-/* Compatibility with old compilers */
-#ifndef __has_builtin
-#define __has_builtin(x) 0
-#endif
-
/**
* Check whether the value `v` is aligned to the boundary `a`,
* with `a` power of 2.
*/
-#if __has_builtin(__builtin_is_aligned)
#define is_aligned(v, a) __builtin_is_aligned((v), (a))
-#else
-#define is_aligned(v, a) (((uintptr_t)(v) & ((a) - 1)) == 0)
-#endif
/**
* Align up the value `v` to the boundary `a`, with `a` power of 2.
*/
-#if __has_builtin(__builtin_align_up)
#define align_up(v, a) __builtin_align_up((v), (a))
-#else
-#define align_up(v, a) (((uintptr_t)(v) + ((a) - 1)) & ~((a) - 1))
-#endif
/**
* Align down the value `v` to the boundary `a`, with `a` power of 2.
*/
-#if __has_builtin(__builtin_align_down)
#define align_down(v, a) __builtin_align_down((v), (a))
-#else
-#define align_down(v, a) ((uintptr_t)(v) & ~((a) - 1))
-#endif
#ifndef be16toh
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
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`.