Lines Matching +full:loss +full:- +full:of +full:- +full:lock
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
8 * Portions of this software were developed by Konstantin Belousov
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
17 * notice, this list of conditions and the following disclaimer in the
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 #include "un-namespace.h"
42 "pthread_spinlock is too large for off-page");
53 _pthread_spin_init(pthread_spinlock_t *lock, int pshared) in _pthread_spin_init() argument
57 if (lock == NULL) in _pthread_spin_init()
64 *lock = lck; in _pthread_spin_init()
66 lck = __thr_pshared_offpage(lock, 1); in _pthread_spin_init()
69 *lock = THR_PSHARED_PTR; in _pthread_spin_init()
73 _thr_umutex_init(&lck->s_lock); in _pthread_spin_init()
78 _pthread_spin_destroy(pthread_spinlock_t *lock) in _pthread_spin_destroy() argument
83 if (lock == NULL || *lock == NULL) { in _pthread_spin_destroy()
85 } else if (*lock == THR_PSHARED_PTR) { in _pthread_spin_destroy()
86 l = __thr_pshared_offpage(lock, 0); in _pthread_spin_destroy()
91 free(*lock); in _pthread_spin_destroy()
92 *lock = NULL; in _pthread_spin_destroy()
99 _pthread_spin_trylock(pthread_spinlock_t *lock) in _pthread_spin_trylock() argument
103 if (lock == NULL || *lock == NULL) in _pthread_spin_trylock()
105 lck = *lock == THR_PSHARED_PTR ? __thr_pshared_offpage(lock, 0) : *lock; in _pthread_spin_trylock()
108 return (THR_UMUTEX_TRYLOCK(_get_curthread(), &lck->s_lock)); in _pthread_spin_trylock()
112 _pthread_spin_lock(pthread_spinlock_t *lock) in _pthread_spin_lock() argument
118 if (lock == NULL) in _pthread_spin_lock()
120 lck = *lock == THR_PSHARED_PTR ? __thr_pshared_offpage(lock, 0) : *lock; in _pthread_spin_lock()
126 while (THR_UMUTEX_TRYLOCK(curthread, &lck->s_lock) != 0) { in _pthread_spin_lock()
127 while (lck->s_lock.m_owner) { in _pthread_spin_lock()
132 if (--count <= 0) { in _pthread_spin_lock()
143 _pthread_spin_unlock(pthread_spinlock_t *lock) in _pthread_spin_unlock() argument
147 if (lock == NULL) in _pthread_spin_unlock()
149 lck = *lock == THR_PSHARED_PTR ? __thr_pshared_offpage(lock, 0) : *lock; in _pthread_spin_unlock()
152 return (THR_UMUTEX_UNLOCK(_get_curthread(), &lck->s_lock)); in _pthread_spin_unlock()