summaryrefslogtreecommitdiffstats
path: root/devel/sdl/files/patch-ae
blob: e879ae7decea1bbb0c99879f0954ba8186aee209 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
--- src/thread/SDL_thread.c.orig	Fri Mar  3 01:24:35 2000
+++ src/thread/SDL_thread.c	Mon Apr 17 21:05:52 2000
@@ -30,6 +30,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 
 #include "SDL_error.h"
 #include "SDL_mutex.h"
@@ -175,7 +176,7 @@
 	int (*func)(void *);
 	void *data;
 	SDL_Thread *info;
-	SDL_mutex *wait;
+	int wait;
 } thread_args;
 
 void SDL_RunThread(void *data)
@@ -199,8 +200,8 @@
 	userdata = args->data;
 	statusloc = &args->info->status;
 
	/* Wake up the parent thread */
-	SDL_mutexV(args->wait);
+	args->wait = 1;
 
 	/* Run the function */
 	*statusloc = userfunc(userdata);
@@ -213,16 +214,16 @@
 	int ret;
 
 	/* Allocate memory for the thread info structure */
-	thread = (SDL_Thread *)malloc(sizeof(*thread));
+	thread = (SDL_Thread *)malloc(sizeof(thread));
 	if ( thread == NULL ) {
 		SDL_OutOfMemory();
 		return(NULL);
 	}
-	memset(thread, 0, (sizeof *thread));
+	memset(thread, 0, (sizeof thread));
 	thread->status = -1;
 
 	/* Set up the arguments for the thread */
-	args = (thread_args *)malloc(sizeof(*args));
+	args = (thread_args *)malloc(sizeof(args));
 	if ( args == NULL ) {
 		SDL_OutOfMemory();
 		free(thread);
@@ -231,14 +232,7 @@
 	args->func = fn;
 	args->data = data;
 	args->info = thread;
-	args->wait = SDL_CreateMutex();
-	if ( args->wait == NULL ) {
-		free(thread);
-		free(args);
-		SDL_OutOfMemory();
-		return(NULL);
-	}
-	SDL_mutexP(args->wait);		/* We will block later */
+	args->wait = 0;
 
 	/* Add the thread to the list of available threads */
 	SDL_AddThread(thread);
@@ -247,14 +241,14 @@
 	ret = SDL_SYS_CreateThread(thread, args);
 	if ( ret >= 0 ) {
 		/* Wait for the thread function to use arguments */
-		SDL_mutexP(args->wait);
+		while (args->wait == 0)
+			usleep(20000);
 	} else {
 		/* Oops, failed.  Gotta free everything */
 		SDL_DelThread(thread);
 		free(thread);
 		thread = NULL;
 	}
-	SDL_DestroyMutex(args->wait);
 	free(args);
 
 	/* Everything is running now */
OpenPOWER on IntegriCloud