View | Details | Raw Unified | Return to bug 235560
Collapse All | Expand All

(-)Makefile (-3 / +1 lines)
Lines 14-25 Link Here
14
14
15
LICENSE=	LGPL21
15
LICENSE=	LGPL21
16
16
17
BROKEN_powerpc64=	fails to compile: cc1: error: unrecognized command line option -faltivec
18
19
MAKEFILE=	makefile
17
MAKEFILE=	makefile
20
18
21
GNU_CONFIGURE=	yes
19
GNU_CONFIGURE=	yes
22
USES=		autoreconf gmake tar:bzip2
20
USES=		autoreconf compiler:c11 gmake tar:bzip2
23
USE_LDCONFIG=	yes
21
USE_LDCONFIG=	yes
24
PLIST_FILES=	include/fec.h		\
22
PLIST_FILES=	include/fec.h		\
25
		lib/libfec.so		\
23
		lib/libfec.so		\
(-)files/cpu_mode.c (-3 / +8 lines)
Lines 4-9 Link Here
4
#include <stdio.h>
4
#include <stdio.h>
5
#include "fec.h"
5
#include "fec.h"
6
#ifdef __VEC__
6
#ifdef __VEC__
7
#include <sys/types.h>
7
#include <sys/sysctl.h>
8
#include <sys/sysctl.h>
8
#endif
9
#endif
9
10
Lines 33-47 Link Here
33
    Cpu_mode = MMX;
34
    Cpu_mode = MMX;
34
  }
35
  }
35
#endif
36
#endif
36
//#ifdef __VEC__
37
#ifdef __VEC__
37
#if 0
38
// This looks very Linux specific
39
  {
38
  {
40
  /* Ask the OS if we have Altivec support */
39
  /* Ask the OS if we have Altivec support */
40
#ifdef __APPLE__
41
  int selectors[2] = { CTL_HW, HW_VECTORUNIT };
41
  int selectors[2] = { CTL_HW, HW_VECTORUNIT };
42
#endif
42
  int hasVectorUnit = 0;
43
  int hasVectorUnit = 0;
43
  size_t length = sizeof(hasVectorUnit);
44
  size_t length = sizeof(hasVectorUnit);
45
#ifdef __APPLE__
44
  int error = sysctl(selectors, 2, &hasVectorUnit, &length, NULL, 0);
46
  int error = sysctl(selectors, 2, &hasVectorUnit, &length, NULL, 0);
47
#elif __FreeBSD__
48
  int error = sysctlbyname("hw.altivec", &hasVectorUnit, &length, NULL, 0);
49
#endif
45
  if(0 == error && hasVectorUnit)
50
  if(0 == error && hasVectorUnit)
46
    Cpu_mode = ALTIVEC;
51
    Cpu_mode = ALTIVEC;
47
  }
52
  }
(-)files/patch-configure.in (-1 / +2 lines)
Lines 17-23 Link Here
17
+	cpu_features.o"
17
+	cpu_features.o"
18
 	;;
18
 	;;
19
 powerpc*)
19
 powerpc*)
20
 	ARCH_OPTION="-fno-common -faltivec"
20
-	ARCH_OPTION="-fno-common -faltivec"
21
+	ARCH_OPTION="-fno-common -maltivec"
21
 	MLIBS="viterbi27_av.o viterbi29_av.o viterbi39_av.o viterbi615_av.o \
22
 	MLIBS="viterbi27_av.o viterbi29_av.o viterbi39_av.o viterbi615_av.o \
22
 	encode_rs_av.o \
23
 	encode_rs_av.o \
23
-	dotprod_av.o sumsq_av.o peakval_av.o cpu_mode_ppc.o"
24
-	dotprod_av.o sumsq_av.o peakval_av.o cpu_mode_ppc.o"
(-)files/patch-dotprod__av.c (+28 lines)
Line 0 Link Here
1
--- dotprod_av.c.orig	2019-02-05 19:37:00 UTC
2
+++ dotprod_av.c
3
@@ -3,6 +3,7 @@
4
  * Copyright 2004 Phil Karn
