NSPR no longer defines symbols with the PTHREAD prefix. Bugzilla #9907.
authorsrinivas%netscape.com
Thu, 15 Jul 1999 13:06:28 +0000
changeset 705 5d78b4a93d1c17579220a2098631da37b11bcc96
parent 704 3d1a2d7e494442b75b7d84b26b987edee4e982c0
child 706 8601e38b2b0c274f5664b362a7e2be99e1f819a0
push idunknown
push userunknown
push dateunknown
NSPR no longer defines symbols with the PTHREAD prefix. Bugzilla #9907.
pr/include/md/_pth.h
pr/src/malloc/prmem.c
pr/src/pthreads/ptsynch.c
pr/src/pthreads/ptthread.c
pr/tests/attach.c
pr/tests/foreign.c
pr/tests/provider.c
--- a/pr/include/md/_pth.h
+++ b/pr/include/md/_pth.h
@@ -27,109 +27,109 @@
 #define _PR_MD_DISABLE_CLOCK_INTERRUPTS()
 #define _PR_MD_ENABLE_CLOCK_INTERRUPTS()
 
 /* In good standards fashion, the DCE threads (based on posix-4) are not
  * quite the same as newer posix implementations.  These are mostly name
  * changes and small differences, so macros usually do the trick
  */
 #ifdef _PR_DCETHREADS
-#define PTHREAD_MUTEXATTR_INIT        pthread_mutexattr_create
-#define PTHREAD_MUTEXATTR_DESTROY     pthread_mutexattr_delete
-#define PTHREAD_MUTEX_INIT(m, a)      pthread_mutex_init(&(m), a)
-#define PTHREAD_MUTEX_IS_LOCKED(m)    (0 == pthread_mutex_trylock(&(m)))
-#define PTHREAD_CONDATTR_INIT         pthread_condattr_create
-#define PTHREAD_COND_INIT(m, a)       pthread_cond_init(&(m), a)
-#define PTHREAD_CONDATTR_DESTROY      pthread_condattr_delete
+#define _PT_PTHREAD_MUTEXATTR_INIT        pthread_mutexattr_create
+#define _PT_PTHREAD_MUTEXATTR_DESTROY     pthread_mutexattr_delete
+#define _PT_PTHREAD_MUTEX_INIT(m, a)      pthread_mutex_init(&(m), a)
+#define _PT_PTHREAD_MUTEX_IS_LOCKED(m)    (0 == pthread_mutex_trylock(&(m)))
+#define _PT_PTHREAD_CONDATTR_INIT         pthread_condattr_create
+#define _PT_PTHREAD_COND_INIT(m, a)       pthread_cond_init(&(m), a)
+#define _PT_PTHREAD_CONDATTR_DESTROY      pthread_condattr_delete
 
 /* Notes about differences between DCE threads and pthreads 10:
  *   1. pthread_mutex_trylock returns 1 when it locks the mutex
  *      0 when it does not.  The latest pthreads has a set of errno-like
  *      return values.
  *   2. return values from pthread_cond_timedwait are different.
  *
  *
  *
  */
 #elif defined(BSDI)
 /*
  * Mutex and condition attributes are not supported.  The attr
  * argument to pthread_mutex_init() and pthread_cond_init() must
  * be passed as NULL.
  *
- * The memset calls in PTHREAD_MUTEX_INIT and PTHREAD_COND_INIT
+ * The memset calls in _PT_PTHREAD_MUTEX_INIT and _PT_PTHREAD_COND_INIT
  * are to work around BSDI's using a single bit to indicate a mutex
  * or condition variable is initialized.  This entire BSDI section
  * will go away when BSDI releases updated threads libraries for
  * BSD/OS 3.1 and 4.0.
  */
-#define PTHREAD_MUTEXATTR_INIT(x)     0
-#define PTHREAD_MUTEXATTR_DESTROY(x)  /* */
-#define PTHREAD_MUTEX_INIT(m, a)      (memset(&(m), 0, sizeof(m)), \
+#define _PT_PTHREAD_MUTEXATTR_INIT(x)     0
+#define _PT_PTHREAD_MUTEXATTR_DESTROY(x)  /* */
+#define _PT_PTHREAD_MUTEX_INIT(m, a)      (memset(&(m), 0, sizeof(m)), \
                                       pthread_mutex_init(&(m), NULL))
-#define PTHREAD_MUTEX_IS_LOCKED(m)    (EBUSY == pthread_mutex_trylock(&(m)))
-#define PTHREAD_CONDATTR_INIT(x)      0
-#define PTHREAD_CONDATTR_DESTROY(x)   /* */
-#define PTHREAD_COND_INIT(m, a)       (memset(&(m), 0, sizeof(m)), \
+#define _PT_PTHREAD_MUTEX_IS_LOCKED(m)    (EBUSY == pthread_mutex_trylock(&(m)))
+#define _PT_PTHREAD_CONDATTR_INIT(x)      0
+#define _PT_PTHREAD_CONDATTR_DESTROY(x)   /* */
+#define _PT_PTHREAD_COND_INIT(m, a)       (memset(&(m), 0, sizeof(m)), \
                                       pthread_cond_init(&(m), NULL))
 #else
