linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Erik Andersen <andersen@codepoet.org>
To: Alan Cox <alan@redhat.com>, linux-kernel@vger.kernel.org
Subject: [PATCH] fix bitops.h circular dependancies
Date: Fri, 23 Aug 2002 09:16:15 -0600	[thread overview]
Message-ID: <20020823151615.GB24609@codepoet.org> (raw)
In-Reply-To: <20020823145907.GA24609@codepoet.org>

On Fri Aug 23, 2002 at 08:59:08AM -0600, Erik wrote:
> It appears that linux/bitops.h includes asm/bitops.h, which itself
> includes linux/bitops.h prior to the #define fls(x)...  Both files
> have include guards, therefore the #define never happens....

Here is a fix.  Not an ideal fix, but it at least works.


--- linux-2.4.20-pre4-ac1/include/asm/bitops.h.orig	Fri Aug 23 08:56:27 2002
+++ linux-2.4.20-pre4-ac1/include/asm/bitops.h	Fri Aug 23 09:12:02 2002
@@ -24,6 +24,35 @@
 
 #define ADDR (*(volatile long *) addr)
 
+static __inline__ int __generic_ffs(int x)
+{
+	int r = 1;
+
+	if (!x)
+		return 0;
+	if (!(x & 0xffff)) {
+		x >>= 16;
+		r += 16;
+	}
+	if (!(x & 0xff)) {
+		x >>= 8;
+		r += 8;
+	}
+	if (!(x & 0xf)) {
+		x >>= 4;
+		r += 4;
+	}
+	if (!(x & 3)) {
+		x >>= 2;
+		r += 2;
+	}
+	if (!(x & 1)) {
+		x >>= 1;
+		r += 1;
+	}
+	return r;
+}
+
 /**
  * set_bit - Atomically set a bit in memory
  * @nr: the bit to set
@@ -386,8 +415,6 @@
 	return (offset + set + res);
 }
 
-#include <linux/bitops.h>
-
 /**
  * ffz - find first zero in word.
  * @word: The word to search
@@ -399,7 +426,7 @@
 	/* 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);
+		return (~word ? (unsigned long) __generic_ffs ((int) ~word) - 1 : 32);
 	} else {
 		__asm__("bsfl %1,%0"
 			:"=r" (word)
@@ -462,7 +489,7 @@
 	/* 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);
+		return __generic_ffs (x);
 	} else {
 		int r;
 
--- linux-2.4.20-pre4-ac1/include/linux/bitops.h.orig	Fri Aug 23 08:57:43 2002
+++ linux-2.4.20-pre4-ac1/include/linux/bitops.h	Fri Aug 23 09:12:12 2002
@@ -2,6 +2,7 @@
 #define _LINUX_BITOPS_H
 #include <asm/bitops.h>
 
+
 /*
  * ffs: find first bit set. This is defined the same way as
  * the libc and compiler builtin ffs routines, therefore
@@ -106,8 +107,5 @@
         res = (res & 0x33) + ((res >> 2) & 0x33);
         return (res & 0x0F) + ((res >> 4) & 0x0F);
 }
-
-#include <asm/bitops.h>
-
 
 #endif

 -Erik

--
Erik B. Andersen             http://codepoet-consulting.com/
--This message was written using 73% post-consumer electrons--

  reply	other threads:[~2002-08-23 15:12 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-23 10:46 Linux 2.4.20-pre4-ac1 Alan Cox
2002-08-23 12:21 ` Erik Andersen
2002-08-23 14:06 ` Eyal Lebedinsky
2002-08-23 14:29   ` Linux 2.4.20-pre4-ac1 (this time regarding 2.5.31) Thunder from the hill
2002-08-23 14:53     ` Steven Cole
2002-08-23 15:07       ` Thunder from the hill
2002-08-23 15:52         ` Greg KH
2002-08-23 15:51   ` Linux 2.4.20-pre4-ac1 Greg KH
2002-08-23 14:59 ` Erik Andersen
2002-08-23 15:16   ` Erik Andersen [this message]
2002-08-23 15:59     ` [PATCH] fix bitops.h circular dependancies Erik Andersen
2002-08-23 15:57 ` Linux 2.4.20-pre4-ac1 Markus Plail
2002-08-23 18:16   ` Andre Hedrick
2002-08-23 16:30 ` Anssi Saari
2002-08-23 16:56   ` Markus Plail
2002-08-24 16:03     ` Anssi Saari
2002-08-23 17:18   ` Alan Cox
2002-08-23 19:30     ` Anssi Saari
2002-08-24 13:27 ` Allan Duncan
2002-08-24 13:55   ` Alan Cox
2002-08-24 14:07     ` Erik Andersen
2002-08-25 11:01       ` Tomas Szepe
2002-08-25 11:10         ` Thunder from the hill
2002-08-25 11:32           ` Thomas Molina
2002-08-25 11:45             ` Sean Neakums
2002-08-25 12:10               ` Geert Uytterhoeven
2002-08-25 12:19                 ` Thunder from the hill
2002-08-25 12:25                   ` Sean Neakums
2002-08-25 13:44                     ` Tomas Szepe
2002-08-26  2:01               ` Rik van Riel
2002-08-25 11:41           ` Tomas Szepe
2002-08-26  0:24             ` Allan Duncan
2002-08-25 21:33           ` Henning P. Schmiedehausen
2002-08-24 17:32 ` Axel Siebenwirth
2002-08-24 17:59   ` Alan Cox
2002-08-25  4:49     ` Zephaniah E. Hull
2002-08-25 20:15 ` Adrian Bunk

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=20020823151615.GB24609@codepoet.org \
    --to=andersen@codepoet.org \
    --cc=alan@redhat.com \
    --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;
as well as URLs for NNTP newsgroup(s).