TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Bo Simonsen
from: Pascal Schmidt
date: 2004-01-24 01:13:04
subject: Re: Big endian machines

Hi Bo! :-)

 BS> On little endian machines it should just be defined as fido_swap(x)
 BS> with no action?
Yes, right.

 PS>> Or do something like this:

 PS>> void swap16(uint16_t *orig)
 PS>> {
 PS>>     uint8_t x,y;

 PS>>     x = *(uint8_t *) orig;
 PS>>     y = *(((uint8_t *) orig)+1);

 PS>>     *orig = x + y * 256;
 PS>> }

 PS>> That should work on both big and little endian machines, if *orig is
 PS>> read from disk and is stored there in little endian byteorder.

 BS> Aha smart!
Best try it on a big endian machine first, though, I didn't actually try to
compile or run this piece of code. I don't even know if it works on a
little endian machine. It should, but I may have made mistakes.

Ciao
Pascal

--- Msged/LNX 6.1.1
* Origin: By order of the king, the city must empty. (1:153/401.2)
SEEN-BY: 633/267 270
@PATH: 153/401 307 140/1 106/2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.