summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.c1
-rw-r--r--messagepump.c1
-rw-r--r--threading_pthread.c22
3 files changed, 7 insertions, 17 deletions
diff --git a/main.c b/main.c
index 0980175f..688f9ee5 100644
--- a/main.c
+++ b/main.c
@@ -19,7 +19,6 @@ int psdl_terminate = 0;
void
psdl_thread (uintptr_t ctx) {
- printf ("psdl_thread started!\n");
psdl_play ();
while (!psdl_terminate) {
uint32_t msg;
diff --git a/messagepump.c b/messagepump.c
index 9967a8dc..abdcb390 100644
--- a/messagepump.c
+++ b/messagepump.c
@@ -31,6 +31,7 @@ void
messagepump_free () {
mutex_lock (mutex);
messagepump_reset ();
+ mutex_unlock (mutex);
mutex_free (mutex);
}
diff --git a/threading_pthread.c b/threading_pthread.c
index 76dd65a5..17ad59e3 100644
--- a/threading_pthread.c
+++ b/threading_pthread.c
@@ -4,37 +4,23 @@
#include "threading.h"
void thread_start (void (*fn)(uintptr_t ctx), uintptr_t ctx) {
- printf ("thread_start called!\n");
pthread_t tid;
pthread_attr_t attr;
- printf ("pthread_attr_init!\n");
int s = pthread_attr_init (&attr);
if (s) {
printf ("pthread_attr_init failed\n");
return;
}
- printf ("pthread_create!\n");
if (pthread_create (&tid, &attr, (void *(*)(void *))fn, (void*)ctx)) {
printf ("pthread_create failed\n");
return;
}
- printf ("pthread_attr_destroy!\n");
s = pthread_attr_destroy (&attr);
if (s) {
printf ("pthread_attr_destroy failed\n");
return;
}
-#if 0
- void *res;
- printf ("pthread_join!\n");
- s = pthread_join (tid, &res);
- if (s) {
- printf ("pthread_join failed\n");
- return;
- }
- free (res);
-#endif
}
uintptr_t mutex_create (void) {
pthread_mutex_t *mtx = malloc (sizeof (pthread_mutex_t));
@@ -52,10 +38,14 @@ void mutex_free (uintptr_t _mtx) {
}
int mutex_lock (uintptr_t _mtx) {
pthread_mutex_t *mtx = (pthread_mutex_t *)_mtx;
- pthread_mutex_lock (mtx);
+ if (pthread_mutex_lock (mtx)) {
+ printf ("pthread_mutex_lock failed\n");
+ }
}
int mutex_unlock (uintptr_t _mtx) {
pthread_mutex_t *mtx = (pthread_mutex_t *)_mtx;
- pthread_mutex_unlock (mtx);
+ if (pthread_mutex_unlock (mtx)) {
+ printf ("pthread_mutex_unlock failed\n");
+ };
}