actions: implement is_equal
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Sat, 14 Dec 2019 00:06:41 +0000 (19:06 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 9 Jun 2020 17:49:06 +0000 (13:49 -0400)
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I9272253202cfd0d6b6fb165293a534a824fbe854
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
include/lttng/action/action-internal.h
src/common/actions/action.c
src/common/actions/notify.c

index d1868b06ba49375237b93c99ea7c9ce932ff3596..f747276c78c0240cd08c214bd034b75b16e68d28 100644 (file)
@@ -19,6 +19,8 @@ typedef bool (*action_validate_cb)(struct lttng_action *action);
 typedef void (*action_destroy_cb)(struct lttng_action *action);
 typedef int (*action_serialize_cb)(struct lttng_action *action,
                struct lttng_dynamic_buffer *buf);
+typedef bool (*action_equal_cb)(const struct lttng_action *a,
+               const struct lttng_action *b);
 typedef ssize_t (*action_create_from_buffer_cb)(
                const struct lttng_buffer_view *view,
                struct lttng_action **action);
@@ -27,6 +29,7 @@ struct lttng_action {
        enum lttng_action_type type;
        action_validate_cb validate;
        action_serialize_cb serialize;
+       action_equal_cb equal;
        action_destroy_cb destroy;
 };
 
@@ -40,6 +43,7 @@ void lttng_action_init(struct lttng_action *action,
                enum lttng_action_type type,
                action_validate_cb validate,
                action_serialize_cb serialize,
+               action_equal_cb equal,
                action_destroy_cb destroy);
 
 LTTNG_HIDDEN
@@ -57,4 +61,8 @@ LTTNG_HIDDEN
 enum lttng_action_type lttng_action_get_type_const(
                const struct lttng_action *action);
 
+LTTNG_HIDDEN
+bool lttng_action_is_equal(const struct lttng_action *a,
+               const struct lttng_action *b);
+
 #endif /* LTTNG_ACTION_INTERNAL_H */
index f15163818c7a622b2ea24085afa1c4219bde240a..50e1b1d84b1d1a971f2bc188adc66897b21d5d53 100644 (file)
@@ -40,11 +40,13 @@ void lttng_action_init(
                enum lttng_action_type type,
                action_validate_cb validate,
                action_serialize_cb serialize,
+               action_equal_cb equal,
                action_destroy_cb destroy)
 {
        action->type = type;
        action->validate = validate;
        action->serialize = serialize;
+       action->equal = equal;
        action->destroy = destroy;
 }
 
@@ -155,3 +157,28 @@ ssize_t lttng_action_create_from_buffer(const struct lttng_buffer_view *view,
 end:
        return consumed_len;
 }
+
+LTTNG_HIDDEN
+bool lttng_action_is_equal(const struct lttng_action *a,
+               const struct lttng_action *b)
+{
+       bool is_equal = false;
+
+       if (!a || !b) {
+               goto end;
+       }
+
+       if (a->type != b->type) {
+               goto end;
+       }
+
+       if (a == b) {
+               is_equal = true;
+               goto end;
+       }
+
+       assert(a->equal);
+       is_equal = a->equal(a, b);
+end:
+       return is_equal;
+}
index ea68c75fd0f0c38eba8255e7374033ec1928d5dd..d03bacb2ebf16b7fcc4b97ca061c1e71977bc8a1 100644 (file)
@@ -23,6 +23,14 @@ int lttng_action_notify_serialize(struct lttng_action *action,
        return 0;
 }
 
+static
+bool lttng_action_notify_is_equal(const struct lttng_action *a,
+               const struct lttng_action *b)
+{
+       /* There is no discriminant between notify actions. */
+       return true;
+}
+
 struct lttng_action *lttng_action_notify_create(void)
 {
        struct lttng_action_notify *notify;
@@ -34,6 +42,7 @@ struct lttng_action *lttng_action_notify_create(void)
 
        lttng_action_init(&notify->parent, LTTNG_ACTION_TYPE_NOTIFY, NULL,
                        lttng_action_notify_serialize,
+                       lttng_action_notify_is_equal,
                        lttng_action_notify_destroy);
 end:
        return &notify->parent;
This page took 0.028634 seconds and 4 git commands to generate.