RTEMS 6.1-rc5
Loading...
Searching...
No Matches
Macros
Base Definitions

This group contains basic macros and defines to give access to compiler-specific features. More...

Macros

#define RTEMS_ALIAS(_target)
 Instructs the compiler to generate an alias to the target function.
 
#define RTEMS_ALIGN_DOWN(_value, _alignment)    ( ( _value ) & ~( ( _alignment ) - 1 ) )
 Aligns down the value to the alignment.
 
#define RTEMS_ALIGN_UP(_value, _alignment)    ( ( ( _value ) + ( _alignment ) - 1 ) & ~( ( _alignment ) - 1 ) )
 Aligns up the value to the alignment.
 
#define RTEMS_ALIGNED(_alignment)
 Instructs the compiler in a declaration or definition to enforce the alignment.
 
#define RTEMS_ALIGNOF(_type_name)   sizeof( _type_name )
 Gets the alignment requirement of the type.
 
#define RTEMS_ALLOC_ALIGN(_index)
 Tells the compiler in a declaration that the memory allocation alignment parameter of this function is similar to aligned_alloc().
 
#define RTEMS_ALLOC_SIZE(_index)
 Tells the compiler in a declaration that the memory allocation size parameter of this function is similar to malloc().
 
#define RTEMS_ALLOC_SIZE_2(_count_index, _size_index)
 Tells the compiler in a declaration that the memory allocation item count and item size parameter of this function is similar to calloc().
 
#define RTEMS_ARRAY_SIZE(_array)    ( sizeof( _array ) / sizeof( ( _array )[ 0 ] ) )
 Gets the element count of the array.
 
#define RTEMS_COMPILER_MEMORY_BARRIER()   do { } while ( 0 )
 This macro forbids the compiler to reorder read and write commands around it.
 
#define RTEMS_CONCAT(_x, _y)   _x##_y
 Concatenates _x and _y without expanding.
 
#define RTEMS_CONST
 Tells the compiler in a function declaration that this function has no effect except the return value and that the return value depends only on the value of parameters.
 
#define RTEMS_CONTAINER_OF(_m, _type, _member_name)    ( (_type *) ( (uintptr_t) ( _m ) - offsetof( _type, _member_name ) ) )
 Gets the container of a member.
 
#define RTEMS_DECLARE_GLOBAL_SYMBOL(_name)   extern char _name[]
 Declares a global symbol with the name.
 
#define RTEMS_DEPRECATED
 Instructs the compiler in a declaration to issue a warning whenever a variable, function, or type using this declaration will be used.
 
#define RTEMS_COMPILER_DEPRECATED_ATTRIBUTE   RTEMS_DEPRECATED
 Provided for backward compatibility.
 
#define RTEMS_EXPAND(_token)   _token
 Helper macro to perform a macro expansion on the token.
 
#define RTEMS_FUNCTION_NAME   __func__
 Expands to the name of the function containing the use of this define.
 
#define RTEMS_NO_RETURN
 Tells the compiler in a function declaration that this function does not return.
 
#define RTEMS_COMPILER_NO_RETURN_ATTRIBUTE   RTEMS_NO_RETURN
 Provided for backward compatibility.
 
#define RTEMS_SECTION(_section)
 Instructs the compiler to place the variable or function in the section.
 
#define RTEMS_STRING(...)   #__VA_ARGS__
 Stringifies the arguments without expanding them.
 
#define RTEMS_TYPEOF_REFX(_level, _target)
 Gets the pointer reference type.
 
#define RTEMS_XCONCAT(_x, _y)   RTEMS_CONCAT( _x, _y )
 Concatenates expansion of _x and expansion of _y.
 
#define RTEMS_DEQUALIFY_DEPTHX(_ptr_level, _type, _var)    ( (_type) (uintptr_t) (const volatile void *)( _var ) )
 Performs a type cast which removes qualifiers without warnings to the type for the variable.
 
