diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5FD.c | 8 | ||||
-rw-r--r-- | src/H5Pdcpl.c | 12 | ||||
-rw-r--r-- | src/H5Ppublic.h | 2 | ||||
-rw-r--r-- | src/H5Z.c | 6 | ||||
-rw-r--r-- | src/H5Zfletcher32.c (renamed from src/H5Zadler32.c) | 88 | ||||
-rw-r--r-- | src/H5Zprivate.h | 2 | ||||
-rw-r--r-- | src/H5Zpublic.h | 2 | ||||
-rw-r--r-- | src/H5config.h.in | 4 | ||||
-rw-r--r-- | src/Makefile.in | 2 |
9 files changed, 74 insertions, 52 deletions
@@ -1178,7 +1178,7 @@ H5FDalloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) haddr_t ret_value = HADDR_UNDEF; FUNC_ENTER_API(H5FDalloc, HADDR_UNDEF); - H5TRACE3("a","xMth",file,type,size); + H5TRACE4("a","xMtih",file,type,dxpl_id,size); /* Check args */ if (!file || !file->cls) @@ -1704,7 +1704,7 @@ H5FDfree(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t siz herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5FDfree, FAIL); - H5TRACE4("e","xMtah",file,type,addr,size); + H5TRACE5("e","xMtiah",file,type,dxpl_id,addr,size); /* Check args */ if (!file || !file->cls) @@ -1985,7 +1985,7 @@ H5FDrealloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t old_addr, hsiz haddr_t ret_value=HADDR_UNDEF; FUNC_ENTER_API(H5FDrealloc, HADDR_UNDEF); - H5TRACE5("a","xMtahh",file,type,old_addr,old_size,new_size); + H5TRACE6("a","xMtiahh",file,type,dxpl_id,old_addr,old_size,new_size); /* Check args */ if (H5P_DEFAULT == dxpl_id) @@ -2870,7 +2870,7 @@ H5FDflush(H5FD_t *file, hid_t dxpl_id, unsigned closing) herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5FDflush, FAIL); - H5TRACE2("e","xIu",file,closing); + H5TRACE3("e","xiIu",file,dxpl_id,closing); /* Check args */ if (!file || !file->cls) diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index efcd8c6..708506c 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -802,9 +802,9 @@ done: /*------------------------------------------------------------------------- - * Function: H5Pset_adler32 + * Function: H5Pset_fletcher32 * - * Purpose: Sets Adler32 checksum of EDC for a dataset creation + * Purpose: Sets Fletcher32 checksum of EDC for a dataset creation * property list. * * Return: Non-negative on success/Negative on failure @@ -817,23 +817,23 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pset_adler32(hid_t plist_id) +H5Pset_fletcher32(hid_t plist_id) { H5O_pline_t pline; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ - FUNC_ENTER_API(H5Pset_adler32, FAIL); + FUNC_ENTER_API(H5Pset_fletcher32, FAIL); H5TRACE1("e","i",plist_id); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); - /* Add the Adler32 checksum as a filter */ + /* Add the Fletcher32 checksum as a filter */ if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline"); - if(H5Z_append(&pline, H5Z_FILTER_ADLER32, H5Z_FLAG_MANDATORY, 0, NULL)<0) + if(H5Z_append(&pline, H5Z_FILTER_FLETCHER32, H5Z_FLAG_MANDATORY, 0, NULL)<0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add deflate filter to pipeline"); if(H5P_set(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to set pipeline"); diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index fbe1aea..58bd95f 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -219,7 +219,7 @@ H5_DLL H5Z_filter_t H5Pget_filter(hid_t plist_id, int filter, size_t namelen, char name[]); H5_DLL herr_t H5Pset_deflate(hid_t plist_id, unsigned aggression); H5_DLL herr_t H5Pset_shuffle(hid_t plist_id, unsigned bytespertype); -H5_DLL herr_t H5Pset_adler32(hid_t plist_id); +H5_DLL herr_t H5Pset_fletcher32(hid_t plist_id); H5_DLL herr_t H5Pset_edc_check(hid_t plist_id, H5Z_EDC_t check); H5_DLL H5Z_EDC_t H5Pget_edc_check(hid_t plist_id); H5_DLL herr_t H5Pset_filter_callback(hid_t plist_id, H5Z_filter_func_t func, @@ -52,9 +52,9 @@ H5Z_init_interface (void) #ifdef H5_HAVE_FILTER_SHUFFLE H5Z_register (H5Z_FILTER_SHUFFLE, "shuffle", H5Z_filter_shuffle); #endif /* H5_HAVE_FILTER_SHUFFLE */ -#ifdef H5_HAVE_FILTER_ADLER32 - H5Z_register (H5Z_FILTER_ADLER32, "adler32", H5Z_filter_adler32); -#endif /* H5_HAVE_FILTER_ADLER32 */ +#ifdef H5_HAVE_FILTER_FLETCHER32 + H5Z_register (H5Z_FILTER_FLETCHER32, "fletcher32", H5Z_filter_fletcher32); +#endif /* H5_HAVE_FILTER_FLETCHER32 */ FUNC_LEAVE_NOAPI(SUCCEED); } diff --git a/src/H5Zadler32.c b/src/H5Zfletcher32.c index 9f380e5..bd4c68f 100644 --- a/src/H5Zadler32.c +++ b/src/H5Zfletcher32.c @@ -10,23 +10,22 @@ #include "H5MMprivate.h" #include "H5Zprivate.h" -#ifdef H5_HAVE_FILTER_ADLER32 +#ifdef H5_HAVE_FILTER_FLETCHER32 -#define ADLER_LEN 4 -#define ADLER_BASE 65521 +#define FLETCHER_LEN 4 /* Interface initialization */ -#define PABLO_MASK H5Z_adler32_mask +#define PABLO_MASK H5Z_fletcher32_mask #define INTERFACE_INIT NULL static int interface_initialize_g = 0; /*------------------------------------------------------------------------- - * Function: H5Z_filter_adler32_compute + * Function: H5Z_filter_fletcher32_compute * - * Purpose: Implement an Adler32 Checksum + * Purpose: Implement an Fletcher32 Checksum using 1's complement. * - * Return: Success: Adler32 value + * Return: Success: Fletcher32 value * * Failure: Can't fail * @@ -37,18 +36,41 @@ static int interface_initialize_g = 0; * *------------------------------------------------------------------------- */ -static unsigned int H5Z_filter_adler32_compute(unsigned char *buf, size_t len) +static unsigned int H5Z_filter_fletcher32_compute(unsigned short *buf, size_t len) { - size_t i; - register unsigned int s1 = 1; + size_t count = len; + register unsigned int s1 = 0; register unsigned int s2 = 0; + unsigned short *src = buf; - FUNC_ENTER_NOINIT(H5Z_filter_adler32_compute); + FUNC_ENTER_NOINIT(H5Z_filter_fletcher32_compute); /* Compute checksum */ - for(i=0; i<len; i++) { - s1 = (s1 + *buf++) % ADLER_BASE; - s2 = (s2 + s1) % ADLER_BASE; + while(count > 1) { + s1 += *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; + } + + 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); @@ -56,11 +78,11 @@ static unsigned int H5Z_filter_adler32_compute(unsigned char *buf, size_t len) /*------------------------------------------------------------------------- - * Function: H5Z_filter_adler32 + * Function: H5Z_filter_fletcher32 * - * Purpose: Implement an I/O filter of Adler32 Checksum + * Purpose: Implement an I/O filter of Fletcher32 Checksum * - * Return: Success: size of data plus the size of Adler32 value + * Return: Success: size of data plus the size of Fletcher32 value * * Failure: 0 * @@ -72,58 +94,58 @@ static unsigned int H5Z_filter_adler32_compute(unsigned char *buf, size_t len) *------------------------------------------------------------------------- */ size_t -H5Z_filter_adler32 (unsigned flags, size_t UNUSED cd_nelmts, const unsigned UNUSED cd_values[], +H5Z_filter_fletcher32 (unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes, size_t *buf_size, void **buf) { size_t ret_value = 0; void *outbuf = NULL; unsigned char *src = (unsigned char*)(*buf); - unsigned int adler = 1; + unsigned int fletcher = 0; - FUNC_ENTER_NOAPI(H5Z_filter_adler32, 0); + FUNC_ENTER_NOAPI(H5Z_filter_fletcher32, 0); assert(sizeof(unsigned int)==4); if (flags & H5Z_FLAG_REVERSE) { /* Read */ size_t src_nbytes = nbytes; - unsigned int origin_adler; + unsigned int origin_fletcher; /* Do checksum if it's enabled for read; otherwise skip it * to save performance. */ if (!(flags & H5Z_FLAG_SKIP_EDC)) { /* Read */ unsigned char *tmp_src; - src_nbytes -= ADLER_LEN; + src_nbytes -= FLETCHER_LEN; tmp_src=src+src_nbytes; - UINT32DECODE(tmp_src, origin_adler); + UINT32DECODE(tmp_src, origin_fletcher); /* Compute checksum */ - adler = H5Z_filter_adler32_compute(src,src_nbytes); + fletcher = H5Z_filter_fletcher32_compute((unsigned short*)src,src_nbytes); - if(origin_adler != adler) - HGOTO_ERROR(H5E_STORAGE, H5E_READERROR, 0, "data error detected by Adler32 checksum"); + if(origin_fletcher != fletcher) + HGOTO_ERROR(H5E_STORAGE, H5E_READERROR, 0, "data error detected by Fletcher32 checksum"); } - *buf_size = nbytes - ADLER_LEN; + *buf_size = nbytes - FLETCHER_LEN; ret_value = *buf_size; } else { /* Write */ unsigned char *dst; /* Compute checksum */ - adler = H5Z_filter_adler32_compute(src,nbytes); + fletcher = H5Z_filter_fletcher32_compute((unsigned short*)src,nbytes); - if (NULL==(dst=outbuf=H5MM_malloc(nbytes+ADLER_LEN))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "unable to allocate Adler32 checksum destination buffer"); + if (NULL==(dst=outbuf=H5MM_malloc(nbytes+FLETCHER_LEN))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "unable to allocate Fletcher32 checksum destination buffer"); /* Copy raw data */ HDmemcpy((void*)dst, (void*)(*buf), nbytes); /* Append checksum to raw data */ dst += nbytes; - UINT32ENCODE(dst, adler); + UINT32ENCODE(dst, fletcher); - *buf_size = nbytes + ADLER_LEN; + *buf_size = nbytes + FLETCHER_LEN; H5MM_xfree(*buf); *buf = outbuf; outbuf = NULL; @@ -136,4 +158,4 @@ done: FUNC_LEAVE_NOAPI(ret_value); } -#endif /* H5_HAVE_FILTER_ADLER32 */ +#endif /* H5_HAVE_FILTER_FLETCHER32 */ diff --git a/src/H5Zprivate.h b/src/H5Zprivate.h index b150d0f..be87d9e 100644 --- a/src/H5Zprivate.h +++ b/src/H5Zprivate.h @@ -55,7 +55,7 @@ H5_DLL size_t H5Z_filter_shuffle(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes, size_t *buf_size, void **buf); -H5_DLL size_t H5Z_filter_adler32(unsigned flags, size_t cd_nelmts, +H5_DLL size_t H5Z_filter_fletcher32(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes, size_t *buf_size, void **buf); diff --git a/src/H5Zpublic.h b/src/H5Zpublic.h index f45c96c..3acf54d 100644 --- a/src/H5Zpublic.h +++ b/src/H5Zpublic.h @@ -20,7 +20,7 @@ typedef int H5Z_filter_t; #define H5Z_FILTER_NONE 0 /*reserved indefinitely */ #define H5Z_FILTER_DEFLATE 1 /*deflation like gzip */ #define H5Z_FILTER_SHUFFLE 2 /*shuffle the data */ -#define H5Z_FILTER_ADLER32 3 /*adler32 checksum of EDC */ +#define H5Z_FILTER_FLETCHER32 3 /*fletcher32 checksum of EDC */ #define H5Z_FILTER_RESERVED 256 /*filter ids below this value are reserved */ #define H5Z_FILTER_MAX 65535 /*maximum filter id */ diff --git a/src/H5config.h.in b/src/H5config.h.in index 4ac1519..9397a22 100644 --- a/src/H5config.h.in +++ b/src/H5config.h.in @@ -21,8 +21,8 @@ /* Define to 1 if you have the <features.h> header file. */ #undef HAVE_FEATURES_H -/* Define if support for Adler32 checksum is enabled */ -#undef HAVE_FILTER_ADLER32 +/* Define if support for Fletcher32 checksum is enabled */ +#undef HAVE_FILTER_FLETCHER32 /* Define if support for deflate filter is enabled */ #undef HAVE_FILTER_DEFLATE diff --git a/src/Makefile.in b/src/Makefile.in index e8aab01..92a1ee9 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -42,7 +42,7 @@ LIB_SRC=H5.c H5A.c H5AC.c H5B.c H5D.c H5E.c H5F.c H5Farray.c H5Fcontig.c \ H5Tcompound.c H5Tconv.c H5Tcset.c H5Tenum.c H5Tfields.c H5Tfixed.c \ H5Tfloat.c H5Tinit.c H5Tnative.c H5Toffset.c H5Topaque.c H5Torder.c \ H5Tpad.c H5Tprecis.c H5Tstrpad.c H5Tvlen.c H5TB.c H5TS.c H5V.c H5Z.c \ - H5Zdeflate.c H5Zshuffle.c H5Zadler32.c + H5Zdeflate.c H5Zshuffle.c H5Zfletcher32.c LIB_OBJ=$(LIB_SRC:.c=.lo) |