Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
[linux-2.6.git] / include / linux / lz4.h
blobd21c13f10a6471590f0a783a53eabfbba9571051
1 #ifndef __LZ4_H__
2 #define __LZ4_H__
3 /*
4 * LZ4 Kernel Interface
6 * Copyright (C) 2013, LG Electronics, Kyungsik Lee <kyungsik.lee@lge.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
12 #define LZ4_MEM_COMPRESS (4096 * sizeof(unsigned char *))
13 #define LZ4HC_MEM_COMPRESS (65538 * sizeof(unsigned char *))
16 * lz4_compressbound()
17 * Provides the maximum size that LZ4 may output in a "worst case" scenario
18 * (input data not compressible)
20 static inline size_t lz4_compressbound(size_t isize)
22 return isize + (isize / 255) + 16;
26 * lz4_compress()
27 * src : source address of the original data
28 * src_len : size of the original data
29 * dst : output buffer address of the compressed data
30 * This requires 'dst' of size LZ4_COMPRESSBOUND.
31 * dst_len : is the output size, which is returned after compress done
32 * workmem : address of the working memory.
33 * This requires 'workmem' of size LZ4_MEM_COMPRESS.
34 * return : Success if return 0
35 * Error if return (< 0)
36 * note : Destination buffer and workmem must be already allocated with
37 * the defined size.
39 int lz4_compress(const unsigned char *src, size_t src_len,
40 unsigned char *dst, size_t *dst_len, void *wrkmem);
43 * lz4hc_compress()
44 * src : source address of the original data
45 * src_len : size of the original data
46 * dst : output buffer address of the compressed data
47 * This requires 'dst' of size LZ4_COMPRESSBOUND.
48 * dst_len : is the output size, which is returned after compress done
49 * workmem : address of the working memory.
50 * This requires 'workmem' of size LZ4HC_MEM_COMPRESS.
51 * return : Success if return 0
52 * Error if return (< 0)
53 * note : Destination buffer and workmem must be already allocated with
54 * the defined size.
56 int lz4hc_compress(const unsigned char *src, size_t src_len,
57 unsigned char *dst, size_t *dst_len, void *wrkmem);
60 * lz4_decompress()
61 * src : source address of the compressed data
62 * src_len : is the input size, whcih is returned after decompress done
63 * dest : output buffer address of the decompressed data
64 * actual_dest_len: is the size of uncompressed data, supposing it's known
65 * return : Success if return 0
66 * Error if return (< 0)
67 * note : Destination buffer must be already allocated.
68 * slightly faster than lz4_decompress_unknownoutputsize()
70 int lz4_decompress(const char *src, size_t *src_len, char *dest,
71 size_t actual_dest_len);
74 * lz4_decompress_unknownoutputsize()
75 * src : source address of the compressed data
76 * src_len : is the input size, therefore the compressed size
77 * dest : output buffer address of the decompressed data
78 * dest_len: is the max size of the destination buffer, which is
79 * returned with actual size of decompressed data after
80 * decompress done
81 * return : Success if return 0
82 * Error if return (< 0)
83 * note : Destination buffer must be already allocated.
85 int lz4_decompress_unknownoutputsize(const char *src, size_t src_len,
86 char *dest, size_t *dest_len);
87 #endif