* inclusion of <endian.h> in a kernel header? ok or not?
@ 2008-08-19 19:16 Frans Meulenbroeks
2008-08-19 19:52 ` Adrian Bunk
0 siblings, 1 reply; 3+ messages in thread
From: Frans Meulenbroeks @ 2008-08-19 19:16 UTC (permalink / raw)
To: LKML
Is it ok to #include <endian.h> in a kernel header file.
This is done in linux/patchkey.h and linux/soundcard.h but other
places seem to prefer <asm/byteorder.h>
Basically I am looking for a simple way to isolate a piece of endian
specific code (something like #ifdef BIG_ENDIAN ...#endif
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: inclusion of <endian.h> in a kernel header? ok or not?
2008-08-19 19:16 inclusion of <endian.h> in a kernel header? ok or not? Frans Meulenbroeks
@ 2008-08-19 19:52 ` Adrian Bunk
2008-08-19 21:06 ` Frans Meulenbroeks
0 siblings, 1 reply; 3+ messages in thread
From: Adrian Bunk @ 2008-08-19 19:52 UTC (permalink / raw)
To: Frans Meulenbroeks; +Cc: LKML
On Tue, Aug 19, 2008 at 09:16:56PM +0200, Frans Meulenbroeks wrote:
> Is it ok to #include <endian.h> in a kernel header file.
> This is done in linux/patchkey.h and linux/soundcard.h but other
> places seem to prefer <asm/byteorder.h>
>...
Look at the two files you mention - they only do it in userspace.
And considering that these only users in the kernel are in the OSS code
it's most likely not the best solution.
cu
Adrian
--
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: inclusion of <endian.h> in a kernel header? ok or not?
2008-08-19 19:52 ` Adrian Bunk
@ 2008-08-19 21:06 ` Frans Meulenbroeks
0 siblings, 0 replies; 3+ messages in thread
From: Frans Meulenbroeks @ 2008-08-19 21:06 UTC (permalink / raw)
To: Adrian Bunk; +Cc: LKML
2008/8/19 Adrian Bunk <bunk@kernel.org>:
> On Tue, Aug 19, 2008 at 09:16:56PM +0200, Frans Meulenbroeks wrote:
>> Is it ok to #include <endian.h> in a kernel header file.
>> This is done in linux/patchkey.h and linux/soundcard.h but other
>> places seem to prefer <asm/byteorder.h>
>>...
>
> Look at the two files you mention - they only do it in userspace.
>
> And considering that these only users in the kernel are in the OSS code
> it's most likely not the best solution.
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-08-19 21:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-19 19:16 inclusion of <endian.h> in a kernel header? ok or not? Frans Meulenbroeks
2008-08-19 19:52 ` Adrian Bunk
2008-08-19 21:06 ` Frans Meulenbroeks
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®