5 int mtx_lock(mtx_t *mtx)
\r
7 DWORD myId = GetCurrentThreadId();
\r
9 if(mtx->_ThreadId == (long) myId) {
\r
11 return thrd_success;
\r
15 LONG prev = InterlockedCompareExchange(&mtx->_ThreadId, myId, 0);
\r
17 return thrd_success;
\r
19 DWORD rv = WaitForSingleObject(mtx->_WaitEvHandle, INFINITE);
\r
20 if(rv != WAIT_OBJECT_0)
\r
27 #include <_PDCLIB_test.h>
\r
31 return TEST_RESULTS;
\r