os/graphics/graphicscomposition/openwfcompositionengine/adaptation/src/Platform/OS/symbian/owfsemaphore.c
Update contrib.
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.
25 #include <semaphore.h>
28 #include "owfsemaphore.h"
29 #include "owfmemory.h"
31 #define SEM(x) (sem_t*)(*x)
34 OWF_Semaphore_Init(OWF_SEMAPHORE* sem, OWFint val)
36 *sem = xalloc(1, sizeof(sem_t));
40 return sem_init(SEM(sem), 0, val);
44 OWF_Semaphore_Wait(OWF_SEMAPHORE* sem)
49 return sem_wait(SEM(sem));
53 OWF_Semaphore_TryWait(OWF_SEMAPHORE* sem)
58 return sem_trywait(SEM(sem));
62 OWF_Semaphore_Post(OWF_SEMAPHORE* sem)
71 OWF_Semaphore_GetValue(OWF_SEMAPHORE* sem, OWFint* val)
76 return sem_getvalue(SEM(sem), (int *)val);
80 OWF_Semaphore_Destroy(OWF_SEMAPHORE* sem)
85 err = sem_destroy(SEM(sem));