diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2012-07-26 20:03:12 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2012-07-26 20:03:12 (GMT) |
commit | 0728b38ddd4d0c31269f26f5b600f4e569670f6f (patch) | |
tree | dc6495de1a103f179a3cdae43ce6410468c1cee1 /src/H5Fprivate.h | |
parent | 0ea9a38644765aa4045b9110e86c5e50a5f24dac (diff) | |
download | hdf5-0728b38ddd4d0c31269f26f5b600f4e569670f6f.zip hdf5-0728b38ddd4d0c31269f26f5b600f4e569670f6f.tar.gz hdf5-0728b38ddd4d0c31269f26f5b600f4e569670f6f.tar.bz2 |
[svn-r22609] Description:
Bring r22608 from trunk to 1.8 branch:
Switch propert list/class iteration from internal to external form of
iteration, cleaning up and simplifying the code a bit.
Bring other general improvements from plist_encode_decode branch back to
trunk.
Clean up many warnings.
Tested on:
Mac OSX/64 10.7.4 (amazon) w/gcc 4.7, debug and C++ & FORTRAN
(too minor to require h5committest)
Diffstat (limited to 'src/H5Fprivate.h')
-rw-r--r-- | src/H5Fprivate.h | 44 |
1 files changed, 15 insertions, 29 deletions
diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index b0aaeec..5a11f5f 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -70,10 +70,10 @@ typedef struct H5F_blk_aggr_t H5F_blk_aggr_t; *(p) = (uint8_t)(((i) >> 24) & 0xff); (p)++; \ } -/* Encode a 32-bit unsigned integer into a variable-sized buffer */ +/* Encode an unsigned integer into a variable-sized buffer */ /* (Assumes that the high bits of the integer are zero) */ -# define UINT32ENCODE_VAR(p, n, l) { \ - uint32_t _n = (n); \ +# define ENCODE_VAR(p, typ, n, l) { \ + typ _n = (n); \ size_t _i; \ uint8_t *_p = (uint8_t*)(p); \ \ @@ -82,6 +82,10 @@ typedef struct H5F_blk_aggr_t H5F_blk_aggr_t; (p) = (uint8_t*)(p) + l; \ } +/* Encode a 32-bit unsigned integer into a variable-sized buffer */ +/* (Assumes that the high bits of the integer are zero) */ +# define UINT32ENCODE_VAR(p, n, l) ENCODE_VAR(p, uint32_t, n, l) + # define INT64ENCODE(p, n) { \ int64_t _n = (n); \ size_t _i; \ @@ -108,15 +112,7 @@ typedef struct H5F_blk_aggr_t H5F_blk_aggr_t; /* Encode a 64-bit unsigned integer into a variable-sized buffer */ /* (Assumes that the high bits of the integer are zero) */ -# define UINT64ENCODE_VAR(p, n, l) { \ - uint64_t _n = (n); \ - size_t _i; \ - uint8_t *_p = (uint8_t*)(p); \ - \ - for(_i = 0; _i < l; _i++, _n >>= 8) \ - *_p++ = (uint8_t)(_n & 0xff); \ - (p) = (uint8_t*)(p) + l; \ -} +# define UINT64ENCODE_VAR(p, n, l) ENCODE_VAR(p, uint64_t, n, l) /* DECODE converts little endian bytes pointed by p to integer values and store * it in i. For signed values, need to do sign-extension when converting @@ -152,12 +148,9 @@ typedef struct H5F_blk_aggr_t H5F_blk_aggr_t; (i) |= ((uint32_t)(*(p) & 0xff) << 24); (p)++; \ } -/* Decode a variable-sized buffer into a 32-bit unsigned integer */ +/* Decode a variable-sized buffer */ /* (Assumes that the high bits of the integer will be zero) */ -/* (Note: this is exactly the same code as the 64-bit variable-length decoder - * and bugs/improvements should be make in both places - QAK) - */ -# define UINT32DECODE_VAR(p, n, l) { \ +# define DECODE_VAR(p, n, l) { \ size_t _i; \ \ n = 0; \ @@ -167,6 +160,10 @@ typedef struct H5F_blk_aggr_t H5F_blk_aggr_t; (p) += l; \ } +/* Decode a variable-sized buffer into a 32-bit unsigned integer */ +/* (Assumes that the high bits of the integer will be zero) */ +# define UINT32DECODE_VAR(p, n, l) DECODE_VAR(p, n, l) + # define INT64DECODE(p, n) { \ /* WE DON'T CHECK FOR OVERFLOW! */ \ size_t _i; \ @@ -191,18 +188,7 @@ typedef struct H5F_blk_aggr_t H5F_blk_aggr_t; /* Decode a variable-sized buffer into a 64-bit unsigned integer */ /* (Assumes that the high bits of the integer will be zero) */ -/* (Note: this is exactly the same code as the 32-bit variable-length decoder - * and bugs/improvements should be make in both places - QAK) - */ -# define UINT64DECODE_VAR(p, n, l) { \ - size_t _i; \ - \ - n = 0; \ - (p) += l; \ - for (_i = 0; _i < l; _i++) \ - n = (n << 8) | *(--p); \ - (p) += l; \ -} +# define UINT64DECODE_VAR(p, n, l) DECODE_VAR(p, n, l) /* Address-related macros */ #define H5F_addr_overflow(X,Z) (HADDR_UNDEF==(X) || \ |