Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) #ifndef __LZ4DEFS_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) #define __LZ4DEFS_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * lz4defs.h -- common and architecture specific defines for the kernel usage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * LZ4 - Fast LZ compression algorithm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * Copyright (C) 2011-2016, Yann Collet.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * Redistribution and use in source and binary forms, with or without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * modification, are permitted provided that the following conditions are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  * met:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *	* Redistributions of source code must retain the above copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  *	  notice, this list of conditions and the following disclaimer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  *	* Redistributions in binary form must reproduce the above
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  * copyright notice, this list of conditions and the following disclaimer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  * in the documentation and/or other materials provided with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  * distribution.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  * You can contact the author at :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  *	- LZ4 homepage : http://www.lz4.org
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  *	- LZ4 source repository : https://github.com/lz4/lz4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  *	Changed for kernel usage by:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  *	Sven Schmidt <4sschmid@informatik.uni-hamburg.de>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #include <asm/unaligned.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #include <linux/string.h>	 /* memset, memcpy */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #define FORCE_INLINE __always_inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) /*-************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  *	Basic Types
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)  **************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) typedef	uint8_t BYTE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) typedef uint16_t U16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) typedef uint32_t U32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) typedef	int32_t S32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) typedef uint64_t U64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) typedef uintptr_t uptrval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) /*-************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)  *	Architecture specifics
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)  **************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) #if defined(CONFIG_64BIT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) #define LZ4_ARCH64 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) #define LZ4_ARCH64 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) #if defined(__LITTLE_ENDIAN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) #define LZ4_LITTLE_ENDIAN 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) #define LZ4_LITTLE_ENDIAN 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) /*-************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  *	Constants
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  **************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) #define MINMATCH 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) #define WILDCOPYLENGTH 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) #define LASTLITERALS 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) #define MFLIMIT (WILDCOPYLENGTH + MINMATCH)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)  * ensure it's possible to write 2 x wildcopyLength
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)  * without overflowing output buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) #define MATCH_SAFEGUARD_DISTANCE  ((2 * WILDCOPYLENGTH) - MINMATCH)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) /* Increase this value ==> compression run slower on incompressible data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) #define LZ4_SKIPTRIGGER 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) #define HASH_UNIT sizeof(size_t)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) #define KB (1 << 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) #define MB (1 << 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) #define GB (1U << 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) #define MAXD_LOG 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) #define MAX_DISTANCE ((1 << MAXD_LOG) - 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) #define STEPSIZE sizeof(size_t)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) #define ML_BITS	4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) #define ML_MASK	((1U << ML_BITS) - 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) #define RUN_BITS (8 - ML_BITS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) #define RUN_MASK ((1U << RUN_BITS) - 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) /*-************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)  *	Reading and writing into memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)  **************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) static FORCE_INLINE U16 LZ4_read16(const void *ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	return get_unaligned((const U16 *)ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) static FORCE_INLINE U32 LZ4_read32(const void *ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	return get_unaligned((const U32 *)ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) static FORCE_INLINE size_t LZ4_read_ARCH(const void *ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	return get_unaligned((const size_t *)ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) static FORCE_INLINE void LZ4_write16(void *memPtr, U16 value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	put_unaligned(value, (U16 *)memPtr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) static FORCE_INLINE void LZ4_write32(void *memPtr, U32 value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	put_unaligned(value, (U32 *)memPtr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) static FORCE_INLINE U16 LZ4_readLE16(const void *memPtr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	return get_unaligned_le16(memPtr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) static FORCE_INLINE void LZ4_writeLE16(void *memPtr, U16 value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	return put_unaligned_le16(value, memPtr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)  * LZ4 relies on memcpy with a constant size being inlined. In freestanding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)  * environments, the compiler can't assume the implementation of memcpy() is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)  * standard compliant, so apply its specialized memcpy() inlining logic. When
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)  * possible, use __builtin_memcpy() to tell the compiler to analyze memcpy()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)  * as-if it were standard compliant, so it can inline it in freestanding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)  * environments. This is needed when decompressing the Linux Kernel, for example.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) #define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) #define LZ4_memmove(dst, src, size) __builtin_memmove(dst, src, size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) static FORCE_INLINE void LZ4_copy8(void *dst, const void *src)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) #if LZ4_ARCH64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	U64 a = get_unaligned((const U64 *)src);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	put_unaligned(a, (U64 *)dst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	U32 a = get_unaligned((const U32 *)src);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	U32 b = get_unaligned((const U32 *)src + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	put_unaligned(a, (U32 *)dst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	put_unaligned(b, (U32 *)dst + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)  * customized variant of memcpy,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)  * which can overwrite up to 7 bytes beyond dstEnd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) static FORCE_INLINE void LZ4_wildCopy(void *dstPtr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	const void *srcPtr, void *dstEnd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	BYTE *d = (BYTE *)dstPtr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	const BYTE *s = (const BYTE *)srcPtr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	BYTE *const e = (BYTE *)dstEnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 		LZ4_copy8(d, s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		d += 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 		s += 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	} while (d < e);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) static FORCE_INLINE unsigned int LZ4_NbCommonBytes(register size_t val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) #if LZ4_LITTLE_ENDIAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	return __ffs(val) >> 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	return (BITS_PER_LONG - 1 - __fls(val)) >> 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) static FORCE_INLINE unsigned int LZ4_count(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	const BYTE *pIn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	const BYTE *pMatch,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	const BYTE *pInLimit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	const BYTE *const pStart = pIn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	while (likely(pIn < pInLimit - (STEPSIZE - 1))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		size_t const diff = LZ4_read_ARCH(pMatch) ^ LZ4_read_ARCH(pIn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 		if (!diff) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 			pIn += STEPSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 			pMatch += STEPSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		pIn += LZ4_NbCommonBytes(diff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		return (unsigned int)(pIn - pStart);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) #if LZ4_ARCH64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	if ((pIn < (pInLimit - 3))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		&& (LZ4_read32(pMatch) == LZ4_read32(pIn))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 		pIn += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		pMatch += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	if ((pIn < (pInLimit - 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		&& (LZ4_read16(pMatch) == LZ4_read16(pIn))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 		pIn += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		pMatch += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	if ((pIn < pInLimit) && (*pMatch == *pIn))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		pIn++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	return (unsigned int)(pIn - pStart);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) typedef enum { noLimit = 0, limitedOutput = 1 } limitedOutput_directive;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) typedef enum { byPtr, byU32, byU16 } tableType_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) typedef enum { noDict = 0, withPrefix64k, usingExtDict } dict_directive;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) typedef enum { noDictIssue = 0, dictSmall } dictIssue_directive;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) typedef enum { endOnOutputSize = 0, endOnInputSize = 1 } endCondition_directive;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) typedef enum { decode_full_block = 0, partial_decode = 1 } earlyEnd_directive;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) #define LZ4_STATIC_ASSERT(c)	BUILD_BUG_ON(!(c))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) #endif