Mercurial > sdl-ios-xcode
annotate src/thread/amigaos/SDL_systhread.c @ 42:eb1459f3a3ae
*** empty log message ***
author | Sam Lantinga <slouken@lokigames.com> |
---|---|
date | Sun, 27 May 2001 00:38:26 +0000 |
parents | 75a95f82bc1f |
children | e8157fcb3114 |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
3 Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga | |
4 | |
5 This library is free software; you can redistribute it and/or | |
6 modify it under the terms of the GNU Library General Public | |
7 License as published by the Free Software Foundation; either | |
8 version 2 of the License, or (at your option) any later version. | |
9 | |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 Library General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU Library General Public | |
16 License along with this library; if not, write to the Free | |
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | |
19 Sam Lantinga | |
20 slouken@devolution.com | |
21 */ | |
22 | |
23 #ifdef SAVE_RCSID | |
24 static char rcsid = | |
25 "@(#) $Id$"; | |
26 #endif | |
27 | |
21
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
28 /* BeOS thread management routines for SDL */ |
0 | 29 |
30 #include "SDL_error.h" | |
31 #include "SDL_mutex.h" | |
32 #include "SDL_thread.h" | |
33 #include "SDL_thread_c.h" | |
34 #include "SDL_systhread.h" | |
35 | |
36 typedef struct { | |
37 int (*func)(void *); | |
38 void *data; | |
39 SDL_Thread *info; | |
40 struct Task *wait; | |
41 } thread_args; | |
42 | |
21
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
43 #ifndef MORPHOS |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
44 |
0 | 45 #if defined(__SASC) && !defined(__PPC__) |
46 __saveds __asm Uint32 RunThread(register __a0 char *args ) | |
47 #elif defined(__PPC__) | |
48 Uint32 RunThread(char *args) | |
49 #else | |
50 Uint32 RunThread(char *args __asm("a0") ) | |
51 #endif | |
52 { | |
53 thread_args *data=(thread_args *)atol(args); | |
54 struct Task *Father; | |
55 | |
56 D(bug("Received data: %lx\n",data)); | |
57 Father=data->wait; | |
58 | |
59 SDL_RunThread(data); | |
60 | |
61 Signal(Father,SIGBREAKF_CTRL_F); | |
62 return(0); | |
63 } | |
64 | |
21
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
65 #else |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
66 |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
67 #include <emul/emulinterface.h> |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
68 |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
69 Uint32 RunTheThread(void) |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
70 { |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
71 thread_args *data=(thread_args *)atol(REG_A0); |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
72 struct Task *Father; |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
73 |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
74 D(bug("Received data: %lx\n",data)); |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
75 Father=data->wait; |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
76 |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
77 SDL_RunThread(data); |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
78 |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
79 Signal(Father,SIGBREAKF_CTRL_F); |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
80 return(0); |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
81 } |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
82 |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
83 struct EmulLibEntry RunThread= |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
84 { |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
85 TRAP_LIB, |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
86 0, |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
87 RunTheThread |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
88 }; |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
89 |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
90 #endif |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
91 |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
92 |
0 | 93 int SDL_SYS_CreateThread(SDL_Thread *thread, void *args) |
94 { | |
95 /* Create the thread and go! */ | |
96 char buffer[20]; | |
97 | |
98 D(bug("Sending %lx to the new thread...\n",args)); | |
99 | |
100 if(args) | |
101 sprintf(buffer,"%ld",args); | |
102 | |
103 | |
104 thread->handle=(struct Task *)CreateNewProcTags(NP_Output,Output(), | |
105 NP_Name,(ULONG)"SDL subtask", | |
106 NP_CloseOutput, FALSE, | |
107 NP_StackSize,20000, | |
108 NP_Entry,(ULONG)RunThread, | |
109 args ? NP_Arguments : TAG_IGNORE,(ULONG)buffer, | |
110 TAG_DONE); | |
111 if(!thread->handle) | |
112 { | |
113 SDL_SetError("Not enough resources to create thread"); | |
114 return(-1); | |
115 } | |
116 | |
117 return(0); | |
118 } | |
119 | |
120 void SDL_SYS_SetupThread(void) | |
121 { | |
122 } | |
123 | |
124 Uint32 SDL_ThreadID(void) | |
125 { | |
126 return((Uint32)FindTask(NULL)); | |
127 } | |
128 | |
129 void SDL_SYS_WaitThread(SDL_Thread *thread) | |
130 { | |
21
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
131 SetSignal(0L,SIGBREAKF_CTRL_F|SIGBREAKF_CTRL_C); |
0 | 132 Wait(SIGBREAKF_CTRL_F|SIGBREAKF_CTRL_C); |
133 } | |
134 | |
135 void SDL_SYS_KillThread(SDL_Thread *thread) | |
136 { | |
137 Signal((struct Task *)thread->handle,SIGBREAKF_CTRL_C); | |
138 } |