Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename HDqsort() to qsort() #3193

Merged
merged 2 commits into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/H5Aint.c
Original file line number Diff line number Diff line change
Expand Up @@ -1885,18 +1885,18 @@ H5A__attr_sort_table(H5A_attr_table_t *atable, H5_index_t idx_type, H5_iter_orde
/* Pick appropriate comparison routine */
if (idx_type == H5_INDEX_NAME) {
if (order == H5_ITER_INC)
HDqsort(atable->attrs, atable->nattrs, sizeof(H5A_t *), H5A__attr_cmp_name_inc);
qsort(atable->attrs, atable->nattrs, sizeof(H5A_t *), H5A__attr_cmp_name_inc);
else if (order == H5_ITER_DEC)
HDqsort(atable->attrs, atable->nattrs, sizeof(H5A_t *), H5A__attr_cmp_name_dec);
qsort(atable->attrs, atable->nattrs, sizeof(H5A_t *), H5A__attr_cmp_name_dec);
else
HDassert(order == H5_ITER_NATIVE);
} /* end if */
else {
HDassert(idx_type == H5_INDEX_CRT_ORDER);
if (order == H5_ITER_INC)
HDqsort(atable->attrs, atable->nattrs, sizeof(H5A_t *), H5A__attr_cmp_corder_inc);
qsort(atable->attrs, atable->nattrs, sizeof(H5A_t *), H5A__attr_cmp_corder_inc);
else if (order == H5_ITER_DEC)
HDqsort(atable->attrs, atable->nattrs, sizeof(H5A_t *), H5A__attr_cmp_corder_dec);
qsort(atable->attrs, atable->nattrs, sizeof(H5A_t *), H5A__attr_cmp_corder_dec);
else
HDassert(order == H5_ITER_NATIVE);
} /* end else */
Expand Down
4 changes: 2 additions & 2 deletions src/H5Cimage.c
Original file line number Diff line number Diff line change
Expand Up @@ -1062,8 +1062,8 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated)
HGOTO_ERROR(H5E_CACHE, H5E_CANTINIT, FAIL, "can't setup image entries array.")

