X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FThreadLabels.c;h=72cd5d3c4b073e04748618f20b7a9b9f36a7dc24;hb=45c35148be308b3290f1c14240d406f1cb1af166;hp=9b9f1723ffdc0f6a8055279843e8eab6aaeeb4d1;hpb=0065d5ab628975892cea1ec7303f968c3338cbe1;p=ghc-hetmet.git diff --git a/rts/ThreadLabels.c b/rts/ThreadLabels.c index 9b9f172..72cd5d3 100644 --- a/rts/ThreadLabels.c +++ b/rts/ThreadLabels.c @@ -8,8 +8,10 @@ * ---------------------------------------------------------------------------*/ #include "PosixSource.h" +#include "Rts.h" #include "ThreadLabels.h" #include "RtsUtils.h" +#include "Hash.h" #include @@ -47,4 +49,19 @@ removeThreadLabel(StgWord key) stgFree(old); } } + +void +labelThread(StgPtr tso, char *label) +{ + int len; + void *buf; + + /* Caveat: Once set, you can only set the thread name to "" */ + len = strlen(label)+1; + buf = stgMallocBytes(len * sizeof(char), "Schedule.c:labelThread()"); + strncpy(buf,label,len); + /* Update will free the old memory for us */ + updateThreadLabel(((StgTSO *)tso)->id,buf); +} + #endif /* DEBUG */