/*
* LZ4 - Fast LZ compression algorithm
* Header File
* Copyright (C) 2011-2013, 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
* 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://fastcompression.blogspot.com/p/lz4.html
* - LZ4 source repository : http://code.google.com/p/lz4/
*/
#include "fsys_zfs.h"
#include <string.h>
int isize, int maxOutputSize);
int
{
src[3];
/* invalid compressed buffer size encoded at start */
return (1);
/*
* Returns 0 on success (decompression function returned non-negative)
* and non-zero on failure (decompression function returned negative).
*/
d_len) < 0);
}
/*
* CPU Feature Detection
*/
/* 32 or 64 bits ? */
#else
#define LZ4_ARCH64 0
#endif
/*
* Little Endian or Big Endian?
* Note: overwrite the below #define if you know your architecture endianess.
*/
#if (defined(__BIG_ENDIAN__) || defined(__BIG_ENDIAN) || \
#else
/*
* Little Endian assumed. PDP Endian and other very rare endian format
* are unsupported.
*/
#endif
/*
* Compiler Options
*/
/* "restrict" is a known keyword */
#else
/* Disable restrict */
#define restrict
#endif
| (((x) & 0xffu) << 8)))
#else
#endif
/* Basic types */
typedef struct _U16_S {
U16 v;
} U16_S;
typedef struct _U32_S {
U32 v;
} U32_S;
typedef struct _U64_S {
U64 v;
} U64_S;
/*
* Constants
*/
/*
* Architecture-specific macros
*/
#if LZ4_ARCH64
#else
#endif
#if (defined(LZ4_BIG_ENDIAN) && !defined(BIG_ENDIAN_NATIVE_BUT_INCOMPATIBLE))
#define LZ4_READ_LITTLEENDIAN_16(d, s, p) \
#define LZ4_WRITE_LITTLEENDIAN_16(p, i) \
#else
#endif
/* Macros */
/* Decompression functions */
static int
{
/* Local Variables */
/* Main Loop */
int length;
/* get runlength */
int s = 255;
s = *ip++;
length += s;
}
}
/* copy literals */
/* CORNER-CASE: cpy might overflow. */
goto _output_error; /* cpy was overflowed, bail! */
/*
* Error: request to write beyond destination
* buffer.
*/
goto _output_error;
/*
* Error : request to read beyond source
* buffer.
*/
goto _output_error;
/* Error : LZ4 format violation */
goto _output_error;
/* Necessarily EOF, due to parsing restrictions. */
break;
}
/* get offset */
ip += 2;
/*
* Error: offset creates reference outside of
* destination buffer.
*/
goto _output_error;
/* get matchlength */
int s = *ip++;
length += s;
if (s == 255)
continue;
break;
}
}
/* copy repeated sequence */
#if LZ4_ARCH64
#else
const int dec2 = 0;
#endif
} else {
}
/*
* Error: request to write outside of
* destination buffer.
*/
goto _output_error;
/*
* Check EOF (should never happen, since last
* 5 bytes are supposed to be literals).
*/
break;
continue;
}
}
/* end of decoding */
/* write overflow error detected */
}