1 /* Copyright (c) 2008 Patrick Mansfield <patmans@us.ibm.com> */
2 #include <assert.h>
3 #include <stdlib.h>
4 #include <stdio.h>
5
6 /*
7 * SPU specific assert: just directly call exit(6), and use fprintf. That
8 * way we do not pull in the abort, signal.o code, nor (the likely
9 * otherwise unused) fiprintf.
10 */
11
12 /* func can be NULL, in which case no function information is given. */
13 void
__assert_func(const char * file,int line,const char * func,const char * failedexpr)14 __assert_func (const char *file,
15 int line,
16 const char *func,
17 const char *failedexpr)
18 {
19 fprintf(stderr,
20 "assertion \"%s\" failed: file \"%s\", line %d%s%s\n",
21 failedexpr, file, line,
22 func ? ", function: " : "", func ? func : "");
23 /*
24 * On the SPU, we do not have signaling. Previously, standard newlib
25 * abort code was used. That eventually leads to a kill(SIGABRT), and
26 * for SPU too an exit(SIGABRT). SIGABRT was 6, so just use that value
27 * here.
28 */
29 exit(6);
30 /* NOTREACHED */
31 }
32
33 void
__assert(const char * file,int line,const char * failedexpr)34 __assert (const char *file,
35 int line,
36 const char *failedexpr)
37 {
38 __assert_func (file, line, NULL, failedexpr);
39 /* NOTREACHED */
40 }
41