From owner-p4-projects@FreeBSD.ORG Fri Apr 14 21:27:28 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 1855016A419; Fri, 14 Apr 2006 21:27:28 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E886816A417 for ; Fri, 14 Apr 2006 21:27:27 +0000 (UTC) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 98DF943D46 for ; Fri, 14 Apr 2006 21:27:27 +0000 (GMT) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k3ELRRIr034633 for ; Fri, 14 Apr 2006 21:27:27 GMT (envelope-from jb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k3ELRRrh034630 for perforce@freebsd.org; Fri, 14 Apr 2006 21:27:27 GMT (envelope-from jb@freebsd.org) Date: Fri, 14 Apr 2006 21:27:27 GMT Message-Id: <200604142127.k3ELRRrh034630@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jb@freebsd.org using -f From: John Birrell To: Perforce Change Reviews Cc: Subject: PERFORCE change 95271 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Apr 2006 21:27:28 -0000 http://perforce.freebsd.org/chv.cgi?CH=95271 Change 95271 by jb@jb_freebsd2 on 2006/04/14 21:26:28 Add some experimental (non-POSIX, non-portable) thread functions to check if a mutex or a rwlock is held. Solaris has these in it's non-standard thread implementation and they've implemented DTrace mostly using the non-standard threads, but with some pthreads thrown in... and to make matters worse, even non-POSIX pthread functions. Yuk. Solaris may well be standards compatible from an outside programmer's perspective, but it sure as hell isn't on the inside. Affected files ... .. //depot/projects/dtrace/src/include/pthread_np.h#2 edit .. //depot/projects/dtrace/src/lib/libpthread/pthread.map#2 edit .. //depot/projects/dtrace/src/lib/libpthread/thread/thr_mutex.c#2 edit .. //depot/projects/dtrace/src/lib/libpthread/thread/thr_rwlock.c#2 edit Differences ... ==== //depot/projects/dtrace/src/include/pthread_np.h#2 (text+ko) ==== @@ -49,8 +49,11 @@ int pthread_multi_np(void); int pthread_mutexattr_getkind_np(pthread_mutexattr_t); int pthread_mutexattr_setkind_np(pthread_mutexattr_t *, int); +int pthread_mutex_held_np(pthread_mutex_t *); void pthread_resume_all_np(void); int pthread_resume_np(pthread_t); +int pthread_rwlock_rdheld_np(pthread_rwlock_t *); +int pthread_rwlock_wrheld_np(pthread_rwlock_t *); void pthread_set_name_np(pthread_t, const char *); int pthread_single_np(void); void pthread_suspend_all_np(void); ==== //depot/projects/dtrace/src/lib/libpthread/pthread.map#2 (text+ko) ==== @@ -258,6 +258,7 @@ pthread_multi_np; pthread_mutex_destroy; pthread_mutex_getprioceiling; + pthread_mutex_held_np; pthread_mutex_init; pthread_mutex_lock; pthread_mutex_setprioceiling; @@ -280,6 +281,8 @@ pthread_resume_all_np; pthread_resume_np; pthread_rwlock_destroy; + pthread_rwlock_rdheld_np; + pthread_rwlock_wrheld_np; pthread_rwlock_init; pthread_rwlock_rdlock; pthread_rwlock_timedrdlock; ==== //depot/projects/dtrace/src/lib/libpthread/thread/thr_mutex.c#2 (text+ko) ==== @@ -1582,6 +1582,12 @@ } } +int +pthread_mutex_held_np(pthread_mutex_t *m) +{ + return((*m)->m_owner == _get_curthread()); +} + /* * This is called by the current thread when it wants to back out of a * mutex_lock in order to run a signal handler. ==== //depot/projects/dtrace/src/lib/libpthread/thread/thr_rwlock.c#2 (text+ko) ==== @@ -436,3 +436,15 @@ { return (rwlock_wrlock_common (rwlock, abstime)); } + +int +pthread_rwlock_rdheld_np(pthread_rwlock_t *rwlock) +{ + return((*rwlock)->state > 0); +} + +int +pthread_rwlock_wrheld_np(pthread_rwlock_t *rwlock) +{ + return((*rwlock)->state < 0); +}