#define RTEMS_DECONST(_type, _var)   RTEMS_DEQUALIFY_DEPTHX( *, _type, _var )
 Performs a type cast which removes const qualifiers without warnings to the type for the pointer variable.
 
#define RTEMS_DEQUALIFY(_type, _var)   RTEMS_DEQUALIFY_DEPTHX( *, _type, _var )
 Performs a type cast which removes all qualifiers without warnings to the type for the pointer variable.
 
#define RTEMS_DEVOLATILE(_type, _var)   RTEMS_DEQUALIFY_DEPTHX( *, _type, _var )
 Performs a type cast which removes volatile qualifiers without warnings to the type for the pointer variable.
 
#define FALSE   0
 If FALSE is undefined, then FALSE is defined to 0.
 
#define RTEMS_HAVE_MEMBER_SAME_TYPE(_t_lhs, _m_lhs, _t_rhs, _m_rhs)   true
 Checks if members of two types have compatible types.
 
#define RTEMS_INLINE_ROUTINE   static inline
 Gives a hint to the compiler in a function declaration to inline this function.
 
#define RTEMS_MALLOCLIKE
 Tells the compiler in a declaration that this function is a memory allocation function similar to malloc().
 
#define RTEMS_NO_INLINE
 Instructs the compiler in a function declaration to not inline this function.
 
#define RTEMS_NOINIT   RTEMS_SECTION( ".noinit" )
 Instructs the compiler to place the variable in a section which is not initialized.
 
#define RTEMS_OBFUSCATE_VARIABLE(_var)   (void) ( _var )
 Obfuscates the variable so that the compiler cannot perform optimizations based on the variable value.
 
#define RTEMS_PACKED
 Instructs the compiler in a type definition to place members of a structure or union so that the memory required is minimized.
 
#define RTEMS_COMPILER_PACKED_ATTRIBUTE   RTEMS_PACKED
 Provided for backward compatibility.
 
#define RTEMS_PREDICT_FALSE(_exp)   ( _exp )
 Evaluates the integral expression and tells the compiler that the predicted value is false (0).
 
#define RTEMS_PREDICT_TRUE(_exp)   ( _exp )
 Evaluates the integral expression and tells the compiler that the predicted value is true (1).
 
#define RTEMS_PRINTFLIKE(_format_pos, _ap_pos)
 Tells the compiler in a declaration that this function expects printf()-like arguments.
 
#define RTEMS_PURE
 Tells the compiler in a function declaration that this function has no effect except the return value and that the return value depends only on the value of parameters and/or global variables.
 
#define RTEMS_COMPILER_PURE_ATTRIBUTE   RTEMS_PURE
 Provided for backward compatibility.
 
#define RTEMS_RETURN_ADDRESS()   NULL
 Gets the return address of the current function.
 
#define RTEMS_STATIC_ASSERT(_cond, _msg)
 It is defined if a static analysis run is performed.
 
#define RTEMS_SYMBOL_NAME(_name)   RTEMS_EXPAND( _name )
 Maps the name to the associated symbol name.
 
#define TRUE   1
 If TRUE is undefined, then TRUE is defined to 1.
 
#define RTEMS_UNREACHABLE()   do { } while ( 0 )
 Tells the compiler that this program point is unreachable.
 
#define RTEMS_UNUSED
 Tells the compiler that the variable or function is deliberately unused.
 
#define RTEMS_COMPILER_UNUSED_ATTRIBUTE   RTEMS_UNUSED
 Provided for backward compatibility.
 
#define RTEMS_USED
 Tells the compiler that the variable or function is used.
 
#define RTEMS_WARN_UNUSED_RESULT
 Tells the compiler in a declaration that the result of this function should be used.
 
#define RTEMS_WEAK
 Tells the compiler in a function definition that this function should be weak.
 
#define RTEMS_WEAK_ALIAS(_target)
 Instructs the compiler to generate a weak alias to the target function.
 
