Skip to content

Commit

Permalink
Windows: added xxhash.c to CMakeLists
Browse files Browse the repository at this point in the history
Parallel 234e960
Explode zstd 1.4.5 into separate upstream files

Signed-off-by: Andrew Innes <[email protected]>
  • Loading branch information
andrewc12 committed Sep 23, 2022
1 parent 94aed17 commit 3ee3d43
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 18 deletions.
23 changes: 22 additions & 1 deletion lib/libzstd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,28 @@ use_clang()
set(ZSTD_MODULE_DIR "../../module/zstd")

add_library(libzstd
"${ZSTD_MODULE_DIR}/lib/common/entropy_common.c"
"${ZSTD_MODULE_DIR}/lib/common/error_private.c"
"${ZSTD_MODULE_DIR}/lib/common/fse_decompress.c"
"${ZSTD_MODULE_DIR}/lib/common/pool.c"
"${ZSTD_MODULE_DIR}/lib/common/zstd_common.c"
"${ZSTD_MODULE_DIR}/lib/common/xxhash.c"
"${ZSTD_MODULE_DIR}/lib/compress/fse_compress.c"
"${ZSTD_MODULE_DIR}/lib/compress/hist.c"
"${ZSTD_MODULE_DIR}/lib/compress/huf_compress.c"
"${ZSTD_MODULE_DIR}/lib/compress/zstd_compress_literals.c"
"${ZSTD_MODULE_DIR}/lib/compress/zstd_compress_sequences.c"
"${ZSTD_MODULE_DIR}/lib/compress/zstd_compress_superblock.c"
"${ZSTD_MODULE_DIR}/lib/compress/zstd_compress.c"
"${ZSTD_MODULE_DIR}/lib/compress/zstd_double_fast.c"
"${ZSTD_MODULE_DIR}/lib/compress/zstd_fast.c"
"${ZSTD_MODULE_DIR}/lib/compress/zstd_lazy.c"
"${ZSTD_MODULE_DIR}/lib/compress/zstd_ldm.c"
"${ZSTD_MODULE_DIR}/lib/compress/zstd_opt.c"
"${ZSTD_MODULE_DIR}/lib/decompress/huf_decompress.c"
"${ZSTD_MODULE_DIR}/lib/decompress/zstd_ddict.c"
"${ZSTD_MODULE_DIR}/lib/decompress/zstd_decompress.c"
"${ZSTD_MODULE_DIR}/lib/decompress/zstd_decompress_block.c"
"${ZSTD_MODULE_DIR}/zfs_zstd.c"
"${ZSTD_MODULE_DIR}/lib/zstd.c"
)
target_link_libraries(libzstd PUBLIC libnvpair libpthread)
23 changes: 22 additions & 1 deletion module/zstd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,28 @@
use_clang()

wdk_add_library(zstdkern
lib/zstd.c
lib/common/entropy_common.c
lib/common/error_private.c
lib/common/fse_decompress.c
lib/common/pool.c
lib/common/zstd_common.c
lib/common/xxhash.c
lib/compress/fse_compress.c
lib/compress/hist.c
lib/compress/huf_compress.c
lib/compress/zstd_compress_literals.c
lib/compress/zstd_compress_sequences.c
lib/compress/zstd_compress_superblock.c
lib/compress/zstd_compress.c
lib/compress/zstd_double_fast.c
lib/compress/zstd_fast.c
lib/compress/zstd_lazy.c
lib/compress/zstd_ldm.c
lib/compress/zstd_opt.c
lib/decompress/huf_decompress.c
lib/decompress/zstd_ddict.c
lib/decompress/zstd_decompress.c
lib/decompress/zstd_decompress_block.c
zfs_zstd.c
)

