about summary refs log tree commit diff
path: root/src/engine/system.c
diff options
context:
space:
mode:
authorJoel de Vahl <joel@stalverk80.se>2007-10-02 16:19:25 +0000
committerJoel de Vahl <joel@stalverk80.se>2007-10-02 16:19:25 +0000
commit21df126c88230f11749bc9241ed51a26d31f0810 (patch)
treecb1975ea5c41e44f1361c96c4105c702cf865ae1 /src/engine/system.c
parent4bf60da04b668d10c53d5d3784ba3543c7a4d314 (diff)
downloadzcatch-21df126c88230f11749bc9241ed51a26d31f0810.tar.gz
zcatch-21df126c88230f11749bc9241ed51a26d31f0810.zip
sound fixes and initial lock implementation
Diffstat (limited to 'src/engine/system.c')
-rw-r--r--src/engine/system.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/engine/system.c b/src/engine/system.c
index 8717d58a..381b7ca3 100644
--- a/src/engine/system.c
+++ b/src/engine/system.c
@@ -4,6 +4,7 @@
 #include <string.h>
 #include <time.h>
 
+#include "detect.h"
 #include "system.h"
 
 #if defined(CONF_FAMILY_UNIX)
@@ -18,6 +19,7 @@
 	#include <netdb.h>      
 	#include <netinet/in.h>
 	#include <fcntl.h>
+	#include <pthread.h>
 
 	#include <dirent.h>
 	#include <unistd.h>
@@ -250,6 +252,61 @@ void thread_sleep(int milliseconds)
 #endif
 }
 
+#if defined(CONF_FAMILY_UNIX)
+typedef pthread_mutex_t LOCKINTERNAL;
+#else
+	#error not implemented on this platform
+#endif
+
+LOCK lock_create()
+{
+	LOCKINTERNAL *l = (LOCKINTERNAL*)mem_alloc(sizeof(LOCKINTERNAL), 4);
+
+#if defined(CONF_FAMILY_UNIX)
+	pthread_mutex_init(l, 0x0);
+#else
+	#error not implemented on this platform
+#endif
+	return l;
+}
+
+void lock_destroy(LOCK lock)
+{
+#if defined(CONF_FAMILY_UNIX)
+	pthread_mutex_destroy(lock);
+#else
+	#error not implemented on this platform
+#endif
+	mem_free(lock);
+}
+
+int lock_try(LOCK lock)
+{
+#if defined(CONF_FAMILY_UNIX)
+	return pthread_mutex_trylock(lock);
+#else
+	#error not implemented on this platform
+#endif
+}
+
+void lock_wait(LOCK lock)
+{
+#if defined(CONF_FAMILY_UNIX)
+	pthread_mutex_lock(lock);
+#else
+	#error not implemented on this platform
+#endif
+}
+
+void lock_release(LOCK lock)
+{
+#if defined(CONF_FAMILY_UNIX)
+	pthread_mutex_unlock(lock);
+#else
+	#error not implemented on this platform
+#endif
+}
+
 /* -----  time ----- */
 int64 time_get()
 {