Module Name: src Committed By: riastradh Date: Wed Jul 24 02:24:02 UTC 2013
Modified Files: src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: hash.h Log Message: Implement hash_long in <linux/hash.h>. Uses the same hash function as in Linux, implemented differently. To generate a diff of this commit: cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \ src/sys/external/bsd/drm2/include/linux/hash.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/external/bsd/drm2/include/linux/hash.h diff -u src/sys/external/bsd/drm2/include/linux/hash.h:1.1.2.1 src/sys/external/bsd/drm2/include/linux/hash.h:1.1.2.2 --- src/sys/external/bsd/drm2/include/linux/hash.h:1.1.2.1 Wed Jul 24 00:33:12 2013 +++ src/sys/external/bsd/drm2/include/linux/hash.h Wed Jul 24 02:24:02 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: hash.h,v 1.1.2.1 2013/07/24 00:33:12 riastradh Exp $ */ +/* $NetBSD: hash.h,v 1.1.2.2 2013/07/24 02:24:02 riastradh Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -32,4 +32,15 @@ #ifndef _LINUX_HASH_H_ #define _LINUX_HASH_H_ +#include <machine/limits.h> + +static inline unsigned long +hash_long(unsigned long value, unsigned int bits) +{ + const unsigned long factor = (sizeof(factor) > 4? + 0x9e37fffffffc0001ull : 0x9e370001ul); + + return ((value * factor) >> ((CHAR_BIT * sizeof(value)) - bits)); +} + #endif /* _LINUX_HASH_H_ */