Mercurial > sdl-ios-xcode
comparison src/thread/amigaos/SDL_systhread.c @ 255:dcb5e869f8b5
Updated Amiga port by Gabriele Greco
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 16 Dec 2001 20:00:27 +0000 |
parents | e8157fcb3114 |
children | f6ffac90895c |
comparison
equal
deleted
inserted
replaced
254:4fc12b8edf74 | 255:dcb5e869f8b5 |
---|---|
30 #include "SDL_error.h" | 30 #include "SDL_error.h" |
31 #include "SDL_mutex.h" | 31 #include "SDL_mutex.h" |
32 #include "SDL_thread.h" | 32 #include "SDL_thread.h" |
33 #include "SDL_thread_c.h" | 33 #include "SDL_thread_c.h" |
34 #include "SDL_systhread.h" | 34 #include "SDL_systhread.h" |
35 #include "mydebug.h" | |
35 | 36 |
36 typedef struct { | 37 typedef struct { |
37 int (*func)(void *); | 38 int (*func)(void *); |
38 void *data; | 39 void *data; |
39 SDL_Thread *info; | 40 SDL_Thread *info; |
45 #if defined(__SASC) && !defined(__PPC__) | 46 #if defined(__SASC) && !defined(__PPC__) |
46 __saveds __asm Uint32 RunThread(register __a0 char *args ) | 47 __saveds __asm Uint32 RunThread(register __a0 char *args ) |
47 #elif defined(__PPC__) | 48 #elif defined(__PPC__) |
48 Uint32 RunThread(char *args) | 49 Uint32 RunThread(char *args) |
49 #else | 50 #else |
50 Uint32 RunThread(char *args __asm("a0") ) | 51 Uint32 __saveds RunThread(char *args __asm("a0") ) |
51 #endif | 52 #endif |
52 { | 53 { |
54 #ifdef STORMC4_WOS | |
55 thread_args *data=(thread_args *)args; | |
56 #else | |
53 thread_args *data=(thread_args *)atol(args); | 57 thread_args *data=(thread_args *)atol(args); |
58 #endif | |
59 | |
54 struct Task *Father; | 60 struct Task *Father; |
55 | 61 |
56 D(bug("Received data: %lx\n",data)); | 62 D(bug("Received data: %lx\n",data)); |
57 Father=data->wait; | 63 Father=data->wait; |
58 | 64 |
59 SDL_RunThread(data); | 65 SDL_RunThread(data); |
60 | 66 |
61 Signal(Father,SIGBREAKF_CTRL_F); | 67 Signal(Father,SIGBREAKF_CTRL_F); |
68 D(bug("Thread with data %lx ended\n",data)); | |
62 return(0); | 69 return(0); |
63 } | 70 } |
64 | 71 |
65 #else | 72 #else |
66 | 73 |
67 #include <emul/emulinterface.h> | 74 #include <emul/emulinterface.h> |
68 | 75 |
69 Uint32 RunTheThread(void) | 76 Uint32 RunTheThread(void) |
70 { | 77 { |
71 thread_args *data=(thread_args *)atol(REG_A0); | 78 thread_args *data=(thread_args *)atol((char *)REG_A0); |
72 struct Task *Father; | 79 struct Task *Father; |
73 | 80 |
74 D(bug("Received data: %lx\n",data)); | 81 D(bug("Received data: %lx\n",data)); |
75 Father=data->wait; | 82 Father=data->wait; |
76 | 83 |
77 SDL_RunThread(data); | 84 SDL_RunThread(data); |
78 | 85 |
79 Signal(Father,SIGBREAKF_CTRL_F); | 86 Signal(Father,SIGBREAKF_CTRL_F); |
87 D(bug("Thread with data %lx ended\n",data)); | |
80 return(0); | 88 return(0); |
81 } | 89 } |
82 | 90 |
83 struct EmulLibEntry RunThread= | 91 struct EmulLibEntry RunThreadStruct= |
84 { | 92 { |
85 TRAP_LIB, | 93 TRAP_LIB, |
86 0, | 94 0, |
87 RunTheThread | 95 (ULONG)RunTheThread |
88 }; | 96 }; |
89 | 97 |
98 void *RunThread=&RunThreadStruct; | |
90 #endif | 99 #endif |
91 | 100 |
92 | 101 |
93 int SDL_SYS_CreateThread(SDL_Thread *thread, void *args) | 102 int SDL_SYS_CreateThread(SDL_Thread *thread, void *args) |
94 { | 103 { |
98 D(bug("Sending %lx to the new thread...\n",args)); | 107 D(bug("Sending %lx to the new thread...\n",args)); |
99 | 108 |
100 if(args) | 109 if(args) |
101 sprintf(buffer,"%ld",args); | 110 sprintf(buffer,"%ld",args); |
102 | 111 |
103 | 112 #ifdef STORMC4_WOS |
113 thread->handle=CreateTaskPPCTags(TASKATTR_CODE, RunThread, | |
114 TASKATTR_NAME, "SDL subtask", | |
115 TASKATTR_STACKSIZE, 100000, | |
116 (args ? TASKATTR_R3 : TAG_IGNORE), args, | |
117 TASKATTR_INHERITR2, TRUE, | |
118 TAG_DONE); | |
119 #else | |
104 thread->handle=(struct Task *)CreateNewProcTags(NP_Output,Output(), | 120 thread->handle=(struct Task *)CreateNewProcTags(NP_Output,Output(), |
105 NP_Name,(ULONG)"SDL subtask", | 121 NP_Name,(ULONG)"SDL subtask", |
106 NP_CloseOutput, FALSE, | 122 NP_CloseOutput, FALSE, |
107 NP_StackSize,20000, | 123 NP_StackSize,20000, |
108 NP_Entry,(ULONG)RunThread, | 124 NP_Entry,(ULONG)RunThread, |
109 args ? NP_Arguments : TAG_IGNORE,(ULONG)buffer, | 125 args ? NP_Arguments : TAG_IGNORE,(ULONG)buffer, |
110 TAG_DONE); | 126 TAG_DONE); |
127 #endif | |
128 | |
111 if(!thread->handle) | 129 if(!thread->handle) |
112 { | 130 { |
113 SDL_SetError("Not enough resources to create thread"); | 131 SDL_SetError("Not enough resources to create thread"); |
114 return(-1); | 132 return(-1); |
115 } | 133 } |