diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2007-10-18 16:10:46 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2007-10-18 16:10:46 (GMT) |
commit | b0eb42058c02bff41cacae11880b4fbf174821db (patch) | |
tree | c389ee389c680cccbd2a5c5f11107b588f4bcfa0 /src/H5Toffset.c | |
parent | dcf8866b6af90aa0bf50ebeceda6b0f184a07c17 (diff) | |
download | hdf5-b0eb42058c02bff41cacae11880b4fbf174821db.zip hdf5-b0eb42058c02bff41cacae11880b4fbf174821db.tar.gz hdf5-b0eb42058c02bff41cacae11880b4fbf174821db.tar.bz2 |
[svn-r14208] Description:
Make H5Pget_filter_by_id() API versioned and switch internal usage
to H5Pget_filter_by_id2().
Add simple regression test for H5Pget_filter_by_id1().
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
Diffstat (limited to 'src/H5Toffset.c')
-rw-r--r-- | src/H5Toffset.c | 66 |
1 files changed, 54 insertions, 12 deletions
diff --git a/src/H5Toffset.c b/src/H5Toffset.c index 563e5cd..5495368 100644 --- a/src/H5Toffset.c +++ b/src/H5Toffset.c @@ -77,41 +77,83 @@ H5T_init_offset_interface(void) * 3: [0x22] [ pad] [ pad] [0x11] * * Return: Success: The offset (non-negative) - * * Failure: Negative * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * - * Modifications: - * Robb Matzke, 22 Dec 1998 - * Also works for derived data types. - * *------------------------------------------------------------------------- */ int H5Tget_offset(hid_t type_id) { - H5T_t *dt = NULL; + H5T_t *dt; int ret_value; FUNC_ENTER_API(H5Tget_offset, -1) H5TRACE1("Is", "i", type_id); /* Check args */ - if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) + if(NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type") - while (dt->shared->parent) - dt = dt->shared->parent; /*defer to parent*/ - if (!H5T_IS_ATOMIC(dt->shared)) + + /* Get offset */ + if((ret_value = H5T_get_offset(dt)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "cant't get offset for specified datatype") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Tget_offset() */ + + +/*------------------------------------------------------------------------- + * Function: H5T_get_offset + * + * Purpose: Retrieves the bit offset of the first significant bit. The + * signficant bits of an atomic datum can be offset from the + * beginning of the memory for that datum by an amount of + * padding. The `offset' property specifies the number of bits + * of padding that appear to the "right of" the value. That is, + * if we have a 32-bit datum with 16-bits of precision having + * the value 0x1122 then it will be layed out in memory as (from + * small byte address toward larger byte addresses): + * + * Big Big Little Little + * Endian Endian Endian Endian + * offset=0 offset=16 offset=0 offset=16 + * + * 0: [ pad] [0x11] [0x22] [ pad] + * 1: [ pad] [0x22] [0x11] [ pad] + * 2: [0x11] [ pad] [ pad] [0x22] + * 3: [0x22] [ pad] [ pad] [0x11] + * + * Return: Success: The offset (non-negative) + * Failure: Negative + * + * Programmer: Quincey Koziol + * Wednesday, October 17, 2007 + * + *------------------------------------------------------------------------- + */ +int +H5T_get_offset(const H5T_t *dt) +{ + int ret_value; + + FUNC_ENTER_NOAPI(H5T_get_offset, -1) + + /* Defer to parent*/ + while(dt->shared->parent) + dt = dt->shared->parent; + if(!H5T_IS_ATOMIC(dt->shared)) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for specified data type") /* Offset */ ret_value = (int)dt->shared->u.atomic.offset; done: - FUNC_LEAVE_API(ret_value) -} + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T_get_offset() */ /*------------------------------------------------------------------------- |