From: Michal Moskal <malekith@pld.org.pl>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] gcc-3.1 ffs problem, kernel 2.4.18
Date: Wed, 20 Mar 2002 18:42:38 +0100 [thread overview]
Message-ID: <20020320174238.GA13533@ep09.kernel.pl> (raw)
Following patch is needed to compile linux-2.4.18 with xfs patch with
recent gcc 3.1 snapshot. It is clearly bug in linux includes (they use
asm code unconditionally, even on constants, and they can get constants
if exposed to tree-inliner). Other asm includes might need fixing too,
I saw asm-cris is fixed already.
Beside this linux-2.4.18 compiled with gcc-3.1 20020311 works fine for
me.
diff -ur linux-/include/asm-i386/bitops.h linux/include/asm-i386/bitops.h
--- linux-/include/asm-i386/bitops.h Thu Nov 22 20:46:18 2001
+++ linux/include/asm-i386/bitops.h Tue Mar 5 21:08:15 2002
@@ -316,6 +316,8 @@
return (offset + set + res);
}
+#include <linux/bitops.h>
+
/**
* ffz - find first zero in word.
* @word: The word to search
@@ -324,10 +326,16 @@
*/
static __inline__ unsigned long ffz(unsigned long word)
{
- __asm__("bsfl %1,%0"
- :"=r" (word)
- :"r" (~word));
- return word;
+ /* The generic_ffs function is used to avoid the asm when the
+ argument is a constant. */
+ if (__builtin_constant_p (word)) {
+ return (~word ? (unsigned long) generic_ffs ((int) ~word) - 1 : 32);
+ } else {
+ __asm__("bsfl %1,%0"
+ :"=r" (word)
+ :"r" (~word));
+ return word;
+ }
}
#ifdef __KERNEL__
@@ -342,13 +350,19 @@
*/
static __inline__ int ffs(int x)
{
- int r;
-
- __asm__("bsfl %1,%0\n\t"
- "jnz 1f\n\t"
- "movl $-1,%0\n"
- "1:" : "=r" (r) : "g" (x));
- return r+1;
+ /* The generic_ffs function is used to avoid the asm when the
+ argument is a constant. */
+ if (__builtin_constant_p (x)) {
+ return generic_ffs (x);
+ } else {
+ int r;
+
+ __asm__("bsfl %1,%0\n\t"
+ "jnz 1f\n\t"
+ "movl $-1,%0\n"
+ "1:" : "=r" (r) : "g" (x));
+ return r+1;
+ }
}
/**
--
: Michal Moskal :::::::: malekith/at/pld.org.pl : GCS {C,UL}++++$ a? !tv
: PLD Linux ::::::: Wroclaw University, CS Dept : {E-,w}-- {b++,e}>+++ h
next reply other threads:[~2002-03-20 17:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-03-20 17:42 Michal Moskal [this message]
2002-03-29 5:10 ` [PATCH] gcc-3.1 ffs problem, kernel 2.4.18 Richard Henderson
[not found] ` <20020329115731.GA3227@ep09.kernel.pl>
[not found] ` <20020329144232.A495@twiddle.net>
[not found] ` <20020402114848.GA9004@ep09.kernel.pl>
2002-04-02 22:59 ` Richard Henderson
2002-04-03 0:04 ` Linus Torvalds
2002-04-03 11:00 ` Richard Henderson
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=20020320174238.GA13533@ep09.kernel.pl \
--to=malekith@pld.org.pl \
--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