Index: trunk/src/libs/xpcom18a4/Makefile.kmk
===================================================================
--- trunk/src/libs/xpcom18a4/Makefile.kmk	(revision 101804)
+++ trunk/src/libs/xpcom18a4/Makefile.kmk	(revision 101805)
@@ -523,5 +523,4 @@
 	nsprpub/pr/src/linking/prlink.c \
 	nsprpub/pr/src/md/prosdep.c \
-	nsprpub/pr/src/memory/prseg.c \
 	nsprpub/pr/src/memory/prshm.c \
 	nsprpub/pr/src/memory/prshma.c \
Index: trunk/src/libs/xpcom18a4/nsprpub/pr/include/private/primpl.h
===================================================================
--- trunk/src/libs/xpcom18a4/nsprpub/pr/include/private/primpl.h	(revision 101804)
+++ trunk/src/libs/xpcom18a4/nsprpub/pr/include/private/primpl.h	(revision 101805)
@@ -47,23 +47,5 @@
  */
 
-#if defined(_PR_PTHREADS)
 #include <pthread.h>
-#endif
-
-#if defined(_PR_BTHREADS)
-#include <kernel/OS.h>
-#endif
-
-#ifdef WINNT
-/* Need to force service-pack 3 extensions to be defined by
-** setting _WIN32_WINNT to NT 4.0 for winsock.h, winbase.h, winnt.h.
-*/
-#ifndef  _WIN32_WINNT
-    #define _WIN32_WINNT 0x0400
-#elif   (_WIN32_WINNT < 0x0400)
-    #undef  _WIN32_WINNT
-    #define _WIN32_WINNT 0x0400
-#endif /* _WIN32_WINNT */
-#endif /* WINNT */
 
 #include "nspr.h"
@@ -159,6 +141,4 @@
 typedef struct _MDFileMap _MDFileMap;
 
