-#ifndef REGTEST\r
-#include <threads.h>\r
-\r
-int mtx_unlock(mtx_t *mtx)\r
-{\r
- if(*mtx) {\r
- *mtx = 0;\r
- return thrd_success;\r
- } else return thrd_error;\r
-}\r
-#endif\r
-\r
-#ifdef TEST\r
-#include <_PDCLIB_test.h>\r
-\r
-int main( void )\r
-{\r
- return TEST_RESULTS;\r
-}\r
-\r
-#endif
\ No newline at end of file
+#ifndef REGTEST
+#include <threads.h>
+
+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