Problem with 64-bit variables on ppc405

David Hawkins dwh at ovro.caltech.edu
Tue Nov 20 07:46:15 EST 2007


Hi Mirek,

> Doubles and long long are 8 bytes long but the byte order differs
> on my host linux Intel PC from this what I have on the target
> linux ppc 405.

That would be due to the difference in endianness of the
processors.

http://en.wikipedia.org/wiki/Endianness

If you want to work on data on both an Intel machine, and a
PowerPC, then you have to transfer the data between the machines
using a machine-independent binary format.

There are several around:

1. Network byte order = big-endian.

2. XDR

    http://en.wikipedia.org/wiki/External_Data_Representation

    used by NFS,

3. Common Data Representation

    http://en.wikipedia.org/wiki/Common_Data_Representation

    Which is implemented in the ACE C++ library.

    The nice thing about CDR is that the 'reader makes right',
    so its only when the endianness of the reader is different
    that it has to use CPU cycles to reformat the data.


Its not only processors that have subtle endian issues.
I use little-endian x86 host CPUs in a little-endian PCI
backplane talking to big-endian PowerPC processors.

Data transferred between the processors is first encoded
into a CDR data stream and then decoded. I write binary
data files using the same stream formatters, and then
use mex routines written in C++ to pull the data into
MATLAB data structures.

MATLAB data files are also an example of a machine independent
binary format. But I don't use them.

Cheers,
Dave





More information about the Linuxppc-embedded mailing list