5 * Copyright (C) 2002 by Theodore Ts'o
7 * This file is released under the GPL v2.
9 * This file may be redistributed under the terms of the GNU Public
13 #define DELTA 0x9E3779B9
15 static void TEA_transform(__u32 buf[2], __u32 const in[])
18 __u32 b0 = buf[0], b1 = buf[1];
19 __u32 a = in[0], b = in[1], c = in[2], d = in[3];
24 b0 += ((b1 << 4)+a) ^ (b1+sum) ^ ((b1 >> 5)+b);
25 b1 += ((b0 << 4)+c) ^ (b0+sum) ^ ((b0 >> 5)+d);
32 static void str2hashbuf(const char *msg, int len, __u32 *buf, int num)
37 pad = (__u32)len | ((__u32)len << 8);
43 for (i=0; i < len; i++) {
46 val = msg[i] + (val << 8);
59 int btrfs_name_hash(const char *name, int len, u64 *hash_result)
66 /* Initialize the default seed for the hash checksum functions */
74 str2hashbuf(p, len, in, 4);
75 TEA_transform(buf, in);
81 *hash_result = buf[0];
83 *hash_result |= buf[1];