server: Store process/thread affinity as a 64-bit value.

This commit is contained in:
Alexandre Julliard 2009-01-19 14:15:51 +01:00
parent 7f1dc355ec
commit 913e792b57
9 changed files with 49 additions and 38 deletions

View File

@ -146,7 +146,7 @@ NTSTATUS WINAPI NtQueryInformationProcess(
case ProcessBasicInformation:
{
PROCESS_BASIC_INFORMATION pbi;
const unsigned int affinity_mask = (1 << NtCurrentTeb()->Peb->NumberOfProcessors) - 1;
const ULONG_PTR affinity_mask = ((ULONG_PTR)1 << NtCurrentTeb()->Peb->NumberOfProcessors) - 1;
if (ProcessInformationLength >= sizeof(PROCESS_BASIC_INFORMATION))
{
@ -363,7 +363,7 @@ NTSTATUS WINAPI NtSetInformationProcess(
{
case ProcessAffinityMask:
if (ProcessInformationLength != sizeof(DWORD_PTR)) return STATUS_INVALID_PARAMETER;
if (*(PDWORD_PTR)ProcessInformation & ~((1 << NtCurrentTeb()->Peb->NumberOfProcessors) - 1))
if (*(PDWORD_PTR)ProcessInformation & ~(((DWORD_PTR)1 << NtCurrentTeb()->Peb->NumberOfProcessors) - 1))
return STATUS_INVALID_PARAMETER;
SERVER_START_REQ( set_process_info )
{

View File

@ -1169,7 +1169,7 @@ NTSTATUS WINAPI NtQueryInformationThread( HANDLE handle, THREADINFOCLASS class,
case ThreadBasicInformation:
{
THREAD_BASIC_INFORMATION info;
const unsigned int affinity_mask = (1 << NtCurrentTeb()->Peb->NumberOfProcessors) - 1;
const ULONG_PTR affinity_mask = ((ULONG_PTR)1 << NtCurrentTeb()->Peb->NumberOfProcessors) - 1;
SERVER_START_REQ( get_thread_info )
{
@ -1420,9 +1420,9 @@ NTSTATUS WINAPI NtSetInformationThread( HANDLE handle, THREADINFOCLASS class,
return status;
case ThreadAffinityMask:
{
const DWORD affinity_mask = (1 << NtCurrentTeb()->Peb->NumberOfProcessors) - 1;
const DWORD *paff = data;
if (length != sizeof(DWORD)) return STATUS_INVALID_PARAMETER;
const ULONG_PTR affinity_mask = ((ULONG_PTR)1 << NtCurrentTeb()->Peb->NumberOfProcessors) - 1;
const ULONG_PTR *paff = data;
if (length != sizeof(ULONG_PTR)) return STATUS_INVALID_PARAMETER;
if (*paff & ~affinity_mask) return STATUS_INVALID_PARAMETER;
SERVER_START_REQ( set_thread_info )
{

View File

@ -27,6 +27,7 @@ typedef unsigned __int64 apc_param_t;
typedef unsigned __int64 mem_size_t;
typedef unsigned __int64 file_pos_t;
typedef unsigned __int64 client_ptr_t;
typedef unsigned __int64 affinity_t;
typedef client_ptr_t mod_handle_t;
struct request_header
@ -620,13 +621,12 @@ struct get_process_info_reply
struct reply_header __header;
process_id_t pid;
process_id_t ppid;
int priority;
unsigned int affinity;
affinity_t affinity;
client_ptr_t peb;
timeout_t start_time;
timeout_t end_time;
int exit_code;
char __pad_52[4];
int priority;
};
@ -637,8 +637,7 @@ struct set_process_info_request
obj_handle_t handle;
int mask;
int priority;
unsigned int affinity;
char __pad_28[4];
affinity_t affinity;
};
struct set_process_info_reply
{
@ -661,12 +660,13 @@ struct get_thread_info_reply
process_id_t pid;
thread_id_t tid;
client_ptr_t teb;
int priority;
unsigned int affinity;
affinity_t affinity;
timeout_t creation_time;
timeout_t exit_time;
int exit_code;
int priority;
int last;
char __pad_60[4];
};
@ -677,8 +677,9 @@ struct set_thread_info_request
obj_handle_t handle;
int mask;
int priority;
unsigned int affinity;
affinity_t affinity;
obj_handle_t token;
char __pad_36[4];
};
struct set_thread_info_reply
{
@ -5214,6 +5215,6 @@ union generic_reply
struct set_window_layered_info_reply set_window_layered_info_reply;
};
#define SERVER_PROTOCOL_VERSION 380
#define SERVER_PROTOCOL_VERSION 381
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */

View File

@ -63,8 +63,8 @@ struct process
int running_threads; /* number of threads running in this process */
timeout_t start_time; /* absolute time at process start */
timeout_t end_time; /* absolute time at process end */
affinity_t affinity; /* process affinity mask */
int priority; /* priority class */
unsigned int affinity; /* process affinity mask */
int suspend; /* global process suspend count */
int is_system; /* is it a system process? */
unsigned int create_flags; /* process creation flags */

View File

@ -43,6 +43,7 @@ typedef unsigned __int64 apc_param_t;
typedef unsigned __int64 mem_size_t;
typedef unsigned __int64 file_pos_t;
typedef unsigned __int64 client_ptr_t;
typedef unsigned __int64 affinity_t;
typedef client_ptr_t mod_handle_t;
struct request_header
@ -588,12 +589,12 @@ typedef union
@REPLY
process_id_t pid; /* server process id */
process_id_t ppid; /* server process id of parent */
int priority; /* priority class */
unsigned int affinity; /* process affinity mask */
affinity_t affinity; /* process affinity mask */
client_ptr_t peb; /* PEB address in process address space */
timeout_t start_time; /* process start time */
timeout_t end_time; /* process end time */
int exit_code; /* process exit code */
int priority; /* priority class */
@END
@ -602,7 +603,7 @@ typedef union
obj_handle_t handle; /* process handle */
int mask; /* setting mask (see below) */
int priority; /* priority class */
unsigned int affinity; /* affinity mask */
affinity_t affinity; /* affinity mask */
@END
#define SET_PROCESS_INFO_PRIORITY 0x01
#define SET_PROCESS_INFO_AFFINITY 0x02
@ -616,11 +617,11 @@ typedef union
process_id_t pid; /* server process id */
thread_id_t tid; /* server thread id */
client_ptr_t teb; /* thread teb pointer */
int priority; /* thread priority level */
unsigned int affinity; /* thread affinity mask */
affinity_t affinity; /* thread affinity mask */
timeout_t creation_time; /* thread creation time */
timeout_t exit_time; /* thread exit time */
int exit_code; /* thread exit code */
int priority; /* thread priority level */
int last; /* last thread in process */
@END
@ -630,7 +631,7 @@ typedef union
obj_handle_t handle; /* thread handle */
int mask; /* setting mask (see below) */
int priority; /* priority class */
unsigned int affinity; /* affinity mask */
affinity_t affinity; /* affinity mask */
obj_handle_t token; /* impersonation token */
@END
#define SET_THREAD_INFO_PRIORITY 0x01

View File

@ -591,6 +591,7 @@ static const req_handler req_handlers[REQ_NB_REQUESTS] =
(req_handler)req_set_window_layered_info,
};
C_ASSERT( sizeof(affinity_t) == 8 );
C_ASSERT( sizeof(apc_call_t) == 40 );
C_ASSERT( sizeof(apc_param_t) == 8 );
C_ASSERT( sizeof(apc_result_t) == 40 );
@ -681,12 +682,12 @@ C_ASSERT( sizeof(struct terminate_thread_reply) == 16 );
C_ASSERT( FIELD_OFFSET(struct get_process_info_request, handle) == 12 );
C_ASSERT( FIELD_OFFSET(struct get_process_info_reply, pid) == 8 );
C_ASSERT( FIELD_OFFSET(struct get_process_info_reply, ppid) == 12 );
C_ASSERT( FIELD_OFFSET(struct get_process_info_reply, priority) == 16 );
C_ASSERT( FIELD_OFFSET(struct get_process_info_reply, affinity) == 20 );
C_ASSERT( FIELD_OFFSET(struct get_process_info_reply, affinity) == 16 );
C_ASSERT( FIELD_OFFSET(struct get_process_info_reply, peb) == 24 );
C_ASSERT( FIELD_OFFSET(struct get_process_info_reply, start_time) == 32 );
C_ASSERT( FIELD_OFFSET(struct get_process_info_reply, end_time) == 40 );
C_ASSERT( FIELD_OFFSET(struct get_process_info_reply, exit_code) == 48 );
C_ASSERT( FIELD_OFFSET(struct get_process_info_reply, priority) == 52 );
C_ASSERT( sizeof(struct get_process_info_reply) == 56 );
C_ASSERT( FIELD_OFFSET(struct set_process_info_request, handle) == 12 );
C_ASSERT( FIELD_OFFSET(struct set_process_info_request, mask) == 16 );
@ -698,19 +699,19 @@ C_ASSERT( FIELD_OFFSET(struct get_thread_info_request, tid_in) == 16 );
C_ASSERT( FIELD_OFFSET(struct get_thread_info_reply, pid) == 8 );
C_ASSERT( FIELD_OFFSET(struct get_thread_info_reply, tid) == 12 );
C_ASSERT( FIELD_OFFSET(struct get_thread_info_reply, teb) == 16 );
C_ASSERT( FIELD_OFFSET(struct get_thread_info_reply, priority) == 24 );
C_ASSERT( FIELD_OFFSET(struct get_thread_info_reply, affinity) == 28 );
C_ASSERT( FIELD_OFFSET(struct get_thread_info_reply, affinity) == 24 );
C_ASSERT( FIELD_OFFSET(struct get_thread_info_reply, creation_time) == 32 );
C_ASSERT( FIELD_OFFSET(struct get_thread_info_reply, exit_time) == 40 );
C_ASSERT( FIELD_OFFSET(struct get_thread_info_reply, exit_code) == 48 );
C_ASSERT( FIELD_OFFSET(struct get_thread_info_reply, last) == 52 );
C_ASSERT( sizeof(struct get_thread_info_reply) == 56 );
C_ASSERT( FIELD_OFFSET(struct get_thread_info_reply, priority) == 52 );
C_ASSERT( FIELD_OFFSET(struct get_thread_info_reply, last) == 56 );
C_ASSERT( sizeof(struct get_thread_info_reply) == 64 );
C_ASSERT( FIELD_OFFSET(struct set_thread_info_request, handle) == 12 );
C_ASSERT( FIELD_OFFSET(struct set_thread_info_request, mask) == 16 );
C_ASSERT( FIELD_OFFSET(struct set_thread_info_request, priority) == 20 );
C_ASSERT( FIELD_OFFSET(struct set_thread_info_request, affinity) == 24 );
C_ASSERT( FIELD_OFFSET(struct set_thread_info_request, token) == 28 );
C_ASSERT( sizeof(struct set_thread_info_request) == 32 );
C_ASSERT( FIELD_OFFSET(struct set_thread_info_request, token) == 32 );
C_ASSERT( sizeof(struct set_thread_info_request) == 40 );
C_ASSERT( FIELD_OFFSET(struct get_dll_info_request, handle) == 12 );
C_ASSERT( FIELD_OFFSET(struct get_dll_info_request, base_address) == 16 );
C_ASSERT( FIELD_OFFSET(struct get_dll_info_reply, entry_point) == 8 );

View File

@ -79,8 +79,8 @@ struct thread
CONTEXT *context; /* current context if in an exception handler */
CONTEXT *suspend_context; /* current context if suspended */
client_ptr_t teb; /* TEB address (in client address space) */
affinity_t affinity; /* affinity mask */
int priority; /* priority level */
unsigned int affinity; /* affinity mask */
int suspend; /* suspend count */
obj_handle_t desktop; /* desktop handle */
int desktop_users; /* number of objects using the thread desktop */

View File

@ -1039,8 +1039,9 @@ static void dump_get_process_info_reply( const struct get_process_info_reply *re
{
fprintf( stderr, " pid=%04x,", req->pid );
fprintf( stderr, " ppid=%04x,", req->ppid );
fprintf( stderr, " priority=%d,", req->priority );
fprintf( stderr, " affinity=%08x,", req->affinity );
fprintf( stderr, " affinity=" );
dump_uint64( &req->affinity );
fprintf( stderr, "," );
fprintf( stderr, " peb=" );
dump_uint64( &req->peb );
fprintf( stderr, "," );
@ -1050,7 +1051,8 @@ static void dump_get_process_info_reply( const struct get_process_info_reply *re
fprintf( stderr, " end_time=" );
dump_timeout( &req->end_time );
fprintf( stderr, "," );
fprintf( stderr, " exit_code=%d", req->exit_code );
fprintf( stderr, " exit_code=%d,", req->exit_code );
fprintf( stderr, " priority=%d", req->priority );
}
static void dump_set_process_info_request( const struct set_process_info_request *req )
@ -1058,7 +1060,8 @@ static void dump_set_process_info_request( const struct set_process_info_request
fprintf( stderr, " handle=%04x,", req->handle );
fprintf( stderr, " mask=%d,", req->mask );
fprintf( stderr, " priority=%d,", req->priority );
fprintf( stderr, " affinity=%08x", req->affinity );
fprintf( stderr, " affinity=" );
dump_uint64( &req->affinity );
}
static void dump_get_thread_info_request( const struct get_thread_info_request *req )
@ -1074,8 +1077,9 @@ static void dump_get_thread_info_reply( const struct get_thread_info_reply *req
fprintf( stderr, " teb=" );
dump_uint64( &req->teb );
fprintf( stderr, "," );
fprintf( stderr, " priority=%d,", req->priority );
fprintf( stderr, " affinity=%08x,", req->affinity );
fprintf( stderr, " affinity=" );
dump_uint64( &req->affinity );
fprintf( stderr, "," );
fprintf( stderr, " creation_time=" );
dump_timeout( &req->creation_time );
fprintf( stderr, "," );
@ -1083,6 +1087,7 @@ static void dump_get_thread_info_reply( const struct get_thread_info_reply *req
dump_timeout( &req->exit_time );
fprintf( stderr, "," );
fprintf( stderr, " exit_code=%d,", req->exit_code );
fprintf( stderr, " priority=%d,", req->priority );
fprintf( stderr, " last=%d", req->last );
}
@ -1091,7 +1096,9 @@ static void dump_set_thread_info_request( const struct set_thread_info_request *
fprintf( stderr, " handle=%04x,", req->handle );
fprintf( stderr, " mask=%d,", req->mask );
fprintf( stderr, " priority=%d,", req->priority );
fprintf( stderr, " affinity=%08x,", req->affinity );
fprintf( stderr, " affinity=" );
dump_uint64( &req->affinity );
fprintf( stderr, "," );
fprintf( stderr, " token=%04x", req->token );
}

View File

@ -41,6 +41,7 @@ my %formats =
"apc_param_t" => [ 8, 8, "&dump_uint64" ],
"file_pos_t" => [ 8, 8, "&dump_uint64" ],
"mem_size_t" => [ 8, 8, "&dump_uint64" ],
"affinity_t" => [ 8, 8, "&dump_uint64" ],
"timeout_t" => [ 8, 8, "&dump_timeout" ],
"rectangle_t" => [ 16, 4, "&dump_rectangle" ],
"char_info_t" => [ 4, 2, "&dump_char_info" ],