struct lttng_condition_buffer_usage_comm {
uint8_t threshold_set_in_bytes;
- /*
- * Expressed in bytes if "threshold_set_in_bytes" is not 0.
- * Otherwise, it is expressed a ratio in the interval [0.0, 1.0]
- * that is mapped to the range on a 32-bit unsigned integer.
- * The ratio is obtained by (threshold / UINT32_MAX).
- */
- uint32_t threshold;
+ uint64_t threshold_bytes;
+ double threshold_ratio;
/* Both lengths include the trailing \0. */
uint32_t session_name_len;
uint32_t channel_name_len;
lttng_ht_seed);
}
if (condition->threshold_ratio.set) {
- uint64_t val;
-
- val = condition->threshold_ratio.value * (double) UINT32_MAX;
- hash ^= hash_key_u64(&val, lttng_ht_seed);
+ hash ^= hash_key_u64(&condition->threshold_ratio.value, lttng_ht_seed);
} else if (condition->threshold_bytes.set) {
uint64_t val;
lttng_condition_get_type(condition) == LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH \
)
-static
-double fixed_to_double(uint32_t val)
-{
- return (double) val / (double) UINT32_MAX;
-}
-
-static
-uint64_t double_to_fixed(double val)
-{
- return (val * (double) UINT32_MAX);
-}
-
static
bool is_usage_evaluation(const struct lttng_evaluation *evaluation)
{
usage_comm.domain_type = (int8_t) usage->domain.type;
if (usage->threshold_bytes.set) {
- usage_comm.threshold = usage->threshold_bytes.value;
+ usage_comm.threshold_bytes = usage->threshold_bytes.value;
} else {
- uint64_t val = double_to_fixed(
- usage->threshold_ratio.value);
-
- if (val > UINT32_MAX) {
- /* overflow. */
- ret = -1;
- goto end;
- }
- usage_comm.threshold = val;
+ usage_comm.threshold_ratio = usage->threshold_ratio.value;
}
ret = lttng_dynamic_buffer_append(&payload->buffer, &usage_comm,
if (condition_comm->threshold_set_in_bytes) {
status = lttng_condition_buffer_usage_set_threshold(condition,
- condition_comm->threshold);
+ condition_comm->threshold_bytes);
} else {
status = lttng_condition_buffer_usage_set_threshold_ratio(
- condition,
- fixed_to_double(condition_comm->threshold));
+ condition, condition_comm->threshold_ratio);
}
if (status != LTTNG_CONDITION_STATUS_OK) {