-#if defined(_PR_PTHREADS)
-
 /*
 ** The following definitions are unique to implementing NSPR using pthreads.
@@ -225,1076 +205,4 @@
 
 NSPR_API(void) PT_FPrintStats(PRFileDesc *fd, const char *msg);
-
-#else /* defined(_PR_PTHREADS) */
-
-NSPR_API(void) PT_FPrintStats(PRFileDesc *fd, const char *msg);
-
-/*
-** This section is contains those parts needed to implement NSPR on
-** platforms in general. One would assume that the pthreads implementation
-** included lots of the same types, at least conceptually.
-*/
-
-/*
- * Local threads only.  No multiple CPU support and hence all the
- * following routines are no-op.
- */
-#ifdef _PR_LOCAL_THREADS_ONLY
-
-#define        _PR_MD_SUSPEND_THREAD(thread)
-#define        _PR_MD_RESUME_THREAD(thread)
-#define        _PR_MD_SUSPEND_CPU(cpu)
-#define        _PR_MD_RESUME_CPU(cpu)
-#define        _PR_MD_BEGIN_SUSPEND_ALL()
-#define        _PR_MD_END_SUSPEND_ALL()
-#define        _PR_MD_BEGIN_RESUME_ALL()
-#define        _PR_MD_END_RESUME_ALL()
-#define _PR_MD_INIT_ATTACHED_THREAD(thread) PR_FAILURE
-
-#endif
-
-typedef struct _PRCPUQueue _PRCPUQueue;
-typedef struct _PRCPU _PRCPU;
-typedef struct _MDCPU _MDCPU;
-
-struct _PRCPUQueue {
-    _MDLock  runQLock;          /* lock for the run + wait queues */
-    _MDLock  sleepQLock;        /* lock for the run + wait queues */
-    _MDLock  miscQLock;         /* lock for the run + wait queues */
-
-    PRCList runQ[PR_PRIORITY_LAST + 1]; /* run queue for this CPU */
-    PRUint32  runQReadyMask;
-    PRCList sleepQ;
-    PRIntervalTime sleepQmax;
-    PRCList pauseQ;
-    PRCList suspendQ;
-    PRCList waitingToJoinQ;
-
-    PRUintn   numCPUs;          /* number of CPUs using this Q */
-};
-
-struct _PRCPU {
-    PRCList links;              /* link list of CPUs */
-    PRUint32 id;                /* id for this CPU */
-
-    union {
-        PRInt32 bits;
-        PRUint8 missed[4];
-    } u;
-    PRIntn where;               /* index into u.missed */
-    PRPackedBool paused;        /* cpu is paused */
-    PRPackedBool exit;          /* cpu should exit */
-
-    PRThread *thread;           /* native thread for this CPUThread */
-    PRThread *idle_thread;      /* user-level idle thread for this CPUThread */
-
-    PRIntervalTime last_clock;  /* the last time we went into
-                                 * _PR_ClockInterrupt() on this CPU
-                                 */
-
-    _PRCPUQueue *queue;
-
-    _MDCPU md;
-};
-
-typedef struct _PRInterruptTable {
-    const char *name;
-    PRUintn missed_bit;
-    void (*handler)(void);
-} _PRInterruptTable;
-
-#define _PR_CPU_PTR(_qp) \
-    ((_PRCPU*) ((char*) (_qp) - offsetof(_PRCPU,links)))
-
-#if !defined(IRIX) && !defined(WIN32) && !defined(XP_OS2) \
-        && !(defined(SOLARIS) && defined(_PR_GLOBAL_THREADS_ONLY))
-#define _MD_GET_ATTACHED_THREAD()        (_PR_MD_CURRENT_THREAD())
-#endif
-
-#ifdef _PR_LOCAL_THREADS_ONLY
-
-NSPR_API(struct _PRCPU *)              _pr_currentCPU;
-NSPR_API(PRThread *)                   _pr_currentThread;
-NSPR_API(PRThread *)                   _pr_lastThread;
-NSPR_API(PRInt32)                      _pr_intsOff;
-
-#define _MD_CURRENT_CPU()               (_pr_currentCPU)
-#define _MD_SET_CURRENT_CPU(_cpu)       (_pr_currentCPU = (_cpu))
-#define _MD_CURRENT_THREAD()            (_pr_currentThread)
-#define _MD_SET_CURRENT_THREAD(_thread) (_pr_currentThread = (_thread))
-#define _MD_LAST_THREAD()               (_pr_lastThread)
-#define _MD_SET_LAST_THREAD(t)          (_pr_lastThread = t)
-
-#ifndef XP_MAC
-#define _MD_GET_INTSOFF()               (_pr_intsOff)
-#define _MD_SET_INTSOFF(_val)           (_pr_intsOff = _val)
-#endif
-
-
-/* The unbalanced curly braces in these two macros are intentional */
-#define _PR_LOCK_HEAP() { PRIntn _is; if (_pr_currentCPU) _PR_INTSOFF(_is);
-#define _PR_UNLOCK_HEAP() if (_pr_currentCPU) _PR_INTSON(_is); }
-
-#endif /* _PR_LOCAL_THREADS_ONLY */
-
-extern PRInt32                  _native_threads_only;
-
-#if defined(_PR_GLOBAL_THREADS_ONLY)
-
-#define _MD_GET_INTSOFF() 0
-#define _MD_SET_INTSOFF(_val)
-#define _PR_INTSOFF(_is)
-#define _PR_FAST_INTSON(_is)
-#define _PR_INTSON(_is)
-#define _PR_THREAD_LOCK(_thread)
-#define _PR_THREAD_UNLOCK(_thread)
-#define _PR_RUNQ_LOCK(cpu)
-#define _PR_RUNQ_UNLOCK(cpu)
-#define _PR_SLEEPQ_LOCK(thread)
-#define _PR_SLEEPQ_UNLOCK(thread)
-#define _PR_MISCQ_LOCK(thread)
-#define _PR_MISCQ_UNLOCK(thread)
-#define _PR_CPU_LIST_LOCK()
-#define _PR_CPU_LIST_UNLOCK()
-
-#define _PR_ADD_RUNQ(_thread, _cpu, _pri)
-#define _PR_DEL_RUNQ(_thread)
-#define _PR_ADD_SLEEPQ(_thread, _timeout)
-#define _PR_DEL_SLEEPQ(_thread, _propogate)
-#define _PR_ADD_JOINQ(_thread, _cpu)
-#define _PR_DEL_JOINQ(_thread)
-#define _PR_ADD_SUSPENDQ(_thread, _cpu)
-#define _PR_DEL_SUSPENDQ(_thread)
-
-#define _PR_THREAD_SWITCH_CPU(_thread, _newCPU)
-
-#define _PR_IS_NATIVE_THREAD(thread) 1
-#define _PR_IS_NATIVE_THREAD_SUPPORTED() 1
-
-#else
-
-#ifdef XP_MAC
-
-#define _PR_INTSOFF(_is)        _MD_INTSOFF(_is)
-
-#else /* XP_MAC */
-
-#define _PR_INTSOFF(_is) \
-    PR_BEGIN_MACRO \
-        (_is) = _PR_MD_GET_INTSOFF(); \
-        _PR_MD_SET_INTSOFF(1); \
-    PR_END_MACRO
-
-#endif /* XP_MAC */
-
-#define _PR_FAST_INTSON(_is) \
-    PR_BEGIN_MACRO \
-        _PR_MD_SET_INTSOFF(_is); \
-    PR_END_MACRO
-
-#define _PR_INTSON(_is) \
-    PR_BEGIN_MACRO \
-        if ((_is == 0) && (_PR_MD_CURRENT_CPU())->u.bits) \
-                _PR_IntsOn((_PR_MD_CURRENT_CPU())); \
-        _PR_MD_SET_INTSOFF(_is); \
-    PR_END_MACRO
-
-#ifdef _PR_LOCAL_THREADS_ONLY
-
-#define _PR_IS_NATIVE_THREAD(thread) 0
-#define _PR_THREAD_LOCK(_thread)
-#define _PR_THREAD_UNLOCK(_thread)
-#define _PR_RUNQ_LOCK(cpu)
-#define _PR_RUNQ_UNLOCK(cpu)
-#define _PR_SLEEPQ_LOCK(thread)
-#define _PR_SLEEPQ_UNLOCK(thread)
-#define _PR_MISCQ_LOCK(thread)
-#define _PR_MISCQ_UNLOCK(thread)
-#define _PR_CPU_LIST_LOCK()
-#define _PR_CPU_LIST_UNLOCK()
-
-#define _PR_ADD_RUNQ(_thread, _cpu, _pri) \
-    PR_BEGIN_MACRO \
-    PR_APPEND_LINK(&(_thread)->links, &_PR_RUNQ(_cpu)[_pri]); \
-    _PR_RUNQREADYMASK(_cpu) |= (1L << _pri); \
-    PR_END_MACRO
-
-#define _PR_DEL_RUNQ(_thread) \
-    PR_BEGIN_MACRO \
-    _PRCPU *_cpu = _thread->cpu; \
-    PRInt32 _pri = _thread->priority; \
-    PR_REMOVE_LINK(&(_thread)->links); \
-    if (PR_CLIST_IS_EMPTY(&_PR_RUNQ(_cpu)[_pri])) \
-        _PR_RUNQREADYMASK(_cpu) &= ~(1L << _pri); \
-    PR_END_MACRO
-
-#define _PR_ADD_SLEEPQ(_thread, _timeout) \
-    _PR_AddSleepQ(_thread, _timeout);
-
-#define _PR_DEL_SLEEPQ(_thread, _propogate) \
-    _PR_DelSleepQ(_thread, _propogate);
-
-#define _PR_ADD_JOINQ(_thread, _cpu) \
-    PR_APPEND_LINK(&(_thread)->links, &_PR_WAITINGTOJOINQ(_cpu));
-
-#define _PR_DEL_JOINQ(_thread) \
-    PR_REMOVE_LINK(&(_thread)->links);
-
-#define _PR_ADD_SUSPENDQ(_thread, _cpu) \
-    PR_APPEND_LINK(&(_thread)->links, &_PR_SUSPENDQ(_cpu));
-
-#define _PR_DEL_SUSPENDQ(_thread) \
-    PR_REMOVE_LINK(&(_thread)->links);
-
-#define _PR_THREAD_SWITCH_CPU(_thread, _newCPU)
-
-#define _PR_IS_NATIVE_THREAD_SUPPORTED() 0
-
-#else        /* _PR_LOCAL_THREADS_ONLY */
-
-/* These are for the "combined" thread model */
-
-#define _PR_THREAD_LOCK(_thread) \
-    _PR_MD_LOCK(&(_thread)->threadLock);
-
-#define _PR_THREAD_UNLOCK(_thread) \
-    _PR_MD_UNLOCK(&(_thread)->threadLock);
-
-#define _PR_RUNQ_LOCK(_cpu) \
-    PR_BEGIN_MACRO \
-    _PR_MD_LOCK(&(_cpu)->queue->runQLock );\
-    PR_END_MACRO
-
-#define _PR_RUNQ_UNLOCK(_cpu) \
-    PR_BEGIN_MACRO \
-    _PR_MD_UNLOCK(&(_cpu)->queue->runQLock );\
-    PR_END_MACRO
-
-#define _PR_SLEEPQ_LOCK(_cpu) \
-    _PR_MD_LOCK(&(_cpu)->queue->sleepQLock );
-
-#define _PR_SLEEPQ_UNLOCK(_cpu) \
-    _PR_MD_UNLOCK(&(_cpu)->queue->sleepQLock );
-
-#define _PR_MISCQ_LOCK(_cpu) \
-    _PR_MD_LOCK(&(_cpu)->queue->miscQLock );
-
-#define _PR_MISCQ_UNLOCK(_cpu) \
-    _PR_MD_UNLOCK(&(_cpu)->queue->miscQLock );
-
-#define _PR_CPU_LIST_LOCK()                 _PR_MD_LOCK(&_pr_cpuLock)
-#define _PR_CPU_LIST_UNLOCK()               _PR_MD_UNLOCK(&_pr_cpuLock)
-
-#define QUEUE_RUN           0x1
-#define QUEUE_SLEEP         0x2
-#define QUEUE_JOIN          0x4
-#define QUEUE_SUSPEND       0x8
-#define QUEUE_LOCK          0x10
-
-#define _PR_ADD_RUNQ(_thread, _cpu, _pri) \
-    PR_BEGIN_MACRO \
-    PR_APPEND_LINK(&(_thread)->links, &_PR_RUNQ(_cpu)[_pri]); \
-    _PR_RUNQREADYMASK(_cpu) |= (1L << _pri); \
-    PR_ASSERT((_thread)->queueCount == 0); \
-    (_thread)->queueCount = QUEUE_RUN; \
-    PR_END_MACRO
-
-#define _PR_DEL_RUNQ(_thread) \
-    PR_BEGIN_MACRO \
-    _PRCPU *_cpu = _thread->cpu; \
-    PRInt32 _pri = _thread->priority; \
-    PR_REMOVE_LINK(&(_thread)->links); \
-    if (PR_CLIST_IS_EMPTY(&_PR_RUNQ(_cpu)[_pri])) \
-        _PR_RUNQREADYMASK(_cpu) &= ~(1L << _pri); \
-    PR_ASSERT((_thread)->queueCount == QUEUE_RUN);\
-    (_thread)->queueCount = 0; \
-    PR_END_MACRO
-
-#define _PR_ADD_SLEEPQ(_thread, _timeout) \
-    PR_ASSERT((_thread)->queueCount == 0); \
-    (_thread)->queueCount = QUEUE_SLEEP; \
-    _PR_AddSleepQ(_thread, _timeout);
-
-#define _PR_DEL_SLEEPQ(_thread, _propogate) \
-    PR_ASSERT((_thread)->queueCount == QUEUE_SLEEP);\
-    (_thread)->queueCount = 0; \
-    _PR_DelSleepQ(_thread, _propogate);
-
-#define _PR_ADD_JOINQ(_thread, _cpu) \
-    PR_ASSERT((_thread)->queueCount == 0); \
-    (_thread)->queueCount = QUEUE_JOIN; \
-    PR_APPEND_LINK(&(_thread)->links, &_PR_WAITINGTOJOINQ(_cpu));
-
-#define _PR_DEL_JOINQ(_thread) \
-    PR_ASSERT((_thread)->queueCount == QUEUE_JOIN);\
-    (_thread)->queueCount = 0; \
-    PR_REMOVE_LINK(&(_thread)->links);
-
-#define _PR_ADD_SUSPENDQ(_thread, _cpu) \
-    PR_ASSERT((_thread)->queueCount == 0); \
-    (_thread)->queueCount = QUEUE_SUSPEND; \
-    PR_APPEND_LINK(&(_thread)->links, &_PR_SUSPENDQ(_cpu));
-
-#define _PR_DEL_SUSPENDQ(_thread) \
-    PR_ASSERT((_thread)->queueCount == QUEUE_SUSPEND);\
-    (_thread)->queueCount = 0; \
-    PR_REMOVE_LINK(&(_thread)->links);
-
-#define _PR_THREAD_SWITCH_CPU(_thread, _newCPU) \
-    (_thread)->cpu = (_newCPU);
-
-#define _PR_IS_NATIVE_THREAD(thread) (thread->flags & _PR_GLOBAL_SCOPE)
-#define _PR_IS_NATIVE_THREAD_SUPPORTED() 1
-
-#endif /* _PR_LOCAL_THREADS_ONLY */
-
-#endif /* _PR_GLOBAL_THREADS_ONLY */
-
-#define _PR_SET_RESCHED_FLAG() _PR_MD_CURRENT_CPU()->u.missed[3] = 1
-#define _PR_CLEAR_RESCHED_FLAG() _PR_MD_CURRENT_CPU()->u.missed[3] = 0
-
-extern _PRInterruptTable _pr_interruptTable[];
-
-/* Bits for _pr_interruptState.u.missed[0,1] */
-#define _PR_MISSED_CLOCK    0x1
-#define _PR_MISSED_IO        0x2
-#define _PR_MISSED_CHILD    0x4
-
-extern void _PR_IntsOn(_PRCPU *cpu);
-
-NSPR_API(void) _PR_WakeupCPU(void);
-NSPR_API(void) _PR_PauseCPU(void);
-
-/************************************************************************/
-
-#define _PR_LOCK_LOCK(_lock) \
-    _PR_MD_LOCK(&(_lock)->ilock);
-#define _PR_LOCK_UNLOCK(_lock) \
-    _PR_MD_UNLOCK(&(_lock)->ilock);
-
-extern void _PR_UnblockLockWaiter(PRLock *lock);
-
-#define _PR_LOCK_PTR(_qp) \
-    ((PRLock*) ((char*) (_qp) - offsetof(PRLock,links)))
-
-/************************************************************************/
-
-#define _PR_CVAR_LOCK(_cvar) \
-    _PR_MD_LOCK(&(_cvar)->ilock);
-#define _PR_CVAR_UNLOCK(_cvar) \
-    _PR_MD_UNLOCK(&(_cvar)->ilock);
-
-extern PRStatus _PR_WaitCondVar(
-    PRThread *thread, PRCondVar *cvar, PRLock *lock, PRIntervalTime timeout);
-extern PRUint32 _PR_CondVarToString(PRCondVar *cvar, char *buf, PRUint32 buflen);
-
-NSPR_API(void) _PR_Notify(PRMonitor *mon, PRBool all, PRBool sticky);
-
-/* PRThread.flags */
-#define _PR_SYSTEM          0x01
-#define _PR_INTERRUPT       0x02
-#define _PR_ATTACHED        0x04        /* created via PR_AttachThread */
-#define _PR_PRIMORDIAL      0x08        /* the thread that called PR_Init */
-#define _PR_ON_SLEEPQ       0x10        /* thread is on the sleepQ */
-#define _PR_ON_PAUSEQ       0x20        /* thread is on the pauseQ */
-#define _PR_SUSPENDING      0x40        /* thread wants to suspend */
-#define _PR_GLOBAL_SCOPE    0x80        /* thread is global scope */
-#define _PR_IDLE_THREAD     0x200       /* this is an idle thread        */
-#define _PR_GCABLE_THREAD   0x400       /* this is a collectable thread */
-#define _PR_BOUND_THREAD    0x800       /* a bound thread */
-#define _PR_INTERRUPT_BLOCKED	0x1000	/* interrupts blocked */
-
-/* PRThread.state */
-#define _PR_UNBORN       0
-#define _PR_RUNNABLE     1
-#define _PR_RUNNING      2
-#define _PR_LOCK_WAIT    3
-#define _PR_COND_WAIT    4
-#define _PR_JOIN_WAIT    5
-#define _PR_IO_WAIT      6
-#define _PR_SUSPENDED    7
-#define _PR_DEAD_STATE   8  /* for debugging */
-
-/* PRThreadStack.flags */
-#define _PR_STACK_VM            0x1    /* using vm instead of malloc */
-#define _PR_STACK_MAPPED        0x2    /* vm is mapped */
-#define _PR_STACK_PRIMORDIAL    0x4    /* stack for primordial thread */
-
-/*
-** If the default stcksize from the client is zero, we need to pick a machine
-** dependent value.  This is only for standard user threads.  For custom threads,
-** 0 has a special meaning.
-** Adjust stackSize. Round up to a page boundary.
-*/
-
-#ifndef _MD_MINIMUM_STACK_SIZE
-#define _MD_MINIMUM_STACK_SIZE	0
-#endif
-
-#if (!defined(HAVE_CUSTOM_USER_THREADS))
-#define        _PR_ADJUST_STACKSIZE(stackSize) \
-        PR_BEGIN_MACRO \
-    if (stackSize == 0) \
-                stackSize = _MD_DEFAULT_STACK_SIZE; \
-    if (stackSize < _MD_MINIMUM_STACK_SIZE) \
-                stackSize = _MD_MINIMUM_STACK_SIZE; \
-    stackSize = (stackSize + (1 << _pr_pageShift) - 1) >> _pr_pageShift; \
-    stackSize <<= _pr_pageShift; \
-        PR_END_MACRO
-#else
-#define        _PR_ADJUST_STACKSIZE(stackSize)
-#endif
-
-#define _PR_IS_GCABLE_THREAD(thr) ((thr)->flags & _PR_GCABLE_THREAD)
-
-#define _PR_PENDING_INTERRUPT(thr)					\
-		(!((thr)->flags & _PR_INTERRUPT_BLOCKED) && ((thr)->flags & _PR_INTERRUPT))
-#define _PR_THREAD_BLOCK_INTERRUPT(thr)			\
-		(thr->flags |= _PR_INTERRUPT_BLOCKED)
-#define _PR_THREAD_UNBLOCK_INTERRUPT(thr)			\
-		(thr->flags &= ~_PR_INTERRUPT_BLOCKED)
-
-#define _PR_THREAD_PTR(_qp) \
-    ((PRThread*) ((char*) (_qp) - offsetof(PRThread,links)))
-
-#define _PR_ACTIVE_THREAD_PTR(_qp) \
-    ((PRThread*) ((char*) (_qp) - offsetof(PRThread,active)))
-
-#define _PR_THREAD_CONDQ_PTR(_qp) \
-    ((PRThread*) ((char*) (_qp) - offsetof(PRThread,waitQLinks)))
-
-#define _PR_THREAD_MD_TO_PTR(_md) \
-    ((PRThread*) ((char*) (_md) - offsetof(PRThread,md)))
-
-#define _PR_THREAD_STACK_TO_PTR(_stack) \
-    ((PRThread*) (_stack->thr))
-
-extern PRCList _pr_active_local_threadQ;
-extern PRCList _pr_active_global_threadQ;
-extern PRCList _pr_cpuQ;
-extern _MDLock  _pr_cpuLock;
-extern PRInt32 _pr_md_idle_cpus;
-
-#define _PR_ACTIVE_LOCAL_THREADQ()          _pr_active_local_threadQ
-#define _PR_ACTIVE_GLOBAL_THREADQ()         _pr_active_global_threadQ
-#define _PR_CPUQ()                          _pr_cpuQ
-#define _PR_RUNQ(_cpu)                      ((_cpu)->queue->runQ)
-#define _PR_RUNQREADYMASK(_cpu)             ((_cpu)->queue->runQReadyMask)
-#define _PR_SLEEPQ(_cpu)                    ((_cpu)->queue->sleepQ)
-#define _PR_SLEEPQMAX(_cpu)                 ((_cpu)->queue->sleepQmax)
-#define _PR_PAUSEQ(_cpu)                    ((_cpu)->queue->pauseQ)
-#define _PR_SUSPENDQ(_cpu)                  ((_cpu)->queue->suspendQ)
-#define _PR_WAITINGTOJOINQ(_cpu)            ((_cpu)->queue->waitingToJoinQ)
-
-extern PRUint32 _pr_recycleThreads;   /* Flag for behavior on thread cleanup */
-extern PRLock *_pr_deadQLock;
-extern PRUint32 _pr_numNativeDead;
-extern PRUint32 _pr_numUserDead;
-extern PRCList _pr_deadNativeQ;
-extern PRCList _pr_deadUserQ;
-#define _PR_DEADNATIVEQ     _pr_deadNativeQ
-#define _PR_DEADUSERQ       _pr_deadUserQ
-#define _PR_DEADQ_LOCK      PR_Lock(_pr_deadQLock);
-#define _PR_DEADQ_UNLOCK    PR_Unlock(_pr_deadQLock);
-#define _PR_INC_DEADNATIVE  (_pr_numNativeDead++)
-#define _PR_DEC_DEADNATIVE  (_pr_numNativeDead--)
-#define _PR_NUM_DEADNATIVE  (_pr_numNativeDead)
-#define _PR_INC_DEADUSER    (_pr_numUserDead++)
-#define _PR_DEC_DEADUSER    (_pr_numUserDead--)
-#define _PR_NUM_DEADUSER    (_pr_numUserDead)
-
-extern PRUint32 _pr_utid;
-
-extern struct _PRCPU  *_pr_primordialCPU;
-
-extern PRLock *_pr_activeLock;          /* lock for userActive and systemActive */
-extern PRInt32 _pr_userActive;          /* number of active user threads */
-extern PRInt32 _pr_systemActive;        /* number of active system threads */
-extern PRInt32 _pr_primordialExitCount; /* number of user threads left
-                                         * before the primordial thread
-                                         * can exit.  */
-extern PRCondVar *_pr_primordialExitCVar; /* the condition variable for
-                                           * notifying the primordial thread
-                                           * when all other user threads
-                                           * have terminated.  */
-
-extern PRUintn _pr_maxPTDs;
-
-extern PRLock *_pr_terminationCVLock;
-
-/*************************************************************************
-* Internal routines either called by PR itself or from machine-dependent *
-* code.                                                                  *
-*************************************************************************/
-
-extern void _PR_ClockInterrupt(void);
-
-extern void _PR_Schedule(void);
-extern void _PR_SetThreadPriority(
-    PRThread* thread, PRThreadPriority priority);
-
-/***********************************************************************
-** FUNCTION:	_PR_NewSegment()
-** DESCRIPTION:
-**   Allocate a memory segment. The "size" value is rounded up to the
-**   native system page size and a page aligned portion of memory is
-**   returned.  This memory is not part of the malloc heap. If "vaddr" is
-**   not NULL then PR tries to allocate the segment at the desired virtual
-**   address.
-** INPUTS:	size:  size of the desired memory segment
-**          vaddr:  address at which the newly aquired segment is to be
-**                  mapped into memory.
-** OUTPUTS:	a memory segment is allocated, a PRSegment is allocated
-** RETURN:	pointer to PRSegment
-***********************************************************************/
-extern PRSegment* _PR_NewSegment(PRUint32 size, void *vaddr);
-
-/***********************************************************************
-** FUNCTION:	_PR_DestroySegment()
-** DESCRIPTION:
-**   The memory segment and the PRSegment are freed
-** INPUTS:	seg:  pointer to PRSegment to be freed
-** OUTPUTS:	the the PRSegment and its associated memory segment are freed
-** RETURN:	void
-***********************************************************************/
-extern void _PR_DestroySegment(PRSegment *seg);
-
-extern PRThreadStack * _PR_NewStack(PRUint32 stackSize);
-extern void _PR_FreeStack(PRThreadStack *stack);
-extern PRBool _PR_NotifyThread (PRThread *thread, PRThread *me);
-extern void _PR_NotifyLockedThread (PRThread *thread);
-
-NSPR_API(void) _PR_AddSleepQ(PRThread *thread, PRIntervalTime timeout);
-NSPR_API(void) _PR_DelSleepQ(PRThread *thread, PRBool propogate_time);
-
-extern void _PR_AddThreadToRunQ(PRThread *me, PRThread *thread);
-
-NSPR_API(PRThread*) _PR_CreateThread(PRThreadType type,
-                                     void (*start)(void *arg),
-                                     void *arg,
-                                     PRThreadPriority priority,
-                                     PRThreadScope scope,
-                                     PRThreadState state,
-                                     PRUint32 stackSize,
-                     PRUint32 flags);
-
-extern void _PR_NativeDestroyThread(PRThread *thread);
-extern void _PR_UserDestroyThread(PRThread *thread);
-
-extern PRThread* _PRI_AttachThread(
-    PRThreadType type, PRThreadPriority priority,
-    PRThreadStack *stack, PRUint32 flags);
-
-extern void _PRI_DetachThread(void);
-
-
-#define _PR_IO_PENDING(_thread) ((_thread)->io_pending)
-
-NSPR_API(void) _PR_MD_INIT_CPUS();
-#define    _PR_MD_INIT_CPUS _MD_INIT_CPUS
-
-NSPR_API(void) _PR_MD_WAKEUP_CPUS();
-#define    _PR_MD_WAKEUP_CPUS _MD_WAKEUP_CPUS
-
-/* Interrupts related */
-
-NSPR_API(void) _PR_MD_START_INTERRUPTS(void);
-#define    _PR_MD_START_INTERRUPTS _MD_START_INTERRUPTS
-
-NSPR_API(void) _PR_MD_STOP_INTERRUPTS(void);
-#define    _PR_MD_STOP_INTERRUPTS _MD_STOP_INTERRUPTS
-
-NSPR_API(void) _PR_MD_ENABLE_CLOCK_INTERRUPTS(void);
-#define    _PR_MD_ENABLE_CLOCK_INTERRUPTS _MD_ENABLE_CLOCK_INTERRUPTS
-
-NSPR_API(void) _PR_MD_DISABLE_CLOCK_INTERRUPTS(void);
-#define    _PR_MD_DISABLE_CLOCK_INTERRUPTS _MD_DISABLE_CLOCK_INTERRUPTS
-
-NSPR_API(void) _PR_MD_BLOCK_CLOCK_INTERRUPTS(void);
-#define    _PR_MD_BLOCK_CLOCK_INTERRUPTS _MD_BLOCK_CLOCK_INTERRUPTS
-
-NSPR_API(void) _PR_MD_UNBLOCK_CLOCK_INTERRUPTS(void);
-#define    _PR_MD_UNBLOCK_CLOCK_INTERRUPTS _MD_UNBLOCK_CLOCK_INTERRUPTS
-
-/* The _PR_MD_WAIT_LOCK and _PR_MD_WAKEUP_WAITER functions put to sleep and
- * awaken a thread which is waiting on a lock or cvar.
- */
-extern PRStatus _PR_MD_WAIT(PRThread *, PRIntervalTime timeout);
-#define    _PR_MD_WAIT _MD_WAIT
-
-extern PRStatus _PR_MD_WAKEUP_WAITER(PRThread *);
-#define    _PR_MD_WAKEUP_WAITER _MD_WAKEUP_WAITER
-
-#ifndef _PR_LOCAL_THREADS_ONLY /* not if only local threads supported */
-NSPR_API(void) _PR_MD_CLOCK_INTERRUPT(void);
-#define    _PR_MD_CLOCK_INTERRUPT _MD_CLOCK_INTERRUPT
-#endif
-
-/* Stack debugging */
-NSPR_API(void) _PR_MD_INIT_STACK(PRThreadStack *ts, PRIntn redzone);
-#define    _PR_MD_INIT_STACK _MD_INIT_STACK
-
-NSPR_API(void) _PR_MD_CLEAR_STACK(PRThreadStack* ts);
-#define    _PR_MD_CLEAR_STACK _MD_CLEAR_STACK
-
-/* CPU related */
-NSPR_API(PRInt32) _PR_MD_GET_INTSOFF(void);
-#define    _PR_MD_GET_INTSOFF _MD_GET_INTSOFF
-
-NSPR_API(void) _PR_MD_SET_INTSOFF(PRInt32 _val);
-#define    _PR_MD_SET_INTSOFF _MD_SET_INTSOFF
-
-NSPR_API(_PRCPU*) _PR_MD_CURRENT_CPU(void);
-#define    _PR_MD_CURRENT_CPU _MD_CURRENT_CPU
-
-NSPR_API(void) _PR_MD_SET_CURRENT_CPU(_PRCPU *cpu);
-#define    _PR_MD_SET_CURRENT_CPU _MD_SET_CURRENT_CPU
-
-NSPR_API(void) _PR_MD_INIT_RUNNING_CPU(_PRCPU *cpu);
-#define    _PR_MD_INIT_RUNNING_CPU _MD_INIT_RUNNING_CPU
-
-/*
- * Returns the number of threads awoken or 0 if a timeout occurred;
- */
-extern PRInt32 _PR_MD_PAUSE_CPU(PRIntervalTime timeout);
-#define    _PR_MD_PAUSE_CPU _MD_PAUSE_CPU
-
-extern void _PR_MD_CLEANUP_BEFORE_EXIT(void);
-#define _PR_MD_CLEANUP_BEFORE_EXIT _MD_CLEANUP_BEFORE_EXIT
-
-extern void _PR_MD_EXIT(PRIntn status);
-#define    _PR_MD_EXIT _MD_EXIT
-
-/* Locks related */
-
-NSPR_API(void) _PR_MD_INIT_LOCKS(void);
-#define    _PR_MD_INIT_LOCKS _MD_INIT_LOCKS
-
-NSPR_API(PRStatus) _PR_MD_NEW_LOCK(_MDLock *md);
-#define    _PR_MD_NEW_LOCK _MD_NEW_LOCK
-
-NSPR_API(void) _PR_MD_FREE_LOCK(_MDLock *md);
-#define    _PR_MD_FREE_LOCK _MD_FREE_LOCK
-
-NSPR_API(void) _PR_MD_LOCK(_MDLock *md);
-#define    _PR_MD_LOCK _MD_LOCK
-
-/* Return 0 on success, a nonzero value on failure. */
-NSPR_API(PRIntn) _PR_MD_TEST_AND_LOCK(_MDLock *md);
-#define    _PR_MD_TEST_AND_LOCK _MD_TEST_AND_LOCK
-
-NSPR_API(void) _PR_MD_UNLOCK(_MDLock *md);
-#define    _PR_MD_UNLOCK _MD_UNLOCK
-
-NSPR_API(void) _PR_MD_IOQ_LOCK(void);
-#define    _PR_MD_IOQ_LOCK _MD_IOQ_LOCK
-
-NSPR_API(void) _PR_MD_IOQ_UNLOCK(void);
-#define    _PR_MD_IOQ_UNLOCK _MD_IOQ_UNLOCK
-
-#ifndef _PR_LOCAL_THREADS_ONLY /* not if only local threads supported */
-/* Semaphore related -- only for native threads */
-#ifdef HAVE_CVAR_BUILT_ON_SEM
-NSPR_API(void) _PR_MD_NEW_SEM(_MDSemaphore *md, PRUintn value);
-#define _PR_MD_NEW_SEM _MD_NEW_SEM
-
-NSPR_API(void) _PR_MD_DESTROY_SEM(_MDSemaphore *md);
-#define _PR_MD_DESTROY_SEM _MD_DESTROY_SEM
-
-NSPR_API(PRStatus) _PR_MD_TIMED_WAIT_SEM(
-    _MDSemaphore *md, PRIntervalTime timeout);
-#define _PR_MD_TIMED_WAIT_SEM _MD_TIMED_WAIT_SEM
-
-NSPR_API(PRStatus) _PR_MD_WAIT_SEM(_MDSemaphore *md);
-#define _PR_MD_WAIT_SEM _MD_WAIT_SEM
-
-NSPR_API(void) _PR_MD_POST_SEM(_MDSemaphore *md);
-#define _PR_MD_POST_SEM _MD_POST_SEM
-#endif /* HAVE_CVAR_BUILT_ON_SEM */
-
-#endif
-
-/* Condition Variables related -- only for native threads */
-
-#ifndef _PR_LOCAL_THREADS_ONLY /* not if only local threads supported */
-NSPR_API(PRInt32) _PR_MD_NEW_CV(_MDCVar *md);
-#define    _PR_MD_NEW_CV _MD_NEW_CV
-
-NSPR_API(void) _PR_MD_FREE_CV(_MDCVar *md);
-#define    _PR_MD_FREE_CV _MD_FREE_CV
-
-NSPR_API(void) _PR_MD_WAIT_CV(
-    _MDCVar *mdCVar,_MDLock *mdLock,PRIntervalTime timeout);
-#define    _PR_MD_WAIT_CV _MD_WAIT_CV
-
-NSPR_API(void) _PR_MD_NOTIFY_CV(_MDCVar *md, _MDLock *lock);
-#define    _PR_MD_NOTIFY_CV _MD_NOTIFY_CV
-
-NSPR_API(void) _PR_MD_NOTIFYALL_CV(_MDCVar *md, _MDLock *lock);
-#define    _PR_MD_NOTIFYALL_CV _MD_NOTIFYALL_CV
-#endif /* _PR_LOCAL_THREADS_ONLY */
-
-/* Threads related */
-NSPR_API(PRThread*) _PR_MD_CURRENT_THREAD(void);
-#define    _PR_MD_CURRENT_THREAD _MD_CURRENT_THREAD
-
-NSPR_API(PRThread*) _PR_MD_GET_ATTACHED_THREAD(void);
-#define    _PR_MD_GET_ATTACHED_THREAD _MD_GET_ATTACHED_THREAD
-
-NSPR_API(PRThread*) _PR_MD_LAST_THREAD(void);
-#define    _PR_MD_LAST_THREAD _MD_LAST_THREAD
-
-NSPR_API(void) _PR_MD_SET_CURRENT_THREAD(PRThread *thread);
-#define    _PR_MD_SET_CURRENT_THREAD _MD_SET_CURRENT_THREAD
-
-NSPR_API(void) _PR_MD_SET_LAST_THREAD(PRThread *thread);
-#define    _PR_MD_SET_LAST_THREAD _MD_SET_LAST_THREAD
-
-extern PRStatus _PR_MD_INIT_THREAD(PRThread *thread);
-#define    _PR_MD_INIT_THREAD _MD_INIT_THREAD
-
-extern void _PR_MD_EXIT_THREAD(PRThread *thread);
-#define    _PR_MD_EXIT_THREAD _MD_EXIT_THREAD
-
-#ifndef _PR_LOCAL_THREADS_ONLY /* not if only local threads supported */
-
-NSPR_API(PRStatus) _PR_MD_INIT_ATTACHED_THREAD(PRThread *thread);
-#define    _PR_MD_INIT_ATTACHED_THREAD _MD_INIT_ATTACHED_THREAD
-
-extern void _PR_MD_SUSPEND_THREAD(PRThread *thread);
-#define    _PR_MD_SUSPEND_THREAD _MD_SUSPEND_THREAD
-
-extern void _PR_MD_RESUME_THREAD(PRThread *thread);
-#define    _PR_MD_RESUME_THREAD _MD_RESUME_THREAD
-
-extern void _PR_MD_SUSPEND_CPU(_PRCPU  *cpu);
-#define    _PR_MD_SUSPEND_CPU _MD_SUSPEND_CPU
-
-extern void _PR_MD_RESUME_CPU(_PRCPU  *cpu);
-#define    _PR_MD_RESUME_CPU _MD_RESUME_CPU
-
-extern void _PR_MD_BEGIN_SUSPEND_ALL(void);
-#define    _PR_MD_BEGIN_SUSPEND_ALL _MD_BEGIN_SUSPEND_ALL
-
-extern void _PR_MD_END_SUSPEND_ALL(void);
-#define    _PR_MD_END_SUSPEND_ALL _MD_END_SUSPEND_ALL
-
-extern void _PR_MD_BEGIN_RESUME_ALL(void);
-#define    _PR_MD_BEGIN_RESUME_ALL _MD_BEGIN_RESUME_ALL
-
-extern void _PR_MD_END_RESUME_ALL(void);
-#define    _PR_MD_END_RESUME_ALL _MD_END_RESUME_ALL
-
-#if defined(IRIX)
-NSPR_API(void) _PR_IRIX_CHILD_PROCESS(void);
-#endif        /* IRIX */
-
-#endif        /* !_PR_LOCAL_THREADS_ONLY */
-
-extern void _PR_MD_CLEAN_THREAD(PRThread *thread);
-#define    _PR_MD_CLEAN_THREAD _MD_CLEAN_THREAD
-
-#ifdef HAVE_CUSTOM_USER_THREADS
-extern void _PR_MD_CREATE_PRIMORDIAL_USER_THREAD(PRThread *);
-#define    _PR_MD_CREATE_PRIMORDIAL_USER_THREAD _MD_CREATE_PRIMORDIAL_USER_THREAD
-
-extern PRThread* _PR_MD_CREATE_USER_THREAD(
-                        PRUint32 stacksize,
-                        void (*start)(void *),
-                        void *arg);
-#define    _PR_MD_CREATE_USER_THREAD _MD_CREATE_USER_THREAD
-#endif
-
-extern PRStatus _PR_MD_CREATE_THREAD(
-                        PRThread *thread,
-                        void (*start) (void *),
-                        PRThreadPriority priority,
-                        PRThreadScope scope,
-                        PRThreadState state,
-                        PRUint32 stackSize);
-#define    _PR_MD_CREATE_THREAD _MD_CREATE_THREAD
-
-extern void _PR_MD_JOIN_THREAD(_MDThread *md);
-#define    _PR_MD_JOIN_THREAD _MD_JOIN_THREAD
-
-extern void _PR_MD_END_THREAD(void);
-#define    _PR_MD_END_THREAD _MD_END_THREAD
-
-extern void _PR_MD_YIELD(void);
-#define    _PR_MD_YIELD _MD_YIELD
-
-extern void _PR_MD_SET_PRIORITY(_MDThread *md, PRThreadPriority newPri);
-#define    _PR_MD_SET_PRIORITY _MD_SET_PRIORITY
-
-NSPR_API(void) _PR_MD_SUSPENDALL(void);
-#define    _PR_MD_SUSPENDALL _MD_SUSPENDALL
-
-NSPR_API(void) _PR_MD_RESUMEALL(void);
-#define    _PR_MD_RESUMEALL _MD_RESUMEALL
-
-extern void _PR_MD_INIT_CONTEXT(
-    PRThread *thread, char *top, void (*start) (void), PRBool *status);
-#define    _PR_MD_INIT_CONTEXT _MD_INIT_CONTEXT
-
-extern void _PR_MD_SWITCH_CONTEXT(PRThread *thread);
-#define    _PR_MD_SWITCH_CONTEXT _MD_SWITCH_CONTEXT
-
-extern void _PR_MD_RESTORE_CONTEXT(PRThread *thread);
-#define    _PR_MD_RESTORE_CONTEXT _MD_RESTORE_CONTEXT
-
-/* Segment related */
-extern void _PR_MD_INIT_SEGS(void);
-#define    _PR_MD_INIT_SEGS _MD_INIT_SEGS
-
-extern PRStatus _PR_MD_ALLOC_SEGMENT(PRSegment *seg, PRUint32 size, void *vaddr);
-#define    _PR_MD_ALLOC_SEGMENT _MD_ALLOC_SEGMENT
-
-extern void _PR_MD_FREE_SEGMENT(PRSegment *seg);
-#define    _PR_MD_FREE_SEGMENT _MD_FREE_SEGMENT
-
-/* Directory enumeration related */
-extern PRStatus _PR_MD_OPEN_DIR(_MDDir *md,const char *name);
-#define    _PR_MD_OPEN_DIR _MD_OPEN_DIR
-
-extern char * _PR_MD_READ_DIR(_MDDir *md, PRIntn flags);
-#define    _PR_MD_READ_DIR _MD_READ_DIR
-
-extern PRInt32 _PR_MD_CLOSE_DIR(_MDDir *md);
-#define    _PR_MD_CLOSE_DIR _MD_CLOSE_DIR
-
-/* Named semaphores related */
-extern PRSem * _PR_MD_OPEN_SEMAPHORE(
-    const char *osname, PRIntn flags, PRIntn mode, PRUintn value);
-#define    _PR_MD_OPEN_SEMAPHORE _MD_OPEN_SEMAPHORE
-
-extern PRStatus _PR_MD_WAIT_SEMAPHORE(PRSem *sem);
-#define    _PR_MD_WAIT_SEMAPHORE _MD_WAIT_SEMAPHORE
-
-extern PRStatus _PR_MD_POST_SEMAPHORE(PRSem *sem);
-#define    _PR_MD_POST_SEMAPHORE _MD_POST_SEMAPHORE
-
-extern PRStatus _PR_MD_CLOSE_SEMAPHORE(PRSem *sem);
-#define    _PR_MD_CLOSE_SEMAPHORE _MD_CLOSE_SEMAPHORE
-
-extern PRStatus _PR_MD_DELETE_SEMAPHORE(const char *osname);
-#define    _PR_MD_DELETE_SEMAPHORE _MD_DELETE_SEMAPHORE
-
-/* I/O related */
-extern void _PR_MD_INIT_FILEDESC(PRFileDesc *fd);
-#define    _PR_MD_INIT_FILEDESC _MD_INIT_FILEDESC
-
-#ifdef XP_MAC
-extern void _PR_MD_FREE_FILEDESC(PRFileDesc *fd);
-#define    _PR_MD_FREE_FILEDESC _MD_FREE_FILEDESC
-#endif
-
-extern void _PR_MD_MAKE_NONBLOCK(PRFileDesc *fd);
-#define    _PR_MD_MAKE_NONBLOCK _MD_MAKE_NONBLOCK
-
-/* File I/O related */
-extern PRInt32 _PR_MD_OPEN(const char *name, PRIntn osflags, PRIntn mode);
-#define    _PR_MD_OPEN _MD_OPEN
-
-extern PRInt32 _PR_MD_OPEN_FILE(const char *name, PRIntn osflags, PRIntn mode);
-#define    _PR_MD_OPEN_FILE _MD_OPEN_FILE
-
-extern PRInt32 _PR_MD_CLOSE_FILE(PRInt32 osfd);
-#define    _PR_MD_CLOSE_FILE _MD_CLOSE_FILE
-
-extern PRInt32 _PR_MD_READ(PRFileDesc *fd, void *buf, PRInt32 amount);
-#define    _PR_MD_READ _MD_READ
-
-extern PRInt32 _PR_MD_WRITE(PRFileDesc *fd, const void *buf, PRInt32 amount);
-#define    _PR_MD_WRITE _MD_WRITE
-
-extern PRInt32 _PR_MD_WRITEV(
-    PRFileDesc *fd, const struct PRIOVec *iov,
-    PRInt32 iov_size, PRIntervalTime timeout);
-#define    _PR_MD_WRITEV _MD_WRITEV
-
-extern PRInt32 _PR_MD_FSYNC(PRFileDesc *fd);
-#define    _PR_MD_FSYNC _MD_FSYNC
-
-extern PRInt32 _PR_MD_DELETE(const char *name);
-#define        _PR_MD_DELETE _MD_DELETE
-
-extern PRInt32 _PR_MD_RENAME(const char *from, const char *to);
-#define _PR_MD_RENAME _MD_RENAME
-
-extern PRInt32 _PR_MD_ACCESS(const char *name, PRAccessHow how);
-#define _PR_MD_ACCESS _MD_ACCESS
-
-extern PRInt32 _PR_MD_STAT(const char *name, struct stat *buf);
-#define _PR_MD_STAT _MD_STAT
-
-extern PRInt32 _PR_MD_MKDIR(const char *name, PRIntn mode);
-#define _PR_MD_MKDIR _MD_MKDIR
-
-extern PRInt32 _PR_MD_MAKE_DIR(const char *name, PRIntn mode);
-#define _PR_MD_MAKE_DIR _MD_MAKE_DIR
-
-extern PRInt32 _PR_MD_RMDIR(const char *name);
-#define _PR_MD_RMDIR _MD_RMDIR
-
-#ifdef MOZ_UNICODE
-/* UTF16 File I/O related */
-extern PRStatus _PR_MD_OPEN_DIR_UTF16(_MDDirUTF16 *md, const PRUnichar *name);
-#define    _PR_MD_OPEN_DIR_UTF16 _MD_OPEN_DIR_UTF16
-
-extern PRInt32 _PR_MD_OPEN_FILE_UTF16(const PRUnichar *name, PRIntn osflags, PRIntn mode);
-#define    _PR_MD_OPEN_FILE_UTF16 _MD_OPEN_FILE_UTF16
-
-extern PRUnichar * _PR_MD_READ_DIR_UTF16(_MDDirUTF16 *md, PRIntn flags);
-#define    _PR_MD_READ_DIR_UTF16 _MD_READ_DIR_UTF16
-
-extern PRInt32 _PR_MD_CLOSE_DIR_UTF16(_MDDirUTF16 *md);
-#define    _PR_MD_CLOSE_DIR_UTF16 _MD_CLOSE_DIR_UTF16
-
-extern PRInt32 _PR_MD_GETFILEINFO64_UTF16(const PRUnichar *fn, PRFileInfo64 *info);
-#define _PR_MD_GETFILEINFO64_UTF16 _MD_GETFILEINFO64_UTF16
-#endif /* MOZ_UNICODE */
-
-/* Socket I/O related */
-extern void _PR_MD_INIT_IO(void);
-#define    _PR_MD_INIT_IO _MD_INIT_IO
-
-extern PRInt32 _PR_MD_CLOSE_SOCKET(PRInt32 osfd);
-#define    _PR_MD_CLOSE_SOCKET _MD_CLOSE_SOCKET
-
-extern PRInt32 _PR_MD_CONNECT(
-    PRFileDesc *fd, const PRNetAddr *addr,
-    PRUint32 addrlen, PRIntervalTime timeout);
-#define    _PR_MD_CONNECT _MD_CONNECT
-
-extern PRInt32 _PR_MD_ACCEPT(
-    PRFileDesc *fd, PRNetAddr *addr,
-    PRUint32 *addrlen, PRIntervalTime timeout);
-#define    _PR_MD_ACCEPT _MD_ACCEPT
-
-extern PRInt32 _PR_MD_BIND(PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen);
-#define    _PR_MD_BIND _MD_BIND
-
-extern PRInt32 _PR_MD_LISTEN(PRFileDesc *fd, PRIntn backlog);
-#define    _PR_MD_LISTEN _MD_LISTEN
-
-extern PRInt32 _PR_MD_SHUTDOWN(PRFileDesc *fd, PRIntn how);
-#define    _PR_MD_SHUTDOWN _MD_SHUTDOWN
-
-extern PRInt32 _PR_MD_RECV(PRFileDesc *fd, void *buf, PRInt32 amount,
-                               PRIntn flags, PRIntervalTime timeout);
-#define    _PR_MD_RECV _MD_RECV
-
-extern PRInt32 _PR_MD_SEND(
-    PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags,
-    PRIntervalTime timeout);
-#define    _PR_MD_SEND _MD_SEND
-
-extern PRInt32 _PR_MD_ACCEPT_READ(PRFileDesc *sd, PRInt32 *newSock,
-                                PRNetAddr **raddr, void *buf, PRInt32 amount,
-                                PRIntervalTime timeout);
-#define _PR_MD_ACCEPT_READ _MD_ACCEPT_READ
-
-#ifdef WIN32
-extern PRInt32 _PR_MD_FAST_ACCEPT(PRFileDesc *fd, PRNetAddr *addr,
-                                PRUint32 *addrlen, PRIntervalTime timeout,
-                                PRBool fast,
-                                _PR_AcceptTimeoutCallback callback,
-                                void *callbackArg);
-
-extern PRInt32 _PR_MD_FAST_ACCEPT_READ(PRFileDesc *sd, PRInt32 *newSock,
-                                PRNetAddr **raddr, void *buf, PRInt32 amount,
-                                PRIntervalTime timeout, PRBool fast,
-                                _PR_AcceptTimeoutCallback callback,
-                                void *callbackArg);
-
-extern void _PR_MD_UPDATE_ACCEPT_CONTEXT(PRInt32 s, PRInt32 ls);
-#define _PR_MD_UPDATE_ACCEPT_CONTEXT _MD_UPDATE_ACCEPT_CONTEXT
-#endif /* WIN32 */
-
-extern PRInt32 _PR_MD_SENDFILE(
-    PRFileDesc *sock, PRSendFileData *sfd,
-	PRInt32 flags, PRIntervalTime timeout);
-#define _PR_MD_SENDFILE _MD_SENDFILE
-
-extern PRStatus _PR_MD_GETSOCKNAME(
-    PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen);
-#define    _PR_MD_GETSOCKNAME _MD_GETSOCKNAME
-
-extern PRStatus _PR_MD_GETPEERNAME(
-    PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen);
-#define    _PR_MD_GETPEERNAME _MD_GETPEERNAME
-
-extern PRStatus _PR_MD_GETSOCKOPT(
-    PRFileDesc *fd, PRInt32 level, PRInt32 optname, char* optval, PRInt32* optlen);
-#define    _PR_MD_GETSOCKOPT _MD_GETSOCKOPT
-
-extern PRStatus _PR_MD_SETSOCKOPT(
-    PRFileDesc *fd, PRInt32 level, PRInt32 optname,
-    const char* optval, PRInt32 optlen);
-#define    _PR_MD_SETSOCKOPT _MD_SETSOCKOPT
-
-extern PRStatus PR_CALLBACK _PR_SocketGetSocketOption(
-    PRFileDesc *fd, PRSocketOptionData *data);
-
-extern PRStatus PR_CALLBACK _PR_SocketSetSocketOption(
-    PRFileDesc *fd, const PRSocketOptionData *data);
-
-extern PRInt32 _PR_MD_RECVFROM(
-    PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags,
-    PRNetAddr *addr, PRUint32 *addrlen, PRIntervalTime timeout);
-#define    _PR_MD_RECVFROM _MD_RECVFROM
-
-extern PRInt32 _PR_MD_SENDTO(
-    PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags,
-    const PRNetAddr *addr, PRUint32 addrlen, PRIntervalTime timeout);
-#define    _PR_MD_SENDTO _MD_SENDTO
-
-extern PRInt32 _PR_MD_SOCKETPAIR(int af, int type, int flags, PRInt32 *osfd);
-#define    _PR_MD_SOCKETPAIR _MD_SOCKETPAIR
-
-extern PRInt32 _PR_MD_SOCKET(int af, int type, int flags);
-#define    _PR_MD_SOCKET _MD_SOCKET
-
-extern PRInt32 _PR_MD_SOCKETAVAILABLE(PRFileDesc *fd);
-#define    _PR_MD_SOCKETAVAILABLE _MD_SOCKETAVAILABLE
-
-extern PRInt32 _PR_MD_PIPEAVAILABLE(PRFileDesc *fd);
-#define    _PR_MD_PIPEAVAILABLE _MD_PIPEAVAILABLE
-
-extern PRInt32 _PR_MD_PR_POLL(PRPollDesc *pds, PRIntn npds,
-                                                                                        PRIntervalTime timeout);
-#define    _PR_MD_PR_POLL _MD_PR_POLL
-
-/*
- * Initialize fd->secret->inheritable for a newly created fd.
- * If 'imported' is false, the osfd (i.e., fd->secret->md.osfd)
- * was created by NSPR and hence has the OS-dependent default
- * inheritable attribute.  If 'imported' is true, the osfd was
- * not created by NSPR and hence a system call is required to
- * query its inheritable attribute.  Since we may never need to
- * know the inheritable attribute of a fd, a platform may choose
- * to initialize fd->secret->inheritable of an imported fd to
- * _PR_TRI_UNKNOWN and only pay the cost of the system call
- * (in _PR_MD_QUERY_FD_INHERITABLE) when necessary.
- */
-extern void _PR_MD_INIT_FD_INHERITABLE(PRFileDesc *fd, PRBool imported);
-#define    _PR_MD_INIT_FD_INHERITABLE _MD_INIT_FD_INHERITABLE
-
-extern PRStatus _PR_MD_SET_FD_INHERITABLE(PRFileDesc *fd, PRBool inheritable);
-#define    _PR_MD_SET_FD_INHERITABLE _MD_SET_FD_INHERITABLE
-
-
-#define _PR_PROCESS_TIMEOUT_INTERRUPT_ERRORS(me) \
-        if (_PR_PENDING_INTERRUPT(me)) { \
-                me->flags &= ~_PR_INTERRUPT; \
-                PR_SetError( PR_PENDING_INTERRUPT_ERROR, 0); \
-        } else { \
-                PR_SetError(PR_IO_TIMEOUT_ERROR, 0); \
-        }
-
-extern void *_PR_MD_GET_SP(PRThread *thread);
-#define    _PR_MD_GET_SP _MD_GET_SP
-
-#endif /* defined(_PR_PTHREADS) */
 
 /************************************************************************/
