Skip to content

Commit

Permalink
Remove HD prefix from math functions
Browse files Browse the repository at this point in the history
  • Loading branch information
derobins committed Sep 14, 2023
1 parent fbeddf2 commit 1e8d031
Show file tree
Hide file tree
Showing 19 changed files with 128 additions and 206 deletions.
2 changes: 1 addition & 1 deletion src/H5Bcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ H5B__cache_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, vo
*image++ = (uint8_t)shared->type->id;

/* 2^8 limit: only 1 byte is used to store node level */
if (bt->level >= HDpow(2, LEVEL_BITS))
if (bt->level >= pow(2, LEVEL_BITS))
HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode node level");

H5_CHECK_OVERFLOW(bt->level, unsigned, uint8_t);
Expand Down
2 changes: 1 addition & 1 deletion src/H5FDonion.c
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ H5FD__onion_open(const char *filename, unsigned flags, hid_t fapl_id, haddr_t ma
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "page size is not a power of two");

/* Assign the page size */
log2_page_size = HDlog2((double)(fa->page_size));
log2_page_size = log2((double)(fa->page_size));
file->curr_rev_record.archival_index.page_size_log2 = (uint32_t)log2_page_size;

/* Proceed with open. */
Expand Down
2 changes: 1 addition & 1 deletion src/H5FDsubfiling/H5FDioc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1531,7 +1531,7 @@ H5FD__ioc_del(const char *name, hid_t fapl)
"can't delete subfiling config file");

/* Try to delete each of the subfiles */
num_digits = (int)(HDlog10(n_subfiles) + 1);
num_digits = (int)(log10(n_subfiles) + 1);

for (int i = 0; i < n_subfiles; i++) {
/* TODO: No support for subfile directory prefix currently */
Expand Down
4 changes: 2 additions & 2 deletions src/H5FDsubfiling/H5subfiling_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -2181,7 +2181,7 @@ ioc_open_files(int64_t file_context_id, int file_acc_flags)
"couldn't allocate space for subfile filename");

num_subfiles = sf_context->sf_num_subfiles;
num_digits = (int)(HDlog10(num_subfiles) + 1);
num_digits = (int)(log10(num_subfiles) + 1);

