From 499e349afa57536ce80497aa99f61c5492e3733e Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Sat, 29 Jan 2011 03:15:44 +0100 Subject: More filesystem stuff working. devfs is now in place with stdin, stdout, and stderr. --- os/src/hash-djb2.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 os/src/hash-djb2.c (limited to 'os/src/hash-djb2.c') 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 +#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; +} -- cgit v1.2.3