synch.h (204076) | synch.h (211876) |
---|---|
1/*- 2 * Copyright (c) 2009-2010 The FreeBSD Foundation 3 * All rights reserved. 4 * 5 * This software was developed by Pawel Jakub Dawidek under sponsorship from 6 * the FreeBSD Foundation. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 12 unchanged lines hidden (view full) --- 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * | 1/*- 2 * Copyright (c) 2009-2010 The FreeBSD Foundation 3 * All rights reserved. 4 * 5 * This software was developed by Pawel Jakub Dawidek under sponsorship from 6 * the FreeBSD Foundation. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 12 unchanged lines hidden (view full) --- 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * |
29 * $FreeBSD: head/sbin/hastd/synch.h 204076 2010-02-18 23:16:19Z pjd $ | 29 * $FreeBSD: head/sbin/hastd/synch.h 211876 2010-08-27 13:58:38Z pjd $ |
30 */ 31 32#ifndef _SYNCH_H_ 33#define _SYNCH_H_ 34 35#include <assert.h> | 30 */ 31 32#ifndef _SYNCH_H_ 33#define _SYNCH_H_ 34 35#include <assert.h> |
36#include <errno.h> |
|
36#include <pthread.h> | 37#include <pthread.h> |
38#include <pthread_np.h> |
|
37#include <stdbool.h> 38#include <time.h> 39 40static __inline void 41mtx_init(pthread_mutex_t *lock) 42{ 43 int error; 44 --- 20 unchanged lines hidden (view full) --- 65static __inline void 66mtx_unlock(pthread_mutex_t *lock) 67{ 68 int error; 69 70 error = pthread_mutex_unlock(lock); 71 assert(error == 0); 72} | 39#include <stdbool.h> 40#include <time.h> 41 42static __inline void 43mtx_init(pthread_mutex_t *lock) 44{ 45 int error; 46 --- 20 unchanged lines hidden (view full) --- 67static __inline void 68mtx_unlock(pthread_mutex_t *lock) 69{ 70 int error; 71 72 error = pthread_mutex_unlock(lock); 73 assert(error == 0); 74} |
75static __inline bool 76mtx_owned(pthread_mutex_t *lock) 77{ |
|
73 | 78 |
79 return (pthread_mutex_isowned_np(lock) != 0); 80} 81 |
|
74static __inline void 75rw_init(pthread_rwlock_t *lock) 76{ 77 int error; 78 79 error = pthread_rwlock_init(lock, NULL); 80 assert(error == 0); 81} --- 81 unchanged lines hidden --- | 82static __inline void 83rw_init(pthread_rwlock_t *lock) 84{ 85 int error; 86 87 error = pthread_rwlock_init(lock, NULL); 88 assert(error == 0); 89} --- 81 unchanged lines hidden --- |