5
  * May be used under the terms of the GNU Lesser General Public License (LGPL)
6
  */
7
+#include <altivec.h>
8
 #include <stdlib.h>
9
 #include "fec.h"
10
 
11
@@ -70,7 +71,7 @@ long dotprod_av(void *p,signed short a[]){
12
   nblocks = (dp->len+al-1)/8+1;
13
   
14
   /* Sum into four vectors each holding four 32-bit partial sums */
15
-  sums3 = sums2 = sums1 = sums0 = (vector signed int)(0);
16
+  sums3 = sums2 = sums1 = sums0 = (vector signed int){0};
17
   while(nblocks >= 4){
18
     sums0 = vec_msums(ar[nblocks-1],d[nblocks-1],sums0);
19
     sums1 = vec_msums(ar[nblocks-2],d[nblocks-2],sums1);
20
@@ -85,7 +86,7 @@ long dotprod_av(void *p,signed short a[]){
21
     sums0 = vec_msums(ar[nblocks],d[nblocks],sums0);
22
   }
23
   /* Sum 4 partial sums into final result */
24
-  s.v = vec_sums(sums0,(vector signed int)(0));
25
+  s.v = vec_sums(sums0,(vector signed int){0});
26
   
27
   return s.w[3];
28
 }
(-)files/patch-encode__rs__8.c (+27 lines)
Line 0 Link Here
1
--- encode_rs_8.c.orig	2019-02-06 10:40:06 UTC
2
+++ encode_rs_8.c
3
@@ -3,6 +3,7 @@
4
  * May be used under the terms of the GNU Lesser General Public License (LGPL)
5
  */
6
 #include <string.h>
7
+#include <sys/types.h>
8
 #include "fixed.h"
9
 #ifdef __VEC__
10
 #include <sys/sysctl.h>
11
@@ -36,10 +37,16 @@ void encode_rs_8(data_t *data, data_t *parity,int pad)
12
     }
13
 #elif __VEC__
14
     /* Ask the OS if we have Altivec support */
15
+#ifdef __APPLE__
16
     int selectors[2] = { CTL_HW, HW_VECTORUNIT };
17
+#endif
18
     int hasVectorUnit = 0;
19
     size_t length = sizeof(hasVectorUnit);
20
+#ifdef __APPLE__
21
     int error = sysctl(selectors, 2, &hasVectorUnit, &length, NULL, 0);
22
+#elif __FreeBSD__
23
+    int error = sysctlbyname("hw.altivec", &hasVectorUnit, &length, NULL, 0);
24
+#endif
25
     if(0 == error && hasVectorUnit)
26
       cpu_mode = ALTIVEC;
27
     else
(-)files/patch-encode__rs__av.c (+41 lines)
Line 0 Link Here
1
--- encode_rs_av.c.orig	2019-02-05 19:29:53 UTC
2
+++ encode_rs_av.c
3
@@ -2,6 +2,7 @@
4
  * Copyright 2004, Phil Karn KA9Q
5
  * May be used under the terms of the GNU Lesser General Public License (LGPL)
6
  */
7
+#include <altivec.h>
8
 #include <stdio.h>
9
 #include <string.h>
10
 #include "fixed.h"
11
@@ -12,8 +13,8 @@
12
  */
13
 static union { vector unsigned char v; unsigned char c[16]; } table[256];
14
 
15
-static vector unsigned char reverse = (vector unsigned char)(0,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1);
16
-static vector unsigned char shift_right = (vector unsigned char)(15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30);
17
+static vector unsigned char reverse = (vector unsigned char){0,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1};
18
+static vector unsigned char shift_right = (vector unsigned char){15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30};
19
 
20
 extern data_t CCSDS_alpha_to[];
21
 extern data_t CCSDS_index_of[];
