comparison src/thread/amigaos/SDL_systhread.c @ 0:74212992fb08

Initial revision
author Sam Lantinga <slouken@lokigames.com>
date Thu, 26 Apr 2001 16:45:43 +0000
parents
children 75a95f82bc1f
comparison
equal deleted inserted replaced
-1:000000000000 0:74212992fb08
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
28 /* AmigaOS thread management routines for SDL */
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
43 #if defined(__SASC) && !defined(__PPC__)
44 __saveds __asm Uint32 RunThread(register __a0 char *args )
45 #elif defined(__PPC__)
46 Uint32 RunThread(char *args)
47 #else
48 Uint32 RunThread(char *args __asm("a0") )
49 #endif
50 {
51 thread_args *data=(thread_args *)atol(args);
52 struct Task *Father;
53
54 D(bug("Received data: %lx\n",data));
55 Father=data->wait;
56
57 SDL_RunThread(data);
58
59 Signal(Father,SIGBREAKF_CTRL_F);
60 return(0);
61 }
62
63 int SDL_SYS_CreateThread(SDL_Thread *thread, void *args)
64 {
65 /* Create the thread and go! */
66 char buffer[20];
67
68 D(bug("Sending %lx to the new thread...\n",args));
69
70 if(args)
71 sprintf(buffer,"%ld",args);
72
73
74 thread->handle=(struct Task *)CreateNewProcTags(NP_Output,Output(),
75 NP_Name,(ULONG)"SDL subtask",
76 NP_CloseOutput, FALSE,
77 NP_StackSize,20000,
78 NP_Entry,(ULONG)RunThread,
79 args ? NP_Arguments : TAG_IGNORE,(ULONG)buffer,
80 TAG_DONE);
81 if(!thread->handle)
82 {
83 SDL_SetError("Not enough resources to create thread");
84 return(-1);
85 }
86
87 return(0);
88 }
89
90 void SDL_SYS_SetupThread(void)
91 {
92 }
93
94 Uint32 SDL_ThreadID(void)
95 {
96 return((Uint32)FindTask(NULL));
97 }
98
99 void SDL_SYS_WaitThread(SDL_Thread *thread)
100 {
101 Wait(SIGBREAKF_CTRL_F|SIGBREAKF_CTRL_C);
102 }
103
104 void SDL_SYS_KillThread(SDL_Thread *thread)
105 {
106 Signal((struct Task *)thread->handle,SIGBREAKF_CTRL_C);
107 }