diff options
author | Richard Henderson <richard.henderson@linaro.org> | 2019-09-23 11:24:12 -0700 |
---|---|---|
committer | Richard Henderson <richard.henderson@linaro.org> | 2019-09-25 10:19:57 -0700 |
commit | 560e36d5a42e04aa2871c01da6d432592151f7e8 (patch) | |
tree | 09df97ef9297281c8c3f4a37f57f6723b2b5fa2e /include | |
parent | c6b716cdc0f993e43b19849df1f1698723132246 (diff) | |
download | qemu-560e36d5a42e04aa2871c01da6d432592151f7e8.zip qemu-560e36d5a42e04aa2871c01da6d432592151f7e8.tar.gz qemu-560e36d5a42e04aa2871c01da6d432592151f7e8.tar.bz2 |
qemu/compiler.h: Add qemu_build_not_reached
Use this as a compile-time assert that a particular
code path is not reachable.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/qemu/compiler.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h index 20780e7..7b93c73 100644 --- a/include/qemu/compiler.h +++ b/include/qemu/compiler.h @@ -221,4 +221,19 @@ #define QEMU_GENERIC9(x, a0, ...) QEMU_GENERIC_IF(x, a0, QEMU_GENERIC8(x, __VA_ARGS__)) #define QEMU_GENERIC10(x, a0, ...) QEMU_GENERIC_IF(x, a0, QEMU_GENERIC9(x, __VA_ARGS__)) +/** + * qemu_build_not_reached() + * + * The compiler, during optimization, is expected to prove that a call + * to this function cannot be reached and remove it. If the compiler + * supports QEMU_ERROR, this will be reported at compile time; otherwise + * this will be reported at link time due to the missing symbol. + */ +#ifdef __OPTIMIZE__ +extern void QEMU_NORETURN QEMU_ERROR("code path is reachable") + qemu_build_not_reached(void); +#else +#define qemu_build_not_reached() g_assert_not_reached() +#endif + #endif /* COMPILER_H */ |