From 5d9cf8cadfd844e4524d8b36cdab84f915bebc34 Mon Sep 17 00:00:00 2001
From: Greg Tucker <greg.b.tucker@intel.com>
Date: Tue, 21 Mar 2017 13:46:30 -0700
Subject: [PATCH] ec: Fixes for 32-bit build

Change-Id: Iac362f0d7282716a8502afcec939b0d1877a943f
Signed-off-by: Greg Tucker <greg.b.tucker@intel.com>
---
 Makefile.am                      |  1 +
 erasure_code/Makefile.am         |  5 +++--
 erasure_code/ec_base.c           | 12 ++++++++++++
 erasure_code/ec_highlevel_func.c | 11 -----------
 make.inc                         |  6 ++++++
 5 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index b3c37f2..262cf44 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -20,6 +20,7 @@ examples=
 other_tests=
 lsrc_x86_64=
 lsrc_x86_32=
+lsrc_base_aliases=
 lsrc32=
 unit_tests32=
 perf_tests32=
diff --git a/erasure_code/Makefile.am b/erasure_code/Makefile.am
index c151581..054dd73 100644
--- a/erasure_code/Makefile.am
+++ b/erasure_code/Makefile.am
@@ -27,12 +27,12 @@
 #  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ########################################################################
 
-lsrc         += erasure_code/ec_highlevel_func.c \
-		erasure_code/ec_base.c
+lsrc         += erasure_code/ec_base.c
 
 lsrc_base_aliases += erasure_code/ec_base_aliases.c
 
 lsrc_x86_64  += \
+		erasure_code/ec_highlevel_func.c \
 		erasure_code/gf_vect_mul_sse.asm \
 		erasure_code/gf_vect_mul_avx.asm \
 		erasure_code/gf_vect_dot_prod_sse.asm  \
@@ -85,6 +85,7 @@ lsrc_x86_64  += \
 		erasure_code/gf_4vect_mad_avx512.asm
 
 lsrc_x86_32  += \
+		erasure_code/ec_highlevel_func.c \
 		erasure_code/ec_multibinary.asm \
 		erasure_code/gf_vect_dot_prod_avx.asm \
 		erasure_code/gf_2vect_dot_prod_avx.asm \
diff --git a/erasure_code/ec_base.c b/erasure_code/ec_base.c
index e690b46..a34e3fd 100644
--- a/erasure_code/ec_base.c
+++ b/erasure_code/ec_base.c
@@ -33,6 +33,18 @@
 #include "ec_base.h"		// for GF tables
 #include "types.h"
 
+void ec_init_tables(int k, int rows, unsigned char *a, unsigned char *g_tbls)
+{
+	int i, j;
+
+	for (i = 0; i < rows; i++) {
+		for (j = 0; j < k; j++) {
+			gf_vect_mul_init(*a++, g_tbls);
+			g_tbls += 32;
+		}
+	}
+}
+
 unsigned char gf_mul(unsigned char a, unsigned char b)
 {
 #ifndef GF_LARGE_TABLES
diff --git a/erasure_code/ec_highlevel_func.c b/erasure_code/ec_highlevel_func.c
index d777921..baaf20d 100644
--- a/erasure_code/ec_highlevel_func.c
+++ b/erasure_code/ec_highlevel_func.c
@@ -30,17 +30,6 @@
 #include "erasure_code.h"
 #include "types.h"
 
-void ec_init_tables(int k, int rows, unsigned char *a, unsigned char *g_tbls)
-{
-	int i, j;
-
-	for (i = 0; i < rows; i++) {
-		for (j = 0; j < k; j++) {
-			gf_vect_mul_init(*a++, g_tbls);
-			g_tbls += 32;
-		}
-	}
-}
 
 void ec_encode_data_sse(int len, int k, int rows, unsigned char *g_tbls, unsigned char **data,
 			unsigned char **coding)
diff --git a/make.inc b/make.inc
index 0f791a3..34be8d3 100644
--- a/make.inc
+++ b/make.inc
@@ -80,6 +80,12 @@ ifeq ($(arch),mingw)
   AR=x86_64-w64-mingw32-ar
 endif
 
+# arch=noarch build options
+ARFLAGS_noarch = cr $@
+ifeq ($(arch),noarch)
+  host_cpu=base_aliases
+endif
+
 ASFLAGS_Darwin = -f macho64 --prefix=_
 ARFLAGS_Darwin = -r $@
 ifeq ($(arch),Darwin)