Index: trunk/src/libs/xpcom18a4/nsprpub/pr/include/prthread.h
===================================================================
--- trunk/src/libs/xpcom18a4/nsprpub/pr/include/prthread.h	(revision 102200)
+++ trunk/src/libs/xpcom18a4/nsprpub/pr/include/prthread.h	(revision 102202)
@@ -80,20 +80,5 @@
 
 #ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
-#define PR_CreateThread VBoxNsprPR_CreateThread
-#define PR_JoinThread VBoxNsprPR_JoinThread
-#define PR_Sleep VBoxNsprPR_Sleep
 #define PR_GetCurrentThread VBoxNsprPR_GetCurrentThread
-#define PR_GetThreadState VBoxNsprPR_GetThreadState
-#define PR_SetThreadPrivate VBoxNsprPR_SetThreadPrivate
-#define PR_GetThreadPrivate VBoxNsprPR_GetThreadPrivate
-#define PR_NewThreadPrivateIndex VBoxNsprPR_NewThreadPrivateIndex
-#define PR_GetThreadPriority VBoxNsprPR_GetThreadPriority
-#define PR_SetThreadPriority VBoxNsprPR_SetThreadPriority
-#define PR_Interrupt VBoxNsprPR_Interrupt
-#define PR_ClearInterrupt VBoxNsprPR_ClearInterrupt
-#define PR_BlockInterrupt VBoxNsprPR_BlockInterrupt
-#define PR_UnblockInterrupt VBoxNsprPR_UnblockInterrupt
-#define PR_GetThreadScope VBoxNsprPR_GetThreadScope
-#define PR_GetThreadType VBoxNsprPR_GetThreadType
 #endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
 
@@ -130,158 +115,8 @@
 
 /*
-** Create a new thread:
-**     "type" is the type of thread to create
-**     "start(arg)" will be invoked as the threads "main"
-**     "priority" will be created thread's priority
-**     "scope" will specify whether the thread is local or global
-**     "state" will specify whether the thread is joinable or not
-**     "stackSize" the size of the stack, in bytes. The value can be zero
-**        and then a machine specific stack size will be chosen.
-**
-** This can return NULL if some kind of error occurs, such as if memory is
-** tight.
-**
-** If you want the thread to start up waiting for the creator to do
-** something, enter a lock before creating the thread and then have the
-** threads start routine enter and exit the same lock. When you are ready
-** for the thread to run, exit the lock.
-**
-** If you want to detect the completion of the created thread, the thread
-** should be created joinable.  Then, use PR_JoinThread to synchrnoize the
-** termination of another thread.
-**
-** When the start function returns the thread exits. If it is the last
-** PR_USER_THREAD to exit then the process exits.
-*/
-NSPR_API(PRThread*) PR_CreateThread(PRThreadType type,
-                     void (PR_CALLBACK *start)(void *arg),
-                     void *arg,
-                     PRThreadPriority priority,
-                     PRThreadScope scope,
-                     PRThreadState state,
-                     PRUint32 stackSize);
-
-/*
-** Wait for thread termination:
-**     "thread" is the target thread 
-**
-** This can return PR_FAILURE if no joinable thread could be found 
-** corresponding to the specified target thread.
-**
-** The calling thread is blocked until the target thread completes.
-** Several threads cannot wait for the same thread to complete; one thread
-** will operate successfully and others will terminate with an error PR_FAILURE.
-** The calling thread will not be blocked if the target thread has already
-** terminated.
-*/
-NSPR_API(PRStatus) PR_JoinThread(PRThread *thread);
-
-/*
 ** Return the current thread object for the currently running code.
 ** Never returns NULL.
 */
 NSPR_API(PRThread*) PR_GetCurrentThread(void);
