os/graphics/graphicscomposition/openwfcompositionengine/adaptation/src/Platform/OS/symbian/owfmutex.c
First public contribution.
1 /* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and/or associated documentation files (the
5 * "Materials"), to deal in the Materials without restriction, including
6 * without limitation the rights to use, copy, modify, merge, publish,
7 * distribute, sublicense, and/or sell copies of the Materials, and to
8 * permit persons to whom the Materials are furnished to do so, subject to
9 * the following conditions:
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Materials.
14 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
34 #include "owfmemory.h"
39 #define MUTEX(x) (pthread_mutex_t*)(*x)
42 OWF_Mutex_Init(OWF_MUTEX* mutex)
49 *mutex = xalloc(1, sizeof(pthread_mutex_t));
54 return pthread_mutex_init(MUTEX(mutex), NULL);
58 OWF_Mutex_Destroy(OWF_MUTEX* mutex)
69 err = pthread_mutex_destroy(MUTEX(mutex));
77 OWF_Mutex_Lock(OWF_MUTEX* mutex)
79 if (!(mutex && *mutex))
84 return pthread_mutex_lock(MUTEX(mutex));
88 OWF_Mutex_Unlock(OWF_MUTEX* mutex)
90 if (!(mutex && *mutex))
94 return pthread_mutex_unlock(MUTEX(mutex));