-#define PTHREAD_MUTEXATTR_INIT        pthread_mutexattr_init
-#define PTHREAD_MUTEXATTR_DESTROY     pthread_mutexattr_destroy
-#define PTHREAD_MUTEX_INIT(m, a)      pthread_mutex_init(&(m), &(a))
-#define PTHREAD_MUTEX_IS_LOCKED(m)    (EBUSY == pthread_mutex_trylock(&(m)))
-#define PTHREAD_CONDATTR_INIT         pthread_condattr_init
-#define PTHREAD_CONDATTR_DESTROY      pthread_condattr_destroy
-#define PTHREAD_COND_INIT(m, a)       pthread_cond_init(&(m), &(a))
+#define _PT_PTHREAD_MUTEXATTR_INIT        pthread_mutexattr_init
+#define _PT_PTHREAD_MUTEXATTR_DESTROY     pthread_mutexattr_destroy
+#define _PT_PTHREAD_MUTEX_INIT(m, a)      pthread_mutex_init(&(m), &(a))
+#define _PT_PTHREAD_MUTEX_IS_LOCKED(m)    (EBUSY == pthread_mutex_trylock(&(m)))
+#define _PT_PTHREAD_CONDATTR_INIT         pthread_condattr_init
+#define _PT_PTHREAD_CONDATTR_DESTROY      pthread_condattr_destroy
+#define _PT_PTHREAD_COND_INIT(m, a)       pthread_cond_init(&(m), &(a))
 #endif
 
 /* The pthread_t handle used to identify a thread can vary in size
  * with different implementations of pthreads.  This macro defines
  * a way to get a unique identifier from the handle.  This may be
  * more of a problem as we adapt to more pthreads implementations.
  */
 #if defined(_PR_DCETHREADS)
-#define PTHREAD_ZERO_THR_HANDLE(t)        memset(&(t), 0, sizeof(pthread_t))
-#define PTHREAD_THR_HANDLE_IS_ZERO(t) \
+#define _PT_PTHREAD_ZERO_THR_HANDLE(t)        memset(&(t), 0, sizeof(pthread_t))
+#define _PT_PTHREAD_THR_HANDLE_IS_ZERO(t) \
 	(!memcmp(&(t), &pt_zero_tid, sizeof(pthread_t)))
-#define PTHREAD_COPY_THR_HANDLE(st, dt)   (dt) = (st)
+#define _PT_PTHREAD_COPY_THR_HANDLE(st, dt)   (dt) = (st)
 #elif defined(IRIX) || defined(OSF1) || defined(AIX) || defined(SOLARIS) \
 	|| defined(HPUX) || defined(LINUX) || defined(FREEBSD) \
 	|| defined(NETBSD) || defined(OPENBSD) || defined(BSDI) \
 	|| defined(VMS) || defined(NTO)
-#define PTHREAD_ZERO_THR_HANDLE(t)        (t) = 0
-#define PTHREAD_THR_HANDLE_IS_ZERO(t)     (t) == 0
-#define PTHREAD_COPY_THR_HANDLE(st, dt)   (dt) = (st)
+#define _PT_PTHREAD_ZERO_THR_HANDLE(t)        (t) = 0
+#define _PT_PTHREAD_THR_HANDLE_IS_ZERO(t)     (t) == 0
+#define _PT_PTHREAD_COPY_THR_HANDLE(st, dt)   (dt) = (st)
 #else 
 #error "pthreads is not supported for this architecture"
 #endif
 
 #if defined(_PR_DCETHREADS)
-#define PTHREAD_ATTR_INIT            pthread_attr_create
-#define PTHREAD_ATTR_DESTROY         pthread_attr_delete
-#define PTHREAD_CREATE(t, a, f, r)   pthread_create(t, a, f, r) 
-#define PTHREAD_KEY_CREATE           pthread_keycreate
-#define PTHREAD_ATTR_SETSCHEDPOLICY  pthread_attr_setsched
-#define PTHREAD_ATTR_GETSTACKSIZE(a, s) \
+#define _PT_PTHREAD_ATTR_INIT            pthread_attr_create
+#define _PT_PTHREAD_ATTR_DESTROY         pthread_attr_delete
+#define _PT_PTHREAD_CREATE(t, a, f, r)   pthread_create(t, a, f, r) 
+#define _PT_PTHREAD_KEY_CREATE           pthread_keycreate
+#define _PT_PTHREAD_ATTR_SETSCHEDPOLICY  pthread_attr_setsched
+#define _PT_PTHREAD_ATTR_GETSTACKSIZE(a, s) \
                                      (*(s) = pthread_attr_getstacksize(*(a)), 0)
-#define PTHREAD_GETSPECIFIC(k, r) \
+#define _PT_PTHREAD_GETSPECIFIC(k, r) \
 		pthread_getspecific((k), (pthread_addr_t *) &(r))
 #elif defined(_PR_PTHREADS)
-#define PTHREAD_ATTR_INIT            pthread_attr_init
-#define PTHREAD_ATTR_DESTROY         pthread_attr_destroy
-#define PTHREAD_CREATE(t, a, f, r)   pthread_create(t, &a, f, r) 
-#define PTHREAD_KEY_CREATE           pthread_key_create
-#define PTHREAD_ATTR_SETSCHEDPOLICY  pthread_attr_setschedpolicy
-#define PTHREAD_ATTR_GETSTACKSIZE(a, s) pthread_attr_getstacksize(a, s)
-#define PTHREAD_GETSPECIFIC(k, r)    (r) = pthread_getspecific(k)
+#define _PT_PTHREAD_ATTR_INIT            pthread_attr_init
+#define _PT_PTHREAD_ATTR_DESTROY         pthread_attr_destroy
+#define _PT_PTHREAD_CREATE(t, a, f, r)   pthread_create(t, &a, f, r) 
+#define _PT_PTHREAD_KEY_CREATE           pthread_key_create
+#define _PT_PTHREAD_ATTR_SETSCHEDPOLICY  pthread_attr_setschedpolicy
+#define _PT_PTHREAD_ATTR_GETSTACKSIZE(a, s) pthread_attr_getstacksize(a, s)
+#define _PT_PTHREAD_GETSPECIFIC(k, r)    (r) = pthread_getspecific(k)
 #else
 #error "Cannot determine pthread strategy"
 #endif
 
 #if defined(_PR_DCETHREADS)
-#define PTHREAD_EXPLICIT_SCHED      PTHREAD_DEFAULT_SCHED
+#define _PT_PTHREAD_EXPLICIT_SCHED      _PT_PTHREAD_DEFAULT_SCHED
 #endif
 
 /*
  * pthread_mutex_trylock returns different values in DCE threads and
  * pthreads.
  */
 #if defined(_PR_DCETHREADS)
 #define PT_TRYLOCK_SUCCESS 1
