From: mathieu.desnoyers@efficios.com (Mathieu Desnoyers)
Subject: [ltt-dev] [PATCH 2/4] add a definition for fls() for ARM, taken from the linux kernel
Date: Tue, 22 Feb 2011 17:31:49 -0500 [thread overview]
Message-ID: <20110222223149.GA20793@Krystal> (raw)
In-Reply-To: <20110222222142.GA20613@Krystal>
* Mathieu Desnoyers (mathieu.desnoyers at efficios.com) wrote:
> * Jason Wessel (jason.wessel at windriver.com) wrote:
> > Insert the definition from the linux kernel along with the copyright
> > attribution for the fls() operation for ARM.
>
> You could instead use my own clean room reimplementation at:
>
> http://git.efficios.com/?p=babeltrace.git;a=blob;f=tests/test-bitfield.c
>
> (for LGPLv2.1 licensing concerns)
Actually, I just imported in into the UST git tree. I'll merge your other
patches, thanks !
Mathieu
>
> The header of this file states "GPL", but I give you my blessing to relicense
> the arch-agnostic fls() implementation as LGPL for UST.
>
> If you don't feel like recoding the arm-specific fls, we can leave it out and
> just use the arch-agnostic version for now.
>
> Thanks,
>
> Mathieu
>
> >
> > Signed-off-by: Jason Wessel <jason.wessel at windriver.com>
> > ---
> > include/ust/processor.h | 53 +++++++++++++++++++++++++++++++++++++++++++++++
> > 1 files changed, 53 insertions(+), 0 deletions(-)
> >
> > diff --git a/include/ust/processor.h b/include/ust/processor.h
> > index 01aa290..70e244b 100644
> > --- a/include/ust/processor.h
> > +++ b/include/ust/processor.h
> > @@ -454,6 +454,59 @@ static __inline__ int fls(unsigned int x)
> > struct registers {
> > };
> >
> > +/* constant_fls() and fls() were take directly from the linux kernel
> > + * sources in 2.6.37 from the file arch/arm/include/asm/bitops.h
> > + * which had the following copyright.
> > + *
> > + * Copyright 1995, Russell King.
> > + * Various bits and pieces copyrights include:
> > + * Linus Torvalds (test_bit).
> > + * Big endian support: Copyright 2001, Nicolas Pitre
> > + * reworked by rmk.
> > + */
> > +
> > +static inline int constant_fls(int x)
> > +{
> > + int r = 32;
> > +
> > + if (!x)
> > + return 0;
> > + if (!(x & 0xffff0000u)) {
> > + x <<= 16;
> > + r -= 16;
> > + }
> > + if (!(x & 0xff000000u)) {
> > + x <<= 8;
> > + r -= 8;
> > + }
> > + if (!(x & 0xf0000000u)) {
> > + x <<= 4;
> > + r -= 4;
> > + }
> > + if (!(x & 0xc0000000u)) {
> > + x <<= 2;
> > + r -= 2;
> > + }
> > + if (!(x & 0x80000000u)) {
> > + x <<= 1;
> > + r -= 1;
> > + }
> > + return r;
> > +}
> > +
> > +static __inline__ int fls(unsigned int x)
> > +{
> > + int ret;
> > +
> > + if (__builtin_constant_p(x))
> > + return constant_fls(x);
> > +
> > + asm("clz\t%0, %1" : "=r" (ret) : "r" (x) : "cc");
> > + ret = 32 - ret;
> > + return ret;
> > +}
> > +/*------- end of source taken from linux kernel headers -------*/
> > +
> > #define ARCH_COPY_ADDR(dst) "ldr "dst", =2b\n\t" \
> > "b 55f\n\t" \
> > ".ltorg\n\t" \
> > --
> > 1.6.6.2
> >
>
> --
> Mathieu Desnoyers
> Operating System Efficiency R&D Consultant
> EfficiOS Inc.
> http://www.efficios.com
--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
next prev parent reply other threads:[~2011-02-22 22:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-22 21:48 [ltt-dev] [PATCH 0/4] Embedded UST support for ARM and busybox Jason Wessel
2011-02-22 21:48 ` [ltt-dev] [PATCH 1/4] add ARM specific support for UST Jason Wessel
2011-02-22 21:48 ` [ltt-dev] [PATCH 2/4] add a definition for fls() for ARM, taken from the linux kernel Jason Wessel
2011-02-22 21:48 ` [ltt-dev] [PATCH 3/4] usttrace: Use /bin/sh instead of /bin/bash for busybox compatibility Jason Wessel
2011-02-22 21:48 ` [ltt-dev] [PATCH 4/4] usttrace: use short signal names " Jason Wessel
2011-02-22 22:21 ` [ltt-dev] [PATCH 2/4] add a definition for fls() for ARM, taken from the linux kernel Mathieu Desnoyers
2011-02-22 22:31 ` Mathieu Desnoyers [this message]
2011-02-22 22:24 ` [ltt-dev] [PATCH 0/4] Embedded UST support for ARM and busybox Mathieu Desnoyers
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=20110222223149.GA20793@Krystal \
--to=mathieu.desnoyers@efficios.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