]> git.saurik.com Git - apple/libc.git/blob - gen/FreeBSD/assert.c.patch
4297577a380df78115e00b25767bb3362c34fafa
[apple/libc.git] / gen / FreeBSD / assert.c.patch
1 --- assert.c.orig 2010-09-24 10:27:46.000000000 -0700
2 +++ assert.c 2010-09-24 10:37:33.000000000 -0700
3 @@ -34,23 +34,60 @@ static char sccsid[] = "@(#)assert.c 8.1
4 __FBSDID("$FreeBSD: src/lib/libc/gen/assert.c,v 1.8 2007/01/09 00:27:53 imp Exp $");
5
6 #include <assert.h>
7 -#include <stdio.h>
8 #include <stdlib.h>
9 +#include <unistd.h>
10 +#include "CrashReporterClient.h"
11 +#include "_simple.h"
12
13 void
14 -__assert(func, file, line, failedexpr)
15 +__assert_rtn(func, file, line, failedexpr)
16 const char *func, *file;
17 int line;
18 const char *failedexpr;
19 {
20 - if (func == NULL)
21 - (void)fprintf(stderr,
22 + if (func == (const char *)-1L) {
23 + /* 8462256: special case to replace __eprintf */
24 + _simple_dprintf(STDERR_FILENO,
25 + "%s:%u: failed assertion `%s'\n", file, line, failedexpr);
26 + if (!CRGetCrashLogMessage()) {
27 + _SIMPLE_STRING s = _simple_salloc();
28 + if (s) {
29 + _simple_sprintf(s,
30 + "%s:%u: failed assertion `%s'\n",
31 + file, line, failedexpr);
32 + CRSetCrashLogMessage(_simple_string(s));
33 + } else
34 + CRSetCrashLogMessage(failedexpr);
35 + }
36 + } else if (func == NULL) {
37 + _simple_dprintf(STDERR_FILENO,
38 "Assertion failed: (%s), file %s, line %d.\n", failedexpr,
39 file, line);
40 - else
41 - (void)fprintf(stderr,
42 + if (!CRGetCrashLogMessage()) {
43 + _SIMPLE_STRING s = _simple_salloc();
44 + if (s) {
45 + _simple_sprintf(s,
46 + "Assertion failed: (%s), file %s, line %d.\n",
47 + failedexpr, file, line);
48 + CRSetCrashLogMessage(_simple_string(s));
49 + } else
50 + CRSetCrashLogMessage(failedexpr);
51 + }
52 + } else {
53 + _simple_dprintf(STDERR_FILENO,
54 "Assertion failed: (%s), function %s, file %s, line %d.\n",
55 failedexpr, func, file, line);
56 + if (!CRGetCrashLogMessage()) {
57 + _SIMPLE_STRING s = _simple_salloc();
58 + if (s) {
59 + _simple_sprintf(s,
60 + "Assertion failed: (%s), function %s, file %s, line %d.\n",
61 + failedexpr, func, file, line);
62 + CRSetCrashLogMessage(_simple_string(s));
63 + } else
64 + CRSetCrashLogMessage(failedexpr);
65 + }
66 + }
67 abort();
68 /* NOTREACHED */
69 }