summaryrefslogtreecommitdiff
path: root/src/upstream/lookup3.h
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2020-11-25 17:57:35 -0800
committerVito Caputo <vcaputo@pengaru.com>2020-11-25 17:57:35 -0800
commit7b15a68d12e2df7f45c4311d0281ff9a78693e81 (patch)
tree79a9e097888e3458366e5dbf68895036007878d1 /src/upstream/lookup3.h
parent9ab253b33805bb7416e458992ffed73e9883a52b (diff)
upstream: import some hacked systemd headers
This brings journal-file data structures and byte swapping helpers I may as well just reuse. I've had to do some minor messing about to make things workable in isolation out of the systemd tree without pulling in too much. I've also added a new HashedObjectHeader type to encompass the slightly larger common header components of FieldObject and DataObject to facilitate a generic hash table iterator that can operate on just loading HashedObjectHeader when nothing more than the object size is needed for accounting. Basically the HashedObjectHeader is ObjectHeader+hash+next_hash_offset.
Diffstat (limited to 'src/upstream/lookup3.h')
-rw-r--r--src/upstream/lookup3.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/upstream/lookup3.h b/src/upstream/lookup3.h
new file mode 100644
index 0000000..ce8a468
--- /dev/null
+++ b/src/upstream/lookup3.h
@@ -0,0 +1,20 @@
+#pragma once
+
+#include <inttypes.h>
+#include <sys/types.h>
+
+uint32_t jenkins_hashword(const uint32_t *k, size_t length, uint32_t initval);
+void jenkins_hashword2(const uint32_t *k, size_t length, uint32_t *pc, uint32_t *pb);
+
+uint32_t jenkins_hashlittle(const void *key, size_t length, uint32_t initval);
+void jenkins_hashlittle2(const void *key, size_t length, uint32_t *pc, uint32_t *pb);
+
+uint32_t jenkins_hashbig(const void *key, size_t length, uint32_t initval);
+
+static inline uint64_t jenkins_hash64(const void *data, size_t length) {
+ uint32_t a = 0, b = 0;
+
+ jenkins_hashlittle2(data, length, &a, &b);
+
+ return ((uint64_t) a << 32ULL) | (uint64_t) b;
+}
© All Rights Reserved