summaryrefslogtreecommitdiffstats
path: root/vendor/rand_xorshift
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
commit64d98f8ee037282c35007b64c2649055c56af1db (patch)
tree5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /vendor/rand_xorshift
parentAdding debian version 1.67.1+dfsg1-1. (diff)
downloadrustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz
rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/rand_xorshift')
-rw-r--r--vendor/rand_xorshift/.cargo-checksum.json2
-rw-r--r--vendor/rand_xorshift/CHANGELOG.md5
-rw-r--r--vendor/rand_xorshift/Cargo.toml20
-rw-r--r--vendor/rand_xorshift/README.md8
-rw-r--r--vendor/rand_xorshift/src/lib.rs32
5 files changed, 31 insertions, 36 deletions
diff --git a/vendor/rand_xorshift/.cargo-checksum.json b/vendor/rand_xorshift/.cargo-checksum.json
index 847a9b469..d23b0404a 100644
--- a/vendor/rand_xorshift/.cargo-checksum.json
+++ b/vendor/rand_xorshift/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"CHANGELOG.md":"427035c9349cf6111dbf842d0e09734876860c86bf6d36186f750cab3a2dff77","COPYRIGHT":"90eb64f0279b0d9432accfa6023ff803bc4965212383697eee27a0f426d5f8d5","Cargo.toml":"bf45abaf41b7ad05a769306380b763bd09ddff0fdc05a97302f01945835878ce","LICENSE-APACHE":"aaff376532ea30a0cd5330b9502ad4a4c8bf769c539c87ffe78819d188a18ebf","LICENSE-MIT":"209fbbe0ad52d9235e37badf9cadfe4dbdc87203179c0899e738b39ade42177b","README.md":"e06aa190aa69ee8d8ad61574feef8a30223518c561b53031e12c1da7bbc0f764","src/lib.rs":"f06ce7c72089045dcea39ad2aa3943b2d599522f54f25e245fa803227080a7f1","tests/mod.rs":"aaea1940ccb26ab48d4c404a94bc694a94b06b29f214a42b0f13b147f82b6fc5"},"package":"77d416b86801d23dde1aa643023b775c3a462efc0ed96443add11546cdf1dca8"} \ No newline at end of file
+{"files":{"CHANGELOG.md":"76d4654c4bf382be2e970861545722323436a9ea1c9a239c293e055a67a38109","COPYRIGHT":"90eb64f0279b0d9432accfa6023ff803bc4965212383697eee27a0f426d5f8d5","Cargo.toml":"8831fe280bfa28371000e6b6b4b65db57f904def97eee8c1ba3e9607db2571c8","LICENSE-APACHE":"aaff376532ea30a0cd5330b9502ad4a4c8bf769c539c87ffe78819d188a18ebf","LICENSE-MIT":"209fbbe0ad52d9235e37badf9cadfe4dbdc87203179c0899e738b39ade42177b","README.md":"66b98cefe946383e7e82c2ffeb89a28dc50ee0c09ae8d16c18f0b69e06dba92c","src/lib.rs":"b3737134f16ae788b130ae80a06400af79a3655b92ca8935efa5083959dc963b","tests/mod.rs":"aaea1940ccb26ab48d4c404a94bc694a94b06b29f214a42b0f13b147f82b6fc5"},"package":"d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f"} \ No newline at end of file
diff --git a/vendor/rand_xorshift/CHANGELOG.md b/vendor/rand_xorshift/CHANGELOG.md
index ce3098a16..52367bdb2 100644
--- a/vendor/rand_xorshift/CHANGELOG.md
+++ b/vendor/rand_xorshift/CHANGELOG.md
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [0.3.0] - 2020-12-18
+- Bump `rand_core` version to 0.6 (#17)
+- Derive PartialEq+Eq for XorShiftRng (#6)
+- Bump serde to 1.0.118 so that `serde1` feature can also be no-std (#12)
+
## [0.2.0] - 2019-06-12
- Bump minor crate version since rand_core bump is a breaking change
- Switch to Edition 2018
diff --git a/vendor/rand_xorshift/Cargo.toml b/vendor/rand_xorshift/Cargo.toml
index 0260d1315..335c5d1d0 100644
--- a/vendor/rand_xorshift/Cargo.toml
+++ b/vendor/rand_xorshift/Cargo.toml
@@ -13,30 +13,26 @@
[package]
edition = "2018"
name = "rand_xorshift"
-version = "0.2.0"
+version = "0.3.0"
authors = ["The Rand Project Developers", "The Rust Project Developers"]
description = "Xorshift random number generator\n"
-homepage = "https://crates.io/crates/rand_xorshift"
-documentation = "https://rust-random.github.io/rand/rand_xorshift/"
+homepage = "https://rust-random.github.io/book"
+documentation = "https://docs.rs/rand_xorshift"
readme = "README.md"
keywords = ["random", "rng", "xorshift"]
categories = ["algorithms", "no-std"]
-license = "MIT/Apache-2.0"
-repository = "https://github.com/rust-random/rand"
+license = "MIT OR Apache-2.0"
+repository = "https://github.com/rust-random/rngs"
[dependencies.rand_core]
-version = "0.5"
+version = "0.6"
[dependencies.serde]
-version = "1"
+version = "1.0.118"
features = ["derive"]
optional = true
+default-features = false
[dev-dependencies.bincode]
version = "1"
[features]
serde1 = ["serde"]
-[badges.appveyor]
-repository = "rust-random/rand"
-
-[badges.travis-ci]
-repository = "rust-random/rand"
diff --git a/vendor/rand_xorshift/README.md b/vendor/rand_xorshift/README.md
index 57de284be..df7fa33b8 100644
--- a/vendor/rand_xorshift/README.md
+++ b/vendor/rand_xorshift/README.md
@@ -1,12 +1,12 @@
# rand_xorshift
-[![Build Status](https://travis-ci.org/rust-random/rand.svg)](https://travis-ci.org/rust-random/rand)
-[![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-random/rand?svg=true)](https://ci.appveyor.com/project/rust-random/rand)
+[![Build Status](https://travis-ci.org/rust-random/rngs.svg)](https://travis-ci.org/rust-random/rngs)
+[![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-random/rngs?svg=true)](https://ci.appveyor.com/project/rust-random/rngs)
[![Latest version](https://img.shields.io/crates/v/rand_xorshift.svg)](https://crates.io/crates/rand_xorshift)
[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/)
[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand_xorshift)
[![API](https://docs.rs/rand_xorshift/badge.svg)](https://docs.rs/rand_xorshift)
-[![Minimum rustc version](https://img.shields.io/badge/rustc-1.32+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements)
+[![Minimum rustc version](https://img.shields.io/badge/rustc-1.32+-lightgray.svg)](https://github.com/rust-random/rngs#rust-version-requirements)
Implements the Xorshift random number generator.
@@ -22,7 +22,7 @@ Links:
- [API documentation (master)](https://rust-random.github.io/rand/rand_xorshift)
- [API documentation (docs.rs)](https://docs.rs/rand_xorshift)
-- [Changelog](https://github.com/rust-random/rand/blob/master/rand_xorshift/CHANGELOG.md)
+- [Changelog](https://github.com/rust-random/rngs/blob/master/rand_xorshift/CHANGELOG.md)
[rand]: https://crates.io/crates/rand
diff --git a/vendor/rand_xorshift/src/lib.rs b/vendor/rand_xorshift/src/lib.rs
index 769921fca..7fb59a482 100644
--- a/vendor/rand_xorshift/src/lib.rs
+++ b/vendor/rand_xorshift/src/lib.rs
@@ -10,7 +10,7 @@
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
html_favicon_url = "https://www.rust-lang.org/favicon.ico",
- html_root_url = "https://rust-random.github.io/rand/")]
+ html_root_url = "https://docs.rs/rand_xorshift/0.3.0")]
#![deny(missing_docs)]
#![deny(missing_debug_implementations)]
@@ -18,7 +18,7 @@
#![no_std]
use core::num::Wrapping as w;
-use core::{fmt, slice};
+use core::fmt;
use rand_core::{RngCore, SeedableRng, Error, impls, le};
#[cfg(feature="serde1")] use serde::{Serialize, Deserialize};
@@ -31,7 +31,7 @@ use rand_core::{RngCore, SeedableRng, Error, impls, le};
/// [^1]: Marsaglia, George (July 2003).
/// ["Xorshift RNGs"](https://www.jstatsoft.org/v08/i14/paper).
/// *Journal of Statistical Software*. Vol. 8 (Issue 14).
-#[derive(Clone)]
+#[derive(Clone, PartialEq, Eq)]
#[cfg_attr(feature="serde1", derive(Serialize,Deserialize))]
pub struct XorShiftRng {
x: w<u32>,
@@ -71,7 +71,8 @@ impl RngCore for XorShiftRng {
}
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
- Ok(self.fill_bytes(dest))
+ self.fill_bytes(dest);
+ Ok(())
}
}
@@ -98,26 +99,19 @@ impl SeedableRng for XorShiftRng {
}
fn from_rng<R: RngCore>(mut rng: R) -> Result<Self, Error> {
- let mut seed_u32 = [0u32; 4];
+ let mut b = [0u8; 16];
loop {
- unsafe {
- let ptr = seed_u32.as_mut_ptr() as *mut u8;
-
- let slice = slice::from_raw_parts_mut(ptr, 4 * 4);
- rng.try_fill_bytes(slice)?;
+ rng.try_fill_bytes(&mut b[..])?;
+ if !b.iter().all(|&x| x == 0) {
+ break;
}
- for v in seed_u32.iter_mut() {
- // enforce LE for consistency across platforms
- *v = v.to_le();
- }
- if !seed_u32.iter().all(|&x| x == 0) { break; }
}
Ok(XorShiftRng {
- x: w(seed_u32[0]),
- y: w(seed_u32[1]),
- z: w(seed_u32[2]),
- w: w(seed_u32[3]),
+ x: w(u32::from_le_bytes([b[0], b[1], b[2], b[3]])),
+ y: w(u32::from_le_bytes([b[4], b[5], b[6], b[7]])),
+ z: w(u32::from_le_bytes([b[8], b[9], b[10], b[11]])),
+ w: w(u32::from_le_bytes([b[12], b[13], b[14], b[15]])),
})
}
}