From a357f434f06de70e5d670b8669becccb09f4c7a6 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Wed, 25 Mar 2015 18:06:40 +0100 Subject: [PATCH] Fixed cast-align warnings on 32-bits --- lib/lz4.c | 2 +- lib/lz4.h | 4 ++-- lib/lz4hc.c | 2 +- lib/lz4hc.h | 16 +++++++++++----- lib/xxhash.h | 18 ++++++++++-------- 5 files changed, 25 insertions(+), 17 deletions(-) diff --git a/lib/lz4.c b/lib/lz4.c index e15a022..881d1af 100644 --- a/lib/lz4.c +++ b/lib/lz4.c @@ -1321,7 +1321,7 @@ void* LZ4_create (const char* inputBuffer) char* LZ4_slideInputBuffer (void* LZ4_Data) { LZ4_stream_t_internal* ctx = (LZ4_stream_t_internal*)LZ4_Data; - int dictSize = LZ4_saveDict((LZ4_stream_t*)ctx, (char*)ctx->bufferStart, 64 KB); + int dictSize = LZ4_saveDict((LZ4_stream_t*)LZ4_Data, (char*)ctx->bufferStart, 64 KB); return (char*)(ctx->bufferStart + dictSize); } diff --git a/lib/lz4.h b/lib/lz4.h index 7b938da..de43fc0 100644 --- a/lib/lz4.h +++ b/lib/lz4.h @@ -39,8 +39,8 @@ extern "C" { #endif /* - * lz4.h provides raw compression format functions, for optimal performance and integration into programs. - * If you need to generate data using an inter-operable format (respecting the framing specification), + * lz4.h provides block compression functions, for optimal performance. + * If you need to generate inter-operable compressed data (respecting LZ4 frame specification), * please use lz4frame.h instead. */ diff --git a/lib/lz4hc.c b/lib/lz4hc.c index 357fa96..a03c511 100644 --- a/lib/lz4hc.c +++ b/lib/lz4hc.c @@ -594,7 +594,7 @@ int LZ4_freeStreamHC (LZ4_streamHC_t* LZ4_streamHCPtr) { free(LZ4_streamHCPtr); /* initialization */ void LZ4_resetStreamHC (LZ4_streamHC_t* LZ4_streamHCPtr, int compressionLevel) { - LZ4_STATIC_ASSERT(sizeof(LZ4HC_Data_Structure) <= LZ4_STREAMHCSIZE); /* if compilation fails here, LZ4_STREAMHCSIZE must be increased */ + LZ4_STATIC_ASSERT(sizeof(LZ4HC_Data_Structure) <= sizeof(LZ4_streamHC_t)); /* if compilation fails here, LZ4_STREAMHCSIZE must be increased */ ((LZ4HC_Data_Structure*)LZ4_streamHCPtr)->base = NULL; ((LZ4HC_Data_Structure*)LZ4_streamHCPtr)->compressionLevel = (unsigned)compressionLevel; } diff --git a/lib/lz4hc.h b/lib/lz4hc.h index eb72051..4a05845 100644 --- a/lib/lz4hc.h +++ b/lib/lz4hc.h @@ -79,7 +79,7 @@ int LZ4_compressHC2_limitedOutput (const char* source, char* dest, int inputSize /************************************** - Using an external allocation +* Using an external allocation **************************************/ int LZ4_sizeofStateHC(void); int LZ4_compressHC_withStateHC (void* state, const char* source, char* dest, int inputSize); @@ -102,12 +102,18 @@ They just use the externally allocated memory for state instead of allocating th +/***************************** +* Includes +*****************************/ +#include /* size_t */ + + /************************************** - Experimental Streaming Functions +* Experimental Streaming Functions **************************************/ -#define LZ4_STREAMHCSIZE_U64 32774 -#define LZ4_STREAMHCSIZE (LZ4_STREAMHCSIZE_U64 * sizeof(unsigned long long)) -typedef struct { unsigned long long table[LZ4_STREAMHCSIZE_U64]; } LZ4_streamHC_t; +#define LZ4_STREAMHCSIZE 262192 +#define LZ4_STREAMHCSIZE_SIZET (LZ4_STREAMHCSIZE / sizeof(size_t)) +typedef struct { size_t table[LZ4_STREAMHCSIZE_SIZET]; } LZ4_streamHC_t; /* LZ4_streamHC_t This structure allows static allocation of LZ4 HC streaming state. diff --git a/lib/xxhash.h b/lib/xxhash.h index 99b0c27..34eea73 100644 --- a/lib/xxhash.h +++ b/lib/xxhash.h @@ -56,6 +56,12 @@ SHA1-32 0.28 GB/s 10 Q.Score is a measure of quality of the hash function. It depends on successfully passing SMHasher test set. 10 is a perfect score. + +A new 64-bits version, named XXH64, is available since r35. +It offers better speed for 64-bits applications. +Name Speed on 64 bits Speed on 32 bits +XXH64 13.8 GB/s 1.9 GB/s +XXH32 6.8 GB/s 6.0 GB/s */ #pragma once @@ -66,20 +72,15 @@ extern "C" { /***************************** - Includes +* Definitions *****************************/ #include /* size_t */ - - -/***************************** - Type -*****************************/ typedef enum { XXH_OK=0, XXH_ERROR } XXH_errorcode; /***************************** - Simple Hash Functions +* Simple Hash Functions *****************************/ unsigned int XXH32 (const void* input, size_t length, unsigned seed); @@ -94,12 +95,13 @@ XXH32() : Speed on Core 2 Duo @ 3 GHz (single thread, SMHasher benchmark) : 5.4 GB/s XXH64() : Calculate the 64-bits hash of sequence of length "len" stored at memory address "input". + Faster on 64-bits systems. Slower on 32-bits systems. */ /***************************** - Advanced Hash Functions +* Advanced Hash Functions *****************************/ typedef struct { long long ll[ 6]; } XXH32_state_t; typedef struct { long long ll[11]; } XXH64_state_t; -- 2.7.4