2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997, 1998, 1999, 2000 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)
29 /* Mutex functions using the Win32 API */
38 #include "SDL_error.h"
39 #include "SDL_mutex.h"
46 extern TInt
CreateUnique(TInt (*aFunc
)(const TDesC
& aName
, TAny
*, TAny
*), TAny
*, TAny
*);
48 TInt
NewMutex(const TDesC
& aName
, TAny
* aPtr1
, TAny
*)
50 return ((RMutex
*)aPtr1
)->CreateGlobal(aName
);
53 void DeleteMutex(TAny
* aMutex
)
55 SDL_DestroyMutex ((SDL_mutex
*) aMutex
);
59 SDL_mutex
*SDL_CreateMutex(void)
63 TInt status
= CreateUnique(NewMutex
, &rmutex
, NULL
);
64 if(status
!= KErrNone
)
66 SDL_SetError("Couldn't create mutex");
68 SDL_mutex
* mutex
= new SDL_mutex
;
69 mutex
->handle
= rmutex
.Handle();
70 EpocSdlEnv::AppendCleanupItem(TSdlCleanupItem(DeleteMutex
, mutex
));
75 void SDL_DestroyMutex(SDL_mutex
*mutex
)
80 rmutex
.SetHandle(mutex
->handle
);
86 EpocSdlEnv::RemoveCleanupItem(mutex
);
93 int SDL_mutexP(SDL_mutex
*mutex
)
95 if ( mutex
== NULL
) {
96 SDL_SetError("Passed a NULL mutex");
100 rmutex
.SetHandle(mutex
->handle
);
105 /* Unlock the mutex */
106 int SDL_mutexV(SDL_mutex
*mutex
)
108 if ( mutex
== NULL
) {
109 SDL_SetError("Passed a NULL mutex");
113 rmutex
.SetHandle(mutex
->handle
);