diff options
| author | Michael Ellerman <mpe@ellerman.id.au> | 2025-03-16 12:02:46 +1100 |
|---|---|---|
| committer | Michael Ellerman <mpe@ellerman.id.au> | 2025-03-16 12:02:46 +1100 |
| commit | ff443fb402e95f5095dde3c64f7c3249d7c6f993 (patch) | |
| tree | fac700d27838ff41a7308dc217551253a1e2b0df /include/linux/compiler.h | |
| parent | 772ba9b5bd2701a9967c084b66ff1daaee0367eb (diff) | |
| parent | eff2eb592efd73f00590d578c3d6021f604df62c (diff) | |
| download | lwn-ff443fb402e95f5095dde3c64f7c3249d7c6f993.tar.gz lwn-ff443fb402e95f5095dde3c64f7c3249d7c6f993.zip | |
Merge branch 'fixes' into topic/cxl
Merge our fixes branch to bring in the changes to the CXL documentation that
the CXL removal patch depends on.
Diffstat (limited to 'include/linux/compiler.h')
| -rw-r--r-- | include/linux/compiler.h | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/include/linux/compiler.h b/include/linux/compiler.h index b087de2f3e94..200fd3c5bc70 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -191,6 +191,25 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, __v; \ }) +#ifdef __CHECKER__ +#define __BUILD_BUG_ON_ZERO_MSG(e, msg) (0) +#else /* __CHECKER__ */ +#define __BUILD_BUG_ON_ZERO_MSG(e, msg) ((int)sizeof(struct {_Static_assert(!(e), msg);})) +#endif /* __CHECKER__ */ + +/* &a[0] degrades to a pointer: a different type from an array */ +#define __is_array(a) (!__same_type((a), &(a)[0])) +#define __must_be_array(a) __BUILD_BUG_ON_ZERO_MSG(!__is_array(a), \ + "must be array") + +#define __is_byte_array(a) (__is_array(a) && sizeof((a)[0]) == 1) +#define __must_be_byte_array(a) __BUILD_BUG_ON_ZERO_MSG(!__is_byte_array(a), \ + "must be byte array") + +/* Require C Strings (i.e. NUL-terminated) lack the "nonstring" attribute. */ +#define __must_be_cstr(p) \ + __BUILD_BUG_ON_ZERO_MSG(__annotated(p, nonstring), "must be cstr (NUL-terminated)") + #endif /* __KERNEL__ */ /** @@ -231,19 +250,6 @@ static inline void *offset_to_ptr(const int *off) #define __ADDRESSABLE_ASM_STR(sym) __stringify(__ADDRESSABLE_ASM(sym)) -#ifdef __CHECKER__ -#define __BUILD_BUG_ON_ZERO_MSG(e, msg) (0) -#else /* __CHECKER__ */ -#define __BUILD_BUG_ON_ZERO_MSG(e, msg) ((int)sizeof(struct {_Static_assert(!(e), msg);})) -#endif /* __CHECKER__ */ - -/* &a[0] degrades to a pointer: a different type from an array */ -#define __must_be_array(a) __BUILD_BUG_ON_ZERO_MSG(__same_type((a), &(a)[0]), "must be array") - -/* Require C Strings (i.e. NUL-terminated) lack the "nonstring" attribute. */ -#define __must_be_cstr(p) \ - __BUILD_BUG_ON_ZERO_MSG(__annotated(p, nonstring), "must be cstr (NUL-terminated)") - /* * This returns a constant expression while determining if an argument is * a constant expression, most importantly without evaluating the argument. |