@@ -162,18 +162,18 @@
 #define PT_PRIO_MAX            PRI_OTHER_MAX
 #elif defined(IRIX)
 #include <sys/sched.h>
 #define PT_PRIO_MIN            PX_PRIO_MIN
 #define PT_PRIO_MAX            PX_PRIO_MAX
 #elif defined(AIX)
 #include <sys/priv.h>
 #include <sys/sched.h>
-#ifndef PTHREAD_CREATE_JOINABLE
-#define PTHREAD_CREATE_JOINABLE     PTHREAD_CREATE_UNDETACHED
+#ifndef _PT_PTHREAD_CREATE_JOINABLE
+#define _PT_PTHREAD_CREATE_JOINABLE     _PT_PTHREAD_CREATE_UNDETACHED
 #endif
 #define PT_PRIO_MIN            DEFAULT_PRIO
 #define PT_PRIO_MAX            DEFAULT_PRIO
 #elif defined(HPUX)
 
 #if defined(_PR_DCETHREADS)
 #define PT_PRIO_MIN            PRI_OTHER_MIN
 #define PT_PRIO_MAX            PRI_OTHER_MAX
@@ -207,40 +207,40 @@
 	|| defined(BSDI) /* XXX */
 #define PT_PRIO_MIN            0
 #define PT_PRIO_MAX            126
 #else
 #error "pthreads is not supported for this architecture"
 #endif
 
 /*
- * The PTHREAD_YIELD function is called from a signal handler.
+ * The _PT_PTHREAD_YIELD function is called from a signal handler.
  * Needed for garbage collection -- Look at PR_Suspend/PR_Resume
  * implementation.
  */
 #if defined(_PR_DCETHREADS)
-#define PTHREAD_YIELD()            	pthread_yield()
+#define _PT_PTHREAD_YIELD()            	pthread_yield()
 #elif defined(OSF1) || defined(VMS)
 /*
  * sched_yield can't be called from a signal handler.  Must use
  * the _np version.
  */
-#define PTHREAD_YIELD()            	pthread_yield_np()
+#define _PT_PTHREAD_YIELD()            	pthread_yield_np()
 #elif defined(AIX)
 extern int (*_PT_aix_yield_fcn)();
-#define PTHREAD_YIELD()			(*_PT_aix_yield_fcn)()
+#define _PT_PTHREAD_YIELD()			(*_PT_aix_yield_fcn)()
 #elif defined(IRIX)
 #include <time.h>
-#define PTHREAD_YIELD() \
+#define _PT_PTHREAD_YIELD() \
     PR_BEGIN_MACRO               				\
 		struct timespec onemillisec = {0};		\
 		onemillisec.tv_nsec = 1000000L;			\
         nanosleep(&onemillisec,NULL);			\
     PR_END_MACRO
 #elif defined(HPUX) || defined(LINUX) || defined(SOLARIS) \
 	|| defined(FREEBSD) || defined(NETBSD) || defined(OPENBSD) \
 	|| defined(BSDI) || defined(NTO)
-#define PTHREAD_YIELD()            	sched_yield()
+#define _PT_PTHREAD_YIELD()            	sched_yield()
 #else
-#error "Need to define PTHREAD_YIELD for this platform"
+#error "Need to define _PT_PTHREAD_YIELD for this platform"
 #endif
 
 #endif /* nspr_pth_defs_h_ */
