src/h5core/h5t_map_private.h

- bugfix: we have to use a signed type for 'low', 'mid' and ' high'
This commit is contained in:
2015-10-08 16:23:46 +02:00
parent 3fe0cc74be
commit 95e21118e4
+46 -46
View File
@@ -21,39 +21,39 @@
Find ID in sorted list
Special version of macro h5priv_find_in_xlist() for local and global entity IDs
*/
#define h5priv_find_in_idlist(type) \
static inline h5_loc_idx_t \
h5priv_find_in_ ## type ## list ( \
h5_ ## type ## list_t* list, \
const h5_ ## type ## _t item \
) { \
H5_PRIV_API_ENTER (h5_err_t, \
"list=%p, item=%llu", \
list, (long long unsigned)item); \
if (!list) { \
H5_PRIV_API_LEAVE (-1); \
} \
register size_t low = 0; \
register size_t mid; \
register size_t high = list->num_items - 1; \
register h5_ ## type ## x_t diff; \
const h5_ ## type ## _t face_id = h5tpriv_get_face_id(item); \
const h5_ ## type ## x_t elem_idx = h5tpriv_get_elem_idx(item); \
while (low <= high) { \
mid = (low + high) / 2; \
diff = h5tpriv_get_elem_idx(list->items[mid]) - elem_idx; \
if (diff == 0) { \
diff = h5tpriv_get_face_id (list->items[mid]) - face_id; \
} \
if ( diff > 0 ) \
high = mid - 1; \
else if ( diff < 0 ) \
low = mid + 1; \
else \
H5_PRIV_API_LEAVE (mid); \
} \
H5_PRIV_API_RETURN (-(low+1)); \
}
#define h5priv_find_in_idlist(type) \
static inline h5_loc_idx_t \
h5priv_find_in_ ## type ## list ( \
h5_ ## type ## list_t* list, \
const h5_ ## type ## _t item \
) { \
H5_PRIV_API_ENTER (h5_err_t, \
"list=%p, item=%llu", \
list, (long long unsigned)item); \
if (!list) { \
H5_PRIV_API_LEAVE (-1); \
} \
register ssize_t low = 0; \
register ssize_t mid; \
register ssize_t high = list->num_items - 1; \
register h5_ ## type ## x_t diff; \
const h5_ ## type ## _t face_id = h5tpriv_get_face_id(item); \
const h5_ ## type ## x_t elem_idx = h5tpriv_get_elem_idx(item); \
while (low <= high) { \
mid = (low + high) / 2; \
diff = h5tpriv_get_elem_idx(list->items[mid]) - elem_idx; \
if (diff == 0) { \
diff = h5tpriv_get_face_id (list->items[mid]) - face_id; \
} \
if ( diff > 0 ) \
high = mid - 1; \
else if ( diff < 0 ) \
low = mid + 1; \
else \
H5_PRIV_API_LEAVE (mid); \
} \
H5_PRIV_API_RETURN (-(low+1)); \
}
h5priv_alloc_xlist (loc_id)
@@ -70,18 +70,18 @@ h5priv_search_in_xlist (glb_id)
h5_err_t
h5tpriv_get_loc_vtx_idx_of_vtx (
h5t_mesh_t* const m,
const h5_loc_id_t entity_id,
h5_loc_idx_t* vertex_index
);
h5t_mesh_t* const m,
const h5_loc_id_t entity_id,
h5_loc_idx_t* vertex_index
);
h5_err_t
h5tpriv_get_loc_vtx_idx_of_vtx2 (
h5t_mesh_t* const m,
const h5_loc_idx_t face_idx,
const h5_loc_idx_t elem_idx,
h5_loc_idx_t* vertex_indices
);
h5t_mesh_t* const m,
const h5_loc_idx_t face_idx,
const h5_loc_idx_t elem_idx,
h5_loc_idx_t* vertex_indices
);
h5_err_t
h5tpriv_sort_local_vertex_indices (
@@ -108,13 +108,13 @@ h5tpriv_rebuild_map_vertex_g2l_partial (
);
h5_err_t
h5priv_exchange_loc_list_to_glb (
h5t_mesh_t* const m,
h5_glb_idxlist_t** glb_list
);
h5t_mesh_t* const m,
h5_glb_idxlist_t** glb_list
);
h5_loc_idx_t
h5tpriv_find_glb_idx_in_map (
h5_idxmap_t* map,
h5_idxmap_t* map,
const h5_glb_idx_t glb_idx
);
#endif