/* Sort the entries */
HDqsort(cache_ptr->image_entries, (size_t)cache_ptr->num_entries_in_image,
sizeof(H5C_image_entry_t), H5C__image_entry_cmp);
qsort(cache_ptr->image_entries, (size_t)cache_ptr->num_entries_in_image,
sizeof(H5C_image_entry_t), H5C__image_entry_cmp);
} /* end if */
else { /* cancel creation of metadata cache image */
HDassert(cache_ptr->image_entries == NULL);
Expand Down
4 changes: 2 additions & 2 deletions src/H5Dchunk.c
Original file line number Diff line number Diff line change
Expand Up @@ -5665,8 +5665,8 @@ H5D__chunk_collective_fill(const H5D_t *dset, H5D_chunk_coll_fill_info_t *chunk_
}

if (need_sort)
HDqsort(chunk_fill_info->chunk_info, chunk_fill_info->num_chunks,
sizeof(struct chunk_coll_fill_info), H5D__chunk_cmp_coll_fill_info);
qsort(chunk_fill_info->chunk_info, chunk_fill_info->num_chunks,
sizeof(struct chunk_coll_fill_info), H5D__chunk_cmp_coll_fill_info);

/* Allocate buffer for block lengths if necessary */
if (!all_same_block_len)
Expand Down
20 changes: 10 additions & 10 deletions src/H5Dmpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1524,8 +1524,8 @@ H5D__link_piece_collective_io(H5D_io_info_t *io_info, int H5_ATTR_UNUSED mpi_ran

/* Sort sel_pieces if necessary */
if (need_sort)
HDqsort(io_info->sel_pieces, io_info->pieces_added, sizeof(io_info->sel_pieces[0]),
H5D__cmp_piece_addr);
qsort(io_info->sel_pieces, io_info->pieces_added, sizeof(io_info->sel_pieces[0]),
H5D__cmp_piece_addr);

/* Allocate chunking information */
if (NULL == (chunk_mtype = (MPI_Datatype *)H5MM_malloc(num_chunk * sizeof(MPI_Datatype))))
Expand Down Expand Up @@ -3219,8 +3219,8 @@ H5D__mpio_collective_filtered_chunk_io_setup(const H5D_io_info_t *io_info, const

/* Ensure the chunk list is sorted in ascending order of offset in the file */
if (need_sort)
HDqsort(local_info_array, num_chunks_selected, sizeof(H5D_filtered_collective_io_info_t),
H5D__cmp_filtered_collective_io_info_entry);
qsort(local_info_array, num_chunks_selected, sizeof(H5D_filtered_collective_io_info_t),
H5D__cmp_filtered_collective_io_info_entry);

#ifdef H5Dmpio_DEBUG
H5D__mpio_dump_collective_filtered_chunk_list(local_info_array, num_chunks_selected, mpi_rank);
Expand Down Expand Up @@ -3527,8 +3527,8 @@ H5D__mpio_redistribute_shared_chunks_int(H5D_filtered_collective_io_info_t *chun
HDmemset(num_chunks_assigned_map, 0, (size_t)mpi_size * sizeof(*num_chunks_assigned_map));

/* Sort collective chunk list according to chunk index */
HDqsort(coll_chunk_list, coll_chunk_list_num_entries, sizeof(H5D_chunk_redistribute_info_t),
H5D__cmp_chunk_redistribute_info);
qsort(coll_chunk_list, coll_chunk_list_num_entries, sizeof(H5D_chunk_redistribute_info_t),
H5D__cmp_chunk_redistribute_info);

/*
* Process all chunks in the collective chunk list.
Expand Down Expand Up @@ -3609,8 +3609,8 @@ H5D__mpio_redistribute_shared_chunks_int(H5D_filtered_collective_io_info_t *chun
* algorithm may be devised that doesn't rely on frail sorting,
* but the current implementation is a quick and naive approach.
*/
HDqsort(coll_chunk_list, coll_chunk_list_num_entries, sizeof(H5D_chunk_redistribute_info_t),
H5D__cmp_chunk_redistribute_info_orig_owner);
qsort(coll_chunk_list, coll_chunk_list_num_entries, sizeof(H5D_chunk_redistribute_info_t),
H5D__cmp_chunk_redistribute_info_orig_owner);
}

if (all_ranks_involved) {
Expand Down Expand Up @@ -4995,8 +4995,8 @@ H5D__mpio_collective_filtered_chunk_reallocate(H5D_filtered_collective_io_info_t
* ascending order of offset in the file
*/
if (need_sort)
HDqsort(chunk_list, chunk_list_num_entries, sizeof(H5D_filtered_collective_io_info_t),
H5D__cmp_filtered_collective_io_info_entry);
qsort(chunk_list, chunk_list_num_entries, sizeof(H5D_filtered_collective_io_info_t),
H5D__cmp_filtered_collective_io_info_entry);

done:
H5MM_free(gathered_array);
Expand Down
2 changes: 1 addition & 1 deletion src/H5FDint.c
Original file line number Diff line number Diff line change
Expand Up @@ -2293,7 +2293,7 @@ H5FD_sort_vector_io_req(hbool_t *vector_was_sorted, uint32_t _count, H5FD_mem_t
}

/* sort the srt_tmp array */
HDqsort(srt_tmp, count, sizeof(struct H5FD_vsrt_tmp_t), H5FD__vsrt_tmp_cmp);
qsort(srt_tmp, count, sizeof(struct H5FD_vsrt_tmp_t), H5FD__vsrt_tmp_cmp);

/* verify no duplicate entries */
i = 1;
Expand Down
8 changes: 4 additions & 4 deletions src/H5FDonion_index.c
Original file line number Diff line number Diff line change
Expand Up @@ -882,8 +882,8 @@ H5FD__onion_merge_revision_index_into_archival_index(const H5FD_onion_revision_i
}

/* Sort the new archival list */
HDqsort(new_aix.list, new_aix.n_entries, sizeof(H5FD_onion_index_entry_t),
H5FD__onion_archival_index_list_sort_cmp);
qsort(new_aix.list, new_aix.n_entries, sizeof(H5FD_onion_index_entry_t),
H5FD__onion_archival_index_list_sort_cmp);

/* Add the old archival index entries to a 'kept' list containing the
* old archival list entries that are not also included in the revision
Expand Down Expand Up @@ -924,8 +924,8 @@ H5FD__onion_merge_revision_index_into_archival_index(const H5FD_onion_revision_i
}

/* Sort this list */
HDqsort(aix->list, aix->n_entries, sizeof(H5FD_onion_index_entry_t),
H5FD__onion_archival_index_list_sort_cmp);
qsort(aix->list, aix->n_entries, sizeof(H5FD_onion_index_entry_t),
H5FD__onion_archival_index_list_sort_cmp);

done:
/* Free the temporary lists */
Expand Down
2 changes: 1 addition & 1 deletion src/H5FDsubfiling/H5subfiling_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1359,7 +1359,7 @@ init_app_layout(sf_topology_t *app_topology, MPI_Comm comm, MPI_Comm node_comm)
H5_SUBFILING_GOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "can't gather application topology info");

/* Sort the list according to the node local lead rank values */
HDqsort(app_layout->layout, (size_t)app_layout->world_size, sizeof(layout_t), compare_layout_nodelocal);
qsort(app_layout->layout, (size_t)app_layout->world_size, sizeof(layout_t), compare_layout_nodelocal);

/*
* Count the number of nodes by checking how many
Expand Down
8 changes: 4 additions & 4 deletions src/H5Glink.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,18 +416,18 @@ H5G__link_sort_table(H5G_link_table_t *ltable, H5_index_t idx_type, H5_iter_orde
/* Pick appropriate sorting routine */
if (idx_type == H5_INDEX_NAME) {
if (order == H5_ITER_INC)
HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G__link_cmp_name_inc);
qsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G__link_cmp_name_inc);
else if (order == H5_ITER_DEC)
HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G__link_cmp_name_dec);
qsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G__link_cmp_name_dec);
else
HDassert(order == H5_ITER_NATIVE);
} /* end if */
else {
HDassert(idx_type == H5_INDEX_CRT_ORDER);
if (order == H5_ITER_INC)
HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G__link_cmp_corder_inc);
qsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G__link_cmp_corder_inc);
else if (order == H5_ITER_DEC)
HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G__link_cmp_corder_dec);
qsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G__link_cmp_corder_dec);
else
HDassert(order == H5_ITER_NATIVE);
} /* end else */
Expand Down
3 changes: 0 additions & 3 deletions src/H5private.h
Original file line number Diff line number Diff line change
Expand Up @@ -982,9 +982,6 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation);
#ifndef HDpwrite
#define HDpwrite(F, B, C, O) pwrite(F, B, C, O)
#endif
#ifndef HDqsort
#define HDqsort(M, N, Z, F) qsort(M, N, Z, F)
#endif

