uint32_t mod64(uint64_t x, uint32_t y) {
#if 1
// TODO FIXME
- uint32_t d = (uint32_t)x;
- return d % y;
-#else
+ uint32_t a = (uint32_t)x;
+ uint32_t b = (x >> 32);
+
+ a %= y;
+ b %= y;
+
+ return (a + b) % y;
+#endif
+#if 0
uint32_t mod;
asm("div %3;" : "=d"(mod) : "a"((uint32_t)x), "d"((uint32_t)(x >> 32)), "r"(y) : "cc");
uint64_t compute_qstr_hash(qstr_t *q) {
q->hash = 0;
for (int i = 0; i < q->len; i++) {
- uint64_t x = (uint64_t)(q->name[i]);
+ uint64_t c = (uint64_t)(q->name[i]);
+ uint64_t x = q->hash;
q->hash = (x << 4) | (x >> (8 * sizeof(q->hash) - 4));
+ q->hash ^= c;
}
q->hash += q->hash >> (4 * sizeof(q->hash));
- q->hash &= 0x00000000FFFFFFFF;
-
return q->hash;
}