RTEMS  5.1
assert.h
Go to the documentation of this file.
1 
9 /*
10  * Copyright (c) 2013-2014 embedded brains GmbH. All rights reserved.
11  *
12  * embedded brains GmbH
13  * Dornierstr. 4
14  * 82178 Puchheim
15  * Germany
16  * <rtems@embedded-brains.de>
17  *
18  * The license and distribution terms for this file may be
19  * found in the file LICENSE in this distribution or at
20  * http://www.rtems.org/license/LICENSE.
21  */
22 
23 #ifndef _RTEMS_SCORE_ASSERT_H
24 #define _RTEMS_SCORE_ASSERT_H
25 
26 #include <rtems/score/basedefs.h>
27 
38 #if defined( RTEMS_DEBUG )
39  #include <assert.h>
40 #endif
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif /* __cplusplus */
45 
50 #if defined( RTEMS_DEBUG )
51 
59  #ifndef __RTEMS_ASSERT_FUNCTION
60  /* Use g++'s demangled names in C++. */
61  #if defined __cplusplus && defined __GNUC__
62  #define __RTEMS_ASSERT_FUNCTION __PRETTY_FUNCTION__
63 
64  /* C99 requires the use of __func__. */
65  #elif __STDC_VERSION__ >= 199901L
66  #define __RTEMS_ASSERT_FUNCTION __func__
67 
68  /* Older versions of gcc don't have __func__ but can use __FUNCTION__. */
69  #elif __GNUC__ >= 2
70  #define __RTEMS_ASSERT_FUNCTION __FUNCTION__
71 
72  /* failed to detect __func__ support. */
73  #else
74  #define __RTEMS_ASSERT_FUNCTION ((char *) 0)
75  #endif
76  #endif /* !__RTEMS_ASSERT_FUNCTION */
77 
78  #if !defined( RTEMS_SCHEDSIM )
79  /* normal build is newlib. */
80 
81  void __assert_func(const char *, int, const char *, const char *)
83 
84  #define _Assert( _e ) \
85  ( ( _e ) ? \
86  ( void ) 0 : \
87  __assert_func( __FILE__, __LINE__, __RTEMS_ASSERT_FUNCTION, #_e ) )
88 
89  #elif defined(__linux__)
90  /* Scheduler simulator has only beed tested on glibc. */
91  #define _Assert( _e ) \
92  ( ( _e ) ? \
93  ( void ) 0 : \
94  __assert_fail( #_e, __FILE__, __LINE__, __RTEMS_ASSERT_FUNCTION ) )
95  #else
96  #error "Implement RTEMS assert support for this C Library"
97  #endif
98 
99 #else
100  #define _Assert( _e ) ( ( void ) 0 )
101 #endif
102 
106 #if defined( RTEMS_SMP )
107  #define _SMP_Assert( _e ) _Assert( _e )
108 #else
109  #define _SMP_Assert( _e ) ( ( void ) 0 )
110 #endif
111 
118 #if defined( RTEMS_DEBUG )
119  bool _Debug_Is_thread_dispatching_allowed( void );
120 #endif
121 
122 #ifdef __cplusplus
123 }
124 #endif /* __cplusplus */
125 
128 #endif /* _RTEMS_SCORE_ASSERT_H */
#define RTEMS_NO_RETURN
Definition: basedefs.h:102
Information for the Assert Handler.
Basic Definitions.