From: Richard Henderson Date: Sat, 22 Oct 2022 11:34:12 +0000 (+1000) Subject: include/qemu/osdep: Add qemu_build_assert X-Git-Tag: v7.2.0-rc0~38^2~42 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d44e3737f937c0d0da1ad18d7b48bfc3ed885e1a;p=thirdparty%2Fqemu.git include/qemu/osdep: Add qemu_build_assert This differs from assert, in that with optimization enabled it triggers at build-time. It differs from QEMU_BUILD_BUG_ON, aka _Static_assert, in that it is sensitive to control flow and is subject to dead-code elimination. Acked-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index b1c161c035a..2276094729a 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -186,6 +186,14 @@ void QEMU_ERROR("code path is reachable") #define qemu_build_not_reached() g_assert_not_reached() #endif +/** + * qemu_build_assert() + * + * The compiler, during optimization, is expected to prove that the + * assertion is true. + */ +#define qemu_build_assert(test) while (!(test)) qemu_build_not_reached() + /* * According to waitpid man page: * WCOREDUMP