From: "MAGENHEIMER,DAN (HP-FtCollins,ex1)" <dan_magenheimer@hp.com>
To: linux-ia64@vger.kernel.org
Subject: [Linux-ia64] ia64_fls patch (asm-ia64/bitops.h)
Date: Thu, 16 Jan 2003 22:48:33 +0000 [thread overview]
Message-ID: <marc-linux-ia64-105590709805705@msgid-missing> (raw)
Here's a patch for a mistake in ia64_fls in bitops.h. The result
was incorrect (64) for inputs starting at 0xfffffffffffffc00.
I've also fixed the comment and the return value (which was -65535!)
for a zero input value. According to davidm, existing calls don't use
any of the "bad" input values so classify it as a bug waiting to happen.
This is on 2.4.20... I haven't looked at 2.5.x but I'd imagine
the patch needs to be put there too.
This is my first post and my first patch... apologies in advance (and
correct protocol pointers welcome) if anything goes wrong!
Dan Magenheimer
HP Laboratories Fort Collins
==
diff -Nur include/asm-ia64/bitops.h include-fix-ia64_ffs/asm-ia64/bitops.h
--- include/asm-ia64/bitops.h 2003-01-02 11:38:26.000000000 -0700
+++ include-fix-ia64_ffs/asm-ia64/bitops.h 2003-01-16
15:36:12.000000000 -0700
@@ -283,17 +283,19 @@
#ifdef __KERNEL__
/*
- * find_last_zero_bit - find the last zero bit in a 64 bit quantity
+ * find_last_set_bit - find the last set bit in a non-zero 64 bit quantity
* @x: The value to search
+ * returns -1 if the input is all zeroes, else the bit number of the most
+ * significant one-bit
*/
static inline unsigned long
ia64_fls (unsigned long x)
{
- double d = x;
+ long double d = x;
long exp;
__asm__ ("getf.exp %0=%1" : "=r"(exp) : "f"(d));
- return exp - 0xffff;
+ return x ? (exp - 0xffff) : -1L;
}
/*
next reply other threads:[~2003-01-16 22:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-16 22:48 MAGENHEIMER,DAN (HP-FtCollins,ex1) [this message]
2003-01-16 22:53 ` [Linux-ia64] ia64_fls patch (asm-ia64/bitops.h) David Mosberger
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=marc-linux-ia64-105590709805705@msgid-missing \
--to=dan_magenheimer@hp.com \
--cc=linux-ia64@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