-#ifndef NO_NSPR_10_SUPPORT
-#define PR_CurrentThread() PR_GetCurrentThread() /* for nspr1.0 compat. */
-#endif /* NO_NSPR_10_SUPPORT */
-
-/*
-** Get the priority of "thread".
-*/
-NSPR_API(PRThreadPriority) PR_GetThreadPriority(const PRThread *thread);
-
-/*
-** Change the priority of the "thread" to "priority".
-*/
-NSPR_API(void) PR_SetThreadPriority(PRThread *thread, PRThreadPriority priority);
-
-/*
-** This routine returns a new index for per-thread-private data table. 
-** The index is visible to all threads within a process. This index can 
-** be used with the PR_SetThreadPrivate() and PR_GetThreadPrivate() routines 
-** to save and retrieve data associated with the index for a thread.
-**
-** Each index is associationed with a destructor function ('dtor'). The function
-** may be specified as NULL when the index is created. If it is not NULL, the
-** function will be called when:
-**      - the thread exits and the private data for the associated index
-**        is not NULL,
-**      - new thread private data is set and the current private data is
-**        not NULL.
-**
-** The index independently maintains specific values for each binding thread. 
-** A thread can only get access to its own thread-specific-data.
-**
-** Upon a new index return the value associated with the index for all threads
-** is NULL, and upon thread creation the value associated with all indices for 
-** that thread is NULL. 
-**
-** Returns PR_FAILURE if the total number of indices will exceed the maximun 
-** allowed.
-*/
-typedef void (PR_CALLBACK *PRThreadPrivateDTOR)(void *priv);
-
-NSPR_API(PRStatus) PR_NewThreadPrivateIndex(
-    PRUintn *newIndex, PRThreadPrivateDTOR destructor);
-
-/*
-** Define some per-thread-private data.
-**     "tpdIndex" is an index into the per-thread private data table
-**     "priv" is the per-thread-private data 
-**
-** If the per-thread private data table has a previously registered
-** destructor function and a non-NULL per-thread-private data value,
-** the destructor function is invoked.
-**
-** This can return PR_FAILURE if the index is invalid.
-*/
-NSPR_API(PRStatus) PR_SetThreadPrivate(PRUintn tpdIndex, void *priv);
-
-/*
-** Recover the per-thread-private data for the current thread. "tpdIndex" is
-** the index into the per-thread private data table. 
-**
-** The returned value may be NULL which is indistinguishable from an error 
-** condition.
-**
-** A thread can only get access to its own thread-specific-data.
-*/
-NSPR_API(void*) PR_GetThreadPrivate(PRUintn tpdIndex);
-
-/*
-** This routine sets the interrupt request for a target thread. The interrupt
-** request remains in the thread's state until it is delivered exactly once
-** or explicitly canceled.
-**
-** A thread that has been interrupted will fail all NSPR blocking operations
-** that return a PRStatus (I/O, waiting on a condition, etc).
-**
-** PR_Interrupt may itself fail if the target thread is invalid.
-*/
-NSPR_API(PRStatus) PR_Interrupt(PRThread *thread);
-
-/*
-** Make the current thread sleep until "ticks" time amount of time
-** has expired. If "ticks" is PR_INTERVAL_NO_WAIT then the call is
-** equivalent to calling PR_Yield. Calling PR_Sleep with an argument
-** equivalent to PR_INTERVAL_NO_TIMEOUT is an error and will result
-** in a PR_FAILURE error return.
-*/
-NSPR_API(PRStatus) PR_Sleep(PRIntervalTime ticks);
-
-/*
-** Get the scoping of this thread.
-*/
-NSPR_API(PRThreadScope) PR_GetThreadScope(const PRThread *thread);
-
-/*
-** Get the type of this thread.
-*/
-NSPR_API(PRThreadType) PR_GetThreadType(const PRThread *thread);
-
-/*
-** Get the join state of this thread.
-*/
-NSPR_API(PRThreadState) PR_GetThreadState(const PRThread *thread);
 
 PR_END_EXTERN_C
