aboutsummaryrefslogtreecommitdiffstats
path: root/usr
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2006-06-25 15:03:28 -0700
committerH. Peter Anvin <hpa@zytor.com>2006-06-25 15:03:28 -0700
commit0ba34a10b095d25601dacd540420a97b71278a28 (patch)
treeae702b23881bb30a9729b98ab18fe0216ea2f53e /usr
parentf41b3ae4c4e37faa1f1eecf9599f8842813d0297 (diff)
downloadlinux-2.6-klibc-0ba34a10b095d25601dacd540420a97b71278a28.tar.gz
[klibc] __assert_fail() is a __noreturn function
__assert_fail() never returns, and telling that to the compiler can sometimes generate better code. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'usr')
-rw-r--r--usr/include/assert.h4
-rw-r--r--usr/klibc/assert.c3
2 files changed, 5 insertions, 2 deletions
diff --git a/usr/include/assert.h b/usr/include/assert.h
index ec74037c547d11..d89e082a4ca924 100644
--- a/usr/include/assert.h
+++ b/usr/include/assert.h
@@ -5,13 +5,15 @@
#ifndef _ASSERT_H
#define _ASSERT_H
+#include <klibc/compiler.h>
+
#ifdef NDEBUG
#define assert(x) ((void)(x))
#else
-extern void __assert_fail(const char *, const char *, unsigned int);
+extern __noreturn __assert_fail(const char *, const char *, unsigned int);
#define assert(x) ((x) ? (void)0 : __assert_fail(#x, __FILE__, __LINE__))
diff --git a/usr/klibc/assert.c b/usr/klibc/assert.c
index b922416cf15ee8..cca4129bea11ae 100644
--- a/usr/klibc/assert.c
+++ b/usr/klibc/assert.c
@@ -5,8 +5,9 @@
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
+#include <klibc/compiler.h>
-void __assert_fail(const char *expr, const char *file, unsigned int line)
+__noreturn __assert_fail(const char *expr, const char *file, unsigned int line)
{
printf("Assertion %s failed, file %s, line %u\n", expr, file, line);
abort();