util: add SWAP(a,b) macro

Equivalent to:
	auto t = a;
	a = b;
	b = t;
This commit is contained in:
Andrei Alexeyev 2023-04-28 21:51:40 +02:00
parent cc1ddbd598
commit f21d997fc6
No known key found for this signature in database
GPG key ID: 72D26128040B9690

View file

@ -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; \
})