From bc5b6ff8ce0ee8f8e9b76ef858456c6681631c0c Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Thu, 8 Feb 2024 00:58:43 +0400 Subject: [PATCH] Fix compatibility with platforms without AtomicU64 Fixes #3456. --- CHANGELOG.md | 1 + src/event_loop.rs | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6725a47c7..083783c8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Unreleased` header. # Unreleased +- Fix compatibility with 32-bit platforms without 64-bit atomics. - On macOS, fix incorrect IME cursor rect origin. - On X11, fix swapped instance and general class names. - On Windows, fixed a race condition when sending an event through the loop proxy. diff --git a/src/event_loop.rs b/src/event_loop.rs index 13e7488e8..76e797afa 100644 --- a/src/event_loop.rs +++ b/src/event_loop.rs @@ -11,7 +11,7 @@ use std::marker::PhantomData; use std::ops::Deref; #[cfg(any(x11_platform, wayland_platform))] use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, RawFd}; -use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; +use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use std::{error, fmt}; #[cfg(not(wasm_platform))] @@ -459,16 +459,16 @@ pub enum DeviceEvents { /// executed and removed from the list. #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct AsyncRequestSerial { - serial: u64, + serial: usize, } impl AsyncRequestSerial { - // TODO(kchibisov) remove `cfg` when the clipboard will be added. + // TODO(kchibisov): Remove `cfg` when the clipboard will be added. #[allow(dead_code)] pub(crate) fn get() -> Self { - static CURRENT_SERIAL: AtomicU64 = AtomicU64::new(0); - // NOTE: we rely on wrap around here, while the user may just request - // in the loop u64::MAX times that's issue is considered on them. + static CURRENT_SERIAL: AtomicUsize = AtomicUsize::new(0); + // NOTE: We rely on wrap around here, while the user may just request + // in the loop usize::MAX times that's issue is considered on them. let serial = CURRENT_SERIAL.fetch_add(1, Ordering::Relaxed); Self { serial } }