Skip to content

Commit

Permalink
Merge branch 'master' into dp/chore/secp256k1-from-upstream
Browse files Browse the repository at this point in the history
* master:
  Add different mode for malloc_size_of_is_0 macro dealing with generics (#334)
  [parity-crypto] Use upstream secp256k1 (#258)
  Bump parking_lot to 0.10 and minor versions (#332)
  Remove libc completely (#333)
  • Loading branch information
dvdplm committed Feb 7, 2020
2 parents 1640391 + 11ad766 commit 472a3e9
Show file tree
Hide file tree
Showing 13 changed files with 111 additions and 49 deletions.
8 changes: 0 additions & 8 deletions fixed-hash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ pub extern crate alloc as alloc_;
#[doc(hidden)]
pub use core as core_;

#[cfg(all(feature = "libc", not(target_os = "unknown")))]
#[doc(hidden)]
pub use libc;

// This disables a warning for unused #[macro_use(..)]
// which is incorrect since the compiler does not check
// for all available configurations.
Expand All @@ -38,10 +34,6 @@ pub use static_assertions::const_assert;
#[doc(hidden)]
pub use byteorder;

#[cfg(not(feature = "libc"))]
#[doc(hidden)]
pub mod libc {}

#[cfg(feature = "rustc-hex")]
#[doc(hidden)]
pub use rustc_hex;
Expand Down
3 changes: 3 additions & 0 deletions kvdb-memorydb/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog].

## [Unreleased]

## [0.4.0] - 2019-02-05
- Bump parking_lot to 0.10. [#332](https://github.com/paritytech/parity-common/pull/332)

## [0.3.1] - 2019-01-06
- Updated features and feature dependencies. [#307](https://github.com/paritytech/parity-common/pull/307)

Expand Down
10 changes: 5 additions & 5 deletions kvdb-memorydb/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[package]
name = "kvdb-memorydb"
version = "0.3.1"
version = "0.4.0"
authors = ["Parity Technologies <[email protected]>"]
repository = "https://github.com/paritytech/parity-common"
description = "A key-value in-memory database that implements the `KeyValueDB` trait"
license = "GPL-3.0"
edition = "2018"

[dependencies]
parity-util-mem = { path = "../parity-util-mem", version = "0.4", default-features = false, features = ["std"] }
parking_lot = "0.9.0"
kvdb = { version = "0.3", path = "../kvdb" }
parity-util-mem = { path = "../parity-util-mem", version = "0.5", default-features = false, features = ["std"] }
parking_lot = "0.10.0"
kvdb = { version = "0.4", path = "../kvdb" }

[dev-dependencies]
kvdb-shared-tests = { path = "../kvdb-shared-tests", version = "0.1" }
kvdb-shared-tests = { path = "../kvdb-shared-tests", version = "0.2" }
3 changes: 3 additions & 0 deletions kvdb-rocksdb/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog].

## [Unreleased]

## [0.5.0] - 2019-02-05
- Bump parking_lot to 0.10. [#332](https://github.com/paritytech/parity-common/pull/332

## [0.4.2] - 2019-02-04
### Fixes
- Fixed `iter_from_prefix` being slow. [#326](https://github.com/paritytech/parity-common/pull/326)
Expand Down
10 changes: 5 additions & 5 deletions kvdb-rocksdb/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "kvdb-rocksdb"
version = "0.4.2"
version = "0.5.0"
authors = ["Parity Technologies <[email protected]>"]
repository = "https://github.com/paritytech/parity-common"
description = "kvdb implementation backed by RocksDB"
Expand All @@ -15,19 +15,19 @@ harness = false
smallvec = "1.0.0"
fs-swap = "0.2.4"
interleaved-ordered = "0.1.1"
kvdb = { path = "../kvdb", version = "0.3" }
kvdb = { path = "../kvdb", version = "0.4" }
log = "0.4.8"
num_cpus = "1.10.1"
parking_lot = "0.9.0"
parking_lot = "0.10.0"
regex = "1.3.1"
rocksdb = { version = "0.13", features = ["snappy"], default-features = false }
owning_ref = "0.4.0"
parity-util-mem = { path = "../parity-util-mem", version = "0.4", default-features = false, features = ["std", "smallvec"] }
parity-util-mem = { path = "../parity-util-mem", version = "0.5", default-features = false, features = ["std", "smallvec"] }

[dev-dependencies]
alloc_counter = "0.0.4"
criterion = "0.3"
ethereum-types = { path = "../ethereum-types" }
kvdb-shared-tests = { path = "../kvdb-shared-tests", version = "0.1" }
kvdb-shared-tests = { path = "../kvdb-shared-tests", version = "0.2" }
rand = "0.7.2"
tempdir = "0.3.7"
4 changes: 2 additions & 2 deletions kvdb-shared-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "kvdb-shared-tests"
version = "0.1.0"
version = "0.2.0"
authors = ["Parity Technologies <[email protected]>"]
edition = "2018"
description = "Shared tests for kvdb functionality, to be executed against actual implementations"
license = "GPL-3.0"

[dependencies]
kvdb = { path = "../kvdb", version = "0.3" }
kvdb = { path = "../kvdb", version = "0.4" }
3 changes: 3 additions & 0 deletions kvdb-web/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog].

## [Unreleased]

## [0.4.0] - 2019-02-05
- Bump parking_lot to 0.10. [#332](https://github.com/paritytech/parity-common/pull/332)

## [0.3.1] - 2019-01-06
- Updated features and feature dependencies. [#307](https://github.com/paritytech/parity-common/pull/307)

Expand Down
10 changes: 5 additions & 5 deletions kvdb-web/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "kvdb-web"
version = "0.3.1"
version = "0.4.0"
authors = ["Parity Technologies <[email protected]>"]
repository = "https://github.com/paritytech/parity-common"
description = "A key-value database for use in browsers"
Expand All @@ -11,12 +11,12 @@ edition = "2018"
[dependencies]
wasm-bindgen = "0.2.54"
js-sys = "0.3.31"
kvdb = { version = "0.3", path = "../kvdb" }
kvdb-memorydb = { version = "0.3", path = "../kvdb-memorydb" }
kvdb = { version = "0.4", path = "../kvdb" }
kvdb-memorydb = { version = "0.4", path = "../kvdb-memorydb" }
futures = "0.3"
log = "0.4.8"
send_wrapper = "0.3.0"
parity-util-mem = { path = "../parity-util-mem", version = "0.4", default-features = false }
parity-util-mem = { path = "../parity-util-mem", version = "0.5", default-features = false }

[dependencies.web-sys]
version = "0.3.31"
Expand All @@ -39,6 +39,6 @@ features = [

[dev-dependencies]
console_log = "0.1.2"
kvdb-shared-tests = { path = "../kvdb-shared-tests", version = "0.1" }
kvdb-shared-tests = { path = "../kvdb-shared-tests", version = "0.2" }
wasm-bindgen-test = "0.3.4"
wasm-bindgen-futures = "0.4.4"
3 changes: 3 additions & 0 deletions kvdb/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog].

## [Unreleased]

## [0.4.0] - 2019-01-06
- Bump parking_lot to 0.10. [#332](https://github.com/paritytech/parity-common/pull/332)

## [0.3.1] - 2019-01-06
- Updated features and feature dependencies. [#307](https://github.com/paritytech/parity-common/pull/307)

Expand Down
4 changes: 2 additions & 2 deletions kvdb/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "kvdb"
version = "0.3.1"
version = "0.4.0"
authors = ["Parity Technologies <[email protected]>"]
repository = "https://github.com/paritytech/parity-common"
description = "Generic key-value trait"
Expand All @@ -10,4 +10,4 @@ edition = "2018"
[dependencies]
smallvec = "1.0.0"
bytes = { package = "parity-bytes", version = "0.1", path = "../parity-bytes" }
parity-util-mem = { path = "../parity-util-mem", version = "0.4", default-features = false }
parity-util-mem = { path = "../parity-util-mem", version = "0.5", default-features = false }
6 changes: 6 additions & 0 deletions parity-util-mem/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog].

## [Unreleased]

## [0.5.1] - 2019-02-05
- Add different mode for malloc_size_of_is_0 macro dealing with generics #334. [#332](https://github.com/paritytech/parity-common/pull/334)

## [0.5.0] - 2019-02-05
- Bump parking_lot to 0.10. [#332](https://github.com/paritytech/parity-common/pull/332)

## [0.4.2] - 2020-02-04
- Implementation of `MallocSizeOf` for `BTreeSet`. [#325](https://github.com/paritytech/parity-common/pull/325)
- Split off implementation of `MallocSizeOf` for `primitive-types`. [#323](https://github.com/paritytech/parity-common/pull/323)
Expand Down
4 changes: 2 additions & 2 deletions parity-util-mem/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "parity-util-mem"
version = "0.4.2"
version = "0.5.1"
authors = ["Parity Technologies <[email protected]>"]
repository = "https://github.com/paritytech/parity-common"
description = "Collection of memory related utilities"
Expand All @@ -25,7 +25,7 @@ impl-trait-for-tuples = "0.1.3"

smallvec = { version = "1.0.0", optional = true }
ethereum-types = { version = "0.8.0", optional = true, path = "../ethereum-types" }
parking_lot = { version = "0.9.0", optional = true }
parking_lot = { version = "0.10.0", optional = true }
primitive-types = { version = "0.6", path = "../primitive-types", default-features = false, optional = true }

[target.'cfg(target_os = "windows")'.dependencies]
Expand Down
92 changes: 72 additions & 20 deletions parity-util-mem/src/malloc_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,28 +564,68 @@ impl<T: MallocSizeOf> MallocSizeOf for parking_lot::RwLock<T> {
}
}

/// Implement notion of 0 allocation size for some type(s).
///
/// if used for generics, by default it will require that generaic arguments
/// should implement `MallocSizeOf`. This can be avoided with passing "any: "
/// in front of type list.
///
/// ```rust
/// use parity_util_mem::{malloc_size, malloc_size_of_is_0};
///
/// struct Data<P> {
/// phantom: std::marker::PhantomData<P>,
/// }
///
/// malloc_size_of_is_0!(any: Data<P>);
///
/// // MallocSizeOf is NOT implemented for [u8; 333]
/// assert_eq!(malloc_size(&Data::<[u8; 333]> { phantom: std::marker::PhantomData }), 0);
/// ```
///
/// and when no "any: "
///
/// use parity_util_mem::{malloc_size, malloc_size_of_is_0};
///
/// struct Data<T> { pub T }
///
/// // generic argument (`T`) must be `impl MallocSizeOf`
/// malloc_size_of_is_0!(Data<u8>);
///
/// assert_eq!(malloc_size(&Data(0u8), 0);
/// ```
#[macro_export]
macro_rules! malloc_size_of_is_0(
($($ty:ty),+) => (
$(
impl $crate::MallocSizeOf for $ty {
#[inline(always)]
fn size_of(&self, _: &mut $crate::MallocSizeOfOps) -> usize {
0
}
}
)+
);
($($ty:ident<$($gen:ident),+>),+) => (
$(
impl<$($gen: $crate::MallocSizeOf),+> $crate::MallocSizeOf for $ty<$($gen),+> {
#[inline(always)]
fn size_of(&self, _: &mut $crate::MallocSizeOfOps) -> usize {
0
}
}
)+
);
($($ty:ty),+) => (
$(
impl $crate::MallocSizeOf for $ty {
#[inline(always)]
fn size_of(&self, _: &mut $crate::MallocSizeOfOps) -> usize {
0
}
}
)+
);
(any: $($ty:ident<$($gen:ident),+>),+) => (
$(
impl<$($gen),+> $crate::MallocSizeOf for $ty<$($gen),+> {
#[inline(always)]
fn size_of(&self, _: &mut $crate::MallocSizeOfOps) -> usize {
0
}
}
)+
);
($($ty:ident<$($gen:ident),+>),+) => (
$(
impl<$($gen: $crate::MallocSizeOf),+> $crate::MallocSizeOf for $ty<$($gen),+> {
#[inline(always)]
fn size_of(&self, _: &mut $crate::MallocSizeOfOps) -> usize {
0
}
}
)+
);
);

malloc_size_of_is_0!(bool, char, str);
Expand Down Expand Up @@ -763,4 +803,16 @@ mod tests {
// ~36 per value
assert!(crate::malloc_size(&set) > 3000);
}

#[test]
fn special_malloc_size_of_0() {
struct Data<P> {
phantom: std::marker::PhantomData<P>,
}

malloc_size_of_is_0!(any: Data<P>);

// MallocSizeOf is not implemented for [u8; 333]
assert_eq!(crate::malloc_size(&Data::<[u8; 333]> { phantom: std::marker::PhantomData }), 0);
}
}

0 comments on commit 472a3e9

Please sign in to comment.