Hi, On Arm, you can access only word aligned data. To access a 32 bit value, the address needs to be 32 bit aligned etc.. If the data is not aligned, then a bus error is thrown.
I'm guessing that its because of the char m, data[] will not be aligned in _test_c. Thanks and Regards, Sid +91-80-25099294 -----Original Message----- From: zhenfeng ren [mailto:1985re...@gmail.com] Sent: Saturday, April 25, 2009 8:44 AM To: davinci-linux-open-source@linux.davincidsp.com Subject: when port a software , bus error hi, everyone: Just like the code as below: 1 #include <algorithm> 2 #include <stdio.h> 3 4 #pragma pack(push, 1) 5 typedef struct _test_c 6 { 7 char m; 8 int data[10]; 9 }test_c; 10 #pragma pack(pop) 11 12 int main() 13 { 14 printf(" sizeof test_c is %d \n", sizeof(test_c)); 15 test_c test; 16 for(int i=0; i<10; i++) 17 test.data[i] = 9-i; 18 //int data[10]={9, 8, 7, 6, 5, 4, 2, 3, 1 , 0}; 19 std::sort(test.data, test.data+10); 20 21 return 1; 22 } This code can work on X86, but cause bus error runing on Davinci(My board is DM6446, GCC 3.4) . I know the problem is: std::sort(test.data, test.data+10); test.data is not 4-Bytes aligned. The software I want to port uses structs liking "test_c" a lot. Could anyone give me some advice ? -- Thanks, Zhenfeng Ren _______________________________________________ Davinci-linux-open-source mailing list Davinci-linux-open-source@linux.davincidsp.com http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source