1 diff -Nurp kernel-2.6.28-20094102.3+0m5/crypto/lzo.c kernel-2.6.28-20094102.6+0m5/crypto/lzo.c
2 --- kernel-2.6.28-20094102.3+0m5/crypto/lzo.c 2008-12-25 00:26:37.000000000 +0100
3 +++ kernel-2.6.28-20094102.6+0m5/crypto/lzo.c 2011-09-04 11:36:23.000000000 +0200
4 @@ -37,6 +37,17 @@ static int lzo_init(struct crypto_tfm *t
8 +static int lzo999_init(struct crypto_tfm *tfm)
10 + struct lzo_ctx *ctx = crypto_tfm_ctx(tfm);
12 + ctx->lzo_comp_mem = vmalloc(LZO1X_999_MEM_COMPRESS);
13 + if (!ctx->lzo_comp_mem)
19 static void lzo_exit(struct crypto_tfm *tfm)
21 struct lzo_ctx *ctx = crypto_tfm_ctx(tfm);
22 @@ -60,6 +71,24 @@ static int lzo_compress(struct crypto_tf
26 +static int lzo999_compress(struct crypto_tfm *tfm, const u8 *src,
27 + unsigned int slen, u8 *dst, unsigned int *dlen)
29 + struct lzo_ctx *ctx = crypto_tfm_ctx(tfm);
30 + size_t tmp_len = *dlen; /* size_t(ulong) <-> uint on 64 bit */
33 + err = lzo1x_999_compress_level(src, slen, dst, &tmp_len,
34 + ctx->lzo_comp_mem, NULL, 0 ,
35 + (lzo_progress_callback_t) 0, 7);
37 + if (err != LZO_E_OK)
44 static int lzo_decompress(struct crypto_tfm *tfm, const u8 *src,
45 unsigned int slen, u8 *dst, unsigned int *dlen)
47 @@ -89,13 +118,37 @@ static struct crypto_alg alg = {
48 .coa_decompress = lzo_decompress } }
51 +static struct crypto_alg alg999 = {
52 + .cra_name = "lzo999",
53 + .cra_flags = CRYPTO_ALG_TYPE_COMPRESS,
54 + .cra_ctxsize = sizeof(struct lzo_ctx),
55 + .cra_module = THIS_MODULE,
56 + .cra_list = LIST_HEAD_INIT(alg999.cra_list),
57 + .cra_init = lzo999_init,
58 + .cra_exit = lzo_exit,
59 + .cra_u = { .compress = {
60 + .coa_compress = lzo999_compress,
61 + .coa_decompress = lzo_decompress } }
64 static int __init lzo_mod_init(void)
66 - return crypto_register_alg(&alg);
69 + ret = crypto_register_alg(&alg);
73 + ret = crypto_register_alg(&alg999);
75 + crypto_unregister_alg(&alg);
80 static void __exit lzo_mod_fini(void)
82 + crypto_unregister_alg(&alg999);
83 crypto_unregister_alg(&alg);
86 diff -Nurp kernel-2.6.28-20094102.3+0m5/fs/ubifs/compress.c kernel-2.6.28-20094102.6+0m5/fs/ubifs/compress.c
87 --- kernel-2.6.28-20094102.3+0m5/fs/ubifs/compress.c 2011-09-04 11:34:12.000000000 +0200
88 +++ kernel-2.6.28-20094102.6+0m5/fs/ubifs/compress.c 2011-09-04 11:36:23.000000000 +0200
89 @@ -46,11 +46,24 @@ static struct ubifs_compressor lzo_compr
94 +static DEFINE_MUTEX(lzo999_mutex);
96 +static struct ubifs_compressor lzo999_compr = {
97 + .compr_type = UBIFS_COMPR_LZO999,
98 + .comp_mutex = &lzo999_mutex,
100 + .capi_name = "lzo999",
103 static struct ubifs_compressor lzo_compr = {
104 .compr_type = UBIFS_COMPR_LZO,
107 +static struct ubifs_compressor lzo_compr = {
108 + .compr_type = UBIFS_COMPR_LZO999,
113 #ifdef CONFIG_UBIFS_FS_ZLIB
114 @@ -125,6 +138,9 @@ void ubifs_compress(const void *in_buf,
115 if (in_len - *out_len < UBIFS_MIN_COMPRESS_DIFF)
118 + if (*compr_type == UBIFS_COMPR_LZO999)
119 + *compr_type = UBIFS_COMPR_LZO;
124 @@ -229,13 +245,19 @@ int __init ubifs_compressors_init(void)
128 - err = compr_init(&zlib_compr);
129 + err = compr_init(&lzo999_compr);
133 + err = compr_init(&zlib_compr);
137 ubifs_compressors[UBIFS_COMPR_NONE] = &none_compr;
141 + compr_exit(&lzo999_compr);
143 compr_exit(&lzo_compr);
145 @@ -246,6 +268,7 @@ out_lzo:
147 void ubifs_compressors_exit(void)
149 + compr_exit(&lzo999_compr);
150 compr_exit(&lzo_compr);
151 compr_exit(&zlib_compr);
153 diff -Nurp kernel-2.6.28-20094102.3+0m5/fs/ubifs/journal.c kernel-2.6.28-20094102.6+0m5/fs/ubifs/journal.c
154 --- kernel-2.6.28-20094102.3+0m5/fs/ubifs/journal.c 2011-09-04 11:34:12.000000000 +0200
155 +++ kernel-2.6.28-20094102.6+0m5/fs/ubifs/journal.c 2011-09-04 11:36:23.000000000 +0200
156 @@ -469,7 +469,10 @@ static void pack_inode(struct ubifs_info
157 ino->flags = cpu_to_le32(ui->flags);
158 ino->size = cpu_to_le64(ui->ui_size);
159 ino->nlink = cpu_to_le32(inode->i_nlink);
160 - ino->compr_type = cpu_to_le16(ui->compr_type);
161 + if (ui->compr_type == UBIFS_COMPR_LZO999)
162 + ino->compr_type = cpu_to_le16(UBIFS_COMPR_LZO);
164 + ino->compr_type = cpu_to_le16(ui->compr_type);
165 ino->data_len = cpu_to_le32(ui->data_len);
166 ino->xattr_cnt = cpu_to_le32(ui->xattr_cnt);
167 ino->xattr_size = cpu_to_le32(ui->xattr_size);
168 diff -Nurp kernel-2.6.28-20094102.3+0m5/fs/ubifs/sb.c kernel-2.6.28-20094102.6+0m5/fs/ubifs/sb.c
169 --- kernel-2.6.28-20094102.3+0m5/fs/ubifs/sb.c 2011-09-04 11:34:12.000000000 +0200
170 +++ kernel-2.6.28-20094102.6+0m5/fs/ubifs/sb.c 2011-09-04 11:36:23.000000000 +0200
171 @@ -181,9 +181,12 @@ static int create_default_filesystem(str
172 sup->lsave_cnt = cpu_to_le32(c->lsave_cnt);
173 sup->fmt_version = cpu_to_le32(UBIFS_FORMAT_VERSION);
174 sup->time_gran = cpu_to_le32(DEFAULT_TIME_GRAN);
175 - if (c->mount_opts.override_compr)
176 - sup->default_compr = cpu_to_le16(c->mount_opts.compr_type);
178 + if (c->mount_opts.override_compr) {
179 + if (c->mount_opts.compr_type == UBIFS_COMPR_LZO999)
180 + sup->default_compr = cpu_to_le16(UBIFS_COMPR_LZO);
182 + sup->default_compr = cpu_to_le16(c->mount_opts.compr_type);
184 sup->default_compr = cpu_to_le16(UBIFS_COMPR_LZO);
186 generate_random_uuid(sup->uuid);
187 diff -Nurp kernel-2.6.28-20094102.3+0m5/fs/ubifs/super.c kernel-2.6.28-20094102.6+0m5/fs/ubifs/super.c
188 --- kernel-2.6.28-20094102.3+0m5/fs/ubifs/super.c 2011-09-04 11:34:12.000000000 +0200
189 +++ kernel-2.6.28-20094102.6+0m5/fs/ubifs/super.c 2011-09-04 11:36:23.000000000 +0200
190 @@ -1001,6 +1001,8 @@ static int ubifs_parse_options(struct ub
191 c->mount_opts.compr_type = UBIFS_COMPR_LZO;
192 else if (!strcmp(name, "zlib"))
193 c->mount_opts.compr_type = UBIFS_COMPR_ZLIB;
194 + else if (!strcmp(name, "lzo999"))
195 + c->mount_opts.compr_type = UBIFS_COMPR_LZO999;
197 ubifs_err("unknown compressor \"%s\"", name);
199 diff -Nurp kernel-2.6.28-20094102.3+0m5/fs/ubifs/ubifs-media.h kernel-2.6.28-20094102.6+0m5/fs/ubifs/ubifs-media.h
200 --- kernel-2.6.28-20094102.3+0m5/fs/ubifs/ubifs-media.h 2011-09-04 11:34:12.000000000 +0200
201 +++ kernel-2.6.28-20094102.6+0m5/fs/ubifs/ubifs-media.h 2011-09-04 11:36:23.000000000 +0200
202 @@ -303,12 +303,14 @@ enum {
203 * UBIFS_COMPR_NONE: no compression
204 * UBIFS_COMPR_LZO: LZO compression
205 * UBIFS_COMPR_ZLIB: ZLIB compression
206 + * UBIFS_COMPR_LZO999: LZO999 compression
207 * UBIFS_COMPR_TYPES_CNT: count of supported compression types
213 + UBIFS_COMPR_LZO999,
214 UBIFS_COMPR_TYPES_CNT,
217 diff -Nurp kernel-2.6.28-20094102.3+0m5/include/linux/lzo.h kernel-2.6.28-20094102.6+0m5/include/linux/lzo.h
218 --- kernel-2.6.28-20094102.3+0m5/include/linux/lzo.h 2008-12-25 00:26:37.000000000 +0100
219 +++ kernel-2.6.28-20094102.6+0m5/include/linux/lzo.h 2011-09-04 11:36:23.000000000 +0200
221 #define LZO1X_MEM_COMPRESS (16384 * sizeof(unsigned char *))
222 #define LZO1X_1_MEM_COMPRESS LZO1X_MEM_COMPRESS
224 +#define LZO1X_999_MEM_COMPRESS ((unsigned) (14 * 16384L * sizeof(short)))
226 #define lzo1x_worst_compress(x) ((x) + ((x) / 16) + 64 + 3)
228 /* This requires 'workmem' of size LZO1X_1_MEM_COMPRESS */
229 @@ -27,6 +29,27 @@ int lzo1x_1_compress(const unsigned char
230 int lzo1x_decompress_safe(const unsigned char *src, size_t src_len,
231 unsigned char *dst, size_t *dst_len);
234 +lzo1x_999_compress ( const unsigned char *src, unsigned src_len,
235 + unsigned char *dst, unsigned * dst_len,
239 +lzo1x_999_compress_dict ( const unsigned char *in , unsigned in_len,
240 + unsigned char *out, unsigned * out_len,
242 + const unsigned char *dict, unsigned dict_len );
244 +typedef void ( *lzo_progress_callback_t) (unsigned, unsigned);
247 +lzo1x_999_compress_level ( const unsigned char *in , unsigned in_len,
248 + unsigned char *out, unsigned * out_len,
250 + const unsigned char *dict, unsigned dict_len,
251 + lzo_progress_callback_t cb,
252 + int compression_level );
255 * Return values (< 0 = Error)
257 diff -Nurp kernel-2.6.28-20094102.3+0m5/lib/lzo/lzo1x_9x.c kernel-2.6.28-20094102.6+0m5/lib/lzo/lzo1x_9x.c
258 --- kernel-2.6.28-20094102.3+0m5/lib/lzo/lzo1x_9x.c 1970-01-01 01:00:00.000000000 +0100
259 +++ kernel-2.6.28-20094102.6+0m5/lib/lzo/lzo1x_9x.c 2011-09-04 11:36:23.000000000 +0200
261 +/* lzo1x_9x.c -- implementation of the LZO1X-999 compression algorithm
263 + This file is part of the LZO real-time data compression library.
265 + Copyright (C) 1996-2002 Markus Franz Xaver Johannes Oberhumer
266 + All Rights Reserved.
268 + The LZO library is free software; you can redistribute it and/or
269 + modify it under the terms of version 2 of the GNU General Public
270 + License as published by the Free Software Foundation.
272 + The LZO library is distributed in the hope that it will be useful,
273 + but WITHOUT ANY WARRANTY; without even the implied warranty of
274 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
275 + GNU General Public License for more details.
277 + You should have received a copy of the GNU General Public License
278 + along with the LZO library; see the file COPYING.
279 + If not, write to the Free Software Foundation, Inc.,
280 + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
282 + Markus F.X.J. Oberhumer
283 + <markus@oberhumer.com>
286 +#include <linux/module.h>
287 +#include <linux/string.h>
289 +typedef unsigned int lzo_uint32;
290 +typedef int lzo_int32;
291 +typedef unsigned int lzo_uint;
292 +typedef int lzo_int;
293 +typedef int lzo_bool;
295 +typedef void ( *lzo_progress_callback_t) (unsigned, unsigned);
306 + lzo_uint last_m_len;
307 + lzo_uint last_m_off;
309 + const unsigned char *bp;
310 + const unsigned char *ip;
311 + const unsigned char *in;
312 + const unsigned char *in_end;
313 + unsigned char *out;
315 + lzo_progress_callback_t cb;
319 + lzo_uint printcount;
322 + unsigned long lit_bytes;
323 + unsigned long match_bytes;
324 + unsigned long rep_bytes;
325 + unsigned long lazy;
330 + unsigned long m1a_m, m1b_m, m2_m, m3_m, m4_m;
331 + unsigned long lit1_r, lit2_r, lit3_r;
335 +typedef unsigned short swd_uint;
341 + lzo_uint threshold;
343 + lzo_uint max_chain;
344 + lzo_uint nice_length;
345 + lzo_bool use_best_off;
346 + lzo_uint lazy_insert;
353 + lzo_uint best_off[ (((8) >= (33) ? ((8) >= (9) ? (8) : (9)) : ((33) >= (9) ? (33) : (9))) + 1) ];
358 + lzo_uint best_pos[ (((8) >= (33) ? ((8) >= (9) ? (8) : (9)) : ((33) >= (9) ? (33) : (9))) + 1) ];
360 + const unsigned char *dict;
361 + const unsigned char *dict_end;
369 + unsigned char *b_wrap;
371 + lzo_uint node_count;
374 + unsigned char b [ 0xbfff + 2048 + 2048 ];
375 + swd_uint head3 [ 16384 ];
376 + swd_uint succ3 [ 0xbfff + 2048 ];
377 + swd_uint best3 [ 0xbfff + 2048 ];
378 + swd_uint llen3 [ 16384 ];
380 + swd_uint head2 [ 65536L ];
385 +void swd_initdict(lzo1x_999_swd_t *s, const unsigned char *dict, lzo_uint dict_len)
387 + s->dict = s->dict_end = ((void *)0);
390 + if (!dict || dict_len <= 0)
392 + if (dict_len > s->n)
394 + dict += dict_len - s->n;
399 + s->dict_len = dict_len;
400 + s->dict_end = dict + dict_len;
401 + memcpy(s->b,dict,dict_len);
407 +void swd_insertdict(lzo1x_999_swd_t *s, lzo_uint node, lzo_uint len)
411 + s->node_count = s->n - len;
412 + s->first_rp = node;
416 + key = (((0x9f5f*(((((lzo_uint32)s->b[node]<<5)^s->b[node+1])<<5)^s->b[node+2]))>>5) & (16384 -1));
417 + s->succ3[node] = s->head3[key];
418 + s->head3[key] = ((swd_uint)(node));
419 + s->best3[node] = ((swd_uint)(s->f + 1));
424 + key = (* (unsigned short *) &(s->b[node]));
425 + s->head2[key] = ((swd_uint)(node));
438 +int swd_init(lzo1x_999_swd_t *s, const unsigned char *dict, lzo_uint dict_len)
448 + s->max_chain = 2048;
449 + s->nice_length = 2048;
450 + s->use_best_off = 0;
451 + s->lazy_insert = 0;
453 + s->b_size = s->n + s->f;
454 + if (2 * s->f >= s->n || s->b_size + s->f >= (32767 * 2 + 1))
456 + s->b_wrap = s->b + s->b_size;
457 + s->node_count = s->n;
459 + memset(s->llen3, 0, sizeof(s->llen3[0]) * 16384);
462 + memset(s->head2, 0xff, sizeof(s->head2[0]) * 65536L);
471 + swd_initdict(s,dict,dict_len);
473 + s->first_rp = s->ip;
477 + s->look = (lzo_uint) (s->c->in_end - s->c->ip);
480 + if (s->look > s->f)
482 + memcpy(&s->b[s->ip],s->c->ip,s->look);
483 + s->c->ip += s->look;
487 + if (s->ip == s->b_size)
490 + if (s->look >= 2 && s->dict_len > 0)
491 + swd_insertdict(s,0,s->dict_len);
493 + s->rp = s->first_rp;
494 + if (s->rp >= s->node_count)
495 + s->rp -= s->node_count;
497 + s->rp += s->b_size - s->node_count;
506 +void swd_exit(lzo1x_999_swd_t *s)
514 +void swd_getbyte(lzo1x_999_swd_t *s)
518 + if ((c = ((*(s->c)).ip < (*(s->c)).in_end ? *((*(s->c)).ip)++ : (-1))) < 0)
531 + s->b[s->ip] = ((unsigned char) ((c) & 0xff));
533 + s->b_wrap[s->ip] = ((unsigned char) ((c) & 0xff));
535 + if (++s->ip == s->b_size)
537 + if (++s->bp == s->b_size)
539 + if (++s->rp == s->b_size)
549 +void swd_remove_node(lzo1x_999_swd_t *s, lzo_uint node)
551 + if (s->node_count == 0)
555 + key = (((0x9f5f*(((((lzo_uint32)s->b[node]<<5)^s->b[node+1])<<5)^s->b[node+2]))>>5) & (16384 -1));
560 + key = (* (unsigned short *) &(s->b[node]));
562 + if ((lzo_uint) s->head2[key] == node)
563 + s->head2[key] = (32767 * 2 + 1);
576 +void swd_accept(lzo1x_999_swd_t *s, lzo_uint n)
584 + swd_remove_node(s,s->rp);
587 + key = (((0x9f5f*(((((lzo_uint32)s->b[s->bp]<<5)^s->b[s->bp+1])<<5)^s->b[s->bp+2]))>>5) & (16384 -1));
588 + s->succ3[s->bp] = s->head3[key];
589 + s->head3[key] = ((swd_uint)(s->bp));
590 + s->best3[s->bp] = ((swd_uint)(s->f + 1));
596 + key = (* (unsigned short *) &(s->b[s->bp]));
597 + s->head2[key] = ((swd_uint)(s->bp));
610 +void swd_search(lzo1x_999_swd_t *s, lzo_uint node, lzo_uint cnt)
617 + const unsigned char *p1;
618 + const unsigned char *p2;
619 + const unsigned char *px;
621 + lzo_uint m_len = s->m_len;
622 + const unsigned char * b = s->b;
623 + const unsigned char * bp = s->b + s->bp;
624 + const unsigned char * bx = s->b + s->bp + s->look;
625 + unsigned char scan_end1;
629 + scan_end1 = bp[m_len - 1];
630 + for ( ; cnt-- > 0; node = s->succ3[node])
640 + p2[m_len - 1] == scan_end1 &&
641 + p2[m_len] == p1[m_len] &&
650 + do {} while (++p1 < px && *p1 == *++p2);
663 + if (i < (((8) >= (33) ? ((8) >= (9) ? (8) : (9)) : ((33) >= (9) ? (33) : (9))) + 1))
665 + if (s->best_pos[i] == 0)
666 + s->best_pos[i] = node + 1;
671 + s->m_len = m_len = i;
673 + if (m_len == s->look)
675 + if (m_len >= s->nice_length)
677 + if (m_len > (lzo_uint) s->best3[node])
679 + scan_end1 = bp[m_len - 1];
686 +lzo_bool swd_search2(lzo1x_999_swd_t *s)
693 + key = s->head2[ (* (unsigned short *) &(s->b[s->bp])) ];
694 + if (key == (32767 * 2 + 1))
703 + if (s->best_pos[2] == 0)
704 + s->best_pos[2] = key + 1;
716 +void swd_findbest(lzo1x_999_swd_t *s)
719 + lzo_uint cnt, node;
725 + key = (((0x9f5f*(((((lzo_uint32)s->b[s->bp]<<5)^s->b[s->bp+1])<<5)^s->b[s->bp+2]))>>5) & (16384 -1));
726 + node = s->succ3[s->bp] = s->head3[key];
727 + cnt = s->llen3[key]++;
729 + if (cnt > s->max_chain && s->max_chain > 0)
730 + cnt = s->max_chain;
731 + s->head3[key] = ((swd_uint)(s->bp));
733 + s->b_char = s->b[s->bp];
735 + if (s->m_len >= s->look)
740 + s->best3[s->bp] = ((swd_uint)(s->f + 1));
745 + if (swd_search2(s))
748 + swd_search(s,node,cnt);
749 + if (s->m_len > len)
750 + s->m_off = (s->bp > (s->m_pos) ? s->bp - (s->m_pos) : s->b_size - ((s->m_pos) - s->bp));
751 + s->best3[s->bp] = ((swd_uint)(s->m_len));
754 + if (s->use_best_off)
757 + for (i = 2; i < (((8) >= (33) ? ((8) >= (9) ? (8) : (9)) : ((33) >= (9) ? (33) : (9))) + 1); i++)
758 + if (s->best_pos[i] > 0)
759 + s->best_off[i] = (s->bp > (s->best_pos[i]-1) ? s->bp - (s->best_pos[i]-1) : s->b_size - ((s->best_pos[i]-1) - s->bp));
761 + s->best_off[i] = 0;
766 + swd_remove_node(s,s->rp);
770 + key = (* (unsigned short *) &(s->b[s->bp]));
771 + s->head2[key] = ((swd_uint)(s->bp));
783 +init_match ( lzo1x_999_t *c, lzo1x_999_swd_t *s,
784 + const unsigned char *dict, lzo_uint dict_len,
794 + c->last_m_len = c->last_m_off = 0;
796 + c->textsize = c->codesize = c->printcount = 0;
797 + c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
800 + r = swd_init(s,dict,dict_len);
804 + s->use_best_off = (flags & 1) ? 1 : 0;
814 +find_match ( lzo1x_999_t *c, lzo1x_999_swd_t *s,
815 + lzo_uint this_len, lzo_uint skip )
822 + swd_accept(s, this_len - skip);
823 + c->textsize += this_len - skip + 1;
828 + c->textsize += this_len - skip;
834 + if (s->use_best_off)
835 + memset(s->best_pos,0,sizeof(s->best_pos));
838 + c->m_len = s->m_len;
839 + c->m_off = s->m_off;
851 + c->look = s->look + 1;
853 + c->bp = c->ip - c->look;
855 + if (c->cb && c->textsize > c->printcount)
857 + (*c->cb)(c->textsize,c->codesize);
858 + c->printcount += 1024;
868 +lzo1x_999_compress_internal ( const unsigned char *in , lzo_uint in_len,
869 + unsigned char *out, lzo_uint * out_len,
871 + const unsigned char *dict, lzo_uint dict_len,
872 + lzo_progress_callback_t cb,
874 + lzo_uint good_length,
876 + lzo_uint nice_length,
877 + lzo_uint max_chain,
878 + lzo_uint32 flags );
885 +static unsigned char *
886 +code_match ( lzo1x_999_t *c, unsigned char *op, lzo_uint m_len, lzo_uint m_off )
888 + lzo_uint x_len = m_len;
889 + lzo_uint x_off = m_off;
891 + c->match_bytes += m_len;
897 + ((void) (0)); ((void) (0));
903 + *op++ = ((unsigned char) ((0 | ((m_off & 3) << 2)) & 0xff));
904 + *op++ = ((unsigned char) ((m_off >> 2) & 0xff));
911 + else if (m_len <= 8 && m_off <= 0x0800)
917 + *op++ = ((unsigned char) ((((m_len - 1) << 5) | ((m_off & 7) << 2)) & 0xff));
918 + *op++ = ((unsigned char) ((m_off >> 3) & 0xff));
923 + else if (m_len == 3 && m_off <= (0x0400 + 0x0800) && c->r1_lit >= 4)
927 + m_off -= 1 + 0x0800;
932 + *op++ = ((unsigned char) ((0 | ((m_off & 3) << 2)) & 0xff));
933 + *op++ = ((unsigned char) ((m_off >> 2) & 0xff));
937 + else if (m_off <= 0x4000)
942 + *op++ = ((unsigned char) ((32 | (m_len - 2)) & 0xff));
947 + while (m_len > 255)
953 + *op++ = ((unsigned char) ((m_len) & 0xff));
959 + *op++ = ((unsigned char) ((m_off << 2) & 0xff));
960 + *op++ = ((unsigned char) ((m_off >> 6) & 0xff));
969 + ((void) (0)); ((void) (0));
971 + k = (m_off & 0x4000) >> 11;
973 + *op++ = ((unsigned char) ((16 | k | (m_len - 2)) & 0xff));
977 + *op++ = ((unsigned char) ((16 | k | 0) & 0xff));
978 + while (m_len > 255)
984 + *op++ = ((unsigned char) ((m_len) & 0xff));
990 + *op++ = ((unsigned char) ((m_off << 2) & 0xff));
991 + *op++ = ((unsigned char) ((m_off >> 6) & 0xff));
996 + c->last_m_len = x_len;
997 + c->last_m_off = x_off;
1002 +static unsigned char *
1003 +STORE_RUN ( lzo1x_999_t *c, unsigned char *op, const unsigned char *ii, lzo_uint t )
1005 + c->lit_bytes += t;
1007 + if (op == c->out && t <= 238)
1009 + *op++ = ((unsigned char) ((17 + t) & 0xff));
1016 + op[-2] |= ((unsigned char) ((t) & 0xff));
1022 + *op++ = ((unsigned char) ((t - 3) & 0xff));
1027 + lzo_uint tt = t - 18;
1036 + *op++ = ((unsigned char) ((tt) & 0xff));
1039 + do *op++ = *ii++; while (--t > 0);
1045 +static unsigned char *
1046 +code_run ( lzo1x_999_t *c, unsigned char *op, const unsigned char *ii,
1047 + lzo_uint lit, lzo_uint m_len )
1052 + op = STORE_RUN(c,op,ii,lit);
1053 + c->r1_m_len = m_len;
1072 +len_of_coded_match ( lzo_uint m_len, lzo_uint m_off, lzo_uint lit )
1079 + return (m_off <= 0x0400 && lit > 0 && lit < 4) ? 2 : -1;
1080 + if (m_len <= 8 && m_off <= 0x0800)
1082 + if (m_len == 3 && m_off <= (0x0400 + 0x0800) && lit >= 4)
1084 + if (m_off <= 0x4000)
1089 + while (m_len > 255)
1096 + if (m_off <= 0xbfff)
1101 + while (m_len > 255)
1113 +min_gain(lzo_uint ahead, lzo_uint lit1, lzo_uint lit2, int l1, int l2, int l3)
1115 + lzo_int lazy_match_min_gain = 0;
1118 + lazy_match_min_gain += ahead;
1126 + lazy_match_min_gain += (lit2 <= 3) ? 0 : 2;
1127 + else if (lit1 <= 18)
1128 + lazy_match_min_gain += (lit2 <= 18) ? 0 : 1;
1130 + lazy_match_min_gain += (l2 - l1) * 2;
1132 + lazy_match_min_gain -= (ahead - l3) * 2;
1134 + if (lazy_match_min_gain < 0)
1135 + lazy_match_min_gain = 0;
1143 + return lazy_match_min_gain;
1147 +better_match ( const lzo1x_999_swd_t *swd, lzo_uint *m_len, lzo_uint *m_off )
1156 + if (*m_off <= 0x0800)
1161 + if (*m_off > 0x0800 &&
1162 + *m_len >= 3 + 1 && *m_len <= 8 + 1 &&
1163 + swd->best_off[*m_len-1] && swd->best_off[*m_len-1] <= 0x0800)
1165 + *m_len = *m_len - 1;
1166 + *m_off = swd->best_off[*m_len];
1173 + if (*m_off > 0x4000 &&
1174 + *m_len >= 9 + 1 && *m_len <= 8 + 2 &&
1175 + swd->best_off[*m_len-2] && swd->best_off[*m_len-2] <= 0x0800)
1177 + *m_len = *m_len - 2;
1178 + *m_off = swd->best_off[*m_len];
1185 + if (*m_off > 0x4000 &&
1186 + *m_len >= 9 + 1 && *m_len <= 33 + 1 &&
1187 + swd->best_off[*m_len-1] && swd->best_off[*m_len-1] <= 0x4000)
1189 + *m_len = *m_len - 1;
1190 + *m_off = swd->best_off[*m_len];
1196 +lzo1x_999_compress_internal ( const unsigned char *in , lzo_uint in_len,
1197 + unsigned char *out, lzo_uint * out_len,
1199 + const unsigned char *dict, lzo_uint dict_len,
1200 + lzo_progress_callback_t cb,
1202 + lzo_uint good_length,
1203 + lzo_uint max_lazy,
1204 + lzo_uint nice_length,
1205 + lzo_uint max_chain,
1206 + lzo_uint32 flags )
1208 + unsigned char *op;
1209 + const unsigned char *ii;
1211 + lzo_uint m_len, m_off;
1213 + lzo1x_999_t * const c = &cc;
1214 + lzo1x_999_swd_t * const swd = (lzo1x_999_swd_t *) wrkmem;
1223 + if (!(((lzo_uint32) (14 * 16384L * sizeof(short))) >= ((lzo_uint) (sizeof(lzo1x_999_swd_t)))))
1231 + if (good_length <= 0)
1234 + if (max_lazy <= 0)
1237 + if (nice_length <= 0)
1240 + if (max_chain <= 0)
1244 + c->ip = c->in = in;
1245 + c->in_end = in + in_len;
1248 + c->m1a_m = c->m1b_m = c->m2_m = c->m3_m = c->m4_m = 0;
1249 + c->lit1_r = c->lit2_r = c->lit3_r = 0;
1254 + c->r1_lit = c->r1_m_len = 0;
1256 + r = init_match(c,swd,dict,dict_len,flags);
1259 + if (max_chain > 0)
1260 + swd->max_chain = max_chain;
1261 + if (nice_length > 0)
1262 + swd->nice_length = nice_length;
1264 + r = find_match(c,swd,0,0);
1267 + while (c->look > 0)
1270 + lzo_uint max_ahead;
1273 + c->codesize = op - out;
1286 + (m_len == 2 && (m_off > 0x0400 || lit == 0 || lit >= 4)) ||
1292 + (m_len == 2 && op == out) ||
1294 + (op == out && lit == 0))
1299 + else if (m_len == 3)
1302 + if (m_off > (0x0400 + 0x0800) && lit >= 4)
1310 + swd->max_chain = max_chain;
1311 + r = find_match(c,swd,1,0);
1318 + if (swd->use_best_off)
1319 + better_match(swd,&m_len,&m_off);
1327 + if (try_lazy <= 0 || m_len >= max_lazy)
1336 + l1 = len_of_coded_match(m_len,m_off,lit);
1339 + max_ahead = ((try_lazy) <= (l1 - 1) ? (try_lazy) : (l1 - 1));
1346 + while (ahead < max_ahead && c->look > m_len)
1348 + lzo_int lazy_match_min_gain;
1350 + if (m_len >= good_length)
1351 + swd->max_chain = max_chain >> 2;
1353 + swd->max_chain = max_chain;
1354 + r = find_match(c,swd,1,0);
1366 + if (c->m_len < m_len)
1369 + if (c->m_len == m_len && c->m_off >= m_off)
1373 + if (swd->use_best_off)
1374 + better_match(swd,&c->m_len,&c->m_off);
1376 + l2 = len_of_coded_match(c->m_len,c->m_off,lit+ahead);
1380 + l3 = (op == out) ? -1 : len_of_coded_match(ahead,m_off,lit);
1385 + lazy_match_min_gain = min_gain(ahead,lit,lit+ahead,l1,l2,l3);
1386 + if (c->m_len >= m_len + lazy_match_min_gain)
1394 + op = code_run(c,op,ii,lit,ahead);
1397 + op = code_match(c,op,ahead,m_off);
1404 + goto lazy_match_done;
1412 + op = code_run(c,op,ii,lit,m_len);
1416 + op = code_match(c,op,m_len,m_off);
1417 + swd->max_chain = max_chain;
1418 + r = find_match(c,swd,m_len,1+ahead);
1427 + op = STORE_RUN(c,op,ii,lit);
1435 + c->codesize = op - out;
1438 + *out_len = op - out;
1441 + (*c->cb)(c->textsize,c->codesize);
1460 +lzo1x_999_compress_level ( const unsigned char *in , unsigned in_len,
1461 + unsigned char *out, unsigned * out_len,
1463 + const unsigned char *dict, unsigned dict_len,
1464 + lzo_progress_callback_t cb,
1465 + int compression_level )
1467 + static const struct
1470 + lzo_uint good_length;
1471 + lzo_uint max_lazy;
1472 + lzo_uint nice_length;
1473 + lzo_uint max_chain;
1476 + { 0, 0, 0, 8, 4, 0 },
1477 + { 0, 0, 0, 16, 8, 0 },
1478 + { 0, 0, 0, 32, 16, 0 },
1480 + { 1, 4, 4, 16, 16, 0 },
1481 + { 1, 8, 16, 32, 32, 0 },
1482 + { 1, 8, 16, 128, 128, 0 },
1484 + { 2, 8, 32, 128, 256, 0 },
1485 + { 2, 32, 128, 2048, 2048, 1 },
1486 + { 2, 2048, 2048, 2048, 4096, 1 }
1489 + if (compression_level < 1 || compression_level > 9)
1492 + compression_level -= 1;
1493 + return lzo1x_999_compress_internal(in, in_len, out, out_len, wrkmem,
1494 + dict, dict_len, cb,
1495 + c[compression_level].try_lazy,
1496 + c[compression_level].good_length,
1497 + c[compression_level].max_lazy,
1503 + c[compression_level].max_chain,
1504 + c[compression_level].flags);
1506 +EXPORT_SYMBOL_GPL(lzo1x_999_compress_level);
1513 +lzo1x_999_compress_dict ( const unsigned char *in , unsigned in_len,
1514 + unsigned char *out, unsigned * out_len,
1516 + const unsigned char *dict, unsigned dict_len )
1518 + return lzo1x_999_compress_level(in, in_len, out, out_len, wrkmem,
1519 + dict, dict_len, 0, 8);
1521 +EXPORT_SYMBOL_GPL(lzo1x_999_compress_dict);
1524 +lzo1x_999_compress ( const unsigned char *in , unsigned in_len,
1525 + unsigned char *out, unsigned * out_len,
1528 + return lzo1x_999_compress_level(in, in_len, out, out_len, wrkmem,
1529 + ((void *)0), 0, 0, 8);
1531 +EXPORT_SYMBOL_GPL(lzo1x_999_compress);
1533 diff -Nurp kernel-2.6.28-20094102.3+0m5/lib/lzo/Makefile kernel-2.6.28-20094102.6+0m5/lib/lzo/Makefile
1534 --- kernel-2.6.28-20094102.3+0m5/lib/lzo/Makefile 2008-12-25 00:26:37.000000000 +0100
1535 +++ kernel-2.6.28-20094102.6+0m5/lib/lzo/Makefile 2011-09-04 11:36:23.000000000 +0200
1537 -lzo_compress-objs := lzo1x_compress.o
1538 +lzo_compress-objs := lzo1x_compress.o lzo1x_9x.o
1539 lzo_decompress-objs := lzo1x_decompress.o
1541 obj-$(CONFIG_LZO_COMPRESS) += lzo_compress.o