NSPR no longer defines symbols with the PTHREAD prefix. Bugzilla #9907.
git-svn-id: svn://10.0.0.236/trunk@39528 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
123ee88fd9
commit
b5f35458f2
@ -32,13 +32,13 @@
|
||||
* 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
|
||||
@ -55,29 +55,29 @@
|
||||
* 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
|
||||
@ -86,45 +86,45 @@
|
||||
* 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
|
||||
|
||||
/*
|
||||
@ -167,8 +167,8 @@
|
||||
#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
|
||||
@ -212,24 +212,24 @@
|
||||
#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; \
|
||||
@ -238,9 +238,9 @@ extern int (*_PT_aix_yield_fcn)();
|
||||
#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_ */
|
||||
|
||||
@ -168,11 +168,11 @@ PR_IMPLEMENT(PRStatus) _PR_MallocInit(void)
|
||||
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 */
|
||||
|
||||
@ -52,10 +52,10 @@ static pthread_t pt_zero_tid; /* a null pthread_t (pthread_t is a struct
|
||||
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);
|
||||
}
|
||||
|
||||
@ -135,7 +135,7 @@ PR_IMPLEMENT(PRLock*) PR_NewLock(void)
|
||||
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)
|
||||
@ -148,7 +148,7 @@ 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);
|
||||
@ -168,8 +168,8 @@ PR_IMPLEMENT(void) PR_Lock(PRLock *lock)
|
||||
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
|
||||
@ -180,13 +180,13 @@ 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);
|
||||
@ -258,7 +258,7 @@ static void pt_PostNotifyToCvar(PRCondVar *cvar, PRBool broadcast)
|
||||
_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)
|
||||
{
|
||||
@ -298,7 +298,7 @@ PR_IMPLEMENT(PRCondVar*) PR_NewCondVar(PRLock *lock)
|
||||
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;
|
||||
@ -329,7 +329,7 @@ PR_IMPLEMENT(PRStatus) PR_WaitCondVar(PRCondVar *cvar, PRIntervalTime timeout)
|
||||
|
||||
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()));
|
||||
|
||||
@ -354,7 +354,7 @@ PR_IMPLEMENT(PRStatus) PR_WaitCondVar(PRCondVar *cvar, PRIntervalTime timeout)
|
||||
/*
|
||||
* 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);
|
||||
@ -362,8 +362,8 @@ PR_IMPLEMENT(PRStatus) PR_WaitCondVar(PRCondVar *cvar, PRIntervalTime timeout)
|
||||
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 */
|
||||
@ -413,11 +413,11 @@ PR_IMPLEMENT(PRMonitor*) PR_NewMonitor(void)
|
||||
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;
|
||||
@ -478,9 +478,9 @@ PR_IMPLEMENT(void) PR_EnterMonitor(PRMonitor *mon)
|
||||
/* 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
|
||||
{
|
||||
@ -492,7 +492,7 @@ PR_IMPLEMENT(void) PR_EnterMonitor(PRMonitor *mon)
|
||||
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;
|
||||
@ -504,7 +504,7 @@ PR_IMPLEMENT(PRStatus) PR_ExitMonitor(PRMonitor *mon)
|
||||
|
||||
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))
|
||||
@ -516,7 +516,7 @@ PR_IMPLEMENT(PRStatus) PR_ExitMonitor(PRMonitor *mon)
|
||||
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;
|
||||
@ -530,7 +530,7 @@ PR_IMPLEMENT(PRStatus) PR_Wait(PRMonitor *mon, PRIntervalTime timeout)
|
||||
|
||||
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 */
|
||||
@ -539,14 +539,14 @@ PR_IMPLEMENT(PRStatus) PR_Wait(PRMonitor *mon, PRIntervalTime timeout)
|
||||
/* 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 */
|
||||
@ -555,7 +555,7 @@ 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 */
|
||||
@ -570,7 +570,7 @@ 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 */
|
||||
@ -662,11 +662,11 @@ 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 */
|
||||
@ -681,7 +681,7 @@ PR_IMPLEMENT(PRCondVar*) PRP_NewNakedCondVar()
|
||||
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;
|
||||
}
|
||||
@ -704,7 +704,7 @@ PR_IMPLEMENT(PRStatus) PRP_NakedWait(
|
||||
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
|
||||
|
||||
@ -255,7 +255,7 @@ static PRThread* _PR_CreateThread(
|
||||
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)
|
||||
@ -381,7 +381,7 @@ static PRThread* _PR_CreateThread(
|
||||
* 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)
|
||||
@ -407,7 +407,7 @@ static PRThread* _PR_CreateThread(
|
||||
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
|
||||
|
||||
@ -453,7 +453,7 @@ static PRThread* _PR_CreateThread(
|
||||
}
|
||||
|
||||
done:
|
||||
rv = PTHREAD_ATTR_DESTROY(&tattr);
|
||||
rv = _PT_PTHREAD_ATTR_DESTROY(&tattr);
|
||||
PR_ASSERT(0 == rv);
|
||||
|
||||
return thred;
|
||||
@ -559,7 +559,7 @@ PR_IMPLEMENT(PRThread*) PR_GetCurrentThread()
|
||||
|
||||
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;
|
||||
@ -634,7 +634,7 @@ PR_IMPLEMENT(PRStatus) PR_NewThreadPrivateIndex(
|
||||
|
||||
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)
|
||||
{
|
||||
@ -668,7 +668,7 @@ 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
|
||||
@ -731,7 +731,7 @@ PR_IMPLEMENT(PRStatus) PR_Sleep(PRIntervalTime ticks)
|
||||
|
||||
if (PR_INTERVAL_NO_WAIT == ticks)
|
||||
{
|
||||
PTHREAD_YIELD();
|
||||
_PT_PTHREAD_YIELD();
|
||||
rv = PR_SUCCESS;
|
||||
}
|
||||
else
|
||||
@ -854,7 +854,7 @@ void _PR_InitThreads(
|
||||
* 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);
|
||||
|
||||
@ -213,7 +213,7 @@ int main(int argc, char **argv)
|
||||
|
||||
#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;
|
||||
@ -228,7 +228,7 @@ int main(int argc, char **argv)
|
||||
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;
|
||||
@ -239,7 +239,7 @@ int main(int argc, char **argv)
|
||||
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;
|
||||
|
||||
@ -132,7 +132,7 @@ static PRStatus CreateThread(StartFn start, void *arg)
|
||||
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);
|
||||
@ -143,8 +143,8 @@ static PRStatus CreateThread(StartFn start, void *arg)
|
||||
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
|
||||
|
||||
@ -722,7 +722,7 @@ static PRStatus NewThread(
|
||||
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);
|
||||
@ -733,8 +733,8 @@ static PRStatus NewThread(
|
||||
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user