Skip to content

Commit 82e6387

Browse files
migrate from paste to preinterpret
Signed-off-by: BenjaminBrienen <[email protected]>
1 parent 5c5a9f7 commit 82e6387

File tree

8 files changed

+63
-55
lines changed

8 files changed

+63
-55
lines changed

Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
[workspace]
2-
members = ["jemallocator", "jemallocator-global", "jemalloc-ctl", "jemalloc-sys"]
2+
members = [
3+
"jemallocator",
4+
"jemallocator-global",
5+
"jemalloc-ctl",
6+
"jemalloc-sys",
7+
]

jemalloc-ctl/Cargo.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
name = "tikv-jemalloc-ctl"
33
version = "0.6.0"
44
authors = [
5-
"Steven Fackler <[email protected]>",
6-
"Gonzalo Brito Gadeschi <[email protected]>",
7-
"The TiKV Project Developers",
5+
"Steven Fackler <[email protected]>",
6+
"Gonzalo Brito Gadeschi <[email protected]>",
7+
"The TiKV Project Developers",
88
]
99
license = "MIT/Apache-2.0"
1010
readme = "README.md"
11-
categories = ["memory-management", "api-bindings", "development-tools" ]
11+
categories = ["memory-management", "api-bindings", "development-tools"]
1212
keywords = ["allocator", "jemalloc"]
1313
repository = "https://github.com/tikv/jemallocator"
1414
homepage = "https://github.com/tikv/jemallocator"
@@ -28,7 +28,7 @@ maintenance = { status = "actively-developed" }
2828
[dependencies]
2929
tikv-jemalloc-sys = { path = "../jemalloc-sys", version = "0.6.0" }
3030
libc = { version = "0.2", default-features = false }
31-
paste = "1"
31+
preinterpret = "0.2.0"
3232

3333
[dev-dependencies]
3434
tikv-jemallocator = { path = "../jemallocator", version = "0.6.0" }
@@ -37,9 +37,9 @@ tikv-jemallocator = { path = "../jemallocator", version = "0.6.0" }
3737
default = []
3838
stats = ["tikv-jemalloc-sys/stats"]
3939
profiling = ["tikv-jemalloc-sys/profiling"]
40-
use_std = [ "libc/use_std" ]
40+
use_std = ["libc/use_std"]
4141
disable_initial_exec_tls = ["tikv-jemalloc-sys/disable_initial_exec_tls"]
4242

4343
[package.metadata.docs.rs]
44-
rustdoc-args = [ "--cfg", "jemallocator_docs" ]
44+
rustdoc-args = ["--cfg", "jemallocator_docs"]
4545
features = ["stats", "profiling", "use_std"]

jemalloc-ctl/rustfmt.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
max_width = 79
1+
max_width = 79