@@ -1431,21 +339,8 @@
 
 struct PRLock {
-#if defined(_PR_PTHREADS)
     pthread_mutex_t mutex;          /* the underlying lock */
     _PT_Notified notified;          /* array of conditions notified */
     PRBool locked;                  /* whether the mutex is locked */
     pthread_t owner;                /* if locked, current lock owner */
-#elif defined(_PR_BTHREADS)
-    sem_id	semaphoreID;	    /* the underlying lock */
-    int32	benaphoreCount;	    /* number of people in lock */
-    thread_id	owner;		    /* current lock owner */
-#else /* not pthreads or Be threads */
-    PRCList links;                  /* linkage for PRThread.lockList */
-    struct PRThread *owner;         /* current lock owner */
-    PRCList waitQ;                  /* list of threads waiting for lock */
-    PRThreadPriority priority;      /* priority of lock */
-    PRThreadPriority boostPriority; /* boosted priority of lock owner */
-    _MDLock ilock;                  /* Internal Lock to protect user-level fields */
-#endif
 };
 
@@ -1454,19 +349,6 @@
 struct PRCondVar {
     PRLock *lock;               /* associated lock that protects the condition */
-#if defined(_PR_PTHREADS)
     pthread_cond_t cv;          /* underlying pthreads condition */
     PRInt32 notify_pending;     /* CV has destroy pending notification */
-#elif defined(_PR_BTHREADS)
-    sem_id    sem;              /* the underlying lock */
-    sem_id    handshakeSem;     /* the lock for 'notify'-threads waiting for confirmation */
-    sem_id    signalSem;        /* the lock for threads waiting for someone to notify */
-    volatile int32    nw;       /* the number waiting */
-    volatile int32    ns;       /* the number signalling */
-    long signalBenCount;        /* the number waiting on the underlying sem */
-#else /* not pthreads or Be threads */
-    PRCList condQ;              /* Condition variable wait Q */
-    _MDLock ilock;              /* Internal Lock to protect condQ */
-    _MDCVar md;
-#endif
 };
 
@@ -1475,11 +357,7 @@
 struct PRMonitor {
     const char* name;           /* monitor name for debugging */
-#if defined(_PR_PTHREADS)
     PRLock lock;                /* the lock structure */
     pthread_t owner;            /* the owner of the lock or invalid */
     PRCondVar *cvar;            /* condition variable queue */
-#else  /* defined(_PR_PTHREADS) */
-    PRCondVar *cvar;            /* associated lock and condition variable queue */
-#endif /* defined(_PR_PTHREADS) */
     PRUint32 entryCount;        /* # of times re-entered */
 };
@@ -1488,16 +366,7 @@
 
 struct PRSemaphore {
-#if defined(_PR_BTHREADS)
-    sem_id  sem;
-    int32   benaphoreCount;
-#else
     PRCondVar *cvar;        /* associated lock and condition variable queue */
     PRUintn count;            /* the value of the counting semaphore */
     PRUint32 waiters;            /* threads waiting on the semaphore */
-#if defined(_PR_PTHREADS)
-#else  /* defined(_PR_PTHREADS) */
-    _MDSemaphore md;
-#endif /* defined(_PR_PTHREADS) */
-#endif /* defined(_PR_BTHREADS) */
 };
 
@@ -1547,9 +416,4 @@
     PRSegment *seg;
         PRThread* thr;          /* back pointer to thread owning this stack */
-
-#if defined(_PR_PTHREADS)
-#else /* defined(_PR_PTHREADS) */
-    _MDThreadStack md;
-#endif /* defined(_PR_PTHREADS) */
 };
 
@@ -1582,5 +446,4 @@
     char *errorString;              /* current error string | NULL */
 
-#if defined(_PR_PTHREADS)
     pthread_t id;                   /* pthread identifier for the thread */
     PRBool okToDelete;              /* ok to delete the PRThread struct? */
@@ -1599,74 +462,4 @@
     int *selectfd_list;             /* Unix fd's that PR_Poll selects on */
     PRUint32 selectfd_count;        /* number of elements in selectfd_list */
-#endif
-#elif defined(_PR_BTHREADS)
-    PRUint32 flags;
-    _MDThread md;
-    PRBool io_pending;
-    PRInt32 io_fd;
-    PRBool io_suspended;
-#else /* not pthreads or Be threads */
-    _MDLock threadLock;             /* Lock to protect thread state variables.
-                                     * Protects the following fields:
-                                     *     state
-                                     *     priority
-                                     *     links
-                                     *     wait
-                                     *     cpu
-                                     */
-    PRUint32 queueCount;
-    PRUint32 waitCount;
-
-    PRCList active;                 /* on list of all active threads        */
-    PRCList links;
-    PRCList waitQLinks;             /* when thread is PR_Wait'ing */
-    PRCList lockList;               /* list of locks currently holding */
-    PRIntervalTime sleep;           /* sleep time when thread is sleeping */
-    struct _wait {
-        struct PRLock *lock;
-        struct PRCondVar *cvar;
-    } wait;
-
-    PRUint32 id;
-    PRUint32 flags;
-    PRUint32 no_sched;              /* Don't schedule the thread to run.
-                                     * This flag has relevance only when
-                                     * multiple NSPR CPUs are created.
-                                     * When a thread is de-scheduled, there
-                                     * is a narrow window of time in which
-                                     * the thread is put on the run queue
-                                     * but the scheduler is actually using
-                                     * the stack of this thread.  It is safe
-                                     * to run this thread on a different CPU
-                                     * only when its stack is not in use on
-                                     * any other CPU.  The no_sched flag is
-                                     * set during this interval to prevent
-                                     * the thread from being scheduled on a
-                                     * different CPU.
-                                     */
-
-    /* thread termination condition variable for join */
-    PRCondVar *term;
-
-    _PRCPU *cpu;                    /* cpu to which this thread is bound    */
-    PRUint32 threadAllocatedOnStack;/* boolean */
-
-    /* When an async IO is in progress and a second async IO cannot be
-     * initiated, the io_pending flag is set to true.  Some platforms will
-     * not use the io_pending flag.  If the io_pending flag is true, then
-     * io_fd is the OS-file descriptor on which IO is pending.
-     */
-    PRBool io_pending;
-    PRInt32 io_fd;
-
-    /* If a timeout occurs or if an outstanding IO is interrupted and the
-     * OS doesn't support a real cancellation (NT or MAC), then the
-     * io_suspended flag will be set to true.  The thread will be resumed
-     * but may run into trouble issuing additional IOs until the io_pending
-     * flag can be cleared
-     */
-    PRBool io_suspended;
-
-    _MDThread md;
 #endif
 };
@@ -1803,8 +596,4 @@
     PRUint32 size;
     PRUintn flags;
-#if defined(_PR_PTHREADS)
-#else  /* defined(_PR_PTHREADS) */
-    _MDSegment md;
-#endif /* defined(_PR_PTHREADS) */
 };
 
Index: trunk/src/libs/xpcom18a4/nsprpub/pr/src/io/prlog.c
===================================================================
--- trunk/src/libs/xpcom18a4/nsprpub/pr/src/io/prlog.c	(revision 101804)
+++ trunk/src/libs/xpcom18a4/nsprpub/pr/src/io/prlog.c	(revision 101805)
@@ -72,28 +72,6 @@
  */
 static PRLock *_pr_logLock;
-#if defined(_PR_PTHREADS) || defined(_PR_BTHREADS)
 #define _PR_LOCK_LOG() PR_Lock(_pr_logLock);
 #define _PR_UNLOCK_LOG() PR_Unlock(_pr_logLock);
-#elif defined(_PR_GLOBAL_THREADS_ONLY)
-#define _PR_LOCK_LOG() { _PR_LOCK_LOCK(_pr_logLock)
-#define _PR_UNLOCK_LOG() _PR_LOCK_UNLOCK(_pr_logLock); }
-#else
-
-#define _PR_LOCK_LOG() \
-{ \
-    PRIntn _is; \
-    PRThread *_me = _PR_MD_CURRENT_THREAD(); \
-    if (!_PR_IS_NATIVE_THREAD(_me)) \
-        _PR_INTSOFF(_is); \
-    _PR_LOCK_LOCK(_pr_logLock)
-
-#define _PR_UNLOCK_LOG() \
-    _PR_LOCK_UNLOCK(_pr_logLock); \
-    PR_ASSERT(_me == _PR_MD_CURRENT_THREAD()); \
-    if (!_PR_IS_NATIVE_THREAD(_me)) \
-        _PR_INTSON(_is); \
-}
-
-#endif
 
 #if defined(XP_PC)
Index: trunk/src/libs/xpcom18a4/nsprpub/pr/src/io/prmapopt.c
===================================================================
--- trunk/src/libs/xpcom18a4/nsprpub/pr/src/io/prmapopt.c	(revision 101804)
+++ trunk/src/libs/xpcom18a4/nsprpub/pr/src/io/prmapopt.c	(revision 101805)
@@ -74,287 +74,4 @@
 #include <netinet/tcp.h>  /* TCP_NODELAY, TCP_MAXSEG */
 #endif
-
-#ifndef _PR_PTHREADS
-
-PRStatus PR_CALLBACK _PR_SocketGetSocketOption(PRFileDesc *fd, PRSocketOptionData *data)
-{
-    PRStatus rv;
-    PRInt32 length;
-    PRInt32 level, name;
-
-    /*
-     * PR_SockOpt_Nonblocking is a special case that does not
-     * translate to a getsockopt() call
-     */
-    if (PR_SockOpt_Nonblocking == data->option)
-    {
-        data->value.non_blocking = fd->secret->nonblocking;
-        return PR_SUCCESS;
-    }
-
-    rv = _PR_MapOptionName(data->option, &level, &name);
-    if (PR_SUCCESS == rv)
-    {
-        switch (data->option)
-        {
-            case PR_SockOpt_Linger:
-            {
-#if !defined(XP_BEOS) || defined(BONE_VERSION)
-                struct linger linger;
-                length = sizeof(linger);
-                rv = _PR_MD_GETSOCKOPT(
-                    fd, level, name, (char *) &linger, &length);
-                if (PR_SUCCESS == rv)
-                {
-                    PR_ASSERT(sizeof(linger) == length);
-                    data->value.linger.polarity =
-                        (linger.l_onoff) ? PR_TRUE : PR_FALSE;
-                    data->value.linger.linger =
-                        PR_SecondsToInterval(linger.l_linger);
-                }
-                break;
-#else
-                PR_SetError( PR_NOT_IMPLEMENTED_ERROR, 0 );
-                return PR_FAILURE;
-#endif
-            }
-            case PR_SockOpt_Reuseaddr:
-            case PR_SockOpt_Keepalive:
-            case PR_SockOpt_NoDelay:
-            case PR_SockOpt_Broadcast:
-            {
-#ifdef WIN32 /* Winsock */
-                BOOL value;
-#else
-                PRIntn value;
-#endif
-                length = sizeof(value);
-                rv = _PR_MD_GETSOCKOPT(
-                    fd, level, name, (char*)&value, &length);
-                if (PR_SUCCESS == rv)
-                    data->value.reuse_addr = (0 == value) ? PR_FALSE : PR_TRUE;
-                break;
-            }
-            case PR_SockOpt_McastLoopback:
-            {
-#ifdef WIN32 /* Winsock */
-                BOOL bool;
-#else
-                PRUint8 bool;
-#endif
-                length = sizeof(bool);
-                rv = _PR_MD_GETSOCKOPT(
-                    fd, level, name, (char*)&bool, &length);
-                if (PR_SUCCESS == rv)
-                    data->value.mcast_loopback = (0 == bool) ? PR_FALSE : PR_TRUE;
-                break;
-            }
-            case PR_SockOpt_RecvBufferSize:
-            case PR_SockOpt_SendBufferSize:
-            case PR_SockOpt_MaxSegment:
-            {
-                PRIntn value;
-                length = sizeof(value);
-                rv = _PR_MD_GETSOCKOPT(
-                    fd, level, name, (char*)&value, &length);
-                if (PR_SUCCESS == rv)
-                    data->value.recv_buffer_size = value;
-                break;
-            }
-            case PR_SockOpt_IpTimeToLive:
-            case PR_SockOpt_IpTypeOfService:
-            {
-                /* These options should really be an int (or PRIntn). */
-                length = sizeof(PRUintn);
-                rv = _PR_MD_GETSOCKOPT(
-                    fd, level, name, (char*)&data->value.ip_ttl, &length);
-                break;
-            }
-            case PR_SockOpt_McastTimeToLive:
-            {
-#ifdef WIN32 /* Winsock */
-                int ttl;
-#else
-                PRUint8 ttl;
-#endif
-                length = sizeof(ttl);
-                rv = _PR_MD_GETSOCKOPT(
-                    fd, level, name, (char*)&ttl, &length);
-                if (PR_SUCCESS == rv)
-                    data->value.mcast_ttl = ttl;
-                break;
-            }
-#ifdef IP_ADD_MEMBERSHIP
-            case PR_SockOpt_AddMember:
-            case PR_SockOpt_DropMember:
-            {
-                struct ip_mreq mreq;
-                length = sizeof(mreq);
-                rv = _PR_MD_GETSOCKOPT(
-                    fd, level, name, (char*)&mreq, &length);
-                if (PR_SUCCESS == rv)
-                {
-                    data->value.add_member.mcaddr.inet.ip =
-                        mreq.imr_multiaddr.s_addr;
-                    data->value.add_member.ifaddr.inet.ip =
-                        mreq.imr_interface.s_addr;
-                }
-                break;
-            }
-#endif /* IP_ADD_MEMBERSHIP */
-            case PR_SockOpt_McastInterface:
-            {
-                /* This option is a struct in_addr. */
-                length = sizeof(data->value.mcast_if.inet.ip);
-                rv = _PR_MD_GETSOCKOPT(
-                    fd, level, name,
-                    (char*)&data->value.mcast_if.inet.ip, &length);
-                break;
-            }
-            default:
-                PR_NOT_REACHED("Unknown socket option");
-                break;
-        }  
-    }
-    return rv;
-}  /* _PR_SocketGetSocketOption */
-
-PRStatus PR_CALLBACK _PR_SocketSetSocketOption(PRFileDesc *fd, const PRSocketOptionData *data)
-{
-    PRStatus rv;
-    PRInt32 level, name;
-
-    /*
-     * PR_SockOpt_Nonblocking is a special case that does not
-     * translate to a setsockopt call.
-     */
-    if (PR_SockOpt_Nonblocking == data->option)
-    {
-#ifdef WINNT
-        PR_ASSERT((fd->secret->md.io_model_committed == PR_FALSE)
-            || (fd->secret->nonblocking == data->value.non_blocking));
-        if (fd->secret->md.io_model_committed
-            && (fd->secret->nonblocking != data->value.non_blocking))
-        {
-            /*
-             * On NT, once we have associated a socket with the io
-             * completion port, we can't disassociate it.  So we
-             * can't change the nonblocking option of the socket
-             * afterwards.
-             */
-            PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
-            return PR_FAILURE;
-        }
-#endif
-        fd->secret->nonblocking = data->value.non_blocking;
-        return PR_SUCCESS;
-    }
-
-    rv = _PR_MapOptionName(data->option, &level, &name);
-    if (PR_SUCCESS == rv)
-    {
-        switch (data->option)
-        {
-            case PR_SockOpt_Linger:
-            {
-#if !defined(XP_BEOS) || defined(BONE_VERSION)
-                struct linger linger;
-                linger.l_onoff = data->value.linger.polarity;
-                linger.l_linger = PR_IntervalToSeconds(data->value.linger.linger);
-                rv = _PR_MD_SETSOCKOPT(
-                    fd, level, name, (char*)&linger, sizeof(linger));
-                break;
-#else
-                PR_SetError( PR_NOT_IMPLEMENTED_ERROR, 0 );
-                return PR_FAILURE;
-#endif
-            }
-            case PR_SockOpt_Reuseaddr:
-            case PR_SockOpt_Keepalive:
-            case PR_SockOpt_NoDelay:
-            case PR_SockOpt_Broadcast:
-            {
-#ifdef WIN32 /* Winsock */
-                BOOL value;
-#else
-                PRIntn value;
-#endif
-                value = (data->value.reuse_addr) ? 1 : 0;
-                rv = _PR_MD_SETSOCKOPT(
-                    fd, level, name, (char*)&value, sizeof(value));
-                break;
-            }
-            case PR_SockOpt_McastLoopback:
-            {
-#ifdef WIN32 /* Winsock */
-                BOOL bool;
-#else
-                PRUint8 bool;
-#endif
-                bool = data->value.mcast_loopback ? 1 : 0;
-                rv = _PR_MD_SETSOCKOPT(
-                    fd, level, name, (char*)&bool, sizeof(bool));
-                break;
-            }
-            case PR_SockOpt_RecvBufferSize:
-            case PR_SockOpt_SendBufferSize:
-            case PR_SockOpt_MaxSegment:
-            {
-                PRIntn value = data->value.recv_buffer_size;
-                rv = _PR_MD_SETSOCKOPT(
-                    fd, level, name, (char*)&value, sizeof(value));
-                break;
-            }
-            case PR_SockOpt_IpTimeToLive:
-            case PR_SockOpt_IpTypeOfService:
-            {
-                /* These options should really be an int (or PRIntn). */
-                rv = _PR_MD_SETSOCKOPT(
-                    fd, level, name, (char*)&data->value.ip_ttl, sizeof(PRUintn));
-                break;
-            }
-            case PR_SockOpt_McastTimeToLive:
-            {
-#ifdef WIN32 /* Winsock */
-                int ttl;
-#else
-                PRUint8 ttl;
-#endif
-                ttl = data->value.mcast_ttl;
-                rv = _PR_MD_SETSOCKOPT(
-                    fd, level, name, (char*)&ttl, sizeof(ttl));
-                break;
-            }
-#ifdef IP_ADD_MEMBERSHIP
-            case PR_SockOpt_AddMember:
-            case PR_SockOpt_DropMember:
-            {
-                struct ip_mreq mreq;
-                mreq.imr_multiaddr.s_addr =
-                    data->value.add_member.mcaddr.inet.ip;
-                mreq.imr_interface.s_addr =
-                    data->value.add_member.ifaddr.inet.ip;
-                rv = _PR_MD_SETSOCKOPT(
-                    fd, level, name, (char*)&mreq, sizeof(mreq));
-                break;
-            }
-#endif /* IP_ADD_MEMBERSHIP */
-            case PR_SockOpt_McastInterface:
-            {
-                /* This option is a struct in_addr. */
-                rv = _PR_MD_SETSOCKOPT(
-                    fd, level, name, (char*)&data->value.mcast_if.inet.ip,
-                    sizeof(data->value.mcast_if.inet.ip));
-                break;
-            }
-            default:
-                PR_NOT_REACHED("Unknown socket option");
-                break;
-        }  
-    }
-    return rv;
-}  /* _PR_SocketSetSocketOption */
-
-#endif /* ! _PR_PTHREADS */
 
 /*
Index: trunk/src/libs/xpcom18a4/nsprpub/pr/src/md/unix/darwin.c
===================================================================
--- trunk/src/libs/xpcom18a4/nsprpub/pr/src/md/unix/darwin.c	(revision 101804)
+++ trunk/src/libs/xpcom18a4/nsprpub/pr/src/md/unix/darwin.c	(revision 101805)
@@ -44,66 +44,7 @@
 PRWord *_MD_HomeGCRegisters(PRThread *t, int isCurrent, int *np)
 {
-#if !defined(_PR_PTHREADS)
-    if (isCurrent) {
-	(void) setjmp(CONTEXT(t));
-    }
-    *np = sizeof(CONTEXT(t)) / sizeof(PRWord);
-    return (PRWord *) CONTEXT(t);
-#else
 	*np = 0;
 	return NULL;
-#endif
 }
-
-#if !defined(_PR_PTHREADS)
-void
-_MD_SET_PRIORITY(_MDThread *thread, PRUintn newPri)
-{
-    return;
-}
-
-PRStatus
-_MD_InitializeThread(PRThread *thread)
-{
-	return PR_SUCCESS;
-}
-
-PRStatus
-_MD_WAIT(PRThread *thread, PRIntervalTime ticks)
-{
-    PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));
-    _PR_MD_SWITCH_CONTEXT(thread);
-    return PR_SUCCESS;
-}
-
-PRStatus
-_MD_WAKEUP_WAITER(PRThread *thread)
-{
-    if (thread) {
-	PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));
-    }
-    return PR_SUCCESS;
-}
-
-/* These functions should not be called for Darwin */
-void
-_MD_YIELD(void)
-{
-    PR_NOT_REACHED("_MD_YIELD should not be called for Darwin.");
-}
-
-PRStatus
-_MD_CREATE_THREAD(
-    PRThread *thread,
-    void (*start) (void *),
-    PRThreadPriority priority,
-    PRThreadScope scope,
-    PRThreadState state,
-    PRUint32 stackSize)
-{
-    PR_NOT_REACHED("_MD_CREATE_THREAD should not be called for Darwin.");
-	return PR_FAILURE;
-}
-#endif /* ! _PR_PTHREADS */
 
 /* darwin.c */
