Jacek Caban : ntdll: Add support for returning previous state argument in event functions.

Alexandre Julliard julliard at winehq.org
Tue Mar 12 16:56:16 CDT 2019


Module: wine
Branch: master
Commit: 7ba361b47bc95df624eac83c170d6c1a4041d8f8
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=7ba361b47bc95df624eac83c170d6c1a4041d8f8

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Mar 11 18:06:39 2019 +0100

ntdll: Add support for returning previous state argument in event functions.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/sync.c              | 10 +++-------
 dlls/ntdll/tests/om.c          |  5 -----
 include/wine/server_protocol.h |  4 +++-
 server/event.c                 |  1 +
 server/protocol.def            |  2 ++
 server/request.h               |  2 ++
 server/trace.c                 |  7 ++++++-
 7 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/dlls/ntdll/sync.c b/dlls/ntdll/sync.c
index ac8c7e5..edf081a 100644
--- a/dlls/ntdll/sync.c
+++ b/dlls/ntdll/sync.c
@@ -405,14 +405,12 @@ NTSTATUS WINAPI NtOpenEvent( HANDLE *handle, ACCESS_MASK access, const OBJECT_AT
 NTSTATUS WINAPI NtSetEvent( HANDLE handle, LONG *prev_state )
 {
     NTSTATUS ret;
-
-    /* FIXME: set NumberOfThreadsReleased */
-
     SERVER_START_REQ( event_op )
     {
         req->handle = wine_server_obj_handle( handle );
         req->op     = SET_EVENT;
         ret = wine_server_call( req );
+        if (!ret && prev_state) *prev_state = reply->state;
     }
     SERVER_END_REQ;
     return ret;
@@ -424,15 +422,12 @@ NTSTATUS WINAPI NtSetEvent( HANDLE handle, LONG *prev_state )
 NTSTATUS WINAPI NtResetEvent( HANDLE handle, LONG *prev_state )
 {
     NTSTATUS ret;
-
-    /* resetting an event can't release any thread... */
-    if (prev_state) *prev_state = 0;
-
     SERVER_START_REQ( event_op )
     {
         req->handle = wine_server_obj_handle( handle );
         req->op     = RESET_EVENT;
         ret = wine_server_call( req );
+        if (!ret && prev_state) *prev_state = reply->state;
     }
     SERVER_END_REQ;
     return ret;
@@ -464,6 +459,7 @@ NTSTATUS WINAPI NtPulseEvent( HANDLE handle, LONG *prev_state )
         req->handle = wine_server_obj_handle( handle );
         req->op     = PULSE_EVENT;
         ret = wine_server_call( req );
+        if (!ret && prev_state) *prev_state = reply->state;
     }
     SERVER_END_REQ;
     return ret;
diff --git a/dlls/ntdll/tests/om.c b/dlls/ntdll/tests/om.c
index 0047a1d..84f97d4 100644
--- a/dlls/ntdll/tests/om.c
+++ b/dlls/ntdll/tests/om.c
@@ -1622,7 +1622,6 @@ static void test_event(void)
 
     status = pNtPulseEvent(Event, &prev_state);
     ok( status == STATUS_SUCCESS, "NtPulseEvent failed %08x\n", status );
-    todo_wine
     ok( !prev_state, "prev_state = %x\n", prev_state );
 
     status = pNtQueryEvent(Event, EventBasicInformation, &info, sizeof(info), NULL);
@@ -1643,17 +1642,14 @@ static void test_event(void)
 
     status = pNtSetEvent( Event, &prev_state );
     ok( status == STATUS_SUCCESS, "NtSetEvent failed: %08x\n", status );
-    todo_wine
     ok( !prev_state, "prev_state = %x\n", prev_state );
 
     status = pNtSetEvent( Event, &prev_state );
     ok( status == STATUS_SUCCESS, "NtSetEvent failed: %08x\n", status );
-    todo_wine
     ok( prev_state == 1, "prev_state = %x\n", prev_state );
 
     status = pNtResetEvent( Event, &prev_state );
     ok( status == STATUS_SUCCESS, "NtSetEvent failed: %08x\n", status );
-    todo_wine
     ok( prev_state == 1, "prev_state = %x\n", prev_state );
 
     status = pNtResetEvent( Event, &prev_state );
@@ -1670,7 +1666,6 @@ static void test_event(void)
 
     status = pNtPulseEvent( Event, &prev_state );
     ok( status == STATUS_SUCCESS, "NtPulseEvent failed %08x\n", status );
-    todo_wine
     ok( prev_state == 1, "prev_state = %x\n", prev_state );
 
     pNtClose(Event);
diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h
index 63f65cd..8b23082e 100644
--- a/include/wine/server_protocol.h
+++ b/include/wine/server_protocol.h
@@ -1247,6 +1247,8 @@ struct event_op_request
 struct event_op_reply
 {
     struct reply_header __header;
+    int           state;
+    char __pad_12[4];
 };
 enum event_op { PULSE_EVENT, SET_EVENT, RESET_EVENT };
 
@@ -6554,6 +6556,6 @@ union generic_reply
     struct terminate_job_reply terminate_job_reply;
 };
 
-#define SERVER_PROTOCOL_VERSION 572
+#define SERVER_PROTOCOL_VERSION 573
 
 #endif /* __WINE_WINE_SERVER_PROTOCOL_H */
diff --git a/server/event.c b/server/event.c
index cfc0f6a..750d20a 100644
--- a/server/event.c
+++ b/server/event.c
@@ -311,6 +311,7 @@ DECL_HANDLER(event_op)
     struct event *event;
 
     if (!(event = get_event_obj( current->process, req->handle, EVENT_MODIFY_STATE ))) return;
+    reply->state = event->signaled;
     switch(req->op)
     {
     case PULSE_EVENT:
diff --git a/server/protocol.def b/server/protocol.def
index e65b984..d567846 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -1080,6 +1080,8 @@ struct rawinput_device
 @REQ(event_op)
     obj_handle_t  handle;       /* handle to event */
     int           op;           /* event operation (see below) */
+ at REPLY
+    int           state;        /* previous state */
 @END
 enum event_op { PULSE_EVENT, SET_EVENT, RESET_EVENT };
 
diff --git a/server/request.h b/server/request.h
index 4610ca6..f71d775 100644
--- a/server/request.h
+++ b/server/request.h
@@ -931,6 +931,8 @@ C_ASSERT( sizeof(struct create_event_reply) == 16 );
 C_ASSERT( FIELD_OFFSET(struct event_op_request, handle) == 12 );
 C_ASSERT( FIELD_OFFSET(struct event_op_request, op) == 16 );
 C_ASSERT( sizeof(struct event_op_request) == 24 );
+C_ASSERT( FIELD_OFFSET(struct event_op_reply, state) == 8 );
+C_ASSERT( sizeof(struct event_op_reply) == 16 );
 C_ASSERT( FIELD_OFFSET(struct query_event_request, handle) == 12 );
 C_ASSERT( sizeof(struct query_event_request) == 16 );
 C_ASSERT( FIELD_OFFSET(struct query_event_reply, manual_reset) == 8 );
diff --git a/server/trace.c b/server/trace.c
index 41bbe4a..8f4ec0d 100644
--- a/server/trace.c
+++ b/server/trace.c
@@ -1594,6 +1594,11 @@ static void dump_event_op_request( const struct event_op_request *req )
     fprintf( stderr, ", op=%d", req->op );
 }
 
+static void dump_event_op_reply( const struct event_op_reply *req )
+{
+    fprintf( stderr, " state=%d", req->state );
+}
+
 static void dump_query_event_request( const struct query_event_request *req )
 {
     fprintf( stderr, " handle=%04x", req->handle );
@@ -4865,7 +4870,7 @@ static const dump_func reply_dumpers[REQ_NB_REQUESTS] = {
     (dump_func)dump_open_thread_reply,
     (dump_func)dump_select_reply,
     (dump_func)dump_create_event_reply,
-    NULL,
+    (dump_func)dump_event_op_reply,
     (dump_func)dump_query_event_reply,
     (dump_func)dump_open_event_reply,
     (dump_func)dump_create_keyed_event_reply,




More information about the wine-cvs mailing list