From: Steven Whitehouse <swhiteho@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 1/3] bitops: Add __ffs64 bitop
Date: Thu, 23 Apr 2009 10:16:54 +0100 [thread overview]
Message-ID: <1240478216-2594-2-git-send-email-swhiteho@redhat.com> (raw)
In-Reply-To: <1240478216-2594-1-git-send-email-swhiteho@redhat.com>
Finds the first set bit in a 64 bit word. This is required in order
to fix a bug in GFS2, but I think it should be a generic function
in case of future users.
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Reviewed-by: Christoph Lameter <cl@linux.com>
Reviewed-by: Willy Tarreau <w@1wt.eu>
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index 6182913..c05a29c 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -112,6 +112,25 @@ static inline unsigned fls_long(unsigned long l)
return fls64(l);
}
+/**
+ * __ffs64 - find first set bit in a 64 bit word
+ * @word: The 64 bit word
+ *
+ * On 64 bit arches this is a synomyn for __ffs
+ * The result is not defined if no bits are set, so check that @word
+ * is non-zero before calling this.
+ */
+static inline unsigned long __ffs64(u64 word)
+{
+#if BITS_PER_LONG == 32
+ if (((u32)word) == 0UL)
+ return __ffs((u32)(word >> 32)) + 32;
+#elif BITS_PER_LONG != 64
+#error BITS_PER_LONG not 32 or 64
+#endif
+ return __ffs((unsigned long)word);
+}
+
#ifdef __KERNEL__
#ifdef CONFIG_GENERIC_FIND_FIRST_BIT
--
1.6.0.6
next prev parent reply other threads:[~2009-04-23 9:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-23 9:16 [Cluster-devel] GFS2: Block alloc fixes Steven Whitehouse
2009-04-23 9:16 ` Steven Whitehouse [this message]
2009-04-23 9:16 ` [Cluster-devel] [PATCH 2/3] GFS2: Fix bug in block allocation Steven Whitehouse
2009-04-23 9:16 ` [Cluster-devel] [PATCH 3/3] GFS2: Ensure that the inode goal block settings are updated Steven Whitehouse
[not found] ` <52615.1240839635@turing-police.cc.vt.edu>
2009-04-27 15:41 ` [Cluster-devel] Re: [PATCH 1/3] bitops: Add __ffs64 bitop Steven Whitehouse
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=1240478216-2594-2-git-send-email-swhiteho@redhat.com \
--to=swhiteho@redhat.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