Vendor dependencies for 0.3.0 release

This commit is contained in:
2025-09-27 10:29:08 -05:00
parent 0c8d39d483
commit 82ab7f317b
26803 changed files with 16134934 additions and 0 deletions

1
vendor/mach2/.cargo-checksum.json vendored Normal file
View File

@@ -0,0 +1 @@
{"files":{"Cargo.lock":"1526d3a5f79ed0f33c1f19aaeaebc79f89d5490916692f1c11eb5737a0598492","Cargo.toml":"845ff525437adf23b2fddeb1d80d1e365ff61faf1e72734227942a3b6b8a5172","LICENSE-APACHE":"62c7a1e35f56406896d7aa7ca52d0cc0d272ac022b5d2796e7d6905db8a3636a","LICENSE-BSD":"044983df14c97f2f9570766aaf977b3cdfc4a06cf1f36b776331c5ff89b4fb89","LICENSE-MIT":"3f9f0f7e5a5911a8042e32c83ff5d061ce1ffd02e8a207ec2135a44ad73b4191","README.md":"9429b5231aecf35dc85bd4d365dd4c7885abcbd43e4871763104ed70f9cdfcc9","src/boolean.rs":"1d24ea9872748881cd7269a383a7c344e3a650df23f0e44e3b6c266fb8205d9a","src/bootstrap.rs":"a5ab69d74ad8bfb8fad1cb45c8c571977c0bf907a70e767309a437580cee184c","src/clock.rs":"a33c1bfb2f174abb695d164c469ee744be52fec4bc345656e6027d063e150d71","src/clock_priv.rs":"a8e6a96896a94eda67c9fb6e45c564581a711cc9fdcf7674251bb6c0c28b47c2","src/clock_reply.rs":"bac04b6602dcdd4daac8e3a0a1e56fa4b6de20cf2c3fe7bb583358166aca8a3b","src/clock_types.rs":"d55d1d2a953e477f9dd064bd684b118235aa7bd79de85cdeaf75e21510aaaefa","src/dyld.rs":"20e73955ff109f8381160953f3a703db86f9a30328d03bdacd326e506ddcfcdb","src/dyld_kernel.rs":"566a17f597aa29619a1ce15f6b22577fc70ac5356f96e00fddbcb28560a5c83c","src/exc.rs":"e12f7418ca072d4c79af71782cc4f891f6306ebd844a6f2114dba5247a330e4f","src/exception_types.rs":"c7894831d73145adb1a4b5d2a5d0b346f2b2dc05382b97f2f3f0275d337f6dfc","src/kern_return.rs":"cfa0f57f813387892d3486ba1ea2c13a36adee16a5bb553538fba2a92cfdcd93","src/lib.rs":"dd367bdb56e553db44ad034eed786819ba2d109cb7d67a4c6ed2a4e0c9d93ccd","src/loader.rs":"fd74c869064610dbba3377c6a76bed1b6e2c5a28d35157791bff66613500723c","src/mach_init.rs":"df49bd287fd05fb74bc76254df7607fad0d6b90cb20da803e9f9a1dc2fcfe2fc","src/mach_port.rs":"d7dff08222be25dc9bca1a7fed145e94ac42956b310f17b007df98df723cac1f","src/mach_time.rs":"b9493e820acf21fee1f6e7e82a510d887925dc1117d6b71b681acc40cfa776af","src/mach_types.rs":"e2d17741ebcdcdff9686ec9ee5c90fb7a150ce990979507da01c351771fb3a19","src/memory_object_types.rs":"6fcb446c00ddd5ef4920efe618bd89df2e87f7ae3cf660a2bc1d25cf1f331dc2","src/message.rs":"731d34e067f22b2ed511418a7d0dd7cefd170af8d2c5346e29b2cf506a1a2936","src/ndr.rs":"80dfe3af4f0afe6e5ab61228636925954e71d06b1c15c9697b1d13ef8e92ebc8","src/port.rs":"a4a17bb012fd3af8cbbb00b014dd2d4b16b0edd1bac8c2f1d6121c934faa8cfc","src/semaphore.rs":"7ce37b9d2ac02d98e2417d94ef3f6a4768e158fead8ac18907ba4627c0e9f458","src/structs.rs":"c65baa66dba7feb2a0853f09d8c82b61bc1b7408ba3d1801f702839597a69c1f","src/sync_policy.rs":"913a09168fb3ace7981aa7066e706d1d617dc3871cac3c96a499ed4e8fda5639","src/task.rs":"9a008398a505492be3168f5b5ebff72f75de13aae36146e75af48bba7b9d8084","src/task_info.rs":"36222151c35b7d6c6cba2fe48d055b22d965497f8db576384da33f44f6dfbc27","src/thread_act.rs":"07f0590d8cf34ed8c723f0cf40633eae59bd94cf7756817e897349ae6d246aab","src/thread_policy.rs":"e8999b03a03d398a456056274ed8ebc4c38a1cbbbba2da931503885da0e9c2e3","src/thread_status.rs":"adde7b1837ede9d38d9d9aaf2e6f956c20a17c8a3061b3529c8e70b4f07ece92","src/time_value.rs":"281a38c39c47aeb8bd02e7d8643815a8ca6e9d94448cd557cf38f0bae820f850","src/traps.rs":"59a65e0cc3cf67d79180eabfe31248287afa7a2daa58ec367ebb6302ff39f4cb","src/vm.rs":"1e3fe55704dbbc0c287ad543f5642389a823539f72b337cbff726d6927566b23","src/vm_attributes.rs":"7f73f41572d1ca854b45199a17e9008197f3898cfe6a82dba6d14293d49269c6","src/vm_behavior.rs":"a5d195a52602f5ebe2991774c2390a6f20f1bfa82168dd62e88f2804134da1f3","src/vm_inherit.rs":"dbc7432350869733d6e7cf1da8617d97aafbeb1afcb1bdc60ed7ab53e37abf61","src/vm_page_size.rs":"1cd209f8f6fbc4d3b7a44b77f5a3c53c578f357199e3c616b2386a63e5bfe70a","src/vm_prot.rs":"65e5f7179e155c600cec1a1b3e030f2d0d6b446a6ec9ebad0d04f56ccd884a86","src/vm_purgable.rs":"e32963f20905c4edd1cfee364ad489ef646ad7d401967d0ed9e1e7ed6cd57e5d","src/vm_region.rs":"905daa12391c0c3bca9200ceaecbd02dd03550bbdc9c3342dceeeb6e4056184f","src/vm_statistics.rs":"abee2c810b13fa007a7e38dd2b3d6460005e9e78f5972e069d7fc3e0df80190e","src/vm_sync.rs":"e6006b66f0fa1a06c5e853d765a9366aab85009cc77a095b93f902330cf4ec81","src/vm_types.rs":"493df2d189d8ea62d512bb90e36f56be6f955c8f067cabb1fbc3cbde9858be78"},"package":"d640282b302c0bb0a2a8e0233ead9035e3bed871f0b7e81fe4a1ec829765db44"}

16
vendor/mach2/Cargo.lock generated vendored Normal file
View File

@@ -0,0 +1,16 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "libc"
version = "0.2.174"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776"
[[package]]
name = "mach2"
version = "0.4.3"
dependencies = [
"libc",
]

59
vendor/mach2/Cargo.toml vendored Normal file
View File

@@ -0,0 +1,59 @@
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
edition = "2015"
name = "mach2"
version = "0.4.3"
build = false
include = [
"src/**/*",
"LICENSE-*",
"README.md",
]
autolib = false
autobins = false
autoexamples = false
autotests = false
autobenches = false
description = "A Rust interface to the user-space API of the Mach 3.0 kernel that underlies OSX."
readme = "README.md"
keywords = [
"kernel",
"macos",
"darwin",
]
categories = [
"api-bindings",
"external-ffi-bindings",
"no-std",
"os",
]
license = "BSD-2-Clause OR MIT OR Apache-2.0"
repository = "https://github.com/JohnTitor/mach2"
[package.metadata.docs.rs]
default-target = "x86_64-apple-darwin"
[badges.maintenance]
status = "passively-maintained"
[features]
default = []
unstable = []
[lib]
name = "mach2"
path = "src/lib.rs"
[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies.libc]
version = "0.2"
default-features = false

176
vendor/mach2/LICENSE-APACHE vendored Normal file
View File

@@ -0,0 +1,176 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS

23
vendor/mach2/LICENSE-BSD vendored Normal file
View File

@@ -0,0 +1,23 @@
Copyright (c) 2019 Nick Fitzgerald, 2021 Yuki Okushi
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

25
vendor/mach2/LICENSE-MIT vendored Normal file
View File

@@ -0,0 +1,25 @@
Copyright (c) 2019 Nick Fitzgerald, 2021 Yuki Okushi
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

116
vendor/mach2/README.md vendored Normal file
View File

@@ -0,0 +1,116 @@
# mach2
[![Latest Version]][crates.io] [![docs]][docs.rs]
A Rust interface to the **user-space** API of the Mach 3.0 kernel exposed in
`/usr/include/mach` that underlies macOS and is linked via `libSystem` (and
`libsystem_kernel`).
This library does not expose the **kernel-space** API of the Mach 3.0 kernel
exposed in
`SDK/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/mach`.
That is, if you are writing a kernel-resident device drivers or some other
kernel extensions you have to use something else. The user-space kernel API is
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
Add the following to your `Cargo.toml` to conditionally include mach on those
platforms that support it.
```toml
[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies.mach]
version = "0.4"
```
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
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.
## Examples
Examples can be found in the [examples](./examples) directory of this repository.
Since [`examples/dump_process_registers.rs`](./examples/dump_process_registers.rs) makes use of the `task_for_pid()` function, which requires elevated privileges, it is necessary to disable System Integrity Protection (SIP) and to be part of the `admin` or `_developer` group in order to run the example. However, do note that disabling SIP is in no way encouraged, and should only be done for development/debugging purposes.
1. Reboot macOS in recovery mode.
2. Click on `Options`.
3. Log in to your user.
4. In the menu click on `Utilities` and then `Terminal`.
5. In the terminal type the following command to disable SIP: `csrutil disable` (`csrutil enable` to re-enable SIP).
6. Reboot your machine.
To run the example, build it as follows:
```
cargo b --example dump_process_registers
```
Then run it using `sudo`:
```
sudo ./target/debug/examples/dump_process_registers
```
## Platform support
The following table describes the current CI set-up:
| Target | Min. Rust | XCode | build | ctest | run |
|-------------------------|-----------|-----------------|-------|-------|-----|
| `x86_64-apple-darwin` | 1.33.0 | 10.3.0 - 13.1.0 | ✓ | ✓ | ✓ |
| `aarch64-apple-darwin` | nightly | 13.1.0 | ✓ | - | - |
| `aarch64-apple-ios` | nightly | 13.1.0 | ✓ | - | - |
| `aarch64-apple-ios-sim` | nightly | 13.1.0 | ✓ | - | - |
| `x86_64-apple-ios` | nightly | 13.1.0 | ✓ | - | - |
## License
This project is licensed under either of
* A 2-clause BSD License ([LICENSE-BSD](LICENSE-BSD)), or
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or
http://opensource.org/licenses/MIT)
at your option.
## 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
triple licensed as above, without any additional terms or conditions.
To locally test the library, run:
```
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. `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
[Latest Version]: https://img.shields.io/crates/v/mach2.svg
[docs]: https://docs.rs/mach2/badge.svg
[docs.rs]: https://docs.rs/mach2

7
vendor/mach2/src/boolean.rs vendored Normal file
View File

@@ -0,0 +1,7 @@
//! This module corresponds to `mach/i386/boolean.h`.
#[cfg(target_arch = "x86_64")]
pub type boolean_t = ::libc::c_uint;
#[cfg(not(target_arch = "x86_64"))]
pub type boolean_t = ::libc::c_int;

76
vendor/mach2/src/bootstrap.rs vendored Normal file
View File

@@ -0,0 +1,76 @@
//! This module corresponds to `bootstrap.h`
use boolean::boolean_t;
use kern_return::kern_return_t;
use port::mach_port_t;
pub const BOOTSTRAP_MAX_NAME_LEN: ::libc::c_uint = 128;
pub const BOOTSTRAP_MAX_CMD_LEN: ::libc::c_uint = 512;
pub const BOOTSTRAP_MAX_LOOKUP_COUNT: ::libc::c_uint = 20;
pub const BOOTSTRAP_SUCCESS: ::libc::c_uint = 0;
pub const BOOTSTRAP_NOT_PRIVILEGED: ::libc::c_uint = 1100;
pub const BOOTSTRAP_NAME_IN_USE: ::libc::c_uint = 1101;
pub const BOOTSTRAP_UNKNOWN_SERVICE: ::libc::c_uint = 1102;
pub const BOOTSTRAP_SERVICE_ACTIVE: ::libc::c_uint = 1103;
pub const BOOTSTRAP_BAD_COUNT: ::libc::c_uint = 1104;
pub const BOOTSTRAP_NO_MEMORY: ::libc::c_uint = 1105;
pub const BOOTSTRAP_NO_CHILDREN: ::libc::c_uint = 1106;
pub const BOOTSTRAP_STATUS_INACTIVE: ::libc::c_uint = 0;
pub const BOOTSTRAP_STATUS_ACTIVE: ::libc::c_uint = 1;
pub const BOOTSTRAP_STATUS_ON_DEMAND: ::libc::c_uint = 2;
pub type name_t = [::libc::c_char; 128];
pub type cmd_t = [::libc::c_char; 512];
pub type name_array_t = *mut name_t;
pub type bootstrap_status_t = ::libc::c_int;
pub type bootstrap_status_array_t = *mut bootstrap_status_t;
pub type bootstrap_property_t = ::libc::c_uint;
pub type bootstrap_property_array_t = *mut bootstrap_property_t;
pub type bool_array_t = *mut boolean_t;
extern "C" {
pub static bootstrap_port: mach_port_t;
pub fn bootstrap_create_server(
bp: mach_port_t,
server_cmd: *mut ::libc::c_char,
server_uid: ::libc::uid_t,
on_demand: boolean_t,
server_port: *mut mach_port_t,
) -> kern_return_t;
pub fn bootstrap_subset(
bp: mach_port_t,
requestor_port: mach_port_t,
subset_port: *mut mach_port_t,
) -> kern_return_t;
pub fn bootstrap_unprivileged(bp: mach_port_t, unpriv_port: *mut mach_port_t) -> kern_return_t;
pub fn bootstrap_parent(bp: mach_port_t, parent_port: *mut mach_port_t) -> kern_return_t;
pub fn bootstrap_register(
bp: mach_port_t,
service_name: *mut ::libc::c_char,
sp: mach_port_t,
) -> kern_return_t;
pub fn bootstrap_create_service(
bp: mach_port_t,
service_name: *mut ::libc::c_char,
sp: *mut mach_port_t,
) -> kern_return_t;
pub fn bootstrap_check_in(
bp: mach_port_t,
service_name: *const ::libc::c_char,
sp: *mut mach_port_t,
) -> kern_return_t;
pub fn bootstrap_look_up(
bp: mach_port_t,
service_name: *const ::libc::c_char,
sp: *mut mach_port_t,
) -> kern_return_t;
pub fn bootstrap_status(
bp: mach_port_t,
service_name: *mut ::libc::c_char,
service_active: *mut bootstrap_status_t,
) -> kern_return_t;
pub fn bootstrap_strerror(r: kern_return_t) -> *const ::libc::c_char;
}

