adding a test case
[IRC.git] / Robust / src / Runtime / DSTM / interface / llookup.h
1 #ifndef _LLOOKUP_H_
2 #define _LLOOKUP_H_
3
4 #include <stdlib.h>
5 #include <stdio.h>
6 #include <pthread.h>
7
8 #define SIMPLE_LLOOKUP
9
10 #define LOADFACTOR 0.5
11 #define HASH_SIZE 100
12
13 #define INLINE    inline __attribute__((always_inline))
14
15 typedef struct lhashlistnode {
16   unsigned int oid;
17   unsigned int mid;
18   struct lhashlistnode *next;
19 } lhashlistnode_t;
20
21 typedef struct lhashtable {
22   lhashlistnode_t *table;       // points to beginning of hash table
23   unsigned int size;
24   unsigned int numelements;
25   float loadfactor;
26   pthread_mutex_t locktable;
27 } lhashtable_t;
28
29 //returns 0 for success and 1 for failure
30 unsigned int lhashCreate(unsigned int size, float loadfactor);
31 //returns 0 for success and 1 for failure
32 unsigned int lhashInsert(unsigned int oid, unsigned int mid);
33 //returns mid, 0 if not found
34 unsigned int lhashSearch(unsigned int oid);
35 //returns 0 for success and 1 for failure
36 unsigned int lhashRemove(unsigned int oid);
37
38 //helper functions
39 unsigned int lhashResize(unsigned int newsize);
40 unsigned int lhashFunction(unsigned int oid);
41
42 #endif