56 #ifndef _RTEMS_SCORE_BASEDEFS_H 57 #define _RTEMS_SCORE_BASEDEFS_H 59 #include <rtems/score/cpuopts.h> 105 #define RTEMS_CONCAT( _x, _y ) _x##_y 114 #if defined(__GNUC__) 115 __attribute__((__error__(
"RTEMS_DEQUALIFY() types differ not only by volatile and const"))) void *
136 #if defined(__GNUC__) 137 #define RTEMS_TYPEOF_REFX( _level, _target ) \ 138 __typeof__(_level(union { int z; __typeof__(_target) x; }){0}.x) 140 #define RTEMS_TYPEOF_REFX( _level, _target ) 154 #define RTEMS_STRING( _x ) #_x 171 #define RTEMS_XCONCAT( _x, _y ) RTEMS_CONCAT( _x, _y ) 182 #define RTEMS_EXPAND( _token ) _token 192 #if defined(__GNUC__) 193 #define RTEMS_DEPRECATED __attribute__((__deprecated__)) 195 #define RTEMS_DEPRECATED 206 #if defined(__GNUC__) 207 #define RTEMS_NO_RETURN __attribute__((__noreturn__)) 209 #define RTEMS_NO_RETURN 220 #if defined(__GNUC__) 221 #define RTEMS_PACKED __attribute__((__packed__)) 235 #if defined(__GNUC__) 236 #define RTEMS_PURE __attribute__((__pure__)) 248 #if defined(__GNUC__) 249 #define RTEMS_USED __attribute__((__used__)) 268 #if defined(__cplusplus) 269 #define RTEMS_DEQUALIFY_DEPTHX( _ptr_level, _type, _var ) \ 270 (const_cast<_type>(_var)) 271 #elif defined(__GNUC__) 272 #define RTEMS_DEQUALIFY_DEPTHX( _ptr_level, _type, _var ) \ 273 __builtin_choose_expr(__builtin_types_compatible_p( \ 274 RTEMS_TYPEOF_REFX(_ptr_level, _var), \ 275 RTEMS_TYPEOF_REFX(_ptr_level, _type) \ 276 ) || __builtin_types_compatible_p(_type, void *), \ 278 RTEMS_DEQUALIFY_types_not_compatible()) 280 #define RTEMS_DEQUALIFY_DEPTHX( _ptr_level, _type, _var ) \ 281 ((_type)(uintptr_t)(const volatile void *)(_var)) 295 #define RTEMS_XSTRING( _x ) RTEMS_STRING( _x ) 307 #if defined(__USER_LABEL_PREFIX__) 308 #define RTEMS_SYMBOL_NAME( _name ) RTEMS_XCONCAT(__USER_LABEL_PREFIX__, _name) 310 #define RTEMS_SYMBOL_NAME( _name ) RTEMS_EXPAND(_name) 318 #if defined(RTEMS_DEBUG) 319 #define _Assert_Unreachable() _Assert( 0 ) 321 #define _Assert_Unreachable() do { } while ( 0 ) 334 #if defined(__GNUC__) 335 #define RTEMS_ALIAS( _target ) __attribute__((__alias__(#_target))) 337 #define RTEMS_ALIAS( _target ) 356 #define RTEMS_ALIGN_DOWN( _value, _alignment ) \ 357 ( ( _value ) & ~( ( _alignment ) - 1 ) ) 375 #define RTEMS_ALIGN_UP( _value, _alignment ) \ 376 ( ( ( _value ) + ( _alignment ) - 1 ) & ~( ( _alignment ) - 1 ) ) 388 #if defined(__GNUC__) 389 #define RTEMS_ALIGNED( _alignment ) __attribute__((__aligned__(_alignment))) 391 #define RTEMS_ALIGNED( _alignment ) 405 #if defined(__GNUC__) 406 #define RTEMS_ALLOC_ALIGN( _index ) __attribute__((__alloc_align__(_index))) 408 #define RTEMS_ALLOC_ALIGN( _index ) 421 #if defined(__GNUC__) 422 #define RTEMS_ALLOC_SIZE( _index ) __attribute__((__alloc_size__(_index))) 424 #define RTEMS_ALLOC_SIZE( _index ) 441 #if defined(__GNUC__) 442 #define RTEMS_ALLOC_SIZE_2( _count_index, _size_index ) \ 443 __attribute__((__alloc_size__(_count_index, _size_index))) 445 #define RTEMS_ALLOC_SIZE_2( _count_index, _size_index ) 459 #define RTEMS_ARRAY_SIZE( _array ) (sizeof(_array) / sizeof((_array)[0])) 468 #define RTEMS_COMPILER_DEPRECATED_ATTRIBUTE RTEMS_DEPRECATED 478 #if defined(__GNUC__) 479 #define RTEMS_COMPILER_MEMORY_BARRIER() __asm__ volatile( "" ::: "memory" ) 481 #define RTEMS_COMPILER_MEMORY_BARRIER() do { } while ( 0 ) 491 #define RTEMS_COMPILER_NO_RETURN_ATTRIBUTE RTEMS_NO_RETURN 500 #define RTEMS_COMPILER_PACKED_ATTRIBUTE RTEMS_PACKED 509 #define RTEMS_COMPILER_PURE_ATTRIBUTE RTEMS_PURE 518 #define RTEMS_COMPILER_USED_ATTRIBUTE RTEMS_USED 529 #if defined(__GNUC__) 530 #define RTEMS_CONST __attribute__((__const__)) 550 #define RTEMS_CONTAINER_OF( _m, _type, _member_name ) \ 551 ( (_type *) ( (uintptr_t) ( _m ) - offsetof( _type, _member_name ) ) ) 565 #define RTEMS_DECLARE_GLOBAL_SYMBOL( _name ) extern char _name[] 579 #define RTEMS_DECONST( _type, _var ) RTEMS_DEQUALIFY_DEPTHX(*, _type, _var) 598 #if defined(__USER_LABEL_PREFIX__) 599 #define RTEMS_DEFINE_GLOBAL_SYMBOL( _name, _value ) \ 601 "\t.globl " RTEMS_XSTRING( RTEMS_SYMBOL_NAME( _name ) ) \ 602 "\n\t.set " RTEMS_XSTRING( RTEMS_SYMBOL_NAME( _name ) ) \ 603 ", " RTEMS_STRING( _value ) "\n" \ 606 #define RTEMS_DEFINE_GLOBAL_SYMBOL( _name, _value ) 621 #define RTEMS_DEQUALIFY( _type, _var ) RTEMS_DEQUALIFY_DEPTHX(*, _type, _var) 635 #define RTEMS_DEVOLATILE( _type, _var ) RTEMS_DEQUALIFY_DEPTHX(*, _type, _var) 664 #if defined(__GNUC__) 665 #define RTEMS_HAVE_MEMBER_SAME_TYPE( _t_lhs, _m_lhs, _t_rhs, _m_rhs ) \ 666 __builtin_types_compatible_p( \ 667 __typeof__( ( (_t_lhs *) 0 )->_m_lhs ), \ 668 __typeof__( ( (_t_rhs *) 0 )->_m_rhs ) \ 671 #define RTEMS_HAVE_MEMBER_SAME_TYPE( _t_lhs, _m_lhs, _t_rhs, _m_rhs ) true 682 #if defined(__GNUC__) 683 #define RTEMS_INLINE_ROUTINE static __inline__ 685 #define RTEMS_INLINE_ROUTINE static inline 696 #if defined(__GNUC__) 697 #define RTEMS_MALLOCLIKE __attribute__((__malloc__)) 699 #define RTEMS_MALLOCLIKE 710 #if defined(__GNUC__) 711 #define RTEMS_NO_INLINE __attribute__((__noinline__)) 713 #define RTEMS_NO_INLINE 728 #if defined(__GNUC__) 729 #define RTEMS_OBFUSCATE_VARIABLE( _var ) __asm__( "" : "+r" ( _var ) ) 731 #define RTEMS_OBFUSCATE_VARIABLE( _var ) (void) (_var) 746 #if defined(__GNUC__) 747 #define RTEMS_PREDICT_FALSE( _exp ) __builtin_expect( ( _exp ), 0 ) 749 #define RTEMS_PREDICT_FALSE( _exp ) ( _exp ) 764 #if defined(__GNUC__) 765 #define RTEMS_PREDICT_TRUE( _exp ) __builtin_expect( ( _exp ), 1 ) 767 #define RTEMS_PREDICT_TRUE( _exp ) ( _exp ) 784 #if defined(__GNUC__) 785 #define RTEMS_PRINTFLIKE( _format_pos, _ap_pos ) \ 786 __attribute__((__format__(__printf__, _format_pos, _ap_pos))) 788 #define RTEMS_PRINTFLIKE( _format_pos, _ap_pos ) 800 #if defined(__GNUC__) 801 #define RTEMS_RETURN_ADDRESS() __builtin_return_address(0) 803 #define RTEMS_RETURN_ADDRESS() NULL 816 #if defined(__GNUC__) 817 #define RTEMS_SECTION( _section ) __attribute__((__section__(_section))) 819 #define RTEMS_SECTION( _section ) 833 #if __cplusplus >= 201103L 834 #define RTEMS_STATIC_ASSERT( _cond, _msg ) static_assert(_cond, # _msg) 835 #elif __STDC_VERSION__ >= 201112L 836 #define RTEMS_STATIC_ASSERT( _cond, _msg ) _Static_assert(_cond, # _msg) 838 #define RTEMS_STATIC_ASSERT( _cond, _msg ) \ 839 struct rtems_static_assert_ ## _msg \ 840 { int rtems_static_assert_ ## _msg : (_cond) ? 1 : -1; } 859 #if defined(__GNUC__) 860 #define RTEMS_UNREACHABLE() \ 862 __builtin_unreachable(); \ 863 _Assert_Unreachable(); \ 866 #define RTEMS_UNREACHABLE() _Assert_Unreachable() 877 #if defined(__GNUC__) 878 #define RTEMS_UNUSED __attribute__((__unused__)) 891 #if defined(__GNUC__) 892 #define RTEMS_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) 894 #define RTEMS_WARN_UNUSED_RESULT 908 #if defined(__GNUC__) 909 #define RTEMS_WEAK __attribute__((__weak__)) 924 #if defined(__GNUC__) 925 #define RTEMS_WEAK_ALIAS( _target ) \ 926 __attribute__((__weak__, __alias__(#_target))) 928 #define RTEMS_WEAK_ALIAS( _target ) 942 #if __STDC_VERSION__ >= 199409L 943 #define RTEMS_ZERO_LENGTH_ARRAY 945 #define RTEMS_ZERO_LENGTH_ARRAY 0 void * RTEMS_DEQUALIFY_types_not_compatible(void)
A not implemented function to trigger compile time errors with an error message.