summaryrefslogtreecommitdiffstats
path: root/lib/lz4.h
diff options
context:
space:
mode:
authorjonrumsey <jrumsey@uk.ibm.com>2022-07-11 10:28:32 (GMT)
committerjonrumsey <jrumsey@uk.ibm.com>2022-07-11 10:28:32 (GMT)
commitb4f508608f8f9423350cf48e46dd22c452f0b809 (patch)
tree4cb175fe5ccd15449add65fce82536f80f925b0a /lib/lz4.h
parent0b0e3330bcc62b8582ce6fee3a7465391f7b56c7 (diff)
downloadlz4-b4f508608f8f9423350cf48e46dd22c452f0b809.zip
lz4-b4f508608f8f9423350cf48e46dd22c452f0b809.tar.gz
lz4-b4f508608f8f9423350cf48e46dd22c452f0b809.tar.bz2
Change definitions of LZ4_STREAMSIZE, LZ4_STREAMDECODESIZE and LZ4_STREAMHCSIZE to factor in OS400 pointer length and structure alignment rules
Update the length values on platforms where pointers are 16-bytes, factor in implicit compiler padding to ensure proper alignment of members and overall structure lengths
Diffstat (limited to 'lib/lz4.h')
-rw-r--r--lib/lz4.h30
1 files changed, 28 insertions, 2 deletions
diff --git a/lib/lz4.h b/lib/lz4.h
index 07cc18e..1bd7d26 100644
--- a/lib/lz4.h
+++ b/lib/lz4.h
@@ -631,8 +631,22 @@ typedef struct {
* Init this structure with LZ4_initStream() before first use.
* note : only use this definition in association with static linking !
* this definition is not API/ABI safe, and may change in future versions.
+ * Note : OS400 pointers are 16 bytes and the compiler adds 8 bytes of padding after
+ * tableType and 12 bytes after dictSize to ensure the structure is word aligned:
+ * |=========================================================
+ * | Offset | Length | Member Name
+ * |=========================================================
+ * | 0 | 16384 | hashTable[4096]
+ * | 16384 | 4 | currentOffset
+ * | 16388 | 4 | tableType
+ * | 16392 | 8 | ***PADDING***
+ * | 16400 | 16 | dictionary
+ * | 16416 | 16 | dictCtx
+ * | 16432 | 4 | dictSize
+ * | 16436 | 12 | ***PADDING***
+ * ==========================================================
*/
-#define LZ4_STREAMSIZE ((1UL << LZ4_MEMORY_USAGE) + 32) /* static size, for inter-version compatibility */
+#define LZ4_STREAMSIZE ((1UL << LZ4_MEMORY_USAGE) + ((sizeof(void*)==16) ? 64 : 32)) /* static size, for inter-version compatibility */
#define LZ4_STREAMSIZE_VOIDP (LZ4_STREAMSIZE / sizeof(void*))
union LZ4_stream_u {
void* table[LZ4_STREAMSIZE_VOIDP];
@@ -663,8 +677,20 @@ LZ4LIB_API LZ4_stream_t* LZ4_initStream (void* buffer, size_t size);
* note : only use in association with static linking !
* this definition is not API/ABI safe,
* and may change in a future version !
+ * Note : Same story as LZ4_STREAMSIZE for OS400 in terms of additional padding to
+ * ensure pointers start on and structures finish on 16 byte boundaries
+ * |=========================================================
+ * | Offset | Length | Member Name
+ * |=========================================================
+ * | 0 | 16 | externalDict
+ * | 16 | 4 | extDictSize
+ * | 20 | 12 | ***PADDING***
+ * | 32 | 16 | prefixEnd
+ * | 48 | 4 | prefixSize
+ * | 52 | 12 | ***PADDING***
+ * ==========================================================
*/
-#define LZ4_STREAMDECODESIZE_U64 (4 + ((sizeof(void*)==16) ? 2 : 0) /*AS-400*/ )
+#define LZ4_STREAMDECODESIZE_U64 (4 + ((sizeof(void*)==16) ? 4 : 0))
#define LZ4_STREAMDECODESIZE (LZ4_STREAMDECODESIZE_U64 * sizeof(unsigned long long))
union LZ4_streamDecode_u {
unsigned long long table[LZ4_STREAMDECODESIZE_U64];