Lines Matching +full:int +full:- +full:b
5 * SPDX-License-Identifier: Apache-2.0
35 return bar - posix_barrier_pool; in posix_barrier_to_offset()
38 static inline size_t to_posix_barrier_idx(pthread_barrier_t b) in to_posix_barrier_idx() argument
40 return mark_pthread_obj_uninitialized(b); in to_posix_barrier_idx()
43 struct posix_barrier *get_posix_barrier(pthread_barrier_t b) in get_posix_barrier() argument
45 int actually_initialized; in get_posix_barrier()
46 size_t bit = to_posix_barrier_idx(b); in get_posix_barrier()
49 if (!is_pthread_obj_initialized(b)) { in get_posix_barrier()
66 int pthread_barrier_wait(pthread_barrier_t *b) in pthread_barrier_wait() argument
68 int ret; in pthread_barrier_wait()
69 int err; in pthread_barrier_wait()
70 pthread_barrier_t bb = *b; in pthread_barrier_wait()
78 err = k_mutex_lock(&bar->mutex, K_FOREVER); in pthread_barrier_wait()
81 ++bar->count; in pthread_barrier_wait()
83 if (bar->count == bar->max) { in pthread_barrier_wait()
84 bar->count = 0; in pthread_barrier_wait()
90 while (bar->count != 0) { in pthread_barrier_wait()
91 err = k_condvar_wait(&bar->cond, &bar->mutex, K_FOREVER); in pthread_barrier_wait()
99 err = k_condvar_signal(&bar->cond); in pthread_barrier_wait()
101 err = k_mutex_unlock(&bar->mutex); in pthread_barrier_wait()
107 int pthread_barrier_init(pthread_barrier_t *b, const pthread_barrierattr_t *attr, in pthread_barrier_init() argument
108 unsigned int count) in pthread_barrier_init()
122 bar->max = count; in pthread_barrier_init()
123 bar->count = 0; in pthread_barrier_init()
125 *b = mark_pthread_obj_initialized(bit); in pthread_barrier_init()
130 int pthread_barrier_destroy(pthread_barrier_t *b) in pthread_barrier_destroy() argument
132 int err; in pthread_barrier_destroy()
136 bar = get_posix_barrier(*b); in pthread_barrier_destroy()
141 err = k_mutex_lock(&bar->mutex, K_FOREVER); in pthread_barrier_destroy()
143 return -err; in pthread_barrier_destroy()
148 bar->max = 0; in pthread_barrier_destroy()
149 bar->count = 0; in pthread_barrier_destroy()
155 err = k_condvar_broadcast(&bar->cond); in pthread_barrier_destroy()
158 err = k_mutex_unlock(&bar->mutex); in pthread_barrier_destroy()
164 int pthread_barrierattr_init(pthread_barrierattr_t *attr) in pthread_barrierattr_init()
168 attr->pshared = PTHREAD_PROCESS_PRIVATE; in pthread_barrierattr_init()
173 int pthread_barrierattr_setpshared(pthread_barrierattr_t *attr, int pshared) in pthread_barrierattr_setpshared()
176 return -EINVAL; in pthread_barrierattr_setpshared()
179 attr->pshared = pshared; in pthread_barrierattr_setpshared()
183 int pthread_barrierattr_getpshared(const pthread_barrierattr_t *restrict attr, in pthread_barrierattr_getpshared()
184 int *restrict pshared) in pthread_barrierattr_getpshared()
186 *pshared = attr->pshared; in pthread_barrierattr_getpshared()
191 int pthread_barrierattr_destroy(pthread_barrierattr_t *attr) in pthread_barrierattr_destroy()
198 static int pthread_barrier_pool_init(void) in pthread_barrier_pool_init()
200 int err; in pthread_barrier_pool_init()