How to fix misaligned assignment statements in the source code?
I'm not a C/C++ programmer, but I'm familiar with this programm language.
The thing is that I'm trying to compile and run DDS (Darwin Streaming Server) on "Gentoo on Sparc" architecture.
Although I've managed to compile DSS under my arch. I'm constatntly get "Bus error" while trying to connect to DSS with QT player.
I've read that:
"The "bus error" signal usually means a data access was not properly aligned. It is always due to an error in the program.
One major cause is accessing data via a pointer of a different type that has different alignment requirements. Example:
On SPARC, an int must be aligned on a 4-byte boundary, but a short only needs 2-byte alignment. The attempted load fails with a bus error if array s was not 4-byte aligned.
short s; // 2-byte alignment
int* p = (int*)s; // pretend the 2 shorts are one int int i = *p; // bus error is likely
Here is the example of resolution for this kind of problem on another project (a snap from the .diff):
So I thought there may be some way to overcome these alignment requirements by may be replacing (with some search and replace func.) int and short definitions with the proper ones?
@@ -499,8 +499,11 @@
conn->request_len -= req->len;
if (conn->request_len == 0)
+#if defined (__i386__)
req = (void *) req + req->len;
+memmove(&conn->request, (void *)req + req->len, conn->request_len);
if (conn->request_len > 0 && req != &conn->request)
As I've said I'm not a C/C++ programmer so I hope you could give me some good advices to resolve this problem.