From 0c49aa0624c289164b5501a8724b6d9fdbae7f49 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Wed, 16 Aug 2017 17:16:45 -0700 Subject: [PATCH] util: Add a NORETURN macro MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Tapani Pälli Reviewed-by: Ian Romanick --- configure.ac | 1 + meson.build | 4 ++++ src/util/macros.h | 6 ++++++ 3 files changed, 11 insertions(+) diff --git a/configure.ac b/configure.ac index 475155a96e4..a4564d23f4c 100644 --- a/configure.ac +++ b/configure.ac @@ -250,6 +250,7 @@ AX_GCC_FUNC_ATTRIBUTE([visibility]) AX_GCC_FUNC_ATTRIBUTE([warn_unused_result]) AX_GCC_FUNC_ATTRIBUTE([weak]) AX_GCC_FUNC_ATTRIBUTE([alias]) +AX_GCC_FUNC_ATTRIBUTE([noreturn]) AM_CONDITIONAL([GEN_ASM_OFFSETS], test "x$GEN_ASM_OFFSETS" = xyes) diff --git a/meson.build b/meson.build index f227bc3e018..ddc4a44eb6f 100644 --- a/meson.build +++ b/meson.build @@ -479,6 +479,10 @@ if cc.compiles('int foo(void) { return 0; } int bar(void) __attribute__((alias(" name : '__attribute__((alias(...)))') pre_args += '-DHAVE_FUNC_ATTRIBUTE_ALIAS' endif +if cc.compiles('int foo(void) __attribute__((__noreturn__));', + name : '__attribute__((__noreturn__))') + pre_args += '-DHAVE_FUNC_ATTRIBUTE_NORETURN' +endif # TODO: this is very incomplete if ['linux', 'cygwin'].contains(host_machine.system()) diff --git a/src/util/macros.h b/src/util/macros.h index aa36253217c..d6e37053b15 100644 --- a/src/util/macros.h +++ b/src/util/macros.h @@ -171,6 +171,12 @@ do { \ #define ATTRIBUTE_RETURNS_NONNULL #endif +#ifdef HAVE_FUNC_ATTRIBUTE_NORETURN +#define NORETURN __attribute__((__noreturn__)) +#else +#define NORETURN +#endif + #ifdef __cplusplus /** * Macro function that evaluates to true if T is a trivially -- 2.30.2