/* clang-format off */
#ifdef H5_HAVE_RAND_R
Expand Down
8 changes: 4 additions & 4 deletions test/API/titerate.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ test_iter_group(hid_t fapl, hbool_t new_format)
CHECK(ret, FAIL, "H5Fclose");

/* Sort the dataset names */
HDqsort(lnames, (size_t)(NDATASETS + 2), sizeof(char *), iter_strcmp);
qsort(lnames, (size_t)(NDATASETS + 2), sizeof(char *), iter_strcmp);

/* Iterate through the datasets in the root group in various ways */
file = H5Fopen(DATAFILE, H5F_ACC_RDONLY, fapl);
Expand Down Expand Up @@ -749,7 +749,7 @@ test_iter_group_large(hid_t fapl)
CHECK(ret, FAIL, "H5Tclose");

/* Need to sort the names in the root group, cause that's what the library does */
HDqsort(names, (size_t)(ITER_NGROUPS + 2), sizeof(iter_info), iter_strcmp2);
qsort(names, (size_t)(ITER_NGROUPS + 2), sizeof(iter_info), iter_strcmp2);

/* Iterate through the file to see members of the root group */
curr_name = &names[0];
Expand Down Expand Up @@ -848,7 +848,7 @@ test_grp_memb_funcs(hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");

/* Sort the dataset names */
HDqsort(dnames, (size_t)(NDATASETS + 2), sizeof(char *), iter_strcmp);
qsort(dnames, (size_t)(NDATASETS + 2), sizeof(char *), iter_strcmp);

/* Iterate through the datasets in the root group in various ways */
file = H5Fopen(DATAFILE, H5F_ACC_RDONLY, fapl);
Expand Down Expand Up @@ -905,7 +905,7 @@ test_grp_memb_funcs(hid_t fapl)
VERIFY(ret, FAIL, "H5Lget_name_by_idx");

/* Sort the dataset names */
HDqsort(obj_names, (size_t)(NDATASETS + 2), sizeof(char *), iter_strcmp);
qsort(obj_names, (size_t)(NDATASETS + 2), sizeof(char *), iter_strcmp);

/* Compare object names */
for (i = 0; i < (int)ginfo.nlinks; i++) {
Expand Down
4 changes: 2 additions & 2 deletions test/API/tselect.c
Original file line number Diff line number Diff line change
Expand Up @@ -1383,8 +1383,8 @@ test_select_hyper_stride(hid_t xfer_plist)
CHECK(ret, FAIL, "H5Dread");

/* Sort the locations into the proper order */
HDqsort(loc1, (size_t)72, sizeof(size_t), compare_size_t);
HDqsort(loc2, (size_t)72, sizeof(size_t), compare_size_t);
qsort(loc1, (size_t)72, sizeof(size_t), compare_size_t);
qsort(loc2, (size_t)72, sizeof(size_t), compare_size_t);
/* Compare data read with data written out */
for (i = 0; i < 72; i++) {
tbuf = wbuf + loc1[i];
Expand Down
8 changes: 4 additions & 4 deletions test/titerate.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ test_iter_group(hid_t fapl, hbool_t new_format)
CHECK(ret, FAIL, "H5Fclose");

/* Sort the dataset names */
HDqsort(lnames, (size_t)(NDATASETS + 2), sizeof(char *), iter_strcmp);
qsort(lnames, (size_t)(NDATASETS + 2), sizeof(char *), iter_strcmp);

/* Iterate through the datasets in the root group in various ways */
file = H5Fopen(DATAFILE, H5F_ACC_RDONLY, fapl);
Expand Down Expand Up @@ -706,7 +706,7 @@ test_iter_group_large(hid_t fapl)
CHECK(ret, FAIL, "H5Tclose");

/* Need to sort the names in the root group, cause that's what the library does */
HDqsort(names, (size_t)(ITER_NGROUPS + 2), sizeof(iter_info), iter_strcmp2);
qsort(names, (size_t)(ITER_NGROUPS + 2), sizeof(iter_info), iter_strcmp2);

/* Iterate through the file to see members of the root group */
curr_name = &names[0];
Expand Down Expand Up @@ -804,7 +804,7 @@ test_grp_memb_funcs(hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");

/* Sort the dataset names */
HDqsort(dnames, (size_t)(NDATASETS + 2), sizeof(char *), iter_strcmp);
qsort(dnames, (size_t)(NDATASETS + 2), sizeof(char *), iter_strcmp);

/* Iterate through the datasets in the root group in various ways */
file = H5Fopen(DATAFILE, H5F_ACC_RDONLY, fapl);
Expand Down Expand Up @@ -861,7 +861,7 @@ test_grp_memb_funcs(hid_t fapl)
VERIFY(ret, FAIL, "H5Lget_name_by_idx");

/* Sort the dataset names */
HDqsort(obj_names, (size_t)(NDATASETS + 2), sizeof(char *), iter_strcmp);
qsort(obj_names, (size_t)(NDATASETS + 2), sizeof(char *), iter_strcmp);

/* Compare object names */
for (i = 0; i < (int)ginfo.nlinks; i++) {
Expand Down
4 changes: 2 additions & 2 deletions test/tselect.c
Original file line number Diff line number Diff line change
Expand Up @@ -1382,8 +1382,8 @@ test_select_hyper_stride(hid_t xfer_plist)
CHECK(ret, FAIL, "H5Dread");

/* Sort the locations into the proper order */
HDqsort(loc1, (size_t)72, sizeof(size_t), compare_size_t);
HDqsort(loc2, (size_t)72, sizeof(size_t), compare_size_t);
qsort(loc1, (size_t)72, sizeof(size_t), compare_size_t);
qsort(loc2, (size_t)72, sizeof(size_t), compare_size_t);
/* Compare data read with data written out */
for (i = 0; i < 72; i++) {
tbuf = wbuf + loc1[i];
Expand Down
4 changes: 2 additions & 2 deletions test/tskiplist.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ test_skiplist_init(void)
HDmemcpy(sort_rand_num, rand_num, sizeof(int) * NUM_ELEMS);

/* Sort random numbers */
HDqsort(sort_rand_num, (size_t)NUM_ELEMS, sizeof(int), tst_sort);
qsort(sort_rand_num, (size_t)NUM_ELEMS, sizeof(int), tst_sort);

/* Copy random values to reverse sorted array */
HDmemcpy(rev_sort_rand_num, rand_num, sizeof(int) * NUM_ELEMS);

/* Sort random numbers */
HDqsort(rev_sort_rand_num, (size_t)NUM_ELEMS, sizeof(int), tst_rev_sort);
qsort(rev_sort_rand_num, (size_t)NUM_ELEMS, sizeof(int), tst_rev_sort);
} /* end test_skiplist_init() */

/****************************************************************
Expand Down