Helper Reference Manual
1.7.1
macros.h
Go to the documentation of this file.
1
/* SPDX-License-Identifier: BSD-3-Clause
2
* Copyright(C) 2023-2025 Nokia
3
*/
4
11
#ifndef ODPH_MACROS_H_
12
#define ODPH_MACROS_H_
13
14
#ifdef __cplusplus
15
extern
"C"
{
16
#endif
17
28
#define ODPH_ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
29
33
#define ODPH_MIN(a, b) \
34
__extension__ ({ \
35
__typeof__(a) min_a = (a); \
36
__typeof__(b) min_b = (b); \
37
min_a < min_b ? min_a : min_b; \
38
})
39
43
#define ODPH_MAX(a, b) \
44
__extension__ ({ \
45
__typeof__(a) max_a = (a); \
46
__typeof__(b) max_b = (b); \
47
max_a > max_b ? max_a : max_b; \
48
})
49
53
#define ODPH_ABS(v) \
54
__extension__ ({ \
55
__typeof__(v) abs_v = (v); \
56
abs_v < 0 ? -abs_v : abs_v; \
57
})
58
63
#define ODPH_DIV_ROUNDUP(dividend, divisor) \
64
__extension__ ({ \
65
__typeof__(dividend) _dividend = (dividend); \
66
__typeof__(divisor) _divisor = (divisor); \
67
(_dividend + _divisor - 1) / _divisor; \
68
})
69
73
#define ODPH_ROUNDUP_MULTIPLE(x, y) \
74
__extension__ ({ \
75
__typeof__(x) _x = (x); \
76
__typeof__(y) _y = (y); \
77
_y * (ODPH_DIV_ROUNDUP(_x, _y)); \
78
})
79
84
#ifdef __cplusplus
85
}
86
#endif
87
88
#endif
/* ODPH_MACROS_H_ */
helper
include
odp
helper
macros.h
Generated by
1.9.1