zephyr/lib/posix/pthread_mutex.c
Ramakrishna Pallala f603e603bb lib: posix: Move posix layer from 'kernel' to 'lib'
Move posix layer from 'kernel' to 'lib' folder as it is not
a core kernel feature.

Fixed posix header file dependencies as part of the move and
also removed NEWLIBC related macros from posix headers.

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
2018-04-05 16:43:05 -04:00

25 lines
355 B
C

/*
* Copyright (c) 2017 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <kernel.h>
#include <ksched.h>
#include <wait_q.h>
#include <posix/pthread.h>
int pthread_mutex_trylock(pthread_mutex_t *m)
{
int key = irq_lock(), ret = EBUSY;
if (m->sem->count) {
m->sem->count = 0;
ret = 0;
}
irq_unlock(key);
return ret;
}