From 7b15a68d12e2df7f45c4311d0281ff9a78693e81 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Wed, 25 Nov 2020 17:57:35 -0800 Subject: 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. --- src/upstream/lookup3.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/upstream/lookup3.h (limited to 'src/upstream/lookup3.h') 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 +#include + +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; +} -- cgit v1.2.3