Index: trunk/src/libs/xpcom18a4/nsprpub/pr/src/md/unix/freebsd.c
===================================================================
--- trunk/src/libs/xpcom18a4/nsprpub/pr/src/md/unix/freebsd.c	(revision 101804)
+++ trunk/src/libs/xpcom18a4/nsprpub/pr/src/md/unix/freebsd.c	(revision 101805)
@@ -56,64 +56,6 @@
 PRWord *_MD_HomeGCRegisters(PRThread *t, int isCurrent, int *np)
 {
-#ifndef _PR_PTHREADS
-    if (isCurrent) {
-	(void) sigsetjmp(CONTEXT(t), 1);
-    }
-    *np = sizeof(CONTEXT(t)) / sizeof(PRWord);
-    return (PRWord *) CONTEXT(t);
-#else
 	*np = 0;
 	return NULL;
-#endif
 }
 
-#ifndef _PR_PTHREADS
-void
-_MD_SET_PRIORITY(_MDThread *thread, PRUintn newPri)
-{
-    return;
-}
-
-PRStatus
-_MD_InitializeThread(PRThread *thread)
-{
-	return PR_SUCCESS;
-}
-
-PRStatus
-_MD_WAIT(PRThread *thread, PRIntervalTime ticks)
-{
-    PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));
-    _PR_MD_SWITCH_CONTEXT(thread);
-    return PR_SUCCESS;
-}
-
-PRStatus
-_MD_WAKEUP_WAITER(PRThread *thread)
-{
-    if (thread) {
-	PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));
-    }
-    return PR_SUCCESS;
-}
-
-/* These functions should not be called for FreeBSD */
-void
-_MD_YIELD(void)
-{
-    PR_NOT_REACHED("_MD_YIELD should not be called for FreeBSD.");
-}
-
-PRStatus
-_MD_CREATE_THREAD(
-    PRThread *thread,
-    void (*start) (void *),
-    PRThreadPriority priority,
-    PRThreadScope scope,
-    PRThreadState state,
-    PRUint32 stackSize)
-{
-    PR_NOT_REACHED("_MD_CREATE_THREAD should not be called for FreeBSD.");
-	return PR_FAILURE;
-}
-#endif /* ! _PR_PTHREADS */
Index: trunk/src/libs/xpcom18a4/nsprpub/pr/src/md/unix/linux.c
===================================================================
--- trunk/src/libs/xpcom18a4/nsprpub/pr/src/md/unix/linux.c	(revision 101804)
+++ trunk/src/libs/xpcom18a4/nsprpub/pr/src/md/unix/linux.c	(revision 101805)
@@ -44,17 +44,7 @@
 PRWord *_MD_HomeGCRegisters(PRThread *t, int isCurrent, int *np)
 {
-#ifndef _PR_PTHREADS
-    if (isCurrent) {
-	(void) setjmp(CONTEXT(t));
-    }
-    *np = sizeof(CONTEXT(t)) / sizeof(PRWord);
-    return (PRWord *) CONTEXT(t);
-#else
 	*np = 0;
 	return NULL;
-#endif
 }
-
-#ifdef _PR_PTHREADS
 
 extern void _MD_unix_terminate_waitpid_daemon(void);
@@ -65,59 +55,2 @@
 }
 
-#else /* ! _PR_PTHREADS */
-
-void
-_MD_SET_PRIORITY(_MDThread *thread, PRUintn newPri)
-{
-    return;
-}
-
-PRStatus
-_MD_InitializeThread(PRThread *thread)
-{
-	/*
-	 * set the pointers to the stack-pointer and frame-pointer words in the
-	 * context structure; this is for debugging use.
-	 */
-	thread->md.sp = _MD_GET_SP_PTR(thread);
-	thread->md.fp = _MD_GET_FP_PTR(thread);
-	return PR_SUCCESS;
-}
-
-PRStatus
-_MD_WAIT(PRThread *thread, PRIntervalTime ticks)
-{
-    PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));
-    _PR_MD_SWITCH_CONTEXT(thread);
-    return PR_SUCCESS;
-}
-
-PRStatus
-_MD_WAKEUP_WAITER(PRThread *thread)
-{
-    if (thread) {
-	PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));
-    }
-    return PR_SUCCESS;
-}
-
-/* These functions should not be called for Linux */
-void
-_MD_YIELD(void)
-{
-    PR_NOT_REACHED("_MD_YIELD should not be called for Linux.");
-}
-
-PRStatus
-_MD_CREATE_THREAD(
-    PRThread *thread,
-    void (*start) (void *),
-    PRThreadPriority priority,
-    PRThreadScope scope,
-    PRThreadState state,
-    PRUint32 stackSize)
-{
-    PR_NOT_REACHED("_MD_CREATE_THREAD should not be called for Linux.");
-	return PR_FAILURE;
-}
-#endif /* ! _PR_PTHREADS */
Index: trunk/src/libs/xpcom18a4/nsprpub/pr/src/md/unix/netbsd.c
===================================================================
--- trunk/src/libs/xpcom18a4/nsprpub/pr/src/md/unix/netbsd.c	(revision 101804)
+++ trunk/src/libs/xpcom18a4/nsprpub/pr/src/md/unix/netbsd.c	(revision 101805)
@@ -58,64 +58,6 @@
 PRWord *_MD_HomeGCRegisters(PRThread *t, int isCurrent, int *np)
 {
-#ifndef _PR_PTHREADS
-    if (isCurrent) {
-        (void) sigsetjmp(CONTEXT(t), 1);
-    }
-    *np = sizeof(CONTEXT(t)) / sizeof(PRWord);
-    return (PRWord *) CONTEXT(t);
-#else
     *np = 0;
     return NULL;
-#endif
 }
 
-#ifndef _PR_PTHREADS
-void
-_MD_SET_PRIORITY(_MDThread *thread, PRUintn newPri)
-{
-    return;
-}
-
-PRStatus
-_MD_InitializeThread(PRThread *thread)
-{
-    return PR_SUCCESS;
-}
-
-PRStatus
-_MD_WAIT(PRThread *thread, PRIntervalTime ticks)
-{
-    PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));
-    _PR_MD_SWITCH_CONTEXT(thread);
-    return PR_SUCCESS;
-}
-
-PRStatus
-_MD_WAKEUP_WAITER(PRThread *thread)
-{
-    if (thread) {
-        PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));
-    }
-    return PR_SUCCESS;
-}
-
-/* These functions should not be called for NetBSD */
-void
-_MD_YIELD(void)
-{
-    PR_NOT_REACHED("_MD_YIELD should not be called for NetBSD.");
-}
-
-PRStatus
-_MD_CREATE_THREAD(
-    PRThread *thread,
-    void (*start) (void *),
-    PRThreadPriority priority,
-    PRThreadScope scope,
-    PRThreadState state,
-    PRUint32 stackSize)
-{
-    PR_NOT_REACHED("_MD_CREATE_THREAD should not be called for NetBSD.");
-    return PR_FAILURE;
-}
-#endif /* ! _PR_PTHREADS */
Index: trunk/src/libs/xpcom18a4/nsprpub/pr/src/md/unix/openbsd.c
===================================================================
--- trunk/src/libs/xpcom18a4/nsprpub/pr/src/md/unix/openbsd.c	(revision 101804)
+++ trunk/src/libs/xpcom18a4/nsprpub/pr/src/md/unix/openbsd.c	(revision 101805)
@@ -58,64 +58,6 @@
 PRWord *_MD_HomeGCRegisters(PRThread *t, int isCurrent, int *np)
 {
-#ifndef _PR_PTHREADS
-    if (isCurrent) {
-        (void) sigsetjmp(CONTEXT(t), 1);
-    }
-    *np = sizeof(CONTEXT(t)) / sizeof(PRWord);
-    return (PRWord *) CONTEXT(t);
-#else
     *np = 0;
     return NULL;
-#endif
 }
 
-#ifndef _PR_PTHREADS
-void
-_MD_SET_PRIORITY(_MDThread *thread, PRUintn newPri)
-{
-    return;
-}
-
-PRStatus
-_MD_InitializeThread(PRThread *thread)
-{
-    return PR_SUCCESS;
-}
-
-PRStatus
-_MD_WAIT(PRThread *thread, PRIntervalTime ticks)
-{
-    PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));
-    _PR_MD_SWITCH_CONTEXT(thread);
-    return PR_SUCCESS;
-}
-
-PRStatus
-_MD_WAKEUP_WAITER(PRThread *thread)
-{
-    if (thread) {
-        PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));
-    }
-    return PR_SUCCESS;
-}
-
-/* These functions should not be called for OpenBSD */
-void
-_MD_YIELD(void)
-{
-    PR_NOT_REACHED("_MD_YIELD should not be called for OpenBSD.");
-}
-
-PRStatus
-_MD_CREATE_THREAD(
-    PRThread *thread,
-    void (*start) (void *),
-    PRThreadPriority priority,
-    PRThreadScope scope,
-    PRThreadState state,
-    PRUint32 stackSize)
-{
-    PR_NOT_REACHED("_MD_CREATE_THREAD should not be called for OpenBSD.");
-    return PR_FAILURE;
-}
-#endif /* ! _PR_PTHREADS */
Index: trunk/src/libs/xpcom18a4/nsprpub/pr/src/md/unix/solaris.c
===================================================================
--- trunk/src/libs/xpcom18a4/nsprpub/pr/src/md/unix/solaris.c	(revision 101804)
+++ trunk/src/libs/xpcom18a4/nsprpub/pr/src/md/unix/solaris.c	(revision 101805)
@@ -75,5 +75,4 @@
 }
 
-#ifdef _PR_PTHREADS
 void _MD_EarlyInit(void)
 {
@@ -85,5 +84,4 @@
 	return NULL;
 }
-#endif /* _PR_PTHREADS */
 
 #if !defined(i386) && !defined(IS_64)
@@ -636,127 +634,4 @@
 }
 
-#ifdef OLD_CODE
-
-void _MD_SuspendAll()
-{
-    /* On solaris there are threads, and there are LWPs. 
-     * Calling _PR_DoSingleThread would freeze all of the threads bound to LWPs
-     * but not necessarily stop all LWPs (for example if someone did
-     * an attachthread of a thread which was not bound to an LWP).
-     * So now go through all the LWPs for this process and freeze them.
-     *
-     * Note that if any thread which is capable of having the GC run on it must
-     * had better be a LWP with a single bound thread on it.  Otherwise, this 
-     * might not stop that thread from being run.
-     */
-    PRThread *current = _PR_MD_CURRENT_THREAD();
-    prstatus_t status, lwpstatus;
-    int result, index, lwp_fd;
-    lwpid_t me = _lwp_self();
-    int err;
-    int lwp_main_proc_fd;
-
-    solaris_preempt_off();
-
-    /* run at highest prio so I cannot be preempted */
-    thr_getprio(thr_self(), &gcprio);
-    thr_setprio(thr_self(), 0x7fffffff); 
-
-    current->md.sp = (uint_t)&me;	/* set my own stack pointer */
-
-    if ( (lwp_main_proc_fd = solaris_open_main_proc_fd()) < 0) {
-        PR_ASSERT(0);
-        solaris_preempt_on();
-        return;   /* XXXMB ARGH, we're hosed! */
-    }
-
-    if ( (result = syscall(SYS_ioctl, lwp_main_proc_fd, PIOCSTATUS, &status)) < 0) {
-        err = errno;
-        PR_ASSERT(0);
-        goto failure;   /* XXXMB ARGH, we're hosed! */
-    }
-
-    num_lwps = status.pr_nlwp;
-
-    if ( (all_lwps = (lwpid_t *)PR_MALLOC((num_lwps+1) * sizeof(lwpid_t)))==NULL) {
-        PR_ASSERT(0);
-        goto failure;   /* XXXMB ARGH, we're hosed! */
-    }
-           
-    if ( (result = syscall(SYS_ioctl, lwp_main_proc_fd, PIOCLWPIDS, all_lwps)) < 0) {
-        PR_ASSERT(0);
-        PR_DELETE(all_lwps);
-        goto failure;   /* XXXMB ARGH, we're hosed! */
-    }
-
-    for (index=0; index< num_lwps; index++) {
-        if (all_lwps[index] != me)  {
-            if (_lwp_suspend(all_lwps[index]) < 0) { 
-                /* could happen if lwp exited */
-                all_lwps[index] = me;	/* dummy it up */
-            }
-        }
-    }
-
-    /* Turns out that lwp_suspend is not a blocking call.
-     * Go through the list and make sure they are all stopped.
-     */
-    for (index=0; index< num_lwps; index++) {
-        if (all_lwps[index] != me)  {
-            if ( (lwp_fd = solaris_open_lwp(all_lwps[index], lwp_main_proc_fd)) < 0) {
-                PR_ASSERT(0);
-                PR_DELETE(all_lwps);
-                all_lwps = NULL;
-                goto failure;   /* XXXMB ARGH, we're hosed! */
-            }
-
-            if ( (result = syscall(SYS_ioctl, lwp_fd, PIOCSTATUS, &lwpstatus)) < 0) {
-                /* Hopefully the thread just died... */
-                close(lwp_fd);
-                continue;
-            }
-            while ( !(lwpstatus.pr_flags & PR_STOPPED) ) {
-                if ( (result = syscall(SYS_ioctl, lwp_fd, PIOCSTATUS, &lwpstatus)) < 0) {
-                    PR_ASSERT(0);  /* ARGH SOMETHING WRONG! */
-                    break;
-                }
-                solaris_msec_sleep(1);
-            }
-            solaris_record_regs(&lwpstatus);
-            close(lwp_fd);
-        }
-    }
-
-    close(lwp_main_proc_fd);
-
-    return;
-failure:
-    solaris_preempt_on();
-    thr_setprio(thr_self(), gcprio);
-    close(lwp_main_proc_fd);
-    return;
-}
-
-void _MD_ResumeAll()
-{
-    int i;
-    lwpid_t me = _lwp_self();
- 
-    for (i=0; i < num_lwps; i++) {
-        if (all_lwps[i] == me)
-            continue;
-        if ( _lwp_continue(all_lwps[i]) < 0) {
-            PR_ASSERT(0);  /* ARGH, we are hosed! */
-        }
-    }
-
-    /* restore priority and sigmask */
-    thr_setprio(thr_self(), gcprio);
-    solaris_preempt_on();
-    PR_DELETE(all_lwps);
-    all_lwps = NULL;
-}
-#endif /* OLD_CODE */
-
 #ifdef USE_SETJMP
 PRWord *_MD_HomeGCRegisters(PRThread *t, int isCurrent, int *np)
@@ -862,28 +737,2 @@
 
 #endif /* _PR_GLOBAL_THREADS_ONLY */
-
-#ifndef _PR_PTHREADS
-#if defined(i386) && defined(SOLARIS2_4)
-/* 
- * Because clock_gettime() on Solaris/x86 2.4 always generates a
- * segmentation fault, we use an emulated version _pr_solx86_clock_gettime(),
- * which is implemented using gettimeofday().
- */
-
-int
-_pr_solx86_clock_gettime(clockid_t clock_id, struct timespec *tp)
-{
-    struct timeval tv;
-
-    if (clock_id != CLOCK_REALTIME) {
-	errno = EINVAL;
-	return -1;
-    }
-
-    gettimeofday(&tv, NULL);
-    tp->tv_sec = tv.tv_sec;
-    tp->tv_nsec = tv.tv_usec * 1000;
-    return 0;
-}
-#endif  /* i386 && SOLARIS2_4 */
-#endif  /* _PR_PTHREADS */
Index: trunk/src/libs/xpcom18a4/nsprpub/pr/src/md/unix/unix.c
===================================================================
--- trunk/src/libs/xpcom18a4/nsprpub/pr/src/md/unix/unix.c	(revision 101804)
+++ trunk/src/libs/xpcom18a4/nsprpub/pr/src/md/unix/unix.c	(revision 101805)
@@ -97,2200 +97,4 @@
 sigset_t timer_set;
 
