From: "Darren Jenkins\\" <darrenrjenkins@gmail.com>
To: kernel Janitors <kernel-janitors@lists.osdl.org>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [kj][RFC] roll macro's in bitops.h
Date: Sat, 17 Feb 2007 11:02:51 +1100 [thread overview]
Message-ID: <1171670571.7850.27.camel@localhost.localdomain> (raw)
G'day people,
I was looking at bitops.h and noticed there were a couple of inline roll
functions to operate on 32bit variables. (left and right)
I think that is a little bit dumb as they are constant width (only
32bits) due to it being an inline function, and was wondering if anyone
thought it would be useful to have some (variable sized) roll macros
instead.
I whipped these twp up as examples, but have not tested them yet.
#define RollRight(Data, Distance) \
({ typeof(Data) __a = Data; \
typeof(Distance) __b = Distance%(sizeof(__a) * 8); \
__a = ((__a>>__b) | (__a<<((sizeof(__a) * 8) - __b))) \
__a; \
})
#define RollLeft(Data, Distance) \
({ typeof(Data) __a = Data; \
typeof(Distance) __b = Distance%(sizeof(__a) * 8); \
__a = ((__a<<__b) | (__a>>((sizeof(__a) * 8) - __b))) \
__a; \
})
Also if these are useful I was wondering how to handle the existing
functions ? #define them out for the time being ?
#define rol32(a, b) RollLeft(a, b)
#define ror32(a, b) RollRight(a, b)
Darren Jenkins
reply other threads:[~2007-02-17 0:03 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1171670571.7850.27.camel@localhost.localdomain \
--to=darrenrjenkins@gmail.com \
--cc=kernel-janitors@lists.osdl.org \
--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