From: Jens Axboe Date: Fri, 9 Sep 2005 07:18:49 +0000 (+0200) Subject: [PATCH] Use __WORDSIZE in hash X-Git-Tag: blktrace-0.99~184 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=16ef714eb7c8f14abe5706e24d1492f70c610044;p=blktrace.git [PATCH] Use __WORDSIZE in hash Originally fron Nathan, improved to remove 'bpl' as well. --- 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)