zephyr/kernel/posix/pthread_mutex.c
Youvedeep Singh 325abfbcf4 kernel: POSIX: Fixing return value of POSIX APIs on error.
As per IEEE 1003.1 POSIX APIs should return ERROR_CODE on error.
But currently these are returning -ERROR_CODE instead of ERROR_CODE.
So fixing the return value.

Signed-off-by: Youvedeep Singh <youvedeep.singh@intel.com>
2018-02-21 19:17:28 -05:00

25 lines
349 B
C

/*
* Copyright (c) 2017 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <kernel.h>
#include <pthread.h>
#include "ksched.h"
#include "wait_q.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;
}