summaryrefslogtreecommitdiffstats
path: root/src/H5Tbit.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Tbit.c')
-rw-r--r--src/H5Tbit.c62
1 files changed, 31 insertions, 31 deletions
diff --git a/src/H5Tbit.c b/src/H5Tbit.c
index 0049682..e3769fe 100644
--- a/src/H5Tbit.c
+++ b/src/H5Tbit.c
@@ -58,7 +58,7 @@ H5T_bit_copy (uint8_t *dst, size_t dst_offset, const uint8_t *src,
d_idx = (int)dst_offset / 8;
src_offset %= 8;
dst_offset %= 8;
-
+
/*
* 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
@@ -94,7 +94,7 @@ H5T_bit_copy (uint8_t *dst, size_t dst_offset, const uint8_t *src,
}
size -= nbits;
}
-
+
/*
* 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.
@@ -110,7 +110,7 @@ H5T_bit_copy (uint8_t *dst, size_t dst_offset, const uint8_t *src,
* +---------------+---------------+
* dst[d_idx+1] dst[d_idx]
*
- *
+ *
* Calculate shifts and masks. See diagrams below. MASK_LO in this
* example is 0x1f (the low five bits) and MASK_HI is 0xe0 (the high three
* bits). SHIFT is three since the source must be shifted right three bits
@@ -119,7 +119,7 @@ H5T_bit_copy (uint8_t *dst, size_t dst_offset, const uint8_t *src,
shift = (int)dst_offset;
mask_lo = (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] &= ~(mask_lo<<shift);
@@ -159,13 +159,13 @@ H5T_bit_copy (uint8_t *dst, size_t dst_offset, const uint8_t *src,
*
* 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
+ * value <<= 3, or value >>= 16. SHIFT_DIST is positive for
* left shift, negative for right shift. The bit vector starts
* at OFFSET and is SIZE long. The caller has to make sure
* SIZE+OFFSET doesn't exceed the size of BUF.
*
* For example, if we have a bit sequence 00011100, offset=2,
- * size=3, shift_dist=2, the result will be 00010000.
+ * size=3, shift_dist=2, the result will be 00010000.
*
* Return: void
*
@@ -188,23 +188,23 @@ H5T_bit_shift (uint8_t *buf, ssize_t shift_dist, size_t offset, size_t size)
assert(size);
if(!shift_dist)
- goto done;
+ goto done;
if((size_t)ABS(shift_dist) >= size) {
H5T_bit_set(buf, offset, size, 0);
goto done;
}
-
+
tmp_buf = (uint8_t*)H5MM_calloc(size/8+1);
assert(tmp_buf);
- /* Shift vector by making copies */
- if(shift_dist > 0) { /* left shift */
+ /* Shift vector by making copies */
+ if(shift_dist > 0) { /* left shift */
/* Copy part to be shifted to a temporary buffer */
H5T_bit_copy (tmp_buf, 0, buf, offset, (size_t)(size-shift_dist));
-
+
/* Copy it back to the original buffer */
H5T_bit_copy (buf, offset+shift_dist, tmp_buf, 0, (size_t)(size-shift_dist));
-
+
/* Zero-set the left part*/
H5T_bit_set(buf, offset, (size_t)shift_dist, 0);
} else { /* right shift */
@@ -246,7 +246,7 @@ H5T_bit_get_d (uint8_t *buf, size_t offset, size_t size)
hsize_t val=0;
size_t i, hs;
hsize_t ret_value; /* Return value */
-
+
FUNC_ENTER_NOAPI_NOFUNC(H5T_bit_get_d);
assert (8*sizeof(val)>=size);
@@ -293,7 +293,7 @@ void
H5T_bit_set_d (uint8_t *buf, size_t offset, size_t size, hsize_t val)
{
size_t i, hs;
-
+
assert (8*sizeof(val)>=size);
switch (H5T_native_order_g) {
@@ -351,7 +351,7 @@ H5T_bit_set (uint8_t *buf, size_t offset, size_t size, hbool_t value)
}
size -= nbits;
}
-
+
/* The middle bytes */
while (size>=8) {
buf[idx++] = value ? 0xff : 0x00;
@@ -376,7 +376,7 @@ H5T_bit_set (uint8_t *buf, size_t offset, size_t size, hbool_t value)
* 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
+ * 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
@@ -411,7 +411,7 @@ H5T_bit_find (uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction,
/* Calculate index */
idx = (ssize_t)(offset / 8);
offset %= 8;
-
+
/* Beginning */
if (offset) {
for (iu=offset; iu<8 && size>0; iu++, size--) {
@@ -443,7 +443,7 @@ H5T_bit_find (uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction,
/* Calculate index */
idx = (ssize_t)((offset+size-1) / 8);
offset %= 8;
-
+
/* Beginning */
if (size>8-offset && (offset+size)%8) {
for (iu=(offset+size)%8; iu>0; --iu, --size) {
@@ -472,7 +472,7 @@ H5T_bit_find (uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction,
}
break;
}
-
+
done:
FUNC_LEAVE_NOAPI(ret_value);
}
@@ -481,10 +481,10 @@ done:
/*-------------------------------------------------------------------------
* Function: H5T_bit_inc
*
- * Purpose: Increment part of a bit field by adding 1. The bit field
+ * Purpose: Increment part of a bit field by adding 1. The bit field
* starts with bit position START and is SIZE bits long.
*
- * Return: Success: The carry-out value. One if overflows,
+ * Return: Success: The carry-out value. One if overflows,
* zero otherwise.
*
* Failure: Negative
@@ -550,7 +550,7 @@ H5T_bit_inc(uint8_t *buf, size_t start, size_t size)
/*-------------------------------------------------------------------------
* Function: H5T_bit_dec
*
- * Purpose: decrement part of a bit field by substracting 1. The bit
+ * Purpose: decrement part of a bit field by substracting 1. The bit
* field starts with bit position START and is SIZE bits long.
*
* Return: Success: The "borrow-in" value. It's one if underflows,
@@ -572,7 +572,7 @@ H5T_bit_dec(uint8_t *buf, size_t start, size_t size)
size_t pos = start % 8;
uint8_t tmp;
unsigned borrow = 0;
-
+
/* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_bit_dec);
@@ -581,21 +581,21 @@ H5T_bit_dec(uint8_t *buf, size_t start, size_t size)
/* The first partial byte */
if ((size+start-1)/8 > idx) { /*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
+ /* 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))
borrow = 1;
buf[idx] -= 1 << pos;
idx++;
size -= (8 - pos);
} else { /* bit sequence ends in the same byte as starts */
- /* Example: a sequence like 11000100 and pos=3, size=3. We substract 00001000
+ /* 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] -= 1 << pos;
if((buf[idx] >> (pos+size)) != tmp >> (pos+size)) {
@@ -604,7 +604,7 @@ H5T_bit_dec(uint8_t *buf, size_t start, size_t size)
}
goto done;
}
-
+
/* The middle bytes */
while (borrow && size>=8) {
if(buf[idx])
@@ -632,7 +632,7 @@ done:
/*-------------------------------------------------------------------------
* Function: H5T_bit_neg
*
- * Purpose: negate part of a bit sequence. The bit
+ * Purpose: negate part of a bit sequence. The bit
* field starts with bit position START and is SIZE bits long.
*
* Return: void
@@ -650,7 +650,7 @@ 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;
-
+
/* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_bit_neg);