rts: Add getPhysicalMemorySize
[ghc.git] / rts / Hash.h
1 /*-----------------------------------------------------------------------------
2 *
3 * (c) The GHC Team, 1999
4 *
5 * Prototypes for Hash.c
6 *
7 * -------------------------------------------------------------------------- */
8
9 #ifndef HASH_H
10 #define HASH_H
11
12 #include "BeginPrivate.h"
13
14 typedef struct hashtable HashTable; /* abstract */
15
16 /* Hash table access where the keys are StgWords */
17 HashTable * allocHashTable ( void );
18 void * lookupHashTable ( HashTable *table, StgWord key );
19 void insertHashTable ( HashTable *table, StgWord key, void *data );
20 void * removeHashTable ( HashTable *table, StgWord key, void *data );
21
22 int keyCountHashTable (HashTable *table);
23
24 /* Hash table access where the keys are C strings (the strings are
25 * assumed to be allocated by the caller, and mustn't be deallocated
26 * until the corresponding hash table entry has been removed).
27 */
28 HashTable * allocStrHashTable ( void );
29
30 #define lookupStrHashTable(table, key) \
31 (lookupHashTable(table, (StgWord)key))
32
33 #define insertStrHashTable(table, key, data) \
34 (insertHashTable(table, (StgWord)key, data))
35
36 #define removeStrHashTable(table, key, data) \
37 (removeHashTable(table, (StgWord)key, data))
38
39 /* Hash tables for arbitrary keys */
40 typedef int HashFunction(HashTable *table, StgWord key);
41 typedef int CompareFunction(StgWord key1, StgWord key2);
42 HashTable * allocHashTable_(HashFunction *hash, CompareFunction *compare);
43 int hashWord(HashTable *table, StgWord key);
44 int hashStr(HashTable *table, char *key);
45
46 /* Freeing hash tables
47 */
48 void freeHashTable ( HashTable *table, void (*freeDataFun)(void *) );
49
50 void exitHashTable ( void );
51
52 #include "EndPrivate.h"
53
54 #endif /* HASH_H */