2 * msvcrt.dll thread functions
4 * Copyright 2000 Jon Griffiths
8 #include "msvcrt/process.h"
10 DEFAULT_DEBUG_CHANNEL(msvcrt);
12 /********************************************************************/
15 _beginthread_start_routine_t start_address;
17 } _beginthread_trampoline_t;
19 /*********************************************************************
20 * _beginthread_trampoline
22 static DWORD CALLBACK _beginthread_trampoline(LPVOID arg)
24 _beginthread_trampoline_t *trampoline = arg;
25 trampoline->start_address(trampoline->arglist);
29 /*********************************************************************
30 * _beginthread (MSVCRT.@)
32 unsigned long _beginthread(
33 _beginthread_start_routine_t start_address, /* [in] Start address of routine that begins execution of new thread */
34 unsigned int stack_size, /* [in] Stack size for new thread or 0 */
35 void *arglist) /* [in] Argument list to be passed to new thread or NULL */
37 _beginthread_trampoline_t trampoline;
39 TRACE("(%p, %d, %p)\n", start_address, stack_size, arglist);
41 trampoline.start_address = start_address;
42 trampoline.arglist = arglist;
45 return CreateThread(NULL, stack_size, _beginthread_trampoline, &trampoline, 0, NULL);
48 /*********************************************************************
49 * _beginthreadex (MSVCRT.@)
51 unsigned long _beginthreadex(
52 void *security, /* [in] Security descriptor for new thread; must be NULL for Windows 9x applications */
53 unsigned int stack_size, /* [in] Stack size for new thread or 0 */
54 _beginthreadex_start_routine_t start_address, /* [in] Start address of routine that begins execution of new thread */
55 void *arglist, /* [in] Argument list to be passed to new thread or NULL */
56 unsigned int initflag, /* [in] Initial state of new thread (0 for running or CREATE_SUSPEND for suspended) */
57 unsigned int *thrdaddr) /* [out] Points to a 32-bit variable that receives the thread identifier */
59 TRACE("(%p, %d, %p, %p, %d, %p)\n", security, stack_size, start_address, arglist, initflag, thrdaddr);
62 return CreateThread(security, stack_size, (LPTHREAD_START_ROUTINE) start_address,
63 arglist, initflag, (LPDWORD) thrdaddr);
66 /*********************************************************************
67 * _endthread (MSVCRT.@)
77 /*********************************************************************
78 * _endthreadex (MSVCRT.@)
81 unsigned int retval) /* [in] Thread exit code */
83 TRACE("(%d)\n", retval);