Vendor deps.
This commit is contained in:
1 parent
294527085e
commit
91e18fde3a
1714 files changed
+556667
-7
No files matched your search
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"files":{".cargo_vcs_info.json":"3ae25e402263c1d372a9c6a0b09d4f63d6744a1f8d7912108191c3b6276ceb4f",".editorconfig":"e57fecd6b82cd69640ca1bc4e44f0c7acfe5fc12f641f14af9536e323b4159db",".git-blame-ignore-revs":"761aa385c661241fa77c15b502c361398cf500bbb9f8c3a4579b412c4c6249d7",".release-plz.toml":"fcf2d382c4a2abd96caf9cc391b63e0c94d5832f5c48e9ab9eb4b2c847c0887c",".rustfmt.toml":"c88d9ba0e884291a2904d43cc7b940fafcb1ab443cdb7bcfca7117809c4f2816","CHANGELOG.md":"1629ffb688b6f2ea0c1720ba1f768904ef9f27da4e9e7f32b76d6d52cd1940d1","CONTRIBUTING.md":"ed7177a16e331da75244df3232c4e34f70bf58d2b31cffffd9b769a4745de567","Cargo.lock":"7b23220c994971e1ef93c3a13c78476fb35043e701a2e9c3f80567af3d94a9c3","Cargo.toml":"95159789ef9c9aaee8230b13be5c89594833a7bf2db299e61eb23b512cb67144","Cargo.toml.orig":"cba73b06128539455a57f7432e466ba583358ecb83ef8eda60731751b8a9f5cc","LICENSE-APACHE":"62c7a1e35f56406896d7aa7ca52d0cc0d272ac022b5d2796e7d6905db8a3636a","LICENSE-MIT":"123a331b5dbf04c30097fa43b8f858bc85df671fe776de498d01f3d6b7c1f69e","README.md":"5af805465cb8cfa4186cb75df07f4aebd35a3d88f497ed71d189b74ecf8cbcdc","build.rs":"e47f4a6762799b6e69cefc7acdb3291df828010e4de20609f7378f9c94ea29e6","etc/libc-util.py":"a99fdefe6354c28c52eeac9c1e851041b69dad25b8a3b521d4f57b761517c798","src/fuchsia/aarch64.rs":"34105478e20e9ce40b9e484eea6494e2408fead17c13500da90a2d44d996ce63","src/fuchsia/mod.rs":"3b17821b3ceaf3430b6503965f5337b033817077e289e3cce29c80bf3960770f","src/fuchsia/riscv64.rs":"a91ae8276df139f6181591be7209f9a68e9f3de5eec881c2e1c9768c53c4e292","src/fuchsia/x86_64.rs":"543ea567b29d646afc026956ee5e652c10e87256789058e7e39f91bf2fe8bf14","src/hermit.rs":"ebfe4d68e8f0323dc97d7e3165f7b315e4058ee9f5ced3e76f181f0a492e75e1","src/lib.rs":"0701ce9606a01448c3229517fab308d49d160cccfca02ed6ebd8edfd8bb37d66","src/macros.rs":"6d534c7b511cd19217ba205a4a30e289f7243ba3706645d6ec5cb417b7bdac7c","src/new/aix/mod.rs":"df0de5d8e452a8abb27727b8451b2ceff3bb856f7e5d9e9306df5177e4c6326f","src/new/aix/unistd.rs":"bcbb65f70759cd84c81fc24ea36aac423edb8f9d7148f65b545ee63954411fd1","src/new/apple/libc/signal.rs":"a960b6153775d791055b278534f79e21f8ff76c2c0c2891271e7abdf26e193d3","src/new/apple/libc/unistd.rs":"bcbb65f70759cd84c81fc24ea36aac423edb8f9d7148f65b545ee63954411fd1","src/new/apple/libpthread/mod.rs":"1e99efe513b0ee1fa6e53daf5950fc027380b1d71d793eca9e5b22af7b331b5b","src/new/apple/libpthread/pthread_/introspection.rs":"3c797ded6d1a55670f9537a997407cf2267e6c7e7dbfa360d32474e2432979af","src/new/apple/libpthread/pthread_/pthread.rs":"c2b680120ec8db839e702c4340bc39748ac34c806b5fc08acea0a4593131a015","src/new/apple/libpthread/pthread_/pthread_impl.rs":"57a9925a75b79d092c65288b8a8eb21bfb6c7de4c70d37a49018b4eb8b32a646","src/new/apple/libpthread/pthread_/pthread_spis.rs":"1ba51c251249822fae222db6a19e17278ffffc424fc6eea30282a6171491edbe","src/new/apple/libpthread/pthread_/qos.rs":"40f816fb6cebd19ead21197671e5425b454144515ee4b966d00db32ba6b0dfe5","src/new/apple/libpthread/pthread_/sched.rs":"7b22a3204e72d5013ebac7b830235d50883aefca86d720f1f38b93d54e309477","src/new/apple/libpthread/pthread_/spawn.rs":"daef8af8ed0b3d16922c2f5a511a67f57f69b5f80dfe37362bd0b410213f95ca","src/new/apple/libpthread/pthread_/stack_np.rs":"d1b6e2eab1850c303f8eec4059b3e8ec57d69eb47c216243f6b4b7523761fc29","src/new/apple/libpthread/sys/_pthread/_pthread_types.rs":"a7a4307d7c3f91a6b03f76599fac5f40de556e5652123c6bc3b95df2bfa685de","src/new/apple/libpthread/sys/mod.rs":"337265fe49d77a7dcc879cd23e4f5baedcffab4808433dfb6ab9deb4ab490380","src/new/apple/libpthread/sys/qos.rs":"a6297cbab4089b330416bfcbe13b6d7aa8e75352299295046429b2e9d3bada42","src/new/apple/mod.rs":"96e4f2300247b8b587f312aeb8de991c65afd6a1693bbe0dc25610b9574d66db","src/new/apple/xnu/arm/_mcontext.rs":"63f1c62b47e7d7181c2b85f3cd3833c69a29eb0cad37a5754bfa6b5954ae7f6f","src/new/apple/xnu/i386/_mcontext.rs":"50543eaa5cf1d87f900b0c3e531dbfefd7586e1be2be3406223b2319edfcb7f2","src/new/apple/xnu/mach/arm/_structs.rs":"8e4af554170cef61c9143f92a283fd7eef66ad78824f194bbc89b098c6049a43","src/new/apple/xnu/mach/i386/_structs.rs":"d7316b7d3fa5e55a5818cfd8a1977921bb14e07133648cffa8f4d9da2e31a604","src/new/apple/xnu/mach/machine/_structs.rs":"82f5a7f751897c882ed4c378d6282976ff21cf0c9cdf7f3be3cecd369a63b6f8","src/new/apple/xnu/mach/mod.rs":"46aad5c7197df2cc57c4392d9019034236233f0240bc7975f9e22ac33c9d40ed","src/new/apple/xnu/machine/_mcontext.rs":"166b0a450b730e2a943ca08a0c70061effb77ff9eff6f41c7b0c51b2d4215db9","src/new/apple/xnu/mod.rs":"9359b08f58f8cd88ade250166850202daa6e3278d387c072ac51e8f0c0cced19","src/new/apple/xnu/net/bpf.rs":"0b6477e4ff541fbabe66ac2729524fc38c1e4be52a2f9e34c4155be732643318","src/new/apple/xnu/net/mod.rs":"7868b2b0065e01776ec4badaf166cac4ccb68ed98bf9bc284dbaffbf33e367b5","src/new/apple/xnu/netinet6/in6_var.rs":"61d6fc1ed1bbff8b0aa7de219b181aa68cc870ef290a6c39f5f3703eab955608","src/new/apple/xnu/netinet6/mod.rs":"dd1b80a3a57ffe7b48c60639a003d6e293646eb7a2cf209bf3673b043edbe611","src/new/apple/xnu/sys/_types/_ucontext.rs":"1651132d39042Line truncated
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"git": {
|
||||
"sha1": "ef0906e20828777175f65caa7e681a0ce33c559a"
|
||||
},
|
||||
"path_in_vcs": ""
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
[*.sh]
|
||||
# See https://github.com/mvdan/sh/blob/master/cmd/shfmt/shfmt.1.scd#examples
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
switch_case_indent = true
|
||||
space_redirects = true
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
# Format macro bodies
|
||||
50f26e08e146b7e9c7d1af9614486eba327d1e31
|
||||
|
||||
# Automated changes related to the 2021 edition upgrade
|
||||
643182f7da26cedb09349b8bb3735c2e58ba24e6
|
||||
108310db03e7db35ef48a902d9ce9a88ab8f9b77
|
||||
Vendored
+49
@@ -0,0 +1,49 @@
|
||||
[workspace]
|
||||
git_release_name = "{{ version }}"
|
||||
git_tag_name = "{{ version }}"
|
||||
|
||||
[changelog]
|
||||
body = """
|
||||
## [{{ version | trim_start_matches(pat="v") }}]\
|
||||
{%- if release_link -%}\
|
||||
({{ release_link }})\
|
||||
{% endif %} \
|
||||
- {{ timestamp | date(format="%Y-%m-%d") }}
|
||||
{% for group, commits in commits | group_by(attribute="group") %}
|
||||
### {{ group | upper_first }}
|
||||
{% for commit in commits %}
|
||||
- {% if commit.scope -%}{{ commit.scope | upper_first }}: {% endif %}
|
||||
{%- if commit.breaking %}[**breaking**] {% endif %}
|
||||
{{- commit.message }}
|
||||
{%- if commit.links %} ([{{ commit.links.1.text }}]({{ commit.links.1.href }})){% endif -%}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{%- if github -%}
|
||||
{% if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %}
|
||||
## New Contributors ❤️
|
||||
{% endif %}\
|
||||
{% for contributor in github.contributors | filter(attribute="is_first_time", value=true) %}
|
||||
* @{{ contributor.username }} made their first contribution
|
||||
{%- if contributor.pr_number %} in \
|
||||
[#{{ contributor.pr_number }}]({{ self::remote_url() }}/pull/{{ contributor.pr_number }}) \
|
||||
{%- endif %}
|
||||
{%- endfor -%}
|
||||
{%- endif %}
|
||||
"""
|
||||
|
||||
commit_parsers = [
|
||||
{ message = '(?i)^(\w+: )?feat', group = "added" },
|
||||
{ message = '(?i)^(\w+: )?add', group = "added" },
|
||||
{ message = '(?i)^(\w+: )?change', group = "changed" },
|
||||
{ message = '(?i)^(\w+: )?cleanup', group = "cleanup" },
|
||||
{ message = '(?i)^(\w+: )?deprecate', group = "deprecated" },
|
||||
{ message = '(?i)^(\w+: )?remove', group = "removed" },
|
||||
{ message = '(?i)^(\w+: )?fix', group = "fixed" },
|
||||
{ message = '(?i)^(\w+: )?fix', group = "fixed" },
|
||||
{ message = '^.*', group = "other" },
|
||||
]
|
||||
|
||||
link_parsers = [
|
||||
# Extract backport patterns
|
||||
{ pattern = '\(backport <.*/(\d+)>\)', text = "#$1", href = "https://github.com/rust-lang/libc/pull/$1"}
|
||||
]
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
edition = "2021"
|
||||
error_on_line_overflow = true
|
||||
group_imports = "StdExternalCrate"
|
||||
imports_granularity = "Module"
|
||||
# This crate gets large lists of reexports. Use vertical to reduce conflicts.
|
||||
imports_layout = "Vertical"
|
||||
Vendored
+1212
File diff suppressed because it is too large.
Load diff
Vendored
+152
@@ -0,0 +1,152 @@
|
||||
# Contributing to `libc`
|
||||
|
||||
Welcome! If you are reading this document, it means you are interested in
|
||||
contributing to the `libc` crate.
|
||||
|
||||
## v1.0 Roadmap
|
||||
|
||||
`libc` has two active branches: `main` and `libc-0.2`. `main` is for active
|
||||
development of the upcoming v1.0 release, and should be the target of all pull
|
||||
requests. `libc-0.2` is for updates to the currently released version.
|
||||
|
||||
If a pull request to `main` is a good candidate for inclusion in an `0.2.x`
|
||||
release, include `@rustbot label stable-nominated` in a comment to propose this.
|
||||
Almost everything should be included in stable, unless it involves breaking
|
||||
changes.
|
||||
|
||||
Once a `stable-nominated` PR targeting `main` has merged, it can be cherry
|
||||
picked to the `libc-0.2` branch. A maintainer will likely do these cherry picks
|
||||
in a batch before a release, so there is no need for any action as a PR author.
|
||||
|
||||
When cherry picking, run the following after branching from `libc-0.2`:
|
||||
`git cherry-pick -xe commit-sha-on-main` (or `git cherry-pick -xe
|
||||
start-sha^..end-sha` if a range of commits is needed). `git` will automatically
|
||||
add the "cherry picked from commit" note, but try to add a backport note so the
|
||||
original PR gets crosslinked:
|
||||
|
||||
```
|
||||
# ... original commit message ...
|
||||
|
||||
(backport <https://github.com/rust-lang/libc/pull/1234>) # add manually
|
||||
(cherry picked from commit 104b6a4ae31c726814c36318dc718470cc96e167) # added by git
|
||||
```
|
||||
|
||||
Cherry pick PRs can then target `libc-0.2`.
|
||||
|
||||
See the [tracking issue](https://github.com/rust-lang/libc/issues/3248) for
|
||||
details.
|
||||
|
||||
## Adding an API
|
||||
|
||||
Want to use an API which currently isn't bound in `libc`? It's quite easy to add
|
||||
one!
|
||||
|
||||
If you are adding API for a header that doesn't already have some bindings,
|
||||
create a new file in the appropriate location in `src/new`. These modules should
|
||||
approximately match source trees: try to follow the patterns that are there but
|
||||
don't hesitate to ask maintainers if guidance is needed.
|
||||
|
||||
If some bindings for the relevant header has already been added outside of
|
||||
`src/new`, it is fine to extend what already exists. Everything outside of
|
||||
`src/new` uses a hierarchial structure: a single path from root to a leaf node
|
||||
represents a single platform, and adding API at a given level will make it
|
||||
available on all children.
|
||||
|
||||
We are currently in a reorganization process, moving from the hierarchial
|
||||
structure to the source-mapped structure in `src/new`.
|
||||
|
||||
New items (i.e. functions, constants etc.) should also be added to the symbol
|
||||
list(s) found in the `libc-test/semver` directory. These lists track of what
|
||||
API is public in the libc crate and ensures they remain available between
|
||||
changes to the crate. If the new symbol(s) are available on all supported Unixes
|
||||
it should be added to `unix.txt` list[^1], otherwise they should be added to the
|
||||
OS-specific list(s).
|
||||
|
||||
With that in mind, the steps for adding a new API are:
|
||||
|
||||
1. Determine where to add your API.
|
||||
2. Add the API, including adding new symbol(s) to the semver lists.
|
||||
3. Send a PR to this repo.
|
||||
4. Wait for CI to pass, fixing errors.
|
||||
5. Wait for a merge!
|
||||
|
||||
[^1]: Note that this list has nothing to do with any Unix or Posix standard,
|
||||
it's just a list shared among all OSs that declare `#[cfg(unix)]`.
|
||||
|
||||
## Test before you commit
|
||||
|
||||
There are a few relevant tests in `libc`:
|
||||
|
||||
1. `libc-test` is the main test suite. This can be run locally with `cargo test
|
||||
--workspace`.
|
||||
|
||||
If needed, the `skip_*()` functions in `libc-test/build.rs` can be used to
|
||||
skip testing specific API.
|
||||
2. Style checker and formatter, located at [`./ci/style.py`][style-py]. Running
|
||||
this also invokes the code formatter. (This also formats code within macros,
|
||||
which `cargo fmt` won't do.)
|
||||
3. `ci/verify-build.py`, which checks the build on a wide range of targets.
|
||||
Typically there is no need to run this locally.
|
||||
|
||||
[style-py]: https://github.com/rust-lang/libc/blob/main/ci/style.py
|
||||
|
||||
## Submitting a Pull Request
|
||||
|
||||
When you submit a PR, please follow these guidelines to give your PR the best
|
||||
chance of being accepted:
|
||||
|
||||
1. All new API should be added to `libc-test/semver`, which makes sure it
|
||||
doesn't get removed in the future.
|
||||
2. All changes *must* have permalink to headers in commit messages. See
|
||||
[Source links](#source-links) below for more details.
|
||||
3. For any constants that are expected to change, e.g. `*LAST` or `*MAX`, try to
|
||||
add the following doc comment:
|
||||
|
||||
```rust
|
||||
/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
|
||||
/// for details.
|
||||
```
|
||||
5. Run tests locally, following the directions at
|
||||
[Test before you commit](test-before-you-commit). This is especially relevant
|
||||
for platforms that aren't tested on CI.
|
||||
|
||||
### Source links
|
||||
|
||||
Please include permalinks to headers in commit messages for all API changes.
|
||||
Common sources include:
|
||||
|
||||
* Linux uapi: https://github.com/torvalds/linux/tree/master/include/uapi
|
||||
* Glibc: https://sourceware.org/git/?p=glibc.git;a=tree
|
||||
* Musl: https://github.com/kraj/musl (original is https://git.musl-libc.org/cgit/musl/tree/)
|
||||
* Apple XNU: https://github.com/apple-oss-distributions/xnu, libc https://github.com/apple-oss-distributions/Libc/tree/main/include
|
||||
* Android: https://cs.android.com/android/platform/superproject/main
|
||||
* FreeBSD: https://github.com/freebsd/freebsd-src/tree/main/lib/libc
|
||||
* Illumos: https://github.com/illumos/illumos-gate/tree/master/usr/src/lib/libc
|
||||
* Fuchsia: https://cs.opensource.google/fuchsia/fuchsia/+/main:zircon/
|
||||
|
||||
After navigating to the relevant file and selecting relevant lines, get a
|
||||
permalink. On GitHub this is available by clicking the triple dots and
|
||||
selecting "copy permalink", and on the Android and Fuchsia source viewers
|
||||
this is available via l-r (links->commit).
|
||||
|
||||
If sources are closed, link to documentation or paste relevant C declarations.
|
||||
|
||||
(Including this information in the PR description is fine too, commit messages
|
||||
are preferred because they become part of history.)
|
||||
|
||||
## Breaking change policy
|
||||
|
||||
See `src/lib.rs` for details.
|
||||
|
||||
## Supported target policy
|
||||
|
||||
When Rust removes a support for a target, the libc crate also may remove the
|
||||
support at any time. MSRV may be different for different targets.
|
||||
|
||||
## Releasing change to crates.io
|
||||
|
||||
This repository uses [release-plz] to handle releases. Once your pull request
|
||||
has been merged, a maintainer needs to create the changelog and merge a PR
|
||||
bumping the version. This will automatically publish to crates.io!
|
||||
|
||||
[release-plz]: https://github.com/MarcoIeni/release-plz
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.189"
|
||||
dependencies = [
|
||||
"rustc-std-workspace-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-std-workspace-core"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa9c45b374136f52f2d6311062c7146bff20fec063c3f5d46a410bd937746955"
|
||||
Vendored
+225
@@ -0,0 +1,225 @@
|
||||
# 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 = "2021"
|
||||
rust-version = "1.65"
|
||||
name = "libc"
|
||||
version = "0.2.189"
|
||||
build = "build.rs"
|
||||
exclude = [
|
||||
"/ci/*",
|
||||
"/.github/*",
|
||||
"/triagebot.toml",
|
||||
"cherry-pick-stable.sh",
|
||||
]
|
||||
autolib = false
|
||||
autobins = false
|
||||
autoexamples = false
|
||||
autotests = false
|
||||
autobenches = false
|
||||
description = "Raw FFI bindings to platform libraries like libc."
|
||||
readme = "README.md"
|
||||
keywords = [
|
||||
"libc",
|
||||
"ffi",
|
||||
"bindings",
|
||||
"operating",
|
||||
"system",
|
||||
]
|
||||
categories = [
|
||||
"external-ffi-bindings",
|
||||
"no-std",
|
||||
"os",
|
||||
]
|
||||
license = "MIT OR Apache-2.0"
|
||||
repository = "https://github.com/rust-lang/libc"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
features = ["extra_traits"]
|
||||
default-target = "x86_64-unknown-linux-gnu"
|
||||
targets = [
|
||||
"aarch64-apple-darwin",
|
||||
"aarch64-pc-windows-msvc",
|
||||
"aarch64-unknown-linux-gnu",
|
||||
"i686-pc-windows-msvc",
|
||||
"i686-unknown-linux-gnu",
|
||||
"x86_64-pc-windows-gnu",
|
||||
"x86_64-pc-windows-msvc",
|
||||
"x86_64-unknown-linux-gnu",
|
||||
"aarch64-pc-windows-gnullvm",
|
||||
"aarch64-unknown-linux-musl",
|
||||
"aarch64-unknown-linux-ohos",
|
||||
"arm-unknown-linux-gnueabi",
|
||||
"arm-unknown-linux-gnueabihf",
|
||||
"armv7-unknown-linux-gnueabihf",
|
||||
"armv7-unknown-linux-ohos",
|
||||
"i686-pc-windows-gnu",
|
||||
"loongarch64-unknown-linux-gnu",
|
||||
"loongarch64-unknown-linux-musl",
|
||||
"powerpc-unknown-linux-gnu",
|
||||
"powerpc64-unknown-linux-gnu",
|
||||
"powerpc64-unknown-linux-musl",
|
||||
"powerpc64le-unknown-linux-gnu",
|
||||
"powerpc64le-unknown-linux-musl",
|
||||
"riscv64gc-unknown-linux-gnu",
|
||||
"s390x-unknown-linux-gnu",
|
||||
"sparcv9-sun-solaris",
|
||||
"x86_64-apple-darwin",
|
||||
"x86_64-pc-solaris",
|
||||
"x86_64-pc-windows-gnullvm",
|
||||
"x86_64-unknown-freebsd",
|
||||
"x86_64-unknown-illumos",
|
||||
"x86_64-unknown-linux-musl",
|
||||
"x86_64-unknown-linux-ohos",
|
||||
"x86_64-unknown-netbsd",
|
||||
"aarch64-apple-ios",
|
||||
"aarch64-apple-tvos",
|
||||
"aarch64-apple-visionos",
|
||||
"aarch64-apple-watchos",
|
||||
"aarch64-linux-android",
|
||||
"aarch64-unknown-fuchsia",
|
||||
"arm-linux-androideabi",
|
||||
"arm-unknown-linux-musleabi",
|
||||
"arm-unknown-linux-musleabihf",
|
||||
"arm64ec-pc-windows-msvc",
|
||||
"armv5te-unknown-linux-gnueabi",
|
||||
"armv5te-unknown-linux-musleabi",
|
||||
"armv7-linux-androideabi",
|
||||
"armv7-unknown-linux-musleabihf",
|
||||
"i586-unknown-linux-gnu",
|
||||
"i586-unknown-linux-musl",
|
||||
"i686-linux-android",
|
||||
"i686-unknown-freebsd",
|
||||
"i686-unknown-linux-musl",
|
||||
"nvptx64-nvidia-cuda",
|
||||
"riscv64gc-unknown-linux-musl",
|
||||
"sparc64-unknown-linux-gnu",
|
||||
"thumbv7neon-linux-androideabi",
|
||||
"thumbv7neon-unknown-linux-gnueabihf",
|
||||
"wasm32-unknown-emscripten",
|
||||
"wasm32-unknown-unknown",
|
||||
"wasm32-wasip1",
|
||||
"wasm32-wasip2",
|
||||
"x86_64-fortanix-unknown-sgx",
|
||||
"x86_64-linux-android",
|
||||
"x86_64-unknown-fuchsia",
|
||||
"x86_64-unknown-linux-gnux32",
|
||||
"x86_64-unknown-redox",
|
||||
"aarch64-unknown-freebsd",
|
||||
"aarch64-unknown-hermit",
|
||||
"aarch64-unknown-illumos",
|
||||
"aarch64-unknown-netbsd",
|
||||
"aarch64-unknown-qnx",
|
||||
"aarch64-unknown-openbsd",
|
||||
"aarch64-unknown-redox",
|
||||
"aarch64-wrs-vxworks",
|
||||
"aarch64_be-unknown-linux-gnu",
|
||||
"aarch64_be-unknown-linux-musl",
|
||||
"armebv7r-none-eabi",
|
||||
"armebv7r-none-eabihf",
|
||||
"armv7-linux-androideabi",
|
||||
"armv7-wrs-vxworks-eabihf",
|
||||
"armv7r-none-eabi",
|
||||
"armv7r-none-eabihf",
|
||||
"hexagon-unknown-linux-musl",
|
||||
"i686-unknown-haiku",
|
||||
"i686-unknown-netbsd",
|
||||
"i686-unknown-openbsd",
|
||||
"i686-wrs-vxworks",
|
||||
"mips-unknown-linux-gnu",
|
||||
"mips-unknown-linux-musl",
|
||||
"mips64-unknown-linux-gnuabi64",
|
||||
"mips64-unknown-linux-muslabi64",
|
||||
"mips64el-unknown-linux-gnuabi64",
|
||||
"mips64el-unknown-linux-muslabi64",
|
||||
"mipsel-sony-psp",
|
||||
"mipsel-unknown-linux-gnu",
|
||||
"mipsel-unknown-linux-musl",
|
||||
"powerpc-unknown-linux-gnuspe",
|
||||
"powerpc-unknown-netbsd",
|
||||
"powerpc-wrs-vxworks",
|
||||
"powerpc-wrs-vxworks-spe",
|
||||
"powerpc64-ibm-aix",
|
||||
"powerpc64-unknown-freebsd",
|
||||
"powerpc64-unknown-linux-gnu",
|
||||
"powerpc64-wrs-vxworks",
|
||||
"riscv32-wrs-vxworks",
|
||||
"riscv32gc-unknown-linux-musl",
|
||||
"riscv32i-unknown-none-elf",
|
||||
"riscv32imac-unknown-none-elf",
|
||||
"riscv32imc-unknown-none-elf",
|
||||
"riscv64-wrs-vxworks",
|
||||
"riscv64gc-unknown-freebsd",
|
||||
"riscv64gc-unknown-hermit",
|
||||
"riscv64gc-unknown-none-elf",
|
||||
"riscv64imac-unknown-none-elf",
|
||||
"s390x-unknown-linux-musl",
|
||||
"sparc-unknown-linux-gnu",
|
||||
"sparc64-unknown-netbsd",
|
||||
"thumbv6m-none-eabi",
|
||||
"thumbv7em-none-eabi",
|
||||
"thumbv7em-none-eabihf",
|
||||
"thumbv7m-none-eabi",
|
||||
"wasm32-wasip3",
|
||||
"x86_64-apple-ios",
|
||||
"x86_64-pc-cygwin",
|
||||
"x86_64-unknown-dragonfly",
|
||||
"x86_64-unknown-haiku",
|
||||
"x86_64-unknown-hermit",
|
||||
"x86_64-unknown-hurd-gnu",
|
||||
"x86_64-unknown-l4re-uclibc",
|
||||
"x86_64-unknown-openbsd",
|
||||
"x86_64-wrs-vxworks",
|
||||
]
|
||||
cargo-args = ["-Zbuild-std=core"]
|
||||
|
||||
[package.metadata.cargo-semver-checks.lints]
|
||||
repr_align_removed = "warn"
|
||||
global_value_marked_deprecated = "warn"
|
||||
|
||||
[features]
|
||||
align = []
|
||||
const-extern-fn = []
|
||||
default = ["std"]
|
||||
extra_traits = []
|
||||
rustc-dep-of-std = [
|
||||
"align",
|
||||
"rustc-std-workspace-core",
|
||||
]
|
||||
std = []
|
||||
use_std = ["std"]
|
||||
|
||||
[lib]
|
||||
name = "libc"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[[test]]
|
||||
name = "const_fn"
|
||||
path = "tests/const_fn.rs"
|
||||
|
||||
[dependencies.rustc-std-workspace-core]
|
||||
version = "1.0.1"
|
||||
optional = true
|
||||
|
||||
[lints.clippy]
|
||||
explicit_iter_loop = "warn"
|
||||
identity_op = "allow"
|
||||
manual_assert = "warn"
|
||||
map_unwrap_or = "warn"
|
||||
missing_safety_doc = "allow"
|
||||
non_minimal_cfg = "allow"
|
||||
ptr_as_ptr = "warn"
|
||||
unnecessary_cast = "allow"
|
||||
unnecessary_semicolon = "warn"
|
||||
|
||||
[lints.rust]
|
||||
unused_qualifications = "allow"
|
||||
+214
@@ -0,0 +1,214 @@
|
||||
[package]
|
||||
name = "libc"
|
||||
version = "0.2.189"
|
||||
keywords = ["libc", "ffi", "bindings", "operating", "system"]
|
||||
categories = ["external-ffi-bindings", "no-std", "os"]
|
||||
exclude = ["/ci/*", "/.github/*", "/triagebot.toml", "cherry-pick-stable.sh"]
|
||||
description = "Raw FFI bindings to platform libraries like libc."
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
repository = "https://github.com/rust-lang/libc"
|
||||
rust-version = "1.65"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
features = ["extra_traits"]
|
||||
default-target = "x86_64-unknown-linux-gnu"
|
||||
targets = [
|
||||
# Note: Keep this in sync with ci/verify-build.py
|
||||
#
|
||||
# Tier 1
|
||||
"aarch64-apple-darwin",
|
||||
"aarch64-pc-windows-msvc",
|
||||
"aarch64-unknown-linux-gnu",
|
||||
"i686-pc-windows-msvc",
|
||||
"i686-unknown-linux-gnu",
|
||||
"x86_64-pc-windows-gnu",
|
||||
"x86_64-pc-windows-msvc",
|
||||
"x86_64-unknown-linux-gnu",
|
||||
#
|
||||
# Tier 2 with host tools
|
||||
"aarch64-pc-windows-gnullvm",
|
||||
"aarch64-unknown-linux-musl",
|
||||
"aarch64-unknown-linux-ohos",
|
||||
"arm-unknown-linux-gnueabi",
|
||||
"arm-unknown-linux-gnueabihf",
|
||||
"armv7-unknown-linux-gnueabihf",
|
||||
"armv7-unknown-linux-ohos",
|
||||
"i686-pc-windows-gnu",
|
||||
"loongarch64-unknown-linux-gnu",
|
||||
"loongarch64-unknown-linux-musl",
|
||||
"powerpc-unknown-linux-gnu",
|
||||
"powerpc64-unknown-linux-gnu",
|
||||
"powerpc64-unknown-linux-musl",
|
||||
"powerpc64le-unknown-linux-gnu",
|
||||
"powerpc64le-unknown-linux-musl",
|
||||
"riscv64gc-unknown-linux-gnu",
|
||||
"s390x-unknown-linux-gnu",
|
||||
"sparcv9-sun-solaris",
|
||||
"x86_64-apple-darwin",
|
||||
"x86_64-pc-solaris",
|
||||
"x86_64-pc-windows-gnullvm",
|
||||
"x86_64-unknown-freebsd",
|
||||
"x86_64-unknown-illumos",
|
||||
"x86_64-unknown-linux-musl",
|
||||
"x86_64-unknown-linux-ohos",
|
||||
"x86_64-unknown-netbsd",
|
||||
#
|
||||
# Tier 2 without host tools
|
||||
"aarch64-apple-ios",
|
||||
"aarch64-apple-tvos",
|
||||
"aarch64-apple-visionos",
|
||||
"aarch64-apple-watchos",
|
||||
"aarch64-linux-android",
|
||||
"aarch64-unknown-fuchsia",
|
||||
"arm-linux-androideabi",
|
||||
"arm-unknown-linux-musleabi",
|
||||
"arm-unknown-linux-musleabihf",
|
||||
"arm64ec-pc-windows-msvc",
|
||||
"armv5te-unknown-linux-gnueabi",
|
||||
"armv5te-unknown-linux-musleabi",
|
||||
"armv7-linux-androideabi",
|
||||
"armv7-unknown-linux-musleabihf",
|
||||
"i586-unknown-linux-gnu",
|
||||
"i586-unknown-linux-musl",
|
||||
"i686-linux-android",
|
||||
"i686-unknown-freebsd",
|
||||
"i686-unknown-linux-musl",
|
||||
"nvptx64-nvidia-cuda",
|
||||
"riscv64gc-unknown-linux-musl",
|
||||
"sparc64-unknown-linux-gnu",
|
||||
"thumbv7neon-linux-androideabi",
|
||||
"thumbv7neon-unknown-linux-gnueabihf",
|
||||
"wasm32-unknown-emscripten",
|
||||
"wasm32-unknown-unknown",
|
||||
"wasm32-wasip1",
|
||||
"wasm32-wasip2",
|
||||
"x86_64-fortanix-unknown-sgx",
|
||||
"x86_64-linux-android",
|
||||
"x86_64-unknown-fuchsia",
|
||||
"x86_64-unknown-linux-gnux32",
|
||||
"x86_64-unknown-redox",
|
||||
#
|
||||
# Tier 3 targets that are distinct enough to be useful, or have historically
|
||||
# been documented.
|
||||
"aarch64-unknown-freebsd",
|
||||
"aarch64-unknown-hermit",
|
||||
"aarch64-unknown-illumos",
|
||||
"aarch64-unknown-netbsd",
|
||||
"aarch64-unknown-qnx",
|
||||
"aarch64-unknown-openbsd",
|
||||
"aarch64-unknown-redox",
|
||||
"aarch64-wrs-vxworks",
|
||||
"aarch64_be-unknown-linux-gnu",
|
||||
"aarch64_be-unknown-linux-musl",
|
||||
"armebv7r-none-eabi",
|
||||
"armebv7r-none-eabihf",
|
||||
"armv7-linux-androideabi",
|
||||
"armv7-wrs-vxworks-eabihf",
|
||||
"armv7r-none-eabi",
|
||||
"armv7r-none-eabihf",
|
||||
"hexagon-unknown-linux-musl",
|
||||
"i686-unknown-haiku",
|
||||
"i686-unknown-netbsd",
|
||||
"i686-unknown-openbsd",
|
||||
"i686-wrs-vxworks",
|
||||
"mips-unknown-linux-gnu",
|
||||
"mips-unknown-linux-musl",
|
||||
"mips64-unknown-linux-gnuabi64",
|
||||
"mips64-unknown-linux-muslabi64",
|
||||
"mips64el-unknown-linux-gnuabi64",
|
||||
"mips64el-unknown-linux-muslabi64",
|
||||
"mipsel-sony-psp",
|
||||
"mipsel-unknown-linux-gnu",
|
||||
"mipsel-unknown-linux-musl",
|
||||
"powerpc-unknown-linux-gnuspe",
|
||||
"powerpc-unknown-netbsd",
|
||||
"powerpc-wrs-vxworks",
|
||||
"powerpc-wrs-vxworks-spe",
|
||||
"powerpc64-ibm-aix",
|
||||
"powerpc64-unknown-freebsd",
|
||||
"powerpc64-unknown-linux-gnu",
|
||||
"powerpc64-wrs-vxworks",
|
||||
"riscv32-wrs-vxworks",
|
||||
"riscv32gc-unknown-linux-musl",
|
||||
"riscv32i-unknown-none-elf",
|
||||
"riscv32imac-unknown-none-elf",
|
||||
"riscv32imc-unknown-none-elf",
|
||||
"riscv64-wrs-vxworks",
|
||||
"riscv64gc-unknown-freebsd",
|
||||
"riscv64gc-unknown-hermit",
|
||||
"riscv64gc-unknown-none-elf",
|
||||
"riscv64imac-unknown-none-elf",
|
||||
"s390x-unknown-linux-musl",
|
||||
"sparc-unknown-linux-gnu",
|
||||
"sparc64-unknown-netbsd",
|
||||
"thumbv6m-none-eabi",
|
||||
"thumbv7em-none-eabi",
|
||||
"thumbv7em-none-eabihf",
|
||||
"thumbv7m-none-eabi",
|
||||
"wasm32-wasip3",
|
||||
"x86_64-apple-ios",
|
||||
"x86_64-pc-cygwin",
|
||||
"x86_64-unknown-dragonfly",
|
||||
"x86_64-unknown-haiku",
|
||||
"x86_64-unknown-hermit",
|
||||
"x86_64-unknown-hurd-gnu",
|
||||
"x86_64-unknown-l4re-uclibc",
|
||||
"x86_64-unknown-openbsd",
|
||||
"x86_64-wrs-vxworks"
|
||||
]
|
||||
cargo-args = ["-Zbuild-std=core"]
|
||||
|
||||
[dependencies]
|
||||
rustc-std-workspace-core = { version = "1.0.1", optional = true }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = []
|
||||
rustc-dep-of-std = ['align', 'rustc-std-workspace-core']
|
||||
extra_traits = []
|
||||
|
||||
# `const-extern-function` is deprecated and no longer does anything
|
||||
const-extern-fn = []
|
||||
|
||||
# `align` is deprecated and no longer does anything
|
||||
align = []
|
||||
|
||||
# use_std is deprecated, use `std` instead
|
||||
use_std = ['std']
|
||||
|
||||
[workspace]
|
||||
members = [
|
||||
"ctest",
|
||||
"libc-test",
|
||||
]
|
||||
|
||||
[workspace.lints.rust]
|
||||
# FIXME(cleanup): make ident usage consistent in each file
|
||||
unused_qualifications = "allow"
|
||||
|
||||
[workspace.lints.clippy]
|
||||
# Enable pedantic lints - use this manually once in a while, but don't enable by default
|
||||
# pedantic = { level = "warn", priority = -1 }
|
||||
|
||||
# We are okay with the current state of these lints
|
||||
explicit_iter_loop = "warn"
|
||||
identity_op = "allow" # some expressions like `0 | x` are clearer for bit ops
|
||||
manual_assert = "warn"
|
||||
map_unwrap_or = "warn"
|
||||
missing_safety_doc = "allow" # safety? in libc? seriously?
|
||||
non_minimal_cfg = "allow" # for some reason cfg_if! sometimes trigger this
|
||||
ptr_as_ptr = "warn"
|
||||
unnecessary_semicolon = "warn"
|
||||
|
||||
# FIXME(clippy): these should be fixed if possible
|
||||
unnecessary_cast = "allow" # some casts like `as usize` are only needed for some targets
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[package.metadata.cargo-semver-checks.lints]
|
||||
# Alignment is an internal detail that users must not rely upon
|
||||
repr_align_removed = "warn"
|
||||
# We deprecate things all the time
|
||||
global_value_marked_deprecated = "warn"
|
||||
Vendored
+176
@@ -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
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
Copyright (c) The Rust Project Developers
|
||||
|
||||
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.
|
||||
Vendored
+101
@@ -0,0 +1,101 @@
|
||||
# libc - Raw FFI bindings to platforms' system libraries
|
||||
|
||||
[![GHA Status]][GitHub Actions] [![Latest Version]][crates.io] [![Documentation]][docs.rs] ![License]
|
||||
|
||||
`libc` provides all of the definitions necessary to easily interoperate with C
|
||||
code (or "C-like" code) on each of the platforms that Rust supports. This
|
||||
includes type definitions (e.g. `c_int`), constants (e.g. `EINVAL`) as well as
|
||||
function headers (e.g. `malloc`).
|
||||
|
||||
This crate exports all underlying platform types, functions, and constants under
|
||||
the crate root, so all items are accessible as `libc::foo`. The types and values
|
||||
of all the exported APIs match the platform that libc is compiled for.
|
||||
|
||||
Windows API bindings are not included in this crate. If you are looking for
|
||||
WinAPI bindings, consider using crates like [windows-sys].
|
||||
|
||||
More detailed information about the design of this library can be found in its
|
||||
[associated RFC][rfc].
|
||||
|
||||
[rfc]: https://github.com/rust-lang/rfcs/blob/HEAD/text/1291-promote-libc.md
|
||||
[windows-sys]: https://docs.rs/windows-sys
|
||||
|
||||
## v1.0 Roadmap
|
||||
|
||||
Currently, `libc` has two active branches: `main` for the upcoming v1.0 release,
|
||||
and `libc-0.2` for the currently published version. By default all pull requests
|
||||
should target `main`; once reviewed, they can be cherry picked to the `libc-0.2`
|
||||
branch if needed.
|
||||
|
||||
We will stop making new v0.2 releases once v1.0 is released.
|
||||
|
||||
See the section in [CONTRIBUTING.md](CONTRIBUTING.md#v10-roadmap) for more
|
||||
details.
|
||||
|
||||
## Usage
|
||||
|
||||
Add the following to your `Cargo.toml`:
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
libc = "0.2"
|
||||
```
|
||||
|
||||
## Rust version support
|
||||
|
||||
The minimum supported Rust toolchain version is currently **Rust 1.65**.
|
||||
|
||||
Increases to the MSRV are allowed to change without a major (i.e. semver-
|
||||
breaking) release in order to avoid a ripple effect in the ecosystem. A policy
|
||||
for when this may change is a work in progress.
|
||||
|
||||
`libc` may continue to compile with Rust versions older than the current MSRV
|
||||
but this is not guaranteed.
|
||||
|
||||
## Platform support
|
||||
|
||||
You can see the platform(target)-specific docs on [docs.rs], select a platform
|
||||
you want to see.
|
||||
|
||||
See [`ci/verify-build.py`](https://github.com/rust-lang/libc/blob/HEAD/ci/verify-build.py) for
|
||||
the platforms on which `libc` is guaranteed to build for each Rust toolchain.
|
||||
The test matrices at [GitHub Actions] show the platforms in which `libc` tests
|
||||
are run.
|
||||
|
||||
<div class="platform_docs"></div>
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under either of
|
||||
|
||||
* [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0)
|
||||
([LICENSE-APACHE](https://github.com/rust-lang/libc/blob/HEAD/LICENSE-APACHE))
|
||||
|
||||
* [MIT License](https://opensource.org/licenses/MIT)
|
||||
([LICENSE-MIT](https://github.com/rust-lang/libc/blob/HEAD/LICENSE-MIT))
|
||||
|
||||
at your option.
|
||||
|
||||
## Contributing
|
||||
|
||||
We welcome all people who want to contribute. Please see the
|
||||
[contributing instructions] for more information.
|
||||
|
||||
[contributing instructions]: https://github.com/rust-lang/libc/blob/HEAD/CONTRIBUTING.md
|
||||
|
||||
Contributions in any form (issues, pull requests, etc.) to this project must
|
||||
adhere to Rust's [Code of Conduct].
|
||||
|
||||
[Code of Conduct]: https://www.rust-lang.org/policies/code-of-conduct
|
||||
|
||||
Unless you explicitly state otherwise, any contribution intentionally submitted
|
||||
for inclusion in `libc` by you, as defined in the Apache-2.0 license, shall be
|
||||
dual licensed as above, without any additional terms or conditions.
|
||||
|
||||
[GitHub Actions]: https://github.com/rust-lang/libc/actions
|
||||
[GHA Status]: https://github.com/rust-lang/libc/workflows/CI/badge.svg
|
||||
[crates.io]: https://crates.io/crates/libc
|
||||
[Latest Version]: https://img.shields.io/crates/v/libc.svg
|
||||
[Documentation]: https://docs.rs/libc/badge.svg
|
||||
[docs.rs]: https://docs.rs/libc
|
||||
[License]: https://img.shields.io/crates/l/libc.svg
|
||||
Vendored
+393
@@ -0,0 +1,393 @@
|
||||
use std::env::VarError;
|
||||
use std::process::{
|
||||
Command,
|
||||
Output,
|
||||
};
|
||||
use std::sync::atomic::AtomicBool;
|
||||
use std::sync::atomic::Ordering::Relaxed;
|
||||
use std::{
|
||||
env,
|
||||
str,
|
||||
};
|
||||
|
||||
// List of cfgs this build script is allowed to set. The list is needed to support check-cfg, as we
|
||||
// need to know all the possible cfgs that this script will set. If you need to set another cfg
|
||||
// make sure to add it to this list as well.
|
||||
const ALLOWED_CFGS: &[&str] = &[
|
||||
"emscripten_old_stat_abi",
|
||||
// Should be enabled by users if esp-idf (>=6.0) is build with picolibc instead of newlib.
|
||||
"espidf_picolibc",
|
||||
"espidf_time32",
|
||||
"freebsd10",
|
||||
"freebsd11",
|
||||
"freebsd12",
|
||||
"freebsd13",
|
||||
"freebsd14",
|
||||
"freebsd15",
|
||||
// Corresponds to `_FILE_OFFSET_BITS=64` in glibc
|
||||
"gnu_file_offset_bits64",
|
||||
// Corresponds to `_TIME_BITS=64` in glibc. Also used in x86 Windows with
|
||||
// GNU to expose a 64-bit `time_t`.
|
||||
"gnu_time_bits64",
|
||||
"libc_deny_warnings",
|
||||
// Corresponds to `__USE_TIME_BITS64` in UAPI
|
||||
"linux_time_bits64",
|
||||
"musl_v1_2_3",
|
||||
// musl v1.2.3+ && 32-bit: time_t is i64, struct layouts change
|
||||
"musl32_time64",
|
||||
// Corresponds to `_REDIR_TIME64` in musl: symbol redirects to __*_time64
|
||||
"musl_redir_time64",
|
||||
"vxworks_lt_25_09",
|
||||
"libc_pauthtest",
|
||||
];
|
||||
|
||||
// Extra values to allow for check-cfg.
|
||||
const CHECK_CFG_EXTRA: &[(&str, &[&str])] = &[
|
||||
(
|
||||
"target_os",
|
||||
&[
|
||||
"switch", "aix", "ohos", "hurd", "rtems", "visionos", "nuttx", "cygwin", "qurt", "qnx",
|
||||
],
|
||||
),
|
||||
(
|
||||
"target_env",
|
||||
&["illumos", "wasi", "aix", "ohos", "nto71_iosock"],
|
||||
),
|
||||
(
|
||||
"target_arch",
|
||||
&["loongarch64", "mips32r6", "mips64r6", "csky"],
|
||||
),
|
||||
];
|
||||
|
||||
/// Musl architectures that define `_REDIR_TIME64` (i.e. those that transitioned
|
||||
/// from 32-bit to 64-bit `time_t` and need `__*_time64` symbol redirects).
|
||||
const MUSL_REDIR_TIME64_ARCHES: &[&str] = &["arm", "mips", "powerpc", "x86"];
|
||||
|
||||
/// Read from env, print more debug output via `cargo:warning` if set.
|
||||
static VERBOSE_BUILD: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
/// Print info via warnings if `LIBC_BUILD_VERBOSE` is set.
|
||||
macro_rules! info {
|
||||
($($tt:tt)+) => {
|
||||
if VERBOSE_BUILD.load(Relaxed) {
|
||||
println!("cargo:warning=info: {}", format_args!($($tt)*));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// Avoid unnecessary re-building.
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
|
||||
println!("cargo:rerun-if-env-changed=LIBC_BUILD_VERBOSE");
|
||||
if env_flag("LIBC_BUILD_VERBOSE") {
|
||||
VERBOSE_BUILD.store(true, Relaxed);
|
||||
}
|
||||
|
||||
let (rustc_minor_ver, _is_nightly) = rustc_minor_nightly();
|
||||
let libc_ci = env_flag("LIBC_CI");
|
||||
let target_env = env::var("CARGO_CFG_TARGET_ENV").unwrap_or_default();
|
||||
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();
|
||||
let target_ptr_width = env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap_or_default();
|
||||
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_default();
|
||||
let target_abi = env::var("CARGO_CFG_TARGET_ABI").unwrap_or_default();
|
||||
|
||||
// FIXME(msrv): Once the MSRV is 1.78, use `cfg(target_abi = "pauthtest")`
|
||||
// directly instead of translating it to `libc_pauthtest`. `target_abi`
|
||||
// cannot be used directly in cfg expressions on the current MSRV.
|
||||
if target_abi == "pauthtest" {
|
||||
set_cfg("libc_pauthtest");
|
||||
}
|
||||
|
||||
// FIXME: this can be removed in 1-2 releases
|
||||
println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_FREEBSD_VERSION");
|
||||
if env::var("RUST_LIBC_UNSTABLE_FREEBSD_VERSION").is_ok() {
|
||||
println!(
|
||||
"cargo:warning=RUST_LIBC_UNSTABLE_FREEBSD_VERSION has been removed; set \
|
||||
the cfg libc_unstable_freebsd_version via RUSTFLAGS instead"
|
||||
);
|
||||
}
|
||||
|
||||
// The ABI of libc used by std is backward compatible with FreeBSD 12.
|
||||
// The ABI of libc from crates.io is backward compatible with FreeBSD 12.
|
||||
//
|
||||
// On CI, we detect the actual FreeBSD version and match its ABI exactly,
|
||||
// running tests to ensure that the ABI is correct.
|
||||
// Allow overriding the default version for testing
|
||||
let which_freebsd = if let Ok(version) = env::var("CARGO_CFG_LIBC_UNSTABLE_FREEBSD_VERSION") {
|
||||
let vers = version.parse().unwrap();
|
||||
println!("cargo:warning=setting FreeBSD version to {vers}");
|
||||
vers
|
||||
} else if libc_ci {
|
||||
which_freebsd().unwrap_or(12)
|
||||
} else {
|
||||
12
|
||||
};
|
||||
|
||||
match which_freebsd {
|
||||
x if x < 10 => panic!("FreeBSD older than 10 is not supported"),
|
||||
10 => set_cfg("freebsd10"),
|
||||
11 => set_cfg("freebsd11"),
|
||||
12 => set_cfg("freebsd12"),
|
||||
13 => set_cfg("freebsd13"),
|
||||
14 => set_cfg("freebsd14"),
|
||||
_ => set_cfg("freebsd15"),
|
||||
}
|
||||
|
||||
match emcc_version_code() {
|
||||
Some(v) if (v < 30142) => set_cfg("emscripten_old_stat_abi"),
|
||||
// Non-Emscripten or version >= 3.1.42.
|
||||
_ => (),
|
||||
}
|
||||
|
||||
match vxworks_version_code() {
|
||||
Some(v) if (v < (25, 9)) => set_cfg("vxworks_lt_25_09"),
|
||||
// VxWorks version >= 25.09
|
||||
_ => (),
|
||||
}
|
||||
|
||||
let mut musl_v1_2_3 = env_flag("CARGO_CFG_LIBC_UNSTABLE_MUSL_V1_2_3");
|
||||
|
||||
// OpenHarmony uses a fork of the musl libc
|
||||
let musl = target_env == "musl" || target_env == "ohos";
|
||||
|
||||
// loongarch64, hexagon, ohos and pauthtest only exist with recent musl
|
||||
if target_arch == "loongarch64"
|
||||
|| target_arch == "hexagon"
|
||||
|| target_env == "ohos"
|
||||
|| target_abi == "pauthtest"
|
||||
{
|
||||
musl_v1_2_3 = true;
|
||||
}
|
||||
|
||||
if musl && musl_v1_2_3 {
|
||||
set_cfg("musl_v1_2_3");
|
||||
if target_ptr_width == "32" {
|
||||
set_cfg("musl32_time64");
|
||||
set_cfg("linux_time_bits64");
|
||||
}
|
||||
if MUSL_REDIR_TIME64_ARCHES.contains(&target_arch.as_str()) {
|
||||
set_cfg("musl_redir_time64");
|
||||
}
|
||||
}
|
||||
|
||||
let uclibc_use_time64 = env_flag("CARGO_CFG_LIBC_UNSTABLE_UCLIBC_TIME64");
|
||||
if target_env == "uclibc" && uclibc_use_time64 {
|
||||
set_cfg("linux_time_bits64");
|
||||
}
|
||||
|
||||
if target_env == "gnu"
|
||||
&& matches!(target_os.as_str(), "linux" | "windows")
|
||||
&& target_ptr_width == "32"
|
||||
&& target_arch != "riscv32"
|
||||
&& target_arch != "x86_64"
|
||||
{
|
||||
let defaultbits = "32";
|
||||
|
||||
let mut tb_env = env::var("CARGO_CFG_LIBC_UNSTABLE_GNU_TIME_BITS");
|
||||
|
||||
// FIXME: remove these fallbacks in a few releases
|
||||
if let Ok(old_tb_env) = env::var("RUST_LIBC_UNSTABLE_GNU_TIME_BITS") {
|
||||
println!(
|
||||
"cargo:warning=RUST_LIBC_UNSTABLE_GNU_TIME_BITS will be removed; \
|
||||
set `--cfg=libc_unstable_gnu_time_bits=\"...\"` via RUSTFLAGS instead"
|
||||
);
|
||||
tb_env = tb_env.or(Ok(old_tb_env));
|
||||
}
|
||||
if env::var("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS").is_ok()
|
||||
|| env::var("CARGO_CFG_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS").is_ok()
|
||||
{
|
||||
println!(
|
||||
"cargo:warning=glibc file offset can no longer be set independently of \
|
||||
`gnu_time_bits`"
|
||||
);
|
||||
}
|
||||
|
||||
let timebits = match tb_env.as_deref() {
|
||||
Err(_) => defaultbits,
|
||||
Ok(tb) if tb == "64" => tb,
|
||||
Ok(tb) if tb == "32" => tb,
|
||||
Ok(_) => {
|
||||
panic!("Invalid value for libc_unstable_gnu_time_bits. Must be 32, 64, or unset.")
|
||||
}
|
||||
};
|
||||
|
||||
if timebits == "64" {
|
||||
set_cfg("linux_time_bits64");
|
||||
set_cfg("gnu_file_offset_bits64");
|
||||
set_cfg("gnu_time_bits64");
|
||||
}
|
||||
}
|
||||
|
||||
// On CI: deny all warnings
|
||||
if libc_ci {
|
||||
set_cfg("libc_deny_warnings");
|
||||
}
|
||||
|
||||
// Since Rust 1.80, configuration that isn't recognized by default needs to be provided to
|
||||
// avoid warnings.
|
||||
if rustc_minor_ver >= 80 {
|
||||
for cfg in ALLOWED_CFGS {
|
||||
println!("cargo:rustc-check-cfg=cfg({cfg})");
|
||||
}
|
||||
for &(name, values) in CHECK_CFG_EXTRA {
|
||||
let values = values.join("\",\"");
|
||||
println!("cargo:rustc-check-cfg=cfg({name},values(\"{values}\"))");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Run `rustc --version` and capture the output, adjusting arguments as needed if `clippy-driver`
|
||||
/// is used instead.
|
||||
fn rustc_version_cmd(is_clippy_driver: bool) -> Output {
|
||||
let rustc = env::var_os("RUSTC").expect("Failed to get rustc version: missing RUSTC env");
|
||||
|
||||
let mut cmd = match env::var_os("RUSTC_WRAPPER") {
|
||||
Some(ref wrapper) if wrapper.is_empty() => Command::new(rustc),
|
||||
Some(wrapper) => {
|
||||
let mut cmd = Command::new(wrapper);
|
||||
cmd.arg(rustc);
|
||||
if is_clippy_driver {
|
||||
cmd.arg("--rustc");
|
||||
}
|
||||
|
||||
cmd
|
||||
}
|
||||
None => Command::new(rustc),
|
||||
};
|
||||
|
||||
cmd.arg("--version");
|
||||
|
||||
let output = cmd.output().expect("Failed to get rustc version");
|
||||
|
||||
assert!(
|
||||
output.status.success(),
|
||||
"failed to run rustc: {}",
|
||||
String::from_utf8_lossy(output.stderr.as_slice())
|
||||
);
|
||||
|
||||
output
|
||||
}
|
||||
|
||||
/// Return the minor version of `rustc`, as well as a bool indicating whether or not the version
|
||||
/// is a nightly.
|
||||
fn rustc_minor_nightly() -> (u32, bool) {
|
||||
macro_rules! otry {
|
||||
($e:expr) => {
|
||||
match $e {
|
||||
Some(e) => e,
|
||||
None => panic!("Failed to get rustc version"),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
let mut output = rustc_version_cmd(false);
|
||||
|
||||
if otry!(str::from_utf8(&output.stdout).ok()).starts_with("clippy") {
|
||||
output = rustc_version_cmd(true);
|
||||
}
|
||||
|
||||
let version = otry!(str::from_utf8(&output.stdout).ok());
|
||||
|
||||
let mut pieces = version.split('.');
|
||||
|
||||
assert_eq!(
|
||||
pieces.next(),
|
||||
Some("rustc 1"),
|
||||
"Failed to get rustc version"
|
||||
);
|
||||
|
||||
let minor = pieces.next();
|
||||
|
||||
// If `rustc` was built from a tarball, its version string
|
||||
// will have neither a git hash nor a commit date
|
||||
// (e.g. "rustc 1.39.0"). Treat this case as non-nightly,
|
||||
// since a nightly build should either come from CI
|
||||
// or a git checkout
|
||||
let nightly_raw = otry!(pieces.next()).split('-').nth(1);
|
||||
let nightly = nightly_raw.map_or(false, |raw| {
|
||||
raw.starts_with("dev") || raw.starts_with("nightly")
|
||||
});
|
||||
let minor = otry!(otry!(minor).parse().ok());
|
||||
|
||||
info!("detected rust 1.{minor}, nightly={nightly}");
|
||||
|
||||
(minor, nightly)
|
||||
}
|
||||
|
||||
fn which_freebsd() -> Option<i32> {
|
||||
let output = Command::new("freebsd-version").output().ok()?;
|
||||
if !output.status.success() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let stdout = String::from_utf8(output.stdout).ok()?;
|
||||
|
||||
match &stdout {
|
||||
s if s.starts_with("10") => Some(10),
|
||||
s if s.starts_with("11") => Some(11),
|
||||
s if s.starts_with("12") => Some(12),
|
||||
s if s.starts_with("13") => Some(13),
|
||||
s if s.starts_with("14") => Some(14),
|
||||
s if s.starts_with("15") => Some(15),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn emcc_version_code() -> Option<u64> {
|
||||
let emcc = if cfg!(target_os = "windows") {
|
||||
"emcc.bat"
|
||||
} else {
|
||||
"emcc"
|
||||
};
|
||||
|
||||
let output = Command::new(emcc).arg("-dumpversion").output().ok()?;
|
||||
if !output.status.success() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let version = String::from_utf8(output.stdout).ok()?;
|
||||
|
||||
// Some Emscripten versions come with `-git` attached, so split the
|
||||
// version string also on the `-` char.
|
||||
let mut pieces = version.trim().split(['.', '-']);
|
||||
|
||||
let major = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0);
|
||||
let minor = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0);
|
||||
let patch = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0);
|
||||
|
||||
Some(major * 10000 + minor * 100 + patch)
|
||||
}
|
||||
|
||||
/// Retrieve the VxWorks release version from the environment variable set by the VxWorks build
|
||||
/// environment, in `(minor, patch)` form. Currently the only major version supported by Rust
|
||||
/// is 7.
|
||||
fn vxworks_version_code() -> Option<(u32, u32)> {
|
||||
let version = env::var("WIND_RELEASE_ID").ok()?;
|
||||
|
||||
let mut pieces = version.trim().split(['.']);
|
||||
|
||||
let major: u32 = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0);
|
||||
let minor: u32 = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0);
|
||||
|
||||
Some((major, minor))
|
||||
}
|
||||
|
||||
fn set_cfg(cfg: &str) {
|
||||
assert!(
|
||||
ALLOWED_CFGS.contains(&cfg),
|
||||
"trying to set cfg {cfg}, but it is not in ALLOWED_CFGS",
|
||||
);
|
||||
println!("cargo:rustc-cfg={cfg}");
|
||||
info!("setting config `{cfg}`");
|
||||
}
|
||||
|
||||
/// Return true if the env is set to a value other than `0`.
|
||||
fn env_flag(key: &str) -> bool {
|
||||
match env::var(key) {
|
||||
Ok(x) if x == "0" => false,
|
||||
Err(VarError::NotPresent) => false,
|
||||
Err(VarError::NotUnicode(_)) => panic!("non-unicode var for `{key}`"),
|
||||
Ok(_) => true,
|
||||
}
|
||||
}
|
||||
+1112
File diff suppressed because it is too large.
Load diff
Vendored
+69
@@ -0,0 +1,69 @@
|
||||
use crate::off_t;
|
||||
use crate::prelude::*;
|
||||
|
||||
pub type __u64 = c_ulonglong;
|
||||
pub type wchar_t = u32;
|
||||
pub type nlink_t = c_ulong;
|
||||
pub type blksize_t = c_long;
|
||||
|
||||
s! {
|
||||
pub struct stat {
|
||||
pub st_dev: crate::dev_t,
|
||||
pub st_ino: crate::ino_t,
|
||||
pub st_mode: crate::mode_t,
|
||||
pub st_nlink: crate::nlink_t,
|
||||
pub st_uid: crate::uid_t,
|
||||
pub st_gid: crate::gid_t,
|
||||
pub st_rdev: crate::dev_t,
|
||||
__pad0: Padding<c_ulong>,
|
||||
pub st_size: off_t,
|
||||
pub st_blksize: crate::blksize_t,
|
||||
__pad1: Padding<c_int>,
|
||||
pub st_blocks: crate::blkcnt_t,
|
||||
pub st_atime: crate::time_t,
|
||||
pub st_atime_nsec: c_long,
|
||||
pub st_mtime: crate::time_t,
|
||||
pub st_mtime_nsec: c_long,
|
||||
pub st_ctime: crate::time_t,
|
||||
pub st_ctime_nsec: c_long,
|
||||
__unused: Padding<[c_uint; 2]>,
|
||||
}
|
||||
|
||||
pub struct stat64 {
|
||||
pub st_dev: crate::dev_t,
|
||||
pub st_ino: crate::ino_t,
|
||||
pub st_mode: crate::mode_t,
|
||||
pub st_nlink: crate::nlink_t,
|
||||
pub st_uid: crate::uid_t,
|
||||
pub st_gid: crate::gid_t,
|
||||
pub st_rdev: crate::dev_t,
|
||||
__pad0: Padding<c_ulong>,
|
||||
pub st_size: off_t,
|
||||
pub st_blksize: crate::blksize_t,
|
||||
__pad1: Padding<c_int>,
|
||||
pub st_blocks: crate::blkcnt_t,
|
||||
pub st_atime: crate::time_t,
|
||||
pub st_atime_nsec: c_long,
|
||||
pub st_mtime: crate::time_t,
|
||||
pub st_mtime_nsec: c_long,
|
||||
pub st_ctime: crate::time_t,
|
||||
pub st_ctime_nsec: c_long,
|
||||
__unused: Padding<[c_uint; 2]>,
|
||||
}
|
||||
|
||||
pub struct ipc_perm {
|
||||
pub __ipc_perm_key: crate::key_t,
|
||||
pub uid: crate::uid_t,
|
||||
pub gid: crate::gid_t,
|
||||
pub cuid: crate::uid_t,
|
||||
pub cgid: crate::gid_t,
|
||||
pub mode: crate::mode_t,
|
||||
pub __seq: c_ushort,
|
||||
__unused1: Padding<c_ulong>,
|
||||
__unused2: Padding<c_ulong>,
|
||||
}
|
||||
}
|
||||
|
||||
// From https://cs.opensource.google/fuchsia/fuchsia/+/main:zircon/third_party/ulib/musl/include/bits/signal.h;l=20-21;drc=0827b18ab9540c46f8037f407d17ea15a79e9ba7
|
||||
pub const MINSIGSTKSZ: size_t = 6144;
|
||||
pub const SIGSTKSZ: size_t = 12288;
|
||||
Vendored
+4028
File diff suppressed because it is too large.
Load diff
Vendored
+46
@@ -0,0 +1,46 @@
|
||||
use crate::off_t;
|
||||
use crate::prelude::*;
|
||||
|
||||
// From psABI Calling Convention for RV64
|
||||
pub type __u64 = c_ulonglong;
|
||||
pub type wchar_t = i32;
|
||||
|
||||
pub type nlink_t = c_ulong;
|
||||
pub type blksize_t = c_long;
|
||||
|
||||
pub type stat64 = stat;
|
||||
s! {
|
||||
pub struct stat {
|
||||
pub st_dev: crate::dev_t,
|
||||
pub st_ino: crate::ino_t,
|
||||
pub st_nlink: crate::nlink_t,
|
||||
pub st_mode: crate::mode_t,
|
||||
pub st_uid: crate::uid_t,
|
||||
pub st_gid: crate::gid_t,
|
||||
__pad0: Padding<c_int>,
|
||||
pub st_rdev: crate::dev_t,
|
||||
pub st_size: off_t,
|
||||
pub st_blksize: crate::blksize_t,
|
||||
pub st_blocks: crate::blkcnt_t,
|
||||
pub st_atime: crate::time_t,
|
||||
pub st_atime_nsec: c_long,
|
||||
pub st_mtime: crate::time_t,
|
||||
pub st_mtime_nsec: c_long,
|
||||
pub st_ctime: crate::time_t,
|
||||
pub st_ctime_nsec: c_long,
|
||||
__unused: Padding<[c_long; 3]>,
|
||||
}
|
||||
|
||||
// Not actually used, IPC calls just return ENOSYS
|
||||
pub struct ipc_perm {
|
||||
pub __ipc_perm_key: crate::key_t,
|
||||
pub uid: crate::uid_t,
|
||||
pub gid: crate::gid_t,
|
||||
pub cuid: crate::uid_t,
|
||||
pub cgid: crate::gid_t,
|
||||
pub mode: crate::mode_t,
|
||||
pub __seq: c_ushort,
|
||||
__unused1: Padding<c_ulong>,
|
||||
__unused2: Padding<c_ulong>,
|
||||
}
|
||||
}
|
||||
Vendored
+110
@@ -0,0 +1,110 @@
|
||||
use crate::off_t;
|
||||
use crate::prelude::*;
|
||||
|
||||
pub type wchar_t = i32;
|
||||
pub type nlink_t = u64;
|
||||
pub type blksize_t = c_long;
|
||||
pub type __u64 = c_ulonglong;
|
||||
|
||||
s! {
|
||||
pub struct stat {
|
||||
pub st_dev: crate::dev_t,
|
||||
pub st_ino: crate::ino_t,
|
||||
pub st_nlink: crate::nlink_t,
|
||||
pub st_mode: crate::mode_t,
|
||||
pub st_uid: crate::uid_t,
|
||||
pub st_gid: crate::gid_t,
|
||||
__pad0: Padding<c_int>,
|
||||
pub st_rdev: crate::dev_t,
|
||||
pub st_size: off_t,
|
||||
pub st_blksize: crate::blksize_t,
|
||||
pub st_blocks: crate::blkcnt_t,
|
||||
pub st_atime: crate::time_t,
|
||||
pub st_atime_nsec: c_long,
|
||||
pub st_mtime: crate::time_t,
|
||||
pub st_mtime_nsec: c_long,
|
||||
pub st_ctime: crate::time_t,
|
||||
pub st_ctime_nsec: c_long,
|
||||
__unused: Padding<[c_long; 3]>,
|
||||
}
|
||||
|
||||
pub struct stat64 {
|
||||
pub st_dev: crate::dev_t,
|
||||
pub st_ino: crate::ino64_t,
|
||||
pub st_nlink: crate::nlink_t,
|
||||
pub st_mode: crate::mode_t,
|
||||
pub st_uid: crate::uid_t,
|
||||
pub st_gid: crate::gid_t,
|
||||
__pad0: Padding<c_int>,
|
||||
pub st_rdev: crate::dev_t,
|
||||
pub st_size: off_t,
|
||||
pub st_blksize: crate::blksize_t,
|
||||
pub st_blocks: crate::blkcnt64_t,
|
||||
pub st_atime: crate::time_t,
|
||||
pub st_atime_nsec: c_long,
|
||||
pub st_mtime: crate::time_t,
|
||||
pub st_mtime_nsec: c_long,
|
||||
pub st_ctime: crate::time_t,
|
||||
pub st_ctime_nsec: c_long,
|
||||
__reserved: Padding<[c_long; 3]>,
|
||||
}
|
||||
|
||||
pub struct mcontext_t {
|
||||
__private: [u64; 32],
|
||||
}
|
||||
|
||||
pub struct ipc_perm {
|
||||
pub __ipc_perm_key: crate::key_t,
|
||||
pub uid: crate::uid_t,
|
||||
pub gid: crate::gid_t,
|
||||
pub cuid: crate::uid_t,
|
||||
pub cgid: crate::gid_t,
|
||||
pub mode: crate::mode_t,
|
||||
pub __seq: c_int,
|
||||
__unused1: Padding<c_long>,
|
||||
__unused2: Padding<c_long>,
|
||||
}
|
||||
|
||||
pub struct ucontext_t {
|
||||
pub uc_flags: c_ulong,
|
||||
pub uc_link: *mut ucontext_t,
|
||||
pub uc_stack: crate::stack_t,
|
||||
pub uc_mcontext: mcontext_t,
|
||||
pub uc_sigmask: crate::sigset_t,
|
||||
__private: [u8; 512],
|
||||
}
|
||||
}
|
||||
|
||||
// offsets in user_regs_structs, from sys/reg.h
|
||||
pub const R15: c_int = 0;
|
||||
pub const R14: c_int = 1;
|
||||
pub const R13: c_int = 2;
|
||||
pub const R12: c_int = 3;
|
||||
pub const RBP: c_int = 4;
|
||||
pub const RBX: c_int = 5;
|
||||
pub const R11: c_int = 6;
|
||||
pub const R10: c_int = 7;
|
||||
pub const R9: c_int = 8;
|
||||
pub const R8: c_int = 9;
|
||||
pub const RAX: c_int = 10;
|
||||
pub const RCX: c_int = 11;
|
||||
pub const RDX: c_int = 12;
|
||||
pub const RSI: c_int = 13;
|
||||
pub const RDI: c_int = 14;
|
||||
pub const ORIG_RAX: c_int = 15;
|
||||
pub const RIP: c_int = 16;
|
||||
pub const CS: c_int = 17;
|
||||
pub const EFLAGS: c_int = 18;
|
||||
pub const RSP: c_int = 19;
|
||||
pub const SS: c_int = 20;
|
||||
pub const FS_BASE: c_int = 21;
|
||||
pub const GS_BASE: c_int = 22;
|
||||
pub const DS: c_int = 23;
|
||||
pub const ES: c_int = 24;
|
||||
pub const FS: c_int = 25;
|
||||
pub const GS: c_int = 26;
|
||||
|
||||
pub const MAP_32BIT: c_int = 0x0040;
|
||||
|
||||
pub const SIGSTKSZ: size_t = 8192;
|
||||
pub const MINSIGSTKSZ: size_t = 2048;
|
||||
Vendored
+562
@@ -0,0 +1,562 @@
|
||||
//! Hermit C type definitions
|
||||
|
||||
use crate::prelude::*;
|
||||
|
||||
pub type intmax_t = i64;
|
||||
pub type uintmax_t = u64;
|
||||
pub type intptr_t = isize;
|
||||
pub type uintptr_t = usize;
|
||||
|
||||
pub type size_t = usize;
|
||||
pub type ssize_t = isize;
|
||||
pub type ptrdiff_t = isize;
|
||||
|
||||
pub type clockid_t = i32;
|
||||
pub type in_addr_t = u32;
|
||||
pub type in_port_t = u16;
|
||||
pub type mode_t = u32;
|
||||
pub type nfds_t = usize;
|
||||
pub type pid_t = i32;
|
||||
pub type sa_family_t = u8;
|
||||
pub type socklen_t = u32;
|
||||
pub type time_t = i64;
|
||||
|
||||
s! {
|
||||
pub struct addrinfo {
|
||||
pub ai_flags: i32,
|
||||
pub ai_family: i32,
|
||||
pub ai_socktype: i32,
|
||||
pub ai_protocol: i32,
|
||||
pub ai_addrlen: socklen_t,
|
||||
pub ai_canonname: *mut c_char,
|
||||
pub ai_addr: *mut sockaddr,
|
||||
pub ai_next: *mut addrinfo,
|
||||
}
|
||||
|
||||
pub struct dirent64 {
|
||||
pub d_ino: u64,
|
||||
pub d_off: i64,
|
||||
pub d_reclen: u16,
|
||||
pub d_type: u8,
|
||||
pub d_name: [c_char; 256],
|
||||
}
|
||||
|
||||
#[repr(align(4))]
|
||||
pub struct in6_addr {
|
||||
pub s6_addr: [u8; 16],
|
||||
}
|
||||
|
||||
pub struct in_addr {
|
||||
pub s_addr: in_addr_t,
|
||||
}
|
||||
|
||||
pub struct iovec {
|
||||
iov_base: *mut c_void,
|
||||
iov_len: usize,
|
||||
}
|
||||
|
||||
pub struct pollfd {
|
||||
pub fd: i32,
|
||||
pub events: i16,
|
||||
pub revents: i16,
|
||||
}
|
||||
|
||||
pub struct sockaddr {
|
||||
pub sa_len: u8,
|
||||
pub sa_family: sa_family_t,
|
||||
pub sa_data: [c_char; 14],
|
||||
}
|
||||
|
||||
pub struct sockaddr_in {
|
||||
pub sin_len: u8,
|
||||
pub sin_family: sa_family_t,
|
||||
pub sin_port: in_port_t,
|
||||
pub sin_addr: in_addr,
|
||||
pub sin_zero: [c_char; 8],
|
||||
}
|
||||
|
||||
pub struct sockaddr_in6 {
|
||||
pub sin6_len: u8,
|
||||
pub sin6_family: sa_family_t,
|
||||
pub sin6_port: in_port_t,
|
||||
pub sin6_flowinfo: u32,
|
||||
pub sin6_addr: in6_addr,
|
||||
pub sin6_scope_id: u32,
|
||||
}
|
||||
|
||||
pub struct sockaddr_storage {
|
||||
pub ss_len: u8,
|
||||
pub ss_family: sa_family_t,
|
||||
__ss_pad1: Padding<[u8; 6]>,
|
||||
__ss_align: i64,
|
||||
__ss_pad2: Padding<[u8; 112]>,
|
||||
}
|
||||
|
||||
pub struct stat {
|
||||
pub st_dev: u64,
|
||||
pub st_ino: u64,
|
||||
pub st_nlink: u64,
|
||||
pub st_mode: mode_t,
|
||||
pub st_uid: u32,
|
||||
pub st_gid: u32,
|
||||
pub st_rdev: u64,
|
||||
pub st_size: i64,
|
||||
pub st_blksize: i64,
|
||||
pub st_blocks: i64,
|
||||
pub st_atim: timespec,
|
||||
pub st_mtim: timespec,
|
||||
pub st_ctim: timespec,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct timespec {
|
||||
pub tv_sec: time_t,
|
||||
pub tv_nsec: i32,
|
||||
}
|
||||
}
|
||||
|
||||
pub const AF_UNSPEC: i32 = 0;
|
||||
pub const AF_INET: i32 = 3;
|
||||
pub const AF_INET6: i32 = 1;
|
||||
pub const AF_VSOCK: i32 = 2;
|
||||
|
||||
pub const CLOCK_REALTIME: clockid_t = 1;
|
||||
pub const CLOCK_MONOTONIC: clockid_t = 4;
|
||||
|
||||
pub const DT_UNKNOWN: u8 = 0;
|
||||
pub const DT_FIFO: u8 = 1;
|
||||
pub const DT_CHR: u8 = 2;
|
||||
pub const DT_DIR: u8 = 4;
|
||||
pub const DT_BLK: u8 = 6;
|
||||
pub const DT_REG: u8 = 8;
|
||||
pub const DT_LNK: u8 = 10;
|
||||
pub const DT_SOCK: u8 = 12;
|
||||
pub const DT_WHT: u8 = 14;
|
||||
|
||||
pub const EAI_AGAIN: i32 = 2;
|
||||
pub const EAI_BADFLAGS: i32 = 3;
|
||||
pub const EAI_FAIL: i32 = 4;
|
||||
pub const EAI_FAMILY: i32 = 5;
|
||||
pub const EAI_MEMORY: i32 = 6;
|
||||
pub const EAI_NODATA: i32 = 7;
|
||||
pub const EAI_NONAME: i32 = 8;
|
||||
pub const EAI_SERVICE: i32 = 9;
|
||||
pub const EAI_SOCKTYPE: i32 = 10;
|
||||
pub const EAI_SYSTEM: i32 = 11;
|
||||
pub const EAI_OVERFLOW: i32 = 14;
|
||||
|
||||
pub const EFD_SEMAPHORE: i16 = 0o1;
|
||||
pub const EFD_NONBLOCK: i16 = 0o4000;
|
||||
pub const EFD_CLOEXEC: i16 = 0o40000;
|
||||
|
||||
pub const F_DUPFD: i32 = 0;
|
||||
pub const F_GETFD: i32 = 1;
|
||||
pub const F_SETFD: i32 = 2;
|
||||
pub const F_GETFL: i32 = 3;
|
||||
pub const F_SETFL: i32 = 4;
|
||||
|
||||
pub const FD_CLOEXEC: i32 = 1;
|
||||
|
||||
pub const FIONBIO: i32 = u32_cast_int(0x8008667e);
|
||||
|
||||
pub const FUTEX_RELATIVE_TIMEOUT: u32 = 1;
|
||||
|
||||
pub const IP_TOS: i32 = 1;
|
||||
pub const IP_TTL: i32 = 2;
|
||||
pub const IP_ADD_MEMBERSHIP: i32 = 3;
|
||||
pub const IP_DROP_MEMBERSHIP: i32 = 4;
|
||||
pub const IP_MULTICAST_TTL: i32 = 5;
|
||||
pub const IP_MULTICAST_LOOP: i32 = 7;
|
||||
|
||||
pub const IPPROTO_IP: i32 = 0;
|
||||
pub const IPPROTO_TCP: i32 = 6;
|
||||
pub const IPPROTO_UDP: i32 = 17;
|
||||
pub const IPPROTO_IPV6: i32 = 41;
|
||||
|
||||
pub const IPV6_ADD_MEMBERSHIP: i32 = 12;
|
||||
pub const IPV6_DROP_MEMBERSHIP: i32 = 13;
|
||||
pub const IPV6_MULTICAST_LOOP: i32 = 19;
|
||||
pub const IPV6_V6ONLY: i32 = 27;
|
||||
|
||||
pub const MSG_PEEK: i32 = 1;
|
||||
|
||||
pub const O_RDONLY: i32 = 0o0;
|
||||
pub const O_WRONLY: i32 = 0o1;
|
||||
pub const O_RDWR: i32 = 0o2;
|
||||
pub const O_CREAT: i32 = 0o100;
|
||||
pub const O_EXCL: i32 = 0o200;
|
||||
pub const O_TRUNC: i32 = 0o1000;
|
||||
pub const O_APPEND: i32 = 0o2000;
|
||||
pub const O_NONBLOCK: i32 = 0o4000;
|
||||
pub const O_DIRECTORY: i32 = 0o200000;
|
||||
|
||||
pub const POLLIN: i16 = 0x1;
|
||||
pub const POLLPRI: i16 = 0x2;
|
||||
pub const POLLOUT: i16 = 0x4;
|
||||
pub const POLLERR: i16 = 0x8;
|
||||
pub const POLLHUP: i16 = 0x10;
|
||||
pub const POLLNVAL: i16 = 0x20;
|
||||
pub const POLLRDNORM: i16 = 0x040;
|
||||
pub const POLLRDBAND: i16 = 0x080;
|
||||
pub const POLLWRNORM: i16 = 0x0100;
|
||||
pub const POLLWRBAND: i16 = 0x0200;
|
||||
pub const POLLRDHUP: i16 = 0x2000;
|
||||
|
||||
pub const S_IRWXU: mode_t = 0o0700;
|
||||
pub const S_IRUSR: mode_t = 0o0400;
|
||||
pub const S_IWUSR: mode_t = 0o0200;
|
||||
pub const S_IXUSR: mode_t = 0o0100;
|
||||
pub const S_IRWXG: mode_t = 0o0070;
|
||||
pub const S_IRGRP: mode_t = 0o0040;
|
||||
pub const S_IWGRP: mode_t = 0o0020;
|
||||
pub const S_IXGRP: mode_t = 0o0010;
|
||||
pub const S_IRWXO: mode_t = 0o0007;
|
||||
pub const S_IROTH: mode_t = 0o0004;
|
||||
pub const S_IWOTH: mode_t = 0o0002;
|
||||
pub const S_IXOTH: mode_t = 0o0001;
|
||||
|
||||
pub const S_IFMT: mode_t = 0o17_0000;
|
||||
pub const S_IFSOCK: mode_t = 0o14_0000;
|
||||
pub const S_IFLNK: mode_t = 0o12_0000;
|
||||
pub const S_IFREG: mode_t = 0o10_0000;
|
||||
pub const S_IFBLK: mode_t = 0o6_0000;
|
||||
pub const S_IFDIR: mode_t = 0o4_0000;
|
||||
pub const S_IFCHR: mode_t = 0o2_0000;
|
||||
pub const S_IFIFO: mode_t = 0o1_0000;
|
||||
|
||||
pub const SHUT_RD: i32 = 0;
|
||||
pub const SHUT_WR: i32 = 1;
|
||||
pub const SHUT_RDWR: i32 = 2;
|
||||
|
||||
pub const SO_REUSEADDR: i32 = 0x0004;
|
||||
pub const SO_KEEPALIVE: i32 = 0x0008;
|
||||
pub const SO_BROADCAST: i32 = 0x0020;
|
||||
pub const SO_LINGER: i32 = 0x0080;
|
||||
pub const SO_SNDBUF: i32 = 0x1001;
|
||||
pub const SO_RCVBUF: i32 = 0x1002;
|
||||
pub const SO_SNDTIMEO: i32 = 0x1005;
|
||||
pub const SO_RCVTIMEO: i32 = 0x1006;
|
||||
pub const SO_ERROR: i32 = 0x1007;
|
||||
|
||||
pub const SOCK_STREAM: i32 = 1;
|
||||
pub const SOCK_DGRAM: i32 = 2;
|
||||
pub const SOCK_NONBLOCK: i32 = 0o4000;
|
||||
pub const SOCK_CLOEXEC: i32 = 0o40000;
|
||||
|
||||
pub const SOL_SOCKET: i32 = 4095;
|
||||
|
||||
pub const STDIN_FILENO: c_int = 0;
|
||||
pub const STDOUT_FILENO: c_int = 1;
|
||||
pub const STDERR_FILENO: c_int = 2;
|
||||
|
||||
pub const TCP_NODELAY: i32 = 1;
|
||||
|
||||
pub const EPERM: i32 = 1;
|
||||
pub const ENOENT: i32 = 2;
|
||||
pub const ESRCH: i32 = 3;
|
||||
pub const EINTR: i32 = 4;
|
||||
pub const EIO: i32 = 5;
|
||||
pub const ENXIO: i32 = 6;
|
||||
pub const E2BIG: i32 = 7;
|
||||
pub const ENOEXEC: i32 = 8;
|
||||
pub const EBADF: i32 = 9;
|
||||
pub const ECHILD: i32 = 10;
|
||||
pub const EAGAIN: i32 = 11;
|
||||
pub const ENOMEM: i32 = 12;
|
||||
pub const EACCES: i32 = 13;
|
||||
pub const EFAULT: i32 = 14;
|
||||
pub const ENOTBLK: i32 = 15;
|
||||
pub const EBUSY: i32 = 16;
|
||||
pub const EEXIST: i32 = 17;
|
||||
pub const EXDEV: i32 = 18;
|
||||
pub const ENODEV: i32 = 19;
|
||||
pub const ENOTDIR: i32 = 20;
|
||||
pub const EISDIR: i32 = 21;
|
||||
pub const EINVAL: i32 = 22;
|
||||
pub const ENFILE: i32 = 23;
|
||||
pub const EMFILE: i32 = 24;
|
||||
pub const ENOTTY: i32 = 25;
|
||||
pub const ETXTBSY: i32 = 26;
|
||||
pub const EFBIG: i32 = 27;
|
||||
pub const ENOSPC: i32 = 28;
|
||||
pub const ESPIPE: i32 = 29;
|
||||
pub const EROFS: i32 = 30;
|
||||
pub const EMLINK: i32 = 31;
|
||||
pub const EPIPE: i32 = 32;
|
||||
pub const EDOM: i32 = 33;
|
||||
pub const ERANGE: i32 = 34;
|
||||
pub const EDEADLK: i32 = 35;
|
||||
pub const ENAMETOOLONG: i32 = 36;
|
||||
pub const ENOLCK: i32 = 37;
|
||||
pub const ENOSYS: i32 = 38;
|
||||
pub const ENOTEMPTY: i32 = 39;
|
||||
pub const ELOOP: i32 = 40;
|
||||
pub const EWOULDBLOCK: i32 = EAGAIN;
|
||||
pub const ENOMSG: i32 = 42;
|
||||
pub const EIDRM: i32 = 43;
|
||||
pub const ECHRNG: i32 = 44;
|
||||
pub const EL2NSYNC: i32 = 45;
|
||||
pub const EL3HLT: i32 = 46;
|
||||
pub const EL3RST: i32 = 47;
|
||||
pub const ELNRNG: i32 = 48;
|
||||
pub const EUNATCH: i32 = 49;
|
||||
pub const ENOCSI: i32 = 50;
|
||||
pub const EL2HLT: i32 = 51;
|
||||
pub const EBADE: i32 = 52;
|
||||
pub const EBADR: i32 = 53;
|
||||
pub const EXFULL: i32 = 54;
|
||||
pub const ENOANO: i32 = 55;
|
||||
pub const EBADRQC: i32 = 56;
|
||||
pub const EBADSLT: i32 = 57;
|
||||
pub const EDEADLOCK: i32 = EDEADLK;
|
||||
pub const EBFONT: i32 = 59;
|
||||
pub const ENOSTR: i32 = 60;
|
||||
pub const ENODATA: i32 = 61;
|
||||
pub const ETIME: i32 = 62;
|
||||
pub const ENOSR: i32 = 63;
|
||||
pub const ENONET: i32 = 64;
|
||||
pub const ENOPKG: i32 = 65;
|
||||
pub const EREMOTE: i32 = 66;
|
||||
pub const ENOLINK: i32 = 67;
|
||||
pub const EADV: i32 = 68;
|
||||
pub const ESRMNT: i32 = 69;
|
||||
pub const ECOMM: i32 = 70;
|
||||
pub const EPROTO: i32 = 71;
|
||||
pub const EMULTIHOP: i32 = 72;
|
||||
pub const EDOTDOT: i32 = 73;
|
||||
pub const EBADMSG: i32 = 74;
|
||||
pub const EOVERFLOW: i32 = 75;
|
||||
pub const ENOTUNIQ: i32 = 76;
|
||||
pub const EBADFD: i32 = 77;
|
||||
pub const EREMCHG: i32 = 78;
|
||||
pub const ELIBACC: i32 = 79;
|
||||
pub const ELIBBAD: i32 = 80;
|
||||
pub const ELIBSCN: i32 = 81;
|
||||
pub const ELIBMAX: i32 = 82;
|
||||
pub const ELIBEXEC: i32 = 83;
|
||||
pub const EILSEQ: i32 = 84;
|
||||
pub const ERESTART: i32 = 85;
|
||||
pub const ESTRPIPE: i32 = 86;
|
||||
pub const EUSERS: i32 = 87;
|
||||
pub const ENOTSOCK: i32 = 88;
|
||||
pub const EDESTADDRREQ: i32 = 89;
|
||||
pub const EMSGSIZE: i32 = 90;
|
||||
pub const EPROTOTYPE: i32 = 91;
|
||||
pub const ENOPROTOOPT: i32 = 92;
|
||||
pub const EPROTONOSUPPORT: i32 = 93;
|
||||
pub const ESOCKTNOSUPPORT: i32 = 94;
|
||||
pub const EOPNOTSUPP: i32 = 95;
|
||||
pub const EPFNOSUPPORT: i32 = 96;
|
||||
pub const EAFNOSUPPORT: i32 = 97;
|
||||
pub const EADDRINUSE: i32 = 98;
|
||||
pub const EADDRNOTAVAIL: i32 = 99;
|
||||
pub const ENETDOWN: i32 = 100;
|
||||
pub const ENETUNREACH: i32 = 101;
|
||||
pub const ENETRESET: i32 = 102;
|
||||
pub const ECONNABORTED: i32 = 103;
|
||||
pub const ECONNRESET: i32 = 104;
|
||||
pub const ENOBUFS: i32 = 105;
|
||||
pub const EISCONN: i32 = 106;
|
||||
pub const ENOTCONN: i32 = 107;
|
||||
pub const ESHUTDOWN: i32 = 108;
|
||||
pub const ETOOMANYREFS: i32 = 109;
|
||||
pub const ETIMEDOUT: i32 = 110;
|
||||
pub const ECONNREFUSED: i32 = 111;
|
||||
pub const EHOSTDOWN: i32 = 112;
|
||||
pub const EHOSTUNREACH: i32 = 113;
|
||||
pub const EALREADY: i32 = 114;
|
||||
pub const EINPROGRESS: i32 = 115;
|
||||
pub const ESTALE: i32 = 116;
|
||||
pub const EUCLEAN: i32 = 117;
|
||||
pub const ENOTNAM: i32 = 118;
|
||||
pub const ENAVAIL: i32 = 119;
|
||||
pub const EISNAM: i32 = 120;
|
||||
pub const EREMOTEIO: i32 = 121;
|
||||
pub const EDQUOT: i32 = 122;
|
||||
pub const ENOMEDIUM: i32 = 123;
|
||||
pub const EMEDIUMTYPE: i32 = 124;
|
||||
pub const ECANCELED: i32 = 125;
|
||||
pub const ENOKEY: i32 = 126;
|
||||
pub const EKEYEXPIRED: i32 = 127;
|
||||
pub const EKEYREVOKED: i32 = 128;
|
||||
pub const EKEYREJECTED: i32 = 129;
|
||||
pub const EOWNERDEAD: i32 = 130;
|
||||
pub const ENOTRECOVERABLE: i32 = 131;
|
||||
pub const ERFKILL: i32 = 132;
|
||||
pub const EHWPOISON: i32 = 133;
|
||||
|
||||
extern "C" {
|
||||
#[link_name = "sys_alloc"]
|
||||
pub fn alloc(size: usize, align: usize) -> *mut u8;
|
||||
|
||||
#[link_name = "sys_alloc_zeroed"]
|
||||
pub fn alloc_zeroed(size: usize, align: usize) -> *mut u8;
|
||||
|
||||
#[link_name = "sys_realloc"]
|
||||
pub fn realloc(ptr: *mut u8, size: usize, align: usize, new_size: usize) -> *mut u8;
|
||||
|
||||
#[link_name = "sys_dealloc"]
|
||||
pub fn dealloc(ptr: *mut u8, size: usize, align: usize);
|
||||
|
||||
#[link_name = "sys_exit"]
|
||||
pub fn exit(status: i32) -> !;
|
||||
|
||||
#[link_name = "sys_abort"]
|
||||
pub fn abort() -> !;
|
||||
|
||||
#[link_name = "sys_errno"]
|
||||
pub fn errno() -> i32;
|
||||
|
||||
#[link_name = "sys_clock_gettime"]
|
||||
pub fn clock_gettime(clockid: clockid_t, tp: *mut timespec) -> i32;
|
||||
|
||||
#[link_name = "sys_nanosleep"]
|
||||
pub fn nanosleep(req: *const timespec) -> i32;
|
||||
|
||||
#[link_name = "sys_available_parallelism"]
|
||||
pub fn available_parallelism() -> usize;
|
||||
|
||||
#[link_name = "sys_futex_wait"]
|
||||
pub fn futex_wait(
|
||||
address: *mut u32,
|
||||
expected: u32,
|
||||
timeout: *const timespec,
|
||||
flags: u32,
|
||||
) -> i32;
|
||||
|
||||
#[link_name = "sys_futex_wake"]
|
||||
pub fn futex_wake(address: *mut u32, count: i32) -> i32;
|
||||
|
||||
#[link_name = "sys_stat"]
|
||||
pub fn stat(path: *const c_char, stat: *mut stat) -> i32;
|
||||
|
||||
#[link_name = "sys_fstat"]
|
||||
pub fn fstat(fd: i32, stat: *mut stat) -> i32;
|
||||
|
||||
#[link_name = "sys_lstat"]
|
||||
pub fn lstat(path: *const c_char, stat: *mut stat) -> i32;
|
||||
|
||||
#[link_name = "sys_open"]
|
||||
pub fn open(path: *const c_char, flags: i32, mode: mode_t) -> i32;
|
||||
|
||||
#[link_name = "sys_unlink"]
|
||||
pub fn unlink(path: *const c_char) -> i32;
|
||||
|
||||
#[link_name = "sys_mkdir"]
|
||||
pub fn mkdir(path: *const c_char, mode: mode_t) -> i32;
|
||||
|
||||
#[link_name = "sys_rmdir"]
|
||||
pub fn rmdir(path: *const c_char) -> i32;
|
||||
|
||||
#[link_name = "sys_read"]
|
||||
pub fn read(fd: i32, buf: *mut u8, len: usize) -> isize;
|
||||
|
||||
#[link_name = "sys_write"]
|
||||
pub fn write(fd: i32, buf: *const u8, len: usize) -> isize;
|
||||
|
||||
#[link_name = "sys_readv"]
|
||||
pub fn readv(fd: i32, iov: *const iovec, iovcnt: usize) -> isize;
|
||||
|
||||
#[link_name = "sys_writev"]
|
||||
pub fn writev(fd: i32, iov: *const iovec, iovcnt: usize) -> isize;
|
||||
|
||||
#[link_name = "sys_close"]
|
||||
pub fn close(fd: i32) -> i32;
|
||||
|
||||
#[link_name = "sys_dup"]
|
||||
pub fn dup(fd: i32) -> i32;
|
||||
|
||||
#[link_name = "sys_fcntl"]
|
||||
pub fn fcntl(fd: i32, cmd: i32, arg: i32) -> i32;
|
||||
|
||||
#[link_name = "sys_getdents64"]
|
||||
pub fn getdents64(fd: i32, dirp: *mut dirent64, count: usize) -> isize;
|
||||
|
||||
#[link_name = "sys_getaddrinfo"]
|
||||
pub fn getaddrinfo(
|
||||
nodename: *const c_char,
|
||||
servname: *const c_char,
|
||||
hints: *const addrinfo,
|
||||
res: *mut *mut addrinfo,
|
||||
) -> i32;
|
||||
|
||||
#[link_name = "sys_freeaddrinfo"]
|
||||
pub fn freeaddrinfo(ai: *mut addrinfo);
|
||||
|
||||
#[link_name = "sys_socket"]
|
||||
pub fn socket(domain: i32, ty: i32, protocol: i32) -> i32;
|
||||
|
||||
#[link_name = "sys_bind"]
|
||||
pub fn bind(sockfd: i32, addr: *const sockaddr, addrlen: socklen_t) -> i32;
|
||||
|
||||
#[link_name = "sys_listen"]
|
||||
pub fn listen(sockfd: i32, backlog: i32) -> i32;
|
||||
|
||||
#[link_name = "sys_accept"]
|
||||
pub fn accept(sockfd: i32, addr: *mut sockaddr, addrlen: *mut socklen_t) -> i32;
|
||||
|
||||
#[link_name = "sys_connect"]
|
||||
pub fn connect(sockfd: i32, addr: *const sockaddr, addrlen: socklen_t) -> i32;
|
||||
|
||||
#[link_name = "sys_recv"]
|
||||
pub fn recv(sockfd: i32, buf: *mut u8, len: usize, flags: i32) -> isize;
|
||||
|
||||
#[link_name = "sys_recvfrom"]
|
||||
pub fn recvfrom(
|
||||
sockfd: i32,
|
||||
buf: *mut c_void,
|
||||
len: usize,
|
||||
flags: i32,
|
||||
addr: *mut sockaddr,
|
||||
addrlen: *mut socklen_t,
|
||||
) -> isize;
|
||||
|
||||
#[link_name = "sys_send"]
|
||||
pub fn send(sockfd: i32, buf: *const c_void, len: usize, flags: i32) -> isize;
|
||||
|
||||
#[link_name = "sys_sendto"]
|
||||
pub fn sendto(
|
||||
sockfd: i32,
|
||||
buf: *const c_void,
|
||||
len: usize,
|
||||
flags: i32,
|
||||
to: *const sockaddr,
|
||||
tolen: socklen_t,
|
||||
) -> isize;
|
||||
|
||||
#[link_name = "sys_getpeername"]
|
||||
pub fn getpeername(sockfd: i32, addr: *mut sockaddr, addrlen: *mut socklen_t) -> i32;
|
||||
|
||||
#[link_name = "sys_getsockname"]
|
||||
pub fn getsockname(sockfd: i32, addr: *mut sockaddr, addrlen: *mut socklen_t) -> i32;
|
||||
|
||||
#[link_name = "sys_getsockopt"]
|
||||
pub fn getsockopt(
|
||||
sockfd: i32,
|
||||
level: i32,
|
||||
optname: i32,
|
||||
optval: *mut c_void,
|
||||
optlen: *mut socklen_t,
|
||||
) -> i32;
|
||||
|
||||
#[link_name = "sys_setsockopt"]
|
||||
pub fn setsockopt(
|
||||
sockfd: i32,
|
||||
level: i32,
|
||||
optname: i32,
|
||||
optval: *const c_void,
|
||||
optlen: socklen_t,
|
||||
) -> i32;
|
||||
|
||||
#[link_name = "sys_ioctl"]
|
||||
pub fn ioctl(sockfd: i32, cmd: i32, argp: *mut c_void) -> i32;
|
||||
|
||||
#[link_name = "sys_shutdown"]
|
||||
pub fn shutdown(sockfd: i32, how: i32) -> i32;
|
||||
|
||||
#[link_name = "sys_eventfd"]
|
||||
pub fn eventfd(initval: u64, flags: i16) -> i32;
|
||||
|
||||
#[link_name = "sys_poll"]
|
||||
pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: i32) -> i32;
|
||||
}
|
||||
Vendored
+309
@@ -0,0 +1,309 @@
|
||||
//! Raw FFI bindings to platform system libraries.
|
||||
//!
|
||||
//! # Usage Guidelines
|
||||
//!
|
||||
//! `libc` exposes non-Rust interfaces in Rust, which makes for some caveats to its use that are
|
||||
//! not present in most Rust libraries. Observing the following guidelines are recommended to help
|
||||
//! avoid soundness and stability pitfalls.
|
||||
//!
|
||||
//! 1. *Never* construct a `libc` struct with `MaybeUninit::uninit()`, initialize it, then call
|
||||
//! `assume_init`. Many structures have padding fields or may gain fields in the future, and
|
||||
//! it is far too easy to end up calling `assume_init` on partially initialized data.
|
||||
//!
|
||||
//! Instead, use `MaybeUninit::zeroed()` or the `Default` implementations that are slowly being
|
||||
//! added. Alternatively, access fields only via raw pointer without ever using `assume_init`.
|
||||
//!
|
||||
//! 2. Avoid relying on the exact value of constants, the exact length of arrays, or the exact
|
||||
//! types of type aliases, as they may change across `libc` versions. That is, if `libc`
|
||||
//! contains code like:
|
||||
//!
|
||||
//! <!-- relevant for how rustdoc displays these structs:
|
||||
//! https://github.com/rust-lang/rust/issues/102456 -->
|
||||
//! ```ignore
|
||||
//! const IFNAMSIZ: usize = 16;
|
||||
//!
|
||||
//! pub struct ifreq {
|
||||
//! pub ifr_name: [c_char; IFNAMSIZ],
|
||||
//! // ...
|
||||
//! }
|
||||
//!
|
||||
//! extern "C" {
|
||||
//! pub fn time(time: *mut time_t) -> time_t;
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
//! Then avoid writing code like:
|
||||
//!
|
||||
//! ```ignore
|
||||
//! // Bad assumption that the length will always be 16.
|
||||
//! fn takes_ifr_name(ifr_name: [c_char; 16]) { /* ... */ }
|
||||
//!
|
||||
//! fn process_ifr(ifr: ifreq) {
|
||||
//! takes_ifr_name(ifr.ifr_name);
|
||||
//! }
|
||||
//!
|
||||
//! // Bad assumption that `time_t` will always be an `i64`. Use `-> time_t` instead, or
|
||||
//! // explicitly cast to an `i64`.`
|
||||
//! fn get_time() -> i64 {
|
||||
//! unsafe { time(ptr::null_mut()) }
|
||||
//! }
|
||||
//!
|
||||
//! ```
|
||||
//!
|
||||
//! For `takes_ifr_name`, use `[c_char; IFNAMSIZ]` or just `&[c_char]` instead. For `get_time`,
|
||||
//! return a `time_t` or explicitly cast to an `i64`.
|
||||
//!
|
||||
//! Along the same lines, if you write code along the lines of `assert_eq!(libc::ELAST, 97)`,
|
||||
//! expect that there may be a release where this starts to fail.
|
||||
//!
|
||||
//! 3. Do not name `__c_anonymous_*` types anywhere, which exist to represent anonymous fields in
|
||||
//! C. For example, FreeBSD defines:
|
||||
//!
|
||||
//! ```c
|
||||
//! struct filestat {
|
||||
//! int fs_type;
|
||||
//! // ...
|
||||
//! struct { struct filestat stqe_next; } next;
|
||||
//! };
|
||||
//! ```
|
||||
//!
|
||||
//! Which is represented in `libc` as:
|
||||
//!
|
||||
//! ```ignore
|
||||
//! struct filestat {
|
||||
//! fs_type: c_int,
|
||||
//! // ...
|
||||
//! next: __c_anonymous_filestat,
|
||||
//! }
|
||||
//!
|
||||
//! struct __c_anonymous_filestat { stqe_next: *mut filestat }
|
||||
//! ```
|
||||
//!
|
||||
//! Accessing `some_filestat.next.stqe_next` is completely fine, but `__c_anonymous_filestat`
|
||||
//! should not be used anywhere (e.g. in a function signature). This is done to permit `libc` to
|
||||
//! switch to anonymous fields if the feature is ever added to Rust.
|
||||
//!
|
||||
//! 4. Avoid accessing fields with names such as `__reserved`, `_pad`, or `_spare`. Usually the
|
||||
//! platform libraries use these to allow adding new fields without changing the size of a
|
||||
//! struct, but this means their types change frequently.
|
||||
//!
|
||||
//! 5. Be aware of deprecation warnings. These are used as a way to migrate necessary API changes.
|
||||
//!
|
||||
//! # Cargo Features
|
||||
//!
|
||||
//! - `std`: by default `libc` assumes that the standard library contains link directives necessary
|
||||
//! to use the APIs in this crate. If `std` is disabled, `libc` will emit the directives instead.
|
||||
//!
|
||||
//! This feature is slated for removal in `libc` 1.0. The intention is that no-std users of
|
||||
//! `libc` should use their own `#[link]` attributes, `rustc-link-lib` build script directives,
|
||||
//! or `-l` arguments for only the system libraries they need to link, rather than `libc`
|
||||
//! possibly linking more than is needed or available. If you are using `libc` without the `std`
|
||||
//! feature, consider starting to add link directives now for a smoother 1.0 transition.
|
||||
//!
|
||||
//! - `extra_traits`: all types in `libc` implement `Clone`, `Copy`, and `Debug`. The
|
||||
//! `extra_traits` feature adds `Eq`, `Hash`, and `PartialEq`.
|
||||
//!
|
||||
//! This feature is expected to be removed in libc 1.0. Libraries should instead hash or check
|
||||
//! equality of only needed fields.
|
||||
//!
|
||||
//! - The features `const-extern-fn`, `align`, and `use_std` are all deprecated and do nothing.
|
||||
//!
|
||||
//! # Stability Expectations
|
||||
//!
|
||||
//! Due to `libc`'s position in the ecosystem, it can effectively never publish semver-breaking
|
||||
//! releases. However, the API that `libc` binds changes _all the time_; sometimes in ways that
|
||||
//! are harmless, sometimes in ways that are technically API-breaking for all users but unlikely
|
||||
//! to be noticed (e.g. removing deprecated API), and sometimes in ways that are nonbreaking in
|
||||
//! C but translate to breaking changes in Rust (e.g. changing the type of an integer). `libc`
|
||||
//! tries to strike a balance but all of this means that unfortunately, `libc` must occasionally
|
||||
//! ship changes within a semver-compatible release that are technically semver-breaking.
|
||||
//!
|
||||
//! The following are examples of changes that fall into this category:
|
||||
//!
|
||||
//! - Fields are added to a struct that is otherwise exhaustive.
|
||||
//! - Fields with names such as `padding` or `reserved` change type or are removed.
|
||||
//! - The length of an array type changes.
|
||||
//! - A struct field (with available padding) is changed from `int` to `long`.
|
||||
//!
|
||||
//! In general, `libc` aims to follow platform API changes, even when this means changes that are
|
||||
//! user-visible in Rust. There are a few guidelines used here:
|
||||
//!
|
||||
//! - Adding struct fields is not considered breaking, nor is changing fields named `reserved`,
|
||||
//! `padding`, or similar. This is because users are expected to use field-by-field
|
||||
//! initialization.
|
||||
//! - Changing type aliases, values of constants, or array lengths is not considered breaking.
|
||||
//! - If the platform libc has accepted breakage on the C side (typically in the form of removing
|
||||
//! old API), the `libc` crate will follow suit.
|
||||
//! - Where possible, `#[deprecated(...)]` will be used to warn about changes before applying them.
|
||||
//! Alternative mitigations may be considered.
|
||||
//! - Potentially breaking changes will be well-identified in release notes.
|
||||
//! - Beyond this, public API is not expected to change on Tier 1 targets. Tier 2 targets have
|
||||
//! relaxed API stability requirements, and API stability is not enforced on tier 3 targets.
|
||||
//!
|
||||
//! While this section seems scary, keep in mind that it is meant to cover worst-case scenarios. In
|
||||
//! practice, breakage is rare and following the above-discussed [Usage Guidelines](#usage-guidelines)
|
||||
//! means that most `libc` users will never encounter a problem.
|
||||
|
||||
// Make it a bit easier to build without Cargo
|
||||
#![crate_name = "libc"]
|
||||
#![crate_type = "rlib"]
|
||||
// Pretty much all C API doesn't match Rust conventions.
|
||||
#![allow(nonstandard_style)]
|
||||
// Not all macros and all patterns are used on all targets.
|
||||
#![allow(unused_macros)]
|
||||
#![allow(unused_macro_rules)]
|
||||
// All traits should be `Copy` and `Debug`.
|
||||
#![warn(missing_copy_implementations)]
|
||||
#![warn(missing_debug_implementations)]
|
||||
// Downgrade deny to a warning.
|
||||
#![warn(overflowing_literals)]
|
||||
// Prepare for a future upgrade.
|
||||
#![warn(rust_2024_compatibility)]
|
||||
// Things missing for 2024 that are blocked on MSRV or breakage.
|
||||
#![allow(missing_unsafe_on_extern)]
|
||||
#![allow(edition_2024_expr_fragment_specifier)]
|
||||
// Allowed globally, the warning is enabled in individual modules as we work through them
|
||||
#![allow(unsafe_op_in_unsafe_fn)]
|
||||
#![cfg_attr(libc_deny_warnings, deny(warnings))]
|
||||
// Attributes needed when building as part of the standard library
|
||||
#![cfg_attr(feature = "rustc-dep-of-std", feature(link_cfg, no_core))]
|
||||
#![cfg_attr(feature = "rustc-dep-of-std", allow(internal_features))]
|
||||
// Some targets don't need `link_cfg` and emit a warning.
|
||||
#![cfg_attr(feature = "rustc-dep-of-std", allow(unused_features))]
|
||||
// DIFF(1.0): The thread local references that raise this lint were removed in 1.0
|
||||
#![cfg_attr(feature = "rustc-dep-of-std", allow(static_mut_refs))]
|
||||
#![cfg_attr(not(feature = "rustc-dep-of-std"), no_std)]
|
||||
#![cfg_attr(feature = "rustc-dep-of-std", no_core)]
|
||||
|
||||
#[macro_use]
|
||||
mod macros;
|
||||
mod new;
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(feature = "rustc-dep-of-std")] {
|
||||
extern crate rustc_std_workspace_core as core;
|
||||
}
|
||||
}
|
||||
|
||||
pub use core::ffi::c_void;
|
||||
|
||||
#[allow(unused_imports)] // needed while the module is empty on some platforms
|
||||
pub use new::*;
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(windows)] {
|
||||
mod primitives;
|
||||
pub use crate::primitives::*;
|
||||
|
||||
mod windows;
|
||||
pub use crate::windows::*;
|
||||
|
||||
prelude!();
|
||||
} else if #[cfg(target_os = "fuchsia")] {
|
||||
mod primitives;
|
||||
pub use crate::primitives::*;
|
||||
|
||||
mod fuchsia;
|
||||
pub use crate::fuchsia::*;
|
||||
|
||||
prelude!();
|
||||
} else if #[cfg(target_os = "switch")] {
|
||||
mod primitives;
|
||||
pub use primitives::*;
|
||||
|
||||
mod switch;
|
||||
pub use switch::*;
|
||||
|
||||
prelude!();
|
||||
} else if #[cfg(target_os = "psp")] {
|
||||
mod primitives;
|
||||
pub use primitives::*;
|
||||
|
||||
mod psp;
|
||||
pub use crate::psp::*;
|
||||
|
||||
prelude!();
|
||||
} else if #[cfg(target_os = "vxworks")] {
|
||||
mod primitives;
|
||||
pub use crate::primitives::*;
|
||||
|
||||
mod vxworks;
|
||||
pub use crate::vxworks::*;
|
||||
|
||||
prelude!();
|
||||
} else if #[cfg(target_os = "qurt")] {
|
||||
mod primitives;
|
||||
pub use crate::primitives::*;
|
||||
|
||||
mod qurt;
|
||||
pub use crate::qurt::*;
|
||||
|
||||
prelude!();
|
||||
} else if #[cfg(target_os = "solid_asp3")] {
|
||||
mod primitives;
|
||||
pub use crate::primitives::*;
|
||||
|
||||
mod solid;
|
||||
pub use crate::solid::*;
|
||||
|
||||
prelude!();
|
||||
} else if #[cfg(unix)] {
|
||||
mod primitives;
|
||||
pub use crate::primitives::*;
|
||||
|
||||
mod unix;
|
||||
pub use crate::unix::*;
|
||||
|
||||
prelude!();
|
||||
} else if #[cfg(target_os = "hermit")] {
|
||||
mod primitives;
|
||||
pub use crate::primitives::*;
|
||||
|
||||
mod hermit;
|
||||
pub use crate::hermit::*;
|
||||
|
||||
prelude!();
|
||||
} else if #[cfg(target_os = "teeos")] {
|
||||
mod primitives;
|
||||
pub use primitives::*;
|
||||
|
||||
mod teeos;
|
||||
pub use teeos::*;
|
||||
|
||||
prelude!();
|
||||
} else if #[cfg(target_os = "trusty")] {
|
||||
mod primitives;
|
||||
pub use crate::primitives::*;
|
||||
|
||||
mod trusty;
|
||||
pub use crate::trusty::*;
|
||||
|
||||
prelude!();
|
||||
} else if #[cfg(all(target_env = "sgx", target_vendor = "fortanix"))] {
|
||||
mod primitives;
|
||||
pub use crate::primitives::*;
|
||||
|
||||
mod sgx;
|
||||
pub use crate::sgx::*;
|
||||
|
||||
prelude!();
|
||||
} else if #[cfg(any(target_env = "wasi", target_os = "wasi"))] {
|
||||
mod primitives;
|
||||
pub use crate::primitives::*;
|
||||
|
||||
mod wasi;
|
||||
pub use crate::wasi::*;
|
||||
|
||||
prelude!();
|
||||
} else if #[cfg(target_os = "xous")] {
|
||||
mod primitives;
|
||||
pub use crate::primitives::*;
|
||||
|
||||
mod xous;
|
||||
pub use crate::xous::*;
|
||||
|
||||
prelude!();
|
||||
} else {
|
||||
// non-supported targets: empty...
|
||||
}
|
||||
}
|
||||
Vendored
+700
@@ -0,0 +1,700 @@
|
||||
/// A macro for defining #[cfg] if-else statements.
|
||||
///
|
||||
/// This is similar to the `if/elif` C preprocessor macro by allowing definition
|
||||
/// of a cascade of `#[cfg]` cases, emitting the implementation which matches
|
||||
/// first.
|
||||
///
|
||||
/// This allows you to conveniently provide a long list #[cfg]'d blocks of code
|
||||
/// without having to rewrite each clause multiple times.
|
||||
macro_rules! cfg_if {
|
||||
// match if/else chains with a final `else`
|
||||
($(
|
||||
if #[cfg($($meta:meta),*)] { $($it:item)* }
|
||||
) else * else {
|
||||
$($it2:item)*
|
||||
}) => {
|
||||
cfg_if! {
|
||||
@__items
|
||||
() ;
|
||||
$( ( ($($meta),*) ($($it)*) ), )*
|
||||
( () ($($it2)*) ),
|
||||
}
|
||||
};
|
||||
|
||||
// match if/else chains lacking a final `else`
|
||||
(
|
||||
if #[cfg($($i_met:meta),*)] { $($i_it:item)* }
|
||||
$(
|
||||
else if #[cfg($($e_met:meta),*)] { $($e_it:item)* }
|
||||
)*
|
||||
) => {
|
||||
cfg_if! {
|
||||
@__items
|
||||
() ;
|
||||
( ($($i_met),*) ($($i_it)*) ),
|
||||
$( ( ($($e_met),*) ($($e_it)*) ), )*
|
||||
( () () ),
|
||||
}
|
||||
};
|
||||
|
||||
// Internal and recursive macro to emit all the items
|
||||
//
|
||||
// Collects all the negated `cfg`s in a list at the beginning and after the
|
||||
// semicolon is all the remaining items
|
||||
(@__items ($($not:meta,)*) ; ) => {};
|
||||
(@__items ($($not:meta,)*) ; ( ($($m:meta),*) ($($it:item)*) ),
|
||||
$($rest:tt)*) => {
|
||||
// Emit all items within one block, applying an appropriate #[cfg]. The
|
||||
// #[cfg] will require all `$m` matchers specified and must also negate
|
||||
// all previous matchers.
|
||||
cfg_if! { @__apply cfg(all($($m,)* not(any($($not),*)))), $($it)* }
|
||||
|
||||
// Recurse to emit all other items in `$rest`, and when we do so add all
|
||||
// our `$m` matchers to the list of `$not` matchers as future emissions
|
||||
// will have to negate everything we just matched as well.
|
||||
cfg_if! { @__items ($($not,)* $($m,)*) ; $($rest)* }
|
||||
};
|
||||
|
||||
// Internal macro to Apply a cfg attribute to a list of items
|
||||
(@__apply $m:meta, $($it:item)*) => {
|
||||
$(#[$m] $it)*
|
||||
};
|
||||
}
|
||||
|
||||
/// Create an internal crate prelude with `core` reexports and common types.
|
||||
macro_rules! prelude {
|
||||
() => {
|
||||
mod types;
|
||||
|
||||
/// Frequently-used types that are available on all platforms
|
||||
///
|
||||
/// We need to reexport the core types so this works with `rust-dep-of-std`.
|
||||
mod prelude {
|
||||
// Exports from `core`
|
||||
#[allow(unused_imports)]
|
||||
pub(crate) use core::clone::Clone;
|
||||
#[allow(unused_imports)]
|
||||
pub(crate) use core::default::Default;
|
||||
#[allow(unused_imports)]
|
||||
pub(crate) use core::marker::{
|
||||
Copy,
|
||||
Send,
|
||||
Sync,
|
||||
};
|
||||
#[allow(unused_imports)]
|
||||
pub(crate) use core::option::Option;
|
||||
#[allow(unused_imports)]
|
||||
pub(crate) use core::prelude::v1::derive;
|
||||
#[allow(unused_imports)]
|
||||
pub(crate) use core::{
|
||||
assert,
|
||||
cfg,
|
||||
debug_assert,
|
||||
fmt,
|
||||
hash,
|
||||
iter,
|
||||
mem,
|
||||
ptr,
|
||||
};
|
||||
|
||||
#[allow(unused_imports)]
|
||||
pub(crate) use fmt::Debug;
|
||||
#[allow(unused_imports)]
|
||||
pub(crate) use mem::{
|
||||
align_of,
|
||||
align_of_val,
|
||||
size_of,
|
||||
size_of_val,
|
||||
};
|
||||
|
||||
#[allow(unused_imports)]
|
||||
#[cfg(any(target_os = "linux", target_os = "android", target_os = "l4re"))]
|
||||
pub(crate) use crate::types::u32_cast_ioctl;
|
||||
#[allow(unused_imports)]
|
||||
pub(crate) use crate::types::{
|
||||
replace_array_items,
|
||||
u16_cast_short,
|
||||
u32_cast_int,
|
||||
u32_cast_long,
|
||||
u8_slice_cast_char_slice,
|
||||
ulong_cast_int,
|
||||
ulong_cast_uint,
|
||||
CEnumRepr,
|
||||
Padding,
|
||||
};
|
||||
// Commonly used types defined in this crate
|
||||
#[allow(unused_imports)]
|
||||
pub(crate) use crate::{
|
||||
c_char,
|
||||
c_double,
|
||||
c_float,
|
||||
c_int,
|
||||
c_long,
|
||||
c_longlong,
|
||||
c_short,
|
||||
c_uchar,
|
||||
c_uint,
|
||||
c_ulong,
|
||||
c_ulonglong,
|
||||
c_ushort,
|
||||
c_void,
|
||||
intptr_t,
|
||||
size_t,
|
||||
ssize_t,
|
||||
uintptr_t,
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// Implement `Clone`, `Copy`, and `Debug` for one or more structs, as well as `PartialEq`, `Eq`,
|
||||
/// and `Hash` if the `extra_traits` feature is enabled.
|
||||
///
|
||||
/// Also mark the type with `repr(C)`.
|
||||
///
|
||||
/// Use [`s_no_extra_traits`] for structs where the `extra_traits` feature does not
|
||||
/// make sense, and for unions.
|
||||
macro_rules! s {
|
||||
($(
|
||||
$(#[$attr:meta])*
|
||||
$pub:vis $t:ident $i:ident { $($field:tt)* }
|
||||
)*) => ($(
|
||||
s!(it: $(#[$attr])* $pub $t $i { $($field)* });
|
||||
)*);
|
||||
|
||||
(it: $(#[$attr:meta])* $pub:vis union $i:ident { $($field:tt)* }) => (
|
||||
compile_error!("unions cannot derive extra traits, use s_no_extra_traits instead");
|
||||
);
|
||||
|
||||
(it: $(#[$attr:meta])* $pub:vis struct $i:ident { $($field:tt)* }) => (
|
||||
#[repr(C)]
|
||||
#[::core::prelude::v1::derive(
|
||||
::core::clone::Clone,
|
||||
::core::marker::Copy,
|
||||
::core::fmt::Debug,
|
||||
)]
|
||||
#[cfg_attr(
|
||||
feature = "extra_traits",
|
||||
::core::prelude::v1::derive(PartialEq, Eq, Hash)
|
||||
)]
|
||||
#[allow(deprecated)]
|
||||
$(#[$attr])*
|
||||
$pub struct $i { $($field)* }
|
||||
);
|
||||
}
|
||||
|
||||
/// Implement `Clone`, `Copy`, and `Debug` for a tuple struct, as well as `PartialEq`, `Eq`,
|
||||
/// and `Hash` if the `extra_traits` feature is enabled.
|
||||
///
|
||||
/// Unlike `s!`, this does *not* mark the type with `repr(C)`. Users should provide their own
|
||||
/// `repr` attribute via `$attr` as necessary.
|
||||
macro_rules! s_paren {
|
||||
($(
|
||||
$(#[$attr:meta])*
|
||||
$pub:vis struct $i:ident ( $($field:tt)* );
|
||||
)*) => ($(
|
||||
#[::core::prelude::v1::derive(
|
||||
::core::clone::Clone,
|
||||
::core::marker::Copy,
|
||||
::core::fmt::Debug,
|
||||
)]
|
||||
#[cfg_attr(
|
||||
feature = "extra_traits",
|
||||
::core::prelude::v1::derive(PartialEq, Eq, Hash)
|
||||
)]
|
||||
$(#[$attr])*
|
||||
$pub struct $i ( $($field)* );
|
||||
)*);
|
||||
}
|
||||
|
||||
/// Implement `Clone`, `Copy`, and `Debug` for one or more structs/unions, but exclude `PartialEq`,
|
||||
/// `Eq`, and `Hash`.
|
||||
///
|
||||
/// Also mark the type with `repr(C)`.
|
||||
///
|
||||
/// Most structs will prefer to use [`s`].
|
||||
macro_rules! s_no_extra_traits {
|
||||
($(
|
||||
$(#[$attr:meta])*
|
||||
$pub:vis $t:ident $i:ident { $($field:tt)* }
|
||||
)*) => ($(
|
||||
s_no_extra_traits!(it: $(#[$attr])* $pub $t $i { $($field)* });
|
||||
)*);
|
||||
|
||||
(it: $(#[$attr:meta])* $pub:vis union $i:ident { $($field:tt)* }) => (
|
||||
#[repr(C)]
|
||||
#[::core::prelude::v1::derive(
|
||||
::core::clone::Clone,
|
||||
::core::marker::Copy,
|
||||
)]
|
||||
$(#[$attr])*
|
||||
$pub union $i { $($field)* }
|
||||
|
||||
impl ::core::fmt::Debug for $i {
|
||||
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
|
||||
f.debug_struct(::core::stringify!($i)).finish_non_exhaustive()
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
(it: $(#[$attr:meta])* $pub:vis struct $i:ident { $($field:tt)* }) => (
|
||||
#[repr(C)]
|
||||
#[::core::prelude::v1::derive(
|
||||
::core::clone::Clone,
|
||||
::core::marker::Copy,
|
||||
::core::fmt::Debug,
|
||||
)]
|
||||
$(#[$attr])*
|
||||
$pub struct $i { $($field)* }
|
||||
);
|
||||
}
|
||||
|
||||
/// Create an uninhabited type that can't be constructed. It implements `Debug`, `Clone`,
|
||||
/// and `Copy`, but these aren't meaningful for extern types so they should eventually
|
||||
/// be removed.
|
||||
///
|
||||
/// Really what we want here is something that also can't be named without indirection (in
|
||||
/// ADTs or function signatures), but this doesn't exist.
|
||||
macro_rules! extern_ty {
|
||||
($(
|
||||
$(#[$attr:meta])*
|
||||
$vis:vis type $i:ident;
|
||||
)*) => ($(
|
||||
$(#[$attr])*
|
||||
/// This is an extern type ("opaque" or "incomplete" type in C).
|
||||
///
|
||||
/// <div class="warning">
|
||||
/// This type's current representation allows inspecting some properties, such as via
|
||||
/// <code>size_of</code>, and it is technically possible to construct the type within
|
||||
/// <code>MaybeUninit</code>, However, this <strong>MUST NOT</strong> be relied upon
|
||||
/// because a future version of <code>libc</code> may switch to a proper
|
||||
/// <a href="https://rust-lang.github.io/rfcs/1861-extern-types.html">extern type</a>
|
||||
/// representation when available.
|
||||
/// </div>
|
||||
// ^ unfortunately warning blocks currently don't render markdown so we need to
|
||||
// use raw HTML.
|
||||
//
|
||||
// Representation based on the Nomicon:
|
||||
// <https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs>.
|
||||
//
|
||||
// FIXME(1.0): These traits are unreachable and should be removed.
|
||||
#[::core::prelude::v1::derive(
|
||||
::core::clone::Clone,
|
||||
::core::marker::Copy,
|
||||
::core::fmt::Debug,
|
||||
)]
|
||||
#[repr(C)]
|
||||
$vis struct $i {
|
||||
_data: (),
|
||||
_marker: ::core::marker::PhantomData<(*mut u8, ::core::marker::PhantomPinned)>,
|
||||
}
|
||||
)*);
|
||||
}
|
||||
|
||||
/// Implement `Clone` and `Copy` for an enum, as well as `Debug`, `Eq`, `Hash`, and
|
||||
/// `PartialEq` if the `extra_traits` feature is enabled.
|
||||
// FIXME(#4419): Replace all uses of `e!` with `c_enum!`
|
||||
macro_rules! e {
|
||||
($(
|
||||
$(#[$attr:meta])*
|
||||
pub enum $i:ident { $($field:tt)* }
|
||||
)*) => ($(
|
||||
#[cfg_attr(
|
||||
feature = "extra_traits",
|
||||
::core::prelude::v1::derive(Eq, Hash, PartialEq)
|
||||
)]
|
||||
#[::core::prelude::v1::derive(
|
||||
::core::clone::Clone,
|
||||
::core::marker::Copy,
|
||||
::core::fmt::Debug,
|
||||
)]
|
||||
$(#[$attr])*
|
||||
pub enum $i { $($field)* }
|
||||
)*);
|
||||
}
|
||||
|
||||
/// Represent a C enum as Rust constants and a type.
|
||||
///
|
||||
/// C enums can't soundly be mapped to Rust enums since C enums are allowed to have duplicates or
|
||||
/// unlisted values, but this is UB in Rust. This enum doesn't implement any traits, its main
|
||||
/// purpose is to calculate the correct enum values.
|
||||
///
|
||||
/// Use the magic name `#anon` if the C enum doesn't create a type.
|
||||
///
|
||||
/// See <https://github.com/rust-lang/libc/issues/4419> for more.
|
||||
macro_rules! c_enum {
|
||||
// Matcher for multiple enums
|
||||
($(
|
||||
$(#[repr($repr:ty)])?
|
||||
$vis:vis enum $($ty_name:ident)? $(#$anon:ident)? {
|
||||
$($field_vis:vis $variant:ident $(= $value:expr)?,)+
|
||||
}
|
||||
)+) => {
|
||||
$(c_enum!(@single;
|
||||
$(#[repr($repr)])?
|
||||
$vis enum $($ty_name)? $(#$anon)? {
|
||||
$($field_vis $variant $(= $value)?,)+
|
||||
}
|
||||
);)+
|
||||
};
|
||||
|
||||
// Matcher for a single enum
|
||||
(@single;
|
||||
$(#[repr($repr:ty)])?
|
||||
$vis:vis enum $ty_name:ident {
|
||||
$($field_vis:vis $variant:ident $(= $value:expr)?,)+
|
||||
}
|
||||
) => {
|
||||
$vis type $ty_name = c_enum!(@ty $($repr)?);
|
||||
c_enum! {
|
||||
@variant;
|
||||
ty: $ty_name;
|
||||
default: 0;
|
||||
variants: [$($field_vis $variant $(= $value)?,)+]
|
||||
}
|
||||
};
|
||||
|
||||
// Matcher for a single anonymous enum
|
||||
(@single;
|
||||
$(#[repr($repr:ty)])?
|
||||
$vis:vis enum #anon {
|
||||
$($field_vis:vis $variant:ident $(= $value:expr)?,)+
|
||||
}
|
||||
) => {
|
||||
c_enum! {
|
||||
@variant;
|
||||
ty: c_enum!(@ty $($repr)?);
|
||||
default: 0;
|
||||
variants: [$($field_vis $variant $(= $value)?,)+]
|
||||
}
|
||||
};
|
||||
|
||||
// Matcher for variants: eats a single variant then recurses with the rest
|
||||
(@variant; ty: $_ty_name:ty; default: $_idx:expr; variants: []) => { /* end of the chain */ };
|
||||
(
|
||||
@variant;
|
||||
ty: $ty_name:ty;
|
||||
default: $default_val:expr;
|
||||
variants: [
|
||||
$field_vis:vis $variant:ident $(= $value:expr)?,
|
||||
$($tail:tt)*
|
||||
]
|
||||
) => {
|
||||
$field_vis const $variant: $ty_name = {
|
||||
#[allow(unused_variables)]
|
||||
let r = $default_val;
|
||||
$(let r = $value;)?
|
||||
r
|
||||
};
|
||||
|
||||
// The next value is always one more than the previous value, unless
|
||||
// set explicitly.
|
||||
c_enum! {
|
||||
@variant;
|
||||
ty: $ty_name;
|
||||
default: $variant + 1;
|
||||
variants: [$($tail)*]
|
||||
}
|
||||
};
|
||||
|
||||
// Use a specific type if provided, otherwise default to `CEnumRepr`
|
||||
(@ty $repr:ty) => { $repr };
|
||||
(@ty) => { $crate::prelude::CEnumRepr };
|
||||
}
|
||||
|
||||
/// Define a `unsafe` function.
|
||||
macro_rules! f {
|
||||
($(
|
||||
$(#[$attr:meta])*
|
||||
pub $(const $($const_dummy:literal)?)? unsafe
|
||||
fn $i:ident ($($arg:ident: $argty:ty),* $(,)?) -> $ret:ty
|
||||
$body:block
|
||||
)+) => {$(
|
||||
#[inline]
|
||||
$(#[$attr])*
|
||||
pub $(const $($const_dummy)?)? unsafe extern "C"
|
||||
fn $i ($($arg: $argty),*) -> $ret
|
||||
$body
|
||||
)+};
|
||||
}
|
||||
|
||||
/// Define a safe function.
|
||||
macro_rules! safe_f {
|
||||
($(
|
||||
$(#[$attr:meta])*
|
||||
pub $(const $($const_dummy:literal)?)? safe
|
||||
fn $i:ident ($($arg:ident: $argty:ty),* $(,)?) -> $ret:ty
|
||||
$body:block
|
||||
)+) => {$(
|
||||
#[inline]
|
||||
$(#[$attr])*
|
||||
pub $(const $($const_dummy)?)? extern "C"
|
||||
fn $i ($($arg: $argty),*) -> $ret
|
||||
$body
|
||||
)+};
|
||||
}
|
||||
|
||||
// This macro is used to deprecate items that should be accessed via the mach2 crate
|
||||
macro_rules! deprecated_mach {
|
||||
(pub const $id:ident: $ty:ty = $expr:expr;) => {
|
||||
#[deprecated(
|
||||
since = "0.2.55",
|
||||
note = "Use the `mach2` crate instead",
|
||||
)]
|
||||
#[allow(deprecated)]
|
||||
pub const $id: $ty = $expr;
|
||||
};
|
||||
($(pub const $id:ident: $ty:ty = $expr:expr;)*) => {
|
||||
$(
|
||||
deprecated_mach!(
|
||||
pub const $id: $ty = $expr;
|
||||
);
|
||||
)*
|
||||
};
|
||||
(pub type $id:ident = $ty:ty;) => {
|
||||
#[deprecated(
|
||||
since = "0.2.55",
|
||||
note = "Use the `mach2` crate instead",
|
||||
)]
|
||||
#[allow(deprecated)]
|
||||
pub type $id = $ty;
|
||||
};
|
||||
($(pub type $id:ident = $ty:ty;)*) => {
|
||||
$(
|
||||
deprecated_mach!(
|
||||
pub type $id = $ty;
|
||||
);
|
||||
)*
|
||||
}
|
||||
}
|
||||
|
||||
/// Polyfill for std's `offset_of`.
|
||||
// FIXME(msrv): stabilized in std in 1.77
|
||||
macro_rules! offset_of {
|
||||
($Ty:path, $field:ident) => {{
|
||||
// Taken from bytemuck, avoids accidentally calling on deref
|
||||
#[allow(clippy::unneeded_wildcard_pattern)]
|
||||
let $Ty { $field: _, .. };
|
||||
let data = core::mem::MaybeUninit::<$Ty>::uninit();
|
||||
let ptr = data.as_ptr();
|
||||
// nested unsafe, see f!
|
||||
#[allow(unused_unsafe)]
|
||||
// SAFETY: computed address is inbounds since we have a stack alloc for T
|
||||
let fptr = unsafe { core::ptr::addr_of!((*ptr).$field) };
|
||||
let off = (fptr as usize).checked_sub(ptr as usize).unwrap();
|
||||
core::assert!(off <= core::mem::size_of::<$Ty>());
|
||||
off
|
||||
}};
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use core::any::TypeId;
|
||||
|
||||
use crate::types::CEnumRepr;
|
||||
|
||||
#[test]
|
||||
fn c_enum_basic() {
|
||||
// By default, variants get sequential values.
|
||||
c_enum! {
|
||||
pub enum e {
|
||||
VAR0,
|
||||
VAR1,
|
||||
VAR2,
|
||||
}
|
||||
|
||||
// Also check enums that don't create a type.
|
||||
pub enum #anon {
|
||||
ANON0,
|
||||
ANON1,
|
||||
ANON2,
|
||||
}
|
||||
|
||||
// No visibility required.
|
||||
enum #anon {
|
||||
ANON3,
|
||||
ANON4,
|
||||
ANON5,
|
||||
}
|
||||
}
|
||||
|
||||
assert_eq!(TypeId::of::<e>(), TypeId::of::<CEnumRepr>());
|
||||
assert_eq!(VAR0, 0 as CEnumRepr);
|
||||
assert_eq!(VAR1, 1 as CEnumRepr);
|
||||
assert_eq!(VAR2, 2 as CEnumRepr);
|
||||
|
||||
assert_eq!(type_id_of_val(&ANON0), TypeId::of::<CEnumRepr>());
|
||||
assert_eq!(ANON0, 0 as CEnumRepr);
|
||||
assert_eq!(ANON1, 1 as CEnumRepr);
|
||||
assert_eq!(ANON2, 2 as CEnumRepr);
|
||||
|
||||
assert_eq!(type_id_of_val(&ANON3), TypeId::of::<CEnumRepr>());
|
||||
assert_eq!(ANON3, 0 as CEnumRepr);
|
||||
assert_eq!(ANON4, 1 as CEnumRepr);
|
||||
assert_eq!(ANON5, 2 as CEnumRepr);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn c_enum_repr() {
|
||||
// Check specifying the integer representation
|
||||
c_enum! {
|
||||
#[repr(u16)]
|
||||
pub enum e {
|
||||
VAR0,
|
||||
}
|
||||
|
||||
#[repr(u16)]
|
||||
pub enum #anon {
|
||||
ANON0,
|
||||
}
|
||||
}
|
||||
|
||||
assert_eq!(TypeId::of::<e>(), TypeId::of::<u16>());
|
||||
assert_eq!(VAR0, 0_u16);
|
||||
|
||||
assert_eq!(type_id_of_val(&ANON0), TypeId::of::<u16>());
|
||||
assert_eq!(ANON0, 0_u16);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn c_enum_set_value() {
|
||||
// Setting an explicit value resets the count.
|
||||
c_enum! {
|
||||
pub enum e {
|
||||
VAR2 = 2,
|
||||
VAR3,
|
||||
VAR4,
|
||||
}
|
||||
}
|
||||
|
||||
assert_eq!(VAR2, 2 as CEnumRepr);
|
||||
assert_eq!(VAR3, 3 as CEnumRepr);
|
||||
assert_eq!(VAR4, 4 as CEnumRepr);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn c_enum_multiple_set_value() {
|
||||
// C enums always take one more than the previous value, unless set to a specific
|
||||
// value. Duplicates are allowed.
|
||||
c_enum! {
|
||||
pub enum e {
|
||||
VAR0,
|
||||
VAR2_0 = 2,
|
||||
VAR3_0,
|
||||
VAR4_0,
|
||||
VAR2_1 = 2,
|
||||
VAR3_1,
|
||||
VAR4_1,
|
||||
}
|
||||
}
|
||||
|
||||
assert_eq!(VAR0, 0 as CEnumRepr);
|
||||
assert_eq!(VAR2_0, 2 as CEnumRepr);
|
||||
assert_eq!(VAR3_0, 3 as CEnumRepr);
|
||||
assert_eq!(VAR4_0, 4 as CEnumRepr);
|
||||
assert_eq!(VAR2_1, 2 as CEnumRepr);
|
||||
assert_eq!(VAR3_1, 3 as CEnumRepr);
|
||||
assert_eq!(VAR4_1, 4 as CEnumRepr);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn c_enum_vis() {
|
||||
mod priv1 {
|
||||
c_enum! {
|
||||
#[repr(u8)]
|
||||
pub enum e1 {
|
||||
PRIV_ON_1 = 10,
|
||||
// Variant should still be usable within its visibility
|
||||
pub PUB1 = PRIV_ON_1 * 2,
|
||||
}
|
||||
}
|
||||
}
|
||||
mod priv2 {
|
||||
c_enum! {
|
||||
#[repr(u16)]
|
||||
pub enum e2 {
|
||||
pub PRIV_ON_1 = 42,
|
||||
pub PUB2 = PRIV_ON_1 * 2,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
use priv1::*;
|
||||
use priv2::*;
|
||||
|
||||
assert_eq!(TypeId::of::<e1>(), TypeId::of::<u8>());
|
||||
assert_eq!(TypeId::of::<e2>(), TypeId::of::<u16>());
|
||||
assert_eq!(PUB1, 10u8 * 2);
|
||||
assert_eq!(PUB2, 42u16 * 2);
|
||||
// Verify that the default is private. If `PRIV_ON_1` was actually public in `priv1`, this
|
||||
// would be an ambiguous import and/or type mismatch error.
|
||||
assert_eq!(PRIV_ON_1, 42u16);
|
||||
}
|
||||
|
||||
fn type_id_of_val<T: 'static>(_: &T) -> TypeId {
|
||||
TypeId::of::<T>()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_offset_of() {
|
||||
#[repr(C)]
|
||||
struct Off1 {
|
||||
a: u8,
|
||||
b: u32,
|
||||
c: Off2,
|
||||
d: u64,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[repr(align(128))]
|
||||
struct Off2 {}
|
||||
|
||||
assert_eq!(core::mem::offset_of!(Off1, a), offset_of!(Off1, a));
|
||||
assert_eq!(core::mem::offset_of!(Off1, b), offset_of!(Off1, b));
|
||||
assert_eq!(core::mem::offset_of!(Off1, c), offset_of!(Off1, c));
|
||||
assert_eq!(core::mem::offset_of!(Off1, d), offset_of!(Off1, d));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[allow(unused)]
|
||||
mod macro_checks {
|
||||
s! {
|
||||
pub struct S1 {
|
||||
pub a: u32,
|
||||
b: u32,
|
||||
}
|
||||
|
||||
struct S1Priv {
|
||||
pub a: u32,
|
||||
b: u32,
|
||||
}
|
||||
}
|
||||
|
||||
s_no_extra_traits! {
|
||||
pub struct S2 {
|
||||
pub a: u32,
|
||||
b: u32,
|
||||
}
|
||||
|
||||
struct S2Priv {
|
||||
pub a: u32,
|
||||
b: u32,
|
||||
}
|
||||
|
||||
pub union U2 {
|
||||
pub a: u32,
|
||||
b: f32,
|
||||
}
|
||||
|
||||
union U2Priv {
|
||||
pub a: u32,
|
||||
b: f32,
|
||||
}
|
||||
}
|
||||
|
||||
extern_ty! {
|
||||
type Foo;
|
||||
pub type Bar;
|
||||
}
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
//! IBM AIX libc.
|
||||
//!
|
||||
//! * Headers are not public
|
||||
//! * Manual pages: <https://www.ibm.com/docs/en/aix> (under "Technical reference" for that version)
|
||||
|
||||
pub(crate) mod unistd;
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
//! Header: `unistd.h`
|
||||
|
||||
pub use crate::new::common::posix::unistd::{
|
||||
STDERR_FILENO,
|
||||
STDIN_FILENO,
|
||||
STDOUT_FILENO,
|
||||
};
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
//! Header: `signal.h`
|
||||
//!
|
||||
//! <https://github.com/apple-oss-distributions/Libc/blob/main/include/signal.h>
|
||||
|
||||
pub use crate::sys::signal::*;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
//! Header: `unistd.h`
|
||||
|
||||
pub use crate::new::common::posix::unistd::{
|
||||
STDERR_FILENO,
|
||||
STDIN_FILENO,
|
||||
STDOUT_FILENO,
|
||||
};
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
//! Source from libpthread <https://github.com/apple-oss-distributions/libpthread/tree/main>
|
||||
|
||||
/// Directory: `pthread/`
|
||||
///
|
||||
/// Note that this module has a trailing underscore to avoid conflicting with its child `pthread`
|
||||
/// module.
|
||||
///
|
||||
/// <https://github.com/apple-oss-distributions/libpthread/tree/main/include/pthread>
|
||||
pub(crate) mod pthread_ {
|
||||
pub(crate) mod introspection;
|
||||
pub(crate) mod pthread;
|
||||
pub(crate) mod pthread_impl;
|
||||
pub(crate) mod pthread_spis;
|
||||
pub(crate) mod qos;
|
||||
pub(crate) mod sched;
|
||||
pub(crate) mod spawn;
|
||||
pub(crate) mod stack_np;
|
||||
}
|
||||
|
||||
pub(crate) mod sys;
|
||||
@@ -0,0 +1,36 @@
|
||||
//! Header: `pthread/introspection.h`
|
||||
//!
|
||||
//! <https://github.com/apple-oss-distributions/libpthread/blob/main/include/pthread/introspection.h>
|
||||
|
||||
use crate::prelude::*;
|
||||
pub use crate::pthread_::pthread::*;
|
||||
|
||||
c_enum! {
|
||||
#[repr(c_uint)]
|
||||
pub enum #anon {
|
||||
pub PTHREAD_INTROSPECTION_THREAD_CREATE = 1,
|
||||
pub PTHREAD_INTROSPECTION_THREAD_START,
|
||||
pub PTHREAD_INTROSPECTION_THREAD_TERMINATE,
|
||||
pub PTHREAD_INTROSPECTION_THREAD_DESTROY,
|
||||
}
|
||||
}
|
||||
|
||||
pub type pthread_introspection_hook_t =
|
||||
extern "C" fn(event: c_uint, thread: pthread_t, addr: *mut c_void, size: size_t);
|
||||
|
||||
extern "C" {
|
||||
// Available from Big Sur
|
||||
pub fn pthread_introspection_hook_install(
|
||||
hook: pthread_introspection_hook_t,
|
||||
) -> pthread_introspection_hook_t;
|
||||
pub fn pthread_introspection_setspecific_np(
|
||||
thread: pthread_t,
|
||||
key: pthread_key_t,
|
||||
value: *const c_void,
|
||||
) -> c_int;
|
||||
|
||||
pub fn pthread_introspection_getspecific_np(
|
||||
thread: pthread_t,
|
||||
key: pthread_key_t,
|
||||
) -> *mut c_void;
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
//! Header: `pthread.h` or `pthread/pthread.h`
|
||||
//!
|
||||
//! <https://github.com/apple-oss-distributions/libpthread/blob/main/include/pthread/pthread.h>
|
||||
|
||||
use crate::prelude::*;
|
||||
pub use crate::pthread_::qos::*;
|
||||
pub use crate::pthread_::sched::*;
|
||||
// No need to import from the `_pthread_attr_t` and similar modules since `_pthread_types` has
|
||||
// everything we need.
|
||||
pub use crate::sys::_pthread::_pthread_types::*;
|
||||
|
||||
pub const PTHREAD_CREATE_JOINABLE: c_int = 1;
|
||||
pub const PTHREAD_CREATE_DETACHED: c_int = 2;
|
||||
|
||||
pub const PTHREAD_INHERIT_SCHED: c_int = 1;
|
||||
pub const PTHREAD_EXPLICIT_SCHED: c_int = 2;
|
||||
|
||||
pub const PTHREAD_CANCEL_ENABLE: c_int = 0x01;
|
||||
pub const PTHREAD_CANCEL_DISABLE: c_int = 0x00;
|
||||
pub const PTHREAD_CANCEL_DEFERRED: c_int = 0x02;
|
||||
pub const PTHREAD_CANCEL_ASYNCHRONOUS: c_int = 0x00;
|
||||
|
||||
pub const PTHREAD_CANCELED: *mut c_void = 1 as *mut c_void;
|
||||
|
||||
pub const PTHREAD_SCOPE_SYSTEM: c_int = 1;
|
||||
pub const PTHREAD_SCOPE_PROCESS: c_int = 2;
|
||||
|
||||
pub const PTHREAD_PROCESS_SHARED: c_int = 1;
|
||||
pub const PTHREAD_PROCESS_PRIVATE: c_int = 2;
|
||||
|
||||
pub const PTHREAD_PRIO_NONE: c_int = 0;
|
||||
pub const PTHREAD_PRIO_INHERIT: c_int = 1;
|
||||
pub const PTHREAD_PRIO_PROTECT: c_int = 2;
|
||||
|
||||
pub const PTHREAD_MUTEX_NORMAL: c_int = 0;
|
||||
pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 1;
|
||||
pub const PTHREAD_MUTEX_RECURSIVE: c_int = 2;
|
||||
pub const PTHREAD_MUTEX_DEFAULT: c_int = PTHREAD_MUTEX_NORMAL;
|
||||
|
||||
pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
|
||||
__sig: _PTHREAD_RWLOCK_SIG_init,
|
||||
__opaque: [0; __PTHREAD_RWLOCK_SIZE__],
|
||||
};
|
||||
|
||||
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
|
||||
__sig: _PTHREAD_MUTEX_SIG_init,
|
||||
__opaque: [0; __PTHREAD_MUTEX_SIZE__],
|
||||
};
|
||||
|
||||
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
|
||||
__sig: _PTHREAD_COND_SIG_init,
|
||||
__opaque: [0; __PTHREAD_COND_SIZE__],
|
||||
};
|
||||
|
||||
pub const PTHREAD_ONCE_INIT: crate::pthread_once_t = crate::pthread_once_t {
|
||||
__sig: _PTHREAD_ONCE_SIG_INIT,
|
||||
__opaque: [0; __PTHREAD_ONCE_SIZE__],
|
||||
};
|
||||
|
||||
pub use crate::new::common::posix::pthread::{
|
||||
pthread_attr_getinheritsched,
|
||||
pthread_attr_getschedparam,
|
||||
pthread_attr_getschedpolicy,
|
||||
pthread_attr_setinheritsched,
|
||||
pthread_attr_setschedparam,
|
||||
pthread_attr_setschedpolicy,
|
||||
pthread_condattr_getpshared,
|
||||
pthread_condattr_setpshared,
|
||||
pthread_getschedparam,
|
||||
pthread_mutexattr_getpshared,
|
||||
pthread_mutexattr_setpshared,
|
||||
pthread_once,
|
||||
pthread_rwlockattr_getpshared,
|
||||
pthread_rwlockattr_setpshared,
|
||||
pthread_setschedparam,
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
use crate::prelude::*;
|
||||
|
||||
// FIXME(apple): these should all be `pub(crate)`
|
||||
pub const _PTHREAD_MUTEX_SIG_init: c_long = 0x32AAABA7;
|
||||
|
||||
pub const _PTHREAD_COND_SIG_init: c_long = 0x3CB0B1BB;
|
||||
pub(crate) const _PTHREAD_ONCE_SIG_INIT: c_long = 0x30B1BCBA;
|
||||
pub const _PTHREAD_RWLOCK_SIG_init: c_long = 0x2DA8B3B4;
|
||||
|
||||
pub const SCHED_OTHER: c_int = 1;
|
||||
pub const SCHED_FIFO: c_int = 4;
|
||||
pub const SCHED_RR: c_int = 2;
|
||||
@@ -0,0 +1,14 @@
|
||||
//! Header: `pthread/pthread_spis.h`
|
||||
//!
|
||||
//! <https://github.com/apple-oss-distributions/libpthread/blob/main/include/pthread/pthread_spis.h>
|
||||
|
||||
use crate::prelude::*;
|
||||
|
||||
extern "C" {
|
||||
pub fn pthread_create_from_mach_thread(
|
||||
thread: *mut crate::pthread_t,
|
||||
attr: *const crate::pthread_attr_t,
|
||||
f: extern "C" fn(*mut c_void) -> *mut c_void,
|
||||
value: *mut c_void,
|
||||
) -> c_int;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
//! Header: `pthread/qos.h`
|
||||
//!
|
||||
//! <https://github.com/apple-oss-distributions/libpthread/blob/main/include/pthread/qos.h>
|
||||
|
||||
use crate::prelude::*;
|
||||
pub use crate::sys::qos::*;
|
||||
|
||||
extern "C" {
|
||||
pub fn pthread_attr_set_qos_class_np(
|
||||
attr: *mut crate::pthread_attr_t,
|
||||
class: qos_class_t,
|
||||
priority: c_int,
|
||||
) -> c_int;
|
||||
pub fn pthread_attr_get_qos_class_np(
|
||||
attr: *mut crate::pthread_attr_t,
|
||||
class: *mut qos_class_t,
|
||||
priority: *mut c_int,
|
||||
) -> c_int;
|
||||
pub fn pthread_set_qos_class_self_np(class: qos_class_t, priority: c_int) -> c_int;
|
||||
pub fn pthread_get_qos_class_np(
|
||||
thread: crate::pthread_t,
|
||||
class: *mut qos_class_t,
|
||||
priority: *mut c_int,
|
||||
) -> c_int;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
pub use crate::new::pthread_::pthread_impl::*;
|
||||
use crate::prelude::*;
|
||||
|
||||
s! {
|
||||
pub struct sched_param {
|
||||
pub sched_priority: c_int,
|
||||
__opaque: [c_char; 4],
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
//! Header: `pthread/spawn.h`
|
||||
//!
|
||||
//! <https://github.com/apple-oss-distributions/libpthread/blob/main/include/pthread/spawn.h>
|
||||
|
||||
use crate::prelude::*;
|
||||
|
||||
extern "C" {
|
||||
pub fn posix_spawnattr_set_qos_class_np(
|
||||
attr: *mut crate::posix_spawnattr_t,
|
||||
qos_class: crate::qos_class_t,
|
||||
) -> c_int;
|
||||
pub fn posix_spawnattr_get_qos_class_np(
|
||||
attr: *const crate::posix_spawnattr_t,
|
||||
qos_class: *mut crate::qos_class_t,
|
||||
) -> c_int;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
//! Header: `pthread/stack_np.h`
|
||||
//!
|
||||
//! <https://github.com/apple-oss-distributions/libpthread/blob/main/include/pthread/stack_np.h>
|
||||
|
||||
use crate::prelude::*;
|
||||
|
||||
extern "C" {
|
||||
pub fn pthread_stack_frame_decode_np(
|
||||
frame_addr: uintptr_t,
|
||||
return_addr: *mut uintptr_t,
|
||||
) -> uintptr_t;
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
//! Header: `sys/_pthread/_pthread_types.h`
|
||||
//!
|
||||
//! <https://github.com/apple-oss-distributions/libpthread/blob/main/include/sys/_pthread/_pthread_types.h>
|
||||
//!
|
||||
//! Note that the actual header defines `_opaque_pthread_*` structs which are typedefed to
|
||||
//! `__darwin_pthread*` structs, and typedefed again in separate `_pthread_*.h` files to their final
|
||||
//! `pthread_` name. This isn't useful for us so we simplify a bit and just define everything here.
|
||||
|
||||
use crate::prelude::*;
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(target_pointer_width = "64")] {
|
||||
pub const __PTHREAD_SIZE__: usize = 8176;
|
||||
pub const __PTHREAD_ATTR_SIZE__: usize = 56;
|
||||
pub const __PTHREAD_MUTEXATTR_SIZE__: usize = 8;
|
||||
pub const __PTHREAD_MUTEX_SIZE__: usize = 56;
|
||||
pub const __PTHREAD_CONDATTR_SIZE__: usize = 8;
|
||||
pub const __PTHREAD_COND_SIZE__: usize = 40;
|
||||
pub const __PTHREAD_ONCE_SIZE__: usize = 8;
|
||||
pub const __PTHREAD_RWLOCK_SIZE__: usize = 192;
|
||||
pub const __PTHREAD_RWLOCKATTR_SIZE__: usize = 16;
|
||||
} else {
|
||||
pub const __PTHREAD_SIZE__: usize = 4088;
|
||||
pub const __PTHREAD_ATTR_SIZE__: usize = 36;
|
||||
pub const __PTHREAD_MUTEXATTR_SIZE__: usize = 8;
|
||||
pub const __PTHREAD_MUTEX_SIZE__: usize = 40;
|
||||
pub const __PTHREAD_CONDATTR_SIZE__: usize = 4;
|
||||
pub const __PTHREAD_COND_SIZE__: usize = 24;
|
||||
pub const __PTHREAD_ONCE_SIZE__: usize = 4;
|
||||
pub const __PTHREAD_RWLOCK_SIZE__: usize = 124;
|
||||
pub const __PTHREAD_RWLOCKATTR_SIZE__: usize = 12;
|
||||
}
|
||||
}
|
||||
|
||||
s! {
|
||||
pub struct pthread_attr_t {
|
||||
pub(crate) __sig: c_long,
|
||||
pub(crate) __opaque: [c_char; __PTHREAD_ATTR_SIZE__],
|
||||
}
|
||||
|
||||
pub struct pthread_cond_t {
|
||||
pub(crate) __sig: c_long,
|
||||
pub(crate) __opaque: [u8; __PTHREAD_COND_SIZE__],
|
||||
}
|
||||
|
||||
pub struct pthread_condattr_t {
|
||||
pub(crate) __sig: c_long,
|
||||
pub(crate) __opaque: [u8; __PTHREAD_CONDATTR_SIZE__],
|
||||
}
|
||||
|
||||
pub struct pthread_mutex_t {
|
||||
pub(crate) __sig: c_long,
|
||||
pub(crate) __opaque: [u8; __PTHREAD_MUTEX_SIZE__],
|
||||
}
|
||||
|
||||
pub struct pthread_mutexattr_t {
|
||||
pub(crate) __sig: c_long,
|
||||
pub(crate) __opaque: [u8; __PTHREAD_MUTEXATTR_SIZE__],
|
||||
}
|
||||
|
||||
pub struct pthread_once_t {
|
||||
pub(crate) __sig: c_long,
|
||||
pub(crate) __opaque: [c_char; __PTHREAD_ONCE_SIZE__],
|
||||
}
|
||||
|
||||
pub struct pthread_rwlock_t {
|
||||
pub(crate) __sig: c_long,
|
||||
pub(crate) __opaque: [u8; __PTHREAD_RWLOCK_SIZE__],
|
||||
}
|
||||
|
||||
pub struct pthread_rwlockattr_t {
|
||||
pub(crate) __sig: c_long,
|
||||
pub(crate) __opaque: [u8; __PTHREAD_RWLOCKATTR_SIZE__],
|
||||
}
|
||||
}
|
||||
|
||||
pub type pthread_key_t = c_ulong;
|
||||
|
||||
pub use crate::pthread_t;
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
//! Directory: `sys/`
|
||||
//!
|
||||
//! <https://github.com/apple-oss-distributions/libpthread/tree/main/include/sys/_pthread>
|
||||
|
||||
/// Directory: `sys/_pthread/`
|
||||
///
|
||||
/// <https://github.com/apple-oss-distributions/libpthread/tree/main/include/sys>
|
||||
pub(crate) mod _pthread {
|
||||
// We don't have the `_pthread_attr_t` and similar modules to match `_pthread_attr_t.h`,
|
||||
// everything is defined in `_pthread_types`.
|
||||
pub(crate) mod _pthread_types;
|
||||
}
|
||||
|
||||
pub(crate) mod qos;
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
//! Header: `sys/qos.h`
|
||||
//!
|
||||
//! <https://github.com/apple-oss-distributions/libpthread/blob/main/include/sys/qos.h>
|
||||
|
||||
use crate::prelude::*;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[repr(u32)]
|
||||
pub enum qos_class_t {
|
||||
QOS_CLASS_USER_INTERACTIVE = 0x21,
|
||||
QOS_CLASS_USER_INITIATED = 0x19,
|
||||
QOS_CLASS_DEFAULT = 0x15,
|
||||
QOS_CLASS_UTILITY = 0x11,
|
||||
QOS_CLASS_BACKGROUND = 0x09,
|
||||
QOS_CLASS_UNSPECIFIED = 0x00,
|
||||
}
|
||||
impl Copy for qos_class_t {}
|
||||
impl Clone for qos_class_t {
|
||||
fn clone(&self) -> qos_class_t {
|
||||
*self
|
||||
}
|
||||
}
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
//! Apple interfaces.
|
||||
//!
|
||||
//! The Xcode SDK includes interfaces that are split across a couple of different libraries. Most
|
||||
//! of these are available at <https://github.com/apple-oss-distributions>.
|
||||
|
||||
/// Entrypoint for Apple headers, usually found as part of the Xcode SDK.
|
||||
///
|
||||
/// <https://github.com/apple-oss-distributions/Libc/tree/main/include>
|
||||
mod libc {
|
||||
pub(crate) mod signal;
|
||||
pub(crate) mod unistd;
|
||||
}
|
||||
|
||||
mod libpthread;
|
||||
mod xnu;
|
||||
|
||||
pub(crate) use libc::*;
|
||||
pub(crate) use libpthread::pthread_;
|
||||
pub(crate) use xnu::*;
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
//! Header: `arm/_mcontext.h`
|
||||
//!
|
||||
//! <https://github.com/apple-oss-distributions/xnu/blob/main/bsd/arm/_mcontext.h>
|
||||
|
||||
pub use crate::mach::machine::_structs::*;
|
||||
|
||||
s! {
|
||||
pub struct __darwin_mcontext64 {
|
||||
pub __es: __darwin_arm_exception_state64,
|
||||
pub __ss: __darwin_arm_thread_state64,
|
||||
pub __ns: __darwin_arm_neon_state64,
|
||||
}
|
||||
}
|
||||
|
||||
pub type mcontext_t = *mut __darwin_mcontext64;
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
//! Header: `i386/_mcontext.h`
|
||||
//!
|
||||
//! <https://github.com/apple-oss-distributions/xnu/blob/main/bsd/i386/_mcontext.h>
|
||||
|
||||
pub use crate::mach::machine::_structs::*;
|
||||
|
||||
s! {
|
||||
pub struct __darwin_mcontext64 {
|
||||
pub __es: __darwin_x86_exception_state64,
|
||||
pub __ss: __darwin_x86_thread_state64,
|
||||
pub __fs: __darwin_x86_float_state64,
|
||||
}
|
||||
}
|
||||
|
||||
pub type mcontext_t = *mut __darwin_mcontext64;
|
||||
@@ -0,0 +1,37 @@
|
||||
//! Header: `arm/_structs.h`
|
||||
//!
|
||||
//! <https://github.com/apple-oss-distributions/xnu/blob/main/osfmk/mach/arm/_structs.h>
|
||||
|
||||
#[cfg(target_arch = "arm")]
|
||||
use crate::prelude::*;
|
||||
|
||||
s! {
|
||||
pub struct __darwin_arm_exception_state64 {
|
||||
pub __far: u64,
|
||||
pub __esr: u32,
|
||||
pub __exception: u32,
|
||||
}
|
||||
|
||||
pub struct __darwin_arm_thread_state64 {
|
||||
pub __x: [u64; 29],
|
||||
pub __fp: u64,
|
||||
pub __lr: u64,
|
||||
pub __sp: u64,
|
||||
pub __pc: u64,
|
||||
pub __cpsr: u32,
|
||||
pub __pad: u32,
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
pub struct __darwin_arm_neon_state64 {
|
||||
pub __v: [u128; 32],
|
||||
pub __fpsr: u32,
|
||||
pub __fpcr: u32,
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "arm")]
|
||||
#[repr(align(16))]
|
||||
pub struct __darwin_arm_neon_state64 {
|
||||
opaque: [c_char; (32 * 16) + (2 * size_of::<u32>())],
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
//! Header: `i386/_structs.h`
|
||||
//!
|
||||
//! <https://github.com/apple-oss-distributions/xnu/blob/main/osfmk/mach/i386/_structs.h>
|
||||
|
||||
use crate::prelude::*;
|
||||
|
||||
s! {
|
||||
pub struct __darwin_mmst_reg {
|
||||
pub __mmst_reg: [c_char; 10],
|
||||
pub __mmst_rsrv: [c_char; 6],
|
||||
}
|
||||
|
||||
pub struct __darwin_xmm_reg {
|
||||
pub __xmm_reg: [c_char; 16],
|
||||
}
|
||||
|
||||
pub struct __darwin_x86_thread_state64 {
|
||||
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,
|
||||
}
|
||||
|
||||
pub struct __darwin_x86_exception_state64 {
|
||||
pub __trapno: u16,
|
||||
pub __cpu: u16,
|
||||
pub __err: u32,
|
||||
pub __faultvaddr: u64,
|
||||
}
|
||||
|
||||
pub struct __darwin_x86_float_state64 {
|
||||
pub __fpu_reserved: [c_int; 2],
|
||||
__fpu_fcw: c_short,
|
||||
__fpu_fsw: c_short,
|
||||
pub __fpu_ftw: u8,
|
||||
pub __fpu_rsrv1: u8,
|
||||
pub __fpu_fop: u16,
|
||||
pub __fpu_ip: u32,
|
||||
pub __fpu_cs: u16,
|
||||
pub __fpu_rsrv2: u16,
|
||||
pub __fpu_dp: u32,
|
||||
pub __fpu_ds: u16,
|
||||
pub __fpu_rsrv3: u16,
|
||||
pub __fpu_mxcsr: u32,
|
||||
pub __fpu_mxcsrmask: u32,
|
||||
pub __fpu_stmm0: __darwin_mmst_reg,
|
||||
pub __fpu_stmm1: __darwin_mmst_reg,
|
||||
pub __fpu_stmm2: __darwin_mmst_reg,
|
||||
pub __fpu_stmm3: __darwin_mmst_reg,
|
||||
pub __fpu_stmm4: __darwin_mmst_reg,
|
||||
pub __fpu_stmm5: __darwin_mmst_reg,
|
||||
pub __fpu_stmm6: __darwin_mmst_reg,
|
||||
pub __fpu_stmm7: __darwin_mmst_reg,
|
||||
pub __fpu_xmm0: __darwin_xmm_reg,
|
||||
pub __fpu_xmm1: __darwin_xmm_reg,
|
||||
pub __fpu_xmm2: __darwin_xmm_reg,
|
||||
pub __fpu_xmm3: __darwin_xmm_reg,
|
||||
pub __fpu_xmm4: __darwin_xmm_reg,
|
||||
pub __fpu_xmm5: __darwin_xmm_reg,
|
||||
pub __fpu_xmm6: __darwin_xmm_reg,
|
||||
pub __fpu_xmm7: __darwin_xmm_reg,
|
||||
pub __fpu_xmm8: __darwin_xmm_reg,
|
||||
pub __fpu_xmm9: __darwin_xmm_reg,
|
||||
pub __fpu_xmm10: __darwin_xmm_reg,
|
||||
pub __fpu_xmm11: __darwin_xmm_reg,
|
||||
pub __fpu_xmm12: __darwin_xmm_reg,
|
||||
pub __fpu_xmm13: __darwin_xmm_reg,
|
||||
pub __fpu_xmm14: __darwin_xmm_reg,
|
||||
pub __fpu_xmm15: __darwin_xmm_reg,
|
||||
// FIXME(apple): this field is actually [u8; 96], but defining it with a bigger type allows
|
||||
// us to auto-implement traits for it since the length of the array is less than 32
|
||||
__fpu_rsrv4: [u32; 24],
|
||||
pub __fpu_reserved1: c_int,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
//! Header: `mach/machine/_structs.h`
|
||||
//!
|
||||
//! <https://github.com/apple-oss-distributions/xnu/blob/main/osfmk/mach/machine/_structs.h>
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] {
|
||||
pub use crate::mach::i386::_structs::*;
|
||||
} else if #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] {
|
||||
pub use crate::mach::arm::_structs::*;
|
||||
} else {
|
||||
// Unsupported arch
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
//! Directory: `mach/`
|
||||
//!
|
||||
//! <https://github.com/apple-oss-distributions/xnu/tree/main/osfmk/mach>
|
||||
|
||||
/// Directory: `mach/arm`
|
||||
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
|
||||
pub(crate) mod arm {
|
||||
pub(crate) mod _structs;
|
||||
}
|
||||
|
||||
/// Directory: `mach/i386`
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
pub(crate) mod i386 {
|
||||
pub(crate) mod _structs;
|
||||
}
|
||||
|
||||
/// Directory: `mach/machine`
|
||||
pub(crate) mod machine {
|
||||
pub(crate) mod _structs;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
//! Header: `machine/_mcontext.h`
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] {
|
||||
pub use crate::i386::_mcontext::*;
|
||||
} else if #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] {
|
||||
pub use crate::arm::_mcontext::*;
|
||||
} else {
|
||||
// Unsupported arch
|
||||
}
|
||||
}
|
||||
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
//! Source from XNU <https://github.com/apple-oss-distributions/xnu/tree/main>
|
||||
//!
|
||||
//! We omit nesting for the `bsd` module since most items of interest are in there.
|
||||
|
||||
/// Directory: `arm/`
|
||||
///
|
||||
/// https://github.com/apple-oss-distributions/xnu/tree/main/bsd/arm
|
||||
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
|
||||
pub(crate) mod arm {
|
||||
pub(crate) mod _mcontext;
|
||||
}
|
||||
|
||||
/// Directory: `i386/`
|
||||
///
|
||||
/// https://github.com/apple-oss-distributions/xnu/tree/main/bsd/i386
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
pub(crate) mod i386 {
|
||||
pub(crate) mod _mcontext;
|
||||
}
|
||||
|
||||
pub(crate) mod mach;
|
||||
|
||||
/// Directory: `machine/`
|
||||
///
|
||||
/// https://github.com/apple-oss-distributions/xnu/tree/main/bsd/machine
|
||||
pub(crate) mod machine {
|
||||
pub(crate) mod _mcontext;
|
||||
}
|
||||
|
||||
pub(crate) mod net;
|
||||
|
||||
pub(crate) mod netinet6;
|
||||
|
||||
pub(crate) mod sys;
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
//! Header: `net/bpf.h`
|
||||
//!
|
||||
//! <https://github.com/apple-oss-distributions/xnu/blob/main/bsd/net/bpf.h>
|
||||
|
||||
use crate::prelude::*;
|
||||
use crate::sys::ioccom::*;
|
||||
|
||||
s! {
|
||||
pub struct bpf_insn {
|
||||
pub code: c_ushort,
|
||||
pub jt: c_uchar,
|
||||
pub jf: c_uchar,
|
||||
pub k: u32,
|
||||
}
|
||||
|
||||
pub struct bpf_program {
|
||||
pub bf_len: c_uint,
|
||||
pub bf_insns: *mut bpf_insn,
|
||||
}
|
||||
}
|
||||
|
||||
s_no_extra_traits! {
|
||||
#[repr(packed(4))]
|
||||
pub struct bpf_dltlist {
|
||||
pub bfl_len: u32,
|
||||
pub bfl_u: __c_anonymous_bfl_u,
|
||||
}
|
||||
|
||||
pub union __c_anonymous_bfl_u {
|
||||
pub bflu_list: *mut u32,
|
||||
pub bflu_pad: u64,
|
||||
}
|
||||
}
|
||||
|
||||
pub const DLT_NULL: c_uint = 0; // no link-layer encapsulation
|
||||
pub const DLT_EN10MB: c_uint = 1; // Ethernet (10Mb)
|
||||
pub const DLT_EN3MB: c_uint = 2; // Experimental Ethernet (3Mb)
|
||||
pub const DLT_AX25: c_uint = 3; // Amateur Radio AX.25
|
||||
pub const DLT_PRONET: c_uint = 4; // Proteon ProNET Token Ring
|
||||
pub const DLT_CHAOS: c_uint = 5; // Chaos
|
||||
pub const DLT_IEEE802: c_uint = 6; // IEEE 802 Networks
|
||||
pub const DLT_ARCNET: c_uint = 7; // ARCNET
|
||||
pub const DLT_SLIP: c_uint = 8; // Serial Line IP
|
||||
pub const DLT_PPP: c_uint = 9; // Point-to-point Protocol
|
||||
pub const DLT_FDDI: c_uint = 10; // FDDI
|
||||
pub const DLT_ATM_RFC1483: c_uint = 11; // LLC/SNAP encapsulated atm
|
||||
pub const DLT_RAW: c_uint = 12; // raw IP
|
||||
pub const DLT_LOOP: c_uint = 108;
|
||||
|
||||
pub const BPF_ALIGNMENT: c_int = size_of::<i32>() as c_int;
|
||||
|
||||
pub const BIOCGRSIG: c_ulong = _IOR::<c_uint>('B' as c_ulong, 114);
|
||||
pub const BIOCSRSIG: c_ulong = _IOW::<c_uint>('B' as c_ulong, 115);
|
||||
pub const BIOCGSEESENT: c_ulong = _IOR::<c_uint>('B' as c_ulong, 118);
|
||||
pub const BIOCSSEESENT: c_ulong = _IOW::<c_uint>('B' as c_ulong, 119);
|
||||
pub const BIOCSDLT: c_ulong = _IOW::<c_uint>('B' as c_ulong, 120);
|
||||
pub const BIOCGDLTLIST: c_ulong = _IOWR::<bpf_dltlist>('B' as c_ulong, 121);
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
//! Directory: `net/`
|
||||
//!
|
||||
//! <https://github.com/apple-oss-distributions/xnu/tree/main/bsd/net>
|
||||
|
||||
pub(crate) mod bpf;
|
||||
@@ -0,0 +1,22 @@
|
||||
//! Header: `netinet6/in6_var.h`
|
||||
//!
|
||||
//! <https://github.com/apple-oss-distributions/xnu/blob/main/bsd/netinet6/in6_var.h>
|
||||
|
||||
use crate::prelude::*;
|
||||
use crate::sys::ioccom::*;
|
||||
|
||||
pub const IN6_IFF_ANYCAST: c_int = 0x0001;
|
||||
pub const IN6_IFF_TENTATIVE: c_int = 0x0002;
|
||||
pub const IN6_IFF_DUPLICATED: c_int = 0x0004;
|
||||
pub const IN6_IFF_DETACHED: c_int = 0x0008;
|
||||
pub const IN6_IFF_DEPRECATED: c_int = 0x0010;
|
||||
pub const IN6_IFF_NODAD: c_int = 0x0020;
|
||||
pub const IN6_IFF_AUTOCONF: c_int = 0x0040;
|
||||
pub const IN6_IFF_TEMPORARY: c_int = 0x0080;
|
||||
pub const IN6_IFF_DYNAMIC: c_int = 0x0100;
|
||||
pub const IN6_IFF_OPTIMISTIC: c_int = 0x0200;
|
||||
pub const IN6_IFF_SECURED: c_int = 0x0400;
|
||||
pub const IN6_IFF_CLAT46: c_int = 0x1000;
|
||||
pub const IN6_IFF_NOPFX: c_int = 0x8000;
|
||||
|
||||
pub const SIOCGIFAFLAG_IN6: c_ulong = _IOWR::<crate::in6_ifreq>('i' as c_ulong, 73);
|
||||
@@ -0,0 +1,5 @@
|
||||
//! Directory: `netinet6/`
|
||||
//!
|
||||
//! <https://github.com/apple-oss-distributions/xnu/tree/main/bsd/netinet6>
|
||||
|
||||
pub(crate) mod in6_var;
|
||||
@@ -0,0 +1,17 @@
|
||||
//! Header: `sys/_types/_ucontext.h`
|
||||
|
||||
pub use crate::machine::_mcontext::*;
|
||||
use crate::prelude::*;
|
||||
|
||||
s! {
|
||||
pub struct __darwin_ucontext {
|
||||
pub uc_onstack: c_int,
|
||||
pub uc_sigmask: crate::sigset_t,
|
||||
pub uc_stack: crate::stack_t,
|
||||
pub uc_link: *mut ucontext_t,
|
||||
pub uc_mcsize: usize,
|
||||
pub uc_mcontext: mcontext_t,
|
||||
}
|
||||
}
|
||||
|
||||
pub type ucontext_t = __darwin_ucontext;
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
//! Header: `sys/ioccom.h`
|
||||
//!
|
||||
//! <https://github.com/apple-oss-distributions/xnu/blob/main/bsd/sys/ioccom.h>
|
||||
|
||||
use crate::prelude::*;
|
||||
|
||||
const IOCPARM_MASK: c_ulong = 0x1fff;
|
||||
|
||||
const IOCPARM_MAX: c_ulong = IOCPARM_MASK + 1;
|
||||
|
||||
// These are u32 in source but would probably be more practical as c_ulong if we ever need
|
||||
// to make them public.
|
||||
pub(crate) const IOC_VOID: u32 = 0x20000000;
|
||||
pub(crate) const IOC_OUT: u32 = 0x40000000;
|
||||
pub(crate) const IOC_IN: u32 = 0x80000000;
|
||||
pub(crate) const IOC_INOUT: u32 = IOC_IN | IOC_OUT;
|
||||
pub(crate) const IOC_DIRMASK: u32 = 0xe0000000;
|
||||
|
||||
// Only pub(crate) for the above reason.
|
||||
pub(crate) const fn _IOC(inout: u32, group: c_ulong, num: c_ulong, len: c_ulong) -> c_ulong {
|
||||
debug_assert!(inout <= IOC_DIRMASK);
|
||||
debug_assert!(group <= 0xff);
|
||||
debug_assert!(num <= 0xff);
|
||||
debug_assert!(len <= IOCPARM_MAX);
|
||||
|
||||
// Sanity check the cast
|
||||
assert!(size_of::<u32>() <= size_of::<c_ulong>());
|
||||
|
||||
(inout as c_ulong) | ((len & IOCPARM_MASK) << 16) | (group << 8) | num
|
||||
}
|
||||
|
||||
pub const fn _IO(g: c_ulong, n: c_ulong) -> c_ulong {
|
||||
_IOC(IOC_VOID, g, n, 0)
|
||||
}
|
||||
|
||||
/// Build an ioctl number for an read-only ioctl.
|
||||
pub const fn _IOR<T>(g: c_ulong, n: c_ulong) -> c_ulong {
|
||||
_IOC(IOC_OUT, g, n, mem::size_of::<T>() as c_ulong)
|
||||
}
|
||||
|
||||
/// Build an ioctl number for an write-only ioctl.
|
||||
pub const fn _IOW<T>(g: c_ulong, n: c_ulong) -> c_ulong {
|
||||
_IOC(IOC_IN, g, n, mem::size_of::<T>() as c_ulong)
|
||||
}
|
||||
|
||||
/// Build an ioctl number for a read-write ioctl.
|
||||
pub const fn _IOWR<T>(g: c_ulong, n: c_ulong) -> c_ulong {
|
||||
_IOC(IOC_INOUT, g, n, mem::size_of::<T>() as c_ulong)
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
//! Directory: `sys/`
|
||||
//!
|
||||
//! <https://github.com/apple-oss-distributions/xnu/tree/main/bsd/sys>
|
||||
|
||||
pub(crate) mod ioccom;
|
||||
pub(crate) mod signal;
|
||||
pub(crate) mod sockio;
|
||||
pub(crate) mod ttycom;
|
||||
|
||||
/// Directory: `sys/_types`
|
||||
///
|
||||
/// https://github.com/apple-oss-distributions/xnu/tree/main/bsd/sys/_types
|
||||
pub(crate) mod _types {
|
||||
pub(crate) mod _ucontext;
|
||||
}
|
||||
|
||||
// Bit of a hack since the directories get merged and we can't have >1 sys module.
|
||||
pub(crate) use crate::new::apple::libpthread::sys::*;
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
//! Header: `sys/signal.h`
|
||||
//!
|
||||
//! <https://github.com/apple-oss-distributions/xnu/blob/main/bsd/sys/signal.h>
|
||||
|
||||
pub use crate::machine::_mcontext::*;
|
||||
pub use crate::sys::_types::_ucontext::*;
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
//! Header: `sys/sockio.h`
|
||||
//!
|
||||
//! <https://github.com/apple-oss-distributions/xnu/blob/main/bsd/sys/sockio.h>
|
||||
|
||||
use crate::prelude::*;
|
||||
use crate::sys::ioccom::*;
|
||||
|
||||
pub const SIOCSHIWAT: c_ulong = _IOW::<c_int>('s' as c_ulong, 0);
|
||||
pub const SIOCGHIWAT: c_ulong = _IOR::<c_int>('s' as c_ulong, 1);
|
||||
pub const SIOCSLOWAT: c_ulong = _IOW::<c_int>('s' as c_ulong, 2);
|
||||
pub const SIOCGLOWAT: c_ulong = _IOR::<c_int>('s' as c_ulong, 3);
|
||||
pub const SIOCATMARK: c_ulong = _IOR::<c_int>('s' as c_ulong, 7);
|
||||
pub const SIOCSPGRP: c_ulong = _IOW::<c_int>('s' as c_ulong, 8);
|
||||
pub const SIOCGPGRP: c_ulong = _IOR::<c_int>('s' as c_ulong, 9);
|
||||
|
||||
pub const SIOCSIFADDR: c_ulong = _IOW::<crate::ifreq>('i' as c_ulong, 12);
|
||||
pub const SIOCSIFDSTADDR: c_ulong = _IOW::<crate::ifreq>('i' as c_ulong, 14);
|
||||
pub const SIOCSIFFLAGS: c_ulong = _IOW::<crate::ifreq>('i' as c_ulong, 16);
|
||||
pub const SIOCGIFFLAGS: c_ulong = _IOWR::<crate::ifreq>('i' as c_ulong, 17);
|
||||
pub const SIOCSIFBRDADDR: c_ulong = _IOW::<crate::ifreq>('i' as c_ulong, 19);
|
||||
pub const SIOCSIFNETMASK: c_ulong = _IOW::<crate::ifreq>('i' as c_ulong, 22);
|
||||
pub const SIOCGIFMETRIC: c_ulong = _IOWR::<crate::ifreq>('i' as c_ulong, 23);
|
||||
pub const SIOCSIFMETRIC: c_ulong = _IOW::<crate::ifreq>('i' as c_ulong, 24);
|
||||
pub const SIOCDIFADDR: c_ulong = _IOW::<crate::ifreq>('i' as c_ulong, 25);
|
||||
// struct ifaliasreq
|
||||
pub const SIOCAIFADDR: c_ulong = _IOC(IOC_IN, 'i' as c_ulong, 26, 64);
|
||||
pub const SIOCGIFDSTADDR: c_ulong = _IOWR::<crate::ifreq>('i' as c_ulong, 34);
|
||||
pub const SIOCGIFBRDADDR: c_ulong = _IOWR::<crate::ifreq>('i' as c_ulong, 35);
|
||||
pub const SIOCGIFCONF: c_ulong = _IOWR::<crate::ifconf>('i' as c_ulong, 36);
|
||||
pub const SIOCGIFNETMASK: c_ulong = _IOWR::<crate::ifreq>('i' as c_ulong, 37);
|
||||
pub const SIOCAUTOADDR: c_ulong = _IOWR::<crate::ifreq>('i' as c_ulong, 38);
|
||||
pub const SIOCAUTONETMASK: c_ulong = _IOW::<crate::ifreq>('i' as c_ulong, 39);
|
||||
pub const SIOCARPIPLL: c_ulong = _IOWR::<crate::ifreq>('i' as c_ulong, 40);
|
||||
pub const SIOCADDMULTI: c_ulong = _IOW::<crate::ifreq>('i' as c_ulong, 49);
|
||||
pub const SIOCDELMULTI: c_ulong = _IOW::<crate::ifreq>('i' as c_ulong, 50);
|
||||
pub const SIOCGIFMTU: c_ulong = _IOWR::<crate::ifreq>('i' as c_ulong, 51);
|
||||
pub const SIOCSIFMTU: c_ulong = _IOW::<crate::ifreq>('i' as c_ulong, 52);
|
||||
pub const SIOCGIFPHYS: c_ulong = _IOWR::<crate::ifreq>('i' as c_ulong, 53);
|
||||
pub const SIOCSIFPHYS: c_ulong = _IOW::<crate::ifreq>('i' as c_ulong, 54);
|
||||
pub const SIOCSIFMEDIA: c_ulong = _IOWR::<crate::ifreq>('i' as c_ulong, 55);
|
||||
// struct ifmediareq
|
||||
pub const SIOCGIFMEDIA: c_ulong = _IOC(IOC_INOUT, 'i' as c_ulong, 56, 44);
|
||||
pub const SIOCSIFGENERIC: c_ulong = _IOW::<crate::ifreq>('i' as c_ulong, 57);
|
||||
pub const SIOCGIFGENERIC: c_ulong = _IOWR::<crate::ifreq>('i' as c_ulong, 58);
|
||||
// struct rslvmulti_req
|
||||
pub const SIOCRSLVMULTI: c_ulong = _IOC(IOC_INOUT, 'i' as c_ulong, 59, 16);
|
||||
pub const SIOCSIFLLADDR: c_ulong = _IOW::<crate::ifreq>('i' as c_ulong, 60);
|
||||
// struct ifstat
|
||||
pub const SIOCGIFSTATUS: c_ulong = _IOC(IOC_INOUT, 'i' as c_ulong, 61, 817);
|
||||
// struct ifaliasreq
|
||||
pub const SIOCSIFPHYADDR: c_ulong = _IOC(IOC_IN, 'i' as c_ulong, 62, 64);
|
||||
pub const SIOCGIFPSRCADDR: c_ulong = _IOWR::<crate::ifreq>('i' as c_ulong, 63);
|
||||
pub const SIOCGIFPDSTADDR: c_ulong = _IOWR::<crate::ifreq>('i' as c_ulong, 64);
|
||||
pub const SIOCDIFPHYADDR: c_ulong = _IOW::<crate::ifreq>('i' as c_ulong, 65);
|
||||
pub const SIOCGIFDEVMTU: c_ulong = _IOWR::<crate::ifreq>('i' as c_ulong, 68);
|
||||
pub const SIOCSIFALTMTU: c_ulong = _IOW::<crate::ifreq>('i' as c_ulong, 69);
|
||||
pub const SIOCGIFALTMTU: c_ulong = _IOWR::<crate::ifreq>('i' as c_ulong, 72);
|
||||
pub const SIOCSIFBOND: c_ulong = _IOW::<crate::ifreq>('i' as c_ulong, 70);
|
||||
pub const SIOCGIFBOND: c_ulong = _IOWR::<crate::ifreq>('i' as c_ulong, 71);
|
||||
// struct ifmediareq
|
||||
pub const SIOCGIFXMEDIA: c_ulong = _IOC(IOC_INOUT, 'i' as c_ulong, 72, 44);
|
||||
pub const SIOCSIFCAP: c_ulong = _IOW::<crate::ifreq>('i' as c_ulong, 90);
|
||||
pub const SIOCGIFCAP: c_ulong = _IOWR::<crate::ifreq>('i' as c_ulong, 91);
|
||||
pub const SIOCSIFMANAGEMENT: c_ulong = _IOWR::<crate::ifreq>('i' as c_ulong, 92);
|
||||
pub const SIOCIFCREATE: c_ulong = _IOWR::<crate::ifreq>('i' as c_ulong, 120);
|
||||
pub const SIOCIFDESTROY: c_ulong = _IOW::<crate::ifreq>('i' as c_ulong, 121);
|
||||
pub const SIOCIFCREATE2: c_ulong = _IOWR::<crate::ifreq>('i' as c_ulong, 122);
|
||||
// struct ifdrv
|
||||
pub const SIOCSDRVSPEC: c_ulong = _IOC(IOC_IN, 'i' as c_ulong, 123, 40);
|
||||
// struct ifdrv
|
||||
pub const SIOCGDRVSPEC: c_ulong = _IOC(IOC_INOUT, 'i' as c_ulong, 123, 40);
|
||||
pub const SIOCSIFVLAN: c_ulong = _IOW::<crate::ifreq>('i' as c_ulong, 126);
|
||||
pub const SIOCGIFVLAN: c_ulong = _IOWR::<crate::ifreq>('i' as c_ulong, 127);
|
||||
pub const SIOCSETVLAN: c_ulong = SIOCSIFVLAN;
|
||||
pub const SIOCGETVLAN: c_ulong = SIOCGIFVLAN;
|
||||
// struct if_clonereq
|
||||
pub const SIOCIFGCLONERS: c_ulong = _IOC(IOC_INOUT, 'i' as c_ulong, 129, 16);
|
||||
pub const SIOCGIFASYNCMAP: c_ulong = _IOWR::<crate::ifreq>('i' as c_ulong, 124);
|
||||
pub const SIOCSIFASYNCMAP: c_ulong = _IOW::<crate::ifreq>('i' as c_ulong, 125);
|
||||
pub const SIOCGIFMAC: c_ulong = _IOWR::<crate::ifreq>('i' as c_ulong, 130);
|
||||
pub const SIOCSIFMAC: c_ulong = _IOW::<crate::ifreq>('i' as c_ulong, 131);
|
||||
pub const SIOCSIFKPI: c_ulong = _IOW::<crate::ifreq>('i' as c_ulong, 134);
|
||||
pub const SIOCGIFKPI: c_ulong = _IOWR::<crate::ifreq>('i' as c_ulong, 135);
|
||||
pub const SIOCGIFWAKEFLAGS: c_ulong = _IOWR::<crate::ifreq>('i' as c_ulong, 136);
|
||||
pub const SIOCGIFFUNCTIONALTYPE: c_ulong = _IOWR::<crate::ifreq>('i' as c_ulong, 173);
|
||||
pub const SIOCSIF6LOWPAN: c_ulong = _IOW::<crate::ifreq>('i' as c_ulong, 196);
|
||||
pub const SIOCGIF6LOWPAN: c_ulong = _IOWR::<crate::ifreq>('i' as c_ulong, 197);
|
||||
pub const SIOCGIFDIRECTLINK: c_ulong = _IOWR::<crate::ifreq>('i' as c_ulong, 222);
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
//! Header: `sys/ttycom.h`
|
||||
//!
|
||||
//! <https://github.com/apple-oss-distributions/xnu/blob/main/bsd/sys/ttycom.h>
|
||||
|
||||
use crate::prelude::*;
|
||||
use crate::sys::ioccom::*;
|
||||
|
||||
/* FIXME(1.0): a number of ioctl numbers are `c_int` or `c_uint` and should be changed to
|
||||
* `c_ulong` to match the others. */
|
||||
|
||||
pub const TIOCMODG: c_ulong = _IOR::<c_int>('t' as c_ulong, 3);
|
||||
pub const TIOCMODS: c_ulong = _IOW::<c_int>('t' as c_ulong, 4);
|
||||
|
||||
pub const TIOCM_LE: c_int = 0o0001;
|
||||
pub const TIOCM_DTR: c_int = 0o0002;
|
||||
pub const TIOCM_RTS: c_int = 0o0004;
|
||||
pub const TIOCM_ST: c_int = 0o0010;
|
||||
pub const TIOCM_SR: c_int = 0o0020;
|
||||
pub const TIOCM_CTS: c_int = 0o0040;
|
||||
pub const TIOCM_CAR: c_int = 0o0100;
|
||||
pub const TIOCM_CD: c_int = TIOCM_CAR;
|
||||
pub const TIOCM_RNG: c_int = 0o0200;
|
||||
pub const TIOCM_RI: c_int = TIOCM_RNG;
|
||||
pub const TIOCM_DSR: c_int = 0o0400;
|
||||
|
||||
pub const TIOCEXCL: c_int = ulong_cast_int(_IO('t' as c_ulong, 13));
|
||||
pub const TIOCNXCL: c_int = ulong_cast_int(_IO('t' as c_ulong, 14));
|
||||
|
||||
pub const TIOCFLUSH: c_ulong = _IOW::<c_int>('t' as c_ulong, 16);
|
||||
|
||||
pub const TIOCGETA: c_ulong = _IOR::<crate::termios>('t' as c_ulong, 19);
|
||||
pub const TIOCSETA: c_ulong = _IOW::<crate::termios>('t' as c_ulong, 20);
|
||||
pub const TIOCSETAW: c_ulong = _IOW::<crate::termios>('t' as c_ulong, 21);
|
||||
pub const TIOCSETAF: c_ulong = _IOW::<crate::termios>('t' as c_ulong, 22);
|
||||
|
||||
pub const TIOCGETD: c_ulong = _IOR::<c_int>('t' as c_ulong, 26);
|
||||
pub const TIOCSETD: c_ulong = _IOW::<c_int>('t' as c_ulong, 27);
|
||||
|
||||
pub const TIOCIXON: c_int = ulong_cast_int(_IO('t' as c_ulong, 129));
|
||||
pub const TIOCIXOFF: c_int = ulong_cast_int(_IO('t' as c_ulong, 128));
|
||||
|
||||
pub const TIOCSBRK: c_int = ulong_cast_int(_IO('t' as c_ulong, 123));
|
||||
pub const TIOCCBRK: c_int = ulong_cast_int(_IO('t' as c_ulong, 122));
|
||||
pub const TIOCSDTR: c_int = ulong_cast_int(_IO('t' as c_ulong, 121));
|
||||
pub const TIOCCDTR: c_int = ulong_cast_int(_IO('t' as c_ulong, 120));
|
||||
pub const TIOCGPGRP: c_ulong = _IOR::<c_int>('t' as c_ulong, 119);
|
||||
pub const TIOCSPGRP: c_ulong = _IOW::<c_int>('t' as c_ulong, 118);
|
||||
|
||||
pub const TIOCOUTQ: c_ulong = _IOR::<c_int>('t' as c_ulong, 115);
|
||||
pub const TIOCSTI: c_ulong = _IOW::<c_char>('t' as c_ulong, 114);
|
||||
pub const TIOCNOTTY: c_ulong = _IO('t' as c_ulong, 113);
|
||||
pub const TIOCPKT: c_ulong = _IOW::<c_int>('t' as c_ulong, 112);
|
||||
|
||||
pub const TIOCPKT_DATA: c_int = 0x00;
|
||||
pub const TIOCPKT_FLUSHREAD: c_int = 0x01;
|
||||
pub const TIOCPKT_FLUSHWRITE: c_int = 0x02;
|
||||
pub const TIOCPKT_STOP: c_int = 0x04;
|
||||
pub const TIOCPKT_START: c_int = 0x08;
|
||||
pub const TIOCPKT_NOSTOP: c_int = 0x10;
|
||||
pub const TIOCPKT_DOSTOP: c_int = 0x20;
|
||||
pub const TIOCPKT_IOCTL: c_int = 0x40;
|
||||
|
||||
pub const TIOCSTOP: c_uint = ulong_cast_uint(_IO('t' as c_ulong, 111));
|
||||
pub const TIOCSTART: c_uint = ulong_cast_uint(_IO('t' as c_ulong, 110));
|
||||
pub const TIOCMSET: c_ulong = _IOW::<c_int>('t' as c_ulong, 109);
|
||||
pub const TIOCMBIS: c_ulong = _IOW::<c_int>('t' as c_ulong, 108);
|
||||
pub const TIOCMBIC: c_ulong = _IOW::<c_int>('t' as c_ulong, 107);
|
||||
pub const TIOCMGET: c_ulong = _IOR::<c_int>('t' as c_ulong, 106);
|
||||
|
||||
#[deprecated(since = "0.2.178", note = "Removed in MacOSX 12.0.1")]
|
||||
pub const TIOCREMOTE: c_ulong = 0x80047469;
|
||||
|
||||
pub const TIOCGWINSZ: c_ulong = _IOR::<crate::winsize>('t' as c_ulong, 104);
|
||||
pub const TIOCSWINSZ: c_ulong = _IOW::<crate::winsize>('t' as c_ulong, 103);
|
||||
pub const TIOCUCNTL: c_ulong = _IOW::<c_int>('t' as c_ulong, 102);
|
||||
pub const TIOCSTAT: c_uint = ulong_cast_uint(_IO('t' as c_ulong, 101));
|
||||
|
||||
pub const TIOCSCONS: c_uint = ulong_cast_uint(_IO('t' as c_ulong, 99));
|
||||
pub const TIOCCONS: c_ulong = _IOW::<c_int>('t' as c_ulong, 98);
|
||||
pub const TIOCSCTTY: c_uint = ulong_cast_uint(_IO('t' as c_ulong, 97));
|
||||
pub const TIOCEXT: c_ulong = _IOW::<c_int>('t' as c_ulong, 96);
|
||||
pub const TIOCSIG: c_uint = ulong_cast_uint(_IO('t' as c_ulong, 95));
|
||||
pub const TIOCDRAIN: c_uint = ulong_cast_uint(_IO('t' as c_ulong, 94));
|
||||
pub const TIOCMSDTRWAIT: c_ulong = _IOW::<c_int>('t' as c_ulong, 91);
|
||||
pub const TIOCMGDTRWAIT: c_ulong = _IOR::<c_int>('t' as c_ulong, 90);
|
||||
pub const TIOCTIMESTAMP: c_ulong = _IOR::<crate::timeval>('t' as c_ulong, 89);
|
||||
pub const TIOCDCDTIMESTAMP: c_ulong = _IOR::<crate::timeval>('t' as c_ulong, 88);
|
||||
pub const TIOCSDRAINWAIT: c_ulong = _IOW::<c_int>('t' as c_ulong, 87);
|
||||
pub const TIOCGDRAINWAIT: c_ulong = _IOR::<c_int>('t' as c_ulong, 86);
|
||||
pub const TIOCDSIMICROCODE: c_uint = ulong_cast_uint(_IO('t' as c_ulong, 85));
|
||||
pub const TIOCPTYGRANT: c_uint = ulong_cast_uint(_IO('t' as c_ulong, 84));
|
||||
pub const TIOCPTYGNAME: c_uint = ulong_cast_uint(_IOC(IOC_OUT, 't' as c_ulong, 83, 128));
|
||||
pub const TIOCPTYUNLK: c_uint = ulong_cast_uint(_IO('t' as c_ulong, 82));
|
||||
@@ -0,0 +1,5 @@
|
||||
//! Directory: `bionic/libc/kernel/uapi/linux/`
|
||||
//!
|
||||
//! <https://cs.android.com/android/platform/superproject/main/+/main:bionic/libc/kernel/uapi/linux/>
|
||||
|
||||
pub(crate) mod types;
|
||||
@@ -0,0 +1,21 @@
|
||||
//! * Header: `bionic/libc/kernel/uapi/linux/types.h`
|
||||
//! * Header: `bionic/libc/kernel/uapi/asm-generic/int-ll64.h`
|
||||
|
||||
use crate::prelude::*;
|
||||
|
||||
/* Definitions from `asm/types.h` -> `asm-generic/types.h` -> `asm-generic/int-ll64.h` */
|
||||
|
||||
pub type __u8 = c_uchar;
|
||||
|
||||
pub type __u16 = c_ushort;
|
||||
pub type __s16 = c_short;
|
||||
|
||||
pub type __u32 = c_uint;
|
||||
pub type __s32 = c_int;
|
||||
|
||||
pub type __s64 = c_longlong;
|
||||
pub type __u64 = c_ulonglong;
|
||||
|
||||
/* From `uapi/linux/types.h` */
|
||||
|
||||
pub type __be16 = __u16;
|
||||
@@ -0,0 +1,3 @@
|
||||
//! Directory: `bionic/libc/kernel/uapi`
|
||||
|
||||
pub(crate) mod linux;
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
//! This directory maps to `bionic/libc/include` in the Android source. `bionic/libc/kernel` is
|
||||
//! the source of UAPI definitions, which are a cleaned form of the default Linux headers.
|
||||
//!
|
||||
//! <https://cs.android.com/android/platform/superproject/main/+/main:bionic/libc/include/>,
|
||||
//! <https://cs.android.com/android/platform/superproject/main/+/main:bionic/libc/kernel/uapi/>
|
||||
|
||||
pub(crate) mod kernel_uapi;
|
||||
pub(crate) mod pthread;
|
||||
pub(crate) mod sys;
|
||||
pub(crate) mod unistd;
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
//! Header: `unistd.h`
|
||||
|
||||
pub use crate::new::common::linux_like::pthread::{
|
||||
pthread_getattr_np,
|
||||
pthread_setname_np,
|
||||
};
|
||||
pub use crate::new::common::posix::pthread::{
|
||||
pthread_atfork,
|
||||
pthread_attr_getguardsize,
|
||||
pthread_attr_getinheritsched,
|
||||
pthread_attr_getstack,
|
||||
pthread_attr_setguardsize,
|
||||
pthread_attr_setinheritsched,
|
||||
pthread_attr_setstack,
|
||||
pthread_barrier_destroy,
|
||||
pthread_barrier_init,
|
||||
pthread_barrier_wait,
|
||||
pthread_barrierattr_destroy,
|
||||
pthread_barrierattr_getpshared,
|
||||
pthread_barrierattr_init,
|
||||
pthread_barrierattr_setpshared,
|
||||
pthread_condattr_getclock,
|
||||
pthread_condattr_getpshared,
|
||||
pthread_condattr_setclock,
|
||||
pthread_condattr_setpshared,
|
||||
pthread_create,
|
||||
pthread_getcpuclockid,
|
||||
pthread_getschedparam,
|
||||
pthread_kill,
|
||||
pthread_mutex_timedlock,
|
||||
pthread_mutexattr_getpshared,
|
||||
pthread_mutexattr_setpshared,
|
||||
pthread_rwlockattr_getpshared,
|
||||
pthread_rwlockattr_setpshared,
|
||||
pthread_setschedparam,
|
||||
pthread_sigmask,
|
||||
pthread_spin_destroy,
|
||||
pthread_spin_init,
|
||||
pthread_spin_lock,
|
||||
pthread_spin_trylock,
|
||||
pthread_spin_unlock,
|
||||
};
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
//! Directory: `sys/`
|
||||
|
||||
pub(crate) mod socket;
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
//! Header: `sys/socket.h`
|
||||
|
||||
use crate::prelude::*;
|
||||
|
||||
s! {
|
||||
pub struct msghdr {
|
||||
pub msg_name: *mut c_void,
|
||||
pub msg_namelen: crate::socklen_t,
|
||||
pub msg_iov: *mut crate::iovec,
|
||||
pub msg_iovlen: size_t,
|
||||
pub msg_control: *mut c_void,
|
||||
pub msg_controllen: size_t,
|
||||
pub msg_flags: c_int,
|
||||
}
|
||||
|
||||
pub struct cmsghdr {
|
||||
pub cmsg_len: size_t,
|
||||
pub cmsg_level: c_int,
|
||||
pub cmsg_type: c_int,
|
||||
}
|
||||
|
||||
pub struct ucred {
|
||||
pub pid: crate::pid_t,
|
||||
pub uid: crate::uid_t,
|
||||
pub gid: crate::gid_t,
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
pub fn recvmmsg(
|
||||
sockfd: c_int,
|
||||
msgvec: *mut crate::mmsghdr,
|
||||
vlen: c_uint,
|
||||
flags: c_int,
|
||||
timeout: *const crate::timespec,
|
||||
) -> c_int;
|
||||
pub fn sendmmsg(
|
||||
sockfd: c_int,
|
||||
msgvec: *const crate::mmsghdr,
|
||||
vlen: c_uint,
|
||||
flags: c_int,
|
||||
) -> c_int;
|
||||
pub fn recvfrom(
|
||||
socket: c_int,
|
||||
buf: *mut c_void,
|
||||
len: size_t,
|
||||
flags: c_int,
|
||||
addr: *mut crate::sockaddr,
|
||||
addrlen: *mut crate::socklen_t,
|
||||
) -> ssize_t;
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
//! Header: `unistd.h`
|
||||
|
||||
pub use crate::new::common::posix::unistd::{
|
||||
STDERR_FILENO,
|
||||
STDIN_FILENO,
|
||||
STDOUT_FILENO,
|
||||
};
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
//! Interfaces common across the BSD family.
|
||||
+1
@@ -0,0 +1 @@
|
||||
//! Interfaces common in FreeBSD-derived operating systems. This includes FreeBSD and DragonFlyBSD.
|
||||
@@ -0,0 +1,9 @@
|
||||
//! API that primarily comes from Linux but is also used other platforms (e.g. Android).
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "emscripten",
|
||||
target_os = "l4re",
|
||||
target_os = "linux"
|
||||
))]
|
||||
pub(crate) mod pthread;
|
||||
@@ -0,0 +1,25 @@
|
||||
use crate::prelude::*;
|
||||
|
||||
extern "C" {
|
||||
#[cfg(any(target_os = "linux", target_os = "l4re"))]
|
||||
pub fn pthread_getaffinity_np(
|
||||
thread: crate::pthread_t,
|
||||
cpusetsize: size_t,
|
||||
cpuset: *mut crate::cpu_set_t,
|
||||
) -> c_int;
|
||||
|
||||
pub fn pthread_getattr_np(native: crate::pthread_t, attr: *mut crate::pthread_attr_t) -> c_int;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub fn pthread_getname_np(thread: crate::pthread_t, name: *mut c_char, len: size_t) -> c_int;
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "l4re"))]
|
||||
pub fn pthread_setaffinity_np(
|
||||
thread: crate::pthread_t,
|
||||
cpusetsize: size_t,
|
||||
cpuset: *const crate::cpu_set_t,
|
||||
) -> c_int;
|
||||
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
pub fn pthread_setname_np(thread: crate::pthread_t, name: *const c_char) -> c_int;
|
||||
}
|
||||
Vendored
+39
@@ -0,0 +1,39 @@
|
||||
//! Interfaces that are common across multiple platforms
|
||||
//!
|
||||
//! We make these available everywhere but each platform must opt in to reexporting.
|
||||
//!
|
||||
//! There shouldn't be any repeated definitions or complex configuration in this module. On
|
||||
//! platforms that don't use common APIs it is fine to use `#[cfg(not(...))]`, but if a platform
|
||||
//! needs a custom definition then it should be defined in the platform-specific module.
|
||||
//!
|
||||
//! The goal is that platforms need to opt in to the definitions here, so that worst case we have
|
||||
//! an unused warning on untested platforms (rather than exposing incorrect API).
|
||||
|
||||
#[cfg(any(
|
||||
target_vendor = "apple",
|
||||
target_os = "dragonfly",
|
||||
target_os = "freebsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd",
|
||||
))]
|
||||
pub(crate) mod bsd;
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "emscripten",
|
||||
target_os = "l4re",
|
||||
target_os = "linux",
|
||||
))]
|
||||
pub(crate) mod linux_like;
|
||||
|
||||
#[cfg(any(target_os = "dragonfly", target_os = "freebsd"))]
|
||||
pub(crate) mod freebsd_like;
|
||||
|
||||
#[cfg(any(target_os = "netbsd", target_os = "openbsd"))]
|
||||
pub(crate) mod netbsd_like;
|
||||
|
||||
#[cfg(any(target_os = "illumos", target_os = "solaris"))]
|
||||
pub(crate) mod solarish;
|
||||
|
||||
#[cfg(target_family = "unix")]
|
||||
pub(crate) mod posix;
|
||||
+1
@@ -0,0 +1 @@
|
||||
//! Interfaces common in NetBSD-derived operating systems. This includes NetBSD and OpenBSD.
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
//! POSIX APIs that are used by a number of platforms
|
||||
//!
|
||||
//! These can be found at: <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/contents.html>.
|
||||
|
||||
// FIXME(pthread): eventually all platforms should use this module
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "emscripten",
|
||||
target_os = "l4re",
|
||||
target_os = "linux",
|
||||
target_os = "qurt",
|
||||
target_vendor = "apple",
|
||||
))]
|
||||
pub(crate) mod pthread;
|
||||
pub(crate) mod unistd;
|
||||
+332
@@ -0,0 +1,332 @@
|
||||
//! Header: `pthread.h`
|
||||
//!
|
||||
//! <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/pthread.h.html>
|
||||
|
||||
use crate::prelude::*;
|
||||
|
||||
extern "C" {
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
pub fn pthread_atfork(
|
||||
prepare: Option<unsafe extern "C" fn()>,
|
||||
parent: Option<unsafe extern "C" fn()>,
|
||||
child: Option<unsafe extern "C" fn()>,
|
||||
) -> c_int;
|
||||
|
||||
#[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))]
|
||||
pub fn pthread_attr_getguardsize(
|
||||
attr: *const crate::pthread_attr_t,
|
||||
guardsize: *mut size_t,
|
||||
) -> c_int;
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "l4re",
|
||||
target_os = "linux",
|
||||
target_vendor = "apple",
|
||||
))]
|
||||
pub fn pthread_attr_getinheritsched(
|
||||
attr: *const crate::pthread_attr_t,
|
||||
inheritsched: *mut c_int,
|
||||
) -> c_int;
|
||||
|
||||
#[cfg(any(target_os = "l4re", target_os = "linux", target_vendor = "apple"))]
|
||||
pub fn pthread_attr_getschedparam(
|
||||
attr: *const crate::pthread_attr_t,
|
||||
param: *mut crate::sched_param,
|
||||
) -> c_int;
|
||||
|
||||
#[cfg(any(target_os = "l4re", target_os = "linux", target_vendor = "apple"))]
|
||||
pub fn pthread_attr_getschedpolicy(
|
||||
attr: *const crate::pthread_attr_t,
|
||||
policy: *mut c_int,
|
||||
) -> c_int;
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "emscripten",
|
||||
target_os = "linux",
|
||||
target_os = "l4re"
|
||||
))]
|
||||
pub fn pthread_attr_getstack(
|
||||
attr: *const crate::pthread_attr_t,
|
||||
stackaddr: *mut *mut c_void,
|
||||
stacksize: *mut size_t,
|
||||
) -> c_int;
|
||||
|
||||
#[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))]
|
||||
pub fn pthread_attr_setguardsize(attr: *mut crate::pthread_attr_t, guardsize: size_t) -> c_int;
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "l4re",
|
||||
target_os = "linux",
|
||||
target_vendor = "apple"
|
||||
))]
|
||||
pub fn pthread_attr_setinheritsched(
|
||||
attr: *mut crate::pthread_attr_t,
|
||||
inheritsched: c_int,
|
||||
) -> c_int;
|
||||
|
||||
#[cfg(any(target_os = "l4re", target_os = "linux", target_vendor = "apple"))]
|
||||
pub fn pthread_attr_setschedparam(
|
||||
attr: *mut crate::pthread_attr_t,
|
||||
param: *const crate::sched_param,
|
||||
) -> c_int;
|
||||
|
||||
#[cfg(any(target_os = "l4re", target_os = "linux", target_vendor = "apple"))]
|
||||
pub fn pthread_attr_setschedpolicy(attr: *mut crate::pthread_attr_t, policy: c_int) -> c_int;
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "emscripten",
|
||||
target_os = "linux",
|
||||
target_os = "l4re"
|
||||
))]
|
||||
pub fn pthread_attr_setstack(
|
||||
attr: *mut crate::pthread_attr_t,
|
||||
stackaddr: *mut c_void,
|
||||
stacksize: size_t,
|
||||
) -> c_int;
|
||||
|
||||
#[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))]
|
||||
pub fn pthread_barrier_destroy(barrier: *mut crate::pthread_barrier_t) -> c_int;
|
||||
|
||||
#[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))]
|
||||
pub fn pthread_barrier_init(
|
||||
barrier: *mut crate::pthread_barrier_t,
|
||||
attr: *const crate::pthread_barrierattr_t,
|
||||
count: c_uint,
|
||||
) -> c_int;
|
||||
|
||||
#[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))]
|
||||
pub fn pthread_barrier_wait(barrier: *mut crate::pthread_barrier_t) -> c_int;
|
||||
|
||||
#[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))]
|
||||
pub fn pthread_barrierattr_destroy(attr: *mut crate::pthread_barrierattr_t) -> c_int;
|
||||
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
pub fn pthread_barrierattr_getpshared(
|
||||
attr: *const crate::pthread_barrierattr_t,
|
||||
shared: *mut c_int,
|
||||
) -> c_int;
|
||||
|
||||
#[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))]
|
||||
pub fn pthread_barrierattr_init(attr: *mut crate::pthread_barrierattr_t) -> c_int;
|
||||
|
||||
#[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))]
|
||||
pub fn pthread_barrierattr_setpshared(
|
||||
attr: *mut crate::pthread_barrierattr_t,
|
||||
shared: c_int,
|
||||
) -> c_int;
|
||||
|
||||
#[cfg(any(target_os = "l4re", all(target_os = "linux", not(target_env = "ohos"))))]
|
||||
pub fn pthread_cancel(thread: crate::pthread_t) -> c_int;
|
||||
|
||||
#[cfg(any(target_os = "android", target_os = "emscripten", target_os = "linux",))]
|
||||
pub fn pthread_condattr_getclock(
|
||||
attr: *const crate::pthread_condattr_t,
|
||||
clock_id: *mut crate::clockid_t,
|
||||
) -> c_int;
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "l4re",
|
||||
target_os = "linux",
|
||||
target_vendor = "apple",
|
||||
))]
|
||||
pub fn pthread_condattr_getpshared(
|
||||
attr: *const crate::pthread_condattr_t,
|
||||
pshared: *mut c_int,
|
||||
) -> c_int;
|
||||
|
||||
#[cfg(any(target_os = "android", target_os = "emscripten", target_os = "linux",))]
|
||||
pub fn pthread_condattr_setclock(
|
||||
attr: *mut crate::pthread_condattr_t,
|
||||
clock_id: crate::clockid_t,
|
||||
) -> c_int;
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "emscripten",
|
||||
target_os = "linux",
|
||||
target_os = "l4re",
|
||||
target_vendor = "apple",
|
||||
))]
|
||||
pub fn pthread_condattr_setpshared(
|
||||
attr: *mut crate::pthread_condattr_t,
|
||||
pshared: c_int,
|
||||
) -> c_int;
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "emscripten",
|
||||
target_os = "l4re",
|
||||
target_os = "linux",
|
||||
))]
|
||||
pub fn pthread_create(
|
||||
native: *mut crate::pthread_t,
|
||||
attr: *const crate::pthread_attr_t,
|
||||
f: extern "C" fn(*mut c_void) -> *mut c_void,
|
||||
value: *mut c_void,
|
||||
) -> c_int;
|
||||
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
pub fn pthread_getcpuclockid(thread: crate::pthread_t, clk_id: *mut crate::clockid_t) -> c_int;
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "l4re",
|
||||
target_os = "linux",
|
||||
target_vendor = "apple",
|
||||
))]
|
||||
pub fn pthread_getschedparam(
|
||||
native: crate::pthread_t,
|
||||
policy: *mut c_int,
|
||||
param: *mut crate::sched_param,
|
||||
) -> c_int;
|
||||
|
||||
// FIXME(reorg): In recent POSIX versions, this is a signal.h function and not required
|
||||
// in pthread.
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "emscripten",
|
||||
target_os = "l4re",
|
||||
target_os = "linux"
|
||||
))]
|
||||
pub fn pthread_kill(thread: crate::pthread_t, sig: c_int) -> c_int;
|
||||
|
||||
#[cfg(all(target_os = "linux", not(target_env = "ohos")))]
|
||||
pub fn pthread_mutex_consistent(mutex: *mut crate::pthread_mutex_t) -> c_int;
|
||||
|
||||
#[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))]
|
||||
#[cfg_attr(gnu_time_bits64, link_name = "__pthread_mutex_timedlock64")]
|
||||
#[cfg_attr(musl_redir_time64, link_name = "__pthread_mutex_timedlock_time64")]
|
||||
pub fn pthread_mutex_timedlock(
|
||||
lock: *mut crate::pthread_mutex_t,
|
||||
abstime: *const crate::timespec,
|
||||
) -> c_int;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub fn pthread_mutexattr_getprotocol(
|
||||
attr: *const crate::pthread_mutexattr_t,
|
||||
protocol: *mut c_int,
|
||||
) -> c_int;
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "l4re",
|
||||
target_os = "linux",
|
||||
target_vendor = "apple",
|
||||
))]
|
||||
pub fn pthread_mutexattr_getpshared(
|
||||
attr: *const crate::pthread_mutexattr_t,
|
||||
pshared: *mut c_int,
|
||||
) -> c_int;
|
||||
|
||||
#[cfg(all(target_os = "linux", not(target_env = "ohos")))]
|
||||
pub fn pthread_mutexattr_getrobust(
|
||||
attr: *const crate::pthread_mutexattr_t,
|
||||
robustness: *mut c_int,
|
||||
) -> c_int;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub fn pthread_mutexattr_setprotocol(
|
||||
attr: *mut crate::pthread_mutexattr_t,
|
||||
protocol: c_int,
|
||||
) -> c_int;
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "emscripten",
|
||||
target_os = "linux",
|
||||
target_os = "l4re",
|
||||
target_vendor = "apple",
|
||||
))]
|
||||
pub fn pthread_mutexattr_setpshared(
|
||||
attr: *mut crate::pthread_mutexattr_t,
|
||||
pshared: c_int,
|
||||
) -> c_int;
|
||||
|
||||
#[cfg(all(target_os = "linux", not(target_env = "ohos")))]
|
||||
pub fn pthread_mutexattr_setrobust(
|
||||
attr: *mut crate::pthread_mutexattr_t,
|
||||
robustness: c_int,
|
||||
) -> c_int;
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "emscripten",
|
||||
target_os = "linux",
|
||||
target_os = "l4re",
|
||||
target_vendor = "apple",
|
||||
))]
|
||||
pub fn pthread_rwlockattr_getpshared(
|
||||
attr: *const crate::pthread_rwlockattr_t,
|
||||
val: *mut c_int,
|
||||
) -> c_int;
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "emscripten",
|
||||
target_os = "linux",
|
||||
target_os = "l4re",
|
||||
target_vendor = "apple",
|
||||
))]
|
||||
pub fn pthread_rwlockattr_setpshared(
|
||||
attr: *mut crate::pthread_rwlockattr_t,
|
||||
val: c_int,
|
||||
) -> c_int;
|
||||
|
||||
// FIXME(1.0): These shoul be combined to the version that takes an optional unsafe function.
|
||||
#[cfg(any(target_os = "l4re", target_os = "linux"))]
|
||||
pub fn pthread_once(control: *mut crate::pthread_once_t, routine: extern "C" fn()) -> c_int;
|
||||
#[cfg(target_vendor = "apple")]
|
||||
pub fn pthread_once(
|
||||
once_control: *mut crate::pthread_once_t,
|
||||
init_routine: Option<unsafe extern "C" fn()>,
|
||||
) -> c_int;
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "l4re",
|
||||
target_os = "linux",
|
||||
target_vendor = "apple",
|
||||
))]
|
||||
pub fn pthread_setschedparam(
|
||||
native: crate::pthread_t,
|
||||
policy: c_int,
|
||||
param: *const crate::sched_param,
|
||||
) -> c_int;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub fn pthread_setschedprio(native: crate::pthread_t, priority: c_int) -> c_int;
|
||||
|
||||
// FIXME(reorg): In recent POSIX versions, this is a signal.h function and not required
|
||||
// in pthread.
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "emscripten",
|
||||
target_os = "l4re",
|
||||
target_os = "linux"
|
||||
))]
|
||||
pub fn pthread_sigmask(
|
||||
how: c_int,
|
||||
set: *const crate::sigset_t,
|
||||
oldset: *mut crate::sigset_t,
|
||||
) -> c_int;
|
||||
|
||||
#[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))]
|
||||
pub fn pthread_spin_destroy(lock: *mut crate::pthread_spinlock_t) -> c_int;
|
||||
|
||||
#[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))]
|
||||
pub fn pthread_spin_init(lock: *mut crate::pthread_spinlock_t, pshared: c_int) -> c_int;
|
||||
|
||||
#[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))]
|
||||
pub fn pthread_spin_lock(lock: *mut crate::pthread_spinlock_t) -> c_int;
|
||||
|
||||
#[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))]
|
||||
pub fn pthread_spin_trylock(lock: *mut crate::pthread_spinlock_t) -> c_int;
|
||||
|
||||
#[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))]
|
||||
pub fn pthread_spin_unlock(lock: *mut crate::pthread_spinlock_t) -> c_int;
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
//! Header: `unistd.h`
|
||||
//!
|
||||
//! <https://pubs.opengroup.org/onlinepubs/007904975/basedefs/unistd.h.html>
|
||||
|
||||
use crate::prelude::*;
|
||||
|
||||
pub const STDIN_FILENO: c_int = 0;
|
||||
pub const STDOUT_FILENO: c_int = 1;
|
||||
pub const STDERR_FILENO: c_int = 2;
|
||||
+1
@@ -0,0 +1 @@
|
||||
//! Interfaces common in solaris-derived operating systems. This includes Solaris and Illumos.
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
//! Cygwin libc.
|
||||
//!
|
||||
//! * Headers: <https://github.com/cygwin/cygwin/tree/main/winsup/cygwin/include>
|
||||
|
||||
pub(crate) mod unistd;
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
//! Header: `unistd.h`
|
||||
|
||||
pub use crate::new::common::posix::unistd::{
|
||||
STDERR_FILENO,
|
||||
STDIN_FILENO,
|
||||
STDOUT_FILENO,
|
||||
};
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
//! DragonFly BSD libc.
|
||||
//!
|
||||
//! * Headers: <https://github.com/DragonFlyBSD/DragonFlyBSD>
|
||||
//! * Manual pages: <https://leaf.dragonflybsd.org/cgi/web-man>
|
||||
|
||||
pub(crate) mod unistd;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
//! Header: `unistd.h`
|
||||
|
||||
pub use crate::new::common::posix::unistd::{
|
||||
STDERR_FILENO,
|
||||
STDIN_FILENO,
|
||||
STDOUT_FILENO,
|
||||
};
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
//! Emscripten libc.
|
||||
//!
|
||||
//! * Headers: <https://github.com/emscripten-core/emscripten/tree/main/system/lib/libc>
|
||||
|
||||
pub(crate) mod pthread;
|
||||
pub(crate) mod sched;
|
||||
pub(crate) mod unistd;
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
//! Header: `pthread.h`
|
||||
|
||||
pub use crate::new::common::linux_like::pthread::pthread_getattr_np;
|
||||
pub use crate::new::common::posix::pthread::{
|
||||
pthread_attr_getstack,
|
||||
pthread_attr_setstack,
|
||||
pthread_condattr_getclock,
|
||||
pthread_condattr_setclock,
|
||||
pthread_condattr_setpshared,
|
||||
pthread_create,
|
||||
pthread_kill,
|
||||
pthread_mutexattr_setpshared,
|
||||
pthread_rwlockattr_getpshared,
|
||||
pthread_rwlockattr_setpshared,
|
||||
pthread_sigmask,
|
||||
};
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
use crate::prelude::*;
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(musl_v1_2_3)] {
|
||||
s! {
|
||||
struct __c_anon_sched_param__reserved2 {
|
||||
__reserved1: crate::time_t,
|
||||
__reserved2: c_long,
|
||||
}
|
||||
|
||||
pub struct sched_param {
|
||||
pub sched_priority: c_int,
|
||||
|
||||
__reserved1: Padding<c_int>,
|
||||
#[cfg(musl32_time64)]
|
||||
__reserved2: Padding<[c_long; 4]>,
|
||||
#[cfg(not(musl32_time64))]
|
||||
__reserved2: Padding<[__c_anon_sched_param__reserved2; 2]>,
|
||||
__reserved3: Padding<c_int>,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
s! {
|
||||
pub struct sched_param {
|
||||
pub sched_priority: c_int,
|
||||
|
||||
#[deprecated(since = "0.2.173", note = "This field has been removed upstream")]
|
||||
pub sched_ss_low_priority: c_int,
|
||||
#[deprecated(since = "0.2.173", note = "This field has been removed upstream")]
|
||||
pub sched_ss_repl_period: crate::timespec,
|
||||
#[deprecated(since = "0.2.173", note = "This field has been removed upstream")]
|
||||
pub sched_ss_init_budget: crate::timespec,
|
||||
#[deprecated(since = "0.2.173", note = "This field has been removed upstream")]
|
||||
pub sched_ss_max_repl: c_int,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
//! Header: `unistd.h`
|
||||
|
||||
pub use crate::new::common::posix::unistd::{
|
||||
STDERR_FILENO,
|
||||
STDIN_FILENO,
|
||||
STDOUT_FILENO,
|
||||
};
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
//! Expressif libc.
|
||||
// FIXME(espidf): link to headers needed.
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
//! FreeBSD libc.
|
||||
//!
|
||||
//! * Headers: <https://github.com/freebsd/freebsd-src/blob/main/sys/riscv/include/ucontext.h>
|
||||
//! * Symbol map: <https://github.com/freebsd/freebsd-src/blob/main/lib/libc/gen/Symbol.map>
|
||||
|
||||
pub(crate) mod net;
|
||||
pub(crate) mod netinet6;
|
||||
pub(crate) mod sys;
|
||||
pub(crate) mod unistd;
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
//! Header: `net/dlt.h`
|
||||
//!
|
||||
//! https://github.com/freebsd/freebsd-src/blob/main/sys/net/dlt.h
|
||||
|
||||
use crate::prelude::*;
|
||||
|
||||
pub const DLT_NULL: c_uint = 0; // no link-layer encapsulation
|
||||
pub const DLT_EN10MB: c_uint = 1; // Ethernet (10Mb)
|
||||
pub const DLT_EN3MB: c_uint = 2; // Experimental Ethernet (3Mb)
|
||||
pub const DLT_AX25: c_uint = 3; // Amateur Radio AX.25
|
||||
pub const DLT_PRONET: c_uint = 4; // Proteon ProNET Token Ring
|
||||
pub const DLT_CHAOS: c_uint = 5; // Chaos
|
||||
pub const DLT_IEEE802: c_uint = 6; // IEEE 802 Networks
|
||||
pub const DLT_ARCNET: c_uint = 7; // ARCNET
|
||||
pub const DLT_SLIP: c_uint = 8; // Serial Line IP
|
||||
pub const DLT_PPP: c_uint = 9; // Point-to-point Protocol
|
||||
pub const DLT_FDDI: c_uint = 10; // FDDI
|
||||
pub const DLT_ATM_RFC1483: c_uint = 11; // LLC/SNAP encapsulated atm
|
||||
pub const DLT_RAW: c_uint = 12; // raw IP
|
||||
pub const DLT_LOOP: c_uint = 108;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
//! Directory: `net/`
|
||||
//!
|
||||
//! https://github.com/freebsd/freebsd-src/tree/main/sys/net
|
||||
|
||||
pub(crate) mod dlt;
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
//! Header: `netinet6/in6_var.h`
|
||||
//!
|
||||
//! https://github.com/freebsd/freebsd-src/blob/main/sys/netinet6/in6_var.h
|
||||
|
||||
use crate::prelude::*;
|
||||
use crate::sys::ioccom::*;
|
||||
|
||||
s! {
|
||||
pub struct in6_addrlifetime {
|
||||
pub ia6t_expire: crate::time_t,
|
||||
pub ia6t_preferred: crate::time_t,
|
||||
pub ia6t_vltime: u32,
|
||||
pub ia6t_pltime: u32,
|
||||
}
|
||||
|
||||
pub struct in6_ifstat {
|
||||
pub ifs6_in_receive: u64,
|
||||
pub ifs6_in_hdrerr: u64,
|
||||
pub ifs6_in_toobig: u64,
|
||||
pub ifs6_in_noroute: u64,
|
||||
pub ifs6_in_addrerr: u64,
|
||||
pub ifs6_in_protounknown: u64,
|
||||
pub ifs6_in_truncated: u64,
|
||||
pub ifs6_in_discard: u64,
|
||||
pub ifs6_in_deliver: u64,
|
||||
pub ifs6_out_forward: u64,
|
||||
pub ifs6_out_request: u64,
|
||||
pub ifs6_out_discard: u64,
|
||||
pub ifs6_out_fragok: u64,
|
||||
pub ifs6_out_fragfail: u64,
|
||||
pub ifs6_out_fragcreat: u64,
|
||||
pub ifs6_reass_reqd: u64,
|
||||
pub ifs6_reass_ok: u64,
|
||||
pub ifs6_reass_fail: u64,
|
||||
pub ifs6_in_mcast: u64,
|
||||
pub ifs6_out_mcast: u64,
|
||||
}
|
||||
|
||||
pub struct icmp6_ifstat {
|
||||
pub ifs6_in_msg: u64,
|
||||
pub ifs6_in_error: u64,
|
||||
pub ifs6_in_dstunreach: u64,
|
||||
pub ifs6_in_adminprohib: u64,
|
||||
pub ifs6_in_timeexceed: u64,
|
||||
pub ifs6_in_paramprob: u64,
|
||||
pub ifs6_in_pkttoobig: u64,
|
||||
pub ifs6_in_echo: u64,
|
||||
pub ifs6_in_echoreply: u64,
|
||||
pub ifs6_in_routersolicit: u64,
|
||||
pub ifs6_in_routeradvert: u64,
|
||||
pub ifs6_in_neighborsolicit: u64,
|
||||
pub ifs6_in_neighboradvert: u64,
|
||||
pub ifs6_in_redirect: u64,
|
||||
pub ifs6_in_mldquery: u64,
|
||||
pub ifs6_in_mldreport: u64,
|
||||
pub ifs6_in_mlddone: u64,
|
||||
pub ifs6_out_msg: u64,
|
||||
pub ifs6_out_error: u64,
|
||||
pub ifs6_out_dstunreach: u64,
|
||||
pub ifs6_out_adminprohib: u64,
|
||||
pub ifs6_out_timeexceed: u64,
|
||||
pub ifs6_out_paramprob: u64,
|
||||
pub ifs6_out_pkttoobig: u64,
|
||||
pub ifs6_out_echo: u64,
|
||||
pub ifs6_out_echoreply: u64,
|
||||
pub ifs6_out_routersolicit: u64,
|
||||
pub ifs6_out_routeradvert: u64,
|
||||
pub ifs6_out_neighborsolicit: u64,
|
||||
pub ifs6_out_neighboradvert: u64,
|
||||
pub ifs6_out_redirect: u64,
|
||||
pub ifs6_out_mldquery: u64,
|
||||
pub ifs6_out_mldreport: u64,
|
||||
pub ifs6_out_mlddone: u64,
|
||||
}
|
||||
}
|
||||
|
||||
s_no_extra_traits! {
|
||||
pub struct in6_ifreq {
|
||||
pub ifr_name: [c_char; crate::IFNAMSIZ],
|
||||
pub ifr_ifru: __c_anonymous_ifr_ifru6,
|
||||
}
|
||||
|
||||
pub union __c_anonymous_ifr_ifru6 {
|
||||
pub ifru_addr: crate::sockaddr_in6,
|
||||
pub ifru_dstaddr: crate::sockaddr_in6,
|
||||
pub ifru_flags: c_int,
|
||||
pub ifru_flags6: c_int,
|
||||
pub ifru_metric: c_int,
|
||||
pub ifru_data: crate::caddr_t,
|
||||
pub ifru_lifetime: in6_addrlifetime,
|
||||
pub ifru_stat: in6_ifstat,
|
||||
pub ifru_icmp6stat: icmp6_ifstat,
|
||||
pub ifru_scope_id: [u32; 16],
|
||||
}
|
||||
}
|
||||
|
||||
pub const IN6_IFF_ANYCAST: c_int = 0x01;
|
||||
pub const IN6_IFF_TENTATIVE: c_int = 0x02;
|
||||
pub const IN6_IFF_DUPLICATED: c_int = 0x04;
|
||||
pub const IN6_IFF_DETACHED: c_int = 0x08;
|
||||
pub const IN6_IFF_DEPRECATED: c_int = 0x10;
|
||||
pub const IN6_IFF_NODAD: c_int = 0x20;
|
||||
pub const IN6_IFF_AUTOCONF: c_int = 0x40;
|
||||
pub const IN6_IFF_TEMPORARY: c_int = 0x80;
|
||||
pub const IN6_IFF_PREFER_SOURCE: c_int = 0x0100;
|
||||
|
||||
pub const SIOCGIFAFLAG_IN6: c_ulong = _IOWR::<crate::in6_ifreq>('i' as c_ulong, 73);
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
//! Directory: `netinet6/`
|
||||
//!
|
||||
//! https://github.com/freebsd/freebsd-src/tree/main/sys/netinet6
|
||||
|
||||
pub(crate) mod in6_var;
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
//! Header: `sys/file.h`
|
||||
//!
|
||||
//! https://github.com/freebsd/freebsd-src/blob/main/sys/sys/file.h
|
||||
|
||||
use crate::prelude::*;
|
||||
|
||||
pub const DTYPE_NONE: c_int = 0;
|
||||
pub const DTYPE_VNODE: c_int = 1;
|
||||
pub const DTYPE_SOCKET: c_int = 2;
|
||||
pub const DTYPE_PIPE: c_int = 3;
|
||||
pub const DTYPE_FIFO: c_int = 4;
|
||||
pub const DTYPE_KQUEUE: c_int = 5;
|
||||
pub const DTYPE_CRYPTO: c_int = 6;
|
||||
pub const DTYPE_MQUEUE: c_int = 7;
|
||||
pub const DTYPE_SHM: c_int = 8;
|
||||
pub const DTYPE_SEM: c_int = 9;
|
||||
pub const DTYPE_PTS: c_int = 10;
|
||||
pub const DTYPE_DEV: c_int = 11;
|
||||
pub const DTYPE_PROCDESC: c_int = 12;
|
||||
pub const DTYPE_EVENTFD: c_int = 13;
|
||||
pub const DTYPE_TIMERFD: c_int = 14;
|
||||
pub const DTYPE_INOTIFY: c_int = 15;
|
||||
pub const DTYPE_JAILDESC: c_int = 16;
|
||||
|
||||
s! {
|
||||
#[cfg(not(any(freebsd10, freebsd11)))]
|
||||
pub struct xfile {
|
||||
pub xf_size: crate::ksize_t,
|
||||
pub xf_pid: crate::pid_t,
|
||||
pub xf_uid: crate::uid_t,
|
||||
pub xf_fd: c_int,
|
||||
_xf_int_pad1: Padding<c_int>,
|
||||
pub xf_file: crate::kvaddr_t,
|
||||
pub xf_type: c_short,
|
||||
_xf_short_pad1: Padding<c_short>,
|
||||
pub xf_count: c_int,
|
||||
pub xf_msgcount: c_int,
|
||||
_xf_int_pad2: Padding<c_int>,
|
||||
pub xf_offset: crate::off_t,
|
||||
pub xf_data: crate::kvaddr_t,
|
||||
pub xf_vnode: crate::kvaddr_t,
|
||||
pub xf_flag: c_uint,
|
||||
_xf_int_pad3: Padding<c_int>,
|
||||
_xf_int64_pad: Padding<[i64; 6]>,
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
//! Header: `sys/ioccom.h`
|
||||
//!
|
||||
//! https://github.com/freebsd/freebsd-src/blob/main/sys/sys/ioccom.h
|
||||
|
||||
use crate::prelude::*;
|
||||
|
||||
const IOCPARM_SHIFT: c_ulong = 13;
|
||||
const IOCPARM_MASK: c_ulong = (1 << IOCPARM_SHIFT) - 1;
|
||||
|
||||
const IOCPARM_MAX: c_ulong = 1 << IOCPARM_SHIFT;
|
||||
|
||||
pub(crate) const IOC_VOID: c_ulong = 0x20000000;
|
||||
pub(crate) const IOC_OUT: c_ulong = 0x40000000;
|
||||
pub(crate) const IOC_IN: c_ulong = 0x80000000;
|
||||
pub(crate) const IOC_INOUT: c_ulong = IOC_IN | IOC_OUT;
|
||||
pub(crate) const IOC_DIRMASK: c_ulong = IOC_VOID | IOC_OUT | IOC_IN;
|
||||
|
||||
pub(crate) const fn _IOC(inout: c_ulong, group: c_ulong, num: c_ulong, len: c_ulong) -> c_ulong {
|
||||
debug_assert!(inout <= IOC_DIRMASK);
|
||||
debug_assert!(group <= 0xff);
|
||||
debug_assert!(num <= 0xff);
|
||||
debug_assert!(len <= IOCPARM_MAX);
|
||||
|
||||
inout | ((len & IOCPARM_MASK) << 16) | (group << 8) | num
|
||||
}
|
||||
|
||||
pub const fn _IO(g: c_ulong, n: c_ulong) -> c_ulong {
|
||||
_IOC(IOC_VOID, g, n, 0)
|
||||
}
|
||||
|
||||
/// Build an ioctl number for an ioctl that passes an `int` by value.
|
||||
pub const fn _IOWINT(g: c_ulong, n: c_ulong) -> c_ulong {
|
||||
_IOC(IOC_VOID, g, n, mem::size_of::<c_int>() as c_ulong)
|
||||
}
|
||||
|
||||
/// Build an ioctl number for an read-only ioctl.
|
||||
pub const fn _IOR<T>(g: c_ulong, n: c_ulong) -> c_ulong {
|
||||
_IOC(IOC_OUT, g, n, mem::size_of::<T>() as c_ulong)
|
||||
}
|
||||
|
||||
/// Build an ioctl number for an write-only ioctl.
|
||||
pub const fn _IOW<T>(g: c_ulong, n: c_ulong) -> c_ulong {
|
||||
_IOC(IOC_IN, g, n, mem::size_of::<T>() as c_ulong)
|
||||
}
|
||||
|
||||
/// Build an ioctl number for a read-write ioctl.
|
||||
pub const fn _IOWR<T>(g: c_ulong, n: c_ulong) -> c_ulong {
|
||||
_IOC(IOC_INOUT, g, n, mem::size_of::<T>() as c_ulong)
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
//! Directory: `sys/`
|
||||
//!
|
||||
//! https://github.com/freebsd/freebsd-src/tree/main/sys/sys'
|
||||
|
||||
pub(crate) mod file;
|
||||
pub(crate) mod ioccom;
|
||||
pub(crate) mod socket;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
//! Header: `sys/socket.h`
|
||||
//!
|
||||
//! https://github.com/freebsd/freebsd-src/blob/main/sys/sys/socket.h
|
||||
|
||||
use crate::prelude::*;
|
||||
|
||||
pub const SO_RERROR: c_int = 0x0002_0000;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
//! Header: `unistd.h`
|
||||
|
||||
pub use crate::new::common::posix::unistd::{
|
||||
STDERR_FILENO,
|
||||
STDIN_FILENO,
|
||||
STDOUT_FILENO,
|
||||
};
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
//! Fuschia libc.
|
||||
// FIXME(fuchsia): link to headers needed.
|
||||
|
||||
pub(crate) mod unistd;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
//! Header: `unistd.h`
|
||||
|
||||
pub use crate::new::common::posix::unistd::{
|
||||
STDERR_FILENO,
|
||||
STDIN_FILENO,
|
||||
STDOUT_FILENO,
|
||||
};
|
||||
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
//! GNU libc.
|
||||
//!
|
||||
//! * Headers: <https://sourceware.org/git/?p=glibc.git> (official)
|
||||
//! * Headers: <https://github.com/bminor/glibc> (mirror)
|
||||
//!
|
||||
//! This module structure is modeled after glibc's source tree. Its build system selects headers
|
||||
//! from different locations based on the platform, which we mimic here with reexports.
|
||||
|
||||
/// Source directory: `posix/`
|
||||
///
|
||||
/// <https://github.com/bminor/glibc/tree/master/posix>
|
||||
mod posix {
|
||||
pub(crate) mod unistd;
|
||||
}
|
||||
|
||||
/// Source directory: `sysdeps/`
|
||||
///
|
||||
/// <https://github.com/bminor/glibc/tree/master/sysdeps>
|
||||
mod sysdeps {
|
||||
// FIXME(pthread): eventually all platforms should use this module
|
||||
#[cfg(target_os = "linux")]
|
||||
pub(crate) mod nptl;
|
||||
pub(crate) mod unix;
|
||||
|
||||
// You'll notice some directories that provide a `bits` module. These are included via
|
||||
// `path = "..."` wherever the generic implementation lives.
|
||||
}
|
||||
|
||||
pub(crate) use posix::*;
|
||||
// FIXME(pthread): eventually all platforms should use this module
|
||||
#[cfg(target_os = "linux")]
|
||||
pub(crate) use sysdeps::nptl::*;
|
||||
#[cfg(target_os = "linux")]
|
||||
pub(crate) use sysdeps::unix::linux::*;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
//! Header: `unistd.h`
|
||||
//!
|
||||
//! <https://github.com/bminor/glibc/blob/master/posix/unistd.h>
|
||||
|
||||
pub use crate::new::common::posix::unistd::{
|
||||
STDERR_FILENO,
|
||||
STDIN_FILENO,
|
||||
STDOUT_FILENO,
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
//! Directory: `sysdeps/mips`
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub(crate) mod nptl {
|
||||
pub(crate) mod bits;
|
||||
}
|
||||
Loaded 100 of 1714 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user