RTEMS CPU Kit with SuperCore  4.11.2
assert.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-2014 embedded brains GmbH. All rights reserved.
3  *
4  * embedded brains GmbH
5  * Dornierstr. 4
6  * 82178 Puchheim
7  * Germany
8  * <rtems@embedded-brains.de>
9  *
10  * The license and distribution terms for this file may be
11  * found in the file LICENSE in this distribution or at
12  * http://www.rtems.org/license/LICENSE.
13  */
14 
15 #ifndef _RTEMS_SCORE_ASSERT_H
16 #define _RTEMS_SCORE_ASSERT_H
17 
18 #include <rtems/score/basedefs.h>
19 
20 #if defined( RTEMS_DEBUG )
21  #include <assert.h>
22 #endif
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif /* __cplusplus */
27 
32 #if defined( RTEMS_DEBUG )
33 
41  #ifndef __RTEMS_ASSERT_FUNCTION
42  /* Use g++'s demangled names in C++. */
43  #if defined __cplusplus && defined __GNUC__
44  #define __RTEMS_ASSERT_FUNCTION __PRETTY_FUNCTION__
45 
46  /* C99 requires the use of __func__. */
47  #elif __STDC_VERSION__ >= 199901L
48  #define __RTEMS_ASSERT_FUNCTION __func__
49 
50  /* Older versions of gcc don't have __func__ but can use __FUNCTION__. */
51  #elif __GNUC__ >= 2
52  #define __RTEMS_ASSERT_FUNCTION __FUNCTION__
53 
54  /* failed to detect __func__ support. */
55  #else
56  #define __RTEMS_ASSERT_FUNCTION ((char *) 0)
57  #endif
58  #endif /* !__RTEMS_ASSERT_FUNCTION */
59 
60  #if !defined( RTEMS_SCHEDSIM )
61  /* normal build is newlib. */
62 
63  void __assert_func(const char *, int, const char *, const char *)
65 
66  #define _Assert( _e ) \
67  ( ( _e ) ? \
68  ( void ) 0 : \
69  __assert_func( __FILE__, __LINE__, __RTEMS_ASSERT_FUNCTION, #_e ) )
70 
71  #elif defined(__linux__)
72  /* Scheduler simulator has only beed tested on glibc. */
73  #define _Assert( _e ) \
74  ( ( _e ) ? \
75  ( void ) 0 : \
76  __assert_fail( #_e, __FILE__, __LINE__, __RTEMS_ASSERT_FUNCTION ) )
77  #else
78  #error "Implement RTEMS assert support for this C Library"
79  #endif
80 
81 #else
82  #define _Assert( _e ) ( ( void ) 0 )
83 #endif
84 
88 #if defined( RTEMS_SMP )
89  #define _SMP_Assert( _e ) _Assert( _e )
90 #else
91  #define _SMP_Assert( _e ) ( ( void ) 0 )
92 #endif
93 
100 #if defined( RTEMS_DEBUG )
101  bool _Debug_Is_thread_dispatching_allowed( void );
102 #endif
103 
107 #if defined( RTEMS_DEBUG )
108  #if defined( RTEMS_SMP )
109  bool _Debug_Is_owner_of_giant( void );
110  #else
111  #define _Debug_Is_owner_of_giant() (true)
112  #endif
113 #endif
114 
119 #if defined( RTEMS_DEBUG )
120  bool _Debug_Is_owner_of_allocator( void );
121 #endif
122 
126 #if RTEMS_SCHEDSIM
127 #define _Assert_Not_reached()
128 #else
129 #define _Assert_Not_reached() _Assert( 0 )
130 #endif
131 
132 #ifdef __cplusplus
133 }
134 #endif /* __cplusplus */
135 
136 #endif /* _RTEMS_SCORE_ASSERT_H */
#define RTEMS_COMPILER_NO_RETURN_ATTRIBUTE
The following macro is a compiler specific way to indicate that the method will NOT return to the cal...
Definition: basedefs.h:162
Basic Definitions.