server: Make the various async I/O parameters client_ptr_t instead of void pointers.

This commit is contained in:
Alexandre Julliard 2008-12-30 21:09:41 +01:00
parent f507ccbf52
commit 6db201080f
12 changed files with 83 additions and 63 deletions

View File

@ -2401,9 +2401,9 @@ NtNotifyChangeDirectoryFile( HANDLE FileHandle, HANDLE Event,
req->want_data = (Buffer != NULL);
req->subtree = WatchTree;
req->async.handle = wine_server_obj_handle( FileHandle );
req->async.callback = read_changes_apc;
req->async.iosb = IoStatusBlock;
req->async.arg = info;
req->async.callback = wine_server_client_ptr( read_changes_apc );
req->async.iosb = wine_server_client_ptr( IoStatusBlock );
req->async.arg = wine_server_client_ptr( info );
req->async.event = wine_server_obj_handle( Event );
req->async.cvalue = cvalue;
status = wine_server_call( req );

View File

@ -657,9 +657,9 @@ NTSTATUS WINAPI NtReadFile(HANDLE hFile, HANDLE hEvent,
req->count = length;
req->async.handle = wine_server_obj_handle( hFile );
req->async.event = wine_server_obj_handle( hEvent );
req->async.callback = FILE_AsyncReadService;
req->async.iosb = io_status;
req->async.arg = fileio;
req->async.callback = wine_server_client_ptr( FILE_AsyncReadService );
req->async.iosb = wine_server_client_ptr( io_status );
req->async.arg = wine_server_client_ptr( fileio );
req->async.cvalue = cvalue;
status = wine_server_call( req );
}
@ -981,9 +981,9 @@ NTSTATUS WINAPI NtWriteFile(HANDLE hFile, HANDLE hEvent,
req->count = length;
req->async.handle = wine_server_obj_handle( hFile );
req->async.event = wine_server_obj_handle( hEvent );
req->async.callback = FILE_AsyncWriteService;
req->async.iosb = io_status;
req->async.arg = fileio;
req->async.callback = wine_server_client_ptr( FILE_AsyncWriteService );
req->async.iosb = wine_server_client_ptr( io_status );
req->async.arg = wine_server_client_ptr( fileio );
req->async.cvalue = cvalue;
status = wine_server_call( req );
}
@ -1164,7 +1164,7 @@ static NTSTATUS ioctl_completion( void *arg, IO_STATUS_BLOCK *io, NTSTATUS statu
SERVER_START_REQ( get_ioctl_result )
{
req->handle = wine_server_obj_handle( async->handle );
req->user_arg = async;
req->user_arg = wine_server_client_ptr( async );
wine_server_set_reply( req, async->buffer, async->size );
if (!(status = wine_server_call( req )))
io->Information = wine_server_reply_size( reply );
@ -1206,9 +1206,9 @@ static NTSTATUS server_ioctl_file( HANDLE handle, HANDLE event,
req->code = code;
req->blocking = !apc && !event;
req->async.handle = wine_server_obj_handle( handle );
req->async.callback = ioctl_completion;
req->async.iosb = io;
req->async.arg = async;
req->async.callback = wine_server_client_ptr( ioctl_completion );
req->async.iosb = wine_server_client_ptr( io );
req->async.arg = wine_server_client_ptr( async );
req->async.event = wine_server_obj_handle( event );
req->async.cvalue = cvalue;
wine_server_add_data( req, in_buffer, in_size );

View File

@ -853,9 +853,12 @@ static BOOL invoke_apc( const apc_call_t *call, apc_result_t *result )
case APC_NONE:
break;
case APC_USER:
call->user.func( call->user.args[0], call->user.args[1], call->user.args[2] );
{
void (WINAPI *func)(ULONG_PTR,ULONG_PTR,ULONG_PTR) = wine_server_get_ptr( call->user.func );
func( call->user.args[0], call->user.args[1], call->user.args[2] );
user_apc = TRUE;
break;
}
case APC_TIMER:
{
void (WINAPI *func)(void*, unsigned int, unsigned int) = wine_server_get_ptr( call->timer.func );
@ -867,14 +870,15 @@ static BOOL invoke_apc( const apc_call_t *call, apc_result_t *result )
case APC_ASYNC_IO:
{
void *apc = NULL;
IO_STATUS_BLOCK *iosb = call->async_io.sb;
IO_STATUS_BLOCK *iosb = wine_server_get_ptr( call->async_io.sb );
NTSTATUS (*func)(void *, IO_STATUS_BLOCK *, NTSTATUS, void **) = wine_server_get_ptr( call->async_io.func );
result->type = call->type;
result->async_io.status = call->async_io.func( call->async_io.user, iosb,
call->async_io.status, &apc );
result->async_io.status = func( wine_server_get_ptr( call->async_io.user ),
iosb, call->async_io.status, &apc );
if (result->async_io.status != STATUS_PENDING)
{
result->async_io.total = iosb->Information;
result->async_io.apc = apc;
result->async_io.apc = wine_server_client_ptr( apc );
}
break;
}

View File

@ -751,7 +751,7 @@ NTSTATUS WINAPI NtQueueApcThread( HANDLE handle, PNTAPCFUNC func, ULONG_PTR arg1
if (func)
{
req->call.type = APC_USER;
req->call.user.func = func;
req->call.user.func = wine_server_client_ptr( func );
req->call.user.args[0] = arg1;
req->call.user.args[1] = arg2;
req->call.user.args[2] = arg3;

View File

@ -1334,9 +1334,9 @@ static int WS2_register_async_shutdown( SOCKET s, int type )
{
req->type = type;
req->async.handle = wine_server_obj_handle( wsa->hSocket );
req->async.callback = WS2_async_shutdown;
req->async.iosb = &wsa->local_iosb;
req->async.arg = wsa;
req->async.callback = wine_server_client_ptr( WS2_async_shutdown );
req->async.iosb = wine_server_client_ptr( &wsa->local_iosb );
req->async.arg = wine_server_client_ptr( wsa );
req->async.cvalue = 0;
status = wine_server_call( req );
}
@ -2786,9 +2786,9 @@ INT WINAPI WSASendTo( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
{
req->type = ASYNC_TYPE_WRITE;
req->async.handle = wine_server_obj_handle( wsa->hSocket );
req->async.callback = WS2_async_send;
req->async.iosb = iosb;
req->async.arg = wsa;
req->async.callback = wine_server_client_ptr( WS2_async_send );
req->async.iosb = wine_server_client_ptr( iosb );
req->async.arg = wine_server_client_ptr( wsa );
req->async.event = wine_server_obj_handle( lpCompletionRoutine ? 0 : lpOverlapped->hEvent );
req->async.cvalue = cvalue;
err = wine_server_call( req );
@ -4311,9 +4311,9 @@ INT WINAPI WSARecvFrom( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
{
req->type = ASYNC_TYPE_READ;
req->async.handle = wine_server_obj_handle( wsa->hSocket );
req->async.callback = WS2_async_recv;
req->async.iosb = iosb;
req->async.arg = wsa;
req->async.callback = wine_server_client_ptr( WS2_async_recv );
req->async.iosb = wine_server_client_ptr( iosb );
req->async.arg = wine_server_client_ptr( wsa );
req->async.event = wine_server_obj_handle( lpCompletionRoutine ? 0 : lpOverlapped->hEvent );
req->async.cvalue = cvalue;
err = wine_server_call( req );

View File

@ -166,9 +166,9 @@ typedef struct
{
obj_handle_t handle;
obj_handle_t event;
void *callback;
void *iosb;
void *arg;
client_ptr_t callback;
client_ptr_t iosb;
client_ptr_t arg;
apc_param_t cvalue;
} async_data_t;
@ -272,7 +272,8 @@ typedef union
struct
{
enum apc_type type;
void (__stdcall *func)(unsigned long,unsigned long,unsigned long);
int __pad;
client_ptr_t func;
apc_param_t args[3];
} user;
struct
@ -286,10 +287,10 @@ typedef union
struct
{
enum apc_type type;
unsigned int (*func)(void*, void*, unsigned int, void **);
void *user;
void *sb;
unsigned int status;
client_ptr_t func;
client_ptr_t user;
client_ptr_t sb;
} async_io;
struct
{
@ -376,7 +377,7 @@ typedef union
{
enum apc_type type;
unsigned int status;
void *apc;
client_ptr_t apc;
unsigned int total;
} async_io;
struct
@ -2727,7 +2728,7 @@ struct get_ioctl_result_request
{
struct request_header __header;
obj_handle_t handle;
void* user_arg;
client_ptr_t user_arg;
};
struct get_ioctl_result_reply
{
@ -5060,6 +5061,6 @@ union generic_reply
struct set_window_layered_info_reply set_window_layered_info_reply;
};
#define SERVER_PROTOCOL_VERSION 372
#define SERVER_PROTOCOL_VERSION 373
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */

View File

@ -234,7 +234,7 @@ void async_set_timeout( struct async *async, timeout_t timeout, unsigned int sta
}
/* store the result of the client-side async callback */
void async_set_result( struct object *obj, unsigned int status, unsigned int total, void *apc )
void async_set_result( struct object *obj, unsigned int status, unsigned int total, client_ptr_t apc )
{
struct async *async = (struct async *)obj;
@ -266,8 +266,8 @@ void async_set_result( struct object *obj, unsigned int status, unsigned int tot
memset( &data, 0, sizeof(data) );
data.type = APC_USER;
data.user.func = apc;
data.user.args[0] = (apc_param_t)(unsigned long)async->data.arg;
data.user.args[1] = (apc_param_t)(unsigned long)async->data.iosb;
data.user.args[0] = async->data.arg;
data.user.args[1] = async->data.iosb;
data.user.args[2] = 0;
thread_queue_apc( async->thread, NULL, &data );
}

View File

@ -40,7 +40,7 @@ struct ioctl_call
struct list mgr_entry; /* entry in manager queue */
struct device *device; /* device containing this ioctl */
struct thread *thread; /* thread that queued the ioctl */
void *user_arg; /* user arg used to identify the request */
client_ptr_t user_arg; /* user arg used to identify the request */
struct async *async; /* pending async op */
ioctl_code_t code; /* ioctl code */
unsigned int status; /* resulting status (or STATUS_PENDING) */
@ -296,7 +296,7 @@ static enum server_fd_type device_get_fd_type( struct fd *fd )
}
static struct ioctl_call *find_ioctl_call( struct device *device, struct thread *thread,
void *user_arg )
client_ptr_t user_arg )
{
struct ioctl_call *ioctl;

View File

@ -138,7 +138,8 @@ extern void free_async_queue( struct async_queue *queue );
extern struct async *create_async( struct thread *thread, struct async_queue *queue,
const async_data_t *data );
extern void async_set_timeout( struct async *async, timeout_t timeout, unsigned int status );
extern void async_set_result( struct object *obj, unsigned int status, unsigned int total, void *apc );
extern void async_set_result( struct object *obj, unsigned int status,
unsigned int total, client_ptr_t apc );
extern int async_waiting( struct async_queue *queue );
extern void async_terminate( struct async *async, unsigned int status );
extern void async_wake_up( struct async_queue *queue, unsigned int status );

View File

@ -182,9 +182,9 @@ typedef struct
{
obj_handle_t handle; /* object to perform I/O on */
obj_handle_t event; /* event to signal when done */
void *callback; /* client-side callback to call upon end of async */
void *iosb; /* I/O status block in client addr space */
void *arg; /* opaque user data to pass to callback */
client_ptr_t callback; /* client-side callback to call upon end of async */
client_ptr_t iosb; /* I/O status block in client addr space */
client_ptr_t arg; /* opaque user data to pass to callback */
apc_param_t cvalue; /* completion value to use for completion events */
} async_data_t;
@ -288,7 +288,8 @@ typedef union
struct
{
enum apc_type type; /* APC_USER */
void (__stdcall *func)(unsigned long,unsigned long,unsigned long);
int __pad;
client_ptr_t func; /* void (__stdcall *func)(ULONG_PTR,ULONG_PTR,ULONG_PTR); */
apc_param_t args[3]; /* arguments for user function */
} user;
struct
@ -302,10 +303,10 @@ typedef union
struct
{
enum apc_type type; /* APC_ASYNC_IO */
unsigned int (*func)(void*, void*, unsigned int, void **);
void *user; /* user pointer */
void *sb; /* status block */
unsigned int status; /* I/O status */
client_ptr_t func; /* unsigned int (*func)(void*, void*, unsigned int, void **); */
client_ptr_t user; /* user pointer */
client_ptr_t sb; /* status block */
} async_io;
struct
{
@ -392,7 +393,7 @@ typedef union
{
enum apc_type type; /* APC_ASYNC_IO */
unsigned int status; /* new status of async operation */
void *apc; /* user APC to call */
client_ptr_t apc; /* user APC to call */
unsigned int total; /* bytes transferred */
} async_io;
struct
@ -2015,7 +2016,7 @@ enum message_type
/* Retrieve results of an async ioctl */
@REQ(get_ioctl_result)
obj_handle_t handle; /* handle to the device */
void* user_arg; /* user arg used to identify the request */
client_ptr_t user_arg; /* user arg used to identify the request */
@REPLY
VARARG(out_data,bytes); /* ioctl output data */
@END

View File

@ -114,7 +114,9 @@ static void dump_apc_call( const apc_call_t *call )
fprintf( stderr, "APC_NONE" );
break;
case APC_USER:
fprintf( stderr, "APC_USER,args={" );
fprintf( stderr, "APC_USER,func=" );
dump_uint64( &call->user.func );
fprintf( stderr, ",args={" );
dump_uint64( &call->user.args[0] );
fputc( ',', stderr );
dump_uint64( &call->user.args[1] );
@ -129,9 +131,13 @@ static void dump_apc_call( const apc_call_t *call )
dump_uint64( &call->timer.arg );
break;
case APC_ASYNC_IO:
fprintf( stderr, "APC_ASYNC_IO,func=%p,user=%p,sb=%p,status=%s",
call->async_io.func, call->async_io.user, call->async_io.sb,
get_status_name(call->async_io.status) );
fprintf( stderr, "APC_ASYNC_IO,func=" );
dump_uint64( &call->async_io.func );
fprintf( stderr, ",user=" );
dump_uint64( &call->async_io.user );
fprintf( stderr, ",sb=" );
dump_uint64( &call->async_io.sb );
fprintf( stderr, ",status=%s", get_status_name(call->async_io.status) );
break;
case APC_VIRTUAL_ALLOC:
fprintf( stderr, "APC_VIRTUAL_ALLOC,addr==" );
@ -218,8 +224,9 @@ static void dump_apc_result( const apc_result_t *result )
case APC_NONE:
break;
case APC_ASYNC_IO:
fprintf( stderr, "APC_ASYNC_IO,status=%s,total=%u,apc=%p",
get_status_name( result->async_io.status ), result->async_io.total, result->async_io.apc );
fprintf( stderr, "APC_ASYNC_IO,status=%s,total=%u,apc=",
get_status_name( result->async_io.status ), result->async_io.total );
dump_uint64( &result->async_io.apc );
break;
case APC_VIRTUAL_ALLOC:
fprintf( stderr, "APC_VIRTUAL_ALLOC,status=%s,addr=",
@ -301,8 +308,13 @@ static void dump_apc_result( const apc_result_t *result )
static void dump_async_data( const async_data_t *data )
{
fprintf( stderr, "{handle=%04x,event=%04x,callback=%p,iosb=%p,arg=%p,cvalue=",
data->handle, data->event, data->callback, data->iosb, data->arg );
fprintf( stderr, "{handle=%04x,event=%04x,callback=", data->handle, data->event );
dump_uint64( &data->callback );
fprintf( stderr, ",iosb=" );
dump_uint64( &data->iosb );
fprintf( stderr, ",arg=" );
dump_uint64( &data->arg );
fprintf( stderr, ",cvalue=" );
dump_uint64( &data->cvalue );
fputc( '}', stderr );
}
@ -2608,7 +2620,8 @@ static void dump_ioctl_reply( const struct ioctl_reply *req )
static void dump_get_ioctl_result_request( const struct get_ioctl_result_request *req )
{
fprintf( stderr, " handle=%04x,", req->handle );
fprintf( stderr, " user_arg=%p", req->user_arg );
fprintf( stderr, " user_arg=" );
dump_uint64( &req->user_arg );
}
static void dump_get_ioctl_result_reply( const struct get_ioctl_result_reply *req )

View File

@ -47,7 +47,7 @@ my %formats =
"char_info_t" => [ 4, 2, "&dump_char_info" ],
"apc_call_t" => [ 40, 8, "&dump_apc_call" ],
"apc_result_t" => [ 40, 8, "&dump_apc_result" ],
"async_data_t" => [ 32, 8, "&dump_async_data" ],
"async_data_t" => [ 40, 8, "&dump_async_data" ],
"luid_t" => [ 8, 4, "&dump_luid" ],
"ioctl_code_t" => [ 4, 4, "&dump_ioctl_code" ],
);