27
vendor/mach2/src/clock.rs vendored Normal file
View File

@@ -0,0 +1,27 @@
//! This module roughly corresponds to `mach/clock.h`.
pub const clock_MSG_COUNT: ::libc::c_uint = 3;
use clock_types::{alarm_type_t, clock_attr_t, clock_flavor_t, mach_timespec_t};
use kern_return::kern_return_t;
use mach_types::{clock_reply_t, clock_serv_t};
use message::mach_msg_type_number_t;
extern "C" {
pub fn clock_get_time(
clock_serv: clock_serv_t,
cur_time: *mut mach_timespec_t,
) -> kern_return_t;
pub fn clock_get_attributes(
clock_serv: clock_serv_t,
flavor: clock_flavor_t,
clock_attr: clock_attr_t,
clock_attrCnt: *mut mach_msg_type_number_t,
) -> kern_return_t;
pub fn clock_alarm(
clock_serv: clock_serv_t,
alarm_type: alarm_type_t,
alarm_time: mach_timespec_t,
alarm_port: clock_reply_t,
) -> kern_return_t;
}

16
vendor/mach2/src/clock_priv.rs vendored Normal file
View File

@@ -0,0 +1,16 @@
//! This module roughly corresponds to `mach/clock_priv.h`.
use clock_types::{clock_attr_t, clock_flavor_t, mach_timespec_t};
use kern_return::kern_return_t;
use mach_types::clock_ctrl_t;
use message::mach_msg_type_number_t;
extern "C" {
pub fn clock_set_time(clock_ctrl: clock_ctrl_t, new_time: mach_timespec_t) -> kern_return_t;
pub fn clock_set_attributes(
clock_ctrl: clock_ctrl_t,
flavor: clock_flavor_t,
clock_attr: clock_attr_t,
clock_attrCnt: mach_msg_type_number_t,
) -> kern_return_t;
}

16
vendor/mach2/src/clock_reply.rs vendored Normal file
View File

@@ -0,0 +1,16 @@
//! This module roughly corresponds to `mach/clock_reply.h`.
use clock_types::{alarm_type_t, mach_timespec_t};
use kern_return::kern_return_t;
use mach_types::clock_reply_t;
use message::mach_msg_type_name_t;
extern "C" {
pub fn clock_alarm_reply(
alarm_port: clock_reply_t,
alarm_portPoly: mach_msg_type_name_t,
alarm_code: kern_return_t,
alarm_type: alarm_type_t,
alarm_time: mach_timespec_t,
) -> kern_return_t;
}

75
vendor/mach2/src/clock_types.rs vendored Normal file
View File

@@ -0,0 +1,75 @@
//! This module roughly corresponds to `mach/clock_types.h`.
pub type alarm_type_t = ::libc::c_int;
pub type sleep_type_t = ::libc::c_int;
pub type clock_id_t = ::libc::c_int;
pub type clock_flavor_t = ::libc::c_int;
pub type clock_attr_t = *mut ::libc::c_int;
pub type clock_res_t = ::libc::c_int;
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct mach_timespec {
pub tv_sec: ::libc::c_uint,
pub tv_nsec: clock_res_t,
}
pub type mach_timespec_t = mach_timespec;
pub const SYSTEM_CLOCK: ::libc::c_uint = 0;
pub const CALENDAR_CLOCK: ::libc::c_uint = 1;
pub const REALTIME_CLOCK: ::libc::c_uint = 0;
pub const CLOCK_GET_TIME_RES: ::libc::c_uint = 1;
pub const CLOCK_ALARM_CURRES: ::libc::c_uint = 3;
pub const CLOCK_ALARM_MINRES: ::libc::c_uint = 4;
pub const CLOCK_ALARM_MAXRES: ::libc::c_uint = 5;
pub const NSEC_PER_USEC: ::libc::c_ulonglong = 1000;
pub const USEC_PER_SEC: ::libc::c_ulonglong = 1_000_000;
pub const NSEC_PER_SEC: ::libc::c_ulonglong = 1_000_000_000;
pub const NSEC_PER_MSEC: ::libc::c_ulonglong = 1_000_000;
#[allow(non_snake_case)]
pub fn BAD_MACH_TIMESPEC(t: mach_timespec) -> bool {
t.tv_nsec < 0 || (t.tv_nsec as ::libc::c_ulonglong) >= NSEC_PER_SEC
}
#[allow(non_snake_case)]
pub fn CMP_MACH_TIMESPEC(t1: &mach_timespec, t2: &mach_timespec) -> ::libc::c_ulonglong {
if t1.tv_sec > t2.tv_sec {
return NSEC_PER_SEC;
}
if t1.tv_sec < t2.tv_sec {
return !NSEC_PER_SEC;
}
(t1.tv_nsec as ::libc::c_ulonglong) - (t2.tv_nsec as ::libc::c_ulonglong)
}
#[allow(non_snake_case)]
pub fn ADD_MACH_TIMESPEC(t1: &mut mach_timespec, t2: &mach_timespec) {
t1.tv_nsec += t2.tv_nsec;
if (t1.tv_nsec as ::libc::c_ulonglong) >= NSEC_PER_SEC {
t1.tv_nsec = (t1.tv_nsec as ::libc::c_ulonglong - NSEC_PER_SEC) as clock_res_t;
t1.tv_sec += 1;
}
t1.tv_sec += t2.tv_sec;
}
#[allow(non_snake_case)]
pub fn SUB_MACH_TIMESPEC(t1: &mut mach_timespec, t2: &mach_timespec) {
t1.tv_nsec -= t2.tv_nsec;
if t1.tv_nsec < 0 {
t1.tv_nsec = (t1.tv_nsec as ::libc::c_ulonglong + NSEC_PER_SEC) as clock_res_t;
t1.tv_sec -= 1;
}
t1.tv_sec -= t2.tv_sec;
}
pub const ALRMTYPE: ::libc::c_uint = 0xff;
pub const TIME_ABSOLUTE: ::libc::c_uint = 0x00;
pub const TIME_RELATIVE: ::libc::c_uint = 0x01;
#[allow(non_snake_case)]
pub fn BAD_ALRMTYPE(t: ::libc::c_uint) -> bool {
t & (!TIME_RELATIVE) != 0
}

10
vendor/mach2/src/dyld.rs vendored Normal file
View File

@@ -0,0 +1,10 @@
//! This module roughly corresponds to `mach-o/dyld.h`.
use loader::mach_header;
extern "C" {
pub fn _dyld_image_count() -> u32;
pub fn _dyld_get_image_header(image_index: u32) -> *const mach_header;
pub fn _dyld_get_image_vmaddr_slide(image_index: u32) -> ::libc::intptr_t;
pub fn _dyld_get_image_name(image_index: u32) -> *const ::libc::c_char;
}

30
vendor/mach2/src/dyld_kernel.rs vendored Normal file
View File

@@ -0,0 +1,30 @@
//! This module roughly corresponds to `mach/dyld_kernel.h`.
use boolean::boolean_t;
use mach_types::{fsid_t, fsobj_id_t, uuid_t};
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct dyld_kernel_image_info {
pub uuid: uuid_t,
pub fsobjid: fsobj_id_t,
pub fsid: fsid_t,
pub load_addr: u64,
}
#[allow(non_snake_case)]
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct dyld_kernel_process_info {
pub cache_image_info: dyld_kernel_image_info,
pub timestamp: u64,
pub imageCount: u32,
pub initialImageCount: u32,
pub dyldState: u8,
pub no_cache: boolean_t,
pub private_cache: boolean_t,
}
pub type dyld_kernel_image_info_t = dyld_kernel_image_info;
pub type dyld_kernel_process_info_t = dyld_kernel_process_info;
pub type dyld_kernel_image_info_array_t = *mut dyld_kernel_image_info_t;

73
vendor/mach2/src/exc.rs vendored Normal file
View File

@@ -0,0 +1,73 @@
//! This module roughly corresponds to `mach/exc.h`.
use exception_types::{exception_data_t, exception_type_t};
use kern_return::kern_return_t;
use message::{
mach_msg_body_t, mach_msg_header_t, mach_msg_port_descriptor_t, mach_msg_type_number_t,
};
use ndr::NDR_record_t;
use port::mach_port_t;
use thread_status::thread_state_t;
use vm_types::integer_t;
pub const exc_MSG_COUNT: ::libc::c_uint = 3;
extern "C" {
pub fn exception_raise(
exception_port: mach_port_t,
thread: mach_port_t,
task: mach_port_t,
exception: exception_type_t,
code: exception_data_t,
codeCnt: mach_msg_type_number_t,
) -> kern_return_t;
pub fn exception_raise_state(
exception_port: mach_port_t,
exception: exception_type_t,
code: exception_data_t,
codeCnt: mach_msg_type_number_t,
flavor: *mut ::libc::c_int,
old_state: thread_state_t,
old_stateCnt: mach_msg_type_number_t,
new_state: thread_state_t,
new_stateCnt: *mut mach_msg_type_number_t,
) -> kern_return_t;
pub fn exception_raise_state_identity(
exception_port: mach_port_t,
thread: mach_port_t,
task: mach_port_t,
exception: exception_type_t,
code: exception_data_t,
codeCnt: mach_msg_type_number_t,
flavor: *mut ::libc::c_int,
old_state: thread_state_t,
old_stateCnt: mach_msg_type_number_t,
new_state: thread_state_t,
new_stateCnt: *mut mach_msg_type_number_t,
) -> kern_return_t;
}
#[repr(C)]
#[allow(dead_code, non_snake_case)]
#[derive(Copy, Clone, Debug)]
pub struct __Request__exception_raise_t {
pub Head: mach_msg_header_t,
/* start of the kernel processed data */
pub msgh_body: mach_msg_body_t,
pub thread: mach_msg_port_descriptor_t,
pub task: mach_msg_port_descriptor_t,
/* end of the kernel processed data */
pub NDR: NDR_record_t,
pub exception: exception_type_t,
pub codeCnt: mach_msg_type_number_t,
pub code: [integer_t; 2],
}
#[repr(C)]
#[allow(dead_code, non_snake_case)]
#[derive(Copy, Clone, Debug)]
pub struct __Reply__exception_raise_t {
pub Head: mach_msg_header_t,
pub NDR: NDR_record_t,
pub RetCode: kern_return_t,
}

56
vendor/mach2/src/exception_types.rs vendored Normal file
View File

@@ -0,0 +1,56 @@
//! This module roughly corresponds to `mach/exception_types.h`.
use port::mach_port_t;
use thread_status::thread_state_flavor_t;
use vm_types::integer_t;
pub const EXC_BAD_ACCESS: ::libc::c_uint = 1;
pub const EXC_BAD_INSTRUCTION: ::libc::c_uint = 2;
pub const EXC_ARITHMETIC: ::libc::c_uint = 3;
pub const EXC_EMULATION: ::libc::c_uint = 4;
pub const EXC_SOFTWARE: ::libc::c_uint = 5;
pub const EXC_BREAKPOINT: ::libc::c_uint = 6;
pub const EXC_SYSCALL: ::libc::c_uint = 7;
pub const EXC_MACH_SYSCALL: ::libc::c_uint = 8;
pub const EXC_RPC_ALERT: ::libc::c_uint = 9;
pub const EXC_CRASH: ::libc::c_uint = 10;
pub const EXC_RESOURCE: ::libc::c_uint = 11;
pub const EXC_GUARD: ::libc::c_uint = 12;
pub const EXC_CORPSE_NOTIFY: ::libc::c_uint = 13;
pub const EXC_CORPSE_VARIANT_BIT: ::libc::c_uint = 256;
pub const EXCEPTION_DEFAULT: ::libc::c_uint = 1;
pub const EXCEPTION_STATE: ::libc::c_uint = 2;
pub const EXCEPTION_STATE_IDENTITY: ::libc::c_uint = 3;
pub const MACH_EXCEPTION_CODES: ::libc::c_uint = 2_147_483_648;
pub const EXC_MASK_BAD_ACCESS: ::libc::c_uint = 2;
pub const EXC_MASK_BAD_INSTRUCTION: ::libc::c_uint = 4;
pub const EXC_MASK_ARITHMETIC: ::libc::c_uint = 8;
pub const EXC_MASK_EMULATION: ::libc::c_uint = 16;
pub const EXC_MASK_SOFTWARE: ::libc::c_uint = 32;
pub const EXC_MASK_BREAKPOINT: ::libc::c_uint = 64;
pub const EXC_MASK_SYSCALL: ::libc::c_uint = 128;
pub const EXC_MASK_MACH_SYSCALL: ::libc::c_uint = 256;
pub const EXC_MASK_RPC_ALERT: ::libc::c_uint = 512;
pub const EXC_MASK_CRASH: ::libc::c_uint = 1024;
pub const EXC_MASK_RESOURCE: ::libc::c_uint = 2048;
pub const EXC_MASK_GUARD: ::libc::c_uint = 4096;
pub const EXC_MASK_CORPSE_NOTIFY: ::libc::c_uint = 8192;
pub const EXC_MASK_ALL: ::libc::c_uint = 7166;
pub const FIRST_EXCEPTION: ::libc::c_uint = 1;
pub const EXC_SOFT_SIGNAL: ::libc::c_uint = 65_539;
pub const EXC_MACF_MIN: ::libc::c_uint = 131_072;
pub const EXC_MACF_MAX: ::libc::c_uint = 196_607;
pub type exception_type_t = ::libc::c_int;
pub type exception_data_type_t = integer_t;
pub type mach_exception_data_type_t = i64;
pub type exception_behavior_t = ::libc::c_int;
pub type exception_data_t = *mut exception_data_type_t;
pub type mach_exception_data_t = *mut mach_exception_data_type_t;
pub type exception_mask_t = ::libc::c_uint;
pub type exception_mask_array_t = *mut exception_mask_t;
pub type exception_behavior_array_t = *mut exception_behavior_t;
pub type exception_flavor_array_t = *mut thread_state_flavor_t;
pub type exception_port_array_t = *mut mach_port_t;
pub type mach_exception_code_t = mach_exception_data_type_t;
pub type mach_exception_subcode_t = mach_exception_data_type_t;

59
vendor/mach2/src/kern_return.rs vendored Normal file
View File

@@ -0,0 +1,59 @@
//! This module corresponds to `mach/kern_return.h`.
// ...Except for this particular type, which is taken from `mach/i386/kern_return.h` and
// `mach/arm/kern_return.h` (also used for aarch64): it is the same type in both header files.
pub type kern_return_t = ::libc::c_int;
pub const KERN_SUCCESS: kern_return_t = 0;
pub const KERN_INVALID_ADDRESS: kern_return_t = 1;
pub const KERN_PROTECTION_FAILURE: kern_return_t = 2;
pub const KERN_NO_SPACE: kern_return_t = 3;
pub const KERN_INVALID_ARGUMENT: kern_return_t = 4;
pub const KERN_FAILURE: kern_return_t = 5;
pub const KERN_RESOURCE_SHORTAGE: kern_return_t = 6;
pub const KERN_NOT_RECEIVER: kern_return_t = 7;
pub const KERN_NO_ACCESS: kern_return_t = 8;
pub const KERN_MEMORY_FAILURE: kern_return_t = 9;
pub const KERN_MEMORY_ERROR: kern_return_t = 10;
pub const KERN_ALREADY_IN_SET: kern_return_t = 11;
pub const KERN_NOT_IN_SET: kern_return_t = 12;
pub const KERN_NAME_EXISTS: kern_return_t = 13;
pub const KERN_ABORTED: kern_return_t = 14;
pub const KERN_INVALID_NAME: kern_return_t = 15;
pub const KERN_INVALID_TASK: kern_return_t = 16;
pub const KERN_INVALID_RIGHT: kern_return_t = 17;
pub const KERN_INVALID_VALUE: kern_return_t = 18;
pub const KERN_UREFS_OVERFLOW: kern_return_t = 19;
pub const KERN_INVALID_CAPABILITY: kern_return_t = 20;
pub const KERN_RIGHT_EXISTS: kern_return_t = 21;
pub const KERN_INVALID_HOST: kern_return_t = 22;
pub const KERN_MEMORY_PRESENT: kern_return_t = 23;
pub const KERN_MEMORY_DATA_MOVED: kern_return_t = 24;
pub const KERN_MEMORY_RESTART_COPY: kern_return_t = 25;
pub const KERN_INVALID_PROCESSOR_SET: kern_return_t = 26;
pub const KERN_POLICY_LIMIT: kern_return_t = 27;
pub const KERN_INVALID_POLICY: kern_return_t = 28;
pub const KERN_INVALID_OBJECT: kern_return_t = 29;
pub const KERN_ALREADY_WAITING: kern_return_t = 30;
pub const KERN_DEFAULT_SET: kern_return_t = 31;
pub const KERN_EXCEPTION_PROTECTED: kern_return_t = 32;
pub const KERN_INVALID_LEDGER: kern_return_t = 33;
pub const KERN_INVALID_MEMORY_CONTROL: kern_return_t = 34;
pub const KERN_INVALID_SECURITY: kern_return_t = 35;
pub const KERN_NOT_DEPRESSED: kern_return_t = 36;
pub const KERN_TERMINATED: kern_return_t = 37;
pub const KERN_LOCK_SET_DESTROYED: kern_return_t = 38;
pub const KERN_LOCK_UNSTABLE: kern_return_t = 39;
pub const KERN_LOCK_OWNED: kern_return_t = 40;
pub const KERN_LOCK_OWNED_SELF: kern_return_t = 41;
pub const KERN_SEMAPHORE_DESTROYED: kern_return_t = 42;
pub const KERN_RPC_SERVER_TERMINATED: kern_return_t = 43;
pub const KERN_RPC_TERMINATE_ORPHAN: kern_return_t = 44;
pub const KERN_RPC_CONTINUE_ORPHAN: kern_return_t = 45;
pub const KERN_NOT_SUPPORTED: kern_return_t = 46;
pub const KERN_NODE_DOWN: kern_return_t = 47;
pub const KERN_NOT_WAITING: kern_return_t = 48;
pub const KERN_OPERATION_TIMED_OUT: kern_return_t = 49;
pub const KERN_CODESIGN_ERROR: kern_return_t = 50;
pub const KERN_POLICY_STATIC: kern_return_t = 51;
pub const KERN_RETURN_MAX: kern_return_t = 0x100;

62
vendor/mach2/src/lib.rs vendored Normal file
View File

@@ -0,0 +1,62 @@
#![allow(non_camel_case_types)]
#![allow(non_upper_case_globals)]
#![deny(missing_debug_implementations)]
#![deny(missing_copy_implementations)]
#![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 macOS or iOS");
extern crate libc;
#[allow(unused_imports)]
use core::{clone, cmp, default, fmt, hash, marker, mem, option};
pub mod boolean;
pub mod bootstrap;
pub mod clock;
pub mod clock_priv;
pub mod clock_reply;
pub mod clock_types; // TODO: test
pub mod dyld;
pub mod dyld_kernel;
// pub mod error; // TODO
pub mod exc;
pub mod exception_types;
pub mod kern_return;
pub mod loader;
pub mod mach_init;
pub mod mach_port;
pub mod mach_time;
pub mod mach_types;
pub mod memory_object_types;
pub mod message;
pub mod ndr;
pub mod port;
pub mod semaphore;
pub mod structs;
pub mod sync_policy;
pub mod task;
pub mod task_info;
pub mod thread_act;
pub mod thread_policy;
pub mod thread_status;
pub mod time_value;
pub mod traps;
pub mod vm;
pub mod vm_attributes;
pub mod vm_behavior;
pub mod vm_inherit;
pub mod vm_page_size;
pub mod vm_prot;
pub mod vm_purgable;
pub mod vm_region;
pub mod vm_statistics;
pub mod vm_sync;
pub mod vm_types;

14
vendor/mach2/src/loader.rs vendored Normal file
View File

@@ -0,0 +1,14 @@
//! This module roughly corresponds to `mach-o/loader.h`.
#[repr(C)]
#[allow(dead_code, non_snake_case)]
#[derive(Copy, Clone, Debug)]
pub struct mach_header {
pub magic: u32,
pub cputype: ::libc::cpu_type_t,
pub cpusubtype: ::libc::cpu_subtype_t,
pub filetype: u32,
pub ncmds: u32,
pub sizeofcmds: u32,
pub flags: u32,
}

22
vendor/mach2/src/mach_init.rs vendored Normal file
View File

@@ -0,0 +1,22 @@
//! This module corresponds to `mach/mach_init.h`.
use mach_types::thread_port_t;
extern "C" {
pub fn mach_thread_self() -> thread_port_t;
}
#[cfg(test)]
mod tests {
use mach_init::*;
use port::*;
#[test]
fn mach_thread_self_test() {
unsafe {
let this_thread = mach_thread_self();
assert!(this_thread != MACH_PORT_NULL);
assert!(this_thread != MACH_PORT_DEAD);
}
}
}

50
vendor/mach2/src/mach_port.rs vendored Normal file
View File

@@ -0,0 +1,50 @@
//! This module corresponds to `mach/mach_port.h`
use kern_return::kern_return_t;
use mach_types::ipc_space_t;
use message::mach_msg_type_name_t;
use port::{
mach_port_delta_t, mach_port_name_t, mach_port_options_t, mach_port_right_t, mach_port_t,
};
use vm_types::mach_port_context_t;
extern "C" {
pub fn mach_port_allocate(
task: ipc_space_t,
right: mach_port_right_t,
name: *mut mach_port_name_t,
) -> kern_return_t;
pub fn mach_port_destroy(task: ipc_space_t, name: mach_port_name_t) -> kern_return_t;
pub fn mach_port_deallocate(task: ipc_space_t, name: mach_port_name_t) -> kern_return_t;
pub fn mach_port_insert_right(
task: ipc_space_t,
name: mach_port_name_t,
poly: mach_port_t,
polyPoly: mach_msg_type_name_t,
) -> kern_return_t;
pub fn mach_port_extract_right(
task: ipc_space_t,
name: mach_port_name_t,
msgt_name: mach_msg_type_name_t,
poly: *mut mach_port_t,
polyPoly: *mut mach_msg_type_name_t,
) -> kern_return_t;
pub fn mach_port_mod_refs(
task: ipc_space_t,
name: mach_port_name_t,
right: mach_port_right_t,
delta: mach_port_delta_t,
) -> kern_return_t;
pub fn mach_port_construct(
task: ipc_space_t,
options: *mut mach_port_options_t,
context: mach_port_context_t,
name: *mut mach_port_name_t,
) -> kern_return_t;
pub fn mach_port_destruct(
task: ipc_space_t,
name: mach_port_name_t,
srdelta: mach_port_delta_t,
guard: mach_port_context_t,
) -> kern_return_t;
}

20
vendor/mach2/src/mach_time.rs vendored Normal file
View File

@@ -0,0 +1,20 @@
//! This module corresponds to `mach/mach_time.h`
use kern_return::kern_return_t;
pub type mach_timebase_info_t = *mut mach_timebase_info;
pub type mach_timebase_info_data_t = mach_timebase_info;
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct mach_timebase_info {
pub numer: u32,
pub denom: u32,
}
extern "C" {
pub fn mach_timebase_info(info: mach_timebase_info_t) -> kern_return_t;
pub fn mach_wait_until(deadline: u64) -> kern_return_t;
pub fn mach_absolute_time() -> u64;
pub fn mach_approximate_time() -> u64;
pub fn mach_continuous_time() -> u64;
pub fn mach_continuous_approximate_time() -> u64;
}

106
vendor/mach2/src/mach_types.rs vendored Normal file
View File

@@ -0,0 +1,106 @@
//! This module corresponds to `mach/mach_types.h`
use port::mach_port_t;
pub type task_t = mach_port_t;
pub type task_name_t = mach_port_t;
pub type task_suspension_token_t = mach_port_t;
pub type thread_t = mach_port_t;
pub type thread_act_t = mach_port_t;
pub type ipc_space_t = mach_port_t;
pub type coalition_t = mach_port_t;
pub type host_t = mach_port_t;
pub type host_priv_t = mach_port_t;
pub type host_security_t = mach_port_t;
pub type processor_t = mach_port_t;
pub type processor_set_t = mach_port_t;
pub type processor_set_control_t = mach_port_t;
pub type semaphore_t = mach_port_t;
pub type lock_set_t = mach_port_t;
pub type ledger_t = mach_port_t;
pub type alarm_t = mach_port_t;
pub type clock_serv_t = mach_port_t;
pub type clock_ctrl_t = mach_port_t;
pub type processor_set_name_t = processor_set_t;
pub type clock_reply_t = mach_port_t;
pub type bootstrap_t = mach_port_t;
pub type mem_entry_name_port_t = mach_port_t;
pub type exception_handler_t = mach_port_t;
pub type exception_handler_array_t = *mut exception_handler_t;
pub type vm_task_entry_t = mach_port_t;
pub type io_master_t = mach_port_t;
pub type UNDServerRef = mach_port_t;
pub type task_array_t = *mut task_t;
pub type thread_array_t = *mut thread_t;
pub type processor_set_array_t = *mut processor_set_t;
pub type processor_set_name_array_t = *mut processor_set_t;
pub type processor_array_t = *mut processor_t;
pub type thread_act_array_t = *mut thread_act_t;
pub type ledger_array_t = *mut ledger_t;
pub type task_port_t = task_t;
pub type task_port_array_t = task_array_t;
pub type thread_port_t = thread_t;
pub type thread_port_array_t = thread_array_t;
pub type ipc_space_port_t = ipc_space_t;
pub type host_name_t = host_t;
pub type host_name_port_t = host_t;
pub type processor_set_port_t = processor_set_t;
pub type processor_set_name_port_t = processor_set_t;
pub type processor_set_name_port_array_t = processor_set_array_t;
pub type processor_set_control_port_t = processor_set_t;
pub type processor_port_t = processor_t;
pub type processor_port_array_t = processor_array_t;
pub type thread_act_port_t = thread_act_t;
pub type thread_act_port_array_t = thread_act_array_t;
pub type semaphore_port_t = semaphore_t;
pub type lock_set_port_t = lock_set_t;
pub type ledger_port_t = ledger_t;
pub type ledger_port_array_t = ledger_array_t;
pub type alarm_port_t = alarm_t;
pub type clock_serv_port_t = clock_serv_t;
pub type clock_ctrl_port_t = clock_ctrl_t;
pub type exception_port_t = exception_handler_t;
pub type exception_port_arrary_t = exception_handler_array_t;
pub const TASK_NULL: task_t = 0;
pub const TASK_NAME_NULL: task_name_t = 0;
pub const THREAD_NULL: thread_t = 0;
pub const TID_NULL: u64 = 0;
pub const THR_ACT_NULL: thread_act_t = 0;
pub const IPC_SPACE_NULL: ipc_space_t = 0;
pub const COALITION_NULL: coalition_t = 0;
pub const HOST_NULL: host_t = 0;
pub const HOST_PRIV_NULL: host_priv_t = 0;
pub const HOST_SECURITY_NULL: host_security_t = 0;
pub const PROCESSOR_SET_NULL: processor_set_t = 0;
pub const PROCESSOR_NULL: processor_t = 0;
pub const SEMAPHORE_NULL: semaphore_t = 0;
pub const LOCK_SET_NULL: lock_set_t = 0;
pub const LEDGER_NULL: ledger_t = 0;
pub const ALARM_NULL: alarm_t = 0;
pub const CLOCK_NULL: ::libc::clock_t = 0;
pub const UND_SERVER_NULL: UNDServerRef = 0;
// <sys/_types.h>: typedef unsigned char __darwin_uuid_t[16];
pub type uuid_t = [::libc::c_uchar; 16];
// <sys/_types/_fsid_t.h>
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct fsid {
pub val: [i32; 2],
}
pub type fsid_t = fsid;
// <sys/_types/_fsobj_id_t.h>
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct fsobj_id {
pub fid_objno: u32,
pub fid_generation: u32,
}
pub type fsobj_id_t = fsobj_id;

