[CLUE-Tech] Byte Order

Dave Hahn dhahn at techangle.com
Wed Dec 20 11:07:53 MST 2000


Gary:

Found this note on a google search.  Not sure if it helps or not, but it is,
at least, a description.  Although Linux will operate on little-endian or
big-endian machines, data storage seems to be the kicker in moving
information back and forth.
=====

Linux has been written on a little endian architecture: intel. In
little-endian mode linux is well tested, the kernel works perfectly. If you
chose big-endian mode, linux is still operational, but some parts of the
kernel will be broken. Drivers, filesystems etc...  must be written in a
big-endian compatible way, all 16bits, 32bits access to hardware or to
external data structures must be converted using some macros defined in the
linux kernel.




-Dave Hahn
-TechAngle Inc.
-dhahn at techangle.com
----- Original Message -----
From: <gary.l.shapiro at lmco.com>
To: <clue-tech at ta8.techangle.com>
Sent: Wednesday, December 20, 2000 9:52 AM
Subject: [CLUE-Tech] Byte Order


> I just started using a Linux computer for the first time, and I've already
noticed a peculiar phenomenon. We have some code which was designed to be
portable: it works on both PC (Windows) and Unix platforms. To do this, the
code performs a "check" on the byte order, which consists of placing a short
constant (1) in memory, then examining the first byte. If the byte is 1, the
machine is LittleEndian, if 0, the machine is BigEndian. Of course, the
Linux machine, being an Intel, is LittleEndian. When the data is written to
a binary file using fwrite, however, it writes it in BigEndian order. Is
this normal for Linux? Of course, the data is "marked" as LittleEndian, even
though it is written as BigEndian, which creates problems when I read in the
data for another program. The obvious solution is to override the byte check
when using Linux. If this is standard Linux behavior, what indicator can I
use to do this and still keep the current behavior on Windows and Unix
platforms?
>
> Gary Shapiro
> Software Engineer
> Advanced Processing Group
> Lockheed Martin Space Systems / Astronautics Operations
> Denver, CO
> _______________________________________________
> CLUE-Tech mailing list
> CLUE-Tech at clue.denver.co.us
> http://clue.denver.co.us/mailman/listinfo/clue-tech
>




More information about the clue-tech mailing list