1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

utils: make SWAP() compatible with C++

This commit is contained in:
Steffen Vogel 2019-03-29 10:05:46 +01:00
parent 63a5b25f57
commit f556d55ac1

View file

@ -117,12 +117,21 @@ extern "C" {
#define ALIGN_MASK(x, m) (((uintptr_t) (x) + (m)) & ~(m))
#define IS_ALIGNED(x, a) (ALIGN(x, a) == (uintptr_t) x)
#define SWAP(x,y) do { \
__auto_type _x = x; \
__auto_type _y = y; \
x = _y; \
y = _x; \
#ifdef __cplusplus
#define SWAP(x,y) do {\
auto &_x = x; \
auto &_y = y; \
x = _y; \
y = _x; \
} while(0)
#else
#define SWAP(x,y) do {\
__auto_type _x = x; \
__auto_type _y = y; \
x = _y; \
y = _x; \
} while(0)
#endif
/** Round-up integer division */
#define CEIL(x, y) (((x) + (y) - 1) / (y))