X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=opt%2Fnothread%2Fmtx_unlock.c;h=42f696aa27e613d00c2d0a9ac6d248df2a107a54;hp=02244bbed591b682cc065cf694e72f4a73a7cccb;hb=abc15df6b9fae3374d24c7cf5c3ab94c605b2a6d;hpb=b41576197133c1211d6ec353faf93f505f573b8a diff --git a/opt/nothread/mtx_unlock.c b/opt/nothread/mtx_unlock.c index 02244bb..42f696a 100644 --- a/opt/nothread/mtx_unlock.c +++ b/opt/nothread/mtx_unlock.c @@ -1,9 +1,20 @@ -#include - -int mtx_unlock(mtx_t *mtx) -{ - if(*mtx) { - *mtx = 0; - return thrd_success; - } else return thrd_error; -} \ No newline at end of file +#ifndef REGTEST +#include + +int mtx_unlock(mtx_t *mtx) +{ + if(--(*mtx) >= 0) + return thrd_success; + return thrd_error; +} +#endif + +#ifdef TEST +#include "_PDCLIB_test.h" + +int main( void ) +{ + return TEST_RESULTS; +} + +#endif