util: make `mmapread()` work on Windows again
522b4d729e89 started referencing `mmap.MAP_PRIVATE`, but that's not available on
Windows, so `hg version` worked, but `make local` did not. That commit also
started calling the constructor with the fine-grained `flags` and `prot` args,
but those aren't available on Windows either[1] (though the backing C code
doesn't seem conditionalized to disallow usage of them).
I assume the change away from from the `access` arg was to provide the same
options, plus `MAP_POPULATE`. Looking at the source code[2], they're not quite
the same- `ACCESS_READ` is equivalent to `flags = MAP_SHARED` and `prot = PROT_READ`.
`MAP_PRIVATE` is only used with `ACCESS_COPY`, which allows read and write.
Therefore, we can't quite get the same baseline flags on Windows, but this was
the status quo ante and `MAP_POPULATE` is a Linux thing, so presumably it works.
I realize that typically the OS differences are abstracted into the platform
modules, but I'm leaving it here so that it is obvious what the differences are
between the platforms.
[1] https://docs.python.org/3/library/mmap.html#mmap.mmap
[2] https://github.com/python/cpython/blob/
5e0abb47886bc665eefdcc19fde985f803e49d4c/Modules/mmapmodule.c#L1539
[package]
name = "chg"
version = "0.1.0"
authors = ["Yuya Nishihara <yuya@tcha.org>"]
description = "Client for Mercurial command server with cHg extension"
license = "GPL-2.0+"
edition = "2018"
[dependencies]
async-trait = "0.1"
bytes = "0.5"
futures = "0.3"
libc = "0.2"
log = { version = "0.4", features = ["std"] }
tokio-hglib = "0.3"
[dependencies.tokio]
version = "0.2"
features = ["rt-core", "io-util", "time", "process", "macros"]
[build-dependencies]
cc = "1.0"