View File

@@ -0,0 +1,9 @@
//! This module roughly corresponds to `mach/memory_object_types.h`.
use vm_types::natural_t;
pub type memory_object_offset_t = ::libc::c_ulonglong;
pub type memory_object_size_t = ::libc::c_ulonglong;
pub type memory_object_cluster_size_t = natural_t;
pub type memory_object_fault_info_t = *mut natural_t;
pub type vm_object_id_t = ::libc::c_ulonglong;

345
vendor/mach2/src/message.rs vendored Normal file
View File

@@ -0,0 +1,345 @@
//! This module corresponds to `mach/message.h`.
use kern_return::kern_return_t;
use port::{mach_port_name_t, mach_port_seqno_t, mach_port_t};
use vm_types::{integer_t, natural_t};
pub type mach_msg_timeout_t = natural_t;
pub type mach_msg_bits_t = ::libc::c_uint;
pub type mach_msg_id_t = integer_t;
pub type mach_msg_size_t = natural_t;
pub type mach_msg_copy_options_t = ::libc::c_uint;
pub type mach_msg_descriptor_type_t = ::libc::c_uint;
pub type mach_msg_type_name_t = ::libc::c_uint;
pub type mach_msg_guard_flags_t = ::libc::c_uint;
pub type mach_msg_trailer_type_t = ::libc::c_uint;
pub type mach_msg_trailer_size_t = ::libc::c_uint;
pub type mach_msg_option_t = integer_t;
pub type mach_msg_type_number_t = natural_t;
pub type mach_msg_type_size_t = natural_t;
pub type mach_msg_return_t = kern_return_t;
pub const MACH_MSG_TIMEOUT_NONE: mach_msg_timeout_t = 0;
pub const MACH_MSGH_BITS_ZERO: mach_msg_bits_t = 0x0000_0000;
pub const MACH_MSGH_BITS_REMOTE_MASK: mach_msg_bits_t = 0x0000_001f;
pub const MACH_MSGH_BITS_LOCAL_MASK: mach_msg_bits_t = 0x0000_1f00;
pub const MACH_MSGH_BITS_VOUCHER_MASK: mach_msg_bits_t = 0x001f_0000;
pub const MACH_MSGH_BITS_PORTS_MASK: mach_msg_bits_t =
MACH_MSGH_BITS_REMOTE_MASK | MACH_MSGH_BITS_LOCAL_MASK | MACH_MSGH_BITS_VOUCHER_MASK;
pub const MACH_MSGH_BITS_COMPLEX: mach_msg_bits_t = 0x8000_0000;
pub const MACH_MSGH_BITS_USER: mach_msg_bits_t = 0x801f_1f1f;
#[allow(non_snake_case)]
pub fn MACH_MSGH_BITS(remote: mach_msg_bits_t, local: mach_msg_bits_t) -> mach_msg_bits_t {
remote | (local << 8)
}
pub const MACH_MSG_TYPE_MOVE_RECEIVE: mach_msg_type_name_t = 16;
pub const MACH_MSG_TYPE_MOVE_SEND: mach_msg_type_name_t = 17;
pub const MACH_MSG_TYPE_MOVE_SEND_ONCE: mach_msg_type_name_t = 18;
pub const MACH_MSG_TYPE_COPY_SEND: mach_msg_type_name_t = 19;
pub const MACH_MSG_TYPE_MAKE_SEND: mach_msg_type_name_t = 20;
pub const MACH_MSG_TYPE_MAKE_SEND_ONCE: mach_msg_type_name_t = 21;
pub const MACH_MSG_TYPE_COPY_RECEIVE: mach_msg_type_name_t = 22;
pub const MACH_MSG_TYPE_DISPOSE_RECEIVE: mach_msg_type_name_t = 24;
pub const MACH_MSG_TYPE_DISPOSE_SEND: mach_msg_type_name_t = 25;
pub const MACH_MSG_TYPE_DISPOSE_SEND_ONCE: mach_msg_type_name_t = 26;
pub const MACH_MSG_PHYSICAL_COPY: mach_msg_copy_options_t = 0;
pub const MACH_MSG_VIRTUAL_COPY: mach_msg_copy_options_t = 1;
pub const MACH_MSG_ALLOCATE: mach_msg_copy_options_t = 2;
pub const MACH_MSG_GUARD_FLAGS_NONE: mach_msg_guard_flags_t = 0;
pub const MACH_MSG_GUARD_FLAGS_IMMOVABLE_RECEIVE: mach_msg_guard_flags_t = 1;
pub const MACH_MSG_GUARD_FLAGS_UNGUARDED_ON_SEND: mach_msg_guard_flags_t = 2;
pub const MACH_MSG_GUARD_FLAGS_MASK: mach_msg_guard_flags_t = 3;
pub const MACH_MSG_PORT_DESCRIPTOR: mach_msg_descriptor_type_t = 0;
pub const MACH_MSG_OOL_DESCRIPTOR: mach_msg_descriptor_type_t = 1;
pub const MACH_MSG_OOL_PORTS_DESCRIPTOR: mach_msg_descriptor_type_t = 2;
pub const MACH_MSG_OOL_VOLATILE_DESCRIPTOR: mach_msg_descriptor_type_t = 3;
pub const MACH_MSG_GUARDED_PORT_DESCRIPTOR: mach_msg_descriptor_type_t = 4;
pub const MACH_MSG_OPTION_NONE: mach_msg_option_t = 0x0000_0000;
pub const MACH_SEND_MSG: mach_msg_option_t = 0x0000_0001;
pub const MACH_RCV_MSG: mach_msg_option_t = 0x0000_0002;
pub const MACH_RCV_LARGE: mach_msg_option_t = 0x0000_0004;
pub const MACH_RCV_LARGE_IDENTITY: mach_msg_option_t = 0x0000_0008;
pub const MACH_SEND_TIMEOUT: mach_msg_option_t = 0x0000_0010;
pub const MACH_SEND_OVERRIDE: mach_msg_option_t = 0x0000_0020;
pub const MACH_SEND_INTERRUPT: mach_msg_option_t = 0x0000_0040;
pub const MACH_SEND_NOTIFY: mach_msg_option_t = 0x0000_0080;
pub const MACH_SEND_ALWAYS: mach_msg_option_t = 0x0001_0000;
pub const MACH_SEND_FILTER_NONFATAL: mach_msg_option_t = 0x0001_0000;
pub const MACH_SEND_TRAILER: mach_msg_option_t = 0x0002_0000;
pub const MACH_SEND_NOIMPORTANCE: mach_msg_option_t = 0x0004_0000;
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_SEND_SYNC_OVERRIDE: mach_msg_option_t = 0x0010_0000;
pub const MACH_SEND_PROPAGATE_QOS: mach_msg_option_t = 0x0020_0000;
pub const MACH_SEND_SYNC_USE_THRPRI: mach_msg_option_t = MACH_SEND_PROPAGATE_QOS;
pub const MACH_RCV_TIMEOUT: mach_msg_option_t = 0x0000_0100;
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_0000;
pub const MACH_RCV_GUARDED_DESC: mach_msg_option_t = 0x0000_1000;
pub const MACH_RCV_SYNC_WAIT: mach_msg_option_t = 0x0000_4000;
pub const MACH_RCV_SYNC_PEEK: mach_msg_option_t = 0x0000_8000;
pub const MACH_MSG_STRICT_REPLY: mach_msg_option_t = 0x0000_0200;
pub const MACH_RCV_TRAILER_NULL: mach_msg_trailer_type_t = 0;
pub const MACH_RCV_TRAILER_SEQNO: mach_msg_trailer_type_t = 1;
pub const MACH_RCV_TRAILER_SENDER: mach_msg_trailer_type_t = 2;
pub const MACH_RCV_TRAILER_AUDIT: mach_msg_trailer_type_t = 3;
pub const MACH_RCV_TRAILER_CTX: mach_msg_trailer_type_t = 4;
pub const MACH_RCV_TRAILER_AV: mach_msg_trailer_type_t = 7;
pub const MACH_RCV_TRAILER_LABELS: mach_msg_trailer_type_t = 8;
pub const MACH_MSG_SUCCESS: mach_msg_return_t = 0x0000_0000;
pub const MACH_MSG_MASK: mach_msg_return_t = 0x0000_3e00;
pub const MACH_MSG_IPC_SPACE: mach_msg_return_t = 0x0000_2000;
pub const MACH_MSG_VM_SPACE: mach_msg_return_t = 0x0000_1000;
pub const MACH_MSG_IPC_KERNEL: mach_msg_return_t = 0x0000_0800;
pub const MACH_MSG_VM_KERNEL: mach_msg_return_t = 0x0000_0400;
pub const MACH_SEND_IN_PROGRESS: mach_msg_return_t = 0x1000_0001;
pub const MACH_SEND_INVALID_DATA: mach_msg_return_t = 0x1000_0002;
pub const MACH_SEND_INVALID_DEST: mach_msg_return_t = 0x1000_0003;
pub const MACH_SEND_TIMED_OUT: mach_msg_return_t = 0x1000_0004;
pub const MACH_SEND_INVALID_VOUCHER: mach_msg_return_t = 0x1000_0005;
pub const MACH_SEND_INTERRUPTED: mach_msg_return_t = 0x1000_0007;
pub const MACH_SEND_MSG_TOO_SMALL: mach_msg_return_t = 0x1000_0008;
pub const MACH_SEND_INVALID_REPLY: mach_msg_return_t = 0x1000_0009;
pub const MACH_SEND_INVALID_RIGHT: mach_msg_return_t = 0x1000_000a;
pub const MACH_SEND_INVALID_NOTIFY: mach_msg_return_t = 0x1000_000b;
pub const MACH_SEND_INVALID_MEMORY: mach_msg_return_t = 0x1000_000c;
pub const MACH_SEND_NO_BUFFER: mach_msg_return_t = 0x1000_000d;
pub const MACH_SEND_TOO_LARGE: mach_msg_return_t = 0x1000_000e;
pub const MACH_SEND_INVALID_TYPE: mach_msg_return_t = 0x1000_000f;
pub const MACH_SEND_INVALID_HEADER: mach_msg_return_t = 0x1000_0010;
pub const MACH_SEND_INVALID_TRAILER: mach_msg_return_t = 0x1000_0011;
pub const MACH_SEND_INVALID_CONTEXT: mach_msg_return_t = 0x1000_0012;
pub const MACH_SEND_INVALID_RT_OOL_SIZE: mach_msg_return_t = 0x1000_0015;
pub const MACH_SEND_NO_GRANT_DEST: mach_msg_return_t = 0x1000_0016;
pub const MACH_SEND_MSG_FILTERED: mach_msg_return_t = 0x1000_0017;
pub const MACH_RCV_IN_PROGRESS: mach_msg_return_t = 0x1000_4001;
pub const MACH_RCV_INVALID_NAME: mach_msg_return_t = 0x1000_4002;
pub const MACH_RCV_TIMED_OUT: mach_msg_return_t = 0x1000_4003;
pub const MACH_RCV_TOO_LARGE: mach_msg_return_t = 0x1000_4004;
pub const MACH_RCV_INTERRUPTED: mach_msg_return_t = 0x1000_4005;
pub const MACH_RCV_PORT_CHANGED: mach_msg_return_t = 0x1000_4006;
pub const MACH_RCV_INVALID_NOTIFY: mach_msg_return_t = 0x1000_4007;
pub const MACH_RCV_INVALID_DATA: mach_msg_return_t = 0x1000_4008;
pub const MACH_RCV_PORT_DIED: mach_msg_return_t = 0x1000_4009;
pub const MACH_RCV_IN_SET: mach_msg_return_t = 0x1000_400a;
pub const MACH_RCV_HEADER_ERROR: mach_msg_return_t = 0x1000_400b;
pub const MACH_RCV_BODY_ERROR: mach_msg_return_t = 0x1000_400c;
pub const MACH_RCV_INVALID_TYPE: mach_msg_return_t = 0x1000_400d;
pub const MACH_RCV_SCATTER_SMALL: mach_msg_return_t = 0x1000_400e;
pub const MACH_RCV_INVALID_TRAILER: mach_msg_return_t = 0x1000_400f;
pub const MACH_RCV_IN_PROGRESS_TIMED: mach_msg_return_t = 0x1000_4011;
pub const MACH_RCV_INVALID_REPLY: mach_msg_return_t = 0x1000_4012;
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct mach_msg_header_t {
pub msgh_bits: mach_msg_bits_t,
pub msgh_size: mach_msg_size_t,
pub msgh_remote_port: mach_port_t,
pub msgh_local_port: mach_port_t,
pub msgh_voucher_port: mach_port_name_t,
pub msgh_id: mach_msg_id_t,
}
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct mach_msg_body_t {
pub msgh_descriptor_count: mach_msg_size_t,
}
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct mach_msg_base_t {
pub header: mach_msg_header_t,
pub body: mach_msg_body_t,
}
pub const MACH_MSG_TRAILER_FORMAT_0: mach_msg_trailer_type_t = 0;
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct mach_msg_trailer_t {
pub msgh_trailer_type: mach_msg_trailer_type_t,
pub msgh_trailer_size: mach_msg_trailer_size_t,
}
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct mach_msg_seqno_trailer_t {
pub msgh_trailer_type: mach_msg_trailer_type_t,
pub msgh_trailer_size: mach_msg_trailer_size_t,
pub msgh_seqno: mach_port_seqno_t,
}
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct security_token_t {
pub val: [::libc::c_uint; 2],
}
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct mach_msg_security_trailer_t {
pub msgh_trailer_type: mach_msg_trailer_type_t,
pub msgh_trailer_size: mach_msg_trailer_size_t,
pub msgh_seqno: mach_port_seqno_t,
pub msgh_sender: security_token_t,
}
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct audit_token_t {
pub val: [::libc::c_uint; 8],
}
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct mach_msg_audit_trailer_t {
pub msgh_trailer_type: mach_msg_trailer_type_t,
pub msgh_trailer_size: mach_msg_trailer_size_t,
pub msgh_seqno: mach_port_seqno_t,
pub msgh_sender: security_token_t,
pub msgh_audit: audit_token_t,
}
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct mach_msg_type_descriptor_t {
pub pad1: natural_t,
pub pad2: mach_msg_size_t,
pub pad3: [u8; 3],
pub type_: u8, // mach_msg_descriptor_type_t bitfield
}
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct mach_msg_port_descriptor_t {
pub name: mach_port_t,
pub pad1: mach_msg_size_t,
pub pad2: u16,
pub disposition: u8, // mach_msg_type_name_t bitfield
pub type_: u8, // mach_msg_descriptor_type_t bitfield
}
impl mach_msg_port_descriptor_t {
pub fn new(name: mach_port_t, disposition: mach_msg_type_name_t) -> Self {
Self {
name,
pad1: 0,
pad2: 0,
disposition: disposition as u8,
type_: MACH_MSG_PORT_DESCRIPTOR as u8,
}
}
}
#[repr(C)]
#[derive(Copy, Clone, Debug, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct mach_msg_ool_descriptor_t {
pub address: *mut ::libc::c_void,
#[cfg(not(target_pointer_width = "64"))]
pub size: mach_msg_size_t,
pub deallocate: u8, // boolean_t bitfield
pub copy: u8, // mach_msg_copy_options_t bitfield
pub pad1: u8,
pub type_: u8, // mach_msg_descriptor_type_t bitfield
#[cfg(target_pointer_width = "64")]
pub size: mach_msg_size_t,
}
impl mach_msg_ool_descriptor_t {
pub fn new(
address: *mut ::libc::c_void,
deallocate: bool,
copy: mach_msg_copy_options_t,
size: mach_msg_size_t,
) -> Self {
Self {
address,
deallocate: if deallocate { 1 } else { 0 },
copy: copy as u8,
pad1: 0,
type_: MACH_MSG_OOL_DESCRIPTOR as u8,
size,
}
}
}
#[repr(C)]
#[derive(Copy, Clone, Debug, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct mach_msg_ool_ports_descriptor_t {
pub address: *mut ::libc::c_void,
#[cfg(not(target_pointer_width = "64"))]
pub count: mach_msg_size_t,
pub deallocate: u8, // boolean_t bitfield
pub copy: u8, // mach_msg_copy_options_t bitfield
pub disposition: u8, // mach_msg_type_name_t bitfield
pub type_: u8, // mach_msg_descriptor_type_t bitfield
#[cfg(target_pointer_width = "64")]
pub count: mach_msg_size_t,
}
impl mach_msg_ool_ports_descriptor_t {
pub fn new(
address: *mut ::libc::c_void,
deallocate: bool,
copy: mach_msg_copy_options_t,
disposition: mach_msg_type_name_t,
count: mach_msg_size_t,
) -> Self {
Self {
address,
deallocate: if deallocate { 1 } else { 0 },
copy: copy as u8,
disposition: disposition as u8,
type_: MACH_MSG_OOL_PORTS_DESCRIPTOR as u8,
count,
}
}
}
extern "C" {
pub fn mach_msg(
msg: *mut mach_msg_header_t,
option: mach_msg_option_t,
send_size: mach_msg_size_t,
recv_size: mach_msg_size_t,
recv_name: mach_port_name_t,
timeout: mach_msg_timeout_t,
notify: mach_port_name_t,
) -> mach_msg_return_t;
// from mach/mach.h
pub fn mach_msg_send(msg: *mut mach_msg_header_t) -> mach_msg_return_t;
pub fn mach_msg_destroy(msg: *mut mach_msg_header_t);
}

