X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=opt%2Fnothread%2Fmtx_unlock.c;h=a12c0a061123b40e2c5b3fe597cadb6336769b38;hp=214a06390a51e752f109b7d53fb1561291b72b03;hb=da0f3f353d417fed71f358a48d5d5394145e460d;hpb=219271fd548949abce8bd75c34dd42e519418fc4 diff --git a/opt/nothread/mtx_unlock.c b/opt/nothread/mtx_unlock.c index 214a063..a12c0a0 100644 --- a/opt/nothread/mtx_unlock.c +++ b/opt/nothread/mtx_unlock.c @@ -3,19 +3,18 @@ int mtx_unlock(mtx_t *mtx) { - if(*mtx) { - *mtx = 0; - return thrd_success; - } else return thrd_error; + if(--(*mtx) >= 0) + return thrd_success; + return thrd_error; } #endif #ifdef TEST -#include <_PDCLIB_test.h> +#include "_PDCLIB_test.h" int main( void ) { return TEST_RESULTS; } -#endif \ No newline at end of file +#endif