Skip to content

Commit

Permalink
Merge pull request #724 from dhardy/master
Browse files Browse the repository at this point in the history
Tune platform-specific crate dependencies
  • Loading branch information
dhardy committed Feb 6, 2019
2 parents 734811a + 4ca5ee3 commit 9d70d8c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -9,6 +9,10 @@ A [separate changelog is kept for rand_core](rand_core/CHANGELOG.md).
You may also find the [Upgrade Guide](https://rust-random.github.io/book/update.html) useful.


## Unreleased
- Enable fork protection of ReseedingRng without `std`
- Remove dependency on `winapi`

## [0.6.5] - 2019-01-28
### Crates
- Update `rand_core` to 0.4 (#703)
Expand Down
5 changes: 1 addition & 4 deletions Cargo.toml
Expand Up @@ -65,12 +65,9 @@ optional = true
features = ["into_bits"]

[target.'cfg(unix)'.dependencies]
# Used for fork protection (reseeding.rs)
libc = { version = "0.2", default-features = false }

# TODO: check if all features are required
[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", features = ["minwindef", "ntsecapi", "profileapi", "winnt"] }

[dev-dependencies]
# This has a histogram implementation used for testing uniformity.
average = "0.9.2"
Expand Down
3 changes: 3 additions & 0 deletions rand_jitter/CHANGELOG.md
Expand Up @@ -4,6 +4,9 @@ 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.1.3] - 2019-02-05
- Use libc in `no_std` mode to fix #723

## [0.1.2] - 2019-01-31
- Fix for older rustc compilers on Windows (#722)

Expand Down
6 changes: 4 additions & 2 deletions rand_jitter/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "rand_jitter"
version = "0.1.2"
version = "0.1.3"
authors = ["The Rand Project Developers"]
license = "MIT/Apache-2.0"
readme = "README.md"
Expand All @@ -18,7 +18,9 @@ rand_core = { path = "../rand_core", version = "0.4" }
log = { version = "0.4", optional = true }

[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies]
libc = "0.2"
# We don't need the 'use_std' feature and depending on it causes
# issues due to: https://github.com/rust-lang/cargo/issues/1197
libc = { version = "0.2", default_features = false }

[target.'cfg(target_os = "windows")'.dependencies]
winapi = { version = "0.3", features = ["profileapi"] }
Expand Down
8 changes: 4 additions & 4 deletions src/rngs/adapter/reseeding.rs
Expand Up @@ -282,12 +282,12 @@ where R: BlockRngCore + SeedableRng + CryptoRng,
Rsdr: RngCore + CryptoRng {}


#[cfg(all(feature="std", unix, not(target_os="emscripten")))]
#[cfg(all(unix, not(target_os="emscripten")))]
mod fork {
extern crate libc;

use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT};
use core::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
use core::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT};

// Fork protection
//
Expand Down Expand Up @@ -323,7 +323,7 @@ mod fork {
}
}

#[cfg(not(all(feature="std", unix, not(target_os="emscripten"))))]
#[cfg(not(all(unix, not(target_os="emscripten"))))]
mod fork {
pub fn get_fork_counter() -> usize { 0 }
pub fn register_fork_handler() {}
Expand Down

0 comments on commit 9d70d8c

Please sign in to comment.