The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH 1/8] dynamic debug - move hashing functions
@ 2008-06-13 18:59 Jason Baron
  0 siblings, 0 replies; only message in thread
From: Jason Baron @ 2008-06-13 18:59 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, joe, greg, nick, randy.dunlap


-move useful dcache hashing functions from include/linux/dcache.h
to include/linux/hash.h. This allows other kernel components
to just include the hashing functions without all of dcache.h

Signed-off-by: Jason Baron <jbaron@redhat.com>

---

 include/linux/dcache.h |   30 ------------------------------
 include/linux/hash.h   |   31 +++++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 30 deletions(-)


diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index cfb1627..a248b7f 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -46,36 +46,6 @@ struct dentry_stat_t {
 };
 extern struct dentry_stat_t dentry_stat;
 
-/* Name hashing routines. Initial hash value */
-/* Hash courtesy of the R5 hash in reiserfs modulo sign bits */
-#define init_name_hash()		0
-
-/* partial hash update function. Assume roughly 4 bits per character */
-static inline unsigned long
-partial_name_hash(unsigned long c, unsigned long prevhash)
-{
-	return (prevhash + (c << 4) + (c >> 4)) * 11;
-}
-
-/*
- * Finally: cut down the number of bits to a int value (and try to avoid
- * losing bits)
- */
-static inline unsigned long end_name_hash(unsigned long hash)
-{
-	return (unsigned int) hash;
-}
-
-/* Compute the hash for a name string. */
-static inline unsigned int
-full_name_hash(const unsigned char *name, unsigned int len)
-{
-	unsigned long hash = init_name_hash();
-	while (len--)
-		hash = partial_name_hash(*name++, hash);
-	return end_name_hash(hash);
-}
-
 struct dcookie_struct;
 
 #define DNAME_INLINE_LEN_MIN 36
diff --git a/include/linux/hash.h b/include/linux/hash.h
index 06d25c1..4083a01 100644
--- a/include/linux/hash.h
+++ b/include/linux/hash.h
@@ -67,4 +67,35 @@ static inline unsigned long hash_ptr(void *ptr, unsigned int bits)
 {
 	return hash_long((unsigned long)ptr, bits);
 }
+
+/* Name hashing routines. Initial hash value */
+/* Hash courtesy of the R5 hash in reiserfs modulo sign bits */
+#define init_name_hash()                0
+
+/* partial hash update function. Assume roughly 4 bits per character */
+static inline unsigned long
+partial_name_hash(unsigned long c, unsigned long prevhash)
+{
+	return (prevhash + (c << 4) + (c >> 4)) * 11;
+}
+
+/*
+ * Finally: cut down the number of bits to a int value (and try to avoid
+ * losing bits)
+ */
+static inline unsigned long end_name_hash(unsigned long hash)
+{
+	return (unsigned int) hash;
+}
+
+/* Compute the hash for a name string. */
+static inline unsigned int
+full_name_hash(const unsigned char *name, unsigned int len)
+{
+	unsigned long hash = init_name_hash();
+	while (len--)
+		hash = partial_name_hash(*name++, hash);
+	return end_name_hash(hash);
+}
+
 #endif /* _LINUX_HASH_H */

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2008-06-13 19:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-13 18:59 [PATCH 1/8] dynamic debug - move hashing functions Jason Baron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox