#pragma prototyped
#ifndef _HASHLIB_H
#define _HASHLIB_H
#include <ast.h>
#define hash_info _hash_info_
typedef void* (*Hash_alloc_f)(size_t);
typedef int (*Hash_compare_f)(const char*, const char*, ...);
typedef unsigned int (*Hash_hash_f)(const char*, ...);
typedef void (*Hash_free_f)(void*);
typedef void* (*Hash_region_f)(void*, void*, size_t, int);
typedef struct
{
Hash_hash_f hash;
Hash_compare_f compare;
Hash_alloc_f alloc;
Hash_free_f free;
Hash_region_f region;
void* handle;
} Hash_local_t;
#define _HASH_POSITION_PRIVATE_ \
Hash_table_t* tab; \
int flags; \
Hash_bucket_t** slot; \
Hash_bucket_t** limit;
#define _HASH_LAST_PRIVATE_ \
const char* name; \
unsigned int hash;
#define _HASH_ROOT_PRIVATE_ \
int namesize; \
int meanchain; \
Hash_local_t* local; \
Hash_root_t* next; \
Hash_table_t* references;
#define _HASH_TABLE_PRIVATE_ \
unsigned char frozen; \
unsigned char bucketsize; \
Hash_bucket_t** table; \
Hash_table_t* next;
#include <hash.h>
#define HASHMINSIZE (1<<4)
#define HASHMEANCHAIN 2
#define HASHMOD(t,h) (h &= (t->size - 1))
#define HASHVAL(x) ((x)&~HASH_FLAGS)
#define HASH(r,n,h) if (r->local->hash) h = r->namesize ? (*r->local->hash)(n, r->namesize) : (*r->local->hash)(n);\
else\
{\
register const char* _hash_s1 = n;\
h = 0;\
if (r->namesize)\
{\
register const char* _hash_s2 = _hash_s1 + r->namesize;\
while (_hash_s1 < _hash_s2) HASHPART(h, *_hash_s1++);\
}\
else while (*_hash_s1) HASHPART(h, *_hash_s1++);\
}
typedef struct
{
Hash_root_t* list;
} Hash_info_t;
extern Hash_info_t hash_info;
#endif