2
* WinPR: Windows Portable Runtime
3
* Synchronization Functions
5
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
7
* Licensed under the Apache License, Version 2.0 (the "License");
8
* you may not use this file except in compliance with the License.
9
* You may obtain a copy of the License at
11
* http://www.apache.org/licenses/LICENSE-2.0
13
* Unless required by applicable law or agreed to in writing, software
14
* distributed under the License is distributed on an "AS IS" BASIS,
15
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
* See the License for the specific language governing permissions and
17
* limitations under the License.
24
#include <winpr/synch.h>
40
#include "../handle/handle.h"
42
HANDLE CreateMutexW(LPSECURITY_ATTRIBUTES lpMutexAttributes, BOOL bInitialOwner, LPCWSTR lpName)
47
mutex = (WINPR_MUTEX*) malloc(sizeof(WINPR_MUTEX));
51
pthread_mutex_init(&mutex->mutex, 0);
53
WINPR_HANDLE_SET_TYPE(mutex, HANDLE_TYPE_MUTEX);
54
handle = (HANDLE) mutex;
57
pthread_mutex_lock(&mutex->mutex);
63
HANDLE CreateMutexA(LPSECURITY_ATTRIBUTES lpMutexAttributes, BOOL bInitialOwner, LPCSTR lpName)
65
return CreateMutexW(lpMutexAttributes, bInitialOwner, NULL);
68
HANDLE CreateMutexExA(LPSECURITY_ATTRIBUTES lpMutexAttributes, LPCTSTR lpName, DWORD dwFlags, DWORD dwDesiredAccess)
70
return CreateMutexW(lpMutexAttributes, FALSE, NULL);
73
HANDLE CreateMutexExW(LPSECURITY_ATTRIBUTES lpMutexAttributes, LPCWSTR lpName, DWORD dwFlags, DWORD dwDesiredAccess)
75
return CreateMutexW(lpMutexAttributes, FALSE, NULL);
78
HANDLE OpenMutexA(DWORD dwDesiredAccess, BOOL bInheritHandle,LPCSTR lpName)
83
HANDLE OpenMutexW(DWORD dwDesiredAccess, BOOL bInheritHandle,LPCWSTR lpName)
88
BOOL ReleaseMutex(HANDLE hMutex)
94
if (!winpr_Handle_GetInfo(hMutex, &Type, &Object))
97
if (Type == HANDLE_TYPE_MUTEX)
99
mutex = (WINPR_MUTEX*) Object;
100
pthread_mutex_unlock(&mutex->mutex);