You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.6 KiB
82 lines
2.6 KiB
10 years ago
|
From 3bdd905ddf3c6c9feabbf88901bf4f655924cb61 Mon Sep 17 00:00:00 2001
|
||
|
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
|
||
|
Date: Thu, 16 Oct 2014 13:12:07 +0200
|
||
|
Subject: [PATCH 1/2] Prefer external csnappy library in Sereal::Decoder
|
||
|
MIME-Version: 1.0
|
||
|
Content-Type: text/plain; charset=UTF-8
|
||
|
Content-Transfer-Encoding: 8bit
|
||
|
|
||
|
This patch checks for presence of csnappy library and header file and
|
||
|
if they are available, they will be used to link to the
|
||
|
Sereal::Decoder XS module. Otherwise the bundled csnappy code will be
|
||
|
used.
|
||
|
|
||
|
<https://github.com/Sereal/Sereal/issues/72>
|
||
|
|
||
|
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
||
|
---
|
||
|
Perl/Decoder/Makefile.PL | 15 ++++++++++++++-
|
||
|
Perl/Decoder/srl_decoder.c | 5 +++++
|
||
|
2 files changed, 19 insertions(+), 1 deletion(-)
|
||
|
|
||
|
diff --git a/Perl/Decoder/Makefile.PL b/Perl/Decoder/Makefile.PL
|
||
|
index 71cd40d..864b89b 100644
|
||
|
--- a/Perl/Decoder/Makefile.PL
|
||
|
+++ b/Perl/Decoder/Makefile.PL
|
||
|
@@ -25,6 +25,7 @@ our $OPTIMIZE;
|
||
|
# #define MINIZ_LITTLE_ENDIAN 1
|
||
|
# #define MINIZ_HAS_64BIT_REGISTERS 1
|
||
|
|
||
|
+my $libs = '';
|
||
|
my $defines = join " ", map "-D$_", grep exists $ENV{$_}, qw(NOINLINE DEBUG MEMDEBUG NDEBUG);
|
||
|
if ($Config{gccversion}) {
|
||
|
$OPTIMIZE = '-O3 -Wall -W';
|
||
|
@@ -52,6 +53,18 @@ if ($Config{osname} eq 'hpux' && not $Config{gccversion}) {
|
||
|
$defines .= " -Dinline= ";
|
||
|
}
|
||
|
|
||
|
+# Prefer external csnappy library over the bundled one.
|
||
|
+require Devel::CheckLib;
|
||
|
+my $have_csnappy = Devel::CheckLib::check_lib(
|
||
|
+ lib => 'csnappy',
|
||
|
+ header => 'csnappy.h'
|
||
|
+);
|
||
|
+
|
||
|
+if ($have_csnappy) {
|
||
|
+ $libs .= ' -lcsnappy';
|
||
|
+ $defines .= ' -DHAVE_CSNAPPY';
|
||
|
+}
|
||
|
+
|
||
|
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
|
||
|
# the contents of the Makefile that is written.
|
||
|
WriteMakefile1(
|
||
|
@@ -89,7 +102,7 @@ WriteMakefile1(
|
||
|
LICENSE => 'perl',
|
||
|
ABSTRACT_FROM => 'lib/Sereal/Decoder.pm',
|
||
|
AUTHOR => 'Steffen Mueller <smueller@cpan.org>, Yves Orton <yves@cpan.org>',
|
||
|
- LIBS => [''], # e.g., '-lm'
|
||
|
+ LIBS => [$libs], # e.g., '-lm'
|
||
|
DEFINE => $defines,
|
||
|
INC => '-I.', # e.g., '-I. -I/usr/include/other'
|
||
|
OPTIMIZE => $OPTIMIZE,
|
||
|
diff --git a/Perl/Decoder/srl_decoder.c b/Perl/Decoder/srl_decoder.c
|
||
|
index 890a25c..09b5e52 100644
|
||
|
--- a/Perl/Decoder/srl_decoder.c
|
||
|
+++ b/Perl/Decoder/srl_decoder.c
|
||
|
@@ -51,7 +51,12 @@ extern "C" {
|
||
|
#include "ptable.h"
|
||
|
#include "srl_protocol.h"
|
||
|
|
||
|
+#if defined(HAVE_CSNAPPY)
|
||
|
+#include <csnappy.h>
|
||
|
+#else
|
||
|
#include "snappy/csnappy_decompress.c"
|
||
|
+#endif
|
||
|
+
|
||
|
#include "miniz.h"
|
||
|
|
||
|
/* 5.8.8 and earlier have a nasty bug in their handling of overloading:
|
||
|
--
|
||
|
1.9.3
|
||
|
|