diff options
Diffstat (limited to 'cpukit/include/rtems/score/basedefs.h')
-rw-r--r-- | cpukit/include/rtems/score/basedefs.h | 133 |
1 files changed, 77 insertions, 56 deletions
diff --git a/cpukit/include/rtems/score/basedefs.h b/cpukit/include/rtems/score/basedefs.h index c182ea02ec..010728d795 100644 --- a/cpukit/include/rtems/score/basedefs.h +++ b/cpukit/include/rtems/score/basedefs.h @@ -10,9 +10,9 @@ */ /* - * Copyright (C) 2014 Paval Pisa + * Copyright (C) 2014 Pavel Pisa * Copyright (C) 2011, 2013 On-Line Applications Research Corporation (OAR) - * Copyright (C) 2009, 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2009, 2023 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -75,9 +75,8 @@ extern "C" { /** * @defgroup RTEMSAPI API * - * @brief API - * - * This group contains the RTEMS Application Programming Interface (API). + * @brief This group contains the RTEMS Application Programming Interface + * (API). */ /* Generated from spec:/rtems/basedefs/if/group */ @@ -169,9 +168,9 @@ extern "C" { * * @return Returns the alignment requirement of the type. */ -#if __cplusplus >= 201103L +#if defined( __cplusplus ) && __cplusplus >= 201103L #define RTEMS_ALIGNOF( _type_name ) alignof( _type_name ) -#elif __STDC_VERSION__ >= 201112L +#elif defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 201112L #define RTEMS_ALIGNOF( _type_name ) _Alignof( _type_name ) #else #define RTEMS_ALIGNOF( _type_name ) sizeof( _type_name ) @@ -355,6 +354,47 @@ extern "C" { */ #define RTEMS_EXPAND( _token ) _token +/* Generated from spec:/rtems/basedefs/if/function-name */ + +/** + * @ingroup RTEMSAPIBaseDefs + * + * @brief Expands to the name of the function containing the use of this + * define. + */ +#if defined(__cplusplus) && defined(__GNUC__) + #define RTEMS_FUNCTION_NAME __PRETTY_FUNCTION__ +#else + #define RTEMS_FUNCTION_NAME __func__ +#endif + +/* Generated from spec:/rtems/basedefs/if/no-return */ + +/** + * @ingroup RTEMSAPIBaseDefs + * + * @brief Tells the compiler in a function declaration that this function does + * not return. + */ +#if defined( __cplusplus ) && __cplusplus >= 201103L + #define RTEMS_NO_RETURN [[noreturn]] +#elif defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 201112L + #define RTEMS_NO_RETURN _Noreturn +#elif defined(__GNUC__) + #define RTEMS_NO_RETURN __attribute__(( __noreturn__ )) +#else + #define RTEMS_NO_RETURN +#endif + +/* Generated from spec:/rtems/basedefs/if/compiler-no-return-attribute */ + +/** + * @ingroup RTEMSAPIBaseDefs + * + * @brief Provided for backward compatibility. + */ +#define RTEMS_COMPILER_NO_RETURN_ATTRIBUTE RTEMS_NO_RETURN + /* Generated from spec:/rtems/basedefs/if/section */ /** @@ -392,7 +432,7 @@ extern "C" { * * @brief Gets the pointer reference type. * - * @param _level is the pointer indirection level expressed in *. + * @param _level is the pointer indirection level expressed in ``*``. * * @param _target is the reference target type. * @@ -425,17 +465,25 @@ extern "C" { */ #define RTEMS_XCONCAT( _x, _y ) RTEMS_CONCAT( _x, _y ) -/* Generated from spec:/score/basedefs/if/assert-unreachable */ +#if !defined(ASM) && defined(RTEMS_DEBUG) + /* Generated from spec:/score/basedefs/if/debug-unreachable */ -/** - * @ingroup RTEMSScore - * - * @brief Asserts that this program point is unreachable. - */ -#if defined(RTEMS_DEBUG) - #define _Assert_Unreachable() _Assert( 0 ) -#else - #define _Assert_Unreachable() do { } while ( 0 ) + /** + * @ingroup RTEMSScore + * + * @brief Terminates the program with a failed assertion. + * + * @param file is the file name. + * + * @param line is the line of the file. + * + * @param func is the function name. + */ + RTEMS_NO_RETURN void _Debug_Unreachable( + const char *file, + int line, + const char *func + ); #endif #if !defined(ASM) @@ -463,7 +511,7 @@ extern "C" { * @brief Performs a type cast which removes qualifiers without warnings to the * type for the variable. * - * @param _ptr_level is the pointer indirection level expressed in *. + * @param _ptr_level is the pointer indirection level expressed in ``*``. * * @param _type is the target type of the cast. * @@ -614,33 +662,6 @@ extern "C" { #define RTEMS_NO_INLINE #endif -/* Generated from spec:/rtems/basedefs/if/no-return */ - -/** - * @ingroup RTEMSAPIBaseDefs - * - * @brief Tells the compiler in a function declaration that this function does - * not return. - */ -#if __cplusplus >= 201103L - #define RTEMS_NO_RETURN [[noreturn]] -#elif __STDC_VERSION__ >= 201112L - #define RTEMS_NO_RETURN _Noreturn -#elif defined(__GNUC__) - #define RTEMS_NO_RETURN __attribute__(( __noreturn__ )) -#else - #define RTEMS_NO_RETURN -#endif - -/* Generated from spec:/rtems/basedefs/if/compiler-no-return-attribute */ - -/** - * @ingroup RTEMSAPIBaseDefs - * - * @brief Provided for backward compatibility. - */ -#define RTEMS_COMPILER_NO_RETURN_ATTRIBUTE RTEMS_NO_RETURN - /* Generated from spec:/rtems/basedefs/if/noinit */ /** @@ -812,9 +833,9 @@ extern "C" { * * @param _msg is the error message in case the static assertion fails. */ -#if __cplusplus >= 201103L +#if defined( __cplusplus ) && __cplusplus >= 201103L #define RTEMS_STATIC_ASSERT( _cond, _msg ) static_assert( _cond, # _msg ) -#elif __STDC_VERSION__ >= 201112L +#elif defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 201112L #define RTEMS_STATIC_ASSERT( _cond, _msg ) _Static_assert( _cond, # _msg ) #else #define RTEMS_STATIC_ASSERT( _cond, _msg ) \ @@ -858,14 +879,13 @@ extern "C" { * * @brief Tells the compiler that this program point is unreachable. */ -#if defined(__GNUC__) +#if defined(RTEMS_DEBUG) #define RTEMS_UNREACHABLE() \ - do { \ - __builtin_unreachable(); \ - _Assert_Unreachable(); \ - } while ( 0 ) + _Debug_Unreachable( __FILE__, __LINE__, RTEMS_FUNCTION_NAME ) +#elif defined(__GNUC__) + #define RTEMS_UNREACHABLE() __builtin_unreachable() #else - #define RTEMS_UNREACHABLE() _Assert_Unreachable() + #define RTEMS_UNREACHABLE() do { } while ( 0 ) #endif /* Generated from spec:/rtems/basedefs/if/unused */ @@ -979,11 +999,12 @@ extern "C" { * * @param _value is the value of the symbol. On the value a macro expansion is * performed and afterwards it is stringified. It shall expand to an integer - * expression understood by the assembler. + * expression understood by the assembler. The value shall be representable + * in the code model of the target architecture. * * This macro shall be placed at file scope. */ -#if defined(__USER_LABEL_PREFIX__) +#if defined(__GNUC__) #define RTEMS_DEFINE_GLOBAL_SYMBOL( _name, _value ) \ __asm__( \ "\t.globl " RTEMS_XSTRING( RTEMS_SYMBOL_NAME( _name ) ) \ |