2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-30 22:05:36 +00:00

pid: Add equel_pid() helper

This allows to compare pids values on the whole hierarhy.

v3: Do not use break as some travis builds don't like it.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
This commit is contained in:
Kirill Tkhai
2017-04-10 11:16:23 +03:00
committed by Andrei Vagin
parent a2bfe6a607
commit ec87dd1072

View File

@@ -4,6 +4,7 @@
#include <compel/task-state.h>
#include "stdbool.h"
#include "rbtree.h"
#include "log.h"
/*
* Task states, used in e.g. struct pid's state.
@@ -45,6 +46,22 @@ struct pid {
} ns[1]; /* Must be at the end of struct pid */
};
#define equal_pid(a, b) \
({ \
int ___i, ___ret = true; \
if (a->level == b->level) { \
for (___i = 0; ___i < a->level; ___i++) \
if (a->ns[___i].virt != b->ns[___i].virt) { \
___ret = false; \
___i = a->level; /* break */ \
} \
} else { \
pr_err("Wrong pid nesting level\n"); \
___ret = false; \
} \
___ret; \
})
/*
* When we have to restore a shared resource, we mush select which
* task should do it, and make other(s) wait for it. In order to