forked from mirrors/gecko-dev
Backed out changeset aee727a67f92 (bug 1875006) for causing map related build bustages. CLOSED TREE
This commit is contained in:
parent
a0bacae980
commit
67904b0b53
17 changed files with 241 additions and 572 deletions
17
Cargo.lock
generated
17
Cargo.lock
generated
|
|
@ -3367,21 +3367,14 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
|||
name = "memmap2"
|
||||
version = "0.5.999"
|
||||
dependencies = [
|
||||
"memmap2 0.8.999",
|
||||
"memmap2 0.8.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memmap2"
|
||||
version = "0.8.999"
|
||||
dependencies = [
|
||||
"memmap2 0.9.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memmap2"
|
||||
version = "0.9.3"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "45fd3a57831bf88bc63f8cebc0cf956116276e97fef3966103e96416209f7c92"
|
||||
checksum = "43a5a03cefb0d953ec0be133036f14e109412fa594edc2f77227249db66cc3ed"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
|
@ -3495,7 +3488,7 @@ dependencies = [
|
|||
"goblin 0.7.1",
|
||||
"libc",
|
||||
"mach2",
|
||||
"memmap2 0.8.999",
|
||||
"memmap2 0.8.0",
|
||||
"memoffset 0.9.0",
|
||||
"minidump-common",
|
||||
"nix 0.27.1",
|
||||
|
|
@ -4454,7 +4447,7 @@ dependencies = [
|
|||
name = "profiler_helper"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"memmap2 0.9.3",
|
||||
"memmap2 0.5.999",
|
||||
"object",
|
||||
"rustc-demangle",
|
||||
"thin-vec",
|
||||
|
|
|
|||
|
|
@ -117,8 +117,7 @@ terminal_size = { path = "build/rust/terminal_size" }
|
|||
# Patch bitflags 1.0 to 2.0
|
||||
bitflags = { path = "build/rust/bitflags" }
|
||||
|
||||
# Patch memmap2 0.5.x and 0.8 to 0.9
|
||||
memmap2_0_5 = { package = "memmap2", path = "build/rust/memmap2-0.5" }
|
||||
# Patch memmap2 0.5.x to 0.8.0
|
||||
memmap2 = { path = "build/rust/memmap2" }
|
||||
|
||||
# Patch cfg-if 0.1 to 1.0
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
[package]
|
||||
name = "memmap2"
|
||||
version = "0.5.999"
|
||||
edition = "2018"
|
||||
license = "MPL-2.0"
|
||||
|
||||
[lib]
|
||||
path = "lib.rs"
|
||||
|
||||
[dependencies.memmap2]
|
||||
version = "0.8.0"
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
pub use memmap2::*;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "memmap2"
|
||||
version = "0.8.999"
|
||||
version = "0.5.999"
|
||||
edition = "2018"
|
||||
license = "MPL-2.0"
|
||||
|
||||
|
|
@ -8,4 +8,4 @@ license = "MPL-2.0"
|
|||
path = "lib.rs"
|
||||
|
||||
[dependencies.memmap2]
|
||||
version = "0.9"
|
||||
version = "0.8.0"
|
||||
|
|
|
|||
|
|
@ -2397,11 +2397,6 @@ who = "Gabriele Svelto <gsvelto@mozilla.com>"
|
|||
criteria = "safe-to-deploy"
|
||||
delta = "0.5.9 -> 0.8.0"
|
||||
|
||||
[[audits.memmap2]]
|
||||
who = "Mike Hommey <mh+mozilla@glandium.org>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.8.0 -> 0.9.3"
|
||||
|
||||
[[audits.memoffset]]
|
||||
who = "Gabriele Svelto <gsvelto@mozilla.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{"files":{"CHANGELOG.md":"0ae77d5e9d44c0ee517e9929542ec12cd72bb7d48d7024f33f00aa1423a055e5","Cargo.lock":"91135af9527da65d252135a83a6d9ea0ec783f5fb69b2ef153a9633b6b2136a2","Cargo.toml":"78267ca3e4de47231750867ccc4086db6833881a84f4326a1c4dd93e3f377784","LICENSE-APACHE":"04ea4849dba9dcae07113850c6f1b1a69052c625210639914eee352023f750ad","LICENSE-MIT":"0d25d03b5ab49576178ad0cae7a2648d12c17ad0452fe49c07e55e4b59aa5257","README.md":"eca89ee9874278c7e977992dd782848c6f278f297ccc64362e6831861aaba0c3","examples/cat.rs":"ab0b575d19662e2d5b6c7cea2756b57530e495d56acdb4fd2b56c0ba4d768dfd","src/advice.rs":"d617cd0fc8f6dbe25f146209021c3e10822c4216c112752d09353c5f3bf974d0","src/lib.rs":"5dffdf5b09ee3ca607de268856016a10dd330e7abc037cce6a9e054100f57987","src/stub.rs":"47c8e4a4bf09c1b1623f3c4e624199daa398d7919b64029e2dbbccbe26885731","src/unix.rs":"dc9a84f19e789167864a8608a46c3a9a0fcaaa9fd009e56a5480d8127f3f0617","src/windows.rs":"c27c4cbcd2311fd6cf8ebd0486d5433fbf2d7836e9aadeb26b22b469ca5dc7e1"},"package":"45fd3a57831bf88bc63f8cebc0cf956116276e97fef3966103e96416209f7c92"}
|
||||
{"files":{"CHANGELOG.md":"d334fd0c52c9dd01592b62bb37e2bf4dd1ac176062aacfd915e90de9ffa5e376","Cargo.lock":"8634a29932d4af588c7ede3a939f725ba36455e63e2e4da76d4608e72dd8a6c2","Cargo.toml":"9e9bf7eea9db0f7d3f22aa8abaa040f7870ab8788b43d14b210f0e2ecf8f5e38","LICENSE-APACHE":"04ea4849dba9dcae07113850c6f1b1a69052c625210639914eee352023f750ad","LICENSE-MIT":"0d25d03b5ab49576178ad0cae7a2648d12c17ad0452fe49c07e55e4b59aa5257","README.md":"c7b3cd928f0d1a10faa255e2f84a2a06636e55ea3e7edd4f6334dd9215151205","examples/cat.rs":"ab0b575d19662e2d5b6c7cea2756b57530e495d56acdb4fd2b56c0ba4d768dfd","src/advice.rs":"6e88b81dcf4e7c9315484c228fe5f5a4ce5c8c06e6d8cb866e50bdd9ea8b55ec","src/lib.rs":"19b739c03e43901ce3994818b5d070d844d5a46a9b50d7e22934511722281199","src/stub.rs":"691da940edbe807a815d4a6bb3233df01bca8ab12b306ce7d67c75b4baa14e26","src/unix.rs":"f79013879989364168186dc925446a1d1f9de11999103415ae9970319fb14491","src/windows.rs":"ba820e315a31cd74fee49fcf7606af0172c0817b4a0fe3b1d113024efa79684f"},"package":"43a5a03cefb0d953ec0be133036f14e109412fa594edc2f77227249db66cc3ed"}
|
||||
28
third_party/rust/memmap2/CHANGELOG.md
vendored
28
third_party/rust/memmap2/CHANGELOG.md
vendored
|
|
@ -6,28 +6,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
## [0.9.3] - 2023-12-19
|
||||
### Fixed
|
||||
- Build on Android.
|
||||
|
||||
## [0.9.2] - 2023-12-17
|
||||
### Fixed
|
||||
- Build on FreeBSD.
|
||||
|
||||
## [0.9.1] - 2023-12-16
|
||||
### Changed
|
||||
- Added `MmapOptions::huge` method to support mapping hugetlb. Linux only.
|
||||
[@ollie-etl](https://github.com/ollie-etl)
|
||||
[@oliverbunting](https://github.com/oliverbunting)
|
||||
|
||||
## [0.9.0] - 2023-10-03
|
||||
### Changed
|
||||
- The `Advice` struct was split into two enums: `Advice` and `UncheckedAdvice`.<br>
|
||||
`Advice` can be passed to safe `advise` and `advise_range` methods.
|
||||
And `UncheckedAdvice` can be passed to unsafe `unchecked_advise`
|
||||
and `unchecked_advise_range` methods.<br>
|
||||
[@adamreichold](https://github.com/adamreichold)
|
||||
|
||||
## [0.8.0] - 2023-09-25
|
||||
### Changed
|
||||
- The `Advice` type is a struct and not an enum now.
|
||||
|
|
@ -196,11 +174,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||
### Removed
|
||||
- `winapi` dependency. [memmap-rs/pull/89](https://github.com/danburkert/memmap-rs/pull/89)
|
||||
|
||||
[Unreleased]: https://github.com/RazrFalcon/memmap2-rs/compare/v0.9.3...HEAD
|
||||
[0.9.3]: https://github.com/RazrFalcon/memmap2-rs/compare/v0.9.2...v0.9.3
|
||||
[0.9.2]: https://github.com/RazrFalcon/memmap2-rs/compare/v0.9.1...v0.9.2
|
||||
[0.9.1]: https://github.com/RazrFalcon/memmap2-rs/compare/v0.9.0...v0.9.1
|
||||
[0.9.0]: https://github.com/RazrFalcon/memmap2-rs/compare/v0.8.0...v0.9.0
|
||||
[Unreleased]: https://github.com/RazrFalcon/memmap2-rs/compare/v0.8.0...HEAD
|
||||
[0.8.0]: https://github.com/RazrFalcon/memmap2-rs/compare/v0.7.1...v0.8.0
|
||||
[0.7.1]: https://github.com/RazrFalcon/memmap2-rs/compare/v0.7.0...v0.7.1
|
||||
[0.7.0]: https://github.com/RazrFalcon/memmap2-rs/compare/v0.6.2...v0.7.0
|
||||
|
|
|
|||
195
third_party/rust/memmap2/Cargo.lock
generated
vendored
195
third_party/rust/memmap2/Cargo.lock
generated
vendored
|
|
@ -8,12 +8,6 @@ version = "1.3.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
|
|
@ -21,36 +15,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "errno"
|
||||
version = "0.3.8"
|
||||
name = "fastrand"
|
||||
version = "1.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245"
|
||||
checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.52.0",
|
||||
"instant",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fastrand"
|
||||
version = "2.0.1"
|
||||
name = "instant"
|
||||
version = "0.1.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5"
|
||||
checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.151"
|
||||
version = "0.2.146"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4"
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.4.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456"
|
||||
checksum = "f92be4933c13fd498862a9e02a3055f8a8d9c039ce33db97306fd5a6caa7f29b"
|
||||
|
||||
[[package]]
|
||||
name = "memmap2"
|
||||
version = "0.9.3"
|
||||
version = "0.8.0"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"owning_ref",
|
||||
|
|
@ -69,24 +59,20 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.4.1"
|
||||
version = "0.2.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa"
|
||||
checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.38.28"
|
||||
name = "remove_dir_all"
|
||||
version = "0.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316"
|
||||
checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
|
||||
dependencies = [
|
||||
"bitflags 2.4.1",
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
"windows-sys 0.52.0",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -97,145 +83,36 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
|
|||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.8.1"
|
||||
version = "3.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5"
|
||||
checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"fastrand",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"rustix",
|
||||
"windows-sys 0.48.0",
|
||||
"remove_dir_all",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.48.0"
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"windows-targets 0.48.5",
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.52.0"
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
|
||||
dependencies = [
|
||||
"windows-targets 0.52.0",
|
||||
]
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.48.5"
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm 0.48.5",
|
||||
"windows_aarch64_msvc 0.48.5",
|
||||
"windows_i686_gnu 0.48.5",
|
||||
"windows_i686_msvc 0.48.5",
|
||||
"windows_x86_64_gnu 0.48.5",
|
||||
"windows_x86_64_gnullvm 0.48.5",
|
||||
"windows_x86_64_msvc 0.48.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm 0.52.0",
|
||||
"windows_aarch64_msvc 0.52.0",
|
||||
"windows_i686_gnu 0.52.0",
|
||||
"windows_i686_msvc 0.52.0",
|
||||
"windows_x86_64_gnu 0.52.0",
|
||||
"windows_x86_64_gnullvm 0.52.0",
|
||||
"windows_x86_64_msvc 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
|
|
|||
2
third_party/rust/memmap2/Cargo.toml
vendored
2
third_party/rust/memmap2/Cargo.toml
vendored
|
|
@ -12,7 +12,7 @@
|
|||
[package]
|
||||
edition = "2018"
|
||||
name = "memmap2"
|
||||
version = "0.9.3"
|
||||
version = "0.8.0"
|
||||
authors = [
|
||||
"Dan Burkert <dan@danburkert.com>",
|
||||
"Yevhenii Reizner <razrfalcon@gmail.com>",
|
||||
|
|
|
|||
2
third_party/rust/memmap2/README.md
vendored
2
third_party/rust/memmap2/README.md
vendored
|
|
@ -17,7 +17,7 @@ This is a **fork** of the [memmap-rs](https://github.com/danburkert/memmap-rs) c
|
|||
- [x] read-only memory maps
|
||||
- [x] stack support (`MAP_STACK` on unix)
|
||||
- [x] executable memory maps
|
||||
- [x] huge page support (linux only)
|
||||
- [ ] huge page support
|
||||
|
||||
A list of supported/tested targets can be found in [Actions](https://github.com/RazrFalcon/memmap2-rs/actions).
|
||||
|
||||
|
|
|
|||
301
third_party/rust/memmap2/src/advice.rs
vendored
301
third_party/rust/memmap2/src/advice.rs
vendored
|
|
@ -1,32 +1,145 @@
|
|||
/// Values supported by [`Mmap::advise`][crate::Mmap::advise] and [`MmapMut::advise`][crate::MmapMut::advise] functions.
|
||||
///
|
||||
/// See [madvise()](https://man7.org/linux/man-pages/man2/madvise.2.html) map page.
|
||||
#[repr(i32)]
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
|
||||
pub enum Advice {
|
||||
#[derive(Debug, Eq, PartialEq, Hash)]
|
||||
pub struct Advice(pub(crate) libc::c_int);
|
||||
|
||||
impl Advice {
|
||||
/// **MADV_NORMAL**
|
||||
///
|
||||
/// No special treatment. This is the default.
|
||||
Normal = libc::MADV_NORMAL,
|
||||
pub fn normal() -> Self {
|
||||
Self(libc::MADV_NORMAL)
|
||||
}
|
||||
|
||||
/// **MADV_RANDOM**
|
||||
///
|
||||
/// Expect page references in random order. (Hence, read
|
||||
/// ahead may be less useful than normally.)
|
||||
Random = libc::MADV_RANDOM,
|
||||
pub fn random() -> Self {
|
||||
Self(libc::MADV_RANDOM)
|
||||
}
|
||||
|
||||
/// **MADV_SEQUENTIAL**
|
||||
///
|
||||
/// Expect page references in sequential order. (Hence, pages
|
||||
/// in the given range can be aggressively read ahead, and may
|
||||
/// be freed soon after they are accessed.)
|
||||
Sequential = libc::MADV_SEQUENTIAL,
|
||||
pub fn sequential() -> Self {
|
||||
Self(libc::MADV_SEQUENTIAL)
|
||||
}
|
||||
|
||||
/// **MADV_WILLNEED**
|
||||
///
|
||||
/// Expect access in the near future. (Hence, it might be a
|
||||
/// good idea to read some pages ahead.)
|
||||
WillNeed = libc::MADV_WILLNEED,
|
||||
pub fn will_need() -> Self {
|
||||
Self(libc::MADV_WILLNEED)
|
||||
}
|
||||
|
||||
/// **MADV_DONTNEED**
|
||||
///
|
||||
/// Do not expect access in the near future. (For the time
|
||||
/// being, the application is finished with the given range,
|
||||
/// so the kernel can free resources associated with it.)
|
||||
///
|
||||
/// After a successful MADV_DONTNEED operation, the semantics
|
||||
/// of memory access in the specified region are changed:
|
||||
/// subsequent accesses of pages in the range will succeed,
|
||||
/// but will result in either repopulating the memory contents
|
||||
/// from the up-to-date contents of the underlying mapped file
|
||||
/// (for shared file mappings, shared anonymous mappings, and
|
||||
/// shmem-based techniques such as System V shared memory
|
||||
/// segments) or zero-fill-on-demand pages for anonymous
|
||||
/// private mappings.
|
||||
///
|
||||
/// Note that, when applied to shared mappings, MADV_DONTNEED
|
||||
/// might not lead to immediate freeing of the pages in the
|
||||
/// range. The kernel is free to delay freeing the pages
|
||||
/// until an appropriate moment. The resident set size (RSS)
|
||||
/// of the calling process will be immediately reduced
|
||||
/// however.
|
||||
///
|
||||
/// **MADV_DONTNEED** cannot be applied to locked pages, Huge TLB
|
||||
/// pages, or VM_PFNMAP pages. (Pages marked with the kernel-
|
||||
/// internal VM_PFNMAP flag are special memory areas that are
|
||||
/// not managed by the virtual memory subsystem. Such pages
|
||||
/// are typically created by device drivers that map the pages
|
||||
/// into user space.)
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// Using the returned value with conceptually write to the
|
||||
/// mapped pages, i.e. borrowing the mapping when the pages
|
||||
/// are freed results in undefined behaviour.
|
||||
pub unsafe fn dont_need() -> Self {
|
||||
Self(libc::MADV_DONTNEED)
|
||||
}
|
||||
|
||||
//
|
||||
// The rest are Linux-specific
|
||||
//
|
||||
/// **MADV_FREE** - Linux (since Linux 4.5) and Darwin
|
||||
///
|
||||
/// The application no longer requires the pages in the range
|
||||
/// specified by addr and len. The kernel can thus free these
|
||||
/// pages, but the freeing could be delayed until memory
|
||||
/// pressure occurs. For each of the pages that has been
|
||||
/// marked to be freed but has not yet been freed, the free
|
||||
/// operation will be canceled if the caller writes into the
|
||||
/// page. After a successful MADV_FREE operation, any stale
|
||||
/// data (i.e., dirty, unwritten pages) will be lost when the
|
||||
/// kernel frees the pages. However, subsequent writes to
|
||||
/// pages in the range will succeed and then kernel cannot
|
||||
/// free those dirtied pages, so that the caller can always
|
||||
/// see just written data. If there is no subsequent write,
|
||||
/// the kernel can free the pages at any time. Once pages in
|
||||
/// the range have been freed, the caller will see zero-fill-
|
||||
/// on-demand pages upon subsequent page references.
|
||||
///
|
||||
/// The MADV_FREE operation can be applied only to private
|
||||
/// anonymous pages (see mmap(2)). In Linux before version
|
||||
/// 4.12, when freeing pages on a swapless system, the pages
|
||||
/// in the given range are freed instantly, regardless of
|
||||
/// memory pressure.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// Using the returned value with conceptually write to the
|
||||
/// mapped pages, i.e. borrowing the mapping while the pages
|
||||
/// are still being freed results in undefined behaviour.
|
||||
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "ios"))]
|
||||
pub unsafe fn free() -> Self {
|
||||
Self(libc::MADV_FREE)
|
||||
}
|
||||
|
||||
/// **MADV_REMOVE** - Linux only (since Linux 2.6.16)
|
||||
///
|
||||
/// Free up a given range of pages and its associated backing
|
||||
/// store. This is equivalent to punching a hole in the
|
||||
/// corresponding byte range of the backing store (see
|
||||
/// fallocate(2)). Subsequent accesses in the specified
|
||||
/// address range will see bytes containing zero.
|
||||
///
|
||||
/// The specified address range must be mapped shared and
|
||||
/// writable. This flag cannot be applied to locked pages,
|
||||
/// Huge TLB pages, or VM_PFNMAP pages.
|
||||
///
|
||||
/// In the initial implementation, only tmpfs(5) was supported
|
||||
/// **MADV_REMOVE**; but since Linux 3.5, any filesystem which
|
||||
/// supports the fallocate(2) FALLOC_FL_PUNCH_HOLE mode also
|
||||
/// supports MADV_REMOVE. Hugetlbfs fails with the error
|
||||
/// EINVAL and other filesystems fail with the error
|
||||
/// EOPNOTSUPP.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// Using the returned value with conceptually write to the
|
||||
/// mapped pages, i.e. borrowing the mapping when the pages
|
||||
/// are freed results in undefined behaviour.
|
||||
#[cfg(target_os = "linux")]
|
||||
pub unsafe fn remove() -> Self {
|
||||
Self(libc::MADV_REMOVE)
|
||||
}
|
||||
|
||||
/// **MADV_DONTFORK** - Linux only (since Linux 2.6.16)
|
||||
///
|
||||
|
|
@ -37,14 +150,18 @@ pub enum Advice {
|
|||
/// relocations cause problems for hardware that DMAs into the
|
||||
/// page.)
|
||||
#[cfg(target_os = "linux")]
|
||||
DontFork = libc::MADV_DONTFORK,
|
||||
pub fn dont_fork() -> Self {
|
||||
Self(libc::MADV_DONTFORK)
|
||||
}
|
||||
|
||||
/// **MADV_DOFORK** - Linux only (since Linux 2.6.16)
|
||||
///
|
||||
/// Undo the effect of MADV_DONTFORK, restoring the default
|
||||
/// behavior, whereby a mapping is inherited across fork(2).
|
||||
#[cfg(target_os = "linux")]
|
||||
DoFork = libc::MADV_DOFORK,
|
||||
pub fn do_fork() -> Self {
|
||||
Self(libc::MADV_DOFORK)
|
||||
}
|
||||
|
||||
/// **MADV_MERGEABLE** - Linux only (since Linux 2.6.32)
|
||||
///
|
||||
|
|
@ -67,7 +184,9 @@ pub enum Advice {
|
|||
/// available only if the kernel was configured with
|
||||
/// CONFIG_KSM.
|
||||
#[cfg(target_os = "linux")]
|
||||
Mergeable = libc::MADV_MERGEABLE,
|
||||
pub fn mergeable() -> Self {
|
||||
Self(libc::MADV_MERGEABLE)
|
||||
}
|
||||
|
||||
/// **MADV_UNMERGEABLE** - Linux only (since Linux 2.6.32)
|
||||
///
|
||||
|
|
@ -76,7 +195,9 @@ pub enum Advice {
|
|||
/// it had merged in the address range specified by addr and
|
||||
/// length.
|
||||
#[cfg(target_os = "linux")]
|
||||
Unmergeable = libc::MADV_UNMERGEABLE,
|
||||
pub fn unmergeable() -> Self {
|
||||
Self(libc::MADV_UNMERGEABLE)
|
||||
}
|
||||
|
||||
/// **MADV_HUGEPAGE** - Linux only (since Linux 2.6.38)
|
||||
///
|
||||
|
|
@ -115,14 +236,18 @@ pub enum Advice {
|
|||
/// available only if the kernel was configured with
|
||||
/// CONFIG_TRANSPARENT_HUGEPAGE.
|
||||
#[cfg(target_os = "linux")]
|
||||
HugePage = libc::MADV_HUGEPAGE,
|
||||
pub fn huge_page() -> Self {
|
||||
Self(libc::MADV_HUGEPAGE)
|
||||
}
|
||||
|
||||
/// **MADV_NOHUGEPAGE** - Linux only (since Linux 2.6.38)
|
||||
///
|
||||
/// Ensures that memory in the address range specified by addr
|
||||
/// and length will not be backed by transparent hugepages.
|
||||
#[cfg(target_os = "linux")]
|
||||
NoHugePage = libc::MADV_NOHUGEPAGE,
|
||||
pub fn no_huge_page() -> Self {
|
||||
Self(libc::MADV_NOHUGEPAGE)
|
||||
}
|
||||
|
||||
/// **MADV_DONTDUMP** - Linux only (since Linux 3.4)
|
||||
///
|
||||
|
|
@ -134,13 +259,17 @@ pub enum Advice {
|
|||
/// set via the `/proc/[pid]/coredump_filter` file (see
|
||||
/// core(5)).
|
||||
#[cfg(target_os = "linux")]
|
||||
DontDump = libc::MADV_DONTDUMP,
|
||||
pub fn dont_dump() -> Self {
|
||||
Self(libc::MADV_DONTDUMP)
|
||||
}
|
||||
|
||||
/// **MADV_DODUMP** - Linux only (since Linux 3.4)
|
||||
///
|
||||
/// Undo the effect of an earlier MADV_DONTDUMP.
|
||||
#[cfg(target_os = "linux")]
|
||||
DoDump = libc::MADV_DODUMP,
|
||||
pub fn do_dump() -> Self {
|
||||
Self(libc::MADV_DODUMP)
|
||||
}
|
||||
|
||||
/// **MADV_HWPOISON** - Linux only (since Linux 2.6.32)
|
||||
///
|
||||
|
|
@ -155,7 +284,9 @@ pub enum Advice {
|
|||
/// handling code; it is available only if the kernel was
|
||||
/// configured with CONFIG_MEMORY_FAILURE.
|
||||
#[cfg(target_os = "linux")]
|
||||
HwPoison = libc::MADV_HWPOISON,
|
||||
pub fn hw_poison() -> Self {
|
||||
Self(libc::MADV_HWPOISON)
|
||||
}
|
||||
|
||||
/// **MADV_POPULATE_READ** - Linux only (since Linux 5.14)
|
||||
///
|
||||
|
|
@ -190,7 +321,9 @@ pub enum Advice {
|
|||
/// Note that with MADV_POPULATE_READ, the process can be killed
|
||||
/// at any moment when the system runs out of memory.
|
||||
#[cfg(target_os = "linux")]
|
||||
PopulateRead = libc::MADV_POPULATE_READ,
|
||||
pub fn populate_read() -> Self {
|
||||
Self(libc::MADV_POPULATE_READ)
|
||||
}
|
||||
|
||||
/// **MADV_POPULATE_WRITE** - Linux only (since Linux 5.14)
|
||||
///
|
||||
|
|
@ -222,7 +355,9 @@ pub enum Advice {
|
|||
/// Note that with MADV_POPULATE_WRITE, the process can be killed
|
||||
/// at any moment when the system runs out of memory.
|
||||
#[cfg(target_os = "linux")]
|
||||
PopulateWrite = libc::MADV_POPULATE_WRITE,
|
||||
pub fn populate_write() -> Self {
|
||||
Self(libc::MADV_POPULATE_WRITE)
|
||||
}
|
||||
|
||||
/// **MADV_ZERO_WIRED_PAGES** - Darwin only
|
||||
///
|
||||
|
|
@ -231,123 +366,9 @@ pub enum Advice {
|
|||
/// a munmap(2) without a preceding munlock(2) or the application quits). This is used
|
||||
/// with madvise() system call.
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
ZeroWiredPages = libc::MADV_ZERO_WIRED_PAGES,
|
||||
}
|
||||
|
||||
/// Values supported by [`Mmap::unsafe_advise`][crate::Mmap::unsafe_advise] and [`MmapMut::unsafe_advise`][crate::MmapMut::unsafe_advise] functions.
|
||||
///
|
||||
/// These flags can be passed to the [madvise (2)][man_page] system call
|
||||
/// and effects on the mapped pages which are conceptually writes,
|
||||
/// i.e. the change the observable contents of these pages which
|
||||
/// implies undefined behaviour if the mapping is still borrowed.
|
||||
///
|
||||
/// Hence, these potentially unsafe flags must be used with the unsafe
|
||||
/// methods and the programmer has to justify that the code
|
||||
/// does not keep any borrows of the mapping active while the mapped pages
|
||||
/// are updated by the kernel's memory management subsystem.
|
||||
///
|
||||
/// [man_page]: https://man7.org/linux/man-pages/man2/madvise.2.html
|
||||
#[repr(i32)]
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
|
||||
pub enum UncheckedAdvice {
|
||||
/// **MADV_DONTNEED**
|
||||
///
|
||||
/// Do not expect access in the near future. (For the time
|
||||
/// being, the application is finished with the given range,
|
||||
/// so the kernel can free resources associated with it.)
|
||||
///
|
||||
/// After a successful MADV_DONTNEED operation, the semantics
|
||||
/// of memory access in the specified region are changed:
|
||||
/// subsequent accesses of pages in the range will succeed,
|
||||
/// but will result in either repopulating the memory contents
|
||||
/// from the up-to-date contents of the underlying mapped file
|
||||
/// (for shared file mappings, shared anonymous mappings, and
|
||||
/// shmem-based techniques such as System V shared memory
|
||||
/// segments) or zero-fill-on-demand pages for anonymous
|
||||
/// private mappings.
|
||||
///
|
||||
/// Note that, when applied to shared mappings, MADV_DONTNEED
|
||||
/// might not lead to immediate freeing of the pages in the
|
||||
/// range. The kernel is free to delay freeing the pages
|
||||
/// until an appropriate moment. The resident set size (RSS)
|
||||
/// of the calling process will be immediately reduced
|
||||
/// however.
|
||||
///
|
||||
/// **MADV_DONTNEED** cannot be applied to locked pages, Huge TLB
|
||||
/// pages, or VM_PFNMAP pages. (Pages marked with the kernel-
|
||||
/// internal VM_PFNMAP flag are special memory areas that are
|
||||
/// not managed by the virtual memory subsystem. Such pages
|
||||
/// are typically created by device drivers that map the pages
|
||||
/// into user space.)
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// Using the returned value with conceptually write to the
|
||||
/// mapped pages, i.e. borrowing the mapping when the pages
|
||||
/// are freed results in undefined behaviour.
|
||||
DontNeed = libc::MADV_DONTNEED,
|
||||
|
||||
//
|
||||
// The rest are Linux-specific
|
||||
//
|
||||
/// **MADV_FREE** - Linux (since Linux 4.5) and Darwin
|
||||
///
|
||||
/// The application no longer requires the pages in the range
|
||||
/// specified by addr and len. The kernel can thus free these
|
||||
/// pages, but the freeing could be delayed until memory
|
||||
/// pressure occurs. For each of the pages that has been
|
||||
/// marked to be freed but has not yet been freed, the free
|
||||
/// operation will be canceled if the caller writes into the
|
||||
/// page. After a successful MADV_FREE operation, any stale
|
||||
/// data (i.e., dirty, unwritten pages) will be lost when the
|
||||
/// kernel frees the pages. However, subsequent writes to
|
||||
/// pages in the range will succeed and then kernel cannot
|
||||
/// free those dirtied pages, so that the caller can always
|
||||
/// see just written data. If there is no subsequent write,
|
||||
/// the kernel can free the pages at any time. Once pages in
|
||||
/// the range have been freed, the caller will see zero-fill-
|
||||
/// on-demand pages upon subsequent page references.
|
||||
///
|
||||
/// The MADV_FREE operation can be applied only to private
|
||||
/// anonymous pages (see mmap(2)). In Linux before version
|
||||
/// 4.12, when freeing pages on a swapless system, the pages
|
||||
/// in the given range are freed instantly, regardless of
|
||||
/// memory pressure.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// Using the returned value with conceptually write to the
|
||||
/// mapped pages, i.e. borrowing the mapping while the pages
|
||||
/// are still being freed results in undefined behaviour.
|
||||
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "ios"))]
|
||||
Free = libc::MADV_FREE,
|
||||
|
||||
/// **MADV_REMOVE** - Linux only (since Linux 2.6.16)
|
||||
///
|
||||
/// Free up a given range of pages and its associated backing
|
||||
/// store. This is equivalent to punching a hole in the
|
||||
/// corresponding byte range of the backing store (see
|
||||
/// fallocate(2)). Subsequent accesses in the specified
|
||||
/// address range will see bytes containing zero.
|
||||
///
|
||||
/// The specified address range must be mapped shared and
|
||||
/// writable. This flag cannot be applied to locked pages,
|
||||
/// Huge TLB pages, or VM_PFNMAP pages.
|
||||
///
|
||||
/// In the initial implementation, only tmpfs(5) was supported
|
||||
/// **MADV_REMOVE**; but since Linux 3.5, any filesystem which
|
||||
/// supports the fallocate(2) FALLOC_FL_PUNCH_HOLE mode also
|
||||
/// supports MADV_REMOVE. Hugetlbfs fails with the error
|
||||
/// EINVAL and other filesystems fail with the error
|
||||
/// EOPNOTSUPP.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// Using the returned value with conceptually write to the
|
||||
/// mapped pages, i.e. borrowing the mapping when the pages
|
||||
/// are freed results in undefined behaviour.
|
||||
#[cfg(target_os = "linux")]
|
||||
Remove = libc::MADV_REMOVE,
|
||||
pub fn zero_wired_pages() -> Self {
|
||||
Self(libc::MADV_ZERO_WIRED_PAGES)
|
||||
}
|
||||
|
||||
/// **MADV_FREE_REUSABLE** - Darwin only
|
||||
///
|
||||
|
|
@ -359,7 +380,9 @@ pub enum UncheckedAdvice {
|
|||
/// mapped pages, i.e. borrowing the mapping while the pages
|
||||
/// are still being freed results in undefined behaviour.
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
FreeReusable = libc::MADV_FREE_REUSABLE,
|
||||
pub unsafe fn free_reusable() -> Self {
|
||||
Self(libc::MADV_FREE_REUSABLE)
|
||||
}
|
||||
|
||||
/// **MADV_FREE_REUSE** - Darwin only
|
||||
///
|
||||
|
|
@ -373,7 +396,9 @@ pub enum UncheckedAdvice {
|
|||
/// mapped pages, i.e. borrowing the mapping while the pages
|
||||
/// are still being freed results in undefined behaviour.
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
FreeReuse = libc::MADV_FREE_REUSE,
|
||||
pub unsafe fn free_reuse() -> Self {
|
||||
Self(libc::MADV_FREE_REUSE)
|
||||
}
|
||||
}
|
||||
|
||||
// Future expansion:
|
||||
|
|
|
|||
188
third_party/rust/memmap2/src/lib.rs
vendored
188
third_party/rust/memmap2/src/lib.rs
vendored
|
|
@ -47,7 +47,7 @@ use crate::os::{file_len, MmapInner};
|
|||
#[cfg(unix)]
|
||||
mod advice;
|
||||
#[cfg(unix)]
|
||||
pub use crate::advice::{Advice, UncheckedAdvice};
|
||||
pub use crate::advice::Advice;
|
||||
|
||||
use std::fmt;
|
||||
#[cfg(not(any(unix, windows)))]
|
||||
|
|
@ -140,7 +140,6 @@ where
|
|||
pub struct MmapOptions {
|
||||
offset: u64,
|
||||
len: Option<usize>,
|
||||
huge: Option<u8>,
|
||||
stack: bool,
|
||||
populate: bool,
|
||||
}
|
||||
|
|
@ -282,30 +281,6 @@ impl MmapOptions {
|
|||
self
|
||||
}
|
||||
|
||||
/// Configures the anonymous memory map to be allocated using huge pages.
|
||||
///
|
||||
/// This option corresponds to the `MAP_HUGETLB` flag on Linux. It has no effect on Windows.
|
||||
///
|
||||
/// The size of the requested page can be specified in page bits. If not provided, the system
|
||||
/// default is requested. The requested length should be a multiple of this, or the mapping
|
||||
/// will fail.
|
||||
///
|
||||
/// This option has no effect on file-backed memory maps.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use memmap2::MmapOptions;
|
||||
///
|
||||
/// # fn main() -> std::io::Result<()> {
|
||||
/// let stack = MmapOptions::new().huge(Some(21)).len(2*1024*1024).map_anon();
|
||||
/// # Ok(())
|
||||
/// # }
|
||||
/// ```
|
||||
pub fn huge(&mut self, page_bits: Option<u8>) -> &mut Self {
|
||||
self.huge = Some(page_bits.unwrap_or(0));
|
||||
self
|
||||
}
|
||||
/// Populate (prefault) page tables for a mapping.
|
||||
///
|
||||
/// For a file mapping, this causes read-ahead on the file. This will help to reduce blocking on page faults later.
|
||||
|
|
@ -509,8 +484,7 @@ impl MmapOptions {
|
|||
));
|
||||
}
|
||||
|
||||
MmapInner::map_anon(len, self.stack, self.populate, self.huge)
|
||||
.map(|inner| MmapMut { inner })
|
||||
MmapInner::map_anon(len, self.stack, self.populate).map(|inner| MmapMut { inner })
|
||||
}
|
||||
|
||||
/// Creates a raw memory map.
|
||||
|
|
@ -665,55 +639,24 @@ impl Mmap {
|
|||
Ok(MmapMut { inner: self.inner })
|
||||
}
|
||||
|
||||
/// Advise OS how this memory map will be accessed.
|
||||
///
|
||||
/// Only supported on Unix.
|
||||
/// Advise OS how this memory map will be accessed. Only supported on Unix.
|
||||
///
|
||||
/// 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
|
||||
.advise(advice as libc::c_int, 0, self.inner.len())
|
||||
}
|
||||
|
||||
/// Advise OS how this memory map will be accessed.
|
||||
///
|
||||
/// Used with the [unchecked flags][UncheckedAdvice]. Only supported on Unix.
|
||||
///
|
||||
/// See [madvise()](https://man7.org/linux/man-pages/man2/madvise.2.html) map page.
|
||||
#[cfg(unix)]
|
||||
pub unsafe fn unchecked_advise(&self, advice: UncheckedAdvice) -> Result<()> {
|
||||
self.inner
|
||||
.advise(advice as libc::c_int, 0, self.inner.len())
|
||||
self.inner.advise(advice, 0, self.inner.len())
|
||||
}
|
||||
|
||||
/// Advise OS how this range of memory map will be accessed.
|
||||
///
|
||||
/// Only supported on Unix.
|
||||
///
|
||||
/// The offset and length must be in the bounds of the memory map.
|
||||
///
|
||||
/// Only supported on Unix.
|
||||
///
|
||||
/// See [madvise()](https://man7.org/linux/man-pages/man2/madvise.2.html) map page.
|
||||
#[cfg(unix)]
|
||||
pub fn advise_range(&self, advice: Advice, offset: usize, len: usize) -> Result<()> {
|
||||
self.inner.advise(advice as libc::c_int, offset, len)
|
||||
}
|
||||
|
||||
/// Advise OS how this range of memory map will be accessed.
|
||||
///
|
||||
/// Used with the [unchecked flags][UncheckedAdvice]. Only supported on Unix.
|
||||
///
|
||||
/// The offset and length must be in the bounds of the memory map.
|
||||
///
|
||||
/// See [madvise()](https://man7.org/linux/man-pages/man2/madvise.2.html) map page.
|
||||
#[cfg(unix)]
|
||||
pub unsafe fn unchecked_advise_range(
|
||||
&self,
|
||||
advice: UncheckedAdvice,
|
||||
offset: usize,
|
||||
len: usize,
|
||||
) -> Result<()> {
|
||||
self.inner.advise(advice as libc::c_int, offset, len)
|
||||
self.inner.advise(advice, offset, len)
|
||||
}
|
||||
|
||||
/// Lock the whole memory map into RAM. Only supported on Unix.
|
||||
|
|
@ -909,26 +852,12 @@ impl MmapRaw {
|
|||
self.inner.flush_async(offset, len)
|
||||
}
|
||||
|
||||
/// Advise OS how this memory map will be accessed.
|
||||
///
|
||||
/// Only supported on Unix.
|
||||
/// Advise OS how this memory map will be accessed. Only supported on Unix.
|
||||
///
|
||||
/// 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
|
||||
.advise(advice as libc::c_int, 0, self.inner.len())
|
||||
}
|
||||
|
||||
/// Advise OS how this memory map will be accessed.
|
||||
///
|
||||
/// Used with the [unchecked flags][UncheckedAdvice]. Only supported on Unix.
|
||||
///
|
||||
/// See [madvise()](https://man7.org/linux/man-pages/man2/madvise.2.html) map page.
|
||||
#[cfg(unix)]
|
||||
pub unsafe fn unchecked_advise(&self, advice: UncheckedAdvice) -> Result<()> {
|
||||
self.inner
|
||||
.advise(advice as libc::c_int, 0, self.inner.len())
|
||||
self.inner.advise(advice, 0, self.inner.len())
|
||||
}
|
||||
|
||||
/// Advise OS how this range of memory map will be accessed.
|
||||
|
|
@ -940,24 +869,7 @@ impl MmapRaw {
|
|||
/// See [madvise()](https://man7.org/linux/man-pages/man2/madvise.2.html) map page.
|
||||
#[cfg(unix)]
|
||||
pub fn advise_range(&self, advice: Advice, offset: usize, len: usize) -> Result<()> {
|
||||
self.inner.advise(advice as libc::c_int, offset, len)
|
||||
}
|
||||
|
||||
/// Advise OS how this range of memory map will be accessed.
|
||||
///
|
||||
/// Used with the [unchecked flags][UncheckedAdvice]. Only supported on Unix.
|
||||
///
|
||||
/// The offset and length must be in the bounds of the memory map.
|
||||
///
|
||||
/// See [madvise()](https://man7.org/linux/man-pages/man2/madvise.2.html) map page.
|
||||
#[cfg(unix)]
|
||||
pub unsafe fn unchecked_advise_range(
|
||||
&self,
|
||||
advice: UncheckedAdvice,
|
||||
offset: usize,
|
||||
len: usize,
|
||||
) -> Result<()> {
|
||||
self.inner.advise(advice as libc::c_int, offset, len)
|
||||
self.inner.advise(advice, offset, len)
|
||||
}
|
||||
|
||||
/// Lock the whole memory map into RAM. Only supported on Unix.
|
||||
|
|
@ -1230,55 +1142,24 @@ impl MmapMut {
|
|||
Ok(Mmap { inner: self.inner })
|
||||
}
|
||||
|
||||
/// Advise OS how this memory map will be accessed.
|
||||
///
|
||||
/// Only supported on Unix.
|
||||
/// Advise OS how this memory map will be accessed. Only supported on Unix.
|
||||
///
|
||||
/// 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
|
||||
.advise(advice as libc::c_int, 0, self.inner.len())
|
||||
}
|
||||
|
||||
/// Advise OS how this memory map will be accessed.
|
||||
///
|
||||
/// Used with the [unchecked flags][UncheckedAdvice]. Only supported on Unix.
|
||||
///
|
||||
/// See [madvise()](https://man7.org/linux/man-pages/man2/madvise.2.html) map page.
|
||||
#[cfg(unix)]
|
||||
pub unsafe fn unchecked_advise(&self, advice: UncheckedAdvice) -> Result<()> {
|
||||
self.inner
|
||||
.advise(advice as libc::c_int, 0, self.inner.len())
|
||||
self.inner.advise(advice, 0, self.inner.len())
|
||||
}
|
||||
|
||||
/// Advise OS how this range of memory map will be accessed.
|
||||
///
|
||||
/// Only supported on Unix.
|
||||
///
|
||||
/// The offset and length must be in the bounds of the memory map.
|
||||
///
|
||||
/// Only supported on Unix.
|
||||
///
|
||||
/// See [madvise()](https://man7.org/linux/man-pages/man2/madvise.2.html) map page.
|
||||
#[cfg(unix)]
|
||||
pub fn advise_range(&self, advice: Advice, offset: usize, len: usize) -> Result<()> {
|
||||
self.inner.advise(advice as libc::c_int, offset, len)
|
||||
}
|
||||
|
||||
/// Advise OS how this range of memory map will be accessed.
|
||||
///
|
||||
/// Used with the [unchecked flags][UncheckedAdvice]. Only supported on Unix.
|
||||
///
|
||||
/// The offset and length must be in the bounds of the memory map.
|
||||
///
|
||||
/// See [madvise()](https://man7.org/linux/man-pages/man2/madvise.2.html) map page.
|
||||
#[cfg(unix)]
|
||||
pub fn unchecked_advise_range(
|
||||
&self,
|
||||
advice: UncheckedAdvice,
|
||||
offset: usize,
|
||||
len: usize,
|
||||
) -> Result<()> {
|
||||
self.inner.advise(advice as libc::c_int, offset, len)
|
||||
self.inner.advise(advice, offset, len)
|
||||
}
|
||||
|
||||
/// Lock the whole memory map into RAM. Only supported on Unix.
|
||||
|
|
@ -1935,7 +1816,7 @@ mod test {
|
|||
|
||||
// Test MmapMut::advise
|
||||
let mut mmap = unsafe { MmapMut::map_mut(&file).unwrap() };
|
||||
mmap.advise(Advice::Random)
|
||||
mmap.advise(Advice::random())
|
||||
.expect("mmap advising should be supported on unix");
|
||||
|
||||
let len = mmap.len();
|
||||
|
|
@ -1947,7 +1828,7 @@ mod test {
|
|||
// check that the mmap is empty
|
||||
assert_eq!(&zeros[..], &mmap[..]);
|
||||
|
||||
mmap.advise_range(Advice::Sequential, 0, mmap.len())
|
||||
mmap.advise_range(Advice::sequential(), 0, mmap.len())
|
||||
.expect("mmap advising should be supported on unix");
|
||||
|
||||
// write values into the mmap
|
||||
|
|
@ -1959,7 +1840,7 @@ mod test {
|
|||
// Set advice and Read from the read-only map
|
||||
let mmap = unsafe { Mmap::map(&file).unwrap() };
|
||||
|
||||
mmap.advise(Advice::Random)
|
||||
mmap.advise(Advice::random())
|
||||
.expect("mmap advising should be supported on unix");
|
||||
|
||||
// read values back
|
||||
|
|
@ -1969,47 +1850,18 @@ mod test {
|
|||
#[test]
|
||||
#[cfg(target_os = "linux")]
|
||||
fn advise_writes_unsafely() {
|
||||
let page_size = unsafe { libc::sysconf(libc::_SC_PAGESIZE) as usize };
|
||||
|
||||
let mut mmap = MmapMut::map_anon(page_size).unwrap();
|
||||
let mut mmap = MmapMut::map_anon(4096).unwrap();
|
||||
mmap.as_mut().fill(255);
|
||||
let mmap = mmap.make_read_only().unwrap();
|
||||
|
||||
let a = mmap.as_ref()[0];
|
||||
unsafe {
|
||||
mmap.unchecked_advise(crate::UncheckedAdvice::DontNeed)
|
||||
.unwrap();
|
||||
}
|
||||
mmap.advise(unsafe { Advice::dont_need() }).unwrap();
|
||||
let b = mmap.as_ref()[0];
|
||||
|
||||
assert_eq!(a, 255);
|
||||
assert_eq!(b, 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "linux")]
|
||||
fn advise_writes_unsafely_to_part_of_map() {
|
||||
let page_size = unsafe { libc::sysconf(libc::_SC_PAGESIZE) as usize };
|
||||
|
||||
let mut mmap = MmapMut::map_anon(2 * page_size).unwrap();
|
||||
mmap.as_mut().fill(255);
|
||||
let mmap = mmap.make_read_only().unwrap();
|
||||
|
||||
let a = mmap.as_ref()[0];
|
||||
let b = mmap.as_ref()[page_size];
|
||||
unsafe {
|
||||
mmap.unchecked_advise_range(crate::UncheckedAdvice::DontNeed, page_size, page_size)
|
||||
.unwrap();
|
||||
}
|
||||
let c = mmap.as_ref()[0];
|
||||
let d = mmap.as_ref()[page_size];
|
||||
|
||||
assert_eq!(a, 255);
|
||||
assert_eq!(b, 255);
|
||||
assert_eq!(c, 255);
|
||||
assert_eq!(d, 0);
|
||||
}
|
||||
|
||||
/// Returns true if a non-zero amount of memory is locked.
|
||||
#[cfg(target_os = "linux")]
|
||||
fn is_locked() -> bool {
|
||||
|
|
|
|||
2
third_party/rust/memmap2/src/stub.rs
vendored
2
third_party/rust/memmap2/src/stub.rs
vendored
|
|
@ -36,7 +36,7 @@ impl MmapInner {
|
|||
MmapInner::new()
|
||||
}
|
||||
|
||||
pub fn map_anon(_: usize, _: bool, _: bool, _: Option<u8>) -> io::Result<MmapInner> {
|
||||
pub fn map_anon(_: usize, _: bool, _: bool) -> io::Result<MmapInner> {
|
||||
MmapInner::new()
|
||||
}
|
||||
|
||||
|
|
|
|||
39
third_party/rust/memmap2/src/unix.rs
vendored
39
third_party/rust/memmap2/src/unix.rs
vendored
|
|
@ -6,6 +6,8 @@ use std::os::unix::io::{FromRawFd, RawFd};
|
|||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
use std::{io, ptr};
|
||||
|
||||
use crate::advice::Advice;
|
||||
|
||||
#[cfg(any(
|
||||
all(target_os = "linux", not(target_arch = "mips")),
|
||||
target_os = "freebsd",
|
||||
|
|
@ -26,24 +28,6 @@ const MAP_POPULATE: libc::c_int = libc::MAP_POPULATE;
|
|||
#[cfg(not(any(target_os = "linux", target_os = "android")))]
|
||||
const MAP_POPULATE: libc::c_int = 0;
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
const MAP_HUGETLB: libc::c_int = libc::MAP_HUGETLB;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
const MAP_HUGE_MASK: libc::c_int = libc::MAP_HUGE_MASK;
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
const MAP_HUGE_SHIFT: libc::c_int = libc::MAP_HUGE_SHIFT;
|
||||
|
||||
#[cfg(not(any(target_os = "linux", target_os = "android")))]
|
||||
const MAP_HUGETLB: libc::c_int = 0;
|
||||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
const MAP_HUGE_MASK: libc::c_int = 0;
|
||||
|
||||
#[cfg(not(any(target_os = "linux", target_os = "android")))]
|
||||
const MAP_HUGE_SHIFT: libc::c_int = 0;
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
all(target_os = "linux", not(target_env = "musl"))
|
||||
|
|
@ -279,24 +263,15 @@ impl MmapInner {
|
|||
}
|
||||
|
||||
/// Open an anonymous memory map.
|
||||
pub fn map_anon(
|
||||
len: usize,
|
||||
stack: bool,
|
||||
populate: bool,
|
||||
huge: Option<u8>,
|
||||
) -> io::Result<MmapInner> {
|
||||
pub fn map_anon(len: usize, stack: bool, populate: bool) -> io::Result<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 } else { 0 };
|
||||
let offset = huge
|
||||
.map(|mask| ((mask as u64) & (MAP_HUGE_MASK as u64)) << MAP_HUGE_SHIFT)
|
||||
.unwrap_or(0);
|
||||
MmapInner::new(
|
||||
len,
|
||||
libc::PROT_READ | libc::PROT_WRITE,
|
||||
libc::MAP_PRIVATE | libc::MAP_ANON | stack | populate | hugetlb,
|
||||
libc::MAP_PRIVATE | libc::MAP_ANON | stack | populate,
|
||||
-1,
|
||||
offset,
|
||||
0,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -367,12 +342,12 @@ impl MmapInner {
|
|||
self.len
|
||||
}
|
||||
|
||||
pub fn advise(&self, advice: libc::c_int, offset: usize, len: usize) -> io::Result<()> {
|
||||
pub fn advise(&self, advice: Advice, offset: usize, len: usize) -> io::Result<()> {
|
||||
let alignment = (self.ptr as usize + offset) % page_size();
|
||||
let offset = offset as isize - alignment as isize;
|
||||
let len = len + alignment;
|
||||
unsafe {
|
||||
if libc::madvise(self.ptr.offset(offset), len, advice) != 0 {
|
||||
if libc::madvise(self.ptr.offset(offset), len, advice.0) != 0 {
|
||||
Err(io::Error::last_os_error())
|
||||
} else {
|
||||
Ok(())
|
||||
|
|
|
|||
7
third_party/rust/memmap2/src/windows.rs
vendored
7
third_party/rust/memmap2/src/windows.rs
vendored
|
|
@ -343,12 +343,7 @@ impl MmapInner {
|
|||
Ok(inner)
|
||||
}
|
||||
|
||||
pub fn map_anon(
|
||||
len: usize,
|
||||
_stack: bool,
|
||||
_populate: bool,
|
||||
_huge: Option<u8>,
|
||||
) -> io::Result<MmapInner> {
|
||||
pub fn map_anon(len: usize, _stack: bool, _populate: bool) -> io::Result<MmapInner> {
|
||||
// Ensure a non-zero length for the underlying mapping
|
||||
let mapped_len = len.max(1);
|
||||
unsafe {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ authors = ["Markus Stange <mstange@themasta.com>"]
|
|||
license = "MPL-2.0"
|
||||
|
||||
[dependencies]
|
||||
memmap2 = "0.9"
|
||||
memmap2 = "0.5"
|
||||
rustc-demangle = "0.1"
|
||||
uuid = "1.0"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue