The declarations in this header file contain utility definitions and function prototypes that are used within the SDK but are not part of the API.
More...
#include <stddef.h>
#include <stdint.h>
Go to the source code of this file.
|
#define | CDI_NANOSECONDS_PER_SECOND (1000000000UL) |
| Number of nanoseconds in a second.
|
|
#define | CONTAINER_OF(ptr, type, member) (type*)( (char*)(ptr) - offsetof(type, member) ) |
|
#define | CONTAINER_FROM(ptr, type, member_pointed_to, desired_member) (type*)( (char*)(ptr) + (offsetof(type, desired_member) - offsetof(type, member_pointed_to)) ) |
|
#define | CDI_ARRAY_ELEMENT_COUNT(array) ((int)(sizeof(array) / sizeof(array[0]))) |
|
#define | CDI_MIN(a, b) (((a) < (b)) ? (a) : (b)) |
|
#define | CDI_MAX(a, b) (((a) > (b)) ? (a) : (b)) |
|
#define | CDI_INVALID_ENUM_VALUE (-1) |
| Define used to represent an invalid enum value.
|
|
The declarations in this header file contain utility definitions and function prototypes that are used within the SDK but are not part of the API.
◆ CDI_ARRAY_ELEMENT_COUNT
#define CDI_ARRAY_ELEMENT_COUNT |
( |
| array | ) |
((int)(sizeof(array) / sizeof(array[0]))) |
Evaluates to the number of elements in a statically sized array.
- Parameters
-
array | The name of the statically sized array variable whose element count is to be returned. |
- Returns
- The number of elements that comprise the array variable.
◆ CDI_MAX
#define CDI_MAX |
( |
| a, |
|
|
| b ) (((a) > (b)) ? (a) : (b)) |
Evaluates to the larger of the two quantities. This is implemented as a macro so that it can be used for any type of arguments so long as they can be compared using the greater than operator. Care must be taken when using this macro as the arguments may get evaluated multiple times; don't specify an auto-incremented variable, for example.
◆ CDI_MIN
#define CDI_MIN |
( |
| a, |
|
|
| b ) (((a) < (b)) ? (a) : (b)) |
Evaluates to the smaller of the two quantities. This is implemented as a macro so that it can be used for any type of arguments so long as they can be compared using the less than operator. Care must be taken when using this macro as the arguments may get evaluated multiple times; don't specify an auto-incremented variable, for example.
◆ CONTAINER_FROM
#define CONTAINER_FROM |
( |
| ptr, |
|
|
| type, |
|
|
| member_pointed_to, |
|
|
| desired_member ) (type*)( (char*)(ptr) + (offsetof(type, desired_member) - offsetof(type, member_pointed_to)) ) |
This macro is used to locate a pointer to a desired member in a structure that is located in the same containing structure.
- Parameters
-
ptr | The address of the known contained structure member. |
type | The type of the containing structure. |
member_pointed_to | The name of the member within the containing structure whose address is ptr. |
desired_member | The name of the contained member whose address is to be returned. |
- Returns
- The address of the containing structure.
◆ CONTAINER_OF
#define CONTAINER_OF |
( |
| ptr, |
|
|
| type, |
|
|
| member ) (type*)( (char*)(ptr) - offsetof(type, member) ) |
This macro is used to locate a pointer to the start of a structure given a pointer to the specified member in the structure.
- Parameters
-
ptr | The address of the contained structure member. |
type | The type of the containing structure. |
member | The name of the member within the containing structure whose address is ptr. |
- Returns
- The address of the containing structure.
◆ CdiGetEmptyStringIfNull()
static const char * CdiGetEmptyStringIfNull |
( |
const char * | source_str | ) |
|
|
inlinestatic |
Return an empty string if the string specified is NULL, otherwise the specified string is returned.
- Parameters
-
source_str | Pointer to source string |
- Returns
- Pointer to source_str if it is not NULL, otherwise returns a pointer to an empty string.