summaryrefslogtreecommitdiffstats
path: root/src/H5Tbit.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2012-04-16 21:20:26 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2012-04-16 21:20:26 (GMT)
commita07c8f924703bdf3d1654b59cabf847f5d0f2683 (patch)
tree976dad3d894cfab9b88972a9e85d6bdfcf248f0d /src/H5Tbit.c
parentbdb6e538ac8c4eae6413b2a7583289644dc9c90f (diff)
downloadhdf5-a07c8f924703bdf3d1654b59cabf847f5d0f2683.zip
hdf5-a07c8f924703bdf3d1654b59cabf847f5d0f2683.tar.gz
hdf5-a07c8f924703bdf3d1654b59cabf847f5d0f2683.tar.bz2
[svn-r22287] Description:
Clean up more FUNC_ENTER/FUNC_LEAVE macros and move H5D & H5T code toward the final design (as exemplified by the H5EA & H5FA code). Tested on: Mac OSX/64 10.7.3 (amazon) w/debug & parallel
Diffstat (limited to 'src/H5Tbit.c')
-rw-r--r--src/H5Tbit.c110
1 files changed, 61 insertions, 49 deletions
diff --git a/src/H5Tbit.c b/src/H5Tbit.c
index f85ff14..79cf3a6 100644
--- a/src/H5Tbit.c
+++ b/src/H5Tbit.c
@@ -31,7 +31,7 @@
/*-------------------------------------------------------------------------
- * Function: H5T_bit_copy
+ * Function: H5T__bit_copy
*
* Purpose: Copies bits from one vector to another.
*
@@ -43,13 +43,15 @@
*-------------------------------------------------------------------------
*/
void
-H5T_bit_copy(uint8_t *dst, size_t dst_offset, const uint8_t *src,
+H5T__bit_copy(uint8_t *dst, size_t dst_offset, const uint8_t *src,
size_t src_offset, size_t size)
{
size_t shift;
size_t mask_lo, mask_hi;
size_t s_idx, d_idx;
+ FUNC_ENTER_PACKAGE_NOERR
+
/*
* Normalize the offset to be a byte number and a bit offset within that
* byte.
@@ -155,11 +157,13 @@ H5T_bit_copy(uint8_t *dst, size_t dst_offset, const uint8_t *src,
size -= nbits;
} /* end while */
-} /* end H5T_bit_copy() */
+
+ 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
* in a way similar to shifting a variable value, like
@@ -179,13 +183,13 @@ H5T_bit_copy(uint8_t *dst, size_t dst_offset, const uint8_t *src,
*-------------------------------------------------------------------------
*/
herr_t
-H5T_bit_shift(uint8_t *buf, ssize_t shift_dist, size_t offset, size_t size)
+H5T__bit_shift(uint8_t *buf, ssize_t shift_dist, size_t offset, size_t size)
{
uint8_t tmp_buf[512]; /* Temporary buffer */
H5WB_t *wb = NULL; /* Wrapped buffer for temporary buffer */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_PACKAGE
/* Sanity check */
HDassert(buf);
@@ -195,7 +199,7 @@ H5T_bit_shift(uint8_t *buf, ssize_t shift_dist, size_t offset, size_t size)
size_t abs_shift_dist = (size_t)ABS(shift_dist);
if(abs_shift_dist >= size)
- H5T_bit_set(buf, offset, size, 0);
+ 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 */
@@ -211,18 +215,18 @@ H5T_bit_shift(uint8_t *buf, ssize_t shift_dist, size_t offset, size_t size)
/* Shift vector by making copies */
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);
+ H5T__bit_copy(shift_buf, (size_t)0, buf, offset, size - abs_shift_dist);
/* Copy it back to the original buffer */
- H5T_bit_copy(buf, offset + abs_shift_dist, shift_buf, (size_t)0, size - abs_shift_dist);
+ H5T__bit_copy(buf, offset + abs_shift_dist, shift_buf, (size_t)0, size - abs_shift_dist);
/* Zero-set the left part*/
- H5T_bit_set(buf, offset, abs_shift_dist, 0);
+ 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);
+ 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 */
@@ -233,11 +237,11 @@ done:
HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "can't close wrapped buffer")
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5T_bit_shift() */
+} /* end H5T__bit_shift() */
/*-------------------------------------------------------------------------
- * Function: H5T_bit_get_d
+ * Function: H5T__bit_get_d
*
* Purpose: Return a small bit sequence as a number. Bit vector starts
* at OFFSET and is SIZE bits long.
@@ -253,17 +257,17 @@ done:
*-------------------------------------------------------------------------
*/
uint64_t
-H5T_bit_get_d(uint8_t *buf, size_t offset, size_t size)
+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; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_PACKAGE_NOERR
HDassert(8 * sizeof(val) >= size);
- H5T_bit_copy((uint8_t*)&val, (size_t)0, buf, offset, size);
+ H5T__bit_copy((uint8_t*)&val, (size_t)0, buf, offset, size);
switch(H5T_native_order_g) {
case H5T_ORDER_LE:
break;
@@ -290,11 +294,11 @@ H5T_bit_get_d(uint8_t *buf, size_t offset, size_t size)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5T_bit_get_d() */
+} /* end H5T__bit_get_d() */
/*-------------------------------------------------------------------------
- * Function: H5T_bit_set_d
+ * Function: H5T__bit_set_d
*
* Purpose: Sets part of a bit vector to the specified unsigned value.
*
@@ -306,10 +310,12 @@ done:
*-------------------------------------------------------------------------
*/
void
-H5T_bit_set_d(uint8_t *buf, size_t offset, size_t size, uint64_t val)
+H5T__bit_set_d(uint8_t *buf, size_t offset, size_t size, uint64_t val)
{
size_t i, hs;
+ FUNC_ENTER_PACKAGE_NOERR
+
HDassert(8 * sizeof(val) >= size);
switch(H5T_native_order_g) {
@@ -332,12 +338,14 @@ H5T_bit_set_d(uint8_t *buf, size_t offset, size_t size, uint64_t val)
HDabort();
} /* end switch */
- H5T_bit_copy(buf, offset, (uint8_t*)&val, (size_t)0, size);
-} /* end H5T_bit_set_d() */
+ H5T__bit_copy(buf, offset, (uint8_t*)&val, (size_t)0, size);
+
+ FUNC_LEAVE_NOAPI_VOID
+} /* end H5T__bit_set_d() */
/*-------------------------------------------------------------------------
- * 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.
@@ -352,10 +360,12 @@ H5T_bit_set_d(uint8_t *buf, size_t offset, size_t size, uint64_t val)
*-------------------------------------------------------------------------
*/
void
-H5T_bit_set(uint8_t *buf, size_t offset, size_t size, hbool_t value)
+H5T__bit_set(uint8_t *buf, size_t offset, size_t size, hbool_t value)
{
int idx;
+ FUNC_ENTER_PACKAGE_NOERR
+
/* Normalize */
idx = (int)offset / 8;
offset %= 8;
@@ -385,11 +395,13 @@ H5T_bit_set(uint8_t *buf, size_t offset, size_t size, hbool_t value)
else
buf[idx] &= (uint8_t)(~(((unsigned)1 << size) - 1));
} /* end if */
-} /* end H5T_bit_set() */
+
+ 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
@@ -409,7 +421,7 @@ H5T_bit_set(uint8_t *buf, size_t offset, size_t size, hbool_t value)
*-------------------------------------------------------------------------
*/
ssize_t
-H5T_bit_find(uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction,
+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;
@@ -417,8 +429,8 @@ H5T_bit_find(uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction,
size_t iu;
ssize_t ret_value = (-1); /* Return value */
- /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ /* Use FUNC_ENTER_PACKAGE_NOERR here to avoid performance issues */
+ FUNC_ENTER_PACKAGE_NOERR
/* Some functions call this with value=TRUE */
HDassert(TRUE == 1);
@@ -496,11 +508,11 @@ H5T_bit_find(uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction,
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5T_bit_find() */
+} /* end H5T__bit_find() */
/*-------------------------------------------------------------------------
- * Function: H5T_bit_inc
+ * Function: H5T__bit_inc
*
* Purpose: Increment part of a bit field by adding 1. The bit field
* starts with bit position START and is SIZE bits long.
@@ -516,14 +528,14 @@ done:
*-------------------------------------------------------------------------
*/
htri_t
-H5T_bit_inc(uint8_t *buf, size_t start, size_t size)
+H5T__bit_inc(uint8_t *buf, size_t start, size_t size)
{
size_t idx = start / 8;
unsigned carry = 1;
unsigned acc, mask;
- /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ /* Use FUNC_ENTER_PACKAGE_NOERR here to avoid performance issues */
+ FUNC_ENTER_PACKAGE_NOERR
HDassert(buf);
@@ -566,11 +578,11 @@ H5T_bit_inc(uint8_t *buf, size_t start, size_t size)
} /* end if */
FUNC_LEAVE_NOAPI(carry ? TRUE : FALSE)
-} /* end H5T_bit_inc() */
+} /* 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.
@@ -586,15 +598,15 @@ H5T_bit_inc(uint8_t *buf, size_t start, size_t size)
*-------------------------------------------------------------------------
*/
htri_t
-H5T_bit_dec(uint8_t *buf, size_t start, size_t size)
+H5T__bit_dec(uint8_t *buf, size_t start, size_t size)
{
size_t idx = start / 8;
size_t pos = start % 8;
uint8_t tmp;
unsigned borrow = 0;
- /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ /* Use FUNC_ENTER_PACKAGE_NOERR here to avoid performance issues */
+ FUNC_ENTER_PACKAGE_NOERR
HDassert(buf);
HDassert(size);
@@ -645,11 +657,11 @@ H5T_bit_dec(uint8_t *buf, size_t start, size_t size)
} /* end else */
FUNC_LEAVE_NOAPI(borrow ? TRUE : FALSE)
-} /* end H5T_bit_dec() */
+} /* 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.
@@ -662,14 +674,14 @@ H5T_bit_dec(uint8_t *buf, size_t start, size_t size)
*-------------------------------------------------------------------------
*/
void
-H5T_bit_neg(uint8_t *buf, size_t start, size_t size)
+H5T__bit_neg(uint8_t *buf, size_t start, size_t size)
{
size_t idx = start / 8;
size_t pos = start % 8;
uint8_t tmp[1];
- /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ /* Use FUNC_ENTER_PACKAGE_NOERR here to avoid performance issues */
+ FUNC_ENTER_PACKAGE_NOERR
HDassert(buf);
HDassert(size);
@@ -679,7 +691,7 @@ H5T_bit_neg(uint8_t *buf, size_t start, size_t size)
/* Simply copy the negated bit field back to the original byte */
if((size + start - 1) / 8 > idx) { /*bit sequence doesn't end in the same byte as starts*/
- H5T_bit_copy(&(buf[idx]), pos, tmp, pos, (8-pos));
+ H5T__bit_copy(&(buf[idx]), pos, tmp, pos, (8-pos));
idx++;
size -= (8 - pos);
@@ -694,12 +706,12 @@ H5T_bit_neg(uint8_t *buf, size_t start, size_t size)
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);
+ 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 */
- H5T_bit_copy(&(buf[idx]), pos, tmp, pos, size);
+ H5T__bit_copy(&(buf[idx]), pos, tmp, pos, size);
FUNC_LEAVE_NOAPI_VOID
-} /* end H5T_bit_neg() */
+} /* end H5T__bit_neg() */