Mercurial > sdl-ios-xcode
comparison src/thread/SDL_thread.c @ 3578:0d1b16ee0bca
Fixed bug #741
The thread ID is an unsigned long so it can hold pthread_t so people can do naughty things with it.
I'm going to be adding additional useful thread API functions, but this should prevent crashes in people's existing code on 64-bit architectures.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 16 Dec 2009 04:48:11 +0000 |
parents | 34a4a01da79c |
children | f7b03b6838cb |
comparison
equal
deleted
inserted
replaced
3577:72024425b437 | 3578:0d1b16ee0bca |
---|---|
157 SDL_error *errbuf; | 157 SDL_error *errbuf; |
158 | 158 |
159 errbuf = &SDL_global_error; | 159 errbuf = &SDL_global_error; |
160 if (SDL_Threads) { | 160 if (SDL_Threads) { |
161 int i; | 161 int i; |
162 Uint32 this_thread; | 162 SDL_threadID this_thread; |
163 | 163 |
164 this_thread = SDL_ThreadID(); | 164 this_thread = SDL_ThreadID(); |
165 SDL_mutexP(thread_lock); | 165 SDL_mutexP(thread_lock); |
166 for (i = 0; i < SDL_numthreads; ++i) { | 166 for (i = 0; i < SDL_numthreads; ++i) { |
167 if (this_thread == SDL_Threads[i]->threadid) { | 167 if (this_thread == SDL_Threads[i]->threadid) { |
290 SDL_DelThread(thread); | 290 SDL_DelThread(thread); |
291 SDL_free(thread); | 291 SDL_free(thread); |
292 } | 292 } |
293 } | 293 } |
294 | 294 |
295 Uint32 | 295 SDL_threadID |
296 SDL_GetThreadID(SDL_Thread * thread) | 296 SDL_GetThreadID(SDL_Thread * thread) |
297 { | 297 { |
298 Uint32 id; | 298 SDL_threadID id; |
299 | 299 |
300 if (thread) { | 300 if (thread) { |
301 id = thread->threadid; | 301 id = thread->threadid; |
302 } else { | 302 } else { |
303 id = SDL_ThreadID(); | 303 id = SDL_ThreadID(); |
304 } | 304 } |
305 return (id); | 305 return id; |
306 } | 306 } |
307 | 307 |
308 void | 308 void |
309 SDL_KillThread(SDL_Thread * thread) | 309 SDL_KillThread(SDL_Thread * thread) |
310 { | 310 { |