Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libpthread Adapt to pthread__assert() and remove local d...



details:   https://anonhg.NetBSD.org/src/rev/a8b7ea34b43b
branches:  trunk
changeset: 543040:a8b7ea34b43b
user:      nathanw <nathanw%NetBSD.org@localhost>
date:      Sat Feb 15 04:37:04 2003 +0000

description:
Adapt to pthread__assert() and remove local debug toggle.

diffstat:

 lib/libpthread/pthread_alarms.c |   9 +++------
 lib/libpthread/pthread_lock.c   |  17 ++++-------------
 lib/libpthread/pthread_run.c    |  25 +++++++++++--------------
 lib/libpthread/pthread_sa.c     |  25 +++++++++++--------------
 4 files changed, 29 insertions(+), 47 deletions(-)

diffs (292 lines):

diff -r 64fe78f6f291 -r a8b7ea34b43b lib/libpthread/pthread_alarms.c
--- a/lib/libpthread/pthread_alarms.c   Sat Feb 15 04:34:40 2003 +0000
+++ b/lib/libpthread/pthread_alarms.c   Sat Feb 15 04:37:04 2003 +0000
@@ -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 @@
 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 @@
                            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 @@
                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");
        }
diff -r 64fe78f6f291 -r a8b7ea34b43b lib/libpthread/pthread_lock.c
--- a/lib/libpthread/pthread_lock.c     Sat Feb 15 04:34:40 2003 +0000
+++ b/lib/libpthread/pthread_lock.c     Sat Feb 15 04:37:04 2003 +0000
@@ -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 @@
        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 @@
                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);
 
diff -r 64fe78f6f291 -r a8b7ea34b43b lib/libpthread/pthread_run.c
--- a/lib/libpthread/pthread_run.c      Sat Feb 15 04:34:40 2003 +0000
+++ b/lib/libpthread/pthread_run.c      Sat Feb 15 04:37:04 2003 +0000
@@ -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_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 @@
 
        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 @@
        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_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 @@
                        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;
diff -r 64fe78f6f291 -r a8b7ea34b43b lib/libpthread/pthread_sa.c
--- a/lib/libpthread/pthread_sa.c       Sat Feb 15 04:34:40 2003 +0000
+++ b/lib/libpthread/pthread_sa.c       Sat Feb 15 04:37:04 2003 +0000
@@ -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 @@
                /* 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 @@
                                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 @@
                                        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 @@
                                        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 @@
                                        
                        }
                }
-               assert (victim != self);
+               pthread__assert (victim != self);
                victim->pt_parent = self;
                victim->pt_next = next;
                next = victim;
@@ -459,7 +456,7 @@
                        }
 
                        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 @@
                                printf("ret: %d  threshold: %d\n",
                                    ret, recycle_threshold);
                                /*CONSTCOND*/
-                               assert(0);
+                               pthread__assert(0);
                        }
                }
        }
@@ -591,7 +588,7 @@
                SDPRINTF(("(recycle %p) recycled %d stacks\n", new, recycle_threshold));
                if (ret != recycle_threshold) {
                        /*CONSTCOND*/
-                       assert(0);
+                       pthread__assert(0);
                }
        }
 }



Home | Main Index | Thread Index | Old Index