aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Galenson <jgalenson@google.com>2021-06-22 10:09:30 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-06-22 10:09:30 +0000
commit0a53ddbca8592035120a440df65178abd463979c (patch)
tree1809afbaea2a947fca5533176ca0c33509a47aaa
parent2244f872a59fb316a8f565fd470a68cec5f59d1c (diff)
parent6c485dc3767b3ba62465d66adf608dfb14f15a65 (diff)
downloadcrossbeam-epoch-0a53ddbca8592035120a440df65178abd463979c.tar.gz
Upgrade rust/crates/crossbeam-epoch to 0.9.5 am: 6c485dc376
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/crossbeam-epoch/+/1742593 Change-Id: I2050a0fd5547458424a35cb9895c8a7775b0ee9a
-rw-r--r--.cargo_vcs_info.json2
-rw-r--r--Android.bp14
-rw-r--r--CHANGELOG.md6
-rw-r--r--Cargo.lock31
-rw-r--r--Cargo.toml4
-rw-r--r--Cargo.toml.orig19
-rw-r--r--METADATA8
-rw-r--r--TEST_MAPPING6
-rw-r--r--build.rs32
-rw-r--r--no_atomic.rs59
-rw-r--r--src/atomic.rs27
-rw-r--r--src/lib.rs11
12 files changed, 166 insertions, 53 deletions
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<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)
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<T> Pointable for T {
// [`alloc::alloc::Layout::extend`] instead.
#[repr(C)]
struct Array<T> {
- size: usize,
+ /// The number of elements (not the number of bytes).
+ len: usize,
elements: [MaybeUninit<T>; 0],
}
@@ -247,31 +248,31 @@ impl<T> Pointable for [MaybeUninit<T>] {
type Init = usize;
- unsafe fn init(size: Self::Init) -> usize {
- let size = mem::size_of::<Array<T>>() + mem::size_of::<MaybeUninit<T>>() * size;
+ unsafe fn init(len: Self::Init) -> usize {
+ let size = mem::size_of::<Array<T>>() + mem::size_of::<MaybeUninit<T>>() * len;
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).size = size;
+ (*ptr).len = len;
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.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<T>);
- 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<T>);
- let size = mem::size_of::<Array<T>>() + mem::size_of::<MaybeUninit<T>>() * array.size;
+ let size = mem::size_of::<Array<T>>() + mem::size_of::<MaybeUninit<T>>() * array.len;
let align = mem::align_of::<Array<T>>();
let layout = alloc::Layout::from_size_align(size, align).unwrap();
alloc::dealloc(ptr as *mut u8, layout);
@@ -1529,7 +1530,8 @@ impl<T: ?Sized + Pointable> 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<u8> = Atomic::<u8>::null();
+ 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);
}
}
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;