#define RTEMS_XSTRING(...)   RTEMS_STRING( __VA_ARGS__ )
 Stringifies the expansion of the arguments.
 
#define RTEMS_DEFINE_GLOBAL_SYMBOL(_name, _value)
 Defines a global symbol with the name and value.
 
#define RTEMS_ZERO_LENGTH_ARRAY   0
 This constant represents the element count of a zero-length array.
 

Detailed Description

This group contains basic macros and defines to give access to compiler-specific features.

Macro Definition Documentation

◆ RTEMS_ALIAS

#define RTEMS_ALIAS (   _target)

Instructs the compiler to generate an alias to the target function.

Parameters
_targetis the target function name.

◆ RTEMS_ALIGN_DOWN

#define RTEMS_ALIGN_DOWN (   _value,
  _alignment 
)     ( ( _value ) & ~( ( _alignment ) - 1 ) )

Aligns down the value to the alignment.

Parameters
_valueis the value to align down.
_alignmentis the desired alignment in bytes. The alignment shall be a power of two, otherwise the returned value is undefined. The alignment parameter is evaluated twice.
Returns
Returns the value aligned down to the alignment.

◆ RTEMS_ALIGN_UP

#define RTEMS_ALIGN_UP (   _value,
  _alignment 
)     ( ( ( _value ) + ( _alignment ) - 1 ) & ~( ( _alignment ) - 1 ) )

Aligns up the value to the alignment.

Parameters
_valueis the value to align up.
_alignmentis the desired alignment in bytes. The alignment shall be a power of two, otherwise the returned value is undefined. The alignment parameter is evaluated twice.
Returns
Returns the value aligned up to the alignment.

◆ RTEMS_ALIGNED

#define RTEMS_ALIGNED (   _alignment)

Instructs the compiler in a declaration or definition to enforce the alignment.

Parameters
_alignmentis the desired alignment in bytes.

◆ RTEMS_ALIGNOF

#define RTEMS_ALIGNOF (   _type_name)    sizeof( _type_name )

Gets the alignment requirement of the type.

Parameters
_type_nameis the type name to get the alignment requirement for.
Returns
Returns the alignment requirement of the type.

◆ RTEMS_ALLOC_ALIGN

#define RTEMS_ALLOC_ALIGN (   _index)

Tells the compiler in a declaration that the memory allocation alignment parameter of this function is similar to aligned_alloc().

Parameters
_indexis the allocation alignment parameter index (starting with one).

◆ RTEMS_ALLOC_SIZE

#define RTEMS_ALLOC_SIZE (   _index)

Tells the compiler in a declaration that the memory allocation size parameter of this function is similar to malloc().

Parameters
_indexis the allocation size parameter index (starting with one).

◆ RTEMS_ALLOC_SIZE_2

#define RTEMS_ALLOC_SIZE_2 (   _count_index,
  _size_index 
)

Tells the compiler in a declaration that the memory allocation item count and item size parameter of this function is similar to calloc().

Parameters
_count_indexis the allocation item count parameter index (starting with one).
_size_indexis the allocation item size parameter index (starting with one).

◆ RTEMS_ARRAY_SIZE

#define RTEMS_ARRAY_SIZE (   _array)     ( sizeof( _array ) / sizeof( ( _array )[ 0 ] ) )

Gets the element count of the array.

Parameters
_arrayis the name of the array. This parameter is evaluated twice.
Returns
Returns the element count of the array.

◆ RTEMS_CONCAT

#define RTEMS_CONCAT (   _x,
  _y 
)    _x##_y

Concatenates _x and _y without expanding.

Parameters
_xis the left hand side token of the concatenation.
_yis the right hand side token of the concatenation.
Returns
Returns the concatenation of the tokens _x and _y.

◆ RTEMS_CONTAINER_OF

#define RTEMS_CONTAINER_OF (   _m,
  _type,
  _member_name 
)     ( (_type *) ( (uintptr_t) ( _m ) - offsetof( _type, _member_name ) ) )

