From f7f541115165f6454d65bfbf6593705acaefd914 Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Thu, 6 Oct 2022 10:17:47 +0100 Subject: [PATCH] Support 32bits targets (#1811) * Replace AtomicU64 with AtomicUsize to prevent compilation issues on 32 bits platforms. * Make sure that Rust tests compile on MacOS. * Add CHANGELOG next entry. --- CHANGELOG.next.toml | 16 ++++++++++++++++ rust-runtime/aws-smithy-client/src/never.rs | 6 +++--- .../aws-smithy-http-server-python/src/socket.rs | 8 ++++++++ .../examples/pokemon-service/src/lib.rs | 4 ++-- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.next.toml b/CHANGELOG.next.toml index 18d9fa6ff17..60a2386ebf4 100644 --- a/CHANGELOG.next.toml +++ b/CHANGELOG.next.toml @@ -11,6 +11,22 @@ # meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "client | server | all"} # author = "rcoh" +[[smithy-rs]] +message = """ +Replace all usages of `AtomicU64` with `AtomicUsize` to support 32bit targets. +""" +references = ["smithy-rs#1811"] +meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "server"} +author = "LukeMathWalker" + +[[smithy-rs]] +message = """ +Replace all usages of `AtomicU64` with `AtomicUsize` to support 32bit targets. +""" +references = ["smithy-rs#1811"] +meta = { "breaking" = true, "tada" = false, "bug" = false, "target" = "client"} +author = "LukeMathWalker" + [[smithy-rs]] message = """ Mark `operation` and `operation_handler` modules as private in the generated server crate. diff --git a/rust-runtime/aws-smithy-client/src/never.rs b/rust-runtime/aws-smithy-client/src/never.rs index 57d3f288a0d..7989800d6bd 100644 --- a/rust-runtime/aws-smithy-client/src/never.rs +++ b/rust-runtime/aws-smithy-client/src/never.rs @@ -10,7 +10,7 @@ use http::Uri; use aws_smithy_async::future::never::Never; use std::marker::PhantomData; -use std::sync::atomic::{AtomicU64, Ordering}; +use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Arc; use std::task::{Context, Poll}; @@ -27,7 +27,7 @@ use tower::BoxError; #[derive(Debug)] pub struct NeverService { _resp: PhantomData<(Req, Resp, Err)>, - invocations: Arc, + invocations: Arc, } impl Clone for NeverService { @@ -55,7 +55,7 @@ impl NeverService { } /// Returns the number of invocations made to this service - pub fn num_calls(&self) -> u64 { + pub fn num_calls(&self) -> usize { self.invocations.load(Ordering::SeqCst) } } diff --git a/rust-runtime/aws-smithy-http-server-python/src/socket.rs b/rust-runtime/aws-smithy-http-server-python/src/socket.rs index 5922c5920db..df0e151078f 100644 --- a/rust-runtime/aws-smithy-http-server-python/src/socket.rs +++ b/rust-runtime/aws-smithy-http-server-python/src/socket.rs @@ -73,6 +73,14 @@ impl PySocket { } #[cfg(test)] +// `is_listener` on `Socket` is only available on certain platforms. +// In particular, this fails to compile on MacOS. +#[cfg(any( + target_os = "android", + target_os = "freebsd", + target_os = "fuchsia", + target_os = "linux", +))] mod tests { use super::*; diff --git a/rust-runtime/aws-smithy-http-server/examples/pokemon-service/src/lib.rs b/rust-runtime/aws-smithy-http-server/examples/pokemon-service/src/lib.rs index 93213f73bf5..b309d49cd8a 100644 --- a/rust-runtime/aws-smithy-http-server/examples/pokemon-service/src/lib.rs +++ b/rust-runtime/aws-smithy-http-server/examples/pokemon-service/src/lib.rs @@ -10,7 +10,7 @@ use std::{ collections::HashMap, convert::TryInto, - sync::{atomic::AtomicU64, Arc}, + sync::{atomic::AtomicUsize, Arc}, }; use async_stream::stream; @@ -108,7 +108,7 @@ struct PokemonTranslations { #[derive(Debug)] pub struct State { pokemons_translations: HashMap, - call_count: AtomicU64, + call_count: AtomicUsize, } impl Default for State {