diff options
author | Raymond Lu <songyulu@hdfgroup.org> | 2003-04-22 16:54:13 (GMT) |
---|---|---|
committer | Raymond Lu <songyulu@hdfgroup.org> | 2003-04-22 16:54:13 (GMT) |
commit | 696b504a3773c01a6562a8b141bd32ba025e47e3 (patch) | |
tree | cabfe56465ae4d7fd3e5ee0f596c9d7c2f2a227d | |
parent | 4447d4e5c73b8be3d71dea3e9936810bbb070508 (diff) | |
download | hdf5-696b504a3773c01a6562a8b141bd32ba025e47e3.zip hdf5-696b504a3773c01a6562a8b141bd32ba025e47e3.tar.gz hdf5-696b504a3773c01a6562a8b141bd32ba025e47e3.tar.bz2 |
[svn-r6731]
Purpose: handling special case
Description: This fletcher32 didn't handle Cray's special data type sizes.
Platforms tested: h5committested. Cray
-rw-r--r-- | src/H5Zfletcher32.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/H5Zfletcher32.c b/src/H5Zfletcher32.c index 690c1c3..c97d004 100644 --- a/src/H5Zfletcher32.c +++ b/src/H5Zfletcher32.c @@ -65,8 +65,15 @@ const H5Z_class_t H5Z_FLETCHER32[1] = {{ *------------------------------------------------------------------------- */ static uint32_t -H5Z_filter_fletcher32_compute(unsigned short *src, size_t len) +H5Z_filter_fletcher32_compute(void *_src, size_t len) { +#if H5_SIZEOF_UINT16_T==2 + uint16_t *src=(uint16_t *)_src; +#else /* H5_SIZEOF_UINT16_T */ + /*To handle unusual platforms like Cray*/ + unsigned char *src=(unsigned char *)_src; + unsigned short tmp_src; +#endif /* H5_SIZEOF_UINT16_T */ size_t count = len; /* Number of bytes left to checksum */ uint32_t s1 = 0, s2 = 0; /* Temporary partial checksums */ @@ -74,7 +81,15 @@ H5Z_filter_fletcher32_compute(unsigned short *src, size_t len) /* Compute checksum */ while(count > 1) { +#if H5_SIZEOF_UINT16_T==2 + /*For normal platforms*/ s1 += *src++; +#else /* H5_SIZEOF_UINT16_T */ + /*To handle unusual platforms like Cray*/ + tmp_src = (((unsigned short)src[0])<<8) | ((unsigned short)src[1]); + src +=2; + s1 += tmp_src; +#endif /* H5_SIZEOF_UINT16_T */ if(s1 & 0xFFFF0000) { /*Wrap around carry if occurred*/ s1 &= 0xFFFF; s1++; @@ -130,7 +145,7 @@ H5Z_filter_fletcher32 (unsigned flags, size_t UNUSED cd_nelmts, const unsigned U FUNC_ENTER_NOAPI(H5Z_filter_fletcher32, 0); - assert(sizeof(uint32_t)==4); + assert(sizeof(uint32_t)>=4); if (flags & H5Z_FLAG_REVERSE) { /* Read */ /* Do checksum if it's enabled for read; otherwise skip it |