mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-18 18:59:44 +00:00
ef0f4e834c
[Linux commit 6bab69c65013bed5fce9f101a64a84d0385b3946] BUILD_BUG_ON() is a little annoying, since it cannot be used outside function scope. So one cannot put assertions about the sizeof() a struct next to the struct definition, but has to hide that in some more or less arbitrary function. Since gcc 4.6 (which is now also the required minimum), there is support for the C11 _Static_assert in all C modes, including gnu89. So add a simple wrapper for that. _Static_assert() requires a message argument, which is usually quite redundant (and I believe that bug got fixed at least in newer C++ standards), but we can easily work around that with a little macro magic, making it optional. For example, adding static_assert(sizeof(struct printf_spec) == 8); in vsprintf.c and modifying that struct to violate it, one gets ./include/linux/build_bug.h:78:41: error: static assertion failed: "sizeof(struct printf_spec) == 8" #define __static_assert(expr, msg, ...) _Static_assert(expr, "" msg "") godbolt.org suggests that _Static_assert() has been support by clang since at least 3.0.0. Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk> Reviewed-by: Simon Glass <sjg@chromium.org> |
||
---|---|---|
.. | ||
byteorder | ||
clk | ||
mtd | ||
soc/ti | ||
unaligned | ||
usb | ||
apm_bios.h | ||
arm-smccc.h | ||
asn1.h | ||
asn1_ber_bytecode.h | ||
asn1_decoder.h | ||
bch.h | ||
bitfield.h | ||
bitmap.h | ||
bitops.h | ||
bitrev.h | ||
bug.h | ||
build_bug.h | ||
clk-provider.h | ||
compat.h | ||
compiler-clang.h | ||
compiler-gcc.h | ||
compiler-intel.h | ||
compiler.h | ||
compiler_attributes.h | ||
compiler_types.h | ||
completion.h | ||
const.h | ||
crc7.h | ||
crc32.h | ||
ctype.h | ||
delay.h | ||
dma-direction.h | ||
dma-mapping.h | ||
drm_dp_helper.h | ||
edd.h | ||
err.h | ||
errno.h | ||
ethtool.h | ||
fb.h | ||
if_ether.h | ||
immap_qe.h | ||
input.h | ||
intel-smc.h | ||
io.h | ||
ioctl.h | ||
iopoll.h | ||
ioport.h | ||
kbuild.h | ||
kconfig.h | ||
kernel.h | ||
libfdt.h | ||
libfdt_env.h | ||
linkage.h | ||
linux_string.h | ||
list.h | ||
list_sort.h | ||
log2.h | ||
lzo.h | ||
math64.h | ||
mbus.h | ||
mc146818rtc.h | ||
mdio.h | ||
mii.h | ||
netdevice.h | ||
oid_registry.h | ||
poison.h | ||
posix_types.h | ||
printk.h | ||
psci.h | ||
rational.h | ||
rbtree.h | ||
rbtree_augmented.h | ||
screen_info.h | ||
serial_reg.h | ||
sizes.h | ||
stat.h | ||
stddef.h | ||
string.h | ||
stringify.h | ||
time.h | ||
typecheck.h | ||
types.h | ||
utf.h | ||
xxhash.h | ||
zstd.h |