Loading MAINTAINERS +1 −1 Original line number Diff line number Diff line Loading @@ -22811,7 +22811,7 @@ ZSTD M: Nick Terrell <terrelln@fb.com> S: Maintained B: https://github.com/facebook/zstd/issues T: git git://github.com/terrelln/linux.git T: git https://github.com/terrelln/linux.git F: include/linux/zstd* F: lib/zstd/ F: lib/decompress_unzstd.c include/linux/zstd_lib.h +297 −178 File changed.Preview size limit exceeded, changes collapsed. Show changes lib/zstd/Makefile +1 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ zstd_decompress-y := \ decompress/zstd_decompress_block.o \ zstd_common-y := \ zstd_common_module.o \ common/debug.o \ common/entropy_common.o \ common/error_private.o \ Loading lib/zstd/common/bitstream.h +9 −0 Original line number Diff line number Diff line Loading @@ -313,7 +313,16 @@ MEM_STATIC FORCE_INLINE_ATTR size_t BIT_getMiddleBits(size_t bitContainer, U32 c U32 const regMask = sizeof(bitContainer)*8 - 1; /* if start > regMask, bitstream is corrupted, and result is undefined */ assert(nbBits < BIT_MASK_SIZE); /* x86 transform & ((1 << nbBits) - 1) to bzhi instruction, it is better * than accessing memory. When bmi2 instruction is not present, we consider * such cpus old (pre-Haswell, 2013) and their performance is not of that * importance. */ #if defined(__x86_64__) || defined(_M_X86) return (bitContainer >> (start & regMask)) & ((((U64)1) << nbBits) - 1); #else return (bitContainer >> (start & regMask)) & BIT_mask[nbBits]; #endif } MEM_STATIC FORCE_INLINE_ATTR size_t BIT_getLowerBits(size_t bitContainer, U32 const nbBits) Loading lib/zstd/common/compiler.h +37 −30 Original line number Diff line number Diff line Loading @@ -11,6 +11,8 @@ #ifndef ZSTD_COMPILER_H #define ZSTD_COMPILER_H #include "portability_macros.h" /*-******************************************************* * Compiler specifics *********************************************************/ Loading @@ -34,7 +36,7 @@ /* On MSVC qsort requires that functions passed into it use the __cdecl calling conversion(CC). This explictly marks such functions as __cdecl so that the code will still compile This explicitly marks such functions as __cdecl so that the code will still compile if a CC other than __cdecl has been made the default. */ #define WIN_CDECL Loading Loading @@ -70,25 +72,13 @@ /* target attribute */ #ifndef __has_attribute #define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */ #endif #define TARGET_ATTRIBUTE(target) __attribute__((__target__(target))) /* Enable runtime BMI2 dispatch based on the CPU. * Enabled for clang & gcc >=4.8 on x86 when BMI2 isn't enabled by default. /* Target attribute for BMI2 dynamic dispatch. * Enable lzcnt, bmi, and bmi2. * We test for bmi1 & bmi2. lzcnt is included in bmi1. */ #ifndef DYNAMIC_BMI2 #if ((defined(__clang__) && __has_attribute(__target__)) \ || (defined(__GNUC__) \ && (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)))) \ && (defined(__x86_64__) || defined(_M_X86)) \ && !defined(__BMI2__) # define DYNAMIC_BMI2 1 #else # define DYNAMIC_BMI2 0 #endif #endif #define BMI2_TARGET_ATTRIBUTE TARGET_ATTRIBUTE("lzcnt,bmi,bmi2") /* prefetch * can be disabled, by declaring NO_PREFETCH build macro */ Loading @@ -115,8 +105,9 @@ } /* vectorization * older GCC (pre gcc-4.3 picked as the cutoff) uses a different syntax */ #if !defined(__INTEL_COMPILER) && !defined(__clang__) && defined(__GNUC__) * older GCC (pre gcc-4.3 picked as the cutoff) uses a different syntax, * and some compilers, like Intel ICC and MCST LCC, do not support it at all. */ #if !defined(__INTEL_COMPILER) && !defined(__clang__) && defined(__GNUC__) && !defined(__LCC__) # if (__GNUC__ == 4 && __GNUC_MINOR__ > 3) || (__GNUC__ >= 5) # define DONT_VECTORIZE __attribute__((optimize("no-tree-vectorize"))) # else Loading @@ -134,20 +125,18 @@ #define LIKELY(x) (__builtin_expect((x), 1)) #define UNLIKELY(x) (__builtin_expect((x), 0)) #if __has_builtin(__builtin_unreachable) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))) # define ZSTD_UNREACHABLE { assert(0), __builtin_unreachable(); } #else # define ZSTD_UNREACHABLE { assert(0); } #endif /* disable warnings */ /*Like DYNAMIC_BMI2 but for compile time determination of BMI2 support*/ /* compat. with non-clang compilers */ #ifndef __has_builtin # define __has_builtin(x) 0 #endif /* compat. with non-clang compilers */ #ifndef __has_feature # define __has_feature(x) 0 #endif /* compile time determination of SIMD support */ /* C-language Attributes are added in C23. */ #if defined(__STDC_VERSION__) && (__STDC_VERSION__ > 201710L) && defined(__has_c_attribute) Loading @@ -168,10 +157,28 @@ */ #define ZSTD_FALLTHROUGH fallthrough /* detects whether we are being compiled under msan */ /*-************************************************************** * Alignment check *****************************************************************/ /* this test was initially positioned in mem.h, * but this file is removed (or replaced) for linux kernel * so it's now hosted in compiler.h, * which remains valid for both user & kernel spaces. */ #ifndef ZSTD_ALIGNOF /* covers gcc, clang & MSVC */ /* note : this section must come first, before C11, * due to a limitation in the kernel source generator */ # define ZSTD_ALIGNOF(T) __alignof(T) #endif /* ZSTD_ALIGNOF */ /*-************************************************************** * Sanitizer *****************************************************************/ /* detects whether we are being compiled under asan */ #endif /* ZSTD_COMPILER_H */ Loading
MAINTAINERS +1 −1 Original line number Diff line number Diff line Loading @@ -22811,7 +22811,7 @@ ZSTD M: Nick Terrell <terrelln@fb.com> S: Maintained B: https://github.com/facebook/zstd/issues T: git git://github.com/terrelln/linux.git T: git https://github.com/terrelln/linux.git F: include/linux/zstd* F: lib/zstd/ F: lib/decompress_unzstd.c
include/linux/zstd_lib.h +297 −178 File changed.Preview size limit exceeded, changes collapsed. Show changes
lib/zstd/Makefile +1 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ zstd_decompress-y := \ decompress/zstd_decompress_block.o \ zstd_common-y := \ zstd_common_module.o \ common/debug.o \ common/entropy_common.o \ common/error_private.o \ Loading
lib/zstd/common/bitstream.h +9 −0 Original line number Diff line number Diff line Loading @@ -313,7 +313,16 @@ MEM_STATIC FORCE_INLINE_ATTR size_t BIT_getMiddleBits(size_t bitContainer, U32 c U32 const regMask = sizeof(bitContainer)*8 - 1; /* if start > regMask, bitstream is corrupted, and result is undefined */ assert(nbBits < BIT_MASK_SIZE); /* x86 transform & ((1 << nbBits) - 1) to bzhi instruction, it is better * than accessing memory. When bmi2 instruction is not present, we consider * such cpus old (pre-Haswell, 2013) and their performance is not of that * importance. */ #if defined(__x86_64__) || defined(_M_X86) return (bitContainer >> (start & regMask)) & ((((U64)1) << nbBits) - 1); #else return (bitContainer >> (start & regMask)) & BIT_mask[nbBits]; #endif } MEM_STATIC FORCE_INLINE_ATTR size_t BIT_getLowerBits(size_t bitContainer, U32 const nbBits) Loading
lib/zstd/common/compiler.h +37 −30 Original line number Diff line number Diff line Loading @@ -11,6 +11,8 @@ #ifndef ZSTD_COMPILER_H #define ZSTD_COMPILER_H #include "portability_macros.h" /*-******************************************************* * Compiler specifics *********************************************************/ Loading @@ -34,7 +36,7 @@ /* On MSVC qsort requires that functions passed into it use the __cdecl calling conversion(CC). This explictly marks such functions as __cdecl so that the code will still compile This explicitly marks such functions as __cdecl so that the code will still compile if a CC other than __cdecl has been made the default. */ #define WIN_CDECL Loading Loading @@ -70,25 +72,13 @@ /* target attribute */ #ifndef __has_attribute #define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */ #endif #define TARGET_ATTRIBUTE(target) __attribute__((__target__(target))) /* Enable runtime BMI2 dispatch based on the CPU. * Enabled for clang & gcc >=4.8 on x86 when BMI2 isn't enabled by default. /* Target attribute for BMI2 dynamic dispatch. * Enable lzcnt, bmi, and bmi2. * We test for bmi1 & bmi2. lzcnt is included in bmi1. */ #ifndef DYNAMIC_BMI2 #if ((defined(__clang__) && __has_attribute(__target__)) \ || (defined(__GNUC__) \ && (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)))) \ && (defined(__x86_64__) || defined(_M_X86)) \ && !defined(__BMI2__) # define DYNAMIC_BMI2 1 #else # define DYNAMIC_BMI2 0 #endif #endif #define BMI2_TARGET_ATTRIBUTE TARGET_ATTRIBUTE("lzcnt,bmi,bmi2") /* prefetch * can be disabled, by declaring NO_PREFETCH build macro */ Loading @@ -115,8 +105,9 @@ } /* vectorization * older GCC (pre gcc-4.3 picked as the cutoff) uses a different syntax */ #if !defined(__INTEL_COMPILER) && !defined(__clang__) && defined(__GNUC__) * older GCC (pre gcc-4.3 picked as the cutoff) uses a different syntax, * and some compilers, like Intel ICC and MCST LCC, do not support it at all. */ #if !defined(__INTEL_COMPILER) && !defined(__clang__) && defined(__GNUC__) && !defined(__LCC__) # if (__GNUC__ == 4 && __GNUC_MINOR__ > 3) || (__GNUC__ >= 5) # define DONT_VECTORIZE __attribute__((optimize("no-tree-vectorize"))) # else Loading @@ -134,20 +125,18 @@ #define LIKELY(x) (__builtin_expect((x), 1)) #define UNLIKELY(x) (__builtin_expect((x), 0)) #if __has_builtin(__builtin_unreachable) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))) # define ZSTD_UNREACHABLE { assert(0), __builtin_unreachable(); } #else # define ZSTD_UNREACHABLE { assert(0); } #endif /* disable warnings */ /*Like DYNAMIC_BMI2 but for compile time determination of BMI2 support*/ /* compat. with non-clang compilers */ #ifndef __has_builtin # define __has_builtin(x) 0 #endif /* compat. with non-clang compilers */ #ifndef __has_feature # define __has_feature(x) 0 #endif /* compile time determination of SIMD support */ /* C-language Attributes are added in C23. */ #if defined(__STDC_VERSION__) && (__STDC_VERSION__ > 201710L) && defined(__has_c_attribute) Loading @@ -168,10 +157,28 @@ */ #define ZSTD_FALLTHROUGH fallthrough /* detects whether we are being compiled under msan */ /*-************************************************************** * Alignment check *****************************************************************/ /* this test was initially positioned in mem.h, * but this file is removed (or replaced) for linux kernel * so it's now hosted in compiler.h, * which remains valid for both user & kernel spaces. */ #ifndef ZSTD_ALIGNOF /* covers gcc, clang & MSVC */ /* note : this section must come first, before C11, * due to a limitation in the kernel source generator */ # define ZSTD_ALIGNOF(T) __alignof(T) #endif /* ZSTD_ALIGNOF */ /*-************************************************************** * Sanitizer *****************************************************************/ /* detects whether we are being compiled under asan */ #endif /* ZSTD_COMPILER_H */