comparison src/thread/beos/SDL_systhread.c @ 1662:782fd950bd46 SDL-1.3

Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API. WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid. The code is now run through a consistent indent format: indent -i4 -nut -nsc -br -ce The headers are being converted to automatically generate doxygen documentation.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 28 May 2006 13:04:16 +0000
parents d910939febfa
children 4da1ee79c9af
comparison
equal deleted inserted replaced
1661:281d3f4870e5 1662:782fd950bd46
32 #include "../SDL_thread_c.h" 32 #include "../SDL_thread_c.h"
33 #include "../SDL_systhread.h" 33 #include "../SDL_systhread.h"
34 34
35 35
36 static int sig_list[] = { 36 static int sig_list[] = {
37 SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGWINCH, 0 37 SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGWINCH, 0
38 }; 38 };
39 39
40 void SDL_MaskSignals(sigset_t *omask) 40 void
41 SDL_MaskSignals (sigset_t * omask)
41 { 42 {
42 sigset_t mask; 43 sigset_t mask;
43 int i; 44 int i;
44 45
45 sigemptyset(&mask); 46 sigemptyset (&mask);
46 for ( i=0; sig_list[i]; ++i ) { 47 for (i = 0; sig_list[i]; ++i) {
47 sigaddset(&mask, sig_list[i]); 48 sigaddset (&mask, sig_list[i]);
48 } 49 }
49 sigprocmask(SIG_BLOCK, &mask, omask); 50 sigprocmask (SIG_BLOCK, &mask, omask);
50 }
51 void SDL_UnmaskSignals(sigset_t *omask)
52 {
53 sigprocmask(SIG_SETMASK, omask, NULL);
54 } 51 }
55 52
56 static int32 RunThread(void *data) 53 void
54 SDL_UnmaskSignals (sigset_t * omask)
57 { 55 {
58 SDL_RunThread(data); 56 sigprocmask (SIG_SETMASK, omask, NULL);
59 return(0);
60 } 57 }
61 58
62 int SDL_SYS_CreateThread(SDL_Thread *thread, void *args) 59 static int32
60 RunThread (void *data)
63 { 61 {
64 /* Create the thread and go! */ 62 SDL_RunThread (data);
65 thread->handle=spawn_thread(RunThread, "SDL", B_NORMAL_PRIORITY, args); 63 return (0);
66 if ( (thread->handle == B_NO_MORE_THREADS) ||
67 (thread->handle == B_NO_MEMORY) ) {
68 SDL_SetError("Not enough resources to create thread");
69 return(-1);
70 }
71 resume_thread(thread->handle);
72 return(0);
73 } 64 }
74 65
75 void SDL_SYS_SetupThread(void) 66 int
67 SDL_SYS_CreateThread (SDL_Thread * thread, void *args)
76 { 68 {
77 /* Mask asynchronous signals for this thread */ 69 /* Create the thread and go! */
78 SDL_MaskSignals(NULL); 70 thread->handle = spawn_thread (RunThread, "SDL", B_NORMAL_PRIORITY, args);
71 if ((thread->handle == B_NO_MORE_THREADS) ||
72 (thread->handle == B_NO_MEMORY)) {
73 SDL_SetError ("Not enough resources to create thread");
74 return (-1);
75 }
76 resume_thread (thread->handle);
77 return (0);
79 } 78 }
80 79
81 Uint32 SDL_ThreadID(void) 80 void
81 SDL_SYS_SetupThread (void)
82 { 82 {
83 return((Uint32)find_thread(NULL)); 83 /* Mask asynchronous signals for this thread */
84 SDL_MaskSignals (NULL);
84 } 85 }
85 86
86 void SDL_SYS_WaitThread(SDL_Thread *thread) 87 Uint32
88 SDL_ThreadID (void)
87 { 89 {
88 status_t the_status; 90 return ((Uint32) find_thread (NULL));
89
90 wait_for_thread(thread->handle, &the_status);
91 } 91 }
92 92
93 void SDL_SYS_KillThread(SDL_Thread *thread) 93 void
94 SDL_SYS_WaitThread (SDL_Thread * thread)
94 { 95 {
95 kill_thread(thread->handle); 96 status_t the_status;
97
98 wait_for_thread (thread->handle, &the_status);
96 } 99 }
100
101 void
102 SDL_SYS_KillThread (SDL_Thread * thread)
103 {
104 kill_thread (thread->handle);
105 }
106
107 /* vi: set ts=4 sw=4 expandtab: */