Loading...
Searching...
No Matches
utils.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2023 Otto-von-Guericke-Universität Magdeburg
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
19#ifndef MACROS_UTILS_H
20#define MACROS_UTILS_H
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
29#define CONCAT(a, b) a ## b
30
34#define CONCAT3(a, b, c) a ## b ## c
35
39#define CONCAT4(a, b, c, d) a ## b ## c ## d
40
41/* For compatibility with vendor headers, only provide MAX() and MIN() if not
42 * provided. (The alternative approach of using #undef has the downside that
43 * vendor header files may provide a smarter version of MAX() / MIN() that does
44 * not evaluate the argument twice and rely on this).
45 */
46#ifndef MAX
53#define MAX(a, b) ((a) > (b) ? (a) : (b))
54#endif
55
56#ifndef MIN
63#define MIN(a, b) ((a) < (b) ? (a) : (b))
64#endif
65
66#ifndef ABS
73#define ABS(x) ((x) > 0 ? (x) : -(x))
74#endif
75
90#define LIMIT(val, low, high) ((val < low) ? low : (val > high) ? high : val)
91
92#ifdef __cplusplus
93}
94#endif
95
96#endif /* MACROS_UTILS_H */