19
vendor/mach2/src/ndr.rs vendored Normal file
View File

@@ -0,0 +1,19 @@
//! This module roughly corresponds to `mach/ndr.h`.
#[repr(C)]
#[derive(Copy, Clone, Debug)]
#[allow(dead_code)]
pub struct NDR_record_t {
mig_vers: libc::c_uchar,
if_vers: libc::c_uchar,
reserved1: libc::c_uchar,
mig_encoding: libc::c_uchar,
int_rep: libc::c_uchar,
char_rep: libc::c_uchar,
float_rep: libc::c_uchar,
reserved32: libc::c_uchar,
}
extern "C" {
pub static NDR_record: NDR_record_t;
}

67
vendor/mach2/src/port.rs vendored Normal file
View File

@@ -0,0 +1,67 @@
//! This module corresponds to `mach/port.h`
use vm_types::{integer_t, natural_t};
pub type mach_port_name_t = natural_t;
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct ipc_port;
pub type ipc_port_t = *mut ipc_port;
pub type mach_port_t = ::libc::c_uint;
pub type mach_port_array_t = *mut mach_port_t;
pub const MACH_PORT_NULL: mach_port_t = 0;
pub const MACH_PORT_DEAD: mach_port_t = !0;
pub type mach_port_right_t = natural_t;
pub const MACH_PORT_RIGHT_SEND: mach_port_right_t = 0;
pub const MACH_PORT_RIGHT_RECEIVE: mach_port_right_t = 1;
pub const MACH_PORT_RIGHT_SEND_ONCE: mach_port_right_t = 2;
pub const MACH_PORT_RIGHT_PORT_SET: mach_port_right_t = 3;
pub const MACH_PORT_RIGHT_DEAD_NAME: mach_port_right_t = 4;
pub const MACH_PORT_RIGHT_LABELH: mach_port_right_t = 5;
pub const MACH_PORT_RIGHT_NUMBER: mach_port_right_t = 6;
pub type mach_port_urefs_t = natural_t;
pub type mach_port_delta_t = integer_t;
pub type mach_port_seqno_t = natural_t;
pub type mach_port_mscount_t = natural_t;
pub type mach_port_msgcount_t = natural_t;
pub type mach_port_rights_t = natural_t;
pub const MACH_PORT_QLIMIT_ZERO: mach_port_msgcount_t = 0;
pub const MACH_PORT_QLIMIT_BASIC: mach_port_msgcount_t = 5;
pub const MACH_PORT_QLIMIT_SMALL: mach_port_msgcount_t = 16;
pub const MACH_PORT_QLIMIT_LARGE: mach_port_msgcount_t = 1024;
pub const MACH_PORT_QLIMIT_KERNEL: mach_port_msgcount_t = 65534;
pub const MACH_PORT_QLIMIT_MIN: mach_port_msgcount_t = MACH_PORT_QLIMIT_ZERO;
pub const MACH_PORT_QLIMIT_DEFAULT: mach_port_msgcount_t = MACH_PORT_QLIMIT_BASIC;
pub const MACH_PORT_QLIMIT_MAX: mach_port_msgcount_t = MACH_PORT_QLIMIT_LARGE;
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct mach_port_limits_t {
pub mpl_qlimit: mach_port_msgcount_t,
}
pub const MPO_CONTEXT_AS_GUARD: u32 = 1;
pub const MPO_QLIMIT: u32 = 2;
pub const MPO_TEMPOWNER: u32 = 4;
pub const MPO_IMPORTANCE_RECEIVER: u32 = 8;
pub const MPO_INSERT_SEND_RIGHT: u32 = 0x10;
pub const MPO_STRICT: u32 = 0x20;
pub const MPO_DENAP_RECEIVER: u32 = 0x40;
pub const MPO_IMMOVABLE_RECEIVE: u32 = 0x80;
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct mach_port_options_t {
pub flags: u32,
pub mpl: mach_port_limits_t,
pub reserved: [u64; 2],
}

22
vendor/mach2/src/semaphore.rs vendored Normal file
View File

@@ -0,0 +1,22 @@
//! This module corresponds to `mach/semaphore.h`
use clock_types::mach_timespec_t;
use kern_return::kern_return_t;
use mach_types::{semaphore_t, task_t};
use sync_policy::sync_policy_t;
extern "C" {
pub fn semaphore_create(
task: task_t,
semaphore: *mut semaphore_t,
policy: sync_policy_t,
value: libc::c_int,
) -> kern_return_t;
pub fn semaphore_signal(semaphore: *mut semaphore_t) -> kern_return_t;
pub fn semaphore_wait(semaphore: *mut semaphore_t) -> kern_return_t;
pub fn semaphore_timedwait(
semaphore: *mut semaphore_t,
timeout: mach_timespec_t,
) -> kern_return_t;
pub fn semaphore_destroy(task: task_t, semaphore: *mut semaphore_t) -> kern_return_t;
}

66
vendor/mach2/src/structs.rs vendored Normal file
View File

@@ -0,0 +1,66 @@
//! This module corresponds to `mach/i386/_structs.h` and `mach/arm/_structs.h`.
use mem;
use message::mach_msg_type_number_t;
#[cfg(target_arch = "aarch64")]
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct arm_thread_state64_t {
pub __x: [u64; 29],
pub __fp: u64,
pub __lr: u64,
pub __sp: u64,
pub __pc: u64,
pub __cpsr: u32,
pub __flags: u32,
}
#[cfg(target_arch = "aarch64")]
impl arm_thread_state64_t {
pub fn new() -> Self {
Default::default()
}
pub fn count() -> mach_msg_type_number_t {
(mem::size_of::<Self>() / mem::size_of::<::libc::c_int>()) as mach_msg_type_number_t
}
}
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct x86_thread_state64_t {
pub __rax: u64,
pub __rbx: u64,
pub __rcx: u64,
pub __rdx: u64,
pub __rdi: u64,
pub __rsi: u64,
pub __rbp: u64,
pub __rsp: u64,
pub __r8: u64,
pub __r9: u64,
pub __r10: u64,
pub __r11: u64,
pub __r12: u64,
pub __r13: u64,
pub __r14: u64,
pub __r15: u64,
pub __rip: u64,
pub __rflags: u64,
pub __cs: u64,
pub __fs: u64,
pub __gs: u64,
}
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
impl x86_thread_state64_t {
pub fn new() -> Self {
Default::default()
}
pub fn count() -> mach_msg_type_number_t {
(mem::size_of::<Self>() / mem::size_of::<::libc::c_int>()) as mach_msg_type_number_t
}
}

9
vendor/mach2/src/sync_policy.rs vendored Normal file
View File

@@ -0,0 +1,9 @@
//! This module corresponds to `mach/sync_policy.h`
pub type sync_policy_t = libc::c_int;
pub const SYNC_POLICY_FIFO: sync_policy_t = 0x0;
pub const SYNC_POLICY_FIXED_PRIORITY: sync_policy_t = 0x1;
pub const SYNC_POLICY_REVERSED: sync_policy_t = 0x2;
pub const SYNC_POLICY_ORDER_MASK: sync_policy_t = 0x3;
pub const SYNC_POLICY_LIFO: sync_policy_t = SYNC_POLICY_FIFO | SYNC_POLICY_REVERSED;

46
vendor/mach2/src/task.rs vendored Normal file
View File

@@ -0,0 +1,46 @@
//! This module corresponds to `mach/task.defs`.
use kern_return::kern_return_t;
use mach_types::{task_name_t, task_t, thread_act_array_t};
use message::mach_msg_type_number_t;
use port::{mach_port_array_t, mach_port_t};
use task_info::{task_flavor_t, task_info_t};
pub type task_special_port_t = ::libc::c_int;
pub const TASK_KERNEL_PORT: task_special_port_t = 1;
pub const TASK_HOST_PORT: task_special_port_t = 2;
pub const TASK_NAME_PORT: task_special_port_t = 3;
pub const TASK_BOOTSTRAP_PORT: task_special_port_t = 4;
extern "C" {
pub fn task_resume(target_task: task_t) -> kern_return_t;
pub fn task_suspend(target_task: task_t) -> kern_return_t;
pub fn task_get_special_port(
task: task_t,
which_port: task_special_port_t,
special_port: *mut mach_port_t,
) -> kern_return_t;
pub fn task_threads(
target_task: task_t,
act_list: *mut thread_act_array_t,
act_list_cnt: *mut mach_msg_type_number_t,
) -> kern_return_t;
pub fn task_info(
target_task: task_name_t,
flavor: task_flavor_t,
task_info_out: task_info_t,
task_info_outCnt: *mut mach_msg_type_number_t,
) -> kern_return_t;
pub fn task_set_info(
target_task: task_t,
flavor: task_flavor_t,
task_info_in: task_info_t,
task_info_inCnt: mach_msg_type_number_t,
) -> kern_return_t;
pub fn mach_ports_lookup(
target_task: task_t,
init_port_set: *mut mach_port_array_t,
init_port_setCnt: *mut mach_msg_type_number_t,
) -> kern_return_t;
}

49
vendor/mach2/src/task_info.rs vendored Normal file
View File

@@ -0,0 +1,49 @@
//! This module roughly corresponds to `mach/task_info.h`.
use vm_types::{integer_t, mach_vm_address_t, mach_vm_size_t, natural_t};
pub const TASK_INFO_MAX: ::libc::c_uint = 1024;
pub const TASK_BASIC_INFO_32: ::libc::c_uint = 4;
pub const TASK_BASIC2_INFO_32: ::libc::c_uint = 6;
#[cfg(target_arch = "x86_64")]
pub const TASK_BASIC_INFO_64: ::libc::c_uint = 5;
#[cfg(target_arch = "aarch64")]
pub const TASK_BASIC_INFO_64: ::libc::c_uint = 18;
#[cfg(target_arch = "x86_64")]
pub const TASK_BASIC_INFO: ::libc::c_uint = 5;
#[cfg(target_arch = "aarch64")]
pub const TASK_BASIC_INFO: ::libc::c_uint = 18;
#[cfg(target_arch = "x86")]
pub const TASK_BASIC_INFO: ::libc::c_uint = 4;
pub const TASK_EVENTS_INFO: ::libc::c_uint = 2;
pub const TASK_THREAD_TIMES_INFO: ::libc::c_uint = 3;
pub const TASK_ABSOLUTETIME_INFO: ::libc::c_uint = 1;
pub const TASK_KERNELMEMORY_INFO: ::libc::c_uint = 7;
pub const TASK_SECURITY_TOKEN: ::libc::c_uint = 13;
pub const TASK_AUDIT_TOKEN: ::libc::c_uint = 15;
pub const TASK_AFFINITY_TAG_INFO: ::libc::c_uint = 16;
pub const TASK_DYLD_INFO: ::libc::c_uint = 17;
pub const TASK_DYLD_ALL_IMAGE_INFO_32: ::libc::c_uint = 0;
pub const TASK_DYLD_ALL_IMAGE_INFO_64: ::libc::c_uint = 1;
pub const TASK_EXTMOD_INFO: ::libc::c_uint = 19;
pub const MACH_TASK_BASIC_INFO: ::libc::c_uint = 20;
pub const TASK_POWER_INFO: ::libc::c_uint = 21;
pub const TASK_VM_INFO: ::libc::c_uint = 22;
pub const TASK_VM_INFO_PURGEABLE: ::libc::c_uint = 23;
pub const TASK_TRACE_MEMORY_INFO: ::libc::c_uint = 24;
pub const TASK_WAIT_STATE_INFO: ::libc::c_uint = 25;
pub const TASK_POWER_INFO_V2: ::libc::c_uint = 26;
pub const TASK_VM_INFO_PURGEABLE_ACCOUNT: ::libc::c_uint = 27;
pub const TASK_FLAGS_INFO: ::libc::c_uint = 28;
pub const TASK_DEBUG_INFO_INTERNAL: ::libc::c_uint = 29;
pub type task_flavor_t = natural_t;
pub type task_info_t = *mut integer_t;
#[repr(C, packed(4))]
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct task_dyld_info {
pub all_image_info_addr: mach_vm_address_t,
pub all_image_info_size: mach_vm_size_t,
pub all_image_info_format: integer_t,
}

