From: gregor herrmann Date: Mon, 20 Oct 2014 16:18:46 +0000 (+0200) Subject: Imported Upstream version 3.003 X-Git-Tag: archive/raspbian/4.017+ds-1+rpi1~1^2~3^2~13 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=4eb97a35da64d5b6550d060052c76305b5a8cdfe;p=libsereal-encoder-perl.git Imported Upstream version 3.003 --- diff --git a/Changes b/Changes index 100a37d..c6fb20f 100644 --- a/Changes +++ b/Changes @@ -3,11 +3,13 @@ Revision history for Perl extension Sereal-Encoder * Warning: For a seamless upgrade, upgrade to version 3 * of the decoder before upgrading to version 3 of the * encoder! -3.002_001 Sept 26, 2014 +3.003 Oct 19 2014 * Niko Tyni fixed the 64-bit big endian Sereal bug! (Yay Niko!) * Setup META.yml correctly so that certain dependencies are marked as being test dependencies and not build or run-time dependencies. + * Allow one to build against an externally supplied version + of csnappy or miniz. Thanks to Petr Písař 3.002 Aug 20 2014 Summary of changes from 3.001 - 3.002 diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..7a21163 --- /dev/null +++ b/INSTALL @@ -0,0 +1,18 @@ +Install with + + perl Makefile.PL + make + make test + make instal + +By default the module will detect and use system versions of the miniz +and csnappy libraries during build and install. You can override this +by setting the SEREAL_USE_BUNDLED_LIBS to true, or you can override +it on a case by case basis by setting SEREAL_USE_BUNDLED_MINIZ or +SEREAL_USE_BUNDLED_CSNAPPY env vars. Eg: + + SEREAL_USE_BUNDLED_LIBS=1 perl Makefile.PL + SEREAL_USE_BUNDLED_CSNAPPY=1 perl Makefile.PL + SEREAL_USE_BUNDLED_MINIZ=1 perl Makefile.PL + + diff --git a/MANIFEST b/MANIFEST index c976cbd..2732e97 100644 --- a/MANIFEST +++ b/MANIFEST @@ -12,6 +12,7 @@ const-xs.inc Encoder.xs inc/Devel/CheckLib.pm inc/Sereal/BuildTools.pm +INSTALL lib/Sereal/Encoder.pm lib/Sereal/Encoder/Constants.pm Makefile.PL diff --git a/META.json b/META.json index 13f07cd..287cd25 100644 --- a/META.json +++ b/META.json @@ -50,7 +50,7 @@ } } }, - "release_status" : "testing", + "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/Sereal/Sereal/issues" @@ -60,5 +60,5 @@ "url" : "git://github.com/Sereal/Sereal.git" } }, - "version" : "3.002_001" + "version" : "3.003" } diff --git a/META.yml b/META.yml index c28fe06..4d1a764 100644 --- a/META.yml +++ b/META.yml @@ -32,4 +32,4 @@ requires: resources: bugtracker: https://github.com/Sereal/Sereal/issues repository: git://github.com/Sereal/Sereal.git -version: 3.002_001 +version: '3.003' diff --git a/Makefile.PL b/Makefile.PL index 65d9292..a3bf8bd 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -25,6 +25,8 @@ inc::Sereal::BuildTools::generate_constant_includes($module) if $in_source_repo; our $OPTIMIZE; +my $libs = ''; +my $objects = '$(BASEEXT)$(OBJ_EXT) srl_encoder$(OBJ_EXT)'; my $defines = join " ", map "-D$_", grep exists $ENV{$_}, qw(NOINLINE DEBUG MEMDEBUG NDEBUG ENABLE_DANGEROUS_HACKS); @@ -56,13 +58,18 @@ if ($Config{osname} eq 'hpux' && not $Config{gccversion}) { $defines .= " -Dinline= "; } -# from Compress::Snappy -require Devel::CheckLib; -my $ctz = Devel::CheckLib::check_lib( - lib => 'c', - function => 'return (__builtin_ctzll(0x100000000LL) != 32);' -) ? '-DHAVE_BUILTIN_CTZ' : ''; -$defines .= " $ctz" if $ctz; +# Prefer external libraries over the bundled one. +inc::Sereal::BuildTools::check_external_libraries(\$libs, \$defines, \$objects); + +if ($defines !~ /HAVE_CSNAPPY/) { + # from Compress::Snappy + require Devel::CheckLib; + my $ctz = Devel::CheckLib::check_lib( + lib => 'c', + function => 'return (__builtin_ctzll(0x100000000LL) != 32);' + ) ? '-DHAVE_BUILTIN_CTZ' : ''; + $defines .= " $ctz" if $ctz; +} # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. @@ -101,11 +108,11 @@ WriteMakefile1( LICENSE => 'perl', ABSTRACT_FROM => 'lib/Sereal/Encoder.pm', AUTHOR => 'Steffen Mueller , Yves Orton ', - LIBS => [''], # e.g., '-lm' + LIBS => [$libs], # e.g., '-lm' DEFINE => $defines, INC => '-I.', # e.g., '-I. -I/usr/include/other' OPTIMIZE => $OPTIMIZE, - OBJECT => '$(O_FILES)', + OBJECT => $objects, test => { TESTS => "t/*.t t/*/*/*.t", }, diff --git a/inc/Sereal/BuildTools.pm b/inc/Sereal/BuildTools.pm index a36e1e9..f5eb15d 100644 --- a/inc/Sereal/BuildTools.pm +++ b/inc/Sereal/BuildTools.pm @@ -1264,6 +1264,40 @@ HERE } } +# Prefer external csnappy and miniz libraries over the bundled ones. +sub check_external_libraries { + my ($libs, $defines, $objects) = @_; + require Devel::CheckLib; + + if ( + !$ENV{SEREAL_USE_BUNDLED_LIBS} && + !$ENV{SEREAL_USE_BUNDLED_CSNAPPY} && + Devel::CheckLib::check_lib( + lib => 'csnappy', + header => 'csnappy.h' + )) { + print "Using installed csnappy library\n"; + $$libs .= ' -lcsnappy'; + $$defines .= ' -DHAVE_CSNAPPY'; + } else { + print "Using bundled csnappy code\n"; + } + + if ( + !$ENV{SEREAL_USE_BUNDLED_LIBS} && + !$ENV{SEREAL_USE_BUNDLED_MINIZ} && + Devel::CheckLib::check_lib( + lib => 'miniz', + header => 'miniz.h' + )) { + print "Using installed miniz library\n"; + $$libs .= ' -lminiz'; + $$defines .= ' -DHAVE_MINIZ'; + } else { + print "Using bundled miniz code\n"; + $$objects .= ' miniz$(OBJ_EXT)'; + } +} 1; diff --git a/lib/Sereal/Encoder.pm b/lib/Sereal/Encoder.pm index 45232e5..c87655d 100644 --- a/lib/Sereal/Encoder.pm +++ b/lib/Sereal/Encoder.pm @@ -5,7 +5,7 @@ use warnings; use Carp qw/croak/; use XSLoader; -our $VERSION = '3.002_001'; # Don't forget to update the TestCompat set for testing against installed decoders! +our $VERSION = '3.003'; # Don't forget to update the TestCompat set for testing against installed decoders! our $XS_VERSION = $VERSION; $VERSION= eval $VERSION; # not for public consumption, just for testing. @@ -587,7 +587,7 @@ into a special one byte ARRAYREF tag. This is a very significant optimization for common cases. This, however, does mean that most arrays up to 15 elements could be represented in two different, yet perfectly valid forms. ARRAYREF would have to be outlawed for a properly canonical form. The exact same logic -applies to HASH vs. HASHREF. This behavior can be overriden by the +applies to HASH vs. HASHREF. This behavior can be overridden by the C option, which disables use of HASHREF and ARRAYREF. =item Numeric representation diff --git a/snappy/csnappy.h b/snappy/csnappy.h index d8c128c..a905ac0 100644 --- a/snappy/csnappy.h +++ b/snappy/csnappy.h @@ -8,14 +8,15 @@ Zeev Tarantov extern "C" { #endif -#define CSNAPPY_VERSION 4 +#define CSNAPPY_VERSION 5 -#define CSNAPPY_WORKMEM_BYTES_POWER_OF_TWO 15 +#define CSNAPPY_WORKMEM_BYTES_POWER_OF_TWO 16 #define CSNAPPY_WORKMEM_BYTES (1 << CSNAPPY_WORKMEM_BYTES_POWER_OF_TWO) #ifndef __GNUC__ #define __attribute__(x) /*NOTHING*/ #endif +#include /* * Returns the maximal size of the compressed representation of diff --git a/srl_encoder.c b/srl_encoder.c index 780748f..7756b03 100644 --- a/srl_encoder.c +++ b/srl_encoder.c @@ -52,8 +52,17 @@ extern "C" { #include "ptable.h" #include "srl_buffer.h" +#if defined(HAVE_CSNAPPY) +#include +#else #include "snappy/csnappy_compress.c" +#endif + +#if defined(HAVE_MINIZ) +#include +#else #include "miniz.h" +#endif /* The ENABLE_DANGEROUS_HACKS (passed through from ENV via Makefile.PL) enables * optimizations that may make the code so cozy with a particular version of the