diff options
| author | kleink <kleink@NetBSD.org> | 2000-12-19 14:32:59 +0000 |
|---|---|---|
| committer | kleink <kleink@NetBSD.org> | 2000-12-19 14:32:59 +0000 |
| commit | f02540ff10b332b8ef5ad9e89ded894e39d68bec (patch) | |
| tree | 775e107e82bd688c68133f74df9dd03a49eb1db5 /lib/libc | |
| parent | d615c85a36834952f43c49ca587cb3d530cd8189 (diff) | |
C99: Print the name of the function enclosing the assertion, if possible.
Diffstat (limited to 'lib/libc')
| -rw-r--r-- | lib/libc/gen/assert.c | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/lib/libc/gen/assert.c b/lib/libc/gen/assert.c index b757de05aa1..ff250c82a35 100644 --- a/lib/libc/gen/assert.c +++ b/lib/libc/gen/assert.c @@ -1,4 +1,4 @@ -/* $NetBSD: assert.c,v 1.9 2000/12/10 03:59:00 christos Exp $ */ +/* $NetBSD: assert.c,v 1.10 2000/12/19 14:32:59 kleink Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)assert.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: assert.c,v 1.9 2000/12/10 03:59:00 christos Exp $"); +__RCSID("$NetBSD: assert.c,v 1.10 2000/12/19 14:32:59 kleink Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -52,6 +52,21 @@ __RCSID("$NetBSD: assert.c,v 1.9 2000/12/10 03:59:00 christos Exp $"); extern char *__progname; void +__assert13(file, line, function, failedexpr) + const char *file, *function, *failedexpr; + int line; +{ + (void)fprintf(stderr, + "assertion \"%s\" failed: file \"%s\", line %d%s%s%s\n", + failedexpr, file, line, + function ? ", function \"" : "", + function ? function : "", + function ? "\"" : ""); + abort(); + /* NOTREACHED */ +} + +void __assert(file, line, failedexpr) const char *file, *failedexpr; int line; @@ -64,6 +79,29 @@ __assert(file, line, failedexpr) } void +__diagassert13(file, line, function, failedexpr) + const char *file, *function, *failedexpr; + int line; +{ + /* + * XXX: check $DIAGASSERT here, and do user-defined actions + */ + (void)fprintf(stderr, + "%s: assertion \"%s\" failed: file \"%s\", line %d%s%s\n", + __progname, failedexpr, file, line, + function ? ", function \"" : "", + function ? function : "", + function ? "\"" : ""); + syslog(LOG_DEBUG|LOG_USER, + "assertion \"%s\" failed: file \"%s\", line %d%s%s%s", + failedexpr, file, line, + function ? ", function \"" : "", + function ? function : "", + function ? "\"" : ""); + return; +} + +void __diagassert(file, line, failedexpr) const char *file, *failedexpr; int line; |
