20 #ifndef _RTEMS_BASEDEFS_H 21 #define _RTEMS_BASEDEFS_H 31 #include <rtems/score/cpuopts.h> 54 #error "TRUE equals FALSE" 64 #define RTEMS_INLINE_ROUTINE static __inline__ 66 #define RTEMS_INLINE_ROUTINE static inline 75 #define RTEMS_COMPILER_MEMORY_BARRIER() __asm__ volatile("" ::: "memory") 77 #define RTEMS_COMPILER_MEMORY_BARRIER() 85 #define RTEMS_NO_INLINE __attribute__((__noinline__)) 87 #define RTEMS_NO_INLINE 97 #if defined(RTEMS_SCHEDSIM) 98 #define RTEMS_NO_RETURN 99 #elif defined(__GNUC__) && !defined(RTEMS_DEBUG) 100 #define RTEMS_NO_RETURN __attribute__((__noreturn__)) 102 #define RTEMS_NO_RETURN 106 #define RTEMS_COMPILER_NO_RETURN_ATTRIBUTE RTEMS_NO_RETURN 114 #define RTEMS_CONST __attribute__((__const__)) 126 #define RTEMS_PURE __attribute__((__pure__)) 132 #define RTEMS_COMPILER_PURE_ATTRIBUTE RTEMS_PURE 139 #define RTEMS_DEPRECATED __attribute__((__deprecated__)) 141 #define RTEMS_DEPRECATED 145 #define RTEMS_COMPILER_DEPRECATED_ATTRIBUTE RTEMS_DEPRECATED 151 #if defined(__GNUC__) 152 #define RTEMS_SECTION( _section ) __attribute__((__section__(_section))) 154 #define RTEMS_SECTION( _section ) 160 #if defined(__GNUC__) 161 #define RTEMS_USED __attribute__((__used__)) 171 #if defined(__GNUC__) 172 #define RTEMS_UNUSED __attribute__((__unused__)) 178 #define RTEMS_COMPILER_UNUSED_ATTRIBUTE RTEMS_UNUSED 184 #if defined(__GNUC__) 185 #define RTEMS_PACKED __attribute__((__packed__)) 194 #if defined(__GNUC__) 195 #define RTEMS_ALIAS( _target ) __attribute__((__alias__(#_target))) 197 #define RTEMS_ALIAS( _target ) 204 #if defined(__GNUC__) 205 #define RTEMS_WEAK_ALIAS( _target ) __attribute__((__weak__, __alias__(#_target))) 207 #define RTEMS_WEAK_ALIAS( _target ) 213 #if defined(__GNUC__) 214 #define RTEMS_ALIGNED( _alignment ) __attribute__((__aligned__(_alignment))) 216 #define RTEMS_ALIGNED( _alignment ) 220 #define RTEMS_COMPILER_PACKED_ATTRIBUTE RTEMS_PACKED 222 #if defined(RTEMS_DEBUG) && !defined(RTEMS_SCHEDSIM) 223 #define _Assert_Unreachable() _Assert( 0 ) 225 #define _Assert_Unreachable() do { } while ( 0 ) 231 #if defined(__GNUC__) && !defined(RTEMS_SCHEDSIM) 232 #define RTEMS_UNREACHABLE() \ 234 __builtin_unreachable(); \ 235 _Assert_Unreachable(); \ 238 #define RTEMS_UNREACHABLE() _Assert_Unreachable() 245 #if defined(__GNUC__) 246 #define RTEMS_PRINTFLIKE( _format_pos, _ap_pos ) \ 247 __attribute__((__format__(__printf__, _format_pos, _ap_pos))) 249 #define RTEMS_PRINTFLIKE( _format_pos, _ap_pos ) 256 #if defined(__GNUC__) 257 #define RTEMS_MALLOCLIKE __attribute__((__malloc__)) 259 #define RTEMS_MALLOCLIKE 266 #if defined(__GNUC__) 267 #define RTEMS_ALLOC_SIZE( _index ) __attribute__((__alloc_size__(_index))) 269 #define RTEMS_ALLOC_SIZE( _index ) 276 #if defined(__GNUC__) 277 #define RTEMS_ALLOC_SIZE_2( _count_index, _size_index ) \ 278 __attribute__((__alloc_size__(_count_index, _size_index))) 280 #define RTEMS_ALLOC_SIZE_2( _count_index, _size_index ) 287 #if defined(__GNUC__) 288 #define RTEMS_ALLOC_ALIGN( _index ) __attribute__((__alloc_align__(_index))) 290 #define RTEMS_ALLOC_ALIGN( _index ) 296 #if defined(__GNUC__) 297 #define RTEMS_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) 299 #define RTEMS_WARN_UNUSED_RESULT 308 #if defined(__GNUC__) 309 #define RTEMS_OBFUSCATE_VARIABLE( _var ) __asm__("" : "+r" (_var)) 311 #define RTEMS_OBFUSCATE_VARIABLE( _var ) (void) (_var) 321 #define RTEMS_DECLARE_GLOBAL_SYMBOL( _name ) \ 330 #if defined(__USER_LABEL_PREFIX__) 331 #define RTEMS_SYMBOL_NAME( _name ) \ 332 RTEMS_XCONCAT( __USER_LABEL_PREFIX__, _name ) 335 #define _RTEMS_SYMBOL_NAME( _name ) _name 337 #define RTEMS_SYMBOL_NAME( _name ) _RTEMS_SYMBOL_NAME( _name ) 352 #if defined(__GNUC__) 353 #define RTEMS_DEFINE_GLOBAL_SYMBOL( _name, _value ) \ 355 "\t.globl " RTEMS_XSTRING( RTEMS_SYMBOL_NAME( _name ) ) \ 356 "\n\t.set " RTEMS_XSTRING( RTEMS_SYMBOL_NAME( _name ) ) \ 357 ", " RTEMS_STRING( _value ) "\n" \ 360 #define RTEMS_DEFINE_GLOBAL_SYMBOL( _name, _value ) 371 #if defined(__GNUC__) 372 #define RTEMS_PREDICT_TRUE( _exp ) __builtin_expect( ( _exp ), 1 ) 374 #define RTEMS_PREDICT_TRUE( _exp ) ( _exp ) 385 #if defined(__GNUC__) 386 #define RTEMS_PREDICT_FALSE( _exp ) __builtin_expect( ( _exp ), 0 ) 388 #define RTEMS_PREDICT_FALSE( _exp ) ( _exp ) 396 #if defined(__GNUC__) 397 #define RTEMS_RETURN_ADDRESS() __builtin_return_address( 0 ) 399 #define RTEMS_RETURN_ADDRESS() NULL 402 #if __cplusplus >= 201103L 403 #define RTEMS_STATIC_ASSERT(cond, msg) \ 404 static_assert(cond, # msg) 405 #elif __STDC_VERSION__ >= 201112L 406 #define RTEMS_STATIC_ASSERT(cond, msg) \ 407 _Static_assert(cond, # msg) 409 #define RTEMS_STATIC_ASSERT(cond, msg) \ 410 struct rtems_static_assert_ ## msg \ 411 { int rtems_static_assert_ ## msg : (cond) ? 1 : -1; } 414 #define RTEMS_ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) 421 #define RTEMS_ZERO_LENGTH_ARRAY 0 430 #define RTEMS_CONTAINER_OF( _m, _type, _member_name ) \ 431 ( (_type *) ( (uintptr_t) ( _m ) - offsetof( _type, _member_name ) ) ) 434 #define RTEMS_DEQUALIFY_DEPTHX( _ptr_level, _type, _var ) \ 435 (const_cast<_type>( _var )) 439 #define RTEMS_TYPEOF_REFX(_ptr_level, _ptr_type) \ 440 __typeof__(_ptr_level(union { int z; __typeof__(_ptr_type) x; }){0}.x) 442 #if defined(__GNUC__) && !defined(ASM) 443 #if ((__GNUC__ * 1000 + __GNUC_MINOR__) >= 4004) 444 extern void* RTEMS_DEQUALIFY_types_not_compatible(
void)
445 __attribute__((error (
"RTEMS_DEQUALIFY types differ not only by volatile and const")));
447 extern void RTEMS_DEQUALIFY_types_not_compatible(
void);
449 #define RTEMS_DEQUALIFY_DEPTHX( _ptr_level, _type, _var ) ( \ 450 __builtin_choose_expr( __builtin_types_compatible_p ( \ 451 RTEMS_TYPEOF_REFX( _ptr_level, _var ), \ 452 RTEMS_TYPEOF_REFX( _ptr_level, _type ) \ 453 ) || __builtin_types_compatible_p ( _type, void * ), \ 455 RTEMS_DEQUALIFY_types_not_compatible() \ 461 #ifndef RTEMS_DECONST 462 #ifdef RTEMS_DEQUALIFY_DEPTHX 463 #define RTEMS_DECONST( _type, _var ) \ 464 RTEMS_DEQUALIFY_DEPTHX( *, _type, _var ) 472 #define RTEMS_DECONST( _type, _var ) \ 473 ((_type)(uintptr_t)(const void *) ( _var )) 478 #ifndef RTEMS_DEVOLATILE 479 #ifdef RTEMS_DEQUALIFY_DEPTHX 480 #define RTEMS_DEVOLATILE( _type, _var ) \ 481 RTEMS_DEQUALIFY_DEPTHX( *, _type, _var ) 489 #define RTEMS_DEVOLATILE( _type, _var ) \ 490 ((_type)(uintptr_t)(volatile void *) ( _var )) 495 #ifndef RTEMS_DEQUALIFY 496 #ifdef RTEMS_DEQUALIFY_DEPTHX 497 #define RTEMS_DEQUALIFY( _type, _var ) \ 498 RTEMS_DEQUALIFY_DEPTHX( *, _type, _var ) 506 #define RTEMS_DEQUALIFY( _type, _var ) \ 507 ((_type)(uintptr_t)(const volatile void *) ( _var )) 521 #define RTEMS_HAVE_MEMBER_SAME_TYPE( _t_lhs, _m_lhs, _t_rhs, _m_rhs ) \ 522 __builtin_types_compatible_p( \ 523 __typeof__( ( (_t_lhs *) 0 )->_m_lhs ), \ 524 __typeof__( ( (_t_rhs *) 0 )->_m_rhs ) \ 527 #define RTEMS_HAVE_MEMBER_SAME_TYPE( _t_lhs, _m_lhs, _t_rhs, _m_rhs ) \ 534 #define RTEMS_CONCAT( _x, _y ) _x##_y 539 #define RTEMS_XCONCAT( _x, _y ) RTEMS_CONCAT( _x, _y ) 544 #define RTEMS_STRING( _x ) #_x 549 #define RTEMS_XSTRING( _x ) RTEMS_STRING( _x ) 552 #ifdef RTEMS_DEPRECATED_TYPES typedef __attribute__
Disable IRQ Interrupts.
Definition: cmsis_gcc.h:69
#define RTEMS_DEPRECATED
Public name for task floating point context area.
Definition: basedefs.h:141