/*
* For each subfile this IOC rank owns, generate the name
Expand Down Expand Up @@ -2364,7 +2364,7 @@ create_config_file(subfiling_context_t *sf_context, const char *base_filename, c
"failed to write to subfiling configuration file");

/* Write out each subfile name to the configuration file */
num_digits = (int)(HDlog10(n_subfiles) + 1);
num_digits = (int)(log10(n_subfiles) + 1);
for (int k = 0; k < n_subfiles; k++) {
HDsnprintf(line_buf, PATH_MAX, H5FD_SUBFILING_FILENAME_TEMPLATE "\n", base_filename,
sf_context->h5_file_id, num_digits, k + 1, n_subfiles);
Expand Down
6 changes: 3 additions & 3 deletions src/H5Fint.c
Original file line number Diff line number Diff line change
Expand Up @@ -3307,7 +3307,7 @@ H5F_track_metadata_read_retries(H5F_t *f, unsigned actype, unsigned retries)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");

/* Index to retries based on log10 */
tmp = HDlog10((double)retries);
tmp = log10((double)retries);
log_ind = (unsigned)tmp;
assert(log_ind < f->shared->retries_nbins);

Expand Down Expand Up @@ -3345,9 +3345,9 @@ H5F_set_retries(H5F_t *f)
/* Initialize the # of bins for retries */
f->shared->retries_nbins = 0;
if (f->shared->read_attempts > 1) {
/* Use HDceil to ensure that the log10 value is rounded up to the
/* Use ceil to ensure that the log10 value is rounded up to the
nearest integer before casting to unsigned */
tmp = HDceil(HDlog10((double)f->shared->read_attempts));
tmp = ceil(log10((double)f->shared->read_attempts));
f->shared->retries_nbins = (unsigned)tmp;
}

Expand Down
28 changes: 14 additions & 14 deletions src/H5Tconv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1718,15 +1718,15 @@ H5T__conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz
}
else if (src->shared->size >= dst->shared->size) {
double olap_d =
HDceil((double)(dst->shared->size) / (double)(src->shared->size - dst->shared->size));
ceil((double)(dst->shared->size) / (double)(src->shared->size - dst->shared->size));

olap = (size_t)olap_d;
sp = dp = (uint8_t *)buf;
direction = 1;
}
else {
double olap_d =
HDceil((double)(src->shared->size) / (double)(dst->shared->size - src->shared->size));
ceil((double)(src->shared->size) / (double)(dst->shared->size - src->shared->size));
olap = (size_t)olap_d;
sp = (uint8_t *)buf + (nelmts - 1) * src->shared->size;
dp = (uint8_t *)buf + (nelmts - 1) * dst->shared->size;
Expand Down Expand Up @@ -3871,15 +3871,15 @@ H5T__conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz
}
else if (src->shared->size >= dst->shared->size) {
double olap_d =
HDceil((double)(dst->shared->size) / (double)(src->shared->size - dst->shared->size));
ceil((double)(dst->shared->size) / (double)(src->shared->size - dst->shared->size));

olap = (size_t)olap_d;
sp = dp = (uint8_t *)buf;
direction = 1;
}
else {
double olap_d =
HDceil((double)(src->shared->size) / (double)(dst->shared->size - src->shared->size));
ceil((double)(src->shared->size) / (double)(dst->shared->size - src->shared->size));
olap = (size_t)olap_d;
sp = (uint8_t *)buf + (nelmts - 1) * src->shared->size;
dp = (uint8_t *)buf + (nelmts - 1) * dst->shared->size;
Expand Down Expand Up @@ -4329,14 +4329,14 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz
olap = nelmts;
}
else if (src_p->shared->size >= dst_p->shared->size) {
double olap_d = HDceil((double)(dst_p->shared->size) /
double olap_d = ceil((double)(dst_p->shared->size) /
(double)(src_p->shared->size - dst_p->shared->size));
olap = (size_t)olap_d;
sp = dp = (uint8_t *)buf;
direction = 1;
}
else {
double olap_d = HDceil((double)(src_p->shared->size) /
double olap_d = ceil((double)(src_p->shared->size) /
(double)(dst_p->shared->size - src_p->shared->size));
olap = (size_t)olap_d;
sp = (uint8_t *)buf + (nelmts - 1) * src_p->shared->size;
Expand Down Expand Up @@ -4900,14 +4900,14 @@ H5T__conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz
}
else if (src->shared->size >= dst->shared->size) {
double olapd =
HDceil((double)(dst->shared->size) / (double)(src->shared->size - dst->shared->size));
ceil((double)(dst->shared->size) / (double)(src->shared->size - dst->shared->size));
olap = (size_t)olapd;
sp = dp = (uint8_t *)buf;
direction = 1;
}
else {
double olapd =
HDceil((double)(src->shared->size) / (double)(dst->shared->size - src->shared->size));
ceil((double)(src->shared->size) / (double)(dst->shared->size - src->shared->size));
olap = (size_t)olapd;
sp = (uint8_t *)buf + (nelmts - 1) * src->shared->size;
dp = (uint8_t *)buf + (nelmts - 1) * dst->shared->size;
Expand Down Expand Up @@ -7958,14 +7958,14 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz
olap = nelmts;
}
else if (src_p->shared->size >= dst_p->shared->size) {
double olap_d = HDceil((double)(dst_p->shared->size) /
double olap_d = ceil((double)(dst_p->shared->size) /
(double)(src_p->shared->size - dst_p->shared->size));
olap = (size_t)olap_d;
sp = dp = (uint8_t *)buf;
direction = 1;
}
else {
double olap_d = HDceil((double)(src_p->shared->size) /
double olap_d = ceil((double)(src_p->shared->size) /
(double)(dst_p->shared->size - src_p->shared->size));
olap = (size_t)olap_d;
sp = (uint8_t *)buf + (nelmts - 1) * src_p->shared->size;
Expand All @@ -7976,7 +7976,7 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz
/* Allocate enough space for the buffer holding temporary
* converted value
*/
buf_size = (size_t)(HDpow(2.0, (double)src.u.f.esize) / 8 + 1);
buf_size = (size_t)(pow(2.0, (double)src.u.f.esize) / 8 + 1);
int_buf = (uint8_t *)H5MM_calloc(buf_size);

/* Get conversion exception callback property */
Expand Down Expand Up @@ -8583,14 +8583,14 @@ H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz
olap = nelmts;
}
else if (src_p->shared->size >= dst_p->shared->size) {
double olap_d = HDceil((double)(dst_p->shared->size) /
double olap_d = ceil((double)(dst_p->shared->size) /
(double)(src_p->shared->size - dst_p->shared->size));
olap = (size_t)olap_d;
sp = dp = (uint8_t *)buf;
direction = 1;
}
else {
double olap_d = HDceil((double)(src_p->shared->size) /
double olap_d = ceil((double)(src_p->shared->size) /
(double)(dst_p->shared->size - src_p->shared->size));
olap = (size_t)olap_d;
sp = (uint8_t *)buf + (nelmts - 1) * src_p->shared->size;
Expand Down Expand Up @@ -8811,7 +8811,7 @@ H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz
}

/* Check if the exponent is too big */
expo_max = (hsize_t)(HDpow(2.0, (double)dst.u.f.esize) - 1);
expo_max = (hsize_t)(pow(2.0, (double)dst.u.f.esize) - 1);

if (expo > expo_max) { /*overflows*/
if (cb_struct.func) { /*user's exception handler. Reverse back source order*/
Expand Down
2 changes: 1 addition & 1 deletion src/H5VLnative_token.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ H5VL__native_token_to_str(void *obj, H5I_type_t obj_type, const H5O_token_t *tok
if (addr == 0)
addr_ndigits = 1;
else
addr_ndigits = (size_t)(HDfloor(HDlog10((double)addr)) + 1);
addr_ndigits = (size_t)(floor(log10((double)addr)) + 1);

if (NULL == (*token_str = H5MM_malloc(addr_ndigits + 1)))
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't allocate buffer for token string");
Expand Down
2 changes: 1 addition & 1 deletion src/H5Zdeflate.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const H5Z_class2_t H5Z_DEFLATE[1] = {{
H5Z__filter_deflate, /* The actual filter function */
}};

#define H5Z_DEFLATE_SIZE_ADJUST(s) (HDceil(((double)(s)) * 1.001) + 12)
#define H5Z_DEFLATE_SIZE_ADJUST(s) (ceil(((double)(s)) * 1.001) + 12)

/*-------------------------------------------------------------------------
* Function: H5Z__filter_deflate
Expand Down
12 changes: 6 additions & 6 deletions src/H5Zscaleoffset.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,12 +364,12 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{
#define H5Z_scaleoffset_max_min_3(i, d_nelmts, buf, filval, max, min, D_val) \
{ \
i = 0; \
while (i < d_nelmts && HDfabs((double)(buf[i] - filval)) < HDpow(10.0, -D_val)) \
while (i < d_nelmts && fabs((double)(buf[i] - filval)) < pow(10.0, -D_val)) \
i++; \
if (i < d_nelmts) \
min = max = buf[i]; \
for (; i < d_nelmts; i++) { \
if (HDfabs((double)(buf[i] - filval)) < HDpow(10.0, -D_val)) \
if (fabs((double)(buf[i] - filval)) < pow(10.0, -D_val)) \
continue; /* ignore fill value */ \
if (buf[i] > max) \
max = buf[i]; \
Expand Down Expand Up @@ -1562,10 +1562,10 @@ H5Z__scaleoffset_precompress_fd(void *data, unsigned d_nelmts, enum H5Z_scaleoff
FUNC_ENTER_PACKAGE

if (type == t_float)
H5Z_scaleoffset_precompress_3(float, HDpowf, HDfabsf, HDroundf, HDlroundf, HDllroundf, data, d_nelmts,
H5Z_scaleoffset_precompress_3(float, powf, fabsf, roundf, lroundf, llroundf, data, d_nelmts,
filavail, cd_values, minbits, minval, D_val);
else if (type == t_double)
H5Z_scaleoffset_precompress_3(double, HDpow, HDfabs, HDround, HDlround, HDllround, data, d_nelmts,
H5Z_scaleoffset_precompress_3(double, pow, fabs, round, lround, llround, data, d_nelmts,
filavail, cd_values, minbits, minval, D_val);

done:
Expand All @@ -1585,10 +1585,10 @@ H5Z__scaleoffset_postdecompress_fd(void *data, unsigned d_nelmts, enum H5Z_scale
FUNC_ENTER_PACKAGE

if (type == t_float)
H5Z_scaleoffset_postdecompress_3(float, HDpowf, data, d_nelmts, filavail, cd_values, minbits, sminval,
H5Z_scaleoffset_postdecompress_3(float, powf, data, d_nelmts, filavail, cd_values, minbits, sminval,
D_val);
else if (type == t_double)
H5Z_scaleoffset_postdecompress_3(double, HDpow, data, d_nelmts, filavail, cd_values, minbits, sminval,
H5Z_scaleoffset_postdecompress_3(double, pow, data, d_nelmts, filavail, cd_values, minbits, sminval,
D_val);

done:
Expand Down
Loading

0 comments on commit 1e8d031

Please sign in to comment.