From 16ef714eb7c8f14abe5706e24d1492f70c610044 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Fri, 9 Sep 2005 09:18:49 +0200 Subject: [PATCH] [PATCH] Use __WORDSIZE in hash Originally fron Nathan, improved to remove 'bpl' as well. --- blkparse.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/blkparse.c b/blkparse.c index a83d9e9..292535d 100644 --- a/blkparse.c +++ b/blkparse.c @@ -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) -- 2.25.1