Re: User level Macros for Endianess

2 messages, 2 authors, 2000-01-12 · open the first message on its own page

Re: User level Macros for Endianess

From: Jesper Skov <hidden>
Date: 2000-01-12 09:11:03

quoted
quoted
quoted
quoted
"iweiny" == iweiny  [off-list ref] writes:
iweiny> What Macros should I be using to key off of for this?  I have
iweiny> looked through /usr/include/endian.h and
iweiny> /usr/include/bits/endian.h.  BYTE_ORDER (without the leading
iweiny> underscores) is only defined if __USE_BSD is defined.  BOTH
iweiny> __BIG_ENDIAN and __LITTLE_ENDIAN are defined as are BIG_ENDIAN
iweiny> and LITTLE_ENDIAN.  I'm so confused?

#include <asm/byteorder.h>

then use __le32_to_cpu and friends (see
/usr/include/linux/byteorder/generic.h)

I'm not sure if that's the Proper Way(TM) to do it from user land
though.

Jesper

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

Re: User level Macros for Endianess

From: Gabriel Paubert <hidden>
Date: 2000-01-12 09:31:45



On 12 Jan 2000, Jesper Skov wrote:
#include <asm/byteorder.h>

then use __le32_to_cpu and friends (see
/usr/include/linux/byteorder/generic.h)

I'm not sure if that's the Proper Way(TM) to do it from user land
though.
No, it's very different between application and kernel code (unfortunately
since this forced me to write 2 very different vme.h include files for VME
systems, it's not only a simple cp). Under Linux, asm/byteorder.h is the
right way to get the correct macros, and either LITTLE_ENDIAN or
BIG_ENDIAN is defined.
From userland both are defined and then BYTE_ORDER is set to one of these
(strange architecture might even have a byte order which is neither like
the PDP) so the check is #if __BYTE_ORDER==__BIG_ENDIAN ...

	Gabriel.


** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help