Skip to content

Commit b9c1b3e

Browse files
committed
Remove use of floor function which causes linkage problems on Windows.
1 parent 8306bc8 commit b9c1b3e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/hdr_histogram.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,13 @@ int hdr_calculate_bucket_config(
341341
sub_bucket_count_magnitude = (int32_t) ceil(log((double)largest_value_with_single_unit_resolution) / log(2));
342342
cfg->sub_bucket_half_count_magnitude = ((sub_bucket_count_magnitude > 1) ? sub_bucket_count_magnitude : 1) - 1;
343343

344-
cfg->unit_magnitude = (int32_t) floor(log((double)lowest_trackable_value) / log(2));
344+
double unit_magnitude = log((double)lowest_trackable_value) / log(2);
345+
if (INT32_MAX < unit_magnitude)
346+
{
347+
return EINVAL;
348+
}
345349

350+
cfg->unit_magnitude = (int32_t) unit_magnitude;
346351
cfg->sub_bucket_count = (int32_t) pow(2, (cfg->sub_bucket_half_count_magnitude + 1));
347352
cfg->sub_bucket_half_count = cfg->sub_bucket_count / 2;
348353
cfg->sub_bucket_mask = ((int64_t) cfg->sub_bucket_count - 1) << cfg->unit_magnitude;

0 commit comments

Comments
 (0)