X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=TBBT%2Ftrace_play%2Fhash.h;fp=TBBT%2Ftrace_play%2Fhash.h;h=808a95f3438ae28187ef9984b049df22aa485935;hb=adc8816a09e5b6be2e58f4a7c28d2418a74cce9c;hp=0000000000000000000000000000000000000000;hpb=145b4756946bbd443452ec1b2081984795de70d0;p=bluesky.git diff --git a/TBBT/trace_play/hash.h b/TBBT/trace_play/hash.h new file mode 100644 index 0000000..808a95f --- /dev/null +++ b/TBBT/trace_play/hash.h @@ -0,0 +1,87 @@ +#ifndef RFS_HASH_H +#define RFS_HASH_H + +/* + * hash.h: + * header file for routines to manipulate hash_tble lookup, + * insert and delete. + * + * $Id: hash.h,v 1.1 2002/03/11 20:25:52 ningning Exp $ + * + * Changes: + * $Log: hash.h,v $ + * Revision 1.1 2002/03/11 20:25:52 ningning + * hash function for file handle map completely implemented. + * + */ + +#include +#include +#include +#include +#include +#include "../common/rfs_defines.h" +#include "rfsu_defines.h" + +typedef struct rfsfh rfskey_t; + +struct hash_ent_struct { +#ifdef HASH_DOUBLE_SAFE + struct timeval time; +#endif + rfskey_t key; + int entry; + struct hash_ent_struct * next; +}; + +typedef struct hash_ent_struct hash_ent_t; + +typedef struct { + int size; + int used_entry; /* number of hash table entrie which contains valid data */ + int valid_num; /* number of valid data including those on the chain */ + int (*hash_func) (rfskey_t * key, int size); + /* it's not C++ class, so we have to get size from outside */ + hash_ent_t * buf; +} hash_tbl_t; + +inline int hash_func1 (rfskey_t * key, int size); +inline int blk_hash_func (blkkey_t * key, int size); +int hash_tbl_init (hash_tbl_t * hash_tbl); +int hash_tbl_insert (hash_tbl_t * hash_tbl, rfskey_t * key, int entry, int mode); +int hash_tbl_delete (hash_tbl_t * hash_tbl, rfskey_t * key); +int hash_tbl_lookup (hash_tbl_t * hash_tbl, rfskey_t * key); + +#ifdef ULFS + +struct blk_hash_ent_struct { +#ifdef HASH_DOUBLE_SAFE + struct timeval time; +#endif + blkkey_t key; + int entry; + struct blk_hash_ent_struct * next; +}; + +typedef struct blk_hash_ent_struct blk_hash_ent_t; + +typedef struct { + int size; + int keysize; + int entsize; + int quiet_flag; + int used_entry; /* number of hash table entrie which contains valid data */ + int valid_num; /* number of valid data including those on the chain */ + int (*hash_func) (blkkey_t * key, int size); + /* it's not C++ class, so we have to get size from outside */ + blk_hash_ent_t * buf; +} blk_hash_tbl_t; + +int blk_hash_tbl_init (blk_hash_tbl_t * hash_tbl); +int blk_hash_tbl_insert (blk_hash_tbl_t * hash_tbl, blkkey_t * key, int entry, int mode); +//int blk_hash_tbl_delete (blk_hash_tbl_t * hash_tbl, blkkey_t * key); +int blk_hash_tbl_lookup (blk_hash_tbl_t * hash_tbl, blkkey_t * key); + +#endif + +#endif