diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-02-16 01:13:17 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-02-16 01:13:17 +0000 |
commit | 5bf0d095ee2adf2330a42d6dd638efae36c98291 (patch) | |
tree | b2f6376d7ac86207929c4a9b338b4313e06a8585 | |
parent | b9ce3fd360024e04bff9e8b3ad89f8bd5825e128 (diff) | |
parent | 746ceecf7cf7cd97801582f876a68ba474fe6e95 (diff) | |
download | crossbeam-epoch-5bf0d095ee2adf2330a42d6dd638efae36c98291.tar.gz |
Snap for 8188146 from 746ceecf7cf7cd97801582f876a68ba474fe6e95 to tm-frc-media-release
Change-Id: Ia8c0d4374b67da3a4670a00b32195b368f9ea95e
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | Android.bp | 72 | ||||
-rw-r--r-- | CHANGELOG.md | 11 | ||||
-rw-r--r-- | Cargo.lock | 39 | ||||
-rw-r--r-- | Cargo.toml | 6 | ||||
-rw-r--r-- | Cargo.toml.orig | 21 | ||||
-rw-r--r-- | METADATA | 8 | ||||
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | TEST_MAPPING | 24 | ||||
-rw-r--r-- | build.rs | 32 | ||||
-rw-r--r-- | cargo2android.json | 5 | ||||
-rw-r--r-- | no_atomic.rs | 59 | ||||
-rw-r--r-- | src/atomic.rs | 30 | ||||
-rw-r--r-- | src/lib.rs | 11 |
14 files changed, 118 insertions, 204 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 1f53d5d..1d9c34d 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "6d4cdd4daf9a897deef6cde9569f2fbf12c29bc5" + "sha1": "d841a2028dc72b4e09739116f07e865db60f3690" } } @@ -1,4 +1,4 @@ -// This file is generated by cargo2android.py --config cargo2android.json. +// This file is generated by cargo2android.py --run --device --dependencies --tests. // Do not modify this file as changes will be overridden on upgrade. package { @@ -39,18 +39,48 @@ license { ], } -rust_test { - name: "crossbeam-epoch_test_src_lib", - host_supported: true, +rust_defaults { + name: "crossbeam-epoch_defaults", 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", @@ -60,6 +90,7 @@ rust_test { ], rustlibs: [ "libcfg_if", + "libcrossbeam_epoch", "libcrossbeam_utils", "liblazy_static", "libmemoffset", @@ -68,12 +99,23 @@ rust_test { ], } +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: [ @@ -90,3 +132,17 @@ rust_library { "libscopeguard", ], } + +// dependent_library ["feature_list"] +// autocfg-1.0.1 +// cfg-if-1.0.0 +// crossbeam-utils-0.8.3 "lazy_static,std" +// getrandom-0.2.2 "std" +// lazy_static-1.4.0 +// libc-0.2.92 +// 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" +// rand_chacha-0.3.0 "std" +// rand_core-0.6.2 "alloc,getrandom,std" +// scopeguard-1.1.0 diff --git a/CHANGELOG.md b/CHANGELOG.md index c78fbf8..0f30b70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,14 +1,3 @@ -# Version 0.9.5 - -- Fix UB in `Pointable` impl of `[MaybeUninit<T>]` (#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<T>] 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) @@ -10,9 +10,9 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "cc" -version = "1.0.68" +version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787" +checksum = "e3c69b077ad434294d3ce9f1f6143a2a4b89a8a2d54ef813d85003a4fd1137fd" [[package]] name = "cfg-if" @@ -22,13 +22,13 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "const_fn" -version = "0.4.8" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f92cfa0fd5690b3cf8c1ef2cabbd9b7ef22fa53cf5e1f92b05103f6d5d1cf6e7" +checksum = "28b9d6de7f49e22cf97ad17fc4036ece69300032f45f78f30b4a4482cdc3f4a6" [[package]] name = "crossbeam-epoch" -version = "0.9.5" +version = "0.9.3" dependencies = [ "cfg-if", "const_fn", @@ -42,10 +42,11 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.5" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" +checksum = "e7e9d99fa91428effe99c5c6d4634cdeba32b8cf784fc428a2a687f61a952c49" dependencies = [ + "autocfg", "cfg-if", "lazy_static", "loom", @@ -53,9 +54,9 @@ dependencies = [ [[package]] name = "generator" -version = "0.7.0" +version = "0.6.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1d9279ca822891c1a4dae06d185612cf8fc6acfe5dff37781b41297811b12ee" +checksum = "a9fed24fd1e18827652b4d55652899a1e9da8e54d91624dc3437a5bc3a9f9a9c" dependencies = [ "cc", "libc", @@ -66,9 +67,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.3" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" +checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8" dependencies = [ "cfg-if", "libc", @@ -83,9 +84,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.95" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "789da6d93f1b866ffe175afc5322a4d76c038605a1c3319bb57b06967ca98a36" +checksum = "b7282d924be3275cec7f6756ff4121987bc6481325397dde6ba3e7802b1a8b1c" [[package]] name = "log" @@ -98,9 +99,9 @@ dependencies = [ [[package]] name = "loom" -version = "0.5.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7aa5348dc45fa5f2419b6dd4ea20345e6b01b1fcc9d176a322eada1ac3f382ba" +checksum = "d44c73b4636e497b4917eb21c33539efa3816741a2d3ff26c6316f1b529481a4" dependencies = [ "cfg-if", "generator", @@ -109,9 +110,9 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.6.4" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" +checksum = "157b4208e3059a8f9e78d559edc658e13df41410cb3ae03979c83130067fdd87" dependencies = [ "autocfg", ] @@ -164,9 +165,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.5" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61b3909d758bb75c79f23d4736fac9433868679d3ad2ea7a61e3c25cfda9a088" +checksum = "cb5d2a036dc6d2d8fd16fde3498b04306e29bd193bf306a57427019b823d5acd" [[package]] name = "scoped-tls" @@ -13,7 +13,7 @@ [package] edition = "2018" name = "crossbeam-epoch" -version = "0.9.5" +version = "0.9.3" 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.5" +version = "0.8.3" 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.5" +version = "0.4" optional = true package = "loom" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 939e346..8961f25 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.5" +version = "0.9.3" authors = ["The Crossbeam Project Developers"] edition = "2018" license = "MIT OR Apache-2.0" @@ -24,21 +24,18 @@ 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: 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. +# Note that this is outside of the normal semver guarantees and minor 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. # -# 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. +# This configuration option is outside of the normal semver guarantees: minor +# versions of crossbeam may make breaking changes to it at any time. loom = ["loom-crate", "crossbeam-utils/loom"] [dependencies] @@ -48,13 +45,13 @@ memoffset = "0.6" # Enable the use of loom for concurrency testing. # -# 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. +# 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.5", optional = true } +loom-crate = { package = "loom", version = "0.4", optional = true } [dependencies.crossbeam-utils] -version = "0.8.5" +version = "0.8.3" path = "../crossbeam-utils" default-features = false @@ -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.3.crate" } - version: "0.9.5" + version: "0.9.3" license_type: NOTICE last_upgrade_date { year: 2021 - month: 6 - day: 21 + month: 4 + day: 1 } } @@ -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.com/invite/JXYwgWZ) +[![chat](https://img.shields.io/discord/569610676205781012.svg?logo=discord)](https://discord.gg/BBYwKq) This crate provides epoch-based garbage collection for building concurrent data structures. diff --git a/TEST_MAPPING b/TEST_MAPPING index 161921c..25a9cdc 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -1,30 +1,8 @@ // Generated by update_crate_tests.py for tests that depend on this crate. { - "imports": [ - { - "path": "external/rust/crates/base64" - }, - { - "path": "external/rust/crates/crossbeam-deque" - }, - { - "path": "external/rust/crates/tinytemplate" - }, - { - "path": "external/rust/crates/tinyvec" - }, - { - "path": "external/rust/crates/unicode-xid" - } - ], "presubmit": [ { - "name": "crossbeam-epoch_test_src_lib" - } - ], - "presubmit-rust": [ - { - "name": "crossbeam-epoch_test_src_lib" + "name": "crossbeam-epoch_device_test_src_lib" } ] } diff --git a/build.rs b/build.rs deleted file mode 100644 index 4ef1279..0000000 --- a/build.rs +++ /dev/null @@ -1,32 +0,0 @@ -#![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/cargo2android.json b/cargo2android.json deleted file mode 100644 index d36fb44..0000000 --- a/cargo2android.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "device": true, - "run": true, - "tests": true -}
\ No newline at end of file diff --git a/no_atomic.rs b/no_atomic.rs deleted file mode 100644 index 522b3b8..0000000 --- a/no_atomic.rs +++ /dev/null @@ -1,59 +0,0 @@ -// 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 adb0afa..e4ca23f 100644 --- a/src/atomic.rs +++ b/src/atomic.rs @@ -238,8 +238,7 @@ impl<T> Pointable for T { // [`alloc::alloc::Layout::extend`] instead. #[repr(C)] struct Array<T> { - /// The number of elements (not the number of bytes). - len: usize, + size: usize, elements: [MaybeUninit<T>; 0], } @@ -248,31 +247,28 @@ impl<T> Pointable for [MaybeUninit<T>] { type Init = usize; - unsafe fn init(len: Self::Init) -> usize { - let size = mem::size_of::<Array<T>>() + mem::size_of::<MaybeUninit<T>>() * len; + unsafe fn init(size: Self::Init) -> usize { + let size = mem::size_of::<Array<T>>() + mem::size_of::<MaybeUninit<T>>() * size; let align = mem::align_of::<Array<T>>(); let layout = alloc::Layout::from_size_align(size, align).unwrap(); let ptr = alloc::alloc(layout) as *mut Array<T>; - if ptr.is_null() { - alloc::handle_alloc_error(layout); - } - (*ptr).len = len; + (*ptr).size = size; ptr as usize } unsafe fn deref<'a>(ptr: usize) -> &'a Self { let array = &*(ptr as *const Array<T>); - slice::from_raw_parts(array.elements.as_ptr() as *const _, array.len) + slice::from_raw_parts(array.elements.as_ptr() as *const _, array.size) } unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut Self { let array = &*(ptr as *mut Array<T>); - slice::from_raw_parts_mut(array.elements.as_ptr() as *mut _, array.len) + slice::from_raw_parts_mut(array.elements.as_ptr() as *mut _, array.size) } unsafe fn drop(ptr: usize) { let array = &*(ptr as *mut Array<T>); - let size = mem::size_of::<Array<T>>() + mem::size_of::<MaybeUninit<T>>() * array.len; + let size = mem::size_of::<Array<T>>() + mem::size_of::<MaybeUninit<T>>() * array.size; let align = mem::align_of::<Array<T>>(); let layout = alloc::Layout::from_size_align(size, align).unwrap(); alloc::dealloc(ptr as *mut u8, layout); @@ -1530,8 +1526,7 @@ impl<T: ?Sized + Pointable> Default for Shared<'_, T> { #[cfg(all(test, not(crossbeam_loom)))] mod tests { - use super::{Owned, Shared}; - use std::mem::MaybeUninit; + use super::Shared; #[test] fn valid_tag_i8() { @@ -1547,13 +1542,6 @@ mod tests { #[test] fn const_atomic_null() { use super::Atomic; - static _U: Atomic<u8> = Atomic::<u8>::null(); - } - - #[test] - fn array_init() { - let owned = Owned::<[MaybeUninit<usize>]>::init(10); - let arr: &[MaybeUninit<usize>] = &*owned; - assert_eq!(arr.len(), 10); + const _: Atomic<u8> = Atomic::<u8>::null(); } } @@ -62,7 +62,8 @@ unreachable_pub )] #![cfg_attr(not(feature = "std"), no_std)] -#![cfg_attr(feature = "nightly", feature(const_fn_trait_bound))] +#![cfg_attr(feature = "nightly", feature(cfg_target_has_atomic))] +#![cfg_attr(feature = "nightly", feature(const_fn))] #[cfg(crossbeam_loom)] extern crate loom_crate as loom; @@ -104,11 +105,10 @@ 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(feature = "alloc")] + #[cfg(any(feature = "alloc", feature = "std"))] pub(crate) mod cell { #[derive(Debug)] #[repr(transparent)] @@ -136,13 +136,14 @@ mod primitive { } } } - #[cfg(feature = "alloc")] + #[cfg(any(feature = "alloc", feature = "std"))] 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; } @@ -153,7 +154,7 @@ mod primitive { pub(crate) use lazy_static::lazy_static; } -#[cfg(not(crossbeam_no_atomic_cas))] +#[cfg_attr(feature = "nightly", cfg(target_has_atomic = "ptr"))] cfg_if! { if #[cfg(feature = "alloc")] { extern crate alloc; |