diff options
Diffstat (limited to 'rts/ThreadLabels.c')
-rw-r--r-- | rts/ThreadLabels.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/rts/ThreadLabels.c b/rts/ThreadLabels.c new file mode 100644 index 0000000000..9b9f1723ff --- /dev/null +++ b/rts/ThreadLabels.c @@ -0,0 +1,50 @@ +/* ----------------------------------------------------------------------------- + * ThreadLabels.c + * + * (c) The GHC Team 2002-2003 + * + * Table of thread labels. + * + * ---------------------------------------------------------------------------*/ + +#include "PosixSource.h" +#include "ThreadLabels.h" +#include "RtsUtils.h" + +#include <stdlib.h> + +#if defined(DEBUG) +/* to the end */ +static HashTable * threadLabels = NULL; + +void +initThreadLabelTable(void) +{ + if (threadLabels == NULL) { + threadLabels = allocHashTable(); + } +} + +void +updateThreadLabel(StgWord key, void *data) +{ + removeThreadLabel(key); + insertHashTable(threadLabels,key,data); +} + +void * +lookupThreadLabel(StgWord key) +{ + return lookupHashTable(threadLabels,key); +} + +void +removeThreadLabel(StgWord key) +{ + void * old = NULL; + if ((old = lookupHashTable(threadLabels,key))) { + removeHashTable(threadLabels,key,old); + stgFree(old); + } +} +#endif /* DEBUG */ |