Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
macro_helpers.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015 Roc Streaming authors
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 */
8
9//! @file roc_core/macro_helpers.h
10//! @brief Helper macros.
11
12#ifndef ROC_CORE_MACRO_HELPERS_H_
13#define ROC_CORE_MACRO_HELPERS_H_
14
15#include "roc_core/stddefs.h"
16
17//! Select minum value.
18#define ROC_MIN(a, b) ((a) < (b) ? (a) : (b))
19
20//! Select minum value.
21#define ROC_MAX(a, b) ((a) > (b) ? (a) : (b))
22
23//! Get number of elements in a static array.
24#define ROC_ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
25
26//! Cast a member of a structure out to the containing structure.
27#define ROC_CONTAINER_OF(ptr, type, member) \
28 (reinterpret_cast<type*>((char*)(ptr)-offsetof(type, member)))
29
30//! Stringize macro helper.
31#define ROC_STRINGIZE_(s) #s
32
33//! Stringize macro.
34#define ROC_STRINGIZE(s) ROC_STRINGIZE_(s)
35
36#endif // ROC_CORE_MACRO_HELPERS_H_
Commonly used types and functions.