--- a/pr/src/malloc/prmem.c
+++ b/pr/src/malloc/prmem.c
@@ -163,21 +163,21 @@ PR_IMPLEMENT(PRStatus) _PR_MallocInit(vo
 
     if( PR_TRUE == _PR_malloc_initialised ) return PR_SUCCESS;
 
 #ifdef _PR_PTHREADS
     {
 	int status;
 	pthread_mutexattr_t mattr;
 
-	status = PTHREAD_MUTEXATTR_INIT(&mattr);
+	status = _PT_PTHREAD_MUTEXATTR_INIT(&mattr);
 	PR_ASSERT(0 == status);
-	status = PTHREAD_MUTEX_INIT(_PR_MD_malloc_crustylock, mattr);
+	status = _PT_PTHREAD_MUTEX_INIT(_PR_MD_malloc_crustylock, mattr);
 	PR_ASSERT(0 == status);
-	status = PTHREAD_MUTEXATTR_DESTROY(&mattr);
+	status = _PT_PTHREAD_MUTEXATTR_DESTROY(&mattr);
 	PR_ASSERT(0 == status);
     }
 #else /* _PR_PTHREADS */
     _MD_NEW_LOCK(&_PR_MD_malloc_crustylock);
 #endif /* _PR_PTHREADS */
 
     if( PR_SUCCESS == rv )
     {
--- a/pr/src/pthreads/ptsynch.c
+++ b/pr/src/pthreads/ptsynch.c
@@ -47,20 +47,20 @@ static pthread_t pt_zero_tid;  /* a null
 /**************************************************************/
 /*****************************LOCKS****************************/
 /**************************************************************/
 /**************************************************************/
 
 void _PR_InitLocks(void)
 {
     int rv;
-    rv = PTHREAD_MUTEXATTR_INIT(&_pt_mattr); 
+    rv = _PT_PTHREAD_MUTEXATTR_INIT(&_pt_mattr); 
     PR_ASSERT(0 == rv);
 
-    rv = PTHREAD_CONDATTR_INIT(&_pt_cvar_attr);
+    rv = _PT_PTHREAD_CONDATTR_INIT(&_pt_cvar_attr);
     PR_ASSERT(0 == rv);
 }
 
 static void pt_PostNotifies(PRLock *lock, PRBool unlock)
 {
     PRIntn index, rv;
     _PT_Notified post;
     _PT_Notified *notified, *prev = NULL;
@@ -130,30 +130,30 @@ PR_IMPLEMENT(PRLock*) PR_NewLock(void)
     PRIntn rv;
     PRLock *lock;
 
     if (!_pr_initialized) _PR_ImplicitInitialization();
 
     lock = PR_NEWZAP(PRLock);
     if (lock != NULL)
     {
-        rv = PTHREAD_MUTEX_INIT(lock->mutex, _pt_mattr); 
+        rv = _PT_PTHREAD_MUTEX_INIT(lock->mutex, _pt_mattr); 
         PR_ASSERT(0 == rv);
     }
 #if defined(DEBUG)
     pt_debug.locks_created += 1;
 #endif
     return lock;
 }  /* PR_NewLock */
 
 PR_IMPLEMENT(void) PR_DestroyLock(PRLock *lock)
 {
     PRIntn rv;
     PR_ASSERT(NULL != lock);
-    PR_ASSERT(PTHREAD_THR_HANDLE_IS_ZERO(lock->owner));
+    PR_ASSERT(_PT_PTHREAD_THR_HANDLE_IS_ZERO(lock->owner));
     PR_ASSERT(0 == lock->notified.length);
     PR_ASSERT(NULL == lock->notified.link);
     rv = pthread_mutex_destroy(&lock->mutex);
     PR_ASSERT(0 == rv);
 #if defined(DEBUG)
     memset(lock, 0xaf, sizeof(PRLock));
     pt_debug.locks_destroyed += 1;
 #endif
@@ -163,35 +163,35 @@ PR_IMPLEMENT(void) PR_DestroyLock(PRLock
 PR_IMPLEMENT(void) PR_Lock(PRLock *lock)
 {
     PRIntn rv;
     PR_ASSERT(lock != NULL);
     rv = pthread_mutex_lock(&lock->mutex);
     PR_ASSERT(0 == rv);
     PR_ASSERT(0 == lock->notified.length);
     PR_ASSERT(NULL == lock->notified.link);
-    PR_ASSERT(PTHREAD_THR_HANDLE_IS_ZERO(lock->owner));
-    PTHREAD_COPY_THR_HANDLE(pthread_self(), lock->owner);
+    PR_ASSERT(_PT_PTHREAD_THR_HANDLE_IS_ZERO(lock->owner));
+    _PT_PTHREAD_COPY_THR_HANDLE(pthread_self(), lock->owner);
 #if defined(DEBUG)
     pt_debug.locks_acquired += 1;
 #endif
 }  /* PR_Lock */
 
 PR_IMPLEMENT(PRStatus) PR_Unlock(PRLock *lock)
 {
     PRIntn rv;
 
     PR_ASSERT(lock != NULL);
-    PR_ASSERT(PTHREAD_MUTEX_IS_LOCKED(lock->mutex));
+    PR_ASSERT(_PT_PTHREAD_MUTEX_IS_LOCKED(lock->mutex));
     PR_ASSERT(pthread_equal(lock->owner, pthread_self()));
 
     if (!pthread_equal(lock->owner, pthread_self()))
         return PR_FAILURE;
 
-    PTHREAD_ZERO_THR_HANDLE(lock->owner);
+    _PT_PTHREAD_ZERO_THR_HANDLE(lock->owner);
     if (0 == lock->notified.length)  /* shortcut */
     {
         rv = pthread_mutex_unlock(&lock->mutex);
         PR_ASSERT(0 == rv);
     }
     else pt_PostNotifies(lock, PR_TRUE);
 
 #if defined(DEBUG)
@@ -253,17 +253,17 @@ static PRIntn pt_TimedWait(
  * MP systems don't contend for a lock that they can't have.
  */
 static void pt_PostNotifyToCvar(PRCondVar *cvar, PRBool broadcast)
 {
     PRIntn index = 0;
     _PT_Notified *notified = &cvar->lock->notified;
 
     PR_ASSERT(pthread_equal(cvar->lock->owner, pthread_self()));
-    PR_ASSERT(PTHREAD_MUTEX_IS_LOCKED(cvar->lock->mutex));
+    PR_ASSERT(_PT_PTHREAD_MUTEX_IS_LOCKED(cvar->lock->mutex));
 
     while (1)
     {
         for (index = 0; index < notified->length; ++index)
         {
             if (notified->cv[index].cv == cvar)
             {
                 if (broadcast)
@@ -293,17 +293,17 @@ finished:
 }  /* pt_PostNotifyToCvar */
 
 PR_IMPLEMENT(PRCondVar*) PR_NewCondVar(PRLock *lock)
 {
     PRCondVar *cv = PR_NEW(PRCondVar);
     PR_ASSERT(lock != NULL);
     if (cv != NULL)
     {
-        int rv = PTHREAD_COND_INIT(cv->cv, _pt_cvar_attr); 
+        int rv = _PT_PTHREAD_COND_INIT(cv->cv, _pt_cvar_attr); 
         PR_ASSERT(0 == rv);
         cv->lock = lock;
         cv->notify_pending = 0;
 #if defined(DEBUG)
         pt_debug.cvars_created += 1;
 #endif
     }
     return cv;
@@ -324,17 +324,17 @@ PR_IMPLEMENT(void) PR_DestroyCondVar(PRC
 
 PR_IMPLEMENT(PRStatus) PR_WaitCondVar(PRCondVar *cvar, PRIntervalTime timeout)
 {
     PRIntn rv;
     PRThread *thred = PR_CurrentThread();
 
     PR_ASSERT(cvar != NULL);
     /* We'd better be locked */
-    PR_ASSERT(PTHREAD_MUTEX_IS_LOCKED(cvar->lock->mutex));
+    PR_ASSERT(_PT_PTHREAD_MUTEX_IS_LOCKED(cvar->lock->mutex));
     /* and it better be by us */
     PR_ASSERT(pthread_equal(cvar->lock->owner, pthread_self()));
 
     if (thred->state & PT_THREAD_ABORTED) goto aborted;
 
     /*
      * The thread waiting is used for PR_Interrupt
      */
@@ -349,26 +349,26 @@ PR_IMPLEMENT(PRStatus) PR_WaitCondVar(PR
      * hold until we actually wait.
      */
     if (0 != cvar->lock->notified.length)
         pt_PostNotifies(cvar->lock, PR_FALSE);
 
     /*
      * We're surrendering the lock, so clear out the owner field.
      */
-    PTHREAD_ZERO_THR_HANDLE(cvar->lock->owner);
+    _PT_PTHREAD_ZERO_THR_HANDLE(cvar->lock->owner);
 
     if (timeout == PR_INTERVAL_NO_TIMEOUT)
         rv = pthread_cond_wait(&cvar->cv, &cvar->lock->mutex);
     else
         rv = pt_TimedWait(&cvar->cv, &cvar->lock->mutex, timeout);
 
     /* We just got the lock back - this better be empty */
-    PR_ASSERT(PTHREAD_THR_HANDLE_IS_ZERO(cvar->lock->owner));
-    PTHREAD_COPY_THR_HANDLE(pthread_self(), cvar->lock->owner);
+    PR_ASSERT(_PT_PTHREAD_THR_HANDLE_IS_ZERO(cvar->lock->owner));
+    _PT_PTHREAD_COPY_THR_HANDLE(pthread_self(), cvar->lock->owner);
 
     PR_ASSERT(0 == cvar->lock->notified.length);
     thred->waiting = NULL;  /* and now we're not */
     if (thred->state & PT_THREAD_ABORTED) goto aborted;
     return (rv == 0) ? PR_SUCCESS : PR_FAILURE;
 
 aborted:
     PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);
@@ -408,21 +408,21 @@ PR_IMPLEMENT(PRMonitor*) PR_NewMonitor(v
     {
         PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
         return NULL;
     }
     mon = PR_NEWZAP(PRMonitor);
     if (mon != NULL)
     {
         int rv;
-        rv = PTHREAD_MUTEX_INIT(mon->lock.mutex, _pt_mattr); 
+        rv = _PT_PTHREAD_MUTEX_INIT(mon->lock.mutex, _pt_mattr); 
         PR_ASSERT(0 == rv);
 
         mon->cvar = cvar;
-        rv = PTHREAD_COND_INIT(mon->cvar->cv, _pt_cvar_attr); 
+        rv = _PT_PTHREAD_COND_INIT(mon->cvar->cv, _pt_cvar_attr); 
         PR_ASSERT(0 == rv);
         mon->entryCount = 0;
         mon->cvar->lock = &mon->lock;
         if (0 != rv)
         {
             PR_DELETE(mon);
             PR_DELETE(cvar);
             mon = NULL;
@@ -473,109 +473,109 @@ PR_IMPLEMENT(void) PR_EnterMonitor(PRMon
     if (1 == rv)
 #else
     if (0 == rv)
 #endif
     {
         /* I now have the lock - I can play in the sandbox */
         /* could/should/would not have gotten lock if entries != 0 */
         PR_ASSERT(0 == mon->entryCount);
-        PR_ASSERT(PTHREAD_THR_HANDLE_IS_ZERO(mon->lock.owner));
-        PTHREAD_COPY_THR_HANDLE(pthread_self(), mon->lock.owner);
-        PTHREAD_COPY_THR_HANDLE(self, mon->owner);
+        PR_ASSERT(_PT_PTHREAD_THR_HANDLE_IS_ZERO(mon->lock.owner));
+        _PT_PTHREAD_COPY_THR_HANDLE(pthread_self(), mon->lock.owner);
+        _PT_PTHREAD_COPY_THR_HANDLE(self, mon->owner);
     }
     else
     {
         PR_ASSERT(PT_TRYLOCK_BUSY == rv);  /* and if it isn't? */
         /* somebody has it locked - is it me? */
         if (!pthread_equal(mon->owner, self))
         {
             /* it's not me - this should block */
             PR_Lock(&mon->lock);
             /* and now I have the lock */
             PR_ASSERT(0 == mon->entryCount);
-            PTHREAD_COPY_THR_HANDLE(self, mon->owner);
+            _PT_PTHREAD_COPY_THR_HANDLE(self, mon->owner);
         }
     }
     mon->entryCount += 1;
 }  /* PR_EnterMonitor */
 
 PR_IMPLEMENT(PRStatus) PR_ExitMonitor(PRMonitor *mon)
 {
     pthread_t self = pthread_self();
 
     PR_ASSERT(mon != NULL);
     /* The lock better be that - locked */
-    PR_ASSERT(PTHREAD_MUTEX_IS_LOCKED(mon->lock.mutex));
+    PR_ASSERT(_PT_PTHREAD_MUTEX_IS_LOCKED(mon->lock.mutex));
     /* we'd better be the owner */
     PR_ASSERT(pthread_equal(mon->owner, self));
     if (!pthread_equal(mon->owner, self))
         return PR_FAILURE;
 
     /* if it's locked and we have it, then the entries should be > 0 */
     PR_ASSERT(mon->entryCount > 0);
     mon->entryCount -= 1;  /* reduce by one */
     if (mon->entryCount == 0)
     {
         /* and if it transitioned to zero - unlock */
-        PTHREAD_ZERO_THR_HANDLE(mon->owner);  /* make the owner unknown */
+        _PT_PTHREAD_ZERO_THR_HANDLE(mon->owner);  /* make the owner unknown */
         PR_Unlock(&mon->lock);
     }
     return PR_SUCCESS;
 }  /* PR_ExitMonitor */
 
 PR_IMPLEMENT(PRStatus) PR_Wait(PRMonitor *mon, PRIntervalTime timeout)
 {
     PRStatus rv;
     PRInt16 saved_entries;
     pthread_t saved_owner;
 
     PR_ASSERT(mon != NULL);
     /* we'd better be locked */
-    PR_ASSERT(PTHREAD_MUTEX_IS_LOCKED(mon->lock.mutex));
+    PR_ASSERT(_PT_PTHREAD_MUTEX_IS_LOCKED(mon->lock.mutex));
     /* and the entries better be positive */
     PR_ASSERT(mon->entryCount > 0);
     /* and it better be by us */
     PR_ASSERT(pthread_equal(mon->owner, pthread_self()));
 
     /* tuck these away 'till later */
     saved_entries = mon->entryCount; 
     mon->entryCount = 0;
-    PTHREAD_COPY_THR_HANDLE(mon->owner, saved_owner);
-    PTHREAD_ZERO_THR_HANDLE(mon->owner);
+    _PT_PTHREAD_COPY_THR_HANDLE(mon->owner, saved_owner);
+    _PT_PTHREAD_ZERO_THR_HANDLE(mon->owner);
     
     rv = PR_WaitCondVar(mon->cvar, timeout);
 
     /* reinstate the intresting information */
     mon->entryCount = saved_entries;
-    PTHREAD_COPY_THR_HANDLE(saved_owner, mon->owner);
+    _PT_PTHREAD_COPY_THR_HANDLE(saved_owner, mon->owner);
 
     return rv;
 }  /* PR_Wait */
 
 PR_IMPLEMENT(PRStatus) PR_Notify(PRMonitor *mon)
 {
     PR_ASSERT(NULL != mon);
     /* we'd better be locked */
-    PR_ASSERT(PTHREAD_MUTEX_IS_LOCKED(mon->lock.mutex));
+    PR_ASSERT(_PT_PTHREAD_MUTEX_IS_LOCKED(mon->lock.mutex));
     /* and the entries better be positive */
     PR_ASSERT(mon->entryCount > 0);
     /* and it better be by us */
     PR_ASSERT(pthread_equal(mon->owner, pthread_self()));
 
     pt_PostNotifyToCvar(mon->cvar, PR_FALSE);
 
     return PR_SUCCESS;
 }  /* PR_Notify */
 
 PR_IMPLEMENT(PRStatus) PR_NotifyAll(PRMonitor *mon)
 {
     PR_ASSERT(mon != NULL);
     /* we'd better be locked */
-    PR_ASSERT(PTHREAD_MUTEX_IS_LOCKED(mon->lock.mutex));
+    PR_ASSERT(_PT_PTHREAD_MUTEX_IS_LOCKED(mon->lock.mutex));
     /* and the entries better be positive */
     PR_ASSERT(mon->entryCount > 0);
     /* and it better be by us */
     PR_ASSERT(pthread_equal(mon->owner, pthread_self()));
 
     pt_PostNotifyToCvar(mon->cvar, PR_TRUE);
 
     return PR_SUCCESS;
@@ -657,36 +657,36 @@ PR_IMPLEMENT(PRSemaphore*) PR_NewSem(PRU
 
 #include "prpdce.h"
 
 PR_IMPLEMENT(PRStatus) PRP_TryLock(PRLock *lock)
 {
     PRIntn rv = pthread_mutex_trylock(&lock->mutex);
     if (rv == PT_TRYLOCK_SUCCESS)
     {
-        PR_ASSERT(PTHREAD_THR_HANDLE_IS_ZERO(lock->owner));
-        PTHREAD_COPY_THR_HANDLE(pthread_self(), lock->owner); 
+        PR_ASSERT(_PT_PTHREAD_THR_HANDLE_IS_ZERO(lock->owner));
+        _PT_PTHREAD_COPY_THR_HANDLE(pthread_self(), lock->owner); 
     }
     else
-        PR_ASSERT(!PTHREAD_THR_HANDLE_IS_ZERO(lock->owner));
+        PR_ASSERT(!_PT_PTHREAD_THR_HANDLE_IS_ZERO(lock->owner));
     /* XXX set error code? */
     return (PT_TRYLOCK_SUCCESS == rv) ? PR_SUCCESS : PR_FAILURE;
 }  /* PRP_TryLock */
 
 PR_IMPLEMENT(PRCondVar*) PRP_NewNakedCondVar()
 {
     PRCondVar *cv;
 
     if (!_pr_initialized) _PR_ImplicitInitialization();
 
     cv = PR_NEW(PRCondVar);
     if (cv != NULL)
     {
         int rv;
-        rv = PTHREAD_COND_INIT(cv->cv, _pt_cvar_attr); 
+        rv = _PT_PTHREAD_COND_INIT(cv->cv, _pt_cvar_attr); 
         PR_ASSERT(0 == rv);
         cv->lock = _PR_NAKED_CV_LOCK;
     }
     return cv;
 }  /* PRP_NewNakedCondVar */
 
 PR_IMPLEMENT(void) PRP_DestroyNakedCondVar(PRCondVar *cvar)
 {
@@ -699,17 +699,17 @@ PR_IMPLEMENT(void) PRP_DestroyNakedCondV
 }  /* PRP_DestroyNakedCondVar */
 
 PR_IMPLEMENT(PRStatus) PRP_NakedWait(
     PRCondVar *cvar, PRLock *ml, PRIntervalTime timeout)
 {
     PRIntn rv;
     PR_ASSERT(cvar != NULL);
     /* XXX do we really want to assert this in a naked wait? */
-    PR_ASSERT(PTHREAD_MUTEX_IS_LOCKED(ml->mutex));
+    PR_ASSERT(_PT_PTHREAD_MUTEX_IS_LOCKED(ml->mutex));
     if (timeout == PR_INTERVAL_NO_TIMEOUT)
         rv = pthread_cond_wait(&cvar->cv, &ml->mutex);
     else
         rv = pt_TimedWait(&cvar->cv, &ml->mutex, timeout);
     return (rv == 0) ? PR_SUCCESS : PR_FAILURE;
 }  /* PRP_NakedWait */
 
 PR_IMPLEMENT(PRStatus) PRP_NakedNotify(PRCondVar *cvar)
--- a/pr/src/pthreads/ptthread.c
+++ b/pr/src/pthreads/ptthread.c
@@ -250,17 +250,17 @@ static PRThread* _PR_CreateThread(
 
     if (!_pr_initialized) _PR_ImplicitInitialization();
 
     if ((PRIntn)PR_PRIORITY_FIRST > (PRIntn)priority)
         priority = PR_PRIORITY_FIRST;
     else if ((PRIntn)PR_PRIORITY_LAST < (PRIntn)priority)
         priority = PR_PRIORITY_LAST;
 
-    rv = PTHREAD_ATTR_INIT(&tattr);
+    rv = _PT_PTHREAD_ATTR_INIT(&tattr);
     PR_ASSERT(0 == rv);
 
     if (EPERM != pt_schedpriv)
     {
 #if !defined(_PR_DCETHREADS) && defined(_POSIX_THREAD_PRIORITY_SCHEDULING)
         struct sched_param schedule;
 #endif
 
@@ -376,17 +376,17 @@ static PRThread* _PR_CreateThread(
         else pt_book.user += 1;
         PR_Unlock(pt_book.ml);
 
         /*
          * We pass a pointer to a local copy (instead of thred->id)
          * to pthread_create() because who knows what wacky things
          * pthread_create() may be doing to its argument.
          */
-        rv = PTHREAD_CREATE(&id, tattr, _pt_root, thred);
+        rv = _PT_PTHREAD_CREATE(&id, tattr, _pt_root, thred);
 
 #if !defined(_PR_DCETHREADS)
         if (EPERM == rv)
         {
 #if defined(IRIX)
         	if (PR_GLOBAL_BOUND_THREAD == scope) {
 				/*
 				 * SCOPE_SYSTEM requires appropriate privilege
@@ -402,17 +402,17 @@ static PRThread* _PR_CreateThread(
             PR_LOG(_pr_thread_lm, PR_LOG_MIN,
                 ("_PR_CreateThread: no thread scheduling privilege"));
             /* Try creating the thread again without setting priority. */
 #if defined(_POSIX_THREAD_PRIORITY_SCHEDULING)
             rv = pthread_attr_setinheritsched(&tattr, PTHREAD_INHERIT_SCHED);
             PR_ASSERT(0 == rv);
 #endif
 #endif	/* IRIX */
-            rv = PTHREAD_CREATE(&id, tattr, _pt_root, thred);
+            rv = _PT_PTHREAD_CREATE(&id, tattr, _pt_root, thred);
         }
 #endif
 
         if (0 != rv)
         {
 #if defined(_PR_DCETHREADS)
             PRIntn oserr = errno;
 #else
@@ -448,17 +448,17 @@ static PRThread* _PR_CreateThread(
             PR_Lock(pt_book.ml);
             thred->okToDelete = PR_TRUE;
             PR_NotifyAllCondVar(pt_book.cv);
             PR_Unlock(pt_book.ml);
         }
     }
 
 done:
-    rv = PTHREAD_ATTR_DESTROY(&tattr);
+    rv = _PT_PTHREAD_ATTR_DESTROY(&tattr);
     PR_ASSERT(0 == rv);
 
     return thred;
 }  /* _PR_CreateThread */
 
 PR_IMPLEMENT(PRThread*) PR_CreateThread(
     PRThreadType type, void (*start)(void *arg), void *arg,
     PRThreadPriority priority, PRThreadScope scope,
@@ -554,17 +554,17 @@ PR_IMPLEMENT(PRStatus) PR_JoinThread(PRT
 PR_IMPLEMENT(void) PR_DetachThread() { }  /* PR_DetachThread */
 
 PR_IMPLEMENT(PRThread*) PR_GetCurrentThread()
 {
     void *thred;
 
     if (!_pr_initialized) _PR_ImplicitInitialization();
 
-    PTHREAD_GETSPECIFIC(pt_book.key, thred);
+    _PT_PTHREAD_GETSPECIFIC(pt_book.key, thred);
     if (NULL == thred) thred = pt_AttachThread();
     PR_ASSERT(NULL != thred);
     return (PRThread*)thred;
 }  /* PR_GetCurrentThread */
 
 PR_IMPLEMENT(PRThreadScope) PR_GetThreadScope(const PRThread *thred)
 {
     return (thred->state & PT_THREAD_BOUND) ?
@@ -629,17 +629,17 @@ PR_IMPLEMENT(void) PR_SetThreadPriority(
 #if 0
 PR_IMPLEMENT(PRStatus) PR_NewThreadPrivateIndex(
     PRUintn *newIndex, PRThreadPrivateDTOR destructor)
 {
     int rv;
 
     if (!_pr_initialized) _PR_ImplicitInitialization();
 
-    rv = PTHREAD_KEY_CREATE((pthread_key_t*)newIndex, destructor);
+    rv = _PT_PTHREAD_KEY_CREATE((pthread_key_t*)newIndex, destructor);
 
     if (0 == rv)
     {
         PR_Lock(pt_book.ml);
         if (*newIndex >= pt_book.highwater)
             pt_book.highwater = *newIndex + 1;
         PR_Unlock(pt_book.ml);
         return PR_SUCCESS;
@@ -663,17 +663,17 @@ PR_IMPLEMENT(PRStatus) PR_SetThreadPriva
     PR_SetError(PR_UNKNOWN_ERROR, rv);
     return PR_FAILURE;
 }  /* PR_SetThreadPrivate */
 
 PR_IMPLEMENT(void*) PR_GetThreadPrivate(PRUintn index)
 {
     void *result = NULL;
     if ((pthread_key_t)index < pt_book.highwater)
-        PTHREAD_GETSPECIFIC((pthread_key_t)index, result);
+        _PT_PTHREAD_GETSPECIFIC((pthread_key_t)index, result);
     return result;
 }  /* PR_GetThreadPrivate */
 #endif
 
 PR_IMPLEMENT(PRStatus) PR_Interrupt(PRThread *thred)
 {
     /*
     ** If the target thread indicates that it's waiting,
@@ -726,17 +726,17 @@ PR_IMPLEMENT(PRStatus) PR_Yield()
 PR_IMPLEMENT(PRStatus) PR_Sleep(PRIntervalTime ticks)
 {
     PRStatus rv;
 
     if (!_pr_initialized) _PR_ImplicitInitialization();
 
     if (PR_INTERVAL_NO_WAIT == ticks)
     {
-        PTHREAD_YIELD();
+        _PT_PTHREAD_YIELD();
         rv = PR_SUCCESS;
     }
     else
     {
         PRCondVar *cv;
         PRIntervalTime timein;
 
         timein = PR_IntervalNow();
@@ -849,17 +849,17 @@ void _PR_InitThreads(
      * NB: The destructor logic seems to have a bug so it isn't used.
      * NBB: Oh really? I'm going to give it a spin - AOF 19 June 1998.
      * More info - the problem is that pthreads calls the destructor
      * eagerly as the thread returns from its root, rather than lazily
      * after the thread is joined. Therefore, threads that are joining
      * and holding PRThread references are actually holding pointers to
      * nothing.
      */
-    rv = PTHREAD_KEY_CREATE(&pt_book.key, _pt_thread_death);
+    rv = _PT_PTHREAD_KEY_CREATE(&pt_book.key, _pt_thread_death);
     PR_ASSERT(0 == rv);
     rv = pthread_setspecific(pt_book.key, thred);
     PR_ASSERT(0 == rv);    
     PR_SetThreadPriority(thred, priority);
 }  /* _PR_InitThreads */
 
 PR_IMPLEMENT(PRStatus) PR_Cleanup()
 {
--- a/pr/tests/attach.c
+++ b/pr/tests/attach.c
@@ -208,43 +208,43 @@ int main(int argc, char **argv)
     /*
      * Platform-specific code to create a native thread.  The native
      * thread will repeatedly call PR_AttachThread and PR_DetachThread.
      * The primordial thread waits for this new thread to finish.
      */
 
 #ifdef _PR_PTHREADS
 
-    rv = PTHREAD_ATTR_INIT(&attr);
+    rv = _PT_PTHREAD_ATTR_INIT(&attr);
     if (debug_mode) PR_ASSERT(0 == rv);
 	else if (0 != rv) {
 		failed_already=1;
 		goto exit_now;
 	}
 	
 #ifndef _PR_DCETHREADS
     rv = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
     if (debug_mode) PR_ASSERT(0 == rv);
 	else if (0 != rv) {
 		failed_already=1;
 		goto exit_now;
 	}
 #endif  /* !_PR_DCETHREADS */
-    rv = PTHREAD_CREATE(&threadID, attr, threadStartFunc, NULL);
+    rv = _PT_PTHREAD_CREATE(&threadID, attr, threadStartFunc, NULL);
     if (rv != 0) {
 			fprintf(stderr, "thread creation failed: error code %d\n", rv);
 			failed_already=1;
 			goto exit_now;
 	}
 	else {
 		if (debug_mode)
 			printf ("thread creation succeeded \n");
 
 	}
-    rv = PTHREAD_ATTR_DESTROY(&attr);
+    rv = _PT_PTHREAD_ATTR_DESTROY(&attr);
     if (debug_mode) PR_ASSERT(0 == rv);
 	else if (0 != rv) {
 		failed_already=1;
 		goto exit_now;
 	}
     rv = pthread_join(threadID, NULL);
     if (debug_mode) PR_ASSERT(0 == rv);
 	else if (0 != rv) {
--- a/pr/tests/foreign.c
+++ b/pr/tests/foreign.c
@@ -127,29 +127,29 @@ static PRStatus CreateThread(StartFn sta
             pthread_t id;
             pthread_attr_t tattr;
             StartObject *start_object;
             start_object = PR_NEW(StartObject);
             PR_ASSERT(NULL != start_object);
             start_object->start = start;
             start_object->arg = arg;
 
-            rv = PTHREAD_ATTR_INIT(&tattr);
+            rv = _PT_PTHREAD_ATTR_INIT(&tattr);
             PR_ASSERT(0 == rv);
 
             rv = pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED);
             PR_ASSERT(0 == rv);
 
 #if !defined(LINUX)
             rv = pthread_attr_setstacksize(&tattr, 64 * 1024);
             PR_ASSERT(0 == rv);
 #endif
 
-            rv = PTHREAD_CREATE(&id, tattr, pthread_start, start_object);
-            (void)PTHREAD_ATTR_DESTROY(&tattr);
+            rv = _PT_PTHREAD_CREATE(&id, tattr, pthread_start, start_object);
+            (void)_PT_PTHREAD_ATTR_DESTROY(&tattr);
             return (0 == rv) ? PR_SUCCESS : PR_FAILURE;
         }
 #else
         PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
         rv = PR_FAILURE;
         break;
 #endif /* defined(_PR_PTHREADS) && !defined(_PR_DCETHREADS) */
 
--- a/pr/tests/provider.c
+++ b/pr/tests/provider.c
@@ -717,29 +717,29 @@ static PRStatus NewThread(
             pthread_t id;
             pthread_attr_t tattr;
             StartObject *start_object;
             start_object = PR_NEW(StartObject);
             PR_ASSERT(NULL != start_object);
             start_object->start = start;
             start_object->arg = arg;
 
-            rv = PTHREAD_ATTR_INIT(&tattr);
+            rv = _PT_PTHREAD_ATTR_INIT(&tattr);
             PR_ASSERT(0 == rv);
 
             rv = pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED);
             PR_ASSERT(0 == rv);
 
 #if !defined(LINUX)
             rv = pthread_attr_setstacksize(&tattr, 64 * 1024);
             PR_ASSERT(0 == rv);
 #endif
 
-            rv = PTHREAD_CREATE(&id, tattr, pthread_start, start_object);
-            (void)PTHREAD_ATTR_DESTROY(&tattr);
+            rv = _PT_PTHREAD_CREATE(&id, tattr, pthread_start, start_object);
+            (void)_PT_PTHREAD_ATTR_DESTROY(&tattr);
             return (0 == rv) ? PR_SUCCESS : PR_FAILURE;
         }
 #else
         PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
         rv = PR_FAILURE;
 #endif /* defined(_PR_PTHREADS) && !defined(_PR_DCETHREADS) */
         break;