2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2009 Sam Lantinga
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the Free
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 slouken@devolution.com
26 Epoc version by Markus Mertama (w@iki.fi)
32 "@(#) $Id: SDL_sysmutex.c,v 1.1.2.3 2000/06/22 15:25:23 hercules Exp $";
35 /* Mutex functions using the Win32 API */
44 #include "SDL_error.h"
45 #include "SDL_mutex.h"
60 extern TInt CreateUnique(TInt (*aFunc)(const TDesC& aName, TAny*, TAny*), TAny*, TAny*);
62 TInt NewMutex(const TDesC& aName, TAny* aPtr1, TAny*)
64 return ((RMutex*)aPtr1)->CreateGlobal(aName);
67 void DeleteMutex(TAny* aMutex)
69 SDL_DestroyMutex ((SDL_mutex*) aMutex);
73 SDL_mutex *SDL_CreateMutex(void)
77 TInt status = CreateUnique(NewMutex, &rmutex, NULL);
78 if(status != KErrNone)
80 SDL_SetError("Couldn't create mutex");
82 SDL_mutex* mutex = new /*(ELeave)*/ SDL_mutex;
83 mutex->handle = rmutex.Handle();
84 EpocSdlEnv::AppendCleanupItem(TSdlCleanupItem(DeleteMutex, mutex));
89 void SDL_DestroyMutex(SDL_mutex *mutex)
94 rmutex.SetHandle(mutex->handle);
100 EpocSdlEnv::RemoveCleanupItem(mutex);
107 int SDL_mutexP(SDL_mutex *mutex)
109 if ( mutex == NULL ) {
110 SDL_SetError("Passed a NULL mutex");
114 rmutex.SetHandle(mutex->handle);
119 /* Unlock the mutex */
120 int SDL_mutexV(SDL_mutex *mutex)
122 if ( mutex == NULL ) {
123 SDL_SetError("Passed a NULL mutex");
127 rmutex.SetHandle(mutex->handle);