svn commit: r246605 - in user/attilio/vmc-playground: . cddl/contrib/opensolaris/cmd/zfs cddl/contrib/opensolaris/cmd/zpool lib/libc/stdio lib/libc/sys sys/arm/arm sys/cddl/boot/zfs sys/cddl/compat...
Attilio Rao
attilio at FreeBSD.org
Sun Feb 10 01:18:31 UTC 2013
Author: attilio
Date: Sun Feb 10 01:18:26 2013
New Revision: 246605
URL: http://svnweb.freebsd.org/changeset/base/246605
Log:
Merge from vmcontention
Added:
user/attilio/vmc-playground/sys/cddl/boot/zfs/lz4.c
- copied unchanged from r246604, user/attilio/vmcontention/sys/cddl/boot/zfs/lz4.c
user/attilio/vmc-playground/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/THIRDPARTYLICENSE.lz4
- copied unchanged from r246604, user/attilio/vmcontention/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/THIRDPARTYLICENSE.lz4
user/attilio/vmc-playground/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/THIRDPARTYLICENSE.lz4.descrip
- copied unchanged from r246604, user/attilio/vmcontention/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/THIRDPARTYLICENSE.lz4.descrip
user/attilio/vmc-playground/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/lz4.c
- copied unchanged from r246604, user/attilio/vmcontention/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/lz4.c
Modified:
user/attilio/vmc-playground/Makefile.inc1
user/attilio/vmc-playground/ObsoleteFiles.inc
user/attilio/vmc-playground/cddl/contrib/opensolaris/cmd/zfs/zfs.8
user/attilio/vmc-playground/cddl/contrib/opensolaris/cmd/zpool/zpool-features.7
user/attilio/vmc-playground/lib/libc/stdio/fopen.3
user/attilio/vmc-playground/lib/libc/sys/chflags.2
user/attilio/vmc-playground/sys/arm/arm/vm_machdep.c
user/attilio/vmc-playground/sys/cddl/boot/zfs/README
user/attilio/vmc-playground/sys/cddl/boot/zfs/zfsimpl.h
user/attilio/vmc-playground/sys/cddl/boot/zfs/zfssubr.c
user/attilio/vmc-playground/sys/cddl/compat/opensolaris/sys/byteorder.h
user/attilio/vmc-playground/sys/cddl/contrib/opensolaris/common/zfs/zfeature_common.c
user/attilio/vmc-playground/sys/cddl/contrib/opensolaris/common/zfs/zfeature_common.h
user/attilio/vmc-playground/sys/cddl/contrib/opensolaris/common/zfs/zfs_prop.c
user/attilio/vmc-playground/sys/cddl/contrib/opensolaris/uts/common/Makefile.files
user/attilio/vmc-playground/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h
user/attilio/vmc-playground/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio_compress.h
user/attilio/vmc-playground/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
user/attilio/vmc-playground/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio_compress.c
user/attilio/vmc-playground/sys/conf/files
user/attilio/vmc-playground/sys/dev/ath/ath_hal/ar5416/ar5416_xmit.c
user/attilio/vmc-playground/sys/dev/cxgbe/t4_main.c
user/attilio/vmc-playground/sys/fs/tmpfs/tmpfs_vnops.c
user/attilio/vmc-playground/sys/modules/usb/smsc/Makefile
user/attilio/vmc-playground/sys/netinet/sctp.h
user/attilio/vmc-playground/sys/netinet/sctp_asconf.c
user/attilio/vmc-playground/sys/netinet/sctp_indata.c
user/attilio/vmc-playground/sys/netinet/sctp_input.c
user/attilio/vmc-playground/sys/netinet/sctp_output.c
user/attilio/vmc-playground/sys/netinet/sctp_output.h
user/attilio/vmc-playground/sys/netinet/sctp_pcb.c
user/attilio/vmc-playground/sys/netinet/sctp_structs.h
user/attilio/vmc-playground/sys/netinet/sctp_sysctl.c
user/attilio/vmc-playground/sys/netinet/sctp_timer.c
user/attilio/vmc-playground/sys/netinet/sctp_usrreq.c
user/attilio/vmc-playground/sys/netinet/sctputil.c
user/attilio/vmc-playground/sys/ofed/drivers/net/mlx4/en_tx.c
user/attilio/vmc-playground/usr.bin/Makefile
user/attilio/vmc-playground/usr.bin/csup/csup.1
user/attilio/vmc-playground/usr.bin/ee/Makefile
Directory Properties:
user/attilio/vmc-playground/ (props changed)
user/attilio/vmc-playground/cddl/contrib/opensolaris/ (props changed)
user/attilio/vmc-playground/cddl/contrib/opensolaris/cmd/zfs/ (props changed)
user/attilio/vmc-playground/lib/libc/ (props changed)
user/attilio/vmc-playground/sys/ (props changed)
user/attilio/vmc-playground/sys/cddl/contrib/opensolaris/ (props changed)
user/attilio/vmc-playground/sys/conf/ (props changed)
user/attilio/vmc-playground/usr.bin/csup/ (props changed)
Modified: user/attilio/vmc-playground/Makefile.inc1
==============================================================================
--- user/attilio/vmc-playground/Makefile.inc1 Sun Feb 10 01:13:03 2013 (r246604)
+++ user/attilio/vmc-playground/Makefile.inc1 Sun Feb 10 01:18:26 2013 (r246605)
@@ -673,6 +673,10 @@ _install-info= install-info
_zoneinfo= zic tzsetup
.endif
+.if exists(/usr/sbin/nmtree)
+_nmtree_itools= nmtree
+.endif
+
ITOOLS= [ awk cap_mkdb cat chflags chmod chown \
date echo egrep find grep id install ${_install-info} \
ln lockf make mkdir mtree ${_nmtree_itools} mv pwd_mkdb \
@@ -1134,8 +1138,6 @@ _yacc= usr.bin/yacc
.if ${BOOTSTRAPPING} < 1000026
_nmtree= lib/libnetbsd \
usr.sbin/nmtree
-.else
-_nmtree_itools= nmtree
.endif
.if ${BOOTSTRAPPING} < 1000027
Modified: user/attilio/vmc-playground/ObsoleteFiles.inc
==============================================================================
--- user/attilio/vmc-playground/ObsoleteFiles.inc Sun Feb 10 01:13:03 2013 (r246604)
+++ user/attilio/vmc-playground/ObsoleteFiles.inc Sun Feb 10 01:18:26 2013 (r246605)
@@ -45,6 +45,10 @@ OLD_DIRS+=usr/share/man/man1aout
OLD_DIRS+=usr/share/man/cat1aout
OLD_DIRS+=usr/share/man/en.ISO8859-1/cat1aout
OLD_DIRS+=usr/share/man/en.UTF-8/cat1aout
+# 20130110: bsd.compat.mk removed
+OLD_FILES+=usr/share/mk/bsd.compat.mk
+# 20130103: gnats-supfile removed
+OLD_FILES+=usr/share/examples/cvsup/gnats-supfile
# 20121230: libdisk removed
OLD_FILES+=usr/share/man/man3/libdisk.3.gz usr/include/libdisk.h
OLD_FILES+=usr/lib/libdisk.a usr/lib32/libdisk.a
Modified: user/attilio/vmc-playground/cddl/contrib/opensolaris/cmd/zfs/zfs.8
==============================================================================
--- user/attilio/vmc-playground/cddl/contrib/opensolaris/cmd/zfs/zfs.8 Sun Feb 10 01:13:03 2013 (r246604)
+++ user/attilio/vmc-playground/cddl/contrib/opensolaris/cmd/zfs/zfs.8 Sun Feb 10 01:18:26 2013 (r246605)
@@ -24,10 +24,11 @@
.\" Copyright (c) 2011, Pawel Jakub Dawidek <pjd at FreeBSD.org>
.\" Copyright (c) 2012, Glen Barber <gjb at FreeBSD.org>
.\" Copyright (c) 2012, Bryan Drewery <bdrewery at FreeBSD.org>
+.\" Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
.\"
.\" $FreeBSD$
.\"
-.Dd November 26, 2012
+.Dd February 8, 2012
.Dt ZFS 8
.Os
.Sh NAME
@@ -866,7 +867,7 @@ but this may change in future releases).
disables integrity checking on user data. Disabling checksums is
.Em NOT
a recommended practice.
-.It Sy compression Ns = Ns Cm on | off | lzjb | gzip | gzip- Ns Ar N | Cm zle
+.It Sy compression Ns = Ns Cm on | off | lzjb | gzip | gzip- Ns Ar N | zle | Cm lz4
Controls the compression algorithm used for this dataset. The
.Cm lzjb
compression algorithm is optimized for performance while providing decent data
@@ -894,6 +895,26 @@ The
.Cm zle
compression algorithm compresses runs of zeros.
.Pp
+The
+.Sy lz4
+compression algorithm is a high-performance replacement
+for the
+.Sy lzjb
+algorithm. It features significantly faster
+compression and decompression, as well as a moderately higher
+compression ratio than
+.Sy lzjb ,
+but can only be used on pools with
+the
+.Sy lz4_compress
+feature set to
+.Sy enabled .
+See
+.Xr zpool-features 7
+for details on ZFS feature flags and the
+.Sy lz4_compress
+feature.
+.Pp
This property can also be referred to by its shortened column name
.Cm compress .
Changing this property affects only newly-written data.
Modified: user/attilio/vmc-playground/cddl/contrib/opensolaris/cmd/zpool/zpool-features.7
==============================================================================
--- user/attilio/vmc-playground/cddl/contrib/opensolaris/cmd/zpool/zpool-features.7 Sun Feb 10 01:13:03 2013 (r246604)
+++ user/attilio/vmc-playground/cddl/contrib/opensolaris/cmd/zpool/zpool-features.7 Sun Feb 10 01:18:26 2013 (r246605)
@@ -18,10 +18,11 @@
.\" information: Portions Copyright [yyyy] [name of copyright owner]
.\"
.\" Copyright (c) 2012 by Delphix. All rights reserved.
+.\" Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
.\"
.\" $FreeBSD$
.\"
-.Dd Aug 28, 2012
+.Dd February 8, 2012
.Dt ZPOOL-FEATURES 7
.Os
.Sh NAME
@@ -185,6 +186,49 @@ This feature is
.Sy active
while there are any filesystems, volumes, or snapshots which were created
after enabling this feature.
+.It Sy lz4_compress
+.Bl -column "READ\-ONLY COMPATIBLE" "org.illumos:lz4_compress"
+.It GUID Ta org.illumos:lz4_compress
+.It READ\-ONLY COMPATIBLE Ta no
+.It DEPENDENCIES Ta none
+.El
+.Pp
+.Sy lz4
+is a high-performance real-time compression algorithm that
+features significantly faster compression and decompression as well as a
+higher compression ratio than the older
+.Sy lzjb
+compression.
+Typically,
+.Sy lz4
+compression is approximately 50% faster on
+compressible data and 200% faster on incompressible data than
+.Sy lzjb .
+It is also approximately 80% faster on decompression, while
+giving approximately 10% better compression ratio.
+.Pp
+When the
+.Sy lz4_compress
+feature is set to
+.Sy enabled ,
+the
+administrator can turn on
+.Sy lz4
+compression on any dataset on the
+pool using the
+.Xr zfs 8
+command. Please note that doing so will
+immediately activate the
+.Sy lz4_compress
+feature on the underlying
+pool (even before any data is written). Since this feature is not
+read-only compatible, this operation will render the pool unimportable
+on systems without support for the
+.Sy lz4_compress
+feature. At the
+moment, this operation cannot be reversed. Booting off of
+.Sy lz4
+-compressed root pools is supported.
.El
.Sh SEE ALSO
.Xr zpool 8
Modified: user/attilio/vmc-playground/lib/libc/stdio/fopen.3
==============================================================================
--- user/attilio/vmc-playground/lib/libc/stdio/fopen.3 Sun Feb 10 01:13:03 2013 (r246604)
+++ user/attilio/vmc-playground/lib/libc/stdio/fopen.3 Sun Feb 10 01:18:26 2013 (r246605)
@@ -332,7 +332,7 @@ but is also supported by glibc.
The
.Fn fmemopen
function
-conforms to
+conforms to
.St -p1003.1-2008 .
The ``b'' mode does not conform to any standard
but is also supported by glibc.
Modified: user/attilio/vmc-playground/lib/libc/sys/chflags.2
==============================================================================
--- user/attilio/vmc-playground/lib/libc/sys/chflags.2 Sun Feb 10 01:13:03 2013 (r246604)
+++ user/attilio/vmc-playground/lib/libc/sys/chflags.2 Sun Feb 10 01:18:26 2013 (r246605)
@@ -98,7 +98,7 @@ If one of
or
.Dv SF_NOUNLINK
is set a non-super-user cannot change any flags and even the super-user
-can change flags only if securelevel is greater than 0.
+can change flags only if securelevel is 0.
(See
.Xr init 8
for details.)
Modified: user/attilio/vmc-playground/sys/arm/arm/vm_machdep.c
==============================================================================
--- user/attilio/vmc-playground/sys/arm/arm/vm_machdep.c Sun Feb 10 01:13:03 2013 (r246604)
+++ user/attilio/vmc-playground/sys/arm/arm/vm_machdep.c Sun Feb 10 01:18:26 2013 (r246605)
@@ -402,7 +402,8 @@ cpu_thread_alloc(struct thread *td)
* the ARM EABI.
*/
td->td_frame = (struct trapframe *)STACKALIGN((u_int)td->td_kstack +
- USPACE_SVC_STACK_TOP - sizeof(struct pcb) - 1);
+ USPACE_SVC_STACK_TOP - sizeof(struct pcb) -
+ sizeof(struct trapframe));
#ifdef __XSCALE__
#ifndef CPU_XSCALE_CORE3
pmap_use_minicache(td->td_kstack, td->td_kstack_pages * PAGE_SIZE);
Modified: user/attilio/vmc-playground/sys/cddl/boot/zfs/README
==============================================================================
--- user/attilio/vmc-playground/sys/cddl/boot/zfs/README Sun Feb 10 01:13:03 2013 (r246604)
+++ user/attilio/vmc-playground/sys/cddl/boot/zfs/README Sun Feb 10 01:18:26 2013 (r246605)
@@ -5,6 +5,7 @@ are used by the ZFS bootstrap:
fletcher.c checksum support
sha256.c checksum support
+ lz4.c compression support
lzjb.c compression support
zfssubr.c checksum, compression and raidz support
zfsimpl.h mostly describing the physical layout
Copied: user/attilio/vmc-playground/sys/cddl/boot/zfs/lz4.c (from r246604, user/attilio/vmcontention/sys/cddl/boot/zfs/lz4.c)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/attilio/vmc-playground/sys/cddl/boot/zfs/lz4.c Sun Feb 10 01:18:26 2013 (r246605, copy of r246604, user/attilio/vmcontention/sys/cddl/boot/zfs/lz4.c)
@@ -0,0 +1,308 @@
+/*
+ * LZ4 - Fast LZ compression algorithm
+ * Header File
+ * Copyright (C) 2011-2013, Yann Collet.
+ * BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * You can contact the author at :
+ * - LZ4 homepage : http://fastcompression.blogspot.com/p/lz4.html
+ * - LZ4 source repository : http://code.google.com/p/lz4/
+ *
+ * $FreeBSD$
+ */
+
+static int LZ4_uncompress_unknownOutputSize(const char *source, char *dest,
+ int isize, int maxOutputSize);
+
+/* ARGSUSED */
+static int
+lz4_decompress(void *s_start, void *d_start, size_t s_len, size_t d_len, int dummy __unused)
+{
+ const uint8_t *src = s_start;
+ uint32_t bufsiz = htonl(*(uint32_t *)src);
+
+ /* invalid compressed buffer size encoded at start */
+ if (bufsiz + 4 > s_len)
+ return (1);
+
+ /*
+ * Returns 0 on success (decompression function returned non-negative)
+ * and non-zero on failure (decompression function returned negative).
+ */
+ return (LZ4_uncompress_unknownOutputSize(s_start + 4, d_start, bufsiz,
+ d_len) < 0);
+}
+
+/*
+ * CPU Feature Detection
+ */
+
+/* 32 or 64 bits ? */
+#if (defined(__x86_64__) || defined(__x86_64) || defined(__amd64__) || \
+ defined(__amd64) || defined(__ppc64__) || defined(_WIN64) || \
+ defined(__LP64__) || defined(_LP64))
+#define LZ4_ARCH64 1
+#else
+#define LZ4_ARCH64 0
+#endif
+
+/*
+ * Little Endian or Big Endian?
+ * Note: overwrite the below #define if you know your architecture endianess.
+ */
+#if BYTE_ORDER == BIG_ENDIAN
+#define LZ4_BIG_ENDIAN 1
+#else
+ /*
+ * Little Endian assumed. PDP Endian and other very rare endian format
+ * are unsupported.
+ */
+#endif
+
+/*
+ * Compiler Options
+ */
+#if __STDC_VERSION__ >= 199901L /* C99 */
+/* "restrict" is a known keyword */
+#else
+/* Disable restrict */
+#define restrict
+#endif
+
+#define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
+
+#define lz4_bswap16(x) ((unsigned short int) ((((x) >> 8) & 0xffu) \
+ | (((x) & 0xffu) << 8)))
+
+#if (GCC_VERSION >= 302) || (__INTEL_COMPILER >= 800) || defined(__clang__)
+#define expect(expr, value) (__builtin_expect((expr), (value)))
+#else
+#define expect(expr, value) (expr)
+#endif
+
+#define likely(expr) expect((expr) != 0, 1)
+#define unlikely(expr) expect((expr) != 0, 0)
+
+/* Basic types */
+#define BYTE uint8_t
+#define U16 uint16_t
+#define U32 uint32_t
+#define S32 int32_t
+#define U64 uint64_t
+
+typedef struct _U16_S {
+ U16 v;
+} U16_S;
+typedef struct _U32_S {
+ U32 v;
+} U32_S;
+typedef struct _U64_S {
+ U64 v;
+} U64_S;
+
+#define A64(x) (((U64_S *)(x))->v)
+#define A32(x) (((U32_S *)(x))->v)
+#define A16(x) (((U16_S *)(x))->v)
+
+/*
+ * Constants
+ */
+#define MINMATCH 4
+
+#define COPYLENGTH 8
+#define LASTLITERALS 5
+
+#define ML_BITS 4
+#define ML_MASK ((1U<<ML_BITS)-1)
+#define RUN_BITS (8-ML_BITS)
+#define RUN_MASK ((1U<<RUN_BITS)-1)
+
+/*
+ * Architecture-specific macros
+ */
+#if LZ4_ARCH64
+#define STEPSIZE 8
+#define UARCH U64
+#define AARCH A64
+#define LZ4_COPYSTEP(s, d) A64(d) = A64(s); d += 8; s += 8;
+#define LZ4_COPYPACKET(s, d) LZ4_COPYSTEP(s, d)
+#define LZ4_SECURECOPY(s, d, e) if (d < e) LZ4_WILDCOPY(s, d, e)
+#define HTYPE U32
+#define INITBASE(base) const BYTE* const base = ip
+#else
+#define STEPSIZE 4
+#define UARCH U32
+#define AARCH A32
+#define LZ4_COPYSTEP(s, d) A32(d) = A32(s); d += 4; s += 4;
+#define LZ4_COPYPACKET(s, d) LZ4_COPYSTEP(s, d); LZ4_COPYSTEP(s, d);
+#define LZ4_SECURECOPY LZ4_WILDCOPY
+#define HTYPE const BYTE*
+#define INITBASE(base) const int base = 0
+#endif
+
+#if (defined(LZ4_BIG_ENDIAN) && !defined(BIG_ENDIAN_NATIVE_BUT_INCOMPATIBLE))
+#define LZ4_READ_LITTLEENDIAN_16(d, s, p) \
+ { U16 v = A16(p); v = lz4_bswap16(v); d = (s) - v; }
+#define LZ4_WRITE_LITTLEENDIAN_16(p, i) \
+ { U16 v = (U16)(i); v = lz4_bswap16(v); A16(p) = v; p += 2; }
+#else
+#define LZ4_READ_LITTLEENDIAN_16(d, s, p) { d = (s) - A16(p); }
+#define LZ4_WRITE_LITTLEENDIAN_16(p, v) { A16(p) = v; p += 2; }
+#endif
+
+/* Macros */
+#define LZ4_WILDCOPY(s, d, e) do { LZ4_COPYPACKET(s, d) } while (d < e);
+
+/* Decompression functions */
+
+static int
+LZ4_uncompress_unknownOutputSize(const char *source,
+ char *dest, int isize, int maxOutputSize)
+{
+ /* Local Variables */
+ const BYTE *restrict ip = (const BYTE *) source;
+ const BYTE *const iend = ip + isize;
+ const BYTE *restrict ref;
+
+ BYTE *restrict op = (BYTE *) dest;
+ BYTE *const oend = op + maxOutputSize;
+ BYTE *cpy;
+
+ size_t dec[] = { 0, 3, 2, 3, 0, 0, 0, 0 };
+
+ /* Main Loop */
+ while (ip < iend) {
+ BYTE token;
+ int length;
+
+ /* get runlength */
+ token = *ip++;
+ if ((length = (token >> ML_BITS)) == RUN_MASK) {
+ int s = 255;
+ while ((ip < iend) && (s == 255)) {
+ s = *ip++;
+ length += s;
+ }
+ }
+ /* copy literals */
+ cpy = op + length;
+ if ((cpy > oend - COPYLENGTH) ||
+ (ip + length > iend - COPYLENGTH)) {
+ if (cpy > oend)
+ /*
+ * Error: request to write beyond destination
+ * buffer.
+ */
+ goto _output_error;
+ if (ip + length > iend)
+ /*
+ * Error : request to read beyond source
+ * buffer.
+ */
+ goto _output_error;
+ memcpy(op, ip, length);
+ op += length;
+ ip += length;
+ if (ip < iend)
+ /* Error : LZ4 format violation */
+ goto _output_error;
+ /* Necessarily EOF, due to parsing restrictions. */
+ break;
+ }
+ LZ4_WILDCOPY(ip, op, cpy);
+ ip -= (op - cpy);
+ op = cpy;
+
+ /* get offset */
+ LZ4_READ_LITTLEENDIAN_16(ref, cpy, ip);
+ ip += 2;
+ if (ref < (BYTE * const) dest)
+ /*
+ * Error: offset creates reference outside of
+ * destination buffer.
+ */
+ goto _output_error;
+
+ /* get matchlength */
+ if ((length = (token & ML_MASK)) == ML_MASK) {
+ while (ip < iend) {
+ int s = *ip++;
+ length += s;
+ if (s == 255)
+ continue;
+ break;
+ }
+ }
+ /* copy repeated sequence */
+ if unlikely(op - ref < STEPSIZE) {
+#if LZ4_ARCH64
+ size_t dec2table[] = { 0, 0, 0, -1, 0, 1, 2, 3 };
+ size_t dec2 = dec2table[op - ref];
+#else
+ const int dec2 = 0;
+#endif
+ *op++ = *ref++;
+ *op++ = *ref++;
+ *op++ = *ref++;
+ *op++ = *ref++;
+ ref -= dec[op - ref];
+ A32(op) = A32(ref);
+ op += STEPSIZE - 4;
+ ref -= dec2;
+ } else {
+ LZ4_COPYSTEP(ref, op);
+ }
+ cpy = op + length - (STEPSIZE - 4);
+ if (cpy > oend - COPYLENGTH) {
+ if (cpy > oend)
+ /*
+ * Error: request to write outside of
+ * destination buffer.
+ */
+ goto _output_error;
+ LZ4_SECURECOPY(ref, op, (oend - COPYLENGTH));
+ while (op < cpy)
+ *op++ = *ref++;
+ op = cpy;
+ if (op == oend)
+ /*
+ * Check EOF (should never happen, since last
+ * 5 bytes are supposed to be literals).
+ */
+ break;
+ continue;
+ }
+ LZ4_SECURECOPY(ref, op, cpy);
+ op = cpy; /* correction */
+ }
+
+ /* end of decoding */
+ return (int)(((char *)op) - dest);
+
+ /* write overflow error detected */
+ _output_error:
+ return (int)(-(((char *)ip) - source));
+}
Modified: user/attilio/vmc-playground/sys/cddl/boot/zfs/zfsimpl.h
==============================================================================
--- user/attilio/vmc-playground/sys/cddl/boot/zfs/zfsimpl.h Sun Feb 10 01:13:03 2013 (r246604)
+++ user/attilio/vmc-playground/sys/cddl/boot/zfs/zfsimpl.h Sun Feb 10 01:18:26 2013 (r246605)
@@ -52,6 +52,9 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright 2013 by Saso Kiselkov. All rights reserved.
+ */
#define MAXNAMELEN 256
@@ -439,6 +442,7 @@ enum zio_compress {
ZIO_COMPRESS_GZIP_8,
ZIO_COMPRESS_GZIP_9,
ZIO_COMPRESS_ZLE,
+ ZIO_COMPRESS_LZ4,
ZIO_COMPRESS_FUNCTIONS
};
Modified: user/attilio/vmc-playground/sys/cddl/boot/zfs/zfssubr.c
==============================================================================
--- user/attilio/vmc-playground/sys/cddl/boot/zfs/zfssubr.c Sun Feb 10 01:13:03 2013 (r246604)
+++ user/attilio/vmc-playground/sys/cddl/boot/zfs/zfssubr.c Sun Feb 10 01:18:26 2013 (r246605)
@@ -119,6 +119,7 @@ typedef struct zio_compress_info {
#include "lzjb.c"
#include "zle.c"
+#include "lz4.c"
/*
* Compression vectors.
@@ -139,6 +140,7 @@ static zio_compress_info_t zio_compress_
{NULL, NULL, 8, "gzip-8"},
{NULL, NULL, 9, "gzip-9"},
{NULL, zle_decompress, 64, "zle"},
+ {NULL, lz4_decompress, 0, "lz4"},
};
static void
Modified: user/attilio/vmc-playground/sys/cddl/compat/opensolaris/sys/byteorder.h
==============================================================================
--- user/attilio/vmc-playground/sys/cddl/compat/opensolaris/sys/byteorder.h Sun Feb 10 01:13:03 2013 (r246604)
+++ user/attilio/vmc-playground/sys/cddl/compat/opensolaris/sys/byteorder.h Sun Feb 10 01:18:26 2013 (r246605)
@@ -42,6 +42,11 @@
#ifndef _OPENSOLARIS_SYS_BYTEORDER_H_
#define _OPENSOLARIS_SYS_BYTEORDER_H_
+/* for htonl() */
+#ifndef _KERNEL
+#include <netinet/in.h>
+#endif
+
/*
* Macros to reverse byte order
*/
@@ -86,4 +91,6 @@
#define ntohll(x) BSWAP_64(x)
#endif
+#define BE_IN32(xa) htonl(*((uint32_t *)(void *)(xa)))
+
#endif /* _OPENSOLARIS_SYS_BYTEORDER_H_ */
Modified: user/attilio/vmc-playground/sys/cddl/contrib/opensolaris/common/zfs/zfeature_common.c
==============================================================================
--- user/attilio/vmc-playground/sys/cddl/contrib/opensolaris/common/zfs/zfeature_common.c Sun Feb 10 01:13:03 2013 (r246604)
+++ user/attilio/vmc-playground/sys/cddl/contrib/opensolaris/common/zfs/zfeature_common.c Sun Feb 10 01:18:26 2013 (r246605)
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
*/
#ifdef _KERNEL
@@ -155,4 +156,7 @@ zpool_feature_init(void)
zfeature_register(SPA_FEATURE_EMPTY_BPOBJ,
"com.delphix:empty_bpobj", "empty_bpobj",
"Snapshots use less space.", B_TRUE, B_FALSE, NULL);
+ zfeature_register(SPA_FEATURE_LZ4_COMPRESS,
+ "org.illumos:lz4_compress", "lz4_compress",
+ "LZ4 compression algorithm support.", B_FALSE, B_FALSE, NULL);
}
Modified: user/attilio/vmc-playground/sys/cddl/contrib/opensolaris/common/zfs/zfeature_common.h
==============================================================================
--- user/attilio/vmc-playground/sys/cddl/contrib/opensolaris/common/zfs/zfeature_common.h Sun Feb 10 01:13:03 2013 (r246604)
+++ user/attilio/vmc-playground/sys/cddl/contrib/opensolaris/common/zfs/zfeature_common.h Sun Feb 10 01:18:26 2013 (r246605)
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
*/
#ifndef _ZFEATURE_COMMON_H
@@ -51,6 +52,7 @@ typedef int (zfeature_func_t)(zfeature_i
static enum spa_feature {
SPA_FEATURE_ASYNC_DESTROY,
SPA_FEATURE_EMPTY_BPOBJ,
+ SPA_FEATURE_LZ4_COMPRESS,
SPA_FEATURES
} spa_feature_t;
Modified: user/attilio/vmc-playground/sys/cddl/contrib/opensolaris/common/zfs/zfs_prop.c
==============================================================================
--- user/attilio/vmc-playground/sys/cddl/contrib/opensolaris/common/zfs/zfs_prop.c Sun Feb 10 01:13:03 2013 (r246604)
+++ user/attilio/vmc-playground/sys/cddl/contrib/opensolaris/common/zfs/zfs_prop.c Sun Feb 10 01:18:26 2013 (r246605)
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
*/
/* Portions Copyright 2010 Robert Milkowski */
@@ -96,6 +97,7 @@ zfs_prop_init(void)
{ "gzip-8", ZIO_COMPRESS_GZIP_8 },
{ "gzip-9", ZIO_COMPRESS_GZIP_9 },
{ "zle", ZIO_COMPRESS_ZLE },
+ { "lz4", ZIO_COMPRESS_LZ4 },
{ NULL }
};
@@ -211,8 +213,8 @@ zfs_prop_init(void)
zprop_register_index(ZFS_PROP_COMPRESSION, "compression",
ZIO_COMPRESS_DEFAULT, PROP_INHERIT,
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
- "on | off | lzjb | gzip | gzip-[1-9] | zle", "COMPRESS",
- compress_table);
+ "on | off | lzjb | gzip | gzip-[1-9] | zle | lz4",
+ "COMPRESS", compress_table);
zprop_register_index(ZFS_PROP_SNAPDIR, "snapdir", ZFS_SNAPDIR_HIDDEN,
PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
"hidden | visible", "SNAPDIR", snapdir_table);
Modified: user/attilio/vmc-playground/sys/cddl/contrib/opensolaris/uts/common/Makefile.files
==============================================================================
--- user/attilio/vmc-playground/sys/cddl/contrib/opensolaris/uts/common/Makefile.files Sun Feb 10 01:13:03 2013 (r246604)
+++ user/attilio/vmc-playground/sys/cddl/contrib/opensolaris/uts/common/Makefile.files Sun Feb 10 01:18:26 2013 (r246605)
@@ -22,6 +22,7 @@
#
# Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2012 by Delphix. All rights reserved.
+# Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
#
#
# This Makefile defines all file modules for the directory uts/common
@@ -56,6 +57,7 @@ ZFS_COMMON_OBJS += \
dsl_scan.o \
zfeature.o \
gzip.o \
+ lz4.o \
lzjb.o \
metaslab.o \
refcount.o \
Copied: user/attilio/vmc-playground/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/THIRDPARTYLICENSE.lz4 (from r246604, user/attilio/vmcontention/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/THIRDPARTYLICENSE.lz4)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/attilio/vmc-playground/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/THIRDPARTYLICENSE.lz4 Sun Feb 10 01:18:26 2013 (r246605, copy of r246604, user/attilio/vmcontention/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/THIRDPARTYLICENSE.lz4)
@@ -0,0 +1,30 @@
+LZ4 - Fast LZ compression algorithm
+Copyright (C) 2011-2013, Yann Collet.
+BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+You can contact the author at :
+- LZ4 homepage : http://fastcompression.blogspot.com/p/lz4.html
+- LZ4 source repository : http://code.google.com/p/lz4/
Copied: user/attilio/vmc-playground/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/THIRDPARTYLICENSE.lz4.descrip (from r246604, user/attilio/vmcontention/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/THIRDPARTYLICENSE.lz4.descrip)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/attilio/vmc-playground/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/THIRDPARTYLICENSE.lz4.descrip Sun Feb 10 01:18:26 2013 (r246605, copy of r246604, user/attilio/vmcontention/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/THIRDPARTYLICENSE.lz4.descrip)
@@ -0,0 +1 @@
+LZ4 COMPRESSION FUNCTIONALITY IN ZFS
Copied: user/attilio/vmc-playground/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/lz4.c (from r246604, user/attilio/vmcontention/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/lz4.c)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/attilio/vmc-playground/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/lz4.c Sun Feb 10 01:18:26 2013 (r246605, copy of r246604, user/attilio/vmcontention/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/lz4.c)
@@ -0,0 +1,1064 @@
+/*
+ * LZ4 - Fast LZ compression algorithm
+ * Header File
+ * Copyright (C) 2011-2013, Yann Collet.
+ * BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * You can contact the author at :
+ * - LZ4 homepage : http://fastcompression.blogspot.com/p/lz4.html
+ * - LZ4 source repository : http://code.google.com/p/lz4/
+ */
+
+#include <sys/zfs_context.h>
+
+static int real_LZ4_compress(const char *source, char *dest, int isize,
+ int osize);
+static int real_LZ4_uncompress(const char *source, char *dest, int osize);
+static int LZ4_compressBound(int isize);
+static int LZ4_uncompress_unknownOutputSize(const char *source, char *dest,
+ int isize, int maxOutputSize);
+static int LZ4_compressCtx(void *ctx, const char *source, char *dest,
+ int isize, int osize);
+static int LZ4_compress64kCtx(void *ctx, const char *source, char *dest,
+ int isize, int osize);
+
+/*ARGSUSED*/
+size_t
+lz4_compress(void *s_start, void *d_start, size_t s_len, size_t d_len, int n)
+{
+ uint32_t bufsiz;
+ char *dest = d_start;
+
+ ASSERT(d_len >= sizeof (bufsiz));
+
+ bufsiz = real_LZ4_compress(s_start, &dest[sizeof (bufsiz)], s_len,
+ d_len - sizeof (bufsiz));
+
+ /* Signal an error if the compression routine returned zero. */
+ if (bufsiz == 0)
+ return (s_len);
+
+ /*
+ * Encode the compresed buffer size at the start. We'll need this in
+ * decompression to counter the effects of padding which might be
+ * added to the compressed buffer and which, if unhandled, would
+ * confuse the hell out of our decompression function.
+ */
+ *(uint32_t *)dest = BE_32(bufsiz);
+
+ return (bufsiz + sizeof (bufsiz));
+}
+
+/*ARGSUSED*/
+int
+lz4_decompress(void *s_start, void *d_start, size_t s_len, size_t d_len, int n)
+{
+ const char *src = s_start;
+ uint32_t bufsiz = BE_IN32(src);
+
+ /* invalid compressed buffer size encoded at start */
+ if (bufsiz + sizeof (bufsiz) > s_len)
+ return (1);
+
+ /*
+ * Returns 0 on success (decompression function returned non-negative)
+ * and non-zero on failure (decompression function returned negative.
+ */
+ return (LZ4_uncompress_unknownOutputSize(&src[sizeof (bufsiz)],
+ d_start, bufsiz, d_len) < 0);
+}
+
+/*
+ * LZ4 API Description:
+ *
+ * Simple Functions:
+ * real_LZ4_compress() :
+ * isize : is the input size. Max supported value is ~1.9GB
+ * return : the number of bytes written in buffer dest
+ * or 0 if the compression fails (if LZ4_COMPRESSMIN is set).
+ * note : destination buffer must be already allocated.
+ * destination buffer must be sized to handle worst cases
+ * situations (input data not compressible) worst case size
+ * evaluation is provided by function LZ4_compressBound().
+ *
+ * real_LZ4_uncompress() :
+ * osize : is the output size, therefore the original size
+ * return : the number of bytes read in the source buffer.
+ * If the source stream is malformed, the function will stop
+ * decoding and return a negative result, indicating the byte
+ * position of the faulty instruction. This function never
+ * writes beyond dest + osize, and is therefore protected
+ * against malicious data packets.
+ * note : destination buffer must be already allocated
+ *
+ * Advanced Functions
+ *
+ * LZ4_compressBound() :
+ * Provides the maximum size that LZ4 may output in a "worst case"
+ * scenario (input data not compressible) primarily useful for memory
+ * allocation of output buffer.
+ *
+ * isize : is the input size. Max supported value is ~1.9GB
+ * return : maximum output size in a "worst case" scenario
+ * note : this function is limited by "int" range (2^31-1)
+ *
+ * LZ4_uncompress_unknownOutputSize() :
+ * isize : is the input size, therefore the compressed size
+ * maxOutputSize : is the size of the destination buffer (which must be
+ * already allocated)
+ * return : the number of bytes decoded in the destination buffer
+ * (necessarily <= maxOutputSize). If the source stream is
+ * malformed, the function will stop decoding and return a
+ * negative result, indicating the byte position of the faulty
+ * instruction. This function never writes beyond dest +
+ * maxOutputSize, and is therefore protected against malicious
+ * data packets.
+ * note : Destination buffer must be already allocated.
+ * This version is slightly slower than real_LZ4_uncompress()
+ *
+ * LZ4_compressCtx() :
+ * This function explicitly handles the CTX memory structure.
+ *
+ * ILLUMOS CHANGES: the CTX memory structure must be explicitly allocated
+ * by the caller (either on the stack or using kmem_zalloc). Passing NULL
+ * isn't valid.
+ *
+ * LZ4_compress64kCtx() :
+ * Same as LZ4_compressCtx(), but specific to small inputs (<64KB).
+ * isize *Must* be <64KB, otherwise the output will be corrupted.
+ *
+ * ILLUMOS CHANGES: the CTX memory structure must be explicitly allocated
+ * by the caller (either on the stack or using kmem_zalloc). Passing NULL
+ * isn't valid.
+ */
+
+/*
+ * Tuning parameters
+ */
+
+/*
+ * COMPRESSIONLEVEL: Increasing this value improves compression ratio
+ * Lowering this value reduces memory usage. Reduced memory usage
+ * typically improves speed, due to cache effect (ex: L1 32KB for Intel,
+ * L1 64KB for AMD). Memory usage formula : N->2^(N+2) Bytes
+ * (examples : 12 -> 16KB ; 17 -> 512KB)
+ */
+#define COMPRESSIONLEVEL 12
+
+/*
+ * NOTCOMPRESSIBLE_CONFIRMATION: Decreasing this value will make the
+ * algorithm skip faster data segments considered "incompressible".
+ * This may decrease compression ratio dramatically, but will be
+ * faster on incompressible data. Increasing this value will make
+ * the algorithm search more before declaring a segment "incompressible".
+ * This could improve compression a bit, but will be slower on
+ * incompressible data. The default value (6) is recommended.
+ */
+#define NOTCOMPRESSIBLE_CONFIRMATION 6
+
+/*
+ * BIG_ENDIAN_NATIVE_BUT_INCOMPATIBLE: This will provide a boost to
+ * performance for big endian cpu, but the resulting compressed stream
+ * will be incompatible with little-endian CPU. You can set this option
+ * to 1 in situations where data will stay within closed environment.
+ * This option is useless on Little_Endian CPU (such as x86).
+ */
+/* #define BIG_ENDIAN_NATIVE_BUT_INCOMPATIBLE 1 */
+
+/*
+ * CPU Feature Detection
+ */
+
+/* 32 or 64 bits ? */
+#if (defined(__x86_64__) || defined(__x86_64) || defined(__amd64__) || \
+ defined(__amd64) || defined(__ppc64__) || defined(_WIN64) || \
+ defined(__LP64__) || defined(_LP64))
+#define LZ4_ARCH64 1
+/*
+ * Illumos: On amd64 we have 20k of stack and 24k on sun4u and sun4v, so we
+ * can spend 16k on the algorithm
+ */
+/* FreeBSD: Use heap for all platforms for now */
+#define STACKLIMIT 0
+#else
+#define LZ4_ARCH64 0
+/*
+ * Illumos: On i386 we only have 12k of stack, so in order to maintain the
+ * same COMPRESSIONLEVEL we have to use heap allocation. Performance will
+ * suck, but alas, it's ZFS on 32-bit we're talking about, so...
+ */
+#define STACKLIMIT 0
+#endif
+
+/*
+ * Little Endian or Big Endian?
+ * Note: overwrite the below #define if you know your architecture endianess.
+ */
+#if BYTE_ORDER == BIG_ENDIAN
+#define LZ4_BIG_ENDIAN 1
+#else
+/*
+ * Little Endian assumed. PDP Endian and other very rare endian format
+ * are unsupported.
+ */
+#endif
+
+/*
+ * Unaligned memory access is automatically enabled for "common" CPU,
+ * such as x86. For others CPU, the compiler will be more cautious, and
+ * insert extra code to ensure aligned access is respected. If you know
+ * your target CPU supports unaligned memory access, you may want to
+ * force this option manually to improve performance
+ */
+#if defined(__ARM_FEATURE_UNALIGNED)
+#define LZ4_FORCE_UNALIGNED_ACCESS 1
+#endif
+
+/*
+ * Compiler Options
+ */
+#if __STDC_VERSION__ >= 199901L /* C99 */
+/* "restrict" is a known keyword */
+#else
+/* Disable restrict */
+#define restrict
+#endif
+
+#define lz4_bswap16(x) ((unsigned short int) ((((x) >> 8) & 0xffu) | \
+ (((x) & 0xffu) << 8)))
+
+#define expect(expr, value) (__builtin_expect((expr), (value)))
+
+#if defined(likely)
+#undef likely
+#endif
+#if defined(unlikely)
+#undef unlikely
+#endif
+
+#define likely(expr) expect((expr) != 0, 1)
+#define unlikely(expr) expect((expr) != 0, 0)
+
+/* Basic types */
+#define BYTE uint8_t
+#define U16 uint16_t
+#define U32 uint32_t
+#define S32 int32_t
+#define U64 uint64_t
+
+#ifndef LZ4_FORCE_UNALIGNED_ACCESS
+#pragma pack(1)
+#endif
+
+typedef struct _U16_S {
+ U16 v;
+} U16_S;
+typedef struct _U32_S {
+ U32 v;
+} U32_S;
+typedef struct _U64_S {
+ U64 v;
+} U64_S;
+
+#ifndef LZ4_FORCE_UNALIGNED_ACCESS
+#pragma pack()
+#endif
+
+#define A64(x) (((U64_S *)(x))->v)
+#define A32(x) (((U32_S *)(x))->v)
+#define A16(x) (((U16_S *)(x))->v)
+
+/*
+ * Constants
+ */
+#define MINMATCH 4
+
+#define HASH_LOG COMPRESSIONLEVEL
+#define HASHTABLESIZE (1 << HASH_LOG)
+#define HASH_MASK (HASHTABLESIZE - 1)
+
+#define SKIPSTRENGTH (NOTCOMPRESSIBLE_CONFIRMATION > 2 ? \
+ NOTCOMPRESSIBLE_CONFIRMATION : 2)
+
+/*
+ * Defines if memory is allocated into the stack (local variable),
+ * or into the heap (kmem_alloc()).
+ */
+#define HEAPMODE (HASH_LOG > STACKLIMIT)
+#define COPYLENGTH 8
+#define LASTLITERALS 5
*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
More information about the svn-src-user
mailing list