* we'll need to move the functions to archi specific headers.
*/
-#if (defined __linux__ && defined __KERNEL__)
-#include <linux/hash.h>
-
-#define cfs_hash_long(val, bits) hash_long(val, bits)
-#else
+#ifdef __KERNEL__
+# include <linux/hash.h>
+#else /* __KERNEL__ */
/* Fast hashing routine for a long.
(C) 2002 William Lee Irwin III, IBM */
-#if BITS_PER_LONG == 32
+# if BITS_PER_LONG == 32
/* 2^31 + 2^29 - 2^25 + 2^22 - 2^19 - 2^16 + 1 */
-#define CFS_GOLDEN_RATIO_PRIME CFS_GOLDEN_RATIO_PRIME_32
-#elif BITS_PER_LONG == 64
+# define CFS_GOLDEN_RATIO_PRIME CFS_GOLDEN_RATIO_PRIME_32
+# elif BITS_PER_LONG == 64
/* 2^63 + 2^61 - 2^57 + 2^54 - 2^51 - 2^18 + 1 */
-#define CFS_GOLDEN_RATIO_PRIME CFS_GOLDEN_RATIO_PRIME_64
-#else
-#error Define CFS_GOLDEN_RATIO_PRIME for your wordsize.
-#endif
+# define CFS_GOLDEN_RATIO_PRIME CFS_GOLDEN_RATIO_PRIME_64
+# else
+# error Define CFS_GOLDEN_RATIO_PRIME for your wordsize.
+# endif /* BITS_PER_LONG == 64 */
-static inline unsigned long cfs_hash_long(unsigned long val, unsigned int bits)
+static inline unsigned long hash_long(unsigned long val, unsigned int bits)
{
unsigned long hash = val;
-#if BITS_PER_LONG == 64
+# if BITS_PER_LONG == 64
/* Sigh, gcc can't optimise this alone like it does for 32 bits. */
unsigned long n = hash;
n <<= 18;
hash += n;
n <<= 2;
hash += n;
-#else
+# else /* BITS_PER_LONG == 64 */
/* On some cpus multiply is faster, on others gcc will do shifts */
hash *= CFS_GOLDEN_RATIO_PRIME;
-#endif
+# endif /* BITS_PER_LONG != 64 */
/* High bits are more random, so use them. */
return hash >> (BITS_PER_LONG - bits);
}
-#if 0
-static inline unsigned long hash_ptr(void *ptr, unsigned int bits)
-{
- return cfs_hash_long((unsigned long)ptr, bits);
-}
-#endif
-
-/* !(__linux__ && __KERNEL__) */
-#endif
+#endif /* !__KERNEL__ */
/** disable debug */
#define CFS_HASH_DEBUG_NONE 0
}
/* Generic debug formatting routines mainly for proc handler */
-#ifndef HAVE_ONLY_PROCFS_SEQ
-int cfs_hash_debug_header(char *str, int size);
-int cfs_hash_debug_str(cfs_hash_t *hs, char *str, int size);
-#endif
struct seq_file;
-int cfs_hash_debug_header_seq(struct seq_file *m);
-int cfs_hash_debug_str_seq(cfs_hash_t *hs, struct seq_file *m);
+int cfs_hash_debug_header(struct seq_file *m);
+int cfs_hash_debug_str(cfs_hash_t *hs, struct seq_file *m);
/*
* Generic djb2 hash algorithm for character arrays.