Changeset 3bff410 in rtems


Ignore:
Timestamp:
Sep 2, 2014, 11:07:36 PM (6 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.11, 5, master
Children:
ae03ad26
Parents:
9d95ef9
git-author:
Joel Sherrill <joel.sherrill@…> (09/02/14 23:07:36)
git-committer:
Joel Sherrill <joel.sherrill@…> (09/04/14 14:08:04)
Message:

rtems/score/assert.h: Rework to allow use of NDEBUG

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/include/rtems/score/assert.h

    r9d95ef9 r3bff410  
    3131 */
    3232#if defined( RTEMS_DEBUG )
     33
     34  /**
     35   * @brief Macro with method name used in assert output
     36   *
     37   * Given the variations in compilers and standards, we have to poke a bit.
     38   *
     39   * @note This is based on the code in newlib's assert.h.
     40   */
     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
    3360  #if !defined( RTEMS_SCHEDSIM )
    34     /* __ASSERT_FUNC is newlib. */
     61    /* normal build is newlib. */
     62
     63    void __assert_func(const char *, int, const char *, const char *)
     64      RTEMS_COMPILER_NO_RETURN_ATTRIBUTE;
     65
    3566    #define _Assert( _e ) \
    36       ( ( _e ) ? \
    37         ( void ) 0 : \
    38           __assert_func( __FILE__, __LINE__, __ASSERT_FUNC, #_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 ) )
    3977  #else
    40     /* __ASSERT_FUNCTION is glibc. */
    41     #if defined(__ASSERT_FUNCTION)
    42       #define _Assert( _e ) \
    43         ( ( _e ) ? \
    44           ( void ) 0 : \
    45             __assert_fail( #_e, __FILE__, __LINE__, __ASSERT_FUNCTION ) )
    46     #else
    47        #error "What does assert.h use?"
    48     #endif
     78    #error "Implement RTEMS assert support for this C Library"
    4979  #endif
    5080
Note: See TracChangeset for help on using the changeset viewer.