Repos / kernel.git / commitdiff
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6108385)
raw | patch | inline | side by side (parent: 6108385)
| author | zhaoyanbai <zhaoyanbai@126.com> | |
| Fri, 6 Sep 2024 11:57:43 +0000 (19:57 +0800) | ||
| committer | zhaoyanbai <zhaoyanbai@126.com> | |
| Fri, 6 Sep 2024 11:57:43 +0000 (19:57 +0800) |
| fs/dentry.c | patch | blob | history | |
| fs/path.c | patch | blob | history |
diff --git a/fs/dentry.c b/fs/dentry.c
--- a/fs/dentry.c
+++ b/fs/dentry.c
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");
diff --git a/fs/path.c b/fs/path.c
--- a/fs/path.c
+++ b/fs/path.c
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;
}