X-Git-Url: https://pd.if.org/git/?p=pdclib.old;a=blobdiff_plain;f=opt%2Fpthreads%2Fmtx_trylock.c;fp=opt%2Fpthreads%2Fmtx_trylock.c;h=8a095a5b5c55cb63c045febf0719c01855c1fd02;hp=0000000000000000000000000000000000000000;hb=d293fb98fe80a472ad4d11b4d8a1413d2142064a;hpb=42ca148113de4800d41cbd0491c508160bb1cf36 diff --git a/opt/pthreads/mtx_trylock.c b/opt/pthreads/mtx_trylock.c new file mode 100644 index 0000000..8a095a5 --- /dev/null +++ b/opt/pthreads/mtx_trylock.c @@ -0,0 +1,27 @@ +#ifndef REGTEST +#include +#include +#include + +int mtx_trylock(mtx_t *mtx) +{ + switch(pthread_mutex_trylock(mtx)) { + case 0: + return thrd_success; + case EBUSY: + return thrd_busy; + default: + return thrd_error; + } +} +#endif + +#ifdef TEST +#include <_PDCLIB_test.h> + +int main( void ) +{ + return TEST_RESULTS; +} + +#endif