u-boot/include/linux
Rasmus Villemoes ef0f4e834c build_bug.h: add wrapper for _Static_assert
[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>
2021-07-01 16:34:32 -04:00
..
byteorder
clk clk: at91: add pre-requisite headers for AT91 clock architecture 2020-09-22 11:27:18 +03:00
mtd mtd: spi-nor-core: Add fixups for Cypress s25hl-t/s25hs-t 2021-06-29 19:16:54 +05:30
soc/ti soc: ti: k3-navss-ringacc: Remove unused ring modes 2021-05-12 16:36:38 +05:30
unaligned
usb usb: gadget: add super speed support 2021-01-31 14:08:56 +01:00
apm_bios.h
arm-smccc.h smccc: fix sign bit expansion 2021-01-27 16:58:57 -05:00
asn1.h cmd: add asn1_compiler 2019-12-06 16:44:20 -05:00
asn1_ber_bytecode.h cmd: add asn1_compiler 2019-12-06 16:44:20 -05:00
asn1_decoder.h cmd: add asn1_compiler 2019-12-06 16:44:20 -05:00
bch.h
bitfield.h linux/bitfield.h: Add primitives for manipulating bitfields both in host- and fixed-endian 2020-07-10 11:47:12 +02:00
bitmap.h lib: Import few bitmap functions from Linux 2020-01-20 10:10:28 +05:30
bitops.h log: convert pr_*() to logging 2021-03-01 09:54:11 -05:00
bitrev.h lib: bitrev: Sync with Linux kernel v4.17 2018-09-18 00:01:18 -06:00
bug.h
build_bug.h build_bug.h: add wrapper for _Static_assert 2021-07-01 16:34:32 -04:00
clk-provider.h clk: fixed_rate: add API for directly registering fixed rate clocks 2021-06-11 16:34:52 +05:30
compat.h linux/compat.h: Remove debug() from spin_lock_irqsave() 2020-12-02 16:21:58 -05:00
compiler-clang.h compiler*.h: sync include/linux/compiler*.h with Linux 5.7-rc5 2020-07-01 11:48:05 -04:00
compiler-gcc.h compiler*.h: sync include/linux/compiler*.h with Linux 5.7-rc5 2020-07-01 11:48:05 -04:00
compiler-intel.h compiler*.h: sync include/linux/compiler*.h with Linux 5.7-rc5 2020-07-01 11:48:05 -04:00
compiler.h compiler.h: align the __ADDRESSABLE macro with Linux' version 2021-05-24 14:21:30 -04:00
compiler_attributes.h treewide: Convert macro and uses of __section(foo) to __section("foo") 2021-05-24 14:21:30 -04:00
compiler_types.h compilers: Introduce options for forcing inlining on SPL/TPL 2020-07-01 11:48:05 -04:00
completion.h compat linux: import completion from linux 4.18 2019-04-22 11:55:58 -04:00
const.h linux/const.h: import from kernel 2018-11-20 13:08:15 +01:00
crc7.h
crc32.h
ctype.h
delay.h time: Update mdelay() to delay in one large chunk 2018-12-05 06:01:35 -07:00
dma-direction.h
dma-mapping.h dma-mapping: Add header file for ARCH_DMA_MINALIGN 2020-06-02 13:06:11 -04:00
drm_dp_helper.h
edd.h
err.h linux err: make ERR_PTR/PTR_ERR architecture specific 2019-11-07 18:01:13 -05:00
errno.h
ethtool.h
fb.h
if_ether.h linux/if_ether.h: Add VLAN related macros 2018-10-10 12:28:53 -05:00
immap_qe.h mpc83xx: Introduce ARCH_MPC836* 2019-05-20 13:50:34 +02:00
input.h
intel-smc.h arm: socfpga: smc: Add function to get usercode 2021-04-08 17:29:13 +08:00
io.h include: linux: io: define devm_ioremap on board with ioremap 2019-04-22 11:55:58 -04:00
ioctl.h
iopoll.h iopoll: Add readl_poll_sleep_timeout 2020-05-11 01:30:49 +05:30
ioport.h
kbuild.h
kconfig.h linux/kconfig.h: create two- and three-argument versions of CONFIG_IS_ENABLED 2020-07-09 12:33:24 +08:00
kernel.h include: kernel.h: define SSIZE_MAX 2020-08-24 16:37:53 +02:00
libfdt.h libfdt: split fdt_region declarations out to <fdt_region.h> 2020-04-26 14:24:08 -06:00
libfdt_env.h fdt: Add INT32_MAX to kernel.h for libfdt 2019-11-04 18:15:32 -07:00
linkage.h
linux_string.h
list.h list: import list_first_entry_or_null() 2019-11-07 00:24:59 +01:00
list_sort.h
log2.h
lzo.h
math64.h
mbus.h
mc146818rtc.h
mdio.h linux/mdio.h: Sync with Linux kernel v4.17 2018-10-09 14:18:12 -05:00
mii.h common: Move mii_init() function out of common.h 2019-12-02 18:23:13 -05:00
netdevice.h
oid_registry.h lib: add oid registry utility 2019-12-06 16:44:20 -05:00
poison.h
posix_types.h
printk.h log: convert pr_*() to logging 2021-03-01 09:54:11 -05:00
psci.h psci: add features/reset2 support 2021-04-20 07:31:12 -04:00
rational.h lib: rational: copy the rational fraction lib routines from Linux 2021-06-11 16:34:52 +05:30
rbtree.h
rbtree_augmented.h
screen_info.h
serial_reg.h
sizes.h linux/sizes.h: sync from kernel 2018-11-20 13:08:15 +01:00
stat.h
stddef.h
string.h lib: string: Implement strlcat 2021-04-12 17:44:55 -04:00
stringify.h
time.h linux/time.h: include vsprintf.h 2019-12-06 16:44:19 -05:00
typecheck.h
types.h common: Move type declarations to linux/types.h 2020-01-17 13:27:25 -05:00
utf.h usb: gadget: move utf8_to_utf16le to header file 2021-01-31 14:08:56 +01:00
xxhash.h lib: Add xxhash support 2019-05-05 08:48:50 -04:00
zstd.h lib: add Zstandard decompression support 2019-05-05 08:48:50 -04:00