From: Rémi Bernon <rbernon(a)codeweavers.com> The client should check that the lower SEQUENCE_MASK_BITS are zero before reading the data and confirm that the number is unchanged when it's finished. Based on a patch by Huw Davies <huw(a)codeweavers.com>. --- server/protocol.def | 1 + server/queue.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/server/protocol.def b/server/protocol.def index f8216d57e25..e7c267b4148 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -899,6 +899,7 @@ struct shared_cursor struct desktop_shared_memory { + unsigned int seq; /* sequence number - server updating if (seq & 1) != 0 */ struct shared_cursor cursor; /* global cursor information */ }; typedef volatile struct desktop_shared_memory desktop_shm_t; diff --git a/server/queue.c b/server/queue.c index 960683c7417..f033d1a754e 100644 --- a/server/queue.c +++ b/server/queue.c @@ -232,15 +232,34 @@ static unsigned int last_input_time; static cursor_pos_t cursor_history[64]; static unsigned int cursor_history_latest; +#if defined(__i386__) || defined(__x86_64__) + #define SHARED_WRITE_BEGIN( object, type ) \ do { \ type *shared = (type *)(object)->shared; \ + shared->seq++; \ do #define SHARED_WRITE_END \ while(0); \ + shared->seq++; \ } while(0); +#else + +#define SHARED_WRITE_BEGIN( object, type ) \ + do { \ + type *shared = (type *)(object)->shared; \ + __atomic_add_fetch( &shared->seq, 1, __ATOMIC_RELEASE ); \ + } while(0) + +#define SHARED_WRITE_END \ + while(0); \ + __atomic_add_fetch( &shared->seq, 1, __ATOMIC_RELEASE ); \ + } while(0) + +#endif + static void queue_hardware_message( struct desktop *desktop, struct message *msg, int always_queue ); static void free_message( struct message *msg ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/3103