[PATCH] Use __WORDSIZE in hash
authorJens Axboe <axboe@suse.de>
Fri, 9 Sep 2005 07:18:49 +0000 (09:18 +0200)
committerJens Axboe <axboe@suse.de>
Fri, 9 Sep 2005 07:18:49 +0000 (09:18 +0200)
Originally fron Nathan, improved to remove 'bpl' as well.

blkparse.c

index a83d9e93b7f9d4980fb0e726685f653ad38eb6a6..292535d15fea216be54125d8a15e573de986cb1b 100644 (file)
@@ -126,17 +126,15 @@ static volatile int done;
 
 static inline unsigned long hash_long(unsigned long val)
 {
-       const unsigned int bpl = 8 * sizeof(long);
-
-       /*
-        * assuming 32 or 64-bit
-        */
-       if (bpl == 32)
-               val *= 0x9e370001UL;
-       else
-               val *= 0x9e37fffffffc0001UL;
-
-       return val >> (bpl - PPI_HASH_SHIFT);
+#if __WORDSIZE == 32
+       val *= 0x9e370001UL;
+#elif __WORDSIZE == 64
+       val *= 0x9e37fffffffc0001UL;
+#else
+#error unknown word size
+#endif
+
+       return val >> (__WORDSIZE - PPI_HASH_SHIFT);
 }
 
 static inline void add_process_to_hash(struct per_process_info *ppi)