Re: What does it take to make code endian clean? (fwd)
---------- Forwarded message ----------
Date: Tue, 13 Mar 2001 12:16:42 +0100
From: Gjermund Gusland Thorsen <90167484@mobilpost.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Subject: Re: What does it take to make code endian clean?
Anything I'm missing?
Is this part of a HOWTO?
No? I have ordered some Microgate HDLC cards and installed them but I get
kernel panic, due to endianness? do I switch to x86 box instead?
TIA,
Gjermund
----------
>From: Geert Uytterhoeven <geert@linux-m68k.org>
>To: Gjermund Gusland Thorsen <90167484@mobilpost.com>
>Subject: Re: What does it take to make code endian clean?
>Date: tir 13. mar 2001 09:13
>
> On 13 Mar 2001, Gjermund Gusland Thorsen wrote:
>> What does it take to make code not depending on little or big endian
>
> - Never make assumptions about the ordering of bytes in a multi-word entity
> (short, int, long, long long). I.e. don't cast the address of an int to a
> char pointer and access the individual bytes. Avoid casts of pointers to
> pointers to entities of different sizes.
>
> - When accessing the hardware, use the correct functions for the specific
bus
> type. PCI memory space requires {read,write}[bwl](), PCI I/O space
requires
> {in,out}[bwl](). These functions take care of the PCI bus being little
> endian.
>
> - When handling data that is in a specific endianness, use the
cpu_to[bl]e*()
> and [bl]e*_to_cpu() conversion routines. In the case of TCP/IP (which is
> big endian), use the hton*() and ntoh*() functions.
>
> Anything I'm missing?
> Is this part of a HOWTO?
>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 --
geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like
that.
> -- Linus Torvalds
>
>
> --
> To UNSUBSCRIBE, email to debian-powerpc-request@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
>
Reply to: