inc/ecu/utils.h File Reference
| ECU |
#include <stdbool.h>#include <stddef.h>#include <stdint.h>Go to the source code of this file.
Macros | |
| #define | ECU_CONTAINER_OF(ptr_, type_, member_) ((type_ *)(void *)((uint8_t *)(ptr_) - offsetof(type_, member_))) |
| Converts an intrusive member back into the data type that stores it. See ECU_DNODE_GET_ENTRY() for example usage. More... | |
| #define | ECU_CONST_CONTAINER_OF(ptr_, type_, member_) ((const type_ *)(const void *)((const uint8_t *)(ptr_) - offsetof(type_, member_))) |
| Const-qualified version of ECU_CONTAINER_OF(). Converts an intrusive member back into the data type that stores it. See ECU_DNODE_GET_CONST_ENTRY() for example usage. More... | |
| #define | ECU_FIELD_SIZEOF(type_, member_) (sizeof(((type_ *)0)->member_)) |
| Returns the size of a member within a struct or union declaration at compile-time. More... | |
| #define | ECU_IS_BASE_OF(base_, derived_) ((bool)(offsetof(derived_, base_) == (size_t)0)) |
| Verifies, at compile-time, that derived class correctly inherits base class via C-style inheritance. Returns true if this condition is satisfied. False otherwise. More... | |
| #define | ECU_IS_SIGNED(type_) ((bool)((type_)-1 < (type_)0)) |
| Verifies, at compile-time, that supplied type is signed. Returns true if this condition is satisfied. False otherwise. More... | |
| #define | ECU_IS_UNSIGNED(type_) ((bool)((type_)-1 > (type_)0)) |
| Verifies, at compile-time, that supplied type is unsigned. Returns true if this condition is satisfied. False otherwise. More... | |
Detailed Description
Macro Definition Documentation
◆ ECU_CONST_CONTAINER_OF
| #define ECU_CONST_CONTAINER_OF | ( | ptr_, | |
| type_, | |||
| member_ | |||
| ) | ((const type_ *)(const void *)((const uint8_t *)(ptr_) - offsetof(type_, member_))) |
Const-qualified version of ECU_CONTAINER_OF(). Converts an intrusive member back into the data type that stores it. See ECU_DNODE_GET_CONST_ENTRY() for example usage.
- Parameters
-
ptr_ Pointer to intrusive member. This can be pointer to non-const or const. type_ Data type containing the intrusive member that parameter ptr_points to. Do not use const specifier. I.e. struct my_type, never const struct my_type.member_ Name of intrusive member within type_.
◆ ECU_CONTAINER_OF
| #define ECU_CONTAINER_OF | ( | ptr_, | |
| type_, | |||
| member_ | |||
| ) | ((type_ *)(void *)((uint8_t *)(ptr_) - offsetof(type_, member_))) |
Converts an intrusive member back into the data type that stores it. See ECU_DNODE_GET_ENTRY() for example usage.
- Parameters
-
ptr_ Pointer to intrusive member. This must be pointer to non-const. type_ Data type containing the intrusive member that parameter ptr_points to. Do not use const specifier. I.e. struct my_type, never const struct my_type.member_ Name of intrusive member within type_.
◆ ECU_FIELD_SIZEOF
| #define ECU_FIELD_SIZEOF | ( | type_, | |
| member_ | |||
| ) | (sizeof(((type_ *)0)->member_)) |
Returns the size of a member within a struct or union declaration at compile-time.
- Parameters
-
type_ Struct or union type containing member_.member_ Name of member within type_to get size of.
◆ ECU_IS_BASE_OF
| #define ECU_IS_BASE_OF | ( | base_, | |
| derived_ | |||
| ) | ((bool)(offsetof(derived_, base_) == (size_t)0)) |
Verifies, at compile-time, that derived class correctly inherits base class via C-style inheritance. Returns true if this condition is satisfied. False otherwise.
- Parameters
-
base_ Name of base class member within user's derived_type.derived_ Derived type to check.
◆ ECU_IS_SIGNED
| #define ECU_IS_SIGNED | ( | type_ | ) | ((bool)((type_)-1 < (type_)0)) |
Verifies, at compile-time, that supplied type is signed. Returns true if this condition is satisfied. False otherwise.
- Parameters
-
type_ Type to check. I.e. int8_t, uint8_t, etc.
◆ ECU_IS_UNSIGNED
| #define ECU_IS_UNSIGNED | ( | type_ | ) | ((bool)((type_)-1 > (type_)0)) |
Verifies, at compile-time, that supplied type is unsigned. Returns true if this condition is satisfied. False otherwise.
- Parameters
-
type_ Type to check. I.e. int8_t, uint8_t, etc.
Generated by