From 653d2c4a8de0ff1be7a7db81c9b9fb8fd6b2296c Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Fri, 3 Apr 2009 14:49:10 +0200 Subject: [PATCH] server: Store the type of CPU that the client is running on. --- dlls/ntdll/server.c | 15 +++++++++++++++ include/wine/server_protocol.h | 10 +++++++++- server/process.h | 1 + server/protocol.def | 8 ++++++++ server/request.h | 2 ++ server/thread.c | 6 ++++++ server/trace.c | 19 ++++++++++++++++++- tools/make_requests | 1 + 8 files changed, 60 insertions(+), 2 deletions(-) diff --git a/dlls/ntdll/server.c b/dlls/ntdll/server.c index 46dfc1d2d98..db4f7cee8db 100644 --- a/dlls/ntdll/server.c +++ b/dlls/ntdll/server.c @@ -76,6 +76,20 @@ WINE_DEFAULT_DEBUG_CHANNEL(server); #define SOCKETNAME "socket" /* name of the socket file */ #define LOCKNAME "lock" /* name of the lock file */ +#ifdef __i386__ +static const enum cpu_type client_cpu = CPU_x86; +#elif defined(__x86_64__) +static const enum cpu_type client_cpu = CPU_x86_64; +#elif defined(__ALPHA__) +static const enum cpu_type client_cpu = CPU_ALPHA; +#elif defined(__powerpc__) +static const enum cpu_type client_cpu = CPU_POWERPC; +#elif defined(__sparc__) +static const enum cpu_type client_cpu = CPU_SPARC; +#else +#error Unsupported CPU +#endif + #ifndef HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS /* data structure used to pass an fd with sendmsg/recvmsg */ struct cmsg_fd @@ -1030,6 +1044,7 @@ size_t server_init_thread( void *entry_point ) req->reply_fd = reply_pipe[1]; req->wait_fd = ntdll_get_thread_data()->wait_fd[1]; req->debug_level = (TRACE_ON(server) != 0); + req->cpu = client_cpu; ret = wine_server_call( req ); NtCurrentTeb()->ClientId.UniqueProcess = ULongToHandle(reply->pid); NtCurrentTeb()->ClientId.UniqueThread = ULongToHandle(reply->tid); diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h index a8865e6a037..74366269cee 100644 --- a/include/wine/server_protocol.h +++ b/include/wine/server_protocol.h @@ -128,6 +128,13 @@ typedef union } debug_event_t; +enum cpu_type +{ + CPU_x86, CPU_x86_64, CPU_ALPHA, CPU_POWERPC, CPU_SPARC +}; +typedef int cpu_type_t; + + struct send_fd { thread_id_t tid; @@ -567,6 +574,7 @@ struct init_thread_request client_ptr_t entry; int reply_fd; int wait_fd; + cpu_type_t cpu; }; struct init_thread_reply { @@ -5214,6 +5222,6 @@ union generic_reply struct set_window_layered_info_reply set_window_layered_info_reply; }; -#define SERVER_PROTOCOL_VERSION 382 +#define SERVER_PROTOCOL_VERSION 383 #endif /* __WINE_WINE_SERVER_PROTOCOL_H */ diff --git a/server/process.h b/server/process.h index 5b6dcda20d4..250c5cea035 100644 --- a/server/process.h +++ b/server/process.h @@ -58,6 +58,7 @@ struct process process_id_t id; /* id of the process */ process_id_t group_id; /* group id of the process */ struct timeout_user *sigkill_timeout; /* timeout for final SIGKILL */ + enum cpu_type cpu; /* client CPU type */ int unix_pid; /* Unix pid for final SIGKILL */ int exit_code; /* process exit code */ int running_threads; /* number of threads running in this process */ diff --git a/server/protocol.def b/server/protocol.def index 5cc93dad1b8..0ef309ece52 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -143,6 +143,13 @@ typedef union } rip_info; } debug_event_t; +/* supported CPU types */ +enum cpu_type +{ + CPU_x86, CPU_x86_64, CPU_ALPHA, CPU_POWERPC, CPU_SPARC +}; +typedef int cpu_type_t; + /* structure used in sending an fd from client to server */ struct send_fd { @@ -554,6 +561,7 @@ typedef union client_ptr_t entry; /* entry point or PEB if initial thread (in thread address space) */ int reply_fd; /* fd for reply pipe */ int wait_fd; /* fd for blocking calls pipe */ + cpu_type_t cpu; /* CPU that this thread is running on */ @REPLY process_id_t pid; /* process id of the new thread's process */ thread_id_t tid; /* thread id of the new thread */ diff --git a/server/request.h b/server/request.h index 1adc03b84cb..29ed8c9f9e4 100644 --- a/server/request.h +++ b/server/request.h @@ -600,6 +600,7 @@ C_ASSERT( sizeof(atom_t) == 4 ); C_ASSERT( sizeof(char) == 1 ); C_ASSERT( sizeof(char_info_t) == 4 ); C_ASSERT( sizeof(client_ptr_t) == 8 ); +C_ASSERT( sizeof(cpu_type_t) == 4 ); C_ASSERT( sizeof(data_size_t) == 4 ); C_ASSERT( sizeof(file_pos_t) == 8 ); C_ASSERT( sizeof(int) == 4 ); @@ -663,6 +664,7 @@ C_ASSERT( FIELD_OFFSET(struct init_thread_request, teb) == 24 ); C_ASSERT( FIELD_OFFSET(struct init_thread_request, entry) == 32 ); C_ASSERT( FIELD_OFFSET(struct init_thread_request, reply_fd) == 40 ); C_ASSERT( FIELD_OFFSET(struct init_thread_request, wait_fd) == 44 ); +C_ASSERT( FIELD_OFFSET(struct init_thread_request, cpu) == 48 ); C_ASSERT( FIELD_OFFSET(struct init_thread_reply, pid) == 8 ); C_ASSERT( FIELD_OFFSET(struct init_thread_reply, tid) == 12 ); C_ASSERT( FIELD_OFFSET(struct init_thread_reply, server_start) == 16 ); diff --git a/server/thread.c b/server/thread.c index 6c68a9ea88c..dcf1da22ccf 100644 --- a/server/thread.c +++ b/server/thread.c @@ -1045,10 +1045,16 @@ DECL_HANDLER(init_thread) { process->unix_pid = current->unix_pid; process->peb = req->entry; + process->cpu = req->cpu; reply->info_size = init_process( current ); } else { + if (req->cpu != process->cpu) + { + set_error( STATUS_INVALID_PARAMETER ); + return; + } if (process->unix_pid != current->unix_pid) process->unix_pid = -1; /* can happen with linuxthreads */ if (current->suspend + process->suspend > 0) stop_thread( current ); diff --git a/server/trace.c b/server/trace.c index 13a3ddcbd59..3583cc3ea57 100644 --- a/server/trace.c +++ b/server/trace.c @@ -105,6 +105,21 @@ static void dump_ioctl_code( const ioctl_code_t *code ) } } +static void dump_cpu_type( const cpu_type_t *code ) +{ + switch (*code) + { +#define CASE(c) case CPU_##c: fputs( #c, stderr ); break + CASE(x86); + CASE(x86_64); + CASE(ALPHA); + CASE(POWERPC); + CASE(SPARC); + default: fprintf( stderr, "%u", *code ); break; +#undef CASE + } +} + static void dump_apc_call( const apc_call_t *call ) { fputc( '{', stderr ); @@ -991,7 +1006,9 @@ static void dump_init_thread_request( const struct init_thread_request *req ) dump_uint64( &req->entry ); fprintf( stderr, "," ); fprintf( stderr, " reply_fd=%d,", req->reply_fd ); - fprintf( stderr, " wait_fd=%d", req->wait_fd ); + fprintf( stderr, " wait_fd=%d,", req->wait_fd ); + fprintf( stderr, " cpu=" ); + dump_cpu_type( &req->cpu ); } static void dump_init_thread_reply( const struct init_thread_reply *req ) diff --git a/tools/make_requests b/tools/make_requests index b43fe85b2e2..95c56473a63 100755 --- a/tools/make_requests +++ b/tools/make_requests @@ -50,6 +50,7 @@ my %formats = "async_data_t" => [ 40, 8, "&dump_async_data" ], "luid_t" => [ 8, 4, "&dump_luid" ], "ioctl_code_t" => [ 4, 4, "&dump_ioctl_code" ], + "cpu_type_t" => [ 4, 4, "&dump_cpu_type" ], ); my @requests = ();