Right, I've recompiled the arm side test so that it has a structure 
with members that are the same size as those tested on the DSP. My 
apologies for my earlier mistake.

> What happens if you pack the structure as in
>
> typedef struct __attribute__ ((packed)) endian_test_struct {
>

Thank you for the suggestion.

On the DSP this is not accepted by the compiler (there might be other 
options, but really I'm trying to match the padding of structures 
between the two processors, so this is fine as you'll see below). I'm 
using the following struct on the ARM:

typedef struct endian_test_struct {
     unsigned int iamulong1; // 32bit
     unsigned short iamuint1; // 16bit
     unsigned short iamuint2; // 16bit
     unsigned int iamulong2; // 32bit
     unsigned short iamuint3; // 16bit
     unsigned int iamulong3; // 32bit
} endian_test_struct;

With no packing pragma we get this:

Byte #: Hex :
Byte 0: 78
Byte 1: 56
Byte 2: 34
Byte 3: 12
Byte 4: 34
Byte 5: 12
Byte 6: 34
Byte 7: 12
Byte 8: 78
Byte 9: 56
Byte 10: 34
Byte 11: 12
Byte 12: 34
Byte 13: 12
Byte 14: 0
Byte 15: 40
Byte 16: 78
Byte 17: 56
Byte 18: 34
Byte 19: 12

So the short has been padded into the start of a 32bit space. This is 
the same as happens on the DSP, so I should be able to copy the 
structure over and then fiddle with the endianness of its members.

With the packing pragma we get the following:

Byte #: Hex
Byte 0: 78
Byte 1: 56
Byte 2: 34
Byte 3: 12
Byte 4: 34
Byte 5: 12
Byte 6: 34
Byte 7: 12
Byte 8: 78
Byte 9: 56
Byte 10: 34
Byte 11: 12
Byte 12: 34
Byte 13: 12
Byte 14: 78
Byte 15: 56
Byte 16: 34
Byte 17: 12

Which as you suggest has removed the padding and produced a shorter struct.

Cheers,


Simon

_______________________________________________
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers

Reply via email to