-#ifndef REGTEST\r
-#include <threads.h>\r
-#include <windows.h>\r
-\r
-extern void _PDCLIB_w32errno( void );\r
-int mtx_unlock(mtx_t *mtx)\r
-{\r
- if(mtx->_NestCount) {\r
- mtx->_NestCount--;\r
- return thrd_success;\r
- }\r
-\r
- mtx->_ThreadId = 0;\r
-\r
- DWORD res = InterlockedDecrement(&mtx->_State);\r
- if(res == (DWORD) -1) {\r
- // We reset the state to -1; success!\r
- return thrd_success;\r
- }\r
-\r
- DWORD rv = SetEvent(mtx->_WaitEvHandle);\r
- if(rv == 0) {\r
- _PDCLIB_w32errno();\r
- return thrd_error;\r
- }\r
-\r
- return thrd_success;\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
+#ifndef REGTEST
+#include <threads.h>
+#include <windows.h>
+
+extern void _PDCLIB_w32errno( void );
+int mtx_unlock(mtx_t *mtx)
+{
+ if(mtx->_NestCount) {
+ mtx->_NestCount--;
+ return thrd_success;
+ }
+
+ mtx->_ThreadId = 0;
+ DWORD rv = SetEvent(mtx->_WaitEvHandle);
+ if(rv == 0) {
+ _PDCLIB_w32errno();
+ return thrd_error;
+ }
+ return thrd_success;
+}
+#endif
+
+#ifdef TEST
+#include "_PDCLIB_test.h"
+
+int main( void )
+{
+ return TEST_RESULTS;
+}
+
#endif
\ No newline at end of file