CDI SDK
SDK for transporting chunks of data reliably and with low latency using a polled mode network driver.
Loading...
Searching...
No Matches
src
common
include
utilities_api.h
Go to the documentation of this file.
1
// -------------------------------------------------------------------------------------------
2
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
3
// This file is part of the AWS CDI-SDK, licensed under the BSD 2-Clause "Simplified" License.
4
// License details at: https://github.com/aws/aws-cdi-sdk/blob/mainline/LICENSE
5
// -------------------------------------------------------------------------------------------
6
14
#ifndef CDI_UTILITIES_H__
15
#define CDI_UTILITIES_H__
16
17
#include <stddef.h>
18
#include <stdint.h>
19
20
//*********************************************************************************************************************
21
//***************************************** START OF DEFINITIONS AND TYPES ********************************************
22
//*********************************************************************************************************************
23
25
#define CDI_NANOSECONDS_PER_SECOND (1000000000UL)
26
37
#define CONTAINER_OF(ptr, type, member) \
38
(type*)( (char*)(ptr) - offsetof(type, member) )
39
51
#define CONTAINER_FROM(ptr, type, member_pointed_to, desired_member) \
52
(type*)( (char*)(ptr) + (offsetof(type, desired_member) - offsetof(type, member_pointed_to)) )
53
61
#define CDI_ARRAY_ELEMENT_COUNT(array) ((int)(sizeof(array) / sizeof(array[0])))
62
68
#define CDI_MIN(a, b) (((a) < (b)) ? (a) : (b))
69
75
#define CDI_MAX(a, b) (((a) > (b)) ? (a) : (b))
76
78
#define CDI_INVALID_ENUM_VALUE (-1)
79
87
static
inline
const
char
*
CdiGetEmptyStringIfNull
(
const
char
* source_str)
88
{
89
static
const
char
empty_str[] =
""
;
90
91
if
(NULL == source_str) {
92
return
empty_str;
93
}
94
95
return
source_str;
96
}
97
98
//*********************************************************************************************************************
99
//******************************************* START OF PUBLIC FUNCTIONS ***********************************************
100
//*********************************************************************************************************************
101
102
#endif
// CDI_UTILITIES_H__
CdiGetEmptyStringIfNull
static const char * CdiGetEmptyStringIfNull(const char *source_str)
Definition
utilities_api.h:87
Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.