4 * Copyright 1996, 2003 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/port.h"
27 #include <sys/types.h>
28 #ifdef HAVE_SYS_MMAN_H
31 #ifdef HAVE_SYS_TIMES_H
32 #include <sys/times.h>
34 #ifdef HAVE_SYS_SYSCALL_H
35 #include <sys/syscall.h>
38 #define NONAMELESSUNION
40 #define WIN32_NO_STATUS
42 #include "wine/library.h"
43 #include "wine/server.h"
44 #include "wine/debug.h"
45 #include "ntdll_misc.h"
47 #include "wine/exception.h"
49 WINE_DEFAULT_DEBUG_CHANNEL(thread
);
51 #ifndef PTHREAD_STACK_MIN
52 #define PTHREAD_STACK_MIN 16384
55 struct _KUSER_SHARED_DATA
*user_shared_data
= NULL
;
56 static const WCHAR default_windirW
[] = {'C',':','\\','w','i','n','d','o','w','s',0};
58 void (WINAPI
*kernel32_start_process
)(LPTHREAD_START_ROUTINE
,void*) = NULL
;
60 /* info passed to a starting thread */
64 PRTL_THREAD_START_ROUTINE entry_point
;
69 static PEB_LDR_DATA ldr
;
70 static RTL_USER_PROCESS_PARAMETERS params
; /* default parameters if no parent */
71 static WCHAR current_dir
[MAX_PATH
];
72 static RTL_BITMAP tls_bitmap
;
73 static RTL_BITMAP tls_expansion_bitmap
;
74 static RTL_BITMAP fls_bitmap
;
75 static int nb_threads
= 1;
77 static RTL_CRITICAL_SECTION peb_lock
;
78 static RTL_CRITICAL_SECTION_DEBUG critsect_debug
=
81 { &critsect_debug
.ProcessLocksList
, &critsect_debug
.ProcessLocksList
},
82 0, 0, { (DWORD_PTR
)(__FILE__
": peb_lock") }
84 static RTL_CRITICAL_SECTION peb_lock
= { &critsect_debug
, -1, 0, 0, 0, 0 };
86 /***********************************************************************
89 * Copy a unicode string from the startup info.
91 static inline void get_unicode_string( UNICODE_STRING
*str
, WCHAR
**src
, WCHAR
**dst
, UINT len
)
95 str
->MaximumLength
= len
+ sizeof(WCHAR
);
96 memcpy( str
->Buffer
, *src
, len
);
97 str
->Buffer
[len
/ sizeof(WCHAR
)] = 0;
98 *src
+= len
/ sizeof(WCHAR
);
99 *dst
+= len
/ sizeof(WCHAR
) + 1;
102 /***********************************************************************
103 * init_user_process_params
105 * Fill the RTL_USER_PROCESS_PARAMETERS structure from the server.
107 static NTSTATUS
init_user_process_params( SIZE_T data_size
)
111 SIZE_T info_size
, env_size
, size
, alloc_size
;
113 startup_info_t
*info
;
114 RTL_USER_PROCESS_PARAMETERS
*params
= NULL
;
116 if (!(info
= RtlAllocateHeap( GetProcessHeap(), 0, data_size
)))
117 return STATUS_NO_MEMORY
;
119 SERVER_START_REQ( get_startup_info
)
121 wine_server_set_reply( req
, info
, data_size
);
122 if (!(status
= wine_server_call( req
)))
124 data_size
= wine_server_reply_size( reply
);
125 info_size
= reply
->info_size
;
126 env_size
= data_size
- info_size
;
130 if (status
!= STATUS_SUCCESS
) goto done
;
132 size
= sizeof(*params
);
133 size
+= sizeof(current_dir
);
134 size
+= info
->dllpath_len
+ sizeof(WCHAR
);
135 size
+= info
->imagepath_len
+ sizeof(WCHAR
);
136 size
+= info
->cmdline_len
+ sizeof(WCHAR
);
137 size
+= info
->title_len
+ sizeof(WCHAR
);
138 size
+= info
->desktop_len
+ sizeof(WCHAR
);
139 size
+= info
->shellinfo_len
+ sizeof(WCHAR
);
140 size
+= info
->runtime_len
+ sizeof(WCHAR
);
143 status
= NtAllocateVirtualMemory( NtCurrentProcess(), (void **)¶ms
, 0, &alloc_size
,
144 MEM_COMMIT
, PAGE_READWRITE
);
145 if (status
!= STATUS_SUCCESS
) goto done
;
147 NtCurrentTeb()->Peb
->ProcessParameters
= params
;
148 params
->AllocationSize
= alloc_size
;
150 params
->Flags
= PROCESS_PARAMS_FLAG_NORMALIZED
;
151 params
->DebugFlags
= info
->debug_flags
;
152 params
->ConsoleHandle
= wine_server_ptr_handle( info
->console
);
153 params
->ConsoleFlags
= info
->console_flags
;
154 params
->hStdInput
= wine_server_ptr_handle( info
->hstdin
);
155 params
->hStdOutput
= wine_server_ptr_handle( info
->hstdout
);
156 params
->hStdError
= wine_server_ptr_handle( info
->hstderr
);
157 params
->dwX
= info
->x
;
158 params
->dwY
= info
->y
;
159 params
->dwXSize
= info
->xsize
;
160 params
->dwYSize
= info
->ysize
;
161 params
->dwXCountChars
= info
->xchars
;
162 params
->dwYCountChars
= info
->ychars
;
163 params
->dwFillAttribute
= info
->attribute
;
164 params
->dwFlags
= info
->flags
;
165 params
->wShowWindow
= info
->show
;
167 src
= (WCHAR
*)(info
+ 1);
168 dst
= (WCHAR
*)(params
+ 1);
170 /* current directory needs more space */
171 get_unicode_string( ¶ms
->CurrentDirectory
.DosPath
, &src
, &dst
, info
->curdir_len
);
172 params
->CurrentDirectory
.DosPath
.MaximumLength
= sizeof(current_dir
);
173 dst
= (WCHAR
*)(params
+ 1) + ARRAY_SIZE(current_dir
);
175 get_unicode_string( ¶ms
->DllPath
, &src
, &dst
, info
->dllpath_len
);
176 get_unicode_string( ¶ms
->ImagePathName
, &src
, &dst
, info
->imagepath_len
);
177 get_unicode_string( ¶ms
->CommandLine
, &src
, &dst
, info
->cmdline_len
);
178 get_unicode_string( ¶ms
->WindowTitle
, &src
, &dst
, info
->title_len
);
179 get_unicode_string( ¶ms
->Desktop
, &src
, &dst
, info
->desktop_len
);
180 get_unicode_string( ¶ms
->ShellInfo
, &src
, &dst
, info
->shellinfo_len
);
182 /* runtime info isn't a real string */
183 params
->RuntimeInfo
.Buffer
= dst
;
184 params
->RuntimeInfo
.Length
= params
->RuntimeInfo
.MaximumLength
= info
->runtime_len
;
185 memcpy( dst
, src
, info
->runtime_len
);
187 /* environment needs to be a separate memory block */
189 alloc_size
= max( 1, env_size
);
190 status
= NtAllocateVirtualMemory( NtCurrentProcess(), &ptr
, 0, &alloc_size
,
191 MEM_COMMIT
, PAGE_READWRITE
);
192 if (status
!= STATUS_SUCCESS
) goto done
;
193 memcpy( ptr
, (char *)info
+ info_size
, env_size
);
194 params
->Environment
= ptr
;
197 RtlFreeHeap( GetProcessHeap(), 0, info
);
209 #ifdef HAVE_SYS_AUXV_H
210 # include <sys/auxv.h>
212 #ifndef HAVE_GETAUXVAL
213 static unsigned long getauxval( unsigned long id
)
215 extern char **__wine_main_environ
;
216 char **ptr
= __wine_main_environ
;
221 for (auxv
= (ElfW(auxv_t
) *)ptr
; auxv
->a_type
; auxv
++)
222 if (auxv
->a_type
== id
) return auxv
->a_un
.a_val
;
227 static ULONG_PTR
get_image_addr(void)
229 ULONG_PTR size
, num
, phdr_addr
= getauxval( AT_PHDR
);
232 if (!phdr_addr
) return 0;
233 phdr
= (ElfW(Phdr
) *)phdr_addr
;
234 size
= getauxval( AT_PHENT
);
235 num
= getauxval( AT_PHNUM
);
238 if (phdr
->p_type
== PT_PHDR
) return phdr_addr
- phdr
->p_offset
;
239 phdr
= (ElfW(Phdr
) *)((char *)phdr
+ size
);
244 #elif defined(__APPLE__)
245 #include <mach/mach.h>
246 #include <mach/mach_error.h>
248 static ULONG_PTR
get_image_addr(void)
251 #ifdef TASK_DYLD_INFO
252 struct task_dyld_info dyld_info
;
253 mach_msg_type_number_t size
= TASK_DYLD_INFO_COUNT
;
254 if (task_info(mach_task_self(), TASK_DYLD_INFO
, (task_info_t
)&dyld_info
, &size
) == KERN_SUCCESS
)
255 ret
= dyld_info
.all_image_info_addr
;
261 static ULONG_PTR
get_image_addr(void)
267 /***********************************************************************
270 * Setup the initial thread.
272 * NOTES: The first allocated TEB on NT is at 0x7ffde000.
274 void thread_init(void)
279 SIZE_T size
, info_size
;
282 struct ntdll_thread_data
*thread_data
;
283 static struct debug_info debug_info
; /* debug info for initial thread */
287 /* reserve space for shared user data */
289 addr
= (void *)0x7ffe0000;
291 status
= NtAllocateVirtualMemory( NtCurrentProcess(), &addr
, 0, &size
,
292 MEM_RESERVE
|MEM_COMMIT
, PAGE_READWRITE
);
295 MESSAGE( "wine: failed to map the shared user data: %08x\n", status
);
298 user_shared_data
= addr
;
299 memcpy( user_shared_data
->NtSystemRoot
, default_windirW
, sizeof(default_windirW
) );
301 /* allocate and initialize the PEB */
305 NtAllocateVirtualMemory( NtCurrentProcess(), &addr
, 1, &size
,
306 MEM_COMMIT
| MEM_TOP_DOWN
, PAGE_READWRITE
);
309 peb
->FastPebLock
= &peb_lock
;
310 peb
->ProcessParameters
= ¶ms
;
311 peb
->TlsBitmap
= &tls_bitmap
;
312 peb
->TlsExpansionBitmap
= &tls_expansion_bitmap
;
313 peb
->FlsBitmap
= &fls_bitmap
;
315 peb
->OSMajorVersion
= 5;
316 peb
->OSMinorVersion
= 1;
317 peb
->OSBuildNumber
= 0xA28;
318 peb
->OSPlatformId
= VER_PLATFORM_WIN32_NT
;
319 params
.CurrentDirectory
.DosPath
.Buffer
= current_dir
;
320 params
.CurrentDirectory
.DosPath
.MaximumLength
= sizeof(current_dir
);
321 params
.wShowWindow
= 1; /* SW_SHOWNORMAL */
322 ldr
.Length
= sizeof(ldr
);
323 ldr
.Initialized
= TRUE
;
324 RtlInitializeBitMap( &tls_bitmap
, peb
->TlsBitmapBits
, sizeof(peb
->TlsBitmapBits
) * 8 );
325 RtlInitializeBitMap( &tls_expansion_bitmap
, peb
->TlsExpansionBitmapBits
,
326 sizeof(peb
->TlsExpansionBitmapBits
) * 8 );
327 RtlInitializeBitMap( &fls_bitmap
, peb
->FlsBitmapBits
, sizeof(peb
->FlsBitmapBits
) * 8 );
328 RtlSetBits( peb
->TlsBitmap
, 0, 1 ); /* TLS index 0 is reserved and should be initialized to NULL. */
329 RtlSetBits( peb
->FlsBitmap
, 0, 1 );
330 InitializeListHead( &peb
->FlsListHead
);
331 InitializeListHead( &ldr
.InLoadOrderModuleList
);
332 InitializeListHead( &ldr
.InMemoryOrderModuleList
);
333 InitializeListHead( &ldr
.InInitializationOrderModuleList
);
334 *(ULONG_PTR
*)peb
->Reserved
= get_image_addr();
337 * Starting with Vista, the first user to log on has session id 1.
338 * Session id 0 is for processes that don't interact with the user (like services).
342 /* allocate and initialize the initial TEB */
344 signal_alloc_thread( &teb
);
346 teb
->Tib
.StackBase
= (void *)~0UL;
347 teb
->StaticUnicodeString
.Buffer
= teb
->StaticUnicodeBuffer
;
348 teb
->StaticUnicodeString
.MaximumLength
= sizeof(teb
->StaticUnicodeBuffer
);
350 thread_data
= (struct ntdll_thread_data
*)&teb
->GdiTebBatch
;
351 thread_data
->request_fd
= -1;
352 thread_data
->reply_fd
= -1;
353 thread_data
->wait_fd
[0] = -1;
354 thread_data
->wait_fd
[1] = -1;
355 thread_data
->debug_info
= &debug_info
;
357 signal_init_thread( teb
);
358 virtual_init_threading();
360 debug_info
.str_pos
= debug_info
.strings
;
361 debug_info
.out_pos
= debug_info
.output
;
364 /* setup the server connection */
365 server_init_process();
366 info_size
= server_init_thread( peb
, &suspend
);
368 /* create the process heap */
369 if (!(peb
->ProcessHeap
= RtlCreateHeap( HEAP_GROWABLE
, NULL
, 0, 0, NULL
, NULL
)))
371 MESSAGE( "wine: failed to create the process heap\n" );
375 /* allocate user parameters */
378 init_user_process_params( info_size
);
382 if (isatty(0) || isatty(1) || isatty(2))
383 params
.ConsoleHandle
= (HANDLE
)2; /* see kernel32/kernel_private.h */
385 wine_server_fd_to_handle( 0, GENERIC_READ
|SYNCHRONIZE
, OBJ_INHERIT
, ¶ms
.hStdInput
);
387 wine_server_fd_to_handle( 1, GENERIC_WRITE
|SYNCHRONIZE
, OBJ_INHERIT
, ¶ms
.hStdOutput
);
389 wine_server_fd_to_handle( 2, GENERIC_WRITE
|SYNCHRONIZE
, OBJ_INHERIT
, ¶ms
.hStdError
);
392 /* initialize time values in user_shared_data */
393 NtQuerySystemTime( &now
);
394 user_shared_data
->SystemTime
.LowPart
= now
.u
.LowPart
;
395 user_shared_data
->SystemTime
.High1Time
= user_shared_data
->SystemTime
.High2Time
= now
.u
.HighPart
;
396 user_shared_data
->u
.TickCountQuad
= (now
.QuadPart
- server_start_time
) / 10000;
397 user_shared_data
->u
.TickCount
.High2Time
= user_shared_data
->u
.TickCount
.High1Time
;
398 user_shared_data
->TickCountLowDeprecated
= user_shared_data
->u
.TickCount
.LowPart
;
399 user_shared_data
->TickCountMultiplier
= 1 << 24;
403 NtCreateKeyedEvent( &keyed_event
, GENERIC_READ
| GENERIC_WRITE
, NULL
, 0 );
407 /***********************************************************************
410 static void free_thread_data( TEB
*teb
)
412 struct ntdll_thread_data
*thread_data
= (struct ntdll_thread_data
*)&teb
->GdiTebBatch
;
415 if (teb
->DeallocationStack
)
418 NtFreeVirtualMemory( GetCurrentProcess(), &teb
->DeallocationStack
, &size
, MEM_RELEASE
);
420 if (thread_data
->start_stack
)
423 NtFreeVirtualMemory( GetCurrentProcess(), &thread_data
->start_stack
, &size
, MEM_RELEASE
);
425 signal_free_thread( teb
);
429 /***********************************************************************
432 void abort_thread( int status
)
434 pthread_sigmask( SIG_BLOCK
, &server_block_set
, NULL
);
435 if (interlocked_xchg_add( &nb_threads
, -1 ) <= 1) _exit( status
);
436 signal_exit_thread( status
);
440 /***********************************************************************
443 void exit_thread( int status
)
445 close( ntdll_get_thread_data()->wait_fd
[0] );
446 close( ntdll_get_thread_data()->wait_fd
[1] );
447 close( ntdll_get_thread_data()->reply_fd
);
448 close( ntdll_get_thread_data()->request_fd
);
449 pthread_exit( UIntToPtr(status
) );
453 /***********************************************************************
454 * RtlExitUserThread (NTDLL.@)
456 void WINAPI
RtlExitUserThread( ULONG status
)
458 static void *prev_teb
;
461 if (status
) /* send the exit code to the server (0 is already the default) */
463 SERVER_START_REQ( terminate_thread
)
465 req
->handle
= wine_server_obj_handle( GetCurrentThread() );
466 req
->exit_code
= status
;
467 wine_server_call( req
);
472 if (interlocked_xchg_add( &nb_threads
, -1 ) <= 1)
474 LdrShutdownProcess();
475 pthread_sigmask( SIG_BLOCK
, &server_block_set
, NULL
);
476 signal_exit_process( status
);
480 RtlFreeThreadActivationContextStack();
482 pthread_sigmask( SIG_BLOCK
, &server_block_set
, NULL
);
484 if ((teb
= interlocked_xchg_ptr( &prev_teb
, NtCurrentTeb() )))
486 struct ntdll_thread_data
*thread_data
= (struct ntdll_thread_data
*)&teb
->GdiTebBatch
;
488 if (thread_data
->pthread_id
)
490 pthread_join( thread_data
->pthread_id
, NULL
);
491 free_thread_data( teb
);
495 signal_exit_thread( status
);
499 /***********************************************************************
502 * Startup routine for a newly created thread.
504 static void start_thread( struct startup_info
*info
)
507 TEB
*teb
= info
->teb
;
508 struct ntdll_thread_data
*thread_data
= (struct ntdll_thread_data
*)&teb
->GdiTebBatch
;
509 struct debug_info debug_info
;
511 debug_info
.str_pos
= debug_info
.strings
;
512 debug_info
.out_pos
= debug_info
.output
;
513 thread_data
->debug_info
= &debug_info
;
514 thread_data
->pthread_id
= pthread_self();
516 signal_init_thread( teb
);
517 server_init_thread( info
->entry_point
, &suspend
);
518 signal_start_thread( (LPTHREAD_START_ROUTINE
)info
->entry_point
, info
->entry_arg
, suspend
);
522 /***********************************************************************
523 * NtCreateThreadEx (NTDLL.@)
525 NTSTATUS WINAPI
NtCreateThreadEx( HANDLE
*handle_ptr
, ACCESS_MASK access
, OBJECT_ATTRIBUTES
*attr
,
526 HANDLE process
, LPTHREAD_START_ROUTINE start
, void *param
,
527 ULONG flags
, ULONG zero_bits
, ULONG stack_commit
,
528 ULONG stack_reserve
, void *attribute_list
)
530 FIXME( "%p, %x, %p, %p, %p, %p, %x, %x, %x, %x, %p semi-stub!\n", handle_ptr
, access
, attr
,
531 process
, start
, param
, flags
, zero_bits
, stack_commit
, stack_reserve
, attribute_list
);
533 return RtlCreateUserThread( process
, NULL
, flags
& THREAD_CREATE_FLAGS_CREATE_SUSPENDED
,
534 NULL
, stack_reserve
, stack_commit
, (PRTL_THREAD_START_ROUTINE
)start
,
535 param
, handle_ptr
, NULL
);
539 /***********************************************************************
540 * RtlCreateUserThread (NTDLL.@)
542 NTSTATUS WINAPI
RtlCreateUserThread( HANDLE process
, SECURITY_DESCRIPTOR
*descr
,
543 BOOLEAN suspended
, PVOID stack_addr
,
544 SIZE_T stack_reserve
, SIZE_T stack_commit
,
545 PRTL_THREAD_START_ROUTINE start
, void *param
,
546 HANDLE
*handle_ptr
, CLIENT_ID
*id
)
549 pthread_t pthread_id
;
551 struct ntdll_thread_data
*thread_data
;
552 struct startup_info
*info
;
553 HANDLE handle
= 0, actctx
= 0;
558 SIZE_T extra_stack
= PTHREAD_STACK_MIN
;
560 struct object_attributes
*objattr
= NULL
;
562 if (process
!= NtCurrentProcess())
567 memset( &call
, 0, sizeof(call
) );
569 call
.create_thread
.type
= APC_CREATE_THREAD
;
570 call
.create_thread
.func
= wine_server_client_ptr( start
);
571 call
.create_thread
.arg
= wine_server_client_ptr( param
);
572 call
.create_thread
.reserve
= stack_reserve
;
573 call
.create_thread
.commit
= stack_commit
;
574 call
.create_thread
.suspend
= suspended
;
575 status
= server_queue_process_apc( process
, &call
, &result
);
576 if (status
!= STATUS_SUCCESS
) return status
;
578 if (result
.create_thread
.status
== STATUS_SUCCESS
)
580 if (id
) id
->UniqueThread
= ULongToHandle(result
.create_thread
.tid
);
581 if (handle_ptr
) *handle_ptr
= wine_server_ptr_handle( result
.create_thread
.handle
);
582 else NtClose( wine_server_ptr_handle( result
.create_thread
.handle
));
584 return result
.create_thread
.status
;
589 OBJECT_ATTRIBUTES thread_attr
;
590 InitializeObjectAttributes( &thread_attr
, NULL
, 0, NULL
, descr
);
591 if ((status
= alloc_object_attributes( &thread_attr
, &objattr
, &len
))) return status
;
594 if (server_pipe( request_pipe
) == -1)
596 RtlFreeHeap( GetProcessHeap(), 0, objattr
);
597 return STATUS_TOO_MANY_OPENED_FILES
;
599 wine_server_send_fd( request_pipe
[0] );
601 SERVER_START_REQ( new_thread
)
603 req
->process
= wine_server_obj_handle( process
);
604 req
->access
= THREAD_ALL_ACCESS
;
605 req
->suspend
= suspended
;
606 req
->request_fd
= request_pipe
[0];
607 wine_server_add_data( req
, objattr
, len
);
608 if (!(status
= wine_server_call( req
)))
610 handle
= wine_server_ptr_handle( reply
->handle
);
613 close( request_pipe
[0] );
617 RtlFreeHeap( GetProcessHeap(), 0, objattr
);
620 close( request_pipe
[1] );
624 pthread_sigmask( SIG_BLOCK
, &server_block_set
, &sigset
);
626 if ((status
= signal_alloc_thread( &teb
))) goto error
;
628 teb
->Peb
= NtCurrentTeb()->Peb
;
629 teb
->ClientId
.UniqueProcess
= ULongToHandle(GetCurrentProcessId());
630 teb
->ClientId
.UniqueThread
= ULongToHandle(tid
);
631 teb
->StaticUnicodeString
.Buffer
= teb
->StaticUnicodeBuffer
;
632 teb
->StaticUnicodeString
.MaximumLength
= sizeof(teb
->StaticUnicodeBuffer
);
634 /* create default activation context frame for new thread */
635 RtlGetActiveActivationContext(&actctx
);
638 RTL_ACTIVATION_CONTEXT_STACK_FRAME
*frame
;
640 frame
= RtlAllocateHeap(GetProcessHeap(), 0, sizeof(*frame
));
641 frame
->Previous
= NULL
;
642 frame
->ActivationContext
= actctx
;
644 teb
->ActivationContextStack
.ActiveFrame
= frame
;
647 info
= (struct startup_info
*)(teb
+ 1);
649 info
->entry_point
= start
;
650 info
->entry_arg
= param
;
652 if ((status
= virtual_alloc_thread_stack( teb
, stack_reserve
, stack_commit
, &extra_stack
)))
655 thread_data
= (struct ntdll_thread_data
*)&teb
->GdiTebBatch
;
656 thread_data
->request_fd
= request_pipe
[1];
657 thread_data
->reply_fd
= -1;
658 thread_data
->wait_fd
[0] = -1;
659 thread_data
->wait_fd
[1] = -1;
660 thread_data
->start_stack
= (char *)teb
->Tib
.StackBase
;
662 pthread_attr_init( &attr
);
663 pthread_attr_setstack( &attr
, teb
->DeallocationStack
,
664 (char *)teb
->Tib
.StackBase
+ extra_stack
- (char *)teb
->DeallocationStack
);
665 pthread_attr_setscope( &attr
, PTHREAD_SCOPE_SYSTEM
); /* force creating a kernel thread */
666 interlocked_xchg_add( &nb_threads
, 1 );
667 if (pthread_create( &pthread_id
, &attr
, (void * (*)(void *))start_thread
, info
))
669 interlocked_xchg_add( &nb_threads
, -1 );
670 pthread_attr_destroy( &attr
);
671 status
= STATUS_NO_MEMORY
;
674 pthread_attr_destroy( &attr
);
675 pthread_sigmask( SIG_SETMASK
, &sigset
, NULL
);
677 if (id
) id
->UniqueThread
= ULongToHandle(tid
);
678 if (handle_ptr
) *handle_ptr
= handle
;
679 else NtClose( handle
);
681 return STATUS_SUCCESS
;
684 if (teb
) free_thread_data( teb
);
685 if (handle
) NtClose( handle
);
686 pthread_sigmask( SIG_SETMASK
, &sigset
, NULL
);
687 close( request_pipe
[1] );
692 /******************************************************************************
693 * RtlGetNtGlobalFlags (NTDLL.@)
695 ULONG WINAPI
RtlGetNtGlobalFlags(void)
697 if (!peb
) return 0; /* init not done yet */
698 return peb
->NtGlobalFlag
;
702 /***********************************************************************
703 * NtOpenThread (NTDLL.@)
704 * ZwOpenThread (NTDLL.@)
706 NTSTATUS WINAPI
NtOpenThread( HANDLE
*handle
, ACCESS_MASK access
,
707 const OBJECT_ATTRIBUTES
*attr
, const CLIENT_ID
*id
)
711 SERVER_START_REQ( open_thread
)
713 req
->tid
= HandleToULong(id
->UniqueThread
);
714 req
->access
= access
;
715 req
->attributes
= attr
? attr
->Attributes
: 0;
716 ret
= wine_server_call( req
);
717 *handle
= wine_server_ptr_handle( reply
->handle
);
724 /******************************************************************************
725 * NtSuspendThread (NTDLL.@)
726 * ZwSuspendThread (NTDLL.@)
728 NTSTATUS WINAPI
NtSuspendThread( HANDLE handle
, PULONG count
)
732 SERVER_START_REQ( suspend_thread
)
734 req
->handle
= wine_server_obj_handle( handle
);
735 if (!(ret
= wine_server_call( req
)))
737 if (count
) *count
= reply
->count
;
745 /******************************************************************************
746 * NtResumeThread (NTDLL.@)
747 * ZwResumeThread (NTDLL.@)
749 NTSTATUS WINAPI
NtResumeThread( HANDLE handle
, PULONG count
)
753 SERVER_START_REQ( resume_thread
)
755 req
->handle
= wine_server_obj_handle( handle
);
756 if (!(ret
= wine_server_call( req
)))
758 if (count
) *count
= reply
->count
;
766 /******************************************************************************
767 * NtAlertResumeThread (NTDLL.@)
768 * ZwAlertResumeThread (NTDLL.@)
770 NTSTATUS WINAPI
NtAlertResumeThread( HANDLE handle
, PULONG count
)
772 FIXME( "stub: should alert thread %p\n", handle
);
773 return NtResumeThread( handle
, count
);
777 /******************************************************************************
778 * NtAlertThread (NTDLL.@)
779 * ZwAlertThread (NTDLL.@)
781 NTSTATUS WINAPI
NtAlertThread( HANDLE handle
)
783 FIXME( "stub: %p\n", handle
);
784 return STATUS_NOT_IMPLEMENTED
;
788 /******************************************************************************
789 * NtTerminateThread (NTDLL.@)
790 * ZwTerminateThread (NTDLL.@)
792 NTSTATUS WINAPI
NtTerminateThread( HANDLE handle
, LONG exit_code
)
797 SERVER_START_REQ( terminate_thread
)
799 req
->handle
= wine_server_obj_handle( handle
);
800 req
->exit_code
= exit_code
;
801 ret
= wine_server_call( req
);
802 self
= !ret
&& reply
->self
;
806 if (self
) abort_thread( exit_code
);
811 /******************************************************************************
812 * NtQueueApcThread (NTDLL.@)
814 NTSTATUS WINAPI
NtQueueApcThread( HANDLE handle
, PNTAPCFUNC func
, ULONG_PTR arg1
,
815 ULONG_PTR arg2
, ULONG_PTR arg3
)
818 SERVER_START_REQ( queue_apc
)
820 req
->handle
= wine_server_obj_handle( handle
);
823 req
->call
.type
= APC_USER
;
824 req
->call
.user
.func
= wine_server_client_ptr( func
);
825 req
->call
.user
.args
[0] = arg1
;
826 req
->call
.user
.args
[1] = arg2
;
827 req
->call
.user
.args
[2] = arg3
;
829 else req
->call
.type
= APC_NONE
; /* wake up only */
830 ret
= wine_server_call( req
);
837 /******************************************************************************
838 * RtlPushFrame (NTDLL.@)
840 void WINAPI
RtlPushFrame( TEB_ACTIVE_FRAME
*frame
)
842 frame
->Previous
= NtCurrentTeb()->ActiveFrame
;
843 NtCurrentTeb()->ActiveFrame
= frame
;
847 /******************************************************************************
848 * RtlPopFrame (NTDLL.@)
850 void WINAPI
RtlPopFrame( TEB_ACTIVE_FRAME
*frame
)
852 NtCurrentTeb()->ActiveFrame
= frame
->Previous
;
856 /******************************************************************************
857 * RtlGetFrame (NTDLL.@)
859 TEB_ACTIVE_FRAME
* WINAPI
RtlGetFrame(void)
861 return NtCurrentTeb()->ActiveFrame
;
865 /***********************************************************************
868 NTSTATUS
set_thread_context( HANDLE handle
, const context_t
*context
, BOOL
*self
)
873 SERVER_START_REQ( set_thread_context
)
875 req
->handle
= wine_server_obj_handle( handle
);
877 wine_server_add_data( req
, context
, sizeof(*context
) );
878 ret
= wine_server_call( req
);
883 if (ret
== STATUS_PENDING
)
885 for (i
= 0; i
< 100; i
++)
887 SERVER_START_REQ( set_thread_context
)
889 req
->handle
= wine_server_obj_handle( handle
);
891 wine_server_add_data( req
, context
, sizeof(*context
) );
892 ret
= wine_server_call( req
);
895 if (ret
== STATUS_PENDING
)
897 LARGE_INTEGER timeout
;
898 timeout
.QuadPart
= -10000;
899 NtDelayExecution( FALSE
, &timeout
);
903 NtResumeThread( handle
, &dummy
);
904 if (ret
== STATUS_PENDING
) ret
= STATUS_ACCESS_DENIED
;
911 /***********************************************************************
914 NTSTATUS
get_thread_context( HANDLE handle
, context_t
*context
, unsigned int flags
, BOOL
*self
)
919 SERVER_START_REQ( get_thread_context
)
921 req
->handle
= wine_server_obj_handle( handle
);
924 wine_server_set_reply( req
, context
, sizeof(*context
) );
925 ret
= wine_server_call( req
);
930 if (ret
== STATUS_PENDING
)
932 for (i
= 0; i
< 100; i
++)
934 SERVER_START_REQ( get_thread_context
)
936 req
->handle
= wine_server_obj_handle( handle
);
939 wine_server_set_reply( req
, context
, sizeof(*context
) );
940 ret
= wine_server_call( req
);
943 if (ret
== STATUS_PENDING
)
945 LARGE_INTEGER timeout
;
946 timeout
.QuadPart
= -10000;
947 NtDelayExecution( FALSE
, &timeout
);
951 NtResumeThread( handle
, &dummy
);
952 if (ret
== STATUS_PENDING
) ret
= STATUS_ACCESS_DENIED
;
958 /******************************************************************************
959 * NtQueryInformationThread (NTDLL.@)
960 * ZwQueryInformationThread (NTDLL.@)
962 NTSTATUS WINAPI
NtQueryInformationThread( HANDLE handle
, THREADINFOCLASS
class,
963 void *data
, ULONG length
, ULONG
*ret_len
)
969 case ThreadBasicInformation
:
971 THREAD_BASIC_INFORMATION info
;
972 const ULONG_PTR affinity_mask
= get_system_affinity_mask();
974 SERVER_START_REQ( get_thread_info
)
976 req
->handle
= wine_server_obj_handle( handle
);
978 if (!(status
= wine_server_call( req
)))
980 info
.ExitStatus
= reply
->exit_code
;
981 info
.TebBaseAddress
= wine_server_get_ptr( reply
->teb
);
982 info
.ClientId
.UniqueProcess
= ULongToHandle(reply
->pid
);
983 info
.ClientId
.UniqueThread
= ULongToHandle(reply
->tid
);
984 info
.AffinityMask
= reply
->affinity
& affinity_mask
;
985 info
.Priority
= reply
->priority
;
986 info
.BasePriority
= reply
->priority
; /* FIXME */
990 if (status
== STATUS_SUCCESS
)
992 if (data
) memcpy( data
, &info
, min( length
, sizeof(info
) ));
993 if (ret_len
) *ret_len
= min( length
, sizeof(info
) );
997 case ThreadAffinityMask
:
999 const ULONG_PTR affinity_mask
= get_system_affinity_mask();
1000 ULONG_PTR affinity
= 0;
1002 SERVER_START_REQ( get_thread_info
)
1004 req
->handle
= wine_server_obj_handle( handle
);
1006 if (!(status
= wine_server_call( req
)))
1007 affinity
= reply
->affinity
& affinity_mask
;
1010 if (status
== STATUS_SUCCESS
)
1012 if (data
) memcpy( data
, &affinity
, min( length
, sizeof(affinity
) ));
1013 if (ret_len
) *ret_len
= min( length
, sizeof(affinity
) );
1019 KERNEL_USER_TIMES kusrt
;
1021 SERVER_START_REQ( get_thread_times
)
1023 req
->handle
= wine_server_obj_handle( handle
);
1024 status
= wine_server_call( req
);
1025 if (status
== STATUS_SUCCESS
)
1027 kusrt
.CreateTime
.QuadPart
= reply
->creation_time
;
1028 kusrt
.ExitTime
.QuadPart
= reply
->exit_time
;
1032 if (status
== STATUS_SUCCESS
)
1034 /* We call times(2) for kernel time or user time */
1035 /* We can only (portably) do this for the current thread */
1036 if (handle
== GetCurrentThread())
1038 struct tms time_buf
;
1039 long clocks_per_sec
= sysconf(_SC_CLK_TCK
);
1042 kusrt
.KernelTime
.QuadPart
= (ULONGLONG
)time_buf
.tms_stime
* 10000000 / clocks_per_sec
;
1043 kusrt
.UserTime
.QuadPart
= (ULONGLONG
)time_buf
.tms_utime
* 10000000 / clocks_per_sec
;
1047 static BOOL reported
= FALSE
;
1049 kusrt
.KernelTime
.QuadPart
= 0;
1050 kusrt
.UserTime
.QuadPart
= 0;
1052 TRACE("Cannot get kerneltime or usertime of other threads\n");
1055 FIXME("Cannot get kerneltime or usertime of other threads\n");
1059 if (data
) memcpy( data
, &kusrt
, min( length
, sizeof(kusrt
) ));
1060 if (ret_len
) *ret_len
= min( length
, sizeof(kusrt
) );
1064 case ThreadDescriptorTableEntry
:
1067 THREAD_DESCRIPTOR_INFORMATION
* tdi
= data
;
1068 if (length
< sizeof(*tdi
))
1069 status
= STATUS_INFO_LENGTH_MISMATCH
;
1070 else if (!(tdi
->Selector
& 4)) /* GDT selector */
1072 unsigned sel
= LOWORD(tdi
->Selector
) & ~3; /* ignore RPL */
1073 status
= STATUS_SUCCESS
;
1074 if (!sel
) /* null selector */
1075 memset( &tdi
->Entry
, 0, sizeof(tdi
->Entry
) );
1078 tdi
->Entry
.BaseLow
= 0;
1079 tdi
->Entry
.HighWord
.Bits
.BaseMid
= 0;
1080 tdi
->Entry
.HighWord
.Bits
.BaseHi
= 0;
1081 tdi
->Entry
.LimitLow
= 0xffff;
1082 tdi
->Entry
.HighWord
.Bits
.LimitHi
= 0xf;
1083 tdi
->Entry
.HighWord
.Bits
.Dpl
= 3;
1084 tdi
->Entry
.HighWord
.Bits
.Sys
= 0;
1085 tdi
->Entry
.HighWord
.Bits
.Pres
= 1;
1086 tdi
->Entry
.HighWord
.Bits
.Granularity
= 1;
1087 tdi
->Entry
.HighWord
.Bits
.Default_Big
= 1;
1088 tdi
->Entry
.HighWord
.Bits
.Type
= 0x12;
1089 tdi
->Entry
.HighWord
.Bits
.Reserved_0
= 0;
1090 /* it has to be one of the system GDT selectors */
1091 if (sel
!= (wine_get_ds() & ~3) && sel
!= (wine_get_ss() & ~3))
1093 if (sel
== (wine_get_cs() & ~3))
1094 tdi
->Entry
.HighWord
.Bits
.Type
|= 8; /* code segment */
1095 else if (sel
== (wine_get_fs() & ~3))
1097 ULONG_PTR fs_base
= (ULONG_PTR
)NtCurrentTeb();
1098 tdi
->Entry
.BaseLow
= fs_base
& 0xffff;
1099 tdi
->Entry
.HighWord
.Bits
.BaseMid
= (fs_base
>> 16) & 0xff;
1100 tdi
->Entry
.HighWord
.Bits
.BaseHi
= (fs_base
>> 24) & 0xff;
1101 tdi
->Entry
.LimitLow
= 0x0fff;
1102 tdi
->Entry
.HighWord
.Bits
.LimitHi
= 0;
1103 tdi
->Entry
.HighWord
.Bits
.Granularity
= 0;
1105 else status
= STATUS_ACCESS_DENIED
;
1111 SERVER_START_REQ( get_selector_entry
)
1113 req
->handle
= wine_server_obj_handle( handle
);
1114 req
->entry
= LOWORD(tdi
->Selector
) >> 3;
1115 status
= wine_server_call( req
);
1118 if (!(reply
->flags
& WINE_LDT_FLAGS_ALLOCATED
))
1119 status
= STATUS_ACCESS_VIOLATION
;
1122 wine_ldt_set_base ( &tdi
->Entry
, (void *)reply
->base
);
1123 wine_ldt_set_limit( &tdi
->Entry
, reply
->limit
);
1124 wine_ldt_set_flags( &tdi
->Entry
, reply
->flags
);
1130 if (status
== STATUS_SUCCESS
&& ret_len
)
1131 /* yes, that's a bit strange, but it's the way it is */
1132 *ret_len
= sizeof(LDT_ENTRY
);
1134 status
= STATUS_NOT_IMPLEMENTED
;
1138 case ThreadAmILastThread
:
1140 SERVER_START_REQ(get_thread_info
)
1142 req
->handle
= wine_server_obj_handle( handle
);
1144 status
= wine_server_call( req
);
1145 if (status
== STATUS_SUCCESS
)
1147 BOOLEAN last
= reply
->last
;
1148 if (data
) memcpy( data
, &last
, min( length
, sizeof(last
) ));
1149 if (ret_len
) *ret_len
= min( length
, sizeof(last
) );
1155 case ThreadQuerySetWin32StartAddress
:
1157 SERVER_START_REQ( get_thread_info
)
1159 req
->handle
= wine_server_obj_handle( handle
);
1161 status
= wine_server_call( req
);
1162 if (status
== STATUS_SUCCESS
)
1164 PRTL_THREAD_START_ROUTINE entry
= wine_server_get_ptr( reply
->entry_point
);
1165 if (data
) memcpy( data
, &entry
, min( length
, sizeof(entry
) ) );
1166 if (ret_len
) *ret_len
= min( length
, sizeof(entry
) );
1172 case ThreadGroupInformation
:
1174 const ULONG_PTR affinity_mask
= get_system_affinity_mask();
1175 GROUP_AFFINITY affinity
;
1177 memset(&affinity
, 0, sizeof(affinity
));
1178 affinity
.Group
= 0; /* Wine only supports max 64 processors */
1180 SERVER_START_REQ( get_thread_info
)
1182 req
->handle
= wine_server_obj_handle( handle
);
1184 if (!(status
= wine_server_call( req
)))
1185 affinity
.Mask
= reply
->affinity
& affinity_mask
;
1188 if (status
== STATUS_SUCCESS
)
1190 if (data
) memcpy( data
, &affinity
, min( length
, sizeof(affinity
) ));
1191 if (ret_len
) *ret_len
= min( length
, sizeof(affinity
) );
1195 case ThreadIsIoPending
:
1196 FIXME( "ThreadIsIoPending info class not supported yet\n" );
1197 if (length
!= sizeof(BOOL
)) return STATUS_INFO_LENGTH_MISMATCH
;
1198 if (!data
) return STATUS_ACCESS_DENIED
;
1200 *(BOOL
*)data
= FALSE
;
1201 if (ret_len
) *ret_len
= sizeof(BOOL
);
1202 return STATUS_SUCCESS
;
1203 case ThreadPriority
:
1204 case ThreadBasePriority
:
1205 case ThreadImpersonationToken
:
1206 case ThreadEnableAlignmentFaultFixup
:
1207 case ThreadEventPair_Reusable
:
1208 case ThreadZeroTlsCell
:
1209 case ThreadPerformanceCount
:
1210 case ThreadIdealProcessor
:
1211 case ThreadPriorityBoost
:
1212 case ThreadSetTlsArrayAddress
:
1214 FIXME( "info class %d not supported yet\n", class );
1215 return STATUS_NOT_IMPLEMENTED
;
1220 /******************************************************************************
1221 * NtSetInformationThread (NTDLL.@)
1222 * ZwSetInformationThread (NTDLL.@)
1224 NTSTATUS WINAPI
NtSetInformationThread( HANDLE handle
, THREADINFOCLASS
class,
1225 LPCVOID data
, ULONG length
)
1230 case ThreadZeroTlsCell
:
1231 if (handle
== GetCurrentThread())
1236 if (length
!= sizeof(DWORD
)) return STATUS_INVALID_PARAMETER
;
1237 index
= *(const DWORD
*)data
;
1238 if (index
< TLS_MINIMUM_AVAILABLE
)
1240 RtlAcquirePebLock();
1241 for (entry
= tls_links
.Flink
; entry
!= &tls_links
; entry
= entry
->Flink
)
1243 TEB
*teb
= CONTAINING_RECORD(entry
, TEB
, TlsLinks
);
1244 teb
->TlsSlots
[index
] = 0;
1246 RtlReleasePebLock();
1250 index
-= TLS_MINIMUM_AVAILABLE
;
1251 if (index
>= 8 * sizeof(NtCurrentTeb()->Peb
->TlsExpansionBitmapBits
))
1252 return STATUS_INVALID_PARAMETER
;
1253 RtlAcquirePebLock();
1254 for (entry
= tls_links
.Flink
; entry
!= &tls_links
; entry
= entry
->Flink
)
1256 TEB
*teb
= CONTAINING_RECORD(entry
, TEB
, TlsLinks
);
1257 if (teb
->TlsExpansionSlots
) teb
->TlsExpansionSlots
[index
] = 0;
1259 RtlReleasePebLock();
1261 return STATUS_SUCCESS
;
1263 FIXME( "ZeroTlsCell not supported on other threads\n" );
1264 return STATUS_NOT_IMPLEMENTED
;
1266 case ThreadImpersonationToken
:
1268 const HANDLE
*phToken
= data
;
1269 if (length
!= sizeof(HANDLE
)) return STATUS_INVALID_PARAMETER
;
1270 TRACE("Setting ThreadImpersonationToken handle to %p\n", *phToken
);
1271 SERVER_START_REQ( set_thread_info
)
1273 req
->handle
= wine_server_obj_handle( handle
);
1274 req
->token
= wine_server_obj_handle( *phToken
);
1275 req
->mask
= SET_THREAD_INFO_TOKEN
;
1276 status
= wine_server_call( req
);
1281 case ThreadBasePriority
:
1283 const DWORD
*pprio
= data
;
1284 if (length
!= sizeof(DWORD
)) return STATUS_INVALID_PARAMETER
;
1285 SERVER_START_REQ( set_thread_info
)
1287 req
->handle
= wine_server_obj_handle( handle
);
1288 req
->priority
= *pprio
;
1289 req
->mask
= SET_THREAD_INFO_PRIORITY
;
1290 status
= wine_server_call( req
);
1295 case ThreadAffinityMask
:
1297 const ULONG_PTR affinity_mask
= get_system_affinity_mask();
1300 if (length
!= sizeof(ULONG_PTR
)) return STATUS_INVALID_PARAMETER
;
1301 req_aff
= *(const ULONG_PTR
*)data
& affinity_mask
;
1302 if (!req_aff
) return STATUS_INVALID_PARAMETER
;
1304 SERVER_START_REQ( set_thread_info
)
1306 req
->handle
= wine_server_obj_handle( handle
);
1307 req
->affinity
= req_aff
;
1308 req
->mask
= SET_THREAD_INFO_AFFINITY
;
1309 status
= wine_server_call( req
);
1314 case ThreadHideFromDebugger
:
1315 /* pretend the call succeeded to satisfy some code protectors */
1316 return STATUS_SUCCESS
;
1317 case ThreadQuerySetWin32StartAddress
:
1319 const PRTL_THREAD_START_ROUTINE
*entry
= data
;
1320 if (length
!= sizeof(PRTL_THREAD_START_ROUTINE
)) return STATUS_INVALID_PARAMETER
;
1321 SERVER_START_REQ( set_thread_info
)
1323 req
->handle
= wine_server_obj_handle( handle
);
1324 req
->mask
= SET_THREAD_INFO_ENTRYPOINT
;
1325 req
->entry_point
= wine_server_client_ptr( *entry
);
1326 status
= wine_server_call( req
);
1331 case ThreadGroupInformation
:
1333 const ULONG_PTR affinity_mask
= get_system_affinity_mask();
1334 const GROUP_AFFINITY
*req_aff
;
1336 if (length
!= sizeof(*req_aff
)) return STATUS_INVALID_PARAMETER
;
1337 if (!data
) return STATUS_ACCESS_VIOLATION
;
1340 /* On Windows the request fails if the reserved fields are set */
1341 if (req_aff
->Reserved
[0] || req_aff
->Reserved
[1] || req_aff
->Reserved
[2])
1342 return STATUS_INVALID_PARAMETER
;
1344 /* Wine only supports max 64 processors */
1345 if (req_aff
->Group
) return STATUS_INVALID_PARAMETER
;
1346 if (req_aff
->Mask
& ~affinity_mask
) return STATUS_INVALID_PARAMETER
;
1347 if (!req_aff
->Mask
) return STATUS_INVALID_PARAMETER
;
1348 SERVER_START_REQ( set_thread_info
)
1350 req
->handle
= wine_server_obj_handle( handle
);
1351 req
->affinity
= req_aff
->Mask
;
1352 req
->mask
= SET_THREAD_INFO_AFFINITY
;
1353 status
= wine_server_call( req
);
1358 case ThreadBasicInformation
:
1360 case ThreadPriority
:
1361 case ThreadDescriptorTableEntry
:
1362 case ThreadEnableAlignmentFaultFixup
:
1363 case ThreadEventPair_Reusable
:
1364 case ThreadPerformanceCount
:
1365 case ThreadAmILastThread
:
1366 case ThreadIdealProcessor
:
1367 case ThreadPriorityBoost
:
1368 case ThreadSetTlsArrayAddress
:
1369 case ThreadIsIoPending
:
1371 FIXME( "info class %d not supported yet\n", class );
1372 return STATUS_NOT_IMPLEMENTED
;
1376 /******************************************************************************
1377 * NtGetCurrentProcessorNumber (NTDLL.@)
1379 * Return the processor, on which the thread is running
1382 ULONG WINAPI
NtGetCurrentProcessorNumber(void)
1386 #if defined(__linux__) && defined(__NR_getcpu)
1387 int res
= syscall(__NR_getcpu
, &processor
, NULL
, NULL
);
1388 if (res
!= -1) return processor
;
1391 if (NtCurrentTeb()->Peb
->NumberOfProcessors
> 1)
1393 ULONG_PTR thread_mask
, processor_mask
;
1396 status
= NtQueryInformationThread(GetCurrentThread(), ThreadAffinityMask
,
1397 &thread_mask
, sizeof(thread_mask
), NULL
);
1398 if (status
== STATUS_SUCCESS
)
1400 for (processor
= 0; processor
< NtCurrentTeb()->Peb
->NumberOfProcessors
; processor
++)
1402 processor_mask
= (1 << processor
);
1403 if (thread_mask
& processor_mask
)
1405 if (thread_mask
!= processor_mask
)
1406 FIXME("need multicore support (%d processors)\n",
1407 NtCurrentTeb()->Peb
->NumberOfProcessors
);
1414 /* fallback to the first processor */