comparison src/thread/pth/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 14717b52abc0
children 4da1ee79c9af
comparison
equal deleted inserted replaced
1661:281d3f4870e5 1662:782fd950bd46
34 #include "../SDL_thread_c.h" 34 #include "../SDL_thread_c.h"
35 #include "../SDL_systhread.h" 35 #include "../SDL_systhread.h"
36 36
37 /* List of signals to mask in the subthreads */ 37 /* List of signals to mask in the subthreads */
38 static int sig_list[] = { 38 static int sig_list[] = {
39 SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGCHLD, SIGWINCH, 39 SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGCHLD, SIGWINCH,
40 SIGVTALRM, SIGPROF, 0 40 SIGVTALRM, SIGPROF, 0
41 }; 41 };
42 42
43 static void *RunThread(void *data) 43 static void *
44 RunThread (void *data)
44 { 45 {
45 SDL_RunThread(data); 46 SDL_RunThread (data);
46 pth_exit((void*)0); 47 pth_exit ((void *) 0);
47 return((void *)0); /* Prevent compiler warning */ 48 return ((void *) 0); /* Prevent compiler warning */
48 } 49 }
49 50
50 int SDL_SYS_CreateThread(SDL_Thread *thread, void *args) 51 int
52 SDL_SYS_CreateThread (SDL_Thread * thread, void *args)
51 { 53 {
52 pth_attr_t type; 54 pth_attr_t type;
53 55
54 /* Create a new attribute */ 56 /* Create a new attribute */
55 type = pth_attr_new(); 57 type = pth_attr_new ();
56 if ( type == NULL ) { 58 if (type == NULL) {
57 SDL_SetError("Couldn't initialize pth attributes"); 59 SDL_SetError ("Couldn't initialize pth attributes");
58 return(-1); 60 return (-1);
59 } 61 }
60 pth_attr_set(type, PTH_ATTR_JOINABLE, TRUE); 62 pth_attr_set (type, PTH_ATTR_JOINABLE, TRUE);
61 63
62 /* Create the thread and go! */ 64 /* Create the thread and go! */
63 thread->handle = pth_spawn(type, RunThread, args); 65 thread->handle = pth_spawn (type, RunThread, args);
64 if ( thread->handle == NULL ) { 66 if (thread->handle == NULL) {
65 SDL_SetError("Not enough resources to create thread"); 67 SDL_SetError ("Not enough resources to create thread");
66 return(-1); 68 return (-1);
67 } 69 }
68 return(0); 70 return (0);
69 } 71 }
70 72
71 void SDL_SYS_SetupThread(void) 73 void
74 SDL_SYS_SetupThread (void)
72 { 75 {
73 int i; 76 int i;
74 sigset_t mask; 77 sigset_t mask;
75 int oldstate; 78 int oldstate;
76 79
77 /* Mask asynchronous signals for this thread */ 80 /* Mask asynchronous signals for this thread */
78 sigemptyset(&mask); 81 sigemptyset (&mask);
79 for ( i=0; sig_list[i]; ++i ) { 82 for (i = 0; sig_list[i]; ++i) {
80 sigaddset(&mask, sig_list[i]); 83 sigaddset (&mask, sig_list[i]);
81 } 84 }
82 pth_sigmask(SIG_BLOCK, &mask, 0); 85 pth_sigmask (SIG_BLOCK, &mask, 0);
83 86
84 /* Allow ourselves to be asynchronously cancelled */ 87 /* Allow ourselves to be asynchronously cancelled */
85 pth_cancel_state(PTH_CANCEL_ASYNCHRONOUS, &oldstate); 88 pth_cancel_state (PTH_CANCEL_ASYNCHRONOUS, &oldstate);
86 } 89 }
87 90
88 /* WARNING: This may not work for systems with 64-bit pid_t */ 91 /* WARNING: This may not work for systems with 64-bit pid_t */
89 Uint32 SDL_ThreadID(void) 92 Uint32
93 SDL_ThreadID (void)
90 { 94 {
91 return((Uint32)pth_self()); 95 return ((Uint32) pth_self ());
92 } 96 }
93 97
94 void SDL_SYS_WaitThread(SDL_Thread *thread) 98 void
99 SDL_SYS_WaitThread (SDL_Thread * thread)
95 { 100 {
96 pth_join(thread->handle, NULL); 101 pth_join (thread->handle, NULL);
97 } 102 }
98 103
99 void SDL_SYS_KillThread(SDL_Thread *thread) 104 void
105 SDL_SYS_KillThread (SDL_Thread * thread)
100 { 106 {
101 pth_cancel(thread->handle); 107 pth_cancel (thread->handle);
102 pth_join(thread->handle, NULL); 108 pth_join (thread->handle, NULL);
103 } 109 }
110
111 /* vi: set ts=4 sw=4 expandtab: */