summaryrefslogtreecommitdiff
path: root/os/src/hash-djb2.c
diff options
context:
space:
mode:
authorNicolas "Pixel" Noble <pixel@nobis-crew.org>2011-01-29 03:15:44 +0100
committerNicolas "Pixel" Noble <pixel@nobis-crew.org>2011-01-29 03:15:44 +0100
commit499e349afa57536ce80497aa99f61c5492e3733e (patch)
treefe3308c344659e800172cfaad9793918f24ae4b1 /os/src/hash-djb2.c
parent5754656f65205ff1fd9b23c2a85778b3671caf68 (diff)
More filesystem stuff working. devfs is now in place with stdin, stdout, and stderr.
Diffstat (limited to 'os/src/hash-djb2.c')
-rw-r--r--os/src/hash-djb2.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/os/src/hash-djb2.c b/os/src/hash-djb2.c
new file mode 100644
index 0000000..82dd741
--- /dev/null
+++ b/os/src/hash-djb2.c
@@ -0,0 +1,15 @@
+#include <stdint.h>
+#include "hash-djb2.h"
+#include "osdebug.h"
+
+uint32_t hash_djb2(const uint8_t * str, ssize_t _max) {
+ uint32_t hash = 5381;
+ uint32_t max = (uint32_t) _max;
+ int c;
+
+ while (((c = *str++)) && max--) {
+ hash = ((hash << 5) + hash) ^ c;
+ }
+
+ return hash;
+}