commit_hash
stringlengths
40
40
author
stringlengths
1
57
date
timestamp[s]date
2010-07-26 04:45:09
2026-04-14 18:21:10
message
stringlengths
8
1.39M
diff
stringlengths
68
51.2k
files_changed
int64
1
136
insertions
int64
0
2.35k
deletions
int64
0
1.9k
78d09642517b725ba8a62d5e83026da84d8dbcb4
Wim Looman
2019-05-03T11:26:23
Add tests for writing chunks that should be >8k when compressed
diff --git a/Cargo.toml b/Cargo.toml index 0ae108c..bd52da8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,3 +11,6 @@ bytes = "0.4.12" flate2 = "1.0.7" futures-preview = "0.3.0-alpha.15" pin-project = "0.3.2" + +[dev-dependencies] +rand = "0.6.5" diff --git a/tests/brotli.rs b/tests/brotli.rs index 22908c9..fc8e0e9...
5
114
0
ddc1f64028471ab9e48614adaf3d30324e9060e2
Wim Looman
2019-05-03T11:16:29
Fix writing large final chunks of data Flushing previously didn't guarantee that it would flush out the entire data. As part of this the flate and gzip implementations were refactored to a state machine as I believe this makes them much more understandable, especially the gzip implementation.
diff --git a/src/stream/brotli.rs b/src/stream/brotli.rs index 75da163..b39e127 100644 --- a/src/stream/brotli.rs +++ b/src/stream/brotli.rs @@ -6,7 +6,7 @@ use std::io::Result; use brotli2::raw::{CoStatus, CompressOp}; pub use brotli2::{raw::Compress, CompressParams}; -use bytes::{BufMut, Bytes, BytesMut}; +use by...
3
215
105
7a18d553053b8a68ce2db4f86d26dd84664f4356
grey
2019-05-02T23:53:32
remove unnecessary empty early return
diff --git a/src/stream/gzip.rs b/src/stream/gzip.rs index cddcc77..161af7e 100644 --- a/src/stream/gzip.rs +++ b/src/stream/gzip.rs @@ -165,7 +165,6 @@ impl<S: Stream<Item = Result<Bytes>>> Stream for DecompressedGzipStream<S> { )))); } *this.header_stripped = true; - ...
1
0
1
71e2a73d5bc30ec7cda9b89a3d4ec3edbb427d2e
grey
2019-05-02T18:57:29
add decompressed gzip stream support, tests and a bit of refactoring adding the bytes
diff --git a/src/stream/flate.rs b/src/stream/flate.rs index 5c65c38..f930d92 100644 --- a/src/stream/flate.rs +++ b/src/stream/flate.rs @@ -94,7 +94,7 @@ impl<S: Stream<Item = Result<Bytes>>> Stream for DecompressedStream<S> { if *this.flushing { return Poll::Ready(None); } e...
6
153
27
1c2f1d0632f44c98b59951e548e9e38f76061374
grey
2019-05-02T15:30:06
add decompressed brotli support (untested), cargo fmt
diff --git a/src/stream/brotli.rs b/src/stream/brotli.rs index 75da163..90ac463 100644 --- a/src/stream/brotli.rs +++ b/src/stream/brotli.rs @@ -2,9 +2,9 @@ use core::{ pin::Pin, task::{Context, Poll}, }; -use std::io::Result; +use std::io::{Error, ErrorKind, Result}; -use brotli2::raw::{CoStatus, Compress...
5
120
6
65ebc5398671db4c353e9cb6ed52db5828d25209
grey
2019-05-02T00:38:10
add decompressed stream support for deflate/zlib
diff --git a/src/stream/deflate.rs b/src/stream/deflate.rs index 9c37194..e2b33f7 100644 --- a/src/stream/deflate.rs +++ b/src/stream/deflate.rs @@ -5,9 +5,9 @@ use core::{ use std::io::Result; use std::marker::Unpin; -use super::flate::CompressedStream; +use super::flate::{CompressedStream, DecompressedStream}; u...
3
108
6
5611e39fa3b9abd115bacdb1697cddb5876dd158
grey
2019-05-01T18:24:06
make gzip stream easier to work with
diff --git a/src/stream/gzip.rs b/src/stream/gzip.rs index df39572..c9aeb69 100644 --- a/src/stream/gzip.rs +++ b/src/stream/gzip.rs @@ -1,5 +1,4 @@ use core::{ - marker::{PhantomData, Unpin}, pin::Pin, task::{Context, Poll}, }; @@ -8,38 +7,24 @@ use std::io::Result; use bytes::{Bytes, BytesMut}; pub u...
1
15
29
3052bfc58637b2d7168505d0225fb696c66cbfb0
grey
2019-05-01T17:55:53
hide implementation detail for gzipbodystream
diff --git a/src/stream/gzip.rs b/src/stream/gzip.rs index 7a6dcb7..df39572 100644 --- a/src/stream/gzip.rs +++ b/src/stream/gzip.rs @@ -28,7 +28,7 @@ impl<S: Stream<Item = Result<Bytes>> + Unpin> Stream for GzipStream<S> { } #[unsafe_project(Unpin)] -pub struct GzipBodyStream<S: Stream<Item = Result<Bytes>>> { +st...
1
1
1
d57b4e4c4296f7d09541b88e604901f72e615797
grey
2019-05-01T17:51:27
add gzip stream support
diff --git a/src/stream/gzip.rs b/src/stream/gzip.rs new file mode 100644 index 0000000..7a6dcb7 --- /dev/null +++ b/src/stream/gzip.rs @@ -0,0 +1,127 @@ +use core::{ + marker::{PhantomData, Unpin}, + pin::Pin, + task::{Context, Poll}, +}; +use std::io::Result; + +use bytes::{Bytes, BytesMut}; +pub use flate2:...
3
152
0
05c2c2088f73f567a46856659bfb07db4e913238
Wim Looman
2019-05-01T15:33:43
Add @fairingrey to authors
diff --git a/Cargo.toml b/Cargo.toml index 160c294..0ae108c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "async-compression" version = "0.1.0" -authors = ["Wim Looman <wim@nemo157.com>"] +authors = ["Wim Looman <wim@nemo157.com>", "Allen Bui <fairingrey@gmail.com>"] edition = "2018" li...
1
1
1
abfb082a595554bc256dbec1f6cf7506e3114e5b
grey
2019-05-01T08:19:04
remove leftover dbg! call
diff --git a/src/stream/brotli.rs b/src/stream/brotli.rs index 21322c8..75da163 100644 --- a/src/stream/brotli.rs +++ b/src/stream/brotli.rs @@ -50,7 +50,7 @@ impl<S: Stream<Item = Result<Bytes>>> Stream for BrotliStream<S> { input_ref, output_ref, )?; - while l...
1
1
1
8ba4ed30ba75296a82c42044843cc899439e57df
grey
2019-05-01T05:05:55
reorganize modules create convenience modules and hide flate stream from API
diff --git a/src/lib.rs b/src/lib.rs index f5a86f4..99d72a7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,2 +1,2 @@ -pub mod brotli; -pub mod flate2; +pub mod read; +pub mod stream; diff --git a/src/read/brotli.rs b/src/read/brotli.rs new file mode 100644 index 0000000..27143d5 --- /dev/null +++ b/src/read/brotli.rs @...
13
309
89
cf6ced368c84ee7c4216469f54ce8ea6d6b04a27
Wim Looman
2019-04-30T18:03:21
Use pin-project for dealing with pin projection
diff --git a/Cargo.toml b/Cargo.toml index 5319a81..31516bd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,4 +9,4 @@ brotli2 = "0.3.2" bytes = "0.4.12" flate2 = "1.0.7" futures-preview = "0.3.0-alpha.15" -juliex = "0.3.0-alpha.5" +pin-project = "0.3.2" diff --git a/src/brotli.rs b/src/brotli.rs index 959cfb7..f433b2...
3
46
72
01a3763bf4ccfa654ba67c9c43d7b996c88da7bb
grey
2019-04-30T17:44:40
reorganize more, remove old test
diff --git a/src/brotli.rs b/src/brotli.rs index e6dec75..959cfb7 100644 --- a/src/brotli.rs +++ b/src/brotli.rs @@ -74,14 +74,13 @@ impl<S: Stream<Item = Result<Bytes>>> Stream for CompressedStream<S> { } } -pub fn compress_stream( - stream: impl Stream<Item = Result<Bytes>>, - compress: Compress, -) -> ...
5
27
54
ee8eae7e2905297fdfccb6133369c1bbd87a24ac
grey
2019-04-30T17:28:13
adds brotli stream compression support reorganizes crate a bit (exposes brotli2/flate2 compress objects/params) use published futures version instead
diff --git a/Cargo.toml b/Cargo.toml index b6b60bd..5319a81 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,8 @@ authors = ["Wim Looman <wim@nemo157.com>"] edition = "2018" [dependencies] +brotli2 = "0.3.2" bytes = "0.4.12" flate2 = "1.0.7" -futures-preview = { git = "https://github.com/rust-lang-nursery/futu...
6
320
142
fced9841fa1285ef6033bd5930c9e6a3e56d4b0a
Chris Hennick
2025-03-18T19:25:28
test(deps): Update `zip` Updates `zip` from 0.6.4 (ancient and no longer supported) to 2.x.
diff --git a/Cargo.toml b/Cargo.toml index 5e0dfdf..174a543 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,4 +12,4 @@ keywords = ["parser", "android", "timezone"] include = ["src/**/*", "LICENSE-*", "README.md"] [dev-dependencies] -zip = "0.6.4" +zip = "2"
1
1
1
c632fbf4173fb0210ff657d9dd9ddb03ffc702e4
RumovZ
2023-03-05T09:18:49
Ensure compatibility with 2018 edition
diff --git a/Cargo.toml b/Cargo.toml index bd0e953..5e0dfdf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "android-tzdata" -version = "0.1.0" +version = "0.1.1" authors = ["RumovZ"] -edition = "2021" +edition = "2018" license = "MIT OR Apache-2.0" description = "Parser for the Android-s...
2
4
4
28fdcdd59e9e91ed0971c41c58c4ec2edcb25912
Andy Balaam
2026-04-09T07:47:42
Fix typo 'crated' -> 'created'
diff --git a/src/lib.rs b/src/lib.rs index 365f828..72ada23 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -606,7 +606,7 @@ impl MmapOptions { /// /// The memory map length should be configured using [`MmapOptions::len()`] /// before creating an anonymous memory map, otherwise a zero-length mapping - ///...
1
1
1
b51beb58c909b6afff7cd05d30c3031f406cefd7
daxpedda
2026-01-28T09:48:10
Address review Co-Authored-By: Maarten de Vries <maarten@de-vri.es>
diff --git a/src/lib.rs b/src/lib.rs index fdc6c3d..365f828 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -402,7 +402,7 @@ impl MmapOptions { /// This method returns an error when the underlying system call fails, which can happen for a /// variety of reasons, such as when the file is not open with read permiss...
2
13
13
8de56f357979f60ce0ab79d781db819e36193a84
daxpedda
2026-01-26T13:59:30
Return `ErrorKind::Unsupported` from stub implementation
diff --git a/src/lib.rs b/src/lib.rs index 51be284..fdc6c3d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -402,6 +402,8 @@ impl MmapOptions { /// This method returns an error when the underlying system call fails, which can happen for a /// variety of reasons, such as when the file is not open with read permiss...
2
26
5
d2054a2c9225b8b89968a0f49d10aaed9ff76367
Xing Xue
2025-10-22T18:24:49
Cast the 'addr' argument of 'madvise()' to match the AIX function signature in the 'libc' crate.
diff --git a/src/unix.rs b/src/unix.rs index d944e77..74e4d27 100644 --- a/src/unix.rs +++ b/src/unix.rs @@ -426,7 +426,20 @@ impl MmapInner { let offset = offset as isize - alignment as isize; let len = len + alignment; unsafe { - if libc::madvise(self.ptr.offset(offset), len, adv...
1
14
1
5f753ab4bf78a041614d26b36f55d05400bf7739
Thomas Habets
2025-10-21T08:00:35
Update src/lib.rs Co-authored-by: Maarten de Vries <maarten@de-vri.es>
diff --git a/src/lib.rs b/src/lib.rs index ddafdf3..f628221 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -250,7 +250,7 @@ impl MmapOptions { // This is not a problem on 64-bit targets, but on 32-bit one // having a file or an anonymous mapping larger than 2GB is quite normal // and we have to ...
1
1
1
d0cbc3362908617fd6adcac8d84dddbbee91d4c0
Giovanni Petrantoni
2025-10-20T11:06:14
Replace individual Apple OS checks with target_vendor = "apple" Addresses maintainer feedback to use target_vendor = "apple" instead of checking each Apple OS individually. This automatically includes all Apple platforms (macOS, iOS, visionOS, watchOS, tvOS) and is more maintainable for future Apple platforms. Change...
diff --git a/src/advice.rs b/src/advice.rs index 27e37d0..8b7e1e6 100644 --- a/src/advice.rs +++ b/src/advice.rs @@ -230,7 +230,7 @@ pub enum Advice { /// zeroed out if the address range is deallocated without first unwiring the pages (i.e. /// a munmap(2) without a preceding munlock(2) or the application qui...
3
7
7
5a30f6b79683446e3851263fac15e30301df16b6
Giovanni Petrantoni
2025-10-20T01:16:39
Add visionOS support
diff --git a/src/advice.rs b/src/advice.rs index 3fe36f0..27e37d0 100644 --- a/src/advice.rs +++ b/src/advice.rs @@ -230,7 +230,7 @@ pub enum Advice { /// zeroed out if the address range is deallocated without first unwiring the pages (i.e. /// a munmap(2) without a preceding munlock(2) or the application qui...
2
5
5
4f3d1aa7886f7d7d488ab6589cd26e39b8fd5d7d
Thomas Habets
2025-10-19T16:21:49
Future proof `validate_len()` for 128bit Instead of assuming `isize` fits in `u64`, `try_from()` into it. Signed-off-by: Thomas Habets <thomas@habets.se>
diff --git a/src/lib.rs b/src/lib.rs index 9a1107a..ddafdf3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -250,16 +250,13 @@ impl MmapOptions { // This is not a problem on 64-bit targets, but on 32-bit one // having a file or an anonymous mapping larger than 2GB is quite normal // and we have t...
1
2
5
8bfe4e5440a859f0cbd6540f7623e277edda5c8e
Maarten de Vries
2025-08-15T06:07:52
Rename noreserve in impl to no_reserve.
diff --git a/src/unix.rs b/src/unix.rs index efb07cd..12feb1a 100644 --- a/src/unix.rs +++ b/src/unix.rs @@ -239,14 +239,14 @@ impl MmapInner { file: RawFd, offset: u64, populate: bool, - noreserve: bool, + no_reserve: bool, ) -> io::Result<MmapInner> { let populat...
2
24
24
3fcecb6c7967060f4aae3da1b0df3a7e9657de44
Maarten de Vries
2025-08-15T06:04:11
Also support `no_reserve_swap()` on Illumos.
diff --git a/src/lib.rs b/src/lib.rs index 6ed00ec..9a1107a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -360,18 +360,17 @@ impl MmapOptions { } /// Do not reserve swap space for the memory map. - /// + /// /// By default, platforms may reserve swap space for memory maps. /// This guarantees...
2
10
9
c8235d7bce723b80563cac14ce550693e77f4af5
nhtyy
2025-08-14T19:06:05
chore: run `cargo fmt`
diff --git a/src/lib.rs b/src/lib.rs index a871623..6ed00ec 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -360,7 +360,7 @@ impl MmapOptions { } /// Do not reserve swap space for the memory map. - /// + /// /// By default, platforms may reserve swap space for memory maps. /// This guarantees t...
3
122
26
beb3d3a5da6271c93dce4f0c1745e5f962a88927
N
2025-08-14T18:53:42
fix: apply suggestions to comments Co-authored-by: Maarten de Vries <maarten@de-vri.es>
diff --git a/src/lib.rs b/src/lib.rs index 02f8942..a871623 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -361,14 +361,15 @@ impl MmapOptions { /// Do not reserve swap space for the memory map. /// - /// Platforms may reserve swap space for memory maps that are not backed by a file - /// (and file back...
1
5
4
2abbcd666350b511f0fca61a6087fb9a0a73b314
nhtyy
2025-08-14T18:50:33
fix: cfg target_os
diff --git a/src/lib.rs b/src/lib.rs index f06d509..02f8942 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -382,7 +382,7 @@ impl MmapOptions { /// let file = File::open("LICENSE-MIT")?; /// /// let mmap = unsafe { - /// MmapOptions::new().noreserve().map(&file)? + /// MmapOptions::new().no_res...
2
5
2
7b67e0db767d4a11a9867d66bff4f934c401f887
nhtyy
2025-08-14T18:12:41
fix: update stub and comments
diff --git a/src/lib.rs b/src/lib.rs index 241283f..f06d509 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -361,12 +361,14 @@ impl MmapOptions { /// Do not reserve swap space for the memory map. /// - /// Platforms may reserve swap space for memory maps that are not backed by a file. + /// Platforms may ...
2
10
8
ec72e01a4ca6d4db367c7e7bcf51e3567e359161
N
2025-08-14T17:34:43
fix: noreserve -> noreserve_swap Co-authored-by: Maarten de Vries <maarten@de-vri.es>
diff --git a/src/lib.rs b/src/lib.rs index ebf08a5..241283f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -158,7 +158,7 @@ pub struct MmapOptions { huge: Option<u8>, stack: bool, populate: bool, - noreserve: bool, + no_reserve_swap: bool, } impl MmapOptions { @@ -359,11 +359,16 @@ impl MmapOption...
1
20
15
71f1e1b7af9652e76b0c961bd00f7eae0f4e201f
nhtyy
2025-08-13T00:14:39
feat: exposee `MAP_NORESERVE` from `MmapOptions`
diff --git a/src/lib.rs b/src/lib.rs index 88dc76c..ebf08a5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -158,6 +158,7 @@ pub struct MmapOptions { huge: Option<u8>, stack: bool, populate: bool, + noreserve: bool, } impl MmapOptions { @@ -329,6 +330,7 @@ impl MmapOptions { self.huge = Some(...
3
65
18
f9d4b4ad0c260375d171b8fa5fdbb1072a003705
Maarten de Vries
2025-07-11T08:58:03
Remove unused import.
diff --git a/src/lib.rs b/src/lib.rs index f032ab8..88dc76c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -70,7 +70,6 @@ use std::fmt; #[cfg(not(any(unix, windows)))] use std::fs::File; use std::io::{Error, ErrorKind, Result}; -use std::mem; use std::ops::{Deref, DerefMut}; #[cfg(unix)] use std::os::unix::io::{AsRa...
1
0
1
786473ba8ab2985b57029cea22529e1fe00f8490
наб
2025-07-10T15:37:09
Unwind map_or_else()
diff --git a/src/lib.rs b/src/lib.rs index 27f8cb4..f032ab8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -265,22 +265,22 @@ impl MmapOptions { /// Returns the configured length, or the length of the provided file. fn get_len<T: MmapAsRawDesc>(&self, file: &T) -> Result<usize> { - self.len.map_or_else(...
1
16
16
708546582f28ac2b11b901f76f81ffa51d6be01d
Kevan Hollbach
2025-06-20T02:16:57
Fix broken link in docs
diff --git a/src/advice.rs b/src/advice.rs index eec6c56..3fe36f0 100644 --- a/src/advice.rs +++ b/src/advice.rs @@ -234,7 +234,7 @@ pub enum Advice { ZeroWiredPages = libc::MADV_ZERO_WIRED_PAGES, } -/// Values supported by [`Mmap::unsafe_advise`][crate::Mmap::unsafe_advise] and [`MmapMut::unsafe_advise`][crate...
1
1
1
5e144e7d9438b7d8d715922f8b1f1b8fd0ce57b6
наб
2025-06-01T02:18:35
Validate len > isize::MAX on LP64 too This is a hard invariant of from_raw_parts() on all arches, and an int comparison is faster than failing a mmap(2)
diff --git a/src/lib.rs b/src/lib.rs index f0024a3..27f8cb4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -253,7 +253,7 @@ impl MmapOptions { // // The code below is essentially the same as in Rust's std: // https://github.com/rust-lang/rust/blob/db78ab70a88a0a5e89031d7ee4eccec835dcdbde/library...
1
2
7
b26d371b200abe9775b8542252d3ebd537dfedf2
наб
2025-06-01T02:14:19
Also reject len > isize::MAX if set with .len() You can easily validate the from_raw_parts() invariant here Closes: #144
diff --git a/src/lib.rs b/src/lib.rs index 22e6fa3..f0024a3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -243,6 +243,26 @@ impl MmapOptions { self } + fn validate_len(len: u64) -> Result<usize> { + // Rust's slice cannot be larger than isize::MAX. + // See https://doc.rust-lang.org/std/s...
1
23
20
ce0f54b8640de56ef5b70d0648a02d17b54eb76b
Alex1s
2025-05-06T13:06:42
fix type
diff --git a/src/unix.rs b/src/unix.rs index 024bce3..cdfea5d 100644 --- a/src/unix.rs +++ b/src/unix.rs @@ -286,7 +286,7 @@ impl MmapInner { let hugetlb = if huge.is_some() { MAP_HUGETLB } else { 0 }; let hugetlb_size = huge.map_or(0, |mask| { (u64::from(mask) & (MAP_HUGE_MASK as u64)) <...
1
1
1
78dba6991309180a92b4a23e15c56de51d64eaa7
Alex1s
2025-05-06T13:02:11
hugepage size encoding in flags and not in offset
diff --git a/src/unix.rs b/src/unix.rs index 33e2a66..024bce3 100644 --- a/src/unix.rs +++ b/src/unix.rs @@ -284,15 +284,15 @@ impl MmapInner { let stack = if stack { MAP_STACK } else { 0 }; let populate = if populate { MAP_POPULATE } else { 0 }; let hugetlb = if huge.is_some() { MAP_HUGETLB ...
1
3
3
75062690d52094d8e226938d53a35866f61035aa
Allan
2024-12-05T23:32:14
Remove `extern crate`
diff --git a/examples/cat.rs b/examples/cat.rs index 34599af..d0dce7e 100644 --- a/examples/cat.rs +++ b/examples/cat.rs @@ -1,5 +1,3 @@ -extern crate memmap2; - use std::env; use std::fs::File; use std::io::{self, Write}; diff --git a/src/lib.rs b/src/lib.rs index 1c3ae2b..1c57fc3 100644 --- a/src/lib.rs +++ b/src/...
3
0
25
732e5fb817735646995319d0247a482e1c4e53a6
Maarten de Vries
2024-12-05T23:10:44
Remove use of legacy numeric constants, use associated constants.
diff --git a/src/lib.rs b/src/lib.rs index edf117e..1c3ae2b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,8 +13,6 @@ clippy::return_self_not_must_use, clippy::unreadable_literal, clippy::upper_case_acronyms, - // remove later - clippy::legacy_numeric_constants )] //! A cross-platform Rust API...
2
0
5
c06808eb974df5a3cb8ee0bbed931a0a1be0ed47
Maarten de Vries
2024-12-05T22:09:57
Switch to edition 2021.
diff --git a/Cargo.toml b/Cargo.toml index 243129a..168032b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ repository = "https://github.com/RazrFalcon/memmap2-rs" documentation = "https://docs.rs/memmap2" description = "Cross-platform Rust API for memory-mapped file IO" keywords = ["mmap", "memory-map", ...
1
1
1
0bccd3ae255cc0c09cbb299d43a982ea5ec9debf
Maarten de Vries
2024-12-05T21:57:06
Fix new clippy warnings.
diff --git a/src/lib.rs b/src/lib.rs index a2df6d2..edf117e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -109,7 +109,7 @@ impl MmapAsRawDesc for RawFd { } #[cfg(unix)] -impl<'a, T> MmapAsRawDesc for &'a T +impl<T> MmapAsRawDesc for &T where T: AsRawFd, { @@ -126,7 +126,7 @@ impl MmapAsRawDesc for RawHandle { ...
3
4
4
e10575bac7c4ca3ed7b100b0bc536a6adefb073c
Joe Kale
2024-12-05T21:28:45
Mark unchecked_advise_range as unsafe
diff --git a/src/lib.rs b/src/lib.rs index a2df6d2..fc2778f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1329,7 +1329,7 @@ impl MmapMut { /// /// See [madvise()](https://man7.org/linux/man-pages/man2/madvise.2.html) map page. #[cfg(unix)] - pub fn unchecked_advise_range( + pub unsafe fn unchecked_a...
1
1
1
34776c1f83b0ef17ecbc838a580c66e3d703b51d
xzfc
2024-09-12T17:28:38
Add {Advise, UncheckedAdvice}::is_supported() (#122)
diff --git a/src/advice.rs b/src/advice.rs index 4316058..c803f24 100644 --- a/src/advice.rs +++ b/src/advice.rs @@ -382,3 +382,41 @@ pub enum UncheckedAdvice { // MADV_KEEPONFORK (since Linux 4.14) // MADV_COLD (since Linux 5.4) // MADV_PAGEOUT (since Linux 5.4) + +#[cfg(target_os = "linux")] +impl Advice { + ...
1
38
0
499620538c3144d75654c851606fa8c7f9b579fa
Ralf Jung
2024-09-06T08:22:32
Add links to safety docs in map methods (#121)
diff --git a/src/lib.rs b/src/lib.rs index 6ff9e36..94dba24 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -338,6 +338,10 @@ impl MmapOptions { /// Creates a read-only memory map backed by a file. /// + /// # Safety + /// + /// See the [type-level][MmapOptions] docs for why this function is unsafe. + ...
1
31
0
f7c50830ed332d4a53dd948194c87bfd3b25855b
Petteri Räty
2024-04-29T10:18:46
Improve documentation for huge pages.
diff --git a/src/lib.rs b/src/lib.rs index 0b4ea23..6ff9e36 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -302,6 +302,8 @@ impl MmapOptions { /// # Ok(()) /// # } /// ``` + /// + /// The number 21 corresponds to `MAP_HUGE_2MB`. See mmap(2) for more details. pub fn huge(&mut self, page_bits: Opti...
1
2
0
cc74502f1f2ad3f6bb34ea671240e874794ee23a
Alex Steele
2024-03-28T08:49:13
Fix copy/paste error in MmapMut doc comment (#116)
diff --git a/src/lib.rs b/src/lib.rs index fb912e6..0b4ea23 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -559,6 +559,8 @@ impl MmapOptions { /// /// `Mmap` is [`Sync`] and [`Send`]. /// +/// See [`MmapMut`] for the mutable version. +/// /// ## Safety /// /// All file-backed memory map constructors are marked `unsa...
1
3
3
faafbfd031e283ab6ef637e8c9d6a5d85e84602b
Yevhenii Reizner
2023-12-17T09:52:13
Fix formatting.
diff --git a/src/lib.rs b/src/lib.rs index 7f4a042..fb912e6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1977,7 +1977,8 @@ mod test { let a = mmap.as_ref()[0]; unsafe { - mmap.unchecked_advise(crate::UncheckedAdvice::DontNeed).unwrap(); + mmap.unchecked_advise(crate::UncheckedA...
1
2
1
428bb9bf061af89c33d6188dfa4abff2ffcd7e31
Yevhenii Reizner
2023-12-17T09:25:45
Fix tests.
diff --git a/src/lib.rs b/src/lib.rs index 8bcede4..7f4a042 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1977,7 +1977,7 @@ mod test { let a = mmap.as_ref()[0]; unsafe { - mmap.unchecked_advise(UncheckedAdvice::DontNeed).unwrap(); + mmap.unchecked_advise(crate::UncheckedAdvice::...
1
2
2
55109c68837e80f3c00f4a56a75a6abd49ead7c7
Yevhenii Reizner
2023-12-17T09:09:46
Disable huge tables support for freebsd, since it doesn't support them. Closes #109
diff --git a/src/lib.rs b/src/lib.rs index 6ba98ea..8bcede4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1412,7 +1412,7 @@ mod test { extern crate tempfile; #[cfg(unix)] - use crate::advice::{Advice, UncheckedAdvice}; + use crate::advice::Advice; use std::fs::{File, OpenOptions}; use std::io...
2
7
7
e5faf1339d21ecbe4f62a803050aaae415c96a8d
Adam Reichold
2023-12-09T12:13:50
Fix madvise tests to not assume 4k pages.
diff --git a/src/lib.rs b/src/lib.rs index 3683755..6ba98ea 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1969,7 +1969,9 @@ mod test { #[test] #[cfg(target_os = "linux")] fn advise_writes_unsafely() { - let mut mmap = MmapMut::map_anon(4096).unwrap(); + let page_size = unsafe { libc::sysconf...
1
9
5
6a6a3ead182affbeb44a11224bd3f80cda01650e
Adam Reichold
2023-10-03T14:46:19
Separate safe and unsafe madvice calls.
diff --git a/src/advice.rs b/src/advice.rs index 9b25e4f..4316058 100644 --- a/src/advice.rs +++ b/src/advice.rs @@ -1,145 +1,32 @@ /// Values supported by [`Mmap::advise`][crate::Mmap::advise] and [`MmapMut::advise`][crate::MmapMut::advise] functions. +/// /// See [madvise()](https://man7.org/linux/man-pages/man2/ma...
3
276
186
c4b497ee8b35fcdc9fd4b9284a4dbc0b5499a3f6
Adam Reichold
2023-09-23T20:30:02
Change madvise API to differentiate between safe and unsafe advice options.
diff --git a/src/advice.rs b/src/advice.rs index a53a7f5..9b25e4f 100644 --- a/src/advice.rs +++ b/src/advice.rs @@ -1,35 +1,40 @@ -// The use statement is needed for the `cargo docs` -#[allow(unused_imports)] -use crate::{Mmap, MmapMut}; - -/// Values supported by [`Mmap::advise`] and [`MmapMut::advise`] functions. +/...
3
133
49
657965584da0b9130cd3ba8e2060d114c684daf1
Jesse
2023-05-31T19:12:14
Add MADV_POPULATE_{READ,WRITE}.
diff --git a/Cargo.toml b/Cargo.toml index ac77a9c..a7cd3ac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ edition = "2018" stable_deref_trait = { version = "1.0", optional = true } [target.'cfg(unix)'.dependencies] -libc = "0.2" +libc = "0.2.143" [dev-dependencies] tempfile = "3" diff --git a/src/a...
2
68
1
b098f9ee408f821bd5dd74f57a248bc421a3c686
Sean Lynch
2023-05-31T10:48:50
Refactor pointer handling within `unix.rs` into helper methods.
diff --git a/src/lib.rs b/src/lib.rs index c95affa..dd99ba1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1971,4 +1971,44 @@ mod test { assert_eq!(mmap.len(), 1024); } + + #[test] + #[cfg(target_os = "linux")] + fn remap_with_offset() { + use crate::RemapOptions; + + let offset = 7...
2
156
61
0c9b7f75ed133ef56d2adab3b54a58ecf2528024
Sean Lynch
2023-05-29T21:31:20
Add support for `mremap(2)` on Linux. Closes #81
diff --git a/src/lib.rs b/src/lib.rs index e113774..c95affa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -672,6 +672,28 @@ impl Mmap { pub fn unlock(&self) -> Result<()> { self.inner.unlock() } + + /// Adjust the size of the memory mapping. + /// + /// This will try to resize the memory mappi...
2
234
0
f62a3cb19b4a48d6e8b3f92323ec504d9e66fc6d
Adam Reichold
2023-05-10T11:01:24
Add MmapOptions::map_raw_read_only to avoid intermediate invalid Mmap instances.
diff --git a/src/lib.rs b/src/lib.rs index 94019a9..8cc609b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -497,6 +497,21 @@ impl MmapOptions { MmapInner::map_mut(self.get_len(&file)?, desc.0, self.offset, self.populate) .map(|inner| MmapRaw { inner }) } + + /// Creates a read-only raw memory...
1
32
1
bd52d2cdb6876452e63832b712a3cdc4b9274e01
Tim Visée
2023-05-09T15:00:59
Make lock and unlock &self. Fixes #74
diff --git a/src/lib.rs b/src/lib.rs index 591c4ff..94019a9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -646,7 +646,7 @@ impl Mmap { /// /// See [mlock()](https://man7.org/linux/man-pages/man2/mlock.2.html) map page. #[cfg(unix)] - pub fn lock(&mut self) -> Result<()> { + pub fn lock(&self) -> Resu...
1
7
7
732df20c918e5040d0cf08c7a9ae68888b3fab09
Michael Färber
2023-03-13T07:03:02
Correct documentation spelling.
diff --git a/src/lib.rs b/src/lib.rs index 2d730ae..591c4ff 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,7 +4,7 @@ //! which correspond to mapping a [`File`] to a [`&[u8]`](https://doc.rust-lang.org/std/primitive.slice.html) //! or [`&mut [u8]`](https://doc.rust-lang.org/std/primitive.slice.html) //! respectively....
1
1
1
b26573b52f1ace32f27232276eb0aadd1d0b0640
Jeremy Fitzhardinge
2023-02-22T17:55:01
Implement `.populate()` for `map_anon()`. Closes #70
diff --git a/src/lib.rs b/src/lib.rs index 0d64d2b..2d730ae 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -482,7 +482,7 @@ impl MmapOptions { )); } - MmapInner::map_anon(len, self.stack).map(|inner| MmapMut { inner }) + MmapInner::map_anon(len, self.stack, self.populate).map(|inner| ...
4
6
5
f34800896c9b46dcea42f2994447a16dc55b16cd
Ho 229
2023-02-17T14:49:41
Add `advise_range` for unix. Closes #68
diff --git a/src/lib.rs b/src/lib.rs index 0f4e5ea..0d64d2b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -627,7 +627,19 @@ impl Mmap { /// See [madvise()](https://man7.org/linux/man-pages/man2/madvise.2.html) map page. #[cfg(unix)] pub fn advise(&self, advice: Advice) -> Result<()> { - self.inner.a...
2
47
5
9468f17c435424b29fc3eeb1db3e8617e453026d
Sean Lynch
2023-02-14T19:37:13
Allow converting Mmap and MmapMut into MmapRaw.
diff --git a/src/lib.rs b/src/lib.rs index 58df758..0f4e5ea 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -835,6 +835,18 @@ impl fmt::Debug for MmapRaw { } } +impl From<Mmap> for MmapRaw { + fn from(value: Mmap) -> Self { + Self { inner: value.inner } + } +} + +impl From<MmapMut> for MmapRaw { + f...
1
12
0
0f1c41e4d08929e6d030fdd82e76aa417b8275dc
diwic
2022-11-09T08:49:23
MmapRaw: Add some functions to catch up with MmapMut.
diff --git a/src/lib.rs b/src/lib.rs index 7cd0b0e..58df758 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -800,6 +800,30 @@ impl MmapRaw { pub fn flush_async_range(&self, offset: usize, len: usize) -> Result<()> { self.inner.flush_async(offset, len) } + + /// Advise OS how this memory map will be ac...
1
24
0
7705bdd94c9de74b3e8b19385b90fb4f92c5e9d6
Matt Keeter
2022-10-11T12:20:08
Add doc warning about make_exec. Closes #62
diff --git a/src/lib.rs b/src/lib.rs index 5ddacab..7cd0b0e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1006,6 +1006,12 @@ impl MmapMut { /// /// If the memory map is file-backed, the file must have been opened with execute permissions. /// + /// On systems with separate instructions and data caches ...
1
6
0
466791b187cbb294fb1b1b07939a30ab032ab10c
LingMan
2022-08-26T11:52:15
Fix warning `unused import: self` when compiling tests on non-Linux targets.
diff --git a/src/lib.rs b/src/lib.rs index 0b92ea0..5ddacab 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1088,7 +1088,7 @@ mod test { #[cfg(unix)] use crate::advice::Advice; - use std::fs::{self, OpenOptions}; + use std::fs::OpenOptions; use std::io::{Read, Write}; #[cfg(unix)] use std:...
1
2
2
090dfba607395e6b85833df44559d7a13b014599
LingMan
2022-08-25T14:33:17
Specify licenses in SPDX format. The use of `/` as a separator is deprecated.
diff --git a/Cargo.toml b/Cargo.toml index f36a784..21b1569 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "memmap2" version = "0.5.7" authors = ["Dan Burkert <dan@danburkert.com>", "Yevhenii Reizner <razrfalcon@gmail.com>"] -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" repository = "h...
1
1
1
d46b239e619adb43bd6037a05317edf2f6df8dac
Ben Kimock
2022-08-14T21:02:42
Use File::metadata to get file size and not libc methods
diff --git a/src/unix.rs b/src/unix.rs index 8abc767..158d78c 100644 --- a/src/unix.rs +++ b/src/unix.rs @@ -1,7 +1,8 @@ extern crate libc; -use std::mem::MaybeUninit; -use std::os::unix::io::RawFd; +use std::fs::File; +use std::mem::ManuallyDrop; +use std::os::unix::io::{FromRawFd, RawFd}; use std::sync::atomic::{...
2
16
49
c60a4679dbd87debc08f9328786ec2bde473682c
Volker Mische
2022-08-11T16:02:30
Add support for mlock() and munlock() Closes #51
diff --git a/src/lib.rs b/src/lib.rs index 5a706c4..0b92ea0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -629,6 +629,22 @@ impl Mmap { pub fn advise(&self, advice: Advice) -> Result<()> { self.inner.advise(advice) } + + /// Lock the whole memory map into RAM. Only supported on Unix. + /// + /...
2
105
1
04a86f969fc38b2c4db02a19190fefb82e481f4c
Adam Reichold
2022-07-09T05:49:09
Avoid creating slices that exceed isize::MAX bytes. Closes #48
diff --git a/src/lib.rs b/src/lib.rs index b90d1bc..4d7821a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -51,13 +51,14 @@ use std::fmt; #[cfg(not(any(unix, windows)))] use std::fs::File; use std::io::{Error, ErrorKind, Result}; +use std::isize; +use std::mem; use std::ops::{Deref, DerefMut}; #[cfg(unix)] use std::...
1
32
14
f7db122f70802c3417f54d056d5a75f95317f3bf
Yevhenii Reizner
2022-06-04T10:50:30
Fix formatting.
diff --git a/src/advice.rs b/src/advice.rs index eef6f12..185743e 100644 --- a/src/advice.rs +++ b/src/advice.rs @@ -263,11 +263,11 @@ pub enum Advice { /// zero-filled pages on demand, other pages will be left as is. #[cfg(any(target_os = "macos", target_os = "ios"))] FreeReuse = libc::MADV_FREE_REUSE, ...
1
7
7
b05c42adb761a6a8de5ba0f9587f03c85629096b
Noa
2022-06-04T10:42:15
Make stub implementation Infallible.
diff --git a/src/stub.rs b/src/stub.rs index a555a4f..feec1cf 100644 --- a/src/stub.rs +++ b/src/stub.rs @@ -1,10 +1,10 @@ use std::fs::File; use std::io; +enum Never {} + pub struct MmapInner { - // Private member to prevent external construction - // (might be nice to change the type to ! once that's stabl...
1
11
11
3825a1cba0cb750de956adb607f15cd5e958d744
turbocool3r
2022-06-04T10:40:42
Add madvice operations specific to Darwin.
diff --git a/src/advice.rs b/src/advice.rs index d3c5461..eef6f12 100644 --- a/src/advice.rs +++ b/src/advice.rs @@ -65,7 +65,7 @@ pub enum Advice { // // The rest are Linux-specific // - /// **MADV_FREE** - Linux only (since Linux 4.5) + /// **MADV_FREE** - Linux (since Linux 4.5) and Darwin ...
1
26
2
d8863a9595cf5f1a21665883d9af69e0a65ecdf9
Alexander Kjäll
2022-02-13T10:12:05
Replace tempdir crate with tempfile. https://rustsec.org/advisories/RUSTSEC-2018-0017.html
diff --git a/Cargo.toml b/Cargo.toml index f2d7c9c..b0334da 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,5 +16,5 @@ stable_deref_trait = { version = "1.0", optional = true } libc = "0.2" [dev-dependencies] -tempdir = "0.3" +tempfile = "3" owning_ref = "0.4.1" diff --git a/src/lib.rs b/src/lib.rs index 9473b2c.....
2
25
25
a336dc813b19232bbcc9265686922657f68d13c0
Yuri Astrakhan
2022-02-10T17:53:16
Implement more traits for `Advice`
diff --git a/src/advice.rs b/src/advice.rs index 835cbdb..d3c5461 100644 --- a/src/advice.rs +++ b/src/advice.rs @@ -5,6 +5,7 @@ use crate::{Mmap, MmapMut}; /// Values supported by [Mmap::advise] and [MmapMut::advise] functions. /// See [madvise()](https://man7.org/linux/man-pages/man2/madvise.2.html) map page. #[re...
1
1
0
b23444199b79104571c0a3922b2f4ce972ea46d4
Yuri Astrakhan
2022-02-10T07:45:21
Simplify module import per cfg
diff --git a/src/lib.rs b/src/lib.rs index 7e1fe80..9473b2c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -36,32 +36,17 @@ //! you can use [`MmapOptions`] in order to further configure a mapping //! before you create it. +#[cfg_attr(unix, path = "unix.rs")] +#[cfg_attr(windows, path = "windows.rs")] +#[cfg_attr(not(a...
1
6
21
02a1b3e898146a03e161430ecfed80f63ae8e2b4
Yuri Astrakhan
2022-02-10T07:37:55
Add Mmap::advise and MmapMut::advise Closes #40
diff --git a/src/advice.rs b/src/advice.rs new file mode 100644 index 0000000..835cbdb --- /dev/null +++ b/src/advice.rs @@ -0,0 +1,248 @@ +// The use statement is needed for the `cargo docs` +#[allow(unused_imports)] +use crate::{Mmap, MmapMut}; + +/// Values supported by [Mmap::advise] and [MmapMut::advise] functions...
3
329
0
d54d97ed88468c3587988756f501ee8ec0f6d2e7
Adam Reichold
2022-01-09T19:55:39
Enable the full map_offset test on 32-bit Linux as the length of the map (of only part of the file) is feasible.
diff --git a/src/lib.rs b/src/lib.rs index 83407a2..d702307 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1185,29 +1185,6 @@ mod test { assert_eq!(nulls, &read); } - // 32bit Linux cannot map a file larger than i32, but Windows can. - #[cfg(all(target_os = "linux", target_pointer_width = "32"))] - ...
1
0
23
971f703a2204d0bcac80b7791be9a03bfdd2f928
Adam Reichold
2022-01-09T19:37:52
Explicitly call fstat64 Otherwise, on 32-bit platforms, the length check ```rust if len > (usize::MAX as u64) { ``` in `MmapOptions::get_len` will never evaluate to true as `libc::stat::st_size` is of type `i32`.
diff --git a/src/unix.rs b/src/unix.rs index b394729..d4c0a8d 100644 --- a/src/unix.rs +++ b/src/unix.rs @@ -272,10 +272,15 @@ fn page_size() -> usize { } pub fn file_len(file: RawFd) -> io::Result<u64> { + #[cfg(not(any(target_os = "linux", target_os = "emscripten", target_os = "l4re")))] + use libc::{fstat,...
1
7
2
6d5149fe2070e15775f14587d620f6db1f077158
jam1garner
2021-10-23T17:36:39
Add top-level documentation.
diff --git a/src/lib.rs b/src/lib.rs index 9838f4d..83407a2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,40 @@ //! A cross-platform Rust API for memory mapped buffers. +//! +//! The core functionality is provided by either [`Mmap`] or [`MmapMut`], +//! which correspond to mapping a [`File`] to a [`&[u8]`](https...
1
36
0
8f19b19084ba33b16a52f07e453f699f1e93a70a
Adam Reichold
2021-09-19T16:13:13
Do not panic when failing to release resources in Drop impls. C.f. https://github.com/rust-lang/lang-team/issues/97 for a general discussion on why this is undesirable.
diff --git a/src/unix.rs b/src/unix.rs index ea25591..b394729 100644 --- a/src/unix.rs +++ b/src/unix.rs @@ -243,13 +243,12 @@ impl Drop for MmapInner { let alignment = self.ptr as usize % page_size(); let len = self.len + alignment; let len = len.max(1); + // Any errors during unmappi...
2
8
10
0632c6a4582ba01ed056369313fafe983ed17919
Adam Reichold
2021-09-19T15:32:31
Rebase Windows support onto RawHandle instead of File. This allows mapping anything that implements AsRawHandle including the types of async-std.
diff --git a/src/lib.rs b/src/lib.rs index 426c111..9838f4d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,26 +22,31 @@ use crate::stub::file_len; use crate::stub::MmapInner; use std::fmt; -#[cfg(not(unix))] +#[cfg(not(any(unix, windows)))] use std::fs::File; use std::io::{Error, ErrorKind, Result}; use std::op...
2
162
70
fcf489cd35d028fd5433096d9df7a10c21e8154b
Adam Reichold
2021-09-19T15:26:17
Extend MmapAsRawDesc to handle anything implementing AsRawFd.
diff --git a/src/lib.rs b/src/lib.rs index 2347167..426c111 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,6 +22,7 @@ use crate::stub::file_len; use crate::stub::MmapInner; use std::fmt; +#[cfg(not(unix))] use std::fs::File; use std::io::{Error, ErrorKind, Result}; use std::ops::{Deref, DerefMut}; @@ -48,16 +49...
1
8
4
42b688f84b0cf99cf0e227ce63b8ced51ccfe540
Adam Reichold
2021-09-19T11:55:27
Try to slightly simplify cfg and use structure in crate root.
diff --git a/src/lib.rs b/src/lib.rs index 5fb26f0..2347167 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,24 +26,21 @@ use std::fs::File; use std::io::{Error, ErrorKind, Result}; use std::ops::{Deref, DerefMut}; #[cfg(unix)] -use std::os::unix::io::AsRawFd; +use std::os::unix::io::{AsRawFd, RawFd}; use std::slice...
1
10
20
632c1792d3327fa364e02ff4b73817c6dc22e612
Adam Reichold
2021-09-19T11:52:51
Avoid zeroing out large struct stat which will be initialized by the system call.
diff --git a/src/unix.rs b/src/unix.rs index 53213fb..ea25591 100644 --- a/src/unix.rs +++ b/src/unix.rs @@ -1,5 +1,6 @@ extern crate libc; +use std::mem::MaybeUninit; use std::os::unix::io::RawFd; use std::sync::atomic::{AtomicUsize, Ordering}; use std::{io, ptr}; @@ -273,11 +274,11 @@ fn page_size() -> usize { ...
1
4
3
780de5cb6e0973ebbc988867205b16289263450b
Adam Reichold
2021-09-19T11:47:33
Memoize page size to avoid repeatedly calling into sysconf machinery.
diff --git a/src/unix.rs b/src/unix.rs index 5797c1e..53213fb 100644 --- a/src/unix.rs +++ b/src/unix.rs @@ -1,6 +1,7 @@ extern crate libc; use std::os::unix::io::RawFd; +use std::sync::atomic::{AtomicUsize, Ordering}; use std::{io, ptr}; #[cfg(any( @@ -256,7 +257,18 @@ unsafe impl Sync for MmapInner {} unsafe...
1
13
1
118344980efaaff161c68921a604fee110a84919
Simon Sapin
2021-09-16T18:45:44
Support zero-size `Mmap` and `MmapMut` Closes #23
diff --git a/src/lib.rs b/src/lib.rs index 7a41f02..2424143 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -981,7 +981,7 @@ mod test { assert_eq!(&incr[..], &mmap[..]); } - /// Checks that a 0-length file will not be mapped. + /// Checks that "mapping" a 0-length file derefs to an empty slice. #...
3
79
19
651ef08724c70945052d4b1f55846dbea86285ac
Mrmaxmeier
2021-08-05T11:02:04
fix stubbed implementation
diff --git a/src/lib.rs b/src/lib.rs index a63c478..f072cf6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,6 +19,8 @@ use crate::unix::MmapInner; #[cfg(not(any(unix, windows)))] mod stub; #[cfg(not(any(unix, windows)))] +use crate::stub::file_len; +#[cfg(not(any(unix, windows)))] use crate::stub::MmapInner; use...
2
21
5
bdd2536c627979e0febb7de1bfe73f7f42a21fae
Maxime Ripard
2021-06-10T16:58:42
Support RawFd on cfg(unix) Now that we have the infrastructure to introduce new source types for the file descriptor or handle we want to map in memory, we can introduce RawFd on Unix platforms. Since it's not clear to me if Windows can allocate mappable file handles without a backing file, the Windows implementation...
diff --git a/src/lib.rs b/src/lib.rs index 84d2522..94b22a0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,21 +25,42 @@ use std::fmt; use std::fs::File; use std::io::{Error, ErrorKind, Result}; use std::ops::{Deref, DerefMut}; +#[cfg(unix)] +use std::os::unix::io::AsRawFd; use std::slice; use std::usize; +#[cfg...
2
69
14
aa6b37cf26d86079a2be52bf6e3be3e874b1a460
Maxime Ripard
2021-06-10T16:52:23
lib: Introduce an intermediate file representation Since we want to be more flexible on the arguments to the mapping function and allow to map a file descriptor without a backing file (such as a buffer), we need to change slightly the function prototypes. In order to preserve the API, an intermediate newtype is creat...
diff --git a/src/lib.rs b/src/lib.rs index e756551..84d2522 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -28,6 +28,18 @@ use std::ops::{Deref, DerefMut}; use std::slice; use std::usize; +pub struct MmapRawDescriptor<'a>(&'a File); + +pub trait MmapAsRawDesc { + fn as_raw_desc(&self) -> MmapRawDescriptor; +} + +im...
1
47
22
7bdcb70946e42e5373aeee38a50fa76389738a69
Maxime Ripard
2021-06-10T12:02:00
unix: Rely on fstat to get the backing file length As part of our effort to move the unix implementation to rely on RawFd, we'll need to move over from the metadata() method on std::fs::File to something that could use a RawFd directly. fstat() is provided by the libc crate we already depend on, so we can just use it...
diff --git a/src/unix.rs b/src/unix.rs index 8f7a45c..452e5a7 100644 --- a/src/unix.rs +++ b/src/unix.rs @@ -235,5 +235,14 @@ fn page_size() -> usize { } pub fn file_len(file: &File) -> io::Result<usize> { - Ok(file.metadata()?.len() as usize) + unsafe { + let mut stat: libc::stat = std::mem::zeroed();...
1
10
1
5e271224c8411c89b42060294f9393cfc7b12a2a
Maxime Ripard
2021-06-10T11:58:56
lib: Move the file length retrieval to platform code The current code uses the std::io::File metadata method to retrieve the underlying file length. However, we're going to support RawFd on Unix systems, so we won't be able to rely on the platform-agnostic File methods. Let's move the function to the platform specif...
diff --git a/src/lib.rs b/src/lib.rs index c52bd46..e756551 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,11 +5,15 @@ #[cfg(windows)] mod windows; #[cfg(windows)] +use crate::windows::file_len; +#[cfg(windows)] use crate::windows::MmapInner; #[cfg(unix)] mod unix; #[cfg(unix)] +use crate::unix::file_len; +#[c...
3
14
1
4d31585e9912770d408e2947f8c7642002758461
Maxime Ripard
2021-06-10T11:53:23
lib: Make use path more consistent Most of the use declarations use the crate:: prefix but two. Make that uniform. Signed-off-by: Maxime Ripard <maxime@cerno.tech>
diff --git a/src/lib.rs b/src/lib.rs index 532ad7e..c52bd46 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,12 +5,12 @@ #[cfg(windows)] mod windows; #[cfg(windows)] -use windows::MmapInner; +use crate::windows::MmapInner; #[cfg(unix)] mod unix; #[cfg(unix)] -use unix::MmapInner; +use crate::unix::MmapInner; #...
1
2
2
c90aa339b4c3cef05d6204127dcdee238cd2f910
Evgeniy Reizner
2021-05-24T19:52:01
Clarify as_ptr, as_mut_ptr safety. Closes #13
diff --git a/src/lib.rs b/src/lib.rs index 50a4ae8..5ac0afe 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -537,10 +537,10 @@ impl MmapRaw { /// Returns a raw pointer to the memory mapped file. /// - /// # Safety - /// - /// To safely dereference this pointer, you need to make sure that the file has n...
1
6
6
7f6a88807a6ec7cebb5b2722396545cc5a7585f5
Evgeniy Reizner
2021-05-24T19:39:57
Fix formatting.
diff --git a/src/stub.rs b/src/stub.rs index 1e30585..0825c41 100644 --- a/src/stub.rs +++ b/src/stub.rs @@ -1,5 +1,5 @@ -use std::io; use std::fs::File; +use std::io; pub struct MmapInner { // Private member to prevent external construction @@ -9,7 +9,10 @@ pub struct MmapInner { impl MmapInner { fn n...
1
5
2
d5d360416eabc4c7ed6700ccb00b2fb00718d34a
jcaesar
2021-05-24T19:37:16
Stub out on unsupported platforms. Closes #17
diff --git a/src/lib.rs b/src/lib.rs index 942f02a..50a4ae8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,6 +12,11 @@ mod unix; #[cfg(unix)] use unix::MmapInner; +#[cfg(not(any(unix, windows)))] +mod stub; +#[cfg(not(any(unix, windows)))] +use crate::stub::MmapInner; + use std::fmt; use std::fs::File; use std:...
2
78
0
742e325cf77d979ff667b010f0285da747cea061
Adam Reichold
2021-03-22T18:26:55
Fix alignment computation for flush_async to match flush.
diff --git a/src/lib.rs b/src/lib.rs index 81681e7..f37514f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -946,6 +946,7 @@ mod test { .unwrap() }; (&mut mmap[..]).write_all(write).unwrap(); + mmap.flush_async_range(0, write.len()).unwrap(); mmap.flush_range(0, write.len(...
2
6
10
ea2702999d6bd1788a0473b850e55e2849dfc3eb
Adam Reichold
2021-03-22T17:05:21
Fix the Clippy lints with simple fixes.
diff --git a/src/lib.rs b/src/lib.rs index 13ae929..c0fbb8f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -222,7 +222,7 @@ impl MmapOptions { /// ``` pub unsafe fn map(&self, file: &File) -> Result<Mmap> { MmapInner::map(self.get_len(file)?, file, self.offset, self.populate) - .map(|inner| M...
3
18
18
32759d3bc9f363814e24cdd2f634356fa79650fd
Adam Reichold
2021-03-22T12:57:47
Run Rustfmt on the code base to simplify further changes.
diff --git a/src/lib.rs b/src/lib.rs index e113a4b..13ae929 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,7 +10,7 @@ use windows::MmapInner; #[cfg(unix)] mod unix; #[cfg(unix)] -use crate::unix::MmapInner; +use unix::MmapInner; use std::fmt; use std::fs::File; @@ -537,7 +537,9 @@ impl MmapRaw { /// To saf...
2
20
19