From: Paul Mundt <lethal@linux-sh.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: David Miller <davem@davemloft.net>, linux-arch@vger.kernel.org
Subject: Re: [PATCH 1/3] sparc: Increase portability of strncpy_from_user() implementation.
Date: Fri, 25 May 2012 01:25:00 +0900 [thread overview]
Message-ID: <20120524162459.GA29888@linux-sh.org> (raw)
In-Reply-To: <CA+55aFw8jsrqipdKq9-EiA5a+Y-HKMQmpBsirs9ojfk1yUSxww@mail.gmail.com>
On Thu, May 24, 2012 at 09:04:27AM -0700, Linus Torvalds wrote:
> On Wed, May 23, 2012 at 8:34 PM, David Miller <davem@davemloft.net> wrote:
> > -
> > +#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
> > ? ? ? ?if (((long) dst | (long) src) & (sizeof(long) - 1))
> > ? ? ? ? ? ? ? ?goto byte_at_a_time;
> > +#endif
> > +#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
> > ?byte_at_a_time:
> > +#endif
>
> Btw, this would have been much cleaner with something like
>
> #ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
> #define IS_UNALIGNED(src,dst) 0
> #else
> #define IS_UNALIGNED(src,dst) (((long)(src) | (long)(dst)) &
> (sizeof(long) - 1))
> #endif
>
> and then just
>
> if (IS_UNALIGNED(src,dst))
> goto byte_at_a_time;
>
> in the source code. Those #ifdef's in the middle of the code really
> are horribly ugly, and are unnecessary.
>
> Besides, some architecture may actually have ok unaligned loads, and
> just horrible unaligned stores, and it would be easier with that kind
> of abstraction.
>
SH-4A processors fall under this. All of them support efficient 32-bit
unaligned loads but no stores at all or loads of any other size. Having
said that, the compiler isn't exactly brilliant at figuring out when to
emit them, so I'd probably still have to do it by hand.
next prev parent reply other threads:[~2012-05-24 16:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-24 3:34 [PATCH 1/3] sparc: Increase portability of strncpy_from_user() implementation David Miller
2012-05-24 16:04 ` Linus Torvalds
2012-05-24 16:25 ` Paul Mundt [this message]
2012-05-24 20:04 ` David Miller
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=20120524162459.GA29888@linux-sh.org \
--to=lethal@linux-sh.org \
--cc=davem@davemloft.net \
--cc=linux-arch@vger.kernel.org \
--cc=torvalds@linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).