diff options
author | Yann Collet <cyan@fb.com> | 2020-11-07 00:43:14 (GMT) |
---|---|---|
committer | Yann Collet <cyan@fb.com> | 2020-11-07 00:43:14 (GMT) |
commit | 211d653ff866ee98a51ab135067369f52f6bdc7b (patch) | |
tree | 08203431f5b74519c2e410ffa34082c7d082f4d6 /lib | |
parent | 0c56f838edfb1eb06553985a141e5243f740ef27 (diff) | |
download | lz4-211d653ff866ee98a51ab135067369f52f6bdc7b.zip lz4-211d653ff866ee98a51ab135067369f52f6bdc7b.tar.gz lz4-211d653ff866ee98a51ab135067369f52f6bdc7b.tar.bz2 |
re-enable alignment test on all targets
Diffstat (limited to 'lib')
-rw-r--r-- | lib/README.md | 5 | ||||
-rw-r--r-- | lib/lz4.c | 20 | ||||
-rw-r--r-- | lib/lz4.h | 2 |
3 files changed, 10 insertions, 17 deletions
diff --git a/lib/README.md b/lib/README.md index 7a9e4fd..ee5d3ba 100644 --- a/lib/README.md +++ b/lib/README.md @@ -77,8 +77,9 @@ The following build macro can be selected to adjust source code behavior at comp In most cases, it's not expected to be necessary, but it can be legitimately considered for less common platforms. -- `LZ4_ALIGN_TEST` : disable state alignment test when set to 0. - Is generally enabled by default, except on win32+visual. +- `LZ4_ALIGN_TEST` : alignment test ensures that the memory area + passed as argument to become a compression state is suitable aligned. + This test can be disabled, if it proves flaky, by setting this value to 0. #### Amalgamation @@ -178,18 +178,10 @@ #define unlikely(expr) expect((expr) != 0, 0) #endif -/* for some reason, Visual Studio can fail the aligment test on 32-bit x86 : - * it sometimes report an aligment of 8-bytes (at least in some configurations), - * while only providing a `malloc()` memory area aligned on 4-bytes, - * which is inconsistent with malloc() contract. - * The source of the issue is still unclear. - * Mitigation : made the alignment test optional */ +/* Should the alignment test prove unreliable, for some reason, + * it can be disabled by setting LZ4_ALIGN_TEST to 0 */ #ifndef LZ4_ALIGN_TEST /* can be externally provided */ -# if (defined(_MSC_VER) && !defined(_M_X64)) -# define LZ4_ALIGN_TEST 0 /* disable on win32+visual */ -# else -# define LZ4_ALIGN_TEST 1 -# endif +# define LZ4_ALIGN_TEST 1 #endif @@ -476,7 +468,7 @@ LZ4_memcpy_using_offset(BYTE* dstPtr, const BYTE* srcPtr, BYTE* dstEnd, const si switch(offset) { case 1: - memset(v, *srcPtr, 8); + MEM_INIT(v, *srcPtr, 8); break; case 2: LZ4_memcpy(v, srcPtr, 2); @@ -1441,7 +1433,7 @@ LZ4_stream_t* LZ4_initStream (void* buffer, size_t size) if (buffer == NULL) { return NULL; } if (size < sizeof(LZ4_stream_t)) { return NULL; } if (!LZ4_isAligned(buffer, LZ4_stream_t_alignment())) return NULL; - MEM_INIT(buffer, 0, sizeof(LZ4_stream_t)); + MEM_INIT(buffer, 0, sizeof(LZ4_stream_t_internal)); return (LZ4_stream_t*)buffer; } @@ -1450,7 +1442,7 @@ LZ4_stream_t* LZ4_initStream (void* buffer, size_t size) void LZ4_resetStream (LZ4_stream_t* LZ4_stream) { DEBUGLOG(5, "LZ4_resetStream (ctx:%p)", LZ4_stream); - MEM_INIT(LZ4_stream, 0, sizeof(LZ4_stream_t)); + MEM_INIT(LZ4_stream, 0, sizeof(LZ4_stream_t_internal)); } void LZ4_resetStream_fast(LZ4_stream_t* ctx) { @@ -618,7 +618,7 @@ typedef struct { * (on stack, or as part of larger structure). * 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. + * this definition is not API/ABI safe, and may change in future versions. */ #define LZ4_STREAMSIZE_VOIDP ((sizeof(LZ4_stream_t_internal) + sizeof(void*)-1) / sizeof(void*)) #define LZ4_STREAMSIZE (LZ4_STREAMSIZE_VOIDP * sizeof(void*)) |