[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: endian issues



Glenn McGrath <bug1@optushome.com.au> writes:

> The partitioning program im looking at makes calls to __cpu_le16 which
> is defined in the /usr/include/linux/byteorder/ directroy but i cant see
> an equivalent under the Hurd anywhere.

The Linux definitions look quite portable (apart from their use
of __ identifiers) so I think you could just copy them to the
program and it would work on the Hurd or any other system.

> I dont really understand how endian issues are handled in linux, but i
> dont think it should be a problem under the Hurd because its just on one
> platform.

That may change.  And you have to worry about endiannesses anyway
if you want to make your binary files compatible with big-endian
machines running other operating systems.

> If hurd was on different endian type machines would it all be taken care
> of by the microkernel anyway ?

No.  I assume the partitioning program builds the partition table
in memory and then writes it to the disk as one chunk.  The
microkernel does not know the chunk contains integers in some
endianness -- all it sees is bytes.  The conversion must be done
by the program.

Mach IPC is a different matter.  There every integer is tagged
and can be converted.

> I guess i should just find a way to ignore endian related code when
> compiling under the Hurd.

That would work for a while, because numbers in the partition
table are stored in native i386 byte order (little endian).  But
it's still wrong in principle, and will break when the Hurd is
ported to a big-endian platform.



Reply to: