Package: eegdev
Version: 0.2-3
Tags: sid patch
Severity: important
Justification: FTBFS
User: [email protected]
Usertags: mips-patch


After applying patches form #720833 and #742032,
in an attempt to build package eegdev on mips/mipsel, build failed on testing:

> make  check-TESTS
> make[4]: Entering directory `/build/eegdev-Y6NuMB/eegdev-0.2/tests'
> make[5]: Entering directory `/build/eegdev-Y6NuMB/eegdev-0.2/tests'
> PASS: verify-cast.sh
> PASS: verifysplit
> PASS: syseegfile
> FAIL: testfakeact2.sh
> PASS: testfaketobiia.sh


Test testfakeact2 failed with a Bus error.

The way to reproduce the error:
LD_PRELOAD=./tests/fakelibs/.libs/libfakeact2.so ./tests/.libs/lt-sysbiosemi -d 
1 -c 1
>         Testing biosemi with double data type
> Bus error

The Bus error appears due to unaligned memory access on MIPS architectures.


Patch that fixes this issue is attached.
Could you please consider applying this patch?


Thanks,
Dejan
--- a/src/core/typecast.c
+++ b/src/core/typecast.c
@@ -37,6 +37,28 @@
 	}								\
 }						
 
+// Prototype of a generic type scale and cast function for unaligned memory access
+#define DEFINE_CASTUNALIGNED_FN(tsrc, tdst)                      	\
+static void cast_##tsrc##_##tdst (void* restrict d, const void* restrict s, union gval sc, size_t len)  \
+{                                                                       \
+        union dstdata							\
+        {								\
+                tdst Data;						\
+                unsigned int intData[2];				\
+        };								\
+        const tsrc* src = s;						\
+        union dstdata *dst = d;						\
+        tdst scale = sc.val##tdst;					\
+        while(len)							\
+        {								\
+                union dstdata dst_tmp;					\
+                dst_tmp.Data = scale * ((tdst)(*src));			\
+                dst->intData[0] = dst_tmp.intData[0];			\
+                dst->intData[1] = dst_tmp.intData[1];			\
+                src++; dst++;						\
+                len -= sizeof(*src);					\
+        }								\
+}
 // Prototype of a generic type cast function
 #define DEFINE_CASTNOSC_FN(tsrc, tdst)				\
 static void castnosc_##tsrc##_##tdst (void* restrict d, const void* restrict s, union gval sc, size_t len)	\
@@ -60,7 +82,7 @@
 
 // Declaration/definition of type cast and scale functions
 DEFINE_CAST_FN(int32_t, int32_t)
-DEFINE_CAST_FN(int32_t, double)
+DEFINE_CASTUNALIGNED_FN(int32_t, double)
 DEFINE_CAST_FN(double, int32_t)
 DEFINE_CAST_FN(int32_t, float)
 DEFINE_CAST_FN(float, int32_t)

Reply via email to