36
vendor/mach2/src/thread_act.rs vendored Normal file
View File

@@ -0,0 +1,36 @@
//! This module corresponds to `mach/thread_act.defs`.
use exception_types::{exception_behavior_t, exception_mask_t};
use kern_return::kern_return_t;
use mach_types::{thread_act_t, thread_port_t};
use message::mach_msg_type_number_t;
use port::mach_port_t;
use thread_status::{thread_state_flavor_t, thread_state_t};
extern "C" {
pub fn thread_get_state(
target_act: thread_act_t,
flavor: thread_state_flavor_t,
new_state: thread_state_t,
new_state_count: *mut mach_msg_type_number_t,
) -> kern_return_t;
pub fn thread_set_state(
target_act: thread_port_t,
flavor: thread_state_flavor_t,
new_state: thread_state_t,
new_stateCnt: mach_msg_type_number_t,
) -> kern_return_t;
pub fn thread_set_exception_ports(
thread: thread_port_t,
exception_mask: exception_mask_t,
new_port: mach_port_t,
behavior: exception_behavior_t,
new_flavor: thread_state_flavor_t,
) -> kern_return_t;
pub fn thread_suspend(target_act: thread_act_t) -> kern_return_t;
pub fn thread_resume(target_act: thread_act_t) -> kern_return_t;
}

121
vendor/mach2/src/thread_policy.rs vendored Normal file
View File

@@ -0,0 +1,121 @@
//! This module corresponds to `mach/thread_policy.h`.
use boolean::boolean_t;
use kern_return::kern_return_t;
use libc::thread_policy_t;
use mach_types::thread_t;
use message::mach_msg_type_number_t;
use vm_types::{integer_t, natural_t};
pub type thread_policy_flavor_t = natural_t;
pub const THREAD_STANDARD_POLICY: thread_policy_flavor_t = 1;
pub const THREAD_EXTENDED_POLICY: thread_policy_flavor_t = 1;
pub const THREAD_TIME_CONSTRAINT_POLICY: thread_policy_flavor_t = 2;
pub const THREAD_PRECEDENCE_POLICY: thread_policy_flavor_t = 3;
pub const THREAD_AFFINITY_POLICY: thread_policy_flavor_t = 4;
pub const THREAD_BACKGROUND_POLICY: thread_policy_flavor_t = 5;
pub const THREAD_LATENCY_QOS_POLICY: thread_policy_flavor_t = 7;
pub const THREAD_THROUGHPUT_QOS_POLICY: thread_policy_flavor_t = 8;
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct thread_standard_policy {
pub no_data: natural_t,
}
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct thread_extended_policy {
pub timeshare: boolean_t,
}
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct thread_time_constraint_policy {
pub period: u32,
pub computation: u32,
pub constraint: u32,
pub preemptible: boolean_t,
}
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct thread_precedence_policy {
pub importance: integer_t,
}
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct thread_affinity_policy {
pub affinity_tag: integer_t,
}
pub const THREAD_AFFINITY_TAG_NULL: integer_t = 0;
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct thread_background_policy {
pub priority: integer_t,
}
pub type thread_latency_qos_t = integer_t;
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct thread_latency_qos_policy {
thread_latency_qos_tier: thread_latency_qos_t,
}
pub type thread_throughput_qos_t = integer_t;
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct thread_throughput_qos_policy {
thread_throughput_qos_tier: thread_throughput_qos_t,
}
pub type thread_standard_policy_data_t = thread_standard_policy;
pub type thread_extended_policy_data_t = thread_extended_policy;
pub type thread_time_constraint_policy_data_t = thread_time_constraint_policy;
pub type thread_precedence_policy_data_t = thread_precedence_policy;
pub type thread_affinity_policy_data_t = thread_affinity_policy;
pub type thread_background_policy_data_t = thread_background_policy;
pub type thread_latency_qos_policy_data_t = thread_latency_qos_policy;
pub type thread_throughput_qos_policy_data_t = thread_throughput_qos_policy;
pub const THREAD_STANDARD_POLICY_COUNT: mach_msg_type_number_t = 0;
pub const THREAD_EXTENDED_POLICY_COUNT: mach_msg_type_number_t =
(core::mem::size_of::<thread_extended_policy>() / core::mem::size_of::<integer_t>()) as _;
pub const THREAD_TIME_CONSTRAINT_POLICY_COUNT: mach_msg_type_number_t =
(core::mem::size_of::<thread_time_constraint_policy>() / core::mem::size_of::<integer_t>())
as _;
pub const THREAD_PRECEDENCE_POLICY_COUNT: mach_msg_type_number_t =
(core::mem::size_of::<thread_precedence_policy>() / core::mem::size_of::<integer_t>()) as _;
pub const THREAD_AFFINITY_POLICY_COUNT: mach_msg_type_number_t =
(core::mem::size_of::<thread_affinity_policy>() / core::mem::size_of::<integer_t>()) as _;
pub const THREAD_BACKGROUND_POLICY_COUNT: mach_msg_type_number_t =
(core::mem::size_of::<thread_background_policy>() / core::mem::size_of::<integer_t>()) as _;
pub const THREAD_LATENCY_QOS_POLICY_COUNT: mach_msg_type_number_t =
(core::mem::size_of::<thread_latency_qos_policy>() / core::mem::size_of::<integer_t>()) as _;
pub const THREAD_THROUGHPUT_QOS_POLICY_COUNT: mach_msg_type_number_t =
(core::mem::size_of::<thread_throughput_qos_policy>() / core::mem::size_of::<integer_t>()) as _;
extern "C" {
pub fn thread_policy_set(
thread: thread_t,
flavor: thread_policy_flavor_t,
policy_info: thread_policy_t,
count: mach_msg_type_number_t,
) -> kern_return_t;
}
extern "C" {
pub fn thread_policy_get(
thread: thread_t,
flavor: thread_policy_flavor_t,
policy_info: thread_policy_t,
count: *mut mach_msg_type_number_t,
get_default: *mut boolean_t,
) -> kern_return_t;
}

53
vendor/mach2/src/thread_status.rs vendored Normal file
View File

@@ -0,0 +1,53 @@
//! This module corresponds to `mach/thread_status.h`.
use vm_types::natural_t;
pub type thread_state_t = *mut natural_t;
pub type thread_state_flavor_t = ::libc::c_int;
#[cfg(target_arch = "aarch64")]
mod aarch64 {
use super::thread_state_flavor_t;
pub static ARM_THREAD_STATE: thread_state_flavor_t = 1;
pub static ARM_UNIFIED_THREAD_STATE: thread_state_flavor_t = ARM_THREAD_STATE;
pub static ARM_VFP_STATE: thread_state_flavor_t = 2;
pub static ARM_EXCEPTION_STATE: thread_state_flavor_t = 3;
pub static ARM_DEBUG_STATE: thread_state_flavor_t = 4;
pub static THREAD_STATE_NONE: thread_state_flavor_t = 5;
pub static ARM_THREAD_STATE64: thread_state_flavor_t = 6;
pub static ARM_EXCEPTION_STATE64: thread_state_flavor_t = 7;
pub static ARM_DEBUG_STATE32: thread_state_flavor_t = 14;
pub static ARM_DEBUG_STATE64: thread_state_flavor_t = 15;
pub static ARM_NEON_STATE: thread_state_flavor_t = 16;
pub static ARM_NEON_STATE64: thread_state_flavor_t = 17;
pub static ARM_CPMU_STATE64: thread_state_flavor_t = 18;
}
#[cfg(target_arch = "aarch64")]
pub use self::aarch64::*;
#[cfg(target_arch = "x86_64")]
mod x86_64 {
use super::thread_state_flavor_t;
pub static x86_THREAD_STATE32: thread_state_flavor_t = 1;
pub static x86_FLOAT_STATE32: thread_state_flavor_t = 2;
pub static x86_EXCEPTION_STATE32: thread_state_flavor_t = 3;
pub static x86_THREAD_STATE64: thread_state_flavor_t = 4;
pub static x86_FLOAT_STATE64: thread_state_flavor_t = 5;
pub static x86_EXCEPTION_STATE64: thread_state_flavor_t = 6;
pub static x86_THREAD_STATE: thread_state_flavor_t = 7;
pub static x86_FLOAT_STATE: thread_state_flavor_t = 8;
pub static x86_EXCEPTION_STATE: thread_state_flavor_t = 9;
pub static x86_DEBUG_STATE32: thread_state_flavor_t = 10;
pub static x86_DEBUG_STATE64: thread_state_flavor_t = 11;
pub static x86_DEBUG_STATE: thread_state_flavor_t = 12;
pub static THREAD_STATE_NONE: thread_state_flavor_t = 13;
pub static x86_AVX_STATE32: thread_state_flavor_t = 16;
pub static x86_AVX_STATE64: thread_state_flavor_t = 17;
pub static x86_AVX_STATE: thread_state_flavor_t = 18;
}
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
pub use self::x86_64::*;

11
vendor/mach2/src/time_value.rs vendored Normal file
View File

@@ -0,0 +1,11 @@
use vm_types::integer_t;
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct time_value {
pub seconds: integer_t,
pub microseconds: integer_t,
}
pub type time_value_t = time_value;
pub const TIME_MICROS_MAX: integer_t = 1000000;

37
vendor/mach2/src/traps.rs vendored Normal file
View File

@@ -0,0 +1,37 @@
//! This module corresponds to `mach/mach_traps.h`.
use kern_return::kern_return_t;
use port::{mach_port_name_t, mach_port_t};
extern "C" {
static mach_task_self_: mach_port_t;
pub fn task_for_pid(
target_tport: mach_port_name_t,
pid: ::libc::c_int,
tn: *mut mach_port_name_t,
) -> kern_return_t;
}
#[allow(clippy::missing_safety_doc)] // FIXME
pub unsafe fn mach_task_self() -> mach_port_t {
mach_task_self_
}
#[allow(clippy::missing_safety_doc)] // FIXME
pub unsafe fn current_task() -> mach_port_t {
mach_task_self()
}
#[cfg(test)]
mod tests {
use port::*;
use traps::*;
#[test]
fn mach_task_self_sanity() {
unsafe {
let this_task = mach_task_self();
assert!(this_task != MACH_PORT_NULL);
assert!(this_task != MACH_PORT_DEAD);
}
}
}

248
vendor/mach2/src/vm.rs vendored Normal file
View File

