summaryrefslogtreecommitdiff
path: root/lib/util
diff options
context:
space:
mode:
Diffstat (limited to 'lib/util')
-rw-r--r--lib/util/server_id.c17
-rw-r--r--lib/util/server_id.h1
2 files changed, 18 insertions, 0 deletions
diff --git a/lib/util/server_id.c b/lib/util/server_id.c
index 2904e803196..ca998116bf4 100644
--- a/lib/util/server_id.c
+++ b/lib/util/server_id.c
@@ -30,6 +30,23 @@ bool server_id_same_process(const struct server_id *p1,
return ((p1->pid == p2->pid) && (p1->vnn == p2->vnn));
}
+int server_id_cmp(const struct server_id *p1, const struct server_id *p2)
+{
+ if (p1->vnn != p2->vnn) {
+ return (p1->vnn < p2->vnn) ? -1 : 1;
+ }
+ if (p1->pid != p2->pid) {
+ return (p1->pid < p2->pid) ? -1 : 1;
+ }
+ if (p1->task_id != p2->task_id) {
+ return (p1->task_id < p2->task_id) ? -1 : 1;
+ }
+ if (p1->unique_id != p2->unique_id) {
+ return (p1->unique_id < p2->unique_id) ? -1 : 1;
+ }
+ return 0;
+}
+
bool server_id_equal(const struct server_id *p1, const struct server_id *p2)
{
if (!server_id_same_process(p1, p2)) {
diff --git a/lib/util/server_id.h b/lib/util/server_id.h
index 6dda86ced73..5b723d5cda4 100644
--- a/lib/util/server_id.h
+++ b/lib/util/server_id.h
@@ -28,6 +28,7 @@ struct server_id_buf { char buf[48]; }; /* probably a bit too large ... */
bool server_id_same_process(const struct server_id *p1,
const struct server_id *p2);
+int server_id_cmp(const struct server_id *p1, const struct server_id *p2);
bool server_id_equal(const struct server_id *p1, const struct server_id *p2);
char *server_id_str_buf(struct server_id id, struct server_id_buf *dst);
size_t server_id_str_buf_unique(struct server_id id, char *buf, size_t buflen);