diff options
author | Yann Collet <Cyan4973@users.noreply.github.com> | 2022-07-11 13:31:58 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-11 13:31:58 (GMT) |
commit | 510dc6370610fc6f02bef963040b35d2712c4b7e (patch) | |
tree | 2b405aa79e52d110da6cdee31f7d5580cc34a50b | |
parent | 6f23d0d0810d6565df84b16a99500f47cf283968 (diff) | |
parent | b4f508608f8f9423350cf48e46dd22c452f0b809 (diff) | |
download | lz4-510dc6370610fc6f02bef963040b35d2712c4b7e.zip lz4-510dc6370610fc6f02bef963040b35d2712c4b7e.tar.gz lz4-510dc6370610fc6f02bef963040b35d2712c4b7e.tar.bz2 |
Merge pull request #1104 from jonrumsey/os400-build-fix
Change definitions of LZ4_xxxSIZE defines for OS400
-rw-r--r-- | lib/lz4.h | 30 | ||||
-rw-r--r-- | lib/lz4hc.h | 20 |
2 files changed, 47 insertions, 3 deletions
@@ -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]; diff --git a/lib/lz4hc.h b/lib/lz4hc.h index f4afc9b..6176457 100644 --- a/lib/lz4hc.h +++ b/lib/lz4hc.h @@ -219,8 +219,26 @@ struct LZ4HC_CCtx_internal /* Do not use these definitions directly ! * Declare or allocate an LZ4_streamHC_t instead. + * Note : OS400 uses 16 byte pointers and so the structure size is larger than other + * platforms + * |=========================================================== + * | Offset | Length | Member Name + * |=========================================================== + * | 0 | 131072 | hashTable[32768] + * | 131072 | 131072 | chainTable[65536] + * | 262144 | 16 | end + * | 262160 | 16 | base + * | 262176 | 16 | dictBase + * | 262192 | 4 | dictLimit + * | 262196 | 4 | lowLimit + * | 262200 | 4 | nextToUpdate + * | 262204 | 2 | compressionLevel + * | 262206 | 1 | favorDecSpeed + * | 262207 | 1 | dirty + * | 262208 | 16 | dictCtx + * ============================================================ */ -#define LZ4_STREAMHCSIZE 262200 /* static size, for inter-version compatibility */ +#define LZ4_STREAMHCSIZE (262200 + ((sizeof(void*)==16) ? 24 : 0)) /* static size, for inter-version compatibility */ #define LZ4_STREAMHCSIZE_VOIDP (LZ4_STREAMHCSIZE / sizeof(void*)) union LZ4_streamHC_u { void* table[LZ4_STREAMHCSIZE_VOIDP]; |