22
@@ -40,8 +41,8 @@ void encode_rs_av(unsigned char *data,unsigned char *p
23
   union { vector unsigned char v[2]; unsigned char c[32]; } shift_register;
24
   int i;
25
 
26
-  shift_register.v[0] = (vector unsigned char)(0);
27
-  shift_register.v[1] = (vector unsigned char)(0);
28
+  shift_register.v[0] = (vector unsigned char){0};
29
+  shift_register.v[1] = (vector unsigned char){0};
30
   
31
   for(i=0;i<NN-NROOTS-pad;i++){
32
     vector unsigned char feedback0,feedback1;
33
@@ -53,7 +54,7 @@ void encode_rs_av(unsigned char *data,unsigned char *p
34
 
35
     /* Shift right one byte */
36
     shift_register.v[1] = vec_perm(shift_register.v[0],shift_register.v[1],shift_right) ^ feedback1;
37
-    shift_register.v[0] = vec_sro(shift_register.v[0],(vector unsigned char)(8)) ^ feedback0;
38
+    shift_register.v[0] = vec_sro(shift_register.v[0],(vector unsigned char){8}) ^ feedback0;
39
     shift_register.c[0] = f;
40
   }
41
   for(i=0;i<NROOTS;i++)
(-)files/patch-fec.h (-1 / +1 lines)
Lines 1-6 Link Here
1
--- fec.h.orig	2006-10-13 01:10:53 UTC
1
--- fec.h.orig	2006-10-13 01:10:53 UTC
2
+++ fec.h
2
+++ fec.h
3
@@ -262,7 +262,7 @@ extern enum cpu_mode {UNKNOWN=0,PORT,MMX
3
@@ -262,7 +262,7 @@ extern enum cpu_mode {UNKNOWN=0,PORT,MMX,SSE,SSE2,ALTI
4
 void find_cpu_mode(void); /* Call this once at startup to set Cpu_mode */
4
 void find_cpu_mode(void); /* Call this once at startup to set Cpu_mode */
5
 
5
 
6
 /* Determine parity of argument: 1 = odd, 0 = even */
6
 /* Determine parity of argument: 1 = odd, 0 = even */
(-)files/patch-peakval__av.c (+25 lines)
Line 0 Link Here
1
--- peakval_av.c.orig	2019-02-05 19:35:25 UTC
2
+++ peakval_av.c
3
@@ -6,6 +6,7 @@
4
  * May be used under the terms of the GNU Lesser General Public License (LGPL)
5
  */
6
 
7
+#include <altivec.h>
8
 #include "fec.h"
9
 
10
 signed short peakval_av(signed short *in,int cnt){
11
@@ -14,11 +15,11 @@ signed short peakval_av(signed short *in,int cnt){
12
   union { vector signed char cv; vector signed short hv; signed short s[8]; signed char c[16];} s;
13
   vector signed short smallest,largest;
14
 
15
-  smallest = (vector signed short)(0);
16
-  largest = (vector signed short)(0);
17
+  smallest = (vector signed short){0};
18
+  largest = (vector signed short){0};
19
   if((pad = (int)in & 15)!=0){
20
     /* Load unaligned leading word */
21
-    x = vec_perm(vec_ld(0,in),(vector signed short)(0),vec_lvsl(0,in));
22
+    x = vec_perm(vec_ld(0,in),(vector signed short){0},vec_lvsl(0,in));
23
     if(cnt < 8){ /* Shift right to chop stuff beyond end of short block */
24
       s.c[15] = (8-cnt)<<4;
25
       x = vec_sro(x,s.cv);
(-)files/patch-sumsq__av.c (+47 lines)
Line 0 Link Here
1
--- sumsq_av.c.orig	2019-02-05 19:36:10 UTC
2
+++ sumsq_av.c
3
@@ -8,6 +8,7 @@
4
  * May be used under the terms of the GNU Lesser General Public License (LGPL)
5
  */
6
 
7
+#include <altivec.h>
8
 #include "fec.h"
9
 
10
 unsigned long long sumsq_av(signed short *in,int cnt){
11
@@ -17,15 +18,15 @@ unsigned long long sumsq_av(signed short *in,int cnt){
12
   int pad;
13
   union { vector unsigned char cv; vector unsigned int iv; unsigned int w[4]; unsigned char c[16];} s;
14
 
15
-  carries = sums = (vector unsigned int)(0);
16
+  carries = sums = (vector unsigned int){0};
17
   if((pad = (int)in & 15)!=0){
18
     /* Load unaligned leading word */
19
-    x = vec_perm(vec_ld(0,in),(vector signed short)(0),vec_lvsl(0,in));
20
+    x = vec_perm(vec_ld(0,in),(vector signed short){0},vec_lvsl(0,in));
21
     if(cnt < 8){ /* Shift right to chop stuff beyond end of short block */
22
       s.c[15] = (8-cnt)<<4;
23
       x = vec_sro(x,s.cv);
24
     }
25
-    sums = (vector unsigned int)vec_msum(x,x,(vector signed int)(0));
26
+    sums = (vector unsigned int)vec_msum(x,x,(vector signed int){0});
27
     in += 8-pad/2;
28
     cnt -= 8-pad/2;
29
   }
30
@@ -36,7 +37,7 @@ unsigned long long sumsq_av(signed short *in,int cnt){
31
      * the earlier terms separately to handle the carries
32
      * The cast to unsigned is OK because squares are always positive
33
      */
34
-    s1 = (vector unsigned int)vec_msum(x,x,(vector signed int)(0));
35
+    s1 = (vector unsigned int)vec_msum(x,x,(vector signed int){0});
36
     carries = vec_add(carries,vec_addc(sums,s1));
37
     sums = vec_add(sums,s1);
38
     in += 8;
39
@@ -47,7 +48,7 @@ unsigned long long sumsq_av(signed short *in,int cnt){
40
     x = vec_ld(0,in);
41
     s.c[15] = (8-cnt)<<4;
42
     x = vec_sro(x,s.cv);
43
-    s1 = (vector unsigned int)vec_msum(x,x,(vector signed int)(0));
44
+    s1 = (vector unsigned int)vec_msum(x,x,(vector signed int){0});
45
     carries = vec_add(carries,vec_addc(sums,s1));
46
     sums = vec_add(sums,s1);
47
   }
(-)files/patch-viterbi27__av.c (+41 lines)
Line 0 Link Here
1
--- viterbi27_av.c.orig	2019-02-05 19:34:45 UTC
2
+++ viterbi27_av.c
3
@@ -1,6 +1,7 @@
4
 /* K=7 r=1/2 Viterbi decoder for PowerPC G4/G5 Altivec instructions
5
  * Feb 2004, Phil Karn, KA9Q
6
  */
7
+#include <altivec.h>
8
 #include <stdio.h>
9
 #include <memory.h>
10
 #include <stdlib.h>
11
@@ -31,7 +32,7 @@ int init_viterbi27_av(void *p,int starting_state){
12
   if(p == NULL)
13
     return -1;
14
   for(i=0;i<4;i++)
15
-    vp->metrics1.v[i] = (vector unsigned char)(63);
16
+    vp->metrics1.v[i] = (vector unsigned char){63};
17
   vp->old_metrics = &vp->metrics1;
18
   vp->new_metrics = &vp->metrics2;
19
   vp->dp = vp->decisions;
20
@@ -134,8 +135,8 @@ int update_viterbi27_blk_av(void *p,unsigned char *sym
21
 
22
     /* Form first set of 16 branch metrics */
23
     metric = vec_avg(vec_xor(Branchtab27[0].v[0],sym0v),vec_xor(Branchtab27[1].v[0],sym1v));
24
-    metric = vec_sr(metric,(vector unsigned char)(3));
25
-    m_metric = vec_sub((vector unsigned char)(31),metric);
26
+    metric = vec_sr(metric,(vector unsigned char){3});
27
+    m_metric = vec_sub((vector unsigned char){31},metric);
28
     
29
     /* Form first set of path metrics */
30
     m0 = vec_adds(vp->old_metrics->v[0],metric);
31
@@ -145,8 +146,8 @@ int update_viterbi27_blk_av(void *p,unsigned char *sym
32
     
33
     /* Form second set of 16 branch metrics */
34
     metric = vec_avg(vec_xor(Branchtab27[0].v[1],sym0v),vec_xor(Branchtab27[1].v[1],sym1v));
35
-    metric = vec_sr(metric,(vector unsigned char)(3));
36
-    m_metric = vec_sub((vector unsigned char)(31),metric);
37
+    metric = vec_sr(metric,(vector unsigned char){3});
38
+    m_metric = vec_sub((vector unsigned char){31},metric);
39
 
40
     /* Compare and select first set */
41
     decision0 = vec_cmpgt(m0,m1);
(-)files/patch-viterbi29__av.c (+34 lines)
Line 0 Link Here
1
--- viterbi29_av.c.orig	2019-02-05 19:33:58 UTC
2
+++ viterbi29_av.c
3
@@ -2,9 +2,11 @@
4
  * Copyright Feb 2004, Phil Karn, KA9Q
5
  * May be used under the terms of the GNU Lesser General Public License (LGPL)
6
  */
7
+#include <altivec.h>
8
 #include <stdio.h>
9
 #include <stdlib.h>
10
 #include <memory.h>
11
+#include <sys/types.h>
12
 #include <sys/sysctl.h>
13
 #include "fec.h"
14
 
15
@@ -31,7 +33,7 @@ int init_viterbi29_av(void *p,int starting_state){
16
   if(p == NULL)
17
     return -1;
18
   for(i=0;i<16;i++)
19
-    vp->metrics1.v[i] = (vector unsigned char)(63);
20
+    vp->metrics1.v[i] = (vector unsigned char){63};
21
 
22
   vp->old_metrics = &vp->metrics1;
23
   vp->new_metrics = &vp->metrics2;
24
@@ -136,8 +138,8 @@ int update_viterbi29_blk_av(void *p,unsigned char *sym
25
 
26
       /* Form branch metrics */
27
       metric = vec_avg(vec_xor(Branchtab29[0].v[i],sym1v),vec_xor(Branchtab29[1].v[i],sym2v));
28
-      metric = vec_sr(metric,(vector unsigned char)(3));
29
-      m_metric = (vector unsigned char)(31) - metric;
30
+      metric = vec_sr(metric,(vector unsigned char){3});
31
+      m_metric = (vector unsigned char){31} - metric;
32
     
33
       /* Add branch metrics to path metrics */
34
       m0 = vec_adds(vp->old_metrics->v[i],metric);
(-)files/patch-viterbi39__av.c (+46 lines)
Line 0 Link Here
1
--- viterbi39_av.c.orig	2019-02-05 19:31:24 UTC
2
+++ viterbi39_av.c
3
@@ -3,6 +3,7 @@
4
  * Copyright Aug 2006, Phil Karn, KA9Q
5
  * May be used under the terms of the GNU Lesser General Public License (LGPL)
6
  */
7
+#include <altivec.h>
8
 #include <stdio.h>
9
 #include <stdlib.h>
10
 #include <memory.h>
11
@@ -30,7 +31,7 @@ int init_viterbi39_av(void *p,int starting_state){
12
   int i;
13
 
14
   for(i=0;i<32;i++)
15
-    vp->metrics1.v[i] = (vector unsigned short)(1000);
16
+    vp->metrics1.v[i] = (vector unsigned short){1000};
17
 
18
   vp->old_metrics = &vp->metrics1;
19
   vp->new_metrics = &vp->metrics2;
20
@@ -111,7 +112,7 @@ int update_viterbi39_blk_av(void *p,unsigned char *sym
21
   struct v39 *vp = p;
22
   decision_t *d = (decision_t *)vp->dp;
23
   int path_metric = 0;
24
-  vector unsigned char decisions = (vector unsigned char)(0);
25
+  vector unsigned char decisions = (vector unsigned char){0};
26
 
27
   while(nbits--){
28
     vector unsigned short symv,sym0v,sym1v,sym2v;
29
@@ -122,7 +123,7 @@ int update_viterbi39_blk_av(void *p,unsigned char *sym
30
     /* Splat the 0th symbol across sym0v, the 1st symbol across sym1v, etc */
31
     s = (vector unsigned char)vec_perm(vec_ld(0,syms),vec_ld(5,syms),vec_lvsl(0,syms));
32
 
33
-    symv = (vector unsigned short)vec_mergeh((vector unsigned char)(0),s);    /* Unsigned byte->word unpack */ 
34
+    symv = (vector unsigned short)vec_mergeh((vector unsigned char){0},s);    /* Unsigned byte->word unpack */ 
35
     sym0v = vec_splat(symv,0);
36
     sym1v = vec_splat(symv,1);
37
     sym2v = vec_splat(symv,2);
38
@@ -140,7 +141,7 @@ int update_viterbi39_blk_av(void *p,unsigned char *sym
39
       m0 = vec_add(vec_xor(Branchtab39[0].v[i],sym0v),vec_xor(Branchtab39[1].v[i],sym1v));
40
       m1 = vec_xor(Branchtab39[2].v[i],sym2v);
41
       metric = vec_add(m0,m1);
42
-      m_metric = vec_sub((vector unsigned short)(765),metric);
43
+      m_metric = vec_sub((vector unsigned short){765},metric);
44
     
45
       /* Add branch metrics to path metrics */
46
       m0 = vec_adds(vp->old_metrics->v[i],metric);
(-)files/patch-viterbi615__av.c (+46 lines)
Line 0 Link Here
1
--- viterbi615_av.c.orig	2019-02-05 19:33:18 UTC
2
+++ viterbi615_av.c
3
@@ -3,6 +3,7 @@
4
  * Copyright Mar 2004, Phil Karn, KA9Q
5
  * May be used under the terms of the GNU Lesser General Public License (LGPL)
6
  */
7
+#include <altivec.h>
8
 #include <stdio.h>
9
 #include <stdlib.h>
10
 #include <memory.h>
11
@@ -33,7 +34,7 @@ int init_viterbi615_av(void *p,int starting_state){
12
     return -1;
13
 
14
   for(i=0;i<2048;i++)
15
-    vp->metrics1.v[i] = (vector unsigned short)(5000);
16
+    vp->metrics1.v[i] = (vector unsigned short){5000};
17
 
18
   vp->old_metrics = &vp->metrics1;
19
   vp->new_metrics = &vp->metrics2;
20
@@ -111,7 +112,7 @@ int update_viterbi615_blk_av(void *p,unsigned char *sy
21
   struct v615 *vp = p;
22
   decision_t *d = (decision_t *)vp->dp;
23
   int path_metric = 0;
24
-  vector unsigned char decisions = (vector unsigned char)(0);
25
+  vector unsigned char decisions = (vector unsigned char){0};
26
 
27
   while(nbits--){
28
     vector unsigned short symv,sym0v,sym1v,sym2v,sym3v,sym4v,sym5v;
29
@@ -122,7 +123,7 @@ int update_viterbi615_blk_av(void *p,unsigned char *sy
30
     /* Splat the 0th symbol across sym0v, the 1st symbol across sym1v, etc */
31
     s = (vector unsigned char)vec_perm(vec_ld(0,syms),vec_ld(5,syms),vec_lvsl(0,syms));
32
 
33
-    symv = (vector unsigned short)vec_mergeh((vector unsigned char)(0),s);    /* Unsigned byte->word unpack */ 
34
+    symv = (vector unsigned short)vec_mergeh((vector unsigned char){0},s);    /* Unsigned byte->word unpack */ 
35
     sym0v = vec_splat(symv,0);
36
     sym1v = vec_splat(symv,1);
37
     sym2v = vec_splat(symv,2);
38
@@ -145,7 +146,7 @@ int update_viterbi615_blk_av(void *p,unsigned char *sy
39
       m2 = vec_add(vec_xor(Branchtab615[4].v[i],sym4v),vec_xor(Branchtab615[5].v[i],sym5v));
40
       metric = vec_add(m0,m1);
41
       metric = vec_add(metric,m2);
42
-      m_metric = vec_sub((vector unsigned short)(1530),metric);
43
+      m_metric = vec_sub((vector unsigned short){1530},metric);
44
     
45
       /* Add branch metrics to path metrics */
46
       m0 = vec_adds(vp->old_metrics->v[i],metric);

Return to bug 235560