Use the standard CreateThread routine to create 16-bit tasks instead
[wine/multimedia.git] / scheduler / thread.c
blob77daaacf8ed67c9cb8777ad7ccedcf9a3041b640
1 /*
2 * Win32 threads
4 * Copyright 1996 Alexandre Julliard
5 */
7 #include "config.h"
9 #include <assert.h>
10 #include <fcntl.h>
11 #include <sys/types.h>
12 #ifdef HAVE_SYS_MMAN_H
13 #include <sys/mman.h>
14 #endif
15 #include <unistd.h>
16 #include "wine/winbase16.h"
17 #include "wine/port.h"
18 #include "thread.h"
19 #include "task.h"
20 #include "module.h"
21 #include "winerror.h"
22 #include "heap.h"
23 #include "selectors.h"
24 #include "winnt.h"
25 #include "server.h"
26 #include "services.h"
27 #include "stackframe.h"
28 #include "builtin16.h"
29 #include "debugtools.h"
30 #include "winnls.h"
32 DEFAULT_DEBUG_CHANNEL(thread);
34 /* TEB of the initial thread */
35 static TEB initial_teb;
37 extern struct _PDB current_process;
39 /***********************************************************************
40 * THREAD_IsWin16
42 BOOL THREAD_IsWin16( TEB *teb )
44 return !teb || !(teb->tibflags & TEBF_WIN32);
47 /***********************************************************************
48 * THREAD_IdToTEB
50 * Convert a thread id to a TEB, making sure it is valid.
52 TEB *THREAD_IdToTEB( DWORD id )
54 TEB *ret = NULL;
56 if (!id || id == GetCurrentThreadId()) return NtCurrentTeb();
58 SERVER_START_REQ( get_thread_info )
60 req->handle = 0;
61 req->tid_in = (void *)id;
62 if (!SERVER_CALL()) ret = req->teb;
64 SERVER_END_REQ;
66 if (!ret)
68 /* Allow task handles to be used; convert to main thread */
69 if ( IsTask16( id ) )
71 TDB *pTask = (TDB *)GlobalLock16( id );
72 if (pTask) return pTask->teb;
74 SetLastError( ERROR_INVALID_PARAMETER );
76 return ret;
80 /***********************************************************************
81 * THREAD_InitTEB
83 * Initialization of a newly created TEB.
85 static BOOL THREAD_InitTEB( TEB *teb )
87 teb->except = (void *)~0UL;
88 teb->self = teb;
89 teb->tibflags = TEBF_WIN32;
90 teb->tls_ptr = teb->tls_array;
91 teb->exit_code = STILL_ACTIVE;
92 teb->socket = -1;
93 teb->request_fd = -1;
94 teb->reply_fd = -1;
95 teb->wait_fd = -1;
96 teb->stack_top = (void *)~0UL;
97 teb->StaticUnicodeString.MaximumLength = sizeof(teb->StaticUnicodeBuffer);
98 teb->StaticUnicodeString.Buffer = (PWSTR)teb->StaticUnicodeBuffer;
99 teb->teb_sel = SELECTOR_AllocBlock( teb, 0x1000, WINE_LDT_FLAGS_DATA|WINE_LDT_FLAGS_32BIT );
100 return (teb->teb_sel != 0);
104 /***********************************************************************
105 * THREAD_FreeTEB
107 * Free data structures associated with a thread.
108 * Must be called from the context of another thread.
110 static void CALLBACK THREAD_FreeTEB( TEB *teb )
112 TRACE("(%p) called\n", teb );
113 if (teb->cleanup) SERVICE_Delete( teb->cleanup );
115 /* Free the associated memory */
117 if (teb->socket != -1) close( teb->socket );
118 close( teb->request_fd );
119 close( teb->reply_fd );
120 close( teb->wait_fd );
121 if (teb->stack_sel) FreeSelector16( teb->stack_sel );
122 FreeSelector16( teb->teb_sel );
123 if (teb->buffer) munmap( (void *)teb->buffer, teb->buffer_size );
124 if (teb->debug_info) HeapFree( GetProcessHeap(), 0, teb->debug_info );
125 VirtualFree( teb->stack_base, 0, MEM_RELEASE );
129 /***********************************************************************
130 * THREAD_InitStack
132 * Allocate the stack of a thread.
134 TEB *THREAD_InitStack( TEB *teb, DWORD stack_size )
136 DWORD old_prot, total_size;
137 DWORD page_size = getpagesize();
138 void *base;
140 /* Allocate the stack */
142 if (stack_size >= 16*1024*1024)
143 WARN("Thread stack size is %ld MB.\n",stack_size/1024/1024);
145 /* if size is smaller than default, get stack size from parent */
146 if (stack_size < 1024 * 1024)
148 if (teb)
149 stack_size = 1024 * 1024; /* no parent */
150 else
151 stack_size = ((char *)NtCurrentTeb()->stack_top - (char *)NtCurrentTeb()->stack_base
152 - SIGNAL_STACK_SIZE - 3 * page_size);
155 /* FIXME: some Wine functions use a lot of stack, so we add 64Kb here */
156 stack_size += 64 * 1024;
158 /* Memory layout in allocated block:
160 * size contents
161 * 1 page NOACCESS guard page
162 * SIGNAL_STACK_SIZE signal stack
163 * 1 page NOACCESS guard page
164 * 1 page PAGE_GUARD guard page
165 * stack_size normal stack
166 * 64Kb 16-bit stack (optional)
167 * 1 page TEB (except for initial thread)
170 stack_size = (stack_size + (page_size - 1)) & ~(page_size - 1);
171 total_size = stack_size + SIGNAL_STACK_SIZE + 3 * page_size;
172 total_size += 0x10000; /* 16-bit stack */
173 if (!teb) total_size += page_size;
175 if (!(base = VirtualAlloc( NULL, total_size, MEM_COMMIT, PAGE_EXECUTE_READWRITE )))
176 return NULL;
178 if (!teb)
180 teb = (TEB *)((char *)base + total_size - page_size);
181 if (!THREAD_InitTEB( teb ))
183 VirtualFree( base, 0, MEM_RELEASE );
184 return NULL;
188 teb->stack_low = base;
189 teb->stack_base = base;
190 teb->signal_stack = (char *)base + page_size;
191 teb->stack_top = (char *)base + 3 * page_size + SIGNAL_STACK_SIZE + stack_size;
193 /* Setup guard pages */
195 VirtualProtect( base, 1, PAGE_NOACCESS, &old_prot );
196 VirtualProtect( (char *)teb->signal_stack + SIGNAL_STACK_SIZE, 1, PAGE_NOACCESS, &old_prot );
197 VirtualProtect( (char *)teb->signal_stack + SIGNAL_STACK_SIZE + page_size, 1,
198 PAGE_EXECUTE_READWRITE | PAGE_GUARD, &old_prot );
200 /* Allocate the 16-bit stack selector */
202 teb->stack_sel = SELECTOR_AllocBlock( teb->stack_top, 0x10000, WINE_LDT_FLAGS_DATA );
203 if (!teb->stack_sel) goto error;
204 teb->cur_stack = MAKESEGPTR( teb->stack_sel, 0x10000 - sizeof(STACK16FRAME) );
206 return teb;
208 error:
209 THREAD_FreeTEB( teb );
210 return NULL;
214 /***********************************************************************
215 * thread_errno_location
217 * Get the per-thread errno location.
219 static int *thread_errno_location(void)
221 return &NtCurrentTeb()->thread_errno;
224 /***********************************************************************
225 * thread_h_errno_location
227 * Get the per-thread h_errno location.
229 static int *thread_h_errno_location(void)
231 return &NtCurrentTeb()->thread_h_errno;
234 /***********************************************************************
235 * THREAD_Init
237 * Setup the initial thread.
239 * NOTES: The first allocated TEB on NT is at 0x7ffde000.
241 void THREAD_Init(void)
243 if (!initial_teb.self) /* do it only once */
245 THREAD_InitTEB( &initial_teb );
246 assert( initial_teb.teb_sel );
247 initial_teb.process = &current_process;
248 SYSDEPS_SetCurThread( &initial_teb );
249 wine_errno_location = thread_errno_location;
250 wine_h_errno_location = thread_h_errno_location;
254 DECL_GLOBAL_CONSTRUCTOR(thread_init) { THREAD_Init(); }
257 /***********************************************************************
258 * THREAD_Start
260 * Start execution of a newly created thread. Does not return.
262 static void THREAD_Start(void)
264 HANDLE cleanup_object;
265 LPTHREAD_START_ROUTINE func = (LPTHREAD_START_ROUTINE)NtCurrentTeb()->entry_point;
267 /* install cleanup handler */
268 if (DuplicateHandle( GetCurrentProcess(), GetCurrentThread(),
269 GetCurrentProcess(), &cleanup_object,
270 0, FALSE, DUPLICATE_SAME_ACCESS ))
271 NtCurrentTeb()->cleanup = SERVICE_AddObject( cleanup_object, (PAPCFUNC)THREAD_FreeTEB,
272 (ULONG_PTR)NtCurrentTeb() );
274 PROCESS_CallUserSignalProc( USIG_THREAD_INIT, 0 );
275 PE_InitTls();
276 MODULE_DllThreadAttach( NULL );
277 ExitThread( func( NtCurrentTeb()->entry_arg ) );
281 /***********************************************************************
282 * CreateThread (KERNEL32.@)
284 HANDLE WINAPI CreateThread( SECURITY_ATTRIBUTES *sa, DWORD stack,
285 LPTHREAD_START_ROUTINE start, LPVOID param,
286 DWORD flags, LPDWORD id )
288 int socket = -1;
289 HANDLE handle = 0;
290 TEB *teb;
291 void *tid = 0;
293 SERVER_START_REQ( new_thread )
295 req->suspend = ((flags & CREATE_SUSPENDED) != 0);
296 req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
297 if (!SERVER_CALL_ERR())
299 handle = req->handle;
300 tid = req->tid;
301 socket = wine_server_recv_fd( handle, 0 );
304 SERVER_END_REQ;
305 if (!handle) return 0;
307 if (!(teb = THREAD_InitStack( NULL, stack )))
309 close( socket );
310 return 0;
313 teb->process = NtCurrentTeb()->process;
314 teb->socket = socket;
315 teb->entry_point = start;
316 teb->entry_arg = param;
317 teb->startup = THREAD_Start;
318 teb->htask16 = GetCurrentTask();
319 fcntl( socket, F_SETFD, 1 ); /* set close on exec flag */
321 if (id) *id = (DWORD)tid;
322 if (SYSDEPS_SpawnThread( teb ) == -1)
324 CloseHandle( handle );
325 THREAD_FreeTEB( teb );
326 return 0;
328 return handle;
331 /***********************************************************************
332 * CreateThread16 (KERNEL.441)
334 static DWORD CALLBACK THREAD_StartThread16( LPVOID threadArgs )
336 FARPROC16 start = ((FARPROC16 *)threadArgs)[0];
337 DWORD param = ((DWORD *)threadArgs)[1];
338 HeapFree( GetProcessHeap(), 0, threadArgs );
340 ((LPDWORD)CURRENT_STACK16)[-1] = param;
341 return wine_call_to_16_long( start, sizeof(DWORD) );
343 HANDLE WINAPI CreateThread16( SECURITY_ATTRIBUTES *sa, DWORD stack,
344 FARPROC16 start, SEGPTR param,
345 DWORD flags, LPDWORD id )
347 DWORD *threadArgs = HeapAlloc( GetProcessHeap(), 0, 2*sizeof(DWORD) );
348 if (!threadArgs) return INVALID_HANDLE_VALUE;
349 threadArgs[0] = (DWORD)start;
350 threadArgs[1] = (DWORD)param;
352 return CreateThread( sa, stack, THREAD_StartThread16, threadArgs, flags, id );
356 /***********************************************************************
357 * ExitThread [KERNEL32.215] Ends a thread
359 * RETURNS
360 * None
362 void WINAPI ExitThread( DWORD code ) /* [in] Exit code for this thread */
364 BOOL last;
365 SERVER_START_REQ( terminate_thread )
367 /* send the exit code to the server */
368 req->handle = GetCurrentThread();
369 req->exit_code = code;
370 SERVER_CALL();
371 last = req->last;
373 SERVER_END_REQ;
375 if (last)
377 MODULE_DllProcessDetach( TRUE, (LPVOID)1 );
378 exit( code );
380 else
382 MODULE_DllThreadDetach( NULL );
383 if (!(NtCurrentTeb()->tibflags & TEBF_WIN32)) TASK_ExitTask();
384 SYSDEPS_ExitThread( code );
389 /***********************************************************************
390 * SetThreadContext [KERNEL32.670] Sets context of thread.
392 * RETURNS
393 * Success: TRUE
394 * Failure: FALSE
396 BOOL WINAPI SetThreadContext( HANDLE handle, /* [in] Handle to thread with context */
397 const CONTEXT *context ) /* [in] Address of context structure */
399 BOOL ret;
400 SERVER_START_VAR_REQ( set_thread_context, sizeof(*context) )
402 req->handle = handle;
403 req->flags = context->ContextFlags;
404 memcpy( server_data_ptr(req), context, sizeof(*context) );
405 ret = !SERVER_CALL_ERR();
407 SERVER_END_VAR_REQ;
408 return ret;
412 /***********************************************************************
413 * GetThreadContext [KERNEL32.@] Retrieves context of thread.
415 * RETURNS
416 * Success: TRUE
417 * Failure: FALSE
419 BOOL WINAPI GetThreadContext( HANDLE handle, /* [in] Handle to thread with context */
420 CONTEXT *context ) /* [out] Address of context structure */
422 BOOL ret;
423 SERVER_START_VAR_REQ( get_thread_context, sizeof(*context) )
425 req->handle = handle;
426 req->flags = context->ContextFlags;
427 memcpy( server_data_ptr(req), context, sizeof(*context) );
428 if ((ret = !SERVER_CALL_ERR()))
429 memcpy( context, server_data_ptr(req), sizeof(*context) );
431 SERVER_END_VAR_REQ;
432 return ret;
436 /**********************************************************************
437 * GetThreadPriority [KERNEL32.@] Returns priority for thread.
439 * RETURNS
440 * Success: Thread's priority level.
441 * Failure: THREAD_PRIORITY_ERROR_RETURN
443 INT WINAPI GetThreadPriority(
444 HANDLE hthread) /* [in] Handle to thread */
446 INT ret = THREAD_PRIORITY_ERROR_RETURN;
447 SERVER_START_REQ( get_thread_info )
449 req->handle = hthread;
450 req->tid_in = 0;
451 if (!SERVER_CALL_ERR()) ret = req->priority;
453 SERVER_END_REQ;
454 return ret;
458 /**********************************************************************
459 * SetThreadPriority [KERNEL32.@] Sets priority for thread.
461 * RETURNS
462 * Success: TRUE
463 * Failure: FALSE
465 BOOL WINAPI SetThreadPriority(
466 HANDLE hthread, /* [in] Handle to thread */
467 INT priority) /* [in] Thread priority level */
469 BOOL ret;
470 SERVER_START_REQ( set_thread_info )
472 req->handle = hthread;
473 req->priority = priority;
474 req->mask = SET_THREAD_INFO_PRIORITY;
475 ret = !SERVER_CALL_ERR();
477 SERVER_END_REQ;
478 return ret;
482 /**********************************************************************
483 * GetThreadPriorityBoost [KERNEL32.877] Returns priority boost for thread.
485 * Always reports that priority boost is disabled.
487 * RETURNS
488 * Success: TRUE.
489 * Failure: FALSE
491 BOOL WINAPI GetThreadPriorityBoost(
492 HANDLE hthread, /* [in] Handle to thread */
493 PBOOL pstate) /* [out] pointer to var that receives the boost state */
495 if (pstate) *pstate = FALSE;
496 return NO_ERROR;
500 /**********************************************************************
501 * SetThreadPriorityBoost [KERNEL32.893] Sets priority boost for thread.
503 * Priority boost is not implemented. Thsi function always returns
504 * FALSE and sets last error to ERROR_CALL_NOT_IMPLEMENTED
506 * RETURNS
507 * Always returns FALSE to indicate a failure
509 BOOL WINAPI SetThreadPriorityBoost(
510 HANDLE hthread, /* [in] Handle to thread */
511 BOOL disable) /* [in] TRUE to disable priority boost */
513 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
514 return FALSE;
518 /**********************************************************************
519 * SetThreadAffinityMask (KERNEL32.669)
521 DWORD WINAPI SetThreadAffinityMask( HANDLE hThread, DWORD dwThreadAffinityMask )
523 DWORD ret;
524 SERVER_START_REQ( set_thread_info )
526 req->handle = hThread;
527 req->affinity = dwThreadAffinityMask;
528 req->mask = SET_THREAD_INFO_AFFINITY;
529 ret = !SERVER_CALL_ERR();
530 /* FIXME: should return previous value */
532 SERVER_END_REQ;
533 return ret;
537 /**********************************************************************
538 * TerminateThread [KERNEL32.685] Terminates a thread
540 * RETURNS
541 * Success: TRUE
542 * Failure: FALSE
544 BOOL WINAPI TerminateThread( HANDLE handle, /* [in] Handle to thread */
545 DWORD exit_code) /* [in] Exit code for thread */
547 NTSTATUS status = NtTerminateThread( handle, exit_code );
548 if (status) SetLastError( RtlNtStatusToDosError(status) );
549 return !status;
553 /**********************************************************************
554 * GetExitCodeThread (KERNEL32.@)
555 * GetExitCodeThread (WIN32S16.13)
557 * Gets termination status of thread.
559 * RETURNS
560 * Success: TRUE
561 * Failure: FALSE
563 BOOL WINAPI GetExitCodeThread(
564 HANDLE hthread, /* [in] Handle to thread */
565 LPDWORD exitcode) /* [out] Address to receive termination status */
567 BOOL ret;
568 SERVER_START_REQ( get_thread_info )
570 req->handle = hthread;
571 req->tid_in = 0;
572 ret = !SERVER_CALL_ERR();
573 if (ret && exitcode) *exitcode = req->exit_code;
575 SERVER_END_REQ;
576 return ret;
580 /**********************************************************************
581 * ResumeThread [KERNEL32.587] Resumes a thread.
583 * Decrements a thread's suspend count. When count is zero, the
584 * execution of the thread is resumed.
586 * RETURNS
587 * Success: Previous suspend count
588 * Failure: 0xFFFFFFFF
589 * Already running: 0
591 DWORD WINAPI ResumeThread(
592 HANDLE hthread) /* [in] Identifies thread to restart */
594 DWORD ret = 0xffffffff;
595 SERVER_START_REQ( resume_thread )
597 req->handle = hthread;
598 if (!SERVER_CALL_ERR()) ret = req->count;
600 SERVER_END_REQ;
601 return ret;
605 /**********************************************************************
606 * SuspendThread [KERNEL32.681] Suspends a thread.
608 * RETURNS
609 * Success: Previous suspend count
610 * Failure: 0xFFFFFFFF
612 DWORD WINAPI SuspendThread(
613 HANDLE hthread) /* [in] Handle to the thread */
615 DWORD ret = 0xffffffff;
616 SERVER_START_REQ( suspend_thread )
618 req->handle = hthread;
619 if (!SERVER_CALL_ERR()) ret = req->count;
621 SERVER_END_REQ;
622 return ret;
626 /***********************************************************************
627 * QueueUserAPC (KERNEL32.566)
629 DWORD WINAPI QueueUserAPC( PAPCFUNC func, HANDLE hthread, ULONG_PTR data )
631 DWORD ret;
632 SERVER_START_REQ( queue_apc )
634 req->handle = hthread;
635 req->user = 1;
636 req->func = func;
637 req->param = (void *)data;
638 ret = !SERVER_CALL_ERR();
640 SERVER_END_REQ;
641 return ret;
645 /**********************************************************************
646 * GetThreadTimes [KERNEL32.@] Obtains timing information.
648 * NOTES
649 * What are the fields where these values are stored?
651 * RETURNS
652 * Success: TRUE
653 * Failure: FALSE
655 BOOL WINAPI GetThreadTimes(
656 HANDLE thread, /* [in] Specifies the thread of interest */
657 LPFILETIME creationtime, /* [out] When the thread was created */
658 LPFILETIME exittime, /* [out] When the thread was destroyed */
659 LPFILETIME kerneltime, /* [out] Time thread spent in kernel mode */
660 LPFILETIME usertime) /* [out] Time thread spent in user mode */
662 FIXME("(0x%08x): stub\n",thread);
663 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
664 return FALSE;
668 /**********************************************************************
669 * VWin32_BoostThreadGroup [KERNEL.535]
671 VOID WINAPI VWin32_BoostThreadGroup( DWORD threadId, INT boost )
673 FIXME("(0x%08lx,%d): stub\n", threadId, boost);
676 /**********************************************************************
677 * VWin32_BoostThreadStatic [KERNEL.536]
679 VOID WINAPI VWin32_BoostThreadStatic( DWORD threadId, INT boost )
681 FIXME("(0x%08lx,%d): stub\n", threadId, boost);
685 /***********************************************************************
686 * GetThreadLocale (KERNEL32.@)
688 LCID WINAPI GetThreadLocale(void)
690 LCID ret = NtCurrentTeb()->CurrentLocale;
691 if (!ret) NtCurrentTeb()->CurrentLocale = ret = GetUserDefaultLCID();
692 return ret;
696 /**********************************************************************
697 * SetThreadLocale [KERNEL32.671] Sets the calling threads current locale.
699 * RETURNS
700 * Success: TRUE
701 * Failure: FALSE
703 * FIXME
704 * check if lcid is a valid cp
706 BOOL WINAPI SetThreadLocale(
707 LCID lcid) /* [in] Locale identifier */
709 switch (lcid)
711 case LOCALE_SYSTEM_DEFAULT:
712 lcid = GetSystemDefaultLCID();
713 break;
714 case LOCALE_USER_DEFAULT:
715 case LOCALE_NEUTRAL:
716 lcid = GetUserDefaultLCID();
717 break;
719 NtCurrentTeb()->CurrentLocale = lcid;
720 return TRUE;
724 /***********************************************************************
725 * GetCurrentThread [KERNEL32.@] Gets pseudohandle for current thread
727 * RETURNS
728 * Pseudohandle for the current thread
730 #undef GetCurrentThread
731 HANDLE WINAPI GetCurrentThread(void)
733 return 0xfffffffe;
737 /***********************************************************************
738 * ProcessIdToSessionId (KERNEL32.@)
739 * This function is available on Terminal Server 4SP4 and Windows 2000
741 BOOL WINAPI ProcessIdToSessionId( DWORD procid, DWORD *sessionid_ptr )
743 /* According to MSDN, if the calling process is not in a terminal
744 * services environment, then the sessionid returned is zero.
746 *sessionid_ptr = 0;
747 return TRUE;
751 #ifdef __i386__
753 /* void WINAPI SetLastError( DWORD error ); */
754 __ASM_GLOBAL_FUNC( SetLastError,
755 "movl 4(%esp),%eax\n\t"
756 ".byte 0x64\n\t"
757 "movl %eax,0x60\n\t"
758 "ret $4" );
760 /* DWORD WINAPI GetLastError(void); */
761 __ASM_GLOBAL_FUNC( GetLastError, ".byte 0x64\n\tmovl 0x60,%eax\n\tret" );
763 /* DWORD WINAPI GetCurrentProcessId(void) */
764 __ASM_GLOBAL_FUNC( GetCurrentProcessId, ".byte 0x64\n\tmovl 0x20,%eax\n\tret" );
766 /* DWORD WINAPI GetCurrentThreadId(void) */
767 __ASM_GLOBAL_FUNC( GetCurrentThreadId, ".byte 0x64\n\tmovl 0x24,%eax\n\tret" );
769 #else /* __i386__ */
771 /**********************************************************************
772 * SetLastError (KERNEL.147)
773 * SetLastError (KERNEL32.@)
775 * Sets the last-error code.
777 void WINAPI SetLastError( DWORD error ) /* [in] Per-thread error code */
779 NtCurrentTeb()->last_error = error;
782 /**********************************************************************
783 * GetLastError (KERNEL.10)
784 * GetLastError (KERNEL32.@)
785 * GetLastError (WIN32S16.10)
787 * Returns last-error code.
789 DWORD WINAPI GetLastError(void)
791 return NtCurrentTeb()->last_error;
794 /***********************************************************************
795 * GetCurrentProcessId (KERNEL.471)
796 * GetCurrentProcessId (KERNEL32.@)
798 * Returns process identifier.
800 DWORD WINAPI GetCurrentProcessId(void)
802 return (DWORD)NtCurrentTeb()->pid;
805 /***********************************************************************
806 * GetCurrentThreadId (KERNEL.462)
807 * GetCurrentThreadId (KERNEL32.@)
809 * Returns thread identifier.
811 DWORD WINAPI GetCurrentThreadId(void)
813 return (DWORD)NtCurrentTeb()->tid;
816 #endif /* __i386__ */