From: Jonathan Rajotte Date: Sat, 14 Dec 2019 00:06:41 +0000 (-0500) Subject: actions: implement is_equal X-Git-Tag: v2.13.0-rc1~627 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=3dd04a6a94950c91b0895e6da9da5f84db1e7abc;p=lttng-tools.git actions: implement is_equal Signed-off-by: Jonathan Rajotte Change-Id: I9272253202cfd0d6b6fb165293a534a824fbe854 Signed-off-by: Jérémie Galarneau --- diff --git a/include/lttng/action/action-internal.h b/include/lttng/action/action-internal.h index d1868b06b..f747276c7 100644 --- a/include/lttng/action/action-internal.h +++ b/include/lttng/action/action-internal.h @@ -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 */ diff --git a/src/common/actions/action.c b/src/common/actions/action.c index f15163818..50e1b1d84 100644 --- a/src/common/actions/action.c +++ b/src/common/actions/action.c @@ -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; +} diff --git a/src/common/actions/notify.c b/src/common/actions/notify.c index ea68c75fd..d03bacb2e 100644 --- a/src/common/actions/notify.c +++ b/src/common/actions/notify.c @@ -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(¬ify->parent, LTTNG_ACTION_TYPE_NOTIFY, NULL, lttng_action_notify_serialize, + lttng_action_notify_is_equal, lttng_action_notify_destroy); end: return ¬ify->parent;