mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-01-23 02:14:37 +00:00
utils: Introduce SWAP() helper to exchange two variables
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
parent
f41a087891
commit
bfbd7bbacb
2 changed files with 9 additions and 6 deletions
|
|
@ -48,14 +48,10 @@ struct pid {
|
|||
|
||||
static inline bool equal_pid(struct pid *a, struct pid *b)
|
||||
{
|
||||
struct pid *t;
|
||||
int i;
|
||||
|
||||
if (a->level > b->level) {
|
||||
t = a;
|
||||
a = b;
|
||||
b = t;
|
||||
}
|
||||
if (a->level > b->level)
|
||||
SWAP(a, b);
|
||||
|
||||
for(i = 0; i < b->level; i++) {
|
||||
if (i < a->level) {
|
||||
|
|
|
|||
|
|
@ -85,6 +85,13 @@
|
|||
type __max2 = (y); \
|
||||
__max1 > __max2 ? __max1: __max2; })
|
||||
|
||||
#define SWAP(x, y) \
|
||||
do { \
|
||||
typeof(x) ____val = x; \
|
||||
x = y; \
|
||||
y = ____val; \
|
||||
} while (0)
|
||||
|
||||
#define is_log2(v) (((v) & ((v) - 1)) == 0)
|
||||
|
||||
#endif /* __CR_COMPILER_H__ */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue