From 5159ff2cf1eda44bc1b575ced7f82667ebac6beb Mon Sep 17 00:00:00 2001 From: Joerg Sonnenberger Date: Tue, 26 Apr 2005 10:41:57 +0000 Subject: [PATCH 1/1] Correct and improve __diagassert. --- include/assert.h | 6 +++--- lib/libc/gen/assert.c | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/assert.h b/include/assert.h index e4caa298df..1d48d0472d 100644 --- a/include/assert.h +++ b/include/assert.h @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)assert.h 8.2 (Berkeley) 1/21/94 - * $DragonFly: src/include/assert.h,v 1.3 2005/01/06 17:32:44 joerg Exp $ + * $DragonFly: src/include/assert.h,v 1.4 2005/04/26 10:41:57 joerg Exp $ */ /* @@ -57,7 +57,7 @@ #undef _DIAGASSERT #ifdef _DIAGNOSTIC -#define _DIAGASSERT(e) ((e) ? (void)0 : __assert(__FILE__, __LINE__, #e)) +#define _DIAGASSERT(e) ((e) ? (void)0 : __diagassert(__FILE__, __LINE__, __func__, #e)) #else #define _DIAGASSERT(e) ((void)0) #endif @@ -66,5 +66,5 @@ __BEGIN_DECLS void __assert(const char *, int, const char *); -void __diag_assert(const char *, int, const char *); +void __diagassert(const char *, int, const char *, const char *); __END_DECLS diff --git a/lib/libc/gen/assert.c b/lib/libc/gen/assert.c index a765a1c323..88da83ba36 100644 --- a/lib/libc/gen/assert.c +++ b/lib/libc/gen/assert.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)assert.c 8.1 (Berkeley) 6/4/93 - * $DragonFly: src/lib/libc/gen/assert.c,v 1.4 2005/01/06 17:34:25 joerg Exp $ + * $DragonFly: src/lib/libc/gen/assert.c,v 1.5 2005/04/26 10:41:57 joerg Exp $ */ #include @@ -57,8 +57,8 @@ enum { static int diagassert_flags = -1; void -__diagassert(const char *file, const char *line, const char *function, - int failedexpr) +__diagassert(const char *file, int line, const char *function, + const char *failedexpr) { char buf[1024]; @@ -92,7 +92,8 @@ __diagassert(const char *file, const char *line, const char *function, } snprintf(buf, sizeof(buf), - "assertion \"%s\" failed: file \"%s\", line %d"); + "assertion \"%s\" failed: file \"%s\", line %d, function \"%s\"", + failedexpr, file, line, function); if (diagassert_flags & DIAGASSERT_STDERR) fprintf(stderr, "%s: %s\n", getprogname(), buf); if (diagassert_flags & DIAGASSERT_SYSLOG) -- 2.41.0