Date: Mon, 02 Jul 2012 13:10:06 +0000 From: gmiller@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r238804 - in soc2012/gmiller/locking-head: . lib/libwitness Message-ID: <20120702131006.68E19106567E@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: gmiller Date: Mon Jul 2 13:10:06 2012 New Revision: 238804 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=238804 Log: r238821@FreeBSD-dev: root | 2012-06-29 15:25:31 -0500 Add wrappers for spinlocks. Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/lib/libwitness/wrappers.c Modified: soc2012/gmiller/locking-head/lib/libwitness/wrappers.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/wrappers.c Mon Jul 2 13:09:56 2012 (r238803) +++ soc2012/gmiller/locking-head/lib/libwitness/wrappers.c Mon Jul 2 13:10:06 2012 (r238804) @@ -32,15 +32,18 @@ int _pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *ts); int _pthread_mutex_unlock(pthread_mutex_t *mutex); -int _pthread_rwlock_rdlock(pthread_rwlock_t *mutex); -int _pthread_rwlock_tryrdlock(pthread_rwlock_t *mutex); -int _pthread_rwlock_timedrdlock(pthread_rwlock_t *mutex, +int _pthread_rwlock_rdlock(pthread_rwlock_t *rwlock); +int _pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock); +int _pthread_rwlock_timedrdlock(pthread_rwlock_t *rwlock, const struct timespec *ts); -int _pthread_rwlock_wrlock(pthread_rwlock_t *mutex); -int _pthread_rwlock_trywrlock(pthread_rwlock_t *mutex); -int _pthread_rwlock_timedwrlock(pthread_rwlock_t *mutex, +int _pthread_rwlock_wrlock(pthread_rwlock_t *rwlock); +int _pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock); +int _pthread_rwlock_timedwrlock(pthread_rwlock_t *rwlock, const struct timespec *ts); -int _pthread_rwlock_unlock(pthread_rwlock_t *mutex); +int _pthread_rwlock_unlock(pthread_rwlock_t *rwlock); +int _pthread_spin_lock(pthread_spinlock_t *spin); +int _pthread_spin_trylock(pthread_spinlock_t *spin); +int _pthread_spin_unlock(pthread_spinlock_t *spin); pthread_mutex_t witness_mtx = PTHREAD_MUTEX_INITIALIZER; @@ -186,3 +189,42 @@ return (ret); } + +int +pthread_spin_lock(pthread_spinlock_t *spin) +{ + int ret; + + ret = _pthread_spin_lock(spin); + if (ret == 0) { + add_lock(spin); + } + + return (ret); +} + +int +pthread_spin_trylock(pthread_spinlock_t *spin) +{ + int ret; + + ret = _pthread_spin_lock(spin); + if (ret == 0) { + add_lock(spin); + } + + return (ret); +} + +int +pthread_spin_unlock(pthread_spinlock_t *spin) +{ + int ret; + + ret = _pthread_spin_unlock(spin); + if (ret == 0) { + remove_lock(spin); + } + + return (ret); +}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120702131006.68E19106567E>