Expand Down
2 changes: 1 addition & 1 deletion module/zstd/lib/common/bitstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ MEM_STATIC unsigned BIT_highbit32 (U32 val)
{
assert(val != 0);
{
# if defined(_MSC_VER) /* Visual */
# if defined(_MSC_VER) && !defined(__clang__) /* Visual */
unsigned long r=0;
return _BitScanReverse ( &r, val ) ? (unsigned)r : 0;
# elif defined(__GNUC__) && (__GNUC__ >= 3) /* Use GCC Intrinsic */
Expand Down
4 changes: 2 additions & 2 deletions module/zstd/lib/common/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
# define PREFETCH_L1(ptr) (void)(ptr) /* disabled */
# define PREFETCH_L2(ptr) (void)(ptr) /* disabled */
#else
# if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_I86)) /* _mm_prefetch() is not defined outside of x86/x64 */
# if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_I86)) && !defined(__clang__) /* _mm_prefetch() is not defined outside of x86/x64 */
# include <mmintrin.h> /* https://msdn.microsoft.com/fr-fr/library/84szxsww(v=vs.90).aspx */
# define PREFETCH_L1(ptr) _mm_prefetch((const char*)(ptr), _MM_HINT_T0)
# define PREFETCH_L2(ptr) _mm_prefetch((const char*)(ptr), _MM_HINT_T1)
Expand Down Expand Up @@ -163,7 +163,7 @@
#endif

/* disable warnings */
#ifdef _MSC_VER /* Visual Studio */
#if defined(_MSC_VER) && !defined(__clang__) /* Visual Studio */
# include <intrin.h> /* For Visual 2005 */
# pragma warning(disable : 4100) /* disable: C4100: unreferenced formal parameter */
# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
Expand Down
4 changes: 2 additions & 2 deletions module/zstd/lib/common/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "mem.h"

#ifdef _MSC_VER
#if defined(_MSC_VER) && !defined(__clang__)
#include <intrin.h>
#endif

Expand All @@ -36,7 +36,7 @@ MEM_STATIC ZSTD_cpuid_t ZSTD_cpuid(void) {
U32 f1d = 0;
U32 f7b = 0;
U32 f7c = 0;
#if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_IX86))
#if defined(_MSC_VER) && !defined(__clang__) && (defined(_M_X64) || defined(_M_IX86))
int reg[4];
__cpuid((int*)reg, 0);
{
Expand Down
6 changes: 3 additions & 3 deletions module/zstd/lib/common/mem.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extern "C" {
/*-****************************************
* Compiler specifics
******************************************/
#if defined(_MSC_VER) /* Visual Studio */
#if defined(_MSC_VER) && !defined(__clang__) /* Visual Studio */
# include <stdlib.h> /* _byteswap_ulong */
# include <intrin.h> /* _byteswap_* */
#endif
Expand Down Expand Up @@ -270,7 +270,7 @@ MEM_STATIC void MEM_write64(void* memPtr, U64 value)

MEM_STATIC U32 MEM_swap32(U32 in)
{
#if defined(_MSC_VER) /* Visual Studio */
#if defined(_MSC_VER) && !defined(__clang__) /* Visual Studio */
return _byteswap_ulong(in);
#elif (defined (__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 403)) \
|| (defined(__clang__) && __has_builtin(__builtin_bswap32))
Expand All @@ -285,7 +285,7 @@ MEM_STATIC U32 MEM_swap32(U32 in)

MEM_STATIC U64 MEM_swap64(U64 in)
{
#if defined(_MSC_VER) /* Visual Studio */
#if defined(_MSC_VER) && !defined(__clang__) /* Visual Studio */
return _byteswap_uint64(in);
#elif (defined (__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 403)) \
|| (defined(__clang__) && __has_builtin(__builtin_bswap64))
Expand Down
4 changes: 2 additions & 2 deletions module/zstd/lib/common/xxhash.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* You can contact the author at :
* - xxHash homepage: http://www.xxhash.com
* - xxHash source repository : https://github.com/Cyan4973/xxHash
*
*
* This source code is licensed under both the BSD-style license (found in the
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
* in the COPYING file in the root directory of this source tree).
Expand Down Expand Up @@ -196,7 +196,7 @@ static U64 XXH_read64(const void* memPtr)
# define XXH_rotl64(x,r) ((x << r) | (x >> (64 - r)))
#endif

#if defined(_MSC_VER) /* Visual Studio */
#if defined(_MSC_VER) && !defined(__clang__) /* Visual Studio */
# define XXH_swap32 _byteswap_ulong
# define XXH_swap64 _byteswap_uint64
#elif GCC_VERSION >= 403
Expand Down
4 changes: 2 additions & 2 deletions module/zstd/lib/common/zstd_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ typedef enum {
* - ZSTD_overlap_src_before_dst: The src and dst may overlap, but they MUST be at least 8 bytes apart.
* The src buffer must be before the dst buffer.
*/
MEM_STATIC FORCE_INLINE_ATTR
MEM_STATIC FORCE_INLINE_ATTR
void ZSTD_wildcopy(void* dst, const void* src, ptrdiff_t length, ZSTD_overlap_e const ovtype)
{
ptrdiff_t diff = (BYTE*)dst - (const BYTE*)src;
Expand Down Expand Up @@ -393,7 +393,7 @@ MEM_STATIC U32 ZSTD_highbit32(U32 val) /* compress, dictBuilder, decodeCorpus
{
assert(val != 0);
{
# if defined(_MSC_VER) /* Visual */
# if defined(_MSC_VER) && !defined(__clang__)
unsigned long r=0;
return _BitScanReverse(&r, val) ? (unsigned)r : 0;
# elif defined(__GNUC__) && (__GNUC__ >= 3) /* GCC Intrinsic */
Expand Down
8 changes: 4 additions & 4 deletions module/zstd/lib/compress/zstd_compress_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ static unsigned ZSTD_NbCommonBytes (size_t val)
{
if (MEM_isLittleEndian()) {
if (MEM_64bits()) {
# if defined(_MSC_VER) && defined(_WIN64)
# if defined(_MSC_VER) && defined(_WIN64) && !defined(__clang__)
unsigned long r = 0;
return _BitScanForward64( &r, (U64)val ) ? (unsigned)(r >> 3) : 0;
# elif defined(__GNUC__) && (__GNUC__ >= 4)
Expand All @@ -514,7 +514,7 @@ static unsigned ZSTD_NbCommonBytes (size_t val)
return DeBruijnBytePos[((U64)((val & -(long long)val) * 0x0218A392CDABBD3FULL)) >> 58];
# endif
} else { /* 32 bits */
# if defined(_MSC_VER)
# if defined(_MSC_VER) && !defined(__clang__)
unsigned long r=0;
return _BitScanForward( &r, (U32)val ) ? (unsigned)(r >> 3) : 0;
# elif defined(__GNUC__) && (__GNUC__ >= 3)
Expand All @@ -529,7 +529,7 @@ static unsigned ZSTD_NbCommonBytes (size_t val)
}
} else { /* Big Endian CPU */
if (MEM_64bits()) {
# if defined(_MSC_VER) && defined(_WIN64)
# if defined(_MSC_VER) && defined(_WIN64) && !defined(__clang__)
unsigned long r = 0;
return _BitScanReverse64( &r, val ) ? (unsigned)(r >> 3) : 0;
# elif defined(__GNUC__) && (__GNUC__ >= 4)
Expand All @@ -543,7 +543,7 @@ static unsigned ZSTD_NbCommonBytes (size_t val)
return r;
# endif
} else { /* 32 bits */
# if defined(_MSC_VER)
# if defined(_MSC_VER) && !defined(__clang__)
unsigned long r = 0;
return _BitScanReverse( &r, (unsigned long)val ) ? (unsigned)(r >> 3) : 0;
# elif defined(__GNUC__) && (__GNUC__ >= 3)
Expand Down

0 comments on commit 3ee3d43

Please sign in to comment.