]> pd.if.org Git - pdclib.old/blob - opt/pthreads/mtx_trylock.c
[gandr] split _PDCLIB_stdinit to better separate stdio and locale
[pdclib.old] / opt / pthreads / mtx_trylock.c
1 #ifndef REGTEST
2 #include <threads.h>
3 #include <pthread.h>
4 #include <errno.h>
5
6 int mtx_trylock(mtx_t *mtx)
7 {
8     switch(pthread_mutex_trylock(mtx)) {
9         case 0:
10             return thrd_success;
11         case EBUSY:
12             return thrd_busy;
13         default:
14             return thrd_error;
15     }
16 }
17 #endif
18
19 #ifdef TEST
20 #include <_PDCLIB_test.h>
21
22 int main( void )
23 {
24     return TEST_RESULTS;
25 }
26
27 #endif