@@ -0,0 +1,248 @@
//! This module roughly corresponds to `mach/mach_vm.defs`.
use boolean::boolean_t;
use kern_return::kern_return_t;
use mach_types::{mem_entry_name_port_t, vm_task_entry_t};
use memory_object_types::{memory_object_offset_t, memory_object_size_t};
use message::mach_msg_type_number_t;
use port::mach_port_t;
use vm_attributes::{vm_machine_attribute_t, vm_machine_attribute_val_t};
use vm_behavior::vm_behavior_t;
use vm_inherit::vm_inherit_t;
use vm_prot::vm_prot_t;
use vm_purgable::vm_purgable_t;
use vm_region::mach_vm_read_entry_t;
use vm_region::{
vm_page_info_flavor_t, vm_page_info_t, vm_region_flavor_t, vm_region_info_t,
vm_region_recurse_info_t,
};
use vm_sync::vm_sync_t;
use vm_types::{
integer_t, mach_vm_address_t, mach_vm_offset_t, mach_vm_size_t, natural_t, vm_map_t,
vm_offset_t, vm_size_t,
};
extern "C" {
pub fn mach_vm_allocate(
target: vm_task_entry_t,
address: *mut mach_vm_address_t,
size: mach_vm_size_t,
flags: ::libc::c_int,
) -> kern_return_t;
pub fn mach_vm_deallocate(
target: vm_task_entry_t,
address: mach_vm_address_t,
size: mach_vm_size_t,
) -> kern_return_t;
pub fn mach_vm_protect(
target_task: vm_task_entry_t,
address: mach_vm_address_t,
size: mach_vm_size_t,
set_maximum: boolean_t,
new_protection: vm_prot_t,
) -> kern_return_t;
pub fn mach_vm_inherit(
target_task: vm_task_entry_t,
address: mach_vm_address_t,
size: mach_vm_size_t,
new_inheritance: vm_inherit_t,
) -> kern_return_t;
pub fn mach_vm_read(
target_task: vm_task_entry_t,
address: mach_vm_address_t,
size: mach_vm_size_t,
data: *mut vm_offset_t,
dataCnt: *mut mach_msg_type_number_t,
) -> kern_return_t;
#[allow(improper_ctypes)]
pub fn mach_vm_read_list(
target_task: vm_task_entry_t,
data_list: mach_vm_read_entry_t,
count: natural_t,
) -> kern_return_t;
pub fn mach_vm_write(
target_task: vm_map_t,
address: mach_vm_address_t,
data: vm_offset_t,
dataCnt: mach_msg_type_number_t,
) -> kern_return_t;
pub fn mach_vm_copy(
target_task: vm_task_entry_t,
source_address: mach_vm_address_t,
size: mach_vm_size_t,
dest_address: mach_vm_address_t,
) -> kern_return_t;
pub fn mach_vm_read_overwrite(
target_task: vm_task_entry_t,
address: mach_vm_address_t,
size: mach_vm_size_t,
data: mach_vm_address_t,
outsize: *mut mach_vm_size_t,
) -> kern_return_t;
pub fn mach_vm_msync(
target_task: vm_task_entry_t,
address: mach_vm_address_t,
size: mach_vm_size_t,
sync_flags: vm_sync_t,
) -> kern_return_t;
pub fn mach_vm_behavior_set(
target_task: vm_task_entry_t,
address: mach_vm_address_t,
size: mach_vm_size_t,
new_behavior: vm_behavior_t,
) -> kern_return_t;
pub fn mach_vm_map(
target_task: vm_task_entry_t,
inout: *mut mach_vm_address_t,
size: mach_vm_size_t,
mask: mach_vm_offset_t,
flags: ::libc::c_int,
object: mem_entry_name_port_t,
offset: memory_object_offset_t,
copy: boolean_t,
cur_protection: vm_prot_t,
max_protection: vm_prot_t,
inheritance: vm_inherit_t,
) -> kern_return_t;
pub fn mach_vm_machine_attribute(
target_task: vm_task_entry_t,
address: mach_vm_address_t,
size: mach_vm_size_t,
attribute: vm_machine_attribute_t,
value: *mut vm_machine_attribute_val_t,
) -> kern_return_t;
pub fn mach_vm_remap(
target_task: vm_task_entry_t,
target_address: *mut mach_vm_address_t,
size: mach_vm_size_t,
mask: mach_vm_offset_t,
flags: ::libc::c_int,
src_task: vm_task_entry_t,
src_address: mach_vm_address_t,
copy: boolean_t,
cur_protection: *mut vm_prot_t,
out: *mut vm_prot_t,
inheritance: vm_inherit_t,
) -> kern_return_t;
pub fn mach_vm_page_query(
target_map: vm_map_t,
offset: mach_vm_offset_t,
disposition: *mut integer_t,
ref_count: *mut integer_t,
) -> kern_return_t;
pub fn mach_vm_region_recurse(
target_task: vm_task_entry_t,
address: *mut mach_vm_address_t,
size: *mut mach_vm_size_t,
nesting_depth: *mut natural_t,
info: vm_region_recurse_info_t,
infoCnt: *mut mach_msg_type_number_t,
) -> kern_return_t;
pub fn mach_vm_region(
target_task: vm_task_entry_t,
address: *mut mach_vm_address_t,
size: *mut mach_vm_size_t,
flavor: vm_region_flavor_t,
info: vm_region_info_t,
infoCnt: *mut mach_msg_type_number_t,
object_name: *mut mach_port_t,
) -> kern_return_t;
pub fn mach_make_memory_entry(
target_task: vm_map_t,
size: *mut vm_size_t,
offset: vm_offset_t,
permission: vm_prot_t,
object_handle: *mut mem_entry_name_port_t,
parent_handle: mem_entry_name_port_t,
) -> kern_return_t;
pub fn mach_make_memory_entry_64(
target_task: vm_map_t,
size: *mut memory_object_size_t,
offset: memory_object_offset_t,
permission: vm_prot_t,
object_handle: *mut mach_port_t,
parent_entry: mem_entry_name_port_t,
) -> kern_return_t;
pub fn mach_vm_purgable_control(
target_task: vm_task_entry_t,
address: mach_vm_address_t,
control: vm_purgable_t,
state: *mut ::libc::c_int,
) -> kern_return_t;
pub fn mach_vm_page_info(
target_task: vm_task_entry_t,
address: mach_vm_address_t,
flavor: vm_page_info_flavor_t,
info: vm_page_info_t,
infoCnt: *mut mach_msg_type_number_t,
) -> kern_return_t;
}
#[cfg(test)]
mod tests {
use super::*;
use kern_return::KERN_SUCCESS;
use traps::mach_task_self;
use vm_statistics::VM_FLAGS_ANYWHERE;
#[test]
fn mach_vm_allocate_sanity() {
unsafe {
let size = 0x100;
let task = mach_task_self();
let mut address: mach_vm_address_t = 0;
assert_eq!(
mach_vm_allocate(task, &mut address, size, VM_FLAGS_ANYWHERE),
KERN_SUCCESS
);
assert_eq!(mach_vm_deallocate(task, address, size), KERN_SUCCESS);
}
}
#[test]
fn mach_vm_region_sanity() {
use mem;
use vm_prot::{VM_PROT_EXECUTE, VM_PROT_READ};
use vm_region::{vm_region_basic_info_64, VM_REGION_BASIC_INFO_64};
unsafe {
let mut size = 0x10;
let mut object_name = 0;
let mut address = mach_vm_region_sanity as mach_vm_address_t;
let mut info: vm_region_basic_info_64 = mem::zeroed();
let mut info_size = vm_region_basic_info_64::count();
let result = mach_vm_region(
mach_task_self(),
&mut address,
&mut size,
VM_REGION_BASIC_INFO_64,
(&mut info as *mut _) as vm_region_info_t,
&mut info_size,
&mut object_name,
);
assert_eq!(result, KERN_SUCCESS);
assert_eq!(info.protection, VM_PROT_READ | VM_PROT_EXECUTE);
}
}
}

18
vendor/mach2/src/vm_attributes.rs vendored Normal file
View File

@@ -0,0 +1,18 @@
//! This module corresponds to `mach/vm_attributes.h`.
pub type vm_machine_attribute_t = ::libc::c_uint;
pub const MATTR_CACHE: vm_machine_attribute_t = 1;
pub const MATTR_MIGRATE: vm_machine_attribute_t = 1 << 1;
pub const MATTR_REPLICATE: vm_machine_attribute_t = 1 << 2;
pub type vm_machine_attribute_val_t = ::libc::c_int;
pub const MATTR_VAL_OFF: vm_machine_attribute_val_t = 0;
pub const MATTR_VAL_ON: vm_machine_attribute_val_t = 1;
pub const MATTR_VAL_GET: vm_machine_attribute_val_t = 2;
pub const MATTR_VAL_CACHE_FLUSH: vm_machine_attribute_val_t = 6;
pub const MATTR_VAL_DCACHE_FLUSH: vm_machine_attribute_val_t = 7;
pub const MATTR_VAL_ICACHE_FLUSH: vm_machine_attribute_val_t = 8;
pub const MATTR_VAL_CACHE_SYNC: vm_machine_attribute_val_t = 9;
pub const MATTR_VAL_GET_INFO: vm_machine_attribute_val_t = 10;

15
vendor/mach2/src/vm_behavior.rs vendored Normal file
View File

@@ -0,0 +1,15 @@
//! This module corresponds to `mach/vm_behavior.h`.
pub type vm_behavior_t = ::libc::c_int;
pub const VM_BEHAVIOR_DEFAULT: vm_behavior_t = 0;
pub const VM_BEHAVIOR_RANDOM: vm_behavior_t = 1;
pub const VM_BEHAVIOR_SEQUENTIAL: vm_behavior_t = 2;
pub const VM_BEHAVIOR_RSEQNTL: vm_behavior_t = 3;
pub const VM_BEHAVIOR_WILLNEED: vm_behavior_t = 4;
pub const VM_BEHAVIOR_DONTNEED: vm_behavior_t = 5;
pub const VM_BEHAVIOR_FREE: vm_behavior_t = 6;
pub const VM_BEHAVIOR_ZERO_WIRED_PAGES: vm_behavior_t = 7;
pub const VM_BEHAVIOR_REUSABLE: vm_behavior_t = 8;
pub const VM_BEHAVIOR_REUSE: vm_behavior_t = 9;
pub const VM_BEHAVIOR_CAN_REUSE: vm_behavior_t = 10;

10
vendor/mach2/src/vm_inherit.rs vendored Normal file
View File

@@ -0,0 +1,10 @@
//! This module corresponds to `mach/vm_inherit.h`.
pub type vm_inherit_t = ::libc::c_uint;
pub const VM_INHERIT_SHARE: vm_inherit_t = 0;
pub const VM_INHERIT_COPY: vm_inherit_t = 1;
pub const VM_INHERIT_NONE: vm_inherit_t = 2;
pub const VM_INHERIT_DONATE_COPY: vm_inherit_t = 3;
pub const VM_INHERIT_DEFAULT: vm_inherit_t = VM_INHERIT_COPY;
pub const VM_INHERIT_LAST_VALID: vm_inherit_t = VM_INHERIT_NONE;

40
vendor/mach2/src/vm_page_size.rs vendored Normal file
View File

@@ -0,0 +1,40 @@
//! This module roughly corresponds to `mach/vm_page_size.h`
use vm_types::{mach_vm_offset_t, mach_vm_size_t, vm_size_t};
extern "C" {
pub static vm_page_size: vm_size_t;
pub static vm_page_mask: vm_size_t;
pub static vm_page_shift: ::libc::c_int;
}
#[allow(clippy::missing_safety_doc)] // FIXME
pub unsafe fn mach_vm_trunc_page(x: mach_vm_offset_t) -> mach_vm_offset_t {
x & !(vm_page_mask as mach_vm_size_t)
}
#[allow(clippy::missing_safety_doc)] // FIXME
pub unsafe fn mach_vm_round_page(x: mach_vm_offset_t) -> mach_vm_offset_t {
(x + vm_page_mask as mach_vm_size_t) & !(vm_page_mask as mach_vm_size_t)
}
#[cfg(test)]
mod tests {
use vm_page_size::*;
use vm_types::mach_vm_size_t;
#[test]
fn page_size() {
unsafe {
assert!(vm_page_size > 0);
assert!(vm_page_size % 2 == 0);
assert_eq!(mach_vm_round_page(1), vm_page_size as mach_vm_size_t);
#[cfg(target_arch = "aarch64")]
assert_eq!(vm_page_size, 16384);
#[cfg(not(target_arch = "aarch64"))]
assert_eq!(vm_page_size, 4096);
}
}
}

13
vendor/mach2/src/vm_prot.rs vendored Normal file
View File

@@ -0,0 +1,13 @@
//! This module corresponds to `mach/vm_prot.h`.
pub type vm_prot_t = ::libc::c_int;
pub const VM_PROT_NONE: vm_prot_t = 0;
pub const VM_PROT_READ: vm_prot_t = 1;
pub const VM_PROT_WRITE: vm_prot_t = 1 << 1;
pub const VM_PROT_EXECUTE: vm_prot_t = 1 << 2;
pub const VM_PROT_NO_CHANGE: vm_prot_t = 1 << 3;
pub const VM_PROT_COPY: vm_prot_t = 1 << 4;
pub const VM_PROT_WANTS_COPY: vm_prot_t = 1 << 4;
pub const VM_PROT_DEFAULT: vm_prot_t = VM_PROT_READ | VM_PROT_WRITE;
pub const VM_PROT_ALL: vm_prot_t = VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE;

42
vendor/mach2/src/vm_purgable.rs vendored Normal file
View File

@@ -0,0 +1,42 @@
//! This module corresponds to `mach/vm_purgable.h`.
pub type vm_purgable_t = ::libc::c_int;
pub const VM_PURGABLE_SET_STATE: vm_purgable_t = 0;
pub const VM_PURGABLE_GET_STATE: vm_purgable_t = 1;
pub const VM_VOLATILE_GROUP_SHIFT: ::libc::c_int = 8;
pub const VM_VOLATILE_GROUP_MASK: ::libc::c_int = 7 << VM_VOLATILE_GROUP_SHIFT;
pub const VM_VOLATILE_GROUP_DEFAULT: ::libc::c_int = VM_VOLATILE_GROUP_0;
pub const VM_VOLATILE_GROUP_0: ::libc::c_int = 0 << VM_VOLATILE_GROUP_SHIFT;
pub const VM_VOLATILE_GROUP_1: ::libc::c_int = 1 << VM_VOLATILE_GROUP_SHIFT;
pub const VM_VOLATILE_GROUP_2: ::libc::c_int = 2 << VM_VOLATILE_GROUP_SHIFT;
pub const VM_VOLATILE_GROUP_3: ::libc::c_int = 3 << VM_VOLATILE_GROUP_SHIFT;
pub const VM_VOLATILE_GROUP_4: ::libc::c_int = 4 << VM_VOLATILE_GROUP_SHIFT;
pub const VM_VOLATILE_GROUP_5: ::libc::c_int = 5 << VM_VOLATILE_GROUP_SHIFT;
pub const VM_VOLATILE_GROUP_6: ::libc::c_int = 6 << VM_VOLATILE_GROUP_SHIFT;
pub const VM_VOLATILE_GROUP_7: ::libc::c_int = 7 << VM_VOLATILE_GROUP_SHIFT;
pub const VM_PURGABLE_BEHAVIOR_SHIFT: ::libc::c_int = 6;
pub const VM_PURGABLE_BEHAVIOR_MASK: ::libc::c_int = 1 << VM_PURGABLE_BEHAVIOR_SHIFT;
pub const VM_PURGABLE_BEHAVIOR_FIFO: ::libc::c_int = 0 << VM_PURGABLE_BEHAVIOR_SHIFT;
pub const VM_PURGABLE_BEHAVIOR_LIFO: ::libc::c_int = 1 << VM_PURGABLE_BEHAVIOR_SHIFT;
pub const VM_PURGABLE_ORDERING_SHIFT: ::libc::c_int = 5;
pub const VM_PURGABLE_ORDERING_MASK: ::libc::c_int = 1 << VM_PURGABLE_ORDERING_SHIFT;
pub const VM_PURGABLE_ORDERING_OBSOLETE: ::libc::c_int = 1 << VM_PURGABLE_ORDERING_SHIFT;
pub const VM_PURGABLE_ORDERING_NORMAL: ::libc::c_int = 0 << VM_PURGABLE_ORDERING_SHIFT;
pub const VM_VOLATILE_ORDER_SHIFT: ::libc::c_int = 4;
pub const VM_VOLATILE_ORDER_MASK: ::libc::c_int = 1 << VM_VOLATILE_ORDER_SHIFT;
pub const VM_VOLATILE_MAKE_FIRST_IN_GROUP: ::libc::c_int = 1 << VM_VOLATILE_ORDER_SHIFT;
pub const VM_VOLATILE_MAKE_LAST_IN_GROUP: ::libc::c_int = 0 << VM_VOLATILE_ORDER_SHIFT;
pub const VM_PURGABLE_STATE_MIN: ::libc::c_int = 0;
pub const VM_PURGABLE_STATE_MAX: ::libc::c_int = 3;
pub const VM_PURGABLE_STATE_MASK: ::libc::c_int = 3;
pub const VM_PURGABLE_NONVOLATILE: ::libc::c_int = 0;
pub const VM_PURGABLE_VOLATILE: ::libc::c_int = 1;
pub const VM_PURGABLE_EMPTY: ::libc::c_int = 2;
pub const VM_PURGABLE_DENY: ::libc::c_int = 3;

238
vendor/mach2/src/vm_region.rs vendored Normal file
View File

