Adapt to pthread__assert() and remove local debug toggle.
This commit is contained in:
parent
8bcff70bb0
commit
53827081be
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pthread_alarms.c,v 1.3 2003/01/18 18:45:53 christos Exp $ */
|
||||
/* $NetBSD: pthread_alarms.c,v 1.4 2003/02/15 04:37:04 nathanw Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
@ -36,7 +36,6 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <err.h>
|
||||
#include <sys/time.h>
|
||||
#include <stdlib.h>
|
||||
@ -48,8 +47,6 @@ timer_t pthread_alarmtimer;
|
||||
PTQ_HEAD(, pt_alarm_t) pthread_alarmqueue = PTQ_HEAD_INITIALIZER;
|
||||
pthread_spin_t pthread_alarmqlock;
|
||||
|
||||
#define PTHREAD_ALARM_DEBUG
|
||||
|
||||
#ifdef PTHREAD_ALARM_DEBUG
|
||||
#define SDPRINTF(x) DPRINTF(x)
|
||||
#else
|
||||
@ -136,7 +133,7 @@ pthread__alarm_del(pthread_t self, struct pt_alarm_t *alarm)
|
||||
self, it.it_value.tv_sec, it.it_value.tv_nsec/1000));
|
||||
retval = timer_settime(pthread_alarmtimer, TIMER_ABSTIME, &it,
|
||||
NULL);
|
||||
assert(retval == 0);
|
||||
pthread__assert(retval == 0);
|
||||
if (retval)
|
||||
err(1, "timer_settime");
|
||||
}
|
||||
@ -194,7 +191,7 @@ pthread__alarm_process(pthread_t self, void *arg)
|
||||
SDPRINTF(("(pro %p) resetting alarm timer to %d.%09d\n", self,
|
||||
it.it_value.tv_sec, it.it_value.tv_nsec));
|
||||
retval = timer_settime(pthread_alarmtimer, TIMER_ABSTIME, &it, NULL);
|
||||
assert(retval == 0);
|
||||
pthread__assert(retval == 0);
|
||||
if (retval)
|
||||
err(1, "timer_settime");
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pthread_lock.c,v 1.4 2003/01/22 13:52:03 scw Exp $ */
|
||||
/* $NetBSD: pthread_lock.c,v 1.5 2003/02/15 04:37:04 nathanw Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
@ -40,16 +40,13 @@
|
||||
#include <sys/ras.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "pthread.h"
|
||||
#include "pthread_int.h"
|
||||
|
||||
#undef PTHREAD_SPIN_DEBUG
|
||||
|
||||
#ifdef PTHREAD_SPIN_DEBUG
|
||||
#ifdef PTHREAD_SPIN_DEBUG_PRINT
|
||||
#define SDPRINTF(x) DPRINTF(x)
|
||||
#else
|
||||
#define SDPRINTF(x)
|
||||
@ -176,10 +173,7 @@ pthread_spinlock(pthread_t thread, pthread_spin_t *lock)
|
||||
SDPRINTF(("(pthread_spinlock %p) incrementing spinlock %p (count %d)\n",
|
||||
thread, lock, thread->pt_spinlocks));
|
||||
#ifdef PTHREAD_SPIN_DEBUG
|
||||
if(!(thread->pt_spinlocks >= 0)) {
|
||||
(void)kill(getpid(), SIGABRT);
|
||||
_exit(1);
|
||||
}
|
||||
pthread__assert(thread->pt_spinlocks >= 0);
|
||||
#endif
|
||||
++thread->pt_spinlocks;
|
||||
|
||||
@ -256,10 +250,7 @@ pthread_spinunlock(pthread_t thread, pthread_spin_t *lock)
|
||||
thread, lock, thread->pt_spinlocks));
|
||||
--thread->pt_spinlocks;
|
||||
#ifdef PTHREAD_SPIN_DEBUG
|
||||
if (!(thread->pt_spinlocks >= 0)) {
|
||||
(void)kill(getpid(), SIGABRT);
|
||||
_exit(1);
|
||||
}
|
||||
pthread__assert(thread->pt_spinlocks >= 0);
|
||||
#endif
|
||||
PTHREADD_ADD(PTHREADD_SPINUNLOCKS);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pthread_run.c,v 1.6 2003/01/31 12:27:19 tron Exp $ */
|
||||
/* $NetBSD: pthread_run.c,v 1.7 2003/02/15 04:37:04 nathanw Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
@ -37,14 +37,11 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <ucontext.h>
|
||||
|
||||
#include "pthread.h"
|
||||
#include "pthread_int.h"
|
||||
|
||||
#undef PTHREAD_RUN_DEBUG
|
||||
|
||||
#ifdef PTHREAD_RUN_DEBUG
|
||||
#define SDPRINTF(x) DPRINTF(x)
|
||||
#else
|
||||
@ -111,13 +108,13 @@ pthread__next(pthread_t self)
|
||||
pthread_spinlock(self, &pthread__runqueue_lock);
|
||||
next = PTQ_FIRST(&pthread__runqueue);
|
||||
if (next) {
|
||||
assert(next->pt_type == PT_THREAD_NORMAL);
|
||||
pthread__assert(next->pt_type == PT_THREAD_NORMAL);
|
||||
PTQ_REMOVE(&pthread__runqueue, next, pt_runq);
|
||||
} else {
|
||||
next = PTQ_FIRST(&pthread__idlequeue);
|
||||
assert(next != 0);
|
||||
pthread__assert(next != 0);
|
||||
PTQ_REMOVE(&pthread__idlequeue, next, pt_runq);
|
||||
assert(next->pt_type == PT_THREAD_IDLE);
|
||||
pthread__assert(next->pt_type == PT_THREAD_IDLE);
|
||||
SDPRINTF(("(next %p) returning idle thread %p\n", self, next));
|
||||
}
|
||||
pthread_spinunlock(self, &pthread__runqueue_lock);
|
||||
@ -133,8 +130,8 @@ pthread__sched(pthread_t self, pthread_t thread)
|
||||
|
||||
SDPRINTF(("(sched %p) scheduling %p\n", self, thread));
|
||||
thread->pt_state = PT_STATE_RUNNABLE;
|
||||
assert (thread->pt_type == PT_THREAD_NORMAL);
|
||||
assert (thread->pt_spinlocks == 0);
|
||||
pthread__assert (thread->pt_type == PT_THREAD_NORMAL);
|
||||
pthread__assert (thread->pt_spinlocks == 0);
|
||||
#ifdef PTHREAD__DEBUG
|
||||
thread->rescheds++;
|
||||
#endif
|
||||
@ -153,8 +150,8 @@ pthread__sched_sleepers(pthread_t self, struct pthread_queue_t *threadq)
|
||||
PTQ_FOREACH(thread, threadq, pt_sleep) {
|
||||
SDPRINTF(("(sched_sleepers %p) scheduling %p\n", self, thread));
|
||||
thread->pt_state = PT_STATE_RUNNABLE;
|
||||
assert (thread->pt_type == PT_THREAD_NORMAL);
|
||||
assert (thread->pt_spinlocks == 0);
|
||||
pthread__assert (thread->pt_type == PT_THREAD_NORMAL);
|
||||
pthread__assert (thread->pt_spinlocks == 0);
|
||||
#ifdef PTHREAD__DEBUG
|
||||
thread->rescheds++;
|
||||
#endif
|
||||
@ -222,7 +219,7 @@ pthread__sched_bulk(pthread_t self, pthread_t qhead)
|
||||
pthread_spinlock(self, &pthread__runqueue_lock);
|
||||
for ( ; qhead && (qhead != self) ; qhead = next) {
|
||||
next = qhead->pt_next;
|
||||
assert (qhead->pt_spinlocks == 0);
|
||||
pthread__assert (qhead->pt_spinlocks == 0);
|
||||
if (qhead->pt_type == PT_THREAD_NORMAL) {
|
||||
qhead->pt_state = PT_STATE_RUNNABLE;
|
||||
qhead->pt_next = NULL;
|
||||
@ -231,8 +228,8 @@ pthread__sched_bulk(pthread_t self, pthread_t qhead)
|
||||
qhead->rescheds++;
|
||||
#endif
|
||||
SDPRINTF(("(bulk %p) scheduling %p\n", self, qhead));
|
||||
assert(PTQ_LAST(&pthread__runqueue, pthread_queue_t) != qhead);
|
||||
assert(PTQ_FIRST(&pthread__runqueue) != qhead);
|
||||
pthread__assert(PTQ_LAST(&pthread__runqueue, pthread_queue_t) != qhead);
|
||||
pthread__assert(PTQ_FIRST(&pthread__runqueue) != qhead);
|
||||
PTQ_INSERT_TAIL(&pthread__runqueue, qhead, pt_runq);
|
||||
} else if (qhead->pt_type == PT_THREAD_IDLE) {
|
||||
qhead->pt_state = PT_STATE_RUNNABLE;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pthread_sa.c,v 1.5 2003/01/30 01:04:50 nathanw Exp $ */
|
||||
/* $NetBSD: pthread_sa.c,v 1.6 2003/02/15 04:37:04 nathanw Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
@ -36,7 +36,6 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <lwp.h>
|
||||
@ -52,8 +51,6 @@
|
||||
#include "pthread.h"
|
||||
#include "pthread_int.h"
|
||||
|
||||
#define PTHREAD_SA_DEBUG
|
||||
|
||||
#ifdef PTHREAD_SA_DEBUG
|
||||
#define SDPRINTF(x) DPRINTF(x)
|
||||
#else
|
||||
@ -197,21 +194,21 @@ pthread__upcall(int type, struct sa_t *sas[], int ev, int intr, void *arg)
|
||||
/* We don't send ourselves one of these. */
|
||||
default:
|
||||
/*CONSTCOND*/
|
||||
assert(0);
|
||||
pthread__assert(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* At this point everything on our list should be scheduled
|
||||
* (or was an upcall).
|
||||
*/
|
||||
assert(self->pt_spinlocks == 0);
|
||||
pthread__assert(self->pt_spinlocks == 0);
|
||||
next = pthread__next(self);
|
||||
next->pt_state = PT_STATE_RUNNING;
|
||||
SDPRINTF(("(up %p) switching to %p (uc: %p pc: %lx)\n",
|
||||
self, next, next->pt_uc, pthread__uc_pc(next->pt_uc)));
|
||||
pthread__upcall_switch(self, next);
|
||||
/*NOTREACHED*//*CONSTCOND*/
|
||||
assert(0);
|
||||
pthread__assert(0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -254,7 +251,7 @@ pthread__find_interrupted(struct sa_t *sas[], int nsas, pthread_t *qhead,
|
||||
for ( ; victim->pt_parent != NULL;
|
||||
victim = victim->pt_parent) {
|
||||
SDPRINTF((" parent %p", victim->pt_parent));
|
||||
assert(victim->pt_parent != victim);
|
||||
pthread__assert(victim->pt_parent != victim);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -273,7 +270,7 @@ pthread__find_interrupted(struct sa_t *sas[], int nsas, pthread_t *qhead,
|
||||
for ( ; victim->pt_parent != NULL;
|
||||
victim = victim->pt_parent) {
|
||||
SDPRINTF((" parent %p", victim->pt_parent));
|
||||
assert(victim->pt_parent != victim);
|
||||
pthread__assert(victim->pt_parent != victim);
|
||||
}
|
||||
|
||||
|
||||
@ -291,7 +288,7 @@ pthread__find_interrupted(struct sa_t *sas[], int nsas, pthread_t *qhead,
|
||||
for ( ; victim->pt_parent != NULL;
|
||||
victim = victim->pt_parent) {
|
||||
SDPRINTF((" parent %p", victim->pt_parent));
|
||||
assert(victim->pt_parent != victim);
|
||||
pthread__assert(victim->pt_parent != victim);
|
||||
}
|
||||
} else if (victim->pt_flags & PT_FLAG_IDLED) {
|
||||
/*
|
||||
@ -309,7 +306,7 @@ pthread__find_interrupted(struct sa_t *sas[], int nsas, pthread_t *qhead,
|
||||
|
||||
}
|
||||
}
|
||||
assert (victim != self);
|
||||
pthread__assert (victim != self);
|
||||
victim->pt_parent = self;
|
||||
victim->pt_next = next;
|
||||
next = victim;
|
||||
@ -459,7 +456,7 @@ pthread__resolve_locks(pthread_t self, pthread_t *intqueuep)
|
||||
}
|
||||
|
||||
if (switchto) {
|
||||
assert(switchto->pt_spinlocks == 0);
|
||||
pthread__assert(switchto->pt_spinlocks == 0);
|
||||
/*
|
||||
* Threads can have switchto set to themselves
|
||||
* if they hit new_preempt. Don't put them
|
||||
@ -549,7 +546,7 @@ pthread__recycle_bulk(pthread_t self, pthread_t qhead)
|
||||
printf("ret: %d threshold: %d\n",
|
||||
ret, recycle_threshold);
|
||||
/*CONSTCOND*/
|
||||
assert(0);
|
||||
pthread__assert(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -591,7 +588,7 @@ pthread__sa_recycle(pthread_t old, pthread_t new)
|
||||
SDPRINTF(("(recycle %p) recycled %d stacks\n", new, recycle_threshold));
|
||||
if (ret != recycle_threshold) {
|
||||
/*CONSTCOND*/
|
||||
assert(0);
|
||||
pthread__assert(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user