Gets the container of a member.

Parameters
_mis the pointer to a member of the container.
_typeis the type of the container.
_member_nameis the designator name of the container member.
Returns
Returns the pointer to the container of a member pointer.

◆ RTEMS_DECLARE_GLOBAL_SYMBOL

#define RTEMS_DECLARE_GLOBAL_SYMBOL (   _name)    extern char _name[]

Declares a global symbol with the name.

Parameters
_nameis the name of the global symbol. It shall be a valid designator.

This macro must be placed at file scope.

◆ RTEMS_DECONST

#define RTEMS_DECONST (   _type,
  _var 
)    RTEMS_DEQUALIFY_DEPTHX( *, _type, _var )

Performs a type cast which removes const qualifiers without warnings to the type for the pointer variable.

Parameters
_typeis the target type of the cast.
_varis the pointer variable.

◆ RTEMS_DEFINE_GLOBAL_SYMBOL

#define RTEMS_DEFINE_GLOBAL_SYMBOL (   _name,
  _value 
)

Defines a global symbol with the name and value.

Parameters
_nameis the user defined name of the symbol. The name shall be a valid designator. On the name a macro expansion is performed and afterwards it is stringified.
_valueis 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. The value shall be representable in the code model of the target architecture.

This macro shall be placed at file scope.

◆ RTEMS_DEQUALIFY

#define RTEMS_DEQUALIFY (   _type,
  _var 
)    RTEMS_DEQUALIFY_DEPTHX( *, _type, _var )

Performs a type cast which removes all qualifiers without warnings to the type for the pointer variable.

Parameters
_typeis the target type of the cast.
_varis the pointer variable.

◆ RTEMS_DEQUALIFY_DEPTHX

#define RTEMS_DEQUALIFY_DEPTHX (   _ptr_level,
  _type,
  _var 
)     ( (_type) (uintptr_t) (const volatile void *)( _var ) )

Performs a type cast which removes qualifiers without warnings to the type for the variable.

Parameters
_ptr_levelis the pointer indirection level expressed in *.
_typeis the target type of the cast.
_varis the variable.

◆ RTEMS_DEVOLATILE

#define RTEMS_DEVOLATILE (   _type,
  _var 
)    RTEMS_DEQUALIFY_DEPTHX( *, _type, _var )

Performs a type cast which removes volatile qualifiers without warnings to the type for the pointer variable.

Parameters
_typeis the target type of the cast.
_varis the pointer variable.

◆ RTEMS_EXPAND

#define RTEMS_EXPAND (   _token)    _token

Helper macro to perform a macro expansion on the token.

Parameters
_tokenis the token to expand.

◆ RTEMS_HAVE_MEMBER_SAME_TYPE

#define RTEMS_HAVE_MEMBER_SAME_TYPE (   _t_lhs,
  _m_lhs,
  _t_rhs,
  _m_rhs 
)    true

Checks if members of two types have compatible types.

Parameters
_t_lhsis the left hand side type.
_m_lhsis the left hand side member.
_t_rhsis the right hand side type.
_m_rhsis the right hand side member.
Returns
Returns to true, if the members of two types have compatible types, otherwise false.

◆ RTEMS_OBFUSCATE_VARIABLE

#define RTEMS_OBFUSCATE_VARIABLE (   _var)    (void) ( _var )

Obfuscates the variable so that the compiler cannot perform optimizations based on the variable value.

Parameters
_varis the variable to obfuscate.

The variable must be simple enough to fit into a register.

◆ RTEMS_PREDICT_FALSE

#define RTEMS_PREDICT_FALSE (   _exp)    ( _exp )

Evaluates the integral expression and tells the compiler that the predicted value is false (0).

Parameters
_expis the integral expression.
Returns
Returns the value of the integral expression and tells the compiler that the predicted value is false (0).

◆ RTEMS_PREDICT_TRUE