@@ -0,0 +1,238 @@
//! This module roughly corresponds to `mach/vm_region.h`.
use boolean::boolean_t;
use mem;
use memory_object_types::{memory_object_offset_t, vm_object_id_t};
use message::mach_msg_type_number_t;
use vm_behavior::vm_behavior_t;
use vm_inherit::vm_inherit_t;
use vm_prot::vm_prot_t;
use vm_types::{mach_vm_address_t, mach_vm_size_t};
pub type vm32_object_id_t = u32;
pub type vm_region_info_t = *mut ::libc::c_int;
pub type vm_region_info_64_t = *mut ::libc::c_int;
pub type vm_region_recurse_info_t = *mut ::libc::c_int;
pub type vm_region_recurse_info_64_t = *mut ::libc::c_int;
pub type vm_region_flavor_t = ::libc::c_int;
pub type vm_region_info_data_t = [::libc::c_int; VM_REGION_INFO_MAX as usize];
pub type vm_region_basic_info_64_t = *mut vm_region_basic_info_64;
pub type vm_region_basic_info_data_64_t = vm_region_basic_info_64;
pub type vm_region_basic_info_t = *mut vm_region_basic_info;
pub type vm_region_basic_info_data_t = vm_region_basic_info;
pub type vm_region_extended_info_t = *mut vm_region_extended_info;
pub type vm_region_extended_info_data_t = vm_region_extended_info;
pub type vm_region_top_info_t = *mut vm_region_top_info;
pub type vm_region_top_info_data_t = vm_region_top_info;
pub type vm_region_submap_info_t = *mut vm_region_submap_info;
pub type vm_region_submap_info_data_t = vm_region_submap_info;
pub type vm_region_submap_info_64_t = *mut vm_region_submap_info_64;
pub type vm_region_submap_info_data_64_t = vm_region_submap_info_64;
pub type vm_region_submap_short_info_64_t = *mut vm_region_submap_short_info_64;
pub type vm_region_submap_short_info_data_64_t = vm_region_submap_short_info_64;
pub type vm_page_info_t = *mut ::libc::c_int;
pub type vm_page_info_flavor_t = ::libc::c_int;
pub type vm_page_info_basic_t = *mut vm_page_info_basic;
pub type vm_page_info_basic_data_t = vm_page_info_basic;
pub type mach_vm_read_entry_t = [mach_vm_read_entry; VM_MAP_ENTRY_MAX as usize];
pub const VM_REGION_INFO_MAX: ::libc::c_int = 1 << 10;
pub const VM_MAP_ENTRY_MAX: ::libc::c_int = 1 << 8;
pub const VM_PAGE_INFO_BASIC: vm_page_info_flavor_t = 1;
pub const VM_REGION_BASIC_INFO_64: vm_region_flavor_t = 9;
pub const VM_REGION_BASIC_INFO: vm_region_flavor_t = 10;
pub const VM_REGION_EXTENDED_INFO: vm_region_flavor_t = 13;
pub const VM_REGION_TOP_INFO: vm_region_flavor_t = 12;
pub const SM_COW: ::libc::c_uchar = 1;
pub const SM_PRIVATE: ::libc::c_uchar = 2;
pub const SM_EMPTY: ::libc::c_uchar = 3;
pub const SM_SHARED: ::libc::c_uchar = 4;
pub const SM_TRUESHARED: ::libc::c_uchar = 5;
pub const SM_PRIVATE_ALIASED: ::libc::c_uchar = 6;
pub const SM_SHARED_ALIASED: ::libc::c_uchar = 7;
#[repr(C, packed(4))]
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct vm_region_basic_info_64 {
pub protection: vm_prot_t,
pub max_protection: vm_prot_t,
pub inheritance: vm_inherit_t,
pub shared: boolean_t,
pub reserved: boolean_t,
pub offset: memory_object_offset_t,
pub behavior: vm_behavior_t,
pub user_wired_count: ::libc::c_ushort,
}
impl vm_region_basic_info_64 {
pub fn count() -> mach_msg_type_number_t {
(mem::size_of::<Self>() / mem::size_of::<::libc::c_int>()) as mach_msg_type_number_t
}
}
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct vm_region_basic_info {
pub protection: vm_prot_t,
pub max_protection: vm_prot_t,
pub inheritance: vm_inherit_t,
pub shared: boolean_t,
pub reserved: boolean_t,
pub offset: u32,
pub behavior: vm_behavior_t,
pub user_wired_count: ::libc::c_ushort,
}
impl vm_region_basic_info {
pub fn count() -> mach_msg_type_number_t {
(mem::size_of::<Self>() / mem::size_of::<::libc::c_int>()) as mach_msg_type_number_t
}
}
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct vm_region_extended_info {
pub protection: vm_prot_t,
pub user_tag: ::libc::c_uint,
pub pages_resident: ::libc::c_uint,
pub pages_shared_now_private: ::libc::c_uint,
pub pages_swapped_out: ::libc::c_uint,
pub pages_dirtied: ::libc::c_uint,
pub ref_count: ::libc::c_uint,
pub shadow_depth: ::libc::c_ushort,
pub external_pager: ::libc::c_uchar,
pub share_mode: ::libc::c_uchar,
pub pages_reusable: ::libc::c_uint,
}
impl vm_region_extended_info {
pub fn count() -> mach_msg_type_number_t {
(mem::size_of::<Self>() / mem::size_of::<::libc::c_int>()) as mach_msg_type_number_t
}
}
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct vm_region_top_info {
pub obj_id: ::libc::c_uint,
pub ref_count: ::libc::c_uint,
pub private_pages_resident: ::libc::c_uint,
pub shared_pages_resident: ::libc::c_uint,
pub share_mode: ::libc::c_uchar,
}
impl vm_region_top_info {
pub fn count() -> mach_msg_type_number_t {
(mem::size_of::<Self>() / mem::size_of::<::libc::c_int>()) as mach_msg_type_number_t
}
}
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct vm_region_submap_info {
pub protection: vm_prot_t,
pub max_protection: vm_prot_t,
pub inheritance: vm_inherit_t,
pub offset: u32,
pub user_tag: ::libc::c_uint,
pub pages_resident: ::libc::c_uint,
pub pages_shared_now_private: ::libc::c_uint,
pub pages_swapped_out: ::libc::c_uint,
pub pages_dirtied: ::libc::c_uint,
pub ref_count: ::libc::c_uint,
pub shadow_depth: ::libc::c_ushort,
pub external_pager: ::libc::c_uchar,
pub share_mode: ::libc::c_uchar,
pub is_submap: boolean_t,
pub behavior: vm_behavior_t,
pub object_id: vm32_object_id_t,
pub user_wired_count: ::libc::c_ushort,
}
impl vm_region_submap_info {
pub fn count() -> mach_msg_type_number_t {
(mem::size_of::<Self>() / mem::size_of::<::libc::c_int>()) as mach_msg_type_number_t
}
}
#[repr(C, packed(4))]
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct vm_region_submap_info_64 {
pub protection: vm_prot_t,
pub max_protection: vm_prot_t,
pub inheritance: vm_inherit_t,
pub offset: memory_object_offset_t,
pub user_tag: ::libc::c_uint,
pub pages_resident: ::libc::c_uint,
pub pages_shared_now_private: ::libc::c_uint,
pub pages_swapped_out: ::libc::c_uint,
pub pages_dirtied: ::libc::c_uint,
pub ref_count: ::libc::c_uint,
pub shadow_depth: ::libc::c_ushort,
pub external_pager: ::libc::c_uchar,
pub share_mode: ::libc::c_uchar,
pub is_submap: boolean_t,
pub behavior: vm_behavior_t,
pub object_id: vm32_object_id_t,
pub user_wired_count: ::libc::c_ushort,
pub pages_reusable: ::libc::c_uint,
}
impl vm_region_submap_info_64 {
pub fn count() -> mach_msg_type_number_t {
(mem::size_of::<Self>() / mem::size_of::<::libc::c_int>()) as mach_msg_type_number_t
}
}
#[repr(C, packed(4))]
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct vm_region_submap_short_info_64 {
pub protection: vm_prot_t,
pub max_protection: vm_prot_t,
pub inheritance: vm_inherit_t,
pub offset: memory_object_offset_t,
pub user_tag: ::libc::c_uint,
pub ref_count: ::libc::c_uint,
pub shadow_depth: ::libc::c_ushort,
pub external_pager: ::libc::c_uchar,
pub share_mode: ::libc::c_uchar,
pub is_submap: boolean_t,
pub behavior: vm_behavior_t,
pub object_id: vm32_object_id_t,
pub user_wired_count: ::libc::c_ushort,
}
impl vm_region_submap_short_info_64 {
pub fn count() -> mach_msg_type_number_t {
(mem::size_of::<Self>() / mem::size_of::<::libc::c_int>()) as mach_msg_type_number_t
}
}
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct vm_page_info_basic {
pub disposition: ::libc::c_int,
pub ref_count: ::libc::c_int,
pub object_id: vm_object_id_t,
pub offset: memory_object_offset_t,
pub depth: ::libc::c_int,
pub __pad: ::libc::c_int,
}
impl vm_page_info_basic {
pub fn count() -> mach_msg_type_number_t {
(mem::size_of::<Self>() / mem::size_of::<::libc::c_int>()) as mach_msg_type_number_t
}
}
#[repr(C, packed(4))]
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct mach_vm_read_entry {
pub address: mach_vm_address_t,
pub size: mach_vm_size_t,
}

58
vendor/mach2/src/vm_statistics.rs vendored Normal file
View File

@@ -0,0 +1,58 @@
//! This module roughly corresponds to `mach/vm_statistics.h`
use vm_types::{integer_t, natural_t};
pub type vm_statistics_t = *mut vm_statistics;
pub type vm_statistics_data_t = vm_statistics;
pub const VM_PAGE_QUERY_PAGE_PRESENT: integer_t = 1;
pub const VM_PAGE_QUERY_PAGE_FICTITIOUS: integer_t = 1 << 1;
pub const VM_PAGE_QUERY_PAGE_REF: integer_t = 1 << 2;
pub const VM_PAGE_QUERY_PAGE_DIRTY: integer_t = 1 << 3;
pub const VM_MEMORY_MALLOC: ::libc::c_uint = 1;
pub const VM_MEMORY_MALLOC_SMALL: ::libc::c_uint = 2;
pub const VM_MEMORY_MALLOC_LARGE: ::libc::c_uint = 3;
pub const VM_MEMORY_MALLOC_HUGE: ::libc::c_uint = 4;
pub const VM_MEMORY_SBRK: ::libc::c_uint = 5;
pub const VM_MEMORY_ANALYSIS_TOOL: ::libc::c_uint = 10;
pub const VM_MEMORY_MACH_MSG: ::libc::c_uint = 20;
pub const VM_MEMORY_IOKIT: ::libc::c_uint = 21;
pub const VM_MEMORY_STACK: ::libc::c_uint = 30;
pub const VM_MEMORY_GUARD: ::libc::c_uint = 31;
pub const VM_MEMORY_SHARED_PMAP: ::libc::c_uint = 32;
pub const VM_MEMORY_DYLIB: ::libc::c_uint = 33;
pub const VM_MEMORY_APPKIT: ::libc::c_uint = 40;
pub const VM_MEMORY_FOUNDATION: ::libc::c_uint = 41;
pub const VM_MEMORY_COREGRAPHICS: ::libc::c_uint = 42;
pub const VM_MEMORY_CARBON: ::libc::c_uint = 43;
pub const VM_MEMORY_JAVA: ::libc::c_uint = 44;
pub const VM_MEMORY_ATS: ::libc::c_uint = 50;
pub const VM_MEMORY_DYLD: ::libc::c_uint = 60;
pub const VM_MEMORY_DYLD_MALLOC: ::libc::c_uint = 61;
pub const VM_MEMORY_APPLICATION_SPECIFIC_1: ::libc::c_uint = 240;
pub const VM_MEMORY_APPLICATION_SPECIFIC_16: ::libc::c_uint = 255;
pub const VM_FLAGS_FIXED: ::libc::c_int = 0x0;
pub const VM_FLAGS_ANYWHERE: ::libc::c_int = 0x1;
pub const VM_FLAGS_OVERWRITE: ::libc::c_int = 0x4000;
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct vm_statistics {
pub free_count: natural_t,
pub active_count: natural_t,
pub inactive_count: natural_t,
pub wire_count: natural_t,
pub zero_fill_count: natural_t,
pub reactivations: natural_t,
pub pageins: natural_t,
pub pageouts: natural_t,
pub faults: natural_t,
pub cow_faults: natural_t,
pub lookups: natural_t,
pub hits: natural_t,
pub purgeable_count: natural_t,
pub purges: natural_t,
pub speculative_count: natural_t,
}

11
vendor/mach2/src/vm_sync.rs vendored Normal file
View File

@@ -0,0 +1,11 @@
//! This module corresponds to `mach/vm_sync.h`.
pub type vm_sync_t = ::libc::c_uint;
pub const VM_SYNC_ASYNCHRONOUS: vm_sync_t = 1;
pub const VM_SYNC_SYNCHRONOUS: vm_sync_t = 1 << 1;
pub const VM_SYNC_INVALIDATE: vm_sync_t = 1 << 2;
pub const VM_SYNC_KILLPAGES: vm_sync_t = 1 << 3;
pub const VM_SYNC_DEACTIVATE: vm_sync_t = 1 << 4;
pub const VM_SYNC_CONTIGUOUS: vm_sync_t = 1 << 5;
pub const VM_SYNC_REUSABLEPAGES: vm_sync_t = 1 << 6;

19
vendor/mach2/src/vm_types.rs vendored Normal file
View File

@@ -0,0 +1,19 @@
//! This module roughly corresponds to `mach/i386/vm_types.h` and `mach/arm/vm_types.h` on aarch64.
pub type natural_t = ::libc::c_uint;
pub type integer_t = ::libc::c_int;
pub type user_addr_t = u64;
pub type mach_vm_address_t = u64;
pub type mach_vm_offset_t = u64;
pub type mach_vm_size_t = u64;
pub type vm_map_offset_t = u64;
pub type vm_map_address_t = u64;
pub type vm_map_size_t = u64;
pub type vm_map_t = ::port::mach_port_t;
pub type vm_offset_t = ::libc::uintptr_t;
pub type vm_size_t = ::libc::uintptr_t;
pub type vm_address_t = vm_offset_t;
pub type mach_port_context_t = mach_vm_address_t;