]> pd.if.org Git - pdclib/blob - platform/win32/functions/threads/mtx_unlock.c
dos2unix
[pdclib] / platform / win32 / functions / threads / mtx_unlock.c
1 #ifndef REGTEST
2 #include <threads.h>
3 #include <windows.h>
4
5 extern void _PDCLIB_w32errno( void );
6 int mtx_unlock(mtx_t *mtx)
7 {
8     if(mtx->_NestCount) {
9         mtx->_NestCount--;
10         return thrd_success;
11     }
12
13     mtx->_ThreadId = 0;
14     DWORD rv = SetEvent(mtx->_WaitEvHandle);
15     if(rv == 0) {
16         _PDCLIB_w32errno();
17         return thrd_error;
18     }
19     return thrd_success;
20 }
21 #endif
22
23 #ifdef TEST
24 #include "_PDCLIB_test.h"
25
26 int main( void )
27 {
28     return TEST_RESULTS;
29 }
30
31 #endif