diff options
author | Raymond Lu <songyulu@hdfgroup.org> | 2004-04-13 18:37:06 (GMT) |
---|---|---|
committer | Raymond Lu <songyulu@hdfgroup.org> | 2004-04-13 18:37:06 (GMT) |
commit | 6e9faf2337fa950615dc7a414bc8311fe3525220 (patch) | |
tree | c9d06de9985e5460a5c691df767468c5c7028114 /src/H5Tbit.c | |
parent | e3e3e9ccf0fc8e51a3c8ad7e120d5e4addda0292 (diff) | |
download | hdf5-6e9faf2337fa950615dc7a414bc8311fe3525220.zip hdf5-6e9faf2337fa950615dc7a414bc8311fe3525220.tar.gz hdf5-6e9faf2337fa950615dc7a414bc8311fe3525220.tar.bz2 |
[svn-r8348] Purpose: More test
Description: Add more tests for bittests.c to check bit operations like H5S_bit_shift,
H5S_bit_inc, H5S_bit_dec, H5S_bit_neg.
Platforms tested: h5committest
Diffstat (limited to 'src/H5Tbit.c')
-rw-r--r-- | src/H5Tbit.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/H5Tbit.c b/src/H5Tbit.c index 5f4cfe4..79bb296 100644 --- a/src/H5Tbit.c +++ b/src/H5Tbit.c @@ -168,7 +168,11 @@ H5T_bit_copy (uint8_t *dst, size_t dst_offset, const uint8_t *src, * 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 - * at OFFSET and is SIZE long. + * 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. * * Return: void * @@ -379,9 +383,9 @@ H5T_bit_set (uint8_t *buf, size_t offset, size_t size, hbool_t value) * 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_MSB + * 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_LSB as DIRECTION). + * significant end(H5T_BIT_MSB as DIRECTION). * * Return: Success: The position of the bit found, relative to * the offset. @@ -493,8 +497,8 @@ done: * * Failure: Negative * - * Programmer: Robb Matzke - * Friday, June 26, 1998 + * Programmer: Raymond Lu + * Mar 17, 2004 * * Modifications: * @@ -596,14 +600,14 @@ H5T_bit_dec(uint8_t *buf, size_t start, size_t size) idx++; size -= (8 - pos); } else { /* bit sequence ends in the same byte as starts */ - /* Example: a sequence like 11000100 and start=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] >> (start+size)) != tmp >> (start+size)) { - buf[idx] += 1 << (start+size); + if((buf[idx] >> (pos+size)) != tmp >> (pos+size)) { + buf[idx] += 1 << (pos+size); borrow = 1; } goto done; |