зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 3 changesets (bug 1854025) for causing build bustages.
Backed out changeset dd3a03791ed7 (bug 1854025) Backed out changeset b9136831bc35 (bug 1854025) Backed out changeset 08a18581bb77 (bug 1854025)
This commit is contained in:
Родитель
1e09918ec1
Коммит
80668b020f
|
@ -1519,27 +1519,6 @@ dependencies = [
|
|||
"termcolor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "errno"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd"
|
||||
dependencies = [
|
||||
"errno-dragonfly",
|
||||
"libc",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "errno-dragonfly"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "error-chain"
|
||||
version = "0.12.4"
|
||||
|
@ -1626,9 +1605,12 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "fastrand"
|
||||
version = "2.0.0"
|
||||
version = "1.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764"
|
||||
checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be"
|
||||
dependencies = [
|
||||
"instant",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ffi-support"
|
||||
|
@ -2767,6 +2749,15 @@ dependencies = [
|
|||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "instant"
|
||||
version = "0.1.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "interrupt-support"
|
||||
version = "0.1.0"
|
||||
|
@ -3077,9 +3068,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67"
|
|||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.148"
|
||||
version = "0.2.139"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b"
|
||||
checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79"
|
||||
|
||||
[[package]]
|
||||
name = "libdbus-sys"
|
||||
|
@ -3150,12 +3141,6 @@ version = "0.5.6"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.4.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1a9bad9f94746442c783ca431b22403b519cd7fbeed0533fdd6328b2f2212128"
|
||||
|
||||
[[package]]
|
||||
name = "litemap"
|
||||
version = "0.7.0"
|
||||
|
@ -4138,7 +4123,7 @@ checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447"
|
|||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"redox_syscall 0.3.999",
|
||||
"smallvec",
|
||||
"windows-targets",
|
||||
]
|
||||
|
@ -4540,6 +4525,13 @@ dependencies = [
|
|||
"num_cpus",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.2.999"
|
||||
dependencies = [
|
||||
"redox_syscall 0.3.999",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.3.999"
|
||||
|
@ -4745,19 +4737,6 @@ dependencies = [
|
|||
"semver",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.38.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d7db8590df6dfcd144d22afd1b83b36c21a18d7cbc1dc4bb5295a8712e9eb662"
|
||||
dependencies = [
|
||||
"bitflags 2.999.999",
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.12"
|
||||
|
@ -5389,15 +5368,16 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.8.0"
|
||||
version = "3.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef"
|
||||
checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"fastrand",
|
||||
"redox_syscall",
|
||||
"rustix",
|
||||
"windows-sys",
|
||||
"libc",
|
||||
"redox_syscall 0.2.999",
|
||||
"remove_dir_all",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
@ -121,6 +121,7 @@ serde_with = { path = "build/rust/serde_with" }
|
|||
redox_users = { path = "build/rust/redox_users" }
|
||||
|
||||
# Patch redox_syscall to an empty crate
|
||||
redox_syscall_0_2 = { package = "redox_syscall", path = "build/rust/redox_syscall_0_2" }
|
||||
redox_syscall = { path = "build/rust/redox_syscall" }
|
||||
|
||||
# Override tinyvec with smallvec
|
||||
|
|
|
@ -9,7 +9,6 @@ path = "lib.rs"
|
|||
|
||||
[features]
|
||||
serde = []
|
||||
std = []
|
||||
|
||||
[dependencies.bitflags]
|
||||
version = "1.0"
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
[package]
|
||||
name = "redox_syscall"
|
||||
version = "0.2.999"
|
||||
edition = "2018"
|
||||
license = "MPL-2.0"
|
||||
|
||||
[lib]
|
||||
path = "lib.rs"
|
||||
|
||||
[dependencies]
|
||||
redox_syscall = "0.3"
|
|
@ -0,0 +1,3 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
@ -1359,11 +1359,6 @@ who = "Nicolas Silva <nical@fastmail.com>"
|
|||
criteria = "safe-to-deploy"
|
||||
delta = "0.9.3 -> 0.10.0"
|
||||
|
||||
[[audits.errno]]
|
||||
who = "Mike Hommey <mh+mozilla@glandium.org>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.3.1 -> 0.3.3"
|
||||
|
||||
[[audits.extend]]
|
||||
who = "Ben Dean-Kawamura <bdk@mozilla.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
|
@ -1396,11 +1391,6 @@ who = "Mike Hommey <mh+mozilla@glandium.org>"
|
|||
criteria = "safe-to-deploy"
|
||||
delta = "1.8.0 -> 1.9.0"
|
||||
|
||||
[[audits.fastrand]]
|
||||
who = "Mike Hommey <mh+mozilla@glandium.org>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "1.9.0 -> 2.0.0"
|
||||
|
||||
[[audits.filetime_win]]
|
||||
who = "Nick Alexander <nalexander@mozilla.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
|
@ -2019,11 +2009,6 @@ who = "Mike Hommey <mh+mozilla@glandium.org>"
|
|||
criteria = "safe-to-deploy"
|
||||
delta = "0.2.138 -> 0.2.139"
|
||||
|
||||
[[audits.libc]]
|
||||
who = "Mike Hommey <mh+mozilla@glandium.org>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.2.147 -> 0.2.148"
|
||||
|
||||
[[audits.libloading]]
|
||||
who = "Mike Hommey <mh+mozilla@glandium.org>"
|
||||
criteria = "safe-to-deploy"
|
||||
|
@ -3276,11 +3261,6 @@ who = "Mike Hommey <mh+mozilla@glandium.org>"
|
|||
criteria = "safe-to-deploy"
|
||||
delta = "0.12.6 -> 0.13.0"
|
||||
|
||||
[[audits.tempfile]]
|
||||
who = "Mike Hommey <mh+mozilla@glandium.org>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "3.6.0 -> 3.8.0"
|
||||
|
||||
[[audits.termcolor]]
|
||||
who = "Mike Hommey <mh+mozilla@glandium.org>"
|
||||
criteria = "safe-to-deploy"
|
||||
|
@ -4502,12 +4482,6 @@ user-id = 2915 # Amanieu d'Antras (Amanieu)
|
|||
start = "2021-01-27"
|
||||
end = "2024-05-05"
|
||||
|
||||
[[trusted.linux-raw-sys]]
|
||||
criteria = "safe-to-deploy"
|
||||
user-id = 6825 # Dan Gohman (sunfishcode)
|
||||
start = "2021-06-12"
|
||||
end = "2024-09-08"
|
||||
|
||||
[[trusted.lock_api]]
|
||||
criteria = "safe-to-deploy"
|
||||
user-id = 2915 # Amanieu d'Antras (Amanieu)
|
||||
|
@ -4592,12 +4566,6 @@ user-id = 189 # Andrew Gallant (BurntSushi)
|
|||
start = "2019-03-30"
|
||||
end = "2024-05-03"
|
||||
|
||||
[[trusted.rustix]]
|
||||
criteria = "safe-to-deploy"
|
||||
user-id = 6825 # Dan Gohman (sunfishcode)
|
||||
start = "2021-10-29"
|
||||
end = "2024-09-08"
|
||||
|
||||
[[trusted.ryu]]
|
||||
criteria = "safe-to-deploy"
|
||||
user-id = 3618 # David Tolnay (dtolnay)
|
||||
|
|
|
@ -288,20 +288,6 @@ user-id = 2915
|
|||
user-login = "Amanieu"
|
||||
user-name = "Amanieu d'Antras"
|
||||
|
||||
[[publisher.libc]]
|
||||
version = "0.2.146"
|
||||
when = "2023-06-06"
|
||||
user-id = 2915
|
||||
user-login = "Amanieu"
|
||||
user-name = "Amanieu d'Antras"
|
||||
|
||||
[[publisher.linux-raw-sys]]
|
||||
version = "0.4.7"
|
||||
when = "2023-09-10"
|
||||
user-id = 6825
|
||||
user-login = "sunfishcode"
|
||||
user-name = "Dan Gohman"
|
||||
|
||||
[[publisher.lock_api]]
|
||||
version = "0.4.9"
|
||||
when = "2022-09-20"
|
||||
|
@ -420,13 +406,6 @@ user-id = 57462
|
|||
user-login = "mozkeeler"
|
||||
user-name = "Dana Keeler"
|
||||
|
||||
[[publisher.rustix]]
|
||||
version = "0.38.13"
|
||||
when = "2023-09-10"
|
||||
user-id = 6825
|
||||
user-login = "sunfishcode"
|
||||
user-name = "Dan Gohman"
|
||||
|
||||
[[publisher.ryu]]
|
||||
version = "1.0.12"
|
||||
when = "2022-12-17"
|
||||
|
@ -875,24 +854,6 @@ who = "Benjamin Bouvier <public@benj.me>"
|
|||
criteria = "safe-to-deploy"
|
||||
version = "0.1.3"
|
||||
|
||||
[[audits.bytecode-alliance.audits.errno]]
|
||||
who = "Dan Gohman <dev@sunfishcode.online>"
|
||||
criteria = "safe-to-deploy"
|
||||
version = "0.3.0"
|
||||
notes = "This crate uses libc and windows-sys APIs to get and set the raw OS error value."
|
||||
|
||||
[[audits.bytecode-alliance.audits.errno]]
|
||||
who = "Dan Gohman <dev@sunfishcode.online>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.3.0 -> 0.3.1"
|
||||
notes = "Just a dependency version bump and a bug fix for redox"
|
||||
|
||||
[[audits.bytecode-alliance.audits.errno-dragonfly]]
|
||||
who = "Jamey Sharp <jsharp@fastly.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
version = "0.1.2"
|
||||
notes = "This should be portable to any POSIX system and seems like it should be part of the libc crate, but at any rate it's safe as is."
|
||||
|
||||
[[audits.bytecode-alliance.audits.foreign-types]]
|
||||
who = "Pat Hickey <phickey@fastly.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
|
@ -971,12 +932,6 @@ criteria = "safe-to-deploy"
|
|||
version = "0.2.5"
|
||||
notes = "I am the author of this crate."
|
||||
|
||||
[[audits.bytecode-alliance.audits.libc]]
|
||||
who = "Alex Crichton <alex@alexcrichton.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.2.146 -> 0.2.147"
|
||||
notes = "Only new type definitions and updating others for some platforms, no major changes"
|
||||
|
||||
[[audits.bytecode-alliance.audits.memoffset]]
|
||||
who = "Alex Crichton <alex@alexcrichton.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
|
@ -1034,17 +989,6 @@ criteria = "safe-to-deploy"
|
|||
version = "0.4.6"
|
||||
notes = "provides a datastructure implemented using std's Vec. all uses of unsafe are just delegating to the underlying unsafe Vec methods."
|
||||
|
||||
[[audits.bytecode-alliance.audits.tempfile]]
|
||||
who = "Pat Hickey <phickey@fastly.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "3.3.0 -> 3.5.0"
|
||||
|
||||
[[audits.bytecode-alliance.audits.tempfile]]
|
||||
who = "Alex Crichton <alex@alexcrichton.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "3.5.0 -> 3.6.0"
|
||||
notes = "Dependency updates and new optimized trait implementations, but otherwise everything looks normal."
|
||||
|
||||
[[audits.bytecode-alliance.audits.unicase]]
|
||||
who = "Alex Crichton <alex@alexcrichton.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
{"files":{"Cargo.toml":"36cf2ca7d85e09d22a7dd384f95c51eb6a7f1a6234d3c54d251dfa575b990430","LICENSE":"e5b1e4fcd8ea2b20b09f378e44ef3f51f4b6a72a72b9f6a729e0f87bddcef97f","README.md":"1e8440a65b6befd65a507b60fb11ab29f314dd77012aa7a11b5d1fadbb5f908f","build.rs":"10d4f05ac56556fea0e98732dc4250ddf3f1acc3fea541c63a0bc130aca772e6","src/errno.c":"a857e47b114acb85fddcb252a610ab5734d225c26b7bedd7c35d7789d46c8526","src/lib.rs":"47245dcfc2d5797584444e70edb1997b2f5e39ecc0779599a7fcded379966c0f"},"package":"aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf"}
|
|
@ -1,27 +0,0 @@
|
|||
# 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 believe there's an error in this file please file an
|
||||
# issue against the rust-lang/cargo repository. If you're
|
||||
# editing this file be aware that the upstream Cargo.toml
|
||||
# will likely look very different (and much more reasonable)
|
||||
|
||||
[package]
|
||||
edition = "2018"
|
||||
name = "errno-dragonfly"
|
||||
version = "0.1.2"
|
||||
authors = ["Michael Neumann <mneumann@ntecs.de>"]
|
||||
include = ["Cargo.toml", "LICENSE", "README.md", "build.rs", "src/lib.rs", "src/errno.c"]
|
||||
description = "Exposes errno functionality to stable Rust on DragonFlyBSD"
|
||||
keywords = ["dragonfly"]
|
||||
license = "MIT"
|
||||
repository = "https://github.com/mneumann/errno-dragonfly-rs"
|
||||
[dependencies.libc]
|
||||
version = "0.2"
|
||||
default-features = false
|
||||
[build-dependencies.cc]
|
||||
version = "1.0"
|
|
@ -1,21 +0,0 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2017 Michael Neumann
|
||||
|
||||
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.
|
|
@ -1,3 +0,0 @@
|
|||
# errno-dragonfly-rs
|
||||
|
||||
Exposing `errno` functionality to stable Rust on DragonFly BSD.
|
|
@ -1,3 +0,0 @@
|
|||
fn main() {
|
||||
cc::Build::new().file("src/errno.c").compile("liberrno.a");
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
#include <errno.h>
|
||||
|
||||
int *errno_location() { return &errno; }
|
|
@ -1,6 +0,0 @@
|
|||
#![no_std]
|
||||
|
||||
#[link(name = "errno", kind = "static")]
|
||||
extern "C" {
|
||||
pub fn errno_location() -> *mut libc::c_int;
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
{"files":{"CHANGELOG.md":"a79eced1320b216cd070df7d341f3fa1cae36419e5d93bbe38958974b6ce9412","Cargo.toml":"f0be240b8f099ace32511671f4976590f92edecb4d4ee764433442248c980de4","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"8764a597675778ddfd4e25f81b08a05dbcf089ac05662df7613fe67f150e3aa2","README.md":"96a40903ea0fe68cf512d176a230f4a37df76de262f047f01a46f31de75402bd","clippy.toml":"2c27890fbf0454bb2405bdb013b1daeb78d57c5844b964bcac9afcc125fa46e4","src/hermit.rs":"ad03355bc4d79c180ab3210e1d3edd538eccaaea8d4f9a9b7eb8a0dc2d39b5df","src/lib.rs":"318f864b8cb9296c85f70f9dfb855c552303630b3a9390f147bb4b581b8d8b5c","src/unix.rs":"bbdb80131148c10687aca9c9d6037e5fb8b84c3c9a6a10f134c587f83dfd3af6","src/wasi.rs":"c606886ebda52b5dc7682c0f3aaf51e146692455acd5e303812cf0d634589d05","src/windows.rs":"7cbcdb8e74582f357fa945bb1c44c4d19c1a10bec958da1223305bf68ec35baf"},"package":"136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd"}
|
|
@ -1,60 +0,0 @@
|
|||
# [Unreleased]
|
||||
|
||||
# [0.3.3] - 2023-08-28
|
||||
|
||||
- Disable "libc/std" in no-std configurations.
|
||||
[#77](https://github.com/lambda-fairy/rust-errno/pull/77)
|
||||
|
||||
- Bump errno-dragonfly to 0.1.2
|
||||
[#75](https://github.com/lambda-fairy/rust-errno/pull/75)
|
||||
|
||||
- Support for the ESP-IDF framework
|
||||
[#74](https://github.com/lambda-fairy/rust-errno/pull/74)
|
||||
|
||||
# [0.3.2] - 2023-07-30
|
||||
|
||||
- Fix build on Hermit
|
||||
[#73](https://github.com/lambda-fairy/rust-errno/pull/73)
|
||||
|
||||
- Add support for QNX Neutrino
|
||||
[#72](https://github.com/lambda-fairy/rust-errno/pull/72)
|
||||
|
||||
# [0.3.1] - 2023-04-08
|
||||
|
||||
- Correct link name on redox
|
||||
[#69](https://github.com/lambda-fairy/rust-errno/pull/69)
|
||||
|
||||
- Update windows-sys requirement from 0.45 to 0.48
|
||||
[#70](https://github.com/lambda-fairy/rust-errno/pull/70)
|
||||
|
||||
# [0.3.0] - 2023-02-12
|
||||
|
||||
- Add haiku support
|
||||
[#42](https://github.com/lambda-fairy/rust-errno/pull/42)
|
||||
|
||||
- Add AIX support
|
||||
[#54](https://github.com/lambda-fairy/rust-errno/pull/54)
|
||||
|
||||
- Add formatting with `#![no_std]`
|
||||
[#44](https://github.com/lambda-fairy/rust-errno/pull/44)
|
||||
|
||||
- Switch from `winapi` to `windows-sys` [#55](https://github.com/lambda-fairy/rust-errno/pull/55)
|
||||
|
||||
- Update minimum Rust version to 1.48
|
||||
[#48](https://github.com/lambda-fairy/rust-errno/pull/48) [#55](https://github.com/lambda-fairy/rust-errno/pull/55)
|
||||
|
||||
- Upgrade to Rust 2018 edition [#59](https://github.com/lambda-fairy/rust-errno/pull/59)
|
||||
|
||||
- wasm32-wasi: Use `__errno_location` instead of `feature(thread_local)`. [#66](https://github.com/lambda-fairy/rust-errno/pull/66)
|
||||
|
||||
# [0.2.8] - 2021-10-27
|
||||
|
||||
- Optionally support no_std
|
||||
[#31](https://github.com/lambda-fairy/rust-errno/pull/31)
|
||||
|
||||
[Unreleased]: https://github.com/lambda-fairy/rust-errno/compare/v0.3.3...HEAD
|
||||
[0.3.3]: https://github.com/lambda-fairy/rust-errno/compare/v0.3.1...v0.3.2
|
||||
[0.3.2]: https://github.com/lambda-fairy/rust-errno/compare/v0.3.1...v0.3.2
|
||||
[0.3.1]: https://github.com/lambda-fairy/rust-errno/compare/v0.3.0...v0.3.1
|
||||
[0.3.0]: https://github.com/lambda-fairy/rust-errno/compare/v0.2.8...v0.3.0
|
||||
[0.2.8]: https://github.com/lambda-fairy/rust-errno/compare/v0.2.7...v0.2.8
|
|
@ -1,52 +0,0 @@
|
|||
# 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 = "2018"
|
||||
rust-version = "1.48"
|
||||
name = "errno"
|
||||
version = "0.3.3"
|
||||
authors = ["Chris Wong <lambda.fairy@gmail.com>"]
|
||||
description = "Cross-platform interface to the `errno` variable."
|
||||
documentation = "https://docs.rs/errno"
|
||||
readme = "README.md"
|
||||
categories = [
|
||||
"no-std",
|
||||
"os",
|
||||
]
|
||||
license = "MIT OR Apache-2.0"
|
||||
repository = "https://github.com/lambda-fairy/rust-errno"
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = ["libc/std"]
|
||||
|
||||
[target."cfg(target_os=\"dragonfly\")".dependencies.errno-dragonfly]
|
||||
version = "0.1.2"
|
||||
|
||||
[target."cfg(target_os=\"hermit\")".dependencies.libc]
|
||||
version = "0.2"
|
||||
default-features = false
|
||||
|
||||
[target."cfg(target_os=\"wasi\")".dependencies.libc]
|
||||
version = "0.2"
|
||||
default-features = false
|
||||
|
||||
[target."cfg(unix)".dependencies.libc]
|
||||
version = "0.2"
|
||||
default-features = false
|
||||
|
||||
[target."cfg(windows)".dependencies.windows-sys]
|
||||
version = "0.48"
|
||||
features = [
|
||||
"Win32_Foundation",
|
||||
"Win32_System_Diagnostics_Debug",
|
||||
]
|
|
@ -1,201 +0,0 @@
|
|||
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
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
|
@ -1,25 +0,0 @@
|
|||
Copyright (c) 2014 Chris Wong
|
||||
|
||||
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.
|
|
@ -1,62 +0,0 @@
|
|||
# errno [![CI](https://github.com/lambda-fairy/rust-errno/actions/workflows/main.yml/badge.svg)](https://github.com/lambda-fairy/rust-errno/actions/workflows/main.yml) [![Cargo](https://img.shields.io/crates/v/errno.svg)](https://crates.io/crates/errno)
|
||||
|
||||
Cross-platform interface to the [`errno`][errno] variable. Works on Rust 1.48 or newer.
|
||||
|
||||
Documentation is available at <https://docs.rs/errno>.
|
||||
|
||||
[errno]: https://en.wikipedia.org/wiki/Errno.h
|
||||
|
||||
|
||||
## Dependency
|
||||
|
||||
Add to your `Cargo.toml`:
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
errno = "*"
|
||||
```
|
||||
|
||||
|
||||
## Comparison with `std::io::Error`
|
||||
|
||||
The standard library provides [`Error::last_os_error`][last_os_error] which fetches `errno` in the same way.
|
||||
|
||||
This crate provides these extra features:
|
||||
|
||||
- No heap allocations
|
||||
- Optional `#![no_std]` support
|
||||
- A `set_errno` function
|
||||
|
||||
[last_os_error]: https://doc.rust-lang.org/std/io/struct.Error.html#method.last_os_error
|
||||
|
||||
|
||||
## Examples
|
||||
|
||||
```rust
|
||||
extern crate errno;
|
||||
use errno::{Errno, errno, set_errno};
|
||||
|
||||
// Get the current value of errno
|
||||
let e = errno();
|
||||
|
||||
// Set the current value of errno
|
||||
set_errno(e);
|
||||
|
||||
// Extract the error code as an i32
|
||||
let code = e.0;
|
||||
|
||||
// Display a human-friendly error message
|
||||
println!("Error {}: {}", code, e);
|
||||
```
|
||||
|
||||
|
||||
## `#![no_std]`
|
||||
|
||||
Enable `#![no_std]` support by disabling the default `std` feature:
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
errno = { version = "*", default-features = false }
|
||||
```
|
||||
|
||||
The `Error` impl will be unavailable.
|
|
@ -1 +0,0 @@
|
|||
msrv = "1.48"
|
|
@ -1,32 +0,0 @@
|
|||
//! Implementation of `errno` functionality for RustyHermit.
|
||||
//!
|
||||
//! Currently, the error handling in RustyHermit isn't clearly
|
||||
//! defined. At the current stage of RustyHermit, only a placeholder
|
||||
//! is provided to be compatible to the classical errno interface.
|
||||
|
||||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use crate::Errno;
|
||||
|
||||
pub fn with_description<F, T>(_err: Errno, callback: F) -> T
|
||||
where
|
||||
F: FnOnce(Result<&str, Errno>) -> T,
|
||||
{
|
||||
callback(Ok("unknown error"))
|
||||
}
|
||||
|
||||
pub const STRERROR_NAME: &str = "strerror_r";
|
||||
|
||||
pub fn errno() -> Errno {
|
||||
Errno(0)
|
||||
}
|
||||
|
||||
pub fn set_errno(_: Errno) {}
|
|
@ -1,156 +0,0 @@
|
|||
//! Cross-platform interface to the `errno` variable.
|
||||
//!
|
||||
//! # Examples
|
||||
//! ```
|
||||
//! use errno::{Errno, errno, set_errno};
|
||||
//!
|
||||
//! // Get the current value of errno
|
||||
//! let e = errno();
|
||||
//!
|
||||
//! // Set the current value of errno
|
||||
//! set_errno(e);
|
||||
//!
|
||||
//! // Extract the error code as an i32
|
||||
//! let code = e.0;
|
||||
//!
|
||||
//! // Display a human-friendly error message
|
||||
//! println!("Error {}: {}", code, e);
|
||||
//! ```
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
#[cfg_attr(unix, path = "unix.rs")]
|
||||
#[cfg_attr(windows, path = "windows.rs")]
|
||||
#[cfg_attr(target_os = "wasi", path = "wasi.rs")]
|
||||
#[cfg_attr(target_os = "hermit", path = "hermit.rs")]
|
||||
mod sys;
|
||||
|
||||
use core::fmt;
|
||||
#[cfg(feature = "std")]
|
||||
use std::error::Error;
|
||||
#[cfg(feature = "std")]
|
||||
use std::io;
|
||||
|
||||
/// Wraps a platform-specific error code.
|
||||
///
|
||||
/// The `Display` instance maps the code to a human-readable string. It
|
||||
/// calls [`strerror_r`][1] under POSIX, and [`FormatMessageW`][2] on
|
||||
/// Windows.
|
||||
///
|
||||
/// [1]: http://pubs.opengroup.org/onlinepubs/009695399/functions/strerror.html
|
||||
/// [2]: https://msdn.microsoft.com/en-us/library/windows/desktop/ms679351%28v=vs.85%29.aspx
|
||||
#[derive(Copy, Clone, Eq, Ord, PartialEq, PartialOrd, Hash)]
|
||||
pub struct Errno(pub i32);
|
||||
|
||||
impl fmt::Debug for Errno {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
sys::with_description(*self, |desc| {
|
||||
fmt.debug_struct("Errno")
|
||||
.field("code", &self.0)
|
||||
.field("description", &desc.ok())
|
||||
.finish()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Errno {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
sys::with_description(*self, |desc| match desc {
|
||||
Ok(desc) => fmt.write_str(desc),
|
||||
Err(fm_err) => write!(
|
||||
fmt,
|
||||
"OS error {} ({} returned error {})",
|
||||
self.0,
|
||||
sys::STRERROR_NAME,
|
||||
fm_err.0
|
||||
),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Errno> for i32 {
|
||||
fn from(e: Errno) -> Self {
|
||||
e.0
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl Error for Errno {
|
||||
// TODO: Remove when MSRV >= 1.27
|
||||
#[allow(deprecated)]
|
||||
fn description(&self) -> &str {
|
||||
"system error"
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl From<Errno> for io::Error {
|
||||
fn from(errno: Errno) -> Self {
|
||||
io::Error::from_raw_os_error(errno.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the platform-specific value of `errno`.
|
||||
pub fn errno() -> Errno {
|
||||
sys::errno()
|
||||
}
|
||||
|
||||
/// Sets the platform-specific value of `errno`.
|
||||
pub fn set_errno(err: Errno) {
|
||||
sys::set_errno(err)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
let x = errno();
|
||||
set_errno(x);
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[test]
|
||||
fn it_works_with_to_string() {
|
||||
let x = errno();
|
||||
let _ = x.to_string();
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[test]
|
||||
fn check_description() {
|
||||
let expect = if cfg!(windows) {
|
||||
"Incorrect function."
|
||||
} else if cfg!(target_os = "illumos") {
|
||||
"Not owner"
|
||||
} else if cfg!(target_os = "wasi") {
|
||||
"Argument list too long"
|
||||
} else if cfg!(target_os = "haiku") {
|
||||
"Operation not allowed"
|
||||
} else {
|
||||
"Operation not permitted"
|
||||
};
|
||||
|
||||
let errno_code = if cfg!(target_os = "haiku") {
|
||||
-2147483633
|
||||
} else {
|
||||
1
|
||||
};
|
||||
set_errno(Errno(errno_code));
|
||||
|
||||
assert_eq!(errno().to_string(), expect);
|
||||
assert_eq!(
|
||||
format!("{:?}", errno()),
|
||||
format!(
|
||||
"Errno {{ code: {}, description: Some({:?}) }}",
|
||||
errno_code, expect
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[test]
|
||||
fn check_error_into_errno() {
|
||||
const ERROR_CODE: i32 = 1;
|
||||
|
||||
let error = io::Error::from_raw_os_error(ERROR_CODE);
|
||||
let new_error: io::Error = Errno(ERROR_CODE).into();
|
||||
assert_eq!(error.kind(), new_error.kind());
|
||||
}
|
|
@ -1,90 +0,0 @@
|
|||
//! Implementation of `errno` functionality for Unix systems.
|
||||
//!
|
||||
//! Adapted from `src/libstd/sys/unix/os.rs` in the Rust distribution.
|
||||
|
||||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use core::str;
|
||||
#[cfg(target_os = "dragonfly")]
|
||||
use errno_dragonfly::errno_location;
|
||||
use libc::{self, c_char, c_int, size_t, strlen};
|
||||
|
||||
use crate::Errno;
|
||||
|
||||
fn from_utf8_lossy(input: &[u8]) -> &str {
|
||||
match str::from_utf8(input) {
|
||||
Ok(valid) => valid,
|
||||
Err(error) => unsafe { str::from_utf8_unchecked(&input[..error.valid_up_to()]) },
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_description<F, T>(err: Errno, callback: F) -> T
|
||||
where
|
||||
F: FnOnce(Result<&str, Errno>) -> T,
|
||||
{
|
||||
let mut buf = [0u8; 1024];
|
||||
let c_str = unsafe {
|
||||
if strerror_r(err.0, buf.as_mut_ptr() as *mut _, buf.len() as size_t) < 0 {
|
||||
let fm_err = errno();
|
||||
if fm_err != Errno(libc::ERANGE) {
|
||||
return callback(Err(fm_err));
|
||||
}
|
||||
}
|
||||
let c_str_len = strlen(buf.as_ptr() as *const _);
|
||||
&buf[..c_str_len]
|
||||
};
|
||||
callback(Ok(from_utf8_lossy(c_str)))
|
||||
}
|
||||
|
||||
pub const STRERROR_NAME: &str = "strerror_r";
|
||||
|
||||
pub fn errno() -> Errno {
|
||||
unsafe { Errno(*errno_location()) }
|
||||
}
|
||||
|
||||
pub fn set_errno(Errno(errno): Errno) {
|
||||
unsafe {
|
||||
*errno_location() = errno;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
#[cfg(not(target_os = "dragonfly"))]
|
||||
#[cfg_attr(
|
||||
any(target_os = "macos", target_os = "ios", target_os = "freebsd"),
|
||||
link_name = "__error"
|
||||
)]
|
||||
#[cfg_attr(
|
||||
any(
|
||||
target_os = "openbsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "bitrig",
|
||||
target_os = "android",
|
||||
target_os = "espidf"
|
||||
),
|
||||
link_name = "__errno"
|
||||
)]
|
||||
#[cfg_attr(
|
||||
any(target_os = "solaris", target_os = "illumos"),
|
||||
link_name = "___errno"
|
||||
)]
|
||||
#[cfg_attr(target_os = "haiku", link_name = "_errnop")]
|
||||
#[cfg_attr(
|
||||
any(target_os = "linux", target_os = "redox"),
|
||||
link_name = "__errno_location"
|
||||
)]
|
||||
#[cfg_attr(target_os = "aix", link_name = "_Errno")]
|
||||
#[cfg_attr(target_os = "nto", link_name = "__get_errno_ptr")]
|
||||
fn errno_location() -> *mut c_int;
|
||||
|
||||
#[cfg_attr(target_os = "linux", link_name = "__xpg_strerror_r")]
|
||||
fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: size_t) -> c_int;
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
//! Implementation of `errno` functionality for WASI.
|
||||
//!
|
||||
//! Adapted from `unix.rs`.
|
||||
|
||||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use core::str;
|
||||
use libc::{self, c_char, c_int, size_t, strlen};
|
||||
|
||||
use crate::Errno;
|
||||
|
||||
fn from_utf8_lossy(input: &[u8]) -> &str {
|
||||
match str::from_utf8(input) {
|
||||
Ok(valid) => valid,
|
||||
Err(error) => unsafe { str::from_utf8_unchecked(&input[..error.valid_up_to()]) },
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_description<F, T>(err: Errno, callback: F) -> T
|
||||
where
|
||||
F: FnOnce(Result<&str, Errno>) -> T,
|
||||
{
|
||||
let mut buf = [0u8; 1024];
|
||||
let c_str = unsafe {
|
||||
if strerror_r(err.0, buf.as_mut_ptr() as *mut _, buf.len() as size_t) < 0 {
|
||||
let fm_err = errno();
|
||||
if fm_err != Errno(libc::ERANGE) {
|
||||
return callback(Err(fm_err));
|
||||
}
|
||||
}
|
||||
let c_str_len = strlen(buf.as_ptr() as *const _);
|
||||
&buf[..c_str_len]
|
||||
};
|
||||
callback(Ok(from_utf8_lossy(c_str)))
|
||||
}
|
||||
|
||||
pub const STRERROR_NAME: &str = "strerror_r";
|
||||
|
||||
pub fn errno() -> Errno {
|
||||
unsafe { Errno(*__errno_location()) }
|
||||
}
|
||||
|
||||
pub fn set_errno(Errno(new_errno): Errno) {
|
||||
unsafe {
|
||||
*__errno_location() = new_errno;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
fn __errno_location() -> *mut c_int;
|
||||
fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: size_t) -> c_int;
|
||||
}
|
|
@ -1,81 +0,0 @@
|
|||
//! Implementation of `errno` functionality for Windows.
|
||||
//!
|
||||
//! Adapted from `src/libstd/sys/windows/os.rs` in the Rust distribution.
|
||||
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use core::char::{self, REPLACEMENT_CHARACTER};
|
||||
use core::ptr;
|
||||
use core::str;
|
||||
use windows_sys::Win32::Foundation::{GetLastError, SetLastError, WIN32_ERROR};
|
||||
use windows_sys::Win32::System::Diagnostics::Debug::{
|
||||
FormatMessageW, FORMAT_MESSAGE_FROM_SYSTEM, FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
};
|
||||
|
||||
use crate::Errno;
|
||||
|
||||
fn from_utf16_lossy<'a>(input: &[u16], output: &'a mut [u8]) -> &'a str {
|
||||
let mut output_len = 0;
|
||||
for c in char::decode_utf16(input.iter().copied().take_while(|&x| x != 0))
|
||||
.map(|x| x.unwrap_or(REPLACEMENT_CHARACTER))
|
||||
{
|
||||
let c_len = c.len_utf8();
|
||||
if c_len > output.len() - output_len {
|
||||
break;
|
||||
}
|
||||
c.encode_utf8(&mut output[output_len..]);
|
||||
output_len += c_len;
|
||||
}
|
||||
unsafe { str::from_utf8_unchecked(&output[..output_len]) }
|
||||
}
|
||||
|
||||
pub fn with_description<F, T>(err: Errno, callback: F) -> T
|
||||
where
|
||||
F: FnOnce(Result<&str, Errno>) -> T,
|
||||
{
|
||||
// This value is calculated from the macro
|
||||
// MAKELANGID(LANG_SYSTEM_DEFAULT, SUBLANG_SYS_DEFAULT)
|
||||
let lang_id = 0x0800_u32;
|
||||
|
||||
let mut buf = [0u16; 2048];
|
||||
|
||||
unsafe {
|
||||
let res = FormatMessageW(
|
||||
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
ptr::null_mut(),
|
||||
err.0 as u32,
|
||||
lang_id,
|
||||
buf.as_mut_ptr(),
|
||||
buf.len() as u32,
|
||||
ptr::null_mut(),
|
||||
);
|
||||
if res == 0 {
|
||||
// Sometimes FormatMessageW can fail e.g. system doesn't like lang_id
|
||||
let fm_err = errno();
|
||||
return callback(Err(fm_err));
|
||||
}
|
||||
|
||||
let mut msg = [0u8; 2048];
|
||||
let msg = from_utf16_lossy(&buf[..res as usize], &mut msg[..]);
|
||||
// Trim trailing CRLF inserted by FormatMessageW
|
||||
callback(Ok(msg.trim_end()))
|
||||
}
|
||||
}
|
||||
|
||||
pub const STRERROR_NAME: &str = "FormatMessageW";
|
||||
|
||||
pub fn errno() -> Errno {
|
||||
unsafe { Errno(GetLastError() as i32) }
|
||||
}
|
||||
|
||||
pub fn set_errno(Errno(errno): Errno) {
|
||||
unsafe { SetLastError(errno as WIN32_ERROR) }
|
||||
}
|
|
@ -1 +1 @@
|
|||
{"files":{"CHANGELOG.md":"a88b4ec120e965c0219c8d4a95e0868ed9396acb47d171ca864608eacda7efb8","Cargo.toml":"f0bc7071d293be9565d4a960fa914317f00f319901e9578e7a49a3a86959d90a","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"ba09e4125cf5450a26d1bd2236bd079d668b118df639d9055e61eaa4d3c23336","benches/bench.rs":"95df618eeb6f3432e11295d75267c0ececcda35a6d230e9ca504e5d772fa2b62","src/global_rng.rs":"43a74ba2c3c15ebdbbacff65d6da5a90b4c062dedc43c6bf3fcf05499beaeece","src/lib.rs":"67568c53a27b34c5e2eb5e613a9656bcc9da1688a85070c4c36b60c216e3da8b","tests/char.rs":"a530b41837f5bf43701d983ef0267d9b44779d455f24cbf30b881cd348de9ee1","tests/smoke.rs":"8eac48144705364d142882538be43b8d69018959579404c3b1e638827888e62e"},"package":"6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764"}
|
||||
{"files":{"CHANGELOG.md":"64192695962b6d2ec5f1f57f3b7909c216611a5de5cd5d0d28d863477eef0a12","Cargo.toml":"9d3bf85fff7d7228a8aae6e0c20a43f19a846412e598ee0b7d1f6f2a30bac880","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"dec6b96d3549746937d7e0e62e35e206e6f5b7e2d1886451281905f4edf096d4","benches/bench.rs":"234b2e5f725102ed0ff7686def089de23e433eeecaf03542af31fc60725e85e3","src/lib.rs":"88bf8a952c723b28b989c7b998b2ec0de6a1351f6891088d6237300c8982f36d","tests/char.rs":"a530b41837f5bf43701d983ef0267d9b44779d455f24cbf30b881cd348de9ee1","tests/smoke.rs":"aac00322cce06f15378aacbf247a37e9602c46cfd2bd588a0887b266cbc4770a"},"package":"e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be"}
|
|
@ -1,12 +1,3 @@
|
|||
# Version 2.0.0
|
||||
|
||||
- **Breaking:** Remove interior mutability from `Rng`. (#47)
|
||||
- Add a `fork()` method. (#49)
|
||||
- Add a `no_std` mode. (#50)
|
||||
- Add an iterator selection function. (#51)
|
||||
- Add a `choose_multiple()` function for sampling several elements from an iterator. (#55)
|
||||
- Use the `getrandom` crate for seeding on WebAssembly targets if the `js` feature is enabled. (#60)
|
||||
|
||||
# Version 1.9.0
|
||||
|
||||
- Add `Rng::fill()` (#35, #43)
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
|
||||
[package]
|
||||
edition = "2018"
|
||||
rust-version = "1.36"
|
||||
rust-version = "1.34"
|
||||
name = "fastrand"
|
||||
version = "2.0.0"
|
||||
version = "1.9.0"
|
||||
authors = ["Stjepan Glavina <stjepang@gmail.com>"]
|
||||
exclude = ["/.*"]
|
||||
description = "A simple and fast random number generator"
|
||||
|
@ -29,13 +29,6 @@ categories = ["algorithms"]
|
|||
license = "Apache-2.0 OR MIT"
|
||||
repository = "https://github.com/smol-rs/fastrand"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
rustdoc-args = [
|
||||
"--cfg",
|
||||
"docsrs",
|
||||
]
|
||||
|
||||
[dev-dependencies.getrandom]
|
||||
version = "0.2"
|
||||
|
||||
|
@ -45,23 +38,16 @@ version = "0.8"
|
|||
[dev-dependencies.wyhash]
|
||||
version = "0.5"
|
||||
|
||||
[features]
|
||||
alloc = []
|
||||
default = ["std"]
|
||||
js = [
|
||||
"std",
|
||||
"getrandom",
|
||||
]
|
||||
std = ["alloc"]
|
||||
[target."cfg(all(target_arch = \"wasm32\", not(target_os = \"wasi\")))".dependencies.instant]
|
||||
version = "0.1"
|
||||
|
||||
[target."cfg(all(any(target_arch = \"wasm32\", target_arch = \"wasm64\"), target_os = \"unknown\"))".dependencies.getrandom]
|
||||
version = "0.2"
|
||||
features = ["js"]
|
||||
optional = true
|
||||
|
||||
[target."cfg(all(any(target_arch = \"wasm32\", target_arch = \"wasm64\"), target_os = \"unknown\"))".dev-dependencies.getrandom]
|
||||
[target."cfg(all(target_arch = \"wasm32\", not(target_os = \"wasi\")))".dev-dependencies.getrandom]
|
||||
version = "0.2"
|
||||
features = ["js"]
|
||||
|
||||
[target."cfg(all(any(target_arch = \"wasm32\", target_arch = \"wasm64\"), target_os = \"unknown\"))".dev-dependencies.wasm-bindgen-test]
|
||||
[target."cfg(all(target_arch = \"wasm32\", not(target_os = \"wasi\")))".dev-dependencies.instant]
|
||||
version = "0.1"
|
||||
features = ["wasm-bindgen"]
|
||||
|
||||
[target."cfg(all(target_arch = \"wasm32\", not(target_os = \"wasi\")))".dev-dependencies.wasm-bindgen-test]
|
||||
version = "0.3"
|
||||
|
|
|
@ -40,13 +40,6 @@ let i = fastrand::usize(..v.len());
|
|||
let elem = v[i];
|
||||
```
|
||||
|
||||
Sample values from an array with `O(n)` complexity (`n` is the length of array):
|
||||
|
||||
```rust
|
||||
fastrand::choose_multiple(vec![1, 4, 5].iter(), 2);
|
||||
fastrand::choose_multiple(0..20, 12);
|
||||
```
|
||||
|
||||
Shuffle an array:
|
||||
|
||||
```rust
|
||||
|
@ -83,12 +76,6 @@ let rng = fastrand::Rng::new();
|
|||
let mut bytes: Vec<u8> = repeat_with(|| rng.u8(..)).take(10_000).collect();
|
||||
```
|
||||
|
||||
# Features
|
||||
|
||||
- `std` (enabled by default): Enables the `std` library. This is required for the global
|
||||
generator and global entropy. Without this feature, [`Rng`] can only be instantiated using
|
||||
the [`with_seed`](Rng::with_seed) method.
|
||||
|
||||
## License
|
||||
|
||||
Licensed under either of
|
||||
|
|
|
@ -18,7 +18,7 @@ fn shuffle_wyhash(b: &mut Bencher) {
|
|||
|
||||
#[bench]
|
||||
fn shuffle_fastrand(b: &mut Bencher) {
|
||||
let mut rng = fastrand::Rng::new();
|
||||
let rng = fastrand::Rng::new();
|
||||
let mut x = (0..100).collect::<Vec<usize>>();
|
||||
b.iter(|| {
|
||||
rng.shuffle(&mut x);
|
||||
|
@ -40,7 +40,7 @@ fn u8_wyhash(b: &mut Bencher) {
|
|||
|
||||
#[bench]
|
||||
fn u8_fastrand(b: &mut Bencher) {
|
||||
let mut rng = fastrand::Rng::new();
|
||||
let rng = fastrand::Rng::new();
|
||||
b.iter(|| {
|
||||
let mut sum = 0u8;
|
||||
for _ in 0..10_000 {
|
||||
|
@ -64,7 +64,7 @@ fn u32_wyhash(b: &mut Bencher) {
|
|||
|
||||
#[bench]
|
||||
fn u32_fastrand(b: &mut Bencher) {
|
||||
let mut rng = fastrand::Rng::new();
|
||||
let rng = fastrand::Rng::new();
|
||||
b.iter(|| {
|
||||
let mut sum = 0u32;
|
||||
for _ in 0..10_000 {
|
||||
|
@ -76,7 +76,7 @@ fn u32_fastrand(b: &mut Bencher) {
|
|||
|
||||
#[bench]
|
||||
fn fill(b: &mut Bencher) {
|
||||
let mut rng = fastrand::Rng::new();
|
||||
let rng = fastrand::Rng::new();
|
||||
b.iter(|| {
|
||||
// Pick a size that isn't divisble by 8.
|
||||
let mut bytes = [0u8; 367];
|
||||
|
@ -87,7 +87,7 @@ fn fill(b: &mut Bencher) {
|
|||
|
||||
#[bench]
|
||||
fn fill_naive(b: &mut Bencher) {
|
||||
let mut rng = fastrand::Rng::new();
|
||||
let rng = fastrand::Rng::new();
|
||||
b.iter(|| {
|
||||
let mut bytes = [0u8; 367];
|
||||
for item in &mut bytes {
|
||||
|
|
|
@ -1,218 +0,0 @@
|
|||
//! A global, thread-local random number generator.
|
||||
|
||||
use crate::Rng;
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::ops::RangeBounds;
|
||||
|
||||
// Chosen by fair roll of the dice.
|
||||
const DEFAULT_RNG_SEED: u64 = 0xef6f79ed30ba75a;
|
||||
|
||||
impl Default for Rng {
|
||||
/// Initialize the `Rng` from the system's random number generator.
|
||||
///
|
||||
/// This is equivalent to [`Rng::new()`].
|
||||
#[inline]
|
||||
fn default() -> Rng {
|
||||
Rng::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl Rng {
|
||||
/// Creates a new random number generator.
|
||||
#[inline]
|
||||
pub fn new() -> Rng {
|
||||
try_with_rng(Rng::fork).unwrap_or_else(|_| Rng::with_seed(0x4d595df4d0f33173))
|
||||
}
|
||||
}
|
||||
|
||||
thread_local! {
|
||||
static RNG: Cell<Rng> = Cell::new(Rng(random_seed().unwrap_or(DEFAULT_RNG_SEED)));
|
||||
}
|
||||
|
||||
/// Run an operation with the current thread-local generator.
|
||||
#[inline]
|
||||
fn with_rng<R>(f: impl FnOnce(&mut Rng) -> R) -> R {
|
||||
RNG.with(|rng| {
|
||||
let current = rng.replace(Rng(0));
|
||||
|
||||
let mut restore = RestoreOnDrop { rng, current };
|
||||
|
||||
f(&mut restore.current)
|
||||
})
|
||||
}
|
||||
|
||||
/// Try to run an operation with the current thread-local generator.
|
||||
#[inline]
|
||||
fn try_with_rng<R>(f: impl FnOnce(&mut Rng) -> R) -> Result<R, std::thread::AccessError> {
|
||||
RNG.try_with(|rng| {
|
||||
let current = rng.replace(Rng(0));
|
||||
|
||||
let mut restore = RestoreOnDrop { rng, current };
|
||||
|
||||
f(&mut restore.current)
|
||||
})
|
||||
}
|
||||
|
||||
/// Make sure the original RNG is restored even on panic.
|
||||
struct RestoreOnDrop<'a> {
|
||||
rng: &'a Cell<Rng>,
|
||||
current: Rng,
|
||||
}
|
||||
|
||||
impl Drop for RestoreOnDrop<'_> {
|
||||
fn drop(&mut self) {
|
||||
self.rng.set(Rng(self.current.0));
|
||||
}
|
||||
}
|
||||
|
||||
/// Initializes the thread-local generator with the given seed.
|
||||
#[inline]
|
||||
pub fn seed(seed: u64) {
|
||||
with_rng(|r| r.seed(seed));
|
||||
}
|
||||
|
||||
/// Gives back **current** seed that is being held by the thread-local generator.
|
||||
#[inline]
|
||||
pub fn get_seed() -> u64 {
|
||||
with_rng(|r| r.get_seed())
|
||||
}
|
||||
|
||||
/// Generates a random `bool`.
|
||||
#[inline]
|
||||
pub fn bool() -> bool {
|
||||
with_rng(|r| r.bool())
|
||||
}
|
||||
|
||||
/// Generates a random `char` in ranges a-z and A-Z.
|
||||
#[inline]
|
||||
pub fn alphabetic() -> char {
|
||||
with_rng(|r| r.alphabetic())
|
||||
}
|
||||
|
||||
/// Generates a random `char` in ranges a-z, A-Z and 0-9.
|
||||
#[inline]
|
||||
pub fn alphanumeric() -> char {
|
||||
with_rng(|r| r.alphanumeric())
|
||||
}
|
||||
|
||||
/// Generates a random `char` in range a-z.
|
||||
#[inline]
|
||||
pub fn lowercase() -> char {
|
||||
with_rng(|r| r.lowercase())
|
||||
}
|
||||
|
||||
/// Generates a random `char` in range A-Z.
|
||||
#[inline]
|
||||
pub fn uppercase() -> char {
|
||||
with_rng(|r| r.uppercase())
|
||||
}
|
||||
|
||||
/// Choose an item from an iterator at random.
|
||||
///
|
||||
/// This function may have an unexpected result if the `len()` property of the
|
||||
/// iterator does not match the actual number of items in the iterator. If
|
||||
/// the iterator is empty, this returns `None`.
|
||||
#[inline]
|
||||
pub fn choice<I>(iter: I) -> Option<I::Item>
|
||||
where
|
||||
I: IntoIterator,
|
||||
I::IntoIter: ExactSizeIterator,
|
||||
{
|
||||
with_rng(|r| r.choice(iter))
|
||||
}
|
||||
|
||||
/// Generates a random digit in the given `base`.
|
||||
///
|
||||
/// Digits are represented by `char`s in ranges 0-9 and a-z.
|
||||
///
|
||||
/// Panics if the base is zero or greater than 36.
|
||||
#[inline]
|
||||
pub fn digit(base: u32) -> char {
|
||||
with_rng(|r| r.digit(base))
|
||||
}
|
||||
|
||||
/// Shuffles a slice randomly.
|
||||
#[inline]
|
||||
pub fn shuffle<T>(slice: &mut [T]) {
|
||||
with_rng(|r| r.shuffle(slice))
|
||||
}
|
||||
|
||||
macro_rules! integer {
|
||||
($t:tt, $doc:tt) => {
|
||||
#[doc = $doc]
|
||||
///
|
||||
/// Panics if the range is empty.
|
||||
#[inline]
|
||||
pub fn $t(range: impl RangeBounds<$t>) -> $t {
|
||||
with_rng(|r| r.$t(range))
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
integer!(u8, "Generates a random `u8` in the given range.");
|
||||
integer!(i8, "Generates a random `i8` in the given range.");
|
||||
integer!(u16, "Generates a random `u16` in the given range.");
|
||||
integer!(i16, "Generates a random `i16` in the given range.");
|
||||
integer!(u32, "Generates a random `u32` in the given range.");
|
||||
integer!(i32, "Generates a random `i32` in the given range.");
|
||||
integer!(u64, "Generates a random `u64` in the given range.");
|
||||
integer!(i64, "Generates a random `i64` in the given range.");
|
||||
integer!(u128, "Generates a random `u128` in the given range.");
|
||||
integer!(i128, "Generates a random `i128` in the given range.");
|
||||
integer!(usize, "Generates a random `usize` in the given range.");
|
||||
integer!(isize, "Generates a random `isize` in the given range.");
|
||||
integer!(char, "Generates a random `char` in the given range.");
|
||||
|
||||
/// Generates a random `f32` in range `0..1`.
|
||||
pub fn f32() -> f32 {
|
||||
with_rng(|r| r.f32())
|
||||
}
|
||||
|
||||
/// Generates a random `f64` in range `0..1`.
|
||||
pub fn f64() -> f64 {
|
||||
with_rng(|r| r.f64())
|
||||
}
|
||||
|
||||
/// Collects `amount` values at random from the iterator into a vector.
|
||||
pub fn choose_multiple<T: Iterator>(source: T, amount: usize) -> Vec<T::Item> {
|
||||
with_rng(|rng| rng.choose_multiple(source, amount))
|
||||
}
|
||||
|
||||
#[cfg(not(all(
|
||||
any(target_arch = "wasm32", target_arch = "wasm64"),
|
||||
target_os = "unknown"
|
||||
)))]
|
||||
fn random_seed() -> Option<u64> {
|
||||
use std::collections::hash_map::DefaultHasher;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::thread;
|
||||
use std::time::Instant;
|
||||
|
||||
let mut hasher = DefaultHasher::new();
|
||||
Instant::now().hash(&mut hasher);
|
||||
thread::current().id().hash(&mut hasher);
|
||||
let hash = hasher.finish();
|
||||
Some((hash << 1) | 1)
|
||||
}
|
||||
|
||||
#[cfg(all(
|
||||
any(target_arch = "wasm32", target_arch = "wasm64"),
|
||||
target_os = "unknown",
|
||||
feature = "js"
|
||||
))]
|
||||
fn random_seed() -> Option<u64> {
|
||||
// TODO(notgull): Failures should be logged somewhere.
|
||||
let mut seed = [0u8; 8];
|
||||
getrandom::getrandom(&mut seed).ok()?;
|
||||
Some(u64::from_ne_bytes(seed))
|
||||
}
|
||||
|
||||
#[cfg(all(
|
||||
any(target_arch = "wasm32", target_arch = "wasm64"),
|
||||
target_os = "unknown",
|
||||
not(feature = "js")
|
||||
))]
|
||||
fn random_seed() -> Option<u64> {
|
||||
None
|
||||
}
|
|
@ -29,14 +29,6 @@
|
|||
//! let elem = v[i];
|
||||
//! ```
|
||||
//!
|
||||
//! Sample values from an array with `O(n)` complexity (`n` is the length of array):
|
||||
//!
|
||||
//! ```
|
||||
//! fastrand::choose_multiple(vec![1, 4, 5].iter(), 2);
|
||||
//! fastrand::choose_multiple(0..20, 12);
|
||||
//! ```
|
||||
//!
|
||||
//!
|
||||
//! Shuffle an array:
|
||||
//!
|
||||
//! ```
|
||||
|
@ -69,88 +61,87 @@
|
|||
//! ```
|
||||
//! use std::iter::repeat_with;
|
||||
//!
|
||||
//! let mut rng = fastrand::Rng::new();
|
||||
//! let rng = fastrand::Rng::new();
|
||||
//! let mut bytes: Vec<u8> = repeat_with(|| rng.u8(..)).take(10_000).collect();
|
||||
//! ```
|
||||
//!
|
||||
//! # Features
|
||||
//!
|
||||
//! - `std` (enabled by default): Enables the `std` library. This is required for the global
|
||||
//! generator and global entropy. Without this feature, [`Rng`] can only be instantiated using
|
||||
//! the [`with_seed`](Rng::with_seed) method.
|
||||
//! - `js`: Assumes that WebAssembly targets are being run in a JavaScript environment. See the
|
||||
//! [WebAssembly Notes](#webassembly-notes) section for more information.
|
||||
//!
|
||||
//! # WebAssembly Notes
|
||||
//!
|
||||
//! For non-WASI WASM targets, there is additional sublety to consider when utilizing the global RNG.
|
||||
//! By default, `std` targets will use entropy sources in the standard library to seed the global RNG.
|
||||
//! However, these sources are not available by default on WASM targets outside of WASI.
|
||||
//!
|
||||
//! If the `js` feature is enabled, this crate will assume that it is running in a JavaScript
|
||||
//! environment. At this point, the [`getrandom`] crate will be used in order to access the available
|
||||
//! entropy sources and seed the global RNG. If the `js` feature is not enabled, the global RNG will
|
||||
//! use a predefined seed.
|
||||
//!
|
||||
//! [`getrandom`]: https://crates.io/crates/getrandom
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||
#![forbid(unsafe_code)]
|
||||
#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
extern crate alloc;
|
||||
use std::cell::Cell;
|
||||
use std::collections::hash_map::DefaultHasher;
|
||||
use std::convert::TryInto;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::ops::{Bound, RangeBounds};
|
||||
use std::thread;
|
||||
|
||||
use core::convert::{TryFrom, TryInto};
|
||||
use core::ops::{Bound, RangeBounds};
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
use alloc::vec::Vec;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
|
||||
mod global_rng;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub use global_rng::*;
|
||||
#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
|
||||
use instant::Instant;
|
||||
#[cfg(not(all(target_arch = "wasm32", not(target_os = "wasi"))))]
|
||||
use std::time::Instant;
|
||||
|
||||
/// A random number generator.
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct Rng(u64);
|
||||
pub struct Rng(Cell<u64>);
|
||||
|
||||
impl Default for Rng {
|
||||
#[inline]
|
||||
fn default() -> Rng {
|
||||
Rng::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl Clone for Rng {
|
||||
/// Clones the generator by creating a new generator with the same seed.
|
||||
/// Clones the generator by deterministically deriving a new generator based on the initial
|
||||
/// seed.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// // Seed two generators equally, and clone both of them.
|
||||
/// let base1 = fastrand::Rng::new();
|
||||
/// base1.seed(0x4d595df4d0f33173);
|
||||
/// base1.bool(); // Use the generator once.
|
||||
///
|
||||
/// let base2 = fastrand::Rng::new();
|
||||
/// base2.seed(0x4d595df4d0f33173);
|
||||
/// base2.bool(); // Use the generator once.
|
||||
///
|
||||
/// let rng1 = base1.clone();
|
||||
/// let rng2 = base2.clone();
|
||||
///
|
||||
/// assert_eq!(rng1.u64(..), rng2.u64(..), "the cloned generators are identical");
|
||||
/// ```
|
||||
fn clone(&self) -> Rng {
|
||||
Rng::with_seed(self.0)
|
||||
Rng::with_seed(self.gen_u64())
|
||||
}
|
||||
}
|
||||
|
||||
impl Rng {
|
||||
/// Generates a random `u32`.
|
||||
#[inline]
|
||||
fn gen_u32(&mut self) -> u32 {
|
||||
fn gen_u32(&self) -> u32 {
|
||||
self.gen_u64() as u32
|
||||
}
|
||||
|
||||
/// Generates a random `u64`.
|
||||
#[inline]
|
||||
fn gen_u64(&mut self) -> u64 {
|
||||
let s = self.0.wrapping_add(0xA0761D6478BD642F);
|
||||
self.0 = s;
|
||||
fn gen_u64(&self) -> u64 {
|
||||
let s = self.0.get().wrapping_add(0xA0761D6478BD642F);
|
||||
self.0.set(s);
|
||||
let t = u128::from(s) * u128::from(s ^ 0xE7037ED1A0B428DB);
|
||||
(t as u64) ^ (t >> 64) as u64
|
||||
}
|
||||
|
||||
/// Generates a random `u128`.
|
||||
#[inline]
|
||||
fn gen_u128(&mut self) -> u128 {
|
||||
fn gen_u128(&self) -> u128 {
|
||||
(u128::from(self.gen_u64()) << 64) | u128::from(self.gen_u64())
|
||||
}
|
||||
|
||||
/// Generates a random `u32` in `0..n`.
|
||||
#[inline]
|
||||
fn gen_mod_u32(&mut self, n: u32) -> u32 {
|
||||
fn gen_mod_u32(&self, n: u32) -> u32 {
|
||||
// Adapted from: https://lemire.me/blog/2016/06/30/fast-random-shuffling/
|
||||
let mut r = self.gen_u32();
|
||||
let mut hi = mul_high_u32(r, n);
|
||||
|
@ -168,7 +159,7 @@ impl Rng {
|
|||
|
||||
/// Generates a random `u64` in `0..n`.
|
||||
#[inline]
|
||||
fn gen_mod_u64(&mut self, n: u64) -> u64 {
|
||||
fn gen_mod_u64(&self, n: u64) -> u64 {
|
||||
// Adapted from: https://lemire.me/blog/2016/06/30/fast-random-shuffling/
|
||||
let mut r = self.gen_u64();
|
||||
let mut hi = mul_high_u64(r, n);
|
||||
|
@ -186,7 +177,7 @@ impl Rng {
|
|||
|
||||
/// Generates a random `u128` in `0..n`.
|
||||
#[inline]
|
||||
fn gen_mod_u128(&mut self, n: u128) -> u128 {
|
||||
fn gen_mod_u128(&self, n: u128) -> u128 {
|
||||
// Adapted from: https://lemire.me/blog/2016/06/30/fast-random-shuffling/
|
||||
let mut r = self.gen_u128();
|
||||
let mut hi = mul_high_u128(r, n);
|
||||
|
@ -203,6 +194,16 @@ impl Rng {
|
|||
}
|
||||
}
|
||||
|
||||
thread_local! {
|
||||
static RNG: Rng = Rng(Cell::new({
|
||||
let mut hasher = DefaultHasher::new();
|
||||
Instant::now().hash(&mut hasher);
|
||||
thread::current().id().hash(&mut hasher);
|
||||
let hash = hasher.finish();
|
||||
(hash << 1) | 1
|
||||
}));
|
||||
}
|
||||
|
||||
/// Computes `(a * b) >> 32`.
|
||||
#[inline]
|
||||
fn mul_high_u32(a: u32, b: u32) -> u32 {
|
||||
|
@ -234,7 +235,7 @@ macro_rules! rng_integer {
|
|||
///
|
||||
/// Panics if the range is empty.
|
||||
#[inline]
|
||||
pub fn $t(&mut self, range: impl RangeBounds<$t>) -> $t {
|
||||
pub fn $t(&self, range: impl RangeBounds<$t>) -> $t {
|
||||
let panic_empty_range = || {
|
||||
panic!(
|
||||
"empty range: {:?}..{:?}",
|
||||
|
@ -244,13 +245,13 @@ macro_rules! rng_integer {
|
|||
};
|
||||
|
||||
let low = match range.start_bound() {
|
||||
Bound::Unbounded => core::$t::MIN,
|
||||
Bound::Unbounded => std::$t::MIN,
|
||||
Bound::Included(&x) => x,
|
||||
Bound::Excluded(&x) => x.checked_add(1).unwrap_or_else(panic_empty_range),
|
||||
};
|
||||
|
||||
let high = match range.end_bound() {
|
||||
Bound::Unbounded => core::$t::MAX,
|
||||
Bound::Unbounded => std::$t::MAX,
|
||||
Bound::Included(&x) => x,
|
||||
Bound::Excluded(&x) => x.checked_sub(1).unwrap_or_else(panic_empty_range),
|
||||
};
|
||||
|
@ -259,7 +260,7 @@ macro_rules! rng_integer {
|
|||
panic_empty_range();
|
||||
}
|
||||
|
||||
if low == core::$t::MIN && high == core::$t::MAX {
|
||||
if low == std::$t::MIN && high == std::$t::MAX {
|
||||
self.$gen() as $t
|
||||
} else {
|
||||
let len = high.wrapping_sub(low).wrapping_add(1);
|
||||
|
@ -270,59 +271,46 @@ macro_rules! rng_integer {
|
|||
}
|
||||
|
||||
impl Rng {
|
||||
/// Creates a new random number generator.
|
||||
#[inline]
|
||||
pub fn new() -> Rng {
|
||||
Rng::with_seed(
|
||||
RNG.try_with(|rng| rng.u64(..))
|
||||
.unwrap_or(0x4d595df4d0f33173),
|
||||
)
|
||||
}
|
||||
|
||||
/// Creates a new random number generator with the initial seed.
|
||||
#[inline]
|
||||
#[must_use = "this creates a new instance of `Rng`; if you want to initialize the thread-local generator, use `fastrand::seed()` instead"]
|
||||
pub fn with_seed(seed: u64) -> Self {
|
||||
let mut rng = Rng(0);
|
||||
let rng = Rng(Cell::new(0));
|
||||
|
||||
rng.seed(seed);
|
||||
rng
|
||||
}
|
||||
|
||||
/// Clones the generator by deterministically deriving a new generator based on the initial
|
||||
/// seed.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// // Seed two generators equally, and clone both of them.
|
||||
/// let mut base1 = fastrand::Rng::new();
|
||||
/// base1.seed(0x4d595df4d0f33173);
|
||||
/// base1.bool(); // Use the generator once.
|
||||
///
|
||||
/// let mut base2 = fastrand::Rng::new();
|
||||
/// base2.seed(0x4d595df4d0f33173);
|
||||
/// base2.bool(); // Use the generator once.
|
||||
///
|
||||
/// let mut rng1 = base1.clone();
|
||||
/// let mut rng2 = base2.clone();
|
||||
///
|
||||
/// assert_eq!(rng1.u64(..), rng2.u64(..), "the cloned generators are identical");
|
||||
/// ```
|
||||
#[inline]
|
||||
#[must_use = "this creates a new instance of `Rng`"]
|
||||
pub fn fork(&mut self) -> Self {
|
||||
Rng::with_seed(self.gen_u64())
|
||||
}
|
||||
|
||||
/// Generates a random `char` in ranges a-z and A-Z.
|
||||
#[inline]
|
||||
pub fn alphabetic(&mut self) -> char {
|
||||
pub fn alphabetic(&self) -> char {
|
||||
const CHARS: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
*self.choice(CHARS).unwrap() as char
|
||||
let len = CHARS.len() as u8;
|
||||
let i = self.u8(..len);
|
||||
CHARS[i as usize] as char
|
||||
}
|
||||
|
||||
/// Generates a random `char` in ranges a-z, A-Z and 0-9.
|
||||
#[inline]
|
||||
pub fn alphanumeric(&mut self) -> char {
|
||||
pub fn alphanumeric(&self) -> char {
|
||||
const CHARS: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
*self.choice(CHARS).unwrap() as char
|
||||
let len = CHARS.len() as u8;
|
||||
let i = self.u8(..len);
|
||||
CHARS[i as usize] as char
|
||||
}
|
||||
|
||||
/// Generates a random `bool`.
|
||||
#[inline]
|
||||
pub fn bool(&mut self) -> bool {
|
||||
pub fn bool(&self) -> bool {
|
||||
self.u8(..) % 2 == 0
|
||||
}
|
||||
|
||||
|
@ -332,7 +320,7 @@ impl Rng {
|
|||
///
|
||||
/// Panics if the base is zero or greater than 36.
|
||||
#[inline]
|
||||
pub fn digit(&mut self, base: u32) -> char {
|
||||
pub fn digit(&self, base: u32) -> char {
|
||||
if base == 0 {
|
||||
panic!("base cannot be zero");
|
||||
}
|
||||
|
@ -348,57 +336,19 @@ impl Rng {
|
|||
}
|
||||
|
||||
/// Generates a random `f32` in range `0..1`.
|
||||
pub fn f32(&mut self) -> f32 {
|
||||
pub fn f32(&self) -> f32 {
|
||||
let b = 32;
|
||||
let f = core::f32::MANTISSA_DIGITS - 1;
|
||||
let f = std::f32::MANTISSA_DIGITS - 1;
|
||||
f32::from_bits((1 << (b - 2)) - (1 << f) + (self.u32(..) >> (b - f))) - 1.0
|
||||
}
|
||||
|
||||
/// Generates a random `f64` in range `0..1`.
|
||||
pub fn f64(&mut self) -> f64 {
|
||||
pub fn f64(&self) -> f64 {
|
||||
let b = 64;
|
||||
let f = core::f64::MANTISSA_DIGITS - 1;
|
||||
let f = std::f64::MANTISSA_DIGITS - 1;
|
||||
f64::from_bits((1 << (b - 2)) - (1 << f) + (self.u64(..) >> (b - f))) - 1.0
|
||||
}
|
||||
|
||||
/// Collects `amount` values at random from the iterator into a vector.
|
||||
///
|
||||
/// The length of the returned vector equals `amount` unless the iterator
|
||||
/// contains insufficient elements, in which case it equals the number of
|
||||
/// elements available.
|
||||
///
|
||||
/// Complexity is `O(n)` where `n` is the length of the iterator.
|
||||
#[cfg(feature = "alloc")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
|
||||
pub fn choose_multiple<T: Iterator>(&mut self, mut source: T, amount: usize) -> Vec<T::Item> {
|
||||
// Adapted from: https://docs.rs/rand/latest/rand/seq/trait.IteratorRandom.html#method.choose_multiple
|
||||
let mut reservoir = Vec::with_capacity(amount);
|
||||
|
||||
reservoir.extend(source.by_ref().take(amount));
|
||||
|
||||
// Continue unless the iterator was exhausted
|
||||
//
|
||||
// note: this prevents iterators that "restart" from causing problems.
|
||||
// If the iterator stops once, then so do we.
|
||||
if reservoir.len() == amount {
|
||||
for (i, elem) in source.enumerate() {
|
||||
let end = i + 1 + amount;
|
||||
let k = self.usize(0..end);
|
||||
if let Some(slot) = reservoir.get_mut(k) {
|
||||
*slot = elem;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// If less than one third of the `Vec` was used, reallocate
|
||||
// so that the unused space is not wasted. There is a corner
|
||||
// case where `amount` was much less than `self.len()`.
|
||||
if reservoir.capacity() > 3 * reservoir.len() {
|
||||
reservoir.shrink_to_fit();
|
||||
}
|
||||
}
|
||||
reservoir
|
||||
}
|
||||
|
||||
rng_integer!(
|
||||
i8,
|
||||
u8,
|
||||
|
@ -466,49 +416,28 @@ impl Rng {
|
|||
|
||||
/// Generates a random `char` in range a-z.
|
||||
#[inline]
|
||||
pub fn lowercase(&mut self) -> char {
|
||||
pub fn lowercase(&self) -> char {
|
||||
const CHARS: &[u8] = b"abcdefghijklmnopqrstuvwxyz";
|
||||
*self.choice(CHARS).unwrap() as char
|
||||
let len = CHARS.len() as u8;
|
||||
let i = self.u8(..len);
|
||||
CHARS[i as usize] as char
|
||||
}
|
||||
|
||||
/// Initializes this generator with the given seed.
|
||||
#[inline]
|
||||
pub fn seed(&mut self, seed: u64) {
|
||||
self.0 = seed;
|
||||
pub fn seed(&self, seed: u64) {
|
||||
self.0.set(seed);
|
||||
}
|
||||
|
||||
/// Gives back **current** seed that is being held by this generator.
|
||||
#[inline]
|
||||
pub fn get_seed(&self) -> u64 {
|
||||
self.0
|
||||
}
|
||||
|
||||
/// Choose an item from an iterator at random.
|
||||
///
|
||||
/// This function may have an unexpected result if the `len()` property of the
|
||||
/// iterator does not match the actual number of items in the iterator. If
|
||||
/// the iterator is empty, this returns `None`.
|
||||
#[inline]
|
||||
pub fn choice<I>(&mut self, iter: I) -> Option<I::Item>
|
||||
where
|
||||
I: IntoIterator,
|
||||
I::IntoIter: ExactSizeIterator,
|
||||
{
|
||||
let mut iter = iter.into_iter();
|
||||
|
||||
// Get the item at a random index.
|
||||
let len = iter.len();
|
||||
if len == 0 {
|
||||
return None;
|
||||
}
|
||||
let index = self.usize(0..len);
|
||||
|
||||
iter.nth(index)
|
||||
self.0.get()
|
||||
}
|
||||
|
||||
/// Shuffles a slice randomly.
|
||||
#[inline]
|
||||
pub fn shuffle<T>(&mut self, slice: &mut [T]) {
|
||||
pub fn shuffle<T>(&self, slice: &mut [T]) {
|
||||
for i in 1..slice.len() {
|
||||
slice.swap(i, self.usize(..=i));
|
||||
}
|
||||
|
@ -516,7 +445,7 @@ impl Rng {
|
|||
|
||||
/// Fill a byte slice with random data.
|
||||
#[inline]
|
||||
pub fn fill(&mut self, slice: &mut [u8]) {
|
||||
pub fn fill(&self, slice: &mut [u8]) {
|
||||
// We fill the slice by chunks of 8 bytes, or one block of
|
||||
// WyRand output per new state.
|
||||
let mut chunks = slice.chunks_exact_mut(core::mem::size_of::<u64>());
|
||||
|
@ -613,16 +542,20 @@ impl Rng {
|
|||
|
||||
/// Generates a random `char` in range A-Z.
|
||||
#[inline]
|
||||
pub fn uppercase(&mut self) -> char {
|
||||
pub fn uppercase(&self) -> char {
|
||||
const CHARS: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
*self.choice(CHARS).unwrap() as char
|
||||
let len = CHARS.len() as u8;
|
||||
let i = self.u8(..len);
|
||||
CHARS[i as usize] as char
|
||||
}
|
||||
|
||||
/// Generates a random `char` in the given range.
|
||||
///
|
||||
/// Panics if the range is empty.
|
||||
#[inline]
|
||||
pub fn char(&mut self, range: impl RangeBounds<char>) -> char {
|
||||
pub fn char(&self, range: impl RangeBounds<char>) -> char {
|
||||
use std::convert::TryFrom;
|
||||
|
||||
let panic_empty_range = || {
|
||||
panic!(
|
||||
"empty range: {:?}..{:?}",
|
||||
|
@ -648,7 +581,7 @@ impl Rng {
|
|||
};
|
||||
|
||||
let high = match range.end_bound() {
|
||||
Bound::Unbounded => core::char::MAX,
|
||||
Bound::Unbounded => std::char::MAX,
|
||||
Bound::Included(&x) => x,
|
||||
Bound::Excluded(&x) => {
|
||||
let scalar = if x as u32 == surrogate_start + surrogate_len {
|
||||
|
@ -677,3 +610,97 @@ impl Rng {
|
|||
val.try_into().unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
/// Initializes the thread-local generator with the given seed.
|
||||
#[inline]
|
||||
pub fn seed(seed: u64) {
|
||||
RNG.with(|rng| rng.seed(seed))
|
||||
}
|
||||
|
||||
/// Gives back **current** seed that is being held by the thread-local generator.
|
||||
#[inline]
|
||||
pub fn get_seed() -> u64 {
|
||||
RNG.with(|rng| rng.get_seed())
|
||||
}
|
||||
|
||||
/// Generates a random `bool`.
|
||||
#[inline]
|
||||
pub fn bool() -> bool {
|
||||
RNG.with(|rng| rng.bool())
|
||||
}
|
||||
|
||||
/// Generates a random `char` in ranges a-z and A-Z.
|
||||
#[inline]
|
||||
pub fn alphabetic() -> char {
|
||||
RNG.with(|rng| rng.alphabetic())
|
||||
}
|
||||
|
||||
/// Generates a random `char` in ranges a-z, A-Z and 0-9.
|
||||
#[inline]
|
||||
pub fn alphanumeric() -> char {
|
||||
RNG.with(|rng| rng.alphanumeric())
|
||||
}
|
||||
|
||||
/// Generates a random `char` in range a-z.
|
||||
#[inline]
|
||||
pub fn lowercase() -> char {
|
||||
RNG.with(|rng| rng.lowercase())
|
||||
}
|
||||
|
||||
/// Generates a random `char` in range A-Z.
|
||||
#[inline]
|
||||
pub fn uppercase() -> char {
|
||||
RNG.with(|rng| rng.uppercase())
|
||||
}
|
||||
|
||||
/// Generates a random digit in the given `base`.
|
||||
///
|
||||
/// Digits are represented by `char`s in ranges 0-9 and a-z.
|
||||
///
|
||||
/// Panics if the base is zero or greater than 36.
|
||||
#[inline]
|
||||
pub fn digit(base: u32) -> char {
|
||||
RNG.with(|rng| rng.digit(base))
|
||||
}
|
||||
|
||||
/// Shuffles a slice randomly.
|
||||
#[inline]
|
||||
pub fn shuffle<T>(slice: &mut [T]) {
|
||||
RNG.with(|rng| rng.shuffle(slice))
|
||||
}
|
||||
|
||||
macro_rules! integer {
|
||||
($t:tt, $doc:tt) => {
|
||||
#[doc = $doc]
|
||||
///
|
||||
/// Panics if the range is empty.
|
||||
#[inline]
|
||||
pub fn $t(range: impl RangeBounds<$t>) -> $t {
|
||||
RNG.with(|rng| rng.$t(range))
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
integer!(u8, "Generates a random `u8` in the given range.");
|
||||
integer!(i8, "Generates a random `i8` in the given range.");
|
||||
integer!(u16, "Generates a random `u16` in the given range.");
|
||||
integer!(i16, "Generates a random `i16` in the given range.");
|
||||
integer!(u32, "Generates a random `u32` in the given range.");
|
||||
integer!(i32, "Generates a random `i32` in the given range.");
|
||||
integer!(u64, "Generates a random `u64` in the given range.");
|
||||
integer!(i64, "Generates a random `i64` in the given range.");
|
||||
integer!(u128, "Generates a random `u128` in the given range.");
|
||||
integer!(i128, "Generates a random `i128` in the given range.");
|
||||
integer!(usize, "Generates a random `usize` in the given range.");
|
||||
integer!(isize, "Generates a random `isize` in the given range.");
|
||||
integer!(char, "Generates a random `char` in the given range.");
|
||||
|
||||
/// Generates a random `f32` in range `0..1`.
|
||||
pub fn f32() -> f32 {
|
||||
RNG.with(|rng| rng.f32())
|
||||
}
|
||||
|
||||
/// Generates a random `f64` in range `0..1`.
|
||||
pub fn f64() -> f64 {
|
||||
RNG.with(|rng| rng.f64())
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ fn u128() {
|
|||
|
||||
#[test]
|
||||
fn fill() {
|
||||
let mut r = fastrand::Rng::new();
|
||||
let r = fastrand::Rng::new();
|
||||
let mut a = [0u8; 64];
|
||||
let mut b = [0u8; 64];
|
||||
|
||||
|
@ -89,7 +89,7 @@ fn fill() {
|
|||
|
||||
#[test]
|
||||
fn rng() {
|
||||
let mut r = fastrand::Rng::new();
|
||||
let r = fastrand::Rng::new();
|
||||
|
||||
assert_ne!(r.u64(..), r.u64(..));
|
||||
|
||||
|
@ -102,8 +102,8 @@ fn rng() {
|
|||
|
||||
#[test]
|
||||
fn rng_init() {
|
||||
let mut a = fastrand::Rng::new();
|
||||
let mut b = fastrand::Rng::new();
|
||||
let a = fastrand::Rng::new();
|
||||
let b = fastrand::Rng::new();
|
||||
assert_ne!(a.u64(..), b.u64(..));
|
||||
|
||||
a.seed(7);
|
||||
|
@ -113,31 +113,8 @@ fn rng_init() {
|
|||
|
||||
#[test]
|
||||
fn with_seed() {
|
||||
let mut a = fastrand::Rng::with_seed(7);
|
||||
let mut b = fastrand::Rng::new();
|
||||
let a = fastrand::Rng::with_seed(7);
|
||||
let b = fastrand::Rng::new();
|
||||
b.seed(7);
|
||||
assert_eq!(a.u64(..), b.u64(..));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn choose_multiple() {
|
||||
let mut a = fastrand::Rng::new();
|
||||
let mut elements = (0..20).collect::<Vec<_>>();
|
||||
|
||||
while !elements.is_empty() {
|
||||
let chosen = a.choose_multiple(0..20, 5);
|
||||
for &x in &chosen {
|
||||
elements.retain(|&y| y != x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn choice() {
|
||||
let items = [1, 4, 9, 5, 2, 3, 6, 7, 8, 0];
|
||||
let mut r = fastrand::Rng::new();
|
||||
|
||||
for item in &items {
|
||||
while r.choice(&items).unwrap() != item {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
{"files":{"AUTHORS":"451a1be16acafff0cb0eaedc49b46063cc6ce087d0c36f6d64d67aa93d20e485","CHANGELOGS.md":"bb587c08dd9b1f04cba934a241a99655f9d7e38bc70e4d45feca95efa09bd799","Cargo.toml":"a64c7ab3a5906d2e7360fb30cc23e5042bd7c22aa640e8e47bb3dad1a3dbf8eb","LICENSE":"2510d4cde8c4e13d8c54b9fe2a9d144daf567ec8d02832f1454e7ca2d58cdda6","README.md":"22b54b9f16ad18144f29e50d1b1f16791c5e8f1afee81265bad9b72f6efb8e62","src/lib.rs":"cc4822f1c4ac7926859045608d91e3f855914468039bffb75bc9b455c0950ab3","src/native.rs":"bd4cd1f888b83a9eaf07f640bef51c4f16138ceb427a685d3ab07152eec53d1c","src/wasm.rs":"c17c7bf8a28fee134444201212d1cf62bff49650f297e42367ec1b7aeaddc7c9","tests/wasm.rs":"1b81ff541bec36bac824a7ec41cd15f68d9919c3c7522290aa003fa4c253e840"},"package":"7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"}
|
|
@ -0,0 +1,2 @@
|
|||
Main developer:
|
||||
* Sébastien Crozet <developer@crozet.re>
|
|
@ -0,0 +1,7 @@
|
|||
# v0.1.12
|
||||
## Added
|
||||
- Add `SystemTime` which works in both native and WASM environments.
|
||||
|
||||
## Modified
|
||||
- The `now` function is always available now: there is no need to enable the `now` feature any more. The `now` feature
|
||||
still exists (but doesn’t do anything) for backwards compatibility.
|
|
@ -0,0 +1,81 @@
|
|||
# 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 = "2018"
|
||||
name = "instant"
|
||||
version = "0.1.12"
|
||||
authors = ["sebcrozet <developer@crozet.re>"]
|
||||
description = "A partial replacement for std::time::Instant that works on WASM too."
|
||||
readme = "README.md"
|
||||
keywords = ["time", "wasm"]
|
||||
license = "BSD-3-Clause"
|
||||
repository = "https://github.com/sebcrozet/instant"
|
||||
[dependencies.cfg-if]
|
||||
version = "1.0"
|
||||
[dev-dependencies.wasm-bindgen-test]
|
||||
version = "0.3"
|
||||
|
||||
[features]
|
||||
inaccurate = []
|
||||
now = []
|
||||
wasm-bindgen = ["js-sys", "wasm-bindgen_rs", "web-sys"]
|
||||
[target.asmjs-unknown-emscripten.dependencies.js-sys]
|
||||
version = "0.3"
|
||||
optional = true
|
||||
|
||||
[target.asmjs-unknown-emscripten.dependencies.stdweb]
|
||||
version = "0.4"
|
||||
optional = true
|
||||
|
||||
[target.asmjs-unknown-emscripten.dependencies.wasm-bindgen_rs]
|
||||
version = "0.2"
|
||||
optional = true
|
||||
package = "wasm-bindgen"
|
||||
|
||||
[target.asmjs-unknown-emscripten.dependencies.web-sys]
|
||||
version = "0.3"
|
||||
features = ["Window", "Performance", "PerformanceTiming"]
|
||||
optional = true
|
||||
[target.wasm32-unknown-emscripten.dependencies.js-sys]
|
||||
version = "0.3"
|
||||
optional = true
|
||||
|
||||
[target.wasm32-unknown-emscripten.dependencies.stdweb]
|
||||
version = "0.4"
|
||||
optional = true
|
||||
|
||||
[target.wasm32-unknown-emscripten.dependencies.wasm-bindgen_rs]
|
||||
version = "0.2"
|
||||
optional = true
|
||||
package = "wasm-bindgen"
|
||||
|
||||
[target.wasm32-unknown-emscripten.dependencies.web-sys]
|
||||
version = "0.3"
|
||||
features = ["Window", "Performance", "PerformanceTiming"]
|
||||
optional = true
|
||||
[target.wasm32-unknown-unknown.dependencies.js-sys]
|
||||
version = "0.3"
|
||||
optional = true
|
||||
|
||||
[target.wasm32-unknown-unknown.dependencies.stdweb]
|
||||
version = "0.4"
|
||||
optional = true
|
||||
|
||||
[target.wasm32-unknown-unknown.dependencies.wasm-bindgen_rs]
|
||||
version = "0.2"
|
||||
optional = true
|
||||
package = "wasm-bindgen"
|
||||
|
||||
[target.wasm32-unknown-unknown.dependencies.web-sys]
|
||||
version = "0.3"
|
||||
features = ["Window", "Performance", "PerformanceTiming"]
|
||||
optional = true
|
|
@ -0,0 +1,27 @@
|
|||
Copyright (c) 2019, Sébastien Crozet
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the author nor the names of its contributors may be used
|
||||
to endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@ -0,0 +1,143 @@
|
|||
# Instant
|
||||
|
||||
If you call `std::time::Instant::now()` on a WASM platform, it will panic. This crate provides a partial
|
||||
replacement for `std::time::Instant` that works on WASM too. This defines the type `instant::Instant` which is:
|
||||
|
||||
* A struct emulating the behavior of **std::time::Instant** if you are targeting `wasm32-unknown-unknown` or `wasm32-unknown-asmjs`
|
||||
**and** you enabled either the `stdweb` or the `wasm-bindgen` feature. This emulation is based on the javascript `performance.now()` function.
|
||||
* A type alias for `std::time::Instant` otherwise.
|
||||
|
||||
|
||||
|
||||
Note that even if the **stdweb** or **wasm-bindgen** feature is enabled, this crate will continue to rely on `std::time::Instant`
|
||||
as long as you are not targeting wasm32. This allows for portable code that will work on both native and WASM platforms.
|
||||
|
||||
This crate also exports the function `instant::now()` which returns a representation of the current time as an `f64`, expressed in milliseconds, in a platform-agnostic way. `instant::now()` will either:
|
||||
|
||||
* Call `performance.now()` when compiling for a WASM platform with the features **stdweb** or **wasm-bindgen** enabled, or using a custom javascript function.
|
||||
* Return the time elapsed since the *Unix Epoch* on *native*, *non-WASM* platforms.
|
||||
|
||||
*Note*: The old feature, `now`, has been deprecated. `instant::now()` is always exported and the `now` feature flag no longer has any effect. It remains listed in `Cargo.toml` to avoid introducing breaking changes and may be removed in future versions.
|
||||
|
||||
## Examples
|
||||
### Using `instant` for a native platform.
|
||||
_Cargo.toml_:
|
||||
```toml
|
||||
[dependencies]
|
||||
instant = "0.1"
|
||||
```
|
||||
|
||||
_main.rs_:
|
||||
```rust
|
||||
fn main() {
|
||||
// Will be the same as `std::time::Instant`.
|
||||
let now = instant::Instant::now();
|
||||
}
|
||||
```
|
||||
|
||||
-----
|
||||
|
||||
### Using `instant` for a WASM platform.
|
||||
This example shows the use of the `stdweb` feature. It would be similar with `wasm-bindgen`.
|
||||
|
||||
_Cargo.toml_:
|
||||
```toml
|
||||
[dependencies]
|
||||
instant = { version = "0.1", features = [ "stdweb" ] }
|
||||
```
|
||||
|
||||
_main.rs_:
|
||||
```rust
|
||||
fn main() {
|
||||
// Will emulate `std::time::Instant` based on `performance.now()`.
|
||||
let now = instant::Instant::now();
|
||||
}
|
||||
```
|
||||
|
||||
-----
|
||||
|
||||
### Using `instant` for a WASM platform where `performance.now()` is not available.
|
||||
This example shows the use of the `inaccurate` feature.
|
||||
|
||||
_Cargo.toml_:
|
||||
```toml
|
||||
[dependencies]
|
||||
instant = { version = "0.1", features = [ "wasm-bindgen", "inaccurate" ] }
|
||||
```
|
||||
|
||||
_main.rs_:
|
||||
```rust
|
||||
fn main() {
|
||||
// Will emulate `std::time::Instant` based on `Date.now()`.
|
||||
let now = instant::Instant::now();
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
-----
|
||||
|
||||
### Using `instant` for any platform enabling a feature transitively.
|
||||
_Cargo.toml_:
|
||||
```toml
|
||||
[features]
|
||||
stdweb = [ "instant/stdweb" ]
|
||||
wasm-bindgen = [ "instant/wasm-bindgen" ]
|
||||
|
||||
[dependencies]
|
||||
instant = "0.1"
|
||||
```
|
||||
|
||||
_lib.rs_:
|
||||
```rust
|
||||
fn my_function() {
|
||||
// Will select the proper implementation depending on the
|
||||
// feature selected by the user.
|
||||
let now = instant::Instant::now();
|
||||
}
|
||||
```
|
||||
|
||||
-----
|
||||
|
||||
### Using `instant::now()`
|
||||
_Cargo.toml_:
|
||||
```toml
|
||||
[features]
|
||||
stdweb = [ "instant/stdweb" ]
|
||||
wasm-bindgen = [ "instant/wasm-bindgen" ]
|
||||
|
||||
[dependencies]
|
||||
instant = "0.1"
|
||||
```
|
||||
|
||||
_lib.rs_:
|
||||
```rust
|
||||
fn my_function() {
|
||||
// Will select the proper implementation depending on the
|
||||
// feature selected by the user.
|
||||
let now_instant = instant::Instant::now();
|
||||
let now_milliseconds = instant::now(); // In milliseconds.
|
||||
}
|
||||
```
|
||||
|
||||
### Using the feature `now` without `stdweb` or `wasm-bindgen`.
|
||||
_Cargo.toml_:
|
||||
```toml
|
||||
[dependencies]
|
||||
instant = "0.1"
|
||||
```
|
||||
|
||||
_lib.rs_:
|
||||
```rust
|
||||
fn my_function() {
|
||||
// Will use the 'now' javascript implementation.
|
||||
let now_instant = instant::Instant::now();
|
||||
let now_milliseconds = instant::now(); // In milliseconds.
|
||||
}
|
||||
```
|
||||
|
||||
_javascript WASM bindings file_:
|
||||
```js
|
||||
function now() {
|
||||
return Date.now() / 1000.0;
|
||||
}
|
||||
```
|
|
@ -0,0 +1,22 @@
|
|||
cfg_if::cfg_if! {
|
||||
if #[cfg(any(
|
||||
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||
target_arch = "asmjs"
|
||||
))] {
|
||||
#[cfg(all(feature = "stdweb", not(feature = "wasm-bindgen")))]
|
||||
#[macro_use]
|
||||
extern crate stdweb;
|
||||
|
||||
mod wasm;
|
||||
pub use wasm::Instant;
|
||||
pub use crate::wasm::now;
|
||||
pub use wasm::SystemTime;
|
||||
} else {
|
||||
mod native;
|
||||
pub use native::Instant;
|
||||
pub use native::now;
|
||||
pub use native::SystemTime;
|
||||
}
|
||||
}
|
||||
|
||||
pub use std::time::Duration;
|
|
@ -0,0 +1,9 @@
|
|||
pub type Instant = std::time::Instant;
|
||||
pub type SystemTime = std::time::SystemTime;
|
||||
|
||||
/// The current time, expressed in milliseconds since the Unix Epoch.
|
||||
pub fn now() -> f64 {
|
||||
std::time::SystemTime::now().duration_since(std::time::SystemTime::UNIX_EPOCH)
|
||||
.expect("System clock was before 1970.")
|
||||
.as_secs_f64() * 1000.0
|
||||
}
|
|
@ -0,0 +1,240 @@
|
|||
use std::cmp::Ordering;
|
||||
use std::ops::{Add, AddAssign, Sub, SubAssign};
|
||||
use std::time::Duration;
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Hash)]
|
||||
pub struct Instant(Duration);
|
||||
|
||||
impl Ord for Instant {
|
||||
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
|
||||
self.partial_cmp(other)
|
||||
.expect("an instant should never be NaN or Inf.")
|
||||
}
|
||||
}
|
||||
impl Eq for Instant {}
|
||||
|
||||
impl Instant {
|
||||
#[inline]
|
||||
pub fn now() -> Self {
|
||||
Instant(duration_from_f64(now()))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn duration_since(&self, earlier: Instant) -> Duration {
|
||||
assert!(
|
||||
earlier.0 <= self.0,
|
||||
"`earlier` cannot be later than `self`."
|
||||
);
|
||||
self.0 - earlier.0
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn elapsed(&self) -> Duration {
|
||||
Self::now().duration_since(*self)
|
||||
}
|
||||
|
||||
/// Returns `Some(t)` where `t` is the time `self + duration` if `t` can be represented as
|
||||
/// `Instant` (which means it's inside the bounds of the underlying data structure), `None`
|
||||
/// otherwise.
|
||||
#[inline]
|
||||
pub fn checked_add(&self, duration: Duration) -> Option<Instant> {
|
||||
self.0.checked_add(duration).map(Instant)
|
||||
}
|
||||
|
||||
/// Returns `Some(t)` where `t` is the time `self - duration` if `t` can be represented as
|
||||
/// `Instant` (which means it's inside the bounds of the underlying data structure), `None`
|
||||
/// otherwise.
|
||||
#[inline]
|
||||
pub fn checked_sub(&self, duration: Duration) -> Option<Instant> {
|
||||
self.0.checked_sub(duration).map(Instant)
|
||||
}
|
||||
|
||||
/// Returns the amount of time elapsed from another instant to this one, or None if that
|
||||
/// instant is later than this one.
|
||||
#[inline]
|
||||
pub fn checked_duration_since(&self, earlier: Instant) -> Option<Duration> {
|
||||
if earlier.0 > self.0 {
|
||||
None
|
||||
} else {
|
||||
Some(self.0 - earlier.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the amount of time elapsed from another instant to this one, or zero duration if
|
||||
/// that instant is later than this one.
|
||||
#[inline]
|
||||
pub fn saturating_duration_since(&self, earlier: Instant) -> Duration {
|
||||
self.checked_duration_since(earlier).unwrap_or_default()
|
||||
}
|
||||
}
|
||||
|
||||
impl Add<Duration> for Instant {
|
||||
type Output = Self;
|
||||
|
||||
#[inline]
|
||||
fn add(self, rhs: Duration) -> Self {
|
||||
Instant(self.0 + rhs)
|
||||
}
|
||||
}
|
||||
|
||||
impl AddAssign<Duration> for Instant {
|
||||
#[inline]
|
||||
fn add_assign(&mut self, rhs: Duration) {
|
||||
self.0 += rhs
|
||||
}
|
||||
}
|
||||
|
||||
impl Sub<Duration> for Instant {
|
||||
type Output = Self;
|
||||
|
||||
#[inline]
|
||||
fn sub(self, rhs: Duration) -> Self {
|
||||
Instant(self.0 - rhs)
|
||||
}
|
||||
}
|
||||
|
||||
impl Sub<Instant> for Instant {
|
||||
type Output = Duration;
|
||||
|
||||
#[inline]
|
||||
fn sub(self, rhs: Instant) -> Duration {
|
||||
self.duration_since(rhs)
|
||||
}
|
||||
}
|
||||
|
||||
impl SubAssign<Duration> for Instant {
|
||||
#[inline]
|
||||
fn sub_assign(&mut self, rhs: Duration) {
|
||||
self.0 -= rhs
|
||||
}
|
||||
}
|
||||
|
||||
fn duration_from_f64(millis: f64) -> Duration {
|
||||
Duration::from_millis(millis.trunc() as u64)
|
||||
+ Duration::from_nanos((millis.fract() * 1.0e6) as u64)
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "stdweb", not(feature = "wasm-bindgen")))]
|
||||
#[allow(unused_results)] // Needed because the js macro triggers it.
|
||||
pub fn now() -> f64 {
|
||||
use stdweb::unstable::TryInto;
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/Performance/now
|
||||
#[cfg(not(feature = "inaccurate"))]
|
||||
let v = js! { return performance.now(); };
|
||||
#[cfg(feature = "inaccurate")]
|
||||
let v = js! { return Date.now(); };
|
||||
v.try_into().unwrap()
|
||||
}
|
||||
|
||||
#[cfg(feature = "wasm-bindgen")]
|
||||
pub fn now() -> f64 {
|
||||
#[cfg(not(feature = "inaccurate"))]
|
||||
let now = {
|
||||
use wasm_bindgen_rs::prelude::*;
|
||||
use wasm_bindgen_rs::JsCast;
|
||||
js_sys::Reflect::get(&js_sys::global(), &JsValue::from_str("performance"))
|
||||
.expect("failed to get performance from global object")
|
||||
.unchecked_into::<web_sys::Performance>()
|
||||
.now()
|
||||
};
|
||||
#[cfg(feature = "inaccurate")]
|
||||
let now = js_sys::Date::now();
|
||||
now
|
||||
}
|
||||
|
||||
// The JS now function is in a module so it won't have to be renamed
|
||||
#[cfg(not(any(feature = "wasm-bindgen", feature = "stdweb")))]
|
||||
mod js {
|
||||
extern "C" {
|
||||
#[cfg(not(target_os = "emscripten"))]
|
||||
pub fn now() -> f64;
|
||||
#[cfg(target_os = "emscripten")]
|
||||
pub fn _emscripten_get_now() -> f64;
|
||||
}
|
||||
}
|
||||
// Make the unsafe extern function "safe" so it can be called like the other 'now' functions
|
||||
#[cfg(not(any(feature = "wasm-bindgen", feature = "stdweb")))]
|
||||
pub fn now() -> f64 {
|
||||
#[cfg(not(target_os = "emscripten"))]
|
||||
return unsafe { js::now() };
|
||||
#[cfg(target_os = "emscripten")]
|
||||
return unsafe { js::_emscripten_get_now() };
|
||||
}
|
||||
|
||||
/// Returns the number of millisecods elapsed since January 1, 1970 00:00:00 UTC.
|
||||
#[cfg(any(feature = "wasm-bindgen", feature = "stdweb"))]
|
||||
fn get_time() -> f64 {
|
||||
#[cfg(feature = "wasm-bindgen")]
|
||||
return js_sys::Date::now();
|
||||
#[cfg(all(feature = "stdweb", not(feature = "wasm-bindgen")))]
|
||||
{
|
||||
let v = js! { return Date.now(); };
|
||||
return v.try_into().unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)]
|
||||
pub struct SystemTime(f64);
|
||||
|
||||
impl SystemTime {
|
||||
pub const UNIX_EPOCH: SystemTime = SystemTime(0.0);
|
||||
|
||||
pub fn now() -> SystemTime {
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(any(feature = "wasm-bindgen", feature = "stdweb"))] {
|
||||
SystemTime(get_time())
|
||||
} else {
|
||||
SystemTime(now())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn duration_since(&self, earlier: SystemTime) -> Result<Duration, ()> {
|
||||
let dur_ms = self.0 - earlier.0;
|
||||
if dur_ms < 0.0 {
|
||||
return Err(());
|
||||
}
|
||||
Ok(Duration::from_millis(dur_ms as u64))
|
||||
}
|
||||
|
||||
pub fn elapsed(&self) -> Result<Duration, ()> {
|
||||
self.duration_since(SystemTime::now())
|
||||
}
|
||||
|
||||
pub fn checked_add(&self, duration: Duration) -> Option<SystemTime> {
|
||||
Some(*self + duration)
|
||||
}
|
||||
|
||||
pub fn checked_sub(&self, duration: Duration) -> Option<SystemTime> {
|
||||
Some(*self - duration)
|
||||
}
|
||||
}
|
||||
|
||||
impl Add<Duration> for SystemTime {
|
||||
type Output = SystemTime;
|
||||
|
||||
fn add(self, other: Duration) -> SystemTime {
|
||||
SystemTime(self.0 + other.as_millis() as f64)
|
||||
}
|
||||
}
|
||||
|
||||
impl Sub<Duration> for SystemTime {
|
||||
type Output = SystemTime;
|
||||
|
||||
fn sub(self, other: Duration) -> SystemTime {
|
||||
SystemTime(self.0 - other.as_millis() as f64)
|
||||
}
|
||||
}
|
||||
|
||||
impl AddAssign<Duration> for SystemTime {
|
||||
fn add_assign(&mut self, rhs: Duration) {
|
||||
*self = *self + rhs;
|
||||
}
|
||||
}
|
||||
|
||||
impl SubAssign<Duration> for SystemTime {
|
||||
fn sub_assign(&mut self, rhs: Duration) {
|
||||
*self = *self - rhs;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
extern crate wasm_bindgen_test;
|
||||
|
||||
use instant::{Instant, SystemTime};
|
||||
use std::time::Duration;
|
||||
use wasm_bindgen_test::*;
|
||||
|
||||
wasm_bindgen_test_configure!(run_in_browser);
|
||||
// run these tests using: wasm-pack test --chrome --headless -- --features wasm-bindgen
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn test_instant_now() {
|
||||
let now = Instant::now();
|
||||
#[cfg(feature = "inaccurate")]
|
||||
while now.elapsed().as_millis() == 0 {}
|
||||
#[cfg(not(feature = "inaccurate"))]
|
||||
assert!(now.elapsed().as_nanos() > 0);
|
||||
}
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn test_duration() {
|
||||
let now = Instant::now();
|
||||
let one_sec = Duration::from_secs(1);
|
||||
assert!(now.elapsed() < one_sec);
|
||||
}
|
||||
|
||||
// Duration::new will overflow when you have u64::MAX seconds and one billion nanoseconds.
|
||||
// <https://doc.rust-lang.org/std/time/struct.Duration.html#method.new>
|
||||
const ONE_BILLION: u32 = 1_000_000_000;
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn test_checked_add() {
|
||||
let now = Instant::now();
|
||||
|
||||
assert!(now.checked_add(Duration::from_millis(1)).is_some());
|
||||
assert_eq!(
|
||||
None,
|
||||
now.checked_add(Duration::new(u64::MAX, ONE_BILLION - 1))
|
||||
);
|
||||
}
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn test_checked_sub() {
|
||||
let now = Instant::now();
|
||||
|
||||
assert!(now.checked_sub(Duration::from_millis(1)).is_some());
|
||||
assert!(now
|
||||
.checked_sub(Duration::new(u64::MAX, ONE_BILLION - 1))
|
||||
.is_none());
|
||||
}
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn test_system_time() {
|
||||
assert!(SystemTime::UNIX_EPOCH
|
||||
.duration_since(SystemTime::now())
|
||||
.is_err());
|
||||
}
|
||||
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -11,7 +11,7 @@
|
|||
|
||||
[package]
|
||||
name = "libc"
|
||||
version = "0.2.148"
|
||||
version = "0.2.139"
|
||||
authors = ["The Rust Project Developers"]
|
||||
build = "build.rs"
|
||||
exclude = [
|
||||
|
@ -42,119 +42,10 @@ license = "MIT OR Apache-2.0"
|
|||
repository = "https://github.com/rust-lang/libc"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
cargo-args = ["-Zbuild-std=core"]
|
||||
default-target = "x86_64-unknown-linux-gnu"
|
||||
features = [
|
||||
"const-extern-fn",
|
||||
"extra_traits",
|
||||
]
|
||||
targets = [
|
||||
"aarch64-apple-ios",
|
||||
"aarch64-linux-android",
|
||||
"aarch64-pc-windows-msvc",
|
||||
"aarch64-unknown-freebsd",
|
||||
"aarch64-unknown-fuchsia",
|
||||
"aarch64-unknown-hermit",
|
||||
"aarch64-unknown-linux-gnu",
|
||||
"aarch64-unknown-linux-musl",
|
||||
"aarch64-unknown-netbsd",
|
||||
"aarch64-unknown-openbsd",
|
||||
"aarch64-wrs-vxworks",
|
||||
"arm-linux-androideabi",
|
||||
"arm-unknown-linux-gnueabi",
|
||||
"arm-unknown-linux-gnueabihf",
|
||||
"arm-unknown-linux-musleabi",
|
||||
"arm-unknown-linux-musleabihf",
|
||||
"armebv7r-none-eabi",
|
||||
"armebv7r-none-eabihf",
|
||||
"armv5te-unknown-linux-gnueabi",
|
||||
"armv5te-unknown-linux-musleabi",
|
||||
"armv7-linux-androideabi",
|
||||
"armv7-unknown-linux-gnueabihf",
|
||||
"armv7-unknown-linux-musleabihf",
|
||||
"armv7-wrs-vxworks-eabihf",
|
||||
"armv7r-none-eabi",
|
||||
"armv7r-none-eabihf",
|
||||
"hexagon-unknown-linux-musl",
|
||||
"i586-pc-windows-msvc",
|
||||
"i586-unknown-linux-gnu",
|
||||
"i586-unknown-linux-musl",
|
||||
"i686-linux-android",
|
||||
"i686-pc-windows-gnu",
|
||||
"i686-pc-windows-msvc",
|
||||
"i686-pc-windows-msvc",
|
||||
"i686-unknown-freebsd",
|
||||
"i686-unknown-haiku",
|
||||
"i686-unknown-linux-gnu",
|
||||
"i686-unknown-linux-musl",
|
||||
"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",
|
||||
"nvptx64-nvidia-cuda",
|
||||
"powerpc-unknown-linux-gnu",
|
||||
"powerpc-unknown-linux-gnuspe",
|
||||
"powerpc-unknown-netbsd",
|
||||
"powerpc-wrs-vxworks",
|
||||
"powerpc-wrs-vxworks-spe",
|
||||
"powerpc64-unknown-freebsd",
|
||||
"powerpc64-unknown-linux-gnu",
|
||||
"powerpc64-wrs-vxworks",
|
||||
"powerpc64le-unknown-linux-gnu",
|
||||
"riscv32gc-unknown-linux-gnu",
|
||||
"riscv32i-unknown-none-elf",
|
||||
"riscv32imac-unknown-none-elf",
|
||||
"riscv32imc-unknown-none-elf",
|
||||
"riscv64gc-unknown-freebsd",
|
||||
"riscv64gc-unknown-linux-gnu",
|
||||
"riscv64gc-unknown-linux-musl",
|
||||
"riscv64gc-unknown-none-elf",
|
||||
"riscv64imac-unknown-none-elf",
|
||||
"s390x-unknown-linux-gnu",
|
||||
"s390x-unknown-linux-musl",
|
||||
"sparc-unknown-linux-gnu",
|
||||
"sparc64-unknown-linux-gnu",
|
||||
"sparc64-unknown-netbsd",
|
||||
"sparcv9-sun-solaris",
|
||||
"thumbv6m-none-eabi",
|
||||
"thumbv7em-none-eabi",
|
||||
"thumbv7em-none-eabihf",
|
||||
"thumbv7m-none-eabi",
|
||||
"thumbv7neon-linux-androideabi",
|
||||
"thumbv7neon-unknown-linux-gnueabihf",
|
||||
"wasm32-unknown-emscripten",
|
||||
"wasm32-unknown-unknown",
|
||||
"wasm32-wasi",
|
||||
"x86_64-apple-darwin",
|
||||
"x86_64-apple-ios",
|
||||
"x86_64-fortanix-unknown-sgx",
|
||||
"x86_64-linux-android",
|
||||
"x86_64-pc-solaris",
|
||||
"x86_64-pc-windows-gnu",
|
||||
"x86_64-pc-windows-msvc",
|
||||
"x86_64-unknown-dragonfly",
|
||||
"x86_64-unknown-freebsd",
|
||||
"x86_64-unknown-fuchsia",
|
||||
"x86_64-unknown-haiku",
|
||||
"x86_64-unknown-hermit",
|
||||
"x86_64-unknown-illumos",
|
||||
"x86_64-unknown-l4re-uclibc",
|
||||
"x86_64-unknown-linux-gnu",
|
||||
"x86_64-unknown-linux-gnux32",
|
||||
"x86_64-unknown-linux-musl",
|
||||
"x86_64-unknown-netbsd",
|
||||
"x86_64-unknown-openbsd",
|
||||
"x86_64-unknown-redox",
|
||||
"x86_64-wrs-vxworks",
|
||||
]
|
||||
|
||||
[dependencies.rustc-std-workspace-core]
|
||||
version = "1.0.0"
|
||||
|
|
|
@ -14,7 +14,7 @@ of all the exported APIs match the platform that libc is compiled for.
|
|||
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
|
||||
[rfc]: https://github.com/rust-lang/rfcs/blob/master/text/1291-promote-libc.md
|
||||
|
||||
## Usage
|
||||
|
||||
|
@ -60,10 +60,10 @@ newer Rust features are only available on newer Rust toolchains:
|
|||
|
||||
## Platform support
|
||||
|
||||
[Platform-specific documentation (HEAD)][docs.head].
|
||||
[Platform-specific documentation (master branch)][docs.master].
|
||||
|
||||
See
|
||||
[`ci/build.sh`](https://github.com/rust-lang/libc/blob/HEAD/ci/build.sh)
|
||||
[`ci/build.sh`](https://github.com/rust-lang/libc/blob/master/ci/build.sh)
|
||||
for the platforms on which `libc` is guaranteed to build for each Rust
|
||||
toolchain. The test-matrix at [GitHub Actions] and [Cirrus CI] show the
|
||||
platforms in which `libc` tests are run.
|
||||
|
@ -75,10 +75,10 @@ platforms in which `libc` tests are run.
|
|||
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))
|
||||
([LICENSE-APACHE](https://github.com/rust-lang/libc/blob/master/LICENSE-APACHE))
|
||||
|
||||
* [MIT License](https://opensource.org/licenses/MIT)
|
||||
([LICENSE-MIT](https://github.com/rust-lang/libc/blob/HEAD/LICENSE-MIT))
|
||||
([LICENSE-MIT](https://github.com/rust-lang/libc/blob/master/LICENSE-MIT))
|
||||
|
||||
at your option.
|
||||
|
||||
|
@ -87,7 +87,7 @@ at your option.
|
|||
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
|
||||
[contributing instructions]: https://github.com/rust-lang/libc/blob/master/CONTRIBUTING.md
|
||||
|
||||
Contributions in any form (issues, pull requests, etc.) to this project
|
||||
must adhere to Rust's [Code of Conduct].
|
||||
|
@ -107,4 +107,4 @@ dual licensed as above, without any additional terms or conditions.
|
|||
[Documentation]: https://docs.rs/libc/badge.svg
|
||||
[docs.rs]: https://docs.rs/libc
|
||||
[License]: https://img.shields.io/crates/l/libc.svg
|
||||
[docs.head]: https://rust-lang.github.io/libc/#platform-specific-documentation
|
||||
[docs.master]: https://rust-lang.github.io/libc/#platform-specific-documentation
|
||||
|
|
|
@ -1,45 +1,6 @@
|
|||
use std::env;
|
||||
use std::process::Command;
|
||||
use std::str;
|
||||
use std::string::String;
|
||||
|
||||
// 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: &'static [&'static str] = &[
|
||||
"emscripten_new_stat_abi",
|
||||
"freebsd10",
|
||||
"freebsd11",
|
||||
"freebsd12",
|
||||
"freebsd13",
|
||||
"freebsd14",
|
||||
"libc_align",
|
||||
"libc_cfg_target_vendor",
|
||||
"libc_const_extern_fn",
|
||||
"libc_const_extern_fn_unstable",
|
||||
"libc_const_size_of",
|
||||
"libc_core_cvoid",
|
||||
"libc_deny_warnings",
|
||||
"libc_int128",
|
||||
"libc_long_array",
|
||||
"libc_non_exhaustive",
|
||||
"libc_packedN",
|
||||
"libc_priv_mod_use",
|
||||
"libc_ptr_addr_of",
|
||||
"libc_thread_local",
|
||||
"libc_underscore_const_names",
|
||||
"libc_union",
|
||||
];
|
||||
|
||||
// Extra values to allow for check-cfg.
|
||||
const CHECK_CFG_EXTRA: &'static [(&'static str, &'static [&'static str])] = &[
|
||||
("target_os", &["switch", "aix", "ohos"]),
|
||||
("target_env", &["illumos", "wasi", "aix", "ohos"]),
|
||||
(
|
||||
"target_arch",
|
||||
&["loongarch64", "mips32r6", "mips64r6", "csky"],
|
||||
),
|
||||
];
|
||||
|
||||
fn main() {
|
||||
// Avoid unnecessary re-building.
|
||||
|
@ -50,7 +11,6 @@ fn main() {
|
|||
let align_cargo_feature = env::var("CARGO_FEATURE_ALIGN").is_ok();
|
||||
let const_extern_fn_cargo_feature = env::var("CARGO_FEATURE_CONST_EXTERN_FN").is_ok();
|
||||
let libc_ci = env::var("LIBC_CI").is_ok();
|
||||
let libc_check_cfg = env::var("LIBC_CHECK_CFG").is_ok();
|
||||
|
||||
if env::var("CARGO_FEATURE_USE_STD").is_ok() {
|
||||
println!(
|
||||
|
@ -65,113 +25,89 @@ fn main() {
|
|||
// On CI, we detect the actual FreeBSD version and match its ABI exactly,
|
||||
// running tests to ensure that the ABI is correct.
|
||||
match which_freebsd() {
|
||||
Some(10) if libc_ci || rustc_dep_of_std => set_cfg("freebsd10"),
|
||||
Some(11) if libc_ci => set_cfg("freebsd11"),
|
||||
Some(12) if libc_ci => set_cfg("freebsd12"),
|
||||
Some(13) if libc_ci => set_cfg("freebsd13"),
|
||||
Some(14) if libc_ci => set_cfg("freebsd14"),
|
||||
Some(_) | None => set_cfg("freebsd11"),
|
||||
Some(10) if libc_ci || rustc_dep_of_std => {
|
||||
println!("cargo:rustc-cfg=freebsd10")
|
||||
}
|
||||
|
||||
match emcc_version_code() {
|
||||
Some(v) if (v >= 30142) => set_cfg("emscripten_new_stat_abi"),
|
||||
// Non-Emscripten or version < 3.1.42.
|
||||
Some(_) | None => (),
|
||||
Some(11) if libc_ci => println!("cargo:rustc-cfg=freebsd11"),
|
||||
Some(12) if libc_ci => println!("cargo:rustc-cfg=freebsd12"),
|
||||
Some(13) if libc_ci => println!("cargo:rustc-cfg=freebsd13"),
|
||||
Some(14) if libc_ci => println!("cargo:rustc-cfg=freebsd14"),
|
||||
Some(_) | None => println!("cargo:rustc-cfg=freebsd11"),
|
||||
}
|
||||
|
||||
// On CI: deny all warnings
|
||||
if libc_ci {
|
||||
set_cfg("libc_deny_warnings");
|
||||
println!("cargo:rustc-cfg=libc_deny_warnings");
|
||||
}
|
||||
|
||||
// Rust >= 1.15 supports private module use:
|
||||
if rustc_minor_ver >= 15 || rustc_dep_of_std {
|
||||
set_cfg("libc_priv_mod_use");
|
||||
println!("cargo:rustc-cfg=libc_priv_mod_use");
|
||||
}
|
||||
|
||||
// Rust >= 1.19 supports unions:
|
||||
if rustc_minor_ver >= 19 || rustc_dep_of_std {
|
||||
set_cfg("libc_union");
|
||||
println!("cargo:rustc-cfg=libc_union");
|
||||
}
|
||||
|
||||
// Rust >= 1.24 supports const mem::size_of:
|
||||
if rustc_minor_ver >= 24 || rustc_dep_of_std {
|
||||
set_cfg("libc_const_size_of");
|
||||
println!("cargo:rustc-cfg=libc_const_size_of");
|
||||
}
|
||||
|
||||
// Rust >= 1.25 supports repr(align):
|
||||
if rustc_minor_ver >= 25 || rustc_dep_of_std || align_cargo_feature {
|
||||
set_cfg("libc_align");
|
||||
println!("cargo:rustc-cfg=libc_align");
|
||||
}
|
||||
|
||||
// Rust >= 1.26 supports i128 and u128:
|
||||
if rustc_minor_ver >= 26 || rustc_dep_of_std {
|
||||
set_cfg("libc_int128");
|
||||
println!("cargo:rustc-cfg=libc_int128");
|
||||
}
|
||||
|
||||
// Rust >= 1.30 supports `core::ffi::c_void`, so libc can just re-export it.
|
||||
// Otherwise, it defines an incompatible type to retaining
|
||||
// backwards-compatibility.
|
||||
if rustc_minor_ver >= 30 || rustc_dep_of_std {
|
||||
set_cfg("libc_core_cvoid");
|
||||
println!("cargo:rustc-cfg=libc_core_cvoid");
|
||||
}
|
||||
|
||||
// Rust >= 1.33 supports repr(packed(N)) and cfg(target_vendor).
|
||||
if rustc_minor_ver >= 33 || rustc_dep_of_std {
|
||||
set_cfg("libc_packedN");
|
||||
set_cfg("libc_cfg_target_vendor");
|
||||
println!("cargo:rustc-cfg=libc_packedN");
|
||||
println!("cargo:rustc-cfg=libc_cfg_target_vendor");
|
||||
}
|
||||
|
||||
// Rust >= 1.40 supports #[non_exhaustive].
|
||||
if rustc_minor_ver >= 40 || rustc_dep_of_std {
|
||||
set_cfg("libc_non_exhaustive");
|
||||
}
|
||||
|
||||
// Rust >= 1.47 supports long array:
|
||||
if rustc_minor_ver >= 47 || rustc_dep_of_std {
|
||||
set_cfg("libc_long_array");
|
||||
println!("cargo:rustc-cfg=libc_non_exhaustive");
|
||||
}
|
||||
|
||||
if rustc_minor_ver >= 51 || rustc_dep_of_std {
|
||||
set_cfg("libc_ptr_addr_of");
|
||||
println!("cargo:rustc-cfg=libc_ptr_addr_of");
|
||||
}
|
||||
|
||||
// Rust >= 1.37.0 allows underscores as anonymous constant names.
|
||||
if rustc_minor_ver >= 37 || rustc_dep_of_std {
|
||||
set_cfg("libc_underscore_const_names");
|
||||
println!("cargo:rustc-cfg=libc_underscore_const_names");
|
||||
}
|
||||
|
||||
// #[thread_local] is currently unstable
|
||||
if rustc_dep_of_std {
|
||||
set_cfg("libc_thread_local");
|
||||
println!("cargo:rustc-cfg=libc_thread_local");
|
||||
}
|
||||
|
||||
// Rust >= 1.62.0 allows to use `const_extern_fn` for "Rust" and "C".
|
||||
if rustc_minor_ver >= 62 {
|
||||
set_cfg("libc_const_extern_fn");
|
||||
println!("cargo:rustc-cfg=libc_const_extern_fn");
|
||||
} else {
|
||||
// Rust < 1.62.0 requires a crate feature and feature gate.
|
||||
if const_extern_fn_cargo_feature {
|
||||
if !is_nightly || rustc_minor_ver < 40 {
|
||||
panic!("const-extern-fn requires a nightly compiler >= 1.40");
|
||||
}
|
||||
set_cfg("libc_const_extern_fn_unstable");
|
||||
set_cfg("libc_const_extern_fn");
|
||||
}
|
||||
}
|
||||
|
||||
// check-cfg is a nightly cargo/rustc feature to warn when unknown cfgs are used across the
|
||||
// codebase. libc can configure it if the appropriate environment variable is passed. Since
|
||||
// rust-lang/rust enforces it, this is useful when using a custom libc fork there.
|
||||
//
|
||||
// https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg
|
||||
if libc_check_cfg {
|
||||
for cfg in ALLOWED_CFGS {
|
||||
println!("cargo:rustc-check-cfg=values({})", cfg);
|
||||
}
|
||||
for &(name, values) in CHECK_CFG_EXTRA {
|
||||
let values = values.join("\",\"");
|
||||
println!("cargo:rustc-check-cfg=values({},\"{}\")", name, values);
|
||||
println!("cargo:rustc-cfg=libc_const_extern_fn_unstable");
|
||||
println!("cargo:rustc-cfg=libc_const_extern_fn");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -192,13 +128,6 @@ fn rustc_minor_nightly() -> (u32, bool) {
|
|||
.output()
|
||||
.ok()
|
||||
.expect("Failed to get rustc version");
|
||||
if !output.status.success() {
|
||||
panic!(
|
||||
"failed to run rustc: {}",
|
||||
String::from_utf8_lossy(output.stderr.as_slice())
|
||||
);
|
||||
}
|
||||
|
||||
let version = otry!(str::from_utf8(&output.stdout).ok());
|
||||
let mut pieces = version.split('.');
|
||||
|
||||
|
@ -247,37 +176,3 @@ fn which_freebsd() -> Option<i32> {
|
|||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn emcc_version_code() -> Option<u64> {
|
||||
let output = std::process::Command::new("emcc")
|
||||
.arg("-dumpversion")
|
||||
.output()
|
||||
.ok();
|
||||
if output.is_none() {
|
||||
return None;
|
||||
}
|
||||
let output = output.unwrap();
|
||||
if !output.status.success() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let stdout = String::from_utf8(output.stdout).ok();
|
||||
if stdout.is_none() {
|
||||
return None;
|
||||
}
|
||||
let version = stdout.unwrap();
|
||||
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)
|
||||
}
|
||||
|
||||
fn set_cfg(cfg: &str) {
|
||||
if !ALLOWED_CFGS.contains(&cfg) {
|
||||
panic!("trying to set cfg {}, but it is not in ALLOWED_CFGS", cfg);
|
||||
}
|
||||
println!("cargo:rustc-cfg={}", cfg);
|
||||
}
|
||||
|
|
|
@ -62,6 +62,5 @@ s! {
|
|||
}
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
|
|
@ -2602,7 +2602,6 @@ pub const PR_SET_MM_MAP: ::c_int = 14;
|
|||
pub const PR_SET_MM_MAP_SIZE: ::c_int = 15;
|
||||
|
||||
pub const PR_SET_PTRACER: ::c_int = 0x59616d61;
|
||||
pub const PR_SET_PTRACER_ANY: ::c_ulong = 0xffffffffffffffff;
|
||||
|
||||
pub const PR_SET_CHILD_SUBREAPER: ::c_int = 36;
|
||||
pub const PR_GET_CHILD_SUBREAPER: ::c_int = 37;
|
||||
|
@ -3271,7 +3270,7 @@ f! {
|
|||
as ::c_uint
|
||||
}
|
||||
|
||||
pub {const} fn CMSG_LEN(len: ::c_uint) -> ::c_uint {
|
||||
pub fn CMSG_LEN(len: ::c_uint) -> ::c_uint {
|
||||
(CMSG_ALIGN(::mem::size_of::<cmsghdr>()) + len as ::size_t) as ::c_uint
|
||||
}
|
||||
}
|
||||
|
@ -4260,9 +4259,6 @@ cfg_if! {
|
|||
} else if #[cfg(any(target_arch = "x86_64"))] {
|
||||
mod x86_64;
|
||||
pub use self::x86_64::*;
|
||||
} else if #[cfg(any(target_arch = "riscv64"))] {
|
||||
mod riscv64;
|
||||
pub use self::riscv64::*;
|
||||
} else {
|
||||
// Unknown target_arch
|
||||
}
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
// From psABI Calling Convention for RV64
|
||||
pub type c_char = u8;
|
||||
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: ::dev_t,
|
||||
pub st_ino: ::ino_t,
|
||||
pub st_nlink: ::nlink_t,
|
||||
pub st_mode: ::mode_t,
|
||||
pub st_uid: ::uid_t,
|
||||
pub st_gid: ::gid_t,
|
||||
__pad0: ::c_int,
|
||||
pub st_rdev: ::dev_t,
|
||||
pub st_size: ::off_t,
|
||||
pub st_blksize: ::blksize_t,
|
||||
pub st_blocks: ::blkcnt_t,
|
||||
pub st_atime: ::time_t,
|
||||
pub st_atime_nsec: ::c_long,
|
||||
pub st_mtime: ::time_t,
|
||||
pub st_mtime_nsec: ::c_long,
|
||||
pub st_ctime: ::time_t,
|
||||
pub st_ctime_nsec: ::c_long,
|
||||
__unused: [::c_long; 3],
|
||||
}
|
||||
|
||||
// Not actually used, IPC calls just return ENOSYS
|
||||
pub struct ipc_perm {
|
||||
pub __ipc_perm_key: ::key_t,
|
||||
pub uid: ::uid_t,
|
||||
pub gid: ::gid_t,
|
||||
pub cuid: ::uid_t,
|
||||
pub cgid: ::gid_t,
|
||||
pub mode: ::mode_t,
|
||||
pub __seq: ::c_ushort,
|
||||
__unused1: ::c_ulong,
|
||||
__unused2: ::c_ulong,
|
||||
}
|
||||
}
|
|
@ -151,12 +151,6 @@ cfg_if! {
|
|||
|
||||
mod wasi;
|
||||
pub use wasi::*;
|
||||
} else if #[cfg(target_os = "xous")] {
|
||||
mod fixed_width_ints;
|
||||
pub use fixed_width_ints::*;
|
||||
|
||||
mod xous;
|
||||
pub use xous::*;
|
||||
} else {
|
||||
// non-supported targets: empty...
|
||||
}
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,644 +0,0 @@
|
|||
pub type c_long = i64;
|
||||
pub type c_ulong = u64;
|
||||
|
||||
s! {
|
||||
pub struct sigset_t {
|
||||
pub ss_set: [c_ulong; 4],
|
||||
}
|
||||
|
||||
pub struct fd_set {
|
||||
pub fds_bits: [c_long; 1024],
|
||||
}
|
||||
|
||||
pub struct flock {
|
||||
pub l_type: ::c_short,
|
||||
pub l_whence: ::c_short,
|
||||
pub l_sysid: ::c_uint,
|
||||
pub l_pid: ::pid_t,
|
||||
pub l_vfs: ::c_int,
|
||||
pub l_start: ::off_t,
|
||||
pub l_len: ::off_t,
|
||||
}
|
||||
|
||||
pub struct statvfs {
|
||||
pub f_bsize: ::c_ulong,
|
||||
pub f_frsize: ::c_ulong,
|
||||
pub f_blocks: ::fsblkcnt_t,
|
||||
pub f_bfree: ::fsblkcnt_t,
|
||||
pub f_bavail: ::fsblkcnt_t,
|
||||
pub f_files: ::fsfilcnt_t,
|
||||
pub f_ffree: ::fsfilcnt_t,
|
||||
pub f_favail: ::fsfilcnt_t,
|
||||
pub f_fsid: ::c_ulong,
|
||||
pub f_basetype: [::c_char; 16],
|
||||
pub f_flag: ::c_ulong,
|
||||
pub f_namemax: ::c_ulong,
|
||||
pub f_fstr: [::c_char; 32],
|
||||
pub f_filler: [::c_ulong; 16]
|
||||
}
|
||||
|
||||
pub struct pthread_rwlock_t {
|
||||
__rw_word: [::c_long; 10],
|
||||
}
|
||||
|
||||
pub struct pthread_cond_t {
|
||||
__cv_word: [::c_long; 6],
|
||||
}
|
||||
|
||||
pub struct pthread_mutex_t {
|
||||
__mt_word: [::c_long; 8],
|
||||
}
|
||||
|
||||
pub struct stat {
|
||||
pub st_dev: ::dev_t,
|
||||
pub st_ino: ::ino_t,
|
||||
pub st_mode: ::mode_t,
|
||||
pub st_nlink: ::nlink_t,
|
||||
pub st_flag: ::c_ushort,
|
||||
pub st_uid: ::uid_t,
|
||||
pub st_gid: ::gid_t,
|
||||
pub st_rdev: ::dev_t,
|
||||
pub st_ssize: ::c_int,
|
||||
pub st_atime: ::st_timespec,
|
||||
pub st_mtime: ::st_timespec,
|
||||
pub st_ctime: ::st_timespec,
|
||||
pub st_blksize: ::blksize_t,
|
||||
pub st_blocks: ::blkcnt_t,
|
||||
pub st_vfstype: ::c_int,
|
||||
pub st_vfs: ::c_uint,
|
||||
pub st_type: ::c_uint,
|
||||
pub st_gen: ::c_uint,
|
||||
pub st_reserved: [::c_uint; 9],
|
||||
pub st_padto_ll: ::c_uint,
|
||||
pub st_size: ::off_t,
|
||||
}
|
||||
|
||||
pub struct statfs {
|
||||
pub f_version: ::c_int,
|
||||
pub f_type: ::c_int,
|
||||
pub f_bsize: ::c_ulong,
|
||||
pub f_blocks: ::fsblkcnt_t,
|
||||
pub f_bfree: ::fsblkcnt_t,
|
||||
pub f_bavail: ::fsblkcnt_t,
|
||||
pub f_files: ::fsblkcnt_t,
|
||||
pub f_ffree: ::fsblkcnt_t,
|
||||
pub f_fsid: ::fsid64_t,
|
||||
pub f_vfstype: ::c_int,
|
||||
pub f_fsize: ::c_ulong,
|
||||
pub f_vfsnumber: ::c_int,
|
||||
pub f_vfsoff: ::c_int,
|
||||
pub f_vfslen: ::c_int,
|
||||
pub f_vfsvers: ::c_int,
|
||||
pub f_fname: [::c_char; 32],
|
||||
pub f_fpack: [::c_char; 32],
|
||||
pub f_name_max: ::c_int,
|
||||
}
|
||||
|
||||
pub struct aiocb {
|
||||
pub aio_lio_opcode: ::c_int,
|
||||
pub aio_fildes: ::c_int,
|
||||
pub aio_word1: ::c_int,
|
||||
pub aio_offset: ::off_t,
|
||||
pub aio_buf: *mut ::c_void,
|
||||
pub aio_return: ::ssize_t,
|
||||
pub aio_errno: ::c_int,
|
||||
pub aio_nbytes: ::size_t,
|
||||
pub aio_reqprio: ::c_int,
|
||||
pub aio_sigevent: ::sigevent,
|
||||
pub aio_word2: ::c_int,
|
||||
pub aio_fp: ::c_int,
|
||||
pub aio_handle: *mut aiocb,
|
||||
pub aio_reserved: [::c_uint; 2],
|
||||
pub aio_sigev_tid: c_long,
|
||||
}
|
||||
|
||||
pub struct ucontext_t {
|
||||
pub __sc_onstack: ::c_int,
|
||||
pub uc_sigmask: ::sigset_t,
|
||||
pub __sc_uerror: ::c_int,
|
||||
pub uc_mcontext: ::mcontext_t,
|
||||
pub uc_link: *mut ucontext_t,
|
||||
pub uc_stack: ::stack_t,
|
||||
// Should be pointer to __extctx_t
|
||||
pub __extctx: *mut ::c_void,
|
||||
pub __extctx_magic: ::c_int,
|
||||
pub __pad: [::c_int; 1],
|
||||
}
|
||||
|
||||
pub struct mcontext_t {
|
||||
pub gpr: [::c_ulonglong; 32],
|
||||
pub msr: ::c_ulonglong,
|
||||
pub iar: ::c_ulonglong,
|
||||
pub lr: ::c_ulonglong,
|
||||
pub ctr: ::c_ulonglong,
|
||||
pub cr: ::c_uint,
|
||||
pub xer: ::c_uint,
|
||||
pub fpscr: ::c_uint,
|
||||
pub fpscrx: ::c_uint,
|
||||
pub except: [::c_ulonglong; 1],
|
||||
// Should be array of double type
|
||||
pub fpr: [::uint64_t; 32],
|
||||
pub fpeu: ::c_char,
|
||||
pub fpinfo: ::c_char,
|
||||
pub fpscr24_31: ::c_char,
|
||||
pub pad: [::c_char; 1],
|
||||
pub excp_type: ::c_int,
|
||||
}
|
||||
|
||||
pub struct utmpx {
|
||||
pub ut_user: [::c_char; 256],
|
||||
pub ut_id: [::c_char; 14],
|
||||
pub ut_line: [::c_char; 64],
|
||||
pub ut_pid: ::pid_t,
|
||||
pub ut_type: ::c_short,
|
||||
pub ut_tv: ::timeval,
|
||||
pub ut_host: [::c_char; 256],
|
||||
pub __dbl_word_pad: ::c_int,
|
||||
pub __reservedA: [::c_int; 2],
|
||||
pub __reservedV: [::c_int; 6],
|
||||
}
|
||||
|
||||
pub struct pthread_spinlock_t {
|
||||
pub __sp_word: [::c_long; 3],
|
||||
}
|
||||
|
||||
pub struct pthread_barrier_t {
|
||||
pub __br_word: [::c_long; 5],
|
||||
}
|
||||
|
||||
pub struct msqid_ds {
|
||||
pub msg_perm: ::ipc_perm,
|
||||
pub msg_first: ::c_uint,
|
||||
pub msg_last: ::c_uint,
|
||||
pub msg_cbytes: ::c_uint,
|
||||
pub msg_qnum: ::c_uint,
|
||||
pub msg_qbytes: ::c_ulong,
|
||||
pub msg_lspid: ::pid_t,
|
||||
pub msg_lrpid: ::pid_t,
|
||||
pub msg_stime: ::time_t,
|
||||
pub msg_rtime: ::time_t,
|
||||
pub msg_ctime: ::time_t,
|
||||
pub msg_rwait: ::c_int,
|
||||
pub msg_wwait: ::c_int,
|
||||
pub msg_reqevents: ::c_ushort,
|
||||
}
|
||||
}
|
||||
|
||||
s_no_extra_traits! {
|
||||
pub struct siginfo_t {
|
||||
pub si_signo: ::c_int,
|
||||
pub si_errno: ::c_int,
|
||||
pub si_code: ::c_int,
|
||||
pub si_pid: ::pid_t,
|
||||
pub si_uid: ::uid_t,
|
||||
pub si_status: ::c_int,
|
||||
pub si_addr: *mut ::c_void,
|
||||
pub si_band: ::c_long,
|
||||
pub si_value: ::sigval,
|
||||
pub __si_flags: ::c_int,
|
||||
pub __pad: [::c_int; 3],
|
||||
}
|
||||
|
||||
#[cfg(libc_union)]
|
||||
pub union _kernel_simple_lock {
|
||||
pub _slock: ::c_long,
|
||||
// Should be pointer to 'lock_data_instrumented'
|
||||
pub _slockp: *mut ::c_void,
|
||||
}
|
||||
|
||||
pub struct fileops_t {
|
||||
pub fo_rw: extern fn(file: *mut file, rw: ::uio_rw, io: *mut ::c_void, ext: ::c_long,
|
||||
secattr: *mut ::c_void) -> ::c_int,
|
||||
pub fo_ioctl: extern fn(file: *mut file, a: ::c_long, b: ::caddr_t, c: ::c_long,
|
||||
d: ::c_long) -> ::c_int,
|
||||
pub fo_select: extern fn(file: *mut file, a: ::c_int, b: *mut ::c_ushort,
|
||||
c: extern fn()) -> ::c_int,
|
||||
pub fo_close: extern fn(file: *mut file) -> ::c_int,
|
||||
pub fo_fstat: extern fn(file: *mut file, sstat: *mut ::stat) -> ::c_int,
|
||||
}
|
||||
|
||||
pub struct file {
|
||||
pub f_flag: ::c_long,
|
||||
pub f_count: ::c_int,
|
||||
pub f_options: ::c_short,
|
||||
pub f_type: ::c_short,
|
||||
// Should be pointer to 'vnode'
|
||||
pub f_data: *mut ::c_void,
|
||||
pub f_offset: ::c_longlong,
|
||||
pub f_dir_off: ::c_long,
|
||||
// Should be pointer to 'cred'
|
||||
pub f_cred: *mut ::c_void,
|
||||
#[cfg(libc_union)]
|
||||
pub f_lock: _kernel_simple_lock,
|
||||
#[cfg(libc_union)]
|
||||
pub f_offset_lock: _kernel_simple_lock,
|
||||
pub f_vinfo: ::caddr_t,
|
||||
pub f_ops: *mut fileops_t,
|
||||
pub f_parentp: ::caddr_t,
|
||||
pub f_fnamep: ::caddr_t,
|
||||
pub f_fdata: [::c_char; 160],
|
||||
}
|
||||
|
||||
#[cfg(libc_union)]
|
||||
pub union __ld_info_file {
|
||||
pub _ldinfo_fd: ::c_int,
|
||||
pub _ldinfo_fp: *mut file,
|
||||
pub _core_offset: ::c_long,
|
||||
}
|
||||
|
||||
pub struct ld_info {
|
||||
pub ldinfo_next: ::c_uint,
|
||||
pub ldinfo_flags: ::c_uint,
|
||||
#[cfg(libc_union)]
|
||||
pub _file: __ld_info_file,
|
||||
pub ldinfo_textorg: *mut ::c_void,
|
||||
pub ldinfo_textsize: ::c_ulong,
|
||||
pub ldinfo_dataorg: *mut ::c_void,
|
||||
pub ldinfo_datasize: ::c_ulong,
|
||||
pub ldinfo_filename: [::c_char; 2],
|
||||
}
|
||||
|
||||
#[cfg(libc_union)]
|
||||
pub union __pollfd_ext_u {
|
||||
pub addr: *mut ::c_void,
|
||||
pub data32: u32,
|
||||
pub data: u64,
|
||||
}
|
||||
|
||||
pub struct pollfd_ext {
|
||||
pub fd: ::c_int,
|
||||
pub events: ::c_ushort,
|
||||
pub revents: ::c_ushort,
|
||||
#[cfg(libc_union)]
|
||||
pub data: __pollfd_ext_u,
|
||||
}
|
||||
}
|
||||
|
||||
impl siginfo_t {
|
||||
pub unsafe fn si_addr(&self) -> *mut ::c_void {
|
||||
self.si_addr
|
||||
}
|
||||
|
||||
pub unsafe fn si_value(&self) -> ::sigval {
|
||||
self.si_value
|
||||
}
|
||||
|
||||
pub unsafe fn si_pid(&self) -> ::pid_t {
|
||||
self.si_pid
|
||||
}
|
||||
|
||||
pub unsafe fn si_uid(&self) -> ::uid_t {
|
||||
self.si_uid
|
||||
}
|
||||
|
||||
pub unsafe fn si_status(&self) -> ::c_int {
|
||||
self.si_status
|
||||
}
|
||||
}
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(feature = "extra_traits")] {
|
||||
impl PartialEq for siginfo_t {
|
||||
fn eq(&self, other: &siginfo_t) -> bool {
|
||||
#[cfg(libc_union)]
|
||||
let value_eq = self.si_value == other.si_value;
|
||||
#[cfg(not(libc_union))]
|
||||
let value_eq = true;
|
||||
self.si_signo == other.si_signo
|
||||
&& self.si_errno == other.si_errno
|
||||
&& self.si_code == other.si_code
|
||||
&& self.si_pid == other.si_pid
|
||||
&& self.si_uid == other.si_uid
|
||||
&& self.si_status == other.si_status
|
||||
&& self.si_addr == other.si_addr
|
||||
&& self.si_band == other.si_band
|
||||
&& self.__si_flags == other.__si_flags
|
||||
&& value_eq
|
||||
}
|
||||
}
|
||||
impl Eq for siginfo_t {}
|
||||
impl ::fmt::Debug for siginfo_t {
|
||||
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
|
||||
let mut struct_formatter = f.debug_struct("siginfo_t");
|
||||
struct_formatter.field("si_signo", &self.si_signo);
|
||||
struct_formatter.field("si_errno", &self.si_errno);
|
||||
struct_formatter.field("si_code", &self.si_code);
|
||||
struct_formatter.field("si_pid", &self.si_pid);
|
||||
struct_formatter.field("si_uid", &self.si_uid);
|
||||
struct_formatter.field("si_status", &self.si_status);
|
||||
struct_formatter.field("si_addr", &self.si_addr);
|
||||
struct_formatter.field("si_band", &self.si_band);
|
||||
#[cfg(libc_union)]
|
||||
struct_formatter.field("si_value", &self.si_value);
|
||||
struct_formatter.field("__si_flags", &self.__si_flags);
|
||||
struct_formatter.finish()
|
||||
}
|
||||
}
|
||||
impl ::hash::Hash for siginfo_t {
|
||||
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
|
||||
self.si_signo.hash(state);
|
||||
self.si_errno.hash(state);
|
||||
self.si_code.hash(state);
|
||||
self.si_pid.hash(state);
|
||||
self.si_uid.hash(state);
|
||||
self.si_status.hash(state);
|
||||
self.si_addr.hash(state);
|
||||
self.si_band.hash(state);
|
||||
#[cfg(libc_union)]
|
||||
self.si_value.hash(state);
|
||||
self.__si_flags.hash(state);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(libc_union)]
|
||||
impl PartialEq for _kernel_simple_lock {
|
||||
fn eq(&self, other: &_kernel_simple_lock) -> bool {
|
||||
unsafe {
|
||||
self._slock == other._slock
|
||||
&& self._slockp == other._slockp
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(libc_union)]
|
||||
impl Eq for _kernel_simple_lock {}
|
||||
#[cfg(libc_union)]
|
||||
impl ::fmt::Debug for _kernel_simple_lock {
|
||||
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
|
||||
f.debug_struct("_kernel_simple_lock")
|
||||
.field("_slock", unsafe { &self._slock })
|
||||
.field("_slockp", unsafe { &self._slockp })
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
#[cfg(libc_union)]
|
||||
impl ::hash::Hash for _kernel_simple_lock {
|
||||
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
|
||||
unsafe {
|
||||
self._slock.hash(state);
|
||||
self._slockp.hash(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for fileops_t {
|
||||
fn eq(&self, other: &fileops_t) -> bool {
|
||||
self.fo_rw == other.fo_rw
|
||||
&& self.fo_ioctl == other.fo_ioctl
|
||||
&& self.fo_select == other.fo_select
|
||||
&& self.fo_close == other.fo_close
|
||||
&& self.fo_fstat == other.fo_fstat
|
||||
}
|
||||
}
|
||||
impl Eq for fileops_t {}
|
||||
impl ::fmt::Debug for fileops_t {
|
||||
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
|
||||
let mut struct_formatter = f.debug_struct("fileops_t");
|
||||
struct_formatter.field("fo_rw", &self.fo_rw);
|
||||
struct_formatter.field("fo_ioctl", &self.fo_ioctl);
|
||||
struct_formatter.field("fo_select", &self.fo_select);
|
||||
struct_formatter.field("fo_close", &self.fo_close);
|
||||
struct_formatter.field("fo_fstat", &self.fo_fstat);
|
||||
struct_formatter.finish()
|
||||
}
|
||||
}
|
||||
impl ::hash::Hash for fileops_t {
|
||||
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
|
||||
self.fo_rw.hash(state);
|
||||
self.fo_ioctl.hash(state);
|
||||
self.fo_select.hash(state);
|
||||
self.fo_close.hash(state);
|
||||
self.fo_fstat.hash(state);
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for file {
|
||||
fn eq(&self, other: &file) -> bool {
|
||||
#[cfg(libc_union)]
|
||||
let lock_eq = self.f_lock == other.f_lock
|
||||
&& self.f_offset_lock == other.f_offset_lock;
|
||||
#[cfg(not(libc_union))]
|
||||
let lock_eq = true;
|
||||
self.f_flag == other.f_flag
|
||||
&& self.f_count == other.f_count
|
||||
&& self.f_options == other.f_options
|
||||
&& self.f_type == other.f_type
|
||||
&& self.f_data == other.f_data
|
||||
&& self.f_offset == other.f_offset
|
||||
&& self.f_dir_off == other.f_dir_off
|
||||
&& self.f_cred == other.f_cred
|
||||
&& self.f_vinfo == other.f_vinfo
|
||||
&& self.f_ops == other.f_ops
|
||||
&& self.f_parentp == other.f_parentp
|
||||
&& self.f_fnamep == other.f_fnamep
|
||||
&& self.f_fdata == other.f_fdata
|
||||
&& lock_eq
|
||||
}
|
||||
}
|
||||
impl Eq for file {}
|
||||
impl ::fmt::Debug for file {
|
||||
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
|
||||
let mut struct_formatter = f.debug_struct("file");
|
||||
struct_formatter.field("f_flag", &self.f_flag);
|
||||
struct_formatter.field("f_count", &self.f_count);
|
||||
struct_formatter.field("f_options", &self.f_options);
|
||||
struct_formatter.field("f_type", &self.f_type);
|
||||
struct_formatter.field("f_data", &self.f_data);
|
||||
struct_formatter.field("f_offset", &self.f_offset);
|
||||
struct_formatter.field("f_dir_off", &self.f_dir_off);
|
||||
struct_formatter.field("f_cred", &self.f_cred);
|
||||
#[cfg(libc_union)]
|
||||
struct_formatter.field("f_lock", &self.f_lock);
|
||||
#[cfg(libc_union)]
|
||||
struct_formatter.field("f_offset_lock", &self.f_offset_lock);
|
||||
struct_formatter.field("f_vinfo", &self.f_vinfo);
|
||||
struct_formatter.field("f_ops", &self.f_ops);
|
||||
struct_formatter.field("f_parentp", &self.f_parentp);
|
||||
struct_formatter.field("f_fnamep", &self.f_fnamep);
|
||||
struct_formatter.field("f_fdata", &self.f_fdata);
|
||||
struct_formatter.finish()
|
||||
}
|
||||
}
|
||||
impl ::hash::Hash for file {
|
||||
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
|
||||
self.f_flag.hash(state);
|
||||
self.f_count.hash(state);
|
||||
self.f_options.hash(state);
|
||||
self.f_type.hash(state);
|
||||
self.f_data.hash(state);
|
||||
self.f_offset.hash(state);
|
||||
self.f_dir_off.hash(state);
|
||||
self.f_cred.hash(state);
|
||||
#[cfg(libc_union)]
|
||||
self.f_lock.hash(state);
|
||||
#[cfg(libc_union)]
|
||||
self.f_offset_lock.hash(state);
|
||||
self.f_vinfo.hash(state);
|
||||
self.f_ops.hash(state);
|
||||
self.f_parentp.hash(state);
|
||||
self.f_fnamep.hash(state);
|
||||
self.f_fdata.hash(state);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(libc_union)]
|
||||
impl PartialEq for __ld_info_file {
|
||||
fn eq(&self, other: &__ld_info_file) -> bool {
|
||||
unsafe {
|
||||
self._ldinfo_fd == other._ldinfo_fd
|
||||
&& self._ldinfo_fp == other._ldinfo_fp
|
||||
&& self._core_offset == other._core_offset
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(libc_union)]
|
||||
impl Eq for __ld_info_file {}
|
||||
#[cfg(libc_union)]
|
||||
impl ::fmt::Debug for __ld_info_file {
|
||||
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
|
||||
f.debug_struct("__ld_info_file")
|
||||
.field("_ldinfo_fd", unsafe { &self._ldinfo_fd })
|
||||
.field("_ldinfo_fp", unsafe { &self._ldinfo_fp })
|
||||
.field("_core_offset", unsafe { &self._core_offset })
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
#[cfg(libc_union)]
|
||||
impl ::hash::Hash for __ld_info_file {
|
||||
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
|
||||
unsafe {
|
||||
self._ldinfo_fd.hash(state);
|
||||
self._ldinfo_fp.hash(state);
|
||||
self._core_offset.hash(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for ld_info {
|
||||
fn eq(&self, other: &ld_info) -> bool {
|
||||
#[cfg(libc_union)]
|
||||
let file_eq = self._file == other._file;
|
||||
#[cfg(not(libc_union))]
|
||||
let file_eq = true;
|
||||
self.ldinfo_next == other.ldinfo_next
|
||||
&& self.ldinfo_flags == other.ldinfo_flags
|
||||
&& self.ldinfo_textorg == other.ldinfo_textorg
|
||||
&& self.ldinfo_textsize == other.ldinfo_textsize
|
||||
&& self.ldinfo_dataorg == other.ldinfo_dataorg
|
||||
&& self.ldinfo_datasize == other.ldinfo_datasize
|
||||
&& self.ldinfo_filename == other.ldinfo_filename
|
||||
&& file_eq
|
||||
}
|
||||
}
|
||||
impl Eq for ld_info {}
|
||||
impl ::fmt::Debug for ld_info {
|
||||
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
|
||||
let mut struct_formatter = f.debug_struct("ld_info");
|
||||
struct_formatter.field("ldinfo_next", &self.ldinfo_next);
|
||||
struct_formatter.field("ldinfo_flags", &self.ldinfo_flags);
|
||||
struct_formatter.field("ldinfo_textorg", &self.ldinfo_textorg);
|
||||
struct_formatter.field("ldinfo_textsize", &self.ldinfo_textsize);
|
||||
struct_formatter.field("ldinfo_dataorg", &self.ldinfo_dataorg);
|
||||
struct_formatter.field("ldinfo_datasize", &self.ldinfo_datasize);
|
||||
struct_formatter.field("ldinfo_filename", &self.ldinfo_filename);
|
||||
#[cfg(libc_union)]
|
||||
struct_formatter.field("_file", &self._file);
|
||||
struct_formatter.finish()
|
||||
}
|
||||
}
|
||||
impl ::hash::Hash for ld_info {
|
||||
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
|
||||
self.ldinfo_next.hash(state);
|
||||
self.ldinfo_flags.hash(state);
|
||||
self.ldinfo_textorg.hash(state);
|
||||
self.ldinfo_textsize.hash(state);
|
||||
self.ldinfo_dataorg.hash(state);
|
||||
self.ldinfo_datasize.hash(state);
|
||||
self.ldinfo_filename.hash(state);
|
||||
#[cfg(libc_union)]
|
||||
self._file.hash(state);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(libc_union)]
|
||||
impl PartialEq for __pollfd_ext_u {
|
||||
fn eq(&self, other: &__pollfd_ext_u) -> bool {
|
||||
unsafe {
|
||||
self.addr == other.addr
|
||||
&& self.data32 == other.data32
|
||||
&& self.data == other.data
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(libc_union)]
|
||||
impl Eq for __pollfd_ext_u {}
|
||||
#[cfg(libc_union)]
|
||||
impl ::fmt::Debug for __pollfd_ext_u {
|
||||
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
|
||||
f.debug_struct("__pollfd_ext_u")
|
||||
.field("addr", unsafe { &self.addr })
|
||||
.field("data32", unsafe { &self.data32 })
|
||||
.field("data", unsafe { &self.data })
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
#[cfg(libc_union)]
|
||||
impl ::hash::Hash for __pollfd_ext_u {
|
||||
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
|
||||
unsafe {
|
||||
self.addr.hash(state);
|
||||
self.data.hash(state);
|
||||
self.data32.hash(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for pollfd_ext {
|
||||
fn eq(&self, other: &pollfd_ext) -> bool {
|
||||
#[cfg(libc_union)]
|
||||
let data_eq = self.data == other.data;
|
||||
#[cfg(not(libc_union))]
|
||||
let data_eq = true;
|
||||
self.fd == other.fd
|
||||
&& self.events == other.events
|
||||
&& self.revents == other.revents
|
||||
&& data_eq
|
||||
}
|
||||
}
|
||||
impl Eq for pollfd_ext {}
|
||||
impl ::fmt::Debug for pollfd_ext {
|
||||
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
|
||||
let mut struct_formatter = f.debug_struct("pollfd_ext");
|
||||
struct_formatter.field("fd", &self.fd);
|
||||
struct_formatter.field("events", &self.events);
|
||||
struct_formatter.field("revents", &self.revents);
|
||||
#[cfg(libc_union)]
|
||||
struct_formatter.field("data", &self.data);
|
||||
struct_formatter.finish()
|
||||
}
|
||||
}
|
||||
impl ::hash::Hash for pollfd_ext {
|
||||
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
|
||||
self.fd.hash(state);
|
||||
self.events.hash(state);
|
||||
self.revents.hash(state);
|
||||
#[cfg(libc_union)]
|
||||
self.data.hash(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
|
||||
__mt_word: [0, 2, 0, 0, 0, 0, 0, 0],
|
||||
};
|
||||
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
|
||||
__cv_word: [0, 0, 0, 0, 2, 0],
|
||||
};
|
||||
pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
|
||||
__rw_word: [2, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
};
|
||||
pub const RLIM_INFINITY: ::c_ulong = 0x7fffffffffffffff;
|
||||
|
||||
extern "C" {
|
||||
pub fn getsystemcfg(label: ::c_int) -> ::c_ulong;
|
||||
}
|
|
@ -15,6 +15,7 @@ s! {
|
|||
pub uc_link: *mut ::ucontext_t,
|
||||
pub uc_mcsize: usize,
|
||||
pub uc_mcontext: mcontext_t,
|
||||
__mcontext_data: __darwin_mcontext64,
|
||||
}
|
||||
|
||||
pub struct __darwin_mcontext64 {
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
s! {
|
||||
pub struct ctl_info {
|
||||
pub ctl_id: u32,
|
||||
pub ctl_name: [::c_char; MAX_KCTL_NAME],
|
||||
}
|
||||
}
|
||||
|
||||
pub const MAX_KCTL_NAME: usize = 96;
|
|
@ -435,80 +435,6 @@ s! {
|
|||
pub ifm_data: if_data,
|
||||
}
|
||||
|
||||
pub struct ifa_msghdr {
|
||||
pub ifam_msglen: ::c_ushort,
|
||||
pub ifam_version: ::c_uchar,
|
||||
pub ifam_type: ::c_uchar,
|
||||
pub ifam_addrs: ::c_int,
|
||||
pub ifam_flags: ::c_int,
|
||||
pub ifam_index: ::c_ushort,
|
||||
pub ifam_metric: ::c_int,
|
||||
}
|
||||
|
||||
pub struct ifma_msghdr {
|
||||
pub ifmam_msglen: ::c_ushort,
|
||||
pub ifmam_version: ::c_uchar,
|
||||
pub ifmam_type: ::c_uchar,
|
||||
pub ifmam_addrs: ::c_int,
|
||||
pub ifmam_flags: ::c_int,
|
||||
pub ifmam_index: ::c_ushort,
|
||||
}
|
||||
|
||||
pub struct ifma_msghdr2 {
|
||||
pub ifmam_msglen: ::c_ushort,
|
||||
pub ifmam_version: ::c_uchar,
|
||||
pub ifmam_type: ::c_uchar,
|
||||
pub ifmam_addrs: ::c_int,
|
||||
pub ifmam_flags: ::c_int,
|
||||
pub ifmam_index: ::c_ushort,
|
||||
pub ifmam_refcount: i32,
|
||||
}
|
||||
|
||||
pub struct rt_metrics {
|
||||
pub rmx_locks: u32,
|
||||
pub rmx_mtu: u32,
|
||||
pub rmx_hopcount: u32,
|
||||
pub rmx_expire: i32,
|
||||
pub rmx_recvpipe: u32,
|
||||
pub rmx_sendpipe: u32,
|
||||
pub rmx_ssthresh: u32,
|
||||
pub rmx_rtt: u32,
|
||||
pub rmx_rttvar: u32,
|
||||
pub rmx_pksent: u32,
|
||||
pub rmx_state: u32,
|
||||
pub rmx_filler: [u32; 3],
|
||||
}
|
||||
|
||||
pub struct rt_msghdr {
|
||||
pub rtm_msglen: ::c_ushort,
|
||||
pub rtm_version: ::c_uchar,
|
||||
pub rtm_type: ::c_uchar,
|
||||
pub rtm_index: ::c_ushort,
|
||||
pub rtm_flags: ::c_int,
|
||||
pub rtm_addrs: ::c_int,
|
||||
pub rtm_pid: ::pid_t,
|
||||
pub rtm_seq: ::c_int,
|
||||
pub rtm_errno: ::c_int,
|
||||
pub rtm_use: ::c_int,
|
||||
pub rtm_inits: u32,
|
||||
pub rtm_rmx: rt_metrics,
|
||||
}
|
||||
|
||||
pub struct rt_msghdr2 {
|
||||
pub rtm_msglen: ::c_ushort,
|
||||
pub rtm_version: ::c_uchar,
|
||||
pub rtm_type: ::c_uchar,
|
||||
pub rtm_index: ::c_ushort,
|
||||
pub rtm_flags: ::c_int,
|
||||
pub rtm_addrs: ::c_int,
|
||||
pub rtm_refcnt: i32,
|
||||
pub rtm_parentflags: ::c_int,
|
||||
pub rtm_reserved: ::c_int,
|
||||
pub rtm_use: ::c_int,
|
||||
pub rtm_inits: u32,
|
||||
pub rtm_rmx: rt_metrics,
|
||||
}
|
||||
|
||||
pub struct termios {
|
||||
pub c_iflag: ::tcflag_t,
|
||||
pub c_oflag: ::tcflag_t,
|
||||
|
@ -1381,15 +1307,6 @@ s_no_extra_traits! {
|
|||
pub struct os_unfair_lock_s {
|
||||
_os_unfair_lock_opaque: u32,
|
||||
}
|
||||
|
||||
#[cfg_attr(libc_packedN, repr(packed(1)))]
|
||||
pub struct sockaddr_vm {
|
||||
pub svm_len: ::c_uchar,
|
||||
pub svm_family: ::sa_family_t,
|
||||
pub svm_reserved1: ::c_ushort,
|
||||
pub svm_port: ::c_uint,
|
||||
pub svm_cid: ::c_uint,
|
||||
}
|
||||
}
|
||||
|
||||
impl siginfo_t {
|
||||
|
@ -2692,52 +2609,6 @@ cfg_if! {
|
|||
self._os_unfair_lock_opaque.hash(state);
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for sockaddr_vm {
|
||||
fn eq(&self, other: &sockaddr_vm) -> bool {
|
||||
self.svm_len == other.svm_len
|
||||
&& self.svm_family == other.svm_family
|
||||
&& self.svm_reserved1 == other.svm_reserved1
|
||||
&& self.svm_port == other.svm_port
|
||||
&& self.svm_cid == other.svm_cid
|
||||
}
|
||||
}
|
||||
|
||||
impl Eq for sockaddr_vm {}
|
||||
|
||||
impl ::fmt::Debug for sockaddr_vm {
|
||||
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
|
||||
let svm_len = self.svm_len;
|
||||
let svm_family = self.svm_family;
|
||||
let svm_reserved1 = self.svm_reserved1;
|
||||
let svm_port = self.svm_port;
|
||||
let svm_cid = self.svm_cid;
|
||||
|
||||
f.debug_struct("sockaddr_vm")
|
||||
.field("svm_len",&svm_len)
|
||||
.field("svm_family",&svm_family)
|
||||
.field("svm_reserved1",&svm_reserved1)
|
||||
.field("svm_port",&svm_port)
|
||||
.field("svm_cid",&svm_cid)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl ::hash::Hash for sockaddr_vm {
|
||||
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
|
||||
let svm_len = self.svm_len;
|
||||
let svm_family = self.svm_family;
|
||||
let svm_reserved1 = self.svm_reserved1;
|
||||
let svm_port = self.svm_port;
|
||||
let svm_cid = self.svm_cid;
|
||||
|
||||
svm_len.hash(state);
|
||||
svm_family.hash(state);
|
||||
svm_reserved1.hash(state);
|
||||
svm_port.hash(state);
|
||||
svm_cid.hash(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3442,8 +3313,6 @@ pub const MINCORE_MODIFIED: ::c_int = 0x4;
|
|||
pub const MINCORE_REFERENCED_OTHER: ::c_int = 0x8;
|
||||
pub const MINCORE_MODIFIED_OTHER: ::c_int = 0x10;
|
||||
|
||||
pub const CTLIOCGINFO: c_ulong = 0xc0644e03;
|
||||
|
||||
//
|
||||
// sys/netinet/in.h
|
||||
// Protocols (RFC 1700)
|
||||
|
@ -3699,9 +3568,6 @@ pub const AF_SYSTEM: ::c_int = 32;
|
|||
pub const AF_NETBIOS: ::c_int = 33;
|
||||
pub const AF_PPP: ::c_int = 34;
|
||||
pub const pseudo_AF_HDRCMPLT: ::c_int = 35;
|
||||
pub const AF_IEEE80211: ::c_int = 37;
|
||||
pub const AF_UTUN: ::c_int = 38;
|
||||
pub const AF_VSOCK: ::c_int = 40;
|
||||
pub const AF_SYS_CONTROL: ::c_int = 2;
|
||||
|
||||
pub const SYSPROTO_EVENT: ::c_int = 1;
|
||||
|
@ -3743,7 +3609,6 @@ pub const PF_NATM: ::c_int = AF_NATM;
|
|||
pub const PF_SYSTEM: ::c_int = AF_SYSTEM;
|
||||
pub const PF_NETBIOS: ::c_int = AF_NETBIOS;
|
||||
pub const PF_PPP: ::c_int = AF_PPP;
|
||||
pub const PF_VSOCK: ::c_int = AF_VSOCK;
|
||||
|
||||
pub const NET_RT_DUMP: ::c_int = 1;
|
||||
pub const NET_RT_FLAGS: ::c_int = 2;
|
||||
|
@ -3851,13 +3716,12 @@ pub const MSG_HOLD: ::c_int = 0x800;
|
|||
pub const MSG_SEND: ::c_int = 0x1000;
|
||||
pub const MSG_HAVEMORE: ::c_int = 0x2000;
|
||||
pub const MSG_RCVMORE: ::c_int = 0x4000;
|
||||
pub const MSG_NEEDSA: ::c_int = 0x10000;
|
||||
pub const MSG_NOSIGNAL: ::c_int = 0x80000;
|
||||
// pub const MSG_COMPAT: ::c_int = 0x8000;
|
||||
|
||||
pub const SCM_TIMESTAMP: ::c_int = 0x02;
|
||||
pub const SCM_CREDS: ::c_int = 0x03;
|
||||
|
||||
// https://github.com/aosm/xnu/blob/HEAD/bsd/net/if.h#L140-L156
|
||||
// https://github.com/aosm/xnu/blob/master/bsd/net/if.h#L140-L156
|
||||
pub const IFF_UP: ::c_int = 0x1; // interface is up
|
||||
pub const IFF_BROADCAST: ::c_int = 0x2; // broadcast address valid
|
||||
pub const IFF_DEBUG: ::c_int = 0x4; // turn on debugging
|
||||
|
@ -4189,7 +4053,6 @@ pub const RTLD_FIRST: ::c_int = 0x100;
|
|||
pub const RTLD_NODELETE: ::c_int = 0x80;
|
||||
pub const RTLD_NOLOAD: ::c_int = 0x10;
|
||||
pub const RTLD_GLOBAL: ::c_int = 0x8;
|
||||
pub const RTLD_MAIN_ONLY: *mut ::c_void = -5isize as *mut ::c_void;
|
||||
|
||||
pub const _WSTOPPED: ::c_int = 0o177;
|
||||
|
||||
|
@ -4655,7 +4518,7 @@ 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;
|
||||
|
||||
// https://github.com/apple/darwin-xnu/blob/HEAD/bsd/net/bpf.h#L100
|
||||
// https://github.com/apple/darwin-xnu/blob/master/bsd/net/bpf.h#L100
|
||||
// sizeof(i32)
|
||||
pub const BPF_ALIGNMENT: ::c_int = 4;
|
||||
|
||||
|
@ -5051,25 +4914,6 @@ pub const VOL_CAP_INT_RENAME_SWAP: attrgroup_t = 0x00040000;
|
|||
pub const VOL_CAP_INT_RENAME_EXCL: attrgroup_t = 0x00080000;
|
||||
pub const VOL_CAP_INT_RENAME_OPENFAIL: attrgroup_t = 0x00100000;
|
||||
|
||||
// <proc.h>
|
||||
/// Process being created by fork.
|
||||
pub const SIDL: u32 = 1;
|
||||
/// Currently runnable.
|
||||
pub const SRUN: u32 = 2;
|
||||
/// Sleeping on an address.
|
||||
pub const SSLEEP: u32 = 3;
|
||||
/// Process debugging or suspension.
|
||||
pub const SSTOP: u32 = 4;
|
||||
/// Awaiting collection by parent.
|
||||
pub const SZOMB: u32 = 5;
|
||||
|
||||
// sys/vsock.h
|
||||
pub const VMADDR_CID_ANY: ::c_uint = 0xFFFFFFFF;
|
||||
pub const VMADDR_CID_HYPERVISOR: ::c_uint = 0;
|
||||
pub const VMADDR_CID_RESERVED: ::c_uint = 1;
|
||||
pub const VMADDR_CID_HOST: ::c_uint = 2;
|
||||
pub const VMADDR_PORT_ANY: ::c_uint = 0xFFFFFFFF;
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(libc_const_extern_fn)] {
|
||||
const fn __DARWIN_ALIGN32(p: usize) -> usize {
|
||||
|
@ -5175,7 +5019,7 @@ f! {
|
|||
as ::c_uint
|
||||
}
|
||||
|
||||
pub {const} fn CMSG_LEN(length: ::c_uint) -> ::c_uint {
|
||||
pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint {
|
||||
(__DARWIN_ALIGN32(::mem::size_of::<::cmsghdr>()) + length as usize)
|
||||
as ::c_uint
|
||||
}
|
||||
|
@ -5275,23 +5119,6 @@ extern "C" {
|
|||
pub fn endutxent();
|
||||
pub fn utmpxname(file: *const ::c_char) -> ::c_int;
|
||||
|
||||
pub fn asctime(tm: *const ::tm) -> *mut ::c_char;
|
||||
pub fn ctime(clock: *const time_t) -> *mut ::c_char;
|
||||
pub fn getdate(datestr: *const ::c_char) -> *mut ::tm;
|
||||
pub fn strftime(
|
||||
buf: *mut ::c_char,
|
||||
maxsize: ::size_t,
|
||||
format: *const ::c_char,
|
||||
timeptr: *const ::tm,
|
||||
) -> ::size_t;
|
||||
pub fn strptime(
|
||||
buf: *const ::c_char,
|
||||
format: *const ::c_char,
|
||||
timeptr: *mut ::tm,
|
||||
) -> *mut ::c_char;
|
||||
pub fn asctime_r(tm: *const ::tm, result: *mut ::c_char) -> *mut ::c_char;
|
||||
pub fn ctime_r(clock: *const time_t, result: *mut ::c_char) -> *mut ::c_char;
|
||||
|
||||
pub fn getnameinfo(
|
||||
sa: *const ::sockaddr,
|
||||
salen: ::socklen_t,
|
||||
|
@ -5361,10 +5188,6 @@ extern "C" {
|
|||
f: extern "C" fn(*mut ::c_void) -> *mut ::c_void,
|
||||
value: *mut ::c_void,
|
||||
) -> ::c_int;
|
||||
pub fn pthread_stack_frame_decode_np(
|
||||
frame_addr: ::uintptr_t,
|
||||
return_addr: *mut ::uintptr_t,
|
||||
) -> ::uintptr_t;
|
||||
pub fn pthread_get_stackaddr_np(thread: ::pthread_t) -> *mut ::c_void;
|
||||
pub fn pthread_get_stacksize_np(thread: ::pthread_t) -> ::size_t;
|
||||
pub fn pthread_condattr_setpshared(attr: *mut pthread_condattr_t, pshared: ::c_int) -> ::c_int;
|
||||
|
@ -5372,7 +5195,6 @@ extern "C" {
|
|||
attr: *const pthread_condattr_t,
|
||||
pshared: *mut ::c_int,
|
||||
) -> ::c_int;
|
||||
pub fn pthread_main_np() -> ::c_int;
|
||||
pub fn pthread_mutexattr_setpshared(
|
||||
attr: *mut pthread_mutexattr_t,
|
||||
pshared: ::c_int,
|
||||
|
@ -5734,14 +5556,6 @@ extern "C" {
|
|||
subpref: *mut ::cpu_subtype_t,
|
||||
ocount: *mut ::size_t,
|
||||
) -> ::c_int;
|
||||
pub fn posix_spawnattr_set_qos_class_np(
|
||||
attr: *mut posix_spawnattr_t,
|
||||
qos_class: ::qos_class_t,
|
||||
) -> ::c_int;
|
||||
pub fn posix_spawnattr_get_qos_class_np(
|
||||
attr: *const posix_spawnattr_t,
|
||||
qos_class: *mut ::qos_class_t,
|
||||
) -> ::c_int;
|
||||
|
||||
pub fn posix_spawn_file_actions_init(actions: *mut posix_spawn_file_actions_t) -> ::c_int;
|
||||
pub fn posix_spawn_file_actions_destroy(actions: *mut posix_spawn_file_actions_t) -> ::c_int;
|
||||
|
@ -6059,15 +5873,6 @@ extern "C" {
|
|||
|
||||
pub fn dirname(path: *mut ::c_char) -> *mut ::c_char;
|
||||
pub fn basename(path: *mut ::c_char) -> *mut ::c_char;
|
||||
|
||||
pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char, mode: ::mode_t) -> ::c_int;
|
||||
pub fn mknodat(
|
||||
dirfd: ::c_int,
|
||||
pathname: *const ::c_char,
|
||||
mode: ::mode_t,
|
||||
dev: dev_t,
|
||||
) -> ::c_int;
|
||||
pub fn freadlink(fd: ::c_int, buf: *mut ::c_char, size: ::size_t) -> ::c_int;
|
||||
}
|
||||
|
||||
pub unsafe fn mach_task_self() -> ::mach_port_t {
|
||||
|
@ -6126,10 +5931,3 @@ cfg_if! {
|
|||
// Unknown target_arch
|
||||
}
|
||||
}
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(libc_long_array)] {
|
||||
mod long_array;
|
||||
pub use self::long_array::*;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1091,7 +1091,6 @@ pub const EV_NODATA: u16 = 0x1000;
|
|||
pub const EV_FLAG1: u16 = 0x2000;
|
||||
pub const EV_ERROR: u16 = 0x4000;
|
||||
pub const EV_EOF: u16 = 0x8000;
|
||||
pub const EV_HUP: u16 = 0x8000;
|
||||
pub const EV_SYSFLAGS: u16 = 0xf000;
|
||||
|
||||
pub const FIODNAME: ::c_ulong = 0x80106678;
|
||||
|
@ -1133,7 +1132,7 @@ pub const PROC_REAP_STATUS: ::c_int = 0x0003;
|
|||
pub const PROC_PDEATHSIG_CTL: ::c_int = 0x0004;
|
||||
pub const PROC_PDEATHSIG_STATUS: ::c_int = 0x0005;
|
||||
|
||||
// https://github.com/DragonFlyBSD/DragonFlyBSD/blob/HEAD/sys/net/if.h#L101
|
||||
// https://github.com/DragonFlyBSD/DragonFlyBSD/blob/master/sys/net/if.h#L101
|
||||
pub const IFF_UP: ::c_int = 0x1; // interface is up
|
||||
pub const IFF_BROADCAST: ::c_int = 0x2; // broadcast address valid
|
||||
pub const IFF_DEBUG: ::c_int = 0x4; // turn on debugging
|
||||
|
@ -1519,9 +1518,6 @@ pub const MAXCOMLEN: usize = 16;
|
|||
pub const MAXLOGNAME: usize = 33;
|
||||
pub const NGROUPS: usize = 16;
|
||||
|
||||
pub const RB_PAUSE: ::c_int = 0x40000;
|
||||
pub const RB_VIDEO: ::c_int = 0x20000000;
|
||||
|
||||
const_fn! {
|
||||
{const} fn _CMSG_ALIGN(n: usize) -> usize {
|
||||
(n + (::mem::size_of::<::c_long>() - 1)) & !(::mem::size_of::<::c_long>() - 1)
|
||||
|
@ -1534,7 +1530,7 @@ f! {
|
|||
.offset(_CMSG_ALIGN(::mem::size_of::<::cmsghdr>()) as isize)
|
||||
}
|
||||
|
||||
pub {const} fn CMSG_LEN(length: ::c_uint) -> ::c_uint {
|
||||
pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint {
|
||||
(_CMSG_ALIGN(::mem::size_of::<::cmsghdr>()) + length as usize)
|
||||
as ::c_uint
|
||||
}
|
||||
|
@ -1581,14 +1577,6 @@ f! {
|
|||
let (idx, offset) = ((cpu >> 6) & 3, cpu & 63);
|
||||
0 != cpuset.ary[idx] & (1 << offset)
|
||||
}
|
||||
|
||||
pub fn major(dev: ::dev_t) -> ::c_int {
|
||||
((dev >> 8) & 0xff) as ::c_int
|
||||
}
|
||||
|
||||
pub fn minor(dev: ::dev_t) -> ::c_int {
|
||||
(dev & 0xffff00ff) as ::c_int
|
||||
}
|
||||
}
|
||||
|
||||
safe_f! {
|
||||
|
|
|
@ -442,16 +442,6 @@ safe_f! {
|
|||
}
|
||||
}
|
||||
|
||||
f! {
|
||||
pub fn major(dev: ::dev_t) -> ::c_int {
|
||||
((dev >> 8) & 0xff) as ::c_int
|
||||
}
|
||||
|
||||
pub fn minor(dev: ::dev_t) -> ::c_int {
|
||||
(dev & 0xffff00ff) as ::c_int
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
// Return type ::c_int was removed in FreeBSD 12
|
||||
pub fn setgrent() -> ::c_int;
|
||||
|
@ -472,8 +462,8 @@ extern "C" {
|
|||
msgflg: ::c_int,
|
||||
) -> ::c_int;
|
||||
|
||||
// Type of `path` argument changed from `const void*` to `void*`
|
||||
// in FreeBSD 12
|
||||
pub fn fdatasync(fd: ::c_int) -> ::c_int;
|
||||
|
||||
pub fn dirname(path: *const ::c_char) -> *mut ::c_char;
|
||||
pub fn basename(path: *const ::c_char) -> *mut ::c_char;
|
||||
}
|
||||
|
|
|
@ -462,16 +462,6 @@ safe_f! {
|
|||
}
|
||||
}
|
||||
|
||||
f! {
|
||||
pub fn major(dev: ::dev_t) -> ::c_int {
|
||||
(((dev >> 32) & 0xffffff00) | ((dev >> 8) & 0xff)) as ::c_int
|
||||
}
|
||||
|
||||
pub fn minor(dev: ::dev_t) -> ::c_int {
|
||||
(((dev >> 24) & 0xff00) | (dev & 0xffff00ff)) as ::c_int
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
pub fn setgrent();
|
||||
pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int;
|
||||
|
@ -483,6 +473,20 @@ extern "C" {
|
|||
msgtyp: ::c_long,
|
||||
msgflg: ::c_int,
|
||||
) -> ::ssize_t;
|
||||
pub fn clock_nanosleep(
|
||||
clk_id: ::clockid_t,
|
||||
flags: ::c_int,
|
||||
rqtp: *const ::timespec,
|
||||
rmtp: *mut ::timespec,
|
||||
) -> ::c_int;
|
||||
|
||||
pub fn fdatasync(fd: ::c_int) -> ::c_int;
|
||||
|
||||
pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t;
|
||||
pub fn elf_aux_info(aux: ::c_int, buf: *mut ::c_void, buflen: ::c_int) -> ::c_int;
|
||||
pub fn setproctitle_fast(fmt: *const ::c_char, ...);
|
||||
pub fn timingsafe_bcmp(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int;
|
||||
pub fn timingsafe_memcmp(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int;
|
||||
|
||||
pub fn dirname(path: *mut ::c_char) -> *mut ::c_char;
|
||||
pub fn basename(path: *mut ::c_char) -> *mut ::c_char;
|
||||
|
|
|
@ -481,16 +481,6 @@ safe_f! {
|
|||
}
|
||||
}
|
||||
|
||||
f! {
|
||||
pub fn major(dev: ::dev_t) -> ::c_int {
|
||||
(((dev >> 32) & 0xffffff00) | ((dev >> 8) & 0xff)) as ::c_int
|
||||
}
|
||||
|
||||
pub fn minor(dev: ::dev_t) -> ::c_int {
|
||||
(((dev >> 24) & 0xff00) | (dev & 0xffff00ff)) as ::c_int
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
pub fn setgrent();
|
||||
pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int;
|
||||
|
@ -502,6 +492,23 @@ extern "C" {
|
|||
msgtyp: ::c_long,
|
||||
msgflg: ::c_int,
|
||||
) -> ::ssize_t;
|
||||
pub fn clock_nanosleep(
|
||||
clk_id: ::clockid_t,
|
||||
flags: ::c_int,
|
||||
rqtp: *const ::timespec,
|
||||
rmtp: *mut ::timespec,
|
||||
) -> ::c_int;
|
||||
|
||||
pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int;
|
||||
|
||||
pub fn fdatasync(fd: ::c_int) -> ::c_int;
|
||||
|
||||
pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t;
|
||||
pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int;
|
||||
pub fn elf_aux_info(aux: ::c_int, buf: *mut ::c_void, buflen: ::c_int) -> ::c_int;
|
||||
pub fn setproctitle_fast(fmt: *const ::c_char, ...);
|
||||
pub fn timingsafe_bcmp(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int;
|
||||
pub fn timingsafe_memcmp(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int;
|
||||
|
||||
pub fn cpuset_getdomain(
|
||||
level: ::cpulevel_t,
|
||||
|
|
|
@ -481,16 +481,6 @@ safe_f! {
|
|||
}
|
||||
}
|
||||
|
||||
f! {
|
||||
pub fn major(dev: ::dev_t) -> ::c_int {
|
||||
(((dev >> 32) & 0xffffff00) | ((dev >> 8) & 0xff)) as ::c_int
|
||||
}
|
||||
|
||||
pub fn minor(dev: ::dev_t) -> ::c_int {
|
||||
(((dev >> 24) & 0xff00) | (dev & 0xffff00ff)) as ::c_int
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
pub fn setgrent();
|
||||
pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int;
|
||||
|
@ -502,6 +492,23 @@ extern "C" {
|
|||
msgtyp: ::c_long,
|
||||
msgflg: ::c_int,
|
||||
) -> ::ssize_t;
|
||||
pub fn clock_nanosleep(
|
||||
clk_id: ::clockid_t,
|
||||
flags: ::c_int,
|
||||
rqtp: *const ::timespec,
|
||||
rmtp: *mut ::timespec,
|
||||
) -> ::c_int;
|
||||
|
||||
pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int;
|
||||
|
||||
pub fn fdatasync(fd: ::c_int) -> ::c_int;
|
||||
|
||||
pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t;
|
||||
pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int;
|
||||
pub fn elf_aux_info(aux: ::c_int, buf: *mut ::c_void, buflen: ::c_int) -> ::c_int;
|
||||
pub fn setproctitle_fast(fmt: *const ::c_char, ...);
|
||||
pub fn timingsafe_bcmp(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int;
|
||||
pub fn timingsafe_memcmp(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int;
|
||||
|
||||
pub fn cpuset_getdomain(
|
||||
level: ::cpulevel_t,
|
||||
|
|
|
@ -3,10 +3,3 @@ pub const PROC_KPTI_CTL_ENABLE_ON_EXEC: ::c_int = 1;
|
|||
pub const PROC_KPTI_CTL_DISABLE_ON_EXEC: ::c_int = 2;
|
||||
pub const PROC_KPTI_STATUS: ::c_int = ::PROC_PROCCTL_MD_MIN + 1;
|
||||
pub const PROC_KPTI_STATUS_ACTIVE: ::c_int = 0x80000000;
|
||||
pub const PROC_LA_CTL: ::c_int = ::PROC_PROCCTL_MD_MIN + 2;
|
||||
pub const PROC_LA_STATUS: ::c_int = ::PROC_PROCCTL_MD_MIN + 3;
|
||||
pub const PROC_LA_CTL_LA48_ON_EXEC: ::c_int = 1;
|
||||
pub const PROC_LA_CTL_LA57_ON_EXEC: ::c_int = 2;
|
||||
pub const PROC_LA_CTL_DEFAULT_ON_EXEC: ::c_int = 3;
|
||||
pub const PROC_LA_STATUS_LA48: ::c_int = 0x01000000;
|
||||
pub const PROC_LA_STATUS_LA57: ::c_int = 0x02000000;
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -6,41 +6,6 @@ pub type time_t = i32;
|
|||
pub type suseconds_t = i32;
|
||||
pub type register_t = i32;
|
||||
|
||||
s_no_extra_traits! {
|
||||
pub struct mcontext_t {
|
||||
pub mc_onstack: register_t,
|
||||
pub mc_gs: register_t,
|
||||
pub mc_fs: register_t,
|
||||
pub mc_es: register_t,
|
||||
pub mc_ds: register_t,
|
||||
pub mc_edi: register_t,
|
||||
pub mc_esi: register_t,
|
||||
pub mc_ebp: register_t,
|
||||
pub mc_isp: register_t,
|
||||
pub mc_ebx: register_t,
|
||||
pub mc_edx: register_t,
|
||||
pub mc_ecx: register_t,
|
||||
pub mc_eax: register_t,
|
||||
pub mc_trapno: register_t,
|
||||
pub mc_err: register_t,
|
||||
pub mc_eip: register_t,
|
||||
pub mc_cs: register_t,
|
||||
pub mc_eflags: register_t,
|
||||
pub mc_esp: register_t,
|
||||
pub mc_ss: register_t,
|
||||
pub mc_len: ::c_int,
|
||||
pub mc_fpformat: ::c_int,
|
||||
pub mc_ownedfp: ::c_int,
|
||||
pub mc_flags: register_t,
|
||||
pub mc_fpstate: [[::c_int; 32]; 4],
|
||||
pub mc_fsbase: register_t,
|
||||
pub mc_gsbase: register_t,
|
||||
pub mc_xfpustate: register_t,
|
||||
pub mc_xfpustate_len: register_t,
|
||||
pub mc_spare2: [::c_int; 4],
|
||||
}
|
||||
}
|
||||
|
||||
s! {
|
||||
pub struct stat {
|
||||
pub st_dev: ::dev_t,
|
||||
|
@ -66,15 +31,6 @@ s! {
|
|||
pub st_birthtime_nsec: ::c_long,
|
||||
__unused: [u8; 8],
|
||||
}
|
||||
|
||||
pub struct ucontext_t {
|
||||
pub uc_sigmask: ::sigset_t,
|
||||
pub uc_mcontext: ::mcontext_t,
|
||||
pub uc_link: *mut ::ucontext_t,
|
||||
pub uc_stack: ::stack_t,
|
||||
pub uc_flags: ::c_int,
|
||||
__spare__: [::c_int; 4],
|
||||
}
|
||||
}
|
||||
|
||||
// should be pub(crate), but that requires Rust 1.18.0
|
||||
|
@ -87,115 +43,4 @@ cfg_if! {
|
|||
pub const _ALIGNBYTES: usize = 4 - 1;
|
||||
}
|
||||
}
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(feature = "extra_traits")] {
|
||||
impl PartialEq for mcontext_t {
|
||||
fn eq(&self, other: &mcontext_t) -> bool {
|
||||
self.mc_onstack == other.mc_onstack &&
|
||||
self.mc_gs == other.mc_gs &&
|
||||
self.mc_fs == other.mc_fs &&
|
||||
self.mc_es == other.mc_es &&
|
||||
self.mc_ds == other.mc_ds &&
|
||||
self.mc_edi == other.mc_edi &&
|
||||
self.mc_esi == other.mc_esi &&
|
||||
self.mc_ebp == other.mc_ebp &&
|
||||
self.mc_isp == other.mc_isp &&
|
||||
self.mc_ebx == other.mc_ebx &&
|
||||
self.mc_edx == other.mc_edx &&
|
||||
self.mc_ecx == other.mc_ecx &&
|
||||
self.mc_eax == other.mc_eax &&
|
||||
self.mc_trapno == other.mc_trapno &&
|
||||
self.mc_err == other.mc_err &&
|
||||
self.mc_eip == other.mc_eip &&
|
||||
self.mc_cs == other.mc_cs &&
|
||||
self.mc_eflags == other.mc_eflags &&
|
||||
self.mc_esp == other.mc_esp &&
|
||||
self.mc_ss == other.mc_ss &&
|
||||
self.mc_len == other.mc_len &&
|
||||
self.mc_fpformat == other.mc_fpformat &&
|
||||
self.mc_ownedfp == other.mc_ownedfp &&
|
||||
self.mc_flags == other.mc_flags &&
|
||||
self.mc_fpstate.iter().zip(other.mc_fpstate.iter()).all(|(a, b)| a == b) &&
|
||||
self.mc_fsbase == other.mc_fsbase &&
|
||||
self.mc_gsbase == other.mc_gsbase &&
|
||||
self.mc_xfpustate == other.mc_xfpustate &&
|
||||
self.mc_xfpustate_len == other.mc_xfpustate_len &&
|
||||
self.mc_spare2.iter().zip(other.mc_spare2.iter()).all(|(a, b)| a == b)
|
||||
}
|
||||
}
|
||||
impl Eq for mcontext_t {}
|
||||
impl ::fmt::Debug for mcontext_t {
|
||||
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
|
||||
f.debug_struct("mcontext_t")
|
||||
.field("mc_onstack", &self.mc_onstack)
|
||||
.field("mc_gs", &self.mc_gs)
|
||||
.field("mc_fs", &self.mc_fs)
|
||||
.field("mc_es", &self.mc_es)
|
||||
.field("mc_ds", &self.mc_ds)
|
||||
.field("mc_edi", &self.mc_edi)
|
||||
.field("mc_esi", &self.mc_esi)
|
||||
.field("mc_ebp", &self.mc_ebp)
|
||||
.field("mc_isp", &self.mc_isp)
|
||||
.field("mc_ebx", &self.mc_ebx)
|
||||
.field("mc_edx", &self.mc_edx)
|
||||
.field("mc_ecx", &self.mc_ecx)
|
||||
.field("mc_eax", &self.mc_eax)
|
||||
.field("mc_trapno", &self.mc_trapno)
|
||||
.field("mc_err", &self.mc_err)
|
||||
.field("mc_eip", &self.mc_eip)
|
||||
.field("mc_cs", &self.mc_cs)
|
||||
.field("mc_eflags", &self.mc_eflags)
|
||||
.field("mc_esp", &self.mc_esp)
|
||||
.field("mc_ss", &self.mc_ss)
|
||||
.field("mc_len", &self.mc_len)
|
||||
.field("mc_fpformat", &self.mc_fpformat)
|
||||
.field("mc_ownedfp", &self.mc_ownedfp)
|
||||
.field("mc_flags", &self.mc_flags)
|
||||
.field("mc_fpstate", &self.mc_fpstate)
|
||||
.field("mc_fsbase", &self.mc_fsbase)
|
||||
.field("mc_gsbase", &self.mc_gsbase)
|
||||
.field("mc_xfpustate", &self.mc_xfpustate)
|
||||
.field("mc_xfpustate_len", &self.mc_xfpustate_len)
|
||||
.field("mc_spare2", &self.mc_spare2)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
impl ::hash::Hash for mcontext_t {
|
||||
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
|
||||
self.mc_onstack.hash(state);
|
||||
self.mc_gs.hash(state);
|
||||
self.mc_fs.hash(state);
|
||||
self.mc_es.hash(state);
|
||||
self.mc_ds.hash(state);
|
||||
self.mc_edi.hash(state);
|
||||
self.mc_esi.hash(state);
|
||||
self.mc_ebp.hash(state);
|
||||
self.mc_isp.hash(state);
|
||||
self.mc_ebx.hash(state);
|
||||
self.mc_edx.hash(state);
|
||||
self.mc_ecx.hash(state);
|
||||
self.mc_eax.hash(state);
|
||||
self.mc_trapno.hash(state);
|
||||
self.mc_err.hash(state);
|
||||
self.mc_eip.hash(state);
|
||||
self.mc_cs.hash(state);
|
||||
self.mc_eflags.hash(state);
|
||||
self.mc_esp.hash(state);
|
||||
self.mc_ss.hash(state);
|
||||
self.mc_len.hash(state);
|
||||
self.mc_fpformat.hash(state);
|
||||
self.mc_ownedfp.hash(state);
|
||||
self.mc_flags.hash(state);
|
||||
self.mc_fpstate.hash(state);
|
||||
self.mc_fsbase.hash(state);
|
||||
self.mc_gsbase.hash(state);
|
||||
self.mc_xfpustate.hash(state);
|
||||
self.mc_xfpustate_len.hash(state);
|
||||
self.mc_spare2.hash(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub const MINSIGSTKSZ: ::size_t = 2048; // 512 * 4
|
||||
|
|
|
@ -824,15 +824,12 @@ pub const CLOCK_VIRTUAL: ::clockid_t = 1;
|
|||
pub const CLOCK_PROF: ::clockid_t = 2;
|
||||
pub const CLOCK_MONOTONIC: ::clockid_t = 4;
|
||||
pub const CLOCK_UPTIME: ::clockid_t = 5;
|
||||
pub const CLOCK_BOOTTIME: ::clockid_t = CLOCK_UPTIME;
|
||||
pub const CLOCK_UPTIME_PRECISE: ::clockid_t = 7;
|
||||
pub const CLOCK_UPTIME_FAST: ::clockid_t = 8;
|
||||
pub const CLOCK_REALTIME_PRECISE: ::clockid_t = 9;
|
||||
pub const CLOCK_REALTIME_FAST: ::clockid_t = 10;
|
||||
pub const CLOCK_REALTIME_COARSE: ::clockid_t = CLOCK_REALTIME_FAST;
|
||||
pub const CLOCK_MONOTONIC_PRECISE: ::clockid_t = 11;
|
||||
pub const CLOCK_MONOTONIC_FAST: ::clockid_t = 12;
|
||||
pub const CLOCK_MONOTONIC_COARSE: ::clockid_t = CLOCK_MONOTONIC_FAST;
|
||||
pub const CLOCK_SECOND: ::clockid_t = 13;
|
||||
pub const CLOCK_THREAD_CPUTIME_ID: ::clockid_t = 14;
|
||||
pub const CLOCK_PROCESS_CPUTIME_ID: ::clockid_t = 15;
|
||||
|
@ -1339,7 +1336,7 @@ pub const CMGROUP_MAX: usize = 16;
|
|||
|
||||
pub const EUI64_LEN: usize = 8;
|
||||
|
||||
// https://github.com/freebsd/freebsd/blob/HEAD/sys/net/bpf.h
|
||||
// https://github.com/freebsd/freebsd/blob/master/sys/net/bpf.h
|
||||
pub const BPF_ALIGNMENT: usize = SIZEOF_LONG;
|
||||
|
||||
// Values for rtprio struct (prio field) and syscall (function argument)
|
||||
|
@ -1434,31 +1431,6 @@ pub const SHM_RND: ::c_int = 0o20000;
|
|||
pub const SHM_R: ::c_int = 0o400;
|
||||
pub const SHM_W: ::c_int = 0o200;
|
||||
|
||||
pub const KENV_GET: ::c_int = 0;
|
||||
pub const KENV_SET: ::c_int = 1;
|
||||
pub const KENV_UNSET: ::c_int = 2;
|
||||
pub const KENV_DUMP: ::c_int = 3;
|
||||
pub const KENV_MNAMELEN: ::c_int = 128;
|
||||
pub const KENV_MVALLEN: ::c_int = 128;
|
||||
|
||||
pub const RB_ASKNAME: ::c_int = 0x001;
|
||||
pub const RB_SINGLE: ::c_int = 0x002;
|
||||
pub const RB_NOSYNC: ::c_int = 0x004;
|
||||
pub const RB_HALT: ::c_int = 0x008;
|
||||
pub const RB_INITNAME: ::c_int = 0x010;
|
||||
pub const RB_DFLTROOT: ::c_int = 0x020;
|
||||
pub const RB_KDB: ::c_int = 0x040;
|
||||
pub const RB_RDONLY: ::c_int = 0x080;
|
||||
pub const RB_DUMP: ::c_int = 0x100;
|
||||
pub const RB_MINIROOT: ::c_int = 0x200;
|
||||
pub const RB_VERBOSE: ::c_int = 0x800;
|
||||
pub const RB_SERIAL: ::c_int = 0x1000;
|
||||
pub const RB_CDROM: ::c_int = 0x2000;
|
||||
pub const RB_POWEROFF: ::c_int = 0x4000;
|
||||
pub const RB_GDB: ::c_int = 0x8000;
|
||||
pub const RB_MUTE: ::c_int = 0x10000;
|
||||
pub const RB_SELFTEST: ::c_int = 0x20000;
|
||||
|
||||
safe_f! {
|
||||
pub {const} fn WIFCONTINUED(status: ::c_int) -> bool {
|
||||
status == 0x13
|
||||
|
@ -1571,7 +1543,6 @@ extern "C" {
|
|||
mode: ::mode_t,
|
||||
dev: dev_t,
|
||||
) -> ::c_int;
|
||||
pub fn malloc_usable_size(ptr: *const ::c_void) -> ::size_t;
|
||||
pub fn mincore(addr: *const ::c_void, len: ::size_t, vec: *mut ::c_char) -> ::c_int;
|
||||
pub fn newlocale(mask: ::c_int, locale: *const ::c_char, base: ::locale_t) -> ::locale_t;
|
||||
pub fn nl_langinfo_l(item: ::nl_item, locale: ::locale_t) -> *mut ::c_char;
|
||||
|
@ -1763,14 +1734,6 @@ extern "C" {
|
|||
pub fn eui64_hostton(hostname: *const ::c_char, id: *mut eui64) -> ::c_int;
|
||||
|
||||
pub fn eaccess(path: *const ::c_char, mode: ::c_int) -> ::c_int;
|
||||
|
||||
pub fn kenv(
|
||||
action: ::c_int,
|
||||
name: *const ::c_char,
|
||||
value: *mut ::c_char,
|
||||
len: ::c_int,
|
||||
) -> ::c_int;
|
||||
pub fn reboot(howto: ::c_int) -> ::c_int;
|
||||
}
|
||||
|
||||
#[link(name = "rt")]
|
||||
|
|
|
@ -628,7 +628,6 @@ extern "C" {
|
|||
pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int;
|
||||
pub fn freeifaddrs(ifa: *mut ::ifaddrs);
|
||||
pub fn setgroups(ngroups: ::c_int, ptr: *const ::gid_t) -> ::c_int;
|
||||
pub fn setlogin(name: *const ::c_char) -> ::c_int;
|
||||
pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
|
||||
pub fn kqueue() -> ::c_int;
|
||||
pub fn unmount(target: *const ::c_char, arg: ::c_int) -> ::c_int;
|
||||
|
|
|
@ -746,7 +746,6 @@ extern "C" {
|
|||
|
||||
pub fn dirname(path: *mut ::c_char) -> *mut ::c_char;
|
||||
pub fn basename(path: *mut ::c_char) -> *mut ::c_char;
|
||||
pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int;
|
||||
}
|
||||
|
||||
cfg_if! {
|
||||
|
|
|
@ -709,49 +709,6 @@ s! {
|
|||
#[cfg(libc_union)]
|
||||
pub ifc_ifcu: __c_anonymous_ifc_ifcu,
|
||||
}
|
||||
|
||||
pub struct tcp_info {
|
||||
pub tcpi_state: u8,
|
||||
pub __tcpi_ca_state: u8,
|
||||
pub __tcpi_retransmits: u8,
|
||||
pub __tcpi_probes: u8,
|
||||
pub __tcpi_backoff: u8,
|
||||
pub tcpi_options: u8,
|
||||
pub tcp_snd_wscale: u8,
|
||||
pub tcp_rcv_wscale: u8,
|
||||
pub tcpi_rto: u32,
|
||||
pub __tcpi_ato: u32,
|
||||
pub tcpi_snd_mss: u32,
|
||||
pub tcpi_rcv_mss: u32,
|
||||
pub __tcpi_unacked: u32,
|
||||
pub __tcpi_sacked: u32,
|
||||
pub __tcpi_lost: u32,
|
||||
pub __tcpi_retrans: u32,
|
||||
pub __tcpi_fackets: u32,
|
||||
pub __tcpi_last_data_sent: u32,
|
||||
pub __tcpi_last_ack_sent: u32,
|
||||
pub tcpi_last_data_recv: u32,
|
||||
pub __tcpi_last_ack_recv: u32,
|
||||
pub __tcpi_pmtu: u32,
|
||||
pub __tcpi_rcv_ssthresh: u32,
|
||||
pub tcpi_rtt: u32,
|
||||
pub tcpi_rttvar: u32,
|
||||
pub tcpi_snd_ssthresh: u32,
|
||||
pub tcpi_snd_cwnd: u32,
|
||||
pub __tcpi_advmss: u32,
|
||||
pub __tcpi_reordering: u32,
|
||||
pub __tcpi_rcv_rtt: u32,
|
||||
pub tcpi_rcv_space: u32,
|
||||
pub tcpi_snd_wnd: u32,
|
||||
pub tcpi_snd_bwnd: u32,
|
||||
pub tcpi_snd_nxt: u32,
|
||||
pub tcpi_rcv_nxt: u32,
|
||||
pub tcpi_toe_tid: u32,
|
||||
pub tcpi_snd_rexmitpack: u32,
|
||||
pub tcpi_rcv_ooopack: u32,
|
||||
pub tcpi_snd_zerowin: u32,
|
||||
pub __tcpi_pad: [u32; 26],
|
||||
}
|
||||
}
|
||||
|
||||
s_no_extra_traits! {
|
||||
|
@ -1441,7 +1398,7 @@ pub const MS_SYNC: ::c_int = 0x4;
|
|||
pub const MS_INVALIDATE: ::c_int = 0x2;
|
||||
|
||||
// Here because they are not present on OpenBSD
|
||||
// (https://github.com/openbsd/src/blob/HEAD/sys/sys/resource.h)
|
||||
// (https://github.com/openbsd/src/blob/master/sys/sys/resource.h)
|
||||
pub const RLIMIT_SBSIZE: ::c_int = 9;
|
||||
pub const RLIMIT_AS: ::c_int = 10;
|
||||
pub const RLIMIT_NTHR: ::c_int = 11;
|
||||
|
@ -1464,15 +1421,7 @@ pub const ENOATTR: ::c_int = 93;
|
|||
pub const EMULTIHOP: ::c_int = 94;
|
||||
pub const ENOLINK: ::c_int = 95;
|
||||
pub const EPROTO: ::c_int = 96;
|
||||
pub const EOWNERDEAD: ::c_int = 97;
|
||||
pub const ENOTRECOVERABLE: ::c_int = 98;
|
||||
#[deprecated(
|
||||
since = "0.2.143",
|
||||
note = "This value will always match the highest defined error number \
|
||||
and thus is not stable. \
|
||||
See #3040 for more info."
|
||||
)]
|
||||
pub const ELAST: ::c_int = 98;
|
||||
pub const ELAST: ::c_int = 96;
|
||||
|
||||
pub const F_DUPFD_CLOEXEC: ::c_int = 12;
|
||||
pub const F_CLOSEM: ::c_int = 10;
|
||||
|
@ -1977,9 +1926,6 @@ pub const EVFILT_SIGNAL: u32 = 5;
|
|||
pub const EVFILT_TIMER: u32 = 6;
|
||||
pub const EVFILT_VNODE: u32 = 3;
|
||||
pub const EVFILT_WRITE: u32 = 1;
|
||||
pub const EVFILT_FS: u32 = 7;
|
||||
pub const EVFILT_USER: u32 = 8;
|
||||
pub const EVFILT_EMPTY: u32 = 9;
|
||||
|
||||
pub const EV_ADD: u32 = 0x1;
|
||||
pub const EV_DELETE: u32 = 0x2;
|
||||
|
@ -1994,13 +1940,6 @@ pub const EV_ERROR: u32 = 0x4000;
|
|||
pub const EV_EOF: u32 = 0x8000;
|
||||
pub const EV_SYSFLAGS: u32 = 0xf000;
|
||||
|
||||
pub const NOTE_TRIGGER: u32 = 0x01000000;
|
||||
pub const NOTE_FFNOP: u32 = 0x00000000;
|
||||
pub const NOTE_FFAND: u32 = 0x40000000;
|
||||
pub const NOTE_FFOR: u32 = 0x80000000;
|
||||
pub const NOTE_FFCOPY: u32 = 0xc0000000;
|
||||
pub const NOTE_FFCTRLMASK: u32 = 0xc0000000;
|
||||
pub const NOTE_FFLAGSMASK: u32 = 0x00ffffff;
|
||||
pub const NOTE_LOWAT: u32 = 0x00000001;
|
||||
pub const NOTE_DELETE: u32 = 0x00000001;
|
||||
pub const NOTE_WRITE: u32 = 0x00000002;
|
||||
|
@ -2017,11 +1956,6 @@ pub const NOTE_PCTRLMASK: u32 = 0xf0000000;
|
|||
pub const NOTE_TRACK: u32 = 0x00000001;
|
||||
pub const NOTE_TRACKERR: u32 = 0x00000002;
|
||||
pub const NOTE_CHILD: u32 = 0x00000004;
|
||||
pub const NOTE_MSECONDS: u32 = 0x00000000;
|
||||
pub const NOTE_SECONDS: u32 = 0x00000001;
|
||||
pub const NOTE_USECONDS: u32 = 0x00000002;
|
||||
pub const NOTE_NSECONDS: u32 = 0x00000003;
|
||||
pub const NOTE_ABSTIME: u32 = 0x000000010;
|
||||
|
||||
pub const TMP_MAX: ::c_uint = 308915776;
|
||||
|
||||
|
@ -2228,11 +2162,6 @@ pub const WCONTINUED: ::c_int = 0x00000010;
|
|||
pub const WEXITED: ::c_int = 0x000000020;
|
||||
pub const WNOWAIT: ::c_int = 0x00010000;
|
||||
|
||||
pub const WALTSIG: ::c_int = 0x00000004;
|
||||
pub const WALLSIG: ::c_int = 0x00000008;
|
||||
pub const WTRAPPED: ::c_int = 0x00000040;
|
||||
pub const WNOZOMBIE: ::c_int = 0x00020000;
|
||||
|
||||
pub const P_ALL: idtype_t = 0;
|
||||
pub const P_PID: idtype_t = 1;
|
||||
pub const P_PGID: idtype_t = 4;
|
||||
|
@ -2392,24 +2321,6 @@ pub const XATTR_REPLACE: ::c_int = 0x02;
|
|||
// sys/extattr.h
|
||||
pub const EXTATTR_NAMESPACE_EMPTY: ::c_int = 0;
|
||||
|
||||
// For getrandom()
|
||||
pub const GRND_NONBLOCK: ::c_uint = 0x1;
|
||||
pub const GRND_RANDOM: ::c_uint = 0x2;
|
||||
pub const GRND_INSECURE: ::c_uint = 0x4;
|
||||
|
||||
cfg_if! {
|
||||
|
||||
if #[cfg(libc_const_extern_fn)] {
|
||||
pub const fn MAP_ALIGNED(alignment: ::c_int) -> ::c_int {
|
||||
alignment << MAP_ALIGNMENT_SHIFT
|
||||
}
|
||||
} else {
|
||||
pub fn MAP_ALIGNED(alignment: ::c_int) -> ::c_int {
|
||||
alignment << MAP_ALIGNMENT_SHIFT
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const_fn! {
|
||||
{const} fn _ALIGN(p: usize) -> usize {
|
||||
(p + _ALIGNBYTES) & !_ALIGNBYTES
|
||||
|
@ -2422,7 +2333,7 @@ f! {
|
|||
.offset(_ALIGN(::mem::size_of::<::cmsghdr>()) as isize)
|
||||
}
|
||||
|
||||
pub {const} fn CMSG_LEN(length: ::c_uint) -> ::c_uint {
|
||||
pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint {
|
||||
_ALIGN(::mem::size_of::<::cmsghdr>()) as ::c_uint + length
|
||||
}
|
||||
|
||||
|
@ -2472,17 +2383,6 @@ f! {
|
|||
pub fn PROT_MPROTECT_EXTRACT(x: ::c_int) -> ::c_int {
|
||||
(x >> 3) & 0x7
|
||||
}
|
||||
|
||||
pub fn major(dev: ::dev_t) -> ::c_int {
|
||||
(((dev as u32) & 0x000fff00) >> 8) as ::c_int
|
||||
}
|
||||
|
||||
pub fn minor(dev: ::dev_t) -> ::c_int {
|
||||
let mut res = 0;
|
||||
res |= ((dev as u32) & 0xfff00000) >> 12;
|
||||
res |= (dev as u32) & 0x000000ff;
|
||||
res as ::c_int
|
||||
}
|
||||
}
|
||||
|
||||
safe_f! {
|
||||
|
@ -2524,7 +2424,31 @@ extern "C" {
|
|||
) -> ::c_int;
|
||||
|
||||
pub fn reallocarr(ptr: *mut ::c_void, number: ::size_t, size: ::size_t) -> ::c_int;
|
||||
}
|
||||
|
||||
#[link(name = "rt")]
|
||||
extern "C" {
|
||||
pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int;
|
||||
pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int;
|
||||
pub fn aio_fsync(op: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
|
||||
pub fn aio_error(aiocbp: *const aiocb) -> ::c_int;
|
||||
pub fn aio_return(aiocbp: *mut aiocb) -> ::ssize_t;
|
||||
#[link_name = "__aio_suspend50"]
|
||||
pub fn aio_suspend(
|
||||
aiocb_list: *const *const aiocb,
|
||||
nitems: ::c_int,
|
||||
timeout: *const ::timespec,
|
||||
) -> ::c_int;
|
||||
pub fn aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
|
||||
pub fn lio_listio(
|
||||
mode: ::c_int,
|
||||
aiocb_list: *const *mut aiocb,
|
||||
nitems: ::c_int,
|
||||
sevp: *mut sigevent,
|
||||
) -> ::c_int;
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
pub fn chflags(path: *const ::c_char, flags: ::c_ulong) -> ::c_int;
|
||||
pub fn fchflags(fd: ::c_int, flags: ::c_ulong) -> ::c_int;
|
||||
pub fn lchflags(path: *const ::c_char, flags: ::c_ulong) -> ::c_int;
|
||||
|
@ -2869,12 +2793,7 @@ extern "C" {
|
|||
ts: *const ::timespec,
|
||||
sigmask: *const ::sigset_t,
|
||||
) -> ::c_int;
|
||||
pub fn ppoll(
|
||||
fds: *mut ::pollfd,
|
||||
nfds: ::nfds_t,
|
||||
ts: *const ::timespec,
|
||||
sigmask: *const ::sigset_t,
|
||||
) -> ::c_int;
|
||||
|
||||
pub fn posix_spawn(
|
||||
pid: *mut ::pid_t,
|
||||
path: *const ::c_char,
|
||||
|
@ -2951,29 +2870,6 @@ extern "C" {
|
|||
fd: ::c_int,
|
||||
newfd: ::c_int,
|
||||
) -> ::c_int;
|
||||
pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t;
|
||||
}
|
||||
|
||||
#[link(name = "rt")]
|
||||
extern "C" {
|
||||
pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int;
|
||||
pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int;
|
||||
pub fn aio_fsync(op: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
|
||||
pub fn aio_error(aiocbp: *const aiocb) -> ::c_int;
|
||||
pub fn aio_return(aiocbp: *mut aiocb) -> ::ssize_t;
|
||||
#[link_name = "__aio_suspend50"]
|
||||
pub fn aio_suspend(
|
||||
aiocb_list: *const *const aiocb,
|
||||
nitems: ::c_int,
|
||||
timeout: *const ::timespec,
|
||||
) -> ::c_int;
|
||||
pub fn aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
|
||||
pub fn lio_listio(
|
||||
mode: ::c_int,
|
||||
aiocb_list: *const *mut aiocb,
|
||||
nitems: ::c_int,
|
||||
sevp: *mut sigevent,
|
||||
) -> ::c_int;
|
||||
}
|
||||
|
||||
#[link(name = "util")]
|
||||
|
|
|
@ -7,7 +7,6 @@ pub type sigset_t = ::c_uint;
|
|||
pub type blksize_t = i32;
|
||||
pub type fsblkcnt_t = u64;
|
||||
pub type fsfilcnt_t = u64;
|
||||
pub type idtype_t = ::c_uint;
|
||||
pub type pthread_attr_t = *mut ::c_void;
|
||||
pub type pthread_mutex_t = *mut ::c_void;
|
||||
pub type pthread_mutexattr_t = *mut ::c_void;
|
||||
|
@ -110,7 +109,7 @@ s! {
|
|||
pub struct mfs_args {
|
||||
pub fspec: *mut ::c_char,
|
||||
pub export_info: export_args,
|
||||
// https://github.com/openbsd/src/blob/HEAD/sys/sys/types.h#L134
|
||||
// https://github.com/openbsd/src/blob/master/sys/sys/types.h#L134
|
||||
pub base: *mut ::c_char,
|
||||
pub size: ::c_ulong,
|
||||
}
|
||||
|
@ -190,7 +189,7 @@ s! {
|
|||
pub cr_uid: ::uid_t,
|
||||
pub cr_gid: ::gid_t,
|
||||
pub cr_ngroups: ::c_short,
|
||||
//https://github.com/openbsd/src/blob/HEAD/sys/sys/syslimits.h#L44
|
||||
//https://github.com/openbsd/src/blob/master/sys/sys/syslimits.h#L44
|
||||
pub cr_groups: [::gid_t; 16],
|
||||
}
|
||||
|
||||
|
@ -499,7 +498,6 @@ s! {
|
|||
pub p_tid: i32,
|
||||
pub p_rtableid: u32,
|
||||
pub p_pledge: u64,
|
||||
pub p_name: [::c_char; KI_MAXCOMLEN as usize],
|
||||
}
|
||||
|
||||
pub struct kinfo_vmentry {
|
||||
|
@ -999,8 +997,6 @@ pub const SO_NETPROC: ::c_int = 0x1020;
|
|||
pub const SO_RTABLE: ::c_int = 0x1021;
|
||||
pub const SO_PEERCRED: ::c_int = 0x1022;
|
||||
pub const SO_SPLICE: ::c_int = 0x1023;
|
||||
pub const SO_DOMAIN: ::c_int = 0x1024;
|
||||
pub const SO_PROTOCOL: ::c_int = 0x1025;
|
||||
|
||||
// sys/netinet/in.h
|
||||
// Protocols (RFC 1700)
|
||||
|
@ -1075,8 +1071,6 @@ pub const IP_RECVIF: ::c_int = 30;
|
|||
pub const TCP_MD5SIG: ::c_int = 0x04;
|
||||
pub const TCP_NOPUSH: ::c_int = 0x10;
|
||||
|
||||
pub const MSG_WAITFORONE: ::c_int = 0x1000;
|
||||
|
||||
pub const AF_ECMA: ::c_int = 8;
|
||||
pub const AF_ROUTE: ::c_int = 17;
|
||||
pub const AF_ENCAP: ::c_int = 28;
|
||||
|
@ -1284,15 +1278,13 @@ pub const PTHREAD_MUTEX_NORMAL: ::c_int = 3;
|
|||
pub const PTHREAD_MUTEX_STRICT_NP: ::c_int = 4;
|
||||
pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_STRICT_NP;
|
||||
|
||||
pub const EVFILT_READ: i16 = -1;
|
||||
pub const EVFILT_WRITE: i16 = -2;
|
||||
pub const EVFILT_AIO: i16 = -3;
|
||||
pub const EVFILT_VNODE: i16 = -4;
|
||||
pub const EVFILT_PROC: i16 = -5;
|
||||
pub const EVFILT_READ: i16 = -1;
|
||||
pub const EVFILT_SIGNAL: i16 = -6;
|
||||
pub const EVFILT_TIMER: i16 = -7;
|
||||
pub const EVFILT_DEVICE: i16 = -8;
|
||||
pub const EVFILT_EXCEPT: i16 = -9;
|
||||
pub const EVFILT_VNODE: i16 = -4;
|
||||
pub const EVFILT_WRITE: i16 = -2;
|
||||
|
||||
pub const EV_ADD: u16 = 0x1;
|
||||
pub const EV_DELETE: u16 = 0x2;
|
||||
|
@ -1311,7 +1303,6 @@ pub const EV_SYSFLAGS: u16 = 0xf800;
|
|||
|
||||
pub const NOTE_LOWAT: u32 = 0x00000001;
|
||||
pub const NOTE_EOF: u32 = 0x00000002;
|
||||
pub const NOTE_OOB: u32 = 0x00000004;
|
||||
pub const NOTE_DELETE: u32 = 0x00000001;
|
||||
pub const NOTE_WRITE: u32 = 0x00000002;
|
||||
pub const NOTE_EXTEND: u32 = 0x00000004;
|
||||
|
@ -1328,7 +1319,6 @@ pub const NOTE_PCTRLMASK: u32 = 0xf0000000;
|
|||
pub const NOTE_TRACK: u32 = 0x00000001;
|
||||
pub const NOTE_TRACKERR: u32 = 0x00000002;
|
||||
pub const NOTE_CHILD: u32 = 0x00000004;
|
||||
pub const NOTE_CHANGE: u32 = 0x00000001;
|
||||
|
||||
pub const TMP_MAX: ::c_uint = 0x7fffffff;
|
||||
|
||||
|
@ -1517,7 +1507,7 @@ pub const OLCUC: ::tcflag_t = 0x20;
|
|||
pub const ONOCR: ::tcflag_t = 0x40;
|
||||
pub const ONLRET: ::tcflag_t = 0x80;
|
||||
|
||||
//https://github.com/openbsd/src/blob/HEAD/sys/sys/mount.h
|
||||
//https://github.com/openbsd/src/blob/master/sys/sys/mount.h
|
||||
pub const ISOFSMNT_NORRIP: ::c_int = 0x1; // disable Rock Ridge Ext
|
||||
pub const ISOFSMNT_GENS: ::c_int = 0x2; // enable generation numbers
|
||||
pub const ISOFSMNT_EXTATT: ::c_int = 0x4; // enable extended attr
|
||||
|
@ -1581,7 +1571,7 @@ pub const TMPFS_ARGS_VERSION: ::c_int = 1;
|
|||
pub const MAP_STACK: ::c_int = 0x4000;
|
||||
pub const MAP_CONCEAL: ::c_int = 0x8000;
|
||||
|
||||
// https://github.com/openbsd/src/blob/HEAD/sys/net/if.h#L187
|
||||
// https://github.com/openbsd/src/blob/master/sys/net/if.h#L187
|
||||
pub const IFF_UP: ::c_int = 0x1; // interface is up
|
||||
pub const IFF_BROADCAST: ::c_int = 0x2; // broadcast address valid
|
||||
pub const IFF_DEBUG: ::c_int = 0x4; // turn on debugging
|
||||
|
@ -1620,15 +1610,7 @@ pub const BIOCSDLT: ::c_ulong = 0x8004427a;
|
|||
|
||||
pub const PTRACE_FORK: ::c_int = 0x0002;
|
||||
|
||||
pub const WCONTINUED: ::c_int = 0x08;
|
||||
pub const WEXITED: ::c_int = 0x04;
|
||||
pub const WSTOPPED: ::c_int = 0x02; // same as WUNTRACED
|
||||
pub const WNOWAIT: ::c_int = 0x10;
|
||||
pub const WTRAPPED: ::c_int = 0x20;
|
||||
|
||||
pub const P_ALL: ::idtype_t = 0;
|
||||
pub const P_PGID: ::idtype_t = 1;
|
||||
pub const P_PID: ::idtype_t = 2;
|
||||
pub const WCONTINUED: ::c_int = 8;
|
||||
|
||||
// search.h
|
||||
pub const FIND: ::ACTION = 0;
|
||||
|
@ -1677,12 +1659,6 @@ pub const MNT_WAIT: ::c_int = 1;
|
|||
pub const MNT_NOWAIT: ::c_int = 2;
|
||||
pub const MNT_LAZY: ::c_int = 3;
|
||||
|
||||
// sys/_time.h
|
||||
pub const CLOCK_PROCESS_CPUTIME_ID: ::clockid_t = 2;
|
||||
pub const CLOCK_THREAD_CPUTIME_ID: ::clockid_t = 4;
|
||||
pub const CLOCK_UPTIME: ::clockid_t = 5;
|
||||
pub const CLOCK_BOOTTIME: ::clockid_t = 6;
|
||||
|
||||
pub const LC_COLLATE_MASK: ::c_int = 1 << ::LC_COLLATE;
|
||||
pub const LC_CTYPE_MASK: ::c_int = 1 << ::LC_CTYPE;
|
||||
pub const LC_MONETARY_MASK: ::c_int = 1 << ::LC_MONETARY;
|
||||
|
@ -1707,7 +1683,7 @@ f! {
|
|||
.offset(_ALIGN(::mem::size_of::<::cmsghdr>()) as isize)
|
||||
}
|
||||
|
||||
pub {const} fn CMSG_LEN(length: ::c_uint) -> ::c_uint {
|
||||
pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint {
|
||||
_ALIGN(::mem::size_of::<::cmsghdr>()) as ::c_uint + length
|
||||
}
|
||||
|
||||
|
@ -1733,19 +1709,6 @@ f! {
|
|||
(_ALIGN(::mem::size_of::<::cmsghdr>()) + _ALIGN(length as usize))
|
||||
as ::c_uint
|
||||
}
|
||||
|
||||
pub fn major(dev: ::dev_t) -> ::c_uint{
|
||||
((dev as ::c_uint) >> 8) & 0xff
|
||||
}
|
||||
|
||||
pub fn minor(dev: ::dev_t) -> ::c_uint {
|
||||
let dev = dev as ::c_uint;
|
||||
let mut res = 0;
|
||||
res |= (dev) & 0xff;
|
||||
res |= ((dev) & 0xffff0000) >> 8;
|
||||
|
||||
res
|
||||
}
|
||||
}
|
||||
|
||||
safe_f! {
|
||||
|
@ -1859,6 +1822,7 @@ extern "C" {
|
|||
newp: *mut ::c_void,
|
||||
newlen: ::size_t,
|
||||
) -> ::c_int;
|
||||
pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int;
|
||||
pub fn setresgid(rgid: ::gid_t, egid: ::gid_t, sgid: ::gid_t) -> ::c_int;
|
||||
pub fn setresuid(ruid: ::uid_t, euid: ::uid_t, suid: ::uid_t) -> ::c_int;
|
||||
pub fn ptrace(request: ::c_int, pid: ::pid_t, addr: caddr_t, data: ::c_int) -> ::c_int;
|
||||
|
@ -1924,8 +1888,6 @@ extern "C" {
|
|||
timeout: *const ::timespec,
|
||||
uaddr2: *mut u32,
|
||||
) -> ::c_int;
|
||||
|
||||
pub fn mimmutable(addr: *mut ::c_void, len: ::size_t) -> ::c_int;
|
||||
}
|
||||
|
||||
#[link(name = "execinfo")]
|
||||
|
|
|
@ -55,8 +55,6 @@ pub type ACTION = ::c_int;
|
|||
pub type posix_spawnattr_t = *mut ::c_void;
|
||||
pub type posix_spawn_file_actions_t = *mut ::c_void;
|
||||
|
||||
pub type StringList = _stringlist;
|
||||
|
||||
#[cfg_attr(feature = "extra_traits", derive(Debug))]
|
||||
pub enum timezone {}
|
||||
impl ::Copy for timezone {}
|
||||
|
@ -439,19 +437,6 @@ s! {
|
|||
pub flag: *mut ::c_int,
|
||||
pub val: ::c_int,
|
||||
}
|
||||
|
||||
pub struct _stringlist {
|
||||
pub sl_str: *mut *mut ::c_char,
|
||||
pub sl_max: ::size_t,
|
||||
pub sl_cur: ::size_t,
|
||||
}
|
||||
|
||||
pub struct dl_phdr_info {
|
||||
pub dlpi_addr: ::Elf_Addr,
|
||||
pub dlpi_name: *const ::c_char,
|
||||
pub dlpi_phdr: *const ::Elf_Phdr,
|
||||
pub dlpi_phnum: ::Elf_Half,
|
||||
}
|
||||
}
|
||||
|
||||
s_no_extra_traits! {
|
||||
|
@ -685,9 +670,6 @@ pub const EOF: ::c_int = -1;
|
|||
pub const SEEK_SET: ::c_int = 0;
|
||||
pub const SEEK_CUR: ::c_int = 1;
|
||||
pub const SEEK_END: ::c_int = 2;
|
||||
pub const L_SET: ::c_int = SEEK_SET;
|
||||
pub const L_INCR: ::c_int = SEEK_CUR;
|
||||
pub const L_XTND: ::c_int = SEEK_END;
|
||||
pub const _IOFBF: ::c_int = 0;
|
||||
pub const _IONBF: ::c_int = 2;
|
||||
pub const _IOLBF: ::c_int = 1;
|
||||
|
@ -979,7 +961,7 @@ pub const MADV_WILLNEED: ::c_int = 4;
|
|||
pub const MADV_DONTNEED: ::c_int = 5;
|
||||
pub const MADV_FREE: ::c_int = 6;
|
||||
|
||||
// https://github.com/haiku/haiku/blob/HEAD/headers/posix/net/if.h#L80
|
||||
// https://github.com/haiku/haiku/blob/master/headers/posix/net/if.h#L80
|
||||
pub const IFF_UP: ::c_int = 0x0001;
|
||||
pub const IFF_BROADCAST: ::c_int = 0x0002; // valid broadcast address
|
||||
pub const IFF_LOOPBACK: ::c_int = 0x0008;
|
||||
|
@ -1504,7 +1486,7 @@ f! {
|
|||
as ::c_uint
|
||||
}
|
||||
|
||||
pub {const} fn CMSG_LEN(length: ::c_uint) -> ::c_uint {
|
||||
pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint {
|
||||
CMSG_ALIGN(::mem::size_of::<cmsghdr>()) as ::c_uint + length
|
||||
}
|
||||
|
||||
|
@ -2002,17 +1984,6 @@ extern "C" {
|
|||
longopts: *const option,
|
||||
longindex: *mut ::c_int,
|
||||
) -> ::c_int;
|
||||
pub fn strcasecmp_l(
|
||||
string1: *const ::c_char,
|
||||
string2: *const ::c_char,
|
||||
locale: ::locale_t,
|
||||
) -> ::c_int;
|
||||
pub fn strncasecmp_l(
|
||||
string1: *const ::c_char,
|
||||
string2: *const ::c_char,
|
||||
length: ::size_t,
|
||||
locale: ::locale_t,
|
||||
) -> ::c_int;
|
||||
}
|
||||
|
||||
#[link(name = "bsd")]
|
||||
|
@ -2035,34 +2006,6 @@ extern "C" {
|
|||
pub fn strsep(string: *mut *mut ::c_char, delimiters: *const ::c_char) -> *mut ::c_char;
|
||||
pub fn explicit_bzero(buf: *mut ::c_void, len: ::size_t);
|
||||
pub fn login_tty(_fd: ::c_int) -> ::c_int;
|
||||
|
||||
pub fn sl_init() -> *mut StringList;
|
||||
pub fn sl_add(sl: *mut StringList, n: *mut ::c_char) -> ::c_int;
|
||||
pub fn sl_free(sl: *mut StringList, i: ::c_int);
|
||||
pub fn sl_find(sl: *mut StringList, n: *mut ::c_char) -> *mut ::c_char;
|
||||
|
||||
pub fn getprogname() -> *const ::c_char;
|
||||
pub fn setprogname(progname: *const ::c_char);
|
||||
pub fn dl_iterate_phdr(
|
||||
callback: ::Option<
|
||||
unsafe extern "C" fn(
|
||||
info: *mut dl_phdr_info,
|
||||
size: usize,
|
||||
data: *mut ::c_void,
|
||||
) -> ::c_int,
|
||||
>,
|
||||
data: *mut ::c_void,
|
||||
) -> ::c_int;
|
||||
}
|
||||
|
||||
#[link(name = "gnu")]
|
||||
extern "C" {
|
||||
pub fn memmem(
|
||||
source: *const ::c_void,
|
||||
sourceLength: ::size_t,
|
||||
search: *const ::c_void,
|
||||
searchLength: ::size_t,
|
||||
) -> *mut ::c_void;
|
||||
}
|
||||
|
||||
cfg_if! {
|
||||
|
|
|
@ -501,17 +501,9 @@ pub const SYS_pwritev2: ::c_long = 393;
|
|||
pub const SYS_pkey_mprotect: ::c_long = 394;
|
||||
pub const SYS_pkey_alloc: ::c_long = 395;
|
||||
pub const SYS_pkey_free: ::c_long = 396;
|
||||
pub const SYS_statx: ::c_long = 397;
|
||||
pub const SYS_pidfd_send_signal: ::c_long = 424;
|
||||
pub const SYS_io_uring_setup: ::c_long = 425;
|
||||
pub const SYS_io_uring_enter: ::c_long = 426;
|
||||
pub const SYS_io_uring_register: ::c_long = 427;
|
||||
pub const SYS_open_tree: ::c_long = 428;
|
||||
pub const SYS_move_mount: ::c_long = 429;
|
||||
pub const SYS_fsopen: ::c_long = 430;
|
||||
pub const SYS_fsconfig: ::c_long = 431;
|
||||
pub const SYS_fsmount: ::c_long = 432;
|
||||
pub const SYS_fspick: ::c_long = 433;
|
||||
|
||||
// offsets in mcontext_t.gregs from sys/ucontext.h
|
||||
pub const REG_R0: ::c_int = 0;
|
||||
|
|
|
@ -533,17 +533,9 @@ pub const SYS_pwritev2: ::c_long = 379;
|
|||
pub const SYS_pkey_mprotect: ::c_long = 380;
|
||||
pub const SYS_pkey_alloc: ::c_long = 381;
|
||||
pub const SYS_pkey_free: ::c_long = 382;
|
||||
pub const SYS_statx: ::c_long = 383;
|
||||
pub const SYS_pidfd_send_signal: ::c_long = 424;
|
||||
pub const SYS_io_uring_setup: ::c_long = 425;
|
||||
pub const SYS_io_uring_enter: ::c_long = 426;
|
||||
pub const SYS_io_uring_register: ::c_long = 427;
|
||||
pub const SYS_open_tree: ::c_long = 428;
|
||||
pub const SYS_move_mount: ::c_long = 429;
|
||||
pub const SYS_fsopen: ::c_long = 430;
|
||||
pub const SYS_fsconfig: ::c_long = 431;
|
||||
pub const SYS_fsmount: ::c_long = 432;
|
||||
pub const SYS_fspick: ::c_long = 433;
|
||||
|
||||
// offsets in user_regs_structs, from sys/reg.h
|
||||
pub const EBX: ::c_int = 0;
|
||||
|
|
|
@ -107,31 +107,6 @@ pub const HWCAP2_SVESHA3: ::c_ulong = 1 << 5;
|
|||
pub const HWCAP2_SVESM4: ::c_ulong = 1 << 6;
|
||||
pub const HWCAP2_FLAGM2: ::c_ulong = 1 << 7;
|
||||
pub const HWCAP2_FRINT: ::c_ulong = 1 << 8;
|
||||
pub const HWCAP2_SVEI8MM: ::c_ulong = 1 << 9;
|
||||
pub const HWCAP2_SVEF32MM: ::c_ulong = 1 << 10;
|
||||
pub const HWCAP2_SVEF64MM: ::c_ulong = 1 << 11;
|
||||
pub const HWCAP2_SVEBF16: ::c_ulong = 1 << 12;
|
||||
pub const HWCAP2_I8MM: ::c_ulong = 1 << 13;
|
||||
pub const HWCAP2_BF16: ::c_ulong = 1 << 14;
|
||||
pub const HWCAP2_DGH: ::c_ulong = 1 << 15;
|
||||
pub const HWCAP2_RNG: ::c_ulong = 1 << 16;
|
||||
pub const HWCAP2_BTI: ::c_ulong = 1 << 17;
|
||||
pub const HWCAP2_MTE: ::c_ulong = 1 << 18;
|
||||
pub const HWCAP2_ECV: ::c_ulong = 1 << 19;
|
||||
pub const HWCAP2_AFP: ::c_ulong = 1 << 20;
|
||||
pub const HWCAP2_RPRES: ::c_ulong = 1 << 21;
|
||||
pub const HWCAP2_MTE3: ::c_ulong = 1 << 22;
|
||||
pub const HWCAP2_SME: ::c_ulong = 1 << 23;
|
||||
pub const HWCAP2_SME_I16I64: ::c_ulong = 1 << 24;
|
||||
pub const HWCAP2_SME_F64F64: ::c_ulong = 1 << 25;
|
||||
pub const HWCAP2_SME_I8I32: ::c_ulong = 1 << 26;
|
||||
pub const HWCAP2_SME_F16F32: ::c_ulong = 1 << 27;
|
||||
pub const HWCAP2_SME_B16F32: ::c_ulong = 1 << 28;
|
||||
pub const HWCAP2_SME_F32F32: ::c_ulong = 1 << 29;
|
||||
pub const HWCAP2_SME_FA64: ::c_ulong = 1 << 30;
|
||||
pub const HWCAP2_WFXT: ::c_ulong = 1 << 31;
|
||||
pub const HWCAP2_EBF16: ::c_ulong = 1 << 32;
|
||||
pub const HWCAP2_SVE_EBF16: ::c_ulong = 1 << 33;
|
||||
|
||||
pub const SYS_io_setup: ::c_long = 0;
|
||||
pub const SYS_io_destroy: ::c_long = 1;
|
||||
|
@ -399,22 +374,11 @@ pub const SYS_pwritev2: ::c_long = 287;
|
|||
pub const SYS_pkey_mprotect: ::c_long = 288;
|
||||
pub const SYS_pkey_alloc: ::c_long = 289;
|
||||
pub const SYS_pkey_free: ::c_long = 290;
|
||||
pub const SYS_statx: ::c_long = 291;
|
||||
pub const SYS_pidfd_send_signal: ::c_long = 424;
|
||||
pub const SYS_io_uring_setup: ::c_long = 425;
|
||||
pub const SYS_io_uring_enter: ::c_long = 426;
|
||||
pub const SYS_io_uring_register: ::c_long = 427;
|
||||
pub const SYS_open_tree: ::c_long = 428;
|
||||
pub const SYS_move_mount: ::c_long = 429;
|
||||
pub const SYS_fsopen: ::c_long = 430;
|
||||
pub const SYS_fsconfig: ::c_long = 431;
|
||||
pub const SYS_fsmount: ::c_long = 432;
|
||||
pub const SYS_fspick: ::c_long = 433;
|
||||
pub const SYS_syscalls: ::c_long = 436;
|
||||
|
||||
pub const PROT_BTI: ::c_int = 0x10;
|
||||
pub const PROT_MTE: ::c_int = 0x20;
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(libc_align)] {
|
||||
mod align;
|
||||
|
|
|
@ -60,12 +60,12 @@ pub const SIGSTKSZ: ::size_t = 8192;
|
|||
pub const MINSIGSTKSZ: ::size_t = 2048;
|
||||
|
||||
// From NDK's asm/hwcap.h
|
||||
pub const COMPAT_HWCAP_ISA_I: ::c_ulong = 1 << (b'I' - b'A');
|
||||
pub const COMPAT_HWCAP_ISA_M: ::c_ulong = 1 << (b'M' - b'A');
|
||||
pub const COMPAT_HWCAP_ISA_A: ::c_ulong = 1 << (b'A' - b'A');
|
||||
pub const COMPAT_HWCAP_ISA_F: ::c_ulong = 1 << (b'F' - b'A');
|
||||
pub const COMPAT_HWCAP_ISA_D: ::c_ulong = 1 << (b'D' - b'A');
|
||||
pub const COMPAT_HWCAP_ISA_C: ::c_ulong = 1 << (b'C' - b'A');
|
||||
pub const COMPAT_HWCAP_ISA_I: ::c_ulong = 1 << ('I' - 'A');
|
||||
pub const COMPAT_HWCAP_ISA_M: ::c_ulong = 1 << ('M' - 'A');
|
||||
pub const COMPAT_HWCAP_ISA_A: ::c_ulong = 1 << ('A' - 'A');
|
||||
pub const COMPAT_HWCAP_ISA_F: ::c_ulong = 1 << ('F' - 'A');
|
||||
pub const COMPAT_HWCAP_ISA_D: ::c_ulong = 1 << ('D' - 'A');
|
||||
pub const COMPAT_HWCAP_ISA_C: ::c_ulong = 1 << ('C' - 'A');
|
||||
|
||||
pub const SYS_io_setup: ::c_long = 0;
|
||||
pub const SYS_io_destroy: ::c_long = 1;
|
||||
|
@ -332,17 +332,6 @@ pub const SYS_pwritev2: ::c_long = 287;
|
|||
pub const SYS_pkey_mprotect: ::c_long = 288;
|
||||
pub const SYS_pkey_alloc: ::c_long = 289;
|
||||
pub const SYS_pkey_free: ::c_long = 290;
|
||||
pub const SYS_statx: ::c_long = 291;
|
||||
pub const SYS_pidfd_send_signal: ::c_long = 424;
|
||||
pub const SYS_io_uring_setup: ::c_long = 425;
|
||||
pub const SYS_io_uring_enter: ::c_long = 426;
|
||||
pub const SYS_io_uring_register: ::c_long = 427;
|
||||
pub const SYS_open_tree: ::c_long = 428;
|
||||
pub const SYS_move_mount: ::c_long = 429;
|
||||
pub const SYS_fsopen: ::c_long = 430;
|
||||
pub const SYS_fsconfig: ::c_long = 431;
|
||||
pub const SYS_fsmount: ::c_long = 432;
|
||||
pub const SYS_fspick: ::c_long = 433;
|
||||
pub const SYS_syscalls: ::c_long = 436;
|
||||
|
||||
cfg_if! {
|
||||
|
|
|
@ -728,17 +728,9 @@ pub const SYS_pwritev2: ::c_long = 328;
|
|||
pub const SYS_pkey_mprotect: ::c_long = 329;
|
||||
pub const SYS_pkey_alloc: ::c_long = 330;
|
||||
pub const SYS_pkey_free: ::c_long = 331;
|
||||
pub const SYS_statx: ::c_long = 332;
|
||||
pub const SYS_pidfd_send_signal: ::c_long = 424;
|
||||
pub const SYS_io_uring_setup: ::c_long = 425;
|
||||
pub const SYS_io_uring_enter: ::c_long = 426;
|
||||
pub const SYS_io_uring_register: ::c_long = 427;
|
||||
pub const SYS_open_tree: ::c_long = 428;
|
||||
pub const SYS_move_mount: ::c_long = 429;
|
||||
pub const SYS_fsopen: ::c_long = 430;
|
||||
pub const SYS_fsconfig: ::c_long = 431;
|
||||
pub const SYS_fsmount: ::c_long = 432;
|
||||
pub const SYS_fspick: ::c_long = 433;
|
||||
|
||||
// offsets in user_regs_structs, from sys/reg.h
|
||||
pub const R15: ::c_int = 0;
|
||||
|
|
|
@ -350,11 +350,6 @@ s! {
|
|||
pub args: [::__u64; 6],
|
||||
}
|
||||
|
||||
pub struct seccomp_metadata {
|
||||
pub filter_off: ::__u64,
|
||||
pub flags: ::__u64,
|
||||
}
|
||||
|
||||
pub struct ptrace_peeksiginfo_args {
|
||||
pub off: ::__u64,
|
||||
pub flags: ::__u32,
|
||||
|
@ -1446,26 +1441,12 @@ pub const SO_PEERSEC: ::c_int = 31;
|
|||
pub const SO_SNDBUFFORCE: ::c_int = 32;
|
||||
pub const SO_RCVBUFFORCE: ::c_int = 33;
|
||||
pub const SO_PASSSEC: ::c_int = 34;
|
||||
pub const SO_TIMESTAMPNS: ::c_int = 35;
|
||||
// pub const SO_TIMESTAMPNS_OLD: ::c_int = 35;
|
||||
pub const SO_MARK: ::c_int = 36;
|
||||
pub const SO_TIMESTAMPING: ::c_int = 37;
|
||||
// pub const SO_TIMESTAMPING_OLD: ::c_int = 37;
|
||||
pub const SO_PROTOCOL: ::c_int = 38;
|
||||
pub const SO_DOMAIN: ::c_int = 39;
|
||||
pub const SO_RXQ_OVFL: ::c_int = 40;
|
||||
pub const SO_PEEK_OFF: ::c_int = 42;
|
||||
pub const SO_BUSY_POLL: ::c_int = 46;
|
||||
pub const SCM_TIMESTAMPING_OPT_STATS: ::c_int = 54;
|
||||
pub const SCM_TIMESTAMPING_PKTINFO: ::c_int = 58;
|
||||
pub const SO_TIMESTAMP_NEW: ::c_int = 63;
|
||||
pub const SO_TIMESTAMPNS_NEW: ::c_int = 64;
|
||||
pub const SO_TIMESTAMPING_NEW: ::c_int = 65;
|
||||
|
||||
// Defined in unix/linux_like/mod.rs
|
||||
// pub const SCM_TIMESTAMP: ::c_int = SO_TIMESTAMP;
|
||||
pub const SCM_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS;
|
||||
pub const SCM_TIMESTAMPING: ::c_int = SO_TIMESTAMPING;
|
||||
|
||||
pub const IPTOS_ECN_NOTECT: u8 = 0x00;
|
||||
|
||||
|
@ -1527,7 +1508,6 @@ pub const PTRACE_GETSIGINFO: ::c_int = 0x4202;
|
|||
pub const PTRACE_SETSIGINFO: ::c_int = 0x4203;
|
||||
pub const PTRACE_GETREGSET: ::c_int = 0x4204;
|
||||
pub const PTRACE_SETREGSET: ::c_int = 0x4205;
|
||||
pub const PTRACE_SECCOMP_GET_METADATA: ::c_int = 0x420d;
|
||||
|
||||
pub const PTRACE_EVENT_STOP: ::c_int = 128;
|
||||
|
||||
|
@ -1599,23 +1579,6 @@ pub const FIONREAD: ::c_int = 0x541B;
|
|||
pub const TIOCCONS: ::c_int = 0x541D;
|
||||
pub const TIOCSBRK: ::c_int = 0x5427;
|
||||
pub const TIOCCBRK: ::c_int = 0x5428;
|
||||
cfg_if! {
|
||||
if #[cfg(any(target_arch = "x86",
|
||||
target_arch = "x86_64",
|
||||
target_arch = "arm",
|
||||
target_arch = "aarch64",
|
||||
target_arch = "riscv64",
|
||||
target_arch = "s390x"))] {
|
||||
pub const FICLONE: ::c_int = 0x40049409;
|
||||
pub const FICLONERANGE: ::c_int = 0x4020940D;
|
||||
} else if #[cfg(any(target_arch = "mips",
|
||||
target_arch = "mips64",
|
||||
target_arch = "powerpc",
|
||||
target_arch = "powerpc64"))] {
|
||||
pub const FICLONE: ::c_int = 0x80049409;
|
||||
pub const FICLONERANGE: ::c_int = 0x8020940D;
|
||||
}
|
||||
}
|
||||
|
||||
pub const ST_RDONLY: ::c_ulong = 1;
|
||||
pub const ST_NOSUID: ::c_ulong = 2;
|
||||
|
@ -1643,14 +1606,6 @@ pub const AI_ADDRCONFIG: ::c_int = 0x00000400;
|
|||
pub const AI_V4MAPPED: ::c_int = 0x00000800;
|
||||
pub const AI_DEFAULT: ::c_int = AI_V4MAPPED_CFG | AI_ADDRCONFIG;
|
||||
|
||||
// linux/kexec.h
|
||||
pub const KEXEC_ON_CRASH: ::c_int = 0x00000001;
|
||||
pub const KEXEC_PRESERVE_CONTEXT: ::c_int = 0x00000002;
|
||||
pub const KEXEC_ARCH_MASK: ::c_int = 0xffff0000;
|
||||
pub const KEXEC_FILE_UNLOAD: ::c_int = 0x00000001;
|
||||
pub const KEXEC_FILE_ON_CRASH: ::c_int = 0x00000002;
|
||||
pub const KEXEC_FILE_NO_INITRAMFS: ::c_int = 0x00000004;
|
||||
|
||||
pub const LINUX_REBOOT_MAGIC1: ::c_int = 0xfee1dead;
|
||||
pub const LINUX_REBOOT_MAGIC2: ::c_int = 672274793;
|
||||
pub const LINUX_REBOOT_MAGIC2A: ::c_int = 85072278;
|
||||
|
@ -1837,7 +1792,6 @@ pub const NLM_F_MULTI: ::c_int = 2;
|
|||
pub const NLM_F_ACK: ::c_int = 4;
|
||||
pub const NLM_F_ECHO: ::c_int = 8;
|
||||
pub const NLM_F_DUMP_INTR: ::c_int = 16;
|
||||
pub const NLM_F_DUMP_FILTERED: ::c_int = 32;
|
||||
|
||||
pub const NLM_F_ROOT: ::c_int = 0x100;
|
||||
pub const NLM_F_MATCH: ::c_int = 0x200;
|
||||
|
@ -2167,10 +2121,6 @@ pub const PT_HIOS: u32 = 0x6fffffff;
|
|||
pub const PT_LOPROC: u32 = 0x70000000;
|
||||
pub const PT_HIPROC: u32 = 0x7fffffff;
|
||||
|
||||
// uapi/linux/mount.h
|
||||
pub const OPEN_TREE_CLONE: ::c_uint = 0x01;
|
||||
pub const OPEN_TREE_CLOEXEC: ::c_uint = O_CLOEXEC as ::c_uint;
|
||||
|
||||
// linux/netfilter.h
|
||||
pub const NF_DROP: ::c_int = 0;
|
||||
pub const NF_ACCEPT: ::c_int = 1;
|
||||
|
@ -2487,7 +2437,8 @@ pub const IFF_PERSIST: ::c_int = 0x0800;
|
|||
pub const IFF_NOFILTER: ::c_int = 0x1000;
|
||||
|
||||
// start android/platform/bionic/libc/kernel/uapi/linux/if_ether.h
|
||||
// from https://android.googlesource.com/platform/bionic/+/HEAD/libc/kernel/uapi/linux/if_ether.h
|
||||
// from https://android.googlesource.com/
|
||||
// platform/bionic/+/master/libc/kernel/uapi/linux/if_ether.h
|
||||
pub const ETH_ALEN: ::c_int = 6;
|
||||
pub const ETH_HLEN: ::c_int = 14;
|
||||
pub const ETH_ZLEN: ::c_int = 60;
|
||||
|
@ -2587,88 +2538,6 @@ pub const ETH_P_XDSA: ::c_int = 0x00F8;
|
|||
/* see rust-lang/libc#924 pub const ETH_P_MAP: ::c_int = 0x00F9;*/
|
||||
// end android/platform/bionic/libc/kernel/uapi/linux/if_ether.h
|
||||
|
||||
// start android/platform/bionic/libc/kernel/uapi/linux/neighbour.h
|
||||
pub const NDA_UNSPEC: ::c_ushort = 0;
|
||||
pub const NDA_DST: ::c_ushort = 1;
|
||||
pub const NDA_LLADDR: ::c_ushort = 2;
|
||||
pub const NDA_CACHEINFO: ::c_ushort = 3;
|
||||
pub const NDA_PROBES: ::c_ushort = 4;
|
||||
pub const NDA_VLAN: ::c_ushort = 5;
|
||||
pub const NDA_PORT: ::c_ushort = 6;
|
||||
pub const NDA_VNI: ::c_ushort = 7;
|
||||
pub const NDA_IFINDEX: ::c_ushort = 8;
|
||||
pub const NDA_MASTER: ::c_ushort = 9;
|
||||
pub const NDA_LINK_NETNSID: ::c_ushort = 10;
|
||||
pub const NDA_SRC_VNI: ::c_ushort = 11;
|
||||
pub const NDA_PROTOCOL: ::c_ushort = 12;
|
||||
pub const NDA_NH_ID: ::c_ushort = 13;
|
||||
pub const NDA_FDB_EXT_ATTRS: ::c_ushort = 14;
|
||||
pub const NDA_FLAGS_EXT: ::c_ushort = 15;
|
||||
pub const NDA_NDM_STATE_MASK: ::c_ushort = 16;
|
||||
pub const NDA_NDM_FLAGS_MASK: ::c_ushort = 17;
|
||||
|
||||
pub const NTF_USE: u8 = 0x01;
|
||||
pub const NTF_SELF: u8 = 0x02;
|
||||
pub const NTF_MASTER: u8 = 0x04;
|
||||
pub const NTF_PROXY: u8 = 0x08;
|
||||
pub const NTF_EXT_LEARNED: u8 = 0x10;
|
||||
pub const NTF_OFFLOADED: u8 = 0x20;
|
||||
pub const NTF_STICKY: u8 = 0x40;
|
||||
pub const NTF_ROUTER: u8 = 0x80;
|
||||
|
||||
pub const NTF_EXT_MANAGED: u8 = 0x01;
|
||||
pub const NTF_EXT_LOCKED: u8 = 0x02;
|
||||
|
||||
pub const NUD_NONE: u16 = 0x00;
|
||||
pub const NUD_INCOMPLETE: u16 = 0x01;
|
||||
pub const NUD_REACHABLE: u16 = 0x02;
|
||||
pub const NUD_STALE: u16 = 0x04;
|
||||
pub const NUD_DELAY: u16 = 0x08;
|
||||
pub const NUD_PROBE: u16 = 0x10;
|
||||
pub const NUD_FAILED: u16 = 0x20;
|
||||
pub const NUD_NOARP: u16 = 0x40;
|
||||
pub const NUD_PERMANENT: u16 = 0x80;
|
||||
|
||||
pub const NDTPA_UNSPEC: ::c_ushort = 0;
|
||||
pub const NDTPA_IFINDEX: ::c_ushort = 1;
|
||||
pub const NDTPA_REFCNT: ::c_ushort = 2;
|
||||
pub const NDTPA_REACHABLE_TIME: ::c_ushort = 3;
|
||||
pub const NDTPA_BASE_REACHABLE_TIME: ::c_ushort = 4;
|
||||
pub const NDTPA_RETRANS_TIME: ::c_ushort = 5;
|
||||
pub const NDTPA_GC_STALETIME: ::c_ushort = 6;
|
||||
pub const NDTPA_DELAY_PROBE_TIME: ::c_ushort = 7;
|
||||
pub const NDTPA_QUEUE_LEN: ::c_ushort = 8;
|
||||
pub const NDTPA_APP_PROBES: ::c_ushort = 9;
|
||||
pub const NDTPA_UCAST_PROBES: ::c_ushort = 10;
|
||||
pub const NDTPA_MCAST_PROBES: ::c_ushort = 11;
|
||||
pub const NDTPA_ANYCAST_DELAY: ::c_ushort = 12;
|
||||
pub const NDTPA_PROXY_DELAY: ::c_ushort = 13;
|
||||
pub const NDTPA_PROXY_QLEN: ::c_ushort = 14;
|
||||
pub const NDTPA_LOCKTIME: ::c_ushort = 15;
|
||||
pub const NDTPA_QUEUE_LENBYTES: ::c_ushort = 16;
|
||||
pub const NDTPA_MCAST_REPROBES: ::c_ushort = 17;
|
||||
pub const NDTPA_PAD: ::c_ushort = 18;
|
||||
pub const NDTPA_INTERVAL_PROBE_TIME_MS: ::c_ushort = 19;
|
||||
|
||||
pub const NDTA_UNSPEC: ::c_ushort = 0;
|
||||
pub const NDTA_NAME: ::c_ushort = 1;
|
||||
pub const NDTA_THRESH1: ::c_ushort = 2;
|
||||
pub const NDTA_THRESH2: ::c_ushort = 3;
|
||||
pub const NDTA_THRESH3: ::c_ushort = 4;
|
||||
pub const NDTA_CONFIG: ::c_ushort = 5;
|
||||
pub const NDTA_PARMS: ::c_ushort = 6;
|
||||
pub const NDTA_STATS: ::c_ushort = 7;
|
||||
pub const NDTA_GC_INTERVAL: ::c_ushort = 8;
|
||||
pub const NDTA_PAD: ::c_ushort = 9;
|
||||
|
||||
pub const FDB_NOTIFY_BIT: u16 = 0x01;
|
||||
pub const FDB_NOTIFY_INACTIVE_BIT: u16 = 0x02;
|
||||
|
||||
pub const NFEA_UNSPEC: ::c_ushort = 0;
|
||||
pub const NFEA_ACTIVITY_NOTIFY: ::c_ushort = 1;
|
||||
pub const NFEA_DONT_REFRESH: ::c_ushort = 2;
|
||||
// end android/platform/bionic/libc/kernel/uapi/linux/neighbour.h
|
||||
|
||||
pub const SIOCADDRT: ::c_ulong = 0x0000890B;
|
||||
pub const SIOCDELRT: ::c_ulong = 0x0000890C;
|
||||
pub const SIOCGIFNAME: ::c_ulong = 0x00008910;
|
||||
|
@ -2711,23 +2580,6 @@ pub const SIOCSIFMAP: ::c_ulong = 0x00008971;
|
|||
pub const MODULE_INIT_IGNORE_MODVERSIONS: ::c_uint = 0x0001;
|
||||
pub const MODULE_INIT_IGNORE_VERMAGIC: ::c_uint = 0x0002;
|
||||
|
||||
// linux/net_tstamp.h
|
||||
pub const SOF_TIMESTAMPING_TX_HARDWARE: ::c_uint = 1 << 0;
|
||||
pub const SOF_TIMESTAMPING_TX_SOFTWARE: ::c_uint = 1 << 1;
|
||||
pub const SOF_TIMESTAMPING_RX_HARDWARE: ::c_uint = 1 << 2;
|
||||
pub const SOF_TIMESTAMPING_RX_SOFTWARE: ::c_uint = 1 << 3;
|
||||
pub const SOF_TIMESTAMPING_SOFTWARE: ::c_uint = 1 << 4;
|
||||
pub const SOF_TIMESTAMPING_SYS_HARDWARE: ::c_uint = 1 << 5;
|
||||
pub const SOF_TIMESTAMPING_RAW_HARDWARE: ::c_uint = 1 << 6;
|
||||
pub const SOF_TIMESTAMPING_OPT_ID: ::c_uint = 1 << 7;
|
||||
pub const SOF_TIMESTAMPING_TX_SCHED: ::c_uint = 1 << 8;
|
||||
pub const SOF_TIMESTAMPING_TX_ACK: ::c_uint = 1 << 9;
|
||||
pub const SOF_TIMESTAMPING_OPT_CMSG: ::c_uint = 1 << 10;
|
||||
pub const SOF_TIMESTAMPING_OPT_TSONLY: ::c_uint = 1 << 11;
|
||||
pub const SOF_TIMESTAMPING_OPT_STATS: ::c_uint = 1 << 12;
|
||||
pub const SOF_TIMESTAMPING_OPT_PKTINFO: ::c_uint = 1 << 13;
|
||||
pub const SOF_TIMESTAMPING_OPT_TX_SWHW: ::c_uint = 1 << 14;
|
||||
|
||||
#[deprecated(
|
||||
since = "0.2.55",
|
||||
note = "ENOATTR is not available on Android; use ENODATA instead"
|
||||
|
@ -2876,18 +2728,6 @@ pub const SCHED_RESET_ON_FORK: ::c_int = 0x40000000;
|
|||
|
||||
pub const CLONE_PIDFD: ::c_int = 0x1000;
|
||||
|
||||
// linux/membarrier.h
|
||||
pub const MEMBARRIER_CMD_QUERY: ::c_int = 0;
|
||||
pub const MEMBARRIER_CMD_GLOBAL: ::c_int = 1 << 0;
|
||||
pub const MEMBARRIER_CMD_GLOBAL_EXPEDITED: ::c_int = 1 << 1;
|
||||
pub const MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED: ::c_int = 1 << 2;
|
||||
pub const MEMBARRIER_CMD_PRIVATE_EXPEDITED: ::c_int = 1 << 3;
|
||||
pub const MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED: ::c_int = 1 << 4;
|
||||
pub const MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE: ::c_int = 1 << 5;
|
||||
pub const MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE: ::c_int = 1 << 6;
|
||||
pub const MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ: ::c_int = 1 << 7;
|
||||
pub const MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ: ::c_int = 1 << 8;
|
||||
|
||||
// linux/mempolicy.h
|
||||
pub const MPOL_DEFAULT: ::c_int = 0;
|
||||
pub const MPOL_PREFERRED: ::c_int = 1;
|
||||
|
@ -3006,19 +2846,6 @@ pub const IFLA_CARRIER_DOWN_COUNT: ::c_ushort = 48;
|
|||
pub const IFLA_NEW_IFINDEX: ::c_ushort = 49;
|
||||
pub const IFLA_MIN_MTU: ::c_ushort = 50;
|
||||
pub const IFLA_MAX_MTU: ::c_ushort = 51;
|
||||
pub const IFLA_PROP_LIST: ::c_ushort = 52;
|
||||
pub const IFLA_ALT_IFNAME: ::c_ushort = 53;
|
||||
pub const IFLA_PERM_ADDRESS: ::c_ushort = 54;
|
||||
pub const IFLA_PROTO_DOWN_REASON: ::c_ushort = 55;
|
||||
pub const IFLA_PARENT_DEV_NAME: ::c_ushort = 56;
|
||||
pub const IFLA_PARENT_DEV_BUS_NAME: ::c_ushort = 57;
|
||||
pub const IFLA_GRO_MAX_SIZE: ::c_ushort = 58;
|
||||
pub const IFLA_TSO_MAX_SIZE: ::c_ushort = 59;
|
||||
pub const IFLA_TSO_MAX_SEGS: ::c_ushort = 60;
|
||||
pub const IFLA_ALLMULTI: ::c_ushort = 61;
|
||||
pub const IFLA_DEVLINK_PORT: ::c_ushort = 62;
|
||||
pub const IFLA_GSO_IPV4_MAX_SIZE: ::c_ushort = 63;
|
||||
pub const IFLA_GRO_IPV4_MAX_SIZE: ::c_ushort = 64;
|
||||
|
||||
pub const IFLA_INFO_UNSPEC: ::c_ushort = 0;
|
||||
pub const IFLA_INFO_KIND: ::c_ushort = 1;
|
||||
|
@ -3516,13 +3343,7 @@ extern "C" {
|
|||
pub fn sendfile(
|
||||
out_fd: ::c_int,
|
||||
in_fd: ::c_int,
|
||||
offset: *mut ::off_t,
|
||||
count: ::size_t,
|
||||
) -> ::ssize_t;
|
||||
pub fn sendfile64(
|
||||
out_fd: ::c_int,
|
||||
in_fd: ::c_int,
|
||||
offset: *mut ::off64_t,
|
||||
offset: *mut off_t,
|
||||
count: ::size_t,
|
||||
) -> ::ssize_t;
|
||||
pub fn setfsgid(gid: ::gid_t) -> ::c_int;
|
||||
|
@ -3642,9 +3463,7 @@ extern "C" {
|
|||
|
||||
pub fn gettid() -> ::pid_t;
|
||||
|
||||
/// Only available in API Version 28+
|
||||
pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t;
|
||||
pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int;
|
||||
|
||||
pub fn pthread_setname_np(thread: ::pthread_t, name: *const ::c_char) -> ::c_int;
|
||||
|
||||
|
@ -3687,16 +3506,6 @@ extern "C" {
|
|||
longopts: *const option,
|
||||
longindex: *mut ::c_int,
|
||||
) -> ::c_int;
|
||||
|
||||
pub fn sync();
|
||||
pub fn syncfs(fd: ::c_int) -> ::c_int;
|
||||
|
||||
pub fn memmem(
|
||||
haystack: *const ::c_void,
|
||||
haystacklen: ::size_t,
|
||||
needle: *const ::c_void,
|
||||
needlelen: ::size_t,
|
||||
) -> *mut ::c_void;
|
||||
}
|
||||
|
||||
cfg_if! {
|
||||
|
|
|
@ -260,16 +260,13 @@ s! {
|
|||
}
|
||||
pub struct stat {
|
||||
pub st_dev: ::dev_t,
|
||||
#[cfg(not(emscripten_new_stat_abi))]
|
||||
__st_dev_padding: ::c_int,
|
||||
#[cfg(not(emscripten_new_stat_abi))]
|
||||
__st_ino_truncated: ::c_long,
|
||||
pub st_mode: ::mode_t,
|
||||
pub st_nlink: ::nlink_t,
|
||||
pub st_uid: ::uid_t,
|
||||
pub st_gid: ::gid_t,
|
||||
pub st_rdev: ::dev_t,
|
||||
#[cfg(not(emscripten_new_stat_abi))]
|
||||
__st_rdev_padding: ::c_int,
|
||||
pub st_size: ::off_t,
|
||||
pub st_blksize: ::blksize_t,
|
||||
|
@ -285,16 +282,13 @@ s! {
|
|||
|
||||
pub struct stat64 {
|
||||
pub st_dev: ::dev_t,
|
||||
#[cfg(not(emscripten_new_stat_abi))]
|
||||
__st_dev_padding: ::c_int,
|
||||
#[cfg(not(emscripten_new_stat_abi))]
|
||||
__st_ino_truncated: ::c_long,
|
||||
pub st_mode: ::mode_t,
|
||||
pub st_nlink: ::nlink_t,
|
||||
pub st_uid: ::uid_t,
|
||||
pub st_gid: ::gid_t,
|
||||
pub st_rdev: ::dev_t,
|
||||
#[cfg(not(emscripten_new_stat_abi))]
|
||||
__st_rdev_padding: ::c_int,
|
||||
pub st_size: ::off_t,
|
||||
pub st_blksize: ::blksize_t,
|
||||
|
@ -1125,7 +1119,6 @@ pub const PR_SET_MM_MAP: ::c_int = 14;
|
|||
pub const PR_SET_MM_MAP_SIZE: ::c_int = 15;
|
||||
|
||||
pub const PR_SET_PTRACER: ::c_int = 0x59616d61;
|
||||
pub const PR_SET_PTRACER_ANY: ::c_ulong = 0xffffffffffffffff;
|
||||
|
||||
pub const PR_SET_CHILD_SUBREAPER: ::c_int = 36;
|
||||
pub const PR_GET_CHILD_SUBREAPER: ::c_int = 37;
|
||||
|
@ -1731,7 +1724,7 @@ f! {
|
|||
pub fn major(dev: ::dev_t) -> ::c_uint {
|
||||
// see
|
||||
// https://github.com/emscripten-core/emscripten/blob/
|
||||
// main/system/lib/libc/musl/include/sys/sysmacros.h
|
||||
// master/system/include/libc/sys/sysmacros.h
|
||||
let mut major = 0;
|
||||
major |= (dev & 0x00000fff) >> 8;
|
||||
major |= (dev & 0xfffff000) >> 31 >> 1;
|
||||
|
@ -1741,7 +1734,7 @@ f! {
|
|||
pub fn minor(dev: ::dev_t) -> ::c_uint {
|
||||
// see
|
||||
// https://github.com/emscripten-core/emscripten/blob/
|
||||
// main/system/lib/libc/musl/include/sys/sysmacros.h
|
||||
// master/system/include/libc/sys/sysmacros.h
|
||||
let mut minor = 0;
|
||||
minor |= (dev & 0x000000ff) >> 0;
|
||||
minor |= (dev & 0xffffff00) >> 12;
|
||||
|
@ -1821,6 +1814,7 @@ extern "C" {
|
|||
) -> ::c_int;
|
||||
pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int;
|
||||
|
||||
// Not available now on Android
|
||||
pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char, mode: ::mode_t) -> ::c_int;
|
||||
pub fn if_nameindex() -> *mut if_nameindex;
|
||||
pub fn if_freenameindex(ptr: *mut if_nameindex);
|
||||
|
@ -1888,8 +1882,6 @@ extern "C" {
|
|||
f: extern "C" fn(*mut ::c_void) -> *mut ::c_void,
|
||||
value: *mut ::c_void,
|
||||
) -> ::c_int;
|
||||
|
||||
pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int;
|
||||
}
|
||||
|
||||
cfg_if! {
|
||||
|
|
|
@ -5,7 +5,6 @@ macro_rules! expand_align {
|
|||
target_arch = "x86_64",
|
||||
target_arch = "powerpc64",
|
||||
target_arch = "mips64",
|
||||
target_arch = "mips64r6",
|
||||
target_arch = "s390x",
|
||||
target_arch = "sparc64",
|
||||
target_arch = "aarch64",
|
||||
|
@ -17,7 +16,6 @@ macro_rules! expand_align {
|
|||
target_arch = "x86_64",
|
||||
target_arch = "powerpc64",
|
||||
target_arch = "mips64",
|
||||
target_arch = "mips64r6",
|
||||
target_arch = "s390x",
|
||||
target_arch = "sparc64",
|
||||
target_arch = "aarch64",
|
||||
|
@ -30,10 +28,9 @@ macro_rules! expand_align {
|
|||
size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T],
|
||||
}
|
||||
|
||||
#[cfg_attr(any(target_env = "musl", target_env = "ohos", target_pointer_width = "32"),
|
||||
#[cfg_attr(any(target_env = "musl", target_pointer_width = "32"),
|
||||
repr(align(4)))]
|
||||
#[cfg_attr(all(not(target_env = "musl"),
|
||||
not(target_env = "ohos"),
|
||||
target_pointer_width = "64"),
|
||||
repr(align(8)))]
|
||||
pub struct pthread_rwlockattr_t {
|
||||
|
@ -47,12 +44,6 @@ macro_rules! expand_align {
|
|||
size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T],
|
||||
}
|
||||
|
||||
#[repr(align(4))]
|
||||
pub struct pthread_barrierattr_t {
|
||||
#[doc(hidden)]
|
||||
size: [u8; ::__SIZEOF_PTHREAD_BARRIERATTR_T],
|
||||
}
|
||||
|
||||
#[repr(align(8))]
|
||||
pub struct fanotify_event_metadata {
|
||||
pub event_len: __u32,
|
||||
|
@ -66,16 +57,16 @@ macro_rules! expand_align {
|
|||
}
|
||||
|
||||
s_no_extra_traits! {
|
||||
#[cfg_attr(all(any(target_env = "musl", target_env = "ohos"),
|
||||
#[cfg_attr(all(target_env = "musl",
|
||||
target_pointer_width = "32"),
|
||||
repr(align(4)))]
|
||||
#[cfg_attr(all(any(target_env = "musl", target_env = "ohos"),
|
||||
#[cfg_attr(all(target_env = "musl",
|
||||
target_pointer_width = "64"),
|
||||
repr(align(8)))]
|
||||
#[cfg_attr(all(not(any(target_env = "musl", target_env = "ohos")),
|
||||
#[cfg_attr(all(not(target_env = "musl"),
|
||||
target_arch = "x86"),
|
||||
repr(align(4)))]
|
||||
#[cfg_attr(all(not(any(target_env = "musl", target_env = "ohos")),
|
||||
#[cfg_attr(all(not(target_env = "musl"),
|
||||
not(target_arch = "x86")),
|
||||
repr(align(8)))]
|
||||
pub struct pthread_cond_t {
|
||||
|
@ -85,11 +76,9 @@ macro_rules! expand_align {
|
|||
|
||||
#[cfg_attr(all(target_pointer_width = "32",
|
||||
any(target_arch = "mips",
|
||||
target_arch = "mips32r6",
|
||||
target_arch = "arm",
|
||||
target_arch = "hexagon",
|
||||
target_arch = "m68k",
|
||||
target_arch = "csky",
|
||||
target_arch = "powerpc",
|
||||
target_arch = "sparc",
|
||||
target_arch = "x86_64",
|
||||
|
@ -97,11 +86,9 @@ macro_rules! expand_align {
|
|||
repr(align(4)))]
|
||||
#[cfg_attr(any(target_pointer_width = "64",
|
||||
not(any(target_arch = "mips",
|
||||
target_arch = "mips32r6",
|
||||
target_arch = "arm",
|
||||
target_arch = "hexagon",
|
||||
target_arch = "m68k",
|
||||
target_arch = "csky",
|
||||
target_arch = "powerpc",
|
||||
target_arch = "sparc",
|
||||
target_arch = "x86_64",
|
||||
|
@ -114,11 +101,9 @@ macro_rules! expand_align {
|
|||
|
||||
#[cfg_attr(all(target_pointer_width = "32",
|
||||
any(target_arch = "mips",
|
||||
target_arch = "mips32r6",
|
||||
target_arch = "arm",
|
||||
target_arch = "hexagon",
|
||||
target_arch = "m68k",
|
||||
target_arch = "csky",
|
||||
target_arch = "powerpc",
|
||||
target_arch = "sparc",
|
||||
target_arch = "x86_64",
|
||||
|
@ -126,7 +111,6 @@ macro_rules! expand_align {
|
|||
repr(align(4)))]
|
||||
#[cfg_attr(any(target_pointer_width = "64",
|
||||
not(any(target_arch = "mips",
|
||||
target_arch = "mips32r6",
|
||||
target_arch = "arm",
|
||||
target_arch = "hexagon",
|
||||
target_arch = "m68k",
|
||||
|
@ -139,34 +123,6 @@ macro_rules! expand_align {
|
|||
size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T],
|
||||
}
|
||||
|
||||
#[cfg_attr(all(target_pointer_width = "32",
|
||||
any(target_arch = "mips",
|
||||
target_arch = "mips32r6",
|
||||
target_arch = "arm",
|
||||
target_arch = "hexagon",
|
||||
target_arch = "m68k",
|
||||
target_arch = "csky",
|
||||
target_arch = "powerpc",
|
||||
target_arch = "sparc",
|
||||
target_arch = "x86_64",
|
||||
target_arch = "x86")),
|
||||
repr(align(4)))]
|
||||
#[cfg_attr(any(target_pointer_width = "64",
|
||||
not(any(target_arch = "mips",
|
||||
target_arch = "mips32r6",
|
||||
target_arch = "arm",
|
||||
target_arch = "hexagon",
|
||||
target_arch = "m68k",
|
||||
target_arch = "csky",
|
||||
target_arch = "powerpc",
|
||||
target_arch = "sparc",
|
||||
target_arch = "x86_64",
|
||||
target_arch = "x86"))),
|
||||
repr(align(8)))]
|
||||
pub struct pthread_barrier_t {
|
||||
size: [u8; ::__SIZEOF_PTHREAD_BARRIER_T],
|
||||
}
|
||||
|
||||
// linux/can.h
|
||||
#[repr(align(8))]
|
||||
#[allow(missing_debug_implementations)]
|
||||
|
@ -189,17 +145,6 @@ macro_rules! expand_align {
|
|||
__res1: u8,
|
||||
pub data: [u8; CANFD_MAX_DLEN],
|
||||
}
|
||||
|
||||
#[repr(align(8))]
|
||||
#[allow(missing_debug_implementations)]
|
||||
pub struct canxl_frame {
|
||||
pub prio: canid_t,
|
||||
pub flags: u8,
|
||||
pub sdt: u8,
|
||||
pub len: u16,
|
||||
pub af: u32,
|
||||
pub data: [u8; CANXL_MAX_DLEN],
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -94,10 +94,8 @@ cfg_if! {
|
|||
// But they may still not have those _OLD ones.
|
||||
if #[cfg(all(any(target_arch = "x86",
|
||||
target_arch = "x86_64",
|
||||
target_arch = "aarch64",
|
||||
target_arch = "csky",
|
||||
target_arch = "loongarch64"),
|
||||
not(any(target_env = "musl", target_env = "ohos"))))] {
|
||||
target_arch = "aarch64"),
|
||||
not(target_env = "musl")))] {
|
||||
pub const SO_TIMESTAMP_NEW: ::c_int = 63;
|
||||
pub const SO_TIMESTAMPNS_NEW: ::c_int = 64;
|
||||
pub const SO_TIMESTAMPING_NEW: ::c_int = 65;
|
||||
|
@ -106,22 +104,17 @@ cfg_if! {
|
|||
pub const SO_DETACH_REUSEPORT_BPF: ::c_int = 68;
|
||||
}
|
||||
}
|
||||
// pub const SO_PREFER_BUSY_POLL: ::c_int = 69;
|
||||
// pub const SO_BUSY_POLL_BUDGET: ::c_int = 70;
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(any(target_arch = "x86",
|
||||
target_arch = "x86_64",
|
||||
target_arch = "arm",
|
||||
target_arch = "aarch64",
|
||||
target_arch = "riscv64",
|
||||
target_arch = "s390x",
|
||||
target_arch = "csky",
|
||||
target_arch = "loongarch64"))] {
|
||||
target_arch = "aarch64"))] {
|
||||
pub const FICLONE: ::c_ulong = 0x40049409;
|
||||
pub const FICLONERANGE: ::c_ulong = 0x4020940D;
|
||||
}
|
||||
}
|
||||
// pub const SO_PREFER_BUSY_POLL: ::c_int = 69;
|
||||
// pub const SO_BUSY_POLL_BUDGET: ::c_int = 70;
|
||||
|
||||
// Defined in unix/linux_like/mod.rs
|
||||
// pub const SCM_TIMESTAMP: ::c_int = SO_TIMESTAMP;
|
||||
|
@ -259,7 +252,7 @@ cfg_if! {
|
|||
pub const RLIMIT_RTTIME: ::__rlimit_resource_t = 15;
|
||||
pub const RLIMIT_NLIMITS: ::__rlimit_resource_t = RLIM_NLIMITS;
|
||||
|
||||
} else if #[cfg(any(target_env = "musl", target_env = "ohos"))] {
|
||||
} else if #[cfg(target_env = "musl")] {
|
||||
|
||||
pub const RLIMIT_CPU: ::c_int = 0;
|
||||
pub const RLIMIT_FSIZE: ::c_int = 1;
|
||||
|
|
|
@ -103,9 +103,6 @@ pub const SO_TIMESTAMPING: ::c_int = 37;
|
|||
// pub const SO_PREFER_BUSY_POLL: ::c_int = 69;
|
||||
// pub const SO_BUSY_POLL_BUDGET: ::c_int = 70;
|
||||
|
||||
pub const FICLONE: ::c_ulong = 0x80049409;
|
||||
pub const FICLONERANGE: ::c_ulong = 0x8020940D;
|
||||
|
||||
// Defined in unix/linux_like/mod.rs
|
||||
// pub const SCM_TIMESTAMP: ::c_int = SO_TIMESTAMP;
|
||||
pub const SCM_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS;
|
||||
|
@ -272,7 +269,7 @@ cfg_if! {
|
|||
}
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(any(target_arch = "mips64", target_arch = "mips64r6"),
|
||||
if #[cfg(target_arch = "mips64",
|
||||
any(target_env = "gnu",
|
||||
target_env = "uclibc"))] {
|
||||
pub const RLIM_INFINITY: ::rlim_t = !0;
|
||||
|
@ -280,7 +277,7 @@ cfg_if! {
|
|||
}
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(any(target_arch = "mips", target_arch = "mips32r6"),
|
||||
if #[cfg(target_arch = "mips",
|
||||
any(target_env = "gnu",
|
||||
target_env = "uclibc"))] {
|
||||
pub const RLIM_INFINITY: ::rlim_t = 0x7fffffff;
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
cfg_if! {
|
||||
if #[cfg(any(target_arch = "mips",
|
||||
target_arch = "mips32r6",
|
||||
target_arch = "mips64",
|
||||
target_arch = "mips64r6"))] {
|
||||
if #[cfg(any(target_arch = "mips", target_arch = "mips64"))] {
|
||||
mod mips;
|
||||
pub use self::mips::*;
|
||||
} else if #[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))] {
|
||||
|
|
|
@ -85,9 +85,6 @@ pub const SO_BINDTOIFINDEX: ::c_int = 62;
|
|||
// pub const SO_PREFER_BUSY_POLL: ::c_int = 69;
|
||||
// pub const SO_BUSY_POLL_BUDGET: ::c_int = 70;
|
||||
|
||||
pub const FICLONE: ::c_ulong = 0x80049409;
|
||||
pub const FICLONERANGE: ::c_ulong = 0x8020940D;
|
||||
|
||||
// Defined in unix/linux_like/mod.rs
|
||||
// pub const SCM_TIMESTAMP: ::c_int = SO_TIMESTAMP;
|
||||
pub const SCM_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS;
|
||||
|
|
|
@ -191,27 +191,6 @@ s! {
|
|||
pub arm_cpsr: ::c_ulong,
|
||||
pub fault_address: ::c_ulong,
|
||||
}
|
||||
|
||||
pub struct user_regs {
|
||||
pub arm_r0: ::c_ulong,
|
||||
pub arm_r1: ::c_ulong,
|
||||
pub arm_r2: ::c_ulong,
|
||||
pub arm_r3: ::c_ulong,
|
||||
pub arm_r4: ::c_ulong,
|
||||
pub arm_r5: ::c_ulong,
|
||||
pub arm_r6: ::c_ulong,
|
||||
pub arm_r7: ::c_ulong,
|
||||
pub arm_r8: ::c_ulong,
|
||||
pub arm_r9: ::c_ulong,
|
||||
pub arm_r10: ::c_ulong,
|
||||
pub arm_fp: ::c_ulong,
|
||||
pub arm_ip: ::c_ulong,
|
||||
pub arm_sp: ::c_ulong,
|
||||
pub arm_lr: ::c_ulong,
|
||||
pub arm_pc: ::c_ulong,
|
||||
pub arm_cpsr: ::c_ulong,
|
||||
pub arm_orig_r0: ::c_ulong,
|
||||
}
|
||||
}
|
||||
|
||||
pub const VEOF: usize = 4;
|
||||
|
@ -837,7 +816,6 @@ pub const SYS_pkey_alloc: ::c_long = 395;
|
|||
pub const SYS_pkey_free: ::c_long = 396;
|
||||
pub const SYS_statx: ::c_long = 397;
|
||||
pub const SYS_rseq: ::c_long = 398;
|
||||
pub const SYS_kexec_file_load: ::c_long = 401;
|
||||
pub const SYS_pidfd_send_signal: ::c_long = 424;
|
||||
pub const SYS_io_uring_setup: ::c_long = 425;
|
||||
pub const SYS_io_uring_enter: ::c_long = 426;
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
s_no_extra_traits! {
|
||||
#[allow(missing_debug_implementations)]
|
||||
#[repr(align(8))]
|
||||
pub struct max_align_t {
|
||||
priv_: [i64; 2]
|
||||
}
|
||||
}
|
|
@ -1,745 +0,0 @@
|
|||
pub type c_char = u8;
|
||||
pub type wchar_t = u32;
|
||||
|
||||
s! {
|
||||
pub struct sigaction {
|
||||
pub sa_sigaction: ::sighandler_t,
|
||||
pub sa_mask: ::sigset_t,
|
||||
pub sa_flags: ::c_int,
|
||||
pub sa_restorer: ::Option<extern fn()>,
|
||||
}
|
||||
|
||||
pub struct statfs {
|
||||
pub f_type: ::__fsword_t,
|
||||
pub f_bsize: ::__fsword_t,
|
||||
pub f_blocks: ::fsblkcnt_t,
|
||||
pub f_bfree: ::fsblkcnt_t,
|
||||
pub f_bavail: ::fsblkcnt_t,
|
||||
|
||||
pub f_files: ::fsfilcnt_t,
|
||||
pub f_ffree: ::fsfilcnt_t,
|
||||
pub f_fsid: ::fsid_t,
|
||||
|
||||
pub f_namelen: ::__fsword_t,
|
||||
pub f_frsize: ::__fsword_t,
|
||||
f_spare: [::__fsword_t; 5],
|
||||
}
|
||||
|
||||
pub struct flock {
|
||||
pub l_type: ::c_short,
|
||||
pub l_whence: ::c_short,
|
||||
pub l_start: ::off_t,
|
||||
pub l_len: ::off_t,
|
||||
pub l_pid: ::pid_t,
|
||||
}
|
||||
|
||||
pub struct flock64 {
|
||||
pub l_type: ::c_short,
|
||||
pub l_whence: ::c_short,
|
||||
pub l_start: ::off64_t,
|
||||
pub l_len: ::off64_t,
|
||||
pub l_pid: ::pid_t,
|
||||
}
|
||||
|
||||
pub struct ipc_perm {
|
||||
pub __key: ::key_t,
|
||||
pub uid: ::uid_t,
|
||||
pub gid: ::gid_t,
|
||||
pub cuid: ::uid_t,
|
||||
pub cgid: ::gid_t,
|
||||
pub mode: ::c_ushort,
|
||||
__pad1: ::c_ushort,
|
||||
pub __seq: ::c_ushort,
|
||||
__pad2: ::c_ushort,
|
||||
__unused1: ::c_ulong,
|
||||
__unused2: ::c_ulong
|
||||
}
|
||||
|
||||
pub struct stat64 {
|
||||
pub st_dev: ::dev_t,
|
||||
__pad1: ::c_uint,
|
||||
__st_ino: ::ino_t,
|
||||
pub st_mode: ::mode_t,
|
||||
pub st_nlink: ::nlink_t,
|
||||
pub st_uid: ::uid_t,
|
||||
pub st_gid: ::gid_t,
|
||||
pub st_rdev: ::dev_t,
|
||||
__pad2: ::c_uint,
|
||||
pub st_size: ::off64_t,
|
||||
pub st_blksize: ::blksize_t,
|
||||
pub st_blocks: ::blkcnt64_t,
|
||||
pub st_atime: ::time_t,
|
||||
pub st_atime_nsec: ::c_long,
|
||||
pub st_mtime: ::time_t,
|
||||
pub st_mtime_nsec: ::c_long,
|
||||
pub st_ctime: ::time_t,
|
||||
pub st_ctime_nsec: ::c_long,
|
||||
pub st_ino: ::ino64_t,
|
||||
}
|
||||
|
||||
pub struct statfs64 {
|
||||
pub f_type: ::__fsword_t,
|
||||
pub f_bsize: ::__fsword_t,
|
||||
pub f_blocks: u64,
|
||||
pub f_bfree: u64,
|
||||
pub f_bavail: u64,
|
||||
pub f_files: u64,
|
||||
pub f_ffree: u64,
|
||||
pub f_fsid: ::fsid_t,
|
||||
pub f_namelen: ::__fsword_t,
|
||||
pub f_frsize: ::__fsword_t,
|
||||
pub f_flags: ::__fsword_t,
|
||||
pub f_spare: [::__fsword_t; 4],
|
||||
}
|
||||
|
||||
pub struct statvfs64 {
|
||||
pub f_bsize: ::c_ulong,
|
||||
pub f_frsize: ::c_ulong,
|
||||
pub f_blocks: u64,
|
||||
pub f_bfree: u64,
|
||||
pub f_bavail: u64,
|
||||
pub f_files: u64,
|
||||
pub f_ffree: u64,
|
||||
pub f_favail: u64,
|
||||
pub f_fsid: ::c_ulong,
|
||||
__f_unused: ::c_int,
|
||||
pub f_flag: ::c_ulong,
|
||||
pub f_namemax: ::c_ulong,
|
||||
__f_spare: [::c_int; 6],
|
||||
}
|
||||
|
||||
pub struct shmid_ds {
|
||||
pub shm_perm: ::ipc_perm,
|
||||
pub shm_segsz: ::size_t,
|
||||
pub shm_atime: ::time_t,
|
||||
__unused1: ::c_ulong,
|
||||
pub shm_dtime: ::time_t,
|
||||
__unused2: ::c_ulong,
|
||||
pub shm_ctime: ::time_t,
|
||||
__unused3: ::c_ulong,
|
||||
pub shm_cpid: ::pid_t,
|
||||
pub shm_lpid: ::pid_t,
|
||||
pub shm_nattch: ::shmatt_t,
|
||||
__unused4: ::c_ulong,
|
||||
__unused5: ::c_ulong
|
||||
}
|
||||
|
||||
pub struct msqid_ds {
|
||||
pub msg_perm: ::ipc_perm,
|
||||
pub msg_stime: ::time_t,
|
||||
__glibc_reserved1: ::c_ulong,
|
||||
pub msg_rtime: ::time_t,
|
||||
__glibc_reserved2: ::c_ulong,
|
||||
pub msg_ctime: ::time_t,
|
||||
__glibc_reserved3: ::c_ulong,
|
||||
__msg_cbytes: ::c_ulong,
|
||||
pub msg_qnum: ::msgqnum_t,
|
||||
pub msg_qbytes: ::msglen_t,
|
||||
pub msg_lspid: ::pid_t,
|
||||
pub msg_lrpid: ::pid_t,
|
||||
__glibc_reserved4: ::c_ulong,
|
||||
__glibc_reserved5: ::c_ulong,
|
||||
}
|
||||
|
||||
pub struct siginfo_t {
|
||||
pub si_signo: ::c_int,
|
||||
pub si_errno: ::c_int,
|
||||
pub si_code: ::c_int,
|
||||
#[doc(hidden)]
|
||||
#[deprecated(
|
||||
since="0.2.54",
|
||||
note="Please leave a comment on \
|
||||
https://github.com/rust-lang/libc/pull/1316 if you're using \
|
||||
this field"
|
||||
)]
|
||||
pub _pad: [::c_int; 29],
|
||||
_align: [usize; 0],
|
||||
}
|
||||
|
||||
pub struct stack_t {
|
||||
pub ss_sp: *mut ::c_void,
|
||||
pub ss_flags: ::c_int,
|
||||
pub ss_size: ::size_t
|
||||
}
|
||||
}
|
||||
|
||||
pub const VEOF: usize = 4;
|
||||
pub const RTLD_DEEPBIND: ::c_int = 0x8;
|
||||
pub const RTLD_GLOBAL: ::c_int = 0x100;
|
||||
pub const RTLD_NOLOAD: ::c_int = 0x4;
|
||||
pub const O_DIRECT: ::c_int = 0x4000;
|
||||
pub const O_DIRECTORY: ::c_int = 0x10000;
|
||||
pub const O_NOFOLLOW: ::c_int = 0x20000;
|
||||
pub const O_LARGEFILE: ::c_int = 0o100000;
|
||||
pub const O_APPEND: ::c_int = 1024;
|
||||
pub const O_CREAT: ::c_int = 64;
|
||||
pub const O_EXCL: ::c_int = 128;
|
||||
pub const O_NOCTTY: ::c_int = 256;
|
||||
pub const O_NONBLOCK: ::c_int = 2048;
|
||||
pub const O_SYNC: ::c_int = 1052672;
|
||||
pub const O_RSYNC: ::c_int = 1052672;
|
||||
pub const O_DSYNC: ::c_int = 4096;
|
||||
pub const O_FSYNC: ::c_int = 0x101000;
|
||||
pub const O_ASYNC: ::c_int = 0x2000;
|
||||
pub const O_NDELAY: ::c_int = 0x800;
|
||||
|
||||
pub const MADV_SOFT_OFFLINE: ::c_int = 101;
|
||||
pub const MAP_LOCKED: ::c_int = 0x02000;
|
||||
pub const MAP_NORESERVE: ::c_int = 0x04000;
|
||||
pub const MAP_ANON: ::c_int = 0x0020;
|
||||
pub const MAP_ANONYMOUS: ::c_int = 0x0020;
|
||||
pub const MAP_DENYWRITE: ::c_int = 0x0800;
|
||||
pub const MAP_EXECUTABLE: ::c_int = 0x01000;
|
||||
pub const MAP_POPULATE: ::c_int = 0x08000;
|
||||
pub const MAP_NONBLOCK: ::c_int = 0x010000;
|
||||
pub const MAP_STACK: ::c_int = 0x020000;
|
||||
pub const MAP_HUGETLB: ::c_int = 0x040000;
|
||||
pub const MAP_GROWSDOWN: ::c_int = 0x0100;
|
||||
pub const MAP_SYNC: ::c_int = 0x080000;
|
||||
|
||||
pub const EDEADLOCK: ::c_int = 35;
|
||||
pub const EUCLEAN: ::c_int = 117;
|
||||
pub const ENOTNAM: ::c_int = 118;
|
||||
pub const ENAVAIL: ::c_int = 119;
|
||||
pub const EISNAM: ::c_int = 120;
|
||||
pub const EREMOTEIO: ::c_int = 121;
|
||||
pub const EDEADLK: ::c_int = 35;
|
||||
pub const ENAMETOOLONG: ::c_int = 36;
|
||||
pub const ENOLCK: ::c_int = 37;
|
||||
pub const ENOSYS: ::c_int = 38;
|
||||
pub const ENOTEMPTY: ::c_int = 39;
|
||||
pub const ELOOP: ::c_int = 40;
|
||||
pub const ENOMSG: ::c_int = 42;
|
||||
pub const EIDRM: ::c_int = 43;
|
||||
pub const ECHRNG: ::c_int = 44;
|
||||
pub const EL2NSYNC: ::c_int = 45;
|
||||
pub const EL3HLT: ::c_int = 46;
|
||||
pub const EL3RST: ::c_int = 47;
|
||||
pub const ELNRNG: ::c_int = 48;
|
||||
pub const EUNATCH: ::c_int = 49;
|
||||
pub const ENOCSI: ::c_int = 50;
|
||||
pub const EL2HLT: ::c_int = 51;
|
||||
pub const EBADE: ::c_int = 52;
|
||||
pub const EBADR: ::c_int = 53;
|
||||
pub const EXFULL: ::c_int = 54;
|
||||
pub const ENOANO: ::c_int = 55;
|
||||
pub const EBADRQC: ::c_int = 56;
|
||||
pub const EBADSLT: ::c_int = 57;
|
||||
pub const EMULTIHOP: ::c_int = 72;
|
||||
pub const EOVERFLOW: ::c_int = 75;
|
||||
pub const ENOTUNIQ: ::c_int = 76;
|
||||
pub const EBADFD: ::c_int = 77;
|
||||
pub const EBADMSG: ::c_int = 74;
|
||||
pub const EREMCHG: ::c_int = 78;
|
||||
pub const ELIBACC: ::c_int = 79;
|
||||
pub const ELIBBAD: ::c_int = 80;
|
||||
pub const ELIBSCN: ::c_int = 81;
|
||||
pub const ELIBMAX: ::c_int = 82;
|
||||
pub const ELIBEXEC: ::c_int = 83;
|
||||
pub const EILSEQ: ::c_int = 84;
|
||||
pub const ERESTART: ::c_int = 85;
|
||||
pub const ESTRPIPE: ::c_int = 86;
|
||||
pub const EUSERS: ::c_int = 87;
|
||||
pub const ENOTSOCK: ::c_int = 88;
|
||||
pub const EDESTADDRREQ: ::c_int = 89;
|
||||
pub const EMSGSIZE: ::c_int = 90;
|
||||
pub const EPROTOTYPE: ::c_int = 91;
|
||||
pub const ENOPROTOOPT: ::c_int = 92;
|
||||
pub const EPROTONOSUPPORT: ::c_int = 93;
|
||||
pub const ESOCKTNOSUPPORT: ::c_int = 94;
|
||||
pub const EOPNOTSUPP: ::c_int = 95;
|
||||
pub const EPFNOSUPPORT: ::c_int = 96;
|
||||
pub const EAFNOSUPPORT: ::c_int = 97;
|
||||
pub const EADDRINUSE: ::c_int = 98;
|
||||
pub const EADDRNOTAVAIL: ::c_int = 99;
|
||||
pub const ENETDOWN: ::c_int = 100;
|
||||
pub const ENETUNREACH: ::c_int = 101;
|
||||
pub const ENETRESET: ::c_int = 102;
|
||||
pub const ECONNABORTED: ::c_int = 103;
|
||||
pub const ECONNRESET: ::c_int = 104;
|
||||
pub const ENOBUFS: ::c_int = 105;
|
||||
pub const EISCONN: ::c_int = 106;
|
||||
pub const ENOTCONN: ::c_int = 107;
|
||||
pub const ESHUTDOWN: ::c_int = 108;
|
||||
pub const ETOOMANYREFS: ::c_int = 109;
|
||||
pub const ETIMEDOUT: ::c_int = 110;
|
||||
pub const ECONNREFUSED: ::c_int = 111;
|
||||
pub const EHOSTDOWN: ::c_int = 112;
|
||||
pub const EHOSTUNREACH: ::c_int = 113;
|
||||
pub const EALREADY: ::c_int = 114;
|
||||
pub const EINPROGRESS: ::c_int = 115;
|
||||
pub const ESTALE: ::c_int = 116;
|
||||
pub const EDQUOT: ::c_int = 122;
|
||||
pub const ENOMEDIUM: ::c_int = 123;
|
||||
pub const EMEDIUMTYPE: ::c_int = 124;
|
||||
pub const ECANCELED: ::c_int = 125;
|
||||
pub const ENOKEY: ::c_int = 126;
|
||||
pub const EKEYEXPIRED: ::c_int = 127;
|
||||
pub const EKEYREVOKED: ::c_int = 128;
|
||||
pub const EKEYREJECTED: ::c_int = 129;
|
||||
pub const EOWNERDEAD: ::c_int = 130;
|
||||
pub const ENOTRECOVERABLE: ::c_int = 131;
|
||||
pub const EHWPOISON: ::c_int = 133;
|
||||
pub const ERFKILL: ::c_int = 132;
|
||||
|
||||
pub const SA_SIGINFO: ::c_int = 0x00000004;
|
||||
pub const SA_NOCLDWAIT: ::c_int = 0x00000002;
|
||||
|
||||
pub const SOCK_STREAM: ::c_int = 1;
|
||||
pub const SOCK_DGRAM: ::c_int = 2;
|
||||
|
||||
pub const MCL_CURRENT: ::c_int = 0x0001;
|
||||
pub const MCL_FUTURE: ::c_int = 0x0002;
|
||||
|
||||
pub const POLLWRNORM: ::c_short = 0x100;
|
||||
pub const POLLWRBAND: ::c_short = 0x200;
|
||||
|
||||
pub const F_GETLK: ::c_int = 5;
|
||||
pub const F_GETOWN: ::c_int = 9;
|
||||
pub const F_SETOWN: ::c_int = 8;
|
||||
|
||||
pub const EFD_NONBLOCK: ::c_int = 0x800;
|
||||
pub const SFD_NONBLOCK: ::c_int = 0x0800;
|
||||
|
||||
pub const SIGCHLD: ::c_int = 17;
|
||||
pub const SIGBUS: ::c_int = 7;
|
||||
pub const SIGUSR1: ::c_int = 10;
|
||||
pub const SIGUSR2: ::c_int = 12;
|
||||
pub const SIGCONT: ::c_int = 18;
|
||||
pub const SIGSTOP: ::c_int = 19;
|
||||
pub const SIGTSTP: ::c_int = 20;
|
||||
pub const SIGURG: ::c_int = 23;
|
||||
pub const SIGIO: ::c_int = 29;
|
||||
pub const SIGSYS: ::c_int = 31;
|
||||
pub const SIGSTKFLT: ::c_int = 16;
|
||||
#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")]
|
||||
pub const SIGUNUSED: ::c_int = 31;
|
||||
pub const SIGPOLL: ::c_int = 29;
|
||||
pub const SIGPWR: ::c_int = 30;
|
||||
pub const SIG_SETMASK: ::c_int = 2;
|
||||
pub const SIG_BLOCK: ::c_int = 0x000000;
|
||||
pub const SIG_UNBLOCK: ::c_int = 0x01;
|
||||
pub const SIGTTIN: ::c_int = 21;
|
||||
pub const SIGTTOU: ::c_int = 22;
|
||||
pub const SIGXCPU: ::c_int = 24;
|
||||
pub const SIGXFSZ: ::c_int = 25;
|
||||
pub const SIGVTALRM: ::c_int = 26;
|
||||
pub const SIGPROF: ::c_int = 27;
|
||||
pub const SIGWINCH: ::c_int = 28;
|
||||
pub const SIGSTKSZ: ::size_t = 8192;
|
||||
pub const MINSIGSTKSZ: ::size_t = 2048;
|
||||
pub const CBAUD: ::tcflag_t = 0o0010017;
|
||||
pub const TAB1: ::tcflag_t = 0x00000800;
|
||||
pub const TAB2: ::tcflag_t = 0x00001000;
|
||||
pub const TAB3: ::tcflag_t = 0x00001800;
|
||||
pub const CR1: ::tcflag_t = 0x00000200;
|
||||
pub const CR2: ::tcflag_t = 0x00000400;
|
||||
pub const CR3: ::tcflag_t = 0x00000600;
|
||||
pub const FF1: ::tcflag_t = 0x00008000;
|
||||
pub const BS1: ::tcflag_t = 0x00002000;
|
||||
pub const VT1: ::tcflag_t = 0x00004000;
|
||||
pub const VWERASE: usize = 14;
|
||||
pub const VREPRINT: usize = 12;
|
||||
pub const VSUSP: usize = 10;
|
||||
pub const VSTART: usize = 8;
|
||||
pub const VSTOP: usize = 9;
|
||||
pub const VDISCARD: usize = 13;
|
||||
pub const VTIME: usize = 5;
|
||||
pub const IXON: ::tcflag_t = 0x00000400;
|
||||
pub const IXOFF: ::tcflag_t = 0x00001000;
|
||||
pub const ONLCR: ::tcflag_t = 0x4;
|
||||
pub const CSIZE: ::tcflag_t = 0x00000030;
|
||||
pub const CS6: ::tcflag_t = 0x00000010;
|
||||
pub const CS7: ::tcflag_t = 0x00000020;
|
||||
pub const CS8: ::tcflag_t = 0x00000030;
|
||||
pub const CSTOPB: ::tcflag_t = 0x00000040;
|
||||
pub const CREAD: ::tcflag_t = 0x00000080;
|
||||
pub const PARENB: ::tcflag_t = 0x00000100;
|
||||
pub const PARODD: ::tcflag_t = 0x00000200;
|
||||
pub const HUPCL: ::tcflag_t = 0x00000400;
|
||||
pub const CLOCAL: ::tcflag_t = 0x00000800;
|
||||
pub const ECHOKE: ::tcflag_t = 0x00000800;
|
||||
pub const ECHOE: ::tcflag_t = 0x00000010;
|
||||
pub const ECHOK: ::tcflag_t = 0x00000020;
|
||||
pub const ECHONL: ::tcflag_t = 0x00000040;
|
||||
pub const ECHOPRT: ::tcflag_t = 0x00000400;
|
||||
pub const ECHOCTL: ::tcflag_t = 0x00000200;
|
||||
pub const ISIG: ::tcflag_t = 0x00000001;
|
||||
pub const ICANON: ::tcflag_t = 0x00000002;
|
||||
pub const PENDIN: ::tcflag_t = 0x00004000;
|
||||
pub const NOFLSH: ::tcflag_t = 0x00000080;
|
||||
pub const CIBAUD: ::tcflag_t = 0o02003600000;
|
||||
pub const CBAUDEX: ::tcflag_t = 0o010000;
|
||||
pub const VSWTC: usize = 7;
|
||||
pub const OLCUC: ::tcflag_t = 0o000002;
|
||||
pub const NLDLY: ::tcflag_t = 0o000400;
|
||||
pub const CRDLY: ::tcflag_t = 0o003000;
|
||||
pub const TABDLY: ::tcflag_t = 0o014000;
|
||||
pub const BSDLY: ::tcflag_t = 0o020000;
|
||||
pub const FFDLY: ::tcflag_t = 0o100000;
|
||||
pub const VTDLY: ::tcflag_t = 0o040000;
|
||||
pub const XTABS: ::tcflag_t = 0o014000;
|
||||
|
||||
pub const B0: ::speed_t = 0o000000;
|
||||
pub const B50: ::speed_t = 0o000001;
|
||||
pub const B75: ::speed_t = 0o000002;
|
||||
pub const B110: ::speed_t = 0o000003;
|
||||
pub const B134: ::speed_t = 0o000004;
|
||||
pub const B150: ::speed_t = 0o000005;
|
||||
pub const B200: ::speed_t = 0o000006;
|
||||
pub const B300: ::speed_t = 0o000007;
|
||||
pub const B600: ::speed_t = 0o000010;
|
||||
pub const B1200: ::speed_t = 0o000011;
|
||||
pub const B1800: ::speed_t = 0o000012;
|
||||
pub const B2400: ::speed_t = 0o000013;
|
||||
pub const B4800: ::speed_t = 0o000014;
|
||||
pub const B9600: ::speed_t = 0o000015;
|
||||
pub const B19200: ::speed_t = 0o000016;
|
||||
pub const B38400: ::speed_t = 0o000017;
|
||||
pub const EXTA: ::speed_t = B19200;
|
||||
pub const EXTB: ::speed_t = B38400;
|
||||
pub const B57600: ::speed_t = 0o010001;
|
||||
pub const B115200: ::speed_t = 0o010002;
|
||||
pub const B230400: ::speed_t = 0o010003;
|
||||
pub const B460800: ::speed_t = 0o010004;
|
||||
pub const B500000: ::speed_t = 0o010005;
|
||||
pub const B576000: ::speed_t = 0o010006;
|
||||
pub const B921600: ::speed_t = 0o010007;
|
||||
pub const B1000000: ::speed_t = 0o010010;
|
||||
pub const B1152000: ::speed_t = 0o010011;
|
||||
pub const B1500000: ::speed_t = 0o010012;
|
||||
pub const B2000000: ::speed_t = 0o010013;
|
||||
pub const B2500000: ::speed_t = 0o010014;
|
||||
pub const B3000000: ::speed_t = 0o010015;
|
||||
pub const B3500000: ::speed_t = 0o010016;
|
||||
pub const B4000000: ::speed_t = 0o010017;
|
||||
|
||||
pub const SECCOMP_SET_MODE_STRICT: ::c_uint = 0;
|
||||
pub const SECCOMP_SET_MODE_FILTER: ::c_uint = 1;
|
||||
pub const SECCOMP_GET_ACTION_AVAIL: ::c_uint = 2;
|
||||
pub const SECCOMP_GET_NOTIF_SIZES: ::c_uint = 3;
|
||||
|
||||
pub const VEOL: usize = 11;
|
||||
pub const VEOL2: usize = 16;
|
||||
pub const VMIN: usize = 6;
|
||||
pub const IEXTEN: ::tcflag_t = 0x00008000;
|
||||
pub const TOSTOP: ::tcflag_t = 0x00000100;
|
||||
pub const FLUSHO: ::tcflag_t = 0x00001000;
|
||||
pub const EXTPROC: ::tcflag_t = 0x00010000;
|
||||
|
||||
pub const TCSANOW: ::c_int = 0;
|
||||
pub const TCSADRAIN: ::c_int = 1;
|
||||
pub const TCSAFLUSH: ::c_int = 2;
|
||||
|
||||
// Syscall table
|
||||
pub const SYS_read: ::c_long = 63;
|
||||
pub const SYS_write: ::c_long = 64;
|
||||
pub const SYS_close: ::c_long = 57;
|
||||
pub const SYS_fstat: ::c_long = 80;
|
||||
pub const SYS_lseek: ::c_long = 62;
|
||||
pub const SYS_mmap: ::c_long = 222;
|
||||
pub const SYS_mprotect: ::c_long = 226;
|
||||
pub const SYS_munmap: ::c_long = 215;
|
||||
pub const SYS_brk: ::c_long = 214;
|
||||
pub const SYS_rt_sigaction: ::c_long = 134;
|
||||
pub const SYS_rt_sigprocmask: ::c_long = 135;
|
||||
pub const SYS_rt_sigreturn: ::c_long = 139;
|
||||
pub const SYS_ioctl: ::c_long = 29;
|
||||
pub const SYS_pread64: ::c_long = 67;
|
||||
pub const SYS_pwrite64: ::c_long = 68;
|
||||
pub const SYS_readv: ::c_long = 65;
|
||||
pub const SYS_writev: ::c_long = 66;
|
||||
pub const SYS_sched_yield: ::c_long = 124;
|
||||
pub const SYS_mremap: ::c_long = 216;
|
||||
pub const SYS_msync: ::c_long = 227;
|
||||
pub const SYS_mincore: ::c_long = 232;
|
||||
pub const SYS_madvise: ::c_long = 233;
|
||||
pub const SYS_shmget: ::c_long = 194;
|
||||
pub const SYS_shmat: ::c_long = 196;
|
||||
pub const SYS_shmctl: ::c_long = 195;
|
||||
pub const SYS_dup: ::c_long = 23;
|
||||
pub const SYS_nanosleep: ::c_long = 101;
|
||||
pub const SYS_getitimer: ::c_long = 102;
|
||||
pub const SYS_setitimer: ::c_long = 103;
|
||||
pub const SYS_getpid: ::c_long = 172;
|
||||
pub const SYS_sendfile: ::c_long = 71;
|
||||
pub const SYS_socket: ::c_long = 198;
|
||||
pub const SYS_connect: ::c_long = 203;
|
||||
pub const SYS_accept: ::c_long = 202;
|
||||
pub const SYS_sendto: ::c_long = 206;
|
||||
pub const SYS_recvfrom: ::c_long = 207;
|
||||
pub const SYS_sendmsg: ::c_long = 211;
|
||||
pub const SYS_recvmsg: ::c_long = 212;
|
||||
pub const SYS_shutdown: ::c_long = 210;
|
||||
pub const SYS_bind: ::c_long = 200;
|
||||
pub const SYS_listen: ::c_long = 201;
|
||||
pub const SYS_getsockname: ::c_long = 204;
|
||||
pub const SYS_getpeername: ::c_long = 205;
|
||||
pub const SYS_socketpair: ::c_long = 199;
|
||||
pub const SYS_setsockopt: ::c_long = 208;
|
||||
pub const SYS_getsockopt: ::c_long = 209;
|
||||
pub const SYS_clone: ::c_long = 220;
|
||||
pub const SYS_execve: ::c_long = 221;
|
||||
pub const SYS_exit: ::c_long = 93;
|
||||
pub const SYS_wait4: ::c_long = 260;
|
||||
pub const SYS_kill: ::c_long = 129;
|
||||
pub const SYS_uname: ::c_long = 160;
|
||||
pub const SYS_semget: ::c_long = 190;
|
||||
pub const SYS_semop: ::c_long = 193;
|
||||
pub const SYS_semctl: ::c_long = 191;
|
||||
pub const SYS_shmdt: ::c_long = 197;
|
||||
pub const SYS_msgget: ::c_long = 186;
|
||||
pub const SYS_msgsnd: ::c_long = 189;
|
||||
pub const SYS_msgrcv: ::c_long = 188;
|
||||
pub const SYS_msgctl: ::c_long = 187;
|
||||
pub const SYS_fcntl: ::c_long = 25;
|
||||
pub const SYS_flock: ::c_long = 32;
|
||||
pub const SYS_fsync: ::c_long = 82;
|
||||
pub const SYS_fdatasync: ::c_long = 83;
|
||||
pub const SYS_truncate: ::c_long = 45;
|
||||
pub const SYS_ftruncate: ::c_long = 46;
|
||||
pub const SYS_getcwd: ::c_long = 17;
|
||||
pub const SYS_chdir: ::c_long = 49;
|
||||
pub const SYS_fchdir: ::c_long = 50;
|
||||
pub const SYS_fchmod: ::c_long = 52;
|
||||
pub const SYS_fchown: ::c_long = 55;
|
||||
pub const SYS_umask: ::c_long = 166;
|
||||
pub const SYS_gettimeofday: ::c_long = 169;
|
||||
pub const SYS_getrlimit: ::c_long = 163;
|
||||
pub const SYS_getrusage: ::c_long = 165;
|
||||
pub const SYS_sysinfo: ::c_long = 179;
|
||||
pub const SYS_times: ::c_long = 153;
|
||||
pub const SYS_ptrace: ::c_long = 117;
|
||||
pub const SYS_getuid: ::c_long = 174;
|
||||
pub const SYS_syslog: ::c_long = 116;
|
||||
pub const SYS_getgid: ::c_long = 176;
|
||||
pub const SYS_setuid: ::c_long = 146;
|
||||
pub const SYS_setgid: ::c_long = 144;
|
||||
pub const SYS_geteuid: ::c_long = 175;
|
||||
pub const SYS_getegid: ::c_long = 177;
|
||||
pub const SYS_setpgid: ::c_long = 154;
|
||||
pub const SYS_getppid: ::c_long = 173;
|
||||
pub const SYS_setsid: ::c_long = 157;
|
||||
pub const SYS_setreuid: ::c_long = 145;
|
||||
pub const SYS_setregid: ::c_long = 143;
|
||||
pub const SYS_getgroups: ::c_long = 158;
|
||||
pub const SYS_setgroups: ::c_long = 159;
|
||||
pub const SYS_setresuid: ::c_long = 147;
|
||||
pub const SYS_getresuid: ::c_long = 148;
|
||||
pub const SYS_setresgid: ::c_long = 149;
|
||||
pub const SYS_getresgid: ::c_long = 150;
|
||||
pub const SYS_getpgid: ::c_long = 155;
|
||||
pub const SYS_setfsuid: ::c_long = 151;
|
||||
pub const SYS_setfsgid: ::c_long = 152;
|
||||
pub const SYS_getsid: ::c_long = 156;
|
||||
pub const SYS_capget: ::c_long = 90;
|
||||
pub const SYS_capset: ::c_long = 91;
|
||||
pub const SYS_rt_sigpending: ::c_long = 136;
|
||||
pub const SYS_rt_sigtimedwait: ::c_long = 137;
|
||||
pub const SYS_rt_sigqueueinfo: ::c_long = 138;
|
||||
pub const SYS_rt_sigsuspend: ::c_long = 133;
|
||||
pub const SYS_sigaltstack: ::c_long = 132;
|
||||
pub const SYS_personality: ::c_long = 92;
|
||||
pub const SYS_statfs: ::c_long = 43;
|
||||
pub const SYS_fstatfs: ::c_long = 44;
|
||||
pub const SYS_getpriority: ::c_long = 141;
|
||||
pub const SYS_setpriority: ::c_long = 140;
|
||||
pub const SYS_sched_setparam: ::c_long = 118;
|
||||
pub const SYS_sched_getparam: ::c_long = 121;
|
||||
pub const SYS_sched_setscheduler: ::c_long = 119;
|
||||
pub const SYS_sched_getscheduler: ::c_long = 120;
|
||||
pub const SYS_sched_get_priority_max: ::c_long = 125;
|
||||
pub const SYS_sched_get_priority_min: ::c_long = 126;
|
||||
pub const SYS_sched_rr_get_interval: ::c_long = 127;
|
||||
pub const SYS_mlock: ::c_long = 228;
|
||||
pub const SYS_munlock: ::c_long = 229;
|
||||
pub const SYS_mlockall: ::c_long = 230;
|
||||
pub const SYS_munlockall: ::c_long = 231;
|
||||
pub const SYS_vhangup: ::c_long = 58;
|
||||
pub const SYS_pivot_root: ::c_long = 41;
|
||||
pub const SYS_prctl: ::c_long = 167;
|
||||
pub const SYS_adjtimex: ::c_long = 171;
|
||||
pub const SYS_setrlimit: ::c_long = 164;
|
||||
pub const SYS_chroot: ::c_long = 51;
|
||||
pub const SYS_sync: ::c_long = 81;
|
||||
pub const SYS_acct: ::c_long = 89;
|
||||
pub const SYS_settimeofday: ::c_long = 170;
|
||||
pub const SYS_mount: ::c_long = 40;
|
||||
pub const SYS_umount2: ::c_long = 39;
|
||||
pub const SYS_swapon: ::c_long = 224;
|
||||
pub const SYS_swapoff: ::c_long = 225;
|
||||
pub const SYS_reboot: ::c_long = 142;
|
||||
pub const SYS_sethostname: ::c_long = 161;
|
||||
pub const SYS_setdomainname: ::c_long = 162;
|
||||
pub const SYS_init_module: ::c_long = 105;
|
||||
pub const SYS_delete_module: ::c_long = 106;
|
||||
pub const SYS_quotactl: ::c_long = 60;
|
||||
pub const SYS_nfsservctl: ::c_long = 42;
|
||||
pub const SYS_gettid: ::c_long = 178;
|
||||
pub const SYS_readahead: ::c_long = 213;
|
||||
pub const SYS_setxattr: ::c_long = 5;
|
||||
pub const SYS_lsetxattr: ::c_long = 6;
|
||||
pub const SYS_fsetxattr: ::c_long = 7;
|
||||
pub const SYS_getxattr: ::c_long = 8;
|
||||
pub const SYS_lgetxattr: ::c_long = 9;
|
||||
pub const SYS_fgetxattr: ::c_long = 10;
|
||||
pub const SYS_listxattr: ::c_long = 11;
|
||||
pub const SYS_llistxattr: ::c_long = 12;
|
||||
pub const SYS_flistxattr: ::c_long = 13;
|
||||
pub const SYS_removexattr: ::c_long = 14;
|
||||
pub const SYS_lremovexattr: ::c_long = 15;
|
||||
pub const SYS_fremovexattr: ::c_long = 16;
|
||||
pub const SYS_tkill: ::c_long = 130;
|
||||
pub const SYS_futex: ::c_long = 98;
|
||||
pub const SYS_sched_setaffinity: ::c_long = 122;
|
||||
pub const SYS_sched_getaffinity: ::c_long = 123;
|
||||
pub const SYS_io_setup: ::c_long = 0;
|
||||
pub const SYS_io_destroy: ::c_long = 1;
|
||||
pub const SYS_io_getevents: ::c_long = 4;
|
||||
pub const SYS_io_submit: ::c_long = 2;
|
||||
pub const SYS_io_cancel: ::c_long = 3;
|
||||
pub const SYS_lookup_dcookie: ::c_long = 18;
|
||||
pub const SYS_remap_file_pages: ::c_long = 234;
|
||||
pub const SYS_getdents64: ::c_long = 61;
|
||||
pub const SYS_set_tid_address: ::c_long = 96;
|
||||
pub const SYS_restart_syscall: ::c_long = 128;
|
||||
pub const SYS_semtimedop: ::c_long = 192;
|
||||
pub const SYS_fadvise64: ::c_long = 223;
|
||||
pub const SYS_timer_create: ::c_long = 107;
|
||||
pub const SYS_timer_settime: ::c_long = 110;
|
||||
pub const SYS_timer_gettime: ::c_long = 108;
|
||||
pub const SYS_timer_getoverrun: ::c_long = 109;
|
||||
pub const SYS_timer_delete: ::c_long = 111;
|
||||
pub const SYS_clock_settime: ::c_long = 112;
|
||||
pub const SYS_clock_gettime: ::c_long = 113;
|
||||
pub const SYS_clock_getres: ::c_long = 114;
|
||||
pub const SYS_clock_nanosleep: ::c_long = 115;
|
||||
pub const SYS_exit_group: ::c_long = 94;
|
||||
pub const SYS_epoll_ctl: ::c_long = 21;
|
||||
pub const SYS_tgkill: ::c_long = 131;
|
||||
pub const SYS_mbind: ::c_long = 235;
|
||||
pub const SYS_set_mempolicy: ::c_long = 237;
|
||||
pub const SYS_get_mempolicy: ::c_long = 236;
|
||||
pub const SYS_mq_open: ::c_long = 180;
|
||||
pub const SYS_mq_unlink: ::c_long = 181;
|
||||
pub const SYS_mq_timedsend: ::c_long = 182;
|
||||
pub const SYS_mq_timedreceive: ::c_long = 183;
|
||||
pub const SYS_mq_notify: ::c_long = 184;
|
||||
pub const SYS_mq_getsetattr: ::c_long = 185;
|
||||
pub const SYS_kexec_load: ::c_long = 104;
|
||||
pub const SYS_waitid: ::c_long = 95;
|
||||
pub const SYS_add_key: ::c_long = 217;
|
||||
pub const SYS_request_key: ::c_long = 218;
|
||||
pub const SYS_keyctl: ::c_long = 219;
|
||||
pub const SYS_ioprio_set: ::c_long = 30;
|
||||
pub const SYS_ioprio_get: ::c_long = 31;
|
||||
pub const SYS_inotify_add_watch: ::c_long = 27;
|
||||
pub const SYS_inotify_rm_watch: ::c_long = 28;
|
||||
pub const SYS_migrate_pages: ::c_long = 238;
|
||||
pub const SYS_openat: ::c_long = 56;
|
||||
pub const SYS_mkdirat: ::c_long = 34;
|
||||
pub const SYS_mknodat: ::c_long = 33;
|
||||
pub const SYS_fchownat: ::c_long = 54;
|
||||
pub const SYS_newfstatat: ::c_long = 79;
|
||||
pub const SYS_unlinkat: ::c_long = 35;
|
||||
pub const SYS_linkat: ::c_long = 37;
|
||||
pub const SYS_symlinkat: ::c_long = 36;
|
||||
pub const SYS_readlinkat: ::c_long = 78;
|
||||
pub const SYS_fchmodat: ::c_long = 53;
|
||||
pub const SYS_faccessat: ::c_long = 48;
|
||||
pub const SYS_pselect6: ::c_long = 72;
|
||||
pub const SYS_ppoll: ::c_long = 73;
|
||||
pub const SYS_unshare: ::c_long = 97;
|
||||
pub const SYS_set_robust_list: ::c_long = 99;
|
||||
pub const SYS_get_robust_list: ::c_long = 100;
|
||||
pub const SYS_splice: ::c_long = 76;
|
||||
pub const SYS_tee: ::c_long = 77;
|
||||
pub const SYS_sync_file_range: ::c_long = 84;
|
||||
pub const SYS_vmsplice: ::c_long = 75;
|
||||
pub const SYS_move_pages: ::c_long = 239;
|
||||
pub const SYS_utimensat: ::c_long = 88;
|
||||
pub const SYS_epoll_pwait: ::c_long = 22;
|
||||
pub const SYS_timerfd_create: ::c_long = 85;
|
||||
pub const SYS_fallocate: ::c_long = 47;
|
||||
pub const SYS_timerfd_settime: ::c_long = 86;
|
||||
pub const SYS_timerfd_gettime: ::c_long = 87;
|
||||
pub const SYS_accept4: ::c_long = 242;
|
||||
pub const SYS_signalfd4: ::c_long = 74;
|
||||
pub const SYS_eventfd2: ::c_long = 19;
|
||||
pub const SYS_epoll_create1: ::c_long = 20;
|
||||
pub const SYS_dup3: ::c_long = 24;
|
||||
pub const SYS_pipe2: ::c_long = 59;
|
||||
pub const SYS_inotify_init1: ::c_long = 26;
|
||||
pub const SYS_preadv: ::c_long = 69;
|
||||
pub const SYS_pwritev: ::c_long = 70;
|
||||
pub const SYS_rt_tgsigqueueinfo: ::c_long = 240;
|
||||
pub const SYS_perf_event_open: ::c_long = 241;
|
||||
pub const SYS_recvmmsg: ::c_long = 243;
|
||||
pub const SYS_fanotify_init: ::c_long = 262;
|
||||
pub const SYS_fanotify_mark: ::c_long = 263;
|
||||
pub const SYS_prlimit64: ::c_long = 261;
|
||||
pub const SYS_name_to_handle_at: ::c_long = 264;
|
||||
pub const SYS_open_by_handle_at: ::c_long = 265;
|
||||
pub const SYS_clock_adjtime: ::c_long = 266;
|
||||
pub const SYS_syncfs: ::c_long = 267;
|
||||
pub const SYS_sendmmsg: ::c_long = 269;
|
||||
pub const SYS_setns: ::c_long = 268;
|
||||
pub const SYS_getcpu: ::c_long = 168;
|
||||
pub const SYS_process_vm_readv: ::c_long = 270;
|
||||
pub const SYS_process_vm_writev: ::c_long = 271;
|
||||
pub const SYS_kcmp: ::c_long = 272;
|
||||
pub const SYS_finit_module: ::c_long = 273;
|
||||
pub const SYS_sched_setattr: ::c_long = 274;
|
||||
pub const SYS_sched_getattr: ::c_long = 275;
|
||||
pub const SYS_renameat2: ::c_long = 276;
|
||||
pub const SYS_seccomp: ::c_long = 277;
|
||||
pub const SYS_getrandom: ::c_long = 278;
|
||||
pub const SYS_memfd_create: ::c_long = 279;
|
||||
pub const SYS_bpf: ::c_long = 280;
|
||||
pub const SYS_execveat: ::c_long = 281;
|
||||
pub const SYS_userfaultfd: ::c_long = 282;
|
||||
pub const SYS_membarrier: ::c_long = 283;
|
||||
pub const SYS_mlock2: ::c_long = 284;
|
||||
pub const SYS_copy_file_range: ::c_long = 285;
|
||||
pub const SYS_preadv2: ::c_long = 286;
|
||||
pub const SYS_pwritev2: ::c_long = 287;
|
||||
pub const SYS_pkey_mprotect: ::c_long = 288;
|
||||
pub const SYS_pkey_alloc: ::c_long = 289;
|
||||
pub const SYS_pkey_free: ::c_long = 290;
|
||||
pub const SYS_statx: ::c_long = 291;
|
||||
pub const SYS_rseq: ::c_long = 293;
|
||||
pub const SYS_syscall: ::c_long = 294;
|
||||
pub const SYS_pidfd_send_signal: ::c_long = 424;
|
||||
pub const SYS_io_uring_setup: ::c_long = 425;
|
||||
pub const SYS_io_uring_enter: ::c_long = 426;
|
||||
pub const SYS_io_uring_register: ::c_long = 427;
|
||||
pub const SYS_open_tree: ::c_long = 428;
|
||||
pub const SYS_move_mount: ::c_long = 429;
|
||||
pub const SYS_fsopen: ::c_long = 430;
|
||||
pub const SYS_fsconfig: ::c_long = 431;
|
||||
pub const SYS_fsmount: ::c_long = 432;
|
||||
pub const SYS_fspick: ::c_long = 433;
|
||||
pub const SYS_pidfd_open: ::c_long = 434;
|
||||
pub const SYS_clone3: ::c_long = 435;
|
||||
pub const SYS_close_range: ::c_long = 436;
|
||||
pub const SYS_openat2: ::c_long = 437;
|
||||
pub const SYS_pidfd_getfd: ::c_long = 438;
|
||||
pub const SYS_faccessat2: ::c_long = 439;
|
||||
pub const SYS_process_madvise: ::c_long = 440;
|
||||
pub const SYS_epoll_pwait2: ::c_long = 441;
|
||||
pub const SYS_mount_setattr: ::c_long = 442;
|
||||
pub const SYS_quotactl_fd: ::c_long = 443;
|
||||
pub const SYS_landlock_create_ruleset: ::c_long = 444;
|
||||
pub const SYS_landlock_add_rule: ::c_long = 445;
|
||||
pub const SYS_landlock_restrict_self: ::c_long = 446;
|
||||
pub const SYS_memfd_secret: ::c_long = 447;
|
||||
pub const SYS_process_mrelease: ::c_long = 448;
|
||||
pub const SYS_futex_waitv: ::c_long = 449;
|
||||
pub const SYS_set_mempolicy_home_node: ::c_long = 450;
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(libc_align)] {
|
||||
mod align;
|
||||
pub use self::align::*;
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@ s! {
|
|||
pub struct sigaction {
|
||||
pub sa_sigaction: ::sighandler_t,
|
||||
pub sa_mask: ::sigset_t,
|
||||
pub sa_flags: ::c_int,
|
||||
pub sa_flags: ::c_ulong,
|
||||
pub sa_restorer: ::Option<extern fn()>,
|
||||
}
|
||||
|
||||
|
|
|
@ -43,34 +43,34 @@ cfg_if! {
|
|||
|
||||
s! {
|
||||
pub struct stat {
|
||||
#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
|
||||
#[cfg(not(target_arch = "mips"))]
|
||||
pub st_dev: ::dev_t,
|
||||
#[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
|
||||
#[cfg(target_arch = "mips")]
|
||||
pub st_dev: ::c_ulong,
|
||||
|
||||
#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
|
||||
#[cfg(not(target_arch = "mips"))]
|
||||
__pad1: ::c_short,
|
||||
#[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
|
||||
#[cfg(target_arch = "mips")]
|
||||
st_pad1: [::c_long; 3],
|
||||
pub st_ino: ::ino_t,
|
||||
pub st_mode: ::mode_t,
|
||||
pub st_nlink: ::nlink_t,
|
||||
pub st_uid: ::uid_t,
|
||||
pub st_gid: ::gid_t,
|
||||
#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
|
||||
#[cfg(not(target_arch = "mips"))]
|
||||
pub st_rdev: ::dev_t,
|
||||
#[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
|
||||
#[cfg(target_arch = "mips")]
|
||||
pub st_rdev: ::c_ulong,
|
||||
#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
|
||||
#[cfg(not(target_arch = "mips"))]
|
||||
__pad2: ::c_short,
|
||||
#[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
|
||||
#[cfg(target_arch = "mips")]
|
||||
st_pad2: [::c_long; 2],
|
||||
pub st_size: ::off_t,
|
||||
#[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
|
||||
#[cfg(target_arch = "mips")]
|
||||
st_pad3: ::c_long,
|
||||
#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
|
||||
#[cfg(not(target_arch = "mips"))]
|
||||
pub st_blksize: ::blksize_t,
|
||||
#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
|
||||
#[cfg(not(target_arch = "mips"))]
|
||||
pub st_blocks: ::blkcnt_t,
|
||||
pub st_atime: ::time_t,
|
||||
pub st_atime_nsec: ::c_long,
|
||||
|
@ -78,15 +78,15 @@ s! {
|
|||
pub st_mtime_nsec: ::c_long,
|
||||
pub st_ctime: ::time_t,
|
||||
pub st_ctime_nsec: ::c_long,
|
||||
#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
|
||||
#[cfg(not(target_arch = "mips"))]
|
||||
__unused4: ::c_long,
|
||||
#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
|
||||
#[cfg(not(target_arch = "mips"))]
|
||||
__unused5: ::c_long,
|
||||
#[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
|
||||
#[cfg(target_arch = "mips")]
|
||||
pub st_blksize: ::blksize_t,
|
||||
#[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
|
||||
#[cfg(target_arch = "mips")]
|
||||
pub st_blocks: ::blkcnt_t,
|
||||
#[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
|
||||
#[cfg(target_arch = "mips")]
|
||||
st_pad5: [::c_long; 14],
|
||||
}
|
||||
|
||||
|
@ -140,12 +140,12 @@ s! {
|
|||
#[cfg(target_arch = "powerpc")]
|
||||
__reserved: ::__syscall_ulong_t,
|
||||
pub sem_otime: ::time_t,
|
||||
#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6", target_arch = "powerpc")))]
|
||||
#[cfg(not(any(target_arch = "mips", target_arch = "powerpc")))]
|
||||
__reserved: ::__syscall_ulong_t,
|
||||
#[cfg(target_arch = "powerpc")]
|
||||
__reserved2: ::__syscall_ulong_t,
|
||||
pub sem_ctime: ::time_t,
|
||||
#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6", target_arch = "powerpc")))]
|
||||
#[cfg(not(any(target_arch = "mips", target_arch = "powerpc")))]
|
||||
__reserved2: ::__syscall_ulong_t,
|
||||
pub sem_nsems: ::__syscall_ulong_t,
|
||||
__glibc_reserved3: ::__syscall_ulong_t,
|
||||
|
@ -163,10 +163,8 @@ pub const F_OFD_SETLKW: ::c_int = 38;
|
|||
pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
|
||||
pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24;
|
||||
pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32;
|
||||
pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 20;
|
||||
pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
|
||||
pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8;
|
||||
pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4;
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(target_arch = "sparc")] {
|
||||
|
@ -337,7 +335,7 @@ cfg_if! {
|
|||
} else if #[cfg(target_arch = "arm")] {
|
||||
mod arm;
|
||||
pub use self::arm::*;
|
||||
} else if #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] {
|
||||
} else if #[cfg(target_arch = "mips")] {
|
||||
mod mips;
|
||||
pub use self::mips::*;
|
||||
} else if #[cfg(target_arch = "m68k")] {
|
||||
|
@ -352,9 +350,6 @@ cfg_if! {
|
|||
} else if #[cfg(target_arch = "riscv32")] {
|
||||
mod riscv32;
|
||||
pub use self::riscv32::*;
|
||||
} else if #[cfg(target_arch = "csky")] {
|
||||
mod csky;
|
||||
pub use self::csky::*;
|
||||
} else {
|
||||
// Unknown target_arch
|
||||
}
|
||||
|
|
|
@ -196,41 +196,6 @@ s! {
|
|||
pub l_len: ::off64_t,
|
||||
pub l_pid: ::pid_t,
|
||||
}
|
||||
|
||||
pub struct user_regs_struct {
|
||||
pub pc: ::c_ulong,
|
||||
pub ra: ::c_ulong,
|
||||
pub sp: ::c_ulong,
|
||||
pub gp: ::c_ulong,
|
||||
pub tp: ::c_ulong,
|
||||
pub t0: ::c_ulong,
|
||||
pub t1: ::c_ulong,
|
||||
pub t2: ::c_ulong,
|
||||
pub s0: ::c_ulong,
|
||||
pub s1: ::c_ulong,
|
||||
pub a0: ::c_ulong,
|
||||
pub a1: ::c_ulong,
|
||||
pub a2: ::c_ulong,
|
||||
pub a3: ::c_ulong,
|
||||
pub a4: ::c_ulong,
|
||||
pub a5: ::c_ulong,
|
||||
pub a6: ::c_ulong,
|
||||
pub a7: ::c_ulong,
|
||||
pub s2: ::c_ulong,
|
||||
pub s3: ::c_ulong,
|
||||
pub s4: ::c_ulong,
|
||||
pub s5: ::c_ulong,
|
||||
pub s6: ::c_ulong,
|
||||
pub s7: ::c_ulong,
|
||||
pub s8: ::c_ulong,
|
||||
pub s9: ::c_ulong,
|
||||
pub s10: ::c_ulong,
|
||||
pub s11: ::c_ulong,
|
||||
pub t3: ::c_ulong,
|
||||
pub t4: ::c_ulong,
|
||||
pub t5: ::c_ulong,
|
||||
pub t6: ::c_ulong,
|
||||
}
|
||||
}
|
||||
|
||||
pub const O_LARGEFILE: ::c_int = 0;
|
||||
|
@ -370,7 +335,6 @@ pub const TCSAFLUSH: ::c_int = 2;
|
|||
|
||||
pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
|
||||
pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
|
||||
pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4;
|
||||
pub const O_DIRECT: ::c_int = 16384;
|
||||
pub const O_DIRECTORY: ::c_int = 65536;
|
||||
pub const O_NOFOLLOW: ::c_int = 131072;
|
||||
|
@ -488,7 +452,6 @@ pub const FLUSHO: ::tcflag_t = 4096;
|
|||
pub const EXTPROC: ::tcflag_t = 65536;
|
||||
pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40;
|
||||
pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
|
||||
pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32;
|
||||
pub const NGREG: usize = 32;
|
||||
pub const REG_PC: usize = 0;
|
||||
pub const REG_RA: usize = 1;
|
||||
|
|
|
@ -27,6 +27,13 @@ s! {
|
|||
__reserved: [[u64; 32]; 16],
|
||||
}
|
||||
|
||||
#[repr(align(16))]
|
||||
pub struct user_fpsimd_struct {
|
||||
pub vregs: [[u64; 2]; 32],
|
||||
pub fpsr: ::c_uint,
|
||||
pub fpcr: ::c_uint,
|
||||
}
|
||||
|
||||
#[repr(align(8))]
|
||||
pub struct clone_args {
|
||||
pub flags: ::c_ulonglong,
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
s! {
|
||||
#[repr(align(16))]
|
||||
pub struct user_fpsimd_struct {
|
||||
pub vregs: [[u64; 2]; 32],
|
||||
pub fpsr: ::c_uint,
|
||||
pub fpcr: ::c_uint,
|
||||
}
|
||||
}
|
|
@ -7,8 +7,6 @@ pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
|
|||
pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 32;
|
||||
pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
|
||||
pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 48;
|
||||
pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4;
|
||||
pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 20;
|
||||
|
||||
align_const! {
|
||||
#[cfg(target_endian = "little")]
|
||||
|
|
|
@ -7,8 +7,6 @@ pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 8;
|
|||
pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 48;
|
||||
pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 8;
|
||||
pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
|
||||
pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 8;
|
||||
pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32;
|
||||
|
||||
align_const! {
|
||||
#[cfg(target_endian = "little")]
|
||||
|
|
|
@ -590,13 +590,6 @@ pub const PR_PAC_APDAKEY: ::c_ulong = 1 << 2;
|
|||
pub const PR_PAC_APDBKEY: ::c_ulong = 1 << 3;
|
||||
pub const PR_PAC_APGAKEY: ::c_ulong = 1 << 4;
|
||||
|
||||
pub const PR_SME_SET_VL: ::c_int = 63;
|
||||
pub const PR_SME_GET_VL: ::c_int = 64;
|
||||
pub const PR_SME_VL_LEN_MAX: ::c_int = 0xffff;
|
||||
|
||||
pub const PR_SME_SET_VL_INHERIT: ::c_ulong = 1 << 17;
|
||||
pub const PR_SME_SET_VL_ONE_EXEC: ::c_ulong = 1 << 18;
|
||||
|
||||
// Syscall table
|
||||
pub const SYS_io_setup: ::c_long = 0;
|
||||
pub const SYS_io_destroy: ::c_long = 1;
|
||||
|
@ -902,9 +895,6 @@ pub const SYS_process_mrelease: ::c_long = 448;
|
|||
pub const SYS_futex_waitv: ::c_long = 449;
|
||||
pub const SYS_set_mempolicy_home_node: ::c_long = 450;
|
||||
|
||||
pub const PROT_BTI: ::c_int = 0x10;
|
||||
pub const PROT_MTE: ::c_int = 0x20;
|
||||
|
||||
extern "C" {
|
||||
pub fn sysctl(
|
||||
name: *mut ::c_int,
|
||||
|
@ -931,16 +921,11 @@ cfg_if! {
|
|||
mod align;
|
||||
pub use self::align::*;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(libc_int128)] {
|
||||
mod int128;
|
||||
pub use self::int128::*;
|
||||
} else if #[cfg(libc_align)] {
|
||||
mod fallback;
|
||||
pub use self::fallback::*;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,10 +17,10 @@ s! {
|
|||
|
||||
#[repr(align(16))]
|
||||
pub struct mcontext_t {
|
||||
pub __pc: ::c_ulonglong,
|
||||
pub __gregs: [::c_ulonglong; 32],
|
||||
pub __flags: ::c_uint,
|
||||
pub __extcontext: [::c_ulonglong; 0],
|
||||
pub sc_pc: ::c_ulonglong,
|
||||
pub sc_regs: [::c_ulonglong; 32],
|
||||
pub sc_flags: ::c_ulong,
|
||||
pub sc_extcontext: [u64; 0],
|
||||
}
|
||||
|
||||
#[repr(align(8))]
|
||||
|
|
|
@ -189,29 +189,12 @@ s! {
|
|||
__unused4: ::c_ulong,
|
||||
__unused5: ::c_ulong
|
||||
}
|
||||
|
||||
pub struct user_regs_struct {
|
||||
pub regs: [u64; 32],
|
||||
pub orig_a0: u64,
|
||||
pub csr_era: u64,
|
||||
pub csr_badv: u64,
|
||||
pub reserved: [u64; 10],
|
||||
|
||||
}
|
||||
|
||||
pub struct user_fp_struct {
|
||||
pub fpr: [u64; 32],
|
||||
pub fcc: u64,
|
||||
pub fcsr: u32,
|
||||
}
|
||||
}
|
||||
|
||||
pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
|
||||
pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
|
||||
pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4;
|
||||
pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40;
|
||||
pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
|
||||
pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32;
|
||||
|
||||
align_const! {
|
||||
#[cfg(target_endian = "little")]
|
||||
|
@ -564,7 +547,7 @@ pub const SYS_landlock_add_rule: ::c_long = 445;
|
|||
pub const SYS_landlock_restrict_self: ::c_long = 446;
|
||||
pub const SYS_process_mrelease: ::c_long = 448;
|
||||
pub const SYS_futex_waitv: ::c_long = 449;
|
||||
pub const SYS_set_mempolicy_home_node: ::c_long = 450;
|
||||
//pub const SYS_set_mempolicy_home_node: ::c_long = 450;
|
||||
|
||||
pub const POSIX_FADV_DONTNEED: ::c_int = 4;
|
||||
pub const POSIX_FADV_NOREUSE: ::c_int = 5;
|
||||
|
@ -699,8 +682,6 @@ pub const ENOTRECOVERABLE: ::c_int = 131;
|
|||
pub const ERFKILL: ::c_int = 132;
|
||||
pub const EHWPOISON: ::c_int = 133;
|
||||
|
||||
pub const MADV_SOFT_OFFLINE: ::c_int = 101;
|
||||
|
||||
pub const MAP_NORESERVE: ::c_int = 0x4000;
|
||||
pub const MAP_ANONYMOUS: ::c_int = 0x0020;
|
||||
pub const MAP_ANON: ::c_int = 0x0020;
|
||||
|
@ -712,7 +693,6 @@ pub const MAP_POPULATE: ::c_int = 0x8000;
|
|||
pub const MAP_NONBLOCK: ::c_int = 0x10000;
|
||||
pub const MAP_STACK: ::c_int = 0x20000;
|
||||
pub const MAP_HUGETLB: ::c_int = 0x40000;
|
||||
pub const MAP_SYNC: ::c_int = 0x080000;
|
||||
pub const MCL_CURRENT: ::c_int = 0x0001;
|
||||
pub const MCL_FUTURE: ::c_int = 0x0002;
|
||||
pub const MCL_ONFAULT: ::c_int = 0x0004;
|
||||
|
@ -764,8 +744,6 @@ pub const PTRACE_GETFPXREGS: ::c_uint = 18;
|
|||
pub const PTRACE_SETFPXREGS: ::c_uint = 19;
|
||||
pub const PTRACE_GETREGS: ::c_uint = 12;
|
||||
pub const PTRACE_SETREGS: ::c_uint = 13;
|
||||
pub const PTRACE_SYSEMU: ::c_uint = 31;
|
||||
pub const PTRACE_SYSEMU_SINGLESTEP: ::c_uint = 32;
|
||||
|
||||
pub const RTLD_DEEPBIND: ::c_int = 0x8;
|
||||
pub const RTLD_GLOBAL: ::c_int = 0x100;
|
||||
|
@ -866,7 +844,6 @@ pub const ECHOPRT: ::tcflag_t = 0x00000400;
|
|||
pub const ECHOCTL: ::tcflag_t = 0x00000200;
|
||||
pub const ISIG: ::tcflag_t = 0x00000001;
|
||||
pub const ICANON: ::tcflag_t = 0x00000002;
|
||||
pub const XCASE: ::tcflag_t = 0x00000004;
|
||||
pub const PENDIN: ::tcflag_t = 0x00004000;
|
||||
pub const NOFLSH: ::tcflag_t = 0x00000080;
|
||||
|
||||
|
|
|
@ -188,10 +188,8 @@ s! {
|
|||
|
||||
pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
|
||||
pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
|
||||
pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4;
|
||||
pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40;
|
||||
pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
|
||||
pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32;
|
||||
|
||||
align_const! {
|
||||
#[cfg(target_endian = "little")]
|
||||
|
|
|
@ -72,7 +72,6 @@ s! {
|
|||
target_arch = "aarch64",
|
||||
target_arch = "loongarch64",
|
||||
target_arch = "mips64",
|
||||
target_arch = "mips64r6",
|
||||
target_arch = "powerpc64",
|
||||
target_arch = "riscv64",
|
||||
target_arch = "sparc64")))]
|
||||
|
@ -82,7 +81,6 @@ s! {
|
|||
target_arch = "aarch64",
|
||||
target_arch = "loongarch64",
|
||||
target_arch = "mips64",
|
||||
target_arch = "mips64r6",
|
||||
target_arch = "powerpc64",
|
||||
target_arch = "riscv64",
|
||||
target_arch = "sparc64")))]
|
||||
|
@ -107,7 +105,7 @@ cfg_if! {
|
|||
} else if #[cfg(any(target_arch = "sparc64"))] {
|
||||
mod sparc64;
|
||||
pub use self::sparc64::*;
|
||||
} else if #[cfg(any(target_arch = "mips64", target_arch = "mips64r6"))] {
|
||||
} else if #[cfg(any(target_arch = "mips64"))] {
|
||||
mod mips64;
|
||||
pub use self::mips64::*;
|
||||
} else if #[cfg(any(target_arch = "s390x"))] {
|
||||
|
|
|
@ -201,7 +201,6 @@ pub const RTLD_GLOBAL: ::c_int = 0x100;
|
|||
pub const RTLD_NOLOAD: ::c_int = 0x4;
|
||||
pub const VEOF: usize = 4;
|
||||
pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
|
||||
pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32;
|
||||
|
||||
pub const O_APPEND: ::c_int = 1024;
|
||||
pub const O_CREAT: ::c_int = 64;
|
||||
|
@ -403,7 +402,6 @@ pub const EFD_CLOEXEC: ::c_int = 0x80000;
|
|||
pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
|
||||
pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40;
|
||||
pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
|
||||
pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4;
|
||||
|
||||
align_const! {
|
||||
#[cfg(target_endian = "little")]
|
||||
|
|
|
@ -192,41 +192,6 @@ s! {
|
|||
pub l_len: ::off64_t,
|
||||
pub l_pid: ::pid_t,
|
||||
}
|
||||
|
||||
pub struct user_regs_struct {
|
||||
pub pc: ::c_ulong,
|
||||
pub ra: ::c_ulong,
|
||||
pub sp: ::c_ulong,
|
||||
pub gp: ::c_ulong,
|
||||
pub tp: ::c_ulong,
|
||||
pub t0: ::c_ulong,
|
||||
pub t1: ::c_ulong,
|
||||
pub t2: ::c_ulong,
|
||||
pub s0: ::c_ulong,
|
||||
pub s1: ::c_ulong,
|
||||
pub a0: ::c_ulong,
|
||||
pub a1: ::c_ulong,
|
||||
pub a2: ::c_ulong,
|
||||
pub a3: ::c_ulong,
|
||||
pub a4: ::c_ulong,
|
||||
pub a5: ::c_ulong,
|
||||
pub a6: ::c_ulong,
|
||||
pub a7: ::c_ulong,
|
||||
pub s2: ::c_ulong,
|
||||
pub s3: ::c_ulong,
|
||||
pub s4: ::c_ulong,
|
||||
pub s5: ::c_ulong,
|
||||
pub s6: ::c_ulong,
|
||||
pub s7: ::c_ulong,
|
||||
pub s8: ::c_ulong,
|
||||
pub s9: ::c_ulong,
|
||||
pub s10: ::c_ulong,
|
||||
pub s11: ::c_ulong,
|
||||
pub t3: ::c_ulong,
|
||||
pub t4: ::c_ulong,
|
||||
pub t5: ::c_ulong,
|
||||
pub t6: ::c_ulong,
|
||||
}
|
||||
}
|
||||
|
||||
pub const POSIX_FADV_DONTNEED: ::c_int = 4;
|
||||
|
@ -403,7 +368,6 @@ pub const EPOLL_CLOEXEC: ::c_int = 524288;
|
|||
pub const EFD_CLOEXEC: ::c_int = 524288;
|
||||
pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
|
||||
pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
|
||||
pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4;
|
||||
pub const O_DIRECT: ::c_int = 16384;
|
||||
pub const O_DIRECTORY: ::c_int = 65536;
|
||||
pub const O_NOFOLLOW: ::c_int = 131072;
|
||||
|
@ -527,7 +491,6 @@ pub const FLUSHO: ::tcflag_t = 4096;
|
|||
pub const EXTPROC: ::tcflag_t = 65536;
|
||||
pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40;
|
||||
pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
|
||||
pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32;
|
||||
pub const NGREG: usize = 32;
|
||||
pub const REG_PC: usize = 0;
|
||||
pub const REG_RA: usize = 1;
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче