369bc1feb65c44b76684e649c52d839862d9f1ce
[openwrt.git] / package / compcache / patches / 000-provide_lzo_kmod.patch
1 diff -uNr compcache-org/Makefile compcache-0.6.2/Makefile
2 --- compcache-org/Makefile      2010-01-24 17:46:50.000000000 +0100
3 +++ compcache-0.6.2/Makefile    2010-03-18 16:00:41.000000000 +0100
4 @@ -1,14 +1,17 @@
5  KERNEL_BUILD_PATH ?= "/lib/modules/$(shell uname -r)/build"
6  
7  XVM = sub-projects/allocators/xvmalloc-kmod
8 +LZO = sub-projects/compression/lzo-kmod
9  EXTRA_CFLAGS   :=      -DCONFIG_RAMZSWAP_STATS         \
10                         -Wall
11  
12 -obj-m          +=      ramzswap.o
13 +obj-m          +=      ramzswap.o $(LZO)/lzo1x.o
14  ramzswap-objs  :=      ramzswap_drv.o $(XVM)/xvmalloc.o
15 +                       
16  
17  all:
18         make -C $(KERNEL_BUILD_PATH) M=$(PWD) modules
19 +       make -C $(KERNEL_BUILD_PATH) M=$(PWD)/$(LZO) modules
20         make -C sub-projects/rzscontrol
21  
22  doc:
23 @@ -16,5 +19,6 @@
24  
25  clean:
26         make -C $(KERNEL_BUILD_PATH) M=$(PWD) clean
27 +       make -C $(KERNEL_BUILD_PATH) M=$(PWD)/$(LZO) clean
28         make -C sub-projects/rzscontrol clean
29         @rm -rf *.ko
30 diff -uNr compcache-org/ramzswap_drv.c compcache-0.6.2/ramzswap_drv.c
31 --- compcache-org/ramzswap_drv.c        2010-01-24 17:52:19.000000000 +0100
32 +++ compcache-0.6.2/ramzswap_drv.c      2010-03-18 16:03:23.000000000 +0100
33 @@ -23,13 +23,13 @@
34  #include <linux/device.h>
35  #include <linux/genhd.h>
36  #include <linux/highmem.h>
37 -#include <linux/lzo.h>
38  #include <linux/string.h>
39  #include <linux/swap.h>
40  #include <linux/swapops.h>
41  #include <linux/vmalloc.h>
42  #include <linux/version.h>
43  
44 +#include "lzo.h"
45  #include "compat.h"
46  #include "ramzswap_drv.h"
47  
48 diff -uNr compcache-old/sub-projects/compression/lzo-kmod/lzo1x.c compcache/sub-projects/compression/lzo-kmod/lzo1x.c
49 --- compcache-old/sub-projects/compression/lzo-kmod/lzo1x.c     1970-01-01 01:00:00.000000000 +0100
50 +++ compcache/sub-projects/compression/lzo-kmod/lzo1x.c 2009-10-17 09:35:59.000000000 +0200
51 @@ -0,0 +1,7 @@
52 +#include <linux/module.h>
53 +
54 +#include "lzo1x_compress.c"
55 +#include "lzo1x_decompress.c"
56 +
57 +MODULE_LICENSE("GPL");
58 +MODULE_DESCRIPTION("LZO1X Lib");
59 diff -uNr compcache-old/sub-projects/compression/lzo-kmod/lzo1x_compress.c compcache/sub-projects/compression/lzo-kmod/lzo1x_compress.c
60 --- compcache-old/sub-projects/compression/lzo-kmod/lzo1x_compress.c    1970-01-01 01:00:00.000000000 +0100
61 +++ compcache/sub-projects/compression/lzo-kmod/lzo1x_compress.c        2009-10-17 09:35:59.000000000 +0200
62 @@ -0,0 +1,227 @@
63 +/*
64 + *  LZO1X Compressor from MiniLZO
65 + *
66 + *  Copyright (C) 1996-2005 Markus F.X.J. Oberhumer <markus@oberhumer.com>
67 + *
68 + *  The full LZO package can be found at:
69 + *  http://www.oberhumer.com/opensource/lzo/
70 + *
71 + *  Changed for kernel use by:
72 + *  Nitin Gupta <nitingupta910@gmail.com>
73 + *  Richard Purdie <rpurdie@openedhand.com>
74 + */
75 +
76 +#include <linux/module.h>
77 +#include <linux/kernel.h>
78 +#include <asm/unaligned.h>
79 +
80 +#include "lzodefs.h"
81 +#include "lzo.h"
82 +
83 +static noinline size_t
84 +_lzo1x_1_do_compress(const unsigned char *in, size_t in_len,
85 +               unsigned char *out, size_t *out_len, void *wrkmem)
86 +{
87 +       const unsigned char * const in_end = in + in_len;
88 +       const unsigned char * const ip_end = in + in_len - M2_MAX_LEN - 5;
89 +       const unsigned char ** const dict = wrkmem;
90 +       const unsigned char *ip = in, *ii = ip;
91 +       const unsigned char *end, *m, *m_pos;
92 +       size_t m_off, m_len, dindex;
93 +       unsigned char *op = out;
94 +
95 +       ip += 4;
96 +
97 +       for (;;) {
98 +               dindex = ((size_t)(0x21 * DX3(ip, 5, 5, 6)) >> 5) & D_MASK;
99 +               m_pos = dict[dindex];
100 +
101 +               if (m_pos < in)
102 +                       goto literal;
103 +
104 +               if (ip == m_pos || ((size_t)(ip - m_pos) > M4_MAX_OFFSET))
105 +                       goto literal;
106 +
107 +               m_off = ip - m_pos;
108 +               if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3])
109 +                       goto try_match;
110 +
111 +               dindex = (dindex & (D_MASK & 0x7ff)) ^ (D_HIGH | 0x1f);
112 +               m_pos = dict[dindex];
113 +
114 +               if (m_pos < in)
115 +                       goto literal;
116 +
117 +               if (ip == m_pos || ((size_t)(ip - m_pos) > M4_MAX_OFFSET))
118 +                       goto literal;
119 +
120 +               m_off = ip - m_pos;
121 +               if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3])
122 +                       goto try_match;
123 +
124 +               goto literal;
125 +
126 +try_match:
127 +               if (get_unaligned((const unsigned short *)m_pos)
128 +                               == get_unaligned((const unsigned short *)ip)) {
129 +                       if (likely(m_pos[2] == ip[2]))
130 +                                       goto match;
131 +               }
132 +
133 +literal:
134 +               dict[dindex] = ip;
135 +               ++ip;
136 +               if (unlikely(ip >= ip_end))
137 +                       break;
138 +               continue;
139 +
140 +match:
141 +               dict[dindex] = ip;
142 +               if (ip != ii) {
143 +                       size_t t = ip - ii;
144 +
145 +                       if (t <= 3) {
146 +                               op[-2] |= t;
147 +                       } else if (t <= 18) {
148 +                               *op++ = (t - 3);
149 +                       } else {
150 +                               size_t tt = t - 18;
151 +
152 +                               *op++ = 0;
153 +                               while (tt > 255) {
154 +                                       tt -= 255;
155 +                                       *op++ = 0;
156 +                               }
157 +                               *op++ = tt;
158 +                       }
159 +                       do {
160 +                               *op++ = *ii++;
161 +                       } while (--t > 0);
162 +               }
163 +
164 +               ip += 3;
165 +               if (m_pos[3] != *ip++ || m_pos[4] != *ip++
166 +                               || m_pos[5] != *ip++ || m_pos[6] != *ip++
167 +                               || m_pos[7] != *ip++ || m_pos[8] != *ip++) {
168 +                       --ip;
169 +                       m_len = ip - ii;
170 +
171 +                       if (m_off <= M2_MAX_OFFSET) {
172 +                               m_off -= 1;
173 +                               *op++ = (((m_len - 1) << 5)
174 +                                               | ((m_off & 7) << 2));
175 +                               *op++ = (m_off >> 3);
176 +                       } else if (m_off <= M3_MAX_OFFSET) {
177 +                               m_off -= 1;
178 +                               *op++ = (M3_MARKER | (m_len - 2));
179 +                               goto m3_m4_offset;
180 +                       } else {
181 +                               m_off -= 0x4000;
182 +
183 +                               *op++ = (M4_MARKER | ((m_off & 0x4000) >> 11)
184 +                                               | (m_len - 2));
185 +                               goto m3_m4_offset;
186 +                       }
187 +               } else {
188 +                       end = in_end;
189 +                       m = m_pos + M2_MAX_LEN + 1;
190 +
191 +                       while (ip < end && *m == *ip) {
192 +                               m++;
193 +                               ip++;
194 +                       }
195 +                       m_len = ip - ii;
196 +
197 +                       if (m_off <= M3_MAX_OFFSET) {
198 +                               m_off -= 1;
199 +                               if (m_len <= 33) {
200 +                                       *op++ = (M3_MARKER | (m_len - 2));
201 +                               } else {
202 +                                       m_len -= 33;
203 +                                       *op++ = M3_MARKER | 0;
204 +                                       goto m3_m4_len;
205 +                               }
206 +                       } else {
207 +                               m_off -= 0x4000;
208 +                               if (m_len <= M4_MAX_LEN) {
209 +                                       *op++ = (M4_MARKER
210 +                                               | ((m_off & 0x4000) >> 11)
211 +                                               | (m_len - 2));
212 +                               } else {
213 +                                       m_len -= M4_MAX_LEN;
214 +                                       *op++ = (M4_MARKER
215 +                                               | ((m_off & 0x4000) >> 11));
216 +m3_m4_len:
217 +                                       while (m_len > 255) {
218 +                                               m_len -= 255;
219 +                                               *op++ = 0;
220 +                                       }
221 +
222 +                                       *op++ = (m_len);
223 +                               }
224 +                       }
225 +m3_m4_offset:
226 +                       *op++ = ((m_off & 63) << 2);
227 +                       *op++ = (m_off >> 6);
228 +               }
229 +
230 +               ii = ip;
231 +               if (unlikely(ip >= ip_end))
232 +                       break;
233 +       }
234 +
235 +       *out_len = op - out;
236 +       return in_end - ii;
237 +}
238 +
239 +int lzo1x_1_compress(const unsigned char *in, size_t in_len, unsigned char *out,
240 +                       size_t *out_len, void *wrkmem)
241 +{
242 +       const unsigned char *ii;
243 +       unsigned char *op = out;
244 +       size_t t;
245 +
246 +       if (unlikely(in_len <= M2_MAX_LEN + 5)) {
247 +               t = in_len;
248 +       } else {
249 +               t = _lzo1x_1_do_compress(in, in_len, op, out_len, wrkmem);
250 +               op += *out_len;
251 +       }
252 +
253 +       if (t > 0) {
254 +               ii = in + in_len - t;
255 +
256 +               if (op == out && t <= 238) {
257 +                       *op++ = (17 + t);
258 +               } else if (t <= 3) {
259 +                       op[-2] |= t;
260 +               } else if (t <= 18) {
261 +                       *op++ = (t - 3);
262 +               } else {
263 +                       size_t tt = t - 18;
264 +
265 +                       *op++ = 0;
266 +                       while (tt > 255) {
267 +                               tt -= 255;
268 +                               *op++ = 0;
269 +                       }
270 +
271 +                       *op++ = tt;
272 +               }
273 +               do {
274 +                       *op++ = *ii++;
275 +               } while (--t > 0);
276 +       }
277 +
278 +       *op++ = M4_MARKER | 1;
279 +       *op++ = 0;
280 +       *op++ = 0;
281 +
282 +       *out_len = op - out;
283 +       return LZO_E_OK;
284 +}
285 +EXPORT_SYMBOL_GPL(lzo1x_1_compress);
286 +
287 +MODULE_LICENSE("GPL");
288 +MODULE_DESCRIPTION("LZO1X-1 Compressor");
289 +
290 diff -uNr compcache-old/sub-projects/compression/lzo-kmod/lzo1x_decompress.c compcache/sub-projects/compression/lzo-kmod/lzo1x_decompress.c
291 --- compcache-old/sub-projects/compression/lzo-kmod/lzo1x_decompress.c  1970-01-01 01:00:00.000000000 +0100
292 +++ compcache/sub-projects/compression/lzo-kmod/lzo1x_decompress.c      2009-10-17 09:35:59.000000000 +0200
293 @@ -0,0 +1,255 @@
294 +/*
295 + *  LZO1X Decompressor from MiniLZO
296 + *
297 + *  Copyright (C) 1996-2005 Markus F.X.J. Oberhumer <markus@oberhumer.com>
298 + *
299 + *  The full LZO package can be found at:
300 + *  http://www.oberhumer.com/opensource/lzo/
301 + *
302 + *  Changed for kernel use by:
303 + *  Nitin Gupta <nitingupta910@gmail.com>
304 + *  Richard Purdie <rpurdie@openedhand.com>
305 + */
306 +
307 +#include <linux/module.h>
308 +#include <linux/kernel.h>
309 +#include <asm/byteorder.h>
310 +#include <asm/unaligned.h>
311 +
312 +#include "lzodefs.h"
313 +#include "lzo.h"
314 +
315 +#define HAVE_IP(x, ip_end, ip) ((size_t)(ip_end - ip) < (x))
316 +#define HAVE_OP(x, op_end, op) ((size_t)(op_end - op) < (x))
317 +#define HAVE_LB(m_pos, out, op) (m_pos < out || m_pos >= op)
318 +
319 +#define COPY4(dst, src)        \
320 +               put_unaligned(get_unaligned((const u32 *)(src)), (u32 *)(dst))
321 +
322 +int lzo1x_decompress_safe(const unsigned char *in, size_t in_len,
323 +                       unsigned char *out, size_t *out_len)
324 +{
325 +       const unsigned char * const ip_end = in + in_len;
326 +       unsigned char * const op_end = out + *out_len;
327 +       const unsigned char *ip = in, *m_pos;
328 +       unsigned char *op = out;
329 +       size_t t;
330 +
331 +       *out_len = 0;
332 +
333 +       if (*ip > 17) {
334 +               t = *ip++ - 17;
335 +               if (t < 4)
336 +                       goto match_next;
337 +               if (HAVE_OP(t, op_end, op))
338 +                       goto output_overrun;
339 +               if (HAVE_IP(t + 1, ip_end, ip))
340 +                       goto input_overrun;
341 +               do {
342 +                       *op++ = *ip++;
343 +               } while (--t > 0);
344 +               goto first_literal_run;
345 +       }
346 +
347 +       while ((ip < ip_end)) {
348 +               t = *ip++;
349 +               if (t >= 16)
350 +                       goto match;
351 +               if (t == 0) {
352 +                       if (HAVE_IP(1, ip_end, ip))
353 +                               goto input_overrun;
354 +                       while (*ip == 0) {
355 +                               t += 255;
356 +                               ip++;
357 +                               if (HAVE_IP(1, ip_end, ip))
358 +                                       goto input_overrun;
359 +                       }
360 +                       t += 15 + *ip++;
361 +               }
362 +               if (HAVE_OP(t + 3, op_end, op))
363 +                       goto output_overrun;
364 +               if (HAVE_IP(t + 4, ip_end, ip))
365 +                       goto input_overrun;
366 +
367 +               COPY4(op, ip);
368 +               op += 4;
369 +               ip += 4;
370 +               if (--t > 0) {
371 +                       if (t >= 4) {
372 +                               do {
373 +                                       COPY4(op, ip);
374 +                                       op += 4;
375 +                                       ip += 4;
376 +                                       t -= 4;
377 +                               } while (t >= 4);
378 +                               if (t > 0) {
379 +                                       do {
380 +                                               *op++ = *ip++;
381 +                                       } while (--t > 0);
382 +                               }
383 +                       } else {
384 +                               do {
385 +                                       *op++ = *ip++;
386 +                               } while (--t > 0);
387 +                       }
388 +               }
389 +
390 +first_literal_run:
391 +               t = *ip++;
392 +               if (t >= 16)
393 +                       goto match;
394 +               m_pos = op - (1 + M2_MAX_OFFSET);
395 +               m_pos -= t >> 2;
396 +               m_pos -= *ip++ << 2;
397 +
398 +               if (HAVE_LB(m_pos, out, op))
399 +                       goto lookbehind_overrun;
400 +
401 +               if (HAVE_OP(3, op_end, op))
402 +                       goto output_overrun;
403 +               *op++ = *m_pos++;
404 +               *op++ = *m_pos++;
405 +               *op++ = *m_pos;
406 +
407 +               goto match_done;
408 +
409 +               do {
410 +match:
411 +                       if (t >= 64) {
412 +                               m_pos = op - 1;
413 +                               m_pos -= (t >> 2) & 7;
414 +                               m_pos -= *ip++ << 3;
415 +                               t = (t >> 5) - 1;
416 +                               if (HAVE_LB(m_pos, out, op))
417 +                                       goto lookbehind_overrun;
418 +                               if (HAVE_OP(t + 3 - 1, op_end, op))
419 +                                       goto output_overrun;
420 +                               goto copy_match;
421 +                       } else if (t >= 32) {
422 +                               t &= 31;
423 +                               if (t == 0) {
424 +                                       if (HAVE_IP(1, ip_end, ip))
425 +                                               goto input_overrun;
426 +                                       while (*ip == 0) {
427 +                                               t += 255;
428 +                                               ip++;
429 +                                               if (HAVE_IP(1, ip_end, ip))
430 +                                                       goto input_overrun;
431 +                                       }
432 +                                       t += 31 + *ip++;
433 +                               }
434 +                               m_pos = op - 1;
435 +                               m_pos -= le16_to_cpu(get_unaligned(
436 +                                       (const unsigned short *)ip)) >> 2;
437 +                               ip += 2;
438 +                       } else if (t >= 16) {
439 +                               m_pos = op;
440 +                               m_pos -= (t & 8) << 11;
441 +
442 +                               t &= 7;
443 +                               if (t == 0) {
444 +                                       if (HAVE_IP(1, ip_end, ip))
445 +                                               goto input_overrun;
446 +                                       while (*ip == 0) {
447 +                                               t += 255;
448 +                                               ip++;
449 +                                               if (HAVE_IP(1, ip_end, ip))
450 +                                                       goto input_overrun;
451 +                                       }
452 +                                       t += 7 + *ip++;
453 +                               }
454 +                               m_pos -= le16_to_cpu(get_unaligned(
455 +                                       (const unsigned short *)ip)) >> 2;
456 +                               ip += 2;
457 +                               if (m_pos == op)
458 +                                       goto eof_found;
459 +                               m_pos -= 0x4000;
460 +                       } else {
461 +                               m_pos = op - 1;
462 +                               m_pos -= t >> 2;
463 +                               m_pos -= *ip++ << 2;
464 +
465 +                               if (HAVE_LB(m_pos, out, op))
466 +                                       goto lookbehind_overrun;
467 +                               if (HAVE_OP(2, op_end, op))
468 +                                       goto output_overrun;
469 +
470 +                               *op++ = *m_pos++;
471 +                               *op++ = *m_pos;
472 +                               goto match_done;
473 +                       }
474 +
475 +                       if (HAVE_LB(m_pos, out, op))
476 +                               goto lookbehind_overrun;
477 +                       if (HAVE_OP(t + 3 - 1, op_end, op))
478 +                               goto output_overrun;
479 +
480 +                       if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4) {
481 +                               COPY4(op, m_pos);
482 +                               op += 4;
483 +                               m_pos += 4;
484 +                               t -= 4 - (3 - 1);
485 +                               do {
486 +                                       COPY4(op, m_pos);
487 +                                       op += 4;
488 +                                       m_pos += 4;
489 +                                       t -= 4;
490 +                               } while (t >= 4);
491 +                               if (t > 0)
492 +                                       do {
493 +                                               *op++ = *m_pos++;
494 +                                       } while (--t > 0);
495 +                       } else {
496 +copy_match:
497 +                               *op++ = *m_pos++;
498 +                               *op++ = *m_pos++;
499 +                               do {
500 +                                       *op++ = *m_pos++;
501 +                               } while (--t > 0);
502 +                       }
503 +match_done:
504 +                       t = ip[-2] & 3;
505 +                       if (t == 0)
506 +                               break;
507 +match_next:
508 +                       if (HAVE_OP(t, op_end, op))
509 +                               goto output_overrun;
510 +                       if (HAVE_IP(t + 1, ip_end, ip))
511 +                               goto input_overrun;
512 +
513 +                       *op++ = *ip++;
514 +                       if (t > 1) {
515 +                               *op++ = *ip++;
516 +                               if (t > 2)
517 +                                       *op++ = *ip++;
518 +                       }
519 +
520 +                       t = *ip++;
521 +               } while (ip < ip_end);
522 +       }
523 +
524 +       *out_len = op - out;
525 +       return LZO_E_EOF_NOT_FOUND;
526 +
527 +eof_found:
528 +       *out_len = op - out;
529 +       return (ip == ip_end ? LZO_E_OK :
530 +               (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN));
531 +input_overrun:
532 +       *out_len = op - out;
533 +       return LZO_E_INPUT_OVERRUN;
534 +
535 +output_overrun:
536 +       *out_len = op - out;
537 +       return LZO_E_OUTPUT_OVERRUN;
538 +
539 +lookbehind_overrun:
540 +       *out_len = op - out;
541 +       return LZO_E_LOOKBEHIND_OVERRUN;
542 +}
543 +
544 +EXPORT_SYMBOL_GPL(lzo1x_decompress_safe);
545 +
546 +MODULE_LICENSE("GPL");
547 +MODULE_DESCRIPTION("LZO1X Decompressor");
548 +
549 diff -uNr compcache-old/sub-projects/compression/lzo-kmod/lzodefs.h compcache/sub-projects/compression/lzo-kmod/lzodefs.h
550 --- compcache-old/sub-projects/compression/lzo-kmod/lzodefs.h   1970-01-01 01:00:00.000000000 +0100
551 +++ compcache/sub-projects/compression/lzo-kmod/lzodefs.h       2009-10-17 09:35:59.000000000 +0200
552 @@ -0,0 +1,43 @@
553 +/*
554 + *  lzodefs.h -- architecture, OS and compiler specific defines
555 + *
556 + *  Copyright (C) 1996-2005 Markus F.X.J. Oberhumer <markus@oberhumer.com>
557 + *
558 + *  The full LZO package can be found at:
559 + *  http://www.oberhumer.com/opensource/lzo/
560 + *
561 + *  Changed for kernel use by:
562 + *  Nitin Gupta <nitingupta910@gmail.com>
563 + *  Richard Purdie <rpurdie@openedhand.com>
564 + */
565 +
566 +#define LZO_VERSION            0x2020
567 +#define LZO_VERSION_STRING     "2.02"
568 +#define LZO_VERSION_DATE       "Oct 17 2005"
569 +
570 +#define M1_MAX_OFFSET  0x0400
571 +#define M2_MAX_OFFSET  0x0800
572 +#define M3_MAX_OFFSET  0x4000
573 +#define M4_MAX_OFFSET  0xbfff
574 +
575 +#define M1_MIN_LEN     2
576 +#define M1_MAX_LEN     2
577 +#define M2_MIN_LEN     3
578 +#define M2_MAX_LEN     8
579 +#define M3_MIN_LEN     3
580 +#define M3_MAX_LEN     33
581 +#define M4_MIN_LEN     3
582 +#define M4_MAX_LEN     9
583 +
584 +#define M1_MARKER      0
585 +#define M2_MARKER      64
586 +#define M3_MARKER      32
587 +#define M4_MARKER      16
588 +
589 +#define D_BITS         14
590 +#define D_MASK         ((1u << D_BITS) - 1)
591 +#define D_HIGH         ((D_MASK >> 1) + 1)
592 +
593 +#define DX2(p, s1, s2) (((((size_t)((p)[2]) << (s2)) ^ (p)[1]) \
594 +                                                       << (s1)) ^ (p)[0])
595 +#define DX3(p, s1, s2, s3)     ((DX2((p)+1, s2, s3) << (s1)) ^ (p)[0])
596 diff -uNr compcache-old/sub-projects/compression/lzo-kmod/lzo.h compcache/sub-projects/compression/lzo-kmod/lzo.h
597 --- compcache-old/sub-projects/compression/lzo-kmod/lzo.h       1970-01-01 01:00:00.000000000 +0100
598 +++ compcache/sub-projects/compression/lzo-kmod/lzo.h   2009-10-17 09:35:59.000000000 +0200
599 @@ -0,0 +1,44 @@
600 +#ifndef __LZO_H__
601 +#define __LZO_H__
602 +/*
603 + *  LZO Public Kernel Interface
604 + *  A mini subset of the LZO real-time data compression library
605 + *
606 + *  Copyright (C) 1996-2005 Markus F.X.J. Oberhumer <markus@oberhumer.com>
607 + *
608 + *  The full LZO package can be found at:
609 + *  http://www.oberhumer.com/opensource/lzo/
610 + *
611 + *  Changed for kernel use by:
612 + *  Nitin Gupta <nitingupta910@gmail.com>
613 + *  Richard Purdie <rpurdie@openedhand.com>
614 + */
615 +
616 +#define LZO1X_MEM_COMPRESS     (16384 * sizeof(unsigned char *))
617 +#define LZO1X_1_MEM_COMPRESS   LZO1X_MEM_COMPRESS
618 +
619 +#define lzo1x_worst_compress(x) ((x) + ((x) / 16) + 64 + 3)
620 +
621 +/* This requires 'workmem' of size LZO1X_1_MEM_COMPRESS */
622 +int lzo1x_1_compress(const unsigned char *src, size_t src_len,
623 +                       unsigned char *dst, size_t *dst_len, void *wrkmem);
624 +
625 +/* safe decompression with overrun testing */
626 +int lzo1x_decompress_safe(const unsigned char *src, size_t src_len,
627 +                       unsigned char *dst, size_t *dst_len);
628 +
629 +/*
630 + * Return values (< 0 = Error)
631 + */
632 +#define LZO_E_OK                       0
633 +#define LZO_E_ERROR                    (-1)
634 +#define LZO_E_OUT_OF_MEMORY            (-2)
635 +#define LZO_E_NOT_COMPRESSIBLE         (-3)
636 +#define LZO_E_INPUT_OVERRUN            (-4)
637 +#define LZO_E_OUTPUT_OVERRUN           (-5)
638 +#define LZO_E_LOOKBEHIND_OVERRUN       (-6)
639 +#define LZO_E_EOF_NOT_FOUND            (-7)
640 +#define LZO_E_INPUT_NOT_CONSUMED       (-8)
641 +#define LZO_E_NOT_YET_IMPLEMENTED      (-9)
642 +
643 +#endif
644 diff -uNr compcache-old/sub-projects/compression/lzo-kmod/Makefile compcache/sub-projects/compression/lzo-kmod/Makefile
645 --- compcache-old/sub-projects/compression/lzo-kmod/Makefile    1970-01-01 01:00:00.000000000 +0100
646 +++ compcache/sub-projects/compression/lzo-kmod/Makefile        2009-10-17 09:35:59.000000000 +0200
647 @@ -0,0 +1,8 @@
648 +obj-m += lzo1x_compress.o lzo1x_decompress.o
649 +
650 +all:
651 +       make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
652 +
653 +clean:
654 +       make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
655 +