Lines Matching refs:lock
379 void __retarget_lock_init(_LOCK_T *lock) in __retarget_lock_init() argument
381 __ASSERT_NO_MSG(lock != NULL); in __retarget_lock_init()
385 *lock = malloc(sizeof(struct k_sem)); in __retarget_lock_init()
387 *lock = k_object_alloc(K_OBJ_SEM); in __retarget_lock_init()
389 __ASSERT(*lock != NULL, "non-recursive lock allocation failed"); in __retarget_lock_init()
391 k_sem_init((struct k_sem *)*lock, 1, 1); in __retarget_lock_init()
393 k_object_access_all_grant(*lock); in __retarget_lock_init()
398 void __retarget_lock_init_recursive(_LOCK_T *lock) in __retarget_lock_init_recursive() argument
400 __ASSERT_NO_MSG(lock != NULL); in __retarget_lock_init_recursive()
404 *lock = malloc(sizeof(struct k_mutex)); in __retarget_lock_init_recursive()
406 *lock = k_object_alloc(K_OBJ_MUTEX); in __retarget_lock_init_recursive()
408 __ASSERT(*lock != NULL, "recursive lock allocation failed"); in __retarget_lock_init_recursive()
410 k_mutex_init((struct k_mutex *)*lock); in __retarget_lock_init_recursive()
412 k_object_access_all_grant(*lock); in __retarget_lock_init_recursive()
417 void __retarget_lock_close(_LOCK_T lock) in __retarget_lock_close() argument
419 __ASSERT_NO_MSG(lock != NULL); in __retarget_lock_close()
421 free(lock); in __retarget_lock_close()
423 k_object_release(lock); in __retarget_lock_close()
428 void __retarget_lock_close_recursive(_LOCK_T lock) in __retarget_lock_close_recursive() argument
430 __ASSERT_NO_MSG(lock != NULL); in __retarget_lock_close_recursive()
432 free(lock); in __retarget_lock_close_recursive()
434 k_object_release(lock); in __retarget_lock_close_recursive()
439 void __retarget_lock_acquire(_LOCK_T lock) in __retarget_lock_acquire() argument
441 __ASSERT_NO_MSG(lock != NULL); in __retarget_lock_acquire()
442 k_sem_take((struct k_sem *)lock, K_FOREVER); in __retarget_lock_acquire()
446 void __retarget_lock_acquire_recursive(_LOCK_T lock) in __retarget_lock_acquire_recursive() argument
448 __ASSERT_NO_MSG(lock != NULL); in __retarget_lock_acquire_recursive()
449 k_mutex_lock((struct k_mutex *)lock, K_FOREVER); in __retarget_lock_acquire_recursive()
453 int __retarget_lock_try_acquire(_LOCK_T lock) in __retarget_lock_try_acquire() argument
455 __ASSERT_NO_MSG(lock != NULL); in __retarget_lock_try_acquire()
456 return !k_sem_take((struct k_sem *)lock, K_NO_WAIT); in __retarget_lock_try_acquire()
460 int __retarget_lock_try_acquire_recursive(_LOCK_T lock) in __retarget_lock_try_acquire_recursive() argument
462 __ASSERT_NO_MSG(lock != NULL); in __retarget_lock_try_acquire_recursive()
463 return !k_mutex_lock((struct k_mutex *)lock, K_NO_WAIT); in __retarget_lock_try_acquire_recursive()
467 void __retarget_lock_release(_LOCK_T lock) in __retarget_lock_release() argument
469 __ASSERT_NO_MSG(lock != NULL); in __retarget_lock_release()
470 k_sem_give((struct k_sem *)lock); in __retarget_lock_release()
474 void __retarget_lock_release_recursive(_LOCK_T lock) in __retarget_lock_release_recursive() argument
476 __ASSERT_NO_MSG(lock != NULL); in __retarget_lock_release_recursive()
477 k_mutex_unlock((struct k_mutex *)lock); in __retarget_lock_release_recursive()