From: Russell King <rmk-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org>
To: Harvey Harrison
<harvey.harrison-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Andrew Morton
<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>,
linux-arch <linux-arch-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCHv2 1/8] kernel: add common infrastructure for unaligned access
Date: Fri, 11 Apr 2008 19:09:28 +0100 [thread overview]
Message-ID: <20080411180928.GA9137@flint.arm.linux.org.uk> (raw)
In-Reply-To: <1207872394.22001.69.camel@brick>
On Thu, Apr 10, 2008 at 05:06:34PM -0700, Harvey Harrison wrote:
> +#define __get_unaligned_cpu(ptr) ({ \
> + const void *__gu_p = (ptr); \
> + typeof(*(ptr)) __val; \
> + switch (sizeof(*(ptr))) { \
> + case 1: \
> + __val = *(const u8 *)__gu_p; \
> + break; \
> + case 2: \
> + __val = __get_unaligned_cpu16(__gu_p); \
> + break; \
> + case 4: \
> + __val = __get_unaligned_cpu32(__gu_p); \
> + break; \
> + case 8: \
> + __val = __get_unaligned_cpu64(__gu_p); \
> + break; \
> + default: \
> + BUILD_BUG_ON(1); \
> + break; \
> + }; \
> + __val; })
This won't work - on ARM we used to use this style, but it fails in
some corner case, so we ended up switching to using GCC's
__builtin_choose_expr() instead.
Such a corner case:
static unsigned long foo(const unsigned long *ptr)
{
return __get_unaligned_cpu(ptr);
}
This results in '__val' being declared as const, and therefore the
compiler errors out in the switch statement since the code tries to
assign to a const '__val'.
See 17b602b1c1a38f3f0a4461bb1f571346e751b36b.
So, for the present set of patches, NAK for changing ARM.
--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of:
WARNING: multiple messages have this Message-ID (diff)
From: Russell King <rmk@arm.linux.org.uk>
To: Harvey Harrison <harvey.harrison@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-arch <linux-arch@vger.kernel.org>
Subject: Re: [PATCHv2 1/8] kernel: add common infrastructure for unaligned access
Date: Fri, 11 Apr 2008 19:09:28 +0100 [thread overview]
Message-ID: <20080411180928.GA9137@flint.arm.linux.org.uk> (raw)
Message-ID: <20080411180928.4fHGZng-Z8OFPXA8bzXuHiekd3DaEUirrayHTndNBOE@z> (raw)
In-Reply-To: <1207872394.22001.69.camel@brick>
On Thu, Apr 10, 2008 at 05:06:34PM -0700, Harvey Harrison wrote:
> +#define __get_unaligned_cpu(ptr) ({ \
> + const void *__gu_p = (ptr); \
> + typeof(*(ptr)) __val; \
> + switch (sizeof(*(ptr))) { \
> + case 1: \
> + __val = *(const u8 *)__gu_p; \
> + break; \
> + case 2: \
> + __val = __get_unaligned_cpu16(__gu_p); \
> + break; \
> + case 4: \
> + __val = __get_unaligned_cpu32(__gu_p); \
> + break; \
> + case 8: \
> + __val = __get_unaligned_cpu64(__gu_p); \
> + break; \
> + default: \
> + BUILD_BUG_ON(1); \
> + break; \
> + }; \
> + __val; })
This won't work - on ARM we used to use this style, but it fails in
some corner case, so we ended up switching to using GCC's
__builtin_choose_expr() instead.
Such a corner case:
static unsigned long foo(const unsigned long *ptr)
{
return __get_unaligned_cpu(ptr);
}
This results in '__val' being declared as const, and therefore the
compiler errors out in the switch statement since the code tries to
assign to a const '__val'.
See 17b602b1c1a38f3f0a4461bb1f571346e751b36b.
So, for the present set of patches, NAK for changing ARM.
--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of:
next prev parent reply other threads:[~2008-04-11 18:09 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-10 19:44 [PATCH 1/8] kernel: add common infrastructure for unaligned access Harvey Harrison
2008-04-10 19:44 ` Harvey Harrison
2008-04-10 21:43 ` David Howells
2008-04-10 21:43 ` David Howells
[not found] ` <11527.1207863801-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2008-04-10 21:55 ` Harvey Harrison
2008-04-10 21:55 ` Harvey Harrison
2008-04-10 22:01 ` David Howells
2008-04-10 22:01 ` David Howells
[not found] ` <11814.1207864864-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2008-04-10 22:06 ` Harvey Harrison
2008-04-10 22:06 ` Harvey Harrison
2008-04-10 22:15 ` David Howells
2008-04-10 22:15 ` David Howells
[not found] ` <11907.1207865758-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2008-04-10 22:20 ` Harvey Harrison
2008-04-10 22:20 ` Harvey Harrison
2008-04-10 22:33 ` David Howells
2008-04-10 22:33 ` David Howells
[not found] ` <11989.1207866793-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2008-04-10 22:37 ` Harvey Harrison
2008-04-10 22:37 ` Harvey Harrison
2008-04-11 0:06 ` [PATCHv2 " Harvey Harrison
2008-04-11 0:06 ` Harvey Harrison
2008-04-11 18:09 ` Russell King [this message]
2008-04-11 18:09 ` Russell King
[not found] ` <20080411180928.GA9137-f404yB8NqCZvn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2008-04-11 19:01 ` Harvey Harrison
2008-04-11 19:01 ` Harvey Harrison
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080411180928.GA9137@flint.arm.linux.org.uk \
--to=rmk-lfz/pmaqli7xmaaqvzeohq@public.gmane.org \
--cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
--cc=harvey.harrison-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=linux-arch-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.