-#if !defined(_PR_PTHREADS)
-
-static sigset_t empty_set;
-
-#ifdef SOLARIS
-#include <sys/file.h>
-#include <sys/filio.h>
-#endif
-
-#ifndef PIPE_BUF
-#define PIPE_BUF 512
-#endif
-
-/*
- * _nspr_noclock - if set clock interrupts are disabled
- */
-int _nspr_noclock = 1;
-
-#ifdef IRIX
-extern PRInt32 _nspr_terminate_on_error;
-#endif
-
-/*
- * There is an assertion in this code that NSPR's definition of PRIOVec
- * is bit compatible with UNIX' definition of a struct iovec. This is
- * applicable to the 'writev()' operations where the types are casually
- * cast to avoid warnings.
- */
-
-int _pr_md_pipefd[2] = { -1, -1 };
-static char _pr_md_pipebuf[PIPE_BUF];
-static PRInt32 local_io_wait(PRInt32 osfd, PRInt32 wait_flag,
-							PRIntervalTime timeout);
-
-_PRInterruptTable _pr_interruptTable[] = {
-    { 
-        "clock", _PR_MISSED_CLOCK, _PR_ClockInterrupt,     },
-    { 
-        0     }
-};
-
-PR_IMPLEMENT(void) _MD_unix_init_running_cpu(_PRCPU *cpu)
-{
-    PR_INIT_CLIST(&(cpu->md.md_unix.ioQ));
-    cpu->md.md_unix.ioq_max_osfd = -1;
-    cpu->md.md_unix.ioq_timeout = PR_INTERVAL_NO_TIMEOUT;
-}
-
-PRStatus _MD_open_dir(_MDDir *d, const char *name)
-{
-int err;
-
-    d->d = opendir(name);
-    if (!d->d) {
-        err = _MD_ERRNO();
-        _PR_MD_MAP_OPENDIR_ERROR(err);
-        return PR_FAILURE;
-    }
-    return PR_SUCCESS;
-}
-
-PRInt32 _MD_close_dir(_MDDir *d)
-{
-int rv = 0, err;
-
-    if (d->d) {
-        rv = closedir(d->d);
-        if (rv == -1) {
-                err = _MD_ERRNO();
-                _PR_MD_MAP_CLOSEDIR_ERROR(err);
-        }
-    }
-    return rv;
-}
-
-char * _MD_read_dir(_MDDir *d, PRIntn flags)
-{
-struct dirent *de;
-int err;
-
-    for (;;) {
-        /*
-          * XXX: readdir() is not MT-safe. There is an MT-safe version
-          * readdir_r() on some systems.
-          */
-        de = readdir(d->d);
-        if (!de) {
-            err = _MD_ERRNO();
-            _PR_MD_MAP_READDIR_ERROR(err);
-            return 0;
-        }        
-        if ((flags & PR_SKIP_DOT) &&
-            (de->d_name[0] == '.') && (de->d_name[1] == 0))
-            continue;
-        if ((flags & PR_SKIP_DOT_DOT) &&
-            (de->d_name[0] == '.') && (de->d_name[1] == '.') &&
-            (de->d_name[2] == 0))
-            continue;
-        if ((flags & PR_SKIP_HIDDEN) && (de->d_name[0] == '.'))
-            continue;
-        break;
-    }
-    return de->d_name;
-}
-
-PRInt32 _MD_delete(const char *name)
-{
-PRInt32 rv, err;
-#ifdef UNIXWARE
-    sigset_t set, oset;
-#endif
-
-#ifdef UNIXWARE
-    sigfillset(&set);
-    sigprocmask(SIG_SETMASK, &set, &oset);
-#endif
-    rv = unlink(name);
-#ifdef UNIXWARE
-    sigprocmask(SIG_SETMASK, &oset, NULL);
-#endif
-    if (rv == -1) {
-            err = _MD_ERRNO();
-            _PR_MD_MAP_UNLINK_ERROR(err);
-    }
-    return(rv);
-}
-
-PRInt32 _MD_rename(const char *from, const char *to)
-{
-    PRInt32 rv = -1, err;
-
-    /*
-    ** This is trying to enforce the semantics of WINDOZE' rename
-    ** operation. That means one is not allowed to rename over top
-    ** of an existing file. Holding a lock across these two function
-    ** and the open function is known to be a bad idea, but ....
-    */
-    if (NULL != _pr_rename_lock)
-        PR_Lock(_pr_rename_lock);
-    if (0 == access(to, F_OK))
-        PR_SetError(PR_FILE_EXISTS_ERROR, 0);
-    else
-    {
-        rv = rename(from, to);
-        if (rv < 0) {
-            err = _MD_ERRNO();
-            _PR_MD_MAP_RENAME_ERROR(err);
-        }
-    }
-    if (NULL != _pr_rename_lock)
-        PR_Unlock(_pr_rename_lock);
-    return rv;
-}
-
-PRInt32 _MD_access(const char *name, PRAccessHow how)
-{
-PRInt32 rv, err;
-int amode;
-
-    switch (how) {
-        case PR_ACCESS_WRITE_OK:
-            amode = W_OK;
-            break;
-        case PR_ACCESS_READ_OK:
-            amode = R_OK;
-            break;
-        case PR_ACCESS_EXISTS:
-            amode = F_OK;
-            break;
-        default:
-            PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
-            rv = -1;
-            goto done;
-    }
-    rv = access(name, amode);
-
-    if (rv < 0) {
-        err = _MD_ERRNO();
-        _PR_MD_MAP_ACCESS_ERROR(err);
-    }
-
-done:
-    return(rv);
-}
-
-PRInt32 _MD_mkdir(const char *name, PRIntn mode)
-{
-int rv, err;
-
-    /*
-    ** This lock is used to enforce rename semantics as described
-    ** in PR_Rename. Look there for more fun details.
-    */
-    if (NULL !=_pr_rename_lock)
-        PR_Lock(_pr_rename_lock);
-    rv = mkdir(name, mode);
-    if (rv < 0) {
-        err = _MD_ERRNO();
-        _PR_MD_MAP_MKDIR_ERROR(err);
-    }
-    if (NULL !=_pr_rename_lock)
-        PR_Unlock(_pr_rename_lock);
-    return rv;
-}
-
-PRInt32 _MD_rmdir(const char *name)
-{
-int rv, err;
-
-    rv = rmdir(name);
-    if (rv == -1) {
-            err = _MD_ERRNO();
-            _PR_MD_MAP_RMDIR_ERROR(err);
-    }
-    return rv;
-}
-
-PRInt32 _MD_read(PRFileDesc *fd, void *buf, PRInt32 amount)
-{
-PRThread *me = _PR_MD_CURRENT_THREAD();
-PRInt32 rv, err;
-#ifndef _PR_USE_POLL
-fd_set rd;
-#else
-struct pollfd pfd;
-#endif /* _PR_USE_POLL */
-PRInt32 osfd = fd->secret->md.osfd;
-
-#ifndef _PR_USE_POLL
-    FD_ZERO(&rd);
-    FD_SET(osfd, &rd);
-#else
-    pfd.fd = osfd;
-    pfd.events = POLLIN;
-#endif /* _PR_USE_POLL */
-    while ((rv = read(osfd,buf,amount)) == -1) {
-        err = _MD_ERRNO();
-        if ((err == EAGAIN) || (err == EWOULDBLOCK)) {
-            if (fd->secret->nonblocking) {
-                break;
-            }
-            if (!_PR_IS_NATIVE_THREAD(me)) {
-                if ((rv = local_io_wait(osfd, _PR_UNIX_POLL_READ,
-										PR_INTERVAL_NO_TIMEOUT)) < 0)
-					goto done;								
-            } else {
-#ifndef _PR_USE_POLL
-                while ((rv = _MD_SELECT(osfd + 1, &rd, NULL, NULL, NULL))
-                        == -1 && (err = _MD_ERRNO()) == EINTR) {
-                    /* retry _MD_SELECT() if it is interrupted */
-                }
-#else /* _PR_USE_POLL */
-                while ((rv = _MD_POLL(&pfd, 1, -1))
-                        == -1 && (err = _MD_ERRNO()) == EINTR) {
-                    /* retry _MD_POLL() if it is interrupted */
-                }
-#endif /* _PR_USE_POLL */
-                if (rv == -1) {
-                    break;
-                }
-            }
-            if (_PR_PENDING_INTERRUPT(me))
-                break;
-        } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))){
-            continue;
-        } else {
-            break;
-        }
-    }
-    if (rv < 0) {
-        if (_PR_PENDING_INTERRUPT(me)) {
-            me->flags &= ~_PR_INTERRUPT;
-            PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);
-        } else {
-            _PR_MD_MAP_READ_ERROR(err);
-        }
-    }
-done:
-    return(rv);
-}
-
-PRInt32 _MD_write(PRFileDesc *fd, const void *buf, PRInt32 amount)
-{
-PRThread *me = _PR_MD_CURRENT_THREAD();
-PRInt32 rv, err;
-#ifndef _PR_USE_POLL
-fd_set wd;
-#else
-struct pollfd pfd;
-#endif /* _PR_USE_POLL */
-PRInt32 osfd = fd->secret->md.osfd;
-
-#ifndef _PR_USE_POLL
-    FD_ZERO(&wd);
-    FD_SET(osfd, &wd);
-#else
-    pfd.fd = osfd;
-    pfd.events = POLLOUT;
-#endif /* _PR_USE_POLL */
-    while ((rv = write(osfd,buf,amount)) == -1) {
-        err = _MD_ERRNO();
-        if ((err == EAGAIN) || (err == EWOULDBLOCK)) {
-            if (fd->secret->nonblocking) {
-                break;
-            }
-            if (!_PR_IS_NATIVE_THREAD(me)) {
-                if ((rv = local_io_wait(osfd, _PR_UNIX_POLL_WRITE,
-										PR_INTERVAL_NO_TIMEOUT)) < 0)
-                    goto done;
-            } else {
-#ifndef _PR_USE_POLL
-                while ((rv = _MD_SELECT(osfd + 1, NULL, &wd, NULL, NULL))
-                        == -1 && (err = _MD_ERRNO()) == EINTR) {
-                    /* retry _MD_SELECT() if it is interrupted */
-                }
-#else /* _PR_USE_POLL */
-                while ((rv = _MD_POLL(&pfd, 1, -1))
-                        == -1 && (err = _MD_ERRNO()) == EINTR) {
-                    /* retry _MD_POLL() if it is interrupted */
-                }
-#endif /* _PR_USE_POLL */
-                if (rv == -1) {
-                    break;
-                }
-            }
-            if (_PR_PENDING_INTERRUPT(me))
-                break;
-        } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))){
-            continue;
-        } else {
-            break;
-        }
-    }
-    if (rv < 0) {
-        if (_PR_PENDING_INTERRUPT(me)) {
-            me->flags &= ~_PR_INTERRUPT;
-            PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);
-        } else {
-            _PR_MD_MAP_WRITE_ERROR(err);
-        }
-    }
-done:
-    return(rv);
-}
-
-PRInt32 _MD_fsync(PRFileDesc *fd)
-{
-PRInt32 rv, err;
-
-    rv = fsync(fd->secret->md.osfd);
-    if (rv == -1) {
-        err = _MD_ERRNO();
-        _PR_MD_MAP_FSYNC_ERROR(err);
-    }
-    return(rv);
-}
-
-PRInt32 _MD_close(PRInt32 osfd)
-{
-PRInt32 rv, err;
-
-    rv = close(osfd);
-    if (rv == -1) {
-        err = _MD_ERRNO();
-        _PR_MD_MAP_CLOSE_ERROR(err);
-    }
-    return(rv);
-}
-
-PRInt32 _MD_socket(PRInt32 domain, PRInt32 type, PRInt32 proto)
-{
-    PRInt32 osfd, err;
-
-    osfd = socket(domain, type, proto);
-
-    if (osfd == -1) {
-        err = _MD_ERRNO();
-        _PR_MD_MAP_SOCKET_ERROR(err);
-        return(osfd);
-    }
-
-    return(osfd);
-}
-
-PRInt32 _MD_socketavailable(PRFileDesc *fd)
-{
-    PRInt32 result;
-
-    if (ioctl(fd->secret->md.osfd, FIONREAD, &result) < 0) {
-        _PR_MD_MAP_SOCKETAVAILABLE_ERROR(_MD_ERRNO());
-        return -1;
-    }
-    return result;
-}
-
-PRInt64 _MD_socketavailable64(PRFileDesc *fd)
-{
-    PRInt64 result;
-    LL_I2L(result, _MD_socketavailable(fd));
-    return result;
-}  /* _MD_socketavailable64 */
-
-#define READ_FD        1
-#define WRITE_FD    2
-
-/*
- * socket_io_wait --
- *
- * wait for socket i/o, periodically checking for interrupt
- *
- * The first implementation uses select(), for platforms without
- * poll().  The second (preferred) implementation uses poll().
- */
-
-#ifndef _PR_USE_POLL
-
-static PRInt32 socket_io_wait(PRInt32 osfd, PRInt32 fd_type,
-    PRIntervalTime timeout)
-{
-    PRInt32 rv = -1;
-    struct timeval tv;
-    PRThread *me = _PR_MD_CURRENT_THREAD();
-    PRIntervalTime epoch, now, elapsed, remaining;
-    PRBool wait_for_remaining;
-    PRInt32 syserror;
-    fd_set rd_wr;
-
-    switch (timeout) {
-        case PR_INTERVAL_NO_WAIT:
-            PR_SetError(PR_IO_TIMEOUT_ERROR, 0);
-            break;
-        case PR_INTERVAL_NO_TIMEOUT:
-            /*
-             * This is a special case of the 'default' case below.
-             * Please see the comments there.
-             */
-            tv.tv_sec = _PR_INTERRUPT_CHECK_INTERVAL_SECS;
-            tv.tv_usec = 0;
-            FD_ZERO(&rd_wr);
-            do {
-                FD_SET(osfd, &rd_wr);
-                if (fd_type == READ_FD)
-                    rv = _MD_SELECT(osfd + 1, &rd_wr, NULL, NULL, &tv);
-                else
-                    rv = _MD_SELECT(osfd + 1, NULL, &rd_wr, NULL, &tv);
-                if (rv == -1 && (syserror = _MD_ERRNO()) != EINTR) {
-                    _PR_MD_MAP_SELECT_ERROR(syserror);
-                    break;
-                }
-                if (_PR_PENDING_INTERRUPT(me)) {
-                    me->flags &= ~_PR_INTERRUPT;
-                    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);
-                    rv = -1;
-                    break;
-                }
-            } while (rv == 0 || (rv == -1 && syserror == EINTR));
-            break;
-        default:
-            now = epoch = PR_IntervalNow();
-            remaining = timeout;
-            FD_ZERO(&rd_wr);
-            do {
-                /*
-                 * We block in _MD_SELECT for at most
-                 * _PR_INTERRUPT_CHECK_INTERVAL_SECS seconds,
-                 * so that there is an upper limit on the delay
-                 * before the interrupt bit is checked.
-                 */
-                wait_for_remaining = PR_TRUE;
-                tv.tv_sec = PR_IntervalToSeconds(remaining);
-                if (tv.tv_sec > _PR_INTERRUPT_CHECK_INTERVAL_SECS) {
-                    wait_for_remaining = PR_FALSE;
-                    tv.tv_sec = _PR_INTERRUPT_CHECK_INTERVAL_SECS;
-                    tv.tv_usec = 0;
-                } else {
-                    tv.tv_usec = PR_IntervalToMicroseconds(
-                        remaining -
-                        PR_SecondsToInterval(tv.tv_sec));
-                }
-                FD_SET(osfd, &rd_wr);
-                if (fd_type == READ_FD)
-                    rv = _MD_SELECT(osfd + 1, &rd_wr, NULL, NULL, &tv);
-                else
-                    rv = _MD_SELECT(osfd + 1, NULL, &rd_wr, NULL, &tv);
-                /*
-                 * we don't consider EINTR a real error
-                 */
-                if (rv == -1 && (syserror = _MD_ERRNO()) != EINTR) {
-                    _PR_MD_MAP_SELECT_ERROR(syserror);
-                    break;
-                }
-                if (_PR_PENDING_INTERRUPT(me)) {
-                    me->flags &= ~_PR_INTERRUPT;
-                    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);
-                    rv = -1;
-                    break;
-                }
-                /*
-                 * We loop again if _MD_SELECT timed out or got interrupted
-                 * by a signal, and the timeout deadline has not passed yet.
-                 */
-                if (rv == 0 || (rv == -1 && syserror == EINTR)) {
-                    /*
-                     * If _MD_SELECT timed out, we know how much time
-                     * we spent in blocking, so we can avoid a
-                     * PR_IntervalNow() call.
-                     */
-                    if (rv == 0) {
-                        if (wait_for_remaining) {
-                            now += remaining;
-                        } else {
-                            now += PR_SecondsToInterval(tv.tv_sec)
-                                + PR_MicrosecondsToInterval(tv.tv_usec);
-                        }
-                    } else {
-                        now = PR_IntervalNow();
-                    }
-                    elapsed = (PRIntervalTime) (now - epoch);
-                    if (elapsed >= timeout) {
-                        PR_SetError(PR_IO_TIMEOUT_ERROR, 0);
-                        rv = -1;
-                        break;
-                    } else {
-                        remaining = timeout - elapsed;
-                    }
-                }
-            } while (rv == 0 || (rv == -1 && syserror == EINTR));
-            break;
-    }
-    return(rv);
-}
-
-#else /* _PR_USE_POLL */
-
-static PRInt32 socket_io_wait(PRInt32 osfd, PRInt32 fd_type,
-    PRIntervalTime timeout)
-{
-    PRInt32 rv = -1;
-    int msecs;
-    PRThread *me = _PR_MD_CURRENT_THREAD();
-    PRIntervalTime epoch, now, elapsed, remaining;
-    PRBool wait_for_remaining;
-    PRInt32 syserror;
-    struct pollfd pfd;
-
-    switch (timeout) {
-        case PR_INTERVAL_NO_WAIT:
-            PR_SetError(PR_IO_TIMEOUT_ERROR, 0);
-            break;
-        case PR_INTERVAL_NO_TIMEOUT:
-            /*
-             * This is a special case of the 'default' case below.
-             * Please see the comments there.
-             */
-            msecs = _PR_INTERRUPT_CHECK_INTERVAL_SECS * 1000;
-            pfd.fd = osfd;
-            if (fd_type == READ_FD) {
-                pfd.events = POLLIN;
-            } else {
-                pfd.events = POLLOUT;
-            }
-            do {
-                rv = _MD_POLL(&pfd, 1, msecs);
-                if (rv == -1 && (syserror = _MD_ERRNO()) != EINTR) {
-                    _PR_MD_MAP_POLL_ERROR(syserror);
-                    break;
-                }
-				/*
-				 * If POLLERR is set, don't process it; retry the operation
-				 */
-                if ((rv == 1) && (pfd.revents & (POLLHUP | POLLNVAL))) {
-					rv = -1;
-                    _PR_MD_MAP_POLL_REVENTS_ERROR(pfd.revents);
-                    break;
-                }
-                if (_PR_PENDING_INTERRUPT(me)) {
-                    me->flags &= ~_PR_INTERRUPT;
-                    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);
-                    rv = -1;
-                    break;
-                }
-            } while (rv == 0 || (rv == -1 && syserror == EINTR));
-            break;
-        default:
-            now = epoch = PR_IntervalNow();
-            remaining = timeout;
-            pfd.fd = osfd;
-            if (fd_type == READ_FD) {
-                pfd.events = POLLIN;
-            } else {
-                pfd.events = POLLOUT;
-            }
-            do {
-                /*
-                 * We block in _MD_POLL for at most
-                 * _PR_INTERRUPT_CHECK_INTERVAL_SECS seconds,
-                 * so that there is an upper limit on the delay
-                 * before the interrupt bit is checked.
-                 */
-                wait_for_remaining = PR_TRUE;
-                msecs = PR_IntervalToMilliseconds(remaining);
-                if (msecs > _PR_INTERRUPT_CHECK_INTERVAL_SECS * 1000) {
-                    wait_for_remaining = PR_FALSE;
-                    msecs = _PR_INTERRUPT_CHECK_INTERVAL_SECS * 1000;
-                }
-                rv = _MD_POLL(&pfd, 1, msecs);
-                /*
-                 * we don't consider EINTR a real error
-                 */
-                if (rv == -1 && (syserror = _MD_ERRNO()) != EINTR) {
-                    _PR_MD_MAP_POLL_ERROR(syserror);
-                    break;
-                }
-                if (_PR_PENDING_INTERRUPT(me)) {
-                    me->flags &= ~_PR_INTERRUPT;
-                    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);
-                    rv = -1;
-                    break;
-                }
-				/*
-				 * If POLLERR is set, don't process it; retry the operation
-				 */
-                if ((rv == 1) && (pfd.revents & (POLLHUP | POLLNVAL))) {
-					rv = -1;
-                    _PR_MD_MAP_POLL_REVENTS_ERROR(pfd.revents);
-                    break;
-                }
-                /*
-                 * We loop again if _MD_POLL timed out or got interrupted
-                 * by a signal, and the timeout deadline has not passed yet.
-                 */
-                if (rv == 0 || (rv == -1 && syserror == EINTR)) {
-                    /*
-                     * If _MD_POLL timed out, we know how much time
-                     * we spent in blocking, so we can avoid a
-                     * PR_IntervalNow() call.
-                     */
-                    if (rv == 0) {
-                        if (wait_for_remaining) {
-                            now += remaining;
-                        } else {
-                            now += PR_MillisecondsToInterval(msecs);
-                        }
-                    } else {
-                        now = PR_IntervalNow();
-                    }
-                    elapsed = (PRIntervalTime) (now - epoch);
-                    if (elapsed >= timeout) {
-                        PR_SetError(PR_IO_TIMEOUT_ERROR, 0);
-                        rv = -1;
-                        break;
-                    } else {
-                        remaining = timeout - elapsed;
-                    }
-                }
-            } while (rv == 0 || (rv == -1 && syserror == EINTR));
-            break;
-    }
-    return(rv);
-}
-
-#endif /* _PR_USE_POLL */
-
-static PRInt32 local_io_wait(
-    PRInt32 osfd,
-    PRInt32 wait_flag,
-    PRIntervalTime timeout)
-{
-    _PRUnixPollDesc pd;
-    PRInt32 rv;
-
-    PR_LOG(_pr_io_lm, PR_LOG_MIN,
-       ("waiting to %s on osfd=%d",
-        (wait_flag == _PR_UNIX_POLL_READ) ? "read" : "write",
-        osfd));
-
-    if (timeout == PR_INTERVAL_NO_WAIT) return 0;
-
-    pd.osfd = osfd;
-    pd.in_flags = wait_flag;
-    pd.out_flags = 0;
-
-    rv = _PR_WaitForMultipleFDs(&pd, 1, timeout);
-
-    if (rv == 0) {
-        PR_SetError(PR_IO_TIMEOUT_ERROR, 0);
-        rv = -1;
-    }
-    return rv;
-}
-
-
-PRInt32 _MD_recv(PRFileDesc *fd, void *buf, PRInt32 amount,
-                                PRInt32 flags, PRIntervalTime timeout)
-{
-    PRInt32 osfd = fd->secret->md.osfd;
-    PRInt32 rv, err;
-    PRThread *me = _PR_MD_CURRENT_THREAD();
-
-/*
- * Many OS's (Solaris, Unixware) have a broken recv which won't read
- * from socketpairs.  As long as we don't use flags on socketpairs, this
- * is a decent fix. - mikep
- */
-#if defined(UNIXWARE) || defined(SOLARIS) || defined(NCR)
-    while ((rv = read(osfd,buf,amount)) == -1) {
-#else
-    while ((rv = recv(osfd,buf,amount,flags)) == -1) {
-#endif
-        err = _MD_ERRNO();
-        if ((err == EAGAIN) || (err == EWOULDBLOCK)) {
-            if (fd->secret->nonblocking) {
-                break;
-            }
-            if (!_PR_IS_NATIVE_THREAD(me)) {
-				if ((rv = local_io_wait(osfd,_PR_UNIX_POLL_READ,timeout)) < 0)
-					goto done;
-            } else {
-                if ((rv = socket_io_wait(osfd, READ_FD, timeout)) < 0)
-                    goto done;
-            }
-        } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))){
-            continue;
-        } else {
-            break;
-        }
-    }
-    if (rv < 0) {
-        _PR_MD_MAP_RECV_ERROR(err);
-    }
-done:
-    return(rv);
-}
-
-PRInt32 _MD_recvfrom(PRFileDesc *fd, void *buf, PRInt32 amount,
-                        PRIntn flags, PRNetAddr *addr, PRUint32 *addrlen,
-                        PRIntervalTime timeout)
-{
-    PRInt32 osfd = fd->secret->md.osfd;
-    PRInt32 rv, err;
-    PRThread *me = _PR_MD_CURRENT_THREAD();
-
-    while ((*addrlen = PR_NETADDR_SIZE(addr)),
-                ((rv = recvfrom(osfd, buf, amount, flags,
-                        (struct sockaddr *) addr, (_PRSockLen_t *)addrlen)) == -1)) {
-        err = _MD_ERRNO();
-        if ((err == EAGAIN) || (err == EWOULDBLOCK)) {
-            if (fd->secret->nonblocking) {
-                break;
-            }
-            if (!_PR_IS_NATIVE_THREAD(me)) {
-                if ((rv = local_io_wait(osfd, _PR_UNIX_POLL_READ, timeout)) < 0)
-                    goto done;
-            } else {
-                if ((rv = socket_io_wait(osfd, READ_FD, timeout)) < 0)
-                    goto done;
-            }
-        } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))){
-            continue;
-        } else {
-            break;
-        }
-    }
-    if (rv < 0) {
-        _PR_MD_MAP_RECVFROM_ERROR(err);
-    }
-done:
-#ifdef _PR_HAVE_SOCKADDR_LEN
-    if (rv != -1) {
-        /* ignore the sa_len field of struct sockaddr */
-        if (addr) {
-            addr->raw.family = ((struct sockaddr *) addr)->sa_family;
-        }
-    }
-#endif /* _PR_HAVE_SOCKADDR_LEN */
-    return(rv);
-}
-
-PRInt32 _MD_send(PRFileDesc *fd, const void *buf, PRInt32 amount,
-                            PRInt32 flags, PRIntervalTime timeout)
-{
-    PRInt32 osfd = fd->secret->md.osfd;
-    PRInt32 rv, err;
-    PRThread *me = _PR_MD_CURRENT_THREAD();
-#if defined(SOLARIS)
-	PRInt32 tmp_amount = amount;
-#endif
-
-    /*
-     * On pre-2.6 Solaris, send() is much slower than write().
-     * On 2.6 and beyond, with in-kernel sockets, send() and
-     * write() are fairly equivalent in performance.
-     */
-#if defined(SOLARIS)
-    PR_ASSERT(0 == flags);
-    while ((rv = write(osfd,buf,tmp_amount)) == -1) {
-#else
-    while ((rv = send(osfd,buf,amount,flags)) == -1) {
-#endif
-        err = _MD_ERRNO();
-        if ((err == EAGAIN) || (err == EWOULDBLOCK))    {
-            if (fd->secret->nonblocking) {
-                break;
-            }
-            if (!_PR_IS_NATIVE_THREAD(me)) {
-                if ((rv = local_io_wait(osfd, _PR_UNIX_POLL_WRITE, timeout)) < 0)
-                    goto done;
-            } else {
-                if ((rv = socket_io_wait(osfd, WRITE_FD, timeout))< 0)
-                    goto done;
-            }
-        } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))){
-            continue;
-        } else {
-#if defined(SOLARIS)
-			/*
-			 * The write system call has been reported to return the ERANGE
-			 * error on occasion. Try to write in smaller chunks to workaround
-			 * this bug.
-			 */
-			if (err == ERANGE) {
-				if (tmp_amount > 1) {
-					tmp_amount = tmp_amount/2;	/* half the bytes */
-					continue;
-				}
-			}
-#endif
-            break;
-        }
-    }
-        /*
-         * optimization; if bytes sent is less than "amount" call
-         * select before returning. This is because it is likely that
-         * the next send() call will return EWOULDBLOCK.
-         */
-    if ((!fd->secret->nonblocking) && (rv > 0) && (rv < amount)
-            && (timeout != PR_INTERVAL_NO_WAIT)) {
-        if (_PR_IS_NATIVE_THREAD(me)) {
-			if (socket_io_wait(osfd, WRITE_FD, timeout)< 0) {
-				rv = -1;
-				goto done;
-			}
-        } else {
-			if (local_io_wait(osfd, _PR_UNIX_POLL_WRITE, timeout) < 0) {
-				rv = -1;
-				goto done;
-			}
-        }
-    }
-    if (rv < 0) {
-        _PR_MD_MAP_SEND_ERROR(err);
-    }
-done:
-    return(rv);
-}
-
-PRInt32 _MD_sendto(
-    PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags,
-    const PRNetAddr *addr, PRUint32 addrlen, PRIntervalTime timeout)
-{
-    PRInt32 osfd = fd->secret->md.osfd;
-    PRInt32 rv, err;
-    PRThread *me = _PR_MD_CURRENT_THREAD();
-#ifdef _PR_HAVE_SOCKADDR_LEN
-    PRNetAddr addrCopy;
-
-    addrCopy = *addr;
-    ((struct sockaddr *) &addrCopy)->sa_len = addrlen;
-    ((struct sockaddr *) &addrCopy)->sa_family = addr->raw.family;
-
-    while ((rv = sendto(osfd, buf, amount, flags,
-            (struct sockaddr *) &addrCopy, addrlen)) == -1) {
-#else
-    while ((rv = sendto(osfd, buf, amount, flags,
-            (struct sockaddr *) addr, addrlen)) == -1) {
-#endif
-        err = _MD_ERRNO();
-        if ((err == EAGAIN) || (err == EWOULDBLOCK))    {
-            if (fd->secret->nonblocking) {
-                break;
-            }
-            if (!_PR_IS_NATIVE_THREAD(me)) {
-				if ((rv = local_io_wait(osfd, _PR_UNIX_POLL_WRITE, timeout)) < 0)
-					goto done;
-            } else {
-                if ((rv = socket_io_wait(osfd, WRITE_FD, timeout))< 0)
-                    goto done;
-            }
-        } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))){
-            continue;
-        } else {
-            break;
-        }
-    }
-    if (rv < 0) {
-        _PR_MD_MAP_SENDTO_ERROR(err);
-    }
-done:
-    return(rv);
-}
-
-PRInt32 _MD_writev(
-    PRFileDesc *fd, const PRIOVec *iov,
-    PRInt32 iov_size, PRIntervalTime timeout)
-{
-    PRInt32 rv, err;
-    PRThread *me = _PR_MD_CURRENT_THREAD();
-    PRInt32 index, amount = 0;
-    PRInt32 osfd = fd->secret->md.osfd;
-
-    /*
-     * Calculate the total number of bytes to be sent; needed for
-     * optimization later.
-     * We could avoid this if this number was passed in; but it is
-     * probably not a big deal because iov_size is usually small (less than
-     * 3)
-     */
-    if (!fd->secret->nonblocking) {
-        for (index=0; index<iov_size; index++) {
-            amount += iov[index].iov_len;
-        }
-    }
-
-    while ((rv = writev(osfd, (const struct iovec*)iov, iov_size)) == -1) {
-        err = _MD_ERRNO();
-        if ((err == EAGAIN) || (err == EWOULDBLOCK))    {
-            if (fd->secret->nonblocking) {
-                break;
-            }
-            if (!_PR_IS_NATIVE_THREAD(me)) {
-				if ((rv = local_io_wait(osfd, _PR_UNIX_POLL_WRITE, timeout)) < 0)
-					goto done;
-            } else {
-                if ((rv = socket_io_wait(osfd, WRITE_FD, timeout))<0)
-                    goto done;
-            }
-        } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))){
-            continue;
-        } else {
-            break;
-        }
-    }
-    /*
-     * optimization; if bytes sent is less than "amount" call
-     * select before returning. This is because it is likely that
-     * the next writev() call will return EWOULDBLOCK.
-     */
-    if ((!fd->secret->nonblocking) && (rv > 0) && (rv < amount)
-            && (timeout != PR_INTERVAL_NO_WAIT)) {
-        if (_PR_IS_NATIVE_THREAD(me)) {
-            if (socket_io_wait(osfd, WRITE_FD, timeout) < 0) {
-				rv = -1;
-                goto done;
-			}
-        } else {
-			if (local_io_wait(osfd, _PR_UNIX_POLL_WRITE, timeout) < 0) {
-				rv = -1;
-				goto done;
-			}
-        }
-    }
-    if (rv < 0) {
-        _PR_MD_MAP_WRITEV_ERROR(err);
-    }
-done:
-    return(rv);
-}
-
-PRInt32 _MD_accept(PRFileDesc *fd, PRNetAddr *addr,
-                            PRUint32 *addrlen, PRIntervalTime timeout)
-{
-    PRInt32 osfd = fd->secret->md.osfd;
-    PRInt32 rv, err;
-    PRThread *me = _PR_MD_CURRENT_THREAD();
-
-    while ((rv = accept(osfd, (struct sockaddr *) addr,
-                                        (_PRSockLen_t *)addrlen)) == -1) {
-        err = _MD_ERRNO();
-        if ((err == EAGAIN) || (err == EWOULDBLOCK) || (err == ECONNABORTED)) {
-            if (fd->secret->nonblocking) {
-                break;
-            }
-            if (!_PR_IS_NATIVE_THREAD(me)) {
-				if ((rv = local_io_wait(osfd, _PR_UNIX_POLL_READ, timeout)) < 0)
-					goto done;
-            } else {
-                if ((rv = socket_io_wait(osfd, READ_FD, timeout)) < 0)
-                    goto done;
-            }
-        } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))){
-            continue;
-        } else {
-            break;
-        }
-    }
-    if (rv < 0) {
-        _PR_MD_MAP_ACCEPT_ERROR(err);
-    }
-done:
-#ifdef _PR_HAVE_SOCKADDR_LEN
-    if (rv != -1) {
-        /* ignore the sa_len field of struct sockaddr */
-        if (addr) {
-            addr->raw.family = ((struct sockaddr *) addr)->sa_family;
-        }
-    }
-#endif /* _PR_HAVE_SOCKADDR_LEN */
-    return(rv);
-}
-
-extern int _connect (int s, const struct sockaddr *name, int namelen);
-PRInt32 _MD_connect(
-    PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen, PRIntervalTime timeout)
-{
-    PRInt32 rv, err;
-    PRThread *me = _PR_MD_CURRENT_THREAD();
-    PRInt32 osfd = fd->secret->md.osfd;
-#ifdef IRIX
-extern PRInt32 _MD_irix_connect(
-        PRInt32 osfd, const PRNetAddr *addr, PRInt32 addrlen, PRIntervalTime timeout);
-#endif
-#ifdef _PR_HAVE_SOCKADDR_LEN
-    PRNetAddr addrCopy;
-
-    addrCopy = *addr;
-    ((struct sockaddr *) &addrCopy)->sa_len = addrlen;
-    ((struct sockaddr *) &addrCopy)->sa_family = addr->raw.family;
-#endif
-
-    /*
-     * We initiate the connection setup by making a nonblocking connect()
-     * call.  If the connect() call fails, there are two cases we handle
-     * specially:
-     * 1. The connect() call was interrupted by a signal.  In this case
-     *    we simply retry connect().
-     * 2. The NSPR socket is nonblocking and connect() fails with
-     *    EINPROGRESS.  We first wait until the socket becomes writable.
-     *    Then we try to find out whether the connection setup succeeded
-     *    or failed.
-     */
-
-retry:
-#ifdef IRIX
-    if ((rv = _MD_irix_connect(osfd, addr, addrlen, timeout)) == -1) {
-#else
-#ifdef _PR_HAVE_SOCKADDR_LEN
-    if ((rv = connect(osfd, (struct sockaddr *)&addrCopy, addrlen)) == -1) {
-#else
-    if ((rv = connect(osfd, (struct sockaddr *)addr, addrlen)) == -1) {
-#endif
-#endif
-        err = _MD_ERRNO();
-
-        if (err == EINTR) {
-            if (_PR_PENDING_INTERRUPT(me)) {
-                me->flags &= ~_PR_INTERRUPT;
-                PR_SetError( PR_PENDING_INTERRUPT_ERROR, 0);
-                return -1;
-            }
-            goto retry;
-        }
-
-        if (!fd->secret->nonblocking && (err == EINPROGRESS)) {
-            if (!_PR_IS_NATIVE_THREAD(me)) {
-
-				if ((rv = local_io_wait(osfd, _PR_UNIX_POLL_WRITE, timeout)) < 0)
-                    return -1;
-            } else {
-                /*
-                 * socket_io_wait() may return -1 or 1.
-                 */
-
-                rv = socket_io_wait(osfd, WRITE_FD, timeout);
-                if (rv == -1) {
-                    return -1;
-                }
-            }
-
-            PR_ASSERT(rv == 1);
-            if (_PR_PENDING_INTERRUPT(me)) {
-                me->flags &= ~_PR_INTERRUPT;
-                PR_SetError( PR_PENDING_INTERRUPT_ERROR, 0);
-                return -1;
-            }
-            err = _MD_unix_get_nonblocking_connect_error(osfd);
-            if (err != 0) {
-                _PR_MD_MAP_CONNECT_ERROR(err);
-                return -1;
-            }
-            return 0;
-        }
-
-        _PR_MD_MAP_CONNECT_ERROR(err);
-    }
-
-    return rv;
-}  /* _MD_connect */
-
-PRInt32 _MD_bind(PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen)
-{
-    PRInt32 rv, err;
-#ifdef _PR_HAVE_SOCKADDR_LEN
-    PRNetAddr addrCopy;
-
-    addrCopy = *addr;
-    ((struct sockaddr *) &addrCopy)->sa_len = addrlen;
-    ((struct sockaddr *) &addrCopy)->sa_family = addr->raw.family;
-    rv = bind(fd->secret->md.osfd, (struct sockaddr *) &addrCopy, (int )addrlen);
-#else
-    rv = bind(fd->secret->md.osfd, (struct sockaddr *) addr, (int )addrlen);
-#endif
-    if (rv < 0) {
-        err = _MD_ERRNO();
-        _PR_MD_MAP_BIND_ERROR(err);
-    }
-    return(rv);
-}
-
-PRInt32 _MD_listen(PRFileDesc *fd, PRIntn backlog)
-{
-    PRInt32 rv, err;
-
-    rv = listen(fd->secret->md.osfd, backlog);
-    if (rv < 0) {
-        err = _MD_ERRNO();
-        _PR_MD_MAP_LISTEN_ERROR(err);
-    }
-    return(rv);
-}
-
-PRInt32 _MD_shutdown(PRFileDesc *fd, PRIntn how)
-{
-    PRInt32 rv, err;
-
-    rv = shutdown(fd->secret->md.osfd, how);
-    if (rv < 0) {
-        err = _MD_ERRNO();
-        _PR_MD_MAP_SHUTDOWN_ERROR(err);
-    }
-    return(rv);
-}
-
-PRInt32 _MD_socketpair(int af, int type, int flags,
-                                                        PRInt32 *osfd)
-{
-    PRInt32 rv, err;
-
-    rv = socketpair(af, type, flags, osfd);
-    if (rv < 0) {
-        err = _MD_ERRNO();
-        _PR_MD_MAP_SOCKETPAIR_ERROR(err);
-    }
-    return rv;
-}
-
-PRStatus _MD_getsockname(PRFileDesc *fd, PRNetAddr *addr,
-                                                PRUint32 *addrlen)
-{
-    PRInt32 rv, err;
-
-    rv = getsockname(fd->secret->md.osfd,
-            (struct sockaddr *) addr, (_PRSockLen_t *)addrlen);
-#ifdef _PR_HAVE_SOCKADDR_LEN
-    if (rv == 0) {
-        /* ignore the sa_len field of struct sockaddr */
-        if (addr) {
-            addr->raw.family = ((struct sockaddr *) addr)->sa_family;
-        }
-    }
-#endif /* _PR_HAVE_SOCKADDR_LEN */
-    if (rv < 0) {
-        err = _MD_ERRNO();
-        _PR_MD_MAP_GETSOCKNAME_ERROR(err);
-    }
-    return rv==0?PR_SUCCESS:PR_FAILURE;
-}
-
-PRStatus _MD_getpeername(PRFileDesc *fd, PRNetAddr *addr,
-                                        PRUint32 *addrlen)
-{
-    PRInt32 rv, err;
-
-    rv = getpeername(fd->secret->md.osfd,
-            (struct sockaddr *) addr, (_PRSockLen_t *)addrlen);
-#ifdef _PR_HAVE_SOCKADDR_LEN
-    if (rv == 0) {
-        /* ignore the sa_len field of struct sockaddr */
-        if (addr) {
-            addr->raw.family = ((struct sockaddr *) addr)->sa_family;
-        }
-    }
-#endif /* _PR_HAVE_SOCKADDR_LEN */
-    if (rv < 0) {
-        err = _MD_ERRNO();
-        _PR_MD_MAP_GETPEERNAME_ERROR(err);
-    }
-    return rv==0?PR_SUCCESS:PR_FAILURE;
-}
-
-PRStatus _MD_getsockopt(PRFileDesc *fd, PRInt32 level,
-                        PRInt32 optname, char* optval, PRInt32* optlen)
-{
-    PRInt32 rv, err;
-
-    rv = getsockopt(fd->secret->md.osfd, level, optname, optval, (_PRSockLen_t *)optlen);
-    if (rv < 0) {
-        err = _MD_ERRNO();
-        _PR_MD_MAP_GETSOCKOPT_ERROR(err);
-    }
-    return rv==0?PR_SUCCESS:PR_FAILURE;
-}
-
-PRStatus _MD_setsockopt(PRFileDesc *fd, PRInt32 level,   
-                    PRInt32 optname, const char* optval, PRInt32 optlen)
-{
-    PRInt32 rv, err;
-
-    rv = setsockopt(fd->secret->md.osfd, level, optname, optval, optlen);
-    if (rv < 0) {
-        err = _MD_ERRNO();
-        _PR_MD_MAP_SETSOCKOPT_ERROR(err);
-    }
-    return rv==0?PR_SUCCESS:PR_FAILURE;
-}
-
-PRStatus _MD_set_fd_inheritable(PRFileDesc *fd, PRBool inheritable)
-{
-    int rv;
-
-    rv = fcntl(fd->secret->md.osfd, F_SETFD, inheritable ? 0 : FD_CLOEXEC);
-    if (-1 == rv) {
-        PR_SetError(PR_UNKNOWN_ERROR, _MD_ERRNO());
-        return PR_FAILURE;
-    }
-    return PR_SUCCESS;
-}
-
-void _MD_init_fd_inheritable(PRFileDesc *fd, PRBool imported)
-{
-    if (imported) {
-        fd->secret->inheritable = _PR_TRI_UNKNOWN;
-    } else {
-        /* By default, a Unix fd is not closed on exec. */
-#ifdef DEBUG
-        {
-            int flags = fcntl(fd->secret->md.osfd, F_GETFD, 0);
-            PR_ASSERT(0 == flags);
-        }
-#endif
-        fd->secret->inheritable = _PR_TRI_TRUE;
-    }
-}
-
-/************************************************************************/
-#if !defined(_PR_USE_POLL)
-
-/*
-** Scan through io queue and find any bad fd's that triggered the error
-** from _MD_SELECT
-*/
-static void FindBadFDs(void)
-{
-    PRCList *q;
-    PRThread *me = _MD_CURRENT_THREAD();
-
-    PR_ASSERT(!_PR_IS_NATIVE_THREAD(me));
-    q = (_PR_IOQ(me->cpu)).next;
-    _PR_IOQ_MAX_OSFD(me->cpu) = -1;
-    _PR_IOQ_TIMEOUT(me->cpu) = PR_INTERVAL_NO_TIMEOUT;
-    while (q != &_PR_IOQ(me->cpu)) {
-        PRPollQueue *pq = _PR_POLLQUEUE_PTR(q);
-        PRBool notify = PR_FALSE;
-        _PRUnixPollDesc *pds = pq->pds;
-        _PRUnixPollDesc *epds = pds + pq->npds;
-        PRInt32 pq_max_osfd = -1;
-
-        q = q->next;
-        for (; pds < epds; pds++) {
-            PRInt32 osfd = pds->osfd;
-            pds->out_flags = 0;
-            PR_ASSERT(osfd >= 0 || pds->in_flags == 0);
-            if (pds->in_flags == 0) {
-                continue;  /* skip this fd */
-            }
-            if (fcntl(osfd, F_GETFL, 0) == -1) {
-                /* Found a bad descriptor, remove it from the fd_sets. */
-                PR_LOG(_pr_io_lm, PR_LOG_MAX,
-                    ("file descriptor %d is bad", osfd));
-                pds->out_flags = _PR_UNIX_POLL_NVAL;
-                notify = PR_TRUE;
-            }
-            if (osfd > pq_max_osfd) {
-                pq_max_osfd = osfd;
-            }
-        }
-
-        if (notify) {
-            PRIntn pri;
-            PR_REMOVE_LINK(&pq->links);
-            pq->on_ioq = PR_FALSE;
-
-            /*
-         * Decrement the count of descriptors for each desciptor/event
-         * because this I/O request is being removed from the
-         * ioq
-         */
-            pds = pq->pds;
-            for (; pds < epds; pds++) {
-                PRInt32 osfd = pds->osfd;
-                PRInt16 in_flags = pds->in_flags;
-                PR_ASSERT(osfd >= 0 || in_flags == 0);
-                if (in_flags & _PR_UNIX_POLL_READ) {
-                    if (--(_PR_FD_READ_CNT(me->cpu))[osfd] == 0)
-                        FD_CLR(osfd, &_PR_FD_READ_SET(me->cpu));
-                }
-                if (in_flags & _PR_UNIX_POLL_WRITE) {
-                    if (--(_PR_FD_WRITE_CNT(me->cpu))[osfd] == 0)
-                        FD_CLR(osfd, &_PR_FD_WRITE_SET(me->cpu));
-                }
-                if (in_flags & _PR_UNIX_POLL_EXCEPT) {
-                    if (--(_PR_FD_EXCEPTION_CNT(me->cpu))[osfd] == 0)
-                        FD_CLR(osfd, &_PR_FD_EXCEPTION_SET(me->cpu));
-                }
-            }
-
-            _PR_THREAD_LOCK(pq->thr);
-            if (pq->thr->flags & (_PR_ON_PAUSEQ|_PR_ON_SLEEPQ)) {
-                _PRCPU *cpu = pq->thr->cpu;
-                _PR_SLEEPQ_LOCK(pq->thr->cpu);
-                _PR_DEL_SLEEPQ(pq->thr, PR_TRUE);
-                _PR_SLEEPQ_UNLOCK(pq->thr->cpu);
-
-				if (pq->thr->flags & _PR_SUSPENDING) {
-				    /*
-				     * set thread state to SUSPENDED;
-				     * a Resume operation on the thread
-				     * will move it to the runQ
-				     */
-				    pq->thr->state = _PR_SUSPENDED;
-				    _PR_MISCQ_LOCK(pq->thr->cpu);
-				    _PR_ADD_SUSPENDQ(pq->thr, pq->thr->cpu);
-				    _PR_MISCQ_UNLOCK(pq->thr->cpu);
-				} else {
-				    pri = pq->thr->priority;
-				    pq->thr->state = _PR_RUNNABLE;
-
-				    _PR_RUNQ_LOCK(cpu);
-				    _PR_ADD_RUNQ(pq->thr, cpu, pri);
-				    _PR_RUNQ_UNLOCK(cpu);
-				}
-            }
-            _PR_THREAD_UNLOCK(pq->thr);
-        } else {
-            if (pq->timeout < _PR_IOQ_TIMEOUT(me->cpu))
-                _PR_IOQ_TIMEOUT(me->cpu) = pq->timeout;
-            if (_PR_IOQ_MAX_OSFD(me->cpu) < pq_max_osfd)
-                _PR_IOQ_MAX_OSFD(me->cpu) = pq_max_osfd;
-        }
-    }
-    if (_PR_IS_NATIVE_THREAD_SUPPORTED()) {
-        if (_PR_IOQ_MAX_OSFD(me->cpu) < _pr_md_pipefd[0])
-            _PR_IOQ_MAX_OSFD(me->cpu) = _pr_md_pipefd[0];
-    }
-}
-#endif  /* !defined(_PR_USE_POLL) */
-
-/************************************************************************/
-
-/*
-** Called by the scheduler when there is nothing to do. This means that
-** all threads are blocked on some monitor somewhere.
-**
-** Note: this code doesn't release the scheduler lock.
-*/
-/*
-** Pause the current CPU. longjmp to the cpu's pause stack
-**
-** This must be called with the scheduler locked
-*/
-void _MD_PauseCPU(PRIntervalTime ticks)
-{
-    PRThread *me = _MD_CURRENT_THREAD();
-#ifdef _PR_USE_POLL
-    int timeout;
-    struct pollfd *pollfds;    /* an array of pollfd structures */
-    struct pollfd *pollfdPtr;    /* a pointer that steps through the array */
-    unsigned long npollfds;     /* number of pollfd structures in array */
-    unsigned long pollfds_size;
-    int nfd;                    /* to hold the return value of poll() */
-#else
-    struct timeval timeout, *tvp;
-    fd_set r, w, e;
-    fd_set *rp, *wp, *ep;
-    PRInt32 max_osfd, nfd;
-#endif  /* _PR_USE_POLL */
-    PRInt32 rv;
-    PRCList *q;
-    PRUint32 min_timeout;
-    sigset_t oldset;
-#ifdef IRIX
-extern sigset_t ints_off;
-#endif
-
-    PR_ASSERT(_PR_MD_GET_INTSOFF() != 0);
-
-    _PR_MD_IOQ_LOCK();
-
-#ifdef _PR_USE_POLL
-    /* Build up the pollfd structure array to wait on */
-
-    /* Find out how many pollfd structures are needed */
-    npollfds = _PR_IOQ_OSFD_CNT(me->cpu);
-    PR_ASSERT(npollfds >= 0);
-
-    /*
-     * We use a pipe to wake up a native thread.  An fd is needed
-     * for the pipe and we poll it for reading.
-     */
-    if (_PR_IS_NATIVE_THREAD_SUPPORTED()) {
-        npollfds++;
-#ifdef	IRIX
-		/*
-		 * On Irix, a second pipe is used to cause the primordial cpu to
-		 * wakeup and exit, when the process is exiting because of a call
-		 * to exit/PR_ProcessExit.
-		 */
-		if (me->cpu->id == 0) {
-        	npollfds++;
-		}
-#endif
-	}
-
-    /*
-     * if the cpu's pollfd array is not big enough, release it and allocate a new one
-     */
-    if (npollfds > _PR_IOQ_POLLFDS_SIZE(me->cpu)) {
-        if (_PR_IOQ_POLLFDS(me->cpu) != NULL)
-            PR_DELETE(_PR_IOQ_POLLFDS(me->cpu));
-        pollfds_size =  PR_MAX(_PR_IOQ_MIN_POLLFDS_SIZE(me->cpu), npollfds);
-        pollfds = (struct pollfd *) PR_MALLOC(pollfds_size * sizeof(struct pollfd));
-        _PR_IOQ_POLLFDS(me->cpu) = pollfds;
-        _PR_IOQ_POLLFDS_SIZE(me->cpu) = pollfds_size;
-    } else {
-        pollfds = _PR_IOQ_POLLFDS(me->cpu);
-    }
-    pollfdPtr = pollfds;
-
-    /*
-     * If we need to poll the pipe for waking up a native thread,
-     * the pipe's fd is the first element in the pollfds array.
-     */
-    if (_PR_IS_NATIVE_THREAD_SUPPORTED()) {
-        pollfdPtr->fd = _pr_md_pipefd[0];
-        pollfdPtr->events = POLLIN;
-        pollfdPtr++;
-#ifdef	IRIX
-		/*
-		 * On Irix, the second element is the exit pipe
-		 */
-		if (me->cpu->id == 0) {
-			pollfdPtr->fd = _pr_irix_primoridal_cpu_fd[0];
-			pollfdPtr->events = POLLIN;
-			pollfdPtr++;
-		}
-#endif
-    }
-
-    min_timeout = PR_INTERVAL_NO_TIMEOUT;
-    for (q = _PR_IOQ(me->cpu).next; q != &_PR_IOQ(me->cpu); q = q->next) {
-        PRPollQueue *pq = _PR_POLLQUEUE_PTR(q);
-        _PRUnixPollDesc *pds = pq->pds;
-        _PRUnixPollDesc *epds = pds + pq->npds;
-
-        if (pq->timeout < min_timeout) {
-            min_timeout = pq->timeout;
-        }
-        for (; pds < epds; pds++, pollfdPtr++) {
-            /*
-         * Assert that the pollfdPtr pointer does not go
-         * beyond the end of the pollfds array
-         */
-            PR_ASSERT(pollfdPtr < pollfds + npollfds);
-            pollfdPtr->fd = pds->osfd;
-            /* direct copy of poll flags */
-            pollfdPtr->events = pds->in_flags;
-        }
-    }
-    _PR_IOQ_TIMEOUT(me->cpu) = min_timeout;
-#else
-    /*
-     * assigment of fd_sets
-     */
-    r = _PR_FD_READ_SET(me->cpu);
-    w = _PR_FD_WRITE_SET(me->cpu);
-    e = _PR_FD_EXCEPTION_SET(me->cpu);
-
-    rp = &r;
-    wp = &w;
-    ep = &e;
-
-    max_osfd = _PR_IOQ_MAX_OSFD(me->cpu) + 1;
-    min_timeout = _PR_IOQ_TIMEOUT(me->cpu);
-#endif  /* _PR_USE_POLL */
-    /*
-    ** Compute the minimum timeout value: make it the smaller of the
-    ** timeouts specified by the i/o pollers or the timeout of the first
-    ** sleeping thread.
-    */
-    q = _PR_SLEEPQ(me->cpu).next;
-
-    if (q != &_PR_SLEEPQ(me->cpu)) {
-        PRThread *t = _PR_THREAD_PTR(q);
-
-        if (t->sleep < min_timeout) {
-            min_timeout = t->sleep;
-        }
-    }
-    if (min_timeout > ticks) {
-        min_timeout = ticks;
-    }
-
-#ifdef _PR_USE_POLL
-    if (min_timeout == PR_INTERVAL_NO_TIMEOUT)
-        timeout = -1;
-    else
-        timeout = PR_IntervalToMilliseconds(min_timeout);
-#else
-    if (min_timeout == PR_INTERVAL_NO_TIMEOUT) {
-        tvp = NULL;
-    } else {
-        timeout.tv_sec = PR_IntervalToSeconds(min_timeout);
-        timeout.tv_usec = PR_IntervalToMicroseconds(min_timeout)
-            % PR_USEC_PER_SEC;
-        tvp = &timeout;
-    }
-#endif  /* _PR_USE_POLL */
-
-    _PR_MD_IOQ_UNLOCK();
-    _MD_CHECK_FOR_EXIT();
-    /*
-     * check for i/o operations
-     */
-#ifndef _PR_NO_CLOCK_TIMER
-    /*
-     * Disable the clock interrupts while we are in select, if clock interrupts
-     * are enabled. Otherwise, when the select/poll calls are interrupted, the
-     * timer value starts ticking from zero again when the system call is restarted.
-     */
-#ifdef IRIX
-    /*
-     * SIGCHLD signal is used on Irix to detect he termination of an
-     * sproc by SIGSEGV, SIGBUS or SIGABRT signals when
-     * _nspr_terminate_on_error is set.
-     */
-    if ((!_nspr_noclock) || (_nspr_terminate_on_error))
-#else
-        if (!_nspr_noclock)
-#endif    /* IRIX */
-#ifdef IRIX
-    sigprocmask(SIG_BLOCK, &ints_off, &oldset);
-#else
-    PR_ASSERT(sigismember(&timer_set, SIGALRM));
-    sigprocmask(SIG_BLOCK, &timer_set, &oldset);
-#endif    /* IRIX */
-#endif  /* !_PR_NO_CLOCK_TIMER */
-
-#ifndef _PR_USE_POLL
-    PR_ASSERT(FD_ISSET(_pr_md_pipefd[0],rp));
-    nfd = _MD_SELECT(max_osfd, rp, wp, ep, tvp);
-#else
-    nfd = _MD_POLL(pollfds, npollfds, timeout);
-#endif  /* !_PR_USE_POLL */
-
-#ifndef _PR_NO_CLOCK_TIMER
-#ifdef IRIX
-    if ((!_nspr_noclock) || (_nspr_terminate_on_error))
-#else
-        if (!_nspr_noclock)
-#endif    /* IRIX */
-    sigprocmask(SIG_SETMASK, &oldset, 0);
-#endif  /* !_PR_NO_CLOCK_TIMER */
-
-    _MD_CHECK_FOR_EXIT();
-
-#ifdef IRIX
-	_PR_MD_primordial_cpu();
-#endif
-
-    _PR_MD_IOQ_LOCK();
-    /*
-    ** Notify monitors that are associated with the selected descriptors.
-    */
-#ifdef _PR_USE_POLL
-    if (nfd > 0) {
-        pollfdPtr = pollfds;
-        if (_PR_IS_NATIVE_THREAD_SUPPORTED()) {
-            /*
-			 * Assert that the pipe is the first element in the
-			 * pollfds array.
-			 */
-            PR_ASSERT(pollfds[0].fd == _pr_md_pipefd[0]);
-            if ((pollfds[0].revents & POLLIN) && (nfd == 1)) {
-                /*
-				 * woken up by another thread; read all the data
-				 * in the pipe to empty the pipe
-				 */
-                while ((rv = read(_pr_md_pipefd[0], _pr_md_pipebuf,
-                    PIPE_BUF)) == PIPE_BUF){
-                }
-                PR_ASSERT((rv > 0) || ((rv == -1) && (errno == EAGAIN)));
-            }
-            pollfdPtr++;
-#ifdef	IRIX
-			/*
-			 * On Irix, check to see if the primordial cpu needs to exit
-			 * to cause the process to terminate
-			 */
-			if (me->cpu->id == 0) {
-            	PR_ASSERT(pollfds[1].fd == _pr_irix_primoridal_cpu_fd[0]);
-				if (pollfdPtr->revents & POLLIN) {
-					if (_pr_irix_process_exit) {
-						/*
-						 * process exit due to a call to PR_ProcessExit
-						 */
-						prctl(PR_SETEXITSIG, SIGKILL);
-						_exit(_pr_irix_process_exit_code);
-					} else {
-						while ((rv = read(_pr_irix_primoridal_cpu_fd[0],
-							_pr_md_pipebuf, PIPE_BUF)) == PIPE_BUF) {
-						}
-						PR_ASSERT(rv > 0);
-					}
-				}
-				pollfdPtr++;
-			}
-#endif
-        }
-        for (q = _PR_IOQ(me->cpu).next; q != &_PR_IOQ(me->cpu); q = q->next) {
-            PRPollQueue *pq = _PR_POLLQUEUE_PTR(q);
-            PRBool notify = PR_FALSE;
-            _PRUnixPollDesc *pds = pq->pds;
-            _PRUnixPollDesc *epds = pds + pq->npds;
-
-            for (; pds < epds; pds++, pollfdPtr++) {
-                /*
-                  * Assert that the pollfdPtr pointer does not go beyond
-                  * the end of the pollfds array.
-                  */
-                PR_ASSERT(pollfdPtr < pollfds + npollfds);
-                /*
-                 * Assert that the fd's in the pollfds array (stepped
-                 * through by pollfdPtr) are in the same order as
-                 * the fd's in _PR_IOQ() (stepped through by q and pds).
-                 * This is how the pollfds array was created earlier.
-                 */
-                PR_ASSERT(pollfdPtr->fd == pds->osfd);
-                pds->out_flags = pollfdPtr->revents;
-                /* Negative fd's are ignored by poll() */
-                if (pds->osfd >= 0 && pds->out_flags) {
-                    notify = PR_TRUE;
-                }
-            }
-            if (notify) {
-                PRIntn pri;
-                PRThread *thred;
-
-                PR_REMOVE_LINK(&pq->links);
-                pq->on_ioq = PR_FALSE;
-
-                thred = pq->thr;
-                _PR_THREAD_LOCK(thred);
-                if (pq->thr->flags & (_PR_ON_PAUSEQ|_PR_ON_SLEEPQ)) {
-                    _PRCPU *cpu = pq->thr->cpu;
-                    _PR_SLEEPQ_LOCK(pq->thr->cpu);
-                    _PR_DEL_SLEEPQ(pq->thr, PR_TRUE);
-                    _PR_SLEEPQ_UNLOCK(pq->thr->cpu);
-
-					if (pq->thr->flags & _PR_SUSPENDING) {
-					    /*
-					     * set thread state to SUSPENDED;
-					     * a Resume operation on the thread
-					     * will move it to the runQ
-					     */
-					    pq->thr->state = _PR_SUSPENDED;
-					    _PR_MISCQ_LOCK(pq->thr->cpu);
-					    _PR_ADD_SUSPENDQ(pq->thr, pq->thr->cpu);
-					    _PR_MISCQ_UNLOCK(pq->thr->cpu);
-					} else {
-						pri = pq->thr->priority;
-						pq->thr->state = _PR_RUNNABLE;
-
-						_PR_RUNQ_LOCK(cpu);
-						_PR_ADD_RUNQ(pq->thr, cpu, pri);
-						_PR_RUNQ_UNLOCK(cpu);
-						if (_pr_md_idle_cpus > 1)
-							_PR_MD_WAKEUP_WAITER(thred);
-					}
-                }
-                _PR_THREAD_UNLOCK(thred);
-                _PR_IOQ_OSFD_CNT(me->cpu) -= pq->npds;
-                PR_ASSERT(_PR_IOQ_OSFD_CNT(me->cpu) >= 0);
-            }
-        }
-    } else if (nfd == -1) {
-        PR_LOG(_pr_io_lm, PR_LOG_MAX, ("poll() failed with errno %d", errno));
-    }
-
-#else
-    if (nfd > 0) {
-        q = _PR_IOQ(me->cpu).next;
-        _PR_IOQ_MAX_OSFD(me->cpu) = -1;
-        _PR_IOQ_TIMEOUT(me->cpu) = PR_INTERVAL_NO_TIMEOUT;
-        while (q != &_PR_IOQ(me->cpu)) {
-            PRPollQueue *pq = _PR_POLLQUEUE_PTR(q);
-            PRBool notify = PR_FALSE;
-            _PRUnixPollDesc *pds = pq->pds;
-            _PRUnixPollDesc *epds = pds + pq->npds;
-            PRInt32 pq_max_osfd = -1;
-
-            q = q->next;
-            for (; pds < epds; pds++) {
-                PRInt32 osfd = pds->osfd;
-                PRInt16 in_flags = pds->in_flags;
-                PRInt16 out_flags = 0;
-                PR_ASSERT(osfd >= 0 || in_flags == 0);
-                if ((in_flags & _PR_UNIX_POLL_READ) && FD_ISSET(osfd, rp)) {
-                    out_flags |= _PR_UNIX_POLL_READ;
-                }
-                if ((in_flags & _PR_UNIX_POLL_WRITE) && FD_ISSET(osfd, wp)) {
-                    out_flags |= _PR_UNIX_POLL_WRITE;
-                }
-                if ((in_flags & _PR_UNIX_POLL_EXCEPT) && FD_ISSET(osfd, ep)) {
-                    out_flags |= _PR_UNIX_POLL_EXCEPT;
-                }
-                pds->out_flags = out_flags;
-                if (out_flags) {
-                    notify = PR_TRUE;
-                }
-                if (osfd > pq_max_osfd) {
-                    pq_max_osfd = osfd;
-                }
-            }
-            if (notify == PR_TRUE) {
-                PRIntn pri;
-                PRThread *thred;
-
-                PR_REMOVE_LINK(&pq->links);
-                pq->on_ioq = PR_FALSE;
-
-                /*
-                 * Decrement the count of descriptors for each desciptor/event
-                 * because this I/O request is being removed from the
-                 * ioq
-                 */
-                pds = pq->pds;
-                for (; pds < epds; pds++) {
-                    PRInt32 osfd = pds->osfd;
-                    PRInt16 in_flags = pds->in_flags;
-                    PR_ASSERT(osfd >= 0 || in_flags == 0);
-                    if (in_flags & _PR_UNIX_POLL_READ) {
-                        if (--(_PR_FD_READ_CNT(me->cpu))[osfd] == 0)
-                            FD_CLR(osfd, &_PR_FD_READ_SET(me->cpu));
-                    }
-                    if (in_flags & _PR_UNIX_POLL_WRITE) {
-                        if (--(_PR_FD_WRITE_CNT(me->cpu))[osfd] == 0)
-                            FD_CLR(osfd, &_PR_FD_WRITE_SET(me->cpu));
-                    }
-                    if (in_flags & _PR_UNIX_POLL_EXCEPT) {
-                        if (--(_PR_FD_EXCEPTION_CNT(me->cpu))[osfd] == 0)
-                            FD_CLR(osfd, &_PR_FD_EXCEPTION_SET(me->cpu));
-                    }
-                }
-
-                /*
-                 * Because this thread can run on a different cpu right
-                 * after being added to the run queue, do not dereference
-                 * pq
-                 */
-                 thred = pq->thr;
-                _PR_THREAD_LOCK(thred);
-                if (pq->thr->flags & (_PR_ON_PAUSEQ|_PR_ON_SLEEPQ)) {
-                    _PRCPU *cpu = thred->cpu;
-                    _PR_SLEEPQ_LOCK(pq->thr->cpu);
-                    _PR_DEL_SLEEPQ(pq->thr, PR_TRUE);
-                    _PR_SLEEPQ_UNLOCK(pq->thr->cpu);
-
-					if (pq->thr->flags & _PR_SUSPENDING) {
-					    /*
-					     * set thread state to SUSPENDED;
-					     * a Resume operation on the thread
-					     * will move it to the runQ
-					     */
-					    pq->thr->state = _PR_SUSPENDED;
-					    _PR_MISCQ_LOCK(pq->thr->cpu);
-					    _PR_ADD_SUSPENDQ(pq->thr, pq->thr->cpu);
-					    _PR_MISCQ_UNLOCK(pq->thr->cpu);
-					} else {
-						pri = pq->thr->priority;
-						pq->thr->state = _PR_RUNNABLE;
-
-						pq->thr->cpu = cpu;
-						_PR_RUNQ_LOCK(cpu);
-						_PR_ADD_RUNQ(pq->thr, cpu, pri);
-						_PR_RUNQ_UNLOCK(cpu);
-						if (_pr_md_idle_cpus > 1)
-							_PR_MD_WAKEUP_WAITER(thred);
-					}
-                }
-                _PR_THREAD_UNLOCK(thred);
-            } else {
-                if (pq->timeout < _PR_IOQ_TIMEOUT(me->cpu))
-                    _PR_IOQ_TIMEOUT(me->cpu) = pq->timeout;
-                if (_PR_IOQ_MAX_OSFD(me->cpu) < pq_max_osfd)
-                    _PR_IOQ_MAX_OSFD(me->cpu) = pq_max_osfd;
-            }
-        }
-        if (_PR_IS_NATIVE_THREAD_SUPPORTED()) {
-            if ((FD_ISSET(_pr_md_pipefd[0], rp)) && (nfd == 1)) {
-                /*
-             * woken up by another thread; read all the data
-             * in the pipe to empty the pipe
-             */
-                while ((rv =
-                    read(_pr_md_pipefd[0], _pr_md_pipebuf, PIPE_BUF))
-                    == PIPE_BUF){
-                }
-                PR_ASSERT((rv > 0) ||
-                    ((rv == -1) && (errno == EAGAIN)));
-            }
-            if (_PR_IOQ_MAX_OSFD(me->cpu) < _pr_md_pipefd[0])
-                _PR_IOQ_MAX_OSFD(me->cpu) = _pr_md_pipefd[0];
-#ifdef	IRIX
-			if ((me->cpu->id == 0) && 
-						(FD_ISSET(_pr_irix_primoridal_cpu_fd[0], rp))) {
-				if (_pr_irix_process_exit) {
-					/*
-					 * process exit due to a call to PR_ProcessExit
-					 */
-					prctl(PR_SETEXITSIG, SIGKILL);
-					_exit(_pr_irix_process_exit_code);
-				} else {
-						while ((rv = read(_pr_irix_primoridal_cpu_fd[0],
-							_pr_md_pipebuf, PIPE_BUF)) == PIPE_BUF) {
-						}
-						PR_ASSERT(rv > 0);
-				}
-			}
-			if (me->cpu->id == 0) {
-				if (_PR_IOQ_MAX_OSFD(me->cpu) < _pr_irix_primoridal_cpu_fd[0])
-					_PR_IOQ_MAX_OSFD(me->cpu) = _pr_irix_primoridal_cpu_fd[0];
-			}
-#endif
-        }
-    } else if (nfd < 0) {
-        if (errno == EBADF) {
-            FindBadFDs();
-        } else {
-            PR_LOG(_pr_io_lm, PR_LOG_MAX, ("select() failed with errno %d",
-                errno));
-        }
-    } else {
-        PR_ASSERT(nfd == 0);
-        /*
-         * compute the new value of _PR_IOQ_TIMEOUT
-         */
-        q = _PR_IOQ(me->cpu).next;
-        _PR_IOQ_MAX_OSFD(me->cpu) = -1;
-        _PR_IOQ_TIMEOUT(me->cpu) = PR_INTERVAL_NO_TIMEOUT;
-        while (q != &_PR_IOQ(me->cpu)) {
-            PRPollQueue *pq = _PR_POLLQUEUE_PTR(q);
-            _PRUnixPollDesc *pds = pq->pds;
-            _PRUnixPollDesc *epds = pds + pq->npds;
-            PRInt32 pq_max_osfd = -1;
-
-            q = q->next;
-            for (; pds < epds; pds++) {
-                if (pds->osfd > pq_max_osfd) {
-                    pq_max_osfd = pds->osfd;
-                }
-            }
-            if (pq->timeout < _PR_IOQ_TIMEOUT(me->cpu))
-                _PR_IOQ_TIMEOUT(me->cpu) = pq->timeout;
-            if (_PR_IOQ_MAX_OSFD(me->cpu) < pq_max_osfd)
-                _PR_IOQ_MAX_OSFD(me->cpu) = pq_max_osfd;
-        }
-        if (_PR_IS_NATIVE_THREAD_SUPPORTED()) {
-            if (_PR_IOQ_MAX_OSFD(me->cpu) < _pr_md_pipefd[0])
-                _PR_IOQ_MAX_OSFD(me->cpu) = _pr_md_pipefd[0];
-        }
-    }
-#endif  /* _PR_USE_POLL */
-    _PR_MD_IOQ_UNLOCK();
-}
-
-void _MD_Wakeup_CPUs()
-{
-    PRInt32 rv, data;
-
-    data = 0;
-    rv = write(_pr_md_pipefd[1], &data, 1);
-
-    while ((rv < 0) && (errno == EAGAIN)) {
-        /*
-         * pipe full, read all data in pipe to empty it
-         */
-        while ((rv =
-            read(_pr_md_pipefd[0], _pr_md_pipebuf, PIPE_BUF))
-            == PIPE_BUF) {
-        }
-        PR_ASSERT((rv > 0) ||
-            ((rv == -1) && (errno == EAGAIN)));
-        rv = write(_pr_md_pipefd[1], &data, 1);
-    }
-}
-
-
-void _MD_InitCPUS()
-{
-    PRInt32 rv, flags;
-    PRThread *me = _MD_CURRENT_THREAD();
-
-    rv = pipe(_pr_md_pipefd);
-    PR_ASSERT(rv == 0);
-    _PR_IOQ_MAX_OSFD(me->cpu) = _pr_md_pipefd[0];
-#ifndef _PR_USE_POLL
-    FD_SET(_pr_md_pipefd[0], &_PR_FD_READ_SET(me->cpu));
-#endif
-
-    flags = fcntl(_pr_md_pipefd[0], F_GETFL, 0);
-    fcntl(_pr_md_pipefd[0], F_SETFL, flags | O_NONBLOCK);
-    flags = fcntl(_pr_md_pipefd[1], F_GETFL, 0);
-    fcntl(_pr_md_pipefd[1], F_SETFL, flags | O_NONBLOCK);
-}
-
-/*
-** Unix SIGALRM (clock) signal handler
-*/
-static void ClockInterruptHandler()
-{
-    int olderrno;
-    PRUintn pri;
-    _PRCPU *cpu = _PR_MD_CURRENT_CPU();
-    PRThread *me = _MD_CURRENT_THREAD();
-
-#ifdef SOLARIS
-    if (!me || _PR_IS_NATIVE_THREAD(me)) {
-        _pr_primordialCPU->u.missed[_pr_primordialCPU->where] |= _PR_MISSED_CLOCK;
-        return;
-    }
-#endif
-
-    if (_PR_MD_GET_INTSOFF() != 0) {
-        cpu->u.missed[cpu->where] |= _PR_MISSED_CLOCK;
-        return;
-    }
-    _PR_MD_SET_INTSOFF(1);
-
-    olderrno = errno;
-    _PR_ClockInterrupt();
-    errno = olderrno;
-
-    /*
-    ** If the interrupt wants a resched or if some other thread at
-    ** the same priority needs the cpu, reschedule.
-    */
-    pri = me->priority;
-    if ((cpu->u.missed[3] || (_PR_RUNQREADYMASK(me->cpu) >> pri))) {
-#ifdef _PR_NO_PREEMPT
-        cpu->resched = PR_TRUE;
-        if (pr_interruptSwitchHook) {
-            (*pr_interruptSwitchHook)(pr_interruptSwitchHookArg);
-        }
-#else /* _PR_NO_PREEMPT */
-        /*
-    ** Re-enable unix interrupts (so that we can use
-    ** setjmp/longjmp for context switching without having to
-    ** worry about the signal state)
-    */
-        sigprocmask(SIG_SETMASK, &empty_set, 0);
-        PR_LOG(_pr_sched_lm, PR_LOG_MIN, ("clock caused context switch"));
-
-        if(!(me->flags & _PR_IDLE_THREAD)) {
-            _PR_THREAD_LOCK(me);
-            me->state = _PR_RUNNABLE;
-            me->cpu = cpu;
-            _PR_RUNQ_LOCK(cpu);
-            _PR_ADD_RUNQ(me, cpu, pri);
-            _PR_RUNQ_UNLOCK(cpu);
-            _PR_THREAD_UNLOCK(me);
-        } else
-            me->state = _PR_RUNNABLE;
-        _MD_SWITCH_CONTEXT(me);
-        PR_LOG(_pr_sched_lm, PR_LOG_MIN, ("clock back from context switch"));
-#endif /* _PR_NO_PREEMPT */
-    }
-    /*
-     * Because this thread could be running on a different cpu after
-     * a context switch the current cpu should be accessed and the
-     * value of the 'cpu' variable should not be used.
-     */
-    _PR_MD_SET_INTSOFF(0);
-}
-
-/*
- * On HP-UX 9, we have to use the sigvector() interface to restart
- * interrupted system calls, because sigaction() does not have the
- * SA_RESTART flag.
- */
-
-#ifdef HPUX9
-static void HPUX9_ClockInterruptHandler(
-    int sig,
-    int code,
-    struct sigcontext *scp)
-{
-    ClockInterruptHandler();
-    scp->sc_syscall_action = SIG_RESTART;
-}
-#endif /* HPUX9 */
-
-/* # of milliseconds per clock tick that we will use */
-#define MSEC_PER_TICK    50
-
-
-void _MD_StartInterrupts()
-{
-    char *eval;
-
-    if ((eval = getenv("NSPR_NOCLOCK")) != NULL) {
-        if (atoi(eval) == 0)
-            _nspr_noclock = 0;
-        else
-            _nspr_noclock = 1;
-    }
-
-#ifndef _PR_NO_CLOCK_TIMER
-    if (!_nspr_noclock) {
-        _MD_EnableClockInterrupts();
-    }
-#endif
-}
-
-void _MD_StopInterrupts()
-{
-    sigprocmask(SIG_BLOCK, &timer_set, 0);
-}
-
-void _MD_EnableClockInterrupts()
-{
-    struct itimerval itval;
-    extern PRUintn _pr_numCPU;
-#ifdef HPUX9
-    struct sigvec vec;
-
-    vec.sv_handler = (void (*)()) HPUX9_ClockInterruptHandler;
-    vec.sv_mask = 0;
-    vec.sv_flags = 0;
-    sigvector(SIGALRM, &vec, 0);
-#else
-    struct sigaction vtact;
-
-    vtact.sa_handler = (void (*)()) ClockInterruptHandler;
-    sigemptyset(&vtact.sa_mask);
-    vtact.sa_flags = SA_RESTART;
-    sigaction(SIGALRM, &vtact, 0);
-#endif /* HPUX9 */
-
-    PR_ASSERT(_pr_numCPU == 1);
-	itval.it_interval.tv_sec = 0;
-	itval.it_interval.tv_usec = MSEC_PER_TICK * PR_USEC_PER_MSEC;
-	itval.it_value = itval.it_interval;
-	setitimer(ITIMER_REAL, &itval, 0);
-}
-
-void _MD_DisableClockInterrupts()
-{
-    struct itimerval itval;
-    extern PRUintn _pr_numCPU;
-
-    PR_ASSERT(_pr_numCPU == 1);
-	itval.it_interval.tv_sec = 0;
-	itval.it_interval.tv_usec = 0;
-	itval.it_value = itval.it_interval;
-	setitimer(ITIMER_REAL, &itval, 0);
-}
-
-void _MD_BlockClockInterrupts()
-{
-    sigprocmask(SIG_BLOCK, &timer_set, 0);
-}
-
-void _MD_UnblockClockInterrupts()
-{
-    sigprocmask(SIG_UNBLOCK, &timer_set, 0);
-}
-
-void _MD_MakeNonblock(PRFileDesc *fd)
-{
-    PRInt32 osfd = fd->secret->md.osfd;
-    int flags;
-
-    if (osfd <= 2) {
-        /* Don't mess around with stdin, stdout or stderr */
-        return;
-    }
-    flags = fcntl(osfd, F_GETFL, 0);
-
-    /*
-     * Use O_NONBLOCK (POSIX-style non-blocking I/O) whenever possible.
-     * On SunOS 4, we must use FNDELAY (BSD-style non-blocking I/O),
-     * otherwise connect() still blocks and can be interrupted by SIGALRM.
-     */
-
-#ifdef SUNOS4
-    fcntl(osfd, F_SETFL, flags | FNDELAY);
-#else
-    fcntl(osfd, F_SETFL, flags | O_NONBLOCK);
-#endif
-    }
-
-PRInt32 _MD_open(const char *name, PRIntn flags, PRIntn mode)
-{
-    PRInt32 osflags;
-    PRInt32 rv, err;
-
-    if (flags & PR_RDWR) {
-        osflags = O_RDWR;
-    } else if (flags & PR_WRONLY) {
-        osflags = O_WRONLY;
-    } else {
-        osflags = O_RDONLY;
-    }
-
-    if (flags & PR_EXCL)
-        osflags |= O_EXCL;
-    if (flags & PR_APPEND)
-        osflags |= O_APPEND;
-    if (flags & PR_TRUNCATE)
-        osflags |= O_TRUNC;
-    if (flags & PR_SYNC) {
-#if defined(O_SYNC)
-        osflags |= O_SYNC;
-#elif defined(O_FSYNC)
-        osflags |= O_FSYNC;
-#else
-#error "Neither O_SYNC nor O_FSYNC is defined on this platform"
-#endif
-    }
-
-    /*
-    ** On creations we hold the 'create' lock in order to enforce
-    ** the semantics of PR_Rename. (see the latter for more details)
-    */
-    if (flags & PR_CREATE_FILE)
-    {
-        osflags |= O_CREAT;
-        if (NULL !=_pr_rename_lock)
-            PR_Lock(_pr_rename_lock);
-    }
-
-    rv = _md_iovector._open64(name, osflags, mode);
-
-    if (rv < 0) {
-        err = _MD_ERRNO();
-        _PR_MD_MAP_OPEN_ERROR(err);
-    }
-
-    if ((flags & PR_CREATE_FILE) && (NULL !=_pr_rename_lock))
-        PR_Unlock(_pr_rename_lock);
-    return rv;
-}
-
-PRIntervalTime intr_timeout_ticks;
-
-#if defined(SOLARIS) || defined(IRIX)
-static void sigsegvhandler() {
-    fprintf(stderr,"Received SIGSEGV\n");
-    fflush(stderr);
-    pause();
-}
-
-static void sigaborthandler() {
-    fprintf(stderr,"Received SIGABRT\n");
-    fflush(stderr);
-    pause();
-}
-
-static void sigbushandler() {
-    fprintf(stderr,"Received SIGBUS\n");
-    fflush(stderr);
-    pause();
-}
-#endif /* SOLARIS, IRIX */
-
-#endif  /* !defined(_PR_PTHREADS) */
-
 void _MD_query_fd_inheritable(PRFileDesc *fd)
 {
@@ -2820,53 +624,4 @@
     sigemptyset(&timer_set);
 
-#if !defined(_PR_PTHREADS)
-
-    sigaddset(&timer_set, SIGALRM);
-    sigemptyset(&empty_set);
-    intr_timeout_ticks =
-            PR_SecondsToInterval(_PR_INTERRUPT_CHECK_INTERVAL_SECS);
-
-#if defined(SOLARIS) || defined(IRIX)
-
-    if (getenv("NSPR_SIGSEGV_HANDLE")) {
-        sigact.sa_handler = sigsegvhandler;
-        sigact.sa_flags = 0;
-        sigact.sa_mask = timer_set;
-        sigaction(SIGSEGV, &sigact, 0);
-    }
-
-    if (getenv("NSPR_SIGABRT_HANDLE")) {
-        sigact.sa_handler = sigaborthandler;
-        sigact.sa_flags = 0;
-        sigact.sa_mask = timer_set;
-        sigaction(SIGABRT, &sigact, 0);
-    }
-
-    if (getenv("NSPR_SIGBUS_HANDLE")) {
-        sigact.sa_handler = sigbushandler;
-        sigact.sa_flags = 0;
-        sigact.sa_mask = timer_set;
-        sigaction(SIGBUS, &sigact, 0);
-    }
-
-#endif
-#endif  /* !defined(_PR_PTHREADS) */
-
-    /*
-     * Under HP-UX DCE threads, sigaction() installs a per-thread
-     * handler, so we use sigvector() to install a process-wide
-     * handler.
-     */
-#if defined(HPUX) && defined(_PR_DCETHREADS)
-    {
-        struct sigvec vec;
-
-        vec.sv_handler = SIG_IGN;
-        vec.sv_mask = 0;
-        vec.sv_flags = 0;
-        rv = sigvector(SIGPIPE, &vec, NULL);
-        PR_ASSERT(0 == rv);
-    }
-#else
     sigact.sa_handler = SIG_IGN;
     sigemptyset(&sigact.sa_mask);
@@ -2874,5 +629,4 @@
     rv = sigaction(SIGPIPE, &sigact, 0);
     PR_ASSERT(0 == rv);
-#endif /* HPUX && _PR_DCETHREADS */
 
     _pr_rename_lock = PR_NewLock();
@@ -2887,94 +641,4 @@
     _PR_InitIOV();  /* one last hack */
 }
-
-#if !defined(_PR_PTHREADS)
-
-/*
- * Variables used by the GC code, initialized in _MD_InitSegs().
- */
-static PRInt32 _pr_zero_fd = -1;
-static PRLock *_pr_md_lock = NULL;
-
-/*
- * _MD_InitSegs --
- *
- * This is Unix's version of _PR_MD_INIT_SEGS(), which is
- * called by _PR_InitSegs(), which in turn is called by
- * PR_Init().
- */
-void _MD_InitSegs(void)
-{
-#ifdef DEBUG
-    /*
-    ** Disable using mmap(2) if NSPR_NO_MMAP is set
-    */
-    if (getenv("NSPR_NO_MMAP")) {
-        _pr_zero_fd = -2;
-        return;
-    }
-#endif
-    _pr_zero_fd = open("/dev/zero",O_RDWR , 0);
-    /* Prevent the fd from being inherited by child processes */
-    fcntl(_pr_zero_fd, F_SETFD, FD_CLOEXEC);
-    _pr_md_lock = PR_NewLock();
-}
-
-PRStatus _MD_AllocSegment(PRSegment *seg, PRUint32 size, void *vaddr)
-{
-    static char *lastaddr = (char*) _PR_STACK_VMBASE;
-    PRStatus retval = PR_SUCCESS;
-    int prot;
-    void *rv;
-
-    PR_ASSERT(seg != 0);
-    PR_ASSERT(size != 0);
-
-    PR_Lock(_pr_md_lock);
-    if (_pr_zero_fd < 0) {
-from_heap:
-        seg->vaddr = PR_MALLOC(size);
-        if (!seg->vaddr) {
-            retval = PR_FAILURE;
-        }
-        else {
-            seg->size = size;
-        }
-        goto exit;
-    }
-
-    prot = PROT_READ|PROT_WRITE;
-    /*
-     * On Alpha Linux, the user-level thread stack needs
-     * to be made executable because longjmp/signal seem
-     * to put machine instructions on the stack.
-     */
-#if defined(LINUX) && defined(__alpha)
-    prot |= PROT_EXEC;
-#endif
-    rv = mmap((vaddr != 0) ? vaddr : lastaddr, size, prot,
-        _MD_MMAP_FLAGS,
-        _pr_zero_fd, 0);
-    if (rv == (void*)-1) {
-        goto from_heap;
-    }
-    lastaddr += size;
-    seg->vaddr = rv;
-    seg->size = size;
-    seg->flags = _PR_SEG_VM;
-
-exit:
-    PR_Unlock(_pr_md_lock);
-    return retval;
-}
-
-void _MD_FreeSegment(PRSegment *seg)
-{
-    if (seg->flags & _PR_SEG_VM)
-        (void) munmap(seg->vaddr, seg->size);
-    else
-        PR_DELETE(seg->vaddr);
-}
-
-#endif /* _PR_PTHREADS */
 
 /*
@@ -3023,192 +687,4 @@
 }
 
-#if !defined(_PR_PTHREADS)
-/*
- * Wait for I/O on multiple descriptors.
- *
- * Return 0 if timed out, return -1 if interrupted,
- * else return the number of ready descriptors.
- */
-PRInt32 _PR_WaitForMultipleFDs(
-    _PRUnixPollDesc *unixpds,
-    PRInt32 pdcnt,
-    PRIntervalTime timeout)
-{
-    PRPollQueue pq;
-    PRIntn is;
-    PRInt32 rv;
-    _PRCPU *io_cpu;
-    _PRUnixPollDesc *unixpd, *eunixpd;
-    PRThread *me = _PR_MD_CURRENT_THREAD();
-
-    PR_ASSERT(!(me->flags & _PR_IDLE_THREAD));
-
-    if (_PR_PENDING_INTERRUPT(me)) {
-        me->flags &= ~_PR_INTERRUPT;
-        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);
-        return -1;
-    }
-
-    pq.pds = unixpds;
-    pq.npds = pdcnt;
-
-    _PR_INTSOFF(is);
-    _PR_MD_IOQ_LOCK();
-    _PR_THREAD_LOCK(me);
-
-    pq.thr = me;
-    io_cpu = me->cpu;
-    pq.on_ioq = PR_TRUE;
-    pq.timeout = timeout;
-    _PR_ADD_TO_IOQ(pq, me->cpu);
-
-#if !defined(_PR_USE_POLL)
-    eunixpd = unixpds + pdcnt;
-    for (unixpd = unixpds; unixpd < eunixpd; unixpd++) {
-        PRInt32 osfd = unixpd->osfd;
-        if (unixpd->in_flags & _PR_UNIX_POLL_READ) {
-            FD_SET(osfd, &_PR_FD_READ_SET(me->cpu));
-            _PR_FD_READ_CNT(me->cpu)[osfd]++;
-        }
-        if (unixpd->in_flags & _PR_UNIX_POLL_WRITE) {
-            FD_SET(osfd, &_PR_FD_WRITE_SET(me->cpu));
-            (_PR_FD_WRITE_CNT(me->cpu))[osfd]++;
-        }
-        if (unixpd->in_flags & _PR_UNIX_POLL_EXCEPT) {
-            FD_SET(osfd, &_PR_FD_EXCEPTION_SET(me->cpu));
-            (_PR_FD_EXCEPTION_CNT(me->cpu))[osfd]++;
-        }
-        if (osfd > _PR_IOQ_MAX_OSFD(me->cpu)) {
-            _PR_IOQ_MAX_OSFD(me->cpu) = osfd;
-        }
-    }
-#endif  /* !defined(_PR_USE_POLL) */
-
-    if (_PR_IOQ_TIMEOUT(me->cpu) > timeout) {
-        _PR_IOQ_TIMEOUT(me->cpu) = timeout;
-    }
-
-    _PR_IOQ_OSFD_CNT(me->cpu) += pdcnt;
-        
-    _PR_SLEEPQ_LOCK(me->cpu);
-    _PR_ADD_SLEEPQ(me, timeout);
-    me->state = _PR_IO_WAIT;
-    me->io_pending = PR_TRUE;
-    me->io_suspended = PR_FALSE;
-    _PR_SLEEPQ_UNLOCK(me->cpu);
-    _PR_THREAD_UNLOCK(me);
-    _PR_MD_IOQ_UNLOCK();
-
-    _PR_MD_WAIT(me, timeout);
-
-    me->io_pending = PR_FALSE;
-    me->io_suspended = PR_FALSE;
-
-    /*
-     * This thread should run on the same cpu on which it was blocked; when 
-     * the IO request times out the fd sets and fd counts for the
-     * cpu are updated below.
-     */
-    PR_ASSERT(me->cpu == io_cpu);
-
-    /*
-    ** If we timed out the pollq might still be on the ioq. Remove it
-    ** before continuing.
-    */
-    if (pq.on_ioq) {
-        _PR_MD_IOQ_LOCK();
-        /*
-         * Need to check pq.on_ioq again
-         */
-        if (pq.on_ioq) {
-            PR_REMOVE_LINK(&pq.links);
-#ifndef _PR_USE_POLL
-            eunixpd = unixpds + pdcnt;
-            for (unixpd = unixpds; unixpd < eunixpd; unixpd++) {
-                PRInt32 osfd = unixpd->osfd;
-                PRInt16 in_flags = unixpd->in_flags;
-
-                if (in_flags & _PR_UNIX_POLL_READ) {
-                    if (--(_PR_FD_READ_CNT(me->cpu))[osfd] == 0)
-                        FD_CLR(osfd, &_PR_FD_READ_SET(me->cpu));
-                }
-                if (in_flags & _PR_UNIX_POLL_WRITE) {
-                    if (--(_PR_FD_WRITE_CNT(me->cpu))[osfd] == 0)
-                        FD_CLR(osfd, &_PR_FD_WRITE_SET(me->cpu));
-                }
-                if (in_flags & _PR_UNIX_POLL_EXCEPT) {
-                    if (--(_PR_FD_EXCEPTION_CNT(me->cpu))[osfd] == 0)
-                        FD_CLR(osfd, &_PR_FD_EXCEPTION_SET(me->cpu));
-                }
-            }
-#endif  /* _PR_USE_POLL */
-            PR_ASSERT(pq.npds == pdcnt);
-            _PR_IOQ_OSFD_CNT(me->cpu) -= pdcnt;
-            PR_ASSERT(_PR_IOQ_OSFD_CNT(me->cpu) >= 0);
-        }
-        _PR_MD_IOQ_UNLOCK();
-    }
-    /* XXX Should we use _PR_FAST_INTSON or _PR_INTSON? */
-    if (1 == pdcnt) {
-        _PR_FAST_INTSON(is);
-    } else {
-        _PR_INTSON(is);
-    }
-
-    if (_PR_PENDING_INTERRUPT(me)) {
-        me->flags &= ~_PR_INTERRUPT;
-        PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);
-        return -1;
-    }
-
-    rv = 0;
-    if (pq.on_ioq == PR_FALSE) {
-        /* Count the number of ready descriptors */
-        while (--pdcnt >= 0) {
-            if (unixpds->out_flags != 0) {
-                rv++;
-            }
-            unixpds++;
-        }
-    }
-
-    return rv;
-}
-
-/*
- * Unblock threads waiting for I/O
- *    used when interrupting threads
- *
- * NOTE: The thread lock should held when this function is called.
- * On return, the thread lock is released.
- */
-void _PR_Unblock_IO_Wait(PRThread *thr)
-{
-    int pri = thr->priority;
-    _PRCPU *cpu = thr->cpu;
- 
-    /*
-     * GLOBAL threads wakeup periodically to check for interrupt
-     */
-    if (_PR_IS_NATIVE_THREAD(thr)) {
-        _PR_THREAD_UNLOCK(thr); 
-        return;
-    }
-
-    PR_ASSERT(thr->flags & (_PR_ON_SLEEPQ | _PR_ON_PAUSEQ));
-    _PR_SLEEPQ_LOCK(cpu);
-    _PR_DEL_SLEEPQ(thr, PR_TRUE);
-    _PR_SLEEPQ_UNLOCK(cpu);
-
-    PR_ASSERT(!(thr->flags & _PR_IDLE_THREAD));
-    thr->state = _PR_RUNNABLE;
-    _PR_RUNQ_LOCK(cpu);
-    _PR_ADD_RUNQ(thr, cpu, pri);
-    _PR_RUNQ_UNLOCK(cpu);
-    _PR_THREAD_UNLOCK(thr);
-    _PR_MD_WAKEUP_WAITER(thr);
-}
-#endif  /* !defined(_PR_PTHREADS) */
-
 /*
  * When a nonblocking connect has completed, determine whether it
@@ -3221,79 +697,4 @@
 int _MD_unix_get_nonblocking_connect_error(int osfd)
 {
-#if defined(NTO)
-    /* Neutrino does not support the SO_ERROR socket option */
-    PRInt32      rv;
-    PRNetAddr    addr;
-    _PRSockLen_t addrlen = sizeof(addr);
-
-    /* Test to see if we are using the Tiny TCP/IP Stack or the Full one. */
-    struct statvfs superblock;
-    rv = fstatvfs(osfd, &superblock);
-    if (rv == 0) {
-        if (strcmp(superblock.f_basetype, "ttcpip") == 0) {
-            /* Using the Tiny Stack! */
-            rv = getpeername(osfd, (struct sockaddr *) &addr,
-                    (_PRSockLen_t *) &addrlen);
-            if (rv == -1) {
-                int errno_copy = errno;    /* make a copy so I don't
-                                            * accidentally reset */
-
-                if (errno_copy == ENOTCONN) {
-                    struct stat StatInfo;
-                    rv = fstat(osfd, &StatInfo);
-                    if (rv == 0) {
-                        time_t current_time = time(NULL);
-
-                        /*
-                         * this is a real hack, can't explain why it
-                         * works it just does
-                         */
-                        if (abs(current_time - StatInfo.st_atime) < 5) {
-                            return ECONNREFUSED;
-                        } else {
-                            return ETIMEDOUT;
-                        }
-                    } else {
-                        return ECONNREFUSED;
-                    }
-                } else {
-                    return errno_copy;
-                }
-            } else {
-                /* No Error */
-                return 0;
-            }
-        } else {
-            /* Have the FULL Stack which supports SO_ERROR */
-            /* Hasn't been written yet, never been tested! */
-            /* Jerry.Kirk@Nexwarecorp.com */
-
-            int err;
-            _PRSockLen_t optlen = sizeof(err);
-
-            if (getsockopt(osfd, SOL_SOCKET, SO_ERROR,
-                    (char *) &err, &optlen) == -1) {
-                return errno;
-            } else {
-                return err;
-            }		
-        }
-    } else {
-        return ECONNREFUSED;
-    }	
-#elif defined(NCR) || defined(UNIXWARE) || defined(SNI) || defined(NEC)
-    /*
-     * getsockopt() fails with EPIPE, so use getmsg() instead.
-     */
-
-    int rv;
-    int flags = 0;
-    rv = getmsg(osfd, NULL, NULL, &flags);
-    PR_ASSERT(-1 == rv || 0 == rv);
-    if (-1 == rv && errno != EAGAIN && errno != EWOULDBLOCK) {
-        return errno;
-    }
-    return 0;  /* no error */
-#else
     int err;
     _PRSockLen_t optlen = sizeof(err);
