Re: Why get/put_unaligned are hidden behind #ifdef __KERNEL__ on PowerPC and Microblaze?

From: Arnd Bergmann
Date: Sun Oct 31 2010 - 13:44:32 EST


On Sunday 31 October 2010, Igor Zhbanov wrote:
> 2010/10/31 Andreas Schwab <schwab@xxxxxxxxxxxxxx>:

> I think that unaligned memory access interface are stable, so it can
> be safely exported
> to user space. We have some other platform-related exported headers,
> e.g. <asm/byteorder.h>,
> so why not to export <asm/unaligned.h>. Let it be "official" way to
> deal with unaligned data
> in user space too.

There are libraries to deal with stuff like this. The kernel headers
are in no way a portable way to do this and any code that tries to
use them in this way would not even be portable across different
distribution that put the kernel headers in different places or
to architectures that define these functions as extern.

If you need something like get_unaligned, look in places like
http://ccan.ozlabs.org or http://www.gnu.org/software/gnulib/.

You can also use a generic gcc based implementation that uses
attribute((packed)) for unaligned access.

Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/