Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ maintenance = { status = "passively-maintained" }

[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies]
libc = { version = "0.2", default-features = false }
rustc-std-workspace-core = { version = "1.0.0", optional = true }

[features]
default = []
# Enables deprecated and removed APIs.
deprecated = []
rustc-dep-of-std = ['rustc-std-workspace-core', 'libc/rustc-dep-of-std']
# Uses newer APIs
unstable = []

[workspace]
members = ["mach-test"]
Expand Down
35 changes: 25 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# mach2

[![Latest Version]][crates.io] [![docs]][docs.rs]

A Rust interface to the **user-space** API of the Mach 3.0 kernel exposed in
Expand All @@ -14,7 +16,7 @@ often API-incompatible with the kernel space one, and even in the cases where
they match, they are sometimes ABI incompatible such that using this library
would have **undefined behavior**.

# Usage
## Usage

Add the following to your `Cargo.toml` to conditionally include mach on those
platforms that support it.
Expand All @@ -24,14 +26,27 @@ platforms that support it.
version = "0.3"
```

The following crate features are available:
Available crate feature:

* **unstable** (disabled by default): Exposes newly changed APIs. Enabling this may
bring breaking changes (see the breaking change policy).


### Breaking change policy

We do the following steps when an item is changed/removed on latest toolchain:

1. Deprecate an existing one
2. Declare a new one under the `unstable` feature
3. After a month or more since releasing a new version that contains that change,
remove/change an older one

* **deprecated** (disabled by default): exposes deprecated APIs that have been
removed from the latest versions of the MacOS SDKs. The behavior of using
these APIs on MacOS versions that do not support them is undefined (hopefully
a linker error).
For instance, if const `FOO` value is changed from `3` to `4`,
we expose the newer one, i.e. `4`, under `unstable` first.
So the `unstable` users should notice the change on the first release since deprecating.
After a month or more, all the users should notice it.

# Platform support
## Platform support

The following table describes the current CI set-up:

Expand All @@ -43,7 +58,7 @@ The following table describes the current CI set-up:
| `aarch64-apple-ios-sim` | nightly | 13.1.0 | ✓ | - | - |
| `x86_64-apple-ios` | nightly | 13.1.0 | ✓ | - | - |

# License
## License

This project is licensed under either of

Expand All @@ -55,7 +70,7 @@ This project is licensed under either of

at your option.

# Contribution
## Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in `mach` by you, as defined in the Apache-2.0 license, shall be
Expand All @@ -68,7 +83,7 @@ TARGET=x86_64-apple-darwin RUST_VERSION=nightly ./ci/run.sh
```

where you can replace the `TARGET` and `RUST_VERSION` with the target you
want to test (e.g. `x86_64-apple-darwin`) and the Rust version you want to use for
want to test (e.g. `aarch64-apple-darwin`) and the Rust version you want to use for
the tests (e.g. `stable`, `1.33.0`, etc.).

[crates.io]: https://crates.io/crates/mach2
Expand Down
2 changes: 1 addition & 1 deletion ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ cargo build --no-default-features --target "${TARGET}" -vv 2>&1 | tee build_no_s
# Runs mach's run-time tests:
if [ -z "$NORUN" ]; then
cargo test --target "${TARGET}" -vv
cargo test --target "${TARGET}" -vv --features deprecated
cargo test --target "${TARGET}" -vv --features unstable
cargo test --no-default-features --target "${TARGET}" -vv
fi

Expand Down
15 changes: 10 additions & 5 deletions mach-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ fn main() {
// SDKs/MacOSX.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/mach
"ipc_port" => true,

// FIXME:
"vm_region_submap_info_64" => true,
// FIXME: Changed in XCode 11, figure out what's changed.
"vm_region_submap_info_64" if xcode >= Xcode(11, 0) => true,

_ => false,
}
Expand All @@ -168,8 +168,8 @@ fn main() {
// SDKs/MacOSX.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/mach
"ipc_port_t" => true,

// FIXME
"vm_region_submap_info_data_64_t" => true,
// FIXME: Changed in XCode 11, see `vm_region_submap_info_data_64`'s comment.
"vm_region_submap_info_data_64_t" if xcode >= Xcode(11, 0) => true,

_ => false,
}
Expand All @@ -186,7 +186,12 @@ fn main() {
});

cfg.skip_const(move |s| match s {
"MACH_RCV_NOTIFY" | "MACH_RCV_OVERWRITE" | "VM_PROT_NO_CHANGE" => true,
"MACH_RCV_NOTIFY" | "MACH_RCV_OVERWRITE" if xcode <= Xcode(11, 0) => true,

// FIXME: Somehow it fails, like:
// bad VM_PROT_NO_CHANGE value at byte 0: rust: 8 (0x8) != c 0 (0x0)
// bad VM_PROT_NO_CHANGE value at byte 3: rust: 0 (0x0) != c 1 (0x1)
"VM_PROT_NO_CHANGE" if xcode >= Xcode(13, 0) => true,
_ => false,
});

Expand Down
9 changes: 2 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,16 @@
#![allow(non_upper_case_globals)]
#![deny(missing_debug_implementations)]
#![deny(missing_copy_implementations)]
#![cfg_attr(feature = "rustc-dep-of-std", feature(no_core))]
#![cfg_attr(feature = "rustc-dep-of-std", no_core)]
#![cfg_attr(not(feature = "rustc-dep-of-std"), no_std)]
#![allow(
clippy::module_name_repetitions,
clippy::cast_sign_loss,
clippy::cast_possible_truncation,
clippy::trivially_copy_pass_by_ref
)]
#![no_std]

#[cfg(not(any(target_os = "macos", target_os = "ios")))]
compile_error!("mach requires MacOSX or iOS");

#[cfg(feature = "rustc-dep-of-std")]
extern crate rustc_std_workspace_core as core;
compile_error!("mach requires macOS or iOS");

extern crate libc;

Expand Down
4 changes: 2 additions & 2 deletions src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ pub const MACH_SEND_NODENAP: mach_msg_option_t = MACH_SEND_NOIMPORTANCE;
pub const MACH_SEND_IMPORTANCE: mach_msg_option_t = 0x0008_0000;

pub const MACH_RCV_TIMEOUT: mach_msg_option_t = 0x0000_0100;
pub const MACH_RCV_NOTIFY: mach_msg_option_t = 0x0000_0200;
pub const MACH_RCV_NOTIFY: mach_msg_option_t = 0x0000_0000;
pub const MACH_RCV_INTERRUPT: mach_msg_option_t = 0x0000_0400;
pub const MACH_RCV_VOUCHER: mach_msg_option_t = 0x0000_0800;
pub const MACH_RCV_OVERWRITE: mach_msg_option_t = 0x0000_1000;
pub const MACH_RCV_OVERWRITE: mach_msg_option_t = 0x0000_0000;

pub const MACH_MSG_SUCCESS: mach_msg_return_t = 0x0000_0000;

Expand Down