+2008-10-12 Bruno Haible <bruno@clisp.org>
+
+ Use msvcrt aware primitives for creation/termination of Win32 threads.
+ * lib/glthread/thread.c: Include <process.h>.
+ (glthread_create_func): Use _beginthreadex instead of CreateThread.
+ (wrapper_func): Update signature.
+ (gl_thread_exit_func): Use _endthreadex instead of EndThread.
+
2008-10-11 Yoann Vandoorselaere <yoann@prelude-ids.org>
Bruno Haible <bruno@clisp.org>
#if USE_WIN32_THREADS
+#include <process.h>
+
/* -------------------------- gl_thread_t datatype -------------------------- */
/* The Thread-Local Storage (TLS) key that allows to access each thread's
/* The main function of a freshly creating thread. It's a wrapper around
the FUNC and ARG arguments passed to glthread_create_func. */
-static DWORD WINAPI
+static unsigned int WINAPI
wrapper_func (void *varg)
{
struct gl_thread_struct *thread = (struct gl_thread_struct *)varg;
thread->arg = arg;
{
- DWORD thread_id;
+ unsigned int thread_id;
HANDLE thread_handle;
- thread_handle =
- CreateThread (NULL, 100000, wrapper_func, thread, 0, &thread_id);
+ thread_handle = (HANDLE)
+ _beginthreadex (NULL, 100000, wrapper_func, thread, 0, &thread_id);
+ /* calls CreateThread with the same arguments */
if (thread_handle == NULL)
{
DeleteCriticalSection (&thread->handle_lock);
{
gl_thread_t thread = gl_thread_self ();
thread->result = retval;
- ExitThread (0);
+ _endthreadex (0); /* calls ExitThread (0) */
}
#endif