util: add SWAP(a,b) macro
Equivalent to: auto t = a; a = b; b = t;
This commit is contained in:
parent
cc1ddbd598
commit
f21d997fc6
1 changed files with 7 additions and 0 deletions
|
@ -40,3 +40,10 @@ INLINE double bits_to_double(uint64_t i) {
|
|||
}
|
||||
|
||||
#define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(*(arr)))
|
||||
|
||||
#define SWAP(_a, _b) ({ \
|
||||
auto _swap_temp = _a; \
|
||||
_a = _b; \
|
||||
_b = _swap_temp; \
|
||||
(void)0; \
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue