source: rtems/cpukit/libcsupport/src/__assert.c @ e02d5dd9

4.115
Last change on this file since e02d5dd9 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

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