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