#ifndef __LZ4DEFS_H__ #define __LZ4DEFS_H__ /* * lz4defs.h -- common and architecture specific defines for the kernel usage * LZ4 - Fast LZ compression algorithm * Copyright (C) 2011-2016, Yann Collet. * BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * You can contact the author at : * - LZ4 homepage : http://www.lz4.org * - LZ4 source repository : https://github.com/lz4/lz4 * * Changed for kernel usage by: * Sven Schmidt <[email protected]> */ #include <asm/unaligned.h> #include <linux/bitops.h> #include <linux/string.h> /* memset, memcpy */ #define FORCE_INLINE … /*-************************************ * Basic Types **************************************/ #include <linux/types.h> BYTE; U16; U32; S32; U64; uptrval; /*-************************************ * Architecture specifics **************************************/ #if defined(CONFIG_64BIT) #define LZ4_ARCH64 … #else #define LZ4_ARCH64 … #endif #if defined(__LITTLE_ENDIAN) #define LZ4_LITTLE_ENDIAN … #else #define LZ4_LITTLE_ENDIAN … #endif /*-************************************ * Constants **************************************/ #define MINMATCH … #define WILDCOPYLENGTH … #define LASTLITERALS … #define MFLIMIT … /* * ensure it's possible to write 2 x wildcopyLength * without overflowing output buffer */ #define MATCH_SAFEGUARD_DISTANCE … /* Increase this value ==> compression run slower on incompressible data */ #define LZ4_SKIPTRIGGER … #define HASH_UNIT … #define KB … #define MB … #define GB … #define MAXD_LOG … #define MAX_DISTANCE … #define STEPSIZE … #define ML_BITS … #define ML_MASK … #define RUN_BITS … #define RUN_MASK … /*-************************************ * Reading and writing into memory **************************************/ static FORCE_INLINE U16 LZ4_read16(const void *ptr) { … } static FORCE_INLINE U32 LZ4_read32(const void *ptr) { … } static FORCE_INLINE size_t LZ4_read_ARCH(const void *ptr) { … } static FORCE_INLINE void LZ4_write16(void *memPtr, U16 value) { … } static FORCE_INLINE void LZ4_write32(void *memPtr, U32 value) { … } static FORCE_INLINE U16 LZ4_readLE16(const void *memPtr) { … } static FORCE_INLINE void LZ4_writeLE16(void *memPtr, U16 value) { … } /* * LZ4 relies on memcpy with a constant size being inlined. In freestanding * environments, the compiler can't assume the implementation of memcpy() is * standard compliant, so apply its specialized memcpy() inlining logic. When * possible, use __builtin_memcpy() to tell the compiler to analyze memcpy() * as-if it were standard compliant, so it can inline it in freestanding * environments. This is needed when decompressing the Linux Kernel, for example. */ #define LZ4_memcpy(dst, src, size) … #define LZ4_memmove(dst, src, size) … static FORCE_INLINE void LZ4_copy8(void *dst, const void *src) { … } /* * customized variant of memcpy, * which can overwrite up to 7 bytes beyond dstEnd */ static FORCE_INLINE void LZ4_wildCopy(void *dstPtr, const void *srcPtr, void *dstEnd) { … } static FORCE_INLINE unsigned int LZ4_NbCommonBytes(register size_t val) { … } static FORCE_INLINE unsigned int LZ4_count( const BYTE *pIn, const BYTE *pMatch, const BYTE *pInLimit) { … } limitedOutput_directive; tableType_t; dict_directive; dictIssue_directive; endCondition_directive; earlyEnd_directive; #define LZ4_STATIC_ASSERT(c) … #endif