X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=opt%2Fnothread%2Fmtx_unlock.c;h=d22d40e0ed3c75859ea614771950293c577a8236;hb=24f274eec4d6ac3868f3fdf03d2e1876c80be616;hp=214a06390a51e752f109b7d53fb1561291b72b03;hpb=217a2f477ad6dbbac816981589ee2f5a81dffd67;p=pdclib.old diff --git a/opt/nothread/mtx_unlock.c b/opt/nothread/mtx_unlock.c index 214a063..d22d40e 100644 --- a/opt/nothread/mtx_unlock.c +++ b/opt/nothread/mtx_unlock.c @@ -3,10 +3,9 @@ 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 @@ -18,4 +17,4 @@ int main( void ) return TEST_RESULTS; } -#endif \ No newline at end of file +#endif