comparison src/thread/os2/SDL_systhread.c @ 1668:4da1ee79c9af SDL-1.3

more tweaking indent options
author Sam Lantinga <slouken@libsdl.org>
date Mon, 29 May 2006 04:04:35 +0000
parents 782fd950bd46
children
comparison
equal deleted inserted replaced
1667:1fddae038bc8 1668:4da1ee79c9af
37 void *args; 37 void *args;
38 pfnSDL_CurrentEndThread pfnCurrentEndThread; 38 pfnSDL_CurrentEndThread pfnCurrentEndThread;
39 } tThreadStartParms, *pThreadStartParms; 39 } tThreadStartParms, *pThreadStartParms;
40 40
41 static void 41 static void
42 threadfunc (void *pparm) 42 threadfunc(void *pparm)
43 { 43 {
44 pThreadStartParms pThreadParms = pparm; 44 pThreadStartParms pThreadParms = pparm;
45 pfnSDL_CurrentEndThread pfnCurrentEndThread = NULL; 45 pfnSDL_CurrentEndThread pfnCurrentEndThread = NULL;
46 46
47 // Call the thread function! 47 // Call the thread function!
48 SDL_RunThread (pThreadParms->args); 48 SDL_RunThread(pThreadParms->args);
49 49
50 // Get the current endthread we have to use! 50 // Get the current endthread we have to use!
51 if (pThreadParms) { 51 if (pThreadParms) {
52 pfnCurrentEndThread = pThreadParms->pfnCurrentEndThread; 52 pfnCurrentEndThread = pThreadParms->pfnCurrentEndThread;
53 SDL_free (pThreadParms); 53 SDL_free(pThreadParms);
54 } 54 }
55 // Call endthread! 55 // Call endthread!
56 if (pfnCurrentEndThread) 56 if (pfnCurrentEndThread)
57 (*pfnCurrentEndThread) (); 57 (*pfnCurrentEndThread) ();
58 } 58 }
59 59
60 int 60 int
61 SDL_SYS_CreateThread (SDL_Thread * thread, void *args, 61 SDL_SYS_CreateThread(SDL_Thread * thread, void *args,
62 pfnSDL_CurrentBeginThread pfnBeginThread, 62 pfnSDL_CurrentBeginThread pfnBeginThread,
63 pfnSDL_CurrentEndThread pfnEndThread) 63 pfnSDL_CurrentEndThread pfnEndThread)
64 { 64 {
65 pThreadStartParms pThreadParms = SDL_malloc (sizeof (tThreadStartParms)); 65 pThreadStartParms pThreadParms = SDL_malloc(sizeof(tThreadStartParms));
66 if (!pThreadParms) { 66 if (!pThreadParms) {
67 SDL_SetError ("Not enough memory to create thread"); 67 SDL_SetError("Not enough memory to create thread");
68 return (-1); 68 return (-1);
69 } 69 }
70 // Save the function which we will have to call to clear the RTL of calling app! 70 // Save the function which we will have to call to clear the RTL of calling app!
71 pThreadParms->pfnCurrentEndThread = pfnEndThread; 71 pThreadParms->pfnCurrentEndThread = pfnEndThread;
72 // Also save the real parameters we have to pass to thread function 72 // Also save the real parameters we have to pass to thread function
73 pThreadParms->args = args; 73 pThreadParms->args = args;
74 // Start the thread using the runtime library of calling app! 74 // Start the thread using the runtime library of calling app!
75 thread->threadid = thread->handle = 75 thread->threadid = thread->handle =
76 (*pfnBeginThread) (threadfunc, NULL, 512 * 1024, pThreadParms); 76 (*pfnBeginThread) (threadfunc, NULL, 512 * 1024, pThreadParms);
77 if ((int) thread->threadid <= 0) { 77 if ((int) thread->threadid <= 0) {
78 SDL_SetError ("Not enough resources to create thread"); 78 SDL_SetError("Not enough resources to create thread");
79 return (-1); 79 return (-1);
80 } 80 }
81 return (0); 81 return (0);
82 } 82 }
83 83
84 void 84 void
85 SDL_SYS_SetupThread (void) 85 SDL_SYS_SetupThread(void)
86 { 86 {
87 return; 87 return;
88 } 88 }
89 89
90 DECLSPEC Uint32 SDLCALL 90 DECLSPEC Uint32 SDLCALL
91 SDL_ThreadID (void) 91 SDL_ThreadID(void)
92 { 92 {
93 PTIB tib; 93 PTIB tib;
94 DosGetInfoBlocks (&tib, NULL); 94 DosGetInfoBlocks(&tib, NULL);
95 return ((Uint32) (tib->tib_ptib2->tib2_ultid)); 95 return ((Uint32) (tib->tib_ptib2->tib2_ultid));
96 } 96 }
97 97
98 void 98 void
99 SDL_SYS_WaitThread (SDL_Thread * thread) 99 SDL_SYS_WaitThread(SDL_Thread * thread)
100 { 100 {
101 TID tid = thread->handle; 101 TID tid = thread->handle;
102 DosWaitThread (&tid, DCWW_WAIT); 102 DosWaitThread(&tid, DCWW_WAIT);
103 } 103 }
104 104
105 /* WARNING: This function is really a last resort. 105 /* WARNING: This function is really a last resort.
106 * Threads should be signaled and then exit by themselves. 106 * Threads should be signaled and then exit by themselves.
107 * TerminateThread() doesn't perform stack and DLL cleanup. 107 * TerminateThread() doesn't perform stack and DLL cleanup.
108 */ 108 */
109 void 109 void
110 SDL_SYS_KillThread (SDL_Thread * thread) 110 SDL_SYS_KillThread(SDL_Thread * thread)
111 { 111 {
112 DosKillThread (thread->handle); 112 DosKillThread(thread->handle);
113 } 113 }
114 114
115 /* vi: set ts=4 sw=4 expandtab: */ 115 /* vi: set ts=4 sw=4 expandtab: */