4 * Copyright 1996 Alexandre Julliard
11 #include <sys/types.h>
12 #ifdef HAVE_SYS_SOCKET_H
13 # include <sys/socket.h>
15 #ifdef HAVE_SYS_MMAN_H
19 #include "wine/winbase16.h"
27 #include "selectors.h"
31 #include "stackframe.h"
32 #include "builtin16.h"
33 #include "debugtools.h"
37 DEFAULT_DEBUG_CHANNEL(thread
)
39 /* TEB of the initial thread */
40 static TEB initial_teb
;
42 /* Global thread list (FIXME: not thread-safe) */
43 TEB
*THREAD_First
= &initial_teb
;
45 /***********************************************************************
48 BOOL
THREAD_IsWin16( TEB
*teb
)
50 return !teb
|| !(teb
->flags
& TEBF_WIN32
);
53 /***********************************************************************
56 * Convert a thread id to a TEB, making sure it is valid.
58 TEB
*THREAD_IdToTEB( DWORD id
)
60 TEB
*teb
= THREAD_First
;
62 if (!id
) return NtCurrentTeb();
65 if ((DWORD
)teb
->tid
== id
) return teb
;
68 /* Allow task handles to be used; convert to main thread */
71 TDB
*pTask
= (TDB
*)GlobalLock16( id
);
72 if (pTask
) return pTask
->teb
;
74 SetLastError( ERROR_INVALID_PARAMETER
);
79 /***********************************************************************
82 * Initialization of a newly created TEB.
84 static BOOL
THREAD_InitTEB( TEB
*teb
, DWORD stack_size
, BOOL alloc_stack16
,
85 LPSECURITY_ATTRIBUTES sa
)
89 /* Allocate the stack */
92 * If stacksize smaller than 1 MB, allocate 1MB
93 * (one program wanted only 10 kB, which is recommendable, but some WINE
94 * functions, noteably in the files subdir, push HUGE structures and
95 * arrays on the stack. They probably shouldn't.)
96 * If stacksize larger than 16 MB, warn the user. (We could shrink the stack
97 * but this could give more or less unexplainable crashes.)
99 if (stack_size
<1024*1024)
100 stack_size
= 1024 * 1024;
101 if (stack_size
>= 16*1024*1024)
102 WARN("Thread stack size is %ld MB.\n",stack_size
/1024/1024);
103 teb
->stack_base
= VirtualAlloc(NULL
, stack_size
+ SIGNAL_STACK_SIZE
+
104 (alloc_stack16
? 0x10000 : 0),
105 MEM_COMMIT
, PAGE_EXECUTE_READWRITE
);
106 if (!teb
->stack_base
) goto error
;
107 /* Set a guard page at the bottom of the stack */
108 VirtualProtect( teb
->stack_base
, 1, PAGE_EXECUTE_READWRITE
| PAGE_GUARD
, &old_prot
);
109 teb
->stack_top
= (char *)teb
->stack_base
+ stack_size
;
110 teb
->stack_low
= teb
->stack_base
;
111 teb
->signal_stack
= teb
->stack_top
; /* start of signal stack */
113 /* Allocate the 16-bit stack selector */
117 teb
->stack_sel
= SELECTOR_AllocBlock( teb
->stack_top
, 0x10000, SEGMENT_DATA
,
119 if (!teb
->stack_sel
) goto error
;
120 teb
->cur_stack
= PTR_SEG_OFF_TO_SEGPTR( teb
->stack_sel
,
121 0x10000 - sizeof(STACK16FRAME
) );
122 teb
->signal_stack
= (char *)teb
->signal_stack
+ 0x10000;
125 /* Create the thread event */
127 if (!(teb
->event
= CreateEventA( NULL
, FALSE
, FALSE
, NULL
))) goto error
;
128 teb
->event
= ConvertToGlobalHandle( teb
->event
);
132 if (teb
->event
) CloseHandle( teb
->event
);
133 if (teb
->stack_sel
) SELECTOR_FreeBlock( teb
->stack_sel
, 1 );
134 if (teb
->stack_base
) VirtualFree( teb
->stack_base
, 0, MEM_RELEASE
);
139 /***********************************************************************
142 * Free data structures associated with a thread.
143 * Must be called from the context of another thread.
145 void CALLBACK
THREAD_FreeTEB( ULONG_PTR arg
)
147 TEB
*teb
= (TEB
*)arg
;
148 TEB
**pptr
= &THREAD_First
;
150 TRACE("(%p) called\n", teb
);
151 SERVICE_Delete( teb
->cleanup
);
153 PROCESS_CallUserSignalProc( USIG_THREAD_EXIT
, (DWORD
)teb
->tid
, 0 );
155 CloseHandle( teb
->event
);
156 while (*pptr
&& (*pptr
!= teb
)) pptr
= &(*pptr
)->next
;
157 if (*pptr
) *pptr
= teb
->next
;
159 /* Free the associated memory */
161 if (teb
->stack_sel
) SELECTOR_FreeBlock( teb
->stack_sel
, 1 );
162 SELECTOR_FreeBlock( teb
->teb_sel
, 1 );
163 close( teb
->socket
);
164 if (teb
->buffer
) munmap( teb
->buffer
, teb
->buffer_size
);
165 VirtualFree( teb
->stack_base
, 0, MEM_RELEASE
);
166 VirtualFree( teb
, 0, MEM_FREE
);
170 /***********************************************************************
171 * THREAD_CreateInitialThread
173 * Create the initial thread.
175 TEB
*THREAD_CreateInitialThread( PDB
*pdb
, int server_fd
)
177 initial_teb
.except
= (void *)-1;
178 initial_teb
.self
= &initial_teb
;
179 initial_teb
.flags
= /* TEBF_WIN32 */ 0;
180 initial_teb
.tls_ptr
= initial_teb
.tls_array
;
181 initial_teb
.process
= pdb
;
182 initial_teb
.exit_code
= 0x103; /* STILL_ACTIVE */
183 initial_teb
.socket
= server_fd
;
185 /* Allocate the TEB selector (%fs register) */
187 if (!(initial_teb
.teb_sel
= SELECTOR_AllocBlock( &initial_teb
, 0x1000,
188 SEGMENT_DATA
, TRUE
, FALSE
)))
190 MESSAGE("Could not allocate fs register for initial thread\n" );
193 SYSDEPS_SetCurThread( &initial_teb
);
195 /* Now proceed with normal initialization */
197 if (CLIENT_InitThread()) return NULL
;
198 if (!THREAD_InitTEB( &initial_teb
, 0, TRUE
, NULL
)) return NULL
;
203 /***********************************************************************
207 * Native NT dlls are using the space left on the allocated page
208 * the first allocated TEB on NT is at 0x7ffde000, since we can't
209 * allocate in this area and don't support a granularity of 4kb
210 * yet we leave it to VirtualAlloc to choose an address.
212 TEB
*THREAD_Create( PDB
*pdb
, DWORD flags
, DWORD stack_size
, BOOL alloc_stack16
,
213 LPSECURITY_ATTRIBUTES sa
, int *server_handle
)
215 struct new_thread_request
*req
= get_req_buffer();
217 HANDLE cleanup_object
;
219 TEB
*teb
= VirtualAlloc(0, 0x1000, MEM_COMMIT
, PAGE_EXECUTE_READWRITE
);
220 if (!teb
) return NULL
;
221 teb
->except
= (void *)-1;
222 teb
->htask16
= pdb
->task
;
224 teb
->flags
= (pdb
->flags
& PDB32_WIN16_PROC
)? 0 : TEBF_WIN32
;
225 teb
->tls_ptr
= teb
->tls_array
;
227 teb
->exit_code
= 0x103; /* STILL_ACTIVE */
230 /* Allocate the TEB selector (%fs register) */
233 teb
->teb_sel
= SELECTOR_AllocBlock( teb
, 0x1000, SEGMENT_DATA
, TRUE
, FALSE
);
234 if (!teb
->teb_sel
) goto error
;
236 /* Create the socket pair for server communication */
238 if (socketpair( AF_UNIX
, SOCK_STREAM
, 0, fd
) == -1)
240 SetLastError( ERROR_TOO_MANY_OPEN_FILES
); /* FIXME */
244 fcntl( fd
[0], F_SETFD
, 1 ); /* set close on exec flag */
246 /* Create the thread on the server side */
248 req
->pid
= teb
->process
->server_pid
;
249 req
->suspend
= ((flags
& CREATE_SUSPENDED
) != 0);
250 req
->inherit
= (sa
&& (sa
->nLength
>=sizeof(*sa
)) && sa
->bInheritHandle
);
251 if (server_call_fd( REQ_NEW_THREAD
, fd
[1], NULL
)) goto error
;
253 *server_handle
= req
->handle
;
255 /* Do the rest of the initialization */
257 if (!THREAD_InitTEB( teb
, stack_size
, alloc_stack16
, sa
)) goto error
;
258 teb
->next
= THREAD_First
;
261 /* Install cleanup handler */
262 if ( !DuplicateHandle( GetCurrentProcess(), *server_handle
,
263 GetCurrentProcess(), &cleanup_object
,
264 0, FALSE
, DUPLICATE_SAME_ACCESS
) ) goto error
;
265 teb
->cleanup
= SERVICE_AddObject( cleanup_object
, THREAD_FreeTEB
, (ULONG_PTR
)teb
);
267 TRACE("(%p) succeeded\n", teb
);
271 if (*server_handle
!= -1) CloseHandle( *server_handle
);
272 if (teb
->teb_sel
) SELECTOR_FreeBlock( teb
->teb_sel
, 1 );
273 if (teb
->socket
!= -1) close( teb
->socket
);
274 VirtualFree( teb
, 0, MEM_FREE
);
279 /***********************************************************************
282 * Start execution of a newly created thread. Does not return.
284 static void THREAD_Start(void)
286 LPTHREAD_START_ROUTINE func
= (LPTHREAD_START_ROUTINE
)NtCurrentTeb()->entry_point
;
287 PROCESS_CallUserSignalProc( USIG_THREAD_INIT
, (DWORD
)NtCurrentTeb()->tid
, 0 );
289 MODULE_DllThreadAttach( NULL
);
291 if (NtCurrentTeb()->process
->flags
& PDB32_DEBUGGED
) DEBUG_SendCreateThreadEvent( func
);
293 ExitThread( func( NtCurrentTeb()->entry_arg
) );
297 /***********************************************************************
298 * CreateThread (KERNEL32.63)
300 HANDLE WINAPI
CreateThread( SECURITY_ATTRIBUTES
*sa
, DWORD stack
,
301 LPTHREAD_START_ROUTINE start
, LPVOID param
,
302 DWORD flags
, LPDWORD id
)
305 TEB
*teb
= THREAD_Create( PROCESS_Current(), flags
, stack
, TRUE
, sa
, &handle
);
307 teb
->flags
|= TEBF_WIN32
;
308 teb
->entry_point
= start
;
309 teb
->entry_arg
= param
;
310 teb
->startup
= THREAD_Start
;
311 if (SYSDEPS_SpawnThread( teb
) == -1)
313 CloseHandle( handle
);
316 if (id
) *id
= (DWORD
)teb
->tid
;
320 /***********************************************************************
321 * CreateThread16 (KERNEL.441)
323 static DWORD CALLBACK
THREAD_StartThread16( LPVOID threadArgs
)
325 FARPROC16 start
= ((FARPROC16
*)threadArgs
)[0];
326 DWORD param
= ((DWORD
*)threadArgs
)[1];
327 HeapFree( GetProcessHeap(), 0, threadArgs
);
329 ((LPDWORD
)CURRENT_STACK16
)[-1] = param
;
330 return CallTo16Long( start
, sizeof(DWORD
) );
332 HANDLE WINAPI
CreateThread16( SECURITY_ATTRIBUTES
*sa
, DWORD stack
,
333 FARPROC16 start
, SEGPTR param
,
334 DWORD flags
, LPDWORD id
)
336 DWORD
*threadArgs
= HeapAlloc( GetProcessHeap(), 0, 2*sizeof(DWORD
) );
337 if (!threadArgs
) return INVALID_HANDLE_VALUE
;
338 threadArgs
[0] = (DWORD
)start
;
339 threadArgs
[1] = (DWORD
)param
;
341 return CreateThread( sa
, stack
, THREAD_StartThread16
, threadArgs
, flags
, id
);
345 /***********************************************************************
346 * ExitThread [KERNEL32.215] Ends a thread
351 void WINAPI
ExitThread( DWORD code
) /* [in] Exit code for this thread */
353 MODULE_DllThreadDetach( NULL
);
354 TerminateThread( GetCurrentThread(), code
);
358 /***********************************************************************
359 * GetCurrentThread [KERNEL32.200] Gets pseudohandle for current thread
362 * Pseudohandle for the current thread
364 HANDLE WINAPI
GetCurrentThread(void)
366 return CURRENT_THREAD_PSEUDOHANDLE
;
370 /**********************************************************************
371 * GetLastError [KERNEL.148] [KERNEL32.227] Returns last-error code.
374 * Calling thread's last error code value.
376 DWORD WINAPI
GetLastError(void)
378 return NtCurrentTeb()->last_error
;
382 /**********************************************************************
383 * SetLastErrorEx [USER32.485] Sets the last-error code.
388 void WINAPI
SetLastErrorEx(
389 DWORD error
, /* [in] Per-thread error code */
390 DWORD type
) /* [in] Error type */
392 TRACE("(0x%08lx, 0x%08lx)\n", error
,type
);
399 /* Fall through for now */
401 FIXME("(error=%08lx, type=%08lx): Unhandled type\n", error
,type
);
404 SetLastError( error
);
408 /**********************************************************************
409 * TlsAlloc [KERNEL32.530] Allocates a TLS index.
411 * Allocates a thread local storage index
415 * Failure: 0xFFFFFFFF
417 DWORD WINAPI
TlsAlloc( void )
419 PDB
*process
= PROCESS_Current();
420 DWORD i
, mask
, ret
= 0;
421 DWORD
*bits
= process
->tls_bits
;
422 EnterCriticalSection( &process
->crit_section
);
423 if (*bits
== 0xffffffff)
427 if (*bits
== 0xffffffff)
429 LeaveCriticalSection( &process
->crit_section
);
430 SetLastError( ERROR_NO_MORE_ITEMS
);
434 for (i
= 0, mask
= 1; i
< 32; i
++, mask
<<= 1) if (!(*bits
& mask
)) break;
436 LeaveCriticalSection( &process
->crit_section
);
441 /**********************************************************************
442 * TlsFree [KERNEL32.531] Releases a TLS index.
444 * Releases a thread local storage index, making it available for reuse
451 DWORD index
) /* [in] TLS Index to free */
453 PDB
*process
= PROCESS_Current();
455 DWORD
*bits
= process
->tls_bits
;
458 SetLastError( ERROR_INVALID_PARAMETER
);
461 EnterCriticalSection( &process
->crit_section
);
462 if (index
>= 32) bits
++;
463 mask
= (1 << (index
& 31));
464 if (!(*bits
& mask
)) /* already free? */
466 LeaveCriticalSection( &process
->crit_section
);
467 SetLastError( ERROR_INVALID_PARAMETER
);
471 NtCurrentTeb()->tls_array
[index
] = 0;
472 /* FIXME: should zero all other thread values */
473 LeaveCriticalSection( &process
->crit_section
);
478 /**********************************************************************
479 * TlsGetValue [KERNEL32.532] Gets value in a thread's TLS slot
482 * Success: Value stored in calling thread's TLS slot for index
483 * Failure: 0 and GetLastError returns NO_ERROR
485 LPVOID WINAPI
TlsGetValue(
486 DWORD index
) /* [in] TLS index to retrieve value for */
490 SetLastError( ERROR_INVALID_PARAMETER
);
493 SetLastError( ERROR_SUCCESS
);
494 return NtCurrentTeb()->tls_array
[index
];
498 /**********************************************************************
499 * TlsSetValue [KERNEL32.533] Stores a value in the thread's TLS slot.
505 BOOL WINAPI
TlsSetValue(
506 DWORD index
, /* [in] TLS index to set value for */
507 LPVOID value
) /* [in] Value to be stored */
511 SetLastError( ERROR_INVALID_PARAMETER
);
514 NtCurrentTeb()->tls_array
[index
] = value
;
519 /***********************************************************************
520 * SetThreadContext [KERNEL32.670] Sets context of thread.
526 BOOL WINAPI
SetThreadContext(
527 HANDLE handle
, /* [in] Handle to thread with context */
528 const CONTEXT
*context
) /* [out] Address of context structure */
530 FIXME("not implemented\n" );
534 /***********************************************************************
535 * GetThreadContext [KERNEL32.294] Retrieves context of thread.
541 BOOL WINAPI
GetThreadContext(
542 HANDLE handle
, /* [in] Handle to thread with context */
543 CONTEXT
*context
) /* [out] Address of context structure */
548 FIXME("returning dummy info\n" );
550 /* make up some plausible values for segment registers */
564 /**********************************************************************
565 * GetThreadPriority [KERNEL32.296] Returns priority for thread.
568 * Success: Thread's priority level.
569 * Failure: THREAD_PRIORITY_ERROR_RETURN
571 INT WINAPI
GetThreadPriority(
572 HANDLE hthread
) /* [in] Handle to thread */
574 INT ret
= THREAD_PRIORITY_ERROR_RETURN
;
575 struct get_thread_info_request
*req
= get_req_buffer();
576 req
->handle
= hthread
;
577 if (!server_call( REQ_GET_THREAD_INFO
)) ret
= req
->priority
;
582 /**********************************************************************
583 * SetThreadPriority [KERNEL32.514] Sets priority for thread.
589 BOOL WINAPI
SetThreadPriority(
590 HANDLE hthread
, /* [in] Handle to thread */
591 INT priority
) /* [in] Thread priority level */
593 struct set_thread_info_request
*req
= get_req_buffer();
594 req
->handle
= hthread
;
595 req
->priority
= priority
;
596 req
->mask
= SET_THREAD_INFO_PRIORITY
;
597 return !server_call( REQ_SET_THREAD_INFO
);
601 /**********************************************************************
602 * SetThreadAffinityMask (KERNEL32.669)
604 DWORD WINAPI
SetThreadAffinityMask( HANDLE hThread
, DWORD dwThreadAffinityMask
)
606 struct set_thread_info_request
*req
= get_req_buffer();
607 req
->handle
= hThread
;
608 req
->affinity
= dwThreadAffinityMask
;
609 req
->mask
= SET_THREAD_INFO_AFFINITY
;
610 if (server_call( REQ_SET_THREAD_INFO
)) return 0;
611 return 1; /* FIXME: should return previous value */
615 /**********************************************************************
616 * TerminateThread [KERNEL32.685] Terminates a thread
622 BOOL WINAPI
TerminateThread(
623 HANDLE handle
, /* [in] Handle to thread */
624 DWORD exitcode
) /* [in] Exit code for thread */
626 struct terminate_thread_request
*req
= get_req_buffer();
627 req
->handle
= handle
;
628 req
->exit_code
= exitcode
;
629 return !server_call( REQ_TERMINATE_THREAD
);
633 /**********************************************************************
634 * GetExitCodeThread [KERNEL32.???] Gets termination status of thread.
640 BOOL WINAPI
GetExitCodeThread(
641 HANDLE hthread
, /* [in] Handle to thread */
642 LPDWORD exitcode
) /* [out] Address to receive termination status */
645 struct get_thread_info_request
*req
= get_req_buffer();
646 req
->handle
= hthread
;
647 if (!server_call( REQ_GET_THREAD_INFO
))
649 if (exitcode
) *exitcode
= req
->exit_code
;
656 /**********************************************************************
657 * ResumeThread [KERNEL32.587] Resumes a thread.
659 * Decrements a thread's suspend count. When count is zero, the
660 * execution of the thread is resumed.
663 * Success: Previous suspend count
664 * Failure: 0xFFFFFFFF
667 DWORD WINAPI
ResumeThread(
668 HANDLE hthread
) /* [in] Identifies thread to restart */
670 DWORD ret
= 0xffffffff;
671 struct resume_thread_request
*req
= get_req_buffer();
672 req
->handle
= hthread
;
673 if (!server_call( REQ_RESUME_THREAD
)) ret
= req
->count
;
678 /**********************************************************************
679 * SuspendThread [KERNEL32.681] Suspends a thread.
682 * Success: Previous suspend count
683 * Failure: 0xFFFFFFFF
685 DWORD WINAPI
SuspendThread(
686 HANDLE hthread
) /* [in] Handle to the thread */
688 DWORD ret
= 0xffffffff;
689 struct suspend_thread_request
*req
= get_req_buffer();
690 req
->handle
= hthread
;
691 if (!server_call( REQ_SUSPEND_THREAD
)) ret
= req
->count
;
696 /***********************************************************************
697 * QueueUserAPC (KERNEL32.566)
699 DWORD WINAPI
QueueUserAPC( PAPCFUNC func
, HANDLE hthread
, ULONG_PTR data
)
701 struct queue_apc_request
*req
= get_req_buffer();
702 req
->handle
= hthread
;
704 req
->param
= (void *)data
;
705 return !server_call( REQ_QUEUE_APC
);
709 /**********************************************************************
710 * GetThreadTimes [KERNEL32.???] Obtains timing information.
713 * What are the fields where these values are stored?
719 BOOL WINAPI
GetThreadTimes(
720 HANDLE thread
, /* [in] Specifies the thread of interest */
721 LPFILETIME creationtime
, /* [out] When the thread was created */
722 LPFILETIME exittime
, /* [out] When the thread was destroyed */
723 LPFILETIME kerneltime
, /* [out] Time thread spent in kernel mode */
724 LPFILETIME usertime
) /* [out] Time thread spent in user mode */
726 FIXME("(0x%08x): stub\n",thread
);
727 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
732 /**********************************************************************
733 * AttachThreadInput [KERNEL32.8] Attaches input of 1 thread to other
735 * Attaches the input processing mechanism of one thread to that of
743 * 1. Reset the Key State (currenly per thread key state is not maintained)
745 BOOL WINAPI
AttachThreadInput(
746 DWORD idAttach
, /* [in] Thread to attach */
747 DWORD idAttachTo
, /* [in] Thread to attach to */
748 BOOL fAttach
) /* [in] Attach or detach */
750 MESSAGEQUEUE
*pSrcMsgQ
= 0, *pTgtMsgQ
= 0;
753 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
755 /* A thread cannot attach to itself */
756 if ( idAttach
== idAttachTo
)
759 /* According to the docs this method should fail if a
760 * "Journal record" hook is installed. (attaches all input queues together)
762 if ( HOOK_IsHooked( WH_JOURNALRECORD
) )
765 /* Retrieve message queues corresponding to the thread id's */
766 pTgtMsgQ
= (MESSAGEQUEUE
*)QUEUE_Lock( GetThreadQueue16( idAttach
) );
767 pSrcMsgQ
= (MESSAGEQUEUE
*)QUEUE_Lock( GetThreadQueue16( idAttachTo
) );
769 /* Ensure we have message queues and that Src and Tgt threads
770 * are not system threads.
772 if ( !pSrcMsgQ
|| !pTgtMsgQ
|| !pSrcMsgQ
->pQData
|| !pTgtMsgQ
->pQData
)
775 if (fAttach
) /* Attach threads */
777 /* Only attach if currently detached */
778 if ( pTgtMsgQ
->pQData
!= pSrcMsgQ
->pQData
)
780 /* First release the target threads perQData */
781 PERQDATA_Release( pTgtMsgQ
->pQData
);
783 /* Share a reference to the source threads perQDATA */
784 PERQDATA_Addref( pSrcMsgQ
->pQData
);
785 pTgtMsgQ
->pQData
= pSrcMsgQ
->pQData
;
788 else /* Detach threads */
790 /* Only detach if currently attached */
791 if ( pTgtMsgQ
->pQData
== pSrcMsgQ
->pQData
)
793 /* First release the target threads perQData */
794 PERQDATA_Release( pTgtMsgQ
->pQData
);
796 /* Give the target thread its own private perQDATA once more */
797 pTgtMsgQ
->pQData
= PERQDATA_CreateInstance();
801 /* TODO: Reset the Key State */
803 bRet
= 1; /* Success */
807 /* Unlock the queues before returning */
809 QUEUE_Unlock( pSrcMsgQ
);
811 QUEUE_Unlock( pTgtMsgQ
);
816 /**********************************************************************
817 * VWin32_BoostThreadGroup [KERNEL.535]
819 VOID WINAPI
VWin32_BoostThreadGroup( DWORD threadId
, INT boost
)
821 FIXME("(0x%08lx,%d): stub\n", threadId
, boost
);
824 /**********************************************************************
825 * VWin32_BoostThreadStatic [KERNEL.536]
827 VOID WINAPI
VWin32_BoostThreadStatic( DWORD threadId
, INT boost
)
829 FIXME("(0x%08lx,%d): stub\n", threadId
, boost
);
832 /**********************************************************************
833 * SetThreadLocale [KERNEL32.671] Sets the calling threads current locale.
840 * Implemented in NT only (3.1 and above according to MS
842 BOOL WINAPI
SetThreadLocale(
843 LCID lcid
) /* [in] Locale identifier */
845 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
850 /**********************************************************************
851 * SetLastError [KERNEL.147] [KERNEL32.497] Sets the last-error code.
857 void WINAPI
SetLastError( DWORD error
) /* [in] Per-thread error code */
859 NtCurrentTeb()->last_error
= error
;
863 /***********************************************************************
864 * GetCurrentThreadId [KERNEL32.201] Returns thread identifier.
867 * Thread identifier of calling thread
869 #undef GetCurrentThreadId
870 DWORD WINAPI
GetCurrentThreadId(void)
872 return (DWORD
)NtCurrentTeb()->tid
;