From 20687fef1c64dbd0a14cf6a3fcf9baebdfe0313e 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 824a5e7c..decfd7ae 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 X11, fix swapped instance and general class names. - **Breaking:** Removed unnecessary generic parameter `T` from `EventLoopWindowTarget`. - On Windows, macOS, X11, Wayland and Web, implement setting images as cursors. See the `custom_cursors.rs` example. diff --git a/src/event_loop.rs b/src/event_loop.rs index 7f16dbba..ad2bfa59 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(web_platform))] @@ -518,16 +518,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 } }