[fpc-pascal] Binary compatibility between Intel CPU and PowerPC CPU
Adriaan van Os
fpc at microbizz.nl
Tue Sep 16 18:44:04 CEST 2008
Adriaan van Os wrote:
> Roland Turcan wrote:
>> Hello FPC-Pascal users discussions!
>>
>> What is the best way to keep the binary compatibility among different
>> CPU architectures.
>>
>> I need to make our own database engine compatible and other binary
>> files, that user still can use our data from i386 or PowerPC computer.
>>
>> I really don't like the idea to change the order of all numeric
>> variables on PowerPC, because it costs time of CPU.
>>
>> There must be easier way how to keep the compatibility.
>>
>> Could you give me some hints for better solution.
>
> Whether you "like the idea" or not, the best way is as follows:
>
> - add a byte to the header of source data that indicates the endianness,
> high-endian for PowerPC, low-endian for i386
> - perform byte swapping if the endianness of source data is different
> from the endianness of the current CPU
>
> With "source data" I mean
> - reading files
> - reading data over a network
>
> This is best built-into a streaming toolbox, so that it happens
> automatically.
I forgot to mention:
- write data in the endianness of the current CPU
To me, this is obvious, but for example Postgres always transfers data high-endian over a network,
which is ridicuous. So, for example if they send binary data from an i386 machine to another i386
machine, they perform byte-swapping twice, unnecessary,
Regards,
Adriaan van Os
More information about the fpc-pascal
mailing list