X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=opt%2Fnothread%2Fmtx_unlock.c;h=d22d40e0ed3c75859ea614771950293c577a8236;hb=ad695562522feac5197c19716dd91922f229cf32;hp=214a06390a51e752f109b7d53fb1561291b72b03;hpb=10f020f1a39804bbef8cd1cf35ef7c9a8e75c7d6;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