Mercurial > sdl-ios-xcode
diff src/thread/os2/SDL_systhread.c @ 1895:c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 10 Jul 2006 21:04:37 +0000 |
parents | 9ebbbb4ae53b |
children | 4436464c4f51 |
line wrap: on
line diff
--- a/src/thread/os2/SDL_systhread.c Thu Jul 06 18:01:37 2006 +0000 +++ b/src/thread/os2/SDL_systhread.c Mon Jul 10 21:04:37 2006 +0000 @@ -34,75 +34,82 @@ typedef struct ThreadStartParms { - void *args; - pfnSDL_CurrentEndThread pfnCurrentEndThread; + void *args; + pfnSDL_CurrentEndThread pfnCurrentEndThread; } tThreadStartParms, *pThreadStartParms; -static void threadfunc(void *pparm) +static void +threadfunc(void *pparm) { - pThreadStartParms pThreadParms = pparm; - pfnSDL_CurrentEndThread pfnCurrentEndThread = NULL; + pThreadStartParms pThreadParms = pparm; + pfnSDL_CurrentEndThread pfnCurrentEndThread = NULL; - // Call the thread function! - SDL_RunThread(pThreadParms->args); + // Call the thread function! + SDL_RunThread(pThreadParms->args); - // Get the current endthread we have to use! - if (pThreadParms) - { - pfnCurrentEndThread = pThreadParms->pfnCurrentEndThread; - SDL_free(pThreadParms); - } - // Call endthread! - if (pfnCurrentEndThread) - (*pfnCurrentEndThread)(); + // Get the current endthread we have to use! + if (pThreadParms) { + pfnCurrentEndThread = pThreadParms->pfnCurrentEndThread; + SDL_free(pThreadParms); + } + // Call endthread! + if (pfnCurrentEndThread) + (*pfnCurrentEndThread) (); } -int SDL_SYS_CreateThread(SDL_Thread *thread, void *args, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread) +int +SDL_SYS_CreateThread(SDL_Thread * thread, void *args, + pfnSDL_CurrentBeginThread pfnBeginThread, + pfnSDL_CurrentEndThread pfnEndThread) { - pThreadStartParms pThreadParms = SDL_malloc(sizeof(tThreadStartParms)); - if (!pThreadParms) - { - SDL_SetError("Not enough memory to create thread"); - return(-1); - } - - // Save the function which we will have to call to clear the RTL of calling app! - pThreadParms->pfnCurrentEndThread = pfnEndThread; - // Also save the real parameters we have to pass to thread function - pThreadParms->args = args; - // Start the thread using the runtime library of calling app! - thread->threadid = thread->handle = (*pfnBeginThread)(threadfunc, NULL, 512*1024, pThreadParms); - if ((int)thread->threadid <= 0) - { - SDL_SetError("Not enough resources to create thread"); - return(-1); - } - return(0); + pThreadStartParms pThreadParms = SDL_malloc(sizeof(tThreadStartParms)); + if (!pThreadParms) { + SDL_SetError("Not enough memory to create thread"); + return (-1); + } + // Save the function which we will have to call to clear the RTL of calling app! + pThreadParms->pfnCurrentEndThread = pfnEndThread; + // Also save the real parameters we have to pass to thread function + pThreadParms->args = args; + // Start the thread using the runtime library of calling app! + thread->threadid = thread->handle = + (*pfnBeginThread) (threadfunc, NULL, 512 * 1024, pThreadParms); + if ((int) thread->threadid <= 0) { + SDL_SetError("Not enough resources to create thread"); + return (-1); + } + return (0); } -void SDL_SYS_SetupThread(void) +void +SDL_SYS_SetupThread(void) { - return; + return; } -DECLSPEC Uint32 SDLCALL SDL_ThreadID(void) +DECLSPEC Uint32 SDLCALL +SDL_ThreadID(void) { - PTIB tib; - DosGetInfoBlocks(&tib, NULL); - return((Uint32) (tib->tib_ptib2->tib2_ultid)); + PTIB tib; + DosGetInfoBlocks(&tib, NULL); + return ((Uint32) (tib->tib_ptib2->tib2_ultid)); } -void SDL_SYS_WaitThread(SDL_Thread *thread) +void +SDL_SYS_WaitThread(SDL_Thread * thread) { - TID tid = thread->handle; - DosWaitThread(&tid, DCWW_WAIT); + TID tid = thread->handle; + DosWaitThread(&tid, DCWW_WAIT); } /* WARNING: This function is really a last resort. * Threads should be signaled and then exit by themselves. * TerminateThread() doesn't perform stack and DLL cleanup. */ -void SDL_SYS_KillThread(SDL_Thread *thread) +void +SDL_SYS_KillThread(SDL_Thread * thread) { - DosKillThread(thread->handle); + DosKillThread(thread->handle); } + +/* vi: set ts=4 sw=4 expandtab: */