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