win32 thread creation fix

This commit is contained in:
jsorg71 2006-09-23 01:57:16 +00:00
parent de8343eca5
commit e0d2711c90

View File

@ -28,13 +28,20 @@
#include "arch.h" #include "arch.h"
/*****************************************************************************/ /*****************************************************************************/
/* returns error */
#if defined(_WIN32) #if defined(_WIN32)
int APP_CC int APP_CC
g_thread_create(unsigned long (__stdcall * start_routine)(void*), void* arg) g_thread_create(unsigned long (__stdcall * start_routine)(void*), void* arg)
{ {
DWORD thread; DWORD thread_id;
HANDLE thread;
int rv;
return !CreateThread(0, 0, start_routine, arg, 0, &thread); /* CreateThread returns handle or zero on error */
thread = CreateThread(0, 0, start_routine, arg, 0, &thread_id);
rv = !thread;
CloseHandle(thread);
return rv;
} }
#else #else
int APP_CC int APP_CC
@ -43,6 +50,7 @@ g_thread_create(void* (* start_routine)(void*), void* arg)
pthread_t thread; pthread_t thread;
int rv; int rv;
/* pthread_create returns error */
rv = pthread_create(&thread, 0, start_routine, arg); rv = pthread_create(&thread, 0, start_routine, arg);
pthread_detach(thread); pthread_detach(thread);
return rv; return rv;