RTEMS
|
This group contains basic macros and defines to give access to compiler-specific features. More...
Files | |
file | basedefs.h |
This header file provides basic definitions used by the API and the implementation. | |
Macros | |
#define | RTEMS_CONCAT(_x, _y) _x##_y |
Concatenates _x and _y without expanding. More... | |
#define | RTEMS_TYPEOF_REFX(_level, _target) __typeof__(_level(union { int z; __typeof__(_target) x; }){0}.x) |
Returns the type of a pointer reference of the specified level to the specified type. More... | |
#define | RTEMS_STRING(_x) #_x |
Stringifies _x without expanding. More... | |
#define | RTEMS_XCONCAT(_x, _y) RTEMS_CONCAT( _x, _y ) |
Concatenates expansion of _x and expansion of _y. More... | |
#define | RTEMS_EXPAND(_token) _token |
Helper macro to perform a macro expansion on the specified token. More... | |
#define | RTEMS_DEPRECATED __attribute__((__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_NO_RETURN __attribute__((__noreturn__)) |
Tells the compiler in a function declaration that this function does not return. | |
#define | RTEMS_PACKED __attribute__((__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_PURE __attribute__((__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_USED __attribute__((__used__)) |
Tells the compiler that a specific variable or function is used. | |
#define | RTEMS_DEQUALIFY_DEPTHX(_ptr_level, _type, _var) |
Performs a type cast which removes qualifiers without warnings to the specified type for the specified variable. More... | |
#define | RTEMS_XSTRING(_x) RTEMS_STRING( _x ) |
Stringifies the expansion of _x. More... | |
#define | RTEMS_SYMBOL_NAME(_name) RTEMS_EXPAND(_name) |
Constructs a symbol name. More... | |
#define | RTEMS_ALIAS(_target) __attribute__((__alias__(#_target))) |
Instructs the compiler to generate an alias to the specified target function. More... | |
#define | RTEMS_ALIGN_DOWN(_value, _alignment) ( ( _value ) & ~( ( _alignment ) - 1 ) ) |
Returns the specified value aligned down to the specified alignment. More... | |
#define | RTEMS_ALIGN_UP(_value, _alignment) ( ( ( _value ) + ( _alignment ) - 1 ) & ~( ( _alignment ) - 1 ) ) |
Returns the specified value aligned up to the specified alignment. More... | |
#define | RTEMS_ALIGNED(_alignment) __attribute__((__aligned__(_alignment))) |
Instructs the compiler in a declaration or definition to enforce the specified alignment. More... | |
#define | RTEMS_ALLOC_ALIGN(_index) __attribute__((__alloc_align__(_index))) |
Tells the compiler in a declaration that the memory allocation alignment parameter of this function is similar to aligned_alloc(). More... | |
#define | RTEMS_ALLOC_SIZE(_index) __attribute__((__alloc_size__(_index))) |
Tells the compiler in a declaration that the memory allocation size parameter of this function is similar to malloc(). More... | |
#define | RTEMS_ALLOC_SIZE_2(_count_index, _size_index) __attribute__((__alloc_size__(_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(). More... | |
#define | RTEMS_ARRAY_SIZE(_array) (sizeof(_array) / sizeof((_array)[0])) |
Returns the element count of the specified array. More... | |
#define | RTEMS_COMPILER_DEPRECATED_ATTRIBUTE RTEMS_DEPRECATED |
Provided for backward compatibility. | |
#define | RTEMS_COMPILER_MEMORY_BARRIER() __asm__ volatile( "" ::: "memory" ) |
This macro forbids the compiler to reorder read and write commands around it. | |
#define | RTEMS_COMPILER_NO_RETURN_ATTRIBUTE RTEMS_NO_RETURN |
Provided for backward compatibility. | |
#define | RTEMS_COMPILER_PACKED_ATTRIBUTE RTEMS_PACKED |
Provided for backward compatibility. | |
#define | RTEMS_COMPILER_PURE_ATTRIBUTE RTEMS_PURE |
Provided for backward compatibility. | |
#define | RTEMS_COMPILER_USED_ATTRIBUTE RTEMS_USED |
Provided for backward compatibility. | |
#define | RTEMS_CONST __attribute__((__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 ) ) ) |
Returns the pointer to the container of a specified member pointer. More... | |
#define | RTEMS_DECLARE_GLOBAL_SYMBOL(_name) extern char _name[] |
Declares a global symbol with the specified name. More... | |
#define | RTEMS_DECONST(_type, _var) RTEMS_DEQUALIFY_DEPTHX(*, _type, _var) |
Performs a type cast which removes const qualifiers without warnings to the specified type for the specified pointer variable. More... | |
#define | RTEMS_DEFINE_GLOBAL_SYMBOL(_name, _value) |
Defines a global symbol with the specified name and value. More... | |
#define | RTEMS_DEQUALIFY(_type, _var) RTEMS_DEQUALIFY_DEPTHX(*, _type, _var) |
Performs a type cast which removes all qualifiers without warnings to the specified type for the specified pointer variable. More... | |
#define | RTEMS_DEVOLATILE(_type, _var) RTEMS_DEQUALIFY_DEPTHX(*, _type, _var) |
Performs a type cast which removes volatile qualifiers without warnings to the specified type for the specified pointer variable. More... | |
#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) |
Evaluates to true if the specified members of two types have compatible types, otherwise to false. More... | |
#define | RTEMS_INLINE_ROUTINE static __inline__ |
Gives a hint to the compiler in a function declaration to inline this function. | |
#define | RTEMS_MALLOCLIKE __attribute__((__malloc__)) |
Tells the compiler in a declaration that this function is a memory allocation function similar to malloc(). | |
#define | RTEMS_NO_INLINE __attribute__((__noinline__)) |
Instructs the compiler in a function declaration to not inline this function. | |
#define | RTEMS_OBFUSCATE_VARIABLE(_var) __asm__( "" : "+r" ( _var ) ) |
Obfuscates the variable so that the compiler cannot perform optimizations based on the variable value. More... | |
#define | RTEMS_PREDICT_FALSE(_exp) __builtin_expect( ( _exp ), 0 ) |
Returns the value of the specified integral expression and tells the compiler that the predicted value is false (1). More... | |
#define | RTEMS_PREDICT_TRUE(_exp) __builtin_expect( ( _exp ), 1 ) |
Returns the value of the specified integral expression and tells the compiler that the predicted value is true (1). More... | |
#define | RTEMS_PRINTFLIKE(_format_pos, _ap_pos) __attribute__((__format__(__printf__, _format_pos, _ap_pos))) |
Tells the compiler in a declaration that this function expects printf()-like arguments. More... | |
#define | RTEMS_RETURN_ADDRESS() __builtin_return_address(0) |
Returns the return address of the current function. More... | |
#define | RTEMS_SECTION(_section) __attribute__((__section__(_section))) |
Instructs the compiler to place a specific variable or function in the specified section. More... | |
#define | RTEMS_STATIC_ASSERT(_cond, _msg) |
Asserts at compile time that the specified condition is satisfied. More... | |
#define | TRUE 1 |
If TRUE is undefined, then TRUE is defined to 1. | |
#define | RTEMS_UNUSED __attribute__((__unused__)) |
Tells the compiler that a specific variable or function is deliberately unused. | |
#define | RTEMS_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) |
Tells the compiler in a declaration that the result of this function should be used. | |
#define | RTEMS_WEAK __attribute__((__weak__)) |
Tells the compiler in a function definition that this function should be weak. More... | |
#define | RTEMS_WEAK_ALIAS(_target) __attribute__((__weak__, __alias__(#_target))) |
Instructs the compiler to generate a weak alias to the specified target function. More... | |
#define | RTEMS_ZERO_LENGTH_ARRAY 0 |
This is a constant to declare zero-length arrays. More... | |
This group contains basic macros and defines to give access to compiler-specific features.
#define RTEMS_ALIAS | ( | _target | ) | __attribute__((__alias__(#_target))) |
Instructs the compiler to generate an alias to the specified target function.
_target | is the target function name. |
Definition at line 335 of file basedefs.h.
#define RTEMS_ALIGN_DOWN | ( | _value, | |
_alignment | |||
) | ( ( _value ) & ~( ( _alignment ) - 1 ) ) |
Returns the specified value aligned down to the specified alignment.
_value | is the value to align down. |
_alignment | is 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. |
Definition at line 356 of file basedefs.h.
#define RTEMS_ALIGN_UP | ( | _value, | |
_alignment | |||
) | ( ( ( _value ) + ( _alignment ) - 1 ) & ~( ( _alignment ) - 1 ) ) |
Returns the specified value aligned up to the specified alignment.
_value | is the value to align up. |
_alignment | is 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. |
Definition at line 375 of file basedefs.h.
#define RTEMS_ALIGNED | ( | _alignment | ) | __attribute__((__aligned__(_alignment))) |
Instructs the compiler in a declaration or definition to enforce the specified alignment.
_alignment | is the desired alignment in bytes. |
Definition at line 389 of file basedefs.h.
#define RTEMS_ALLOC_ALIGN | ( | _index | ) | __attribute__((__alloc_align__(_index))) |
Tells the compiler in a declaration that the memory allocation alignment parameter of this function is similar to aligned_alloc().
_index | is the allocation alignment parameter index (starting with one). |
Definition at line 406 of file basedefs.h.
#define RTEMS_ALLOC_SIZE | ( | _index | ) | __attribute__((__alloc_size__(_index))) |
Tells the compiler in a declaration that the memory allocation size parameter of this function is similar to malloc().
_index | is the allocation size parameter index (starting with one). |
Definition at line 422 of file basedefs.h.
#define RTEMS_ALLOC_SIZE_2 | ( | _count_index, | |
_size_index | |||
) | __attribute__((__alloc_size__(_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().
_count_index | is the allocation item count parameter index (starting with one). |
_size_index | is the allocation item size parameter index (starting with one). |
Definition at line 442 of file basedefs.h.
#define RTEMS_ARRAY_SIZE | ( | _array | ) | (sizeof(_array) / sizeof((_array)[0])) |
Returns the element count of the specified array.
_array | is the name of the array. |
Definition at line 459 of file basedefs.h.
#define RTEMS_CONCAT | ( | _x, | |
_y | |||
) | _x##_y |
Concatenates _x and _y without expanding.
_x | is the left hand side token of the concatenation. |
_y | is the right hand side token of the concatenation. |
Definition at line 105 of file basedefs.h.
#define RTEMS_CONTAINER_OF | ( | _m, | |
_type, | |||
_member_name | |||
) | ( (_type *) ( (uintptr_t) ( _m ) - offsetof( _type, _member_name ) ) ) |
Returns the pointer to the container of a specified member pointer.
_m | is the pointer to a member of the container. |
_type | is the type of the container. |
_member_name | is the designator name of the container member. |
Definition at line 550 of file basedefs.h.
#define RTEMS_DECLARE_GLOBAL_SYMBOL | ( | _name | ) | extern char _name[] |
Declares a global symbol with the specified name.
This macro must be placed at file scope.
_name | is the name of the global symbol. It shall be a valid designator. |
Definition at line 565 of file basedefs.h.
#define RTEMS_DECONST | ( | _type, | |
_var | |||
) | RTEMS_DEQUALIFY_DEPTHX(*, _type, _var) |
Performs a type cast which removes const qualifiers without warnings to the specified type for the specified pointer variable.
_type | is the target type of the cast. |
_var | is the pointer variable. |
Definition at line 579 of file basedefs.h.
#define RTEMS_DEFINE_GLOBAL_SYMBOL | ( | _name, | |
_value | |||
) |
Defines a global symbol with the specified name and value.
This macro shall be placed at file scope.
_name | is 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. |
_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. |
Definition at line 606 of file basedefs.h.
#define RTEMS_DEQUALIFY | ( | _type, | |
_var | |||
) | RTEMS_DEQUALIFY_DEPTHX(*, _type, _var) |
Performs a type cast which removes all qualifiers without warnings to the specified type for the specified pointer variable.
_type | is the target type of the cast. |
_var | is the pointer variable. |
Definition at line 621 of file basedefs.h.
#define RTEMS_DEQUALIFY_DEPTHX | ( | _ptr_level, | |
_type, | |||
_var | |||
) |
Performs a type cast which removes qualifiers without warnings to the specified type for the specified variable.
_ptr_level | is the pointer indirection level expressed in *. |
_type | is the target type of the cast. |
_var | is the variable. |
Definition at line 272 of file basedefs.h.
#define RTEMS_DEVOLATILE | ( | _type, | |
_var | |||
) | RTEMS_DEQUALIFY_DEPTHX(*, _type, _var) |
Performs a type cast which removes volatile qualifiers without warnings to the specified type for the specified pointer variable.
_type | is the target type of the cast. |
_var | is the pointer variable. |
Definition at line 635 of file basedefs.h.
#define RTEMS_EXPAND | ( | _token | ) | _token |
Helper macro to perform a macro expansion on the specified token.
_token | is the token to expand. |
Definition at line 182 of file basedefs.h.
#define RTEMS_HAVE_MEMBER_SAME_TYPE | ( | _t_lhs, | |
_m_lhs, | |||
_t_rhs, | |||
_m_rhs | |||
) |
Evaluates to true if the specified members of two types have compatible types, otherwise to false.
_t_lhs | is the left hand side type. |
_m_lhs | is the left hand side member. |
_t_rhs | is the right hand side type. |
_m_rhs | is the right hand side member. |
Definition at line 665 of file basedefs.h.
#define RTEMS_OBFUSCATE_VARIABLE | ( | _var | ) | __asm__( "" : "+r" ( _var ) ) |
Obfuscates the variable so that the compiler cannot perform optimizations based on the variable value.
The variable must be simple enough to fit into a register.
_var | is the variable to obfuscate. |
Definition at line 729 of file basedefs.h.
#define RTEMS_PREDICT_FALSE | ( | _exp | ) | __builtin_expect( ( _exp ), 0 ) |
Returns the value of the specified integral expression and tells the compiler that the predicted value is false (1).
_exp | is the expression. |
Definition at line 747 of file basedefs.h.
#define RTEMS_PREDICT_TRUE | ( | _exp | ) | __builtin_expect( ( _exp ), 1 ) |
Returns the value of the specified integral expression and tells the compiler that the predicted value is true (1).
_exp | is the expression. |
Definition at line 765 of file basedefs.h.
#define RTEMS_PRINTFLIKE | ( | _format_pos, | |
_ap_pos | |||
) | __attribute__((__format__(__printf__, _format_pos, _ap_pos))) |
Tells the compiler in a declaration that this function expects printf()-like arguments.
_format_pos | is the position of the format parameter index (starting with one). |
_ap_pos | is the position of the argument pointer parameter index (starting with one). |
Definition at line 785 of file basedefs.h.
#define RTEMS_RETURN_ADDRESS | ( | ) | __builtin_return_address(0) |
Returns the return address of the current function.
Definition at line 801 of file basedefs.h.
#define RTEMS_SECTION | ( | _section | ) | __attribute__((__section__(_section))) |
Instructs the compiler to place a specific variable or function in the specified section.
_section | is the section name as a string. |
Definition at line 817 of file basedefs.h.
#define RTEMS_STATIC_ASSERT | ( | _cond, | |
_msg | |||
) |
Asserts at compile time that the specified condition is satisfied.
_cond | is the condition this static assertion shall satisfy. |
_msg | is the error message in case the static assertion fails. |
Definition at line 838 of file basedefs.h.
#define RTEMS_STRING | ( | _x | ) | #_x |
Stringifies _x without expanding.
_x | is the token to stringify. |
Definition at line 154 of file basedefs.h.
#define RTEMS_SYMBOL_NAME | ( | _name | ) | RTEMS_EXPAND(_name) |
Constructs a symbol name.
_name | is the user defined name of the symbol. The name shall be a valid designator. On the name a macro expansion is performed. |
Definition at line 310 of file basedefs.h.
#define RTEMS_TYPEOF_REFX | ( | _level, | |
_target | |||
) | __typeof__(_level(union { int z; __typeof__(_target) x; }){0}.x) |
Returns the type of a pointer reference of the specified level to the specified type.
The reference type idea is based on libHX by Jan Engelhardt.
_level | is the pointer indirection level expressed in *. |
_target | is the reference target type. |
Definition at line 137 of file basedefs.h.
#define RTEMS_WEAK __attribute__((__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.
Definition at line 909 of file basedefs.h.
#define RTEMS_WEAK_ALIAS | ( | _target | ) | __attribute__((__weak__, __alias__(#_target))) |
Instructs the compiler to generate a weak alias to the specified target function.
_target | is the target function name. |
Definition at line 925 of file basedefs.h.
#define RTEMS_XCONCAT | ( | _x, | |
_y | |||
) | RTEMS_CONCAT( _x, _y ) |
Concatenates expansion of _x and expansion of _y.
_x | is expanded first and then used as the left hand side token of the concatenation. |
_y | is expanded first and then used as the right hand side token of the concatenation. |
Definition at line 171 of file basedefs.h.
#define RTEMS_XSTRING | ( | _x | ) | RTEMS_STRING( _x ) |
Stringifies the expansion of _x.
_x | is the token expand and stringify. |
Definition at line 295 of file basedefs.h.
#define RTEMS_ZERO_LENGTH_ARRAY 0 |
This is a constant to declare zero-length arrays.
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.
Definition at line 945 of file basedefs.h.