summaryrefslogtreecommitdiff
path: root/qstd
diff options
context:
space:
mode:
Diffstat (limited to 'qstd')
-rw-r--r--qstd/Makefile5
-rw-r--r--qstd/str.c11
-rw-r--r--qstd/str.h9
3 files changed, 24 insertions, 1 deletions
diff --git a/qstd/Makefile b/qstd/Makefile
index fa952dc..3c4b6a8 100644
--- a/qstd/Makefile
+++ b/qstd/Makefile
@@ -5,7 +5,7 @@ defines = -Dplat_x86 -Dplat_posix -Dallocation_default_alignment=8
cflags = -std=c90 -pedantic -Wall -Wextra $(DEBUG_COMPILE_FLAG) $(includes) $(defines)
lflags = $(DEBUG_LINK_FLAG)
-objects = plat.o memory.o
+objects = plat.o memory.o str.o
.PHONY: all clean
@@ -17,6 +17,9 @@ memory.o: memory.c memory.h plat.h
plat.o: plat.c plat.h
$(CC) -c $(cflags) plat.c -o plat.o
+str.o: str.c str.h
+ $(CC) -c $(cflags) str.c -o str.o
+
$(target): $(objects)
$(AR) -rcs $(target) $(objects)
diff --git a/qstd/str.c b/qstd/str.c
new file mode 100644
index 0000000..a1c1aa1
--- /dev/null
+++ b/qstd/str.c
@@ -0,0 +1,11 @@
+#include "str.h"
+
+uint64_t fnv1a64(uint8_t* buf, size_t size) {
+ size_t i;
+ uint64_t hash = 0xcbf29ce484222325;
+ for (i = 0; i < size; i++, buf++) {
+ hash ^= *buf;
+ hash *= 0x100000001b3;
+ }
+ return hash;
+}
diff --git a/qstd/str.h b/qstd/str.h
new file mode 100644
index 0000000..f55333e
--- /dev/null
+++ b/qstd/str.h
@@ -0,0 +1,9 @@
+#ifndef str_h
+#define str_h
+
+#include <stddef.h>
+#include <stdint.h>
+
+uint64_t fnv1a64(uint8_t* buf, size_t size);
+
+#endif