You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was taking a look at trying to add this myself, but I don't know if it should use #[cfg(target_os = "linux")] or #[cfg(any(target_os = "android", target_os = "linux"))]. I also don't know if there is any cfg hackery that should be done for supporting people on older kernels?
#define MAP_FIXED_NOREPLACE 0x100000
MAP_FIXED_NOREPLACE (since Linux 4.17)
This flag provides behavior that is similar to
MAP_FIXED with respect to the addr enforcement, but
differs in that MAP_FIXED_NOREPLACE never clobbers a
preexisting mapped range. If the requested range
would collide with an existing mapping, then this call
fails with the error EEXIST. This flag can therefore
be used as a way to atomically (with respect to other
threads) attempt to map an address range: one thread
will succeed; all others will report failure.
Note that older kernels which do not recognize the
MAP_FIXED_NOREPLACE flag will typically (upon detect‐
ing a collision with a preexisting mapping) fall back
to a "non-MAP_FIXED" type of behavior: they will re‐
turn an address that is different from the requested
address. Therefore, backward-compatible software
should check the returned address against the re‐
quested address.
The text was updated successfully, but these errors were encountered:
You don't need to do anything at build-time to support older Linux kernels. If an application tries to use an unsupported feature, it will simply fail at runtime. As for Android support, the best thing to do is to check the latest version of the Android headers. If it's in there, then you should include it here (and you may have to add it to https://github.com/rust-lang/libc first).
rtzoeller
changed the title
MAP_FIXED_REPLACE support
MAP_FIXED_NOREPLACE support
Jan 16, 2022
A new flag introduced in kernel 4.17.
I was taking a look at trying to add this myself, but I don't know if it should use
#[cfg(target_os = "linux")]
or#[cfg(any(target_os = "android", target_os = "linux"))]
. I also don't know if there is anycfg
hackery that should be done for supporting people on older kernels?#define MAP_FIXED_NOREPLACE 0x100000
The text was updated successfully, but these errors were encountered: