*
*/
-#include <assert.h>
#include <common/buffer-view.h>
#include <common/dynamic-buffer.h>
#include <common/error.h>
static bool lttng_rate_policy_once_after_n_should_execute(
const struct lttng_rate_policy *policy, uint64_t counter);
-LTTNG_HIDDEN
const char *lttng_rate_policy_type_string(
enum lttng_rate_policy_type rate_policy_type)
{
return policy ? policy->type : LTTNG_RATE_POLICY_TYPE_UNKNOWN;
}
-LTTNG_HIDDEN
void lttng_rate_policy_init(struct lttng_rate_policy *rate_policy,
enum lttng_rate_policy_type type,
rate_policy_serialize_cb serialize,
rate_policy->destroy(rate_policy);
}
-LTTNG_HIDDEN
int lttng_rate_policy_serialize(struct lttng_rate_policy *rate_policy,
struct lttng_payload *payload)
{
return consumed_len;
}
-LTTNG_HIDDEN
ssize_t lttng_rate_policy_create_from_payload(struct lttng_payload_view *view,
struct lttng_rate_policy **rate_policy)
{
goto end;
}
- assert(*rate_policy);
+ LTTNG_ASSERT(*rate_policy);
consumed_len = sizeof(struct lttng_rate_policy_comm) +
specific_rate_policy_consumed_len;
return consumed_len;
}
-LTTNG_HIDDEN
bool lttng_rate_policy_is_equal(const struct lttng_rate_policy *a,
const struct lttng_rate_policy *b)
{
goto end;
}
- assert(a->equal);
+ LTTNG_ASSERT(a->equal);
is_equal = a->equal(a, b);
end:
return is_equal;
}
-LTTNG_HIDDEN
bool lttng_rate_policy_should_execute(
const struct lttng_rate_policy *policy, uint64_t counter)
{
static struct lttng_rate_policy_every_n *rate_policy_every_n_from_rate_policy(
struct lttng_rate_policy *policy)
{
- assert(policy);
+ LTTNG_ASSERT(policy);
return container_of(policy, struct lttng_rate_policy_every_n, parent);
}
rate_policy_every_n_from_rate_policy_const(
const struct lttng_rate_policy *policy)
{
- assert(policy);
+ LTTNG_ASSERT(policy);
return container_of(policy, struct lttng_rate_policy_every_n, parent);
}
struct lttng_rate_policy_every_n *every_n_policy;
struct lttng_rate_policy_every_n_comm comm = {};
- assert(policy);
- assert(payload);
+ LTTNG_ASSERT(policy);
+ LTTNG_ASSERT(payload);
every_n_policy = rate_policy_every_n_from_rate_policy(policy);
comm.interval = every_n_policy->interval;
enum lttng_error_code ret_code;
const struct lttng_rate_policy_every_n *every_n_policy = NULL;
- assert(rate_policy);
- assert(IS_EVERY_N_RATE_POLICY(rate_policy));
- assert(writer);
+ LTTNG_ASSERT(rate_policy);
+ LTTNG_ASSERT(IS_EVERY_N_RATE_POLICY(rate_policy));
+ LTTNG_ASSERT(writer);
every_n_policy = rate_policy_every_n_from_rate_policy_const(
rate_policy);
const struct lttng_rate_policy *policy, uint64_t counter)
{
const struct lttng_rate_policy_every_n *every_n_policy;
- assert(policy);
+ LTTNG_ASSERT(policy);
bool execute = false;
every_n_policy = rate_policy_every_n_from_rate_policy_const(policy);
static struct lttng_rate_policy_once_after_n *
rate_policy_once_after_n_from_rate_policy(struct lttng_rate_policy *policy)
{
- assert(policy);
+ LTTNG_ASSERT(policy);
return container_of(
policy, struct lttng_rate_policy_once_after_n, parent);
rate_policy_once_after_n_from_rate_policy_const(
const struct lttng_rate_policy *policy)
{
- assert(policy);
+ LTTNG_ASSERT(policy);
return container_of(
policy, struct lttng_rate_policy_once_after_n, parent);
struct lttng_rate_policy_once_after_n *once_after_n_policy;
struct lttng_rate_policy_once_after_n_comm comm = {};
- assert(policy);
- assert(payload);
+ LTTNG_ASSERT(policy);
+ LTTNG_ASSERT(payload);
once_after_n_policy = rate_policy_once_after_n_from_rate_policy(policy);
comm.threshold = once_after_n_policy->threshold;
enum lttng_error_code ret_code;
const struct lttng_rate_policy_once_after_n *once_after_n_policy = NULL;
- assert(rate_policy);
- assert(IS_ONCE_AFTER_N_RATE_POLICY(rate_policy));
- assert(writer);
+ LTTNG_ASSERT(rate_policy);
+ LTTNG_ASSERT(IS_ONCE_AFTER_N_RATE_POLICY(rate_policy));
+ LTTNG_ASSERT(writer);
once_after_n_policy = rate_policy_once_after_n_from_rate_policy_const(
rate_policy);
return status;
}
-LTTNG_HIDDEN
struct lttng_rate_policy *lttng_rate_policy_copy(
const struct lttng_rate_policy *source)
{
- assert(source->copy);
+ LTTNG_ASSERT(source->copy);
return source->copy(source);
}
{
const struct lttng_rate_policy_once_after_n *once_after_n_policy;
bool execute = false;
- assert(policy);
+ LTTNG_ASSERT(policy);
once_after_n_policy =
rate_policy_once_after_n_from_rate_policy_const(policy);
return counter == once_after_n_policy->threshold;
}
-LTTNG_HIDDEN
enum lttng_error_code lttng_rate_policy_mi_serialize(
const struct lttng_rate_policy *rate_policy,
struct mi_writer *writer)
int ret;
enum lttng_error_code ret_code;
- assert(rate_policy);
- assert(writer);
- assert(rate_policy->mi_serialize);
+ LTTNG_ASSERT(rate_policy);
+ LTTNG_ASSERT(writer);
+ LTTNG_ASSERT(rate_policy->mi_serialize);
/* Open rate policy element. */
ret = mi_lttng_writer_open_element(