X-Git-Url: https://git.saurik.com/apple/libc.git/blobdiff_plain/3d9156a7a519a5e3aa1b92e9d9d4b991f1aed7ff..refs/heads/master:/gen/FreeBSD/assert.c?ds=sidebyside diff --git a/gen/FreeBSD/assert.c b/gen/FreeBSD/assert.c index f14e39c..0d4c06e 100644 --- a/gen/FreeBSD/assert.c +++ b/gen/FreeBSD/assert.c @@ -10,10 +10,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. @@ -35,26 +31,68 @@ static char sccsid[] = "@(#)assert.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ #include -__FBSDID("$FreeBSD: src/lib/libc/gen/assert.c,v 1.7 2002/02/01 00:57:29 obrien Exp $"); +__FBSDID("$FreeBSD: src/lib/libc/gen/assert.c,v 1.8 2007/01/09 00:27:53 imp Exp $"); #include -#include #include +#include +#if __has_include() +#include +#else +#define CRGetCrashLogMessage() NULL +#define CRSetCrashLogMessage(...) +#endif +#include "_simple.h" void -__assert(func, file, line, failedexpr) +__assert_rtn(func, file, line, failedexpr) const char *func, *file; int line; const char *failedexpr; { - if (func == NULL) - (void)fprintf(stderr, + if (func == (const char *)-1L) { + /* 8462256: special case to replace __eprintf */ + _simple_dprintf(STDERR_FILENO, + "%s:%d: failed assertion `%s'\n", file, line, failedexpr); + if (!CRGetCrashLogMessage()) { + _SIMPLE_STRING s = _simple_salloc(); + if (s) { + _simple_sprintf(s, + "%s:%d: failed assertion `%s'\n", + file, line, failedexpr); + CRSetCrashLogMessage(_simple_string(s)); + } else + CRSetCrashLogMessage(failedexpr); + } + } else if (func == NULL) { + _simple_dprintf(STDERR_FILENO, "Assertion failed: (%s), file %s, line %d.\n", failedexpr, file, line); - else - (void)fprintf(stderr, + if (!CRGetCrashLogMessage()) { + _SIMPLE_STRING s = _simple_salloc(); + if (s) { + _simple_sprintf(s, + "Assertion failed: (%s), file %s, line %d.\n", + failedexpr, file, line); + CRSetCrashLogMessage(_simple_string(s)); + } else + CRSetCrashLogMessage(failedexpr); + } + } else { + _simple_dprintf(STDERR_FILENO, "Assertion failed: (%s), function %s, file %s, line %d.\n", failedexpr, func, file, line); + if (!CRGetCrashLogMessage()) { + _SIMPLE_STRING s = _simple_salloc(); + if (s) { + _simple_sprintf(s, + "Assertion failed: (%s), function %s, file %s, line %d.\n", + failedexpr, func, file, line); + CRSetCrashLogMessage(_simple_string(s)); + } else + CRSetCrashLogMessage(failedexpr); + } + } abort(); /* NOTREACHED */ }