Re: inclusion of <endian.h> in a kernel header? ok or not?

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Adrian Bunk <bunk@...>
Cc: LKML <linux-kernel@...>
Date: Tuesday, August 19, 2008 - 5:06 pm

2008/8/19 Adrian Bunk <bunk@kernel.org>:

Agree.
But as I want to do it right I'd like to know what the best way is.
would that be including <asm/byteorder.h> and then have code with
#ifdef __LITTLE_ENDIAN
#else
#endif
be the preferred solution?

(I don't want to use the conversion functions just want to get the
leftmost short from an uint32_t)

With gcc 4.1.3 (which is the default on my ubuntu 7.10 dev system) a
typecast like
a_short = *(unsigned short volatile *)&a_long;
which would do the trick gives faulty code with -O2 or up.
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
inclusion of &lt;endian.h&gt; in a kernel header? ok or not?, Frans Meulenbroeks, (Tue Aug 19, 3:16 pm)
Re: inclusion of <endian.h> in a kernel header? ok or not?, Frans Meulenbroeks, (Tue Aug 19, 5:06 pm)