Skip to content

Commit d0cbc33

Browse files
committed
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. Changes: - src/advice.rs: Replace cfg checks for ZeroWiredPages, Free, FreeReusable, and FreeReuse - src/unix.rs: Replace cfg checks for MAP_NORESERVE constant - src/lib.rs: Update documentation to reflect Apple platforms coverage
1 parent 5a30f6b commit d0cbc33

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/advice.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ pub enum Advice {
230230
/// zeroed out if the address range is deallocated without first unwiring the pages (i.e.
231231
/// a munmap(2) without a preceding munlock(2) or the application quits). This is used
232232
/// with `madvise()` system call.
233-
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "visionos"))]
233+
#[cfg(target_vendor = "apple")]
234234
ZeroWiredPages = libc::MADV_ZERO_WIRED_PAGES,
235235
}
236236

@@ -319,7 +319,7 @@ pub enum UncheckedAdvice {
319319
/// Using the returned value with conceptually write to the
320320
/// mapped pages, i.e. borrowing the mapping while the pages
321321
/// are still being freed results in undefined behaviour.
322-
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "ios", target_os = "visionos"))]
322+
#[cfg(any(target_os = "linux", target_vendor = "apple"))]
323323
Free = libc::MADV_FREE,
324324

325325
/// **MADV_REMOVE** - Linux only (since Linux 2.6.16)
@@ -358,7 +358,7 @@ pub enum UncheckedAdvice {
358358
/// Using the returned value with conceptually write to the
359359
/// mapped pages, i.e. borrowing the mapping while the pages
360360
/// are still being freed results in undefined behaviour.
361-
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "visionos"))]
361+
#[cfg(target_vendor = "apple")]
362362
FreeReusable = libc::MADV_FREE_REUSABLE,
363363

364364
/// **MADV_FREE_REUSE** - Darwin only
@@ -372,7 +372,7 @@ pub enum UncheckedAdvice {
372372
/// Using the returned value with conceptually write to the
373373
/// mapped pages, i.e. borrowing the mapping while the pages
374374
/// are still being freed results in undefined behaviour.
375-
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "visionos"))]
375+
#[cfg(target_vendor = "apple")]
376376
FreeReuse = libc::MADV_FREE_REUSE,
377377
}
378378

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ impl MmapOptions {
368368
/// This option requests that no swap space will be allocated for the memory map,
369369
/// which can be useful for extremely large maps that are only written to sparsely.
370370
///
371-
/// This option is currently supported on Linux, Android, macOS, iOS, visionOS, NetBSD, Solaris and Illumos.
371+
/// This option is currently supported on Linux, Android, Apple platforms (macOS, iOS, visionOS, etc.), NetBSD, Solaris and Illumos.
372372
/// On those platforms, this option corresponds to the `MAP_NORESERVE` flag.
373373
/// On Linux, this option is ignored if [`vm.overcommit_memory`](https://www.kernel.org/doc/Documentation/vm/overcommit-accounting) is set to 2.
374374
///

src/unix.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const MAP_HUGE_SHIFT: libc::c_int = 0;
4545
#[cfg(any(
4646
target_os = "linux",
4747
target_os = "android",
48-
target_os = "macos",
48+
target_vendor = "apple",
4949
target_os = "netbsd",
5050
target_os = "solaris",
5151
target_os = "illumos",
@@ -55,7 +55,7 @@ const MAP_NORESERVE: libc::c_int = libc::MAP_NORESERVE;
5555
#[cfg(not(any(
5656
target_os = "linux",
5757
target_os = "android",
58-
target_os = "macos",
58+
target_vendor = "apple",
5959
target_os = "netbsd",
6060
target_os = "solaris",
6161
target_os = "illumos",

0 commit comments

Comments
 (0)