Index: trunk/src/libs/xpcom18a4/nsprpub/pr/src/pthreads/ptsynch.c
===================================================================
--- trunk/src/libs/xpcom18a4/nsprpub/pr/src/pthreads/ptsynch.c	(revision 102200)
+++ trunk/src/libs/xpcom18a4/nsprpub/pr/src/pthreads/ptsynch.c	(revision 102202)
@@ -322,5 +322,5 @@
 {
     PRIntn rv;
-    PRThread *thred = PR_CurrentThread();
+    PRThread *thred = PR_GetCurrentThread();
 
     Assert(cvar != NULL);
Index: trunk/src/libs/xpcom18a4/nsprpub/pr/src/pthreads/ptthread.c
===================================================================
--- trunk/src/libs/xpcom18a4/nsprpub/pr/src/pthreads/ptthread.c	(revision 102200)
+++ trunk/src/libs/xpcom18a4/nsprpub/pr/src/pthreads/ptthread.c	(revision 102202)
@@ -80,102 +80,4 @@
 static void _pt_thread_death(void *arg);
 
-#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING)
-static PRIntn pt_PriorityMap(PRThreadPriority pri)
-{
-    return pt_book.minPrio +
-	    pri * (pt_book.maxPrio - pt_book.minPrio) / PR_PRIORITY_LAST;
-}
-#endif
-
-static void *_pt_root(void *arg)
-{
-    PRIntn rv;
-    PRThread *thred = (PRThread*)arg;
-    PRBool detached = (thred->state & PT_THREAD_DETACHED) ? PR_TRUE : PR_FALSE;
-
-    /*
-     * Both the parent thread and this new thread set thred->id.
-     * The new thread must ensure that thred->id is set before
-     * it executes its startFunc.  The parent thread must ensure
-     * that thred->id is set before PR_CreateThread() returns.
-     * Both threads set thred->id without holding a lock.  Since
-     * they are writing the same value, this unprotected double
-     * write should be safe.
-     */
-    thred->id = pthread_self();
-
-    /*
-     * Set within the current thread the pointer to our object.
-     * This object will be deleted when the thread termintates,
-     * whether in a join or detached (see _PR_InitThreads()).
-     */
-    rv = pthread_setspecific(pt_book.key, thred);
-    Assert(0 == rv);
-
-    /* make the thread visible to the rest of the runtime */
-    PR_Lock(pt_book.ml);
-
-    /* If this is a GCABLE thread, set its state appropriately */
-    if (thred->suspend & PT_THREAD_SETGCABLE)
-	    thred->state |= PT_THREAD_GCABLE;
-    thred->suspend = 0;
-
-    thred->prev = pt_book.last;
-    pt_book.last->next = thred;
-    thred->next = NULL;
-    pt_book.last = thred;
-    PR_Unlock(pt_book.ml);
-
-    thred->startFunc(thred->arg);  /* make visible to the client */
-
-    /* unhook the thread from the runtime */
-    PR_Lock(pt_book.ml);
-    /*
-     * At this moment, PR_CreateThread() may not have set thred->id yet.
-     * It is safe for a detached thread to free thred only after
-     * PR_CreateThread() has set thred->id.
-     */
-    if (detached)
-    {
-        while (!thred->okToDelete)
-            PR_WaitCondVar(pt_book.cv, PR_INTERVAL_NO_TIMEOUT);
-    }
-
-    if (thred->state & PT_THREAD_SYSTEM)
-        pt_book.system -= 1;
-    else if (--pt_book.user == pt_book.this_many)
-        PR_NotifyAllCondVar(pt_book.cv);
-    thred->prev->next = thred->next;
-    if (NULL == thred->next)
-        pt_book.last = thred->prev;
-    else
-        thred->next->prev = thred->prev;
-    PR_Unlock(pt_book.ml);
-
-    /*
-    * Here we set the pthread's backpointer to the PRThread to NULL.
-    * Otherwise the desctructor would get called eagerly as the thread
-    * returns to the pthread runtime. The joining thread would them be
-    * the proud possessor of a dangling reference. However, this is the
-    * last chance to delete the object if the thread is detached, so
-    * just let the destuctor do the work.
-    */
-    if (PR_FALSE == detached)
-    {
-        rv = pthread_setspecific(pt_book.key, NULL);
-        Assert(0 == rv);
-    }
-
-    return NULL;
-}  /* _pt_root */
-
-static DECLCALLBACK(int) _pt_iprt_root(
-    RTTHREAD Thread, void *pvUser)
-{
-    PRThread *thred = (PRThread *)pvUser;
-    _pt_root(thred);
-    return VINF_SUCCESS;
-}
-
 static PRThread* pt_AttachThread(void)
 {
@@ -218,181 +120,4 @@
 }  /* pt_AttachThread */
 
-static PRThread* _PR_CreateThread(
-    PRThreadType type, void (*start)(void *arg),
-    void *arg, PRThreadPriority priority, PRThreadScope scope,
-    PRThreadState state, PRUint32 stackSize, PRBool isGCAble)
-{
-    int rv;
-    PRThread *thred;
-    static uint32_t volatile s_iThread = 0;
-    RTTHREADTYPE enmType;
-    RTTHREAD hThread;
-    uint32_t fFlags = 0;
-
-    if (!_pr_initialized) _PR_ImplicitInitialization();
-
-    if ((PRIntn)PR_PRIORITY_FIRST > (PRIntn)priority)
-        priority = PR_PRIORITY_FIRST;
-    else if ((PRIntn)PR_PRIORITY_LAST < (PRIntn)priority)
-        priority = PR_PRIORITY_LAST;
-
-    /* calc priority */
-    switch (priority)
-    {
-        default:
-        case PR_PRIORITY_NORMAL:    enmType = RTTHREADTYPE_DEFAULT; break;
-        case PR_PRIORITY_LOW:       enmType = RTTHREADTYPE_MAIN_HEAVY_WORKER; break;
-        case PR_PRIORITY_HIGH:      enmType = RTTHREADTYPE_MAIN_WORKER; break;
-        case PR_PRIORITY_URGENT:    enmType = RTTHREADTYPE_IO; break;
-    }
-
-    if (state == PR_JOINABLE_THREAD)
-        fFlags |= RTTHREADFLAGS_WAITABLE;
-
-    thred = PR_NEWZAP(PRThread);
-    if (NULL == thred)
-    {
-        PR_SetError(PR_OUT_OF_MEMORY_ERROR, errno);
-        goto done;
-    }
-    else
-    {
-        pthread_t id;
-
-        thred->arg = arg;
-        thred->startFunc = start;
-        thred->priority = priority;
-        if (PR_UNJOINABLE_THREAD == state)
-            thred->state |= PT_THREAD_DETACHED;
-
-        if (PR_LOCAL_THREAD == scope)
-        	scope = PR_GLOBAL_THREAD;
-        if (PR_GLOBAL_THREAD == scope)
-            thred->state |= PT_THREAD_GLOBAL;
-        else if (PR_GLOBAL_BOUND_THREAD == scope)
-            thred->state |= (PT_THREAD_GLOBAL | PT_THREAD_BOUND);
-		else	/* force it global */
-            thred->state |= PT_THREAD_GLOBAL;
-        if (PR_SYSTEM_THREAD == type)
-            thred->state |= PT_THREAD_SYSTEM;
-
-        thred->suspend =(isGCAble) ? PT_THREAD_SETGCABLE : 0;
-
-#ifdef PT_NO_SIGTIMEDWAIT
-        pthread_mutex_init(&thred->suspendResumeMutex,NULL);
-        pthread_cond_init(&thred->suspendResumeCV,NULL);
-#endif
-
-        /* make the thread counted to the rest of the runtime */
-        PR_Lock(pt_book.ml);
-        if (PR_SYSTEM_THREAD == type)
-            pt_book.system += 1;
-        else pt_book.user += 1;
-        PR_Unlock(pt_book.ml);
-
-        /*
-         * We pass a pointer to a local copy (instead of thred->id)
-         * to pthread_create() because who knows what wacky things
-         * pthread_create() may be doing to its argument.
-         */
-		rv = RTThreadCreateF(&hThread, _pt_iprt_root, thred, stackSize, enmType, fFlags, "nspr-%u", ASMAtomicIncU32(&s_iThread));
-		if (RT_SUCCESS(rv)) {
-			RTMEM_WILL_LEAK(hThread);
-			id = (pthread_t)RTThreadGetNative(hThread);
-            rv = 0;
-        } 
-
-        if (0 != rv)
-        {
-            PRIntn oserr = rv;
-            PR_Lock(pt_book.ml);
-            if (thred->state & PT_THREAD_SYSTEM)
-                pt_book.system -= 1;
-            else if (--pt_book.user == pt_book.this_many)
-                PR_NotifyAllCondVar(pt_book.cv);
-            PR_Unlock(pt_book.ml);
-
-            PR_Free(thred);  /* all that work ... poof! */
-            PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, oserr);
-            thred = NULL;  /* and for what? */
-            goto done;
-        }
-
-        /*
-         * Both the parent thread and this new thread set thred->id.
-         * The parent thread must ensure that thred->id is set before
-         * PR_CreateThread() returns.  (See comments in _pt_root().)
-         */
-        thred->id = id;
-
-        /*
-         * If the new thread is detached, tell it that PR_CreateThread()
-         * has set thred->id so it's ok to delete thred.
-         */
-        if (PR_UNJOINABLE_THREAD == state)
-        {
-            PR_Lock(pt_book.ml);
-            thred->okToDelete = PR_TRUE;
-            PR_NotifyAllCondVar(pt_book.cv);
-            PR_Unlock(pt_book.ml);
-        }
-    }
-
-done:
-    return thred;
-}  /* _PR_CreateThread */
-
-PR_IMPLEMENT(PRThread*) PR_CreateThread(
-    PRThreadType type, void (*start)(void *arg), void *arg,
-    PRThreadPriority priority, PRThreadScope scope,
-    PRThreadState state, PRUint32 stackSize)
-{
-    return _PR_CreateThread(
-        type, start, arg, priority, scope, state, stackSize, PR_FALSE);
-} /* PR_CreateThread */
-
-PR_IMPLEMENT(PRStatus) PR_JoinThread(PRThread *thred)
-{
-    int rv = -1;
-    void *result = NULL;
-    Assert(thred != NULL);
-
-    if ((0xafafafaf == thred->state)
-    || (PT_THREAD_DETACHED == (PT_THREAD_DETACHED & thred->state))
-    || (PT_THREAD_FOREIGN == (PT_THREAD_FOREIGN & thred->state)))
-    {
-        /*
-         * This might be a bad address, but if it isn't, the state should
-         * either be an unjoinable thread or it's already had the object
-         * deleted. However, the client that called join on a detached
-         * thread deserves all the rath I can muster....
-         */
-        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
-        Log(("PR_JoinThread: 0x%X not joinable | already smashed\n", thred));
-    }
-    else
-    {
-        rv = VERR_INVALID_HANDLE;
-        RTTHREAD hThread = RTThreadFromNative((RTNATIVETHREAD)thred->id);
-        if (hThread != NIL_RTTHREAD)
-        {
-            int rcThread = 0;
-            rv = RTThreadWait(hThread, RT_INDEFINITE_WAIT, &rcThread);
-            Assert(RT_SUCCESS(rv) && rcThread == VINF_SUCCESS);
-            if (RT_SUCCESS(rv))
-            {
-                rv = 0;
-                _pt_thread_death(thred);
-            }
-            else
-                PR_SetError(rv == VERR_THREAD_NOT_WAITABLE 
-                            ? PR_INVALID_ARGUMENT_ERROR 
-                            : PR_UNKNOWN_ERROR, 
-                            rv);
-        }
-    }
-    return (0 == rv) ? PR_SUCCESS : PR_FAILURE;
-}  /* PR_JoinThread */
-
 PR_IMPLEMENT(PRThread*) PR_GetCurrentThread(void)
 {
@@ -406,103 +131,4 @@
     return (PRThread*)thred;
 }  /* PR_GetCurrentThread */
