| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Re: Big endian machines |
Hi Bo! :-)
BS> Okay, but just to be scure, I will use Jasens fidoswap, I wonder if
BS> there should be any problems in that?
You still get to implement autodetection of the machine's native byteorder,
and then only use fidoswap when it is needed.
Or do something like this:
void swap16(uint16_t *orig)
{
uint8_t x,y;
x = *(uint8_t *) orig;
y = *(((uint8_t *) orig)+1);
*orig = x + y * 256;
}
That should work on both big and little endian machines, if *orig is
read from disk and is stored there in little endian byteorder.
Note that all the parens in the y expression are important, don't leave
any off or change their scope.
Ciao
Pascal
--- Msged/LNX 6.1.1
* Origin: Linux kernel 2.4.24 on Red Hat 7.3 (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™.