1 From 1b0dafa7a6920dd2e9ce97a1c8c084e4c8fc5f68 Mon Sep 17 00:00:00 2001
2 From: Alexander Evseev <aevseev@mirantis.com>
3 Date: Wed, 29 Jul 2015 16:13:32 +0300
4 Subject: [PATCH] Fix build for 32 bit targets
6 * Define CPU flags for non-x86_64 targets
7 * Use non-SSE version of ec_encode_data for non-x86_64 targets
8 * Add make variable "arch" as it should be used in isa-l
10 Signed-off-by: Alexander Evseev <aevseev@mirantis.com>
13 include/compiler.h | 6 ++++++
14 lib/Makefile.am | 14 ++++++++++++--
16 4 files changed, 23 insertions(+), 3 deletions(-)
18 diff --git a/configure.ac b/configure.ac
19 index e637f42..66b733b 100644
22 @@ -199,6 +199,7 @@ LINT_FLAGS="-weak -unrecog +posixlib +ignoresigns -fcnuse \
23 -badflag -D__gnuc_va_list=va_list -D__attribute\(x\)="
25 AM_CONDITIONAL(BUILD_SHA1_HW, [[[[ $host = *x86_64* ]]]])
26 +AM_CONDITIONAL(X86_64, [[[[ $host = *x86_64* ]]]])
28 AC_ARG_ENABLE([fatal-warnings],
29 [ --enable-fatal-warnings : enable fatal warnings. ],
30 diff --git a/include/compiler.h b/include/compiler.h
31 index 3c68b75..64ab6b4 100644
32 --- a/include/compiler.h
33 +++ b/include/compiler.h
34 @@ -155,6 +155,12 @@ static inline uint64_t xgetbv(uint32_t idx)
35 #define cpu_has_avx cpu_has(X86_FEATURE_AVX)
36 #define cpu_has_osxsave cpu_has(X86_FEATURE_OSXSAVE)
38 +#else /* __x86_64__ */
40 +#define cpu_has_ssse3 0
41 +#define cpu_has_avx 0
42 +#define cpu_has_osxsave 0
44 #endif /* __x86_64__ */
46 #endif /* SD_COMPILER_H */
47 diff --git a/lib/Makefile.am b/lib/Makefile.am
48 index dec81c7..dfb2fb0 100644
51 @@ -38,7 +38,7 @@ libsd_a_SOURCES = event.c logger.c net.c util.c rbtree.c strbuf.c \
52 sha1.c option.c work.c sockfd_cache.c fec.c \
55 -libsheepdog_a_LIBADD = isa-l/bin/ec_base.o \
56 +libsheepdog_a_LIBADD_ = isa-l/bin/ec_base.o \
57 isa-l/bin/ec_highlevel_func.o \
58 isa-l/bin/ec_multibinary.o \
59 isa-l/bin/gf_2vect_dot_prod_sse.o \
60 @@ -50,6 +50,16 @@ libsd_a_LIBADD = isa-l/bin/ec_base.o \
61 isa-l/bin/gf_vect_mul_avx.o \
62 isa-l/bin/gf_vect_mul_sse.o
64 +libsheepdog_a_LIBADD_32 = isa-l/bin/ec_base.o \
65 + isa-l/bin/ec_highlevel_func.o \
66 + isa-l/bin/ec_multibinary.o
72 +libsheepdog_a_LIBADD = $(libsheepdog_a_LIBADD_$(arch))
75 libsd_a_SOURCES += sha1_ssse3.S
77 @@ -74,7 +84,7 @@ check-style:
78 @$(CHECK_STYLE) $(libsd_a_SOURCES)
81 - cd isa-l/ && $(MAKE) && cd ..
82 + cd isa-l/ && $(MAKE) arch=$(arch) && cd ..
85 rm -f *.o gmon.out *.da *.bb *.bbg
86 diff --git a/lib/fec.c b/lib/fec.c
87 index e0908bc..e2d5cd1 100644
90 @@ -739,5 +739,8 @@ void isa_decode_buffer(struct fec *ctx, uint8_t *input[], const int in_idx[],
92 lost[0] = (unsigned char *)buf;
93 ec_init_tables(ed, 1, cm, ec_tbl);
94 - ec_encode_data_sse(len, ed, 1, ec_tbl, input, lost);
96 + ec_encode_data_sse(len, ed, 1, ec_tbl, input, lost);
98 + ec_encode_data(len, ed, 1, ec_tbl, input, lost);