#define RTEMS_PREDICT_TRUE (   _exp)    ( _exp )

Evaluates the integral expression and tells the compiler that the predicted value is true (1).

Parameters
_expis the integral expression.
Returns
Returns the value of the integral expression and tells the compiler that the predicted value is true (1).

◆ RTEMS_PRINTFLIKE

#define RTEMS_PRINTFLIKE (   _format_pos,
  _ap_pos 
)

Tells the compiler in a declaration that this function expects printf()-like arguments.

Parameters
_format_posis the position of the format parameter index (starting with one).
_ap_posis the position of the argument pointer parameter index (starting with one).

◆ RTEMS_RETURN_ADDRESS

#define RTEMS_RETURN_ADDRESS ( )    NULL

Gets the return address of the current function.

Returns
Returns the return address of the current function.

◆ RTEMS_SECTION

#define RTEMS_SECTION (   _section)

Instructs the compiler to place the variable or function in the section.

Parameters
_sectionis the section name as a string.

◆ RTEMS_STATIC_ASSERT

#define RTEMS_STATIC_ASSERT (   _cond,
  _msg 
)
Value:
struct rtems_static_assert_ ## _msg \
{ int rtems_static_assert_ ## _msg : ( _cond ) ? 1 : -1; }

It is defined if a static analysis run is performed.

Asserts at compile time that the condition is satisfied.

Parameters
_condis the condition this static assertion shall satisfy.
_msgis the error message in case the static assertion fails.

◆ RTEMS_STRING

#define RTEMS_STRING (   ...)    #__VA_ARGS__

Stringifies the arguments without expanding them.

Parameters
...are the arguments to stringify.
Returns
Returns the stringification of the arguments. In case of several arguments a single string is returned not several.

◆ RTEMS_SYMBOL_NAME

#define RTEMS_SYMBOL_NAME (   _name)    RTEMS_EXPAND( _name )

Maps the name to the associated symbol name.

Parameters
_nameis the user defined name of the symbol. The name shall be a valid designator. On the name a macro expansion is performed.
Returns
Returns the symbol name associated with the name.

◆ RTEMS_TYPEOF_REFX

#define RTEMS_TYPEOF_REFX (   _level,
  _target 
)

Gets the pointer reference type.

Parameters
_levelis the pointer indirection level expressed in *.
_targetis the reference target type.

The reference type idea is based on libHX by Jan Engelhardt.

Returns
Returns the type of a pointer reference of the specified level to the specified type.

◆ RTEMS_WEAK

#define RTEMS_WEAK

Tells the compiler in a function definition that this function should be weak.

Use this attribute for function definitions. Do not use it for function declarations.

◆ RTEMS_WEAK_ALIAS

#define RTEMS_WEAK_ALIAS (   _target)

Instructs the compiler to generate a weak alias to the target function.

Parameters
_targetis the target function name.

◆ RTEMS_XCONCAT

#define RTEMS_XCONCAT (   _x,
  _y 
)    RTEMS_CONCAT( _x, _y )

Concatenates expansion of _x and expansion of _y.

Parameters
_xis expanded first and then used as the left hand side token of the concatenation.
_yis expanded first and then used as the right hand side token of the concatenation.
Returns
Returns the concatenation of the expansions of tokens _x and _y.

◆ RTEMS_XSTRING

#define RTEMS_XSTRING (   ...)    RTEMS_STRING( __VA_ARGS__ )

Stringifies the expansion of the arguments.

Parameters
...are the arguments to expand and stringify.
Returns
Returns the stringification of the expansion of the arguments. In case of several arguments a single string is returned not several.

◆ RTEMS_ZERO_LENGTH_ARRAY

#define RTEMS_ZERO_LENGTH_ARRAY   0

This constant represents the element count of a zero-length array.

Zero-length arrays are valid in C99 as flexible array members. C++11 does not allow flexible array members. Use the GNU extension which is also supported by other compilers.