58#ifndef _RTEMS_SCORE_BASEDEFS_H
59#define _RTEMS_SCORE_BASEDEFS_H
61#include <rtems/score/cpuopts.h>
103 #define RTEMS_ALIAS( _target ) __attribute__(( __alias__( #_target ) ))
105 #define RTEMS_ALIAS( _target )
123#define RTEMS_ALIGN_DOWN( _value, _alignment ) \
124 ( ( _value ) & ~( ( _alignment ) - 1 ) )
141#define RTEMS_ALIGN_UP( _value, _alignment ) \
142 ( ( ( _value ) + ( _alignment ) - 1 ) & ~( ( _alignment ) - 1 ) )
155 #define RTEMS_ALIGNED( _alignment ) __attribute__(( __aligned__( _alignment ) ))
157 #define RTEMS_ALIGNED( _alignment )
171#if defined( __cplusplus ) && __cplusplus >= 201103L
172 #define RTEMS_ALIGNOF( _type_name ) alignof( _type_name )
173#elif defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 201112L
174 #define RTEMS_ALIGNOF( _type_name ) _Alignof( _type_name )
176 #define RTEMS_ALIGNOF( _type_name ) sizeof( _type_name )
191 #define RTEMS_ALLOC_ALIGN( _index ) __attribute__(( __alloc_align__( _index ) ))
193 #define RTEMS_ALLOC_ALIGN( _index )
207 #define RTEMS_ALLOC_SIZE( _index ) __attribute__(( __alloc_size__( _index ) ))
209 #define RTEMS_ALLOC_SIZE( _index )
227 #define RTEMS_ALLOC_SIZE_2( _count_index, _size_index ) \
228 __attribute__(( __alloc_size__( _count_index, _size_index ) ))
230 #define RTEMS_ALLOC_SIZE_2( _count_index, _size_index )
244#define RTEMS_ARRAY_SIZE( _array ) \
245 ( sizeof( _array ) / sizeof( ( _array )[ 0 ] ) )
256 #define RTEMS_COMPILER_MEMORY_BARRIER() __asm__ volatile( "" ::: "memory" )
258 #define RTEMS_COMPILER_MEMORY_BARRIER() do { } while ( 0 )
274#define RTEMS_CONCAT( _x, _y ) _x##_y
286 #define RTEMS_CONST __attribute__(( __const__ ))
306#define RTEMS_CONTAINER_OF( _m, _type, _member_name ) \
307 ( (_type *) ( (uintptr_t) ( _m ) - offsetof( _type, _member_name ) ) )
321#define RTEMS_DECLARE_GLOBAL_SYMBOL( _name ) extern char _name[]
332 #define RTEMS_DEPRECATED __attribute__(( __deprecated__ ))
334 #define RTEMS_DEPRECATED
344#define RTEMS_COMPILER_DEPRECATED_ATTRIBUTE RTEMS_DEPRECATED
355#define RTEMS_EXPAND( _token ) _token
365#if defined(__cplusplus) && defined(__GNUC__)
366 #define RTEMS_FUNCTION_NAME __PRETTY_FUNCTION__
368 #define RTEMS_FUNCTION_NAME __func__
379#if defined( __cplusplus ) && __cplusplus >= 201103L
380 #define RTEMS_NO_RETURN [[noreturn]]
381#elif defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 201112L
382 #define RTEMS_NO_RETURN _Noreturn
383#elif defined(__GNUC__)
384 #define RTEMS_NO_RETURN __attribute__(( __noreturn__ ))
386 #define RTEMS_NO_RETURN
396#define RTEMS_COMPILER_NO_RETURN_ATTRIBUTE RTEMS_NO_RETURN
409 #define RTEMS_SECTION( _section ) __attribute__(( __section__( _section ) ))
411 #define RTEMS_SECTION( _section )
426#define RTEMS_STRING( ... ) #__VA_ARGS__
445 #define RTEMS_TYPEOF_REFX( _level, _target ) \
446 __typeof__( _level( union { int _z; __typeof__( _target ) _x; } ){ 0 }._x )
448 #define RTEMS_TYPEOF_REFX( _level, _target )
466#define RTEMS_XCONCAT( _x, _y ) RTEMS_CONCAT( _x, _y )
468#if !defined(ASM) && defined(RTEMS_DEBUG)
498 #if defined(__GNUC__)
499 __attribute__((__error__(
"RTEMS_DEQUALIFY() types differ not only by volatile and const"))) void *
520#if defined(__cplusplus)
521 #define RTEMS_DEQUALIFY_DEPTHX( _ptr_level, _type, _var ) \
522 ( const_cast<_type>( _var ) )
523#elif defined(__GNUC__)
524 #define RTEMS_DEQUALIFY_DEPTHX( _ptr_level, _type, _var ) \
525 __builtin_choose_expr( \
526 __builtin_types_compatible_p( \
527 RTEMS_TYPEOF_REFX( _ptr_level, _var ), \
528 RTEMS_TYPEOF_REFX( _ptr_level, _type ) \
530 __builtin_types_compatible_p( \
535 RTEMS_DEQUALIFY_types_not_compatible() \
538 #define RTEMS_DEQUALIFY_DEPTHX( _ptr_level, _type, _var ) \
539 ( (_type) (uintptr_t) (const volatile void *)( _var ) )
554#define RTEMS_DECONST( _type, _var ) RTEMS_DEQUALIFY_DEPTHX( *, _type, _var )
568#define RTEMS_DEQUALIFY( _type, _var ) RTEMS_DEQUALIFY_DEPTHX( *, _type, _var )
582#define RTEMS_DEVOLATILE( _type, _var ) RTEMS_DEQUALIFY_DEPTHX( *, _type, _var )
601#if defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 202311L
602 #define RTEMS_FALL_THROUGH() [[fallthrough]]
603#elif defined(__GNUC__)
604 #define RTEMS_FALL_THROUGH() __attribute__(( __fallthrough__ ))
606 #define RTEMS_FALL_THROUGH() do {} while ( 0 )
639 #define RTEMS_HAVE_MEMBER_SAME_TYPE( _t_lhs, _m_lhs, _t_rhs, _m_rhs ) \
640 __builtin_types_compatible_p( \
641 __typeof__( ( (_t_lhs *) 0 )->_m_lhs ), \
642 __typeof__( ( (_t_rhs *) 0 )->_m_rhs ) \
645 #define RTEMS_HAVE_MEMBER_SAME_TYPE( _t_lhs, _m_lhs, _t_rhs, _m_rhs ) true
657 #define RTEMS_INLINE_ROUTINE static __inline__
659 #define RTEMS_INLINE_ROUTINE static inline
671 #define RTEMS_MALLOCLIKE __attribute__(( __malloc__ ))
673 #define RTEMS_MALLOCLIKE
685 #define RTEMS_NO_INLINE __attribute__(( __noinline__ ))
687 #define RTEMS_NO_INLINE
698#define RTEMS_NOINIT RTEMS_SECTION( ".noinit" )
713 #define RTEMS_OBFUSCATE_VARIABLE( _var ) __asm__( "" : "+r" ( _var ) )
715 #define RTEMS_OBFUSCATE_VARIABLE( _var ) (void) ( _var )
727 #define RTEMS_PACKED __attribute__(( __packed__ ))
739#define RTEMS_COMPILER_PACKED_ATTRIBUTE RTEMS_PACKED
755 #define RTEMS_PREDICT_FALSE( _exp ) __builtin_expect( ( _exp ), 0 )
757 #define RTEMS_PREDICT_FALSE( _exp ) ( _exp )
774 #define RTEMS_PREDICT_TRUE( _exp ) __builtin_expect( ( _exp ), 1 )
776 #define RTEMS_PREDICT_TRUE( _exp ) ( _exp )
794 #define RTEMS_PRINTFLIKE( _format_pos, _ap_pos ) \
795 __attribute__(( __format__( __printf__, _format_pos, _ap_pos ) ))
797 #define RTEMS_PRINTFLIKE( _format_pos, _ap_pos )
810 #define RTEMS_PURE __attribute__(( __pure__ ))
822#define RTEMS_COMPILER_PURE_ATTRIBUTE RTEMS_PURE
834 #define RTEMS_RETURN_ADDRESS() __builtin_return_address( 0 )
836 #define RTEMS_RETURN_ADDRESS() NULL
846#if defined(__COVERITY__)
847 #define RTEMS_STATIC_ANALYSIS
861#if defined( __cplusplus ) && __cplusplus >= 201103L
862 #define RTEMS_STATIC_ASSERT( _cond, _msg ) static_assert( _cond, # _msg )
863#elif defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 201112L
864 #define RTEMS_STATIC_ASSERT( _cond, _msg ) _Static_assert( _cond, # _msg )
866 #define RTEMS_STATIC_ASSERT( _cond, _msg ) \
867 struct rtems_static_assert_ ## _msg \
868 { int rtems_static_assert_ ## _msg : ( _cond ) ? 1 : -1; }
883#if defined(__USER_LABEL_PREFIX__)
884 #define RTEMS_SYMBOL_NAME( _name ) RTEMS_XCONCAT( __USER_LABEL_PREFIX__, _name )
886 #define RTEMS_SYMBOL_NAME( _name ) RTEMS_EXPAND( _name )
907#if defined(RTEMS_DEBUG)
908 #define RTEMS_UNREACHABLE() \
909 _Debug_Unreachable( __FILE__, __LINE__, RTEMS_FUNCTION_NAME )
910#elif defined(__GNUC__)
911 #define RTEMS_UNREACHABLE() __builtin_unreachable()
913 #define RTEMS_UNREACHABLE() do { } while ( 0 )
925 #define RTEMS_UNUSED __attribute__(( __unused__ ))
937#define RTEMS_COMPILER_UNUSED_ATTRIBUTE RTEMS_UNUSED
947 #define RTEMS_USED __attribute__(( __used__ ))
961 #define RTEMS_WARN_UNUSED_RESULT __attribute__(( __warn_unused_result__ ))
963 #define RTEMS_WARN_UNUSED_RESULT
978 #define RTEMS_WEAK __attribute__(( __weak__ ))
994 #define RTEMS_WEAK_ALIAS( _target ) \
995 __attribute__(( __weak__, __alias__( #_target ) ))
997 #define RTEMS_WEAK_ALIAS( _target )
1012#define RTEMS_XSTRING( ... ) RTEMS_STRING( __VA_ARGS__ )
1032#if defined(__GNUC__)
1033 #define RTEMS_DEFINE_GLOBAL_SYMBOL( _name, _value ) \
1035 "\t.globl " RTEMS_XSTRING( RTEMS_SYMBOL_NAME( _name ) ) \
1036 "\n\t.set " RTEMS_XSTRING( RTEMS_SYMBOL_NAME( _name ) ) \
1037 ", " RTEMS_STRING( _value ) "\n" \
1040 #define RTEMS_DEFINE_GLOBAL_SYMBOL( _name, _value )
1054#if __STDC_VERSION__ >= 199409L
1055 #define RTEMS_ZERO_LENGTH_ARRAY
1057 #define RTEMS_ZERO_LENGTH_ARRAY 0
#define RTEMS_NO_RETURN
Tells the compiler in a function declaration that this function does not return.
Definition: basedefs.h:386
void * RTEMS_DEQUALIFY_types_not_compatible(void)
A not implemented function to trigger compile time errors with an error message.
Definition: xnandpsu_onfi.h:185