@@ -3303,5 +704,4 @@
         return err;
     }
-#endif
 }
 
Index: trunk/src/libs/xpcom18a4/nsprpub/pr/src/memory/prseg.c
===================================================================
--- trunk/src/libs/xpcom18a4/nsprpub/pr/src/memory/prseg.c	(revision 101804)
+++ 	(revision )
@@ -1,93 +1,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is the Netscape Portable Runtime (NSPR).
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998-2000
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "primpl.h"
-
-#if defined(_PR_PTHREADS)
-
-/*
-** The pthreads version doesn't use these functions.
-*/
-void _PR_InitSegs(void)
-{
-}
-
-#else /* _PR_PTHREADS */
-
-void _PR_InitSegs(void)
-{
-	_PR_MD_INIT_SEGS();
-}
-
-/*
-** Allocate a memory segment. The size value is rounded up to the native
-** system page size and a page aligned portion of memory is returned.
-** This memory is not part of the malloc heap. If "vaddr" is not NULL
-** then PR tries to allocate the segment at the desired virtual address.
-*/
-PRSegment* _PR_NewSegment(PRUint32 size, void *vaddr)
-{
-    PRSegment *seg;
-
-	/* calloc the data structure for the segment */
-    seg = PR_NEWZAP(PRSegment);
-
-    if (seg) {
-	    size = ((size + _pr_pageSize - 1) >> _pr_pageShift) << _pr_pageShift;
-		/*
-		**	Now, allocate the actual segment memory (or map under some OS)
-		**	The OS specific code decides from where or how to allocate memory.
-		*/
-	    if (_PR_MD_ALLOC_SEGMENT(seg, size, vaddr) != PR_SUCCESS) {
-			PR_DELETE(seg);
-			return NULL;
-    	}
-	}
-
-    return seg;
-}
-
-/*
-** Free a memory segment.
-*/
-void _PR_DestroySegment(PRSegment *seg)
-{
-	_PR_MD_FREE_SEGMENT(seg);
-    PR_DELETE(seg);
-}
-
-#endif /* _PR_PTHREADS */
Index: trunk/src/libs/xpcom18a4/nsprpub/pr/src/misc/prinit.c
===================================================================
--- trunk/src/libs/xpcom18a4/nsprpub/pr/src/misc/prinit.c	(revision 101804)
+++ trunk/src/libs/xpcom18a4/nsprpub/pr/src/misc/prinit.c	(revision 101805)
@@ -173,5 +173,4 @@
     _PR_InitLocks();
     _PR_InitAtomic();
