Package: libmad
Version: 0.15.1b-5
Severity: wishlist
While building this package on the new armhf port -running on debian-ports atm-
we encountered two bugs that were already discovered in Ubuntu for ARM:
1. use "adr" instead of "add" to make code ready for
thumb2 (LP: #513734)
2. Provide-Thumb-2-alternative-code-for-MAD_F_MLN.diff: fix another
ftbfs with thumb2 as "rsc" doesnt exist anymore - thanks to Dave
Martin for this patch (LP: #534287)
The reason it wasn't discovered on armel or arm is that armhf by design uses
thumb2
by default for size/speed reasons which led to a number of similar bugs found
across
some packages.
I've gathered both into a patch which I would appreciate if you would apply to
the
current libmad version in order to have it build properly on armhf.
Thanks
Konstantinos Margaritis
Genesi USA, Senior Software engineer, armhf port maintainer
Debian Developer
diff -ruN libmad-0.15.1b/debian/changelog libmad-0.15.1b.armhf//debian/changelog
--- libmad-0.15.1b/debian/changelog 2010-09-14 22:40:51.000000000 +0000
+++ libmad-0.15.1b.armhf//debian/changelog 2010-09-14 22:40:25.000000000 +0000
@@ -1,3 +1,14 @@
+libmad (0.15.1b-6) unstable; urgency=low
+
+ Use patches from Ubuntu version:
+ * libmad.thumb.diff: use "adr" instead of "add" to make code ready for
+ thumb2 (LP: #513734)
+ * Provide-Thumb-2-alternative-code-for-MAD_F_MLN.diff: fix another
+ ftbfs with thumb2 as "rsc" doesnt exist anymore - thanks to Dave
+ Martin for this patch (LP: #534287).
+
+ -- Konstantinos Margaritis <[email protected]> Sat, 31 Jul 2010 17:34:27 +0300
+
libmad (0.15.1b-5) unstable; urgency=low
* gcc-4.4 removed an assembler constraint on mips/mipsel. Use the new
diff -ruN libmad-0.15.1b/debian/libmad.thumb.diff libmad-0.15.1b.armhf//debian/libmad.thumb.diff
--- libmad-0.15.1b/debian/libmad.thumb.diff 1970-01-01 00:00:00.000000000 +0000
+++ libmad-0.15.1b.armhf//debian/libmad.thumb.diff 2010-09-14 22:40:25.000000000 +0000
@@ -0,0 +1,11 @@
+--- ./imdct_l_arm.S.orig 2010-02-25 13:25:23.000000000 +0100
++++ ./imdct_l_arm.S 2010-02-25 13:27:26.000000000 +0100
+@@ -468,7 +468,7 @@
+
+ @----
+
+- add r2, pc, #(imdct36_long_karray-.-8) @ r2 = base address of Knn array (PIC safe ?)
++ adr r2, imdct36_long_karray
+
+
+ loop:
diff -ruN libmad-0.15.1b/debian/patches/libmad.thumb.diff libmad-0.15.1b.armhf//debian/patches/libmad.thumb.diff
--- libmad-0.15.1b/debian/patches/libmad.thumb.diff 1970-01-01 00:00:00.000000000 +0000
+++ libmad-0.15.1b.armhf//debian/patches/libmad.thumb.diff 2010-09-14 22:40:25.000000000 +0000
@@ -0,0 +1,11 @@
+--- ./imdct_l_arm.S.orig 2010-02-25 13:25:23.000000000 +0100
++++ ./imdct_l_arm.S 2010-02-25 13:27:26.000000000 +0100
+@@ -468,7 +468,7 @@
+
+ @----
+
+- add r2, pc, #(imdct36_long_karray-.-8) @ r2 = base address of Knn array (PIC safe ?)
++ adr r2, imdct36_long_karray
+
+
+ loop:
diff -ruN libmad-0.15.1b/debian/patches/Provide-Thumb-2-alternative-code-for-MAD_F_MLN.diff libmad-0.15.1b.armhf//debian/patches/Provide-Thumb-2-alternative-code-for-MAD_F_MLN.diff
--- libmad-0.15.1b/debian/patches/Provide-Thumb-2-alternative-code-for-MAD_F_MLN.diff 1970-01-01 00:00:00.000000000 +0000
+++ libmad-0.15.1b.armhf//debian/patches/Provide-Thumb-2-alternative-code-for-MAD_F_MLN.diff 2010-09-14 22:40:25.000000000 +0000
@@ -0,0 +1,71 @@
+diff --git a/fixed.h b/fixed.h
+index 4b58abf..ba4bc26 100644
+--- a/fixed.h
++++ b/fixed.h
+@@ -275,12 +275,25 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
+ : "+r" (lo), "+r" (hi) \
+ : "%r" (x), "r" (y))
+
++#ifdef __thumb__
++/* In Thumb-2, the RSB-immediate instruction is only allowed with a zero
++ operand. If needed this code can also support Thumb-1
++ (simply append "s" to the end of the second two instructions). */
++# define MAD_F_MLN(hi, lo) \
++ asm ("rsbs %0, %2, #0\n\t" \
++ "sbc %1, %1, %1\n\t" \
++ "sub %1, %1, %3\n\t" \
++ : "=&r" (lo), "=&r" (hi) \
++ : "0" (lo), "1" (hi) \
++ : "cc")
++#else /* ! __thumb__ */
+ # define MAD_F_MLN(hi, lo) \
+ asm ("rsbs %0, %2, #0\n\t" \
+ "rsc %1, %3, #0" \
+- : "=r" (lo), "=r" (hi) \
++ : "=&r" (lo), "=r" (hi) \
+ : "0" (lo), "1" (hi) \
+ : "cc")
++#endif /* __thumb__ */
+
+ # define mad_f_scale64(hi, lo) \
+ ({ mad_fixed_t __result; \
+diff --git a/mad.h b/mad.h
+index 9ef6cc8..130881d 100644
+--- a/mad.h
++++ b/mad.h
+@@ -24,7 +24,7 @@
+ extern "C" {
+ # endif
+
+-# define FPM_INTEL
++# define FPM_ARM
+
+
+
+@@ -320,12 +320,25 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
+ : "+r" (lo), "+r" (hi) \
+ : "%r" (x), "r" (y))
+
++#ifdef __thumb__
++/* In Thumb-2, the RSB-immediate instruction is only allowed with a zero
++ operand. If needed this code can also support Thumb-1
++ (simply append "s" to the end of the second two instructions). */
++# define MAD_F_MLN(hi, lo) \
++ asm ("rsbs %0, %2, #0\n\t" \
++ "sbc %1, %1, %1\n\t" \
++ "sub %1, %1, %3\n\t" \
++ : "=&r" (lo), "=&r" (hi) \
++ : "0" (lo), "1" (hi) \
++ : "cc")
++#else /* ! __thumb__ */
+ # define MAD_F_MLN(hi, lo) \
+ asm ("rsbs %0, %2, #0\n\t" \
+ "rsc %1, %3, #0" \
+- : "=r" (lo), "=r" (hi) \
++ : "=&r" (lo), "=r" (hi) \
+ : "0" (lo), "1" (hi) \
+ : "cc")
++#endif /* __thumb__ */
+
+ # define mad_f_scale64(hi, lo) \
+ ({ mad_fixed_t __result; \
diff -ruN libmad-0.15.1b/debian/patches/series libmad-0.15.1b.armhf//debian/patches/series
--- libmad-0.15.1b/debian/patches/series 2010-09-14 22:40:51.000000000 +0000
+++ libmad-0.15.1b.armhf//debian/patches/series 2010-09-14 22:40:25.000000000 +0000
@@ -1,5 +1,7 @@
optimize.diff
amd64-64bit.diff
frame_length.diff
+Provide-Thumb-2-alternative-code-for-MAD_F_MLN.diff
+libmad.thumb.diff
autoconf
mips-gcc4.4.diff
diff -ruN libmad-0.15.1b/debian/Provide-Thumb-2-alternative-code-for-MAD_F_MLN.diff libmad-0.15.1b.armhf//debian/Provide-Thumb-2-alternative-code-for-MAD_F_MLN.diff
--- libmad-0.15.1b/debian/Provide-Thumb-2-alternative-code-for-MAD_F_MLN.diff 1970-01-01 00:00:00.000000000 +0000
+++ libmad-0.15.1b.armhf//debian/Provide-Thumb-2-alternative-code-for-MAD_F_MLN.diff 2010-09-14 22:40:25.000000000 +0000
@@ -0,0 +1,71 @@
+diff --git a/fixed.h b/fixed.h
+index 4b58abf..ba4bc26 100644
+--- a/fixed.h
++++ b/fixed.h
+@@ -275,12 +275,25 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
+ : "+r" (lo), "+r" (hi) \
+ : "%r" (x), "r" (y))
+
++#ifdef __thumb__
++/* In Thumb-2, the RSB-immediate instruction is only allowed with a zero
++ operand. If needed this code can also support Thumb-1
++ (simply append "s" to the end of the second two instructions). */
++# define MAD_F_MLN(hi, lo) \
++ asm ("rsbs %0, %2, #0\n\t" \
++ "sbc %1, %1, %1\n\t" \
++ "sub %1, %1, %3\n\t" \
++ : "=&r" (lo), "=&r" (hi) \
++ : "0" (lo), "1" (hi) \
++ : "cc")
++#else /* ! __thumb__ */
+ # define MAD_F_MLN(hi, lo) \
+ asm ("rsbs %0, %2, #0\n\t" \
+ "rsc %1, %3, #0" \
+- : "=r" (lo), "=r" (hi) \
++ : "=&r" (lo), "=r" (hi) \
+ : "0" (lo), "1" (hi) \
+ : "cc")
++#endif /* __thumb__ */
+
+ # define mad_f_scale64(hi, lo) \
+ ({ mad_fixed_t __result; \
+diff --git a/mad.h b/mad.h
+index 9ef6cc8..130881d 100644
+--- a/mad.h
++++ b/mad.h
+@@ -24,7 +24,7 @@
+ extern "C" {
+ # endif
+
+-# define FPM_INTEL
++# define FPM_ARM
+
+
+
+@@ -320,12 +320,25 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
+ : "+r" (lo), "+r" (hi) \
+ : "%r" (x), "r" (y))
+
++#ifdef __thumb__
++/* In Thumb-2, the RSB-immediate instruction is only allowed with a zero
++ operand. If needed this code can also support Thumb-1
++ (simply append "s" to the end of the second two instructions). */
++# define MAD_F_MLN(hi, lo) \
++ asm ("rsbs %0, %2, #0\n\t" \
++ "sbc %1, %1, %1\n\t" \
++ "sub %1, %1, %3\n\t" \
++ : "=&r" (lo), "=&r" (hi) \
++ : "0" (lo), "1" (hi) \
++ : "cc")
++#else /* ! __thumb__ */
+ # define MAD_F_MLN(hi, lo) \
+ asm ("rsbs %0, %2, #0\n\t" \
+ "rsc %1, %3, #0" \
+- : "=r" (lo), "=r" (hi) \
++ : "=&r" (lo), "=r" (hi) \
+ : "0" (lo), "1" (hi) \
+ : "cc")
++#endif /* __thumb__ */
+
+ # define mad_f_scale64(hi, lo) \
+ ({ mad_fixed_t __result; \