jemalloc-ctl/src/macros.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ macro_rules! types {
55
docs: $(#[$doc:meta])*
66
mib_docs: $(#[$doc_mib:meta])*
77
) => {
8-
paste::paste! {
8+
preinterpret::preinterpret! {
99
$(#[$doc])*
1010
#[allow(non_camel_case_types)]
1111
pub struct $id;
@@ -22,8 +22,8 @@ macro_rules! types {
2222
/// Returns Management Information Base (MIB)
2323
///
2424
/// This value can be used to access the key without doing string lookup.
25-
pub fn mib() -> crate::error::Result<[<$id _mib>]> {
26-
Ok([<$id _mib>](Self::NAME.$name_to_mib()?))
25+
pub fn mib() -> crate::error::Result<[!ident! $id _mib]> {
26+
Ok([!ident! $id _mib](Self::NAME.$name_to_mib()?))
2727
}
2828

2929
/// Key [`crate::keys::Name`].
@@ -36,15 +36,15 @@ macro_rules! types {
3636
#[repr(transparent)]
3737
#[derive(Copy, Clone)]
3838
#[allow(non_camel_case_types)]
39-
pub struct [<$id _mib>](pub crate::keys::$mib);
39+
pub struct [!ident! $id _mib](pub crate::keys::$mib);
4040
}
4141
};
4242
}
4343

4444
/// Read
4545
macro_rules! r {
4646
($id:ident => $ret_ty:ty) => {
47-
paste::paste! {
47+
preinterpret::preinterpret! {
4848
impl $id {
4949
/// Reads value using string API.
5050
pub fn read() -> crate::error::Result<$ret_ty> {
@@ -53,7 +53,7 @@ macro_rules! r {
5353
}
5454
}
5555

56-
impl [<$id _mib>] {
56+
impl [!ident! $id _mib] {
5757
/// Reads value using MIB API.
5858
pub fn read(self) -> crate::error::Result<$ret_ty> {
5959
use crate::keys::Access;
@@ -64,7 +64,7 @@ macro_rules! r {
6464
#[cfg(test)]
6565
#[test]
6666
#[allow(unused)]
67-
fn [<$id _read_test>]() {
67+
fn [!ident! $id _read_test]() {
6868
match stringify!($id) {
6969
"background_thread" |
7070
"max_background_threads"
@@ -92,7 +92,7 @@ macro_rules! r {
9292
/// Write
9393
macro_rules! w {
9494
($id:ident => $ret_ty:ty) => {
95-
paste::paste! {
95+
preinterpret::preinterpret! {
9696
impl $id {
9797
/// Writes `value` using string API.
9898
pub fn write(value: $ret_ty) -> crate::error::Result<()> {
@@ -101,7 +101,7 @@ macro_rules! w {
101101
}
102102
}
103103

104-
impl [<$id _mib>] {
104+
impl [!ident! $id _mib] {
105105
/// Writes `value` using MIB API.
106106
pub fn write(self, value: $ret_ty) -> crate::error::Result<()> {
107107
use crate::keys::Access;
@@ -111,7 +111,7 @@ macro_rules! w {
111111

112112
#[cfg(test)]
113113
#[test]
114-
fn [<$id _write_test>]() {
114+
fn [!ident! $id _write_test]() {
115115
match stringify!($id) {
116116
"background_thread" |
117117
"max_background_threads"
@@ -140,7 +140,7 @@ macro_rules! w {
140140
/// Update
141141
macro_rules! u {
142142
($id:ident => $ret_ty:ty) => {
143-
paste::paste! {
143+
preinterpret::preinterpret! {
144144
impl $id {
145145
/// Updates key to `value` returning its old value using string API.
146146
pub fn update(value: $ret_ty) -> crate::error::Result<$ret_ty> {
@@ -149,7 +149,7 @@ macro_rules! u {
149149
}
150150
}
151151

152-
impl [<$id _mib>] {
152+
impl [!ident! $id _mib] {
153153
/// Updates key to `value` returning its old value using MIB API.
154154
pub fn update(self, value: $ret_ty) -> crate::error::Result<$ret_ty> {
155155
use crate::keys::Access;
@@ -160,7 +160,7 @@ macro_rules! u {
160160
#[cfg(test)]
161161
#[test]
162162
#[allow(unused)]
163-
fn [<$id _update_test>]() {
163+
fn [!ident! $id _update_test]() {
164164
match stringify!($id) {
165165
"background_thread" |
166166
"max_background_threads"

jemalloc-sys/Cargo.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
name = "tikv-jemalloc-sys"
33
version = "0.6.0+5.3.0-1-ge13ca993e8ccb9ba9847cc330696e02839f328f7"
44
authors = [
5-
"Alex Crichton <[email protected]>",
6-
"Gonzalo Brito Gadeschi <[email protected]>",
7-
"The TiKV Project Developers",
5+
"Alex Crichton <[email protected]>",
6+
"Gonzalo Brito Gadeschi <[email protected]>",
7+
"The TiKV Project Developers",
88
]
99
build = "build.rs"
1010
links = "jemalloc"
@@ -28,8 +28,8 @@ maintenance = { status = "actively-developed" }
2828

2929
[lints.rust]
3030
unexpected_cfgs = { level = "allow", check-cfg = [
31-
'cfg(jemallocator_docs)',
32-
'cfg(prefixed)',
31+
'cfg(jemallocator_docs)',
32+
'cfg(prefixed)',
3333
] }
3434

3535
[dependencies]
@@ -43,11 +43,11 @@ default = ["background_threads_runtime_support"]
4343
profiling = []
4444
debug = []
4545
background_threads_runtime_support = []
46-
background_threads = [ "background_threads_runtime_support" ]
46+
background_threads = ["background_threads_runtime_support"]
4747
stats = []
4848
unprefixed_malloc_on_supported_platforms = []
4949
disable_initial_exec_tls = []
5050
disable_cache_oblivious = []
5151

5252
[package.metadata.docs.rs]
53-
rustdoc-args = [ "--cfg", "jemallocator_docs" ]
53+
rustdoc-args = ["--cfg", "jemallocator_docs"]

jemallocator-global/Cargo.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ name = "tikv-jemallocator-global"
33
# Make sure to update the version in the readme as well:
44
version = "0.6.0"
55
authors = [
6-
"Gonzalo Brito Gadeschi <[email protected]>",
7-
"The TiKV Project Developers",
6+
"Gonzalo Brito Gadeschi <[email protected]>",
7+
"The TiKV Project Developers",
88
]
99
edition = "2018"
1010
license = "MIT/Apache-2.0"
@@ -32,7 +32,7 @@ cfg-if = "0.1"
3232
[features]
3333
default = []
3434
# Unconditionally sets jemalloc as the global allocator:
35-
force_global_jemalloc = [ "tikv-jemallocator" ]
35+
force_global_jemalloc = ["tikv-jemallocator"]
3636

3737
# To enable `jemalloc` as the `#[global_allocator]` by default
3838
# for a particular target, white-list the target explicitly here:
@@ -51,4 +51,3 @@ tikv-jemallocator = { version = "0.6.0", path = "../jemallocator", optional = fa
5151
# - fuchsia
5252
# - emscripten
5353
# - wasm32
54-

jemallocator/Cargo.toml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ name = "tikv-jemallocator"
33
# Make sure to update the version in the README as well:
44
version = "0.6.0"
55
authors = [
6-
"Alex Crichton <[email protected]>",
7-
"Gonzalo Brito Gadeschi <[email protected]>",
8-
"Simon Sapin <[email protected]>",
9-
"Steven Fackler <[email protected]>",
10-
"The TiKV Project Developers",
6+
"Alex Crichton <[email protected]>",
7+
"Gonzalo Brito Gadeschi <[email protected]>",
8+
"Simon Sapin <[email protected]>",
9+
"Steven Fackler <[email protected]>",
10+
"The TiKV Project Developers",
1111
]
1212
license = "MIT/Apache-2.0"
1313
readme = "README.md"
@@ -41,7 +41,7 @@ tikv-jemalloc-sys = { path = "../jemalloc-sys", version = "0.6.0", default-featu
4141
libc = { version = "^0.2.8", default-features = false }
4242

4343
[dev-dependencies]
44-
paste = "1"
44+
preinterpret = "0.2.0"
4545
tikv-jemalloc-ctl = { path = "../jemalloc-ctl", version = "0.6.0" }
4646

4747
[features]
@@ -50,12 +50,16 @@ alloc_trait = []
5050
profiling = ["tikv-jemalloc-sys/profiling"]
5151
debug = ["tikv-jemalloc-sys/debug"]
5252
stats = ["tikv-jemalloc-sys/stats"]
53-
background_threads_runtime_support = ["tikv-jemalloc-sys/background_threads_runtime_support"]
53+
background_threads_runtime_support = [
54+
"tikv-jemalloc-sys/background_threads_runtime_support",
55+
]
5456
background_threads = ["tikv-jemalloc-sys/background_threads"]
55-
unprefixed_malloc_on_supported_platforms = ["tikv-jemalloc-sys/unprefixed_malloc_on_supported_platforms"]
57+
unprefixed_malloc_on_supported_platforms = [
58+
"tikv-jemalloc-sys/unprefixed_malloc_on_supported_platforms",
59+
]
5660
disable_initial_exec_tls = ["tikv-jemalloc-sys/disable_initial_exec_tls"]
5761
disable_cache_oblivious = ["tikv-jemalloc-sys/disable_cache_oblivious"]
5862

5963
[package.metadata.docs.rs]
6064
features = []
61-
rustdoc-args = [ "--cfg", "jemallocator_docs" ]
65+
rustdoc-args = ["--cfg", "jemallocator_docs"]

jemallocator/benches/roundtrip.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ fn layout_to_flags(layout: &Layout) -> c_int {
4343

4444
macro_rules! rt {
4545
($size:expr, $align:expr) => {
46-
paste::paste! {
46+
preinterpret::preinterpret! {
4747
#[bench]
48-
fn [<rt_mallocx_size_ $size _align_ $align>](b: &mut Bencher) {
48+
fn [!ident! rt_mallocx_size_ $size _align_ $align](b: &mut Bencher) {
4949
b.iter(|| unsafe {
5050
use jemalloc_sys as jemalloc;
5151
let flags = layout_to_flags(&Layout::from_size_align($size, $align).unwrap());
@@ -56,7 +56,7 @@ macro_rules! rt {
5656
}
5757

5858
#[bench]
59-
fn [<rt_mallocx_nallocx_size_ $size _align_ $align>](b: &mut Bencher) {
59+
fn [!ident! rt_mallocx_nallocx_size_ $size _align_ $align](b: &mut Bencher) {
6060
b.iter(|| unsafe {
6161
use jemalloc_sys as jemalloc;
6262
let flags = layout_to_flags(&Layout::from_size_align($size, $align).unwrap());
@@ -69,7 +69,7 @@ macro_rules! rt {
6969
}
7070

7171
#[bench]
72-
fn [<rt_alloc_layout_checked_size_ $size _align_ $align>](b: &mut Bencher) {
72+
fn [!ident! rt_alloc_layout_checked_size_ $size _align_ $align](b: &mut Bencher) {
7373
b.iter(|| unsafe {
7474
let layout = Layout::from_size_align($size, $align).unwrap();
7575
let ptr = Jemalloc.alloc(layout.clone()).unwrap();
@@ -79,7 +79,7 @@ macro_rules! rt {
7979
}
8080

8181
#[bench]
82-
fn [<rt_alloc_layout_unchecked_size_ $size _align_ $align>](b: &mut Bencher) {
82+
fn [!ident! rt_alloc_layout_unchecked_size_ $size _align_ $align](b: &mut Bencher) {
8383
b.iter(|| unsafe {
8484
let layout = Layout::from_size_align_unchecked($size, $align);
8585
let ptr = Jemalloc.alloc(layout.clone()).unwrap();
@@ -89,7 +89,7 @@ macro_rules! rt {
8989
}
9090

9191
#[bench]
92-
fn [<rt_alloc_excess_unused_size_ $size _align_ $align>](b: &mut Bencher) {
92+
fn [!ident! rt_alloc_excess_unused_size_ $size _align_ $align](b: &mut Bencher) {
9393
b.iter(|| unsafe {
9494
let layout = Layout::from_size_align($size, $align).unwrap();
9595
let Excess(ptr, _) = Jemalloc.alloc_excess(layout.clone()).unwrap();
@@ -99,7 +99,7 @@ macro_rules! rt {
9999
}
100100

101101
#[bench]
102-
fn [<rt_alloc_excess_used_size_ $size _align_ $align>](b: &mut Bencher) {
102+
fn [!ident! rt_alloc_excess_used_size_ $size _align_ $align](b: &mut Bencher) {
103103
b.iter(|| unsafe {
104104
let layout = Layout::from_size_align($size, $align).unwrap();
105105
let Excess(ptr, excess) = Jemalloc.alloc_excess(layout.clone()).unwrap();
@@ -110,7 +110,7 @@ macro_rules! rt {
110110
}
111111

112112
#[bench]
113-
fn [<rt_mallocx_zeroed_size_ $size _align_ $align>](b: &mut Bencher) {
113+
fn [!ident! rt_mallocx_zeroed_size_ $size _align_ $align](b: &mut Bencher) {
114114
b.iter(|| unsafe {
115115
use jemalloc_sys as jemalloc;
116116
let flags = layout_to_flags(&Layout::from_size_align($size, $align).unwrap());
@@ -121,7 +121,7 @@ macro_rules! rt {
121121
}
122122

123123
#[bench]
124-
fn [<rt_calloc_size_ $size _align_ $align>](b: &mut Bencher) {
124+
fn [!ident! rt_calloc_size_ $size _align_ $align](b: &mut Bencher) {
125125
b.iter(|| unsafe {
126126
use jemalloc_sys as jemalloc;
127127
let flags = layout_to_flags(&Layout::from_size_align($size, $align).unwrap());
@@ -133,7 +133,7 @@ macro_rules! rt {
133133
}
134134

135135
#[bench]
136-
fn [<rt_realloc_naive_size_ $size _align_ $align>](b: &mut Bencher) {
136+
fn [!ident! rt_realloc_naive_size_ $size _align_ $align](b: &mut Bencher) {
137137
b.iter(|| unsafe {
138138
let layout = Layout::from_size_align($size, $align).unwrap();
139139
let ptr = Jemalloc.alloc(layout.clone()).unwrap();
@@ -154,7 +154,7 @@ macro_rules! rt {
154154
}
155155

156156
#[bench]
157-
fn [<rt_realloc_size_ $size _align_ $align>](b: &mut Bencher) {
157+
fn [!ident! rt_realloc_size_ $size _align_ $align](b: &mut Bencher) {
158158
b.iter(|| unsafe {
159159
let layout = Layout::from_size_align($size, $align).unwrap();
160160
let ptr = Jemalloc.alloc(layout.clone()).unwrap();
@@ -169,7 +169,7 @@ macro_rules! rt {
169169
}
170170

171171
#[bench]
172-
fn [<rt_realloc_excess_unused_size_ $size _align_ $align>](b: &mut Bencher) {
172+
fn [!ident! rt_realloc_excess_unused_size_ $size _align_ $align](b: &mut Bencher) {
173173
b.iter(|| unsafe {
174174
let layout = Layout::from_size_align($size, $align).unwrap();
175175
let ptr = Jemalloc.alloc(layout.clone()).unwrap();
@@ -186,7 +186,7 @@ macro_rules! rt {
186186
}
187187

188188
#[bench]
189-
fn [<rt_realloc_excess_used_size_ $size _align_ $align>](b: &mut Bencher) {
189+
fn [!ident! rt_realloc_excess_used_size_ $size _align_ $align](b: &mut Bencher) {
190190
b.iter(|| unsafe {
191191
let layout = Layout::from_size_align($size, $align).unwrap();
192192
let ptr = Jemalloc.alloc(layout.clone()).unwrap();

0 commit comments

Comments
 (0)