summaryrefslogtreecommitdiffstats
path: root/src/H5Fprivate.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Fprivate.h')
-rw-r--r--src/H5Fprivate.h44
1 files changed, 15 insertions, 29 deletions
diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h
index 40e075b..7c6fae8 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) || \