Lines Matching +full:- +full:m

5  * SPDX-License-Identifier: Apache-2.0
44 static inline size_t posix_mutex_to_offset(struct k_mutex *m) in posix_mutex_to_offset() argument
46 return m - posix_mutex_pool; in posix_mutex_to_offset()
84 struct k_mutex *m; in to_posix_mutex() local
100 m = &posix_mutex_pool[bit]; in to_posix_mutex()
102 err = k_mutex_init(m); in to_posix_mutex()
105 return m; in to_posix_mutex()
110 int type = -1; in acquire_mutex()
111 size_t bit = -1; in acquire_mutex()
113 size_t lock_count = -1; in acquire_mutex()
114 struct k_mutex *m = NULL; in acquire_mutex() local
118 m = to_posix_mutex(mu); in acquire_mutex()
119 if (m == NULL) { in acquire_mutex()
124 LOG_DBG("Locking mutex %p with timeout %llx", m, timeout.ticks); in acquire_mutex()
127 bit = posix_mutex_to_offset(m); in acquire_mutex()
129 owner = m->owner; in acquire_mutex()
130 lock_count = m->lock_count; in acquire_mutex()
141 LOG_DBG("Timeout locking mutex %p", m); in acquire_mutex()
146 LOG_DBG("Attempt to relock non-recursive mutex %p", m); in acquire_mutex()
154 LOG_DBG("Mutex %p locked recursively too many times", m); in acquire_mutex()
159 LOG_DBG("Attempt to recursively lock non-recursive mutex %p", m); in acquire_mutex()
170 ret = k_mutex_lock(m, timeout); in acquire_mutex()
171 if (ret == -EAGAIN) { in acquire_mutex()
172 LOG_DBG("Timeout locking mutex %p", m); in acquire_mutex()
174 * special quirk - k_mutex_lock() returns EAGAIN if a timeout occurs, but in acquire_mutex()
184 ret = -ret; in acquire_mutex()
188 LOG_DBG("Locked mutex %p", m); in acquire_mutex()
195 * @brief Lock POSIX mutex with non-blocking call.
199 int pthread_mutex_trylock(pthread_mutex_t *m) in pthread_mutex_trylock() argument
201 return acquire_mutex(m, K_NO_WAIT); in pthread_mutex_trylock()
210 int pthread_mutex_timedlock(pthread_mutex_t *m, in pthread_mutex_timedlock() argument
214 return acquire_mutex(m, K_MSEC(timeout)); in pthread_mutex_timedlock()
225 struct k_mutex *m; in pthread_mutex_init() local
230 m = to_posix_mutex(mu); in pthread_mutex_init()
231 if (m == NULL) { in pthread_mutex_init()
235 bit = posix_mutex_to_offset(m); in pthread_mutex_init()
239 posix_mutex_type[bit] = attr->type; in pthread_mutex_init()
242 LOG_DBG("Initialized mutex %p", m); in pthread_mutex_init()
253 int pthread_mutex_lock(pthread_mutex_t *m) in pthread_mutex_lock() argument
255 return acquire_mutex(m, K_FOREVER); in pthread_mutex_lock()
266 struct k_mutex *m; in pthread_mutex_unlock() local
268 m = get_posix_mutex(*mu); in pthread_mutex_unlock()
269 if (m == NULL) { in pthread_mutex_unlock()
273 ret = k_mutex_unlock(m); in pthread_mutex_unlock()
276 return -ret; in pthread_mutex_unlock()
280 LOG_DBG("Unlocked mutex %p", m); in pthread_mutex_unlock()
294 struct k_mutex *m; in pthread_mutex_destroy() local
296 m = get_posix_mutex(*mu); in pthread_mutex_destroy()
297 if (m == NULL) { in pthread_mutex_destroy()
305 LOG_DBG("Destroyed mutex %p", m); in pthread_mutex_destroy()
357 a->type = PTHREAD_MUTEX_DEFAULT; in pthread_mutexattr_init()
358 a->initialized = true; in pthread_mutexattr_init()
367 if (a == NULL || !a->initialized) { in pthread_mutexattr_destroy()
385 if (a == NULL || type == NULL || !a->initialized) { in pthread_mutexattr_gettype()
389 *type = a->type; in pthread_mutexattr_gettype()
403 if (a == NULL || !a->initialized) { in pthread_mutexattr_settype()
411 a->type = type; in pthread_mutexattr_settype()