mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-05 17:22:51 -06:00
initial import of the C runtime
This commit is contained in:
40
src/runtime/c/gu/hash.h
Normal file
40
src/runtime/c/gu/hash.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifndef GU_HASH_H_
|
||||
#define GU_HASH_H_
|
||||
|
||||
#include <gu/fun.h>
|
||||
|
||||
typedef GuWord GuHash;
|
||||
|
||||
static inline GuHash
|
||||
gu_hash_ptr(void* ptr)
|
||||
{
|
||||
return (GuHash) ptr;
|
||||
}
|
||||
|
||||
|
||||
static inline GuHash
|
||||
gu_hash_byte(GuHash h, uint8_t u)
|
||||
{
|
||||
// Paul Larson's simple byte hash
|
||||
return h * 101 + u;
|
||||
}
|
||||
|
||||
|
||||
GuHash
|
||||
gu_hash_bytes(GuHash h, const uint8_t* buf, size_t len);
|
||||
|
||||
typedef const struct GuHasher GuHasher;
|
||||
|
||||
struct GuHasher {
|
||||
GuEquality eq;
|
||||
GuHash (*hash)(GuHasher* self, const void* p);
|
||||
};
|
||||
|
||||
|
||||
extern GuHasher gu_int_hasher[1];
|
||||
|
||||
extern GuHasher gu_addr_hasher[1];
|
||||
|
||||
extern GuHasher gu_word_hasher[1];
|
||||
|
||||
#endif // GU_HASH_H_
|
||||
Reference in New Issue
Block a user