summaryrefslogtreecommitdiffstats
path: root/src/H5Zfletcher32.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/H5Zfletcher32.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/H5Zfletcher32.c')
-rw-r--r--src/H5Zfletcher32.c69
1 files changed, 2 insertions, 67 deletions
diff --git a/src/H5Zfletcher32.c b/src/H5Zfletcher32.c
index 770d05a..9092452 100644
--- a/src/H5Zfletcher32.c
+++ b/src/H5Zfletcher32.c
@@ -48,71 +48,6 @@ const H5Z_class_t H5Z_FLETCHER32[1] = {{
/*-------------------------------------------------------------------------
- * Function: H5Z_filter_fletcher32_compute
- *
- * Purpose: Implement an Fletcher32 Checksum using 1's complement.
- *
- * Return: Success: Fletcher32 value
- *
- * Failure: Can't fail
- *
- * Programmer: Raymond Lu
- * Jan 3, 2003
- *
- * Modifications: Pedro Vicente, March 10, 2004
- * defined *SRC as unsigned char for all cases
- *
- *-------------------------------------------------------------------------
- */
-static uint32_t
-H5Z_filter_fletcher32_compute(void *_src, size_t len)
-{
- unsigned char *src=(unsigned char *)_src;
- size_t count = len; /* Number of bytes left to checksum */
- uint32_t s1 = 0, s2 = 0; /* Temporary partial checksums */
-
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5Z_filter_fletcher32_compute)
-
- /* Compute checksum */
- while(count > 1) {
- unsigned short tmp_src; /*To handle unusual platforms like Cray*/
-
- tmp_src = (((unsigned short)src[0])<<8) | ((unsigned short)src[1]);
- src +=2;
- s1 += tmp_src;
-
- if(s1 & 0xFFFF0000) { /*Wrap around carry if occurred*/
- s1 &= 0xFFFF;
- s1++;
- }
- s2 += s1;
- if(s2 & 0xFFFF0000) { /*Wrap around carry if occurred*/
- s2 &= 0xFFFF;
- s2++;
- }
- count -= 2;
- }
-
- /* Check for single byte remaining */
- if(count==1) {
- s1 += *(unsigned char*)src;
- if(s1 & 0xFFFF0000) { /*Wrap around carry if occurred*/
- s1 &= 0xFFFF;
- s1++;
- }
- s2 += s1;
- if(s2 & 0xFFFF0000) { /*Wrap around carry if occurred*/
- s2 &= 0xFFFF;
- s2++;
- }
- }
-
- FUNC_LEAVE_NOAPI((s2 << 16) + s1)
-}
-
-
-
-/*-------------------------------------------------------------------------
* Function: H5Z_filter_fletcher32
*
* Purpose: Implement an I/O filter of Fletcher32 Checksum
@@ -167,7 +102,7 @@ H5Z_filter_fletcher32 (unsigned flags, size_t UNUSED cd_nelmts, const unsigned U
UINT32DECODE(tmp_src, stored_fletcher);
/* Compute checksum (can't fail) */
- fletcher = H5Z_filter_fletcher32_compute(src,src_nbytes);
+ fletcher = H5_fletcher32(src, src_nbytes);
/* The reversed checksum. There was a bug in the calculating code of
* the Fletcher32 checksum in the library before v1.6.3. The checksum
@@ -201,7 +136,7 @@ H5Z_filter_fletcher32 (unsigned flags, size_t UNUSED cd_nelmts, const unsigned U
unsigned char *dst; /* Temporary pointer to destination buffer */
/* Compute checksum (can't fail) */
- fletcher = H5Z_filter_fletcher32_compute(src,nbytes);
+ fletcher = H5_fletcher32(src, nbytes);
if (NULL==(dst=outbuf=H5MM_malloc(nbytes+FLETCHER_LEN)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "unable to allocate Fletcher32 checksum destination buffer")