1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
/**
* @file
*
* @brief Evaluate Assertion
* @ingroup libcsupport
*/
/*
* COPYRIGHT (c) 2007-2013.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include <rtems/bspIo.h>
#include <rtems.h>
#if defined(RTEMS_NEWLIB) && !defined(HAVE___ASSERT_FUNC)
#include <assert.h>
/**
* Newlib 1.16.0 added this method. Together these provide an
* RTEMS safe, low memory implementation.
*/
void __assert_func(
const char *file,
int line,
const char *func,
const char *failedexpr
)
{
rtems_assert_context assert_context = {
.file = file,
.line = line,
.function = func,
.failed_expression = failedexpr
};
printk("assertion \"%s\" failed: file \"%s\", line %d%s%s\n",
failedexpr,
file,
line,
(func) ? ", function: " : "",
(func) ? func : ""
);
rtems_fatal( RTEMS_FATAL_SOURCE_ASSERT, (rtems_fatal_code) &assert_context );
}
#endif
#if defined(RTEMS_NEWLIB) && !defined(HAVE___ASSERT)
/**
* small RTEMS Specific Implementation
*/
void __assert(
const char *file,
int line,
const char *failedexpr
)
{
__assert_func (file, line, NULL, failedexpr);
}
#endif
|