Mercurial > sdl-ios-xcode
comparison src/thread/beos/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 | d910939febfa |
children | 4436464c4f51 |
comparison
equal
deleted
inserted
replaced
1894:c69cee13dd76 | 1895:c121d94672cb |
---|---|
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: */ |