RTEMS  5.0.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
assert.h
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 
104 #ifdef __cplusplus
105 }
106 #endif /* __cplusplus */
107 
108 #endif /* _RTEMS_SCORE_ASSERT_H */
#define RTEMS_NO_RETURN
Definition: basedefs.h:101
Basic Definitions.