lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Tue, 19 Aug 2008 23:06:04 +0200
From:	"Frans Meulenbroeks" <fransmeulenbroeks@...il.com>
To:	"Adrian Bunk" <bunk@...nel.org>
Cc:	LKML <linux-kernel@...r.kernel.org>
Subject: Re: inclusion of <endian.h> in a kernel header? ok or not?

2008/8/19 Adrian Bunk <bunk@...nel.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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