/* Implement a simple hash on a character string. Rotate the hash value by 7 bits, then XOR each character in. This is implemented with some source-level loop unrolling.  */
xfs_dahash_t xfs_da_hashname(const __uint8_t *name, int namelen)
/* Implement a simple hash on a character string. Rotate the hash value by 7 bits, then XOR each character in. This is implemented with some source-level loop unrolling.  */
xfs_dahash_t xfs_da_hashname(const __uint8_t *name, int namelen)
{
	xfs_dahash_t hash;
	for (hash = 0; namelen >= 4; namelen -= 4, name += 4)
		hash = (name[0] << 21) ^ (name[1] << 14) ^ (name[2] << 7) ^
		       (name[3] << 0) ^ rol32(hash, 7 * 4);
	switch (namelen) {
	case 3:
		return (name[0] << 14) ^ (name[1] << 7) ^ (name[2] << 0) ^
		       rol32(hash, 7 * 3);
	case 2:
		return (name[0] << 7) ^ (name[1] << 0) ^ rol32(hash, 7 * 2);
	case 1:
		return (name[0] << 0) ^ rol32(hash, 7 * 1);
	default:
		return hash;
	}
}