The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: Harvey Harrison <harvey.harrison@gmail.com>
Cc: 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 21:45:36 +0100	[thread overview]
Message-ID: <8d55c7ae2d3c851013db4857506b537c@kernel.crashing.org> (raw)
In-Reply-To: <1205254569.22317.8.camel@brick>

> +/**
> + * 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.


Segher


  reply	other threads:[~2008-03-11 20:47 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 [this message]
2008-03-11 20:59   ` Andreas Schwab
2008-03-11 21:15     ` Harvey Harrison
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=8d55c7ae2d3c851013db4857506b537c@kernel.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=akpm@linux-foundation.org \
    --cc=harvey.harrison@gmail.com \
    --cc=linux-kernel@vger.kernel.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