![]() |
|
|||
File indexing completed on 2025-05-11 08:24:12
0001 /* SPDX-License-Identifier: BSD-2-Clause */ 0002 0003 /** 0004 * @file 0005 * 0006 * @ingroup RTEMSScoreAssert 0007 * 0008 * @brief This header file provides the interfaces of the 0009 * @ref RTEMSScoreAssert. 0010 */ 0011 0012 /* 0013 * Copyright (C) 2013, 2014 embedded brains GmbH & Co. KG 0014 * 0015 * Redistribution and use in source and binary forms, with or without 0016 * modification, are permitted provided that the following conditions 0017 * are met: 0018 * 1. Redistributions of source code must retain the above copyright 0019 * notice, this list of conditions and the following disclaimer. 0020 * 2. Redistributions in binary form must reproduce the above copyright 0021 * notice, this list of conditions and the following disclaimer in the 0022 * documentation and/or other materials provided with the distribution. 0023 * 0024 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 0025 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0026 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0027 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 0028 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 0029 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 0030 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0031 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 0032 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 0033 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 0034 * POSSIBILITY OF SUCH DAMAGE. 0035 */ 0036 0037 #ifndef _RTEMS_SCORE_ASSERT_H 0038 #define _RTEMS_SCORE_ASSERT_H 0039 0040 #include <rtems/score/basedefs.h> 0041 0042 /** 0043 * @defgroup RTEMSScoreAssert Assert Handler 0044 * 0045 * @ingroup RTEMSScore 0046 * 0047 * @brief This group contains the Assert Handler implementation. 0048 * 0049 * @{ 0050 */ 0051 0052 #if defined( RTEMS_DEBUG ) 0053 #include <assert.h> 0054 #endif 0055 0056 #ifdef __cplusplus 0057 extern "C" { 0058 #endif /* __cplusplus */ 0059 0060 /** 0061 * @brief Assertion similar to assert() controlled via RTEMS_DEBUG instead of 0062 * NDEBUG and static analysis runs. 0063 */ 0064 #if defined( RTEMS_DEBUG ) || defined( RTEMS_STATIC_ANALYSIS ) 0065 0066 /** 0067 * @brief Macro with method name used in assert output 0068 * 0069 * Given the variations in compilers and standards, we have to poke a bit. 0070 * 0071 * @note This is based on the code in newlib's assert.h. 0072 */ 0073 #ifndef __RTEMS_ASSERT_FUNCTION 0074 #define __RTEMS_ASSERT_FUNCTION RTEMS_FUNCTION_NAME 0075 #endif /* !__RTEMS_ASSERT_FUNCTION */ 0076 0077 #if !defined( RTEMS_SCHEDSIM ) 0078 /* normal build is newlib. */ 0079 0080 #define _Assert( _e ) \ 0081 ( ( _e ) ? \ 0082 ( void ) 0 : \ 0083 __assert_func( __FILE__, __LINE__, __RTEMS_ASSERT_FUNCTION, #_e ) ) 0084 0085 #elif defined(__linux__) 0086 /* Scheduler simulator has only beed tested on glibc. */ 0087 #define _Assert( _e ) \ 0088 ( ( _e ) ? \ 0089 ( void ) 0 : \ 0090 __assert_fail( #_e, __FILE__, __LINE__, __RTEMS_ASSERT_FUNCTION ) ) 0091 #else 0092 #error "Implement RTEMS assert support for this C Library" 0093 #endif 0094 0095 #else 0096 #define _Assert( _e ) ( ( void ) 0 ) 0097 #endif 0098 0099 /** 0100 * @brief Assert if unused return value is equal. 0101 * 0102 * Assert whether @a _var and @a _val are equal and ensure @a _var is 0103 * marked as used when not building for debug. 0104 * 0105 * @param _var The return value to be checked. 0106 * @param _val Indicates what @a _var is supposed to be. 0107 */ 0108 #define _Assert_Unused_variable_equals(_var,_val) \ 0109 do { \ 0110 _Assert((_var) == (_val)); \ 0111 (void) (_var); \ 0112 } while (0) 0113 0114 /** 0115 * @brief Assert if unused return value is not equal. 0116 * 0117 * Assert whether @a _var and @a _val are not equal and ensure @a _var 0118 * is marked as used when not building for debug. 0119 * 0120 * @param _var The return value to be checked. 0121 * @param _val Indicates what @a _var is not supposed to be. 0122 */ 0123 #define _Assert_Unused_variable_unequal(_var,_val) \ 0124 do { \ 0125 _Assert((_var) != (_val)); \ 0126 (void) (_var); \ 0127 } while (0) 0128 0129 /** 0130 * @brief Returns true if thread dispatching is allowed. 0131 * 0132 * Thread dispatching can be repressed via _Thread_Disable_dispatch() or 0133 * _ISR_Local_disable(). 0134 */ 0135 #if defined( RTEMS_DEBUG ) 0136 bool _Debug_Is_thread_dispatching_allowed( void ); 0137 #endif 0138 0139 #ifdef __cplusplus 0140 } 0141 #endif /* __cplusplus */ 0142 0143 /** @} */ 0144 0145 #endif /* _RTEMS_SCORE_ASSERT_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |