Merge pull request #809 in HDFFV/hdf5 from ~DEROBINS/hdf5_der:vol_normalize to develop

* commit '2e80fbbfcc5a15c296c16e4a4295ce77a9af6587':
  Fixed an incorrect FUNC_ENTER macro.
  Normalization with VOL integration branch.
This commit is contained in:
Dana Robinson 2017-12-01 10:08:04 -06:00
commit 930a0b5d7c
14 changed files with 665 additions and 744 deletions

View File

@ -24,6 +24,7 @@
#include "H5Dprivate.h" /* Datasets */
#include "H5Eprivate.h" /* Error handling */
#include "H5FLprivate.h" /* Free lists */
#include "H5FSprivate.h" /* File free space */
#include "H5Lprivate.h" /* Links */
#include "H5MMprivate.h" /* Memory management */
#include "H5Pprivate.h" /* Property lists */

View File

@ -1150,7 +1150,7 @@ H5Arename(hid_t loc_id, const char *old_name, const char *new_name)
if(HDstrcmp(old_name, new_name)) {
H5G_loc_t loc; /* Object location */
if(H5G_loc(loc_id, & loc) < 0)
if(H5G_loc(loc_id, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
/* Call private attribute rename routine */
@ -1205,7 +1205,7 @@ H5Arename_by_name(hid_t loc_id, const char *obj_name, const char *old_attr_name,
if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id, loc_id, TRUE) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access and transfer property lists")
if(H5G_loc(loc_id, & loc) < 0)
if(H5G_loc(loc_id, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
/* Call private attribute rename routine */

View File

@ -33,14 +33,14 @@
/***********/
/* Headers */
/***********/
#include "H5private.h" /* Generic Functions */
#include "H5Apkg.h" /* Attributes */
#include "H5Dprivate.h" /* Datasets */
#include "H5Eprivate.h" /* Error handling */
#include "H5Iprivate.h" /* IDs */
#include "H5MMprivate.h" /* Memory management */
#include "H5Opkg.h" /* Object headers */
#include "H5SMprivate.h" /* Shared Object Header Messages */
#include "H5private.h" /* Generic Functions */
#include "H5Apkg.h" /* Attributes */
#include "H5Dprivate.h" /* Datasets */
#include "H5Eprivate.h" /* Error handling */
#include "H5Iprivate.h" /* IDs */
#include "H5MMprivate.h" /* Memory management */
#include "H5Opkg.h" /* Object headers */
#include "H5SMprivate.h" /* Shared Object Header Messages */
/****************/

View File

@ -322,7 +322,7 @@ done:
/*-------------------------------------------------------------------------
* Function: H5D__pre_write
*
* Purpose: Preparation for writing data.
* Purpose: Preparation for writing data.
*
* Return: SUCCEED/FAIL
*

View File

@ -18,6 +18,9 @@
#ifndef _H5Fprivate_H
#define _H5Fprivate_H
/* Early typedefs to avoid circular dependencies */
typedef struct H5F_t H5F_t;
/* Include package's public header */
#include "H5Fpublic.h"
@ -475,8 +478,8 @@
#define H5F_ACS_SIEVE_BUF_SIZE_NAME "sieve_buf_size" /* Maximum sieve buffer size (when data sieving is allowed by file driver) */
#define H5F_ACS_SDATA_BLOCK_SIZE_NAME "sdata_block_size" /* Minimum "small data" allocation block size (when aggregating "small" raw data allocations) */
#define H5F_ACS_GARBG_COLCT_REF_NAME "gc_ref" /* Garbage-collect references */
#define H5F_ACS_FILE_DRV_NAME "driver-id/info" /* File driver ID & info */
#define H5F_ACS_CLOSE_DEGREE_NAME "close_degree" /* File close degree */
#define H5F_ACS_FILE_DRV_NAME "vfd_info" /* File driver ID & info */
#define H5F_ACS_CLOSE_DEGREE_NAME "close_degree" /* File close degree */
#define H5F_ACS_FAMILY_OFFSET_NAME "family_offset" /* Offset position in file for family file driver */
#define H5F_ACS_FAMILY_NEWSIZE_NAME "family_newsize" /* New member size of family driver. (private property only used by h5repart) */
#define H5F_ACS_FAMILY_TO_SEC2_NAME "family_to_sec2" /* Whether to convert family to sec2 driver. (private property only used by h5repart) */
@ -484,7 +487,7 @@
#define H5F_ACS_LATEST_FORMAT_NAME "latest_format" /* 'Use latest format version' flag */
#define H5F_ACS_WANT_POSIX_FD_NAME "want_posix_fd" /* Internal: query the file descriptor from the core VFD, instead of the memory address */
#define H5F_ACS_METADATA_READ_ATTEMPTS_NAME "metadata_read_attempts" /* # of metadata read attempts */
#define H5F_ACS_OBJECT_FLUSH_CB_NAME "object_flush_cb" /* Object flush callback */
#define H5F_ACS_OBJECT_FLUSH_CB_NAME "object_flush_cb" /* Object flush callback */
#define H5F_ACS_EFC_SIZE_NAME "efc_size" /* Size of external file cache */
#define H5F_ACS_FILE_IMAGE_INFO_NAME "file_image_info" /* struct containing initial file image and callback info */
#define H5F_ACS_CLEAR_STATUS_FLAGS_NAME "clear_status_flags" /* Whether to clear superblock status_flags (private property only used by h5clear) */
@ -652,12 +655,12 @@ struct H5B_class_t;
struct H5UC_t;
struct H5O_loc_t;
struct H5HG_heap_t;
struct H5VL_class_t;
struct H5P_genplist_t;
/* Forward declarations for anonymous H5F objects */
/* Main file structures */
typedef struct H5F_t H5F_t;
typedef struct H5F_file_t H5F_file_t;
/* Block aggregation structure */

View File

@ -695,29 +695,26 @@ done:
/*-------------------------------------------------------------------------
* Function: H5Giterate
* Function: H5Giterate
*
* Purpose: Iterates over the entries of a group. The LOC_ID and NAME
* identify the group over which to iterate and IDX indicates
* where to start iterating (zero means at the beginning). The
* OPERATOR is called for each member and the iteration
* continues until the operator returns non-zero or all members
* are processed. The operator is passed a group ID for the
* group being iterated, a member name, and OP_DATA for each
* member.
* Purpose: Iterates over the entries of a group. The LOC_ID and NAME
* identify the group over which to iterate and IDX indicates
* where to start iterating (zero means at the beginning). The
* OPERATOR is called for each member and the iteration
* continues until the operator returns non-zero or all members
* are processed. The operator is passed a group ID for the
* group being iterated, a member name, and OP_DATA for each
* member.
*
* Note: Deprecated in favor of H5Literate
* NOTE: Deprecated in favor of H5Literate
*
* Return: Success: The return value of the first operator that
* returns non-zero, or zero if all members were
* processed with no operator returning non-zero.
* Return: Success: The return value of the first operator that
* returns non-zero, or zero if all members were
* processed with no operator returning non-zero.
*
* Failure: Negative if something goes wrong within the
* library, or the negative value returned by one
* of the operators.
*
* Programmer: Robb Matzke
* Monday, March 23, 1998
* Failure: Negative if something goes wrong within the
* library, or the negative value returned by one
* of the operators.
*
*-------------------------------------------------------------------------
*/
@ -725,21 +722,21 @@ herr_t
H5Giterate(hid_t loc_id, const char *name, int *idx_p, H5G_iterate_t op,
void *op_data)
{
H5G_link_iterate_t lnk_op; /* Link operator */
hsize_t last_obj; /* Index of last object looked at */
hsize_t idx; /* Internal location to hold index */
herr_t ret_value;
H5G_link_iterate_t lnk_op; /* Link operator */
hsize_t last_obj; /* Index of last object looked at */
hsize_t idx; /* Internal location to hold index */
herr_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE5("e", "i*s*Isx*x", loc_id, name, idx_p, op, op_data);
/* Check args */
if(!name || !*name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified")
if(idx_p && *idx_p < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified")
if(!op)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified")
if (!name || !*name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified")
if (idx_p && *idx_p < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified")
if (!op)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified")
/* Set number of objects looked at to zero */
last_obj = 0;
@ -750,11 +747,11 @@ H5Giterate(hid_t loc_id, const char *name, int *idx_p, H5G_iterate_t op,
lnk_op.op_func.op_old = op;
/* Call private function. */
if((ret_value = H5G_iterate(loc_id, name, H5_INDEX_NAME, H5_ITER_INC, idx, &last_obj, &lnk_op, op_data, H5P_DEFAULT, H5AC_ind_read_dxpl_id)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "group iteration failed")
if ((ret_value = H5G_iterate(loc_id, name, H5_INDEX_NAME, H5_ITER_INC, idx, &last_obj, &lnk_op, op_data, H5P_DEFAULT, H5AC_ind_read_dxpl_id)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "group iteration failed")
/* Set the index we stopped at */
if(idx_p)
if (idx_p)
*idx_p = (int)last_obj;
done:

647
src/H5I.c

File diff suppressed because it is too large Load Diff

116
src/H5L.c
View File

@ -50,18 +50,6 @@ typedef struct {
hid_t dxpl_id; /* DXPL to use in callback */
} H5L_trav_gi_t;
/* User data for path traversal routine for getting link info by index */
typedef struct {
/* In */
H5_index_t idx_type; /* Index to use */
H5_iter_order_t order; /* Order to iterate in index */
hsize_t n; /* Offset of link within index */
hid_t dxpl_id; /* DXPL to use in callback */
/* Out */
H5L_info_t *linfo; /* Buffer to return to user */
} H5L_trav_gibi_t;
/* User data for path traversal callback to creating a link */
typedef struct {
H5F_t *file; /* Pointer to the file */
@ -108,47 +96,11 @@ typedef struct {
void *buf; /* User buffer */
} H5L_trav_gv_t;
/* User data for path traversal routine for getting link value by index */
typedef struct {
/* In */
H5_index_t idx_type; /* Index to use */
H5_iter_order_t order; /* Order to iterate in index */
hsize_t n; /* Offset of link within index */
hid_t dxpl_id; /* DXPL to use in callback */
size_t size; /* Size of user buffer */
/* Out */
void *buf; /* User buffer */
} H5L_trav_gvbi_t;
/* User data for path traversal routine for removing link */
typedef struct {
hid_t dxpl_id; /* DXPL to use in callback */
} H5L_trav_rm_t;
/* User data for path traversal routine for removing link by index */
typedef struct {
/* In */
H5_index_t idx_type; /* Index to use */
H5_iter_order_t order; /* Order to iterate in index */
hsize_t n; /* Offset of link within index */
hid_t dxpl_id; /* DXPL to use in callback */
} H5L_trav_rmbi_t;
/* User data for path traversal routine for getting name by index */
typedef struct {
/* In */
H5_index_t idx_type; /* Index to use */
H5_iter_order_t order; /* Order to iterate in index */
hsize_t n; /* Offset of link within index */
size_t size; /* Size of name buffer */
hid_t dxpl_id; /* DXPL to use in callback */
/* Out */
char *name; /* Buffer to return name to user */
ssize_t name_len; /* Length of full name */
} H5L_trav_gnbi_t;
/********************/
/* Local Prototypes */
/********************/
@ -185,8 +137,6 @@ static herr_t H5L__exists_final_cb(H5G_loc_t *grp_loc/*in*/, const char *name,
static herr_t H5L__exists_inter_cb(H5G_loc_t *grp_loc/*in*/, const char *name,
const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/,
H5G_own_loc_t *own_loc/*out*/);
static htri_t H5L__exists(const H5G_loc_t *loc, const char *name, hid_t lapl_id,
hid_t dxpl_id);
static herr_t H5L_get_info_cb(H5G_loc_t *grp_loc/*in*/, const char *name,
const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/,
H5G_own_loc_t *own_loc/*out*/);
@ -866,17 +816,17 @@ H5Lexists(hid_t loc_id, const char *name, hid_t lapl_id)
/* Check arguments */
if(H5G_loc(loc_id, &loc))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
if(!name || !*name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified")
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified")
/* Verify access property list and get correct dxpl */
if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id, loc_id, FALSE) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access and transfer property lists")
/* Check for the existence of the link */
if((ret_value = H5L__exists(&loc, name, lapl_id, dxpl_id)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link info")
if((ret_value = H5L_exists(&loc, name, lapl_id, dxpl_id)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link info")
done:
FUNC_LEAVE_API(ret_value)
@ -1181,24 +1131,20 @@ done:
/*-------------------------------------------------------------------------
* Function: H5Literate
* Function: H5Literate
*
* Purpose: Iterates over links in a group, with user callback routine,
* Purpose: Iterates over links in a group, with user callback routine,
* according to the order within an index.
*
* Same pattern of behavior as H5Giterate.
*
* Return: Success: The return value of the first operator that
* returns non-zero, or zero if all members were
* processed with no operator returning non-zero.
* Return: Success: The return value of the first operator that
* returns non-zero, or zero if all members were
* processed with no operator returning non-zero.
*
* Failure: Negative if something goes wrong within the
* library, or the negative value returned by one
* of the operators.
*
*
* Programmer: Quincey Koziol
* Thursday, November 16, 2006
* Failure: Negative if something goes wrong within the
* library, or the negative value returned by one
* of the operators.
*
*-------------------------------------------------------------------------
*/
@ -1206,25 +1152,25 @@ herr_t
H5Literate(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order,
hsize_t *idx_p, H5L_iterate_t op, void *op_data)
{
H5I_type_t id_type; /* Type of ID */
H5G_link_iterate_t lnk_op; /* Link operator */
hsize_t last_lnk; /* Index of last object looked at */
hsize_t idx; /* Internal location to hold index */
herr_t ret_value; /* Return value */
H5I_type_t id_type; /* Type of ID */
H5G_link_iterate_t lnk_op; /* Link operator */
hsize_t last_lnk; /* Index of last object looked at */
hsize_t idx; /* Internal location to hold index */
herr_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE6("e", "iIiIo*hx*x", grp_id, idx_type, order, idx_p, op, op_data);
/* Check arguments */
id_type = H5I_get_type(grp_id);
if(!(H5I_GROUP == id_type || H5I_FILE == id_type))
if (!(H5I_GROUP == id_type || H5I_FILE == id_type))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument")
if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified")
if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified")
if(!op)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified")
if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified")
if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified")
if (!op)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified")
/* Set up iteration beginning/end info */
idx = (idx_p == NULL ? 0 : *idx_p);
@ -1235,8 +1181,8 @@ H5Literate(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order,
lnk_op.op_func.op_new = op;
/* Iterate over the links */
if((ret_value = H5G_iterate(grp_id, ".", idx_type, order, idx, &last_lnk, &lnk_op, op_data, H5P_DEFAULT, H5AC_ind_read_dxpl_id)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link iteration failed")
if ((ret_value = H5G_iterate(grp_id, ".", idx_type, order, idx, &last_lnk, &lnk_op, op_data, H5P_DEFAULT, H5AC_ind_read_dxpl_id)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link iteration failed")
/* Set the index we stopped at */
if(idx_p)
@ -2930,7 +2876,7 @@ done:
/*-------------------------------------------------------------------------
* Function: H5L__exists
* Function: H5L_exists
*
* Purpose: Returns whether a link exists in a group
*
@ -2944,13 +2890,13 @@ done:
*
*-------------------------------------------------------------------------
*/
static htri_t
H5L__exists(const H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id)
htri_t
H5L_exists(const H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id)
{
H5L_trav_le_t udata; /* User data for traversal */
htri_t ret_value = FAIL; /* Return value */
FUNC_ENTER_STATIC
FUNC_ENTER_NOAPI(FAIL)
/* A path of "/" will always exist in a file */
if(0 == HDstrcmp(name, "/"))
@ -2966,7 +2912,7 @@ H5L__exists(const H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5L__exists() */
} /* H5L_exists() */
/*-------------------------------------------------------------------------

View File

@ -48,6 +48,54 @@
/* Library Private Typedefs */
/****************************/
/* User data for path traversal routine for getting link value by index */
typedef struct {
/* In */
H5_index_t idx_type; /* Index to use */
H5_iter_order_t order; /* Order to iterate in index */
hsize_t n; /* Offset of link within index */
hid_t dxpl_id; /* DXPL to use in callback */
size_t size; /* Size of user buffer */
/* Out */
void *buf; /* User buffer */
} H5L_trav_gvbi_t;
/* User data for path traversal routine for getting link info by index */
typedef struct {
/* In */
H5_index_t idx_type; /* Index to use */
H5_iter_order_t order; /* Order to iterate in index */
hsize_t n; /* Offset of link within index */
hid_t dxpl_id; /* DXPL to use in callback */
/* Out */
H5L_info_t *linfo; /* Buffer to return to user */
} H5L_trav_gibi_t;
/* User data for path traversal routine for getting name by index */
typedef struct {
/* In */
H5_index_t idx_type; /* Index to use */
H5_iter_order_t order; /* Order to iterate in index */
hsize_t n; /* Offset of link within index */
size_t size; /* Size of name buffer */
hid_t dxpl_id; /* DXPL to use in callback */
/* Out */
char *name; /* Buffer to return name to user */
ssize_t name_len; /* Length of full name */
} H5L_trav_gnbi_t;
/* User data for path traversal routine for removing link by index */
typedef struct {
/* In */
H5_index_t idx_type; /* Index to use */
H5_iter_order_t order; /* Order to iterate in index */
hsize_t n; /* Offset of link within index */
hid_t dxpl_id; /* DXPL to use in callback */
} H5L_trav_rmbi_t;
/* Structure for external link traversal callback property */
typedef struct H5L_elink_cb_t {
H5L_elink_traverse_t func;
@ -81,6 +129,7 @@ H5_DLL herr_t H5L_move(H5G_loc_t *src_loc, const char *src_name,
hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id);
H5_DLL htri_t H5L_exists_tolerant(const H5G_loc_t *loc, const char *name, hid_t lapl_id,
hid_t dxpl_id);
H5_DLL htri_t H5L_exists(const H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id);
H5_DLL herr_t H5L_get_info(const H5G_loc_t *loc, const char *name,
H5L_info_t *linkbuf/*out*/, hid_t lapl_id, hid_t dxpl_id);
H5_DLL herr_t H5L_delete(H5G_loc_t *loc, const char *name, hid_t lapl_id,

View File

@ -247,20 +247,20 @@ struct H5O_msg_class_t {
};
struct H5O_mesg_t {
const H5O_msg_class_t *type; /*type of message */
hbool_t dirty; /*raw out of date wrt native */
uint8_t flags; /*message flags */
H5O_msg_crt_idx_t crt_idx; /*message creation index */
unsigned chunkno; /*chunk number for this mesg */
void *native; /*native format message */
uint8_t *raw; /*ptr to raw data */
size_t raw_size; /*size with alignment */
const H5O_msg_class_t *type; /* type of message */
hbool_t dirty; /* raw out of date wrt native */
uint8_t flags; /* message flags */
H5O_msg_crt_idx_t crt_idx; /* message creation index */
unsigned chunkno; /* chunk number for this mesg */
void *native; /* native format message */
uint8_t *raw; /* pointer to raw data */
size_t raw_size; /* size with alignment */
};
/* Struct for storing information about "best" message to move to new chunk */
typedef struct H5O_msg_alloc_info_t {
int msgno; /* Index in message array */
unsigned id; /* Message type ID on disk */
unsigned id; /* Message type ID on disk */
unsigned chunkno; /* Index in chunk array */
size_t gap_size; /* Size of any "gap" in the chunk immediately after message */
size_t null_size; /* Size of any null message in the chunk immediately after message */

View File

@ -26,6 +26,7 @@
/* Early typedefs to avoid circular dependencies */
typedef struct H5O_t H5O_t;
typedef struct H5O_fill_t H5O_fill_t;
/* Include the public header file for this API */
#include "H5Opublic.h" /* Object header functions */
@ -308,7 +309,7 @@ typedef struct H5O_linfo_t {
* message if it's shared.
*/
typedef struct H5O_fill_t {
struct H5O_fill_t {
H5O_shared_t sh_loc; /* Shared message info (must be first) */
unsigned version; /* Encoding version number */
@ -318,7 +319,7 @@ typedef struct H5O_fill_t {
H5D_alloc_time_t alloc_time; /* time to allocate space */
H5D_fill_time_t fill_time; /* time to write fill value */
hbool_t fill_defined; /* whether fill value is defined */
} H5O_fill_t;
};
/*
* Link message.

View File

@ -389,8 +389,8 @@ static const unsigned H5F_def_page_buf_min_raw_perc_g = H5F_ACS_PAGE_BUFFER_MIN_
static herr_t
H5P__facc_reg_prop(H5P_genclass_t *pclass)
{
const H5FD_driver_prop_t def_driver_prop = H5F_ACS_FILE_DRV_DEF; /* Default VFL driver ID & info (initialized from a variable) */
herr_t ret_value = SUCCEED; /* Return value */
const H5FD_driver_prop_t def_driver_prop = H5F_ACS_FILE_DRV_DEF; /* Default VFL driver ID & info (initialized from a variable) */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC

View File

@ -11,10 +11,9 @@
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Module Info: Operations on bit vectors. A bit vector is an array of bytes
* with the least-significant bits in the first byte. That is,
* the bytes are in little-endian order.
/* Module Info: Operations on bit vectors. A bit vector is an array of bytes
* with the least-significant bits in the first byte. That is,
* the bytes are in little-endian order.
*/
#include "H5Tmodule.h" /* This source code file is part of the H5T module */
@ -29,14 +28,11 @@
/*-------------------------------------------------------------------------
* Function: H5T__bit_copy
* Function: H5T__bit_copy
*
* Purpose: Copies bits from one vector to another.
* Purpose: Copies bits from one vector to another.
*
* Return: void
*
* Programmer: Robb Matzke
* Wednesday, June 10, 1998
* Return: void
*
*-------------------------------------------------------------------------
*/
@ -50,8 +46,7 @@ H5T__bit_copy(uint8_t *dst, size_t dst_offset, const uint8_t *src,
FUNC_ENTER_PACKAGE_NOERR
/*
* Normalize the offset to be a byte number and a bit offset within that
/* Normalize the offset to be a byte number and a bit offset within that
* byte.
*/
s_idx = src_offset / 8;
@ -59,8 +54,7 @@ H5T__bit_copy(uint8_t *dst, size_t dst_offset, const uint8_t *src,
src_offset %= 8;
dst_offset %= 8;
/*
* Get things rolling. This means copying bits until we're aligned on a
/* Get things rolling. This means copying bits until we're aligned on a
* source byte. This the following example, five bits are copied to the
* destination.
*
@ -75,30 +69,29 @@ H5T__bit_copy(uint8_t *dst, size_t dst_offset, const uint8_t *src,
* ...+---------------+---------------+
* dst[d_idx+1] dst[d_idx]
*/
while(src_offset && size > 0) {
size_t nbits = MIN3(size, 8 - dst_offset, 8 - src_offset);
size_t mask = ((size_t)1 << nbits) - 1;
while (src_offset && size > 0) {
size_t nbits = MIN3(size, 8 - dst_offset, 8 - src_offset);
size_t mask = ((size_t)1 << nbits) - 1;
dst[d_idx] &= (uint8_t)~(mask << dst_offset);
dst[d_idx] = (uint8_t)(dst[d_idx] | (((src[s_idx] >> src_offset) & (uint8_t)mask) << dst_offset));
dst[d_idx] &= (uint8_t)~(mask << dst_offset);
dst[d_idx] = (uint8_t)(dst[d_idx] | (((src[s_idx] >> src_offset) & (uint8_t)mask) << dst_offset));
src_offset += nbits;
if(src_offset >= 8) {
s_idx++;
src_offset %= 8;
} /* end if */
src_offset += nbits;
if (src_offset >= 8) {
s_idx++;
src_offset %= 8;
}
dst_offset += nbits;
if(dst_offset >= 8) {
d_idx++;
dst_offset %= 8;
} /* end if */
dst_offset += nbits;
if (dst_offset >= 8) {
d_idx++;
dst_offset %= 8;
}
size -= nbits;
} /* end while */
size -= nbits;
}
/*
* The middle bits. We are aligned on a source byte which needs to be
/* The middle bits. We are aligned on a source byte which needs to be
* copied to two (or one in the degenerate case) destination bytes.
*
* src[s_idx]
@ -122,48 +115,48 @@ H5T__bit_copy(uint8_t *dst, size_t dst_offset, const uint8_t *src,
mask_lo = ((size_t)1 << (8 - shift)) - 1;
mask_hi = (~mask_lo) & 0xff;
for(/*void*/; size > 8; size -= 8, d_idx++, s_idx++) {
if(shift) {
dst[d_idx + 0] &= (uint8_t)(~(mask_lo << shift));
dst[d_idx + 0] |= (uint8_t)((src[s_idx] & mask_lo) << shift);
dst[d_idx + 1] &= (uint8_t)(~(mask_hi >> (8 - shift)));
dst[d_idx + 1] |= (uint8_t)((src[s_idx] & mask_hi) >> (8 - shift));
} /* end if */
for (/*void*/; size > 8; size -= 8, d_idx++, s_idx++) {
if (shift) {
dst[d_idx + 0] &= (uint8_t)(~(mask_lo << shift));
dst[d_idx + 0] |= (uint8_t)((src[s_idx] & mask_lo) << shift);
dst[d_idx + 1] &= (uint8_t)(~(mask_hi >> (8 - shift)));
dst[d_idx + 1] |= (uint8_t)((src[s_idx] & mask_hi) >> (8 - shift));
}
else
dst[d_idx] = src[s_idx];
} /* end for */
dst[d_idx] = src[s_idx];
}
/* Finish up */
while(size > 0) {
size_t nbits = (size_t)MIN3 (size, 8 - dst_offset, 8 - src_offset);
size_t mask = ((size_t)1 << nbits) - 1;
while (size > 0) {
size_t nbits = (size_t)MIN3 (size, 8 - dst_offset, 8 - src_offset);
size_t mask = ((size_t)1 << nbits) - 1;
dst[d_idx] &= (uint8_t)(~(mask << dst_offset));
dst[d_idx] = (uint8_t)(dst[d_idx] | (((src[s_idx] >> src_offset) & (uint8_t)mask) << dst_offset));
dst[d_idx] &= (uint8_t)(~(mask << dst_offset));
dst[d_idx] = (uint8_t)(dst[d_idx] | (((src[s_idx] >> src_offset) & (uint8_t)mask) << dst_offset));
src_offset += nbits;
if(src_offset >= 8) {
s_idx++;
src_offset %= 8;
} /* end if */
src_offset += nbits;
if (src_offset >= 8) {
s_idx++;
src_offset %= 8;
}
dst_offset += nbits;
if(dst_offset >= 8) {
d_idx++;
dst_offset %= 8;
} /* end if */
dst_offset += nbits;
if (dst_offset >= 8) {
d_idx++;
dst_offset %= 8;
}
size -= nbits;
} /* end while */
size -= nbits;
}
FUNC_LEAVE_NOAPI_VOID
} /* end H5T__bit_copy() */
/*-------------------------------------------------------------------------
* Function: H5T__bit_shift
* Function: H5T__bit_shift
*
* Purpose: Simulation of hardware shifting. Shifts a bit vector
* Purpose: Simulation of hardware shifting. Shifts a bit vector
* in a way similar to shifting a variable value, like
* value <<= 3, or value >>= 16. SHIFT_DIST is positive for
* left shift, negative for right shift. The bit vector starts
@ -173,10 +166,7 @@ H5T__bit_copy(uint8_t *dst, size_t dst_offset, const uint8_t *src,
* For example, if we have a bit sequence 00011100, offset=2,
* size=3, shift_dist=2, the result will be 00010000.
*
* Return: void
*
* Programmer: Raymond Lu
* Monday, April 12, 2004
* Return: void
*
*-------------------------------------------------------------------------
*/
@ -193,25 +183,25 @@ H5T__bit_shift(uint8_t *buf, ssize_t shift_dist, size_t offset, size_t size)
HDassert(buf);
HDassert(size);
if(shift_dist) {
if (shift_dist) {
size_t abs_shift_dist = (size_t)ABS(shift_dist);
if(abs_shift_dist >= size)
if (abs_shift_dist >= size)
H5T__bit_set(buf, offset, size, 0);
else {
size_t buf_size = (size / 8) + 1; /* Size of shift buffer needed */
uint8_t *shift_buf; /* Pointer to shift buffer */
/* Wrap the local buffer for serialized header info */
if(NULL == (wb = H5WB_wrap(tmp_buf, sizeof(tmp_buf))))
if (NULL == (wb = H5WB_wrap(tmp_buf, sizeof(tmp_buf))))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't wrap buffer")
/* Get a pointer to a buffer that's large enough */
if(NULL == (shift_buf = (uint8_t *)H5WB_actual(wb, buf_size)))
if (NULL == (shift_buf = (uint8_t *)H5WB_actual(wb, buf_size)))
HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, FAIL, "can't get actual buffer")
/* Shift vector by making copies */
if(shift_dist > 0) { /* left shift */
if (shift_dist > 0) { /* left shift */
/* Copy part to be shifted to a temporary buffer */
H5T__bit_copy(shift_buf, (size_t)0, buf, offset, size - abs_shift_dist);
@ -220,18 +210,18 @@ H5T__bit_shift(uint8_t *buf, ssize_t shift_dist, size_t offset, size_t size)
/* Zero-set the left part*/
H5T__bit_set(buf, offset, abs_shift_dist, 0);
} /* end if */
}
else { /* right shift */
H5T__bit_copy(shift_buf, (size_t)0, buf, offset + abs_shift_dist, size - abs_shift_dist);
H5T__bit_copy(buf, offset, shift_buf, (size_t)0, size - abs_shift_dist);
H5T__bit_set(buf, offset + size - abs_shift_dist, abs_shift_dist, 0);
} /* end else */
}
} /* end else */
} /* end if */
done:
/* Release resources */
if(wb && H5WB_unwrap(wb) < 0)
if (wb && H5WB_unwrap(wb) < 0)
HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "can't close wrapped buffer")
FUNC_LEAVE_NOAPI(ret_value)
@ -239,27 +229,24 @@ done:
/*-------------------------------------------------------------------------
* Function: H5T__bit_get_d
* Function: H5T__bit_get_d
*
* Purpose: Return a small bit sequence as a number. Bit vector starts
* Purpose: Return a small bit sequence as a number. Bit vector starts
* at OFFSET and is SIZE bits long.
*
* Return: Success: The bit sequence interpretted as an unsigned
* integer.
* Return: Success: The bit sequence interpretted as an unsigned
* integer.
*
* Failure: 0
*
* Programmer: Robb Matzke
* Tuesday, June 23, 1998
* Failure: 0
*
*-------------------------------------------------------------------------
*/
uint64_t
H5T__bit_get_d(uint8_t *buf, size_t offset, size_t size)
{
uint64_t val = 0;
size_t i, hs;
uint64_t ret_value = 0; /* Return value */
uint64_t val = 0;
size_t i, hs;
uint64_t ret_value = 0; /* Return value */
FUNC_ENTER_PACKAGE_NOERR
@ -271,11 +258,11 @@ H5T__bit_get_d(uint8_t *buf, size_t offset, size_t size)
break;
case H5T_ORDER_BE:
for(i = 0, hs = sizeof(val) / 2; i < hs; i++) {
for (i = 0, hs = sizeof(val) / 2; i < hs; i++) {
uint8_t tmp = ((uint8_t*)&val)[i];
((uint8_t*)&val)[i] = ((uint8_t*)&val)[sizeof(val) - (i + 1)];
((uint8_t*)&val)[sizeof(val) - (i + 1)] = tmp;
} /* end for */
}
break;
case H5T_ORDER_ERROR:
@ -285,7 +272,7 @@ H5T__bit_get_d(uint8_t *buf, size_t offset, size_t size)
default:
/* Unknown endianness. Bail out. */
HGOTO_DONE(UFAIL)
} /* end switch */
}
/* Set return value */
ret_value = val;
@ -296,14 +283,11 @@ done:
/*-------------------------------------------------------------------------
* Function: H5T__bit_set_d
* Function: H5T__bit_set_d
*
* Purpose: Sets part of a bit vector to the specified unsigned value.
* Purpose: Sets part of a bit vector to the specified unsigned value.
*
* Return: void
*
* Programmer: Robb Matzke
* Wednesday, June 24, 1998
* Return: void
*
*-------------------------------------------------------------------------
*/
@ -321,11 +305,11 @@ H5T__bit_set_d(uint8_t *buf, size_t offset, size_t size, uint64_t val)
break;
case H5T_ORDER_BE:
for(i = 0, hs = sizeof(val) / 2; i < hs; i++) {
for (i = 0, hs = sizeof(val) / 2; i < hs; i++) {
uint8_t tmp = ((uint8_t *)&val)[i];
((uint8_t *)&val)[i] = ((uint8_t *)&val)[sizeof(val) - (i + 1)];
((uint8_t *)&val)[sizeof(val) - (i + 1)] = tmp;
} /* end for */
}
break;
case H5T_ORDER_ERROR:
@ -334,7 +318,7 @@ H5T__bit_set_d(uint8_t *buf, size_t offset, size_t size, uint64_t val)
case H5T_ORDER_MIXED:
default:
HDabort();
} /* end switch */
}
H5T__bit_copy(buf, offset, (uint8_t*)&val, (size_t)0, size);
@ -343,24 +327,19 @@ H5T__bit_set_d(uint8_t *buf, size_t offset, size_t size, uint64_t val)
/*-------------------------------------------------------------------------
* Function: H5T__bit_set
* Function: H5T__bit_set
*
* Purpose: Sets or clears bits in a contiguous region of a vector
* beginning at bit OFFSET and continuing for SIZE bits.
* Purpose: Sets or clears bits in a contiguous region of a vector
* beginning at bit OFFSET and continuing for SIZE bits.
*
* Return: void
*
* Programmer: Robb Matzke
* Wednesday, June 10, 1998
*
* Modifications:
* Return: void
*
*-------------------------------------------------------------------------
*/
void
H5T__bit_set(uint8_t *buf, size_t offset, size_t size, hbool_t value)
{
int idx;
int idx;
FUNC_ENTER_PACKAGE_NOERR
@ -369,54 +348,51 @@ H5T__bit_set(uint8_t *buf, size_t offset, size_t size, hbool_t value)
offset %= 8;
/* The first partial byte */
if(size && offset % 8) {
size_t nbits = MIN(size, 8 - offset);
unsigned mask = ((unsigned)1 << nbits) - 1;
if (size && offset % 8) {
size_t nbits = MIN(size, 8 - offset);
unsigned mask = ((unsigned)1 << nbits) - 1;
if(value)
buf[idx] = (uint8_t)(buf[idx] | (mask << offset));
else
buf[idx] &= (uint8_t)(~(mask << offset));
if (value)
buf[idx] = (uint8_t)(buf[idx] | (mask << offset));
else
buf[idx] &= (uint8_t)(~(mask << offset));
idx++;
size -= nbits;
} /* end if */
idx++;
size -= nbits;
}
/* The middle bytes */
while(size >= 8) {
buf[idx++] = value ? 0xff : 0x00;
size -= 8;
} /* end while */
while (size >= 8) {
buf[idx++] = value ? 0xff : 0x00;
size -= 8;
}
/* The last partial byte */
if(size) {
if(value)
buf[idx] |= (uint8_t)(((unsigned)1 << size) - 1);
else
buf[idx] &= (uint8_t)(~(((unsigned)1 << size) - 1));
} /* end if */
if (size) {
if (value)
buf[idx] |= (uint8_t)(((unsigned)1 << size) - 1);
else
buf[idx] &= (uint8_t)(~(((unsigned)1 << size) - 1));
}
FUNC_LEAVE_NOAPI_VOID
} /* end H5T__bit_set() */
/*-------------------------------------------------------------------------
* Function: H5T__bit_find
* Function: H5T__bit_find
*
* Purpose: Finds the first bit with the specified VALUE within a region
* of a bit vector. The region begins at OFFSET and continues
* for SIZE bits, but the region can be searched from the least
* significat end toward the most significant end(H5T_BIT_LSB
* as DIRECTION), or from the most significant end to the least
* significant end(H5T_BIT_MSB as DIRECTION).
* Purpose: Finds the first bit with the specified VALUE within a region
* of a bit vector. The region begins at OFFSET and continues
* for SIZE bits, but the region can be searched from the least
* significat end toward the most significant end(H5T_BIT_LSB
* as DIRECTION), or from the most significant end to the least
* significant end(H5T_BIT_MSB as DIRECTION).
*
* Return: Success: The position of the bit found, relative to
* the offset.
* Return: Success: The position of the bit found, relative to
* the offset.
*
* Failure: -1
*
* Programmer: Robb Matzke
* Wednesday, June 10, 1998
* Failure: -1
*
*-------------------------------------------------------------------------
*/
@ -424,9 +400,9 @@ ssize_t
H5T__bit_find(uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction,
hbool_t value)
{
ssize_t base = (ssize_t)offset;
ssize_t idx, i;
size_t iu;
ssize_t base = (ssize_t)offset;
ssize_t idx, i;
size_t iu;
ssize_t ret_value = (-1); /* Return value */
/* Use FUNC_ENTER_PACKAGE_NOERR here to avoid performance issues */
@ -435,16 +411,16 @@ H5T__bit_find(uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction,
/* Some functions call this with value=TRUE */
HDassert(TRUE == 1);
switch(direction) {
switch (direction) {
case H5T_BIT_LSB:
/* Calculate index */
idx = (ssize_t)(offset / 8);
offset %= 8;
/* Beginning */
if(offset) {
for(iu = offset; iu < 8 && size > 0; iu++, size--)
if(value == (hbool_t)((buf[idx] >> iu) & 0x01))
if (offset) {
for (iu = offset; iu < 8 && size > 0; iu++, size--)
if (value == (hbool_t)((buf[idx] >> iu) & 0x01))
HGOTO_DONE(8 * idx + (ssize_t)iu - base);
offset = 0;
@ -452,10 +428,10 @@ H5T__bit_find(uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction,
} /* end if */
/* Middle */
while(size >= 8) {
if((value ? 0x00 : 0xff) != buf[idx])
for(i = 0; i < 8; i++)
if(value == (hbool_t)((buf[idx] >> i) & 0x01))
while (size >= 8) {
if ((value ? 0x00 : 0xff) != buf[idx])
for (i = 0; i < 8; i++)
if (value == (hbool_t)((buf[idx] >> i) & 0x01))
HGOTO_DONE(8 * idx + i - base);
size -= 8;
@ -463,8 +439,8 @@ H5T__bit_find(uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction,
} /* end while */
/* End */
for(i = 0; i < (ssize_t)size; i++)
if(value == (hbool_t)((buf[idx] >> i) & 0x01))
for (i = 0; i < (ssize_t)size; i++)
if (value == (hbool_t)((buf[idx] >> i) & 0x01))
HGOTO_DONE(8 * idx + i - base);
break;
@ -474,19 +450,19 @@ H5T__bit_find(uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction,
offset %= 8;
/* Beginning */
if(size > 8 - offset && (offset + size) % 8) {
for(iu = (offset + size) % 8; iu > 0; --iu, --size)
if(value == (hbool_t)((buf[idx] >> (iu - 1)) & 0x01))
if (size > 8 - offset && (offset + size) % 8) {
for (iu = (offset + size) % 8; iu > 0; --iu, --size)
if (value == (hbool_t)((buf[idx] >> (iu - 1)) & 0x01))
HGOTO_DONE(8 * idx + (ssize_t)(iu - 1) - base);
--idx;
} /* end if */
/* Middle */
while(size >= 8) {
if((value ? 0x00 : 0xff) != buf[idx]) {
for(i = 7; i >= 0; --i)
if(value == (hbool_t)((buf[idx] >> i) & 0x01))
while (size >= 8) {
if ((value ? 0x00 : 0xff) != buf[idx]) {
for (i = 7; i >= 0; --i)
if (value == (hbool_t)((buf[idx] >> i) & 0x01))
HGOTO_DONE(8 * idx + i - base);
} /* end if */
@ -495,11 +471,11 @@ H5T__bit_find(uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction,
} /* end while */
/* End */
if(size > 0) {
for(iu = offset + size; iu > offset; --iu)
if(value == (hbool_t)((buf[idx] >> (iu - 1)) & 0x01))
if (size > 0) {
for (iu = offset + size; iu > offset; --iu)
if (value == (hbool_t)((buf[idx] >> (iu - 1)) & 0x01))
HGOTO_DONE(8 * idx + (ssize_t)(iu - 1) - base);
} /* end if */
}
break;
default:
@ -519,17 +495,14 @@ done:
*
* Return: The carry-out value. TRUE if overflows, FALSE otherwise.
*
* Programmer: Robb Matzke
* Friday, June 26, 1998
*
*-------------------------------------------------------------------------
*/
hbool_t
H5T__bit_inc(uint8_t *buf, size_t start, size_t size)
{
size_t idx = start / 8;
unsigned carry = 1;
unsigned acc, mask;
size_t idx = start / 8;
unsigned carry = 1;
unsigned acc, mask;
/* Use FUNC_ENTER_PACKAGE_NOERR here to avoid performance issues */
FUNC_ENTER_PACKAGE_NOERR
@ -539,7 +512,7 @@ H5T__bit_inc(uint8_t *buf, size_t start, size_t size)
start %= 8;
/* The first partial byte */
if(start) {
if (start) {
if(size + start < 8)
mask = ((unsigned)1 << size) - 1;
else
@ -552,34 +525,34 @@ H5T__bit_inc(uint8_t *buf, size_t start, size_t size)
size -= MIN(size, 8 - start);
start = 0;
idx++;
} /* end if */
}
/* The middle */
while(carry && size >= 8) {
while (carry && size >= 8) {
acc = buf[idx];
acc++;
carry = acc & 0x100;
buf[idx] = acc & 0xff;
idx++;
size -= 8;
} /* end while */
}
/* The last bits */
if(carry && size > 0) {
if (carry && size > 0) {
mask = ((unsigned)1 << size) - 1;
acc = buf[idx] & mask;
acc++;
carry = acc & ((unsigned)1 << size);
buf[idx] &= (uint8_t)(~mask);
buf[idx] |= (uint8_t)(acc & mask);
} /* end if */
}
FUNC_LEAVE_NOAPI(carry ? TRUE : FALSE)
} /* end H5T__bit_inc() */
/*-------------------------------------------------------------------------
* Function: H5T__bit_dec
* Function: H5T__bit_dec
*
* Purpose: Decrement part of a bit field by substracting 1. The bit
* field starts with bit position START and is SIZE bits long.
@ -587,18 +560,15 @@ H5T__bit_inc(uint8_t *buf, size_t start, size_t size)
* Return: The "borrow-in" value. It's TRUE if underflows, FALSE
* otherwise.
*
* Programmer: Raymond Lu
* March 17, 2004
*
*-------------------------------------------------------------------------
*/
hbool_t
H5T__bit_dec(uint8_t *buf, size_t start, size_t size)
{
size_t idx = start / 8;
size_t idx = start / 8;
size_t pos = start % 8;
uint8_t tmp;
unsigned borrow = 0;
unsigned borrow = 0;
/* Use FUNC_ENTER_PACKAGE_NOERR here to avoid performance issues */
FUNC_ENTER_PACKAGE_NOERR
@ -607,71 +577,72 @@ H5T__bit_dec(uint8_t *buf, size_t start, size_t size)
HDassert(size);
/* The first partial byte */
if((size + start - 1) / 8 > idx) { /*bit sequence doesn't end in the same byte as starts*/
if ((size + start - 1) / 8 > idx) {
/* The bit sequence doesn't end in the same byte as starts */
/* Example: a sequence like 11000100 and start = 3. We substract 00001000 from
* it and get 10111100. If a sequence is 00000111, we do right shift for START
* bits and get 00000000. So we need to borrow from higher byte when we substract
* 00001000.
*/
if(!(buf[idx] >> pos))
if (!(buf[idx] >> pos))
borrow = 1;
buf[idx] = (uint8_t)(buf[idx] - (1 << pos));
idx++;
size -= (8 - pos);
/* The middle bytes */
while(borrow && size >= 8) {
if(buf[idx])
while (borrow && size >= 8) {
if (buf[idx])
borrow = 0;
buf[idx]--;
idx++;
size -= 8;
} /* end while */
}
/* The last partial byte */
if(borrow && size > 0) {
if (borrow && size > 0) {
/* Similar to the first byte case, where sequence ends in the same byte as starts */
tmp = buf[idx];
buf[idx]--;
if((buf[idx] >> size) != tmp >> size)
if ((buf[idx] >> size) != tmp >> size)
buf[idx] = (uint8_t)(buf[idx] + (1 << size));
} /* end if */
} /* end if */
else { /* bit sequence ends in the same byte as starts */
}
}
else {
/* The bit sequence ends in the same byte as starts */
/* Example: a sequence like 11000100 and pos=3, size=3. We substract 00001000
* and get 10111100. A bit is borrowed from 6th bit(buf[idx]>>6=00000010, tmp>>6=00000011,
* not equal). We need to put this bit back by increment 1000000.
*/
tmp = buf[idx];
buf[idx] = (uint8_t)(buf[idx] - (1 << pos));
if((buf[idx] >> (pos + size)) != tmp >> (pos + size)) {
if ((buf[idx] >> (pos + size)) != tmp >> (pos + size)) {
buf[idx] = (uint8_t)(buf[idx] + (1 << (pos + size)));
borrow = 1;
} /* end if */
} /* end else */
}
}
FUNC_LEAVE_NOAPI(borrow ? TRUE : FALSE)
} /* end H5T__bit_dec() */
/*-------------------------------------------------------------------------
* Function: H5T__bit_neg
* Function: H5T__bit_neg
*
* Purpose: negate part of a bit sequence. The bit
* field starts with bit position START and is SIZE bits long.
* Purpose: Negate part of a bit sequence. The bit field starts with
* bit position START and is SIZE bits long.
*
* Return: void
*
* Programmer: Raymond Lu
* March 19, 2004
* Return: void
*
*-------------------------------------------------------------------------
*/
void
H5T__bit_neg(uint8_t *buf, size_t start, size_t size)
{
size_t idx = start / 8;
size_t idx = start / 8;
size_t pos = start % 8;
uint8_t tmp[1];
@ -695,17 +666,19 @@ H5T__bit_neg(uint8_t *buf, size_t start, size_t size)
buf[idx] = (uint8_t)~(buf[idx]);
idx++;
size -= 8;
} /* end while */
}
/* The last partial byte */
if(size > 0) {
/* Similar to the first byte case, where sequence ends in the same byte as starts */
tmp[0] = (uint8_t)~buf[idx];
H5T__bit_copy(&(buf[idx]), (size_t)0, tmp, (size_t)0, size);
} /* end if */
} /* end if */
else /* bit sequence ends in the same byte as starts */
}
}
else {
/* bit sequence ends in the same byte as starts */
H5T__bit_copy(&(buf[idx]), pos, tmp, pos, size);
}
FUNC_LEAVE_NOAPI_VOID
} /* end H5T__bit_neg() */

View File

@ -4079,13 +4079,15 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
sp = dp = (uint8_t*)buf;
direction = 1;
olap = nelmts;
} else if (src_p->shared->size>=dst_p->shared->size) {
}
else if (src_p->shared->size>=dst_p->shared->size) {
double olap_d = HDceil((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 {
}
else {
double olap_d = HDceil((double)(src_p->shared->size)/
(double)(dst_p->shared->size-src_p->shared->size));
olap = (size_t)olap_d;
@ -4127,7 +4129,8 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
if (direction>0) {
s = sp;
d = elmtno<olap ? dbuf : dp;
} else {
}
else {
s = sp;
d = elmtno+olap >= nelmts ? dbuf : dp;
}
@ -4136,7 +4139,8 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
if (d==dbuf) {
HDassert((dp>=sp && dp<sp+src_p->shared->size) ||
(sp>=dp && sp<dp+dst_p->shared->size));
} else {
}
else {
HDassert((dp<sp && dp+dst_p->shared->size<=sp) ||
(sp<dp && sp+src_p->shared->size<=dp));
}
@ -4154,7 +4158,8 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
s[src_p->shared->size-(i+1)] = s[i];
s[i] = tmp1;
}
} else if (H5T_ORDER_VAX==src.order) {
}
else if (H5T_ORDER_VAX==src.order) {
tsize = src_p->shared->size;
HDassert(0 == tsize % 2);
@ -4187,7 +4192,8 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
H5T__bit_set (d, dst.u.f.epos, dst.u.f.esize, FALSE);
H5T__bit_set (d, dst.u.f.mpos, dst.u.f.msize, FALSE);
goto padding;
} else if (H5T__bit_find (s, src.u.f.epos, src.u.f.esize,
}
else if (H5T__bit_find (s, src.u.f.epos, src.u.f.esize,
H5T_BIT_LSB, FALSE)<0) {
/* +Inf or -Inf */
if(cb_struct.func) { /*If user's exception handler is present, use it*/
@ -4210,16 +4216,19 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
*this case.*/
if (H5T_NORM_NONE==dst.u.f.norm)
H5T__bit_set (d, dst.u.f.mpos+dst.u.f.msize-1, (size_t)1, TRUE);
} else if(except_ret == H5T_CONV_HANDLED) {
}
else if(except_ret == H5T_CONV_HANDLED) {
/*No need to reverse the order of destination because user handles it*/
reverse = FALSE;
goto next;
} else if(except_ret == H5T_CONV_ABORT)
}
else if(except_ret == H5T_CONV_ABORT)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception")
goto padding;
}
} else if (H5T_NORM_NONE==src.u.f.norm && H5T__bit_find (s, src.u.f.mpos, src.u.f.msize-1,
}
else if (H5T_NORM_NONE==src.u.f.norm && H5T__bit_find (s, src.u.f.mpos, src.u.f.msize-1,
H5T_BIT_LSB, TRUE)<0 && H5T__bit_find (s, src.u.f.epos, src.u.f.esize,
H5T_BIT_LSB, FALSE)<0) {
/*This is a special case for the source of no implied mantissa bit.
@ -4246,11 +4255,13 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
*this case.*/
if (H5T_NORM_NONE==dst.u.f.norm)
H5T__bit_set (d, dst.u.f.mpos+dst.u.f.msize-1, (size_t)1, TRUE);
} else if(except_ret == H5T_CONV_HANDLED) {
}
else if(except_ret == H5T_CONV_HANDLED) {
/*No need to reverse the order of destination because user handles it*/
reverse = FALSE;
goto next;
} else if(except_ret == H5T_CONV_ABORT)
}
else if(except_ret == H5T_CONV_ABORT)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception")
goto padding;
@ -4259,7 +4270,8 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
* still need to handle legacy VAX files so this code must
* remain in place.
*/
} else if (H5T__bit_find (s, src.u.f.epos, src.u.f.esize,
}
else if (H5T__bit_find (s, src.u.f.epos, src.u.f.esize,
H5T_BIT_LSB, FALSE)<0) {
/* NaN */
if(cb_struct.func) { /*If user's exception handler is present, use it*/
@ -4275,11 +4287,13 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
H5T__bit_copy (d, dst.u.f.sign, s, src.u.f.sign, (size_t)1);
H5T__bit_set (d, dst.u.f.epos, dst.u.f.esize, TRUE);
H5T__bit_set(d, dst.u.f.mpos, dst.u.f.msize, TRUE);
} else if(except_ret == H5T_CONV_HANDLED) {
}
else if(except_ret == H5T_CONV_HANDLED) {
/*No need to reverse the order of destination because user handles it*/
reverse = FALSE;
goto next;
} else if(except_ret == H5T_CONV_ABORT)
}
else if(except_ret == H5T_CONV_ABORT)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception")
goto padding;
@ -4292,7 +4306,7 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
*/
expo = (int64_t)H5T__bit_get_d(s, src.u.f.epos, src.u.f.esize);
if(expo==0)
if (expo==0)
denormalized=TRUE;
/*
@ -4302,16 +4316,19 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
implied = 1;
mpos = src.u.f.mpos;
mrsh = 0;
if(0 == expo || H5T_NORM_NONE == src.u.f.norm) {
if((bitno = H5T__bit_find(s, src.u.f.mpos, src.u.f.msize, H5T_BIT_MSB, TRUE)) > 0) {
if (0 == expo || H5T_NORM_NONE == src.u.f.norm) {
if ((bitno = H5T__bit_find(s, src.u.f.mpos, src.u.f.msize, H5T_BIT_MSB, TRUE)) > 0) {
msize = (size_t)bitno;
} else if (0==bitno) {
}
else if (0==bitno) {
msize = 1;
H5T__bit_set(s, src.u.f.mpos, (size_t)1, FALSE);
}
} else if (H5T_NORM_IMPLIED==src.u.f.norm) {
}
else if (H5T_NORM_IMPLIED==src.u.f.norm) {
msize = src.u.f.msize;
} else {
}
else {
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "normalization method not implemented yet")
}
@ -4328,9 +4345,11 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
if (0==expo || H5T_NORM_NONE==src.u.f.norm) {
HDassert(bitno>=0);
expo -= (int64_t)((src.u.f.ebias - 1) + (src.u.f.msize - (size_t)bitno));
} else if (H5T_NORM_IMPLIED==src.u.f.norm) {
}
else if (H5T_NORM_IMPLIED==src.u.f.norm) {
expo -= (int64_t)src.u.f.ebias;
} else {
}
else {
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "normalization method not implemented yet")
}
@ -4353,7 +4372,8 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
expo = 0;
H5T__bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE);
msize = 0;
} else if (expo<=0) {
}
else if (expo<=0) {
/*
* The exponent is too small to fit in the exponent field,
* but by shifting the mantissa to the right we can
@ -4363,7 +4383,8 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
mrsh += (size_t)(1 - expo);
expo = 0;
denormalized=TRUE;
} else if (expo>=expo_max) {
}
else if (expo>=expo_max) {
/*
* The exponent is too large to fit in the available region
* or it results in the maximum possible value. Use positive
@ -4383,7 +4404,8 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
expo = expo_max;
H5T__bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE);
msize = 0;
} else if(except_ret == H5T_CONV_ABORT)
}
else if(except_ret == H5T_CONV_ABORT)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception")
else if(except_ret == H5T_CONV_HANDLED) {
reverse = FALSE;
@ -4410,7 +4432,8 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
if(carry)
implied = 2;
}
} else if(H5T__bit_get_d(s, (mpos + (size_t)bitno) - 1, (size_t)1) && denormalized)
}
else if(H5T__bit_get_d(s, (mpos + (size_t)bitno) - 1, (size_t)1) && denormalized)
/* For either source or destination, denormalized value doesn't increment carry.*/
H5T__bit_inc(s, mpos + (size_t)bitno - 1, 1 + msize - (size_t)bitno);
}
@ -4422,13 +4445,16 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
*/
if (mrsh>dst.u.f.msize+1) {
H5T__bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE);
} else if (mrsh==dst.u.f.msize+1) {
}
else if (mrsh==dst.u.f.msize+1) {
H5T__bit_set(d, dst.u.f.mpos+1, dst.u.f.msize-1, FALSE);
H5T__bit_set(d, dst.u.f.mpos, (size_t)1, TRUE);
} else if (mrsh==dst.u.f.msize) {
}
else if (mrsh==dst.u.f.msize) {
H5T__bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE);
H5T__bit_set_d(d, dst.u.f.mpos, MIN(2, dst.u.f.msize), (hsize_t)implied);
} else {
}
else {
if (mrsh>0) {
H5T__bit_set(d, dst.u.f.mpos+dst.u.f.msize-mrsh, mrsh,
FALSE);
@ -4439,7 +4465,8 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
H5T__bit_copy(d, dst.u.f.mpos,
s, (mpos+msize+mrsh-dst.u.f.msize),
dst.u.f.msize-mrsh);
} else {
}
else {
H5T__bit_copy(d, dst.u.f.mpos+dst.u.f.msize-(mrsh+msize),
s, mpos, msize);
H5T__bit_set(d, dst.u.f.mpos, dst.u.f.msize-(mrsh+msize),
@ -4469,7 +4496,8 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
if(except_ret == H5T_CONV_UNHANDLED) {
expo = expo_max;
H5T__bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE);
} else if(except_ret == H5T_CONV_ABORT)
}
else if(except_ret == H5T_CONV_ABORT)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception")
else if(except_ret == H5T_CONV_HANDLED) {
reverse = FALSE;