-    _PR_InitSegs();
 	_PR_InitTPD();
     _PR_InitEnv();
@@ -199,45 +198,20 @@
 {
 	_PR_InitStuff();
-
-    /* Enable interrupts */
-#if !defined(_PR_PTHREADS) && !defined(_PR_GLOBAL_THREADS_ONLY)
-    _PR_MD_START_INTERRUPTS();
-#endif
-
 }
 
 PR_IMPLEMENT(void) PR_DisableClockInterrupts(void)
 {
-#if !defined(_PR_PTHREADS) && !defined(_PR_BTHREADS)
-	if (!_pr_initialized) {
-		_PR_InitStuff();
-	} else {
-    	_PR_MD_DISABLE_CLOCK_INTERRUPTS();
-	}
-#endif
 }
 
 PR_IMPLEMENT(void) PR_EnableClockInterrupts(void)
 {
-#if !defined(_PR_PTHREADS) && !defined(_PR_BTHREADS)
-	if (!_pr_initialized) {
-		_PR_InitStuff();
-	}
-    _PR_MD_ENABLE_CLOCK_INTERRUPTS();
-#endif
 }
 
 PR_IMPLEMENT(void) PR_BlockClockInterrupts(void)
 {
-#if !defined(_PR_PTHREADS) && !defined(_PR_BTHREADS)
-    	_PR_MD_BLOCK_CLOCK_INTERRUPTS();
-#endif
 }
 
 PR_IMPLEMENT(void) PR_UnblockClockInterrupts(void)
 {
-#if !defined(_PR_PTHREADS) && !defined(_PR_BTHREADS)
-    	_PR_MD_UNBLOCK_CLOCK_INTERRUPTS();
-#endif
 }
 
