Index: mozilla/nsprpub/pr/src/threads/combined/pruthr.c |
=================================================================== |
--- mozilla/nsprpub/pr/src/threads/combined/pruthr.c (revision 179237) |
+++ mozilla/nsprpub/pr/src/threads/combined/pruthr.c (working copy) |
@@ -237,6 +237,7 @@ |
PR_ASSERT(thread->dumpArg == 0 && thread->dump == 0); |
PR_ASSERT(thread->errorString == 0 && thread->errorStringSize == 0); |
PR_ASSERT(thread->errorStringLength == 0); |
+ PR_ASSERT(thread->name == 0); |
/* Reset data members in thread structure */ |
thread->errorCode = thread->osErrorCode = 0; |
@@ -1581,7 +1582,38 @@ |
} else _PR_SetThreadPriority(thread, newPri); |
} |
+PR_IMPLEMENT(PRStatus) PR_SetCurrentThreadName(const char *name) |
+{ |
+ PRThread *thread; |
+ size_t nameLen; |
+ if (!name) { |
+ PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0); |
+ return PR_FAILURE; |
+ } |
+ |
+ thread = PR_GetCurrentThread(); |
+ if (!thread) |
+ return PR_FAILURE; |
+ |
+ PR_Free(thread->name); |
+ nameLen = strlen(name); |
+ thread->name = (char *)PR_Malloc(nameLen + 1); |
+ if (!thread->name) |
+ return PR_FAILURE; |
+ memcpy(thread->name, name, nameLen + 1); |
+ _PR_MD_SET_CURRENT_THREAD_NAME(thread->name); |
+ return PR_SUCCESS; |
+} |
+ |
+PR_IMPLEMENT(const char *) PR_GetThreadName(const PRThread *thread) |
+{ |
+ if (!thread) |
+ return NULL; |
+ return thread->name; |
+} |
+ |
+ |
/* |
** This routine prevents all other threads from running. This call is needed by |
** the garbage collector. |