-
-PR_IMPLEMENT(PRThreadScope) PR_GetThreadScope(const PRThread *thred)
-{
-    return (thred->state & PT_THREAD_BOUND) ?
-        PR_GLOBAL_BOUND_THREAD : PR_GLOBAL_THREAD;
-}  /* PR_GetThreadScope() */
-
-PR_IMPLEMENT(PRThreadType) PR_GetThreadType(const PRThread *thred)
-{
-    return (thred->state & PT_THREAD_SYSTEM) ?
-        PR_SYSTEM_THREAD : PR_USER_THREAD;
-}
-
-PR_IMPLEMENT(PRThreadState) PR_GetThreadState(const PRThread *thred)
-{
-    return (thred->state & PT_THREAD_DETACHED) ?
-        PR_UNJOINABLE_THREAD : PR_JOINABLE_THREAD;
-}  /* PR_GetThreadState */
-
-PR_IMPLEMENT(PRThreadPriority) PR_GetThreadPriority(const PRThread *thred)
-{
-    Assert(thred != NULL);
-    return thred->priority;
-}  /* PR_GetThreadPriority */
-
-PR_IMPLEMENT(void) PR_SetThreadPriority(PRThread *thred, PRThreadPriority newPri)
-{
-    PRIntn rv = -1;
-
-    Assert(NULL != thred);
-
-    if ((PRIntn)PR_PRIORITY_FIRST > (PRIntn)newPri)
-        newPri = PR_PRIORITY_FIRST;
-    else if ((PRIntn)PR_PRIORITY_LAST < (PRIntn)newPri)
-        newPri = PR_PRIORITY_LAST;
-
-#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING)
-    if (EPERM != pt_schedpriv)
-    {
-        int policy;
-        struct sched_param schedule;
-
-        rv = pthread_getschedparam(thred->id, &policy, &schedule);
-        if(0 == rv) {
-			schedule.sched_priority = pt_PriorityMap(newPri);
-			rv = pthread_setschedparam(thred->id, policy, &schedule);
-			if (EPERM == rv)
-			{
-				pt_schedpriv = EPERM;
-				Log(("PR_SetThreadPriority: no thread scheduling privilege\n"));
-			}
-		}
-		if (rv != 0)
-			rv = -1;
-    }
-#endif
-
-    thred->priority = newPri;
-}  /* PR_SetThreadPriority */
-
-PR_IMPLEMENT(PRStatus) PR_Interrupt(PRThread *thred)
-{
-    /*
-    ** If the target thread indicates that it's waiting,
-    ** find the condition and broadcast to it. Broadcast
-    ** since we don't know which thread (if there are more
-    ** than one). This sounds risky, but clients must
-    ** test their invariants when resumed from a wait and
-    ** I don't expect very many threads to be waiting on
-    ** a single condition and I don't expect interrupt to
-    ** be used very often.
-    **
-    ** I don't know why I thought this would work. Must have
-    ** been one of those weaker momements after I'd been
-    ** smelling the vapors.
-    **
-    ** Even with the followng changes it is possible that
-    ** the pointer to the condition variable is pointing
-    ** at a bogus value. Will the unerlying code detect
-    ** that?
-    */
-    PRCondVar *cv;
-    Assert(NULL != thred);
-    if (NULL == thred) return PR_FAILURE;
-
-    thred->state |= PT_THREAD_ABORTED;
-
-    cv = thred->waiting;
-    if ((NULL != cv) && !thred->interrupt_blocked)
-    {
-        PRIntn rv;
-        ASMAtomicIncU32(&cv->notify_pending);
-        rv = pthread_cond_broadcast(&cv->cv);
-        Assert(0 == rv);
-        if (0 > ASMAtomicDecU32(&cv->notify_pending))
-            PR_DestroyCondVar(cv);
-    }
-    return PR_SUCCESS;
-}  /* PR_Interrupt */
 
 static void _pt_thread_death(void *arg)
@@ -607,10 +233,9 @@
     rv = pthread_setspecific(pt_book.key, thred);
     Assert(0 == rv);    
-    PR_SetThreadPriority(thred, priority);
 }  /* _PR_InitThreads */
 
 PR_IMPLEMENT(PRStatus) PR_Cleanup(void)
 {
-    PRThread *me = PR_CurrentThread();
+    PRThread *me = PR_GetCurrentThread();
     Log(("PR_Cleanup: shutting down NSPR\n"));
     Assert(me->state & PT_THREAD_PRIMORD);
