[libsereal-decoder-perl] 01/03: Add patch from upstream git which is supposed to fix alignment issues on ARM

gregor herrmann gregoa at debian.org
Thu May 15 14:48:46 UTC 2014


This is an automated email from the git hooks/post-receive script.

gregoa pushed a commit to branch master
in repository libsereal-decoder-perl.

commit 2107196981fa54a75b4b8e4c2a770bf45c6badce
Author: gregor herrmann <gregoa at debian.org>
Date:   Thu May 15 16:37:54 2014 +0200

    Add patch from upstream git which is supposed to fix alignment issues on ARM
    
    which cause build failures in libsereal-encoder-perl.
---
 debian/patches/series                              |  1 +
 ...RM_to_ensure_alignment_for_floating_point.patch | 88 ++++++++++++++++++++++
 2 files changed, 89 insertions(+)

diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..f914225
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+use_a_union_on_ARM_to_ensure_alignment_for_floating_point.patch
diff --git a/debian/patches/use_a_union_on_ARM_to_ensure_alignment_for_floating_point.patch b/debian/patches/use_a_union_on_ARM_to_ensure_alignment_for_floating_point.patch
new file mode 100644
index 0000000..19426fc
--- /dev/null
+++ b/debian/patches/use_a_union_on_ARM_to_ensure_alignment_for_floating_point.patch
@@ -0,0 +1,88 @@
+From 925053456efc71380537cb70a7d2735283924a8e Mon Sep 17 00:00:00 2001
+From: Yves Orton <yves.orton at booking.com>
+Date: Thu, 15 May 2014 00:40:56 +0200
+Subject: [PATCH] Use a union on ARM to ensure alignment for floating point
+ loads
+
+I hope this fixes ARM. I have no way to test.
+---
+ Perl/Decoder/srl_decoder.c | 44 +++++++++++++++++++++++++++++++++++++++-----
+ 1 file changed, 39 insertions(+), 5 deletions(-)
+
+diff --git a/Perl/Decoder/srl_decoder.c b/Perl/Decoder/srl_decoder.c
+index fd4929b..71ce384 100644
+--- a/srl_decoder.c
++++ b/srl_decoder.c
+@@ -843,12 +843,28 @@ srl_read_string(pTHX_ srl_decoder_t *dec, int is_utf8, SV* into)
+     dec->pos+= len;
+ }
+ 
++/* declare a union so that we are guaranteed the right alignment
++ * rules - this is required for ARM */
++union myfloat {
++    U8 c[sizeof(long double)];
++    float f;
++    double d;
++    long double ld;
++};
+ 
+ SRL_STATIC_INLINE void
+ srl_read_float(pTHX_ srl_decoder_t *dec, SV* into)
+ {
++    union myfloat val;
++#ifdef __ARM_ARCH
+     ASSERT_BUF_SPACE(dec, sizeof(float), " while reading FLOAT");
+-    sv_setnv(into, (NV)*((float *)dec->pos));
++    Copy(dec->pos,v.c,sizeof(float),U8);
++    val.f= *((float *)tmp);
++#else
++    ASSERT_BUF_SPACE(dec, sizeof(float), " while reading FLOAT");
++    val.f= *((float *)dec->pos);
++#endif
++    sv_setnv(into, (NV)val.f);
+     dec->pos+= sizeof(float);
+ }
+ 
+@@ -856,8 +872,17 @@ srl_read_float(pTHX_ srl_decoder_t *dec, SV* into)
+ SRL_STATIC_INLINE void
+ srl_read_double(pTHX_ srl_decoder_t *dec, SV* into)
+ {
+-    ASSERT_BUF_SPACE(dec, sizeof(double)," while reading DOUBLE");
+-    sv_setnv(into, (NV)*((double *)dec->pos));
++    union myfloat val;
++#ifdef __ARM_ARCH
++    U8 tmp[sizeof(double)];
++    ASSERT_BUF_SPACE(dec, sizeof(double), " while reading DOUBLE");
++    Copy(dec->pos,val.c,sizeof(double),U8);
++    val.d= *((double *)tmp);
++#else
++    ASSERT_BUF_SPACE(dec, sizeof(double), " while reading DOUBLE");
++    val.d= *((double *)dec->pos);
++#endif
++    sv_setnv(into, (NV)val.d);
+     dec->pos+= sizeof(double);
+ }
+ 
+@@ -865,8 +890,17 @@ srl_read_double(pTHX_ srl_decoder_t *dec, SV* into)
+ SRL_STATIC_INLINE void
+ srl_read_long_double(pTHX_ srl_decoder_t *dec, SV* into)
+ {
+-    ASSERT_BUF_SPACE(dec, sizeof(long double)," while reading LONG_DOUBLE");
+-    sv_setnv(into, (NV)*((long double *)dec->pos));
++    union myfloat val;
++#ifdef __ARM_ARCH
++    U8 tmp[sizeof(long double)];
++    ASSERT_BUF_SPACE(dec, sizeof(long double), " while reading LONG_DOUBLE");
++    Copy(dec->pos,v.c,sizeof(long double),U8);
++    val.ld= *((long double *)tmp);
++#else
++    ASSERT_BUF_SPACE(dec, sizeof(long double), " while reading LONG_DOUBLE");
++    val.ld= *((long double *)dec->pos);
++#endif
++    sv_setnv(into, (NV)val.ld);
+     dec->pos+= sizeof(long double);
+ }
+ 
+-- 
+1.9.3
+

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libsereal-decoder-perl.git



More information about the Pkg-perl-cvs-commits mailing list