xref: /onnv-gate/usr/src/uts/common/fs/zfs/sys/zio_compress.h (revision 10922:e2081f502306)
1789Sahrens /*
2789Sahrens  * CDDL HEADER START
3789Sahrens  *
4789Sahrens  * The contents of this file are subject to the terms of the
53886Sahl  * Common Development and Distribution License (the "License").
63886Sahl  * You may not use this file except in compliance with the License.
7789Sahrens  *
8789Sahrens  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9789Sahrens  * or http://www.opensolaris.org/os/licensing.
10789Sahrens  * See the License for the specific language governing permissions
11789Sahrens  * and limitations under the License.
12789Sahrens  *
13789Sahrens  * When distributing Covered Code, include this CDDL HEADER in each
14789Sahrens  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15789Sahrens  * If applicable, add the following below this CDDL HEADER, with the
16789Sahrens  * fields enclosed by brackets "[]" replaced with your own identifying
17789Sahrens  * information: Portions Copyright [yyyy] [name of copyright owner]
18789Sahrens  *
19789Sahrens  * CDDL HEADER END
20789Sahrens  */
213886Sahl 
22789Sahrens /*
23*10922SJeff.Bonwick@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24789Sahrens  * Use is subject to license terms.
25789Sahrens  */
26789Sahrens 
27789Sahrens #ifndef _SYS_ZIO_COMPRESS_H
28789Sahrens #define	_SYS_ZIO_COMPRESS_H
29789Sahrens 
30789Sahrens #include <sys/zio.h>
31789Sahrens 
32789Sahrens #ifdef	__cplusplus
33789Sahrens extern "C" {
34789Sahrens #endif
35789Sahrens 
36789Sahrens /*
37789Sahrens  * Common signature for all zio compress/decompress functions.
38789Sahrens  */
39789Sahrens typedef size_t zio_compress_func_t(void *src, void *dst,
403886Sahl     size_t s_len, size_t d_len, int);
41789Sahrens typedef int zio_decompress_func_t(void *src, void *dst,
423886Sahl     size_t s_len, size_t d_len, int);
43789Sahrens 
44789Sahrens /*
45789Sahrens  * Information about each compression function.
46789Sahrens  */
47789Sahrens typedef struct zio_compress_info {
483886Sahl 	zio_compress_func_t	*ci_compress;	/* compression function */
493886Sahl 	zio_decompress_func_t	*ci_decompress;	/* decompression function */
503886Sahl 	int			ci_level;	/* level parameter */
513886Sahl 	char			*ci_name;	/* algorithm name */
52789Sahrens } zio_compress_info_t;
53789Sahrens 
54789Sahrens extern zio_compress_info_t zio_compress_table[ZIO_COMPRESS_FUNCTIONS];
55789Sahrens 
56789Sahrens /*
57789Sahrens  * Compression routines.
58789Sahrens  */
593886Sahl extern size_t lzjb_compress(void *src, void *dst, size_t s_len, size_t d_len,
603886Sahl     int level);
613886Sahl extern int lzjb_decompress(void *src, void *dst, size_t s_len, size_t d_len,
623886Sahl     int level);
633886Sahl extern size_t gzip_compress(void *src, void *dst, size_t s_len, size_t d_len,
643886Sahl     int level);
653886Sahl extern int gzip_decompress(void *src, void *dst, size_t s_len, size_t d_len,
663886Sahl     int level);
67*10922SJeff.Bonwick@Sun.COM extern size_t zle_compress(void *src, void *dst, size_t s_len, size_t d_len,
68*10922SJeff.Bonwick@Sun.COM     int level);
69*10922SJeff.Bonwick@Sun.COM extern int zle_decompress(void *src, void *dst, size_t s_len, size_t d_len,
70*10922SJeff.Bonwick@Sun.COM     int level);
71789Sahrens 
72789Sahrens /*
73789Sahrens  * Compress and decompress data if necessary.
74789Sahrens  */
75*10922SJeff.Bonwick@Sun.COM extern size_t zio_compress_data(enum zio_compress c, void *src, void *dst,
76*10922SJeff.Bonwick@Sun.COM     size_t s_len);
77*10922SJeff.Bonwick@Sun.COM extern int zio_decompress_data(enum zio_compress c, void *src, void *dst,
78*10922SJeff.Bonwick@Sun.COM     size_t s_len, size_t d_len);
79789Sahrens 
80789Sahrens #ifdef	__cplusplus
81789Sahrens }
82789Sahrens #endif
83789Sahrens 
84789Sahrens #endif	/* _SYS_ZIO_COMPRESS_H */
85