From: Harvey Harrison <harvey.harrison@gmail.com>
To: Andreas Schwab <schwab@suse.de>
Cc: Segher Boessenkool <segher@kernel.crashing.org>,
LKML <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] bitops: add 8-bit and 16-bit rotation functions
Date: Tue, 11 Mar 2008 14:15:02 -0700 [thread overview]
Message-ID: <1205270102.22317.40.camel@brick> (raw)
In-Reply-To: <je1w6hc6yw.fsf@sykes.suse.de>
On Tue, 2008-03-11 at 21:59 +0100, Andreas Schwab wrote:
> Segher Boessenkool <segher@kernel.crashing.org> writes:
>
> >> +/**
> >> + * rol16 - rotate a 16-bit value left
> >> + * @word: value to rotate
> >> + * @shift: bits to roll
> >> + */
> >> +static inline __u16 rol16(__u16 word, unsigned int shift)
> >> +{
> >> + return (word << shift) | (word >> (16 - shift));
> >> +}
> >
> > This doesn't work for shift values of 0: you get word >> 16, and
> > shifts greater than or equal to the word size aren't valid C. GCC
> > will warn about this, too.
>
> On the other hand, a value narrower than int will always be promoted
> first, so this is not a problem in this case.
>
It's the same way rol32/ror32 is done directly above this section, I saw
this as well, but figured that if checking for shift = 0 was wanted, it
would have been there.
So...don't do that ;-)
Harvey
next prev parent reply other threads:[~2008-03-11 21:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-11 16:56 [PATCH] bitops: add 8-bit and 16-bit rotation functions Harvey Harrison
2008-03-11 20:45 ` Segher Boessenkool
2008-03-11 20:59 ` Andreas Schwab
2008-03-11 21:15 ` Harvey Harrison [this message]
2008-03-11 21:18 ` Segher Boessenkool
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=1205270102.22317.40.camel@brick \
--to=harvey.harrison@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=schwab@suse.de \
--cc=segher@kernel.crashing.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.