2 * FreeRDP: A Remote Desktop Protocol Client
5 * Copyright 2011 Vic Lee
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.
20 #include <freerdp/utils/memory.h>
21 #include <freerdp/utils/mutex.h>
25 #define freerdp_mutex_t HANDLE
28 #define freerdp_mutex_t pthread_mutex_t
31 freerdp_mutex freerdp_mutex_new(void)
34 freerdp_mutex_t mutex;
35 mutex = CreateMutex(NULL, FALSE, NULL);
36 return (freerdp_mutex) mutex;
38 freerdp_mutex_t* mutex;
39 mutex = xnew(freerdp_mutex_t);
40 pthread_mutex_init(mutex, 0);
45 void freerdp_mutex_free(freerdp_mutex mutex)
48 CloseHandle((freerdp_mutex_t) mutex);
50 pthread_mutex_destroy((freerdp_mutex_t*) mutex);
55 void freerdp_mutex_lock(freerdp_mutex mutex)
58 WaitForSingleObject((freerdp_mutex_t) mutex, INFINITE);
60 pthread_mutex_lock(mutex);
64 void freerdp_mutex_unlock(freerdp_mutex mutex)
67 ReleaseMutex((freerdp_mutex_t) mutex);
69 pthread_mutex_unlock(mutex);