1 diff -uNr compcache-0.5.4-old/Makefile compcache-0.5.4/Makefile
2 --- compcache-0.5.4-old/Makefile 2009-10-17 08:49:42.000000000 +0200
3 +++ compcache-0.5.4/Makefile 2009-10-17 09:39:34.000000000 +0200
5 KERNEL_BUILD_PATH ?= "/lib/modules/$(shell uname -r)/build"
7 XVM = sub-projects/allocators/xvmalloc-kmod
8 -EXTRA_CFLAGS := -DCONFIG_BLK_DEV_RAMZSWAP_STATS \
10 +LZO = sub-projects/compression/lzo-kmod
12 +EXTRA_CFLAGS += -DCONFIG_BLK_DEV_RAMZSWAP_STATS \
17 obj-m += $(XVM)/xvmalloc.o \
22 make -C $(KERNEL_BUILD_PATH) M=$(PWD)/$(XVM) modules
23 + make -C $(KERNEL_BUILD_PATH) M=$(PWD)/$(LZO) modules
24 make -C $(KERNEL_BUILD_PATH) M=$(PWD) modules
25 @ln -sf $(XVM)/xvmalloc.ko
26 + @ln -sf $(LZO)/xvmalloc.ko
29 make -C $(KERNEL_BUILD_PATH) M=$(PWD) clean
30 make -C $(KERNEL_BUILD_PATH) M=$(PWD)/$(XVM) clean
31 + make -C $(KERNEL_BUILD_PATH) M=$(PWD)/$(LZO) clean
33 diff -uNr compcache-0.5.4-old/ramzswap.c compcache-0.5.4/ramzswap.c
34 --- compcache-0.5.4-old/ramzswap.c 2009-10-17 08:50:06.000000000 +0200
35 +++ compcache-0.5.4/ramzswap.c 2009-10-17 09:35:59.000000000 +0200
37 #include <linux/device.h>
38 #include <linux/genhd.h>
39 #include <linux/highmem.h>
40 -#include <linux/lzo.h>
41 #include <linux/mutex.h>
42 #include <linux/proc_fs.h>
43 #include <linux/string.h>
44 diff -uNr compcache-0.5.4-old/ramzswap.h compcache-0.5.4/ramzswap.h
45 --- compcache-0.5.4-old/ramzswap.h 2009-10-17 08:50:06.000000000 +0200
46 +++ compcache-0.5.4/ramzswap.h 2009-10-17 09:40:45.000000000 +0200
54 * Stored at beginning of each compressed object.
55 diff -uNr compcache-0.5.4-old/sub-projects/compression/lzo-kmod/lzo1x.c compcache-0.5.4/sub-projects/compression/lzo-kmod/lzo1x.c
56 --- compcache-0.5.4-old/sub-projects/compression/lzo-kmod/lzo1x.c 1970-01-01 01:00:00.000000000 +0100
57 +++ compcache-0.5.4/sub-projects/compression/lzo-kmod/lzo1x.c 2009-10-17 09:35:59.000000000 +0200
59 +#include <linux/module.h>
61 +#include "lzo1x_compress.c"
62 +#include "lzo1x_decompress.c"
64 +MODULE_LICENSE("GPL");
65 +MODULE_DESCRIPTION("LZO1X Lib");
66 diff -uNr compcache-0.5.4-old/sub-projects/compression/lzo-kmod/lzo1x_compress.c compcache-0.5.4/sub-projects/compression/lzo-kmod/lzo1x_compress.c
67 --- compcache-0.5.4-old/sub-projects/compression/lzo-kmod/lzo1x_compress.c 1970-01-01 01:00:00.000000000 +0100
68 +++ compcache-0.5.4/sub-projects/compression/lzo-kmod/lzo1x_compress.c 2009-10-17 09:35:59.000000000 +0200
71 + * LZO1X Compressor from MiniLZO
73 + * Copyright (C) 1996-2005 Markus F.X.J. Oberhumer <markus@oberhumer.com>
75 + * The full LZO package can be found at:
76 + * http://www.oberhumer.com/opensource/lzo/
78 + * Changed for kernel use by:
79 + * Nitin Gupta <nitingupta910@gmail.com>
80 + * Richard Purdie <rpurdie@openedhand.com>
83 +#include <linux/module.h>
84 +#include <linux/kernel.h>
85 +#include <asm/unaligned.h>
90 +static noinline size_t
91 +_lzo1x_1_do_compress(const unsigned char *in, size_t in_len,
92 + unsigned char *out, size_t *out_len, void *wrkmem)
94 + const unsigned char * const in_end = in + in_len;
95 + const unsigned char * const ip_end = in + in_len - M2_MAX_LEN - 5;
96 + const unsigned char ** const dict = wrkmem;
97 + const unsigned char *ip = in, *ii = ip;
98 + const unsigned char *end, *m, *m_pos;
99 + size_t m_off, m_len, dindex;
100 + unsigned char *op = out;
105 + dindex = ((size_t)(0x21 * DX3(ip, 5, 5, 6)) >> 5) & D_MASK;
106 + m_pos = dict[dindex];
111 + if (ip == m_pos || ((size_t)(ip - m_pos) > M4_MAX_OFFSET))
114 + m_off = ip - m_pos;
115 + if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3])
118 + dindex = (dindex & (D_MASK & 0x7ff)) ^ (D_HIGH | 0x1f);
119 + m_pos = dict[dindex];
124 + if (ip == m_pos || ((size_t)(ip - m_pos) > M4_MAX_OFFSET))
127 + m_off = ip - m_pos;
128 + if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3])
134 + if (get_unaligned((const unsigned short *)m_pos)
135 + == get_unaligned((const unsigned short *)ip)) {
136 + if (likely(m_pos[2] == ip[2]))
143 + if (unlikely(ip >= ip_end))
150 + size_t t = ip - ii;
154 + } else if (t <= 18) {
157 + size_t tt = t - 18;
172 + if (m_pos[3] != *ip++ || m_pos[4] != *ip++
173 + || m_pos[5] != *ip++ || m_pos[6] != *ip++
174 + || m_pos[7] != *ip++ || m_pos[8] != *ip++) {
178 + if (m_off <= M2_MAX_OFFSET) {
180 + *op++ = (((m_len - 1) << 5)
181 + | ((m_off & 7) << 2));
182 + *op++ = (m_off >> 3);
183 + } else if (m_off <= M3_MAX_OFFSET) {
185 + *op++ = (M3_MARKER | (m_len - 2));
190 + *op++ = (M4_MARKER | ((m_off & 0x4000) >> 11)
196 + m = m_pos + M2_MAX_LEN + 1;
198 + while (ip < end && *m == *ip) {
204 + if (m_off <= M3_MAX_OFFSET) {
207 + *op++ = (M3_MARKER | (m_len - 2));
210 + *op++ = M3_MARKER | 0;
215 + if (m_len <= M4_MAX_LEN) {
217 + | ((m_off & 0x4000) >> 11)
220 + m_len -= M4_MAX_LEN;
222 + | ((m_off & 0x4000) >> 11));
224 + while (m_len > 255) {
233 + *op++ = ((m_off & 63) << 2);
234 + *op++ = (m_off >> 6);
238 + if (unlikely(ip >= ip_end))
242 + *out_len = op - out;
243 + return in_end - ii;
246 +int lzo1x_1_compress(const unsigned char *in, size_t in_len, unsigned char *out,
247 + size_t *out_len, void *wrkmem)
249 + const unsigned char *ii;
250 + unsigned char *op = out;
253 + if (unlikely(in_len <= M2_MAX_LEN + 5)) {
256 + t = _lzo1x_1_do_compress(in, in_len, op, out_len, wrkmem);
261 + ii = in + in_len - t;
263 + if (op == out && t <= 238) {
265 + } else if (t <= 3) {
267 + } else if (t <= 18) {
270 + size_t tt = t - 18;
285 + *op++ = M4_MARKER | 1;
289 + *out_len = op - out;
292 +EXPORT_SYMBOL_GPL(lzo1x_1_compress);
294 +MODULE_LICENSE("GPL");
295 +MODULE_DESCRIPTION("LZO1X-1 Compressor");
297 diff -uNr compcache-0.5.4-old/sub-projects/compression/lzo-kmod/lzo1x_decompress.c compcache-0.5.4/sub-projects/compression/lzo-kmod/lzo1x_decompress.c
298 --- compcache-0.5.4-old/sub-projects/compression/lzo-kmod/lzo1x_decompress.c 1970-01-01 01:00:00.000000000 +0100
299 +++ compcache-0.5.4/sub-projects/compression/lzo-kmod/lzo1x_decompress.c 2009-10-17 09:35:59.000000000 +0200
302 + * LZO1X Decompressor from MiniLZO
304 + * Copyright (C) 1996-2005 Markus F.X.J. Oberhumer <markus@oberhumer.com>
306 + * The full LZO package can be found at:
307 + * http://www.oberhumer.com/opensource/lzo/
309 + * Changed for kernel use by:
310 + * Nitin Gupta <nitingupta910@gmail.com>
311 + * Richard Purdie <rpurdie@openedhand.com>
314 +#include <linux/module.h>
315 +#include <linux/kernel.h>
316 +#include <asm/byteorder.h>
317 +#include <asm/unaligned.h>
319 +#include "lzodefs.h"
322 +#define HAVE_IP(x, ip_end, ip) ((size_t)(ip_end - ip) < (x))
323 +#define HAVE_OP(x, op_end, op) ((size_t)(op_end - op) < (x))
324 +#define HAVE_LB(m_pos, out, op) (m_pos < out || m_pos >= op)
326 +#define COPY4(dst, src) \
327 + put_unaligned(get_unaligned((const u32 *)(src)), (u32 *)(dst))
329 +int lzo1x_decompress_safe(const unsigned char *in, size_t in_len,
330 + unsigned char *out, size_t *out_len)
332 + const unsigned char * const ip_end = in + in_len;
333 + unsigned char * const op_end = out + *out_len;
334 + const unsigned char *ip = in, *m_pos;
335 + unsigned char *op = out;
344 + if (HAVE_OP(t, op_end, op))
345 + goto output_overrun;
346 + if (HAVE_IP(t + 1, ip_end, ip))
347 + goto input_overrun;
351 + goto first_literal_run;
354 + while ((ip < ip_end)) {
359 + if (HAVE_IP(1, ip_end, ip))
360 + goto input_overrun;
364 + if (HAVE_IP(1, ip_end, ip))
365 + goto input_overrun;
369 + if (HAVE_OP(t + 3, op_end, op))
370 + goto output_overrun;
371 + if (HAVE_IP(t + 4, ip_end, ip))
372 + goto input_overrun;
401 + m_pos = op - (1 + M2_MAX_OFFSET);
403 + m_pos -= *ip++ << 2;
405 + if (HAVE_LB(m_pos, out, op))
406 + goto lookbehind_overrun;
408 + if (HAVE_OP(3, op_end, op))
409 + goto output_overrun;
420 + m_pos -= (t >> 2) & 7;
421 + m_pos -= *ip++ << 3;
423 + if (HAVE_LB(m_pos, out, op))
424 + goto lookbehind_overrun;
425 + if (HAVE_OP(t + 3 - 1, op_end, op))
426 + goto output_overrun;
428 + } else if (t >= 32) {
431 + if (HAVE_IP(1, ip_end, ip))
432 + goto input_overrun;
436 + if (HAVE_IP(1, ip_end, ip))
437 + goto input_overrun;
442 + m_pos -= le16_to_cpu(get_unaligned(
443 + (const unsigned short *)ip)) >> 2;
445 + } else if (t >= 16) {
447 + m_pos -= (t & 8) << 11;
451 + if (HAVE_IP(1, ip_end, ip))
452 + goto input_overrun;
456 + if (HAVE_IP(1, ip_end, ip))
457 + goto input_overrun;
461 + m_pos -= le16_to_cpu(get_unaligned(
462 + (const unsigned short *)ip)) >> 2;
470 + m_pos -= *ip++ << 2;
472 + if (HAVE_LB(m_pos, out, op))
473 + goto lookbehind_overrun;
474 + if (HAVE_OP(2, op_end, op))
475 + goto output_overrun;
482 + if (HAVE_LB(m_pos, out, op))
483 + goto lookbehind_overrun;
484 + if (HAVE_OP(t + 3 - 1, op_end, op))
485 + goto output_overrun;
487 + if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4) {
515 + if (HAVE_OP(t, op_end, op))
516 + goto output_overrun;
517 + if (HAVE_IP(t + 1, ip_end, ip))
518 + goto input_overrun;
528 + } while (ip < ip_end);
531 + *out_len = op - out;
532 + return LZO_E_EOF_NOT_FOUND;
535 + *out_len = op - out;
536 + return (ip == ip_end ? LZO_E_OK :
537 + (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN));
539 + *out_len = op - out;
540 + return LZO_E_INPUT_OVERRUN;
543 + *out_len = op - out;
544 + return LZO_E_OUTPUT_OVERRUN;
547 + *out_len = op - out;
548 + return LZO_E_LOOKBEHIND_OVERRUN;
551 +EXPORT_SYMBOL_GPL(lzo1x_decompress_safe);
553 +MODULE_LICENSE("GPL");
554 +MODULE_DESCRIPTION("LZO1X Decompressor");
556 diff -uNr compcache-0.5.4-old/sub-projects/compression/lzo-kmod/lzodefs.h compcache-0.5.4/sub-projects/compression/lzo-kmod/lzodefs.h
557 --- compcache-0.5.4-old/sub-projects/compression/lzo-kmod/lzodefs.h 1970-01-01 01:00:00.000000000 +0100
558 +++ compcache-0.5.4/sub-projects/compression/lzo-kmod/lzodefs.h 2009-10-17 09:35:59.000000000 +0200
561 + * lzodefs.h -- architecture, OS and compiler specific defines
563 + * Copyright (C) 1996-2005 Markus F.X.J. Oberhumer <markus@oberhumer.com>
565 + * The full LZO package can be found at:
566 + * http://www.oberhumer.com/opensource/lzo/
568 + * Changed for kernel use by:
569 + * Nitin Gupta <nitingupta910@gmail.com>
570 + * Richard Purdie <rpurdie@openedhand.com>
573 +#define LZO_VERSION 0x2020
574 +#define LZO_VERSION_STRING "2.02"
575 +#define LZO_VERSION_DATE "Oct 17 2005"
577 +#define M1_MAX_OFFSET 0x0400
578 +#define M2_MAX_OFFSET 0x0800
579 +#define M3_MAX_OFFSET 0x4000
580 +#define M4_MAX_OFFSET 0xbfff
582 +#define M1_MIN_LEN 2
583 +#define M1_MAX_LEN 2
584 +#define M2_MIN_LEN 3
585 +#define M2_MAX_LEN 8
586 +#define M3_MIN_LEN 3
587 +#define M3_MAX_LEN 33
588 +#define M4_MIN_LEN 3
589 +#define M4_MAX_LEN 9
592 +#define M2_MARKER 64
593 +#define M3_MARKER 32
594 +#define M4_MARKER 16
597 +#define D_MASK ((1u << D_BITS) - 1)
598 +#define D_HIGH ((D_MASK >> 1) + 1)
600 +#define DX2(p, s1, s2) (((((size_t)((p)[2]) << (s2)) ^ (p)[1]) \
602 +#define DX3(p, s1, s2, s3) ((DX2((p)+1, s2, s3) << (s1)) ^ (p)[0])
603 diff -uNr compcache-0.5.4-old/sub-projects/compression/lzo-kmod/lzo.h compcache-0.5.4/sub-projects/compression/lzo-kmod/lzo.h
604 --- compcache-0.5.4-old/sub-projects/compression/lzo-kmod/lzo.h 1970-01-01 01:00:00.000000000 +0100
605 +++ compcache-0.5.4/sub-projects/compression/lzo-kmod/lzo.h 2009-10-17 09:35:59.000000000 +0200
610 + * LZO Public Kernel Interface
611 + * A mini subset of the LZO real-time data compression library
613 + * Copyright (C) 1996-2005 Markus F.X.J. Oberhumer <markus@oberhumer.com>
615 + * The full LZO package can be found at:
616 + * http://www.oberhumer.com/opensource/lzo/
618 + * Changed for kernel use by:
619 + * Nitin Gupta <nitingupta910@gmail.com>
620 + * Richard Purdie <rpurdie@openedhand.com>
623 +#define LZO1X_MEM_COMPRESS (16384 * sizeof(unsigned char *))
624 +#define LZO1X_1_MEM_COMPRESS LZO1X_MEM_COMPRESS
626 +#define lzo1x_worst_compress(x) ((x) + ((x) / 16) + 64 + 3)
628 +/* This requires 'workmem' of size LZO1X_1_MEM_COMPRESS */
629 +int lzo1x_1_compress(const unsigned char *src, size_t src_len,
630 + unsigned char *dst, size_t *dst_len, void *wrkmem);
632 +/* safe decompression with overrun testing */
633 +int lzo1x_decompress_safe(const unsigned char *src, size_t src_len,
634 + unsigned char *dst, size_t *dst_len);
637 + * Return values (< 0 = Error)
640 +#define LZO_E_ERROR (-1)
641 +#define LZO_E_OUT_OF_MEMORY (-2)
642 +#define LZO_E_NOT_COMPRESSIBLE (-3)
643 +#define LZO_E_INPUT_OVERRUN (-4)
644 +#define LZO_E_OUTPUT_OVERRUN (-5)
645 +#define LZO_E_LOOKBEHIND_OVERRUN (-6)
646 +#define LZO_E_EOF_NOT_FOUND (-7)
647 +#define LZO_E_INPUT_NOT_CONSUMED (-8)
648 +#define LZO_E_NOT_YET_IMPLEMENTED (-9)
651 diff -uNr compcache-0.5.4-old/sub-projects/compression/lzo-kmod/Makefile compcache-0.5.4/sub-projects/compression/lzo-kmod/Makefile
652 --- compcache-0.5.4-old/sub-projects/compression/lzo-kmod/Makefile 1970-01-01 01:00:00.000000000 +0100
653 +++ compcache-0.5.4/sub-projects/compression/lzo-kmod/Makefile 2009-10-17 09:35:59.000000000 +0200
655 +obj-m += lzo1x_compress.o lzo1x_decompress.o
658 + make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
661 + make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean