From 963a63be30d72fd073eb297b005e21a3c75c2fcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= ppisar@redhat.com Date: Fri, 2 Oct 2015 17:08:18 +0200 Subject: 3.8 bump
diff --git a/.gitignore b/.gitignore index 1124518..656b24c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /Compress-LZF-3.7.tar.gz +/Compress-LZF-3.8.tar.gz diff --git a/Compress-LZF-3.8-Unbundle-liblzf.patch b/Compress-LZF-3.8-Unbundle-liblzf.patch new file mode 100644 index 0000000..c4e3bf1 --- /dev/null +++ b/Compress-LZF-3.8-Unbundle-liblzf.patch @@ -0,0 +1,1260 @@ +From b55f15dfd8a4bf289ad38d85ffb7ddd03ee12083 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= ppisar@redhat.com +Date: Fri, 2 Oct 2015 16:49:13 +0200 +Subject: [PATCH] Unbundle liblzf +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Compress-LZF-3.8 bundles liblzf-3.8 that has not yet been released. + +This patch removed support for `best' which is not yet available in +distribution's liblizf-3.6. + +bug #1268333 +bug #1237116 + +Signed-off-by: Petr Písař ppisar@redhat.com +--- + LZF.pm | 27 ++--- + LZF.xs | 36 ++----- + MANIFEST | 5 - + Makefile.PL | 2 +- + lzfP.h | 227 ----------------------------------------- + lzf_c.c | 292 ----------------------------------------------------- + lzf_c_best.c | 212 -------------------------------------- + lzf_d.c | 194 ----------------------------------- + t/03_freeze_best.t | 59 ----------- + 9 files changed, 15 insertions(+), 1039 deletions(-) + delete mode 100644 lzfP.h + delete mode 100644 lzf_c.c + delete mode 100644 lzf_c_best.c + delete mode 100644 lzf_d.c + delete mode 100644 t/03_freeze_best.t + +diff --git a/LZF.pm b/LZF.pm +index 3e9cb2a..e7357e4 100644 +--- a/LZF.pm ++++ b/LZF.pm +@@ -37,16 +37,11 @@ patents. + + =item $compressed = compress $uncompressed + +-=item $compressed = compress_best $uncompressed +- + Try to compress the given string as quickly and as much as possible. In + the worst case, the string can enlarge by 1 byte, but that should be the + absolute exception. You can expect a 45% compression ratio on large, + binary strings. + +-The C<compress_best> function uses a different algorithm that is slower +-but usually achieves better compression. +- + =item $decompressed = decompress $compressed + + Uncompress the string (compressed by C<compress>) and return the original +@@ -55,8 +50,6 @@ checksum kept) or a runtime error. + + =item $serialized = sfreeze $value (simplified freeze) + +-=item $serialized = sfreeze_best $value +- + Often there is the need to serialize data into a string. This function does that, by using the Storable + module. It does the following transforms: + +@@ -76,13 +69,8 @@ anyways, it tries to compress the string. + The C<sfreeze> functions will enlarge the original data one byte at most + and will only load the Storable method when neccessary. + +-The C<sfreeze_best> function uses a different algorithm that is slower +-but usually achieves better compression. +- + =item $serialized = sfreeze_c $value (sfreeze and compress) + +-=item $serialized = sfreeze_c_best $value +- + Similar to C<sfreeze>, but always tries to C<c>ompress the resulting + string. This still leaves most small objects (most numbers) untouched. + +@@ -91,15 +79,10 @@ but usually achieves better compression. + + =item $serialized = sfreeze_cr $value (sfreeze and compress references) + +-=item $serialized = sfreeze_cr_best $value +- + Similar to C<sfreeze>, but tries to C<c>ompress the resulting string + unless it's a "simple" string. References for example are not "simple" and + as such are being compressed. + +-The C<sfreeze_cr_best> function uses a different algorithm that is slower +-but usually achieves better compression. +- + =item $original_data = sthaw $serialized + + Recreate the original object from it's serialized representation. This +@@ -119,6 +102,12 @@ This module supports the perl multicore specification + (Lhttp://perlmulticore.schmorp.de/) for all compression (> 2000 octets) and + decompression (> 4000 octets) functions. + ++=head1 NO SUPPORT FOR BEST METHODS ++ ++C<compress_best> and other L<_best> subroutines were removed because ++liblzf-3.6 does not yet support them. See ++Lhttps://bugzilla.redhat.com/show_bug.cgi?id=1268333. ++ + =head1 SEE ALSO + + Other Compress::* modules, especially Compress::LZV1 (an older, less +@@ -144,8 +133,8 @@ require DynaLoader; + $VERSION = 3.8; + @ISA = qw/Exporter DynaLoader/; + %EXPORT_TAGS = ( +- freeze => [qw(sfreeze sfreeze_best sfreeze_cr sfreeze_cr_best sfreeze_c sfreeze_c_best sthaw)], +- compress => [qw(compress compress_best decompress)], ++ freeze => [qw(sfreeze sfreeze_cr sfreeze_c sthaw)], ++ compress => [qw(compress decompress)], + ); + + Exporter::export_tags('compress'); +diff --git a/LZF.xs b/LZF.xs +index 8497868..2f6fd98 100644 +--- a/LZF.xs ++++ b/LZF.xs +@@ -7,10 +7,6 @@ + #define LZF_STANDALONE 1 + #define LZF_STATE_ARG 1 + +-#include "lzf_c.c" +-#include "lzf_d.c" +-#include "lzf_c_best.c" +- + /* we re-use the storable header for our purposes */ + #define MAGIC_LO 0 + #define MAGIC_U 0 /* uncompressed data follows */ +@@ -35,9 +31,8 @@ static CV *storable_mstore, *storable_mretrieve; + #endif + + static SV * +-compress_sv (SV *data, char cprepend, int uprepend, int best) ++compress_sv (SV *data, char cprepend, int uprepend) + { +- void *state; + STRLEN usize, csize; + char *src = (char *)SvPVbyte (data, usize); + +@@ -97,19 +92,8 @@ compress_sv (SV *data, char cprepend, int uprepend, int best) + + if (usize > 2000) perlinterp_release (); + +- state = malloc (best ? sizeof (LZF_STATE_BEST) : sizeof (LZF_STATE)); +- if (!state) +- { +- if (usize > 2000) perlinterp_acquire (); +- croak ("Compress::LZF unable to allocate memory for compression state"); +- } +- + /* 11 bytes is the smallest compressible string */ +- csize = usize < 11 ? 0 : +- (best ? lzf_compress_best (src, usize, dst + skip, usize - skip, *(LZF_STATE_BEST *)state) +- : lzf_compress (src, usize, dst + skip, usize - skip, *(LZF_STATE *)state)); +- +- free (state); ++ csize = usize < 11 ? 0 : lzf_compress (src, usize, dst + skip, usize - skip); + + if (usize > 2000) perlinterp_acquire (); + +@@ -267,11 +251,9 @@ set_serializer(package, mstore, mretrieve) + void + compress(data) + SV * data +- ALIAS: +- compress_best = 1 + PROTOTYPE: $ + PPCODE: +- XPUSHs (sv_2mortal (compress_sv (data, 0, MAGIC_U, ix))); ++ XPUSHs (sv_2mortal (compress_sv (data, 0, MAGIC_U))); + + void + decompress(data) +@@ -287,15 +269,9 @@ sfreeze(sv) + sfreeze = 0 + sfreeze_cr = 1 + sfreeze_c = 2 +- sfreeze_best = 4 +- sfreeze_cr_best = 5 +- sfreeze_c_best = 6 + PROTOTYPE: $ + PPCODE: + { +- int best = ix & 4; +- ix &= 3; +- + SvGETMAGIC (sv); + + if (!SvOK (sv)) +@@ -350,14 +326,14 @@ sfreeze(sv) + } + + if (ix) /* compress */ +- sv = sv_2mortal (compress_sv (sv, deref ? MAGIC_CR_deref : MAGIC_CR, -1, best)); ++ sv = sv_2mortal (compress_sv (sv, deref ? MAGIC_CR_deref : MAGIC_CR, -1)); + + XPUSHs (sv); + } + else if (SvPOKp (sv) && IN_RANGE (SvPVX (sv)[0], MAGIC_LO, MAGIC_HI)) +- XPUSHs (sv_2mortal (compress_sv (sv, MAGIC_C, MAGIC_U, best))); /* need to prefix only */ ++ XPUSHs (sv_2mortal (compress_sv (sv, MAGIC_C, MAGIC_U))); /* need to prefix only */ + else if (ix == 2) /* compress always */ +- XPUSHs (sv_2mortal (compress_sv (sv, MAGIC_C, -1, best))); ++ XPUSHs (sv_2mortal (compress_sv (sv, MAGIC_C, -1))); + else if (SvNIOK (sv)) /* don't compress */ + { + STRLEN len; +diff --git a/MANIFEST b/MANIFEST +index 1271ca3..05cb98f 100644 +--- a/MANIFEST ++++ b/MANIFEST +@@ -9,13 +9,8 @@ perlmulticore.h + t/00_load.t + t/01_run.t + t/02_freeze.t +-t/03_freeze_best.t + LZF.pm + LZF.xs +-lzfP.h +-lzf_c.c +-lzf_d.c +-lzf_c_best.c + + debian/control + debian/changelog +diff --git a/Makefile.PL b/Makefile.PL +index 49a6c43..e3717da 100644 +--- a/Makefile.PL ++++ b/Makefile.PL +@@ -10,7 +10,7 @@ WriteMakefile( + }, + 'NAME' => 'Compress::LZF', + 'VERSION_FROM' => 'LZF.pm', +- 'LIBS' => [''], ++ 'LIBS' => ['-llzf'], + 'DEFINE' => '', + 'INC' => '', + ); +diff --git a/lzfP.h b/lzfP.h +deleted file mode 100644 +index e325a83..0000000 +--- a/lzfP.h ++++ /dev/null +@@ -1,227 +0,0 @@ +-/* +- * Copyright (c) 2000-2007 Marc Alexander Lehmann schmorp@schmorp.de +- * +- * Redistribution and use in source and binary forms, with or without modifica- +- * tion, are permitted provided that the following conditions are met: +- * +- * 1. Redistributions of source code must retain the above copyright notice, +- * this list of conditions and the following disclaimer. +- * +- * 2. 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 AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- +- * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +- * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- +- * CIAL, 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 OTH- +- * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +- * OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * Alternatively, the contents of this file may be used under the terms of +- * the GNU General Public License ("GPL") version 2 or any later version, +- * in which case the provisions of the GPL are applicable instead of +- * the above. If you wish to allow the use of your version of this file +- * only under the terms of the GPL and not to allow others to use your +- * version of this file under the BSD license, indicate your decision +- * by deleting the provisions above and replace them with the notice +- * and other provisions required by the GPL. If you do not delete the +- * provisions above, a recipient may use your version of this file under +- * either the BSD or the GPL. +- */ +- +-#ifndef LZFP_h +-#define LZFP_h +- +-#define STANDALONE 1 /* at the moment, this is ok. */ +- +-#ifndef STANDALONE +-# include "lzf.h" +-#endif +- +-/* +- * Size of hashtable is (1 << HLOG) * sizeof (char *) +- * decompression is independent of the hash table size +- * the difference between 15 and 14 is very small +- * for small blocks (and 14 is usually a bit faster). +- * For a low-memory/faster configuration, use HLOG == 13; +- * For best compression, use 15 or 16 (or more, up to 22). +- */ +-#ifndef HLOG +-# define HLOG 16 +-#endif +- +-/* +- * Sacrifice very little compression quality in favour of compression speed. +- * This gives almost the same compression as the default code, and is +- * (very roughly) 15% faster. This is the preferred mode of operation. +- */ +-#ifndef VERY_FAST +-# define VERY_FAST 1 +-#endif +- +-/* +- * Sacrifice some more compression quality in favour of compression speed. +- * (roughly 1-2% worse compression for large blocks and +- * 9-10% for small, redundant, blocks and >>20% better speed in both cases) +- * In short: when in need for speed, enable this for binary data, +- * possibly disable this for text data. +- */ +-#ifndef ULTRA_FAST +-# define ULTRA_FAST 0 +-#endif +- +-/* +- * Unconditionally aligning does not cost very much, so do it if unsure +- */ +-#ifndef STRICT_ALIGN +-# define STRICT_ALIGN !(defined(__i386) || defined (__amd64)) +-#endif +- +-/* +- * You may choose to pre-set the hash table (might be faster on some +- * modern cpus and large (>>64k) blocks, and also makes compression +- * deterministic/repeatable when the configuration otherwise is the same). +- */ +-#ifndef INIT_HTAB +-# define INIT_HTAB 1 +-#endif +- +-/* +- * Avoid assigning values to errno variable? for some embedding purposes +- * (linux kernel for example), this is necessary. NOTE: this breaks +- * the documentation in lzf.h. Avoiding errno has no speed impact. +- */ +-#ifndef AVOID_ERRNO +-# define AVOID_ERRNO 0 +-#endif +- +-/* +- * Whether to pass the LZF_STATE variable as argument, or allocate it +- * on the stack. For small-stack environments, define this to 1. +- * NOTE: this breaks the prototype in lzf.h. +- */ +-#ifndef LZF_STATE_ARG +-# define LZF_STATE_ARG 0 +-#endif +- +-/* +- * Whether to add extra checks for input validity in lzf_decompress +- * and return EINVAL if the input stream has been corrupted. This +- * only shields against overflowing the input buffer and will not +- * detect most corrupted streams. +- * This check is not normally noticeable on modern hardware +- * (<1% slowdown), but might slow down older cpus considerably. +- */ +-#ifndef CHECK_INPUT +-# define CHECK_INPUT 1 +-#endif +- +-/* +- * Whether the target CPU has a slow multiplication. This affects +- * the default hash function for the compressor, and enables a slightly +- * worse hash function that needs only shifts. +- */ +-#ifndef MULTIPLICATION_IS_SLOW +-# define MULTIPLICATION_IS_SLOW 0 +-#endif +- +-/* +- * If defined, then this data type will be used for storing offsets. +- * This can be useful if you want to use a huge hashtable, want to +- * conserve memory, or both, and your data fits into e.g. 64kb. +- * If instead you want to compress data > 4GB, then it's better to +- * to "#define LZF_USE_OFFSETS 0" instead. +- */ +-/*#define LZF_HSLOT unsigned short*/ +- +-/* +- * Whether to store pointers or offsets inside the hash table. On +- * 64 bit architetcures, pointers take up twice as much space, +- * and might also be slower. Default is to autodetect. +- */ +-/*#define LZF_USE_OFFSETS autodetect */ +- +-/* +- * Whether to optimise code for size, at the expense of speed. Use +- * this when you are extremely tight on memory, perhaps in combination +- * with AVOID_ERRNO 1 and CHECK_INPUT 0. +- */ +-#ifndef OPTIMISE_SIZE +-# ifdef __OPTIMIZE_SIZE__ +-# define OPTIMISE_SIZE 1 +-# else +-# define OPTIMISE_SIZE 0 +-# endif +-#endif +- +-/*****************************************************************************/ +-/* nothing should be changed below */ +- +-#ifdef __cplusplus +-# include <cstring> +-# include <climits> +-using namespace std; +-#else +-# include <string.h> +-# include <limits.h> +-#endif +- +-#if ULTRA_FAST +-# undef VERY_FAST +-#endif +- +-#ifndef LZF_USE_OFFSETS +-# ifdef _WIN32 +-# define LZF_USE_OFFSETS defined(_M_X64) +-# else +-# if __cplusplus > 199711L +-# include <cstdint> +-# else +-# include <stdint.h> +-# endif +-# define LZF_USE_OFFSETS (UINTPTR_MAX > 0xffffffffU) +-# endif +-#endif +- +-typedef unsigned char u8; +- +-#ifdef LZF_HSLOT +-# define LZF_HSLOT_BIAS ((const u8 *)in_data) +-#else +-# if LZF_USE_OFFSETS +-# define LZF_HSLOT_BIAS ((const u8 *)in_data) +- typedef unsigned int LZF_HSLOT; +-# else +-# define LZF_HSLOT_BIAS 0 +- typedef const u8 *LZF_HSLOT; +-# endif +-#endif +- +-#if USHRT_MAX == 65535 +- typedef unsigned short u16; +-#elif UINT_MAX == 65535 +- typedef unsigned int u16; +-#else +-# undef STRICT_ALIGN +-# define STRICT_ALIGN 1 +-#endif +- +-#define LZF_MAX_LIT (1 << 5) +-#define LZF_MAX_OFF (1 << 13) +-#define LZF_MAX_REF ((1 << 8) + (1 << 3)) +- +-typedef LZF_HSLOT LZF_STATE[1 << (HLOG)]; +- +-typedef struct +-{ +- const u8 *first [1 << (6+8)]; /* most recent occurance of a match */ +- u16 prev [LZF_MAX_OFF]; /* how many bytes to go backwards for the next match */ +-} LZF_STATE_BEST[1]; +- +-#endif +- +diff --git a/lzf_c.c b/lzf_c.c +deleted file mode 100644 +index 1ca3fc0..0000000 +--- a/lzf_c.c ++++ /dev/null +@@ -1,292 +0,0 @@ +-/* +- * Copyright (c) 2000-2010,2012 Marc Alexander Lehmann schmorp@schmorp.de +- * +- * Redistribution and use in source and binary forms, with or without modifica- +- * tion, are permitted provided that the following conditions are met: +- * +- * 1. Redistributions of source code must retain the above copyright notice, +- * this list of conditions and the following disclaimer. +- * +- * 2. 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 AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- +- * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +- * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- +- * CIAL, 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 OTH- +- * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +- * OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * Alternatively, the contents of this file may be used under the terms of +- * the GNU General Public License ("GPL") version 2 or any later version, +- * in which case the provisions of the GPL are applicable instead of +- * the above. If you wish to allow the use of your version of this file +- * only under the terms of the GPL and not to allow others to use your +- * version of this file under the BSD license, indicate your decision +- * by deleting the provisions above and replace them with the notice +- * and other provisions required by the GPL. If you do not delete the +- * provisions above, a recipient may use your version of this file under +- * either the BSD or the GPL. +- */ +- +-#include "lzfP.h" +- +-#define HSIZE (1 << (HLOG)) +- +-/* +- * don't play with this unless you benchmark! +- * the data format is not dependent on the hash function. +- * the hash function might seem strange, just believe me, +- * it works ;) +- */ +-#ifndef FRST +-# define FRST(p) (((p[0]) << 8) | p[1]) +-# define NEXT(v,p) (((v) << 8) | p[2]) +-# if MULTIPLICATION_IS_SLOW +-# if ULTRA_FAST +-# define IDX(h) ((( h >> (3*8 - HLOG)) - h ) & (HSIZE - 1)) +-# elif VERY_FAST +-# define IDX(h) ((( h >> (3*8 - HLOG)) - h*5) & (HSIZE - 1)) +-# else +-# define IDX(h) ((((h ^ (h << 5)) >> (3*8 - HLOG)) - h*5) & (HSIZE - 1)) +-# endif +-# else +-/* this one was developed with sesse, +- * and is very similar to the one in snappy. +- * it does need a modern enough cpu with a fast multiplication. +- */ +-# define IDX(h) (((h * 0x1e35a7bdU) >> (32 - HLOG - 8)) & (HSIZE - 1)) +-# endif +-#endif +- +-#if 0 +-/* original lzv-like hash function, much worse and thus slower */ +-# define FRST(p) (p[0] << 5) ^ p[1] +-# define NEXT(v,p) ((v) << 5) ^ p[2] +-# define IDX(h) ((h) & (HSIZE - 1)) +-#endif +- +-#if __GNUC__ >= 3 +-# define expect(expr,value) __builtin_expect ((expr),(value)) +-# define inline inline +-#else +-# define expect(expr,value) (expr) +-# define inline static +-#endif +- +-#define expect_false(expr) expect ((expr) != 0, 0) +-#define expect_true(expr) expect ((expr) != 0, 1) +- +-/* +- * compressed format +- * +- * 000LLLLL <L+1> ; literal, L+1=1..33 octets +- * LLLooooo oooooooo ; backref L+1=1..7 octets, o+1=1..4096 offset +- * 111ooooo LLLLLLLL oooooooo ; backref L+8 octets, o+1=1..4096 offset +- * +- */ +- +-unsigned int +-lzf_compress (const void *const in_data, unsigned int in_len, +- void *out_data, unsigned int out_len +-#if LZF_STATE_ARG +- , LZF_STATE htab +-#endif +- ) +-{ +-#if !LZF_STATE_ARG +- LZF_STATE htab; +-#endif +- const u8 *ip = (const u8 *)in_data; +- u8 *op = (u8 *)out_data; +- const u8 *in_end = ip + in_len; +- u8 *out_end = op + out_len; +- const u8 *ref; +- +- /* off requires a type wide enough to hold a general pointer difference. +- * ISO C doesn't have that (size_t might not be enough and ptrdiff_t only +- * works for differences within a single object). We also assume that +- * no bit pattern traps. Since the only platform that is both non-POSIX +- * and fails to support both assumptions is windows 64 bit, we make a +- * special workaround for it. +- */ +-#if defined (_WIN32) && defined (_M_X64) +- /* workaround for missing POSIX compliance */ +- #if __GNUC__ +- unsigned long long off; +- #else +- unsigned __int64 off; +- #endif +-#else +- unsigned long off; +-#endif +- unsigned int hval; +- int lit; +- +- if (!in_len || !out_len) +- return 0; +- +-#if INIT_HTAB +- memset (htab, 0, sizeof (htab)); +-#endif +- +- lit = 0; op++; /* start run */ +- +- hval = FRST (ip); +- while (ip < in_end - 2) +- { +- LZF_HSLOT *hslot; +- +- hval = NEXT (hval, ip); +- hslot = htab + IDX (hval); +- ref = *hslot + LZF_HSLOT_BIAS; *hslot = ip - LZF_HSLOT_BIAS; +- +- if (1 +-#if INIT_HTAB +- && ref < ip /* the next test will actually take care of this, but this is faster */ +-#endif +- && (off = ip - ref - 1) < LZF_MAX_OFF +- && ref > (u8 *)in_data +- && ref[2] == ip[2] +-#if STRICT_ALIGN +- && ((ref[1] << 8) | ref[0]) == ((ip[1] << 8) | ip[0]) +-#else +- && *(u16 *)ref == *(u16 *)ip +-#endif +- ) +- { +- /* match found at *ref++ */ +- unsigned int len = 2; +- unsigned int maxlen = in_end - ip - len; +- maxlen = maxlen > LZF_MAX_REF ? LZF_MAX_REF : maxlen; +- +- if (expect_false (op + 3 + 1 >= out_end)) /* first a faster conservative test */ +- if (op - !lit + 3 + 1 >= out_end) /* second the exact but rare test */ +- return 0; +- +- op [- lit - 1] = lit - 1; /* stop run */ +- op -= !lit; /* undo run if length is zero */ +- +- for (;;) +- { +- if (expect_true (maxlen > 16)) +- { +- len++; if (ref [len] != ip [len]) break; +- len++; if (ref [len] != ip [len]) break; +- len++; if (ref [len] != ip [len]) break; +- len++; if (ref [len] != ip [len]) break; +- +- len++; if (ref [len] != ip [len]) break; +- len++; if (ref [len] != ip [len]) break; +- len++; if (ref [len] != ip [len]) break; +- len++; if (ref [len] != ip [len]) break; +- +- len++; if (ref [len] != ip [len]) break; +- len++; if (ref [len] != ip [len]) break; +- len++; if (ref [len] != ip [len]) break; +- len++; if (ref [len] != ip [len]) break; +- +- len++; if (ref [len] != ip [len]) break; +- len++; if (ref [len] != ip [len]) break; +- len++; if (ref [len] != ip [len]) break; +- len++; if (ref [len] != ip [len]) break; +- } +- +- do +- len++; +- while (len < maxlen && ref[len] == ip[len]); +- +- break; +- } +- +- len -= 2; /* len is now #octets - 1 */ +- ip++; +- +- if (len < 7) +- { +- *op++ = (off >> 8) + (len << 5); +- } +- else +- { +- *op++ = (off >> 8) + ( 7 << 5); +- *op++ = len - 7; +- } +- +- *op++ = off; +- +- lit = 0; op++; /* start run */ +- +- ip += len + 1; +- +- if (expect_false (ip >= in_end - 2)) +- break; +- +-#if ULTRA_FAST || VERY_FAST +- --ip; +-# if VERY_FAST && !ULTRA_FAST +- --ip; +-# endif +- hval = FRST (ip); +- +- hval = NEXT (hval, ip); +- htab[IDX (hval)] = ip - LZF_HSLOT_BIAS; +- ip++; +- +-# if VERY_FAST && !ULTRA_FAST +- hval = NEXT (hval, ip); +- htab[IDX (hval)] = ip - LZF_HSLOT_BIAS; +- ip++; +-# endif +-#else +- ip -= len + 1; +- +- do +- { +- hval = NEXT (hval, ip); +- htab[IDX (hval)] = ip - LZF_HSLOT_BIAS; +- ip++; +- } +- while (len--); +-#endif +- } +- else +- { +- /* one more literal byte we must copy */ +- if (expect_false (op >= out_end)) +- return 0; +- +- lit++; *op++ = *ip++; +- +- if (expect_false (lit == LZF_MAX_LIT)) +- { +- op [- lit - 1] = lit - 1; /* stop run */ +- lit = 0; op++; /* start run */ +- } +- } +- } +- +- if (op + 3 > out_end) /* at most 3 bytes can be missing here */ +- return 0; +- +- while (ip < in_end) +- { +- lit++; *op++ = *ip++; +- +- if (expect_false (lit == LZF_MAX_LIT)) +- { +- op [- lit - 1] = lit - 1; /* stop run */ +- lit = 0; op++; /* start run */ +- } +- } +- +- op [- lit - 1] = lit - 1; /* end run */ +- op -= !lit; /* undo run if length is zero */ +- +- return op - (u8 *)out_data; +-} +- +diff --git a/lzf_c_best.c b/lzf_c_best.c +deleted file mode 100644 +index a997966..0000000 +--- a/lzf_c_best.c ++++ /dev/null +@@ -1,212 +0,0 @@ +-/* +- * Copyright (c) 2000-2012 Marc Alexander Lehmann schmorp@schmorp.de +- * +- * Redistribution and use in source and binary forms, with or without modifica- +- * tion, are permitted provided that the following conditions are met: +- * +- * 1. Redistributions of source code must retain the above copyright notice, +- * this list of conditions and the following disclaimer. +- * +- * 2. 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 AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- +- * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +- * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- +- * CIAL, 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 OTH- +- * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +- * OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * Alternatively, the contents of this file may be used under the terms of +- * the GNU General Public License ("GPL") version 2 or any later version, +- * in which case the provisions of the GPL are applicable instead of +- * the above. If you wish to allow the use of your version of this file +- * only under the terms of the GPL and not to allow others to use your +- * version of this file under the BSD license, indicate your decision +- * by deleting the provisions above and replace them with the notice +- * and other provisions required by the GPL. If you do not delete the +- * provisions above, a recipient may use your version of this file under +- * either the BSD or the GPL. +- */ +- +-#include "lzfP.h" +- +-#define HASH(p) (p[0] << 6) ^ (p[1] << 3) ^ p[2] +- +-#if __GNUC__ >= 3 +-# define expect(expr,value) __builtin_expect ((expr),(value)) +-# define inline inline +-#else +-# define expect(expr,value) (expr) +-# define inline static +-#endif +- +-#define expect_false(expr) expect ((expr) != 0, 0) +-#define expect_true(expr) expect ((expr) != 0, 1) +- +-/* +- * compressed format +- * +- * 000LLLLL <L+1> ; literal, L+1=1..33 octets +- * LLLooooo oooooooo ; backref L+1=1..7 octets, o+1=1..4096 offset +- * 111ooooo LLLLLLLL oooooooo ; backref L+8 octets, o+1=1..4096 offset +- * +- */ +- +-unsigned int +-lzf_compress_best (const void *const in_data, unsigned int in_len, +- void *out_data, unsigned int out_len +-#if LZF_STATE_ARG +- , LZF_STATE_BEST state +-#endif +- ) +-{ +- const u8 *ip = (const u8 *)in_data; +- u8 *op = (u8 *)out_data; +- const u8 *in_end = ip + in_len; +- u8 *out_end = op + out_len; +- +-#if !LZF_STATE_ARG +- LZF_STATE_BEST state; +-#endif +-#define STATE state[0] +- +- int lit; +- +- if (!in_len || !out_len) +- return 0; +- +- lit = 0; op++; /* start run */ +- +- lit++; *op++ = *ip++; +- +- while (ip < in_end - 2) +- { +- int best_l = 0; +- const u8 *best_p; +- int e = (in_end - ip < LZF_MAX_REF ? in_end - ip : LZF_MAX_REF) - 1; +- unsigned int res = ((unsigned long)ip) & (LZF_MAX_OFF - 1); +- u16 hash = HASH (ip); +- u16 diff; +- const u8 *b = ip < (u8 *)in_data + LZF_MAX_OFF ? in_data : ip - LZF_MAX_OFF; +- const u8 *p = STATE.first [hash]; +- STATE.prev [res] = ip - p; /* update ptr to previous hash match */ +- STATE.first [hash] = ip; /* first hash match is here */ +- +- if (p < ip) +- while (p >= b) +- { +- if (p[2] == ip[2]) /* first two bytes almost always match */ +- if (p[best_l] == ip[best_l]) /* new match must be longer than the old one to qualify */ +- if (p[1] == ip[1] && p[0] == ip[0]) /* just to be sure */ +- { +- int l = 3; +- +- while (p[l] == ip[l] && l < e) +- ++l; +- +- if (l >= best_l) +- { +- best_p = p; +- best_l = l; +- } +- } +- +- diff = STATE.prev [((unsigned long)p) & (LZF_MAX_OFF - 1)]; +- p = diff ? p - diff : 0; +- } +- +- if (best_l) +- { +- int len = best_l; +- int off = ip - best_p - 1; +- +- if (expect_false (op + 3 + 1 >= out_end)) /* first a faster conservative test */ +- if (op - !lit + 3 + 1 >= out_end) /* second the exact but rare test */ +- return 0; +- +- op [- lit - 1] = lit - 1; /* stop run */ +- op -= !lit; /* undo run if length is zero */ +- +- len -= 2; /* len is now #octets - 1 */ +- ip++; +- +- if (len < 7) +- { +- *op++ = (off >> 8) + (len << 5); +- } +- else +- { +- *op++ = (off >> 8) + ( 7 << 5); +- *op++ = len - 7; +- } +- +- *op++ = off; +- +- lit = 0; op++; /* start run */ +- +- ip += len + 1; +- +- if (expect_false (ip >= in_end - 2)) +- break; +- +- ip -= len + 1; +- +- //printf (" fill %p for %d\n", ip, len);//D +- do +- { +- u16 hash = HASH (ip); +- res = ((unsigned long)ip) & (LZF_MAX_OFF - 1); +- +- p = STATE.first [hash]; +- STATE.prev [res] = ip - p; /* update ptr to previous hash match */ +- STATE.first [hash] = ip; /* first hash match is here */ +- +- ip++; +- } +- while (len--); +- } +- else +- { +- /* one more literal byte we must copy */ +- if (expect_false (op >= out_end)) +- return 0; +- +- lit++; *op++ = *ip++; +- +- if (expect_false (lit == LZF_MAX_LIT)) +- { +- op [- lit - 1] = lit - 1; /* stop run */ +- lit = 0; op++; /* start run */ +- } +- } +- } +- +- if (op + 3 > out_end) /* at most 3 bytes can be missing here */ +- return 0; +- +- while (ip < in_end) +- { +- lit++; *op++ = *ip++; +- +- if (expect_false (lit == LZF_MAX_LIT)) +- { +- op [- lit - 1] = lit - 1; /* stop run */ +- lit = 0; op++; /* start run */ +- } +- } +- +- op [- lit - 1] = lit - 1; /* end run */ +- op -= !lit; /* undo run if length is zero */ +- +- return op - (u8 *)out_data; +- +-#undef STATE +-} +- +- +diff --git a/lzf_d.c b/lzf_d.c +deleted file mode 100644 +index 91b21f0..0000000 +--- a/lzf_d.c ++++ /dev/null +@@ -1,194 +0,0 @@ +-/* +- * Copyright (c) 2000-2010 Marc Alexander Lehmann schmorp@schmorp.de +- * +- * Redistribution and use in source and binary forms, with or without modifica- +- * tion, are permitted provided that the following conditions are met: +- * +- * 1. Redistributions of source code must retain the above copyright notice, +- * this list of conditions and the following disclaimer. +- * +- * 2. 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 AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- +- * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +- * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- +- * CIAL, 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 OTH- +- * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +- * OF THE POSSIBILITY OF SUCH DAMAGE. +- * +- * Alternatively, the contents of this file may be used under the terms of +- * the GNU General Public License ("GPL") version 2 or any later version, +- * in which case the provisions of the GPL are applicable instead of +- * the above. If you wish to allow the use of your version of this file +- * only under the terms of the GPL and not to allow others to use your +- * version of this file under the BSD license, indicate your decision +- * by deleting the provisions above and replace them with the notice +- * and other provisions required by the GPL. If you do not delete the +- * provisions above, a recipient may use your version of this file under +- * either the BSD or the GPL. +- */ +- +-#include "lzfP.h" +- +-#if AVOID_ERRNO +-# define SET_ERRNO(n) +-#else +-# include <errno.h> +-# define SET_ERRNO(n) errno = (n) +-#endif +- +-#if USE_REP_MOVSB /* small win on amd, big loss on intel */ +-#if (__i386 || __amd64) && __GNUC__ >= 3 +-# define lzf_movsb(dst, src, len) \ +- asm ("rep movsb" \ +- : "=D" (dst), "=S" (src), "=c" (len) \ +- : "0" (dst), "1" (src), "2" (len)); +-#endif +-#endif +- +-unsigned int +-lzf_decompress (const void *const in_data, unsigned int in_len, +- void *out_data, unsigned int out_len) +-{ +- u8 const *ip = (const u8 *)in_data; +- u8 *op = (u8 *)out_data; +- u8 const *const in_end = ip + in_len; +- u8 *const out_end = op + out_len; +- +- do +- { +- unsigned int ctrl = *ip++; +- +- if (ctrl < (1 << 5)) /* literal run */ +- { +- ctrl++; +- +- if (op + ctrl > out_end) +- { +- SET_ERRNO (E2BIG); +- return 0; +- } +- +-#if CHECK_INPUT +- if (ip + ctrl > in_end) +- { +- SET_ERRNO (EINVAL); +- return 0; +- } +-#endif +- +-#ifdef lzf_movsb +- lzf_movsb (op, ip, ctrl); +-#elif OPTIMISE_SIZE +- while (ctrl--) +- *op++ = *ip++; +-#else +- switch (ctrl) +- { +- case 32: *op++ = *ip++; case 31: *op++ = *ip++; case 30: *op++ = *ip++; case 29: *op++ = *ip++; +- case 28: *op++ = *ip++; case 27: *op++ = *ip++; case 26: *op++ = *ip++; case 25: *op++ = *ip++; +- case 24: *op++ = *ip++; case 23: *op++ = *ip++; case 22: *op++ = *ip++; case 21: *op++ = *ip++; +- case 20: *op++ = *ip++; case 19: *op++ = *ip++; case 18: *op++ = *ip++; case 17: *op++ = *ip++; +- case 16: *op++ = *ip++; case 15: *op++ = *ip++; case 14: *op++ = *ip++; case 13: *op++ = *ip++; +- case 12: *op++ = *ip++; case 11: *op++ = *ip++; case 10: *op++ = *ip++; case 9: *op++ = *ip++; +- case 8: *op++ = *ip++; case 7: *op++ = *ip++; case 6: *op++ = *ip++; case 5: *op++ = *ip++; +- case 4: *op++ = *ip++; case 3: *op++ = *ip++; case 2: *op++ = *ip++; case 1: *op++ = *ip++; +- } +-#endif +- } +- else /* back reference */ +- { +- unsigned int len = ctrl >> 5; +- +- u8 *ref = op - ((ctrl & 0x1f) << 8) - 1; +- +-#if CHECK_INPUT +- if (ip >= in_end) +- { +- SET_ERRNO (EINVAL); +- return 0; +- } +-#endif +- if (len == 7) +- { +- len += *ip++; +-#if CHECK_INPUT +- if (ip >= in_end) +- { +- SET_ERRNO (EINVAL); +- return 0; +- } +-#endif +- } +- +- ref -= *ip++; +- +- if (op + len + 2 > out_end) +- { +- SET_ERRNO (E2BIG); +- return 0; +- } +- +- if (ref < (u8 *)out_data) +- { +- SET_ERRNO (EINVAL); +- return 0; +- } +- +-#ifdef lzf_movsb +- len += 2; +- lzf_movsb (op, ref, len); +-#elif OPTIMISE_SIZE +- len += 2; +- +- do +- *op++ = *ref++; +- while (--len); +-#else +- switch (len) +- { +- default: +- len += 2; +- +- if (op >= ref + len) +- { +- /* disjunct areas */ +- memcpy (op, ref, len); +- op += len; +- } +- else +- { +- /* overlapping, use octet by octet copying */ +- do +- *op++ = *ref++; +- while (--len); +- } +- +- break; +- +- case 9: *op++ = *ref++; +- case 8: *op++ = *ref++; +- case 7: *op++ = *ref++; +- case 6: *op++ = *ref++; +- case 5: *op++ = *ref++; +- case 4: *op++ = *ref++; +- case 3: *op++ = *ref++; +- case 2: *op++ = *ref++; +- case 1: *op++ = *ref++; +- case 0: *op++ = *ref++; /* two octets more */ +- *op++ = *ref++; +- } +-#endif +- } +- } +- while (ip < in_end); +- +- return op - (u8 *)out_data; +-} +- +diff --git a/t/03_freeze_best.t b/t/03_freeze_best.t +deleted file mode 100644 +index 9bdb8cc..0000000 +--- a/t/03_freeze_best.t ++++ /dev/null +@@ -1,59 +0,0 @@ +-BEGIN { +- eval "use Storable; 1" or do { +- print "1..0 # skip Storable module unavailable\n"; +- exit; +- }; +-} +- +-BEGIN { $| = 1; print "1..1959\n"; } +- +-END {print "not ok 1\n" unless $loaded;} +-use Compress::LZF ':freeze'; +-use Storable; +-$loaded = 1; +-print "ok 1\n"; +- +-$tst = 0; +- +-sub ok { +- print (($_[0] ? "ok " : "not ok "), 1+ ++$tst, "\n"); +-} +- +-sub chk { +- my $s = shift; +- my $n = sfreeze_best $s; ok(1); +- my $nr = sfreeze_cr_best $s; ok(1); +- my $nc = sfreeze_c_best $s; ok(1); +- my $r = sfreeze_best $s; ok(1); +- my $rr = sfreeze_cr_best$s; ok(1); +- my $rc = sfreeze_c_best $s; ok(1); +- +- ok (length ($n) >= length ($nc)); +- ok (length ($n) <= length ($r)); +- ok (length ($r) >= length ($rr)); +- ok ($rr eq $rc); +- ok (length ($r) >= length ($rr)); +- +- #print unpack("H*", $s), " => ", unpack("H*", $rc), "\n"; +- +- ok ($s eq sthaw $n); +- ok ($s eq sthaw $nr); +- ok ($s eq sthaw $nc); +- ok ($s eq ${sthaw $r}); +- ok ($s eq ${sthaw $rr}); +- ok ($s eq ${sthaw $rc}); +-} +- +-for my $pfx (0, 1, 4, 6, 7, 40, ord('x'), 240..255) { +- chk $pfx; +- $pfx =~ /(.*)/; +- chk $1; +- chk chr($pfx)."x"; +- chk chr($pfx)."xxxxxxxxxxxxx"; +- chk chr($pfx)."abcdefghijklm"; +-} +- +-ok (eval {sthaw undef; 1}); +-ok (!eval {sthaw "\x07"; 1}); +-ok (!defined sthaw sfreeze_best undef); +- +-- +2.4.3 + diff --git a/Compress-LZF-3.8-Unbundle-perlmulticore.patch b/Compress-LZF-3.8-Unbundle-perlmulticore.patch new file mode 100644 index 0000000..02bdaac --- /dev/null +++ b/Compress-LZF-3.8-Unbundle-perlmulticore.patch @@ -0,0 +1,449 @@ +From 5b3fd16594515047f5b9bd8f15865d0491e07369 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= ppisar@redhat.com +Date: Mon, 5 Oct 2015 16:07:17 +0200 +Subject: [PATCH] Unbundle perlmulticore +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Petr Písař ppisar@redhat.com +--- + LZF.xs | 2 +- + MANIFEST | 1 - + perlmulticore.h | 399 -------------------------------------------------------- + 3 files changed, 1 insertion(+), 401 deletions(-) + delete mode 100644 perlmulticore.h + +diff --git a/LZF.xs b/LZF.xs +index 2f6fd98..5d69122 100644 +--- a/LZF.xs ++++ b/LZF.xs +@@ -2,7 +2,7 @@ + #include "perl.h" + #include "XSUB.h" + +-#include "perlmulticore.h" ++#include <perlmulticore.h> + + #define LZF_STANDALONE 1 + #define LZF_STATE_ARG 1 +diff --git a/MANIFEST b/MANIFEST +index 05cb98f..227ee3d 100644 +--- a/MANIFEST ++++ b/MANIFEST +@@ -5,7 +5,6 @@ COPYING + COPYING.Artistic + COPYING.GNU + Makefile.PL +-perlmulticore.h + t/00_load.t + t/01_run.t + t/02_freeze.t +diff --git a/perlmulticore.h b/perlmulticore.h +deleted file mode 100644 +index 5c268f5..0000000 +--- a/perlmulticore.h ++++ /dev/null +@@ -1,399 +0,0 @@ +-/* +- * Author: Marc A. Lehmann xsthreadpool@schmorp.de +- * License: public domain, or where this is not possible/at your option, +- * CC0 (https://creativecommons.org/publicdomain/zero/1.0/) +- */ +- +-#ifndef PERL_MULTICORE_H +-#define PERL_MULTICORE_H +- +-/* +- +-=head1 NAME +- +-perlmulticore.h - the Perl Multicore Specification and Implementation +- +-=head1 SYNOPSIS +- +- #include "perlmultiore.h" +- +- // in your XS function: +- +- perlinterp_release (); +- do_the_C_thing (); +- perlinterp_acquire (); +- +-=head1 DESCRIPTION +- +-This header file implements a simple mechanism for XS modules to allow +-re-use of the perl interpreter for other threads while doing some lengthy +-operation, such as cryptography, SQL queries, disk I/O and so on. +- +-The design goals for this mechanism were to be simple to use, very +-efficient when not needed, low code and data size overhead and broad +-applicability. +- +-The newest version of this document can be found at +-Lhttp://pod.tst.eu/http://cvs.schmorp.de/Coro-Multicore/perlmulticore.h. +- +-The newest version of the header file itself, which +-includes this documentation, can be downloaded from +-Lhttp://cvs.schmorp.de/Coro-Multicore/perlmulticore.h. +- +-=head1 HOW DO I USE THIS IN MY MODULES? +- +-The usage is very simple - you include this header file in your XS module. Then, before you +-do your lengthy operation, you release the perl interpreter: +- +- perlinterp_release (); +- +-And when you are done with your computation, you acquire it again: +- +- perlinterp_acquire (); +- +-And that's it. This doesn't load any modules and consists of only a few +-machine instructions when no module to take advantage of it is loaded. +- +-Here is a simple example, an C<flock> wrapper implemented in XS. Unlike +-perl's built-in C<flock>, it allows other threads (for example, those +-provided by L<Coro>) to execute, instead of blocking the whole perl +-interpreter. For the sake of this example, it requires a file descriptor +-instead of a handle. +- +- #include "perlmulticore.h" // this header file +- +- // and in the XS portion +- int flock (int fd, int operation) +- CODE: +- perlinterp_release (); +- RETVAL = flock (fd, operation); +- perlinterp_acquire (); +- OUTPUT: +- RETVAL +- +-Another example would be to modify LDBD::mysql to allow other +-threads to execute while executing SQL queries. One way to do this +-is find all C<mysql_st_internal_execute> and similar calls (such as +-C<mysql_st_internal_execute41>), and adorn them with release/acquire +-calls: +- +- { +- perlinterp_release (); +- imp_sth->row_num= mysql_st_internal_execute(sth, ...); +- perlinterp_acquire (); +- } +- +-=head2 HOW ABOUT NOT-SO LONG WORK? +- +-Sometimes you don't know how long your code will take - in a compression +-library for example, compressing a few hundred Kilobyte of data can take +-a while, while 50 Bytes will compress so fast that even attempting to do +-something else could be more costly than just doing it. +- +-This is a very hard problem to solve. The best you can do at the moment is +-to release the perl interpreter only when you think the work to be done +-justifies the expense. +- +-As a rule of thumb, if you expect to need more than a few thousand cycles, +-you should release the interpreter, else you shouldn't. When in doubt, +-release. +- +-For example, in a compression library, you might want to do this: +- +- if (bytes_to_be_compressed > 2000) perlinterp_release (); +- do_compress (...); +- if (bytes_to_be_compressed > 2000) perlinterp_acquire (); +- +-Make sure the if conditions are exactly the same and don't change, so you +-always call acquire when you release, and vice versa. +- +-When you don't have a handy indicator, you might still do something +-useful. For example, if you do some file locking with C<fcntl> and you +-expect the lock to be available immediately in most cases, you could try +-with C<F_SETLK> (which doesn't wait), and only release/wait/acquire when +-the lock couldn't be set: +- +- int res = fcntl (fd, F_SETLK, &flock); +- +- if (res) +- { +- // error, assume lock is held by another process and do it the slow way +- perlinterp_release (); +- res = fcntl (fd, F_SETLKW, &flock); +- perlinterp_acquire (); +- } +- +-=head1 THE HARD AND FAST RULES +- +-As with everything, there are a number of rules to follow. +- +-=over 4 +- +-=item I<Never> touch any perl data structures after calling C<perlinterp_release>. +- +-Possibly the most important rule of them all, anything perl is +-completely off-limits after C<perlinterp_release>, until you call +-C<perlinterp_acquire>, after which you can access perl stuff again. +- +-That includes anything in the perl interpreter that you didn't prove to be +-safe, and didn't prove to be safe in older and future versions of perl: +-global variables, local perl scalars, even if you are sure nobody accesses +-them and you only try to "read" their value, and so on. +- +-If you need to access perl things, do it before releasing the +-interpreter with C<perlinterp_release>, or after acquiring it again with +-C<perlinterp_acquire>. +- +-=item I<Always> call C<perlinterp_release> and C<perlinterp_acquire> in pairs. +- +-For each C<perlinterp_release> call there must be a C<perlinterp_acquire> +-call. They don't have to be in the same function, and you can have +-multiple calls to them, as long as every C<perlinterp_release> call is +-followed by exactly one C<perlinterp_acquire> call. +- +-For example., this would be fine: +- +- perlinterp_release (); +- +- if (!function_that_fails_with_0_return_value ()) +- { +- perlinterp_acquire (); +- croak ("error"); +- // croak doesn't return +- } +- +- perlinterp_acquire (); +- // do other stuff +- +-=item I<Never> nest calls to C<perlinterp_release> and C<perlinterp_acquire>. +- +-That simply means that after calling C<perlinterp_release>, you must +-call C<perlinterp_acquire> before calling C<perlinterp_release> +-again. Likewise, after C<perlinterp_acquire>, you can call +-C<perlinterp_release> but not another C<perlinterp_acquire>. +- +-=item I<Always> call C<perlinterp_release> first. +- +-Also simple: you I<must not> call C<perlinterp_acquire> without having +-called C<perlinterp_release> before. +- +-=item I<Never> underestimate threads. +- +-While it's easy to add parallel execution ability to your XS module, it +-doesn't mean it is safe. After you release the perl interpreter, it's +-perfectly possible that it will call your XS function in another thread, +-even while your original function still executes. In other words: your C +-code must be thread safe, and if you use any library, that library must be +-thread-safe, too. +- +-Always assume that the code between C<perlinterp_release> and +-C<perlinterp_acquire> is executed in parallel on multiple CPUs at the same +-time. If your code can't cope with that, you could consider using a mutex +-to only allow one such execution, which is still better than blocking +-everybody else from doing anything: +- +- static pthread_mutex_t my_mutex = PTHREAD_MUTEX_INITIALIZER; +- +- perlinterp_release (); +- pthread_mutex_lock (&my_mutex); +- do_your_non_thread_safe_thing (); +- pthread_mutex_unlock (&my_mutex); +- perlinterp_acquire (); +- +-=item I<Don't> get confused by having to release first. +- +-In many real world scenarios, you acquire a resource, do something, then +-release it again. Don't let this confuse you, with this, you already own +-the resource (the perl interpreter) so you have to I<release> first, and +-I<acquire> it again later, not the other way around. +- +-=back +- +- +-=head1 DESIGN PRINCIPLES +- +-This section discusses how the design goals were reached (you be the +-judge), how it is implemented, and what overheads this implies. +- +-=over 4 +- +-=item Simple to Use +- +-All you have to do is identify the place in your existing code where you +-stop touching perl stuff, do your actual work, and start touching perl +-stuff again. +- +-Then slap C<perlinterp_release ()> and C<perlinterp_acquire ()> around the +-actual work code. +- +-You have to include F<perlmulticore.h> and distribute it with your XS +-code, but all these things border on the trivial. +- +-=item Very Efficient +- +-The definition for C<perlinterp_release> and C<perlinterp_release> is very +-short: +- +- #define perlinterp_release() perl_multicore_api->pmapi_release () +- #define perlinterp_acquire() perl_multicore_api->pmapi_acquire () +- +-Both are macros that read a pointer from memory (perl_multicore_api), +-dereference a function pointer stored at that place, and call the +-function, which takes no arguments and returns nothing. +- +-The first call to C<perlinterp_release> will check for the presence +-of any supporting module, and if none is loaded, will create a dummy +-implementation where both C<pmapi_release> and C<pmapi_acquire> execute +-this function: +- +- static void perl_multicore_nop (void) { } +- +-So in the case of no magical module being loaded, all calls except the +-first are two memory accesses and a predictable function call of an empty +-function. +- +-Of course, the overhead is much higher when these functions actually +-implement anything useful, but you always get what you pay for. +- +-With LCoro::Multicore, every release/acquire involves two pthread +-switches, two coro thread switches, a bunch of syscalls, and sometimes +-interacting with the event loop. +- +-A dedicated thread pool such as the one LIO::AIO uses could reduce +-these overheads, and would also reduce the dependencies (L<AnyEvent> is a +-smaller and more portable dependency than L<Coro>), but it would require a +-lot more work on the side of the module author wanting to support it than +-this solution. +- +-=item Low Code and Data Size Overhead +- +-On a 64 bit system, F<perlmulticore.h> uses exactly C<8> octets (one +-pointer) of your data segment, to store the C<perl_multicore_api> +-pointer. In addition it creates a C<16> octet perl string to store the +-function pointers in, and stores it in a hash provided by perl for this +-purpose. +- +-This is pretty much the equivalent of executing this code: +- +- $existing_hash{perl_multicore_api} = "123456781234567812345678"; +- +-And that's it, which is, as I think, indeed very little. +- +-As for code size, on my amd64 system, every call to C<perlinterp_release> +-or C<perlinterp_acquire> results in a variation of the following 9-10 +-octet sequence: +- +- 150> mov 0x200f23(%rip),%rax # <perl_multicore_api> +- 157> callq *0x8(%rax) +- +-The biggest part if the initialisation code, which consists of 11 lines of +-typical XS code. On my system, all the code in F<perlmulticore.h> compiles +-to less than 160 octets of read-only data. +- +-=item Broad Applicability +- +-While there are alternative ways to achieve the goal of parallel execution +-with threads that might be more efficient, this mechanism was chosen +-because it is very simple to retrofit existing modules with it, and it +- +-The design goals for this mechanism were to be simple to use, very +-efficient when not needed, low code and data size overhead and broad +-applicability. +- +-=back +- +- +-=head1 DISABLING PERL MULTICORE AT COMPILE TIME +- +-You can disable the complete perl multicore API by defining the +-symbol C<PERL_MULTICORE_DISABLE> to C<1> (e.g. by specifying +-F<-DPERL_MULTICORE_DISABLE> as compiler argument). +- +-This will leave no traces of the API in the compiled code, suitable +-"empty" C<perl_release> and C<perl_acquire> definitions will be provided. +- +-This could be added to perl's C<CPPFLAGS> when configuring perl on +-platforms that do not support threading at all for example. +- +- +-=head1 AUTHOR +- +- Marc A. Lehmann perlmulticore@schmorp.de +- http://perlmulticore.schmorp.de/ +- +-=head1 LICENSE +- +-The F<perlmulticore.h> header file is put into the public +-domain. Where this is legally not possible, or at your +-option, it can be licensed under creativecommons CC0 +-license: Lhttps://creativecommons.org/publicdomain/zero/1.0/. +- +-=cut +- +-*/ +- +-#define PERL_MULTICORE_MAJOR 1 /* bumped on incompatible changes */ +-#define PERL_MULTICORE_MINOR 0 /* bumped on every change */ +- +-#if PERL_MULTICORE_DISABLE +- +-#define perlinterp_release() do { } while (0) +-#define perlinterp_acquire() do { } while (0) +- +-#else +- +-/* this struct is shared between all modules, and currently */ +-/* contain only the two function pointers for release/acquire */ +-struct perl_multicore_api +-{ +- void (*pmapi_release)(void); +- void (*pmapi_acquire)(void); +-}; +- +-static void perl_multicore_init (void); +- +-const struct perl_multicore_api perl_multicore_api_init = { perl_multicore_init, abort }; +- +-static struct perl_multicore_api *perl_multicore_api +- = (struct perl_multicore_api *)&perl_multicore_api_init; +- +-#define perlinterp_release() perl_multicore_api->pmapi_release () +-#define perlinterp_acquire() perl_multicore_api->pmapi_acquire () +- +-/* this is the release/acquire implementation used as fallback */ +-static void +-perl_multicore_nop (void) +-{ +-} +- +-/* this is the initial implementation of "release" - it initialises */ +-/* the api and then calls the real release function */ +-static void +-perl_multicore_init (void) +-{ +- dTHX; +- +- /* check for existing API struct in PL_modglobal */ +- SV **api_svp = hv_fetch (PL_modglobal, "perl_multicore_api", sizeof ("perl_multicore_api") - 1, 1); +- +- if (SvPOKp (*api_svp)) +- perl_multicore_api = (struct perl_multicore_api *)SvPVX (*api_svp); /* we have one, use the existing one */ +- else +- { +- /* create a new one with a dummy nop implementation */ +- SV *api_sv = NEWSV (0, sizeof (*perl_multicore_api)); +- SvCUR_set (api_sv, sizeof (*perl_multicore_api)); +- SvPOK_only (api_sv); +- perl_multicore_api = (struct perl_multicore_api *)SvPVX (api_sv); +- perl_multicore_api->pmapi_release = +- perl_multicore_api->pmapi_acquire = perl_multicore_nop; +- *api_svp = api_sv; +- } +- +- /* call the real (or dummy) implementation now */ +- perlinterp_release (); +-} +- +-#endif +- +-#endif +-- +2.4.3 + diff --git a/compress_lzf_unbundle.patch b/compress_lzf_unbundle.patch deleted file mode 100644 index 4af62c1..0000000 --- a/compress_lzf_unbundle.patch +++ /dev/null @@ -1,1073 +0,0 @@ -diff -Naur old/lzf_c_best.c new/lzf_c_best.c ---- old/lzf_c_best.c 2013-08-26 04:03:41.000000000 +1000 -+++ new/lzf_c_best.c 1970-01-01 10:00:00.000000000 +1000 -@@ -1,207 +0,0 @@ --/* -- * Copyright (c) 2000-2012 Marc Alexander Lehmann schmorp@schmorp.de -- * -- * Redistribution and use in source and binary forms, with or without modifica- -- * tion, are permitted provided that the following conditions are met: -- * -- * 1. Redistributions of source code must retain the above copyright notice, -- * this list of conditions and the following disclaimer. -- * -- * 2. 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 AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- -- * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -- * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- -- * CIAL, 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 OTH- -- * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -- * OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * Alternatively, the contents of this file may be used under the terms of -- * the GNU General Public License ("GPL") version 2 or any later version, -- * in which case the provisions of the GPL are applicable instead of -- * the above. If you wish to allow the use of your version of this file -- * only under the terms of the GPL and not to allow others to use your -- * version of this file under the BSD license, indicate your decision -- * by deleting the provisions above and replace them with the notice -- * and other provisions required by the GPL. If you do not delete the -- * provisions above, a recipient may use your version of this file under -- * either the BSD or the GPL. -- */ -- --#include "lzfP.h" -- --#define HASH(p) (p[0] << 6) ^ (p[1] << 3) ^ p[2] -- --#define MAX_LIT (1 << 5) --#define MAX_OFF (1 << 13) --#define MAX_REF ((1 << 8) + (1 << 3)) -- --#if __GNUC__ >= 3 --# define expect(expr,value) __builtin_expect ((expr),(value)) --# define inline inline --#else --# define expect(expr,value) (expr) --# define inline static --#endif -- --#define expect_false(expr) expect ((expr) != 0, 0) --#define expect_true(expr) expect ((expr) != 0, 1) -- --/* -- * compressed format -- * -- * 000LLLLL <L+1> ; literal, L+1=1..33 octets -- * LLLooooo oooooooo ; backref L+1=1..7 octets, o+1=1..4096 offset -- * 111ooooo LLLLLLLL oooooooo ; backref L+8 octets, o+1=1..4096 offset -- * -- */ -- --unsigned int --lzf_compress_best (const void *const in_data, unsigned int in_len, -- void *out_data, unsigned int out_len) --{ -- const u8 *ip = (const u8 *)in_data; -- u8 *op = (u8 *)out_data; -- const u8 *in_end = ip + in_len; -- u8 *out_end = op + out_len; -- -- const u8 *first [1 << (6+8)]; /* most recent occurance of a match */ -- u16 prev [MAX_OFF]; /* how many bytes to go backwards for te next match */ -- -- int lit; -- -- if (!in_len || !out_len) -- return 0; -- -- lit = 0; op++; /* start run */ -- -- lit++; *op++ = *ip++; -- -- while (ip < in_end - 2) -- { -- int best_l = 0; -- const u8 *best_p; -- int e = (in_end - ip < MAX_REF ? in_end - ip : MAX_REF) - 1; -- unsigned int res = ((unsigned int)ip) & (MAX_OFF - 1); -- u16 hash = HASH (ip); -- u16 diff; -- const u8 *b = ip < (u8 *)in_data + MAX_OFF ? in_data : ip - MAX_OFF; -- const u8 *p = first [hash]; -- prev [res] = ip - p; /* update ptr to previous hash match */ -- first [hash] = ip; /* first hash match is here */ -- -- if (p < ip) -- while (p >= b) -- { -- if (p[2] == ip[2]) /* first two bytes almost always match */ -- if (p[best_l] == ip[best_l]) /* new match must be longer than the old one to qualify */ -- if (p[1] == ip[1] && p[0] == ip[0]) /* just to be sure */ -- { -- int l = 3; -- -- while (p[l] == ip[l] && l < e) -- ++l; -- -- if (l >= best_l) -- { -- best_p = p; -- best_l = l; -- } -- } -- -- diff = prev [((unsigned int)p) & (MAX_OFF - 1)]; -- p = diff ? p - diff : 0; -- } -- -- if (best_l) -- { -- int len = best_l; -- int off = ip - best_p - 1; -- -- if (expect_false (op + 3 + 1 >= out_end)) /* first a faster conservative test */ -- if (op - !lit + 3 + 1 >= out_end) /* second the exact but rare test */ -- return 0; -- -- op [- lit - 1] = lit - 1; /* stop run */ -- op -= !lit; /* undo run if length is zero */ -- -- len -= 2; /* len is now #octets - 1 */ -- ip++; -- -- if (len < 7) -- { -- *op++ = (off >> 8) + (len << 5); -- } -- else -- { -- *op++ = (off >> 8) + ( 7 << 5); -- *op++ = len - 7; -- } -- -- *op++ = off; -- -- lit = 0; op++; /* start run */ -- -- ip += len + 1; -- -- if (expect_false (ip >= in_end - 2)) -- break; -- -- ip -= len + 1; -- -- //printf (" fill %p for %d\n", ip, len);//D -- do -- { -- u16 hash = HASH (ip); -- res = ((unsigned int)ip) & (MAX_OFF - 1); -- -- p = first [hash]; -- prev [res] = ip - p; /* update ptr to previous hash match */ -- first [hash] = ip; /* first hash match is here */ -- -- ip++; -- } -- while (len--); -- } -- else -- { -- /* one more literal byte we must copy */ -- if (expect_false (op >= out_end)) -- return 0; -- -- lit++; *op++ = *ip++; -- -- if (expect_false (lit == MAX_LIT)) -- { -- op [- lit - 1] = lit - 1; /* stop run */ -- lit = 0; op++; /* start run */ -- } -- } -- } -- -- if (op + 3 > out_end) /* at most 3 bytes can be missing here */ -- return 0; -- -- while (ip < in_end) -- { -- lit++; *op++ = *ip++; -- -- if (expect_false (lit == MAX_LIT)) -- { -- op [- lit - 1] = lit - 1; /* stop run */ -- lit = 0; op++; /* start run */ -- } -- } -- -- op [- lit - 1] = lit - 1; /* end run */ -- op -= !lit; /* undo run if length is zero */ -- -- return op - (u8 *)out_data; --} -- -diff -Naur old/lzf_c.c new/lzf_c.c ---- old/lzf_c.c 2013-08-26 03:51:51.000000000 +1000 -+++ new/lzf_c.c 1970-01-01 10:00:00.000000000 +1000 -@@ -1,296 +0,0 @@ --/* -- * Copyright (c) 2000-2010,2012 Marc Alexander Lehmann schmorp@schmorp.de -- * -- * Redistribution and use in source and binary forms, with or without modifica- -- * tion, are permitted provided that the following conditions are met: -- * -- * 1. Redistributions of source code must retain the above copyright notice, -- * this list of conditions and the following disclaimer. -- * -- * 2. 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 AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- -- * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -- * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- -- * CIAL, 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 OTH- -- * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -- * OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * Alternatively, the contents of this file may be used under the terms of -- * the GNU General Public License ("GPL") version 2 or any later version, -- * in which case the provisions of the GPL are applicable instead of -- * the above. If you wish to allow the use of your version of this file -- * only under the terms of the GPL and not to allow others to use your -- * version of this file under the BSD license, indicate your decision -- * by deleting the provisions above and replace them with the notice -- * and other provisions required by the GPL. If you do not delete the -- * provisions above, a recipient may use your version of this file under -- * either the BSD or the GPL. -- */ -- --#include "lzfP.h" -- --#define HSIZE (1 << (HLOG)) -- --/* -- * don't play with this unless you benchmark! -- * the data format is not dependent on the hash function. -- * the hash function might seem strange, just believe me, -- * it works ;) -- */ --#ifndef FRST --# define FRST(p) (((p[0]) << 8) | p[1]) --# define NEXT(v,p) (((v) << 8) | p[2]) --# if MULTIPLICATION_IS_SLOW --# if ULTRA_FAST --# define IDX(h) ((( h >> (3*8 - HLOG)) - h ) & (HSIZE - 1)) --# elif VERY_FAST --# define IDX(h) ((( h >> (3*8 - HLOG)) - h*5) & (HSIZE - 1)) --# else --# define IDX(h) ((((h ^ (h << 5)) >> (3*8 - HLOG)) - h*5) & (HSIZE - 1)) --# endif --# else --/* this one was developed with sesse, -- * and is very similar to the one in snappy. -- * it does need a modern enough cpu with a fast multiplication. -- */ --# define IDX(h) (((h * 0x1e35a7bdU) >> (32 - HLOG - 8)) & (HSIZE - 1)) --# endif --#endif -- --#if 0 --/* original lzv-like hash function, much worse and thus slower */ --# define FRST(p) (p[0] << 5) ^ p[1] --# define NEXT(v,p) ((v) << 5) ^ p[2] --# define IDX(h) ((h) & (HSIZE - 1)) --#endif -- --#define MAX_LIT (1 << 5) --#define MAX_OFF (1 << 13) --#define MAX_REF ((1 << 8) + (1 << 3)) -- --#if __GNUC__ >= 3 --# define expect(expr,value) __builtin_expect ((expr),(value)) --# define inline inline --#else --# define expect(expr,value) (expr) --# define inline static --#endif -- --#define expect_false(expr) expect ((expr) != 0, 0) --#define expect_true(expr) expect ((expr) != 0, 1) -- --/* -- * compressed format -- * -- * 000LLLLL <L+1> ; literal, L+1=1..33 octets -- * LLLooooo oooooooo ; backref L+1=1..7 octets, o+1=1..4096 offset -- * 111ooooo LLLLLLLL oooooooo ; backref L+8 octets, o+1=1..4096 offset -- * -- */ -- --unsigned int --lzf_compress (const void *const in_data, unsigned int in_len, -- void *out_data, unsigned int out_len --#if LZF_STATE_ARG -- , LZF_STATE htab --#endif -- ) --{ --#if !LZF_STATE_ARG -- LZF_STATE htab; --#endif -- const u8 *ip = (const u8 *)in_data; -- u8 *op = (u8 *)out_data; -- const u8 *in_end = ip + in_len; -- u8 *out_end = op + out_len; -- const u8 *ref; -- -- /* off requires a type wide enough to hold a general pointer difference. -- * ISO C doesn't have that (size_t might not be enough and ptrdiff_t only -- * works for differences within a single object). We also assume that -- * no bit pattern traps. Since the only platform that is both non-POSIX -- * and fails to support both assumptions is windows 64 bit, we make a -- * special workaround for it. -- */ --#if defined (_WIN32) && defined (_M_X64) -- /* workaround for missing POSIX compliance */ -- #if __GNUC__ -- unsigned long long off; -- #else -- unsigned __int64 off; -- #endif --#else -- unsigned long off; --#endif -- unsigned int hval; -- int lit; -- -- if (!in_len || !out_len) -- return 0; -- --#if INIT_HTAB -- memset (htab, 0, sizeof (htab)); --#endif -- -- lit = 0; op++; /* start run */ -- -- hval = FRST (ip); -- while (ip < in_end - 2) -- { -- LZF_HSLOT *hslot; -- -- hval = NEXT (hval, ip); -- hslot = htab + IDX (hval); -- ref = *hslot + LZF_HSLOT_BIAS; *hslot = ip - LZF_HSLOT_BIAS; -- -- if (1 --#if INIT_HTAB -- && ref < ip /* the next test will actually take care of this, but this is faster */ --#endif -- && (off = ip - ref - 1) < MAX_OFF -- && ref > (u8 *)in_data -- && ref[2] == ip[2] --#if STRICT_ALIGN -- && ((ref[1] << 8) | ref[0]) == ((ip[1] << 8) | ip[0]) --#else -- && *(u16 *)ref == *(u16 *)ip --#endif -- ) -- { -- /* match found at *ref++ */ -- unsigned int len = 2; -- unsigned int maxlen = in_end - ip - len; -- maxlen = maxlen > MAX_REF ? MAX_REF : maxlen; -- -- if (expect_false (op + 3 + 1 >= out_end)) /* first a faster conservative test */ -- if (op - !lit + 3 + 1 >= out_end) /* second the exact but rare test */ -- return 0; -- -- op [- lit - 1] = lit - 1; /* stop run */ -- op -= !lit; /* undo run if length is zero */ -- -- for (;;) -- { -- if (expect_true (maxlen > 16)) -- { -- len++; if (ref [len] != ip [len]) break; -- len++; if (ref [len] != ip [len]) break; -- len++; if (ref [len] != ip [len]) break; -- len++; if (ref [len] != ip [len]) break; -- -- len++; if (ref [len] != ip [len]) break; -- len++; if (ref [len] != ip [len]) break; -- len++; if (ref [len] != ip [len]) break; -- len++; if (ref [len] != ip [len]) break; -- -- len++; if (ref [len] != ip [len]) break; -- len++; if (ref [len] != ip [len]) break; -- len++; if (ref [len] != ip [len]) break; -- len++; if (ref [len] != ip [len]) break; -- -- len++; if (ref [len] != ip [len]) break; -- len++; if (ref [len] != ip [len]) break; -- len++; if (ref [len] != ip [len]) break; -- len++; if (ref [len] != ip [len]) break; -- } -- -- do -- len++; -- while (len < maxlen && ref[len] == ip[len]); -- -- break; -- } -- -- len -= 2; /* len is now #octets - 1 */ -- ip++; -- -- if (len < 7) -- { -- *op++ = (off >> 8) + (len << 5); -- } -- else -- { -- *op++ = (off >> 8) + ( 7 << 5); -- *op++ = len - 7; -- } -- -- *op++ = off; -- -- lit = 0; op++; /* start run */ -- -- ip += len + 1; -- -- if (expect_false (ip >= in_end - 2)) -- break; -- --#if ULTRA_FAST || VERY_FAST -- --ip; --# if VERY_FAST && !ULTRA_FAST -- --ip; --# endif -- hval = FRST (ip); -- -- hval = NEXT (hval, ip); -- htab[IDX (hval)] = ip - LZF_HSLOT_BIAS; -- ip++; -- --# if VERY_FAST && !ULTRA_FAST -- hval = NEXT (hval, ip); -- htab[IDX (hval)] = ip - LZF_HSLOT_BIAS; -- ip++; --# endif --#else -- ip -= len + 1; -- -- do -- { -- hval = NEXT (hval, ip); -- htab[IDX (hval)] = ip - LZF_HSLOT_BIAS; -- ip++; -- } -- while (len--); --#endif -- } -- else -- { -- /* one more literal byte we must copy */ -- if (expect_false (op >= out_end)) -- return 0; -- -- lit++; *op++ = *ip++; -- -- if (expect_false (lit == MAX_LIT)) -- { -- op [- lit - 1] = lit - 1; /* stop run */ -- lit = 0; op++; /* start run */ -- } -- } -- } -- -- if (op + 3 > out_end) /* at most 3 bytes can be missing here */ -- return 0; -- -- while (ip < in_end) -- { -- lit++; *op++ = *ip++; -- -- if (expect_false (lit == MAX_LIT)) -- { -- op [- lit - 1] = lit - 1; /* stop run */ -- lit = 0; op++; /* start run */ -- } -- } -- -- op [- lit - 1] = lit - 1; /* end run */ -- op -= !lit; /* undo run if length is zero */ -- -- return op - (u8 *)out_data; --} -- -diff -Naur old/lzf_d.c new/lzf_d.c ---- old/lzf_d.c 2013-08-26 03:51:51.000000000 +1000 -+++ new/lzf_d.c 1970-01-01 10:00:00.000000000 +1000 -@@ -1,185 +0,0 @@ --/* -- * Copyright (c) 2000-2010 Marc Alexander Lehmann schmorp@schmorp.de -- * -- * Redistribution and use in source and binary forms, with or without modifica- -- * tion, are permitted provided that the following conditions are met: -- * -- * 1. Redistributions of source code must retain the above copyright notice, -- * this list of conditions and the following disclaimer. -- * -- * 2. 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 AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- -- * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -- * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- -- * CIAL, 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 OTH- -- * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -- * OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * Alternatively, the contents of this file may be used under the terms of -- * the GNU General Public License ("GPL") version 2 or any later version, -- * in which case the provisions of the GPL are applicable instead of -- * the above. If you wish to allow the use of your version of this file -- * only under the terms of the GPL and not to allow others to use your -- * version of this file under the BSD license, indicate your decision -- * by deleting the provisions above and replace them with the notice -- * and other provisions required by the GPL. If you do not delete the -- * provisions above, a recipient may use your version of this file under -- * either the BSD or the GPL. -- */ -- --#include "lzfP.h" -- --#if AVOID_ERRNO --# define SET_ERRNO(n) --#else --# include <errno.h> --# define SET_ERRNO(n) errno = (n) --#endif -- --#if USE_REP_MOVSB /* small win on amd, big loss on intel */ --#if (__i386 || __amd64) && __GNUC__ >= 3 --# define lzf_movsb(dst, src, len) \ -- asm ("rep movsb" \ -- : "=D" (dst), "=S" (src), "=c" (len) \ -- : "0" (dst), "1" (src), "2" (len)); --#endif --#endif -- --unsigned int --lzf_decompress (const void *const in_data, unsigned int in_len, -- void *out_data, unsigned int out_len) --{ -- u8 const *ip = (const u8 *)in_data; -- u8 *op = (u8 *)out_data; -- u8 const *const in_end = ip + in_len; -- u8 *const out_end = op + out_len; -- -- do -- { -- unsigned int ctrl = *ip++; -- -- if (ctrl < (1 << 5)) /* literal run */ -- { -- ctrl++; -- -- if (op + ctrl > out_end) -- { -- SET_ERRNO (E2BIG); -- return 0; -- } -- --#if CHECK_INPUT -- if (ip + ctrl > in_end) -- { -- SET_ERRNO (EINVAL); -- return 0; -- } --#endif -- --#ifdef lzf_movsb -- lzf_movsb (op, ip, ctrl); --#else -- switch (ctrl) -- { -- case 32: *op++ = *ip++; case 31: *op++ = *ip++; case 30: *op++ = *ip++; case 29: *op++ = *ip++; -- case 28: *op++ = *ip++; case 27: *op++ = *ip++; case 26: *op++ = *ip++; case 25: *op++ = *ip++; -- case 24: *op++ = *ip++; case 23: *op++ = *ip++; case 22: *op++ = *ip++; case 21: *op++ = *ip++; -- case 20: *op++ = *ip++; case 19: *op++ = *ip++; case 18: *op++ = *ip++; case 17: *op++ = *ip++; -- case 16: *op++ = *ip++; case 15: *op++ = *ip++; case 14: *op++ = *ip++; case 13: *op++ = *ip++; -- case 12: *op++ = *ip++; case 11: *op++ = *ip++; case 10: *op++ = *ip++; case 9: *op++ = *ip++; -- case 8: *op++ = *ip++; case 7: *op++ = *ip++; case 6: *op++ = *ip++; case 5: *op++ = *ip++; -- case 4: *op++ = *ip++; case 3: *op++ = *ip++; case 2: *op++ = *ip++; case 1: *op++ = *ip++; -- } --#endif -- } -- else /* back reference */ -- { -- unsigned int len = ctrl >> 5; -- -- u8 *ref = op - ((ctrl & 0x1f) << 8) - 1; -- --#if CHECK_INPUT -- if (ip >= in_end) -- { -- SET_ERRNO (EINVAL); -- return 0; -- } --#endif -- if (len == 7) -- { -- len += *ip++; --#if CHECK_INPUT -- if (ip >= in_end) -- { -- SET_ERRNO (EINVAL); -- return 0; -- } --#endif -- } -- -- ref -= *ip++; -- -- if (op + len + 2 > out_end) -- { -- SET_ERRNO (E2BIG); -- return 0; -- } -- -- if (ref < (u8 *)out_data) -- { -- SET_ERRNO (EINVAL); -- return 0; -- } -- --#ifdef lzf_movsb -- len += 2; -- lzf_movsb (op, ref, len); --#else -- switch (len) -- { -- default: -- len += 2; -- -- if (op >= ref + len) -- { -- /* disjunct areas */ -- memcpy (op, ref, len); -- op += len; -- } -- else -- { -- /* overlapping, use octte by octte copying */ -- do -- *op++ = *ref++; -- while (--len); -- } -- -- break; -- -- case 9: *op++ = *ref++; -- case 8: *op++ = *ref++; -- case 7: *op++ = *ref++; -- case 6: *op++ = *ref++; -- case 5: *op++ = *ref++; -- case 4: *op++ = *ref++; -- case 3: *op++ = *ref++; -- case 2: *op++ = *ref++; -- case 1: *op++ = *ref++; -- case 0: *op++ = *ref++; /* two octets more */ -- *op++ = *ref++; -- } --#endif -- } -- } -- while (ip < in_end); -- -- return op - (u8 *)out_data; --} -- -diff -Naur old/lzfP.h new/lzfP.h ---- old/lzfP.h 2013-08-26 03:51:51.000000000 +1000 -+++ new/lzfP.h 1970-01-01 10:00:00.000000000 +1000 -@@ -1,204 +0,0 @@ --/* -- * Copyright (c) 2000-2007 Marc Alexander Lehmann schmorp@schmorp.de -- * -- * Redistribution and use in source and binary forms, with or without modifica- -- * tion, are permitted provided that the following conditions are met: -- * -- * 1. Redistributions of source code must retain the above copyright notice, -- * this list of conditions and the following disclaimer. -- * -- * 2. 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 AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED -- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- -- * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -- * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- -- * CIAL, 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 OTH- -- * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -- * OF THE POSSIBILITY OF SUCH DAMAGE. -- * -- * Alternatively, the contents of this file may be used under the terms of -- * the GNU General Public License ("GPL") version 2 or any later version, -- * in which case the provisions of the GPL are applicable instead of -- * the above. If you wish to allow the use of your version of this file -- * only under the terms of the GPL and not to allow others to use your -- * version of this file under the BSD license, indicate your decision -- * by deleting the provisions above and replace them with the notice -- * and other provisions required by the GPL. If you do not delete the -- * provisions above, a recipient may use your version of this file under -- * either the BSD or the GPL. -- */ -- --#ifndef LZFP_h --#define LZFP_h -- --#define STANDALONE 1 /* at the moment, this is ok. */ -- --#ifndef STANDALONE --# include "lzf.h" --#endif -- --/* -- * Size of hashtable is (1 << HLOG) * sizeof (char *) -- * decompression is independent of the hash table size -- * the difference between 15 and 14 is very small -- * for small blocks (and 14 is usually a bit faster). -- * For a low-memory/faster configuration, use HLOG == 13; -- * For best compression, use 15 or 16 (or more, up to 22). -- */ --#ifndef HLOG --# define HLOG 16 --#endif -- --/* -- * Sacrifice very little compression quality in favour of compression speed. -- * This gives almost the same compression as the default code, and is -- * (very roughly) 15% faster. This is the preferred mode of operation. -- */ --#ifndef VERY_FAST --# define VERY_FAST 1 --#endif -- --/* -- * Sacrifice some more compression quality in favour of compression speed. -- * (roughly 1-2% worse compression for large blocks and -- * 9-10% for small, redundant, blocks and >>20% better speed in both cases) -- * In short: when in need for speed, enable this for binary data, -- * possibly disable this for text data. -- */ --#ifndef ULTRA_FAST --# define ULTRA_FAST 0 --#endif -- --/* -- * Unconditionally aligning does not cost very much, so do it if unsure -- */ --#ifndef STRICT_ALIGN --# define STRICT_ALIGN !(defined(__i386) || defined (__amd64)) --#endif -- --/* -- * You may choose to pre-set the hash table (might be faster on some -- * modern cpus and large (>>64k) blocks, and also makes compression -- * deterministic/repeatable when the configuration otherwise is the same). -- */ --#ifndef INIT_HTAB --# define INIT_HTAB 1 --#endif -- --/* -- * Avoid assigning values to errno variable? for some embedding purposes -- * (linux kernel for example), this is necessary. NOTE: this breaks -- * the documentation in lzf.h. Avoiding errno has no speed impact. -- */ --#ifndef AVOID_ERRNO --# define AVOID_ERRNO 0 --#endif -- --/* -- * Whether to pass the LZF_STATE variable as argument, or allocate it -- * on the stack. For small-stack environments, define this to 1. -- * NOTE: this breaks the prototype in lzf.h. -- */ --#ifndef LZF_STATE_ARG --# define LZF_STATE_ARG 0 --#endif -- --/* -- * Whether to add extra checks for input validity in lzf_decompress -- * and return EINVAL if the input stream has been corrupted. This -- * only shields against overflowing the input buffer and will not -- * detect most corrupted streams. -- * This check is not normally noticeable on modern hardware -- * (<1% slowdown), but might slow down older cpus considerably. -- */ --#ifndef CHECK_INPUT --# define CHECK_INPUT 1 --#endif -- --/* -- * Whether the target CPU has a slow multiplication. This affects -- * the default hash function for the compressor, and enables a slightly -- * worse hash function that needs only shifts. -- */ --#ifndef MULTIPLICATION_IS_SLOW --# define MULTIPLICATION_IS_SLOW 0 --#endif -- --/* -- * If defined, then this data type will be used for storing offsets. -- * This can be useful if you want to use a huge hashtable, want to -- * conserve memory, or both, and your data fits into e.g. 64kb. -- * If instead you want to compress data > 4GB, then it's better to -- * to "#define LZF_USE_OFFSETS 0" instead. -- */ --/*#define LZF_HSLOT unsigned short*/ -- --/* -- * Whether to store pointers or offsets inside the hash table. On -- * 64 bit architetcures, pointers take up twice as much space, -- * and might also be slower. Default is to autodetect. -- */ --/*#define LZF_USE_OFFSETS autodetect */ -- --/*****************************************************************************/ --/* nothing should be changed below */ -- --#ifdef __cplusplus --# include <cstring> --# include <climits> --using namespace std; --#else --# include <string.h> --# include <limits.h> --#endif -- --#ifndef LZF_USE_OFFSETS --# ifdef _WIN32 --# define LZF_USE_OFFSETS defined(_M_X64) --# else --# if __cplusplus > 199711L --# include <cstdint> --# else --# include <stdint.h> --# endif --# define LZF_USE_OFFSETS (UINTPTR_MAX > 0xffffffffU) --# endif --#endif -- --typedef unsigned char u8; -- --#ifdef LZF_HSLOT --# define LZF_HSLOT_BIAS ((const u8 *)in_data) --#else --# if LZF_USE_OFFSETS --# define LZF_HSLOT_BIAS ((const u8 *)in_data) -- typedef unsigned int LZF_HSLOT; --# else --# define LZF_HSLOT_BIAS 0 -- typedef const u8 *LZF_HSLOT; --# endif --#endif -- --typedef LZF_HSLOT LZF_STATE[1 << (HLOG)]; -- --#if USHRT_MAX == 65535 -- typedef unsigned short u16; --#elif UINT_MAX == 65535 -- typedef unsigned int u16; --#else --# undef STRICT_ALIGN --# define STRICT_ALIGN 1 --#endif -- --#if ULTRA_FAST --# undef VERY_FAST --#endif -- --#endif -- -diff -Naur old/LZF.xs new/LZF.xs ---- old/LZF.xs 2013-08-26 04:08:35.000000000 +1000 -+++ new/LZF.xs 2014-04-10 20:14:09.423267181 +1000 -@@ -5,10 +5,6 @@ - #define LZF_STANDALONE 1 - #define LZF_STATE_ARG 1 - --#include "lzf_c.c" --#include "lzf_d.c" --#include "lzf_c_best.c" -- - /* we re-use the storable header for our purposes */ - #define MAGIC_LO 0 - #define MAGIC_U 0 /* uncompressed data follows */ -@@ -33,9 +29,8 @@ - #endif - - static SV * --compress_sv (SV *data, char cprepend, int uprepend, int best) -+compress_sv (SV *data, char cprepend, int uprepend) - { -- LZF_STATE *state; - STRLEN usize, csize; - char *src = (char *)SvPVbyte (data, usize); - -@@ -93,16 +88,8 @@ - else - croak ("compress can only compress up to %ld bytes", 0x7fffffffL); - -- New (0, state, 1, LZF_STATE); -- if (!state) -- croak ("Compress::LZF unable to allocate memory for compression state"); -- - /* 11 bytes is the smallest compressible string */ -- csize = usize < 11 ? 0 : -- (best ? lzf_compress_best (src, usize, dst + skip, usize - skip) -- : lzf_compress (src, usize, dst + skip, usize - skip, *state)); -- -- Safefree (state); -+ csize = usize < 11 ? 0 : lzf_compress (src, usize, dst + skip, usize - skip); - - if (csize) - { -@@ -253,11 +240,9 @@ - void - compress(data) - SV * data -- ALIAS: -- compress_best = 1 - PROTOTYPE: $ - PPCODE: -- XPUSHs (sv_2mortal (compress_sv (data, 0, MAGIC_U, ix))); -+ XPUSHs (sv_2mortal (compress_sv (data, 0, MAGIC_U))); - - void - decompress(data) -@@ -273,15 +258,9 @@ - sfreeze = 0 - sfreeze_cr = 1 - sfreeze_c = 2 -- sfreeze_best = 4 -- sfreeze_cr_best = 5 -- sfreeze_c_best = 6 - PROTOTYPE: $ - PPCODE: - { -- int best = ix & 4; -- ix &= 3; -- - SvGETMAGIC (sv); - - if (!SvOK (sv)) -@@ -336,14 +315,14 @@ - } - - if (ix) /* compress */ -- sv = sv_2mortal (compress_sv (sv, deref ? MAGIC_CR_deref : MAGIC_CR, -1, best)); -+ sv = sv_2mortal (compress_sv (sv, deref ? MAGIC_CR_deref : MAGIC_CR, -1)); - - XPUSHs (sv); - } - else if (SvPOKp (sv) && IN_RANGE (SvPVX (sv)[0], MAGIC_LO, MAGIC_HI)) -- XPUSHs (sv_2mortal (compress_sv (sv, MAGIC_C, MAGIC_U, best))); /* need to prefix only */ -+ XPUSHs (sv_2mortal (compress_sv (sv, MAGIC_C, MAGIC_U))); /* need to prefix only */ - else if (ix == 2) /* compress always */ -- XPUSHs (sv_2mortal (compress_sv (sv, MAGIC_C, -1, best))); -+ XPUSHs (sv_2mortal (compress_sv (sv, MAGIC_C, -1))); - else if (SvNIOK (sv)) /* don't compress */ - { - STRLEN len; -diff -Naur old/Makefile.PL new/Makefile.PL ---- old/Makefile.PL 2010-06-01 13:31:02.000000000 +1000 -+++ new/Makefile.PL 2014-04-10 20:10:18.746011784 +1000 -@@ -10,7 +10,7 @@ - }, - 'NAME' => 'Compress::LZF', - 'VERSION_FROM' => 'LZF.pm', -- 'LIBS' => [''], -+ 'LIBS' => ['-llzf'], - 'DEFINE' => '', - 'INC' => '', - ); -diff -Naur old/t/03_freeze_best.t new/t/03_freeze_best.t ---- old/t/03_freeze_best.t 2013-08-26 04:09:36.000000000 +1000 -+++ new/t/03_freeze_best.t 1970-01-01 10:00:00.000000000 +1000 -@@ -1,59 +0,0 @@ --BEGIN { -- eval "use Storable; 1" or do { -- print "1..0 # skip Storable module unavailable\n"; -- exit; -- }; --} -- --BEGIN { $| = 1; print "1..1959\n"; } -- --END {print "not ok 1\n" unless $loaded;} --use Compress::LZF ':freeze'; --use Storable; --$loaded = 1; --print "ok 1\n"; -- --$tst = 0; -- --sub ok { -- print (($_[0] ? "ok " : "not ok "), 1+ ++$tst, "\n"); --} -- --sub chk { -- my $s = shift; -- my $n = sfreeze_best $s; ok(1); -- my $nr = sfreeze_cr_best $s; ok(1); -- my $nc = sfreeze_c_best $s; ok(1); -- my $r = sfreeze_best $s; ok(1); -- my $rr = sfreeze_cr_best$s; ok(1); -- my $rc = sfreeze_c_best $s; ok(1); -- -- ok (length ($n) >= length ($nc)); -- ok (length ($n) <= length ($r)); -- ok (length ($r) >= length ($rr)); -- ok ($rr eq $rc); -- ok (length ($r) >= length ($rr)); -- -- #print unpack("H*", $s), " => ", unpack("H*", $rc), "\n"; -- -- ok ($s eq sthaw $n); -- ok ($s eq sthaw $nr); -- ok ($s eq sthaw $nc); -- ok ($s eq ${sthaw $r}); -- ok ($s eq ${sthaw $rr}); -- ok ($s eq ${sthaw $rc}); --} -- --for my $pfx (0, 1, 4, 6, 7, 40, ord('x'), 240..255) { -- chk $pfx; -- $pfx =~ /(.*)/; -- chk $1; -- chk chr($pfx)."x"; -- chk chr($pfx)."xxxxxxxxxxxxx"; -- chk chr($pfx)."abcdefghijklm"; --} -- --ok (eval {sthaw undef; 1}); --ok (!eval {sthaw "\x07"; 1}); --ok (!defined sthaw sfreeze_best undef); -- diff --git a/perl-Compress-LZF.spec b/perl-Compress-LZF.spec index 12d1fa5..dcac4e2 100644 --- a/perl-Compress-LZF.spec +++ b/perl-Compress-LZF.spec @@ -1,51 +1,64 @@ Name: perl-Compress-LZF -Version: 3.7 -Release: 6%{?dist} +Version: 3.8 +Release: 1%{?dist} Summary: Extremely light-weight Lempel-Ziv-Free compression -License: GPL+ or Artistic +# TODO: Unbundle perlmulticore.h +# perlmulticore.h: Public Domain or CC0 +# Other files: GPL+ or Artistic +## Not in the binary packages +# liblzf files: BSD or GPLv2+ +License: (GPL+ or Artistic) and (Public Domain or CC0) # patch to address https://fedoraproject.org/wiki/Common_Rpmlint_issues#incorrect-fsf-address has been sent upstream at https://rt.cpan.org/Ticket/Display.html?id=93643 Group: Development/Libraries URL: http://search.cpan.org/dist/Compress-LZF/ Source0: http://www.cpan.org/modules/by-module/Compress/Compress-LZF-%%7Bversion%7D.t... -Patch1: compress_lzf_unbundle.patch +Patch0: Compress-LZF-3.8-Unbundle-liblzf.patch +# Unbundle perlmulticore.h +Patch1: Compress-LZF-3.8-Unbundle-perlmulticore.patch +BuildRequires: coreutils +BuildRequires: findutils BuildRequires: liblzf-devel +BuildRequires: make BuildRequires: perl +BuildRequires: perlmulticore-static BuildRequires: perl(DynaLoader) BuildRequires: perl(Exporter) BuildRequires: perl(ExtUtils::MakeMaker) BuildRequires: perl(Storable) -Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version)) +Requires: perl(:MODULE_COMPAT_%(eval "`perl -V:version`"; echo $version))
%description This is Perl binding to the LZF compression library.
%prep %setup -q -n Compress-LZF-%{version} - +%patch0 -p1 %patch1 -p1
%build -%{__perl} Makefile.PL INSTALLDIRS=vendor OPTIMIZE="$RPM_OPT_FLAGS" +perl Makefile.PL INSTALLDIRS=vendor OPTIMIZE="$RPM_OPT_FLAGS" make %{?_smp_mflags}
%install -make pure_install PERL_INSTALL_ROOT=$RPM_BUILD_ROOT - +make pure_install DESTDIR=$RPM_BUILD_ROOT find $RPM_BUILD_ROOT -type f -name .packlist -exec rm -f {} ; find $RPM_BUILD_ROOT -type f -name '*.bs' -size 0 -exec rm -f {} ; - %{_fixperms} $RPM_BUILD_ROOT/*
%check make test
%files -%doc Changes COPYING COPYING.Artistic COPYING.GNU README +%license COPYING COPYING.Artistic COPYING.GNU +%doc Changes README %{perl_vendorarch}/auto/* %{perl_vendorarch}/Compress* %{_mandir}/man3/*
%changelog +* Fri Oct 02 2015 Petr Pisar ppisar@redhat.com - 3.8-1 +- 3.8 bump + * Thu Jun 18 2015 Fedora Release Engineering rel-eng@lists.fedoraproject.org - 3.7-6 - Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
diff --git a/sources b/sources index 56cdd04..e3efeb4 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -a23ffab4875d4cff4795023c95a5360f Compress-LZF-3.7.tar.gz +c6c4c09d288fd040782eb7edfc39b015 Compress-LZF-3.8.tar.gz
perl-devel@lists.fedoraproject.org