Mercurial > sdl-ios-xcode
annotate src/thread/irix/SDL_systhread.c @ 1077:f122afdfa025
The Darwin/MacOSX joystick code is largely copied from the HID Utilities
package...make the symbols defined by HID Utilities static inside SDL so that
an app can link against their own copy of this package without symbol clash.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Wed, 15 Jun 2005 23:41:57 +0000 |
parents | b8d311d90021 |
children | c9b51268668f |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
769
b8d311d90021
Updated copyright information for 2004 (Happy New Year!)
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
3 Copyright (C) 1997-2004 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
6 modify it under the terms of the GNU Library General Public | |
7 License as published by the Free Software Foundation; either | |
8 version 2 of the License, or (at your option) any later version. | |
9 | |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 Library General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU Library General Public | |
16 License along with this library; if not, write to the Free | |
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
22 | |
23 #ifdef SAVE_RCSID | |
24 static char rcsid = | |
25 "@(#) $Id$"; | |
26 #endif | |
27 | |
28 /* IRIX thread management routines for SDL */ | |
29 | |
30 #include <stdlib.h> | |
31 #include <errno.h> | |
32 #include <signal.h> | |
33 #include <sys/types.h> | |
34 #include <sys/wait.h> | |
35 #include <sys/prctl.h> | |
36 | |
37 #include "SDL_error.h" | |
38 #include "SDL_thread.h" | |
39 #include "SDL_systhread.h" | |
40 | |
41 | |
42 static int sig_list[] = { | |
43 SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGCLD, SIGWINCH, | |
44 SIGVTALRM, SIGPROF, 0 | |
45 }; | |
46 | |
47 | |
48 int SDL_SYS_CreateThread(SDL_Thread *thread, void *args) | |
49 { | |
50 /* Create the thread and go! */ | |
51 if ( sproc(SDL_RunThread, PR_SALL, args) < 0 ) { | |
52 SDL_SetError("Not enough resources to create thread"); | |
53 return(-1); | |
54 } | |
55 return(0); | |
56 } | |
57 | |
58 void SDL_SYS_SetupThread(void) | |
59 { | |
60 int i; | |
61 sigset_t mask; | |
62 | |
63 /* Mask asynchronous signals for this thread */ | |
64 sigemptyset(&mask); | |
65 for ( i=0; sig_list[i]; ++i ) { | |
66 sigaddset(&mask, sig_list[i]); | |
67 } | |
68 sigprocmask(SIG_BLOCK, &mask, NULL); | |
69 } | |
70 | |
71 /* WARNING: This may not work for systems with 64-bit pid_t */ | |
72 Uint32 SDL_ThreadID(void) | |
73 { | |
74 return((Uint32)getpid()); | |
75 } | |
76 | |
77 /* WARNING: This may not work for systems with 64-bit pid_t */ | |
78 void SDL_WaitThread(SDL_Thread *thread, int *status) | |
79 { | |
80 errno = 0; | |
81 while ( errno != ECHILD ) { | |
82 waitpid(thread->handle, NULL, 0); | |
83 } | |
84 } | |
85 | |
86 /* WARNING: This may not work for systems with 64-bit pid_t */ | |
87 void SDL_KillThread(SDL_Thread *thread) | |
88 { | |
89 kill(thread->handle, SIGKILL); | |
90 } | |
91 |