000-provide_lzo_kmod.patch 16 KB

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