diff options
author | Max Horn | 2003-07-05 15:17:46 +0000 |
---|---|---|
committer | Max Horn | 2003-07-05 15:17:46 +0000 |
commit | 4611b12c0a84ec528f9f020dc85bf4e9a0108c82 (patch) | |
tree | 8a7f87ffbad997a6873a1a6e75d0d49746e9d69e /backends | |
parent | 39abb7cf0a36f348c2755197e18ae2d9edc59eda (diff) | |
download | scummvm-rg350-4611b12c0a84ec528f9f020dc85bf4e9a0108c82.tar.gz scummvm-rg350-4611b12c0a84ec528f9f020dc85bf4e9a0108c82.tar.bz2 scummvm-rg350-4611b12c0a84ec528f9f020dc85bf4e9a0108c82.zip |
updated backends to use type MutexRef
svn-id: r8776
Diffstat (limited to 'backends')
-rw-r--r-- | backends/PalmOS/Src/palm.cpp | 8 | ||||
-rw-r--r-- | backends/PalmOS/Src/palm.h | 8 | ||||
-rw-r--r-- | backends/dc/dc.h | 8 | ||||
-rw-r--r-- | backends/dc/dcmain.cpp | 8 | ||||
-rw-r--r-- | backends/gp32/gp32.cpp | 8 | ||||
-rw-r--r-- | backends/gp32/gp32.h | 8 | ||||
-rw-r--r-- | backends/morphos/morphos.cpp | 10 | ||||
-rw-r--r-- | backends/morphos/morphos.h | 8 | ||||
-rw-r--r-- | backends/sdl/sdl-common.cpp | 15 | ||||
-rw-r--r-- | backends/sdl/sdl-common.h | 21 | ||||
-rw-r--r-- | backends/wince/wince.cpp | 10 | ||||
-rw-r--r-- | backends/wince/wince.h | 8 | ||||
-rw-r--r-- | backends/x11/x11.cpp | 18 |
13 files changed, 64 insertions, 74 deletions
diff --git a/backends/PalmOS/Src/palm.cpp b/backends/PalmOS/Src/palm.cpp index 7fb2164ef0..e25c25433f 100644 --- a/backends/PalmOS/Src/palm.cpp +++ b/backends/PalmOS/Src/palm.cpp @@ -562,20 +562,20 @@ void OSystem_PALMOS::set_timer(int timer, int (*callback)(int)) } /* Mutex handling */ -void *OSystem_PALMOS::create_mutex() +MutexRef OSystem_PALMOS::create_mutex() { return NULL; } -void OSystem_PALMOS::lock_mutex(void *mutex) +void OSystem_PALMOS::lock_mutex(MutexRef mutex) { } -void OSystem_PALMOS::unlock_mutex(void *mutex) +void OSystem_PALMOS::unlock_mutex(MutexRef mutex) { } -void OSystem_PALMOS::delete_mutex(void *mutex) +void OSystem_PALMOS::delete_mutex(MutexRef mutex) { } diff --git a/backends/PalmOS/Src/palm.h b/backends/PalmOS/Src/palm.h index 8c6e8b442d..59d39e153c 100644 --- a/backends/PalmOS/Src/palm.h +++ b/backends/PalmOS/Src/palm.h @@ -121,10 +121,10 @@ public: void set_timer(int timer, int (*callback)(int)); // Mutex handling - void *create_mutex(); - void lock_mutex(void *mutex); - void unlock_mutex(void *mutex); - void delete_mutex(void *mutex); + MutexRef create_mutex(); + void lock_mutex(MutexRef mutex); + void unlock_mutex(MutexRef mutex); + void delete_mutex(MutexRef mutex); // Quit void quit(); diff --git a/backends/dc/dc.h b/backends/dc/dc.h index 775c33b54f..8be53db2fd 100644 --- a/backends/dc/dc.h +++ b/backends/dc/dc.h @@ -85,10 +85,10 @@ class OSystem_Dreamcast : public OSystem { virtual void set_timer(int timer, int (*callback)(int)); // Mutex handling - virtual void *create_mutex(); - virtual void lock_mutex(void *mutex); - virtual void unlock_mutex(void *mutex); - virtual void delete_mutex(void *mutex); + virtual MutexRef create_mutex(); + virtual void lock_mutex(MutexRef mutex); + virtual void unlock_mutex(MutexRef mutex); + virtual void delete_mutex(MutexRef mutex); // Savefile handling virtual SaveFileManager *get_savefile_manager(); diff --git a/backends/dc/dcmain.cpp b/backends/dc/dcmain.cpp index 55c58c109d..49ffce2822 100644 --- a/backends/dc/dcmain.cpp +++ b/backends/dc/dcmain.cpp @@ -134,20 +134,20 @@ void OSystem_Dreamcast::create_thread(ThreadProc *proc, void *param) { /* Mutex handling */ -void *OSystem_Dreamcast::create_mutex() +MutexRef OSystem_Dreamcast::create_mutex() { return NULL; } -void OSystem_Dreamcast::lock_mutex(void *mutex) +void OSystem_Dreamcast::lock_mutex(MutexRef mutex) { } -void OSystem_Dreamcast::unlock_mutex(void *mutex) +void OSystem_Dreamcast::unlock_mutex(MutexRef mutex) { } -void OSystem_Dreamcast::delete_mutex(void *mutex) +void OSystem_Dreamcast::delete_mutex(MutexRef mutex) { } diff --git a/backends/gp32/gp32.cpp b/backends/gp32/gp32.cpp index cb62c227ba..e9c653a968 100644 --- a/backends/gp32/gp32.cpp +++ b/backends/gp32/gp32.cpp @@ -1075,10 +1075,10 @@ void OSystem_GP32::update_cdrom() { } void OSystem_GP32::set_timer(int timer, int (*callback)(int)) { } // Mutex handling -void* OSystem_GP32::create_mutex() { } -void OSystem_GP32::lock_mutex(void *mutex) { } -void OSystem_GP32::unlock_mutex(void *mutex) { } -void OSystem_GP32::delete_mutex(void *mutex) { } +MutexRef OSystem_GP32::create_mutex() { } +void OSystem_GP32::lock_mutex(MutexRef mutex) { } +void OSystem_GP32::unlock_mutex(MutexRef mutex) { } +void OSystem_GP32::delete_mutex(MutexRef mutex) { } // Quit void gphalt(int); diff --git a/backends/gp32/gp32.h b/backends/gp32/gp32.h index 825eeccb51..19d0f9ebd6 100644 --- a/backends/gp32/gp32.h +++ b/backends/gp32/gp32.h @@ -102,10 +102,10 @@ public: void set_timer(int timer, int (*callback)(int)); // Mutex handling - void *create_mutex(); - void lock_mutex(void *mutex); - void unlock_mutex(void *mutex); - void delete_mutex(void *mutex); + MutexRef create_mutex(); + void lock_mutex(MutexRef mutex); + void unlock_mutex(MutexRef mutex); + void delete_mutex(MutexRef mutex); // Quit void quit(); diff --git a/backends/morphos/morphos.cpp b/backends/morphos/morphos.cpp index ebfd651c54..b316f1b97c 100644 --- a/backends/morphos/morphos.cpp +++ b/backends/morphos/morphos.cpp @@ -316,27 +316,27 @@ void OSystem_MorphOS::create_thread(ThreadProc *proc, void *param) NP_PPC_Arg1, (ULONG) param, TAG_DONE); } -void *OSystem_MorphOS::create_mutex() +MutexRef OSystem_MorphOS::create_mutex() { SignalSemaphore *sem = (SignalSemaphore *) AllocVec(sizeof (SignalSemaphore), MEMF_PUBLIC); if (sem) InitSemaphore(sem); - return sem; + return (MutexRef)sem; } -void OSystem_MorphOS::lock_mutex(void *mutex) +void OSystem_MorphOS::lock_mutex(MutexRef mutex) { ObtainSemaphore((SignalSemaphore *) mutex); } -void OSystem_MorphOS::unlock_mutex(void *mutex) +void OSystem_MorphOS::unlock_mutex(MutexRef mutex) { ReleaseSemaphore((SignalSemaphore *)mutex); } -void OSystem_MorphOS::delete_mutex(void *mutex) +void OSystem_MorphOS::delete_mutex(MutexRef mutex) { FreeVec(mutex); } diff --git a/backends/morphos/morphos.h b/backends/morphos/morphos.h index 124e7b17f3..5076c2d479 100644 --- a/backends/morphos/morphos.h +++ b/backends/morphos/morphos.h @@ -85,10 +85,10 @@ class OSystem_MorphOS : public OSystem virtual void set_timer(int timer, int (*callback)(int)); // Mutex handling - virtual void *create_mutex(); - virtual void lock_mutex(void *mutex); - virtual void unlock_mutex(void *mutex); - virtual void delete_mutex(void *mutex); + virtual MutexRef create_mutex(); + virtual void lock_mutex(MutexRef mutex); + virtual void unlock_mutex(MutexRef mutex); + virtual void delete_mutex(MutexRef mutex); // Create a thread virtual void create_thread(ThreadProc *proc, void *param); diff --git a/backends/sdl/sdl-common.cpp b/backends/sdl/sdl-common.cpp index fd720cd9b9..28e87db04b 100644 --- a/backends/sdl/sdl-common.cpp +++ b/backends/sdl/sdl-common.cpp @@ -23,6 +23,7 @@ #include "sound/mididrv.h" #include "common/scaler.h" #include "common/engine.h" // Only #included for error() and warning() +#include "common/util.h" #include "scummvm.xpm" @@ -63,7 +64,7 @@ void OSystem_SDL_Common::init_intern(int gfx_mode, bool full_screen, bool aspect error("Could not initialize SDL: %s.\n", SDL_GetError()); } - _graphicsMutex = SDL_CreateMutex(); + _graphicsMutex = create_mutex(); SDL_ShowCursor(SDL_DISABLE); @@ -113,7 +114,7 @@ OSystem_SDL_Common::~OSystem_SDL_Common() { free(_dirty_checksums); free(_currentPalette); free(_mouseBackup); - SDL_DestroyMutex(_graphicsMutex); + delete_mutex(_graphicsMutex); SDL_ShowCursor(SDL_ENABLE); #ifdef MACOSX @@ -1192,19 +1193,19 @@ void OSystem_SDL_Common::setup_icon() { SDL_FreeSurface(sdl_surf); } -void *OSystem_SDL_Common::create_mutex(void) { - return (void *) SDL_CreateMutex(); +OSystem::MutexRef OSystem_SDL_Common::create_mutex(void) { + return (MutexRef) SDL_CreateMutex(); } -void OSystem_SDL_Common::lock_mutex(void *mutex) { +void OSystem_SDL_Common::lock_mutex(MutexRef mutex) { SDL_mutexP((SDL_mutex *) mutex); } -void OSystem_SDL_Common::unlock_mutex(void *mutex) { +void OSystem_SDL_Common::unlock_mutex(MutexRef mutex) { SDL_mutexV((SDL_mutex *) mutex); } -void OSystem_SDL_Common::delete_mutex(void *mutex) { +void OSystem_SDL_Common::delete_mutex(MutexRef mutex) { SDL_DestroyMutex((SDL_mutex *) mutex); } diff --git a/backends/sdl/sdl-common.h b/backends/sdl/sdl-common.h index da878153d4..4a2a8d0087 100644 --- a/backends/sdl/sdl-common.h +++ b/backends/sdl/sdl-common.h @@ -105,10 +105,10 @@ public: void set_timer(int timer, int (*callback)(int)); // Mutex handling - void *create_mutex(); - void lock_mutex(void *mutex); - void unlock_mutex(void *mutex); - void delete_mutex(void *mutex); + MutexRef create_mutex(); + void lock_mutex(MutexRef mutex); + void unlock_mutex(MutexRef mutex); + void delete_mutex(MutexRef mutex); // Overlay virtual void show_overlay(); @@ -208,7 +208,7 @@ protected: // Mutex that prevents multiple threads interferring with each other // when accessing the screen. - SDL_mutex *_graphicsMutex; + MutexRef _graphicsMutex; void add_dirty_rgn_auto(const byte *buf); @@ -229,15 +229,4 @@ protected: void init_joystick() { _joystick = SDL_JoystickOpen(0); } }; -// Auxillary class to (un)lock a mutex on the stack -class StackLock { - SDL_mutex *_mutex; -public: - StackLock(SDL_mutex *mutex) : _mutex(mutex) { lock(); } - ~StackLock() { unlock(); } - void lock() { SDL_mutexP(_mutex); } - void unlock() { SDL_mutexV(_mutex); } -}; - - #endif diff --git a/backends/wince/wince.cpp b/backends/wince/wince.cpp index de34d533ed..eb4c1eff6e 100644 --- a/backends/wince/wince.cpp +++ b/backends/wince/wince.cpp @@ -1744,18 +1744,18 @@ void OSystem_WINCE3::update_cdrom() {;} //void ScummDebugger::attach(Scumm *s) {;} /* Mutex stuff */ -void* OSystem_WINCE3::create_mutex() { - return (void*)CreateMutex(NULL, FALSE, NULL); +MutexRefOSystem_WINCE3::create_mutex() { + return (MutexRef)CreateMutex(NULL, FALSE, NULL); } -void OSystem_WINCE3::lock_mutex(void *handle) { +void OSystem_WINCE3::lock_mutex(MutexRefhandle) { WaitForSingleObject((HANDLE)handle, INFINITE); } -void OSystem_WINCE3::unlock_mutex(void *handle) { +void OSystem_WINCE3::unlock_mutex(MutexRefhandle) { ReleaseMutex((HANDLE)handle); } -void OSystem_WINCE3::delete_mutex(void *handle) { +void OSystem_WINCE3::delete_mutex(MutexRefhandle) { CloseHandle((HANDLE)handle); } diff --git a/backends/wince/wince.h b/backends/wince/wince.h index 1b369caeed..411e169d89 100644 --- a/backends/wince/wince.h +++ b/backends/wince/wince.h @@ -159,10 +159,10 @@ public: // Mutex functions - void* create_mutex(); - void lock_mutex(void*); - void unlock_mutex(void*); - void delete_mutex(void*); + MutexRef create_mutex(); + void lock_mutex(MutexRef); + void unlock_mutex(MutexRef); + void delete_mutex(MutexRef); // Windows callbacks & stuff static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); diff --git a/backends/x11/x11.cpp b/backends/x11/x11.cpp index 1f467a550c..bd3394abe3 100644 --- a/backends/x11/x11.cpp +++ b/backends/x11/x11.cpp @@ -121,10 +121,10 @@ public: void set_timer(int timer, int (*callback) (int)); // Mutex handling - void *create_mutex(); - void lock_mutex(void *mutex); - void unlock_mutex(void *mutex); - void delete_mutex(void *mutex); + MutexRef create_mutex(); + void lock_mutex(MutexRef mutex); + void unlock_mutex(MutexRef mutex); + void delete_mutex(MutexRef mutex); // Overlay handling for the new menu system void show_overlay(); @@ -1029,24 +1029,24 @@ void OSystem_X11::set_timer(int timer, int (*callback) (int)) } } -void *OSystem_X11::create_mutex() +MutexRef OSystem_X11::create_mutex() { pthread_mutex_t *mutex = (pthread_mutex_t *) malloc(sizeof(pthread_mutex_t)); pthread_mutex_init(mutex, NULL); - return (void *)mutex; + return (MutexRef)mutex; } -void OSystem_X11::lock_mutex(void *mutex) +void OSystem_X11::lock_mutex(MutexRef mutex) { pthread_mutex_lock((pthread_mutex_t *) mutex); } -void OSystem_X11::unlock_mutex(void *mutex) +void OSystem_X11::unlock_mutex(MutexRef mutex) { pthread_mutex_unlock((pthread_mutex_t *) mutex); } -void OSystem_X11::delete_mutex(void *mutex) +void OSystem_X11::delete_mutex(MutexRef mutex) { pthread_mutex_destroy((pthread_mutex_t *) mutex); free(mutex); |