summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorzuul <zuul@gerrit.asterisk.org>2016-07-21 15:29:22 -0500
committerGerrit Code Review <gerrit2@gerrit.digium.api>2016-07-21 15:29:22 -0500
commitfbdeb01edff59364aaa795b1c9f317406c6d9c1f (patch)
treef7ede0a5084daee67bbb3fc7e49ed151564aec75 /include
parent3ca6407dab1d40478d656d3e46b1122ee0995037 (diff)
parent8f6e9ffcc6231cfd4ae6c0a8b6e1d11beb59dc58 (diff)
Merge "Add conditional support for noreturn functions."
Diffstat (limited to 'include')
-rw-r--r--include/asterisk/autoconfig.h.in3
-rw-r--r--include/asterisk/compiler.h6
-rw-r--r--include/asterisk/utils.h9
3 files changed, 16 insertions, 2 deletions
diff --git a/include/asterisk/autoconfig.h.in b/include/asterisk/autoconfig.h.in
index 51f0f1462..9d2a84c02 100644
--- a/include/asterisk/autoconfig.h.in
+++ b/include/asterisk/autoconfig.h.in
@@ -102,6 +102,9 @@
/* Define to 1 if your GCC C compiler supports the 'may_alias' attribute. */
#undef HAVE_ATTRIBUTE_may_alias
+/* Define to 1 if your GCC C compiler supports the 'noreturn' attribute. */
+#undef HAVE_ATTRIBUTE_noreturn
+
/* Define to 1 if your GCC C compiler supports the 'pure' attribute. */
#undef HAVE_ATTRIBUTE_pure
diff --git a/include/asterisk/compiler.h b/include/asterisk/compiler.h
index 77b5de40e..6ceaa5f77 100644
--- a/include/asterisk/compiler.h
+++ b/include/asterisk/compiler.h
@@ -77,6 +77,12 @@
#define attribute_may_alias
#endif
+#ifdef HAVE_ATTRIBUTE_noreturn
+#define attribute_noreturn __attribute__((noreturn))
+#else
+#define attribute_noreturn
+#endif
+
/* Some older version of GNU gcc (3.3.5 on OpenBSD 4.3 for example) dont like 'NULL' as sentinel */
#define SENTINEL ((char *)NULL)
diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h
index c7a473732..c311e9cd5 100644
--- a/include/asterisk/utils.h
+++ b/include/asterisk/utils.h
@@ -843,9 +843,14 @@ struct ast_http_digest {
*/
int ast_parse_digest(const char *digest, struct ast_http_digest *d, int request, int pedantic);
+#ifdef DO_CRASH
+#define DO_CRASH_NORETURN attribute_noreturn
+#else
+#define DO_CRASH_NORETURN
+#endif
#ifdef AST_DEVMODE
-void __ast_assert_failed(int condition, const char *condition_str, const char *file, int line, const char *function);
+void DO_CRASH_NORETURN __ast_assert_failed(int condition, const char *condition_str, const char *file, int line, const char *function);
#define ast_assert(a) _ast_assert(a, # a, __FILE__, __LINE__, __PRETTY_FUNCTION__)
static void force_inline _ast_assert(int condition, const char *condition_str, const char *file, int line, const char *function)
{
@@ -864,7 +869,7 @@ static void force_inline _ast_assert(int condition, const char *condition_str, c
*
* \return Nothing
*/
-void ast_do_crash(void);
+void DO_CRASH_NORETURN ast_do_crash(void);
#include "asterisk/strings.h"