comparison src/thread/riscos/SDL_systhread.c @ 1668:4da1ee79c9af SDL-1.3

more tweaking indent options
author Sam Lantinga <slouken@libsdl.org>
date Mon, 29 May 2006 04:04:35 +0000
parents 782fd950bd46
children
comparison
equal deleted inserted replaced
1667:1fddae038bc8 1668:4da1ee79c9af
27 #include "../SDL_systhread.h" 27 #include "../SDL_systhread.h"
28 28
29 #if SDL_THREADS_DISABLED 29 #if SDL_THREADS_DISABLED
30 30
31 int 31 int
32 SDL_SYS_CreateThread (SDL_Thread * thread, void *args) 32 SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
33 { 33 {
34 SDL_SetError 34 SDL_SetError
35 ("Threads have not been compiled into this version of the library"); 35 ("Threads have not been compiled into this version of the library");
36 return (-1); 36 return (-1);
37 } 37 }
38 38
39 void 39 void
40 SDL_SYS_SetupThread (void) 40 SDL_SYS_SetupThread(void)
41 { 41 {
42 return; 42 return;
43 } 43 }
44 44
45 Uint32 45 Uint32
46 SDL_ThreadID (void) 46 SDL_ThreadID(void)
47 { 47 {
48 return (0); 48 return (0);
49 } 49 }
50 50
51 void 51 void
52 SDL_SYS_WaitThread (SDL_Thread * thread) 52 SDL_SYS_WaitThread(SDL_Thread * thread)
53 { 53 {
54 return; 54 return;
55 } 55 }
56 56
57 void 57 void
58 SDL_SYS_KillThread (SDL_Thread * thread) 58 SDL_SYS_KillThread(SDL_Thread * thread)
59 { 59 {
60 return; 60 return;
61 } 61 }
62 62
63 #else 63 #else
74 74
75 int riscos_using_threads = 0; 75 int riscos_using_threads = 0;
76 Uint32 riscos_main_thread = 0; /* Thread running events */ 76 Uint32 riscos_main_thread = 0; /* Thread running events */
77 77
78 static void * 78 static void *
79 RunThread (void *data) 79 RunThread(void *data)
80 { 80 {
81 SDL_RunThread (data); 81 SDL_RunThread(data);
82 pthread_exit ((void *) 0); 82 pthread_exit((void *) 0);
83 return ((void *) 0); /* Prevent compiler warning */ 83 return ((void *) 0); /* Prevent compiler warning */
84 } 84 }
85 85
86 int 86 int
87 SDL_SYS_CreateThread (SDL_Thread * thread, void *args) 87 SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
88 { 88 {
89 pthread_attr_t type; 89 pthread_attr_t type;
90 90
91 /* Set the thread attributes */ 91 /* Set the thread attributes */
92 if (pthread_attr_init (&type) != 0) { 92 if (pthread_attr_init(&type) != 0) {
93 SDL_SetError ("Couldn't initialize pthread attributes"); 93 SDL_SetError("Couldn't initialize pthread attributes");
94 return (-1); 94 return (-1);
95 } 95 }
96 pthread_attr_setdetachstate (&type, PTHREAD_CREATE_JOINABLE); 96 pthread_attr_setdetachstate(&type, PTHREAD_CREATE_JOINABLE);
97 97
98 /* Create the thread and go! */ 98 /* Create the thread and go! */
99 if (pthread_create (&thread->handle, &type, RunThread, args) != 0) { 99 if (pthread_create(&thread->handle, &type, RunThread, args) != 0) {
100 SDL_SetError ("Not enough resources to create thread"); 100 SDL_SetError("Not enough resources to create thread");
101 return (-1); 101 return (-1);
102 } 102 }
103 103
104 if (riscos_using_threads == 0) { 104 if (riscos_using_threads == 0) {
105 riscos_using_threads = 1; 105 riscos_using_threads = 1;
106 riscos_main_thread = SDL_ThreadID (); 106 riscos_main_thread = SDL_ThreadID();
107 } 107 }
108 108
109 return (0); 109 return (0);
110 } 110 }
111 111
112 void 112 void
113 SDL_SYS_SetupThread (void) 113 SDL_SYS_SetupThread(void)
114 { 114 {
115 int i; 115 int i;
116 sigset_t mask; 116 sigset_t mask;
117 117
118 /* Mask asynchronous signals for this thread */ 118 /* Mask asynchronous signals for this thread */
119 sigemptyset (&mask); 119 sigemptyset(&mask);
120 for (i = 0; sig_list[i]; ++i) { 120 for (i = 0; sig_list[i]; ++i) {
121 sigaddset (&mask, sig_list[i]); 121 sigaddset(&mask, sig_list[i]);
122 } 122 }
123 pthread_sigmask (SIG_BLOCK, &mask, 0); 123 pthread_sigmask(SIG_BLOCK, &mask, 0);
124 124
125 #ifdef PTHREAD_CANCEL_ASYNCHRONOUS 125 #ifdef PTHREAD_CANCEL_ASYNCHRONOUS
126 /* Allow ourselves to be asynchronously cancelled */ 126 /* Allow ourselves to be asynchronously cancelled */
127 { 127 {
128 int oldstate; 128 int oldstate;
129 pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &oldstate); 129 pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldstate);
130 } 130 }
131 #endif 131 #endif
132 } 132 }
133 133
134 Uint32 134 Uint32
135 SDL_ThreadID (void) 135 SDL_ThreadID(void)
136 { 136 {
137 return ((Uint32) pthread_self ()); 137 return ((Uint32) pthread_self());
138 } 138 }
139 139
140 void 140 void
141 SDL_SYS_WaitThread (SDL_Thread * thread) 141 SDL_SYS_WaitThread(SDL_Thread * thread)
142 { 142 {
143 pthread_join (thread->handle, 0); 143 pthread_join(thread->handle, 0);
144 } 144 }
145 145
146 void 146 void
147 SDL_SYS_KillThread (SDL_Thread * thread) 147 SDL_SYS_KillThread(SDL_Thread * thread)
148 { 148 {
149 #ifdef PTHREAD_CANCEL_ASYNCHRONOUS 149 #ifdef PTHREAD_CANCEL_ASYNCHRONOUS
150 pthread_cancel (thread->handle); 150 pthread_cancel(thread->handle);
151 #else 151 #else
152 pthread_kill (thread->handle, SIGKILL); 152 pthread_kill(thread->handle, SIGKILL);
153 #endif 153 #endif
154 } 154 }
155 155
156 #endif 156 #endif
157 /* vi: set ts=4 sw=4 expandtab: */ 157 /* vi: set ts=4 sw=4 expandtab: */