Index: trunk/src/libs/xpcom18a4/nsprpub/pr/src/misc/pripcsem.c
===================================================================
--- trunk/src/libs/xpcom18a4/nsprpub/pr/src/misc/pripcsem.c	(revision 101804)
+++ 	(revision )
@@ -1,130 +1,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is the Netscape Portable Runtime (NSPR).
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999-2000
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-/*
- * File: pripcsem.c
- *
- * Description: implements the named semaphores API in prsemipc.h
- * for classic NSPR.  If _PR_HAVE_NAMED_SEMAPHORES is not defined,
- * the named semaphore functions all fail with the error code
- * PR_NOT_IMPLEMENTED_ERROR.
- */
-
-#include "primpl.h"
-
-#ifdef _PR_PTHREADS
-
-#error "This file should not be compiled for the pthreads version"
-
-#else
-
-#ifndef _PR_HAVE_NAMED_SEMAPHORES
-
-PRSem * _PR_MD_OPEN_SEMAPHORE(
-    const char *osname, PRIntn flags, PRIntn mode, PRUintn value)
-{
-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
-    return NULL;
-}
-
-PRStatus _PR_MD_WAIT_SEMAPHORE(PRSem *sem)
-{
-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
-    return PR_FAILURE;
-}
-
-PRStatus _PR_MD_POST_SEMAPHORE(PRSem *sem)
-{
-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
-    return PR_FAILURE;
-}
-
-PRStatus _PR_MD_CLOSE_SEMAPHORE(PRSem *sem)
-{
-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
-    return PR_FAILURE;
-}
-
-PRStatus _PR_MD_DELETE_SEMAPHORE(const char *osname)
-{
-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
-    return PR_FAILURE;
-}
-
-#endif /* !_PR_HAVE_NAMED_SEMAPHORES */
-
-PR_IMPLEMENT(PRSem *) PR_OpenSemaphore(
-    const char *name, PRIntn flags, PRIntn mode, PRUintn value)
-{
-    char osname[PR_IPC_NAME_SIZE];
-
-    if (!_pr_initialized) _PR_ImplicitInitialization();
-    if (_PR_MakeNativeIPCName(name, osname, sizeof(osname), _PRIPCSem)
-            == PR_FAILURE) {
-        return NULL;
-    }
-    return _PR_MD_OPEN_SEMAPHORE(osname, flags, mode, value);
-}
-
-PR_IMPLEMENT(PRStatus) PR_WaitSemaphore(PRSem *sem)
-{
-    return _PR_MD_WAIT_SEMAPHORE(sem);
-}
-
-PR_IMPLEMENT(PRStatus) PR_PostSemaphore(PRSem *sem)
-{
-    return _PR_MD_POST_SEMAPHORE(sem);
-}
-
-PR_IMPLEMENT(PRStatus) PR_CloseSemaphore(PRSem *sem)
-{
-    return _PR_MD_CLOSE_SEMAPHORE(sem);
-}
-
-PR_IMPLEMENT(PRStatus) PR_DeleteSemaphore(const char *name)
-{
-    char osname[PR_IPC_NAME_SIZE];
-
-    if (!_pr_initialized) _PR_ImplicitInitialization();
-    if (_PR_MakeNativeIPCName(name, osname, sizeof(osname), _PRIPCSem)
-            == PR_FAILURE) {
-        return PR_FAILURE;
-    }
-    return _PR_MD_DELETE_SEMAPHORE(osname);
-}
-
-#endif /* _PR_PTHREADS */
Index: trunk/src/libs/xpcom18a4/nsprpub/pr/src/pthreads/ptio.c
===================================================================
--- trunk/src/libs/xpcom18a4/nsprpub/pr/src/pthreads/ptio.c	(revision 101804)
+++ trunk/src/libs/xpcom18a4/nsprpub/pr/src/pthreads/ptio.c	(revision 101805)
@@ -40,6 +40,4 @@
 ** Descritpion:  Implemenation of I/O methods for pthreads
 */
-
-#if defined(_PR_PTHREADS)
 
 #if defined(_PR_POLL_WITH_SELECT)
@@ -4180,5 +4178,4 @@
     return rv;
 }
-#endif /* defined(_PR_PTHREADS) */
 
 #ifdef MOZ_UNICODE
Index: trunk/src/libs/xpcom18a4/nsprpub/pr/src/pthreads/ptsynch.c
===================================================================
--- trunk/src/libs/xpcom18a4/nsprpub/pr/src/pthreads/ptsynch.c	(revision 101804)
+++ trunk/src/libs/xpcom18a4/nsprpub/pr/src/pthreads/ptsynch.c	(revision 101805)
@@ -42,6 +42,4 @@
 */
 
-#if defined(_PR_PTHREADS)
-
 #include "primpl.h"
 
@@ -1126,5 +1124,3 @@
 }  /* PRP_NakedBroadcast */
 
-#endif  /* defined(_PR_PTHREADS) */
-
 /* ptsynch.c */
Index: trunk/src/libs/xpcom18a4/nsprpub/pr/src/pthreads/ptthread.c
===================================================================
--- trunk/src/libs/xpcom18a4/nsprpub/pr/src/pthreads/ptthread.c	(revision 101804)
+++ trunk/src/libs/xpcom18a4/nsprpub/pr/src/pthreads/ptthread.c	(revision 101805)
@@ -41,6 +41,4 @@
 ** Exports:            ptthread.h
 */
-
-#if defined(_PR_PTHREADS) || defined(_PR_DCETHREADS)
 
 #include "prlog.h"
@@ -1560,5 +1558,3 @@
 #endif /* !defined(_PR_DCETHREADS) */
 
-#endif  /* defined(_PR_PTHREADS) || defined(_PR_DCETHREADS) */
-
 /* ptthread.c */
