summaryrefslogtreecommitdiffstats
path: root/src/H5checksum.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2006-08-22 13:51:30 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2006-08-22 13:51:30 (GMT)
commitc17ea4461717a8065cc421980f897fa30a07f8d0 (patch)
tree45679c8bdb4e4e09b3e834e8bd15799e3e69f86a /src/H5checksum.c
parent7a5586ca8ea00b164b4b1aaa61617fbbd9cd0f25 (diff)
downloadhdf5-c17ea4461717a8065cc421980f897fa30a07f8d0.zip
hdf5-c17ea4461717a8065cc421980f897fa30a07f8d0.tar.gz
hdf5-c17ea4461717a8065cc421980f897fa30a07f8d0.tar.bz2
[svn-r12607] Description:
Tweak the library's new faster fletcher32 algorithm to always produce the same checksum as the previous fletcher32 code in the fletcher32 I/O pipeline filter and switch the filter to use the library's version of the algorithm. Tested on: Linux/32 2.6 (chicago) Linux/64 2.6 (chicago2) Too minor to require h5committest
Diffstat (limited to 'src/H5checksum.c')
-rw-r--r--src/H5checksum.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/H5checksum.c b/src/H5checksum.c
index 3aafd3d..9ad575d 100644
--- a/src/H5checksum.c
+++ b/src/H5checksum.c
@@ -80,6 +80,11 @@
* http://en.wikipedia.org/wiki/Fletcher%27s_checksum
* for more details, etc.
*
+ * Note #2: The algorithm below differs from that given in the Wikipedia
+ * page by copying the data into 'sum1' in a more portable way
+ * and also by initializing 'sum1' and 'sum2' to 0 instead of
+ * 0xffff (for backward compatibility reasons, mostly).
+ *
* Return: 32-bit fletcher checksum of input buffer (can't fail)
*
* Programmer: Quincey Koziol
@@ -92,7 +97,7 @@ H5_fletcher32(const void *_data, size_t _len)
{
const uint8_t *data = (const uint8_t *)_data; /* Pointer to the data to be summed */
size_t len = _len / 2; /* Length in 16-bit words */
- uint32_t sum1 = 0xffff, sum2 = 0xffff;
+ uint32_t sum1 = 0, sum2 = 0;
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5_fletcher32)
@@ -128,6 +133,6 @@ H5_fletcher32(const void *_data, size_t _len)
sum1 = (sum1 & 0xffff) + (sum1 >> 16);
sum2 = (sum2 & 0xffff) + (sum2 >> 16);
- FUNC_LEAVE_NOAPI(sum2 << 16 | sum1)
+ FUNC_LEAVE_NOAPI((sum2 << 16) | sum1)
} /* end H5_fletcher32() */