diff options
author | Daniel Mueller <deso@posteo.net> | 2018-12-10 21:00:27 -0800 |
---|---|---|
committer | Daniel Mueller <deso@posteo.net> | 2018-12-10 21:00:27 -0800 |
commit | e2604a756aaddcd5919ee2f1b9cc0055d200f846 (patch) | |
tree | 1ea1b9900db20d3aadbddbce18882d0c957247d7 /libc | |
parent | 5875df6c958743cf86c75b2cb5fc2efe5ca0de43 (diff) | |
download | nitrocli-e2604a756aaddcd5919ee2f1b9cc0055d200f846.tar.gz nitrocli-e2604a756aaddcd5919ee2f1b9cc0055d200f846.tar.bz2 |
Update libc crate to 0.2.45
This change updates the libc crate to version 0.2.45.
Import subrepo libc/:libc at f5636fc618f8e16968b3178196d73c94ad9f7b05
Diffstat (limited to 'libc')
113 files changed, 9743 insertions, 1542 deletions
diff --git a/libc/.cirrus.yml b/libc/.cirrus.yml new file mode 100644 index 0000000..3aa24af --- /dev/null +++ b/libc/.cirrus.yml @@ -0,0 +1,14 @@ +freebsd_instance: + image: freebsd-11-1-release-amd64 + +task: + # This name gets reported as a build status in GitHub + name: stable x86_64-unknown-freebsd + setup_script: + - pkg install -y curl + - curl https://sh.rustup.rs -sSf --output rustup.sh + - sh rustup.sh -y + test_script: + - . $HOME/.cargo/env + - cd libc-test + - cargo test diff --git a/libc/.travis.yml b/libc/.travis.yml index 6acf0a8..da882ae 100644 --- a/libc/.travis.yml +++ b/libc/.travis.yml @@ -1,47 +1,34 @@ language: rust rust: stable sudo: required -dist: trusty -services: - - docker -install: - - if [ -z "$NO_ADD" ]; then rustup target add $TARGET; fi -script: - - cargo build $OPT - - cargo build $OPT --no-default-features - - cargo generate-lockfile --manifest-path libc-test/Cargo.toml - - if [[ $TRAVIS_OS_NAME = "linux" ]]; then - sh ci/run-docker.sh $TARGET; - else - export CARGO_TARGET_DIR=`pwd`/target; - sh ci/run.sh $TARGET; - fi - - rustc ci/style.rs && ./style src -env: - global: - secure: "e2/3QjgRN9atOuSHp22TrYG7QVKcYUWY48Hi9b60w+r1+BhPkTseIJLte7WefRhdXtqpjjUJTooKDhnurFOeHaCT+nmBgiv+FPU893sBl4bhesY4m0vgUJVbNZcs6lTImYekWVb+aqjGdgV/XAgCw7c3kPmrZV0MzGDWL64Xaps=" +dist: xenial +services: docker + matrix: include: - # 1.0.0 compat - - env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1 - rust: 1.0.0 + # 1.13.0 compat + - env: TARGET=x86_64-unknown-linux-gnu + rust: 1.13.0 script: rm -f Cargo.lock && cargo build - install: + install: true # build documentation - - env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1 + - env: TARGET=x86_64-unknown-linux-gnu rust: nightly script: sh ci/dox.sh + install: true # stable compat - - env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1 + - env: TARGET=x86_64-unknown-linux-gnu + install: true - env: TARGET=i686-unknown-linux-gnu - os: osx - env: TARGET=x86_64-apple-darwin NO_ADD=1 - osx_image: xcode8.3 + env: TARGET=x86_64-apple-darwin + osx_image: xcode10 + install: true - os: osx env: TARGET=i686-apple-darwin - osx_image: xcode8.3 + osx_image: xcode10 - env: TARGET=arm-linux-androideabi - env: TARGET=aarch64-linux-android # FIXME(#826) should reenable @@ -53,23 +40,6 @@ matrix: - env: TARGET=arm-unknown-linux-musleabihf - env: TARGET=aarch64-unknown-linux-gnu - env: TARGET=aarch64-unknown-linux-musl - # FIXME(#856) - rust: 1.22.1 - - os: osx - osx_image: xcode8.2 - env: TARGET=i386-apple-ios - CARGO_TARGET_I386_APPLE_IOS_RUNNER=$HOME/runtest - RUSTFLAGS=-Clink-arg=-mios-simulator-version-min=7.0 - before_install: - rustc ./ci/ios/deploy_and_run_on_ios_simulator.rs -o $HOME/runtest - - os: osx - osx_image: xcode8.2 - env: TARGET=x86_64-apple-ios - CARGO_TARGET_X86_64_APPLE_IOS_RUNNER=$HOME/runtest - RUSTFLAGS=-Clink-arg=-mios-simulator-version-min=7.0 - before_install: - rustc ./ci/ios/deploy_and_run_on_ios_simulator.rs -o $HOME/runtest - - env: TARGET=x86_64-rumprun-netbsd - env: TARGET=powerpc-unknown-linux-gnu - env: TARGET=powerpc64-unknown-linux-gnu - env: TARGET=powerpc64le-unknown-linux-gnu @@ -84,30 +54,58 @@ matrix: - env: TARGET=wasm32-unknown-emscripten # beta - - env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1 + - env: TARGET=x86_64-unknown-linux-gnu rust: beta + install: true - os: osx - env: TARGET=x86_64-apple-darwin NO_ADD=1 - osx_image: xcode8.3 + env: TARGET=x86_64-apple-darwin + osx_image: xcode10 rust: beta + install: true # nightly - - env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1 + - env: TARGET=x86_64-unknown-linux-gnu rust: nightly + install: true - os: osx - env: TARGET=x86_64-apple-darwin NO_ADD=1 - osx_image: xcode8.3 + env: TARGET=x86_64-apple-darwin + osx_image: xcode10 rust: nightly + install: true # not available on stable # without --release the build fails # see https://github.com/rust-lang/rust/issues/45417 - env: TARGET=x86_64-unknown-linux-gnux32 OPT="--release" rust: nightly - # QEMU based targets that compile in an emulator - - env: TARGET=x86_64-unknown-freebsd + - env: TARGET=wasm32-unknown-unknown + install: rustup target add $TARGET + script: cargo build --no-default-features --target $TARGET --release + + - name: "Shellcheck" + install: true + script: + - shellcheck --version + - shellcheck ci/*.sh + + allow_failures: + - env: TARGET=aarch64-linux-android + - env: TARGET=x86_64-linux-android + +install: rustup target add $TARGET +script: + - cargo generate-lockfile --manifest-path libc-test/Cargo.toml + - if [[ $TRAVIS_OS_NAME = "linux" ]]; then + sh ci/run-docker.sh $TARGET; + else + export CARGO_TARGET_DIR=`pwd`/target; + sh ci/run.sh $TARGET; + fi + - rustc ci/style.rs && ./style src +env: + global: + secure: "e2/3QjgRN9atOuSHp22TrYG7QVKcYUWY48Hi9b60w+r1+BhPkTseIJLte7WefRhdXtqpjjUJTooKDhnurFOeHaCT+nmBgiv+FPU893sBl4bhesY4m0vgUJVbNZcs6lTImYekWVb+aqjGdgV/XAgCw7c3kPmrZV0MzGDWL64Xaps=" notifications: email: on_success: never - webhooks: https://buildbot.rust-lang.org/homu/travis diff --git a/libc/Cargo.lock b/libc/Cargo.lock index d6f7365..6d94df8 100644 --- a/libc/Cargo.lock +++ b/libc/Cargo.lock @@ -5,61 +5,57 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "bitflags" -version = "1.0.1" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cc" -version = "1.0.3" +version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cfg-if" -version = "0.1.2" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "ctest" -version = "0.1.6" -source = "git+https://github.com/alexcrichton/ctest#29d33e26d8f1297736c3716f4f2495dd068849ef" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", "syntex_syntax 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "dtoa" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] name = "extprim" -version = "1.4.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num-traits 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "fuchsia-zircon" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-zircon-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "fuchsia-zircon-sys" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "itoa" -version = "0.3.4" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -73,19 +69,22 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.34" +version = "0.2.44" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.36" +version = "0.2.45" +dependencies = [ + "rustc-std-workspace-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "libc-test" version = "0.1.0" dependencies = [ - "ctest 0.1.6 (git+https://github.com/alexcrichton/ctest)", - "libc 0.2.36", + "ctest 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.45", ] [[package]] @@ -93,47 +92,69 @@ name = "log" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "log" -version = "0.4.1" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "num-traits" -version = "0.1.41" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] +name = "proc-macro2" +version = "0.4.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "quote" -version = "0.3.15" +version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "rand" -version = "0.3.19" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "fuchsia-zircon 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] +name = "rustc-std-workspace-core" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] name = "rustc_version" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] +name = "ryu" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] name = "semver" -version = "0.6.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -146,58 +167,40 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.27" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_derive" -version = "1.0.27" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive_internals 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "serde_derive_internals" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", - "synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_json" -version = "1.0.9" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syn" -version = "0.11.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", - "synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "synom" -version = "0.11.3" +version = "0.15.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -205,9 +208,9 @@ name = "syntex_errors" version = "0.59.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", "syntex_pos 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -218,8 +221,8 @@ name = "syntex_pos" version = "0.59.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -228,11 +231,11 @@ version = "0.59.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", - "extprim 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "extprim 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)", "syntex_errors 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)", "syntex_pos 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -249,56 +252,72 @@ dependencies = [ [[package]] name = "unicode-xid" -version = "0.0.4" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "unicode-xid" -version = "0.1.0" +name = "winapi" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "winapi" -version = "0.2.8" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "winapi-build" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [metadata] "checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5" -"checksum bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b3c30d3802dfb7281680d6285f2ccdaa8c2d8fee41f93805dba5c4cf50dc23cf" -"checksum cc 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a9b13a57efd6b30ecd6598ebdb302cca617930b5470647570468a65d12ef9719" -"checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de" -"checksum ctest 0.1.6 (git+https://github.com/alexcrichton/ctest)" = "<none>" -"checksum dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "09c3753c3db574d215cba4ea76018483895d7bff25a31b49ba45db21c48e50ab" -"checksum extprim 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1de79797db68eb235c616cc3ad1a2793fa94a2245594cb6f81d602e62ed951c5" -"checksum fuchsia-zircon 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bd510087c325af53ba24f3be8f1c081b0982319adcb8b03cad764512923ccc19" -"checksum fuchsia-zircon-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "08b3a6f13ad6b96572b53ce7af74543132f1a7055ccceb6d073dd36c54481859" -"checksum itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8324a32baf01e2ae060e9de58ed0bc2320c9a2833491ee36cd3b4c414de4db8c" +"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" +"checksum cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "f159dfd43363c4d08055a07703eb7a3406b0dac4d0584d96965a3262db3c9d16" +"checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4" +"checksum ctest 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3574c0edc91c25cb50d1e4238f35ae2651b0beadf72bfec31fb4ead46b4eb5b8" +"checksum extprim 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "054bc2552b3f66fa8097e29e47255bfff583c08e737a67cbbb54b817ddaa5206" +"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" +"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" +"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -"checksum libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)" = "36fbc8a8929c632868295d0178dd8f63fc423fd7537ad0738372bd010b3ac9b0" +"checksum libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)" = "10923947f84a519a45c8fefb7dd1b3e8c08747993381adee176d7a82b4195311" "checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" -"checksum log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "89f010e843f2b1a31dbd316b3b8d443758bc634bed37aabade59c686d644e0a2" -"checksum num-traits 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "cacfcab5eb48250ee7d0c7896b51a2c5eec99c1feea5f32025635f5ae4b00070" -"checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" -"checksum rand 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "9e7944d95d25ace8f377da3ac7068ce517e4c646754c43a1b1849177bbf72e59" -"checksum rustc_version 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b9743a7670d88d5d52950408ecdb7c71d8986251ab604d4689dd2ca25c9bca69" -"checksum semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a3186ec9e65071a2095434b1f5bb24838d4e8e130f584c790f6033c79943537" +"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" +"checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1" +"checksum proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)" = "77619697826f31a02ae974457af0b29b723e5619e113e9397b8b82c6bd253f09" +"checksum quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "53fa22a1994bd0f9372d7a816207d8a2677ad0325b073f5c5332760f0fb62b5c" +"checksum rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8356f47b32624fef5b3301c1be97e5944ecdd595409cc5da11d05f211db6cfbd" +"checksum rustc-std-workspace-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1956f5517128a2b6f23ab2dadf1a976f4f5b27962e7724c2bf3d45e539ec098c" +"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +"checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" +"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)" = "db99f3919e20faa51bb2996057f5031d8685019b5a06139b1ce761da671b8526" -"checksum serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)" = "f4ba7591cfe93755e89eeecdbcc668885624829b020050e6aec99c2a03bd3fd0" -"checksum serde_derive_internals 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6e03f1c9530c3fb0a0a5c9b826bdd9246a5921ae995d75f512ac917fc4dd55b5" -"checksum serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c9db7266c7d63a4c4b7fe8719656ccdd51acf1bed6124b174f933b009fb10bcb" -"checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" -"checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" +"checksum serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)" = "c91eb5b0190ae87b4e2e39cbba6e3bed3ac6186935fe265f0426156c4c49961b" +"checksum serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)" = "477b13b646f5b5b56fc95bedfc3b550d12141ce84f466f6c44b9a17589923885" +"checksum serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)" = "c37ccd6be3ed1fdf419ee848f7c758eb31b054d7cd3ae3600e3bae0adf569811" +"checksum syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)" = "ae8b29eb5210bc5cf63ed6149cbf9adfc82ac0be023d8735c176ee74a2db4da7" "checksum syntex_errors 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3133289179676c9f5c5b2845bf5a2e127769f4889fcbada43035ef6bd662605e" "checksum syntex_pos 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)" = "30ab669fa003d208c681f874bbc76d91cc3d32550d16b5d9d2087cf477316470" "checksum syntex_syntax 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03815b9f04d95828770d9c974aa39c6e1f6ef3114eb77a3ce09008a0d15dd142" "checksum term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fa63644f74ce96fbeb9b794f66aff2a52d601cbd5e80f4b97123e3899f4570f1" -"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" +"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" +"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/libc/Cargo.toml b/libc/Cargo.toml index c9be832..8d8272e 100644 --- a/libc/Cargo.toml +++ b/libc/Cargo.toml @@ -1,25 +1,32 @@ [package] - name = "libc" -version = "0.2.36" +version = "0.2.45" authors = ["The Rust Project Developers"] -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" readme = "README.md" repository = "https://github.com/rust-lang/libc" homepage = "https://github.com/rust-lang/libc" documentation = "http://doc.rust-lang.org/libc" +keywords = ["libc", "ffi", "bindings", "operating", "system" ] +categories = ["external-ffi-bindings", "no-std", "os"] +build = "build.rs" +exclude = ["/ci/*", "/.travis.yml", "/appveyor.yml"] description = """ -A library for types and bindings to native C functions often found in libc or -other common platform libraries. +Raw FFI bindings to platform libraries like libc. """ [badges] travis-ci = { repository = "rust-lang/libc" } appveyor = { repository = "rust-lang/libc", project_name = "rust-lang-libs/libc" } +[dependencies] +rustc-std-workspace-core = { version = "1.0.0", optional = true } + [features] default = ["use_std"] use_std = [] +align = [] +rustc-dep-of-std = ['align', 'rustc-std-workspace-core'] [workspace] members = ["libc-test"] diff --git a/libc/README.md b/libc/README.md index c3333da..6cf2d15 100644 --- a/libc/README.md +++ b/libc/README.md @@ -1,13 +1,14 @@ libc ==== -A Rust library with native bindings to the types and functions commonly found on -various systems, including libc. +Raw FFI bindings to platform libraries like `libc`. [![Build Status](https://travis-ci.org/rust-lang/libc.svg?branch=master)](https://travis-ci.org/rust-lang/libc) [![Build status](https://ci.appveyor.com/api/projects/status/github/rust-lang/libc?svg=true)](https://ci.appveyor.com/project/rust-lang-libs/libc) +[![Latest version](https://img.shields.io/crates/v/libc.svg)](https://crates.io/crates/libc) +[![Documentation](https://docs.rs/libc/badge.svg)](https://docs.rs/libc) +![License](https://img.shields.io/crates/l/libc.svg) -[Documentation](#platforms-and-documentation) ## Usage @@ -33,6 +34,16 @@ this via: libc = { version = "0.2", default-features = false } ``` +By default libc uses private fields in structs in order to enforce a certain +memory alignment on them. These structs can be hard to instantiate outside of +libc. To make libc use `#[repr(align(x))]`, instead of the private fields, +activate the *align* feature. This requires Rust 1.25 or newer: + +```toml +[dependencies] +libc = { version = "0.2", features = ["align"] } +``` + ## What is libc? The primary purpose of this crate is to provide all of the definitions necessary @@ -122,38 +133,41 @@ it. If you'd like to get a release out ASAP you can follow these steps: The following platforms are currently tested and have documentation available: Tested: - * [`i686-pc-windows-msvc`](https://doc.rust-lang.org/libc/i686-pc-windows-msvc/libc/) - * [`x86_64-pc-windows-msvc`](https://doc.rust-lang.org/libc/x86_64-pc-windows-msvc/libc/) + * [`i686-pc-windows-msvc`](https://rust-lang.github.io/libc/i686-pc-windows-msvc/libc/) + * [`x86_64-pc-windows-msvc`](https://rust-lang.github.io/libc/x86_64-pc-windows-msvc/libc/) (Windows) - * [`i686-pc-windows-gnu`](https://doc.rust-lang.org/libc/i686-pc-windows-gnu/libc/) - * [`x86_64-pc-windows-gnu`](https://doc.rust-lang.org/libc/x86_64-pc-windows-gnu/libc/) - * [`i686-apple-darwin`](https://doc.rust-lang.org/libc/i686-apple-darwin/libc/) - * [`x86_64-apple-darwin`](https://doc.rust-lang.org/libc/x86_64-apple-darwin/libc/) + * [`i686-pc-windows-gnu`](https://rust-lang.github.io/libc/i686-pc-windows-gnu/libc/) + * [`x86_64-pc-windows-gnu`](https://rust-lang.github.io/libc/x86_64-pc-windows-gnu/libc/) + * [`i686-apple-darwin`](https://rust-lang.github.io/libc/i686-apple-darwin/libc/) + * [`x86_64-apple-darwin`](https://rust-lang.github.io/libc/x86_64-apple-darwin/libc/) (OSX) * `i386-apple-ios` * `x86_64-apple-ios` - * [`i686-unknown-linux-gnu`](https://doc.rust-lang.org/libc/i686-unknown-linux-gnu/libc/) - * [`x86_64-unknown-linux-gnu`](https://doc.rust-lang.org/libc/x86_64-unknown-linux-gnu/libc/) + * [`i686-unknown-linux-gnu`](https://rust-lang.github.io/libc/i686-unknown-linux-gnu/libc/) + * [`x86_64-unknown-linux-gnu`](https://rust-lang.github.io/libc/x86_64-unknown-linux-gnu/libc/) (Linux) - * [`x86_64-unknown-linux-musl`](https://doc.rust-lang.org/libc/x86_64-unknown-linux-musl/libc/) + * [`x86_64-unknown-linux-musl`](https://rust-lang.github.io/libc/x86_64-unknown-linux-musl/libc/) (Linux MUSL) - * [`aarch64-unknown-linux-gnu`](https://doc.rust-lang.org/libc/aarch64-unknown-linux-gnu/libc/) + * [`aarch64-unknown-linux-gnu`](https://rust-lang.github.io/libc/aarch64-unknown-linux-gnu/libc/) (Linux) - * [`aarch64-unknown-linux-musl`](https://doc.rust-lang.org/libc/aarch64-unknown-linux-musl/libc/) + * `aarch64-unknown-linux-musl` (Linux MUSL) - * [`mips-unknown-linux-gnu`](https://doc.rust-lang.org/libc/mips-unknown-linux-gnu/libc/) - * [`arm-unknown-linux-gnueabihf`](https://doc.rust-lang.org/libc/arm-unknown-linux-gnueabihf/libc/) - * [`arm-linux-androideabi`](https://doc.rust-lang.org/libc/arm-linux-androideabi/libc/) + * [`sparc64-unknown-linux-gnu`](https://rust-lang.github.io/libc/sparc64-unknown-linux-gnu/libc/) + (Linux) + * [`mips-unknown-linux-gnu`](https://rust-lang.github.io/libc/mips-unknown-linux-gnu/libc/) + * [`arm-unknown-linux-gnueabihf`](https://rust-lang.github.io/libc/arm-unknown-linux-gnueabihf/libc/) + * [`arm-linux-androideabi`](https://rust-lang.github.io/libc/arm-linux-androideabi/libc/) (Android) - * [`x86_64-unknown-freebsd`](https://doc.rust-lang.org/libc/x86_64-unknown-freebsd/libc/) - * [`x86_64-unknown-openbsd`](https://doc.rust-lang.org/libc/x86_64-unknown-openbsd/libc/) - * [`x86_64-rumprun-netbsd`](https://doc.rust-lang.org/libc/x86_64-unknown-netbsd/libc/) + * [`x86_64-unknown-freebsd`](https://rust-lang.github.io/libc/x86_64-unknown-freebsd/libc/) + * [`x86_64-unknown-openbsd`](https://rust-lang.github.io/libc/x86_64-unknown-openbsd/libc/) + * [`x86_64-rumprun-netbsd`](https://rust-lang.github.io/libc/x86_64-unknown-netbsd/libc/) The following may be supported, but are not guaranteed to always work: * `i686-unknown-freebsd` - * [`x86_64-unknown-bitrig`](https://doc.rust-lang.org/libc/x86_64-unknown-bitrig/libc/) - * [`x86_64-unknown-dragonfly`](https://doc.rust-lang.org/libc/x86_64-unknown-dragonfly/libc/) + * [`x86_64-unknown-bitrig`](https://rust-lang.github.io/libc/x86_64-unknown-bitrig/libc/) + * [`x86_64-unknown-dragonfly`](https://rust-lang.github.io/libc/x86_64-unknown-dragonfly/libc/) * `i686-unknown-haiku` * `x86_64-unknown-haiku` - * [`x86_64-unknown-netbsd`](https://doc.rust-lang.org/libc/x86_64-unknown-netbsd/libc/) + * [`x86_64-unknown-netbsd`](https://rust-lang.github.io/libc/x86_64-unknown-netbsd/libc/) + * [`x86_64-sun-solaris`](https://rust-lang.github.io/libc/x86_64-sun-solaris/libc/) diff --git a/libc/appveyor.yml b/libc/appveyor.yml index 07ac4a9..9fd4b26 100644 --- a/libc/appveyor.yml +++ b/libc/appveyor.yml @@ -1,9 +1,9 @@ environment: # When this was added there were revocation check failures when using the # libcurl backend as libcurl checks by default, but rustup doesn't provide the - # switch to turn this off. Switch to Hyper which looks to not check for + # switch to turn this off. Switch to Reqwest which looks to not check for # revocation by default like libcurl does. - RUSTUP_USE_HYPER: 1 + RUSTUP_USE_REQWEST: 1 CARGO_HTTP_CHECK_REVOKE: false matrix: - TARGET: x86_64-pc-windows-gnu @@ -24,4 +24,5 @@ build: false test_script: - cargo test --target %TARGET% + - cargo test --no-default-features --target %TARGET% - cargo test --manifest-path libc-test/Cargo.toml --target %TARGET% diff --git a/libc/build.rs b/libc/build.rs new file mode 100644 index 0000000..1852ed2 --- /dev/null +++ b/libc/build.rs @@ -0,0 +1,35 @@ +use std::env; +use std::process::Command; +use std::str; + +fn main() { + /* + * If `core::ffi::c_void` exists, libc can just re-export it. Otherwise, it + * must define an incompatible type to retain backwards-compatibility. + */ + if rustc_minor_version().expect("Failed to get rustc version") >= 30 { + println!("cargo:rustc-cfg=core_cvoid"); + } +} + +fn rustc_minor_version() -> Option<u32> { + macro_rules! otry { + ($e:expr) => { + match $e { + Some(e) => e, + None => return None, + } + }; + } + + let rustc = otry!(env::var_os("RUSTC")); + let output = otry!(Command::new(rustc).arg("--version").output().ok()); + let version = otry!(str::from_utf8(&output.stdout).ok()); + let mut pieces = version.split('.'); + + if pieces.next() != Some("rustc 1") { + return None; + } + + otry!(pieces.next()).parse().ok() +} diff --git a/libc/ci/README.md b/libc/ci/README.md index aef6ef1..28152e5 100644 --- a/libc/ci/README.md +++ b/libc/ci/README.md @@ -128,32 +128,72 @@ QEMU is available, and if so mount it, run a script (it'll specifically be `run-qemu.sh` in this folder which is copied into the generated image talked about above), and then shut down. -### QEMU setup - FreeBSD - -1. Download CD installer (most minimal is fine) -2. `qemu-img create -f qcow2 foo.qcow2 2G` -3. `qemu -cdrom foo.iso -drive if=virtio,file=foo.qcow2 -net nic,model=virtio -net user` -4. run installer -5. `echo 'console="comconsole"' >> /boot/loader.conf` -6. `echo 'autoboot_delay="0"' >> /boot/loader.conf` -7. look at /etc/ttys, see what getty argument is for ttyu0 -8. edit /etc/gettytab, look for ttyu0 argument, prepend `:al=root` to line - beneath - -(note that the current image has a `freebsd` user, but this isn't really -necessary) - -Once that's done, arrange for this script to run at login: - -``` -#!/bin/sh - -sudo kldload ext2fs -[ -e /dev/vtbd1 ] || exit 0 -sudo mount -t ext2fs /dev/vtbd1 /mnt -sh /mnt/run.sh /mnt -sudo poweroff -``` +### QEMU Setup - FreeBSD + +1. [Download the latest stable amd64-bootonly release ISO](https://www.freebsd.org/where.html). + E.g. FreeBSD-11.1-RELEASE-amd64-bootonly.iso +2. Create the disk image: `qemu-img create -f qcow2 FreeBSD-11.1-RELEASE-amd64.qcow2 2G` +3. Boot the machine: `qemu-system-x86_64 -cdrom FreeBSD-11.1-RELEASE-amd64-bootonly.iso -drive if=virtio,file=FreeBSD-11.1-RELEASE-amd64.qcow2 -net nic,model=virtio -net user` +4. Run the installer, and install FreeBSD: + 1. Install + 1. Continue with default keymap + 1. Set Hostname: freebsd-ci + 1. Distribution Select: + 1. Uncheck lib32 + 1. Uncheck ports + 1. Network Configuration: vtnet0 + 1. Configure IPv4? Yes + 1. DHCP? Yes + 1. Configure IPv6? No + 1. Resolver Configuration: Ok + 1. Mirror Selection: Main Site + 1. Partitioning: Auto (UFS) + 1. Partition: Entire Disk + 1. Partition Scheme: MBR + 1. App Partition: Ok + 1. Partition Editor: Finish + 1. Confirmation: Commit + 1. Wait for sets to install + 1. Set the root password to nothing (press enter twice) + 1. Set time zone to UTC + 1. Set Date: Skip + 1. Set Time: Skip + 1. System Configuration: + 1. Disable sshd + 1. Disable dumpdev + 1. System Hardening + 1. Disable Sendmail service + 1. Add User Accounts: No + 1. Final Configuration: Exit + 1. Manual Configuration: Yes + 1. `echo 'console="comconsole"' >> /boot/loader.conf` + 1. `echo 'autoboot_delay="0"' >> /boot/loader.conf` + 1. `echo 'ext2fs_load="YES"' >> /boot/loader.conf` + 1. Look at `/etc/ttys`, see what getty argument is for `ttyu0` (E.g. `3wire`) + 1. Edit `/etc/gettytab` (with `vi` for example), look for `ttyu0` argument, + prepend `:al=root` to the line beneath to have the machine auto-login as + root. E.g. + + 3wire:\ + :np:nc:sp#0: + becomes: + + 3wire:\ + :al=root:np:nc:sp#0: + + 1. Edit `/root/.login` and put this in it: + + [ -e /dev/vtbd1 ] || exit 0 + mount -t ext2fs /dev/vtbd1 /mnt + sh /mnt/run.sh /mnt + poweroff + + 1. Exit the post install shell: `exit` + 1. Back in in the installer choose Reboot + 1. If all went well the machine should reboot and show a login prompt. + If you switch to the serial console by choosing View > serial0 in + the qemu menu, you should be logged in as root. + 1. Shutdown the machine: `shutdown -p now` Helpful links diff --git a/libc/ci/android-install-ndk.sh b/libc/ci/android-install-ndk.sh index 873f6c5..ce11d00 100644 --- a/libc/ci/android-install-ndk.sh +++ b/libc/ci/android-install-ndk.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env sh # Copyright 2016 The Rust Project Developers. See the COPYRIGHT # file at the top-level directory of this distribution and at # http://rust-lang.org/COPYRIGHT. @@ -11,7 +11,7 @@ set -ex -curl -O https://dl.google.com/android/repository/android-ndk-r15b-linux-x86_64.zip +curl --retry 5 -O https://dl.google.com/android/repository/android-ndk-r15b-linux-x86_64.zip unzip -q android-ndk-r15b-linux-x86_64.zip case "$1" in @@ -30,8 +30,8 @@ esac; android-ndk-r15b/build/tools/make_standalone_toolchain.py \ --unified-headers \ - --install-dir /android/ndk-$1 \ - --arch $arch \ + --install-dir "/android/ndk-${1}" \ + --arch "${arch}" \ --api 24 rm -rf ./android-ndk-r15b-linux-x86_64.zip ./android-ndk-r15b diff --git a/libc/ci/android-install-sdk.sh b/libc/ci/android-install-sdk.sh index ab7e14d..c0f63c9 100644 --- a/libc/ci/android-install-sdk.sh +++ b/libc/ci/android-install-sdk.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env sh # Copyright 2016 The Rust Project Developers. See the COPYRIGHT # file at the top-level directory of this distribution and at # http://rust-lang.org/COPYRIGHT. @@ -19,7 +19,7 @@ set -ex # which apparently magically accepts the licenses. mkdir sdk -curl https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip -O +curl --retry 5 https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip -O unzip -d sdk sdk-tools-linux-3859397.zip case "$1" in @@ -56,5 +56,5 @@ echo "yes" | \ echo "no" | ./sdk/tools/bin/avdmanager create avd \ - --name $1 \ + --name "${1}" \ --package "system-images;android-24;default;$abi" diff --git a/libc/ci/android-sysimage.sh b/libc/ci/android-sysimage.sh index 9611dfe..9eabd7c 100644 --- a/libc/ci/android-sysimage.sh +++ b/libc/ci/android-sysimage.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + # Copyright 2017 The Rust Project Developers. See the COPYRIGHT # file at the top-level directory of this distribution and at # http://rust-lang.org/COPYRIGHT. @@ -13,32 +15,34 @@ set -ex URL=https://dl.google.com/android/repository/sys-img/android main() { - local arch=$1 - local name=$2 + local arch="${1}" + local name="${2}" local dest=/system - local td=$(mktemp -d) + local td + td="$(mktemp -d)" apt-get install --no-install-recommends e2tools - pushd $td - curl -O $URL/$name - unzip -q $name + pushd "${td}" + curl --retry 5 -O "${URL}/${name}" + unzip -q "${name}" - local system=$(find . -name system.img) - mkdir -p $dest/{bin,lib,lib64} + local system + system="$(find . -name system.img)" + mkdir -p ${dest}/{bin,lib,lib64} # Extract android linker and libraries to /system # This allows android executables to be run directly (or with qemu) - if [ $arch = "x86_64" -o $arch = "arm64" ]; then - e2cp -p $system:/bin/linker64 $dest/bin/ - e2cp -p $system:/lib64/libdl.so $dest/lib64/ - e2cp -p $system:/lib64/libc.so $dest/lib64/ - e2cp -p $system:/lib64/libm.so $dest/lib64/ + if [ "${arch}" = "x86_64" ] || [ "${arch}" = "arm64" ]; then + e2cp -p "${system}:/bin/linker64" "${dest}/bin/" + e2cp -p "${system}:/lib64/libdl.so" "${dest}/lib64/" + e2cp -p "${system}:/lib64/libc.so" "${dest}/lib64/" + e2cp -p "${system}:/lib64/libm.so" "${dest}/lib64/" else - e2cp -p $system:/bin/linker $dest/bin/ - e2cp -p $system:/lib/libdl.so $dest/lib/ - e2cp -p $system:/lib/libc.so $dest/lib/ - e2cp -p $system:/lib/libm.so $dest/lib/ + e2cp -p "${system}:/bin/linker" "${dest}/bin/" + e2cp -p "${system}:/lib/libdl.so" "${dest}/lib/" + e2cp -p "${system}:/lib/libc.so" "${dest}/lib/" + e2cp -p "${system}:/lib/libm.so" "${dest}/lib/" fi # clean up @@ -46,7 +50,7 @@ main() { popd - rm -rf $td + rm -rf "${td}" } main "${@}" diff --git a/libc/ci/docker/aarch64-unknown-linux-musl/Dockerfile b/libc/ci/docker/aarch64-unknown-linux-musl/Dockerfile index e86c4c0..fbc47d9 100644 --- a/libc/ci/docker/aarch64-unknown-linux-musl/Dockerfile +++ b/libc/ci/docker/aarch64-unknown-linux-musl/Dockerfile @@ -3,21 +3,21 @@ FROM ubuntu:17.10 RUN apt-get update && apt-get install -y --no-install-recommends \ gcc make libc6-dev git curl ca-certificates \ gcc-aarch64-linux-gnu qemu-user -RUN curl https://www.musl-libc.org/releases/musl-1.1.16.tar.gz | \ +RUN curl --retry 5 https://www.musl-libc.org/releases/musl-1.1.19.tar.gz | \ tar xzf - && \ - cd musl-1.1.16 && \ + cd musl-1.1.19 && \ CC=aarch64-linux-gnu-gcc \ ./configure --prefix=/musl-aarch64 --enable-wrapper=yes && \ make install -j4 && \ cd .. && \ - rm -rf musl-1.1.16 && \ + rm -rf musl-1.1.19 # Install linux kernel headers sanitized for use with musl - curl -L https://github.com/sabotage-linux/kernel-headers/archive/v3.12.6-5.tar.gz | \ +RUN curl --retry 5 -L https://github.com/sabotage-linux/kernel-headers/archive/v3.12.6-6.tar.gz | \ tar xzf - && \ - cd kernel-headers-3.12.6-5 && \ + cd kernel-headers-3.12.6-6 && \ make ARCH=arm64 prefix=/musl-aarch64 install -j4 && \ cd .. && \ - rm -rf kernel-headers-3.12.6-5 + rm -rf kernel-headers-3.12.6-6 # FIXME: shouldn't need the `-lgcc` here, shouldn't that be in libstd? ENV PATH=$PATH:/musl-aarch64/bin:/rust/bin \ diff --git a/libc/ci/docker/arm-unknown-linux-musleabihf/Dockerfile b/libc/ci/docker/arm-unknown-linux-musleabihf/Dockerfile index 130730b..3fc9dd3 100644 --- a/libc/ci/docker/arm-unknown-linux-musleabihf/Dockerfile +++ b/libc/ci/docker/arm-unknown-linux-musleabihf/Dockerfile @@ -4,21 +4,21 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ gcc make libc6-dev git curl ca-certificates \ gcc-arm-linux-gnueabihf qemu-user -RUN curl https://www.musl-libc.org/releases/musl-1.1.16.tar.gz | tar xzf - -WORKDIR /musl-1.1.16 +RUN curl --retry 5 https://www.musl-libc.org/releases/musl-1.1.19.tar.gz | tar xzf - +WORKDIR /musl-1.1.19 RUN CC=arm-linux-gnueabihf-gcc \ CFLAGS="-march=armv6 -marm" \ ./configure --prefix=/musl-arm --enable-wrapper=yes RUN make install -j4 # Install linux kernel headers sanitized for use with musl -RUN \ - curl -L https://github.com/sabotage-linux/kernel-headers/archive/v3.12.6-5.tar.gz | \ +RUN curl --retry 5 -L https://github.com/sabotage-linux/kernel-headers/archive/v3.12.6-6.tar.gz | \ tar xzf - && \ - cd kernel-headers-3.12.6-5 && \ + cd kernel-headers-3.12.6-6 && \ make ARCH=arm prefix=/musl-arm install -j4 && \ cd .. && \ - rm -rf kernel-headers-3.12.6-5 + rm -rf kernel-headers-3.12.6-6 + ENV PATH=$PATH:/musl-arm/bin:/rust/bin \ CC_arm_unknown_linux_musleabihf=musl-gcc \ CARGO_TARGET_ARM_UNKNOWN_LINUX_MUSLEABIHF_LINKER=musl-gcc \ diff --git a/libc/ci/docker/i686-unknown-linux-gnu/Dockerfile b/libc/ci/docker/i686-unknown-linux-gnu/Dockerfile index 1af4134..03f3e8e 100644 --- a/libc/ci/docker/i686-unknown-linux-gnu/Dockerfile +++ b/libc/ci/docker/i686-unknown-linux-gnu/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:17.04 +FROM ubuntu:18.04 RUN apt-get update RUN apt-get install -y --no-install-recommends \ gcc-multilib libc6-dev ca-certificates diff --git a/libc/ci/docker/i686-unknown-linux-musl/Dockerfile b/libc/ci/docker/i686-unknown-linux-musl/Dockerfile index 3adb920..b726e4d 100644 --- a/libc/ci/docker/i686-unknown-linux-musl/Dockerfile +++ b/libc/ci/docker/i686-unknown-linux-musl/Dockerfile @@ -12,19 +12,20 @@ RUN apt-get install -y --no-install-recommends \ # since otherwise the script will fail to find a compiler. # * We manually unset CROSS_COMPILE when running make; otherwise the makefile # will call the non-existent binary 'i686-ar'. -RUN curl https://www.musl-libc.org/releases/musl-1.1.15.tar.gz | \ +RUN curl --retry 5 https://www.musl-libc.org/releases/musl-1.1.19.tar.gz | \ tar xzf - && \ - cd musl-1.1.15 && \ + cd musl-1.1.19 && \ CC=gcc CFLAGS=-m32 ./configure --prefix=/musl-i686 --disable-shared --target=i686 && \ make CROSS_COMPILE= install -j4 && \ cd .. && \ - rm -rf musl-1.1.15 && \ + rm -rf musl-1.1.19 # Install linux kernel headers sanitized for use with musl - curl -L https://github.com/sabotage-linux/kernel-headers/archive/v3.12.6-5.tar.gz | \ +RUN curl --retry 5 -L https://github.com/sabotage-linux/kernel-headers/archive/v3.12.6-6.tar.gz | \ tar xzf - && \ - cd kernel-headers-3.12.6-5 && \ + cd kernel-headers-3.12.6-6 && \ make ARCH=i386 prefix=/musl-i686 install -j4 && \ cd .. && \ - rm -rf kernel-headers-3.12.6-5 + rm -rf kernel-headers-3.12.6-6 + ENV PATH=$PATH:/musl-i686/bin:/rust/bin \ CC_i686_unknown_linux_musl=musl-gcc diff --git a/libc/ci/docker/mips-unknown-linux-musl/Dockerfile b/libc/ci/docker/mips-unknown-linux-musl/Dockerfile index 91ffd58..dde22fd 100644 --- a/libc/ci/docker/mips-unknown-linux-musl/Dockerfile +++ b/libc/ci/docker/mips-unknown-linux-musl/Dockerfile @@ -8,7 +8,7 @@ RUN mkdir /toolchain # Note that this originally came from: # https://downloads.openwrt.org/snapshots/trunk/ar71xx/generic/OpenWrt-SDK-ar71xx-generic_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2 -RUN curl -L https://s3-us-west-1.amazonaws.com/rust-lang-ci2/libc/OpenWrt-SDK-ar71xx-generic_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2 | \ +RUN curl --retry 5 -L https://s3-us-west-1.amazonaws.com/rust-lang-ci2/libc/OpenWrt-SDK-ar71xx-generic_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2 | \ tar xjf - -C /toolchain --strip-components=1 ENV PATH=$PATH:/rust/bin:/toolchain/staging_dir/toolchain-mips_34kc_gcc-5.3.0_musl-1.1.15/bin \ diff --git a/libc/ci/docker/mipsel-unknown-linux-musl/Dockerfile b/libc/ci/docker/mipsel-unknown-linux-musl/Dockerfile index 3642fa8..037bf64 100644 --- a/libc/ci/docker/mipsel-unknown-linux-musl/Dockerfile +++ b/libc/ci/docker/mipsel-unknown-linux-musl/Dockerfile @@ -8,7 +8,7 @@ RUN mkdir /toolchain # Note that this originally came from: # https://downloads.openwrt.org/snapshots/trunk/malta/generic/OpenWrt-Toolchain-malta-le_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2 -RUN curl -L https://s3-us-west-1.amazonaws.com/rust-lang-ci2/libc/OpenWrt-Toolchain-malta-le_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2 | \ +RUN curl --retry 5 -L https://s3-us-west-1.amazonaws.com/rust-lang-ci2/libc/OpenWrt-Toolchain-malta-le_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2 | \ tar xjf - -C /toolchain --strip-components=2 ENV PATH=$PATH:/rust/bin:/toolchain/bin \ diff --git a/libc/ci/docker/sparc64-unknown-linux-gnu/Dockerfile b/libc/ci/docker/sparc64-unknown-linux-gnu/Dockerfile index 2c551f9..d9edaab 100644 --- a/libc/ci/docker/sparc64-unknown-linux-gnu/Dockerfile +++ b/libc/ci/docker/sparc64-unknown-linux-gnu/Dockerfile @@ -1,12 +1,14 @@ -# link fails on 17.10 -FROM ubuntu:17.04 +FROM debian:stretch RUN apt-get update && apt-get install -y --no-install-recommends \ curl ca-certificates \ gcc libc6-dev \ gcc-sparc64-linux-gnu libc6-dev-sparc64-cross \ qemu-system-sparc64 openbios-sparc seabios ipxe-qemu \ - p7zip-full cpio + p7zip-full cpio linux-libc-dev-sparc64-cross linux-headers-4.9.0-3-common + +# Put linux/module.h into the right spot as it is not shipped by debian +RUN cp /usr/src/linux-headers-4.9.0-3-common/include/uapi/linux/module.h /usr/sparc64-linux-gnu/include/linux/ COPY linux-sparc64.sh / RUN bash /linux-sparc64.sh diff --git a/libc/ci/docker/x86_64-unknown-freebsd/Dockerfile b/libc/ci/docker/x86_64-unknown-freebsd/Dockerfile deleted file mode 100644 index 7ad3faf..0000000 --- a/libc/ci/docker/x86_64-unknown-freebsd/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM alexcrichton/port-prebuilt-freebsd:2017-09-16 - -RUN apt-get update -RUN apt-get install -y --no-install-recommends \ - qemu genext2fs -RUN apt-get install -y curl ca-certificates gcc - -ENTRYPOINT ["sh"] - -ENV PATH=$PATH:/rust/bin \ - QEMU=2016-11-06/freebsd.qcow2.gz \ - CAN_CROSS=1 \ - CARGO_TARGET_X86_64_UNKNOWN_FREEBSD_LINKER=x86_64-unknown-freebsd10-gcc diff --git a/libc/ci/docker/x86_64-unknown-linux-gnu/Dockerfile b/libc/ci/docker/x86_64-unknown-linux-gnu/Dockerfile index c5ec682..6ab9c92 100644 --- a/libc/ci/docker/x86_64-unknown-linux-gnu/Dockerfile +++ b/libc/ci/docker/x86_64-unknown-linux-gnu/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:17.04 +FROM ubuntu:18.04 RUN apt-get update RUN apt-get install -y --no-install-recommends \ gcc libc6-dev ca-certificates diff --git a/libc/ci/docker/x86_64-unknown-linux-gnux32/Dockerfile b/libc/ci/docker/x86_64-unknown-linux-gnux32/Dockerfile index 1af4134..03f3e8e 100644 --- a/libc/ci/docker/x86_64-unknown-linux-gnux32/Dockerfile +++ b/libc/ci/docker/x86_64-unknown-linux-gnux32/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:17.04 +FROM ubuntu:18.04 RUN apt-get update RUN apt-get install -y --no-install-recommends \ gcc-multilib libc6-dev ca-certificates diff --git a/libc/ci/docker/x86_64-unknown-linux-musl/Dockerfile b/libc/ci/docker/x86_64-unknown-linux-musl/Dockerfile index d9d6511..0a27709 100644 --- a/libc/ci/docker/x86_64-unknown-linux-musl/Dockerfile +++ b/libc/ci/docker/x86_64-unknown-linux-musl/Dockerfile @@ -3,18 +3,18 @@ FROM ubuntu:17.10 RUN apt-get update RUN apt-get install -y --no-install-recommends \ gcc make libc6-dev git curl ca-certificates -RUN curl https://www.musl-libc.org/releases/musl-1.1.15.tar.gz | \ +RUN curl --retry 5 https://www.musl-libc.org/releases/musl-1.1.19.tar.gz | \ tar xzf - && \ - cd musl-1.1.15 && \ + cd musl-1.1.19 && \ ./configure --prefix=/musl-x86_64 && \ make install -j4 && \ cd .. && \ - rm -rf musl-1.1.15 && \ + rm -rf musl-1.1.19 # Install linux kernel headers sanitized for use with musl - curl -L https://github.com/sabotage-linux/kernel-headers/archive/v3.12.6-5.tar.gz | \ +RUN curl --retry 5 -L https://github.com/sabotage-linux/kernel-headers/archive/v3.12.6-6.tar.gz | \ tar xzf - && \ - cd kernel-headers-3.12.6-5 && \ + cd kernel-headers-3.12.6-6 && \ make ARCH=x86_64 prefix=/musl-x86_64 install -j4 && \ cd .. && \ - rm -rf kernel-headers-3.12.6-5 + rm -rf kernel-headers-3.12.6-6 ENV PATH=$PATH:/musl-x86_64/bin:/rust/bin diff --git a/libc/ci/dox.sh b/libc/ci/dox.sh index 85e9243..521743e 100644 --- a/libc/ci/dox.sh +++ b/libc/ci/dox.sh @@ -1,12 +1,12 @@ -#!/bin/sh +#!/usr/bin/env sh # Builds documentation for all target triples that we have a registered URL for # in liblibc. This scrapes the list of triples to document from `src/lib.rs` # which has a bunch of `html_root_url` directives we pick up. -set -e +set -ex -TARGETS=`grep html_root_url src/lib.rs | sed 's/.*".*\/\(.*\)"/\1/'` +TARGETS=$(grep html_root_url src/lib.rs | sed 's/.*".*\/\(.*\)"/\1/'| sed 's/)//') rm -rf target/doc mkdir -p target/doc @@ -14,12 +14,12 @@ mkdir -p target/doc cp ci/landing-page-head.html target/doc/index.html for target in $TARGETS; do - echo documenting $target + echo "documenting ${target}" - rustdoc -o target/doc/$target --target $target src/lib.rs --cfg dox \ + rustdoc -o "target/doc/${target}" --target "${target}" src/lib.rs --cfg cross_platform_docs \ --crate-name libc - echo "<li><a href="/libc/$target/libc/index.html">$target</a></li>" \ + echo "<li><a href=\"/libc/${target}/libc/index.html\">${target}</a></li>" \ >> target/doc/index.html done @@ -28,6 +28,6 @@ cat ci/landing-page-footer.html >> target/doc/index.html # If we're on travis, not a PR, and on the right branch, publish! if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" = "master" ]; then pip install ghp_import --install-option="--prefix=$HOME/.local" - $HOME/.local/bin/ghp-import -n target/doc - git push -qf https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages + "${HOME}/.local/bin/ghp-import" -n target/doc + git push -qf "https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git" gh-pages fi diff --git a/libc/ci/emscripten-entry.sh b/libc/ci/emscripten-entry.sh index 22ae8b0..e92c1cb 100755 --- a/libc/ci/emscripten-entry.sh +++ b/libc/ci/emscripten-entry.sh @@ -11,6 +11,7 @@ set -ex +# shellcheck disable=SC1091 source /emsdk-portable/emsdk_env.sh &> /dev/null # emsdk-portable provides a node binary, but we need version 8 to run wasm diff --git a/libc/ci/emscripten.sh b/libc/ci/emscripten.sh index d802585..ce3b541 100644 --- a/libc/ci/emscripten.sh +++ b/libc/ci/emscripten.sh @@ -1,3 +1,4 @@ +#!/usr/bin/env bash # Copyright 2017 The Rust Project Developers. See the COPYRIGHT # file at the top-level directory of this distribution and at # http://rust-lang.org/COPYRIGHT. @@ -17,10 +18,10 @@ echo ERROR: An error was encountered with the build. cat /tmp/build.log exit 1 " - trap "$on_err" ERR + trap '$on_err' ERR bash -c "while true; do sleep 30; echo \$(date) - building ...; done" & PING_LOOP_PID=$! - $@ &> /tmp/build.log + "${@}" &> /tmp/build.log trap - ERR kill $PING_LOOP_PID rm -f /tmp/build.log @@ -28,7 +29,7 @@ exit 1 } cd / -curl -L https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz | \ +curl --retry 5 -L https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz | \ tar -xz cd /emsdk-portable @@ -37,6 +38,7 @@ hide_output ./emsdk install sdk-1.37.20-64bit ./emsdk activate sdk-1.37.20-64bit # Compile and cache libc +# shellcheck disable=SC1091 source ./emsdk_env.sh echo "main(){}" > a.c HOME=/emsdk-portable/ emcc a.c @@ -49,6 +51,6 @@ chmod a+rxw -R /emsdk-portable # node 8 is required to run wasm cd / -curl -L https://nodejs.org/dist/v8.0.0/node-v8.0.0-linux-x64.tar.xz | \ +curl --retry 5 -L https://nodejs.org/dist/v8.0.0/node-v8.0.0-linux-x64.tar.xz | \ tar -xJ diff --git a/libc/ci/ios/deploy_and_run_on_ios_simulator.rs b/libc/ci/ios/deploy_and_run_on_ios_simulator.rs index b146150..95df52d 100644 --- a/libc/ci/ios/deploy_and_run_on_ios_simulator.rs +++ b/libc/ci/ios/deploy_and_run_on_ios_simulator.rs @@ -123,6 +123,7 @@ fn run_app_on_simulator() { .arg("com.rust.unittests") .output()); + println!("status: {}", output.status); println!("stdout --\n{}\n", String::from_utf8_lossy(&output.stdout)); println!("stderr --\n{}\n", String::from_utf8_lossy(&output.stderr)); diff --git a/libc/ci/linux-s390x.sh b/libc/ci/linux-s390x.sh index 972abee..a230cfe 100644 --- a/libc/ci/linux-s390x.sh +++ b/libc/ci/linux-s390x.sh @@ -1,11 +1,13 @@ +#!/usr/bin/env sh + set -ex mkdir -m 777 /qemu cd /qemu -curl -LO https://github.com/qemu/qemu/raw/master/pc-bios/s390-ccw.img -curl -LO http://ftp.debian.org/debian/dists/testing/main/installer-s390x/20170828/images/generic/kernel.debian -curl -LO http://ftp.debian.org/debian/dists/testing/main/installer-s390x/20170828/images/generic/initrd.debian +curl --retry 5 -LO https://github.com/qemu/qemu/raw/master/pc-bios/s390-ccw.img +curl --retry 5 -LO http://ftp.debian.org/debian/dists/testing/main/installer-s390x/20170828/images/generic/kernel.debian +curl --retry 5 -LO http://ftp.debian.org/debian/dists/testing/main/installer-s390x/20170828/images/generic/initrd.debian mv kernel.debian kernel mv initrd.debian initrd.gz diff --git a/libc/ci/linux-sparc64.sh b/libc/ci/linux-sparc64.sh index 33a3c46..7fb28d9 100644 --- a/libc/ci/linux-sparc64.sh +++ b/libc/ci/linux-sparc64.sh @@ -1,9 +1,11 @@ +#!/usr/bin/env sh + set -ex mkdir -m 777 /qemu cd /qemu -curl -LO https://cdimage.debian.org/cdimage/ports/debian-9.0-sparc64-NETINST-1.iso +curl --retry 5 -LO https://cdimage.debian.org/cdimage/ports/9.0/sparc64/iso-cd/debian-9.0-sparc64-NETINST-1.iso 7z e debian-9.0-sparc64-NETINST-1.iso boot/initrd.gz 7z e debian-9.0-sparc64-NETINST-1.iso boot/sparc64 mv sparc64 kernel diff --git a/libc/ci/run-docker.sh b/libc/ci/run-docker.sh index 662a1d4..c656f59 100755 --- a/libc/ci/run-docker.sh +++ b/libc/ci/run-docker.sh @@ -1,36 +1,42 @@ +#!/usr/bin/env sh + # Small script to run tests for a target (or all targets) inside all the # respective docker images. set -ex run() { - echo $1 + echo "Building docker container for target ${1}" + # use -f so we can use ci/ as build context - docker build -t libc -f ci/docker/$1/Dockerfile ci/ + docker build -t libc -f "ci/docker/${1}/Dockerfile" ci/ mkdir -p target if [ -w /dev/kvm ]; then - kvm="--volume /dev/kvm:/dev/kvm" + kvm="--volume /dev/kvm:/dev/kvm" + else + kvm="" fi + docker run \ - --user `id -u`:`id -g` \ + --user "$(id -u)":"$(id -g)" \ --rm \ --init \ - --volume $HOME/.cargo:/cargo \ + --volume "${HOME}/.cargo":/cargo \ $kvm \ --env CARGO_HOME=/cargo \ - --volume `rustc --print sysroot`:/rust:ro \ - --volume `pwd`:/checkout:ro \ - --volume `pwd`/target:/checkout/target \ + --volume "$(rustc --print sysroot)":/rust:ro \ + --volume "$(pwd)":/checkout:ro \ + --volume "$(pwd)"/target:/checkout/target \ --env CARGO_TARGET_DIR=/checkout/target \ --workdir /checkout \ libc \ - ci/run.sh $1 + ci/run.sh "${1}" } -if [ -z "$1" ]; then - for d in `ls ci/docker/`; do - run $d +if [ -z "${1}" ]; then + for d in ci/docker/*; do + run "${d}" done else - run $1 + run "${1}" fi diff --git a/libc/ci/run-qemu.sh b/libc/ci/run-qemu.sh index b2f457d..6fba629 100644 --- a/libc/ci/run-qemu.sh +++ b/libc/ci/run-qemu.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env sh + # Initial script which is run inside of all qemu images. The first argument to # this script (as arranged by the qemu image itself) is the path to where the # libc crate is mounted. @@ -10,11 +12,11 @@ set -ex -ROOT=$1 -cp -r $ROOT/libc /tmp/libc +ROOT="${1}" +cp -r "${ROOT}/libc" /tmp/libc cd /tmp/libc -TARGET=$(cat $ROOT/TARGET) +TARGET="$(cat "${ROOT}/TARGET")" export CARGO_TARGET_DIR=/tmp case $TARGET in @@ -24,9 +26,9 @@ case $TARGET in ;; *) - echo "Unknown target: $TARGET" + echo "Unknown target: ${TARGET}" exit 1 ;; esac -exec sh ci/run.sh $TARGET +exec sh ci/run.sh "${TARGET}" diff --git a/libc/ci/run.sh b/libc/ci/run.sh index 02dd35a..81ebd61 100755 --- a/libc/ci/run.sh +++ b/libc/ci/run.sh @@ -1,11 +1,11 @@ -#!/bin/sh +#!/usr/bin/env sh # Builds and runs tests for a particular target passed as an argument to this # script. set -ex -TARGET=$1 +TARGET="${1}" # If we're going to run tests inside of a qemu image, then we don't need any of # the scripts below. Instead, download the image, prepare a filesystem which has @@ -15,45 +15,53 @@ TARGET=$1 # script from the second which we place inside. if [ "$QEMU" != "" ]; then tmpdir=/tmp/qemu-img-creation - mkdir -p $tmpdir + mkdir -p "${tmpdir}" if [ -z "${QEMU#*.gz}" ]; then # image is .gz : download and uncompress it - qemufile=$(echo ${QEMU%.gz} | sed 's/\//__/g') - if [ ! -f $tmpdir/$qemufile ]; then - curl https://s3-us-west-1.amazonaws.com/rust-lang-ci2/libc/$QEMU | \ - gunzip -d > $tmpdir/$qemufile + qemufile="$(echo "${QEMU%.gz}" | sed 's/\//__/g')" + if [ ! -f "${tmpdir}/${qemufile}" ]; then + curl --retry 5 "https://s3-us-west-1.amazonaws.com/rust-lang-ci2/libc/${QEMU}" | \ + gunzip -d > "${tmpdir}/${qemufile}" + fi + elif [ -z "${QEMU#*.xz}" ]; then + # image is .xz : download and uncompress it + qemufile="$(echo "${QEMU%.xz}" | sed 's/\//__/g')" + if [ ! -f "${tmpdir}/${qemufile}" ]; then + curl --retry 5 "https://s3-us-west-1.amazonaws.com/rust-lang-ci2/libc/${QEMU}" | \ + unxz > "${tmpdir}/${qemufile}" fi else # plain qcow2 image: just download it - qemufile=$(echo ${QEMU} | sed 's/\//__/g') - if [ ! -f $tmpdir/$qemufile ]; then - curl https://s3-us-west-1.amazonaws.com/rust-lang-ci2/libc/$QEMU \ - > $tmpdir/$qemufile + qemufile="$(echo "${QEMU}" | sed 's/\//__/g')" + if [ ! -f "${tmpdir}/${qemufile}" ]; then + curl --retry 5 "https://s3-us-west-1.amazonaws.com/rust-lang-ci2/libc/${QEMU}" \ + > "${tmpdir}/${qemufile}" fi fi # Create a mount a fresh new filesystem image that we'll later pass to QEMU. # This will have a `run.sh` script will which use the artifacts inside to run # on the host. - rm -f $tmpdir/libc-test.img - mkdir $tmpdir/mount + rm -f "${tmpdir}/libc-test.img" + mkdir "${tmpdir}/mount" # Do the standard rigamarole of cross-compiling an executable and then the # script to run just executes the binary. cargo build \ --manifest-path libc-test/Cargo.toml \ - --target $TARGET \ + --target "${TARGET}" \ --test main - rm $CARGO_TARGET_DIR/$TARGET/debug/main-*.d - cp $CARGO_TARGET_DIR/$TARGET/debug/main-* $tmpdir/mount/libc-test - echo 'exec $1/libc-test' > $tmpdir/mount/run.sh + rm "${CARGO_TARGET_DIR}/${TARGET}"/debug/main-*.d + cp "${CARGO_TARGET_DIR}/${TARGET}"/debug/main-* "${tmpdir}"/mount/libc-test + # shellcheck disable=SC2016 + echo 'exec $1/libc-test' > "${tmpdir}/mount/run.sh" - du -sh $tmpdir/mount + du -sh "${tmpdir}/mount" genext2fs \ - --root $tmpdir/mount \ + --root "${tmpdir}/mount" \ --size-in-blocks 100000 \ - $tmpdir/libc-test.img + "${tmpdir}/libc-test.img" # Pass -snapshot to prevent tampering with the disk images, this helps when # running this script in development. The two drives are then passed next, @@ -63,20 +71,29 @@ if [ "$QEMU" != "" ]; then qemu-system-x86_64 \ -m 1024 \ -snapshot \ - -drive if=virtio,file=$tmpdir/$qemufile \ - -drive if=virtio,file=$tmpdir/libc-test.img \ + -drive if=virtio,file="${tmpdir}/${qemufile}" \ + -drive if=virtio,file="${tmpdir}/libc-test.img" \ -net nic,model=virtio \ -net user \ -nographic \ - -vga none 2>&1 | tee $CARGO_TARGET_DIR/out.log - exec grep "^PASSED .* tests" $CARGO_TARGET_DIR/out.log + -vga none 2>&1 | tee "${CARGO_TARGET_DIR}/out.log" + exec grep "^PASSED .* tests" "${CARGO_TARGET_DIR}/out.log" fi -# FIXME: x86_64-unknown-linux-gnux32 fail to compile wihout --release +# FIXME: x86_64-unknown-linux-gnux32 fail to compile without --release # See https://github.com/rust-lang/rust/issues/45417 opt= if [ "$TARGET" = "x86_64-unknown-linux-gnux32" ]; then opt="--release" fi -exec cargo test $opt --manifest-path libc-test/Cargo.toml --target $TARGET +# Building with --no-default-features is currently broken on rumprun because we +# need cfg(target_vendor), which is currently unstable. +if [ "$TARGET" != "x86_64-rumprun-netbsd" ]; then + cargo test $opt --no-default-features --manifest-path libc-test/Cargo.toml --target "${TARGET}" +fi +# Test the #[repr(align(x))] feature if this is building on Rust >= 1.25 +if [ "$(rustc --version | sed -E 's/^rustc 1\.([0-9]*)\..*/\1/')" -ge 25 ]; then + cargo test $opt --features align --manifest-path libc-test/Cargo.toml --target "${TARGET}" +fi +exec cargo test $opt --manifest-path libc-test/Cargo.toml --target "${TARGET}" diff --git a/libc/ci/style.rs b/libc/ci/style.rs index 32e4ba7..747e26c 100644 --- a/libc/ci/style.rs +++ b/libc/ci/style.rs @@ -72,6 +72,8 @@ fn walk(path: &Path, err: &mut Errors) { "dox.rs" | "lib.rs" | + "ctypes.rs" | + "libc.rs" | "macros.rs" => continue, _ => {} @@ -127,7 +129,10 @@ fn check_style(file: &str, path: &Path, err: &mut Errors) { if line.contains("extern \"C\"") { err.error(path, i, "use `extern` instead of `extern \"C\""); } - if line.contains("#[cfg(") && !line.contains(" if ") { + if line.contains("#[cfg(") && !line.contains(" if ") + && !(line.contains("target_endian") || + line.contains("target_arch")) + { if state != State::Structs { err.error(path, i, "use cfg_if! and submodules \ instead of #[cfg]"); diff --git a/libc/libc-test/Cargo.toml b/libc/libc-test/Cargo.toml index 771d3b3..b782a95 100644 --- a/libc/libc-test/Cargo.toml +++ b/libc/libc-test/Cargo.toml @@ -4,11 +4,17 @@ version = "0.1.0" authors = ["Alex Crichton <alex@alexcrichton.com>"] build = "build.rs" -[dependencies] -libc = { path = ".." } +[dependencies.libc] +path = ".." +default-features = false [build-dependencies] -ctest = { git = "https://github.com/alexcrichton/ctest" } +ctest = "0.2.8" + +[features] +default = [ "use_std" ] +use_std = [ "libc/use_std" ] +align = [ "libc/align" ] [[test]] name = "main" @@ -19,3 +25,4 @@ harness = false name = "linux-fcntl" path = "test/linux_fcntl.rs" harness = false + diff --git a/libc/libc-test/build.rs b/libc/libc-test/build.rs index 48f596f..460eb72 100644 --- a/libc/libc-test/build.rs +++ b/libc/libc-test/build.rs @@ -15,6 +15,7 @@ fn main() { let linux = target.contains("unknown-linux"); let android = target.contains("android"); let apple = target.contains("apple"); + let ios = target.contains("apple-ios"); let emscripten = target.contains("asm"); let musl = target.contains("musl") || emscripten; let uclibc = target.contains("uclibc"); @@ -25,6 +26,8 @@ fn main() { let openbsd = target.contains("openbsd"); let rumprun = target.contains("rumprun"); let solaris = target.contains("solaris"); + let cloudabi = target.contains("cloudabi"); + let redox = target.contains("redox"); let bsdlike = freebsd || apple || netbsd || openbsd || dragonfly; let mut cfg = ctest::TestGenerator::new(); @@ -33,12 +36,16 @@ fn main() { cfg.define("_GNU_SOURCE", None); } else if netbsd { cfg.define("_NETBSD_SOURCE", Some("1")); + } else if apple { + cfg.define("__APPLE_USE_RFC_3542", None); } else if windows { cfg.define("_WIN32_WINNT", Some("0x8000")); } else if solaris { cfg.define("_XOPEN_SOURCE", Some("700")); cfg.define("__EXTENSIONS__", None); cfg.define("_LCONV_C99", None); + } else if freebsd { + cfg.define("_WITH_GETLINE", None); } // Android doesn't actually have in_port_t but it's much easier if we @@ -48,17 +55,17 @@ fn main() { } cfg.header("errno.h") - .header("fcntl.h") - .header("limits.h") - .header("locale.h") - .header("stddef.h") - .header("stdint.h") - .header("stdio.h") - .header("stdlib.h") - .header("sys/stat.h") - .header("sys/types.h") - .header("time.h") - .header("wchar.h"); + .header("fcntl.h") + .header("limits.h") + .header("locale.h") + .header("stddef.h") + .header("stdint.h") + .header("stdio.h") + .header("stdlib.h") + .header("sys/stat.h") + .header("sys/types.h") + .header("time.h") + .header("wchar.h"); if windows { cfg.header("winsock2.h"); // must be before windows.h @@ -82,6 +89,10 @@ fn main() { cfg.header("sys/socket.h"); } cfg.header("net/if.h"); + if !ios { + cfg.header("net/route.h"); + cfg.header("net/if_arp.h"); + } cfg.header("netdb.h"); cfg.header("netinet/in.h"); cfg.header("netinet/ip.h"); @@ -99,6 +110,7 @@ fn main() { cfg.header("sys/socket.h"); if linux && !musl { cfg.header("linux/if.h"); + cfg.header("sys/auxv.h"); } cfg.header("sys/time.h"); cfg.header("sys/un.h"); @@ -108,7 +120,7 @@ fn main() { cfg.header("pwd.h"); cfg.header("grp.h"); cfg.header("sys/utsname.h"); - if !solaris { + if !solaris && !ios { cfg.header("sys/ptrace.h"); } cfg.header("sys/mount.h"); @@ -131,6 +143,7 @@ fn main() { cfg.header("arpa/inet.h"); cfg.header("xlocale.h"); cfg.header("utmp.h"); + cfg.header("ifaddrs.h"); if i686 || x86_64 { cfg.header("sys/reg.h"); } @@ -148,7 +161,6 @@ fn main() { } if !musl && !uclibc { - if !netbsd && !openbsd && !uclibc { cfg.header("execinfo.h"); } @@ -162,21 +174,30 @@ fn main() { } if apple { + cfg.header("spawn.h"); cfg.header("mach-o/dyld.h"); cfg.header("mach/mach_time.h"); cfg.header("malloc/malloc.h"); cfg.header("util.h"); cfg.header("xlocale.h"); cfg.header("sys/xattr.h"); - cfg.header("sys/sys_domain.h"); - cfg.header("net/if_utun.h"); - cfg.header("net/bpf.h"); - if target.starts_with("x86") { + if target.starts_with("x86") && !ios { cfg.header("crt_externs.h"); } - cfg.header("net/route.h"); - cfg.header("netinet/if_ether.h"); - cfg.header("sys/proc_info.h"); + cfg.header("netinet/in.h"); + cfg.header("sys/ipc.h"); + cfg.header("sys/sem.h"); + cfg.header("sys/shm.h"); + + if !ios { + cfg.header("sys/sys_domain.h"); + cfg.header("net/if_utun.h"); + cfg.header("net/bpf.h"); + cfg.header("net/route.h"); + cfg.header("netinet/if_ether.h"); + cfg.header("sys/proc_info.h"); + cfg.header("sys/kern_control.h"); + } } if bsdlike { @@ -237,26 +258,35 @@ fn main() { } cfg.header("sys/reboot.h"); if !emscripten { + cfg.header("linux/sockios.h"); + cfg.header("linux/netlink.h"); + cfg.header("linux/genetlink.h"); cfg.header("linux/netfilter_ipv4.h"); + cfg.header("linux/netfilter_ipv6.h"); cfg.header("linux/fs.h"); } if !musl { cfg.header("asm/mman.h"); - cfg.header("linux/netlink.h"); cfg.header("linux/magic.h"); cfg.header("linux/reboot.h"); + cfg.header("linux/netfilter/nf_tables.h"); if !mips { cfg.header("linux/quota.h"); } } } + if solaris { + cfg.header("sys/epoll.h"); + } if linux || android { cfg.header("sys/fsuid.h"); + cfg.header("linux/module.h"); cfg.header("linux/seccomp.h"); cfg.header("linux/if_ether.h"); - + cfg.header("linux/if_tun.h"); + cfg.header("linux/net_tstamp.h"); // DCCP support if !uclibc && !musl && !emscripten { cfg.header("linux/dccp.h"); @@ -271,7 +301,7 @@ fn main() { cfg.header("linux/random.h"); cfg.header("elf.h"); cfg.header("link.h"); - cfg.header("linux/if_tun.h"); + cfg.header("spawn.h"); } if freebsd { @@ -279,16 +309,21 @@ fn main() { cfg.header("pthread_np.h"); cfg.header("sched.h"); cfg.header("ufs/ufs/quota.h"); + cfg.header("sys/extattr.h"); cfg.header("sys/jail.h"); cfg.header("sys/ipc.h"); cfg.header("sys/msg.h"); cfg.header("sys/shm.h"); + cfg.header("sys/procdesc.h"); + cfg.header("sys/rtprio.h"); + cfg.header("spawn.h"); } if netbsd { cfg.header("mqueue.h"); cfg.header("ufs/ufs/quota.h"); cfg.header("ufs/ufs/quota1.h"); + cfg.header("sys/extattr.h"); cfg.header("sys/ioctl_compat.h"); // DCCP support @@ -306,6 +341,7 @@ fn main() { cfg.header("ufs/ufs/quota.h"); cfg.header("pthread_np.h"); cfg.header("sys/ioctl_compat.h"); + cfg.header("sys/rtprio.h"); } if solaris { @@ -321,15 +357,17 @@ fn main() { } } - cfg.type_name(move |ty, is_struct| { + if cloudabi || redox { + cfg.header("strings.h"); + } + + cfg.type_name(move |ty, is_struct, is_union| { match ty { // Just pass all these through, no need for a "struct" prefix - "FILE" | - "fd_set" | - "Dl_info" | - "DIR" | - "Elf32_Phdr" | - "Elf64_Phdr" => ty.to_string(), + "FILE" | "fd_set" | "Dl_info" | "DIR" | "Elf32_Phdr" + | "Elf64_Phdr" | "Elf32_Shdr" | "Elf64_Shdr" | "Elf32_Sym" + | "Elf64_Sym" | "Elf32_Ehdr" | "Elf64_Ehdr" | "Elf32_Chdr" + | "Elf64_Chdr" => ty.to_string(), // Fixup a few types on windows that don't actually exist. "time64_t" if windows => "__time64_t".to_string(), @@ -338,6 +376,8 @@ fn main() { // OSX calls this something else "sighandler_t" if bsdlike => "sig_t".to_string(), + t if is_union => format!("union {}", t), + t if t.ends_with("_t") => t.to_string(), // Windows uppercase structs don't have `struct` in front, there's a @@ -362,8 +402,12 @@ fn main() { let target2 = target.clone(); cfg.field_name(move |struct_, field| { match field { - "st_birthtime" if openbsd && struct_ == "stat" => "__st_birthtime".to_string(), - "st_birthtime_nsec" if openbsd && struct_ == "stat" => "__st_birthtimensec".to_string(), + "st_birthtime" if openbsd && struct_ == "stat" => { + "__st_birthtime".to_string() + } + "st_birthtime_nsec" if openbsd && struct_ == "stat" => { + "__st_birthtimensec".to_string() + } // Our stat *_nsec fields normally don't actually exist but are part // of a timeval struct s if s.ends_with("_nsec") && struct_.starts_with("stat") => { @@ -376,9 +420,15 @@ fn main() { } } "u64" if struct_ == "epoll_event" => "data.u64".to_string(), - "type_" if linux && - (struct_ == "input_event" || struct_ == "input_mask" || - struct_ == "ff_effect") => "type".to_string(), + "type_" + if (linux || freebsd || dragonfly) + && (struct_ == "input_event" + || struct_ == "input_mask" + || struct_ == "ff_effect" + || struct_ == "rtprio") => + { + "type".to_string() + } s => s.to_string(), } }); @@ -388,7 +438,7 @@ fn main() { // sighandler_t is crazy across platforms "sighandler_t" => true, - _ => false + _ => false, } }); @@ -401,8 +451,10 @@ fn main() { // which is absent in glibc, has to be defined. "__timeval" if linux => true, - // The alignment of this is 4 on 64-bit OSX... - "kevent" if apple && x86_64 => true, + // Fixed on feature=align with repr(packed(4)) + // Once repr_packed stabilizes we can fix this unconditionally + // and remove this check. + "kevent" | "shmid_ds" | "semid_ds" if apple && x86_64 => true, // This is actually a union, not a struct "sigval" => true, @@ -420,16 +472,26 @@ fn main() { // header conflicts when including them with all the other structs. "termios2" => true, - _ => false + // Present on historical versions of iOS but missing in more recent + // SDKs + "bpf_hdr" | "proc_taskinfo" | "proc_taskallinfo" + | "proc_bsdinfo" | "proc_threadinfo" | "sockaddr_inarp" + | "sockaddr_ctl" | "arphdr" + if ios => + { + true + } + + _ => false, } }); cfg.skip_signededness(move |c| { match c { - "LARGE_INTEGER" | - "mach_timebase_info_data_t" | - "float" | - "double" => true, + "LARGE_INTEGER" + | "mach_timebase_info_data_t" + | "float" + | "double" => true, // uuid_t is a struct, not an integer. "uuid_t" if dragonfly => true, n if n.starts_with("pthread") => true, @@ -438,6 +500,9 @@ fn main() { // mqd_t is a pointer on FreeBSD and DragonFly "mqd_t" if freebsd || dragonfly => true, + // Just some typedefs on osx, no need to check their sign + "posix_spawnattr_t" | "posix_spawn_file_actions_t" => true, + // windows-isms n if n.starts_with("P") => true, n if n.starts_with("H") => true, @@ -449,25 +514,31 @@ fn main() { cfg.skip_const(move |name| { match name { // Apparently these don't exist in mingw headers? - "MEM_RESET_UNDO" | - "FILE_ATTRIBUTE_NO_SCRUB_DATA" | - "FILE_ATTRIBUTE_INTEGRITY_STREAM" | - "ERROR_NOTHING_TO_TERMINATE" if mingw => true, + "MEM_RESET_UNDO" + | "FILE_ATTRIBUTE_NO_SCRUB_DATA" + | "FILE_ATTRIBUTE_INTEGRITY_STREAM" + | "ERROR_NOTHING_TO_TERMINATE" + if mingw => + { + true + } - "SIG_DFL" | - "SIG_ERR" | - "SIG_IGN" => true, // sighandler_t weirdness - "SIGUNUSED" => true, // removed in glibc 2.26 + "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // sighandler_t weirdness + "SIGUNUSED" => true, // removed in glibc 2.26 // types on musl are defined a little differently n if musl && n.contains("__SIZEOF_PTHREAD") => true, // Skip constants not defined in MUSL but just passed down to the // kernel regardless - "RLIMIT_NLIMITS" | - "TCP_COOKIE_TRANSACTIONS" | - "RLIMIT_RTTIME" | - "MSG_COPY" if musl => true, + "RLIMIT_NLIMITS" + | "TCP_COOKIE_TRANSACTIONS" + | "RLIMIT_RTTIME" + | "MSG_COPY" + if musl => + { + true + } // work around super old mips toolchain "SCHED_IDLE" | "SHM_NORESERVE" => mips, @@ -476,21 +547,32 @@ fn main() { "MS_RMT_MASK" => true, // updated in glibc 2.22 and musl 1.1.13 // These OSX constants are flagged as deprecated - "NOTE_EXIT_REPARENTED" | - "NOTE_REAP" if apple => true, + "NOTE_EXIT_REPARENTED" | "NOTE_REAP" if apple => true, // These constants were removed in FreeBSD 11 (svn r273250) but will // still be accepted and ignored at runtime. - "MAP_RENAME" | - "MAP_NORESERVE" if freebsd => true, + "MAP_RENAME" | "MAP_NORESERVE" if freebsd => true, // These constants were removed in FreeBSD 11 (svn r262489), // and they've never had any legitimate use outside of the // base system anyway. - "CTL_MAXID" | - "KERN_MAXID" | - "HW_MAXID" | - "USER_MAXID" if freebsd => true, + "CTL_MAXID" | "KERN_MAXID" | "HW_MAXID" | "NET_MAXID" + | "USER_MAXID" + if freebsd => + { + true + } + + // These constants were added in FreeBSD 11 + "EVFILT_PROCDESC" | "EVFILT_SENDFILE" | "EVFILT_EMPTY" + | "PD_CLOEXEC" | "PD_ALLOWED_AT_FORK" + if freebsd => + { + true + } + + // These constants were added in FreeBSD 12 + "SF_USER_READAHEAD" | "SO_REUSEPORT_LB" if freebsd => true, // These OSX constants are removed in Sierra. // https://developer.apple.com/library/content/releasenotes/General/APIDiffsMacOS10_12/Swift/Darwin.html @@ -499,21 +581,43 @@ fn main() { // These constants were removed in OpenBSD 6 (https://git.io/v7gBO // https://git.io/v7gBq) - "KERN_USERMOUNT" | - "KERN_ARND" if openbsd => true, - - // These constats were added in OpenBSD 6.2 - "EV_RECEIPT" | "EV_DISPATCH" if openbsd => true, + "KERN_USERMOUNT" | "KERN_ARND" if openbsd => true, // These are either unimplemented or optionally built into uClibc - "LC_CTYPE_MASK" | "LC_NUMERIC_MASK" | "LC_TIME_MASK" | "LC_COLLATE_MASK" | "LC_MONETARY_MASK" | "LC_MESSAGES_MASK" | - "MADV_MERGEABLE" | "MADV_UNMERGEABLE" | "MADV_HWPOISON" | "IPV6_ADD_MEMBERSHIP" | "IPV6_DROP_MEMBERSHIP" | "IPV6_MULTICAST_LOOP" | "IPV6_V6ONLY" | - "MAP_STACK" | "RTLD_DEEPBIND" | "SOL_IPV6" | "SOL_ICMPV6" if uclibc => true, + "LC_CTYPE_MASK" + | "LC_NUMERIC_MASK" + | "LC_TIME_MASK" + | "LC_COLLATE_MASK" + | "LC_MONETARY_MASK" + | "LC_MESSAGES_MASK" + | "MADV_MERGEABLE" + | "MADV_UNMERGEABLE" + | "MADV_HWPOISON" + | "IPV6_ADD_MEMBERSHIP" + | "IPV6_DROP_MEMBERSHIP" + | "IPV6_MULTICAST_LOOP" + | "IPV6_V6ONLY" + | "MAP_STACK" + | "RTLD_DEEPBIND" + | "SOL_IPV6" + | "SOL_ICMPV6" + if uclibc => + { + true + } // Musl uses old, patched kernel headers - "FALLOC_FL_COLLAPSE_RANGE" | "FALLOC_FL_ZERO_RANGE" | - "FALLOC_FL_INSERT_RANGE" | "FALLOC_FL_UNSHARE_RANGE" | - "RENAME_NOREPLACE" | "RENAME_EXCHANGE" | "RENAME_WHITEOUT" if musl => true, + "FALLOC_FL_COLLAPSE_RANGE" + | "FALLOC_FL_ZERO_RANGE" + | "FALLOC_FL_INSERT_RANGE" + | "FALLOC_FL_UNSHARE_RANGE" + | "RENAME_NOREPLACE" + | "RENAME_EXCHANGE" + | "RENAME_WHITEOUT" + if musl => + { + true + } // Both android and musl use old kernel headers // These are constants used in getrandom syscall @@ -521,7 +625,7 @@ fn main() { // Defined by libattr not libc on linux (hard to test). // See constant definition for more details. - "ENOATTR" if linux => true, + "ENOATTR" if android || linux => true, // On mips*-unknown-linux-gnu* CMSPAR cannot be included with the set of headers we // want to use here for testing. It's originally defined in asm/termbits.h, which is @@ -538,18 +642,67 @@ fn main() { // These constants are tested in a separate test program generated below because there // are header conflicts if we try to include the headers that define them here. "F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" => true, - "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" | "F_SEAL_WRITE" => true, - "QFMT_VFS_OLD" | "QFMT_VFS_V0" | "QFMT_VFS_V1" if mips && linux => true, // Only on MIPS + "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" + | "F_SEAL_WRITE" => true, + "QFMT_VFS_OLD" | "QFMT_VFS_V0" | "QFMT_VFS_V1" + if mips && linux => + { + true + } // Only on MIPS "BOTHER" => true, "MFD_CLOEXEC" | "MFD_ALLOW_SEALING" if !mips && musl => true, - "DT_FIFO" | "DT_CHR" | "DT_DIR" | "DT_BLK" | "DT_REG" | "DT_LNK" | "DT_SOCK" if solaris => true, + "DT_FIFO" | "DT_CHR" | "DT_DIR" | "DT_BLK" | "DT_REG" + | "DT_LNK" | "DT_SOCK" + if solaris => + { + true + } "USRQUOTA" | "GRPQUOTA" if solaris => true, "PRIO_MIN" | "PRIO_MAX" if solaris => true, // These are defined for Solaris 11, but the crate is tested on illumos, where they are currently not defined - "EADI" | "PORT_SOURCE_POSTWAIT" | "PORT_SOURCE_SIGNAL" | "PTHREAD_STACK_MIN" => true, + "EADI" + | "PORT_SOURCE_POSTWAIT" + | "PORT_SOURCE_SIGNAL" + | "PTHREAD_STACK_MIN" => true, + + // These change all the time from release to release of linux + // distros, let's just not bother trying to verify them. They + // shouldn't be used in code anyway... + "AF_MAX" | "PF_MAX" => true, + + // These are not in a glibc release yet, only in kernel headers. + "AF_XDP" | "PF_XDP" | "SOL_XDP" if linux => true, + + // Present on historical versions of iOS, but now removed in more + // recent SDKs + "ARPOP_REQUEST" + | "ARPOP_REPLY" + | "ATF_COM" + | "ATF_PERM" + | "ATF_PUBL" + | "ATF_USETRAILERS" + | "AF_SYS_CONTROL" + | "SYSPROTO_EVENT" + | "PROC_PIDTASKALLINFO" + | "PROC_PIDTASKINFO" + | "PROC_PIDTHREADINFO" + | "UTUN_OPT_FLAGS" + | "UTUN_OPT_IFNAME" + | "BPF_ALIGNMENT" + | "SYSPROTO_CONTROL" + if ios => + { + true + } + s if ios && s.starts_with("RTF_") => true, + s if ios && s.starts_with("RTM_") => true, + s if ios && s.starts_with("RTA_") => true, + s if ios && s.starts_with("RTAX_") => true, + s if ios && s.starts_with("RTV_") => true, + s if ios && s.starts_with("DLT_") => true, _ => false, } @@ -636,6 +789,9 @@ fn main() { // the symbol. "uname" if freebsd => true, + // FIXME: need to upgrade FreeBSD version; see https://github.com/rust-lang/libc/issues/938 + "setgrent" if freebsd => true, + // aio_waitcomplete's return type changed between FreeBSD 10 and 11. "aio_waitcomplete" if freebsd => true, @@ -690,6 +846,18 @@ fn main() { // FIXME: mincore is defined with caddr_t on Solaris. "mincore" if solaris => true, + // These were all included in historical versions of iOS but appear + // to be removed now + "system" | "ptrace" if ios => true, + + _ => false, + } + }); + + cfg.skip_static(move |name| { + match name { + // Internal constant, not declared in any headers. + "__progname" if android => true, _ => false, } }); @@ -731,7 +899,13 @@ fn main() { // musl seems to define this as an *anonymous* bitfield (musl && struct_ == "statvfs" && field == "__f_unused") || // sigev_notify_thread_id is actually part of a sigev_un union - (struct_ == "sigevent" && field == "sigev_notify_thread_id") + (struct_ == "sigevent" && field == "sigev_notify_thread_id") || + // signalfd had SIGSYS fields added in Linux 4.18, but no libc release has them yet. + (struct_ == "signalfd_siginfo" && (field == "ssi_addr_lsb" || + field == "_pad2" || + field == "ssi_syscall" || + field == "ssi_call_addr" || + field == "ssi_arch")) }); cfg.fn_cname(move |name, cname| { @@ -749,7 +923,8 @@ fn main() { // fails on a lot of platforms. let mut cfg = ctest::TestGenerator::new(); cfg.skip_type(|_| true) - .skip_fn(|_| true); + .skip_fn(|_| true) + .skip_static(|_| true); if android || linux { // musl defines these directly in `fcntl.h` if musl { @@ -763,23 +938,23 @@ fn main() { } cfg.header("linux/quota.h"); cfg.header("asm/termbits.h"); - cfg.skip_const(move |name| { - match name { - "F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" => false, - "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" | "F_SEAL_WRITE" => false, - "QFMT_VFS_OLD" | "QFMT_VFS_V0" | "QFMT_VFS_V1" if mips && linux => false, - "BOTHER" => false, - _ => true, + cfg.skip_const(move |name| match name { + "F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" => false, + "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" + | "F_SEAL_WRITE" => false, + "QFMT_VFS_OLD" | "QFMT_VFS_V0" | "QFMT_VFS_V1" + if mips && linux => + { + false } + "BOTHER" => false, + _ => true, }); - cfg.skip_struct(|s| { - s != "termios2" - }); - cfg.type_name(move |ty, is_struct| { - match ty { - t if is_struct => format!("struct {}", t), - t => t.to_string(), - } + cfg.skip_struct(|s| s != "termios2"); + cfg.type_name(move |ty, is_struct, is_union| match ty { + t if is_struct => format!("struct {}", t), + t if is_union => format!("union {}", t), + t => t.to_string(), }); } else { cfg.skip_const(|_| true); diff --git a/libc/src/cloudabi/mod.rs b/libc/src/cloudabi/mod.rs index e506414..df11de0 100644 --- a/libc/src/cloudabi/mod.rs +++ b/libc/src/cloudabi/mod.rs @@ -1,3 +1,33 @@ +use dox::Option; + +pub type int8_t = i8; +pub type int16_t = i16; +pub type int32_t = i32; +pub type int64_t = i64; +pub type uint8_t = u8; +pub type uint16_t = u16; +pub type uint32_t = u32; +pub type uint64_t = u64; + +pub type c_schar = i8; +pub type c_uchar = u8; +pub type c_short = i16; +pub type c_ushort = u16; +pub type c_int = i32; +pub type c_uint = u32; +pub type c_float = f32; +pub type c_double = f64; +pub type c_longlong = i64; +pub type c_ulonglong = u64; +pub type intmax_t = i64; +pub type uintmax_t = u64; + +pub type size_t = usize; +pub type ptrdiff_t = isize; +pub type intptr_t = isize; +pub type uintptr_t = usize; +pub type ssize_t = isize; + pub type in_addr_t = u32; pub type in_port_t = u16; pub type pthread_key_t = usize; @@ -56,6 +86,9 @@ s! { } } +pub const INT_MIN: c_int = -2147483648; +pub const INT_MAX: c_int = 2147483647; + pub const _SC_NPROCESSORS_ONLN: ::c_int = 52; pub const _SC_PAGESIZE: ::c_int = 54; @@ -89,7 +122,114 @@ pub const PTHREAD_STACK_MIN: ::size_t = 1024; pub const SOCK_DGRAM: ::c_int = 128; pub const SOCK_STREAM: ::c_int = 130; +pub enum FILE {} +pub enum fpos_t {} // TODO: fill this out with a struct + extern { + pub fn isalnum(c: c_int) -> c_int; + pub fn isalpha(c: c_int) -> c_int; + pub fn iscntrl(c: c_int) -> c_int; + pub fn isdigit(c: c_int) -> c_int; + pub fn isgraph(c: c_int) -> c_int; + pub fn islower(c: c_int) -> c_int; + pub fn isprint(c: c_int) -> c_int; + pub fn ispunct(c: c_int) -> c_int; + pub fn isspace(c: c_int) -> c_int; + pub fn isupper(c: c_int) -> c_int; + pub fn isxdigit(c: c_int) -> c_int; + pub fn tolower(c: c_int) -> c_int; + pub fn toupper(c: c_int) -> c_int; + pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE; + pub fn freopen(filename: *const c_char, mode: *const c_char, + file: *mut FILE) -> *mut FILE; + pub fn fflush(file: *mut FILE) -> c_int; + pub fn fclose(file: *mut FILE) -> c_int; + pub fn remove(filename: *const c_char) -> c_int; + pub fn rename(oldname: *const c_char, newname: *const c_char) -> c_int; + pub fn tmpfile() -> *mut FILE; + pub fn setvbuf(stream: *mut FILE, buffer: *mut c_char, mode: c_int, + size: size_t) -> c_int; + pub fn setbuf(stream: *mut FILE, buf: *mut c_char); + pub fn getchar() -> c_int; + pub fn putchar(c: c_int) -> c_int; + pub fn fgetc(stream: *mut FILE) -> c_int; + pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char; + pub fn fputc(c: c_int, stream: *mut FILE) -> c_int; + pub fn fputs(s: *const c_char, stream: *mut FILE) -> c_int; + pub fn puts(s: *const c_char) -> c_int; + pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int; + pub fn fread(ptr: *mut c_void, size: size_t, nobj: size_t, + stream: *mut FILE) -> size_t; + pub fn fwrite(ptr: *const c_void, size: size_t, nobj: size_t, + stream: *mut FILE) -> size_t; + pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int; + pub fn ftell(stream: *mut FILE) -> c_long; + pub fn rewind(stream: *mut FILE); + pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int; + pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int; + pub fn feof(stream: *mut FILE) -> c_int; + pub fn ferror(stream: *mut FILE) -> c_int; + pub fn perror(s: *const c_char); + pub fn atoi(s: *const c_char) -> c_int; + pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double; + pub fn strtol(s: *const c_char, endp: *mut *mut c_char, + base: c_int) -> c_long; + pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, + base: c_int) -> c_ulong; + pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; + pub fn malloc(size: size_t) -> *mut c_void; + pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; + pub fn free(p: *mut c_void); + pub fn abort() -> !; + pub fn exit(status: c_int) -> !; + pub fn _exit(status: c_int) -> !; + pub fn atexit(cb: extern fn()) -> c_int; + pub fn system(s: *const c_char) -> c_int; + pub fn getenv(s: *const c_char) -> *mut c_char; + pub fn getline (lineptr: *mut *mut c_char, n: *mut size_t, + stream: *mut FILE) -> ssize_t; + + pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char; + pub fn strncpy(dst: *mut c_char, src: *const c_char, + n: size_t) -> *mut c_char; + pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char; + pub fn strncat(s: *mut c_char, ct: *const c_char, n: size_t) -> *mut c_char; + pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strncmp(cs: *const c_char, ct: *const c_char, n: size_t) -> c_int; + pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strdup(cs: *const c_char) -> *mut c_char; + pub fn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn strcasecmp(s1: *const c_char, s2: *const c_char) -> c_int; + pub fn strncasecmp(s1: *const c_char, s2: *const c_char, + n: size_t) -> c_int; + pub fn strlen(cs: *const c_char) -> size_t; + pub fn strnlen(cs: *const c_char, maxlen: size_t) -> size_t; + pub fn strerror(n: c_int) -> *mut c_char; + pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char; + pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t; + pub fn wcslen(buf: *const wchar_t) -> size_t; + pub fn wcstombs(dest: *mut c_char, src: *const wchar_t, + n: size_t) -> ::size_t; + + pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; + pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int; + pub fn memcpy(dest: *mut c_void, src: *const c_void, + n: size_t) -> *mut c_void; + pub fn memmove(dest: *mut c_void, src: *const c_void, + n: size_t) -> *mut c_void; + pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void; + + pub fn abs(i: c_int) -> c_int; + pub fn atof(s: *const c_char) -> c_double; + pub fn labs(i: c_long) -> c_long; + pub fn rand() -> c_int; + pub fn srand(seed: c_uint); + pub fn arc4random_buf(buf: *const ::c_void, len: ::size_t); pub fn freeaddrinfo(res: *mut addrinfo); pub fn gai_strerror(errcode: ::c_int) -> *const ::c_char; @@ -164,3 +304,21 @@ cfg_if! { // Unknown target_arch } } + +cfg_if! { + if #[cfg(core_cvoid)] { + pub use core::ffi::c_void; + } else { + // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help + // enable more optimization opportunities around it recognizing things + // like malloc/free. + #[repr(u8)] + pub enum c_void { + // Two dummy variants so the #[repr] attribute can be used. + #[doc(hidden)] + __variant1, + #[doc(hidden)] + __variant2, + } + } +} diff --git a/libc/src/dox.rs b/libc/src/dox.rs index 5c095b9..33a9c16 100644 --- a/libc/src/dox.rs +++ b/libc/src/dox.rs @@ -1,14 +1,14 @@ pub use self::imp::*; -#[cfg(not(dox))] +#[cfg(not(cross_platform_docs))] mod imp { - pub use core::option::Option; pub use core::clone::Clone; pub use core::marker::Copy; pub use core::mem; + pub use core::option::Option; } -#[cfg(dox)] +#[cfg(cross_platform_docs)] mod imp { pub enum Option<T> { Some(T), @@ -16,7 +16,23 @@ mod imp { } impl<T: Copy> Copy for Option<T> {} impl<T: Clone> Clone for Option<T> { - fn clone(&self) -> Option<T> { loop {} } + fn clone(&self) -> Option<T> { + loop {} + } + } + + impl<T> Copy for *mut T {} + impl<T> Clone for *mut T { + fn clone(&self) -> *mut T { + loop {} + } + } + + impl<T> Copy for *const T {} + impl<T> Clone for *const T { + fn clone(&self) -> *const T { + loop {} + } } pub trait Clone { @@ -37,56 +53,83 @@ mod imp { pub trait Sized {} macro_rules! each_int { - ($mac:ident) => ( + ($mac:ident) => { $mac!(u8); $mac!(u16); $mac!(u32); $mac!(u64); $mac!(usize); each_signed_int!($mac); - ) + }; } macro_rules! each_signed_int { - ($mac:ident) => ( + ($mac:ident) => { $mac!(i8); $mac!(i16); $mac!(i32); $mac!(i64); $mac!(isize); - ) + }; } #[lang = "div"] - pub trait Div<RHS> { + pub trait Div<RHS = Self> { type Output; fn div(self, rhs: RHS) -> Self::Output; } #[lang = "shl"] - pub trait Shl<RHS> { + pub trait Shl<RHS = Self> { type Output; fn shl(self, rhs: RHS) -> Self::Output; } #[lang = "mul"] - pub trait Mul<RHS=Self> { + pub trait Mul<RHS = Self> { type Output; fn mul(self, rhs: RHS) -> Self::Output; } #[lang = "sub"] - pub trait Sub<RHS=Self> { + pub trait Sub<RHS = Self> { type Output; fn sub(self, rhs: RHS) -> Self::Output; } + #[lang = "bitand"] + pub trait BitAnd<RHS = Self> { + type Output; + fn bitand(self, rhs: RHS) -> Self::Output; + } + + #[lang = "bitand_assign"] + pub trait BitAndAssign<RHS = Self> { + fn bitand_assign(&mut self, rhs: RHS); + } + #[lang = "bitor"] - pub trait Bitor<RHS=Self> { + pub trait BitOr<RHS = Self> { type Output; fn bitor(self, rhs: RHS) -> Self::Output; } + #[lang = "bitor_assign"] + pub trait BitOrAssign<RHS = Self> { + fn bitor_assign(&mut self, rhs: RHS); + } + + #[lang = "bitxor"] + pub trait BitXor<RHS = Self> { + type Output; + fn bitxor(self, rhs: RHS) -> Self::Output; + } + + #[lang = "bitxor_assign"] + pub trait BitXorAssign<RHS = Self> { + fn bitxor_assign(&mut self, rhs: RHS); + } + #[lang = "neg"] pub trait Neg { type Output; @@ -124,10 +167,27 @@ mod imp { type Output = $i; fn sub(self, rhs: $i) -> $i { self - rhs } } - impl Bitor for $i { + impl BitAnd for $i { + type Output = $i; + fn bitand(self, rhs: $i) -> $i { self & rhs } + } + impl BitAndAssign for $i { + fn bitand_assign(&mut self, rhs: $i) { *self &= rhs; } + } + impl BitOr for $i { type Output = $i; fn bitor(self, rhs: $i) -> $i { self | rhs } } + impl BitOrAssign for $i { + fn bitor_assign(&mut self, rhs: $i) { *self |= rhs; } + } + impl BitXor for $i { + type Output = $i; + fn bitxor(self, rhs: $i) -> $i { self ^ rhs } + } + impl BitXorAssign for $i { + fn bitxor_assign(&mut self, rhs: $i) { *self ^= rhs; } + } impl Neg for $i { type Output = $i; fn neg(self) -> $i { -self } @@ -140,12 +200,20 @@ mod imp { type Output = $i; fn add(self, other: $i) -> $i { self + other } } + impl Copy for $i {} + impl Clone for $i { + fn clone(&self) -> $i { loop {} } + } )*) } each_int!(impl_traits); pub mod mem { - pub fn size_of_val<T>(_: &T) -> usize { 4 } - pub fn size_of<T>(_: &T) -> usize { 4 } + pub fn size_of_val<T>(_: &T) -> usize { + 4 + } + pub const fn size_of<T>() -> usize { + 4 + } } } diff --git a/libc/src/fuchsia/aarch64.rs b/libc/src/fuchsia/aarch64.rs index 157d3d6..572f8c1 100644 --- a/libc/src/fuchsia/aarch64.rs +++ b/libc/src/fuchsia/aarch64.rs @@ -1,8 +1,8 @@ pub type c_char = u8; pub type __u64 = ::c_ulonglong; pub type wchar_t = u32; -pub type nlink_t = u32; -pub type blksize_t = ::c_int; +pub type nlink_t = ::c_ulong; +pub type blksize_t = ::c_long; s! { pub struct stat { diff --git a/libc/src/fuchsia/mod.rs b/libc/src/fuchsia/mod.rs index ac11fbb..e785fab 100644 --- a/libc/src/fuchsia/mod.rs +++ b/libc/src/fuchsia/mod.rs @@ -7,6 +7,34 @@ use dox::{mem, Option}; // PUB_TYPE +pub type int8_t = i8; +pub type int16_t = i16; +pub type int32_t = i32; +pub type int64_t = i64; +pub type uint8_t = u8; +pub type uint16_t = u16; +pub type uint32_t = u32; +pub type uint64_t = u64; + +pub type c_schar = i8; +pub type c_uchar = u8; +pub type c_short = i16; +pub type c_ushort = u16; +pub type c_int = i32; +pub type c_uint = u32; +pub type c_float = f32; +pub type c_double = f64; +pub type c_longlong = i64; +pub type c_ulonglong = u64; +pub type intmax_t = i64; +pub type uintmax_t = u64; + +pub type size_t = usize; +pub type ptrdiff_t = isize; +pub type intptr_t = isize; +pub type uintptr_t = usize; +pub type ssize_t = isize; + pub type pid_t = i32; pub type uid_t = u32; pub type gid_t = u32; @@ -97,16 +125,13 @@ s! { pub tv_usec: suseconds_t, } - // linux x32 compatibility - // See https://sourceware.org/bugzilla/show_bug.cgi?id=16437 pub struct timespec { pub tv_sec: time_t, - #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - pub tv_nsec: i64, - #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] pub tv_nsec: ::c_long, } + // FIXME: the rlimit and rusage related functions and types don't exist + // within zircon. Are there reasons for keeping them around? pub struct rlimit { pub rlim_cur: rlim_t, pub rlim_max: rlim_t, @@ -168,7 +193,6 @@ s! { pub struct in6_addr { pub s6_addr: [u8; 16], - __align: [u32; 0], } pub struct ip_mreq { @@ -178,9 +202,6 @@ s! { pub struct ipv6_mreq { pub ipv6mr_multiaddr: in6_addr, - #[cfg(target_os = "android")] - pub ipv6mr_interface: ::c_int, - #[cfg(not(target_os = "android"))] pub ipv6mr_interface: ::c_uint, } @@ -398,13 +419,9 @@ s! { pub struct sched_param { pub sched_priority: ::c_int, - #[cfg(target_env = "musl")] pub sched_ss_low_priority: ::c_int, - #[cfg(target_env = "musl")] pub sched_ss_repl_period: ::timespec, - #[cfg(target_env = "musl")] pub sched_ss_init_budget: ::timespec, - #[cfg(target_env = "musl")] pub sched_ss_max_repl: ::c_int, } @@ -415,11 +432,6 @@ s! { pub dli_saddr: *mut ::c_void, } - #[cfg_attr(any(all(target_arch = "x86", - not(target_env = "musl"), - not(target_os = "android")), - target_arch = "x86_64"), - repr(packed))] pub struct epoll_event { pub events: ::uint32_t, pub u64: ::uint64_t, @@ -465,13 +477,9 @@ s! { pub sigev_value: ::sigval, pub sigev_signo: ::c_int, pub sigev_notify: ::c_int, - // Actually a union. We only expose sigev_notify_thread_id because it's - // the most useful member - pub sigev_notify_thread_id: ::c_int, - #[cfg(target_pointer_width = "64")] - __unused1: [::c_int; 11], - #[cfg(target_pointer_width = "32")] - __unused1: [::c_int; 12] + pub sigev_notify_function: fn(::sigval), + pub sigev_notify_attributes: *mut pthread_attr_t, + pub __pad: [::c_char; 56 - 3 * 8 /* 8 == sizeof(long) */], } pub struct dirent { @@ -518,71 +526,118 @@ s! { pub ifa_data: *mut ::c_void } + #[cfg_attr(all(feature = "align", + target_pointer_width = "32", + any(target_arch = "arm", + target_arch = "x86_64")), + repr(align(4)))] + #[cfg_attr(all(feature = "align", + any(target_pointer_width = "64", + not(any(target_arch = "arm", + target_arch = "x86_64")))), + repr(align(8)))] pub struct pthread_mutex_t { - #[cfg(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc", - all(target_arch = "x86_64", - target_pointer_width = "32")))] + #[cfg(all(not(feature = "align"), + any(target_arch = "arm", + all(target_arch = "x86_64", + target_pointer_width = "32"))))] __align: [::c_long; 0], - #[cfg(not(any(target_arch = "mips", + #[cfg(not(any(feature = "align", target_arch = "arm", - target_arch = "powerpc", all(target_arch = "x86_64", target_pointer_width = "32"))))] __align: [::c_longlong; 0], size: [u8; __SIZEOF_PTHREAD_MUTEX_T], } + #[cfg_attr(all(feature = "align", + target_pointer_width = "32", + any(target_arch = "arm", + target_arch = "x86_64")), + repr(align(4)))] + #[cfg_attr(all(feature = "align", + any(target_pointer_width = "64", + not(any(target_arch = "arm", + target_arch = "x86_64")))), + repr(align(8)))] pub struct pthread_rwlock_t { - #[cfg(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc", - all(target_arch = "x86_64", - target_pointer_width = "32")))] + #[cfg(all(not(feature = "align"), + any(target_arch = "arm", + all(target_arch = "x86_64", + target_pointer_width = "32"))))] __align: [::c_long; 0], - #[cfg(not(any(target_arch = "mips", + #[cfg(not(any(feature = "align", target_arch = "arm", - target_arch = "powerpc", all(target_arch = "x86_64", target_pointer_width = "32"))))] __align: [::c_longlong; 0], size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], } + #[cfg_attr(all(feature = "align", + any(target_pointer_width = "32", + target_arch = "x86_64", + all(target_arch = "aarch64", target_env = "musl"))), + repr(align(4)))] + #[cfg_attr(all(feature = "align", + not(any(target_pointer_width = "32", + target_arch = "x86_64", + all(target_arch = "aarch64", target_env = "musl")))), + repr(align(8)))] pub struct pthread_mutexattr_t { - #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64"))] + #[cfg(all(not(features = "align"), + any(target_arch = "x86_64", + all(target_arch = "aarch64", target_env = "musl"))))] __align: [::c_int; 0], - #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64", target_arch = "aarch64")))] - __align: [::c_long; 0], - #[cfg(all(target_arch = "aarch64", target_env = "gnu"))] + #[cfg(all(not(features = "align"), + not(any(target_arch = "x86_64", + all(target_arch = "aarch64", target_env = "musl")))))] __align: [::c_long; 0], - #[cfg(all(target_arch = "aarch64", target_env = "musl"))] - __align: [::c_int; 0], size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], } + #[cfg_attr(all(feature = "align", + any(target_env = "musl", target_pointer_width = "32")), + repr(align(4)))] + #[cfg_attr(all(feature = "align", + not(target_env = "musl"), + target_pointer_width = "64"), + repr(align(8)))] pub struct pthread_rwlockattr_t { - #[cfg(any(target_env = "musl"))] + #[cfg(all(not(feature = "align"), target_env = "musl"))] __align: [::c_int; 0], - #[cfg(not(any(target_env = "musl")))] + #[cfg(all(not(feature = "align"), not(target_env = "musl")))] __align: [::c_long; 0], size: [u8; __SIZEOF_PTHREAD_RWLOCKATTR_T], } + #[cfg_attr(all(feature = "align", + target_env = "musl", + target_pointer_width = "32"), + repr(align(4)))] + #[cfg_attr(all(feature = "align", + target_env = "musl", + target_pointer_width = "64"), + repr(align(8)))] + #[cfg_attr(all(feature = "align", + not(target_env = "musl"), + target_arch = "x86"), + repr(align(4)))] + #[cfg_attr(all(feature = "align", + not(target_env = "musl"), + not(target_arch = "x86")), + repr(align(8)))] pub struct pthread_cond_t { - #[cfg(any(target_env = "musl"))] + #[cfg(all(not(feature = "align"), target_env = "musl"))] __align: [*const ::c_void; 0], - #[cfg(not(any(target_env = "musl")))] + #[cfg(not(any(feature = "align", target_env = "musl")))] __align: [::c_longlong; 0], size: [u8; __SIZEOF_PTHREAD_COND_T], } + #[cfg_attr(feature = "align", repr(align(4)))] pub struct pthread_condattr_t { + #[cfg(not(feature = "align"))] __align: [::c_int; 0], size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], } @@ -658,7 +713,12 @@ s! { pub ssi_utime: ::uint64_t, pub ssi_stime: ::uint64_t, pub ssi_addr: ::uint64_t, - _pad: [::uint8_t; 48], + pub ssi_addr_lsb: ::uint16_t, + _pad2: ::uint16_t, + pub ssi_syscall: ::int32_t, + pub ssi_call_addr: ::uint64_t, + pub ssi_arch: ::uint32_t, + _pad: [::uint8_t; 28], } pub struct itimerspec { @@ -1017,6 +1077,9 @@ s! { // PUB_CONST +pub const INT_MIN: c_int = -2147483648; +pub const INT_MAX: c_int = 2147483647; + pub const SIG_DFL: sighandler_t = 0 as sighandler_t; pub const SIG_IGN: sighandler_t = 1 as sighandler_t; pub const SIG_ERR: sighandler_t = !0 as sighandler_t; @@ -1351,6 +1414,9 @@ pub const IFF_MULTICAST: ::c_int = 0x1000; pub const IFF_PORTSEL: ::c_int = 0x2000; pub const IFF_AUTOMEDIA: ::c_int = 0x4000; pub const IFF_DYNAMIC: ::c_int = 0x8000; +pub const IFF_TUN: ::c_int = 0x0001; +pub const IFF_TAP: ::c_int = 0x0002; +pub const IFF_NO_PI: ::c_int = 0x1000; pub const SOL_IP: ::c_int = 0; pub const SOL_TCP: ::c_int = 6; @@ -1483,8 +1549,13 @@ pub const IP_HDRINCL: ::c_int = 3; pub const IP_ADD_MEMBERSHIP: ::c_int = 35; pub const IP_DROP_MEMBERSHIP: ::c_int = 36; pub const IP_TRANSPARENT: ::c_int = 19; +pub const IPV6_UNICAST_HOPS: ::c_int = 16; +pub const IPV6_MULTICAST_IF: ::c_int = 17; +pub const IPV6_MULTICAST_HOPS: ::c_int = 18; +pub const IPV6_MULTICAST_LOOP: ::c_int = 19; pub const IPV6_ADD_MEMBERSHIP: ::c_int = 20; pub const IPV6_DROP_MEMBERSHIP: ::c_int = 21; +pub const IPV6_V6ONLY: ::c_int = 26; pub const TCP_NODELAY: ::c_int = 1; pub const TCP_MAXSEG: ::c_int = 2; @@ -1500,9 +1571,6 @@ pub const TCP_INFO: ::c_int = 11; pub const TCP_QUICKACK: ::c_int = 12; pub const TCP_CONGESTION: ::c_int = 13; -pub const IPV6_MULTICAST_LOOP: ::c_int = 19; -pub const IPV6_V6ONLY: ::c_int = 26; - pub const SO_DEBUG: ::c_int = 1; pub const SHUT_RD: ::c_int = 0; @@ -1999,18 +2067,17 @@ pub const RTLD_NOW: ::c_int = 0x2; pub const TCP_MD5SIG: ::c_int = 14; -pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { - __align: [], - size: [0; __SIZEOF_PTHREAD_MUTEX_T], -}; -pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { - __align: [], - size: [0; __SIZEOF_PTHREAD_COND_T], -}; -pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { - __align: [], - size: [0; __SIZEOF_PTHREAD_RWLOCK_T], -}; +align_const! { + pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + size: [0; __SIZEOF_PTHREAD_MUTEX_T], + }; + pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + size: [0; __SIZEOF_PTHREAD_COND_T], + }; + pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + size: [0; __SIZEOF_PTHREAD_RWLOCK_T], + }; +} pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2; @@ -2975,7 +3042,110 @@ f! { #[link(name = "fdio")] extern {} +pub enum FILE {} +pub enum fpos_t {} // TODO: fill this out with a struct + extern { + pub fn isalnum(c: c_int) -> c_int; + pub fn isalpha(c: c_int) -> c_int; + pub fn iscntrl(c: c_int) -> c_int; + pub fn isdigit(c: c_int) -> c_int; + pub fn isgraph(c: c_int) -> c_int; + pub fn islower(c: c_int) -> c_int; + pub fn isprint(c: c_int) -> c_int; + pub fn ispunct(c: c_int) -> c_int; + pub fn isspace(c: c_int) -> c_int; + pub fn isupper(c: c_int) -> c_int; + pub fn isxdigit(c: c_int) -> c_int; + pub fn tolower(c: c_int) -> c_int; + pub fn toupper(c: c_int) -> c_int; + pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE; + pub fn freopen(filename: *const c_char, mode: *const c_char, + file: *mut FILE) -> *mut FILE; + pub fn fflush(file: *mut FILE) -> c_int; + pub fn fclose(file: *mut FILE) -> c_int; + pub fn remove(filename: *const c_char) -> c_int; + pub fn rename(oldname: *const c_char, newname: *const c_char) -> c_int; + pub fn tmpfile() -> *mut FILE; + pub fn setvbuf(stream: *mut FILE, buffer: *mut c_char, mode: c_int, + size: size_t) -> c_int; + pub fn setbuf(stream: *mut FILE, buf: *mut c_char); + pub fn getchar() -> c_int; + pub fn putchar(c: c_int) -> c_int; + pub fn fgetc(stream: *mut FILE) -> c_int; + pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char; + pub fn fputc(c: c_int, stream: *mut FILE) -> c_int; + pub fn fputs(s: *const c_char, stream: *mut FILE) -> c_int; + pub fn puts(s: *const c_char) -> c_int; + pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int; + pub fn fread(ptr: *mut c_void, size: size_t, nobj: size_t, + stream: *mut FILE) -> size_t; + pub fn fwrite(ptr: *const c_void, size: size_t, nobj: size_t, + stream: *mut FILE) -> size_t; + pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int; + pub fn ftell(stream: *mut FILE) -> c_long; + pub fn rewind(stream: *mut FILE); + pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int; + pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int; + pub fn feof(stream: *mut FILE) -> c_int; + pub fn ferror(stream: *mut FILE) -> c_int; + pub fn perror(s: *const c_char); + pub fn atoi(s: *const c_char) -> c_int; + pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double; + pub fn strtol(s: *const c_char, endp: *mut *mut c_char, + base: c_int) -> c_long; + pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, + base: c_int) -> c_ulong; + pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; + pub fn malloc(size: size_t) -> *mut c_void; + pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; + pub fn free(p: *mut c_void); + pub fn abort() -> !; + pub fn exit(status: c_int) -> !; + pub fn _exit(status: c_int) -> !; + pub fn atexit(cb: extern fn()) -> c_int; + pub fn system(s: *const c_char) -> c_int; + pub fn getenv(s: *const c_char) -> *mut c_char; + + pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char; + pub fn strncpy(dst: *mut c_char, src: *const c_char, + n: size_t) -> *mut c_char; + pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char; + pub fn strncat(s: *mut c_char, ct: *const c_char, + n: size_t) -> *mut c_char; + pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strncmp(cs: *const c_char, ct: *const c_char, n: size_t) -> c_int; + pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strdup(cs: *const c_char) -> *mut c_char; + pub fn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn strlen(cs: *const c_char) -> size_t; + pub fn strnlen(cs: *const c_char, maxlen: size_t) -> size_t; + pub fn strerror(n: c_int) -> *mut c_char; + pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char; + pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t; + pub fn wcslen(buf: *const wchar_t) -> size_t; + pub fn wcstombs(dest: *mut c_char, src: *const wchar_t, + n: size_t) -> ::size_t; + + pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; + pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int; + pub fn memcpy(dest: *mut c_void, src: *const c_void, + n: size_t) -> *mut c_void; + pub fn memmove(dest: *mut c_void, src: *const c_void, + n: size_t) -> *mut c_void; + pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void; + + pub fn abs(i: c_int) -> c_int; + pub fn atof(s: *const c_char) -> c_double; + pub fn labs(i: c_long) -> c_long; + pub fn rand() -> c_int; + pub fn srand(seed: c_uint); + pub fn getpwnam(name: *const ::c_char) -> *mut passwd; pub fn getpwuid(uid: ::uid_t) -> *mut passwd; @@ -3115,6 +3285,7 @@ extern { -> ::ssize_t; pub fn rmdir(path: *const c_char) -> ::c_int; pub fn seteuid(uid: uid_t) -> ::c_int; + pub fn setegid(gid: gid_t) -> ::c_int; pub fn setgid(gid: gid_t) -> ::c_int; pub fn setpgid(pid: pid_t, pgid: pid_t) -> ::c_int; pub fn setsid() -> pid_t; @@ -3791,6 +3962,8 @@ extern { pub fn sched_rr_get_interval(pid: ::pid_t, tp: *mut ::timespec) -> ::c_int; pub fn sem_timedwait(sem: *mut sem_t, abstime: *const ::timespec) -> ::c_int; + pub fn sem_getvalue(sem: *mut sem_t, + sval: *mut ::c_int) -> ::c_int; pub fn sched_setparam(pid: ::pid_t, param: *const ::sched_param) -> ::c_int; pub fn setns(fd: ::c_int, nstype: ::c_int) -> ::c_int; pub fn swapoff(puath: *const ::c_char) -> ::c_int; @@ -3908,9 +4081,6 @@ cfg_if! { if #[cfg(target_arch = "aarch64")] { mod aarch64; pub use self::aarch64::*; - } else if #[cfg(any(target_arch = "powerpc64"))] { - mod powerpc64; - pub use self::powerpc64::*; } else if #[cfg(any(target_arch = "x86_64"))] { mod x86_64; pub use self::x86_64::*; @@ -3918,3 +4088,21 @@ cfg_if! { // Unknown target_arch } } + +cfg_if! { + if #[cfg(core_cvoid)] { + pub use core::ffi::c_void; + } else { + // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help + // enable more optimization opportunities around it recognizing things + // like malloc/free. + #[repr(u8)] + pub enum c_void { + // Two dummy variants so the #[repr] attribute can be used. + #[doc(hidden)] + __variant1, + #[doc(hidden)] + __variant2, + } + } +} diff --git a/libc/src/fuchsia/powerpc64.rs b/libc/src/fuchsia/powerpc64.rs deleted file mode 100644 index 112cd43..0000000 --- a/libc/src/fuchsia/powerpc64.rs +++ /dev/null @@ -1,79 +0,0 @@ -pub type c_char = u8; -pub type wchar_t = i32; -pub type __u64 = ::c_ulong; -pub type nlink_t = u64; -pub type blksize_t = ::c_long; - -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], - } - - pub struct stat64 { - pub st_dev: ::dev_t, - pub st_ino: ::ino64_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: ::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, - __reserved: [::c_long; 3], - } - - 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_int, - __unused1: ::c_long, - __unused2: ::c_long - } -} - -pub const SYS_pivot_root: ::c_long = 203; -pub const SYS_gettid: ::c_long = 207; -pub const SYS_perf_event_open: ::c_long = 319; -pub const SYS_memfd_create: ::c_long = 360; - -pub const MAP_32BIT: ::c_int = 0x0040; - -pub const SIGSTKSZ: ::size_t = 8192; -pub const MINSIGSTKSZ: ::size_t = 2048; - -#[doc(hidden)] -pub const AF_MAX: ::c_int = 42; -#[doc(hidden)] -pub const PF_MAX: ::c_int = AF_MAX; - -// Syscall table -pub const SYS_renameat2: ::c_long = 357; diff --git a/libc/src/lib.rs b/libc/src/lib.rs index 1c374bf..03e7804 100644 --- a/libc/src/lib.rs +++ b/libc/src/lib.rs @@ -13,271 +13,166 @@ #![allow(bad_style, overflowing_literals, improper_ctypes)] #![crate_type = "rlib"] #![crate_name = "libc"] -#![cfg_attr(dox, feature(no_core, lang_items))] -#![cfg_attr(dox, no_core)] -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico")] - -#![cfg_attr(all(target_os = "linux", target_arch = "x86_64"), doc( - html_root_url = "https://doc.rust-lang.org/libc/x86_64-unknown-linux-gnu" -))] -#![cfg_attr(all(target_os = "linux", target_arch = "x86"), doc( - html_root_url = "https://doc.rust-lang.org/libc/i686-unknown-linux-gnu" -))] -#![cfg_attr(all(target_os = "linux", target_arch = "arm"), doc( - html_root_url = "https://doc.rust-lang.org/libc/arm-unknown-linux-gnueabihf" -))] -#![cfg_attr(all(target_os = "linux", target_arch = "mips"), doc( - html_root_url = "https://doc.rust-lang.org/libc/mips-unknown-linux-gnu" -))] -#![cfg_attr(all(target_os = "linux", target_arch = "aarch64"), doc( - html_root_url = "https://doc.rust-lang.org/libc/aarch64-unknown-linux-gnu" -))] -#![cfg_attr(all(target_os = "linux", target_env = "musl"), doc( - html_root_url = "https://doc.rust-lang.org/libc/x86_64-unknown-linux-musl" -))] -#![cfg_attr(all(target_os = "macos", target_arch = "x86_64"), doc( - html_root_url = "https://doc.rust-lang.org/libc/x86_64-apple-darwin" -))] -#![cfg_attr(all(target_os = "macos", target_arch = "x86"), doc( - html_root_url = "https://doc.rust-lang.org/libc/i686-apple-darwin" -))] -#![cfg_attr(all(windows, target_arch = "x86_64", target_env = "gnu"), doc( - html_root_url = "https://doc.rust-lang.org/libc/x86_64-pc-windows-gnu" -))] -#![cfg_attr(all(windows, target_arch = "x86", target_env = "gnu"), doc( - html_root_url = "https://doc.rust-lang.org/libc/i686-pc-windows-gnu" -))] -#![cfg_attr(all(windows, target_arch = "x86_64", target_env = "msvc"), doc( - html_root_url = "https://doc.rust-lang.org/libc/x86_64-pc-windows-msvc" -))] -#![cfg_attr(all(windows, target_arch = "x86", target_env = "msvc"), doc( - html_root_url = "https://doc.rust-lang.org/libc/i686-pc-windows-msvc" -))] -#![cfg_attr(target_os = "android", doc( - html_root_url = "https://doc.rust-lang.org/libc/arm-linux-androideabi" -))] -#![cfg_attr(target_os = "freebsd", doc( - html_root_url = "https://doc.rust-lang.org/libc/x86_64-unknown-freebsd" -))] -#![cfg_attr(target_os = "openbsd", doc( - html_root_url = "https://doc.rust-lang.org/libc/x86_64-unknown-openbsd" -))] -#![cfg_attr(target_os = "bitrig", doc( - html_root_url = "https://doc.rust-lang.org/libc/x86_64-unknown-bitrig" -))] -#![cfg_attr(target_os = "netbsd", doc( - html_root_url = "https://doc.rust-lang.org/libc/x86_64-unknown-netbsd" -))] -#![cfg_attr(target_os = "dragonfly", doc( - html_root_url = "https://doc.rust-lang.org/libc/x86_64-unknown-dragonfly" -))] -#![cfg_attr(all(target_os = "emscripten", target_arch = "asmjs"), doc( - html_root_url = "https://doc.rust-lang.org/libc/asmjs-unknown-emscripten" -))] -#![cfg_attr(all(target_os = "emscripten", target_arch = "wasm32"), doc( - html_root_url = "https://doc.rust-lang.org/libc/wasm32-unknown-emscripten" -))] -#![cfg_attr(all(target_os = "linux", target_arch = "xparc64"), doc( - html_root_url = "https://doc.rust-lang.org/libc/sparc64-unknown-linux-gnu" -))] - +#![cfg_attr(cross_platform_docs, feature(no_core, lang_items, const_fn))] +#![cfg_attr(cross_platform_docs, no_core)] +#![doc( + html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", + html_favicon_url = "https://doc.rust-lang.org/favicon.ico" +)] +#![cfg_attr( + all(target_os = "linux", target_arch = "x86_64"), + doc( + html_root_url = "https://rust-lang.github.io/libc/x86_64-unknown-linux-gnu" + ) +)] +#![cfg_attr( + all(target_os = "linux", target_arch = "x86"), + doc( + html_root_url = "https://rust-lang.github.io/libc/i686-unknown-linux-gnu" + ) +)] +#![cfg_attr( + all(target_os = "linux", target_arch = "arm"), + doc( + html_root_url = "https://rust-lang.github.io/libc/arm-unknown-linux-gnueabihf" + ) +)] +#![cfg_attr( + all(target_os = "linux", target_arch = "mips"), + doc( + html_root_url = "https://rust-lang.github.io/libc/mips-unknown-linux-gnu" + ) +)] +#![cfg_attr( + all(target_os = "linux", target_arch = "aarch64"), + doc( + html_root_url = "https://rust-lang.github.io/libc/aarch64-unknown-linux-gnu" + ) +)] +#![cfg_attr( + all(target_os = "linux", target_env = "musl"), + doc( + html_root_url = "https://rust-lang.github.io/libc/x86_64-unknown-linux-musl" + ) +)] +#![cfg_attr( + all(target_os = "macos", target_arch = "x86_64"), + doc( + html_root_url = "https://rust-lang.github.io/libc/x86_64-apple-darwin" + ) +)] +#![cfg_attr( + all(target_os = "macos", target_arch = "x86"), + doc(html_root_url = "https://rust-lang.github.io/libc/i686-apple-darwin") +)] +#![cfg_attr( + all(windows, target_arch = "x86_64", target_env = "gnu"), + doc( + html_root_url = "https://rust-lang.github.io/libc/x86_64-pc-windows-gnu" + ) +)] +#![cfg_attr( + all(windows, target_arch = "x86", target_env = "gnu"), + doc( + html_root_url = "https://rust-lang.github.io/libc/i686-pc-windows-gnu" + ) +)] +#![cfg_attr( + all(windows, target_arch = "x86_64", target_env = "msvc"), + doc( + html_root_url = "https://rust-lang.github.io/libc/x86_64-pc-windows-msvc" + ) +)] +#![cfg_attr( + all(windows, target_arch = "x86", target_env = "msvc"), + doc( + html_root_url = "https://rust-lang.github.io/libc/i686-pc-windows-msvc" + ) +)] +#![cfg_attr( + target_os = "android", + doc( + html_root_url = "https://rust-lang.github.io/libc/arm-linux-androideabi" + ) +)] +#![cfg_attr( + target_os = "freebsd", + doc( + html_root_url = "https://rust-lang.github.io/libc/x86_64-unknown-freebsd" + ) +)] +#![cfg_attr( + target_os = "openbsd", + doc( + html_root_url = "https://rust-lang.github.io/libc/x86_64-unknown-openbsd" + ) +)] +#![cfg_attr( + target_os = "bitrig", + doc( + html_root_url = "https://rust-lang.github.io/libc/x86_64-unknown-bitrig" + ) +)] +#![cfg_attr( + target_os = "netbsd", + doc( + html_root_url = "https://rust-lang.github.io/libc/x86_64-unknown-netbsd" + ) +)] +#![cfg_attr( + target_os = "dragonfly", + doc( + html_root_url = "https://rust-lang.github.io/libc/x86_64-unknown-dragonfly" + ) +)] +#![cfg_attr( + target_os = "solaris", + doc( + html_root_url = "https://rust-lang.github.io/libc/x86_64-sun-solaris" + ) +)] +#![cfg_attr( + all(target_os = "emscripten", target_arch = "asmjs"), + doc( + html_root_url = "https://rust-lang.github.io/libc/asmjs-unknown-emscripten" + ) +)] +#![cfg_attr( + all(target_os = "emscripten", target_arch = "wasm32"), + doc( + html_root_url = "https://rust-lang.github.io/libc/wasm32-unknown-emscripten" + ) +)] +#![cfg_attr( + all(target_os = "linux", target_arch = "sparc64"), + doc( + html_root_url = "https://rust-lang.github.io/libc/sparc64-unknown-linux-gnu" + ) +)] // Attributes needed when building as part of the standard library -#![cfg_attr(feature = "stdbuild", feature(no_std, staged_api, custom_attribute, cfg_target_vendor))] -#![cfg_attr(feature = "stdbuild", feature(link_cfg))] -#![cfg_attr(feature = "stdbuild", no_std)] -#![cfg_attr(feature = "stdbuild", staged_api)] -#![cfg_attr(feature = "stdbuild", allow(warnings))] -#![cfg_attr(feature = "stdbuild", unstable(feature = "libc", - reason = "use `libc` from crates.io", - issue = "27783"))] - -#![cfg_attr(not(feature = "use_std"), no_std)] - -#[cfg(all(not(dox), feature = "use_std"))] +#![cfg_attr(feature = "rustc-dep-of-std", feature(cfg_target_vendor))] +#![cfg_attr(feature = "rustc-dep-of-std", feature(link_cfg, repr_packed))] +#![cfg_attr(feature = "rustc-dep-of-std", feature(no_core))] +#![cfg_attr(feature = "rustc-dep-of-std", no_core)] +#![cfg_attr(feature = "rustc-dep-of-std", allow(warnings))] +#![cfg_attr(not(any(feature = "use_std", feature = "rustc-dep-of-std")), no_std)] + +#[cfg(all(not(cross_platform_docs), feature = "use_std"))] extern crate std as core; -#[macro_use] mod macros; -mod dox; - -cfg_if! { - if #[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))] { - // empty ... - } else { - - // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help enable - // more optimization opportunities around it recognizing things like - // malloc/free. - #[repr(u8)] - pub enum c_void { - // Two dummy variants so the #[repr] attribute can be used. - #[doc(hidden)] - __variant1, - #[doc(hidden)] - __variant2, - } - - pub type int8_t = i8; - pub type int16_t = i16; - pub type int32_t = i32; - pub type int64_t = i64; - pub type uint8_t = u8; - pub type uint16_t = u16; - pub type uint32_t = u32; - pub type uint64_t = u64; +#[cfg(feature = "rustc-dep-of-std")] +extern crate rustc_std_workspace_core as core; +#[cfg(feature = "rustc-dep-of-std")] +#[allow(unused_imports)] +use core::iter; +#[cfg(feature = "rustc-dep-of-std")] +#[allow(unused_imports)] +use core::option; - pub type c_schar = i8; - pub type c_uchar = u8; - pub type c_short = i16; - pub type c_ushort = u16; - pub type c_int = i32; - pub type c_uint = u32; - pub type c_float = f32; - pub type c_double = f64; - pub type c_longlong = i64; - pub type c_ulonglong = u64; - pub type intmax_t = i64; - pub type uintmax_t = u64; +#[macro_use] +mod macros; - pub type size_t = usize; - pub type ptrdiff_t = isize; - pub type intptr_t = isize; - pub type uintptr_t = usize; - pub type ssize_t = isize; - - pub enum FILE {} - pub enum fpos_t {} // TODO: fill this out with a struct - - extern { - pub fn isalnum(c: c_int) -> c_int; - pub fn isalpha(c: c_int) -> c_int; - pub fn iscntrl(c: c_int) -> c_int; - pub fn isdigit(c: c_int) -> c_int; - pub fn isgraph(c: c_int) -> c_int; - pub fn islower(c: c_int) -> c_int; - pub fn isprint(c: c_int) -> c_int; - pub fn ispunct(c: c_int) -> c_int; - pub fn isspace(c: c_int) -> c_int; - pub fn isupper(c: c_int) -> c_int; - pub fn isxdigit(c: c_int) -> c_int; - pub fn tolower(c: c_int) -> c_int; - pub fn toupper(c: c_int) -> c_int; - - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "fopen$UNIX2003")] - pub fn fopen(filename: *const c_char, - mode: *const c_char) -> *mut FILE; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "freopen$UNIX2003")] - pub fn freopen(filename: *const c_char, mode: *const c_char, - file: *mut FILE) -> *mut FILE; - pub fn fflush(file: *mut FILE) -> c_int; - pub fn fclose(file: *mut FILE) -> c_int; - pub fn remove(filename: *const c_char) -> c_int; - pub fn rename(oldname: *const c_char, newname: *const c_char) -> c_int; - pub fn tmpfile() -> *mut FILE; - pub fn setvbuf(stream: *mut FILE, - buffer: *mut c_char, - mode: c_int, - size: size_t) -> c_int; - pub fn setbuf(stream: *mut FILE, buf: *mut c_char); - pub fn getchar() -> c_int; - pub fn putchar(c: c_int) -> c_int; - pub fn fgetc(stream: *mut FILE) -> c_int; - pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char; - pub fn fputc(c: c_int, stream: *mut FILE) -> c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "fputs$UNIX2003")] - pub fn fputs(s: *const c_char, stream: *mut FILE)-> c_int; - pub fn puts(s: *const c_char) -> c_int; - pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int; - pub fn fread(ptr: *mut c_void, - size: size_t, - nobj: size_t, - stream: *mut FILE) - -> size_t; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "fwrite$UNIX2003")] - pub fn fwrite(ptr: *const c_void, - size: size_t, - nobj: size_t, - stream: *mut FILE) - -> size_t; - pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int; - pub fn ftell(stream: *mut FILE) -> c_long; - pub fn rewind(stream: *mut FILE); - #[cfg_attr(target_os = "netbsd", link_name = "__fgetpos50")] - pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int; - #[cfg_attr(target_os = "netbsd", link_name = "__fsetpos50")] - pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int; - pub fn feof(stream: *mut FILE) -> c_int; - pub fn ferror(stream: *mut FILE) -> c_int; - pub fn perror(s: *const c_char); - pub fn atoi(s: *const c_char) -> c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "strtod$UNIX2003")] - pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double; - pub fn strtol(s: *const c_char, - endp: *mut *mut c_char, base: c_int) -> c_long; - pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, - base: c_int) -> c_ulong; - pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; - pub fn malloc(size: size_t) -> *mut c_void; - pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; - pub fn free(p: *mut c_void); - pub fn abort() -> !; - pub fn exit(status: c_int) -> !; - pub fn _exit(status: c_int) -> !; - pub fn atexit(cb: extern fn()) -> c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "system$UNIX2003")] - pub fn system(s: *const c_char) -> c_int; - pub fn getenv(s: *const c_char) -> *mut c_char; - - pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char; - pub fn strncpy(dst: *mut c_char, src: *const c_char, n: size_t) - -> *mut c_char; - pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char; - pub fn strncat(s: *mut c_char, ct: *const c_char, n: size_t) -> *mut c_char; - pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int; - pub fn strncmp(cs: *const c_char, ct: *const c_char, n: size_t) -> c_int; - pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int; - pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char; - pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char; - pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t; - pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t; - pub fn strdup(cs: *const c_char) -> *mut c_char; - pub fn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char; - pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char; - pub fn strlen(cs: *const c_char) -> size_t; - pub fn strnlen(cs: *const c_char, maxlen: size_t) -> size_t; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "strerror$UNIX2003")] - pub fn strerror(n: c_int) -> *mut c_char; - pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char; - pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t; - pub fn wcslen(buf: *const wchar_t) -> size_t; - pub fn wcstombs(dest: *mut c_char, src: *const wchar_t, n: size_t) -> ::size_t; - - pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; - pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int; - pub fn memcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; - pub fn memmove(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; - pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void; - } - - // These are all inline functions on android, so they end up just being entirely - // missing on that platform. - #[cfg(not(target_os = "android"))] - extern { - pub fn abs(i: c_int) -> c_int; - pub fn atof(s: *const c_char) -> c_double; - pub fn labs(i: c_long) -> c_long; - pub fn rand() -> c_int; - pub fn srand(seed: c_uint); - } - } -} +mod dox; cfg_if! { if #[cfg(windows)] { @@ -292,10 +187,16 @@ cfg_if! { } else if #[cfg(target_os = "fuchsia")] { mod fuchsia; pub use fuchsia::*; + } else if #[cfg(target_os = "switch")] { + mod switch; + pub use switch::*; } else if #[cfg(unix)] { mod unix; pub use unix::*; - } else { - // Unknown target_family + } else if #[cfg(target_env = "sgx")] { + mod sgx; + pub use sgx::*; + } else { + // non-supported targets: empty... } } diff --git a/libc/src/macros.rs b/libc/src/macros.rs index 8429442..7720578 100644 --- a/libc/src/macros.rs +++ b/libc/src/macros.rs @@ -35,11 +35,11 @@ macro_rules! __cfg_if_apply { } macro_rules! s { - ($($(#[$attr:meta])* pub struct $i:ident { $($field:tt)* })*) => ($( + ($($(#[$attr:meta])* pub $t:ident $i:ident { $($field:tt)* })*) => ($( __item! { #[repr(C)] $(#[$attr])* - pub struct $i { $($field)* } + pub $t $i { $($field)* } } impl ::dox::Copy for $i {} impl ::dox::Clone for $i { @@ -48,17 +48,18 @@ macro_rules! s { )*) } +#[allow(unused_macros)] macro_rules! f { ($(pub fn $i:ident($($arg:ident: $argty:ty),*) -> $ret:ty { $($body:stmt);* })*) => ($( #[inline] - #[cfg(not(dox))] + #[cfg(not(cross_platform_docs))] pub unsafe extern fn $i($($arg: $argty),*) -> $ret { $($body);* } - #[cfg(dox)] + #[cfg(cross_platform_docs)] #[allow(dead_code)] pub unsafe extern fn $i($($arg: $argty),*) -> $ret { loop {} @@ -67,5 +68,24 @@ macro_rules! f { } macro_rules! __item { - ($i:item) => ($i) + ($i:item) => { + $i + }; +} + +#[allow(unused_macros)] +macro_rules! align_const { + ($($(#[$attr:meta])* pub const $name:ident : $t1:ty = $t2:ident { $($field:tt)* };)*) => ($( + #[cfg(feature = "align")] + $(#[$attr])* + pub const $name : $t1 = $t2 { + $($field)* + }; + #[cfg(not(feature = "align"))] + $(#[$attr])* + pub const $name : $t1 = $t2 { + $($field)* + __align: [], + }; + )*) } diff --git a/libc/src/redox/mod.rs b/libc/src/redox/mod.rs index 82b296f..9f68632 100644 --- a/libc/src/redox/mod.rs +++ b/libc/src/redox/mod.rs @@ -1,3 +1,32 @@ + +pub type int8_t = i8; +pub type int16_t = i16; +pub type int32_t = i32; +pub type int64_t = i64; +pub type uint8_t = u8; +pub type uint16_t = u16; +pub type uint32_t = u32; +pub type uint64_t = u64; + +pub type c_schar = i8; +pub type c_uchar = u8; +pub type c_short = i16; +pub type c_ushort = u16; +pub type c_int = i32; +pub type c_uint = u32; +pub type c_float = f32; +pub type c_double = f64; +pub type c_longlong = i64; +pub type c_ulonglong = u64; +pub type intmax_t = i64; +pub type uintmax_t = u64; + +pub type size_t = usize; +pub type ptrdiff_t = isize; +pub type intptr_t = isize; +pub type uintptr_t = usize; +pub type ssize_t = isize; + pub type c_char = i8; pub type c_long = i64; pub type c_ulong = u64; @@ -25,6 +54,9 @@ s! { } } +pub const INT_MIN: c_int = -2147483648; +pub const INT_MAX: c_int = 2147483647; + pub const STDIN_FILENO: ::c_int = 0; pub const STDOUT_FILENO: ::c_int = 1; pub const STDERR_FILENO: ::c_int = 2; @@ -85,14 +117,160 @@ pub const O_SYMLINK: ::c_int = 0x4000_0000; pub const O_NOFOLLOW: ::c_int = 0x8000_0000; pub const O_ACCMODE: ::c_int = O_RDONLY | O_WRONLY | O_RDWR; +pub const SIGHUP: ::c_int = 1; +pub const SIGINT: ::c_int = 2; +pub const SIGQUIT: ::c_int = 3; +pub const SIGILL: ::c_int = 4; +pub const SIGTRAP: ::c_int = 5; +pub const SIGABRT: ::c_int = 6; +pub const SIGBUS: ::c_int = 7; +pub const SIGFPE: ::c_int = 8; +pub const SIGKILL: ::c_int = 9; +pub const SIGUSR1: ::c_int = 10; +pub const SIGSEGV: ::c_int = 11; +pub const SIGUSR2: ::c_int = 12; +pub const SIGPIPE: ::c_int = 13; +pub const SIGALRM: ::c_int = 14; +pub const SIGTERM: ::c_int = 15; +pub const SIGSTKFLT: ::c_int = 16; +pub const SIGCHLD: ::c_int = 17; +pub const SIGCONT: ::c_int = 18; +pub const SIGSTOP: ::c_int = 19; +pub const SIGTSTP: ::c_int = 20; +pub const SIGTTIN: ::c_int = 21; +pub const SIGTTOU: ::c_int = 22; +pub const SIGURG: ::c_int = 23; +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 SIGIO: ::c_int = 29; +pub const SIGPWR: ::c_int = 30; +pub const SIGSYS: ::c_int = 31; + +pub enum FILE {} +pub enum fpos_t {} // TODO: fill this out with a struct + extern { + pub fn isalnum(c: c_int) -> c_int; + pub fn isalpha(c: c_int) -> c_int; + pub fn iscntrl(c: c_int) -> c_int; + pub fn isdigit(c: c_int) -> c_int; + pub fn isgraph(c: c_int) -> c_int; + pub fn islower(c: c_int) -> c_int; + pub fn isprint(c: c_int) -> c_int; + pub fn ispunct(c: c_int) -> c_int; + pub fn isspace(c: c_int) -> c_int; + pub fn isupper(c: c_int) -> c_int; + pub fn isxdigit(c: c_int) -> c_int; + pub fn tolower(c: c_int) -> c_int; + pub fn toupper(c: c_int) -> c_int; + pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE; + pub fn freopen(filename: *const c_char, mode: *const c_char, + file: *mut FILE) -> *mut FILE; + pub fn fflush(file: *mut FILE) -> c_int; + pub fn fclose(file: *mut FILE) -> c_int; + pub fn remove(filename: *const c_char) -> c_int; + pub fn rename(oldname: *const c_char, newname: *const c_char) -> c_int; + pub fn tmpfile() -> *mut FILE; + pub fn setvbuf(stream: *mut FILE, buffer: *mut c_char, mode: c_int, + size: size_t) -> c_int; + pub fn setbuf(stream: *mut FILE, buf: *mut c_char); + pub fn getchar() -> c_int; + pub fn putchar(c: c_int) -> c_int; + pub fn fgetc(stream: *mut FILE) -> c_int; + pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char; + pub fn fputc(c: c_int, stream: *mut FILE) -> c_int; + pub fn fputs(s: *const c_char, stream: *mut FILE) -> c_int; + pub fn puts(s: *const c_char) -> c_int; + pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int; + pub fn fread(ptr: *mut c_void, size: size_t, nobj: size_t, + stream: *mut FILE) -> size_t; + pub fn fwrite(ptr: *const c_void, size: size_t, nobj: size_t, + stream: *mut FILE) -> size_t; + pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int; + pub fn ftell(stream: *mut FILE) -> c_long; + pub fn rewind(stream: *mut FILE); + pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int; + pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int; + pub fn feof(stream: *mut FILE) -> c_int; + pub fn ferror(stream: *mut FILE) -> c_int; + pub fn perror(s: *const c_char); + pub fn atoi(s: *const c_char) -> c_int; + pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double; + pub fn strtol(s: *const c_char, endp: *mut *mut c_char, + base: c_int) -> c_long; + pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, + base: c_int) -> c_ulong; + pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; + pub fn malloc(size: size_t) -> *mut c_void; + pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; + pub fn free(p: *mut c_void); + pub fn abort() -> !; + pub fn exit(status: c_int) -> !; + pub fn _exit(status: c_int) -> !; + pub fn atexit(cb: extern fn()) -> c_int; + pub fn system(s: *const c_char) -> c_int; + pub fn getenv(s: *const c_char) -> *mut c_char; + + pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char; + pub fn strncpy(dst: *mut c_char, src: *const c_char, + n: size_t) -> *mut c_char; + pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char; + pub fn strncat(s: *mut c_char, ct: *const c_char, + n: size_t) -> *mut c_char; + pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strncmp(cs: *const c_char, ct: *const c_char, + n: size_t) -> c_int; + pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strdup(cs: *const c_char) -> *mut c_char; + pub fn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn strcasestr(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn strcasecmp(s1: *const c_char, s2: *const c_char) -> c_int; + pub fn strncasecmp(s1: *const c_char, s2: *const c_char, + n: size_t) -> c_int; + pub fn strlen(cs: *const c_char) -> size_t; + pub fn strnlen(cs: *const c_char, maxlen: size_t) -> size_t; + pub fn strerror(n: c_int) -> *mut c_char; + pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char; + pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t; + pub fn wcslen(buf: *const wchar_t) -> size_t; + pub fn wcstombs(dest: *mut c_char, src: *const wchar_t, + n: size_t) -> ::size_t; + + pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; + pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int; + pub fn memcpy(dest: *mut c_void, src: *const c_void, + n: size_t) -> *mut c_void; + pub fn memmove(dest: *mut c_void, src: *const c_void, + n: size_t) -> *mut c_void; + pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void; + + pub fn abs(i: c_int) -> c_int; + pub fn atof(s: *const c_char) -> c_double; + pub fn labs(i: c_long) -> c_long; + pub fn rand() -> c_int; + pub fn srand(seed: c_uint); + + pub fn chown(path: *const c_char, uid: uid_t, gid: gid_t) -> ::c_int; + pub fn close(fd: ::c_int) -> ::c_int; + pub fn fchown(fd: ::c_int, uid: ::uid_t, gid: ::gid_t) -> ::c_int; + pub fn fcntl(fd: ::c_int, cmd: ::c_int, ...) -> ::c_int; + pub fn gethostname(name: *mut ::c_char, len: ::size_t) -> ::c_int; + pub fn getpid() -> pid_t; pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void; - pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::size_t) - -> ::ssize_t; + pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::size_t) -> ::ssize_t; + pub fn setenv(name: *const c_char, val: *const c_char, overwrite: ::c_int) + -> ::c_int; + pub fn unsetenv(name: *const c_char) -> ::c_int; pub fn write(fd: ::c_int, buf: *const ::c_void, count: ::size_t) -> ::ssize_t; - pub fn fcntl(fd: ::c_int, cmd: ::c_int, ...) -> ::c_int; - pub fn close(fd: ::c_int) -> ::c_int; } #[link(name = "c")] @@ -102,3 +280,21 @@ extern {} pub use self::net::*; mod net; + +cfg_if! { + if #[cfg(core_cvoid)] { + pub use core::ffi::c_void; + } else { + // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help + // enable more optimization opportunities around it recognizing things + // like malloc/free. + #[repr(u8)] + pub enum c_void { + // Two dummy variants so the #[repr] attribute can be used. + #[doc(hidden)] + __variant1, + #[doc(hidden)] + __variant2, + } + } +} diff --git a/libc/src/redox/net.rs b/libc/src/redox/net.rs index 0916916..fcbb181 100644 --- a/libc/src/redox/net.rs +++ b/libc/src/redox/net.rs @@ -9,8 +9,10 @@ s! { pub s_addr: in_addr_t, } + #[cfg_attr(feature = "align", repr(align(4)))] pub struct in6_addr { pub s6_addr: [u8; 16], + #[cfg(not(feature = "align"))] __align: [u32; 0], } @@ -107,4 +109,16 @@ extern { pub fn setsockopt(socket: ::c_int, level: ::c_int, name: ::c_int, value: *const ::c_void, option_len: socklen_t) -> ::c_int; + pub fn getpeername(socket: ::c_int, address: *mut sockaddr, + address_len: *mut socklen_t) -> ::c_int; + pub fn sendto(socket: ::c_int, buf: *const ::c_void, len: ::size_t, + flags: ::c_int, addr: *const sockaddr, + addrlen: socklen_t) -> ::ssize_t; + pub fn send(socket: ::c_int, buf: *const ::c_void, len: ::size_t, + flags: ::c_int) -> ::ssize_t; + pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, + flags: ::c_int, addr: *mut ::sockaddr, + addrlen: *mut ::socklen_t) -> ::ssize_t; + pub fn recv(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, + flags: ::c_int) -> ::ssize_t; } diff --git a/libc/src/sgx.rs b/libc/src/sgx.rs new file mode 100644 index 0000000..0451333 --- /dev/null +++ b/libc/src/sgx.rs @@ -0,0 +1,54 @@ +//! SGX C types definition + +pub type int8_t = i8; +pub type int16_t = i16; +pub type int32_t = i32; +pub type int64_t = i64; +pub type uint8_t = u8; +pub type uint16_t = u16; +pub type uint32_t = u32; +pub type uint64_t = u64; + +pub type c_schar = i8; +pub type c_uchar = u8; +pub type c_short = i16; +pub type c_ushort = u16; +pub type c_int = i32; +pub type c_uint = u32; +pub type c_float = f32; +pub type c_double = f64; +pub type c_longlong = i64; +pub type c_ulonglong = u64; +pub type intmax_t = i64; +pub type uintmax_t = u64; + +pub type size_t = usize; +pub type ptrdiff_t = isize; +pub type intptr_t = isize; +pub type uintptr_t = usize; +pub type ssize_t = isize; + +pub type c_char = i8; +pub type c_long = i64; +pub type c_ulong = u64; + +pub const INT_MIN: c_int = -2147483648; +pub const INT_MAX: c_int = 2147483647; + +cfg_if! { + if #[cfg(core_cvoid)] { + pub use core::ffi::c_void; + } else { + // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help + // enable more optimization opportunities around it recognizing things + // like malloc/free. + #[repr(u8)] + pub enum c_void { + // Two dummy variants so the #[repr] attribute can be used. + #[doc(hidden)] + __variant1, + #[doc(hidden)] + __variant2, + } + } +} diff --git a/libc/src/switch.rs b/libc/src/switch.rs new file mode 100644 index 0000000..e2d9b49 --- /dev/null +++ b/libc/src/switch.rs @@ -0,0 +1,57 @@ +//! Switch C type definitions + +pub type int8_t = i8; +pub type int16_t = i16; +pub type int32_t = i32; +pub type int64_t = i64; +pub type uint8_t = u8; +pub type uint16_t = u16; +pub type uint32_t = u32; +pub type uint64_t = u64; + +pub type c_schar = i8; +pub type c_uchar = u8; +pub type c_short = i16; +pub type c_ushort = u16; +pub type c_int = i32; +pub type c_uint = u32; +pub type c_float = f32; +pub type c_double = f64; +pub type c_longlong = i64; +pub type c_ulonglong = u64; +pub type intmax_t = i64; +pub type uintmax_t = u64; + +pub type size_t = usize; +pub type ptrdiff_t = isize; +pub type intptr_t = isize; +pub type uintptr_t = usize; +pub type ssize_t = isize; + +pub type off_t = i64; +pub type c_char = u8; +pub type c_long = i64; +pub type c_ulong = u64; +pub type wchar_t = u32; + +pub const INT_MIN: c_int = -2147483648; +pub const INT_MAX: c_int = 2147483647; + +cfg_if! { + if #[cfg(core_cvoid)] { + pub use core::ffi::c_void; + } else { + // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help + // enable more optimization opportunities around it recognizing things + // like malloc/free. + #[repr(u8)] + pub enum c_void { + // Two dummy variants so the #[repr] attribute can be used. + #[doc(hidden)] + __variant1, + #[doc(hidden)] + __variant2, + } + } +} + diff --git a/libc/src/unix/bsd/apple/b32.rs b/libc/src/unix/bsd/apple/b32.rs index 5dea472..907ab02 100644 --- a/libc/src/unix/bsd/apple/b32.rs +++ b/libc/src/unix/bsd/apple/b32.rs @@ -58,3 +58,9 @@ pub const __PTHREAD_RWLOCKATTR_SIZE__: usize = 12; pub const TIOCTIMESTAMP: ::c_ulong = 0x40087459; pub const TIOCDCDTIMESTAMP: ::c_ulong = 0x40087458; + +extern { + pub fn exchangedata(path1: *const ::c_char, + path2: *const ::c_char, + options: ::c_ulong) -> ::c_int; +} diff --git a/libc/src/unix/bsd/apple/b64.rs b/libc/src/unix/bsd/apple/b64.rs index 2b34f85..8e8c87d 100644 --- a/libc/src/unix/bsd/apple/b64.rs +++ b/libc/src/unix/bsd/apple/b64.rs @@ -64,4 +64,8 @@ pub const __PTHREAD_RWLOCKATTR_SIZE__: usize = 16; pub const TIOCTIMESTAMP: ::c_ulong = 0x40107459; pub const TIOCDCDTIMESTAMP: ::c_ulong = 0x40107458; -pub const FIONREAD: ::c_ulong = 0x4004667f; +extern { + pub fn exchangedata(path1: *const ::c_char, + path2: *const ::c_char, + options: ::c_uint) -> ::c_int; +} diff --git a/libc/src/unix/bsd/apple/mod.rs b/libc/src/unix/bsd/apple/mod.rs index 7281f91..bb07cc4 100644 --- a/libc/src/unix/bsd/apple/mod.rs +++ b/libc/src/unix/bsd/apple/mod.rs @@ -28,6 +28,10 @@ pub type integer_t = ::c_int; pub type cpu_type_t = integer_t; pub type cpu_subtype_t = integer_t; pub type vm_prot_t = ::c_int; +pub type posix_spawnattr_t = *mut ::c_void; +pub type posix_spawn_file_actions_t = *mut ::c_void; +pub type key_t = ::c_int; +pub type shmatt_t = ::c_ushort; pub enum timezone {} @@ -241,7 +245,7 @@ s! { pub f_reserved: [::uint32_t; 8], } - // FIXME: this should have align 4 but it's got align 8 on 64-bit + #[cfg_attr(feature = "rustc-dep-of-std", repr(packed(4)))] pub struct kevent { pub ident: ::uintptr_t, pub filter: ::int16_t, @@ -498,6 +502,90 @@ s! { pub sin_tos: ::c_ushort, pub sin_other: ::c_ushort, } + + pub struct sockaddr_ctl { + pub sc_len: ::c_uchar, + pub sc_family: ::c_uchar, + pub ss_sysaddr: ::uint16_t, + pub sc_id: ::uint32_t, + pub sc_unit: ::uint32_t, + pub sc_reserved: [::uint32_t; 5], + } + + pub struct in_pktinfo { + pub ipi_ifindex: ::c_uint, + pub ipi_spec_dst: ::in_addr, + pub ipi_addr: ::in_addr, + } + + pub struct in6_pktinfo { + pub ipi6_addr: ::in6_addr, + pub ipi6_ifindex: ::c_uint, + } + + // sys/ipc.h: + + pub struct ipc_perm { + pub uid: ::uid_t, + pub gid: ::gid_t, + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub mode: ::mode_t, + pub _seq: ::c_ushort, + pub _key: ::key_t, + } + + // sys/sem.h + + pub struct sembuf { + pub sem_num: ::c_ushort, + pub sem_op: ::c_short, + pub sem_flg: ::c_short, + } + + #[cfg_attr(feature = "rustc-dep-of-std", repr(packed(4)))] + pub struct semid_ds { + // Note the manpage shows different types than the system header. + pub sem_perm: ipc_perm, + pub sem_base: ::int32_t, + pub sem_nsems: ::c_ushort, + pub sem_otime: ::time_t, + pub sem_pad1: ::int32_t, + pub sem_ctime: ::time_t, + pub sem_pad2: ::int32_t, + pub sem_pad3: [::int32_t; 4], + } + + pub union semun { + pub val: ::c_int, + pub buf: *mut semid_ds, + pub array: *mut ::c_ushort, + } + + // sys/shm.h + + #[cfg_attr(feature = "rustc-dep-of-std", repr(packed(4)))] + pub struct shmid_ds { + pub shm_perm: ipc_perm, + pub shm_segsz: ::size_t, + pub shm_lpid: ::pid_t, + pub shm_cpid: ::pid_t, + pub shm_nattch: ::shmatt_t, + pub shm_atime: ::time_t, // FIXME: 64-bit wrong align => wrong offset + pub shm_dtime: ::time_t, // FIXME: 64-bit wrong align => wrong offset + pub shm_ctime: ::time_t, // FIXME: 64-bit wrong align => wrong offset + // FIXME: 64-bit wrong align => wrong offset: + pub shm_internal: *mut ::c_void, + + } + + pub struct arphdr { + pub ar_hrd: u16, + pub ar_pro: u16, + pub ar_hln: u8, + pub ar_pln: u8, + pub ar_op: u16, + } } pub const _UTX_USERSIZE: usize = 256; @@ -688,11 +776,32 @@ pub const PROT_READ: ::c_int = 1; pub const PROT_WRITE: ::c_int = 2; pub const PROT_EXEC: ::c_int = 4; +pub const PT_TRACE_ME: ::c_int = 0; +pub const PT_READ_I: ::c_int = 1; +pub const PT_READ_D: ::c_int = 2; +pub const PT_READ_U: ::c_int = 3; +pub const PT_WRITE_I: ::c_int = 4; +pub const PT_WRITE_D: ::c_int = 5; +pub const PT_WRITE_U: ::c_int = 6; +pub const PT_CONTINUE: ::c_int = 7; +pub const PT_KILL: ::c_int = 8; +pub const PT_STEP: ::c_int = 9; +pub const PT_ATTACH: ::c_int = 10; +pub const PT_DETACH: ::c_int = 11; +pub const PT_SIGEXC: ::c_int = 12; +pub const PT_THUPDATE: ::c_int = 13; +pub const PT_ATTACHEXC: ::c_int = 14; + +pub const PT_FORCEQUOTA: ::c_int = 30; +pub const PT_DENY_ATTACH: ::c_int = 31; +pub const PT_FIRSTMACH: ::c_int = 32; + pub const MAP_FILE: ::c_int = 0x0000; pub const MAP_SHARED: ::c_int = 0x0001; pub const MAP_PRIVATE: ::c_int = 0x0002; pub const MAP_FIXED: ::c_int = 0x0010; pub const MAP_ANON: ::c_int = 0x1000; +pub const MAP_ANONYMOUS: ::c_int = MAP_ANON; pub const VM_FLAGS_FIXED: ::c_int = 0x0000; pub const VM_FLAGS_ANYWHERE: ::c_int = 0x0001; @@ -706,16 +815,8 @@ pub const VM_FLAGS_SUPERPAGE_MASK: ::c_int = 0x70000; pub const VM_FLAGS_RETURN_DATA_ADDR: ::c_int = 0x100000; pub const VM_FLAGS_RETURN_4K_DATA_ADDR: ::c_int = 0x800000; pub const VM_FLAGS_ALIAS_MASK: ::c_int = 0xFF000000; -pub const VM_FLAGS_USER_ALLOCATE: ::c_int = VM_FLAGS_FIXED | VM_FLAGS_ANYWHERE | - VM_FLAGS_PURGABLE | - VM_FLAGS_RANDOM_ADDR | - VM_FLAGS_NO_CACHE | - VM_FLAGS_OVERWRITE | - VM_FLAGS_SUPERPAGE_MASK | - VM_FLAGS_ALIAS_MASK; -pub const VM_FLAGS_USER_MAP: ::c_int = VM_FLAGS_USER_ALLOCATE | - VM_FLAGS_RETURN_4K_DATA_ADDR | - VM_FLAGS_RETURN_DATA_ADDR; +pub const VM_FLAGS_USER_ALLOCATE: ::c_int = 0xff07401f; +pub const VM_FLAGS_USER_MAP: ::c_int = 0xff97401f; pub const VM_FLAGS_USER_REMAP: ::c_int = VM_FLAGS_FIXED | VM_FLAGS_ANYWHERE | VM_FLAGS_RANDOM_ADDR | VM_FLAGS_OVERWRITE | @@ -1026,6 +1127,13 @@ pub const TIOCPTYGRANT: ::c_uint = 0x20007454; pub const TIOCPTYGNAME: ::c_uint = 0x40807453; pub const TIOCPTYUNLK: ::c_uint = 0x20007452; +pub const FIONCLEX: ::c_uint = 0x20006602; +pub const FIONREAD: ::c_ulong = 0x4004667f; +pub const FIOASYNC: ::c_ulong = 0x8004667d; +pub const FIOSETOWN: ::c_ulong = 0x8004667c; +pub const FIOGETOWN: ::c_ulong = 0x4004667b; +pub const FIODTYPE: ::c_ulong = 0x4004667a; + pub const B0: speed_t = 0; pub const B50: speed_t = 50; pub const B75: speed_t = 75; @@ -1100,6 +1208,7 @@ pub const _SC_XOPEN_SHM: ::c_int = 113; pub const _SC_XOPEN_UNIX: ::c_int = 115; pub const _SC_XOPEN_VERSION: ::c_int = 116; pub const _SC_XOPEN_XCU_VERSION: ::c_int = 121; +pub const _SC_PHYS_PAGES: ::c_int = 200; pub const PTHREAD_PROCESS_PRIVATE: ::c_int = 2; pub const PTHREAD_PROCESS_SHARED: ::c_int = 1; @@ -1463,10 +1572,14 @@ pub const IP_TTL: ::c_int = 4; pub const IP_HDRINCL: ::c_int = 2; pub const IP_ADD_MEMBERSHIP: ::c_int = 12; pub const IP_DROP_MEMBERSHIP: ::c_int = 13; +pub const IP_PKTINFO: ::c_int = 26; pub const IPV6_JOIN_GROUP: ::c_int = 12; pub const IPV6_LEAVE_GROUP: ::c_int = 13; +pub const IPV6_PKTINFO: ::c_int = 46; +pub const IPV6_RECVPKTINFO: ::c_int = 61; -pub const TCP_NODELAY: ::c_int = 0x01; +pub const TCP_NOPUSH: ::c_int = 4; +pub const TCP_NOOPT: ::c_int = 8; pub const TCP_KEEPALIVE: ::c_int = 0x10; pub const SOL_LOCAL: ::c_int = 0; @@ -1805,6 +1918,9 @@ pub const NI_MAXHOST: ::socklen_t = 1025; pub const Q_GETQUOTA: ::c_int = 0x300; pub const Q_SETQUOTA: ::c_int = 0x400; +pub const RENAME_SWAP: ::c_uint = 0x00000002; +pub const RENAME_EXCL: ::c_uint = 0x00000004; + pub const RTLD_LOCAL: ::c_int = 0x4; pub const RTLD_FIRST: ::c_int = 0x100; pub const RTLD_NODELETE: ::c_int = 0x80; @@ -2187,6 +2303,61 @@ pub const DLT_LOOP: ::c_uint = 108; // sizeof(int32_t) pub const BPF_ALIGNMENT: ::c_int = 4; +// sys/spawn.h: +pub const POSIX_SPAWN_RESETIDS: ::c_int = 0x01; +pub const POSIX_SPAWN_SETPGROUP: ::c_int = 0x02; +pub const POSIX_SPAWN_SETSIGDEF: ::c_int = 0x04; +pub const POSIX_SPAWN_SETSIGMASK: ::c_int = 0x08; +pub const POSIX_SPAWN_SETEXEC: ::c_int = 0x40; +pub const POSIX_SPAWN_START_SUSPENDED: ::c_int = 0x80; +pub const POSIX_SPAWN_CLOEXEC_DEFAULT: ::c_int = 0x4000; + +// sys/ipc.h: +pub const IPC_CREAT: ::c_int = 0x200; +pub const IPC_EXCL: ::c_int = 0x400; +pub const IPC_NOWAIT: ::c_int = 0x800; +pub const IPC_PRIVATE: key_t = 0; + +pub const IPC_RMID: ::c_int = 0; +pub const IPC_SET: ::c_int = 1; +pub const IPC_STAT: ::c_int = 2; + +pub const IPC_R: ::c_int = 0x100; +pub const IPC_W: ::c_int = 0x80; +pub const IPC_M: ::c_int = 0x1000; + +// sys/sem.h +pub const SEM_UNDO: ::c_int = 0o10000; + +pub const GETNCNT: ::c_int = 3; +pub const GETPID: ::c_int = 4; +pub const GETVAL: ::c_int = 5; +pub const GETALL: ::c_int = 6; +pub const GETZCNT: ::c_int = 7; +pub const SETVAL: ::c_int = 8; +pub const SETALL: ::c_int = 9; + +// sys/shm.h +pub const SHM_RDONLY: ::c_int = 0x1000; +pub const SHM_RND: ::c_int = 0x2000; +pub const SHMLBA: ::c_int = 4096; +pub const SHM_R: ::c_int = IPC_R; +pub const SHM_W: ::c_int = IPC_W; + +// Flags for chflags(2) +pub const UF_SETTABLE: ::c_uint = 0x0000ffff; +pub const UF_NODUMP: ::c_uint = 0x00000001; +pub const UF_IMMUTABLE: ::c_uint = 0x00000002; +pub const UF_APPEND: ::c_uint = 0x00000004; +pub const UF_OPAQUE: ::c_uint = 0x00000008; +pub const UF_COMPRESSED: ::c_uint = 0x00000020; +pub const UF_TRACKED: ::c_uint = 0x00000040; +pub const SF_SETTABLE: ::c_uint = 0xffff0000; +pub const SF_ARCHIVED: ::c_uint = 0x00010000; +pub const SF_IMMUTABLE: ::c_uint = 0x00020000; +pub const SF_APPEND: ::c_uint = 0x00040000; +pub const UF_HIDDEN: ::c_uint = 0x00008000; + f! { pub fn WSTOPSIG(status: ::c_int) -> ::c_int { status >> 8 @@ -2220,6 +2391,8 @@ extern { 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 chflags(path: *const ::c_char, flags: ::c_uint) -> ::c_int; + pub fn fchflags(fd: ::c_int, flags: ::c_uint) -> ::c_int; pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; pub fn lio_listio(mode: ::c_int, aiocb_list: *const *mut aiocb, @@ -2254,7 +2427,23 @@ extern { link_name = "mprotect$UNIX2003")] pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int; + pub fn semget(key: key_t, nsems: ::c_int, semflg: ::c_int) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "semctl$UNIX2003")] + pub fn semctl(semid: ::c_int, + semnum: ::c_int, + cmd: ::c_int, ...) -> ::c_int; + pub fn semop(semid: ::c_int, sops: *mut sembuf, nsops: ::size_t) -> ::c_int; pub fn shm_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::c_int; + pub fn ftok(pathname : *const c_char, proj_id : ::c_int) -> key_t; + pub fn shmat(shmid: ::c_int, shmaddr: *const ::c_void, + shmflg: ::c_int) -> *mut ::c_void; + pub fn shmdt(shmaddr: *const ::c_void) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "shmctl$UNIX2003")] + pub fn shmctl(shmid: ::c_int, cmd: ::c_int, + buf: *mut ::shmid_ds) -> ::c_int; + pub fn shmget(key: key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int; pub fn sysctl(name: *mut ::c_int, namelen: ::c_uint, oldp: *mut ::c_void, @@ -2324,6 +2513,9 @@ extern { len: *mut ::off_t, hdtr: *mut ::sf_hdtr, flags: ::c_int) -> ::c_int; + pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int; + pub fn utimensat(dirfd: ::c_int, path: *const ::c_char, + times: *const ::timespec, flag: ::c_int) -> ::c_int; pub fn openpty(amaster: *mut ::c_int, aslave: *mut ::c_int, name: *mut ::c_char, @@ -2343,7 +2535,8 @@ extern { pub fn querylocale(mask: ::c_int, loc: ::locale_t) -> *const ::c_char; pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int; pub fn setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int; - + pub fn getdomainname(name: *mut ::c_char, len: ::c_int) -> ::c_int; + pub fn setdomainname(name: *const ::c_char, len: ::c_int) -> ::c_int; pub fn getxattr(path: *const ::c_char, name: *const ::c_char, value: *mut ::c_void, size: ::size_t, position: u32, flags: ::c_int) -> ::ssize_t; @@ -2362,6 +2555,11 @@ extern { size: ::size_t, flags: ::c_int) -> ::ssize_t; pub fn removexattr(path: *const ::c_char, name: *const ::c_char, flags: ::c_int) -> ::c_int; + pub fn renamex_np(from: *const ::c_char, to: *const ::c_char, + flags: ::c_uint) -> ::c_int; + pub fn renameatx_np(fromfd: ::c_int, from: *const ::c_char, + tofd: ::c_int, to: *const ::c_char, + flags: ::c_uint) -> ::c_int; pub fn fremovexattr(filedes: ::c_int, name: *const ::c_char, flags: ::c_int) -> ::c_int; @@ -2382,6 +2580,60 @@ extern { pub fn _dyld_get_image_header(image_index: u32) -> *const mach_header; pub fn _dyld_get_image_vmaddr_slide(image_index: u32) -> ::intptr_t; pub fn _dyld_get_image_name(image_index: u32) -> *const ::c_char; + + pub fn posix_spawn(pid: *mut ::pid_t, + path: *const ::c_char, + file_actions: *const ::posix_spawn_file_actions_t, + attrp: *const ::posix_spawnattr_t, + argv: *const *mut ::c_char, + envp: *const *mut ::c_char) -> ::c_int; + pub fn posix_spawnp(pid: *mut ::pid_t, + file: *const ::c_char, + file_actions: *const ::posix_spawn_file_actions_t, + attrp: *const ::posix_spawnattr_t, + argv: *const *mut ::c_char, + envp: *const *mut ::c_char) -> ::c_int; + pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> ::c_int; + pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> ::c_int; + pub fn posix_spawnattr_getsigdefault(attr: *const posix_spawnattr_t, + default: *mut ::sigset_t) -> ::c_int; + pub fn posix_spawnattr_setsigdefault(attr: *mut posix_spawnattr_t, + default: *const ::sigset_t) -> ::c_int; + pub fn posix_spawnattr_getsigmask(attr: *const posix_spawnattr_t, + default: *mut ::sigset_t) -> ::c_int; + pub fn posix_spawnattr_setsigmask(attr: *mut posix_spawnattr_t, + default: *const ::sigset_t) -> ::c_int; + pub fn posix_spawnattr_getflags(attr: *const posix_spawnattr_t, + flags: *mut ::c_short) -> ::c_int; + pub fn posix_spawnattr_setflags(attr: *mut posix_spawnattr_t, + flags: ::c_short) -> ::c_int; + pub fn posix_spawnattr_getpgroup(attr: *const posix_spawnattr_t, + flags: *mut ::pid_t) -> ::c_int; + pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, + flags: ::pid_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; + pub fn posix_spawn_file_actions_addopen( + actions: *mut posix_spawn_file_actions_t, + fd: ::c_int, + path: *const ::c_char, + oflag: ::c_int, + mode: ::mode_t, + ) -> ::c_int; + pub fn posix_spawn_file_actions_addclose( + actions: *mut posix_spawn_file_actions_t, + fd: ::c_int, + ) -> ::c_int; + pub fn posix_spawn_file_actions_adddup2( + actions: *mut posix_spawn_file_actions_t, + fd: ::c_int, + newfd: ::c_int, + ) -> ::c_int; } cfg_if! { diff --git a/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs index 620fad4..0414380 100644 --- a/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -1,5 +1,6 @@ pub type clock_t = u64; pub type ino_t = u64; +pub type lwpid_t = i32; pub type nlink_t = u32; pub type blksize_t = i64; pub type clockid_t = ::c_ulong; @@ -114,6 +115,27 @@ s! { pub f_uid_uuid: ::uuid_t, } + pub struct statfs { + pub f_bsize: ::c_long, + pub f_iosize: ::c_long, + pub f_blocks: ::c_long, + pub f_bfree: ::c_long, + pub f_bavail: ::c_long, + pub f_files: ::c_long, + pub f_ffree: ::c_long, + pub f_fsid: ::fsid_t, + pub f_owner: ::uid_t, + pub f_type: ::int32_t, + pub f_flags: ::int32_t, + pub f_syncwrites: ::c_long, + pub f_asyncwrites: ::c_long, + pub f_fstypename: [::c_char; 16], + pub f_mntonname: [::c_char; 90], + pub f_syncreads: ::c_long, + pub f_asyncreads: ::c_long, + pub f_mntfromname: [::c_char; 90], + } + pub struct stat { pub st_ino: ::ino_t, pub st_nlink: ::nlink_t, @@ -200,6 +222,8 @@ pub const O_DIRECTORY: ::c_int = 0x08000000; pub const F_GETLK: ::c_int = 7; pub const F_SETLK: ::c_int = 8; pub const F_SETLKW: ::c_int = 9; +pub const ENOMEDIUM: ::c_int = 93; +pub const EASYNC: ::c_int = 99; pub const ELAST: ::c_int = 99; pub const RLIMIT_POSIXLOCKS: ::c_int = 11; pub const RLIM_NLIMITS: ::rlim_t = 12; @@ -407,6 +431,8 @@ pub const NOTE_CHILD: ::uint32_t = 0x00000004; pub const SO_SNDSPACE: ::c_int = 0x100a; pub const SO_CPUHINT: ::c_int = 0x1030; +pub const PT_FIRSTMACH: ::c_int = 32; + // 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 @@ -658,6 +684,11 @@ pub const IPPROTO_DONE: ::c_int = 257; /// Used by RSS: the layer3 protocol is unknown pub const IPPROTO_UNKNOWN: ::c_int = 258; +// sys/netinet/tcp.h +pub const TCP_SIGNATURE_ENABLE: ::c_int = 16; +pub const TCP_KEEPINIT: ::c_int = 32; +pub const TCP_FASTKEEP: ::c_int = 128; + pub const AF_BLUETOOTH: ::c_int = 33; pub const AF_MPLS: ::c_int = 34; pub const AF_IEEE80211: ::c_int = 35; @@ -737,6 +768,20 @@ pub const _SC_THREAD_ROBUST_PRIO_PROTECT: ::c_int = 127; pub const WCONTINUED: ::c_int = 4; pub const WSTOPPED: ::c_int = 0o177; +// Values for struct rtprio (type_ field) +pub const RTP_PRIO_REALTIME: ::c_ushort = 0; +pub const RTP_PRIO_NORMAL: ::c_ushort = 1; +pub const RTP_PRIO_IDLE: ::c_ushort = 2; +pub const RTP_PRIO_THREAD: ::c_ushort = 3; + +// Flags for chflags(2) +pub const UF_NOHISTORY: ::c_ulong = 0x00000040; +pub const UF_CACHE: ::c_ulong = 0x00000080; +pub const UF_XLINK: ::c_ulong = 0x00000100; +pub const SF_NOHISTORY: ::c_ulong = 0x00400000; +pub const SF_CACHE: ::c_ulong = 0x00800000; +pub const SF_XLINK: ::c_ulong = 0x01000000; + extern { pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int; @@ -750,4 +795,10 @@ extern { timeout: *mut ::timespec) -> ::c_int; pub fn freelocale(loc: ::locale_t); + + pub fn lwp_rtprio(function: ::c_int, pid: ::pid_t, lwpid: lwpid_t, + rtp: *mut super::rtprio) -> ::c_int; + + pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int; + pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int; } diff --git a/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs b/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs index 74f2cf8..1ead166 100644 --- a/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -3,7 +3,7 @@ pub type clock_t = i32; pub type ino_t = u32; pub type lwpid_t = i32; pub type nlink_t = u16; -pub type blksize_t = u32; +pub type blksize_t = i32; pub type clockid_t = ::c_int; pub type sem_t = _sem; @@ -15,6 +15,9 @@ pub type key_t = ::c_long; pub type msglen_t = ::c_ulong; pub type msgqnum_t = ::c_ulong; +pub type posix_spawnattr_t = *mut ::c_void; +pub type posix_spawn_file_actions_t = *mut ::c_void; + s! { pub struct utmpx { pub ut_type: ::c_short, @@ -96,6 +99,31 @@ s! { pub f_namemax: ::c_ulong, } + pub struct statfs { + pub f_version: ::uint32_t, + pub f_type: ::uint32_t, + pub f_flags: ::uint64_t, + pub f_bsize: ::uint64_t, + pub f_iosize: ::uint64_t, + pub f_blocks: ::uint64_t, + pub f_bfree: ::uint64_t, + pub f_bavail: ::int64_t, + pub f_files: ::uint64_t, + pub f_ffree: ::int64_t, + pub f_syncwrites: ::uint64_t, + pub f_asyncwrites: ::uint64_t, + pub f_syncreads: ::uint64_t, + pub f_asyncreads: ::uint64_t, + f_spare: [::uint64_t; 10], + pub f_namemax: ::uint32_t, + pub f_owner: ::uid_t, + pub f_fsid: ::fsid_t, + f_charspare: [::c_char; 80], + pub f_fstypename: [::c_char; 16], + pub f_mntfromname: [::c_char; 88], + pub f_mntonname: [::c_char; 88], + } + // internal structure has changed over time pub struct _sem { data: [u32; 4], @@ -158,6 +186,10 @@ s! { pub const SIGEV_THREAD_ID: ::c_int = 4; +pub const EXTATTR_NAMESPACE_EMPTY: ::c_int = 0; +pub const EXTATTR_NAMESPACE_USER: ::c_int = 1; +pub const EXTATTR_NAMESPACE_SYSTEM: ::c_int = 2; + pub const RAND_MAX: ::c_int = 0x7fff_fffd; pub const PTHREAD_STACK_MIN: ::size_t = 2048; pub const PTHREAD_MUTEX_ADAPTIVE_NP: ::c_int = 4; @@ -165,6 +197,8 @@ pub const SIGSTKSZ: ::size_t = 34816; pub const SF_NODISKIO: ::c_int = 0x00000001; pub const SF_MNOWAIT: ::c_int = 0x00000002; pub const SF_SYNC: ::c_int = 0x00000004; +pub const SF_USER_READAHEAD: ::c_int = 0x00000008; +pub const SF_NOCACHE: ::c_int = 0x00000010; pub const O_CLOEXEC: ::c_int = 0x00100000; pub const O_DIRECTORY: ::c_int = 0x00020000; pub const O_EXEC: ::c_int = 0x00040000; @@ -179,7 +213,9 @@ pub const EOWNERDEAD: ::c_int = 96; pub const ELAST: ::c_int = 96; pub const RLIMIT_NPTS: ::c_int = 11; pub const RLIMIT_SWAP: ::c_int = 12; -pub const RLIM_NLIMITS: ::rlim_t = 13; +pub const RLIMIT_KQUEUES: ::c_int = 13; +pub const RLIMIT_UMTXP: ::c_int = 14; +pub const RLIM_NLIMITS: ::rlim_t = 15; pub const Q_GETQUOTA: ::c_int = 0x700; pub const Q_SETQUOTA: ::c_int = 0x800; @@ -200,9 +236,12 @@ pub const EVFILT_VNODE: ::int16_t = -4; pub const EVFILT_PROC: ::int16_t = -5; pub const EVFILT_SIGNAL: ::int16_t = -6; pub const EVFILT_TIMER: ::int16_t = -7; +pub const EVFILT_PROCDESC: ::int16_t = -8; pub const EVFILT_FS: ::int16_t = -9; pub const EVFILT_LIO: ::int16_t = -10; pub const EVFILT_USER: ::int16_t = -11; +pub const EVFILT_SENDFILE: ::int16_t = -12; +pub const EVFILT_EMPTY: ::int16_t = -13; pub const EV_ADD: ::uint16_t = 0x1; pub const EV_DELETE: ::uint16_t = 0x2; @@ -422,6 +461,7 @@ pub const JAIL_SYS_INHERIT: ::c_int = 2; pub const SO_BINTIME: ::c_int = 0x2000; pub const SO_NO_OFFLOAD: ::c_int = 0x4000; pub const SO_NO_DDP: ::c_int = 0x8000; +pub const SO_REUSEPORT_LB: ::c_int = 0x10000; pub const SO_LABEL: ::c_int = 0x1009; pub const SO_PEERLABEL: ::c_int = 0x1010; pub const SO_LISTENQLIMIT: ::c_int = 0x1011; @@ -438,6 +478,39 @@ pub const LOCAL_CREDS: ::c_int = 2; pub const LOCAL_CONNWAIT: ::c_int = 4; pub const LOCAL_VENDOR: ::c_int = SO_VENDOR; +pub const PT_LWPINFO: ::c_int = 13; +pub const PT_GETNUMLWPS: ::c_int = 14; +pub const PT_GETLWPLIST: ::c_int = 15; +pub const PT_CLEARSTEP: ::c_int = 16; +pub const PT_SETSTEP: ::c_int = 17; +pub const PT_SUSPEND: ::c_int = 18; +pub const PT_RESUME: ::c_int = 19; +pub const PT_TO_SCE: ::c_int = 20; +pub const PT_TO_SCX: ::c_int = 21; +pub const PT_SYSCALL: ::c_int = 22; +pub const PT_FOLLOW_FORK: ::c_int = 23; +pub const PT_LWP_EVENTS: ::c_int = 24; +pub const PT_GET_EVENT_MASK: ::c_int = 25; +pub const PT_SET_EVENT_MASK: ::c_int = 26; +pub const PT_GETREGS: ::c_int = 33; +pub const PT_SETREGS: ::c_int = 34; +pub const PT_GETFPREGS: ::c_int = 35; +pub const PT_SETFPREGS: ::c_int = 36; +pub const PT_GETDBREGS: ::c_int = 37; +pub const PT_SETDBREGS: ::c_int = 38; +pub const PT_VM_TIMESTAMP: ::c_int = 40; +pub const PT_VM_ENTRY: ::c_int = 41; +pub const PT_FIRSTMACH: ::c_int = 64; + +pub const PTRACE_EXEC: ::c_int = 0x0001; +pub const PTRACE_SCE: ::c_int = 0x0002; +pub const PTRACE_SCX: ::c_int = 0x0004; +pub const PTRACE_SYSCALL: ::c_int = PTRACE_SCE | PTRACE_SCX; +pub const PTRACE_FORK: ::c_int = 0x0008; +pub const PTRACE_LWP: ::c_int = 0x0010; +pub const PTRACE_VFORK: ::c_int = 0x0020; +pub const PTRACE_DEFAULT: ::c_int = PTRACE_EXEC; + pub const AF_SLOW: ::c_int = 33; pub const AF_SCLUSTER: ::c_int = 34; pub const AF_ARP: ::c_int = 35; @@ -719,6 +792,16 @@ pub const IPPROTO_DIVERT: ::c_int = 258; /// SeND pseudo-protocol pub const IPPROTO_SEND: ::c_int = 259; +// sys/netinet/TCP.h +pub const TCP_MD5SIG: ::c_int = 16; +pub const TCP_INFO: ::c_int = 32; +pub const TCP_CONGESTION: ::c_int = 64; +pub const TCP_CCALGOOPT: ::c_int = 65; +pub const TCP_KEEPINIT: ::c_int = 128; +pub const TCP_FASTOPEN: ::c_int = 1025; +pub const TCP_PCAP_OUT: ::c_int = 2048; +pub const TCP_PCAP_IN: ::c_int = 4096; + pub const IP_BINDANY: ::c_int = 24; pub const PF_SLOW: ::c_int = AF_SLOW; @@ -795,10 +878,10 @@ pub const SHUTDOWN_TIME: ::c_short = 8; pub const LC_COLLATE_MASK: ::c_int = (1 << 0); pub const LC_CTYPE_MASK: ::c_int = (1 << 1); -pub const LC_MESSAGES_MASK: ::c_int = (1 << 2); -pub const LC_MONETARY_MASK: ::c_int = (1 << 3); -pub const LC_NUMERIC_MASK: ::c_int = (1 << 4); -pub const LC_TIME_MASK: ::c_int = (1 << 5); +pub const LC_MONETARY_MASK: ::c_int =(1 << 2); +pub const LC_NUMERIC_MASK: ::c_int = (1 << 3); +pub const LC_TIME_MASK: ::c_int = (1 << 4); +pub const LC_MESSAGES_MASK: ::c_int = (1 << 5); pub const LC_ALL_MASK: ::c_int = LC_COLLATE_MASK | LC_CTYPE_MASK | LC_MESSAGES_MASK @@ -838,6 +921,33 @@ pub const _SC_CPUSET_SIZE: ::c_int = 122; pub const XU_NGROUPS: ::c_int = 16; pub const XUCRED_VERSION: ::c_uint = 0; +// Flags which can be passed to pdfork(2) +pub const PD_DAEMON: ::c_int = 0x00000001; +pub const PD_CLOEXEC: ::c_int = 0x00000002; +pub const PD_ALLOWED_AT_FORK: ::c_int = PD_DAEMON | PD_CLOEXEC; + +// Values for struct rtprio (type_ field) +pub const RTP_PRIO_REALTIME: ::c_ushort = 2; +pub const RTP_PRIO_NORMAL: ::c_ushort = 3; +pub const RTP_PRIO_IDLE: ::c_ushort = 4; + +pub const POSIX_SPAWN_RESETIDS: ::c_int = 0x01; +pub const POSIX_SPAWN_SETPGROUP: ::c_int = 0x02; +pub const POSIX_SPAWN_SETSCHEDPARAM: ::c_int = 0x04; +pub const POSIX_SPAWN_SETSCHEDULER: ::c_int = 0x08; +pub const POSIX_SPAWN_SETSIGDEF: ::c_int = 0x10; +pub const POSIX_SPAWN_SETSIGMASK: ::c_int = 0x20; + +// Flags for chflags(2) +pub const UF_SYSTEM: ::c_ulong = 0x00000080; +pub const UF_SPARSE: ::c_ulong = 0x00000100; +pub const UF_OFFLINE: ::c_ulong = 0x00000200; +pub const UF_REPARSE: ::c_ulong = 0x00000400; +pub const UF_ARCHIVE: ::c_ulong = 0x00000800; +pub const UF_READONLY: ::c_ulong = 0x00001000; +pub const UF_HIDDEN: ::c_ulong = 0x00008000; +pub const SF_SNAPSHOT: ::c_ulong = 0x00200000; + extern { pub fn __error() -> *mut ::c_int; @@ -848,6 +958,58 @@ extern { pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; pub fn clock_settime(clk_id: ::clockid_t, tp: *const ::timespec) -> ::c_int; + pub fn extattr_delete_fd(fd: ::c_int, + attrnamespace: ::c_int, + attrname: *const ::c_char) -> ::c_int; + pub fn extattr_delete_file(path: *const ::c_char, + attrnamespace: ::c_int, + attrname: *const ::c_char) -> ::c_int; + pub fn extattr_delete_link(path: *const ::c_char, + attrnamespace: ::c_int, + attrname: *const ::c_char) -> ::c_int; + pub fn extattr_get_fd(fd: ::c_int, + attrnamespace: ::c_int, + attrname: *const ::c_char, + data: *mut ::c_void, + nbytes: ::size_t) -> ::ssize_t; + pub fn extattr_get_file(path: *const ::c_char, + attrnamespace: ::c_int, + attrname: *const ::c_char, + data: *mut ::c_void, + nbytes: ::size_t) -> ::ssize_t; + pub fn extattr_get_link(path: *const ::c_char, + attrnamespace: ::c_int, + attrname: *const ::c_char, + data: *mut ::c_void, + nbytes: ::size_t) -> ::ssize_t; + pub fn extattr_list_fd(fd: ::c_int, + attrnamespace: ::c_int, + data: *mut ::c_void, + nbytes: ::size_t) -> ::ssize_t; + pub fn extattr_list_file(path: *const ::c_char, + attrnamespace: ::c_int, + data: *mut ::c_void, + nbytes: ::size_t) -> ::ssize_t; + pub fn extattr_list_link(path: *const ::c_char, + attrnamespace: ::c_int, + data: *mut ::c_void, + nbytes: ::size_t) -> ::ssize_t; + pub fn extattr_set_fd(fd: ::c_int, + attrnamespace: ::c_int, + attrname: *const ::c_char, + data: *const ::c_void, + nbytes: ::size_t) -> ::ssize_t; + pub fn extattr_set_file(path: *const ::c_char, + attrnamespace: ::c_int, + attrname: *const ::c_char, + data: *const ::c_void, + nbytes: ::size_t) -> ::ssize_t; + pub fn extattr_set_link(path: *const ::c_char, + attrnamespace: ::c_int, + attrname: *const ::c_char, + data: *const ::c_void, + nbytes: ::size_t) -> ::ssize_t; + pub fn jail(jail: *mut ::jail) -> ::c_int; pub fn jail_attach(jid: ::c_int) -> ::c_int; pub fn jail_remove(jid: ::c_int) -> ::c_int; @@ -856,6 +1018,7 @@ extern { pub fn jail_set(iov: *mut ::iovec, niov: ::c_uint, flags: ::c_int) -> ::c_int; + pub fn fdatasync(fd: ::c_int) -> ::c_int; pub fn posix_fallocate(fd: ::c_int, offset: ::off_t, len: ::off_t) -> ::c_int; pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t, @@ -893,6 +1056,92 @@ extern { pub fn fexecve(fd: ::c_int, argv: *const *const ::c_char, envp: *const *const ::c_char) -> ::c_int; + + pub fn pdfork(fdp: *mut ::c_int, flags: ::c_int) -> ::pid_t; + pub fn pdgetpid(fd: ::c_int, pidp: *mut ::pid_t) -> ::c_int; + pub fn pdkill(fd: ::c_int, signum: ::c_int) -> ::c_int; + + pub fn rtprio_thread(function: ::c_int, lwpid: ::lwpid_t, + rtp: *mut super::rtprio) -> ::c_int; + + pub fn posix_spawn(pid: *mut ::pid_t, + path: *const ::c_char, + file_actions: *const ::posix_spawn_file_actions_t, + attrp: *const ::posix_spawnattr_t, + argv: *const *mut ::c_char, + envp: *const *mut ::c_char) -> ::c_int; + pub fn posix_spawnp(pid: *mut ::pid_t, + file: *const ::c_char, + file_actions: *const ::posix_spawn_file_actions_t, + attrp: *const ::posix_spawnattr_t, + argv: *const *mut ::c_char, + envp: *const *mut ::c_char) -> ::c_int; + pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> ::c_int; + pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> ::c_int; + pub fn posix_spawnattr_getsigdefault(attr: *const posix_spawnattr_t, + default: *mut ::sigset_t) -> ::c_int; + pub fn posix_spawnattr_setsigdefault(attr: *mut posix_spawnattr_t, + default: *const ::sigset_t) -> ::c_int; + pub fn posix_spawnattr_getsigmask(attr: *const posix_spawnattr_t, + default: *mut ::sigset_t) -> ::c_int; + pub fn posix_spawnattr_setsigmask(attr: *mut posix_spawnattr_t, + default: *const ::sigset_t) -> ::c_int; + pub fn posix_spawnattr_getflags(attr: *const posix_spawnattr_t, + flags: *mut ::c_short) -> ::c_int; + pub fn posix_spawnattr_setflags(attr: *mut posix_spawnattr_t, + flags: ::c_short) -> ::c_int; + pub fn posix_spawnattr_getpgroup(attr: *const posix_spawnattr_t, + flags: *mut ::pid_t) -> ::c_int; + pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, + flags: ::pid_t) -> ::c_int; + pub fn posix_spawnattr_getschedpolicy(attr: *const posix_spawnattr_t, + flags: *mut ::c_int) -> ::c_int; + pub fn posix_spawnattr_setschedpolicy(attr: *mut posix_spawnattr_t, + flags: ::c_int) -> ::c_int; + pub fn posix_spawnattr_getschedparam( + attr: *const posix_spawnattr_t, + param: *mut ::sched_param, + ) -> ::c_int; + pub fn posix_spawnattr_setschedparam( + attr: *mut posix_spawnattr_t, + param: *const ::sched_param, + ) -> ::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; + pub fn posix_spawn_file_actions_addopen( + actions: *mut posix_spawn_file_actions_t, + fd: ::c_int, + path: *const ::c_char, + oflag: ::c_int, + mode: ::mode_t, + ) -> ::c_int; + pub fn posix_spawn_file_actions_addclose( + actions: *mut posix_spawn_file_actions_t, + fd: ::c_int, + ) -> ::c_int; + pub fn posix_spawn_file_actions_adddup2( + actions: *mut posix_spawn_file_actions_t, + fd: ::c_int, + newfd: ::c_int, + ) -> ::c_int; + + pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int; + pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int; + + pub fn dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::c_int; +} + +#[link(name = "util")] +extern { + pub fn extattr_namespace_to_string(attrnamespace: ::c_int, + string: *mut *mut ::c_char) -> ::c_int; + pub fn extattr_string_to_namespace(string: *const ::c_char, + attrnamespace: *mut ::c_int) -> ::c_int; } cfg_if! { diff --git a/libc/src/unix/bsd/freebsdlike/mod.rs b/libc/src/unix/bsd/freebsdlike/mod.rs index 5cea759..cb3dba4 100644 --- a/libc/src/unix/bsd/freebsdlike/mod.rs +++ b/libc/src/unix/bsd/freebsdlike/mod.rs @@ -170,6 +170,24 @@ s! { pub cmcred_ngroups: ::c_short, pub cmcred_groups: [::gid_t; CMGROUP_MAX], } + + pub struct rtprio { + pub type_: ::c_ushort, + pub prio: ::c_ushort, + } + + pub struct in6_pktinfo { + pub ipi6_addr: ::in6_addr, + pub ipi6_ifindex: ::c_uint, + } + + pub struct arphdr { + pub ar_hrd: u16, + pub ar_pro: u16, + pub ar_hln: u8, + pub ar_pln: u8, + pub ar_op: u16, + } } pub const AIO_LISTIO_MAX: ::c_int = 16; @@ -606,6 +624,18 @@ pub const PF_NATM: ::c_int = AF_NATM; pub const PF_ATM: ::c_int = AF_ATM; pub const PF_NETGRAPH: ::c_int = AF_NETGRAPH; +pub const PT_TRACE_ME: ::c_int = 0; +pub const PT_READ_I: ::c_int = 1; +pub const PT_READ_D: ::c_int = 2; +pub const PT_WRITE_I: ::c_int = 4; +pub const PT_WRITE_D: ::c_int = 5; +pub const PT_CONTINUE: ::c_int = 7; +pub const PT_KILL: ::c_int = 8; +pub const PT_STEP: ::c_int = 9; +pub const PT_ATTACH: ::c_int = 10; +pub const PT_DETACH: ::c_int = 11; +pub const PT_IO: ::c_int = 12; + pub const SOMAXCONN: ::c_int = 128; pub const MSG_OOB: ::c_int = 0x00000001; @@ -630,13 +660,21 @@ pub const SOCK_NONBLOCK: ::c_int = 0x20000000; pub const SOCK_MAXADDRLEN: ::c_int = 255; pub const IP_TTL: ::c_int = 4; pub const IP_HDRINCL: ::c_int = 2; +pub const IP_RECVDSTADDR: ::c_int = 7; +pub const IP_SENDSRCADDR: ::c_int = IP_RECVDSTADDR; pub const IP_ADD_MEMBERSHIP: ::c_int = 12; pub const IP_DROP_MEMBERSHIP: ::c_int = 13; pub const IPV6_JOIN_GROUP: ::c_int = 12; pub const IPV6_LEAVE_GROUP: ::c_int = 13; +pub const IPV6_RECVPKTINFO: ::c_int = 36; +pub const IPV6_PKTINFO: ::c_int = 46; + +pub const TCP_NOPUSH: ::c_int = 4; +pub const TCP_NOOPT: ::c_int = 8; +pub const TCP_KEEPIDLE: ::c_int = 256; +pub const TCP_KEEPINTVL: ::c_int = 512; +pub const TCP_KEEPCNT: ::c_int = 1024; -pub const TCP_NODELAY: ::c_int = 1; -pub const TCP_KEEPIDLE: ::c_int = 256; pub const SOL_SOCKET: ::c_int = 0xffff; pub const SO_DEBUG: ::c_int = 0x01; pub const SO_ACCEPTCONN: ::c_int = 0x0002; @@ -960,6 +998,27 @@ pub const CMGROUP_MAX: usize = 16; // sizeof(long) pub const BPF_ALIGNMENT: ::c_int = 8; +// Values for rtprio struct (prio field) and syscall (function argument) +pub const RTP_PRIO_MIN: ::c_ushort = 0; +pub const RTP_PRIO_MAX: ::c_ushort = 31; +pub const RTP_LOOKUP: ::c_int = 0; +pub const RTP_SET: ::c_int = 1; + +// Flags for chflags(2) +pub const UF_SETTABLE: ::c_ulong = 0x0000ffff; +pub const UF_NODUMP: ::c_ulong = 0x00000001; +pub const UF_IMMUTABLE: ::c_ulong = 0x00000002; +pub const UF_APPEND: ::c_ulong = 0x00000004; +pub const UF_OPAQUE: ::c_ulong = 0x00000008; +pub const UF_NOUNLINK: ::c_ulong = 0x00000010; +pub const SF_SETTABLE: ::c_ulong = 0xffff0000; +pub const SF_ARCHIVED: ::c_ulong = 0x00010000; +pub const SF_IMMUTABLE: ::c_ulong = 0x00020000; +pub const SF_APPEND: ::c_ulong = 0x00040000; +pub const SF_NOUNLINK: ::c_ulong = 0x00100000; + +pub const TIMER_ABSTIME: ::c_int = 1; + f! { pub fn WIFCONTINUED(status: ::c_int) -> bool { status == 0x13 @@ -979,24 +1038,73 @@ f! { } extern { - pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int; + pub fn accept4(s: ::c_int, addr: *mut ::sockaddr, + addrlen: *mut ::socklen_t, flags: ::c_int) -> ::c_int; + 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; + 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 chflags(path: *const ::c_char, flags: ::c_ulong) -> ::c_int; + pub fn chflagsat(fd: ::c_int, path: *const ::c_char, flags: ::c_ulong, + atflag: ::c_int) -> ::c_int; + pub fn dirfd(dirp: *mut ::DIR) -> ::c_int; + pub fn duplocale(base: ::locale_t) -> ::locale_t; pub fn endutxent(); - pub fn getutxent() -> *mut utmpx; - pub fn getutxid(ut: *const utmpx) -> *mut utmpx; - pub fn getutxline(ut: *const utmpx) -> *mut utmpx; - pub fn pututxline(ut: *const utmpx) -> *mut utmpx; - pub fn setutxent(); - 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 fchflags(fd: ::c_int, flags: ::c_ulong) -> ::c_int; + pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int; + pub fn getdomainname(name: *mut ::c_char, len: ::c_int) -> ::c_int; + pub fn getgrent_r(grp: *mut ::group, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut ::group) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__getpwent_r50")] + pub fn getpwent_r(pwd: *mut ::passwd, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut ::passwd) -> ::c_int; pub fn getgrouplist(name: *const ::c_char, basegid: ::gid_t, groups: *mut ::gid_t, ngroups: *mut ::c_int) -> ::c_int; + pub fn getnameinfo(sa: *const ::sockaddr, + salen: ::socklen_t, + host: *mut ::c_char, + hostlen: ::size_t, + serv: *mut ::c_char, + servlen: ::size_t, + flags: ::c_int) -> ::c_int; + pub fn getpriority(which: ::c_int, who: ::c_int) -> ::c_int; + pub fn getutxent() -> *mut utmpx; + pub fn getutxid(ut: *const utmpx) -> *mut utmpx; + pub fn getutxline(ut: *const utmpx) -> *mut utmpx; pub fn initgroups(name: *const ::c_char, basegid: ::gid_t) -> ::c_int; - pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t; + #[cfg_attr(target_os = "freebsd", link_name = "kevent@FBSD_1.0")] + pub fn kevent(kq: ::c_int, + changelist: *const ::kevent, + nchanges: ::c_int, + eventlist: *mut ::kevent, + nevents: ::c_int, + timeout: *const ::timespec) -> ::c_int; + pub fn lchflags(path: *const ::c_char, flags: ::c_ulong) -> ::c_int; + pub fn lio_listio(mode: ::c_int, aiocb_list: *const *mut aiocb, + nitems: ::c_int, sevp: *mut sigevent) -> ::c_int; + pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int; + pub fn memrchr(cx: *const ::c_void, + c: ::c_int, + n: ::size_t) -> *mut ::c_void; + pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char, + mode: ::mode_t) -> ::c_int; + #[cfg_attr(target_os = "freebsd", link_name = "mknodat@FBSD_1.1")] + pub fn mknodat(dirfd: ::c_int, pathname: *const ::c_char, + mode: ::mode_t, dev: dev_t) -> ::c_int; pub fn mq_close(mqd: ::mqd_t) -> ::c_int; pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int; pub fn mq_notify(mqd: ::mqd_t, notification: *const ::sigevent) -> ::c_int; + pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t; pub fn mq_receive(mqd: ::mqd_t, msg_ptr: *mut ::c_char, msg_len: ::size_t, @@ -1019,70 +1127,66 @@ extern { msq_prio: ::c_uint, abs_timeout: *const ::timespec) -> ::c_int; pub fn mq_unlink(name: *const ::c_char) -> ::c_int; -} - -#[link(name = "util")] -extern { - 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; - 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; - pub fn dirfd(dirp: *mut ::DIR) -> ::c_int; - pub fn getnameinfo(sa: *const ::sockaddr, - salen: ::socklen_t, - host: *mut ::c_char, - hostlen: ::size_t, - serv: *mut ::c_char, - servlen: ::size_t, - flags: ::c_int) -> ::c_int; - pub fn kevent(kq: ::c_int, - changelist: *const ::kevent, - nchanges: ::c_int, - eventlist: *mut ::kevent, - nevents: ::c_int, - timeout: *const ::timespec) -> ::c_int; pub fn mincore(addr: *const ::c_void, len: ::size_t, vec: *mut ::c_char) -> ::c_int; - pub fn pwritev(fd: ::c_int, - iov: *const ::iovec, - iovcnt: ::c_int, - offset: ::off_t) -> ::ssize_t; + 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; + pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int; + pub fn ppoll(fds: *mut ::pollfd, + nfds: ::nfds_t, + timeout: *const ::timespec, + sigmask: *const sigset_t) -> ::c_int; pub fn preadv(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int, offset: ::off_t) -> ::ssize_t; - pub fn sysctlnametomib(name: *const ::c_char, - mibp: *mut ::c_int, - sizep: *mut ::size_t) - -> ::c_int; - pub fn shm_open(name: *const ::c_char, oflag: ::c_int, mode: ::mode_t) - -> ::c_int; - pub fn sysctl(name: *const ::c_int, - namelen: ::c_uint, - oldp: *mut ::c_void, - oldlenp: *mut ::size_t, - newp: *const ::c_void, - newlen: ::size_t) - -> ::c_int; - pub fn sysctlbyname(name: *const ::c_char, - oldp: *mut ::c_void, - oldlenp: *mut ::size_t, - newp: *const ::c_void, - newlen: ::size_t) - -> ::c_int; + pub fn pthread_attr_get_np(tid: ::pthread_t, + attr: *mut ::pthread_attr_t) -> ::c_int; + pub fn pthread_attr_getguardsize(attr: *const ::pthread_attr_t, + guardsize: *mut ::size_t) -> ::c_int; + pub fn pthread_attr_getstack(attr: *const ::pthread_attr_t, + stackaddr: *mut *mut ::c_void, + stacksize: *mut ::size_t) -> ::c_int; + pub fn pthread_condattr_getclock(attr: *const pthread_condattr_t, + clock_id: *mut clockid_t) -> ::c_int; + pub fn pthread_condattr_getpshared(attr: *const pthread_condattr_t, + pshared: *mut ::c_int) -> ::c_int; + pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t, + clock_id: ::clockid_t) -> ::c_int; + pub fn pthread_condattr_setpshared(attr: *mut pthread_condattr_t, + pshared: ::c_int) -> ::c_int; + pub fn pthread_mutex_timedlock(lock: *mut pthread_mutex_t, + abstime: *const ::timespec) -> ::c_int; + pub fn pthread_mutexattr_getpshared(attr: *const pthread_mutexattr_t, + pshared: *mut ::c_int) -> ::c_int; + pub fn pthread_mutexattr_setpshared(attr: *mut pthread_mutexattr_t, + pshared: ::c_int) -> ::c_int; + pub fn pthread_rwlockattr_getpshared(attr: *const pthread_rwlockattr_t, + val: *mut ::c_int) -> ::c_int; + pub fn pthread_rwlockattr_setpshared(attr: *mut pthread_rwlockattr_t, + val: ::c_int) -> ::c_int; + pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char); + pub fn ptrace(request: ::c_int, + pid: ::pid_t, + addr: *mut ::c_char, + data: ::c_int) -> ::c_int; + pub fn pututxline(ut: *const utmpx) -> *mut utmpx; + pub fn pwritev(fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + offset: ::off_t) -> ::ssize_t; + pub fn querylocale(mask: ::c_int, loc: ::locale_t) -> *const ::c_char; + pub fn rtprio(function: ::c_int, pid: ::pid_t, rtp: *mut rtprio) -> ::c_int; + pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int; pub fn sched_setscheduler(pid: ::pid_t, policy: ::c_int, param: *const ::sched_param) -> ::c_int; - pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int; - pub fn memrchr(cx: *const ::c_void, - c: ::c_int, - n: ::size_t) -> *mut ::c_void; + pub fn sem_getvalue(sem: *mut sem_t, + sval: *mut ::c_int) -> ::c_int; + pub fn sem_timedwait(sem: *mut sem_t, + abstime: *const ::timespec) -> ::c_int; pub fn sendfile(fd: ::c_int, s: ::c_int, offset: ::off_t, @@ -1090,11 +1194,44 @@ extern { hdtr: *mut ::sf_hdtr, sbytes: *mut ::off_t, flags: ::c_int) -> ::c_int; + pub fn setdomainname(name: *const ::c_char, len: ::c_int) -> ::c_int; + pub fn sethostname(name: *const ::c_char, len: ::c_int) -> ::c_int; + pub fn setpriority(which: ::c_int, who: ::c_int, prio: ::c_int) -> ::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 settimeofday(tv: *const ::timeval, tz: *const ::timezone) -> ::c_int; + pub fn setutxent(); + pub fn shm_open(name: *const ::c_char, oflag: ::c_int, mode: ::mode_t) + -> ::c_int; pub fn sigtimedwait(set: *const sigset_t, info: *mut siginfo_t, timeout: *const ::timespec) -> ::c_int; pub fn sigwaitinfo(set: *const sigset_t, info: *mut siginfo_t) -> ::c_int; + pub fn sysctl(name: *const ::c_int, + namelen: ::c_uint, + oldp: *mut ::c_void, + oldlenp: *mut ::size_t, + newp: *const ::c_void, + newlen: ::size_t) + -> ::c_int; + pub fn sysctlbyname(name: *const ::c_char, + oldp: *mut ::c_void, + oldlenp: *mut ::size_t, + newp: *const ::c_void, + newlen: ::size_t) + -> ::c_int; + pub fn sysctlnametomib(name: *const ::c_char, + mibp: *mut ::c_int, + sizep: *mut ::size_t) + -> ::c_int; + pub fn uselocale(loc: ::locale_t) -> ::locale_t; + pub fn utimensat(dirfd: ::c_int, path: *const ::c_char, + times: *const ::timespec, flag: ::c_int) -> ::c_int; +} + +#[link(name = "util")] +extern { pub fn openpty(amaster: *mut ::c_int, aslave: *mut ::c_int, name: *mut ::c_char, @@ -1104,59 +1241,6 @@ extern { name: *mut ::c_char, termp: *mut termios, winp: *mut ::winsize) -> ::pid_t; - pub fn nl_langinfo_l(item: ::nl_item, locale: ::locale_t) -> *mut ::c_char; - pub fn duplocale(base: ::locale_t) -> ::locale_t; - pub fn newlocale(mask: ::c_int, - locale: *const ::c_char, - base: ::locale_t) -> ::locale_t; - pub fn uselocale(loc: ::locale_t) -> ::locale_t; - pub fn querylocale(mask: ::c_int, loc: ::locale_t) -> *const ::c_char; - pub fn accept4(s: ::c_int, addr: *mut ::sockaddr, - addrlen: *mut ::socklen_t, flags: ::c_int) -> ::c_int; - pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char); - pub fn pthread_attr_get_np(tid: ::pthread_t, - attr: *mut ::pthread_attr_t) -> ::c_int; - pub fn pthread_attr_getguardsize(attr: *const ::pthread_attr_t, - guardsize: *mut ::size_t) -> ::c_int; - pub fn pthread_attr_getstack(attr: *const ::pthread_attr_t, - stackaddr: *mut *mut ::c_void, - stacksize: *mut ::size_t) -> ::c_int; - pub fn pthread_condattr_setpshared(attr: *mut pthread_condattr_t, - pshared: ::c_int) -> ::c_int; - pub fn pthread_condattr_getpshared(attr: *const pthread_condattr_t, - pshared: *mut ::c_int) -> ::c_int; - pub fn pthread_mutexattr_setpshared(attr: *mut pthread_mutexattr_t, - pshared: ::c_int) -> ::c_int; - pub fn pthread_mutexattr_getpshared(attr: *const pthread_mutexattr_t, - pshared: *mut ::c_int) -> ::c_int; - pub fn pthread_rwlockattr_getpshared(attr: *const pthread_rwlockattr_t, - val: *mut ::c_int) -> ::c_int; - pub fn pthread_rwlockattr_setpshared(attr: *mut pthread_rwlockattr_t, - val: ::c_int) -> ::c_int; - pub fn getpriority(which: ::c_int, who: ::c_int) -> ::c_int; - pub fn setpriority(which: ::c_int, who: ::c_int, prio: ::c_int) -> ::c_int; - - pub fn fdopendir(fd: ::c_int) -> *mut ::DIR; - - pub fn mknodat(dirfd: ::c_int, pathname: *const ::c_char, - mode: ::mode_t, dev: dev_t) -> ::c_int; - pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char, - mode: ::mode_t) -> ::c_int; - pub fn pthread_condattr_getclock(attr: *const pthread_condattr_t, - clock_id: *mut clockid_t) -> ::c_int; - pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t, - clock_id: ::clockid_t) -> ::c_int; - pub fn sethostname(name: *const ::c_char, len: ::c_int) -> ::c_int; - pub fn sem_timedwait(sem: *mut sem_t, - abstime: *const ::timespec) -> ::c_int; - pub fn pthread_mutex_timedlock(lock: *mut pthread_mutex_t, - abstime: *const ::timespec) -> ::c_int; - pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int; - pub fn ppoll(fds: *mut ::pollfd, - nfds: ::nfds_t, - timeout: *const ::timespec, - sigmask: *const sigset_t) -> ::c_int; - pub fn settimeofday(tv: *const ::timeval, tz: *const ::timezone) -> ::c_int; } cfg_if! { diff --git a/libc/src/unix/bsd/mod.rs b/libc/src/unix/bsd/mod.rs index b9a88f0..770b9b9 100644 --- a/libc/src/unix/bsd/mod.rs +++ b/libc/src/unix/bsd/mod.rs @@ -183,6 +183,9 @@ pub const IP_MULTICAST_IF: ::c_int = 9; pub const IP_MULTICAST_TTL: ::c_int = 10; pub const IP_MULTICAST_LOOP: ::c_int = 11; +pub const IPV6_UNICAST_HOPS: ::c_int = 4; +pub const IPV6_MULTICAST_IF: ::c_int = 9; +pub const IPV6_MULTICAST_HOPS: ::c_int = 10; pub const IPV6_MULTICAST_LOOP: ::c_int = 11; pub const IPV6_V6ONLY: ::c_int = 27; @@ -212,6 +215,10 @@ pub const O_NDELAY: ::c_int = O_NONBLOCK; pub const F_GETOWN: ::c_int = 5; pub const F_SETOWN: ::c_int = 6; +pub const F_RDLCK: ::c_short = 1; +pub const F_UNLCK: ::c_short = 2; +pub const F_WRLCK: ::c_short = 3; + pub const MNT_FORCE: ::c_int = 0x80000; pub const Q_SYNC: ::c_int = 0x600; @@ -309,6 +316,7 @@ pub const LOG_AUTHPRIV: ::c_int = 10 << 3; pub const LOG_FTP: ::c_int = 11 << 3; pub const LOG_PERROR: ::c_int = 0x20; +pub const TCP_NODELAY: ::c_int = 1; pub const TCP_MAXSEG: ::c_int = 2; pub const PIPE_BUF: usize = 512; @@ -325,6 +333,43 @@ pub const POLLRDBAND: ::c_short = 0x080; pub const POLLWRBAND: ::c_short = 0x100; f! { + pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr { + if (*mhdr).msg_controllen as usize >= mem::size_of::<cmsghdr>() { + (*mhdr).msg_control as *mut cmsghdr + } else { + 0 as *mut cmsghdr + } + } + + pub fn CMSG_NXTHDR(mhdr: *const msghdr, + cmsg: *const cmsghdr) -> *mut cmsghdr { + if cmsg.is_null() { + return CMSG_FIRSTHDR(mhdr); + }; + let pad = mem::align_of::<cmsghdr>() - 1; + let next = cmsg as usize + (*cmsg).cmsg_len as usize + pad & !pad; + let max = (*mhdr).msg_control as usize + + (*mhdr).msg_controllen as usize; + if next < max { + next as *mut cmsghdr + } else { + 0 as *mut cmsghdr + } + } + + pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut ::c_uchar { + cmsg.offset(1) as *mut ::c_uchar + } + + pub fn CMSG_SPACE(length: ::c_uint) -> ::c_uint { + let pad = mem::align_of::<cmsghdr>() as ::c_uint - 1; + mem::size_of::<cmsghdr>() as ::c_uint + ((length + pad) & !pad) + } + + pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint { + mem::size_of::<cmsghdr>() as ::c_uint + length + } + pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () { let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8; let fd = fd as usize; @@ -373,6 +418,12 @@ f! { } extern { + pub fn abs(i: ::c_int) -> ::c_int; + pub fn atof(s: *const ::c_char) -> ::c_double; + pub fn labs(i: ::c_long) -> ::c_long; + pub fn rand() -> ::c_int; + pub fn srand(seed: ::c_uint); + pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int; pub fn freeifaddrs(ifa: *mut ::ifaddrs); pub fn setgroups(ngroups: ::c_int, @@ -385,6 +436,10 @@ extern { pub fn getpwent() -> *mut passwd; pub fn setpwent(); pub fn endpwent(); + pub fn setgrent(); + pub fn endgrent(); + pub fn getgrent() -> *mut ::group; + pub fn getprogname() -> *const ::c_char; pub fn setprogname(name: *const ::c_char); pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int; @@ -397,12 +452,14 @@ extern { #[cfg_attr(target_os = "macos", link_name = "glob$INODE64")] #[cfg_attr(target_os = "netbsd", link_name = "__glob30")] + #[cfg_attr(target_os = "freebsd", link_name = "glob@FBSD_1.0")] pub fn glob(pattern: *const ::c_char, flags: ::c_int, errfunc: Option<extern fn(epath: *const ::c_char, errno: ::c_int) -> ::c_int>, pglob: *mut ::glob_t) -> ::c_int; #[cfg_attr(target_os = "netbsd", link_name = "__globfree30")] + #[cfg_attr(target_os = "freebsd", link_name = "globfree@FBSD_1.0")] pub fn globfree(pglob: *mut ::glob_t); pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) @@ -435,6 +492,7 @@ extern { flags: ::c_int, addr: *mut ::sockaddr, addrlen: *mut ::socklen_t) -> ::ssize_t; pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__futimes50")] pub fn futimes(fd: ::c_int, times: *const ::timeval) -> ::c_int; pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char; @@ -529,6 +587,7 @@ extern { attr: *const ::pthread_attr_t, f: extern fn(*mut ::c_void) -> *mut ::c_void, value: *mut ::c_void) -> ::c_int; + pub fn acct(filename: *const ::c_char) -> ::c_int; } cfg_if! { diff --git a/libc/src/unix/bsd/netbsdlike/mod.rs b/libc/src/unix/bsd/netbsdlike/mod.rs index 9179e6a..bfd541d 100644 --- a/libc/src/unix/bsd/netbsdlike/mod.rs +++ b/libc/src/unix/bsd/netbsdlike/mod.rs @@ -35,6 +35,11 @@ s! { pub sin_zero: [::int8_t; 8], } + pub struct in6_pktinfo { + pub ipi6_addr: ::in6_addr, + pub ipi6_ifindex: ::c_uint, + } + pub struct termios { pub c_iflag: ::tcflag_t, pub c_oflag: ::tcflag_t, @@ -177,7 +182,6 @@ pub const SIGSEGV : ::c_int = 11; pub const SIGPIPE : ::c_int = 13; pub const SIGALRM : ::c_int = 14; pub const SIGTERM : ::c_int = 15; -pub const SIGSTKSZ : ::size_t = 40960; pub const PROT_NONE : ::c_int = 0; pub const PROT_READ : ::c_int = 1; @@ -310,6 +314,17 @@ pub const POSIX_MADV_DONTNEED : ::c_int = 4; pub const PTHREAD_CREATE_JOINABLE : ::c_int = 0; pub const PTHREAD_CREATE_DETACHED : ::c_int = 1; +pub const PT_TRACE_ME: ::c_int = 0; +pub const PT_READ_I: ::c_int = 1; +pub const PT_READ_D: ::c_int = 2; +pub const PT_WRITE_I: ::c_int = 4; +pub const PT_WRITE_D: ::c_int = 5; +pub const PT_CONTINUE: ::c_int = 7; +pub const PT_KILL: ::c_int = 8; +pub const PT_ATTACH: ::c_int = 9; +pub const PT_DETACH: ::c_int = 10; +pub const PT_IO: ::c_int = 11; + // http://man.openbsd.org/OpenBSD-current/man2/clock_getres.2 // The man page says clock_gettime(3) can accept various values as clockid_t but // http://fxr.watson.org/fxr/source/kern/kern_time.c?v=OPENBSD;im=excerpts#L161 @@ -413,8 +428,9 @@ pub const IP_TTL: ::c_int = 4; pub const IP_HDRINCL: ::c_int = 2; pub const IP_ADD_MEMBERSHIP: ::c_int = 12; pub const IP_DROP_MEMBERSHIP: ::c_int = 13; +pub const IPV6_RECVPKTINFO: ::c_int = 36; +pub const IPV6_PKTINFO: ::c_int = 46; -pub const TCP_NODELAY: ::c_int = 0x01; pub const SOL_SOCKET: ::c_int = 0xffff; pub const SO_DEBUG: ::c_int = 0x01; pub const SO_ACCEPTCONN: ::c_int = 0x0002; @@ -532,6 +548,24 @@ pub const CRTS_IFLOW: ::tcflag_t = CRTSCTS; pub const CCTS_OFLOW: ::tcflag_t = CRTSCTS; pub const OCRNL: ::tcflag_t = 0x10; +pub const TIOCEXCL: ::c_ulong = 0x2000740d; +pub const TIOCNXCL: ::c_ulong = 0x2000740e; +pub const TIOCFLUSH: ::c_ulong = 0x80047410; +pub const TIOCGETA: ::c_ulong = 0x402c7413; +pub const TIOCSETA: ::c_ulong = 0x802c7414; +pub const TIOCSETAW: ::c_ulong = 0x802c7415; +pub const TIOCSETAF: ::c_ulong = 0x802c7416; +pub const TIOCGETD: ::c_ulong = 0x4004741a; +pub const TIOCSETD: ::c_ulong = 0x8004741b; +pub const TIOCMGET: ::c_ulong = 0x4004746a; +pub const TIOCMBIC: ::c_ulong = 0x8004746b; +pub const TIOCMBIS: ::c_ulong = 0x8004746c; +pub const TIOCMSET: ::c_ulong = 0x8004746d; +pub const TIOCSTART: ::c_ulong = 0x2000746e; +pub const TIOCSTOP: ::c_ulong = 0x2000746f; +pub const TIOCSCTTY: ::c_ulong = 0x20007461; +pub const TIOCGWINSZ: ::c_ulong = 0x40087468; +pub const TIOCSWINSZ: ::c_ulong = 0x80087467; pub const TIOCM_LE: ::c_int = 0o0001; pub const TIOCM_DTR: ::c_int = 0o0002; pub const TIOCM_RTS: ::c_int = 0o0004; @@ -544,6 +578,19 @@ pub const TIOCM_DSR: ::c_int = 0o0400; pub const TIOCM_CD: ::c_int = TIOCM_CAR; pub const TIOCM_RI: ::c_int = TIOCM_RNG; +// Flags for chflags(2) +pub const UF_SETTABLE: ::c_ulong = 0x0000ffff; +pub const UF_NODUMP: ::c_ulong = 0x00000001; +pub const UF_IMMUTABLE: ::c_ulong = 0x00000002; +pub const UF_APPEND: ::c_ulong = 0x00000004; +pub const UF_OPAQUE: ::c_ulong = 0x00000008; +pub const SF_SETTABLE: ::c_ulong = 0xffff0000; +pub const SF_ARCHIVED: ::c_ulong = 0x00010000; +pub const SF_IMMUTABLE: ::c_ulong = 0x00020000; +pub const SF_APPEND: ::c_ulong = 0x00040000; + +pub const TIMER_ABSTIME: ::c_int = 1; + f! { pub fn WSTOPSIG(status: ::c_int) -> ::c_int { status >> 8 @@ -602,14 +649,14 @@ extern { pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int; pub fn setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int; - pub fn fdopendir(fd: ::c_int) -> *mut ::DIR; - pub fn mknodat(dirfd: ::c_int, pathname: *const ::c_char, mode: ::mode_t, dev: dev_t) -> ::c_int; pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char, mode: ::mode_t) -> ::c_int; pub fn sem_timedwait(sem: *mut sem_t, abstime: *const ::timespec) -> ::c_int; + pub fn sem_getvalue(sem: *mut sem_t, + sval: *mut ::c_int) -> ::c_int; pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t, clock_id: ::clockid_t) -> ::c_int; pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int; @@ -625,6 +672,8 @@ extern { pub fn fexecve(fd: ::c_int, argv: *const *const ::c_char, envp: *const *const ::c_char) -> ::c_int; + pub fn getdomainname(name: *mut ::c_char, len: ::size_t) -> ::c_int; + pub fn setdomainname(name: *const ::c_char, len: ::size_t) -> ::c_int; } cfg_if! { diff --git a/libc/src/unix/bsd/netbsdlike/netbsd/aarch64.rs b/libc/src/unix/bsd/netbsdlike/netbsd/aarch64.rs new file mode 100644 index 0000000..66f3301 --- /dev/null +++ b/libc/src/unix/bsd/netbsdlike/netbsd/aarch64.rs @@ -0,0 +1,11 @@ +use PT_FIRSTMACH; + +pub type c_long = i64; +pub type c_ulong = u64; +pub type c_char = u8; +pub type __cpu_simple_lock_nv_t = ::c_uchar; + +pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 0; +pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 1; +pub const PT_GETFPREGS: ::c_int = PT_FIRSTMACH + 2; +pub const PT_SETFPREGS: ::c_int = PT_FIRSTMACH + 3; diff --git a/libc/src/unix/bsd/netbsdlike/netbsd/arm.rs b/libc/src/unix/bsd/netbsdlike/netbsd/arm.rs new file mode 100644 index 0000000..9e67316 --- /dev/null +++ b/libc/src/unix/bsd/netbsdlike/netbsd/arm.rs @@ -0,0 +1,11 @@ +use PT_FIRSTMACH; + +pub type c_long = i32; +pub type c_ulong = u32; +pub type c_char = u8; +pub type __cpu_simple_lock_nv_t = ::c_int; + +pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1; +pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 2; +pub const PT_GETFPREGS: ::c_int = PT_FIRSTMACH + 3; +pub const PT_SETFPREGS: ::c_int = PT_FIRSTMACH + 4; diff --git a/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs b/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs index 4c528b5..55b8f4c 100644 --- a/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -1,6 +1,5 @@ use dox::mem; -pub type c_char = i8; pub type clock_t = ::c_uint; pub type suseconds_t = ::c_int; pub type dev_t = u64; @@ -9,6 +8,7 @@ pub type fsblkcnt_t = ::uint64_t; pub type fsfilcnt_t = ::uint64_t; pub type idtype_t = ::c_int; pub type mqd_t = ::c_int; +type __pthread_spin_t = __cpu_simple_lock_nv_t; s! { pub struct aiocb { @@ -161,9 +161,14 @@ s! { pub struct pthread_mutex_t { ptm_magic: ::c_uint, - ptm_errorcheck: ::c_uchar, + ptm_errorcheck: __pthread_spin_t, + #[cfg(any(target_arch = "sparc", target_arch = "sparc64", + target_arch = "x86", target_arch = "x86_64"))] ptm_pad1: [u8; 3], - ptm_interlock: ::c_uchar, + // actually a union with a non-unused, 0-initialized field + ptm_unused: __pthread_spin_t, + #[cfg(any(target_arch = "sparc", target_arch = "sparc64", + target_arch = "x86", target_arch = "x86_64"))] ptm_pad2: [u8; 3], ptm_owner: ::pthread_t, ptm_waiters: *mut u8, @@ -183,7 +188,7 @@ s! { pub struct pthread_cond_t { ptc_magic: ::c_uint, - ptc_lock: ::c_uchar, + ptc_lock: __pthread_spin_t, ptc_waiters_first: *mut u8, ptc_waiters_last: *mut u8, ptc_mutex: *mut ::pthread_mutex_t, @@ -197,7 +202,7 @@ s! { pub struct pthread_rwlock_t { ptr_magic: ::c_uint, - ptr_interlock: ::c_uchar, + ptr_interlock: __pthread_spin_t, ptr_rblocked_first: *mut u8, ptr_rblocked_last: *mut u8, ptr_wblocked_first: *mut u8, @@ -313,6 +318,20 @@ s! { pub sdl_slen: ::uint8_t, pub sdl_data: [::c_char; 12], } + + pub struct in_pktinfo { + pub ipi_addr: ::in_addr, + pub ipi_ifindex: ::c_uint, + } + + #[repr(packed)] + pub struct arphdr { + pub ar_hrd: u16, + pub ar_pro: u16, + pub ar_hln: u8, + pub ar_pln: u8, + pub ar_op: u16, + } } pub const AT_FDCWD: ::c_int = -100; @@ -321,6 +340,9 @@ pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x200; pub const AT_SYMLINK_FOLLOW: ::c_int = 0x400; pub const AT_REMOVEDIR: ::c_int = 0x800; +pub const EXTATTR_NAMESPACE_USER: ::c_int = 1; +pub const EXTATTR_NAMESPACE_SYSTEM: ::c_int = 2; + 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); @@ -371,9 +393,19 @@ pub const F_GETNOSIGPIPE: ::c_int = 13; pub const F_SETNOSIGPIPE: ::c_int = 14; pub const F_MAXFD: ::c_int = 11; +pub const IP_PKTINFO: ::c_int = 25; +pub const IP_RECVPKTINFO: ::c_int = 26; pub const IPV6_JOIN_GROUP: ::c_int = 12; pub const IPV6_LEAVE_GROUP: ::c_int = 13; +pub const TCP_KEEPIDLE: ::c_int = 3; +pub const TCP_KEEPINTVL: ::c_int = 5; +pub const TCP_KEEPCNT: ::c_int = 6; +pub const TCP_KEEPINIT: ::c_int = 7; +pub const TCP_INFO: ::c_int = 9; +pub const TCP_MD5SIG: ::c_int = 0x10; +pub const TCP_CONGCTL: ::c_int = 0x20; + pub const SOCK_CONN_DGRAM: ::c_int = 6; pub const SOCK_DCCP: ::c_int = SOCK_CONN_DGRAM; pub const SOCK_NOSIGPIPE: ::c_int = 0x40000000; @@ -675,14 +707,19 @@ pub const ST_NOSUID: ::c_ulong = 8; pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { ptm_magic: 0x33330003, ptm_errorcheck: 0, - ptm_interlock: 0, - ptm_waiters: 0 as *mut _, - ptm_owner: 0, + #[cfg(any(target_arch = "sparc", target_arch = "sparc64", + target_arch = "x86", target_arch = "x86_64"))] ptm_pad1: [0; 3], + ptm_unused: 0, + #[cfg(any(target_arch = "sparc", target_arch = "sparc64", + target_arch = "x86", target_arch = "x86_64"))] ptm_pad2: [0; 3], + ptm_waiters: 0 as *mut _, + ptm_owner: 0, ptm_recursed: 0, ptm_spare2: 0 as *mut _, }; + pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { ptc_magic: 0x55550005, ptc_lock: 0, @@ -947,6 +984,22 @@ pub const CHWFLOW: ::tcflag_t = ::MDMBUF | ::CRTSCTS | ::CDTRCTS; pub const SOCK_CLOEXEC: ::c_int = 0x10000000; pub const SOCK_NONBLOCK: ::c_int = 0x20000000; +pub const SIGSTKSZ : ::size_t = 40960; + +pub const PT_DUMPCORE: ::c_int = 12; +pub const PT_LWPINFO: ::c_int = 13; +pub const PT_SYSCALL: ::c_int = 14; +pub const PT_SYSCALLEMU: ::c_int = 15; +pub const PT_SET_EVENT_MASK: ::c_int = 16; +pub const PT_GET_EVENT_MASK: ::c_int = 17; +pub const PT_GET_PROCESS_STATE: ::c_int = 18; +pub const PT_FIRSTMACH: ::c_int = 32; + +// Flags for chflags(2) +pub const SF_SNAPSHOT: ::c_ulong = 0x00200000; +pub const SF_LOG: ::c_ulong = 0x00400000; +pub const SF_SNAPINVAL: ::c_ulong = 0x00800000; + // dirfd() is a macro on netbsd to access // the first field of the struct where dirp points to: // http://cvsweb.netbsd.org/bsdweb.cgi/src/include/dirent.h?rev=1.36 @@ -982,6 +1035,55 @@ extern { pub fn lio_listio(mode: ::c_int, aiocb_list: *const *mut aiocb, nitems: ::c_int, sevp: *mut sigevent) -> ::c_int; + 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; + + pub fn extattr_delete_fd(fd: ::c_int, + attrnamespace: ::c_int, + attrname: *const ::c_char) -> ::c_int; + pub fn extattr_delete_file(path: *const ::c_char, + attrnamespace: ::c_int, + attrname: *const ::c_char) -> ::c_int; + pub fn extattr_delete_link(path: *const ::c_char, + attrnamespace: ::c_int, + attrname: *const ::c_char) -> ::c_int; + pub fn extattr_get_fd(fd: ::c_int, + attrnamespace: ::c_int, + attrname: *const ::c_char, + data: *mut ::c_void, + nbytes: ::size_t) -> ::ssize_t; + pub fn extattr_get_file(path: *const ::c_char, + attrnamespace: ::c_int, + attrname: *const ::c_char, + data: *mut ::c_void, + nbytes: ::size_t) -> ::ssize_t; + pub fn extattr_get_link(path: *const ::c_char, + attrnamespace: ::c_int, + attrname: *const ::c_char, + data: *mut ::c_void, + nbytes: ::size_t) -> ::ssize_t; + pub fn extattr_namespace_to_string(attrnamespace: ::c_int, + string: *mut *mut ::c_char) -> ::c_int; + pub fn extattr_set_fd(fd: ::c_int, + attrnamespace: ::c_int, + attrname: *const ::c_char, + data: *const ::c_void, + nbytes: ::size_t) -> ::c_int; + pub fn extattr_set_file(path: *const ::c_char, + attrnamespace: ::c_int, + attrname: *const ::c_char, + data: *const ::c_void, + nbytes: ::size_t) -> ::c_int; + pub fn extattr_set_link(path: *const ::c_char, + attrnamespace: ::c_int, + attrname: *const ::c_char, + data: *const ::c_void, + nbytes: ::size_t) -> ::c_int; + pub fn extattr_string_to_namespace(string: *const ::c_char, + attrnamespace: *mut ::c_int) -> ::c_int; + + #[link_name = "__lutimes50"] pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int; pub fn getnameinfo(sa: *const ::sockaddr, salen: ::socklen_t, @@ -1033,11 +1135,13 @@ extern { pub fn mq_setattr(mqd: ::mqd_t, newattr: *const ::mq_attr, oldattr: *mut ::mq_attr) -> ::c_int; + #[link_name = "__mq_timedreceive50"] pub fn mq_timedreceive(mqd: ::mqd_t, msg_ptr: *mut ::c_char, msg_len: ::size_t, msq_prio: *mut ::c_uint, abs_timeout: *const ::timespec) -> ::ssize_t; + #[link_name = "__mq_timedsend50"] pub fn mq_timedsend(mqd: ::mqd_t, msg_ptr: *const ::c_char, msg_len: ::size_t, @@ -1072,7 +1176,43 @@ extern { base: ::locale_t) -> ::locale_t; #[link_name = "__settimeofday50"] pub fn settimeofday(tv: *const ::timeval, tz: *const ::c_void) -> ::c_int; + + pub fn dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::c_int; } -mod other; -pub use self::other::*; +#[link(name = "util")] +extern { + #[cfg_attr(target_os = "netbsd", link_name = "__getpwent_r50")] + pub fn getpwent_r(pwd: *mut ::passwd, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut ::passwd) -> ::c_int; + pub fn getgrent_r(grp: *mut ::group, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut ::group) -> ::c_int; +} + +cfg_if! { + if #[cfg(target_arch = "aarch64")] { + mod aarch64; + pub use self::aarch64::*; + } else if #[cfg(target_arch = "arm")] { + mod arm; + pub use self::arm::*; + } else if #[cfg(target_arch = "powerpc")] { + mod powerpc; + pub use self::powerpc::*; + } else if #[cfg(target_arch = "sparc64")] { + mod sparc64; + pub use self::sparc64::*; + } else if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } else if #[cfg(target_arch = "x86")] { + mod x86; + pub use self::x86::*; + } else { + // Unknown target_arch + } +} diff --git a/libc/src/unix/bsd/netbsdlike/netbsd/other/b32/mod.rs b/libc/src/unix/bsd/netbsdlike/netbsd/other/b32/mod.rs deleted file mode 100644 index 9b0b338..0000000 --- a/libc/src/unix/bsd/netbsdlike/netbsd/other/b32/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub type c_long = i32; -pub type c_ulong = u32; diff --git a/libc/src/unix/bsd/netbsdlike/netbsd/other/b64/mod.rs b/libc/src/unix/bsd/netbsdlike/netbsd/other/b64/mod.rs deleted file mode 100644 index b07c476..0000000 --- a/libc/src/unix/bsd/netbsdlike/netbsd/other/b64/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub type c_long = i64; -pub type c_ulong = u64; diff --git a/libc/src/unix/bsd/netbsdlike/netbsd/other/mod.rs b/libc/src/unix/bsd/netbsdlike/netbsd/other/mod.rs deleted file mode 100644 index 3a9bf08..0000000 --- a/libc/src/unix/bsd/netbsdlike/netbsd/other/mod.rs +++ /dev/null @@ -1,14 +0,0 @@ -cfg_if! { - if #[cfg(any(target_arch = "sparc64", - target_arch = "x86_64"))] { - mod b64; - pub use self::b64::*; - } else if #[cfg(any(target_arch = "arm", - target_arch = "powerpc", - target_arch = "x86"))] { - mod b32; - pub use self::b32::*; - } else { - // Unknown target_arch - } -} diff --git a/libc/src/unix/bsd/netbsdlike/netbsd/powerpc.rs b/libc/src/unix/bsd/netbsdlike/netbsd/powerpc.rs new file mode 100644 index 0000000..54d069e --- /dev/null +++ b/libc/src/unix/bsd/netbsdlike/netbsd/powerpc.rs @@ -0,0 +1,10 @@ +use PT_FIRSTMACH; + +pub type c_long = i32; +pub type c_ulong = u32; +pub type c_char = u8; +pub type __cpu_simple_lock_nv_t = ::c_int; + +pub const PT_STEP: ::c_int = PT_FIRSTMACH + 0; +pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1; +pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 2; diff --git a/libc/src/unix/bsd/netbsdlike/netbsd/sparc64.rs b/libc/src/unix/bsd/netbsdlike/netbsd/sparc64.rs new file mode 100644 index 0000000..db8f2a9 --- /dev/null +++ b/libc/src/unix/bsd/netbsdlike/netbsd/sparc64.rs @@ -0,0 +1,4 @@ +pub type c_long = i64; +pub type c_ulong = u64; +pub type c_char = i8; +pub type __cpu_simple_lock_nv_t = ::c_uchar; diff --git a/libc/src/unix/bsd/netbsdlike/netbsd/x86.rs b/libc/src/unix/bsd/netbsdlike/netbsd/x86.rs new file mode 100644 index 0000000..8bd1058 --- /dev/null +++ b/libc/src/unix/bsd/netbsdlike/netbsd/x86.rs @@ -0,0 +1,4 @@ +pub type c_long = i32; +pub type c_ulong = u32; +pub type c_char = i8; +pub type __cpu_simple_lock_nv_t = ::c_uchar; diff --git a/libc/src/unix/bsd/netbsdlike/netbsd/x86_64.rs b/libc/src/unix/bsd/netbsdlike/netbsd/x86_64.rs new file mode 100644 index 0000000..8d3de84 --- /dev/null +++ b/libc/src/unix/bsd/netbsdlike/netbsd/x86_64.rs @@ -0,0 +1,12 @@ +use PT_FIRSTMACH; + +pub type c_long = i64; +pub type c_ulong = u64; +pub type c_char = i8; +pub type __cpu_simple_lock_nv_t = ::c_uchar; + +pub const PT_STEP: ::c_int = PT_FIRSTMACH + 0; +pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1; +pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 2; +pub const PT_GETFPREGS: ::c_int = PT_FIRSTMACH + 3; +pub const PT_SETFPREGS: ::c_int = PT_FIRSTMACH + 4; diff --git a/libc/src/unix/bsd/netbsdlike/openbsdlike/bitrig/mod.rs b/libc/src/unix/bsd/netbsdlike/openbsdlike/bitrig/mod.rs index ac4acad..e5f0219 100644 --- a/libc/src/unix/bsd/netbsdlike/openbsdlike/bitrig/mod.rs +++ b/libc/src/unix/bsd/netbsdlike/openbsdlike/bitrig/mod.rs @@ -65,6 +65,28 @@ pub const ALTMON_12: ::nl_item = 69; pub const KERN_RND: ::c_int = 31; +// https://github.com/bitrig/bitrig/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 +pub const IFF_LOOPBACK: ::c_int = 0x8; // is a loopback net +pub const IFF_POINTOPOINT: ::c_int = 0x10; // interface is point-to-point link +pub const IFF_NOTRAILERS: ::c_int = 0x20; // avoid use of trailers +pub const IFF_RUNNING: ::c_int = 0x40; // resources allocated +pub const IFF_NOARP: ::c_int = 0x80; // no address resolution protocol +pub const IFF_PROMISC: ::c_int = 0x100; // receive all packets +pub const IFF_ALLMULTI: ::c_int = 0x200; // receive all multicast packets +pub const IFF_OACTIVE: ::c_int = 0x400; // transmission in progress +pub const IFF_SIMPLEX: ::c_int = 0x800; // can't hear own transmissions +pub const IFF_LINK0: ::c_int = 0x1000; // per link layer defined bit +pub const IFF_LINK1: ::c_int = 0x2000; // per link layer defined bit +pub const IFF_LINK2: ::c_int = 0x4000; // per link layer defined bit +pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast + +pub const SIGSTKSZ : ::size_t = 40960; + +pub const PT_FIRSTMACH: ::c_int = 32; + extern { pub fn nl_langinfo_l(item: ::nl_item, locale: ::locale_t) -> *mut ::c_char; pub fn duplocale(base: ::locale_t) -> ::locale_t; @@ -73,6 +95,8 @@ extern { locale: *const ::c_char, base: ::locale_t) -> ::locale_t; pub fn uselocale(loc: ::locale_t) -> ::locale_t; + pub fn pledge(promises: *const ::c_char, + paths: *mut *const ::c_char) -> ::c_int; pub fn querylocale(mask: ::c_int, loc: ::locale_t) -> *const ::c_char; } diff --git a/libc/src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86_64.rs b/libc/src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86_64.rs index b07c476..d3971aa 100644 --- a/libc/src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86_64.rs +++ b/libc/src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86_64.rs @@ -1,2 +1,10 @@ +use PT_FIRSTMACH; + pub type c_long = i64; pub type c_ulong = u64; + +pub const PT_STEP: ::c_int = PT_FIRSTMACH + 0; +pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1; +pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 2; +pub const PT_GETFPREGS: ::c_int = PT_FIRSTMACH + 3; +pub const PT_SETFPREGS: ::c_int = PT_FIRSTMACH + 4; diff --git a/libc/src/unix/bsd/netbsdlike/openbsdlike/mod.rs b/libc/src/unix/bsd/netbsdlike/openbsdlike/mod.rs index 1f40e34..85f0a02 100644 --- a/libc/src/unix/bsd/netbsdlike/openbsdlike/mod.rs +++ b/libc/src/unix/bsd/netbsdlike/openbsdlike/mod.rs @@ -14,6 +14,7 @@ pub type pthread_cond_t = *mut ::c_void; pub type pthread_condattr_t = *mut ::c_void; pub type pthread_rwlock_t = *mut ::c_void; pub type pthread_rwlockattr_t = *mut ::c_void; +pub type caddr_t = *mut ::c_char; s! { pub struct dirent { @@ -187,6 +188,20 @@ s! { pub sdl_slen: ::c_uchar, pub sdl_data: [::c_char; 24], } + + pub struct sockpeercred { + pub uid: ::uid_t, + pub gid: ::gid_t, + pub pid: ::pid_t, + } + + pub struct arphdr { + pub ar_hrd: u16, + pub ar_pro: u16, + pub ar_hln: u8, + pub ar_pln: u8, + pub ar_op: u16, + } } pub const UT_NAMESIZE: usize = 32; @@ -236,24 +251,6 @@ pub const SO_RTABLE: ::c_int = 0x1021; pub const SO_PEERCRED: ::c_int = 0x1022; pub const SO_SPLICE: ::c_int = 0x1023; -// 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 -pub const IFF_LOOPBACK: ::c_int = 0x8; // is a loopback net -pub const IFF_POINTOPOINT: ::c_int = 0x10; // interface is point-to-point link -pub const IFF_NOTRAILERS: ::c_int = 0x20; // avoid use of trailers -pub const IFF_RUNNING: ::c_int = 0x40; // resources allocated -pub const IFF_NOARP: ::c_int = 0x80; // no address resolution protocol -pub const IFF_PROMISC: ::c_int = 0x100; // receive all packets -pub const IFF_ALLMULTI: ::c_int = 0x200; // receive all multicast packets -pub const IFF_OACTIVE: ::c_int = 0x400; // transmission in progress -pub const IFF_SIMPLEX: ::c_int = 0x800; // can't hear own transmissions -pub const IFF_LINK0: ::c_int = 0x1000; // per link layer defined bit -pub const IFF_LINK1: ::c_int = 0x2000; // per link layer defined bit -pub const IFF_LINK2: ::c_int = 0x4000; // per link layer defined bit -pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast - // sys/netinet/in.h // Protocols (RFC 1700) // NOTE: These are in addition to the constants defined in src/unix/mod.rs @@ -320,6 +317,13 @@ pub const IPPROTO_MAX: ::c_int = 256; /// Divert sockets pub const IPPROTO_DIVERT: ::c_int = 258; +pub const IP_RECVDSTADDR: ::c_int = 7; +pub const IP_SENDSRCADDR: ::c_int = IP_RECVDSTADDR; + +// sys/netinet/in.h +pub const TCP_MD5SIG: ::c_int = 0x04; +pub const TCP_NOPUSH: ::c_int = 0x10; + pub const AF_ECMA: ::c_int = 8; pub const AF_ROUTE: ::c_int = 17; pub const AF_ENCAP: ::c_int = 28; @@ -588,6 +592,7 @@ pub const CTL_MACHDEP: ::c_int = 7; pub const CTL_DDB: ::c_int = 9; pub const CTL_VFS: ::c_int = 10; pub const CTL_MAXID: ::c_int = 11; +pub const HW_NCPUONLINE: ::c_int = 25; pub const KERN_OSTYPE: ::c_int = 1; pub const KERN_OSRELEASE: ::c_int = 2; pub const KERN_OSREV: ::c_int = 3; @@ -662,7 +667,9 @@ pub const KERN_PROC_VMMAP: ::c_int = 80; pub const KERN_GLOBAL_PTRACE: ::c_int = 81; pub const KERN_CONSBUFSIZE: ::c_int = 82; pub const KERN_CONSBUF: ::c_int = 83; -pub const KERN_MAXID: ::c_int = 84; +pub const KERN_AUDIO: ::c_int = 84; +pub const KERN_CPUSTATS: ::c_int = 85; +pub const KERN_MAXID: ::c_int = 86; pub const KERN_PROC_ALL: ::c_int = 0; pub const KERN_PROC_PID: ::c_int = 1; pub const KERN_PROC_PGRP: ::c_int = 2; @@ -694,6 +701,8 @@ pub const SOCK_CLOEXEC: ::c_int = 0x8000; pub const SOCK_NONBLOCK: ::c_int = 0x4000; pub const SOCK_DNS: ::c_int = 0x1000; +pub const PTRACE_FORK: ::c_int = 0x0002; + pub const WCONTINUED: ::c_int = 8; f! { @@ -703,6 +712,10 @@ f! { } extern { + pub fn chflags(path: *const ::c_char, flags: ::c_uint) -> ::c_int; + pub fn fchflags(fd: ::c_int, flags: ::c_uint) -> ::c_int; + pub fn chflagsat(fd: ::c_int, path: *const ::c_char, flags: ::c_uint, + atflag: ::c_int) -> ::c_int; pub fn dirfd(dirp: *mut ::DIR) -> ::c_int; pub fn getnameinfo(sa: *const ::sockaddr, salen: ::socklen_t, @@ -731,10 +744,12 @@ extern { newlen: ::size_t) -> ::c_int; pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int; - pub fn pledge(promises: *const ::c_char, - paths: *mut *const ::c_char) -> ::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; } cfg_if! { diff --git a/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs b/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs index e7e5876..a2a7a30 100644 --- a/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs +++ b/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs @@ -25,13 +25,246 @@ s! { pub int_p_sign_posn: ::c_char, pub int_n_sign_posn: ::c_char, } + + pub struct statfs { + pub f_flags: ::uint32_t, + pub f_bsize: ::uint32_t, + pub f_iosize: ::uint32_t, + pub f_blocks: ::uint64_t, + pub f_bfree: ::uint64_t, + pub f_bavail: ::int64_t, + pub f_files: ::uint64_t, + pub f_ffree: ::uint64_t, + pub f_favail: ::int64_t, + pub f_syncwrites: ::uint64_t, + pub f_syncreads: ::uint64_t, + pub f_asyncwrites: ::uint64_t, + pub f_asyncreads: ::uint64_t, + pub f_fsid: ::fsid_t, + pub f_namemax: ::uint32_t, + pub f_owner: ::uid_t, + pub f_ctime: ::uint64_t, + pub f_fstypename: [::c_char; 16], + pub f_mntonname: [::c_char; 90], + pub f_mntfromname: [::c_char; 90], + pub f_mntfromspec: [::c_char; 90], + pub mount_info: mount_info, + } + + pub union mount_info { + pub ufs_args: ufs_args, + pub mfs_args: mfs_args, + pub nfs_args: nfs_args, + pub iso_args: iso_args, + pub msdosfs_args: msdosfs_args, + pub ntfs_args: ntfs_args, + pub tmpfs_args: tmpfs_args, + align: [::c_char; 160], + } + + pub struct ufs_args { + pub fspec: *mut ::c_char, + pub export_info: export_args, + } + + pub struct mfs_args { + pub fspec: *mut ::c_char, + pub export_info: export_args, + // https://github.com/openbsd/src/blob/master/sys/sys/types.h#L134 + pub base: *mut ::c_char, + pub size: ::c_ulong, + } + + pub struct iso_args { + pub fspec: *mut ::c_char, + pub export_info: export_args, + pub flags: ::c_int, + pub sess: ::c_int, + } + + pub struct nfs_args { + pub version: ::c_int, + pub addr: *mut ::sockaddr, + pub addrlen: ::c_int, + pub sotype: ::c_int, + pub proto: ::c_int, + pub fh: *mut ::c_uchar, + pub fhsize: ::c_int, + pub flags: ::c_int, + pub wsize: ::c_int, + pub rsize: ::c_int, + pub readdirsize: ::c_int, + pub timeo: ::c_int, + pub retrans: ::c_int, + pub maxgrouplist: ::c_int, + pub readahead: ::c_int, + pub leaseterm: ::c_int, + pub deadthresh: ::c_int, + pub hostname: *mut ::c_char, + pub acregmin: ::c_int, + pub acregmax: ::c_int, + pub acdirmin: ::c_int, + pub acdirmax: ::c_int, + } + + pub struct msdosfs_args { + pub fspec: *mut ::c_char, + pub export_info: export_args, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub mask: ::mode_t, + pub flags: ::c_int, + } + + pub struct ntfs_args { + pub fspec: *mut ::c_char, + pub export_info: export_args, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub mode: ::mode_t, + pub flag: ::c_ulong, + } + + pub struct udf_args { + pub fspec: *mut ::c_char, + pub lastblock: ::uint32_t, + } + + pub struct tmpfs_args { + pub ta_version: ::c_int, + pub ta_nodes_max: ::ino_t, + pub ta_size_max: ::off_t, + pub ta_root_uid: ::uid_t, + pub ta_root_gid: ::gid_t, + pub ta_root_mode: ::mode_t, + } + + pub struct fusefs_args { + pub name: *mut ::c_char, + pub fd: ::c_int, + pub max_read: ::c_int, + pub allow_other: ::c_int, + } + + pub struct xucred { + pub cr_uid: ::uid_t, + pub cr_gid: ::gid_t, + pub cr_ngroups: ::c_short, + //https://github.com/openbsd/src/blob/master/sys/sys/syslimits.h#L44 + pub cr_groups: [::gid_t; 16], + } + + pub struct export_args { + pub ex_flags: ::c_int, + pub ex_root: ::uid_t, + pub ex_anon: xucred, + pub ex_addr: *mut ::sockaddr, + pub ex_addrlen: ::c_int, + pub ex_mask: *mut ::sockaddr, + pub ex_masklen: ::c_int, + } } +//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 +pub const ISOFSMNT_NOJOLIET: ::c_int = 0x8; // disable Joliet Ext +pub const ISOFSMNT_SESS: ::c_int = 0x10; // use iso_args.sess + +pub const NFS_ARGSVERSION: ::c_int = 4; // change when nfs_args changes + +pub const NFSMNT_RESVPORT: ::c_int = 0; // always use reserved ports +pub const NFSMNT_SOFT: ::c_int = 0x1; // soft mount (hard is default) +pub const NFSMNT_WSIZE: ::c_int = 0x2; // set write size +pub const NFSMNT_RSIZE: ::c_int = 0x4; // set read size +pub const NFSMNT_TIMEO: ::c_int = 0x8; // set initial timeout +pub const NFSMNT_RETRANS: ::c_int = 0x10; // set number of request retries +pub const NFSMNT_MAXGRPS: ::c_int = 0x20; // set maximum grouplist size +pub const NFSMNT_INT: ::c_int = 0x40; // allow interrupts on hard mount +pub const NFSMNT_NOCONN: ::c_int = 0x80; // Don't Connect the socket +pub const NFSMNT_NQNFS: ::c_int = 0x100; // Use Nqnfs protocol +pub const NFSMNT_NFSV3: ::c_int = 0x200; // Use NFS Version 3 protocol +pub const NFSMNT_KERB: ::c_int = 0x400; // Use Kerberos authentication +pub const NFSMNT_DUMBTIMR: ::c_int = 0x800; // Don't estimate rtt dynamically +pub const NFSMNT_LEASETERM: ::c_int = 0x1000; // set lease term (nqnfs) +pub const NFSMNT_READAHEAD: ::c_int = 0x2000; // set read ahead +pub const NFSMNT_DEADTHRESH: ::c_int = 0x4000; // set dead server retry thresh +pub const NFSMNT_NOAC: ::c_int = 0x8000; // disable attribute cache +pub const NFSMNT_RDIRPLUS: ::c_int = 0x10000; // Use Readdirplus for V3 +pub const NFSMNT_READDIRSIZE: ::c_int = 0x20000; // Set readdir size + +/* Flags valid only in mount syscall arguments */ +pub const NFSMNT_ACREGMIN: ::c_int = 0x40000; // acregmin field valid +pub const NFSMNT_ACREGMAX: ::c_int = 0x80000; // acregmax field valid +pub const NFSMNT_ACDIRMIN: ::c_int = 0x100000; // acdirmin field valid +pub const NFSMNT_ACDIRMAX: ::c_int = 0x200000; // acdirmax field valid + +/* Flags valid only in kernel */ +pub const NFSMNT_INTERNAL: ::c_int = 0xfffc0000; // Bits set internally +pub const NFSMNT_HASWRITEVERF: ::c_int = 0x40000; // Has write verifier for V3 +pub const NFSMNT_GOTPATHCONF: ::c_int = 0x80000; // Got the V3 pathconf info +pub const NFSMNT_GOTFSINFO: ::c_int = 0x100000; // Got the V3 fsinfo +pub const NFSMNT_MNTD: ::c_int = 0x200000; // Mnt server for mnt point +pub const NFSMNT_DISMINPROG: ::c_int = 0x400000; // Dismount in progress +pub const NFSMNT_DISMNT: ::c_int = 0x800000; // Dismounted +pub const NFSMNT_SNDLOCK: ::c_int = 0x1000000; // Send socket lock +pub const NFSMNT_WANTSND: ::c_int = 0x2000000; // Want above +pub const NFSMNT_RCVLOCK: ::c_int = 0x4000000; // Rcv socket lock +pub const NFSMNT_WANTRCV: ::c_int = 0x8000000; // Want above +pub const NFSMNT_WAITAUTH: ::c_int = 0x10000000; // Wait for authentication +pub const NFSMNT_HASAUTH: ::c_int = 0x20000000; // Has authenticator +pub const NFSMNT_WANTAUTH: ::c_int = 0x40000000; // Wants an authenticator +pub const NFSMNT_AUTHERR: ::c_int = 0x80000000; // Authentication error + +pub const MSDOSFSMNT_SHORTNAME: ::c_int = 0x1; // Force old DOS short names only +pub const MSDOSFSMNT_LONGNAME: ::c_int = 0x2; // Force Win'95 long names +pub const MSDOSFSMNT_NOWIN95: ::c_int = 0x4; // Completely ignore Win95 entries + +pub const NTFS_MFLAG_CASEINS: ::c_int = 0x1; +pub const NTFS_MFLAG_ALLNAMES: ::c_int = 0x2; + +pub const TMPFS_ARGS_VERSION: ::c_int = 1; + +pub const MAP_STACK : ::c_int = 0x4000; + +// 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 +pub const IFF_LOOPBACK: ::c_int = 0x8; // is a loopback net +pub const IFF_POINTOPOINT: ::c_int = 0x10; // interface is point-to-point link +pub const IFF_STATICARP: ::c_int = 0x20; // only static ARP +pub const IFF_RUNNING: ::c_int = 0x40; // resources allocated +pub const IFF_NOARP: ::c_int = 0x80; // no address resolution protocol +pub const IFF_PROMISC: ::c_int = 0x100; // receive all packets +pub const IFF_ALLMULTI: ::c_int = 0x200; // receive all multicast packets +pub const IFF_OACTIVE: ::c_int = 0x400; // transmission in progress +pub const IFF_SIMPLEX: ::c_int = 0x800; // can't hear own transmissions +pub const IFF_LINK0: ::c_int = 0x1000; // per link layer defined bit +pub const IFF_LINK1: ::c_int = 0x2000; // per link layer defined bit +pub const IFF_LINK2: ::c_int = 0x4000; // per link layer defined bit +pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast + +pub const SIGSTKSZ : ::size_t = 28672; + +pub const PT_FIRSTMACH: ::c_int = 32; + extern { pub fn accept4(s: ::c_int, addr: *mut ::sockaddr, addrlen: *mut ::socklen_t, flags: ::c_int) -> ::c_int; pub fn execvpe(file: *const ::c_char, argv: *const *const ::c_char, envp: *const *const ::c_char) -> ::c_int; + pub fn pledge(promises: *const ::c_char, + execpromises: *const ::c_char) -> ::c_int; + pub fn strtonum(nptr: *const ::c_char, minval: ::c_longlong, + maxval: ::c_longlong, + errstr: *mut *const ::c_char) -> ::c_longlong; + + pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int; + pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int; + + pub fn dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::c_int; } cfg_if! { diff --git a/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/x86_64.rs b/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/x86_64.rs index 27b9412..3bc7f52 100644 --- a/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/x86_64.rs +++ b/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/x86_64.rs @@ -1,3 +1,11 @@ +use PT_FIRSTMACH; + pub type c_long = i64; pub type c_ulong = u64; pub type c_char = i8; + +pub const PT_STEP: ::c_int = PT_FIRSTMACH + 0; +pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1; +pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 2; +pub const PT_GETFPREGS: ::c_int = PT_FIRSTMACH + 3; +pub const PT_SETFPREGS: ::c_int = PT_FIRSTMACH + 4; diff --git a/libc/src/unix/haiku/mod.rs b/libc/src/unix/haiku/mod.rs index 9b0252d..e65bca7 100644 --- a/libc/src/unix/haiku/mod.rs +++ b/libc/src/unix/haiku/mod.rs @@ -351,6 +351,10 @@ pub const F_SETLK: ::c_int = 0x0080; pub const F_SETLKW: ::c_int = 0x0100; pub const F_DUPFD_CLOEXEC: ::c_int = 0x0200; +pub const F_RDLCK: ::c_int = 0x0040; +pub const F_UNLCK: ::c_int = 0x0200; +pub const F_WRLCK: ::c_int = 0x0400; + pub const AT_FDCWD: ::c_int = -1; pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x01; pub const AT_SYMLINK_FOLLOW: ::c_int = 0x02; @@ -379,6 +383,7 @@ pub const RLIMIT_CPU: ::c_int = 1; pub const RLIMIT_DATA: ::c_int = 2; pub const RLIMIT_FSIZE: ::c_int = 3; pub const RLIMIT_NOFILE: ::c_int = 4; +pub const RLIMIT_STACK: ::c_int = 5; pub const RLIMIT_AS: ::c_int = 6; // Haiku specific pub const RLIMIT_NOVMON: ::c_int = 7; @@ -386,7 +391,7 @@ pub const RLIMIT_NLIMITS: ::c_int = 8; pub const RUSAGE_SELF: ::c_int = 0; -pub const RTLD_LAXY: ::c_int = 0; +pub const RTLD_LAZY: ::c_int = 0; pub const NCCS: usize = 11; @@ -645,22 +650,43 @@ pub const AF_UNIX: ::c_int = AF_LOCAL; pub const AF_BLUETOOTH: ::c_int = 10; pub const AF_MAX: ::c_int = 11; +pub const IP_OPTIONS: ::c_int = 1; +pub const IP_HDRINCL: ::c_int = 2; +pub const IP_TOS: ::c_int = 3; +pub const IP_TTL: ::c_int = 4; +pub const IP_RECVOPTS: ::c_int = 5; +pub const IP_RECVRETOPTS: ::c_int = 6; +pub const IP_RECVDSTADDR: ::c_int = 7; +pub const IP_RETOPTS: ::c_int = 8; +pub const IP_MULTICAST_IF: ::c_int = 9; pub const IP_MULTICAST_TTL: ::c_int = 10; pub const IP_MULTICAST_LOOP: ::c_int = 11; -pub const IP_TTL: ::c_int = 4; -pub const IP_HDRINCL: ::c_int = 2; pub const IP_ADD_MEMBERSHIP: ::c_int = 12; pub const IP_DROP_MEMBERSHIP: ::c_int = 13; +pub const IP_BLOCK_SOURCE: ::c_int = 14; +pub const IP_UNBLOCK_SOURCE: ::c_int = 15; +pub const IP_ADD_SOURCE_MEMBERSHIP: ::c_int = 16; +pub const IP_DROP_SOURCE_MEMBERSHIP: ::c_int = 17; pub const TCP_NODELAY: ::c_int = 0x01; pub const TCP_MAXSEG: ::c_int = 0x02; pub const TCP_NOPUSH: ::c_int = 0x04; pub const TCP_NOOPT: ::c_int = 0x08; +pub const IPV6_MULTICAST_IF: ::c_int = 24; +pub const IPV6_MULTICAST_HOPS: ::c_int = 25; pub const IPV6_MULTICAST_LOOP: ::c_int = 26; +pub const IPV6_UNICAST_HOPS: ::c_int = 27; pub const IPV6_JOIN_GROUP: ::c_int = 28; pub const IPV6_LEAVE_GROUP: ::c_int = 29; pub const IPV6_V6ONLY: ::c_int = 30; +pub const IPV6_PKTINFO: ::c_int = 31; +pub const IPV6_RECVPKTINFO: ::c_int = 32; +pub const IPV6_HOPLIMIT: ::c_int = 33; +pub const IPV6_REVCHOPLIMIT: ::c_int = 34; +pub const IPV6_HOPOPTS: ::c_int = 35; +pub const IPV6_DSTOPTS: ::c_int = 36; +pub const IPV6_RTHDR: ::c_int = 37; pub const MSG_OOB: ::c_int = 0x0001; pub const MSG_PEEK: ::c_int = 0x0002; @@ -701,7 +727,9 @@ pub const SA_ONESHOT: ::c_int = SA_RESETHAND; pub const FD_SETSIZE: usize = 1024; +pub const RTLD_LOCAL: ::c_int = 0x0; pub const RTLD_NOW: ::c_int = 0x1; +pub const RTLD_GLOBAL: ::c_int = 0x2; pub const RTLD_DEFAULT: *mut ::c_void = 0isize as *mut ::c_void; pub const BUFSIZ: ::c_uint = 8192; @@ -1058,6 +1086,14 @@ f! { } } +extern { + pub fn abs(i: ::c_int) -> ::c_int; + pub fn atof(s: *const ::c_char) -> ::c_double; + pub fn labs(i: ::c_long) -> ::c_long; + pub fn rand() -> ::c_int; + pub fn srand(seed: ::c_uint); +} + #[link(name = "bsd")] extern { pub fn clock_gettime(clk_id: ::c_int, tp: *mut ::timespec) -> ::c_int; @@ -1094,7 +1130,6 @@ extern { pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t, options: ::c_int) -> ::c_int; - pub fn fdopendir(fd: ::c_int) -> *mut ::DIR; pub fn glob(pattern: *const ::c_char, flags: ::c_int, errfunc: Option<extern fn(epath: *const ::c_char, diff --git a/libc/src/unix/hermit/aarch64.rs b/libc/src/unix/hermit/aarch64.rs new file mode 100644 index 0000000..1a92e3b --- /dev/null +++ b/libc/src/unix/hermit/aarch64.rs @@ -0,0 +1,2 @@ +pub type c_char = u8; +pub type wchar_t = u32; diff --git a/libc/src/unix/hermit/mod.rs b/libc/src/unix/hermit/mod.rs new file mode 100644 index 0000000..aadfa1c --- /dev/null +++ b/libc/src/unix/hermit/mod.rs @@ -0,0 +1,742 @@ +// Copyright 2018 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. + +// liblibc port for HermitCore (https://hermitcore.org) +// HermitCore is a unikernel based on lwIP, newlib, and +// pthread-embedded. +// Consider these definitions when porting liblibc to another +// lwIP/newlib/pte-based target. +// +// Ported by Colin Finck <colin.finck@rwth-aachen.de> + +pub type c_long = i64; +pub type c_ulong = u64; + +pub type uid_t = u16; +pub type gid_t = u16; +pub type speed_t = ::c_uint; +pub type mode_t = u32; +pub type dev_t = i16; +pub type nfds_t = ::c_ulong; +pub type socklen_t = u32; +pub type sa_family_t = u8; +pub type clock_t = c_ulong; +pub type time_t = c_long; +pub type suseconds_t = c_long; +pub type off_t = i64; +pub type rlim_t = ::c_ulonglong; +pub type sigset_t = ::c_ulong; +pub type ino_t = u16; +pub type nlink_t = u16; +pub type blksize_t = c_long; +pub type blkcnt_t = c_long; +pub type stat64 = stat; +pub type clockid_t = c_ulong; +pub type pthread_t = pte_handle_t; +pub type pthread_attr_t = usize; +pub type pthread_cond_t = usize; +pub type pthread_condattr_t = usize; +pub type pthread_key_t = usize; +pub type pthread_mutex_t = usize; +pub type pthread_mutexattr_t = usize; +pub type pthread_rwlock_t = usize; +pub type pthread_rwlockattr_t = usize; + +s! { + pub struct addrinfo { + pub ai_flags: ::c_int, + pub ai_family: ::c_int, + pub ai_socktype: ::c_int, + pub ai_protocol: ::c_int, + pub ai_addrlen: socklen_t, + pub ai_addr: *mut ::sockaddr, + pub ai_canonname: *mut c_char, + pub ai_next: *mut addrinfo, + } + + pub struct dirent { + pub d_ino: ::c_long, + pub d_off: off_t, + pub d_reclen: u16, + pub d_name: [::c_char; 256], + } + + pub struct Dl_info {} + + pub struct fd_set { + fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE], + } + + pub struct lconv { + pub decimal_point: *mut ::c_char, + pub thousands_sep: *mut ::c_char, + pub grouping: *mut ::c_char, + pub int_curr_symbol: *mut ::c_char, + pub currency_symbol: *mut ::c_char, + pub mon_decimal_point: *mut ::c_char, + pub mon_thousands_sep: *mut ::c_char, + pub mon_grouping: *mut ::c_char, + pub positive_sign: *mut ::c_char, + pub negative_sign: *mut ::c_char, + pub int_frac_digits: ::c_char, + pub frac_digits: ::c_char, + pub p_cs_precedes: ::c_char, + pub p_sep_by_space: ::c_char, + pub n_cs_precedes: ::c_char, + pub n_sep_by_space: ::c_char, + pub p_sign_posn: ::c_char, + pub n_sign_posn: ::c_char, + pub int_p_cs_precedes: ::c_char, + pub int_p_sep_by_space: ::c_char, + pub int_n_cs_precedes: ::c_char, + pub int_n_sep_by_space: ::c_char, + pub int_p_sign_posn: ::c_char, + pub int_n_sign_posn: ::c_char, + } + + pub struct passwd { // Unverified + pub pw_name: *mut ::c_char, + pub pw_passwd: *mut ::c_char, + pub pw_uid: ::uid_t, + pub pw_gid: ::gid_t, + pub pw_gecos: *mut ::c_char, + pub pw_dir: *mut ::c_char, + pub pw_shell: *mut ::c_char, + } + + pub struct pte_handle_t { + pub p: usize, + pub x: ::c_uint, + } + + pub struct sched_param { + pub sched_priority: ::c_int, + } + + pub struct sem_t { + pub value: i32, + pub lock: usize, + pub sem: usize, + } + + pub struct sigaction { + pub sa_flags: ::c_int, + pub sa_mask: sigset_t, + pub sa_handler: usize, + } + + pub struct sockaddr { + pub sa_len: u8, + pub sa_family: sa_family_t, + pub sa_data: [::c_char; 14], + } + + pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: sa_family_t, + pub sin_port: ::in_port_t, + pub sin_addr: ::in_addr, + pub sin_zero: [::c_char; 8], + } + + pub struct sockaddr_in6 { + pub sin6_len: u8, + pub sin6_family: sa_family_t, + pub sin6_port: ::in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: ::in6_addr, + pub sin6_scope_id: u32, + } + + pub struct sockaddr_storage { + pub s2_len: u8, + pub ss_family: sa_family_t, + pub s2_data1: [::c_char; 2], + pub s2_data2: [u32; 3], + pub s2_data3: [u32; 3], + } + + // Dummy + pub struct sockaddr_un { + pub sun_family: sa_family_t, + pub sun_path: [::c_char; 108], + } + + 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_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: dev_t, + pub st_size: off_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_blksize: blksize_t, + pub st_blocks: blkcnt_t, + pub st_spare4: [::c_long; 2], + } + + pub struct statvfs {} + + pub struct tm { + pub tm_sec: ::c_int, + pub tm_min: ::c_int, + pub tm_hour: ::c_int, + pub tm_mday: ::c_int, + pub tm_mon: ::c_int, + pub tm_year: ::c_int, + pub tm_wday: ::c_int, + pub tm_yday: ::c_int, + pub tm_isdst: ::c_int, + } + + pub struct tms { + pub tms_utime: ::clock_t, + pub tms_stime: ::clock_t, + pub tms_cutime: ::clock_t, + pub tms_cstime: ::clock_t, + } + + pub struct termios {} + + pub struct utsname {} +} + +pub const AF_UNSPEC: ::c_int = 0; +pub const AF_INET: ::c_int = 2; +pub const AF_INET6: ::c_int = 10; + +// Dummy +pub const AF_UNIX: ::c_int = 1; + +pub const CLOCK_REALTIME: ::clockid_t = 1; +pub const CLOCK_MONOTONIC: ::clockid_t = 4; + +// Dummy +pub const EAI_SYSTEM: ::c_int = -11; + +pub const EPERM: ::c_int = 1; +pub const ENOENT: ::c_int = 2; +pub const ESRCH: ::c_int = 3; +pub const EINTR: ::c_int = 4; +pub const EIO: ::c_int = 5; +pub const ENXIO: ::c_int = 6; +pub const E2BIG: ::c_int = 7; +pub const ENOEXEC: ::c_int = 8; +pub const EBADF: ::c_int = 9; +pub const ECHILD: ::c_int = 10; +pub const EAGAIN: ::c_int = 11; +pub const ENOMEM: ::c_int = 12; +pub const EACCES: ::c_int = 13; +pub const EFAULT: ::c_int = 14; +pub const EBUSY: ::c_int = 16; +pub const EEXIST: ::c_int = 17; +pub const EXDEV: ::c_int = 18; +pub const ENODEV: ::c_int = 19; +pub const ENOTDIR: ::c_int = 20; +pub const EISDIR: ::c_int = 21; +pub const EINVAL: ::c_int = 22; +pub const ENFILE: ::c_int = 23; +pub const EMFILE: ::c_int = 24; +pub const ENOTTY: ::c_int = 25; +pub const ETXTBSY: ::c_int = 26; +pub const EFBIG: ::c_int = 27; +pub const ENOSPC: ::c_int = 28; +pub const ESPIPE: ::c_int = 29; +pub const EROFS: ::c_int = 30; +pub const EMLINK: ::c_int = 31; +pub const EPIPE: ::c_int = 32; +pub const EDOM: ::c_int = 33; +pub const ERANGE: ::c_int = 34; +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 EWOULDBLOCK: ::c_int = EAGAIN; +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 EDEADLOCK: ::c_int = EDEADLK; +pub const EBFONT: ::c_int = 59; +pub const ENOSTR: ::c_int = 60; +pub const ENODATA: ::c_int = 61; +pub const ETIME: ::c_int = 62; +pub const ENOSR: ::c_int = 63; +pub const ENONET: ::c_int = 64; +pub const ENOPKG: ::c_int = 65; +pub const EREMOTE: ::c_int = 66; +pub const ENOLINK: ::c_int = 67; +pub const EADV: ::c_int = 68; +pub const ESRMNT: ::c_int = 69; +pub const ECOMM: ::c_int = 70; +pub const EPROTO: ::c_int = 71; +pub const EMULTIHOP: ::c_int = 72; +pub const EDOTDOT: ::c_int = 73; +pub const EBADMSG: ::c_int = 74; +pub const EOVERFLOW: ::c_int = 75; +pub const ENOTUNIQ: ::c_int = 76; +pub const EBADFD: ::c_int = 77; +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 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 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 ERFKILL: ::c_int = 132; +pub const EHWPOISON: ::c_int = 133; + +pub const EXIT_FAILURE: ::c_int = 1; +pub const EXIT_SUCCESS: ::c_int = 0; + +pub const F_DUPFD: ::c_int = 0; +pub const F_GETFD: ::c_int = 1; +pub const F_SETFD: ::c_int = 2; +pub const F_GETFL: ::c_int = 3; +pub const F_SETFL: ::c_int = 4; +pub const F_GETOWN: ::c_int = 5; +pub const F_SETOWN: ::c_int = 6; +pub const F_GETLK: ::c_int = 7; +pub const F_SETLK: ::c_int = 8; +pub const F_SETLKW: ::c_int = 9; +pub const F_RGETLK: ::c_int = 10; +pub const F_RSETLK: ::c_int = 11; +pub const F_CNVT: ::c_int = 12; +pub const F_RSETLKW: ::c_int = 13; +pub const F_DUPFD_CLOEXEC: ::c_int = 14; + +pub const FD_SETSIZE: usize = 1024; + +// Dummy +pub const FIOCLEX: ::c_int = 0x5451; + +pub const FIONBIO: ::c_int = 0x8004667e; +pub const FIONREAD: ::c_int = 0x4004667f; + +pub const IP_ADD_MEMBERSHIP: ::c_int = 3; +pub const IP_DROP_MEMBERSHIP: ::c_int = 4; + +pub const IP_TOS: ::c_int = 1; +pub const IP_TTL: ::c_int = 2; + +pub const IP_MULTICAST_TTL: ::c_int = 5; +pub const IP_MULTICAST_IF: ::c_int = 6; +pub const IP_MULTICAST_LOOP: ::c_int = 7; + +pub const IPV6_JOIN_GROUP: ::c_int = 12; +pub const IPV6_ADD_MEMBERSHIP: ::c_int = 12; +pub const IPV6_LEAVE_GROUP: ::c_int = 13; +pub const IPV6_DROP_MEMBERSHIP: ::c_int = 13; +pub const IPV6_V6ONLY: ::c_int = 27; + +// Dummy +pub const IPV6_MULTICAST_LOOP: ::c_int = 7; + +pub const MSG_PEEK: ::c_int = 0x01; +pub const MSG_WAITALL: ::c_int = 0x02; +pub const MSG_OOB: ::c_int = 0x04; +pub const MSG_DONTWAIT: ::c_int = 0x08; +pub const MSG_MORE: ::c_int = 0x10; + +pub const O_ACCMODE: ::c_int = 3; +pub const O_RDONLY: ::c_int = 0; +pub const O_WRONLY: ::c_int = 1; +pub const O_RDWR: ::c_int = 2; +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_TRUNC: ::c_int = 512; +pub const O_CLOEXEC: ::c_int = 524288; + +pub const POLLIN: ::c_short = 0x1; +pub const POLLPRI: ::c_short = 0x2; +pub const POLLOUT: ::c_short = 0x4; +pub const POLLERR: ::c_short = 0x8; +pub const POLLHUP: ::c_short = 0x10; +pub const POLLNVAL: ::c_short = 0x20; + +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = usize::max_value(); +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = usize::max_value(); +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = usize::max_value(); + +pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; +pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; +pub const PTHREAD_STACK_MIN: ::size_t = 0; + +// Dummy +pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void; + +pub const _SC_ARG_MAX: ::c_int = 0; +pub const _SC_CHILD_MAX: ::c_int = 1; +pub const _SC_CLK_TCK: ::c_int = 2; +pub const _SC_NGROUPS_MAX: ::c_int = 3; +pub const _SC_OPEN_MAX: ::c_int = 4; +pub const _SC_JOB_CONTROL: ::c_int = 5; +pub const _SC_SAVED_IDS: ::c_int = 6; +pub const _SC_VERSION: ::c_int = 7; +pub const _SC_PAGESIZE: ::c_int = 8; +pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE; +pub const _SC_NPROCESSORS_CONF: ::c_int = 9; +pub const _SC_NPROCESSORS_ONLN: ::c_int = 10; +pub const _SC_PHYS_PAGES: ::c_int = 11; +pub const _SC_AVPHYS_PAGES: ::c_int = 12; +pub const _SC_MQ_OPEN_MAX: ::c_int = 13; +pub const _SC_MQ_PRIO_MAX: ::c_int = 14; +pub const _SC_RTSIG_MAX: ::c_int = 15; +pub const _SC_SEM_NSEMS_MAX: ::c_int = 16; +pub const _SC_SEM_VALUE_MAX: ::c_int = 17; +pub const _SC_SIGQUEUE_MAX: ::c_int = 18; +pub const _SC_TIMER_MAX: ::c_int = 19; +pub const _SC_TZNAME_MAX: ::c_int = 20; +pub const _SC_ASYNCHRONOUS_IO: ::c_int = 21; +pub const _SC_FSYNC: ::c_int = 22; +pub const _SC_MAPPED_FILES: ::c_int = 23; +pub const _SC_MEMLOCK: ::c_int = 24; +pub const _SC_MEMLOCK_RANGE: ::c_int = 25; +pub const _SC_MEMORY_PROTECTION: ::c_int = 26; +pub const _SC_MESSAGE_PASSING: ::c_int = 27; +pub const _SC_PRIORITIZED_IO: ::c_int = 28; +pub const _SC_REALTIME_SIGNALS: ::c_int = 29; +pub const _SC_SEMAPHORES: ::c_int = 30; +pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 31; +pub const _SC_SYNCHRONIZED_IO: ::c_int = 32; +pub const _SC_TIMERS: ::c_int = 33; +pub const _SC_AIO_LISTIO_MAX: ::c_int = 34; +pub const _SC_AIO_MAX: ::c_int = 35; +pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 36; +pub const _SC_DELAYTIMER_MAX: ::c_int = 37; +pub const _SC_THREAD_KEYS_MAX: ::c_int = 38; +pub const _SC_THREAD_STACK_MIN: ::c_int = 39; +pub const _SC_THREAD_THREADS_MAX: ::c_int = 40; +pub const _SC_TTY_NAME_MAX: ::c_int = 41; +pub const _SC_THREADS: ::c_int = 42; +pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 43; +pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 44; +pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 45; +pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 46; +pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 47; +pub const _SC_THREAD_PRIO_CEILING: ::c_int = _SC_THREAD_PRIO_PROTECT; +pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 48; +pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 49; +pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 50; +pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 51; +pub const _SC_LOGIN_NAME_MAX: ::c_int = 52; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 53; +pub const _SC_ADVISORY_INFO: ::c_int = 54; +pub const _SC_ATEXIT_MAX: ::c_int = 55; +pub const _SC_BARRIERS: ::c_int = 56; +pub const _SC_BC_BASE_MAX: ::c_int = 57; +pub const _SC_BC_DIM_MAX: ::c_int = 58; +pub const _SC_BC_SCALE_MAX: ::c_int = 59; +pub const _SC_BC_STRING_MAX: ::c_int = 60; +pub const _SC_CLOCK_SELECTION: ::c_int = 61; +pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 62; +pub const _SC_CPUTIME: ::c_int = 63; +pub const _SC_EXPR_NEST_MAX: ::c_int = 64; +pub const _SC_HOST_NAME_MAX: ::c_int = 65; +pub const _SC_IOV_MAX: ::c_int = 66; +pub const _SC_IPV6: ::c_int = 67; +pub const _SC_LINE_MAX: ::c_int = 68; +pub const _SC_MONOTONIC_CLOCK: ::c_int = 69; +pub const _SC_RAW_SOCKETS: ::c_int = 70; +pub const _SC_READER_WRITER_LOCKS: ::c_int = 71; +pub const _SC_REGEXP: ::c_int = 72; +pub const _SC_RE_DUP_MAX: ::c_int = 73; +pub const _SC_SHELL: ::c_int = 74; +pub const _SC_SPAWN: ::c_int = 75; +pub const _SC_SPIN_LOCKS: ::c_int = 76; +pub const _SC_SPORADIC_SERVER: ::c_int = 77; +pub const _SC_SS_REPL_MAX: ::c_int = 78; +pub const _SC_SYMLOOP_MAX: ::c_int = 79; +pub const _SC_THREAD_CPUTIME: ::c_int = 80; +pub const _SC_THREAD_SPORADIC_SERVER: ::c_int = 81; +pub const _SC_TIMEOUTS: ::c_int = 82; +pub const _SC_TRACE: ::c_int = 83; +pub const _SC_TRACE_EVENT_FILTER: ::c_int = 84; +pub const _SC_TRACE_EVENT_NAME_MAX: ::c_int = 85; +pub const _SC_TRACE_INHERIT: ::c_int = 86; +pub const _SC_TRACE_LOG: ::c_int = 87; +pub const _SC_TRACE_NAME_MAX: ::c_int = 88; +pub const _SC_TRACE_SYS_MAX: ::c_int = 89; +pub const _SC_TRACE_USER_EVENT_MAX: ::c_int = 90; +pub const _SC_TYPED_MEMORY_OBJECTS: ::c_int = 91; +pub const _SC_V7_ILP32_OFF32: ::c_int = 92; +pub const _SC_V6_ILP32_OFF32: ::c_int =_SC_V7_ILP32_OFF32; +pub const _SC_XBS5_ILP32_OFF32: ::c_int = _SC_V7_ILP32_OFF32; +pub const _SC_V7_ILP32_OFFBIG: ::c_int = 93; +pub const _SC_V6_ILP32_OFFBIG: ::c_int = _SC_V7_ILP32_OFFBIG; +pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = _SC_V7_ILP32_OFFBIG; +pub const _SC_V7_LP64_OFF64: ::c_int = 94; +pub const _SC_V6_LP64_OFF64: ::c_int = _SC_V7_LP64_OFF64; +pub const _SC_XBS5_LP64_OFF64: ::c_int = _SC_V7_LP64_OFF64; +pub const _SC_V7_LPBIG_OFFBIG: ::c_int = 95; +pub const _SC_V6_LPBIG_OFFBIG: ::c_int = _SC_V7_LPBIG_OFFBIG; +pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = _SC_V7_LPBIG_OFFBIG; +pub const _SC_XOPEN_CRYPT: ::c_int = 96; +pub const _SC_XOPEN_ENH_I18N: ::c_int = 97; +pub const _SC_XOPEN_LEGACY: ::c_int = 98; +pub const _SC_XOPEN_REALTIME: ::c_int = 99; +pub const _SC_STREAM_MAX: ::c_int = 100; +pub const _SC_PRIORITY_SCHEDULING: ::c_int = 101; +pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 102; +pub const _SC_XOPEN_SHM: ::c_int = 103; +pub const _SC_XOPEN_STREAMS: ::c_int = 104; +pub const _SC_XOPEN_UNIX: ::c_int = 105; +pub const _SC_XOPEN_VERSION: ::c_int = 106; +pub const _SC_2_CHAR_TERM: ::c_int = 107; +pub const _SC_2_C_BIND: ::c_int = 108; +pub const _SC_2_C_DEV: ::c_int = 109; +pub const _SC_2_FORT_DEV: ::c_int = 110; +pub const _SC_2_FORT_RUN: ::c_int = 111; +pub const _SC_2_LOCALEDEF: ::c_int = 112; +pub const _SC_2_PBS: ::c_int = 113; +pub const _SC_2_PBS_ACCOUNTING: ::c_int = 114; +pub const _SC_2_PBS_CHECKPOINT: ::c_int = 115; +pub const _SC_2_PBS_LOCATE: ::c_int = 116; +pub const _SC_2_PBS_MESSAGE: ::c_int = 117; +pub const _SC_2_PBS_TRACK: ::c_int = 118; +pub const _SC_2_SW_DEV: ::c_int = 119; +pub const _SC_2_UPE: ::c_int = 120; +pub const _SC_2_VERSION: ::c_int = 121; +pub const _SC_THREAD_ROBUST_PRIO_INHERIT: ::c_int = 122; +pub const _SC_THREAD_ROBUST_PRIO_PROTECT: ::c_int = 123; +pub const _SC_XOPEN_UUCP: ::c_int = 124; +pub const _SC_LEVEL1_ICACHE_SIZE: ::c_int = 125; +pub const _SC_LEVEL1_ICACHE_ASSOC: ::c_int = 126; +pub const _SC_LEVEL1_ICACHE_LINESIZE: ::c_int = 127; +pub const _SC_LEVEL1_DCACHE_SIZE: ::c_int = 128; +pub const _SC_LEVEL1_DCACHE_ASSOC: ::c_int = 129; +pub const _SC_LEVEL1_DCACHE_LINESIZE: ::c_int = 130; +pub const _SC_LEVEL2_CACHE_SIZE: ::c_int = 131; +pub const _SC_LEVEL2_CACHE_ASSOC: ::c_int = 132; +pub const _SC_LEVEL2_CACHE_LINESIZE: ::c_int = 133; +pub const _SC_LEVEL3_CACHE_SIZE: ::c_int = 134; +pub const _SC_LEVEL3_CACHE_ASSOC: ::c_int = 135; +pub const _SC_LEVEL3_CACHE_LINESIZE: ::c_int = 136; +pub const _SC_LEVEL4_CACHE_SIZE: ::c_int = 137; +pub const _SC_LEVEL4_CACHE_ASSOC: ::c_int = 138; +pub const _SC_LEVEL4_CACHE_LINESIZE: ::c_int = 139; + +pub const S_BLKSIZE: ::mode_t = 1024; +pub const S_IREAD: ::mode_t = 256; +pub const S_IWRITE: ::mode_t = 128; +pub const S_IEXEC: ::mode_t = 64; +pub const S_ENFMT: ::mode_t = 1024; +pub const S_IFMT: ::mode_t = 61440; +pub const S_IFDIR: ::mode_t = 16384; +pub const S_IFCHR: ::mode_t = 8192; +pub const S_IFBLK: ::mode_t = 24576; +pub const S_IFREG: ::mode_t = 32768; +pub const S_IFLNK: ::mode_t = 40960; +pub const S_IFSOCK: ::mode_t = 49152; +pub const S_IFIFO: ::mode_t = 4096; +pub const S_IRUSR: ::mode_t = 256; +pub const S_IWUSR: ::mode_t = 128; +pub const S_IXUSR: ::mode_t = 64; +pub const S_IRGRP: ::mode_t = 32; +pub const S_IWGRP: ::mode_t = 16; +pub const S_IXGRP: ::mode_t = 8; +pub const S_IROTH: ::mode_t = 4; +pub const S_IWOTH: ::mode_t = 2; +pub const S_IXOTH: ::mode_t = 1; + +pub const SEEK_SET: ::c_int = 0; +pub const SEEK_CUR: ::c_int = 1; +pub const SEEK_END: ::c_int = 2; + +pub const SHUT_RD: ::c_int = 0; +pub const SHUT_WR: ::c_int = 1; +pub const SHUT_RDWR: ::c_int = 2; + +pub const SIG_SETMASK: ::c_int = 0; + +pub const SIGHUP: ::c_int = 1; +pub const SIGINT: ::c_int = 2; +pub const SIGQUIT: ::c_int = 3; +pub const SIGILL: ::c_int = 4; +pub const SIGABRT: ::c_int = 6; +pub const SIGEMT: ::c_int = 7; +pub const SIGFPE: ::c_int = 8; +pub const SIGKILL: ::c_int = 9; +pub const SIGSEGV: ::c_int = 11; +pub const SIGPIPE: ::c_int = 13; +pub const SIGALRM: ::c_int = 14; +pub const SIGTERM: ::c_int = 15; + +pub const SO_DEBUG: ::c_int = 0x0001; +pub const SO_ACCEPTCONN: ::c_int = 0x0002; +pub const SO_REUSEADDR: ::c_int = 0x0004; +pub const SO_KEEPALIVE: ::c_int = 0x0008; +pub const SO_DONTROUTE: ::c_int = 0x0010; +pub const SO_BROADCAST: ::c_int = 0x0020; +pub const SO_USELOOPBACK: ::c_int = 0x0040; +pub const SO_LINGER: ::c_int = 0x0080; +pub const SO_OOBINLINE: ::c_int = 0x0100; +pub const SO_REUSEPORT: ::c_int = 0x0200; +pub const SO_SNDBUF: ::c_int = 0x1001; +pub const SO_RCVBUF: ::c_int = 0x1002; +pub const SO_SNDLOWAT: ::c_int = 0x1003; +pub const SO_RCVLOWAT: ::c_int = 0x1004; +pub const SO_SNDTIMEO: ::c_int = 0x1005; +pub const SO_RCVTIMEO: ::c_int = 0x1006; +pub const SO_ERROR: ::c_int = 0x1007; +pub const SO_TYPE: ::c_int = 0x1008; +pub const SO_CONTIMEO: ::c_int = 0x1009; +pub const SO_NO_CHECK: ::c_int = 0x100a; + +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; +pub const SOCK_RAW: ::c_int = 3; + +pub const SOL_SOCKET: ::c_int = 0xfff; + +pub const STDIN_FILENO: ::c_int = 0; +pub const STDOUT_FILENO: ::c_int = 1; +pub const STDERR_FILENO: ::c_int = 2; + +pub const TCP_NODELAY: ::c_int = 0x01; +pub const TCP_KEEPALIVE: ::c_int = 0x02; +pub const TCP_KEEPIDLE: ::c_int = 0x03; +pub const TCP_KEEPINTVL: ::c_int = 0x04; +pub const TCP_KEEPCNT: ::c_int = 0x05; + +const ULONG_SIZE: usize = 64; + +pub const WNOHANG: ::c_int = 0x00000001; + +f! { + pub fn WEXITSTATUS(status: ::c_int) -> ::c_int { + (status >> 8) & 0xff + } + + pub fn WIFEXITED(status: ::c_int) -> bool { + (status & 0xff) == 0 + } + + pub fn WTERMSIG(status: ::c_int) -> ::c_int { + status & 0x7f + } +} + +extern { + pub fn abs(i: ::c_int) -> ::c_int; + pub fn atof(s: *const ::c_char) -> ::c_double; + pub fn labs(i: ::c_long) -> ::c_long; + pub fn rand() -> ::c_int; + pub fn srand(seed: ::c_uint); + + pub fn bind(s: ::c_int, name: *const ::sockaddr, namelen: ::socklen_t) + -> ::c_int; + + pub fn clock_gettime(clock_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; + + pub fn getpwuid_r(uid: ::uid_t, pwd: *mut passwd, buf: *mut ::c_char, + buflen: ::size_t, result: *mut *mut passwd) -> ::c_int; + + // Dummy + pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; + + pub fn memalign(align: ::size_t, nbytes: ::size_t) -> *mut ::c_void; + + pub fn pthread_create(tid: *mut ::pthread_t, attr: *const ::pthread_attr_t, + start: extern fn(*mut ::c_void) -> *mut ::c_void, arg: *mut ::c_void) + -> ::c_int; + + pub fn pthread_sigmask(how: ::c_int, set: *const ::sigset_t, + oset: *mut ::sigset_t) -> ::c_int; + + pub fn recvfrom(s: ::c_int, mem: *mut ::c_void, len: ::size_t, + flags: ::c_int, from: *mut ::sockaddr, fromlen: *mut ::socklen_t) + -> ::c_int; + + pub fn setgroups(ngroups: ::c_int, grouplist: *const ::gid_t) -> ::c_int; +} + +cfg_if! { + if #[cfg(target_arch = "aarch64")] { + mod aarch64; + pub use self::aarch64::*; + } else if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } else { + // Unknown target_arch + } +} diff --git a/libc/src/unix/hermit/x86_64.rs b/libc/src/unix/hermit/x86_64.rs new file mode 100644 index 0000000..76ec3ce --- /dev/null +++ b/libc/src/unix/hermit/x86_64.rs @@ -0,0 +1,2 @@ +pub type c_char = i8; +pub type wchar_t = i32; diff --git a/libc/src/unix/mod.rs b/libc/src/unix/mod.rs index 57067e0..370d7f4 100644 --- a/libc/src/unix/mod.rs +++ b/libc/src/unix/mod.rs @@ -5,6 +5,34 @@ use dox::Option; +pub type int8_t = i8; +pub type int16_t = i16; +pub type int32_t = i32; +pub type int64_t = i64; +pub type uint8_t = u8; +pub type uint16_t = u16; +pub type uint32_t = u32; +pub type uint64_t = u64; + +pub type c_schar = i8; +pub type c_uchar = u8; +pub type c_short = i16; +pub type c_ushort = u16; +pub type c_int = i32; +pub type c_uint = u32; +pub type c_float = f32; +pub type c_double = f64; +pub type c_longlong = i64; +pub type c_ulonglong = u64; +pub type intmax_t = i64; +pub type uintmax_t = u64; + +pub type size_t = usize; +pub type ptrdiff_t = isize; +pub type intptr_t = isize; +pub type uintptr_t = usize; +pub type ssize_t = isize; + pub type pid_t = i32; pub type uid_t = u32; pub type gid_t = u32; @@ -104,8 +132,10 @@ s! { pub s_addr: in_addr_t, } + #[cfg_attr(feature = "align", repr(align(4)))] pub struct in6_addr { pub s6_addr: [u8; 16], + #[cfg(not(feature = "align"))] __align: [u32; 0], } @@ -186,10 +216,14 @@ s! { } } +pub const INT_MIN: c_int = -2147483648; +pub const INT_MAX: c_int = 2147483647; + pub const SIG_DFL: sighandler_t = 0 as sighandler_t; pub const SIG_IGN: sighandler_t = 1 as sighandler_t; pub const SIG_ERR: sighandler_t = !0 as sighandler_t; +pub const DT_UNKNOWN: u8 = 0; pub const DT_FIFO: u8 = 1; pub const DT_CHR: u8 = 2; pub const DT_DIR: u8 = 4; @@ -267,22 +301,35 @@ pub const INADDR_ANY: in_addr_t = 0; pub const INADDR_BROADCAST: in_addr_t = 4294967295; pub const INADDR_NONE: in_addr_t = 4294967295; +pub const ARPOP_REQUEST: u16 = 1; +pub const ARPOP_REPLY: u16 = 2; + +pub const ATF_COM: ::c_int = 0x02; +pub const ATF_PERM: ::c_int = 0x04; +pub const ATF_PUBL: ::c_int = 0x08; +pub const ATF_USETRAILERS: ::c_int = 0x10; + cfg_if! { - if #[cfg(dox)] { + if #[cfg(cross_platform_docs)] { // on dox builds don't pull in anything } else if #[cfg(target_os = "l4re")] { // required libraries for L4Re are linked externally, ATM } else if #[cfg(feature = "use_std")] { // cargo build, don't pull in anything extra as the libstd dep // already pulls in all libs. - } else if #[cfg(any(all(target_env = "musl", not(target_arch = "mips"))))] { - #[link(name = "c", kind = "static", cfg(target_feature = "crt-static"))] - #[link(name = "c", cfg(not(target_feature = "crt-static")))] + } else if #[cfg(target_env = "musl")] { + #[cfg_attr(feature = "rustc-dep-of-std", + link(name = "c", kind = "static", + cfg(target_feature = "crt-static")))] + #[cfg_attr(feature = "rustc-dep-of-std", + link(name = "c", cfg(not(target_feature = "crt-static"))))] extern {} } else if #[cfg(target_os = "emscripten")] { #[link(name = "c")] extern {} - } else if #[cfg(all(target_os = "netbsd", target_vendor = "rumprun"))] { + } else if #[cfg(all(target_os = "netbsd", + feature = "rustc-dep-of-std", + target_vendor = "rumprun"))] { // Since we don't use -nodefaultlibs on Rumprun, libc is always pulled // in automatically by the linker. We avoid passing it explicitly, as it // causes some versions of binutils to crash with an assertion failure. @@ -300,14 +347,15 @@ cfg_if! { #[link(name = "root")] #[link(name = "network")] extern {} - } else if #[cfg(target_os = "fuchsia")] { - #[link(name = "c")] - #[link(name = "fdio")] - extern {} } else if #[cfg(target_env = "newlib")] { #[link(name = "c")] #[link(name = "m")] extern {} + } else if #[cfg(target_os = "hermit")] { + // no_default_libraries is set to false for HermitCore, so only a link + // to "pthread" needs to be added. + #[link(name = "pthread")] + extern {} } else { #[link(name = "c")] #[link(name = "m")] @@ -317,6 +365,138 @@ cfg_if! { } } +pub enum FILE {} +pub enum fpos_t {} // TODO: fill this out with a struct + +extern { + pub fn isalnum(c: c_int) -> c_int; + pub fn isalpha(c: c_int) -> c_int; + pub fn iscntrl(c: c_int) -> c_int; + pub fn isdigit(c: c_int) -> c_int; + pub fn isgraph(c: c_int) -> c_int; + pub fn islower(c: c_int) -> c_int; + pub fn isprint(c: c_int) -> c_int; + pub fn ispunct(c: c_int) -> c_int; + pub fn isspace(c: c_int) -> c_int; + pub fn isupper(c: c_int) -> c_int; + pub fn isxdigit(c: c_int) -> c_int; + pub fn tolower(c: c_int) -> c_int; + pub fn toupper(c: c_int) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "fopen$UNIX2003" + )] + pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "freopen$UNIX2003" + )] + pub fn freopen(filename: *const c_char, mode: *const c_char, + file: *mut FILE) -> *mut FILE; + pub fn fflush(file: *mut FILE) -> c_int; + pub fn fclose(file: *mut FILE) -> c_int; + pub fn remove(filename: *const c_char) -> c_int; + pub fn rename(oldname: *const c_char, newname: *const c_char) -> c_int; + pub fn tmpfile() -> *mut FILE; + pub fn setvbuf(stream: *mut FILE, buffer: *mut c_char, mode: c_int, + size: size_t) -> c_int; + pub fn setbuf(stream: *mut FILE, buf: *mut c_char); + pub fn getchar() -> c_int; + pub fn putchar(c: c_int) -> c_int; + pub fn fgetc(stream: *mut FILE) -> c_int; + pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char; + pub fn fputc(c: c_int, stream: *mut FILE) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "fputs$UNIX2003" + )] + pub fn fputs(s: *const c_char, stream: *mut FILE) -> c_int; + pub fn puts(s: *const c_char) -> c_int; + pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int; + pub fn fread(ptr: *mut c_void, size: size_t, nobj: size_t, + stream: *mut FILE) -> size_t; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "fwrite$UNIX2003" + )] + pub fn fwrite(ptr: *const c_void, size: size_t, nobj: size_t, + stream: *mut FILE) -> size_t; + pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int; + pub fn ftell(stream: *mut FILE) -> c_long; + pub fn rewind(stream: *mut FILE); + #[cfg_attr(target_os = "netbsd", link_name = "__fgetpos50")] + pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__fsetpos50")] + pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int; + pub fn feof(stream: *mut FILE) -> c_int; + pub fn ferror(stream: *mut FILE) -> c_int; + pub fn perror(s: *const c_char); + pub fn atoi(s: *const c_char) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "strtod$UNIX2003" + )] + pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double; + pub fn strtol(s: *const c_char, endp: *mut *mut c_char, + base: c_int) -> c_long; + pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, + base: c_int) -> c_ulong; + pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; + pub fn malloc(size: size_t) -> *mut c_void; + pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; + pub fn free(p: *mut c_void); + pub fn abort() -> !; + pub fn exit(status: c_int) -> !; + pub fn _exit(status: c_int) -> !; + pub fn atexit(cb: extern fn()) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "system$UNIX2003" + )] + pub fn system(s: *const c_char) -> c_int; + pub fn getenv(s: *const c_char) -> *mut c_char; + + pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char; + pub fn strncpy(dst: *mut c_char, src: *const c_char, + n: size_t) -> *mut c_char; + pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char; + pub fn strncat(s: *mut c_char, ct: *const c_char, + n: size_t) -> *mut c_char; + pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strncmp(cs: *const c_char, ct: *const c_char, n: size_t) -> c_int; + pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strdup(cs: *const c_char) -> *mut c_char; + pub fn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn strcasecmp(s1: *const c_char, s2: *const c_char) -> c_int; + pub fn strncasecmp(s1: *const c_char, s2: *const c_char, + n: size_t) -> c_int; + pub fn strlen(cs: *const c_char) -> size_t; + pub fn strnlen(cs: *const c_char, maxlen: size_t) -> size_t; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "strerror$UNIX2003" + )] + pub fn strerror(n: c_int) -> *mut c_char; + pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char; + pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t; + pub fn wcslen(buf: *const wchar_t) -> size_t; + pub fn wcstombs(dest: *mut c_char, src: *const wchar_t, + n: size_t) -> ::size_t; + + pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; + pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int; + pub fn memcpy(dest: *mut c_void, src: *const c_void, + n: size_t) -> *mut c_void; + pub fn memmove(dest: *mut c_void, src: *const c_void, + n: size_t) -> *mut c_void; + pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void; +} + extern { #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam50")] pub fn getpwnam(name: *const ::c_char) -> *mut passwd; @@ -379,12 +559,14 @@ extern { #[cfg_attr(target_os = "macos", link_name = "fstat$INODE64")] #[cfg_attr(target_os = "netbsd", link_name = "__fstat50")] + #[cfg_attr(target_os = "freebsd", link_name = "fstat@FBSD_1.0")] pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int; pub fn mkdir(path: *const c_char, mode: mode_t) -> ::c_int; #[cfg_attr(target_os = "macos", link_name = "stat$INODE64")] #[cfg_attr(target_os = "netbsd", link_name = "__stat50")] + #[cfg_attr(target_os = "freebsd", link_name = "stat@FBSD_1.0")] pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int; pub fn pclose(stream: *mut ::FILE) -> ::c_int; @@ -409,12 +591,21 @@ extern { link_name = "opendir$INODE64$UNIX2003")] #[cfg_attr(target_os = "netbsd", link_name = "__opendir30")] pub fn opendir(dirname: *const c_char) -> *mut ::DIR; + + #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), + link_name = "fdopendir$INODE64")] + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "fdopendir$INODE64$UNIX2003")] + pub fn fdopendir(fd: ::c_int) -> *mut ::DIR; + #[cfg_attr(target_os = "macos", link_name = "readdir$INODE64")] #[cfg_attr(target_os = "netbsd", link_name = "__readdir30")] + #[cfg_attr(target_os = "freebsd", link_name = "readdir@FBSD_1.0")] pub fn readdir(dirp: *mut ::DIR) -> *mut ::dirent; #[cfg_attr(target_os = "macos", link_name = "readdir_r$INODE64")] #[cfg_attr(target_os = "netbsd", link_name = "__readdir_r30")] #[cfg_attr(target_os = "solaris", link_name = "__posix_readdir_r")] + #[cfg_attr(target_os = "freebsd", link_name = "readdir_r@FBSD_1.0")] pub fn readdir_r(dirp: *mut ::DIR, entry: *mut ::dirent, result: *mut *mut ::dirent) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), @@ -437,6 +628,7 @@ extern { owner: ::uid_t, group: ::gid_t, flags: ::c_int) -> ::c_int; #[cfg_attr(target_os = "macos", link_name = "fstatat$INODE64")] + #[cfg_attr(target_os = "freebsd", link_name = "fstatat@FBSD_1.1")] pub fn fstatat(dirfd: ::c_int, pathname: *const ::c_char, buf: *mut stat, flags: ::c_int) -> ::c_int; pub fn linkat(olddirfd: ::c_int, oldpath: *const ::c_char, @@ -519,6 +711,7 @@ extern { -> ::ssize_t; pub fn rmdir(path: *const c_char) -> ::c_int; pub fn seteuid(uid: uid_t) -> ::c_int; + pub fn setegid(gid: gid_t) -> ::c_int; pub fn setgid(gid: gid_t) -> ::c_int; pub fn setpgid(pid: pid_t, pgid: pid_t) -> ::c_int; pub fn setsid() -> pid_t; @@ -562,6 +755,9 @@ extern { #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "kill$UNIX2003")] pub fn kill(pid: pid_t, sig: ::c_int) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "killpg$UNIX2003")] + pub fn killpg(pgrp: pid_t, sig: ::c_int) -> ::c_int; pub fn mlock(addr: *const ::c_void, len: ::size_t) -> ::c_int; pub fn munlock(addr: *const ::c_void, len: ::size_t) -> ::c_int; @@ -587,6 +783,7 @@ extern { #[cfg_attr(target_os = "macos", link_name = "lstat$INODE64")] #[cfg_attr(target_os = "netbsd", link_name = "__lstat50")] + #[cfg_attr(target_os = "freebsd", link_name = "lstat@FBSD_1.0")] pub fn lstat(path: *const c_char, buf: *mut stat) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), @@ -605,6 +802,7 @@ extern { pub fn symlink(path1: *const c_char, path2: *const c_char) -> ::c_int; + pub fn truncate(path: *const c_char, length: off_t) -> ::c_int; pub fn ftruncate(fd: ::c_int, length: off_t) -> ::c_int; pub fn signal(signum: ::c_int, handler: sighandler_t) -> sighandler_t; @@ -771,6 +969,7 @@ extern { pub fn difftime(time1: time_t, time0: time_t) -> ::c_double; #[cfg_attr(target_os = "netbsd", link_name = "__mknod50")] + #[cfg_attr(target_os = "freebsd", link_name = "mknod@FBSD_1.0")] pub fn mknod(pathname: *const ::c_char, mode: ::mode_t, dev: ::dev_t) -> ::c_int; pub fn uname(buf: *mut ::utsname) -> ::c_int; @@ -899,6 +1098,7 @@ extern { pub fn openlog(ident: *const ::c_char, logopt: ::c_int, facility: ::c_int); pub fn closelog(); pub fn setlogmask(maskpri: ::c_int) -> ::c_int; + #[cfg_attr(target_os = "macos", link_name = "syslog$DARWIN_EXTSN")] pub fn syslog(priority: ::c_int, message: *const ::c_char, ...); #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "nice$UNIX2003")] @@ -908,6 +1108,10 @@ extern { pub fn posix_openpt(flags: ::c_int) -> ::c_int; pub fn ptsname(fd: ::c_int) -> *mut ::c_char; pub fn unlockpt(fd: ::c_int) -> ::c_int; + + pub fn strcasestr(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn getline (lineptr: *mut *mut c_char, n: *mut size_t, + stream: *mut FILE) -> ssize_t; } cfg_if! { @@ -919,8 +1123,7 @@ cfg_if! { pub use self::newlib::*; } else if #[cfg(any(target_os = "linux", target_os = "android", - target_os = "emscripten", - target_os = "fuchsia"))] { + target_os = "emscripten"))] { mod notbsd; pub use self::notbsd::*; } else if #[cfg(any(target_os = "macos", @@ -938,7 +1141,28 @@ cfg_if! { } else if #[cfg(target_os = "haiku")] { mod haiku; pub use self::haiku::*; + } else if #[cfg(target_os = "hermit")] { + mod hermit; + pub use self::hermit::*; } else { // Unknown target_os } } + +cfg_if! { + if #[cfg(core_cvoid)] { + pub use core::ffi::c_void; + } else { + // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help + // enable more optimization opportunities around it recognizing things + // like malloc/free. + #[repr(u8)] + pub enum c_void { + // Two dummy variants so the #[repr] attribute can be used. + #[doc(hidden)] + __variant1, + #[doc(hidden)] + __variant2, + } + } +} diff --git a/libc/src/unix/newlib/mod.rs b/libc/src/unix/newlib/mod.rs index 6cf8633..77a4eb9 100644 --- a/libc/src/unix/newlib/mod.rs +++ b/libc/src/unix/newlib/mod.rs @@ -238,34 +238,80 @@ s! { __size: [u64; 7] } + #[cfg_attr(all(feature = "align", + target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")), + repr(align(4)))] + #[cfg_attr(all(feature = "align", + any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")))), + repr(align(8)))] pub struct pthread_mutex_t { // Unverified - #[cfg(any(target_arch = "mips", target_arch = "arm", - target_arch = "powerpc"))] + #[cfg(all(not(feature = "align"), + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")))] __align: [::c_long; 0], - #[cfg(not(any(target_arch = "mips", target_arch = "arm", + #[cfg(not(any(feature = "align", + target_arch = "mips", + target_arch = "arm", target_arch = "powerpc")))] __align: [::c_longlong; 0], size: [u8; __SIZEOF_PTHREAD_MUTEX_T], } + #[cfg_attr(all(feature = "align", + target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")), + repr(align(4)))] + #[cfg_attr(all(feature = "align", + any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")))), + repr(align(8)))] pub struct pthread_rwlock_t { // Unverified - #[cfg(any(target_arch = "mips", target_arch = "arm", - target_arch = "powerpc"))] + #[cfg(all(not(feature = "align"), + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")))] __align: [::c_long; 0], - #[cfg(not(any(target_arch = "mips", target_arch = "arm", + #[cfg(not(any(feature = "align", + target_arch = "mips", + target_arch = "arm", target_arch = "powerpc")))] __align: [::c_longlong; 0], size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], } + #[cfg_attr(all(feature = "align", + any(target_pointer_width = "32", + target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64")), + repr(align(4)))] + #[cfg_attr(all(feature = "align", + not(any(target_pointer_width = "32", + target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64"))), + repr(align(8)))] pub struct pthread_mutexattr_t { // Unverified - #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64"))] - __align: [::c_int; 0], - #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64", + #[cfg(all(not(feature = "align"), + any(target_arch = "x86_64", target_arch = "powerpc64", target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64")))] + __align: [::c_int; 0], + #[cfg(all(not(feature = "align"), + not(any(target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64"))))] __align: [::c_long; 0], size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], } @@ -275,12 +321,16 @@ s! { __pshared: ::c_int, } + #[cfg_attr(feature = "align", repr(align(8)))] pub struct pthread_cond_t { // Unverified + #[cfg(not(feature = "align"))] __align: [::c_longlong; 0], size: [u8; __SIZEOF_PTHREAD_COND_T], } + #[cfg_attr(feature = "align", repr(align(4)))] pub struct pthread_condattr_t { // Unverified + #[cfg(not(feature = "align"))] __align: [::c_int; 0], size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], } @@ -288,18 +338,17 @@ s! { } // unverified constants -pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { - __align: [], - size: [0; __SIZEOF_PTHREAD_MUTEX_T], -}; -pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { - __align: [], - size: [0; __SIZEOF_PTHREAD_COND_T], -}; -pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { - __align: [], - size: [0; __SIZEOF_PTHREAD_RWLOCK_T], -}; +align_const! { + pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + size: [0; __SIZEOF_PTHREAD_MUTEX_T], + }; + pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + size: [0; __SIZEOF_PTHREAD_COND_T], + }; + pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + size: [0; __SIZEOF_PTHREAD_RWLOCK_T], + }; +} pub const NCCS: usize = 32; pub const __SIZEOF_PTHREAD_ATTR_T: usize = 56; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; @@ -605,6 +654,12 @@ f! { } extern { + pub fn abs(i: ::c_int) -> ::c_int; + pub fn atof(s: *const ::c_char) -> ::c_double; + pub fn labs(i: ::c_long) -> ::c_long; + pub fn rand() -> ::c_int; + pub fn srand(seed: ::c_uint); + pub fn bind(fd: ::c_int, addr: *const sockaddr, len: socklen_t) -> ::c_int; pub fn closesocket(sockfd: ::c_int) -> ::c_int; pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; diff --git a/libc/src/unix/notbsd/android/b32/mod.rs b/libc/src/unix/notbsd/android/b32/mod.rs index 99af6d8..394abe8 100644 --- a/libc/src/unix/notbsd/android/b32/mod.rs +++ b/libc/src/unix/notbsd/android/b32/mod.rs @@ -198,22 +198,6 @@ pub const SIGSTKSZ: ::size_t = 8192; pub const MINSIGSTKSZ: ::size_t = 2048; extern { - pub fn bind(socket: ::c_int, address: *const ::sockaddr, - address_len: socklen_t) -> ::c_int; - - pub fn writev(fd: ::c_int, - iov: *const ::iovec, - iovcnt: ::c_int) -> ::ssize_t; - pub fn readv(fd: ::c_int, - iov: *const ::iovec, - iovcnt: ::c_int) -> ::ssize_t; - - pub fn sendmsg(fd: ::c_int, - msg: *const ::msghdr, - flags: ::c_int) -> ::ssize_t; - pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) - -> ::ssize_t; - pub fn timegm64(tm: *const ::tm) -> ::time64_t; } diff --git a/libc/src/unix/notbsd/android/b64/mod.rs b/libc/src/unix/notbsd/android/b64/mod.rs index 4aa6997..fb94334 100644 --- a/libc/src/unix/notbsd/android/b64/mod.rs +++ b/libc/src/unix/notbsd/android/b64/mod.rs @@ -154,31 +154,6 @@ pub const UT_LINESIZE: usize = 32; pub const UT_NAMESIZE: usize = 32; pub const UT_HOSTSIZE: usize = 256; -// Some weirdness in Android -extern { - // address_len should be socklen_t, but it is c_int! - pub fn bind(socket: ::c_int, address: *const ::sockaddr, - address_len: ::c_int) -> ::c_int; - - // the return type should be ::ssize_t, but it is c_int! - pub fn writev(fd: ::c_int, - iov: *const ::iovec, - iovcnt: ::c_int) -> ::c_int; - - // the return type should be ::ssize_t, but it is c_int! - pub fn readv(fd: ::c_int, - iov: *const ::iovec, - iovcnt: ::c_int) -> ::c_int; - - // the return type should be ::ssize_t, but it is c_int! - pub fn sendmsg(fd: ::c_int, - msg: *const ::msghdr, - flags: ::c_int) -> ::c_int; - - // the return type should be ::ssize_t, but it is c_int! - pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) -> ::c_int; -} - cfg_if! { if #[cfg(target_arch = "x86_64")] { mod x86_64; diff --git a/libc/src/unix/notbsd/android/mod.rs b/libc/src/unix/notbsd/android/mod.rs index 17f6eda..70052e1 100644 --- a/libc/src/unix/notbsd/android/mod.rs +++ b/libc/src/unix/notbsd/android/mod.rs @@ -177,7 +177,11 @@ s! { pub ssi_stime: ::c_ulonglong, pub ssi_addr: ::c_ulonglong, pub ssi_addr_lsb: ::uint16_t, - _pad: [::uint8_t; 46], + _pad2: ::uint16_t, + pub ssi_syscall: ::int32_t, + pub ssi_call_addr: ::uint64_t, + pub ssi_arch: ::uint32_t, + _pad: [::uint8_t; 28], } pub struct ucred { @@ -185,6 +189,55 @@ s! { pub uid: ::uid_t, pub gid: ::gid_t, } + + pub struct genlmsghdr { + pub cmd: u8, + pub version: u8, + pub reserved: u16, + } + + pub struct nlmsghdr { + pub nlmsg_len: u32, + pub nlmsg_type: u16, + pub nlmsg_flags: u16, + pub nlmsg_seq: u32, + pub nlmsg_pid: u32, + } + + pub struct nlmsgerr { + pub error: ::c_int, + pub msg: nlmsghdr, + } + + pub struct nl_pktinfo { + pub group: u32, + } + + pub struct nl_mmap_req { + pub nm_block_size: ::c_uint, + pub nm_block_nr: ::c_uint, + pub nm_frame_size: ::c_uint, + pub nm_frame_nr: ::c_uint, + } + + pub struct nl_mmap_hdr { + pub nm_status: ::c_uint, + pub nm_len: ::c_uint, + pub nm_group: u32, + pub nm_pid: u32, + pub nm_uid: u32, + pub nm_gid: u32, + } + + pub struct nlattr { + pub nla_len: u16, + pub nla_type: u16, + } + + pub struct in6_pktinfo { + pub ipi6_addr: ::in6_addr, + pub ipi6_ifindex: ::c_int, + } } pub const O_TRUNC: ::c_int = 512; @@ -342,6 +395,49 @@ pub const _SC_PHYS_PAGES: ::c_int = 98; pub const _SC_AVPHYS_PAGES: ::c_int = 99; pub const _SC_MONOTONIC_CLOCK: ::c_int = 100; +pub const _SC_2_PBS: ::c_int = 101; +pub const _SC_2_PBS_ACCOUNTING: ::c_int = 102; +pub const _SC_2_PBS_CHECKPOINT: ::c_int = 103; +pub const _SC_2_PBS_LOCATE: ::c_int = 104; +pub const _SC_2_PBS_MESSAGE: ::c_int = 105; +pub const _SC_2_PBS_TRACK: ::c_int = 106; +pub const _SC_ADVISORY_INFO: ::c_int = 107; +pub const _SC_BARRIERS: ::c_int = 108; +pub const _SC_CLOCK_SELECTION: ::c_int = 109; +pub const _SC_CPUTIME: ::c_int = 110; +pub const _SC_HOST_NAME_MAX: ::c_int = 111; +pub const _SC_IPV6: ::c_int = 112; +pub const _SC_RAW_SOCKETS: ::c_int = 113; +pub const _SC_READER_WRITER_LOCKS: ::c_int = 114; +pub const _SC_REGEXP: ::c_int = 115; +pub const _SC_SHELL: ::c_int = 116; +pub const _SC_SPAWN: ::c_int = 117; +pub const _SC_SPIN_LOCKS: ::c_int = 118; +pub const _SC_SPORADIC_SERVER: ::c_int = 119; +pub const _SC_SS_REPL_MAX: ::c_int = 120; +pub const _SC_SYMLOOP_MAX: ::c_int = 121; +pub const _SC_THREAD_CPUTIME: ::c_int = 122; +pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 123; +pub const _SC_THREAD_ROBUST_PRIO_INHERIT: ::c_int = 124; +pub const _SC_THREAD_ROBUST_PRIO_PROTECT: ::c_int = 125; +pub const _SC_THREAD_SPORADIC_SERVER: ::c_int = 126; +pub const _SC_TIMEOUTS: ::c_int = 127; +pub const _SC_TRACE: ::c_int = 128; +pub const _SC_TRACE_EVENT_FILTER: ::c_int = 129; +pub const _SC_TRACE_EVENT_NAME_MAX: ::c_int = 130; +pub const _SC_TRACE_INHERIT: ::c_int = 131; +pub const _SC_TRACE_LOG: ::c_int = 132; +pub const _SC_TRACE_NAME_MAX: ::c_int = 133; +pub const _SC_TRACE_SYS_MAX: ::c_int = 134; +pub const _SC_TRACE_USER_EVENT_MAX: ::c_int = 135; +pub const _SC_TYPED_MEMORY_OBJECTS: ::c_int = 136; +pub const _SC_V7_ILP32_OFF32: ::c_int = 137; +pub const _SC_V7_ILP32_OFFBIG: ::c_int = 138; +pub const _SC_V7_LP64_OFF64: ::c_int = 139; +pub const _SC_V7_LPBIG_OFFBIG: ::c_int = 140; +pub const _SC_XOPEN_STREAMS: ::c_int = 141; +pub const _SC_XOPEN_UUCP: ::c_int = 142; + pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2; @@ -652,6 +748,10 @@ pub const F_SETOWN: ::c_int = 8; pub const F_SETLK: ::c_int = 6; pub const F_SETLKW: ::c_int = 7; +pub const F_RDLCK: ::c_int = 0; +pub const F_WRLCK: ::c_int = 1; +pub const F_UNLCK: ::c_int = 2; + pub const TCGETS: ::c_int = 0x5401; pub const TCSETS: ::c_int = 0x5402; pub const TCSETSW: ::c_int = 0x5403; @@ -860,6 +960,49 @@ pub const NLMSG_DONE: ::c_int = 0x3; pub const NLMSG_OVERRUN: ::c_int = 0x4; pub const NLMSG_MIN_TYPE: ::c_int = 0x10; +pub const GENL_NAMSIZ: ::c_int = 16; + +pub const GENL_MIN_ID: ::c_int = NLMSG_MIN_TYPE; +pub const GENL_MAX_ID: ::c_int = 1023; + +pub const GENL_ADMIN_PERM: ::c_int = 0x01; +pub const GENL_CMD_CAP_DO: ::c_int = 0x02; +pub const GENL_CMD_CAP_DUMP: ::c_int = 0x04; +pub const GENL_CMD_CAP_HASPOL: ::c_int = 0x08; +pub const GENL_UNS_ADMIN_PERM: ::c_int = 0x10; + +pub const GENL_ID_CTRL: ::c_int = NLMSG_MIN_TYPE; +pub const GENL_ID_VFS_DQUOT: ::c_int = NLMSG_MIN_TYPE + 1; +pub const GENL_ID_PMCRAID: ::c_int = NLMSG_MIN_TYPE + 2; + +pub const CTRL_CMD_UNSPEC: ::c_int = 0; +pub const CTRL_CMD_NEWFAMILY: ::c_int = 1; +pub const CTRL_CMD_DELFAMILY: ::c_int = 2; +pub const CTRL_CMD_GETFAMILY: ::c_int = 3; +pub const CTRL_CMD_NEWOPS: ::c_int = 4; +pub const CTRL_CMD_DELOPS: ::c_int = 5; +pub const CTRL_CMD_GETOPS: ::c_int = 6; +pub const CTRL_CMD_NEWMCAST_GRP: ::c_int = 7; +pub const CTRL_CMD_DELMCAST_GRP: ::c_int = 8; +pub const CTRL_CMD_GETMCAST_GRP: ::c_int = 9; + +pub const CTRL_ATTR_UNSPEC: ::c_int = 0; +pub const CTRL_ATTR_FAMILY_ID: ::c_int = 1; +pub const CTRL_ATTR_FAMILY_NAME: ::c_int = 2; +pub const CTRL_ATTR_VERSION: ::c_int = 3; +pub const CTRL_ATTR_HDRSIZE: ::c_int = 4; +pub const CTRL_ATTR_MAXATTR: ::c_int = 5; +pub const CTRL_ATTR_OPS: ::c_int = 6; +pub const CTRL_ATTR_MCAST_GROUPS: ::c_int = 7; + +pub const CTRL_ATTR_OP_UNSPEC: ::c_int = 0; +pub const CTRL_ATTR_OP_ID: ::c_int = 1; +pub const CTRL_ATTR_OP_FLAGS: ::c_int = 2; + +pub const CTRL_ATTR_MCAST_GRP_UNSPEC: ::c_int = 0; +pub const CTRL_ATTR_MCAST_GRP_NAME: ::c_int = 1; +pub const CTRL_ATTR_MCAST_GRP_ID: ::c_int = 2; + pub const NETLINK_ADD_MEMBERSHIP: ::c_int = 1; pub const NETLINK_DROP_MEMBERSHIP: ::c_int = 2; pub const NETLINK_PKTINFO: ::c_int = 3; @@ -879,6 +1022,8 @@ pub const NLA_F_NESTED: ::c_int = 1 << 15; pub const NLA_F_NET_BYTEORDER: ::c_int = 1 << 14; pub const NLA_TYPE_MASK: ::c_int = !(NLA_F_NESTED | NLA_F_NET_BYTEORDER); +pub const NLA_ALIGNTO: ::c_int = 4; + pub const SIGEV_THREAD_ID: ::c_int = 4; pub const CIBAUD: ::tcflag_t = 0o02003600000; @@ -912,6 +1057,422 @@ pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY; pub const MFD_CLOEXEC: ::c_uint = 0x0001; pub const MFD_ALLOW_SEALING: ::c_uint = 0x0002; +// linux/netfilter.h +pub const NF_DROP: ::c_int = 0; +pub const NF_ACCEPT: ::c_int = 1; +pub const NF_STOLEN: ::c_int = 2; +pub const NF_QUEUE: ::c_int = 3; +pub const NF_REPEAT: ::c_int = 4; +pub const NF_STOP: ::c_int = 5; +pub const NF_MAX_VERDICT: ::c_int = NF_STOP; + +pub const NF_VERDICT_MASK: ::c_int = 0x000000ff; +pub const NF_VERDICT_FLAG_QUEUE_BYPASS: ::c_int = 0x00008000; + +pub const NF_VERDICT_QMASK: ::c_int = 0xffff0000; +pub const NF_VERDICT_QBITS: ::c_int = 16; + +pub const NF_VERDICT_BITS: ::c_int = 16; + +pub const NF_INET_PRE_ROUTING: ::c_int = 0; +pub const NF_INET_LOCAL_IN: ::c_int = 1; +pub const NF_INET_FORWARD: ::c_int = 2; +pub const NF_INET_LOCAL_OUT: ::c_int = 3; +pub const NF_INET_POST_ROUTING: ::c_int = 4; +pub const NF_INET_NUMHOOKS: ::c_int = 5; + +pub const NF_NETDEV_INGRESS: ::c_int = 0; +pub const NF_NETDEV_NUMHOOKS: ::c_int = 1; + +pub const NFPROTO_UNSPEC: ::c_int = 0; +pub const NFPROTO_INET: ::c_int = 1; +pub const NFPROTO_IPV4: ::c_int = 2; +pub const NFPROTO_ARP: ::c_int = 3; +pub const NFPROTO_NETDEV: ::c_int = 5; +pub const NFPROTO_BRIDGE: ::c_int = 7; +pub const NFPROTO_IPV6: ::c_int = 10; +pub const NFPROTO_DECNET: ::c_int = 12; +pub const NFPROTO_NUMPROTO: ::c_int = 13; + +// linux/netfilter_ipv4.h +pub const NF_IP_PRE_ROUTING: ::c_int = 0; +pub const NF_IP_LOCAL_IN: ::c_int = 1; +pub const NF_IP_FORWARD: ::c_int = 2; +pub const NF_IP_LOCAL_OUT: ::c_int = 3; +pub const NF_IP_POST_ROUTING: ::c_int = 4; +pub const NF_IP_NUMHOOKS: ::c_int = 5; + +pub const NF_IP_PRI_FIRST: ::c_int = ::INT_MIN; +pub const NF_IP_PRI_CONNTRACK_DEFRAG: ::c_int = -400; +pub const NF_IP_PRI_RAW: ::c_int = -300; +pub const NF_IP_PRI_SELINUX_FIRST: ::c_int = -225; +pub const NF_IP_PRI_CONNTRACK: ::c_int = -200; +pub const NF_IP_PRI_MANGLE: ::c_int = -150; +pub const NF_IP_PRI_NAT_DST: ::c_int = -100; +pub const NF_IP_PRI_FILTER: ::c_int = 0; +pub const NF_IP_PRI_SECURITY: ::c_int = 50; +pub const NF_IP_PRI_NAT_SRC: ::c_int = 100; +pub const NF_IP_PRI_SELINUX_LAST: ::c_int = 225; +pub const NF_IP_PRI_CONNTRACK_HELPER: ::c_int = 300; +pub const NF_IP_PRI_CONNTRACK_CONFIRM: ::c_int = ::INT_MAX; +pub const NF_IP_PRI_LAST: ::c_int = ::INT_MAX; + +// linux/netfilter_ipv6.h +pub const NF_IP6_PRE_ROUTING: ::c_int = 0; +pub const NF_IP6_LOCAL_IN: ::c_int = 1; +pub const NF_IP6_FORWARD: ::c_int = 2; +pub const NF_IP6_LOCAL_OUT: ::c_int = 3; +pub const NF_IP6_POST_ROUTING: ::c_int = 4; +pub const NF_IP6_NUMHOOKS: ::c_int = 5; + +pub const NF_IP6_PRI_FIRST: ::c_int = ::INT_MIN; +pub const NF_IP6_PRI_CONNTRACK_DEFRAG: ::c_int = -400; +pub const NF_IP6_PRI_RAW: ::c_int = -300; +pub const NF_IP6_PRI_SELINUX_FIRST: ::c_int = -225; +pub const NF_IP6_PRI_CONNTRACK: ::c_int = -200; +pub const NF_IP6_PRI_MANGLE: ::c_int = -150; +pub const NF_IP6_PRI_NAT_DST: ::c_int = -100; +pub const NF_IP6_PRI_FILTER: ::c_int = 0; +pub const NF_IP6_PRI_SECURITY: ::c_int = 50; +pub const NF_IP6_PRI_NAT_SRC: ::c_int = 100; +pub const NF_IP6_PRI_SELINUX_LAST: ::c_int = 225; +pub const NF_IP6_PRI_CONNTRACK_HELPER: ::c_int = 300; +pub const NF_IP6_PRI_LAST: ::c_int = ::INT_MAX; + +// linux/netfilter/nf_tables.h +pub const NFT_TABLE_MAXNAMELEN: ::c_int = 32; +pub const NFT_CHAIN_MAXNAMELEN: ::c_int = 32; +pub const NFT_SET_MAXNAMELEN: ::c_int = 32; +pub const NFT_OBJ_MAXNAMELEN: ::c_int = 32; +pub const NFT_USERDATA_MAXLEN: ::c_int = 256; + +pub const NFT_REG_VERDICT: ::c_int = 0; +pub const NFT_REG_1: ::c_int = 1; +pub const NFT_REG_2: ::c_int = 2; +pub const NFT_REG_3: ::c_int = 3; +pub const NFT_REG_4: ::c_int = 4; +pub const __NFT_REG_MAX: ::c_int = 5; +pub const NFT_REG32_00: ::c_int = 8; +pub const NFT_REG32_01: ::c_int = 9; +pub const NFT_REG32_02: ::c_int = 10; +pub const NFT_REG32_03: ::c_int = 11; +pub const NFT_REG32_04: ::c_int = 12; +pub const NFT_REG32_05: ::c_int = 13; +pub const NFT_REG32_06: ::c_int = 14; +pub const NFT_REG32_07: ::c_int = 15; +pub const NFT_REG32_08: ::c_int = 16; +pub const NFT_REG32_09: ::c_int = 17; +pub const NFT_REG32_10: ::c_int = 18; +pub const NFT_REG32_11: ::c_int = 19; +pub const NFT_REG32_12: ::c_int = 20; +pub const NFT_REG32_13: ::c_int = 21; +pub const NFT_REG32_14: ::c_int = 22; +pub const NFT_REG32_15: ::c_int = 23; + +pub const NFT_REG_SIZE: ::c_int = 16; +pub const NFT_REG32_SIZE: ::c_int = 4; + +pub const NFT_CONTINUE: ::c_int = -1; +pub const NFT_BREAK: ::c_int = -2; +pub const NFT_JUMP: ::c_int = -3; +pub const NFT_GOTO: ::c_int = -4; +pub const NFT_RETURN: ::c_int = -5; + +pub const NFT_MSG_NEWTABLE: ::c_int = 0; +pub const NFT_MSG_GETTABLE: ::c_int = 1; +pub const NFT_MSG_DELTABLE: ::c_int = 2; +pub const NFT_MSG_NEWCHAIN: ::c_int = 3; +pub const NFT_MSG_GETCHAIN: ::c_int = 4; +pub const NFT_MSG_DELCHAIN: ::c_int = 5; +pub const NFT_MSG_NEWRULE: ::c_int = 6; +pub const NFT_MSG_GETRULE: ::c_int = 7; +pub const NFT_MSG_DELRULE: ::c_int = 8; +pub const NFT_MSG_NEWSET: ::c_int = 9; +pub const NFT_MSG_GETSET: ::c_int = 10; +pub const NFT_MSG_DELSET: ::c_int = 11; +pub const NFT_MSG_NEWSETELEM: ::c_int = 12; +pub const NFT_MSG_GETSETELEM: ::c_int = 13; +pub const NFT_MSG_DELSETELEM: ::c_int = 14; +pub const NFT_MSG_NEWGEN: ::c_int = 15; +pub const NFT_MSG_GETGEN: ::c_int = 16; +pub const NFT_MSG_TRACE: ::c_int = 17; +pub const NFT_MSG_NEWOBJ: ::c_int = 18; +pub const NFT_MSG_GETOBJ: ::c_int = 19; +pub const NFT_MSG_DELOBJ: ::c_int = 20; +pub const NFT_MSG_GETOBJ_RESET: ::c_int = 21; +pub const NFT_MSG_MAX: ::c_int = 22; + +pub const NFT_SET_ANONYMOUS: ::c_int = 0x1; +pub const NFT_SET_CONSTANT: ::c_int = 0x2; +pub const NFT_SET_INTERVAL: ::c_int = 0x4; +pub const NFT_SET_MAP: ::c_int = 0x8; +pub const NFT_SET_TIMEOUT: ::c_int = 0x10; +pub const NFT_SET_EVAL: ::c_int = 0x20; + +pub const NFT_SET_POL_PERFORMANCE: ::c_int = 0; +pub const NFT_SET_POL_MEMORY: ::c_int = 1; + +pub const NFT_SET_ELEM_INTERVAL_END: ::c_int = 0x1; + +pub const NFT_DATA_VALUE: ::c_uint = 0; +pub const NFT_DATA_VERDICT: ::c_uint = 0xffffff00; + +pub const NFT_DATA_RESERVED_MASK: ::c_uint = 0xffffff00; + +pub const NFT_DATA_VALUE_MAXLEN: ::c_int = 64; + +pub const NFT_BYTEORDER_NTOH: ::c_int = 0; +pub const NFT_BYTEORDER_HTON: ::c_int = 1; + +pub const NFT_CMP_EQ: ::c_int = 0; +pub const NFT_CMP_NEQ: ::c_int = 1; +pub const NFT_CMP_LT: ::c_int = 2; +pub const NFT_CMP_LTE: ::c_int = 3; +pub const NFT_CMP_GT: ::c_int = 4; +pub const NFT_CMP_GTE: ::c_int = 5; + +pub const NFT_RANGE_EQ: ::c_int = 0; +pub const NFT_RANGE_NEQ: ::c_int = 1; + +pub const NFT_LOOKUP_F_INV: ::c_int = (1 << 0); + +pub const NFT_DYNSET_OP_ADD: ::c_int = 0; +pub const NFT_DYNSET_OP_UPDATE: ::c_int = 1; + +pub const NFT_DYNSET_F_INV: ::c_int = (1 << 0); + +pub const NFT_PAYLOAD_LL_HEADER: ::c_int = 0; +pub const NFT_PAYLOAD_NETWORK_HEADER: ::c_int = 1; +pub const NFT_PAYLOAD_TRANSPORT_HEADER: ::c_int = 2; + +pub const NFT_PAYLOAD_CSUM_NONE: ::c_int = 0; +pub const NFT_PAYLOAD_CSUM_INET: ::c_int = 1; + +pub const NFT_META_LEN: ::c_int = 0; +pub const NFT_META_PROTOCOL: ::c_int = 1; +pub const NFT_META_PRIORITY: ::c_int = 2; +pub const NFT_META_MARK: ::c_int = 3; +pub const NFT_META_IIF: ::c_int = 4; +pub const NFT_META_OIF: ::c_int = 5; +pub const NFT_META_IIFNAME: ::c_int = 6; +pub const NFT_META_OIFNAME: ::c_int = 7; +pub const NFT_META_IIFTYPE: ::c_int = 8; +pub const NFT_META_OIFTYPE: ::c_int = 9; +pub const NFT_META_SKUID: ::c_int = 10; +pub const NFT_META_SKGID: ::c_int = 11; +pub const NFT_META_NFTRACE: ::c_int = 12; +pub const NFT_META_RTCLASSID: ::c_int = 13; +pub const NFT_META_SECMARK: ::c_int = 14; +pub const NFT_META_NFPROTO: ::c_int = 15; +pub const NFT_META_L4PROTO: ::c_int = 16; +pub const NFT_META_BRI_IIFNAME: ::c_int = 17; +pub const NFT_META_BRI_OIFNAME: ::c_int = 18; +pub const NFT_META_PKTTYPE: ::c_int = 19; +pub const NFT_META_CPU: ::c_int = 20; +pub const NFT_META_IIFGROUP: ::c_int = 21; +pub const NFT_META_OIFGROUP: ::c_int = 22; +pub const NFT_META_CGROUP: ::c_int = 23; +pub const NFT_META_PRANDOM: ::c_int = 24; + +pub const NFT_CT_STATE: ::c_int = 0; +pub const NFT_CT_DIRECTION: ::c_int = 1; +pub const NFT_CT_STATUS: ::c_int = 2; +pub const NFT_CT_MARK: ::c_int = 3; +pub const NFT_CT_SECMARK: ::c_int = 4; +pub const NFT_CT_EXPIRATION: ::c_int = 5; +pub const NFT_CT_HELPER: ::c_int = 6; +pub const NFT_CT_L3PROTOCOL: ::c_int = 7; +pub const NFT_CT_SRC: ::c_int = 8; +pub const NFT_CT_DST: ::c_int = 9; +pub const NFT_CT_PROTOCOL: ::c_int = 10; +pub const NFT_CT_PROTO_SRC: ::c_int = 11; +pub const NFT_CT_PROTO_DST: ::c_int = 12; +pub const NFT_CT_LABELS: ::c_int = 13; +pub const NFT_CT_PKTS: ::c_int = 14; +pub const NFT_CT_BYTES: ::c_int = 15; + +pub const NFT_LIMIT_PKTS: ::c_int = 0; +pub const NFT_LIMIT_PKT_BYTES: ::c_int = 1; + +pub const NFT_LIMIT_F_INV: ::c_int = (1 << 0); + +pub const NFT_QUEUE_FLAG_BYPASS: ::c_int = 0x01; +pub const NFT_QUEUE_FLAG_CPU_FANOUT: ::c_int = 0x02; +pub const NFT_QUEUE_FLAG_MASK: ::c_int = 0x03; + +pub const NFT_QUOTA_F_INV: ::c_int = (1 << 0); + +pub const NFT_REJECT_ICMP_UNREACH: ::c_int = 0; +pub const NFT_REJECT_TCP_RST: ::c_int = 1; +pub const NFT_REJECT_ICMPX_UNREACH: ::c_int = 2; + +pub const NFT_REJECT_ICMPX_NO_ROUTE: ::c_int = 0; +pub const NFT_REJECT_ICMPX_PORT_UNREACH: ::c_int = 1; +pub const NFT_REJECT_ICMPX_HOST_UNREACH: ::c_int = 2; +pub const NFT_REJECT_ICMPX_ADMIN_PROHIBITED: ::c_int = 3; + +pub const NFT_NAT_SNAT: ::c_int = 0; +pub const NFT_NAT_DNAT: ::c_int = 1; + +pub const NFT_TRACETYPE_UNSPEC: ::c_int = 0; +pub const NFT_TRACETYPE_POLICY: ::c_int = 1; +pub const NFT_TRACETYPE_RETURN: ::c_int = 2; +pub const NFT_TRACETYPE_RULE: ::c_int = 3; + +pub const NFT_NG_INCREMENTAL: ::c_int = 0; +pub const NFT_NG_RANDOM: ::c_int = 1; + +pub const IFF_TUN: ::c_int = 0x0001; +pub const IFF_TAP: ::c_int = 0x0002; +pub const IFF_NO_PI: ::c_int = 0x1000; + +// start android/platform/bionic/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; +pub const ETH_DATA_LEN: ::c_int = 1500; +pub const ETH_FRAME_LEN: ::c_int = 1514; +pub const ETH_FCS_LEN: ::c_int = 4; +pub const ETH_MIN_MTU: ::c_int = 68; +pub const ETH_MAX_MTU: ::c_int = 0xFFFF; +pub const ETH_P_LOOP: ::c_int = 0x0060; +pub const ETH_P_PUP: ::c_int = 0x0200; +pub const ETH_P_PUPAT: ::c_int = 0x0201; +pub const ETH_P_TSN: ::c_int = 0x22F0; +pub const ETH_P_IP: ::c_int = 0x0800; +pub const ETH_P_X25: ::c_int = 0x0805; +pub const ETH_P_ARP: ::c_int = 0x0806; +pub const ETH_P_BPQ: ::c_int = 0x08FF; +pub const ETH_P_IEEEPUP: ::c_int = 0x0a00; +pub const ETH_P_IEEEPUPAT: ::c_int = 0x0a01; +pub const ETH_P_BATMAN: ::c_int = 0x4305; +pub const ETH_P_DEC: ::c_int = 0x6000; +pub const ETH_P_DNA_DL: ::c_int = 0x6001; +pub const ETH_P_DNA_RC: ::c_int = 0x6002; +pub const ETH_P_DNA_RT: ::c_int = 0x6003; +pub const ETH_P_LAT: ::c_int = 0x6004; +pub const ETH_P_DIAG: ::c_int = 0x6005; +pub const ETH_P_CUST: ::c_int = 0x6006; +pub const ETH_P_SCA: ::c_int = 0x6007; +pub const ETH_P_TEB: ::c_int = 0x6558; +pub const ETH_P_RARP: ::c_int = 0x8035; +pub const ETH_P_ATALK: ::c_int = 0x809B; +pub const ETH_P_AARP: ::c_int = 0x80F3; +pub const ETH_P_8021Q: ::c_int = 0x8100; +/* see rust-lang/libc#924 pub const ETH_P_ERSPAN: ::c_int = 0x88BE;*/ +pub const ETH_P_IPX: ::c_int = 0x8137; +pub const ETH_P_IPV6: ::c_int = 0x86DD; +pub const ETH_P_PAUSE: ::c_int = 0x8808; +pub const ETH_P_SLOW: ::c_int = 0x8809; +pub const ETH_P_WCCP: ::c_int = 0x883E; +pub const ETH_P_MPLS_UC: ::c_int = 0x8847; +pub const ETH_P_MPLS_MC: ::c_int = 0x8848; +pub const ETH_P_ATMMPOA: ::c_int = 0x884c; +pub const ETH_P_PPP_DISC: ::c_int = 0x8863; +pub const ETH_P_PPP_SES: ::c_int = 0x8864; +pub const ETH_P_LINK_CTL: ::c_int = 0x886c; +pub const ETH_P_ATMFATE: ::c_int = 0x8884; +pub const ETH_P_PAE: ::c_int = 0x888E; +pub const ETH_P_AOE: ::c_int = 0x88A2; +pub const ETH_P_8021AD: ::c_int = 0x88A8; +pub const ETH_P_802_EX1: ::c_int = 0x88B5; +pub const ETH_P_TIPC: ::c_int = 0x88CA; +pub const ETH_P_MACSEC: ::c_int = 0x88E5; +pub const ETH_P_8021AH: ::c_int = 0x88E7; +pub const ETH_P_MVRP: ::c_int = 0x88F5; +pub const ETH_P_1588: ::c_int = 0x88F7; +pub const ETH_P_NCSI: ::c_int = 0x88F8; +pub const ETH_P_PRP: ::c_int = 0x88FB; +pub const ETH_P_FCOE: ::c_int = 0x8906; +/* see rust-lang/libc#924 pub const ETH_P_IBOE: ::c_int = 0x8915;*/ +pub const ETH_P_TDLS: ::c_int = 0x890D; +pub const ETH_P_FIP: ::c_int = 0x8914; +pub const ETH_P_80221: ::c_int = 0x8917; +pub const ETH_P_HSR: ::c_int = 0x892F; +/* see rust-lang/libc#924 pub const ETH_P_NSH: ::c_int = 0x894F;*/ +pub const ETH_P_LOOPBACK: ::c_int = 0x9000; +pub const ETH_P_QINQ1: ::c_int = 0x9100; +pub const ETH_P_QINQ2: ::c_int = 0x9200; +pub const ETH_P_QINQ3: ::c_int = 0x9300; +pub const ETH_P_EDSA: ::c_int = 0xDADA; +/* see rust-lang/libc#924 pub const ETH_P_IFE: ::c_int = 0xED3E;*/ +pub const ETH_P_AF_IUCV: ::c_int = 0xFBFB; +pub const ETH_P_802_3_MIN: ::c_int = 0x0600; +pub const ETH_P_802_3: ::c_int = 0x0001; +pub const ETH_P_AX25: ::c_int = 0x0002; +pub const ETH_P_ALL: ::c_int = 0x0003; +pub const ETH_P_802_2: ::c_int = 0x0004; +pub const ETH_P_SNAP: ::c_int = 0x0005; +pub const ETH_P_DDCMP: ::c_int = 0x0006; +pub const ETH_P_WAN_PPP: ::c_int = 0x0007; +pub const ETH_P_PPP_MP: ::c_int = 0x0008; +pub const ETH_P_LOCALTALK: ::c_int = 0x0009; +pub const ETH_P_CAN: ::c_int = 0x000C; +pub const ETH_P_CANFD: ::c_int = 0x000D; +pub const ETH_P_PPPTALK: ::c_int = 0x0010; +pub const ETH_P_TR_802_2: ::c_int = 0x0011; +pub const ETH_P_MOBITEX: ::c_int = 0x0015; +pub const ETH_P_CONTROL: ::c_int = 0x0016; +pub const ETH_P_IRDA: ::c_int = 0x0017; +pub const ETH_P_ECONET: ::c_int = 0x0018; +pub const ETH_P_HDLC: ::c_int = 0x0019; +pub const ETH_P_ARCNET: ::c_int = 0x001A; +pub const ETH_P_DSA: ::c_int = 0x001B; +pub const ETH_P_TRAILER: ::c_int = 0x001C; +pub const ETH_P_PHONET: ::c_int = 0x00F5; +pub const ETH_P_IEEE802154: ::c_int = 0x00F6; +pub const ETH_P_CAIF: ::c_int = 0x00F7; +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 + +pub const SIOCADDRT: ::c_ulong = 0x0000890B; +pub const SIOCDELRT: ::c_ulong = 0x0000890C; +pub const SIOCGIFNAME: ::c_ulong = 0x00008910; +pub const SIOCSIFLINK: ::c_ulong = 0x00008911; +pub const SIOCGIFCONF: ::c_ulong = 0x00008912; +pub const SIOCGIFFLAGS: ::c_ulong = 0x00008913; +pub const SIOCSIFFLAGS: ::c_ulong = 0x00008914; +pub const SIOCGIFADDR: ::c_ulong = 0x00008915; +pub const SIOCSIFADDR: ::c_ulong = 0x00008916; +pub const SIOCGIFDSTADDR: ::c_ulong = 0x00008917; +pub const SIOCSIFDSTADDR: ::c_ulong = 0x00008918; +pub const SIOCGIFBRDADDR: ::c_ulong = 0x00008919; +pub const SIOCSIFBRDADDR: ::c_ulong = 0x0000891A; +pub const SIOCGIFNETMASK: ::c_ulong = 0x0000891B; +pub const SIOCSIFNETMASK: ::c_ulong = 0x0000891C; +pub const SIOCGIFMETRIC: ::c_ulong = 0x0000891D; +pub const SIOCSIFMETRIC: ::c_ulong = 0x0000891E; +pub const SIOCGIFMEM: ::c_ulong = 0x0000891F; +pub const SIOCSIFMEM: ::c_ulong = 0x00008920; +pub const SIOCGIFMTU: ::c_ulong = 0x00008921; +pub const SIOCSIFMTU: ::c_ulong = 0x00008922; +pub const SIOCSIFHWADDR: ::c_ulong = 0x00008924; +pub const SIOCGIFENCAP: ::c_ulong = 0x00008925; +pub const SIOCSIFENCAP: ::c_ulong = 0x00008926; +pub const SIOCGIFHWADDR: ::c_ulong = 0x00008927; +pub const SIOCGIFSLAVE: ::c_ulong = 0x00008929; +pub const SIOCSIFSLAVE: ::c_ulong = 0x00008930; +pub const SIOCADDMULTI: ::c_ulong = 0x00008931; +pub const SIOCDELMULTI: ::c_ulong = 0x00008932; +pub const SIOCDARP: ::c_ulong = 0x00008953; +pub const SIOCGARP: ::c_ulong = 0x00008954; +pub const SIOCSARP: ::c_ulong = 0x00008955; +pub const SIOCDRARP: ::c_ulong = 0x00008960; +pub const SIOCGRARP: ::c_ulong = 0x00008961; +pub const SIOCSRARP: ::c_ulong = 0x00008962; +pub const SIOCGIFMAP: ::c_ulong = 0x00008970; +pub const SIOCSIFMAP: ::c_ulong = 0x00008971; + +// linux/module.h +pub const MODULE_INIT_IGNORE_MODVERSIONS: ::c_uint = 0x0001; +pub const MODULE_INIT_IGNORE_VERMAGIC: ::c_uint = 0x0002; + +// Similarity to Linux it's not used but defined for compatibility. +pub const ENOATTR: ::c_int = ::ENODATA; + f! { pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () { for slot in cpuset.__bits.iter_mut() { @@ -953,6 +1514,10 @@ f! { let mi = mi as ::dev_t; ((ma & 0xfff) << 8) | (mi & 0xff) | ((mi & 0xfff00) << 12) } + + pub fn NLA_ALIGN(len: ::c_int) -> ::c_int { + return ((len) + NLA_ALIGNTO - 1) & !(NLA_ALIGNTO - 1) + } } extern { @@ -1031,6 +1596,8 @@ extern { pub fn sched_rr_get_interval(pid: ::pid_t, tp: *mut ::timespec) -> ::c_int; pub fn sem_timedwait(sem: *mut sem_t, abstime: *const ::timespec) -> ::c_int; + pub fn sem_getvalue(sem: *mut sem_t, + sval: *mut ::c_int) -> ::c_int; pub fn sched_setparam(pid: ::pid_t, param: *const ::sched_param) -> ::c_int; pub fn setns(fd: ::c_int, nstype: ::c_int) -> ::c_int; pub fn swapoff(puath: *const ::c_char) -> ::c_int; diff --git a/libc/src/unix/notbsd/emscripten.rs b/libc/src/unix/notbsd/emscripten.rs index 90c056c..28791d8 100644 --- a/libc/src/unix/notbsd/emscripten.rs +++ b/libc/src/unix/notbsd/emscripten.rs @@ -72,42 +72,47 @@ s! { __unused5: *mut ::c_void, } - pub struct ifaddrs { - pub ifa_next: *mut ifaddrs, - pub ifa_name: *mut c_char, - pub ifa_flags: ::c_uint, - pub ifa_addr: *mut ::sockaddr, - pub ifa_netmask: *mut ::sockaddr, - pub ifa_ifu: *mut ::sockaddr, // FIXME This should be a union - pub ifa_data: *mut ::c_void - } - + #[cfg_attr(feature = "align", repr(align(4)))] pub struct pthread_mutex_t { + #[cfg(not(feature = "align"))] __align: [::c_long; 0], size: [u8; __SIZEOF_PTHREAD_MUTEX_T], } + #[cfg_attr(feature = "align", repr(align(4)))] pub struct pthread_rwlock_t { + #[cfg(not(feature = "align"))] __align: [::c_long; 0], size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], } + #[cfg_attr(feature = "align", repr(align(4)))] pub struct pthread_mutexattr_t { + #[cfg(not(feature = "align"))] __align: [::c_int; 0], size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], } + #[cfg_attr(feature = "align", repr(align(4)))] pub struct pthread_rwlockattr_t { + #[cfg(not(feature = "align"))] __align: [::c_int; 0], size: [u8; __SIZEOF_PTHREAD_RWLOCKATTR_T], } + #[cfg_attr(all(feature = "align", target_pointer_width = "32"), + repr(align(4)))] + #[cfg_attr(all(feature = "align", target_pointer_width = "64"), + repr(align(8)))] pub struct pthread_cond_t { + #[cfg(not(feature = "align"))] __align: [*const ::c_void; 0], size: [u8; __SIZEOF_PTHREAD_COND_T], } + #[cfg_attr(feature = "align", repr(align(4)))] pub struct pthread_condattr_t { + #[cfg(not(feature = "align"))] __align: [::c_int; 0], size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], } @@ -179,7 +184,12 @@ s! { pub ssi_utime: ::uint64_t, pub ssi_stime: ::uint64_t, pub ssi_addr: ::uint64_t, - _pad: [::uint8_t; 48], + pub ssi_addr_lsb: ::uint16_t, + _pad2: ::uint16_t, + pub ssi_syscall: ::int32_t, + pub ssi_call_addr: ::uint64_t, + pub ssi_arch: ::uint32_t, + _pad: [::uint8_t; 28], } pub struct fsid_t { @@ -461,6 +471,15 @@ s! { pub f_namemax: ::c_ulong, __f_spare: [::c_int; 6], } + + pub struct arpd_request { + pub req: ::c_ushort, + pub ip: u32, + pub dev: ::c_ulong, + pub stamp: ::c_ulong, + pub updated: ::c_ulong, + pub ha: [::c_uchar; ::MAX_ADDR_LEN], + } } pub const ABDAY_1: ::nl_item = 0x20000; @@ -748,18 +767,18 @@ pub const RTLD_NOW: ::c_int = 0x2; pub const TCP_MD5SIG: ::c_int = 14; -pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { - __align: [], - size: [0; __SIZEOF_PTHREAD_MUTEX_T], -}; -pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { - __align: [], - size: [0; __SIZEOF_PTHREAD_COND_T], -}; -pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { - __align: [], - size: [0; __SIZEOF_PTHREAD_RWLOCK_T], -}; +align_const! { + pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + size: [0; __SIZEOF_PTHREAD_MUTEX_T], + }; + pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + size: [0; __SIZEOF_PTHREAD_COND_T], + }; + pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + size: [0; __SIZEOF_PTHREAD_RWLOCK_T], + }; +} + pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2; @@ -1484,6 +1503,12 @@ pub const TIOCM_CD: ::c_int = TIOCM_CAR; pub const TIOCM_RI: ::c_int = TIOCM_RNG; pub const O_TMPFILE: ::c_int = 0x400000; +pub const MAX_ADDR_LEN: usize = 7; +pub const ARPD_UPDATE: ::c_ushort = 0x01; +pub const ARPD_LOOKUP: ::c_ushort = 0x02; +pub const ARPD_FLUSH: ::c_ushort = 0x03; +pub const ATF_MAGIC: ::c_int = 0x80; + f! { pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () { for slot in cpuset.bits.iter_mut() { @@ -1548,6 +1573,12 @@ f! { } extern { + pub fn abs(i: ::c_int) -> ::c_int; + pub fn atof(s: *const ::c_char) -> ::c_double; + pub fn labs(i: ::c_long) -> ::c_long; + pub fn rand() -> ::c_int; + pub fn srand(seed: ::c_uint); + pub fn setpwent(); pub fn endpwent(); pub fn getpwent() -> *mut passwd; @@ -1600,8 +1631,6 @@ extern { mode: ::mode_t) -> ::c_int; pub fn if_nameindex() -> *mut if_nameindex; pub fn if_freenameindex(ptr: *mut if_nameindex); - pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int; - pub fn freeifaddrs(ifa: *mut ::ifaddrs); pub fn mremap(addr: *mut ::c_void, len: ::size_t, @@ -1635,21 +1664,6 @@ extern { pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int; pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char; - pub fn bind(socket: ::c_int, address: *const ::sockaddr, - address_len: ::socklen_t) -> ::c_int; - - pub fn writev(fd: ::c_int, - iov: *const ::iovec, - iovcnt: ::c_int) -> ::ssize_t; - pub fn readv(fd: ::c_int, - iov: *const ::iovec, - iovcnt: ::c_int) -> ::ssize_t; - - pub fn sendmsg(fd: ::c_int, - msg: *const ::msghdr, - flags: ::c_int) -> ::ssize_t; - pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) - -> ::ssize_t; pub fn getdomainname(name: *mut ::c_char, len: ::size_t) -> ::c_int; pub fn setdomainname(name: *const ::c_char, len: ::size_t) -> ::c_int; pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut mmsghdr, vlen: ::c_uint, diff --git a/libc/src/unix/notbsd/linux/mips/mips32.rs b/libc/src/unix/notbsd/linux/mips/mips32.rs index 8fad85b..a6c08a5 100644 --- a/libc/src/unix/notbsd/linux/mips/mips32.rs +++ b/libc/src/unix/notbsd/linux/mips/mips32.rs @@ -1,3 +1,5 @@ +use pthread_mutex_t; + pub type c_char = i8; pub type c_long = i32; pub type c_ulong = u32; @@ -91,6 +93,22 @@ s! { pub f_spare: [::c_long; 5], } + 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, + __f_unused: ::c_int, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + pub struct statvfs64 { pub f_bsize: ::c_ulong, pub f_frsize: ::c_ulong, @@ -100,11 +118,8 @@ s! { pub f_files: u64, pub f_ffree: u64, pub f_favail: u64, - #[cfg(target_endian = "little")] pub f_fsid: ::c_ulong, __f_unused: ::c_int, - #[cfg(target_endian = "big")] - pub f_fsid: ::c_ulong, pub f_flag: ::c_ulong, pub f_namemax: ::c_ulong, __f_spare: [::c_int; 6], @@ -265,6 +280,57 @@ pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; +align_const! { + #[cfg(target_endian = "little")] + pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, + ], + }; + #[cfg(target_endian = "little")] + pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, + ], + }; + #[cfg(target_endian = "little")] + pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, + ], + }; + #[cfg(target_endian = "big")] + pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 0, + ], + }; + #[cfg(target_endian = "big")] + pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 0, + ], + }; + #[cfg(target_endian = "big")] + pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, + 0, 0, 0, + ], + }; +} + pub const O_LARGEFILE: ::c_int = 0x2000; pub const RLIM_INFINITY: ::rlim_t = 0x7fffffff; diff --git a/libc/src/unix/notbsd/linux/mips/mips64.rs b/libc/src/unix/notbsd/linux/mips/mips64.rs index 45b3df8..e8b02a3 100644 --- a/libc/src/unix/notbsd/linux/mips/mips64.rs +++ b/libc/src/unix/notbsd/linux/mips/mips64.rs @@ -1,3 +1,5 @@ +use pthread_mutex_t; + pub type blkcnt_t = i64; pub type blksize_t = i64; pub type c_char = i8; @@ -91,6 +93,21 @@ s! { pub f_spare: [::c_long; 5], } + 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_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + pub struct statvfs64 { pub f_bsize: ::c_ulong, pub f_frsize: ::c_ulong, @@ -247,6 +264,57 @@ pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; +align_const! { + #[cfg(target_endian = "little")] + pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + #[cfg(target_endian = "little")] + pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + #[cfg(target_endian = "little")] + pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + #[cfg(target_endian = "big")] + pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + #[cfg(target_endian = "big")] + pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + #[cfg(target_endian = "big")] + pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; +} + pub const O_LARGEFILE: ::c_int = 0; pub const RLIM_INFINITY: ::rlim_t = 0xffff_ffff_ffff_ffff; diff --git a/libc/src/unix/notbsd/linux/mips/mod.rs b/libc/src/unix/notbsd/linux/mips/mod.rs index a94e2bc..b000d6d 100644 --- a/libc/src/unix/notbsd/linux/mips/mod.rs +++ b/libc/src/unix/notbsd/linux/mips/mod.rs @@ -21,11 +21,16 @@ s! { } // FIXME this is actually a union + #[cfg_attr(all(feature = "align", target_pointer_width = "32"), + repr(align(4)))] + #[cfg_attr(all(feature = "align", target_pointer_width = "64"), + repr(align(8)))] pub struct sem_t { #[cfg(target_pointer_width = "32")] __size: [::c_char; 16], #[cfg(target_pointer_width = "64")] __size: [::c_char; 32], + #[cfg(not(feature = "align"))] __align: [::c_long; 0], } @@ -39,6 +44,44 @@ s! { pub c_ispeed: ::speed_t, pub c_ospeed: ::speed_t, } + + pub struct nlmsghdr { + pub nlmsg_len: u32, + pub nlmsg_type: u16, + pub nlmsg_flags: u16, + pub nlmsg_seq: u32, + pub nlmsg_pid: u32, + } + + pub struct nlmsgerr { + pub error: ::c_int, + pub msg: nlmsghdr, + } + + pub struct nl_pktinfo { + pub group: u32, + } + + pub struct nl_mmap_req { + pub nm_block_size: ::c_uint, + pub nm_block_nr: ::c_uint, + pub nm_frame_size: ::c_uint, + pub nm_frame_nr: ::c_uint, + } + + pub struct nl_mmap_hdr { + pub nm_status: ::c_uint, + pub nm_len: ::c_uint, + pub nm_group: u32, + pub nm_pid: u32, + pub nm_uid: u32, + pub nm_gid: u32, + } + + pub struct nlattr { + pub nla_len: u16, + pub nla_type: u16, + } } pub const SFD_CLOEXEC: ::c_int = 0x080000; @@ -354,8 +397,6 @@ pub const SO_PASSSEC: ::c_int = 34; pub const SO_TIMESTAMPNS: ::c_int = 35; pub const SCM_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS; pub const SO_MARK: ::c_int = 36; -pub const SO_TIMESTAMPING: ::c_int = 37; -pub const SCM_TIMESTAMPING: ::c_int = SO_TIMESTAMPING; pub const SO_RXQ_OVFL: ::c_int = 40; pub const SO_WIFI_STATUS: ::c_int = 41; pub const SCM_WIFI_STATUS: ::c_int = SO_WIFI_STATUS; @@ -425,6 +466,7 @@ pub const POLLWRNORM: ::c_short = 0x004; pub const POLLWRBAND: ::c_short = 0x100; pub const PTHREAD_STACK_MIN: ::size_t = 131072; +pub const PTHREAD_MUTEX_ADAPTIVE_NP: ::c_int = 3; pub const ADFS_SUPER_MAGIC: ::c_long = 0x0000adf5; pub const AFFS_SUPER_MAGIC: ::c_long = 0x0000adff; @@ -662,11 +704,212 @@ pub const EHWPOISON: ::c_int = 168; pub const SIGEV_THREAD_ID: ::c_int = 4; pub const EPOLLWAKEUP: ::c_int = 0x20000000; +pub const NF_NETDEV_INGRESS: ::c_int = 0; +pub const NF_NETDEV_NUMHOOKS: ::c_int = 1; + +pub const NFPROTO_INET: ::c_int = 1; +pub const NFPROTO_NETDEV: ::c_int = 5; + +pub const NLA_ALIGNTO: ::c_int = 4; + +pub const GENL_UNS_ADMIN_PERM: ::c_int = 0x10; + +pub const GENL_ID_VFS_DQUOT: ::c_int = ::NLMSG_MIN_TYPE + 1; +pub const GENL_ID_PMCRAID: ::c_int = ::NLMSG_MIN_TYPE + 2; + +pub const NFT_TABLE_MAXNAMELEN: ::c_int = 32; +pub const NFT_CHAIN_MAXNAMELEN: ::c_int = 32; +pub const NFT_SET_MAXNAMELEN: ::c_int = 32; +pub const NFT_OBJ_MAXNAMELEN: ::c_int = 32; +pub const NFT_USERDATA_MAXLEN: ::c_int = 256; + +pub const NFT_REG_VERDICT: ::c_int = 0; +pub const NFT_REG_1: ::c_int = 1; +pub const NFT_REG_2: ::c_int = 2; +pub const NFT_REG_3: ::c_int = 3; +pub const NFT_REG_4: ::c_int = 4; +pub const __NFT_REG_MAX: ::c_int = 5; +pub const NFT_REG32_00: ::c_int = 8; +pub const NFT_REG32_01: ::c_int = 9; +pub const NFT_REG32_02: ::c_int = 10; +pub const NFT_REG32_03: ::c_int = 11; +pub const NFT_REG32_04: ::c_int = 12; +pub const NFT_REG32_05: ::c_int = 13; +pub const NFT_REG32_06: ::c_int = 14; +pub const NFT_REG32_07: ::c_int = 15; +pub const NFT_REG32_08: ::c_int = 16; +pub const NFT_REG32_09: ::c_int = 17; +pub const NFT_REG32_10: ::c_int = 18; +pub const NFT_REG32_11: ::c_int = 19; +pub const NFT_REG32_12: ::c_int = 20; +pub const NFT_REG32_13: ::c_int = 21; +pub const NFT_REG32_14: ::c_int = 22; +pub const NFT_REG32_15: ::c_int = 23; + +pub const NFT_REG_SIZE: ::c_int = 16; +pub const NFT_REG32_SIZE: ::c_int = 4; + +pub const NFT_CONTINUE: ::c_int = -1; +pub const NFT_BREAK: ::c_int = -2; +pub const NFT_JUMP: ::c_int = -3; +pub const NFT_GOTO: ::c_int = -4; +pub const NFT_RETURN: ::c_int = -5; + +pub const NFT_MSG_NEWTABLE: ::c_int = 0; +pub const NFT_MSG_GETTABLE: ::c_int = 1; +pub const NFT_MSG_DELTABLE: ::c_int = 2; +pub const NFT_MSG_NEWCHAIN: ::c_int = 3; +pub const NFT_MSG_GETCHAIN: ::c_int = 4; +pub const NFT_MSG_DELCHAIN: ::c_int = 5; +pub const NFT_MSG_NEWRULE: ::c_int = 6; +pub const NFT_MSG_GETRULE: ::c_int = 7; +pub const NFT_MSG_DELRULE: ::c_int = 8; +pub const NFT_MSG_NEWSET: ::c_int = 9; +pub const NFT_MSG_GETSET: ::c_int = 10; +pub const NFT_MSG_DELSET: ::c_int = 11; +pub const NFT_MSG_NEWSETELEM: ::c_int = 12; +pub const NFT_MSG_GETSETELEM: ::c_int = 13; +pub const NFT_MSG_DELSETELEM: ::c_int = 14; +pub const NFT_MSG_NEWGEN: ::c_int = 15; +pub const NFT_MSG_GETGEN: ::c_int = 16; +pub const NFT_MSG_TRACE: ::c_int = 17; +pub const NFT_MSG_NEWOBJ: ::c_int = 18; +pub const NFT_MSG_GETOBJ: ::c_int = 19; +pub const NFT_MSG_DELOBJ: ::c_int = 20; +pub const NFT_MSG_GETOBJ_RESET: ::c_int = 21; +pub const NFT_MSG_MAX: ::c_int = 22; + +pub const NFT_SET_ANONYMOUS: ::c_int = 0x1; +pub const NFT_SET_CONSTANT: ::c_int = 0x2; +pub const NFT_SET_INTERVAL: ::c_int = 0x4; +pub const NFT_SET_MAP: ::c_int = 0x8; +pub const NFT_SET_TIMEOUT: ::c_int = 0x10; +pub const NFT_SET_EVAL: ::c_int = 0x20; + +pub const NFT_SET_POL_PERFORMANCE: ::c_int = 0; +pub const NFT_SET_POL_MEMORY: ::c_int = 1; + +pub const NFT_SET_ELEM_INTERVAL_END: ::c_int = 0x1; + +pub const NFT_DATA_VALUE: ::c_uint = 0; +pub const NFT_DATA_VERDICT: ::c_uint = 0xffffff00; + +pub const NFT_DATA_RESERVED_MASK: ::c_uint = 0xffffff00; + +pub const NFT_DATA_VALUE_MAXLEN: ::c_int = 64; + +pub const NFT_BYTEORDER_NTOH: ::c_int = 0; +pub const NFT_BYTEORDER_HTON: ::c_int = 1; + +pub const NFT_CMP_EQ: ::c_int = 0; +pub const NFT_CMP_NEQ: ::c_int = 1; +pub const NFT_CMP_LT: ::c_int = 2; +pub const NFT_CMP_LTE: ::c_int = 3; +pub const NFT_CMP_GT: ::c_int = 4; +pub const NFT_CMP_GTE: ::c_int = 5; + +pub const NFT_RANGE_EQ: ::c_int = 0; +pub const NFT_RANGE_NEQ: ::c_int = 1; + +pub const NFT_LOOKUP_F_INV: ::c_int = (1 << 0); + +pub const NFT_DYNSET_OP_ADD: ::c_int = 0; +pub const NFT_DYNSET_OP_UPDATE: ::c_int = 1; + +pub const NFT_DYNSET_F_INV: ::c_int = (1 << 0); + +pub const NFT_PAYLOAD_LL_HEADER: ::c_int = 0; +pub const NFT_PAYLOAD_NETWORK_HEADER: ::c_int = 1; +pub const NFT_PAYLOAD_TRANSPORT_HEADER: ::c_int = 2; + +pub const NFT_PAYLOAD_CSUM_NONE: ::c_int = 0; +pub const NFT_PAYLOAD_CSUM_INET: ::c_int = 1; + +pub const NFT_META_LEN: ::c_int = 0; +pub const NFT_META_PROTOCOL: ::c_int = 1; +pub const NFT_META_PRIORITY: ::c_int = 2; +pub const NFT_META_MARK: ::c_int = 3; +pub const NFT_META_IIF: ::c_int = 4; +pub const NFT_META_OIF: ::c_int = 5; +pub const NFT_META_IIFNAME: ::c_int = 6; +pub const NFT_META_OIFNAME: ::c_int = 7; +pub const NFT_META_IIFTYPE: ::c_int = 8; +pub const NFT_META_OIFTYPE: ::c_int = 9; +pub const NFT_META_SKUID: ::c_int = 10; +pub const NFT_META_SKGID: ::c_int = 11; +pub const NFT_META_NFTRACE: ::c_int = 12; +pub const NFT_META_RTCLASSID: ::c_int = 13; +pub const NFT_META_SECMARK: ::c_int = 14; +pub const NFT_META_NFPROTO: ::c_int = 15; +pub const NFT_META_L4PROTO: ::c_int = 16; +pub const NFT_META_BRI_IIFNAME: ::c_int = 17; +pub const NFT_META_BRI_OIFNAME: ::c_int = 18; +pub const NFT_META_PKTTYPE: ::c_int = 19; +pub const NFT_META_CPU: ::c_int = 20; +pub const NFT_META_IIFGROUP: ::c_int = 21; +pub const NFT_META_OIFGROUP: ::c_int = 22; +pub const NFT_META_CGROUP: ::c_int = 23; +pub const NFT_META_PRANDOM: ::c_int = 24; + +pub const NFT_CT_STATE: ::c_int = 0; +pub const NFT_CT_DIRECTION: ::c_int = 1; +pub const NFT_CT_STATUS: ::c_int = 2; +pub const NFT_CT_MARK: ::c_int = 3; +pub const NFT_CT_SECMARK: ::c_int = 4; +pub const NFT_CT_EXPIRATION: ::c_int = 5; +pub const NFT_CT_HELPER: ::c_int = 6; +pub const NFT_CT_L3PROTOCOL: ::c_int = 7; +pub const NFT_CT_SRC: ::c_int = 8; +pub const NFT_CT_DST: ::c_int = 9; +pub const NFT_CT_PROTOCOL: ::c_int = 10; +pub const NFT_CT_PROTO_SRC: ::c_int = 11; +pub const NFT_CT_PROTO_DST: ::c_int = 12; +pub const NFT_CT_LABELS: ::c_int = 13; +pub const NFT_CT_PKTS: ::c_int = 14; +pub const NFT_CT_BYTES: ::c_int = 15; + +pub const NFT_LIMIT_PKTS: ::c_int = 0; +pub const NFT_LIMIT_PKT_BYTES: ::c_int = 1; + +pub const NFT_LIMIT_F_INV: ::c_int = (1 << 0); + +pub const NFT_QUEUE_FLAG_BYPASS: ::c_int = 0x01; +pub const NFT_QUEUE_FLAG_CPU_FANOUT: ::c_int = 0x02; +pub const NFT_QUEUE_FLAG_MASK: ::c_int = 0x03; + +pub const NFT_QUOTA_F_INV: ::c_int = (1 << 0); + +pub const NFT_REJECT_ICMP_UNREACH: ::c_int = 0; +pub const NFT_REJECT_TCP_RST: ::c_int = 1; +pub const NFT_REJECT_ICMPX_UNREACH: ::c_int = 2; + +pub const NFT_REJECT_ICMPX_NO_ROUTE: ::c_int = 0; +pub const NFT_REJECT_ICMPX_PORT_UNREACH: ::c_int = 1; +pub const NFT_REJECT_ICMPX_HOST_UNREACH: ::c_int = 2; +pub const NFT_REJECT_ICMPX_ADMIN_PROHIBITED: ::c_int = 3; + +pub const NFT_NAT_SNAT: ::c_int = 0; +pub const NFT_NAT_DNAT: ::c_int = 1; + +pub const NFT_TRACETYPE_UNSPEC: ::c_int = 0; +pub const NFT_TRACETYPE_POLICY: ::c_int = 1; +pub const NFT_TRACETYPE_RETURN: ::c_int = 2; +pub const NFT_TRACETYPE_RULE: ::c_int = 3; + +pub const NFT_NG_INCREMENTAL: ::c_int = 0; +pub const NFT_NG_RANDOM: ::c_int = 1; + #[doc(hidden)] pub const AF_MAX: ::c_int = 42; #[doc(hidden)] pub const PF_MAX: ::c_int = AF_MAX; +f! { + pub fn NLA_ALIGN(len: ::c_int) -> ::c_int { + return ((len) + NLA_ALIGNTO - 1) & !(NLA_ALIGNTO - 1) + } +} + #[link(name = "util")] extern { pub fn sysctl(name: *mut ::c_int, diff --git a/libc/src/unix/notbsd/linux/mod.rs b/libc/src/unix/notbsd/linux/mod.rs index 6ab171d..1aeceb1 100644 --- a/libc/src/unix/notbsd/linux/mod.rs +++ b/libc/src/unix/notbsd/linux/mod.rs @@ -33,6 +33,10 @@ pub type Elf64_Word = u32; pub type Elf64_Off = u64; pub type Elf64_Addr = u64; pub type Elf64_Xword = u64; +pub type Elf64_Sxword = i64; + +pub type Elf32_Section = u16; +pub type Elf64_Section = u16; pub enum fpos64_t {} // TODO: fill this out with a struct @@ -71,24 +75,32 @@ s! { __unused5: *mut ::c_void, } - pub struct ifaddrs { - pub ifa_next: *mut ifaddrs, - pub ifa_name: *mut c_char, - pub ifa_flags: ::c_uint, - pub ifa_addr: *mut ::sockaddr, - pub ifa_netmask: *mut ::sockaddr, - pub ifa_ifu: *mut ::sockaddr, // FIXME This should be a union - pub ifa_data: *mut ::c_void - } - + #[cfg_attr(all(feature = "align", + target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc", + target_arch = "x86_64", + target_arch = "x86")), + repr(align(4)))] + #[cfg_attr(all(feature = "align", + any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc", + target_arch = "x86_64", + target_arch = "x86")))), + repr(align(8)))] pub struct pthread_mutex_t { - #[cfg(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc", - all(target_arch = "x86_64", - target_pointer_width = "32")))] + #[cfg(all(not(feature = "align"), + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc", + all(target_arch = "x86_64", + target_pointer_width = "32"))))] __align: [::c_long; 0], - #[cfg(not(any(target_arch = "mips", + #[cfg(not(any(feature = "align", + target_arch = "mips", target_arch = "arm", target_arch = "powerpc", all(target_arch = "x86_64", @@ -97,14 +109,32 @@ s! { size: [u8; __SIZEOF_PTHREAD_MUTEX_T], } + #[cfg_attr(all(feature = "align", + target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc", + target_arch = "x86_64", + target_arch = "x86")), + repr(align(4)))] + #[cfg_attr(all(feature = "align", + any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc", + target_arch = "x86_64", + target_arch = "x86")))), + repr(align(8)))] pub struct pthread_rwlock_t { - #[cfg(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc", - all(target_arch = "x86_64", - target_pointer_width = "32")))] + #[cfg(all(not(feature = "align"), + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc", + all(target_arch = "x86_64", + target_pointer_width = "32"))))] __align: [::c_long; 0], - #[cfg(not(any(target_arch = "mips", + #[cfg(not(any(feature = "align", + target_arch = "mips", target_arch = "arm", target_arch = "powerpc", all(target_arch = "x86_64", @@ -113,39 +143,78 @@ s! { size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], } + #[cfg_attr(all(feature = "align", + any(target_pointer_width = "32", + target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64", + all(target_arch = "aarch64", target_env = "musl"))), + repr(align(4)))] + #[cfg_attr(all(feature = "align", + not(any(target_pointer_width = "32", + target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64", + all(target_arch = "aarch64", target_env = "musl")))), + repr(align(8)))] pub struct pthread_mutexattr_t { - #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64"))] - __align: [::c_int; 0], - #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64", + #[cfg(all(not(features = "align"), + any(target_arch = "x86_64", target_arch = "powerpc64", target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64", target_arch = "aarch64")))] - __align: [::c_long; 0], - #[cfg(all(target_arch = "aarch64", target_env = "gnu"))] - __align: [::c_long; 0], - #[cfg(all(target_arch = "aarch64", target_env = "musl"))] + target_arch = "sparc64", + all(target_arch = "aarch64", target_env = "musl"))))] __align: [::c_int; 0], + #[cfg(all(not(features = "align"), + not(any(target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64", + all(target_arch = "aarch64", target_env = "musl")))))] + __align: [::c_long; 0], size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], } + #[cfg_attr(all(feature = "align", + any(target_env = "musl", target_pointer_width = "32")), + repr(align(4)))] + #[cfg_attr(all(feature = "align", + not(target_env = "musl"), + target_pointer_width = "64"), + repr(align(8)))] pub struct pthread_rwlockattr_t { - #[cfg(any(target_env = "musl"))] + #[cfg(all(not(feature = "align"), target_env = "musl"))] __align: [::c_int; 0], - #[cfg(not(any(target_env = "musl")))] + #[cfg(all(not(feature = "align"), not(target_env = "musl")))] __align: [::c_long; 0], size: [u8; __SIZEOF_PTHREAD_RWLOCKATTR_T], } + #[cfg_attr(all(feature = "align", + target_env = "musl", + target_pointer_width = "32"), + repr(align(4)))] + #[cfg_attr(all(feature = "align", + target_env = "musl", + target_pointer_width = "64"), + repr(align(8)))] + #[cfg_attr(all(feature = "align", + not(target_env = "musl"), + target_arch = "x86"), + repr(align(4)))] + #[cfg_attr(all(feature = "align", + not(target_env = "musl"), + not(target_arch = "x86")), + repr(align(8)))] pub struct pthread_cond_t { - #[cfg(any(target_env = "musl"))] + #[cfg(all(not(feature = "align"), target_env = "musl"))] __align: [*const ::c_void; 0], - #[cfg(not(any(target_env = "musl")))] + #[cfg(not(any(feature = "align", target_env = "musl")))] __align: [::c_longlong; 0], size: [u8; __SIZEOF_PTHREAD_COND_T], } + #[cfg_attr(feature = "align", repr(align(4)))] pub struct pthread_condattr_t { + #[cfg(not(feature = "align"))] __align: [::c_int; 0], size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], } @@ -172,26 +241,6 @@ s! { pub sp_flag: ::c_ulong, } - 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, - #[cfg(target_endian = "little")] - pub f_fsid: ::c_ulong, - #[cfg(all(target_pointer_width = "32", not(target_arch = "x86_64")))] - __f_unused: ::c_int, - #[cfg(target_endian = "big")] - pub f_fsid: ::c_ulong, - pub f_flag: ::c_ulong, - pub f_namemax: ::c_ulong, - __f_spare: [::c_int; 6], - } - pub struct dqblk { pub dqb_bhardlimit: ::uint64_t, pub dqb_bsoftlimit: ::uint64_t, @@ -221,7 +270,12 @@ s! { pub ssi_utime: ::uint64_t, pub ssi_stime: ::uint64_t, pub ssi_addr: ::uint64_t, - _pad: [::uint8_t; 48], + pub ssi_addr_lsb: ::uint16_t, + _pad2: ::uint16_t, + pub ssi_syscall: ::int32_t, + pub ssi_call_addr: ::uint64_t, + pub ssi_arch: ::uint32_t, + _pad: [::uint8_t; 28], } pub struct itimerspec { @@ -259,6 +313,13 @@ s! { pad: [::c_long; 4], } + pub struct packet_mreq { + pub mr_ifindex: ::c_int, + pub mr_type: ::c_ushort, + pub mr_alen: ::c_ushort, + pub mr_address: [::c_uchar; 8], + } + pub struct cpu_set_t { #[cfg(all(target_pointer_width = "32", not(target_arch = "x86_64")))] @@ -427,6 +488,58 @@ s! { pub dlpi_tls_data: *mut ::c_void, } + pub struct Elf32_Ehdr { + pub e_ident: [::c_uchar; 16], + pub e_type: Elf32_Half, + pub e_machine: Elf32_Half, + pub e_version: Elf32_Word, + pub e_entry: Elf32_Addr, + pub e_phoff: Elf32_Off, + pub e_shoff: Elf32_Off, + pub e_flags: Elf32_Word, + pub e_ehsize: Elf32_Half, + pub e_phentsize: Elf32_Half, + pub e_phnum: Elf32_Half, + pub e_shentsize: Elf32_Half, + pub e_shnum: Elf32_Half, + pub e_shstrndx: Elf32_Half, + } + + pub struct Elf64_Ehdr { + pub e_ident: [::c_uchar; 16], + pub e_type: Elf64_Half, + pub e_machine: Elf64_Half, + pub e_version: Elf64_Word, + pub e_entry: Elf64_Addr, + pub e_phoff: Elf64_Off, + pub e_shoff: Elf64_Off, + pub e_flags: Elf64_Word, + pub e_ehsize: Elf64_Half, + pub e_phentsize: Elf64_Half, + pub e_phnum: Elf64_Half, + pub e_shentsize: Elf64_Half, + pub e_shnum: Elf64_Half, + pub e_shstrndx: Elf64_Half, + } + + pub struct Elf32_Sym { + pub st_name: Elf32_Word, + pub st_value: Elf32_Addr, + pub st_size: Elf32_Word, + pub st_info: ::c_uchar, + pub st_other: ::c_uchar, + pub st_shndx: Elf32_Section, + } + + pub struct Elf64_Sym { + pub st_name: Elf64_Word, + pub st_info: ::c_uchar, + pub st_other: ::c_uchar, + pub st_shndx: Elf64_Section, + pub st_value: Elf64_Addr, + pub st_size: Elf64_Xword, + } + pub struct Elf32_Phdr { pub p_type: Elf32_Word, pub p_offset: Elf32_Off, @@ -449,6 +562,45 @@ s! { pub p_align: Elf64_Xword, } + pub struct Elf32_Shdr { + pub sh_name: Elf32_Word, + pub sh_type: Elf32_Word, + pub sh_flags: Elf32_Word, + pub sh_addr: Elf32_Addr, + pub sh_offset: Elf32_Off, + pub sh_size: Elf32_Word, + pub sh_link: Elf32_Word, + pub sh_info: Elf32_Word, + pub sh_addralign: Elf32_Word, + pub sh_entsize: Elf32_Word, + } + + pub struct Elf64_Shdr { + pub sh_name: Elf64_Word, + pub sh_type: Elf64_Word, + pub sh_flags: Elf64_Xword, + pub sh_addr: Elf64_Addr, + pub sh_offset: Elf64_Off, + pub sh_size: Elf64_Xword, + pub sh_link: Elf64_Word, + pub sh_info: Elf64_Word, + pub sh_addralign: Elf64_Xword, + pub sh_entsize: Elf64_Xword, + } + + pub struct Elf32_Chdr { + pub ch_type: Elf32_Word, + pub ch_size: Elf32_Word, + pub ch_addralign: Elf32_Word, + } + + pub struct Elf64_Chdr { + pub ch_type: Elf64_Word, + pub ch_reserved: Elf64_Word, + pub ch_size: Elf64_Xword, + pub ch_addralign: Elf64_Xword, + } + pub struct ucred { pub pid: ::pid_t, pub uid: ::uid_t, @@ -463,6 +615,46 @@ s! { pub mnt_freq: ::c_int, pub mnt_passno: ::c_int, } + + pub struct posix_spawn_file_actions_t { + __allocated: ::c_int, + __used: ::c_int, + __actions: *mut ::c_int, + __pad: [::c_int; 16], + } + + pub struct posix_spawnattr_t { + __flags: ::c_short, + __pgrp: ::pid_t, + __sd: ::sigset_t, + __ss: ::sigset_t, + #[cfg(target_env = "musl")] + __prio: ::c_int, + #[cfg(not(target_env = "musl"))] + __sp: ::sched_param, + __policy: ::c_int, + __pad: [::c_int; 16], + } + + pub struct genlmsghdr { + pub cmd: u8, + pub version: u8, + pub reserved: u16, + } + + pub struct in6_pktinfo { + pub ipi6_addr: ::in6_addr, + pub ipi6_ifindex: ::c_uint, + } + + pub struct arpd_request { + pub req: ::c_ushort, + pub ip: u32, + pub dev: ::c_ulong, + pub stamp: ::c_ulong, + pub updated: ::c_ulong, + pub ha: [::c_uchar; ::MAX_ADDR_LEN], + } } pub const ABDAY_1: ::nl_item = 0x20000; @@ -736,16 +928,15 @@ pub const IFF_DORMANT: ::c_int = 0x20000; pub const IFF_ECHO: ::c_int = 0x40000; // linux/if_tun.h +pub const IFF_TUN: ::c_short = 0x0001; +pub const IFF_TAP: ::c_short = 0x0002; +pub const IFF_NO_PI: ::c_short = 0x1000; // Read queue size pub const TUN_READQ_SIZE: ::c_short = 500; // TUN device type flags: deprecated. Use IFF_TUN/IFF_TAP instead. -pub const TUN_TUN_DEV: ::c_short = IFF_TUN; -pub const TUN_TAP_DEV: ::c_short = IFF_TAP; +pub const TUN_TUN_DEV: ::c_short = ::IFF_TUN; +pub const TUN_TAP_DEV: ::c_short = ::IFF_TAP; pub const TUN_TYPE_MASK: ::c_short = 0x000f; -// TUNSETIFF ifr flags -pub const IFF_TUN: ::c_short = 0x0001; -pub const IFF_TAP: ::c_short = 0x0002; -pub const IFF_NO_PI: ::c_short = 0x1000; // This flag has no real effect pub const IFF_ONE_QUEUE: ::c_short = 0x2000; pub const IFF_VNET_HDR: ::c_short = 0x4000; @@ -776,18 +967,17 @@ pub const RTLD_NOW: ::c_int = 0x2; pub const TCP_MD5SIG: ::c_int = 14; -pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { - __align: [], - size: [0; __SIZEOF_PTHREAD_MUTEX_T], -}; -pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { - __align: [], - size: [0; __SIZEOF_PTHREAD_COND_T], -}; -pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { - __align: [], - size: [0; __SIZEOF_PTHREAD_RWLOCK_T], -}; +align_const! { + pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + size: [0; __SIZEOF_PTHREAD_MUTEX_T], + }; + pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + size: [0; __SIZEOF_PTHREAD_COND_T], + }; + pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + size: [0; __SIZEOF_PTHREAD_RWLOCK_T], + }; +} pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2; @@ -868,10 +1058,12 @@ pub const AF_IB: ::c_int = 27; pub const AF_MPLS: ::c_int = 28; pub const AF_NFC: ::c_int = 39; pub const AF_VSOCK: ::c_int = 40; +pub const AF_XDP: ::c_int = 44; pub const PF_IB: ::c_int = AF_IB; pub const PF_MPLS: ::c_int = AF_MPLS; pub const PF_NFC: ::c_int = AF_NFC; pub const PF_VSOCK: ::c_int = AF_VSOCK; +pub const PF_XDP: ::c_int = AF_XDP; // System V IPC pub const IPC_PRIVATE: ::key_t = 0; @@ -1238,6 +1430,269 @@ pub const ETH_P_PHONET: ::c_int = 0x00F5; pub const ETH_P_IEEE802154: ::c_int = 0x00F6; pub const ETH_P_CAIF: ::c_int = 0x00F7; +pub const POSIX_SPAWN_RESETIDS: ::c_int = 0x01; +pub const POSIX_SPAWN_SETPGROUP: ::c_int = 0x02; +pub const POSIX_SPAWN_SETSIGDEF: ::c_int = 0x04; +pub const POSIX_SPAWN_SETSIGMASK: ::c_int = 0x08; +pub const POSIX_SPAWN_SETSCHEDPARAM: ::c_int = 0x10; +pub const POSIX_SPAWN_SETSCHEDULER: ::c_int = 0x20; + +pub const NLMSG_NOOP: ::c_int = 0x1; +pub const NLMSG_ERROR: ::c_int = 0x2; +pub const NLMSG_DONE: ::c_int = 0x3; +pub const NLMSG_OVERRUN: ::c_int = 0x4; +pub const NLMSG_MIN_TYPE: ::c_int = 0x10; + +pub const GENL_NAMSIZ: ::c_int = 16; + +pub const GENL_MIN_ID: ::c_int = NLMSG_MIN_TYPE; +pub const GENL_MAX_ID: ::c_int = 1023; + +pub const GENL_ADMIN_PERM: ::c_int = 0x01; +pub const GENL_CMD_CAP_DO: ::c_int = 0x02; +pub const GENL_CMD_CAP_DUMP: ::c_int = 0x04; +pub const GENL_CMD_CAP_HASPOL: ::c_int = 0x08; + +pub const GENL_ID_CTRL: ::c_int = NLMSG_MIN_TYPE; + +pub const CTRL_CMD_UNSPEC: ::c_int = 0; +pub const CTRL_CMD_NEWFAMILY: ::c_int = 1; +pub const CTRL_CMD_DELFAMILY: ::c_int = 2; +pub const CTRL_CMD_GETFAMILY: ::c_int = 3; +pub const CTRL_CMD_NEWOPS: ::c_int = 4; +pub const CTRL_CMD_DELOPS: ::c_int = 5; +pub const CTRL_CMD_GETOPS: ::c_int = 6; +pub const CTRL_CMD_NEWMCAST_GRP: ::c_int = 7; +pub const CTRL_CMD_DELMCAST_GRP: ::c_int = 8; +pub const CTRL_CMD_GETMCAST_GRP: ::c_int = 9; + +pub const CTRL_ATTR_UNSPEC: ::c_int = 0; +pub const CTRL_ATTR_FAMILY_ID: ::c_int = 1; +pub const CTRL_ATTR_FAMILY_NAME: ::c_int = 2; +pub const CTRL_ATTR_VERSION: ::c_int = 3; +pub const CTRL_ATTR_HDRSIZE: ::c_int = 4; +pub const CTRL_ATTR_MAXATTR: ::c_int = 5; +pub const CTRL_ATTR_OPS: ::c_int = 6; +pub const CTRL_ATTR_MCAST_GROUPS: ::c_int = 7; + +pub const CTRL_ATTR_OP_UNSPEC: ::c_int = 0; +pub const CTRL_ATTR_OP_ID: ::c_int = 1; +pub const CTRL_ATTR_OP_FLAGS: ::c_int = 2; + +pub const CTRL_ATTR_MCAST_GRP_UNSPEC: ::c_int = 0; +pub const CTRL_ATTR_MCAST_GRP_NAME: ::c_int = 1; +pub const CTRL_ATTR_MCAST_GRP_ID: ::c_int = 2; + +// linux/if_packet.h +pub const PACKET_ADD_MEMBERSHIP: ::c_int = 1; +pub const PACKET_DROP_MEMBERSHIP: ::c_int = 2; + +pub const PACKET_MR_MULTICAST: ::c_int = 0; +pub const PACKET_MR_PROMISC: ::c_int = 1; +pub const PACKET_MR_ALLMULTI: ::c_int = 2; +pub const PACKET_MR_UNICAST: ::c_int = 3; + +// linux/netfilter.h +pub const NF_DROP: ::c_int = 0; +pub const NF_ACCEPT: ::c_int = 1; +pub const NF_STOLEN: ::c_int = 2; +pub const NF_QUEUE: ::c_int = 3; +pub const NF_REPEAT: ::c_int = 4; +pub const NF_STOP: ::c_int = 5; +pub const NF_MAX_VERDICT: ::c_int = NF_STOP; + +pub const NF_VERDICT_MASK: ::c_int = 0x000000ff; +pub const NF_VERDICT_FLAG_QUEUE_BYPASS: ::c_int = 0x00008000; + +pub const NF_VERDICT_QMASK: ::c_int = 0xffff0000; +pub const NF_VERDICT_QBITS: ::c_int = 16; + +pub const NF_VERDICT_BITS: ::c_int = 16; + +pub const NF_INET_PRE_ROUTING: ::c_int = 0; +pub const NF_INET_LOCAL_IN: ::c_int = 1; +pub const NF_INET_FORWARD: ::c_int = 2; +pub const NF_INET_LOCAL_OUT: ::c_int = 3; +pub const NF_INET_POST_ROUTING: ::c_int = 4; +pub const NF_INET_NUMHOOKS: ::c_int = 5; + +// Some NFPROTO are not compatible with musl and are defined in submodules. +pub const NFPROTO_UNSPEC: ::c_int = 0; +pub const NFPROTO_IPV4: ::c_int = 2; +pub const NFPROTO_ARP: ::c_int = 3; +pub const NFPROTO_BRIDGE: ::c_int = 7; +pub const NFPROTO_IPV6: ::c_int = 10; +pub const NFPROTO_DECNET: ::c_int = 12; +pub const NFPROTO_NUMPROTO: ::c_int = 13; + +// linux/netfilter_ipv4.h +pub const NF_IP_PRE_ROUTING: ::c_int = 0; +pub const NF_IP_LOCAL_IN: ::c_int = 1; +pub const NF_IP_FORWARD: ::c_int = 2; +pub const NF_IP_LOCAL_OUT: ::c_int = 3; +pub const NF_IP_POST_ROUTING: ::c_int = 4; +pub const NF_IP_NUMHOOKS: ::c_int = 5; + +pub const NF_IP_PRI_FIRST: ::c_int = ::INT_MIN; +pub const NF_IP_PRI_CONNTRACK_DEFRAG: ::c_int = -400; +pub const NF_IP_PRI_RAW: ::c_int = -300; +pub const NF_IP_PRI_SELINUX_FIRST: ::c_int = -225; +pub const NF_IP_PRI_CONNTRACK: ::c_int = -200; +pub const NF_IP_PRI_MANGLE: ::c_int = -150; +pub const NF_IP_PRI_NAT_DST: ::c_int = -100; +pub const NF_IP_PRI_FILTER: ::c_int = 0; +pub const NF_IP_PRI_SECURITY: ::c_int = 50; +pub const NF_IP_PRI_NAT_SRC: ::c_int = 100; +pub const NF_IP_PRI_SELINUX_LAST: ::c_int = 225; +pub const NF_IP_PRI_CONNTRACK_HELPER: ::c_int = 300; +pub const NF_IP_PRI_CONNTRACK_CONFIRM: ::c_int = ::INT_MAX; +pub const NF_IP_PRI_LAST: ::c_int = ::INT_MAX; + +// linux/netfilter_ipv6.h +pub const NF_IP6_PRE_ROUTING: ::c_int = 0; +pub const NF_IP6_LOCAL_IN: ::c_int = 1; +pub const NF_IP6_FORWARD: ::c_int = 2; +pub const NF_IP6_LOCAL_OUT: ::c_int = 3; +pub const NF_IP6_POST_ROUTING: ::c_int = 4; +pub const NF_IP6_NUMHOOKS: ::c_int = 5; + +pub const NF_IP6_PRI_FIRST: ::c_int = ::INT_MIN; +pub const NF_IP6_PRI_CONNTRACK_DEFRAG: ::c_int = -400; +pub const NF_IP6_PRI_RAW: ::c_int = -300; +pub const NF_IP6_PRI_SELINUX_FIRST: ::c_int = -225; +pub const NF_IP6_PRI_CONNTRACK: ::c_int = -200; +pub const NF_IP6_PRI_MANGLE: ::c_int = -150; +pub const NF_IP6_PRI_NAT_DST: ::c_int = -100; +pub const NF_IP6_PRI_FILTER: ::c_int = 0; +pub const NF_IP6_PRI_SECURITY: ::c_int = 50; +pub const NF_IP6_PRI_NAT_SRC: ::c_int = 100; +pub const NF_IP6_PRI_SELINUX_LAST: ::c_int = 225; +pub const NF_IP6_PRI_CONNTRACK_HELPER: ::c_int = 300; +pub const NF_IP6_PRI_LAST: ::c_int = ::INT_MAX; + +pub const SIOCADDRT: ::c_ulong = 0x0000890B; +pub const SIOCDELRT: ::c_ulong = 0x0000890C; +pub const SIOCGIFNAME: ::c_ulong = 0x00008910; +pub const SIOCSIFLINK: ::c_ulong = 0x00008911; +pub const SIOCGIFCONF: ::c_ulong = 0x00008912; +pub const SIOCGIFFLAGS: ::c_ulong = 0x00008913; +pub const SIOCSIFFLAGS: ::c_ulong = 0x00008914; +pub const SIOCGIFADDR: ::c_ulong = 0x00008915; +pub const SIOCSIFADDR: ::c_ulong = 0x00008916; +pub const SIOCGIFDSTADDR: ::c_ulong = 0x00008917; +pub const SIOCSIFDSTADDR: ::c_ulong = 0x00008918; +pub const SIOCGIFBRDADDR: ::c_ulong = 0x00008919; +pub const SIOCSIFBRDADDR: ::c_ulong = 0x0000891A; +pub const SIOCGIFNETMASK: ::c_ulong = 0x0000891B; +pub const SIOCSIFNETMASK: ::c_ulong = 0x0000891C; +pub const SIOCGIFMETRIC: ::c_ulong = 0x0000891D; +pub const SIOCSIFMETRIC: ::c_ulong = 0x0000891E; +pub const SIOCGIFMEM: ::c_ulong = 0x0000891F; +pub const SIOCSIFMEM: ::c_ulong = 0x00008920; +pub const SIOCGIFMTU: ::c_ulong = 0x00008921; +pub const SIOCSIFMTU: ::c_ulong = 0x00008922; +pub const SIOCSIFHWADDR: ::c_ulong = 0x00008924; +pub const SIOCGIFENCAP: ::c_ulong = 0x00008925; +pub const SIOCSIFENCAP: ::c_ulong = 0x00008926; +pub const SIOCGIFHWADDR: ::c_ulong = 0x00008927; +pub const SIOCGIFSLAVE: ::c_ulong = 0x00008929; +pub const SIOCSIFSLAVE: ::c_ulong = 0x00008930; +pub const SIOCADDMULTI: ::c_ulong = 0x00008931; +pub const SIOCDELMULTI: ::c_ulong = 0x00008932; +pub const SIOCDARP: ::c_ulong = 0x00008953; +pub const SIOCGARP: ::c_ulong = 0x00008954; +pub const SIOCSARP: ::c_ulong = 0x00008955; +pub const SIOCDRARP: ::c_ulong = 0x00008960; +pub const SIOCGRARP: ::c_ulong = 0x00008961; +pub const SIOCSRARP: ::c_ulong = 0x00008962; +pub const SIOCGIFMAP: ::c_ulong = 0x00008970; +pub const SIOCSIFMAP: ::c_ulong = 0x00008971; + +pub const IPTOS_TOS_MASK: u8 = 0x1E; +pub const IPTOS_PREC_MASK: u8 = 0xE0; + +pub const RTF_UP: ::c_ushort = 0x0001; +pub const RTF_GATEWAY: ::c_ushort = 0x0002; + +pub const RTF_HOST: ::c_ushort = 0x0004; +pub const RTF_REINSTATE: ::c_ushort = 0x0008; +pub const RTF_DYNAMIC: ::c_ushort = 0x0010; +pub const RTF_MODIFIED: ::c_ushort = 0x0020; +pub const RTF_MTU: ::c_ushort = 0x0040; +pub const RTF_MSS: ::c_ushort = RTF_MTU; +pub const RTF_WINDOW: ::c_ushort = 0x0080; +pub const RTF_IRTT: ::c_ushort = 0x0100; +pub const RTF_REJECT: ::c_ushort = 0x0200; +pub const RTF_STATIC: ::c_ushort = 0x0400; +pub const RTF_XRESOLVE: ::c_ushort = 0x0800; +pub const RTF_NOFORWARD: ::c_ushort = 0x1000; +pub const RTF_THROW: ::c_ushort = 0x2000; +pub const RTF_NOPMTUDISC: ::c_ushort = 0x4000; + +pub const RTF_DEFAULT: u32 = 0x00010000; +pub const RTF_ALLONLINK: u32 = 0x00020000; +pub const RTF_ADDRCONF: u32 = 0x00040000; +pub const RTF_LINKRT: u32 = 0x00100000; +pub const RTF_NONEXTHOP: u32 = 0x00200000; +pub const RTF_CACHE: u32 = 0x01000000; +pub const RTF_FLOW: u32 = 0x02000000; +pub const RTF_POLICY: u32 = 0x04000000; + +pub const RTCF_VALVE: u32 = 0x00200000; +pub const RTCF_MASQ: u32 = 0x00400000; +pub const RTCF_NAT: u32 = 0x00800000; +pub const RTCF_DOREDIRECT: u32 = 0x01000000; +pub const RTCF_LOG: u32 = 0x02000000; +pub const RTCF_DIRECTSRC: u32 = 0x04000000; + +pub const RTF_LOCAL: u32 = 0x80000000; +pub const RTF_INTERFACE: u32 = 0x40000000; +pub const RTF_MULTICAST: u32 = 0x20000000; +pub const RTF_BROADCAST: u32 = 0x10000000; +pub const RTF_NAT: u32 = 0x08000000; +pub const RTF_ADDRCLASSMASK: u32 = 0xF8000000; + +pub const RT_CLASS_UNSPEC: u8 = 0; +pub const RT_CLASS_DEFAULT: u8 = 253; +pub const RT_CLASS_MAIN: u8 = 254; +pub const RT_CLASS_LOCAL: u8 = 255; +pub const RT_CLASS_MAX: u8 = 255; + +pub const RTMSG_OVERRUN: u32 = ::NLMSG_OVERRUN as u32; +pub const RTMSG_NEWDEVICE: u32 = 0x11; +pub const RTMSG_DELDEVICE: u32 = 0x12; +pub const RTMSG_NEWROUTE: u32 = 0x21; +pub const RTMSG_DELROUTE: u32 = 0x22; +pub const RTMSG_NEWRULE: u32 = 0x31; +pub const RTMSG_DELRULE: u32 = 0x32; +pub const RTMSG_CONTROL: u32 = 0x40; +pub const RTMSG_AR_FAILED: u32 = 0x51; + +pub const MAX_ADDR_LEN: usize = 7; +pub const ARPD_UPDATE: ::c_ushort = 0x01; +pub const ARPD_LOOKUP: ::c_ushort = 0x02; +pub const ARPD_FLUSH: ::c_ushort = 0x03; +pub const ATF_MAGIC: ::c_int = 0x80; + +#[cfg(not(target_arch = "sparc64"))] +pub const SO_TIMESTAMPING: ::c_int = 37; +#[cfg(target_arch = "sparc64")] +pub const SO_TIMESTAMPING: ::c_int = 35; +pub const SCM_TIMESTAMPING: ::c_int = SO_TIMESTAMPING; + +// linux/module.h +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; + f! { pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () { for slot in cpuset.bits.iter_mut() { @@ -1293,9 +1748,35 @@ f! { dev |= (minor & 0xffffff00) << 12; dev } + + pub fn IPTOS_TOS(tos: u8) -> u8 { + tos & IPTOS_TOS_MASK + } + + pub fn IPTOS_PREC(tos: u8) -> u8 { + tos & IPTOS_PREC_MASK + } + + pub fn RT_TOS(tos: u8) -> u8 { + tos & ::IPTOS_TOS_MASK + } + + pub fn RT_ADDRCLASS(flags: u32) -> u32 { + flags >> 23 + } + + pub fn RT_LOCALADDR(flags: u32) -> bool { + (flags & RTF_ADDRCLASSMASK) == (RTF_LOCAL | RTF_INTERFACE) + } } extern { + pub fn abs(i: ::c_int) -> ::c_int; + pub fn atof(s: *const ::c_char) -> ::c_double; + pub fn labs(i: ::c_long) -> ::c_long; + pub fn rand() -> ::c_int; + pub fn srand(seed: ::c_uint); + 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; @@ -1312,9 +1793,13 @@ extern { pub fn setpwent(); pub fn endpwent(); pub fn getpwent() -> *mut passwd; + pub fn setgrent(); + pub fn endgrent(); + pub fn getgrent() -> *mut ::group; pub fn setspent(); pub fn endspent(); pub fn getspent() -> *mut spwd; + pub fn getspnam(__name: *const ::c_char) -> *mut spwd; pub fn shm_open(name: *const c_char, oflag: ::c_int, @@ -1359,8 +1844,12 @@ extern { pub fn ftello64(stream: *mut ::FILE) -> ::off64_t; pub fn fallocate(fd: ::c_int, mode: ::c_int, offset: ::off_t, len: ::off_t) -> ::c_int; + pub fn fallocate64(fd: ::c_int, mode: ::c_int, + offset: ::off64_t, len: ::off64_t) -> ::c_int; pub fn posix_fallocate(fd: ::c_int, offset: ::off_t, len: ::off_t) -> ::c_int; + pub fn posix_fallocate64(fd: ::c_int, offset: ::off64_t, + len: ::off64_t) -> ::c_int; pub fn readahead(fd: ::c_int, offset: ::off64_t, count: ::size_t) -> ::ssize_t; pub fn getxattr(path: *const c_char, name: *const c_char, @@ -1479,9 +1968,6 @@ extern { pub fn if_freenameindex(ptr: *mut if_nameindex); pub fn sync_file_range(fd: ::c_int, offset: ::off64_t, nbytes: ::off64_t, flags: ::c_uint) -> ::c_int; - pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int; - pub fn freeifaddrs(ifa: *mut ::ifaddrs); - pub fn mremap(addr: *mut ::c_void, len: ::size_t, new_len: ::size_t, @@ -1507,7 +1993,8 @@ extern { -> ::c_int; pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int; - + pub fn remap_file_pages(addr: *mut ::c_void, size: ::size_t, prot: ::c_int, + pgoff: ::size_t, flags: ::c_int) -> ::c_int; pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, flags: ::c_int, addr: *mut ::sockaddr, addrlen: *mut ::socklen_t) -> ::ssize_t; @@ -1515,21 +2002,6 @@ extern { pub fn futimes(fd: ::c_int, times: *const ::timeval) -> ::c_int; pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char; - pub fn bind(socket: ::c_int, address: *const ::sockaddr, - address_len: ::socklen_t) -> ::c_int; - - pub fn writev(fd: ::c_int, - iov: *const ::iovec, - iovcnt: ::c_int) -> ::ssize_t; - pub fn readv(fd: ::c_int, - iov: *const ::iovec, - iovcnt: ::c_int) -> ::ssize_t; - - pub fn sendmsg(fd: ::c_int, - msg: *const ::msghdr, - flags: ::c_int) -> ::ssize_t; - pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) - -> ::ssize_t; pub fn getdomainname(name: *mut ::c_char, len: ::size_t) -> ::c_int; pub fn setdomainname(name: *const ::c_char, len: ::size_t) -> ::c_int; pub fn vhangup() -> ::c_int; @@ -1576,6 +2048,8 @@ extern { pub fn sched_rr_get_interval(pid: ::pid_t, tp: *mut ::timespec) -> ::c_int; pub fn sem_timedwait(sem: *mut sem_t, abstime: *const ::timespec) -> ::c_int; + pub fn sem_getvalue(sem: *mut sem_t, + sval: *mut ::c_int) -> ::c_int; pub fn sched_setparam(pid: ::pid_t, param: *const ::sched_param) -> ::c_int; pub fn setns(fd: ::c_int, nstype: ::c_int) -> ::c_int; pub fn swapoff(puath: *const ::c_char) -> ::c_int; @@ -1711,10 +2185,81 @@ extern { pub fn endmntent(streamp: *mut ::FILE) -> ::c_int; pub fn hasmntopt(mnt: *const ::mntent, opt: *const ::c_char) -> *mut ::c_char; + + pub fn posix_spawn(pid: *mut ::pid_t, + path: *const ::c_char, + file_actions: *const ::posix_spawn_file_actions_t, + attrp: *const ::posix_spawnattr_t, + argv: *const *mut ::c_char, + envp: *const *mut ::c_char) -> ::c_int; + pub fn posix_spawnp(pid: *mut ::pid_t, + file: *const ::c_char, + file_actions: *const ::posix_spawn_file_actions_t, + attrp: *const ::posix_spawnattr_t, + argv: *const *mut ::c_char, + envp: *const *mut ::c_char) -> ::c_int; + pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> ::c_int; + pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> ::c_int; + pub fn posix_spawnattr_getsigdefault(attr: *const posix_spawnattr_t, + default: *mut ::sigset_t) -> ::c_int; + pub fn posix_spawnattr_setsigdefault(attr: *mut posix_spawnattr_t, + default: *const ::sigset_t) -> ::c_int; + pub fn posix_spawnattr_getsigmask(attr: *const posix_spawnattr_t, + default: *mut ::sigset_t) -> ::c_int; + pub fn posix_spawnattr_setsigmask(attr: *mut posix_spawnattr_t, + default: *const ::sigset_t) -> ::c_int; + pub fn posix_spawnattr_getflags(attr: *const posix_spawnattr_t, + flags: *mut ::c_short) -> ::c_int; + pub fn posix_spawnattr_setflags(attr: *mut posix_spawnattr_t, + flags: ::c_short) -> ::c_int; + pub fn posix_spawnattr_getpgroup(attr: *const posix_spawnattr_t, + flags: *mut ::pid_t) -> ::c_int; + pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, + flags: ::pid_t) -> ::c_int; + pub fn posix_spawnattr_getschedpolicy(attr: *const posix_spawnattr_t, + flags: *mut ::c_int) -> ::c_int; + pub fn posix_spawnattr_setschedpolicy(attr: *mut posix_spawnattr_t, + flags: ::c_int) -> ::c_int; + pub fn posix_spawnattr_getschedparam( + attr: *const posix_spawnattr_t, + param: *mut ::sched_param, + ) -> ::c_int; + pub fn posix_spawnattr_setschedparam( + attr: *mut posix_spawnattr_t, + param: *const ::sched_param, + ) -> ::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; + pub fn posix_spawn_file_actions_addopen( + actions: *mut posix_spawn_file_actions_t, + fd: ::c_int, + path: *const ::c_char, + oflag: ::c_int, + mode: ::mode_t, + ) -> ::c_int; + pub fn posix_spawn_file_actions_addclose( + actions: *mut posix_spawn_file_actions_t, + fd: ::c_int, + ) -> ::c_int; + pub fn posix_spawn_file_actions_adddup2( + actions: *mut posix_spawn_file_actions_t, + fd: ::c_int, + newfd: ::c_int, + ) -> ::c_int; + pub fn fread_unlocked(ptr: *mut ::c_void, + size: ::size_t, + nobj: ::size_t, + stream: *mut ::FILE + ) -> ::size_t; } cfg_if! { - if #[cfg(any(target_env = "musl", target_os = "fuchsia"))] { + if #[cfg(target_env = "musl")] { mod musl; pub use self::musl::*; } else if #[cfg(any(target_arch = "mips", diff --git a/libc/src/unix/notbsd/linux/musl/b32/arm.rs b/libc/src/unix/notbsd/linux/musl/b32/arm.rs index 22bf16c..88d8798 100644 --- a/libc/src/unix/notbsd/linux/musl/b32/arm.rs +++ b/libc/src/unix/notbsd/linux/musl/b32/arm.rs @@ -52,6 +52,18 @@ s! { pub ss_size: ::size_t } + 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_int, + __unused1: ::c_long, + __unused2: ::c_long + } + pub struct shmid_ds { pub shm_perm: ::ipc_perm, pub shm_segsz: ::size_t, @@ -151,6 +163,9 @@ s! { } } +pub const SIGSTKSZ: ::size_t = 8192; +pub const MINSIGSTKSZ: ::size_t = 2048; + pub const O_DIRECT: ::c_int = 0x10000; pub const O_DIRECTORY: ::c_int = 0x4000; pub const O_NOFOLLOW: ::c_int = 0x8000; @@ -165,6 +180,76 @@ pub const RLIMIT_NOFILE: ::c_int = 7; pub const RLIMIT_AS: ::c_int = 9; pub const RLIMIT_NPROC: ::c_int = 6; pub const RLIMIT_MEMLOCK: ::c_int = 8; +pub const RLIMIT_NLIMITS: ::c_int = 16; + +pub const MCL_CURRENT: ::c_int = 0x0001; +pub const MCL_FUTURE: ::c_int = 0x0002; +pub const CBAUD: ::tcflag_t = 0o0010017; +pub const TAB1: ::c_int = 0x00000800; +pub const TAB2: ::c_int = 0x00001000; +pub const TAB3: ::c_int = 0x00001800; +pub const CR1: ::c_int = 0x00000200; +pub const CR2: ::c_int = 0x00000400; +pub const CR3: ::c_int = 0x00000600; +pub const FF1: ::c_int = 0x00008000; +pub const BS1: ::c_int = 0x00002000; +pub const VT1: ::c_int = 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 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 O_APPEND: ::c_int = 1024; pub const O_CREAT: ::c_int = 64; @@ -382,6 +467,9 @@ pub const TIOCMSET: ::c_int = 0x5418; pub const FIONREAD: ::c_int = 0x541B; pub const TIOCCONS: ::c_int = 0x541D; +pub const TIOCGRS485: ::c_int = 0x542E; +pub const TIOCSRS485: ::c_int = 0x542F; + pub const POLLWRNORM: ::c_short = 0x100; pub const POLLWRBAND: ::c_short = 0x200; diff --git a/libc/src/unix/notbsd/linux/musl/b32/mips.rs b/libc/src/unix/notbsd/linux/musl/b32/mips.rs index 89231a0..b0694d1 100644 --- a/libc/src/unix/notbsd/linux/musl/b32/mips.rs +++ b/libc/src/unix/notbsd/linux/musl/b32/mips.rs @@ -54,6 +54,18 @@ s! { pub ss_flags: ::c_int, } + 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_int, + __unused1: ::c_long, + __unused2: ::c_long + } + pub struct shmid_ds { pub shm_perm: ::ipc_perm, pub shm_segsz: ::size_t, @@ -162,6 +174,9 @@ s! { } } +pub const SIGSTKSZ: ::size_t = 8192; +pub const MINSIGSTKSZ: ::size_t = 2048; + pub const O_DIRECT: ::c_int = 0o100000; pub const O_DIRECTORY: ::c_int = 0o200000; pub const O_NOFOLLOW: ::c_int = 0o400000; @@ -176,6 +191,76 @@ pub const RLIMIT_NOFILE: ::c_int = 5; pub const RLIMIT_AS: ::c_int = 6; pub const RLIMIT_NPROC: ::c_int = 8; pub const RLIMIT_MEMLOCK: ::c_int = 9; +pub const RLIMIT_NLIMITS: ::c_int = 16; + +pub const MCL_CURRENT: ::c_int = 0x0001; +pub const MCL_FUTURE: ::c_int = 0x0002; +pub const CBAUD: ::tcflag_t = 0o0010017; +pub const TAB1: ::c_int = 0x00000800; +pub const TAB2: ::c_int = 0x00001000; +pub const TAB3: ::c_int = 0x00001800; +pub const CR1: ::c_int = 0x00000200; +pub const CR2: ::c_int = 0x00000400; +pub const CR3: ::c_int = 0x00000600; +pub const FF1: ::c_int = 0x00008000; +pub const BS1: ::c_int = 0x00002000; +pub const VT1: ::c_int = 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 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 O_APPEND: ::c_int = 0o010; pub const O_CREAT: ::c_int = 0o400; @@ -393,6 +478,9 @@ pub const TIOCMSET: ::c_int = 0x741A; pub const FIONREAD: ::c_int = 0x467F; pub const TIOCCONS: ::c_int = 0x80047478; +pub const TIOCGRS485: ::c_int = 0x4020542E; +pub const TIOCSRS485: ::c_int = 0xC020542F; + pub const POLLWRNORM: ::c_short = 0x4; pub const POLLWRBAND: ::c_short = 0x100; diff --git a/libc/src/unix/notbsd/linux/musl/b32/mod.rs b/libc/src/unix/notbsd/linux/musl/b32/mod.rs index f6e19d9..4128a8e 100644 --- a/libc/src/unix/notbsd/linux/musl/b32/mod.rs +++ b/libc/src/unix/notbsd/linux/musl/b32/mod.rs @@ -32,26 +32,17 @@ s! { pub struct sem_t { __val: [::c_int; 4], } - - 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_int, - __unused1: ::c_long, - __unused2: ::c_long - } } -pub const SIGSTKSZ: ::size_t = 8192; -pub const MINSIGSTKSZ: ::size_t = 2048; - pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24; +pub const TIOCINQ: ::c_int = ::FIONREAD; + +extern { + pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; +} + cfg_if! { if #[cfg(any(target_arch = "x86"))] { mod x86; @@ -62,6 +53,9 @@ cfg_if! { } else if #[cfg(any(target_arch = "arm"))] { mod arm; pub use self::arm::*; + } else if #[cfg(any(target_arch = "powerpc"))] { + mod powerpc; + pub use self::powerpc::*; } else { // Unknown target_arch } diff --git a/libc/src/unix/notbsd/linux/musl/b32/powerpc.rs b/libc/src/unix/notbsd/linux/musl/b32/powerpc.rs new file mode 100644 index 0000000..d0f2d68 --- /dev/null +++ b/libc/src/unix/notbsd/linux/musl/b32/powerpc.rs @@ -0,0 +1,869 @@ +pub type c_char = u8; +pub type wchar_t = i32; + +s! { + 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_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + __st_rdev_padding: ::c_short, + 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; 2], + } + + pub struct stat64 { + pub st_dev: ::dev_t, + 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, + pub st_rdev: ::dev_t, + __st_rdev_padding: ::c_short, + 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; 2], + } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_flags: ::c_int, + pub ss_size: ::size_t + } + + 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_int, + __pad1: ::c_int, + __pad2: ::c_longlong, + __pad3: ::c_longlong + } + + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + __unused1: ::c_int, + pub shm_atime: ::time_t, + __unused2: ::c_int, + pub shm_dtime: ::time_t, + __unused3: ::c_int, + pub shm_ctime: ::time_t, + __unused4: ::c_int, + pub shm_segsz: ::size_t, + pub shm_cpid: ::pid_t, + pub shm_lpid: ::pid_t, + pub shm_nattch: ::c_ulong, + __pad1: ::c_ulong, + __pad2: ::c_ulong, + } + + pub struct msqid_ds { + pub msg_perm: ::ipc_perm, + __unused1: ::c_int, + pub msg_stime: ::time_t, + __unused2: ::c_int, + pub msg_rtime: ::time_t, + __unused3: ::c_int, + pub msg_ctime: ::time_t, + __msg_cbytes: ::c_ulong, + pub msg_qnum: ::msgqnum_t, + pub msg_qbytes: ::msglen_t, + pub msg_lspid: ::pid_t, + pub msg_lrpid: ::pid_t, + __pad1: ::c_ulong, + __pad2: ::c_ulong, + } + + pub struct statfs { + pub f_type: ::c_ulong, + pub f_bsize: ::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_fsid: ::fsid_t, + pub f_namelen: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_flags: ::c_ulong, + pub f_spare: [::c_ulong; 4], + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_errno: ::c_int, + pub si_code: ::c_int, + pub _pad: [::c_int; 29], + _align: [usize; 0], + } + + pub struct statfs64 { + pub f_type: ::c_ulong, + pub f_bsize: ::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_fsid: ::fsid_t, + pub f_namelen: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_flags: ::c_ulong, + pub f_spare: [::c_ulong; 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, + #[cfg(target_endian = "little")] + pub f_fsid: ::c_ulong, + __f_unused: ::c_int, + #[cfg(target_endian = "big")] + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + + pub struct termios2 { + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_cc: [::cc_t; 19], + pub c_line: ::cc_t, + pub c_ispeed: ::speed_t, + pub c_ospeed: ::speed_t, + } +} + +pub const SIGSTKSZ: ::size_t = 10240; +pub const MINSIGSTKSZ: ::size_t = 4096; + +pub const O_DIRECT: ::c_int = 0x20000; +pub const O_DIRECTORY: ::c_int = 0x4000; +pub const O_NOFOLLOW: ::c_int = 0x8000; +pub const O_ASYNC: ::c_int = 0x2000; +pub const O_LARGEFILE: ::c_int = 0x10000; + +pub const FIOCLEX: ::c_int = 0x20006601; +pub const FIONBIO: ::c_int = 0x8004667E; + +pub const RLIMIT_RSS: ::c_int = 5; +pub const RLIMIT_NOFILE: ::c_int = 7; +pub const RLIMIT_AS: ::c_int = 9; +pub const RLIMIT_NPROC: ::c_int = 6; +pub const RLIMIT_MEMLOCK: ::c_int = 8; +pub const RLIMIT_NLIMITS: ::c_int = 15; + +pub const MCL_CURRENT: ::c_int = 0x2000; +pub const MCL_FUTURE: ::c_int = 0x4000; +pub const CBAUD: ::tcflag_t = 0o0000377; +pub const TAB1: ::c_int = 0x00000400; +pub const TAB2: ::c_int = 0x00000800; +pub const TAB3: ::c_int = 0x00000C00; +pub const CR1: ::c_int = 0x00001000; +pub const CR2: ::c_int = 0x00002000; +pub const CR3: ::c_int = 0x00003000; +pub const FF1: ::c_int = 0x00004000; +pub const BS1: ::c_int = 0x00008000; +pub const VT1: ::c_int = 0x00010000; +pub const VWERASE: usize = 10; +pub const VREPRINT: usize = 11; +pub const VSUSP: usize = 12; +pub const VSTART: usize = 13; +pub const VSTOP: usize = 14; +pub const VDISCARD: usize = 16; +pub const VTIME: usize = 7; +pub const IXON: ::tcflag_t = 0x00000200; +pub const IXOFF: ::tcflag_t = 0x00000400; +pub const ONLCR: ::tcflag_t = 0x00000002; +pub const CSIZE: ::tcflag_t = 0x00000300; +pub const CS6: ::tcflag_t = 0x00000100; +pub const CS7: ::tcflag_t = 0x00000200; +pub const CS8: ::tcflag_t = 0x00000300; +pub const CSTOPB: ::tcflag_t = 0x00000400; +pub const CREAD: ::tcflag_t = 0x00000800; +pub const PARENB: ::tcflag_t = 0x00001000; +pub const PARODD: ::tcflag_t = 0x00002000; +pub const HUPCL: ::tcflag_t = 0x00004000; +pub const CLOCAL: ::tcflag_t = 0x00008000; +pub const ECHOKE: ::tcflag_t = 0x00000001; +pub const ECHOE: ::tcflag_t = 0x00000002; +pub const ECHOK: ::tcflag_t = 0x00000004; +pub const ECHONL: ::tcflag_t = 0x00000010; +pub const ECHOPRT: ::tcflag_t = 0x00000020; +pub const ECHOCTL: ::tcflag_t = 0x00000040; +pub const ISIG: ::tcflag_t = 0x00000080; +pub const ICANON: ::tcflag_t = 0x00000100; +pub const PENDIN: ::tcflag_t = 0x20000000; +pub const NOFLSH: ::tcflag_t = 0x80000000; +pub const CIBAUD: ::tcflag_t = 0o00077600000; +pub const CBAUDEX: ::tcflag_t = 0o000020; +pub const VSWTC: usize = 9; +pub const OLCUC: ::tcflag_t = 0o000004; +pub const NLDLY: ::tcflag_t = 0o001400; +pub const CRDLY: ::tcflag_t = 0o030000; +pub const TABDLY: ::tcflag_t = 0o006000; +pub const BSDLY: ::tcflag_t = 0o100000; +pub const FFDLY: ::tcflag_t = 0o040000; +pub const VTDLY: ::tcflag_t = 0o200000; +pub const XTABS: ::tcflag_t = 0o006000; +pub const B57600: ::speed_t = 0o000020; +pub const B115200: ::speed_t = 0o000021; +pub const B230400: ::speed_t = 0o000022; +pub const B460800: ::speed_t = 0o000023; +pub const B500000: ::speed_t = 0o000024; +pub const B576000: ::speed_t = 0o000025; +pub const B921600: ::speed_t = 0o000026; +pub const B1000000: ::speed_t = 0o000027; +pub const B1152000: ::speed_t = 0o000030; +pub const B1500000: ::speed_t = 0o000031; +pub const B2000000: ::speed_t = 0o000032; +pub const B2500000: ::speed_t = 0o000033; +pub const B3000000: ::speed_t = 0o000034; +pub const B3500000: ::speed_t = 0o000035; +pub const B4000000: ::speed_t = 0o000036; + +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 SOCK_NONBLOCK: ::c_int = 2048; + +pub const MAP_ANON: ::c_int = 0x0020; +pub const MAP_GROWSDOWN: ::c_int = 0x0100; +pub const MAP_DENYWRITE: ::c_int = 0x0800; +pub const MAP_EXECUTABLE: ::c_int = 0x01000; +pub const MAP_LOCKED: ::c_int = 0x00080; +pub const MAP_NORESERVE: ::c_int = 0x00040; +pub const MAP_POPULATE: ::c_int = 0x08000; +pub const MAP_NONBLOCK: ::c_int = 0x010000; +pub const MAP_STACK: ::c_int = 0x020000; + +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; +pub const SOCK_SEQPACKET: ::c_int = 5; + +pub const SOL_SOCKET: ::c_int = 1; + +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 EDEADLOCK: ::c_int = 58; +pub const EMULTIHOP: ::c_int = 72; +pub const EBADMSG: ::c_int = 74; +pub const EOVERFLOW: ::c_int = 75; +pub const ENOTUNIQ: ::c_int = 76; +pub const EBADFD: ::c_int = 77; +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 ENOTSUP: ::c_int = EOPNOTSUPP; +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 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 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 ERFKILL: ::c_int = 132; +pub const EHWPOISON: ::c_int = 133; + +pub const SO_REUSEADDR: ::c_int = 2; +pub const SO_TYPE: ::c_int = 3; +pub const SO_ERROR: ::c_int = 4; +pub const SO_DONTROUTE: ::c_int = 5; +pub const SO_BROADCAST: ::c_int = 6; +pub const SO_SNDBUF: ::c_int = 7; +pub const SO_RCVBUF: ::c_int = 8; +pub const SO_KEEPALIVE: ::c_int = 9; +pub const SO_OOBINLINE: ::c_int = 10; +pub const SO_NO_CHECK: ::c_int = 11; +pub const SO_PRIORITY: ::c_int = 12; +pub const SO_LINGER: ::c_int = 13; +pub const SO_BSDCOMPAT: ::c_int = 14; +pub const SO_REUSEPORT: ::c_int = 15; +pub const SO_RCVLOWAT: ::c_int = 16; +pub const SO_SNDLOWAT: ::c_int = 17; +pub const SO_RCVTIMEO: ::c_int = 18; +pub const SO_SNDTIMEO: ::c_int = 19; +pub const SO_PASSCRED: ::c_int = 20; +pub const SO_PEERCRED: ::c_int = 21; +pub const SO_ACCEPTCONN: ::c_int = 30; +pub const SO_SNDBUFFORCE: ::c_int = 32; +pub const SO_RCVBUFFORCE: ::c_int = 33; +pub const SO_PROTOCOL: ::c_int = 38; +pub const SO_DOMAIN: ::c_int = 39; + +pub const SA_ONSTACK: ::c_int = 0x08000000; +pub const SA_SIGINFO: ::c_int = 0x00000004; +pub const SA_NOCLDWAIT: ::c_int = 0x00000002; + +pub const SIGCHLD: ::c_int = 17; +pub const SIGBUS: ::c_int = 7; +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 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; +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 EXTPROC: ::tcflag_t = 0x10000000; + +pub const MAP_HUGETLB: ::c_int = 0x040000; + +pub const F_GETLK: ::c_int = 12; +pub const F_GETOWN: ::c_int = 9; +pub const F_SETLK: ::c_int = 13; +pub const F_SETLKW: ::c_int = 14; +pub const F_SETOWN: ::c_int = 8; + +pub const VEOF: usize = 4; +pub const VEOL: usize = 6; +pub const VEOL2: usize = 8; +pub const VMIN: usize = 5; +pub const IEXTEN: ::tcflag_t = 0x00000400; +pub const TOSTOP: ::tcflag_t = 0x00400000; +pub const FLUSHO: ::tcflag_t = 0x00800000; + +pub const TCGETS: ::c_int = 0x402C7413; +pub const TCSETS: ::c_int = 0x802C7414; +pub const TCSETSW: ::c_int = 0x802C7415; +pub const TCSETSF: ::c_int = 0x802C7416; +pub const TCGETA: ::c_int = 0x40147417; +pub const TCSETA: ::c_int = 0x80147418; +pub const TCSETAW: ::c_int = 0x80147419; +pub const TCSETAF: ::c_int = 0x8014741C; +pub const TCSBRK: ::c_int = 0x2000741D; +pub const TCXONC: ::c_int = 0x2000741E; +pub const TCFLSH: ::c_int = 0x2000741F; +pub const TIOCGSOFTCAR: ::c_int = 0x5419; +pub const TIOCSSOFTCAR: ::c_int = 0x541A; +pub const TIOCLINUX: ::c_int = 0x541C; +pub const TIOCGSERIAL: ::c_int = 0x541E; +pub const TIOCEXCL: ::c_int = 0x540C; +pub const TIOCNXCL: ::c_int = 0x540D; +pub const TIOCSCTTY: ::c_int = 0x540E; +pub const TIOCGPGRP: ::c_int = 0x40047477; +pub const TIOCSPGRP: ::c_int = 0x80047476; +pub const TIOCOUTQ: ::c_int = 0x40047473; +pub const TIOCSTI: ::c_int = 0x5412; +pub const TIOCGWINSZ: ::c_int = 0x40087468; +pub const TIOCSWINSZ: ::c_int = 0x80087467; +pub const TIOCMGET: ::c_int = 0x5415; +pub const TIOCMBIS: ::c_int = 0x5416; +pub const TIOCMBIC: ::c_int = 0x5417; +pub const TIOCMSET: ::c_int = 0x5418; +pub const FIONREAD: ::c_int = 0x4004667F; +pub const TIOCCONS: ::c_int = 0x541D; + +pub const TIOCGRS485: ::c_int = 0x542e; +pub const TIOCSRS485: ::c_int = 0x542f; + +pub const POLLWRNORM: ::c_short = 0x100; +pub const POLLWRBAND: ::c_short = 0x200; + +pub const TIOCM_LE: ::c_int = 0x001; +pub const TIOCM_DTR: ::c_int = 0x002; +pub const TIOCM_RTS: ::c_int = 0x004; +pub const TIOCM_ST: ::c_int = 0x008; +pub const TIOCM_SR: ::c_int = 0x010; +pub const TIOCM_CTS: ::c_int = 0x020; +pub const TIOCM_CAR: ::c_int = 0x040; +pub const TIOCM_RNG: ::c_int = 0x080; +pub const TIOCM_DSR: ::c_int = 0x100; +pub const TIOCM_CD: ::c_int = TIOCM_CAR; +pub const TIOCM_RI: ::c_int = TIOCM_RNG; + +// Syscall table +pub const SYS_restart_syscall: ::c_long = 0; +pub const SYS_exit: ::c_long = 1; +pub const SYS_fork: ::c_long = 2; +pub const SYS_read: ::c_long = 3; +pub const SYS_write: ::c_long = 4; +pub const SYS_open: ::c_long = 5; +pub const SYS_close: ::c_long = 6; +pub const SYS_waitpid: ::c_long = 7; +pub const SYS_creat: ::c_long = 8; +pub const SYS_link: ::c_long = 9; +pub const SYS_unlink: ::c_long = 10; +pub const SYS_execve: ::c_long = 11; +pub const SYS_chdir: ::c_long = 12; +pub const SYS_time: ::c_long = 13; +pub const SYS_mknod: ::c_long = 14; +pub const SYS_chmod: ::c_long = 15; +pub const SYS_lchown: ::c_long = 16; +pub const SYS_break: ::c_long = 17; +pub const SYS_oldstat: ::c_long = 18; +pub const SYS_lseek: ::c_long = 19; +pub const SYS_getpid: ::c_long = 20; +pub const SYS_mount: ::c_long = 21; +pub const SYS_umount: ::c_long = 22; +pub const SYS_setuid: ::c_long = 23; +pub const SYS_getuid: ::c_long = 24; +pub const SYS_stime: ::c_long = 25; +pub const SYS_ptrace: ::c_long = 26; +pub const SYS_alarm: ::c_long = 27; +pub const SYS_oldfstat: ::c_long = 28; +pub const SYS_pause: ::c_long = 29; +pub const SYS_utime: ::c_long = 30; +pub const SYS_stty: ::c_long = 31; +pub const SYS_gtty: ::c_long = 32; +pub const SYS_access: ::c_long = 33; +pub const SYS_nice: ::c_long = 34; +pub const SYS_ftime: ::c_long = 35; +pub const SYS_sync: ::c_long = 36; +pub const SYS_kill: ::c_long = 37; +pub const SYS_rename: ::c_long = 38; +pub const SYS_mkdir: ::c_long = 39; +pub const SYS_rmdir: ::c_long = 40; +pub const SYS_dup: ::c_long = 41; +pub const SYS_pipe: ::c_long = 42; +pub const SYS_times: ::c_long = 43; +pub const SYS_prof: ::c_long = 44; +pub const SYS_brk: ::c_long = 45; +pub const SYS_setgid: ::c_long = 46; +pub const SYS_getgid: ::c_long = 47; +pub const SYS_signal: ::c_long = 48; +pub const SYS_geteuid: ::c_long = 49; +pub const SYS_getegid: ::c_long = 50; +pub const SYS_acct: ::c_long = 51; +pub const SYS_umount2: ::c_long = 52; +pub const SYS_lock: ::c_long = 53; +pub const SYS_ioctl: ::c_long = 54; +pub const SYS_fcntl: ::c_long = 55; +pub const SYS_mpx: ::c_long = 56; +pub const SYS_setpgid: ::c_long = 57; +pub const SYS_ulimit: ::c_long = 58; +pub const SYS_oldolduname: ::c_long = 59; +pub const SYS_umask: ::c_long = 60; +pub const SYS_chroot: ::c_long = 61; +pub const SYS_ustat: ::c_long = 62; +pub const SYS_dup2: ::c_long = 63; +pub const SYS_getppid: ::c_long = 64; +pub const SYS_getpgrp: ::c_long = 65; +pub const SYS_setsid: ::c_long = 66; +pub const SYS_sigaction: ::c_long = 67; +pub const SYS_sgetmask: ::c_long = 68; +pub const SYS_ssetmask: ::c_long = 69; +pub const SYS_setreuid: ::c_long = 70; +pub const SYS_setregid: ::c_long = 71; +pub const SYS_sigsuspend: ::c_long = 72; +pub const SYS_sigpending: ::c_long = 73; +pub const SYS_sethostname: ::c_long = 74; +pub const SYS_setrlimit: ::c_long = 75; +pub const SYS_getrlimit: ::c_long = 76; +pub const SYS_getrusage: ::c_long = 77; +pub const SYS_gettimeofday: ::c_long = 78; +pub const SYS_settimeofday: ::c_long = 79; +pub const SYS_getgroups: ::c_long = 80; +pub const SYS_setgroups: ::c_long = 81; +pub const SYS_select: ::c_long = 82; +pub const SYS_symlink: ::c_long = 83; +pub const SYS_oldlstat: ::c_long = 84; +pub const SYS_readlink: ::c_long = 85; +pub const SYS_uselib: ::c_long = 86; +pub const SYS_swapon: ::c_long = 87; +pub const SYS_reboot: ::c_long = 88; +pub const SYS_readdir: ::c_long = 89; +pub const SYS_mmap: ::c_long = 90; +pub const SYS_munmap: ::c_long = 91; +pub const SYS_truncate: ::c_long = 92; +pub const SYS_ftruncate: ::c_long = 93; +pub const SYS_fchmod: ::c_long = 94; +pub const SYS_fchown: ::c_long = 95; +pub const SYS_getpriority: ::c_long = 96; +pub const SYS_setpriority: ::c_long = 97; +pub const SYS_profil: ::c_long = 98; +pub const SYS_statfs: ::c_long = 99; +pub const SYS_fstatfs: ::c_long = 100; +pub const SYS_ioperm: ::c_long = 101; +pub const SYS_socketcall: ::c_long = 102; +pub const SYS_syslog: ::c_long = 103; +pub const SYS_setitimer: ::c_long = 104; +pub const SYS_getitimer: ::c_long = 105; +pub const SYS_stat: ::c_long = 106; +pub const SYS_lstat: ::c_long = 107; +pub const SYS_fstat: ::c_long = 108; +pub const SYS_olduname: ::c_long = 109; +pub const SYS_iopl: ::c_long = 110; +pub const SYS_vhangup: ::c_long = 111; +pub const SYS_idle: ::c_long = 112; +pub const SYS_vm86: ::c_long = 113; +pub const SYS_wait4: ::c_long = 114; +pub const SYS_swapoff: ::c_long = 115; +pub const SYS_sysinfo: ::c_long = 116; +pub const SYS_ipc: ::c_long = 117; +pub const SYS_fsync: ::c_long = 118; +pub const SYS_sigreturn: ::c_long = 119; +pub const SYS_clone: ::c_long = 120; +pub const SYS_setdomainname: ::c_long = 121; +pub const SYS_uname: ::c_long = 122; +pub const SYS_modify_ldt: ::c_long = 123; +pub const SYS_adjtimex: ::c_long = 124; +pub const SYS_mprotect: ::c_long = 125; +pub const SYS_sigprocmask: ::c_long = 126; +pub const SYS_create_module: ::c_long = 127; +pub const SYS_init_module: ::c_long = 128; +pub const SYS_delete_module: ::c_long = 129; +pub const SYS_get_kernel_syms: ::c_long = 130; +pub const SYS_quotactl: ::c_long = 131; +pub const SYS_getpgid: ::c_long = 132; +pub const SYS_fchdir: ::c_long = 133; +pub const SYS_bdflush: ::c_long = 134; +pub const SYS_sysfs: ::c_long = 135; +pub const SYS_personality: ::c_long = 136; +pub const SYS_afs_syscall: ::c_long = 137; +pub const SYS_setfsuid: ::c_long = 138; +pub const SYS_setfsgid: ::c_long = 139; +pub const SYS__llseek: ::c_long = 140; +pub const SYS_getdents: ::c_long = 141; +pub const SYS__newselect: ::c_long = 142; +pub const SYS_flock: ::c_long = 143; +pub const SYS_msync: ::c_long = 144; +pub const SYS_readv: ::c_long = 145; +pub const SYS_writev: ::c_long = 146; +pub const SYS_getsid: ::c_long = 147; +pub const SYS_fdatasync: ::c_long = 148; +pub const SYS__sysctl: ::c_long = 149; +pub const SYS_mlock: ::c_long = 150; +pub const SYS_munlock: ::c_long = 151; +pub const SYS_mlockall: ::c_long = 152; +pub const SYS_munlockall: ::c_long = 153; +pub const SYS_sched_setparam: ::c_long = 154; +pub const SYS_sched_getparam: ::c_long = 155; +pub const SYS_sched_setscheduler: ::c_long = 156; +pub const SYS_sched_getscheduler: ::c_long = 157; +pub const SYS_sched_yield: ::c_long = 158; +pub const SYS_sched_get_priority_max: ::c_long = 159; +pub const SYS_sched_get_priority_min: ::c_long = 160; +pub const SYS_sched_rr_get_interval: ::c_long = 161; +pub const SYS_nanosleep: ::c_long = 162; +pub const SYS_mremap: ::c_long = 163; +pub const SYS_setresuid: ::c_long = 164; +pub const SYS_getresuid: ::c_long = 165; +pub const SYS_query_module: ::c_long = 166; +pub const SYS_poll: ::c_long = 167; +pub const SYS_nfsservctl: ::c_long = 168; +pub const SYS_setresgid: ::c_long = 169; +pub const SYS_getresgid: ::c_long = 170; +pub const SYS_prctl: ::c_long = 171; +pub const SYS_rt_sigreturn: ::c_long = 172; +pub const SYS_rt_sigaction: ::c_long = 173; +pub const SYS_rt_sigprocmask: ::c_long = 174; +pub const SYS_rt_sigpending: ::c_long = 175; +pub const SYS_rt_sigtimedwait: ::c_long = 176; +pub const SYS_rt_sigqueueinfo: ::c_long = 177; +pub const SYS_rt_sigsuspend: ::c_long = 178; +pub const SYS_pread64: ::c_long = 179; +pub const SYS_pwrite64: ::c_long = 180; +pub const SYS_chown: ::c_long = 181; +pub const SYS_getcwd: ::c_long = 182; +pub const SYS_capget: ::c_long = 183; +pub const SYS_capset: ::c_long = 184; +pub const SYS_sigaltstack: ::c_long = 185; +pub const SYS_sendfile: ::c_long = 186; +pub const SYS_getpmsg: ::c_long = 187; +pub const SYS_putpmsg: ::c_long = 188; +pub const SYS_vfork: ::c_long = 189; +pub const SYS_ugetrlimit: ::c_long = 190; +pub const SYS_readahead: ::c_long = 191; +pub const SYS_mmap2: ::c_long = 192; +pub const SYS_truncate64: ::c_long = 193; +pub const SYS_ftruncate64: ::c_long = 194; +pub const SYS_stat64: ::c_long = 195; +pub const SYS_lstat64: ::c_long = 196; +pub const SYS_fstat64: ::c_long = 197; +pub const SYS_pciconfig_read: ::c_long = 198; +pub const SYS_pciconfig_write: ::c_long = 199; +pub const SYS_pciconfig_iobase: ::c_long = 200; +pub const SYS_multiplexer: ::c_long = 201; +pub const SYS_getdents64: ::c_long = 202; +pub const SYS_pivot_root: ::c_long = 203; +pub const SYS_fcntl64: ::c_long = 204; +pub const SYS_madvise: ::c_long = 205; +pub const SYS_mincore: ::c_long = 206; +pub const SYS_gettid: ::c_long = 207; +pub const SYS_tkill: ::c_long = 208; +pub const SYS_setxattr: ::c_long = 209; +pub const SYS_lsetxattr: ::c_long = 210; +pub const SYS_fsetxattr: ::c_long = 211; +pub const SYS_getxattr: ::c_long = 212; +pub const SYS_lgetxattr: ::c_long = 213; +pub const SYS_fgetxattr: ::c_long = 214; +pub const SYS_listxattr: ::c_long = 215; +pub const SYS_llistxattr: ::c_long = 216; +pub const SYS_flistxattr: ::c_long = 217; +pub const SYS_removexattr: ::c_long = 218; +pub const SYS_lremovexattr: ::c_long = 219; +pub const SYS_fremovexattr: ::c_long = 220; +pub const SYS_futex: ::c_long = 221; +pub const SYS_sched_setaffinity: ::c_long = 222; +pub const SYS_sched_getaffinity: ::c_long = 223; +pub const SYS_tuxcall: ::c_long = 225; +pub const SYS_sendfile64: ::c_long = 226; +pub const SYS_io_setup: ::c_long = 227; +pub const SYS_io_destroy: ::c_long = 228; +pub const SYS_io_getevents: ::c_long = 229; +pub const SYS_io_submit: ::c_long = 230; +pub const SYS_io_cancel: ::c_long = 231; +pub const SYS_set_tid_address: ::c_long = 232; +pub const SYS_fadvise64: ::c_long = 233; +pub const SYS_exit_group: ::c_long = 234; +pub const SYS_lookup_dcookie: ::c_long = 235; +pub const SYS_epoll_create: ::c_long = 236; +pub const SYS_epoll_ctl: ::c_long = 237; +pub const SYS_epoll_wait: ::c_long = 238; +pub const SYS_remap_file_pages: ::c_long = 239; +pub const SYS_timer_create: ::c_long = 240; +pub const SYS_timer_settime: ::c_long = 241; +pub const SYS_timer_gettime: ::c_long = 242; +pub const SYS_timer_getoverrun: ::c_long = 243; +pub const SYS_timer_delete: ::c_long = 244; +pub const SYS_clock_settime: ::c_long = 245; +pub const SYS_clock_gettime: ::c_long = 246; +pub const SYS_clock_getres: ::c_long = 247; +pub const SYS_clock_nanosleep: ::c_long = 248; +pub const SYS_swapcontext: ::c_long = 249; +pub const SYS_tgkill: ::c_long = 250; +pub const SYS_utimes: ::c_long = 251; +pub const SYS_statfs64: ::c_long = 252; +pub const SYS_fstatfs64: ::c_long = 253; +pub const SYS_fadvise64_64: ::c_long = 254; +pub const SYS_rtas: ::c_long = 255; +pub const SYS_sys_debug_setcontext: ::c_long = 256; +pub const SYS_migrate_pages: ::c_long = 258; +pub const SYS_mbind: ::c_long = 259; +pub const SYS_get_mempolicy: ::c_long = 260; +pub const SYS_set_mempolicy: ::c_long = 261; +pub const SYS_mq_open: ::c_long = 262; +pub const SYS_mq_unlink: ::c_long = 263; +pub const SYS_mq_timedsend: ::c_long = 264; +pub const SYS_mq_timedreceive: ::c_long = 265; +pub const SYS_mq_notify: ::c_long = 266; +pub const SYS_mq_getsetattr: ::c_long = 267; +pub const SYS_kexec_load: ::c_long = 268; +pub const SYS_add_key: ::c_long = 269; +pub const SYS_request_key: ::c_long = 270; +pub const SYS_keyctl: ::c_long = 271; +pub const SYS_waitid: ::c_long = 272; +pub const SYS_ioprio_set: ::c_long = 273; +pub const SYS_ioprio_get: ::c_long = 274; +pub const SYS_inotify_init: ::c_long = 275; +pub const SYS_inotify_add_watch: ::c_long = 276; +pub const SYS_inotify_rm_watch: ::c_long = 277; +pub const SYS_spu_run: ::c_long = 278; +pub const SYS_spu_create: ::c_long = 279; +pub const SYS_pselect6: ::c_long = 280; +pub const SYS_ppoll: ::c_long = 281; +pub const SYS_unshare: ::c_long = 282; +pub const SYS_splice: ::c_long = 283; +pub const SYS_tee: ::c_long = 284; +pub const SYS_vmsplice: ::c_long = 285; +pub const SYS_openat: ::c_long = 286; +pub const SYS_mkdirat: ::c_long = 287; +pub const SYS_mknodat: ::c_long = 288; +pub const SYS_fchownat: ::c_long = 289; +pub const SYS_futimesat: ::c_long = 290; +pub const SYS_fstatat64: ::c_long = 291; +pub const SYS_unlinkat: ::c_long = 292; +pub const SYS_renameat: ::c_long = 293; +pub const SYS_linkat: ::c_long = 294; +pub const SYS_symlinkat: ::c_long = 295; +pub const SYS_readlinkat: ::c_long = 296; +pub const SYS_fchmodat: ::c_long = 297; +pub const SYS_faccessat: ::c_long = 298; +pub const SYS_get_robust_list: ::c_long = 299; +pub const SYS_set_robust_list: ::c_long = 300; +pub const SYS_move_pages: ::c_long = 301; +pub const SYS_getcpu: ::c_long = 302; +pub const SYS_epoll_pwait: ::c_long = 303; +pub const SYS_utimensat: ::c_long = 304; +pub const SYS_signalfd: ::c_long = 305; +pub const SYS_timerfd_create: ::c_long = 306; +pub const SYS_eventfd: ::c_long = 307; +pub const SYS_sync_file_range2: ::c_long = 308; +pub const SYS_fallocate: ::c_long = 309; +pub const SYS_subpage_prot: ::c_long = 310; +pub const SYS_timerfd_settime: ::c_long = 311; +pub const SYS_timerfd_gettime: ::c_long = 312; +pub const SYS_signalfd4: ::c_long = 313; +pub const SYS_eventfd2: ::c_long = 314; +pub const SYS_epoll_create1: ::c_long = 315; +pub const SYS_dup3: ::c_long = 316; +pub const SYS_pipe2: ::c_long = 317; +pub const SYS_inotify_init1: ::c_long = 318; +pub const SYS_perf_event_open: ::c_long = 319; +pub const SYS_preadv: ::c_long = 320; +pub const SYS_pwritev: ::c_long = 321; +pub const SYS_rt_tgsigqueueinfo: ::c_long = 322; +pub const SYS_fanotify_init: ::c_long = 323; +pub const SYS_fanotify_mark: ::c_long = 324; +pub const SYS_prlimit64: ::c_long = 325; +pub const SYS_socket: ::c_long = 326; +pub const SYS_bind: ::c_long = 327; +pub const SYS_connect: ::c_long = 328; +pub const SYS_listen: ::c_long = 329; +pub const SYS_accept: ::c_long = 330; +pub const SYS_getsockname: ::c_long = 331; +pub const SYS_getpeername: ::c_long = 332; +pub const SYS_socketpair: ::c_long = 333; +pub const SYS_send: ::c_long = 334; +pub const SYS_sendto: ::c_long = 335; +pub const SYS_recv: ::c_long = 336; +pub const SYS_recvfrom: ::c_long = 337; +pub const SYS_shutdown: ::c_long = 338; +pub const SYS_setsockopt: ::c_long = 339; +pub const SYS_getsockopt: ::c_long = 340; +pub const SYS_sendmsg: ::c_long = 341; +pub const SYS_recvmsg: ::c_long = 342; +pub const SYS_recvmmsg: ::c_long = 343; +pub const SYS_accept4: ::c_long = 344; +pub const SYS_name_to_handle_at: ::c_long = 345; +pub const SYS_open_by_handle_at: ::c_long = 346; +pub const SYS_clock_adjtime: ::c_long = 347; +pub const SYS_syncfs: ::c_long = 348; +pub const SYS_sendmmsg: ::c_long = 349; +pub const SYS_setns: ::c_long = 350; +pub const SYS_process_vm_readv: ::c_long = 351; +pub const SYS_process_vm_writev: ::c_long = 352; +pub const SYS_finit_module: ::c_long = 353; +pub const SYS_kcmp: ::c_long = 354; +pub const SYS_sched_setattr: ::c_long = 355; +pub const SYS_sched_getattr: ::c_long = 356; +pub const SYS_renameat2: ::c_long = 357; +pub const SYS_seccomp: ::c_long = 358; +pub const SYS_getrandom: ::c_long = 359; +pub const SYS_memfd_create: ::c_long = 360; +pub const SYS_bpf: ::c_long = 361; +pub const SYS_execveat: ::c_long = 362; +pub const SYS_switch_endian: ::c_long = 363; +pub const SYS_userfaultfd: ::c_long = 364; +pub const SYS_membarrier: ::c_long = 365; +pub const SYS_mlock2: ::c_long = 378; +pub const SYS_copy_file_range: ::c_long = 379; +pub const SYS_preadv2: ::c_long = 380; +pub const SYS_pwritev2: ::c_long = 381; +pub const SYS_kexec_file_load: ::c_long = 382; +pub const SYS_statx: ::c_long = 383; +pub const SYS_pkey_alloc: ::c_long = 384; +pub const SYS_pkey_free: ::c_long = 385; +pub const SYS_pkey_mprotect: ::c_long = 386; + +#[doc(hidden)] +pub const AF_MAX: ::c_int = 43; +#[doc(hidden)] +pub const PF_MAX: ::c_int = AF_MAX; diff --git a/libc/src/unix/notbsd/linux/musl/b32/x86.rs b/libc/src/unix/notbsd/linux/musl/b32/x86.rs index fa57024..b6ea8c1 100644 --- a/libc/src/unix/notbsd/linux/musl/b32/x86.rs +++ b/libc/src/unix/notbsd/linux/musl/b32/x86.rs @@ -52,6 +52,18 @@ s! { pub ss_size: ::size_t } + 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_int, + __unused1: ::c_long, + __unused2: ::c_long + } + pub struct shmid_ds { pub shm_perm: ::ipc_perm, pub shm_segsz: ::size_t, @@ -164,6 +176,9 @@ s! { } } +pub const SIGSTKSZ: ::size_t = 8192; +pub const MINSIGSTKSZ: ::size_t = 2048; + pub const O_DIRECT: ::c_int = 0x4000; pub const O_DIRECTORY: ::c_int = 0x10000; pub const O_NOFOLLOW: ::c_int = 0x20000; @@ -178,6 +193,76 @@ pub const RLIMIT_NOFILE: ::c_int = 7; pub const RLIMIT_AS: ::c_int = 9; pub const RLIMIT_NPROC: ::c_int = 6; pub const RLIMIT_MEMLOCK: ::c_int = 8; +pub const RLIMIT_NLIMITS: ::c_int = 16; + +pub const MCL_CURRENT: ::c_int = 0x0001; +pub const MCL_FUTURE: ::c_int = 0x0002; +pub const CBAUD: ::tcflag_t = 0o0010017; +pub const TAB1: ::c_int = 0x00000800; +pub const TAB2: ::c_int = 0x00001000; +pub const TAB3: ::c_int = 0x00001800; +pub const CR1: ::c_int = 0x00000200; +pub const CR2: ::c_int = 0x00000400; +pub const CR3: ::c_int = 0x00000600; +pub const FF1: ::c_int = 0x00008000; +pub const BS1: ::c_int = 0x00002000; +pub const VT1: ::c_int = 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 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 O_APPEND: ::c_int = 1024; pub const O_CREAT: ::c_int = 64; @@ -396,6 +481,9 @@ pub const TIOCMSET: ::c_int = 0x5418; pub const FIONREAD: ::c_int = 0x541B; pub const TIOCCONS: ::c_int = 0x541D; +pub const TIOCGRS485: ::c_int = 0x542E; +pub const TIOCSRS485: ::c_int = 0x542F; + pub const POLLWRNORM: ::c_short = 0x100; pub const POLLWRBAND: ::c_short = 0x200; diff --git a/libc/src/unix/notbsd/linux/musl/b64/aarch64.rs b/libc/src/unix/notbsd/linux/musl/b64/aarch64.rs index da0827a..f01a5c4 100644 --- a/libc/src/unix/notbsd/linux/musl/b64/aarch64.rs +++ b/libc/src/unix/notbsd/linux/musl/b64/aarch64.rs @@ -339,3 +339,141 @@ 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 RLIMIT_NLIMITS: ::c_int = 16; +pub const TIOCINQ: ::c_int = ::FIONREAD; +pub const MCL_CURRENT: ::c_int = 0x0001; +pub const MCL_FUTURE: ::c_int = 0x0002; +pub const CBAUD: ::tcflag_t = 0o0010017; +pub const TAB1: ::c_int = 0x00000800; +pub const TAB2: ::c_int = 0x00001000; +pub const TAB3: ::c_int = 0x00001800; +pub const CR1: ::c_int = 0x00000200; +pub const CR2: ::c_int = 0x00000400; +pub const CR3: ::c_int = 0x00000600; +pub const FF1: ::c_int = 0x00008000; +pub const BS1: ::c_int = 0x00002000; +pub const VT1: ::c_int = 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 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 FIOCLEX: ::c_int = 0x5451; +pub const FIONBIO: ::c_int = 0x5421; +pub const EDEADLK: ::c_int = 35; +pub const EDEADLOCK: ::c_int = EDEADLK; +pub const SO_PASSCRED: ::c_int = 16; +pub const SO_PEERCRED: ::c_int = 17; +pub const SO_RCVLOWAT: ::c_int = 18; +pub const SO_SNDLOWAT: ::c_int = 19; +pub const SO_RCVTIMEO: ::c_int = 20; +pub const SO_SNDTIMEO: ::c_int = 21; +pub const EXTPROC: ::tcflag_t = 0x00010000; +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 TCGETS: ::c_int = 0x5401; +pub const TCSETS: ::c_int = 0x5402; +pub const TCSETSW: ::c_int = 0x5403; +pub const TCSETSF: ::c_int = 0x5404; +pub const TCGETA: ::c_int = 0x5405; +pub const TCSETA: ::c_int = 0x5406; +pub const TCSETAW: ::c_int = 0x5407; +pub const TCSETAF: ::c_int = 0x5408; +pub const TCSBRK: ::c_int = 0x5409; +pub const TCXONC: ::c_int = 0x540A; +pub const TCFLSH: ::c_int = 0x540B; +pub const TIOCGSOFTCAR: ::c_int = 0x5419; +pub const TIOCSSOFTCAR: ::c_int = 0x541A; +pub const TIOCLINUX: ::c_int = 0x541C; +pub const TIOCGSERIAL: ::c_int = 0x541E; +pub const TIOCEXCL: ::c_int = 0x540C; +pub const TIOCNXCL: ::c_int = 0x540D; +pub const TIOCSCTTY: ::c_int = 0x540E; +pub const TIOCGPGRP: ::c_int = 0x540F; +pub const TIOCSPGRP: ::c_int = 0x5410; +pub const TIOCOUTQ: ::c_int = 0x5411; +pub const TIOCSTI: ::c_int = 0x5412; +pub const TIOCGWINSZ: ::c_int = 0x5413; +pub const TIOCSWINSZ: ::c_int = 0x5414; +pub const TIOCMGET: ::c_int = 0x5415; +pub const TIOCMBIS: ::c_int = 0x5416; +pub const TIOCMBIC: ::c_int = 0x5417; +pub const TIOCMSET: ::c_int = 0x5418; +pub const FIONREAD: ::c_int = 0x541B; +pub const TIOCCONS: ::c_int = 0x541D; + +pub const TIOCGRS485: ::c_int = 0x542E; +pub const TIOCSRS485: ::c_int = 0x542F; + +pub const TIOCM_LE: ::c_int = 0x001; +pub const TIOCM_DTR: ::c_int = 0x002; +pub const TIOCM_RTS: ::c_int = 0x004; +pub const TIOCM_ST: ::c_int = 0x008; +pub const TIOCM_SR: ::c_int = 0x010; +pub const TIOCM_CTS: ::c_int = 0x020; +pub const TIOCM_CAR: ::c_int = 0x040; +pub const TIOCM_RNG: ::c_int = 0x080; +pub const TIOCM_DSR: ::c_int = 0x100; +pub const TIOCM_CD: ::c_int = TIOCM_CAR; +pub const TIOCM_RI: ::c_int = TIOCM_RNG; + +extern { + pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; +} diff --git a/libc/src/unix/notbsd/linux/musl/b64/mod.rs b/libc/src/unix/notbsd/linux/musl/b64/mod.rs index 70baf82..043ca8d 100644 --- a/libc/src/unix/notbsd/linux/musl/b64/mod.rs +++ b/libc/src/unix/notbsd/linux/musl/b64/mod.rs @@ -92,16 +92,25 @@ s! { pub msg_name: *mut ::c_void, pub msg_namelen: ::socklen_t, pub msg_iov: *mut ::iovec, + #[cfg(target_endian = "big")] + __pad1: ::c_int, pub msg_iovlen: ::c_int, + #[cfg(target_endian = "little")] __pad1: ::c_int, pub msg_control: *mut ::c_void, + #[cfg(target_endian = "big")] + __pad2: ::c_int, pub msg_controllen: ::socklen_t, - __pad2: ::socklen_t, + #[cfg(target_endian = "little")] + __pad2: ::c_int, pub msg_flags: ::c_int, } pub struct cmsghdr { + #[cfg(target_endian = "big")] + pub __pad1: ::c_int, pub cmsg_len: ::socklen_t, + #[cfg(target_endian = "little")] pub __pad1: ::c_int, pub cmsg_level: ::c_int, pub cmsg_type: ::c_int, @@ -136,9 +145,6 @@ pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const O_ASYNC: ::c_int = 0x2000; -pub const FIOCLEX: ::c_int = 0x5451; -pub const FIONBIO: ::c_int = 0x5421; - pub const RLIMIT_RSS: ::c_int = 5; pub const RLIMIT_NOFILE: ::c_int = 7; pub const RLIMIT_AS: ::c_int = 9; @@ -172,7 +178,6 @@ pub const SOCK_SEQPACKET: ::c_int = 5; pub const SOL_SOCKET: ::c_int = 1; -pub const EDEADLK: ::c_int = 35; pub const ENAMETOOLONG: ::c_int = 36; pub const ENOLCK: ::c_int = 37; pub const ENOSYS: ::c_int = 38; @@ -194,7 +199,6 @@ 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 EDEADLOCK: ::c_int = EDEADLK; pub const EMULTIHOP: ::c_int = 72; pub const EBADMSG: ::c_int = 74; pub const EOVERFLOW: ::c_int = 75; @@ -272,12 +276,6 @@ pub const SO_PRIORITY: ::c_int = 12; pub const SO_LINGER: ::c_int = 13; pub const SO_BSDCOMPAT: ::c_int = 14; pub const SO_REUSEPORT: ::c_int = 15; -pub const SO_PASSCRED: ::c_int = 16; -pub const SO_PEERCRED: ::c_int = 17; -pub const SO_RCVLOWAT: ::c_int = 18; -pub const SO_SNDLOWAT: ::c_int = 19; -pub const SO_RCVTIMEO: ::c_int = 20; -pub const SO_SNDTIMEO: ::c_int = 21; pub const SO_ACCEPTCONN: ::c_int = 30; pub const SO_SNDBUFFORCE: ::c_int = 32; pub const SO_RCVBUFFORCE: ::c_int = 33; @@ -312,8 +310,6 @@ pub const SIG_SETMASK: ::c_int = 2; pub const SIG_BLOCK: ::c_int = 0x000000; pub const SIG_UNBLOCK: ::c_int = 0x01; -pub const EXTPROC: ::tcflag_t = 0x00010000; - pub const MAP_HUGETLB: ::c_int = 0x040000; pub const F_GETLK: ::c_int = 5; @@ -323,59 +319,10 @@ pub const F_SETLKW: ::c_int = 7; pub const F_SETOWN: ::c_int = 8; pub const VEOF: usize = 4; -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 TCGETS: ::c_int = 0x5401; -pub const TCSETS: ::c_int = 0x5402; -pub const TCSETSW: ::c_int = 0x5403; -pub const TCSETSF: ::c_int = 0x5404; -pub const TCGETA: ::c_int = 0x5405; -pub const TCSETA: ::c_int = 0x5406; -pub const TCSETAW: ::c_int = 0x5407; -pub const TCSETAF: ::c_int = 0x5408; -pub const TCSBRK: ::c_int = 0x5409; -pub const TCXONC: ::c_int = 0x540A; -pub const TCFLSH: ::c_int = 0x540B; -pub const TIOCGSOFTCAR: ::c_int = 0x5419; -pub const TIOCSSOFTCAR: ::c_int = 0x541A; -pub const TIOCLINUX: ::c_int = 0x541C; -pub const TIOCGSERIAL: ::c_int = 0x541E; -pub const TIOCEXCL: ::c_int = 0x540C; -pub const TIOCNXCL: ::c_int = 0x540D; -pub const TIOCSCTTY: ::c_int = 0x540E; -pub const TIOCGPGRP: ::c_int = 0x540F; -pub const TIOCSPGRP: ::c_int = 0x5410; -pub const TIOCOUTQ: ::c_int = 0x5411; -pub const TIOCSTI: ::c_int = 0x5412; -pub const TIOCGWINSZ: ::c_int = 0x5413; -pub const TIOCSWINSZ: ::c_int = 0x5414; -pub const TIOCMGET: ::c_int = 0x5415; -pub const TIOCMBIS: ::c_int = 0x5416; -pub const TIOCMBIC: ::c_int = 0x5417; -pub const TIOCMSET: ::c_int = 0x5418; -pub const FIONREAD: ::c_int = 0x541B; -pub const TIOCCONS: ::c_int = 0x541D; pub const POLLWRNORM: ::c_short = 0x100; pub const POLLWRBAND: ::c_short = 0x200; -pub const TIOCM_LE: ::c_int = 0x001; -pub const TIOCM_DTR: ::c_int = 0x002; -pub const TIOCM_RTS: ::c_int = 0x004; -pub const TIOCM_ST: ::c_int = 0x008; -pub const TIOCM_SR: ::c_int = 0x010; -pub const TIOCM_CTS: ::c_int = 0x020; -pub const TIOCM_CAR: ::c_int = 0x040; -pub const TIOCM_RNG: ::c_int = 0x080; -pub const TIOCM_DSR: ::c_int = 0x100; -pub const TIOCM_CD: ::c_int = TIOCM_CAR; -pub const TIOCM_RI: ::c_int = TIOCM_RNG; - cfg_if! { if #[cfg(target_arch = "aarch64")] { mod aarch64; diff --git a/libc/src/unix/notbsd/linux/musl/b64/powerpc64.rs b/libc/src/unix/notbsd/linux/musl/b64/powerpc64.rs index 1574bff..04eba48 100644 --- a/libc/src/unix/notbsd/linux/musl/b64/powerpc64.rs +++ b/libc/src/unix/notbsd/linux/musl/b64/powerpc64.rs @@ -60,24 +60,516 @@ s! { } } -pub const SYS_pivot_root: ::c_long = 203; -pub const SYS_gettid: ::c_long = 207; -pub const SYS_perf_event_open: ::c_long = 319; -pub const SYS_memfd_create: ::c_long = 360; - pub const MAP_32BIT: ::c_int = 0x0040; -pub const O_DIRECT: ::c_int = 0x4000; -pub const O_DIRECTORY: ::c_int = 0x10000; -pub const O_LARGEFILE: ::c_int = 0; -pub const O_NOFOLLOW: ::c_int = 0x20000; +pub const O_DIRECT: ::c_int = 0x20000; +pub const O_DIRECTORY: ::c_int = 0x4000; +pub const O_LARGEFILE: ::c_int = 0x10000; +pub const O_NOFOLLOW: ::c_int = 0x8000; -pub const SIGSTKSZ: ::size_t = 8192; -pub const MINSIGSTKSZ: ::size_t = 2048; +pub const SIGSTKSZ: ::size_t = 10240; +pub const MINSIGSTKSZ: ::size_t = 4096; #[doc(hidden)] -pub const AF_MAX: ::c_int = 42; +pub const AF_MAX: ::c_int = 43; #[doc(hidden)] pub const PF_MAX: ::c_int = AF_MAX; // Syscall table +pub const SYS_restart_syscall: ::c_long = 0; +pub const SYS_exit: ::c_long = 1; +pub const SYS_fork: ::c_long = 2; +pub const SYS_read: ::c_long = 3; +pub const SYS_write: ::c_long = 4; +pub const SYS_open: ::c_long = 5; +pub const SYS_close: ::c_long = 6; +pub const SYS_waitpid: ::c_long = 7; +pub const SYS_creat: ::c_long = 8; +pub const SYS_link: ::c_long = 9; +pub const SYS_unlink: ::c_long = 10; +pub const SYS_execve: ::c_long = 11; +pub const SYS_chdir: ::c_long = 12; +pub const SYS_time: ::c_long = 13; +pub const SYS_mknod: ::c_long = 14; +pub const SYS_chmod: ::c_long = 15; +pub const SYS_lchown: ::c_long = 16; +pub const SYS_break: ::c_long = 17; +pub const SYS_oldstat: ::c_long = 18; +pub const SYS_lseek: ::c_long = 19; +pub const SYS_getpid: ::c_long = 20; +pub const SYS_mount: ::c_long = 21; +pub const SYS_umount: ::c_long = 22; +pub const SYS_setuid: ::c_long = 23; +pub const SYS_getuid: ::c_long = 24; +pub const SYS_stime: ::c_long = 25; +pub const SYS_ptrace: ::c_long = 26; +pub const SYS_alarm: ::c_long = 27; +pub const SYS_oldfstat: ::c_long = 28; +pub const SYS_pause: ::c_long = 29; +pub const SYS_utime: ::c_long = 30; +pub const SYS_stty: ::c_long = 31; +pub const SYS_gtty: ::c_long = 32; +pub const SYS_access: ::c_long = 33; +pub const SYS_nice: ::c_long = 34; +pub const SYS_ftime: ::c_long = 35; +pub const SYS_sync: ::c_long = 36; +pub const SYS_kill: ::c_long = 37; +pub const SYS_rename: ::c_long = 38; +pub const SYS_mkdir: ::c_long = 39; +pub const SYS_rmdir: ::c_long = 40; +pub const SYS_dup: ::c_long = 41; +pub const SYS_pipe: ::c_long = 42; +pub const SYS_times: ::c_long = 43; +pub const SYS_prof: ::c_long = 44; +pub const SYS_brk: ::c_long = 45; +pub const SYS_setgid: ::c_long = 46; +pub const SYS_getgid: ::c_long = 47; +pub const SYS_signal: ::c_long = 48; +pub const SYS_geteuid: ::c_long = 49; +pub const SYS_getegid: ::c_long = 50; +pub const SYS_acct: ::c_long = 51; +pub const SYS_umount2: ::c_long = 52; +pub const SYS_lock: ::c_long = 53; +pub const SYS_ioctl: ::c_long = 54; +pub const SYS_fcntl: ::c_long = 55; +pub const SYS_mpx: ::c_long = 56; +pub const SYS_setpgid: ::c_long = 57; +pub const SYS_ulimit: ::c_long = 58; +pub const SYS_oldolduname: ::c_long = 59; +pub const SYS_umask: ::c_long = 60; +pub const SYS_chroot: ::c_long = 61; +pub const SYS_ustat: ::c_long = 62; +pub const SYS_dup2: ::c_long = 63; +pub const SYS_getppid: ::c_long = 64; +pub const SYS_getpgrp: ::c_long = 65; +pub const SYS_setsid: ::c_long = 66; +pub const SYS_sigaction: ::c_long = 67; +pub const SYS_sgetmask: ::c_long = 68; +pub const SYS_ssetmask: ::c_long = 69; +pub const SYS_setreuid: ::c_long = 70; +pub const SYS_setregid: ::c_long = 71; +pub const SYS_sigsuspend: ::c_long = 72; +pub const SYS_sigpending: ::c_long = 73; +pub const SYS_sethostname: ::c_long = 74; +pub const SYS_setrlimit: ::c_long = 75; +pub const SYS_getrlimit: ::c_long = 76; +pub const SYS_getrusage: ::c_long = 77; +pub const SYS_gettimeofday: ::c_long = 78; +pub const SYS_settimeofday: ::c_long = 79; +pub const SYS_getgroups: ::c_long = 80; +pub const SYS_setgroups: ::c_long = 81; +pub const SYS_select: ::c_long = 82; +pub const SYS_symlink: ::c_long = 83; +pub const SYS_oldlstat: ::c_long = 84; +pub const SYS_readlink: ::c_long = 85; +pub const SYS_uselib: ::c_long = 86; +pub const SYS_swapon: ::c_long = 87; +pub const SYS_reboot: ::c_long = 88; +pub const SYS_readdir: ::c_long = 89; +pub const SYS_mmap: ::c_long = 90; +pub const SYS_munmap: ::c_long = 91; +pub const SYS_truncate: ::c_long = 92; +pub const SYS_ftruncate: ::c_long = 93; +pub const SYS_fchmod: ::c_long = 94; +pub const SYS_fchown: ::c_long = 95; +pub const SYS_getpriority: ::c_long = 96; +pub const SYS_setpriority: ::c_long = 97; +pub const SYS_profil: ::c_long = 98; +pub const SYS_statfs: ::c_long = 99; +pub const SYS_fstatfs: ::c_long = 100; +pub const SYS_ioperm: ::c_long = 101; +pub const SYS_socketcall: ::c_long = 102; +pub const SYS_syslog: ::c_long = 103; +pub const SYS_setitimer: ::c_long = 104; +pub const SYS_getitimer: ::c_long = 105; +pub const SYS_stat: ::c_long = 106; +pub const SYS_lstat: ::c_long = 107; +pub const SYS_fstat: ::c_long = 108; +pub const SYS_olduname: ::c_long = 109; +pub const SYS_iopl: ::c_long = 110; +pub const SYS_vhangup: ::c_long = 111; +pub const SYS_idle: ::c_long = 112; +pub const SYS_vm86: ::c_long = 113; +pub const SYS_wait4: ::c_long = 114; +pub const SYS_swapoff: ::c_long = 115; +pub const SYS_sysinfo: ::c_long = 116; +pub const SYS_ipc: ::c_long = 117; +pub const SYS_fsync: ::c_long = 118; +pub const SYS_sigreturn: ::c_long = 119; +pub const SYS_clone: ::c_long = 120; +pub const SYS_setdomainname: ::c_long = 121; +pub const SYS_uname: ::c_long = 122; +pub const SYS_modify_ldt: ::c_long = 123; +pub const SYS_adjtimex: ::c_long = 124; +pub const SYS_mprotect: ::c_long = 125; +pub const SYS_sigprocmask: ::c_long = 126; +pub const SYS_create_module: ::c_long = 127; +pub const SYS_init_module: ::c_long = 128; +pub const SYS_delete_module: ::c_long = 129; +pub const SYS_get_kernel_syms: ::c_long = 130; +pub const SYS_quotactl: ::c_long = 131; +pub const SYS_getpgid: ::c_long = 132; +pub const SYS_fchdir: ::c_long = 133; +pub const SYS_bdflush: ::c_long = 134; +pub const SYS_sysfs: ::c_long = 135; +pub const SYS_personality: ::c_long = 136; +pub const SYS_afs_syscall: ::c_long = 137; /* Syscall for Andrew File System */ +pub const SYS_setfsuid: ::c_long = 138; +pub const SYS_setfsgid: ::c_long = 139; +pub const SYS__llseek: ::c_long = 140; +pub const SYS_getdents: ::c_long = 141; +pub const SYS__newselect: ::c_long = 142; +pub const SYS_flock: ::c_long = 143; +pub const SYS_msync: ::c_long = 144; +pub const SYS_readv: ::c_long = 145; +pub const SYS_writev: ::c_long = 146; +pub const SYS_getsid: ::c_long = 147; +pub const SYS_fdatasync: ::c_long = 148; +pub const SYS__sysctl: ::c_long = 149; +pub const SYS_mlock: ::c_long = 150; +pub const SYS_munlock: ::c_long = 151; +pub const SYS_mlockall: ::c_long = 152; +pub const SYS_munlockall: ::c_long = 153; +pub const SYS_sched_setparam: ::c_long = 154; +pub const SYS_sched_getparam: ::c_long = 155; +pub const SYS_sched_setscheduler: ::c_long = 156; +pub const SYS_sched_getscheduler: ::c_long = 157; +pub const SYS_sched_yield: ::c_long = 158; +pub const SYS_sched_get_priority_max: ::c_long = 159; +pub const SYS_sched_get_priority_min: ::c_long = 160; +pub const SYS_sched_rr_get_interval: ::c_long = 161; +pub const SYS_nanosleep: ::c_long = 162; +pub const SYS_mremap: ::c_long = 163; +pub const SYS_setresuid: ::c_long = 164; +pub const SYS_getresuid: ::c_long = 165; +pub const SYS_query_module: ::c_long = 166; +pub const SYS_poll: ::c_long = 167; +pub const SYS_nfsservctl: ::c_long = 168; +pub const SYS_setresgid: ::c_long = 169; +pub const SYS_getresgid: ::c_long = 170; +pub const SYS_prctl: ::c_long = 171; +pub const SYS_rt_sigreturn: ::c_long = 172; +pub const SYS_rt_sigaction: ::c_long = 173; +pub const SYS_rt_sigprocmask: ::c_long = 174; +pub const SYS_rt_sigpending: ::c_long = 175; +pub const SYS_rt_sigtimedwait: ::c_long = 176; +pub const SYS_rt_sigqueueinfo: ::c_long = 177; +pub const SYS_rt_sigsuspend: ::c_long = 178; +pub const SYS_pread64: ::c_long = 179; +pub const SYS_pwrite64: ::c_long = 180; +pub const SYS_chown: ::c_long = 181; +pub const SYS_getcwd: ::c_long = 182; +pub const SYS_capget: ::c_long = 183; +pub const SYS_capset: ::c_long = 184; +pub const SYS_sigaltstack: ::c_long = 185; +pub const SYS_sendfile: ::c_long = 186; +pub const SYS_getpmsg: ::c_long = 187; /* some people actually want streams */ +pub const SYS_putpmsg: ::c_long = 188; /* some people actually want streams */ +pub const SYS_vfork: ::c_long = 189; +pub const SYS_ugetrlimit: ::c_long = 190; /* SuS compliant getrlimit */ +pub const SYS_readahead: ::c_long = 191; +pub const SYS_pciconfig_read: ::c_long = 198; +pub const SYS_pciconfig_write: ::c_long = 199; +pub const SYS_pciconfig_iobase: ::c_long = 200; +pub const SYS_multiplexer: ::c_long = 201; +pub const SYS_getdents64: ::c_long = 202; +pub const SYS_pivot_root: ::c_long = 203; +pub const SYS_madvise: ::c_long = 205; +pub const SYS_mincore: ::c_long = 206; +pub const SYS_gettid: ::c_long = 207; +pub const SYS_tkill: ::c_long = 208; +pub const SYS_setxattr: ::c_long = 209; +pub const SYS_lsetxattr: ::c_long = 210; +pub const SYS_fsetxattr: ::c_long = 211; +pub const SYS_getxattr: ::c_long = 212; +pub const SYS_lgetxattr: ::c_long = 213; +pub const SYS_fgetxattr: ::c_long = 214; +pub const SYS_listxattr: ::c_long = 215; +pub const SYS_llistxattr: ::c_long = 216; +pub const SYS_flistxattr: ::c_long = 217; +pub const SYS_removexattr: ::c_long = 218; +pub const SYS_lremovexattr: ::c_long = 219; +pub const SYS_fremovexattr: ::c_long = 220; +pub const SYS_futex: ::c_long = 221; +pub const SYS_sched_setaffinity: ::c_long = 222; +pub const SYS_sched_getaffinity: ::c_long = 223; +pub const SYS_tuxcall: ::c_long = 225; +pub const SYS_io_setup: ::c_long = 227; +pub const SYS_io_destroy: ::c_long = 228; +pub const SYS_io_getevents: ::c_long = 229; +pub const SYS_io_submit: ::c_long = 230; +pub const SYS_io_cancel: ::c_long = 231; +pub const SYS_set_tid_address: ::c_long = 232; +pub const SYS_exit_group: ::c_long = 234; +pub const SYS_lookup_dcookie: ::c_long = 235; +pub const SYS_epoll_create: ::c_long = 236; +pub const SYS_epoll_ctl: ::c_long = 237; +pub const SYS_epoll_wait: ::c_long = 238; +pub const SYS_remap_file_pages: ::c_long = 239; +pub const SYS_timer_create: ::c_long = 240; +pub const SYS_timer_settime: ::c_long = 241; +pub const SYS_timer_gettime: ::c_long = 242; +pub const SYS_timer_getoverrun: ::c_long = 243; +pub const SYS_timer_delete: ::c_long = 244; +pub const SYS_clock_settime: ::c_long = 245; +pub const SYS_clock_gettime: ::c_long = 246; +pub const SYS_clock_getres: ::c_long = 247; +pub const SYS_clock_nanosleep: ::c_long = 248; +pub const SYS_swapcontext: ::c_long = 249; +pub const SYS_tgkill: ::c_long = 250; +pub const SYS_utimes: ::c_long = 251; +pub const SYS_statfs64: ::c_long = 252; +pub const SYS_fstatfs64: ::c_long = 253; +pub const SYS_rtas: ::c_long = 255; +pub const SYS_sys_debug_setcontext: ::c_long = 256; +pub const SYS_migrate_pages: ::c_long = 258; +pub const SYS_mbind: ::c_long = 259; +pub const SYS_get_mempolicy: ::c_long = 260; +pub const SYS_set_mempolicy: ::c_long = 261; +pub const SYS_mq_open: ::c_long = 262; +pub const SYS_mq_unlink: ::c_long = 263; +pub const SYS_mq_timedsend: ::c_long = 264; +pub const SYS_mq_timedreceive: ::c_long = 265; +pub const SYS_mq_notify: ::c_long = 266; +pub const SYS_mq_getsetattr: ::c_long = 267; +pub const SYS_kexec_load: ::c_long = 268; +pub const SYS_add_key: ::c_long = 269; +pub const SYS_request_key: ::c_long = 270; +pub const SYS_keyctl: ::c_long = 271; +pub const SYS_waitid: ::c_long = 272; +pub const SYS_ioprio_set: ::c_long = 273; +pub const SYS_ioprio_get: ::c_long = 274; +pub const SYS_inotify_init: ::c_long = 275; +pub const SYS_inotify_add_watch: ::c_long = 276; +pub const SYS_inotify_rm_watch: ::c_long = 277; +pub const SYS_spu_run: ::c_long = 278; +pub const SYS_spu_create: ::c_long = 279; +pub const SYS_pselect6: ::c_long = 280; +pub const SYS_ppoll: ::c_long = 281; +pub const SYS_unshare: ::c_long = 282; +pub const SYS_splice: ::c_long = 283; +pub const SYS_tee: ::c_long = 284; +pub const SYS_vmsplice: ::c_long = 285; +pub const SYS_openat: ::c_long = 286; +pub const SYS_mkdirat: ::c_long = 287; +pub const SYS_mknodat: ::c_long = 288; +pub const SYS_fchownat: ::c_long = 289; +pub const SYS_futimesat: ::c_long = 290; +pub const SYS_newfstatat: ::c_long = 291; +pub const SYS_unlinkat: ::c_long = 292; +pub const SYS_renameat: ::c_long = 293; +pub const SYS_linkat: ::c_long = 294; +pub const SYS_symlinkat: ::c_long = 295; +pub const SYS_readlinkat: ::c_long = 296; +pub const SYS_fchmodat: ::c_long = 297; +pub const SYS_faccessat: ::c_long = 298; +pub const SYS_get_robust_list: ::c_long = 299; +pub const SYS_set_robust_list: ::c_long = 300; +pub const SYS_move_pages: ::c_long = 301; +pub const SYS_getcpu: ::c_long = 302; +pub const SYS_epoll_pwait: ::c_long = 303; +pub const SYS_utimensat: ::c_long = 304; +pub const SYS_signalfd: ::c_long = 305; +pub const SYS_timerfd_create: ::c_long = 306; +pub const SYS_eventfd: ::c_long = 307; +pub const SYS_sync_file_range2: ::c_long = 308; +pub const SYS_fallocate: ::c_long = 309; +pub const SYS_subpage_prot: ::c_long = 310; +pub const SYS_timerfd_settime: ::c_long = 311; +pub const SYS_timerfd_gettime: ::c_long = 312; +pub const SYS_signalfd4: ::c_long = 313; +pub const SYS_eventfd2: ::c_long = 314; +pub const SYS_epoll_create1: ::c_long = 315; +pub const SYS_dup3: ::c_long = 316; +pub const SYS_pipe2: ::c_long = 317; +pub const SYS_inotify_init1: ::c_long = 318; +pub const SYS_perf_event_open: ::c_long = 319; +pub const SYS_preadv: ::c_long = 320; +pub const SYS_pwritev: ::c_long = 321; +pub const SYS_rt_tgsigqueueinfo: ::c_long = 322; +pub const SYS_fanotify_init: ::c_long = 323; +pub const SYS_fanotify_mark: ::c_long = 324; +pub const SYS_prlimit64: ::c_long = 325; +pub const SYS_socket: ::c_long = 326; +pub const SYS_bind: ::c_long = 327; +pub const SYS_connect: ::c_long = 328; +pub const SYS_listen: ::c_long = 329; +pub const SYS_accept: ::c_long = 330; +pub const SYS_getsockname: ::c_long = 331; +pub const SYS_getpeername: ::c_long = 332; +pub const SYS_socketpair: ::c_long = 333; +pub const SYS_send: ::c_long = 334; +pub const SYS_sendto: ::c_long = 335; +pub const SYS_recv: ::c_long = 336; +pub const SYS_recvfrom: ::c_long = 337; +pub const SYS_shutdown: ::c_long = 338; +pub const SYS_setsockopt: ::c_long = 339; +pub const SYS_getsockopt: ::c_long = 340; +pub const SYS_sendmsg: ::c_long = 341; +pub const SYS_recvmsg: ::c_long = 342; +pub const SYS_recvmmsg: ::c_long = 343; +pub const SYS_accept4: ::c_long = 344; +pub const SYS_name_to_handle_at: ::c_long = 345; +pub const SYS_open_by_handle_at: ::c_long = 346; +pub const SYS_clock_adjtime: ::c_long = 347; +pub const SYS_syncfs: ::c_long = 348; +pub const SYS_sendmmsg: ::c_long = 349; +pub const SYS_setns: ::c_long = 350; +pub const SYS_process_vm_readv: ::c_long = 351; +pub const SYS_process_vm_writev: ::c_long = 352; +pub const SYS_finit_module: ::c_long = 353; +pub const SYS_kcmp: ::c_long = 354; +pub const SYS_sched_setattr: ::c_long = 355; +pub const SYS_sched_getattr: ::c_long = 356; pub const SYS_renameat2: ::c_long = 357; +pub const SYS_seccomp: ::c_long = 358; +pub const SYS_getrandom: ::c_long = 359; +pub const SYS_memfd_create: ::c_long = 360; +pub const SYS_bpf: ::c_long = 361; +pub const SYS_execveat: ::c_long = 362; +pub const SYS_switch_endian: ::c_long = 363; +pub const SYS_userfaultfd: ::c_long = 364; +pub const SYS_membarrier: ::c_long = 365; +pub const SYS_mlock2: ::c_long = 378; +pub const SYS_copy_file_range: ::c_long = 379; +pub const SYS_preadv2: ::c_long = 380; +pub const SYS_pwritev2: ::c_long = 381; +pub const SYS_kexec_file_load: ::c_long = 382; + +pub const FIOCLEX: ::c_int = 0x20006601; +pub const FIONBIO: ::c_int = 0x8004667e; +pub const EDEADLK: ::c_int = 58; +pub const EDEADLOCK: ::c_int = EDEADLK; +pub const SO_PASSCRED: ::c_int = 20; +pub const SO_PEERCRED: ::c_int = 21; +pub const SO_RCVLOWAT: ::c_int = 16; +pub const SO_SNDLOWAT: ::c_int = 17; +pub const SO_RCVTIMEO: ::c_int = 18; +pub const SO_SNDTIMEO: ::c_int = 19; +pub const EXTPROC: ::tcflag_t = 0x10000000; +pub const VEOL: usize = 6; +pub const VEOL2: usize = 8; +pub const VMIN: usize = 5; +pub const IEXTEN: ::tcflag_t = 0x00000400; +pub const TOSTOP: ::tcflag_t = 0x00400000; +pub const FLUSHO: ::tcflag_t = 0x00800000; +pub const TCGETS: ::c_int = 0x403c7413; +pub const TCSETS: ::c_int = 0x803c7414; +pub const TCSETSW: ::c_int = 0x803c7415; +pub const TCSETSF: ::c_int = 0x803c7416; +pub const TCGETA: ::c_int = 0x40147417; +pub const TCSETA: ::c_int = 0x80147418; +pub const TCSETAW: ::c_int = 0x80147419; +pub const TCSETAF: ::c_int = 0x8014741c; +pub const TCSBRK: ::c_int = 0x2000741d; +pub const TCXONC: ::c_int = 0x2000741e; +pub const TCFLSH: ::c_int = 0x2000741f; +pub const TIOCGSOFTCAR: ::c_int = 0x5419; +pub const TIOCSSOFTCAR: ::c_int = 0x541A; +pub const TIOCLINUX: ::c_int = 0x541C; +pub const TIOCGSERIAL: ::c_int = 0x541E; +pub const TIOCEXCL: ::c_int = 0x540C; +pub const TIOCNXCL: ::c_int = 0x540D; +pub const TIOCSCTTY: ::c_int = 0x540E; +pub const TIOCGPGRP: ::c_int = 0x40047477; +pub const TIOCSPGRP: ::c_int = 0x80047476; +pub const TIOCOUTQ: ::c_int = 0x40047473; +pub const TIOCGWINSZ: ::c_int = 0x40087468; +pub const TIOCSWINSZ: ::c_int = 0x80087467; +pub const TIOCMGET: ::c_int = 0x5415; +pub const TIOCMBIS: ::c_int = 0x5416; +pub const TIOCMBIC: ::c_int = 0x5417; +pub const TIOCMSET: ::c_int = 0x5418; +pub const FIONREAD: ::c_int = 0x4004667f; +pub const TIOCCONS: ::c_int = 0x541D; +pub const TIOCM_LE: ::c_int = 0x001; +pub const TIOCM_DTR: ::c_int = 0x002; +pub const TIOCM_RTS: ::c_int = 0x004; +pub const TIOCM_ST: ::c_int = 0x008; +pub const TIOCM_SR: ::c_int = 0x010; +pub const TIOCM_CTS: ::c_int = 0x020; +pub const TIOCM_CAR: ::c_int = 0x040; +pub const TIOCM_RNG: ::c_int = 0x080; +pub const TIOCM_DSR: ::c_int = 0x100; +pub const TIOCM_CD: ::c_int = TIOCM_CAR; +pub const TIOCM_RI: ::c_int = TIOCM_RNG; + +pub const TIOCGRS485: ::c_int = 0x542E; +pub const TIOCSRS485: ::c_int = 0x542F; + +pub const RLIMIT_NLIMITS: ::c_int = 15; +pub const TIOCINQ: ::c_int = ::FIONREAD; +pub const MCL_CURRENT: ::c_int = 0x2000; +pub const MCL_FUTURE: ::c_int = 0x4000; +pub const CBAUD: ::tcflag_t = 0xff; +pub const TAB1: ::c_int = 0x400; +pub const TAB2: ::c_int = 0x800; +pub const TAB3: ::c_int = 0xc00; +pub const CR1: ::c_int = 0x1000; +pub const CR2: ::c_int = 0x2000; +pub const CR3: ::c_int = 0x3000; +pub const FF1: ::c_int = 0x4000; +pub const BS1: ::c_int = 0x8000; +pub const VT1: ::c_int = 0x10000; +pub const VWERASE: usize = 10; +pub const VREPRINT: usize = 11; +pub const VSUSP: usize = 12; +pub const VSTART: usize = 13; +pub const VSTOP: usize = 14; +pub const VDISCARD: usize = 16; +pub const VTIME: usize = 7; +pub const IXON: ::tcflag_t = 0x00000200; +pub const IXOFF: ::tcflag_t = 0x00000400; +pub const ONLCR: ::tcflag_t = 0x2; +pub const CSIZE: ::tcflag_t = 0x00000300; + +pub const CS6: ::tcflag_t = 0x00000100; +pub const CS7: ::tcflag_t = 0x00000200; +pub const CS8: ::tcflag_t = 0x00000300; +pub const CSTOPB: ::tcflag_t = 0x00000400; +pub const CREAD: ::tcflag_t = 0x00000800; +pub const PARENB: ::tcflag_t = 0x00001000; +pub const PARODD: ::tcflag_t = 0x00002000; +pub const HUPCL: ::tcflag_t = 0x00004000; +pub const CLOCAL: ::tcflag_t = 0x00008000; +pub const ECHOKE: ::tcflag_t = 0x00000001; +pub const ECHOE: ::tcflag_t = 0x00000002; +pub const ECHOK: ::tcflag_t = 0x00000004; +pub const ECHONL: ::tcflag_t = 0x00000010; +pub const ECHOPRT: ::tcflag_t = 0x00000020; +pub const ECHOCTL: ::tcflag_t = 0x00000040; +pub const ISIG: ::tcflag_t = 0x00000080; +pub const ICANON: ::tcflag_t = 0x00000100; +pub const PENDIN: ::tcflag_t = 0x20000000; +pub const NOFLSH: ::tcflag_t = 0x80000000; + +pub const CIBAUD: ::tcflag_t = 0o77600000; +pub const CBAUDEX: ::tcflag_t = 0o0000020; +pub const VSWTC: usize = 9; +pub const OLCUC: ::tcflag_t = 0o000004; +pub const NLDLY: ::tcflag_t = 0o0001400; +pub const CRDLY: ::tcflag_t = 0o0030000; +pub const TABDLY: ::tcflag_t = 0o0006000; +pub const BSDLY: ::tcflag_t = 0o0100000; +pub const FFDLY: ::tcflag_t = 0o0040000; +pub const VTDLY: ::tcflag_t = 0o0200000; +pub const XTABS: ::tcflag_t = 0o00006000; + +pub const B57600: ::speed_t = 0o00020; +pub const B115200: ::speed_t = 0o00021; +pub const B230400: ::speed_t = 0o00022; +pub const B460800: ::speed_t = 0o00023; +pub const B500000: ::speed_t = 0o00024; +pub const B576000: ::speed_t = 0o00025; +pub const B921600: ::speed_t = 0o00026; +pub const B1000000: ::speed_t = 0o00027; +pub const B1152000: ::speed_t = 0o00030; +pub const B1500000: ::speed_t = 0o00031; +pub const B2000000: ::speed_t = 0o00032; +pub const B2500000: ::speed_t = 0o00033; +pub const B3000000: ::speed_t = 0o00034; +pub const B3500000: ::speed_t = 0o00035; +pub const B4000000: ::speed_t = 0o00036; + +extern { + pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; +} diff --git a/libc/src/unix/notbsd/linux/musl/b64/x86_64.rs b/libc/src/unix/notbsd/linux/musl/b64/x86_64.rs index 78d38e4..0e0fcec 100644 --- a/libc/src/unix/notbsd/linux/musl/b64/x86_64.rs +++ b/libc/src/unix/notbsd/linux/musl/b64/x86_64.rs @@ -449,3 +449,139 @@ pub const MINSIGSTKSZ: ::size_t = 2048; pub const AF_MAX: ::c_int = 42; #[doc(hidden)] pub const PF_MAX: ::c_int = AF_MAX; + +pub const RLIMIT_NLIMITS: ::c_int = 16; +pub const TIOCINQ: ::c_int = ::FIONREAD; +pub const MCL_CURRENT: ::c_int = 0x0001; +pub const MCL_FUTURE: ::c_int = 0x0002; +pub const CBAUD: ::tcflag_t = 0o0010017; +pub const TAB1: ::c_int = 0x00000800; +pub const TAB2: ::c_int = 0x00001000; +pub const TAB3: ::c_int = 0x00001800; +pub const CR1: ::c_int = 0x00000200; +pub const CR2: ::c_int = 0x00000400; +pub const CR3: ::c_int = 0x00000600; +pub const FF1: ::c_int = 0x00008000; +pub const BS1: ::c_int = 0x00002000; +pub const VT1: ::c_int = 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 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 FIOCLEX: ::c_int = 0x5451; +pub const FIONBIO: ::c_int = 0x5421; +pub const EDEADLK: ::c_int = 35; +pub const EDEADLOCK: ::c_int = EDEADLK; +pub const SO_PASSCRED: ::c_int = 16; +pub const SO_PEERCRED: ::c_int = 17; +pub const SO_RCVLOWAT: ::c_int = 18; +pub const SO_SNDLOWAT: ::c_int = 19; +pub const SO_RCVTIMEO: ::c_int = 20; +pub const SO_SNDTIMEO: ::c_int = 21; +pub const EXTPROC: ::tcflag_t = 0x00010000; +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 TCGETS: ::c_int = 0x5401; +pub const TCSETS: ::c_int = 0x5402; +pub const TCSETSW: ::c_int = 0x5403; +pub const TCSETSF: ::c_int = 0x5404; +pub const TCGETA: ::c_int = 0x5405; +pub const TCSETA: ::c_int = 0x5406; +pub const TCSETAW: ::c_int = 0x5407; +pub const TCSETAF: ::c_int = 0x5408; +pub const TCSBRK: ::c_int = 0x5409; +pub const TCXONC: ::c_int = 0x540A; +pub const TCFLSH: ::c_int = 0x540B; +pub const TIOCGSOFTCAR: ::c_int = 0x5419; +pub const TIOCSSOFTCAR: ::c_int = 0x541A; +pub const TIOCLINUX: ::c_int = 0x541C; +pub const TIOCGSERIAL: ::c_int = 0x541E; +pub const TIOCEXCL: ::c_int = 0x540C; +pub const TIOCNXCL: ::c_int = 0x540D; +pub const TIOCSCTTY: ::c_int = 0x540E; +pub const TIOCGPGRP: ::c_int = 0x540F; +pub const TIOCSPGRP: ::c_int = 0x5410; +pub const TIOCOUTQ: ::c_int = 0x5411; +pub const TIOCSTI: ::c_int = 0x5412; +pub const TIOCGWINSZ: ::c_int = 0x5413; +pub const TIOCSWINSZ: ::c_int = 0x5414; +pub const TIOCMGET: ::c_int = 0x5415; +pub const TIOCMBIS: ::c_int = 0x5416; +pub const TIOCMBIC: ::c_int = 0x5417; +pub const TIOCMSET: ::c_int = 0x5418; +pub const FIONREAD: ::c_int = 0x541B; +pub const TIOCCONS: ::c_int = 0x541D; + +pub const TIOCM_LE: ::c_int = 0x001; +pub const TIOCM_DTR: ::c_int = 0x002; +pub const TIOCM_RTS: ::c_int = 0x004; +pub const TIOCM_ST: ::c_int = 0x008; +pub const TIOCM_SR: ::c_int = 0x010; +pub const TIOCM_CTS: ::c_int = 0x020; +pub const TIOCM_CAR: ::c_int = 0x040; +pub const TIOCM_RNG: ::c_int = 0x080; +pub const TIOCM_DSR: ::c_int = 0x100; +pub const TIOCM_CD: ::c_int = TIOCM_CAR; +pub const TIOCM_RI: ::c_int = TIOCM_RNG; + +extern { + pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; +} + diff --git a/libc/src/unix/notbsd/linux/musl/mod.rs b/libc/src/unix/notbsd/linux/musl/mod.rs index 7513aae..5ab5d0f 100644 --- a/libc/src/unix/notbsd/linux/musl/mod.rs +++ b/libc/src/unix/notbsd/linux/musl/mod.rs @@ -40,6 +40,26 @@ s! { pub sa_restorer: ::dox::Option<extern fn()>, } + 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, + #[cfg(target_endian = "little")] + pub f_fsid: ::c_ulong, + #[cfg(target_pointer_width = "32")] + __f_unused: ::c_int, + #[cfg(target_endian = "big")] + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + pub struct termios { pub c_iflag: ::tcflag_t, pub c_oflag: ::tcflag_t, @@ -101,6 +121,10 @@ pub const ECOMM: ::c_int = 70; pub const EPROTO: ::c_int = 71; pub const EDOTDOT: ::c_int = 73; +pub const F_RDLCK: ::c_int = 0; +pub const F_WRLCK: ::c_int = 1; +pub const F_UNLCK: ::c_int = 2; + pub const SA_NODEFER: ::c_int = 0x40000000; pub const SA_RESETHAND: ::c_int = 0x80000000; pub const SA_RESTART: ::c_int = 0x10000000; @@ -127,7 +151,6 @@ pub const POSIX_MADV_DONTNEED: ::c_int = 4; pub const RLIM_INFINITY: ::rlim_t = !0; pub const RLIMIT_RTTIME: ::c_int = 15; -pub const RLIMIT_NLIMITS: ::c_int = 16; pub const MAP_ANONYMOUS: ::c_int = MAP_ANON; @@ -193,8 +216,6 @@ pub const TCSANOW: ::c_int = 0; pub const TCSADRAIN: ::c_int = 1; pub const TCSAFLUSH: ::c_int = 2; -pub const TIOCINQ: ::c_int = ::FIONREAD; - pub const RTLD_GLOBAL: ::c_int = 0x100; pub const RTLD_NOLOAD: ::c_int = 0x4; @@ -203,61 +224,6 @@ pub const RTLD_NOLOAD: ::c_int = 0x4; pub const CLOCK_SGI_CYCLE: ::clockid_t = 10; pub const CLOCK_TAI: ::clockid_t = 11; -pub const MCL_CURRENT: ::c_int = 0x0001; -pub const MCL_FUTURE: ::c_int = 0x0002; - -pub const CBAUD: ::tcflag_t = 0o0010017; -pub const TAB1: ::c_int = 0x00000800; -pub const TAB2: ::c_int = 0x00001000; -pub const TAB3: ::c_int = 0x00001800; -pub const CR1: ::c_int = 0x00000200; -pub const CR2: ::c_int = 0x00000400; -pub const CR3: ::c_int = 0x00000600; -pub const FF1: ::c_int = 0x00008000; -pub const BS1: ::c_int = 0x00002000; -pub const VT1: ::c_int = 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; @@ -276,21 +242,6 @@ 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 SO_BINDTODEVICE: ::c_int = 25; pub const SO_TIMESTAMP: ::c_int = 29; @@ -300,10 +251,16 @@ pub const SO_PEEK_OFF: ::c_int = 42; pub const SO_BUSY_POLL: ::c_int = 46; extern { - pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; pub fn ptrace(request: ::c_int, ...) -> ::c_long; pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int; pub fn setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int; + pub fn pthread_getaffinity_np(thread: ::pthread_t, + cpusetsize: ::size_t, + cpuset: *mut ::cpu_set_t) -> ::c_int; + pub fn pthread_setaffinity_np(thread: ::pthread_t, + cpusetsize: ::size_t, + cpuset: *const ::cpu_set_t) -> ::c_int; + pub fn sched_getcpu() -> ::c_int; } cfg_if! { @@ -314,7 +271,8 @@ cfg_if! { pub use self::b64::*; } else if #[cfg(any(target_arch = "x86", target_arch = "mips", - target_arch = "arm"))] { + target_arch = "arm", + target_arch = "powerpc"))] { mod b32; pub use self::b32::*; } else { } diff --git a/libc/src/unix/notbsd/linux/other/b32/mod.rs b/libc/src/unix/notbsd/linux/other/b32/mod.rs index 8536353..d078f75 100644 --- a/libc/src/unix/notbsd/linux/other/b32/mod.rs +++ b/libc/src/unix/notbsd/linux/other/b32/mod.rs @@ -1,5 +1,7 @@ //! 32-bit specific definitions for linux-like values +use pthread_mutex_t; + pub type c_long = i32; pub type c_ulong = u32; pub type clock_t = i32; @@ -44,6 +46,22 @@ s! { __unused5: ::c_long, } + 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, + __f_unused: ::c_int, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + pub struct pthread_attr_t { __size: [u32; 9] } @@ -233,6 +251,10 @@ pub const F_SETOWN: ::c_int = 8; pub const F_SETLK: ::c_int = 6; pub const F_SETLKW: ::c_int = 7; +pub const F_RDLCK: ::c_int = 0; +pub const F_WRLCK: ::c_int = 1; +pub const F_UNLCK: ::c_int = 2; + pub const SFD_NONBLOCK: ::c_int = 0x0800; pub const TIOCEXCL: ::c_ulong = 0x540C; @@ -283,6 +305,57 @@ pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; +align_const! { + #[cfg(target_endian = "little")] + pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, + ], + }; + #[cfg(target_endian = "little")] + pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, + ], + }; + #[cfg(target_endian = "little")] + pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, + ], + }; + #[cfg(target_endian = "big")] + pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 0, + ], + }; + #[cfg(target_endian = "big")] + pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 0, + ], + }; + #[cfg(target_endian = "big")] + pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, + 0, 0, 0, + ], + }; +} + pub const PTRACE_GETFPREGS: ::c_uint = 14; pub const PTRACE_SETFPREGS: ::c_uint = 15; pub const PTRACE_GETREGS: ::c_uint = 12; diff --git a/libc/src/unix/notbsd/linux/other/b64/aarch64.rs b/libc/src/unix/notbsd/linux/other/b64/aarch64.rs index 80ebe7e..d6e37ff 100644 --- a/libc/src/unix/notbsd/linux/other/b64/aarch64.rs +++ b/libc/src/unix/notbsd/linux/other/b64/aarch64.rs @@ -1,5 +1,7 @@ //! AArch64-specific definitions for 64-bit linux-like values +use pthread_mutex_t; + pub type c_long = i64; pub type c_ulong = u64; pub type c_char = u8; @@ -69,6 +71,21 @@ s! { pub f_spare: [::__fsword_t; 4], } + 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_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + pub struct statvfs64 { pub f_bsize: ::c_ulong, pub f_frsize: ::c_ulong, @@ -267,8 +284,6 @@ pub const SO_PASSSEC: ::c_int = 34; pub const SO_TIMESTAMPNS: ::c_int = 35; pub const SCM_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS; pub const SO_MARK: ::c_int = 36; -pub const SO_TIMESTAMPING: ::c_int = 37; -pub const SCM_TIMESTAMPING: ::c_int = SO_TIMESTAMPING; pub const SO_PROTOCOL: ::c_int = 38; pub const SO_DOMAIN: ::c_int = 39; pub const SO_RXQ_OVFL: ::c_int = 40; @@ -323,6 +338,10 @@ pub const F_SETOWN: ::c_int = 8; pub const F_SETLK: ::c_int = 6; pub const F_SETLKW: ::c_int = 7; +pub const F_RDLCK: ::c_int = 0; +pub const F_WRLCK: ::c_int = 1; +pub const F_UNLCK: ::c_int = 2; + pub const SFD_NONBLOCK: ::c_int = 0x0800; pub const TIOCEXCL: ::c_ulong = 0x540C; @@ -371,6 +390,33 @@ pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 8; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 48; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 8; +align_const! { + pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + ], + }; + pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + ], + }; + pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + ], + }; +} + pub const O_DIRECT: ::c_int = 0x10000; pub const O_DIRECTORY: ::c_int = 0x4000; pub const O_NOFOLLOW: ::c_int = 0x8000; diff --git a/libc/src/unix/notbsd/linux/other/b64/not_x32.rs b/libc/src/unix/notbsd/linux/other/b64/not_x32.rs index fb30a31..e3e4498 100644 --- a/libc/src/unix/notbsd/linux/other/b64/not_x32.rs +++ b/libc/src/unix/notbsd/linux/other/b64/not_x32.rs @@ -1,9 +1,79 @@ +use pthread_mutex_t; + pub type c_long = i64; pub type c_ulong = u64; +s! { + 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_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } +} + pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; +align_const! { + #[cfg(target_endian = "little")] + pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + #[cfg(target_endian = "little")] + pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + #[cfg(target_endian = "little")] + pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + #[cfg(target_endian = "big")] + pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + #[cfg(target_endian = "big")] + pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + #[cfg(target_endian = "big")] + pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; +} + // Syscall table pub const SYS_read: ::c_long = 0; diff --git a/libc/src/unix/notbsd/linux/other/b64/powerpc64.rs b/libc/src/unix/notbsd/linux/other/b64/powerpc64.rs index 65f2fa2..bc5b01c 100644 --- a/libc/src/unix/notbsd/linux/other/b64/powerpc64.rs +++ b/libc/src/unix/notbsd/linux/other/b64/powerpc64.rs @@ -1,5 +1,7 @@ //! PowerPC64-specific definitions for 64-bit linux-like values +use pthread_mutex_t; + pub type c_long = i64; pub type c_ulong = u64; pub type c_char = u8; @@ -67,6 +69,21 @@ s! { pub f_spare: [::__fsword_t; 4], } + 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_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + pub struct statvfs64 { pub f_bsize: ::c_ulong, pub f_frsize: ::c_ulong, @@ -254,8 +271,6 @@ pub const SO_PASSSEC: ::c_int = 34; pub const SO_TIMESTAMPNS: ::c_int = 35; pub const SCM_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS; pub const SO_MARK: ::c_int = 36; -pub const SO_TIMESTAMPING: ::c_int = 37; -pub const SCM_TIMESTAMPING: ::c_int = SO_TIMESTAMPING; pub const SO_PROTOCOL: ::c_int = 38; pub const SO_DOMAIN: ::c_int = 39; pub const SO_RXQ_OVFL: ::c_int = 40; @@ -310,6 +325,10 @@ pub const F_SETOWN: ::c_int = 8; pub const F_SETLK: ::c_int = 6; pub const F_SETLKW: ::c_int = 7; +pub const F_RDLCK: ::c_int = 0; +pub const F_WRLCK: ::c_int = 1; +pub const F_UNLCK: ::c_int = 2; + pub const SFD_NONBLOCK: ::c_int = 0x0800; pub const TIOCEXCL: ::c_ulong = 0x540C; @@ -358,6 +377,57 @@ pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; +align_const! { + #[cfg(target_endian = "little")] + pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + #[cfg(target_endian = "little")] + pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + #[cfg(target_endian = "little")] + pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + #[cfg(target_endian = "big")] + pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + #[cfg(target_endian = "big")] + pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + #[cfg(target_endian = "big")] + pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; +} + pub const O_DIRECTORY: ::c_int = 0x4000; pub const O_NOFOLLOW: ::c_int = 0x8000; pub const O_DIRECT: ::c_int = 0x20000; diff --git a/libc/src/unix/notbsd/linux/other/b64/sparc64.rs b/libc/src/unix/notbsd/linux/other/b64/sparc64.rs index 819246e..325c793 100644 --- a/libc/src/unix/notbsd/linux/other/b64/sparc64.rs +++ b/libc/src/unix/notbsd/linux/other/b64/sparc64.rs @@ -1,5 +1,7 @@ //! SPARC64-specific definitions for 64-bit linux-like values +use pthread_mutex_t; + pub type c_long = i64; pub type c_ulong = u64; pub type c_char = i8; @@ -69,6 +71,21 @@ s! { pub f_spare: [::__fsword_t; 4], } + 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_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + pub struct statvfs64 { pub f_bsize: ::c_ulong, pub f_frsize: ::c_ulong, @@ -145,7 +162,7 @@ pub const O_DSYNC: ::c_int = 0x2000; pub const O_FSYNC: ::c_int = 0x802000; pub const O_NOATIME: ::c_int = 0x200000; pub const O_PATH: ::c_int = 0x1000000; -pub const O_TMPFILE: ::c_int = 0o200000000 | O_DIRECTORY; +pub const O_TMPFILE: ::c_int = 0x2000000 | O_DIRECTORY; pub const MAP_GROWSDOWN: ::c_int = 0x0200; @@ -230,6 +247,7 @@ pub const ERFKILL: ::c_int = 134; pub const SOL_SOCKET: ::c_int = 0xffff; +pub const SO_PASSCRED: ::c_int = 2; pub const SO_REUSEADDR: ::c_int = 4; pub const SO_BINDTODEVICE: ::c_int = 0x000d; pub const SO_TIMESTAMP: ::c_int = 0x001d; @@ -243,6 +261,8 @@ pub const SO_DONTROUTE: ::c_int = 16; pub const SO_BROADCAST: ::c_int = 32; pub const SO_SNDBUF: ::c_int = 0x1001; pub const SO_RCVBUF: ::c_int = 0x1002; +pub const SO_SNDBUFFORCE: ::c_int = 0x100a; +pub const SO_RCVBUFFORCE: ::c_int = 0x100b; pub const SO_DOMAIN: ::c_int = 0x1029; pub const SO_KEEPALIVE: ::c_int = 8; pub const SO_OOBINLINE: ::c_int = 0x100; @@ -286,6 +306,10 @@ pub const F_SETOWN: ::c_int = 6; pub const F_SETLK: ::c_int = 8; pub const F_SETLKW: ::c_int = 9; +pub const F_RDLCK: ::c_int = 1; +pub const F_WRLCK: ::c_int = 2; +pub const F_UNLCK: ::c_int = 3; + pub const SFD_NONBLOCK: ::c_int = 0x4000; pub const TIOCEXCL: ::c_ulong = 0x2000740d; @@ -332,6 +356,30 @@ pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; +align_const! { + pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; +} + pub const O_DIRECTORY: ::c_int = 0o200000; pub const O_NOFOLLOW: ::c_int = 0o400000; pub const O_DIRECT: ::c_int = 0x100000; @@ -407,6 +455,41 @@ 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 BOTHER: ::speed_t = 0x1000; +pub const B57600: ::speed_t = 0x1001; +pub const B115200: ::speed_t = 0x1002; +pub const B230400: ::speed_t = 0x1003; +pub const B460800: ::speed_t = 0x1004; +pub const B76800: ::speed_t = 0x1005; +pub const B153600: ::speed_t = 0x1006; +pub const B307200: ::speed_t = 0x1007; +pub const B614400: ::speed_t = 0x1008; +pub const B921600: ::speed_t = 0x1009; +pub const B500000: ::speed_t = 0x100a; +pub const B576000: ::speed_t = 0x100b; +pub const B1000000: ::speed_t = 0x100c; +pub const B1152000: ::speed_t = 0x100d; +pub const B1500000: ::speed_t = 0x100e; +pub const B2000000: ::speed_t = 0x100f; + pub const VEOL: usize = 5; pub const VEOL2: usize = 6; pub const VMIN: usize = 4; diff --git a/libc/src/unix/notbsd/linux/other/b64/x32.rs b/libc/src/unix/notbsd/linux/other/b64/x32.rs index 2e97061..d88dbaf 100644 --- a/libc/src/unix/notbsd/linux/other/b64/x32.rs +++ b/libc/src/unix/notbsd/linux/other/b64/x32.rs @@ -1,9 +1,52 @@ +use pthread_mutex_t; + pub type c_long = i32; pub type c_ulong = u32; +s! { + 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_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } +} + pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 32; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 44; +align_const! { + pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; +} + // Syscall table pub const __X32_SYSCALL_BIT: ::c_long = 0x40000000; diff --git a/libc/src/unix/notbsd/linux/other/b64/x86_64.rs b/libc/src/unix/notbsd/linux/other/b64/x86_64.rs index 5689aaa..43b8b9f 100644 --- a/libc/src/unix/notbsd/linux/other/b64/x86_64.rs +++ b/libc/src/unix/notbsd/linux/other/b64/x86_64.rs @@ -371,8 +371,6 @@ pub const SO_PASSSEC: ::c_int = 34; pub const SO_TIMESTAMPNS: ::c_int = 35; pub const SCM_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS; pub const SO_MARK: ::c_int = 36; -pub const SO_TIMESTAMPING: ::c_int = 37; -pub const SCM_TIMESTAMPING: ::c_int = SO_TIMESTAMPING; pub const SO_PROTOCOL: ::c_int = 38; pub const SO_DOMAIN: ::c_int = 39; pub const SO_RXQ_OVFL: ::c_int = 40; @@ -427,6 +425,10 @@ pub const F_SETOWN: ::c_int = 8; pub const F_SETLK: ::c_int = 6; pub const F_SETLKW: ::c_int = 7; +pub const F_RDLCK: ::c_int = 0; +pub const F_WRLCK: ::c_int = 1; +pub const F_UNLCK: ::c_int = 2; + pub const SFD_NONBLOCK: ::c_int = 0x0800; pub const TIOCEXCL: ::c_ulong = 0x540C; diff --git a/libc/src/unix/notbsd/linux/other/mod.rs b/libc/src/unix/notbsd/linux/other/mod.rs index c256d5f..c1e3393 100644 --- a/libc/src/unix/notbsd/linux/other/mod.rs +++ b/libc/src/unix/notbsd/linux/other/mod.rs @@ -158,13 +158,90 @@ s! { } // FIXME this is actually a union + #[cfg_attr(all(feature = "align", target_pointer_width = "32"), + repr(align(4)))] + #[cfg_attr(all(feature = "align", target_pointer_width = "64"), + repr(align(8)))] pub struct sem_t { #[cfg(target_pointer_width = "32")] __size: [::c_char; 16], #[cfg(target_pointer_width = "64")] __size: [::c_char; 32], + #[cfg(not(feature = "align"))] __align: [::c_long; 0], } + + pub struct mallinfo { + pub arena: ::c_int, + pub ordblks: ::c_int, + pub smblks: ::c_int, + pub hblks: ::c_int, + pub hblkhd: ::c_int, + pub usmblks: ::c_int, + pub fsmblks: ::c_int, + pub uordblks: ::c_int, + pub fordblks: ::c_int, + pub keepcost: ::c_int, + } + + pub struct nlmsghdr { + pub nlmsg_len: u32, + pub nlmsg_type: u16, + pub nlmsg_flags: u16, + pub nlmsg_seq: u32, + pub nlmsg_pid: u32, + } + + pub struct nlmsgerr { + pub error: ::c_int, + pub msg: nlmsghdr, + } + + pub struct nl_pktinfo { + pub group: u32, + } + + pub struct nl_mmap_req { + pub nm_block_size: ::c_uint, + pub nm_block_nr: ::c_uint, + pub nm_frame_size: ::c_uint, + pub nm_frame_nr: ::c_uint, + } + + pub struct nl_mmap_hdr { + pub nm_status: ::c_uint, + pub nm_len: ::c_uint, + pub nm_group: u32, + pub nm_pid: u32, + pub nm_uid: u32, + pub nm_gid: u32, + } + + pub struct nlattr { + pub nla_len: u16, + pub nla_type: u16, + } + + pub struct rtentry { + pub rt_pad1: ::c_ulong, + pub rt_dst: ::sockaddr, + pub rt_gateway: ::sockaddr, + pub rt_genmask: ::sockaddr, + pub rt_flags: ::c_ushort, + pub rt_pad2: ::c_short, + pub rt_pad3: ::c_ulong, + pub rt_tos: ::c_uchar, + pub rt_class: ::c_uchar, + #[cfg(target_pointer_width = "64")] + pub rt_pad4: [::c_short; 3usize], + #[cfg(not(target_pointer_width = "64"))] + pub rt_pad4: ::c_short, + pub rt_metric: ::c_short, + pub rt_dev: *mut ::c_char, + pub rt_mtu: ::c_ulong, + pub rt_window: ::c_ulong, + pub rt_irtt: ::c_ushort, + } } pub const __UT_LINESIZE: usize = 32; @@ -192,13 +269,13 @@ pub const SOCK_NONBLOCK: ::c_int = O_NONBLOCK; pub const SOL_RXRPC: ::c_int = 272; pub const SOL_PPPOL2TP: ::c_int = 273; -pub const SOL_BLUETOOTH: ::c_int = 274; pub const SOL_PNPIPE: ::c_int = 275; pub const SOL_RDS: ::c_int = 276; pub const SOL_IUCV: ::c_int = 277; pub const SOL_CAIF: ::c_int = 278; pub const SOL_ALG: ::c_int = 279; pub const SOL_NFC: ::c_int = 280; +pub const SOL_XDP: ::c_int = 283; pub const MSG_TRYHARD: ::c_int = 4; @@ -504,12 +581,6 @@ pub const NLM_F_EXCL: ::c_int = 0x200; pub const NLM_F_CREATE: ::c_int = 0x400; pub const NLM_F_APPEND: ::c_int = 0x800; -pub const NLMSG_NOOP: ::c_int = 0x1; -pub const NLMSG_ERROR: ::c_int = 0x2; -pub const NLMSG_DONE: ::c_int = 0x3; -pub const NLMSG_OVERRUN: ::c_int = 0x4; -pub const NLMSG_MIN_TYPE: ::c_int = 0x10; - pub const NETLINK_ADD_MEMBERSHIP: ::c_int = 1; pub const NETLINK_DROP_MEMBERSHIP: ::c_int = 2; pub const NETLINK_PKTINFO: ::c_int = 3; @@ -525,6 +596,13 @@ pub const NLA_F_NESTED: ::c_int = 1 << 15; pub const NLA_F_NET_BYTEORDER: ::c_int = 1 << 14; pub const NLA_TYPE_MASK: ::c_int = !(NLA_F_NESTED | NLA_F_NET_BYTEORDER); +pub const NLA_ALIGNTO: ::c_int = 4; + +pub const GENL_UNS_ADMIN_PERM: ::c_int = 0x10; + +pub const GENL_ID_VFS_DQUOT: ::c_int = ::NLMSG_MIN_TYPE + 1; +pub const GENL_ID_PMCRAID: ::c_int = ::NLMSG_MIN_TYPE + 2; + pub const TIOCM_LE: ::c_int = 0x001; pub const TIOCM_DTR: ::c_int = 0x002; pub const TIOCM_RTS: ::c_int = 0x004; @@ -537,6 +615,228 @@ pub const TIOCM_DSR: ::c_int = 0x100; pub const TIOCM_CD: ::c_int = TIOCM_CAR; pub const TIOCM_RI: ::c_int = TIOCM_RNG; +pub const NF_NETDEV_INGRESS: ::c_int = 0; +pub const NF_NETDEV_NUMHOOKS: ::c_int = 1; + +pub const NFPROTO_INET: ::c_int = 1; +pub const NFPROTO_NETDEV: ::c_int = 5; + +// linux/netfilter/nf_tables.h +cfg_if!{ + if #[cfg(any(target_arch = "arm", target_arch = "powerpc", + target_arch = "powerpc64", target_arch = "aarch64"))] { + pub const NFT_TABLE_MAXNAMELEN: ::c_int = 32; + pub const NFT_CHAIN_MAXNAMELEN: ::c_int = 32; + pub const NFT_SET_MAXNAMELEN: ::c_int = 32; + pub const NFT_OBJ_MAXNAMELEN: ::c_int = 32; + } else if #[cfg(target_arch = "sparc64")] { + pub const NFT_TABLE_MAXNAMELEN: ::c_int = 32; + pub const NFT_CHAIN_MAXNAMELEN: ::c_int = 32; + pub const NFT_SET_MAXNAMELEN: ::c_int = 32; + } else { + pub const NFT_TABLE_MAXNAMELEN: ::c_int = 256; + pub const NFT_CHAIN_MAXNAMELEN: ::c_int = 256; + pub const NFT_SET_MAXNAMELEN: ::c_int = 256; + pub const NFT_OBJ_MAXNAMELEN: ::c_int = 256; + } +} +pub const NFT_USERDATA_MAXLEN: ::c_int = 256; + +pub const NFT_REG_VERDICT: ::c_int = 0; +pub const NFT_REG_1: ::c_int = 1; +pub const NFT_REG_2: ::c_int = 2; +pub const NFT_REG_3: ::c_int = 3; +pub const NFT_REG_4: ::c_int = 4; +pub const __NFT_REG_MAX: ::c_int = 5; +pub const NFT_REG32_00: ::c_int = 8; +pub const NFT_REG32_01: ::c_int = 9; +pub const NFT_REG32_02: ::c_int = 10; +pub const NFT_REG32_03: ::c_int = 11; +pub const NFT_REG32_04: ::c_int = 12; +pub const NFT_REG32_05: ::c_int = 13; +pub const NFT_REG32_06: ::c_int = 14; +pub const NFT_REG32_07: ::c_int = 15; +pub const NFT_REG32_08: ::c_int = 16; +pub const NFT_REG32_09: ::c_int = 17; +pub const NFT_REG32_10: ::c_int = 18; +pub const NFT_REG32_11: ::c_int = 19; +pub const NFT_REG32_12: ::c_int = 20; +pub const NFT_REG32_13: ::c_int = 21; +pub const NFT_REG32_14: ::c_int = 22; +pub const NFT_REG32_15: ::c_int = 23; + +pub const NFT_REG_SIZE: ::c_int = 16; +pub const NFT_REG32_SIZE: ::c_int = 4; + +pub const NFT_CONTINUE: ::c_int = -1; +pub const NFT_BREAK: ::c_int = -2; +pub const NFT_JUMP: ::c_int = -3; +pub const NFT_GOTO: ::c_int = -4; +pub const NFT_RETURN: ::c_int = -5; + +pub const NFT_MSG_NEWTABLE: ::c_int = 0; +pub const NFT_MSG_GETTABLE: ::c_int = 1; +pub const NFT_MSG_DELTABLE: ::c_int = 2; +pub const NFT_MSG_NEWCHAIN: ::c_int = 3; +pub const NFT_MSG_GETCHAIN: ::c_int = 4; +pub const NFT_MSG_DELCHAIN: ::c_int = 5; +pub const NFT_MSG_NEWRULE: ::c_int = 6; +pub const NFT_MSG_GETRULE: ::c_int = 7; +pub const NFT_MSG_DELRULE: ::c_int = 8; +pub const NFT_MSG_NEWSET: ::c_int = 9; +pub const NFT_MSG_GETSET: ::c_int = 10; +pub const NFT_MSG_DELSET: ::c_int = 11; +pub const NFT_MSG_NEWSETELEM: ::c_int = 12; +pub const NFT_MSG_GETSETELEM: ::c_int = 13; +pub const NFT_MSG_DELSETELEM: ::c_int = 14; +pub const NFT_MSG_NEWGEN: ::c_int = 15; +pub const NFT_MSG_GETGEN: ::c_int = 16; +pub const NFT_MSG_TRACE: ::c_int = 17; +cfg_if! { + if #[cfg(not(target_arch = "sparc64"))] { + pub const NFT_MSG_NEWOBJ: ::c_int = 18; + pub const NFT_MSG_GETOBJ: ::c_int = 19; + pub const NFT_MSG_DELOBJ: ::c_int = 20; + pub const NFT_MSG_GETOBJ_RESET: ::c_int = 21; + pub const NFT_MSG_MAX: ::c_int = 22; + } else { + pub const NFT_MSG_MAX: ::c_int = 18; + } +} + +pub const NFT_SET_ANONYMOUS: ::c_int = 0x1; +pub const NFT_SET_CONSTANT: ::c_int = 0x2; +pub const NFT_SET_INTERVAL: ::c_int = 0x4; +pub const NFT_SET_MAP: ::c_int = 0x8; +pub const NFT_SET_TIMEOUT: ::c_int = 0x10; +pub const NFT_SET_EVAL: ::c_int = 0x20; + +pub const NFT_SET_POL_PERFORMANCE: ::c_int = 0; +pub const NFT_SET_POL_MEMORY: ::c_int = 1; + +pub const NFT_SET_ELEM_INTERVAL_END: ::c_int = 0x1; + +pub const NFT_DATA_VALUE: ::c_uint = 0; +pub const NFT_DATA_VERDICT: ::c_uint = 0xffffff00; + +pub const NFT_DATA_RESERVED_MASK: ::c_uint = 0xffffff00; + +pub const NFT_DATA_VALUE_MAXLEN: ::c_int = 64; + +pub const NFT_BYTEORDER_NTOH: ::c_int = 0; +pub const NFT_BYTEORDER_HTON: ::c_int = 1; + +pub const NFT_CMP_EQ: ::c_int = 0; +pub const NFT_CMP_NEQ: ::c_int = 1; +pub const NFT_CMP_LT: ::c_int = 2; +pub const NFT_CMP_LTE: ::c_int = 3; +pub const NFT_CMP_GT: ::c_int = 4; +pub const NFT_CMP_GTE: ::c_int = 5; + +pub const NFT_RANGE_EQ: ::c_int = 0; +pub const NFT_RANGE_NEQ: ::c_int = 1; + +pub const NFT_LOOKUP_F_INV: ::c_int = (1 << 0); + +pub const NFT_DYNSET_OP_ADD: ::c_int = 0; +pub const NFT_DYNSET_OP_UPDATE: ::c_int = 1; + +pub const NFT_DYNSET_F_INV: ::c_int = (1 << 0); + +pub const NFT_PAYLOAD_LL_HEADER: ::c_int = 0; +pub const NFT_PAYLOAD_NETWORK_HEADER: ::c_int = 1; +pub const NFT_PAYLOAD_TRANSPORT_HEADER: ::c_int = 2; + +pub const NFT_PAYLOAD_CSUM_NONE: ::c_int = 0; +pub const NFT_PAYLOAD_CSUM_INET: ::c_int = 1; + +pub const NFT_META_LEN: ::c_int = 0; +pub const NFT_META_PROTOCOL: ::c_int = 1; +pub const NFT_META_PRIORITY: ::c_int = 2; +pub const NFT_META_MARK: ::c_int = 3; +pub const NFT_META_IIF: ::c_int = 4; +pub const NFT_META_OIF: ::c_int = 5; +pub const NFT_META_IIFNAME: ::c_int = 6; +pub const NFT_META_OIFNAME: ::c_int = 7; +pub const NFT_META_IIFTYPE: ::c_int = 8; +pub const NFT_META_OIFTYPE: ::c_int = 9; +pub const NFT_META_SKUID: ::c_int = 10; +pub const NFT_META_SKGID: ::c_int = 11; +pub const NFT_META_NFTRACE: ::c_int = 12; +pub const NFT_META_RTCLASSID: ::c_int = 13; +pub const NFT_META_SECMARK: ::c_int = 14; +pub const NFT_META_NFPROTO: ::c_int = 15; +pub const NFT_META_L4PROTO: ::c_int = 16; +pub const NFT_META_BRI_IIFNAME: ::c_int = 17; +pub const NFT_META_BRI_OIFNAME: ::c_int = 18; +pub const NFT_META_PKTTYPE: ::c_int = 19; +pub const NFT_META_CPU: ::c_int = 20; +pub const NFT_META_IIFGROUP: ::c_int = 21; +pub const NFT_META_OIFGROUP: ::c_int = 22; +pub const NFT_META_CGROUP: ::c_int = 23; +pub const NFT_META_PRANDOM: ::c_int = 24; + +pub const NFT_CT_STATE: ::c_int = 0; +pub const NFT_CT_DIRECTION: ::c_int = 1; +pub const NFT_CT_STATUS: ::c_int = 2; +pub const NFT_CT_MARK: ::c_int = 3; +pub const NFT_CT_SECMARK: ::c_int = 4; +pub const NFT_CT_EXPIRATION: ::c_int = 5; +pub const NFT_CT_HELPER: ::c_int = 6; +pub const NFT_CT_L3PROTOCOL: ::c_int = 7; +pub const NFT_CT_SRC: ::c_int = 8; +pub const NFT_CT_DST: ::c_int = 9; +pub const NFT_CT_PROTOCOL: ::c_int = 10; +pub const NFT_CT_PROTO_SRC: ::c_int = 11; +pub const NFT_CT_PROTO_DST: ::c_int = 12; +pub const NFT_CT_LABELS: ::c_int = 13; +pub const NFT_CT_PKTS: ::c_int = 14; +pub const NFT_CT_BYTES: ::c_int = 15; + +pub const NFT_LIMIT_PKTS: ::c_int = 0; +pub const NFT_LIMIT_PKT_BYTES: ::c_int = 1; + +pub const NFT_LIMIT_F_INV: ::c_int = (1 << 0); + +pub const NFT_QUEUE_FLAG_BYPASS: ::c_int = 0x01; +pub const NFT_QUEUE_FLAG_CPU_FANOUT: ::c_int = 0x02; +pub const NFT_QUEUE_FLAG_MASK: ::c_int = 0x03; + +pub const NFT_QUOTA_F_INV: ::c_int = (1 << 0); + +pub const NFT_REJECT_ICMP_UNREACH: ::c_int = 0; +pub const NFT_REJECT_TCP_RST: ::c_int = 1; +pub const NFT_REJECT_ICMPX_UNREACH: ::c_int = 2; + +pub const NFT_REJECT_ICMPX_NO_ROUTE: ::c_int = 0; +pub const NFT_REJECT_ICMPX_PORT_UNREACH: ::c_int = 1; +pub const NFT_REJECT_ICMPX_HOST_UNREACH: ::c_int = 2; +pub const NFT_REJECT_ICMPX_ADMIN_PROHIBITED: ::c_int = 3; + +pub const NFT_NAT_SNAT: ::c_int = 0; +pub const NFT_NAT_DNAT: ::c_int = 1; + +pub const NFT_TRACETYPE_UNSPEC: ::c_int = 0; +pub const NFT_TRACETYPE_POLICY: ::c_int = 1; +pub const NFT_TRACETYPE_RETURN: ::c_int = 2; +pub const NFT_TRACETYPE_RULE: ::c_int = 3; + +pub const NFT_NG_INCREMENTAL: ::c_int = 0; +pub const NFT_NG_RANDOM: ::c_int = 1; + +pub const M_MXFAST: ::c_int = 1; +pub const M_NLBLKS: ::c_int = 2; +pub const M_GRAIN: ::c_int = 3; +pub const M_KEEP: ::c_int = 4; +pub const M_TRIM_THRESHOLD: ::c_int = -1; +pub const M_TOP_PAD: ::c_int = -2; +pub const M_MMAP_THRESHOLD: ::c_int = -3; +pub const M_MMAP_MAX: ::c_int = -4; +pub const M_CHECK_ACTION: ::c_int = -5; +pub const M_PERTURB: ::c_int = -6; +pub const M_ARENA_TEST: ::c_int = -7; +pub const M_ARENA_MAX: ::c_int = -8; + #[doc(hidden)] pub const AF_MAX: ::c_int = 42; #[doc(hidden)] @@ -552,6 +852,13 @@ cfg_if! { pub const PTHREAD_STACK_MIN: ::size_t = 131072; } } +pub const PTHREAD_MUTEX_ADAPTIVE_NP: ::c_int = 3; + +f! { + pub fn NLA_ALIGN(len: ::c_int) -> ::c_int { + return ((len) + NLA_ALIGNTO - 1) & !(NLA_ALIGNTO - 1) + } +} extern { pub fn utmpxname(file: *const ::c_char) -> ::c_int; @@ -562,6 +869,7 @@ extern { pub fn setutxent(); pub fn endutxent(); pub fn getpt() -> ::c_int; + pub fn mallopt(param: ::c_int, value: ::c_int) -> ::c_int; } #[link(name = "util")] @@ -597,6 +905,22 @@ extern { pub fn pthread_rwlockattr_setkind_np(attr: *mut ::pthread_rwlockattr_t, val: ::c_int) -> ::c_int; pub fn sched_getcpu() -> ::c_int; + pub fn mallinfo() -> ::mallinfo; + pub fn malloc_usable_size(ptr: *mut ::c_void) -> ::size_t; + pub fn getauxval(type_: ::c_ulong) -> ::c_ulong; + #[cfg_attr(target_os = "netbsd", link_name = "__getpwent_r50")] + #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwent_r")] + pub fn getpwent_r(pwd: *mut ::unix::notbsd::linux::passwd, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut ::unix::notbsd + ::linux::passwd) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__getgrent_r50")] + #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrent_r")] + pub fn getgrent_r(grp: *mut ::group, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut ::group) -> ::c_int; } cfg_if! { diff --git a/libc/src/unix/notbsd/linux/s390x.rs b/libc/src/unix/notbsd/linux/s390x.rs index d7ed383..9196f88 100644 --- a/libc/src/unix/notbsd/linux/s390x.rs +++ b/libc/src/unix/notbsd/linux/s390x.rs @@ -1,3 +1,5 @@ +use pthread_mutex_t; + pub type blkcnt_t = i64; pub type blksize_t = i64; pub type c_char = u8; @@ -153,6 +155,21 @@ s! { f_spare: [::c_uint; 4], } + 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_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + pub struct msghdr { pub msg_name: *mut ::c_void, pub msg_namelen: ::socklen_t, @@ -230,8 +247,13 @@ s! { } // FIXME this is actually a union + #[cfg_attr(all(feature = "align", target_pointer_width = "32"), + repr(align(4)))] + #[cfg_attr(all(feature = "align", target_pointer_width = "64"), + repr(align(8)))] pub struct sem_t { __size: [::c_char; 32], + #[cfg(not(feature = "align"))] __align: [::c_long; 0], } @@ -356,6 +378,30 @@ pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; +align_const! { + pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; + pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = + pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + }; +} + pub const EADDRINUSE: ::c_int = 98; pub const EADDRNOTAVAIL: ::c_int = 99; pub const ECONNABORTED: ::c_int = 103; @@ -374,6 +420,7 @@ pub const O_CREAT: ::c_int = 64; pub const O_EXCL: ::c_int = 128; pub const O_NONBLOCK: ::c_int = 2048; pub const PTHREAD_STACK_MIN: ::size_t = 16384; +pub const PTHREAD_MUTEX_ADAPTIVE_NP: ::c_int = 3; pub const RLIM_INFINITY: ::rlim_t = 0xffffffffffffffff; pub const SA_NOCLDWAIT: ::c_int = 2; pub const SA_ONSTACK: ::c_int = 0x08000000; @@ -735,6 +782,9 @@ pub const PTRACE_INTERRUPT: ::c_uint = 0x4207; pub const PTRACE_LISTEN: ::c_uint = 0x4208; pub const PTRACE_PEEKSIGINFO: ::c_uint = 0x4209; +pub const MCL_CURRENT: ::c_int = 0x0001; +pub const MCL_FUTURE: ::c_int = 0x0002; + pub const EPOLLWAKEUP: ::c_int = 0x20000000; pub const MAP_HUGETLB: ::c_int = 0x040000; diff --git a/libc/src/unix/notbsd/mod.rs b/libc/src/unix/notbsd/mod.rs index 07a6043..9557d1b 100644 --- a/libc/src/unix/notbsd/mod.rs +++ b/libc/src/unix/notbsd/mod.rs @@ -53,8 +53,7 @@ s! { pub ai_addrlen: socklen_t, #[cfg(any(target_os = "linux", - target_os = "emscripten", - target_os = "fuchsia"))] + target_os = "emscripten"))] pub ai_addr: *mut ::sockaddr, pub ai_canonname: *mut c_char, @@ -177,6 +176,58 @@ s! { #[cfg(target_pointer_width = "32")] __unused1: [::c_int; 12] } + + pub struct in_pktinfo { + pub ipi_ifindex: ::c_int, + pub ipi_spec_dst: ::in_addr, + pub ipi_addr: ::in_addr, + } + + pub struct ifaddrs { + pub ifa_next: *mut ifaddrs, + pub ifa_name: *mut c_char, + pub ifa_flags: ::c_uint, + pub ifa_addr: *mut ::sockaddr, + pub ifa_netmask: *mut ::sockaddr, + pub ifa_ifu: *mut ::sockaddr, // FIXME This should be a union + pub ifa_data: *mut ::c_void + } + + pub struct in6_rtmsg { + rtmsg_dst: ::in6_addr, + rtmsg_src: ::in6_addr, + rtmsg_gateway: ::in6_addr, + rtmsg_type: u32, + rtmsg_dst_len: u16, + rtmsg_src_len: u16, + rtmsg_metric: u32, + rtmsg_info: ::c_ulong, + rtmsg_flags: u32, + rtmsg_ifindex: ::c_int, + } + + pub struct arpreq { + pub arp_pa: ::sockaddr, + pub arp_ha: ::sockaddr, + pub arp_flags: ::c_int, + pub arp_netmask: ::sockaddr, + pub arp_dev: [::c_char; 16], + } + + pub struct arpreq_old { + pub arp_pa: ::sockaddr, + pub arp_ha: ::sockaddr, + pub arp_flags: ::c_int, + pub arp_netmask: ::sockaddr, + } + + pub struct arphdr { + pub ar_hrd: u16, + pub ar_pro: u16, + pub ar_hln: u8, + pub ar_pln: u8, + pub ar_op: u16, + } } // intentionally not public, only used for fd_set @@ -462,6 +513,7 @@ pub const SOL_LLC: ::c_int = 268; pub const SOL_DCCP: ::c_int = 269; pub const SOL_NETLINK: ::c_int = 270; pub const SOL_TIPC: ::c_int = 271; +pub const SOL_BLUETOOTH: ::c_int = 274; pub const AF_UNSPEC: ::c_int = 0; pub const AF_UNIX: ::c_int = 1; @@ -573,11 +625,19 @@ pub const IP_MULTICAST_TTL: ::c_int = 33; pub const IP_MULTICAST_LOOP: ::c_int = 34; pub const IP_TTL: ::c_int = 2; pub const IP_HDRINCL: ::c_int = 3; +pub const IP_PKTINFO: ::c_int = 8; pub const IP_ADD_MEMBERSHIP: ::c_int = 35; pub const IP_DROP_MEMBERSHIP: ::c_int = 36; pub const IP_TRANSPARENT: ::c_int = 19; +pub const IPV6_UNICAST_HOPS: ::c_int = 16; +pub const IPV6_MULTICAST_IF: ::c_int = 17; +pub const IPV6_MULTICAST_HOPS: ::c_int = 18; +pub const IPV6_MULTICAST_LOOP: ::c_int = 19; pub const IPV6_ADD_MEMBERSHIP: ::c_int = 20; pub const IPV6_DROP_MEMBERSHIP: ::c_int = 21; +pub const IPV6_V6ONLY: ::c_int = 26; +pub const IPV6_RECVPKTINFO: ::c_int = 49; +pub const IPV6_PKTINFO: ::c_int = 50; pub const TCP_NODELAY: ::c_int = 1; pub const TCP_MAXSEG: ::c_int = 2; @@ -593,9 +653,6 @@ pub const TCP_INFO: ::c_int = 11; pub const TCP_QUICKACK: ::c_int = 12; pub const TCP_CONGESTION: ::c_int = 13; -pub const IPV6_MULTICAST_LOOP: ::c_int = 19; -pub const IPV6_V6ONLY: ::c_int = 26; - pub const SO_DEBUG: ::c_int = 1; pub const SHUT_RD: ::c_int = 0; @@ -803,7 +860,160 @@ pub const POLLNVAL: ::c_short = 0x20; pub const POLLRDNORM: ::c_short = 0x040; pub const POLLRDBAND: ::c_short = 0x080; +pub const IPTOS_LOWDELAY: u8 = 0x10; +pub const IPTOS_THROUGHPUT: u8 = 0x08; +pub const IPTOS_RELIABILITY: u8 = 0x04; +pub const IPTOS_MINCOST: u8 = 0x02; + +pub const IPTOS_PREC_NETCONTROL: u8 = 0xe0; +pub const IPTOS_PREC_INTERNETCONTROL: u8 = 0xc0; +pub const IPTOS_PREC_CRITIC_ECP: u8 = 0xa0; +pub const IPTOS_PREC_FLASHOVERRIDE: u8 = 0x80; +pub const IPTOS_PREC_FLASH: u8 = 0x60; +pub const IPTOS_PREC_IMMEDIATE: u8 = 0x40; +pub const IPTOS_PREC_PRIORITY: u8 = 0x20; +pub const IPTOS_PREC_ROUTINE: u8 = 0x00; + +pub const IPOPT_COPY: u8 = 0x80; +pub const IPOPT_CLASS_MASK: u8 = 0x60; +pub const IPOPT_NUMBER_MASK: u8 = 0x1f; + +pub const IPOPT_CONTROL: u8 = 0x00; +pub const IPOPT_RESERVED1: u8 = 0x20; +pub const IPOPT_MEASUREMENT: u8 = 0x40; +pub const IPOPT_RESERVED2: u8 = 0x60; +pub const IPOPT_END: u8 = (0 |IPOPT_CONTROL); +pub const IPOPT_NOOP: u8 = (1 |IPOPT_CONTROL); +pub const IPOPT_SEC: u8 = (2 |IPOPT_CONTROL|IPOPT_COPY); +pub const IPOPT_LSRR: u8 = (3 |IPOPT_CONTROL|IPOPT_COPY); +pub const IPOPT_TIMESTAMP: u8 = (4 |IPOPT_MEASUREMENT); +pub const IPOPT_RR: u8 = (7 |IPOPT_CONTROL); +pub const IPOPT_SID: u8 = (8 |IPOPT_CONTROL|IPOPT_COPY); +pub const IPOPT_SSRR: u8 = (9 |IPOPT_CONTROL|IPOPT_COPY); +pub const IPOPT_RA: u8 = (20|IPOPT_CONTROL|IPOPT_COPY); +pub const IPVERSION: u8 = 4; +pub const MAXTTL: u8 = 255; +pub const IPDEFTTL: u8 = 64; +pub const IPOPT_OPTVAL: u8 = 0; +pub const IPOPT_OLEN: u8 = 1; +pub const IPOPT_OFFSET: u8 = 2; +pub const IPOPT_MINOFF: u8 = 4; +pub const MAX_IPOPTLEN: u8 = 40; +pub const IPOPT_NOP: u8 = IPOPT_NOOP; +pub const IPOPT_EOL: u8 = IPOPT_END; +pub const IPOPT_TS: u8 = IPOPT_TIMESTAMP; +pub const IPOPT_TS_TSONLY: u8 = 0; +pub const IPOPT_TS_TSANDADDR: u8 = 1; +pub const IPOPT_TS_PRESPEC: u8 = 3; + +pub const ARPOP_RREQUEST: u16 = 3; +pub const ARPOP_RREPLY: u16 = 4; +pub const ARPOP_InREQUEST: u16 = 8; +pub const ARPOP_InREPLY: u16 = 9; +pub const ARPOP_NAK: u16 = 10; + +pub const ATF_NETMASK: ::c_int = 0x20; +pub const ATF_DONTPUB: ::c_int = 0x40; + +pub const ARPHRD_NETROM: u16 = 0; +pub const ARPHRD_ETHER: u16 = 1; +pub const ARPHRD_EETHER: u16 = 2; +pub const ARPHRD_AX25: u16 = 3; +pub const ARPHRD_PRONET: u16 = 4; +pub const ARPHRD_CHAOS: u16 = 5; +pub const ARPHRD_IEEE802: u16 = 6; +pub const ARPHRD_ARCNET: u16 = 7; +pub const ARPHRD_APPLETLK: u16 = 8; +pub const ARPHRD_DLCI: u16 = 15; +pub const ARPHRD_ATM: u16 = 19; +pub const ARPHRD_METRICOM: u16 = 23; +pub const ARPHRD_IEEE1394: u16 = 24; +pub const ARPHRD_EUI64: u16 = 27; +pub const ARPHRD_INFINIBAND: u16 = 32; + +pub const ARPHRD_SLIP: u16 = 256; +pub const ARPHRD_CSLIP: u16 = 257; +pub const ARPHRD_SLIP6: u16 = 258; +pub const ARPHRD_CSLIP6: u16 = 259; +pub const ARPHRD_RSRVD: u16 = 260; +pub const ARPHRD_ADAPT: u16 = 264; +pub const ARPHRD_ROSE: u16 = 270; +pub const ARPHRD_X25: u16 = 271; +pub const ARPHRD_HWX25: u16 = 272; +pub const ARPHRD_PPP: u16 = 512; +pub const ARPHRD_CISCO: u16 = 513; +pub const ARPHRD_HDLC: u16 = ARPHRD_CISCO; +pub const ARPHRD_LAPB: u16 = 516; +pub const ARPHRD_DDCMP: u16 = 517; +pub const ARPHRD_RAWHDLC: u16 = 518; + +pub const ARPHRD_TUNNEL: u16 = 768; +pub const ARPHRD_TUNNEL6: u16 = 769; +pub const ARPHRD_FRAD: u16 = 770; +pub const ARPHRD_SKIP: u16 = 771; +pub const ARPHRD_LOOPBACK: u16 = 772; +pub const ARPHRD_LOCALTLK: u16 = 773; +pub const ARPHRD_FDDI: u16 = 774; +pub const ARPHRD_BIF: u16 = 775; +pub const ARPHRD_SIT: u16 = 776; +pub const ARPHRD_IPDDP: u16 = 777; +pub const ARPHRD_IPGRE: u16 = 778; +pub const ARPHRD_PIMREG: u16 = 779; +pub const ARPHRD_HIPPI: u16 = 780; +pub const ARPHRD_ASH: u16 = 781; +pub const ARPHRD_ECONET: u16 = 782; +pub const ARPHRD_IRDA: u16 = 783; +pub const ARPHRD_FCPP: u16 = 784; +pub const ARPHRD_FCAL: u16 = 785; +pub const ARPHRD_FCPL: u16 = 786; +pub const ARPHRD_FCFABRIC: u16 = 787; +pub const ARPHRD_IEEE802_TR: u16 = 800; +pub const ARPHRD_IEEE80211: u16 = 801; +pub const ARPHRD_IEEE80211_PRISM: u16 = 802; +pub const ARPHRD_IEEE80211_RADIOTAP: u16 = 803; +pub const ARPHRD_IEEE802154: u16 = 804; + +pub const ARPHRD_VOID: u16 = 0xFFFF; +pub const ARPHRD_NONE: u16 = 0xFFFE; + f! { + pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr { + if (*mhdr).msg_controllen as usize >= mem::size_of::<cmsghdr>() { + (*mhdr).msg_control as *mut cmsghdr + } else { + 0 as *mut cmsghdr + } + } + + pub fn CMSG_NXTHDR(mhdr: *const msghdr, + cmsg: *const cmsghdr) -> *mut cmsghdr { + if cmsg.is_null() { + return CMSG_FIRSTHDR(mhdr); + }; + let pad = mem::align_of::<cmsghdr>() - 1; + let next = cmsg as usize + (*cmsg).cmsg_len as usize + pad & !pad; + let max = (*mhdr).msg_control as usize + + (*mhdr).msg_controllen as usize; + if next < max { + next as *mut cmsghdr + } else { + 0 as *mut cmsghdr + } + } + + pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut ::c_uchar { + cmsg.offset(1) as *mut ::c_uchar + } + + pub fn CMSG_SPACE(length: ::c_uint) -> ::c_uint { + let pad = mem::align_of::<cmsghdr>() as ::c_uint - 1; + mem::size_of::<cmsghdr>() as ::c_uint + ((length + pad) & !pad) + } + + pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint { + mem::size_of::<cmsghdr>() as ::c_uint + length + } + pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () { let fd = fd as usize; let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; @@ -865,6 +1075,18 @@ f! { pub fn QCMD(cmd: ::c_int, type_: ::c_int) -> ::c_int { (cmd << 8) | (type_ & 0x00ff) } + + pub fn IPOPT_COPIED(o: u8) -> u8 { + o & IPOPT_COPY + } + + pub fn IPOPT_CLASS(o: u8) -> u8 { + o & IPOPT_CLASS_MASK + } + + pub fn IPOPT_NUMBER(o: u8) -> u8 { + o & IPOPT_NUMBER_MASK + } } extern { @@ -944,8 +1166,6 @@ extern { pub fn stat64(path: *const c_char, buf: *mut stat64) -> ::c_int; pub fn truncate64(path: *const c_char, length: off64_t) -> ::c_int; - pub fn fdopendir(fd: ::c_int) -> *mut ::DIR; - pub fn mknodat(dirfd: ::c_int, pathname: *const ::c_char, mode: ::mode_t, dev: dev_t) -> ::c_int; pub fn pthread_condattr_getclock(attr: *const pthread_condattr_t, @@ -992,13 +1212,30 @@ extern { pub fn fexecve(fd: ::c_int, argv: *const *const ::c_char, envp: *const *const ::c_char) -> ::c_int; + pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int; + pub fn freeifaddrs(ifa: *mut ::ifaddrs); + pub fn bind(socket: ::c_int, address: *const ::sockaddr, + address_len: ::socklen_t) -> ::c_int; + + pub fn writev(fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int) -> ::ssize_t; + pub fn readv(fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int) -> ::ssize_t; + + pub fn sendmsg(fd: ::c_int, + msg: *const ::msghdr, + flags: ::c_int) -> ::ssize_t; + pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) + -> ::ssize_t; } cfg_if! { if #[cfg(target_os = "emscripten")] { mod emscripten; pub use self::emscripten::*; - } else if #[cfg(any(target_os = "linux", target_os = "fuchsia"))] { + } else if #[cfg(target_os = "linux")] { mod linux; pub use self::linux::*; } else if #[cfg(target_os = "android")] { diff --git a/libc/src/unix/solaris/mod.rs b/libc/src/unix/solaris/mod.rs index 63bd59a..c4ec111 100644 --- a/libc/src/unix/solaris/mod.rs +++ b/libc/src/unix/solaris/mod.rs @@ -353,6 +353,12 @@ s! { pub portev_object: ::uintptr_t, pub portev_user: *mut ::c_void, } + + #[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), repr(packed))] + pub struct epoll_event { + pub events: ::uint32_t, + pub u64: ::uint64_t, + } } pub const LC_CTYPE: ::c_int = 0; @@ -469,6 +475,9 @@ pub const SIG_BLOCK: ::c_int = 1; pub const SIG_UNBLOCK: ::c_int = 2; pub const SIG_SETMASK: ::c_int = 3; +pub const IPV6_UNICAST_HOPS: ::c_int = 0x5; +pub const IPV6_MULTICAST_IF: ::c_int = 0x6; +pub const IPV6_MULTICAST_HOPS: ::c_int = 0x7; pub const IPV6_MULTICAST_LOOP: ::c_int = 0x8; pub const IPV6_V6ONLY: ::c_int = 0x27; @@ -844,6 +853,7 @@ pub const SOCK_STREAM: ::c_int = 2; pub const SOCK_RAW: ::c_int = 4; pub const SOCK_RDM: ::c_int = 5; pub const SOCK_SEQPACKET: ::c_int = 6; +pub const IP_MULTICAST_IF: ::c_int = 16; pub const IP_MULTICAST_TTL: ::c_int = 17; pub const IP_MULTICAST_LOOP: ::c_int = 18; pub const IP_TTL: ::c_int = 4; @@ -1127,6 +1137,9 @@ pub const NCCS: usize = 19; pub const LOG_CRON: ::c_int = 15 << 3; +pub const SYS_epoll_create: ::c_long = 213; +pub const SYS_epoll_create1: ::c_long = 291; + pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { __pthread_mutex_flag1: 0, __pthread_mutex_flag2: 0, @@ -1182,6 +1195,28 @@ pub const PORT_SOURCE_FILE: ::c_int = 7; pub const PORT_SOURCE_POSTWAIT: ::c_int = 8; pub const PORT_SOURCE_SIGNAL: ::c_int = 9; +pub const TIOCGWINSZ: ::c_int = 0x5468; +pub const TIOCSWINSZ: ::c_int = 0x5467; + +pub const EPOLLIN: ::c_int = 0x1; +pub const EPOLLPRI: ::c_int = 0x2; +pub const EPOLLOUT: ::c_int = 0x4; +pub const EPOLLRDNORM: ::c_int = 0x40; +pub const EPOLLRDBAND: ::c_int = 0x80; +pub const EPOLLWRNORM: ::c_int = 0x100; +pub const EPOLLWRBAND: ::c_int = 0x200; +pub const EPOLLMSG: ::c_int = 0x400; +pub const EPOLLERR: ::c_int = 0x8; +pub const EPOLLHUP: ::c_int = 0x10; +pub const EPOLLET: ::c_int = 0x80000000; +pub const EPOLLRDHUP: ::c_int = 0x2000; +pub const EPOLLEXCLUSIVE: ::c_int = 0x10000000; +pub const EPOLLONESHOT: ::c_int = 0x40000000; +pub const EPOLL_CLOEXEC: ::c_int = 0x80000; +pub const EPOLL_CTL_ADD: ::c_int = 1; +pub const EPOLL_CTL_MOD: ::c_int = 3; +pub const EPOLL_CTL_DEL: ::c_int = 2; + f! { pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () { let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8; @@ -1223,6 +1258,12 @@ f! { } extern { + pub fn abs(i: ::c_int) -> ::c_int; + pub fn atof(s: *const ::c_char) -> ::c_double; + pub fn labs(i: ::c_long) -> ::c_long; + pub fn rand() -> ::c_int; + pub fn srand(seed: ::c_uint); + pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int; pub fn freeifaddrs(ifa: *mut ::ifaddrs); @@ -1234,6 +1275,7 @@ extern { pub fn ioctl(fildes: ::c_int, request: ::c_int, ...) -> ::c_int; pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int; + pub fn ___errno() -> *mut ::c_int; pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; pub fn clock_nanosleep(clk_id: ::clockid_t, @@ -1265,8 +1307,6 @@ extern { pub fn getpriority(which: ::c_int, who: ::c_int) -> ::c_int; pub fn setpriority(which: ::c_int, who: ::c_int, prio: ::c_int) -> ::c_int; - pub fn fdopendir(fd: ::c_int) -> *mut ::DIR; - pub fn mknodat(dirfd: ::c_int, pathname: *const ::c_char, mode: ::mode_t, dev: dev_t) -> ::c_int; pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char, @@ -1284,6 +1324,8 @@ extern { clock_id: ::clockid_t) -> ::c_int; pub fn sem_timedwait(sem: *mut sem_t, abstime: *const ::timespec) -> ::c_int; + pub fn sem_getvalue(sem: *mut sem_t, + sval: *mut ::c_int) -> ::c_int; pub fn pthread_mutex_timedlock(lock: *mut pthread_mutex_t, abstime: *const ::timespec) -> ::c_int; pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t, @@ -1361,6 +1403,23 @@ extern { oss: *mut stack_t) -> ::c_int; pub fn sem_close(sem: *mut sem_t) -> ::c_int; pub fn getdtablesize() -> ::c_int; + + pub fn epoll_pwait(epfd: ::c_int, + events: *mut ::epoll_event, + maxevents: ::c_int, + timeout: ::c_int, + sigmask: *const ::sigset_t) -> ::c_int; + pub fn epoll_create(size: ::c_int) -> ::c_int; + pub fn epoll_create1(flags: ::c_int) -> ::c_int; + pub fn epoll_wait(epfd: ::c_int, + events: *mut ::epoll_event, + maxevents: ::c_int, + timeout: ::c_int) -> ::c_int; + pub fn epoll_ctl(epfd: ::c_int, + op: ::c_int, + fd: ::c_int, + event: *mut ::epoll_event) -> ::c_int; + #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrnam_r")] pub fn getgrnam_r(name: *const ::c_char, grp: *mut ::group, @@ -1386,6 +1445,16 @@ extern { buf: *mut ::c_char, buflen: ::size_t, result: *mut *mut passwd) -> ::c_int; + #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwent_r")] + pub fn getpwent_r(pwd: *mut passwd, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut passwd) -> ::c_int; + #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrent_r")] + pub fn getgrent_r(grp: *mut ::group, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut ::group) -> ::c_int; #[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")] pub fn sigwait(set: *const sigset_t, sig: *mut ::c_int) -> ::c_int; @@ -1395,4 +1464,6 @@ extern { pub fn getgrgid(gid: ::gid_t) -> *mut ::group; pub fn popen(command: *const c_char, mode: *const c_char) -> *mut ::FILE; + + pub fn dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::c_int; } diff --git a/libc/src/unix/uclibc/mips/mips32.rs b/libc/src/unix/uclibc/mips/mips32.rs index 70d26e7..dcbfcf8 100644 --- a/libc/src/unix/uclibc/mips/mips32.rs +++ b/libc/src/unix/uclibc/mips/mips32.rs @@ -66,7 +66,7 @@ s! { } pub struct sigaction { - pub sa_flags: ::c_int, + pub sa_flags: ::c_uint, pub sa_sigaction: ::sighandler_t, pub sa_mask: sigset_t, _restorer: *mut ::c_void, @@ -222,11 +222,16 @@ s! { } // FIXME this is actually a union + #[cfg_attr(all(feature = "align", target_pointer_width = "32"), + repr(align(4)))] + #[cfg_attr(all(feature = "align", target_pointer_width = "64"), + repr(align(8)))] pub struct sem_t { #[cfg(target_pointer_width = "32")] __size: [::c_char; 16], #[cfg(target_pointer_width = "64")] __size: [::c_char; 32], + #[cfg(not(feature = "align"))] __align: [::c_long; 0], } } @@ -238,7 +243,372 @@ pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; pub const RLIM_INFINITY: ::rlim_t = 0x7fffffff; -pub const SYS_gettid: ::c_long = 4222; // Valid for O32 +pub const SYS_syscall: ::c_long = 4000 + 0; +pub const SYS_exit: ::c_long = 4000 + 1; +pub const SYS_fork: ::c_long = 4000 + 2; +pub const SYS_read: ::c_long = 4000 + 3; +pub const SYS_write: ::c_long = 4000 + 4; +pub const SYS_open: ::c_long = 4000 + 5; +pub const SYS_close: ::c_long = 4000 + 6; +pub const SYS_waitpid: ::c_long = 4000 + 7; +pub const SYS_creat: ::c_long = 4000 + 8; +pub const SYS_link: ::c_long = 4000 + 9; +pub const SYS_unlink: ::c_long = 4000 + 10; +pub const SYS_execve: ::c_long = 4000 + 11; +pub const SYS_chdir: ::c_long = 4000 + 12; +pub const SYS_time: ::c_long = 4000 + 13; +pub const SYS_mknod: ::c_long = 4000 + 14; +pub const SYS_chmod: ::c_long = 4000 + 15; +pub const SYS_lchown: ::c_long = 4000 + 16; +pub const SYS_break: ::c_long = 4000 + 17; +pub const SYS_unused18: ::c_long = 4000 + 18; +pub const SYS_lseek: ::c_long = 4000 + 19; +pub const SYS_getpid: ::c_long = 4000 + 20; +pub const SYS_mount: ::c_long = 4000 + 21; +pub const SYS_umount: ::c_long = 4000 + 22; +pub const SYS_setuid: ::c_long = 4000 + 23; +pub const SYS_getuid: ::c_long = 4000 + 24; +pub const SYS_stime: ::c_long = 4000 + 25; +pub const SYS_ptrace: ::c_long = 4000 + 26; +pub const SYS_alarm: ::c_long = 4000 + 27; +pub const SYS_unused28: ::c_long = 4000 + 28; +pub const SYS_pause: ::c_long = 4000 + 29; +pub const SYS_utime: ::c_long = 4000 + 30; +pub const SYS_stty: ::c_long = 4000 + 31; +pub const SYS_gtty: ::c_long = 4000 + 32; +pub const SYS_access: ::c_long = 4000 + 33; +pub const SYS_nice: ::c_long = 4000 + 34; +pub const SYS_ftime: ::c_long = 4000 + 35; +pub const SYS_sync: ::c_long = 4000 + 36; +pub const SYS_kill: ::c_long = 4000 + 37; +pub const SYS_rename: ::c_long = 4000 + 38; +pub const SYS_mkdir: ::c_long = 4000 + 39; +pub const SYS_rmdir: ::c_long = 4000 + 40; +pub const SYS_dup: ::c_long = 4000 + 41; +pub const SYS_pipe: ::c_long = 4000 + 42; +pub const SYS_times: ::c_long = 4000 + 43; +pub const SYS_prof: ::c_long = 4000 + 44; +pub const SYS_brk: ::c_long = 4000 + 45; +pub const SYS_setgid: ::c_long = 4000 + 46; +pub const SYS_getgid: ::c_long = 4000 + 47; +pub const SYS_signal: ::c_long = 4000 + 48; +pub const SYS_geteuid: ::c_long = 4000 + 49; +pub const SYS_getegid: ::c_long = 4000 + 50; +pub const SYS_acct: ::c_long = 4000 + 51; +pub const SYS_umount2: ::c_long = 4000 + 52; +pub const SYS_lock: ::c_long = 4000 + 53; +pub const SYS_ioctl: ::c_long = 4000 + 54; +pub const SYS_fcntl: ::c_long = 4000 + 55; +pub const SYS_mpx: ::c_long = 4000 + 56; +pub const SYS_setpgid: ::c_long = 4000 + 57; +pub const SYS_ulimit: ::c_long = 4000 + 58; +pub const SYS_unused59: ::c_long = 4000 + 59; +pub const SYS_umask: ::c_long = 4000 + 60; +pub const SYS_chroot: ::c_long = 4000 + 61; +pub const SYS_ustat: ::c_long = 4000 + 62; +pub const SYS_dup2: ::c_long = 4000 + 63; +pub const SYS_getppid: ::c_long = 4000 + 64; +pub const SYS_getpgrp: ::c_long = 4000 + 65; +pub const SYS_setsid: ::c_long = 4000 + 66; +pub const SYS_sigaction: ::c_long = 4000 + 67; +pub const SYS_sgetmask: ::c_long = 4000 + 68; +pub const SYS_ssetmask: ::c_long = 4000 + 69; +pub const SYS_setreuid: ::c_long = 4000 + 70; +pub const SYS_setregid: ::c_long = 4000 + 71; +pub const SYS_sigsuspend: ::c_long = 4000 + 72; +pub const SYS_sigpending: ::c_long = 4000 + 73; +pub const SYS_sethostname: ::c_long = 4000 + 74; +pub const SYS_setrlimit: ::c_long = 4000 + 75; +pub const SYS_getrlimit: ::c_long = 4000 + 76; +pub const SYS_getrusage: ::c_long = 4000 + 77; +pub const SYS_gettimeofday: ::c_long = 4000 + 78; +pub const SYS_settimeofday: ::c_long = 4000 + 79; +pub const SYS_getgroups: ::c_long = 4000 + 80; +pub const SYS_setgroups: ::c_long = 4000 + 81; +pub const SYS_reserved82: ::c_long = 4000 + 82; +pub const SYS_symlink: ::c_long = 4000 + 83; +pub const SYS_unused84: ::c_long = 4000 + 84; +pub const SYS_readlink: ::c_long = 4000 + 85; +pub const SYS_uselib: ::c_long = 4000 + 86; +pub const SYS_swapon: ::c_long = 4000 + 87; +pub const SYS_reboot: ::c_long = 4000 + 88; +pub const SYS_readdir: ::c_long = 4000 + 89; +pub const SYS_mmap: ::c_long = 4000 + 90; +pub const SYS_munmap: ::c_long = 4000 + 91; +pub const SYS_truncate: ::c_long = 4000 + 92; +pub const SYS_ftruncate: ::c_long = 4000 + 93; +pub const SYS_fchmod: ::c_long = 4000 + 94; +pub const SYS_fchown: ::c_long = 4000 + 95; +pub const SYS_getpriority: ::c_long = 4000 + 96; +pub const SYS_setpriority: ::c_long = 4000 + 97; +pub const SYS_profil: ::c_long = 4000 + 98; +pub const SYS_statfs: ::c_long = 4000 + 99; +pub const SYS_fstatfs: ::c_long = 4000 + 100; +pub const SYS_ioperm: ::c_long = 4000 + 101; +pub const SYS_socketcall: ::c_long = 4000 + 102; +pub const SYS_syslog: ::c_long = 4000 + 103; +pub const SYS_setitimer: ::c_long = 4000 + 104; +pub const SYS_getitimer: ::c_long = 4000 + 105; +pub const SYS_stat: ::c_long = 4000 + 106; +pub const SYS_lstat: ::c_long = 4000 + 107; +pub const SYS_fstat: ::c_long = 4000 + 108; +pub const SYS_unused109: ::c_long = 4000 + 109; +pub const SYS_iopl: ::c_long = 4000 + 110; +pub const SYS_vhangup: ::c_long = 4000 + 111; +pub const SYS_idle: ::c_long = 4000 + 112; +pub const SYS_vm86: ::c_long = 4000 + 113; +pub const SYS_wait4: ::c_long = 4000 + 114; +pub const SYS_swapoff: ::c_long = 4000 + 115; +pub const SYS_sysinfo: ::c_long = 4000 + 116; +pub const SYS_ipc: ::c_long = 4000 + 117; +pub const SYS_fsync: ::c_long = 4000 + 118; +pub const SYS_sigreturn: ::c_long = 4000 + 119; +pub const SYS_clone: ::c_long = 4000 + 120; +pub const SYS_setdomainname: ::c_long = 4000 + 121; +pub const SYS_uname: ::c_long = 4000 + 122; +pub const SYS_modify_ldt: ::c_long = 4000 + 123; +pub const SYS_adjtimex: ::c_long = 4000 + 124; +pub const SYS_mprotect: ::c_long = 4000 + 125; +pub const SYS_sigprocmask: ::c_long = 4000 + 126; +pub const SYS_create_module: ::c_long = 4000 + 127; +pub const SYS_init_module: ::c_long = 4000 + 128; +pub const SYS_delete_module: ::c_long = 4000 + 129; +pub const SYS_get_kernel_syms: ::c_long = 4000 + 130; +pub const SYS_quotactl: ::c_long = 4000 + 131; +pub const SYS_getpgid: ::c_long = 4000 + 132; +pub const SYS_fchdir: ::c_long = 4000 + 133; +pub const SYS_bdflush: ::c_long = 4000 + 134; +pub const SYS_sysfs: ::c_long = 4000 + 135; +pub const SYS_personality: ::c_long = 4000 + 136; +pub const SYS_afs_syscall: ::c_long = 4000 + 137; +pub const SYS_setfsuid: ::c_long = 4000 + 138; +pub const SYS_setfsgid: ::c_long = 4000 + 139; +pub const SYS__llseek: ::c_long = 4000 + 140; +pub const SYS_getdents: ::c_long = 4000 + 141; +pub const SYS__newselect: ::c_long = 4000 + 142; +pub const SYS_flock: ::c_long = 4000 + 143; +pub const SYS_msync: ::c_long = 4000 + 144; +pub const SYS_readv: ::c_long = 4000 + 145; +pub const SYS_writev: ::c_long = 4000 + 146; +pub const SYS_cacheflush: ::c_long = 4000 + 147; +pub const SYS_cachectl: ::c_long = 4000 + 148; +pub const SYS_sysmips: ::c_long = 4000 + 149; +pub const SYS_unused150: ::c_long = 4000 + 150; +pub const SYS_getsid: ::c_long = 4000 + 151; +pub const SYS_fdatasync: ::c_long = 4000 + 152; +pub const SYS__sysctl: ::c_long = 4000 + 153; +pub const SYS_mlock: ::c_long = 4000 + 154; +pub const SYS_munlock: ::c_long = 4000 + 155; +pub const SYS_mlockall: ::c_long = 4000 + 156; +pub const SYS_munlockall: ::c_long = 4000 + 157; +pub const SYS_sched_setparam: ::c_long = 4000 + 158; +pub const SYS_sched_getparam: ::c_long = 4000 + 159; +pub const SYS_sched_setscheduler: ::c_long = 4000 + 160; +pub const SYS_sched_getscheduler: ::c_long = 4000 + 161; +pub const SYS_sched_yield: ::c_long = 4000 + 162; +pub const SYS_sched_get_priority_max: ::c_long = 4000 + 163; +pub const SYS_sched_get_priority_min: ::c_long = 4000 + 164; +pub const SYS_sched_rr_get_interval: ::c_long = 4000 + 165; +pub const SYS_nanosleep: ::c_long = 4000 + 166; +pub const SYS_mremap: ::c_long = 4000 + 167; +pub const SYS_accept: ::c_long = 4000 + 168; +pub const SYS_bind: ::c_long = 4000 + 169; +pub const SYS_connect: ::c_long = 4000 + 170; +pub const SYS_getpeername: ::c_long = 4000 + 171; +pub const SYS_getsockname: ::c_long = 4000 + 172; +pub const SYS_getsockopt: ::c_long = 4000 + 173; +pub const SYS_listen: ::c_long = 4000 + 174; +pub const SYS_recv: ::c_long = 4000 + 175; +pub const SYS_recvfrom: ::c_long = 4000 + 176; +pub const SYS_recvmsg: ::c_long = 4000 + 177; +pub const SYS_send: ::c_long = 4000 + 178; +pub const SYS_sendmsg: ::c_long = 4000 + 179; +pub const SYS_sendto: ::c_long = 4000 + 180; +pub const SYS_setsockopt: ::c_long = 4000 + 181; +pub const SYS_shutdown: ::c_long = 4000 + 182; +pub const SYS_socket: ::c_long = 4000 + 183; +pub const SYS_socketpair: ::c_long = 4000 + 184; +pub const SYS_setresuid: ::c_long = 4000 + 185; +pub const SYS_getresuid: ::c_long = 4000 + 186; +pub const SYS_query_module: ::c_long = 4000 + 187; +pub const SYS_poll: ::c_long = 4000 + 188; +pub const SYS_nfsservctl: ::c_long = 4000 + 189; +pub const SYS_setresgid: ::c_long = 4000 + 190; +pub const SYS_getresgid: ::c_long = 4000 + 191; +pub const SYS_prctl: ::c_long = 4000 + 192; +pub const SYS_rt_sigreturn: ::c_long = 4000 + 193; +pub const SYS_rt_sigaction: ::c_long = 4000 + 194; +pub const SYS_rt_sigprocmask: ::c_long = 4000 + 195; +pub const SYS_rt_sigpending: ::c_long = 4000 + 196; +pub const SYS_rt_sigtimedwait: ::c_long = 4000 + 197; +pub const SYS_rt_sigqueueinfo: ::c_long = 4000 + 198; +pub const SYS_rt_sigsuspend: ::c_long = 4000 + 199; +pub const SYS_pread64: ::c_long = 4000 + 200; +pub const SYS_pwrite64: ::c_long = 4000 + 201; +pub const SYS_chown: ::c_long = 4000 + 202; +pub const SYS_getcwd: ::c_long = 4000 + 203; +pub const SYS_capget: ::c_long = 4000 + 204; +pub const SYS_capset: ::c_long = 4000 + 205; +pub const SYS_sigaltstack: ::c_long = 4000 + 206; +pub const SYS_sendfile: ::c_long = 4000 + 207; +pub const SYS_getpmsg: ::c_long = 4000 + 208; +pub const SYS_putpmsg: ::c_long = 4000 + 209; +pub const SYS_mmap2: ::c_long = 4000 + 210; +pub const SYS_truncate64: ::c_long = 4000 + 211; +pub const SYS_ftruncate64: ::c_long = 4000 + 212; +pub const SYS_stat64: ::c_long = 4000 + 213; +pub const SYS_lstat64: ::c_long = 4000 + 214; +pub const SYS_fstat64: ::c_long = 4000 + 215; +pub const SYS_pivot_root: ::c_long = 4000 + 216; +pub const SYS_mincore: ::c_long = 4000 + 217; +pub const SYS_madvise: ::c_long = 4000 + 218; +pub const SYS_getdents64: ::c_long = 4000 + 219; +pub const SYS_fcntl64: ::c_long = 4000 + 220; +pub const SYS_reserved221: ::c_long = 4000 + 221; +pub const SYS_gettid: ::c_long = 4000 + 222; +pub const SYS_readahead: ::c_long = 4000 + 223; +pub const SYS_setxattr: ::c_long = 4000 + 224; +pub const SYS_lsetxattr: ::c_long = 4000 + 225; +pub const SYS_fsetxattr: ::c_long = 4000 + 226; +pub const SYS_getxattr: ::c_long = 4000 + 227; +pub const SYS_lgetxattr: ::c_long = 4000 + 228; +pub const SYS_fgetxattr: ::c_long = 4000 + 229; +pub const SYS_listxattr: ::c_long = 4000 + 230; +pub const SYS_llistxattr: ::c_long = 4000 + 231; +pub const SYS_flistxattr: ::c_long = 4000 + 232; +pub const SYS_removexattr: ::c_long = 4000 + 233; +pub const SYS_lremovexattr: ::c_long = 4000 + 234; +pub const SYS_fremovexattr: ::c_long = 4000 + 235; +pub const SYS_tkill: ::c_long = 4000 + 236; +pub const SYS_sendfile64: ::c_long = 4000 + 237; +pub const SYS_futex: ::c_long = 4000 + 238; +pub const SYS_sched_setaffinity: ::c_long = 4000 + 239; +pub const SYS_sched_getaffinity: ::c_long = 4000 + 240; +pub const SYS_io_setup: ::c_long = 4000 + 241; +pub const SYS_io_destroy: ::c_long = 4000 + 242; +pub const SYS_io_getevents: ::c_long = 4000 + 243; +pub const SYS_io_submit: ::c_long = 4000 + 244; +pub const SYS_io_cancel: ::c_long = 4000 + 245; +pub const SYS_exit_group: ::c_long = 4000 + 246; +pub const SYS_lookup_dcookie: ::c_long = 4000 + 247; +pub const SYS_epoll_create: ::c_long = 4000 + 248; +pub const SYS_epoll_ctl: ::c_long = 4000 + 249; +pub const SYS_epoll_wait: ::c_long = 4000 + 250; +pub const SYS_remap_file_pages: ::c_long = 4000 + 251; +pub const SYS_set_tid_address: ::c_long = 4000 + 252; +pub const SYS_restart_syscall: ::c_long = 4000 + 253; +pub const SYS_fadvise64: ::c_long = 4000 + 254; +pub const SYS_statfs64: ::c_long = 4000 + 255; +pub const SYS_fstatfs64: ::c_long = 4000 + 256; +pub const SYS_timer_create: ::c_long = 4000 + 257; +pub const SYS_timer_settime: ::c_long = 4000 + 258; +pub const SYS_timer_gettime: ::c_long = 4000 + 259; +pub const SYS_timer_getoverrun: ::c_long = 4000 + 260; +pub const SYS_timer_delete: ::c_long = 4000 + 261; +pub const SYS_clock_settime: ::c_long = 4000 + 262; +pub const SYS_clock_gettime: ::c_long = 4000 + 263; +pub const SYS_clock_getres: ::c_long = 4000 + 264; +pub const SYS_clock_nanosleep: ::c_long = 4000 + 265; +pub const SYS_tgkill: ::c_long = 4000 + 266; +pub const SYS_utimes: ::c_long = 4000 + 267; +pub const SYS_mbind: ::c_long = 4000 + 268; +pub const SYS_get_mempolicy: ::c_long = 4000 + 269; +pub const SYS_set_mempolicy: ::c_long = 4000 + 270; +pub const SYS_mq_open: ::c_long = 4000 + 271; +pub const SYS_mq_unlink: ::c_long = 4000 + 272; +pub const SYS_mq_timedsend: ::c_long = 4000 + 273; +pub const SYS_mq_timedreceive: ::c_long = 4000 + 274; +pub const SYS_mq_notify: ::c_long = 4000 + 275; +pub const SYS_mq_getsetattr: ::c_long = 4000 + 276; +pub const SYS_vserver: ::c_long = 4000 + 277; +pub const SYS_waitid: ::c_long = 4000 + 278; +/* pub const SYS_sys_setaltroot: ::c_long = 4000 + 279; */ +pub const SYS_add_key: ::c_long = 4000 + 280; +pub const SYS_request_key: ::c_long = 4000 + 281; +pub const SYS_keyctl: ::c_long = 4000 + 282; +pub const SYS_set_thread_area: ::c_long = 4000 + 283; +pub const SYS_inotify_init: ::c_long = 4000 + 284; +pub const SYS_inotify_add_watch: ::c_long = 4000 + 285; +pub const SYS_inotify_rm_watch: ::c_long = 4000 + 286; +pub const SYS_migrate_pages: ::c_long = 4000 + 287; +pub const SYS_openat: ::c_long = 4000 + 288; +pub const SYS_mkdirat: ::c_long = 4000 + 289; +pub const SYS_mknodat: ::c_long = 4000 + 290; +pub const SYS_fchownat: ::c_long = 4000 + 291; +pub const SYS_futimesat: ::c_long = 4000 + 292; +pub const SYS_fstatat64: ::c_long = 4000 + 293; +pub const SYS_unlinkat: ::c_long = 4000 + 294; +pub const SYS_renameat: ::c_long = 4000 + 295; +pub const SYS_linkat: ::c_long = 4000 + 296; +pub const SYS_symlinkat: ::c_long = 4000 + 297; +pub const SYS_readlinkat: ::c_long = 4000 + 298; +pub const SYS_fchmodat: ::c_long = 4000 + 299; +pub const SYS_faccessat: ::c_long = 4000 + 300; +pub const SYS_pselect6: ::c_long = 4000 + 301; +pub const SYS_ppoll: ::c_long = 4000 + 302; +pub const SYS_unshare: ::c_long = 4000 + 303; +pub const SYS_splice: ::c_long = 4000 + 304; +pub const SYS_sync_file_range: ::c_long = 4000 + 305; +pub const SYS_tee: ::c_long = 4000 + 306; +pub const SYS_vmsplice: ::c_long = 4000 + 307; +pub const SYS_move_pages: ::c_long = 4000 + 308; +pub const SYS_set_robust_list: ::c_long = 4000 + 309; +pub const SYS_get_robust_list: ::c_long = 4000 + 310; +pub const SYS_kexec_load: ::c_long = 4000 + 311; +pub const SYS_getcpu: ::c_long = 4000 + 312; +pub const SYS_epoll_pwait: ::c_long = 4000 + 313; +pub const SYS_ioprio_set: ::c_long = 4000 + 314; +pub const SYS_ioprio_get: ::c_long = 4000 + 315; +pub const SYS_utimensat: ::c_long = 4000 + 316; +pub const SYS_signalfd: ::c_long = 4000 + 317; +pub const SYS_timerfd: ::c_long = 4000 + 318; +pub const SYS_eventfd: ::c_long = 4000 + 319; +pub const SYS_fallocate: ::c_long = 4000 + 320; +pub const SYS_timerfd_create: ::c_long = 4000 + 321; +pub const SYS_timerfd_gettime: ::c_long = 4000 + 322; +pub const SYS_timerfd_settime: ::c_long = 4000 + 323; +pub const SYS_signalfd4: ::c_long = 4000 + 324; +pub const SYS_eventfd2: ::c_long = 4000 + 325; +pub const SYS_epoll_create1: ::c_long = 4000 + 326; +pub const SYS_dup3: ::c_long = 4000 + 327; +pub const SYS_pipe2: ::c_long = 4000 + 328; +pub const SYS_inotify_init1: ::c_long = 4000 + 329; +pub const SYS_preadv: ::c_long = 4000 + 330; +pub const SYS_pwritev: ::c_long = 4000 + 331; +pub const SYS_rt_tgsigqueueinfo: ::c_long = 4000 + 332; +pub const SYS_perf_event_open: ::c_long = 4000 + 333; +pub const SYS_accept4: ::c_long = 4000 + 334; +pub const SYS_recvmmsg: ::c_long = 4000 + 335; +pub const SYS_fanotify_init: ::c_long = 4000 + 336; +pub const SYS_fanotify_mark: ::c_long = 4000 + 337; +pub const SYS_prlimit64: ::c_long = 4000 + 338; +pub const SYS_name_to_handle_at: ::c_long = 4000 + 339; +pub const SYS_open_by_handle_at: ::c_long = 4000 + 340; +pub const SYS_clock_adjtime: ::c_long = 4000 + 341; +pub const SYS_syncfs: ::c_long = 4000 + 342; +pub const SYS_sendmmsg: ::c_long = 4000 + 343; +pub const SYS_setns: ::c_long = 4000 + 344; +pub const SYS_process_vm_readv: ::c_long = 4000 + 345; +pub const SYS_process_vm_writev: ::c_long = 4000 + 346; +pub const SYS_kcmp: ::c_long = 4000 + 347; +pub const SYS_finit_module: ::c_long = 4000 + 348; +pub const SYS_sched_setattr: ::c_long = 4000 + 349; +pub const SYS_sched_getattr: ::c_long = 4000 + 350; +pub const SYS_renameat2: ::c_long = 4000 + 351; +pub const SYS_seccomp: ::c_long = 4000 + 352; +pub const SYS_getrandom: ::c_long = 4000 + 353; +pub const SYS_memfd_create: ::c_long = 4000 + 354; +pub const SYS_bpf: ::c_long = 4000 + 355; +pub const SYS_execveat: ::c_long = 4000 + 356; +pub const SYS_userfaultfd: ::c_long = 4000 + 357; +pub const SYS_membarrier: ::c_long = 4000 + 358; +pub const SYS_mlock2: ::c_long = 4000 + 359; +pub const SYS_copy_file_range: ::c_long = 4000 + 360; +pub const SYS_preadv2: ::c_long = 4000 + 361; +pub const SYS_pwritev2: ::c_long = 4000 + 362; +pub const SYS_pkey_mprotect: ::c_long = 4000 + 363; +pub const SYS_pkey_alloc: ::c_long = 4000 + 364; +pub const SYS_pkey_free: ::c_long = 4000 + 365; #[link(name = "util")] extern { diff --git a/libc/src/unix/uclibc/mips/mips64.rs b/libc/src/unix/uclibc/mips/mips64.rs index 79bac1f..e35938b 100644 --- a/libc/src/unix/uclibc/mips/mips64.rs +++ b/libc/src/unix/uclibc/mips/mips64.rs @@ -188,8 +188,13 @@ s! { } // FIXME this is actually a union + #[cfg_attr(all(feature = "align", target_pointer_width = "32"), + repr(align(4)))] + #[cfg_attr(all(feature = "align", target_pointer_width = "64"), + repr(align(8)))] pub struct sem_t { __size: [::c_char; 32], + #[cfg(not(feature = "align"))] __align: [::c_long; 0], } } diff --git a/libc/src/unix/uclibc/mips/mod.rs b/libc/src/unix/uclibc/mips/mod.rs index cc3ddf2..27f6fe5 100644 --- a/libc/src/unix/uclibc/mips/mod.rs +++ b/libc/src/unix/uclibc/mips/mod.rs @@ -1,3 +1,5 @@ +pub type pthread_t = ::c_ulong; + pub const SFD_CLOEXEC: ::c_int = 0x080000; pub const NCCS: usize = 32; @@ -224,8 +226,8 @@ pub const SO_BPF_EXTENSIONS: ::c_int = 48; pub const FIOCLEX: ::c_ulong = 0x6601; pub const FIONBIO: ::c_ulong = 0x667e; -pub const SA_ONSTACK: ::c_int = 0x08000000; -pub const SA_SIGINFO: ::c_int = 0x00000008; +pub const SA_ONSTACK: ::c_uint = 0x08000000; +pub const SA_SIGINFO: ::c_uint = 0x00000008; pub const SA_NOCLDWAIT: ::c_int = 0x00010000; pub const SIGCHLD: ::c_int = 18; diff --git a/libc/src/unix/uclibc/mod.rs b/libc/src/unix/uclibc/mod.rs index 3f3a2ba..9d8e97e 100644 --- a/libc/src/unix/uclibc/mod.rs +++ b/libc/src/unix/uclibc/mod.rs @@ -11,7 +11,6 @@ pub type id_t = ::c_uint; pub type useconds_t = u32; pub type dev_t = u64; pub type socklen_t = u32; -pub type pthread_t = ::c_ulong; pub type mode_t = u32; pub type ino64_t = u64; pub type off64_t = i64; @@ -225,34 +224,80 @@ s! { pub ifa_data: *mut ::c_void } + #[cfg_attr(all(feature = "align", + target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")), + repr(align(4)))] + #[cfg_attr(all(feature = "align", + any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")))), + repr(align(8)))] pub struct pthread_mutex_t { - #[cfg(any(target_arch = "mips", target_arch = "arm", - target_arch = "powerpc"))] + #[cfg(all(not(feature = "align"), + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")))] __align: [::c_long; 0], - #[cfg(not(any(target_arch = "mips", target_arch = "arm", + #[cfg(not(any(feature = "align", + target_arch = "mips", + target_arch = "arm", target_arch = "powerpc")))] __align: [::c_longlong; 0], size: [u8; __SIZEOF_PTHREAD_MUTEX_T], } + #[cfg_attr(all(feature = "align", + target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")), + repr(align(4)))] + #[cfg_attr(all(feature = "align", + any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")))), + repr(align(8)))] pub struct pthread_rwlock_t { - #[cfg(any(target_arch = "mips", target_arch = "arm", - target_arch = "powerpc"))] + #[cfg(all(not(feature = "align"), + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")))] __align: [::c_long; 0], - #[cfg(not(any(target_arch = "mips", target_arch = "arm", + #[cfg(not(any(feature = "align", + target_arch = "mips", + target_arch = "arm", target_arch = "powerpc")))] __align: [::c_longlong; 0], size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], } + #[cfg_attr(all(feature = "align", + any(target_pointer_width = "32", + target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64")), + repr(align(4)))] + #[cfg_attr(all(feature = "align", + not(any(target_pointer_width = "32", + target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64"))), + repr(align(8)))] pub struct pthread_mutexattr_t { - #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64"))] - __align: [::c_int; 0], - #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64", + #[cfg(all(not(feature = "align"), + any(target_arch = "x86_64", target_arch = "powerpc64", target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64")))] + __align: [::c_int; 0], + #[cfg(all(not(feature = "align"), + not(any(target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64"))))] __align: [::c_long; 0], size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], } @@ -262,12 +307,16 @@ s! { __pshared: ::c_int, } + #[cfg_attr(feature = "align", repr(align(8)))] pub struct pthread_cond_t { + #[cfg(not(feature = "align"))] __align: [::c_longlong; 0], size: [u8; __SIZEOF_PTHREAD_COND_T], } + #[cfg_attr(feature = "align", repr(align(4)))] pub struct pthread_condattr_t { + #[cfg(not(feature = "align"))] __align: [::c_int; 0], size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], } @@ -342,7 +391,12 @@ s! { pub ssi_utime: ::uint64_t, pub ssi_stime: ::uint64_t, pub ssi_addr: ::uint64_t, - _pad: [::uint8_t; 48], + pub ssi_addr_lsb: ::uint16_t, + _pad2: ::uint16_t, + pub ssi_syscall: ::int32_t, + pub ssi_call_addr: ::uint64_t, + pub ssi_arch: ::uint32_t, + _pad: [::uint8_t; 28], } pub struct fsid_t { @@ -1117,18 +1171,17 @@ pub const RTLD_NOW: ::c_int = 0x2; pub const TCP_MD5SIG: ::c_int = 14; -pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { - __align: [], - size: [0; __SIZEOF_PTHREAD_MUTEX_T], -}; -pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { - __align: [], - size: [0; __SIZEOF_PTHREAD_COND_T], -}; -pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { - __align: [], - size: [0; __SIZEOF_PTHREAD_RWLOCK_T], -}; +align_const! { + pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + size: [0; __SIZEOF_PTHREAD_MUTEX_T], + }; + pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + size: [0; __SIZEOF_PTHREAD_COND_T], + }; + pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + size: [0; __SIZEOF_PTHREAD_RWLOCK_T], + }; +} pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2; @@ -1329,6 +1382,9 @@ pub const PR_GET_TID_ADDRESS: ::c_int = 40; pub const PR_SET_THP_DISABLE: ::c_int = 41; pub const PR_GET_THP_DISABLE: ::c_int = 42; +pub const GRND_NONBLOCK: ::c_uint = 0x0001; +pub const GRND_RANDOM: ::c_uint = 0x0002; + pub const ABDAY_1: ::nl_item = 0x300; pub const ABDAY_2: ::nl_item = 0x301; pub const ABDAY_3: ::nl_item = 0x302; @@ -1495,6 +1551,12 @@ f! { } extern { + pub fn abs(i: ::c_int) -> ::c_int; + pub fn atof(s: *const ::c_char) -> ::c_double; + pub fn labs(i: ::c_long) -> ::c_long; + pub fn rand() -> ::c_int; + pub fn srand(seed: ::c_uint); + pub fn fdatasync(fd: ::c_int) -> ::c_int; pub fn mincore(addr: *mut ::c_void, len: ::size_t, vec: *mut ::c_uchar) -> ::c_int; @@ -1583,6 +1645,8 @@ extern { pub fn uselocale(loc: ::locale_t) -> ::locale_t; pub fn creat64(path: *const c_char, mode: mode_t) -> ::c_int; pub fn fstat64(fildes: ::c_int, buf: *mut stat64) -> ::c_int; + pub fn fstatat64(fildes: ::c_int, path: *const ::c_char, + buf: *mut stat64, flag: ::c_int) -> ::c_int; pub fn ftruncate64(fd: ::c_int, length: off64_t) -> ::c_int; pub fn getrlimit64(resource: ::c_int, rlim: *mut rlimit64) -> ::c_int; pub fn lseek64(fd: ::c_int, offset: off64_t, whence: ::c_int) -> off64_t; @@ -1610,8 +1674,6 @@ extern { pub fn truncate64(path: *const c_char, length: off64_t) -> ::c_int; pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int; - pub fn fdopendir(fd: ::c_int) -> *mut ::DIR; - pub fn mknodat(dirfd: ::c_int, pathname: *const ::c_char, mode: ::mode_t, dev: dev_t) -> ::c_int; pub fn ppoll(fds: *mut ::pollfd, @@ -1635,6 +1697,8 @@ extern { pub fn unshare(flags: ::c_int) -> ::c_int; pub fn sem_timedwait(sem: *mut sem_t, abstime: *const ::timespec) -> ::c_int; + pub fn sem_getvalue(sem: *mut sem_t, + sval: *mut ::c_int) -> ::c_int; pub fn accept4(fd: ::c_int, addr: *mut ::sockaddr, len: *mut ::socklen_t, flg: ::c_int) -> ::c_int; pub fn pthread_mutex_timedlock(lock: *mut pthread_mutex_t, @@ -1802,6 +1866,8 @@ extern { pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long); + pub fn dirfd(dirp: *mut ::DIR) -> ::c_int; + pub fn telldir(dirp: *mut ::DIR) -> ::c_long; pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int; @@ -1890,7 +1956,7 @@ extern { } cfg_if! { - if #[cfg(target_arch = "mips")] { + if #[cfg(any(target_arch = "mips", target_arch = "mips64"))] { mod mips; pub use self::mips::*; } else if #[cfg(target_arch = "x86_64")] { diff --git a/libc/src/unix/uclibc/x86_64/l4re.rs b/libc/src/unix/uclibc/x86_64/l4re.rs index f047a82..4f5811d 100644 --- a/libc/src/unix/uclibc/x86_64/l4re.rs +++ b/libc/src/unix/uclibc/x86_64/l4re.rs @@ -4,6 +4,7 @@ /// libc and hence we should provide them here. pub type l4_umword_t = ::c_ulong; // Unsigned machine word. +pub type pthread_t = *mut ::c_void; s! { /// CPU sets. diff --git a/libc/src/unix/uclibc/x86_64/mod.rs b/libc/src/unix/uclibc/x86_64/mod.rs index 7d08258..bc6571a 100644 --- a/libc/src/unix/uclibc/x86_64/mod.rs +++ b/libc/src/unix/uclibc/x86_64/mod.rs @@ -133,6 +133,7 @@ s! { // // pub struct in6_addr { // pub s6_addr: [u8; 16], +// #[cfg(not(feature = "align"))] // __align: [u32; 0], // } @@ -204,51 +205,106 @@ s! { pub c_cc: [::cc_t; ::NCCS], } + #[cfg_attr(all(feature = "align", target_pointer_width = "32"), + repr(align(4)))] + #[cfg_attr(all(feature = "align", target_pointer_width = "64"), + repr(align(8)))] pub struct sem_t { // ToDo #[cfg(target_pointer_width = "32")] __size: [::c_char; 16], #[cfg(target_pointer_width = "64")] __size: [::c_char; 32], + #[cfg(not(feature = "align"))] __align: [::c_long; 0], } + #[cfg_attr(all(feature = "align", + target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")), + repr(align(4)))] + #[cfg_attr(all(feature = "align", + any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")))), + repr(align(8)))] pub struct pthread_mutex_t { // ToDo - #[cfg(any(target_arch = "mips", target_arch = "arm", - target_arch = "powerpc"))] + #[cfg(all(not(feature = "align"), + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")))] __align: [::c_long; 0], - #[cfg(not(any(target_arch = "mips", target_arch = "arm", + #[cfg(not(any(feature = "align", + target_arch = "mips", + target_arch = "arm", target_arch = "powerpc")))] __align: [::c_longlong; 0], size: [u8; __SIZEOF_PTHREAD_MUTEX_T], } + #[cfg_attr(all(feature = "align", + any(target_pointer_width = "32", + target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64")), + repr(align(4)))] + #[cfg_attr(all(feature = "align", + not(any(target_pointer_width = "32", + target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64"))), + repr(align(8)))] pub struct pthread_mutexattr_t { // ToDo - #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64"))] - __align: [::c_int; 0], - #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64", + #[cfg(all(not(feature = "align"), + any(target_arch = "x86_64", target_arch = "powerpc64", target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64")))] + __align: [::c_int; 0], + #[cfg(all(not(feature = "align"), + not(any(target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64"))))] __align: [::c_long; 0], size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], } + #[cfg_attr(feature = "align", repr(align(8)))] pub struct pthread_cond_t { // ToDo + #[cfg(not(feature = "align"))] __align: [::c_longlong; 0], size: [u8; __SIZEOF_PTHREAD_COND_T], } + #[cfg_attr(feature = "align", repr(align(4)))] pub struct pthread_condattr_t { // ToDo + #[cfg(not(feature = "align"))] __align: [::c_int; 0], size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], } + #[cfg_attr(all(feature = "align", + target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")), + repr(align(4)))] + #[cfg_attr(all(feature = "align", + any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")))), + repr(align(8)))] pub struct pthread_rwlock_t { // ToDo - #[cfg(any(target_arch = "mips", target_arch = "arm", - target_arch = "powerpc"))] + #[cfg(all(not(feature = "align"), + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")))] __align: [::c_long; 0], - #[cfg(not(any(target_arch = "mips", target_arch = "arm", + #[cfg(not(any(feature = "align", + target_arch = "mips", + target_arch = "arm", target_arch = "powerpc")))] __align: [::c_longlong; 0], size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], @@ -352,6 +408,9 @@ cfg_if! { if #[cfg(target_os = "l4re")] { mod l4re; pub use self::l4re::*; - } else { } + } else { + mod other; + pub use other::*; + } } diff --git a/libc/src/unix/uclibc/x86_64/other.rs b/libc/src/unix/uclibc/x86_64/other.rs new file mode 100644 index 0000000..1cc521d --- /dev/null +++ b/libc/src/unix/uclibc/x86_64/other.rs @@ -0,0 +1,4 @@ +// Thestyle checker discourages the use of #[cfg], so this has to go into a +// separate module +pub type pthread_t = ::c_ulong; + diff --git a/libc/src/windows/gnu.rs b/libc/src/windows/gnu.rs new file mode 100644 index 0000000..a67af15 --- /dev/null +++ b/libc/src/windows/gnu.rs @@ -0,0 +1,8 @@ +pub const L_tmpnam: ::c_uint = 14; +pub const TMP_MAX: ::c_uint = 0x7fff; + +extern { + pub fn strcasecmp(s1: *const ::c_char, s2: *const ::c_char) -> ::c_int; + pub fn strncasecmp(s1: *const ::c_char, s2: *const ::c_char, + n: ::size_t) -> ::c_int; +} diff --git a/libc/src/windows.rs b/libc/src/windows/mod.rs index bdb0e02..f46eb36 100644 --- a/libc/src/windows.rs +++ b/libc/src/windows/mod.rs @@ -1,5 +1,33 @@ //! Windows CRT definitions +pub type int8_t = i8; +pub type int16_t = i16; +pub type int32_t = i32; +pub type int64_t = i64; +pub type uint8_t = u8; +pub type uint16_t = u16; +pub type uint32_t = u32; +pub type uint64_t = u64; + +pub type c_schar = i8; +pub type c_uchar = u8; +pub type c_short = i16; +pub type c_ushort = u16; +pub type c_int = i32; +pub type c_uint = u32; +pub type c_float = f32; +pub type c_double = f64; +pub type c_longlong = i64; +pub type c_ulonglong = u64; +pub type intmax_t = i64; +pub type uintmax_t = u64; + +pub type size_t = usize; +pub type ptrdiff_t = isize; +pub type intptr_t = isize; +pub type uintptr_t = usize; +pub type ssize_t = isize; + pub type c_char = i8; pub type c_long = i32; pub type c_ulong = u32; @@ -66,6 +94,9 @@ s! { } } +pub const INT_MIN: c_int = -2147483648; +pub const INT_MAX: c_int = 2147483647; + pub const EXIT_FAILURE: ::c_int = 1; pub const EXIT_SUCCESS: ::c_int = 0; pub const RAND_MAX: ::c_int = 32767; @@ -80,18 +111,6 @@ pub const BUFSIZ: ::c_uint = 512; pub const FOPEN_MAX: ::c_uint = 20; pub const FILENAME_MAX: ::c_uint = 260; -cfg_if! { - if #[cfg(all(target_env = "gnu"))] { - pub const L_tmpnam: ::c_uint = 14; - pub const TMP_MAX: ::c_uint = 0x7fff; - } else if #[cfg(all(target_env = "msvc"))] { - pub const L_tmpnam: ::c_uint = 260; - pub const TMP_MAX: ::c_uint = 0x7fff_ffff; - } else { - // Unknown target_env - } -} - pub const O_RDONLY: ::c_int = 0; pub const O_WRONLY: ::c_int = 1; pub const O_RDWR: ::c_int = 2; @@ -159,12 +178,115 @@ pub const EILSEQ: ::c_int = 42; pub const STRUNCATE: ::c_int = 80; // inline comment below appeases style checker -#[cfg(all(target_env = "msvc", feature = "stdbuild"))] // " if " +#[cfg(all(target_env = "msvc", feature = "rustc-dep-of-std"))] // " if " #[link(name = "msvcrt", cfg(not(target_feature = "crt-static")))] #[link(name = "libcmt", cfg(target_feature = "crt-static"))] extern {} +pub enum FILE {} +pub enum fpos_t {} // TODO: fill this out with a struct + extern { + pub fn isalnum(c: c_int) -> c_int; + pub fn isalpha(c: c_int) -> c_int; + pub fn iscntrl(c: c_int) -> c_int; + pub fn isdigit(c: c_int) -> c_int; + pub fn isgraph(c: c_int) -> c_int; + pub fn islower(c: c_int) -> c_int; + pub fn isprint(c: c_int) -> c_int; + pub fn ispunct(c: c_int) -> c_int; + pub fn isspace(c: c_int) -> c_int; + pub fn isupper(c: c_int) -> c_int; + pub fn isxdigit(c: c_int) -> c_int; + pub fn tolower(c: c_int) -> c_int; + pub fn toupper(c: c_int) -> c_int; + pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE; + pub fn freopen(filename: *const c_char, mode: *const c_char, + file: *mut FILE) -> *mut FILE; + pub fn fflush(file: *mut FILE) -> c_int; + pub fn fclose(file: *mut FILE) -> c_int; + pub fn remove(filename: *const c_char) -> c_int; + pub fn rename(oldname: *const c_char, newname: *const c_char) -> c_int; + pub fn tmpfile() -> *mut FILE; + pub fn setvbuf(stream: *mut FILE, buffer: *mut c_char, mode: c_int, + size: size_t) -> c_int; + pub fn setbuf(stream: *mut FILE, buf: *mut c_char); + pub fn getchar() -> c_int; + pub fn putchar(c: c_int) -> c_int; + pub fn fgetc(stream: *mut FILE) -> c_int; + pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char; + pub fn fputc(c: c_int, stream: *mut FILE) -> c_int; + pub fn fputs(s: *const c_char, stream: *mut FILE) -> c_int; + pub fn puts(s: *const c_char) -> c_int; + pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int; + pub fn fread(ptr: *mut c_void, size: size_t, nobj: size_t, + stream: *mut FILE) -> size_t; + pub fn fwrite(ptr: *const c_void, size: size_t, nobj: size_t, + stream: *mut FILE) -> size_t; + pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int; + pub fn ftell(stream: *mut FILE) -> c_long; + pub fn rewind(stream: *mut FILE); + pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int; + pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int; + pub fn feof(stream: *mut FILE) -> c_int; + pub fn ferror(stream: *mut FILE) -> c_int; + pub fn perror(s: *const c_char); + pub fn atoi(s: *const c_char) -> c_int; + pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double; + pub fn strtol(s: *const c_char, endp: *mut *mut c_char, + base: c_int) -> c_long; + pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, + base: c_int) -> c_ulong; + pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; + pub fn malloc(size: size_t) -> *mut c_void; + pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; + pub fn free(p: *mut c_void); + pub fn abort() -> !; + pub fn exit(status: c_int) -> !; + pub fn _exit(status: c_int) -> !; + pub fn atexit(cb: extern fn()) -> c_int; + pub fn system(s: *const c_char) -> c_int; + pub fn getenv(s: *const c_char) -> *mut c_char; + + pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char; + pub fn strncpy(dst: *mut c_char, src: *const c_char, + n: size_t) -> *mut c_char; + pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char; + pub fn strncat(s: *mut c_char, ct: *const c_char, + n: size_t) -> *mut c_char; + pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strncmp(cs: *const c_char, ct: *const c_char, n: size_t) -> c_int; + pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strdup(cs: *const c_char) -> *mut c_char; + pub fn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn strlen(cs: *const c_char) -> size_t; + pub fn strnlen(cs: *const c_char, maxlen: size_t) -> size_t; + pub fn strerror(n: c_int) -> *mut c_char; + pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char; + pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t; + pub fn wcslen(buf: *const wchar_t) -> size_t; + pub fn wcstombs(dest: *mut c_char, src: *const wchar_t, + n: size_t) -> ::size_t; + + pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; + pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int; + pub fn memcpy(dest: *mut c_void, src: *const c_void, + n: size_t) -> *mut c_void; + pub fn memmove(dest: *mut c_void, src: *const c_void, + n: size_t) -> *mut c_void; + pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void; + + pub fn abs(i: c_int) -> c_int; + pub fn atof(s: *const c_char) -> c_double; + pub fn labs(i: c_long) -> c_long; + pub fn rand() -> c_int; + pub fn srand(seed: c_uint); + #[link_name = "_chmod"] pub fn chmod(path: *const c_char, mode: ::c_int) -> ::c_int; #[link_name = "_wchmod"] @@ -246,3 +368,33 @@ extern { pub fn wsetlocale(category: ::c_int, locale: *const wchar_t) -> *mut wchar_t; } + +cfg_if! { + if #[cfg(core_cvoid)] { + pub use core::ffi::c_void; + } else { + // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help + // enable more optimization opportunities around it recognizing things + // like malloc/free. + #[repr(u8)] + pub enum c_void { + // Two dummy variants so the #[repr] attribute can be used. + #[doc(hidden)] + __variant1, + #[doc(hidden)] + __variant2, + } + } +} + +cfg_if! { + if #[cfg(all(target_env = "gnu"))] { + mod gnu; + pub use self::gnu::*; + } else if #[cfg(all(target_env = "msvc"))] { + mod msvc; + pub use self::msvc::*; + } else { + // Unknown target_env + } +}
\ No newline at end of file diff --git a/libc/src/windows/msvc.rs b/libc/src/windows/msvc.rs new file mode 100644 index 0000000..9e2a9b9 --- /dev/null +++ b/libc/src/windows/msvc.rs @@ -0,0 +1,10 @@ +pub const L_tmpnam: ::c_uint = 260; +pub const TMP_MAX: ::c_uint = 0x7fff_ffff; + +extern { + #[link_name = "_stricmp"] + pub fn stricmp(s1: *const ::c_char, s2: *const ::c_char) -> ::c_int; + #[link_name = "_strnicmp"] + pub fn strnicmp(s1: *const ::c_char, s2: *const ::c_char, + n: ::size_t) -> ::c_int; +}
\ No newline at end of file |