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
5 KERNEL_BUILD_PATH ?= "/lib/modules/$(shell uname -r)/build"
7 XVM = sub-projects/allocators/xvmalloc-kmod
8 +LZO = sub-projects/compression/lzo-kmod
9 EXTRA_CFLAGS := -DCONFIG_RAMZSWAP_STATS \
13 +obj-m += ramzswap.o $(LZO)/lzo1x.o
14 ramzswap-objs := ramzswap_drv.o $(XVM)/xvmalloc.o
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
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
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
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>
46 #include "ramzswap_drv.h"
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
52 +#include <linux/module.h>
54 +#include "lzo1x_compress.c"
55 +#include "lzo1x_decompress.c"
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
64 + * LZO1X Compressor from MiniLZO
66 + * Copyright (C) 1996-2005 Markus F.X.J. Oberhumer <markus@oberhumer.com>
68 + * The full LZO package can be found at:
69 + * http://www.oberhumer.com/opensource/lzo/
71 + * Changed for kernel use by:
72 + * Nitin Gupta <nitingupta910@gmail.com>
73 + * Richard Purdie <rpurdie@openedhand.com>
76 +#include <linux/module.h>
77 +#include <linux/kernel.h>
78 +#include <asm/unaligned.h>
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)
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;
98 + dindex = ((size_t)(0x21 * DX3(ip, 5, 5, 6)) >> 5) & D_MASK;
99 + m_pos = dict[dindex];
104 + if (ip == m_pos || ((size_t)(ip - m_pos) > M4_MAX_OFFSET))
107 + m_off = ip - m_pos;
108 + if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3])
111 + dindex = (dindex & (D_MASK & 0x7ff)) ^ (D_HIGH | 0x1f);
112 + m_pos = dict[dindex];
117 + if (ip == m_pos || ((size_t)(ip - m_pos) > M4_MAX_OFFSET))
120 + m_off = ip - m_pos;
121 + if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3])
127 + if (get_unaligned((const unsigned short *)m_pos)
128 + == get_unaligned((const unsigned short *)ip)) {
129 + if (likely(m_pos[2] == ip[2]))
136 + if (unlikely(ip >= ip_end))
143 + size_t t = ip - ii;
147 + } else if (t <= 18) {
150 + size_t tt = t - 18;
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++) {
171 + if (m_off <= M2_MAX_OFFSET) {
173 + *op++ = (((m_len - 1) << 5)
174 + | ((m_off & 7) << 2));
175 + *op++ = (m_off >> 3);
176 + } else if (m_off <= M3_MAX_OFFSET) {
178 + *op++ = (M3_MARKER | (m_len - 2));
183 + *op++ = (M4_MARKER | ((m_off & 0x4000) >> 11)
189 + m = m_pos + M2_MAX_LEN + 1;
191 + while (ip < end && *m == *ip) {
197 + if (m_off <= M3_MAX_OFFSET) {
200 + *op++ = (M3_MARKER | (m_len - 2));
203 + *op++ = M3_MARKER | 0;
208 + if (m_len <= M4_MAX_LEN) {
210 + | ((m_off & 0x4000) >> 11)
213 + m_len -= M4_MAX_LEN;
215 + | ((m_off & 0x4000) >> 11));
217 + while (m_len > 255) {
226 + *op++ = ((m_off & 63) << 2);
227 + *op++ = (m_off >> 6);
231 + if (unlikely(ip >= ip_end))
235 + *out_len = op - out;
236 + return in_end - ii;
239 +int lzo1x_1_compress(const unsigned char *in, size_t in_len, unsigned char *out,
240 + size_t *out_len, void *wrkmem)
242 + const unsigned char *ii;
243 + unsigned char *op = out;
246 + if (unlikely(in_len <= M2_MAX_LEN + 5)) {
249 + t = _lzo1x_1_do_compress(in, in_len, op, out_len, wrkmem);
254 + ii = in + in_len - t;
256 + if (op == out && t <= 238) {
258 + } else if (t <= 3) {
260 + } else if (t <= 18) {
263 + size_t tt = t - 18;
278 + *op++ = M4_MARKER | 1;
282 + *out_len = op - out;
285 +EXPORT_SYMBOL_GPL(lzo1x_1_compress);
287 +MODULE_LICENSE("GPL");
288 +MODULE_DESCRIPTION("LZO1X-1 Compressor");
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
295 + * LZO1X Decompressor from MiniLZO
297 + * Copyright (C) 1996-2005 Markus F.X.J. Oberhumer <markus@oberhumer.com>
299 + * The full LZO package can be found at:
300 + * http://www.oberhumer.com/opensource/lzo/
302 + * Changed for kernel use by:
303 + * Nitin Gupta <nitingupta910@gmail.com>
304 + * Richard Purdie <rpurdie@openedhand.com>
307 +#include <linux/module.h>
308 +#include <linux/kernel.h>
309 +#include <asm/byteorder.h>
310 +#include <asm/unaligned.h>
312 +#include "lzodefs.h"
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)
319 +#define COPY4(dst, src) \
320 + put_unaligned(get_unaligned((const u32 *)(src)), (u32 *)(dst))
322 +int lzo1x_decompress_safe(const unsigned char *in, size_t in_len,
323 + unsigned char *out, size_t *out_len)
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;
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;
344 + goto first_literal_run;
347 + while ((ip < ip_end)) {
352 + if (HAVE_IP(1, ip_end, ip))
353 + goto input_overrun;
357 + if (HAVE_IP(1, ip_end, ip))
358 + goto input_overrun;
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;
394 + m_pos = op - (1 + M2_MAX_OFFSET);
396 + m_pos -= *ip++ << 2;
398 + if (HAVE_LB(m_pos, out, op))
399 + goto lookbehind_overrun;
401 + if (HAVE_OP(3, op_end, op))
402 + goto output_overrun;
413 + m_pos -= (t >> 2) & 7;
414 + m_pos -= *ip++ << 3;
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;
421 + } else if (t >= 32) {
424 + if (HAVE_IP(1, ip_end, ip))
425 + goto input_overrun;
429 + if (HAVE_IP(1, ip_end, ip))
430 + goto input_overrun;
435 + m_pos -= le16_to_cpu(get_unaligned(
436 + (const unsigned short *)ip)) >> 2;
438 + } else if (t >= 16) {
440 + m_pos -= (t & 8) << 11;
444 + if (HAVE_IP(1, ip_end, ip))
445 + goto input_overrun;
449 + if (HAVE_IP(1, ip_end, ip))
450 + goto input_overrun;
454 + m_pos -= le16_to_cpu(get_unaligned(
455 + (const unsigned short *)ip)) >> 2;
463 + m_pos -= *ip++ << 2;
465 + if (HAVE_LB(m_pos, out, op))
466 + goto lookbehind_overrun;
467 + if (HAVE_OP(2, op_end, op))
468 + goto output_overrun;
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;
480 + if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4) {
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;
521 + } while (ip < ip_end);
524 + *out_len = op - out;
525 + return LZO_E_EOF_NOT_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));
532 + *out_len = op - out;
533 + return LZO_E_INPUT_OVERRUN;
536 + *out_len = op - out;
537 + return LZO_E_OUTPUT_OVERRUN;
540 + *out_len = op - out;
541 + return LZO_E_LOOKBEHIND_OVERRUN;
544 +EXPORT_SYMBOL_GPL(lzo1x_decompress_safe);
546 +MODULE_LICENSE("GPL");
547 +MODULE_DESCRIPTION("LZO1X Decompressor");
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
554 + * lzodefs.h -- architecture, OS and compiler specific defines
556 + * Copyright (C) 1996-2005 Markus F.X.J. Oberhumer <markus@oberhumer.com>
558 + * The full LZO package can be found at:
559 + * http://www.oberhumer.com/opensource/lzo/
561 + * Changed for kernel use by:
562 + * Nitin Gupta <nitingupta910@gmail.com>
563 + * Richard Purdie <rpurdie@openedhand.com>
566 +#define LZO_VERSION 0x2020
567 +#define LZO_VERSION_STRING "2.02"
568 +#define LZO_VERSION_DATE "Oct 17 2005"
570 +#define M1_MAX_OFFSET 0x0400
571 +#define M2_MAX_OFFSET 0x0800
572 +#define M3_MAX_OFFSET 0x4000
573 +#define M4_MAX_OFFSET 0xbfff
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
585 +#define M2_MARKER 64
586 +#define M3_MARKER 32
587 +#define M4_MARKER 16
590 +#define D_MASK ((1u << D_BITS) - 1)
591 +#define D_HIGH ((D_MASK >> 1) + 1)
593 +#define DX2(p, s1, s2) (((((size_t)((p)[2]) << (s2)) ^ (p)[1]) \
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
603 + * LZO Public Kernel Interface
604 + * A mini subset of the LZO real-time data compression library
606 + * Copyright (C) 1996-2005 Markus F.X.J. Oberhumer <markus@oberhumer.com>
608 + * The full LZO package can be found at:
609 + * http://www.oberhumer.com/opensource/lzo/
611 + * Changed for kernel use by:
612 + * Nitin Gupta <nitingupta910@gmail.com>
613 + * Richard Purdie <rpurdie@openedhand.com>
616 +#define LZO1X_MEM_COMPRESS (16384 * sizeof(unsigned char *))
617 +#define LZO1X_1_MEM_COMPRESS LZO1X_MEM_COMPRESS
619 +#define lzo1x_worst_compress(x) ((x) + ((x) / 16) + 64 + 3)
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);
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);
630 + * Return values (< 0 = Error)
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)
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
648 +obj-m += lzo1x_compress.o lzo1x_decompress.o
651 + make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
654 + make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean