14 #include <linux/module.h>
15 #include <linux/kernel.h>
17 #include <asm/unaligned.h>
21 _lzo1x_1_do_compress(
const unsigned char *
in,
size_t in_len,
22 unsigned char *
out,
size_t *
out_len,
void *wrkmem)
24 const unsigned char *
const in_end = in +
in_len;
25 const unsigned char *
const ip_end = in + in_len -
M2_MAX_LEN - 5;
26 const unsigned char **
const dict = wrkmem;
27 const unsigned char *
ip =
in, *ii =
ip;
28 const unsigned char *
end, *
m, *m_pos;
29 size_t m_off, m_len, dindex;
30 unsigned char *
op =
out;
66 if (
likely(m_pos[2] == ip[2]))
102 if (m_pos[3] != *ip++ || m_pos[4] != *ip++
103 || m_pos[5] != *ip++ || m_pos[6] != *ip++
104 || m_pos[7] != *ip++ || m_pos[8] != *ip++) {
110 *op++ = (((m_len - 1) << 5)
111 | ((m_off & 7) << 2));
112 *op++ = (m_off >> 3);
120 *op++ = (
M4_MARKER | ((m_off & 0x4000) >> 11)
126 m = m_pos + M2_MAX_LEN + 1;
128 while (ip < end && *m == *ip) {
147 | ((m_off & 0x4000) >> 11)
152 | ((m_off & 0x4000) >> 11));
154 while (m_len > 255) {
163 *op++ = ((m_off & 63) << 2);
164 *op++ = (m_off >> 6);
177 size_t *out_len,
void *wrkmem)
179 const unsigned char *ii;
180 unsigned char *op =
out;
183 if (
unlikely(in_len <= M2_MAX_LEN + 5)) {
186 t = _lzo1x_1_do_compress(in, in_len, op, out_len, wrkmem);
191 ii = in + in_len -
t;
193 if (op == out && t <= 238) {
197 }
else if (t <= 18) {