From: Andi Kleen <andi@firstfloor.org>
To: Andreas Herrmann <herrmann.der.user@googlemail.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@elte.hu>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org,
Borislav Petkov <borislav.petkov@amd.com>,
Zhu Yi <yi.zhu@intel.com>,
"Luis R. Rodriguez" <lrodriguez@atheros.com>
Subject: Re: [PATCH] bitops: Provide generic sign_extend function (moving it out from wireless code)
Date: Fri, 27 Aug 2010 12:27:53 +0200 [thread overview]
Message-ID: <87k4ncic46.fsf@basil.nowhere.org> (raw)
In-Reply-To: <20100827101651.GC5348@loge.amd.com> (Andreas Herrmann's message of "Fri, 27 Aug 2010 12:16:51 +0200")
Andreas Herrmann <herrmann.der.user@googlemail.com> writes:
>
> +/**
> + * sign_extend - Sign extend a value using specified bit as sign-bit
> + * @value: value to sign extend
> + * @index: 0 based bit index (0<=index<32) to sign bit
> + */
> +static inline __s32 sign_extend(__u32 value, int index)
> +{
> + __u8 shift = 31 - index;
> + return (__s32)(value << shift) >> shift;
> +}
If it only handles 32bit please call it sign_extend32
-Andi
--
ak@linux.intel.com -- Speaking for myself only.
next prev parent reply other threads:[~2010-08-27 10:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-27 10:16 [PATCH] bitops: Provide generic sign_extend function (moving it out from wireless code) Andreas Herrmann
2010-08-27 10:27 ` Andi Kleen [this message]
2010-08-27 19:28 ` Luis R. Rodriguez
2010-08-27 22:09 ` Bob Copeland
2010-08-30 19:04 ` [PATCH v2] bitops: Provide generic sign_extend32 function Andreas Herrmann
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=87k4ncic46.fsf@basil.nowhere.org \
--to=andi@firstfloor.org \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=borislav.petkov@amd.com \
--cc=herrmann.der.user@googlemail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lrodriguez@atheros.com \
--cc=mingo@elte.hu \
--cc=yi.zhu@intel.com \
/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