From 08e1a7361c27dc72d40c10a32f1a6f13f3feb024 Mon Sep 17 00:00:00 2001 From: Joel Galenson Date: Wed, 19 May 2021 15:02:32 -0700 Subject: Upgrade rust/crates/crossbeam-epoch to 0.9.4 Test: make Change-Id: Ib2bff9fb19c1fba16b132fa6e133b18683047ab6 --- .cargo_vcs_info.json | 2 +- Android.bp | 4 ++-- CHANGELOG.md | 5 +++++ Cargo.lock | 26 +++++++++++++------------- Cargo.toml | 6 +++--- Cargo.toml.orig | 6 +++--- METADATA | 8 ++++---- README.md | 2 +- TEST_MAPPING | 3 +++ src/atomic.rs | 3 +++ 10 files changed, 38 insertions(+), 27 deletions(-) diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 1d9c34d..78aaf0a 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "d841a2028dc72b4e09739116f07e865db60f3690" + "sha1": "d4f6785c9be365832eecfc04222f95a1c2dd314a" } } diff --git a/Android.bp b/Android.bp index bba5b1e..1b525e5 100644 --- a/Android.bp +++ b/Android.bp @@ -136,10 +136,10 @@ rust_library { // dependent_library ["feature_list"] // autocfg-1.0.1 // cfg-if-1.0.0 -// crossbeam-utils-0.8.3 "lazy_static,std" +// crossbeam-utils-0.8.4 "lazy_static,std" // getrandom-0.2.2 "std" // lazy_static-1.4.0 -// libc-0.2.92 +// libc-0.2.94 // memoffset-0.6.3 "default" // ppv-lite86-0.2.10 "simd,std" // rand-0.8.3 "alloc,default,getrandom,libc,rand_chacha,rand_hc,std,std_rng" diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f30b70..861b059 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# Version 0.9.4 + +- Fix UB in `<[MaybeUninit] as Pointable>::init` when global allocator failed allocation (#690) +- Bump `loom` dependency to version 0.5. (#686) + # Version 0.9.3 - Make `loom` dependency optional. (#666) diff --git a/Cargo.lock b/Cargo.lock index fd37e90..d457e56 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -22,13 +22,13 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "const_fn" -version = "0.4.5" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b9d6de7f49e22cf97ad17fc4036ece69300032f45f78f30b4a4482cdc3f4a6" +checksum = "402da840495de3f976eaefc3485b7f5eb5b0bf9761f9a47be27fe975b3b8c2ec" [[package]] name = "crossbeam-epoch" -version = "0.9.3" +version = "0.9.4" dependencies = [ "cfg-if", "const_fn", @@ -42,9 +42,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7e9d99fa91428effe99c5c6d4634cdeba32b8cf784fc428a2a687f61a952c49" +checksum = "4feb231f0d4d6af81aed15928e58ecf5816aa62a2393e2c82f46973e92a9a278" dependencies = [ "autocfg", "cfg-if", @@ -54,9 +54,9 @@ dependencies = [ [[package]] name = "generator" -version = "0.6.24" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9fed24fd1e18827652b4d55652899a1e9da8e54d91624dc3437a5bc3a9f9a9c" +checksum = "c1d9279ca822891c1a4dae06d185612cf8fc6acfe5dff37781b41297811b12ee" dependencies = [ "cc", "libc", @@ -84,9 +84,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.86" +version = "0.2.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7282d924be3275cec7f6756ff4121987bc6481325397dde6ba3e7802b1a8b1c" +checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e" [[package]] name = "log" @@ -99,9 +99,9 @@ dependencies = [ [[package]] name = "loom" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d44c73b4636e497b4917eb21c33539efa3816741a2d3ff26c6316f1b529481a4" +checksum = "7aa5348dc45fa5f2419b6dd4ea20345e6b01b1fcc9d176a322eada1ac3f382ba" dependencies = [ "cfg-if", "generator", @@ -110,9 +110,9 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.6.1" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "157b4208e3059a8f9e78d559edc658e13df41410cb3ae03979c83130067fdd87" +checksum = "f83fb6581e8ed1f85fd45c116db8405483899489e38406156c25eb743554361d" dependencies = [ "autocfg", ] diff --git a/Cargo.toml b/Cargo.toml index 2d7eb00..3d78582 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ [package] edition = "2018" name = "crossbeam-epoch" -version = "0.9.3" +version = "0.9.4" authors = ["The Crossbeam Project Developers"] description = "Epoch-based garbage collection" homepage = "https://github.com/crossbeam-rs/crossbeam/tree/master/crossbeam-epoch" @@ -30,7 +30,7 @@ version = "0.4.4" optional = true [dependencies.crossbeam-utils] -version = "0.8.3" +version = "0.8.4" default-features = false [dependencies.lazy_static] @@ -53,6 +53,6 @@ loom = ["loom-crate", "crossbeam-utils/loom"] nightly = ["crossbeam-utils/nightly", "const_fn"] std = ["alloc", "crossbeam-utils/std", "lazy_static"] [target."cfg(crossbeam_loom)".dependencies.loom-crate] -version = "0.4" +version = "0.5" optional = true package = "loom" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 8961f25..de70ebb 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -4,7 +4,7 @@ name = "crossbeam-epoch" # - Update CHANGELOG.md # - Update README.md # - Create "crossbeam-epoch-X.Y.Z" git tag -version = "0.9.3" +version = "0.9.4" authors = ["The Crossbeam Project Developers"] edition = "2018" license = "MIT OR Apache-2.0" @@ -48,10 +48,10 @@ memoffset = "0.6" # This configuration option is outside of the normal semver guarantees: minor # versions of crossbeam may make breaking changes to it at any time. [target.'cfg(crossbeam_loom)'.dependencies] -loom-crate = { package = "loom", version = "0.4", optional = true } +loom-crate = { package = "loom", version = "0.5", optional = true } [dependencies.crossbeam-utils] -version = "0.8.3" +version = "0.8.4" path = "../crossbeam-utils" default-features = false diff --git a/METADATA b/METADATA index fc37c40..5588ef8 100644 --- a/METADATA +++ b/METADATA @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/crossbeam-epoch/crossbeam-epoch-0.9.3.crate" + value: "https://static.crates.io/crates/crossbeam-epoch/crossbeam-epoch-0.9.4.crate" } - version: "0.9.3" + version: "0.9.4" license_type: NOTICE last_upgrade_date { year: 2021 - month: 4 - day: 1 + month: 5 + day: 19 } } diff --git a/README.md b/README.md index c8ebd87..eb33bad 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ https://crates.io/crates/crossbeam-epoch) https://docs.rs/crossbeam-epoch) [![Rust 1.36+](https://img.shields.io/badge/rust-1.36+-lightgray.svg)]( https://www.rust-lang.org) -[![chat](https://img.shields.io/discord/569610676205781012.svg?logo=discord)](https://discord.gg/BBYwKq) +[![chat](https://img.shields.io/discord/569610676205781012.svg?logo=discord)](https://discord.com/invite/JXYwgWZ) This crate provides epoch-based garbage collection for building concurrent data structures. diff --git a/TEST_MAPPING b/TEST_MAPPING index 25a9cdc..9ca6a6c 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -3,6 +3,9 @@ "presubmit": [ { "name": "crossbeam-epoch_device_test_src_lib" + }, + { + "name": "crossbeam-epoch_device_test_tests_loom" } ] } diff --git a/src/atomic.rs b/src/atomic.rs index e4ca23f..75a4714 100644 --- a/src/atomic.rs +++ b/src/atomic.rs @@ -252,6 +252,9 @@ impl Pointable for [MaybeUninit] { let align = mem::align_of::>(); let layout = alloc::Layout::from_size_align(size, align).unwrap(); let ptr = alloc::alloc(layout) as *mut Array; + if ptr.is_null() { + alloc::handle_alloc_error(layout); + } (*ptr).size = size; ptr as usize } -- cgit v1.2.3 From 6c485dc3767b3ba62465d66adf608dfb14f15a65 Mon Sep 17 00:00:00 2001 From: Joel Galenson Date: Mon, 21 Jun 2021 12:20:39 -0700 Subject: Upgrade rust/crates/crossbeam-epoch to 0.9.5 Test: make Change-Id: I05fded55eeb4b47de7b95e882d12da6d0773bf6f --- .cargo_vcs_info.json | 2 +- Android.bp | 14 ++++++------- CHANGELOG.md | 6 ++++++ Cargo.lock | 31 +++++++++++++-------------- Cargo.toml | 4 ++-- Cargo.toml.orig | 19 ++++++++++------- METADATA | 8 +++---- TEST_MAPPING | 6 ++++++ build.rs | 32 ++++++++++++++++++++++++++++ no_atomic.rs | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/atomic.rs | 27 ++++++++++++++++-------- src/lib.rs | 11 +++++----- 12 files changed, 166 insertions(+), 53 deletions(-) create mode 100644 build.rs create mode 100644 no_atomic.rs diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 78aaf0a..1f53d5d 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "d4f6785c9be365832eecfc04222f95a1c2dd314a" + "sha1": "6d4cdd4daf9a897deef6cde9569f2fbf12c29bc5" } } diff --git a/Android.bp b/Android.bp index 1b525e5..72585fa 100644 --- a/Android.bp +++ b/Android.bp @@ -136,13 +136,13 @@ rust_library { // dependent_library ["feature_list"] // autocfg-1.0.1 // cfg-if-1.0.0 -// crossbeam-utils-0.8.4 "lazy_static,std" -// getrandom-0.2.2 "std" +// crossbeam-utils-0.8.5 "lazy_static,std" +// getrandom-0.2.3 "std" // lazy_static-1.4.0 -// libc-0.2.94 -// memoffset-0.6.3 "default" +// libc-0.2.97 +// memoffset-0.6.4 "default" // ppv-lite86-0.2.10 "simd,std" -// rand-0.8.3 "alloc,default,getrandom,libc,rand_chacha,rand_hc,std,std_rng" -// rand_chacha-0.3.0 "std" -// rand_core-0.6.2 "alloc,getrandom,std" +// rand-0.8.4 "alloc,default,getrandom,libc,rand_chacha,rand_hc,std,std_rng" +// rand_chacha-0.3.1 "std" +// rand_core-0.6.3 "alloc,getrandom,std" // scopeguard-1.1.0 diff --git a/CHANGELOG.md b/CHANGELOG.md index 861b059..c78fbf8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# Version 0.9.5 + +- Fix UB in `Pointable` impl of `[MaybeUninit]` (#694) +- Support targets that do not have atomic CAS on stable Rust (#698) +- Fix breakage with nightly feature due to rust-lang/rust#84510 (#692) + # Version 0.9.4 - Fix UB in `<[MaybeUninit] as Pointable>::init` when global allocator failed allocation (#690) diff --git a/Cargo.lock b/Cargo.lock index d457e56..596c26d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,9 +10,9 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "cc" -version = "1.0.67" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3c69b077ad434294d3ce9f1f6143a2a4b89a8a2d54ef813d85003a4fd1137fd" +checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787" [[package]] name = "cfg-if" @@ -22,13 +22,13 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "const_fn" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "402da840495de3f976eaefc3485b7f5eb5b0bf9761f9a47be27fe975b3b8c2ec" +checksum = "f92cfa0fd5690b3cf8c1ef2cabbd9b7ef22fa53cf5e1f92b05103f6d5d1cf6e7" [[package]] name = "crossbeam-epoch" -version = "0.9.4" +version = "0.9.5" dependencies = [ "cfg-if", "const_fn", @@ -42,11 +42,10 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4feb231f0d4d6af81aed15928e58ecf5816aa62a2393e2c82f46973e92a9a278" +checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" dependencies = [ - "autocfg", "cfg-if", "lazy_static", "loom", @@ -67,9 +66,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8" +checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" dependencies = [ "cfg-if", "libc", @@ -84,9 +83,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.94" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e" +checksum = "789da6d93f1b866ffe175afc5322a4d76c038605a1c3319bb57b06967ca98a36" [[package]] name = "log" @@ -110,9 +109,9 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83fb6581e8ed1f85fd45c116db8405483899489e38406156c25eb743554361d" +checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" dependencies = [ "autocfg", ] @@ -165,9 +164,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb5d2a036dc6d2d8fd16fde3498b04306e29bd193bf306a57427019b823d5acd" +checksum = "61b3909d758bb75c79f23d4736fac9433868679d3ad2ea7a61e3c25cfda9a088" [[package]] name = "scoped-tls" diff --git a/Cargo.toml b/Cargo.toml index 3d78582..97f3df3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ [package] edition = "2018" name = "crossbeam-epoch" -version = "0.9.4" +version = "0.9.5" authors = ["The Crossbeam Project Developers"] description = "Epoch-based garbage collection" homepage = "https://github.com/crossbeam-rs/crossbeam/tree/master/crossbeam-epoch" @@ -30,7 +30,7 @@ version = "0.4.4" optional = true [dependencies.crossbeam-utils] -version = "0.8.4" +version = "0.8.5" default-features = false [dependencies.lazy_static] diff --git a/Cargo.toml.orig b/Cargo.toml.orig index de70ebb..939e346 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -4,7 +4,7 @@ name = "crossbeam-epoch" # - Update CHANGELOG.md # - Update README.md # - Create "crossbeam-epoch-X.Y.Z" git tag -version = "0.9.4" +version = "0.9.5" authors = ["The Crossbeam Project Developers"] edition = "2018" license = "MIT OR Apache-2.0" @@ -24,18 +24,21 @@ std = ["alloc", "crossbeam-utils/std", "lazy_static"] # Enable to use APIs that require `alloc`. # This is enabled by default and also enabled if the `std` feature is enabled. +# +# NOTE: Disabling both `std` *and* `alloc` features is not supported yet. alloc = [] # Enable to use of unstable functionality. # This is disabled by default and requires recent nightly compiler. -# Note that this is outside of the normal semver guarantees and minor versions -# of crossbeam may make breaking changes to them at any time. +# +# NOTE: This feature is outside of the normal semver guarantees and minor or +# patch versions of crossbeam may make breaking changes to them at any time. nightly = ["crossbeam-utils/nightly", "const_fn"] # Enable the use of loom for concurrency testing. # -# This configuration option is outside of the normal semver guarantees: minor -# versions of crossbeam may make breaking changes to it at any time. +# NOTE: This feature is outside of the normal semver guarantees and minor or +# patch versions of crossbeam may make breaking changes to them at any time. loom = ["loom-crate", "crossbeam-utils/loom"] [dependencies] @@ -45,13 +48,13 @@ memoffset = "0.6" # Enable the use of loom for concurrency testing. # -# This configuration option is outside of the normal semver guarantees: minor -# versions of crossbeam may make breaking changes to it at any time. +# NOTE: This feature is outside of the normal semver guarantees and minor or +# patch versions of crossbeam may make breaking changes to them at any time. [target.'cfg(crossbeam_loom)'.dependencies] loom-crate = { package = "loom", version = "0.5", optional = true } [dependencies.crossbeam-utils] -version = "0.8.4" +version = "0.8.5" path = "../crossbeam-utils" default-features = false diff --git a/METADATA b/METADATA index 5588ef8..626ee8f 100644 --- a/METADATA +++ b/METADATA @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/crossbeam-epoch/crossbeam-epoch-0.9.4.crate" + value: "https://static.crates.io/crates/crossbeam-epoch/crossbeam-epoch-0.9.5.crate" } - version: "0.9.4" + version: "0.9.5" license_type: NOTICE last_upgrade_date { year: 2021 - month: 5 - day: 19 + month: 6 + day: 21 } } diff --git a/TEST_MAPPING b/TEST_MAPPING index 9ca6a6c..edda712 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -6,6 +6,12 @@ }, { "name": "crossbeam-epoch_device_test_tests_loom" + }, + { + "name": "unicode-xid_device_test_src_lib" + }, + { + "name": "unicode-xid_device_test_tests_exhaustive_tests" } ] } diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..4ef1279 --- /dev/null +++ b/build.rs @@ -0,0 +1,32 @@ +#![warn(rust_2018_idioms)] + +use std::env; + +include!("no_atomic.rs"); + +// The rustc-cfg strings below are *not* public API. Please let us know by +// opening a GitHub issue if your build environment requires some way to enable +// these cfgs other than by executing our build script. +fn main() { + let target = match env::var("TARGET") { + Ok(target) => target, + Err(e) => { + println!( + "cargo:warning={}: unable to get TARGET environment variable: {}", + env!("CARGO_PKG_NAME"), + e + ); + return; + } + }; + + // Note that this is `no_*`, not `has_*`. This allows treating + // `cfg(target_has_atomic = "ptr")` as true when the build script doesn't + // run. This is needed for compatibility with non-cargo build systems that + // don't run the build script. + if NO_ATOMIC_CAS.contains(&&*target) { + println!("cargo:rustc-cfg=crossbeam_no_atomic_cas"); + } + + println!("cargo:rerun-if-changed=no_atomic.rs"); +} diff --git a/no_atomic.rs b/no_atomic.rs new file mode 100644 index 0000000..522b3b8 --- /dev/null +++ b/no_atomic.rs @@ -0,0 +1,59 @@ +// This file is @generated by no_atomic.sh. +// It is not intended for manual editing. + +const NO_ATOMIC_CAS: &[&str] = &[ + "avr-unknown-gnu-atmega328", + "msp430-none-elf", + "riscv32i-unknown-none-elf", + "riscv32imc-unknown-none-elf", + "thumbv4t-none-eabi", + "thumbv6m-none-eabi", +]; +#[allow(dead_code)] +const NO_ATOMIC_64: &[&str] = &[ + "arm-linux-androideabi", + "armebv7r-none-eabi", + "armebv7r-none-eabihf", + "armv4t-unknown-linux-gnueabi", + "armv5te-unknown-linux-gnueabi", + "armv5te-unknown-linux-musleabi", + "armv5te-unknown-linux-uclibceabi", + "armv7r-none-eabi", + "armv7r-none-eabihf", + "hexagon-unknown-linux-musl", + "mips-unknown-linux-gnu", + "mips-unknown-linux-musl", + "mips-unknown-linux-uclibc", + "mipsel-unknown-linux-gnu", + "mipsel-unknown-linux-musl", + "mipsel-unknown-linux-uclibc", + "mipsel-unknown-none", + "mipsisa32r6-unknown-linux-gnu", + "mipsisa32r6el-unknown-linux-gnu", + "powerpc-unknown-linux-gnu", + "powerpc-unknown-linux-gnuspe", + "powerpc-unknown-linux-musl", + "powerpc-unknown-netbsd", + "powerpc-unknown-openbsd", + "powerpc-wrs-vxworks", + "powerpc-wrs-vxworks-spe", + "riscv32gc-unknown-linux-gnu", + "riscv32gc-unknown-linux-musl", + "riscv32imac-unknown-none-elf", + "thumbv7em-none-eabi", + "thumbv7em-none-eabihf", + "thumbv7m-none-eabi", + "thumbv8m.base-none-eabi", + "thumbv8m.main-none-eabi", + "thumbv8m.main-none-eabihf", + "mipsel-sony-psp", + "thumbv4t-none-eabi", + "thumbv6m-none-eabi", +]; +#[allow(dead_code)] +const NO_ATOMIC: &[&str] = &[ + "avr-unknown-gnu-atmega328", + "msp430-none-elf", + "riscv32i-unknown-none-elf", + "riscv32imc-unknown-none-elf", +]; diff --git a/src/atomic.rs b/src/atomic.rs index 75a4714..adb0afa 100644 --- a/src/atomic.rs +++ b/src/atomic.rs @@ -238,7 +238,8 @@ impl Pointable for T { // [`alloc::alloc::Layout::extend`] instead. #[repr(C)] struct Array { - size: usize, + /// The number of elements (not the number of bytes). + len: usize, elements: [MaybeUninit; 0], } @@ -247,31 +248,31 @@ impl Pointable for [MaybeUninit] { type Init = usize; - unsafe fn init(size: Self::Init) -> usize { - let size = mem::size_of::>() + mem::size_of::>() * size; + unsafe fn init(len: Self::Init) -> usize { + let size = mem::size_of::>() + mem::size_of::>() * len; let align = mem::align_of::>(); let layout = alloc::Layout::from_size_align(size, align).unwrap(); let ptr = alloc::alloc(layout) as *mut Array; if ptr.is_null() { alloc::handle_alloc_error(layout); } - (*ptr).size = size; + (*ptr).len = len; ptr as usize } unsafe fn deref<'a>(ptr: usize) -> &'a Self { let array = &*(ptr as *const Array); - slice::from_raw_parts(array.elements.as_ptr() as *const _, array.size) + slice::from_raw_parts(array.elements.as_ptr() as *const _, array.len) } unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut Self { let array = &*(ptr as *mut Array); - slice::from_raw_parts_mut(array.elements.as_ptr() as *mut _, array.size) + slice::from_raw_parts_mut(array.elements.as_ptr() as *mut _, array.len) } unsafe fn drop(ptr: usize) { let array = &*(ptr as *mut Array); - let size = mem::size_of::>() + mem::size_of::>() * array.size; + let size = mem::size_of::>() + mem::size_of::>() * array.len; let align = mem::align_of::>(); let layout = alloc::Layout::from_size_align(size, align).unwrap(); alloc::dealloc(ptr as *mut u8, layout); @@ -1529,7 +1530,8 @@ impl Default for Shared<'_, T> { #[cfg(all(test, not(crossbeam_loom)))] mod tests { - use super::Shared; + use super::{Owned, Shared}; + use std::mem::MaybeUninit; #[test] fn valid_tag_i8() { @@ -1545,6 +1547,13 @@ mod tests { #[test] fn const_atomic_null() { use super::Atomic; - const _: Atomic = Atomic::::null(); + static _U: Atomic = Atomic::::null(); + } + + #[test] + fn array_init() { + let owned = Owned::<[MaybeUninit]>::init(10); + let arr: &[MaybeUninit] = &*owned; + assert_eq!(arr.len(), 10); } } diff --git a/src/lib.rs b/src/lib.rs index 99da911..ba1d331 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -62,8 +62,7 @@ unreachable_pub )] #![cfg_attr(not(feature = "std"), no_std)] -#![cfg_attr(feature = "nightly", feature(cfg_target_has_atomic))] -#![cfg_attr(feature = "nightly", feature(const_fn))] +#![cfg_attr(feature = "nightly", feature(const_fn_trait_bound))] #[cfg(crossbeam_loom)] extern crate loom_crate as loom; @@ -105,10 +104,11 @@ mod primitive { pub(crate) use loom::lazy_static; pub(crate) use loom::thread_local; } +#[cfg(not(crossbeam_no_atomic_cas))] #[cfg(not(crossbeam_loom))] #[allow(unused_imports, dead_code)] mod primitive { - #[cfg(any(feature = "alloc", feature = "std"))] + #[cfg(feature = "alloc")] pub(crate) mod cell { #[derive(Debug)] #[repr(transparent)] @@ -136,14 +136,13 @@ mod primitive { } } } - #[cfg(any(feature = "alloc", feature = "std"))] + #[cfg(feature = "alloc")] pub(crate) mod sync { pub(crate) mod atomic { pub(crate) use core::sync::atomic::compiler_fence; pub(crate) use core::sync::atomic::fence; pub(crate) use core::sync::atomic::AtomicUsize; } - #[cfg_attr(feature = "nightly", cfg(target_has_atomic = "ptr"))] pub(crate) use alloc::sync::Arc; } @@ -154,7 +153,7 @@ mod primitive { pub(crate) use lazy_static::lazy_static; } -#[cfg_attr(feature = "nightly", cfg(target_has_atomic = "ptr"))] +#[cfg(not(crossbeam_no_atomic_cas))] cfg_if! { if #[cfg(feature = "alloc")] { extern crate alloc; -- cgit v1.2.3 From c4640400579f9af3be448154082c813d12550a70 Mon Sep 17 00:00:00 2001 From: Joel Galenson Date: Mon, 23 Aug 2021 09:13:17 -0700 Subject: Update TEST_MAPPING Test: None Change-Id: I6b881650e9ddb43fca63417c90d6cdb48b9fb10c --- TEST_MAPPING | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/TEST_MAPPING b/TEST_MAPPING index edda712..9f94cda 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -1,6 +1,15 @@ // Generated by update_crate_tests.py for tests that depend on this crate. { "presubmit": [ + { + "name": "base64_device_test_tests_decode" + }, + { + "name": "base64_device_test_tests_encode" + }, + { + "name": "base64_device_test_tests_helpers" + }, { "name": "crossbeam-epoch_device_test_src_lib" }, -- cgit v1.2.3 From 84f9711f7e548049a19da3fce5774b639398285f Mon Sep 17 00:00:00 2001 From: Joel Galenson Date: Mon, 29 Nov 2021 14:03:27 -0800 Subject: Refresh Android.bp, cargo2android.json, TEST_MAPPING. Test: None Change-Id: I15c7ff0b653f34a8f052e9524e477a42ce1fe81a --- Android.bp | 72 ++++++------------------------------------------------ TEST_MAPPING | 24 ++++++++++-------- cargo2android.json | 5 ++++ 3 files changed, 27 insertions(+), 74 deletions(-) create mode 100644 cargo2android.json diff --git a/Android.bp b/Android.bp index 72585fa..1ded857 100644 --- a/Android.bp +++ b/Android.bp @@ -1,4 +1,4 @@ -// This file is generated by cargo2android.py --run --device --dependencies --tests. +// This file is generated by cargo2android.py --config cargo2android.json. // Do not modify this file as changes will be overridden on upgrade. package { @@ -39,48 +39,18 @@ license { ], } -rust_defaults { - name: "crossbeam-epoch_defaults", +rust_test { + name: "crossbeam-epoch_test_src_lib", + host_supported: true, crate_name: "crossbeam_epoch", + cargo_env_compat: true, + cargo_pkg_version: "0.9.5", srcs: ["src/lib.rs"], test_suites: ["general-tests"], auto_gen_config: true, - edition: "2018", - features: [ - "alloc", - "default", - "lazy_static", - "std", - ], - rustlibs: [ - "libcfg_if", - "libcrossbeam_utils", - "liblazy_static", - "libmemoffset", - "librand", - "libscopeguard", - ], -} - -rust_test_host { - name: "crossbeam-epoch_host_test_src_lib", - defaults: ["crossbeam-epoch_defaults"], test_options: { unit_test: true, }, -} - -rust_test { - name: "crossbeam-epoch_device_test_src_lib", - defaults: ["crossbeam-epoch_defaults"], -} - -rust_defaults { - name: "crossbeam-epoch_defaults_loom", - crate_name: "loom", - srcs: ["tests/loom.rs"], - test_suites: ["general-tests"], - auto_gen_config: true, edition: "2018", features: [ "alloc", @@ -90,7 +60,6 @@ rust_defaults { ], rustlibs: [ "libcfg_if", - "libcrossbeam_epoch", "libcrossbeam_utils", "liblazy_static", "libmemoffset", @@ -99,23 +68,12 @@ rust_defaults { ], } -rust_test_host { - name: "crossbeam-epoch_host_test_tests_loom", - defaults: ["crossbeam-epoch_defaults_loom"], - test_options: { - unit_test: true, - }, -} - -rust_test { - name: "crossbeam-epoch_device_test_tests_loom", - defaults: ["crossbeam-epoch_defaults_loom"], -} - rust_library { name: "libcrossbeam_epoch", host_supported: true, crate_name: "crossbeam_epoch", + cargo_env_compat: true, + cargo_pkg_version: "0.9.5", srcs: ["src/lib.rs"], edition: "2018", features: [ @@ -132,17 +90,3 @@ rust_library { "libscopeguard", ], } - -// dependent_library ["feature_list"] -// autocfg-1.0.1 -// cfg-if-1.0.0 -// crossbeam-utils-0.8.5 "lazy_static,std" -// getrandom-0.2.3 "std" -// lazy_static-1.4.0 -// libc-0.2.97 -// memoffset-0.6.4 "default" -// ppv-lite86-0.2.10 "simd,std" -// rand-0.8.4 "alloc,default,getrandom,libc,rand_chacha,rand_hc,std,std_rng" -// rand_chacha-0.3.1 "std" -// rand_core-0.6.3 "alloc,getrandom,std" -// scopeguard-1.1.0 diff --git a/TEST_MAPPING b/TEST_MAPPING index 9f94cda..161921c 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -1,26 +1,30 @@ // Generated by update_crate_tests.py for tests that depend on this crate. { - "presubmit": [ + "imports": [ { - "name": "base64_device_test_tests_decode" + "path": "external/rust/crates/base64" }, { - "name": "base64_device_test_tests_encode" + "path": "external/rust/crates/crossbeam-deque" }, { - "name": "base64_device_test_tests_helpers" + "path": "external/rust/crates/tinytemplate" }, { - "name": "crossbeam-epoch_device_test_src_lib" + "path": "external/rust/crates/tinyvec" }, { - "name": "crossbeam-epoch_device_test_tests_loom" - }, + "path": "external/rust/crates/unicode-xid" + } + ], + "presubmit": [ { - "name": "unicode-xid_device_test_src_lib" - }, + "name": "crossbeam-epoch_test_src_lib" + } + ], + "presubmit-rust": [ { - "name": "unicode-xid_device_test_tests_exhaustive_tests" + "name": "crossbeam-epoch_test_src_lib" } ] } diff --git a/cargo2android.json b/cargo2android.json new file mode 100644 index 0000000..d36fb44 --- /dev/null +++ b/cargo2android.json @@ -0,0 +1,5 @@ +{ + "device": true, + "run": true, + "tests": true +} \ No newline at end of file -- cgit v1.2.3 From 15f97029e8026d95a01e2dcbcb4812b036487f04 Mon Sep 17 00:00:00 2001 From: David LeGare Date: Tue, 1 Mar 2022 19:01:24 +0000 Subject: Update crossbeam-epoch to 0.9.7 Test: cd external/rust/crates && atest --host -c Change-Id: I7783cc651d1c9a6db8ac08c4f425630bb9a3ac2b --- .cargo_vcs_info.json | 7 +- Android.bp | 4 +- CHANGELOG.md | 16 +++- Cargo.lock | 237 +++++++++++++++++++++++++++++++++++++++++++++------ Cargo.toml | 46 +++++++--- Cargo.toml.orig | 5 +- METADATA | 10 +-- benches/pin.rs | 2 +- build.rs | 15 +++- no_atomic.rs | 22 +++-- src/atomic.rs | 67 +++++++++++++-- src/collector.rs | 30 ++++++- src/deferred.rs | 11 +-- src/internal.rs | 6 +- src/sync/queue.rs | 7 +- 15 files changed, 398 insertions(+), 87 deletions(-) diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 1f53d5d..0a948d5 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,6 @@ { "git": { - "sha1": "6d4cdd4daf9a897deef6cde9569f2fbf12c29bc5" - } -} + "sha1": "2988f873f87d2263a7fd2b9465fb9c28f43a6490" + }, + "path_in_vcs": "crossbeam-epoch" +} \ No newline at end of file diff --git a/Android.bp b/Android.bp index 1ded857..bd3c978 100644 --- a/Android.bp +++ b/Android.bp @@ -44,7 +44,7 @@ rust_test { host_supported: true, crate_name: "crossbeam_epoch", cargo_env_compat: true, - cargo_pkg_version: "0.9.5", + cargo_pkg_version: "0.9.7", srcs: ["src/lib.rs"], test_suites: ["general-tests"], auto_gen_config: true, @@ -73,7 +73,7 @@ rust_library { host_supported: true, crate_name: "crossbeam_epoch", cargo_env_compat: true, - cargo_pkg_version: "0.9.5", + cargo_pkg_version: "0.9.7", srcs: ["src/lib.rs"], edition: "2018", features: [ diff --git a/CHANGELOG.md b/CHANGELOG.md index c78fbf8..8c158f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,20 @@ +# Version 0.9.7 + +- Fix Miri error when `-Zmiri-check-number-validity` is enabled. (#779) + +# Version 0.9.6 + +- Add `Atomic::fetch_update`. (#706) + # Version 0.9.5 -- Fix UB in `Pointable` impl of `[MaybeUninit]` (#694) -- Support targets that do not have atomic CAS on stable Rust (#698) -- Fix breakage with nightly feature due to rust-lang/rust#84510 (#692) +- Fix UB in `Pointable` impl of `[MaybeUninit]`. (#694) +- Support targets that do not have atomic CAS on stable Rust. (#698) +- Fix breakage with nightly feature due to rust-lang/rust#84510. (#692) # Version 0.9.4 -- Fix UB in `<[MaybeUninit] as Pointable>::init` when global allocator failed allocation (#690) +- Fix UB in `<[MaybeUninit] as Pointable>::init` when global allocator failed allocation. (#690) - Bump `loom` dependency to version 0.5. (#686) # Version 0.9.3 diff --git a/Cargo.lock b/Cargo.lock index 596c26d..ded699e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,15 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + [[package]] name = "autocfg" version = "1.0.1" @@ -10,9 +19,9 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "cc" -version = "1.0.68" +version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787" +checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" [[package]] name = "cfg-if" @@ -22,13 +31,13 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "const_fn" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f92cfa0fd5690b3cf8c1ef2cabbd9b7ef22fa53cf5e1f92b05103f6d5d1cf6e7" +checksum = "fbdcdcb6d86f71c5e97409ad45898af11cbc995b4ee8112d59095a28d376c935" [[package]] name = "crossbeam-epoch" -version = "0.9.5" +version = "0.9.7" dependencies = [ "cfg-if", "const_fn", @@ -42,9 +51,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.5" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" +checksum = "b5e5bed1f1c269533fa816a0a5492b3545209a205ca1a54842be180eb63a16a6" dependencies = [ "cfg-if", "lazy_static", @@ -66,9 +75,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" +checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c" dependencies = [ "cfg-if", "libc", @@ -83,9 +92,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.95" +version = "0.2.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "789da6d93f1b866ffe175afc5322a4d76c038605a1c3319bb57b06967ca98a36" +checksum = "e74d72e0f9b65b5b4ca49a346af3976df0f9c61d550727f349ecd559f251a26c" [[package]] name = "log" @@ -98,35 +107,76 @@ dependencies = [ [[package]] name = "loom" -version = "0.5.0" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7aa5348dc45fa5f2419b6dd4ea20345e6b01b1fcc9d176a322eada1ac3f382ba" +checksum = "edc5c7d328e32cc4954e8e01193d7f0ef5ab257b5090b70a964e099a36034309" dependencies = [ "cfg-if", "generator", "scoped-tls", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata", ] [[package]] name = "memoffset" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" dependencies = [ "autocfg", ] +[[package]] +name = "once_cell" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5" + +[[package]] +name = "pin-project-lite" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e280fbe77cc62c91527259e9442153f4688736748d24660126286329742b4c6c" + [[package]] name = "ppv-lite86" -version = "0.2.10" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" + +[[package]] +name = "proc-macro2" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" +checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145" +dependencies = [ + "proc-macro2", +] [[package]] name = "rand" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e" +checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8" dependencies = [ "libc", "rand_chacha", @@ -136,9 +186,9 @@ dependencies = [ [[package]] name = "rand_chacha" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", "rand_core", @@ -146,27 +196,51 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7" +checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" dependencies = [ "getrandom", ] [[package]] name = "rand_hc" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73" +checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7" dependencies = [ "rand_core", ] +[[package]] +name = "regex" +version = "1.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" +dependencies = [ + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" + [[package]] name = "rustversion" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61b3909d758bb75c79f23d4736fac9433868679d3ad2ea7a61e3c25cfda9a088" +checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" [[package]] name = "scoped-tls" @@ -180,6 +254,115 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "sharded-slab" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "smallvec" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" + +[[package]] +name = "syn" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "thread_local" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" +dependencies = [ + "once_cell", +] + +[[package]] +name = "tracing" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d8d93354fe2a8e50d5953f5ae2e47a3fc2ef03292e7ea46e3cc38f549525fb9" +dependencies = [ + "cfg-if", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8276d9a4a3a558d7b7ad5303ad50b53d58264641b82914b7ada36bd762e7a716" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03cfcb51380632a72d3111cb8d3447a8d908e577d31beeac006f836383d29a23" +dependencies = [ + "lazy_static", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6923477a48e41c1951f1999ef8bb5a3023eb723ceadafe78ffb65dc366761e3" +dependencies = [ + "lazy_static", + "log", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74786ce43333fcf51efe947aed9718fbe46d5c7328ec3f1029e818083966d9aa" +dependencies = [ + "ansi_term", + "lazy_static", + "matchers", + "regex", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", +] + +[[package]] +name = "unicode-xid" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" + +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + [[package]] name = "wasi" version = "0.10.2+wasi-snapshot-preview1" diff --git a/Cargo.toml b/Cargo.toml index 97f3df3..abacbe2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,25 +3,33 @@ # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies +# to registry (e.g., crates.io) dependencies. # -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. [package] edition = "2018" +rust-version = "1.36" name = "crossbeam-epoch" -version = "0.9.5" -authors = ["The Crossbeam Project Developers"] +version = "0.9.7" description = "Epoch-based garbage collection" homepage = "https://github.com/crossbeam-rs/crossbeam/tree/master/crossbeam-epoch" -documentation = "https://docs.rs/crossbeam-epoch" -keywords = ["lock-free", "rcu", "atomic", "garbage"] -categories = ["concurrency", "memory-management", "no-std"] +keywords = [ + "lock-free", + "rcu", + "atomic", + "garbage", +] +categories = [ + "concurrency", + "memory-management", + "no-std", +] license = "MIT OR Apache-2.0" repository = "https://github.com/crossbeam-rs/crossbeam" + [dependencies.cfg-if] version = "1" @@ -43,15 +51,27 @@ version = "0.6" [dependencies.scopeguard] version = "1.1.0" default-features = false + [dev-dependencies.rand] version = "0.8" [features] alloc = [] default = ["std"] -loom = ["loom-crate", "crossbeam-utils/loom"] -nightly = ["crossbeam-utils/nightly", "const_fn"] -std = ["alloc", "crossbeam-utils/std", "lazy_static"] +loom = [ + "loom-crate", + "crossbeam-utils/loom", +] +nightly = [ + "crossbeam-utils/nightly", + "const_fn", +] +std = [ + "alloc", + "crossbeam-utils/std", + "lazy_static", +] + [target."cfg(crossbeam_loom)".dependencies.loom-crate] version = "0.5" optional = true diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 939e346..bdb095a 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -4,13 +4,12 @@ name = "crossbeam-epoch" # - Update CHANGELOG.md # - Update README.md # - Create "crossbeam-epoch-X.Y.Z" git tag -version = "0.9.5" -authors = ["The Crossbeam Project Developers"] +version = "0.9.7" edition = "2018" +rust-version = "1.36" license = "MIT OR Apache-2.0" repository = "https://github.com/crossbeam-rs/crossbeam" homepage = "https://github.com/crossbeam-rs/crossbeam/tree/master/crossbeam-epoch" -documentation = "https://docs.rs/crossbeam-epoch" description = "Epoch-based garbage collection" keywords = ["lock-free", "rcu", "atomic", "garbage"] categories = ["concurrency", "memory-management", "no-std"] diff --git a/METADATA b/METADATA index 626ee8f..1377873 100644 --- a/METADATA +++ b/METADATA @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/crossbeam-epoch/crossbeam-epoch-0.9.5.crate" + value: "https://static.crates.io/crates/crossbeam-epoch/crossbeam-epoch-0.9.7.crate" } - version: "0.9.5" + version: "0.9.7" license_type: NOTICE last_upgrade_date { - year: 2021 - month: 6 - day: 21 + year: 2022 + month: 3 + day: 1 } } diff --git a/benches/pin.rs b/benches/pin.rs index 0dff4c5..8bf87e9 100644 --- a/benches/pin.rs +++ b/benches/pin.rs @@ -8,7 +8,7 @@ use test::Bencher; #[bench] fn single_pin(b: &mut Bencher) { - b.iter(|| epoch::pin()); + b.iter(epoch::pin); } #[bench] diff --git a/build.rs b/build.rs index 4ef1279..587e058 100644 --- a/build.rs +++ b/build.rs @@ -1,12 +1,21 @@ +// The rustc-cfg listed below are considered public API, but it is *unstable* +// and outside of the normal semver guarantees: +// +// - `crossbeam_no_atomic_cas` +// Assume the target does *not* support atomic CAS operations. +// This is usually detected automatically by the build script, but you may +// need to enable it manually when building for custom targets or using +// non-cargo build systems that don't run the build script. +// +// With the exceptions mentioned above, the rustc-cfg emitted by the build +// script are *not* public API. + #![warn(rust_2018_idioms)] use std::env; include!("no_atomic.rs"); -// The rustc-cfg strings below are *not* public API. Please let us know by -// opening a GitHub issue if your build environment requires some way to enable -// these cfgs other than by executing our build script. fn main() { let target = match env::var("TARGET") { Ok(target) => target, diff --git a/no_atomic.rs b/no_atomic.rs index 522b3b8..90ac60a 100644 --- a/no_atomic.rs +++ b/no_atomic.rs @@ -3,13 +3,16 @@ const NO_ATOMIC_CAS: &[&str] = &[ "avr-unknown-gnu-atmega328", + "bpfeb-unknown-none", + "bpfel-unknown-none", "msp430-none-elf", "riscv32i-unknown-none-elf", "riscv32imc-unknown-none-elf", "thumbv4t-none-eabi", "thumbv6m-none-eabi", ]; -#[allow(dead_code)] + +#[allow(dead_code)] // Only crossbeam-utils uses this. const NO_ATOMIC_64: &[&str] = &[ "arm-linux-androideabi", "armebv7r-none-eabi", @@ -18,18 +21,24 @@ const NO_ATOMIC_64: &[&str] = &[ "armv5te-unknown-linux-gnueabi", "armv5te-unknown-linux-musleabi", "armv5te-unknown-linux-uclibceabi", + "armv6k-nintendo-3ds", "armv7r-none-eabi", "armv7r-none-eabihf", + "avr-unknown-gnu-atmega328", "hexagon-unknown-linux-musl", + "m68k-unknown-linux-gnu", "mips-unknown-linux-gnu", "mips-unknown-linux-musl", "mips-unknown-linux-uclibc", + "mipsel-sony-psp", "mipsel-unknown-linux-gnu", "mipsel-unknown-linux-musl", "mipsel-unknown-linux-uclibc", "mipsel-unknown-none", "mipsisa32r6-unknown-linux-gnu", "mipsisa32r6el-unknown-linux-gnu", + "msp430-none-elf", + "powerpc-unknown-freebsd", "powerpc-unknown-linux-gnu", "powerpc-unknown-linux-gnuspe", "powerpc-unknown-linux-musl", @@ -39,18 +48,21 @@ const NO_ATOMIC_64: &[&str] = &[ "powerpc-wrs-vxworks-spe", "riscv32gc-unknown-linux-gnu", "riscv32gc-unknown-linux-musl", + "riscv32i-unknown-none-elf", "riscv32imac-unknown-none-elf", + "riscv32imc-esp-espidf", + "riscv32imc-unknown-none-elf", + "thumbv4t-none-eabi", + "thumbv6m-none-eabi", "thumbv7em-none-eabi", "thumbv7em-none-eabihf", "thumbv7m-none-eabi", "thumbv8m.base-none-eabi", "thumbv8m.main-none-eabi", "thumbv8m.main-none-eabihf", - "mipsel-sony-psp", - "thumbv4t-none-eabi", - "thumbv6m-none-eabi", ]; -#[allow(dead_code)] + +#[allow(dead_code)] // Only crossbeam-utils uses this. const NO_ATOMIC: &[&str] = &[ "avr-unknown-gnu-atmega328", "msp430-none-elf", diff --git a/src/atomic.rs b/src/atomic.rs index adb0afa..f727387 100644 --- a/src/atomic.rs +++ b/src/atomic.rs @@ -562,6 +562,65 @@ impl Atomic { }) } + /// Fetches the pointer, and then applies a function to it that returns a new value. + /// Returns a `Result` of `Ok(previous_value)` if the function returned `Some`, else `Err(_)`. + /// + /// Note that the given function may be called multiple times if the value has been changed by + /// other threads in the meantime, as long as the function returns `Some(_)`, but the function + /// will have been applied only once to the stored value. + /// + /// `fetch_update` takes two [`Ordering`] arguments to describe the memory + /// ordering of this operation. The first describes the required ordering for + /// when the operation finally succeeds while the second describes the + /// required ordering for loads. These correspond to the success and failure + /// orderings of [`Atomic::compare_exchange`] respectively. + /// + /// Using [`Acquire`] as success ordering makes the store part of this + /// operation [`Relaxed`], and using [`Release`] makes the final successful + /// load [`Relaxed`]. The (failed) load ordering can only be [`SeqCst`], + /// [`Acquire`] or [`Relaxed`] and must be equivalent to or weaker than the + /// success ordering. + /// + /// [`Relaxed`]: Ordering::Relaxed + /// [`Acquire`]: Ordering::Acquire + /// [`Release`]: Ordering::Release + /// [`SeqCst`]: Ordering::SeqCst + /// + /// # Examples + /// + /// ``` + /// use crossbeam_epoch::{self as epoch, Atomic}; + /// use std::sync::atomic::Ordering::SeqCst; + /// + /// let a = Atomic::new(1234); + /// let guard = &epoch::pin(); + /// + /// let res1 = a.fetch_update(SeqCst, SeqCst, guard, |x| Some(x.with_tag(1))); + /// assert!(res1.is_ok()); + /// + /// let res2 = a.fetch_update(SeqCst, SeqCst, guard, |x| None); + /// assert!(res2.is_err()); + /// ``` + pub fn fetch_update<'g, F>( + &self, + set_order: Ordering, + fail_order: Ordering, + guard: &'g Guard, + mut func: F, + ) -> Result, Shared<'g, T>> + where + F: FnMut(Shared<'g, T>) -> Option>, + { + let mut prev = self.load(fail_order, guard); + while let Some(next) = func(prev) { + match self.compare_exchange_weak(prev, next, set_order, fail_order, guard) { + Ok(shared) => return Ok(shared), + Err(next_prev) => prev = next_prev.current, + } + } + Err(prev) + } + /// Stores the pointer `new` (either `Shared` or `Owned`) into the atomic pointer if the current /// value is the same as `current`. The tag is also taken into account, so two pointers to the /// same object, but with different tags, will not be considered equal. @@ -1225,7 +1284,6 @@ impl<'g, T> Shared<'g, T> { /// let p = a.load(SeqCst, guard); /// assert_eq!(p.as_raw(), raw); /// ``` - #[allow(clippy::trivially_copy_pass_by_ref)] pub fn as_raw(&self) -> *const T { let (raw, _) = decompose_tag::(self.data); raw as *const _ @@ -1264,7 +1322,6 @@ impl<'g, T: ?Sized + Pointable> Shared<'g, T> { /// a.store(Owned::new(1234), SeqCst); /// assert!(!a.load(SeqCst, guard).is_null()); /// ``` - #[allow(clippy::trivially_copy_pass_by_ref)] pub fn is_null(&self) -> bool { let (raw, _) = decompose_tag::(self.data); raw == 0 @@ -1301,8 +1358,6 @@ impl<'g, T: ?Sized + Pointable> Shared<'g, T> { /// assert_eq!(p.deref(), &1234); /// } /// ``` - #[allow(clippy::trivially_copy_pass_by_ref)] - #[allow(clippy::should_implement_trait)] pub unsafe fn deref(&self) -> &'g T { let (raw, _) = decompose_tag::(self.data); T::deref(raw) @@ -1344,7 +1399,6 @@ impl<'g, T: ?Sized + Pointable> Shared<'g, T> { /// assert_eq!(p.deref(), &vec![1, 2, 3, 4, 5]); /// } /// ``` - #[allow(clippy::should_implement_trait)] pub unsafe fn deref_mut(&mut self) -> &'g mut T { let (raw, _) = decompose_tag::(self.data); T::deref_mut(raw) @@ -1381,7 +1435,6 @@ impl<'g, T: ?Sized + Pointable> Shared<'g, T> { /// assert_eq!(p.as_ref(), Some(&1234)); /// } /// ``` - #[allow(clippy::trivially_copy_pass_by_ref)] pub unsafe fn as_ref(&self) -> Option<&'g T> { let (raw, _) = decompose_tag::(self.data); if raw == 0 { @@ -1433,7 +1486,6 @@ impl<'g, T: ?Sized + Pointable> Shared<'g, T> { /// let p = a.load(SeqCst, guard); /// assert_eq!(p.tag(), 2); /// ``` - #[allow(clippy::trivially_copy_pass_by_ref)] pub fn tag(&self) -> usize { let (_, tag) = decompose_tag::(self.data); tag @@ -1457,7 +1509,6 @@ impl<'g, T: ?Sized + Pointable> Shared<'g, T> { /// assert_eq!(p2.tag(), 2); /// assert_eq!(p1.as_raw(), p2.as_raw()); /// ``` - #[allow(clippy::trivially_copy_pass_by_ref)] pub fn with_tag(&self, tag: usize) -> Shared<'g, T> { unsafe { Self::from_usize(compose_tag::(self.data, tag)) } } diff --git a/src/collector.rs b/src/collector.rs index 7cfb819..099a2ff 100644 --- a/src/collector.rs +++ b/src/collector.rs @@ -178,13 +178,18 @@ mod tests { #[test] fn pin_holds_advance() { + #[cfg(miri)] + const N: usize = 500; + #[cfg(not(miri))] + const N: usize = 500_000; + let collector = Collector::new(); thread::scope(|scope| { for _ in 0..NUM_THREADS { scope.spawn(|_| { let handle = collector.register(); - for _ in 0..500_000 { + for _ in 0..N { let guard = &handle.pin(); let before = collector.global.epoch.load(Ordering::Relaxed); @@ -202,6 +207,9 @@ mod tests { #[cfg(not(crossbeam_sanitize))] // TODO: assertions failed due to `cfg(crossbeam_sanitize)` reduce `internal::MAX_OBJECTS` #[test] fn incremental() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 100_000; static DESTROYS: AtomicUsize = AtomicUsize::new(0); @@ -230,12 +238,16 @@ mod tests { let guard = &handle.pin(); collector.global.collect(guard); } - assert!(DESTROYS.load(Ordering::Relaxed) == 100_000); + assert!(DESTROYS.load(Ordering::Relaxed) == COUNT); } #[test] fn buffering() { const COUNT: usize = 10; + #[cfg(miri)] + const N: usize = 500; + #[cfg(not(miri))] + const N: usize = 100_000; static DESTROYS: AtomicUsize = AtomicUsize::new(0); let collector = Collector::new(); @@ -252,7 +264,7 @@ mod tests { } } - for _ in 0..100_000 { + for _ in 0..N { collector.global.collect(&handle.pin()); } assert!(DESTROYS.load(Ordering::Relaxed) < COUNT); @@ -268,6 +280,9 @@ mod tests { #[test] fn count_drops() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 100_000; static DROPS: AtomicUsize = AtomicUsize::new(0); @@ -301,6 +316,9 @@ mod tests { #[test] fn count_destroy() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 100_000; static DESTROYS: AtomicUsize = AtomicUsize::new(0); @@ -367,6 +385,9 @@ mod tests { #[test] fn destroy_array() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 100_000; static DESTROYS: AtomicUsize = AtomicUsize::new(0); @@ -402,6 +423,9 @@ mod tests { #[test] fn stress() { const THREADS: usize = 8; + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 100_000; static DROPS: AtomicUsize = AtomicUsize::new(0); diff --git a/src/deferred.rs b/src/deferred.rs index d953c46..c33d515 100644 --- a/src/deferred.rs +++ b/src/deferred.rs @@ -18,7 +18,7 @@ type Data = [usize; DATA_WORDS]; /// This is a handy way of keeping an unsized `FnOnce()` within a sized structure. pub(crate) struct Deferred { call: unsafe fn(*mut u8), - data: Data, + data: MaybeUninit, _marker: PhantomData<*mut ()>, // !Send + !Sync } @@ -46,7 +46,7 @@ impl Deferred { Deferred { call: call::, - data: data.assume_init(), + data, _marker: PhantomData, } } else { @@ -57,14 +57,13 @@ impl Deferred { unsafe fn call(raw: *mut u8) { // It's safe to cast `raw` from `*mut u8` to `*mut Box`, because `raw` is // originally derived from `*mut Box`. - #[allow(clippy::cast_ptr_alignment)] let b: Box = ptr::read(raw as *mut Box); (*b)(); } Deferred { call: call::, - data: data.assume_init(), + data, _marker: PhantomData, } } @@ -75,12 +74,14 @@ impl Deferred { #[inline] pub(crate) fn call(mut self) { let call = self.call; - unsafe { call(&mut self.data as *mut Data as *mut u8) }; + unsafe { call(self.data.as_mut_ptr() as *mut u8) }; } } #[cfg(all(test, not(crossbeam_loom)))] mod tests { + #![allow(clippy::drop_copy)] + use super::Deferred; use std::cell::Cell; diff --git a/src/internal.rs b/src/internal.rs index 966bceb..de208b1 100644 --- a/src/internal.rs +++ b/src/internal.rs @@ -101,7 +101,7 @@ impl Bag { /// Seals the bag with the given epoch. fn seal(self, epoch: Epoch) -> SealedBag { - SealedBag { epoch, bag: self } + SealedBag { epoch, _bag: self } } } @@ -216,7 +216,7 @@ fn no_op_func() {} #[derive(Default, Debug)] struct SealedBag { epoch: Epoch, - bag: Bag, + _bag: Bag, } /// It is safe to share `SealedBag` because `is_expired` only inspects the epoch. @@ -311,7 +311,7 @@ impl Global { // TODO(stjepang): `Local`s are stored in a linked list because linked lists are fairly // easy to implement in a lock-free manner. However, traversal can be slow due to cache // misses and data dependencies. We should experiment with other data structures as well. - for local in self.locals.iter(&guard) { + for local in self.locals.iter(guard) { match local { Err(IterError::Stalled) => { // A concurrent thread stalled this iteration. That thread might also try to diff --git a/src/sync/queue.rs b/src/sync/queue.rs index 67c228d..9500438 100644 --- a/src/sync/queue.rs +++ b/src/sync/queue.rs @@ -259,6 +259,9 @@ mod test { } } + #[cfg(miri)] + const CONC_COUNT: i64 = 1000; + #[cfg(not(miri))] const CONC_COUNT: i64 = 1000000; #[test] @@ -422,8 +425,8 @@ mod test { let mut vl2 = vl.clone(); let mut vr2 = vr.clone(); - vl2.sort(); - vr2.sort(); + vl2.sort_unstable(); + vr2.sort_unstable(); assert_eq!(vl, vl2); assert_eq!(vr, vr2); -- cgit v1.2.3