From d54b2d23b43a30ed71b32871a9ae5a10e6d10ecd Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Sun, 17 Jul 2016 15:53:18 +0200 Subject: [PATCH] minor static assert for 32/64 bits system. Suggested by @ebiggers --- NEWS | 3 +++ lib/common/mem.h | 12 +++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 04e64936..2c318462 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +v0.7.5 +Fixed : premature end of frame when zero-sized raw block, reported by Eric Biggers + v0.7.4 Added : homebrew for Mac Added : more examples diff --git a/lib/common/mem.h b/lib/common/mem.h index 9156bfda..f76c52d9 100644 --- a/lib/common/mem.h +++ b/lib/common/mem.h @@ -44,16 +44,14 @@ extern "C" { ******************************************/ #include /* size_t, ptrdiff_t */ #include /* memcpy */ -#if defined(_MSC_VER) /* Visual Studio */ -# include /* _byteswap_ulong */ -#endif /*-**************************************** * Compiler specifics ******************************************/ -#if defined(_MSC_VER) -# include /* _byteswap_ */ +#if defined(_MSC_VER) /* Visual Studio */ +# include /* _byteswap_ulong */ +# include /* _byteswap_* */ #endif #if defined(__GNUC__) # define MEM_STATIC static __attribute__((unused)) @@ -65,6 +63,10 @@ extern "C" { # define MEM_STATIC static /* this version may generate warnings for unused static functions; disable the relevant warning */ #endif +/* code only tested on 32 and 64 bits systems */ +#define MEM_STATIC_ASSERT(c) { enum { XXH_static_assert = 1/(int)(!!(c)) }; } +MEM_STATIC void MEM_check(void) { MEM_STATIC_ASSERT((sizeof(size_t)==4) || (sizeof(size_t)==8)); } + /*-************************************************************** * Basic Types