#endif
io_channel b_io;
int b_size;
- unsigned long long b_blocknr;
- int b_dirty;
- int b_uptodate;
int b_err;
+ unsigned int b_dirty:1;
+ unsigned int b_uptodate:1;
+ unsigned long long b_blocknr;
char b_data[1024];
};
free(cache);
}
+/* generic hashing taken from the Linux kernel */
+#define GOLDEN_RATIO_32 0x61C88647
+#define GOLDEN_RATIO_64 0x61C8864680B583EBull
+
+_INLINE_ __u32 __hash_32(__u32 val)
+{
+ return val * GOLDEN_RATIO_32;
+}
+
+_INLINE_ __u32 hash_32(__u32 val, unsigned int bits)
+{
+ /* High bits are more random, so use them. */
+ return __hash_32(val) >> (32 - bits);
+}
+
+_INLINE_ __u32 hash_64(__u64 val, unsigned int bits)
+{
+ if (sizeof(long) >= 8) {
+ /* 64x64-bit multiply is efficient on all 64-bit processors */
+ return val * GOLDEN_RATIO_64 >> (64 - bits);
+ } else {
+ /* Hash 64 bits using only 32x32-bit multiply. */
+ return hash_32((__u32)val ^ __hash_32(val >> 32), bits);
+ }
+}
+
#undef _INLINE_
#endif