All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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
9#pragma once
10
21#ifdef __cplusplus
22extern "C" {
23#endif
24
28#define CONCAT(a, b) a ## b
29
33#define CONCAT3(a, b, c) a ## b ## c
34
38#define CONCAT4(a, b, c, d) a ## b ## c ## d
39
40/* For compatibility with vendor headers, only provide MAX() and MIN() if not
41 * provided. (The alternative approach of using #undef has the downside that
42 * vendor header files may provide a smarter version of MAX() / MIN() that does
43 * not evaluate the argument twice and rely on this).
44 */
45#ifndef MAX
52#define MAX(a, b) ((a) > (b) ? (a) : (b))
53#endif
54
55#ifndef MIN
62#define MIN(a, b) ((a) < (b) ? (a) : (b))
63#endif
64
65#ifndef ABS
72#define ABS(x) ((x) > 0 ? (x) : -(x))
73#endif
74
89#define LIMIT(val, low, high) ((val < low) ? low : (val > high) ? high : val)
90
91#ifdef __cplusplus
92}
93#endif
94