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:
parent
63a5b25f57
commit
f556d55ac1
1 changed files with 14 additions and 5 deletions
|
@ -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))
|
||||
|
|
Loading…
Add table
Reference in a new issue