HomeFreeBSD

LinuxKPI: Use negative bit field size to trigger BUILD_BUG_ON_ZERO

Description

LinuxKPI: Use negative bit field size to trigger BUILD_BUG_ON_ZERO

compile time assertion on non-NULL pointers. Tests conducted show that
_Static_assert, negative array size method and current code does not
handle pointers well enough. Bit field method solves this problem.

This change is derrived from Linux implementation of BUILD_BUG_ON_ZERO.

MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D33674

(cherry picked from commit 64dab63f3b3b6c6a1f8a92f43bed0aa28319d627)

Details

Provenance
wulfAuthored on Dec 25 2021, 6:42 PM
Differential Revision
D33674: LinuxKPI: Use negative bit field size to trigger BUILD_BUG_ON_ZERO
Parents
rG2d0694b95350: LinuxKPI: Constantly use _LINUXKPI_ prefix in include guards
Branches
Unknown
Tags
Unknown