From 064d11051f477cd2c398e5d4e3cb1301daf683eb Mon Sep 17 00:00:00 2001
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Tue, 17 Aug 2010 22:30:49 +0200
Subject: [PATCH] fix stride tc on amd64. i386 and powerpc

the stride tc segfauls with

|diff --git a/testsuite/stride.c b/testsuite/stride.c
|index abc521e..debc340 100644
|--- a/testsuite/stride.c
|+++ b/testsuite/stride.c
|@@ -74,8 +74,8 @@ int main (int argc, char *argv[])
|       continue;
|     }
|     oil_test_set_iterations (test, 1);
|-    test->n = 1 + oil_rand_u8();
|-    test->m = 1 + oil_rand_u8();
|+    test->n = 1;
|+    test->m = 33;
|
|     oil_test_check_impl (test, klass->reference_impl);
|     for(j=0;j<OIL_ARG_LAST;j++){

as random numers. This was reported as Debian bug #483352.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 liboil/amd64/wavelet.c   |    3 +++
 liboil/i386/wavelet.c    |    2 ++
 liboil/powerpc/rgb2bgr.c |    2 ++
 3 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/liboil/amd64/wavelet.c b/liboil/amd64/wavelet.c
index 6b1946a..353471f 100644
--- a/liboil/amd64/wavelet.c
+++ b/liboil/amd64/wavelet.c
@@ -18,6 +18,9 @@ deinterleave2_asm (int16_t *d1, int16_t *d2, int16_t *s_2xn, int n)
     n--;
   }
 
+  if (!n)
+	  return;
+
   asm volatile ("\n"
       "  sub $2, %%rcx\n"
       "1:\n"
diff --git a/liboil/i386/wavelet.c b/liboil/i386/wavelet.c
index a382a22..d8d61a6 100644
--- a/liboil/i386/wavelet.c
+++ b/liboil/i386/wavelet.c
@@ -117,6 +117,8 @@ deinterleave2_asm (int16_t *d1, int16_t *d2, int16_t *s_2xn, int n)
     s_2xn+=2;
     n--;
   }
+  if (!n)
+	  return;
 
   asm volatile ("\n"
       "  mov %3, %%ecx\n"
diff --git a/liboil/powerpc/rgb2bgr.c b/liboil/powerpc/rgb2bgr.c
index 8787d66..419b8e1 100644
--- a/liboil/powerpc/rgb2bgr.c
+++ b/liboil/powerpc/rgb2bgr.c
@@ -50,6 +50,8 @@ rgb2bgr_ppc (uint8_t *dest, uint8_t* src, int n)
   n /= 4;
   dest -= 4;
   src -= 4;
+  if (!n)
+	  return ;
   asm volatile (
 	"	mtctr %2		\n"
 	"1:	lwzu r10, 4(%1)		\n" /* rgbr x */
-- 
1.5.6.5

