forked from Imagelibrary/rtems
rtems/score/assert.h: Rework to allow use of NDEBUG
This commit is contained in:
@@ -30,22 +30,52 @@ extern "C" {
|
|||||||
* NDEBUG.
|
* NDEBUG.
|
||||||
*/
|
*/
|
||||||
#if defined( RTEMS_DEBUG )
|
#if defined( RTEMS_DEBUG )
|
||||||
#if !defined( RTEMS_SCHEDSIM )
|
|
||||||
/* __ASSERT_FUNC is newlib. */
|
/**
|
||||||
#define _Assert( _e ) \
|
* @brief Macro with method name used in assert output
|
||||||
( ( _e ) ? \
|
*
|
||||||
( void ) 0 : \
|
* Given the variations in compilers and standards, we have to poke a bit.
|
||||||
__assert_func( __FILE__, __LINE__, __ASSERT_FUNC, #_e ) )
|
*
|
||||||
#else
|
* @note This is based on the code in newlib's assert.h.
|
||||||
/* __ASSERT_FUNCTION is glibc. */
|
*/
|
||||||
#if defined(__ASSERT_FUNCTION)
|
#ifndef __RTEMS_ASSERT_FUNCTION
|
||||||
#define _Assert( _e ) \
|
/* Use g++'s demangled names in C++. */
|
||||||
( ( _e ) ? \
|
#if defined __cplusplus && defined __GNUC__
|
||||||
( void ) 0 : \
|
#define __RTEMS_ASSERT_FUNCTION __PRETTY_FUNCTION__
|
||||||
__assert_fail( #_e, __FILE__, __LINE__, __ASSERT_FUNCTION ) )
|
|
||||||
|
/* C99 requires the use of __func__. */
|
||||||
|
#elif __STDC_VERSION__ >= 199901L
|
||||||
|
#define __RTEMS_ASSERT_FUNCTION __func__
|
||||||
|
|
||||||
|
/* Older versions of gcc don't have __func__ but can use __FUNCTION__. */
|
||||||
|
#elif __GNUC__ >= 2
|
||||||
|
#define __RTEMS_ASSERT_FUNCTION __FUNCTION__
|
||||||
|
|
||||||
|
/* failed to detect __func__ support. */
|
||||||
#else
|
#else
|
||||||
#error "What does assert.h use?"
|
#define __RTEMS_ASSERT_FUNCTION ((char *) 0)
|
||||||
#endif
|
#endif
|
||||||
|
#endif /* !__RTEMS_ASSERT_FUNCTION */
|
||||||
|
|
||||||
|
#if !defined( RTEMS_SCHEDSIM )
|
||||||
|
/* normal build is newlib. */
|
||||||
|
|
||||||
|
void __assert_func(const char *, int, const char *, const char *)
|
||||||
|
RTEMS_COMPILER_NO_RETURN_ATTRIBUTE;
|
||||||
|
|
||||||
|
#define _Assert( _e ) \
|
||||||
|
( ( _e ) ? \
|
||||||
|
( void ) 0 : \
|
||||||
|
__assert_func( __FILE__, __LINE__, __RTEMS_ASSERT_FUNCTION, #_e ) )
|
||||||
|
|
||||||
|
#elif defined(__linux__)
|
||||||
|
/* Scheduler simulator has only beed tested on glibc. */
|
||||||
|
#define _Assert( _e ) \
|
||||||
|
( ( _e ) ? \
|
||||||
|
( void ) 0 : \
|
||||||
|
__assert_fail( #_e, __FILE__, __LINE__, __RTEMS_ASSERT_FUNCTION ) )
|
||||||
|
#else
|
||||||
|
#error "Implement RTEMS assert support for this C Library"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|||||||
Reference in New Issue
Block a user