aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLionel Ulmer2002-06-04 18:18:44 +0000
committerLionel Ulmer2002-06-04 18:18:44 +0000
commit31a2efd89cdae6f8722af77177dba2a7763a94a5 (patch)
tree7aff5d5b39d746e20bd58de40e2857bce59d7788
parent08cdef16191c9ea6cdf8611a24d74748533be6d4 (diff)
downloadscummvm-rg350-31a2efd89cdae6f8722af77177dba2a7763a94a5.tar.gz
scummvm-rg350-31a2efd89cdae6f8722af77177dba2a7763a94a5.tar.bz2
scummvm-rg350-31a2efd89cdae6f8722af77177dba2a7763a94a5.zip
Sorry for the mess.... Here is the mutex code :-)
svn-id: r4403
-rw-r--r--sdl.cpp23
-rw-r--r--system.h6
-rw-r--r--x11.cpp25
3 files changed, 54 insertions, 0 deletions
diff --git a/sdl.cpp b/sdl.cpp
index 8ec7d2611c..88c120d8fa 100644
--- a/sdl.cpp
+++ b/sdl.cpp
@@ -99,6 +99,12 @@ public:
// Add a callback timer
void set_timer(int timer, int (*callback)(int));
+ // Mutex handling
+ void *create_mutex(void);
+ void lock_mutex(void *mutex);
+ void unlock_mutex(void *mutex);
+ void delete_mutex(void *mutex);
+
static OSystem *create(int gfx_mode, bool full_screen);
private:
@@ -1148,6 +1154,23 @@ void OSystem_SDL::setup_icon() {
SDL_WM_SetIcon(sdl_surf, (unsigned char *) mask);
}
+void *OSystem_SDL::create_mutex(void) {
+ return (void *) SDL_CreateMutex();
+}
+
+void OSystem_SDL::lock_mutex(void *mutex) {
+ SDL_mutexP((SDL_mutex *) mutex);
+}
+
+void OSystem_SDL::unlock_mutex(void *mutex) {
+ SDL_mutexV((SDL_mutex *) mutex);
+}
+
+void OSystem_SDL::delete_mutex(void *mutex) {
+ SDL_DestroyMutex((SDL_mutex *) mutex);
+}
+
+
#ifdef USE_NULL_DRIVER
/* NULL video driver */
diff --git a/system.h b/system.h
index 5f9d586480..8295772dcf 100644
--- a/system.h
+++ b/system.h
@@ -142,6 +142,12 @@ public:
// Add a new callback timer
virtual void set_timer(int timer, int (*callback)(int)) = 0;
+ // Mutex handling
+ virtual void *create_mutex(void) = 0;
+ virtual void lock_mutex(void *mutex) = 0;
+ virtual void unlock_mutex(void *mutex) = 0;
+ virtual void delete_mutex(void *mutex) = 0;
+
// Quit
virtual void quit() = 0;
};
diff --git a/x11.cpp b/x11.cpp
index 3de40c70a8..ae104c5376 100644
--- a/x11.cpp
+++ b/x11.cpp
@@ -116,6 +116,12 @@ public:
// Add a callback timer
void set_timer(int timer, int (*callback)(int));
+ // Mutex handling
+ void *create_mutex(void);
+ void lock_mutex(void *mutex);
+ void unlock_mutex(void *mutex);
+ void delete_mutex(void *mutex);
+
static OSystem *create(int gfx_mode, bool full_screen);
private:
@@ -936,3 +942,22 @@ void OSystem_X11::set_timer(int timer, int (*callback)(int)) {
_timer_active = false;
}
}
+
+void *OSystem_X11::create_mutex(void) {
+ pthread_mutex_t *mutex = (pthread_mutex_t *) malloc(sizeof(pthread_mutex_t));
+ pthread_mutex_init(mutex, NULL);
+ return (void *) mutex;
+}
+
+void OSystem_X11::lock_mutex(void *mutex) {
+ pthread_mutex_lock((pthread_mutex_t *) mutex);
+}
+
+void OSystem_X11::unlock_mutex(void *mutex) {
+ pthread_mutex_unlock((pthread_mutex_t *) mutex);
+}
+
+void OSystem_X11::delete_mutex(void *mutex) {
+ pthread_mutex_destroy((pthread_mutex_t *) mutex);
+ free(mutex);
+}